Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["2180"],{1775(e,t,r){r.r(t),r.d(t,{prepareLayoutForDagre:()=>r3,getEdgesToRender:()=>rY,runDagreLayoutCore:()=>r4,render:()=>r9,applyDagreLayoutResult:()=>r0,measureDagreLayout:()=>r8});var n,o,a,i=r(97150),u=r(80526),d=r(78222),c=r(64863),s=r(71101);r(63580),r(55485),r(29722),r(92941),r(76144);var f=r(88253),l=r(31293),g=r(86827),h=r(8058),p=r(24898),v=0;let y=function(e){var t=++v;return(0,p.A)(e)+t};var b=r(39142),A=r(76335);let w=function(e){return(null==e?0:e.length)?(0,A.A)(e,1):[]};var m=r(45572),x=r(57029),E=r(65045),j=r(38446);let L=function(e,t){var r=-1,n=(0,j.A)(e)?Array(e.length):[];return(0,E.A)(e,function(e,o,a){n[++r]=t(e,o,a)}),n};var k=r(92049);let O=function(e,t){return((0,k.A)(e)?m.A:L)(e,(0,x.A)(t,3))};var R=Math.ceil,N=Math.max;let P=function(e,t,r,n){for(var o=-1,a=N(R((t-e)/(r||1)),0),i=Array(a);a--;)i[n?a:++o]=e,e+=r;return i};var C=r(66984),S=r(25353),_=r(23149);let M=function(e,t,r){if(!(0,_.A)(r))return!1;var n=typeof t;return("number"==n?!!((0,j.A)(r)&&(0,S.A)(t,r.length)):"string"==n&&t in r)&&(0,C.A)(r[t],e)};var X=/\s/;let D=function(e){for(var t=e.length;t--&&X.test(e.charAt(t)););return t};var T=/^\s+/,I=r(61882),B=0/0,K=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,F=/^0o[0-7]+$/i,U=parseInt;let q=function(e){if("number"==typeof e)return e;if((0,I.A)(e))return B;if((0,_.A)(e)){var t,r="function"==typeof e.valueOf?e.valueOf():e;e=(0,_.A)(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=(t=e)?t.slice(0,D(t)+1).replace(T,""):t;var n=G.test(e);return n||F.test(e)?U(e.slice(2),n?2:8):K.test(e)?B:+e};var J=1/0;let z=function(e){return e?(e=q(e))===J||e===-J?(e<0?-1:1)*17976931348623157e292:e==e?e:0:0===e?e:0},V=function(e,t,r){return r&&"number"!=typeof r&&M(e,t,r)&&(t=r=void 0),e=z(e),void 0===t?(t=e,e=0):t=z(t),r=void 0===r?e<t?1:-1:z(r),P(e,t,r,void 0)};var Y=r(697);class ${constructor(){var e={};e._next=e._prev=e,this._sentinel=e}dequeue(){var e=this._sentinel,t=e._prev;if(t!==e)return H(t),t}enqueue(e){var t=this._sentinel;e._prev&&e._next&&H(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){for(var e=[],t=this._sentinel,r=t._prev;r!==t;)e.push(JSON.stringify(r,W)),r=r._prev;return"["+e.join(", ")+"]"}}function H(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function W(e,t){if("_next"!==e&&"_prev"!==e)return t}var Q=b.A(1);function Z(e,t,r,n,o){var a=o?[]:void 0;return h.A(e.inEdges(n.v),function(n){var i=e.edge(n),u=e.node(n.v);o&&a.push({v:n.v,w:n.w}),u.out-=i,ee(t,r,u)}),h.A(e.outEdges(n.v),function(n){var o=e.edge(n),a=n.w,i=e.node(a);i.in-=o,ee(t,r,i)}),e.removeNode(n.v),a}function ee(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}var et=r(20013),er=r(84171);let en=function(e,t,r){"__proto__"==t&&er.A?(0,er.A)(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r},eo=function(e,t,r){(void 0===r||(0,C.A)(e[t],r))&&(void 0!==r||t in e)||en(e,t,r)};var ea=r(83816),ei=r(41917),eu="object"==typeof exports&&exports&&!exports.nodeType&&exports,ed=eu&&"object"==typeof module&&module&&!module.nodeType&&module,ec=ed&&ed.exports===eu?ei.A.Buffer:void 0,es=ec?ec.allocUnsafe:void 0;let ef=function(e,t){if(t)return e.slice();var r=e.length,n=es?es(r):new e.constructor(r);return e.copy(n),n};var el=r(43988);let eg=function(e){var t=new e.constructor(e.byteLength);return new el.A(t).set(new el.A(e)),t},eh=function(e,t){var r=t?eg(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)},ep=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t};var ev=Object.create,ey=function(){function e(){}return function(t){if(!(0,_.A)(t))return{};if(ev)return ev(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}(),eb=(0,r(40367).A)(Object.getPrototypeOf,Object),eA=r(97271);let ew=function(e){return"function"!=typeof e.constructor||(0,eA.A)(e)?{}:ey(eb(e))};var em=r(20018),ex=r(53533),eE=r(55254),ej=r(89610),eL=r(18348),ek=r(53098),eO=Object.prototype,eR=Function.prototype.toString,eN=eO.hasOwnProperty,eP=eR.call(Object);let eC=function(e){if(!(0,ek.A)(e)||"[object Object]"!=(0,eL.A)(e))return!1;var t=eb(e);if(null===t)return!0;var r=eN.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&eR.call(r)==eP};var eS=r(79415);let e_=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var eM=Object.prototype.hasOwnProperty;let eX=function(e,t,r){var n=e[t];eM.call(e,t)&&(0,C.A)(n,r)&&(void 0!==r||t in e)||en(e,t,r)},eD=function(e,t,r,n){var o=!r;r||(r={});for(var a=-1,i=t.length;++a<i;){var u=t[a],d=n?n(r[u],e[u],u,r,e):void 0;void 0===d&&(d=e[u]),o?en(r,u,d):eX(r,u,d)}return r};var eT=r(91463);let eI=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t};var eB=Object.prototype.hasOwnProperty;let eK=function(e){if(!(0,_.A)(e))return eI(e);var t=(0,eA.A)(e),r=[];for(var n in e)"constructor"==n&&(t||!eB.call(e,n))||r.push(n);return r},eG=function(e){return(0,j.A)(e)?(0,eT.A)(e,!0):eK(e)},eF=function(e,t,r,n,o,a,i){var u=e_(e,r),d=e_(t,r),c=i.get(d);if(c)return void eo(e,r,c);var s=a?a(u,d,r+"",e,t,i):void 0,f=void 0===s;if(f){var l=(0,k.A)(d),g=!l&&(0,eE.A)(d),h=!l&&!g&&(0,eS.A)(d);(s=d,l||g||h)?(0,k.A)(u)?s=u:(0,ex.A)(u)?s=ep(u):g?(f=!1,s=ef(d,!0)):h?(f=!1,s=eh(d,!0)):s=[]:eC(d)||(0,em.A)(d)?(s=u,(0,em.A)(u))?s=eD(u,eG(u)):(!(0,_.A)(u)||(0,ej.A)(u))&&(s=ew(d)):f=!1}f&&(i.set(d,s),o(s,d,n,a,i),i.delete(d)),eo(e,r,s)},eU=function e(t,r,n,o,a){t!==r&&(0,ea.A)(r,function(i,u){if(a||(a=new et.A),(0,_.A)(i))eF(t,r,u,n,e,o,a);else{var d=o?o(e_(t,u),i,u+"",t,r,a):void 0;void 0===d&&(d=i),eo(t,u,d)}},eG)};var eq=r(24326),eJ=(n=function(e,t,r){eU(e,t,r)},(0,eq.A)(function(e,t){var r=-1,o=t.length,a=o>1?t[o-1]:void 0,i=o>2?t[2]:void 0;for(a=n.length>3&&"function"==typeof a?(o--,a):void 0,i&&M(t[0],t[1],i)&&(a=o<3?void 0:a,o=1),e=Object(e);++r<o;){var u=t[r];u&&n(e,u,r,a)}return e})),ez=r(66318),eV=r(24548),eY=r(30901);let e$=function(e,t,r,n){if(!(0,_.A)(e))return e;t=(0,eV.A)(t,e);for(var o=-1,a=t.length,i=a-1,u=e;null!=u&&++o<a;){var d=(0,eY.A)(t[o]),c=r;if("__proto__"===d||"constructor"===d||"prototype"===d)break;if(o!=i){var s=u[d];void 0===(c=n?n(s,d,u):void 0)&&(c=(0,_.A)(s)?s:(0,S.A)(t[o+1])?[]:{})}eX(u,d,c),u=u[d]}return e},eH=function(e,t,r){for(var n=-1,o=t.length,a={};++n<o;){var i=t[n],u=(0,ez.A)(e,i);r(u,i)&&e$(a,(0,eV.A)(i,e),u)}return a};var eW=r(96953),eQ=r(93310),eZ=r(89592),e0=(o=function(e,t){return null==e?{}:eH(e,t,function(t,r){return(0,eW.A)(e,r)})},(0,eZ.A)((0,eQ.A)(o,void 0,w),o+"")),e1=Object.prototype,e2=e1.hasOwnProperty,e3=(0,eq.A)(function(e,t){e=Object(e);var r=-1,n=t.length,o=n>2?t[2]:void 0;for(o&&M(t[0],t[1],o)&&(n=1);++r<n;)for(var a=t[r],i=eG(a),u=-1,d=i.length;++u<d;){var c=i[u],s=e[c];(void 0===s||(0,C.A)(s,e1[c])&&!e2.call(e,c))&&(e[c]=a[c])}return e});let e8=function(e,t,r){for(var n=-1,o=e.length;++n<o;){var a=e[n],i=t(a);if(null!=i&&(void 0===u?i==i&&!(0,I.A)(i):r(i,u)))var u=i,d=a}return d},e4=function(e,t){return e>t};var e5=r(29008);let e6=function(e){return e&&e.length?e8(e,e5.A,e4):void 0},e9=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var e7=r(79841);let te=function(e,t){var r={};return t=(0,x.A)(t,3),(0,e7.A)(e,function(e,n,o){en(r,n,t(e,n,o))}),r};var tt=r(69592);let tr=function(e,t){return e<t},tn=function(e){return e&&e.length?e8(e,e5.A,tr):void 0};var to=Object.prototype.hasOwnProperty;let ta=function(e,t){return null!=e&&to.call(e,t)};var ti=r(85054);let tu=function(e,t){return null!=e&&(0,ti.A)(e,t,ta)};function td(e,t,r,n){var o;do o=y(n);while(e.hasNode(o))return r.dummy=t,e.setNode(o,r),o}function tc(e){var t=new Y.T({multigraph:e.isMultigraph()}).setGraph(e.graph());return h.A(e.nodes(),function(r){e.children(r).length||t.setNode(r,e.node(r))}),h.A(e.edges(),function(r){t.setEdge(r,e.edge(r))}),t}function ts(e,t){var r,n,o=e.x,a=e.y,i=t.x-o,u=t.y-a,d=e.width/2,c=e.height/2;if(!i&&!u)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(u)*d>Math.abs(i)*c?(u<0&&(c=-c),r=c*i/u,n=c):(i<0&&(d=-d),r=d,n=d*u/i),{x:o+r,y:a+n}}function tf(e){var t=O(V(tg(e)+1),function(){return[]});return h.A(e.nodes(),function(r){var n=e.node(r),o=n.rank;tt.A(o)||(t[o][n.order]=r)}),t}function tl(e,t,r,n){var o={width:0,height:0};return arguments.length>=4&&(o.rank=r,o.order=n),td(e,"border",o,t)}function tg(e){return e6(O(e.nodes(),function(t){var r=e.node(t).rank;if(!tt.A(r))return r}))}function th(e,t){return t()}function tp(e,t,r,n,o,a){var i=o[t][a-1],u=td(e,"border",{width:0,height:0,rank:a,borderType:t},r);o[t][a]=u,e.setParent(u,n),i&&e.setEdge(i,u,{weight:1})}function tv(e){h.A(e.nodes(),function(t){ty(e.node(t))}),h.A(e.edges(),function(t){ty(e.edge(t))})}function ty(e){var t=e.width;e.width=e.height,e.height=t}function tb(e){e.y=-e.y}function tA(e){var t=e.x;e.x=e.y,e.y=t}let tw=function(e,t){return e&&e.length?e8(e,(0,x.A)(t,2),tr):void 0};function tm(e){var t={};h.A(e.sources(),function r(n){var o=e.node(n);if(Object.prototype.hasOwnProperty.call(t,n))return o.rank;t[n]=!0;var a=tn(O(e.outEdges(n),function(t){return r(t.w)-e.edge(t).minlen}));return(a===1/0||null==a)&&(a=0),o.rank=a})}function tx(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}function tE(e){var t,r,n,o,a=new Y.T({directed:!1}),i=e.nodes()[0],u=e.nodeCount();for(a.setNode(i,{});t=a,r=e,h.A(t.nodes(),function e(n){h.A(r.nodeEdges(n),function(o){var a=o.v,i=n===a?o.w:a;t.hasNode(i)||tx(r,o)||(t.setNode(i,{}),t.setEdge(n,i,{}),e(i))})}),t.nodeCount()<u;)n=function(e,t){return tw(t.edges(),function(r){if(e.hasNode(r.v)!==e.hasNode(r.w))return tx(t,r)})}(a,e),o=a.hasNode(n.v)?tx(e,n):-tx(e,n),function(e,t,r){h.A(e.nodes(),function(e){t.node(e).rank+=r})}(a,e,o);return a}var tj=r(27422),tL=r(25707);let tk=function(e){var t=z(e),r=t%1;return t==t?r?t-r:t:0};var tO=Math.max,tR=(a=function(e,t,r){var n=null==e?0:e.length;if(!n)return -1;var o=null==r?0:tk(r);return o<0&&(o=tO(n+o,0)),(0,tL.A)(e,(0,x.A)(t,3),o)},function(e,t,r){var n=Object(e);if(!(0,j.A)(e)){var o=(0,x.A)(t,3);e=(0,tj.A)(e),t=function(e){return o(n[e],e,n)}}var i=a(e,t,r);return i>-1?n[o?e[i]:i]:void 0}),tN=r(96654);b.A(1),b.A(1);var tP=r(84065),tC=r(83231),tS=(0,r(70805).A)("length"),t_=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),tM="\\ud800-\\udfff",tX="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",tD="\\ud83c[\\udffb-\\udfff]",tT="[^"+tM+"]",tI="(?:\\ud83c[\\udde6-\\uddff]){2}",tB="[\\ud800-\\udbff][\\udc00-\\udfff]",tK="(?:"+tX+"|"+tD+")?",tG="[\\ufe0e\\ufe0f]?",tF="(?:\\u200d(?:"+[tT,tI,tB].join("|")+")"+tG+tK+")*",tU=RegExp(tD+"(?="+tD+")|"+("(?:"+[tT+tX+"?",tX,tI,tB,"["+tM+"]"].join("|"))+")"+(tG+tK+tF),"g");function tq(){}function tJ(e,t,r){k.A(t)||(t=[t]);var n=(e.isDirected()?e.successors:e.neighbors).bind(e),o=[],a={};return h.A(t,function(t){if(!e.hasNode(t))throw Error("Graph does not have node: "+t);!function e(t,r,n,o,a,i){!Object.prototype.hasOwnProperty.call(o,r)&&(o[r]=!0,n||i.push(r),h.A(a(r),function(r){e(t,r,n,o,a,i)}),n&&i.push(r))}(e,t,"post"===r,a,n,o)}),o}function tz(e){t=e,r=new Y.T().setGraph(t.graph()),h.A(t.nodes(),function(e){r.setNode(e,t.node(e))}),h.A(t.edges(),function(e){var n=r.edge(e.v,e.w)||{weight:0,minlen:1},o=t.edge(e);r.setEdge(e.v,e.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),tm(e=r);var t,r,n,o,a=tE(e);for(t$(a),tV(a,e);n=tH(a);)o=tW(a,e,n),tQ(a,e,n,o)}function tV(e,t){var r=tJ(e,e.nodes(),"post");r=r.slice(0,r.length-1),h.A(r,function(r){var n,o,a,i;n=e,o=t,a=r,i=n.node(a).parent,n.edge(a,i).cutvalue=tY(n,o,a)})}function tY(e,t,r){var n=e.node(r).parent,o=!0,a=t.edge(r,n),i=0;return a||(o=!1,a=t.edge(n,r)),i=a.weight,h.A(t.nodeEdges(r),function(a){var u=a.v===r,d=u?a.w:a.v;if(d!==n){var c,s,f,l=u===o,g=t.edge(a).weight;if(i+=l?g:-g,c=e,s=r,f=d,c.hasEdge(s,f)){var h=e.edge(r,d).cutvalue;i+=l?-h:h}}}),i}function t$(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,r,n,o,a){var i=n,u=t.node(o);return r[o]=!0,h.A(t.neighbors(o),function(a){Object.prototype.hasOwnProperty.call(r,a)||(n=e(t,r,n,a,o))}),u.low=i,u.lim=n++,a?u.parent=a:delete u.parent,n}(e,{},1,t)}function tH(e){return tR(e.edges(),function(t){return e.edge(t).cutvalue<0})}function tW(e,t,r){var n=r.v,o=r.w;t.hasEdge(n,o)||(n=r.w,o=r.v);var a=e.node(n),i=e.node(o),u=a,d=!1;return a.lim>i.lim&&(u=i,d=!0),tw(tN.A(t.edges(),function(t){return d===tZ(e,e.node(t.v),u)&&d!==tZ(e,e.node(t.w),u)}),function(e){return tx(t,e)})}function tQ(e,t,r,n){var o,a,i,u,d=r.v,c=r.w;e.removeEdge(d,c),e.setEdge(n.v,n.w,{}),t$(e),tV(e,t),o=e,a=t,i=tR(o.nodes(),function(e){return!a.node(e).parent}),u=(u=tJ(o,i,"pre")).slice(1),h.A(u,function(e){var t=o.node(e).parent,r=a.edge(e,t),n=!1;r||(r=a.edge(t,e),n=!0),a.node(e).rank=a.node(t).rank+(n?r.minlen:-r.minlen)})}function tZ(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}tq.prototype=Error(),r(44819),tz.initLowLimValues=t$,tz.initCutValues=tV,tz.calcCutValue=tY,tz.leaveEdge=tH,tz.enterEdge=tW,tz.exchangeEdges=tQ;var t0=r(72888),t1=r(64039),t2=r(72641),t3=r(14792),t8=r(76912),t4=r(13153),t5=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)(0,t8.A)(t,(0,t3.A)(e)),e=eb(e);return t}:t4.A,t6=r(19042),t9=r(33831);let t7=function(e){return(0,t9.A)(e,eG,t5)};var re=Object.prototype.hasOwnProperty;let rt=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&re.call(e,"index")&&(r.index=e.index,r.input=e.input),r},rr=function(e,t){var r=t?eg(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)};var rn=/\w*$/;let ro=function(e){var t=new e.constructor(e.source,rn.exec(e));return t.lastIndex=e.lastIndex,t};var ra=r(241),ri=ra.A?ra.A.prototype:void 0,ru=ri?ri.valueOf:void 0;let rd=function(e,t,r){var n=e.constructor;switch(t){case"[object ArrayBuffer]":return eg(e);case"[object Boolean]":case"[object Date]":return new n(+e);case"[object DataView]":return rr(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return eh(e,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(e);case"[object RegExp]":return ro(e);case"[object Symbol]":return ru?Object(ru.call(e)):{}}};var rc=r(52789),rs=r(64841),rf=rs.A&&rs.A.isMap,rl=rf?(0,rc.A)(rf):function(e){return(0,ek.A)(e)&&"[object Map]"==(0,tC.A)(e)},rg=rs.A&&rs.A.isSet,rh=rg?(0,rc.A)(rg):function(e){return(0,ek.A)(e)&&"[object Set]"==(0,tC.A)(e)},rp="[object Arguments]",rv="[object Function]",ry="[object Object]",rb={};rb[rp]=rb["[object Array]"]=rb["[object ArrayBuffer]"]=rb["[object DataView]"]=rb["[object Boolean]"]=rb["[object Date]"]=rb["[object Float32Array]"]=rb["[object Float64Array]"]=rb["[object Int8Array]"]=rb["[object Int16Array]"]=rb["[object Int32Array]"]=rb["[object Map]"]=rb["[object Number]"]=rb[ry]=rb["[object RegExp]"]=rb["[object Set]"]=rb["[object String]"]=rb["[object Symbol]"]=rb["[object Uint8Array]"]=rb["[object Uint8ClampedArray]"]=rb["[object Uint16Array]"]=rb["[object Uint32Array]"]=!0,rb["[object Error]"]=rb[rv]=rb["[object WeakMap]"]=!1;let rA=function e(t,r,n,o,a,i){var u,d=1&r,c=2&r,s=4&r;if(n&&(u=a?n(t,o,a,i):n(t)),void 0!==u)return u;if(!(0,_.A)(t))return t;var f=(0,k.A)(t);if(f){if(u=rt(t),!d)return ep(t,u)}else{var l,g,h,p,v=(0,tC.A)(t),y=v==rv||"[object GeneratorFunction]"==v;if((0,eE.A)(t))return ef(t,d);if(v==ry||v==rp||y&&!a){if(u=c||y?{}:ew(t),!d)return c?(g=(l=u)&&eD(t,eG(t),l),eD(t,t5(t),g)):(p=(h=u)&&eD(t,(0,tj.A)(t),h),eD(t,(0,t3.A)(t),p))}else{if(!rb[v])return a?t:{};u=rd(t,v,d)}}i||(i=new et.A);var b=i.get(t);if(b)return b;i.set(t,u),rh(t)?t.forEach(function(o){u.add(e(o,r,n,o,t,i))}):rl(t)&&t.forEach(function(o,a){u.set(a,e(o,r,n,a,t,i))});var A=s?c?t7:t6.A:c?eG:tj.A,w=f?void 0:A(t);return(0,t2.A)(w||t,function(o,a){w&&(o=t[a=o]),eX(u,a,e(o,r,n,a,t,i))}),u},rw=function(e,t,r){for(var n=-1,o=e.length,a=t.length,i={};++n<o;){var u=n<a?t[n]:void 0;r(i,e[n],u)}return i},rm=function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e},rx=function(e,t){if(e!==t){var r=void 0!==e,n=null===e,o=e==e,a=(0,I.A)(e),i=void 0!==t,u=null===t,d=t==t,c=(0,I.A)(t);if(!u&&!c&&!a&&e>t||a&&i&&d&&!u&&!c||n&&i&&d||!r&&d||!o)return 1;if(!n&&!a&&!c&&e<t||c&&r&&o&&!n&&!a||u&&r&&o||!i&&o||!d)return -1}return 0},rE=function(e,t,r){for(var n=-1,o=e.criteria,a=t.criteria,i=o.length,u=r.length;++n<i;){var d=rx(o[n],a[n]);if(d){if(n>=u)return d;return d*("desc"==r[n]?-1:1)}}return e.index-t.index},rj=function(e,t,r){t=t.length?(0,m.A)(t,function(e){return(0,k.A)(e)?function(t){return(0,ez.A)(t,1===e.length?e[0]:e)}:e}):[e5.A];var n=-1;return t=(0,m.A)(t,(0,rc.A)(x.A)),rm(L(e,function(e,r,o){return{criteria:(0,m.A)(t,function(t){return t(e)}),index:++n,value:e}}),function(e,t){return rE(e,t,r)})};var rL=(0,eq.A)(function(e,t){if(null==e)return[];var r=t.length;return r>1&&M(e,t[0],t[1])?t=[]:r>2&&M(t[0],t[1],t[2])&&(t=[t[0]]),rj(e,(0,A.A)(t,1),[])});function rk(e,t,r){for(var n;t.length&&(n=e9(t)).i<=r;)t.pop(),e.push(n.vs),r++;return r}function rO(e,t,r){return O(t,function(t){var n,o;return n=function(e){for(var t;e.hasNode(t=y("_root")););return t}(e),o=new Y.T({compound:!0}).setGraph({root:n}).setDefaultNodeLabel(function(t){return e.node(t)}),h.A(e.nodes(),function(a){var i=e.node(a),u=e.parent(a);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(o.setNode(a),o.setParent(a,u||n),h.A(e[r](a),function(t){var r=t.v===a?t.w:t.v,n=o.edge(r,a),i=tt.A(n)?0:n.weight;o.setEdge(r,a,{weight:e.edge(t).weight+i})}),Object.prototype.hasOwnProperty.call(i,"minRank")&&o.setNode(a,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))}),o})}function rR(e,t){h.A(t,function(t){h.A(t,function(t,r){e.node(t).order=r})})}var rN=r(99922);function rP(e,t,r){if(t>r){var n=t;t=r,r=n}Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,configurable:!0,value:{},writable:!0}),Object.defineProperty(e[t],r,{enumerable:!0,configurable:!0,value:!0,writable:!0})}var rC=["nodesep","edgesep","ranksep","marginx","marginy"],rS={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},r_=["acyclicer","ranker","rankdir","align"],rM=["width","height"],rX={width:0,height:0},rD=["minlen","weight","width","height","labeloffset"],rT={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},rI=["labelpos"];function rB(e,t){return te(e0(e,t),Number)}function rK(e){var t={};return h.A(e,function(e,r){t[r.toLowerCase()]=e}),t}var rG=(0,g.K)((e,t,r)=>Math.max(t,Math.min(r,e)),"clamp"),rF=(0,g.K)((e="TB")=>{switch(e){case"BT":return"bottom";case"LR":return"right";case"RL":return"left";default:return"top"}},"getDefaultSelfLoopSide"),rU=(0,g.K)(e=>"flowchart"===e||"flowchart-v2"===e||"stateDiagram"===e||"er"===e||"classDiagram"===e,"shouldMergeSelfLoopSegments"),rq=["x","y","width","height","labelBBox","intersect","calcIntersect","diff","clusterNode"],rJ=(0,g.K)((e,t,r,n,o)=>{let a=[],i=new Set;if(r.forEach(({start:e,end:t})=>{e!==n&&i.add(e),t!==n&&i.add(t)}),i.forEach(t=>{let r=e.node(t);"number"==typeof r?.x&&"number"==typeof r?.y&&a.push(r)}),0===a.length&&r.forEach(({edge:e})=>{(e.points??[]).forEach(e=>{"number"==typeof e?.x&&"number"==typeof e?.y&&a.push(e)})}),0===a.length)return rF(o);let u=a.reduce((e,t)=>({x:e.x+t.x/a.length,y:e.y+t.y/a.length}),{x:0,y:0}),d=u.x-t.x,c=u.y-t.y;return Math.abs(d)>Math.abs(c)?d>0?"right":"left":Math.abs(c)>0?c>0?"bottom":"top":rF(o)},"getSelfLoopSide"),rz=(0,g.K)((e,t="top",r=0,n=0)=>{let o=e.x,a=e.y-r,i=e.width/2,u=e.height/2,d=Math.max(36,Math.min(100,.8*e.width)),c=rG(Math.max(n,.35*e.width),36,d),s=rG(.45*Math.min(e.width,e.height),24,48);switch(t){case"bottom":{let e=a+u;return[{x:o-c/2,y:e},{x:o-c/2,y:e+s},{x:o+c/2,y:e+s},{x:o+c/2,y:e}]}case"right":{let e=o+i;return[{x:e,y:a-c/2},{x:e+s,y:a-c/2},{x:e+s,y:a+c/2},{x:e,y:a+c/2}]}case"left":{let e=o-i;return[{x:e,y:a-c/2},{x:e-s,y:a-c/2},{x:e-s,y:a+c/2},{x:e,y:a+c/2}]}default:{let e=a-u;return[{x:o-c/2,y:e},{x:o-c/2,y:e-s},{x:o+c/2,y:e-s},{x:o+c/2,y:e}]}}},"getSelfLoopPoints"),rV=(0,g.K)((e,t,r="top",n=0,o={})=>{let a=e.x,i=e.y-n,u=o.width??0,d=o.height??0;switch(r){case"bottom":return{x:a,y:Math.max(...t.map(e=>e.y))+d/2+4};case"right":return{x:Math.max(...t.map(e=>e.x))+u/2+4,y:i};case"left":return{x:Math.min(...t.map(e=>e.x))-u/2-4,y:i};default:return{x:a,y:Math.min(...t.map(e=>e.y))-d/2-4}}},"getSelfLoopLabelPosition"),rY=(0,g.K)((e,t=0,{mergeSelfLoops:r=!0}={})=>{let n=new Map,o=[],a=e.graph()?.rankdir;return e.edges().forEach(t=>{let a=e.edge(t);if(r&&a.selfLoop){let e=a.selfLoop.id;n.has(e)||n.set(e,[]),n.get(e).push({edge:a,start:t.v,end:t.w})}else o.push({edge:a,start:t.v,end:t.w})}),n.forEach(r=>{if(3!==r.length)return void r.forEach(e=>o.push(e));r.sort((e,t)=>e.edge.selfLoop.order-t.edge.selfLoop.order);let[n,i,u]=r,d=n.edge.originalEdge??i.edge.originalEdge??u.edge.originalEdge??i.edge,c=e.node(d.start);if(!c)return void r.forEach(e=>o.push(e));let s={width:i.edge.width,height:i.edge.height},f=rJ(e,c,r,d.start,a),l=rz(c,f,t,s.width??0),g=rV(c,l,f,t,s),h={...i.edge,...d,id:d.id,points:l,start:d.start,end:d.end,x:g.x,y:g.y,width:s.width,height:s.height,labelStyle:i.edge.labelStyle,fromCluster:n.edge.fromCluster??i.edge.fromCluster??u.edge.fromCluster,toCluster:n.edge.toCluster??i.edge.toCluster??u.edge.toCluster};delete h.selfLoop,delete h.originalEdge,o.push({edge:h,start:h.start,end:h.end})}),o},"getEdgesToRender"),r$=(0,g.K)(async({element:e,graph:t,diagramType:r,id:n,parentCluster:o,siteConfig:a})=>{let u=t.graph().rankdir;l.R.trace("Dir in recursive render - dir:",u);let{clusters:f,edgePaths:h,edgeLabels:p,nodes:v,rootGroups:y}=(0,i.B)(e,{edgePathsClass:"edgePaths"});t.nodes()?l.R.info("Recursive render XXX",t.nodes()):l.R.info("No nodes found for",t),t.edges().length>0&&l.R.info("Recursive edges",t.edge(t.edges()[0]));let b=rU(r);await Promise.all(t.nodes().map(async function(e){let d=t.node(e);if(void 0!==o){let r=JSON.parse(JSON.stringify(o.clusterData));l.R.trace("Setting data for parent cluster XXX\n Node.id = ",e,"\n data=",r.height,"\nParent cluster",o.height),t.setNode(o.id,r),t.parent(e)||(l.R.trace("Setting parent",e,o.id),t.setParent(e,o.id,r))}if(l.R.info("(Insert) Node XXX"+e+": "+JSON.stringify(t.node(e))),d?.clusterNode){l.R.info("Cluster identified XBX",e,d.width,t.node(e));let{ranksep:o,nodesep:i}=t.graph();d.graph.setGraph({...d.graph.graph(),ranksep:o+25,nodesep:i});let u=await r2({element:v,graph:d.graph,diagramType:r,id:n,parentCluster:t.node(e),siteConfig:a}),f=u.elem;(0,s.lC)(d,f),d.diff=u.diff||0,l.R.info("New compound node after recursive render XAX",e,"width",d.width,"height",d.height),(0,c.U7)(f,d)}else t.children(e).length>0?(l.R.trace("Cluster - the non recursive path XBX",e,d.id,d,d.width,"Graph:",t),l.R.trace((0,i.dc)(d.id,t)),i.ju.set(d.id,{id:(0,i.dc)(d.id,t),node:d})):(l.R.trace("Node - the non recursive path XAX",e,v,t.node(e),u),await (0,i.sv)(v,t.node(e),{config:a,dir:u}))}));let A=(0,g.K)(async()=>{let e=t.edges().map(async function(e){let r=t.edge(e.v,e.w,e.name);if(l.R.info("Edge "+e.v+" -> "+e.w+": "+JSON.stringify(e)),l.R.info("Edge "+e.v+" -> "+e.w+": ",e," ",JSON.stringify(t.edge(e))),l.R.info("Fix",i.ju,"ids:",e.v,e.w,"Translating: ",i.ju.get(e.v),i.ju.get(e.w)),b&&r.selfLoop){if(1!==r.selfLoop.order)return;let e={...r.originalEdge,...r,id:r.selfLoop.id,startLabelLeft:r.originalEdge?.startLabelLeft??r.startLabelLeft,startLabelRight:r.originalEdge?.startLabelRight??r.startLabelRight,endLabelLeft:r.originalEdge?.endLabelLeft??r.endLabelLeft,endLabelRight:r.originalEdge?.endLabelRight??r.endLabelRight};await (0,d.jP)(p,e),r.width=e.width,r.height=e.height,r.labelStyle=e.labelStyle;return}await (0,d.jP)(p,r)});await Promise.all(e)},"processEdges");await A();let{subGraphTitleTotalMargin:w}=(0,c.Oi)(a);return{elem:y,graph:t,groups:{clusters:f,edgePaths:h,edgeLabels:p,nodes:v,rootGroups:y},diagramType:r,id:n,mergeSelfLoops:b,subGraphTitleTotalMargin:w}},"measureDagreGraph"),rH=(0,g.K)(e=>{l.R.info("############################################# XXX"),l.R.info("### Layout ### XXX"),l.R.info("############################################# XXX"),th("layout",()=>{var t=th(" buildLayoutGraph",()=>{var t,r,n;return t=e,r=new Y.T({multigraph:!0,compound:!0}),n=rK(t.graph()),r.setGraph(eJ({},rS,rB(n,rC),e0(n,r_))),h.A(t.nodes(),function(e){var n=rK(t.node(e));r.setNode(e,e3(rB(n,rM),rX)),r.setParent(e,t.parent(e))}),h.A(t.edges(),function(e){var n=rK(t.edge(e));r.setEdge(e,eJ({},rT,rB(n,rD),e0(n,rI)))}),r});th(" runLayout",()=>{var e,r;return e=t,void((r=th)(" makeSpaceForEdgeLabels",()=>{var t,r;return r=(t=e).graph(),void(r.ranksep/=2,h.A(t.edges(),function(e){var n=t.edge(e);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===r.rankdir||"BT"===r.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}),r(" removeSelfEdges",()=>{var t;return t=e,void h.A(t.edges(),function(e){if(e.v===e.w){var r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}),r(" acyclic",()=>{var t,r,n,o,a,i;return t="greedy"===e.graph().acyclicer?function(e,t){if(1>=e.nodeCount())return[];var r,n,o,a,i,u,d,c=(r=e,n=t||Q,o=new Y.T,a=0,i=0,h.A(r.nodes(),function(e){o.setNode(e,{v:e,in:0,out:0})}),h.A(r.edges(),function(e){var t=o.edge(e.v,e.w)||0,r=n(e);o.setEdge(e.v,e.w,t+r),i=Math.max(i,o.node(e.v).out+=r),a=Math.max(a,o.node(e.w).in+=r)}),u=V(i+a+3).map(function(){return new $}),d=a+1,h.A(o.nodes(),function(e){ee(u,d,o.node(e))}),{graph:o,buckets:u,zeroIdx:d});return w(O(function(e,t,r){for(var n,o=[],a=t[t.length-1],i=t[0];e.nodeCount();){for(;n=i.dequeue();)Z(e,t,r,n);for(;n=a.dequeue();)Z(e,t,r,n);if(e.nodeCount()){for(var u=t.length-2;u>0;--u)if(n=t[u].dequeue()){o=o.concat(Z(e,t,r,n,!0));break}}}return o}(c.graph,c.buckets,c.zeroIdx),function(t){return e.outEdges(t.v,t.w)}))}(e,(r=e,function(e){return r.edge(e).weight})):(n=e,o=[],a={},i={},h.A(n.nodes(),function e(t){Object.prototype.hasOwnProperty.call(i,t)||(i[t]=!0,a[t]=!0,h.A(n.outEdges(t),function(t){Object.prototype.hasOwnProperty.call(a,t.w)?o.push(t):e(t.w)}),delete a[t])}),o),void h.A(t,function(t){var r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,y("rev"))})}),r(" nestingGraph.run",()=>{var t,r,n,o,a,i,u,d;return t=td(e,"root",{},"_root"),i=e,u={},h.A(i.children(),function(e){!function e(t,r){var n=i.children(t);n&&n.length&&h.A(n,function(t){e(t,r+1)}),u[t]=r}(e,1)}),r=u,o=2*(n=e6(t0.A(r))-1)+1,e.graph().nestingRoot=t,h.A(e.edges(),function(t){e.edge(t).minlen*=o}),a=(d=e,t1.A(d.edges(),function(e,t){return e+d.edge(t).weight},0)+1),void(h.A(e.children(),function(i){!function e(t,r,n,o,a,i,u){var d=t.children(u);if(!d.length){u!==r&&t.setEdge(r,u,{weight:0,minlen:n});return}var c=tl(t,"_bt"),s=tl(t,"_bb"),f=t.node(u);t.setParent(c,u),f.borderTop=c,t.setParent(s,u),f.borderBottom=s,h.A(d,function(d){e(t,r,n,o,a,i,d);var f=t.node(d),l=f.borderTop?f.borderTop:d,g=f.borderBottom?f.borderBottom:d,h=f.borderTop?o:2*o,p=l!==g?1:a-i[u]+1;t.setEdge(c,l,{weight:h,minlen:p,nestingEdge:!0}),t.setEdge(g,s,{weight:h,minlen:p,nestingEdge:!0})}),t.parent(u)||t.setEdge(r,c,{weight:0,minlen:a+i[u]})}(e,t,o,a,n,r,i)}),e.graph().nodeRankFactor=o)}),r(" rank",()=>(function(e){switch(e.graph().ranker){case"network-simplex":default:tz(e);break;case"tight-tree":var t;tm(t=e),tE(t);break;case"longest-path":tm(e)}})(tc(e))),r(" injectEdgeLabelProxies",()=>{var t;return t=e,void h.A(t.edges(),function(e){var r=t.edge(e);if(r.width&&r.height){var n=t.node(e.v),o={rank:(t.node(e.w).rank-n.rank)/2+n.rank,e:e};td(t,"edge-proxy",o,"_ep")}})}),r(" removeEmptyRanks",()=>{var t,r,n,o;return t=tn(O(e.nodes(),function(t){return e.node(t).rank})),r=[],h.A(e.nodes(),function(n){var o=e.node(n).rank-t;r[o]||(r[o]=[]),r[o].push(n)}),n=0,o=e.graph().nodeRankFactor,void h.A(r,function(t,r){tt.A(t)&&r%o!=0?--n:n&&h.A(t,function(t){e.node(t).rank+=n})})}),r(" nestingGraph.cleanup",()=>{var t;return t=e.graph(),void(e.removeNode(t.nestingRoot),delete t.nestingRoot,h.A(e.edges(),function(t){e.edge(t).nestingEdge&&e.removeEdge(t)}))}),r(" normalizeRanks",()=>{var t;return t=tn(O(e.nodes(),function(t){return e.node(t).rank})),void h.A(e.nodes(),function(r){var n=e.node(r);tu(n,"rank")&&(n.rank-=t)})}),r(" assignRankMinMax",()=>{var t,r;return t=e,r=0,void(h.A(t.nodes(),function(e){var n=t.node(e);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,r=e6(r,n.maxRank))}),t.graph().maxRank=r)}),r(" removeEdgeLabelProxies",()=>{var t;return t=e,void h.A(t.nodes(),function(e){var r=t.node(e);"edge-proxy"===r.dummy&&(t.edge(r.e).labelRank=r.rank,t.removeNode(e))})}),r(" normalize.run",()=>{e.graph().dummyChains=[],h.A(e.edges(),function(t){!function(e,t){var r,n,o=t.v,a=e.node(o).rank,i=t.w,u=e.node(i).rank,d=t.name,c=e.edge(t),s=c.labelRank;if(u!==a+1){e.removeEdge(t);var f=void 0;for(n=0,++a;a<u;++n,++a)c.points=[],r=td(e,"edge",f={width:0,height:0,edgeLabel:c,edgeObj:t,rank:a},"_d"),a===s&&(f.width=c.width,f.height=c.height,f.dummy="edge-label",f.labelpos=c.labelpos),e.setEdge(o,r,{weight:c.weight},d),0===n&&e.graph().dummyChains.push(r),o=r;e.setEdge(o,i,{weight:c.weight},d)}}(e,t)})}),r(" parentDummyChains",()=>{var t,r,n,o;return r=e,n={},o=0,h.A(r.children(),function e(t){var a=o;h.A(r.children(t),e),n[t]={low:a,lim:o++}}),t=n,void h.A(e.graph().dummyChains,function(r){for(var n=e.node(r),o=n.edgeObj,a=function(e,t,r,n){var o,a,i=[],u=[],d=Math.min(t[r].low,t[n].low),c=Math.max(t[r].lim,t[n].lim);o=r;do i.push(o=e.parent(o));while(o&&(t[o].low>d||c>t[o].lim))for(a=o,o=n;(o=e.parent(o))!==a;)u.push(o);return{path:i.concat(u.reverse()),lca:a}}(e,t,o.v,o.w),i=a.path,u=a.lca,d=0,c=i[0],s=!0;r!==o.w;){if(n=e.node(r),s){for(;(c=i[d])!==u&&e.node(c).maxRank<n.rank;)d++;c===u&&(s=!1)}if(!s){for(;d<i.length-1&&e.node(c=i[d+1]).minRank<=n.rank;)d++;c=i[d]}e.setParent(r,c),r=e.successors(r)[0]}})}),r(" addBorderSegments",()=>{h.A(e.children(),function t(r){var n=e.children(r),o=e.node(r);if(n.length&&h.A(n,t),Object.prototype.hasOwnProperty.call(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(var a=o.minRank,i=o.maxRank+1;a<i;++a)tp(e,"borderLeft","_bl",r,o,a),tp(e,"borderRight","_br",r,o,a)}})}),r(" order",()=>(function(e){var t=tg(e),r=rO(e,V(1,t+1),"inEdges"),n=rO(e,V(t-1,-1,-1),"outEdges"),o=(a={},u=e6(O(i=tN.A(e.nodes(),function(t){return!e.children(t).length}),function(t){return e.node(t).rank})),d=O(V(u+1),function(){return[]}),c=rL(i,function(t){return e.node(t).rank}),h.A(c,function t(r){tu(a,r)||(a[r]=!0,d[e.node(r).rank].push(r),h.A(e.successors(r),t))}),d);rR(e,o);for(var a,i,u,d,c,s,f=1/0,l=0,g=0;g<4;++l,++g){(function(e,t){var r=new Y.T;h.A(e,function(e){var n,o,a,i=e.graph().root,u=function e(t,r,n,o){var a,i,u,d,c,s,f,l,g,p,v,y=t.children(r),b=t.node(r),A=b?b.borderLeft:void 0,m=b?b.borderRight:void 0,x={};A&&(y=tN.A(y,function(e){return e!==A&&e!==m}));var E=O(y,function(e){var r=t.inEdges(e);if(!r.length)return{v:e};var n=t1.A(r,function(e,r){var n=t.edge(r),o=t.node(r.v);return{sum:e.sum+n.weight*o.order,weight:e.weight+n.weight}},{sum:0,weight:0});return{v:e,barycenter:n.sum/n.weight,weight:n.weight}});h.A(E,function(r){if(t.children(r.v).length){var a,i,u=e(t,r.v,n,o);x[r.v]=u,Object.prototype.hasOwnProperty.call(u,"barycenter")&&(a=r,i=u,tt.A(a.barycenter)?(a.barycenter=i.barycenter,a.weight=i.weight):(a.barycenter=(a.barycenter*a.weight+i.barycenter*i.weight)/(a.weight+i.weight),a.weight+=i.weight))}});var j=(a={},h.A(E,function(e,t){var r=a[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};tt.A(e.barycenter)||(r.barycenter=e.barycenter,r.weight=e.weight)}),h.A(n.edges(),function(e){var t=a[e.v],r=a[e.w];tt.A(t)||tt.A(r)||(r.indegree++,t.out.push(a[e.w]))}),function(e){for(var t=[];e.length;){var r=e.pop();t.push(r),h.A(r.in.reverse(),function(e){return function(t){!t.merged&&(tt.A(t.barycenter)||tt.A(e.barycenter)||t.barycenter>=e.barycenter)&&function(e,t){var r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}(r)),h.A(r.out,function(t){return function(r){r.in.push(t),0==--r.indegree&&e.push(r)}}(r))}return O(tN.A(t,function(e){return!e.merged}),function(e){return e0(e,["vs","i","barycenter","weight"])})}(tN.A(a,function(e){return!e.indegree})));!function(e,t){h.A(e,function(e){e.vs=w(e.vs.map(function(e){return t[e]?t[e].vs:e}))})}(j,x);var L=(c=(i=function(e){return Object.prototype.hasOwnProperty.call(e,"barycenter")},u={lhs:[],rhs:[]},h.A(j,function(e){i(e)?u.lhs.push(e):u.rhs.push(e)}),d=u).lhs,s=rL(d.rhs,function(e){return-e.i}),f=[],l=0,g=0,p=0,c.sort(function(e){return function(t,r){return t.barycenter<r.barycenter?-1:t.barycenter>r.barycenter?1:e?r.i-t.i:t.i-r.i}}(!!o)),p=rk(f,s,p),h.A(c,function(e){p+=e.vs.length,f.push(e.vs),l+=e.barycenter*e.weight,g+=e.weight,p=rk(f,s,p)}),v={vs:w(f)},g&&(v.barycenter=l/g,v.weight=g),v);if(A&&(L.vs=w([A,L.vs,m]),t.predecessors(A).length)){var k=t.node(t.predecessors(A)[0]),R=t.node(t.predecessors(m)[0]);Object.prototype.hasOwnProperty.call(L,"barycenter")||(L.barycenter=0,L.weight=0),L.barycenter=(L.barycenter*L.weight+k.order+R.order)/(L.weight+2),L.weight+=2}return L}(e,i,r,t);h.A(u.vs,function(t,r){e.node(t).order=r}),n=u.vs,a={},h.A(n,function(t){for(var n,i,u=e.parent(t);u;){if((n=e.parent(u))?(i=a[n],a[n]=u):(i=o,o=u),i&&i!==u)return void r.setEdge(i,u);u=n}})})})(l%2?r:n,l%4>=2),o=tf(e);var p=function(e,t){for(var r=0,n=1;n<t.length;++n)r+=function(e,t,r){for(var n=rw(r||[],O(r,function(e,t){return t})||[],eX),o=w(O(t,function(t){return rL(O(e.outEdges(t),function(t){return{pos:n[t.w],weight:e.edge(t).weight}}),"pos")})),a=1;a<r.length;)a<<=1;var i=2*a-1;a-=1;var u=O(Array(i),function(){return 0}),d=0;return h.A(o.forEach(function(e){var t=e.pos+a;u[t]+=e.weight;for(var r=0;t>0;)t%2&&(r+=u[t+1]),t=t-1>>1,u[t]+=e.weight;d+=e.weight*r})),d}(e,t[n-1],t[n]);return r}(e,o);p<f&&(g=0,s=rA(o,5),f=p)}rR(e,s)})(e)),r(" insertSelfEdges",()=>{var t,r;return r=tf(t=e),void h.A(r,function(e){var r=0;h.A(e,function(e,n){var o=t.node(e);o.order=n+r,h.A(o.selfEdges,function(e){td(t,"selfedge",{width:e.label.width,height:e.label.height,rank:o.rank,order:n+ ++r,e:e.e,label:e.label},"_se")}),delete o.selfEdges})})}),r(" adjustCoordinateSystem",()=>{var t;("lr"===(t=e.graph().rankdir.toLowerCase())||"rl"===t)&&tv(e)}),r(" position",()=>{var t,r,n,o,a,i,u,d,c,s,f,l,g,p,v,y,b;v=tf(p=t=tc(t=e)),y=p.graph().ranksep,b=0,h.A(v,function(e){var t=e6(O(e,function(e){return p.node(e).height}));h.A(e,function(e){p.node(e).y=b+t/2}),b+=t+y}),o=tf(r=t),i=eJ((a={},t1.A(o,function(e,t){var n=0,o=0,i=e.length,u=e9(t);return h.A(t,function(e,d){var c=function(e,t){if(e.node(t).dummy)return tR(e.predecessors(t),function(t){return e.node(t).dummy})}(r,e),s=c?r.node(c).order:i;(c||e===u)&&(h.A(t.slice(o,d+1),function(e){h.A(r.predecessors(e),function(t){var o=r.node(t),i=o.order;(i<n||s<i)&&!(o.dummy&&r.node(e).dummy)&&rP(a,t,e)})}),o=d+1,n=s)}),t}),a),function(e,t){var r={};function n(t,n,o,a,i){var u;h.A(V(n,o),function(n){u=t[n],e.node(u).dummy&&h.A(e.predecessors(u),function(t){var n=e.node(t);n.dummy&&(n.order<a||n.order>i)&&rP(r,t,u)})})}return t1.A(t,function(t,r){var o,a=-1,i=0;return h.A(r,function(u,d){if("border"===e.node(u).dummy){var c=e.predecessors(u);c.length&&(o=e.node(c[0]).order,n(r,i,d,a,o),i=d,a=o)}n(r,i,r.length,o,t.length)}),r}),r}(r,o)),u={},h.A(["u","d"],function(e){n="u"===e?o:t0.A(o).reverse(),h.A(["l","r"],function(t){"r"===t&&(n=O(n,function(e){return t0.A(e).reverse()}));var o,a,d,c,s=("u"===e?r.predecessors:r.successors).bind(r),f=(o=n,a={},d={},c={},h.A(o,function(e){h.A(e,function(e,t){a[e]=e,d[e]=e,c[e]=t})}),h.A(o,function(e){var t=-1;h.A(e,function(e){var r=s(e);if(r.length)for(var n=((r=rL(r,function(e){return c[e]})).length-1)/2,o=Math.floor(n),u=Math.ceil(n);o<=u;++o){var f=r[o];d[e]===e&&t<c[f]&&!function(e,t,r){if(t>r){var n=t;t=r,r=n}return!!e[t]&&Object.prototype.hasOwnProperty.call(e[t],r)}(i,e,f)&&(d[f]=e,d[e]=a[e]=a[f],t=c[f])}})}),{root:a,align:d}),l=function(e,t,r,n,o){var a,i,u,d,c,s,f,l,g,p,v={},y=(a=e,i=t,u=r,d=o,l=new Y.T,p=(c=(g=a.graph()).nodesep,s=g.edgesep,f=d,function(e,t,r){var n,o,a=e.node(t),i=e.node(r);if(n=0+a.width/2,Object.prototype.hasOwnProperty.call(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":o=-a.width/2;break;case"r":o=a.width/2}if(o&&(n+=f?o:-o),o=0,n+=(a.dummy?s:c)/2,n+=(i.dummy?s:c)/2,n+=i.width/2,Object.prototype.hasOwnProperty.call(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":o=i.width/2;break;case"r":o=-i.width/2}return o&&(n+=f?o:-o),o=0,n}),h.A(i,function(e){var t;h.A(e,function(e){var r=u[e];if(l.setNode(r),t){var n=u[t],o=l.edge(n,r);l.setEdge(n,r,Math.max(p(a,e,t),o||0))}t=e})}),l),b=o?"borderLeft":"borderRight";function A(e,t){for(var r=y.nodes(),n=r.pop(),o={};n;)o[n]?e(n):(o[n]=!0,r.push(n),r=r.concat(t(n))),n=r.pop()}return A(function(e){v[e]=y.inEdges(e).reduce(function(e,t){return Math.max(e,v[t.v]+y.edge(t))},0)},y.predecessors.bind(y)),A(function(t){var r=y.outEdges(t).reduce(function(e,t){return Math.min(e,v[t.w]-y.edge(t))},1/0),n=e.node(t);r!==1/0&&n.borderType!==b&&(v[t]=Math.max(v[t],r))},y.successors.bind(y)),h.A(n,function(e){v[e]=v[r[e]]}),v}(r,n,f.root,f.align,"r"===t);"r"===t&&(l=te(l,function(e){return-e})),u[e+t]=l})}),d=tw(t0.A(u),function(e){var t,n=-1/0,o=1/0;return t=function(e,t){var a,i,u=(a=r,i=t,a.node(i).width/2);n=Math.max(e+u,n),o=Math.min(e-u,o)},null==e||(0,ea.A)(e,(0,rN.A)(t),eG),n-o}),s=tn(c=t0.A(d)),f=e6(c),h.A(["u","d"],function(e){h.A(["l","r"],function(t){var r,n=e+t,o=u[n];if(o!==d){var a=t0.A(o);(r="l"===t?s-tn(a):f-e6(a))&&(u[n]=te(o,function(e){return e+r}))}})}),l=r.graph().align,g=te(u.ul,function(e,t){if(l)return u[l.toLowerCase()][t];var r=rL(O(u,t));return(r[1]+r[2])/2}),g&&(0,e7.A)(g,(0,rN.A)(function(e,r){t.node(r).x=e}))}),r(" positionSelfEdges",()=>{var t;return t=e,void h.A(t.nodes(),function(e){var r=t.node(e);if("selfedge"===r.dummy){var n=t.node(r.e.v),o=n.x+n.width/2,a=n.y,i=r.x-o,u=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:o+2*i/3,y:a-u},{x:o+5*i/6,y:a-u},{x:o+i,y:a},{x:o+5*i/6,y:a+u},{x:o+2*i/3,y:a+u}],r.label.x=r.x,r.label.y=r.y}})}),r(" removeBorderNodes",()=>{var t;return t=e,void(h.A(t.nodes(),function(e){if(t.children(e).length){var r=t.node(e),n=t.node(r.borderTop),o=t.node(r.borderBottom),a=t.node(e9(r.borderLeft)),i=t.node(e9(r.borderRight));r.width=Math.abs(i.x-a.x),r.height=Math.abs(o.y-n.y),r.x=a.x+r.width/2,r.y=n.y+r.height/2}}),h.A(t.nodes(),function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}),r(" normalize.undo",()=>{h.A(e.graph().dummyChains,function(t){var r,n=e.node(t),o=n.edgeLabel;for(e.setEdge(n.edgeObj,o);n.dummy;)r=e.successors(t)[0],e.removeNode(t),o.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(o.x=n.x,o.y=n.y,o.width=n.width,o.height=n.height),t=r,n=e.node(t)})}),r(" fixupEdgeLabelCoords",()=>{var t;return t=e,void h.A(t.edges(),function(e){var r=t.edge(e);if(Object.prototype.hasOwnProperty.call(r,"x"))switch(("l"===r.labelpos||"r"===r.labelpos)&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}})}),r(" undoCoordinateSystem",()=>{var t,r,n;("bt"===(t=e.graph().rankdir.toLowerCase())||"rl"===t)&&(r=e,h.A(r.nodes(),function(e){tb(r.node(e))}),h.A(r.edges(),function(e){var t=r.edge(e);h.A(t.points,tb),Object.prototype.hasOwnProperty.call(t,"y")&&tb(t)})),("lr"===t||"rl"===t)&&(n=e,h.A(n.nodes(),function(e){tA(n.node(e))}),h.A(n.edges(),function(e){var t=n.edge(e);h.A(t.points,tA),Object.prototype.hasOwnProperty.call(t,"x")&&tA(t)}),tv(e))}),r(" translateGraph",()=>(function(e){var t=1/0,r=0,n=1/0,o=0,a=e.graph(),i=a.marginx||0,u=a.marginy||0;function d(e){var a=e.x,i=e.y,u=e.width,d=e.height;t=Math.min(t,a-u/2),r=Math.max(r,a+u/2),n=Math.min(n,i-d/2),o=Math.max(o,i+d/2)}h.A(e.nodes(),function(t){d(e.node(t))}),h.A(e.edges(),function(t){var r=e.edge(t);Object.prototype.hasOwnProperty.call(r,"x")&&d(r)}),t-=i,n-=u,h.A(e.nodes(),function(r){var o=e.node(r);o.x-=t,o.y-=n}),h.A(e.edges(),function(r){var o=e.edge(r);h.A(o.points,function(e){e.x-=t,e.y-=n}),Object.prototype.hasOwnProperty.call(o,"x")&&(o.x-=t),Object.prototype.hasOwnProperty.call(o,"y")&&(o.y-=n)}),a.width=r-t+i,a.height=o-n+u})(e)),r(" assignNodeIntersects",()=>{var t;return t=e,void h.A(t.edges(),function(e){var r,n,o=t.edge(e),a=t.node(e.v),i=t.node(e.w);o.points?(r=o.points[0],n=o.points[o.points.length-1]):(o.points=[],r=i,n=a),o.points.unshift(ts(a,r)),o.points.push(ts(i,n))})}),r(" reversePoints",()=>{var t;return t=e,void h.A(t.edges(),function(e){var r=t.edge(e);r.reversed&&r.points.reverse()})}),r(" acyclic.undo",()=>{h.A(e.edges(),function(t){var r=e.edge(t);if(r.reversed){e.removeEdge(t);var n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}))}),th(" updateInputGraph",()=>{var r,n;return r=e,n=t,void(h.A(r.nodes(),function(e){var t=r.node(e),o=n.node(e);t&&(t.x=o.x,t.y=o.y,n.children(e).length&&(t.width=o.width,t.height=o.height))}),h.A(r.edges(),function(e){var t=r.edge(e),o=n.edge(e);t.points=o.points,Object.prototype.hasOwnProperty.call(o,"x")&&(t.x=o.x,t.y=o.y)}),r.graph().width=n.graph().width,r.graph().height=n.graph().height)})})},"runDagreGraphLayout"),rW=(0,g.K)((e,t,r)=>{let n=e.node(t);if(!n)return;let o={...n};return n?.clusterNode?o.y=(n.y??0)+r:e.children(t).length>0?o.height=(n.height??0)+r:o.y=(n.y??0)+r/2,o},"normalizeDagreNode"),rQ=(0,g.K)((e,t)=>{rq.forEach(r=>{void 0!==t[r]&&(e[r]=t[r])})},"applyDagreNodeLayout"),rZ=(0,g.K)((e,t,r,n)=>({...e,start:e.start??t,end:e.end??r,points:(e.points??[]).map(e=>({...e,y:"number"==typeof e.y?e.y+n:e.y}))}),"normalizeDagreEdge"),r0=(0,g.K)((e,t)=>{let{graph:r,mergeSelfLoops:n,subGraphTitleTotalMargin:o=0}=t,a=new Map(e.nodes.map(e=>[e.id,e]));(0,i.sc)(r).forEach(e=>{let t=rW(r,e,o);if(!t)return;rQ(r.node(e),t);let n=a.get(e);n&&rQ(n,t)});let u=o/2;return e.edges=rY(r,u,{mergeSelfLoops:n}).map(({edge:e,start:t,end:r})=>rZ(e,t,r,u)),e},"applyDagreLayoutResult"),r1=(0,g.K)(async({elem:e,graph:t,groups:{clusters:r,edgePaths:n},diagramType:o,id:a,mergeSelfLoops:s,subGraphTitleTotalMargin:f})=>{let g=0;await Promise.all((0,i.sc)(t).map(async function(e){let n=t.node(e);if(l.R.info("Position XBX => "+e+": ("+n.x,","+n.y,") width: ",n.width," height: ",n.height),n?.clusterNode)n.y+=f,l.R.info("A tainted cluster node XBX1",e,n.id,n.width,n.height,n.x,n.y,t.parent(e)),i.ju.get(n.id).node=n,(0,c.U_)(n);else if(t.children(e).length>0){l.R.info("A pure cluster node XBX1",e,n.id,n.x,n.y,n.width,n.height,t.parent(e)),n.height+=f,t.node(n.parentId);let o=n?.padding/2||0,a=n?.labelBBox?.height||0;l.R.debug("OffsetY",a-o||0,"labelHeight",a,"halfPadding",o),await (0,u.U)(r,n),i.ju.get(n.id).node=n}else{let e=t.node(n.parentId);n.y+=f/2,l.R.info("A regular node XBX1 - using the padding",n.id,"parent",n.parentId,n.width,n.height,n.x,n.y,"offsetY",n.offsetY,"parent",e,e?.offsetY,n),(0,c.U_)(n)}}));let h=f/2;return rY(t,h,{mergeSelfLoops:s}).forEach(function({edge:e,start:r,end:u}){l.R.info("Edge "+r+" -> "+u+": "+JSON.stringify(e),e),e.points.forEach(e=>e.y+=h);let c=t.node(r),s=t.node(u),f=(0,d.Jo)(n,e,i.ju,o,c,s,a);(0,d.T_)(e,f)}),t.nodes().forEach(function(e){let r=t.node(e);l.R.info(e,r.type,r.diff),r.isGroup&&(g=r.diff)}),l.R.warn("Returning from recursive render XAX",e,g),{elem:e,diff:g}},"paintDagreLayoutCore"),r2=(0,g.K)(async e=>{let t=await r$(e);return rH(t.graph),await r1(t)},"renderDagreSubgraph"),r3=(0,g.K)(e=>{let t=new Y.T({multigraph:!0,compound:!0}).setGraph({rankdir:e.direction,nodesep:e.config?.nodeSpacing||e.nodeSpacing||e.config?.flowchart?.nodeSpacing,ranksep:e.config?.rankSpacing||e.rankSpacing||e.config?.flowchart?.rankSpacing,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});return e.nodes.forEach(e=>{t.setNode(e.id,{...e}),e.parentId&&t.setParent(e.id,e.parentId)}),l.R.debug("Edges:",e.edges),e.edges.forEach(e=>{if(e.start===e.end){let r=e.start,n=r+"---"+r+"---1",o=r+"---"+r+"---2",a=t.node(r);t.setNode(n,{domId:n,id:n,parentId:a.parentId,labelStyle:"",label:"",padding:0,shape:"labelRect",style:"",width:10,height:10}),t.setParent(n,a.parentId),t.setNode(o,{domId:o,id:o,parentId:a.parentId,labelStyle:"",padding:0,shape:"labelRect",label:"",style:"",width:10,height:10}),t.setParent(o,a.parentId);let i=structuredClone(e),u=structuredClone(e),d=structuredClone(e),c=structuredClone(e);u.originalEdge=i,u.selfLoop={id:i.id,order:0},d.originalEdge=i,d.selfLoop={id:i.id,order:1},c.originalEdge=i,c.selfLoop={id:i.id,order:2},u.label="",u.arrowTypeEnd="none",u.endLabelLeft="",u.endLabelRight="",u.startLabelLeft="",u.id=r+"-cyclic-special-1",d.startLabelRight="",d.startLabelLeft="",d.endLabelLeft="",d.endLabelRight="",d.arrowTypeStart="none",d.arrowTypeEnd="none",d.id=r+"-cyclic-special-mid",c.label="",c.startLabelRight="",c.startLabelLeft="",c.arrowTypeStart="none",a.isGroup&&(u.fromCluster=r,c.toCluster=r),c.id=r+"-cyclic-special-2",c.arrowTypeStart="none",t.setEdge(r,n,u,r+"-cyclic-special-0"),t.setEdge(n,o,d,r+"-cyclic-special-1"),t.setEdge(o,r,c,r+"-cyclic-special-2")}else t.setEdge(e.start,e.end,{...e},e.id)}),(0,i.OS)(t),{graph:t}},"prepareLayoutForDagre"),r8=(0,g.K)(async(e,{element:t,preparedLayout:r})=>{let n=r??r3(e),o=(0,f.D7)(),a=await r$({element:t,graph:n.graph,diagramType:e.type,id:e.diagramId,parentCluster:void 0,siteConfig:o});return n.measuredLayout=a,a},"measureDagreLayout"),r4=(0,g.K)((e,t)=>{let r=t.preparedLayout?.measuredLayout;if(!r)throw Error("runDagreLayoutCore requires measureDagreLayout to run first");return rH(r.graph),r0(e,r),r},"runDagreLayoutCore"),r5=(0,g.K)((e,{measure:t})=>(0,i.sc)(t.graph).map(e=>t.graph.node(e)).filter(Boolean),"getDagrePaintNodes"),r6=(0,g.K)((e,t,{measure:r})=>e?r.graph.node(e):void 0,"getDagreEdgeNode"),r9=(0,i.xY)({prepareLayout:r3,measureLayout:r8,runLayoutCore:r4,paintOptions:{clusterDb:i.ju,getNodes:r5,getEdgeNode:r6,skipNode:(0,g.K)((e,{measure:t})=>!t.graph.hasNode(e.id),"skipNode"),isCluster:(0,g.K)((e,{measure:t})=>t.graph.hasNode(e.id)&&(t.graph.children(e.id)??[]).length>0,"isCluster")}})}}]);