ima2-gen 1.1.20 → 1.1.21

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 (93) hide show
  1. package/README.md +15 -25
  2. package/bin/commands/capabilities.js +2 -2
  3. package/bin/commands/capabilities.ts +2 -2
  4. package/bin/commands/defaults.js +2 -2
  5. package/bin/commands/defaults.ts +2 -2
  6. package/bin/commands/doctor.js +3 -3
  7. package/bin/commands/doctor.ts +3 -3
  8. package/bin/commands/edit.js +1 -1
  9. package/bin/commands/edit.ts +1 -1
  10. package/bin/commands/gen.js +1 -1
  11. package/bin/commands/gen.ts +1 -1
  12. package/bin/commands/grok.js +16 -11
  13. package/bin/commands/grok.ts +16 -11
  14. package/bin/commands/multimode.js +1 -1
  15. package/bin/commands/multimode.ts +1 -1
  16. package/bin/commands/observability.js +2 -2
  17. package/bin/commands/observability.ts +2 -2
  18. package/bin/commands/video.js +335 -13
  19. package/bin/commands/video.ts +249 -12
  20. package/bin/ima2.js +9 -9
  21. package/bin/ima2.ts +9 -9
  22. package/bin/lib/error-hints.js +2 -2
  23. package/bin/lib/error-hints.ts +2 -2
  24. package/docs/API.md +112 -3
  25. package/docs/CLI.md +61 -7
  26. package/docs/FAQ.ko.md +15 -20
  27. package/docs/FAQ.md +14 -19
  28. package/docs/NPX_QUICKSTART.md +40 -0
  29. package/docs/PROMPT_STUDIO.ko.md +1 -1
  30. package/docs/PROMPT_STUDIO.md +1 -1
  31. package/docs/README.ja.md +6 -16
  32. package/docs/README.ko.md +10 -20
  33. package/docs/README.zh-CN.md +7 -17
  34. package/docs/migration/runtime-test-inventory.md +8 -1
  35. package/lib/agentRuntime.js +19 -5
  36. package/lib/agentRuntime.ts +17 -5
  37. package/lib/capabilities.js +1 -1
  38. package/lib/capabilities.ts +1 -1
  39. package/lib/generationErrors.js +1 -1
  40. package/lib/generationErrors.ts +1 -1
  41. package/lib/grokProxyLauncher.js +26 -3
  42. package/lib/grokProxyLauncher.ts +27 -3
  43. package/lib/grokVideoAdapter.js +18 -89
  44. package/lib/grokVideoAdapter.ts +27 -88
  45. package/lib/grokVideoCanvas.js +25 -0
  46. package/lib/grokVideoCanvas.ts +26 -0
  47. package/lib/grokVideoDownload.js +58 -0
  48. package/lib/grokVideoDownload.ts +59 -0
  49. package/lib/grokVideoPlannerPrompt.js +64 -0
  50. package/lib/grokVideoPlannerPrompt.ts +67 -0
  51. package/lib/historyList.js +7 -1
  52. package/lib/historyList.ts +5 -1
  53. package/lib/oauthLauncher.js +21 -6
  54. package/lib/oauthLauncher.ts +22 -6
  55. package/lib/videoContinuity.js +149 -0
  56. package/lib/videoContinuity.ts +180 -0
  57. package/lib/videoFrameExtract.js +80 -0
  58. package/lib/videoFrameExtract.ts +78 -0
  59. package/node_modules/progrok/dist/index.js +187 -88
  60. package/node_modules/progrok/dist/index.js.map +1 -1
  61. package/node_modules/progrok/package.json +1 -1
  62. package/node_modules/progrok/skills/progrok/SKILL.md +33 -4
  63. package/package.json +2 -2
  64. package/routes/index.js +4 -0
  65. package/routes/index.ts +4 -0
  66. package/routes/quota.js +66 -0
  67. package/routes/quota.ts +89 -0
  68. package/routes/video.js +77 -15
  69. package/routes/video.ts +82 -14
  70. package/routes/videoExtended.js +293 -0
  71. package/routes/videoExtended.ts +284 -0
  72. package/server.js +6 -2
  73. package/server.ts +5 -2
  74. package/skills/ima2/SKILL.md +320 -7
  75. package/ui/dist/.vite/manifest.json +12 -12
  76. package/ui/dist/assets/{AgentWorkspace-DS8uvoLI.js → AgentWorkspace-B_hq9CLg.js} +2 -2
  77. package/ui/dist/assets/{CardNewsWorkspace-CYxMsE67.js → CardNewsWorkspace-wD12J7qk.js} +1 -1
  78. package/ui/dist/assets/{NodeCanvas-DccIc347.js → NodeCanvas-CI_wuPMf.js} +1 -1
  79. package/ui/dist/assets/{PromptBuilderPanel-BvxxwSJp.js → PromptBuilderPanel-CUTujJUV.js} +1 -1
  80. package/ui/dist/assets/{PromptImportDialog-u1_BFDRd.js → PromptImportDialog-CUi66jPK.js} +2 -2
  81. package/ui/dist/assets/{PromptImportDiscoverySection-C5uvkVSz.js → PromptImportDiscoverySection-Cm3vrjY4.js} +1 -1
  82. package/ui/dist/assets/{PromptImportFolderSection-D3E_O1SD.js → PromptImportFolderSection-DOtWTD9n.js} +1 -1
  83. package/ui/dist/assets/{PromptLibraryPanel-4gyf9CB9.js → PromptLibraryPanel-BMjQegRa.js} +2 -2
  84. package/ui/dist/assets/SettingsWorkspace-PiaVnsdA.js +1 -0
  85. package/ui/dist/assets/{index-DoKtXbod.js → index-31uVIdt4.js} +1 -1
  86. package/ui/dist/assets/index-CjgnNtgt.css +1 -0
  87. package/ui/dist/assets/index-Da2s4_-5.js +36 -0
  88. package/ui/dist/index.html +2 -2
  89. package/vendor/progrok-0.2.0.tgz +0 -0
  90. package/ui/dist/assets/SettingsWorkspace-F3eNu3mJ.js +0 -1
  91. package/ui/dist/assets/index-B6tcw_UF.css +0 -1
  92. package/ui/dist/assets/index-DYOh6gQD.js +0 -32
  93. package/vendor/progrok-0.1.1.tgz +0 -0
