angine 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +3 -2
- package/dist/src/accomplishments.d.ts +29 -0
- package/dist/src/accomplishments.js +43 -0
- package/dist/src/accomplishments.js.map +1 -0
- package/dist/src/reporting.d.ts +1 -1
- package/dist/src/reporting.js +1 -1
- package/docs/releases/v0.5.0.md +19 -0
- package/docs/releasing.md +5 -5
- package/package.json +1 -1
- package/ui/dist/assets/index-BrwaNSwq.css +1 -0
- package/ui/dist/assets/index-Ony46QI7.js +7 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-C9u60ijF.css +0 -1
- package/ui/dist/assets/index-Cd94HjwK.js +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();var gn,oe,Ys,dt,gi,Xs,Zs,Ro,Fn,Qt,qs,Nr,nr,or,Gs,Kn={},Qn=[],ud=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,mn=Array.isArray;function Ze(e,t){for(var n in t)e[n]=t[n];return e}function Ir(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ge(e,t,n){var o,r,s,a={};for(s in t)s=="key"?o=t[s]:s=="ref"?r=t[s]:a[s]=t[s];if(arguments.length>2&&(a.children=arguments.length>3?gn.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)a[s]===void 0&&(a[s]=e.defaultProps[s]);return Jt(e,a,o,r,null)}function Jt(e,t,n,o,r){var s={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r??++Ys,__i:-1,__u:0};return r==null&&oe.vnode!=null&&oe.vnode(s),s}function Ks(){return{current:null}}function q(e){return e.children}function ze(e,t){this.props=e,this.context=t}function wt(e,t){if(t==null)return e.__?wt(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?wt(e):null}function hd(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,o=[],r=[],s=Ze({},t);s.__v=t.__v+1,oe.vnode&&oe.vnode(s),Mr(e.__P,s,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,o,n??wt(t),!!(32&t.__u),r),s.__v=t.__v,s.__.__k[s.__i]=s,na(o,s,r),t.__e=t.__=null,s.__e!=n&&Qs(s)}}function Qs(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Qs(e)}function rr(e){(!e.__d&&(e.__d=!0)&&dt.push(e)&&!Jn.__r++||gi!=oe.debounceRendering)&&((gi=oe.debounceRendering)||Xs)(Jn)}function Jn(){try{for(var e,t=1;dt.length;)dt.length>t&&dt.sort(Zs),e=dt.shift(),t=dt.length,hd(e)}finally{dt.length=Jn.__r=0}}function Js(e,t,n,o,r,s,a,c,u,l,h){var f,d,p,m,_,x,y=o&&o.__k||Qn,S=t.length;for(u=fd(n,t,y,u,S),f=0;f<S;f++)(p=n.__k[f])!=null&&(d=p.__i!=-1&&y[p.__i]||Kn,p.__i=f,x=Mr(e,p,d,r,s,a,c,u,l,h),m=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&Ar(d.ref,null,p),h.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),4&p.__u?(u=ea(p,u,e),d.__e&&(d.__e=null)):typeof p.type=="function"&&x!==void 0?u=x:m&&(u=m.nextSibling),p.__u&=-7);return n.__e=_,u}function fd(e,t,n,o,r){var s,a,c,u,l,h=n.length,f=h,d=0;for(e.__k=new Array(r),s=0;s<r;s++)(a=t[s])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[s]=Jt(null,a,null,null,null):mn(a)?a=e.__k[s]=Jt(q,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[s]=Jt(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[s]=a,u=s+d,a.__=e,a.__b=e.__b+1,c=null,(l=a.__i=pd(a,n,u,f))!=-1&&(f--,(c=n[l])&&(c.__u|=2)),c==null||c.__v==null?(l==-1&&(r>h?d--:r<h&&d++),typeof a.type!="function"&&(a.__u|=4)):l!=u&&(l==u-1?d--:l==u+1?d++:(l>u?d--:d++,a.__u|=4))):e.__k[s]=null;if(f)for(s=0;s<h;s++)(c=n[s])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=wt(c)),ra(c,c));return o}function ea(e,t,n){var o,r;if(typeof e.type=="function"){for(o=e.__k,r=0;o&&r<o.length;r++)o[r]&&(o[r].__=e,t=ea(o[r],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=wt(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function nt(e,t){return t=t||[],e==null||typeof e=="boolean"||(mn(e)?e.some(function(n){nt(n,t)}):t.push(e)),t}function pd(e,t,n,o){var r,s,a,c=e.key,u=e.type,l=t[n],h=l!=null&&(2&l.__u)==0;if(l===null&&c==null||h&&c==l.key&&u==l.type)return n;if(o>(h?1:0)){for(r=n-1,s=n+1;r>=0||s<t.length;)if((l=t[a=r>=0?r--:s++])!=null&&(2&l.__u)==0&&c==l.key&&u==l.type)return a}return-1}function mi(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||ud.test(t)?n:n+"px"}function An(e,t,n,o,r){var s,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||mi(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||mi(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(qs,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=n,n?o?n[Qt]=o[Qt]:(n[Qt]=Nr,e.addEventListener(t,s?or:nr,s)):e.removeEventListener(t,s?or:nr,s);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function yi(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Fn]==null)t[Fn]=Nr++;else if(t[Fn]<n[Qt])return;return n(oe.event?oe.event(t):t)}}}function Mr(e,t,n,o,r,s,a,c,u,l){var h,f,d,p,m,_,x,y,S,g,v,C,b,E,A,P,L=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),s=[c=t.__e=n.__e]),(h=oe.__b)&&h(t);e:if(typeof L=="function"){f=a.length;try{if(S=t.props,g=L.prototype&&L.prototype.render,v=(h=L.contextType)&&o[h.__c],C=h?v?v.props.value:h.__:o,n.__c?y=(d=t.__c=n.__c).__=d.__E:(g?t.__c=d=new L(S,C):(t.__c=d=new ze(S,C),d.constructor=L,d.render=md),v&&v.sub(d),d.state||(d.state={}),d.__n=o,p=d.__d=!0,d.__h=[],d._sb=[]),g&&d.__s==null&&(d.__s=d.state),g&&L.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=Ze({},d.__s)),Ze(d.__s,L.getDerivedStateFromProps(S,d.__s))),m=d.props,_=d.state,d.__v=t,p)g&&L.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),g&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(g&&L.getDerivedStateFromProps==null&&S!==m&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(S,C),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(S,d.__s,C)===!1){t.__v!=n.__v&&(d.props=S,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(D){D&&(D.__=t)}),Qn.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&a.push(d),c=wt(n);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(S,d.__s,C),g&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(m,_,x)})}if(d.context=C,d.props=S,d.__P=e,d.__e=!1,b=oe.__r,E=0,g)d.state=d.__s,d.__d=!1,b&&b(t),h=d.render(d.props,d.state,d.context),Qn.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,b&&b(t),h=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++E<25);d.state=d.__s,d.getChildContext!=null&&(o=Ze(Ze({},o),d.getChildContext())),g&&!p&&d.getSnapshotBeforeUpdate!=null&&(x=d.getSnapshotBeforeUpdate(m,_)),A=h!=null&&h.type===q&&h.key==null?oa(h.props.children):h,c=Js(e,mn(A)?A:[A],t,n,o,r,s,a,c,u,l),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),y&&(d.__E=d.__=null)}catch(D){if(a.length=f,t.__v=null,u||s!=null){if(D.then){for(t.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;s!=null&&(s[s.indexOf(c)]=null),t.__e=c}else if(s!=null)for(P=s.length;P--;)Ir(s[P])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),D.then||ta(t),oe.__e(D,t,n)}}else s==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=gd(n.__e,t,n,o,r,s,a,u,l);return(h=oe.diffed)&&h(t),128&t.__u?void 0:c}function ta(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ta))}function na(e,t,n){for(var o=0;o<n.length;o++)Ar(n[o],n[++o],n[++o]);oe.__c&&oe.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(s){s.call(r)})}catch(s){oe.__e(s,r.__v)}})}function oa(e){return typeof e!="object"||e==null||e.__b>0?e:mn(e)?e.map(oa):e.constructor!==void 0?null:Ze({},e)}function gd(e,t,n,o,r,s,a,c,u){var l,h,f,d,p,m,_,x=n.props||Kn,y=t.props,S=t.type;if(S=="svg"?r="http://www.w3.org/2000/svg":S=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((p=s[l])&&"setAttribute"in p==!!S&&(S?p.localName==S:p.nodeType==3)){e=p,s[l]=null;break}}if(e==null){if(S==null)return document.createTextNode(y);e=document.createElementNS(r,S,y.is&&y),c&&(oe.__m&&oe.__m(t,s),c=!1),s=null}if(S==null)x===y||c&&e.data==y||(e.data=y);else{if(s=S=="textarea"&&y.defaultValue!=null?null:s&&gn.call(e.childNodes),!c&&s!=null)for(x={},l=0;l<e.attributes.length;l++)x[(p=e.attributes[l]).name]=p.value;for(l in x)p=x[l],l=="dangerouslySetInnerHTML"?f=p:l=="children"||l in y||l=="value"&&"defaultValue"in y||l=="checked"&&"defaultChecked"in y||An(e,l,null,p,r);for(l in y)p=y[l],l=="children"?d=p:l=="dangerouslySetInnerHTML"?h=p:l=="value"?m=p:l=="checked"?_=p:c&&typeof p!="function"||x[l]===p||An(e,l,p,x[l],r);if(h)c||f&&(h.__html==f.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(f&&(e.innerHTML=""),Js(t.type=="template"?e.content:e,mn(d)?d:[d],t,n,o,S=="foreignObject"?"http://www.w3.org/1999/xhtml":r,s,a,s?s[0]:n.__k&&wt(n,0),c,u),s!=null)for(l=s.length;l--;)Ir(s[l]);c&&S!="textarea"||(l="value",S=="progress"&&m==null?e.removeAttribute("value"):m!=null&&(m!==e[l]||S=="progress"&&!m||S=="option"&&m!=x[l])&&An(e,l,m,x[l],r),l="checked",_!=null&&_!=e[l]&&An(e,l,_,x[l],r))}return e}function Ar(e,t,n){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(r){oe.__e(r,n)}}function ra(e,t,n){var o,r;if(oe.unmount&&oe.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Ar(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){oe.__e(s,t)}o.base=o.__P=o.__n=null}if(o=e.__k)for(r=0;r<o.length;r++)o[r]&&ra(o[r],t,n||typeof e.type!="function");n||Ir(e.__e),e.__c=e.__=e.__e=void 0}function md(e,t,n){return this.constructor(e,n)}function Tt(e,t,n){var o,r,s,a;t==document&&(t=document.documentElement),oe.__&&oe.__(e,t),r=(o=typeof n=="function")?null:n&&n.__k||t.__k,s=[],a=[],Mr(t,e=(!o&&n||t).__k=Ge(q,null,[e]),r||Kn,Kn,t.namespaceURI,!o&&n?[n]:r?null:t.firstChild?gn.call(t.childNodes):null,s,!o&&n?n:r?r.__e:t.firstChild,o,a),na(s,e,a),e.props.children=null}function ia(e,t){Tt(e,t,ia)}function yd(e,t,n){var o,r,s,a,c=Ze({},e.props);for(s in e.type&&e.type.defaultProps&&(a=e.type.defaultProps),t)s=="key"?o=t[s]:s=="ref"?r=t[s]:c[s]=t[s]===void 0&&a!=null?a[s]:t[s];return arguments.length>2&&(c.children=arguments.length>3?gn.call(arguments,2):n),Jt(e.type,c,o||e.key,r||e.ref,null)}function Ft(e){function t(n){var o,r;return this.getChildContext||(o=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,rr(a)})},this.sub=function(s){o.add(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),a&&a.call(s)}}),n.children}return t.__c="__cC"+Gs++,t.__=e,t.Provider=t.__l=(t.Consumer=function(n,o){return n.children(o)}).contextType=t,t}gn=Qn.slice,oe={__e:function(e,t,n,o){for(var r,s,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((s=r.constructor)&&s.getDerivedStateFromError!=null&&(r.setState(s.getDerivedStateFromError(e)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,o||{}),a=r.__d),a)return r.__E=r}catch(c){e=c}throw e}},Ys=0,ze.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ze({},this.state),typeof e=="function"&&(e=e(Ze({},n),this.props)),e&&Ze(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),rr(this))},ze.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),rr(this))},ze.prototype.render=q,dt=[],Xs=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Zs=function(e,t){return e.__v.__b-t.__v.__b},Jn.__r=0,Ro=Math.random().toString(8),Fn="__d"+Ro,Qt="__a"+Ro,qs=/(PointerCapture)$|Capture$/i,Nr=0,nr=yi(!1),or=yi(!0),Gs=0;var vd=0;function i(e,t,n,o,r,s){t||(t={});var a,c,u=t;if("ref"in u)for(c in u={},t)c=="ref"?a=t[c]:u[c]=t[c];var l={type:e,props:u,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--vd,__i:-1,__u:0,__source:r,__self:s};if(typeof e=="function"&&(a=e.defaultProps))for(c in a)u[c]===void 0&&(u[c]=a[c]);return oe.vnode&&oe.vnode(l),l}var ot,de,Lo,vi,Dt=0,sa=[],fe=oe,_i=fe.__b,wi=fe.__r,xi=fe.diffed,bi=fe.__c,Si=fe.unmount,ki=fe.__;function Et(e,t){fe.__h&&fe.__h(de,e,Dt||t),Dt=0;var n=de.__H||(de.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function X(e){return Dt=1,fo(aa,e)}function fo(e,t,n){var o=Et(ot++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):aa(void 0,t),function(c){var u=o.__N?o.__N[0]:o.__[0],l=o.t(u,c);u!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=de,!de.__f)){var r=function(c,u,l){if(!o.__c.__H)return!0;var h=!1,f=o.__c.props!==c;if(o.__c.__H.__.some(function(p){if(p.__N){h=!0;var m=p.__[0];p.__=p.__N,p.__N=void 0,m!==p.__[0]&&(f=!0)}}),s){var d=s.call(this,c,u,l);return h?d||f:d}return!h||f};de.__f=!0;var s=de.shouldComponentUpdate,a=de.componentWillUpdate;de.componentWillUpdate=function(c,u,l){if(this.__e){var h=s;s=void 0,r(c,u,l),s=h}a&&a.call(this,c,u,l)},de.shouldComponentUpdate=r}return o.__N||o.__}function ne(e,t){var n=Et(ot++,3);!fe.__s&&Dr(n.__H,t)&&(n.__=e,n.u=t,de.__H.__h.push(n))}function it(e,t){var n=Et(ot++,4);!fe.__s&&Dr(n.__H,t)&&(n.__=e,n.u=t,de.__h.push(n))}function re(e){return Dt=5,ve(function(){return{current:e}},[])}function $r(e,t,n){Dt=6,it(function(){if(typeof e=="function"){var o=e(t());return function(){e(null),o&&typeof o=="function"&&o()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function ve(e,t){var n=Et(ot++,7);return Dr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Me(e,t){return Dt=8,ve(function(){return e},t)}function st(e){var t=de.context[e.__c],n=Et(ot++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(de)),t.props.value):e.__}function Pr(e,t){fe.useDebugValue&&fe.useDebugValue(t?t(e):e)}function _d(e){var t=Et(ot++,10),n=X();return t.__=e,de.componentDidCatch||(de.componentDidCatch=function(o,r){t.__&&t.__(o,r),n[1](o)}),[n[0],function(){n[1](void 0)}]}function Tr(){var e=Et(ot++,11);if(!e.__){for(var t=de.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function wd(){for(var e;e=sa.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Un),t.__h.some(ir),t.__h=[]}catch(n){t.__h=[],fe.__e(n,e.__v)}}}fe.__b=function(e){de=null,_i&&_i(e)},fe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ki&&ki(e,t)},fe.__r=function(e){wi&&wi(e),ot=0;var t=(de=e.__c).__H;t&&(Lo===de?(t.__h=[],de.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Un),t.__h.some(ir),t.__h=[],ot=0)),Lo=de},fe.diffed=function(e){xi&&xi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(sa.push(t)!==1&&vi===fe.requestAnimationFrame||((vi=fe.requestAnimationFrame)||xd)(wd)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Lo=de=null},fe.__c=function(e,t){t.some(function(n){try{n.__h.some(Un),n.__h=n.__h.filter(function(o){return!o.__||ir(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],fe.__e(o,n.__v)}}),bi&&bi(e,t)},fe.unmount=function(e){Si&&Si(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(o){try{Un(o)}catch(r){t=r}}),n.__H=void 0,t&&fe.__e(t,n.__v))};var Ci=typeof requestAnimationFrame=="function";function xd(e){var t,n=function(){clearTimeout(o),Ci&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Ci&&(t=requestAnimationFrame(n))}function Un(e){var t=de,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),de=t}function ir(e){var t=de;e.__c=e.__(),de=t}function Dr(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function aa(e,t){return typeof t=="function"?t(e):t}function ca(e,t){for(var n in t)e[n]=t[n];return e}function sr(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function jr(e,t){var n=t(),o=X({t:{__:n,u:t}}),r=o[0].t,s=o[1];return it(function(){r.__=n,r.u=t,Ho(r)&&s({t:r})},[e,n,t]),ne(function(){return Ho(r)&&s({t:r}),e(function(){Ho(r)&&s({t:r})})},[e]),n}function Ho(e){try{return!((t=e.__)===(n=e.u())&&(t!==0||1/t==1/n)||t!=t&&n!=n)}catch{return!0}var t,n}function Or(e){e()}function Rr(e){return e}function Lr(){return[!1,Or]}var Hr=it;function eo(e,t){this.props=e,this.context=t}function ge(e,t){function n(r){var s=this.props.ref;return s!=r.ref&&s&&(typeof s=="function"?s(null):s.current=null),t?!t(this.props,r)||s!=r.ref:sr(this.props,r)}function o(r){return this.shouldComponentUpdate=n,Ge(e,r)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.__f=o.prototype.isReactComponent=!0,o.type=e,o}(eo.prototype=new ze).isPureReactComponent=!0,eo.prototype.shouldComponentUpdate=function(e,t){return sr(this.props,e)||sr(this.state,t)};var Ei=oe.__b;oe.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ei&&Ei(e)};var bd=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function po(e){function t(n){var o=ca({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=bd,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Ni=function(e,t){return e==null?null:nt(nt(e).map(t))},la={map:Ni,forEach:Ni,count:function(e){return e?nt(e).length:0},only:function(e){var t=nt(e);if(t.length!==1)throw"Children.only";return t[0]},toArray:nt},Sd=oe.__e;oe.__e=function(e,t,n,o){if(e.then){for(var r,s=t;s=s.__;)if((r=s.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k||[]),r.__c(e,t)}Sd(e,t,n,o)};var Ii=oe.unmount;function da(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=ca({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return da(o,t,n)})),e}function ua(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return ua(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function en(){this.__u=0,this.o=null,this.__b=null}function ha(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function fa(e){var t,n,o,r=null;function s(a){if(t||(t=e()).then(function(c){c&&(r=c.default||c),o=!0},function(c){n=c,o=!0}),n)throw n;if(!o)throw t;return r?Ge(r,a):null}return s.displayName="Lazy",s.__f=!0,s}function It(){this.i=null,this.l=null}oe.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ii&&Ii(e)},(en.prototype=new ze).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=ha(o.__v),s=!1,a=function(){s||o.__z||(s=!0,n.__R=null,r?r(u):u())};n.__R=a;var c=n.__P;n.__P=null;var u=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=ua(l,l.__c.__P,l.__c.__O)}var h;for(o.setState({__a:o.__b=null});h=o.o.pop();)h.__P=c,h.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(a,a)},en.prototype.componentWillUnmount=function(){this.o=[]},en.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=da(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&Ge(q,null,e.fallback);return r&&(r.__u&=-33),[Ge(q,null,t.__a?null:e.children),r]};var Mi=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function kd(e){return this.getChildContext=function(){return e.context},e.children}function Cd(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){Tt(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var o=t.__v;o!==null&&!o.__m&&o.__!==null;)o=o.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:o.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(r,s){this.childNodes.push(r),t.h.insertBefore(r,s)},removeChild:function(r){this.childNodes.splice(this.childNodes.indexOf(r)>>>1,1),t.h.removeChild(r)}}}Tt(Ge(kd,{context:t.context},e.__v),t.v)}function pa(e,t){var n=Ge(Cd,{__v:e,h:t});return n.containerInfo=t,n}(It.prototype=new ze).__a=function(e){var t=this,n=ha(t.__v),o=t.l.get(e);return o[0]++,function(r){var s=function(){t.props.revealOrder?(o.push(r),Mi(t,e,o)):r()};n?n(s):s()}},It.prototype.render=function(e){this.i=null,this.l=new Map;var t=nt(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},It.prototype.componentDidUpdate=It.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Mi(e,n,t)})};var ga=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Ed=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Nd=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Id=/[A-Z0-9]/g,Md=typeof document<"u",Ad=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function ma(e,t,n){return t.__k==null&&(t.textContent=""),Tt(e,t),typeof n=="function"&&n(),e?e.__c:null}function ya(e,t,n){return ia(e,t),typeof n=="function"&&n(),e?e.__c:null}ze.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(ze.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Ai=oe.event;oe.event=function(e){return Ai&&(e=Ai(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var zr,$d={configurable:!0,get:function(){return this.class}},$i=oe.vnode;oe.vnode=function(e){typeof e.type=="string"&&(function(t){var n=t.props,o=t.type,r={},s=o.indexOf("-")==-1;for(var a in n){var c=n[a];if(!(a==="value"&&"defaultValue"in n&&c==null||Md&&a==="children"&&o==="noscript"||a==="class"||a==="className")){var u=a.toLowerCase();a==="defaultValue"&&"value"in n&&n.value==null?a="value":a==="download"&&c===!0?c="":u==="translate"&&c==="no"?c=!1:u[0]==="o"&&u[1]==="n"?u==="ondoubleclick"?a="ondblclick":u!=="onchange"||o!=="input"&&o!=="textarea"||Ad(n.type)?u==="onfocus"?a="onfocusin":u==="onblur"?a="onfocusout":Nd.test(a)&&(a=u):u=a="oninput":s&&Ed.test(a)?a=a.replace(Id,"-$&").toLowerCase():c===null&&(c=void 0),u==="oninput"&&r[a=u]&&(a="oninputCapture"),r[a]=c}}o=="select"&&(r.multiple&&Array.isArray(r.value)&&(r.value=nt(n.children).forEach(function(l){l.props.selected=r.value.indexOf(l.props.value)!=-1})),r.defaultValue!=null&&(r.value=nt(n.children).forEach(function(l){l.props.selected=r.multiple?r.defaultValue.indexOf(l.props.value)!=-1:r.defaultValue==l.props.value}))),n.class&&!n.className?(r.class=n.class,Object.defineProperty(r,"className",$d)):n.className&&(r.class=r.className=n.className),t.props=r})(e),e.$$typeof=ga,$i&&$i(e)};var Pi=oe.__r;oe.__r=function(e){Pi&&Pi(e),zr=e.__c};var Ti=oe.diffed;oe.diffed=function(e){Ti&&Ti(e);var t=e.props,n=e.__e;n!=null&&e.type==="textarea"&&"value"in t&&t.value!==n.value&&(n.value=t.value==null?"":t.value),zr=null};var va={ReactCurrentDispatcher:{current:{readContext:function(e){return zr.__n[e.__c].props.value},useCallback:Me,useContext:st,useDebugValue:Pr,useDeferredValue:Rr,useEffect:ne,useId:Tr,useImperativeHandle:$r,useInsertionEffect:Hr,useLayoutEffect:it,useMemo:ve,useReducer:fo,useRef:re,useState:X,useSyncExternalStore:jr,useTransition:Lr}}},Pd="18.3.1";function _a(e){return Ge.bind(null,e)}function yn(e){return!!e&&e.$$typeof===ga}function wa(e){return yn(e)&&e.type===q}function xa(e){return!!e&&typeof e.displayName=="string"&&e.displayName.indexOf("Memo(")==0}function ba(e){return yn(e)?yd.apply(null,arguments):e}function Sa(e){return!!e.__k&&(Tt(null,e),!0)}function ka(e){return e&&(e.base||e.nodeType===1&&e)||null}var Ca=function(e,t){return e(t)},Ea=function(e,t){var n,o=oe.debounceRendering;oe.debounceRendering=function(s){n=s};try{var r=e(t);return n&&n(),r}finally{oe.debounceRendering=o}},Na=yn,Ia={useState:X,useId:Tr,useReducer:fo,useEffect:ne,useLayoutEffect:it,useInsertionEffect:Hr,useTransition:Lr,useDeferredValue:Rr,useSyncExternalStore:jr,startTransition:Or,useRef:re,useImperativeHandle:$r,useMemo:ve,useCallback:Me,useContext:st,useDebugValue:Pr,version:"18.3.1",Children:la,render:ma,hydrate:ya,unmountComponentAtNode:Sa,createPortal:pa,createElement:Ge,createContext:Ft,createFactory:_a,cloneElement:ba,createRef:Ks,Fragment:q,isValidElement:yn,isElement:Na,isFragment:wa,isMemo:xa,findDOMNode:ka,Component:ze,PureComponent:eo,memo:ge,forwardRef:po,flushSync:Ea,unstable_batchedUpdates:Ca,StrictMode:q,Suspense:en,SuspenseList:It,lazy:fa,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:va};const Td=Object.freeze(Object.defineProperty({__proto__:null,Children:la,Component:ze,Fragment:q,PureComponent:eo,StrictMode:q,Suspense:en,SuspenseList:It,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:va,cloneElement:ba,createContext:Ft,createElement:Ge,createFactory:_a,createPortal:pa,createRef:Ks,default:Ia,findDOMNode:ka,flushSync:Ea,forwardRef:po,hydrate:ya,isElement:Na,isFragment:wa,isMemo:xa,isValidElement:yn,lazy:fa,memo:ge,render:ma,startTransition:Or,unmountComponentAtNode:Sa,unstable_batchedUpdates:Ca,useCallback:Me,useContext:st,useDebugValue:Pr,useDeferredValue:Rr,useEffect:ne,useErrorBoundary:_d,useId:Tr,useImperativeHandle:$r,useInsertionEffect:Hr,useLayoutEffect:it,useMemo:ve,useReducer:fo,useRef:re,useState:X,useSyncExternalStore:jr,useTransition:Lr,version:Pd},Symbol.toStringTag,{value:"Module"}));function me(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=me(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Dd={value:()=>{}};function go(){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 Wn(n)}function Wn(e){this._=e}function jd(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}})}Wn.prototype=go.prototype={constructor:Wn,on:function(e,t){var n=this._,o=jd(e+"",n),r,s=-1,a=o.length;if(arguments.length<2){for(;++s<a;)if((r=(e=o[s]).type)&&(r=Od(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(r=(e=o[s]).type)n[r]=Di(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Di(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 Wn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,s;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,r=s.length;o<r;++o)s[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,s=o.length;r<s;++r)o[r].value.apply(t,n)}};function Od(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Di(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Dd,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var ar="http://www.w3.org/1999/xhtml";const ji={svg:"http://www.w3.org/2000/svg",xhtml:ar,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function mo(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ji.hasOwnProperty(t)?{space:ji[t],local:e}:e}function Rd(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ar&&t.documentElement.namespaceURI===ar?t.createElement(e):t.createElementNS(n,e)}}function Ld(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ma(e){var t=mo(e);return(t.local?Ld:Rd)(t)}function Hd(){}function Br(e){return e==null?Hd:function(){return this.querySelector(e)}}function zd(e){typeof e!="function"&&(e=Br(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],a=s.length,c=o[r]=new Array(a),u,l,h=0;h<a;++h)(u=s[h])&&(l=e.call(u,u.__data__,h,s))&&("__data__"in u&&(l.__data__=u.__data__),c[h]=l);return new Ae(o,this._parents)}function Bd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Vd(){return[]}function Aa(e){return e==null?Vd:function(){return this.querySelectorAll(e)}}function Fd(e){return function(){return Bd(e.apply(this,arguments))}}function Ud(e){typeof e=="function"?e=Fd(e):e=Aa(e);for(var t=this._groups,n=t.length,o=[],r=[],s=0;s<n;++s)for(var a=t[s],c=a.length,u,l=0;l<c;++l)(u=a[l])&&(o.push(e.call(u,u.__data__,l,a)),r.push(u));return new Ae(o,r)}function $a(e){return function(){return this.matches(e)}}function Pa(e){return function(t){return t.matches(e)}}var Wd=Array.prototype.find;function Yd(e){return function(){return Wd.call(this.children,e)}}function Xd(){return this.firstElementChild}function Zd(e){return this.select(e==null?Xd:Yd(typeof e=="function"?e:Pa(e)))}var qd=Array.prototype.filter;function Gd(){return Array.from(this.children)}function Kd(e){return function(){return qd.call(this.children,e)}}function Qd(e){return this.selectAll(e==null?Gd:Kd(typeof e=="function"?e:Pa(e)))}function Jd(e){typeof e!="function"&&(e=$a(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],a=s.length,c=o[r]=[],u,l=0;l<a;++l)(u=s[l])&&e.call(u,u.__data__,l,s)&&c.push(u);return new Ae(o,this._parents)}function Ta(e){return new Array(e.length)}function eu(){return new Ae(this._enter||this._groups.map(Ta),this._parents)}function to(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}to.prototype={constructor:to,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 tu(e){return function(){return e}}function nu(e,t,n,o,r,s){for(var a=0,c,u=t.length,l=s.length;a<l;++a)(c=t[a])?(c.__data__=s[a],o[a]=c):n[a]=new to(e,s[a]);for(;a<u;++a)(c=t[a])&&(r[a]=c)}function ou(e,t,n,o,r,s,a){var c,u,l=new Map,h=t.length,f=s.length,d=new Array(h),p;for(c=0;c<h;++c)(u=t[c])&&(d[c]=p=a.call(u,u.__data__,c,t)+"",l.has(p)?r[c]=u:l.set(p,u));for(c=0;c<f;++c)p=a.call(e,s[c],c,s)+"",(u=l.get(p))?(o[c]=u,u.__data__=s[c],l.delete(p)):n[c]=new to(e,s[c]);for(c=0;c<h;++c)(u=t[c])&&l.get(d[c])===u&&(r[c]=u)}function ru(e){return e.__data__}function iu(e,t){if(!arguments.length)return Array.from(this,ru);var n=t?ou:nu,o=this._parents,r=this._groups;typeof e!="function"&&(e=tu(e));for(var s=r.length,a=new Array(s),c=new Array(s),u=new Array(s),l=0;l<s;++l){var h=o[l],f=r[l],d=f.length,p=su(e.call(h,h&&h.__data__,l,o)),m=p.length,_=c[l]=new Array(m),x=a[l]=new Array(m),y=u[l]=new Array(d);n(h,f,_,x,y,p,t);for(var S=0,g=0,v,C;S<m;++S)if(v=_[S]){for(S>=g&&(g=S+1);!(C=x[g])&&++g<m;);v._next=C||null}}return a=new Ae(a,o),a._enter=c,a._exit=u,a}function su(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function au(){return new Ae(this._exit||this._groups.map(Ta),this._parents)}function cu(e,t,n){var o=this.enter(),r=this,s=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?s.remove():n(s),o&&r?o.merge(r).order():r}function lu(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,s=o.length,a=Math.min(r,s),c=new Array(r),u=0;u<a;++u)for(var l=n[u],h=o[u],f=l.length,d=c[u]=new Array(f),p,m=0;m<f;++m)(p=l[m]||h[m])&&(d[m]=p);for(;u<r;++u)c[u]=n[u];return new Ae(c,this._parents)}function du(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,s=o[r],a;--r>=0;)(a=o[r])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function uu(e){e||(e=hu);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),s=0;s<o;++s){for(var a=n[s],c=a.length,u=r[s]=new Array(c),l,h=0;h<c;++h)(l=a[h])&&(u[h]=l);u.sort(t)}return new Ae(r,this._parents).order()}function hu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function fu(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function pu(){return Array.from(this)}function gu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length;r<s;++r){var a=o[r];if(a)return a}return null}function mu(){let e=0;for(const t of this)++e;return e}function yu(){return!this.node()}function vu(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],s=0,a=r.length,c;s<a;++s)(c=r[s])&&e.call(c,c.__data__,s,r);return this}function _u(e){return function(){this.removeAttribute(e)}}function wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xu(e,t){return function(){this.setAttribute(e,t)}}function bu(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Su(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ku(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 Cu(e,t){var n=mo(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?wu:_u:typeof t=="function"?n.local?ku:Su:n.local?bu:xu)(n,t))}function Da(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Eu(e){return function(){this.style.removeProperty(e)}}function Nu(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Iu(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Mu(e,t,n){return arguments.length>1?this.each((t==null?Eu:typeof t=="function"?Iu:Nu)(e,t,n??"")):jt(this.node(),e)}function jt(e,t){return e.style.getPropertyValue(t)||Da(e).getComputedStyle(e,null).getPropertyValue(t)}function Au(e){return function(){delete this[e]}}function $u(e,t){return function(){this[e]=t}}function Pu(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Tu(e,t){return arguments.length>1?this.each((t==null?Au:typeof t=="function"?Pu:$u)(e,t)):this.node()[e]}function ja(e){return e.trim().split(/^|\s+/)}function Vr(e){return e.classList||new Oa(e)}function Oa(e){this._node=e,this._names=ja(e.getAttribute("class")||"")}Oa.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 Ra(e,t){for(var n=Vr(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function La(e,t){for(var n=Vr(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Du(e){return function(){Ra(this,e)}}function ju(e){return function(){La(this,e)}}function Ou(e,t){return function(){(t.apply(this,arguments)?Ra:La)(this,e)}}function Ru(e,t){var n=ja(e+"");if(arguments.length<2){for(var o=Vr(this.node()),r=-1,s=n.length;++r<s;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Ou:t?Du:ju)(n,t))}function Lu(){this.textContent=""}function Hu(e){return function(){this.textContent=e}}function zu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Bu(e){return arguments.length?this.each(e==null?Lu:(typeof e=="function"?zu:Hu)(e)):this.node().textContent}function Vu(){this.innerHTML=""}function Fu(e){return function(){this.innerHTML=e}}function Uu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Wu(e){return arguments.length?this.each(e==null?Vu:(typeof e=="function"?Uu:Fu)(e)):this.node().innerHTML}function Yu(){this.nextSibling&&this.parentNode.appendChild(this)}function Xu(){return this.each(Yu)}function Zu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qu(){return this.each(Zu)}function Gu(e){var t=typeof e=="function"?e:Ma(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ku(){return null}function Qu(e,t){var n=typeof e=="function"?e:Ma(e),o=t==null?Ku:typeof t=="function"?t:Br(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Ju(){var e=this.parentNode;e&&e.removeChild(this)}function eh(){return this.each(Ju)}function th(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oh(e){return this.select(e?nh:th)}function rh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ih(e){return function(t){e.call(this,t,this.__data__)}}function sh(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 ah(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,s;n<r;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++o]=s;++o?t.length=o:delete this.__on}}}function ch(e,t,n){return function(){var o=this.__on,r,s=ih(t);if(o){for(var a=0,c=o.length;a<c;++a)if((r=o[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=s,r.options=n),r.value=t;return}}this.addEventListener(e.type,s,n),r={type:e.type,name:e.name,value:t,listener:s,options:n},o?o.push(r):this.__on=[r]}}function lh(e,t,n){var o=sh(e+""),r,s=o.length,a;if(arguments.length<2){var c=this.node().__on;if(c){for(var u=0,l=c.length,h;u<l;++u)for(r=0,h=c[u];r<s;++r)if((a=o[r]).type===h.type&&a.name===h.name)return h.value}return}for(c=t?ch:ah,r=0;r<s;++r)this.each(c(o[r],t,n));return this}function Ha(e,t,n){var o=Da(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 dh(e,t){return function(){return Ha(this,e,t)}}function uh(e,t){return function(){return Ha(this,e,t.apply(this,arguments))}}function hh(e,t){return this.each((typeof t=="function"?uh:dh)(e,t))}function*fh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,s=o.length,a;r<s;++r)(a=o[r])&&(yield a)}var za=[null];function Ae(e,t){this._groups=e,this._parents=t}function vn(){return new Ae([[document.documentElement]],za)}function ph(){return this}Ae.prototype=vn.prototype={constructor:Ae,select:zd,selectAll:Ud,selectChild:Zd,selectChildren:Qd,filter:Jd,data:iu,enter:eu,exit:au,join:cu,merge:lu,selection:ph,order:du,sort:uu,call:fu,nodes:pu,node:gu,size:mu,empty:yu,each:vu,attr:Cu,style:Mu,property:Tu,classed:Ru,text:Bu,html:Wu,raise:Xu,lower:qu,append:Gu,insert:Qu,remove:eh,clone:oh,datum:rh,on:lh,dispatch:hh,[Symbol.iterator]:fh};function Ie(e){return typeof e=="string"?new Ae([[document.querySelector(e)]],[document.documentElement]):new Ae([[e]],za)}function gh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Oe(e,t){if(e=gh(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 mh={passive:!1},rn={capture:!0,passive:!1};function zo(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function Ba(e){var t=e.document.documentElement,n=Ie(e).on("dragstart.drag",$t,rn);"onselectstart"in t?n.on("selectstart.drag",$t,rn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Va(e,t){var n=e.document.documentElement,o=Ie(e).on("dragstart.drag",null);t&&(o.on("click.drag",$t,rn),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 $n=e=>()=>e;function cr(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:s,x:a,y:c,dx:u,dy:l,dispatch:h}){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:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:h}})}cr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function yh(e){return!e.ctrlKey&&!e.button}function vh(){return this.parentNode}function _h(e,t){return t??{x:e.x,y:e.y}}function wh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fa(){var e=yh,t=vh,n=_h,o=wh,r={},s=go("start","drag","end"),a=0,c,u,l,h,f=0;function d(v){v.on("mousedown.drag",p).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,mh).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(v,C){if(!(h||!e.call(this,v,C))){var b=g(this,t.call(this,v,C),v,C,"mouse");b&&(Ie(v.view).on("mousemove.drag",m,rn).on("mouseup.drag",_,rn),Ba(v.view),zo(v),l=!1,c=v.clientX,u=v.clientY,b("start",v))}}function m(v){if($t(v),!l){var C=v.clientX-c,b=v.clientY-u;l=C*C+b*b>f}r.mouse("drag",v)}function _(v){Ie(v.view).on("mousemove.drag mouseup.drag",null),Va(v.view,l),$t(v),r.mouse("end",v)}function x(v,C){if(e.call(this,v,C)){var b=v.changedTouches,E=t.call(this,v,C),A=b.length,P,L;for(P=0;P<A;++P)(L=g(this,E,v,C,b[P].identifier,b[P]))&&(zo(v),L("start",v,b[P]))}}function y(v){var C=v.changedTouches,b=C.length,E,A;for(E=0;E<b;++E)(A=r[C[E].identifier])&&($t(v),A("drag",v,C[E]))}function S(v){var C=v.changedTouches,b=C.length,E,A;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),E=0;E<b;++E)(A=r[C[E].identifier])&&(zo(v),A("end",v,C[E]))}function g(v,C,b,E,A,P){var L=s.copy(),D=Oe(P||b,C),V,N,k;if((k=n.call(v,new cr("beforestart",{sourceEvent:b,target:d,identifier:A,active:a,x:D[0],y:D[1],dx:0,dy:0,dispatch:L}),E))!=null)return V=k.x-D[0]||0,N=k.y-D[1]||0,function I(M,$,O){var j=D,B;switch(M){case"start":r[A]=I,B=a++;break;case"end":delete r[A],--a;case"drag":D=Oe(O||$,C),B=a;break}L.call(M,v,new cr(M,{sourceEvent:$,subject:k,target:d,identifier:A,active:B,x:D[0]+V,y:D[1]+N,dx:D[0]-j[0],dy:D[1]-j[1],dispatch:L}),E)}}return d.filter=function(v){return arguments.length?(e=typeof v=="function"?v:$n(!!v),d):e},d.container=function(v){return arguments.length?(t=typeof v=="function"?v:$n(v),d):t},d.subject=function(v){return arguments.length?(n=typeof v=="function"?v:$n(v),d):n},d.touchable=function(v){return arguments.length?(o=typeof v=="function"?v:$n(!!v),d):o},d.on=function(){var v=s.on.apply(s,arguments);return v===s?d:v},d.clickDistance=function(v){return arguments.length?(f=(v=+v)*v,d):Math.sqrt(f)},d}function Fr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ua(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function _n(){}var sn=.7,no=1/sn,Pt="\\s*([+-]?\\d+)\\s*",an="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xh=/^#([0-9a-f]{3,8})$/,bh=new RegExp(`^rgb\\(${Pt},${Pt},${Pt}\\)$`),Sh=new RegExp(`^rgb\\(${qe},${qe},${qe}\\)$`),kh=new RegExp(`^rgba\\(${Pt},${Pt},${Pt},${an}\\)$`),Ch=new RegExp(`^rgba\\(${qe},${qe},${qe},${an}\\)$`),Eh=new RegExp(`^hsl\\(${an},${qe},${qe}\\)$`),Nh=new RegExp(`^hsla\\(${an},${qe},${qe},${an}\\)$`),Oi={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};Fr(_n,xt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ri,formatHex:Ri,formatHex8:Ih,formatHsl:Mh,formatRgb:Li,toString:Li});function Ri(){return this.rgb().formatHex()}function Ih(){return this.rgb().formatHex8()}function Mh(){return Wa(this).formatHsl()}function Li(){return this.rgb().formatRgb()}function xt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=xh.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hi(t):n===3?new Ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Pn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Pn(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=bh.exec(e))?new Ce(t[1],t[2],t[3],1):(t=Sh.exec(e))?new Ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=kh.exec(e))?Pn(t[1],t[2],t[3],t[4]):(t=Ch.exec(e))?Pn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Eh.exec(e))?Vi(t[1],t[2]/100,t[3]/100,1):(t=Nh.exec(e))?Vi(t[1],t[2]/100,t[3]/100,t[4]):Oi.hasOwnProperty(e)?Hi(Oi[e]):e==="transparent"?new Ce(NaN,NaN,NaN,0):null}function Hi(e){return new Ce(e>>16&255,e>>8&255,e&255,1)}function Pn(e,t,n,o){return o<=0&&(e=t=n=NaN),new Ce(e,t,n,o)}function Ah(e){return e instanceof _n||(e=xt(e)),e?(e=e.rgb(),new Ce(e.r,e.g,e.b,e.opacity)):new Ce}function lr(e,t,n,o){return arguments.length===1?Ah(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}Fr(Ce,lr,Ua(_n,{brighter(e){return e=e==null?no:Math.pow(no,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ce(yt(this.r),yt(this.g),yt(this.b),oo(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:zi,formatHex:zi,formatHex8:$h,formatRgb:Bi,toString:Bi}));function zi(){return`#${mt(this.r)}${mt(this.g)}${mt(this.b)}`}function $h(){return`#${mt(this.r)}${mt(this.g)}${mt(this.b)}${mt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Bi(){const e=oo(this.opacity);return`${e===1?"rgb(":"rgba("}${yt(this.r)}, ${yt(this.g)}, ${yt(this.b)}${e===1?")":`, ${e})`}`}function oo(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function yt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function mt(e){return e=yt(e),(e<16?"0":"")+e.toString(16)}function Vi(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Re(e,t,n,o)}function Wa(e){if(e instanceof Re)return new Re(e.h,e.s,e.l,e.opacity);if(e instanceof _n||(e=xt(e)),!e)return new Re;if(e instanceof Re)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),s=Math.max(t,n,o),a=NaN,c=s-r,u=(s+r)/2;return c?(t===s?a=(n-o)/c+(n<o)*6:n===s?a=(o-t)/c+2:a=(t-n)/c+4,c/=u<.5?s+r:2-s-r,a*=60):c=u>0&&u<1?0:a,new Re(a,c,u,e.opacity)}function Ph(e,t,n,o){return arguments.length===1?Wa(e):new Re(e,t,n,o??1)}function Re(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Fr(Re,Ph,Ua(_n,{brighter(e){return e=e==null?no:Math.pow(no,e),new Re(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?sn:Math.pow(sn,e),new Re(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(Bo(e>=240?e-240:e+120,r,o),Bo(e,r,o),Bo(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new Re(Fi(this.h),Tn(this.s),Tn(this.l),oo(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=oo(this.opacity);return`${e===1?"hsl(":"hsla("}${Fi(this.h)}, ${Tn(this.s)*100}%, ${Tn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Fi(e){return e=(e||0)%360,e<0?e+360:e}function Tn(e){return Math.max(0,Math.min(1,e||0))}function Bo(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 Ur=e=>()=>e;function Th(e,t){return function(n){return e+n*t}}function Dh(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 jh(e){return(e=+e)==1?Ya:function(t,n){return n-t?Dh(t,n,e):Ur(isNaN(t)?n:t)}}function Ya(e,t){var n=t-e;return n?Th(e,n):Ur(isNaN(e)?t:e)}const ro=(function e(t){var n=jh(t);function o(r,s){var a=n((r=lr(r)).r,(s=lr(s)).r),c=n(r.g,s.g),u=n(r.b,s.b),l=Ya(r.opacity,s.opacity);return function(h){return r.r=a(h),r.g=c(h),r.b=u(h),r.opacity=l(h),r+""}}return o.gamma=e,o})(1);function Oh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(s){for(r=0;r<n;++r)o[r]=e[r]*(1-s)+t[r]*s;return o}}function Rh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Lh(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),s=new Array(n),a;for(a=0;a<o;++a)r[a]=tn(e[a],t[a]);for(;a<n;++a)s[a]=t[a];return function(c){for(a=0;a<o;++a)s[a]=r[a](c);return s}}function Hh(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Ye(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function zh(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]=tn(e[r],t[r]):o[r]=t[r];return function(s){for(r in n)o[r]=n[r](s);return o}}var dr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Vo=new RegExp(dr.source,"g");function Bh(e){return function(){return e}}function Vh(e){return function(t){return e(t)+""}}function Xa(e,t){var n=dr.lastIndex=Vo.lastIndex=0,o,r,s,a=-1,c=[],u=[];for(e=e+"",t=t+"";(o=dr.exec(e))&&(r=Vo.exec(t));)(s=r.index)>n&&(s=t.slice(n,s),c[a]?c[a]+=s:c[++a]=s),(o=o[0])===(r=r[0])?c[a]?c[a]+=r:c[++a]=r:(c[++a]=null,u.push({i:a,x:Ye(o,r)})),n=Vo.lastIndex;return n<t.length&&(s=t.slice(n),c[a]?c[a]+=s:c[++a]=s),c.length<2?u[0]?Vh(u[0].x):Bh(t):(t=u.length,function(l){for(var h=0,f;h<t;++h)c[(f=u[h]).i]=f.x(l);return c.join("")})}function tn(e,t){var n=typeof t,o;return t==null||n==="boolean"?Ur(t):(n==="number"?Ye:n==="string"?(o=xt(t))?(t=o,ro):Xa:t instanceof xt?ro:t instanceof Date?Hh:Rh(t)?Oh:Array.isArray(t)?Lh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?zh:Ye)(e,t)}var Ui=180/Math.PI,ur={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Za(e,t,n,o,r,s){var a,c,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*o)&&(n-=e*u,o-=t*u),(c=Math.sqrt(n*n+o*o))&&(n/=c,o/=c,u/=c),e*o<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:r,translateY:s,rotate:Math.atan2(t,e)*Ui,skewX:Math.atan(u)*Ui,scaleX:a,scaleY:c}}var Dn;function Fh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ur:Za(t.a,t.b,t.c,t.d,t.e,t.f)}function Uh(e){return e==null||(Dn||(Dn=document.createElementNS("http://www.w3.org/2000/svg","g")),Dn.setAttribute("transform",e),!(e=Dn.transform.baseVal.consolidate()))?ur:(e=e.matrix,Za(e.a,e.b,e.c,e.d,e.e,e.f))}function qa(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function s(l,h,f,d,p,m){if(l!==f||h!==d){var _=p.push("translate(",null,t,null,n);m.push({i:_-4,x:Ye(l,f)},{i:_-2,x:Ye(h,d)})}else(f||d)&&p.push("translate("+f+t+d+n)}function a(l,h,f,d){l!==h?(l-h>180?h+=360:h-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:Ye(l,h)})):h&&f.push(r(f)+"rotate("+h+o)}function c(l,h,f,d){l!==h?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:Ye(l,h)}):h&&f.push(r(f)+"skewX("+h+o)}function u(l,h,f,d,p,m){if(l!==f||h!==d){var _=p.push(r(p)+"scale(",null,",",null,")");m.push({i:_-4,x:Ye(l,f)},{i:_-2,x:Ye(h,d)})}else(f!==1||d!==1)&&p.push(r(p)+"scale("+f+","+d+")")}return function(l,h){var f=[],d=[];return l=e(l),h=e(h),s(l.translateX,l.translateY,h.translateX,h.translateY,f,d),a(l.rotate,h.rotate,f,d),c(l.skewX,h.skewX,f,d),u(l.scaleX,l.scaleY,h.scaleX,h.scaleY,f,d),l=h=null,function(p){for(var m=-1,_=d.length,x;++m<_;)f[(x=d[m]).i]=x.x(p);return f.join("")}}}var Wh=qa(Fh,"px, ","px)","deg)"),Yh=qa(Uh,", ",")",")"),Xh=1e-12;function Wi(e){return((e=Math.exp(e))+1/e)/2}function Zh(e){return((e=Math.exp(e))-1/e)/2}function qh(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yn=(function e(t,n,o){function r(s,a){var c=s[0],u=s[1],l=s[2],h=a[0],f=a[1],d=a[2],p=h-c,m=f-u,_=p*p+m*m,x,y;if(_<Xh)y=Math.log(d/l)/t,x=function(E){return[c+E*p,u+E*m,l*Math.exp(t*E*y)]};else{var S=Math.sqrt(_),g=(d*d-l*l+o*_)/(2*l*n*S),v=(d*d-l*l-o*_)/(2*d*n*S),C=Math.log(Math.sqrt(g*g+1)-g),b=Math.log(Math.sqrt(v*v+1)-v);y=(b-C)/t,x=function(E){var A=E*y,P=Wi(C),L=l/(n*S)*(P*qh(t*A+C)-Zh(C));return[c+L*p,u+L*m,l*P/Wi(t*A+C)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return r.rho=function(s){var a=Math.max(.001,+s),c=a*a,u=c*c;return e(a,c,u)},r})(Math.SQRT2,2,4);var Ot=0,Gt=0,Zt=0,Ga=1e3,io,Kt,so=0,bt=0,yo=0,cn=typeof performance=="object"&&performance.now?performance:Date,Ka=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wr(){return bt||(Ka(Gh),bt=cn.now()+yo)}function Gh(){bt=0}function ao(){this._call=this._time=this._next=null}ao.prototype=Qa.prototype={constructor:ao,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Wr():+n)+(t==null?0:+t),!this._next&&Kt!==this&&(Kt?Kt._next=this:io=this,Kt=this),this._call=e,this._time=n,hr()},stop:function(){this._call&&(this._call=null,this._time=1/0,hr())}};function Qa(e,t,n){var o=new ao;return o.restart(e,t,n),o}function Kh(){Wr(),++Ot;for(var e=io,t;e;)(t=bt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ot}function Yi(){bt=(so=cn.now())+yo,Ot=Gt=0;try{Kh()}finally{Ot=0,Jh(),bt=0}}function Qh(){var e=cn.now(),t=e-so;t>Ga&&(yo-=t,so=e)}function Jh(){for(var e,t=io,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:io=n);Kt=e,hr(o)}function hr(e){if(!Ot){Gt&&(Gt=clearTimeout(Gt));var t=e-bt;t>24?(e<1/0&&(Gt=setTimeout(Yi,e-cn.now()-yo)),Zt&&(Zt=clearInterval(Zt))):(Zt||(so=cn.now(),Zt=setInterval(Qh,Ga)),Ot=1,Ka(Yi))}}function Xi(e,t,n){var o=new ao;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var ef=go("start","end","cancel","interrupt"),tf=[],Ja=0,Zi=1,fr=2,Xn=3,qi=4,pr=5,Zn=6;function vo(e,t,n,o,r,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;nf(e,n,{name:t,index:o,group:r,on:ef,tween:tf,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Ja})}function Yr(e,t){var n=Ve(e,t);if(n.state>Ja)throw new Error("too late; already scheduled");return n}function Ke(e,t){var n=Ve(e,t);if(n.state>Xn)throw new Error("too late; already running");return n}function Ve(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function nf(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Qa(s,0,n.time);function s(l){n.state=Zi,n.timer.restart(a,n.delay,n.time),n.delay<=l&&a(l-n.delay)}function a(l){var h,f,d,p;if(n.state!==Zi)return u();for(h in o)if(p=o[h],p.name===n.name){if(p.state===Xn)return Xi(a);p.state===qi?(p.state=Zn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete o[h]):+h<t&&(p.state=Zn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete o[h])}if(Xi(function(){n.state===Xn&&(n.state=qi,n.timer.restart(c,n.delay,n.time),c(l))}),n.state=fr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===fr){for(n.state=Xn,r=new Array(d=n.tween.length),h=0,f=-1;h<d;++h)(p=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=p);r.length=f+1}}function c(l){for(var h=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(u),n.state=pr,1),f=-1,d=r.length;++f<d;)r[f].call(e,h);n.state===pr&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Zn,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function qn(e,t){var n=e.__transition,o,r,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((o=n[a]).name!==t){s=!1;continue}r=o.state>fr&&o.state<pr,o.state=Zn,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[a]}s&&delete e.__transition}}function of(e){return this.each(function(){qn(this,e)})}function rf(e,t){var n,o;return function(){var r=Ke(this,e),s=r.tween;if(s!==n){o=n=s;for(var a=0,c=o.length;a<c;++a)if(o[a].name===t){o=o.slice(),o.splice(a,1);break}}r.tween=o}}function sf(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var s=Ke(this,e),a=s.tween;if(a!==o){r=(o=a).slice();for(var c={name:t,value:n},u=0,l=r.length;u<l;++u)if(r[u].name===t){r[u]=c;break}u===l&&r.push(c)}s.tween=r}}function af(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ve(this.node(),n).tween,r=0,s=o.length,a;r<s;++r)if((a=o[r]).name===e)return a.value;return null}return this.each((t==null?rf:sf)(n,e,t))}function Xr(e,t,n){var o=e._id;return e.each(function(){var r=Ke(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Ve(r,o).value[t]}}function ec(e,t){var n;return(typeof t=="number"?Ye:t instanceof xt?ro:(n=xt(t))?(t=n,ro):Xa)(e,t)}function cf(e){return function(){this.removeAttribute(e)}}function lf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function df(e,t,n){var o,r=n+"",s;return function(){var a=this.getAttribute(e);return a===r?null:a===o?s:s=t(o=a,n)}}function uf(e,t,n){var o,r=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===o?s:s=t(o=a,n)}}function hf(e,t,n){var o,r,s;return function(){var a,c=n(this),u;return c==null?void this.removeAttribute(e):(a=this.getAttribute(e),u=c+"",a===u?null:a===o&&u===r?s:(r=u,s=t(o=a,c)))}}function ff(e,t,n){var o,r,s;return function(){var a,c=n(this),u;return c==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),u=c+"",a===u?null:a===o&&u===r?s:(r=u,s=t(o=a,c)))}}function pf(e,t){var n=mo(e),o=n==="transform"?Yh:ec;return this.attrTween(e,typeof t=="function"?(n.local?ff:hf)(n,o,Xr(this,"attr."+e,t)):t==null?(n.local?lf:cf)(n):(n.local?uf:df)(n,o,t))}function gf(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function mf(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function yf(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&mf(e,s)),n}return r._value=t,r}function vf(e,t){var n,o;function r(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&gf(e,s)),n}return r._value=t,r}function _f(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=mo(e);return this.tween(n,(o.local?yf:vf)(o,t))}function wf(e,t){return function(){Yr(this,e).delay=+t.apply(this,arguments)}}function xf(e,t){return t=+t,function(){Yr(this,e).delay=t}}function bf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?wf:xf)(t,e)):Ve(this.node(),t).delay}function Sf(e,t){return function(){Ke(this,e).duration=+t.apply(this,arguments)}}function kf(e,t){return t=+t,function(){Ke(this,e).duration=t}}function Cf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Sf:kf)(t,e)):Ve(this.node(),t).duration}function Ef(e,t){if(typeof t!="function")throw new Error;return function(){Ke(this,e).ease=t}}function Nf(e){var t=this._id;return arguments.length?this.each(Ef(t,e)):Ve(this.node(),t).ease}function If(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ke(this,e).ease=n}}function Mf(e){if(typeof e!="function")throw new Error;return this.each(If(this._id,e))}function Af(e){typeof e!="function"&&(e=$a(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var s=t[r],a=s.length,c=o[r]=[],u,l=0;l<a;++l)(u=s[l])&&e.call(u,u.__data__,l,s)&&c.push(u);return new rt(o,this._parents,this._name,this._id)}function $f(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,s=Math.min(o,r),a=new Array(o),c=0;c<s;++c)for(var u=t[c],l=n[c],h=u.length,f=a[c]=new Array(h),d,p=0;p<h;++p)(d=u[p]||l[p])&&(f[p]=d);for(;c<o;++c)a[c]=t[c];return new rt(a,this._parents,this._name,this._id)}function Pf(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 Tf(e,t,n){var o,r,s=Pf(t)?Yr:Ke;return function(){var a=s(this,e),c=a.on;c!==o&&(r=(o=c).copy()).on(t,n),a.on=r}}function Df(e,t){var n=this._id;return arguments.length<2?Ve(this.node(),n).on.on(e):this.each(Tf(n,e,t))}function jf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Of(){return this.on("end.remove",jf(this._id))}function Rf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Br(e));for(var o=this._groups,r=o.length,s=new Array(r),a=0;a<r;++a)for(var c=o[a],u=c.length,l=s[a]=new Array(u),h,f,d=0;d<u;++d)(h=c[d])&&(f=e.call(h,h.__data__,d,c))&&("__data__"in h&&(f.__data__=h.__data__),l[d]=f,vo(l[d],t,n,d,l,Ve(h,n)));return new rt(s,this._parents,t,n)}function Lf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Aa(e));for(var o=this._groups,r=o.length,s=[],a=[],c=0;c<r;++c)for(var u=o[c],l=u.length,h,f=0;f<l;++f)if(h=u[f]){for(var d=e.call(h,h.__data__,f,u),p,m=Ve(h,n),_=0,x=d.length;_<x;++_)(p=d[_])&&vo(p,t,n,_,d,m);s.push(d),a.push(h)}return new rt(s,a,t,n)}var Hf=vn.prototype.constructor;function zf(){return new Hf(this._groups,this._parents)}function Bf(e,t){var n,o,r;return function(){var s=jt(this,e),a=(this.style.removeProperty(e),jt(this,e));return s===a?null:s===n&&a===o?r:r=t(n=s,o=a)}}function tc(e){return function(){this.style.removeProperty(e)}}function Vf(e,t,n){var o,r=n+"",s;return function(){var a=jt(this,e);return a===r?null:a===o?s:s=t(o=a,n)}}function Ff(e,t,n){var o,r,s;return function(){var a=jt(this,e),c=n(this),u=c+"";return c==null&&(u=c=(this.style.removeProperty(e),jt(this,e))),a===u?null:a===o&&u===r?s:(r=u,s=t(o=a,c))}}function Uf(e,t){var n,o,r,s="style."+t,a="end."+s,c;return function(){var u=Ke(this,e),l=u.on,h=u.value[s]==null?c||(c=tc(t)):void 0;(l!==n||r!==h)&&(o=(n=l).copy()).on(a,r=h),u.on=o}}function Wf(e,t,n){var o=(e+="")=="transform"?Wh:ec;return t==null?this.styleTween(e,Bf(e,o)).on("end.style."+e,tc(e)):typeof t=="function"?this.styleTween(e,Ff(e,o,Xr(this,"style."+e,t))).each(Uf(this._id,e)):this.styleTween(e,Vf(e,o,t),n).on("end.style."+e,null)}function Yf(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Xf(e,t,n){var o,r;function s(){var a=t.apply(this,arguments);return a!==r&&(o=(r=a)&&Yf(e,a,n)),o}return s._value=t,s}function Zf(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,Xf(e,t,n??""))}function qf(e){return function(){this.textContent=e}}function Gf(e){return function(){var t=e(this);this.textContent=t??""}}function Kf(e){return this.tween("text",typeof e=="function"?Gf(Xr(this,"text",e)):qf(e==null?"":e+""))}function Qf(e){return function(t){this.textContent=e.call(this,t)}}function Jf(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Qf(r)),t}return o._value=e,o}function ep(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,Jf(e))}function tp(){for(var e=this._name,t=this._id,n=nc(),o=this._groups,r=o.length,s=0;s<r;++s)for(var a=o[s],c=a.length,u,l=0;l<c;++l)if(u=a[l]){var h=Ve(u,t);vo(u,e,n,l,a,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new rt(o,this._parents,e,n)}function np(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(s,a){var c={value:a},u={value:function(){--r===0&&s()}};n.each(function(){var l=Ke(this,o),h=l.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(u)),l.on=t}),r===0&&s()})}var op=0;function rt(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function nc(){return++op}var et=vn.prototype;rt.prototype={constructor:rt,select:Rf,selectAll:Lf,selectChild:et.selectChild,selectChildren:et.selectChildren,filter:Af,merge:$f,selection:zf,transition:tp,call:et.call,nodes:et.nodes,node:et.node,size:et.size,empty:et.empty,each:et.each,on:Df,attr:pf,attrTween:_f,style:Wf,styleTween:Zf,text:Kf,textTween:ep,remove:Of,tween:af,delay:bf,duration:Cf,ease:Nf,easeVarying:Mf,end:np,[Symbol.iterator]:et[Symbol.iterator]};function rp(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ip={time:null,delay:0,duration:250,ease:rp};function sp(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 ap(e){var t,n;e instanceof rt?(t=e._id,e=e._name):(t=nc(),(n=ip).time=Wr(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,s=0;s<r;++s)for(var a=o[s],c=a.length,u,l=0;l<c;++l)(u=a[l])&&vo(u,e,t,l,a,n||sp(u,t));return new rt(o,this._parents,e,t)}vn.prototype.interrupt=of;vn.prototype.transition=ap;const jn=e=>()=>e;function cp(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 tt(e,t,n){this.k=e,this.x=t,this.y=n}tt.prototype={constructor:tt,scale:function(e){return e===1?this:new tt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new tt(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 _o=new tt(1,0,0);oc.prototype=tt.prototype;function oc(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _o;return e.__zoom}function Fo(e){e.stopImmediatePropagation()}function qt(e){e.preventDefault(),e.stopImmediatePropagation()}function lp(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function dp(){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 Gi(){return this.__zoom||_o}function up(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function hp(){return navigator.maxTouchPoints||"ontouchstart"in this}function fp(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function rc(){var e=lp,t=dp,n=fp,o=up,r=hp,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],c=250,u=Yn,l=go("start","zoom","end"),h,f,d,p=500,m=150,_=0,x=10;function y(k){k.property("__zoom",Gi).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",L).filter(r).on("touchstart.zoom",D).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",N).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(k,I,M,$){var O=k.selection?k.selection():k;O.property("__zoom",Gi),k!==O?C(k,I,M,$):O.interrupt().each(function(){b(this,arguments).event($).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(k,I,M,$){y.scaleTo(k,function(){var O=this.__zoom.k,j=typeof I=="function"?I.apply(this,arguments):I;return O*j},M,$)},y.scaleTo=function(k,I,M,$){y.transform(k,function(){var O=t.apply(this,arguments),j=this.__zoom,B=M==null?v(O):typeof M=="function"?M.apply(this,arguments):M,z=j.invert(B),R=typeof I=="function"?I.apply(this,arguments):I;return n(g(S(j,R),B,z),O,a)},M,$)},y.translateBy=function(k,I,M,$){y.transform(k,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),a)},null,$)},y.translateTo=function(k,I,M,$,O){y.transform(k,function(){var j=t.apply(this,arguments),B=this.__zoom,z=$==null?v(j):typeof $=="function"?$.apply(this,arguments):$;return n(_o.translate(z[0],z[1]).scale(B.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof M=="function"?-M.apply(this,arguments):-M),j,a)},$,O)};function S(k,I){return I=Math.max(s[0],Math.min(s[1],I)),I===k.k?k:new tt(I,k.x,k.y)}function g(k,I,M){var $=I[0]-M[0]*k.k,O=I[1]-M[1]*k.k;return $===k.x&&O===k.y?k:new tt(k.k,$,O)}function v(k){return[(+k[0][0]+ +k[1][0])/2,(+k[0][1]+ +k[1][1])/2]}function C(k,I,M,$){k.on("start.zoom",function(){b(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event($).end()}).tween("zoom",function(){var O=this,j=arguments,B=b(O,j).event($),z=t.apply(O,j),R=M==null?v(z):typeof M=="function"?M.apply(O,j):M,F=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),U=O.__zoom,K=typeof I=="function"?I.apply(O,j):I,ie=u(U.invert(R).concat(F/U.k),K.invert(R).concat(F/K.k));return function(Z){if(Z===1)Z=K;else{var H=ie(Z),Y=F/H[2];Z=new tt(Y,R[0]-H[0]*Y,R[1]-H[1]*Y)}B.zoom(null,Z)}})}function b(k,I,M){return!M&&k.__zooming||new E(k,I)}function E(k,I){this.that=k,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(k,I),this.taps=0}E.prototype={event:function(k){return k&&(this.sourceEvent=k),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(k,I){return this.mouse&&k!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&k!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&k!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(k){var I=Ie(this.that).datum();l.call(k,this.that,new cp(k,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),I)}};function A(k,...I){if(!e.apply(this,arguments))return;var M=b(this,I).event(k),$=this.__zoom,O=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,o.apply(this,arguments)))),j=Oe(k);if(M.wheel)(M.mouse[0][0]!==j[0]||M.mouse[0][1]!==j[1])&&(M.mouse[1]=$.invert(M.mouse[0]=j)),clearTimeout(M.wheel);else{if($.k===O)return;M.mouse=[j,$.invert(j)],qn(this),M.start()}qt(k),M.wheel=setTimeout(B,m),M.zoom("mouse",n(g(S($,O),M.mouse[0],M.mouse[1]),M.extent,a));function B(){M.wheel=null,M.end()}}function P(k,...I){if(d||!e.apply(this,arguments))return;var M=k.currentTarget,$=b(this,I,!0).event(k),O=Ie(k.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",F,!0),j=Oe(k,M),B=k.clientX,z=k.clientY;Ba(k.view),Fo(k),$.mouse=[j,this.__zoom.invert(j)],qn(this),$.start();function R(U){if(qt(U),!$.moved){var K=U.clientX-B,ie=U.clientY-z;$.moved=K*K+ie*ie>_}$.event(U).zoom("mouse",n(g($.that.__zoom,$.mouse[0]=Oe(U,M),$.mouse[1]),$.extent,a))}function F(U){O.on("mousemove.zoom mouseup.zoom",null),Va(U.view,$.moved),qt(U),$.event(U).end()}}function L(k,...I){if(e.apply(this,arguments)){var M=this.__zoom,$=Oe(k.changedTouches?k.changedTouches[0]:k,this),O=M.invert($),j=M.k*(k.shiftKey?.5:2),B=n(g(S(M,j),$,O),t.apply(this,I),a);qt(k),c>0?Ie(this).transition().duration(c).call(C,B,$,k):Ie(this).call(y.transform,B,$,k)}}function D(k,...I){if(e.apply(this,arguments)){var M=k.touches,$=M.length,O=b(this,I,k.changedTouches.length===$).event(k),j,B,z,R;for(Fo(k),B=0;B<$;++B)z=M[B],R=Oe(z,this),R=[R,this.__zoom.invert(R),z.identifier],O.touch0?!O.touch1&&O.touch0[2]!==R[2]&&(O.touch1=R,O.taps=0):(O.touch0=R,j=!0,O.taps=1+!!h);h&&(h=clearTimeout(h)),j&&(O.taps<2&&(f=R[0],h=setTimeout(function(){h=null},p)),qn(this),O.start())}}function V(k,...I){if(this.__zooming){var M=b(this,I).event(k),$=k.changedTouches,O=$.length,j,B,z,R;for(qt(k),j=0;j<O;++j)B=$[j],z=Oe(B,this),M.touch0&&M.touch0[2]===B.identifier?M.touch0[0]=z:M.touch1&&M.touch1[2]===B.identifier&&(M.touch1[0]=z);if(B=M.that.__zoom,M.touch1){var F=M.touch0[0],U=M.touch0[1],K=M.touch1[0],ie=M.touch1[1],Z=(Z=K[0]-F[0])*Z+(Z=K[1]-F[1])*Z,H=(H=ie[0]-U[0])*H+(H=ie[1]-U[1])*H;B=S(B,Math.sqrt(Z/H)),z=[(F[0]+K[0])/2,(F[1]+K[1])/2],R=[(U[0]+ie[0])/2,(U[1]+ie[1])/2]}else if(M.touch0)z=M.touch0[0],R=M.touch0[1];else return;M.zoom("touch",n(g(B,z,R),M.extent,a))}}function N(k,...I){if(this.__zooming){var M=b(this,I).event(k),$=k.changedTouches,O=$.length,j,B;for(Fo(k),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),j=0;j<O;++j)B=$[j],M.touch0&&M.touch0[2]===B.identifier?delete M.touch0:M.touch1&&M.touch1[2]===B.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(B=Oe(B,this),Math.hypot(f[0]-B[0],f[1]-B[1])<x)){var z=Ie(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return y.wheelDelta=function(k){return arguments.length?(o=typeof k=="function"?k:jn(+k),y):o},y.filter=function(k){return arguments.length?(e=typeof k=="function"?k:jn(!!k),y):e},y.touchable=function(k){return arguments.length?(r=typeof k=="function"?k:jn(!!k),y):r},y.extent=function(k){return arguments.length?(t=typeof k=="function"?k:jn([[+k[0][0],+k[0][1]],[+k[1][0],+k[1][1]]]),y):t},y.scaleExtent=function(k){return arguments.length?(s[0]=+k[0],s[1]=+k[1],y):[s[0],s[1]]},y.translateExtent=function(k){return arguments.length?(a[0][0]=+k[0][0],a[1][0]=+k[1][0],a[0][1]=+k[0][1],a[1][1]=+k[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(k){return arguments.length?(n=k,y):n},y.duration=function(k){return arguments.length?(c=+k,y):c},y.interpolate=function(k){return arguments.length?(u=k,y):u},y.on=function(){var k=l.on.apply(l,arguments);return k===l?y:k},y.clickDistance=function(k){return arguments.length?(_=(k=+k)*k,y):Math.sqrt(_)},y.tapDistance=function(k){return arguments.length?(x=+k,y):x},y}const Be={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ln=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ic=["Enter"," ","Escape"],sc={"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 Rt;(function(e){e.Strict="strict",e.Loose="loose"})(Rt||(Rt={}));var vt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(vt||(vt={}));var dn;(function(e){e.Partial="partial",e.Full="full"})(dn||(dn={}));const ac={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ht;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ht||(ht={}));var co;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(co||(co={}));var G;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(G||(G={}));const Ki={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},cc=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,pp=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Zr=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),wn=(e,t=[0,0])=>{const{width:n,height:o}=Fe(e),r=e.origin??t,s=n*r[0],a=o*r[1];return{x:e.position.x-s,y:e.position.y-a}},gp=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,s)=>{const a=typeof s=="string";let c=!t.nodeLookup&&!a?s:void 0;return t.nodeLookup&&(c=a?t.nodeLookup.get(s):Zr(s)?s:t.nodeLookup.get(s.id)),c?(n=!0,wo(r,lo(c,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?xo(o):{x:0,y:0,width:0,height:0}},xn=(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=wo(n,lo(r)),o=!0)}),o?xo(n):{x:0,y:0,width:0,height:0}},qr=(e,t,[n,o,r]=[0,0,1],s=!1,a=!1)=>{const c=(t.x-n)/r,u=(t.y-o)/r,l=t.width/r,h=t.height/r,f=[];for(const d of e.values()){const{measured:p,selectable:m=!0,hidden:_=!1}=d;if(a&&!m||_)continue;const x=p.width??d.width??d.initialWidth??0,y=p.height??d.height??d.initialHeight??0,{x:S,y:g}=d.internals.positionAbsolute,v=hc(c,u,l,h,S,g,x,y),C=x*y,b=s&&v>0;(!d.internals.handleBounds||b||v>=C||d.dragging)&&f.push(d)}return f},mp=(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 yp(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let s;if(t?.includeHiddenNodes){const{width:a,height:c}=Fe(r);s=a>0&&c>0}else s=!!(r.measured.width&&r.measured.height&&!r.hidden);s&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function vp({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:s},a){if(e.size===0)return!0;const c=yp(e,a),u=xn(c),l=Kr(u,t,n,a?.minZoom??r,a?.maxZoom??s,a?.padding??.1);return await o.setViewport(l,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),!0}function lc({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:s}){const a=n.get(e),c=a.parentId?n.get(a.parentId):void 0,{x:u,y:l}=c?c.internals.positionAbsolute:{x:0,y:0},h=a.origin??o;let f=a.extent||r;if(a.extent==="parent"&&!a.expandParent)if(!c)s?.("005",Be.error005());else{const{width:p,height:m}=Fe(c);p&&m&&(f=[[u,l],[u+p,l+m]])}else c&&kt(a.extent)&&(f=[[a.extent[0][0]+u,a.extent[0][1]+l],[a.extent[1][0]+u,a.extent[1][1]+l]]);const d=kt(f)?St(t,f,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&s?.("015",Be.error015()),{position:{x:d.x-u+(a.measured.width??0)*h[0],y:d.y-l+(a.measured.height??0)*h[1]},positionAbsolute:d}}async function _p({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const s=new Set(e.map(d=>d.id)),a=[];for(const d of n){if(d.deletable===!1)continue;const p=s.has(d.id),m=!p&&d.parentId&&a.find(_=>_.id===d.parentId);(p||m)&&a.push(d)}const c=new Set(t.map(d=>d.id)),u=o.filter(d=>d.deletable!==!1),h=mp(a,u);for(const d of u)c.has(d.id)&&!h.find(m=>m.id===d.id)&&h.push(d);if(!r)return{edges:h,nodes:a};const f=await r({nodes:a,edges:h});return typeof f=="boolean"?f?{edges:h,nodes:a}:{edges:[],nodes:[]}:f}const Lt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),St=(e={x:0,y:0},t,n)=>({x:Lt(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Lt(e.y,t[0][1],t[1][1]-(n?.height??0))});function dc(e,t,n){const{width:o,height:r}=Fe(n),{x:s,y:a}=n.internals.positionAbsolute;return St(e,[[s,a],[s+o,a+r]],t)}const Qi=(e,t,n)=>e<t?Lt(Math.abs(e-t),1,t)/t:e>n?-Lt(Math.abs(e-n),1,t)/t:0,Gr=(e,t,n=15,o=40)=>{const r=Qi(e.x,o,t.width-o)*n,s=Qi(e.y,o,t.height-o)*n;return[r,s]},wo=(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)}),gr=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),xo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),un=(e,t=[0,0])=>{const{x:n,y:o}=Zr(e)?e.internals.positionAbsolute:wn(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}},lo=(e,t=[0,0])=>{const{x:n,y:o}=Zr(e)?e.internals.positionAbsolute:wn(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)}},uc=(e,t)=>xo(wo(gr(e),gr(t))),hc=(e,t,n,o,r,s,a,c)=>{const u=Math.max(0,Math.min(e+n,r+a)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,s+c)-Math.max(t,s));return Math.ceil(u*l)},uo=(e,t)=>hc(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ji=e=>Le(e.width)&&Le(e.height)&&Le(e.x)&&Le(e.y),Le=e=>!isNaN(e)&&isFinite(e),fc=(e,t)=>(n,o)=>{},bn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Sn=({x:e,y:t},[n,o,r],s=!1,a=[1,1])=>{const c={x:(e-n)/r,y:(t-o)/r};return s?bn(c,a):c},Ht=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Nt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function wp(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Nt(e,n),r=Nt(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Nt(e.top??e.y??0,n),r=Nt(e.bottom??e.y??0,n),s=Nt(e.left??e.x??0,t),a=Nt(e.right??e.x??0,t);return{top:o,right:a,bottom:r,left:s,x:s+a,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xp(e,t,n,o,r,s){const{x:a,y:c}=Ht(e,[t,n,o]),{x:u,y:l}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,o]),h=r-u,f=s-l;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(f)}}const Kr=(e,t,n,o,r,s)=>{const a=wp(s,t,n),c=(t-a.x)/e.width,u=(n-a.y)/e.height,l=Math.min(c,u),h=Lt(l,o,r),f=e.x+e.width/2,d=e.y+e.height/2,p=t/2-f*h,m=n/2-d*h,_=xp(e,p,m,h,t,n),x={left:Math.min(_.left-a.left,0),top:Math.min(_.top-a.top,0),right:Math.min(_.right-a.right,0),bottom:Math.min(_.bottom-a.bottom,0)};return{x:p-x.left+x.right,y:m-x.top+x.bottom,zoom:h}},hn=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function kt(e){return e!=null&&e!=="parent"}function Fe(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function pc(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function gc(e,t={width:0,height:0},n,o,r){const s={...e},a=o.get(n);if(a){const c=a.origin||r;s.x+=a.internals.positionAbsolute.x-(t.width??0)*c[0],s.y+=a.internals.positionAbsolute.y-(t.height??0)*c[1]}return s}function es(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function bp(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Sp(e){return{...sc,...e||{}}}function mc(e){return e===null?null:e?"valid":"invalid"}function nn(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:s,y:a}=He(e),c=Sn({x:s-(r?.left??0),y:a-(r?.top??0)},o),{x:u,y:l}=n?bn(c,t):c;return{xSnapped:u,ySnapped:l,...c}}const Qr=e=>({width:e.offsetWidth,height:e.offsetHeight}),yc=e=>e?.getRootNode?.()||window?.document,kp=["INPUT","SELECT","TEXTAREA"];function vc(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:kp.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const _c=e=>"clientX"in e,He=(e,t)=>{const n=_c(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)}},ts=(e,t,n,o,r)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:r,position:a.getAttribute("data-handlepos"),x:(c.left-n.left)/o,y:(c.top-n.top)/o,...Qr(a)}})};function wc({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:s,targetControlX:a,targetControlY:c}){const u=e*.125+r*.375+a*.375+n*.125,l=t*.125+s*.375+c*.375+o*.125,h=Math.abs(u-e),f=Math.abs(l-t);return[u,l,h,f]}function On(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ns({pos:e,x1:t,y1:n,x2:o,y2:r,c:s}){switch(e){case G.Left:return[t-On(t-o,s),n];case G.Right:return[t+On(o-t,s),n];case G.Top:return[t,n-On(n-r,s)];case G.Bottom:return[t,n+On(r-n,s)]}}function xc({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:o,targetY:r,targetPosition:s=G.Top,curvature:a=.25}){const[c,u]=ns({pos:n,x1:e,y1:t,x2:o,y2:r,c:a}),[l,h]=ns({pos:s,x1:o,y1:r,x2:e,y2:t,c:a}),[f,d,p,m]=wc({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:c,sourceControlY:u,targetControlX:l,targetControlY:h});return[`M${e},${t} C${c},${u} ${l},${h} ${o},${r}`,f,d,p,m]}function bc({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,s=n<e?n+r:n-r,a=Math.abs(o-t)/2,c=o<t?o+a:o-a;return[s,c,r,a]}function Cp({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:s="basic"}){if(s==="manual")return o;const a=r&&n?o+1e3:o,c=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return a+c}function Ep({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const s=wo(lo(e),lo(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const a={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return uo(a,xo(s))>0}const Np=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Ip=(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)),Mp=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Be.error006()),t;const o=n.getEdgeId||Np;let r;return cc(e)?r={...e}:r={...e,id:o(e)},Ip(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Sc({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,s,a,c]=bc({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,s,a,c]}const os={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},Ap=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.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},rs=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function $p({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:o=G.Top,center:r,offset:s,stepPosition:a}){const c=os[t],u=os[o],l={x:e.x+c.x*s,y:e.y+c.y*s},h={x:n.x+u.x*s,y:n.y+u.y*s},f=Ap({source:l,sourcePosition:t,target:h}),d=f.x!==0?"x":"y",p=f[d];let m=[],_,x;const y={x:0,y:0},S={x:0,y:0},[,,g,v]=bc({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[d]*u[d]===-1){d==="x"?(_=r.x??l.x+(h.x-l.x)*a,x=r.y??(l.y+h.y)/2):(_=r.x??(l.x+h.x)/2,x=r.y??l.y+(h.y-l.y)*a);const A=[{x:_,y:l.y},{x:_,y:h.y}],P=[{x:l.x,y:x},{x:h.x,y:x}];c[d]===p?m=d==="x"?A:P:m=d==="x"?P:A}else{const A=[{x:l.x,y:h.y}],P=[{x:h.x,y:l.y}];if(d==="x"?m=c.x===p?P:A:m=c.y===p?A:P,t===o){const k=Math.abs(e[d]-n[d]);if(k<=s){const I=Math.min(s-1,s-k);c[d]===p?y[d]=(l[d]>e[d]?-1:1)*I:S[d]=(h[d]>n[d]?-1:1)*I}}if(t!==o){const k=d==="x"?"y":"x",I=c[d]===u[k],M=l[k]>h[k],$=l[k]<h[k];(c[d]===1&&(!I&&M||I&&$)||c[d]!==1&&(!I&&$||I&&M))&&(m=d==="x"?A:P)}const L={x:l.x+y.x,y:l.y+y.y},D={x:h.x+S.x,y:h.y+S.y},V=Math.max(Math.abs(L.x-m[0].x),Math.abs(D.x-m[0].x)),N=Math.max(Math.abs(L.y-m[0].y),Math.abs(D.y-m[0].y));V>=N?(_=(L.x+D.x)/2,x=m[0].y):(_=m[0].x,x=(L.y+D.y)/2)}const C={x:l.x+y.x,y:l.y+y.y},b={x:h.x+S.x,y:h.y+S.y};return[[e,...C.x!==m[0].x||C.y!==m[0].y?[C]:[],...m,...b.x!==m[m.length-1].x||b.y!==m[m.length-1].y?[b]:[],n],_,x,g,v]}function Pp(e,t,n,o){const r=Math.min(rs(e,t)/2,rs(t,n)/2,o),{x:s,y:a}=t;if(e.x===s&&s===n.x||e.y===a&&a===n.y)return`L${s} ${a}`;if(e.y===a){const l=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${s+r*l},${a}Q ${s},${a} ${s},${a+r*h}`}const c=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${s},${a+r*u}Q ${s},${a} ${s+r*c},${a}`}function mr({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:o,targetY:r,targetPosition:s=G.Top,borderRadius:a=5,centerX:c,centerY:u,offset:l=20,stepPosition:h=.5}){const[f,d,p,m,_]=$p({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:s,center:{x:c,y:u},offset:l,stepPosition:h});let x=`M${f[0].x} ${f[0].y}`;for(let y=1;y<f.length-1;y++)x+=Pp(f[y-1],f[y],f[y+1],a);return x+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[x,d,p,m,_]}function is(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Tp(e){const{sourceNode:t,targetNode:n}=e;if(!is(t)||!is(n))return null;const o=t.internals.handleBounds||ss(t.handles),r=n.internals.handleBounds||ss(n.handles),s=as(o?.source??[],e.sourceHandle),a=as(e.connectionMode===Rt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!s||!a)return e.onError?.("008",Be.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=s?.position||G.Bottom,u=a?.position||G.Top,l=Ct(t,s,c),h=Ct(n,a,u);return{sourceX:l.x,sourceY:l.y,targetX:h.x,targetY:h.y,sourcePosition:c,targetPosition:u}}function ss(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 Ct(e,t,n=G.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,s=(t?.y??0)+e.internals.positionAbsolute.y,{width:a,height:c}=t??Fe(e);if(o)return{x:r+a/2,y:s+c/2};switch(t?.position??n){case G.Top:return{x:r+a/2,y:s};case G.Right:return{x:r+a,y:s+c/2};case G.Bottom:return{x:r+a/2,y:s+c};case G.Left:return{x:r,y:s+c/2}}}function as(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function yr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Dp(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const s=new Set;return e.reduce((a,c)=>([c.markerStart||o,c.markerEnd||r].forEach(u=>{if(u&&typeof u=="object"){const l=yr(u,t);s.has(l)||(a.push({id:l,color:u.color||n,...u}),s.add(l))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))}const kc=1e3,jp=10,Jr={nodeOrigin:[0,0],nodeExtent:ln,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Op={...Jr,checkEquality:!0};function ei(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Rp(e,t,n){const o=ei(Jr,n);for(const r of e.values())if(r.parentId)ni(r,e,t,o);else{const s=wn(r,o.nodeOrigin),a=kt(r.extent)?r.extent:o.nodeExtent,c=St(s,a,Fe(r));r.internals.positionAbsolute=c}}function Lp(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const s={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(s):r.type==="target"&&o.push(s)}return{source:n,target:o}}function ti(e){return e==="manual"}function vr(e,t,n,o={}){const r=ei(Op,o),s={i:0},a=new Map(t),c=r?.elevateNodesOnSelect&&!ti(r.zIndexMode)?kc:0;let u=e.length>0,l=!1;t.clear(),n.clear();for(const h of e){let f=a.get(h.id);if(r.checkEquality&&h===f?.internals.userNode)t.set(h.id,f);else{const d=wn(h,r.nodeOrigin),p=kt(h.extent)?h.extent:r.nodeExtent,m=St(d,p,Fe(h));f={...r.defaults,...h,measured:{width:h.measured?.width,height:h.measured?.height},internals:{positionAbsolute:m,handleBounds:Lp(h,f),z:Cc(h,c,r.zIndexMode),userNode:h}},t.set(h.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(u=!1),h.parentId&&ni(f,t,n,o,s),l||=h.selected??!1}return{nodesInitialized:u,hasSelectedNodes:l}}function Hp(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 ni(e,t,n,o,r){const{elevateNodesOnSelect:s,nodeOrigin:a,nodeExtent:c,zIndexMode:u}=ei(Jr,o),l=e.parentId,h=t.get(l);if(!h){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Hp(e,n),r&&!h.parentId&&h.internals.rootParentIndex===void 0&&u==="auto"&&(h.internals.rootParentIndex=++r.i,h.internals.z=h.internals.z+r.i*jp),r&&h.internals.rootParentIndex!==void 0&&(r.i=h.internals.rootParentIndex);const f=s&&!ti(u)?kc:0,{x:d,y:p,z:m}=zp(e,h,a,c,f,u),{positionAbsolute:_}=e.internals,x=d!==_.x||p!==_.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:d,y:p}:_,z:m}})}function Cc(e,t,n){const o=Le(e.zIndex)?e.zIndex:0;return ti(n)?o:o+(e.selected?t:0)}function zp(e,t,n,o,r,s){const{x:a,y:c}=t.internals.positionAbsolute,u=Fe(e),l=wn(e,n),h=kt(e.extent)?St(l,e.extent,u):l;let f=St({x:a+h.x,y:c+h.y},o,u);e.extent==="parent"&&(f=dc(f,u,t));const d=Cc(e,r,s),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=d?p+1:d}}function oi(e,t,n,o=[0,0]){const r=[],s=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=s.get(a.parentId)?.expandedRect??un(c),l=uc(u,a.rect);s.set(a.parentId,{expandedRect:l,parent:c})}return s.size>0&&s.forEach(({expandedRect:a,parent:c},u)=>{const l=c.internals.positionAbsolute,h=Fe(c),f=c.origin??o,d=a.x<l.x?Math.round(Math.abs(l.x-a.x)):0,p=a.y<l.y?Math.round(Math.abs(l.y-a.y)):0,m=Math.max(h.width,Math.round(a.width)),_=Math.max(h.height,Math.round(a.height)),x=(m-h.width)*f[0],y=(_-h.height)*f[1];(d>0||p>0||x||y)&&(r.push({id:u,type:"position",position:{x:c.position.x-d+x,y:c.position.y-p+y}}),n.get(u)?.forEach(S=>{e.some(g=>g.id===S.id)||r.push({id:S.id,type:"position",position:{x:S.position.x+d,y:S.position.y+p}})})),(h.width<a.width||h.height<a.height||d||p)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:m+(d?f[0]*d-x:0),height:_+(p?f[1]*p-y:0)}})}),r}function Bp(e,t,n,o,r,s,a){const c=o?.querySelector(".xyflow__viewport");let u=!1;if(!c)return{changes:[],updatedInternals:u};const l=[],h=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(h.transform),d=[];for(const p of e.values()){const m=t.get(p.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),u=!0;continue}const _=Qr(p.nodeElement),x=m.measured.width!==_.width||m.measured.height!==_.height;if(!!(_.width&&_.height&&(x||!m.internals.handleBounds||p.force))){const S=p.nodeElement.getBoundingClientRect(),g=kt(m.extent)?m.extent:s;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const b=t.get(m.parentId);b&&(v=dc(v,_,b))}else g&&(v=St(v,g,_));const C={...m,measured:_,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:ts("source",p.nodeElement,S,f,m.id),target:ts("target",p.nodeElement,S,f,m.id)}}};t.set(m.id,C),m.parentId&&ni(C,t,n,{nodeOrigin:r,zIndexMode:a}),u=!0,x&&(l.push({id:m.id,type:"dimensions",dimensions:_}),m.expandParent&&m.parentId&&d.push({id:m.id,parentId:m.parentId,rect:un(C,r)}))}}if(d.length>0){const p=oi(d,t,n,r);l.push(...p)}return{changes:l,updatedInternals:u}}async function Vp({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:s}){if(!t||!e.x&&!e.y)return!1;const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,s]],o);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function cs(e,t,n,o,r,s){let a=r;const c=o.get(a)||new Map;o.set(a,c.set(n,t)),a=`${r}-${e}`;const u=o.get(a)||new Map;if(o.set(a,u.set(n,t)),s){a=`${r}-${e}-${s}`;const l=o.get(a)||new Map;o.set(a,l.set(n,t))}}function Ec(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:s,sourceHandle:a=null,targetHandle:c=null}=o,u={edgeId:o.id,source:r,target:s,sourceHandle:a,targetHandle:c},l=`${r}-${a}--${s}-${c}`,h=`${s}-${c}--${r}-${a}`;cs("source",u,h,e,r,a),cs("target",u,l,e,s,c),t.set(o.id,o)}}function Nc(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Nc(n,t):!1}function ls(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 Fp(e,t,n,o){const r=new Map;for(const[s,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!Nc(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const c=e.get(s);c&&r.set(s,{id:s,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function Uo({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[a,c]of t){const u=n.get(a)?.internals.userNode;u&&r.push({...u,position:c.position,dragging:o})}if(!e)return[r[0],r];const s=n.get(e)?.internals.userNode;return[s?{...s,position:t.get(e)?.position||s.position,dragging:o}:r[0],r]}function Up({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const s={x:n-r.distance.x,y:o-r.distance.y},a=bn(s,t);return{x:a.x-s.x,y:a.y-s.y}}function Wp({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let s={x:null,y:null},a=0,c=new Map,u=!1,l={x:0,y:0},h=null,f=!1,d=null,p=!1,m=!1,_=null;function x({noDragClassName:S,handleSelector:g,domNode:v,isSelectable:C,nodeId:b,nodeClickDistance:E=0}){d=Ie(v);function A({x:V,y:N}){const{nodeLookup:k,nodeExtent:I,snapGrid:M,snapToGrid:$,nodeOrigin:O,onNodeDrag:j,onSelectionDrag:B,onError:z,updateNodePositions:R}=t();s={x:V,y:N};let F=!1;const U=c.size>1,K=U&&I?gr(xn(c)):null,ie=U&&$?Up({dragItems:c,snapGrid:M,x:V,y:N}):null;for(const[Z,H]of c){if(!k.has(Z))continue;let Y={x:V-H.distance.x,y:N-H.distance.y};$&&(Y=ie?{x:Math.round(Y.x+ie.x),y:Math.round(Y.y+ie.y)}:bn(Y,M));let te=null;if(U&&I&&!H.extent&&K){const{positionAbsolute:ee}=H.internals,se=ee.x-K.x+I[0][0],J=ee.x+H.measured.width-K.x2+I[1][0],ce=ee.y-K.y+I[0][1],ye=ee.y+H.measured.height-K.y2+I[1][1];te=[[se,ce],[J,ye]]}const{position:Q,positionAbsolute:W}=lc({nodeId:Z,nextPosition:Y,nodeLookup:k,nodeExtent:te||I,nodeOrigin:O,onError:z});F=F||H.position.x!==Q.x||H.position.y!==Q.y,H.position=Q,H.internals.positionAbsolute=W}if(m=m||F,!!F&&(R(c,!0),_&&(o||j||!b&&B))){const[Z,H]=Uo({nodeId:b,dragItems:c,nodeLookup:k});o?.(_,c,Z,H),j?.(_,Z,H),b||B?.(_,H)}}async function P(){if(!h)return;const{transform:V,panBy:N,autoPanSpeed:k,autoPanOnNodeDrag:I}=t();if(!I){u=!1,cancelAnimationFrame(a);return}const[M,$]=Gr(l,h,k);(M!==0||$!==0)&&(s.x=(s.x??0)-M/V[2],s.y=(s.y??0)-$/V[2],await N({x:M,y:$})&&A(s)),a=requestAnimationFrame(P)}function L(V){const{nodeLookup:N,multiSelectionActive:k,nodesDraggable:I,transform:M,snapGrid:$,snapToGrid:O,selectNodesOnDrag:j,onNodeDragStart:B,onSelectionDragStart:z,unselectNodesAndEdges:R}=t();f=!0,(!j||!C)&&!k&&b&&(N.get(b)?.selected||R()),C&&j&&b&&e?.(b);const F=nn(V.sourceEvent,{transform:M,snapGrid:$,snapToGrid:O,containerBounds:h});if(s=F,c=Fp(N,I,F,b),c.size>0&&(n||B||!b&&z)){const[U,K]=Uo({nodeId:b,dragItems:c,nodeLookup:N});n?.(V.sourceEvent,c,U,K),B?.(V.sourceEvent,U,K),b||z?.(V.sourceEvent,K)}}const D=Fa().clickDistance(E).on("start",V=>{const{domNode:N,nodeDragThreshold:k,transform:I,snapGrid:M,snapToGrid:$}=t();h=N?.getBoundingClientRect()||null,p=!1,m=!1,_=V.sourceEvent,k===0&&L(V),s=nn(V.sourceEvent,{transform:I,snapGrid:M,snapToGrid:$,containerBounds:h}),l=He(V.sourceEvent,h)}).on("drag",V=>{const{autoPanOnNodeDrag:N,transform:k,snapGrid:I,snapToGrid:M,nodeDragThreshold:$,nodeLookup:O}=t(),j=nn(V.sourceEvent,{transform:k,snapGrid:I,snapToGrid:M,containerBounds:h});if(_=V.sourceEvent,(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1||b&&!O.has(b))&&(p=!0),!p){if(!u&&N&&f&&(u=!0,P()),!f){const B=He(V.sourceEvent,h),z=B.x-l.x,R=B.y-l.y;Math.sqrt(z*z+R*R)>$&&L(V)}(s.x!==j.xSnapped||s.y!==j.ySnapped)&&c&&f&&(l=He(V.sourceEvent,h),A(j))}}).on("end",V=>{if(!f||p){p&&c.size>0&&t().updateNodePositions(c,!1);return}if(u=!1,f=!1,cancelAnimationFrame(a),c.size>0){const{nodeLookup:N,updateNodePositions:k,onNodeDragStop:I,onSelectionDragStop:M}=t();if(m&&(k(c,!1),m=!1),r||I||!b&&M){const[$,O]=Uo({nodeId:b,dragItems:c,nodeLookup:N,dragging:!1});r?.(V.sourceEvent,c,$,O),I?.(V.sourceEvent,$,O),b||M?.(V.sourceEvent,O)}}}).filter(V=>{const N=V.target;return!V.button&&(!S||!ls(N,`.${S}`,v))&&(!g||ls(N,g,v))});d.call(D)}function y(){d?.on(".drag",null)}return{update:x,destroy:y}}function Yp(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())uo(r,un(s))>0&&o.push(s);return o}const Xp=250;function Zp(e,t,n,o){let r=[],s=1/0;const a=Yp(e,n,t+Xp);for(const c of a){const u=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const l of u){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:h,y:f}=Ct(c,l,l.position,!0),d=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));d>t||(d<s?(r=[{...l,x:h,y:f}],s=d):d===s&&r.push({...l,x:h,y:f}))}}if(!r.length)return null;if(r.length>1){const c=o.type==="source"?"target":"source";return r.find(u=>u.type===c)??r[0]}return r[0]}function Ic(e,t,n,o,r,s=!1){const a=o.get(e);if(!a)return null;const c=r==="strict"?a.internals.handleBounds?.[t]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],u=(n?c?.find(l=>l.id===n):c?.[0])??null;return u&&s?{...u,...Ct(a,u,u.position,!0)}:u}function Mc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function qp(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ac=()=>!0;function Gp(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:s,isTarget:a,domNode:c,nodeLookup:u,lib:l,autoPanOnConnect:h,flowId:f,panBy:d,cancelConnection:p,onConnectStart:m,onConnect:_,onConnectEnd:x,isValidConnection:y=Ac,onReconnectEnd:S,updateConnection:g,getTransform:v,getFromHandle:C,autoPanSpeed:b,dragThreshold:E=1,handleDomNode:A}){const P=yc(e.target);let L=0,D;const{x:V,y:N}=He(e),k=Mc(s,A),I=c?.getBoundingClientRect();let M=!1;if(!I||!k)return;const $=Ic(r,k,o,u,t);if(!$)return;let O=He(e,I),j=!1,B=null,z=!1,R=null;function F(){if(!h||!I)return;const[Q,W]=Gr(O,I,b);d({x:Q,y:W}),L=requestAnimationFrame(F)}const U={...$,nodeId:r,type:k,position:$.position},K=u.get(r);let Z={inProgress:!0,isValid:null,from:Ct(K,U,G.Left,!0),fromHandle:U,fromPosition:U.position,fromNode:K,to:O,toHandle:null,toPosition:Ki[U.position],toNode:null,pointer:O};function H(){M=!0,g(Z),m?.(e,{nodeId:r,handleId:o,handleType:k})}E===0&&H();function Y(Q){if(!M){const{x:ye,y:Ee}=He(Q),$e=ye-V,Ne=Ee-N;if(!($e*$e+Ne*Ne>E*E))return;H()}if(!C()||!U){te(Q);return}const W=v();O=He(Q,I),D=Zp(Sn(O,W,!1,[1,1]),n,u,U),j||(F(),j=!0);const ee=$c(Q,{handle:D,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:a?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:f,nodeLookup:u});R=ee.handleDomNode,B=ee.connection,z=qp(!!D,ee.isValid);const se=u.get(r),J=se?Ct(se,U,G.Left,!0):Z.from,ce={...Z,from:J,isValid:z,to:ee.toHandle&&z?Ht({x:ee.toHandle.x,y:ee.toHandle.y},W):O,toHandle:ee.toHandle,toPosition:z&&ee.toHandle?ee.toHandle.position:Ki[U.position],toNode:ee.toHandle?u.get(ee.toHandle.nodeId):null,pointer:O};g(ce),Z=ce}function te(Q){if(!("touches"in Q&&Q.touches.length>0)){if(M){(D||R)&&B&&z&&_?.(B);const{inProgress:W,...ee}=Z,se={...ee,toPosition:Z.toHandle?Z.toPosition:null};x?.(Q,se),s&&S?.(Q,se)}p(),cancelAnimationFrame(L),j=!1,z=!1,B=null,R=null,P.removeEventListener("mousemove",Y),P.removeEventListener("mouseup",te),P.removeEventListener("touchmove",Y),P.removeEventListener("touchend",te)}}P.addEventListener("mousemove",Y),P.addEventListener("mouseup",te),P.addEventListener("touchmove",Y),P.addEventListener("touchend",te)}function $c(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:s,doc:a,lib:c,flowId:u,isValidConnection:l=Ac,nodeLookup:h}){const f=s==="target",d=t?a.querySelector(`.${c}-flow__handle[data-id="${u}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=He(e),_=a.elementFromPoint(p,m),x=_?.classList.contains(`${c}-flow__handle`)?_:d,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const S=Mc(void 0,x),g=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),C=x.classList.contains("connectable"),b=x.classList.contains("connectableend");if(!g||!S)return y;const E={source:f?g:o,sourceHandle:f?v:r,target:f?o:g,targetHandle:f?r:v};y.connection=E;const P=C&&b&&(n===Rt.Strict?f&&S==="source"||!f&&S==="target":g!==o||v!==r);y.isValid=P&&l(E),y.toHandle=Ic(g,S,v,h,n,!0)}return y}const _r={onPointerDown:Gp,isValid:$c};function Kp({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Ie(e);function s({translateExtent:c,width:u,height:l,zoomStep:h=1,pannable:f=!0,zoomable:d=!0,inversePan:p=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),C=g.sourceEvent.ctrlKey&&hn()?10:1,b=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*h,E=v[2]*Math.pow(2,b*C);t.scaleTo(E)};let _=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(_=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],b=[C[0]-_[0],C[1]-_[1]];_=C;const E=o()*Math.max(v[2],Math.log(v[2]))*(p?-1:1),A={x:v[0]-b[0]*E,y:v[1]-b[1]*E},P=[[0,0],[u,l]];t.setViewportConstrained({x:A.x,y:A.y,zoom:v[2]},P,c)},S=rc().on("start",x).on("zoom",f?y:null).on("zoom.wheel",d?m:null);r.call(S,{})}function a(){r.on("zoom",null)}return{update:s,destroy:a,pointer:Oe}}const bo=e=>({x:e.x,y:e.y,zoom:e.k}),Wo=({x:e,y:t,zoom:n})=>_o.translate(e,t).scale(n),ut=(e,t)=>e.target.closest(`.${t}`),Pc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Qp=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Yo=(e,t=0,n=Qp,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Tc=e=>{const t=e.ctrlKey&&hn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Jp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:l}){return h=>{if(ut(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(h.ctrlKey&&a){const x=Oe(h),y=Tc(h),S=f*Math.pow(2,y);o.scaleTo(n,S,x,h);return}const d=h.deltaMode===1?20:1;let p=r===vt.Vertical?0:h.deltaX*d,m=r===vt.Horizontal?0:h.deltaY*d;!hn()&&h.shiftKey&&r!==vt.Vertical&&(p=h.deltaY*d,m=0),o.translateBy(n,-(p/f)*s,-(m/f)*s,{internal:!0});const _=bo(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?u?.(h,_):(e.isPanScrolling=!0,c?.(h,_)),e.panScrollTimeout=setTimeout(()=>{l?.(h,_),e.isPanScrolling=!1},150)}}function eg({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const s=o.type==="wheel",a=!t&&s&&!o.ctrlKey,c=ut(o,e);if(o.ctrlKey&&s&&c&&o.preventDefault(),a||c)return null;o.preventDefault(),n.call(this,o,r)}}function tg({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=bo(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 ng({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return s=>{e.usedRightMouseButton=!!(n&&Pc(t,e.mouseButton??0)),s.sourceEvent?.sync||o([s.transform.x,s.transform.y,s.transform.k]),r&&!s.sourceEvent?.internal&&r?.(s.sourceEvent,bo(s.transform))}}function og({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:s}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,s&&Pc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&s(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const c=bo(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(a.sourceEvent,c)},n?150:0)}}}function rg({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:c,noWheelClassName:u,noPanClassName:l,lib:h,connectionInProgress:f}){return d=>{const p=t||n,m=o&&d.ctrlKey,_=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(ut(d,`${h}-flow__node`)||ut(d,`${h}-flow__edge`)||ut(d,`${h}-flow__selection`)||ut(d,`${h}-flow__nodesselection`)))return!0;if(!r&&!p&&!s&&!a&&!o||c||f&&!_||ut(d,u)&&_||ut(d,l)&&(!_||s&&_&&!t)||!o&&d.ctrlKey&&_)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!p&&!s&&!m&&_||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const x=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||_||e)&&x}}function ig({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:s,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:u}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect();let f=[[0,0],[h.width,h.height]];(typeof ResizeObserver<"u"?new ResizeObserver(N=>{const k=N[0];k&&(f=[[0,0],[k.contentRect.width,k.contentRect.height]])}):null)?.observe(e);const p=rc().extent(()=>f).scaleExtent([t,n]).translateExtent(o),m=Ie(e).call(p);v({x:r.x,y:r.y,zoom:Lt(r.zoom,t,n)},[[0,0],[h.width,h.height]],o);const _=m.on("wheel.zoom"),x=m.on("dblclick.zoom");p.wheelDelta(Tc);async function y(N,k){return m?new Promise(I=>{p?.interpolate(k?.interpolate==="linear"?tn:Yn).transform(Yo(m,k?.duration,k?.ease,()=>I(!0)),N)}):!1}function S({noWheelClassName:N,noPanClassName:k,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:$,panOnDrag:O,panOnScrollMode:j,panOnScrollSpeed:B,preventScrolling:z,zoomOnPinch:R,zoomOnScroll:F,zoomOnDoubleClick:U,panActivationKeyPressed:K=!1,zoomActivationKeyPressed:ie,lib:Z,onTransformChange:H,connectionInProgress:Y,paneClickDistance:te,selectionOnDrag:Q}){M&&!l.isZoomingOrPanning&&g();const W=$&&!ie&&!M;p.clickDistance(Q?1/0:!Le(te)||te<0?0:te);const ee=W?Jp({zoomPanValues:l,noWheelClassName:N,d3Selection:m,d3Zoom:p,panOnScrollMode:j,panOnScrollSpeed:B,zoomOnPinch:R,onPanZoomStart:a,onPanZoom:s,onPanZoomEnd:c}):eg({noWheelClassName:N,preventScrolling:z,d3ZoomHandler:_});m.on("wheel.zoom",ee,{passive:!1});const se=tg({zoomPanValues:l,onDraggingChange:u,onPanZoomStart:a});p.on("start",se);const J=ng({zoomPanValues:l,panOnDrag:O,onPaneContextMenu:!!I,onPanZoom:s,onTransformChange:H});p.on("zoom",J);const ce=og({zoomPanValues:l,panOnDrag:O,panOnScroll:$,onPaneContextMenu:I,onPanZoomEnd:c,onDraggingChange:u});p.on("end",ce);const ye=rg({panActivationKeyPressed:K,zoomActivationKeyPressed:ie,panOnDrag:O,zoomOnScroll:F,panOnScroll:$,zoomOnDoubleClick:U,zoomOnPinch:R,userSelectionActive:M,noPanClassName:k,noWheelClassName:N,lib:Z,connectionInProgress:Y});p.filter(ye),U?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function v(N,k,I){const M=Wo(N),$=p?.constrain()(M,k,I);return $&&await y($),$}async function C(N,k){const I=Wo(N);return await y(I,k),I}function b(N){if(m){const k=Wo(N),I=m.property("__zoom");(I.k!==N.zoom||I.x!==N.x||I.y!==N.y)&&p?.transform(m,k,null,{sync:!0})}}function E(){const N=m?oc(m.node()):{x:0,y:0,k:1};return{x:N.x,y:N.y,zoom:N.k}}async function A(N,k){return m?new Promise(I=>{p?.interpolate(k?.interpolate==="linear"?tn:Yn).scaleTo(Yo(m,k?.duration,k?.ease,()=>I(!0)),N)}):!1}async function P(N,k){return m?new Promise(I=>{p?.interpolate(k?.interpolate==="linear"?tn:Yn).scaleBy(Yo(m,k?.duration,k?.ease,()=>I(!0)),N)}):!1}function L(N){p?.scaleExtent(N)}function D(N){p?.translateExtent(N)}function V(N){const k=!Le(N)||N<0?0:N;p?.clickDistance(k)}return{update:S,destroy:g,setViewport:C,setViewportConstrained:v,getViewport:E,scaleTo:A,scaleBy:P,setScaleExtent:L,setTranslateExtent:D,syncViewport:b,setClickDistance:V}}var zt;(function(e){e.Line="line",e.Handle="handle"})(zt||(zt={}));function sg({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:s}){const a=e-t,c=n-o,u=[a>0?1:a<0?-1:0,c>0?1:c<0?-1:0];return a&&r&&(u[0]=u[0]*-1),c&&s&&(u[1]=u[1]*-1),u}function ds(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 ct(e,t){return Math.max(0,t-e)}function lt(e,t){return Math.max(0,e-t)}function Rn(e,t,n){return Math.max(0,t-e,e-n)}function us(e,t){return e?!t:t}function ag(e,t,n,o,r,s,a,c){let{affectsX:u,affectsY:l}=t;const{isHorizontal:h,isVertical:f}=t,d=h&&f,{xSnapped:p,ySnapped:m}=n,{minWidth:_,maxWidth:x,minHeight:y,maxHeight:S}=o,{x:g,y:v,width:C,height:b,aspectRatio:E}=e;let A=Math.floor(h?p-e.pointerX:0),P=Math.floor(f?m-e.pointerY:0);const L=C+(u?-A:A),D=b+(l?-P:P),V=-s[0]*C,N=-s[1]*b;let k=Rn(L,_,x),I=Rn(D,y,S);if(a){let O=0,j=0;u&&A<0?O=ct(g+A+V,a[0][0]):!u&&A>0&&(O=lt(g+L+V,a[1][0])),l&&P<0?j=ct(v+P+N,a[0][1]):!l&&P>0&&(j=lt(v+D+N,a[1][1])),k=Math.max(k,O),I=Math.max(I,j)}if(c){let O=0,j=0;u&&A>0?O=lt(g+A,c[0][0]):!u&&A<0&&(O=ct(g+L,c[1][0])),l&&P>0?j=lt(v+P,c[0][1]):!l&&P<0&&(j=ct(v+D,c[1][1])),k=Math.max(k,O),I=Math.max(I,j)}if(r){if(h){const O=Rn(L/E,y,S)*E;if(k=Math.max(k,O),a){let j=0;!u&&!l||u&&!l&&d?j=lt(v+N+L/E,a[1][1])*E:j=ct(v+N+(u?A:-A)/E,a[0][1])*E,k=Math.max(k,j)}if(c){let j=0;!u&&!l||u&&!l&&d?j=ct(v+L/E,c[1][1])*E:j=lt(v+(u?A:-A)/E,c[0][1])*E,k=Math.max(k,j)}}if(f){const O=Rn(D*E,_,x)/E;if(I=Math.max(I,O),a){let j=0;!u&&!l||l&&!u&&d?j=lt(g+D*E+V,a[1][0])/E:j=ct(g+(l?P:-P)*E+V,a[0][0])/E,I=Math.max(I,j)}if(c){let j=0;!u&&!l||l&&!u&&d?j=ct(g+D*E,c[1][0])/E:j=lt(g+(l?P:-P)*E,c[0][0])/E,I=Math.max(I,j)}}}P=P+(P<0?I:-I),A=A+(A<0?k:-k),r&&(d?L>D*E?P=(us(u,l)?-A:A)/E:A=(us(u,l)?-P:P)*E:h?(P=A/E,l=u):(A=P*E,u=l));const M=u?g+A:g,$=l?v+P:v;return{width:C+(u?-A:A),height:b+(l?-P:P),x:s[0]*A*(u?-1:1)+M,y:s[1]*P*(l?-1:1)+$}}const Dc={width:0,height:0,x:0,y:0},cg={...Dc,pointerX:0,pointerY:0,aspectRatio:1};function lg(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,s=e.measured.width??0,a=e.measured.height??0,c=n[0]*s,u=n[1]*a;return[[o-c,r-u],[o+s-c,r+a-u]]}function dg({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const s=Ie(e);let a={controlDirection:ds("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:l,boundaries:h,keepAspectRatio:f,resizeDirection:d,onResizeStart:p,onResize:m,onResizeEnd:_,shouldResize:x}){let y={...Dc},S={...cg};a={boundaries:h,resizeDirection:d,keepAspectRatio:f,controlDirection:ds(l)};let g,v=null,C=[],b,E,A;const P=Fa().on("start",L=>{const{nodeLookup:D,transform:V,snapGrid:N,snapToGrid:k,nodeOrigin:I,paneDomNode:M}=n();if(g=D.get(t),!g)return;v=M?.getBoundingClientRect()??null;const{xSnapped:$,ySnapped:O}=nn(L.sourceEvent,{transform:V,snapGrid:N,snapToGrid:k,containerBounds:v});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},S={...y,pointerX:$,pointerY:O,aspectRatio:y.width/y.height},b=void 0,E=kt(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(b=D.get(g.parentId)),b&&g.extent==="parent"&&(E=[[0,0],[b.measured.width,b.measured.height]]),C=[],A=void 0;for(const[j,B]of D)if(B.parentId===t&&(C.push({id:j,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const z=lg(B,g,B.origin??I);A?A=[[Math.min(z[0][0],A[0][0]),Math.min(z[0][1],A[0][1])],[Math.max(z[1][0],A[1][0]),Math.max(z[1][1],A[1][1])]]:A=z}p?.(L,{...y})}).on("drag",L=>{const{transform:D,snapGrid:V,snapToGrid:N,nodeOrigin:k}=n(),I=nn(L.sourceEvent,{transform:D,snapGrid:V,snapToGrid:N,containerBounds:v}),M=[];if(!g)return;const{x:$,y:O,width:j,height:B}=y,z={},R=g.origin??k,{width:F,height:U,x:K,y:ie}=ag(S,a.controlDirection,I,a.boundaries,a.keepAspectRatio,R,E,A),Z=F!==j,H=U!==B,Y=K!==$&&Z,te=ie!==O&&H;if(!Y&&!te&&!Z&&!H)return;const Q={prevValues:{...y},startX:S.x,startY:S.y,childNodes:C.map(J=>({...J,position:{...J.position}}))};if((Y||te||R[0]===1||R[1]===1)&&(z.x=Y?K:y.x,z.y=te?ie:y.y,y.x=z.x,y.y=z.y,C.length>0)){const J=K-$,ce=ie-O;for(const ye of C)ye.position={x:ye.position.x-J+R[0]*(F-j),y:ye.position.y-ce+R[1]*(U-B)},M.push(ye)}if((Z||H)&&(z.width=Z&&(!a.resizeDirection||a.resizeDirection==="horizontal")?F:y.width,z.height=H&&(!a.resizeDirection||a.resizeDirection==="vertical")?U:y.height,y.width=z.width,y.height=z.height),b&&g.expandParent){const J=R[0]*(z.width??0);z.x&&z.x<J&&(y.x=J,S.x=S.x-(z.x-J));const ce=R[1]*(z.height??0);z.y&&z.y<ce&&(y.y=ce,S.y=S.y-(z.y-ce))}const W=sg({width:y.width,prevWidth:j,height:y.height,prevHeight:B,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ee={...y,direction:W};if(x?.(L,ee)===!1){y=Q.prevValues,S.x=Q.startX,S.y=Q.startY,C.forEach((J,ce)=>{J.position=Q.childNodes[ce].position});return}m?.(L,ee),o(z,M)}).on("end",L=>{_?.(L,{...y}),r?.({...y})});s.call(P)}function u(){s.on(".drag",null)}return{update:c,destroy:u}}function ug(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function hg(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),n}var Xo={exports:{}},Zo={};const jc=hg(Td);var qo={exports:{}},Go={};var hs;function fg(){if(hs)return Go;hs=1;var e=jc;function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function c(f,d){var p=d(),m=o({inst:{value:p,getSnapshot:d}}),_=m[0].inst,x=m[1];return s(function(){_.value=p,_.getSnapshot=d,u(_)&&x({inst:_})},[f,p,d]),r(function(){return u(_)&&x({inst:_}),f(function(){u(_)&&x({inst:_})})},[f]),a(p),p}function u(f){var d=f.getSnapshot;f=f.value;try{var p=d();return!n(f,p)}catch{return!0}}function l(f,d){return d()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:c;return Go.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,Go}var fs;function pg(){return fs||(fs=1,qo.exports=fg()),qo.exports}var ps;function gg(){if(ps)return Zo;ps=1;var e=jc,t=pg();function n(l,h){return l===h&&(l!==0||1/l===1/h)||l!==l&&h!==h}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,c=e.useMemo,u=e.useDebugValue;return Zo.useSyncExternalStoreWithSelector=function(l,h,f,d,p){var m=s(null);if(m.current===null){var _={hasValue:!1,value:null};m.current=_}else _=m.current;m=c(function(){function y(b){if(!S){if(S=!0,g=b,b=d(b),p!==void 0&&_.hasValue){var E=_.value;if(p(E,b))return v=E}return v=b}if(E=v,o(g,b))return E;var A=d(b);return p!==void 0&&p(E,A)?(g=b,E):(g=b,v=A)}var S=!1,g,v,C=f===void 0?null:f;return[function(){return y(h())},C===null?void 0:function(){return y(C())}]},[h,f,d,p]);var x=r(l,m[0],m[1]);return a(function(){_.hasValue=!0,_.value=x},[x]),u(x),x},Zo}var gs;function mg(){return gs||(gs=1,Xo.exports=gg()),Xo.exports}var yg=mg();const vg=ug(yg),_g={},ms=e=>{let t;const n=new Set,o=(h,f)=>{const d=typeof h=="function"?h(t):h;if(!Object.is(d,t)){const p=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(m=>m(t,p))}},r=()=>t,u={setState:o,getState:r,getInitialState:()=>l,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(_g?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,u);return u},wg=e=>e?ms(e):ms,{useDebugValue:xg}=Ia,{useSyncExternalStoreWithSelector:bg}=vg,Sg=e=>e;function Oc(e,t=Sg,n){const o=bg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return xg(o),o}const ys=(e,t)=>{const n=wg(e),o=(r,s=t)=>Oc(n,r,s);return Object.assign(o,n),o},kg=(e,t)=>e?ys(e,t):ys;function pe(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 So=Ft(null),Cg=So.Provider,Rc=Be.error001("react");function le(e,t){const n=st(So);if(n===null)throw new Error(Rc);return Oc(n,e,t)}function ue(){const e=st(So);if(e===null)throw new Error(Rc);return ve(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const vs={display:"none"},Eg={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lc="react-flow__node-desc",Hc="react-flow__edge-desc",Ng="react-flow__aria-live",Ig=e=>e.ariaLiveMessage,Mg=e=>e.ariaLabelConfig;function Ag({rfId:e}){const t=le(Ig);return i("div",{id:`${Ng}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Eg,children:t})}function $g({rfId:e,disableKeyboardA11y:t}){const n=le(Mg);return i(q,{children:[i("div",{id:`${Lc}-${e}`,style:vs,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i("div",{id:`${Hc}-${e}`,style:vs,children:n["edge.a11yDescription.default"]}),!t&&i(Ag,{rfId:e})]})}const ko=po(({position:e="top-left",children:t,className:n,style:o,...r},s)=>{const a=`${e}`.split("-");return i("div",{className:me(["react-flow__panel",n,...a]),style:o,ref:s,...r,children:t})});ko.displayName="Panel";const _s="https://reactflow.dev?utm_source=attribution";function Pg({proOptions:e,position:t="bottom-right"}){return ne(()=>{},[]),e?.hideAttribution?null:i(ko,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${_s}`,children:i("a",{href:_s,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Tg=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}},Ln=e=>e.id;function Dg(e,t){return pe(e.selectedNodes.map(Ln),t.selectedNodes.map(Ln))&&pe(e.selectedEdges.map(Ln),t.selectedEdges.map(Ln))}function jg({onSelectionChange:e}){const t=ue(),{selectedNodes:n,selectedEdges:o}=le(Tg,Dg);return ne(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(s=>s(r))},[n,o,e]),null}const Og=e=>!!e.onSelectionChangeHandlers;function Rg({onSelectionChange:e}){const t=le(Og);return e||t?i(jg,{onSelectionChange:e}):null}const zc=[0,0],Lg={x:0,y:0,zoom:1},Hg=["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"],ws=[...Hg,"rfId"],zg=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}),xs={translateExtent:ln,nodeOrigin:zc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Bg(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:s,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:u}=le(zg,pe),l=ue();ne(()=>(u(e.defaultNodes,e.defaultEdges),()=>{h.current=xs,c()}),[]);const h=re(xs);return ne(()=>{for(const f of ws){const d=e[f],p=h.current[f];d!==p&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?s(d):f==="nodeExtent"?a(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:Sp(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}h.current=e},ws.map(f=>e[f])),null}function bs(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Vg(e){const[t,n]=X(e==="system"?null:e);return ne(()=>{if(e!=="system"){n(e);return}const o=bs(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:bs()?.matches?"dark":"light"}const Ss=typeof document<"u"?document:null;function fn(e=null,t={target:Ss,actInsideInputWithModifier:!0}){const[n,o]=X(!1),r=re(!1),s=re(new Set([])),[a,c]=ve(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
|
|
2
|
-
`).replace(`
|
|
3
|
-
|
|
4
|
-
`,`
|
|
5
|
-
+`).split(`
|
|
6
|
-
`)),h=l.reduce((f,d)=>f.concat(...d),[]);return[l,h]}return[[],[]]},[e]);return ne(()=>{const u=t?.target??Ss,l=t?.actInsideInputWithModifier??!0;if(e!==null){const h=p=>{if(r.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!r.current||r.current&&!l)&&vc(p))return!1;const _=Cs(p.code,c);if(s.current.add(p[_]),ks(a,s.current,!1)){const x=p.composedPath?.()?.[0]||p.target,y=x?.nodeName==="BUTTON"||x?.nodeName==="A";t.preventDefault!==!1&&(r.current||!y)&&p.preventDefault(),o(!0)}},f=p=>{const m=Cs(p.code,c);ks(a,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(p[m]),p.key==="Meta"&&s.current.clear(),r.current=!1},d=()=>{s.current.clear(),o(!1)};return u?.addEventListener("keydown",h),u?.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{u?.removeEventListener("keydown",h),u?.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function ks(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function Cs(e,t){return t.includes(e)?"code":"key"}const Fg=()=>{const e=ue();return ve(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,s],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:s,maxZoom:a,panZoom:c}=e.getState(),u=Kr(t,o,r,s,a,n?.padding??.1);return c?(await c.setViewport(u,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:s,domNode:a}=e.getState();if(!a)return t;const{x:c,y:u}=a.getBoundingClientRect(),l={x:t.x-c,y:t.y-u},h=n.snapGrid??r,f=n.snapToGrid??s;return Sn(l,o,f,h)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:s}=o.getBoundingClientRect(),a=Ht(t,n);return{x:a.x+r,y:a.y+s}}}),[])};function Bc(e,t){const n=[],o=new Map,r=[];for(const s of e)if(s.type==="add"){r.push(s);continue}else if(s.type==="remove"||s.type==="replace")o.set(s.id,[s]);else{const a=o.get(s.id);a?a.push(s):o.set(s.id,[s])}for(const s of t){const a=o.get(s.id);if(!a){n.push(s);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const c={...s};for(const u of a)Ug(u,c);n.push(c)}return r.length&&r.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function Ug(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Vc(e,t){return Bc(e,t)}function Wg(e,t){return Bc(e,t)}function gt(e,t){return{id:e,type:"select",selected:t}}function Mt(e,t=new Set,n=!1){const o=[];for(const[r,s]of e){const a=t.has(r);!(s.selected===void 0&&!a)&&s.selected!==a&&(n&&(s.selected=a),o.push(gt(s.id,a)))}return o}function Es({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,s]of e.entries()){const a=t.get(s.id),c=a?.internals?.userNode??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function Ns(e){return{id:e.id,type:"remove"}}const Yg=fc();function Xg(e,t,n={}){return Mp(e,t,{...n,onError:n.onError??Yg})}const Is=e=>pp(e),Zg=e=>cc(e);function Fc(e){return po(e)}const Uc=typeof window<"u"?it:ne;function Ms(e){const[t,n]=X(BigInt(0)),[o]=X(()=>qg(()=>n(r=>r+BigInt(1))));return Uc(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function qg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Wc=Ft(null);function Gg({children:e}){const t=ue(),n=Me(c=>{const{nodes:u=[],setNodes:l,hasDefaultNodes:h,onNodesChange:f,nodeLookup:d,fitViewQueued:p,onNodesChangeMiddlewareMap:m}=t.getState();let _=u;for(const y of c)_=typeof y=="function"?y(_):y;let x=Es({items:_,lookup:d});for(const y of m.values())x=y(x);h&&l(_),x.length>0?f?.(x):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:S,setNodes:g}=t.getState();y&&g(S)})},[]),o=Ms(n),r=Me(c=>{const{edges:u=[],setEdges:l,hasDefaultEdges:h,onEdgesChange:f,edgeLookup:d}=t.getState();let p=u;for(const m of c)p=typeof m=="function"?m(p):m;h?l(p):f&&f(Es({items:p,lookup:d}))},[]),s=Ms(r),a=ve(()=>({nodeQueue:o,edgeQueue:s}),[]);return i(Wc.Provider,{value:a,children:e})}function Kg(){const e=st(Wc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Qg=e=>!!e.panZoom;function ri(){const e=Fg(),t=ue(),n=Kg(),o=le(Qg),r=ve(()=>{const s=f=>t.getState().nodeLookup.get(f),a=f=>{n.nodeQueue.push(f)},c=f=>{n.edgeQueue.push(f)},u=f=>{const{nodeLookup:d,nodeOrigin:p}=t.getState(),m=Is(f)?f:d.get(f.id),_=m.parentId?gc(m.position,m.measured,m.parentId,d,p):m.position,x={...m,position:_,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return un(x)},l=(f,d,p={replace:!1})=>{a(m=>m.map(_=>{if(_.id===f){const x=typeof d=="function"?d(_):d;return p.replace&&Is(x)?x:{..._,...x}}return _}))},h=(f,d,p={replace:!1})=>{c(m=>m.map(_=>{if(_.id===f){const x=typeof d=="function"?d(_):d;return p.replace&&Zg(x)?x:{..._,...x}}return _}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>s(f)?.internals.userNode,getInternalNode:s,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:a,setEdges:c,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:p}=t.getState(),[m,_,x]=p;return{nodes:f.map(y=>({...y})),edges:d.map(y=>({...y})),viewport:{x:m,y:_,zoom:x}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:p,edges:m,onNodesDelete:_,onEdgesDelete:x,triggerNodeChanges:y,triggerEdgeChanges:S,onDelete:g,onBeforeDelete:v}=t.getState(),{nodes:C,edges:b}=await _p({nodesToRemove:f,edgesToRemove:d,nodes:p,edges:m,onBeforeDelete:v}),E=b.length>0,A=C.length>0;if(E){const P=b.map(Ns);x?.(b),S(P)}if(A){const P=C.map(Ns);_?.(C),y(P)}return(A||E)&&g?.({nodes:C,edges:b}),{deletedNodes:C,deletedEdges:b}},getIntersectingNodes:(f,d=!0,p)=>{const m=Ji(f),_=m?f:u(f),x=p!==void 0;return _?(p||t.getState().nodes).filter(y=>{const S=t.getState().nodeLookup.get(y.id);if(S&&!m&&(y.id===f.id||!S.internals.positionAbsolute))return!1;const g=un(x?y:S),v=uo(g,_);return d&&v>0||v>=g.width*g.height||v>=_.width*_.height}):[]},isNodeIntersecting:(f,d,p=!0)=>{const _=Ji(f)?f:u(f);if(!_)return!1;const x=uo(_,d);return p&&x>0||x>=d.width*d.height||x>=_.width*_.height},updateNode:l,updateNodeData:(f,d,p={replace:!1})=>{l(f,m=>{const _=typeof d=="function"?d(m):d;return p.replace?{...m,data:_}:{...m,data:{...m.data,..._}}},p)},updateEdge:h,updateEdgeData:(f,d,p={replace:!1})=>{h(f,m=>{const _=typeof d=="function"?d(m):d;return p.replace?{...m,data:_}:{...m,data:{...m.data,..._}}},p)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:p}=t.getState();return gp(f,{nodeLookup:d,nodeOrigin:p})},getHandleConnections:({type:f,id:d,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${f}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:d,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${f?d?`-${f}-${d}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const d=t.getState().fitViewResolver??bp();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(p=>[...p]),d.promise}}},[]);return ve(()=>({...r,...e,viewportInitialized:o}),[o])}const As=e=>e.selected,Jg=typeof window<"u"?window:void 0;function em({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ue(),{deleteElements:o}=ri(),r=fn(e,{actInsideInputWithModifier:!1}),s=fn(t,{target:Jg});ne(()=>{if(r){const{edges:a,nodes:c}=n.getState();o({nodes:c.filter(As),edges:a.filter(As)}),n.setState({nodesSelectionActive:!1})}},[r]),ne(()=>{n.setState({multiSelectionActive:s})},[s])}function tm(e){const t=ue();ne(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=Qr(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Be.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Co={position:"absolute",width:"100%",height:"100%",top:0,left:0},nm=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function om({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:r,panOnScrollSpeed:s=.5,panOnScrollMode:a=vt.Free,zoomOnDoubleClick:c=!0,panOnDrag:u=!0,defaultViewport:l,translateExtent:h,minZoom:f,maxZoom:d,zoomActivationKeyCode:p,preventScrolling:m=!0,children:_,noWheelClassName:x,noPanClassName:y,onViewportChange:S,isControlledViewport:g,paneClickDistance:v,selectionOnDrag:C}){const b=ue(),E=re(null),{userSelectionActive:A,lib:P,connectionInProgress:L}=le(nm,pe),D=fn(p),V=re();tm(E);const N=Me(k=>{S?.({x:k[0],y:k[1],zoom:k[2]}),g||b.setState({transform:k})},[S,g]);return ne(()=>{if(E.current){V.current=ig({domNode:E.current,minZoom:f,maxZoom:d,translateExtent:h,viewport:l,onDraggingChange:$=>b.setState(O=>O.paneDragging===$?O:{paneDragging:$}),onPanZoomStart:($,O)=>{const{onViewportChangeStart:j,onMoveStart:B}=b.getState();B?.($,O),j?.(O)},onPanZoom:($,O)=>{const{onViewportChange:j,onMove:B}=b.getState();B?.($,O),j?.(O)},onPanZoomEnd:($,O)=>{const{onViewportChangeEnd:j,onMoveEnd:B}=b.getState();B?.($,O),j?.(O)}});const{x:k,y:I,zoom:M}=V.current.getViewport();return b.setState({panZoom:V.current,transform:[k,I,M],domNode:E.current.closest(".react-flow")}),()=>{V.current?.destroy()}}},[]),ne(()=>{V.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:r,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:c,panOnDrag:u,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:y,userSelectionActive:A,noWheelClassName:x,lib:P,onTransformChange:N,connectionInProgress:L,selectionOnDrag:C,paneClickDistance:v})},[e,t,n,o,r,s,a,c,u,D,m,y,A,x,P,N,L,C,v]),i("div",{className:"react-flow__renderer",ref:E,style:Co,children:_})}const rm=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function im(){const{userSelectionActive:e,userSelectionRect:t}=le(rm,pe);return e&&t?i("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Ko=(e,t)=>n=>{n.target===t.current&&e?.(n)},sm=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function am({isSelecting:e,selectionKeyPressed:t,selectionMode:n=dn.Full,panOnDrag:o,autoPanOnSelection:r,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:c,onSelectionEnd:u,onPaneClick:l,onPaneContextMenu:h,onPaneScroll:f,onPaneMouseEnter:d,onPaneMouseMove:p,onPaneMouseLeave:m,children:_}){const x=re(0),y=ue(),{userSelectionActive:S,elementsSelectable:g,dragging:v,panBy:C,autoPanSpeed:b}=le(sm,pe),E=g&&(e||S),A=re(null),P=re(),L=re(new Set),D=re(new Set),V=re(!1),N=re(!1),k=re({x:0,y:0}),I=re(!1),M=H=>{if(N.current||V.current||y.getState().connection.inProgress){N.current=!1,V.current=!1;return}l?.(H),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},$=H=>{if(Array.isArray(o)&&o?.includes(2)){H.preventDefault();return}h?.(H)},O=f?H=>f(H):void 0,j=H=>{N.current&&(H.stopPropagation(),N.current=!1)},B=H=>{if(H.pointerType==="touch"&&o!==!1&&!t)return;const{domNode:Y,transform:te}=y.getState();if(P.current=Y?.getBoundingClientRect(),!P.current)return;const Q=H.target===A.current;if(!Q&&!!H.target.closest(".nokey")||!e||!(a&&Q||t)||H.button!==0||!H.isPrimary)return;H.target?.setPointerCapture?.(H.pointerId),N.current=!1;const{x:se,y:J}=He(H.nativeEvent,P.current),ce=Sn({x:se,y:J},te);y.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:se,y:J}}),Q||(H.stopPropagation(),H.preventDefault())};function z(H,Y){const{userSelectionRect:te}=y.getState();if(!te)return;const{transform:Q,nodeLookup:W,edgeLookup:ee,connectionLookup:se,triggerNodeChanges:J,triggerEdgeChanges:ce,defaultEdgeOptions:ye}=y.getState(),Ee={x:te.startX,y:te.startY},{x:$e,y:Ne}=Ht(Ee,Q),Te={startX:Ee.x,startY:Ee.y,x:H<$e?H:$e,y:Y<Ne?Y:Ne,width:Math.abs(H-$e),height:Math.abs(Y-Ne)},at=L.current,De=D.current;L.current=new Set(qr(W,Te,Q,n===dn.Partial,!0).map(_e=>_e.id)),D.current=new Set;const Ue=ye?.selectable??!0;for(const _e of L.current){const be=se.get(_e);if(be)for(const{edgeId:we}of be.values()){const xe=ee.get(we);xe&&(xe.selectable??Ue)&&D.current.add(we)}}if(!es(at,L.current)){const _e=Mt(W,L.current,!0);J(_e)}if(!es(De,D.current)){const _e=Mt(ee,D.current);ce(_e)}y.setState({userSelectionRect:Te,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!r||!P.current)return;const[H,Y]=Gr(k.current,P.current,b);C({x:H,y:Y}).then(te=>{if(!N.current||!te){x.current=requestAnimationFrame(R);return}const{x:Q,y:W}=k.current;z(Q,W),x.current=requestAnimationFrame(R)})}const F=()=>{cancelAnimationFrame(x.current),x.current=0,I.current=!1};ne(()=>()=>F(),[]);const U=H=>{const{userSelectionRect:Y,transform:te,resetSelectedElements:Q}=y.getState();if(!P.current||!Y)return;const{x:W,y:ee}=He(H.nativeEvent,P.current);k.current={x:W,y:ee};const se=Ht({x:Y.startX,y:Y.startY},te);if(!N.current){const J=t?0:s;if(Math.hypot(W-se.x,ee-se.y)<=J)return;Q(),c?.(H)}N.current=!0,I.current||(R(),I.current=!0),z(W,ee)},K=H=>{if(!E){H.target===A.current&&y.getState().connection.inProgress&&(V.current=!0);return}H.button===0&&(H.target?.releasePointerCapture?.(H.pointerId),!S&&H.target===A.current&&y.getState().userSelectionRect&&M?.(H),y.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(u?.(H),y.setState({nodesSelectionActive:L.current.size>0})),F())},ie=H=>{H.target?.releasePointerCapture?.(H.pointerId),F()},Z=o===!0||Array.isArray(o)&&o.includes(0);return i("div",{className:me(["react-flow__pane",{draggable:Z,dragging:v,selection:e}]),onClick:E?void 0:Ko(M,A),onContextMenu:Ko($,A),onWheel:Ko(O,A),onPointerEnter:E?void 0:d,onPointerMove:E?U:p,onPointerUp:K,onPointerCancel:E?ie:void 0,onPointerDownCapture:E?B:void 0,onClickCapture:E?j:void 0,onPointerLeave:m,ref:A,style:Co,children:[_,i(im,{})]})}function wr({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:a,nodeLookup:c,onError:u}=t.getState(),l=c.get(e);if(!l){u?.("012",Be.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&a)&&(s({nodes:[l],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Yc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:s,nodeClickDistance:a}){const c=ue(),[u,l]=X(!1),h=re();return ne(()=>{if(!t)return h.current=Wp({getStoreItems:()=>c.getState(),onNodeMouseDown:f=>{wr({id:f,store:c,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{h.current?.destroy(),h.current=void 0}},[t,c,e]),ne(()=>{t||!e.current||!h.current||h.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:s,nodeId:r,nodeClickDistance:a})},[n,o,t,s,e,r,a]),u}const cm=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Xc(){const e=ue();return Me(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:s,nodesDraggable:a,onError:c,updateNodePositions:u,nodeLookup:l,nodeOrigin:h}=e.getState(),f=new Map,d=cm(a),p=r?s[0]:5,m=r?s[1]:5,_=n.direction.x*p*n.factor,x=n.direction.y*m*n.factor;for(const[,y]of l){if(!d(y))continue;let S={x:y.internals.positionAbsolute.x+_,y:y.internals.positionAbsolute.y+x};r&&(S=bn(S,s));const{position:g,positionAbsolute:v}=lc({nodeId:y.id,nextPosition:S,nodeLookup:l,nodeExtent:o,nodeOrigin:h,onError:c});y.position=g,y.internals.positionAbsolute=v,f.set(y.id,y)}u(f)},[])}const ii=Ft(null),lm=ii.Provider;ii.Consumer;const Zc=()=>st(ii),dm=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),qc=Ft(null);function um({children:e}){const t=le(dm,pe);return i(qc.Provider,{value:t,children:e})}function hm(){const e=st(qc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const fm={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},pm=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:s,connection:a}=o,{fromHandle:c,toHandle:u,isValid:l}=a;if(!c&&!r)return fm;const h=u?.nodeId===e&&u?.id===t&&u?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:h,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:s===Rt.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!r,valid:h&&l}};function gm({type:e="source",position:t=G.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:a,onConnect:c,children:u,className:l,onMouseDown:h,onTouchStart:f,...d},p){const m=a||null,_=e==="target",x=ue(),y=Zc(),{connectOnClick:S,noPanClassName:g,rfId:v}=hm(),{connectingFrom:C,connectingTo:b,clickConnecting:E,isPossibleEndHandle:A,connectionInProcess:P,clickConnectionInProcess:L,valid:D}=le(pm(y,m,e),pe);y||x.getState().onError?.("010",Be.error010());const V=I=>{const{defaultEdgeOptions:M,onConnect:$,hasDefaultEdges:O}=x.getState(),j={...M,...I};if(O){const{edges:B,setEdges:z,onError:R}=x.getState();z(Xg(j,B,{onError:R}))}$?.(j),c?.(j)},N=I=>{if(!y)return;const M=_c(I.nativeEvent);if(r&&(M&&I.button===0||!M)){const $=x.getState();_r.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:$.autoPanOnConnect,connectionMode:$.connectionMode,connectionRadius:$.connectionRadius,domNode:$.domNode,nodeLookup:$.nodeLookup,lib:$.lib,isTarget:_,handleId:m,nodeId:y,flowId:$.rfId,panBy:$.panBy,cancelConnection:$.cancelConnection,onConnectStart:$.onConnectStart,onConnectEnd:(...O)=>x.getState().onConnectEnd?.(...O),updateConnection:$.updateConnection,onConnect:V,isValidConnection:n||((...O)=>x.getState().isValidConnection?.(...O)??!0),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:$.autoPanSpeed,dragThreshold:$.connectionDragThreshold})}M?h?.(I):f?.(I)},k=I=>{const{onClickConnectStart:M,onClickConnectEnd:$,connectionClickStartHandle:O,connectionMode:j,isValidConnection:B,lib:z,rfId:R,nodeLookup:F,connection:U}=x.getState();if(!y||!O&&!r)return;if(!O){M?.(I.nativeEvent,{nodeId:y,handleId:m,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:y,type:e,id:m}});return}const K=yc(I.target),ie=n||B,{connection:Z,isValid:H}=_r.isValid(I.nativeEvent,{handle:{nodeId:y,id:m,type:e},connectionMode:j,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:ie,flowId:R,doc:K,lib:z,nodeLookup:F});H&&Z&&V(Z);const Y=structuredClone(U);delete Y.inProgress,Y.toPosition=Y.toHandle?Y.toHandle.position:null,$?.(I,Y),x.setState({connectionClickStartHandle:null})};return i("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${v}-${y}-${m}-${e}`,className:me(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,l,{source:!_,target:_,connectable:o,connectablestart:r,connectableend:s,clickconnecting:E,connectingfrom:C,connectingto:b,valid:D,connectionindicator:o&&(!P||A)&&(P||L?s:r)}]),onMouseDown:N,onTouchStart:N,onClick:S?k:void 0,ref:p,...d,children:u})}const Bt=ge(Fc(gm));function mm({data:e,isConnectable:t,sourcePosition:n=G.Bottom}){return i(q,{children:[e?.label,i(Bt,{type:"source",position:n,isConnectable:t})]})}function ym({data:e,isConnectable:t,targetPosition:n=G.Top,sourcePosition:o=G.Bottom}){return i(q,{children:[i(Bt,{type:"target",position:n,isConnectable:t}),e?.label,i(Bt,{type:"source",position:o,isConnectable:t})]})}function vm(){return null}function _m({data:e,isConnectable:t,targetPosition:n=G.Top}){return i(q,{children:[i(Bt,{type:"target",position:n,isConnectable:t}),e?.label]})}const ho={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},$s={input:mm,default:ym,output:_m,group:vm};function wm(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const xm=e=>{const{width:t,height:n,x:o,y:r}=xn(e.nodeLookup,{filter:s=>!!s.selected});return{width:Le(t)?t:null,height:Le(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function bm({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=ue(),{width:r,height:s,transformString:a,userSelectionActive:c}=le(xm,pe),u=Xc(),l=re(null);ne(()=>{n||l.current?.focus({preventScroll:!0})},[n]);const h=!c&&r!==null&&s!==null;if(Yc({nodeRef:l,disabled:!h}),!h)return null;const f=e?p=>{const m=o.getState().nodes.filter(_=>_.selected);e(p,m)}:void 0,d=p=>{Object.prototype.hasOwnProperty.call(ho,p.key)&&(p.preventDefault(),u({direction:ho[p.key],factor:p.shiftKey?4:1}))};return i("div",{className:me(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:i("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:s}})})}const Ps=typeof window<"u"?window:void 0,Sm=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Gc({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:l,selectionOnDrag:h,selectionMode:f,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:_,zoomActivationKeyCode:x,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:g,panOnScroll:v,panOnScrollSpeed:C,panOnScrollMode:b,zoomOnDoubleClick:E,panOnDrag:A,autoPanOnSelection:P,defaultViewport:L,translateExtent:D,minZoom:V,maxZoom:N,preventScrolling:k,onSelectionContextMenu:I,noWheelClassName:M,noPanClassName:$,disableKeyboardA11y:O,onViewportChange:j,isControlledViewport:B}){const{nodesSelectionActive:z,userSelectionActive:R}=le(Sm,pe),F=fn(l,{target:Ps}),U=fn(_,{target:Ps}),K=U||A,ie=U||v,Z=h&&K!==!0,H=F||R||Z;return em({deleteKeyCode:u,multiSelectionKeyCode:m}),i(om,{onPaneContextMenu:s,elementsSelectable:y,zoomOnScroll:S,zoomOnPinch:g,panOnScroll:ie,panActivationKeyPressed:U,panOnScrollSpeed:C,panOnScrollMode:b,zoomOnDoubleClick:E,panOnDrag:!F&&K,defaultViewport:L,translateExtent:D,minZoom:V,maxZoom:N,zoomActivationKeyCode:x,preventScrolling:k,noWheelClassName:M,noPanClassName:$,onViewportChange:j,isControlledViewport:B,paneClickDistance:c,selectionOnDrag:Z,children:i(am,{onSelectionStart:d,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:K,autoPanOnSelection:P,isSelecting:!!H,selectionMode:f,selectionKeyPressed:F,paneClickDistance:c,selectionOnDrag:Z,children:[e,z&&i(bm,{onSelectionContextMenu:I,noPanClassName:$,disableKeyboardA11y:O})]})})}Gc.displayName="FlowRenderer";const km=ge(Gc),Cm=e=>t=>e?qr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function Em(e){return le(Me(Cm(e),[e]),pe)}const Nm=e=>e.updateNodeInternals;function Im(){const e=le(Nm),[t]=X(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const s=r.target.getAttribute("data-id");o.set(s,{id:s,nodeElement:r.target,force:!0})}),e(o)}));return ne(()=>()=>{t?.disconnect()},[t]),t}function Mm({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=ue(),s=re(null),a=re(null),c=re(e.sourcePosition),u=re(e.targetPosition),l=re(t),h=n&&!!e.internals.handleBounds;return ne(()=>{s.current&&!e.hidden&&(!h||a.current!==s.current)&&(a.current&&o?.unobserve(a.current),o?.observe(s.current),a.current=s.current)},[h,e.hidden]),ne(()=>()=>{a.current&&(o?.unobserve(a.current),a.current=null)},[]),ne(()=>{if(s.current){const f=l.current!==t,d=c.current!==e.sourcePosition,p=u.current!==e.targetPosition;(f||d||p)&&(l.current=t,c.current=e.sourcePosition,u.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function Am({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:s,onDoubleClick:a,nodesDraggable:c,elementsSelectable:u,nodesConnectable:l,nodesFocusable:h,resizeObserver:f,noDragClassName:d,noPanClassName:p,disableKeyboardA11y:m,rfId:_,nodeTypes:x,nodeClickDistance:y,onError:S}){const{node:g,internals:v,isParent:C}=le(H=>{const Y=H.nodeLookup.get(e),te=H.parentLookup.has(e);return{node:Y,internals:Y.internals,isParent:te}},pe);let b=g.type||"default",E=x?.[b]||$s[b];E===void 0&&(S?.("003",Be.error003(b)),b="default",E=x?.default||$s.default);const A=!!(g.draggable||c&&typeof g.draggable>"u"),P=!!(g.selectable||u&&typeof g.selectable>"u"),L=!!(g.connectable||l&&typeof g.connectable>"u"),D=!!(g.focusable||h&&typeof g.focusable>"u"),V=ue(),N=pc(g),k=Mm({node:g,nodeType:b,hasDimensions:N,resizeObserver:f}),I=Yc({nodeRef:k,disabled:g.hidden||!A,noDragClassName:d,handleSelector:g.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:y}),M=Xc();if(g.hidden)return null;const $=Fe(g),O=wm(g),j=P||A||t||n||o||r,B=n?H=>n(H,{...v.userNode}):void 0,z=o?H=>o(H,{...v.userNode}):void 0,R=r?H=>r(H,{...v.userNode}):void 0,F=s?H=>s(H,{...v.userNode}):void 0,U=a?H=>a(H,{...v.userNode}):void 0,K=H=>{const{selectNodesOnDrag:Y,nodeDragThreshold:te}=V.getState();P&&(!Y||!A||te>0)&&wr({id:e,store:V,nodeRef:k}),t&&t(H,{...v.userNode})},ie=H=>{if(!(vc(H.nativeEvent)||m)){if(ic.includes(H.key)&&P){const Y=H.key==="Escape";wr({id:e,store:V,unselect:Y,nodeRef:k})}else if(A&&g.selected&&Object.prototype.hasOwnProperty.call(ho,H.key)){H.preventDefault();const{ariaLabelConfig:Y}=V.getState();V.setState({ariaLiveMessage:Y["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),M({direction:ho[H.key],factor:H.shiftKey?4:1})}}},Z=()=>{if(m||!k.current?.matches(":focus-visible"))return;const{transform:H,width:Y,height:te,autoPanOnNodeFocus:Q,setCenter:W}=V.getState();if(!Q)return;qr(new Map([[e,g]]),{x:0,y:0,width:Y,height:te},H,!0).length>0||W(g.position.x+$.width/2,g.position.y+$.height/2,{zoom:H[2]})};return i("div",{className:me(["react-flow__node",`react-flow__node-${b}`,{[p]:A},g.className,{selected:g.selected,selectable:P,parent:C,draggable:A,dragging:I}]),ref:k,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:j?"all":"none",visibility:N?"visible":"hidden",...g.style,...O},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:z,onMouseLeave:R,onContextMenu:F,onClick:K,onDoubleClick:U,onKeyDown:D?ie:void 0,tabIndex:D?0:void 0,onFocus:D?Z:void 0,role:g.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${Lc}-${_}`,"aria-label":g.ariaLabel,...g.domAttributes,children:i(lm,{value:e,children:i(E,{id:e,data:g.data,type:b,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:g.selected??!1,selectable:P,draggable:A,deletable:g.deletable??!0,isConnectable:L,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:I,dragHandle:g.dragHandle,zIndex:v.z,parentId:g.parentId,...$})})})}var $m=ge(Am);const Pm=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Kc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:r}=le(Pm,pe),s=Em(e.onlyRenderVisibleElements),a=Im();return i("div",{className:"react-flow__nodes",style:Co,children:s.map(c=>i($m,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:r},c))})}Kc.displayName="NodeRenderer";const Tm=ge(Kc);function Dm(e){return le(Me(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const s=n.nodeLookup.get(r.source),a=n.nodeLookup.get(r.target);s&&a&&Ep({sourceNode:s,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),pe)}const jm=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return i("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Om=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return i("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Ts={[co.Arrow]:jm,[co.ArrowClosed]:Om};function Rm(e){const t=ue();return ve(()=>Object.prototype.hasOwnProperty.call(Ts,e)?Ts[e]:(t.getState().onError?.("009",Be.error009(e)),null),[e])}const Lm=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:c="auto-start-reverse"})=>{const u=Rm(t);return u?i("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:i(u,{color:n,strokeWidth:a})}):null},Qc=({defaultColor:e,rfId:t})=>{const n=le(s=>s.edges),o=le(s=>s.defaultEdgeOptions),r=ve(()=>Dp(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?i("svg",{className:"react-flow__marker","aria-hidden":"true",children:i("defs",{children:r.map(s=>i(Lm,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};Qc.displayName="MarkerDefinitions";var Hm=ge(Qc);function Jc({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:s,labelBgPadding:a=[2,4],labelBgBorderRadius:c=2,children:u,className:l,...h}){const[f,d]=X({x:1,y:0,width:0,height:0}),p=me(["react-flow__edge-textwrapper",l]),m=re(null);return ne(()=>{if(m.current){const _=m.current.getBBox();d({x:_.x,y:_.y,width:_.width,height:_.height})}},[n]),n?i("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...h,children:[r&&i("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:s,rx:c,ry:c}),i("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:m,style:o,children:n}),u]}):null}Jc.displayName="EdgeText";const zm=ge(Jc);function Eo({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:u,interactionWidth:l=20,...h}){return i(q,{children:[i("path",{...h,d:e,fill:"none",className:me(["react-flow__edge-path",h.className])}),l?i("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&Le(t)&&Le(n)?i(zm,{x:t,y:n,label:o,labelStyle:r,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:u}):null]})}function Ds({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===G.Left||e===G.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function el({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:o,targetY:r,targetPosition:s=G.Top}){const[a,c]=Ds({pos:n,x1:e,y1:t,x2:o,y2:r}),[u,l]=Ds({pos:s,x1:o,y1:r,x2:e,y2:t}),[h,f,d,p]=wc({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:l});return[`M${e},${t} C${a},${c} ${u},${l} ${o},${r}`,h,f,d,p]}function tl(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:a,targetPosition:c,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:m,markerEnd:_,markerStart:x,interactionWidth:y})=>{const[S,g,v]=el({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:s,targetPosition:c}),C=e.isInternal?void 0:t;return i(Eo,{id:C,path:S,labelX:g,labelY:v,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:m,markerEnd:_,markerStart:x,interactionWidth:y})})}const Bm=tl({isInternal:!1}),nl=tl({isInternal:!0});Bm.displayName="SimpleBezierEdge";nl.displayName="SimpleBezierEdgeInternal";function ol(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,sourcePosition:p=G.Bottom,targetPosition:m=G.Top,markerEnd:_,markerStart:x,pathOptions:y,interactionWidth:S})=>{const[g,v,C]=mr({sourceX:n,sourceY:o,sourcePosition:p,targetX:r,targetY:s,targetPosition:m,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),b=e.isInternal?void 0:t;return i(Eo,{id:b,path:g,labelX:v,labelY:C,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,markerEnd:_,markerStart:x,interactionWidth:S})})}const rl=ol({isInternal:!1}),il=ol({isInternal:!0});rl.displayName="SmoothStepEdge";il.displayName="SmoothStepEdgeInternal";function sl(e){return ge(({id:t,...n})=>{const o=e.isInternal?void 0:t;return i(rl,{...n,id:o,pathOptions:ve(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Vm=sl({isInternal:!1}),al=sl({isInternal:!0});Vm.displayName="StepEdge";al.displayName="StepEdgeInternal";function cl(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:m,interactionWidth:_})=>{const[x,y,S]=Sc({sourceX:n,sourceY:o,targetX:r,targetY:s}),g=e.isInternal?void 0:t;return i(Eo,{id:g,path:x,labelX:y,labelY:S,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:m,interactionWidth:_})})}const Fm=cl({isInternal:!1}),ll=cl({isInternal:!0});Fm.displayName="StraightEdge";ll.displayName="StraightEdgeInternal";function dl(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:a=G.Bottom,targetPosition:c=G.Top,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:m,markerEnd:_,markerStart:x,pathOptions:y,interactionWidth:S})=>{const[g,v,C]=xc({sourceX:n,sourceY:o,sourcePosition:a,targetX:r,targetY:s,targetPosition:c,curvature:y?.curvature}),b=e.isInternal?void 0:t;return i(Eo,{id:b,path:g,labelX:v,labelY:C,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:m,markerEnd:_,markerStart:x,interactionWidth:S})})}const Um=dl({isInternal:!1}),ul=dl({isInternal:!0});Um.displayName="BezierEdge";ul.displayName="BezierEdgeInternal";const js={default:ul,straight:ll,step:al,smoothstep:il,simplebezier:nl},Os={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Wm=(e,t,n)=>n===G.Left?e-t:n===G.Right?e+t:e,Ym=(e,t,n)=>n===G.Top?e-t:n===G.Bottom?e+t:e,Rs="react-flow__edgeupdater";function Ls({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:s,onMouseOut:a,type:c}){return i("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:a,className:me([Rs,`${Rs}-${c}`]),cx:Wm(t,o,e),cy:Ym(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Xm({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:s,targetY:a,sourcePosition:c,targetPosition:u,onReconnect:l,onReconnectStart:h,onReconnectEnd:f,setReconnecting:d,setUpdateHover:p}){const m=ue(),_=(v,C)=>{if(v.button!==0)return;const{autoPanOnConnect:b,domNode:E,connectionMode:A,connectionRadius:P,lib:L,onConnectStart:D,cancelConnection:V,nodeLookup:N,rfId:k,panBy:I,updateConnection:M}=m.getState(),$=C.type==="target",O=(z,R)=>{d(!1),f?.(z,n,C.type,R)},j=z=>l?.(n,z),B=(z,R)=>{d(!0),h?.(v,n,C.type),D?.(z,R)};_r.onPointerDown(v.nativeEvent,{autoPanOnConnect:b,connectionMode:A,connectionRadius:P,domNode:E,handleId:C.id,nodeId:C.nodeId,nodeLookup:N,isTarget:$,edgeUpdaterType:C.type,lib:L,flowId:k,cancelConnection:V,panBy:I,isValidConnection:(...z)=>m.getState().isValidConnection?.(...z)??!0,onConnect:j,onConnectStart:B,onConnectEnd:(...z)=>m.getState().onConnectEnd?.(...z),onReconnectEnd:O,updateConnection:M,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},x=v=>_(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=v=>_(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),S=()=>p(!0),g=()=>p(!1);return i(q,{children:[(e===!0||e==="source")&&i(Ls,{position:c,centerX:o,centerY:r,radius:t,onMouseDown:x,onMouseEnter:S,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&i(Ls,{position:u,centerX:s,centerY:a,radius:t,onMouseDown:y,onMouseEnter:S,onMouseOut:g,type:"target"})]})}function Zm({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:s,onContextMenu:a,onMouseEnter:c,onMouseMove:u,onMouseLeave:l,reconnectRadius:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,rfId:m,edgeTypes:_,noPanClassName:x,onError:y,disableKeyboardA11y:S}){let g=le(W=>W.edgeLookup.get(e));const v=le(W=>W.defaultEdgeOptions);g=v?{...v,...g}:g;let C=g.type||"default",b=_?.[C]||js[C];b===void 0&&(y?.("011",Be.error011(C)),C="default",b=_?.default||js.default);const E=!!(g.focusable||t&&typeof g.focusable>"u"),A=typeof f<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),P=!!(g.selectable||o&&typeof g.selectable>"u"),L=re(null),[D,V]=X(!1),[N,k]=X(!1),I=ue(),{zIndex:M=g.zIndex,sourceX:$,sourceY:O,targetX:j,targetY:B,sourcePosition:z,targetPosition:R}=le(Me(W=>{const ee=W.nodeLookup.get(g.source),se=W.nodeLookup.get(g.target);if(!ee||!se)return Os;const J=Tp({id:e,sourceNode:ee,targetNode:se,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:W.connectionMode,onError:y}),ce=Cp({selected:g.selected,zIndex:g.zIndex,sourceNode:ee,targetNode:se,elevateOnSelect:W.elevateEdgesOnSelect,zIndexMode:W.zIndexMode});return{...J||Os,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,y]),pe),F=ve(()=>g.markerStart?`url('#${yr(g.markerStart,m)}')`:void 0,[g.markerStart,m]),U=ve(()=>g.markerEnd?`url('#${yr(g.markerEnd,m)}')`:void 0,[g.markerEnd,m]);if(g.hidden||$===null||O===null||j===null||B===null)return null;const K=W=>{const{addSelectedEdges:ee,unselectNodesAndEdges:se,multiSelectionActive:J}=I.getState();P&&(I.setState({nodesSelectionActive:!1}),g.selected&&J?(se({nodes:[],edges:[g]}),L.current?.blur()):ee([e])),r&&r(W,g)},ie=s?W=>{s(W,{...g})}:void 0,Z=a?W=>{a(W,{...g})}:void 0,H=c?W=>{c(W,{...g})}:void 0,Y=u?W=>{u(W,{...g})}:void 0,te=l?W=>{l(W,{...g})}:void 0,Q=W=>{if(!S&&ic.includes(W.key)&&P){const{unselectNodesAndEdges:ee,addSelectedEdges:se}=I.getState();W.key==="Escape"?(L.current?.blur(),ee({edges:[g]})):se([e])}};return i("svg",{style:{zIndex:M},children:i("g",{className:me(["react-flow__edge",`react-flow__edge-${C}`,g.className,x,{selected:g.selected,animated:g.animated,inactive:!P&&!r,updating:D,selectable:P}]),onClick:K,onDoubleClick:ie,onContextMenu:Z,onMouseEnter:H,onMouseMove:Y,onMouseLeave:te,onKeyDown:E?Q:void 0,tabIndex:E?0:void 0,role:g.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":E?`${Hc}-${m}`:void 0,ref:L,...g.domAttributes,children:[!N&&i(b,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:P,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:$,sourceY:O,targetX:j,targetY:B,sourcePosition:z,targetPosition:R,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:F,markerEnd:U,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),A&&i(Xm,{edge:g,isReconnectable:A,reconnectRadius:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,sourceX:$,sourceY:O,targetX:j,targetY:B,sourcePosition:z,targetPosition:R,setUpdateHover:V,setReconnecting:k})]})})}var qm=ge(Zm);const Gm=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function hl({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:s,onEdgeContextMenu:a,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:l,onEdgeClick:h,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:_}){const{edgesFocusable:x,edgesReconnectable:y,elementsSelectable:S,onError:g}=le(Gm,pe),v=Dm(t);return i("div",{className:"react-flow__edges",children:[i(Hm,{defaultColor:e,rfId:n}),v.map(C=>i(qm,{id:C,edgesFocusable:x,edgesReconnectable:y,elementsSelectable:S,noPanClassName:r,onReconnect:s,onContextMenu:a,onMouseEnter:c,onMouseMove:u,onMouseLeave:l,onClick:h,reconnectRadius:f,onDoubleClick:d,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:g,edgeTypes:o,disableKeyboardA11y:_},C))]})}hl.displayName="EdgeRenderer";const Km=ge(hl),Hs=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Qm({children:e}){const t=ue(),n=re(null),[o]=X(()=>t.getState().transform);return Uc(()=>{let r=null;const s=()=>{const a=t.getState().transform;r&&a[0]===r[0]&&a[1]===r[1]&&a[2]===r[2]||(r=a,n.current&&(n.current.style.transform=Hs(a)))};return s(),t.subscribe(s)},[t]),i("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Hs(o)},children:e})}function Jm(e){const t=ri(),n=re(!1);ne(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const e0=e=>e.panZoom?.syncViewport;function t0(e){const t=le(e0),n=ue();return ne(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function n0(e){return e.connection.inProgress?{...e.connection,to:Sn(e.connection.to,e.transform)}:{...e.connection}}function o0(e){return n0}function r0(e){const t=o0();return le(t,pe)}const i0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function s0({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:s,height:a,isValid:c,inProgress:u}=le(i0,pe);return!(s&&r&&u)?null:i("svg",{style:e,width:s,height:a,className:"react-flow__connectionline react-flow__container",children:i("g",{className:me(["react-flow__connection",mc(c)]),children:i(fl,{style:t,type:n,CustomComponent:o,isValid:c})})})}const fl=({style:e,type:t=ht.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:s,fromNode:a,fromHandle:c,fromPosition:u,to:l,toNode:h,toHandle:f,toPosition:d,pointer:p}=r0();if(!r)return;if(n)return i(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:c,fromX:s.x,fromY:s.y,toX:l.x,toY:l.y,fromPosition:u,toPosition:d,connectionStatus:mc(o),toNode:h,toHandle:f,pointer:p});let m="";const _={sourceX:s.x,sourceY:s.y,sourcePosition:u,targetX:l.x,targetY:l.y,targetPosition:d};switch(t){case ht.Bezier:[m]=xc(_);break;case ht.SimpleBezier:[m]=el(_);break;case ht.Step:[m]=mr({..._,borderRadius:0});break;case ht.SmoothStep:[m]=mr(_);break;default:[m]=Sc(_)}return i("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};fl.displayName="ConnectionLine";const a0={};function zs(e=a0){re(e),ue(),ne(()=>{},[e])}function c0(){ue(),re(!1),ne(()=>{},[])}function pl({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:s,onEdgeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:l,onNodeContextMenu:h,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:_,connectionLineComponent:x,connectionLineContainerStyle:y,selectionKeyCode:S,selectionOnDrag:g,selectionMode:v,multiSelectionKeyCode:C,panActivationKeyCode:b,zoomActivationKeyCode:E,deleteKeyCode:A,onlyRenderVisibleElements:P,elementsSelectable:L,defaultViewport:D,translateExtent:V,minZoom:N,maxZoom:k,preventScrolling:I,defaultMarkerColor:M,zoomOnScroll:$,zoomOnPinch:O,panOnScroll:j,panOnScrollSpeed:B,panOnScrollMode:z,zoomOnDoubleClick:R,panOnDrag:F,autoPanOnSelection:U,onPaneClick:K,onPaneMouseEnter:ie,onPaneMouseMove:Z,onPaneMouseLeave:H,onPaneScroll:Y,onPaneContextMenu:te,paneClickDistance:Q,nodeClickDistance:W,onEdgeContextMenu:ee,onEdgeMouseEnter:se,onEdgeMouseMove:J,onEdgeMouseLeave:ce,reconnectRadius:ye,onReconnect:Ee,onReconnectStart:$e,onReconnectEnd:Ne,noDragClassName:Te,noWheelClassName:at,noPanClassName:De,disableKeyboardA11y:Ue,nodeExtent:_e,rfId:be,viewport:we,onViewportChange:xe,nodesDraggable:Ut}){return zs(e),zs(t),c0(),Jm(n),t0(we),i(km,{onPaneClick:K,onPaneMouseEnter:ie,onPaneMouseMove:Z,onPaneMouseLeave:H,onPaneContextMenu:te,onPaneScroll:Y,paneClickDistance:Q,deleteKeyCode:A,selectionKeyCode:S,selectionOnDrag:g,selectionMode:v,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:L,zoomOnScroll:$,zoomOnPinch:O,zoomOnDoubleClick:R,panOnScroll:j,panOnScrollSpeed:B,panOnScrollMode:z,panOnDrag:F,autoPanOnSelection:U,defaultViewport:D,translateExtent:V,minZoom:N,maxZoom:k,onSelectionContextMenu:f,preventScrolling:I,noDragClassName:Te,noWheelClassName:at,noPanClassName:De,disableKeyboardA11y:Ue,onViewportChange:xe,isControlledViewport:!!we,children:i(Qm,{children:[i(Km,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:a,onReconnect:Ee,onReconnectStart:$e,onReconnectEnd:Ne,onlyRenderVisibleElements:P,onEdgeContextMenu:ee,onEdgeMouseEnter:se,onEdgeMouseMove:J,onEdgeMouseLeave:ce,reconnectRadius:ye,defaultMarkerColor:M,noPanClassName:De,disableKeyboardA11y:Ue,rfId:be}),i(s0,{style:_,type:m,component:x,containerStyle:y}),i("div",{className:"react-flow__edgelabel-renderer"}),i(Tm,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:l,onNodeContextMenu:h,nodeClickDistance:W,onlyRenderVisibleElements:P,noPanClassName:De,noDragClassName:Te,disableKeyboardA11y:Ue,nodeExtent:_e,rfId:be,nodesDraggable:Ut}),i("div",{className:"react-flow__viewport-portal"})]})})}pl.displayName="GraphView";const l0=ge(pl),d0=fc(),Bs=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:a,fitViewOptions:c,minZoom:u=.5,maxZoom:l=2,nodeOrigin:h,nodeExtent:f,zIndexMode:d="basic"}={})=>{const p=new Map,m=new Map,_=new Map,x=new Map,y=o??t??[],S=n??e??[],g=h??[0,0],v=f??ln;Ec(_,x,y);const{nodesInitialized:C}=vr(S,p,m,{nodeOrigin:g,nodeExtent:v,zIndexMode:d});let b=[0,0,1];if(a&&r&&s){const E=xn(p,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:A,y:P,zoom:L}=Kr(E,r,s,u,l,c?.padding??.1);b=[A,P,L]}return{rfId:"1",width:r??0,height:s??0,transform:b,nodes:S,nodesInitialized:C,nodeLookup:p,parentLookup:m,edges:y,edgeLookup:x,connectionLookup:_,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:u,maxZoom:l,translateExtent:ln,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Rt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:c,fitViewResolver:null,connection:{...ac},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:d0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:sc,zIndexMode:d,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},u0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:l,nodeOrigin:h,nodeExtent:f,zIndexMode:d})=>kg((p,m)=>{async function _(){const{nodeLookup:x,panZoom:y,fitViewOptions:S,fitViewResolver:g,width:v,height:C,minZoom:b,maxZoom:E}=m();y&&(await vp({nodes:x,width:v,height:C,panZoom:y,minZoom:b,maxZoom:E},S),g?.resolve(!0),p({fitViewResolver:null}))}return{...Bs({nodes:e,edges:t,width:r,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:l,nodeOrigin:h,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:x=>{const{nodeLookup:y,parentLookup:S,nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:C,fitViewQueued:b,zIndexMode:E,nodesSelectionActive:A}=m(),{nodesInitialized:P,hasSelectedNodes:L}=vr(x,y,S,{nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:E}),D=A&&L;b&&P?(_(),p({nodes:x,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:D})):p({nodes:x,nodesInitialized:P,nodesSelectionActive:D})},setEdges:x=>{const{connectionLookup:y,edgeLookup:S}=m();Ec(y,S,x),p({edges:x})},setDefaultNodesAndEdges:(x,y)=>{if(x){const{setNodes:S}=m();S(x),p({hasDefaultNodes:!0})}if(y){const{setEdges:S}=m();S(y),p({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:y,nodeLookup:S,parentLookup:g,domNode:v,nodeOrigin:C,nodeExtent:b,debug:E,fitViewQueued:A,zIndexMode:P}=m(),{changes:L,updatedInternals:D}=Bp(x,S,g,v,C,b,P);D&&(Rp(S,g,{nodeOrigin:C,nodeExtent:b,zIndexMode:P}),A?(_(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),L?.length>0&&(E&&console.log("React Flow: trigger node changes",L),y?.(L)))},updateNodePositions:(x,y=!1)=>{const S=[];let g=[];const{nodeLookup:v,triggerNodeChanges:C,connection:b,updateConnection:E,onNodesChangeMiddlewareMap:A}=m();for(const[P,L]of x){const D=v.get(P),V=!!(D?.expandParent&&D?.parentId&&L?.position),N={id:P,type:"position",position:V?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:y};if(D&&b.inProgress&&b.fromNode.id===D.id){const k=Ct(D,b.fromHandle,G.Left,!0);E({...b,from:k})}V&&D.parentId&&S.push({id:P,parentId:D.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),g.push(N)}if(S.length>0){const{parentLookup:P,nodeOrigin:L}=m(),D=oi(S,v,P,L);g.push(...D)}for(const P of A.values())g=P(g);C(g)},triggerNodeChanges:x=>{const{onNodesChange:y,setNodes:S,nodes:g,hasDefaultNodes:v,debug:C}=m();if(x?.length){if(v){const b=Vc(x,g);S(b)}C&&console.log("React Flow: trigger node changes",x),y?.(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:y,setEdges:S,edges:g,hasDefaultEdges:v,debug:C}=m();if(x?.length){if(v){const b=Wg(x,g);S(b)}C&&console.log("React Flow: trigger edge changes",x),y?.(x)}},addSelectedNodes:x=>{const{multiSelectionActive:y,edgeLookup:S,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:C}=m();if(y){const b=x.map(E=>gt(E,!0));v(b);return}v(Mt(g,new Set([...x]),!0)),C(Mt(S))},addSelectedEdges:x=>{const{multiSelectionActive:y,edgeLookup:S,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:C}=m();if(y){const b=x.map(E=>gt(E,!0));C(b);return}C(Mt(S,new Set([...x]))),v(Mt(g,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:y}={})=>{const{edges:S,nodes:g,nodeLookup:v,triggerNodeChanges:C,triggerEdgeChanges:b}=m(),E=x||g,A=y||S,P=[];for(const D of E){if(!D.selected)continue;const V=v.get(D.id);V&&(V.selected=!1),P.push(gt(D.id,!1))}const L=[];for(const D of A)D.selected&&L.push(gt(D.id,!1));C(P),b(L)},setMinZoom:x=>{const{panZoom:y,maxZoom:S}=m();y?.setScaleExtent([x,S]),p({minZoom:x})},setMaxZoom:x=>{const{panZoom:y,minZoom:S}=m();y?.setScaleExtent([S,x]),p({maxZoom:x})},setTranslateExtent:x=>{m().panZoom?.setTranslateExtent(x),p({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:y,triggerNodeChanges:S,triggerEdgeChanges:g,elementsSelectable:v}=m();if(!v)return;const C=y.reduce((E,A)=>A.selected?[...E,gt(A.id,!1)]:E,[]),b=x.reduce((E,A)=>A.selected?[...E,gt(A.id,!1)]:E,[]);S(C),g(b)},setNodeExtent:x=>{const{nodes:y,nodeLookup:S,parentLookup:g,nodeOrigin:v,elevateNodesOnSelect:C,nodeExtent:b,zIndexMode:E}=m();x[0][0]===b[0][0]&&x[0][1]===b[0][1]&&x[1][0]===b[1][0]&&x[1][1]===b[1][1]||(vr(y,S,g,{nodeOrigin:v,nodeExtent:x,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:E}),p({nodeExtent:x}))},panBy:x=>{const{transform:y,width:S,height:g,panZoom:v,translateExtent:C}=m();return Vp({delta:x,panZoom:v,transform:y,translateExtent:C,width:S,height:g})},setCenter:async(x,y,S)=>{const{width:g,height:v,maxZoom:C,panZoom:b}=m();if(!b)return!1;const E=typeof S?.zoom<"u"?S.zoom:C;return await b.setViewport({x:g/2-x*E,y:v/2-y*E,zoom:E},{duration:S?.duration,ease:S?.ease,interpolate:S?.interpolate}),!0},cancelConnection:()=>{p({connection:{...ac}})},updateConnection:x=>{p({connection:x})},reset:()=>p({...Bs()})}},Object.is);function h0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:s,initialMinZoom:a,initialMaxZoom:c,initialFitViewOptions:u,fitView:l,nodeOrigin:h,nodeExtent:f,zIndexMode:d,children:p}){const[m]=X(()=>u0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:l,minZoom:a,maxZoom:c,fitViewOptions:u,nodeOrigin:h,nodeExtent:f,zIndexMode:d}));return i(Cg,{value:m,children:i(Gg,{children:i(um,{children:p})})})}function f0({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:s,height:a,fitView:c,fitViewOptions:u,minZoom:l,maxZoom:h,nodeOrigin:f,nodeExtent:d,zIndexMode:p}){return st(So)?i(q,{children:e}):i(h0,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:s,initialHeight:a,fitView:c,initialFitViewOptions:u,initialMinZoom:l,initialMaxZoom:h,nodeOrigin:f,nodeExtent:d,zIndexMode:p,children:e})}const p0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function g0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:s,edgeTypes:a,onNodeClick:c,onEdgeClick:u,onInit:l,onMove:h,onMoveStart:f,onMoveEnd:d,onConnect:p,onConnectStart:m,onConnectEnd:_,onClickConnectStart:x,onClickConnectEnd:y,onNodeMouseEnter:S,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:C,onNodeDoubleClick:b,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:P,onNodesDelete:L,onEdgesDelete:D,onDelete:V,onSelectionChange:N,onSelectionDragStart:k,onSelectionDrag:I,onSelectionDragStop:M,onSelectionContextMenu:$,onSelectionStart:O,onSelectionEnd:j,onBeforeDelete:B,connectionMode:z,connectionLineType:R=ht.Bezier,connectionLineStyle:F,connectionLineComponent:U,connectionLineContainerStyle:K,deleteKeyCode:ie="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:H=!1,selectionMode:Y=dn.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:Q=hn()?"Meta":"Control",zoomActivationKeyCode:W=hn()?"Meta":"Control",snapToGrid:ee,snapGrid:se,onlyRenderVisibleElements:J=!1,selectNodesOnDrag:ce,nodesDraggable:ye,autoPanOnNodeFocus:Ee,nodesConnectable:$e,nodesFocusable:Ne,nodeOrigin:Te=zc,edgesFocusable:at,edgesReconnectable:De,elementsSelectable:Ue=!0,defaultViewport:_e=Lg,minZoom:be=.5,maxZoom:we=2,translateExtent:xe=ln,preventScrolling:Ut=!0,nodeExtent:Wt,defaultMarkerColor:kn="#b1b1b7",zoomOnScroll:Mo=!0,zoomOnPinch:Yt=!0,panOnScroll:Ao=!1,panOnScrollSpeed:Cn=.5,panOnScrollMode:$o=vt.Free,zoomOnDoubleClick:En=!0,panOnDrag:ke=!0,onPaneClick:Po,onPaneMouseEnter:Xt,onPaneMouseMove:Nn,onPaneMouseLeave:To,onPaneScroll:In,onPaneContextMenu:Mn,paneClickDistance:Do=1,nodeClickDistance:w=0,children:T,onReconnect:ae,onReconnectStart:Qe,onReconnectEnd:Je,onEdgeContextMenu:jo,onEdgeDoubleClick:Ml,onEdgeMouseEnter:Al,onEdgeMouseMove:$l,onEdgeMouseLeave:Pl,reconnectRadius:Tl=10,onNodesChange:Dl,onEdgesChange:jl,noDragClassName:Ol="nodrag",noWheelClassName:Rl="nowheel",noPanClassName:ai="nopan",fitView:ci,fitViewOptions:li,connectOnClick:Ll,attributionPosition:Hl,proOptions:zl,defaultEdgeOptions:Bl,elevateNodesOnSelect:Vl=!0,elevateEdgesOnSelect:Fl=!1,disableKeyboardA11y:di=!1,autoPanOnConnect:Ul,autoPanOnNodeDrag:Wl,autoPanOnSelection:Yl=!0,autoPanSpeed:Xl,connectionRadius:Zl,isValidConnection:ql,onError:Gl,style:Kl,id:ui,nodeDragThreshold:Ql,connectionDragThreshold:Jl,viewport:ed,onViewportChange:td,width:nd,height:od,colorMode:rd="light",debug:id,onScroll:hi,ariaLabelConfig:sd,zIndexMode:fi="basic",...ad},cd){const Oo=ui||"1",ld=Vg(rd),dd=Me(pi=>{pi.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),hi?.(pi)},[hi]);return i("div",{"data-testid":"rf__wrapper",...ad,onScroll:dd,style:{...Kl,...p0},ref:cd,className:me(["react-flow",r,ld]),id:ui,role:"application",children:i(f0,{nodes:e,edges:t,width:nd,height:od,fitView:ci,fitViewOptions:li,minZoom:be,maxZoom:we,nodeOrigin:Te,nodeExtent:Wt,zIndexMode:fi,children:[i(Bg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:p,onConnectStart:m,onConnectEnd:_,onClickConnectStart:x,onClickConnectEnd:y,nodesDraggable:ye,autoPanOnNodeFocus:Ee,nodesConnectable:$e,nodesFocusable:Ne,edgesFocusable:at,edgesReconnectable:De,elementsSelectable:Ue,elevateNodesOnSelect:Vl,elevateEdgesOnSelect:Fl,minZoom:be,maxZoom:we,nodeExtent:Wt,onNodesChange:Dl,onEdgesChange:jl,snapToGrid:ee,snapGrid:se,connectionMode:z,translateExtent:xe,connectOnClick:Ll,defaultEdgeOptions:Bl,fitView:ci,fitViewOptions:li,onNodesDelete:L,onEdgesDelete:D,onDelete:V,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:P,onSelectionDrag:I,onSelectionDragStart:k,onSelectionDragStop:M,onMove:h,onMoveStart:f,onMoveEnd:d,noPanClassName:ai,nodeOrigin:Te,rfId:Oo,autoPanOnConnect:Ul,autoPanOnNodeDrag:Wl,autoPanSpeed:Xl,onError:Gl,connectionRadius:Zl,isValidConnection:ql,selectNodesOnDrag:ce,nodeDragThreshold:Ql,connectionDragThreshold:Jl,onBeforeDelete:B,debug:id,ariaLabelConfig:sd,zIndexMode:fi}),i(l0,{onInit:l,onNodeClick:c,onEdgeClick:u,onNodeMouseEnter:S,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:C,onNodeDoubleClick:b,nodeTypes:s,edgeTypes:a,connectionLineType:R,connectionLineStyle:F,connectionLineComponent:U,connectionLineContainerStyle:K,selectionKeyCode:Z,selectionOnDrag:H,selectionMode:Y,deleteKeyCode:ie,multiSelectionKeyCode:Q,panActivationKeyCode:te,zoomActivationKeyCode:W,onlyRenderVisibleElements:J,defaultViewport:_e,translateExtent:xe,minZoom:be,maxZoom:we,preventScrolling:Ut,zoomOnScroll:Mo,zoomOnPinch:Yt,zoomOnDoubleClick:En,panOnScroll:Ao,panOnScrollSpeed:Cn,panOnScrollMode:$o,panOnDrag:ke,autoPanOnSelection:Yl,onPaneClick:Po,onPaneMouseEnter:Xt,onPaneMouseMove:Nn,onPaneMouseLeave:To,onPaneScroll:In,onPaneContextMenu:Mn,paneClickDistance:Do,nodeClickDistance:w,onSelectionContextMenu:$,onSelectionStart:O,onSelectionEnd:j,onReconnect:ae,onReconnectStart:Qe,onReconnectEnd:Je,onEdgeContextMenu:jo,onEdgeDoubleClick:Ml,onEdgeMouseEnter:Al,onEdgeMouseMove:$l,onEdgeMouseLeave:Pl,reconnectRadius:Tl,defaultMarkerColor:kn,noDragClassName:Ol,noWheelClassName:Rl,noPanClassName:ai,rfId:Oo,disableKeyboardA11y:di,nodeExtent:Wt,viewport:ed,onViewportChange:td,nodesDraggable:ye}),i(Rg,{onSelectionChange:N}),T,i(Pg,{proOptions:zl,position:Hl}),i($g,{rfId:Oo,disableKeyboardA11y:di})]})})}var m0=Fc(g0);function y0({dimensions:e,lineWidth:t,variant:n,className:o}){return i("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:me(["react-flow__background-pattern",n,o])})}function v0({radius:e,className:t}){return i("circle",{cx:e,cy:e,r:e,className:me(["react-flow__background-pattern","dots",t])})}var pt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(pt||(pt={}));const _0={[pt.Dots]:1,[pt.Lines]:1,[pt.Cross]:6},w0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function gl({id:e,variant:t=pt.Dots,gap:n=20,size:o,lineWidth:r=1,offset:s=0,color:a,bgColor:c,style:u,className:l,patternClassName:h}){const f=re(null),{transform:d,patternId:p}=le(w0,pe),m=o||_0[t],_=t===pt.Dots,x=t===pt.Cross,y=Array.isArray(n)?n:[n,n],S=[y[0]*d[2]||1,y[1]*d[2]||1],g=m*d[2],v=Array.isArray(s)?s:[s,s],C=x?[g,g]:S,b=[v[0]*d[2]+C[0]/2,v[1]*d[2]+C[1]/2],E=`${p}${e||""}`;return i("svg",{className:me(["react-flow__background",l]),style:{...u,...Co,"--xy-background-color-props":c,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i("pattern",{id:E,x:d[0]%S[0],y:d[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${b[0]},-${b[1]})`,children:_?i(v0,{radius:g/2,className:h}):i(y0,{dimensions:C,lineWidth:r,variant:t,className:h})}),i("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}gl.displayName="Background";const x0=ge(gl);function b0(){return i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:i("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function S0(){return i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:i("path",{d:"M0 0h32v4.2H0z"})})}function k0(){return i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:i("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function C0(){return i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function E0(){return i("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:i("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Hn({children:e,className:t,...n}){return i("button",{type:"button",className:me(["react-flow__controls-button",t]),...n,children:e})}const N0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ml({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:a,onFitView:c,onInteractiveChange:u,className:l,children:h,position:f="bottom-left",orientation:d="vertical","aria-label":p}){const m=ue(),{isInteractive:_,minZoomReached:x,maxZoomReached:y,ariaLabelConfig:S}=le(N0,pe),{zoomIn:g,zoomOut:v,fitView:C}=ri(),b=()=>{g(),s?.()},E=()=>{v(),a?.()},A=()=>{C(r),c?.()},P=()=>{m.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),u?.(!_)};return i(ko,{className:me(["react-flow__controls",d==="horizontal"?"horizontal":"vertical",l]),position:f,style:e,"data-testid":"rf__controls","aria-label":p??S["controls.ariaLabel"],children:[t&&i(q,{children:[i(Hn,{onClick:b,className:"react-flow__controls-zoomin",title:S["controls.zoomIn.ariaLabel"],"aria-label":S["controls.zoomIn.ariaLabel"],disabled:y,children:i(b0,{})}),i(Hn,{onClick:E,className:"react-flow__controls-zoomout",title:S["controls.zoomOut.ariaLabel"],"aria-label":S["controls.zoomOut.ariaLabel"],disabled:x,children:i(S0,{})})]}),n&&i(Hn,{className:"react-flow__controls-fitview",onClick:A,title:S["controls.fitView.ariaLabel"],"aria-label":S["controls.fitView.ariaLabel"],children:i(k0,{})}),o&&i(Hn,{className:"react-flow__controls-interactive",onClick:P,title:S["controls.interactive.ariaLabel"],"aria-label":S["controls.interactive.ariaLabel"],children:_?i(E0,{}):i(C0,{})}),h]})}ml.displayName="Controls";const I0=ge(ml);function M0({id:e,x:t,y:n,width:o,height:r,style:s,color:a,strokeColor:c,strokeWidth:u,className:l,borderRadius:h,shapeRendering:f,selected:d,onClick:p}){const{background:m,backgroundColor:_}=s||{},x=a||m||_;return i("rect",{className:me(["react-flow__minimap-node",{selected:d},l]),x:t,y:n,rx:h,ry:h,width:o,height:r,style:{fill:x,stroke:c,strokeWidth:u},shapeRendering:f,onClick:p?y=>p(y,e):void 0})}const A0=ge(M0),$0=e=>e.nodes.map(t=>t.id),Qo=e=>e instanceof Function?e:()=>e;function P0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:s=A0,onClick:a}){const c=le($0,pe),u=Qo(t),l=Qo(e),h=Qo(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i(q,{children:c.map(d=>i(D0,{id:d,nodeColorFunc:u,nodeStrokeColorFunc:l,nodeClassNameFunc:h,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:s,onClick:a,shapeRendering:f},d))})}function T0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:s,shapeRendering:a,NodeComponent:c,onClick:u}){const{node:l,x:h,y:f,width:d,height:p}=le(m=>{const _=m.nodeLookup.get(e);if(!_)return{node:void 0,x:0,y:0,width:0,height:0};const x=_.internals.userNode,{x:y,y:S}=_.internals.positionAbsolute,{width:g,height:v}=Fe(x);return{node:x,x:y,y:S,width:g,height:v}},pe);return!l||l.hidden||!pc(l)?null:i(c,{x:h,y:f,width:d,height:p,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:s,shapeRendering:a,onClick:u,id:l.id})}const D0=ge(T0);var j0=ge(P0);const O0=200,R0=150,L0=e=>!e.hidden,H0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const o of e.nodeLookup.values())if(!o.hidden){n=!0;break}return{viewBB:t,boundingRect:n?uc(xn(e.nodeLookup,{filter:L0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Vs=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,z0=(e,t)=>Vs(e.viewBB,t.viewBB)&&Vs(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,B0="react-flow__minimap-desc";function yl({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:c,bgColor:u,maskColor:l,maskStrokeColor:h,maskStrokeWidth:f,position:d="bottom-right",onClick:p,onNodeClick:m,pannable:_=!1,zoomable:x=!1,ariaLabel:y,inversePan:S,zoomStep:g=1,offsetScale:v=5}){const C=ue(),b=re(null),{boundingRect:E,panZoom:A,viewBB:P,rfId:L,translateExtent:D,flowWidth:V,flowHeight:N,ariaLabelConfig:k}=le(H0,z0),I=e?.width??O0,M=e?.height??R0,$=E.width/I,O=E.height/M,j=Math.max($,O),B=j*I,z=j*M,R=v*j,F=E.x-(B-E.width)/2-R,U=E.y-(z-E.height)/2-R,K=B+R*2,ie=z+R*2,Z=`${B0}-${L}`,H=re(0),Y=re();H.current=j,ne(()=>{const se=C.getState().panZoom;if(b.current&&se)return Y.current=Kp({domNode:b.current,panZoom:se,getTransform:()=>C.getState().transform,getViewScale:()=>H.current}),()=>{Y.current?.destroy()}},[A]),ne(()=>{Y.current?.update({translateExtent:D,width:V,height:N,inversePan:S,pannable:_,zoomStep:g,zoomable:x})},[_,x,S,g,D,V,N]);const te=p?se=>{const[J,ce]=Y.current?.pointer(se)||[0,0];p(se,{x:J,y:ce})}:void 0,Q=Me((se,J)=>{const ce=C.getState().nodeLookup.get(J).internals.userNode;m?.(se,ce)},[m]),W=m?Q:void 0,ee=y??k["minimap.ariaLabel"];return i(ko,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*j:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:me(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i("svg",{width:I,height:M,viewBox:`${F} ${U} ${K} ${ie}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:b,onClick:te,children:[ee&&i("title",{id:Z,children:ee}),i(j0,{onClick:W,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:r,nodeStrokeWidth:a,nodeComponent:c}),i("path",{className:"react-flow__minimap-mask",d:`M${F-R},${U-R}h${K+R*2}v${ie+R*2}h${-K-R*2}z
|
|
7
|
-
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}yl.displayName="MiniMap";const V0=ge(yl),F0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,U0={[zt.Line]:"right",[zt.Handle]:"bottom-right"};function W0({nodeId:e,position:t,variant:n=zt.Handle,className:o,style:r=void 0,children:s,color:a,minWidth:c=10,minHeight:u=10,maxWidth:l=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:p=!0,shouldResize:m,onResizeStart:_,onResize:x,onResizeEnd:y}){const S=Zc(),g=typeof e=="string"?e:S,v=ue(),C=re(null),b=n===zt.Handle,E=le(Me(F0(b&&p),[b,p]),pe),A=re(null),P=t??U0[n];ne(()=>{if(!(!C.current||!g))return A.current||(A.current=dg({domNode:C.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:D,transform:V,snapGrid:N,snapToGrid:k,nodeOrigin:I,domNode:M}=v.getState();return{nodeLookup:D,transform:V,snapGrid:N,snapToGrid:k,nodeOrigin:I,paneDomNode:M}},onChange:(D,V)=>{const{triggerNodeChanges:N,nodeLookup:k,parentLookup:I,nodeOrigin:M}=v.getState(),$=[],O={x:D.x,y:D.y},j=k.get(g);if(j&&j.expandParent&&j.parentId){const B=j.origin??M,z=D.width??j.measured.width??0,R=D.height??j.measured.height??0,F={id:j.id,parentId:j.parentId,rect:{width:z,height:R,...gc({x:D.x??j.position.x,y:D.y??j.position.y},{width:z,height:R},j.parentId,k,B)}},U=oi([F],k,I,M);$.push(...U),O.x=D.x?Math.max(B[0]*z,D.x):void 0,O.y=D.y?Math.max(B[1]*R,D.y):void 0}if(O.x!==void 0&&O.y!==void 0){const B={id:g,type:"position",position:{...O}};$.push(B)}if(D.width!==void 0&&D.height!==void 0){const z={id:g,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};$.push(z)}for(const B of V){const z={...B,type:"position"};$.push(z)}N($)},onEnd:({width:D,height:V})=>{const N={id:g,type:"dimensions",resizing:!1,dimensions:{width:D,height:V}};v.getState().triggerNodeChanges([N])}})),A.current.update({controlPosition:P,boundaries:{minWidth:c,minHeight:u,maxWidth:l,maxHeight:h},keepAspectRatio:f,resizeDirection:d,onResizeStart:_,onResize:x,onResizeEnd:y,shouldResize:m}),()=>{A.current?.destroy()}},[P,c,u,l,h,f,_,x,y,m]);const L=P.split("-");return i("div",{className:me(["react-flow__resize-control","nodrag",...L,n,o]),ref:C,style:{...r,scale:E,...a&&{[b?"backgroundColor":"borderColor"]:a}},children:s})}ge(W0);function Y0(e){let t=2166136261;for(const n of e)t=Math.imul(t^n.charCodeAt(0),16777619)>>>0;return"#"+[0,8,16].map(n=>(60+(t>>>n&255)%111).toString(16).padStart(2,"0")).join("")}const vl=e=>e.color||Y0(e.id),pn=(e,t,n)=>n&&e.missions[n]?.color||vl(e.projects[t]||{id:t});function X0(e,t,n={},o){let r=[],s=[],a=0;const c=t.query.trim().toLowerCase(),u=(...g)=>g.join(" ").toLowerCase().includes(c),l=(g,v,C,b)=>r.push({id:g,type:"work",position:{x:v,y:C},data:b}),h=(g,v,C)=>s.push({id:`${g}:${v}`,source:g,target:v,type:"smoothstep",style:{stroke:C,strokeWidth:1.5}});for(const g of Object.values(e.projects).filter(v=>!v.archivedAt&&(t.project==="all"||v.id===t.project)).sort((v,C)=>v.name.localeCompare(C.name)||v.id.localeCompare(C.id))){const v=a,C=[];for(const b of Object.values(e.missions).filter(E=>E.projectId===g.id&&!E.archivedAt).sort((E,A)=>E.name.localeCompare(A.name)||E.id.localeCompare(A.id))){const E=Object.values(e.tasks).filter(N=>N.missionId===b.id),A=E.filter(N=>(t.agent==="all"||N.updatedBy===t.agent)&&(t.status==="all"||N.status===t.status)&&u(g.name,b.name,N.title,N.note)).sort((N,k)=>N.createdAt.localeCompare(k.createdAt)||N.id.localeCompare(k.id)),P=t.agent==="all"||Object.values(e.sessions).some(N=>N.agent===t.agent&&(N.missionId===b.id||N.missionIds?.includes(b.id)));if(!A.length&&!(E.length===0&&t.status==="all"&&P&&u(g.name,b.name)))continue;const L=a,D=pn(e,g.id,b.id);for(const N of A)l(N.id,800,a*170,{label:N.title,kind:"Task",status:N.status,color:D,href:`#/tasks/${encodeURIComponent(N.id)}`,summary:`${N.updatedBy} · ${N.status==="completed"?"100%":N.status==="todo"?"0%":N.progress!==void 0?`${N.progress}%`:"Progress not reported"}`}),h(b.id,N.id,D),a++;A.length||a++;const V=(L+a-1)*85;l(b.id,400,V,{label:b.name,kind:"Mission",status:b.status,color:D,href:`#/missions/${encodeURIComponent(b.id)}`,summary:`${A.length} ${t.status==="all"&&t.agent==="all"&&!c?"":"matching "}tasks`}),C.push(b.id),h(g.id,b.id,D),a+=.35}!C.length&&!(t.agent==="all"&&t.status==="all"&&u(g.name)&&!Object.values(e.missions).some(b=>b.projectId===g.id&&!b.archivedAt))||(C.length||a++,l(g.id,0,(v+a-1)*85,{label:g.name,kind:"Project",status:"active",color:pn(e,g.id),href:`#/projects/${encodeURIComponent(g.id)}`,summary:`${C.length} missions`}),a++)}const f={projects:r.filter(g=>g.data.kind==="Project").length,missions:r.filter(g=>g.data.kind==="Mission").length,tasks:r.filter(g=>g.data.kind==="Task").length},d=s,p=new Set(o?.projects),m=new Set(o?.missions);for(const g of r)g.data.childCount=d.filter(v=>v.source===g.id).length,g.data.expanded=!o||(g.data.kind==="Project"?p.has(g.id):m.has(g.id));if(o){const g=new Set(r.filter(E=>E.data.kind==="Project").map(E=>E.id)),v=new Set(d.filter(E=>g.has(E.source)&&p.has(E.source)).map(E=>E.target)),C=new Set(d.filter(E=>v.has(E.source)&&m.has(E.source)).map(E=>E.target));r=r.filter(E=>g.has(E.id)||v.has(E.id)||C.has(E.id));const b=new Set(r.map(E=>E.id));s=s.filter(E=>b.has(E.source)&&b.has(E.target))}const _=new Map(r.map(g=>[g.id,g])),x=g=>s.filter(v=>v.source===g).map(v=>_.get(v.target));let y=0;for(const g of r.filter(v=>v.data.kind==="Project")){const v=x(g.id),C=v.some(L=>x(L.id).length>0),b=Math.min(C?2:3,Math.max(1,v.length)),E=C?540:260,A=b*E;g.position={x:y+(A-220)/2,y:0};let P=180;for(let L=0;L<v.length;L+=b){const D=v.slice(L,L+b);let V=0;for(const[N,k]of D.entries()){const I=x(k.id),M=Math.min(2,Math.max(1,I.length)),$=y+N*E;k.position={x:$+(E-220)/2,y:P};const O=$+(E-(M===2?480:220))/2;for(const[j,B]of I.entries())B.position={x:O+j%2*260,y:P+160+Math.floor(j/2)*150};V=Math.max(V,Math.ceil(I.length/2))}P+=V?160+V*150+50:156}y+=A+70}o&&p.size===0&&r.filter(g=>g.data.kind==="Project").forEach((g,v)=>{g.position={x:v%3*260,y:Math.floor(v/3)*156}});const S=[...Object.values(n)];for(const g of r)if(n[g.id])g.position=n[g.id];else{for(;S.some(v=>Math.abs(v.x-g.position.x)<240&&Math.abs(v.y-g.position.y)<136);)g.position={x:g.position.x,y:g.position.y+156};S.push(g.position)}return{nodes:r,edges:s,counts:f}}const _l={active:"Active",planned:"Planned",running:"Running",todo:"To do",in_progress:"In progress",blocked:"Blocked",completed:"Completed",failed:"Failed",cancelled:"Cancelled"},xr="angine-graph-manual-positions-compact-v5";function Z0(){try{const e=JSON.parse(localStorage.getItem(xr)||"{}");return Object.fromEntries(Object.entries(e).filter(([,t])=>t&&Number.isFinite(t.x)&&Number.isFinite(t.y)))}catch{return{}}}function q0({data:e}){return i("div",{class:"graph-card",style:{borderInlineStart:`4px solid ${e.color}`},children:[i(Bt,{type:"target",position:G.Top,isConnectable:!1}),i("div",{class:"graph-card-top",children:[i("span",{children:e.kind}),i("span",{class:`badge ${e.status}`,children:_l[e.status]||e.status})]}),i("a",{class:"nodrag",href:e.href,title:e.label,children:[e.label,i("span",{"aria-hidden":"true",children:" ↗"})]}),i("p",{children:e.summary}),!!e.childCount&&e.toggle&&i("button",{class:"nodrag graph-expand","aria-expanded":e.expanded,onClick:e.toggle,children:[e.expanded?"− Hide":"+ Show"," ",e.kind==="Project"?"missions":"tasks"]}),i(Bt,{type:"source",position:G.Bottom,isConnectable:!1})]})}const G0={work:q0};function K0({state:e,filters:t,setFilters:n,reset:o}){const r=re(Z0()),s=re({...r.current}),[a,c]=X([]),[u,l]=X(null),[h,f]=X(0),d=re(""),[p,m]=X([]),[_,x]=X([]),y=!!(t.query||t.project!=="all"||t.agent!=="all"||t.status!=="all"),S=(N,k)=>{d.current=k==="Project"?N:e.missions[N]?.projectId||"",(k==="Project"?m:x)(M=>M.includes(N)?M.filter($=>$!==N):[...M,N]),s.current={...r.current},c([]),f(M=>M+1)},g=()=>{d.current="",r.current={},m([]),x([]),s.current={},c([]),f(N=>N+1),o()},v=re(""),C=()=>{const N=a.find(I=>I.id===d.current)||a.find(I=>I.data.kind==="Project")||a[0],k=document.querySelector(".graph-canvas")?.clientWidth||1e3;if(!p.length&&!y){u?.fitView({padding:.15,minZoom:.65,maxZoom:.9,duration:250});return}N&&u?.setViewport({x:k/2-(N.position.x+110)*.9,y:45-N.position.y*.9,zoom:.9},{duration:250})},b=()=>{u?.fitView({padding:.2,minZoom:.65,maxZoom:1,duration:250})};ne(()=>{const N=JSON.stringify([t.project,t.agent,t.status,t.query,h,p,_]);u&&a.length&&v.current!==N&&(v.current=N,requestAnimationFrame(C)),a.length||(v.current="")},[u,a.length,t.project,t.agent,t.status,t.query,h,p,_]);const E=ve(()=>X0(e,t,s.current,{projects:y?Object.keys(e.projects):p,missions:y?Object.keys(e.missions):_}),[e,t.project,t.agent,t.status,t.query,h,p,_]),A=()=>{try{localStorage.setItem(xr,JSON.stringify(r.current))}catch{}};ne(()=>{c(N=>{const k=new Map(N.map(I=>[I.id,I]));return E.nodes.map(I=>{const M=k.get(I.id)?.position||I.position;return s.current[I.id]=M,{...k.get(I.id),...I,position:M,data:{...I.data,toggle:y?void 0:()=>S(I.id,I.data.kind)}}})})},[E]),ne(()=>{for(const N of a)s.current[N.id]=N.position;A()},[a]);const P=Object.values(e.projects).filter(N=>!N.archivedAt).sort((N,k)=>N.name.localeCompare(k.name)),L=[...new Set([...Object.values(e.sessions).map(N=>N.agent),...Object.values(e.tasks).map(N=>N.updatedBy)])].sort(),D=!!(t.query||t.project!=="all"||t.agent!=="all"||t.status!=="all");return i("section",{class:"graph-view",children:[i("div",{class:"graph-heading",children:[i("div",{children:[i("h1",{children:"Work graph"}),i("p",{children:"Projects → Missions → Tasks · Live from agent reports"})]}),i("div",{class:"graph-actions",children:[i("button",{class:"secondary-button",onClick:b,children:"Fit view"}),i("button",{class:"secondary-button",onClick:g,children:"All projects"}),i("button",{class:"secondary-button",onClick:()=>{s.current={...r.current},c([]),m(Object.keys(e.projects)),x(Object.keys(e.missions)),f(N=>N+1)},children:"Expand all"}),i("button",{class:"secondary-button",onClick:()=>{r.current={},s.current={};try{localStorage.removeItem(xr)}catch{}c([]),f(N=>N+1)},children:"Auto arrange"})]})]}),i("div",{class:"toolbar graph-toolbar",children:[i("label",{class:"search",children:[i("span",{"aria-hidden":"true",children:"⌕"}),i("input",{"aria-label":"Search graph",placeholder:"Search projects, missions, tasks…",value:t.query,onInput:N=>n({query:N.currentTarget.value})})]}),i("label",{class:"filter-label",children:[i("span",{children:"Project"}),i("select",{"aria-label":"Graph project",value:t.project,onChange:N=>n({project:N.currentTarget.value}),children:[i("option",{value:"all",children:"All projects"}),P.map(N=>i("option",{value:N.id,children:N.name},N.id))]})]}),i("label",{class:"filter-label",children:[i("span",{children:"Agent"}),i("select",{"aria-label":"Graph agent",value:t.agent,onChange:N=>n({agent:N.currentTarget.value}),children:[i("option",{value:"all",children:"All agents"}),L.map(N=>i("option",{value:N,children:N},N))]})]}),i("label",{class:"filter-label",children:[i("span",{children:"Task status"}),i("select",{"aria-label":"Graph task status",value:t.status,onChange:N=>n({status:N.currentTarget.value}),children:[i("option",{value:"all",children:"All statuses"}),["todo","in_progress","blocked","completed","failed","cancelled"].map(N=>i("option",{value:N,children:_l[N]},N))]})]}),D&&i("button",{class:"clear-filters",onClick:o,children:"Reset"})]}),i("div",{class:"graph-meta",children:[i("span",{children:[E.counts.projects," projects · ",E.counts.missions," missions · ",E.counts.tasks," tasks · ",E.nodes.length," nodes shown"]}),i("span",{children:"Show missions and tasks to explore · Drag to arrange · Scroll to zoom"})]}),i("div",{class:"graph-canvas",role:"region","aria-label":"Interactive project mission and task graph",children:E.nodes.length?i(m0,{nodes:a,edges:E.edges,nodeTypes:G0,onNodesChange:N=>c(k=>Vc(N,k)),onNodeDragStop:(N,k)=>{s.current[k.id]=k.position,r.current[k.id]=k.position,A()},onInit:l,defaultViewport:{x:40,y:40,zoom:.9},minZoom:.3,maxZoom:2,nodesConnectable:!1,edgesReconnectable:!1,deleteKeyCode:null,children:[i(x0,{gap:22,size:1}),i(I0,{showInteractive:!1,showFitView:!1}),i(V0,{pannable:!0,zoomable:!0,nodeColor:N=>String(N.data.color||"#94a3b8")})]}):i("div",{class:"empty",children:[i("h2",{children:D?"No work matches these filters":"Your graph will grow here"}),i("p",{children:D?"Try another project, agent, or task status.":"Ask a connected agent to report a mission. Its project and tasks will appear automatically."}),D?i("button",{class:"secondary-button",onClick:o,children:"Clear filters"}):i("a",{href:"#/agents",children:"Check agent connections"})]})})]})}const zn=(e,t,n)=>e?{borderInlineStart:`3px solid ${pn(e,t,n)}`}:void 0;function Q0({project:e,mission:t,mutate:n}){const[o,r]=X(!1),s=t?{missionId:t.id}:{projectId:e.id},a=async u=>{r(!0);try{await n("color",{...s,color:u})}finally{r(!1)}},c=t?t.color:e.color;return i("div",{class:"color-control",children:[i("label",{children:[i("span",{children:t?"Mission color":"Project color"}),i("input",{type:"color","aria-label":t?"Choose mission color override":"Choose project color",value:c||vl(e),disabled:o,onChange:u=>{a(u.currentTarget.value)}})]}),i("p",{children:t?c?"Custom color for this mission and its tasks.":"Inherits the project color.":"Used by all missions and tasks without an override."}),c&&i("button",{class:"text-button",disabled:o,onClick:()=>{a(null)},children:t?"Use project color":"Reset to automatic"}),o&&i("span",{role:"status",children:"Saving…"})]})}function Fs(){return Object.fromEntries([["claude","Other"],["codex","Other"],["antigravity","Other"],["grok","Other"]].map(([e,t])=>{const n=`${e}-default`,o={id:`profile_${n}`,key:n,name:`${e[0].toUpperCase()+e.slice(1)} / ${t}`,agent:e,context:t,isDefault:!0};return[o.id,o]}))}function on(e,t=60,n=Date.now()){return t>0&&["running","in_progress","blocked"].includes(e.status)&&n-Date.parse(e.updatedAt)>=t*6e4}const J0=e=>`prj_${e}`,Us=e=>e?.path.split(/[\\/]/).filter(Boolean).pop()||"Project";function ey(e,t,n){return JSON.parse(JSON.stringify({id:e.projectId,key:n?.key||Us(t),workspaceId:e.workspaceId,name:n?.name||Us(t),description:n?.description,color:n?.color,status:"active",createdAt:n&&n.createdAt<e.createdAt?n.createdAt:e.createdAt,updatedAt:n&&n.updatedAt>e.updatedAt?n.updatedAt:e.updatedAt,archivedAt:n?.archivedAt,latestUpdate:n?.latestUpdate,latestMonitoring:n?.latestMonitoring}))}function ty(e){if(e.schemaVersion!==void 0&&e.schemaVersion!==1&&e.schemaVersion!==2)throw new Error("Unsupported Angine state version");if(e.schemaVersion===2)return{...e,missions:e.missions||{},profiles:e.profiles||Fs()};const t={},n={},o=e.workspaces||{};for(const a of Object.values(e.projects||{})){const c={...a,projectId:J0(a.workspaceId)};t[c.id]=c,n[c.projectId]=ey(c,o[c.workspaceId],n[c.projectId])}const r={};for(const a of Object.values(e.tasks||{})){const c=t[a.projectId];r[a.id]={...a,missionId:a.missionId||a.projectId,projectId:c?.projectId||a.projectId}}const s={};for(const a of Object.values(e.sessions||{})){const c=a.missionIds||a.projectIds||[a.projectId];s[a.id]={...a,missionId:a.missionId||a.projectId,missionIds:c,projectId:t[a.projectId]?.projectId||a.projectId,projectIds:[...new Set(c.map(u=>t[u]?.projectId||u))]}}return{schemaVersion:2,seq:e.seq||0,workspaces:o,projects:n,missions:t,tasks:r,sessions:s,profiles:e.profiles||Fs()}}function wl(e,t){return!!(e.projects[t.projectId]?.archivedAt||e.missions?.[t.missionId]?.archivedAt)}const ny=3,oy=75e3;function No(e,t=Date.now()){return!e.closedAt&&t-Date.parse(e.lastSeenAt)<oy?"connected":"disconnected"}function xl(e,t){return t?e?.reporters.find(n=>n.id===t):void 0}function ry(e,t=Date.now()){const n=new Map;for(const o of e){const r=JSON.stringify([o.agent,o.profileId||o.profileKey||"default"]);let s=n.get(r);s||(s={id:r,agent:o.agent,profileId:o.profileId,profileKey:o.profileKey,reporters:[],connected:0,sentUpdates:0,connectedOnly:0,issues:0},n.set(r,s)),s.reporters.push(o);const a=No(o,t)==="connected";a&&s.connected++,o.successfulReports>0?s.sentUpdates++:a&&s.connectedOnly++,o.issue&&s.issues++}return[...n.values()].map(o=>({...o,reporters:o.reporters.sort((r,s)=>+!!s.issue-+!!r.issue||+(s.successfulReports>0)-+(r.successfulReports>0)||(s.lastReportAt||"").localeCompare(r.lastReportAt||"")||s.startedAt.localeCompare(r.startedAt))})).sort((o,r)=>r.issues-o.issues||o.agent.localeCompare(r.agent))}function bl(e,t,n,o,r=Date.now()){return t.filter(s=>!e.projects[s.projectId]?.archivedAt&&!e.missions?.[s.missionId]?.archivedAt).flatMap(s=>{if(s.status==="blocked")return[{task:s,reason:s.blocker?.nextStep||s.blocker?.reason||"Blocked — open for details"}];if(s.status==="failed")return[{task:s,reason:"Agent reported failure"}];if(s.status!=="in_progress")return[];const a=xl(n,e.sessions[s.updatedBySessionId||""]?.reporterId);return a?.issue?[{task:s,reason:"Reporter needs attention"}]:a&&No(a,r)==="disconnected"?[{task:s,reason:"Reporter disconnected — task status unconfirmed"}]:on(s,o,r)?[{task:s,reason:"No recent task update"}]:[]})}const Jo=e=>e[0].toUpperCase()+e.slice(1),br=e=>e?new Date(e).toLocaleString():"No reports yet";function iy(){const[e,t]=X(null),[n,o]=X("checking");return ne(()=>{let r=!1,s=!1;const a=new AbortController,c=async()=>{if(!s){s=!0;try{const l=await fetch("/api/health",{signal:a.signal});if(r)return;if(l.status===404){o("outdated"),t(null);return}if(!l.ok)throw new Error;const h=await l.json();if(r)return;t(h),o(h.protocolVersion===ny?"ready":"outdated")}catch{r||(o("unavailable"),t(null))}finally{s=!1}}};c();const u=setInterval(()=>{c()},15e3);return()=>{r=!0,a.abort(),clearInterval(u)}},[]),{health:e,compatibility:n}}function sy({compatibility:e}){return e!=="outdated"?null:i("div",{class:"server-notice",role:"status",children:[i("strong",{children:"Update the running server"}),i("span",{children:["Run ",i("code",{children:"angine restart"}),", refresh this page, then restart your agent sessions. New controls need the updated server."]})]})}function Sl({reporter:e}){const t=e?No(e):"unknown";return i("span",{class:`reporter-health ${t}`,title:"This describes the Angine reporter connection, not whether the agent is currently working.",children:[i("span",{}),t==="connected"?"Reporter connected":t==="disconnected"?"Reporter disconnected":"Connection not tracked"]})}function ay({health:e,session:t}){const n=xl(e,t.reporterId);return i("div",{class:"reporting-details",children:[i(Sl,{reporter:n}),i("p",{children:["Last task report: ",br(t.lastSeenAt)]}),n&&i("p",{children:[n.successfulReports," accepted · ",n.failedReports," rejected reports since server start"]}),i("p",{children:"Task status is agent reported. A connection heartbeat does not confirm task progress."})]})}const cy=e=>e.issue==="profile_missing"?"Profile not found. Check the configured profile key.":e.issue==="reporter_outdated"?"Restart this agent session to load the updated reporter.":e.issue==="report_rejected"?"A report was rejected. Check its profile and task keys; the next accepted report clears this warning.":"";function ly({health:e,compatibility:t,profile:n,profiles:o={}}){const[r,s]=X(!1),a=(e?.reporters||[]).filter(f=>!n||f.profileId===n.id||f.profileKey===n.key&&f.agent===n.agent).sort((f,d)=>d.lastSeenAt.localeCompare(f.lastSeenAt)),c=ry(a),u=a.filter(f=>No(f)==="connected").length,l=n?["mcp","--agent",n.agent,"--profile",n.key]:void 0,h=n?JSON.stringify({command:"angine",args:l},null,2):"angine setup";return i("section",{class:"panel connection-panel",children:[i("div",{class:"panel-heading",children:[i("h2",{children:"Connections"}),i("span",{children:t==="ready"?`${u} connected`:t==="outdated"?"Server update needed":t==="checking"?"Checking…":"Unable to check"})]}),i("p",{class:"muted",children:"Connected means the integration is reachable. “Sent updates” counts reporters that submitted work since the server started; “connected only” means no work updates in that time. Neither confirms the agent is currently working."}),c.map(f=>i("details",{class:"connection-group",children:[i("summary",{children:[i("span",{children:[i("strong",{children:[o[f.profileId||""]?.name||Jo(f.agent),!f.profileId&&f.profileKey?` · ${f.profileKey}`:""]}),i("span",{children:[f.connected," connected · ",f.sentUpdates," sent updates · ",f.connectedOnly," connected only"]})]}),i("span",{class:f.issues?"connection-issue":"connection-group-expand",children:f.issues?`${f.issues} need attention`:`${f.reporters.length} reporters`})]}),i("div",{class:"connection-group-rows",children:f.reporters.map(d=>i("div",{class:"connection-row",children:[i("div",{children:[i("strong",{children:[Jo(d.agent)," · ",d.id.slice(0,8)]}),i(Sl,{reporter:d}),i("span",{children:d.lastReportAt?`Last known report: ${br(d.lastReportAt)}`:"No task updates received in this server session"}),d.issue&&i("p",{class:"connection-issue",children:cy(d)})]}),i("details",{children:[i("summary",{children:"Details"}),i("dl",{children:[i("dt",{children:"Profile"}),i("dd",{children:o[d.profileId||""]?.name||d.profileKey||"Agent default"}),i("dt",{children:"Reporter version"}),i("dd",{children:d.version||"Unknown"}),i("dt",{children:"Last heartbeat"}),i("dd",{children:br(d.lastSeenAt)}),i("dt",{children:"Accepted since server start"}),i("dd",{children:d.successfulReports}),i("dt",{children:"Rejected since server start"}),i("dd",{children:d.failedReports}),i("dt",{children:"Reporter ID"}),i("dd",{children:d.id}),d.sourceSessionId&&i(q,{children:[i("dt",{children:"Agent session"}),i("dd",{children:d.sourceSessionId})]})]})]})]},d.id))})]},f.id)),!a.length&&i("p",{class:"muted",children:["No tracked connections ",n?"for this profile ":"","yet. Restart your configured agent session to load the updated reporter."]}),i("details",{class:"connect-instructions",children:[i("summary",{children:n?"Connect this profile":"Connect an agent"}),i("p",{children:n?"Use this configuration for the agent’s Angine MCP connection. The profile key assigns its reports here.":"Run setup once, then restart Claude or Codex sessions. Setup registers their local MCP reporter."}),i("pre",{children:h}),i("button",{class:"secondary-button",onClick:async()=>{try{await navigator.clipboard.writeText(h),s(!0)}catch{s(!1)}},children:r?"Copied":"Copy setup"}),i("p",{class:"muted",children:"After reconnecting, ask the agent to use Angine’s check_connection tool. A successful check confirms the reporter and profile; reports will appear when the agent sends work updates."}),n?.isDefault&&i("p",{class:"muted",children:["This is the default profile for ",Jo(n.agent),". Existing connections without an explicit profile key use it automatically."]})]})]})}function dy({state:e,tasks:t,health:n,staleMinutes:o}){const r=bl(e,t,n,o),s=t.filter(a=>a.status==="in_progress").length;return i("details",{class:`attention-summary ${r.length?"has-attention":""}`,children:[i("summary",{children:[i("span",{children:[i("strong",{children:r.length?`${r.length} need attention`:"No tasks need attention"}),i("span",{children:[s," in progress · Based on the current filters"]})]}),i("span",{class:"attention-expand",children:"View details"})]}),i("div",{class:"attention-items",children:[r.slice(0,10).map(({task:a,reason:c})=>i("a",{href:`#/tasks/${encodeURIComponent(a.id)}`,children:[i("strong",{children:a.title}),i("span",{class:"attention-context",children:[i("b",{children:"Project:"})," ",e.projects[a.projectId]?.name||"Unknown project"," ",i("span",{"aria-hidden":"true",children:" / "}),i("b",{children:"Mission:"})," ",e.missions[a.missionId]?.name||"Unknown mission"]}),i("span",{class:"attention-reason",children:c})]},a.id)),!r.length&&i("p",{class:"muted",children:"No blocked, failed, stale, or tracked disconnected tasks in this view. This is based on reports received, not independent verification of the work."}),r.length>10&&i("p",{class:"muted",children:"Showing the first 10. Use the task filters to review the remaining work."})]})]})}const er={agent:"all",status:"all",project:"all",mission:"all",profile:"all",query:"",staleOnly:!1},_t=e=>({codex:"Codex",claude:"Claude",antigravity:"Antigravity",grok:"Grok",external:"External"})[(e||"external").trim()]||e||"External",je=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`;function kl(e,t){try{return JSON.parse(localStorage.getItem(e)||"null")??t}catch{return t}}function Cl(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function uy(e){const[t,n]=X(()=>kl("angine-filters-v1",{}));ne(()=>Cl("angine-filters-v1",t),[t]);const o={...er,...t[e]},r=s=>n(a=>({...a,[e]:{...er,...a[e],...s}}));return{filters:o,set:r,reset:()=>r({...er}),resetAll:()=>n({})}}function hy(){const[e,t]=X(()=>{const u=kl("angine-preferences-v1",{staleMinutes:60}),l=u.staleMinutes??60;return{staleMinutes:[0,15,60,240,1440].includes(l)?l:60,showMonitoring:u.showMonitoring!==!1,notifications:{enabled:!1,completed:!0,attention:!0,agent:"all"}}}),[n,o]=X(""),[r,s]=X(!0);return ne(()=>Cl("angine-preferences-v1",{staleMinutes:e.staleMinutes,showMonitoring:e.showMonitoring}),[e.staleMinutes,e.showMonitoring]),ne(()=>{let u=!0;return(async()=>{try{await fetch("/api/dashboard/session");const l=await fetch("/api/dashboard/preferences",{headers:{"X-Angine-UI":"1"}}),h=await l.json();if(!l.ok)throw new Error(h.error||"Could not load notification settings.");u&&(t(f=>({...f,notifications:h.preferences})),s(h.systemNotificationsSupported===!0))}catch(l){u&&o(l.message)}})(),()=>{u=!1}},[]),{preferences:e,setPreferences:t,saveNotifications:async u=>{const l=await Sr("preferences",u);return t(h=>({...h,notifications:u})),o(""),l},testNotifications:async()=>{await Sr("notification-test",{})},notificationError:n,notificationSupported:r}}async function fy(e,t){if(!(await fetch("/api/dashboard/session")).ok)throw new Error("Run angine restart in your terminal to load the new dashboard controls, then refresh this page and save again.");const o=await fetch(`/api/dashboard/${e}`,{method:"POST",headers:{"Content-Type":"application/json","X-Angine-UI":"1"},body:JSON.stringify(t)}),r=await o.json();if(!o.ok)throw new Error(r.error||"Could not save the change.");return r}async function Sr(e,t){return(await fy(e,t)).state}function Io(e,t){if(t)return t?.profileId?e.profiles?.[t.profileId]:Object.values(e.profiles||{}).find(n=>n.isDefault&&n.agent===(t?.agent||"external"))}function Vt(e,t){return Io(e,e.sessions[t.updatedBySessionId||""])||Object.values(e.profiles||{}).find(n=>n.isDefault&&n.agent===(t.updatedBy||"external"))}function Bn({item:e,minutes:t}){return t>0&&on(e,t)?i("span",{class:"stale-tag",title:`No reported update since ${new Date(e.updatedAt).toLocaleString()}`,children:"Stale"}):null}function py({profile:e,mutate:t,close:n}){const[o,r]=X(()=>e||{agent:"external",context:"Personal",isDefault:!0}),[s,a]=X(!1),c={name:"A name you recognise in Angine, such as Team Agent or Development Agent.",agent:"The agent reporting the work: claude, codex, grok, or another agent name. Use external for a generic reporter. This must match the reporter’s agent type.",key:"A unique ID for this profile, such as team-agent. Use this key in the reporter’s --profile setting to link its reports here. It cannot be changed after saving.",context:"What you use this agent for, such as Work or Personal. This label helps you identify and filter its work.",ownerName:"Optional. The person using this agent. Enter the name yourself; Angine does not read it from the agent account.",ownerEmail:"Optional. The owner’s email for identifying whose work this is. It is not used to sign in or send email.",accountLabel:"Optional. A nickname for the account, such as Company account or Personal account. Enter a label, never a password or API key.",description:"Optional. A short note explaining what this profile is used for, such as development and code reviews."},u=(l,h,f=!1,d=160)=>i("label",{children:[h,i("input",{type:l==="ownerEmail"?"email":"text",required:f,readOnly:!!(e&&(l==="agent"||l==="key")),maxLength:d,value:String(o[l]??""),"aria-describedby":`profile-help-${l}`,onInput:p=>r({...o,[l]:p.currentTarget.value})}),i("span",{class:"field-help",id:`profile-help-${l}`,children:c[l]})]});return i("form",{class:"panel profile-form",onSubmit:async l=>{l.preventDefault(),a(!0);const h=await t("profiles",o);a(!1),h&&n()},children:[i("div",{class:"panel-heading",children:[i("h2",{children:e?"Edit profile":"New agent profile"}),i("button",{type:"button",class:"text-button",onClick:n,children:"Close"})]}),i("div",{class:"form-grid",children:[u("name","Profile name",!0),u("agent","Agent type",!0,80),u("key","Stable profile key",!0),u("context","Context (Work, Personal…)",!0,80),u("ownerName","Owner name"),u("ownerEmail","Owner email"),u("accountLabel","Account label"),u("description","Description",!1,500)]}),i("label",{class:"check-label",children:[i("input",{type:"checkbox","aria-describedby":"profile-help-default",checked:o.isDefault===!0,onChange:l=>r({...o,isDefault:l.currentTarget.checked})}),"Default profile for this agent type"]}),i("p",{class:"field-help",id:"profile-help-default",children:"Reports from this agent type use this profile when no profile key is specified. For example, making this the Claude default labels Claude reports with this profile. Only one profile can be the default for each agent type."}),i("p",{class:"muted",children:"Saving creates the profile. To link reports, make it the default or configure the agent’s Angine reporter with this profile key. Saving does not start or configure an agent."}),i("button",{class:"primary-button",disabled:s,children:s?"Saving…":"Save profile"})]})}function gy({state:e,profileId:t,mutate:n,taskRow:o,health:r,compatibility:s}){const[a,c]=X(null),u=Object.values(e.profiles||{}).sort((_,x)=>_.name.localeCompare(x.name)),l=t?e.profiles?.[t]:void 0,h=_=>Object.values(e.sessions).filter(x=>Io(e,x)?.id===_.id),f=_=>Object.values(e.tasks).filter(x=>Vt(e,x)?.id===_.id&&!wl(e,x)),d=_=>{const x=new Set([...f(_).map(y=>y.projectId),...h(_).flatMap(y=>y.projectIds||[y.projectId])]);return Object.values(e.projects).filter(y=>x.has(y.id)&&!y.archivedAt)},p=_=>{const x=new Set([...f(_).map(y=>y.missionId),...h(_).flatMap(y=>y.missionIds||[y.missionId])]);return Object.values(e.missions).filter(y=>x.has(y.id)&&!y.archivedAt&&!e.projects[y.projectId]?.archivedAt)},m=_=>{const x=h(_).sort((C,b)=>b.lastSeenAt.localeCompare(C.lastSeenAt)),y=C=>x.find(b=>b.id!==C.id&&C.parentAgentId===b.agentId&&C.sourceSessionId&&b.sourceSessionId===C.sourceSessionId&&b.workspaceId===C.workspaceId),S=[],g=new Set,v=(C,b)=>{g.has(C.id)||(g.add(C.id),S.push({session:C,depth:b}),x.filter(E=>y(E)?.id===C.id).forEach(E=>v(E,b+1)))};return x.filter(C=>!y(C)).forEach(C=>v(C,0)),x.forEach(C=>v(C,0)),S};return t&&!l?i("div",{class:"empty",children:[i("h2",{children:"Profile not found"}),i("a",{href:je("agents"),children:"All agents"})]}):i(q,{children:[i("div",{class:"view-heading",children:[i("div",{children:[i("h1",{children:l?.name||"Agents & sessions"}),i("p",{children:l?`${l.context} · ${_t(l.agent)}`:"Profiles, collaboration, and reported agent sessions."})]}),i("button",{class:"primary-button",onClick:()=>c(l||"new"),children:l?"Edit profile":"Add profile"})]}),a&&i(py,{profile:a==="new"?void 0:a,mutate:n,close:()=>c(null)},a==="new"?"new":a.id),i(ly,{profiles:e.profiles,health:r,compatibility:s,profile:l}),l?i(q,{children:[i("nav",{class:"breadcrumbs",children:[i("a",{href:je("agents"),children:"Agents"}),i("span",{children:"/"}),i("span",{children:l.name})]}),i("div",{class:"profile-summary panel",children:[i("span",{children:[d(l).length," projects"]}),i("span",{children:[p(l).length," missions"]}),i("span",{children:[f(l).length," tasks"]}),i("span",{children:[h(l).length," sessions"]}),l.ownerName&&i("span",{children:["Owner: ",l.ownerName]}),l.ownerEmail&&i("span",{children:l.ownerEmail}),l.accountLabel&&i("span",{children:["Account: ",l.accountLabel]})]}),i("section",{class:"panel",children:[i("h2",{children:"Projects"}),i("div",{class:"linked-projects",children:[d(l).map(_=>i("a",{href:je("projects",_.id),children:[_.name,i("span",{children:_.status})]})),!d(l).length&&i("p",{class:"muted",children:"No projects reported for this profile yet."})]})]}),i("section",{class:"panel",children:[i("h2",{children:"Missions"}),i("div",{class:"linked-projects",children:[p(l).map(_=>i("a",{href:je("missions",_.id),children:[_.name,i("span",{children:[e.projects[_.projectId]?.name," · ",_.status]})]},_.id)),!p(l).length&&i("p",{class:"muted",children:"No missions reported for this profile yet."})]})]}),i("section",{class:"panel",children:[i("h2",{children:"Tasks"}),i("div",{class:"task-table",children:f(l).map(o)})]}),i("section",{class:"panel",children:[i("h2",{children:"Sessions & child agents"}),i("div",{class:"sessions-view",children:[m(l).map(({session:_,depth:x})=>i("div",{class:"session-card",style:{marginLeft:`${Math.min(x,4)*20}px`},children:[i("strong",{children:_.agentId||_t(_.agent)}),i("span",{children:[_.parentAgentId?`Child of ${_.parentAgentId}`:"Reporter session"," · Last report ",new Date(_.lastSeenAt).toLocaleString()]}),i("dl",{children:[i("dt",{children:"Angine session"}),i("dd",{children:_.id}),_.sourceSessionId&&i(q,{children:[i("dt",{children:"Agent session"}),i("dd",{children:_.sourceSessionId})]}),i("dt",{children:"Projects"}),i("dd",{children:(_.projectIds||[_.projectId]).map(y=>i("a",{class:"session-project",href:je("projects",y),children:e.projects[y]?.name||y}))}),i("dt",{children:"Missions"}),i("dd",{children:(_.missionIds||[_.missionId]).map(y=>i("a",{class:"session-project",href:je("missions",y),children:e.missions[y]?.name||y}))}),i("dt",{children:"Latest task reports"}),i("dd",{children:Object.values(e.tasks).filter(y=>y.updatedBySessionId===_.id).map(y=>i("a",{class:"session-project",href:je("tasks",y.id),children:y.title}))})]})]},_.id)),!h(l).length&&i("p",{class:"muted",children:"Sessions appear when this agent reports work. Child links require reported parent IDs."})]})]})]}):i("div",{class:"profile-grid",children:u.map(_=>i("article",{class:"panel profile-card",children:[i("div",{class:"panel-heading",children:[i("a",{href:je("agents",_.id),children:i("h2",{children:_.name})}),i("button",{class:"text-button",onClick:()=>c(_),children:"Edit"})]}),i("div",{class:"profile-labels",children:[i("span",{children:_t(_.agent)}),i("span",{children:_.context}),_.isDefault&&i("span",{children:"Default"})]}),_.description&&i("p",{class:"muted",children:_.description}),_.ownerName&&i("p",{class:"muted",children:[_.ownerName,_.ownerEmail?` · ${_.ownerEmail}`:""]}),i("a",{class:"profile-counts",href:je("agents",_.id),children:[i("span",{children:[d(_).length," projects"]}),i("span",{children:[p(_).length," missions"]}),i("span",{children:[f(_).length," tasks"]}),i("span",{children:[h(_).length," sessions ↗"]})]})]},_.id))})]})}function my({task:e,state:t,mutate:n}){const[o,r]=X(e.blocker?.reason||""),[s,a]=X(e.blocker?.nextStep||""),[c,u]=X(e.blocker?.owner||""),[l,h]=X(e.relatedTaskKeys||[]),[f,d]=X(!1),[p,m]=X(!1),_=Object.values(t.tasks).filter(y=>y.missionId===e.missionId&&y.id!==e.id),x=_.filter(y=>l.includes(y.key)||y.relatedTaskKeys?.includes(e.key));return i("section",{class:"panel",children:[i("h2",{children:e.status==="blocked"?"Blocker & related work":"Related work"}),x.length?i("div",{class:"related-links",children:x.map(y=>i("a",{href:je("tasks",y.id),children:[y.title,i("span",{children:[_t(y.updatedBy)," · ",y.status.replaceAll("_"," ")]})]}))}):i("p",{class:"muted",children:"Link related tasks from any agent working in this mission."}),i("form",{class:"workflow-form",onSubmit:async y=>{y.preventDefault(),d(!0);const S=await n("task-details",{taskId:e.id,relatedTaskKeys:l,...e.status==="blocked"?{blocker:o.trim()?{reason:o,nextStep:s,owner:c}:null}:{}});d(!1),m(S)},children:[e.status==="blocked"&&i(q,{children:[i("label",{children:["What is blocking this task?",i("textarea",{maxLength:500,value:o,onInput:y=>{r(y.currentTarget.value),m(!1)},placeholder:e.note||"Describe the blocker…"})]}),i("label",{children:["What needs to happen next?",i("textarea",{maxLength:500,value:s,onInput:y=>{a(y.currentTarget.value),m(!1)}})]}),i("label",{children:["Who can unblock it?",i("input",{maxLength:160,value:c,onInput:y=>{u(y.currentTarget.value),m(!1)}})]})]}),i("label",{children:["Related tasks",i("select",{multiple:!0,onChange:y=>{h(Array.from(y.currentTarget.selectedOptions).map(S=>S.value)),m(!1)},size:Math.min(5,Math.max(2,_.length)),children:_.map(y=>i("option",{value:y.key,selected:l.includes(y.key),children:[y.title," · ",_t(y.updatedBy)]}))})]}),i("p",{class:"muted",children:"Select related tasks; use ⌘ or Ctrl to select more than one. Shared project and mission keys link work across agents automatically."}),i("button",{class:"primary-button",disabled:f,children:f?"Saving…":"Save details"}),p&&i("span",{class:"saved-message",children:"Saved"})]})]})}function yy({state:e,mutate:t}){const n=[...Object.values(e.projects).filter(o=>o.archivedAt).map(o=>({...o,kind:"projects"})),...Object.values(e.missions).filter(o=>o.archivedAt).map(o=>({...o,kind:"missions"}))].sort((o,r)=>r.archivedAt.localeCompare(o.archivedAt));return i(q,{children:[i("div",{class:"view-heading",children:i("div",{children:[i("h1",{children:["Archive ",i("span",{class:"section-count",children:n.length})]}),i("p",{children:"Projects and missions hidden from the main views. Tasks and history are preserved."})]})}),i("div",{class:"panel archive-list",children:[n.map(o=>i("div",{children:[i("a",{href:je(o.kind,o.id),children:[i("strong",{children:o.name}),i("span",{children:[o.kind==="missions"?`Mission · ${e.projects[o.projectId]?.name||""}`:"Project"," · Archived ",new Date(o.archivedAt).toLocaleString()]}),o.kind==="missions"&&e.projects[o.projectId]?.archivedAt&&i("span",{children:"Restore the parent project to make this mission visible."})]}),i("button",{class:"secondary-button",onClick:()=>t("archive",{projectId:o.id,archived:!1}),children:"Restore"})]},o.id)),!n.length&&i("p",{class:"muted",children:"No archived projects or missions."})]})]})}function vy({preferences:e,setPreferences:t,resetFilters:n,agents:o,saveNotifications:r,testNotifications:s,notificationError:a,notificationSupported:c}){const[u,l]=X(""),h=async d=>{l("Saving…");try{await r({...e.notifications,...d}),l("Notification settings saved.")}catch(p){l(p.message)}},f=async()=>{l("Sending test alert…");try{await s(),l("Test alert sent.")}catch(d){l(d.message)}};return i(q,{children:[i("div",{class:"view-heading",children:i("div",{children:[i("h1",{children:"Preferences"}),i("p",{children:"Activity indicators, saved filters, and alerts."})]})}),i("section",{class:"panel settings-panel",children:[i("h2",{children:"Stale activity"}),i("label",{children:["Flag active work after no reported update for",i("select",{value:e.staleMinutes,onChange:d=>t({...e,staleMinutes:Number(d.currentTarget.value)}),children:[i("option",{value:0,children:"Off"}),i("option",{value:15,children:"15 minutes"}),i("option",{value:60,children:"1 hour"}),i("option",{value:240,children:"4 hours"}),i("option",{value:1440,children:"1 day"})]})]}),i("p",{class:"muted",children:"Stale describes reporting activity. It does not change a task's status."})]}),i("section",{class:"panel settings-panel",children:[i("h2",{children:"Saved filters"}),i("p",{class:"muted",children:"Project, mission, agent, profile, status, and search selections are remembered separately for each view on this device."}),i("button",{class:"secondary-button",onClick:()=>{n(),l("Saved filters reset.")},children:"Reset saved filters"})]}),i("section",{class:"panel settings-panel",children:[i("h2",{children:"System notifications"}),i("p",{class:"muted",children:"Angine sends alerts from this computer when an agent reports a task completed, blocked, or failed. The dashboard can be closed; Angine must still be running."}),c?i(q,{children:[i("button",{class:"secondary-button",onClick:()=>{h({enabled:!e.notifications.enabled})},children:e.notifications.enabled?"Disable notifications":"Enable notifications"}),e.notifications.enabled&&i("div",{class:"notification-options",children:[i("label",{class:"check-label",children:[i("input",{type:"checkbox",checked:e.notifications.completed,onChange:d=>{h({completed:d.currentTarget.checked})}}),"Task completed"]}),i("label",{class:"check-label",children:[i("input",{type:"checkbox",checked:e.notifications.attention,onChange:d=>{h({attention:d.currentTarget.checked})}}),"Needs attention (blocked or failed)"]}),i("label",{children:["Agent",i("select",{value:e.notifications.agent,onChange:d=>{h({agent:d.currentTarget.value})},children:[i("option",{value:"all",children:"All agents"}),o.map(d=>i("option",{value:d,children:_t(d)},d))]})]}),i("button",{class:"secondary-button",onClick:f,children:"Send test notification"})]})]}):i("p",{class:"muted",children:"Native alerts are currently supported on macOS and Linux."}),i("p",{class:"muted",role:"status",children:u||a})]})]})}function he({name:e,className:t=""}){const n={overview:i(q,{children:[i("rect",{x:"3",y:"4",width:"7",height:"7",rx:"2"}),i("path",{d:"M14 4h7M14 8h5M3 16h18M3 20h12"}),i("circle",{class:"icon-node",cx:"20",cy:"20",r:"1"})]}),projects:i(q,{children:[i("path",{d:"M3 8V6a2 2 0 0 1 2-2h5l3 4h6a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8Z"}),i("path",{d:"M7 12v5h9"}),i("circle",{class:"icon-node",cx:"16",cy:"12",r:"1.5"}),i("path",{d:"M16 14v3"})]}),missions:i(q,{children:[i("circle",{cx:"6",cy:"5",r:"2"}),i("path",{d:"M6 7v10h10M6 11h10"}),i("circle",{class:"icon-node",cx:"18",cy:"11",r:"2"}),i("circle",{cx:"18",cy:"17",r:"2"})]}),tasks:i(q,{children:[i("rect",{x:"4",y:"3",width:"16",height:"18",rx:"3"}),i("path",{d:"m8 9 2 2 5-5M8 16h5"}),i("circle",{class:"icon-node",cx:"17",cy:"16",r:"1"})]}),board:i(q,{children:[i("rect",{x:"3",y:"4",width:"18",height:"16",rx:"3"}),i("path",{d:"M9 4v16M15 4v16M5.5 8h1M11.5 12h1M17.5 8h1"})]}),tree:i(q,{children:[i("rect",{x:"9",y:"2",width:"6",height:"5",rx:"1.5"}),i("path",{d:"M12 7v5M5 16v-4h14v4"}),i("rect",{x:"2",y:"16",width:"6",height:"5",rx:"1.5"}),i("rect",{x:"16",y:"16",width:"6",height:"5",rx:"1.5"})]}),insights:i(q,{children:[i("path",{d:"M3 4v16h18M7 15v-4M12 15V7M17 15v-6"}),i("circle",{class:"icon-node",cx:"17",cy:"5",r:"1.5"})]}),agents:i(q,{children:[i("circle",{cx:"12",cy:"8",r:"4"}),i("path",{d:"M5 21v-2a7 7 0 0 1 14 0v2M3 6v5M21 6v5M9 8h.01M15 8h.01"}),i("path",{class:"icon-signal",d:"M10 17h4"})]}),archive:i(q,{children:[i("rect",{x:"3",y:"3",width:"18",height:"5",rx:"1.5"}),i("path",{d:"M5 8v11a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8M9 12h6M12 12v4"})]}),settings:i(q,{children:[i("path",{d:"M4 7h16M4 17h16"}),i("circle",{cx:"9",cy:"7",r:"3",fill:"var(--field-surface,white)"}),i("circle",{cx:"15",cy:"17",r:"3",fill:"var(--field-surface,white)"})]}),attention:i(q,{children:[i("path",{d:"M12 3 2 20h20L12 3ZM12 9v5"}),i("circle",{class:"icon-node",cx:"12",cy:"17",r:".8"})]}),arrow:i(q,{children:i("path",{d:"M5 18 18 5M7 5h11v11"})}),check:i(q,{children:[i("circle",{cx:"12",cy:"12",r:"9"}),i("path",{class:"icon-check",d:"m7.5 12 3 3 6-6"})]}),search:i(q,{children:[i("circle",{cx:"10",cy:"10",r:"6.5"}),i("path",{d:"m15 15 6 6"})]}),signal:i(q,{children:[i("circle",{class:"icon-node",cx:"5",cy:"12",r:"2"}),i("path",{d:"M9 12h4M15 6a8 8 0 0 1 0 12M19 3a12 12 0 0 1 0 18"})]})};return i("svg",{class:`work-icon ${t}`,width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:n[e]})}function si({seed:e}){const t=[...e].reduce((n,o)=>n+o.charCodeAt(0),0);return i("svg",{class:"project-glyph",width:"28",height:"28",viewBox:"0 0 32 32",fill:"none",stroke:"currentColor","stroke-width":"1.6","stroke-linecap":"round","aria-hidden":"true",children:[i("path",{d:t%2?"M8 7v18M8 16h16M24 7v18":"M8 8h16M16 8v16M8 24h16"}),i("circle",{cx:t%2?8:16,cy:"8",r:"3",fill:"currentColor",stroke:"none"}),i("rect",{x:t%3?20:5,y:"21",width:"6",height:"6",rx:t%3?1.5:3,fill:"currentColor",stroke:"none"}),i("circle",{cx:"24",cy:"8",r:"2.5"})]})}function El({seq:e,projectIds:t,agent:n="all",profile:o="all",compact:r=!1}){const[s,a]=X(14),[c,u]=X(),[l,h]=X(""),[f,d]=X(0),[p,m]=X(),_=[...t].sort().join(","),x=new Date().toLocaleDateString(),y=`${_}:${n}:${o}:${s}:${x}`;ne(()=>{const b=new AbortController;h("");const E=new URLSearchParams({days:String(s),offset:String(new Date().getTimezoneOffset()),projects:_});return n!=="all"&&E.set("agent",n),o!=="all"&&E.set("profile",o),E.set("timezone",Intl.DateTimeFormat().resolvedOptions().timeZone),fetch(`/api/insights?${E}`,{signal:b.signal}).then(async A=>{if(!A.ok)throw new Error(A.status===404?"Restart Angine to load activity charts.":"Activity history is unavailable.");return A.json()}).then(A=>{b.signal.aborted||u({key:y,data:A})}).catch(A=>{b.signal.aborted||h(A.message||"Activity history is unavailable.")}),()=>b.abort()},[e,_,n,o,s,x,f]);const S=c?.key===y?c.data:void 0,g=Math.max(1,...S?.days.flatMap(b=>[b.started,b.completed])||[]),v=S?.days.find(b=>b.date===p),C=b=>new Date(b+"T12:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric"});return i("section",{class:`field-panel field-activity ${r?"compact":""}`,"aria-labelledby":"activity-chart-heading",children:[i("div",{class:"field-panel-heading",children:[i("div",{children:[i("h2",{id:"activity-chart-heading",children:"Work in motion"}),i("span",{children:"Agent-reported task transitions"})]}),i("label",{class:"chart-range",children:[i("span",{class:"visually-hidden",children:"Activity date range"}),i("select",{value:s,onChange:b=>{a(Number(b.currentTarget.value)),m(void 0)},children:[7,14,30,90].map(b=>i("option",{value:b,children:["Last ",b," days"]},b))})]})]}),l?i("div",{class:"field-chart-empty",role:"status",children:[i(he,{name:"signal"}),i("p",{children:l}),i("button",{class:"secondary-button",onClick:()=>d(b=>b+1),children:"Try again"})]}):S?i(q,{children:[!r&&i("div",{class:"insight-metrics",children:["started","completed","blocked","failed"].map(b=>i("div",{children:[i("span",{children:b==="completed"?"Completions":b==="started"?"Starts":b==="blocked"?"Blocked reports":"Failed reports"}),i("strong",{children:S.totals[b]})]},b))}),i("div",{class:"field-chart-legend",children:[i("span",{children:[i("i",{}),"Started"]}),i("span",{children:[i("i",{}),"Completed"]})]}),i("figure",{class:"field-chart-figure",children:[i("div",{class:"field-chart-wrap",children:[i("div",{class:"field-chart-axis","aria-hidden":"true",children:[i("span",{children:g}),i("span",{children:Math.round(g/2)}),i("span",{children:"0"})]}),i("div",{class:"field-chart-plot",style:{"--days":S.days.length},children:S.days.map((b,E)=>i("button",{type:"button",class:`field-chart-day ${p===b.date?"selected":""}`,onClick:()=>m(b.date),"aria-label":`${C(b.date)}: ${b.started} started, ${b.completed} completed, ${b.blocked} blocked, ${b.failed} failed`,"aria-pressed":p===b.date,children:[i("span",{class:"field-chart-bars",children:[i("i",{style:{height:`${b.started/g*100}%`}}),i("i",{style:{height:`${b.completed/g*100}%`}})]}),(E===0||E===S.days.length-1||E===Math.floor(S.days.length/2))&&i("span",{class:"field-chart-date",children:C(b.date)})]},b.date))})]}),i("figcaption",{children:[v?i("span",{children:[i("strong",{children:C(v.date)})," · ",v.started," started · ",v.completed," completed · ",v.blocked," blocked · ",v.failed," failed"]}):i("span",{children:S.totals.completed?i(q,{children:[i("strong",{children:[S.totals.completed," completions"]})," over ",s," days"]}):"No task completions reported in this period."}),i("span",{children:"Local time"})]})]}),i("details",{class:"field-chart-data",children:[i("summary",{children:"View daily numbers"}),i("div",{class:"field-table-scroll",tabIndex:0,role:"region","aria-label":"Daily task transitions",children:i("table",{children:[i("caption",{children:["Task status transitions · last ",s," days"]}),i("thead",{children:i("tr",{children:[i("th",{scope:"col",children:"Day"}),i("th",{scope:"col",children:"Started"}),i("th",{scope:"col",children:"Completed"}),i("th",{scope:"col",children:"Blocked"}),i("th",{scope:"col",children:"Failed"})]})}),i("tbody",{children:S.days.map(b=>i("tr",{children:[i("th",{scope:"row",children:C(b.date)}),i("td",{children:b.started}),i("td",{children:b.completed}),i("td",{children:b.blocked}),i("td",{children:b.failed})]},b.date))})]})})]}),!r&&i("div",{class:"field-agent-totals",children:[i("h3",{children:"Completions by reporting agent"}),S.agents.length?S.agents.map(b=>i("div",{children:[i("span",{children:b.agent}),i("div",{class:"field-mini-track",children:i("span",{style:{transform:`scaleX(${b.completed/Math.max(1,...S.agents.map(E=>E.completed))})`}})}),i("strong",{children:b.completed})]},b.agent)):i("p",{children:"No completions reported."}),i("p",{children:"Counts reflect reported transitions, including completed tasks reopened and completed again."})]})]}):i("div",{class:"field-chart-empty",children:i("span",{children:"Loading activity history…"})})]})}function _y({state:e}){const[t,n]=X("all"),[o,r]=X("all"),s=Object.values(e.projects).filter(u=>!u.archivedAt),a=[...new Set(Object.values(e.tasks).map(u=>u.updatedBy))].sort(),c=s.filter(u=>t==="all"||u.id===t).map(u=>u.id);return i("div",{class:"field-insights",children:[i("div",{class:"field-page-heading",children:[i("div",{children:[i("span",{class:"field-eyebrow",children:"Workspace / Insights"}),i("h1",{children:"Work, day by day."})]}),i("div",{class:"field-insight-filters",children:[i("label",{children:[i("span",{children:"Project"}),i("select",{value:t,onChange:u=>n(u.currentTarget.value),children:[i("option",{value:"all",children:"All projects"}),s.map(u=>i("option",{value:u.id,children:u.name},u.id))]})]}),i("label",{children:[i("span",{children:"Agent"}),i("select",{value:o,onChange:u=>r(u.currentTarget.value),children:[i("option",{value:"all",children:"All agents"}),a.map(u=>i("option",{children:u},u))]})]})]})]}),i(El,{seq:e.seq,projectIds:c,agent:o}),i("p",{class:"field-footnote",children:"Based on recorded task history. Archived work is excluded. Counts describe reports, not independently verified outcomes or hours worked."})]})}const We=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`,Nl=e=>{const t=Math.max(0,Math.floor((Date.now()-Date.parse(e))/6e4));return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:`${Math.floor(t/1440)}d ago`},kr=e=>({claude:"Claude",codex:"Codex",grok:"Grok",antigravity:"Antigravity",external:"External"})[e]||e;function wy({project:e,state:t,tasks:n,attention:o,fresh:r}){const s=Object.values(t.missions).filter(p=>p.projectId===e.id&&!p.archivedAt),a=s.filter(p=>p.status==="running").length,c=n.filter(p=>p.status!=="cancelled"),u=c.filter(p=>p.status==="completed").length,l=c.length?Math.round(u/c.length*100):void 0,h=[...new Set(n.map(p=>Vt(t,p)?.name||kr(p.updatedBy)))],f=[...n].sort((p,m)=>m.updatedAt.localeCompare(p.updatedAt))[0],d=pn(t,e.id);return i("article",{class:`field-project ${r?"has-new-report":""}`,style:{"--project-color":d},children:[i("a",{class:"field-project-main",href:We("projects",e.id),children:[i("div",{class:"field-project-top",children:[i("span",{class:"field-project-glyph",children:i(si,{seed:e.id})}),i("span",{class:`field-project-status ${a?"running":""}`,children:[i("i",{}),a?`${a} running`:c.length&&u===c.length?"All complete":"No running missions"]}),i(he,{name:"arrow",className:"field-project-arrow"})]}),i("h3",{children:e.name}),i("p",{children:e.description||`${s.length} ${s.length===1?"mission":"missions"} · ${n.length} tasks`}),i("div",{class:"field-progress-meta",children:[i("span",{children:c.length?`${u} of ${c.length} tasks complete`:"No tasks reported"}),i("strong",{children:l==null?"—":`${l}%`})]}),i("div",{class:"field-progress-track",role:l==null?void 0:"progressbar","aria-label":`${e.name} tasks completed`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":l,children:i("span",{style:{transform:`scaleX(${(l||0)/100})`}})}),i("div",{class:"field-project-bottom",children:[i("span",{children:[s.length," missions · ",Nl(f?.updatedAt||e.updatedAt)]}),i("span",{class:"field-avatars","aria-label":`Agents: ${h.join(", ")||"none reported"}`,children:[h.slice(0,3).map(p=>i("span",{title:p,children:p.slice(0,2)},p)),h.length>3&&i("span",{children:["+",h.length-3]})]})]}),o>0&&i("div",{class:"field-project-attention",children:[i(he,{name:"attention"}),i("span",{children:[o," ",o===1?"task needs":"tasks need"," attention"]}),i(he,{name:"arrow"})]})]}),i("details",{class:"field-mission-preview",children:[i("summary",{children:[i(he,{name:"missions"}),i("span",{children:"Explore missions"}),i("span",{class:"field-disclosure",children:"+"})]}),i("div",{class:"field-mission-content",children:[s.slice(0,4).map(p=>i("a",{href:We("missions",p.id),children:[i("span",{class:`field-mission-dot ${p.status}`}),i("span",{children:p.name}),i("small",{children:p.status==="running"?"Running":p.status==="completed"?"Done":p.status})]},p.id)),s.length>4&&i("a",{href:We("projects",e.id),children:["View all ",s.length," missions ",i(he,{name:"arrow"})]}),!s.length&&i("p",{children:"No missions reported yet."})]})]})]})}function xy({state:e,projects:t,tasks:n,health:o,staleMinutes:r,agent:s="all",profile:a="all"}){const[c,u]=X("all"),[l,h]=X([]),f=re();ne(()=>{const v=Object.fromEntries(t.map(b=>[b.id,n.filter(E=>E.projectId===b.id).map(E=>E.updatedAt).sort().at(-1)||""]));if(f.current){const b=Object.keys(v).filter(E=>v[E]&&f.current?.[E]!==void 0&&f.current[E]!==v[E]);h(b)}f.current=v;const C=setTimeout(()=>h([]),1600);return()=>clearTimeout(C)},[e.seq]);const d=new Set(t.map(v=>v.id)),p=n.filter(v=>d.has(v.projectId)&&(s==="all"||v.updatedBy===s)&&(a==="all"||Vt(e,v)?.id===a)),m=bl(e,p,o,r),_=v=>m.filter(C=>C.task.projectId===v).length,x=v=>Object.values(e.missions).filter(C=>C.projectId===v&&!C.archivedAt&&C.status==="running").length,y=t.filter(v=>c==="all"||c==="running"&&x(v.id)>0||c==="attention"&&_(v.id)>0),S=new Map;for(const v of p.filter(C=>["todo","in_progress","blocked","failed"].includes(C.status))){const C=Vt(e,v),b=C?.id||v.updatedBy,E=S.get(b)||{id:C?.id||"",name:C?.name||kr(v.updatedBy),tasks:[]};E.tasks.push(v),S.set(b,E)}const g=[...p].sort((v,C)=>C.updatedAt.localeCompare(v.updatedAt)).slice(0,3);return i("div",{class:"field-overview",children:[i("div",{class:"field-page-heading",children:[i("div",{children:[i("span",{class:"field-eyebrow",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),i("h1",{children:"Your work, in view."})]}),i("a",{class:"field-insights-link",href:We("insights"),children:[i(he,{name:"insights"}),"Explore insights",i(he,{name:"arrow"})]})]}),i("section",{class:"field-metrics","aria-label":"Workspace summary",children:[["Projects",t.length,"In this view","projects"],["Running missions",t.reduce((v,C)=>v+x(C.id),0),"Latest reported status","missions"],["Tasks in progress",p.filter(v=>v.status==="in_progress").length,"Reported by agents","tasks"],["Needs attention",m.length,"Blocked, failed, or quiet","attention"]].map(([v,C,b,E])=>i("div",{children:[i("span",{class:"field-metric-label",children:[i(he,{name:E}),v]}),i("strong",{children:C}),i("span",{class:"field-metric-foot",children:b})]},String(v)))}),i("div",{class:"field-home-grid",children:[i("div",{class:"field-home-main",children:[i("section",{"aria-labelledby":"field-projects-heading",children:[i("div",{class:"field-section-heading",children:[i("h2",{id:"field-projects-heading",children:["Your projects ",i("span",{children:y.length})]}),i("div",{class:"field-segmented",role:"group","aria-label":"Filter overview projects",children:["all","running","attention"].map(v=>i("button",{type:"button","aria-pressed":c===v,onClick:()=>u(v),children:v==="all"?"All":v==="running"?"In progress":"Attention"},v))})]}),i("div",{class:"field-project-scroll",tabIndex:y.length>6?0:void 0,role:y.length>6?"region":void 0,"aria-label":"Projects",children:i("div",{class:"field-project-grid",children:[y.map(v=>i(wy,{project:v,state:e,tasks:p.filter(C=>C.projectId===v.id),attention:_(v.id),fresh:l.includes(v.id)},v.id)),!y.length&&i("div",{class:"field-empty",children:[i(si,{seed:"angine"}),i("h3",{children:t.length?"No projects in this view.":"Your next project starts here."}),i("p",{children:t.length?"Choose a different project filter.":"Connect an agent and ask it to report its work."}),i("a",{href:We("agents"),children:["View agent connections ",i(he,{name:"arrow"})]})]})]})})]}),i(El,{compact:!0,seq:e.seq,projectIds:[...d],agent:s,profile:a})]}),i("aside",{class:"field-home-aside",children:[i("section",{class:"field-panel field-attention",children:[i("div",{class:"field-panel-heading",children:[i("h2",{children:"Needs your attention"}),i("span",{class:"field-count",children:m.length})]}),m.length?i("div",{class:"field-attention-list",children:m.slice(0,5).map(({task:v,reason:C})=>i("a",{href:We("tasks",v.id),children:[i(he,{name:"attention"}),i("div",{children:[i("strong",{children:v.title}),i("span",{children:[e.projects[v.projectId]?.name," / ",e.missions[v.missionId]?.name]}),i("small",{children:C})]}),i(he,{name:"arrow"})]},v.id))}):i("div",{class:"field-all-clear",children:[i(he,{name:"check"}),i("strong",{children:"Room to focus."}),i("span",{children:"No tasks need attention in this view."})]}),m.length>5&&i("a",{class:"field-panel-link",href:We("tasks"),children:["Review all ",m.length," tasks",i(he,{name:"arrow"})]})]}),i("section",{class:"field-panel",children:[i("div",{class:"field-panel-heading",children:[i("h2",{children:"Reported open work"}),i("a",{href:We("agents"),"aria-label":"View agents",children:i(he,{name:"arrow"})})]}),[...S.values()].sort((v,C)=>C.tasks.length-v.tasks.length).slice(0,4).map(v=>i("a",{class:"field-agent-row",href:We("agents",v.id||void 0),children:[i("span",{class:"field-agent-glyph",children:i(he,{name:"agents"})}),i("span",{children:[i("strong",{children:v.name}),i("small",{children:[v.tasks.filter(C=>C.status==="in_progress").length," in progress · ",v.tasks.length," open"]})]})]},v.name)),!S.size&&i("p",{class:"field-empty-copy",children:"No open task reports."})]}),i("section",{class:"field-panel",children:[i("div",{class:"field-panel-heading",children:i("h2",{children:"Latest task reports"})}),g.map(v=>i("a",{class:"field-recent-row",href:We("tasks",v.id),children:[i(he,{name:v.status==="completed"?"check":"signal"}),i("span",{children:[i("strong",{children:v.title}),i("small",{children:[e.projects[v.projectId]?.name," · ",kr(v.updatedBy)," · ",Nl(v.updatedAt)]})]})]},v.id)),!g.length&&i("p",{class:"field-empty-copy",children:"No task reports yet."})]})]})]})]})}function by(e){const t=new Map;for(const n of e){if(n.phase!=="monitoring")continue;const o=JSON.stringify([n.projectId,n.missionId||null]),r=t.get(o);(!r||n.reportedAt>=r.reportedAt)&&t.set(o,n)}return[...t.values()].sort((n,o)=>o.reportedAt.localeCompare(n.reportedAt))}function Il(e,t){return by(t).filter(n=>n.status!=="completed"&&!e.projects[n.projectId]?.archivedAt&&(!n.missionId||!e.missions[n.missionId]?.archivedAt))}function Cr({updates:e,state:t,onHide:n,history:o=!1}){const r=o?e:Il(t,e);return r.length?i("section",{class:"monitoring-panel","aria-label":o?"Monitoring history":"Active monitoring",children:[i("div",{class:"monitoring-heading",children:[i(he,{name:"signal"}),i("div",{children:[i("h2",{children:o?"Monitoring history":"Monitoring"}),i("span",{children:[r.length," ",o?"reported checks":"active checks"]})]}),i("div",{class:"monitoring-actions",children:[!o&&i("a",{href:"#/monitoring",children:["View monitoring ",i(he,{name:"arrow"})]}),n&&i("button",{class:"text-button",type:"button",onClick:n,children:"Hide monitoring"})]})]}),i("div",{class:"monitoring-list",children:r.map(s=>{const a=s.missionId?t.missions[s.missionId]:void 0;return i("a",{class:"monitoring-row",href:`#/${a?"missions":"projects"}/${encodeURIComponent(a?.id||s.projectId)}`,children:[i("span",{class:"monitoring-copy",children:[i("span",{class:"monitoring-location",children:[t.projects[s.projectId]?.name||"Project",a?` / ${a.name}`:""]}),i("strong",{children:s.summary}),s.nextStep&&i("span",{class:"monitoring-next",children:["Next: ",s.nextStep]}),i("span",{class:"monitoring-byline",children:[_t(s.updatedBy)," · ",i("time",{dateTime:s.reportedAt,children:new Date(s.reportedAt).toLocaleString()})]})]}),i("span",{class:"monitoring-state",children:[i("span",{class:`badge ${s.status}`,children:{in_progress:"In progress",completed:"Completed",blocked:"Blocked",failed:"Failed"}[s.status]}),s.environment&&i("span",{class:"monitoring-environment",children:s.environment})]}),i(he,{name:"arrow"})]},s.id)})})]}):null}function Sy({state:e,showOnDashboard:t,setShowOnDashboard:n}){const[o,r]=X("active"),[s,a]=X([]),[c,u]=X(!0),[l,h]=X(""),[f,d]=X(0),[p,m]=X("all"),_=Object.keys(e.projects).sort().join(",");ne(()=>{const S=new AbortController;return u(!0),h(""),Promise.all(_.split(",").filter(Boolean).map(async g=>{const v=await fetch(`/api/projects/${encodeURIComponent(g)}/events`,{signal:S.signal});if(!v.ok)throw new Error("Monitoring history could not be loaded.");return(await v.json()).filter(b=>b.type==="work.update_reported"&&b.payload.phase==="monitoring").map(b=>{const E=b.payload;return{...E,projectId:e.projectAliases?.[E.projectId]||E.projectId}})})).then(g=>{if(S.signal.aborted)return;const v=new Map(g.flat().map(C=>[C.id,C]));a([...v.values()].sort((C,b)=>b.reportedAt.localeCompare(C.reportedAt)))}).catch(g=>{S.signal.aborted||h(g.message)}).finally(()=>{S.signal.aborted||u(!1)}),()=>S.abort()},[e.seq,_,f]);const x=Il(e,s),y=(o==="active"?x:s).filter(S=>p==="all"||S.projectId===p);return i("div",{class:"monitoring-page",children:[i("div",{class:"field-page-heading",children:[i("div",{children:[i("span",{class:"field-eyebrow",children:"Workspace"}),i("h1",{children:"Monitoring"})]}),i("label",{class:"monitoring-visibility",children:[i("input",{type:"checkbox",checked:t,onChange:S=>n(S.currentTarget.checked)}),"Show monitoring on dashboard"]})]}),i("div",{class:"monitoring-toolbar",children:[i("div",{class:"field-segmented",role:"group","aria-label":"Monitoring view",children:[i("button",{type:"button","aria-pressed":o==="active",onClick:()=>r("active"),children:["Active ",!c&&!l&&x.length]}),i("button",{type:"button","aria-pressed":o==="history",onClick:()=>r("history"),children:["History ",!c&&!l&&s.length]})]}),i("label",{children:["Project",i("select",{value:p,onChange:S=>m(S.currentTarget.value),children:[i("option",{value:"all",children:"All projects"}),Object.values(e.projects).map(S=>i("option",{value:S.id,children:[S.name,S.archivedAt?" (archived)":""]},S.id))]})]})]}),l?i("div",{class:"field-panel",role:"status",children:[i("p",{children:l}),i("button",{class:"secondary-button",onClick:()=>d(S=>S+1),children:"Try again"})]}):c?i("div",{class:"field-panel",children:i("p",{children:"Loading monitoring history…"})}):y.length?i(Cr,{state:e,updates:y,history:o==="history"}):i("div",{class:"field-empty",children:[i(he,{name:o==="active"?"check":"signal"}),i("h3",{children:o==="active"?"No active monitoring.":"No monitoring history yet."}),i("p",{children:o==="active"?"Completed checks remain in History.":"Agent-reported monitoring checks appear here."})]})]})}const Xe={todo:"To do",in_progress:"In progress",blocked:"Blocked",completed:"Completed",failed:"Failed",cancelled:"Cancelled",planned:"Planned",running:"Running",active:"Active"},Er={request:"Request",implementation:"Implementation",deployment:"Deployment",monitoring:"Monitoring",blocker:"Blocker"},Pe=e=>e?.trim()||"external",ft=e=>({codex:"Codex",claude:"Claude",antigravity:"Antigravity",grok:"Grok",external:"External"})[Pe(e)]||Pe(e),At=e=>{const t=Math.max(0,Math.floor((Date.now()-Date.parse(e))/6e4));return t<1?"Just now":t<60?`${t}m ago`:t<1440?`${Math.floor(t/60)}h ago`:`${Math.floor(t/1440)}d ago`},tr=e=>e.status==="completed"?100:e.status==="todo"?0:e.progress,Se=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`;function Gn({status:e}){return i("span",{class:`badge ${e}`,children:[i("span",{class:"status-dot"}),Xe[e]||e]})}function ky({update:e,state:t}){if(e.phase==="monitoring")return null;const n=e.missionId?t.missions[e.missionId]:void 0;return i("section",{class:"panel work-update-card",children:[i("div",{class:"panel-heading",children:[i("h2",{children:"Latest agent update"}),i(Gn,{status:e.status})]}),i("div",{class:"work-update-meta",children:[i("strong",{children:Er[e.phase]||e.phase}),i("span",{children:[ft(e.updatedBy)," · ",At(e.reportedAt),e.environment?` · ${e.environment}`:""]}),n&&i("a",{href:Se("missions",n.id),children:n.name})]}),i("p",{children:e.summary}),e.nextStep&&i("div",{class:"work-update-next",children:[i("strong",{children:"Next"}),i("span",{children:e.nextStep})]}),i("small",{children:"Agent reported · Angine does not independently verify deployments or production health."})]})}function Vn({value:e,caption:t="Progress"}){return i("div",{class:"progress",children:[i("div",{class:"progress-label",children:[i("span",{children:t}),i("strong",{children:e==null?"Not reported":`${Math.round(e)}%`})]}),i("div",{class:`track ${e==null?"unknown":""}`,role:e==null?void 0:"progressbar","aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e,children:e!=null&&i("span",{style:{width:`${e}%`}})})]})}function Cy({session:e,state:t,health:n}){const o=Io(t,e);return i("div",{class:"reporter",children:[i("div",{class:"reporter-title",children:[i("span",{class:"avatar",children:ft(e.agent).slice(0,1)}),i("div",{children:[i("strong",{children:o?.name||ft(e.agent)}),i("span",{children:[e.agentId||"Reporter"," · ",At(e.lastSeenAt)]})]})]}),i("dl",{children:[o&&i(q,{children:[i("dt",{children:"Profile"}),i("dd",{children:i("a",{href:Se("agents",o.id),children:o.name})})]}),o?.ownerName&&i(q,{children:[i("dt",{children:"Owner"}),i("dd",{children:[o.ownerName,o.ownerEmail?` · ${o.ownerEmail}`:""]})]}),i("dt",{children:"Worktree / workspace"}),i("dd",{children:[t.workspaces[e.workspaceId]?.path,t.workspaces[e.workspaceId]?.branch&&i("span",{children:[" · ",t.workspaces[e.workspaceId].branch]})]}),i("dt",{children:"Angine session"}),i("dd",{children:e.id}),e.sourceSessionId&&i(q,{children:[i("dt",{children:"Agent session"}),i("dd",{children:e.sourceSessionId})]}),e.parentAgentId&&i(q,{children:[i("dt",{children:"Parent agent"}),i("dd",{children:e.parentAgentId})]}),e.accountLabel&&i(q,{children:[i("dt",{children:"Account"}),i("dd",{children:e.accountLabel})]})]}),i(ay,{health:n,session:e})]})}function Ws({status:e,items:t,kind:n,limit:o,row:r}){const s=re(null),[a,c]=X(),u=t.length>o;return it(()=>{const l=s.current;if(!l||!u){c(void 0);return}const h=Array.from(l.children).slice(0,o),f=()=>c(Math.ceil(h.reduce((p,m)=>p+m.getBoundingClientRect().height,0)));f();const d=new ResizeObserver(f);return d.observe(l),h.forEach(p=>d.observe(p)),()=>d.disconnect()},[t,o,u]),i("section",{class:"project-status-section","aria-labelledby":`${n}-${e}`,children:[i("div",{class:"status-section-heading",children:[i("h2",{id:`${n}-${e}`,children:[i("span",{class:`section-status-dot ${e}`}),Xe[e],i("span",{class:"section-count",children:t.length})]}),i("span",{children:u?`Latest ${o} shown · Scroll for ${t.length-o} more`:"Newest updates first"})]}),i("div",{class:"project-list panel",children:[i("div",{class:n==="tasks"?"task-list-head":"project-list-head","aria-hidden":"true",children:[i("span",{children:n==="tasks"?"Task":n==="missions"?"Mission":"Project"}),i("span",{children:"Status"}),i("span",{children:"Progress"}),n!=="tasks"&&i("span",{children:"Agent"}),i("span",{children:"Updated"}),i("span",{})]}),i("div",{class:`project-scroll ${u?"has-overflow":""}`,ref:s,style:u&&a?{maxHeight:`${a}px`}:void 0,tabIndex:u?0:void 0,role:u?"region":void 0,"aria-label":u?`${Xe[e]} ${n}, scroll to see all ${t.length}`:void 0,children:t.length?t.map(r):i("div",{class:"status-section-empty",children:["No ",Xe[e].toLowerCase()," ",n," in this view."]})})]})]})}function Ey(){const[e,t]=X(null),[n,o]=X(location.hash.slice(1)||"/projects"),[r="projects",s]=n.split("/").filter(Boolean);let a="";try{a=decodeURIComponent(s||"")}catch{}const{filters:c,set:u,reset:l,resetAll:h}=uy(r),{agent:f,status:d,project:p,mission:m,profile:_,query:x,staleOnly:y}=c,{preferences:S,setPreferences:g,saveNotifications:v,testNotifications:C,notificationError:b,notificationSupported:E}=hy(),{health:A,compatibility:P}=iy(),[L,D]=X(""),[V,N]=X([]),[k,I]=X(!1),M=re(null),[$,O]=X(),[,j]=X(0),B=w=>t(T=>T&&T.seq>w.seq?T:ty(w)),z=async(w,T)=>{D("");try{return B(await Sr(w,T)),!0}catch(ae){return D(ae.message),!1}};ne(()=>{const w=()=>{o(location.hash.slice(1)||"/projects"),window.scrollTo(0,0)};return window.addEventListener("hashchange",w),()=>window.removeEventListener("hashchange",w)},[]),ne(()=>{fetch("/api/state").then(ae=>{if(!ae.ok)throw new Error;return ae.json()}).then(B).catch(()=>I(!1));const w=new EventSource("/api/events");w.addEventListener("state",ae=>{B(JSON.parse(ae.data)),I(!0)}),w.onerror=()=>I(!1);const T=setInterval(()=>j(ae=>ae+1),3e4);return()=>{w.close(),clearInterval(T)}},[]),it(()=>{const w=M.current;if(r!=="board"||!w)return;const T=()=>O(Math.max(260,window.innerHeight-w.getBoundingClientRect().top-24));T();const ae=new ResizeObserver(T);return w.parentElement&&ae.observe(w.parentElement),window.addEventListener("resize",T),()=>{ae.disconnect(),window.removeEventListener("resize",T)}},[r,!!e]);const R=r==="tasks"&&a?e?.tasks[a]:void 0,F=R?e?.missions[R.missionId]:(r==="missions"||r==="projects")&&a?e?.missions[a]:void 0;R&&(e?.sessions[R.updatedBySessionId||""]?.workspaceId||F?.workspaceId);const U=F?e?.projects[F.projectId]:r==="projects"&&a?e?.projects[e?.projectAliases?.[a]||a]:void 0,K=F?`missions/${encodeURIComponent(F.id)}`:U?`projects/${encodeURIComponent(U.id)}`:"";ne(()=>{if(N([]),!K)return;let w=!0;return fetch(`/api/${K}/events`).then(T=>{if(!T.ok)throw new Error;return T.json()}).then(T=>{w&&N(T)}).catch(()=>{}),()=>{w=!1}},[K,e?.seq]);const ie=w=>w.sort((T,ae)=>ae.updatedAt.localeCompare(T.updatedAt)),Z=ie(Object.values(e?.tasks||{})),H=ie(Object.values(e?.missions||{})),Y=ie(Object.values(e?.projects||{})).filter(w=>!w.archivedAt),te=H.filter(w=>!w.archivedAt&&!e?.projects[w.projectId]?.archivedAt),Q=Z.filter(w=>e?.missions[w.missionId]&&!wl(e,w)),W=Object.values(e?.sessions||{}),ee=[...new Set([...W.map(w=>Pe(w.agent)),...Q.map(w=>Pe(w.updatedBy))])].sort(),se=w=>[...new Set([...w.workspaceIds||[w.workspaceId],...W.filter(T=>T.missionId===w.id||T.missionIds?.includes(w.id)).map(T=>T.workspaceId)])].map(T=>e?.workspaces[T]).filter(Boolean),J=w=>Z.filter(T=>T.missionId===w),ce=w=>te.filter(T=>T.projectId===w),ye=w=>Q.filter(T=>T.projectId===w),Ee=w=>[...new Set([...J(w).map(T=>Pe(T.updatedBy)),...W.filter(T=>T.missionId===w||T.missionIds?.includes(w)).map(T=>Pe(T.agent)),...e?.missions[w]?.latestUpdate?[Pe(e.missions[w].latestUpdate?.updatedBy)]:[]])],$e=w=>[...new Set([...Z.filter(T=>T.projectId===w).map(T=>Pe(T.updatedBy)),...W.filter(T=>T.projectId===w||T.projectIds?.includes(w)).map(T=>Pe(T.agent)),...e?.projects[w]?.latestUpdate?[Pe(e.projects[w].latestUpdate?.updatedBy)]:[]])],Ne=(w,T)=>[...new Set([...w.map(ae=>e?Vt(e,ae)?.id:void 0),...T.map(ae=>e?Io(e,ae)?.id:void 0)])],Te=w=>Ne(Z.filter(T=>T.projectId===w),W.filter(T=>T.projectId===w||T.projectIds?.includes(w))),at=w=>Ne(J(w),W.filter(T=>T.missionId===w||T.missionIds?.includes(w))),De=Y.filter(w=>(f==="all"||$e(w.id).includes(f))&&(_==="all"||Te(w.id).includes(_))),Ue=te.filter(w=>(p==="all"||w.projectId===p)&&(f==="all"||Ee(w.id).includes(f))&&(_==="all"||at(w.id).includes(_)));ne(()=>{if(e){if(e.projectAliases?.[p]){u({project:e.projectAliases[p]});return}if(e.missions[p]){u({project:e.missions[p].projectId,mission:p});return}if(p!=="all"&&!De.some(w=>w.id===p)){u({project:"all",mission:"all"});return}m!=="all"&&!Ue.some(w=>w.id===m)&&u({mission:"all"}),r==="projects"&&!["all","active"].includes(d)&&u({status:"all"})}},[e,r,f,_,p,m,d]);const _e=(...w)=>w.join(" ").toLowerCase().includes(x.toLowerCase().trim()),be=te.filter(w=>(p==="all"||w.projectId===p)&&(m==="all"||w.id===m)&&(f==="all"||Ee(w.id).includes(f))&&(_==="all"||at(w.id).includes(_))&&(!y||on(w,S.staleMinutes))&&(r!=="missions"||d==="all"||w.status===d)&&_e(w.name,w.description,e?.projects[w.projectId]?.name)),we=De.filter(w=>(p==="all"||w.id===p)&&(!y||ce(w.id).some(T=>on(T,S.staleMinutes)))&&(_e(w.name,w.description,e?.workspaces[w.workspaceId]?.path)||ce(w.id).some(T=>_e(T.name,T.description)))),xe=Q.filter(w=>(p==="all"||w.projectId===p)&&(m==="all"||w.missionId===m)&&(f==="all"||Pe(w.updatedBy)===f)&&(_==="all"||e&&Vt(e,w)?.id===_)&&(!y||on(w,S.staleMinutes))&&(d==="all"||w.status===d)&&_e(w.title,w.note,e?.missions[w.missionId]?.name,e?.projects[w.projectId]?.name)),Ut=r==="projects"?Q.filter(w=>we.some(T=>T.id===w.projectId)):r==="missions"?Q.filter(w=>be.some(T=>T.id===w.missionId)):xe,Wt=[...we.map(w=>w.latestMonitoring),...be.map(w=>w.latestMonitoring)].filter(w=>!!w&&w.phase==="monitoring"&&(f==="all"||Pe(w.updatedBy)===f)).filter((w,T,ae)=>ae.findIndex(Qe=>Qe.id===w.id)===T).sort((w,T)=>T.reportedAt.localeCompare(w.reportedAt)),kn=w=>{const T=w.filter(ae=>ae.status!=="cancelled");return T.length?Math.round(T.filter(ae=>ae.status==="completed").length/T.length*100):0},Mo=w=>u({agent:w,...w!=="all"&&_!=="all"&&e?.profiles[_]?.agent!==w?{profile:"all"}:{}}),Yt=w=>i("a",{class:"task-row",style:zn(e,w.projectId,w.missionId),href:Se("tasks",w.id),children:[i("div",{class:"task-row-main",children:[i("span",{class:`task-status ${w.status}`}),i("div",{children:[i("strong",{children:w.title}),i("span",{children:[e?.projects[w.projectId]?.name," / ",e?.missions[w.missionId]?.name," · ",ft(w.updatedBy)," ",i(Bn,{item:w,minutes:S.staleMinutes})]})]})]}),i(Gn,{status:w.status}),i(Vn,{value:tr(w)}),i("span",{class:"row-time",children:At(w.updatedAt)}),i("span",{class:"row-arrow",children:"↗"})]},w.id),Ao=w=>i("a",{class:"project-row",style:zn(e,w.projectId,w.id),href:Se("missions",w.id),children:[i("div",{class:"project-row-main",children:[i("strong",{children:[w.name," ",i(Bn,{item:w,minutes:S.staleMinutes})]}),i("span",{children:[e?.projects[w.projectId]?.name,se(w).some(T=>T?.branch)?` · ${[...new Set(se(w).map(T=>T?.branch).filter(Boolean))].join(" · ")}`:""]}),w.latestUpdate&&i("p",{class:"work-update-line",children:["Latest ",Er[w.latestUpdate.phase]||w.latestUpdate.phase," · ",w.latestUpdate.summary]}),w.description&&i("p",{children:w.description})]}),i(Gn,{status:w.status}),i(Vn,{value:kn(J(w.id)),caption:`${J(w.id).filter(T=>T.status==="completed").length} / ${J(w.id).filter(T=>T.status!=="cancelled").length} tasks`}),i("span",{class:"project-row-agents",children:Ee(w.id).map(ft).join(" · ")||w.latestUpdate?.updatedBy||"External"}),i("span",{class:"row-time",children:At(w.updatedAt)}),i("span",{class:"row-arrow",children:"↗"})]},w.id),Cn=(w,T="all")=>i("div",{class:"project-sections",children:["running","planned","blocked","completed","failed","cancelled"].filter(ae=>(T==="all"||T===ae)&&(!["planned","blocked"].includes(ae)||w.some(Qe=>Qe.status===ae)||T===ae)).map(ae=>i(Ws,{status:ae,kind:"missions",items:w.filter(Qe=>Qe.status===ae),limit:ae==="running"?10:5,row:Ao},ae))}),$o=w=>i("div",{class:"activity",children:w.length?w.slice(-40).reverse().map(T=>i("div",{children:[i("span",{class:"activity-dot"}),i("div",{children:[i("strong",{children:T.type==="work.update_reported"?`${Er[String(T.payload.phase)]||"Work"} · ${Xe[String(T.payload.status)]||"Updated"}`:T.type.startsWith("task.")?T.type==="task.removed"?"Task removed":`${T.type==="task.created"?"Created · ":""}${Xe[String(T.payload.status)]||"Updated"}`:T.type.replace(T.type.startsWith("project.")&&T.payload.status!=="active"?"project.":"never.","mission.").replaceAll("."," ")}),(T.payload.summary||T.payload.note)&&i("p",{children:String(T.payload.summary||T.payload.note)}),i("span",{children:new Date(T.timestamp).toLocaleString()})]})]},T.seq)):i("p",{class:"muted",children:"No recorded activity yet."})}),En=!!a,ke=R||F||U,Po=U&&ke&&(r!=="tasks"||R)&&(r!=="missions"||F),Xt=R?void 0:F?F.latestMonitoring||(U?.latestMonitoring?.missionId?void 0:U?.latestMonitoring):U?.latestMonitoring,Nn=R?W.filter(w=>w.id===R.updatedBySessionId):F?W.filter(w=>w.missionId===F.id||w.missionIds?.includes(F.id)):U?W.filter(w=>w.projectId===U.id||w.projectIds?.includes(U.id)):[],To=w=>e?pn(e,w):"#708064",In=r==="projects"&&F?"missions":r,Mn=(w,T,ae,Qe)=>i("label",{class:"filter-label project-picker",children:[i("span",{children:w}),i("select",{"aria-label":`Filter by ${w.toLowerCase()}`,value:T,onChange:Je=>Qe(Je.currentTarget.value),children:[i("option",{value:"all",children:["All ",w.toLowerCase(),"s"]}),[...ae].sort((Je,jo)=>Je.name.localeCompare(jo.name)).map(Je=>i("option",{value:Je.id,children:Je.name},Je.id))]})]}),Do=r==="projects"?["active"]:r==="missions"?["running","planned","blocked","completed","failed","cancelled"]:["todo","in_progress","blocked","completed","failed","cancelled"];return i("div",{class:"shell field-shell","data-section":r,children:[i("a",{class:"field-skip",href:"#workspace-main",children:"Skip to content"}),i("header",{class:"topbar field-sidebar",children:[i("a",{class:"brand",href:Se("projects"),children:[i("img",{class:"brand-mark",src:"/favicon.svg",alt:"","aria-hidden":"true"}),"angine"]}),i("div",{class:"field-workspace",children:[i(si,{seed:"workspace"}),i("span",{children:["Your workspace",i("small",{children:"Personal · local"})]})]}),i("span",{class:"field-nav-label",children:"Workspace"}),i("nav",{"aria-label":"Main navigation",children:["projects","missions","tasks","insights","monitoring","board","tree","agents","archive","settings"].map(w=>i("a",{href:Se(w),class:In===w?"active":"","aria-current":In===w?"page":void 0,children:[i(he,{name:w==="projects"?"overview":w==="monitoring"?"signal":w}),i("span",{children:w==="projects"?"Overview":w==="tree"?"Work map":w==="settings"?"Preferences":w[0].toUpperCase()+w.slice(1)})]},w))}),i("div",{class:"field-pinned",children:[i("span",{class:"field-nav-label",children:"Recent projects"}),Y.slice(0,3).map(w=>i("a",{href:Se("projects",w.id),children:[i("i",{style:{background:To(w.id)}}),i("span",{children:w.name})]},w.id))]}),i("div",{class:"connection",children:[i("span",{class:k?"live-dot":"offline-dot"}),k?"Dashboard live":"Reconnecting"]}),i("div",{class:"field-local",children:[i(he,{name:"archive"}),i("span",{children:["Yours, on this device.",i("small",{children:"Stored locally"})]})]})]}),i("div",{class:"field-appbar",children:[i("span",{children:["Workspace ",i("b",{children:"/"})," ",r==="projects"?"Overview":r==="tree"?"Work map":r==="settings"?"Preferences":r[0].toUpperCase()+r.slice(1)]}),i("span",{class:"field-appbar-status",children:[i(he,{name:"signal"}),"Agent-reported work"]})]}),i("main",{id:"workspace-main",class:En?"detail-page":"overview-page",children:[i(sy,{compatibility:P}),L&&i("div",{class:"error-banner",role:"alert",children:[L,i("button",{class:"text-button",onClick:()=>D(""),children:"Dismiss"})]}),e?r==="agents"?i(gy,{health:A,compatibility:P,state:e,profileId:a||void 0,mutate:z,taskRow:Yt}):r==="archive"?i(yy,{state:e,mutate:z}):r==="settings"?i(vy,{preferences:S,setPreferences:g,resetFilters:h,saveNotifications:v,testNotifications:C,notificationError:b,notificationSupported:E,agents:[...new Set([...Object.values(e.profiles||{}).map(w=>w.agent),...Object.values(e.sessions||{}).map(w=>w.agent),...Object.values(e.tasks||{}).map(w=>w.updatedBy)])].sort()}):r==="monitoring"?i(Sy,{state:e,showOnDashboard:S.showMonitoring,setShowOnDashboard:w=>g({...S,showMonitoring:w})}):r==="insights"?i(_y,{state:e}):r==="tree"?i(K0,{state:e,filters:c,setFilters:u,reset:l}):En?Po&&U&&ke?i(q,{children:[i("nav",{class:"breadcrumbs","aria-label":"Breadcrumb",children:[i("a",{href:Se("projects"),children:"Projects"}),i("span",{children:"/"}),F?i(q,{children:[i("a",{href:Se("projects",U.id),children:U.name}),i("span",{children:"/"}),R?i(q,{children:[i("a",{href:Se("missions",F.id),children:F.name}),i("span",{children:"/"}),i("span",{children:"Task"})]}):i("span",{children:F.name})]}):i("span",{children:U.name})]}),i("div",{class:"page-heading detail-heading mission-heading",style:zn(e,U.id,F?.id),children:[i("div",{children:[i("div",{class:"overline",children:[R?"TASK":F?"MISSION":"PROJECT"," ",i("span",{children:ke.key})]}),i("h1",{children:R?.title||F?.name||U.name}),i("div",{class:"heading-meta",children:[i(Gn,{status:ke.status}),i("span",{children:["Updated ",At(ke.updatedAt)]}),F&&i(Bn,{item:R||F,minutes:S.staleMinutes}),!R&&i("button",{class:"secondary-button",onClick:()=>z("archive",{projectId:ke.id,archived:!("archivedAt"in ke&&ke.archivedAt)}),children:["archivedAt"in ke&&ke.archivedAt?"Restore":"Archive"," ",F?"mission":"project"]}),(U.archivedAt||F?.archivedAt)&&i("span",{children:"Archived"})]})]}),F?i("div",{class:"heading-progress",children:i(Vn,{value:R?tr(R):kn(J(F.id)),caption:R?"Task progress":"Tasks completed"})}):i("div",{class:"project-overview-counts",children:[i("strong",{children:ce(U.id).length}),i("span",{children:"missions"}),i("strong",{children:ye(U.id).length}),i("span",{children:"tasks"})]})]}),i("div",{class:"detail-grid",children:[i("div",{class:"detail-main",children:[S.showMonitoring&&Xt&&i(Cr,{updates:[Xt],state:e,onHide:()=>g({...S,showMonitoring:!1})}),!R&&(F?.latestUpdate||U.latestUpdate)&&(F?.latestUpdate||U.latestUpdate)?.id!==Xt?.id&&i(ky,{update:F?.latestUpdate||U.latestUpdate,state:e}),i("section",{class:"panel",children:[i("h2",{children:"Overview"}),R&&i("p",{class:"report-provenance",children:["Status reported by ",ft(R.updatedBy)," · ",new Date(R.updatedAt).toLocaleString(),i("span",{children:"Completion is agent reported; test results are not independently verified."})]}),i("p",{class:"description",children:ke.description||(F?"No description provided.":"Missions collect the goals and tasks for this project. Completing a mission does not close the project.")}),R?.note&&i("div",{class:"latest-update",children:[i("div",{class:"overline",children:"LATEST UPDATE"}),i("p",{children:R.note})]})]}),!F&&i("section",{children:[i("div",{class:"panel-heading",children:[i("h2",{children:"Missions"}),i("span",{children:ce(U.id).length})]}),Cn(U.archivedAt?H.filter(w=>w.projectId===U.id):ce(U.id))]}),R&&i(my,{task:R,state:e,mutate:z},R.id),F&&(!R||J(F.id).some(w=>w.parentKey===R.key))&&i("section",{class:"panel",children:[i("div",{class:"panel-heading",children:[i("h2",{children:R?"Subtasks":"Tasks"}),i("span",{children:(R?J(F.id).filter(w=>w.parentKey===R.key):J(F.id)).length})]}),i("div",{class:"task-table",children:(R?J(F.id).filter(w=>w.parentKey===R.key):J(F.id)).map(Yt)})]}),i("section",{class:"panel",children:[i("h2",{children:"Activity"}),$o(V.filter(w=>R?w.taskId===R.id:!w.type.startsWith("session.")))]})]}),i("div",{class:"detail-info",children:[i("section",{class:"panel",children:[i("h2",{children:"Details"}),!R&&i(Q0,{project:U,mission:F,mutate:z}),i("dl",{children:[i("dt",{children:"Project"}),i("dd",{children:i("a",{href:Se("projects",U.id),children:U.name})}),F&&i(q,{children:[i("dt",{children:"Mission"}),i("dd",{children:i("a",{href:Se("missions",F.id),children:F.name})})]}),i("dt",{children:F?"Worktrees / workspaces":"Workspace"}),i("dd",{children:F?se(F).map(w=>i("div",{children:[w.path,w.branch&&i("strong",{children:[" · ",w.branch]})]},w.id)):e.workspaces[U.workspaceId]?.repositoryPath||e.workspaces[U.workspaceId]?.path}),i("dt",{children:"Created"}),i("dd",{children:new Date(ke.createdAt).toLocaleString()}),R?.parentKey&&i(q,{children:[i("dt",{children:"Parent task"}),i("dd",{children:J(R.missionId).find(w=>w.key===R.parentKey)?i("a",{href:Se("tasks",J(R.missionId).find(w=>w.key===R.parentKey).id),children:R.parentKey}):R.parentKey})]})]})]}),i("section",{class:"panel",children:[i("h2",{children:R?"Reporting agent":"Reporter sessions"}),Nn.map(w=>i(Cy,{session:w,state:e,health:A},w.id)),!Nn.length&&i("p",{class:"muted",children:"No reporter session available for this item."})]})]})]})]}):i("div",{class:"empty",children:[i("h2",{children:"This page is unavailable"}),i("a",{href:Se("projects"),children:"Return to projects"})]}):i(q,{children:[i("div",{class:"overview-toolbar",children:[i("div",{class:"stats",children:r==="projects"?i(q,{children:[i("div",{children:[i("strong",{children:we.length}),i("span",{children:"Projects"})]}),i("div",{children:[i("strong",{children:te.filter(w=>we.some(T=>T.id===w.projectId)&&w.status==="running").length}),i("span",{children:"Running missions"})]}),i("div",{children:[i("strong",{children:te.filter(w=>we.some(T=>T.id===w.projectId)&&w.status==="completed").length}),i("span",{children:"Completed missions"})]})]}):["all",r==="missions"?"running":"in_progress","blocked","completed","failed","cancelled"].map(w=>i("div",{children:[i("strong",{children:r==="missions"?w==="all"?be.length:be.filter(T=>T.status===w).length:w==="all"?xe.length:xe.filter(T=>T.status===w).length}),i("span",{children:w==="all"?"Total":Xe[w]})]},w))}),i("div",{class:"toolbar",children:[i("label",{class:"search",children:[i("span",{"aria-hidden":"true",children:"⌕"}),i("input",{"aria-label":"Search work",placeholder:"Search projects, missions, tasks…",value:x,onInput:w=>u({query:w.currentTarget.value})})]}),i("label",{class:"filter-label",children:[i("span",{children:"Agent"}),i("select",{"aria-label":"Filter by agent",value:f,onChange:w=>Mo(w.currentTarget.value),children:[i("option",{value:"all",children:"All agents"}),ee.map(w=>i("option",{value:w,children:ft(w)},w))]})]}),r!=="projects"&&Mn("Project",p,De,w=>u({project:w,mission:"all"})),["tasks","board"].includes(r)&&Mn("Mission",m,Ue,w=>u({mission:w})),r!=="projects"&&i("label",{class:"filter-label",children:[i("span",{children:"Status"}),i("select",{"aria-label":"Filter by status",value:d,onChange:w=>u({status:w.currentTarget.value}),children:[i("option",{value:"all",children:"All statuses"}),Do.map(w=>i("option",{value:w,children:Xe[w]},w))]})]}),i("details",{class:"more-filters",children:[i("summary",{children:["More filters",_!=="all"||y?" · On":""]}),i("div",{class:"extra-filters",children:[i("label",{class:"filter-label",children:[i("span",{children:"Profile"}),i("select",{"aria-label":"Filter by profile",value:_,onChange:w=>u({profile:w.currentTarget.value}),children:[i("option",{value:"all",children:"All profiles"}),Object.values(e.profiles).filter(w=>f==="all"||w.agent===f).map(w=>i("option",{value:w.id,children:w.name},w.id))]})]}),i("label",{class:"filter-label",children:[i("span",{children:"Activity"}),i("select",{"aria-label":"Filter stale activity",value:y?"stale":"all",onChange:w=>u({staleOnly:w.currentTarget.value==="stale"}),children:[i("option",{value:"all",children:"All activity"}),i("option",{value:"stale",children:"Stale only"})]})]})]})]}),(x||f!=="all"||d!=="all"||_!=="all"||y||p!=="all"||m!=="all")&&i("button",{class:"clear-filters",onClick:l,children:"Reset"})]})]}),S.showMonitoring&&i(Cr,{updates:Wt,state:e,onHide:()=>g({...S,showMonitoring:!1})}),r!=="projects"&&i(dy,{state:e,tasks:Ut,health:A,staleMinutes:S.staleMinutes}),r==="board"?i("div",{class:"board",ref:M,style:$?{height:`${$}px`}:void 0,children:["todo","in_progress","blocked","completed","failed","cancelled"].map(w=>i("section",{class:"board-column",children:[i("div",{class:"column-heading",children:[i("span",{class:`task-status ${w}`}),i("h2",{children:Xe[w]}),i("span",{children:xe.filter(T=>T.status===w).length})]}),i("div",{class:"board-stack",tabIndex:0,role:"region","aria-label":`${Xe[w]} tasks, scroll this column`,children:[xe.filter(T=>T.status===w).map(T=>i("a",{class:"board-card",style:zn(e,T.projectId,T.missionId),href:Se("tasks",T.id),children:[i("span",{class:"board-project",children:[e.projects[T.projectId]?.name," / ",e.missions[T.missionId]?.name]}),i("strong",{children:[T.title," ",i(Bn,{item:T,minutes:S.staleMinutes})]}),T.blocker?.nextStep&&i("p",{class:"blocker-next",children:["Next: ",T.blocker.nextStep]}),T.note&&i("p",{children:T.note}),i(Vn,{value:tr(T)}),i("div",{class:"board-footer",children:[i("span",{children:ft(T.updatedBy)}),i("span",{children:At(T.updatedAt)})]})]},T.id)),!xe.some(T=>T.status===w)&&i("div",{class:"column-empty",children:"No tasks"})]})]},w))}):r==="tasks"?i("div",{class:"project-sections",children:["in_progress","todo","blocked","completed","failed","cancelled"].filter(w=>(d==="all"||d===w)&&(!["todo","blocked"].includes(w)||xe.some(T=>T.status===w)||d===w)).map(w=>i(Ws,{status:w,kind:"tasks",items:xe.filter(T=>T.status===w),limit:w==="in_progress"?10:5,row:Yt},w))}):r==="missions"?Cn(be,d):i(xy,{state:e,projects:we,tasks:Q,health:A,staleMinutes:S.staleMinutes,agent:f,profile:_})]}):i("div",{class:"empty",children:i("h2",{children:"Loading your work…"})}),i("footer",{class:"footer",children:[i("span",{children:"Angine"}),i("span",{children:"Stored locally on this device"})]})]})]})}Tt(i(Ey,{}),document.getElementById("app"));
|