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.
@@ -0,0 +1,7 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const s of i)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(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var gn,oe,Zs,ut,mi,qs,Gs,Lo,Fn,Jt,Ks,Mr,rr,ir,Qs,Kn={},Qn=[],fd=/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 Ar(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ge(e,t,n){var o,i,s,a={};for(s in t)s=="key"?o=t[s]:s=="ref"?i=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 en(e,a,o,i,null)}function en(e,t,n,o,i){var s={type:e,props:t,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Zs,__i:-1,__u:0};return i==null&&oe.vnode!=null&&oe.vnode(s),s}function Js(){return{current:null}}function Z(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 pd(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,o=[],i=[],s=Ze({},t);s.__v=t.__v+1,oe.vnode&&oe.vnode(s),$r(e.__P,s,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,o,n??wt(t),!!(32&t.__u),i),s.__v=t.__v,s.__.__k[s.__i]=s,ra(o,s,i),t.__e=t.__=null,s.__e!=n&&ea(s)}}function ea(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}),ea(e)}function sr(e){(!e.__d&&(e.__d=!0)&&ut.push(e)&&!Jn.__r++||mi!=oe.debounceRendering)&&((mi=oe.debounceRendering)||qs)(Jn)}function Jn(){try{for(var e,t=1;ut.length;)ut.length>t&&ut.sort(Gs),e=ut.shift(),t=ut.length,pd(e)}finally{ut.length=Jn.__r=0}}function ta(e,t,n,o,i,s,a,c,u,l,h){var f,d,p,y,_,w,v=o&&o.__k||Qn,k=t.length;for(u=gd(n,t,v,u,k),f=0;f<k;f++)(p=n.__k[f])!=null&&(d=p.__i!=-1&&v[p.__i]||Kn,p.__i=f,w=$r(e,p,d,i,s,a,c,u,l,h),y=p.__e,p.ref&&d.ref!=p.ref&&(d.ref&&Pr(d.ref,null,p),h.push(p.ref,p.__c||y,p)),_==null&&y!=null&&(_=y),4&p.__u?(u=na(p,u,e),d.__e&&(d.__e=null)):typeof p.type=="function"&&w!==void 0?u=w:y&&(u=y.nextSibling),p.__u&=-7);return n.__e=_,u}function gd(e,t,n,o,i){var s,a,c,u,l,h=n.length,f=h,d=0;for(e.__k=new Array(i),s=0;s<i;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]=en(null,a,null,null,null):mn(a)?a=e.__k[s]=en(Z,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[s]=en(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=md(a,n,u,f))!=-1&&(f--,(c=n[l])&&(c.__u|=2)),c==null||c.__v==null?(l==-1&&(i>h?d--:i<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)),sa(c,c));return o}function na(e,t,n){var o,i;if(typeof e.type=="function"){for(o=e.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=e,t=na(o[i],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 md(e,t,n,o){var i,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(i=n-1,s=n+1;i>=0||s<t.length;)if((l=t[a=i>=0?i--:s++])!=null&&(2&l.__u)==0&&c==l.key&&u==l.type)return a}return-1}function yi(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||fd.test(t)?n:n+"px"}function An(e,t,n,o,i){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||yi(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||yi(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(Ks,"$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[Jt]=o[Jt]:(n[Jt]=Mr,e.addEventListener(t,s?ir:rr,s)):e.removeEventListener(t,s?ir:rr,s);else{if(i=="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 vi(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Fn]==null)t[Fn]=Mr++;else if(t[Fn]<n[Jt])return;return n(oe.event?oe.event(t):t)}}}function $r(e,t,n,o,i,s,a,c,u,l){var h,f,d,p,y,_,w,v,k,g,m,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(k=t.props,g=L.prototype&&L.prototype.render,m=(h=L.contextType)&&o[h.__c],C=h?m?m.props.value:h.__:o,n.__c?v=(d=t.__c=n.__c).__=d.__E:(g?t.__c=d=new L(k,C):(t.__c=d=new ze(k,C),d.constructor=L,d.render=vd),m&&m.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(k,d.__s))),y=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&&k!==y&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(k,C),t.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(k,d.__s,C)===!1){t.__v!=n.__v&&(d.props=k,d.state=d.__s,d.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(j){j&&(j.__=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(k,d.__s,C),g&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(y,_,w)})}if(d.context=C,d.props=k,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&&(w=d.getSnapshotBeforeUpdate(y,_)),A=h!=null&&h.type===Z&&h.key==null?ia(h.props.children):h,c=ta(e,mn(A)?A:[A],t,n,o,i,s,a,c,u,l),d.base=t.__e,t.__u&=-161,d.__h.length&&a.push(d),v&&(d.__E=d.__=null)}catch(j){if(a.length=f,t.__v=null,u||s!=null){if(j.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--;)Ar(s[P])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),j.then||oa(t),oe.__e(j,t,n)}}else s==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=yd(n.__e,t,n,o,i,s,a,u,l);return(h=oe.diffed)&&h(t),128&t.__u?void 0:c}function oa(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(oa))}function ra(e,t,n){for(var o=0;o<n.length;o++)Pr(n[o],n[++o],n[++o]);oe.__c&&oe.__c(t,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(s){s.call(i)})}catch(s){oe.__e(s,i.__v)}})}function ia(e){return typeof e!="object"||e==null||e.__b>0?e:mn(e)?e.map(ia):e.constructor!==void 0?null:Ze({},e)}function yd(e,t,n,o,i,s,a,c,u){var l,h,f,d,p,y,_,w=n.props||Kn,v=t.props,k=t.type;if(k=="svg"?i="http://www.w3.org/2000/svg":k=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((p=s[l])&&"setAttribute"in p==!!k&&(k?p.localName==k:p.nodeType==3)){e=p,s[l]=null;break}}if(e==null){if(k==null)return document.createTextNode(v);e=document.createElementNS(i,k,v.is&&v),c&&(oe.__m&&oe.__m(t,s),c=!1),s=null}if(k==null)w===v||c&&e.data==v||(e.data=v);else{if(s=k=="textarea"&&v.defaultValue!=null?null:s&&gn.call(e.childNodes),!c&&s!=null)for(w={},l=0;l<e.attributes.length;l++)w[(p=e.attributes[l]).name]=p.value;for(l in w)p=w[l],l=="dangerouslySetInnerHTML"?f=p:l=="children"||l in v||l=="value"&&"defaultValue"in v||l=="checked"&&"defaultChecked"in v||An(e,l,null,p,i);for(l in v)p=v[l],l=="children"?d=p:l=="dangerouslySetInnerHTML"?h=p:l=="value"?y=p:l=="checked"?_=p:c&&typeof p!="function"||w[l]===p||An(e,l,p,w[l],i);if(h)c||f&&(h.__html==f.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),t.__k=[];else if(f&&(e.innerHTML=""),ta(t.type=="template"?e.content:e,mn(d)?d:[d],t,n,o,k=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,a,s?s[0]:n.__k&&wt(n,0),c,u),s!=null)for(l=s.length;l--;)Ar(s[l]);c&&k!="textarea"||(l="value",k=="progress"&&y==null?e.removeAttribute("value"):y!=null&&(y!==e[l]||k=="progress"&&!y||k=="option"&&y!=w[l])&&An(e,l,y,w[l],i),l="checked",_!=null&&_!=e[l]&&An(e,l,_,w[l],i))}return e}function Pr(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(i){oe.__e(i,n)}}function sa(e,t,n){var o,i;if(oe.unmount&&oe.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||Pr(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(i=0;i<o.length;i++)o[i]&&sa(o[i],t,n||typeof e.type!="function");n||Ar(e.__e),e.__c=e.__=e.__e=void 0}function vd(e,t,n){return this.constructor(e,n)}function Tt(e,t,n){var o,i,s,a;t==document&&(t=document.documentElement),oe.__&&oe.__(e,t),i=(o=typeof n=="function")?null:n&&n.__k||t.__k,s=[],a=[],$r(t,e=(!o&&n||t).__k=Ge(Z,null,[e]),i||Kn,Kn,t.namespaceURI,!o&&n?[n]:i?null:t.firstChild?gn.call(t.childNodes):null,s,!o&&n?n:i?i.__e:t.firstChild,o,a),ra(s,e,a),e.props.children=null}function aa(e,t){Tt(e,t,aa)}function _d(e,t,n){var o,i,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"?i=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),en(e.type,c,o||e.key,i||e.ref,null)}function Ut(e){function t(n){var o,i;return this.getChildContext||(o=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(a){a.__e=!0,sr(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"+Qs++,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 i,s,a;t=t.__;)if((i=t.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(e)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,o||{}),a=i.__d),a)return i.__E=i}catch(c){e=c}throw e}},Zs=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),sr(this))},ze.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),sr(this))},ze.prototype.render=Z,ut=[],qs=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Gs=function(e,t){return e.__v.__b-t.__v.__b},Jn.__r=0,Lo=Math.random().toString(8),Fn="__d"+Lo,Jt="__a"+Lo,Ks=/(PointerCapture)$|Capture$/i,Mr=0,rr=vi(!1),ir=vi(!0),Qs=0;var wd=0;function r(e,t,n,o,i,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:--wd,__i:-1,__u:0,__source:i,__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 rt,ue,Ho,_i,jt=0,ca=[],fe=oe,wi=fe.__b,xi=fe.__r,bi=fe.diffed,ki=fe.__c,Si=fe.unmount,Ci=fe.__;function Et(e,t){fe.__h&&fe.__h(ue,e,jt||t),jt=0;var n=ue.__H||(ue.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function W(e){return jt=1,fo(la,e)}function fo(e,t,n){var o=Et(rt++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):la(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=ue,!ue.__f)){var i=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 y=p.__[0];p.__=p.__N,p.__N=void 0,y!==p.__[0]&&(f=!0)}}),s){var d=s.call(this,c,u,l);return h?d||f:d}return!h||f};ue.__f=!0;var s=ue.shouldComponentUpdate,a=ue.componentWillUpdate;ue.componentWillUpdate=function(c,u,l){if(this.__e){var h=s;s=void 0,i(c,u,l),s=h}a&&a.call(this,c,u,l)},ue.shouldComponentUpdate=i}return o.__N||o.__}function ne(e,t){var n=Et(rt++,3);!fe.__s&&Rr(n.__H,t)&&(n.__=e,n.u=t,ue.__H.__h.push(n))}function st(e,t){var n=Et(rt++,4);!fe.__s&&Rr(n.__H,t)&&(n.__=e,n.u=t,ue.__h.push(n))}function re(e){return jt=5,ve(function(){return{current:e}},[])}function Tr(e,t,n){jt=6,st(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(rt++,7);return Rr(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Me(e,t){return jt=8,ve(function(){return e},t)}function at(e){var t=ue.context[e.__c],n=Et(rt++,9);return n.c=e,t?(n.__==null&&(n.__=!0,t.sub(ue)),t.props.value):e.__}function jr(e,t){fe.useDebugValue&&fe.useDebugValue(t?t(e):e)}function xd(e){var t=Et(rt++,10),n=W();return t.__=e,ue.componentDidCatch||(ue.componentDidCatch=function(o,i){t.__&&t.__(o,i),n[1](o)}),[n[0],function(){n[1](void 0)}]}function Dr(){var e=Et(rt++,11);if(!e.__){for(var t=ue.__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 bd(){for(var e;e=ca.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Un),t.__h.some(ar),t.__h=[]}catch(n){t.__h=[],fe.__e(n,e.__v)}}}fe.__b=function(e){ue=null,wi&&wi(e)},fe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Ci&&Ci(e,t)},fe.__r=function(e){xi&&xi(e),rt=0;var t=(ue=e.__c).__H;t&&(Ho===ue?(t.__h=[],ue.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Un),t.__h.some(ar),t.__h=[],rt=0)),Ho=ue},fe.diffed=function(e){bi&&bi(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ca.push(t)!==1&&_i===fe.requestAnimationFrame||((_i=fe.requestAnimationFrame)||kd)(bd)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),Ho=ue=null},fe.__c=function(e,t){t.some(function(n){try{n.__h.some(Un),n.__h=n.__h.filter(function(o){return!o.__||ar(o)})}catch(o){t.some(function(i){i.__h&&(i.__h=[])}),t=[],fe.__e(o,n.__v)}}),ki&&ki(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(i){t=i}}),n.__H=void 0,t&&fe.__e(t,n.__v))};var Ei=typeof requestAnimationFrame=="function";function kd(e){var t,n=function(){clearTimeout(o),Ei&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Ei&&(t=requestAnimationFrame(n))}function Un(e){var t=ue,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),ue=t}function ar(e){var t=ue;e.__c=e.__(),ue=t}function Rr(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function la(e,t){return typeof t=="function"?t(e):t}function da(e,t){for(var n in t)e[n]=t[n];return e}function cr(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 Or(e,t){var n=t(),o=W({t:{__:n,u:t}}),i=o[0].t,s=o[1];return st(function(){i.__=n,i.u=t,zo(i)&&s({t:i})},[e,n,t]),ne(function(){return zo(i)&&s({t:i}),e(function(){zo(i)&&s({t:i})})},[e]),n}function zo(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 Lr(e){e()}function Hr(e){return e}function zr(){return[!1,Lr]}var Br=st;function eo(e,t){this.props=e,this.context=t}function ge(e,t){function n(i){var s=this.props.ref;return s!=i.ref&&s&&(typeof s=="function"?s(null):s.current=null),t?!t(this.props,i)||s!=i.ref:cr(this.props,i)}function o(i){return this.shouldComponentUpdate=n,Ge(e,i)}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 cr(this.props,e)||cr(this.state,t)};var Ni=oe.__b;oe.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ni&&Ni(e)};var Sd=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function po(e){function t(n){var o=da({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=Sd,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Ii=function(e,t){return e==null?null:nt(nt(e).map(t))},ua={map:Ii,forEach:Ii,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},Cd=oe.__e;oe.__e=function(e,t,n,o){if(e.then){for(var i,s=t;s=s.__;)if((i=s.__c)&&i.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k||[]),i.__c(e,t)}Cd(e,t,n,o)};var Mi=oe.unmount;function ha(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=da({},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 ha(o,t,n)})),e}function fa(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return fa(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 tn(){this.__u=0,this.o=null,this.__b=null}function pa(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function ga(e){var t,n,o,i=null;function s(a){if(t||(t=e()).then(function(c){c&&(i=c.default||c),o=!0},function(c){n=c,o=!0}),n)throw n;if(!o)throw t;return i?Ge(i,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),Mi&&Mi(e)},(tn.prototype=new ze).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var i=pa(o.__v),s=!1,a=function(){s||o.__z||(s=!0,n.__R=null,i?i(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]=fa(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)},tn.prototype.componentWillUnmount=function(){this.o=[]},tn.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]=ha(this.__b,n,o.__O=o.__P)}this.__b=null}var i=t.__a&&Ge(Z,null,e.fallback);return i&&(i.__u&=-33),[Ge(Z,null,t.__a?null:e.children),i]};var Ai=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 Ed(e){return this.getChildContext=function(){return e.context},e.children}function Nd(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(i,s){this.childNodes.push(i),t.h.insertBefore(i,s)},removeChild:function(i){this.childNodes.splice(this.childNodes.indexOf(i)>>>1,1),t.h.removeChild(i)}}}Tt(Ge(Ed,{context:t.context},e.__v),t.v)}function ma(e,t){var n=Ge(Nd,{__v:e,h:t});return n.containerInfo=t,n}(It.prototype=new ze).__a=function(e){var t=this,n=pa(t.__v),o=t.l.get(e);return o[0]++,function(i){var s=function(){t.props.revealOrder?(o.push(i),Ai(t,e,o)):i()};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){Ai(e,n,t)})};var ya=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Id=/^(?: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]/,Md=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ad=/[A-Z0-9]/g,$d=typeof document<"u",Pd=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};function va(e,t,n){return t.__k==null&&(t.textContent=""),Tt(e,t),typeof n=="function"&&n(),e?e.__c:null}function _a(e,t,n){return aa(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 $i=oe.event;oe.event=function(e){return $i&&(e=$i(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Vr,Td={configurable:!0,get:function(){return this.class}},Pi=oe.vnode;oe.vnode=function(e){typeof e.type=="string"&&(function(t){var n=t.props,o=t.type,i={},s=o.indexOf("-")==-1;for(var a in n){var c=n[a];if(!(a==="value"&&"defaultValue"in n&&c==null||$d&&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"||Pd(n.type)?u==="onfocus"?a="onfocusin":u==="onblur"?a="onfocusout":Md.test(a)&&(a=u):u=a="oninput":s&&Id.test(a)?a=a.replace(Ad,"-$&").toLowerCase():c===null&&(c=void 0),u==="oninput"&&i[a=u]&&(a="oninputCapture"),i[a]=c}}o=="select"&&(i.multiple&&Array.isArray(i.value)&&(i.value=nt(n.children).forEach(function(l){l.props.selected=i.value.indexOf(l.props.value)!=-1})),i.defaultValue!=null&&(i.value=nt(n.children).forEach(function(l){l.props.selected=i.multiple?i.defaultValue.indexOf(l.props.value)!=-1:i.defaultValue==l.props.value}))),n.class&&!n.className?(i.class=n.class,Object.defineProperty(i,"className",Td)):n.className&&(i.class=i.className=n.className),t.props=i})(e),e.$$typeof=ya,Pi&&Pi(e)};var Ti=oe.__r;oe.__r=function(e){Ti&&Ti(e),Vr=e.__c};var ji=oe.diffed;oe.diffed=function(e){ji&&ji(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),Vr=null};var wa={ReactCurrentDispatcher:{current:{readContext:function(e){return Vr.__n[e.__c].props.value},useCallback:Me,useContext:at,useDebugValue:jr,useDeferredValue:Hr,useEffect:ne,useId:Dr,useImperativeHandle:Tr,useInsertionEffect:Br,useLayoutEffect:st,useMemo:ve,useReducer:fo,useRef:re,useState:W,useSyncExternalStore:Or,useTransition:zr}}},jd="18.3.1";function xa(e){return Ge.bind(null,e)}function yn(e){return!!e&&e.$$typeof===ya}function ba(e){return yn(e)&&e.type===Z}function ka(e){return!!e&&typeof e.displayName=="string"&&e.displayName.indexOf("Memo(")==0}function Sa(e){return yn(e)?_d.apply(null,arguments):e}function Ca(e){return!!e.__k&&(Tt(null,e),!0)}function Ea(e){return e&&(e.base||e.nodeType===1&&e)||null}var Na=function(e,t){return e(t)},Ia=function(e,t){var n,o=oe.debounceRendering;oe.debounceRendering=function(s){n=s};try{var i=e(t);return n&&n(),i}finally{oe.debounceRendering=o}},Ma=yn,Aa={useState:W,useId:Dr,useReducer:fo,useEffect:ne,useLayoutEffect:st,useInsertionEffect:Br,useTransition:zr,useDeferredValue:Hr,useSyncExternalStore:Or,startTransition:Lr,useRef:re,useImperativeHandle:Tr,useMemo:ve,useCallback:Me,useContext:at,useDebugValue:jr,version:"18.3.1",Children:ua,render:va,hydrate:_a,unmountComponentAtNode:Ca,createPortal:ma,createElement:Ge,createContext:Ut,createFactory:xa,cloneElement:Sa,createRef:Js,Fragment:Z,isValidElement:yn,isElement:Ma,isFragment:ba,isMemo:ka,findDOMNode:Ea,Component:ze,PureComponent:eo,memo:ge,forwardRef:po,flushSync:Ia,unstable_batchedUpdates:Na,StrictMode:Z,Suspense:tn,SuspenseList:It,lazy:ga,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:wa};const Dd=Object.freeze(Object.defineProperty({__proto__:null,Children:ua,Component:ze,Fragment:Z,PureComponent:eo,StrictMode:Z,Suspense:tn,SuspenseList:It,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:wa,cloneElement:Sa,createContext:Ut,createElement:Ge,createFactory:xa,createPortal:ma,createRef:Js,default:Aa,findDOMNode:Ea,flushSync:Ia,forwardRef:po,hydrate:_a,isElement:Ma,isFragment:ba,isMemo:ka,isValidElement:yn,lazy:ga,memo:ge,render:va,startTransition:Lr,unmountComponentAtNode:Ca,unstable_batchedUpdates:Na,useCallback:Me,useContext:at,useDebugValue:jr,useDeferredValue:Hr,useEffect:ne,useErrorBoundary:xd,useId:Dr,useImperativeHandle:Tr,useInsertionEffect:Br,useLayoutEffect:st,useMemo:ve,useReducer:fo,useRef:re,useState:W,useSyncExternalStore:Or,useTransition:zr,version:jd},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 Rd={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 Od(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",i=n.indexOf(".");if(i>=0&&(o=n.slice(i+1),n=n.slice(0,i)),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=Od(e+"",n),i,s=-1,a=o.length;if(arguments.length<2){for(;++s<a;)if((i=(e=o[s]).type)&&(i=Ld(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=o[s]).type)n[i]=Di(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Di(n[i],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((i=arguments.length-2)>0)for(var n=new Array(i),o=0,i,s;o<i;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],o=0,i=s.length;o<i;++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],i=0,s=o.length;i<s;++i)o[i].value.apply(t,n)}};function Ld(e,t){for(var n=0,o=e.length,i;n<o;++n)if((i=e[n]).name===t)return i.value}function Di(e,t,n){for(var o=0,i=e.length;o<i;++o)if(e[o].name===t){e[o]=Rd,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var lr="http://www.w3.org/1999/xhtml";const Ri={svg:"http://www.w3.org/2000/svg",xhtml:lr,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)),Ri.hasOwnProperty(t)?{space:Ri[t],local:e}:e}function Hd(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===lr&&t.documentElement.namespaceURI===lr?t.createElement(e):t.createElementNS(n,e)}}function zd(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function $a(e){var t=mo(e);return(t.local?zd:Hd)(t)}function Bd(){}function Fr(e){return e==null?Bd:function(){return this.querySelector(e)}}function Vd(e){typeof e!="function"&&(e=Fr(e));for(var t=this._groups,n=t.length,o=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,c=o[i]=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 Fd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ud(){return[]}function Pa(e){return e==null?Ud:function(){return this.querySelectorAll(e)}}function Wd(e){return function(){return Fd(e.apply(this,arguments))}}function Yd(e){typeof e=="function"?e=Wd(e):e=Pa(e);for(var t=this._groups,n=t.length,o=[],i=[],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)),i.push(u));return new Ae(o,i)}function Ta(e){return function(){return this.matches(e)}}function ja(e){return function(t){return t.matches(e)}}var Xd=Array.prototype.find;function Zd(e){return function(){return Xd.call(this.children,e)}}function qd(){return this.firstElementChild}function Gd(e){return this.select(e==null?qd:Zd(typeof e=="function"?e:ja(e)))}var Kd=Array.prototype.filter;function Qd(){return Array.from(this.children)}function Jd(e){return function(){return Kd.call(this.children,e)}}function eu(e){return this.selectAll(e==null?Qd:Jd(typeof e=="function"?e:ja(e)))}function tu(e){typeof e!="function"&&(e=Ta(e));for(var t=this._groups,n=t.length,o=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,c=o[i]=[],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 Da(e){return new Array(e.length)}function nu(){return new Ae(this._enter||this._groups.map(Da),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 ou(e){return function(){return e}}function ru(e,t,n,o,i,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])&&(i[a]=c)}function iu(e,t,n,o,i,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)?i[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&&(i[c]=u)}function su(e){return e.__data__}function au(e,t){if(!arguments.length)return Array.from(this,su);var n=t?iu:ru,o=this._parents,i=this._groups;typeof e!="function"&&(e=ou(e));for(var s=i.length,a=new Array(s),c=new Array(s),u=new Array(s),l=0;l<s;++l){var h=o[l],f=i[l],d=f.length,p=cu(e.call(h,h&&h.__data__,l,o)),y=p.length,_=c[l]=new Array(y),w=a[l]=new Array(y),v=u[l]=new Array(d);n(h,f,_,w,v,p,t);for(var k=0,g=0,m,C;k<y;++k)if(m=_[k]){for(k>=g&&(g=k+1);!(C=w[g])&&++g<y;);m._next=C||null}}return a=new Ae(a,o),a._enter=c,a._exit=u,a}function cu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function lu(){return new Ae(this._exit||this._groups.map(Da),this._parents)}function du(e,t,n){var o=this.enter(),i=this,s=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),o&&i?o.merge(i).order():i}function uu(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,i=n.length,s=o.length,a=Math.min(i,s),c=new Array(i),u=0;u<a;++u)for(var l=n[u],h=o[u],f=l.length,d=c[u]=new Array(f),p,y=0;y<f;++y)(p=l[y]||h[y])&&(d[y]=p);for(;u<i;++u)c[u]=n[u];return new Ae(c,this._parents)}function hu(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],i=o.length-1,s=o[i],a;--i>=0;)(a=o[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function fu(e){e||(e=pu);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,i=new Array(o),s=0;s<o;++s){for(var a=n[s],c=a.length,u=i[s]=new Array(c),l,h=0;h<c;++h)(l=a[h])&&(u[h]=l);u.sort(t)}return new Ae(i,this._parents).order()}function pu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gu(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function mu(){return Array.from(this)}function yu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],i=0,s=o.length;i<s;++i){var a=o[i];if(a)return a}return null}function vu(){let e=0;for(const t of this)++e;return e}function _u(){return!this.node()}function wu(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var i=t[n],s=0,a=i.length,c;s<a;++s)(c=i[s])&&e.call(c,c.__data__,s,i);return this}function xu(e){return function(){this.removeAttribute(e)}}function bu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ku(e,t){return function(){this.setAttribute(e,t)}}function Su(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Cu(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Eu(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 Nu(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?bu:xu:typeof t=="function"?n.local?Eu:Cu:n.local?Su:ku)(n,t))}function Ra(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Iu(e){return function(){this.style.removeProperty(e)}}function Mu(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Au(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function $u(e,t,n){return arguments.length>1?this.each((t==null?Iu:typeof t=="function"?Au:Mu)(e,t,n??"")):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||Ra(e).getComputedStyle(e,null).getPropertyValue(t)}function Pu(e){return function(){delete this[e]}}function Tu(e,t){return function(){this[e]=t}}function ju(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Du(e,t){return arguments.length>1?this.each((t==null?Pu:typeof t=="function"?ju:Tu)(e,t)):this.node()[e]}function Oa(e){return e.trim().split(/^|\s+/)}function Ur(e){return e.classList||new La(e)}function La(e){this._node=e,this._names=Oa(e.getAttribute("class")||"")}La.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 Ha(e,t){for(var n=Ur(e),o=-1,i=t.length;++o<i;)n.add(t[o])}function za(e,t){for(var n=Ur(e),o=-1,i=t.length;++o<i;)n.remove(t[o])}function Ru(e){return function(){Ha(this,e)}}function Ou(e){return function(){za(this,e)}}function Lu(e,t){return function(){(t.apply(this,arguments)?Ha:za)(this,e)}}function Hu(e,t){var n=Oa(e+"");if(arguments.length<2){for(var o=Ur(this.node()),i=-1,s=n.length;++i<s;)if(!o.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?Lu:t?Ru:Ou)(n,t))}function zu(){this.textContent=""}function Bu(e){return function(){this.textContent=e}}function Vu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Fu(e){return arguments.length?this.each(e==null?zu:(typeof e=="function"?Vu:Bu)(e)):this.node().textContent}function Uu(){this.innerHTML=""}function Wu(e){return function(){this.innerHTML=e}}function Yu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Xu(e){return arguments.length?this.each(e==null?Uu:(typeof e=="function"?Yu:Wu)(e)):this.node().innerHTML}function Zu(){this.nextSibling&&this.parentNode.appendChild(this)}function qu(){return this.each(Zu)}function Gu(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ku(){return this.each(Gu)}function Qu(e){var t=typeof e=="function"?e:$a(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ju(){return null}function eh(e,t){var n=typeof e=="function"?e:$a(e),o=t==null?Ju:typeof t=="function"?t:Fr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function th(){var e=this.parentNode;e&&e.removeChild(this)}function nh(){return this.each(th)}function oh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function rh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ih(e){return this.select(e?rh:oh)}function sh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function ah(e){return function(t){e.call(this,t,this.__data__)}}function ch(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 lh(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,i=t.length,s;n<i;++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 dh(e,t,n){return function(){var o=this.__on,i,s=ah(t);if(o){for(var a=0,c=o.length;a<c;++a)if((i=o[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},o?o.push(i):this.__on=[i]}}function uh(e,t,n){var o=ch(e+""),i,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(i=0,h=c[u];i<s;++i)if((a=o[i]).type===h.type&&a.name===h.name)return h.value}return}for(c=t?dh:lh,i=0;i<s;++i)this.each(c(o[i],t,n));return this}function Ba(e,t,n){var o=Ra(e),i=o.CustomEvent;typeof i=="function"?i=new i(t,n):(i=o.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function hh(e,t){return function(){return Ba(this,e,t)}}function fh(e,t){return function(){return Ba(this,e,t.apply(this,arguments))}}function ph(e,t){return this.each((typeof t=="function"?fh:hh)(e,t))}function*gh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],i=0,s=o.length,a;i<s;++i)(a=o[i])&&(yield a)}var Va=[null];function Ae(e,t){this._groups=e,this._parents=t}function vn(){return new Ae([[document.documentElement]],Va)}function mh(){return this}Ae.prototype=vn.prototype={constructor:Ae,select:Vd,selectAll:Yd,selectChild:Gd,selectChildren:eu,filter:tu,data:au,enter:nu,exit:lu,join:du,merge:uu,selection:mh,order:hu,sort:fu,call:gu,nodes:mu,node:yu,size:vu,empty:_u,each:wu,attr:Nu,style:$u,property:Du,classed:Hu,text:Fu,html:Xu,raise:qu,lower:Ku,append:Qu,insert:eh,remove:nh,clone:ih,datum:sh,on:uh,dispatch:ph,[Symbol.iterator]:gh};function Ie(e){return typeof e=="string"?new Ae([[document.querySelector(e)]],[document.documentElement]):new Ae([[e]],Va)}function yh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Re(e,t){if(e=yh(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 i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const vh={passive:!1},sn={capture:!0,passive:!1};function Bo(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function Fa(e){var t=e.document.documentElement,n=Ie(e).on("dragstart.drag",$t,sn);"onselectstart"in t?n.on("selectstart.drag",$t,sn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ua(e,t){var n=e.document.documentElement,o=Ie(e).on("dragstart.drag",null);t&&(o.on("click.drag",$t,sn),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 dr(e,{sourceEvent:t,subject:n,target:o,identifier:i,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:i,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}})}dr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function _h(e){return!e.ctrlKey&&!e.button}function wh(){return this.parentNode}function xh(e,t){return t??{x:e.x,y:e.y}}function bh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wa(){var e=_h,t=wh,n=xh,o=bh,i={},s=go("start","drag","end"),a=0,c,u,l,h,f=0;function d(m){m.on("mousedown.drag",p).filter(o).on("touchstart.drag",w).on("touchmove.drag",v,vh).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(m,C){if(!(h||!e.call(this,m,C))){var b=g(this,t.call(this,m,C),m,C,"mouse");b&&(Ie(m.view).on("mousemove.drag",y,sn).on("mouseup.drag",_,sn),Fa(m.view),Bo(m),l=!1,c=m.clientX,u=m.clientY,b("start",m))}}function y(m){if($t(m),!l){var C=m.clientX-c,b=m.clientY-u;l=C*C+b*b>f}i.mouse("drag",m)}function _(m){Ie(m.view).on("mousemove.drag mouseup.drag",null),Ua(m.view,l),$t(m),i.mouse("end",m)}function w(m,C){if(e.call(this,m,C)){var b=m.changedTouches,E=t.call(this,m,C),A=b.length,P,L;for(P=0;P<A;++P)(L=g(this,E,m,C,b[P].identifier,b[P]))&&(Bo(m),L("start",m,b[P]))}}function v(m){var C=m.changedTouches,b=C.length,E,A;for(E=0;E<b;++E)(A=i[C[E].identifier])&&($t(m),A("drag",m,C[E]))}function k(m){var C=m.changedTouches,b=C.length,E,A;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),E=0;E<b;++E)(A=i[C[E].identifier])&&(Bo(m),A("end",m,C[E]))}function g(m,C,b,E,A,P){var L=s.copy(),j=Re(P||b,C),V,N,S;if((S=n.call(m,new dr("beforestart",{sourceEvent:b,target:d,identifier:A,active:a,x:j[0],y:j[1],dx:0,dy:0,dispatch:L}),E))!=null)return V=S.x-j[0]||0,N=S.y-j[1]||0,function I(M,$,R){var D=j,B;switch(M){case"start":i[A]=I,B=a++;break;case"end":delete i[A],--a;case"drag":j=Re(R||$,C),B=a;break}L.call(M,m,new dr(M,{sourceEvent:$,subject:S,target:d,identifier:A,active:B,x:j[0]+V,y:j[1]+N,dx:j[0]-D[0],dy:j[1]-D[1],dispatch:L}),E)}}return d.filter=function(m){return arguments.length?(e=typeof m=="function"?m:$n(!!m),d):e},d.container=function(m){return arguments.length?(t=typeof m=="function"?m:$n(m),d):t},d.subject=function(m){return arguments.length?(n=typeof m=="function"?m:$n(m),d):n},d.touchable=function(m){return arguments.length?(o=typeof m=="function"?m:$n(!!m),d):o},d.on=function(){var m=s.on.apply(s,arguments);return m===s?d:m},d.clickDistance=function(m){return arguments.length?(f=(m=+m)*m,d):Math.sqrt(f)},d}function Wr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ya(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function _n(){}var an=.7,no=1/an,Pt="\\s*([+-]?\\d+)\\s*",cn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",kh=/^#([0-9a-f]{3,8})$/,Sh=new RegExp(`^rgb\\(${Pt},${Pt},${Pt}\\)$`),Ch=new RegExp(`^rgb\\(${qe},${qe},${qe}\\)$`),Eh=new RegExp(`^rgba\\(${Pt},${Pt},${Pt},${cn}\\)$`),Nh=new RegExp(`^rgba\\(${qe},${qe},${qe},${cn}\\)$`),Ih=new RegExp(`^hsl\\(${cn},${qe},${qe}\\)$`),Mh=new RegExp(`^hsla\\(${cn},${qe},${qe},${cn}\\)$`),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};Wr(_n,xt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Li,formatHex:Li,formatHex8:Ah,formatHsl:$h,formatRgb:Hi,toString:Hi});function Li(){return this.rgb().formatHex()}function Ah(){return this.rgb().formatHex8()}function $h(){return Xa(this).formatHsl()}function Hi(){return this.rgb().formatRgb()}function xt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=kh.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?zi(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=Sh.exec(e))?new Ce(t[1],t[2],t[3],1):(t=Ch.exec(e))?new Ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Eh.exec(e))?Pn(t[1],t[2],t[3],t[4]):(t=Nh.exec(e))?Pn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ih.exec(e))?Fi(t[1],t[2]/100,t[3]/100,1):(t=Mh.exec(e))?Fi(t[1],t[2]/100,t[3]/100,t[4]):Oi.hasOwnProperty(e)?zi(Oi[e]):e==="transparent"?new Ce(NaN,NaN,NaN,0):null}function zi(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 Ph(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 ur(e,t,n,o){return arguments.length===1?Ph(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}Wr(Ce,ur,Ya(_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?an:Math.pow(an,e),new Ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ce(vt(this.r),vt(this.g),vt(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:Bi,formatHex:Bi,formatHex8:Th,formatRgb:Vi,toString:Vi}));function Bi(){return`#${yt(this.r)}${yt(this.g)}${yt(this.b)}`}function Th(){return`#${yt(this.r)}${yt(this.g)}${yt(this.b)}${yt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vi(){const e=oo(this.opacity);return`${e===1?"rgb(":"rgba("}${vt(this.r)}, ${vt(this.g)}, ${vt(this.b)}${e===1?")":`, ${e})`}`}function oo(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function vt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function yt(e){return e=vt(e),(e<16?"0":"")+e.toString(16)}function Fi(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Oe(e,t,n,o)}function Xa(e){if(e instanceof Oe)return new Oe(e.h,e.s,e.l,e.opacity);if(e instanceof _n||(e=xt(e)),!e)return new Oe;if(e instanceof Oe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,i=Math.min(t,n,o),s=Math.max(t,n,o),a=NaN,c=s-i,u=(s+i)/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+i:2-s-i,a*=60):c=u>0&&u<1?0:a,new Oe(a,c,u,e.opacity)}function jh(e,t,n,o){return arguments.length===1?Xa(e):new Oe(e,t,n,o??1)}function Oe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Wr(Oe,jh,Ya(_n,{brighter(e){return e=e==null?no:Math.pow(no,e),new Oe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?an:Math.pow(an,e),new Oe(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,i=2*n-o;return new Ce(Vo(e>=240?e-240:e+120,i,o),Vo(e,i,o),Vo(e<120?e+240:e-120,i,o),this.opacity)},clamp(){return new Oe(Ui(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("}${Ui(this.h)}, ${Tn(this.s)*100}%, ${Tn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ui(e){return e=(e||0)%360,e<0?e+360:e}function Tn(e){return Math.max(0,Math.min(1,e||0))}function Vo(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 Yr=e=>()=>e;function Dh(e,t){return function(n){return e+n*t}}function Rh(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 Oh(e){return(e=+e)==1?Za:function(t,n){return n-t?Rh(t,n,e):Yr(isNaN(t)?n:t)}}function Za(e,t){var n=t-e;return n?Dh(e,n):Yr(isNaN(e)?t:e)}const ro=(function e(t){var n=Oh(t);function o(i,s){var a=n((i=ur(i)).r,(s=ur(s)).r),c=n(i.g,s.g),u=n(i.b,s.b),l=Za(i.opacity,s.opacity);return function(h){return i.r=a(h),i.g=c(h),i.b=u(h),i.opacity=l(h),i+""}}return o.gamma=e,o})(1);function Lh(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),i;return function(s){for(i=0;i<n;++i)o[i]=e[i]*(1-s)+t[i]*s;return o}}function Hh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function zh(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,i=new Array(o),s=new Array(n),a;for(a=0;a<o;++a)i[a]=nn(e[a],t[a]);for(;a<n;++a)s[a]=t[a];return function(c){for(a=0;a<o;++a)s[a]=i[a](c);return s}}function Bh(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 Vh(e,t){var n={},o={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=nn(e[i],t[i]):o[i]=t[i];return function(s){for(i in n)o[i]=n[i](s);return o}}var hr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fo=new RegExp(hr.source,"g");function Fh(e){return function(){return e}}function Uh(e){return function(t){return e(t)+""}}function qa(e,t){var n=hr.lastIndex=Fo.lastIndex=0,o,i,s,a=-1,c=[],u=[];for(e=e+"",t=t+"";(o=hr.exec(e))&&(i=Fo.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),c[a]?c[a]+=s:c[++a]=s),(o=o[0])===(i=i[0])?c[a]?c[a]+=i:c[++a]=i:(c[++a]=null,u.push({i:a,x:Ye(o,i)})),n=Fo.lastIndex;return n<t.length&&(s=t.slice(n),c[a]?c[a]+=s:c[++a]=s),c.length<2?u[0]?Uh(u[0].x):Fh(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 nn(e,t){var n=typeof t,o;return t==null||n==="boolean"?Yr(t):(n==="number"?Ye:n==="string"?(o=xt(t))?(t=o,ro):qa:t instanceof xt?ro:t instanceof Date?Bh:Hh(t)?Lh:Array.isArray(t)?zh:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Vh:Ye)(e,t)}var Wi=180/Math.PI,fr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ga(e,t,n,o,i,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:i,translateY:s,rotate:Math.atan2(t,e)*Wi,skewX:Math.atan(u)*Wi,scaleX:a,scaleY:c}}var jn;function Wh(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?fr:Ga(t.a,t.b,t.c,t.d,t.e,t.f)}function Yh(e){return e==null||(jn||(jn=document.createElementNS("http://www.w3.org/2000/svg","g")),jn.setAttribute("transform",e),!(e=jn.transform.baseVal.consolidate()))?fr:(e=e.matrix,Ga(e.a,e.b,e.c,e.d,e.e,e.f))}function Ka(e,t,n,o){function i(l){return l.length?l.pop()+" ":""}function s(l,h,f,d,p,y){if(l!==f||h!==d){var _=p.push("translate(",null,t,null,n);y.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(i(f)+"rotate(",null,o)-2,x:Ye(l,h)})):h&&f.push(i(f)+"rotate("+h+o)}function c(l,h,f,d){l!==h?d.push({i:f.push(i(f)+"skewX(",null,o)-2,x:Ye(l,h)}):h&&f.push(i(f)+"skewX("+h+o)}function u(l,h,f,d,p,y){if(l!==f||h!==d){var _=p.push(i(p)+"scale(",null,",",null,")");y.push({i:_-4,x:Ye(l,f)},{i:_-2,x:Ye(h,d)})}else(f!==1||d!==1)&&p.push(i(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 y=-1,_=d.length,w;++y<_;)f[(w=d[y]).i]=w.x(p);return f.join("")}}}var Xh=Ka(Wh,"px, ","px)","deg)"),Zh=Ka(Yh,", ",")",")"),qh=1e-12;function Yi(e){return((e=Math.exp(e))+1/e)/2}function Gh(e){return((e=Math.exp(e))-1/e)/2}function Kh(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yn=(function e(t,n,o){function i(s,a){var c=s[0],u=s[1],l=s[2],h=a[0],f=a[1],d=a[2],p=h-c,y=f-u,_=p*p+y*y,w,v;if(_<qh)v=Math.log(d/l)/t,w=function(E){return[c+E*p,u+E*y,l*Math.exp(t*E*v)]};else{var k=Math.sqrt(_),g=(d*d-l*l+o*_)/(2*l*n*k),m=(d*d-l*l-o*_)/(2*d*n*k),C=Math.log(Math.sqrt(g*g+1)-g),b=Math.log(Math.sqrt(m*m+1)-m);v=(b-C)/t,w=function(E){var A=E*v,P=Yi(C),L=l/(n*k)*(P*Kh(t*A+C)-Gh(C));return[c+L*p,u+L*y,l*P/Yi(t*A+C)]}}return w.duration=v*1e3*t/Math.SQRT2,w}return i.rho=function(s){var a=Math.max(.001,+s),c=a*a,u=c*c;return e(a,c,u)},i})(Math.SQRT2,2,4);var Rt=0,Kt=0,qt=0,Qa=1e3,io,Qt,so=0,bt=0,yo=0,ln=typeof performance=="object"&&performance.now?performance:Date,Ja=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xr(){return bt||(Ja(Qh),bt=ln.now()+yo)}function Qh(){bt=0}function ao(){this._call=this._time=this._next=null}ao.prototype=ec.prototype={constructor:ao,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Xr():+n)+(t==null?0:+t),!this._next&&Qt!==this&&(Qt?Qt._next=this:io=this,Qt=this),this._call=e,this._time=n,pr()},stop:function(){this._call&&(this._call=null,this._time=1/0,pr())}};function ec(e,t,n){var o=new ao;return o.restart(e,t,n),o}function Jh(){Xr(),++Rt;for(var e=io,t;e;)(t=bt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rt}function Xi(){bt=(so=ln.now())+yo,Rt=Kt=0;try{Jh()}finally{Rt=0,tf(),bt=0}}function ef(){var e=ln.now(),t=e-so;t>Qa&&(yo-=t,so=e)}function tf(){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);Qt=e,pr(o)}function pr(e){if(!Rt){Kt&&(Kt=clearTimeout(Kt));var t=e-bt;t>24?(e<1/0&&(Kt=setTimeout(Xi,e-ln.now()-yo)),qt&&(qt=clearInterval(qt))):(qt||(so=ln.now(),qt=setInterval(ef,Qa)),Rt=1,Ja(Xi))}}function Zi(e,t,n){var o=new ao;return t=t==null?0:+t,o.restart(i=>{o.stop(),e(i+t)},t,n),o}var nf=go("start","end","cancel","interrupt"),of=[],tc=0,qi=1,gr=2,Xn=3,Gi=4,mr=5,Zn=6;function vo(e,t,n,o,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;rf(e,n,{name:t,index:o,group:i,on:nf,tween:of,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:tc})}function Zr(e,t){var n=Ve(e,t);if(n.state>tc)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 rf(e,t,n){var o=e.__transition,i;o[t]=n,n.timer=ec(s,0,n.time);function s(l){n.state=qi,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!==qi)return u();for(h in o)if(p=o[h],p.name===n.name){if(p.state===Xn)return Zi(a);p.state===Gi?(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(Zi(function(){n.state===Xn&&(n.state=Gi,n.timer.restart(c,n.delay,n.time),c(l))}),n.state=gr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===gr){for(n.state=Xn,i=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))&&(i[++f]=p);i.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=mr,1),f=-1,d=i.length;++f<d;)i[f].call(e,h);n.state===mr&&(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,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((o=n[a]).name!==t){s=!1;continue}i=o.state>gr&&o.state<mr,o.state=Zn,o.timer.stop(),o.on.call(i?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[a]}s&&delete e.__transition}}function sf(e){return this.each(function(){qn(this,e)})}function af(e,t){var n,o;return function(){var i=Ke(this,e),s=i.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}}i.tween=o}}function cf(e,t,n){var o,i;if(typeof n!="function")throw new Error;return function(){var s=Ke(this,e),a=s.tween;if(a!==o){i=(o=a).slice();for(var c={name:t,value:n},u=0,l=i.length;u<l;++u)if(i[u].name===t){i[u]=c;break}u===l&&i.push(c)}s.tween=i}}function lf(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ve(this.node(),n).tween,i=0,s=o.length,a;i<s;++i)if((a=o[i]).name===e)return a.value;return null}return this.each((t==null?af:cf)(n,e,t))}function qr(e,t,n){var o=e._id;return e.each(function(){var i=Ke(this,o);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Ve(i,o).value[t]}}function nc(e,t){var n;return(typeof t=="number"?Ye:t instanceof xt?ro:(n=xt(t))?(t=n,ro):qa)(e,t)}function df(e){return function(){this.removeAttribute(e)}}function uf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hf(e,t,n){var o,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===o?s:s=t(o=a,n)}}function ff(e,t,n){var o,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===o?s:s=t(o=a,n)}}function pf(e,t,n){var o,i,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===i?s:(i=u,s=t(o=a,c)))}}function gf(e,t,n){var o,i,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===i?s:(i=u,s=t(o=a,c)))}}function mf(e,t){var n=mo(e),o=n==="transform"?Zh:nc;return this.attrTween(e,typeof t=="function"?(n.local?gf:pf)(n,o,qr(this,"attr."+e,t)):t==null?(n.local?uf:df)(n):(n.local?ff:hf)(n,o,t))}function yf(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function vf(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _f(e,t){var n,o;function i(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&vf(e,s)),n}return i._value=t,i}function wf(e,t){var n,o;function i(){var s=t.apply(this,arguments);return s!==o&&(n=(o=s)&&yf(e,s)),n}return i._value=t,i}function xf(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?_f:wf)(o,t))}function bf(e,t){return function(){Zr(this,e).delay=+t.apply(this,arguments)}}function kf(e,t){return t=+t,function(){Zr(this,e).delay=t}}function Sf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?bf:kf)(t,e)):Ve(this.node(),t).delay}function Cf(e,t){return function(){Ke(this,e).duration=+t.apply(this,arguments)}}function Ef(e,t){return t=+t,function(){Ke(this,e).duration=t}}function Nf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Cf:Ef)(t,e)):Ve(this.node(),t).duration}function If(e,t){if(typeof t!="function")throw new Error;return function(){Ke(this,e).ease=t}}function Mf(e){var t=this._id;return arguments.length?this.each(If(t,e)):Ve(this.node(),t).ease}function Af(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ke(this,e).ease=n}}function $f(e){if(typeof e!="function")throw new Error;return this.each(Af(this._id,e))}function Pf(e){typeof e!="function"&&(e=Ta(e));for(var t=this._groups,n=t.length,o=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,c=o[i]=[],u,l=0;l<a;++l)(u=s[l])&&e.call(u,u.__data__,l,s)&&c.push(u);return new it(o,this._parents,this._name,this._id)}function Tf(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,i=n.length,s=Math.min(o,i),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 it(a,this._parents,this._name,this._id)}function jf(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 Df(e,t,n){var o,i,s=jf(t)?Zr:Ke;return function(){var a=s(this,e),c=a.on;c!==o&&(i=(o=c).copy()).on(t,n),a.on=i}}function Rf(e,t){var n=this._id;return arguments.length<2?Ve(this.node(),n).on.on(e):this.each(Df(n,e,t))}function Of(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Lf(){return this.on("end.remove",Of(this._id))}function Hf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fr(e));for(var o=this._groups,i=o.length,s=new Array(i),a=0;a<i;++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 it(s,this._parents,t,n)}function zf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Pa(e));for(var o=this._groups,i=o.length,s=[],a=[],c=0;c<i;++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,y=Ve(h,n),_=0,w=d.length;_<w;++_)(p=d[_])&&vo(p,t,n,_,d,y);s.push(d),a.push(h)}return new it(s,a,t,n)}var Bf=vn.prototype.constructor;function Vf(){return new Bf(this._groups,this._parents)}function Ff(e,t){var n,o,i;return function(){var s=Dt(this,e),a=(this.style.removeProperty(e),Dt(this,e));return s===a?null:s===n&&a===o?i:i=t(n=s,o=a)}}function oc(e){return function(){this.style.removeProperty(e)}}function Uf(e,t,n){var o,i=n+"",s;return function(){var a=Dt(this,e);return a===i?null:a===o?s:s=t(o=a,n)}}function Wf(e,t,n){var o,i,s;return function(){var a=Dt(this,e),c=n(this),u=c+"";return c==null&&(u=c=(this.style.removeProperty(e),Dt(this,e))),a===u?null:a===o&&u===i?s:(i=u,s=t(o=a,c))}}function Yf(e,t){var n,o,i,s="style."+t,a="end."+s,c;return function(){var u=Ke(this,e),l=u.on,h=u.value[s]==null?c||(c=oc(t)):void 0;(l!==n||i!==h)&&(o=(n=l).copy()).on(a,i=h),u.on=o}}function Xf(e,t,n){var o=(e+="")=="transform"?Xh:nc;return t==null?this.styleTween(e,Ff(e,o)).on("end.style."+e,oc(e)):typeof t=="function"?this.styleTween(e,Wf(e,o,qr(this,"style."+e,t))).each(Yf(this._id,e)):this.styleTween(e,Uf(e,o,t),n).on("end.style."+e,null)}function Zf(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function qf(e,t,n){var o,i;function s(){var a=t.apply(this,arguments);return a!==i&&(o=(i=a)&&Zf(e,a,n)),o}return s._value=t,s}function Gf(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,qf(e,t,n??""))}function Kf(e){return function(){this.textContent=e}}function Qf(e){return function(){var t=e(this);this.textContent=t??""}}function Jf(e){return this.tween("text",typeof e=="function"?Qf(qr(this,"text",e)):Kf(e==null?"":e+""))}function ep(e){return function(t){this.textContent=e.call(this,t)}}function tp(e){var t,n;function o(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ep(i)),t}return o._value=e,o}function np(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,tp(e))}function op(){for(var e=this._name,t=this._id,n=rc(),o=this._groups,i=o.length,s=0;s<i;++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 it(o,this._parents,e,n)}function rp(){var e,t,n=this,o=n._id,i=n.size();return new Promise(function(s,a){var c={value:a},u={value:function(){--i===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}),i===0&&s()})}var ip=0;function it(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function rc(){return++ip}var et=vn.prototype;it.prototype={constructor:it,select:Hf,selectAll:zf,selectChild:et.selectChild,selectChildren:et.selectChildren,filter:Pf,merge:Tf,selection:Vf,transition:op,call:et.call,nodes:et.nodes,node:et.node,size:et.size,empty:et.empty,each:et.each,on:Rf,attr:mf,attrTween:xf,style:Xf,styleTween:Gf,text:Jf,textTween:np,remove:Lf,tween:lf,delay:Sf,duration:Nf,ease:Mf,easeVarying:$f,end:rp,[Symbol.iterator]:et[Symbol.iterator]};function sp(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var ap={time:null,delay:0,duration:250,ease:sp};function cp(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 lp(e){var t,n;e instanceof it?(t=e._id,e=e._name):(t=rc(),(n=ap).time=Xr(),e=e==null?null:e+"");for(var o=this._groups,i=o.length,s=0;s<i;++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||cp(u,t));return new it(o,this._parents,e,t)}vn.prototype.interrupt=sf;vn.prototype.transition=lp;const Dn=e=>()=>e;function dp(e,{sourceEvent:t,target:n,transform:o,dispatch:i}){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:i}})}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);ic.prototype=tt.prototype;function ic(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _o;return e.__zoom}function Uo(e){e.stopImmediatePropagation()}function Gt(e){e.preventDefault(),e.stopImmediatePropagation()}function up(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hp(){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 Ki(){return this.__zoom||_o}function fp(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function pp(){return navigator.maxTouchPoints||"ontouchstart"in this}function gp(e,t,n){var o=e.invertX(t[0][0])-n[0][0],i=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(i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function sc(){var e=up,t=hp,n=gp,o=fp,i=pp,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,y=150,_=0,w=10;function v(S){S.property("__zoom",Ki).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",L).filter(i).on("touchstart.zoom",j).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",N).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(S,I,M,$){var R=S.selection?S.selection():S;R.property("__zoom",Ki),S!==R?C(S,I,M,$):R.interrupt().each(function(){b(this,arguments).event($).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},v.scaleBy=function(S,I,M,$){v.scaleTo(S,function(){var R=this.__zoom.k,D=typeof I=="function"?I.apply(this,arguments):I;return R*D},M,$)},v.scaleTo=function(S,I,M,$){v.transform(S,function(){var R=t.apply(this,arguments),D=this.__zoom,B=M==null?m(R):typeof M=="function"?M.apply(this,arguments):M,z=D.invert(B),O=typeof I=="function"?I.apply(this,arguments):I;return n(g(k(D,O),B,z),R,a)},M,$)},v.translateBy=function(S,I,M,$){v.transform(S,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,$)},v.translateTo=function(S,I,M,$,R){v.transform(S,function(){var D=t.apply(this,arguments),B=this.__zoom,z=$==null?m(D):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),D,a)},$,R)};function k(S,I){return I=Math.max(s[0],Math.min(s[1],I)),I===S.k?S:new tt(I,S.x,S.y)}function g(S,I,M){var $=I[0]-M[0]*S.k,R=I[1]-M[1]*S.k;return $===S.x&&R===S.y?S:new tt(S.k,$,R)}function m(S){return[(+S[0][0]+ +S[1][0])/2,(+S[0][1]+ +S[1][1])/2]}function C(S,I,M,$){S.on("start.zoom",function(){b(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event($).end()}).tween("zoom",function(){var R=this,D=arguments,B=b(R,D).event($),z=t.apply(R,D),O=M==null?m(z):typeof M=="function"?M.apply(R,D):M,F=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),U=R.__zoom,K=typeof I=="function"?I.apply(R,D):I,ie=u(U.invert(O).concat(F/U.k),K.invert(O).concat(F/K.k));return function(q){if(q===1)q=K;else{var H=ie(q),X=F/H[2];q=new tt(X,O[0]-H[0]*X,O[1]-H[1]*X)}B.zoom(null,q)}})}function b(S,I,M){return!M&&S.__zooming||new E(S,I)}function E(S,I){this.that=S,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(S,I),this.taps=0}E.prototype={event:function(S){return S&&(this.sourceEvent=S),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(S,I){return this.mouse&&S!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&S!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&S!=="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(S){var I=Ie(this.that).datum();l.call(S,this.that,new dp(S,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:l}),I)}};function A(S,...I){if(!e.apply(this,arguments))return;var M=b(this,I).event(S),$=this.__zoom,R=Math.max(s[0],Math.min(s[1],$.k*Math.pow(2,o.apply(this,arguments)))),D=Re(S);if(M.wheel)(M.mouse[0][0]!==D[0]||M.mouse[0][1]!==D[1])&&(M.mouse[1]=$.invert(M.mouse[0]=D)),clearTimeout(M.wheel);else{if($.k===R)return;M.mouse=[D,$.invert(D)],qn(this),M.start()}Gt(S),M.wheel=setTimeout(B,y),M.zoom("mouse",n(g(k($,R),M.mouse[0],M.mouse[1]),M.extent,a));function B(){M.wheel=null,M.end()}}function P(S,...I){if(d||!e.apply(this,arguments))return;var M=S.currentTarget,$=b(this,I,!0).event(S),R=Ie(S.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",F,!0),D=Re(S,M),B=S.clientX,z=S.clientY;Fa(S.view),Uo(S),$.mouse=[D,this.__zoom.invert(D)],qn(this),$.start();function O(U){if(Gt(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]=Re(U,M),$.mouse[1]),$.extent,a))}function F(U){R.on("mousemove.zoom mouseup.zoom",null),Ua(U.view,$.moved),Gt(U),$.event(U).end()}}function L(S,...I){if(e.apply(this,arguments)){var M=this.__zoom,$=Re(S.changedTouches?S.changedTouches[0]:S,this),R=M.invert($),D=M.k*(S.shiftKey?.5:2),B=n(g(k(M,D),$,R),t.apply(this,I),a);Gt(S),c>0?Ie(this).transition().duration(c).call(C,B,$,S):Ie(this).call(v.transform,B,$,S)}}function j(S,...I){if(e.apply(this,arguments)){var M=S.touches,$=M.length,R=b(this,I,S.changedTouches.length===$).event(S),D,B,z,O;for(Uo(S),B=0;B<$;++B)z=M[B],O=Re(z,this),O=[O,this.__zoom.invert(O),z.identifier],R.touch0?!R.touch1&&R.touch0[2]!==O[2]&&(R.touch1=O,R.taps=0):(R.touch0=O,D=!0,R.taps=1+!!h);h&&(h=clearTimeout(h)),D&&(R.taps<2&&(f=O[0],h=setTimeout(function(){h=null},p)),qn(this),R.start())}}function V(S,...I){if(this.__zooming){var M=b(this,I).event(S),$=S.changedTouches,R=$.length,D,B,z,O;for(Gt(S),D=0;D<R;++D)B=$[D],z=Re(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],q=(q=K[0]-F[0])*q+(q=K[1]-F[1])*q,H=(H=ie[0]-U[0])*H+(H=ie[1]-U[1])*H;B=k(B,Math.sqrt(q/H)),z=[(F[0]+K[0])/2,(F[1]+K[1])/2],O=[(U[0]+ie[0])/2,(U[1]+ie[1])/2]}else if(M.touch0)z=M.touch0[0],O=M.touch0[1];else return;M.zoom("touch",n(g(B,z,O),M.extent,a))}}function N(S,...I){if(this.__zooming){var M=b(this,I).event(S),$=S.changedTouches,R=$.length,D,B;for(Uo(S),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),D=0;D<R;++D)B=$[D],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=Re(B,this),Math.hypot(f[0]-B[0],f[1]-B[1])<w)){var z=Ie(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return v.wheelDelta=function(S){return arguments.length?(o=typeof S=="function"?S:Dn(+S),v):o},v.filter=function(S){return arguments.length?(e=typeof S=="function"?S:Dn(!!S),v):e},v.touchable=function(S){return arguments.length?(i=typeof S=="function"?S:Dn(!!S),v):i},v.extent=function(S){return arguments.length?(t=typeof S=="function"?S:Dn([[+S[0][0],+S[0][1]],[+S[1][0],+S[1][1]]]),v):t},v.scaleExtent=function(S){return arguments.length?(s[0]=+S[0],s[1]=+S[1],v):[s[0],s[1]]},v.translateExtent=function(S){return arguments.length?(a[0][0]=+S[0][0],a[1][0]=+S[1][0],a[0][1]=+S[0][1],a[1][1]=+S[1][1],v):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},v.constrain=function(S){return arguments.length?(n=S,v):n},v.duration=function(S){return arguments.length?(c=+S,v):c},v.interpolate=function(S){return arguments.length?(u=S,v):u},v.on=function(){var S=l.on.apply(l,arguments);return S===l?v:S},v.clickDistance=function(S){return arguments.length?(_=(S=+S)*S,v):Math.sqrt(_)},v.tapDistance=function(S){return arguments.length?(w=+S,v):w},v}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.`},dn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ac=["Enter"," ","Escape"],cc={"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 Ot;(function(e){e.Strict="strict",e.Loose="loose"})(Ot||(Ot={}));var _t;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(_t||(_t={}));var un;(function(e){e.Partial="partial",e.Full="full"})(un||(un={}));const lc={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var ft;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ft||(ft={}));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 Qi={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},dc=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,mp=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gr=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),i=e.origin??t,s=n*i[0],a=o*i[1];return{x:e.position.x-s,y:e.position.y-a}},yp=(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((i,s)=>{const a=typeof s=="string";let c=!t.nodeLookup&&!a?s:void 0;return t.nodeLookup&&(c=a?t.nodeLookup.get(s):Gr(s)?s:t.nodeLookup.get(s.id)),c?(n=!0,wo(i,lo(c,t.nodeOrigin))):i},{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(i=>{(t.filter===void 0||t.filter(i))&&(n=wo(n,lo(i)),o=!0)}),o?xo(n):{x:0,y:0,width:0,height:0}},Kr=(e,t,[n,o,i]=[0,0,1],s=!1,a=!1)=>{const c=(t.x-n)/i,u=(t.y-o)/i,l=t.width/i,h=t.height/i,f=[];for(const d of e.values()){const{measured:p,selectable:y=!0,hidden:_=!1}=d;if(a&&!y||_)continue;const w=p.width??d.width??d.initialWidth??0,v=p.height??d.height??d.initialHeight??0,{x:k,y:g}=d.internals.positionAbsolute,m=pc(c,u,l,h,k,g,w,v),C=w*v,b=s&&m>0;(!d.internals.handleBounds||b||m>=C||d.dragging)&&f.push(d)}return f},vp=(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 _p(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{let s;if(t?.includeHiddenNodes){const{width:a,height:c}=Fe(i);s=a>0&&c>0}else s=!!(i.measured.width&&i.measured.height&&!i.hidden);s&&(!o||o.has(i.id))&&n.set(i.id,i)}),n}async function wp({nodes:e,width:t,height:n,panZoom:o,minZoom:i,maxZoom:s},a){if(e.size===0)return!0;const c=_p(e,a),u=xn(c),l=Jr(u,t,n,a?.minZoom??i,a?.maxZoom??s,a?.padding??.1);return await o.setViewport(l,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),!0}function uc({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:i,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||i;if(a.extent==="parent"&&!a.expandParent)if(!c)s?.("005",Be.error005());else{const{width:p,height:y}=Fe(c);p&&y&&(f=[[u,l],[u+p,l+y]])}else c&&St(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=St(f)?kt(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 xp({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:i}){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),y=!p&&d.parentId&&a.find(_=>_.id===d.parentId);(p||y)&&a.push(d)}const c=new Set(t.map(d=>d.id)),u=o.filter(d=>d.deletable!==!1),h=vp(a,u);for(const d of u)c.has(d.id)&&!h.find(y=>y.id===d.id)&&h.push(d);if(!i)return{edges:h,nodes:a};const f=await i({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),kt=(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 hc(e,t,n){const{width:o,height:i}=Fe(n),{x:s,y:a}=n.internals.positionAbsolute;return kt(e,[[s,a],[s+o,a+i]],t)}const Ji=(e,t,n)=>e<t?Lt(Math.abs(e-t),1,t)/t:e>n?-Lt(Math.abs(e-n),1,t)/t:0,Qr=(e,t,n=15,o=40)=>{const i=Ji(e.x,o,t.width-o)*n,s=Ji(e.y,o,t.height-o)*n;return[i,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)}),yr=({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}),hn=(e,t=[0,0])=>{const{x:n,y:o}=Gr(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}=Gr(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)}},fc=(e,t)=>xo(wo(yr(e),yr(t))),pc=(e,t,n,o,i,s,a,c)=>{const u=Math.max(0,Math.min(e+n,i+a)-Math.max(e,i)),l=Math.max(0,Math.min(t+o,s+c)-Math.max(t,s));return Math.ceil(u*l)},uo=(e,t)=>pc(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),es=e=>Le(e.width)&&Le(e.height)&&Le(e.x)&&Le(e.y),Le=e=>!isNaN(e)&&isFinite(e),gc=(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])}),kn=({x:e,y:t},[n,o,i],s=!1,a=[1,1])=>{const c={x:(e-n)/i,y:(t-o)/i};return s?bn(c,a):c},Ht=({x:e,y:t},[n,o,i])=>({x:e*i+n,y:t*i+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 bp(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Nt(e,n),i=Nt(e,t);return{top:o,right:i,bottom:o,left:i,x:i*2,y:o*2}}if(typeof e=="object"){const o=Nt(e.top??e.y??0,n),i=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:i,left:s,x:s+a,y:o+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function kp(e,t,n,o,i,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=i-u,f=s-l;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(f)}}const Jr=(e,t,n,o,i,s)=>{const a=bp(s,t,n),c=(t-a.x)/e.width,u=(n-a.y)/e.height,l=Math.min(c,u),h=Lt(l,o,i),f=e.x+e.width/2,d=e.y+e.height/2,p=t/2-f*h,y=n/2-d*h,_=kp(e,p,y,h,t,n),w={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-w.left+w.right,y:y-w.top+w.bottom,zoom:h}},fn=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function St(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 mc(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function yc(e,t={width:0,height:0},n,o,i){const s={...e},a=o.get(n);if(a){const c=a.origin||i;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 ts(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Sp(){let e,t;return{promise:new Promise((o,i)=>{e=o,t=i}),resolve:e,reject:t}}function Cp(e){return{...cc,...e||{}}}function vc(e){return e===null?null:e?"valid":"invalid"}function on(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:i}){const{x:s,y:a}=He(e),c=kn({x:s-(i?.left??0),y:a-(i?.top??0)},o),{x:u,y:l}=n?bn(c,t):c;return{xSnapped:u,ySnapped:l,...c}}const ei=e=>({width:e.offsetWidth,height:e.offsetHeight}),_c=e=>e?.getRootNode?.()||window?.document,Ep=["INPUT","SELECT","TEXTAREA"];function wc(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Ep.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const xc=e=>"clientX"in e,He=(e,t)=>{const n=xc(e),o=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:i-(t?.top??0)}},ns=(e,t,n,o,i)=>{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:i,position:a.getAttribute("data-handlepos"),x:(c.left-n.left)/o,y:(c.top-n.top)/o,...ei(a)}})};function bc({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:i,sourceControlY:s,targetControlX:a,targetControlY:c}){const u=e*.125+i*.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 Rn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function os({pos:e,x1:t,y1:n,x2:o,y2:i,c:s}){switch(e){case G.Left:return[t-Rn(t-o,s),n];case G.Right:return[t+Rn(o-t,s),n];case G.Top:return[t,n-Rn(n-i,s)];case G.Bottom:return[t,n+Rn(i-n,s)]}}function kc({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:o,targetY:i,targetPosition:s=G.Top,curvature:a=.25}){const[c,u]=os({pos:n,x1:e,y1:t,x2:o,y2:i,c:a}),[l,h]=os({pos:s,x1:o,y1:i,x2:e,y2:t,c:a}),[f,d,p,y]=bc({sourceX:e,sourceY:t,targetX:o,targetY:i,sourceControlX:c,sourceControlY:u,targetControlX:l,targetControlY:h});return[`M${e},${t} C${c},${u} ${l},${h} ${o},${i}`,f,d,p,y]}function Sc({sourceX:e,sourceY:t,targetX:n,targetY:o}){const i=Math.abs(n-e)/2,s=n<e?n+i:n-i,a=Math.abs(o-t)/2,c=o<t?o+a:o-a;return[s,c,i,a]}function Np({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:i=!1,zIndexMode:s="basic"}){if(s==="manual")return o;const a=i&&n?o+1e3:o,c=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return a+c}function Ip({sourceNode:e,targetNode:t,width:n,height:o,transform:i}){const s=wo(lo(e),lo(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const a={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:o/i[2]};return uo(a,xo(s))>0}const Mp=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Ap=(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)),$p=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Be.error006()),t;const o=n.getEdgeId||Mp;let i;return dc(e)?i={...e}:i={...e,id:o(e)},Ap(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Cc({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[i,s,a,c]=Sc({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,i,s,a,c]}const rs={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},Pp=({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},is=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Tp({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:o=G.Top,center:i,offset:s,stepPosition:a}){const c=rs[t],u=rs[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=Pp({source:l,sourcePosition:t,target:h}),d=f.x!==0?"x":"y",p=f[d];let y=[],_,w;const v={x:0,y:0},k={x:0,y:0},[,,g,m]=Sc({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[d]*u[d]===-1){d==="x"?(_=i.x??l.x+(h.x-l.x)*a,w=i.y??(l.y+h.y)/2):(_=i.x??(l.x+h.x)/2,w=i.y??l.y+(h.y-l.y)*a);const A=[{x:_,y:l.y},{x:_,y:h.y}],P=[{x:l.x,y:w},{x:h.x,y:w}];c[d]===p?y=d==="x"?A:P:y=d==="x"?P:A}else{const A=[{x:l.x,y:h.y}],P=[{x:h.x,y:l.y}];if(d==="x"?y=c.x===p?P:A:y=c.y===p?A:P,t===o){const S=Math.abs(e[d]-n[d]);if(S<=s){const I=Math.min(s-1,s-S);c[d]===p?v[d]=(l[d]>e[d]?-1:1)*I:k[d]=(h[d]>n[d]?-1:1)*I}}if(t!==o){const S=d==="x"?"y":"x",I=c[d]===u[S],M=l[S]>h[S],$=l[S]<h[S];(c[d]===1&&(!I&&M||I&&$)||c[d]!==1&&(!I&&$||I&&M))&&(y=d==="x"?A:P)}const L={x:l.x+v.x,y:l.y+v.y},j={x:h.x+k.x,y:h.y+k.y},V=Math.max(Math.abs(L.x-y[0].x),Math.abs(j.x-y[0].x)),N=Math.max(Math.abs(L.y-y[0].y),Math.abs(j.y-y[0].y));V>=N?(_=(L.x+j.x)/2,w=y[0].y):(_=y[0].x,w=(L.y+j.y)/2)}const C={x:l.x+v.x,y:l.y+v.y},b={x:h.x+k.x,y:h.y+k.y};return[[e,...C.x!==y[0].x||C.y!==y[0].y?[C]:[],...y,...b.x!==y[y.length-1].x||b.y!==y[y.length-1].y?[b]:[],n],_,w,g,m]}function jp(e,t,n,o){const i=Math.min(is(e,t)/2,is(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+i*l},${a}Q ${s},${a} ${s},${a+i*h}`}const c=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${s},${a+i*u}Q ${s},${a} ${s+i*c},${a}`}function vr({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:o,targetY:i,targetPosition:s=G.Top,borderRadius:a=5,centerX:c,centerY:u,offset:l=20,stepPosition:h=.5}){const[f,d,p,y,_]=Tp({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:i},targetPosition:s,center:{x:c,y:u},offset:l,stepPosition:h});let w=`M${f[0].x} ${f[0].y}`;for(let v=1;v<f.length-1;v++)w+=jp(f[v-1],f[v],f[v+1],a);return w+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[w,d,p,y,_]}function ss(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Dp(e){const{sourceNode:t,targetNode:n}=e;if(!ss(t)||!ss(n))return null;const o=t.internals.handleBounds||as(t.handles),i=n.internals.handleBounds||as(n.handles),s=cs(o?.source??[],e.sourceHandle),a=cs(e.connectionMode===Ot.Strict?i?.target??[]:(i?.target??[]).concat(i?.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 as(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 i=(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:i+a/2,y:s+c/2};switch(t?.position??n){case G.Top:return{x:i+a/2,y:s};case G.Right:return{x:i+a,y:s+c/2};case G.Bottom:return{x:i+a/2,y:s+c};case G.Left:return{x:i,y:s+c/2}}}function cs(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function _r(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Rp(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:i}){const s=new Set;return e.reduce((a,c)=>([c.markerStart||o,c.markerEnd||i].forEach(u=>{if(u&&typeof u=="object"){const l=_r(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 Ec=1e3,Op=10,ti={nodeOrigin:[0,0],nodeExtent:dn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Lp={...ti,checkEquality:!0};function ni(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Hp(e,t,n){const o=ni(ti,n);for(const i of e.values())if(i.parentId)ri(i,e,t,o);else{const s=wn(i,o.nodeOrigin),a=St(i.extent)?i.extent:o.nodeExtent,c=kt(s,a,Fe(i));i.internals.positionAbsolute=c}}function zp(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const i of e.handles){const s={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(s):i.type==="target"&&o.push(s)}return{source:n,target:o}}function oi(e){return e==="manual"}function wr(e,t,n,o={}){const i=ni(Lp,o),s={i:0},a=new Map(t),c=i?.elevateNodesOnSelect&&!oi(i.zIndexMode)?Ec:0;let u=e.length>0,l=!1;t.clear(),n.clear();for(const h of e){let f=a.get(h.id);if(i.checkEquality&&h===f?.internals.userNode)t.set(h.id,f);else{const d=wn(h,i.nodeOrigin),p=St(h.extent)?h.extent:i.nodeExtent,y=kt(d,p,Fe(h));f={...i.defaults,...h,measured:{width:h.measured?.width,height:h.measured?.height},internals:{positionAbsolute:y,handleBounds:zp(h,f),z:Nc(h,c,i.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&&ri(f,t,n,o,s),l||=h.selected??!1}return{nodesInitialized:u,hasSelectedNodes:l}}function Bp(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 ri(e,t,n,o,i){const{elevateNodesOnSelect:s,nodeOrigin:a,nodeExtent:c,zIndexMode:u}=ni(ti,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}Bp(e,n),i&&!h.parentId&&h.internals.rootParentIndex===void 0&&u==="auto"&&(h.internals.rootParentIndex=++i.i,h.internals.z=h.internals.z+i.i*Op),i&&h.internals.rootParentIndex!==void 0&&(i.i=h.internals.rootParentIndex);const f=s&&!oi(u)?Ec:0,{x:d,y:p,z:y}=Vp(e,h,a,c,f,u),{positionAbsolute:_}=e.internals,w=d!==_.x||p!==_.y;(w||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:d,y:p}:_,z:y}})}function Nc(e,t,n){const o=Le(e.zIndex)?e.zIndex:0;return oi(n)?o:o+(e.selected?t:0)}function Vp(e,t,n,o,i,s){const{x:a,y:c}=t.internals.positionAbsolute,u=Fe(e),l=wn(e,n),h=St(e.extent)?kt(l,e.extent,u):l;let f=kt({x:a+h.x,y:c+h.y},o,u);e.extent==="parent"&&(f=hc(f,u,t));const d=Nc(e,i,s),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=d?p+1:d}}function ii(e,t,n,o=[0,0]){const i=[],s=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=s.get(a.parentId)?.expandedRect??hn(c),l=fc(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,y=Math.max(h.width,Math.round(a.width)),_=Math.max(h.height,Math.round(a.height)),w=(y-h.width)*f[0],v=(_-h.height)*f[1];(d>0||p>0||w||v)&&(i.push({id:u,type:"position",position:{x:c.position.x-d+w,y:c.position.y-p+v}}),n.get(u)?.forEach(k=>{e.some(g=>g.id===k.id)||i.push({id:k.id,type:"position",position:{x:k.position.x+d,y:k.position.y+p}})})),(h.width<a.width||h.height<a.height||d||p)&&i.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:y+(d?f[0]*d-w:0),height:_+(p?f[1]*p-v:0)}})}),i}function Fp(e,t,n,o,i,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 y=t.get(p.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),u=!0;continue}const _=ei(p.nodeElement),w=y.measured.width!==_.width||y.measured.height!==_.height;if(!!(_.width&&_.height&&(w||!y.internals.handleBounds||p.force))){const k=p.nodeElement.getBoundingClientRect(),g=St(y.extent)?y.extent:s;let{positionAbsolute:m}=y.internals;if(y.parentId&&y.extent==="parent"){const b=t.get(y.parentId);b&&(m=hc(m,_,b))}else g&&(m=kt(m,g,_));const C={...y,measured:_,internals:{...y.internals,positionAbsolute:m,handleBounds:{source:ns("source",p.nodeElement,k,f,y.id),target:ns("target",p.nodeElement,k,f,y.id)}}};t.set(y.id,C),y.parentId&&ri(C,t,n,{nodeOrigin:i,zIndexMode:a}),u=!0,w&&(l.push({id:y.id,type:"dimensions",dimensions:_}),y.expandParent&&y.parentId&&d.push({id:y.id,parentId:y.parentId,rect:hn(C,i)}))}}if(d.length>0){const p=ii(d,t,n,i);l.push(...p)}return{changes:l,updatedInternals:u}}async function Up({delta:e,panZoom:t,transform:n,translateExtent:o,width:i,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],[i,s]],o);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])}function ls(e,t,n,o,i,s){let a=i;const c=o.get(a)||new Map;o.set(a,c.set(n,t)),a=`${i}-${e}`;const u=o.get(a)||new Map;if(o.set(a,u.set(n,t)),s){a=`${i}-${e}-${s}`;const l=o.get(a)||new Map;o.set(a,l.set(n,t))}}function Ic(e,t,n){e.clear(),t.clear();for(const o of n){const{source:i,target:s,sourceHandle:a=null,targetHandle:c=null}=o,u={edgeId:o.id,source:i,target:s,sourceHandle:a,targetHandle:c},l=`${i}-${a}--${s}-${c}`,h=`${s}-${c}--${i}-${a}`;ls("source",u,h,e,i,a),ls("target",u,l,e,s,c),t.set(o.id,o)}}function Mc(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Mc(n,t):!1}function ds(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 Wp(e,t,n,o){const i=new Map;for(const[s,a]of e)if((a.selected||a.id===o)&&(!a.parentId||!Mc(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const c=e.get(s);c&&i.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 i}function Wo({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const i=[];for(const[a,c]of t){const u=n.get(a)?.internals.userNode;u&&i.push({...u,position:c.position,dragging:o})}if(!e)return[i[0],i];const s=n.get(e)?.internals.userNode;return[s?{...s,position:t.get(e)?.position||s.position,dragging:o}:i[0],i]}function Yp({dragItems:e,snapGrid:t,x:n,y:o}){const i=e.values().next().value;if(!i)return null;const s={x:n-i.distance.x,y:o-i.distance.y},a=bn(s,t);return{x:a.x-s.x,y:a.y-s.y}}function Xp({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:i}){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,y=!1,_=null;function w({noDragClassName:k,handleSelector:g,domNode:m,isSelectable:C,nodeId:b,nodeClickDistance:E=0}){d=Ie(m);function A({x:V,y:N}){const{nodeLookup:S,nodeExtent:I,snapGrid:M,snapToGrid:$,nodeOrigin:R,onNodeDrag:D,onSelectionDrag:B,onError:z,updateNodePositions:O}=t();s={x:V,y:N};let F=!1;const U=c.size>1,K=U&&I?yr(xn(c)):null,ie=U&&$?Yp({dragItems:c,snapGrid:M,x:V,y:N}):null;for(const[q,H]of c){if(!S.has(q))continue;let X={x:V-H.distance.x,y:N-H.distance.y};$&&(X=ie?{x:Math.round(X.x+ie.x),y:Math.round(X.y+ie.y)}:bn(X,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:Y}=uc({nodeId:q,nextPosition:X,nodeLookup:S,nodeExtent:te||I,nodeOrigin:R,onError:z});F=F||H.position.x!==Q.x||H.position.y!==Q.y,H.position=Q,H.internals.positionAbsolute=Y}if(y=y||F,!!F&&(O(c,!0),_&&(o||D||!b&&B))){const[q,H]=Wo({nodeId:b,dragItems:c,nodeLookup:S});o?.(_,c,q,H),D?.(_,q,H),b||B?.(_,H)}}async function P(){if(!h)return;const{transform:V,panBy:N,autoPanSpeed:S,autoPanOnNodeDrag:I}=t();if(!I){u=!1,cancelAnimationFrame(a);return}const[M,$]=Qr(l,h,S);(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:S,nodesDraggable:I,transform:M,snapGrid:$,snapToGrid:R,selectNodesOnDrag:D,onNodeDragStart:B,onSelectionDragStart:z,unselectNodesAndEdges:O}=t();f=!0,(!D||!C)&&!S&&b&&(N.get(b)?.selected||O()),C&&D&&b&&e?.(b);const F=on(V.sourceEvent,{transform:M,snapGrid:$,snapToGrid:R,containerBounds:h});if(s=F,c=Wp(N,I,F,b),c.size>0&&(n||B||!b&&z)){const[U,K]=Wo({nodeId:b,dragItems:c,nodeLookup:N});n?.(V.sourceEvent,c,U,K),B?.(V.sourceEvent,U,K),b||z?.(V.sourceEvent,K)}}const j=Wa().clickDistance(E).on("start",V=>{const{domNode:N,nodeDragThreshold:S,transform:I,snapGrid:M,snapToGrid:$}=t();h=N?.getBoundingClientRect()||null,p=!1,y=!1,_=V.sourceEvent,S===0&&L(V),s=on(V.sourceEvent,{transform:I,snapGrid:M,snapToGrid:$,containerBounds:h}),l=He(V.sourceEvent,h)}).on("drag",V=>{const{autoPanOnNodeDrag:N,transform:S,snapGrid:I,snapToGrid:M,nodeDragThreshold:$,nodeLookup:R}=t(),D=on(V.sourceEvent,{transform:S,snapGrid:I,snapToGrid:M,containerBounds:h});if(_=V.sourceEvent,(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1||b&&!R.has(b))&&(p=!0),!p){if(!u&&N&&f&&(u=!0,P()),!f){const B=He(V.sourceEvent,h),z=B.x-l.x,O=B.y-l.y;Math.sqrt(z*z+O*O)>$&&L(V)}(s.x!==D.xSnapped||s.y!==D.ySnapped)&&c&&f&&(l=He(V.sourceEvent,h),A(D))}}).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:S,onNodeDragStop:I,onSelectionDragStop:M}=t();if(y&&(S(c,!1),y=!1),i||I||!b&&M){const[$,R]=Wo({nodeId:b,dragItems:c,nodeLookup:N,dragging:!1});i?.(V.sourceEvent,c,$,R),I?.(V.sourceEvent,$,R),b||M?.(V.sourceEvent,R)}}}).filter(V=>{const N=V.target;return!V.button&&(!k||!ds(N,`.${k}`,m))&&(!g||ds(N,g,m))});d.call(j)}function v(){d?.on(".drag",null)}return{update:w,destroy:v}}function Zp(e,t,n){const o=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())uo(i,hn(s))>0&&o.push(s);return o}const qp=250;function Gp(e,t,n,o){let i=[],s=1/0;const a=Zp(e,n,t+qp);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?(i=[{...l,x:h,y:f}],s=d):d===s&&i.push({...l,x:h,y:f}))}}if(!i.length)return null;if(i.length>1){const c=o.type==="source"?"target":"source";return i.find(u=>u.type===c)??i[0]}return i[0]}function Ac(e,t,n,o,i,s=!1){const a=o.get(e);if(!a)return null;const c=i==="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 $c(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Kp(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Pc=()=>!0;function Qp(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:i,edgeUpdaterType:s,isTarget:a,domNode:c,nodeLookup:u,lib:l,autoPanOnConnect:h,flowId:f,panBy:d,cancelConnection:p,onConnectStart:y,onConnect:_,onConnectEnd:w,isValidConnection:v=Pc,onReconnectEnd:k,updateConnection:g,getTransform:m,getFromHandle:C,autoPanSpeed:b,dragThreshold:E=1,handleDomNode:A}){const P=_c(e.target);let L=0,j;const{x:V,y:N}=He(e),S=$c(s,A),I=c?.getBoundingClientRect();let M=!1;if(!I||!S)return;const $=Ac(i,S,o,u,t);if(!$)return;let R=He(e,I),D=!1,B=null,z=!1,O=null;function F(){if(!h||!I)return;const[Q,Y]=Qr(R,I,b);d({x:Q,y:Y}),L=requestAnimationFrame(F)}const U={...$,nodeId:i,type:S,position:$.position},K=u.get(i);let q={inProgress:!0,isValid:null,from:Ct(K,U,G.Left,!0),fromHandle:U,fromPosition:U.position,fromNode:K,to:R,toHandle:null,toPosition:Qi[U.position],toNode:null,pointer:R};function H(){M=!0,g(q),y?.(e,{nodeId:i,handleId:o,handleType:S})}E===0&&H();function X(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 Y=m();R=He(Q,I),j=Gp(kn(R,Y,!1,[1,1]),n,u,U),D||(F(),D=!0);const ee=Tc(Q,{handle:j,connectionMode:t,fromNodeId:i,fromHandleId:o,fromType:a?"target":"source",isValidConnection:v,doc:P,lib:l,flowId:f,nodeLookup:u});O=ee.handleDomNode,B=ee.connection,z=Kp(!!j,ee.isValid);const se=u.get(i),J=se?Ct(se,U,G.Left,!0):q.from,ce={...q,from:J,isValid:z,to:ee.toHandle&&z?Ht({x:ee.toHandle.x,y:ee.toHandle.y},Y):R,toHandle:ee.toHandle,toPosition:z&&ee.toHandle?ee.toHandle.position:Qi[U.position],toNode:ee.toHandle?u.get(ee.toHandle.nodeId):null,pointer:R};g(ce),q=ce}function te(Q){if(!("touches"in Q&&Q.touches.length>0)){if(M){(j||O)&&B&&z&&_?.(B);const{inProgress:Y,...ee}=q,se={...ee,toPosition:q.toHandle?q.toPosition:null};w?.(Q,se),s&&k?.(Q,se)}p(),cancelAnimationFrame(L),D=!1,z=!1,B=null,O=null,P.removeEventListener("mousemove",X),P.removeEventListener("mouseup",te),P.removeEventListener("touchmove",X),P.removeEventListener("touchend",te)}}P.addEventListener("mousemove",X),P.addEventListener("mouseup",te),P.addEventListener("touchmove",X),P.addEventListener("touchend",te)}function Tc(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:i,fromType:s,doc:a,lib:c,flowId:u,isValidConnection:l=Pc,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}=He(e),_=a.elementFromPoint(p,y),w=_?.classList.contains(`${c}-flow__handle`)?_:d,v={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const k=$c(void 0,w),g=w.getAttribute("data-nodeid"),m=w.getAttribute("data-handleid"),C=w.classList.contains("connectable"),b=w.classList.contains("connectableend");if(!g||!k)return v;const E={source:f?g:o,sourceHandle:f?m:i,target:f?o:g,targetHandle:f?i:m};v.connection=E;const P=C&&b&&(n===Ot.Strict?f&&k==="source"||!f&&k==="target":g!==o||m!==i);v.isValid=P&&l(E),v.toHandle=Ac(g,k,m,h,n,!0)}return v}const xr={onPointerDown:Qp,isValid:Tc};function Jp({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const i=Ie(e);function s({translateExtent:c,width:u,height:l,zoomStep:h=1,pannable:f=!0,zoomable:d=!0,inversePan:p=!1}){const y=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const m=n(),C=g.sourceEvent.ctrlKey&&fn()?10:1,b=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*h,E=m[2]*Math.pow(2,b*C);t.scaleTo(E)};let _=[0,0];const w=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])},v=g=>{const m=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(m[2],Math.log(m[2]))*(p?-1:1),A={x:m[0]-b[0]*E,y:m[1]-b[1]*E},P=[[0,0],[u,l]];t.setViewportConstrained({x:A.x,y:A.y,zoom:m[2]},P,c)},k=sc().on("start",w).on("zoom",f?v:null).on("zoom.wheel",d?y:null);i.call(k,{})}function a(){i.on("zoom",null)}return{update:s,destroy:a,pointer:Re}}const bo=e=>({x:e.x,y:e.y,zoom:e.k}),Yo=({x:e,y:t,zoom:n})=>_o.translate(e,t).scale(n),ht=(e,t)=>e.target.closest(`.${t}`),jc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),eg=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Xo=(e,t=0,n=eg,o=()=>{})=>{const i=typeof t=="number"&&t>0;return i||o(),i?e.transition().duration(t).ease(n).on("end",o):e},Dc=e=>{const t=e.ctrlKey&&fn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function tg({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:i,panOnScrollSpeed:s,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:l}){return h=>{if(ht(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(h.ctrlKey&&a){const w=Re(h),v=Dc(h),k=f*Math.pow(2,v);o.scaleTo(n,k,w,h);return}const d=h.deltaMode===1?20:1;let p=i===_t.Vertical?0:h.deltaX*d,y=i===_t.Horizontal?0:h.deltaY*d;!fn()&&h.shiftKey&&i!==_t.Vertical&&(p=h.deltaY*d,y=0),o.translateBy(n,-(p/f)*s,-(y/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 ng({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,i){const s=o.type==="wheel",a=!t&&s&&!o.ctrlKey,c=ht(o,e);if(o.ctrlKey&&s&&c&&o.preventDefault(),a||c)return null;o.preventDefault(),n.call(this,o,i)}}function og({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const i=bo(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,i)}}function rg({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:i}){return s=>{e.usedRightMouseButton=!!(n&&jc(t,e.mouseButton??0)),s.sourceEvent?.sync||o([s.transform.x,s.transform.y,s.transform.k]),i&&!s.sourceEvent?.internal&&i?.(s.sourceEvent,bo(s.transform))}}function ig({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:i,onPaneContextMenu:s}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,s&&jc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&s(a.sourceEvent),e.usedRightMouseButton=!1,o(!1),i)){const c=bo(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(a.sourceEvent,c)},n?150:0)}}}function sg({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:i,panOnScroll:s,zoomOnDoubleClick:a,userSelectionActive:c,noWheelClassName:u,noPanClassName:l,lib:h,connectionInProgress:f}){return d=>{const p=t||n,y=o&&d.ctrlKey,_=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(ht(d,`${h}-flow__node`)||ht(d,`${h}-flow__edge`)||ht(d,`${h}-flow__selection`)||ht(d,`${h}-flow__nodesselection`)))return!0;if(!i&&!p&&!s&&!a&&!o||c||f&&!_||ht(d,u)&&_||ht(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&&!y&&_||!i&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(i)&&!i.includes(d.button)&&d.type==="mousedown")return!1;const w=Array.isArray(i)&&i.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||_||e)&&w}}function ag({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:i,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 S=N[0];S&&(f=[[0,0],[S.contentRect.width,S.contentRect.height]])}):null)?.observe(e);const p=sc().extent(()=>f).scaleExtent([t,n]).translateExtent(o),y=Ie(e).call(p);m({x:i.x,y:i.y,zoom:Lt(i.zoom,t,n)},[[0,0],[h.width,h.height]],o);const _=y.on("wheel.zoom"),w=y.on("dblclick.zoom");p.wheelDelta(Dc);async function v(N,S){return y?new Promise(I=>{p?.interpolate(S?.interpolate==="linear"?nn:Yn).transform(Xo(y,S?.duration,S?.ease,()=>I(!0)),N)}):!1}function k({noWheelClassName:N,noPanClassName:S,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:$,panOnDrag:R,panOnScrollMode:D,panOnScrollSpeed:B,preventScrolling:z,zoomOnPinch:O,zoomOnScroll:F,zoomOnDoubleClick:U,panActivationKeyPressed:K=!1,zoomActivationKeyPressed:ie,lib:q,onTransformChange:H,connectionInProgress:X,paneClickDistance:te,selectionOnDrag:Q}){M&&!l.isZoomingOrPanning&&g();const Y=$&&!ie&&!M;p.clickDistance(Q?1/0:!Le(te)||te<0?0:te);const ee=Y?tg({zoomPanValues:l,noWheelClassName:N,d3Selection:y,d3Zoom:p,panOnScrollMode:D,panOnScrollSpeed:B,zoomOnPinch:O,onPanZoomStart:a,onPanZoom:s,onPanZoomEnd:c}):ng({noWheelClassName:N,preventScrolling:z,d3ZoomHandler:_});y.on("wheel.zoom",ee,{passive:!1});const se=og({zoomPanValues:l,onDraggingChange:u,onPanZoomStart:a});p.on("start",se);const J=rg({zoomPanValues:l,panOnDrag:R,onPaneContextMenu:!!I,onPanZoom:s,onTransformChange:H});p.on("zoom",J);const ce=ig({zoomPanValues:l,panOnDrag:R,panOnScroll:$,onPaneContextMenu:I,onPanZoomEnd:c,onDraggingChange:u});p.on("end",ce);const ye=sg({panActivationKeyPressed:K,zoomActivationKeyPressed:ie,panOnDrag:R,zoomOnScroll:F,panOnScroll:$,zoomOnDoubleClick:U,zoomOnPinch:O,userSelectionActive:M,noPanClassName:S,noWheelClassName:N,lib:q,connectionInProgress:X});p.filter(ye),U?y.on("dblclick.zoom",w):y.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function m(N,S,I){const M=Yo(N),$=p?.constrain()(M,S,I);return $&&await v($),$}async function C(N,S){const I=Yo(N);return await v(I,S),I}function b(N){if(y){const S=Yo(N),I=y.property("__zoom");(I.k!==N.zoom||I.x!==N.x||I.y!==N.y)&&p?.transform(y,S,null,{sync:!0})}}function E(){const N=y?ic(y.node()):{x:0,y:0,k:1};return{x:N.x,y:N.y,zoom:N.k}}async function A(N,S){return y?new Promise(I=>{p?.interpolate(S?.interpolate==="linear"?nn:Yn).scaleTo(Xo(y,S?.duration,S?.ease,()=>I(!0)),N)}):!1}async function P(N,S){return y?new Promise(I=>{p?.interpolate(S?.interpolate==="linear"?nn:Yn).scaleBy(Xo(y,S?.duration,S?.ease,()=>I(!0)),N)}):!1}function L(N){p?.scaleExtent(N)}function j(N){p?.translateExtent(N)}function V(N){const S=!Le(N)||N<0?0:N;p?.clickDistance(S)}return{update:k,destroy:g,setViewport:C,setViewportConstrained:m,getViewport:E,scaleTo:A,scaleBy:P,setScaleExtent:L,setTranslateExtent:j,syncViewport:b,setClickDistance:V}}var zt;(function(e){e.Line="line",e.Handle="handle"})(zt||(zt={}));function cg({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:i,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&&i&&(u[0]=u[0]*-1),c&&s&&(u[1]=u[1]*-1),u}function us(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:i}}function lt(e,t){return Math.max(0,t-e)}function dt(e,t){return Math.max(0,e-t)}function On(e,t,n){return Math.max(0,t-e,e-n)}function hs(e,t){return e?!t:t}function lg(e,t,n,o,i,s,a,c){let{affectsX:u,affectsY:l}=t;const{isHorizontal:h,isVertical:f}=t,d=h&&f,{xSnapped:p,ySnapped:y}=n,{minWidth:_,maxWidth:w,minHeight:v,maxHeight:k}=o,{x:g,y:m,width:C,height:b,aspectRatio:E}=e;let A=Math.floor(h?p-e.pointerX:0),P=Math.floor(f?y-e.pointerY:0);const L=C+(u?-A:A),j=b+(l?-P:P),V=-s[0]*C,N=-s[1]*b;let S=On(L,_,w),I=On(j,v,k);if(a){let R=0,D=0;u&&A<0?R=lt(g+A+V,a[0][0]):!u&&A>0&&(R=dt(g+L+V,a[1][0])),l&&P<0?D=lt(m+P+N,a[0][1]):!l&&P>0&&(D=dt(m+j+N,a[1][1])),S=Math.max(S,R),I=Math.max(I,D)}if(c){let R=0,D=0;u&&A>0?R=dt(g+A,c[0][0]):!u&&A<0&&(R=lt(g+L,c[1][0])),l&&P>0?D=dt(m+P,c[0][1]):!l&&P<0&&(D=lt(m+j,c[1][1])),S=Math.max(S,R),I=Math.max(I,D)}if(i){if(h){const R=On(L/E,v,k)*E;if(S=Math.max(S,R),a){let D=0;!u&&!l||u&&!l&&d?D=dt(m+N+L/E,a[1][1])*E:D=lt(m+N+(u?A:-A)/E,a[0][1])*E,S=Math.max(S,D)}if(c){let D=0;!u&&!l||u&&!l&&d?D=lt(m+L/E,c[1][1])*E:D=dt(m+(u?A:-A)/E,c[0][1])*E,S=Math.max(S,D)}}if(f){const R=On(j*E,_,w)/E;if(I=Math.max(I,R),a){let D=0;!u&&!l||l&&!u&&d?D=dt(g+j*E+V,a[1][0])/E:D=lt(g+(l?P:-P)*E+V,a[0][0])/E,I=Math.max(I,D)}if(c){let D=0;!u&&!l||l&&!u&&d?D=lt(g+j*E,c[1][0])/E:D=dt(g+(l?P:-P)*E,c[0][0])/E,I=Math.max(I,D)}}}P=P+(P<0?I:-I),A=A+(A<0?S:-S),i&&(d?L>j*E?P=(hs(u,l)?-A:A)/E:A=(hs(u,l)?-P:P)*E:h?(P=A/E,l=u):(A=P*E,u=l));const M=u?g+A:g,$=l?m+P:m;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 Rc={width:0,height:0,x:0,y:0},dg={...Rc,pointerX:0,pointerY:0,aspectRatio:1};function ug(e,t,n){const o=t.position.x+e.position.x,i=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,i-u],[o+s-c,i+a-u]]}function hg({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:i}){const s=Ie(e);let a={controlDirection:us("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:y,onResizeEnd:_,shouldResize:w}){let v={...Rc},k={...dg};a={boundaries:h,resizeDirection:d,keepAspectRatio:f,controlDirection:us(l)};let g,m=null,C=[],b,E,A;const P=Wa().on("start",L=>{const{nodeLookup:j,transform:V,snapGrid:N,snapToGrid:S,nodeOrigin:I,paneDomNode:M}=n();if(g=j.get(t),!g)return;m=M?.getBoundingClientRect()??null;const{xSnapped:$,ySnapped:R}=on(L.sourceEvent,{transform:V,snapGrid:N,snapToGrid:S,containerBounds:m});v={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},k={...v,pointerX:$,pointerY:R,aspectRatio:v.width/v.height},b=void 0,E=St(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(b=j.get(g.parentId)),b&&g.extent==="parent"&&(E=[[0,0],[b.measured.width,b.measured.height]]),C=[],A=void 0;for(const[D,B]of j)if(B.parentId===t&&(C.push({id:D,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const z=ug(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,{...v})}).on("drag",L=>{const{transform:j,snapGrid:V,snapToGrid:N,nodeOrigin:S}=n(),I=on(L.sourceEvent,{transform:j,snapGrid:V,snapToGrid:N,containerBounds:m}),M=[];if(!g)return;const{x:$,y:R,width:D,height:B}=v,z={},O=g.origin??S,{width:F,height:U,x:K,y:ie}=lg(k,a.controlDirection,I,a.boundaries,a.keepAspectRatio,O,E,A),q=F!==D,H=U!==B,X=K!==$&&q,te=ie!==R&&H;if(!X&&!te&&!q&&!H)return;const Q={prevValues:{...v},startX:k.x,startY:k.y,childNodes:C.map(J=>({...J,position:{...J.position}}))};if((X||te||O[0]===1||O[1]===1)&&(z.x=X?K:v.x,z.y=te?ie:v.y,v.x=z.x,v.y=z.y,C.length>0)){const J=K-$,ce=ie-R;for(const ye of C)ye.position={x:ye.position.x-J+O[0]*(F-D),y:ye.position.y-ce+O[1]*(U-B)},M.push(ye)}if((q||H)&&(z.width=q&&(!a.resizeDirection||a.resizeDirection==="horizontal")?F:v.width,z.height=H&&(!a.resizeDirection||a.resizeDirection==="vertical")?U:v.height,v.width=z.width,v.height=z.height),b&&g.expandParent){const J=O[0]*(z.width??0);z.x&&z.x<J&&(v.x=J,k.x=k.x-(z.x-J));const ce=O[1]*(z.height??0);z.y&&z.y<ce&&(v.y=ce,k.y=k.y-(z.y-ce))}const Y=cg({width:v.width,prevWidth:D,height:v.height,prevHeight:B,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),ee={...v,direction:Y};if(w?.(L,ee)===!1){v=Q.prevValues,k.x=Q.startX,k.y=Q.startY,C.forEach((J,ce)=>{J.position=Q.childNodes[ce].position});return}y?.(L,ee),o(z,M)}).on("end",L=>{_?.(L,{...v}),i?.({...v})});s.call(P)}function u(){s.on(".drag",null)}return{update:c,destroy:u}}function fg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function pg(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function o(){var i=!1;try{i=this instanceof o}catch{}return i?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 i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}),n}var Zo={exports:{}},qo={};const Oc=pg(Dd);var Go={exports:{}},Ko={};var fs;function gg(){if(fs)return Ko;fs=1;var e=Oc;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,i=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function c(f,d){var p=d(),y=o({inst:{value:p,getSnapshot:d}}),_=y[0].inst,w=y[1];return s(function(){_.value=p,_.getSnapshot=d,u(_)&&w({inst:_})},[f,p,d]),i(function(){return u(_)&&w({inst:_}),f(function(){u(_)&&w({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 Ko.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,Ko}var ps;function mg(){return ps||(ps=1,Go.exports=gg()),Go.exports}var gs;function yg(){if(gs)return qo;gs=1;var e=Oc,t=mg();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,i=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,c=e.useMemo,u=e.useDebugValue;return qo.useSyncExternalStoreWithSelector=function(l,h,f,d,p){var y=s(null);if(y.current===null){var _={hasValue:!1,value:null};y.current=_}else _=y.current;y=c(function(){function v(b){if(!k){if(k=!0,g=b,b=d(b),p!==void 0&&_.hasValue){var E=_.value;if(p(E,b))return m=E}return m=b}if(E=m,o(g,b))return E;var A=d(b);return p!==void 0&&p(E,A)?(g=b,E):(g=b,m=A)}var k=!1,g,m,C=f===void 0?null:f;return[function(){return v(h())},C===null?void 0:function(){return v(C())}]},[h,f,d,p]);var w=i(l,y[0],y[1]);return a(function(){_.hasValue=!0,_.value=w},[w]),u(w),w},qo}var ms;function vg(){return ms||(ms=1,Zo.exports=yg()),Zo.exports}var _g=vg();const wg=fg(_g),xg={},ys=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(y=>y(t,p))}},i=()=>t,u={setState:o,getState:i,getInitialState:()=>l,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(xg?"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,i,u);return u},bg=e=>e?ys(e):ys,{useDebugValue:kg}=Aa,{useSyncExternalStoreWithSelector:Sg}=wg,Cg=e=>e;function Lc(e,t=Cg,n){const o=Sg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return kg(o),o}const vs=(e,t)=>{const n=bg(e),o=(i,s=t)=>Lc(n,i,s);return Object.assign(o,n),o},Eg=(e,t)=>e?vs(e,t):vs;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,i]of e)if(!Object.is(i,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 ko=Ut(null),Ng=ko.Provider,Hc=Be.error001("react");function le(e,t){const n=at(ko);if(n===null)throw new Error(Hc);return Lc(n,e,t)}function he(){const e=at(ko);if(e===null)throw new Error(Hc);return ve(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const _s={display:"none"},Ig={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},zc="react-flow__node-desc",Bc="react-flow__edge-desc",Mg="react-flow__aria-live",Ag=e=>e.ariaLiveMessage,$g=e=>e.ariaLabelConfig;function Pg({rfId:e}){const t=le(Ag);return r("div",{id:`${Mg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Ig,children:t})}function Tg({rfId:e,disableKeyboardA11y:t}){const n=le($g);return r(Z,{children:[r("div",{id:`${zc}-${e}`,style:_s,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r("div",{id:`${Bc}-${e}`,style:_s,children:n["edge.a11yDescription.default"]}),!t&&r(Pg,{rfId:e})]})}const So=po(({position:e="top-left",children:t,className:n,style:o,...i},s)=>{const a=`${e}`.split("-");return r("div",{className:me(["react-flow__panel",n,...a]),style:o,ref:s,...i,children:t})});So.displayName="Panel";const ws="https://reactflow.dev?utm_source=attribution";function jg({proOptions:e,position:t="bottom-right"}){return ne(()=>{},[]),e?.hideAttribution?null:r(So,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${ws}`,children:r("a",{href:ws,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Dg=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 Rg(e,t){return pe(e.selectedNodes.map(Ln),t.selectedNodes.map(Ln))&&pe(e.selectedEdges.map(Ln),t.selectedEdges.map(Ln))}function Og({onSelectionChange:e}){const t=he(),{selectedNodes:n,selectedEdges:o}=le(Dg,Rg);return ne(()=>{const i={nodes:n,edges:o};e?.(i),t.getState().onSelectionChangeHandlers.forEach(s=>s(i))},[n,o,e]),null}const Lg=e=>!!e.onSelectionChangeHandlers;function Hg({onSelectionChange:e}){const t=le(Lg);return e||t?r(Og,{onSelectionChange:e}):null}const Vc=[0,0],zg={x:0,y:0,zoom:1},Bg=["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"],xs=[...Bg,"rfId"],Vg=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}),bs={translateExtent:dn,nodeOrigin:Vc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Fg(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:i,setTranslateExtent:s,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:u}=le(Vg,pe),l=he();ne(()=>(u(e.defaultNodes,e.defaultEdges),()=>{h.current=bs,c()}),[]);const h=re(bs);return ne(()=>{for(const f of xs){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"?i(d):f==="translateExtent"?s(d):f==="nodeExtent"?a(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:Cp(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}h.current=e},xs.map(f=>e[f])),null}function ks(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Ug(e){const[t,n]=W(e==="system"?null:e);return ne(()=>{if(e!=="system"){n(e);return}const o=ks(),i=()=>n(o?.matches?"dark":"light");return i(),o?.addEventListener("change",i),()=>{o?.removeEventListener("change",i)}},[e]),t!==null?t:ks()?.matches?"dark":"light"}const Ss=typeof document<"u"?document:null;function pn(e=null,t={target:Ss,actInsideInputWithModifier:!0}){const[n,o]=W(!1),i=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(i.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!i.current||i.current&&!l)&&wc(p))return!1;const _=Es(p.code,c);if(s.current.add(p[_]),Cs(a,s.current,!1)){const w=p.composedPath?.()?.[0]||p.target,v=w?.nodeName==="BUTTON"||w?.nodeName==="A";t.preventDefault!==!1&&(i.current||!v)&&p.preventDefault(),o(!0)}},f=p=>{const y=Es(p.code,c);Cs(a,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(p[y]),p.key==="Meta"&&s.current.clear(),i.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 Cs(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(i=>t.has(i)))}function Es(e,t){return t.includes(e)?"code":"key"}const Wg=()=>{const e=he();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,i,s],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??o,y:t.y??i,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:i,minZoom:s,maxZoom:a,panZoom:c}=e.getState(),u=Jr(t,o,i,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:i,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??i,f=n.snapToGrid??s;return kn(l,o,f,h)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:i,y:s}=o.getBoundingClientRect(),a=Ht(t,n);return{x:a.x+i,y:a.y+s}}}),[])};function Fc(e,t){const n=[],o=new Map,i=[];for(const s of e)if(s.type==="add"){i.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)Yg(u,c);n.push(c)}return i.length&&i.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function Yg(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 Uc(e,t){return Fc(e,t)}function Xg(e,t){return Fc(e,t)}function mt(e,t){return{id:e,type:"select",selected:t}}function Mt(e,t=new Set,n=!1){const o=[];for(const[i,s]of e){const a=t.has(i);!(s.selected===void 0&&!a)&&s.selected!==a&&(n&&(s.selected=a),o.push(mt(s.id,a)))}return o}function Ns({items:e=[],lookup:t}){const n=[],o=new Map(e.map(i=>[i.id,i]));for(const[i,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:i})}for(const[i]of t)o.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Is(e){return{id:e.id,type:"remove"}}const Zg=gc();function qg(e,t,n={}){return $p(e,t,{...n,onError:n.onError??Zg})}const Ms=e=>mp(e),Gg=e=>dc(e);function Wc(e){return po(e)}const Yc=typeof window<"u"?st:ne;function As(e){const[t,n]=W(BigInt(0)),[o]=W(()=>Kg(()=>n(i=>i+BigInt(1))));return Yc(()=>{const i=o.get();i.length&&(e(i),o.reset())},[t]),o}function Kg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Xc=Ut(null);function Qg({children:e}){const t=he(),n=Me(c=>{const{nodes:u=[],setNodes:l,hasDefaultNodes:h,onNodesChange:f,nodeLookup:d,fitViewQueued:p,onNodesChangeMiddlewareMap:y}=t.getState();let _=u;for(const v of c)_=typeof v=="function"?v(_):v;let w=Ns({items:_,lookup:d});for(const v of y.values())w=v(w);h&&l(_),w.length>0?f?.(w):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:k,setNodes:g}=t.getState();v&&g(k)})},[]),o=As(n),i=Me(c=>{const{edges:u=[],setEdges:l,hasDefaultEdges:h,onEdgesChange:f,edgeLookup:d}=t.getState();let p=u;for(const y of c)p=typeof y=="function"?y(p):y;h?l(p):f&&f(Ns({items:p,lookup:d}))},[]),s=As(i),a=ve(()=>({nodeQueue:o,edgeQueue:s}),[]);return r(Xc.Provider,{value:a,children:e})}function Jg(){const e=at(Xc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const em=e=>!!e.panZoom;function si(){const e=Wg(),t=he(),n=Jg(),o=le(em),i=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(),y=Ms(f)?f:d.get(f.id),_=y.parentId?yc(y.position,y.measured,y.parentId,d,p):y.position,w={...y,position:_,width:y.measured?.width??y.width,height:y.measured?.height??y.height};return hn(w)},l=(f,d,p={replace:!1})=>{a(y=>y.map(_=>{if(_.id===f){const w=typeof d=="function"?d(_):d;return p.replace&&Ms(w)?w:{..._,...w}}return _}))},h=(f,d,p={replace:!1})=>{c(y=>y.map(_=>{if(_.id===f){const w=typeof d=="function"?d(_):d;return p.replace&&Gg(w)?w:{..._,...w}}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(),[y,_,w]=p;return{nodes:f.map(v=>({...v})),edges:d.map(v=>({...v})),viewport:{x:y,y:_,zoom:w}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:p,edges:y,onNodesDelete:_,onEdgesDelete:w,triggerNodeChanges:v,triggerEdgeChanges:k,onDelete:g,onBeforeDelete:m}=t.getState(),{nodes:C,edges:b}=await xp({nodesToRemove:f,edgesToRemove:d,nodes:p,edges:y,onBeforeDelete:m}),E=b.length>0,A=C.length>0;if(E){const P=b.map(Is);w?.(b),k(P)}if(A){const P=C.map(Is);_?.(C),v(P)}return(A||E)&&g?.({nodes:C,edges:b}),{deletedNodes:C,deletedEdges:b}},getIntersectingNodes:(f,d=!0,p)=>{const y=es(f),_=y?f:u(f),w=p!==void 0;return _?(p||t.getState().nodes).filter(v=>{const k=t.getState().nodeLookup.get(v.id);if(k&&!y&&(v.id===f.id||!k.internals.positionAbsolute))return!1;const g=hn(w?v:k),m=uo(g,_);return d&&m>0||m>=g.width*g.height||m>=_.width*_.height}):[]},isNodeIntersecting:(f,d,p=!0)=>{const _=es(f)?f:u(f);if(!_)return!1;const w=uo(_,d);return p&&w>0||w>=d.width*d.height||w>=_.width*_.height},updateNode:l,updateNodeData:(f,d,p={replace:!1})=>{l(f,y=>{const _=typeof d=="function"?d(y):d;return p.replace?{...y,data:_}:{...y,data:{...y.data,..._}}},p)},updateEdge:h,updateEdgeData:(f,d,p={replace:!1})=>{h(f,y=>{const _=typeof d=="function"?d(y):d;return p.replace?{...y,data:_}:{...y,data:{...y.data,..._}}},p)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:p}=t.getState();return yp(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??Sp();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(p=>[...p]),d.promise}}},[]);return ve(()=>({...i,...e,viewportInitialized:o}),[o])}const $s=e=>e.selected,tm=typeof window<"u"?window:void 0;function nm({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=he(),{deleteElements:o}=si(),i=pn(e,{actInsideInputWithModifier:!1}),s=pn(t,{target:tm});ne(()=>{if(i){const{edges:a,nodes:c}=n.getState();o({nodes:c.filter($s),edges:a.filter($s)}),n.setState({nodesSelectionActive:!1})}},[i]),ne(()=>{n.setState({multiSelectionActive:s})},[s])}function om(e){const t=he();ne(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=ei(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},rm=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function im({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panActivationKeyPressed:i,panOnScrollSpeed:s=.5,panOnScrollMode:a=_t.Free,zoomOnDoubleClick:c=!0,panOnDrag:u=!0,defaultViewport:l,translateExtent:h,minZoom:f,maxZoom:d,zoomActivationKeyCode:p,preventScrolling:y=!0,children:_,noWheelClassName:w,noPanClassName:v,onViewportChange:k,isControlledViewport:g,paneClickDistance:m,selectionOnDrag:C}){const b=he(),E=re(null),{userSelectionActive:A,lib:P,connectionInProgress:L}=le(rm,pe),j=pn(p),V=re();om(E);const N=Me(S=>{k?.({x:S[0],y:S[1],zoom:S[2]}),g||b.setState({transform:S})},[k,g]);return ne(()=>{if(E.current){V.current=ag({domNode:E.current,minZoom:f,maxZoom:d,translateExtent:h,viewport:l,onDraggingChange:$=>b.setState(R=>R.paneDragging===$?R:{paneDragging:$}),onPanZoomStart:($,R)=>{const{onViewportChangeStart:D,onMoveStart:B}=b.getState();B?.($,R),D?.(R)},onPanZoom:($,R)=>{const{onViewportChange:D,onMove:B}=b.getState();B?.($,R),D?.(R)},onPanZoomEnd:($,R)=>{const{onViewportChangeEnd:D,onMoveEnd:B}=b.getState();B?.($,R),D?.(R)}});const{x:S,y:I,zoom:M}=V.current.getViewport();return b.setState({panZoom:V.current,transform:[S,I,M],domNode:E.current.closest(".react-flow")}),()=>{V.current?.destroy()}}},[]),ne(()=>{V.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panActivationKeyPressed:i,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:c,panOnDrag:u,zoomActivationKeyPressed:j,preventScrolling:y,noPanClassName:v,userSelectionActive:A,noWheelClassName:w,lib:P,onTransformChange:N,connectionInProgress:L,selectionOnDrag:C,paneClickDistance:m})},[e,t,n,o,i,s,a,c,u,j,y,v,A,w,P,N,L,C,m]),r("div",{className:"react-flow__renderer",ref:E,style:Co,children:_})}const sm=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function am(){const{userSelectionActive:e,userSelectionRect:t}=le(sm,pe);return e&&t?r("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 Qo=(e,t)=>n=>{n.target===t.current&&e?.(n)},cm=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function lm({isSelecting:e,selectionKeyPressed:t,selectionMode:n=un.Full,panOnDrag:o,autoPanOnSelection:i,paneClickDistance:s,selectionOnDrag:a,onSelectionStart:c,onSelectionEnd:u,onPaneClick:l,onPaneContextMenu:h,onPaneScroll:f,onPaneMouseEnter:d,onPaneMouseMove:p,onPaneMouseLeave:y,children:_}){const w=re(0),v=he(),{userSelectionActive:k,elementsSelectable:g,dragging:m,panBy:C,autoPanSpeed:b}=le(cm,pe),E=g&&(e||k),A=re(null),P=re(),L=re(new Set),j=re(new Set),V=re(!1),N=re(!1),S=re({x:0,y:0}),I=re(!1),M=H=>{if(N.current||V.current||v.getState().connection.inProgress){N.current=!1,V.current=!1;return}l?.(H),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},$=H=>{if(Array.isArray(o)&&o?.includes(2)){H.preventDefault();return}h?.(H)},R=f?H=>f(H):void 0,D=H=>{N.current&&(H.stopPropagation(),N.current=!1)},B=H=>{if(H.pointerType==="touch"&&o!==!1&&!t)return;const{domNode:X,transform:te}=v.getState();if(P.current=X?.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=kn({x:se,y:J},te);v.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:se,y:J}}),Q||(H.stopPropagation(),H.preventDefault())};function z(H,X){const{userSelectionRect:te}=v.getState();if(!te)return;const{transform:Q,nodeLookup:Y,edgeLookup:ee,connectionLookup:se,triggerNodeChanges:J,triggerEdgeChanges:ce,defaultEdgeOptions:ye}=v.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:X<Ne?X:Ne,width:Math.abs(H-$e),height:Math.abs(X-Ne)},ct=L.current,je=j.current;L.current=new Set(Kr(Y,Te,Q,n===un.Partial,!0).map(_e=>_e.id)),j.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)&&j.current.add(we)}}if(!ts(ct,L.current)){const _e=Mt(Y,L.current,!0);J(_e)}if(!ts(je,j.current)){const _e=Mt(ee,j.current);ce(_e)}v.setState({userSelectionRect:Te,userSelectionActive:!0,nodesSelectionActive:!1})}function O(){if(!i||!P.current)return;const[H,X]=Qr(S.current,P.current,b);C({x:H,y:X}).then(te=>{if(!N.current||!te){w.current=requestAnimationFrame(O);return}const{x:Q,y:Y}=S.current;z(Q,Y),w.current=requestAnimationFrame(O)})}const F=()=>{cancelAnimationFrame(w.current),w.current=0,I.current=!1};ne(()=>()=>F(),[]);const U=H=>{const{userSelectionRect:X,transform:te,resetSelectedElements:Q}=v.getState();if(!P.current||!X)return;const{x:Y,y:ee}=He(H.nativeEvent,P.current);S.current={x:Y,y:ee};const se=Ht({x:X.startX,y:X.startY},te);if(!N.current){const J=t?0:s;if(Math.hypot(Y-se.x,ee-se.y)<=J)return;Q(),c?.(H)}N.current=!0,I.current||(O(),I.current=!0),z(Y,ee)},K=H=>{if(!E){H.target===A.current&&v.getState().connection.inProgress&&(V.current=!0);return}H.button===0&&(H.target?.releasePointerCapture?.(H.pointerId),!k&&H.target===A.current&&v.getState().userSelectionRect&&M?.(H),v.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(u?.(H),v.setState({nodesSelectionActive:L.current.size>0})),F())},ie=H=>{H.target?.releasePointerCapture?.(H.pointerId),F()},q=o===!0||Array.isArray(o)&&o.includes(0);return r("div",{className:me(["react-flow__pane",{draggable:q,dragging:m,selection:e}]),onClick:E?void 0:Qo(M,A),onContextMenu:Qo($,A),onWheel:Qo(R,A),onPointerEnter:E?void 0:d,onPointerMove:E?U:p,onPointerUp:K,onPointerCancel:E?ie:void 0,onPointerDownCapture:E?B:void 0,onClickCapture:E?D:void 0,onPointerLeave:y,ref:A,style:Co,children:[_,r(am,{})]})}function br({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:i,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())):i([e])}function Zc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:i,isSelectable:s,nodeClickDistance:a}){const c=he(),[u,l]=W(!1),h=re();return ne(()=>{if(!t)return h.current=Xp({getStoreItems:()=>c.getState(),onNodeMouseDown:f=>{br({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:i,nodeClickDistance:a})},[n,o,t,s,e,i,a]),u}const dm=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function qc(){const e=he();return Me(n=>{const{nodeExtent:o,snapToGrid:i,snapGrid:s,nodesDraggable:a,onError:c,updateNodePositions:u,nodeLookup:l,nodeOrigin:h}=e.getState(),f=new Map,d=dm(a),p=i?s[0]:5,y=i?s[1]:5,_=n.direction.x*p*n.factor,w=n.direction.y*y*n.factor;for(const[,v]of l){if(!d(v))continue;let k={x:v.internals.positionAbsolute.x+_,y:v.internals.positionAbsolute.y+w};i&&(k=bn(k,s));const{position:g,positionAbsolute:m}=uc({nodeId:v.id,nextPosition:k,nodeLookup:l,nodeExtent:o,nodeOrigin:h,onError:c});v.position=g,v.internals.positionAbsolute=m,f.set(v.id,v)}u(f)},[])}const ai=Ut(null),um=ai.Provider;ai.Consumer;const Gc=()=>at(ai),hm=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Kc=Ut(null);function fm({children:e}){const t=le(hm,pe);return r(Kc.Provider,{value:t,children:e})}function pm(){const e=at(Kc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const gm={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},mm=(e,t,n)=>o=>{const{connectionClickStartHandle:i,connectionMode:s,connection:a}=o,{fromHandle:c,toHandle:u,isValid:l}=a;if(!c&&!i)return gm;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:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:s===Ot.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!i,valid:h&&l}};function ym({type:e="source",position:t=G.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:i=!0,isConnectableEnd:s=!0,id:a,onConnect:c,children:u,className:l,onMouseDown:h,onTouchStart:f,...d},p){const y=a||null,_=e==="target",w=he(),v=Gc(),{connectOnClick:k,noPanClassName:g,rfId:m}=pm(),{connectingFrom:C,connectingTo:b,clickConnecting:E,isPossibleEndHandle:A,connectionInProcess:P,clickConnectionInProcess:L,valid:j}=le(mm(v,y,e),pe);v||w.getState().onError?.("010",Be.error010());const V=I=>{const{defaultEdgeOptions:M,onConnect:$,hasDefaultEdges:R}=w.getState(),D={...M,...I};if(R){const{edges:B,setEdges:z,onError:O}=w.getState();z(qg(D,B,{onError:O}))}$?.(D),c?.(D)},N=I=>{if(!v)return;const M=xc(I.nativeEvent);if(i&&(M&&I.button===0||!M)){const $=w.getState();xr.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:$.autoPanOnConnect,connectionMode:$.connectionMode,connectionRadius:$.connectionRadius,domNode:$.domNode,nodeLookup:$.nodeLookup,lib:$.lib,isTarget:_,handleId:y,nodeId:v,flowId:$.rfId,panBy:$.panBy,cancelConnection:$.cancelConnection,onConnectStart:$.onConnectStart,onConnectEnd:(...R)=>w.getState().onConnectEnd?.(...R),updateConnection:$.updateConnection,onConnect:V,isValidConnection:n||((...R)=>w.getState().isValidConnection?.(...R)??!0),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:$.autoPanSpeed,dragThreshold:$.connectionDragThreshold})}M?h?.(I):f?.(I)},S=I=>{const{onClickConnectStart:M,onClickConnectEnd:$,connectionClickStartHandle:R,connectionMode:D,isValidConnection:B,lib:z,rfId:O,nodeLookup:F,connection:U}=w.getState();if(!v||!R&&!i)return;if(!R){M?.(I.nativeEvent,{nodeId:v,handleId:y,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:v,type:e,id:y}});return}const K=_c(I.target),ie=n||B,{connection:q,isValid:H}=xr.isValid(I.nativeEvent,{handle:{nodeId:v,id:y,type:e},connectionMode:D,fromNodeId:R.nodeId,fromHandleId:R.id||null,fromType:R.type,isValidConnection:ie,flowId:O,doc:K,lib:z,nodeLookup:F});H&&q&&V(q);const X=structuredClone(U);delete X.inProgress,X.toPosition=X.toHandle?X.toHandle.position:null,$?.(I,X),w.setState({connectionClickStartHandle:null})};return r("div",{"data-handleid":y,"data-nodeid":v,"data-handlepos":t,"data-id":`${m}-${v}-${y}-${e}`,className:me(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,l,{source:!_,target:_,connectable:o,connectablestart:i,connectableend:s,clickconnecting:E,connectingfrom:C,connectingto:b,valid:j,connectionindicator:o&&(!P||A)&&(P||L?s:i)}]),onMouseDown:N,onTouchStart:N,onClick:k?S:void 0,ref:p,...d,children:u})}const Bt=ge(Wc(ym));function vm({data:e,isConnectable:t,sourcePosition:n=G.Bottom}){return r(Z,{children:[e?.label,r(Bt,{type:"source",position:n,isConnectable:t})]})}function _m({data:e,isConnectable:t,targetPosition:n=G.Top,sourcePosition:o=G.Bottom}){return r(Z,{children:[r(Bt,{type:"target",position:n,isConnectable:t}),e?.label,r(Bt,{type:"source",position:o,isConnectable:t})]})}function wm(){return null}function xm({data:e,isConnectable:t,targetPosition:n=G.Top}){return r(Z,{children:[r(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}},Ps={input:vm,default:_m,output:xm,group:wm};function bm(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 km=e=>{const{width:t,height:n,x:o,y:i}=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,${i}px)`}};function Sm({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=he(),{width:i,height:s,transformString:a,userSelectionActive:c}=le(km,pe),u=qc(),l=re(null);ne(()=>{n||l.current?.focus({preventScroll:!0})},[n]);const h=!c&&i!==null&&s!==null;if(Zc({nodeRef:l,disabled:!h}),!h)return null;const f=e?p=>{const y=o.getState().nodes.filter(_=>_.selected);e(p,y)}:void 0,d=p=>{Object.prototype.hasOwnProperty.call(ho,p.key)&&(p.preventDefault(),u({direction:ho[p.key],factor:p.shiftKey?4:1}))};return r("div",{className:me(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:r("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:i,height:s}})})}const Ts=typeof window<"u"?window:void 0,Cm=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Qc({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:l,selectionOnDrag:h,selectionMode:f,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:y,panActivationKeyCode:_,zoomActivationKeyCode:w,elementsSelectable:v,zoomOnScroll:k,zoomOnPinch:g,panOnScroll:m,panOnScrollSpeed:C,panOnScrollMode:b,zoomOnDoubleClick:E,panOnDrag:A,autoPanOnSelection:P,defaultViewport:L,translateExtent:j,minZoom:V,maxZoom:N,preventScrolling:S,onSelectionContextMenu:I,noWheelClassName:M,noPanClassName:$,disableKeyboardA11y:R,onViewportChange:D,isControlledViewport:B}){const{nodesSelectionActive:z,userSelectionActive:O}=le(Cm,pe),F=pn(l,{target:Ts}),U=pn(_,{target:Ts}),K=U||A,ie=U||m,q=h&&K!==!0,H=F||O||q;return nm({deleteKeyCode:u,multiSelectionKeyCode:y}),r(im,{onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:k,zoomOnPinch:g,panOnScroll:ie,panActivationKeyPressed:U,panOnScrollSpeed:C,panOnScrollMode:b,zoomOnDoubleClick:E,panOnDrag:!F&&K,defaultViewport:L,translateExtent:j,minZoom:V,maxZoom:N,zoomActivationKeyCode:w,preventScrolling:S,noWheelClassName:M,noPanClassName:$,onViewportChange:D,isControlledViewport:B,paneClickDistance:c,selectionOnDrag:q,children:r(lm,{onSelectionStart:d,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:K,autoPanOnSelection:P,isSelecting:!!H,selectionMode:f,selectionKeyPressed:F,paneClickDistance:c,selectionOnDrag:q,children:[e,z&&r(Sm,{onSelectionContextMenu:I,noPanClassName:$,disableKeyboardA11y:R})]})})}Qc.displayName="FlowRenderer";const Em=ge(Qc),Nm=e=>t=>e?Kr(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 Im(e){return le(Me(Nm(e),[e]),pe)}const Mm=e=>e.updateNodeInternals;function Am(){const e=le(Mm),[t]=W(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(i=>{const s=i.target.getAttribute("data-id");o.set(s,{id:s,nodeElement:i.target,force:!0})}),e(o)}));return ne(()=>()=>{t?.disconnect()},[t]),t}function $m({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const i=he(),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,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function Pm({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:i,onContextMenu:s,onDoubleClick:a,nodesDraggable:c,elementsSelectable:u,nodesConnectable:l,nodesFocusable:h,resizeObserver:f,noDragClassName:d,noPanClassName:p,disableKeyboardA11y:y,rfId:_,nodeTypes:w,nodeClickDistance:v,onError:k}){const{node:g,internals:m,isParent:C}=le(H=>{const X=H.nodeLookup.get(e),te=H.parentLookup.has(e);return{node:X,internals:X.internals,isParent:te}},pe);let b=g.type||"default",E=w?.[b]||Ps[b];E===void 0&&(k?.("003",Be.error003(b)),b="default",E=w?.default||Ps.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"),j=!!(g.focusable||h&&typeof g.focusable>"u"),V=he(),N=mc(g),S=$m({node:g,nodeType:b,hasDimensions:N,resizeObserver:f}),I=Zc({nodeRef:S,disabled:g.hidden||!A,noDragClassName:d,handleSelector:g.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:v}),M=qc();if(g.hidden)return null;const $=Fe(g),R=bm(g),D=P||A||t||n||o||i,B=n?H=>n(H,{...m.userNode}):void 0,z=o?H=>o(H,{...m.userNode}):void 0,O=i?H=>i(H,{...m.userNode}):void 0,F=s?H=>s(H,{...m.userNode}):void 0,U=a?H=>a(H,{...m.userNode}):void 0,K=H=>{const{selectNodesOnDrag:X,nodeDragThreshold:te}=V.getState();P&&(!X||!A||te>0)&&br({id:e,store:V,nodeRef:S}),t&&t(H,{...m.userNode})},ie=H=>{if(!(wc(H.nativeEvent)||y)){if(ac.includes(H.key)&&P){const X=H.key==="Escape";br({id:e,store:V,unselect:X,nodeRef:S})}else if(A&&g.selected&&Object.prototype.hasOwnProperty.call(ho,H.key)){H.preventDefault();const{ariaLabelConfig:X}=V.getState();V.setState({ariaLiveMessage:X["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~m.positionAbsolute.x,y:~~m.positionAbsolute.y})}),M({direction:ho[H.key],factor:H.shiftKey?4:1})}}},q=()=>{if(y||!S.current?.matches(":focus-visible"))return;const{transform:H,width:X,height:te,autoPanOnNodeFocus:Q,setCenter:Y}=V.getState();if(!Q)return;Kr(new Map([[e,g]]),{x:0,y:0,width:X,height:te},H,!0).length>0||Y(g.position.x+$.width/2,g.position.y+$.height/2,{zoom:H[2]})};return r("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:S,style:{zIndex:m.z,transform:`translate(${m.positionAbsolute.x}px,${m.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:N?"visible":"hidden",...g.style,...R},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:z,onMouseLeave:O,onContextMenu:F,onClick:K,onDoubleClick:U,onKeyDown:j?ie:void 0,tabIndex:j?0:void 0,onFocus:j?q:void 0,role:g.ariaRole??(j?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${zc}-${_}`,"aria-label":g.ariaLabel,...g.domAttributes,children:r(um,{value:e,children:r(E,{id:e,data:g.data,type:b,positionAbsoluteX:m.positionAbsolute.x,positionAbsoluteY:m.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:m.z,parentId:g.parentId,...$})})})}var Tm=ge(Pm);const jm=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Jc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:o,onError:i}=le(jm,pe),s=Im(e.onlyRenderVisibleElements),a=Am();return r("div",{className:"react-flow__nodes",style:Co,children:s.map(c=>r(Tm,{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:i},c))})}Jc.displayName="NodeRenderer";const Dm=ge(Jc);function Rm(e){return le(Me(n=>{if(!e)return n.edges.map(i=>i.id);const o=[];if(n.width&&n.height)for(const i of n.edges){const s=n.nodeLookup.get(i.source),a=n.nodeLookup.get(i.target);s&&a&&Ip({sourceNode:s,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&o.push(i.id)}return o},[e]),pe)}const Om=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Lm=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},js={[co.Arrow]:Om,[co.ArrowClosed]:Lm};function Hm(e){const t=he();return ve(()=>Object.prototype.hasOwnProperty.call(js,e)?js[e]:(t.getState().onError?.("009",Be.error009(e)),null),[e])}const zm=({id:e,type:t,color:n,width:o=12.5,height:i=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:c="auto-start-reverse"})=>{const u=Hm(t);return u?r("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:c,refX:"0",refY:"0",children:r(u,{color:n,strokeWidth:a})}):null},el=({defaultColor:e,rfId:t})=>{const n=le(s=>s.edges),o=le(s=>s.defaultEdgeOptions),i=ve(()=>Rp(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return i.length?r("svg",{className:"react-flow__marker","aria-hidden":"true",children:r("defs",{children:i.map(s=>r(zm,{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};el.displayName="MarkerDefinitions";var Bm=ge(el);function tl({x:e,y:t,label:n,labelStyle:o,labelShowBg:i=!0,labelBgStyle:s,labelBgPadding:a=[2,4],labelBgBorderRadius:c=2,children:u,className:l,...h}){const[f,d]=W({x:1,y:0,width:0,height:0}),p=me(["react-flow__edge-textwrapper",l]),y=re(null);return ne(()=>{if(y.current){const _=y.current.getBBox();d({x:_.x,y:_.y,width:_.width,height:_.height})}},[n]),n?r("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...h,children:[i&&r("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}),r("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:y,style:o,children:n}),u]}):null}tl.displayName="EdgeText";const Vm=ge(tl);function Eo({path:e,labelX:t,labelY:n,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:u,interactionWidth:l=20,...h}){return r(Z,{children:[r("path",{...h,d:e,fill:"none",className:me(["react-flow__edge-path",h.className])}),l?r("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&Le(t)&&Le(n)?r(Vm,{x:t,y:n,label:o,labelStyle:i,labelShowBg:s,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:u}):null]})}function Ds({pos:e,x1:t,y1:n,x2:o,y2:i}){return e===G.Left||e===G.Right?[.5*(t+o),n]:[t,.5*(n+i)]}function nl({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:o,targetY:i,targetPosition:s=G.Top}){const[a,c]=Ds({pos:n,x1:e,y1:t,x2:o,y2:i}),[u,l]=Ds({pos:s,x1:o,y1:i,x2:e,y2:t}),[h,f,d,p]=bc({sourceX:e,sourceY:t,targetX:o,targetY:i,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:l});return[`M${e},${t} C${a},${c} ${u},${l} ${o},${i}`,h,f,d,p]}function ol(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:i,targetY:s,sourcePosition:a,targetPosition:c,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:w,interactionWidth:v})=>{const[k,g,m]=nl({sourceX:n,sourceY:o,sourcePosition:a,targetX:i,targetY:s,targetPosition:c}),C=e.isInternal?void 0:t;return r(Eo,{id:C,path:k,labelX:g,labelY:m,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:w,interactionWidth:v})})}const Fm=ol({isInternal:!1}),rl=ol({isInternal:!0});Fm.displayName="SimpleBezierEdge";rl.displayName="SimpleBezierEdgeInternal";function il(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:i,targetY:s,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,sourcePosition:p=G.Bottom,targetPosition:y=G.Top,markerEnd:_,markerStart:w,pathOptions:v,interactionWidth:k})=>{const[g,m,C]=vr({sourceX:n,sourceY:o,sourcePosition:p,targetX:i,targetY:s,targetPosition:y,borderRadius:v?.borderRadius,offset:v?.offset,stepPosition:v?.stepPosition}),b=e.isInternal?void 0:t;return r(Eo,{id:b,path:g,labelX:m,labelY:C,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,markerEnd:_,markerStart:w,interactionWidth:k})})}const sl=il({isInternal:!1}),al=il({isInternal:!0});sl.displayName="SmoothStepEdge";al.displayName="SmoothStepEdgeInternal";function cl(e){return ge(({id:t,...n})=>{const o=e.isInternal?void 0:t;return r(sl,{...n,id:o,pathOptions:ve(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const Um=cl({isInternal:!1}),ll=cl({isInternal:!0});Um.displayName="StepEdge";ll.displayName="StepEdgeInternal";function dl(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:i,targetY:s,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:y,interactionWidth:_})=>{const[w,v,k]=Cc({sourceX:n,sourceY:o,targetX:i,targetY:s}),g=e.isInternal?void 0:t;return r(Eo,{id:g,path:w,labelX:v,labelY:k,label:a,labelStyle:c,labelShowBg:u,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:f,style:d,markerEnd:p,markerStart:y,interactionWidth:_})})}const Wm=dl({isInternal:!1}),ul=dl({isInternal:!0});Wm.displayName="StraightEdge";ul.displayName="StraightEdgeInternal";function hl(e){return ge(({id:t,sourceX:n,sourceY:o,targetX:i,targetY:s,sourcePosition:a=G.Bottom,targetPosition:c=G.Top,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:w,pathOptions:v,interactionWidth:k})=>{const[g,m,C]=kc({sourceX:n,sourceY:o,sourcePosition:a,targetX:i,targetY:s,targetPosition:c,curvature:v?.curvature}),b=e.isInternal?void 0:t;return r(Eo,{id:b,path:g,labelX:m,labelY:C,label:u,labelStyle:l,labelShowBg:h,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:p,style:y,markerEnd:_,markerStart:w,interactionWidth:k})})}const Ym=hl({isInternal:!1}),fl=hl({isInternal:!0});Ym.displayName="BezierEdge";fl.displayName="BezierEdgeInternal";const Rs={default:fl,straight:ul,step:ll,smoothstep:al,simplebezier:rl},Os={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Xm=(e,t,n)=>n===G.Left?e-t:n===G.Right?e+t:e,Zm=(e,t,n)=>n===G.Top?e-t:n===G.Bottom?e+t:e,Ls="react-flow__edgeupdater";function Hs({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:i,onMouseEnter:s,onMouseOut:a,type:c}){return r("circle",{onMouseDown:i,onMouseEnter:s,onMouseOut:a,className:me([Ls,`${Ls}-${c}`]),cx:Xm(t,o,e),cy:Zm(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function qm({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:i,targetX:s,targetY:a,sourcePosition:c,targetPosition:u,onReconnect:l,onReconnectStart:h,onReconnectEnd:f,setReconnecting:d,setUpdateHover:p}){const y=he(),_=(m,C)=>{if(m.button!==0)return;const{autoPanOnConnect:b,domNode:E,connectionMode:A,connectionRadius:P,lib:L,onConnectStart:j,cancelConnection:V,nodeLookup:N,rfId:S,panBy:I,updateConnection:M}=y.getState(),$=C.type==="target",R=(z,O)=>{d(!1),f?.(z,n,C.type,O)},D=z=>l?.(n,z),B=(z,O)=>{d(!0),h?.(m,n,C.type),j?.(z,O)};xr.onPointerDown(m.nativeEvent,{autoPanOnConnect:b,connectionMode:A,connectionRadius:P,domNode:E,handleId:C.id,nodeId:C.nodeId,nodeLookup:N,isTarget:$,edgeUpdaterType:C.type,lib:L,flowId:S,cancelConnection:V,panBy:I,isValidConnection:(...z)=>y.getState().isValidConnection?.(...z)??!0,onConnect:D,onConnectStart:B,onConnectEnd:(...z)=>y.getState().onConnectEnd?.(...z),onReconnectEnd:R,updateConnection:M,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:m.currentTarget})},w=m=>_(m,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=m=>_(m,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>p(!0),g=()=>p(!1);return r(Z,{children:[(e===!0||e==="source")&&r(Hs,{position:c,centerX:o,centerY:i,radius:t,onMouseDown:w,onMouseEnter:k,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&r(Hs,{position:u,centerX:s,centerY:a,radius:t,onMouseDown:v,onMouseEnter:k,onMouseOut:g,type:"target"})]})}function Gm({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:i,onDoubleClick:s,onContextMenu:a,onMouseEnter:c,onMouseMove:u,onMouseLeave:l,reconnectRadius:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,rfId:y,edgeTypes:_,noPanClassName:w,onError:v,disableKeyboardA11y:k}){let g=le(Y=>Y.edgeLookup.get(e));const m=le(Y=>Y.defaultEdgeOptions);g=m?{...m,...g}:g;let C=g.type||"default",b=_?.[C]||Rs[C];b===void 0&&(v?.("011",Be.error011(C)),C="default",b=_?.default||Rs.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),[j,V]=W(!1),[N,S]=W(!1),I=he(),{zIndex:M=g.zIndex,sourceX:$,sourceY:R,targetX:D,targetY:B,sourcePosition:z,targetPosition:O}=le(Me(Y=>{const ee=Y.nodeLookup.get(g.source),se=Y.nodeLookup.get(g.target);if(!ee||!se)return Os;const J=Dp({id:e,sourceNode:ee,targetNode:se,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:Y.connectionMode,onError:v}),ce=Np({selected:g.selected,zIndex:g.zIndex,sourceNode:ee,targetNode:se,elevateOnSelect:Y.elevateEdgesOnSelect,zIndexMode:Y.zIndexMode});return{...J||Os,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,v]),pe),F=ve(()=>g.markerStart?`url('#${_r(g.markerStart,y)}')`:void 0,[g.markerStart,y]),U=ve(()=>g.markerEnd?`url('#${_r(g.markerEnd,y)}')`:void 0,[g.markerEnd,y]);if(g.hidden||$===null||R===null||D===null||B===null)return null;const K=Y=>{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])),i&&i(Y,g)},ie=s?Y=>{s(Y,{...g})}:void 0,q=a?Y=>{a(Y,{...g})}:void 0,H=c?Y=>{c(Y,{...g})}:void 0,X=u?Y=>{u(Y,{...g})}:void 0,te=l?Y=>{l(Y,{...g})}:void 0,Q=Y=>{if(!k&&ac.includes(Y.key)&&P){const{unselectNodesAndEdges:ee,addSelectedEdges:se}=I.getState();Y.key==="Escape"?(L.current?.blur(),ee({edges:[g]})):se([e])}};return r("svg",{style:{zIndex:M},children:r("g",{className:me(["react-flow__edge",`react-flow__edge-${C}`,g.className,w,{selected:g.selected,animated:g.animated,inactive:!P&&!i,updating:j,selectable:P}]),onClick:K,onDoubleClick:ie,onContextMenu:q,onMouseEnter:H,onMouseMove:X,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?`${Bc}-${y}`:void 0,ref:L,...g.domAttributes,children:[!N&&r(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:R,targetX:D,targetY:B,sourcePosition:z,targetPosition:O,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&&r(qm,{edge:g,isReconnectable:A,reconnectRadius:h,onReconnect:f,onReconnectStart:d,onReconnectEnd:p,sourceX:$,sourceY:R,targetX:D,targetY:B,sourcePosition:z,targetPosition:O,setUpdateHover:V,setReconnecting:S})]})})}var Km=ge(Gm);const Qm=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function pl({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:i,onReconnect:s,onEdgeContextMenu:a,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:l,onEdgeClick:h,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:p,onReconnectEnd:y,disableKeyboardA11y:_}){const{edgesFocusable:w,edgesReconnectable:v,elementsSelectable:k,onError:g}=le(Qm,pe),m=Rm(t);return r("div",{className:"react-flow__edges",children:[r(Bm,{defaultColor:e,rfId:n}),m.map(C=>r(Km,{id:C,edgesFocusable:w,edgesReconnectable:v,elementsSelectable:k,noPanClassName:i,onReconnect:s,onContextMenu:a,onMouseEnter:c,onMouseMove:u,onMouseLeave:l,onClick:h,reconnectRadius:f,onDoubleClick:d,onReconnectStart:p,onReconnectEnd:y,rfId:n,onError:g,edgeTypes:o,disableKeyboardA11y:_},C))]})}pl.displayName="EdgeRenderer";const Jm=ge(pl),zs=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function e0({children:e}){const t=he(),n=re(null),[o]=W(()=>t.getState().transform);return Yc(()=>{let i=null;const s=()=>{const a=t.getState().transform;i&&a[0]===i[0]&&a[1]===i[1]&&a[2]===i[2]||(i=a,n.current&&(n.current.style.transform=zs(a)))};return s(),t.subscribe(s)},[t]),r("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:zs(o)},children:e})}function t0(e){const t=si(),n=re(!1);ne(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const n0=e=>e.panZoom?.syncViewport;function o0(e){const t=le(n0),n=he();return ne(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function r0(e){return e.connection.inProgress?{...e.connection,to:kn(e.connection.to,e.transform)}:{...e.connection}}function i0(e){return r0}function s0(e){const t=i0();return le(t,pe)}const a0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function c0({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:i,width:s,height:a,isValid:c,inProgress:u}=le(a0,pe);return!(s&&i&&u)?null:r("svg",{style:e,width:s,height:a,className:"react-flow__connectionline react-flow__container",children:r("g",{className:me(["react-flow__connection",vc(c)]),children:r(gl,{style:t,type:n,CustomComponent:o,isValid:c})})})}const gl=({style:e,type:t=ft.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:i,from:s,fromNode:a,fromHandle:c,fromPosition:u,to:l,toNode:h,toHandle:f,toPosition:d,pointer:p}=s0();if(!i)return;if(n)return r(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:vc(o),toNode:h,toHandle:f,pointer:p});let y="";const _={sourceX:s.x,sourceY:s.y,sourcePosition:u,targetX:l.x,targetY:l.y,targetPosition:d};switch(t){case ft.Bezier:[y]=kc(_);break;case ft.SimpleBezier:[y]=nl(_);break;case ft.Step:[y]=vr({..._,borderRadius:0});break;case ft.SmoothStep:[y]=vr(_);break;default:[y]=Cc(_)}return r("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};gl.displayName="ConnectionLine";const l0={};function Bs(e=l0){re(e),he(),ne(()=>{},[e])}function d0(){he(),re(!1),ne(()=>{},[])}function ml({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:i,onNodeDoubleClick:s,onEdgeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:l,onNodeContextMenu:h,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:p,connectionLineType:y,connectionLineStyle:_,connectionLineComponent:w,connectionLineContainerStyle:v,selectionKeyCode:k,selectionOnDrag:g,selectionMode:m,multiSelectionKeyCode:C,panActivationKeyCode:b,zoomActivationKeyCode:E,deleteKeyCode:A,onlyRenderVisibleElements:P,elementsSelectable:L,defaultViewport:j,translateExtent:V,minZoom:N,maxZoom:S,preventScrolling:I,defaultMarkerColor:M,zoomOnScroll:$,zoomOnPinch:R,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:z,zoomOnDoubleClick:O,panOnDrag:F,autoPanOnSelection:U,onPaneClick:K,onPaneMouseEnter:ie,onPaneMouseMove:q,onPaneMouseLeave:H,onPaneScroll:X,onPaneContextMenu:te,paneClickDistance:Q,nodeClickDistance:Y,onEdgeContextMenu:ee,onEdgeMouseEnter:se,onEdgeMouseMove:J,onEdgeMouseLeave:ce,reconnectRadius:ye,onReconnect:Ee,onReconnectStart:$e,onReconnectEnd:Ne,noDragClassName:Te,noWheelClassName:ct,noPanClassName:je,disableKeyboardA11y:Ue,nodeExtent:_e,rfId:be,viewport:we,onViewportChange:xe,nodesDraggable:Wt}){return Bs(e),Bs(t),d0(),t0(n),o0(we),r(Em,{onPaneClick:K,onPaneMouseEnter:ie,onPaneMouseMove:q,onPaneMouseLeave:H,onPaneContextMenu:te,onPaneScroll:X,paneClickDistance:Q,deleteKeyCode:A,selectionKeyCode:k,selectionOnDrag:g,selectionMode:m,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:L,zoomOnScroll:$,zoomOnPinch:R,zoomOnDoubleClick:O,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:z,panOnDrag:F,autoPanOnSelection:U,defaultViewport:j,translateExtent:V,minZoom:N,maxZoom:S,onSelectionContextMenu:f,preventScrolling:I,noDragClassName:Te,noWheelClassName:ct,noPanClassName:je,disableKeyboardA11y:Ue,onViewportChange:xe,isControlledViewport:!!we,children:r(e0,{children:[r(Jm,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:a,onReconnect:Ee,onReconnectStart:$e,onReconnectEnd:Ne,onlyRenderVisibleElements:P,onEdgeContextMenu:ee,onEdgeMouseEnter:se,onEdgeMouseMove:J,onEdgeMouseLeave:ce,reconnectRadius:ye,defaultMarkerColor:M,noPanClassName:je,disableKeyboardA11y:Ue,rfId:be}),r(c0,{style:_,type:y,component:w,containerStyle:v}),r("div",{className:"react-flow__edgelabel-renderer"}),r(Dm,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:l,onNodeContextMenu:h,nodeClickDistance:Y,onlyRenderVisibleElements:P,noPanClassName:je,noDragClassName:Te,disableKeyboardA11y:Ue,nodeExtent:_e,rfId:be,nodesDraggable:Wt}),r("div",{className:"react-flow__viewport-portal"})]})})}ml.displayName="GraphView";const u0=ge(ml),h0=gc(),Vs=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u=.5,maxZoom:l=2,nodeOrigin:h,nodeExtent:f,zIndexMode:d="basic"}={})=>{const p=new Map,y=new Map,_=new Map,w=new Map,v=o??t??[],k=n??e??[],g=h??[0,0],m=f??dn;Ic(_,w,v);const{nodesInitialized:C}=wr(k,p,y,{nodeOrigin:g,nodeExtent:m,zIndexMode:d});let b=[0,0,1];if(a&&i&&s){const E=xn(p,{filter:j=>!!((j.width||j.initialWidth)&&(j.height||j.initialHeight))}),{x:A,y:P,zoom:L}=Jr(E,i,s,u,l,c?.padding??.1);b=[A,P,L]}return{rfId:"1",width:i??0,height:s??0,transform:b,nodes:k,nodesInitialized:C,nodeLookup:p,parentLookup:y,edges:v,edgeLookup:w,connectionLookup:_,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:u,maxZoom:l,translateExtent:dn,nodeExtent:m,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ot.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:{...lc},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:h0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:cc,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}},f0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:l,nodeOrigin:h,nodeExtent:f,zIndexMode:d})=>Eg((p,y)=>{async function _(){const{nodeLookup:w,panZoom:v,fitViewOptions:k,fitViewResolver:g,width:m,height:C,minZoom:b,maxZoom:E}=y();v&&(await wp({nodes:w,width:m,height:C,panZoom:v,minZoom:b,maxZoom:E},k),g?.resolve(!0),p({fitViewResolver:null}))}return{...Vs({nodes:e,edges:t,width:i,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:l,nodeOrigin:h,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:w=>{const{nodeLookup:v,parentLookup:k,nodeOrigin:g,nodeExtent:m,elevateNodesOnSelect:C,fitViewQueued:b,zIndexMode:E,nodesSelectionActive:A}=y(),{nodesInitialized:P,hasSelectedNodes:L}=wr(w,v,k,{nodeOrigin:g,nodeExtent:m,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:E}),j=A&&L;b&&P?(_(),p({nodes:w,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:j})):p({nodes:w,nodesInitialized:P,nodesSelectionActive:j})},setEdges:w=>{const{connectionLookup:v,edgeLookup:k}=y();Ic(v,k,w),p({edges:w})},setDefaultNodesAndEdges:(w,v)=>{if(w){const{setNodes:k}=y();k(w),p({hasDefaultNodes:!0})}if(v){const{setEdges:k}=y();k(v),p({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:v,nodeLookup:k,parentLookup:g,domNode:m,nodeOrigin:C,nodeExtent:b,debug:E,fitViewQueued:A,zIndexMode:P}=y(),{changes:L,updatedInternals:j}=Fp(w,k,g,m,C,b,P);j&&(Hp(k,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),v?.(L)))},updateNodePositions:(w,v=!1)=>{const k=[];let g=[];const{nodeLookup:m,triggerNodeChanges:C,connection:b,updateConnection:E,onNodesChangeMiddlewareMap:A}=y();for(const[P,L]of w){const j=m.get(P),V=!!(j?.expandParent&&j?.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:v};if(j&&b.inProgress&&b.fromNode.id===j.id){const S=Ct(j,b.fromHandle,G.Left,!0);E({...b,from:S})}V&&j.parentId&&k.push({id:P,parentId:j.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),g.push(N)}if(k.length>0){const{parentLookup:P,nodeOrigin:L}=y(),j=ii(k,m,P,L);g.push(...j)}for(const P of A.values())g=P(g);C(g)},triggerNodeChanges:w=>{const{onNodesChange:v,setNodes:k,nodes:g,hasDefaultNodes:m,debug:C}=y();if(w?.length){if(m){const b=Uc(w,g);k(b)}C&&console.log("React Flow: trigger node changes",w),v?.(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:v,setEdges:k,edges:g,hasDefaultEdges:m,debug:C}=y();if(w?.length){if(m){const b=Xg(w,g);k(b)}C&&console.log("React Flow: trigger edge changes",w),v?.(w)}},addSelectedNodes:w=>{const{multiSelectionActive:v,edgeLookup:k,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:C}=y();if(v){const b=w.map(E=>mt(E,!0));m(b);return}m(Mt(g,new Set([...w]),!0)),C(Mt(k))},addSelectedEdges:w=>{const{multiSelectionActive:v,edgeLookup:k,nodeLookup:g,triggerNodeChanges:m,triggerEdgeChanges:C}=y();if(v){const b=w.map(E=>mt(E,!0));C(b);return}C(Mt(k,new Set([...w]))),m(Mt(g,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:v}={})=>{const{edges:k,nodes:g,nodeLookup:m,triggerNodeChanges:C,triggerEdgeChanges:b}=y(),E=w||g,A=v||k,P=[];for(const j of E){if(!j.selected)continue;const V=m.get(j.id);V&&(V.selected=!1),P.push(mt(j.id,!1))}const L=[];for(const j of A)j.selected&&L.push(mt(j.id,!1));C(P),b(L)},setMinZoom:w=>{const{panZoom:v,maxZoom:k}=y();v?.setScaleExtent([w,k]),p({minZoom:w})},setMaxZoom:w=>{const{panZoom:v,minZoom:k}=y();v?.setScaleExtent([k,w]),p({maxZoom:w})},setTranslateExtent:w=>{y().panZoom?.setTranslateExtent(w),p({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:v,triggerNodeChanges:k,triggerEdgeChanges:g,elementsSelectable:m}=y();if(!m)return;const C=v.reduce((E,A)=>A.selected?[...E,mt(A.id,!1)]:E,[]),b=w.reduce((E,A)=>A.selected?[...E,mt(A.id,!1)]:E,[]);k(C),g(b)},setNodeExtent:w=>{const{nodes:v,nodeLookup:k,parentLookup:g,nodeOrigin:m,elevateNodesOnSelect:C,nodeExtent:b,zIndexMode:E}=y();w[0][0]===b[0][0]&&w[0][1]===b[0][1]&&w[1][0]===b[1][0]&&w[1][1]===b[1][1]||(wr(v,k,g,{nodeOrigin:m,nodeExtent:w,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:E}),p({nodeExtent:w}))},panBy:w=>{const{transform:v,width:k,height:g,panZoom:m,translateExtent:C}=y();return Up({delta:w,panZoom:m,transform:v,translateExtent:C,width:k,height:g})},setCenter:async(w,v,k)=>{const{width:g,height:m,maxZoom:C,panZoom:b}=y();if(!b)return!1;const E=typeof k?.zoom<"u"?k.zoom:C;return await b.setViewport({x:g/2-w*E,y:m/2-v*E,zoom:E},{duration:k?.duration,ease:k?.ease,interpolate:k?.interpolate}),!0},cancelConnection:()=>{p({connection:{...lc}})},updateConnection:w=>{p({connection:w})},reset:()=>p({...Vs()})}},Object.is);function p0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:i,initialHeight:s,initialMinZoom:a,initialMaxZoom:c,initialFitViewOptions:u,fitView:l,nodeOrigin:h,nodeExtent:f,zIndexMode:d,children:p}){const[y]=W(()=>f0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:i,height:s,fitView:l,minZoom:a,maxZoom:c,fitViewOptions:u,nodeOrigin:h,nodeExtent:f,zIndexMode:d}));return r(Ng,{value:y,children:r(Qg,{children:r(fm,{children:p})})})}function g0({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:i,width:s,height:a,fitView:c,fitViewOptions:u,minZoom:l,maxZoom:h,nodeOrigin:f,nodeExtent:d,zIndexMode:p}){return at(ko)?r(Z,{children:e}):r(p0,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:i,initialWidth:s,initialHeight:a,fitView:c,initialFitViewOptions:u,initialMinZoom:l,initialMaxZoom:h,nodeOrigin:f,nodeExtent:d,zIndexMode:p,children:e})}const m0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function y0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:i,nodeTypes:s,edgeTypes:a,onNodeClick:c,onEdgeClick:u,onInit:l,onMove:h,onMoveStart:f,onMoveEnd:d,onConnect:p,onConnectStart:y,onConnectEnd:_,onClickConnectStart:w,onClickConnectEnd:v,onNodeMouseEnter:k,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:C,onNodeDoubleClick:b,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:P,onNodesDelete:L,onEdgesDelete:j,onDelete:V,onSelectionChange:N,onSelectionDragStart:S,onSelectionDrag:I,onSelectionDragStop:M,onSelectionContextMenu:$,onSelectionStart:R,onSelectionEnd:D,onBeforeDelete:B,connectionMode:z,connectionLineType:O=ft.Bezier,connectionLineStyle:F,connectionLineComponent:U,connectionLineContainerStyle:K,deleteKeyCode:ie="Backspace",selectionKeyCode:q="Shift",selectionOnDrag:H=!1,selectionMode:X=un.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:Q=fn()?"Meta":"Control",zoomActivationKeyCode:Y=fn()?"Meta":"Control",snapToGrid:ee,snapGrid:se,onlyRenderVisibleElements:J=!1,selectNodesOnDrag:ce,nodesDraggable:ye,autoPanOnNodeFocus:Ee,nodesConnectable:$e,nodesFocusable:Ne,nodeOrigin:Te=Vc,edgesFocusable:ct,edgesReconnectable:je,elementsSelectable:Ue=!0,defaultViewport:_e=zg,minZoom:be=.5,maxZoom:we=2,translateExtent:xe=dn,preventScrolling:Wt=!0,nodeExtent:Yt,defaultMarkerColor:Sn="#b1b1b7",zoomOnScroll:Ao=!0,zoomOnPinch:Xt=!0,panOnScroll:$o=!1,panOnScrollSpeed:Cn=.5,panOnScrollMode:Po=_t.Free,zoomOnDoubleClick:En=!0,panOnDrag:Se=!0,onPaneClick:To,onPaneMouseEnter:Zt,onPaneMouseMove:Nn,onPaneMouseLeave:jo,onPaneScroll:In,onPaneContextMenu:Mn,paneClickDistance:Do=1,nodeClickDistance:x=0,children:T,onReconnect:ae,onReconnectStart:Qe,onReconnectEnd:Je,onEdgeContextMenu:Ro,onEdgeDoubleClick:$l,onEdgeMouseEnter:Pl,onEdgeMouseMove:Tl,onEdgeMouseLeave:jl,reconnectRadius:Dl=10,onNodesChange:Rl,onEdgesChange:Ol,noDragClassName:Ll="nodrag",noWheelClassName:Hl="nowheel",noPanClassName:ci="nopan",fitView:li,fitViewOptions:di,connectOnClick:zl,attributionPosition:Bl,proOptions:Vl,defaultEdgeOptions:Fl,elevateNodesOnSelect:Ul=!0,elevateEdgesOnSelect:Wl=!1,disableKeyboardA11y:ui=!1,autoPanOnConnect:Yl,autoPanOnNodeDrag:Xl,autoPanOnSelection:Zl=!0,autoPanSpeed:ql,connectionRadius:Gl,isValidConnection:Kl,onError:Ql,style:Jl,id:hi,nodeDragThreshold:ed,connectionDragThreshold:td,viewport:nd,onViewportChange:od,width:rd,height:id,colorMode:sd="light",debug:ad,onScroll:fi,ariaLabelConfig:cd,zIndexMode:pi="basic",...ld},dd){const Oo=hi||"1",ud=Ug(sd),hd=Me(gi=>{gi.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),fi?.(gi)},[fi]);return r("div",{"data-testid":"rf__wrapper",...ld,onScroll:hd,style:{...Jl,...m0},ref:dd,className:me(["react-flow",i,ud]),id:hi,role:"application",children:r(g0,{nodes:e,edges:t,width:rd,height:id,fitView:li,fitViewOptions:di,minZoom:be,maxZoom:we,nodeOrigin:Te,nodeExtent:Yt,zIndexMode:pi,children:[r(Fg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:p,onConnectStart:y,onConnectEnd:_,onClickConnectStart:w,onClickConnectEnd:v,nodesDraggable:ye,autoPanOnNodeFocus:Ee,nodesConnectable:$e,nodesFocusable:Ne,edgesFocusable:ct,edgesReconnectable:je,elementsSelectable:Ue,elevateNodesOnSelect:Ul,elevateEdgesOnSelect:Wl,minZoom:be,maxZoom:we,nodeExtent:Yt,onNodesChange:Rl,onEdgesChange:Ol,snapToGrid:ee,snapGrid:se,connectionMode:z,translateExtent:xe,connectOnClick:zl,defaultEdgeOptions:Fl,fitView:li,fitViewOptions:di,onNodesDelete:L,onEdgesDelete:j,onDelete:V,onNodeDragStart:E,onNodeDrag:A,onNodeDragStop:P,onSelectionDrag:I,onSelectionDragStart:S,onSelectionDragStop:M,onMove:h,onMoveStart:f,onMoveEnd:d,noPanClassName:ci,nodeOrigin:Te,rfId:Oo,autoPanOnConnect:Yl,autoPanOnNodeDrag:Xl,autoPanSpeed:ql,onError:Ql,connectionRadius:Gl,isValidConnection:Kl,selectNodesOnDrag:ce,nodeDragThreshold:ed,connectionDragThreshold:td,onBeforeDelete:B,debug:ad,ariaLabelConfig:cd,zIndexMode:pi}),r(u0,{onInit:l,onNodeClick:c,onEdgeClick:u,onNodeMouseEnter:k,onNodeMouseMove:g,onNodeMouseLeave:m,onNodeContextMenu:C,onNodeDoubleClick:b,nodeTypes:s,edgeTypes:a,connectionLineType:O,connectionLineStyle:F,connectionLineComponent:U,connectionLineContainerStyle:K,selectionKeyCode:q,selectionOnDrag:H,selectionMode:X,deleteKeyCode:ie,multiSelectionKeyCode:Q,panActivationKeyCode:te,zoomActivationKeyCode:Y,onlyRenderVisibleElements:J,defaultViewport:_e,translateExtent:xe,minZoom:be,maxZoom:we,preventScrolling:Wt,zoomOnScroll:Ao,zoomOnPinch:Xt,zoomOnDoubleClick:En,panOnScroll:$o,panOnScrollSpeed:Cn,panOnScrollMode:Po,panOnDrag:Se,autoPanOnSelection:Zl,onPaneClick:To,onPaneMouseEnter:Zt,onPaneMouseMove:Nn,onPaneMouseLeave:jo,onPaneScroll:In,onPaneContextMenu:Mn,paneClickDistance:Do,nodeClickDistance:x,onSelectionContextMenu:$,onSelectionStart:R,onSelectionEnd:D,onReconnect:ae,onReconnectStart:Qe,onReconnectEnd:Je,onEdgeContextMenu:Ro,onEdgeDoubleClick:$l,onEdgeMouseEnter:Pl,onEdgeMouseMove:Tl,onEdgeMouseLeave:jl,reconnectRadius:Dl,defaultMarkerColor:Sn,noDragClassName:Ll,noWheelClassName:Hl,noPanClassName:ci,rfId:Oo,disableKeyboardA11y:ui,nodeExtent:Yt,viewport:nd,onViewportChange:od,nodesDraggable:ye}),r(Hg,{onSelectionChange:N}),T,r(jg,{proOptions:Vl,position:Bl}),r(Tg,{rfId:Oo,disableKeyboardA11y:ui})]})})}var v0=Wc(y0);function _0({dimensions:e,lineWidth:t,variant:n,className:o}){return r("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 w0({radius:e,className:t}){return r("circle",{cx:e,cy:e,r:e,className:me(["react-flow__background-pattern","dots",t])})}var gt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(gt||(gt={}));const x0={[gt.Dots]:1,[gt.Lines]:1,[gt.Cross]:6},b0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function yl({id:e,variant:t=gt.Dots,gap:n=20,size:o,lineWidth:i=1,offset:s=0,color:a,bgColor:c,style:u,className:l,patternClassName:h}){const f=re(null),{transform:d,patternId:p}=le(b0,pe),y=o||x0[t],_=t===gt.Dots,w=t===gt.Cross,v=Array.isArray(n)?n:[n,n],k=[v[0]*d[2]||1,v[1]*d[2]||1],g=y*d[2],m=Array.isArray(s)?s:[s,s],C=w?[g,g]:k,b=[m[0]*d[2]+C[0]/2,m[1]*d[2]+C[1]/2],E=`${p}${e||""}`;return r("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:[r("pattern",{id:E,x:d[0]%k[0],y:d[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${b[0]},-${b[1]})`,children:_?r(w0,{radius:g/2,className:h}):r(_0,{dimensions:C,lineWidth:i,variant:t,className:h})}),r("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}yl.displayName="Background";const k0=ge(yl);function S0(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function C0(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r("path",{d:"M0 0h32v4.2H0z"})})}function E0(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r("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 N0(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("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 I0(){return r("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r("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 r("button",{type:"button",className:me(["react-flow__controls-button",t]),...n,children:e})}const M0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function vl({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:i,onZoomIn:s,onZoomOut:a,onFitView:c,onInteractiveChange:u,className:l,children:h,position:f="bottom-left",orientation:d="vertical","aria-label":p}){const y=he(),{isInteractive:_,minZoomReached:w,maxZoomReached:v,ariaLabelConfig:k}=le(M0,pe),{zoomIn:g,zoomOut:m,fitView:C}=si(),b=()=>{g(),s?.()},E=()=>{m(),a?.()},A=()=>{C(i),c?.()},P=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),u?.(!_)};return r(So,{className:me(["react-flow__controls",d==="horizontal"?"horizontal":"vertical",l]),position:f,style:e,"data-testid":"rf__controls","aria-label":p??k["controls.ariaLabel"],children:[t&&r(Z,{children:[r(Hn,{onClick:b,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:v,children:r(S0,{})}),r(Hn,{onClick:E,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:w,children:r(C0,{})})]}),n&&r(Hn,{className:"react-flow__controls-fitview",onClick:A,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:r(E0,{})}),o&&r(Hn,{className:"react-flow__controls-interactive",onClick:P,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:_?r(I0,{}):r(N0,{})}),h]})}vl.displayName="Controls";const A0=ge(vl);function $0({id:e,x:t,y:n,width:o,height:i,style:s,color:a,strokeColor:c,strokeWidth:u,className:l,borderRadius:h,shapeRendering:f,selected:d,onClick:p}){const{background:y,backgroundColor:_}=s||{},w=a||y||_;return r("rect",{className:me(["react-flow__minimap-node",{selected:d},l]),x:t,y:n,rx:h,ry:h,width:o,height:i,style:{fill:w,stroke:c,strokeWidth:u},shapeRendering:f,onClick:p?v=>p(v,e):void 0})}const P0=ge($0),T0=e=>e.nodes.map(t=>t.id),Jo=e=>e instanceof Function?e:()=>e;function j0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:i,nodeComponent:s=P0,onClick:a}){const c=le(T0,pe),u=Jo(t),l=Jo(e),h=Jo(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r(Z,{children:c.map(d=>r(R0,{id:d,nodeColorFunc:u,nodeStrokeColorFunc:l,nodeClassNameFunc:h,nodeBorderRadius:o,nodeStrokeWidth:i,NodeComponent:s,onClick:a,shapeRendering:f},d))})}function D0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:i,nodeStrokeWidth:s,shapeRendering:a,NodeComponent:c,onClick:u}){const{node:l,x:h,y:f,width:d,height:p}=le(y=>{const _=y.nodeLookup.get(e);if(!_)return{node:void 0,x:0,y:0,width:0,height:0};const w=_.internals.userNode,{x:v,y:k}=_.internals.positionAbsolute,{width:g,height:m}=Fe(w);return{node:w,x:v,y:k,width:g,height:m}},pe);return!l||l.hidden||!mc(l)?null:r(c,{x:h,y:f,width:d,height:p,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:s,shapeRendering:a,onClick:u,id:l.id})}const R0=ge(D0);var O0=ge(j0);const L0=200,H0=150,z0=e=>!e.hidden,B0=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?fc(xn(e.nodeLookup,{filter:z0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Fs=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,V0=(e,t)=>Fs(e.viewBB,t.viewBB)&&Fs(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,F0="react-flow__minimap-desc";function _l({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:c,bgColor:u,maskColor:l,maskStrokeColor:h,maskStrokeWidth:f,position:d="bottom-right",onClick:p,onNodeClick:y,pannable:_=!1,zoomable:w=!1,ariaLabel:v,inversePan:k,zoomStep:g=1,offsetScale:m=5}){const C=he(),b=re(null),{boundingRect:E,panZoom:A,viewBB:P,rfId:L,translateExtent:j,flowWidth:V,flowHeight:N,ariaLabelConfig:S}=le(B0,V0),I=e?.width??L0,M=e?.height??H0,$=E.width/I,R=E.height/M,D=Math.max($,R),B=D*I,z=D*M,O=m*D,F=E.x-(B-E.width)/2-O,U=E.y-(z-E.height)/2-O,K=B+O*2,ie=z+O*2,q=`${F0}-${L}`,H=re(0),X=re();H.current=D,ne(()=>{const se=C.getState().panZoom;if(b.current&&se)return X.current=Jp({domNode:b.current,panZoom:se,getTransform:()=>C.getState().transform,getViewScale:()=>H.current}),()=>{X.current?.destroy()}},[A]),ne(()=>{X.current?.update({translateExtent:j,width:V,height:N,inversePan:k,pannable:_,zoomStep:g,zoomable:w})},[_,w,k,g,j,V,N]);const te=p?se=>{const[J,ce]=X.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;y?.(se,ce)},[y]),Y=y?Q:void 0,ee=v??S["minimap.ariaLabel"];return r(So,{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*D: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:r("svg",{width:I,height:M,viewBox:`${F} ${U} ${K} ${ie}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":q,ref:b,onClick:te,children:[ee&&r("title",{id:q,children:ee}),r(O0,{onClick:Y,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:c}),r("path",{className:"react-flow__minimap-mask",d:`M${F-O},${U-O}h${K+O*2}v${ie+O*2}h${-K-O*2}z
7
+ M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}_l.displayName="MiniMap";const U0=ge(_l),W0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Y0={[zt.Line]:"right",[zt.Handle]:"bottom-right"};function X0({nodeId:e,position:t,variant:n=zt.Handle,className:o,style:i=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:y,onResizeStart:_,onResize:w,onResizeEnd:v}){const k=Gc(),g=typeof e=="string"?e:k,m=he(),C=re(null),b=n===zt.Handle,E=le(Me(W0(b&&p),[b,p]),pe),A=re(null),P=t??Y0[n];ne(()=>{if(!(!C.current||!g))return A.current||(A.current=hg({domNode:C.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:j,transform:V,snapGrid:N,snapToGrid:S,nodeOrigin:I,domNode:M}=m.getState();return{nodeLookup:j,transform:V,snapGrid:N,snapToGrid:S,nodeOrigin:I,paneDomNode:M}},onChange:(j,V)=>{const{triggerNodeChanges:N,nodeLookup:S,parentLookup:I,nodeOrigin:M}=m.getState(),$=[],R={x:j.x,y:j.y},D=S.get(g);if(D&&D.expandParent&&D.parentId){const B=D.origin??M,z=j.width??D.measured.width??0,O=j.height??D.measured.height??0,F={id:D.id,parentId:D.parentId,rect:{width:z,height:O,...yc({x:j.x??D.position.x,y:j.y??D.position.y},{width:z,height:O},D.parentId,S,B)}},U=ii([F],S,I,M);$.push(...U),R.x=j.x?Math.max(B[0]*z,j.x):void 0,R.y=j.y?Math.max(B[1]*O,j.y):void 0}if(R.x!==void 0&&R.y!==void 0){const B={id:g,type:"position",position:{...R}};$.push(B)}if(j.width!==void 0&&j.height!==void 0){const z={id:g,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:j.width,height:j.height}};$.push(z)}for(const B of V){const z={...B,type:"position"};$.push(z)}N($)},onEnd:({width:j,height:V})=>{const N={id:g,type:"dimensions",resizing:!1,dimensions:{width:j,height:V}};m.getState().triggerNodeChanges([N])}})),A.current.update({controlPosition:P,boundaries:{minWidth:c,minHeight:u,maxWidth:l,maxHeight:h},keepAspectRatio:f,resizeDirection:d,onResizeStart:_,onResize:w,onResizeEnd:v,shouldResize:y}),()=>{A.current?.destroy()}},[P,c,u,l,h,f,_,w,v,y]);const L=P.split("-");return r("div",{className:me(["react-flow__resize-control","nodrag",...L,n,o]),ref:C,style:{...i,scale:E,...a&&{[b?"backgroundColor":"borderColor"]:a}},children:s})}ge(X0);function Z0(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 wl=e=>e.color||Z0(e.id),Vt=(e,t,n)=>n&&e.missions[n]?.color||wl(e.projects[t]||{id:t});function q0(e,t,n={},o){let i=[],s=[],a=0;const c=t.query.trim().toLowerCase(),u=(...g)=>g.join(" ").toLowerCase().includes(c),l=(g,m,C,b)=>i.push({id:g,type:"work",position:{x:m,y:C},data:b}),h=(g,m,C)=>s.push({id:`${g}:${m}`,source:g,target:m,type:"smoothstep",style:{stroke:C,strokeWidth:1.5}});for(const g of Object.values(e.projects).filter(m=>!m.archivedAt&&(t.project==="all"||m.id===t.project)).sort((m,C)=>m.name.localeCompare(C.name)||m.id.localeCompare(C.id))){const m=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,S)=>N.createdAt.localeCompare(S.createdAt)||N.id.localeCompare(S.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,j=Vt(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:j,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,j),a++;A.length||a++;const V=(L+a-1)*85;l(b.id,400,V,{label:b.name,kind:"Mission",status:b.status,color:j,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,j),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,(m+a-1)*85,{label:g.name,kind:"Project",status:"active",color:Vt(e,g.id),href:`#/projects/${encodeURIComponent(g.id)}`,summary:`${C.length} missions`}),a++)}const f={projects:i.filter(g=>g.data.kind==="Project").length,missions:i.filter(g=>g.data.kind==="Mission").length,tasks:i.filter(g=>g.data.kind==="Task").length},d=s,p=new Set(o?.projects),y=new Set(o?.missions);for(const g of i)g.data.childCount=d.filter(m=>m.source===g.id).length,g.data.expanded=!o||(g.data.kind==="Project"?p.has(g.id):y.has(g.id));if(o){const g=new Set(i.filter(E=>E.data.kind==="Project").map(E=>E.id)),m=new Set(d.filter(E=>g.has(E.source)&&p.has(E.source)).map(E=>E.target)),C=new Set(d.filter(E=>m.has(E.source)&&y.has(E.source)).map(E=>E.target));i=i.filter(E=>g.has(E.id)||m.has(E.id)||C.has(E.id));const b=new Set(i.map(E=>E.id));s=s.filter(E=>b.has(E.source)&&b.has(E.target))}const _=new Map(i.map(g=>[g.id,g])),w=g=>s.filter(m=>m.source===g).map(m=>_.get(m.target));let v=0;for(const g of i.filter(m=>m.data.kind==="Project")){const m=w(g.id),C=m.some(L=>w(L.id).length>0),b=Math.min(C?2:3,Math.max(1,m.length)),E=C?540:260,A=b*E;g.position={x:v+(A-220)/2,y:0};let P=180;for(let L=0;L<m.length;L+=b){const j=m.slice(L,L+b);let V=0;for(const[N,S]of j.entries()){const I=w(S.id),M=Math.min(2,Math.max(1,I.length)),$=v+N*E;S.position={x:$+(E-220)/2,y:P};const R=$+(E-(M===2?480:220))/2;for(const[D,B]of I.entries())B.position={x:R+D%2*260,y:P+160+Math.floor(D/2)*150};V=Math.max(V,Math.ceil(I.length/2))}P+=V?160+V*150+50:156}v+=A+70}o&&p.size===0&&i.filter(g=>g.data.kind==="Project").forEach((g,m)=>{g.position={x:m%3*260,y:Math.floor(m/3)*156}});const k=[...Object.values(n)];for(const g of i)if(n[g.id])g.position=n[g.id];else{for(;k.some(m=>Math.abs(m.x-g.position.x)<240&&Math.abs(m.y-g.position.y)<136);)g.position={x:g.position.x,y:g.position.y+156};k.push(g.position)}return{nodes:i,edges:s,counts:f}}const xl={active:"Active",planned:"Planned",running:"Running",todo:"To do",in_progress:"In progress",blocked:"Blocked",completed:"Completed",failed:"Failed",cancelled:"Cancelled"},kr="angine-graph-manual-positions-compact-v5";function G0(){try{const e=JSON.parse(localStorage.getItem(kr)||"{}");return Object.fromEntries(Object.entries(e).filter(([,t])=>t&&Number.isFinite(t.x)&&Number.isFinite(t.y)))}catch{return{}}}function K0({data:e}){return r("div",{class:"graph-card",style:{borderInlineStart:`4px solid ${e.color}`},children:[r(Bt,{type:"target",position:G.Top,isConnectable:!1}),r("div",{class:"graph-card-top",children:[r("span",{children:e.kind}),r("span",{class:`badge ${e.status}`,children:xl[e.status]||e.status})]}),r("a",{class:"nodrag",href:e.href,title:e.label,children:[e.label,r("span",{"aria-hidden":"true",children:" ↗"})]}),r("p",{children:e.summary}),!!e.childCount&&e.toggle&&r("button",{class:"nodrag graph-expand","aria-expanded":e.expanded,onClick:e.toggle,children:[e.expanded?"− Hide":"+ Show"," ",e.kind==="Project"?"missions":"tasks"]}),r(Bt,{type:"source",position:G.Bottom,isConnectable:!1})]})}const Q0={work:K0};function J0({state:e,filters:t,setFilters:n,reset:o}){const i=re(G0()),s=re({...i.current}),[a,c]=W([]),[u,l]=W(null),[h,f]=W(0),d=re(""),[p,y]=W([]),[_,w]=W([]),v=!!(t.query||t.project!=="all"||t.agent!=="all"||t.status!=="all"),k=(N,S)=>{d.current=S==="Project"?N:e.missions[N]?.projectId||"",(S==="Project"?y:w)(M=>M.includes(N)?M.filter($=>$!==N):[...M,N]),s.current={...i.current},c([]),f(M=>M+1)},g=()=>{d.current="",i.current={},y([]),w([]),s.current={},c([]),f(N=>N+1),o()},m=re(""),C=()=>{const N=a.find(I=>I.id===d.current)||a.find(I=>I.data.kind==="Project")||a[0],S=document.querySelector(".graph-canvas")?.clientWidth||1e3;if(!p.length&&!v){u?.fitView({padding:.15,minZoom:.65,maxZoom:.9,duration:250});return}N&&u?.setViewport({x:S/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&&m.current!==N&&(m.current=N,requestAnimationFrame(C)),a.length||(m.current="")},[u,a.length,t.project,t.agent,t.status,t.query,h,p,_]);const E=ve(()=>q0(e,t,s.current,{projects:v?Object.keys(e.projects):p,missions:v?Object.keys(e.missions):_}),[e,t.project,t.agent,t.status,t.query,h,p,_]),A=()=>{try{localStorage.setItem(kr,JSON.stringify(i.current))}catch{}};ne(()=>{c(N=>{const S=new Map(N.map(I=>[I.id,I]));return E.nodes.map(I=>{const M=S.get(I.id)?.position||I.position;return s.current[I.id]=M,{...S.get(I.id),...I,position:M,data:{...I.data,toggle:v?void 0:()=>k(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,S)=>N.name.localeCompare(S.name)),L=[...new Set([...Object.values(e.sessions).map(N=>N.agent),...Object.values(e.tasks).map(N=>N.updatedBy)])].sort(),j=!!(t.query||t.project!=="all"||t.agent!=="all"||t.status!=="all");return r("section",{class:"graph-view",children:[r("div",{class:"graph-heading",children:[r("div",{children:[r("h1",{children:"Work graph"}),r("p",{children:"Projects → Missions → Tasks · Live from agent reports"})]}),r("div",{class:"graph-actions",children:[r("button",{class:"secondary-button",onClick:b,children:"Fit view"}),r("button",{class:"secondary-button",onClick:g,children:"All projects"}),r("button",{class:"secondary-button",onClick:()=>{s.current={...i.current},c([]),y(Object.keys(e.projects)),w(Object.keys(e.missions)),f(N=>N+1)},children:"Expand all"}),r("button",{class:"secondary-button",onClick:()=>{i.current={},s.current={};try{localStorage.removeItem(kr)}catch{}c([]),f(N=>N+1)},children:"Auto arrange"})]})]}),r("div",{class:"toolbar graph-toolbar",children:[r("label",{class:"search",children:[r("span",{"aria-hidden":"true",children:"⌕"}),r("input",{"aria-label":"Search graph",placeholder:"Search projects, missions, tasks…",value:t.query,onInput:N=>n({query:N.currentTarget.value})})]}),r("label",{class:"filter-label",children:[r("span",{children:"Project"}),r("select",{"aria-label":"Graph project",value:t.project,onChange:N=>n({project:N.currentTarget.value}),children:[r("option",{value:"all",children:"All projects"}),P.map(N=>r("option",{value:N.id,children:N.name},N.id))]})]}),r("label",{class:"filter-label",children:[r("span",{children:"Agent"}),r("select",{"aria-label":"Graph agent",value:t.agent,onChange:N=>n({agent:N.currentTarget.value}),children:[r("option",{value:"all",children:"All agents"}),L.map(N=>r("option",{value:N,children:N},N))]})]}),r("label",{class:"filter-label",children:[r("span",{children:"Task status"}),r("select",{"aria-label":"Graph task status",value:t.status,onChange:N=>n({status:N.currentTarget.value}),children:[r("option",{value:"all",children:"All statuses"}),["todo","in_progress","blocked","completed","failed","cancelled"].map(N=>r("option",{value:N,children:xl[N]},N))]})]}),j&&r("button",{class:"clear-filters",onClick:o,children:"Reset"})]}),r("div",{class:"graph-meta",children:[r("span",{children:[E.counts.projects," projects · ",E.counts.missions," missions · ",E.counts.tasks," tasks · ",E.nodes.length," nodes shown"]}),r("span",{children:"Show missions and tasks to explore · Drag to arrange · Scroll to zoom"})]}),r("div",{class:"graph-canvas",role:"region","aria-label":"Interactive project mission and task graph",children:E.nodes.length?r(v0,{nodes:a,edges:E.edges,nodeTypes:Q0,onNodesChange:N=>c(S=>Uc(N,S)),onNodeDragStop:(N,S)=>{s.current[S.id]=S.position,i.current[S.id]=S.position,A()},onInit:l,defaultViewport:{x:40,y:40,zoom:.9},minZoom:.3,maxZoom:2,nodesConnectable:!1,edgesReconnectable:!1,deleteKeyCode:null,children:[r(k0,{gap:22,size:1}),r(A0,{showInteractive:!1,showFitView:!1}),r(U0,{pannable:!0,zoomable:!0,nodeColor:N=>String(N.data.color||"#94a3b8")})]}):r("div",{class:"empty",children:[r("h2",{children:j?"No work matches these filters":"Your graph will grow here"}),r("p",{children:j?"Try another project, agent, or task status.":"Ask a connected agent to report a mission. Its project and tasks will appear automatically."}),j?r("button",{class:"secondary-button",onClick:o,children:"Clear filters"}):r("a",{href:"#/agents",children:"Check agent connections"})]})})]})}const zn=(e,t,n)=>e?{borderInlineStart:`3px solid ${Vt(e,t,n)}`}:void 0;function ey({project:e,mission:t,mutate:n}){const[o,i]=W(!1),s=t?{missionId:t.id}:{projectId:e.id},a=async u=>{i(!0);try{await n("color",{...s,color:u})}finally{i(!1)}},c=t?t.color:e.color;return r("div",{class:"color-control",children:[r("label",{children:[r("span",{children:t?"Mission color":"Project color"}),r("input",{type:"color","aria-label":t?"Choose mission color override":"Choose project color",value:c||wl(e),disabled:o,onChange:u=>{a(u.currentTarget.value)}})]}),r("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&&r("button",{class:"text-button",disabled:o,onClick:()=>{a(null)},children:t?"Use project color":"Reset to automatic"}),o&&r("span",{role:"status",children:"Saving…"})]})}function Us(){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 rn(e,t=60,n=Date.now()){return t>0&&["running","in_progress","blocked"].includes(e.status)&&n-Date.parse(e.updatedAt)>=t*6e4}const ty=e=>`prj_${e}`,Ws=e=>e?.path.split(/[\\/]/).filter(Boolean).pop()||"Project";function ny(e,t,n){return JSON.parse(JSON.stringify({id:e.projectId,key:n?.key||Ws(t),workspaceId:e.workspaceId,name:n?.name||Ws(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 oy(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||Us()};const t={},n={},o=e.workspaces||{};for(const a of Object.values(e.projects||{})){const c={...a,projectId:ty(a.workspaceId)};t[c.id]=c,n[c.projectId]=ny(c,o[c.workspaceId],n[c.projectId])}const i={};for(const a of Object.values(e.tasks||{})){const c=t[a.projectId];i[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:i,sessions:s,profiles:e.profiles||Us()}}function bl(e,t){return!!(e.projects[t.projectId]?.archivedAt||e.missions?.[t.missionId]?.archivedAt)}const ry=3,iy=75e3;function No(e,t=Date.now()){return!e.closedAt&&t-Date.parse(e.lastSeenAt)<iy?"connected":"disconnected"}function kl(e,t){return t?e?.reporters.find(n=>n.id===t):void 0}function sy(e,t=Date.now()){const n=new Map;for(const o of e){const i=JSON.stringify([o.agent,o.profileId||o.profileKey||"default"]);let s=n.get(i);s||(s={id:i,agent:o.agent,profileId:o.profileId,profileKey:o.profileKey,reporters:[],connected:0,sentUpdates:0,connectedOnly:0,issues:0},n.set(i,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((i,s)=>+!!s.issue-+!!i.issue||+(s.successfulReports>0)-+(i.successfulReports>0)||(s.lastReportAt||"").localeCompare(i.lastReportAt||"")||s.startedAt.localeCompare(i.startedAt))})).sort((o,i)=>i.issues-o.issues||o.agent.localeCompare(i.agent))}function Sl(e,t,n,o,i=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=kl(n,e.sessions[s.updatedBySessionId||""]?.reporterId);return a?.issue?[{task:s,reason:"Reporter needs attention"}]:a&&No(a,i)==="disconnected"?[{task:s,reason:"Reporter disconnected — task status unconfirmed"}]:rn(s,o,i)?[{task:s,reason:"No recent task update"}]:[]})}const er=e=>e[0].toUpperCase()+e.slice(1),Sr=e=>e?new Date(e).toLocaleString():"No reports yet";function ay(){const[e,t]=W(null),[n,o]=W("checking");return ne(()=>{let i=!1,s=!1;const a=new AbortController,c=async()=>{if(!s){s=!0;try{const l=await fetch("/api/health",{signal:a.signal});if(i)return;if(l.status===404){o("outdated"),t(null);return}if(!l.ok)throw new Error;const h=await l.json();if(i)return;t(h),o(h.protocolVersion===ry?"ready":"outdated")}catch{i||(o("unavailable"),t(null))}finally{s=!1}}};c();const u=setInterval(()=>{c()},15e3);return()=>{i=!0,a.abort(),clearInterval(u)}},[]),{health:e,compatibility:n}}function cy({compatibility:e}){return e!=="outdated"?null:r("div",{class:"server-notice",role:"status",children:[r("strong",{children:"Update the running server"}),r("span",{children:["Run ",r("code",{children:"angine restart"}),", refresh this page, then restart your agent sessions. New controls need the updated server."]})]})}function Cl({reporter:e}){const t=e?No(e):"unknown";return r("span",{class:`reporter-health ${t}`,title:"This describes the Angine reporter connection, not whether the agent is currently working.",children:[r("span",{}),t==="connected"?"Reporter connected":t==="disconnected"?"Reporter disconnected":"Connection not tracked"]})}function ly({health:e,session:t}){const n=kl(e,t.reporterId);return r("div",{class:"reporting-details",children:[r(Cl,{reporter:n}),r("p",{children:["Last task report: ",Sr(t.lastSeenAt)]}),n&&r("p",{children:[n.successfulReports," accepted · ",n.failedReports," rejected reports since server start"]}),r("p",{children:"Task status is agent reported. A connection heartbeat does not confirm task progress."})]})}const dy=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 uy({health:e,compatibility:t,profile:n,profiles:o={}}){const[i,s]=W(!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=sy(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 r("section",{class:"panel connection-panel",children:[r("div",{class:"panel-heading",children:[r("h2",{children:"Connections"}),r("span",{children:t==="ready"?`${u} connected`:t==="outdated"?"Server update needed":t==="checking"?"Checking…":"Unable to check"})]}),r("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=>r("details",{class:"connection-group",children:[r("summary",{children:[r("span",{children:[r("strong",{children:[o[f.profileId||""]?.name||er(f.agent),!f.profileId&&f.profileKey?` · ${f.profileKey}`:""]}),r("span",{children:[f.connected," connected · ",f.sentUpdates," sent updates · ",f.connectedOnly," connected only"]})]}),r("span",{class:f.issues?"connection-issue":"connection-group-expand",children:f.issues?`${f.issues} need attention`:`${f.reporters.length} reporters`})]}),r("div",{class:"connection-group-rows",children:f.reporters.map(d=>r("div",{class:"connection-row",children:[r("div",{children:[r("strong",{children:[er(d.agent)," · ",d.id.slice(0,8)]}),r(Cl,{reporter:d}),r("span",{children:d.lastReportAt?`Last known report: ${Sr(d.lastReportAt)}`:"No task updates received in this server session"}),d.issue&&r("p",{class:"connection-issue",children:dy(d)})]}),r("details",{children:[r("summary",{children:"Details"}),r("dl",{children:[r("dt",{children:"Profile"}),r("dd",{children:o[d.profileId||""]?.name||d.profileKey||"Agent default"}),r("dt",{children:"Reporter version"}),r("dd",{children:d.version||"Unknown"}),r("dt",{children:"Last heartbeat"}),r("dd",{children:Sr(d.lastSeenAt)}),r("dt",{children:"Accepted since server start"}),r("dd",{children:d.successfulReports}),r("dt",{children:"Rejected since server start"}),r("dd",{children:d.failedReports}),r("dt",{children:"Reporter ID"}),r("dd",{children:d.id}),d.sourceSessionId&&r(Z,{children:[r("dt",{children:"Agent session"}),r("dd",{children:d.sourceSessionId})]})]})]})]},d.id))})]},f.id)),!a.length&&r("p",{class:"muted",children:["No tracked connections ",n?"for this profile ":"","yet. Restart your configured agent session to load the updated reporter."]}),r("details",{class:"connect-instructions",children:[r("summary",{children:n?"Connect this profile":"Connect an agent"}),r("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."}),r("pre",{children:h}),r("button",{class:"secondary-button",onClick:async()=>{try{await navigator.clipboard.writeText(h),s(!0)}catch{s(!1)}},children:i?"Copied":"Copy setup"}),r("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&&r("p",{class:"muted",children:["This is the default profile for ",er(n.agent),". Existing connections without an explicit profile key use it automatically."]})]})]})}function hy({state:e,tasks:t,health:n,staleMinutes:o}){const i=Sl(e,t,n,o),s=t.filter(a=>a.status==="in_progress").length;return r("details",{class:`attention-summary ${i.length?"has-attention":""}`,children:[r("summary",{children:[r("span",{children:[r("strong",{children:i.length?`${i.length} need attention`:"No tasks need attention"}),r("span",{children:[s," in progress · Based on the current filters"]})]}),r("span",{class:"attention-expand",children:"View details"})]}),r("div",{class:"attention-items",children:[i.slice(0,10).map(({task:a,reason:c})=>r("a",{href:`#/tasks/${encodeURIComponent(a.id)}`,children:[r("strong",{children:a.title}),r("span",{class:"attention-context",children:[r("b",{children:"Project:"})," ",e.projects[a.projectId]?.name||"Unknown project"," ",r("span",{"aria-hidden":"true",children:" / "}),r("b",{children:"Mission:"})," ",e.missions[a.missionId]?.name||"Unknown mission"]}),r("span",{class:"attention-reason",children:c})]},a.id)),!i.length&&r("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."}),i.length>10&&r("p",{class:"muted",children:"Showing the first 10. Use the task filters to review the remaining work."})]})]})}const tr={agent:"all",status:"all",project:"all",mission:"all",profile:"all",query:"",staleOnly:!1},ot=e=>({codex:"Codex",claude:"Claude",antigravity:"Antigravity",grok:"Grok",external:"External"})[(e||"external").trim()]||e||"External",De=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`;function El(e,t){try{return JSON.parse(localStorage.getItem(e)||"null")??t}catch{return t}}function Nl(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function fy(e){const[t,n]=W(()=>El("angine-filters-v1",{}));ne(()=>Nl("angine-filters-v1",t),[t]);const o={...tr,...t[e]},i=s=>n(a=>({...a,[e]:{...tr,...a[e],...s}}));return{filters:o,set:i,reset:()=>i({...tr}),resetAll:()=>n({})}}function py(){const[e,t]=W(()=>{const u=El("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]=W(""),[i,s]=W(!0);return ne(()=>Nl("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 Cr("preferences",u);return t(h=>({...h,notifications:u})),o(""),l},testNotifications:async()=>{await Cr("notification-test",{})},notificationError:n,notificationSupported:i}}async function gy(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)}),i=await o.json();if(!o.ok)throw new Error(i.error||"Could not save the change.");return i}async function Cr(e,t){return(await gy(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 Ft(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&&rn(e,t)?r("span",{class:"stale-tag",title:`No reported update since ${new Date(e.updatedAt).toLocaleString()}`,children:"Stale"}):null}function my({profile:e,mutate:t,close:n}){const[o,i]=W(()=>e||{agent:"external",context:"Personal",isDefault:!0}),[s,a]=W(!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)=>r("label",{children:[h,r("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=>i({...o,[l]:p.currentTarget.value})}),r("span",{class:"field-help",id:`profile-help-${l}`,children:c[l]})]});return r("form",{class:"panel profile-form",onSubmit:async l=>{l.preventDefault(),a(!0);const h=await t("profiles",o);a(!1),h&&n()},children:[r("div",{class:"panel-heading",children:[r("h2",{children:e?"Edit profile":"New agent profile"}),r("button",{type:"button",class:"text-button",onClick:n,children:"Close"})]}),r("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)]}),r("label",{class:"check-label",children:[r("input",{type:"checkbox","aria-describedby":"profile-help-default",checked:o.isDefault===!0,onChange:l=>i({...o,isDefault:l.currentTarget.checked})}),"Default profile for this agent type"]}),r("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."}),r("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."}),r("button",{class:"primary-button",disabled:s,children:s?"Saving…":"Save profile"})]})}function yy({state:e,profileId:t,mutate:n,taskRow:o,health:i,compatibility:s}){const[a,c]=W(null),u=Object.values(e.profiles||{}).sort((_,w)=>_.name.localeCompare(w.name)),l=t?e.profiles?.[t]:void 0,h=_=>Object.values(e.sessions).filter(w=>Io(e,w)?.id===_.id),f=_=>Object.values(e.tasks).filter(w=>Ft(e,w)?.id===_.id&&!bl(e,w)),d=_=>{const w=new Set([...f(_).map(v=>v.projectId),...h(_).flatMap(v=>v.projectIds||[v.projectId])]);return Object.values(e.projects).filter(v=>w.has(v.id)&&!v.archivedAt)},p=_=>{const w=new Set([...f(_).map(v=>v.missionId),...h(_).flatMap(v=>v.missionIds||[v.missionId])]);return Object.values(e.missions).filter(v=>w.has(v.id)&&!v.archivedAt&&!e.projects[v.projectId]?.archivedAt)},y=_=>{const w=h(_).sort((C,b)=>b.lastSeenAt.localeCompare(C.lastSeenAt)),v=C=>w.find(b=>b.id!==C.id&&C.parentAgentId===b.agentId&&C.sourceSessionId&&b.sourceSessionId===C.sourceSessionId&&b.workspaceId===C.workspaceId),k=[],g=new Set,m=(C,b)=>{g.has(C.id)||(g.add(C.id),k.push({session:C,depth:b}),w.filter(E=>v(E)?.id===C.id).forEach(E=>m(E,b+1)))};return w.filter(C=>!v(C)).forEach(C=>m(C,0)),w.forEach(C=>m(C,0)),k};return t&&!l?r("div",{class:"empty",children:[r("h2",{children:"Profile not found"}),r("a",{href:De("agents"),children:"All agents"})]}):r(Z,{children:[r("div",{class:"view-heading",children:[r("div",{children:[r("h1",{children:l?.name||"Agents & sessions"}),r("p",{children:l?`${l.context} · ${ot(l.agent)}`:"Profiles, collaboration, and reported agent sessions."})]}),r("button",{class:"primary-button",onClick:()=>c(l||"new"),children:l?"Edit profile":"Add profile"})]}),a&&r(my,{profile:a==="new"?void 0:a,mutate:n,close:()=>c(null)},a==="new"?"new":a.id),r(uy,{profiles:e.profiles,health:i,compatibility:s,profile:l}),l?r(Z,{children:[r("nav",{class:"breadcrumbs",children:[r("a",{href:De("agents"),children:"Agents"}),r("span",{children:"/"}),r("span",{children:l.name})]}),r("div",{class:"profile-summary panel",children:[r("span",{children:[d(l).length," projects"]}),r("span",{children:[p(l).length," missions"]}),r("span",{children:[f(l).length," tasks"]}),r("span",{children:[h(l).length," sessions"]}),l.ownerName&&r("span",{children:["Owner: ",l.ownerName]}),l.ownerEmail&&r("span",{children:l.ownerEmail}),l.accountLabel&&r("span",{children:["Account: ",l.accountLabel]})]}),r("section",{class:"panel",children:[r("h2",{children:"Projects"}),r("div",{class:"linked-projects",children:[d(l).map(_=>r("a",{href:De("projects",_.id),children:[_.name,r("span",{children:_.status})]})),!d(l).length&&r("p",{class:"muted",children:"No projects reported for this profile yet."})]})]}),r("section",{class:"panel",children:[r("h2",{children:"Missions"}),r("div",{class:"linked-projects",children:[p(l).map(_=>r("a",{href:De("missions",_.id),children:[_.name,r("span",{children:[e.projects[_.projectId]?.name," · ",_.status]})]},_.id)),!p(l).length&&r("p",{class:"muted",children:"No missions reported for this profile yet."})]})]}),r("section",{class:"panel",children:[r("h2",{children:"Tasks"}),r("div",{class:"task-table",children:f(l).map(o)})]}),r("section",{class:"panel",children:[r("h2",{children:"Sessions & child agents"}),r("div",{class:"sessions-view",children:[y(l).map(({session:_,depth:w})=>r("div",{class:"session-card",style:{marginLeft:`${Math.min(w,4)*20}px`},children:[r("strong",{children:_.agentId||ot(_.agent)}),r("span",{children:[_.parentAgentId?`Child of ${_.parentAgentId}`:"Reporter session"," · Last report ",new Date(_.lastSeenAt).toLocaleString()]}),r("dl",{children:[r("dt",{children:"Angine session"}),r("dd",{children:_.id}),_.sourceSessionId&&r(Z,{children:[r("dt",{children:"Agent session"}),r("dd",{children:_.sourceSessionId})]}),r("dt",{children:"Projects"}),r("dd",{children:(_.projectIds||[_.projectId]).map(v=>r("a",{class:"session-project",href:De("projects",v),children:e.projects[v]?.name||v}))}),r("dt",{children:"Missions"}),r("dd",{children:(_.missionIds||[_.missionId]).map(v=>r("a",{class:"session-project",href:De("missions",v),children:e.missions[v]?.name||v}))}),r("dt",{children:"Latest task reports"}),r("dd",{children:Object.values(e.tasks).filter(v=>v.updatedBySessionId===_.id).map(v=>r("a",{class:"session-project",href:De("tasks",v.id),children:v.title}))})]})]},_.id)),!h(l).length&&r("p",{class:"muted",children:"Sessions appear when this agent reports work. Child links require reported parent IDs."})]})]})]}):r("div",{class:"profile-grid",children:u.map(_=>r("article",{class:"panel profile-card",children:[r("div",{class:"panel-heading",children:[r("a",{href:De("agents",_.id),children:r("h2",{children:_.name})}),r("button",{class:"text-button",onClick:()=>c(_),children:"Edit"})]}),r("div",{class:"profile-labels",children:[r("span",{children:ot(_.agent)}),r("span",{children:_.context}),_.isDefault&&r("span",{children:"Default"})]}),_.description&&r("p",{class:"muted",children:_.description}),_.ownerName&&r("p",{class:"muted",children:[_.ownerName,_.ownerEmail?` · ${_.ownerEmail}`:""]}),r("a",{class:"profile-counts",href:De("agents",_.id),children:[r("span",{children:[d(_).length," projects"]}),r("span",{children:[p(_).length," missions"]}),r("span",{children:[f(_).length," tasks"]}),r("span",{children:[h(_).length," sessions ↗"]})]})]},_.id))})]})}function vy({task:e,state:t,mutate:n}){const[o,i]=W(e.blocker?.reason||""),[s,a]=W(e.blocker?.nextStep||""),[c,u]=W(e.blocker?.owner||""),[l,h]=W(e.relatedTaskKeys||[]),[f,d]=W(!1),[p,y]=W(!1),_=Object.values(t.tasks).filter(v=>v.missionId===e.missionId&&v.id!==e.id),w=_.filter(v=>l.includes(v.key)||v.relatedTaskKeys?.includes(e.key));return r("section",{class:"panel",children:[r("h2",{children:e.status==="blocked"?"Blocker & related work":"Related work"}),w.length?r("div",{class:"related-links",children:w.map(v=>r("a",{href:De("tasks",v.id),children:[v.title,r("span",{children:[ot(v.updatedBy)," · ",v.status.replaceAll("_"," ")]})]}))}):r("p",{class:"muted",children:"Link related tasks from any agent working in this mission."}),r("form",{class:"workflow-form",onSubmit:async v=>{v.preventDefault(),d(!0);const k=await n("task-details",{taskId:e.id,relatedTaskKeys:l,...e.status==="blocked"?{blocker:o.trim()?{reason:o,nextStep:s,owner:c}:null}:{}});d(!1),y(k)},children:[e.status==="blocked"&&r(Z,{children:[r("label",{children:["What is blocking this task?",r("textarea",{maxLength:500,value:o,onInput:v=>{i(v.currentTarget.value),y(!1)},placeholder:e.note||"Describe the blocker…"})]}),r("label",{children:["What needs to happen next?",r("textarea",{maxLength:500,value:s,onInput:v=>{a(v.currentTarget.value),y(!1)}})]}),r("label",{children:["Who can unblock it?",r("input",{maxLength:160,value:c,onInput:v=>{u(v.currentTarget.value),y(!1)}})]})]}),r("label",{children:["Related tasks",r("select",{multiple:!0,onChange:v=>{h(Array.from(v.currentTarget.selectedOptions).map(k=>k.value)),y(!1)},size:Math.min(5,Math.max(2,_.length)),children:_.map(v=>r("option",{value:v.key,selected:l.includes(v.key),children:[v.title," · ",ot(v.updatedBy)]}))})]}),r("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."}),r("button",{class:"primary-button",disabled:f,children:f?"Saving…":"Save details"}),p&&r("span",{class:"saved-message",children:"Saved"})]})]})}function _y({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,i)=>i.archivedAt.localeCompare(o.archivedAt));return r(Z,{children:[r("div",{class:"view-heading",children:r("div",{children:[r("h1",{children:["Archive ",r("span",{class:"section-count",children:n.length})]}),r("p",{children:"Projects and missions hidden from the main views. Tasks and history are preserved."})]})}),r("div",{class:"panel archive-list",children:[n.map(o=>r("div",{children:[r("a",{href:De(o.kind,o.id),children:[r("strong",{children:o.name}),r("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&&r("span",{children:"Restore the parent project to make this mission visible."})]}),r("button",{class:"secondary-button",onClick:()=>t("archive",{projectId:o.id,archived:!1}),children:"Restore"})]},o.id)),!n.length&&r("p",{class:"muted",children:"No archived projects or missions."})]})]})}function wy({preferences:e,setPreferences:t,resetFilters:n,agents:o,saveNotifications:i,testNotifications:s,notificationError:a,notificationSupported:c}){const[u,l]=W(""),h=async d=>{l("Saving…");try{await i({...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 r(Z,{children:[r("div",{class:"view-heading",children:r("div",{children:[r("h1",{children:"Preferences"}),r("p",{children:"Activity indicators, saved filters, and alerts."})]})}),r("section",{class:"panel settings-panel",children:[r("h2",{children:"Stale activity"}),r("label",{children:["Flag active work after no reported update for",r("select",{value:e.staleMinutes,onChange:d=>t({...e,staleMinutes:Number(d.currentTarget.value)}),children:[r("option",{value:0,children:"Off"}),r("option",{value:15,children:"15 minutes"}),r("option",{value:60,children:"1 hour"}),r("option",{value:240,children:"4 hours"}),r("option",{value:1440,children:"1 day"})]})]}),r("p",{class:"muted",children:"Stale describes reporting activity. It does not change a task's status."})]}),r("section",{class:"panel settings-panel",children:[r("h2",{children:"Saved filters"}),r("p",{class:"muted",children:"Project, mission, agent, profile, status, and search selections are remembered separately for each view on this device."}),r("button",{class:"secondary-button",onClick:()=>{n(),l("Saved filters reset.")},children:"Reset saved filters"})]}),r("section",{class:"panel settings-panel",children:[r("h2",{children:"System notifications"}),r("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?r(Z,{children:[r("button",{class:"secondary-button",onClick:()=>{h({enabled:!e.notifications.enabled})},children:e.notifications.enabled?"Disable notifications":"Enable notifications"}),e.notifications.enabled&&r("div",{class:"notification-options",children:[r("label",{class:"check-label",children:[r("input",{type:"checkbox",checked:e.notifications.completed,onChange:d=>{h({completed:d.currentTarget.checked})}}),"Task completed"]}),r("label",{class:"check-label",children:[r("input",{type:"checkbox",checked:e.notifications.attention,onChange:d=>{h({attention:d.currentTarget.checked})}}),"Needs attention (blocked or failed)"]}),r("label",{children:["Agent",r("select",{value:e.notifications.agent,onChange:d=>{h({agent:d.currentTarget.value})},children:[r("option",{value:"all",children:"All agents"}),o.map(d=>r("option",{value:d,children:ot(d)},d))]})]}),r("button",{class:"secondary-button",onClick:f,children:"Send test notification"})]})]}):r("p",{class:"muted",children:"Native alerts are currently supported on macOS and Linux."}),r("p",{class:"muted",role:"status",children:u||a})]})]})}function de({name:e,className:t=""}){const n={overview:r(Z,{children:[r("rect",{x:"3",y:"4",width:"7",height:"7",rx:"2"}),r("path",{d:"M14 4h7M14 8h5M3 16h18M3 20h12"}),r("circle",{class:"icon-node",cx:"20",cy:"20",r:"1"})]}),projects:r(Z,{children:[r("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"}),r("path",{d:"M7 12v5h9"}),r("circle",{class:"icon-node",cx:"16",cy:"12",r:"1.5"}),r("path",{d:"M16 14v3"})]}),missions:r(Z,{children:[r("circle",{cx:"6",cy:"5",r:"2"}),r("path",{d:"M6 7v10h10M6 11h10"}),r("circle",{class:"icon-node",cx:"18",cy:"11",r:"2"}),r("circle",{cx:"18",cy:"17",r:"2"})]}),tasks:r(Z,{children:[r("rect",{x:"4",y:"3",width:"16",height:"18",rx:"3"}),r("path",{d:"m8 9 2 2 5-5M8 16h5"}),r("circle",{class:"icon-node",cx:"17",cy:"16",r:"1"})]}),board:r(Z,{children:[r("rect",{x:"3",y:"4",width:"18",height:"16",rx:"3"}),r("path",{d:"M9 4v16M15 4v16M5.5 8h1M11.5 12h1M17.5 8h1"})]}),tree:r(Z,{children:[r("rect",{x:"9",y:"2",width:"6",height:"5",rx:"1.5"}),r("path",{d:"M12 7v5M5 16v-4h14v4"}),r("rect",{x:"2",y:"16",width:"6",height:"5",rx:"1.5"}),r("rect",{x:"16",y:"16",width:"6",height:"5",rx:"1.5"})]}),insights:r(Z,{children:[r("path",{d:"M3 4v16h18M7 15v-4M12 15V7M17 15v-6"}),r("circle",{class:"icon-node",cx:"17",cy:"5",r:"1.5"})]}),agents:r(Z,{children:[r("circle",{cx:"12",cy:"8",r:"4"}),r("path",{d:"M5 21v-2a7 7 0 0 1 14 0v2M3 6v5M21 6v5M9 8h.01M15 8h.01"}),r("path",{class:"icon-signal",d:"M10 17h4"})]}),archive:r(Z,{children:[r("rect",{x:"3",y:"3",width:"18",height:"5",rx:"1.5"}),r("path",{d:"M5 8v11a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8M9 12h6M12 12v4"})]}),settings:r(Z,{children:[r("path",{d:"M4 7h16M4 17h16"}),r("circle",{cx:"9",cy:"7",r:"3",fill:"var(--field-surface,white)"}),r("circle",{cx:"15",cy:"17",r:"3",fill:"var(--field-surface,white)"})]}),attention:r(Z,{children:[r("path",{d:"M12 3 2 20h20L12 3ZM12 9v5"}),r("circle",{class:"icon-node",cx:"12",cy:"17",r:".8"})]}),arrow:r(Z,{children:r("path",{d:"M5 18 18 5M7 5h11v11"})}),check:r(Z,{children:[r("circle",{cx:"12",cy:"12",r:"9"}),r("path",{class:"icon-check",d:"m7.5 12 3 3 6-6"})]}),search:r(Z,{children:[r("circle",{cx:"10",cy:"10",r:"6.5"}),r("path",{d:"m15 15 6 6"})]}),signal:r(Z,{children:[r("circle",{class:"icon-node",cx:"5",cy:"12",r:"2"}),r("path",{d:"M9 12h4M15 6a8 8 0 0 1 0 12M19 3a12 12 0 0 1 0 18"})]})};return r("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 Mo({seed:e}){const t=[...e].reduce((n,o)=>n+o.charCodeAt(0),0);return r("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:[r("path",{d:t%2?"M8 7v18M8 16h16M24 7v18":"M8 8h16M16 8v16M8 24h16"}),r("circle",{cx:t%2?8:16,cy:"8",r:"3",fill:"currentColor",stroke:"none"}),r("rect",{x:t%3?20:5,y:"21",width:"6",height:"6",rx:t%3?1.5:3,fill:"currentColor",stroke:"none"}),r("circle",{cx:"24",cy:"8",r:"2.5"})]})}function xy(e,t,n=Date.now()){const o=new Date(n);o.setHours(0,0,0,0),t.days&&o.setDate(o.getDate()-t.days+1);const i=h=>!t.days||!!(h&&Number.isFinite(Date.parse(h))&&Date.parse(h)>=o.getTime()&&Date.parse(h)<=n),s=h=>e.projectAliases?.[h]||h,a=[...new Map(Object.values(e.tasks).map(h=>[h.id,h])).values()],c=[...new Map(Object.values(e.missions).map(h=>[h.id,h])).values()],u=[],l=new Set;for(const h of Object.values(e.projects)){const f=s(h.id);if(l.has(f))continue;l.add(f);const d=e.projects[f]||h;if(t.project!=="all"&&f!==s(t.project)||!t.includeArchived&&d.archivedAt)continue;const p=[];for(const _ of c.filter(w=>s(w.projectId)===f)){if(!t.includeArchived&&_.archivedAt)continue;const w=a.filter(m=>m.missionId===_.id),v=[...new Set(w.map(m=>m.updatedBy))].sort(),k=w.filter(m=>m.status==="completed"&&i(m.completedAt)&&(t.agent==="all"||m.updatedBy===t.agent)).sort((m,C)=>(C.completedAt||"").localeCompare(m.completedAt||"")||m.title.localeCompare(C.title)),g=_.status==="completed"&&i(_.completedAt)&&(t.agent==="all"||v.includes(t.agent));!k.length&&!g||p.push({mission:_,tasks:k,completedInRange:g,agents:v})}if(!p.length)continue;p.sort((_,w)=>(w.mission.completedAt||w.tasks[0]?.completedAt||"").localeCompare(_.mission.completedAt||_.tasks[0]?.completedAt||""));const y=p.flatMap(_=>[..._.tasks.map(w=>w.completedAt),..._.completedInRange?[_.mission.completedAt]:[]]).filter(_=>!!_).sort();u.push({project:d,missions:p,completedTasks:p.reduce((_,w)=>_+w.tasks.length,0),completedMissions:p.filter(_=>_.completedInRange).length,latestCompletion:y.at(-1)})}return u.sort((h,f)=>(f.latestCompletion||"").localeCompare(h.latestCompletion||"")||h.project.name.localeCompare(f.project.name)),{projects:u,totals:{projects:u.length,missions:u.reduce((h,f)=>h+f.completedMissions,0),tasks:u.reduce((h,f)=>h+f.completedTasks,0)}}}const nr=(e,t)=>`#/${e}/${encodeURIComponent(t)}`,Ys=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"Date not reported";function by({journey:e,state:t}){const{project:n,missions:o,completedTasks:i,completedMissions:s}=e;return r("article",{class:"accomplishment-card",style:{"--journey-color":Vt(t,n.id)},children:[r("div",{class:"accomplishment-card-top",children:[r("span",{class:"accomplishment-glyph",children:r(Mo,{seed:n.id})}),r("div",{children:[r("h3",{children:r("a",{href:nr("projects",n.id),children:[n.name,r(de,{name:"arrow"})]})}),r("span",{children:[n.archivedAt?"Archived project":"Project"," · ",Ys(e.latestCompletion)]})]})]}),r("div",{class:"accomplishment-card-counts",children:[r("span",{children:[r("strong",{children:s})," missions completed"]}),r("span",{children:[r("strong",{children:i})," tasks completed"]})]}),r("section",{class:"accomplishment-missions","aria-label":`${n.name} mission journeys`,children:o.map(a=>r("details",{class:"accomplishment-mission",children:[r("summary",{children:[r("span",{class:"accomplishment-chevron","aria-hidden":"true",children:"›"}),r(de,{name:a.completedInRange?"check":"missions"}),r("span",{children:[r("strong",{children:a.mission.name}),r("small",{children:[a.completedInRange?"Completed mission":"Completed tasks in an ongoing mission",a.mission.archivedAt?" · Archived":""," · ",a.tasks.length," tasks in view"]})]})]}),r("div",{class:"accomplishment-tasks",children:[r("div",{class:"accomplishment-agents",children:[r("span",{children:"Reporting agents"}),a.agents.map(c=>r("span",{children:ot(c)},c))]}),a.tasks.length?r("ul",{children:a.tasks.map(c=>r("li",{children:[r(de,{name:"check"}),r("a",{href:nr("tasks",c.id),children:[r("strong",{children:c.title}),r("span",{children:[ot(c.updatedBy)," · ",Ys(c.completedAt)]})]})]},c.id))}):r("p",{children:"No completed tasks have completion dates in this range."}),r("a",{class:"accomplishment-mission-link",href:nr("missions",a.mission.id),children:["Open mission",r(de,{name:"arrow"})]})]})]},a.mission.id))})]})}function ky({state:e,project:t,agent:n}){const[o,i]=W(0),[s,a]=W(!1),c=xy(e,{days:o,project:t,agent:n,includeArchived:s});return r("section",{class:"your-work","aria-labelledby":"your-work-heading",children:[r("div",{class:"your-work-heading",children:[r("div",{children:[r("h2",{id:"your-work-heading",children:"The work you've moved forward."}),r("p",{children:"Completed missions and the steps behind them."})]}),r("div",{class:"your-work-controls",children:[r("label",{children:[r("span",{children:"Completed"}),r("select",{value:o,onChange:u=>i(Number(u.currentTarget.value)),children:[r("option",{value:0,children:"All time"}),r("option",{value:7,children:"Last 7 days"}),r("option",{value:30,children:"Last 30 days"}),r("option",{value:90,children:"Last 90 days"})]})]}),r("label",{class:"your-work-archives",children:[r("input",{type:"checkbox",checked:s,onChange:u=>a(u.currentTarget.checked)}),"Include archived work"]})]})]}),r("div",{class:"accomplishment-totals",children:[["projects","Projects with completed work",c.totals.projects],["missions","Missions completed",c.totals.missions],["tasks","Unique tasks completed",c.totals.tasks]].map(([u,l,h])=>r("div",{children:[r("span",{class:"accomplishment-total-icon",children:r(de,{name:u})}),r("strong",{children:h}),r("span",{children:l})]},String(u)))}),c.projects.length?r("div",{class:"accomplishment-scroll",tabIndex:c.projects.length>4?0:void 0,role:c.projects.length>4?"region":void 0,"aria-label":"Project accomplishments",children:r("div",{class:"accomplishment-grid",children:c.projects.map(u=>r(by,{journey:u,state:e},u.project.id))})}):r("div",{class:"field-empty",children:[r(de,{name:"missions"}),r("h3",{children:"No completed work in this view yet."}),r("p",{children:"Try another date range, project, or agent, or include archived work."})]}),r("p",{class:"field-footnote",children:"Currently completed work, counted once per task. Date filters use reported completion dates. Reopened tasks return here when completed again. Reporting agents are the latest reporters on a mission’s tasks."})]})}function Il({seq:e,projectIds:t,agent:n="all",profile:o="all",compact:i=!1}){const[s,a]=W(14),[c,u]=W(),[l,h]=W(""),[f,d]=W(0),[p,y]=W(),_=[...t].sort().join(","),w=new Date().toLocaleDateString(),v=`${_}:${n}:${o}:${s}:${w}`;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:v,data:A})}).catch(A=>{b.signal.aborted||h(A.message||"Activity history is unavailable.")}),()=>b.abort()},[e,_,n,o,s,w,f]);const k=c?.key===v?c.data:void 0,g=Math.max(1,...k?.days.flatMap(b=>[b.started,b.completed])||[]),m=k?.days.find(b=>b.date===p),C=b=>new Date(b+"T12:00:00").toLocaleDateString(void 0,{month:"short",day:"numeric"});return r("section",{class:`field-panel field-activity ${i?"compact":""}`,"aria-labelledby":"activity-chart-heading",children:[r("div",{class:"field-panel-heading",children:[r("div",{children:[r("h2",{id:"activity-chart-heading",children:"Work in motion"}),r("span",{children:"Agent-reported task transitions"})]}),r("label",{class:"chart-range",children:[r("span",{class:"visually-hidden",children:"Activity date range"}),r("select",{value:s,onChange:b=>{a(Number(b.currentTarget.value)),y(void 0)},children:[7,14,30,90].map(b=>r("option",{value:b,children:["Last ",b," days"]},b))})]})]}),l?r("div",{class:"field-chart-empty",role:"status",children:[r(de,{name:"signal"}),r("p",{children:l}),r("button",{class:"secondary-button",onClick:()=>d(b=>b+1),children:"Try again"})]}):k?r(Z,{children:[!i&&r("div",{class:"insight-metrics",children:["started","completed","blocked","failed"].map(b=>r("div",{children:[r("span",{children:b==="completed"?"Completions":b==="started"?"Starts":b==="blocked"?"Blocked reports":"Failed reports"}),r("strong",{children:k.totals[b]})]},b))}),r("div",{class:"field-chart-legend",children:[r("span",{children:[r("i",{}),"Started"]}),r("span",{children:[r("i",{}),"Completed"]})]}),r("figure",{class:"field-chart-figure",children:[r("div",{class:"field-chart-wrap",children:[r("div",{class:"field-chart-axis","aria-hidden":"true",children:[r("span",{children:g}),r("span",{children:Math.round(g/2)}),r("span",{children:"0"})]}),r("div",{class:"field-chart-plot",style:{"--days":k.days.length},children:k.days.map((b,E)=>r("button",{type:"button",class:`field-chart-day ${p===b.date?"selected":""}`,onClick:()=>y(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:[r("span",{class:"field-chart-bars",children:[r("i",{style:{height:`${b.started/g*100}%`}}),r("i",{style:{height:`${b.completed/g*100}%`}})]}),(E===0||E===k.days.length-1||E===Math.floor(k.days.length/2))&&r("span",{class:"field-chart-date",children:C(b.date)})]},b.date))})]}),r("figcaption",{children:[m?r("span",{children:[r("strong",{children:C(m.date)})," · ",m.started," started · ",m.completed," completed · ",m.blocked," blocked · ",m.failed," failed"]}):r("span",{children:k.totals.completed?r(Z,{children:[r("strong",{children:[k.totals.completed," completions"]})," over ",s," days"]}):"No task completions reported in this period."}),r("span",{children:"Local time"})]})]}),r("details",{class:"field-chart-data",children:[r("summary",{children:"View daily numbers"}),r("div",{class:"field-table-scroll",tabIndex:0,role:"region","aria-label":"Daily task transitions",children:r("table",{children:[r("caption",{children:["Task status transitions · last ",s," days"]}),r("thead",{children:r("tr",{children:[r("th",{scope:"col",children:"Day"}),r("th",{scope:"col",children:"Started"}),r("th",{scope:"col",children:"Completed"}),r("th",{scope:"col",children:"Blocked"}),r("th",{scope:"col",children:"Failed"})]})}),r("tbody",{children:k.days.map(b=>r("tr",{children:[r("th",{scope:"row",children:C(b.date)}),r("td",{children:b.started}),r("td",{children:b.completed}),r("td",{children:b.blocked}),r("td",{children:b.failed})]},b.date))})]})})]}),!i&&r("div",{class:"field-agent-totals",children:[r("h3",{children:"Completions by reporting agent"}),k.agents.length?k.agents.map(b=>r("div",{children:[r("span",{children:b.agent}),r("div",{class:"field-mini-track",children:r("span",{style:{transform:`scaleX(${b.completed/Math.max(1,...k.agents.map(E=>E.completed))})`}})}),r("strong",{children:b.completed})]},b.agent)):r("p",{children:"No completions reported."}),r("p",{children:"Counts reflect reported transitions, including completed tasks reopened and completed again."})]})]}):r("div",{class:"field-chart-empty",children:r("span",{children:"Loading activity history…"})})]})}function Sy({state:e}){const[t,n]=W("work"),[o,i]=W("all"),[s,a]=W("all"),c=Object.values(e.projects).filter(h=>t==="work"||!h.archivedAt),u=[...new Set(Object.values(e.tasks).map(h=>h.updatedBy))].sort(),l=c.filter(h=>o==="all"||h.id===o).map(h=>h.id);return r("div",{class:"field-insights",children:[r("div",{class:"field-page-heading",children:[r("div",{children:[r("span",{class:"field-eyebrow",children:"Workspace / Insights"}),r("h1",{children:t==="work"?"Your work.":"Work, day by day."})]}),r("div",{class:"field-insight-filters",children:[r("label",{children:[r("span",{children:"Project"}),r("select",{value:o,onChange:h=>i(h.currentTarget.value),children:[r("option",{value:"all",children:"All projects"}),c.map(h=>r("option",{value:h.id,children:h.name},h.id))]})]}),r("label",{children:[r("span",{children:"Agent"}),r("select",{value:s,onChange:h=>a(h.currentTarget.value),children:[r("option",{value:"all",children:"All agents"}),u.map(h=>r("option",{children:h},h))]})]})]})]}),r("div",{class:"field-segmented insights-view-switch",role:"group","aria-label":"Insights view",children:[r("button",{type:"button","aria-pressed":t==="work",onClick:()=>n("work"),children:"Your work"}),r("button",{type:"button","aria-pressed":t==="activity",onClick:()=>n("activity"),children:"Daily activity"})]}),t==="work"?r(ky,{state:e,project:o,agent:s}):r(Z,{children:[r(Il,{seq:e.seq,projectIds:l,agent:s}),r("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)}`:""}`,Ml=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`},Er=e=>({claude:"Claude",codex:"Codex",grok:"Grok",antigravity:"Antigravity",external:"External"})[e]||e;function Cy({project:e,state:t,tasks:n,attention:o,fresh:i}){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=>Ft(t,p)?.name||Er(p.updatedBy)))],f=[...n].sort((p,y)=>y.updatedAt.localeCompare(p.updatedAt))[0],d=Vt(t,e.id);return r("article",{class:`field-project ${i?"has-new-report":""}`,style:{"--project-color":d},children:[r("a",{class:"field-project-main",href:We("projects",e.id),children:[r("div",{class:"field-project-top",children:[r("span",{class:"field-project-glyph",children:r(Mo,{seed:e.id})}),r("span",{class:`field-project-status ${a?"running":""}`,children:[r("i",{}),a?`${a} running`:c.length&&u===c.length?"All complete":"No running missions"]}),r(de,{name:"arrow",className:"field-project-arrow"})]}),r("h3",{children:e.name}),r("p",{children:e.description||`${s.length} ${s.length===1?"mission":"missions"} · ${n.length} tasks`}),r("div",{class:"field-progress-meta",children:[r("span",{children:c.length?`${u} of ${c.length} tasks complete`:"No tasks reported"}),r("strong",{children:l==null?"—":`${l}%`})]}),r("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:r("span",{style:{transform:`scaleX(${(l||0)/100})`}})}),r("div",{class:"field-project-bottom",children:[r("span",{children:[s.length," missions · ",Ml(f?.updatedAt||e.updatedAt)]}),r("span",{class:"field-avatars","aria-label":`Agents: ${h.join(", ")||"none reported"}`,children:[h.slice(0,3).map(p=>r("span",{title:p,children:p.slice(0,2)},p)),h.length>3&&r("span",{children:["+",h.length-3]})]})]}),o>0&&r("div",{class:"field-project-attention",children:[r(de,{name:"attention"}),r("span",{children:[o," ",o===1?"task needs":"tasks need"," attention"]}),r(de,{name:"arrow"})]})]}),r("details",{class:"field-mission-preview",children:[r("summary",{children:[r(de,{name:"missions"}),r("span",{children:"Explore missions"}),r("span",{class:"field-disclosure",children:"+"})]}),r("div",{class:"field-mission-content",children:[s.slice(0,4).map(p=>r("a",{href:We("missions",p.id),children:[r("span",{class:`field-mission-dot ${p.status}`}),r("span",{children:p.name}),r("small",{children:p.status==="running"?"Running":p.status==="completed"?"Done":p.status})]},p.id)),s.length>4&&r("a",{href:We("projects",e.id),children:["View all ",s.length," missions ",r(de,{name:"arrow"})]}),!s.length&&r("p",{children:"No missions reported yet."})]})]})]})}function Ey({state:e,projects:t,tasks:n,health:o,staleMinutes:i,agent:s="all",profile:a="all"}){const[c,u]=W("all"),[l,h]=W([]),f=re();ne(()=>{const m=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(m).filter(E=>m[E]&&f.current?.[E]!==void 0&&f.current[E]!==m[E]);h(b)}f.current=m;const C=setTimeout(()=>h([]),1600);return()=>clearTimeout(C)},[e.seq]);const d=new Set(t.map(m=>m.id)),p=n.filter(m=>d.has(m.projectId)&&(s==="all"||m.updatedBy===s)&&(a==="all"||Ft(e,m)?.id===a)),y=Sl(e,p,o,i),_=m=>y.filter(C=>C.task.projectId===m).length,w=m=>Object.values(e.missions).filter(C=>C.projectId===m&&!C.archivedAt&&C.status==="running").length,v=t.filter(m=>c==="all"||c==="running"&&w(m.id)>0||c==="attention"&&_(m.id)>0),k=new Map;for(const m of p.filter(C=>["todo","in_progress","blocked","failed"].includes(C.status))){const C=Ft(e,m),b=C?.id||m.updatedBy,E=k.get(b)||{id:C?.id||"",name:C?.name||Er(m.updatedBy),tasks:[]};E.tasks.push(m),k.set(b,E)}const g=[...p].sort((m,C)=>C.updatedAt.localeCompare(m.updatedAt)).slice(0,3);return r("div",{class:"field-overview",children:[r("div",{class:"field-page-heading",children:[r("div",{children:[r("span",{class:"field-eyebrow",children:new Date().toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"})}),r("h1",{children:"Your work, in view."})]}),r("a",{class:"field-insights-link",href:We("insights"),children:[r(de,{name:"insights"}),"Explore insights",r(de,{name:"arrow"})]})]}),r("section",{class:"field-metrics","aria-label":"Workspace summary",children:[["Projects",t.length,"In this view","projects"],["Running missions",t.reduce((m,C)=>m+w(C.id),0),"Latest reported status","missions"],["Tasks in progress",p.filter(m=>m.status==="in_progress").length,"Reported by agents","tasks"],["Needs attention",y.length,"Blocked, failed, or quiet","attention"]].map(([m,C,b,E])=>r("div",{children:[r("span",{class:"field-metric-label",children:[r(de,{name:E}),m]}),r("strong",{children:C}),r("span",{class:"field-metric-foot",children:b})]},String(m)))}),r("div",{class:"field-home-grid",children:[r("div",{class:"field-home-main",children:[r("section",{"aria-labelledby":"field-projects-heading",children:[r("div",{class:"field-section-heading",children:[r("h2",{id:"field-projects-heading",children:["Your projects ",r("span",{children:v.length})]}),r("div",{class:"field-segmented",role:"group","aria-label":"Filter overview projects",children:["all","running","attention"].map(m=>r("button",{type:"button","aria-pressed":c===m,onClick:()=>u(m),children:m==="all"?"All":m==="running"?"In progress":"Attention"},m))})]}),r("div",{class:"field-project-scroll",tabIndex:v.length>6?0:void 0,role:v.length>6?"region":void 0,"aria-label":"Projects",children:r("div",{class:"field-project-grid",children:[v.map(m=>r(Cy,{project:m,state:e,tasks:p.filter(C=>C.projectId===m.id),attention:_(m.id),fresh:l.includes(m.id)},m.id)),!v.length&&r("div",{class:"field-empty",children:[r(Mo,{seed:"angine"}),r("h3",{children:t.length?"No projects in this view.":"Your next project starts here."}),r("p",{children:t.length?"Choose a different project filter.":"Connect an agent and ask it to report its work."}),r("a",{href:We("agents"),children:["View agent connections ",r(de,{name:"arrow"})]})]})]})})]}),r(Il,{compact:!0,seq:e.seq,projectIds:[...d],agent:s,profile:a})]}),r("aside",{class:"field-home-aside",children:[r("section",{class:"field-panel field-attention",children:[r("div",{class:"field-panel-heading",children:[r("h2",{children:"Needs your attention"}),r("span",{class:"field-count",children:y.length})]}),y.length?r("div",{class:"field-attention-list",children:y.slice(0,5).map(({task:m,reason:C})=>r("a",{href:We("tasks",m.id),children:[r(de,{name:"attention"}),r("div",{children:[r("strong",{children:m.title}),r("span",{children:[e.projects[m.projectId]?.name," / ",e.missions[m.missionId]?.name]}),r("small",{children:C})]}),r(de,{name:"arrow"})]},m.id))}):r("div",{class:"field-all-clear",children:[r(de,{name:"check"}),r("strong",{children:"Room to focus."}),r("span",{children:"No tasks need attention in this view."})]}),y.length>5&&r("a",{class:"field-panel-link",href:We("tasks"),children:["Review all ",y.length," tasks",r(de,{name:"arrow"})]})]}),r("section",{class:"field-panel",children:[r("div",{class:"field-panel-heading",children:[r("h2",{children:"Reported open work"}),r("a",{href:We("agents"),"aria-label":"View agents",children:r(de,{name:"arrow"})})]}),[...k.values()].sort((m,C)=>C.tasks.length-m.tasks.length).slice(0,4).map(m=>r("a",{class:"field-agent-row",href:We("agents",m.id||void 0),children:[r("span",{class:"field-agent-glyph",children:r(de,{name:"agents"})}),r("span",{children:[r("strong",{children:m.name}),r("small",{children:[m.tasks.filter(C=>C.status==="in_progress").length," in progress · ",m.tasks.length," open"]})]})]},m.name)),!k.size&&r("p",{class:"field-empty-copy",children:"No open task reports."})]}),r("section",{class:"field-panel",children:[r("div",{class:"field-panel-heading",children:r("h2",{children:"Latest task reports"})}),g.map(m=>r("a",{class:"field-recent-row",href:We("tasks",m.id),children:[r(de,{name:m.status==="completed"?"check":"signal"}),r("span",{children:[r("strong",{children:m.title}),r("small",{children:[e.projects[m.projectId]?.name," · ",Er(m.updatedBy)," · ",Ml(m.updatedAt)]})]})]},m.id)),!g.length&&r("p",{class:"field-empty-copy",children:"No task reports yet."})]})]})]})]})}function Ny(e){const t=new Map;for(const n of e){if(n.phase!=="monitoring")continue;const o=JSON.stringify([n.projectId,n.missionId||null]),i=t.get(o);(!i||n.reportedAt>=i.reportedAt)&&t.set(o,n)}return[...t.values()].sort((n,o)=>o.reportedAt.localeCompare(n.reportedAt))}function Al(e,t){return Ny(t).filter(n=>n.status!=="completed"&&!e.projects[n.projectId]?.archivedAt&&(!n.missionId||!e.missions[n.missionId]?.archivedAt))}function Nr({updates:e,state:t,onHide:n,history:o=!1}){const i=o?e:Al(t,e);return i.length?r("section",{class:"monitoring-panel","aria-label":o?"Monitoring history":"Active monitoring",children:[r("div",{class:"monitoring-heading",children:[r(de,{name:"signal"}),r("div",{children:[r("h2",{children:o?"Monitoring history":"Monitoring"}),r("span",{children:[i.length," ",o?"reported checks":"active checks"]})]}),r("div",{class:"monitoring-actions",children:[!o&&r("a",{href:"#/monitoring",children:["View monitoring ",r(de,{name:"arrow"})]}),n&&r("button",{class:"text-button",type:"button",onClick:n,children:"Hide monitoring"})]})]}),r("div",{class:"monitoring-list",children:i.map(s=>{const a=s.missionId?t.missions[s.missionId]:void 0;return r("a",{class:"monitoring-row",href:`#/${a?"missions":"projects"}/${encodeURIComponent(a?.id||s.projectId)}`,children:[r("span",{class:"monitoring-copy",children:[r("span",{class:"monitoring-location",children:[t.projects[s.projectId]?.name||"Project",a?` / ${a.name}`:""]}),r("strong",{children:s.summary}),s.nextStep&&r("span",{class:"monitoring-next",children:["Next: ",s.nextStep]}),r("span",{class:"monitoring-byline",children:[ot(s.updatedBy)," · ",r("time",{dateTime:s.reportedAt,children:new Date(s.reportedAt).toLocaleString()})]})]}),r("span",{class:"monitoring-state",children:[r("span",{class:`badge ${s.status}`,children:{in_progress:"In progress",completed:"Completed",blocked:"Blocked",failed:"Failed"}[s.status]}),s.environment&&r("span",{class:"monitoring-environment",children:s.environment})]}),r(de,{name:"arrow"})]},s.id)})})]}):null}function Iy({state:e,showOnDashboard:t,setShowOnDashboard:n}){const[o,i]=W("active"),[s,a]=W([]),[c,u]=W(!0),[l,h]=W(""),[f,d]=W(0),[p,y]=W("all"),_=Object.keys(e.projects).sort().join(",");ne(()=>{const k=new AbortController;return u(!0),h(""),Promise.all(_.split(",").filter(Boolean).map(async g=>{const m=await fetch(`/api/projects/${encodeURIComponent(g)}/events`,{signal:k.signal});if(!m.ok)throw new Error("Monitoring history could not be loaded.");return(await m.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(k.signal.aborted)return;const m=new Map(g.flat().map(C=>[C.id,C]));a([...m.values()].sort((C,b)=>b.reportedAt.localeCompare(C.reportedAt)))}).catch(g=>{k.signal.aborted||h(g.message)}).finally(()=>{k.signal.aborted||u(!1)}),()=>k.abort()},[e.seq,_,f]);const w=Al(e,s),v=(o==="active"?w:s).filter(k=>p==="all"||k.projectId===p);return r("div",{class:"monitoring-page",children:[r("div",{class:"field-page-heading",children:[r("div",{children:[r("span",{class:"field-eyebrow",children:"Workspace"}),r("h1",{children:"Monitoring"})]}),r("label",{class:"monitoring-visibility",children:[r("input",{type:"checkbox",checked:t,onChange:k=>n(k.currentTarget.checked)}),"Show monitoring on dashboard"]})]}),r("div",{class:"monitoring-toolbar",children:[r("div",{class:"field-segmented",role:"group","aria-label":"Monitoring view",children:[r("button",{type:"button","aria-pressed":o==="active",onClick:()=>i("active"),children:["Active ",!c&&!l&&w.length]}),r("button",{type:"button","aria-pressed":o==="history",onClick:()=>i("history"),children:["History ",!c&&!l&&s.length]})]}),r("label",{children:["Project",r("select",{value:p,onChange:k=>y(k.currentTarget.value),children:[r("option",{value:"all",children:"All projects"}),Object.values(e.projects).map(k=>r("option",{value:k.id,children:[k.name,k.archivedAt?" (archived)":""]},k.id))]})]})]}),l?r("div",{class:"field-panel",role:"status",children:[r("p",{children:l}),r("button",{class:"secondary-button",onClick:()=>d(k=>k+1),children:"Try again"})]}):c?r("div",{class:"field-panel",children:r("p",{children:"Loading monitoring history…"})}):v.length?r(Nr,{state:e,updates:v,history:o==="history"}):r("div",{class:"field-empty",children:[r(de,{name:o==="active"?"check":"signal"}),r("h3",{children:o==="active"?"No active monitoring.":"No monitoring history yet."}),r("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"},Ir={request:"Request",implementation:"Implementation",deployment:"Deployment",monitoring:"Monitoring",blocker:"Blocker"},Pe=e=>e?.trim()||"external",pt=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`},or=e=>e.status==="completed"?100:e.status==="todo"?0:e.progress,ke=(e,t)=>`#/${e}${t?`/${encodeURIComponent(t)}`:""}`;function Gn({status:e}){return r("span",{class:`badge ${e}`,children:[r("span",{class:"status-dot"}),Xe[e]||e]})}function My({update:e,state:t}){if(e.phase==="monitoring")return null;const n=e.missionId?t.missions[e.missionId]:void 0;return r("section",{class:"panel work-update-card",children:[r("div",{class:"panel-heading",children:[r("h2",{children:"Latest agent update"}),r(Gn,{status:e.status})]}),r("div",{class:"work-update-meta",children:[r("strong",{children:Ir[e.phase]||e.phase}),r("span",{children:[pt(e.updatedBy)," · ",At(e.reportedAt),e.environment?` · ${e.environment}`:""]}),n&&r("a",{href:ke("missions",n.id),children:n.name})]}),r("p",{children:e.summary}),e.nextStep&&r("div",{class:"work-update-next",children:[r("strong",{children:"Next"}),r("span",{children:e.nextStep})]}),r("small",{children:"Agent reported · Angine does not independently verify deployments or production health."})]})}function Vn({value:e,caption:t="Progress"}){return r("div",{class:"progress",children:[r("div",{class:"progress-label",children:[r("span",{children:t}),r("strong",{children:e==null?"Not reported":`${Math.round(e)}%`})]}),r("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&&r("span",{style:{width:`${e}%`}})})]})}function Ay({session:e,state:t,health:n}){const o=Io(t,e);return r("div",{class:"reporter",children:[r("div",{class:"reporter-title",children:[r("span",{class:"avatar",children:pt(e.agent).slice(0,1)}),r("div",{children:[r("strong",{children:o?.name||pt(e.agent)}),r("span",{children:[e.agentId||"Reporter"," · ",At(e.lastSeenAt)]})]})]}),r("dl",{children:[o&&r(Z,{children:[r("dt",{children:"Profile"}),r("dd",{children:r("a",{href:ke("agents",o.id),children:o.name})})]}),o?.ownerName&&r(Z,{children:[r("dt",{children:"Owner"}),r("dd",{children:[o.ownerName,o.ownerEmail?` · ${o.ownerEmail}`:""]})]}),r("dt",{children:"Worktree / workspace"}),r("dd",{children:[t.workspaces[e.workspaceId]?.path,t.workspaces[e.workspaceId]?.branch&&r("span",{children:[" · ",t.workspaces[e.workspaceId].branch]})]}),r("dt",{children:"Angine session"}),r("dd",{children:e.id}),e.sourceSessionId&&r(Z,{children:[r("dt",{children:"Agent session"}),r("dd",{children:e.sourceSessionId})]}),e.parentAgentId&&r(Z,{children:[r("dt",{children:"Parent agent"}),r("dd",{children:e.parentAgentId})]}),e.accountLabel&&r(Z,{children:[r("dt",{children:"Account"}),r("dd",{children:e.accountLabel})]})]}),r(ly,{health:n,session:e})]})}function Xs({status:e,items:t,kind:n,limit:o,row:i}){const s=re(null),[a,c]=W(),u=t.length>o;return st(()=>{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,y)=>p+y.getBoundingClientRect().height,0)));f();const d=new ResizeObserver(f);return d.observe(l),h.forEach(p=>d.observe(p)),()=>d.disconnect()},[t,o,u]),r("section",{class:"project-status-section","aria-labelledby":`${n}-${e}`,children:[r("div",{class:"status-section-heading",children:[r("h2",{id:`${n}-${e}`,children:[r("span",{class:`section-status-dot ${e}`}),Xe[e],r("span",{class:"section-count",children:t.length})]}),r("span",{children:u?`Latest ${o} shown · Scroll for ${t.length-o} more`:"Newest updates first"})]}),r("div",{class:"project-list panel",children:[r("div",{class:n==="tasks"?"task-list-head":"project-list-head","aria-hidden":"true",children:[r("span",{children:n==="tasks"?"Task":n==="missions"?"Mission":"Project"}),r("span",{children:"Status"}),r("span",{children:"Progress"}),n!=="tasks"&&r("span",{children:"Agent"}),r("span",{children:"Updated"}),r("span",{})]}),r("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(i):r("div",{class:"status-section-empty",children:["No ",Xe[e].toLowerCase()," ",n," in this view."]})})]})]})}function $y(){const[e,t]=W(null),[n,o]=W(location.hash.slice(1)||"/projects"),[i="projects",s]=n.split("/").filter(Boolean);let a="";try{a=decodeURIComponent(s||"")}catch{}const{filters:c,set:u,reset:l,resetAll:h}=fy(i),{agent:f,status:d,project:p,mission:y,profile:_,query:w,staleOnly:v}=c,{preferences:k,setPreferences:g,saveNotifications:m,testNotifications:C,notificationError:b,notificationSupported:E}=py(),{health:A,compatibility:P}=ay(),[L,j]=W(""),[V,N]=W([]),[S,I]=W(!1),M=re(null),[$,R]=W(),[,D]=W(0),B=x=>t(T=>T&&T.seq>x.seq?T:oy(x)),z=async(x,T)=>{j("");try{return B(await Cr(x,T)),!0}catch(ae){return j(ae.message),!1}};ne(()=>{const x=()=>{o(location.hash.slice(1)||"/projects"),window.scrollTo(0,0)};return window.addEventListener("hashchange",x),()=>window.removeEventListener("hashchange",x)},[]),ne(()=>{fetch("/api/state").then(ae=>{if(!ae.ok)throw new Error;return ae.json()}).then(B).catch(()=>I(!1));const x=new EventSource("/api/events");x.addEventListener("state",ae=>{B(JSON.parse(ae.data)),I(!0)}),x.onerror=()=>I(!1);const T=setInterval(()=>D(ae=>ae+1),3e4);return()=>{x.close(),clearInterval(T)}},[]),st(()=>{const x=M.current;if(i!=="board"||!x)return;const T=()=>R(Math.max(260,window.innerHeight-x.getBoundingClientRect().top-24));T();const ae=new ResizeObserver(T);return x.parentElement&&ae.observe(x.parentElement),window.addEventListener("resize",T),()=>{ae.disconnect(),window.removeEventListener("resize",T)}},[i,!!e]);const O=i==="tasks"&&a?e?.tasks[a]:void 0,F=O?e?.missions[O.missionId]:(i==="missions"||i==="projects")&&a?e?.missions[a]:void 0;O&&(e?.sessions[O.updatedBySessionId||""]?.workspaceId||F?.workspaceId);const U=F?e?.projects[F.projectId]:i==="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 x=!0;return fetch(`/api/${K}/events`).then(T=>{if(!T.ok)throw new Error;return T.json()}).then(T=>{x&&N(T)}).catch(()=>{}),()=>{x=!1}},[K,e?.seq]);const ie=x=>x.sort((T,ae)=>ae.updatedAt.localeCompare(T.updatedAt)),q=ie(Object.values(e?.tasks||{})),H=ie(Object.values(e?.missions||{})),X=ie(Object.values(e?.projects||{})).filter(x=>!x.archivedAt),te=H.filter(x=>!x.archivedAt&&!e?.projects[x.projectId]?.archivedAt),Q=q.filter(x=>e?.missions[x.missionId]&&!bl(e,x)),Y=Object.values(e?.sessions||{}),ee=[...new Set([...Y.map(x=>Pe(x.agent)),...Q.map(x=>Pe(x.updatedBy))])].sort(),se=x=>[...new Set([...x.workspaceIds||[x.workspaceId],...Y.filter(T=>T.missionId===x.id||T.missionIds?.includes(x.id)).map(T=>T.workspaceId)])].map(T=>e?.workspaces[T]).filter(Boolean),J=x=>q.filter(T=>T.missionId===x),ce=x=>te.filter(T=>T.projectId===x),ye=x=>Q.filter(T=>T.projectId===x),Ee=x=>[...new Set([...J(x).map(T=>Pe(T.updatedBy)),...Y.filter(T=>T.missionId===x||T.missionIds?.includes(x)).map(T=>Pe(T.agent)),...e?.missions[x]?.latestUpdate?[Pe(e.missions[x].latestUpdate?.updatedBy)]:[]])],$e=x=>[...new Set([...q.filter(T=>T.projectId===x).map(T=>Pe(T.updatedBy)),...Y.filter(T=>T.projectId===x||T.projectIds?.includes(x)).map(T=>Pe(T.agent)),...e?.projects[x]?.latestUpdate?[Pe(e.projects[x].latestUpdate?.updatedBy)]:[]])],Ne=(x,T)=>[...new Set([...x.map(ae=>e?Ft(e,ae)?.id:void 0),...T.map(ae=>e?Io(e,ae)?.id:void 0)])],Te=x=>Ne(q.filter(T=>T.projectId===x),Y.filter(T=>T.projectId===x||T.projectIds?.includes(x))),ct=x=>Ne(J(x),Y.filter(T=>T.missionId===x||T.missionIds?.includes(x))),je=X.filter(x=>(f==="all"||$e(x.id).includes(f))&&(_==="all"||Te(x.id).includes(_))),Ue=te.filter(x=>(p==="all"||x.projectId===p)&&(f==="all"||Ee(x.id).includes(f))&&(_==="all"||ct(x.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"&&!je.some(x=>x.id===p)){u({project:"all",mission:"all"});return}y!=="all"&&!Ue.some(x=>x.id===y)&&u({mission:"all"}),i==="projects"&&!["all","active"].includes(d)&&u({status:"all"})}},[e,i,f,_,p,y,d]);const _e=(...x)=>x.join(" ").toLowerCase().includes(w.toLowerCase().trim()),be=te.filter(x=>(p==="all"||x.projectId===p)&&(y==="all"||x.id===y)&&(f==="all"||Ee(x.id).includes(f))&&(_==="all"||ct(x.id).includes(_))&&(!v||rn(x,k.staleMinutes))&&(i!=="missions"||d==="all"||x.status===d)&&_e(x.name,x.description,e?.projects[x.projectId]?.name)),we=je.filter(x=>(p==="all"||x.id===p)&&(!v||ce(x.id).some(T=>rn(T,k.staleMinutes)))&&(_e(x.name,x.description,e?.workspaces[x.workspaceId]?.path)||ce(x.id).some(T=>_e(T.name,T.description)))),xe=Q.filter(x=>(p==="all"||x.projectId===p)&&(y==="all"||x.missionId===y)&&(f==="all"||Pe(x.updatedBy)===f)&&(_==="all"||e&&Ft(e,x)?.id===_)&&(!v||rn(x,k.staleMinutes))&&(d==="all"||x.status===d)&&_e(x.title,x.note,e?.missions[x.missionId]?.name,e?.projects[x.projectId]?.name)),Wt=i==="projects"?Q.filter(x=>we.some(T=>T.id===x.projectId)):i==="missions"?Q.filter(x=>be.some(T=>T.id===x.missionId)):xe,Yt=[...we.map(x=>x.latestMonitoring),...be.map(x=>x.latestMonitoring)].filter(x=>!!x&&x.phase==="monitoring"&&(f==="all"||Pe(x.updatedBy)===f)).filter((x,T,ae)=>ae.findIndex(Qe=>Qe.id===x.id)===T).sort((x,T)=>T.reportedAt.localeCompare(x.reportedAt)),Sn=x=>{const T=x.filter(ae=>ae.status!=="cancelled");return T.length?Math.round(T.filter(ae=>ae.status==="completed").length/T.length*100):0},Ao=x=>u({agent:x,...x!=="all"&&_!=="all"&&e?.profiles[_]?.agent!==x?{profile:"all"}:{}}),Xt=x=>r("a",{class:"task-row",style:zn(e,x.projectId,x.missionId),href:ke("tasks",x.id),children:[r("div",{class:"task-row-main",children:[r("span",{class:`task-status ${x.status}`}),r("div",{children:[r("strong",{children:x.title}),r("span",{children:[e?.projects[x.projectId]?.name," / ",e?.missions[x.missionId]?.name," · ",pt(x.updatedBy)," ",r(Bn,{item:x,minutes:k.staleMinutes})]})]})]}),r(Gn,{status:x.status}),r(Vn,{value:or(x)}),r("span",{class:"row-time",children:At(x.updatedAt)}),r("span",{class:"row-arrow",children:"↗"})]},x.id),$o=x=>r("a",{class:"project-row",style:zn(e,x.projectId,x.id),href:ke("missions",x.id),children:[r("div",{class:"project-row-main",children:[r("strong",{children:[x.name," ",r(Bn,{item:x,minutes:k.staleMinutes})]}),r("span",{children:[e?.projects[x.projectId]?.name,se(x).some(T=>T?.branch)?` · ${[...new Set(se(x).map(T=>T?.branch).filter(Boolean))].join(" · ")}`:""]}),x.latestUpdate&&r("p",{class:"work-update-line",children:["Latest ",Ir[x.latestUpdate.phase]||x.latestUpdate.phase," · ",x.latestUpdate.summary]}),x.description&&r("p",{children:x.description})]}),r(Gn,{status:x.status}),r(Vn,{value:Sn(J(x.id)),caption:`${J(x.id).filter(T=>T.status==="completed").length} / ${J(x.id).filter(T=>T.status!=="cancelled").length} tasks`}),r("span",{class:"project-row-agents",children:Ee(x.id).map(pt).join(" · ")||x.latestUpdate?.updatedBy||"External"}),r("span",{class:"row-time",children:At(x.updatedAt)}),r("span",{class:"row-arrow",children:"↗"})]},x.id),Cn=(x,T="all")=>r("div",{class:"project-sections",children:["running","planned","blocked","completed","failed","cancelled"].filter(ae=>(T==="all"||T===ae)&&(!["planned","blocked"].includes(ae)||x.some(Qe=>Qe.status===ae)||T===ae)).map(ae=>r(Xs,{status:ae,kind:"missions",items:x.filter(Qe=>Qe.status===ae),limit:ae==="running"?10:5,row:$o},ae))}),Po=x=>r("div",{class:"activity",children:x.length?x.slice(-40).reverse().map(T=>r("div",{children:[r("span",{class:"activity-dot"}),r("div",{children:[r("strong",{children:T.type==="work.update_reported"?`${Ir[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)&&r("p",{children:String(T.payload.summary||T.payload.note)}),r("span",{children:new Date(T.timestamp).toLocaleString()})]})]},T.seq)):r("p",{class:"muted",children:"No recorded activity yet."})}),En=!!a,Se=O||F||U,To=U&&Se&&(i!=="tasks"||O)&&(i!=="missions"||F),Zt=O?void 0:F?F.latestMonitoring||(U?.latestMonitoring?.missionId?void 0:U?.latestMonitoring):U?.latestMonitoring,Nn=O?Y.filter(x=>x.id===O.updatedBySessionId):F?Y.filter(x=>x.missionId===F.id||x.missionIds?.includes(F.id)):U?Y.filter(x=>x.projectId===U.id||x.projectIds?.includes(U.id)):[],jo=x=>e?Vt(e,x):"#708064",In=i==="projects"&&F?"missions":i,Mn=(x,T,ae,Qe)=>r("label",{class:"filter-label project-picker",children:[r("span",{children:x}),r("select",{"aria-label":`Filter by ${x.toLowerCase()}`,value:T,onChange:Je=>Qe(Je.currentTarget.value),children:[r("option",{value:"all",children:["All ",x.toLowerCase(),"s"]}),[...ae].sort((Je,Ro)=>Je.name.localeCompare(Ro.name)).map(Je=>r("option",{value:Je.id,children:Je.name},Je.id))]})]}),Do=i==="projects"?["active"]:i==="missions"?["running","planned","blocked","completed","failed","cancelled"]:["todo","in_progress","blocked","completed","failed","cancelled"];return r("div",{class:"shell field-shell","data-section":i,children:[r("a",{class:"field-skip",href:"#workspace-main",children:"Skip to content"}),r("header",{class:"topbar field-sidebar",children:[r("a",{class:"brand",href:ke("projects"),children:[r("img",{class:"brand-mark",src:"/favicon.svg",alt:"","aria-hidden":"true"}),"angine"]}),r("div",{class:"field-workspace",children:[r(Mo,{seed:"workspace"}),r("span",{children:["Your workspace",r("small",{children:"Personal · local"})]})]}),r("span",{class:"field-nav-label",children:"Workspace"}),r("nav",{"aria-label":"Main navigation",children:["projects","missions","tasks","insights","monitoring","board","tree","agents","archive","settings"].map(x=>r("a",{href:ke(x),class:In===x?"active":"","aria-current":In===x?"page":void 0,children:[r(de,{name:x==="projects"?"overview":x==="monitoring"?"signal":x}),r("span",{children:x==="projects"?"Overview":x==="tree"?"Work map":x==="settings"?"Preferences":x[0].toUpperCase()+x.slice(1)})]},x))}),r("div",{class:"field-pinned",children:[r("span",{class:"field-nav-label",children:"Recent projects"}),X.slice(0,3).map(x=>r("a",{href:ke("projects",x.id),children:[r("i",{style:{background:jo(x.id)}}),r("span",{children:x.name})]},x.id))]}),r("div",{class:"connection",children:[r("span",{class:S?"live-dot":"offline-dot"}),S?"Dashboard live":"Reconnecting"]}),r("div",{class:"field-local",children:[r(de,{name:"archive"}),r("span",{children:["Yours, on this device.",r("small",{children:"Stored locally"})]})]})]}),r("div",{class:"field-appbar",children:[r("span",{children:["Workspace ",r("b",{children:"/"})," ",i==="projects"?"Overview":i==="tree"?"Work map":i==="settings"?"Preferences":i[0].toUpperCase()+i.slice(1)]}),r("span",{class:"field-appbar-status",children:[r(de,{name:"signal"}),"Agent-reported work"]})]}),r("main",{id:"workspace-main",class:En?"detail-page":"overview-page",children:[r(cy,{compatibility:P}),L&&r("div",{class:"error-banner",role:"alert",children:[L,r("button",{class:"text-button",onClick:()=>j(""),children:"Dismiss"})]}),e?i==="agents"?r(yy,{health:A,compatibility:P,state:e,profileId:a||void 0,mutate:z,taskRow:Xt}):i==="archive"?r(_y,{state:e,mutate:z}):i==="settings"?r(wy,{preferences:k,setPreferences:g,resetFilters:h,saveNotifications:m,testNotifications:C,notificationError:b,notificationSupported:E,agents:[...new Set([...Object.values(e.profiles||{}).map(x=>x.agent),...Object.values(e.sessions||{}).map(x=>x.agent),...Object.values(e.tasks||{}).map(x=>x.updatedBy)])].sort()}):i==="monitoring"?r(Iy,{state:e,showOnDashboard:k.showMonitoring,setShowOnDashboard:x=>g({...k,showMonitoring:x})}):i==="insights"?r(Sy,{state:e}):i==="tree"?r(J0,{state:e,filters:c,setFilters:u,reset:l}):En?To&&U&&Se?r(Z,{children:[r("nav",{class:"breadcrumbs","aria-label":"Breadcrumb",children:[r("a",{href:ke("projects"),children:"Projects"}),r("span",{children:"/"}),F?r(Z,{children:[r("a",{href:ke("projects",U.id),children:U.name}),r("span",{children:"/"}),O?r(Z,{children:[r("a",{href:ke("missions",F.id),children:F.name}),r("span",{children:"/"}),r("span",{children:"Task"})]}):r("span",{children:F.name})]}):r("span",{children:U.name})]}),r("div",{class:"page-heading detail-heading mission-heading",style:zn(e,U.id,F?.id),children:[r("div",{children:[r("div",{class:"overline",children:[O?"TASK":F?"MISSION":"PROJECT"," ",r("span",{children:Se.key})]}),r("h1",{children:O?.title||F?.name||U.name}),r("div",{class:"heading-meta",children:[r(Gn,{status:Se.status}),r("span",{children:["Updated ",At(Se.updatedAt)]}),F&&r(Bn,{item:O||F,minutes:k.staleMinutes}),!O&&r("button",{class:"secondary-button",onClick:()=>z("archive",{projectId:Se.id,archived:!("archivedAt"in Se&&Se.archivedAt)}),children:["archivedAt"in Se&&Se.archivedAt?"Restore":"Archive"," ",F?"mission":"project"]}),(U.archivedAt||F?.archivedAt)&&r("span",{children:"Archived"})]})]}),F?r("div",{class:"heading-progress",children:r(Vn,{value:O?or(O):Sn(J(F.id)),caption:O?"Task progress":"Tasks completed"})}):r("div",{class:"project-overview-counts",children:[r("strong",{children:ce(U.id).length}),r("span",{children:"missions"}),r("strong",{children:ye(U.id).length}),r("span",{children:"tasks"})]})]}),r("div",{class:"detail-grid",children:[r("div",{class:"detail-main",children:[k.showMonitoring&&Zt&&r(Nr,{updates:[Zt],state:e,onHide:()=>g({...k,showMonitoring:!1})}),!O&&(F?.latestUpdate||U.latestUpdate)&&(F?.latestUpdate||U.latestUpdate)?.id!==Zt?.id&&r(My,{update:F?.latestUpdate||U.latestUpdate,state:e}),r("section",{class:"panel",children:[r("h2",{children:"Overview"}),O&&r("p",{class:"report-provenance",children:["Status reported by ",pt(O.updatedBy)," · ",new Date(O.updatedAt).toLocaleString(),r("span",{children:"Completion is agent reported; test results are not independently verified."})]}),r("p",{class:"description",children:Se.description||(F?"No description provided.":"Missions collect the goals and tasks for this project. Completing a mission does not close the project.")}),O?.note&&r("div",{class:"latest-update",children:[r("div",{class:"overline",children:"LATEST UPDATE"}),r("p",{children:O.note})]})]}),!F&&r("section",{children:[r("div",{class:"panel-heading",children:[r("h2",{children:"Missions"}),r("span",{children:ce(U.id).length})]}),Cn(U.archivedAt?H.filter(x=>x.projectId===U.id):ce(U.id))]}),O&&r(vy,{task:O,state:e,mutate:z},O.id),F&&(!O||J(F.id).some(x=>x.parentKey===O.key))&&r("section",{class:"panel",children:[r("div",{class:"panel-heading",children:[r("h2",{children:O?"Subtasks":"Tasks"}),r("span",{children:(O?J(F.id).filter(x=>x.parentKey===O.key):J(F.id)).length})]}),r("div",{class:"task-table",children:(O?J(F.id).filter(x=>x.parentKey===O.key):J(F.id)).map(Xt)})]}),r("section",{class:"panel",children:[r("h2",{children:"Activity"}),Po(V.filter(x=>O?x.taskId===O.id:!x.type.startsWith("session.")))]})]}),r("div",{class:"detail-info",children:[r("section",{class:"panel",children:[r("h2",{children:"Details"}),!O&&r(ey,{project:U,mission:F,mutate:z}),r("dl",{children:[r("dt",{children:"Project"}),r("dd",{children:r("a",{href:ke("projects",U.id),children:U.name})}),F&&r(Z,{children:[r("dt",{children:"Mission"}),r("dd",{children:r("a",{href:ke("missions",F.id),children:F.name})})]}),r("dt",{children:F?"Worktrees / workspaces":"Workspace"}),r("dd",{children:F?se(F).map(x=>r("div",{children:[x.path,x.branch&&r("strong",{children:[" · ",x.branch]})]},x.id)):e.workspaces[U.workspaceId]?.repositoryPath||e.workspaces[U.workspaceId]?.path}),r("dt",{children:"Created"}),r("dd",{children:new Date(Se.createdAt).toLocaleString()}),O?.parentKey&&r(Z,{children:[r("dt",{children:"Parent task"}),r("dd",{children:J(O.missionId).find(x=>x.key===O.parentKey)?r("a",{href:ke("tasks",J(O.missionId).find(x=>x.key===O.parentKey).id),children:O.parentKey}):O.parentKey})]})]})]}),r("section",{class:"panel",children:[r("h2",{children:O?"Reporting agent":"Reporter sessions"}),Nn.map(x=>r(Ay,{session:x,state:e,health:A},x.id)),!Nn.length&&r("p",{class:"muted",children:"No reporter session available for this item."})]})]})]})]}):r("div",{class:"empty",children:[r("h2",{children:"This page is unavailable"}),r("a",{href:ke("projects"),children:"Return to projects"})]}):r(Z,{children:[r("div",{class:"overview-toolbar",children:[r("div",{class:"stats",children:i==="projects"?r(Z,{children:[r("div",{children:[r("strong",{children:we.length}),r("span",{children:"Projects"})]}),r("div",{children:[r("strong",{children:te.filter(x=>we.some(T=>T.id===x.projectId)&&x.status==="running").length}),r("span",{children:"Running missions"})]}),r("div",{children:[r("strong",{children:te.filter(x=>we.some(T=>T.id===x.projectId)&&x.status==="completed").length}),r("span",{children:"Completed missions"})]})]}):["all",i==="missions"?"running":"in_progress","blocked","completed","failed","cancelled"].map(x=>r("div",{children:[r("strong",{children:i==="missions"?x==="all"?be.length:be.filter(T=>T.status===x).length:x==="all"?xe.length:xe.filter(T=>T.status===x).length}),r("span",{children:x==="all"?"Total":Xe[x]})]},x))}),r("div",{class:"toolbar",children:[r("label",{class:"search",children:[r("span",{"aria-hidden":"true",children:"⌕"}),r("input",{"aria-label":"Search work",placeholder:"Search projects, missions, tasks…",value:w,onInput:x=>u({query:x.currentTarget.value})})]}),r("label",{class:"filter-label",children:[r("span",{children:"Agent"}),r("select",{"aria-label":"Filter by agent",value:f,onChange:x=>Ao(x.currentTarget.value),children:[r("option",{value:"all",children:"All agents"}),ee.map(x=>r("option",{value:x,children:pt(x)},x))]})]}),i!=="projects"&&Mn("Project",p,je,x=>u({project:x,mission:"all"})),["tasks","board"].includes(i)&&Mn("Mission",y,Ue,x=>u({mission:x})),i!=="projects"&&r("label",{class:"filter-label",children:[r("span",{children:"Status"}),r("select",{"aria-label":"Filter by status",value:d,onChange:x=>u({status:x.currentTarget.value}),children:[r("option",{value:"all",children:"All statuses"}),Do.map(x=>r("option",{value:x,children:Xe[x]},x))]})]}),r("details",{class:"more-filters",children:[r("summary",{children:["More filters",_!=="all"||v?" · On":""]}),r("div",{class:"extra-filters",children:[r("label",{class:"filter-label",children:[r("span",{children:"Profile"}),r("select",{"aria-label":"Filter by profile",value:_,onChange:x=>u({profile:x.currentTarget.value}),children:[r("option",{value:"all",children:"All profiles"}),Object.values(e.profiles).filter(x=>f==="all"||x.agent===f).map(x=>r("option",{value:x.id,children:x.name},x.id))]})]}),r("label",{class:"filter-label",children:[r("span",{children:"Activity"}),r("select",{"aria-label":"Filter stale activity",value:v?"stale":"all",onChange:x=>u({staleOnly:x.currentTarget.value==="stale"}),children:[r("option",{value:"all",children:"All activity"}),r("option",{value:"stale",children:"Stale only"})]})]})]})]}),(w||f!=="all"||d!=="all"||_!=="all"||v||p!=="all"||y!=="all")&&r("button",{class:"clear-filters",onClick:l,children:"Reset"})]})]}),k.showMonitoring&&r(Nr,{updates:Yt,state:e,onHide:()=>g({...k,showMonitoring:!1})}),i!=="projects"&&r(hy,{state:e,tasks:Wt,health:A,staleMinutes:k.staleMinutes}),i==="board"?r("div",{class:"board",ref:M,style:$?{height:`${$}px`}:void 0,children:["todo","in_progress","blocked","completed","failed","cancelled"].map(x=>r("section",{class:"board-column",children:[r("div",{class:"column-heading",children:[r("span",{class:`task-status ${x}`}),r("h2",{children:Xe[x]}),r("span",{children:xe.filter(T=>T.status===x).length})]}),r("div",{class:"board-stack",tabIndex:0,role:"region","aria-label":`${Xe[x]} tasks, scroll this column`,children:[xe.filter(T=>T.status===x).map(T=>r("a",{class:"board-card",style:zn(e,T.projectId,T.missionId),href:ke("tasks",T.id),children:[r("span",{class:"board-project",children:[e.projects[T.projectId]?.name," / ",e.missions[T.missionId]?.name]}),r("strong",{children:[T.title," ",r(Bn,{item:T,minutes:k.staleMinutes})]}),T.blocker?.nextStep&&r("p",{class:"blocker-next",children:["Next: ",T.blocker.nextStep]}),T.note&&r("p",{children:T.note}),r(Vn,{value:or(T)}),r("div",{class:"board-footer",children:[r("span",{children:pt(T.updatedBy)}),r("span",{children:At(T.updatedAt)})]})]},T.id)),!xe.some(T=>T.status===x)&&r("div",{class:"column-empty",children:"No tasks"})]})]},x))}):i==="tasks"?r("div",{class:"project-sections",children:["in_progress","todo","blocked","completed","failed","cancelled"].filter(x=>(d==="all"||d===x)&&(!["todo","blocked"].includes(x)||xe.some(T=>T.status===x)||d===x)).map(x=>r(Xs,{status:x,kind:"tasks",items:xe.filter(T=>T.status===x),limit:x==="in_progress"?10:5,row:Xt},x))}):i==="missions"?Cn(be,d):r(Ey,{state:e,projects:we,tasks:Q,health:A,staleMinutes:k.staleMinutes,agent:f,profile:_})]}):r("div",{class:"empty",children:r("h2",{children:"Loading your work…"})}),r("footer",{class:"footer",children:[r("span",{children:"Angine"}),r("span",{children:"Stored locally on this device"})]})]})]})}Tt(r($y,{}),document.getElementById("app"));