@@ -1,4 +1,4 @@
1
- import{r as Sr,g as ma,R as ya,a as T,j as E,u as Xn,b as J,i as gn,S as xa,f as wa,c as va,n as ba,d as _a,e as Ea}from"./index-DYOh6gQD.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 Na={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 Sa(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=Sa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Ca(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]=xo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=xo(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 Ca(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function xo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Na,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var kn="http://www.w3.org/1999/xhtml";const wo={svg:"http://www.w3.org/2000/svg",xhtml:kn,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)),wo.hasOwnProperty(t)?{space:wo[t],local:e}:e}function Ma(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===kn&&t.documentElement.namespaceURI===kn?t.createElement(e):t.createElementNS(n,e)}}function Ia(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cr(e){var t=Jt(e);return(t.local?Ia:Ma)(t)}function ka(){}function Yn(e){return e==null?ka:function(){return this.querySelector(e)}}function Aa(e){typeof e!="function"&&(e=Yn(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 Pa(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $a(){return[]}function Mr(e){return e==null?$a:function(){return this.querySelectorAll(e)}}function Da(e){return function(){return Pa(e.apply(this,arguments))}}function Ta(e){typeof e=="function"?e=Da(e):e=Mr(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 Ir(e){return function(){return this.matches(e)}}function kr(e){return function(t){return t.matches(e)}}var Ra=Array.prototype.find;function za(e){return function(){return Ra.call(this.children,e)}}function Ha(){return this.firstElementChild}function La(e){return this.select(e==null?Ha:za(typeof e=="function"?e:kr(e)))}var Ba=Array.prototype.filter;function Va(){return Array.from(this.children)}function Oa(e){return function(){return Ba.call(this.children,e)}}function ja(e){return this.selectAll(e==null?Va:Oa(typeof e=="function"?e:kr(e)))}function Fa(e){typeof e!="function"&&(e=Ir(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 Ar(e){return new Array(e.length)}function Xa(){return new ue(this._enter||this._groups.map(Ar),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 Ya(e){return function(){return e}}function Wa(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 Za(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 Ga(e){return e.__data__}function qa(e,t){if(!arguments.length)return Array.from(this,Ga);var n=t?Za:Wa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ya(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=Ua(e.call(d,d&&d.__data__,c,o)),g=h.length,y=a[c]=new Array(g),x=s[c]=new Array(g),m=l[c]=new Array(f);n(d,u,y,x,m,h,t);for(var b=0,p=0,w,S;b<g;++b)if(w=y[b]){for(b>=p&&(p=b+1);!(S=x[p])&&++p<g;);w._next=S||null}}return s=new ue(s,o),s._enter=a,s._exit=l,s}function Ua(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ka(){return new ue(this._exit||this._groups.map(Ar),this._parents)}function Qa(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 Ja(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 ec(){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 tc(e){e||(e=nc);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 nc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function oc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rc(){return Array.from(this)}function ic(){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 sc(){let e=0;for(const t of this)++e;return e}function ac(){return!this.node()}function cc(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 lc(e){return function(){this.removeAttribute(e)}}function uc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dc(e,t){return function(){this.setAttribute(e,t)}}function fc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gc(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 pc(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?uc:lc:typeof t=="function"?n.local?gc:hc:n.local?fc:dc)(n,t))}function Pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mc(e){return function(){this.style.removeProperty(e)}}function yc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function wc(e,t,n){return arguments.length>1?this.each((t==null?mc:typeof t=="function"?xc:yc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Pr(e).getComputedStyle(e,null).getPropertyValue(t)}function vc(e){return function(){delete this[e]}}function bc(e,t){return function(){this[e]=t}}function _c(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ec(e,t){return arguments.length>1?this.each((t==null?vc:typeof t=="function"?_c:bc)(e,t)):this.node()[e]}function $r(e){return e.trim().split(/^|\s+/)}function Wn(e){return e.classList||new Dr(e)}function Dr(e){this._node=e,this._names=$r(e.getAttribute("class")||"")}Dr.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 Tr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Rr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Nc(e){return function(){Tr(this,e)}}function Sc(e){return function(){Rr(this,e)}}function Cc(e,t){return function(){(t.apply(this,arguments)?Tr:Rr)(this,e)}}function Mc(e,t){var n=$r(e+"");if(arguments.length<2){for(var o=Wn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Cc:t?Nc:Sc)(n,t))}function Ic(){this.textContent=""}function kc(e){return function(){this.textContent=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Pc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Ac:kc)(e)):this.node().textContent}function $c(){this.innerHTML=""}function Dc(e){return function(){this.innerHTML=e}}function Tc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Rc(e){return arguments.length?this.each(e==null?$c:(typeof e=="function"?Tc:Dc)(e)):this.node().innerHTML}function zc(){this.nextSibling&&this.parentNode.appendChild(this)}function Hc(){return this.each(zc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Bc(){return this.each(Lc)}function Vc(e){var t=typeof e=="function"?e:Cr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function jc(e,t){var n=typeof e=="function"?e:Cr(e),o=t==null?Oc:typeof t=="function"?t:Yn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Fc(){var e=this.parentNode;e&&e.removeChild(this)}function Xc(){return this.each(Fc)}function Yc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Wc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Zc(e){return this.select(e?Wc:Yc)}function Gc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qc(e){return function(t){e.call(this,t,this.__data__)}}function Uc(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 Kc(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 Qc(e,t,n){return function(){var o=this.__on,r,i=qc(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 Jc(e,t,n){var o=Uc(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?Qc:Kc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function zr(e,t,n){var o=Pr(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 el(e,t){return function(){return zr(this,e,t)}}function tl(e,t){return function(){return zr(this,e,t.apply(this,arguments))}}function nl(e,t){return this.each((typeof t=="function"?tl:el)(e,t))}function*ol(){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 Hr=[null];function ue(e,t){this._groups=e,this._parents=t}function xt(){return new ue([[document.documentElement]],Hr)}function rl(){return this}ue.prototype=xt.prototype={constructor:ue,select:Aa,selectAll:Ta,selectChild:La,selectChildren:ja,filter:Fa,data:qa,enter:Xa,exit:Ka,join:Qa,merge:Ja,selection:rl,order:ec,sort:tc,call:oc,nodes:rc,node:ic,size:sc,empty:ac,each:cc,attr:pc,style:wc,property:Ec,classed:Mc,text:Pc,html:Rc,raise:Hc,lower:Bc,append:Vc,insert:jc,remove:Xc,clone:Zc,datum:Gc,on:Jc,dispatch:nl,[Symbol.iterator]:ol};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Hr)}function il(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=il(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 sl={passive:!1},lt={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Xe(e){e.preventDefault(),e.stopImmediatePropagation()}function Lr(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 Br(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 An(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}})}An.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function al(e){return!e.ctrlKey&&!e.button}function cl(){return this.parentNode}function ll(e,t){return t??{x:e.x,y:e.y}}function ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vr(){var e=al,t=cl,n=ll,o=ul,r={},i=Qt("start","drag","end"),s=0,a,l,c,d,u=0;function f(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",m,sl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,S){if(!(d||!e.call(this,w,S))){var N=p(this,t.call(this,w,S),w,S,"mouse");N&&(le(w.view).on("mousemove.drag",g,lt).on("mouseup.drag",y,lt),Lr(w.view),pn(w),c=!1,a=w.clientX,l=w.clientY,N("start",w))}}function g(w){if(Xe(w),!c){var S=w.clientX-a,N=w.clientY-l;c=S*S+N*N>u}r.mouse("drag",w)}function y(w){le(w.view).on("mousemove.drag mouseup.drag",null),Br(w.view,c),Xe(w),r.mouse("end",w)}function x(w,S){if(e.call(this,w,S)){var N=w.changedTouches,_=t.call(this,w,S),I=N.length,$,O;for($=0;$<I;++$)(O=p(this,_,w,S,N[$].identifier,N[$]))&&(pn(w),O("start",w,N[$]))}}function m(w){var S=w.changedTouches,N=S.length,_,I;for(_=0;_<N;++_)(I=r[S[_].identifier])&&(Xe(w),I("drag",w,S[_]))}function b(w){var S=w.changedTouches,N=S.length,_,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<N;++_)(I=r[S[_].identifier])&&(pn(w),I("end",w,S[_]))}function p(w,S,N,_,I,$){var O=i.copy(),A=de($||N,S),R,V,v;if((v=n.call(w,new An("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,w,new An(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(w){return arguments.length?(e=typeof w=="function"?w:Ct(!!w),f):e},f.container=function(w){return arguments.length?(t=typeof w=="function"?w:Ct(w),f):t},f.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Ct(w),f):n},f.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:Ct(!!w),f):o},f.on=function(){var w=i.on.apply(i,arguments);return w===i?f:w},f.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,f):Math.sqrt(u)},f}function Zn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Or(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*",dl=/^#([0-9a-f]{3,8})$/,fl=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),hl=new RegExp(`^rgb\\(${ye},${ye},${ye}\\)$`),gl=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${dt}\\)$`),pl=new RegExp(`^rgba\\(${ye},${ye},${ye},${dt}\\)$`),ml=new RegExp(`^hsl\\(${dt},${ye},${ye}\\)$`),yl=new RegExp(`^hsla\\(${dt},${ye},${ye},${dt}\\)$`),vo={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};Zn(wt,Re,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bo,formatHex:bo,formatHex8:xl,formatHsl:wl,formatRgb:_o,toString:_o});function bo(){return this.rgb().formatHex()}function xl(){return this.rgb().formatHex8()}function wl(){return jr(this).formatHsl()}function _o(){return this.rgb().formatRgb()}function Re(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=dl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Eo(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=fl.exec(e))?new ce(t[1],t[2],t[3],1):(t=hl.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gl.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=pl.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ml.exec(e))?Co(t[1],t[2]/100,t[3]/100,1):(t=yl.exec(e))?Co(t[1],t[2]/100,t[3]/100,t[4]):vo.hasOwnProperty(e)?Eo(vo[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function Eo(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 vl(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 Pn(e,t,n,o){return arguments.length===1?vl(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}Zn(ce,Pn,Or(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:No,formatHex:No,formatHex8:bl,formatRgb:So,toString:So}));function No(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function bl(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function So(){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 Co(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 jr(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 _l(e,t,n,o){return arguments.length===1?jr(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}Zn(fe,_l,Or(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(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new fe(Mo(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("}${Mo(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Mo(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function mn(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 Gn=e=>()=>e;function El(e,t){return function(n){return e+n*t}}function Nl(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 Sl(e){return(e=+e)==1?Fr:function(t,n){return n-t?Nl(t,n,e):Gn(isNaN(t)?n:t)}}function Fr(e,t){var n=t-e;return n?El(e,n):Gn(isNaN(e)?t:e)}const Xt=(function e(t){var n=Sl(t);function o(r,i){var s=n((r=Pn(r)).r,(i=Pn(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=Fr(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 Cl(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 Ml(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Il(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 kl(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 Al(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 $n=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp($n.source,"g");function Pl(e){return function(){return e}}function $l(e){return function(t){return e(t)+""}}function Xr(e,t){var n=$n.lastIndex=yn.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=$n.exec(e))&&(r=yn.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=yn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?$l(l[0].x):Pl(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"?Gn(t):(n==="number"?me:n==="string"?(o=Re(t))?(t=o,Xt):Xr:t instanceof Re?Xt:t instanceof Date?kl:Ml(t)?Cl:Array.isArray(t)?Il:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Al:me)(e,t)}var Io=180/Math.PI,Dn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yr(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)*Io,skewX:Math.atan(l)*Io,scaleX:s,scaleY:a}}var kt;function Dl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Dn:Yr(t.a,t.b,t.c,t.d,t.e,t.f)}function Tl(e){return e==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),!(e=kt.transform.baseVal.consolidate()))?Dn:(e=e.matrix,Yr(e.a,e.b,e.c,e.d,e.e,e.f))}function Wr(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,x;++g<y;)u[(x=f[g]).i]=x.x(h);return u.join("")}}}var Rl=Wr(Dl,"px, ","px)","deg)"),zl=Wr(Tl,", ",")",")"),Hl=1e-12;function ko(e){return((e=Math.exp(e))+1/e)/2}function Ll(e){return((e=Math.exp(e))-1/e)/2}function Bl(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,x,m;if(y<Hl)m=Math.log(f/c)/t,x=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),w=(f*f-c*c-o*y)/(2*f*n*b),S=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(w*w+1)-w);m=(N-S)/t,x=function(_){var I=_*m,$=ko(S),O=c/(n*b)*($*Bl(t*I+S)-Ll(S));return[a+O*h,l+O*g,c*$/ko(t*I+S)]}}return x.duration=m*1e3*t/Math.SQRT2,x}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,Zr=1e3,Yt,st,Wt=0,ze=0,en=0,ft=typeof performance=="object"&&performance.now?performance:Date,Gr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qn(){return ze||(Gr(Vl),ze=ft.now()+en)}function Vl(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=qr.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Yt=this,st=this),this._call=e,this._time=n,Tn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Tn())}};function qr(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Ol(){qn(),++Ze;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Ao(){ze=(Wt=ft.now())+en,Ze=it=0;try{Ol()}finally{Ze=0,Fl(),ze=0}}function jl(){var e=ft.now(),t=e-Wt;t>Zr&&(en-=t,Wt=e)}function Fl(){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,Tn(o)}function Tn(e){if(!Ze){it&&(it=clearTimeout(it));var t=e-ze;t>24?(e<1/0&&(it=setTimeout(Ao,e-ft.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Wt=ft.now(),ot=setInterval(jl,Zr)),Ze=1,Gr(Ao))}}function Po(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 Xl=Qt("start","end","cancel","interrupt"),Yl=[],Ur=0,$o=1,Rn=2,Ht=3,Do=4,zn=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;Wl(e,n,{name:t,index:o,group:r,on:Xl,tween:Yl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ur})}function Un(e,t){var n=pe(e,t);if(n.state>Ur)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 Wl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=qr(i,0,n.time);function i(c){n.state=$o,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!==$o)return l();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Ht)return Po(s);h.state===Do?(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(Po(function(){n.state===Ht&&(n.state=Do,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Rn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Rn){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=zn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);n.state===zn&&(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>Rn&&o.state<zn,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 Zl(e){return this.each(function(){Bt(this,e)})}function Gl(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 ql(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 Ul(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?Gl:ql)(n,e,t))}function Kn(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 Kr(e,t){var n;return(typeof t=="number"?me:t instanceof Re?Xt:(n=Re(t))?(t=n,Xt):Xr)(e,t)}function Kl(e){return function(){this.removeAttribute(e)}}function Ql(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jl(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 eu(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 tu(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 nu(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 ou(e,t){var n=Jt(e),o=n==="transform"?zl:Kr;return this.attrTween(e,typeof t=="function"?(n.local?nu:tu)(n,o,Kn(this,"attr."+e,t)):t==null?(n.local?Ql:Kl)(n):(n.local?eu:Jl)(n,o,t))}function ru(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function iu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function su(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&iu(e,i)),n}return r._value=t,r}function au(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ru(e,i)),n}return r._value=t,r}function cu(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?su:au)(o,t))}function lu(e,t){return function(){Un(this,e).delay=+t.apply(this,arguments)}}function uu(e,t){return t=+t,function(){Un(this,e).delay=t}}function du(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lu:uu)(t,e)):pe(this.node(),t).delay}function fu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function hu(e,t){return t=+t,function(){we(this,e).duration=t}}function gu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fu:hu)(t,e)):pe(this.node(),t).duration}function pu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function mu(e){var t=this._id;return arguments.length?this.each(pu(t,e)):pe(this.node(),t).ease}function yu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function xu(e){if(typeof e!="function")throw new Error;return this.each(yu(this._id,e))}function wu(e){typeof e!="function"&&(e=Ir(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 vu(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 bu(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 _u(e,t,n){var o,r,i=bu(t)?Un:we;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Eu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(_u(n,e,t))}function Nu(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Su(){return this.on("end.remove",Nu(this._id))}function Cu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yn(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 Mu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(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,x=f.length;y<x;++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 Iu=xt.prototype.constructor;function ku(){return new Iu(this._groups,this._parents)}function Au(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 Qr(e){return function(){this.style.removeProperty(e)}}function Pu(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 $u(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 Du(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=Qr(t)):void 0;(c!==n||r!==d)&&(o=(n=c).copy()).on(s,r=d),l.on=o}}function Tu(e,t,n){var o=(e+="")=="transform"?Rl:Kr;return t==null?this.styleTween(e,Au(e,o)).on("end.style."+e,Qr(e)):typeof t=="function"?this.styleTween(e,$u(e,o,Kn(this,"style."+e,t))).each(Du(this._id,e)):this.styleTween(e,Pu(e,o,t),n).on("end.style."+e,null)}function Ru(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function zu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Ru(e,s,n)),o}return i._value=t,i}function Hu(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,zu(e,t,n??""))}function Lu(e){return function(){this.textContent=e}}function Bu(e){return function(){var t=e(this);this.textContent=t??""}}function Vu(e){return this.tween("text",typeof e=="function"?Bu(Kn(this,"text",e)):Lu(e==null?"":e+""))}function Ou(e){return function(t){this.textContent=e.call(this,t)}}function ju(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ou(r)),t}return o._value=e,o}function Fu(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,ju(e))}function Xu(){for(var e=this._name,t=this._id,n=Jr(),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 Yu(){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 Wu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Jr(){return++Wu}var be=xt.prototype;Ee.prototype={constructor:Ee,select:Cu,selectAll:Mu,selectChild:be.selectChild,selectChildren:be.selectChildren,filter:wu,merge:vu,selection:ku,transition:Xu,call:be.call,nodes:be.nodes,node:be.node,size:be.size,empty:be.empty,each:be.each,on:Eu,attr:ou,attrTween:cu,style:Tu,styleTween:Hu,text:Vu,textTween:Fu,remove:Su,tween:Ul,delay:du,duration:gu,ease:mu,easeVarying:xu,end:Yu,[Symbol.iterator]:be[Symbol.iterator]};function Zu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Gu={time:null,delay:0,duration:250,ease:Zu};function qu(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 Uu(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Jr(),(n=Gu).time=qn(),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||qu(l,t));return new Ee(o,this._parents,e,t)}xt.prototype.interrupt=Zl;xt.prototype.transition=Uu;const At=e=>()=>e;function Ku(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);ei.prototype=_e.prototype;function ei(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function rt(e){e.preventDefault(),e.stopImmediatePropagation()}function Qu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ju(){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 To(){return this.__zoom||nn}function ed(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function td(){return navigator.maxTouchPoints||"ontouchstart"in this}function nd(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 ti(){var e=Qu,t=Ju,n=nd,o=ed,r=td,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,x=10;function m(v){v.property("__zoom",To).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",To),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?w(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?w(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 w(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?w(B):typeof C=="function"?C.apply(k,D):C,Z=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),F=k.__zoom,z=typeof M=="function"?M.apply(k,D):M,X=l(F.invert(L).concat(Z/F.k),z.invert(L).concat(Z/z.k));return function(Y){if(Y===1)Y=z;else{var j=X(Y),G=Z/j[2];Y=new _e(G,L[0]-j[0]*G,L[1]-j[1]*G)}H.zoom(null,Y)}})}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 Ku(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;Lr(v.view),xn(v),P.mouse=[D,this.__zoom.invert(D)],Bt(this),P.start();function L(F){if(rt(F),!P.moved){var z=F.clientX-H,X=F.clientY-B;P.moved=z*z+X*X>y}P.event(F).zoom("mouse",n(p(P.that.__zoom,P.mouse[0]=de(F,C),P.mouse[1]),P.extent,s))}function Z(F){k.on("mousemove.zoom mouseup.zoom",null),Br(F.view,P.moved),rt(F),P.event(F).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(xn(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],F=C.touch0[1],z=C.touch1[0],X=C.touch1[1],Y=(Y=z[0]-Z[0])*Y+(Y=z[1]-Z[1])*Y,j=(j=X[0]-F[0])*j+(j=X[1]-F[1])*j;H=b(H,Math.sqrt(Y/j)),B=[(Z[0]+z[0])/2,(Z[1]+z[1])/2],L=[(F[0]+X[0])/2,(F[1]+X[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(xn(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])<x)){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?(x=+v,m):x},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]],ni=["Enter"," ","Escape"],oi={"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 ri={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 W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const Ro={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function ii(e){return e===null?null:e?"valid":"invalid"}const si=e=>"id"in e&&"source"in e&&"target"in e,od=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=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}},rd=(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):Qn(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}},Jn=(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)),x=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=x||c.dragging)&&l.push(c)}return l},id=(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 sd(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 ad({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=sd(e,s),l=bt(a),c=eo(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 ai({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 cd({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=id(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 ci(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 zo=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,li=(e,t,n=15,o=40)=>{const r=zo(e.x,o,t.width-o)*n,i=zo(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)}),Hn=({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}=Qn(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}=Qn(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)}},ui=(e,t)=>rn(on(Hn(e),Hn(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)},Ho=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),ld=(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 ud(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 dd(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 eo=(e,t,n,o,r,i)=>{const s=ud(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=dd(e,h,g,d,t,n),x={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-x.left+x.right,y:g-x.top+x.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 di(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function fi(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 Lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function fd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function hd(e){return{...oi,...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 to=e=>({width:e.offsetWidth,height:e.offsetHeight}),hi=e=>e?.getRootNode?.()||window?.document,gd=["INPUT","SELECT","TEXTAREA"];function gi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:gd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const pi=e=>"clientX"in e,ge=(e,t)=>{const n=pi(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)}},Bo=(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,...to(s)}})};function mi({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 Vo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case W.Left:return[t-Pt(t-o,i),n];case W.Right:return[t+Pt(o-t,i),n];case W.Top:return[t,n-Pt(n-r,i)];case W.Bottom:return[t,n+Pt(r-n,i)]}}function yi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,curvature:s=.25}){const[a,l]=Vo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=Vo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,f,h,g]=mi({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 xi({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 pd({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 md({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 yd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,xd=(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)),wd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||yd;let r;return si(e)?r={...e}:r={...e,id:o(e)},xd(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function wi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=xi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Oo={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},vd=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.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},jo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bd({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:o=W.Top,center:r,offset:i,stepPosition:s}){const a=Oo[t],l=Oo[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=vd({source:c,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,x;const m={x:0,y:0},b={x:0,y:0},[,,p,w]=xi({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,x=r.y??(c.y+d.y)/2):(y=r.x??(c.x+d.x)/2,x=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:x},{x:d.x,y:x}];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,x=g[0].y):(y=g[0].x,x=(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,x,p,w]}function _d(e,t,n,o){const r=Math.min(jo(e,t)/2,jo(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 Ln({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){const[u,f,h,g,y]=bd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:d});let x=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)x+=_d(u[m-1],u[m],u[m+1],s);return x+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[x,f,h,g,y]}function Fo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ed(e){const{sourceNode:t,targetNode:n}=e;if(!Fo(t)||!Fo(n))return null;const o=t.internals.handleBounds||Xo(t.handles),r=n.internals.handleBounds||Xo(n.handles),i=Yo(o?.source??[],e.sourceHandle),s=Yo(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||W.Bottom,l=s?.position||W.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 Xo(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=W.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 W.Top:return{x:r+s/2,y:i};case W.Right:return{x:r+s,y:i+a/2};case W.Bottom:return{x:r+s/2,y:i+a};case W.Left:return{x:r,y:i+a/2}}}function Yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Nd(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=Bn(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 vi=1e3,Sd=10,no={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Cd={...no,checkEquality:!0};function oo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Md(e,t,n){const o=oo(no,n);for(const r of e.values())if(r.parentId)io(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 Id(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 ro(e){return e==="manual"}function Vn(e,t,n,o={}){const r=oo(Cd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!ro(r.zIndexMode)?vi: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:Id(d,u),z:bi(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&&io(u,t,n,o,i),c||=d.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function kd(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 io(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=oo(no,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}kd(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*Sd),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const u=i&&!ro(l)?vi:0,{x:f,y:h,z:g}=Ad(e,d,s,a,u,l),{positionAbsolute:y}=e.internals,x=f!==y.x||h!==y.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:y,z:g}})}function bi(e,t,n){const o=he(e.zIndex)?e.zIndex:0;return ro(n)?o:o+(e.selected?t:0)}function Ad(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=ci(u,l,t));const f=bi(e,r,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function so(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=ui(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)),x=(g-d.width)*u[0],m=(y-d.height)*u[1];(f>0||h>0||x||m)&&(r.push({id:l,type:"position",position:{x:a.position.x-f+x,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-x:0),height:y+(h?u[1]*h-m:0)}})}),r}function Pd(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=to(h.nodeElement),x=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ue(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=ci(w,y,t.get(g.parentId)):p&&(w=Le(w,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:Bo("source",h.nodeElement,b,u,g.id),target:Bo("target",h.nodeElement,b,u,g.id)}}};t.set(g.id,S),g.parentId&&io(S,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,x&&(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=so(f,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function $d({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 Wo(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 _i(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}`;Wo("source",l,d,e,r,s),Wo("target",l,c,e,i,a),t.set(o.id,o)}}function Ei(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ei(n,t):!1}function Zo(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 Dd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ei(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 wn({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 Td({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 Rd({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 x({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:S,nodeId:N,nodeClickDistance:_=0}){f=le(w);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 F=a.size>1,z=F&&M?Hn(bt(a)):null,X=F&&P?Td({dragItems:a,snapGrid:C,x:R,y:V}):null;for(const[Y,j]of a){if(!v.has(Y))continue;let G={x:R-j.distance.x,y:V-j.distance.y};P&&(G=X?{x:Math.round(G.x+X.x),y:Math.round(G.y+X.y)}:_t(G,C));let Q=null;if(F&&M&&!j.extent&&z){const{positionAbsolute:U}=j.internals,te=U.x-z.x+M[0][0],oe=U.x+j.measured.width-z.x2+M[1][0],ne=U.y-z.y+M[0][1],ae=U.y+j.measured.height-z.y2+M[1][1];Q=[[te,ne],[oe,ae]]}const{position:K,positionAbsolute:q}=ai({nodeId:Y,nextPosition:G,nodeLookup:v,nodeExtent:Q||M,nodeOrigin:k,onError:B});Z=Z||j.position.x!==K.x||j.position.y!==K.y,j.position=K,j.internals.positionAbsolute=q}if(g=g||Z,!!Z&&(L(a,!0),y&&(o||D||!N&&H))){const[Y,j]=wn({nodeId:N,dragItems:a,nodeLookup:v});o?.(y,a,Y,j),D?.(y,Y,j),N||H?.(y,j)}}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]=li(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=Dd(V,M,Z,N),a.size>0&&(n||H||!N&&B)){const[F,z]=wn({nodeId:N,dragItems:a,nodeLookup:V});n?.(R.sourceEvent,a,F,z),H?.(R.sourceEvent,F,z),N||B?.(R.sourceEvent,z)}}const A=Vr().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]=wn({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||!Zo(V,`.${b}`,w))&&(!p||Zo(V,p,w))});f.call(A)}function m(){f?.on(".drag",null)}return{update:x,destroy:m}}function zd(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 Hd=250;function Ld(e,t,n,o){let r=[],i=1/0;const s=zd(e,n,t+Hd);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 Ni(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 Si(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Bd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ci=()=>!0;function Vd(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:x,isValidConnection:m=Ci,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:S,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:I}){const $=hi(e.target);let O=0,A;const{x:R,y:V}=ge(e),v=Si(i,I),M=a?.getBoundingClientRect();let C=!1;if(!M||!v)return;const P=Ni(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,q]=li(k,M,N);f({x:K,y:q}),O=requestAnimationFrame(Z)}const F={...P,nodeId:r,type:v,position:P.position},z=l.get(r);let Y={inProgress:!0,isValid:null,from:Be(z,F,W.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:z,to:k,toHandle:null,toPosition:Ro[F.position],toNode:null,pointer:k};function j(){C=!0,p(Y),g?.(e,{nodeId:r,handleId:o,handleType:v})}_===0&&j();function G(K){if(!C){const{x:ae,y:Se}=ge(K),ve=ae-R,Ae=Se-V;if(!(ve*ve+Ae*Ae>_*_))return;j()}if(!S()||!F){Q(K);return}const q=w();k=ge(K,M),A=Ld(Et(k,q,!1,[1,1]),n,l,F),D||(Z(),D=!0);const U=Mi(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:$,lib:c,flowId:u,nodeLookup:l});L=U.handleDomNode,H=U.connection,B=Bd(!!A,U.isValid);const te=l.get(r),oe=te?Be(te,F,W.Left,!0):Y.from,ne={...Y,from:oe,isValid:B,to:U.toHandle&&B?Ut({x:U.toHandle.x,y:U.toHandle.y},q):k,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Ro[F.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:k};p(ne),Y=ne}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(C){(A||L)&&H&&B&&y?.(H);const{inProgress:q,...U}=Y,te={...U,toPosition:Y.toHandle?Y.toPosition:null};x?.(K,te),i&&b?.(K,te)}h(),cancelAnimationFrame(O),D=!1,B=!1,H=null,L=null,$.removeEventListener("mousemove",G),$.removeEventListener("mouseup",Q),$.removeEventListener("touchmove",G),$.removeEventListener("touchend",Q)}}$.addEventListener("mousemove",G),$.addEventListener("mouseup",Q),$.addEventListener("touchmove",G),$.addEventListener("touchend",Q)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Ci,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),x=y?.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),w=x.getAttribute("data-handleid"),S=x.classList.contains("connectable"),N=x.classList.contains("connectableend");if(!p||!b)return m;const _={source:u?p:o,sourceHandle:u?w:r,target:u?o:p,targetHandle:u?r:w};m.connection=_;const $=S&&N&&(n===He.Strict?u&&b==="source"||!u&&b==="target":p!==o||w!==r);m.isValid=$&&c(_),m.toHandle=Ni(p,b,w,d,n,!0)}return m}const On={onPointerDown:Vd,isValid:Mi};function Od({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 w=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,_=w[2]*Math.pow(2,N*S);t.scaleTo(_)};let y=[0,0];const x=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 w=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(w[2],Math.log(w[2]))*(h?-1:1),I={x:w[0]-N[0]*_,y:w[1]-N[1]*_},$=[[0,0],[l,c]];t.setViewportConstrained({x:I.x,y:I.y,zoom:w[2]},$,a)},b=ti().on("start",x).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}),vn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ii=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),jd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=jd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ki=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fd({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 x=de(d),m=ki(d),b=u*Math.pow(2,m);o.scaleTo(n,b,x,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 Xd({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 Yd({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 Wd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ii(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 Zd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ii(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 Gd({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 qd({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=ti().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(ki);function y(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).transform(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function x({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:F,onTransformChange:z,connectionInProgress:X,paneClickDistance:Y,selectionOnDrag:j}){v&&!c.isZoomingOrPanning&&m();const G=M&&!Z&&!v;u.clickDistance(j?1/0:!he(Y)||Y<0?0:Y);const Q=G?Fd({zoomPanValues:c,noWheelClassName:A,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:k,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Xd({noWheelClassName:A,preventScrolling:D,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const q=Yd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",q);const U=Wd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:z});u.on("zoom",U);const te=Zd({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:l});u.on("end",te)}const K=Gd({zoomActivationKeyPressed:Z,panOnDrag:C,zoomOnScroll:B,panOnScroll:M,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:R,noWheelClassName:A,lib:F,connectionInProgress:X});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=vn(A),M=u?.constrain()(v,R,V);return M&&await y(M),new Promise(C=>C(M))}async function p(A,R){const V=vn(A);return await y(V,R),new Promise(v=>v(V))}function w(A){if(f){const R=vn(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?ei(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(bn(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(bn(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:x,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:N,scaleBy:_,setScaleExtent:I,setTranslateExtent:$,syncViewport:w,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Ud({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 Go(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 qo(e,t){return e?!t:t}function Kd(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:x,minHeight:m,maxHeight:b}=o,{x:p,y:w,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,x),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(w+$+V,s[0][1]):!c&&$>0&&(D=Me(w+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(w+$,a[0][1]):!c&&$<0&&(D=Ce(w+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(w+V+O/_,s[1][1])*_:D=Ce(w+V+(l?I:-I)/_,s[0][1])*_,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&f?D=Ce(w+O/_,a[1][1])*_:D=Me(w+(l?I:-I)/_,a[0][1])*_,v=Math.max(v,D)}}if(u){const k=$t(A*_,y,x)/_;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*_?$=(qo(l,c)?-I:I)/_:I=(qo(l,c)?-$:$)*_:d?($=I/_,c=l):(I=$*_,l=c));const C=l?p+I:p,P=c?w+$:w;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 Ai={width:0,height:0,x:0,y:0},Qd={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function Jd(e){return[[0,0],[e.measured.width,e.measured.height]]}function ef(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 tf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Go("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:x}){let m={...Ai},b={...Qd};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Go(c)};let p,w=null,S=[],N,_,I,$=!1;const O=Vr().on("start",A=>{const{nodeLookup:R,transform:V,snapGrid:v,snapToGrid:M,nodeOrigin:C,paneDomNode:P}=n();if(p=R.get(t),!p)return;w=P?.getBoundingClientRect()??null;const{xSnapped:k,ySnapped:D}=ct(A.sourceEvent,{transform:V,snapGrid:v,snapToGrid:M,containerBounds:w});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"?Jd(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=ef(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:w}),P=[];if(!p)return;const{x:k,y:D,width:H,height:B}=m,L={},Z=p.origin??M,{width:F,height:z,x:X,y:Y}=Kd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,Z,_,I),j=F!==H,G=z!==B,Q=X!==k&&j,K=Y!==D&&G;if(!Q&&!K&&!j&&!G)return;if((Q||K||Z[0]===1||Z[1]===1)&&(L.x=Q?X:m.x,L.y=K?Y:m.y,m.x=L.x,m.y=L.y,S.length>0)){const oe=X-k,ne=Y-D;for(const ae of S)ae.position={x:ae.position.x-oe+Z[0]*(F-H),y:ae.position.y-ne+Z[1]*(z-B)},P.push(ae)}if((j||G)&&(L.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:m.width,L.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?z: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 q=Ud({width:m.width,prevWidth:H,height:m.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:q};x?.(A,U)!==!1&&($=!0,g?.(A,U),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 _n={exports:{}},En={},Nn={exports:{}},Sn={};var Uo;function nf(){if(Uo)return Sn;Uo=1;var e=Sr();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,x=g[1];return i(function(){y.value=h,y.getSnapshot=f,l(y)&&x({inst:y})},[u,h,f]),r(function(){return l(y)&&x({inst:y}),u(function(){l(y)&&x({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 Sn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Sn}var Ko;function of(){return Ko||(Ko=1,Nn.exports=nf()),Nn.exports}var Qo;function rf(){if(Qo)return En;Qo=1;var e=Sr(),t=of();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 En.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 w=_}return w=N}if(_=w,o(p,N))return _;var I=f(N);return h!==void 0&&h(_,I)?(p=N,_):(p=N,w=I)}var b=!1,p,w,S=u===void 0?null:u;return[function(){return m(d())},S===null?void 0:function(){return m(S())}]},[d,u,f,h]);var x=r(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},En}var Jo;function sf(){return Jo||(Jo=1,_n.exports=rf()),_n.exports}var af=sf();const cf=ma(af),lf={},er=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:()=>{(lf?"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},uf=e=>e?er(e):er,{useDebugValue:df}=ya,{useSyncExternalStoreWithSelector:ff}=cf,hf=e=>e;function Pi(e,t=hf,n){const o=ff(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return df(o),o}const tr=(e,t)=>{const n=uf(e),o=(r,i=t)=>Pi(n,r,i);return Object.assign(o,n),o},gf=(e,t)=>e?tr(e,t):tr;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),pf=an.Provider,$i=xe.error001();function ee(e,t){const n=T.useContext(an);if(n===null)throw new Error($i);return Pi(n,e,t)}function ie(){const e=T.useContext(an);if(e===null)throw new Error($i);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nr={display:"none"},mf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Di="react-flow__node-desc",Ti="react-flow__edge-desc",yf="react-flow__aria-live",xf=e=>e.ariaLiveMessage,wf=e=>e.ariaLabelConfig;function vf({rfId:e}){const t=ee(xf);return E.jsx("div",{id:`${yf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mf,children:t})}function bf({rfId:e,disableKeyboardA11y:t}){const n=ee(wf);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${Di}-${e}`,style:nr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Ti}-${e}`,style:nr,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(vf,{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 _f({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 Ef=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 Nf(e,t){return re(e.selectedNodes.map(Dt),t.selectedNodes.map(Dt))&&re(e.selectedEdges.map(Dt),t.selectedEdges.map(Dt))}function Sf({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=ee(Ef,Nf);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Cf=e=>!!e.onSelectionChangeHandlers;function Mf({onSelectionChange:e}){const t=ee(Cf);return e||t?E.jsx(Sf,{onSelectionChange:e}):null}const jn=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ri=[0,0],If={x:0,y:0,zoom:1},kf=["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"],or=[...kf,"rfId"],Af=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}),rr={translateExtent:ht,nodeOrigin:Ri,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Pf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(Af,re),c=ie();jn(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=rr,a()}),[]);const d=T.useRef(rr);return jn(()=>{for(const u of or){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:hd(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=e},or.map(u=>e[u])),null}function ir(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function $f(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=ir(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:ir()?.matches?"dark":"light"}const sr=typeof document<"u"?document:null;function yt(e=null,t={target:sr,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 Sr,g as ma,R as ya,a as T,j as E,u as Xn,b as J,i as gn,S as xa,f as wa,c as va,n as ba,d as _a,e as Ea}from"./index-Da2s4_-5.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 Na={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 Sa(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=Sa(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Ca(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]=xo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=xo(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 Ca(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function xo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Na,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var kn="http://www.w3.org/1999/xhtml";const wo={svg:"http://www.w3.org/2000/svg",xhtml:kn,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)),wo.hasOwnProperty(t)?{space:wo[t],local:e}:e}function Ma(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===kn&&t.documentElement.namespaceURI===kn?t.createElement(e):t.createElementNS(n,e)}}function Ia(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Cr(e){var t=Jt(e);return(t.local?Ia:Ma)(t)}function ka(){}function Yn(e){return e==null?ka:function(){return this.querySelector(e)}}function Aa(e){typeof e!="function"&&(e=Yn(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 Pa(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function $a(){return[]}function Mr(e){return e==null?$a:function(){return this.querySelectorAll(e)}}function Da(e){return function(){return Pa(e.apply(this,arguments))}}function Ta(e){typeof e=="function"?e=Da(e):e=Mr(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 Ir(e){return function(){return this.matches(e)}}function kr(e){return function(t){return t.matches(e)}}var Ra=Array.prototype.find;function za(e){return function(){return Ra.call(this.children,e)}}function Ha(){return this.firstElementChild}function La(e){return this.select(e==null?Ha:za(typeof e=="function"?e:kr(e)))}var Ba=Array.prototype.filter;function Va(){return Array.from(this.children)}function Oa(e){return function(){return Ba.call(this.children,e)}}function ja(e){return this.selectAll(e==null?Va:Oa(typeof e=="function"?e:kr(e)))}function Fa(e){typeof e!="function"&&(e=Ir(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 Ar(e){return new Array(e.length)}function Xa(){return new ue(this._enter||this._groups.map(Ar),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 Ya(e){return function(){return e}}function Wa(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 Za(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 Ga(e){return e.__data__}function qa(e,t){if(!arguments.length)return Array.from(this,Ga);var n=t?Za:Wa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ya(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=Ua(e.call(d,d&&d.__data__,c,o)),g=h.length,y=a[c]=new Array(g),x=s[c]=new Array(g),m=l[c]=new Array(f);n(d,u,y,x,m,h,t);for(var b=0,p=0,w,S;b<g;++b)if(w=y[b]){for(b>=p&&(p=b+1);!(S=x[p])&&++p<g;);w._next=S||null}}return s=new ue(s,o),s._enter=a,s._exit=l,s}function Ua(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ka(){return new ue(this._exit||this._groups.map(Ar),this._parents)}function Qa(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 Ja(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 ec(){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 tc(e){e||(e=nc);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 nc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function oc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function rc(){return Array.from(this)}function ic(){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 sc(){let e=0;for(const t of this)++e;return e}function ac(){return!this.node()}function cc(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 lc(e){return function(){this.removeAttribute(e)}}function uc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dc(e,t){return function(){this.setAttribute(e,t)}}function fc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gc(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 pc(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?uc:lc:typeof t=="function"?n.local?gc:hc:n.local?fc:dc)(n,t))}function Pr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function mc(e){return function(){this.style.removeProperty(e)}}function yc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function wc(e,t,n){return arguments.length>1?this.each((t==null?mc:typeof t=="function"?xc:yc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Pr(e).getComputedStyle(e,null).getPropertyValue(t)}function vc(e){return function(){delete this[e]}}function bc(e,t){return function(){this[e]=t}}function _c(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ec(e,t){return arguments.length>1?this.each((t==null?vc:typeof t=="function"?_c:bc)(e,t)):this.node()[e]}function $r(e){return e.trim().split(/^|\s+/)}function Wn(e){return e.classList||new Dr(e)}function Dr(e){this._node=e,this._names=$r(e.getAttribute("class")||"")}Dr.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 Tr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Rr(e,t){for(var n=Wn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Nc(e){return function(){Tr(this,e)}}function Sc(e){return function(){Rr(this,e)}}function Cc(e,t){return function(){(t.apply(this,arguments)?Tr:Rr)(this,e)}}function Mc(e,t){var n=$r(e+"");if(arguments.length<2){for(var o=Wn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Cc:t?Nc:Sc)(n,t))}function Ic(){this.textContent=""}function kc(e){return function(){this.textContent=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Pc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Ac:kc)(e)):this.node().textContent}function $c(){this.innerHTML=""}function Dc(e){return function(){this.innerHTML=e}}function Tc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Rc(e){return arguments.length?this.each(e==null?$c:(typeof e=="function"?Tc:Dc)(e)):this.node().innerHTML}function zc(){this.nextSibling&&this.parentNode.appendChild(this)}function Hc(){return this.each(zc)}function Lc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Bc(){return this.each(Lc)}function Vc(e){var t=typeof e=="function"?e:Cr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Oc(){return null}function jc(e,t){var n=typeof e=="function"?e:Cr(e),o=t==null?Oc:typeof t=="function"?t:Yn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Fc(){var e=this.parentNode;e&&e.removeChild(this)}function Xc(){return this.each(Fc)}function Yc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Wc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Zc(e){return this.select(e?Wc:Yc)}function Gc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qc(e){return function(t){e.call(this,t,this.__data__)}}function Uc(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 Kc(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 Qc(e,t,n){return function(){var o=this.__on,r,i=qc(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 Jc(e,t,n){var o=Uc(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?Qc:Kc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function zr(e,t,n){var o=Pr(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 el(e,t){return function(){return zr(this,e,t)}}function tl(e,t){return function(){return zr(this,e,t.apply(this,arguments))}}function nl(e,t){return this.each((typeof t=="function"?tl:el)(e,t))}function*ol(){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 Hr=[null];function ue(e,t){this._groups=e,this._parents=t}function xt(){return new ue([[document.documentElement]],Hr)}function rl(){return this}ue.prototype=xt.prototype={constructor:ue,select:Aa,selectAll:Ta,selectChild:La,selectChildren:ja,filter:Fa,data:qa,enter:Xa,exit:Ka,join:Qa,merge:Ja,selection:rl,order:ec,sort:tc,call:oc,nodes:rc,node:ic,size:sc,empty:ac,each:cc,attr:pc,style:wc,property:Ec,classed:Mc,text:Pc,html:Rc,raise:Hc,lower:Bc,append:Vc,insert:jc,remove:Xc,clone:Zc,datum:Gc,on:Jc,dispatch:nl,[Symbol.iterator]:ol};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],Hr)}function il(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=il(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 sl={passive:!1},lt={capture:!0,passive:!1};function pn(e){e.stopImmediatePropagation()}function Xe(e){e.preventDefault(),e.stopImmediatePropagation()}function Lr(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 Br(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 An(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}})}An.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function al(e){return!e.ctrlKey&&!e.button}function cl(){return this.parentNode}function ll(e,t){return t??{x:e.x,y:e.y}}function ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vr(){var e=al,t=cl,n=ll,o=ul,r={},i=Qt("start","drag","end"),s=0,a,l,c,d,u=0;function f(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",m,sl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,S){if(!(d||!e.call(this,w,S))){var N=p(this,t.call(this,w,S),w,S,"mouse");N&&(le(w.view).on("mousemove.drag",g,lt).on("mouseup.drag",y,lt),Lr(w.view),pn(w),c=!1,a=w.clientX,l=w.clientY,N("start",w))}}function g(w){if(Xe(w),!c){var S=w.clientX-a,N=w.clientY-l;c=S*S+N*N>u}r.mouse("drag",w)}function y(w){le(w.view).on("mousemove.drag mouseup.drag",null),Br(w.view,c),Xe(w),r.mouse("end",w)}function x(w,S){if(e.call(this,w,S)){var N=w.changedTouches,_=t.call(this,w,S),I=N.length,$,O;for($=0;$<I;++$)(O=p(this,_,w,S,N[$].identifier,N[$]))&&(pn(w),O("start",w,N[$]))}}function m(w){var S=w.changedTouches,N=S.length,_,I;for(_=0;_<N;++_)(I=r[S[_].identifier])&&(Xe(w),I("drag",w,S[_]))}function b(w){var S=w.changedTouches,N=S.length,_,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<N;++_)(I=r[S[_].identifier])&&(pn(w),I("end",w,S[_]))}function p(w,S,N,_,I,$){var O=i.copy(),A=de($||N,S),R,V,v;if((v=n.call(w,new An("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,w,new An(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(w){return arguments.length?(e=typeof w=="function"?w:Ct(!!w),f):e},f.container=function(w){return arguments.length?(t=typeof w=="function"?w:Ct(w),f):t},f.subject=function(w){return arguments.length?(n=typeof w=="function"?w:Ct(w),f):n},f.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:Ct(!!w),f):o},f.on=function(){var w=i.on.apply(i,arguments);return w===i?f:w},f.clickDistance=function(w){return arguments.length?(u=(w=+w)*w,f):Math.sqrt(u)},f}function Zn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Or(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*",dl=/^#([0-9a-f]{3,8})$/,fl=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),hl=new RegExp(`^rgb\\(${ye},${ye},${ye}\\)$`),gl=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${dt}\\)$`),pl=new RegExp(`^rgba\\(${ye},${ye},${ye},${dt}\\)$`),ml=new RegExp(`^hsl\\(${dt},${ye},${ye}\\)$`),yl=new RegExp(`^hsla\\(${dt},${ye},${ye},${dt}\\)$`),vo={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};Zn(wt,Re,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bo,formatHex:bo,formatHex8:xl,formatHsl:wl,formatRgb:_o,toString:_o});function bo(){return this.rgb().formatHex()}function xl(){return this.rgb().formatHex8()}function wl(){return jr(this).formatHsl()}function _o(){return this.rgb().formatRgb()}function Re(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=dl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Eo(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=fl.exec(e))?new ce(t[1],t[2],t[3],1):(t=hl.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=gl.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=pl.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ml.exec(e))?Co(t[1],t[2]/100,t[3]/100,1):(t=yl.exec(e))?Co(t[1],t[2]/100,t[3]/100,t[4]):vo.hasOwnProperty(e)?Eo(vo[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function Eo(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 vl(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 Pn(e,t,n,o){return arguments.length===1?vl(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}Zn(ce,Pn,Or(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:No,formatHex:No,formatHex8:bl,formatRgb:So,toString:So}));function No(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function bl(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function So(){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 Co(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 jr(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 _l(e,t,n,o){return arguments.length===1?jr(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}Zn(fe,_l,Or(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(mn(e>=240?e-240:e+120,r,o),mn(e,r,o),mn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new fe(Mo(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("}${Mo(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Mo(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function mn(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 Gn=e=>()=>e;function El(e,t){return function(n){return e+n*t}}function Nl(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 Sl(e){return(e=+e)==1?Fr:function(t,n){return n-t?Nl(t,n,e):Gn(isNaN(t)?n:t)}}function Fr(e,t){var n=t-e;return n?El(e,n):Gn(isNaN(e)?t:e)}const Xt=(function e(t){var n=Sl(t);function o(r,i){var s=n((r=Pn(r)).r,(i=Pn(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=Fr(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 Cl(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 Ml(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Il(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 kl(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 Al(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 $n=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yn=new RegExp($n.source,"g");function Pl(e){return function(){return e}}function $l(e){return function(t){return e(t)+""}}function Xr(e,t){var n=$n.lastIndex=yn.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=$n.exec(e))&&(r=yn.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=yn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?$l(l[0].x):Pl(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"?Gn(t):(n==="number"?me:n==="string"?(o=Re(t))?(t=o,Xt):Xr:t instanceof Re?Xt:t instanceof Date?kl:Ml(t)?Cl:Array.isArray(t)?Il:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Al:me)(e,t)}var Io=180/Math.PI,Dn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Yr(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)*Io,skewX:Math.atan(l)*Io,scaleX:s,scaleY:a}}var kt;function Dl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Dn:Yr(t.a,t.b,t.c,t.d,t.e,t.f)}function Tl(e){return e==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),!(e=kt.transform.baseVal.consolidate()))?Dn:(e=e.matrix,Yr(e.a,e.b,e.c,e.d,e.e,e.f))}function Wr(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,x;++g<y;)u[(x=f[g]).i]=x.x(h);return u.join("")}}}var Rl=Wr(Dl,"px, ","px)","deg)"),zl=Wr(Tl,", ",")",")"),Hl=1e-12;function ko(e){return((e=Math.exp(e))+1/e)/2}function Ll(e){return((e=Math.exp(e))-1/e)/2}function Bl(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,x,m;if(y<Hl)m=Math.log(f/c)/t,x=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),w=(f*f-c*c-o*y)/(2*f*n*b),S=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(w*w+1)-w);m=(N-S)/t,x=function(_){var I=_*m,$=ko(S),O=c/(n*b)*($*Bl(t*I+S)-Ll(S));return[a+O*h,l+O*g,c*$/ko(t*I+S)]}}return x.duration=m*1e3*t/Math.SQRT2,x}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,Zr=1e3,Yt,st,Wt=0,ze=0,en=0,ft=typeof performance=="object"&&performance.now?performance:Date,Gr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qn(){return ze||(Gr(Vl),ze=ft.now()+en)}function Vl(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=qr.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?qn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Yt=this,st=this),this._call=e,this._time=n,Tn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Tn())}};function qr(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Ol(){qn(),++Ze;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Ao(){ze=(Wt=ft.now())+en,Ze=it=0;try{Ol()}finally{Ze=0,Fl(),ze=0}}function jl(){var e=ft.now(),t=e-Wt;t>Zr&&(en-=t,Wt=e)}function Fl(){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,Tn(o)}function Tn(e){if(!Ze){it&&(it=clearTimeout(it));var t=e-ze;t>24?(e<1/0&&(it=setTimeout(Ao,e-ft.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Wt=ft.now(),ot=setInterval(jl,Zr)),Ze=1,Gr(Ao))}}function Po(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 Xl=Qt("start","end","cancel","interrupt"),Yl=[],Ur=0,$o=1,Rn=2,Ht=3,Do=4,zn=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;Wl(e,n,{name:t,index:o,group:r,on:Xl,tween:Yl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ur})}function Un(e,t){var n=pe(e,t);if(n.state>Ur)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 Wl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=qr(i,0,n.time);function i(c){n.state=$o,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!==$o)return l();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Ht)return Po(s);h.state===Do?(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(Po(function(){n.state===Ht&&(n.state=Do,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Rn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Rn){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=zn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);n.state===zn&&(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>Rn&&o.state<zn,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 Zl(e){return this.each(function(){Bt(this,e)})}function Gl(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 ql(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 Ul(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?Gl:ql)(n,e,t))}function Kn(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 Kr(e,t){var n;return(typeof t=="number"?me:t instanceof Re?Xt:(n=Re(t))?(t=n,Xt):Xr)(e,t)}function Kl(e){return function(){this.removeAttribute(e)}}function Ql(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jl(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 eu(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 tu(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 nu(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 ou(e,t){var n=Jt(e),o=n==="transform"?zl:Kr;return this.attrTween(e,typeof t=="function"?(n.local?nu:tu)(n,o,Kn(this,"attr."+e,t)):t==null?(n.local?Ql:Kl)(n):(n.local?eu:Jl)(n,o,t))}function ru(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function iu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function su(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&iu(e,i)),n}return r._value=t,r}function au(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ru(e,i)),n}return r._value=t,r}function cu(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?su:au)(o,t))}function lu(e,t){return function(){Un(this,e).delay=+t.apply(this,arguments)}}function uu(e,t){return t=+t,function(){Un(this,e).delay=t}}function du(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lu:uu)(t,e)):pe(this.node(),t).delay}function fu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function hu(e,t){return t=+t,function(){we(this,e).duration=t}}function gu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fu:hu)(t,e)):pe(this.node(),t).duration}function pu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function mu(e){var t=this._id;return arguments.length?this.each(pu(t,e)):pe(this.node(),t).ease}function yu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function xu(e){if(typeof e!="function")throw new Error;return this.each(yu(this._id,e))}function wu(e){typeof e!="function"&&(e=Ir(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 vu(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 bu(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 _u(e,t,n){var o,r,i=bu(t)?Un:we;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Eu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(_u(n,e,t))}function Nu(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Su(){return this.on("end.remove",Nu(this._id))}function Cu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yn(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 Mu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mr(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,x=f.length;y<x;++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 Iu=xt.prototype.constructor;function ku(){return new Iu(this._groups,this._parents)}function Au(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 Qr(e){return function(){this.style.removeProperty(e)}}function Pu(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 $u(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 Du(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=Qr(t)):void 0;(c!==n||r!==d)&&(o=(n=c).copy()).on(s,r=d),l.on=o}}function Tu(e,t,n){var o=(e+="")=="transform"?Rl:Kr;return t==null?this.styleTween(e,Au(e,o)).on("end.style."+e,Qr(e)):typeof t=="function"?this.styleTween(e,$u(e,o,Kn(this,"style."+e,t))).each(Du(this._id,e)):this.styleTween(e,Pu(e,o,t),n).on("end.style."+e,null)}function Ru(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function zu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Ru(e,s,n)),o}return i._value=t,i}function Hu(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,zu(e,t,n??""))}function Lu(e){return function(){this.textContent=e}}function Bu(e){return function(){var t=e(this);this.textContent=t??""}}function Vu(e){return this.tween("text",typeof e=="function"?Bu(Kn(this,"text",e)):Lu(e==null?"":e+""))}function Ou(e){return function(t){this.textContent=e.call(this,t)}}function ju(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Ou(r)),t}return o._value=e,o}function Fu(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,ju(e))}function Xu(){for(var e=this._name,t=this._id,n=Jr(),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 Yu(){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 Wu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Jr(){return++Wu}var be=xt.prototype;Ee.prototype={constructor:Ee,select:Cu,selectAll:Mu,selectChild:be.selectChild,selectChildren:be.selectChildren,filter:wu,merge:vu,selection:ku,transition:Xu,call:be.call,nodes:be.nodes,node:be.node,size:be.size,empty:be.empty,each:be.each,on:Eu,attr:ou,attrTween:cu,style:Tu,styleTween:Hu,text:Vu,textTween:Fu,remove:Su,tween:Ul,delay:du,duration:gu,ease:mu,easeVarying:xu,end:Yu,[Symbol.iterator]:be[Symbol.iterator]};function Zu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Gu={time:null,delay:0,duration:250,ease:Zu};function qu(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 Uu(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Jr(),(n=Gu).time=qn(),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||qu(l,t));return new Ee(o,this._parents,e,t)}xt.prototype.interrupt=Zl;xt.prototype.transition=Uu;const At=e=>()=>e;function Ku(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);ei.prototype=_e.prototype;function ei(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function xn(e){e.stopImmediatePropagation()}function rt(e){e.preventDefault(),e.stopImmediatePropagation()}function Qu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ju(){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 To(){return this.__zoom||nn}function ed(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function td(){return navigator.maxTouchPoints||"ontouchstart"in this}function nd(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 ti(){var e=Qu,t=Ju,n=nd,o=ed,r=td,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,x=10;function m(v){v.property("__zoom",To).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",To),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?w(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?w(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 w(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?w(B):typeof C=="function"?C.apply(k,D):C,Z=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),F=k.__zoom,z=typeof M=="function"?M.apply(k,D):M,X=l(F.invert(L).concat(Z/F.k),z.invert(L).concat(Z/z.k));return function(Y){if(Y===1)Y=z;else{var j=X(Y),G=Z/j[2];Y=new _e(G,L[0]-j[0]*G,L[1]-j[1]*G)}H.zoom(null,Y)}})}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 Ku(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;Lr(v.view),xn(v),P.mouse=[D,this.__zoom.invert(D)],Bt(this),P.start();function L(F){if(rt(F),!P.moved){var z=F.clientX-H,X=F.clientY-B;P.moved=z*z+X*X>y}P.event(F).zoom("mouse",n(p(P.that.__zoom,P.mouse[0]=de(F,C),P.mouse[1]),P.extent,s))}function Z(F){k.on("mousemove.zoom mouseup.zoom",null),Br(F.view,P.moved),rt(F),P.event(F).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(xn(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],F=C.touch0[1],z=C.touch1[0],X=C.touch1[1],Y=(Y=z[0]-Z[0])*Y+(Y=z[1]-Z[1])*Y,j=(j=X[0]-F[0])*j+(j=X[1]-F[1])*j;H=b(H,Math.sqrt(Y/j)),B=[(Z[0]+z[0])/2,(Z[1]+z[1])/2],L=[(F[0]+X[0])/2,(F[1]+X[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(xn(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])<x)){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?(x=+v,m):x},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]],ni=["Enter"," ","Escape"],oi={"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 ri={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 W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const Ro={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function ii(e){return e===null?null:e?"valid":"invalid"}const si=e=>"id"in e&&"source"in e&&"target"in e,od=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=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}},rd=(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):Qn(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}},Jn=(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)),x=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=x||c.dragging)&&l.push(c)}return l},id=(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 sd(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 ad({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=sd(e,s),l=bt(a),c=eo(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 ai({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 cd({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=id(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 ci(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 zo=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,li=(e,t,n=15,o=40)=>{const r=zo(e.x,o,t.width-o)*n,i=zo(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)}),Hn=({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}=Qn(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}=Qn(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)}},ui=(e,t)=>rn(on(Hn(e),Hn(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)},Ho=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),ld=(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 ud(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 dd(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 eo=(e,t,n,o,r,i)=>{const s=ud(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=dd(e,h,g,d,t,n),x={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-x.left+x.right,y:g-x.top+x.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 di(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function fi(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 Lo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function fd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function hd(e){return{...oi,...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 to=e=>({width:e.offsetWidth,height:e.offsetHeight}),hi=e=>e?.getRootNode?.()||window?.document,gd=["INPUT","SELECT","TEXTAREA"];function gi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:gd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const pi=e=>"clientX"in e,ge=(e,t)=>{const n=pi(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)}},Bo=(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,...to(s)}})};function mi({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 Vo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case W.Left:return[t-Pt(t-o,i),n];case W.Right:return[t+Pt(o-t,i),n];case W.Top:return[t,n-Pt(n-r,i)];case W.Bottom:return[t,n+Pt(r-n,i)]}}function yi({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,curvature:s=.25}){const[a,l]=Vo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=Vo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,f,h,g]=mi({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 xi({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 pd({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 md({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 yd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,xd=(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)),wd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||yd;let r;return si(e)?r={...e}:r={...e,id:o(e)},xd(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function wi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=xi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Oo={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},vd=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.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},jo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function bd({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:o=W.Top,center:r,offset:i,stepPosition:s}){const a=Oo[t],l=Oo[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=vd({source:c,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,x;const m={x:0,y:0},b={x:0,y:0},[,,p,w]=xi({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,x=r.y??(c.y+d.y)/2):(y=r.x??(c.x+d.x)/2,x=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:x},{x:d.x,y:x}];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,x=g[0].y):(y=g[0].x,x=(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,x,p,w]}function _d(e,t,n,o){const r=Math.min(jo(e,t)/2,jo(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 Ln({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:r,targetPosition:i=W.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){const[u,f,h,g,y]=bd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:d});let x=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)x+=_d(u[m-1],u[m],u[m+1],s);return x+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[x,f,h,g,y]}function Fo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ed(e){const{sourceNode:t,targetNode:n}=e;if(!Fo(t)||!Fo(n))return null;const o=t.internals.handleBounds||Xo(t.handles),r=n.internals.handleBounds||Xo(n.handles),i=Yo(o?.source??[],e.sourceHandle),s=Yo(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||W.Bottom,l=s?.position||W.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 Xo(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=W.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 W.Top:return{x:r+s/2,y:i};case W.Right:return{x:r+s,y:i+a/2};case W.Bottom:return{x:r+s/2,y:i+a};case W.Left:return{x:r,y:i+a/2}}}function Yo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Nd(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=Bn(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 vi=1e3,Sd=10,no={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Cd={...no,checkEquality:!0};function oo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Md(e,t,n){const o=oo(no,n);for(const r of e.values())if(r.parentId)io(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 Id(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 ro(e){return e==="manual"}function Vn(e,t,n,o={}){const r=oo(Cd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!ro(r.zIndexMode)?vi: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:Id(d,u),z:bi(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&&io(u,t,n,o,i),c||=d.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function kd(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 io(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=oo(no,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}kd(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*Sd),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const u=i&&!ro(l)?vi:0,{x:f,y:h,z:g}=Ad(e,d,s,a,u,l),{positionAbsolute:y}=e.internals,x=f!==y.x||h!==y.y;(x||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:y,z:g}})}function bi(e,t,n){const o=he(e.zIndex)?e.zIndex:0;return ro(n)?o:o+(e.selected?t:0)}function Ad(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=ci(u,l,t));const f=bi(e,r,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function so(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=ui(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)),x=(g-d.width)*u[0],m=(y-d.height)*u[1];(f>0||h>0||x||m)&&(r.push({id:l,type:"position",position:{x:a.position.x-f+x,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-x:0),height:y+(h?u[1]*h-m:0)}})}),r}function Pd(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=to(h.nodeElement),x=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(x||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ue(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=ci(w,y,t.get(g.parentId)):p&&(w=Le(w,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:Bo("source",h.nodeElement,b,u,g.id),target:Bo("target",h.nodeElement,b,u,g.id)}}};t.set(g.id,S),g.parentId&&io(S,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,x&&(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=so(f,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function $d({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 Wo(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 _i(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}`;Wo("source",l,d,e,r,s),Wo("target",l,c,e,i,a),t.set(o.id,o)}}function Ei(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ei(n,t):!1}function Zo(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 Dd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ei(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 wn({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 Td({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 Rd({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 x({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:S,nodeId:N,nodeClickDistance:_=0}){f=le(w);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 F=a.size>1,z=F&&M?Hn(bt(a)):null,X=F&&P?Td({dragItems:a,snapGrid:C,x:R,y:V}):null;for(const[Y,j]of a){if(!v.has(Y))continue;let G={x:R-j.distance.x,y:V-j.distance.y};P&&(G=X?{x:Math.round(G.x+X.x),y:Math.round(G.y+X.y)}:_t(G,C));let Q=null;if(F&&M&&!j.extent&&z){const{positionAbsolute:U}=j.internals,te=U.x-z.x+M[0][0],oe=U.x+j.measured.width-z.x2+M[1][0],ne=U.y-z.y+M[0][1],ae=U.y+j.measured.height-z.y2+M[1][1];Q=[[te,ne],[oe,ae]]}const{position:K,positionAbsolute:q}=ai({nodeId:Y,nextPosition:G,nodeLookup:v,nodeExtent:Q||M,nodeOrigin:k,onError:B});Z=Z||j.position.x!==K.x||j.position.y!==K.y,j.position=K,j.internals.positionAbsolute=q}if(g=g||Z,!!Z&&(L(a,!0),y&&(o||D||!N&&H))){const[Y,j]=wn({nodeId:N,dragItems:a,nodeLookup:v});o?.(y,a,Y,j),D?.(y,Y,j),N||H?.(y,j)}}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]=li(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=Dd(V,M,Z,N),a.size>0&&(n||H||!N&&B)){const[F,z]=wn({nodeId:N,dragItems:a,nodeLookup:V});n?.(R.sourceEvent,a,F,z),H?.(R.sourceEvent,F,z),N||B?.(R.sourceEvent,z)}}const A=Vr().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]=wn({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||!Zo(V,`.${b}`,w))&&(!p||Zo(V,p,w))});f.call(A)}function m(){f?.on(".drag",null)}return{update:x,destroy:m}}function zd(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 Hd=250;function Ld(e,t,n,o){let r=[],i=1/0;const s=zd(e,n,t+Hd);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 Ni(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 Si(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Bd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ci=()=>!0;function Vd(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:x,isValidConnection:m=Ci,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:S,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:I}){const $=hi(e.target);let O=0,A;const{x:R,y:V}=ge(e),v=Si(i,I),M=a?.getBoundingClientRect();let C=!1;if(!M||!v)return;const P=Ni(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,q]=li(k,M,N);f({x:K,y:q}),O=requestAnimationFrame(Z)}const F={...P,nodeId:r,type:v,position:P.position},z=l.get(r);let Y={inProgress:!0,isValid:null,from:Be(z,F,W.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:z,to:k,toHandle:null,toPosition:Ro[F.position],toNode:null,pointer:k};function j(){C=!0,p(Y),g?.(e,{nodeId:r,handleId:o,handleType:v})}_===0&&j();function G(K){if(!C){const{x:ae,y:Se}=ge(K),ve=ae-R,Ae=Se-V;if(!(ve*ve+Ae*Ae>_*_))return;j()}if(!S()||!F){Q(K);return}const q=w();k=ge(K,M),A=Ld(Et(k,q,!1,[1,1]),n,l,F),D||(Z(),D=!0);const U=Mi(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:$,lib:c,flowId:u,nodeLookup:l});L=U.handleDomNode,H=U.connection,B=Bd(!!A,U.isValid);const te=l.get(r),oe=te?Be(te,F,W.Left,!0):Y.from,ne={...Y,from:oe,isValid:B,to:U.toHandle&&B?Ut({x:U.toHandle.x,y:U.toHandle.y},q):k,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Ro[F.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:k};p(ne),Y=ne}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(C){(A||L)&&H&&B&&y?.(H);const{inProgress:q,...U}=Y,te={...U,toPosition:Y.toHandle?Y.toPosition:null};x?.(K,te),i&&b?.(K,te)}h(),cancelAnimationFrame(O),D=!1,B=!1,H=null,L=null,$.removeEventListener("mousemove",G),$.removeEventListener("mouseup",Q),$.removeEventListener("touchmove",G),$.removeEventListener("touchend",Q)}}$.addEventListener("mousemove",G),$.addEventListener("mouseup",Q),$.addEventListener("touchmove",G),$.addEventListener("touchend",Q)}function Mi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Ci,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),x=y?.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const b=Si(void 0,x),p=x.getAttribute("data-nodeid"),w=x.getAttribute("data-handleid"),S=x.classList.contains("connectable"),N=x.classList.contains("connectableend");if(!p||!b)return m;const _={source:u?p:o,sourceHandle:u?w:r,target:u?o:p,targetHandle:u?r:w};m.connection=_;const $=S&&N&&(n===He.Strict?u&&b==="source"||!u&&b==="target":p!==o||w!==r);m.isValid=$&&c(_),m.toHandle=Ni(p,b,w,d,n,!0)}return m}const On={onPointerDown:Vd,isValid:Mi};function Od({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 w=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,_=w[2]*Math.pow(2,N*S);t.scaleTo(_)};let y=[0,0];const x=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 w=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(w[2],Math.log(w[2]))*(h?-1:1),I={x:w[0]-N[0]*_,y:w[1]-N[1]*_},$=[[0,0],[l,c]];t.setViewportConstrained({x:I.x,y:I.y,zoom:w[2]},$,a)},b=ti().on("start",x).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}),vn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Ii=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),jd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bn=(e,t=0,n=jd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ki=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fd({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 x=de(d),m=ki(d),b=u*Math.pow(2,m);o.scaleTo(n,b,x,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 Xd({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 Yd({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 Wd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ii(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 Zd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ii(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 Gd({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 qd({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=ti().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(ki);function y(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).transform(bn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function x({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:F,onTransformChange:z,connectionInProgress:X,paneClickDistance:Y,selectionOnDrag:j}){v&&!c.isZoomingOrPanning&&m();const G=M&&!Z&&!v;u.clickDistance(j?1/0:!he(Y)||Y<0?0:Y);const Q=G?Fd({zoomPanValues:c,noWheelClassName:A,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:k,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Xd({noWheelClassName:A,preventScrolling:D,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const q=Yd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",q);const U=Wd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:z});u.on("zoom",U);const te=Zd({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:l});u.on("end",te)}const K=Gd({zoomActivationKeyPressed:Z,panOnDrag:C,zoomOnScroll:B,panOnScroll:M,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:R,noWheelClassName:A,lib:F,connectionInProgress:X});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=vn(A),M=u?.constrain()(v,R,V);return M&&await y(M),new Promise(C=>C(M))}async function p(A,R){const V=vn(A);return await y(V,R),new Promise(v=>v(V))}function w(A){if(f){const R=vn(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?ei(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(bn(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(bn(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:x,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:N,scaleBy:_,setScaleExtent:I,setTranslateExtent:$,syncViewport:w,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Ud({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 Go(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 qo(e,t){return e?!t:t}function Kd(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:x,minHeight:m,maxHeight:b}=o,{x:p,y:w,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,x),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(w+$+V,s[0][1]):!c&&$>0&&(D=Me(w+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(w+$,a[0][1]):!c&&$<0&&(D=Ce(w+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(w+V+O/_,s[1][1])*_:D=Ce(w+V+(l?I:-I)/_,s[0][1])*_,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&f?D=Ce(w+O/_,a[1][1])*_:D=Me(w+(l?I:-I)/_,a[0][1])*_,v=Math.max(v,D)}}if(u){const k=$t(A*_,y,x)/_;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*_?$=(qo(l,c)?-I:I)/_:I=(qo(l,c)?-$:$)*_:d?($=I/_,c=l):(I=$*_,l=c));const C=l?p+I:p,P=c?w+$:w;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 Ai={width:0,height:0,x:0,y:0},Qd={...Ai,pointerX:0,pointerY:0,aspectRatio:1};function Jd(e){return[[0,0],[e.measured.width,e.measured.height]]}function ef(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 tf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Go("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:x}){let m={...Ai},b={...Qd};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Go(c)};let p,w=null,S=[],N,_,I,$=!1;const O=Vr().on("start",A=>{const{nodeLookup:R,transform:V,snapGrid:v,snapToGrid:M,nodeOrigin:C,paneDomNode:P}=n();if(p=R.get(t),!p)return;w=P?.getBoundingClientRect()??null;const{xSnapped:k,ySnapped:D}=ct(A.sourceEvent,{transform:V,snapGrid:v,snapToGrid:M,containerBounds:w});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"?Jd(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=ef(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:w}),P=[];if(!p)return;const{x:k,y:D,width:H,height:B}=m,L={},Z=p.origin??M,{width:F,height:z,x:X,y:Y}=Kd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,Z,_,I),j=F!==H,G=z!==B,Q=X!==k&&j,K=Y!==D&&G;if(!Q&&!K&&!j&&!G)return;if((Q||K||Z[0]===1||Z[1]===1)&&(L.x=Q?X:m.x,L.y=K?Y:m.y,m.x=L.x,m.y=L.y,S.length>0)){const oe=X-k,ne=Y-D;for(const ae of S)ae.position={x:ae.position.x-oe+Z[0]*(F-H),y:ae.position.y-ne+Z[1]*(z-B)},P.push(ae)}if((j||G)&&(L.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:m.width,L.height=G&&(!s.resizeDirection||s.resizeDirection==="vertical")?z: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 q=Ud({width:m.width,prevWidth:H,height:m.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...m,direction:q};x?.(A,U)!==!1&&($=!0,g?.(A,U),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 _n={exports:{}},En={},Nn={exports:{}},Sn={};var Uo;function nf(){if(Uo)return Sn;Uo=1;var e=Sr();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,x=g[1];return i(function(){y.value=h,y.getSnapshot=f,l(y)&&x({inst:y})},[u,h,f]),r(function(){return l(y)&&x({inst:y}),u(function(){l(y)&&x({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 Sn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Sn}var Ko;function of(){return Ko||(Ko=1,Nn.exports=nf()),Nn.exports}var Qo;function rf(){if(Qo)return En;Qo=1;var e=Sr(),t=of();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 En.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 w=_}return w=N}if(_=w,o(p,N))return _;var I=f(N);return h!==void 0&&h(_,I)?(p=N,_):(p=N,w=I)}var b=!1,p,w,S=u===void 0?null:u;return[function(){return m(d())},S===null?void 0:function(){return m(S())}]},[d,u,f,h]);var x=r(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},En}var Jo;function sf(){return Jo||(Jo=1,_n.exports=rf()),_n.exports}var af=sf();const cf=ma(af),lf={},er=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:()=>{(lf?"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},uf=e=>e?er(e):er,{useDebugValue:df}=ya,{useSyncExternalStoreWithSelector:ff}=cf,hf=e=>e;function Pi(e,t=hf,n){const o=ff(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return df(o),o}const tr=(e,t)=>{const n=uf(e),o=(r,i=t)=>Pi(n,r,i);return Object.assign(o,n),o},gf=(e,t)=>e?tr(e,t):tr;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),pf=an.Provider,$i=xe.error001();function ee(e,t){const n=T.useContext(an);if(n===null)throw new Error($i);return Pi(n,e,t)}function ie(){const e=T.useContext(an);if(e===null)throw new Error($i);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nr={display:"none"},mf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Di="react-flow__node-desc",Ti="react-flow__edge-desc",yf="react-flow__aria-live",xf=e=>e.ariaLiveMessage,wf=e=>e.ariaLabelConfig;function vf({rfId:e}){const t=ee(xf);return E.jsx("div",{id:`${yf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mf,children:t})}function bf({rfId:e,disableKeyboardA11y:t}){const n=ee(wf);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${Di}-${e}`,style:nr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Ti}-${e}`,style:nr,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(vf,{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 _f({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 Ef=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 Nf(e,t){return re(e.selectedNodes.map(Dt),t.selectedNodes.map(Dt))&&re(e.selectedEdges.map(Dt),t.selectedEdges.map(Dt))}function Sf({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=ee(Ef,Nf);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Cf=e=>!!e.onSelectionChangeHandlers;function Mf({onSelectionChange:e}){const t=ee(Cf);return e||t?E.jsx(Sf,{onSelectionChange:e}):null}const jn=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ri=[0,0],If={x:0,y:0,zoom:1},kf=["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"],or=[...kf,"rfId"],Af=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}),rr={translateExtent:ht,nodeOrigin:Ri,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Pf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(Af,re),c=ie();jn(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=rr,a()}),[]);const d=T.useRef(rr);return jn(()=>{for(const u of or){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:hd(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=e},or.map(u=>e[u])),null}function ir(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function $f(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=ir(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:ir()?.matches?"dark":"light"}const sr=typeof document<"u"?document:null;function yt(e=null,t={target:sr,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{H as I,J as S,b as u,u as f,j as t,a as _}from"./index-DYOh6gQD.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{H as I,J as S,b as u,u as f,j as t,a as _}from"./index-Da2s4_-5.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 W({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{W as PromptBuilderPanel};