@nitrohe/webtopo-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/webtopo.umd.js ADDED
@@ -0,0 +1,24 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("konva")):"function"==typeof define&&define.amd?define(["exports","konva"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WebTopo={},t.Konva)}(this,function(t,e){"use strict";var n=Object.defineProperty,r=(t,e,r)=>(((t,e,r)=>{e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r})(t,"symbol"!=typeof e?e+"":e,r),r),i="object"==typeof globalThis&&globalThis&&globalThis.Object===Object&&globalThis,o="object"==typeof self&&self&&self.Object===Object&&self,s=i||o||Function("return this")(),a=s.Symbol,h=Object.prototype,d=h.hasOwnProperty,u=h.toString,l=a?a.toStringTag:void 0;var c=Object.prototype.toString;var f=a?a.toStringTag:void 0;function g(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":f&&f in Object(t)?function(t){var e=d.call(t,l),n=t[l];try{t[l]=void 0;var r=!0}catch(o){}var i=u.call(t);return r&&(e?t[l]=n:delete t[l]),i}(t):function(t){return c.call(t)}(t)}function p(t){return null!=t&&"object"==typeof t}function y(t){return"symbol"==typeof t||p(t)&&"[object Symbol]"==g(t)}function m(t){return"number"==typeof t?t:y(t)?NaN:+t}function v(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var x=Array.isArray,w=a?a.prototype:void 0,b=w?w.toString:void 0;function S(t){if("string"==typeof t)return t;if(x(t))return v(t,S)+"";if(y(t))return b?b.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function _(t,e){return function(n,r){var i;if(void 0===n&&void 0===r)return e;if(void 0!==n&&(i=n),void 0!==r){if(void 0===i)return r;"string"==typeof n||"string"==typeof r?(n=S(n),r=S(r)):(n=m(n),r=m(r)),i=t(n,r)}return i}}const A=_(function(t,e){return t+e},0);var k=/\s/;function j(t){for(var e=t.length;e--&&k.test(t.charAt(e)););return e}var I=/^\s+/;function T(t){return t?t.slice(0,j(t)+1).replace(I,""):t}function P(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var M=/^[-+]0x[0-9a-f]+$/i,z=/^0b[01]+$/i,V=/^0o[0-7]+$/i,C=parseInt;function O(t){if("number"==typeof t)return t;if(y(t))return NaN;if(P(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=P(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=T(t);var n=z.test(t);return n||V.test(t)?C(t.slice(2),n?2:8):M.test(t)?NaN:+t}var E=1/0;function R(t){return t?(t=O(t))===E||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function L(t){var e=R(t),n=e%1;return e==e?n?e-n:e:0}function W(t){return t}function B(t){if(!P(t))return!1;var e=g(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var N,D=s["__core-js_shared__"],G=(N=/[^.]+$/.exec(D&&D.keys&&D.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"";var F=Function.prototype.toString;function X(t){if(null!=t){try{return F.call(t)}catch(e){}try{return t+""}catch(e){}}return""}var U=/^\[object .+?Constructor\]$/,Y=Function.prototype,Z=Object.prototype,q=Y.toString,$=Z.hasOwnProperty,H=RegExp("^"+q.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function K(t){return!(!P(t)||(e=t,G&&G in e))&&(B(t)?H:U).test(X(t));var e}function J(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return K(n)?n:void 0}var Q=J(s,"WeakMap"),tt=Q&&new Q,et=tt?function(t,e){return tt.set(t,e),t}:W,nt=Object.create,rt=function(){function t(){}return function(e){if(!P(e))return{};if(nt)return nt(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function it(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=rt(t.prototype),r=t.apply(n,e);return P(r)?r:n}}function ot(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var st=Math.max;function at(t,e,n,r){for(var i=-1,o=t.length,s=n.length,a=-1,h=e.length,d=st(o-s,0),u=Array(h+d),l=!r;++a<h;)u[a]=e[a];for(;++i<s;)(l||i<o)&&(u[n[i]]=t[i]);for(;d--;)u[a++]=t[i++];return u}var ht=Math.max;function dt(t,e,n,r){for(var i=-1,o=t.length,s=-1,a=n.length,h=-1,d=e.length,u=ht(o-a,0),l=Array(u+d),c=!r;++i<u;)l[i]=t[i];for(var f=i;++h<d;)l[f+h]=e[h];for(;++s<a;)(c||i<o)&&(l[f+n[s]]=t[i++]);return l}function ut(){}function lt(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function ct(){}lt.prototype=rt(ut.prototype),lt.prototype.constructor=lt;var ft=tt?function(t){return tt.get(t)}:ct,gt={},pt=Object.prototype.hasOwnProperty;function yt(t){for(var e=t.name+"",n=gt[e],r=pt.call(gt,e)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==t)return i.name}return e}function mt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}function vt(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}function xt(t){if(t instanceof lt)return t.clone();var e=new mt(t.__wrapped__,t.__chain__);return e.__actions__=vt(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}mt.prototype=rt(ut.prototype),mt.prototype.constructor=mt;var wt=Object.prototype.hasOwnProperty;function bt(t){if(p(t)&&!x(t)&&!(t instanceof lt)){if(t instanceof mt)return t;if(wt.call(t,"__wrapped__"))return xt(t)}return new mt(t)}function St(t){var e=yt(t),n=bt[e];if("function"!=typeof n||!(e in lt.prototype))return!1;if(t===n)return!0;var r=ft(n);return!!r&&t===r[0]}bt.prototype=ut.prototype,bt.prototype.constructor=bt;var _t=Date.now;function At(t){var e=0,n=0;return function(){var r=_t(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var kt=At(et),jt=/\{\n\/\* \[wrapped with (.+)\] \*/,It=/,? & /;var Tt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function Pt(t){return function(){return t}}var Mt=function(){try{var t=J(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),zt=Mt?function(t,e){return Mt(t,"toString",{configurable:!0,enumerable:!1,value:Pt(e),writable:!0})}:W;var Vt=At(zt);function Ct(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Ot(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1}function Et(t){return t!=t}function Rt(t,e,n){return e==e?function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}(t,e,n):Ot(t,Et,n)}function Lt(t,e){return!!(null==t?0:t.length)&&Rt(t,e,0)>-1}var Wt=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]];function Bt(t,e,n){var r=e+"";return Vt(t,function(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Tt,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Ct(Wt,function(n){var r="_."+n[0];e&n[1]&&!Lt(t,r)&&t.push(r)}),t.sort()}(function(t){var e=t.match(jt);return e?e[1].split(It):[]}(r),n)))}function Nt(t,e,n,r,i,o,s,a,h,d){var u=8&e;e|=u?32:64,4&(e&=~(u?64:32))||(e&=-4);var l=[t,e,i,u?o:void 0,u?s:void 0,u?void 0:o,u?void 0:s,a,h,d],c=n.apply(void 0,l);return St(t)&&kt(c,l),c.placeholder=r,Bt(c,t,e)}function Dt(t){return t.placeholder}var Gt=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&Gt.test(t))&&t>-1&&t%1==0&&t<e}var Xt=Math.min;var Ut="__lodash_placeholder__";function Yt(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var s=t[n];s!==e&&s!==Ut||(t[n]=Ut,o[i++]=n)}return o}function Zt(t,e,n,r,i,o,a,h,d,u){var l=128&e,c=1&e,f=2&e,g=24&e,p=512&e,y=f?void 0:it(t);return function m(){for(var v=arguments.length,x=Array(v),w=v;w--;)x[w]=arguments[w];if(g)var b=Dt(m),S=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(x,b);if(r&&(x=at(x,r,i,g)),o&&(x=dt(x,o,a,g)),v-=S,g&&v<u){var _=Yt(x,b);return Nt(t,e,Zt,m.placeholder,n,x,_,h,d,u-v)}var A=c?n:this,k=f?A[t]:t;return v=x.length,h?x=function(t,e){for(var n=t.length,r=Xt(e.length,n),i=vt(t);r--;){var o=e[r];t[r]=Ft(o,n)?i[o]:void 0}return t}(x,h):p&&v>1&&x.reverse(),l&&d<v&&(x.length=d),this&&this!==s&&this instanceof m&&(k=y||it(k)),k.apply(A,x)}}var qt="__lodash_placeholder__",$t=128,Ht=Math.min;var Kt=Math.max;function Jt(t,e,n,r,i,o,a,h){var d=2&e;if(!d&&"function"!=typeof t)throw new TypeError("Expected a function");var u=r?r.length:0;if(u||(e&=-97,r=i=void 0),a=void 0===a?a:Kt(L(a),0),h=void 0===h?h:L(h),u-=i?i.length:0,64&e){var l=r,c=i;r=i=void 0}var f=d?void 0:ft(t),g=[t,e,n,r,i,l,c,o,a,h];if(f&&function(t,e){var n=t[1],r=e[1],i=n|r,o=i<131,s=r==$t&&8==n||r==$t&&256==n&&t[7].length<=e[8]||384==r&&e[7].length<=e[8]&&8==n;if(!o&&!s)return t;1&r&&(t[2]=e[2],i|=1&n?0:4);var a=e[3];if(a){var h=t[3];t[3]=h?at(h,a,e[4]):a,t[4]=h?Yt(t[3],qt):e[4]}(a=e[5])&&(h=t[5],t[5]=h?dt(h,a,e[6]):a,t[6]=h?Yt(t[5],qt):e[6]),(a=e[7])&&(t[7]=a),r&$t&&(t[8]=null==t[8]?e[8]:Ht(t[8],e[8])),null==t[9]&&(t[9]=e[9]),t[0]=e[0],t[1]=i}(g,f),t=g[0],e=g[1],n=g[2],r=g[3],i=g[4],!(h=g[9]=void 0===g[9]?d?0:t.length:Kt(g[9]-u,0))&&24&e&&(e&=-25),e&&1!=e)p=8==e||16==e?function(t,e,n){var r=it(t);return function i(){for(var o=arguments.length,a=Array(o),h=o,d=Dt(i);h--;)a[h]=arguments[h];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:Yt(a,d);return(o-=u.length)<n?Nt(t,e,Zt,i.placeholder,void 0,a,u,void 0,void 0,n-o):ot(this&&this!==s&&this instanceof i?r:t,this,a)}}(t,e,h):32!=e&&33!=e||i.length?Zt.apply(void 0,g):function(t,e,n,r){var i=1&e,o=it(t);return function e(){for(var a=-1,h=arguments.length,d=-1,u=r.length,l=Array(u+h),c=this&&this!==s&&this instanceof e?o:t;++d<u;)l[d]=r[d];for(;h--;)l[d++]=arguments[++a];return ot(c,i?n:this,l)}}(t,e,n,r);else var p=function(t,e,n){var r=1&e,i=it(t);return function e(){return(this&&this!==s&&this instanceof e?i:t).apply(r?n:this,arguments)}}(t,e,n);return Bt((f?et:kt)(p,g),t,e)}function Qt(t,e,n){return e=n?void 0:e,Jt(t,128,void 0,void 0,void 0,void 0,e=t&&null==e?t.length:e)}function te(t,e,n){"__proto__"==e&&Mt?Mt(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function ee(t,e){return t===e||t!=t&&e!=e}var ne=Object.prototype.hasOwnProperty;function re(t,e,n){var r=t[e];ne.call(t,e)&&ee(r,n)&&(void 0!==n||e in t)||te(t,e,n)}function ie(t,e,n,r){var i=!n;n||(n={});for(var o=-1,s=e.length;++o<s;){var a=e[o],h=r?r(n[a],t[a],a,n,t):void 0;void 0===h&&(h=t[a]),i?te(n,a,h):re(n,a,h)}return n}var oe=Math.max;function se(t,e,n){return e=oe(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=oe(r.length-e,0),s=Array(o);++i<o;)s[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=n(s),ot(t,this,a)}}function ae(t,e){return Vt(se(t,e,W),t+"")}function he(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function de(t){return null!=t&&he(t.length)&&!B(t)}function ue(t,e,n){if(!P(n))return!1;var r=typeof e;return!!("number"==r?de(n)&&Ft(e,n.length):"string"==r&&e in n)&&ee(n[e],t)}function le(t){return ae(function(e,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=t.length>3&&"function"==typeof o?(i--,o):void 0,s&&ue(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),e=Object(e);++r<i;){var a=n[r];a&&t(e,a,r,o)}return e})}var ce=Object.prototype;function fe(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ce)}function ge(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function pe(t){return p(t)&&"[object Arguments]"==g(t)}var ye=Object.prototype,me=ye.hasOwnProperty,ve=ye.propertyIsEnumerable,xe=pe(function(){return arguments}())?pe:function(t){return p(t)&&me.call(t,"callee")&&!ve.call(t,"callee")};const we=xe;function be(){return!1}var Se="object"==typeof t&&t&&!t.nodeType&&t,_e=Se&&"object"==typeof module&&module&&!module.nodeType&&module,Ae=_e&&_e.exports===Se?s.Buffer:void 0;const ke=(Ae?Ae.isBuffer:void 0)||be;var je={};function Ie(t){return function(e){return t(e)}}je["[object Float32Array]"]=je["[object Float64Array]"]=je["[object Int8Array]"]=je["[object Int16Array]"]=je["[object Int32Array]"]=je["[object Uint8Array]"]=je["[object Uint8ClampedArray]"]=je["[object Uint16Array]"]=je["[object Uint32Array]"]=!0,je["[object Arguments]"]=je["[object Array]"]=je["[object ArrayBuffer]"]=je["[object Boolean]"]=je["[object DataView]"]=je["[object Date]"]=je["[object Error]"]=je["[object Function]"]=je["[object Map]"]=je["[object Number]"]=je["[object Object]"]=je["[object RegExp]"]=je["[object Set]"]=je["[object String]"]=je["[object WeakMap]"]=!1;var Te="object"==typeof t&&t&&!t.nodeType&&t,Pe=Te&&"object"==typeof module&&module&&!module.nodeType&&module,Me=Pe&&Pe.exports===Te&&i.process,ze=function(){try{var t=Pe&&Pe.require&&Pe.require("util").types;return t||Me&&Me.binding&&Me.binding("util")}catch(e){}}(),Ve=ze&&ze.isTypedArray;const Ce=Ve?Ie(Ve):function(t){return p(t)&&he(t.length)&&!!je[g(t)]};var Oe=Object.prototype.hasOwnProperty;function Ee(t,e){var n=x(t),r=!n&&we(t),i=!n&&!r&&ke(t),o=!n&&!r&&!i&&Ce(t),s=n||r||i||o,a=s?ge(t.length,String):[],h=a.length;for(var d in t)!e&&!Oe.call(t,d)||s&&("length"==d||i&&("offset"==d||"parent"==d)||o&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||Ft(d,h))||a.push(d);return a}function Re(t,e){return function(n){return t(e(n))}}var Le=Re(Object.keys,Object),We=Object.prototype.hasOwnProperty;function Be(t){if(!fe(t))return Le(t);var e=[];for(var n in Object(t))We.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Ne(t){return de(t)?Ee(t):Be(t)}var De=Object.prototype.hasOwnProperty,Ge=le(function(t,e){if(fe(e)||de(e))ie(e,Ne(e),t);else for(var n in e)De.call(e,n)&&re(t,n,e[n])});const Fe=Ge;var Xe=Object.prototype.hasOwnProperty;function Ue(t){if(!P(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=fe(t),n=[];for(var r in t)("constructor"!=r||!e&&Xe.call(t,r))&&n.push(r);return n}function Ye(t){return de(t)?Ee(t,!0):Ue(t)}var Ze=le(function(t,e){ie(e,Ye(e),t)});const qe=Ze;var $e=le(function(t,e,n,r){ie(e,Ye(e),t,r)});const He=$e;var Ke=le(function(t,e,n,r){ie(e,Ne(e),t,r)});const Je=Ke;var Qe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tn=/^\w*$/;function en(t,e){if(x(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!y(t))||(tn.test(t)||!Qe.test(t)||null!=e&&t in Object(e))}var nn=J(Object,"create");var rn=Object.prototype.hasOwnProperty;var on=Object.prototype.hasOwnProperty;function sn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function an(t,e){for(var n=t.length;n--;)if(ee(t[n][0],e))return n;return-1}sn.prototype.clear=function(){this.__data__=nn?nn(null):{},this.size=0},sn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},sn.prototype.get=function(t){var e=this.__data__;if(nn){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return rn.call(e,t)?e[t]:void 0},sn.prototype.has=function(t){var e=this.__data__;return nn?void 0!==e[t]:on.call(e,t)},sn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=nn&&void 0===e?"__lodash_hash_undefined__":e,this};var hn=Array.prototype.splice;function dn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}dn.prototype.clear=function(){this.__data__=[],this.size=0},dn.prototype.delete=function(t){var e=this.__data__,n=an(e,t);return!(n<0)&&(n==e.length-1?e.pop():hn.call(e,n,1),--this.size,!0)},dn.prototype.get=function(t){var e=this.__data__,n=an(e,t);return n<0?void 0:e[n][1]},dn.prototype.has=function(t){return an(this.__data__,t)>-1},dn.prototype.set=function(t,e){var n=this.__data__,r=an(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var un=J(s,"Map");function ln(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function cn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}cn.prototype.clear=function(){this.size=0,this.__data__={hash:new sn,map:new(un||dn),string:new sn}},cn.prototype.delete=function(t){var e=ln(this,t).delete(t);return this.size-=e?1:0,e},cn.prototype.get=function(t){return ln(this,t).get(t)},cn.prototype.has=function(t){return ln(this,t).has(t)},cn.prototype.set=function(t,e){var n=ln(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function fn(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(fn.Cache||cn),n}fn.Cache=cn;var gn,pn,yn,mn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,vn=/\\(\\)?/g,xn=(gn=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(mn,function(t,n,r,i){e.push(r?i.replace(vn,"$1"):n||t)}),e},pn=fn(gn,function(t){return 500===yn.size&&yn.clear(),t}),yn=pn.cache,pn);function wn(t){return null==t?"":S(t)}function bn(t,e){return x(t)?t:en(t,e)?[t]:xn(wn(t))}function Sn(t){if("string"==typeof t||y(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function _n(t,e){for(var n=0,r=(e=bn(e,t)).length;null!=t&&n<r;)t=t[Sn(e[n++])];return n&&n==r?t:void 0}function An(t,e,n){var r=null==t?void 0:_n(t,e);return void 0===r?n:r}function kn(t,e){for(var n=-1,r=e.length,i=Array(r),o=null==t;++n<r;)i[n]=o?void 0:An(t,e[n]);return i}function jn(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}var In=a?a.isConcatSpreadable:void 0;function Tn(t){return x(t)||we(t)||!!(In&&t&&t[In])}function Pn(t,e,n,r,i){var o=-1,s=t.length;for(n||(n=Tn),i||(i=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?Pn(a,e-1,n,r,i):jn(i,a):r||(i[i.length]=a)}return i}function Mn(t){return(null==t?0:t.length)?Pn(t,1):[]}function zn(t){return Vt(se(t,void 0,Mn),t+"")}const Vn=zn(kn);var Cn=Re(Object.getPrototypeOf,Object),On=Function.prototype,En=Object.prototype,Rn=On.toString,Ln=En.hasOwnProperty,Wn=Rn.call(Object);function Bn(t){if(!p(t)||"[object Object]"!=g(t))return!1;var e=Cn(t);if(null===e)return!0;var n=Ln.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Rn.call(n)==Wn}function Nn(t){if(!p(t))return!1;var e=g(t);return"[object Error]"==e||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!Bn(t)}var Dn=ae(function(t,e){try{return ot(t,void 0,e)}catch(n){return Nn(n)?n:new Error(n)}});const Gn=Dn;function Fn(t,e){var n;if("function"!=typeof e)throw new TypeError("Expected a function");return t=L(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=void 0),n}}var Xn=ae(function(t,e,n){var r=1;if(n.length){var i=Yt(n,Dt(Xn));r|=32}return Jt(t,r,e,n,i)});Xn.placeholder={};const Un=Xn;const Yn=zn(function(t,e){return Ct(e,function(e){e=Sn(e),te(t,e,Un(t[e],t))}),t});var Zn=ae(function(t,e,n){var r=3;if(n.length){var i=Yt(n,Dt(Zn));r|=32}return Jt(e,r,t,n,i)});Zn.placeholder={};const qn=Zn;function $n(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var o=Array(i);++r<i;)o[r]=t[r+e];return o}function Hn(t,e,n){var r=t.length;return n=void 0===n?r:n,!e&&n>=r?t:$n(t,e,n)}var Kn=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function Jn(t){return Kn.test(t)}var Qn="\\ud800-\\udfff",tr="["+Qn+"]",er="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",nr="\\ud83c[\\udffb-\\udfff]",rr="[^"+Qn+"]",ir="(?:\\ud83c[\\udde6-\\uddff]){2}",or="[\\ud800-\\udbff][\\udc00-\\udfff]",sr="(?:"+er+"|"+nr+")"+"?",ar="[\\ufe0e\\ufe0f]?",hr=ar+sr+("(?:\\u200d(?:"+[rr,ir,or].join("|")+")"+ar+sr+")*"),dr="(?:"+[rr+er+"?",er,ir,or,tr].join("|")+")",ur=RegExp(nr+"(?="+nr+")|"+dr+hr,"g");function lr(t){return Jn(t)?function(t){return t.match(ur)||[]}(t):function(t){return t.split("")}(t)}function cr(t){return function(e){var n=Jn(e=wn(e))?lr(e):void 0,r=n?n[0]:e.charAt(0),i=n?Hn(n,1).join(""):e.slice(1);return r[t]()+i}}const fr=cr("toUpperCase");function gr(t){return fr(wn(t).toLowerCase())}function pr(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function yr(t){return function(e){return null==t?void 0:t[e]}}const mr=yr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"});var vr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,xr=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");function wr(t){return(t=wn(t))&&t.replace(vr,mr).replace(xr,"")}var br=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;var Sr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;var _r="\\ud800-\\udfff",Ar="\\u2700-\\u27bf",kr="a-z\\xdf-\\xf6\\xf8-\\xff",jr="A-Z\\xc0-\\xd6\\xd8-\\xde",Ir="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Tr="["+Ir+"]",Pr="\\d+",Mr="["+Ar+"]",zr="["+kr+"]",Vr="[^"+_r+Ir+Pr+Ar+kr+jr+"]",Cr="(?:\\ud83c[\\udde6-\\uddff]){2}",Or="[\\ud800-\\udbff][\\udc00-\\udfff]",Er="["+jr+"]",Rr="(?:"+zr+"|"+Vr+")",Lr="(?:"+Er+"|"+Vr+")",Wr="(?:['’](?:d|ll|m|re|s|t|ve))?",Br="(?:['’](?:D|LL|M|RE|S|T|VE))?",Nr="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",Dr="[\\ufe0e\\ufe0f]?",Gr=Dr+Nr+("(?:\\u200d(?:"+["[^"+_r+"]",Cr,Or].join("|")+")"+Dr+Nr+")*"),Fr="(?:"+[Mr,Cr,Or].join("|")+")"+Gr,Xr=RegExp([Er+"?"+zr+"+"+Wr+"(?="+[Tr,Er,"$"].join("|")+")",Lr+"+"+Br+"(?="+[Tr,Er+Rr,"$"].join("|")+")",Er+"?"+Rr+"+"+Wr,Er+"+"+Br,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pr,Fr].join("|"),"g");function Ur(t,e,n){return t=wn(t),void 0===(e=n?void 0:e)?function(t){return Sr.test(t)}(t)?function(t){return t.match(Xr)||[]}(t):function(t){return t.match(br)||[]}(t):t.match(e)||[]}var Yr=RegExp("['’]","g");function Zr(t){return function(e){return pr(Ur(wr(e).replace(Yr,"")),t,"")}}var qr=Zr(function(t,e,n){return e=e.toLowerCase(),t+(n?gr(e):e)});const $r=qr;var Hr=s.isFinite,Kr=Math.min;function Jr(t){var e=Math[t];return function(t,n){if(t=O(t),(n=null==n?0:Kr(L(n),292))&&Hr(t)){var r=(wn(t)+"e").split("e");return+((r=(wn(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}const Qr=Jr("ceil");function ti(t){var e=bt(t);return e.__chain__=!0,e}var ei=Math.ceil,ni=Math.max;function ri(t,e,n){return t==t&&(void 0!==n&&(t=t<=n?t:n),void 0!==e&&(t=t>=e?t:e)),t}function ii(t){var e=this.__data__=new dn(t);this.size=e.size}function oi(t,e){return t&&ie(e,Ne(e),t)}ii.prototype.clear=function(){this.__data__=new dn,this.size=0},ii.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},ii.prototype.get=function(t){return this.__data__.get(t)},ii.prototype.has=function(t){return this.__data__.has(t)},ii.prototype.set=function(t,e){var n=this.__data__;if(n instanceof dn){var r=n.__data__;if(!un||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new cn(r)}return n.set(t,e),this.size=n.size,this};var si="object"==typeof t&&t&&!t.nodeType&&t,ai=si&&"object"==typeof module&&module&&!module.nodeType&&module,hi=ai&&ai.exports===si?s.Buffer:void 0,di=hi?hi.allocUnsafe:void 0;function ui(t,e){if(e)return t.slice();var n=t.length,r=di?di(n):new t.constructor(n);return t.copy(r),r}function li(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}function ci(){return[]}var fi=Object.prototype.propertyIsEnumerable,gi=Object.getOwnPropertySymbols,pi=gi?function(t){return null==t?[]:(t=Object(t),li(gi(t),function(e){return fi.call(t,e)}))}:ci;var yi=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)jn(e,pi(t)),t=Cn(t);return e}:ci;function mi(t,e,n){var r=e(t);return x(t)?r:jn(r,n(t))}function vi(t){return mi(t,Ne,pi)}function xi(t){return mi(t,Ye,yi)}var wi=J(s,"DataView"),bi=J(s,"Promise"),Si=J(s,"Set"),_i="[object Map]",Ai="[object Promise]",ki="[object Set]",ji="[object WeakMap]",Ii="[object DataView]",Ti=X(wi),Pi=X(un),Mi=X(bi),zi=X(Si),Vi=X(Q),Ci=g;(wi&&Ci(new wi(new ArrayBuffer(1)))!=Ii||un&&Ci(new un)!=_i||bi&&Ci(bi.resolve())!=Ai||Si&&Ci(new Si)!=ki||Q&&Ci(new Q)!=ji)&&(Ci=function(t){var e=g(t),n="[object Object]"==e?t.constructor:void 0,r=n?X(n):"";if(r)switch(r){case Ti:return Ii;case Pi:return _i;case Mi:return Ai;case zi:return ki;case Vi:return ji}return e});const Oi=Ci;var Ei=Object.prototype.hasOwnProperty;var Ri=s.Uint8Array;function Li(t){var e=new t.constructor(t.byteLength);return new Ri(e).set(new Ri(t)),e}var Wi=/\w*$/;var Bi=a?a.prototype:void 0,Ni=Bi?Bi.valueOf:void 0;function Di(t,e){var n=e?Li(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Gi(t,e,n){var r,i=t.constructor;switch(e){case"[object ArrayBuffer]":return Li(t);case"[object Boolean]":case"[object Date]":return new i(+t);case"[object DataView]":return function(t,e){var n=e?Li(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);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 Di(t,n);case"[object Map]":case"[object Set]":return new i;case"[object Number]":case"[object String]":return new i(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Wi.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return r=t,Ni?Object(Ni.call(r)):{}}}function Fi(t){return"function"!=typeof t.constructor||fe(t)?{}:rt(Cn(t))}var Xi=ze&&ze.isMap;const Ui=Xi?Ie(Xi):function(t){return p(t)&&"[object Map]"==Oi(t)};var Yi=ze&&ze.isSet;const Zi=Yi?Ie(Yi):function(t){return p(t)&&"[object Set]"==Oi(t)};var qi="[object Arguments]",$i="[object Function]",Hi="[object Object]",Ki={};function Ji(t,e,n,r,i,o){var s,a=1&e,h=2&e,d=4&e;if(n&&(s=i?n(t,r,i,o):n(t)),void 0!==s)return s;if(!P(t))return t;var u=x(t);if(u){if(s=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&Ei.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!a)return vt(t,s)}else{var l=Oi(t),c=l==$i||"[object GeneratorFunction]"==l;if(ke(t))return ui(t,a);if(l==Hi||l==qi||c&&!i){if(s=h||c?{}:Fi(t),!a)return h?function(t,e){return ie(t,yi(t),e)}(t,function(t,e){return t&&ie(e,Ye(e),t)}(s,t)):function(t,e){return ie(t,pi(t),e)}(t,oi(s,t))}else{if(!Ki[l])return i?t:{};s=Gi(t,l,a)}}o||(o=new ii);var f=o.get(t);if(f)return f;o.set(t,s),Zi(t)?t.forEach(function(r){s.add(Ji(r,e,n,r,t,o))}):Ui(t)&&t.forEach(function(r,i){s.set(i,Ji(r,e,n,i,t,o))});var g=u?void 0:(d?h?xi:vi:h?Ye:Ne)(t);return Ct(g||t,function(r,i){g&&(r=t[i=r]),re(s,i,Ji(r,e,n,i,t,o))}),s}Ki[qi]=Ki["[object Array]"]=Ki["[object ArrayBuffer]"]=Ki["[object DataView]"]=Ki["[object Boolean]"]=Ki["[object Date]"]=Ki["[object Float32Array]"]=Ki["[object Float64Array]"]=Ki["[object Int8Array]"]=Ki["[object Int16Array]"]=Ki["[object Int32Array]"]=Ki["[object Map]"]=Ki["[object Number]"]=Ki[Hi]=Ki["[object RegExp]"]=Ki["[object Set]"]=Ki["[object String]"]=Ki["[object Symbol]"]=Ki["[object Uint8Array]"]=Ki["[object Uint8ClampedArray]"]=Ki["[object Uint16Array]"]=Ki["[object Uint32Array]"]=!0,Ki["[object Error]"]=Ki[$i]=Ki["[object WeakMap]"]=!1;function Qi(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new cn;++e<n;)this.add(t[e])}function to(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function eo(t,e){return t.has(e)}Qi.prototype.add=Qi.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Qi.prototype.has=function(t){return this.__data__.has(t)};function no(t,e,n,r,i,o){var s=1&n,a=t.length,h=e.length;if(a!=h&&!(s&&h>a))return!1;var d=o.get(t),u=o.get(e);if(d&&u)return d==e&&u==t;var l=-1,c=!0,f=2&n?new Qi:void 0;for(o.set(t,e),o.set(e,t);++l<a;){var g=t[l],p=e[l];if(r)var y=s?r(p,g,l,e,t,o):r(g,p,l,t,e,o);if(void 0!==y){if(y)continue;c=!1;break}if(f){if(!to(e,function(t,e){if(!eo(f,e)&&(g===t||i(g,t,n,r,o)))return f.push(e)})){c=!1;break}}else if(g!==p&&!i(g,p,n,r,o)){c=!1;break}}return o.delete(t),o.delete(e),c}function ro(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function io(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var oo=a?a.prototype:void 0,so=oo?oo.valueOf:void 0;var ao=Object.prototype.hasOwnProperty;var ho="[object Arguments]",uo="[object Array]",lo="[object Object]",co=Object.prototype.hasOwnProperty;function fo(t,e,n,r,i,o){var s=x(t),a=x(e),h=s?uo:Oi(t),d=a?uo:Oi(e),u=(h=h==ho?lo:h)==lo,l=(d=d==ho?lo:d)==lo,c=h==d;if(c&&ke(t)){if(!ke(e))return!1;s=!0,u=!1}if(c&&!u)return o||(o=new ii),s||Ce(t)?no(t,e,n,r,i,o):function(t,e,n,r,i,o,s){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Ri(t),new Ri(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ee(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=ro;case"[object Set]":var h=1&r;if(a||(a=io),t.size!=e.size&&!h)return!1;var d=s.get(t);if(d)return d==e;r|=2,s.set(t,e);var u=no(a(t),a(e),r,i,o,s);return s.delete(t),u;case"[object Symbol]":if(so)return so.call(t)==so.call(e)}return!1}(t,e,h,n,r,i,o);if(!(1&n)){var f=u&&co.call(t,"__wrapped__"),g=l&&co.call(e,"__wrapped__");if(f||g){var p=f?t.value():t,y=g?e.value():e;return o||(o=new ii),i(p,y,n,r,o)}}return!!c&&(o||(o=new ii),function(t,e,n,r,i,o){var s=1&n,a=vi(t),h=a.length;if(h!=vi(e).length&&!s)return!1;for(var d=h;d--;){var u=a[d];if(!(s?u in e:ao.call(e,u)))return!1}var l=o.get(t),c=o.get(e);if(l&&c)return l==e&&c==t;var f=!0;o.set(t,e),o.set(e,t);for(var g=s;++d<h;){var p=t[u=a[d]],y=e[u];if(r)var m=s?r(y,p,u,e,t,o):r(p,y,u,t,e,o);if(!(void 0===m?p===y||i(p,y,n,r,o):m)){f=!1;break}g||(g="constructor"==u)}if(f&&!g){var v=t.constructor,x=e.constructor;v==x||!("constructor"in t)||!("constructor"in e)||"function"==typeof v&&v instanceof v&&"function"==typeof x&&x instanceof x||(f=!1)}return o.delete(t),o.delete(e),f}(t,e,n,r,i,o))}function go(t,e,n,r,i){return t===e||(null==t||null==e||!p(t)&&!p(e)?t!=t&&e!=e:fo(t,e,n,r,go,i))}function po(t,e,n,r){var i=n.length,o=i,s=!r;if(null==t)return!o;for(t=Object(t);i--;){var a=n[i];if(s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++i<o;){var h=(a=n[i])[0],d=t[h],u=a[1];if(s&&a[2]){if(void 0===d&&!(h in t))return!1}else{var l=new ii;if(r)var c=r(d,u,h,t,e,l);if(!(void 0===c?go(u,d,3,r,l):c))return!1}}return!0}function yo(t){return t==t&&!P(t)}function mo(t){for(var e=Ne(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,yo(i)]}return e}function vo(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}function xo(t){var e=mo(t);return 1==e.length&&e[0][2]?vo(e[0][0],e[0][1]):function(n){return n===t||po(n,t,e)}}function wo(t,e){return null!=t&&e in Object(t)}function bo(t,e,n){for(var r=-1,i=(e=bn(e,t)).length,o=!1;++r<i;){var s=Sn(e[r]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++r!=i?o:!!(i=null==t?0:t.length)&&he(i)&&Ft(s,i)&&(x(t)||we(t))}function So(t,e){return null!=t&&bo(t,e,wo)}function _o(t,e){return en(t)&&yo(e)?vo(Sn(t),e):function(n){var r=An(n,t);return void 0===r&&r===e?So(n,t):go(e,r,3)}}function Ao(t){return function(e){return null==e?void 0:e[t]}}function ko(t){return en(t)?Ao(Sn(t)):function(t){return function(e){return _n(e,t)}}(t)}function jo(t){return"function"==typeof t?t:null==t?W:"object"==typeof t?x(t)?_o(t[0],t[1]):xo(t):ko(t)}function Io(t,e,n){var r=n.length;if(null==t)return!r;for(t=Object(t);r--;){var i=n[r],o=e[i],s=t[i];if(void 0===s&&!(i in t)||!o(s))return!1}return!0}function To(t,e,n,r){for(var i=-1,o=null==t?0:t.length;++i<o;){var s=t[i];e(r,s,n(s),t)}return r}function Po(t){return function(e,n,r){for(var i=-1,o=Object(e),s=r(e),a=s.length;a--;){var h=s[t?a:++i];if(!1===n(o[h],h,o))break}return e}}var Mo=Po();function zo(t,e){return t&&Mo(t,e,Ne)}function Vo(t,e){return function(n,r){if(null==n)return n;if(!de(n))return t(n,r);for(var i=n.length,o=e?i:-1,s=Object(n);(e?o--:++o<i)&&!1!==r(s[o],o,s););return n}}var Co=Vo(zo);function Oo(t,e,n,r){return Co(t,function(t,i,o){e(r,t,n(t),o)}),r}function Eo(t,e){return function(n,r){var i=x(n)?To:Oo,o=e?e():{};return i(n,t,jo(r),o)}}var Ro=Object.prototype.hasOwnProperty,Lo=Eo(function(t,e,n){Ro.call(t,n)?++t[n]:te(t,n,1)});const Wo=Lo;function Bo(t,e,n){var r=Jt(t,8,void 0,void 0,void 0,void 0,void 0,e=n?void 0:e);return r.placeholder=Bo.placeholder,r}Bo.placeholder={};function No(t,e,n){var r=Jt(t,16,void 0,void 0,void 0,void 0,void 0,e=n?void 0:e);return r.placeholder=No.placeholder,r}No.placeholder={};const Do=function(){return s.Date.now()};var Go=Math.max,Fo=Math.min;function Xo(t,e,n){var r,i,o,s,a,h,d=0,u=!1,l=!1,c=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function f(e){var n=r,o=i;return r=i=void 0,d=e,s=t.apply(o,n)}function g(t){var n=t-h;return void 0===h||n>=e||n<0||l&&t-d>=o}function p(){var t=Do();if(g(t))return y(t);a=setTimeout(p,function(t){var n=e-(t-h);return l?Fo(n,o-(t-d)):n}(t))}function y(t){return a=void 0,c&&r?f(t):(r=i=void 0,s)}function m(){var t=Do(),n=g(t);if(r=arguments,i=this,h=t,n){if(void 0===a)return function(t){return d=t,a=setTimeout(p,e),u?f(t):s}(h);if(l)return clearTimeout(a),a=setTimeout(p,e),f(h)}return void 0===a&&(a=setTimeout(p,e)),s}return e=O(e)||0,P(n)&&(u=!!n.leading,o=(l="maxWait"in n)?Go(O(n.maxWait)||0,e):o,c="trailing"in n?!!n.trailing:c),m.cancel=function(){void 0!==a&&clearTimeout(a),d=0,r=h=i=a=void 0},m.flush=function(){return void 0===a?s:y(Do())},m}var Uo=Object.prototype,Yo=Uo.hasOwnProperty,Zo=ae(function(t,e){t=Object(t);var n=-1,r=e.length,i=r>2?e[2]:void 0;for(i&&ue(e[0],e[1],i)&&(r=1);++n<r;)for(var o=e[n],s=Ye(o),a=-1,h=s.length;++a<h;){var d=s[a],u=t[d];(void 0===u||ee(u,Uo[d])&&!Yo.call(t,d))&&(t[d]=o[d])}return t});const qo=Zo;function $o(t,e,n){(void 0!==n&&!ee(t[e],n)||void 0===n&&!(e in t))&&te(t,e,n)}function Ho(t){return p(t)&&de(t)}function Ko(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Jo(t){return ie(t,Ye(t))}function Qo(t,e,n,r,i){t!==e&&Mo(e,function(o,s){if(i||(i=new ii),P(o))!function(t,e,n,r,i,o,s){var a=Ko(t,n),h=Ko(e,n),d=s.get(h);if(d)$o(t,n,d);else{var u=o?o(a,h,n+"",t,e,s):void 0,l=void 0===u;if(l){var c=x(h),f=!c&&ke(h),g=!c&&!f&&Ce(h);u=h,c||f||g?x(a)?u=a:Ho(a)?u=vt(a):f?(l=!1,u=ui(h,!0)):g?(l=!1,u=Di(h,!0)):u=[]:Bn(h)||we(h)?(u=a,we(a)?u=Jo(a):P(a)&&!B(a)||(u=Fi(h))):l=!1}l&&(s.set(h,u),i(u,h,r,o,s),s.delete(h)),$o(t,n,u)}}(t,e,s,n,Qo,r,i);else{var a=r?r(Ko(t,s),o,s+"",t,e,i):void 0;void 0===a&&(a=o),$o(t,s,a)}},Ye)}function ts(t,e,n,r,i,o){return P(t)&&P(e)&&(o.set(e,t),Qo(t,e,void 0,ts,o),o.delete(e)),t}var es=le(function(t,e,n,r){Qo(t,e,n,r)});const ns=es;const rs=ae(function(t){return t.push(void 0,ts),ot(ns,void 0,t)});function is(t,e,n){if("function"!=typeof t)throw new TypeError("Expected a function");return setTimeout(function(){t.apply(void 0,n)},e)}var os=ae(function(t,e){return is(t,1,e)});const ss=os;var as=ae(function(t,e,n){return is(t,O(e)||0,n)});const hs=as;function ds(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}function us(t,e,n,r){var i=-1,o=Lt,s=!0,a=t.length,h=[],d=e.length;if(!a)return h;n&&(e=v(e,Ie(n))),r?(o=ds,s=!1):e.length>=200&&(o=eo,s=!1,e=new Qi(e));t:for(;++i<a;){var u=t[i],l=null==n?u:n(u);if(u=r||0!==u?u:0,s&&l==l){for(var c=d;c--;)if(e[c]===l)continue t;h.push(u)}else o(e,l,r)||h.push(u)}return h}const ls=ae(function(t,e){return Ho(t)?us(t,Pn(e,1,Ho,!0)):[]});function cs(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}const fs=ae(function(t,e){var n=cs(e);return Ho(n)&&(n=void 0),Ho(t)?us(t,Pn(e,1,Ho,!0),jo(n)):[]});const gs=ae(function(t,e){var n=cs(e);return Ho(n)&&(n=void 0),Ho(t)?us(t,Pn(e,1,Ho,!0),void 0,n):[]});const ps=_(function(t,e){return t/e},1);function ys(t,e,n,r){for(var i=t.length,o=r?i:-1;(r?o--:++o<i)&&e(t[o],o,t););return n?$n(t,r?0:o,r?o+1:i):$n(t,r?o+1:0,r?i:o)}function ms(t){return"function"==typeof t?t:W}function vs(t,e){return(x(t)?Ct:Co)(t,ms(e))}function xs(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}var ws=Po(!0);function bs(t,e){return t&&ws(t,e,Ne)}const Ss=Vo(bs,!0);function _s(t,e){return(x(t)?xs:Ss)(t,ms(e))}function As(t){return function(e){var n=Oi(e);return"[object Map]"==n?ro(e):"[object Set]"==n?function(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=[t,t]}),n}(e):function(t,e){return v(e,function(e){return[e,t[e]]})}(e,t(e))}}const ks=As(Ne);const js=As(Ye);const Is=yr({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});var Ts=/[&<>"']/g,Ps=RegExp(Ts.source);function Ms(t){return(t=wn(t))&&Ps.test(t)?t.replace(Ts,Is):t}var zs=/[\\^$.*+?()[\]{}|]/g,Vs=RegExp(zs.source);function Cs(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function Os(t,e){var n=!0;return Co(t,function(t,r,i){return n=!!e(t,r,i)}),n}function Es(t){return t?ri(L(t),0,4294967295):0}function Rs(t,e){var n=[];return Co(t,function(t,r,i){e(t,r,i)&&n.push(t)}),n}function Ls(t){return function(e,n,r){var i=Object(e);if(!de(e)){var o=jo(n);e=Ne(e),n=function(t){return o(i[t],t,i)}}var s=t(e,n,r);return s>-1?i[o?e[s]:s]:void 0}}var Ws=Math.max;function Bs(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:L(n);return i<0&&(i=Ws(r+i,0)),Ot(t,jo(e),i)}const Ns=Ls(Bs);function Ds(t,e,n){var r;return n(t,function(t,n,i){if(e(t,n,i))return r=n,!1}),r}var Gs=Math.max,Fs=Math.min;function Xs(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r-1;return void 0!==n&&(i=L(n),i=n<0?Gs(r+i,0):Fs(i,r-1)),Ot(t,jo(e),i,!0)}const Us=Ls(Xs);function Ys(t){return t&&t.length?t[0]:void 0}function Zs(t,e){var n=-1,r=de(t)?Array(t.length):[];return Co(t,function(t,i,o){r[++n]=e(t,i,o)}),r}function qs(t,e){return(x(t)?v:Zs)(t,jo(e))}var $s=1/0;var Hs=1/0;const Ks=Jr("floor");function Js(t){return zn(function(e){var n=e.length,r=n,i=mt.prototype.thru;for(t&&e.reverse();r--;){var o=e[r];if("function"!=typeof o)throw new TypeError("Expected a function");if(i&&!s&&"wrapper"==yt(o))var s=new mt([],!0)}for(r=s?r:n;++r<n;){var a=yt(o=e[r]),h="wrapper"==a?ft(o):void 0;s=h&&St(h[0])&&424==h[1]&&!h[4].length&&1==h[9]?s[yt(h[0])].apply(s,h[3]):1==o.length&&St(o)?s[a]():s.thru(o)}return function(){var t=arguments,r=t[0];if(s&&1==t.length&&x(r))return s.plant(r).value();for(var i=0,o=n?e[i].apply(this,t):r;++i<n;)o=e[i].call(this,o);return o}})}const Qs=Js();const ta=Js(!0);function ea(t,e){return li(e,function(e){return B(t[e])})}var na=Object.prototype.hasOwnProperty,ra=Eo(function(t,e,n){na.call(t,n)?t[n].push(e):te(t,n,[e])});const ia=ra;function oa(t,e){return t>e}function sa(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=O(e),n=O(n)),t(e,n)}}const aa=sa(oa);const ha=sa(function(t,e){return t>=e});var da=Object.prototype.hasOwnProperty;function ua(t,e){return null!=t&&da.call(t,e)}var la=Math.max,ca=Math.min;function fa(t){return"string"==typeof t||!x(t)&&p(t)&&"[object String]"==g(t)}function ga(t,e){return v(e,function(e){return t[e]})}function pa(t){return null==t?[]:ga(t,Ne(t))}var ya=Math.max;var ma=Math.max;var va=Math.min;function xa(t,e,n){for(var r=n?ds:Lt,i=t[0].length,o=t.length,s=o,a=Array(o),h=1/0,d=[];s--;){var u=t[s];s&&e&&(u=v(u,Ie(e))),h=va(u.length,h),a[s]=!n&&(e||i>=120&&u.length>=120)?new Qi(s&&u):void 0}u=t[0];var l=-1,c=a[0];t:for(;++l<i&&d.length<h;){var f=u[l],g=e?e(f):f;if(f=n||0!==f?f:0,!(c?eo(c,g):r(d,g,n))){for(s=o;--s;){var p=a[s];if(!(p?eo(p,g):r(t[s],g,n)))continue t}c&&c.push(g),d.push(f)}}return d}function wa(t){return Ho(t)?t:[]}const ba=ae(function(t){var e=v(t,wa);return e.length&&e[0]===t[0]?xa(e):[]});const Sa=ae(function(t){var e=cs(t),n=v(t,wa);return e===cs(n)?e=void 0:n.pop(),n.length&&n[0]===t[0]?xa(n,jo(e)):[]});const _a=ae(function(t){var e=cs(t),n=v(t,wa);return(e="function"==typeof e?e:void 0)&&n.pop(),n.length&&n[0]===t[0]?xa(n,void 0,e):[]});function Aa(t,e){return function(n,r){return function(t,e,n,r){return zo(t,function(t,i,o){e(r,n(t),i,o)}),r}(n,t,e(r),{})}}var ka=Object.prototype.toString,ja=Aa(function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=ka.call(e)),t[e]=n},Pt(W));const Ia=ja;var Ta=Object.prototype,Pa=Ta.hasOwnProperty,Ma=Ta.toString,za=Aa(function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=Ma.call(e)),Pa.call(t,e)?t[e].push(n):t[e]=[n]},jo);const Va=za;function Ca(t,e){return e.length<2?t:_n(t,$n(e,0,-1))}function Oa(t,e,n){var r=null==(t=Ca(t,e=bn(e,t)))?t:t[Sn(cs(e))];return null==r?void 0:ot(r,t,n)}const Ea=ae(Oa);var Ra=ae(function(t,e,n){var r=-1,i="function"==typeof e,o=de(t)?Array(t.length):[];return Co(t,function(t){o[++r]=i?ot(e,t,n):Oa(t,e,n)}),o});const La=Ra;var Wa=ze&&ze.isArrayBuffer;const Ba=Wa?Ie(Wa):function(t){return p(t)&&"[object ArrayBuffer]"==g(t)};var Na=ze&&ze.isDate;const Da=Na?Ie(Na):function(t){return p(t)&&"[object Date]"==g(t)};var Ga=Object.prototype.hasOwnProperty;var Fa=s.isFinite;function Xa(t){return"number"==typeof t&&t==L(t)}function Ua(t){return"number"==typeof t||p(t)&&"[object Number]"==g(t)}var Ya=D?B:be;var Za=ze&&ze.isRegExp;const qa=Za?Ie(Za):function(t){return p(t)&&"[object RegExp]"==g(t)};var $a=9007199254740991;var Ha=Array.prototype.join;var Ka=Zr(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()});const Ja=Ka;var Qa=Eo(function(t,e,n){te(t,n,e)});const th=Qa;var eh=Math.max,nh=Math.min;var rh=Zr(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()});const ih=rh;const oh=cr("toLowerCase");function sh(t,e){return t<e}const ah=sa(sh);const hh=sa(function(t,e){return t<=e});function dh(t,e,n){for(var r=-1,i=t.length;++r<i;){var o=t[r],s=e(o);if(null!=s&&(void 0===a?s==s&&!y(s):n(s,a)))var a=s,h=o}return h}function uh(t,e){for(var n,r=-1,i=t.length;++r<i;){var o=e(t[r]);void 0!==o&&(n=void 0===n?o:n+o)}return n}function lh(t,e){var n=null==t?0:t.length;return n?uh(t,e)/n:NaN}var ch=le(function(t,e,n){Qo(t,e,n)});const fh=ch;const gh=ae(function(t,e){return function(n){return Oa(n,t,e)}});const ph=ae(function(t,e){return function(n){return Oa(t,n,e)}});function yh(t,e,n){var r=Ne(e),i=ea(e,r),o=!(P(n)&&"chain"in n&&!n.chain),s=B(t);return Ct(i,function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(o||e){var n=t(this.__wrapped__);return(n.__actions__=vt(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,jn([this.value()],arguments))})}),t}const mh=_(function(t,e){return t*e},1);function vh(t){if("function"!=typeof t)throw new TypeError("Expected a function");return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}var xh=a?a.iterator:void 0;function wh(t){if(!t)return[];if(de(t))return fa(t)?lr(t):vt(t);if(xh&&t[xh])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[xh]());var e=Oi(t);return("[object Map]"==e?ro:"[object Set]"==e?io:pa)(t)}function bh(t,e){var n=t.length;if(n)return Ft(e+=e<0?n:0,n)?t[e]:void 0}function Sh(t,e){return null==(t=Ca(t,e=bn(e,t)))||delete t[Sn(cs(e))]}function _h(t){return Bn(t)?void 0:t}var Ah=zn(function(t,e){var n={};if(null==t)return n;var r=!1;e=v(e,function(e){return e=bn(e,t),r||(r=e.length>1),e}),ie(t,xi(t),n),r&&(n=Ji(n,7,_h));for(var i=e.length;i--;)Sh(n,e[i]);return n});const kh=Ah;function jh(t,e,n,r){if(!P(t))return t;for(var i=-1,o=(e=bn(e,t)).length,s=o-1,a=t;null!=a&&++i<o;){var h=Sn(e[i]),d=n;if("__proto__"===h||"constructor"===h||"prototype"===h)return t;if(i!=s){var u=a[h];void 0===(d=r?r(u,h,a):void 0)&&(d=P(u)?u:Ft(e[i+1])?[]:{})}re(a,h,d),a=a[h]}return t}function Ih(t,e,n){for(var r=-1,i=e.length,o={};++r<i;){var s=e[r],a=_n(t,s);n(a,s)&&jh(o,bn(s,t),a)}return o}function Th(t,e){if(null==t)return{};var n=v(xi(t),function(t){return[t]});return e=jo(e),Ih(t,n,function(t,n){return e(t,n[0])})}function Ph(t,e){if(t!==e){var n=void 0!==t,r=null===t,i=t==t,o=y(t),s=void 0!==e,a=null===e,h=e==e,d=y(e);if(!a&&!d&&!o&&t>e||o&&s&&h&&!a&&!d||r&&s&&h||!n&&h||!i)return 1;if(!r&&!o&&!d&&t<e||d&&n&&i&&!r&&!o||a&&n&&i||!s&&i||!h)return-1}return 0}function Mh(t,e,n){e=e.length?v(e,function(t){return x(t)?function(e){return _n(e,1===t.length?t[0]:t)}:t}):[W];var r=-1;return e=v(e,Ie(jo)),function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}(Zs(t,function(t,n,i){return{criteria:v(e,function(e){return e(t)}),index:++r,value:t}}),function(t,e){return function(t,e,n){for(var r=-1,i=t.criteria,o=e.criteria,s=i.length,a=n.length;++r<s;){var h=Ph(i[r],o[r]);if(h)return r>=a?h:h*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)})}function zh(t){return zn(function(e){return e=v(e,Ie(jo)),ae(function(n){var r=this;return t(e,function(t){return ot(t,r,n)})})})}const Vh=zh(v);var Ch=ae,Oh=Math.min,Eh=Ch(function(t,e){var n=(e=1==e.length&&x(e[0])?v(e[0],Ie(jo)):v(Pn(e,1),Ie(jo))).length;return ae(function(r){for(var i=-1,o=Oh(r.length,n);++i<o;)r[i]=e[i].call(this,r[i]);return ot(t,this,r)})});const Rh=Eh;const Lh=zh(Cs);const Wh=zh(to);var Bh=Math.floor;function Nh(t,e){var n="";if(!t||e<1||e>9007199254740991)return n;do{e%2&&(n+=t),(e=Bh(e/2))&&(t+=t)}while(e);return n}var Dh=Ao("length"),Gh="\\ud800-\\udfff",Fh="["+Gh+"]",Xh="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Uh="\\ud83c[\\udffb-\\udfff]",Yh="[^"+Gh+"]",Zh="(?:\\ud83c[\\udde6-\\uddff]){2}",qh="[\\ud800-\\udbff][\\udc00-\\udfff]",$h="(?:"+Xh+"|"+Uh+")"+"?",Hh="[\\ufe0e\\ufe0f]?",Kh=Hh+$h+("(?:\\u200d(?:"+[Yh,Zh,qh].join("|")+")"+Hh+$h+")*"),Jh="(?:"+[Yh+Xh+"?",Xh,Zh,qh,Fh].join("|")+")",Qh=RegExp(Uh+"(?="+Uh+")|"+Jh+Kh,"g");function td(t){return Jn(t)?function(t){for(var e=Qh.lastIndex=0;Qh.test(t);)++e;return e}(t):Dh(t)}var ed=Math.ceil;function nd(t,e){var n=(e=void 0===e?" ":S(e)).length;if(n<2)return n?Nh(e,t):e;var r=Nh(e,ed(t/td(e)));return Jn(e)?Hn(lr(r),0,t).join(""):r.slice(0,t)}var rd=Math.ceil,id=Math.floor;var od=/^\s+/,sd=s.parseInt;var ad=ae(function(t,e){return Jt(t,32,void 0,e,Yt(e,Dt(ad)))});ad.placeholder={};const hd=ad;var dd=ae(function(t,e){return Jt(t,64,void 0,e,Yt(e,Dt(dd)))});dd.placeholder={};const ud=dd;var ld=Eo(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});const cd=ld;const fd=zn(function(t,e){return null==t?{}:function(t,e){return Ih(t,e,function(e,n){return So(t,n)})}(t,e)});function gd(t,e,n,r){for(var i=n-1,o=t.length;++i<o;)if(r(t[i],e))return i;return-1}var pd=Array.prototype.splice;function yd(t,e,n,r){var i=r?gd:Rt,o=-1,s=e.length,a=t;for(t===e&&(e=vt(e)),n&&(a=v(t,Ie(n)));++o<s;)for(var h=0,d=e[o],u=n?n(d):d;(h=i(a,u,h,r))>-1;)a!==t&&pd.call(a,h,1),pd.call(t,h,1);return t}function md(t,e){return t&&t.length&&e&&e.length?yd(t,e):t}const vd=ae(md);var xd=Array.prototype.splice;function wd(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;Ft(i)?xd.call(t,i,1):Sh(t,i)}}return t}var bd=zn(function(t,e){var n=null==t?0:t.length,r=kn(t,e);return wd(t,v(e,function(t){return Ft(t,n)?+t:t}).sort(Ph)),r});const Sd=bd;var _d=Math.floor,Ad=Math.random;function kd(t,e){return t+_d(Ad()*(e-t+1))}var jd=parseFloat,Id=Math.min,Td=Math.random;var Pd=Math.ceil,Md=Math.max;function zd(t){return function(e,n,r){return r&&"number"!=typeof r&&ue(e,n,r)&&(n=r=void 0),e=R(e),void 0===n?(n=e,e=0):n=R(n),function(t,e,n,r){for(var i=-1,o=Md(Pd((e-t)/(n||1)),0),s=Array(o);o--;)s[r?o:++i]=t,t+=n;return s}(e,n,r=void 0===r?e<n?1:-1:R(r),t)}}const Vd=zd();const Cd=zd(!0);var Od=zn(function(t,e){return Jt(t,256,void 0,void 0,void 0,e)});const Ed=Od;function Rd(t,e,n,r,i){return i(t,function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)}),n}function Ld(t,e,n,r){var i=null==t?0:t.length;for(r&&i&&(n=t[--i]);i--;)n=e(n,t[i],i,t);return n}var Wd=Array.prototype.reverse;function Bd(t){return null==t?t:Wd.call(t)}const Nd=Jr("round");function Dd(t){var e=t.length;return e?t[kd(0,e-1)]:void 0}function Gd(t){return Dd(pa(t))}function Fd(t,e){var n=-1,r=t.length,i=r-1;for(e=void 0===e?r:e;++n<e;){var o=kd(n,i),s=t[o];t[o]=t[n],t[n]=s}return t.length=e,t}function Xd(t,e){return Fd(vt(t),ri(e,0,t.length))}function Ud(t,e){var n=pa(t);return Fd(n,ri(e,0,n.length))}function Yd(t){return Fd(vt(t))}function Zd(t){return Fd(pa(t))}var qd=Zr(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()});const $d=qd;function Hd(t,e){var n;return Co(t,function(t,r,i){return!(n=e(t,r,i))}),!!n}const Kd=ae(function(t,e){if(null==t)return[];var n=e.length;return n>1&&ue(t,e[0],e[1])?e=[]:n>2&&ue(e[0],e[1],e[2])&&(e=[e[0]]),Mh(t,Pn(e,1),[])});var Jd=Math.floor,Qd=Math.min;function tu(t,e,n,r){var i=0,o=null==t?0:t.length;if(0===o)return 0;for(var s=(e=n(e))!=e,a=null===e,h=y(e),d=void 0===e;i<o;){var u=Jd((i+o)/2),l=n(t[u]),c=void 0!==l,f=null===l,g=l==l,p=y(l);if(s)var m=r||g;else m=d?g&&(r||c):a?g&&c&&(r||!f):h?g&&c&&!f&&(r||!p):!f&&!p&&(r?l<=e:l<e);m?i=u+1:o=u}return Qd(o,4294967294)}function eu(t,e,n){var r=0,i=null==t?r:t.length;if("number"==typeof e&&e==e&&i<=2147483647){for(;r<i;){var o=r+i>>>1,s=t[o];null!==s&&!y(s)&&(n?s<=e:s<e)?r=o+1:i=o}return i}return tu(t,e,W,n)}function nu(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!ee(a,h)){var h=a;o[i++]=0===s?0:s}}return o}var ru=Math.max;var iu=Zr(function(t,e,n){return t+(n?" ":"")+fr(e)});const ou=iu;const su=_(function(t,e){return t-e},0);var au=Object.prototype,hu=au.hasOwnProperty;function du(t,e,n,r){return void 0===t||ee(t,au[n])&&!hu.call(r,n)?e:t}var uu={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"};function lu(t){return"\\"+uu[t]}const cu=/<%=([\s\S]+?)%>/g;const fu={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:cu,variable:"",imports:{_:{escape:Ms}}};var gu=/\b__p \+= '';/g,pu=/\b(__p \+=) '' \+/g,yu=/(__e\(.*?\)|\b__t\)) \+\n'';/g,mu=/[()=,{}\[\]\/\s]/,vu=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,xu=/($^)/,wu=/['\n\r\u2028\u2029\\]/g,bu=Object.prototype.hasOwnProperty;function Su(t,e){return e(t)}var _u=4294967295,Au=Math.min;function ku(t,e){var n=t;return n instanceof lt&&(n=n.value()),pr(e,function(t,e){return e.func.apply(e.thisArg,jn([t],e.args))},n)}function ju(){return ku(this.__wrapped__,this.__actions__)}var Iu=9007199254740991;function Tu(t,e){for(var n=t.length;n--&&Rt(e,t[n],0)>-1;);return n}function Pu(t,e){for(var n=-1,r=t.length;++n<r&&Rt(e,t[n],0)>-1;);return n}var Mu=/^\s+/;var zu=/\w*$/;const Vu=yr({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var Cu=/&(?:amp|lt|gt|quot|#39);/g,Ou=RegExp(Cu.source);var Eu=Si&&1/io(new Si([,-0]))[1]==1/0?function(t){return new Si(t)}:ct;function Ru(t,e,n){var r=-1,i=Lt,o=t.length,s=!0,a=[],h=a;if(n)s=!1,i=ds;else if(o>=200){var d=e?null:Eu(t);if(d)return io(d);s=!1,i=eo,h=new Qi}else h=e?[]:a;t:for(;++r<o;){var u=t[r],l=e?e(u):u;if(u=n||0!==u?u:0,s&&l==l){for(var c=h.length;c--;)if(h[c]===l)continue t;e&&h.push(l),a.push(u)}else i(h,l,n)||(h!==a&&h.push(l),a.push(u))}return a}const Lu=ae(function(t){return Ru(Pn(t,1,Ho,!0))});const Wu=ae(function(t){var e=cs(t);return Ho(e)&&(e=void 0),Ru(Pn(t,1,Ho,!0),jo(e))});const Bu=ae(function(t){var e=cs(t);return e="function"==typeof e?e:void 0,Ru(Pn(t,1,Ho,!0),void 0,e)});var Nu=0;var Du=Math.max;function Gu(t){if(!t||!t.length)return[];var e=0;return t=li(t,function(t){if(Ho(t))return e=Du(t.length,e),!0}),ge(e,function(e){return v(t,Ao(e))})}function Fu(t,e){if(!t||!t.length)return[];var n=Gu(t);return null==e?n:v(n,function(t){return ot(e,void 0,t)})}function Xu(t,e,n,r){return jh(t,e,n(_n(t,e)),r)}var Uu=Zr(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()});const Yu=Uu;const Zu=ae(function(t,e){return Ho(t)?us(t,e):[]});const qu=zn(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,i=function(e){return kn(e,t)};return!(e>1||this.__actions__.length)&&r instanceof lt&&Ft(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:Su,args:[i],thisArg:void 0}),new mt(r,this.__chain__).thru(function(t){return e&&!t.length&&t.push(void 0),t})):this.thru(i)});function $u(t,e,n){var r=t.length;if(r<2)return r?Ru(t[0]):[];for(var i=-1,o=Array(r);++i<r;)for(var s=t[i],a=-1;++a<r;)a!=i&&(o[i]=us(o[i]||s,t[a],e,n));return Ru(Pn(o,1),e,n)}const Hu=ae(function(t){return $u(li(t,Ho))});const Ku=ae(function(t){var e=cs(t);return Ho(e)&&(e=void 0),$u(li(t,Ho),jo(e))});const Ju=ae(function(t){var e=cs(t);return e="function"==typeof e?e:void 0,$u(li(t,Ho),void 0,e)});const Qu=ae(Gu);function tl(t,e,n){for(var r=-1,i=t.length,o=e.length,s={};++r<i;){var a=r<o?e[r]:void 0;n(s,t[r],a)}return s}var el=ae(function(t){var e=t.length,n=e>1?t[e-1]:void 0;return n="function"==typeof n?(t.pop(),n):void 0,Fu(t,n)});const nl={chunk:function(t,e,n){e=(n?ue(t,e,n):void 0===e)?1:ni(L(e),0);var r=null==t?0:t.length;if(!r||e<1)return[];for(var i=0,o=0,s=Array(ei(r/e));i<r;)s[o++]=$n(t,i,i+=e);return s},compact:function(t){for(var e=-1,n=null==t?0:t.length,r=0,i=[];++e<n;){var o=t[e];o&&(i[r++]=o)}return i},concat:function(){var t=arguments.length;if(!t)return[];for(var e=Array(t-1),n=arguments[0],r=t;r--;)e[r-1]=arguments[r];return jn(x(n)?vt(n):[n],Pn(e,1))},difference:ls,differenceBy:fs,differenceWith:gs,drop:function(t,e,n){var r=null==t?0:t.length;return r?$n(t,(e=n||void 0===e?1:L(e))<0?0:e,r):[]},dropRight:function(t,e,n){var r=null==t?0:t.length;return r?$n(t,0,(e=r-(e=n||void 0===e?1:L(e)))<0?0:e):[]},dropRightWhile:function(t,e){return t&&t.length?ys(t,jo(e),!0,!0):[]},dropWhile:function(t,e){return t&&t.length?ys(t,jo(e),!0):[]},fill:function(t,e,n,r){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&ue(t,e,n)&&(n=0,r=i),function(t,e,n,r){var i=t.length;for((n=L(n))<0&&(n=-n>i?0:i+n),(r=void 0===r||r>i?i:L(r))<0&&(r+=i),r=n>r?0:Es(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},findIndex:Bs,findLastIndex:Xs,first:Ys,flatten:Mn,flattenDeep:function(t){return(null==t?0:t.length)?Pn(t,Hs):[]},flattenDepth:function(t,e){return(null==t?0:t.length)?Pn(t,e=void 0===e?1:L(e)):[]},fromPairs:function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var i=t[e];r[i[0]]=i[1]}return r},head:Ys,indexOf:function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:L(n);return i<0&&(i=ma(r+i,0)),Rt(t,e,i)},initial:function(t){return(null==t?0:t.length)?$n(t,0,-1):[]},intersection:ba,intersectionBy:Sa,intersectionWith:_a,join:function(t,e){return null==t?"":Ha.call(t,e)},last:cs,lastIndexOf:function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=r;return void 0!==n&&(i=(i=L(n))<0?eh(r+i,0):nh(i,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,i):Ot(t,Et,i,!0)},nth:function(t,e){return t&&t.length?bh(t,L(e)):void 0},pull:vd,pullAll:md,pullAllBy:function(t,e,n){return t&&t.length&&e&&e.length?yd(t,e,jo(n)):t},pullAllWith:function(t,e,n){return t&&t.length&&e&&e.length?yd(t,e,void 0,n):t},pullAt:Sd,remove:function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,i=[],o=t.length;for(e=jo(e);++r<o;){var s=t[r];e(s,r,t)&&(n.push(s),i.push(r))}return wd(t,i),n},reverse:Bd,slice:function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&ue(t,e,n)?(e=0,n=r):(e=null==e?0:L(e),n=void 0===n?r:L(n)),$n(t,e,n)):[]},sortedIndex:function(t,e){return eu(t,e)},sortedIndexBy:function(t,e,n){return tu(t,e,jo(n))},sortedIndexOf:function(t,e){var n=null==t?0:t.length;if(n){var r=eu(t,e);if(r<n&&ee(t[r],e))return r}return-1},sortedLastIndex:function(t,e){return eu(t,e,!0)},sortedLastIndexBy:function(t,e,n){return tu(t,e,jo(n),!0)},sortedLastIndexOf:function(t,e){if(null==t?0:t.length){var n=eu(t,e,!0)-1;if(ee(t[n],e))return n}return-1},sortedUniq:function(t){return t&&t.length?nu(t):[]},sortedUniqBy:function(t,e){return t&&t.length?nu(t,jo(e)):[]},tail:function(t){var e=null==t?0:t.length;return e?$n(t,1,e):[]},take:function(t,e,n){return t&&t.length?$n(t,0,(e=n||void 0===e?1:L(e))<0?0:e):[]},takeRight:function(t,e,n){var r=null==t?0:t.length;return r?$n(t,(e=r-(e=n||void 0===e?1:L(e)))<0?0:e,r):[]},takeRightWhile:function(t,e){return t&&t.length?ys(t,jo(e),!1,!0):[]},takeWhile:function(t,e){return t&&t.length?ys(t,jo(e)):[]},union:Lu,unionBy:Wu,unionWith:Bu,uniq:function(t){return t&&t.length?Ru(t):[]},uniqBy:function(t,e){return t&&t.length?Ru(t,jo(e)):[]},uniqWith:function(t,e){return e="function"==typeof e?e:void 0,t&&t.length?Ru(t,void 0,e):[]},unzip:Gu,unzipWith:Fu,without:Zu,xor:Hu,xorBy:Ku,xorWith:Ju,zip:Qu,zipObject:function(t,e){return tl(t||[],e||[],re)},zipObjectDeep:function(t,e){return tl(t||[],e||[],jh)},zipWith:el},rl={countBy:Wo,each:vs,eachRight:_s,every:function(t,e,n){var r=x(t)?Cs:Os;return n&&ue(t,e,n)&&(e=void 0),r(t,jo(e))},filter:function(t,e){return(x(t)?li:Rs)(t,jo(e))},find:Ns,findLast:Us,flatMap:function(t,e){return Pn(qs(t,e),1)},flatMapDeep:function(t,e){return Pn(qs(t,e),$s)},flatMapDepth:function(t,e,n){return n=void 0===n?1:L(n),Pn(qs(t,e),n)},forEach:vs,forEachRight:_s,groupBy:ia,includes:function(t,e,n,r){t=de(t)?t:pa(t),n=n&&!r?L(n):0;var i=t.length;return n<0&&(n=ya(i+n,0)),fa(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&Rt(t,e,n)>-1},invokeMap:La,keyBy:th,map:qs,orderBy:function(t,e,n,r){return null==t?[]:(x(e)||(e=null==e?[]:[e]),x(n=r?void 0:n)||(n=null==n?[]:[n]),Mh(t,e,n))},partition:cd,reduce:function(t,e,n){var r=x(t)?pr:Rd,i=arguments.length<3;return r(t,jo(e),n,i,Co)},reduceRight:function(t,e,n){var r=x(t)?Ld:Rd,i=arguments.length<3;return r(t,jo(e),n,i,Ss)},reject:function(t,e){return(x(t)?li:Rs)(t,vh(jo(e)))},sample:function(t){return(x(t)?Dd:Gd)(t)},sampleSize:function(t,e,n){return e=(n?ue(t,e,n):void 0===e)?1:L(e),(x(t)?Xd:Ud)(t,e)},shuffle:function(t){return(x(t)?Yd:Zd)(t)},size:function(t){if(null==t)return 0;if(de(t))return fa(t)?td(t):t.length;var e=Oi(t);return"[object Map]"==e||"[object Set]"==e?t.size:Be(t).length},some:function(t,e,n){var r=x(t)?to:Hd;return n&&ue(t,e,n)&&(e=void 0),r(t,jo(e))},sortBy:Kd},il={now:Do},ol={after:function(t,e){if("function"!=typeof e)throw new TypeError("Expected a function");return t=L(t),function(){if(--t<1)return e.apply(this,arguments)}},ary:Qt,before:Fn,bind:Un,bindKey:qn,curry:Bo,curryRight:No,debounce:Xo,defer:ss,delay:hs,flip:function(t){return Jt(t,512)},memoize:fn,negate:vh,once:function(t){return Fn(2,t)},overArgs:Rh,partial:hd,partialRight:ud,rearg:Ed,rest:function(t,e){if("function"!=typeof t)throw new TypeError("Expected a function");return ae(t,e=void 0===e?e:L(e))},spread:function(t,e){if("function"!=typeof t)throw new TypeError("Expected a function");return e=null==e?0:ru(L(e),0),ae(function(n){var r=n[e],i=Hn(n,0,e);return r&&jn(i,r),ot(t,this,i)})},throttle:function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return P(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Xo(t,e,{leading:r,maxWait:e,trailing:i})},unary:function(t){return Qt(t,1)},wrap:function(t,e){return hd(ms(e),t)}},sl={castArray:function(){if(!arguments.length)return[];var t=arguments[0];return x(t)?t:[t]},clone:function(t){return Ji(t,4)},cloneDeep:function(t){return Ji(t,5)},cloneDeepWith:function(t,e){return Ji(t,5,e="function"==typeof e?e:void 0)},cloneWith:function(t,e){return Ji(t,4,e="function"==typeof e?e:void 0)},conformsTo:function(t,e){return null==e||Io(t,e,Ne(e))},eq:ee,gt:aa,gte:ha,isArguments:we,isArray:x,isArrayBuffer:Ba,isArrayLike:de,isArrayLikeObject:Ho,isBoolean:function(t){return!0===t||!1===t||p(t)&&"[object Boolean]"==g(t)},isBuffer:ke,isDate:Da,isElement:function(t){return p(t)&&1===t.nodeType&&!Bn(t)},isEmpty:function(t){if(null==t)return!0;if(de(t)&&(x(t)||"string"==typeof t||"function"==typeof t.splice||ke(t)||Ce(t)||we(t)))return!t.length;var e=Oi(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(fe(t))return!Be(t).length;for(var n in t)if(Ga.call(t,n))return!1;return!0},isEqual:function(t,e){return go(t,e)},isEqualWith:function(t,e,n){var r=(n="function"==typeof n?n:void 0)?n(t,e):void 0;return void 0===r?go(t,e,void 0,n):!!r},isError:Nn,isFinite:function(t){return"number"==typeof t&&Fa(t)},isFunction:B,isInteger:Xa,isLength:he,isMap:Ui,isMatch:function(t,e){return t===e||po(t,e,mo(e))},isMatchWith:function(t,e,n){return n="function"==typeof n?n:void 0,po(t,e,mo(e),n)},isNaN:function(t){return Ua(t)&&t!=+t},isNative:function(t){if(Ya(t))throw new Error("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return K(t)},isNil:function(t){return null==t},isNull:function(t){return null===t},isNumber:Ua,isObject:P,isObjectLike:p,isPlainObject:Bn,isRegExp:qa,isSafeInteger:function(t){return Xa(t)&&t>=-9007199254740991&&t<=$a},isSet:Zi,isString:fa,isSymbol:y,isTypedArray:Ce,isUndefined:function(t){return void 0===t},isWeakMap:function(t){return p(t)&&"[object WeakMap]"==Oi(t)},isWeakSet:function(t){return p(t)&&"[object WeakSet]"==g(t)},lt:ah,lte:hh,toArray:wh,toFinite:R,toInteger:L,toLength:Es,toNumber:O,toPlainObject:Jo,toSafeInteger:function(t){return t?ri(L(t),-9007199254740991,Iu):0===t?t:0},toString:wn},al={add:A,ceil:Qr,divide:ps,floor:Ks,max:function(t){return t&&t.length?dh(t,W,oa):void 0},maxBy:function(t,e){return t&&t.length?dh(t,jo(e),oa):void 0},mean:function(t){return lh(t,W)},meanBy:function(t,e){return lh(t,jo(e))},min:function(t){return t&&t.length?dh(t,W,sh):void 0},minBy:function(t,e){return t&&t.length?dh(t,jo(e),sh):void 0},multiply:mh,round:Nd,subtract:su,sum:function(t){return t&&t.length?uh(t,W):0},sumBy:function(t,e){return t&&t.length?uh(t,jo(e)):0}},hl=function(t,e,n){return void 0===n&&(n=e,e=void 0),void 0!==n&&(n=(n=O(n))==n?n:0),void 0!==e&&(e=(e=O(e))==e?e:0),ri(O(t),e,n)},dl=function(t,e,n){return e=R(e),void 0===n?(n=e,e=0):n=R(n),function(t,e,n){return t>=ca(e,n)&&t<la(e,n)}(t=O(t),e,n)},ul=function(t,e,n){if(n&&"boolean"!=typeof n&&ue(t,e,n)&&(e=n=void 0),void 0===n&&("boolean"==typeof e?(n=e,e=void 0):"boolean"==typeof t&&(n=t,t=void 0)),void 0===t&&void 0===e?(t=0,e=1):(t=R(t),void 0===e?(e=t,t=0):e=R(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var i=Td();return Id(t+i*(e-t+jd("1e-"+((i+"").length-1))),e)}return kd(t,e)},ll={assign:Fe,assignIn:qe,assignInWith:He,assignWith:Je,at:Vn,create:function(t,e){var n=rt(t);return null==e?n:oi(n,e)},defaults:qo,defaultsDeep:rs,entries:ks,entriesIn:js,extend:qe,extendWith:He,findKey:function(t,e){return Ds(t,jo(e),zo)},findLastKey:function(t,e){return Ds(t,jo(e),bs)},forIn:function(t,e){return null==t?t:Mo(t,ms(e),Ye)},forInRight:function(t,e){return null==t?t:ws(t,ms(e),Ye)},forOwn:function(t,e){return t&&zo(t,ms(e))},forOwnRight:function(t,e){return t&&bs(t,ms(e))},functions:function(t){return null==t?[]:ea(t,Ne(t))},functionsIn:function(t){return null==t?[]:ea(t,Ye(t))},get:An,has:function(t,e){return null!=t&&bo(t,e,ua)},hasIn:So,invert:Ia,invertBy:Va,invoke:Ea,keys:Ne,keysIn:Ye,mapKeys:function(t,e){var n={};return e=jo(e),zo(t,function(t,r,i){te(n,e(t,r,i),t)}),n},mapValues:function(t,e){var n={};return e=jo(e),zo(t,function(t,r,i){te(n,r,e(t,r,i))}),n},merge:fh,mergeWith:ns,omit:kh,omitBy:function(t,e){return Th(t,vh(jo(e)))},pick:fd,pickBy:Th,result:function(t,e,n){var r=-1,i=(e=bn(e,t)).length;for(i||(i=1,t=void 0);++r<i;){var o=null==t?void 0:t[Sn(e[r])];void 0===o&&(r=i,o=n),t=B(o)?o.call(t):o}return t},set:function(t,e,n){return null==t?t:jh(t,e,n)},setWith:function(t,e,n,r){return r="function"==typeof r?r:void 0,null==t?t:jh(t,e,n,r)},toPairs:ks,toPairsIn:js,transform:function(t,e,n){var r=x(t),i=r||ke(t)||Ce(t);if(e=jo(e),null==n){var o=t&&t.constructor;n=i?r?new o:[]:P(t)&&B(o)?rt(Cn(t)):{}}return(i?Ct:zo)(t,function(t,r,i){return e(n,t,r,i)}),n},unset:function(t,e){return null==t||Sh(t,e)},update:function(t,e,n){return null==t?t:Xu(t,e,ms(n))},updateWith:function(t,e,n,r){return r="function"==typeof r?r:void 0,null==t?t:Xu(t,e,ms(n),r)},values:pa,valuesIn:function(t){return null==t?[]:ga(t,Ye(t))}},cl={at:qu,chain:ti,commit:function(){return new mt(this.value(),this.__chain__)},lodash:bt,next:function(){void 0===this.__values__&&(this.__values__=wh(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?void 0:this.__values__[this.__index__++]}},plant:function(t){for(var e,n=this;n instanceof ut;){var r=xt(n);r.__index__=0,r.__values__=void 0,e?i.__wrapped__=r:e=r;var i=r;n=n.__wrapped__}return i.__wrapped__=t,e},reverse:function(){var t=this.__wrapped__;if(t instanceof lt){var e=t;return this.__actions__.length&&(e=new lt(this)),(e=e.reverse()).__actions__.push({func:Su,args:[Bd],thisArg:void 0}),new mt(e,this.__chain__)}return this.thru(Bd)},tap:function(t,e){return e(t),t},thru:Su,toIterator:function(){return this},toJSON:ju,value:ju,valueOf:ju,wrapperChain:function(){return ti(this)}},fl={camelCase:$r,capitalize:gr,deburr:wr,endsWith:function(t,e,n){t=wn(t),e=S(e);var r=t.length,i=n=void 0===n?r:ri(L(n),0,r);return(n-=e.length)>=0&&t.slice(n,i)==e},escape:Ms,escapeRegExp:function(t){return(t=wn(t))&&Vs.test(t)?t.replace(zs,"\\$&"):t},kebabCase:Ja,lowerCase:ih,lowerFirst:oh,pad:function(t,e,n){t=wn(t);var r=(e=L(e))?td(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return nd(id(i),n)+t+nd(rd(i),n)},padEnd:function(t,e,n){t=wn(t);var r=(e=L(e))?td(t):0;return e&&r<e?t+nd(e-r,n):t},padStart:function(t,e,n){t=wn(t);var r=(e=L(e))?td(t):0;return e&&r<e?nd(e-r,n)+t:t},parseInt:function(t,e,n){return n||null==e?e=0:e&&(e=+e),sd(wn(t).replace(od,""),e||0)},repeat:function(t,e,n){return e=(n?ue(t,e,n):void 0===e)?1:L(e),Nh(wn(t),e)},replace:function(){var t=arguments,e=wn(t[0]);return t.length<3?e:e.replace(t[1],t[2])},snakeCase:$d,split:function(t,e,n){return n&&"number"!=typeof n&&ue(t,e,n)&&(e=n=void 0),(n=void 0===n?4294967295:n>>>0)?(t=wn(t))&&("string"==typeof e||null!=e&&!qa(e))&&!(e=S(e))&&Jn(t)?Hn(lr(t),0,n):t.split(e,n):[]},startCase:ou,startsWith:function(t,e,n){return t=wn(t),n=null==n?0:ri(L(n),0,t.length),e=S(e),t.slice(n,n+e.length)==e},template:function(t,e,n){var r=fu.imports._.templateSettings||fu;n&&ue(t,e,n)&&(e=void 0),t=wn(t),e=He({},e,r,du);var i,o,s=He({},e.imports,r.imports,du),a=Ne(s),h=ga(s,a),d=0,u=e.interpolate||xu,l="__p += '",c=RegExp((e.escape||xu).source+"|"+u.source+"|"+(u===cu?vu:xu).source+"|"+(e.evaluate||xu).source+"|$","g"),f=bu.call(e,"sourceURL")?"//# sourceURL="+(e.sourceURL+"").replace(/\s/g," ")+"\n":"";t.replace(c,function(e,n,r,s,a,h){return r||(r=s),l+=t.slice(d,h).replace(wu,lu),n&&(i=!0,l+="' +\n__e("+n+") +\n'"),a&&(o=!0,l+="';\n"+a+";\n__p += '"),r&&(l+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),d=h+e.length,e}),l+="';\n";var g=bu.call(e,"variable")&&e.variable;if(g){if(mu.test(g))throw new Error("Invalid `variable` option passed into `_.template`")}else l="with (obj) {\n"+l+"\n}\n";l=(o?l.replace(gu,""):l).replace(pu,"$1").replace(yu,"$1;"),l="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+l+"return __p\n}";var p=Gn(function(){return Function(a,f+"return "+l).apply(void 0,h)});if(p.source=l,Nn(p))throw p;return p},templateSettings:fu,toLower:function(t){return wn(t).toLowerCase()},toUpper:function(t){return wn(t).toUpperCase()},trim:function(t,e,n){if((t=wn(t))&&(n||void 0===e))return T(t);if(!t||!(e=S(e)))return t;var r=lr(t),i=lr(e);return Hn(r,Pu(r,i),Tu(r,i)+1).join("")},trimEnd:function(t,e,n){if((t=wn(t))&&(n||void 0===e))return t.slice(0,j(t)+1);if(!t||!(e=S(e)))return t;var r=lr(t);return Hn(r,0,Tu(r,lr(e))+1).join("")},trimStart:function(t,e,n){if((t=wn(t))&&(n||void 0===e))return t.replace(Mu,"");if(!t||!(e=S(e)))return t;var r=lr(t);return Hn(r,Pu(r,lr(e))).join("")},truncate:function(t,e){var n=30,r="...";if(P(e)){var i="separator"in e?e.separator:i;n="length"in e?L(e.length):n,r="omission"in e?S(e.omission):r}var o=(t=wn(t)).length;if(Jn(t)){var s=lr(t);o=s.length}if(n>=o)return t;var a=n-td(r);if(a<1)return r;var h=s?Hn(s,0,a).join(""):t.slice(0,a);if(void 0===i)return h+r;if(s&&(a+=h.length-a),qa(i)){if(t.slice(a).search(i)){var d,u=h;for(i.global||(i=RegExp(i.source,wn(zu.exec(i))+"g")),i.lastIndex=0;d=i.exec(u);)var l=d.index;h=h.slice(0,void 0===l?a:l)}}else if(t.indexOf(S(i),a)!=a){var c=h.lastIndexOf(i);c>-1&&(h=h.slice(0,c))}return h+r},unescape:function(t){return(t=wn(t))&&Ou.test(t)?t.replace(Cu,Vu):t},upperCase:Yu,upperFirst:fr,words:Ur},gl={attempt:Gn,bindAll:Yn,cond:function(t){var e=null==t?0:t.length,n=jo;return t=e?v(t,function(t){if("function"!=typeof t[1])throw new TypeError("Expected a function");return[n(t[0]),t[1]]}):[],ae(function(n){for(var r=-1;++r<e;){var i=t[r];if(ot(i[0],this,n))return ot(i[1],this,n)}})},conforms:function(t){return function(t){var e=Ne(t);return function(n){return Io(n,t,e)}}(Ji(t,1))},constant:Pt,defaultTo:function(t,e){return null==t||t!=t?e:t},flow:Qs,flowRight:ta,identity:W,iteratee:function(t){return jo("function"==typeof t?t:Ji(t,1))},matches:function(t){return xo(Ji(t,1))},matchesProperty:function(t,e){return _o(t,Ji(e,1))},method:gh,methodOf:ph,mixin:yh,noop:ct,nthArg:function(t){return t=L(t),ae(function(e){return bh(e,t)})},over:Vh,overEvery:Lh,overSome:Wh,property:ko,propertyOf:function(t){return function(e){return null==t?void 0:_n(t,e)}},range:Vd,rangeRight:Cd,stubArray:ci,stubFalse:be,stubObject:function(){return{}},stubString:function(){return""},stubTrue:function(){return!0},times:function(t,e){if((t=L(t))<1||t>9007199254740991)return[];var n=_u,r=Au(t,_u);e=ms(e),t-=_u;for(var i=ge(r,e);++n<t;)e(n);return i},toPath:function(t){return x(t)?v(t,Sn):y(t)?[t]:vt(xn(wn(t)))},uniqueId:function(t){var e=++Nu;return wn(t)+e}};var pl=Math.max,yl=Math.min;var ml=Math.min;
2
+ /**
3
+ * @license
4
+ * Lodash (Custom Build) <https://lodash.com/>
5
+ * Build: `lodash modularize exports="es" -o ./`
6
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
7
+ * Released under MIT license <https://lodash.com/license>
8
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
9
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
10
+ */
11
+ var vl,xl=4294967295,wl=Array.prototype,bl=Object.prototype.hasOwnProperty,Sl=a?a.iterator:void 0,_l=Math.max,Al=Math.min,kl=function(t){return function(e,n,r){if(null==r){var i=P(n),o=i&&Ne(n),s=o&&o.length&&ea(n,o);(s?s.length:i)||(r=n,n=e,e=this)}return t(e,n,r)}}(yh);bt.after=ol.after,bt.ary=ol.ary,bt.assign=ll.assign,bt.assignIn=ll.assignIn,bt.assignInWith=ll.assignInWith,bt.assignWith=ll.assignWith,bt.at=ll.at,bt.before=ol.before,bt.bind=ol.bind,bt.bindAll=gl.bindAll,bt.bindKey=ol.bindKey,bt.castArray=sl.castArray,bt.chain=cl.chain,bt.chunk=nl.chunk,bt.compact=nl.compact,bt.concat=nl.concat,bt.cond=gl.cond,bt.conforms=gl.conforms,bt.constant=gl.constant,bt.countBy=rl.countBy,bt.create=ll.create,bt.curry=ol.curry,bt.curryRight=ol.curryRight,bt.debounce=ol.debounce,bt.defaults=ll.defaults,bt.defaultsDeep=ll.defaultsDeep,bt.defer=ol.defer,bt.delay=ol.delay,bt.difference=nl.difference,bt.differenceBy=nl.differenceBy,bt.differenceWith=nl.differenceWith,bt.drop=nl.drop,bt.dropRight=nl.dropRight,bt.dropRightWhile=nl.dropRightWhile,bt.dropWhile=nl.dropWhile,bt.fill=nl.fill,bt.filter=rl.filter,bt.flatMap=rl.flatMap,bt.flatMapDeep=rl.flatMapDeep,bt.flatMapDepth=rl.flatMapDepth,bt.flatten=nl.flatten,bt.flattenDeep=nl.flattenDeep,bt.flattenDepth=nl.flattenDepth,bt.flip=ol.flip,bt.flow=gl.flow,bt.flowRight=gl.flowRight,bt.fromPairs=nl.fromPairs,bt.functions=ll.functions,bt.functionsIn=ll.functionsIn,bt.groupBy=rl.groupBy,bt.initial=nl.initial,bt.intersection=nl.intersection,bt.intersectionBy=nl.intersectionBy,bt.intersectionWith=nl.intersectionWith,bt.invert=ll.invert,bt.invertBy=ll.invertBy,bt.invokeMap=rl.invokeMap,bt.iteratee=gl.iteratee,bt.keyBy=rl.keyBy,bt.keys=Ne,bt.keysIn=ll.keysIn,bt.map=rl.map,bt.mapKeys=ll.mapKeys,bt.mapValues=ll.mapValues,bt.matches=gl.matches,bt.matchesProperty=gl.matchesProperty,bt.memoize=ol.memoize,bt.merge=ll.merge,bt.mergeWith=ll.mergeWith,bt.method=gl.method,bt.methodOf=gl.methodOf,bt.mixin=kl,bt.negate=vh,bt.nthArg=gl.nthArg,bt.omit=ll.omit,bt.omitBy=ll.omitBy,bt.once=ol.once,bt.orderBy=rl.orderBy,bt.over=gl.over,bt.overArgs=ol.overArgs,bt.overEvery=gl.overEvery,bt.overSome=gl.overSome,bt.partial=ol.partial,bt.partialRight=ol.partialRight,bt.partition=rl.partition,bt.pick=ll.pick,bt.pickBy=ll.pickBy,bt.property=gl.property,bt.propertyOf=gl.propertyOf,bt.pull=nl.pull,bt.pullAll=nl.pullAll,bt.pullAllBy=nl.pullAllBy,bt.pullAllWith=nl.pullAllWith,bt.pullAt=nl.pullAt,bt.range=gl.range,bt.rangeRight=gl.rangeRight,bt.rearg=ol.rearg,bt.reject=rl.reject,bt.remove=nl.remove,bt.rest=ol.rest,bt.reverse=nl.reverse,bt.sampleSize=rl.sampleSize,bt.set=ll.set,bt.setWith=ll.setWith,bt.shuffle=rl.shuffle,bt.slice=nl.slice,bt.sortBy=rl.sortBy,bt.sortedUniq=nl.sortedUniq,bt.sortedUniqBy=nl.sortedUniqBy,bt.split=fl.split,bt.spread=ol.spread,bt.tail=nl.tail,bt.take=nl.take,bt.takeRight=nl.takeRight,bt.takeRightWhile=nl.takeRightWhile,bt.takeWhile=nl.takeWhile,bt.tap=cl.tap,bt.throttle=ol.throttle,bt.thru=Su,bt.toArray=sl.toArray,bt.toPairs=ll.toPairs,bt.toPairsIn=ll.toPairsIn,bt.toPath=gl.toPath,bt.toPlainObject=sl.toPlainObject,bt.transform=ll.transform,bt.unary=ol.unary,bt.union=nl.union,bt.unionBy=nl.unionBy,bt.unionWith=nl.unionWith,bt.uniq=nl.uniq,bt.uniqBy=nl.uniqBy,bt.uniqWith=nl.uniqWith,bt.unset=ll.unset,bt.unzip=nl.unzip,bt.unzipWith=nl.unzipWith,bt.update=ll.update,bt.updateWith=ll.updateWith,bt.values=ll.values,bt.valuesIn=ll.valuesIn,bt.without=nl.without,bt.words=fl.words,bt.wrap=ol.wrap,bt.xor=nl.xor,bt.xorBy=nl.xorBy,bt.xorWith=nl.xorWith,bt.zip=nl.zip,bt.zipObject=nl.zipObject,bt.zipObjectDeep=nl.zipObjectDeep,bt.zipWith=nl.zipWith,bt.entries=ll.toPairs,bt.entriesIn=ll.toPairsIn,bt.extend=ll.assignIn,bt.extendWith=ll.assignInWith,kl(bt,bt),bt.add=al.add,bt.attempt=gl.attempt,bt.camelCase=fl.camelCase,bt.capitalize=fl.capitalize,bt.ceil=al.ceil,bt.clamp=hl,bt.clone=sl.clone,bt.cloneDeep=sl.cloneDeep,bt.cloneDeepWith=sl.cloneDeepWith,bt.cloneWith=sl.cloneWith,bt.conformsTo=sl.conformsTo,bt.deburr=fl.deburr,bt.defaultTo=gl.defaultTo,bt.divide=al.divide,bt.endsWith=fl.endsWith,bt.eq=sl.eq,bt.escape=fl.escape,bt.escapeRegExp=fl.escapeRegExp,bt.every=rl.every,bt.find=rl.find,bt.findIndex=nl.findIndex,bt.findKey=ll.findKey,bt.findLast=rl.findLast,bt.findLastIndex=nl.findLastIndex,bt.findLastKey=ll.findLastKey,bt.floor=al.floor,bt.forEach=rl.forEach,bt.forEachRight=rl.forEachRight,bt.forIn=ll.forIn,bt.forInRight=ll.forInRight,bt.forOwn=ll.forOwn,bt.forOwnRight=ll.forOwnRight,bt.get=ll.get,bt.gt=sl.gt,bt.gte=sl.gte,bt.has=ll.has,bt.hasIn=ll.hasIn,bt.head=nl.head,bt.identity=W,bt.includes=rl.includes,bt.indexOf=nl.indexOf,bt.inRange=dl,bt.invoke=ll.invoke,bt.isArguments=sl.isArguments,bt.isArray=x,bt.isArrayBuffer=sl.isArrayBuffer,bt.isArrayLike=sl.isArrayLike,bt.isArrayLikeObject=sl.isArrayLikeObject,bt.isBoolean=sl.isBoolean,bt.isBuffer=sl.isBuffer,bt.isDate=sl.isDate,bt.isElement=sl.isElement,bt.isEmpty=sl.isEmpty,bt.isEqual=sl.isEqual,bt.isEqualWith=sl.isEqualWith,bt.isError=sl.isError,bt.isFinite=sl.isFinite,bt.isFunction=sl.isFunction,bt.isInteger=sl.isInteger,bt.isLength=sl.isLength,bt.isMap=sl.isMap,bt.isMatch=sl.isMatch,bt.isMatchWith=sl.isMatchWith,bt.isNaN=sl.isNaN,bt.isNative=sl.isNative,bt.isNil=sl.isNil,bt.isNull=sl.isNull,bt.isNumber=sl.isNumber,bt.isObject=P,bt.isObjectLike=sl.isObjectLike,bt.isPlainObject=sl.isPlainObject,bt.isRegExp=sl.isRegExp,bt.isSafeInteger=sl.isSafeInteger,bt.isSet=sl.isSet,bt.isString=sl.isString,bt.isSymbol=sl.isSymbol,bt.isTypedArray=sl.isTypedArray,bt.isUndefined=sl.isUndefined,bt.isWeakMap=sl.isWeakMap,bt.isWeakSet=sl.isWeakSet,bt.join=nl.join,bt.kebabCase=fl.kebabCase,bt.last=cs,bt.lastIndexOf=nl.lastIndexOf,bt.lowerCase=fl.lowerCase,bt.lowerFirst=fl.lowerFirst,bt.lt=sl.lt,bt.lte=sl.lte,bt.max=al.max,bt.maxBy=al.maxBy,bt.mean=al.mean,bt.meanBy=al.meanBy,bt.min=al.min,bt.minBy=al.minBy,bt.stubArray=gl.stubArray,bt.stubFalse=gl.stubFalse,bt.stubObject=gl.stubObject,bt.stubString=gl.stubString,bt.stubTrue=gl.stubTrue,bt.multiply=al.multiply,bt.nth=nl.nth,bt.noop=gl.noop,bt.now=il.now,bt.pad=fl.pad,bt.padEnd=fl.padEnd,bt.padStart=fl.padStart,bt.parseInt=fl.parseInt,bt.random=ul,bt.reduce=rl.reduce,bt.reduceRight=rl.reduceRight,bt.repeat=fl.repeat,bt.replace=fl.replace,bt.result=ll.result,bt.round=al.round,bt.sample=rl.sample,bt.size=rl.size,bt.snakeCase=fl.snakeCase,bt.some=rl.some,bt.sortedIndex=nl.sortedIndex,bt.sortedIndexBy=nl.sortedIndexBy,bt.sortedIndexOf=nl.sortedIndexOf,bt.sortedLastIndex=nl.sortedLastIndex,bt.sortedLastIndexBy=nl.sortedLastIndexBy,bt.sortedLastIndexOf=nl.sortedLastIndexOf,bt.startCase=fl.startCase,bt.startsWith=fl.startsWith,bt.subtract=al.subtract,bt.sum=al.sum,bt.sumBy=al.sumBy,bt.template=fl.template,bt.times=gl.times,bt.toFinite=sl.toFinite,bt.toInteger=L,bt.toLength=sl.toLength,bt.toLower=fl.toLower,bt.toNumber=sl.toNumber,bt.toSafeInteger=sl.toSafeInteger,bt.toString=sl.toString,bt.toUpper=fl.toUpper,bt.trim=fl.trim,bt.trimEnd=fl.trimEnd,bt.trimStart=fl.trimStart,bt.truncate=fl.truncate,bt.unescape=fl.unescape,bt.uniqueId=gl.uniqueId,bt.upperCase=fl.upperCase,bt.upperFirst=fl.upperFirst,bt.each=rl.forEach,bt.eachRight=rl.forEachRight,bt.first=nl.head,kl(bt,(vl={},zo(bt,function(t,e){bl.call(bt.prototype,e)||(vl[e]=t)}),vl),{chain:!1}),bt.VERSION="4.17.21",(bt.templateSettings=fl.templateSettings).imports._=bt,Ct(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){bt[t].placeholder=bt}),Ct(["drop","take"],function(t,e){lt.prototype[t]=function(n){n=void 0===n?1:_l(L(n),0);var r=this.__filtered__&&!e?new lt(this):this.clone();return r.__filtered__?r.__takeCount__=Al(n,r.__takeCount__):r.__views__.push({size:Al(n,xl),type:t+(r.__dir__<0?"Right":"")}),r},lt.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ct(["filter","map","takeWhile"],function(t,e){var n=e+1,r=1==n||3==n;lt.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:jo(t),type:n}),e.__filtered__=e.__filtered__||r,e}}),Ct(["head","last"],function(t,e){var n="take"+(e?"Right":"");lt.prototype[t]=function(){return this[n](1).value()[0]}}),Ct(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");lt.prototype[t]=function(){return this.__filtered__?new lt(this):this[n](1)}}),lt.prototype.compact=function(){return this.filter(W)},lt.prototype.find=function(t){return this.filter(t).head()},lt.prototype.findLast=function(t){return this.reverse().find(t)},lt.prototype.invokeMap=ae(function(t,e){return"function"==typeof t?new lt(this):this.map(function(n){return Oa(n,t,e)})}),lt.prototype.reject=function(t){return this.filter(vh(jo(t)))},lt.prototype.slice=function(t,e){t=L(t);var n=this;return n.__filtered__&&(t>0||e<0)?new lt(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),void 0!==e&&(n=(e=L(e))<0?n.dropRight(-e):n.take(e-t)),n)},lt.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},lt.prototype.toArray=function(){return this.take(xl)},zo(lt.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),i=bt[r?"take"+("last"==e?"Right":""):e],o=r||/^find/.test(e);i&&(bt.prototype[e]=function(){var e=this.__wrapped__,s=r?[1]:arguments,a=e instanceof lt,h=s[0],d=a||x(e),u=function(t){var e=i.apply(bt,jn([t],s));return r&&l?e[0]:e};d&&n&&"function"==typeof h&&1!=h.length&&(a=d=!1);var l=this.__chain__,c=!!this.__actions__.length,f=o&&!l,g=a&&!c;if(!o&&d){e=g?e:new lt(this);var p=t.apply(e,s);return p.__actions__.push({func:Su,args:[u],thisArg:void 0}),new mt(p,l)}return f&&g?t.apply(this,s):(p=this.thru(u),f?r?p.value()[0]:p.value():p)})}),Ct(["pop","push","shift","sort","splice","unshift"],function(t){var e=wl[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);bt.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(x(i)?i:[],t)}return this[n](function(n){return e.apply(x(n)?n:[],t)})}}),zo(lt.prototype,function(t,e){var n=bt[e];if(n){var r=n.name+"";bl.call(gt,r)||(gt[r]=[]),gt[r].push({name:e,func:n})}}),gt[Zt(void 0,2).name]=[{name:"wrapper",func:void 0}],lt.prototype.clone=function(){var t=new lt(this.__wrapped__);return t.__actions__=vt(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=vt(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=vt(this.__views__),t},lt.prototype.reverse=function(){if(this.__filtered__){var t=new lt(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},lt.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=x(t),r=e<0,i=n?t.length:0,o=function(t,e,n){for(var r=-1,i=n.length;++r<i;){var o=n[r],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=yl(e,t+s);break;case"takeRight":t=pl(t,e-s)}}return{start:t,end:e}}(0,i,this.__views__),s=o.start,a=o.end,h=a-s,d=r?a:s-1,u=this.__iteratees__,l=u.length,c=0,f=ml(h,this.__takeCount__);if(!n||!r&&i==h&&f==h)return ku(t,this.__actions__);var g=[];t:for(;h--&&c<f;){for(var p=-1,y=t[d+=e];++p<l;){var m=u[p],v=m.iteratee,w=m.type,b=v(y);if(2==w)y=b;else if(!b){if(1==w)continue t;break t}}g[c++]=y}return g},bt.prototype.at=cl.at,bt.prototype.chain=cl.wrapperChain,bt.prototype.commit=cl.commit,bt.prototype.next=cl.next,bt.prototype.plant=cl.plant,bt.prototype.reverse=cl.reverse,bt.prototype.toJSON=bt.prototype.valueOf=bt.prototype.value=cl.value,bt.prototype.first=bt.prototype.head,Sl&&(bt.prototype[Sl]=cl.toIterator);var jl=(t=>(t[t["左键"]=0]="左键",t[t["右键"]=2]="右键",t))(jl||{});class Il{constructor(t,n){r(this,"render"),r(this,"layer"),r(this,"group"),this.render=t,this.layer=n,this.group=new e.Group}init(){this.layer.add(this.group),this.draw()}draw(){}clear(){this.group.destroy();const t=this.group.name();this.group=new e.Group({name:t}),this.layer.add(this.group)}}var Tl=(t=>(t["上"]="ArrowUp",t["左"]="ArrowLeft",t["右"]="ArrowRight",t["下"]="ArrowDown",t))(Tl||{}),Pl=(t=>(t["删除"]="Delete",t.C="KeyC",t.V="KeyV",t.Z="KeyZ",t.A="KeyA",t.R="KeyR",t.Esc="Escape",t.Backspace="Backspace",t.Enter="Enter",t))(Pl||{}),Ml=(t=>(t["垂直居中"]="Middle",t["左对齐"]="Left",t["右对齐"]="Right",t["水平居中"]="Center",t["上对齐"]="Top",t["下对齐"]="Bottom",t))(Ml||{}),zl=(t=>(t.auto="auto",t.straight="straight",t.manual="manual",t.curve="curve",t.bezier="bezier",t))(zl||{}),Vl=(t=>(t.Line="Line",t.Curve="Curve",t.Rect="Rect",t.Circle="Circle",t.Bezier="Bezier",t))(Vl||{}),Cl=(t=>(t.Image="Image",t.Json="Json",t.Graph="Graph",t.Text="Text",t))(Cl||{}),Ol=(t=>(t.svg="svg",t.gif="gif",t.other="other",t))(Ol||{});class El extends Il{constructor(t,e,n){super(t,e),r(this,"option"),this.option=n,this.group.listening(!1)}draw(){this.clear();const t=this.render.getStageState(),n=this.option.size,r=Math.ceil(this.render.toStageValue(t.width+this.render.rulerSize)/n),i=Math.ceil(this.render.toStageValue(t.height+this.render.rulerSize)/n),o=-Math.ceil(this.render.toStageValue(t.x)/n),s=-Math.ceil(this.render.toStageValue(t.y)/n),a=new e.Group;if(a.add(new e.Rect({name:`${this.constructor.name}__background`,x:0,y:0,width:t.width,height:t.height,listening:!1,fill:this.render.getPageSettings().background})),!this.option.readonly){a.add(new e.Rect({name:this.constructor.name,x:0,y:0,width:t.width,height:t.height,stroke:"rgba(255,0,0,0.2)",strokeWidth:this.render.toStageValue(2),listening:!1,dash:[this.render.toStageValue(6),this.render.toStageValue(6)]}));for(let i=0;i<r+o+2;i++){let r=n*i,o=this.render.toStageValue(-t.y+this.render.rulerSize),s=n*i,h=this.render.toStageValue(t.height-t.y+this.render.rulerSize);r=r<t.width?r:t.width,s=s<t.width?s:t.width,o=o>0?o:0,o=o<t.height?o:t.height,h=h>0?h:0,h=h<t.height?h:t.height,a.add(new e.Line({name:this.constructor.name,points:bt.flatten([[r,o>0?o:0],[s,h>0?h:0]]),stroke:"#ddd",strokeWidth:this.render.toStageValue(1),listening:!1}))}for(let r=0;r<i+s+2;r++){let i=this.render.toStageValue(-t.x+this.render.rulerSize),o=n*r,s=this.render.toStageValue(t.width-t.x+this.render.rulerSize),h=n*r;i=i>0?i:0,i=i<t.width?i:t.width,s=s>0?s:0,s=s<t.width?s:t.width,o=o<t.height?o:t.height,h=h<t.height?h:t.height,a.add(new e.Line({name:this.constructor.name,points:bt.flatten([[i,o],[s,h]]),stroke:"#ddd",strokeWidth:this.render.toStageValue(1),listening:!1}))}}this.group.add(a)}}r(El,"name","bg");class Rl extends Il{constructor(t,e,n){super(t,e),r(this,"option"),this.option=n,this.group.listening(!1)}draw(){this.clear();const t=this.render.getStageState(),n=20,r=Math.ceil(this.render.toStageValue(t.width)/n),i=Math.ceil(this.render.toStageValue(t.height)/n),o=-Math.ceil(this.render.toStageValue(t.x-this.option.size)/n),s=-Math.ceil(this.render.toStageValue(t.y-this.option.size)/n),a=new e.Group,h=new e.Group({x:this.render.toStageValue(-t.x+this.option.size),y:this.render.toStageValue(-t.y),width:this.render.toStageValue(t.width-this.option.size+this.render.rulerSize),height:this.render.toStageValue(this.option.size)}),d=new e.Group({x:this.render.toStageValue(-t.x),y:this.render.toStageValue(-t.y+this.option.size),width:this.render.toStageValue(this.option.size),height:this.render.toStageValue(t.height-this.option.size+this.render.rulerSize)});h.add(new e.Rect({name:this.constructor.name,x:0,y:0,width:h.width(),height:h.height(),fill:"#ddd"}));for(let u=r+o-1;u>=o;u--){const t=-h.x()+n*u,r=this.render.toStageValue(this.option.size)/5*4,i=this.render.toStageValue(this.option.size)/5*3;if(t>=0&&(h.add(new e.Line({name:this.constructor.name,points:bt.flatten([[t,u%5?r:i],[t,this.render.toStageValue(this.option.size)]]),stroke:"#999",strokeWidth:this.render.toStageValue(1),listening:!1})),u%5==0)){let r=12;const i=new e.Text({name:this.constructor.name,y:this.render.toStageValue(this.option.size/2-r),text:(u*n).toString(),fontSize:this.render.toStageValue(r),fill:"#999",align:"center",verticalAlign:"middle",lineHeight:1.6});for(;this.render.toStageValue(i.width())>4.6*this.render.toStageValue(n);)r-=1,i.fontSize(this.render.toStageValue(r)),i.y(this.render.toStageValue(this.option.size/2-r));i.x(t-i.width()/2),h.add(i)}}d.add(new e.Rect({name:this.constructor.name,x:0,y:0,width:d.width(),height:d.height(),fill:"#ddd"}));for(let u=i+s-1;u>=s;u--){const t=-d.y()+n*u,r=this.render.toStageValue(this.option.size)/5*4,i=this.render.toStageValue(this.option.size)/5*3;if(t>=0&&(d.add(new e.Line({name:this.constructor.name,points:bt.flatten([[u%5?r:i,t],[this.render.toStageValue(this.option.size),t]]),stroke:"#999",strokeWidth:this.render.toStageValue(1),listening:!1})),u%5==0)){let r=12;const o=new e.Text({name:this.constructor.name,x:0,y:t,text:(u*n).toString(),fontSize:this.render.toStageValue(r),fill:"#999",align:"right",verticalAlign:"bottom",lineHeight:1.6,wrap:"none"});for(;o.width()>.8*i;)r-=1,o.fontSize(this.render.toStageValue(r));o.y(t-o.height()/2),o.width(i-this.render.toStageValue(1)),d.add(o)}}a.add(new e.Rect({name:this.constructor.name,x:this.render.toStageValue(-t.x),y:this.render.toStageValue(-t.y),width:this.render.toStageValue(this.option.size),height:this.render.toStageValue(this.option.size),fill:"#ddd"})),a.add(h),a.add(d),this.group.add(a)}}r(Rl,"name","ruler");class Ll extends Il{constructor(t,e,n){super(t,e),r(this,"option"),r(this,"handlers",{dom:{mousemove:()=>{this.draw()},mouseout:()=>{this.clear()}}}),this.option=n,this.group.listening(!1)}draw(){this.clear();const t=this.render.getStageState(),n=new e.Group,r=this.render.stage.getPointerPosition();r&&(r.y>=this.option.padding&&n.add(new e.Line({name:this.constructor.name,points:bt.flatten([[this.render.toStageValue(-t.x),this.render.toStageValue(r.y-t.y)],[this.render.toStageValue(t.width-t.x+this.render.rulerSize),this.render.toStageValue(r.y-t.y)]]),stroke:"rgba(255,0,0,0.2)",strokeWidth:this.render.toStageValue(1),listening:!1})),r.x>=this.option.padding&&n.add(new e.Line({name:this.constructor.name,points:bt.flatten([[this.render.toStageValue(r.x-t.x),this.render.toStageValue(-t.y)],[this.render.toStageValue(r.x-t.x),this.render.toStageValue(t.height-t.y+this.render.rulerSize)]]),stroke:"rgba(255,0,0,0.2)",strokeWidth:this.render.toStageValue(1),listening:!1}))),this.group.add(n)}}r(Ll,"name","refLine");class Wl extends Il{constructor(t,n,i){super(t,n),r(this,"option"),r(this,"state"),r(this,"handlers",{stage:{mousedown:t=>{this.state.lastPos=this.render.stage.getPointerPosition(),t.evt.button===jl.左键?this.state.menuIsMousedown||(this.state.target=null,this.draw()):t.evt.button!==jl.右键||t.evt.ctrlKey||(this.state.right=!0)},mousemove:()=>{this.state.target&&this.state.right&&(this.state.target=null,this.draw())},mouseup:()=>{this.state.right=!1},contextmenu:t=>{if(!t.evt.ctrlKey){const n=this.render.stage.getPointerPosition();if(n&&this.state.lastPos){const r=this.render.layerCover.find(`.${Fl.name}`)[0];let i=null;if(r){const t=r.find(".link-line");for(const r of t)if(e.Util.haveIntersection({...n,width:1,height:1},r.getClientRect())){i=r;break}}n.x===this.state.lastPos.x||n.y===this.state.lastPos.y?this.state.target=i??t.target:this.state.target=null,this.draw()}}},wheel:()=>{this.state.target=null,this.draw()}}}),this.option=i,this.state={target:null,menuIsMousedown:!1,lastPos:null,right:!1}}draw(){if(this.clear(),this.state.target){const t=[];if(this.state.target===this.render.stage)t.push({name:"自适应大小",action:()=>{this.render.positionTool.positionFit()}}),t.push({name:"恢复位置",action:()=>{this.render.positionTool.positionReset()}}),t.push({name:"恢复大小位置",action:()=>{this.render.positionTool.positionZoomReset()}});else if(!this.render.config.readonly)if("link-line"===this.state.target.name())t.push({name:"删除",action:()=>{this.render.linkTool.remove(this.state.target)}});else{const n=this.state.target.parent;if(t.push({name:"复制",action:()=>{n&&this.render.copyTool.copy([n])}}),t.push({name:"删除",action:()=>{n&&this.render.remove([n])}}),t.push({name:"上移",action:()=>{n&&this.render.zIndexTool.up([n])}}),t.push({name:"下移",action:()=>{n&&this.render.zIndexTool.down([n])}}),t.push({name:"置顶",action:()=>{n&&this.render.zIndexTool.top([n])}}),t.push({name:"置底",action:()=>{n&&this.render.zIndexTool.bottom([n])}}),n instanceof e.Transformer){const r=this.render.stage.getPointerPosition();if(r){const i=n.nodes();if(i.length>1){i.sort((t,e)=>e.zIndex()-t.zIndex());const n=i.find(t=>e.Util.haveIntersection({...r,width:1,height:1},t.getClientRect()));t.push({name:"垂直居中"+(n?"于目标":""),action:()=>{this.render.alignTool.align(Ml.垂直居中,n)}}),t.push({name:"左对齐"+(n?"于目标":""),action:()=>{this.render.alignTool.align(Ml.左对齐,n)}}),t.push({name:"右对齐"+(n?"于目标":""),action:()=>{this.render.alignTool.align(Ml.右对齐,n)}}),t.push({name:"水平居中"+(n?"于目标":""),action:()=>{this.render.alignTool.align(Ml.水平居中,n)}}),t.push({name:"上对齐"+(n?"于目标":""),action:()=>{this.render.alignTool.align(Ml.上对齐,n)}}),t.push({name:"下对齐"+(n?"于目标":""),action:()=>{this.render.alignTool.align(Ml.下对齐,n)}})}}}}const n=this.render.getStageState(),r=new e.Group({name:"contextmenu",width:n.width,height:n.height});let i=0;const o=30,s=this.render.stage.getPointerPosition();if(s)for(const a of t){const t=new e.Rect({x:this.render.toStageValue(s.x-n.x),y:this.render.toStageValue(s.y+i-n.y),width:this.render.toStageValue(150),height:this.render.toStageValue(o),fill:"#fff",stroke:"#999",strokeWidth:this.render.toStageValue(1),name:"contextmenu"}),h=new e.Text({x:this.render.toStageValue(s.x-n.x),y:this.render.toStageValue(s.y+i-n.y),text:a.name,name:"contextmenu",listening:!1,fontSize:this.render.toStageValue(16),fill:"#333",width:this.render.toStageValue(150),height:this.render.toStageValue(o),align:"center",verticalAlign:"middle"});r.add(t),r.add(h),t.on("pointerclick",t=>{t.evt.button===jl.左键&&(a.action(t),this.group.getChildren().forEach(t=>{t.destroy()}),this.group.removeChildren(),this.state.target=null),t.evt.preventDefault(),t.evt.stopPropagation()}),t.on("mousedown",e=>{e.evt.button===jl.左键&&(this.state.menuIsMousedown=!0,t.fill("#dfdfdf")),e.evt.preventDefault(),e.evt.stopPropagation()}),t.on("mouseup",t=>{t.evt.button===jl.左键&&(this.state.menuIsMousedown=!1)}),t.on("mouseenter",e=>{this.state.menuIsMousedown?t.fill("#dfdfdf"):t.fill("#efefef"),e.evt.preventDefault(),e.evt.stopPropagation()}),t.on("mouseout",()=>{t.fill("#fff")}),t.on("contextmenu",t=>{t.evt.preventDefault(),t.evt.stopPropagation()}),i+=o-1}this.group.add(r)}}}r(Wl,"name","contextmenu");class Bl extends Il{constructor(t,e,n){super(t,e),r(this,"option"),r(this,"state",{moving:!1}),this.option=n}draw(){this.clear();const t=this.render.getStageState(),n=new e.Group({name:"preview",scale:{x:this.render.toStageValue(this.option.size),y:this.render.toStageValue(this.option.size)},width:t.width,height:t.height}),r=this.render.stage.find("#main")[0],i=this.render.stage.find("#cover")[0],o=[...r.getChildren(t=>!this.render.ignore(t)),...i.getChildren(t=>t.name()===Fl.name)];let s=0,a=n.width(),h=0,d=n.height();for(const e of o){const{x:n,y:r,width:i,height:o}=(e=>({x:this.render.toStageValue(e.x-t.x),y:this.render.toStageValue(e.y-t.y),width:this.render.toStageValue(e.width),height:this.render.toStageValue(e.height)}))(e.getClientRect());n<s&&(s=n),n+i>a&&(a=n+i),r<h&&(h=r),r+o>d&&(d=r+o)}n.setAttrs({x:this.render.toStageValue(-t.x+this.render.rulerSize+t.width-a*this.option.size-20),y:this.render.toStageValue(-t.y+this.render.rulerSize+t.height-d*this.option.size-20),width:a-s,height:d-h});const u=new e.Rect({name:this.constructor.name,x:s,y:h,width:n.width(),height:n.height(),stroke:"#666",strokeWidth:this.render.toStageValue(1),fill:this.render.getPageSettings().background&&"transparent"!==this.render.getPageSettings().background?this.render.getPageSettings().background:"#fff"}),l=()=>{this.state.moving=!0;const e=this.render.stage.getPointerPosition();if(e){const r=n.width()*this.option.size,i=n.height()*this.option.size,o=r-(t.width-e.x-20),s=i-(t.height-e.y-20),a=o/this.option.size,h=s/this.option.size;this.render.positionTool.updateCenter(a-this.render.rulerSize/this.option.size,h-this.render.rulerSize/this.option.size)}};u.on("mousedown",t=>{t.evt.button===jl.左键&&l(),t.evt.preventDefault()}),u.on("mousemove",t=>{this.state.moving&&l(),t.evt.preventDefault()}),u.on("mouseup",()=>{this.state.moving=!1}),n.add(u),n.add(new e.Rect({name:this.constructor.name,x:0,y:0,width:t.width,height:t.height,stroke:"rgba(255,0,0,0.2)",strokeWidth:1/this.option.size,listening:!1}));for(const e of o){const t=e.clone();t.find(".link-line").forEach(t=>{const e=t.dash();e&&2===e.length&&e.every(t=>1===t)&&t.dash([])}),t.find(".link-point").map(t=>t.destroy()),t.find(".link-manual-point").map(t=>t.destroy()),t.listening(!1),t.name(this.constructor.name),n.add(t)}if(t.scale>1){let r=this.render.toStageValue(-t.x+this.render.rulerSize),i=this.render.toStageValue(-t.y+this.render.rulerSize);r=r>s?r:s,r=r<a?r:a,i=i>h?i:h,i=i<d?i:d;let o=this.render.toStageValue(-t.x+this.render.rulerSize)+this.render.toStageValue(t.width),u=this.render.toStageValue(-t.y+this.render.rulerSize)+this.render.toStageValue(t.height);o=o>s?o:s,o=o<a?o:a,u=u>h?u:h,u=u<d?u:d;let l=[];r>s&&r<a&&o>s&&o<a&&i>h&&i<d&&u>h&&u<d&&(l=[[r,i],[o,i],[o,u],[r,u],[r,i]]),r>s&&r<a&&o>s&&o<a&&i===h&&i<d&&u>h&&u<d&&(l=[[o,i],[o,u],[r,u],[r,i]]),r>s&&r<a&&o>s&&o<a&&i>h&&i<d&&u>h&&u===d&&(l=[[r,u],[r,i],[o,i],[o,u]]),r===s&&r<a&&o>s&&o<a&&i>h&&i<d&&u>h&&u<d&&(l=[[r,i],[o,i],[o,u],[r,u]]),r>s&&r<a&&o>s&&o===a&&i>h&&i<d&&u>h&&u<d&&(l=[[o,i],[r,i],[r,u],[o,u]]),r===s&&r<a&&o>s&&o<a&&i===h&&i<d&&u>h&&u<d&&(l=[[o,i],[o,u],[r,u]]),r>s&&r<a&&o>s&&o===a&&i===h&&i<d&&u>h&&u<d&&(l=[[o,u],[r,u],[r,i]]),r===s&&r<a&&o>s&&o<a&&i>h&&i<d&&u>h&&u===d&&(l=[[r,i],[o,i],[o,u]]),r>s&&r<a&&o>s&&o===a&&i>h&&i<d&&u>h&&u===d&&(l=[[o,i],[r,i],[r,u]]),n.add(new e.Line({name:this.constructor.name,points:bt.flatten(l),stroke:"blue",strokeWidth:1/this.option.size,listening:!1}))}this.group.add(n)}}r(Bl,"name","preview");let Nl=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[t]];return e};function Dl(t){var e,n;const{from:r,to:i,matrix:o,maxCost:s=1}=t,a=function(t){const e=[];for(let n=0;n<t.length;n++){void 0===e[n]&&(e[n]=[]);for(let r=0;r<t[n].length;r++)e[n].push({x:r,y:n,cost:t[n][r]})}return e}(o),h=a[r.y][r.x],d=a[i.y][i.x],u=[h],l=new Set,c=new Map,f=new Map,g=new Map;for(f.set(h,0),g.set(h,y(h,d)),c.set(h,f.get(h)+g.get(h));u.length>0;){const t=u.reduce((t,e)=>c.get(t)<c.get(e)?t:e);if(t===d)return p(d);u.splice(u.indexOf(t),1),l.add(t);for(const r of m(t,a)){if(l.has(r))continue;const i=f.get(t)+(r.cost??1)+(t.x===(null==(e=t.parent)?void 0:e.x)&&t.x!==r.x||t.y===(null==(n=t.parent)?void 0:n.y)&&t.y!==r.y?a.length+a[0].length:0);(!u.includes(r)||i<f.get(r))&&(f.set(r,i),g.set(r,y(r,d)),c.set(r,f.get(r)+g.get(r)),r.parent=t,u.includes(r)||u.push(r))}}return[];function p(t){const e=[t];for(;t.parent;)e.push(t.parent),t=t.parent;return e.reverse()}function y(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function m(t,e){const n=[],{x:r,y:i}=t;return r>0&&(e[i][r-1].cost??0)<s&&n.push(e[i][r-1]),r<e[0].length-1&&(e[i][r+1].cost??0)<s&&n.push(e[i][r+1]),i>0&&(e[i-1][r].cost??0)<s&&n.push(e[i-1][r]),i<e.length-1&&(e[i+1][r].cost??0)<s&&n.push(e[i+1][r]),n}}const Gl=class t extends Il{constructor(t,e,n){super(t,e),r(this,"option"),r(this,"state",{linkingLine:null,linkType:zl.curve,linkManualing:!1}),this.option=n,this.group.name(this.constructor.name)}getGroupLinkArea(t){let n={x1:0,y1:0,x2:0,y2:0};if(t){const r=this.render.getStageState(),i=t.find(".link-anchor").map(t=>t.absolutePosition());if(n={x1:Math.min(...i.map(t=>t.x))-r.x,y1:Math.min(...i.map(t=>t.y))-r.y,x2:Math.max(...i.map(t=>t.x))-r.x,y2:Math.max(...i.map(t=>t.y))-r.y},this.render.debug){const t=new e.Rect({x:this.render.toStageValue(n.x1),y:this.render.toStageValue(n.y1),width:this.render.toStageValue(n.x2-n.x1),height:this.render.toStageValue(n.y2-n.y1),stroke:"rgba(255,0,0,0.5)",strokeWidth:1,listening:!1});this.group.add(t),t.zIndex(0)}}return n}getGroupForbiddenArea(t,n){const r={x1:t.x1-n,y1:t.y1-n,x2:t.x2+n,y2:t.y2+n};if(this.render.debug){const t=new e.Rect({x:this.render.toStageValue(r.x1),y:this.render.toStageValue(r.y1),width:this.render.toStageValue(r.x2-r.x1),height:this.render.toStageValue(r.y2-r.y1),stroke:"rgba(0,0,255,0.5)",strokeWidth:1,listening:!1});this.group.add(t),t.zIndex(0)}return r}getGroupAccessArea(t,n){const r={x1:t.x1-n,y1:t.y1-n,x2:t.x2+n,y2:t.y2+n};if(this.render.debug){const t=new e.Rect({x:this.render.toStageValue(r.x1),y:this.render.toStageValue(r.y1),width:this.render.toStageValue(r.x2-r.x1),height:this.render.toStageValue(r.y2-r.y1),stroke:"rgba(255,0,255,0.5)",strokeWidth:1,listening:!1});this.group.add(t),t.zIndex(0)}return r}getGroupPairArea(t,n){const r={x1:Math.min(t.x1,n.x1),y1:Math.min(t.y1,n.y1),x2:Math.max(t.x2,n.x2),y2:Math.max(t.y2,n.y2)};if(this.render.debug){const t=new e.Rect({x:this.render.toStageValue(r.x1),y:this.render.toStageValue(r.y1),width:this.render.toStageValue(r.x2-r.x1),height:this.render.toStageValue(r.y2-r.y1),stroke:"rgba(0,120,0,0.5)",strokeWidth:1,listening:!1});this.group.add(t),t.zIndex(1)}return r}getGroupPairDistance(t,e){const n=[t.x1,t.x2,e.x1,e.x2],r=Math.max(...n)-Math.min(...n)-(t.x2-t.x1+(e.x2-e.x1)),i=[t.y1,t.y2,e.y1,e.y2],o=Math.max(...i)-Math.min(...i)-(t.y2-t.y1+(e.y2-e.y1));return this.render.toBoardValue(Math.min(.5*this.render.bgSize,.5*Math.max(r<6?6:r,o<6?6:o)))}getGroupPairCenter(t,e){return{x:.5*(e.x1+t.x2),y:.5*(e.y1+t.y2)}}getEntry(t,e,n){const r=this.render.getStageState(),i=t.absolutePosition();let o=i.x-r.x,s=i.y-r.y;const a=t.attrs.direction;if(a){const h=Math.round(10*t.getAbsoluteRotation())/10;if(-45===h)"top"===a?(o=e.x1,s=e.y1):"bottom"===a?(o=e.x2,s=e.y2):"left"===a?(o=e.x1,s=e.y2):"right"===a&&(o=e.x2,s=e.y1);else if(45===h)"top"===a?(o=e.x2,s=e.y1):"bottom"===a?(o=e.x1,s=e.y2):"left"===a?(o=e.x1,s=e.y1):"right"===a&&(o=e.x2,s=e.y2);else if(135===h)"top"===a?(o=e.x2,s=e.y2):"bottom"===a?(o=e.x1,s=e.y1):"left"===a?(o=e.x2,s=e.y1):"right"===a&&(o=e.x1,s=e.y2);else if(-135===h)"top"===a?(o=e.x1,s=e.y2):"bottom"===a?(o=e.x2,s=e.y1):"left"===a?(o=e.x2,s=e.y2):"right"===a&&(o=e.x1,s=e.y1);else if(h>-45&&h<45){const t=n*Math.tan(h*Math.PI/180);"top"===a?(o=i.x-r.x+t,s=e.y1):"bottom"===a?(o=i.x-r.x-t,s=e.y2):"left"===a?(o=e.x1,s=i.y-r.y-t):"right"===a&&(o=e.x2,s=i.y-r.y+t)}else if(h>45&&h<135){const t=n*Math.atan((90-h)*Math.PI/180);"top"===a?(o=e.x2,s=i.y-r.y-t):"bottom"===a?(o=e.x1,s=i.y-r.y+t):"left"===a?(o=i.x-r.x-t,s=e.y1):"right"===a&&(o=i.x-r.x+t,s=e.y2)}else if(h>135&&h<=180||h>=-180&&h<-135){const t=n*Math.tan(h*Math.PI/180);"top"===a?(o=i.x-r.x-t,s=e.y2):"bottom"===a?(o=i.x-r.x+t,s=e.y1):"left"===a?(o=e.x2,s=i.y-r.y+t):"right"===a&&(o=e.x1,s=i.y-r.y-t)}else if(h>-135&&h<-45){const t=n*Math.atan((90+h)*Math.PI/180);"top"===a?(o=e.x1,s=i.y-r.y-t):"bottom"===a?(o=e.x2,s=i.y-r.y+t):"left"===a?(o=i.x-r.x-t,s=e.y2):"right"===a&&(o=i.x-r.x+t,s=e.y1)}}return{x:o,y:s}}getAnchorPos(t){const e=this.render.getStageState();return t?{x:t.absolutePosition().x-e.x,y:t.absolutePosition().y-e.y}:{x:0,y:0}}changeLinkType(t){this.state.linkType=t,this.render.emit("link-type-change",this.state.linkType)}draw(){var n,r,i,o;this.clear();const s=this.render.getStageState(),a=[...this.render.layer.find(".asset"),...this.render.layer.find(".sub-asset")],h=a.reduce((t,e)=>t.concat(Array.isArray(e.getAttr("points"))?e.getAttr("points"):[]),[]),d=h.reduce((t,e)=>t.concat(e.pairs?e.pairs.filter(t=>!t.disabled):[]),[]);this.render.debug&&d.length;for(const u of d)if(u.from.groupId!==u.to.groupId&&!u.disabled){const d=a.find(t=>t.id()===u.from.groupId),l=h.find(t=>t.id===u.from.pointId),c=a.find(t=>t.id()===u.to.groupId),f=h.find(t=>t.id===u.to.pointId);if(u.linkType===zl.manual){if(d&&c&&l&&f){const r=d.findOne(`#${l.id}`),i=c.findOne(`#${f.id}`),o=this.getAnchorPos(r),a=this.getAnchorPos(i),h=d.getAttr("manualPointsMap")??{},g=h[u.id]??[],p=[[this.render.toStageValue(o.x),this.render.toStageValue(o.y)],...g.map(t=>[t.x,t.y]),[this.render.toStageValue(a.x),this.render.toStageValue(a.y)]],y=new e.Arrow({name:"link-line",groupId:d.id(),pointId:l.id,pairId:u.id,linkType:u.linkType,points:bt.flatten(p),pointerAtBeginning:!1,pointerAtEnding:!1});if(y.stroke(this.render.getLinkSettings(y).stroke),y.strokeWidth(this.render.getLinkSettings(y).strokeWidth),y.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth,10)),y.dash((null==(n=this.render.linkTool.linkCurrent)?void 0:n.attrs.pairId)===u.id?[1,1]:[]),y.fill(this.render.getLinkSettings(y).stroke),y.pointerAtBeginning(this.render.getLinkSettings(y).arrowStart),y.pointerAtEnding(this.render.getLinkSettings(y).arrowEnd),this.render.config.readonly||(y.on("pointerclick",()=>{this.render.linkTool.select(y)}),y.on("mouseenter",()=>{y.opacity(.5),document.body.style.cursor="pointer"}),y.on("mouseleave",()=>{y.opacity(1),document.body.style.cursor="default"})),this.group.add(y),!this.render.config.readonly){const n=new e.Line({name:"manualing-line",stroke:"#ff0000",strokeWidth:2,points:[],dash:[4,4]});this.group.add(n);for(let r=0;r<p.length-1;r++){const i=new e.Circle({name:"link-manual-point",id:Nl(),pairId:u.id,x:(p[r][0]+p[r+1][0])/2,y:(p[r][1]+p[r+1][1])/2,radius:this.render.toStageValue(this.render.bgSize/2),stroke:"rgba(0,0,255,0.1)",strokeWidth:this.render.toStageValue(1),linkManualIndex:r});i.on("mouseenter",()=>{i.stroke("rgba(0,0,255,0.8)"),document.body.style.cursor="pointer"}),i.on("mouseleave",()=>{i.attrs.dragStart||(i.stroke("rgba(0,0,255,0.1)"),document.body.style.cursor="default")}),i.on("mousedown",()=>{const t=i.getAbsolutePosition();i.setAttrs({dragStartX:t.x,dragStartY:t.y,dragStart:!0}),this.state.linkManualing=!0}),this.render.stage.on("mousemove",()=>{if(i.attrs.dragStart){const t=this.render.stage.getPointerPosition();if(t){const{pos:e}=this.render.attractTool.attractPoint(t);i.setAbsolutePosition(e);const r=[...p];r.splice(i.attrs.linkManualIndex+1,0,[this.render.toStageValue(e.x-s.x),this.render.toStageValue(e.y-s.y)]),n.points(bt.flatten(r))}}}),i.on("mouseup",()=>{const e=i.getAbsolutePosition();if(Math.abs(e.x-i.attrs.dragStartX)>this.option.size||Math.abs(e.y-i.attrs.dragStartY)>this.option.size){const t=this.render.getStageState();g.splice(i.attrs.linkManualIndex,0,{x:this.render.toStageValue(e.x-t.x),y:this.render.toStageValue(e.y-t.y)}),h[u.id]=g,d.setAttr("manualPointsMap",h)}i.setAttrs({dragStart:!1}),this.state.linkManualing=!1,i.destroy(),n.destroy(),this.render.updateHistory(),this.render.attractTool.alignLinesClear(),this.render.redraw([t.name,Xl.name,Rl.name,Bl.name])}),this.group.add(i)}for(let r=1;r<p.length-1;r++){const i=new e.Circle({name:"link-manual-point",id:Nl(),pairId:u.id,x:p[r][0],y:p[r][1],radius:this.render.toStageValue(this.render.bgSize/2),stroke:"rgba(0,100,0,0.1)",strokeWidth:this.render.toStageValue(1),linkManualIndex:r});i.on("mouseenter",()=>{i.stroke("rgba(0,100,0,1)"),document.body.style.cursor="pointer"}),i.on("mouseleave",()=>{i.attrs.dragStart||(i.stroke("rgba(0,100,0,0.1)"),document.body.style.cursor="default")}),i.on("mousedown",()=>{const t=i.getAbsolutePosition();i.setAttrs({dragStartX:t.x,dragStartY:t.y,dragStart:!0}),this.state.linkManualing=!0}),this.render.stage.on("mousemove",()=>{if(i.attrs.dragStart){const t=this.render.stage.getPointerPosition();if(t){const{pos:e}=this.render.attractTool.attractPoint(t);i.setAbsolutePosition(e);const r=[...p];r[i.attrs.linkManualIndex]=[this.render.toStageValue(e.x-s.x),this.render.toStageValue(e.y-s.y)],n.points(bt.flatten(r))}}}),i.on("mouseup",()=>{const e=i.getAbsolutePosition();if(Math.abs(e.x-i.attrs.dragStartX)>this.option.size||Math.abs(e.y-i.attrs.dragStartY)>this.option.size){const t=this.render.getStageState();g[i.attrs.linkManualIndex-1]={x:this.render.toStageValue(e.x-t.x),y:this.render.toStageValue(e.y-t.y)},h[u.id]=g,d.setAttr("manualPointsMap",h)}i.setAttrs({dragStart:!1}),this.state.linkManualing=!1,i.destroy(),n.destroy(),this.render.updateHistory(),this.render.attractTool.alignLinesClear(),this.render.redraw([t.name,Xl.name,Rl.name,Bl.name])}),this.group.add(i)}}}}else if(u.linkType===zl.curve){if(d&&c&&l&&f){const n=d.findOne(`#${l.id}`),i=c.findOne(`#${f.id}`),o=this.getAnchorPos(n),a=this.getAnchorPos(i),h=d.getAttr("manualPointsMap")??{},g=h[u.id]??[],p=[[this.render.toStageValue(o.x),this.render.toStageValue(o.y)],...g.map(t=>[t.x,t.y]),[this.render.toStageValue(a.x),this.render.toStageValue(a.y)]],y=new e.Arrow({name:"link-line",groupId:d.id(),pointId:l.id,pairId:u.id,linkType:u.linkType,points:bt.flatten(p),pointerAtBeginning:!1,pointerAtEnding:!1});if(y.stroke(this.render.getLinkSettings(y).stroke),y.strokeWidth(this.render.getLinkSettings(y).strokeWidth),y.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth,10)),y.dash((null==(r=this.render.linkTool.linkCurrent)?void 0:r.attrs.pairId)===u.id?[1,1]:[]),y.fill(this.render.getLinkSettings(y).stroke),y.pointerAtBeginning(this.render.getLinkSettings(y).arrowStart),y.pointerAtEnding(this.render.getLinkSettings(y).arrowEnd),y.tension(this.render.getLinkSettings(y).tension||0),this.render.config.readonly||(y.on("pointerclick",()=>{this.render.linkTool.select(y)}),y.on("mouseenter",()=>{y.opacity(.5),document.body.style.cursor="pointer"}),y.on("mouseleave",()=>{y.opacity(1),document.body.style.cursor="default"})),this.group.add(y),!this.render.config.readonly){const n=new e.Arrow({name:"manualing-line",stroke:"#ff0000",strokeWidth:2,points:[],dash:[4,4],pointerAtBeginning:!1,pointerAtEnding:!1,tension:this.render.getLinkSettings(y).tension});this.group.add(n);for(let r=0;r<p.length-1;r++){const i=new e.Circle({name:"link-manual-point",id:Nl(),pairId:u.id,x:(p[r][0]+p[r+1][0])/2,y:(p[r][1]+p[r+1][1])/2,radius:this.render.toStageValue(this.render.bgSize/2),stroke:"rgba(0,0,255,0.1)",strokeWidth:this.render.toStageValue(1),linkManualIndex:r});i.on("mouseenter",()=>{i.stroke("rgba(0,0,255,0.8)"),document.body.style.cursor="pointer"}),i.on("mouseleave",()=>{i.attrs.dragStart||(i.stroke("rgba(0,0,255,0.1)"),document.body.style.cursor="default")}),i.on("mousedown",()=>{const t=i.getAbsolutePosition();i.setAttrs({dragStartX:t.x,dragStartY:t.y,dragStart:!0}),this.state.linkManualing=!0}),this.render.stage.on("mousemove",()=>{if(i.attrs.dragStart){const t=this.render.stage.getPointerPosition();if(t){const{pos:e}=this.render.attractTool.attractPoint(t);i.setAbsolutePosition(e);const r=[...p];r.splice(i.attrs.linkManualIndex+1,0,[this.render.toStageValue(e.x-s.x),this.render.toStageValue(e.y-s.y)]),n.points(bt.flatten(r))}}}),i.on("mouseup",()=>{const e=i.getAbsolutePosition();if(Math.abs(e.x-i.attrs.dragStartX)>this.option.size||Math.abs(e.y-i.attrs.dragStartY)>this.option.size){const t=this.render.getStageState();g.splice(i.attrs.linkManualIndex,0,{x:this.render.toStageValue(e.x-t.x),y:this.render.toStageValue(e.y-t.y)}),h[u.id]=g,d.setAttr("manualPointsMap",h)}i.setAttrs({dragStart:!1}),this.state.linkManualing=!1,i.destroy(),n.destroy(),this.render.updateHistory(),this.render.attractTool.alignLinesClear(),this.render.redraw([t.name,Xl.name,Rl.name,Bl.name])}),this.group.add(i)}for(let r=1;r<p.length-1;r++){const i=new e.Circle({name:"link-manual-point",id:Nl(),pairId:u.id,x:p[r][0],y:p[r][1],radius:this.render.toStageValue(this.render.bgSize/2),stroke:"rgba(0,100,0,0.1)",strokeWidth:this.render.toStageValue(1),linkManualIndex:r});i.on("mouseenter",()=>{i.stroke("rgba(0,100,0,1)"),document.body.style.cursor="pointer"}),i.on("mouseleave",()=>{i.attrs.dragStart||(i.stroke("rgba(0,100,0,0.1)"),document.body.style.cursor="default")}),i.on("mousedown",()=>{const t=i.getAbsolutePosition();i.setAttrs({dragStartX:t.x,dragStartY:t.y,dragStart:!0}),this.state.linkManualing=!0}),this.render.stage.on("mousemove",()=>{if(i.attrs.dragStart){const t=this.render.stage.getPointerPosition();if(t){const{pos:e}=this.render.attractTool.attractPoint(t);i.setAbsolutePosition(e);const r=[...p];r[i.attrs.linkManualIndex]=[this.render.toStageValue(e.x-s.x),this.render.toStageValue(e.y-s.y)],n.points(bt.flatten(r))}}}),i.on("mouseup",()=>{const e=i.getAbsolutePosition();if(Math.abs(e.x-i.attrs.dragStartX)>this.option.size||Math.abs(e.y-i.attrs.dragStartY)>this.option.size){const t=this.render.getStageState();g[i.attrs.linkManualIndex-1]={x:this.render.toStageValue(e.x-t.x),y:this.render.toStageValue(e.y-t.y)},h[u.id]=g,d.setAttr("manualPointsMap",h)}i.setAttrs({dragStart:!1}),this.state.linkManualing=!1,i.destroy(),n.destroy(),this.render.updateHistory(),this.render.attractTool.alignLinesClear(),this.render.redraw([t.name,Xl.name,Rl.name,Bl.name])}),this.group.add(i)}}}}else if(u.linkType===zl.bezier);else if(u.linkType===zl.straight){if(d&&c&&l&&f){const t=d.findOne(`#${l.id}`),n=c.findOne(`#${f.id}`),r=this.getAnchorPos(t),o=this.getAnchorPos(n),s=new e.Arrow({name:"link-line",groupId:d.id(),pointId:l.id,pairId:u.id,linkType:u.linkType,points:bt.flatten([[this.render.toStageValue(r.x),this.render.toStageValue(r.y)],[this.render.toStageValue(o.x),this.render.toStageValue(o.y)]]),pointerAtBeginning:!1,pointerAtEnding:!1});s.stroke(this.render.getLinkSettings(s).stroke),s.strokeWidth(this.render.getLinkSettings(s).strokeWidth),s.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth,10)),s.dash((null==(i=this.render.linkTool.linkCurrent)?void 0:i.attrs.pairId)===u.id?[1,1]:[]),s.fill(this.render.getLinkSettings(s).stroke),s.pointerAtBeginning(this.render.getLinkSettings(s).arrowStart),s.pointerAtEnding(this.render.getLinkSettings(s).arrowEnd),this.render.config.readonly||(s.on("pointerclick",()=>{this.render.linkTool.select(s)}),s.on("mouseenter",()=>{s.opacity(.5),document.body.style.cursor="pointer"}),s.on("mouseleave",()=>{s.opacity(1),document.body.style.cursor="default"})),this.group.add(s)}}else{const t=this.getGroupLinkArea(d),n=this.getGroupLinkArea(c),r=this.getGroupPairDistance(t,n),i=this.getGroupForbiddenArea(t,r-2),s=this.getGroupForbiddenArea(n,r-2),a=this.getGroupPairArea(i,s),h=this.getGroupPairArea(this.getGroupAccessArea(i,r),this.getGroupAccessArea(s,r));if(d&&c&&l&&f){const t=d.findOne(`#${l.id}`),n=c.findOne(`#${f.id}`),g=this.getAnchorPos(t),p=this.getAnchorPos(n);if(t&&n){this.render.debug;const c=this.getEntry(t,i,r),f=this.getEntry(n,s,r);let y=[];y.push({x:h.x1,y:h.y1}),y.push({x:h.x2,y:h.y2}),y.push({x:h.x1,y:h.y2}),y.push({x:h.x2,y:h.y1}),y.push({x:a.x1,y:a.y1}),y.push({x:a.x2,y:a.y2}),y.push({x:a.x1,y:a.y2}),y.push({x:a.x2,y:a.y1}),y.push({...g,type:"from"}),y.push({...c,type:"from-entry"}),y.push({...p,type:"to"}),y.push({...f,type:"to-entry"}),y.push(this.getGroupPairCenter(i,s)),y=y.reduce((t,e)=>{if(void 0===e.type)t.findIndex(t=>t.x===e.x&&t.y===e.y)<0&&t.push(e);else{const n=t.findIndex(t=>t.x===e.x&&t.y===e.y);n>-1&&t.splice(n,1),t.push(e)}return t},[]);const m=[...y.map(t=>t.x),i.x1,i.x2,s.x1,s.x2].sort((t,e)=>t-e);for(let t=m.length-1;t>0;t--)m[t]===m[t-1]&&m.splice(t,1);this.render.debug;const v=[...y.map(t=>t.y),i.y1,i.y2,s.y1,s.y2].sort((t,e)=>t-e);for(let t=v.length-1;t>0;t--)v[t]===v[t-1]&&v.splice(t,1);this.render.debug;const x=m.findIndex(t=>t===i.x1),w=m.findIndex(t=>t===i.x2),b=v.findIndex(t=>t===i.y1),S=v.findIndex(t=>t===i.y2),_=m.findIndex(t=>t===s.x1),A=m.findIndex(t=>t===s.x2),k=v.findIndex(t=>t===s.y1),j=v.findIndex(t=>t===s.y2);let I=null,T=null;const P=[];for(let e=0;e<v.length;e++){void 0===P[e]&&(P[e]=[]);for(let r=0;r<m.length;r++)P[e][r]=r>=x&&r<=w&&e>=b&&e<=S||r>=_&&r<=A&&e>=k&&e<=j?2:0,m[r]===c.x&&v[e]===c.y&&(P[e][r]=1,I={x:r,y:e}),m[r]===f.x&&v[e]===f.y&&(P[e][r]=1,T={x:r,y:e}),t.attrs.direction||m[r]!==c.x&&v[e]!==c.y||r>=x&&r<=w&&e>=b&&e<=S&&(P[e][r]=1),n.attrs.direction||m[r]!==f.x&&v[e]!==f.y||r>=_&&r<=A&&e>=k&&e<=j&&(P[e][r]=1)}if(this.render.debug,this.render.debug)for(const t of y)this.group.add(new e.Circle({id:Nl(),x:this.render.toStageValue(t.x),y:this.render.toStageValue(t.y),radius:this.render.toStageValue(3),stroke:void 0===t.type?"rgba(0,0,255,1)":["from","to"].includes(t.type)?"rgba(255,0,0,1)":"rgba(0,120,0,1)",strokeWidth:this.render.toStageValue(1),listening:!1}));if(I&&T){this.render.debug;const t=Dl({from:I,to:T,matrix:P,maxCost:2}),n=new e.Arrow({name:"link-line",groupId:d.id(),pointId:l.id,pairId:u.id,linkType:u.linkType,points:bt.flatten([[this.render.toStageValue(g.x),this.render.toStageValue(g.y)],...t.map(t=>[this.render.toStageValue(m[t.x]),this.render.toStageValue(v[t.y])]),[this.render.toStageValue(p.x),this.render.toStageValue(p.y)]]),pointerAtBeginning:!1,pointerAtEnding:!1});n.stroke(this.render.getLinkSettings(n).stroke),n.strokeWidth(this.render.getLinkSettings(n).strokeWidth),n.hitStrokeWidth(Math.max(this.render.getLinkSettings().strokeWidth,10)),n.dash((null==(o=this.render.linkTool.linkCurrent)?void 0:o.attrs.pairId)===u.id?[1,1]:[]),n.fill(this.render.getLinkSettings(n).stroke),n.pointerAtBeginning(this.render.getLinkSettings(n).arrowStart),n.pointerAtEnding(this.render.getLinkSettings(n).arrowEnd),this.render.config.readonly||(n.on("pointerclick",()=>{this.render.linkTool.select(n)}),n.on("mouseenter",()=>{n.opacity(.5),document.body.style.cursor="pointer"}),n.on("mouseleave",()=>{n.opacity(1),document.body.style.cursor="default"})),this.group.add(n)}}}}}if(!this.render.config.readonly)for(const u of h){const n=a.find(t=>t.id()===u.groupId);if(n&&!n.getAttr("selected")){const r=this.render.layer.findOne(`#${u.id}`);if(r){const i=new e.Circle({name:"link-point",id:u.id,groupId:n.id(),x:this.render.toStageValue(r.absolutePosition().x-s.x),y:this.render.toStageValue(r.absolutePosition().y-s.y),radius:this.render.toStageValue(this.option.size),stroke:"rgba(255,0,0,0.2)",strokeWidth:this.render.toStageValue(1),opacity:u.visible&&!this.render.draws[rc.name].state.adjusting?1:0});i.on("mouseenter",()=>{i.stroke("rgba(255,0,0,0.5)"),i.opacity(1),document.body.style.cursor="pointer"}),i.on("mouseleave",()=>{i.stroke("rgba(255,0,0,0.2)"),i.opacity(0),document.body.style.cursor="default"}),i.on("mousedown",()=>{this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear();const t=this.render.stage.getPointerPosition();t&&(this.state.linkingLine={group:n,circle:i,line:new e.Line({name:"linking-line",points:bt.flatten([[i.x(),i.y()],[this.render.toStageValue(t.x-s.x),this.render.toStageValue(t.y-s.y)]]),stroke:"blue",strokeWidth:1})},this.layer.add(this.state.linkingLine.line))}),i.on("mouseup",()=>{var e;if(this.state.linkingLine){const n=this.state.linkingLine;if(n.circle.id()!==i.id()){if(a.find(t=>t.id()===i.getAttr("groupId"))){const e=h.find(t=>t.id===n.circle.id());if(e){h.find(t=>t.id===n.circle.id())&&(Array.isArray(e.pairs)&&(e.pairs=[...e.pairs,{id:Nl(),from:{groupId:n.group.id(),pointId:n.circle.id()},to:{groupId:i.getAttr("groupId"),pointId:i.id()},linkType:this.state.linkType}]),this.render.updateHistory(),this.render.attractTool.alignLinesClear(),this.render.redraw([t.name,Xl.name,Rl.name,Bl.name]))}}}null==(e=this.state.linkingLine)||e.line.destroy(),this.state.linkingLine=null}}),this.group.add(i)}}}}};r(Gl,"name","Link");let Fl=Gl;class Xl extends Il{constructor(t,e,n){super(t,e),r(this,"option"),r(this,"on",{}),this.option=n,this.group.name(this.constructor.name)}draw(){if(this.clear(),this.render.debug){const t=this.render.getStageState(),n=this.render.layer.find(".asset").pop();if(n){this.render.selectionTool.selectingNodes=[n];const r=n.getClientRect(),{sortX:i,sortY:o}=this.render.attractTool.getSortItems(r);for(const n of i)this.group.add(new e.Line({name:this.constructor.name,points:bt.flatten([[n.value,this.render.toStageValue(this.render.rulerSize-t.y)],[n.value,this.render.toStageValue(this.render.rulerSize-t.y+t.height)]]),stroke:"rgba(0,200,0,1)",strokeWidth:1,dash:[4,4],listening:!1}));for(const n of o)this.group.add(new e.Line({name:this.constructor.name,points:bt.flatten([[this.render.toStageValue(this.render.rulerSize-t.x),n.value],[this.render.toStageValue(this.render.rulerSize-t.x+t.width),n.value]]),stroke:"rgba(0,200,0,1)",strokeWidth:1,dash:[4,4],listening:!1}))}}}}r(Xl,"name","Attract");class Ul{constructor(t,n,i){r(this,"render"),r(this,"group"),r(this,"hoverRect"),r(this,"id"),r(this,"dropPoint",{x:0,y:0}),r(this,"anchors",[]),r(this,"anchorShadows",[]),r(this,"linkAnchors",[]),r(this,"linkAnchorShadows",[]),this.render=t,this.dropPoint=n,this.id=Nl(),this.group=new e.Group({id:this.id,name:"asset",assetType:Cl.Graph,graphType:i.type,draggable:!0}),this.hoverRect=new e.Rect({name:"hoverRect",x:0,y:0,hitStrokeWidth:this.render.toStageValue(2*this.render.bgSize+2)}),this.anchors=i.anchors.map(t=>({...t,name:"anchor",groupId:this.group.id(),type:i.type})),this.group.setAttr("anchors",this.anchors);for(const r of this.anchors){const t=new e.Circle({adjustType:r.adjustType,anchorType:r.type,name:r.name,radius:0});this.anchorShadows.push(t),this.group.add(t)}this.linkAnchors=i.linkAnchors.map(t=>({...t,id:Nl(),groupId:this.group.id(),visible:!1,pairs:[],direction:t.direction,alias:t.alias})),this.group.setAttrs({points:this.linkAnchors});for(const r of this.linkAnchors){const t=new e.Circle({name:"link-anchor",id:r.id,x:r.x,y:r.y,radius:this.render.toStageValue(1),stroke:"rgba(0,0,255,1)",strokeWidth:this.render.toStageValue(2),visible:!1,direction:r.direction,alias:r.alias});this.linkAnchorShadows.push(t),this.group.add(t)}this.render.layer.add(this.group),this.render.redraw([rc.name])}static updateAnchorShadows(t,e){}static updateLinkAnchorShadows(t,e){}static createAnchorShapes(t,e,n,r){}static adjust(t,e,n,r,i,o,s,a,h,d){null==a||a.position({x:(null==d?void 0:d.x)??0,y:(null==d?void 0:d.y)??0}),null==a||a.size({width:(null==h?void 0:h.width)??e.width(),height:(null==h?void 0:h.height)??e.height()})}static draw(t,e,n){const r=t.attrs.anchors??[],i=t.find(".anchor");return{anchorAndShadows:r.map(t=>({anchor:t,anchorShadow:i.find(e=>e.attrs.adjustType===t.adjustType)})).filter(t=>void 0!==t.anchorShadow)}}drawEnd(t,e){var n;null==(n=this.hoverRect)||n.position({x:(null==e?void 0:e.x)??0,y:(null==e?void 0:e.y)??0}),this.hoverRect.size({width:(null==t?void 0:t.width)??this.group.width(),height:(null==t?void 0:t.height)??this.group.height()}),this.hoverRect.on("mouseenter",()=>{this.group.attrs.hoverAnchor||(this.group.setAttr("hover",!0),this.render.redraw([rc.name])),setTimeout(()=>{this.group.setAttr("hoverAnchor",!1)}),this.render.linkTool.pointsVisible(!0,this.group)}),this.hoverRect.on("mouseleave",()=>{var t;setTimeout(()=>{this.group.attrs.hoverAnchor||(this.group.setAttr("hover",!1),this.group.setAttr("hoverAnchor",!1),this.render.redraw([rc.name]))}),this.render.linkTool.pointsVisible(!1,this.group),null==(t=this.group.findOne("#hoverRect"))||t.visible(!1)}),this.group.add(this.hoverRect)}}const Yl=class t extends Ul{constructor(t,n){super(t,n,{type:Vl.Circle,anchors:[{adjustType:"top"},{adjustType:"bottom"},{adjustType:"left"},{adjustType:"right"},{adjustType:"top-left"},{adjustType:"top-right"},{adjustType:"bottom-left"},{adjustType:"bottom-right"}].map(t=>({adjustType:t.adjustType})),linkAnchors:[{x:0,y:0,alias:"top",direction:"top"},{x:0,y:0,alias:"bottom",direction:"bottom"},{x:0,y:0,alias:"left",direction:"left"},{x:0,y:0,alias:"right",direction:"right"},{x:0,y:0,alias:"center"}]}),r(this,"circle"),this.circle=new e.Ellipse({name:"graph",x:0,y:0,radiusX:0,radiusY:0,stroke:this.render.getPageSettings().stroke,strokeWidth:this.render.getPageSettings().strokeWidth}),this.group.add(this.circle),this.group.position(this.dropPoint)}static updateAnchorShadows(t,e){const{width:n,height:r}=t.size();for(const i of e)switch(i.attrs.adjustType){case"top":i.position({x:n/2,y:0});break;case"bottom":i.position({x:n/2,y:r});break;case"left":i.position({x:0,y:r/2});break;case"right":i.position({x:n,y:r/2});break;case"top-left":i.position({x:0,y:0});break;case"top-right":i.position({x:n,y:0});break;case"bottom-left":i.position({x:0,y:r});break;case"bottom-right":i.position({x:n,y:r})}}static updateLinkAnchorShadows(t,e){const{width:n,height:r}=t.size();for(const i of e)switch(i.attrs.alias){case"top":i.position({x:n/2,y:0});break;case"bottom":i.position({x:n/2,y:r});break;case"left":i.position({x:0,y:r/2});break;case"right":i.position({x:n,y:r/2});break;case"center":i.position({x:n/2,y:r/2})}}static createAnchorShapes(t,n,r,i){const o=t.getStageState();for(const s of r){const{anchor:r,anchorShadow:i}=s,a=t.toStageValue(i.getAbsolutePosition().x-o.x),h=t.toStageValue(i.getAbsolutePosition().y-o.y),d=t.toStageValue(t.pointSize+5),u=new e.Line({name:"anchor",anchor:r,stroke:"rgba(0,0,255,0.4)",strokeWidth:t.toStageValue(2),hitStrokeWidth:t.toStageValue(3),x:a,y:h,points:{"top-left":bt.flatten([[-d,d/2],[-d,-d],[d/2,-d]]),top:bt.flatten([[-d,-d],[d,-d]]),"top-right":bt.flatten([[-d/2,-d],[d,-d],[d,d/2]]),right:bt.flatten([[d,-d],[d,d]]),"bottom-right":bt.flatten([[-d/2,d],[d,d],[d,-d/2]]),bottom:bt.flatten([[-d,d],[d,d]]),"bottom-left":bt.flatten([[-d,-d/2],[-d,d],[d/2,d]]),left:bt.flatten([[-d,-d],[-d,d]])}[r.adjustType]??[],rotation:n.getAbsoluteRotation(),visible:n.attrs.adjusting||!0===n.attrs.hover});u.on("mouseenter",()=>{document.body.style.cursor="move",n.setAttr("hover",!0),n.setAttr("hoverAnchor",!0)}),u.on("mouseleave",()=>{document.body.style.cursor=u.attrs.adjusting?"move":"default",n.setAttr("hover",!1),n.setAttr("hoverAnchor",!1),t.redraw([rc.name])}),s.shape=u}return{anchorAndShadows:r}}static adjust(e,n,r,i,o,s,a,h){var d,u;const l=n.findOne(".graph"),c=r.findOne(".graph"),f=n.find(".anchor")??[],g=r.find(".anchor")??[],p=n.find(".link-anchor")??[];if(l&&c){const[s,h,c,y]=[Math.round(n.rotation()),null==(d=i.attrs.anchor)?void 0:d.adjustType,a.x,a.y];let m,v;switch(h){case"top":m=g.find(t=>"top"===t.attrs.adjustType),v=g.find(t=>"bottom"===t.attrs.adjustType);break;case"bottom":m=g.find(t=>"bottom"===t.attrs.adjustType),v=g.find(t=>"top"===t.attrs.adjustType);break;case"left":m=g.find(t=>"left"===t.attrs.adjustType),v=g.find(t=>"right"===t.attrs.adjustType);break;case"right":m=g.find(t=>"right"===t.attrs.adjustType),v=g.find(t=>"left"===t.attrs.adjustType);break;case"top-left":m=g.find(t=>"top-left"===t.attrs.adjustType),v=g.find(t=>"bottom-right"===t.attrs.adjustType);break;case"top-right":m=g.find(t=>"top-right"===t.attrs.adjustType),v=g.find(t=>"bottom-left"===t.attrs.adjustType);break;case"bottom-left":m=g.find(t=>"bottom-left"===t.attrs.adjustType),v=g.find(t=>"top-right"===t.attrs.adjustType);break;case"bottom-right":m=g.find(t=>"bottom-right"===t.attrs.adjustType),v=g.find(t=>"top-left"===t.attrs.adjustType)}if(m&&v){const{x:t,y:e}=m.getAbsolutePosition(),{x:i,y:o}=v.getAbsolutePosition();{const a=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-o,2)),d=Math.sqrt(Math.pow(c-i,2)+Math.pow(y-o,2))/a;let u=1,l=1;switch(h){case"top":l=s>=45&&s<135?c<=i?0:1:s>=-135&&s<-45?c>=i?0:1:s>=-45&&s<45?y>=o?0:1:y<=o?0:1;break;case"bottom":l=s>=45&&s<135?c<=i?1:0:s>=-135&&s<-45?c>=i?1:0:s>=-45&&s<45?y>=o?1:0:y<=o?1:0;break;case"left":u=s>=45&&s<135?y>=o?0:1:s>=-135&&s<-45?c<=i?0:1:s>=-45&&s<45?c>=i?0:1:y<=o?0:1;break;case"right":u=s>=45&&s<135?y>=o?1:0:s>=-135&&s<-45?c<=i?1:0:s>=-45&&s<45?c>=i?1:0:y<=o?1:0;break;case"top-left":s>-45&&s<45?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):45===s?y>=o?(u=0,l=0):(u=1,l=1):s>45&&s<135?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):135===s?c<=i?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):-135===s?y<=o?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):-45===s&&(c>=i?(u=0,l=0):(u=1,l=1));break;case"top-right":s>-45&&s<45?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):45===s?c<=i?(u=0,l=0):(u=1,l=1):s>45&&s<135?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):135===s?y<=o?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):-135===s?c>=i?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):-45===s&&(y>=o?(u=0,l=0):(u=1,l=1));break;case"bottom-left":s>-45&&s<45?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):45===s?c>=i?(u=0,l=0):(u=1,l=1):s>45&&s<135?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):135===s?y>=o?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):-135===s?c<=i?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):-45===s&&(y<=o?(u=0,l=0):(u=1,l=1));break;case"bottom-right":s>-45&&s<45?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):45===s?y<=o?(u=0,l=0):(u=1,l=1):s>45&&s<135?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):135===s?c>=i?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):-135===s?y>=o?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):-45===s&&(c<=i?(u=0,l=0):(u=1,l=1))}/-?(left|right)$/.test(h)&&n.width(Math.max(2,r.width()*d*u)),/^(top|bottom)-?/.test(h)&&n.height(Math.max(2,r.height()*d*l))}{const[t,e]=[n.width()*n.scaleX(),n.height()*n.scaleY()],r=Math.cos(s*Math.PI/180),a=Math.sin(s*Math.PI/180),d=Math.tan(s*Math.PI/180);switch(h){case"top":n.x(i-(t/2-e*d)*r),90!==s&&-90!==s&&n.y(o-(e/r+(t/2-e*d)*a));break;case"bottom":case"right":break;case"left":if([90,-90].includes(s))n.y(o-t);else if(180===Math.abs(s))n.x(i+t);else{const s=e/2/r,h=t-s*a,d=h*a;n.x(i-h*r),n.y(o-(s+d))}break;case"top-left":n.x(i-(t-e*d)*r),n.y(o-(t*a+e*r));break;case"top-right":n.x(i+e*a),n.y(o-e*r);break;case"bottom-left":n.x(i-t*r),n.y(o-t*a)}}}const[x,w]=[n.width(),n.height()];l.x(x/2),l.radiusX(x/2),l.y(w/2),l.radiusY(w/2),t.updateAnchorShadows(n,f),t.updateLinkAnchorShadows(n,p);const b=e.getStageState();for(const t of f)for(const{shape:r}of o)if(r&&(null==(u=r.attrs.anchor)?void 0:u.adjustType)===t.attrs.adjustType){const i=n.find(".anchor").find(e=>e.attrs.adjustType===t.attrs.adjustType);i&&(r.position({x:e.toStageValue(i.getAbsolutePosition().x-b.x),y:e.toStageValue(i.getAbsolutePosition().y-b.y)}),r.rotation(n.getAbsoluteRotation()))}e.redraw([rc.name,Fl.name,Bl.name])}Ul.adjust(e,n,r,i,o,s,a,h)}static draw(e,n,r){const{anchorAndShadows:i}=super.draw(e,n,r);return t.createAnchorShapes(n,e,i,r)}drawMove(e){let n=e.x-this.dropPoint.x,r=e.y-this.dropPoint.y;n<1&&(n=1),r<1&&(r=1);const i=n/2,o=r/2;this.circle.x(i),this.circle.y(o),this.circle.radiusX(i),this.circle.radiusY(o),this.group.size({width:n,height:r}),t.updateAnchorShadows(this.group,this.anchorShadows),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows),this.render.redraw([rc.name,Fl.name,Bl.name])}drawEnd(){if(this.circle.radiusX()<=1&&this.circle.radiusY()<=1){const e=t.size,n=e,r=t.size/2,i=r;this.circle.x(r),this.circle.y(i),this.circle.radiusX(r-this.circle.strokeWidth()),this.circle.radiusY(i-this.circle.strokeWidth()),this.group.size({width:e,height:n}),t.updateAnchorShadows(this.group,this.anchorShadows),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows),this.render.attractTool.alignLinesClear(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Bl.name])}super.drawEnd()}};r(Yl,"size",100);let Zl=Yl;const ql=class t extends Ul{constructor(t,n){super(t,n,{type:Vl.Rect,anchors:[{adjustType:"top"},{adjustType:"bottom"},{adjustType:"left"},{adjustType:"right"},{adjustType:"top-left"},{adjustType:"top-right"},{adjustType:"bottom-left"},{adjustType:"bottom-right"}].map(t=>({adjustType:t.adjustType})),linkAnchors:[{x:0,y:0,alias:"top",direction:"top"},{x:0,y:0,alias:"bottom",direction:"bottom"},{x:0,y:0,alias:"left",direction:"left"},{x:0,y:0,alias:"right",direction:"right"},{x:0,y:0,alias:"center"}]}),r(this,"rect"),this.rect=new e.Rect({name:"graph",x:0,y:0,width:0,height:0,stroke:this.render.getPageSettings().stroke,strokeWidth:this.render.getPageSettings().strokeWidth}),this.group.add(this.rect),this.group.position(this.dropPoint)}static updateAnchorShadows(t,e){const{width:n,height:r}=t.size();for(const i of e)switch(i.attrs.adjustType){case"top":i.position({x:n/2,y:0});break;case"bottom":i.position({x:n/2,y:r});break;case"left":i.position({x:0,y:r/2});break;case"right":i.position({x:n,y:r/2});break;case"top-left":i.position({x:0,y:0});break;case"top-right":i.position({x:n,y:0});break;case"bottom-left":i.position({x:0,y:r});break;case"bottom-right":i.position({x:n,y:r})}}static updateLinkAnchorShadows(t,e){const{width:n,height:r}=t.size();for(const i of e)switch(i.attrs.alias){case"top":i.position({x:n/2,y:0});break;case"bottom":i.position({x:n/2,y:r});break;case"left":i.position({x:0,y:r/2});break;case"right":i.position({x:n,y:r/2});break;case"center":i.position({x:n/2,y:r/2})}}static createAnchorShapes(t,n,r,i){const o=t.getStageState();for(const s of r){const{anchor:r,anchorShadow:i}=s,a=t.toStageValue(i.getAbsolutePosition().x-o.x),h=t.toStageValue(i.getAbsolutePosition().y-o.y),d=t.toStageValue(t.pointSize+5),u=new e.Line({name:"anchor",anchor:r,stroke:"rgba(0,0,255,0.4)",strokeWidth:t.toStageValue(2),hitStrokeWidth:t.toStageValue(3),x:a,y:h,points:{"top-left":bt.flatten([[-d,d/2],[-d,-d],[d/2,-d]]),top:bt.flatten([[-d,-d],[d,-d]]),"top-right":bt.flatten([[-d/2,-d],[d,-d],[d,d/2]]),right:bt.flatten([[d,-d],[d,d]]),"bottom-right":bt.flatten([[-d/2,d],[d,d],[d,-d/2]]),bottom:bt.flatten([[-d,d],[d,d]]),"bottom-left":bt.flatten([[-d,-d/2],[-d,d],[d/2,d]]),left:bt.flatten([[-d,-d],[-d,d]])}[r.adjustType]??[],rotation:n.getAbsoluteRotation(),visible:n.attrs.adjusting||!0===n.attrs.hover});u.on("mouseenter",()=>{document.body.style.cursor="move",n.setAttr("hover",!0),n.setAttr("hoverAnchor",!0)}),u.on("mouseleave",()=>{document.body.style.cursor=u.attrs.adjusting?"move":"default",n.setAttr("hover",!1),n.setAttr("hoverAnchor",!1),t.redraw([rc.name])}),s.shape=u}return{anchorAndShadows:r}}static adjust(e,n,r,i,o,s,a,h){var d,u;const l=n.findOne(".graph"),c=r.findOne(".graph"),f=n.find(".anchor")??[],g=r.find(".anchor")??[],p=n.find(".link-anchor")??[];if(l&&c){const[s,h,c,y]=[Math.round(n.rotation()),null==(d=i.attrs.anchor)?void 0:d.adjustType,a.x,a.y];let m,v;switch(h){case"top":m=g.find(t=>"top"===t.attrs.adjustType),v=g.find(t=>"bottom"===t.attrs.adjustType);break;case"bottom":m=g.find(t=>"bottom"===t.attrs.adjustType),v=g.find(t=>"top"===t.attrs.adjustType);break;case"left":m=g.find(t=>"left"===t.attrs.adjustType),v=g.find(t=>"right"===t.attrs.adjustType);break;case"right":m=g.find(t=>"right"===t.attrs.adjustType),v=g.find(t=>"left"===t.attrs.adjustType);break;case"top-left":m=g.find(t=>"top-left"===t.attrs.adjustType),v=g.find(t=>"bottom-right"===t.attrs.adjustType);break;case"top-right":m=g.find(t=>"top-right"===t.attrs.adjustType),v=g.find(t=>"bottom-left"===t.attrs.adjustType);break;case"bottom-left":m=g.find(t=>"bottom-left"===t.attrs.adjustType),v=g.find(t=>"top-right"===t.attrs.adjustType);break;case"bottom-right":m=g.find(t=>"bottom-right"===t.attrs.adjustType),v=g.find(t=>"top-left"===t.attrs.adjustType)}if(m&&v){const{x:t,y:e}=m.getAbsolutePosition(),{x:i,y:o}=v.getAbsolutePosition();{const a=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-o,2)),d=Math.sqrt(Math.pow(c-i,2)+Math.pow(y-o,2))/a;let u=1,l=1;switch(h){case"top":l=s>=45&&s<135?c<=i?0:1:s>=-135&&s<-45?c>=i?0:1:s>=-45&&s<45?y>=o?0:1:y<=o?0:1;break;case"bottom":l=s>=45&&s<135?c<=i?1:0:s>=-135&&s<-45?c>=i?1:0:s>=-45&&s<45?y>=o?1:0:y<=o?1:0;break;case"left":u=s>=45&&s<135?y>=o?0:1:s>=-135&&s<-45?c<=i?0:1:s>=-45&&s<45?c>=i?0:1:y<=o?0:1;break;case"right":u=s>=45&&s<135?y>=o?1:0:s>=-135&&s<-45?c<=i?1:0:s>=-45&&s<45?c>=i?1:0:y<=o?1:0;break;case"top-left":s>-45&&s<45?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):45===s?y>=o?(u=0,l=0):(u=1,l=1):s>45&&s<135?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):135===s?c<=i?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):-135===s?y<=o?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):-45===s&&(c>=i?(u=0,l=0):(u=1,l=1));break;case"top-right":s>-45&&s<45?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):45===s?c<=i?(u=0,l=0):(u=1,l=1):s>45&&s<135?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):135===s?y<=o?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):-135===s?c>=i?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):-45===s&&(y>=o?(u=0,l=0):(u=1,l=1));break;case"bottom-left":s>-45&&s<45?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):45===s?c>=i?(u=0,l=0):(u=1,l=1):s>45&&s<135?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):135===s?y>=o?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):-135===s?c<=i?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):-45===s&&(y<=o?(u=0,l=0):(u=1,l=1));break;case"bottom-right":s>-45&&s<45?c<=i&&y<=o?(u=0,l=0):(u=1,l=1):45===s?y<=o?(u=0,l=0):(u=1,l=1):s>45&&s<135?c>=i&&y<=o?(u=0,l=0):(u=1,l=1):135===s?c>=i?(u=0,l=0):(u=1,l=1):s>135&&s<=180||s>=-180&&s<-135?c>=i&&y>=o?(u=0,l=0):(u=1,l=1):-135===s?y>=o?(u=0,l=0):(u=1,l=1):s>-135&&s<-45?c<=i&&y>=o?(u=0,l=0):(u=1,l=1):-45===s&&(c<=i?(u=0,l=0):(u=1,l=1))}/-?(left|right)$/.test(h)&&n.width(Math.max(2,r.width()*d*u)),/^(top|bottom)-?/.test(h)&&n.height(Math.max(2,r.height()*d*l))}{const[t,e]=[n.width()*n.scaleX(),n.height()*n.scaleY()],r=Math.cos(s*Math.PI/180),a=Math.sin(s*Math.PI/180),d=Math.tan(s*Math.PI/180);switch(h){case"top":n.x(i-(t/2-e*d)*r),90!==s&&-90!==s&&n.y(o-(e/r+(t/2-e*d)*a));break;case"bottom":case"right":break;case"left":if([90,-90].includes(s))n.y(o-t);else if(180===Math.abs(s))n.x(i+t);else{const s=e/2/r,h=t-s*a,d=h*a;n.x(i-h*r),n.y(o-(s+d))}break;case"top-left":n.x(i-(t-e*d)*r),n.y(o-(t*a+e*r));break;case"top-right":n.x(i+e*a),n.y(o-e*r);break;case"bottom-left":n.x(i-t*r),n.y(o-t*a)}}}const[x,w]=[n.width(),n.height()];l.width(x),l.height(w),t.updateAnchorShadows(n,f),t.updateLinkAnchorShadows(n,p);const b=e.getStageState();for(const t of f)for(const{shape:r}of o)if(r&&(null==(u=r.attrs.anchor)?void 0:u.adjustType)===t.attrs.adjustType){const i=n.find(".anchor").find(e=>e.attrs.adjustType===t.attrs.adjustType);i&&(r.position({x:e.toStageValue(i.getAbsolutePosition().x-b.x),y:e.toStageValue(i.getAbsolutePosition().y-b.y)}),r.rotation(n.getAbsoluteRotation()))}e.redraw([rc.name,Fl.name,Bl.name])}Ul.adjust(e,n,r,i,o,s,a,h)}static draw(e,n,r){const{anchorAndShadows:i}=super.draw(e,n,r);return t.createAnchorShapes(n,e,i,r)}drawMove(e){let n=e.x-this.dropPoint.x,r=e.y-this.dropPoint.y;n<1&&(n=1),r<1&&(r=1),this.rect.width(n),this.rect.height(r),this.group.size({width:n,height:r}),t.updateAnchorShadows(this.group,this.anchorShadows),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows),this.render.redraw([rc.name,Fl.name,Bl.name])}drawEnd(){if(this.rect.width()<=1&&this.rect.height()<=1){const e=t.size,n=e;this.rect.width(e-this.rect.strokeWidth()),this.rect.height(n-this.rect.strokeWidth()),this.group.size({width:e,height:n}),t.updateAnchorShadows(this.group,this.anchorShadows),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows),this.render.attractTool.alignLinesClear(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Bl.name])}super.drawEnd()}};r(ql,"size",100);let $l=ql;const Hl=class t extends Ul{constructor(t,n){super(t,n,{type:Vl.Line,anchors:[{adjustType:"start"},{adjustType:"end"}].map(t=>({adjustType:t.adjustType})),linkAnchors:[{x:0,y:0,alias:"start"},{x:0,y:0,alias:"end"}]}),r(this,"line"),this.line=new e.Arrow({name:"graph",x:0,y:0,stroke:this.render.getPageSettings().stroke,strokeWidth:this.render.getPageSettings().strokeWidth,fill:this.render.getPageSettings().stroke,points:[],pointerAtBeginning:!1,pointerAtEnding:!1}),this.group.size({width:1,height:1}),this.group.add(this.line),this.group.position(this.dropPoint)}static updateAnchorShadows(t,e,n){if(n){const t=n.points();for(const n of e)switch(n.attrs.adjustType){case"start":n.position({x:t[0],y:t[1]});break;case"end":n.position({x:t[t.length-2],y:t[t.length-1]})}}}static updateLinkAnchorShadows(t,e,n){if(n){const t=n.points();for(const n of e)switch(n.attrs.alias){case"start":n.position({x:t[0],y:t[1]});break;case"end":n.position({x:t[t.length-2],y:t[t.length-1]})}}}static calculateAngle(t,e){if(!isNaN(t)&&!isNaN(e)){return Math.atan2(t,e)*(180/Math.PI)}return 0}static createAnchorShapes(n,r,i,o){const s=n.getStageState(),a=r.findOne(".graph");if(a){const o=a.points();for(const a of i){let i=0;const{anchor:h,anchorShadow:d}=a,u=n.toStageValue(d.getAbsolutePosition().x-s.x),l=n.toStageValue(d.getAbsolutePosition().y-s.y);if("manual"===h.adjustType){const t=new e.Circle({name:"anchor",anchor:h,fill:h.adjusted?"rgba(0,0,0,0.4)":"rgba(0,0,255,0.4)",radius:n.toStageValue(5),strokeWidth:0,x:u,y:l,rotation:r.getAbsoluteRotation(),visible:r.attrs.adjusting||!0===r.attrs.hover});t.on("mouseenter",()=>{document.body.style.cursor="move",r.setAttr("hover",!0),r.setAttr("hoverAnchor",!0)}),t.on("mouseleave",()=>{document.body.style.cursor=t.attrs.adjusting?"move":"default",r.setAttr("hover",!1),r.setAttr("hoverAnchor",!1),n.redraw([rc.name])}),a.shape=t}else{"start"===h.adjustType?i=t.calculateAngle(o[2]-o[0],o[3]-o[1]):"end"===h.adjustType&&(i=t.calculateAngle(o[o.length-2]-o[o.length-4],o[o.length-1]-o[o.length-3]));const s=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180),c=n.toStageValue(n.pointSize-20),f=c*d,g=c*s,p=new e.Circle({name:"anchor",anchor:h,fill:"rgba(0,0,255,0.4)",radius:n.toStageValue(5),strokeWidth:0,x:u,y:l,offsetX:"start"===h.adjustType?f:"end"===h.adjustType?-f:0,offsetY:"start"===h.adjustType?g:"end"===h.adjustType?-g:0,rotation:r.getAbsoluteRotation(),visible:r.attrs.adjusting||!0===r.attrs.hover});p.on("mouseenter",()=>{document.body.style.cursor="move",r.setAttr("hover",!0),r.setAttr("hoverAnchor",!0)}),p.on("mouseleave",()=>{document.body.style.cursor=p.attrs.adjusting?"move":"default",r.setAttr("hover",!1),r.setAttr("hoverAnchor",!1),n.redraw([rc.name])}),a.shape=p}}}return{anchorAndShadows:i}}static rotatePoint(t,e,n,r,i){const o=i*Math.PI/180;return{x:Math.cos(o)*(t-n)-Math.sin(o)*(e-r)+n,y:Math.sin(o)*(t-n)+Math.cos(o)*(e-r)+r}}static adjust(e,n,r,i,o,s,a,h){var d,u,l,c,f,g;const p=n.findOne(".graph"),y=r.findOne(".graph"),m=n.find(".anchor")??[],v=r.find(".anchor")??[],x=n.find(".link-anchor")??[];if(p&&y){const s=e.getStageState();{const[e,o,s,h]=[Math.round(n.rotation()),null==(d=i.attrs.anchor)?void 0:d.adjustType,a.x,a.y],{x:g,y:y,width:x,height:w}=r.getClientRect(),{x:b,y:S}=n.position(),[_,A]=[g+x/2,y+w/2],{x:k,y:j}=t.rotatePoint(s,h,_,A,-e),{x:I,y:T}=t.rotatePoint(b,S,_,A,-e),P=p.points(),M=p.attrs.manualPoints??[];if("manual"===o){if(void 0!==(null==(u=i.attrs.anchor)?void 0:u.manualIndex)){const t=(null==(l=i.attrs.anchor)?void 0:l.adjusted)?null==(c=i.attrs.anchor)?void 0:c.manualIndex:(null==(f=i.attrs.anchor)?void 0:f.manualIndex)+1,e=M.findIndex(e=>e.index===t);e>-1&&(M[e].x=(k-I)/n.scaleX(),M[e].y=(j-T)/n.scaleY());const r=[[P[0],P[1]],...M.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[P[P.length-2],P[P.length-1]]];p.setAttr("manualPoints",M),p.points(bt.flatten(r));const o=m.find(e=>"manual"===e.attrs.adjustType&&e.attrs.manualIndex===t);o&&o.position({x:(k-I)/n.scaleX(),y:(j-T)/n.scaleY()})}}else{const t=m.find(t=>t.attrs.adjustType===o),e=v.find(t=>t.attrs.adjustType===o);if(t&&e){const t=[[P[0],P[1]],...M.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[P[P.length-2],P[P.length-1]]];switch(o){case"start":t[0]=[(k-I)/n.scaleX(),(j-T)/n.scaleY()],p.points(bt.flatten(t));break;case"end":t[t.length-1]=[(k-I)/n.scaleX(),(j-T)/n.scaleY()],p.points(bt.flatten(t))}}}}t.updateAnchor(e,n),t.updateAnchorShadows(n,m,p),t.updateLinkAnchorShadows(n,x,p);for(const t of m)for(const{shape:r}of o)if(r&&(null==(g=r.attrs.anchor)?void 0:g.adjustType)===t.attrs.adjustType){const i=n.find(".anchor").find(e=>e.attrs.adjustType===t.attrs.adjustType);i&&(r.position({x:e.toStageValue(i.getAbsolutePosition().x-s.x),y:e.toStageValue(i.getAbsolutePosition().y-s.y)}),r.rotation(n.getAbsoluteRotation()))}e.redraw([rc.name,Fl.name,Bl.name])}Ul.adjust(e,n,r,i,o,s,a,h,p.size(),{x:Math.min(...p.points().reduce((t,e,n)=>(n%2==0&&t.push(e),t),[])),y:Math.min(...p.points().reduce((t,e,n)=>(n%2==1&&t.push(e),t),[]))})}static draw(e,n,r){const i=e.attrs.anchors??[],o=e.find(".anchor"),s=i.map(t=>({anchor:t,anchorShadow:o.find(e=>e.attrs.adjustType===t.adjustType&&e.attrs.manualIndex===t.manualIndex)})).filter(t=>void 0!==t.anchorShadow);return t.createAnchorShapes(n,e,s,r)}drawMove(e){const n=e.x-this.dropPoint.x,r=e.y-this.dropPoint.y,i=[[this.line.x(),this.line.y()],[this.line.x()+n,this.line.y()+r]];this.line.points(bt.flatten(i)),t.updateAnchorShadows(this.group,this.anchorShadows,this.line),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows,this.line),this.render.redraw([rc.name,Fl.name,Bl.name])}drawEnd(){if(this.line.width()<=10&&this.line.height()<=10){const e=t.size,n=e,r=[[this.line.x(),this.line.y()],[this.line.x()+e,this.line.y()+n]];this.line.points(bt.flatten(r))}t.updateAnchor(this.render,this.group),t.updateAnchorShadows(this.group,this.anchorShadows,this.line),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows,this.line);const e={width:this.line.size().width-10,height:this.line.size().height-10};this.group.size(e),this.render.attractTool.alignLinesClear(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Bl.name]),super.drawEnd(e,{x:Math.min(...this.line.points().reduce((t,e,n)=>(n%2==0&&t.push(e),t),[])),y:Math.min(...this.line.points().reduce((t,e,n)=>(n%2==1&&t.push(e),t),[]))})}static updateAnchor(t,n){const r=n.attrs.anchors??[],i=n.find(".anchor")??[],o=n.findOne(".graph");if(o){let t=o.attrs.manualPoints??[];const s=o.points(),a=[[s[0],s[1]],...t.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[s[s.length-2],s[s.length-1]]];r.splice(2);const h=i.splice(2);for(const e of h)e.remove(),e.destroy();t=[];for(let e=a.length-1;e>0;e--)a.splice(e,0,[]);for(let i=1;i<a.length-1;i++){const o={type:n.attrs.graphType,adjustType:"manual",name:"anchor",groupId:n.id(),manualIndex:i,adjusted:!1};if(0===a[i].length){o.adjusted=!1;const t=a[i-1],r=a[i+1],s=new e.Circle({adjustType:o.adjustType,anchorType:o.type,name:o.name,manualIndex:o.manualIndex,radius:0,x:(t[0]+r[0])/2,y:(t[1]+r[1])/2,anchor:o});n.add(s)}else{o.adjusted=!0;const r=new e.Circle({adjustType:o.adjustType,anchorType:o.type,name:o.name,manualIndex:o.manualIndex,adjusted:!0,radius:0,x:a[i][0],y:a[i][1],anchor:o});n.add(r),t.push({x:a[i][0],y:a[i][1],index:o.manualIndex})}r.push(o)}o.setAttr("manualPoints",t),n.setAttr("anchors",r)}}static adjustStart(e,n,r,i){const{x:o,y:s}=n.position(),a=n.findOne(".graph");if(a&&"number"==typeof r.manualIndex){const h=a.attrs.manualPoints??[];r.adjusted||(h.push({x:i.x-o,y:i.y-s,index:r.manualIndex}),a.setAttr("manualPoints",h)),t.updateAnchor(e,n)}}};r(Hl,"size",100);let Kl=Hl;const Jl=class t extends Ul{constructor(t,n){super(t,n,{type:Vl.Curve,anchors:[{adjustType:"start"},{adjustType:"end"}].map(t=>({adjustType:t.adjustType})),linkAnchors:[{x:0,y:0,alias:"start"},{x:0,y:0,alias:"end"}]}),r(this,"line"),this.line=new e.Arrow({name:"graph",x:0,y:0,stroke:this.render.getPageSettings().stroke,strokeWidth:this.render.getPageSettings().strokeWidth,fill:this.render.getPageSettings().stroke,points:[],pointerAtBeginning:!1,pointerAtEnding:!1,tension:0}),this.group.size({width:1,height:1}),this.group.add(this.line),this.group.position(this.dropPoint)}static updateAnchorShadows(t,e,n){if(n){const t=n.points();for(const n of e)switch(n.attrs.adjustType){case"start":n.position({x:t[0],y:t[1]});break;case"end":n.position({x:t[t.length-2],y:t[t.length-1]})}}}static updateLinkAnchorShadows(t,e,n){if(n){const t=n.points();for(const n of e)switch(n.attrs.alias){case"start":n.position({x:t[0],y:t[1]});break;case"end":n.position({x:t[t.length-2],y:t[t.length-1]})}}}static calculateAngle(t,e){if(!isNaN(t)&&!isNaN(e)){return Math.atan2(t,e)*(180/Math.PI)}return 0}static createAnchorShapes(n,r,i,o){const s=n.getStageState(),a=r.findOne(".graph");if(a){const o=a.points();for(const a of i){let i=0;const{anchor:h,anchorShadow:d}=a,u=n.toStageValue(d.getAbsolutePosition().x-s.x),l=n.toStageValue(d.getAbsolutePosition().y-s.y);if("manual"===h.adjustType){const t=new e.Circle({name:"anchor",anchor:h,fill:h.adjusted?"rgba(0,0,0,0.4)":"rgba(0,0,255,0.4)",radius:n.toStageValue(5),strokeWidth:0,x:u,y:l,rotation:r.getAbsoluteRotation(),visible:r.attrs.adjusting||!0===r.attrs.hover});t.on("mouseenter",()=>{document.body.style.cursor="move",r.setAttr("hover",!0),r.setAttr("hoverAnchor",!0)}),t.on("mouseleave",()=>{document.body.style.cursor=t.attrs.adjusting?"move":"default",r.setAttr("hover",!1),r.setAttr("hoverAnchor",!1),n.redraw([rc.name])}),a.shape=t}else{"start"===h.adjustType?i=t.calculateAngle(o[2]-o[0],o[3]-o[1]):"end"===h.adjustType&&(i=t.calculateAngle(o[o.length-2]-o[o.length-4],o[o.length-1]-o[o.length-3]));const s=Math.cos(i*Math.PI/180),d=Math.sin(i*Math.PI/180),c=n.toStageValue(n.pointSize-20),f=c*d,g=c*s,p=new e.Circle({name:"anchor",anchor:h,fill:"rgba(0,0,255,0.4)",radius:n.toStageValue(5),strokeWidth:0,x:u,y:l,offsetX:"start"===h.adjustType?f:"end"===h.adjustType?-f:0,offsetY:"start"===h.adjustType?g:"end"===h.adjustType?-g:0,rotation:r.getAbsoluteRotation(),visible:r.attrs.adjusting||!0===r.attrs.hover});p.on("mouseenter",()=>{document.body.style.cursor="move",r.setAttr("hover",!0),r.setAttr("hoverAnchor",!0)}),p.on("mouseleave",()=>{document.body.style.cursor=p.attrs.adjusting?"move":"default",r.setAttr("hover",!1),r.setAttr("hoverAnchor",!1),n.redraw([rc.name])}),a.shape=p}}}return{anchorAndShadows:i}}static rotatePoint(t,e,n,r,i){const o=i*Math.PI/180;return{x:Math.cos(o)*(t-n)-Math.sin(o)*(e-r)+n,y:Math.sin(o)*(t-n)+Math.cos(o)*(e-r)+r}}static adjust(e,n,r,i,o,s,a,h){var d,u,l,c,f,g;const p=n.findOne(".graph"),y=r.findOne(".graph"),m=n.find(".anchor")??[],v=r.find(".anchor")??[],x=n.find(".link-anchor")??[];if(p&&y){const s=e.getStageState();{const[e,o,s,h]=[Math.round(n.rotation()),null==(d=i.attrs.anchor)?void 0:d.adjustType,a.x,a.y],{x:g,y:y,width:x,height:w}=r.getClientRect(),{x:b,y:S}=n.position(),[_,A]=[g+x/2,y+w/2],{x:k,y:j}=t.rotatePoint(s,h,_,A,-e),{x:I,y:T}=t.rotatePoint(b,S,_,A,-e),P=p.points(),M=p.attrs.manualPoints??[];if("manual"===o){if(void 0!==(null==(u=i.attrs.anchor)?void 0:u.manualIndex)){const t=(null==(l=i.attrs.anchor)?void 0:l.adjusted)?null==(c=i.attrs.anchor)?void 0:c.manualIndex:(null==(f=i.attrs.anchor)?void 0:f.manualIndex)+1,e=M.findIndex(e=>e.index===t);e>-1&&(M[e].x=(k-I)/n.scaleX(),M[e].y=(j-T)/n.scaleY());const r=[[P[0],P[1]],...M.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[P[P.length-2],P[P.length-1]]];p.setAttr("manualPoints",M),p.points(bt.flatten(r));const o=m.find(e=>"manual"===e.attrs.adjustType&&e.attrs.manualIndex===t);o&&o.position({x:(k-I)/n.scaleX(),y:(j-T)/n.scaleY()})}}else{const t=m.find(t=>t.attrs.adjustType===o),e=v.find(t=>t.attrs.adjustType===o);if(t&&e){const t=[[P[0],P[1]],...M.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[P[P.length-2],P[P.length-1]]];switch(o){case"start":t[0]=[(k-I)/n.scaleX(),(j-T)/n.scaleY()],p.points(bt.flatten(t));break;case"end":t[t.length-1]=[(k-I)/n.scaleX(),(j-T)/n.scaleY()],p.points(bt.flatten(t))}}}}t.updateAnchor(e,n),t.updateAnchorShadows(n,m,p),t.updateLinkAnchorShadows(n,x,p);for(const t of m)for(const{shape:r}of o)if(r&&(null==(g=r.attrs.anchor)?void 0:g.adjustType)===t.attrs.adjustType){const i=n.find(".anchor").find(e=>e.attrs.adjustType===t.attrs.adjustType);i&&(r.position({x:e.toStageValue(i.getAbsolutePosition().x-s.x),y:e.toStageValue(i.getAbsolutePosition().y-s.y)}),r.rotation(n.getAbsoluteRotation()))}e.redraw([rc.name,Fl.name,Bl.name])}const w=p.points().reduce((t,e,n)=>(n%2==0&&t.push(e),t),[]),b=p.points().reduce((t,e,n)=>(n%2==1&&t.push(e),t),[]),S=Math.min(...w),_=Math.max(...w),A=Math.min(...b),k=Math.max(...b);Ul.adjust(e,n,r,i,o,s,a,h,{width:_-S,height:k-A},{x:S,y:A})}static draw(e,n,r){const i=e.attrs.anchors??[],o=e.find(".anchor"),s=i.map(t=>({anchor:t,anchorShadow:o.find(e=>e.attrs.adjustType===t.adjustType&&e.attrs.manualIndex===t.manualIndex)})).filter(t=>void 0!==t.anchorShadow);return t.createAnchorShapes(n,e,s,r)}drawMove(e){const n=e.x-this.dropPoint.x,r=e.y-this.dropPoint.y,i=[[this.line.x(),this.line.y()],[this.line.x()+n,this.line.y()+r]];this.line.points(bt.flatten(i)),t.updateAnchorShadows(this.group,this.anchorShadows,this.line),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows,this.line),this.render.redraw([rc.name,Fl.name,Bl.name])}drawEnd(){if(this.line.width()<=10&&this.line.height()<=10){const e=t.size,n=e,r=[[this.line.x(),this.line.y()],[this.line.x()+e,this.line.y()+n]];this.line.points(bt.flatten(r))}t.updateAnchor(this.render,this.group),t.updateAnchorShadows(this.group,this.anchorShadows,this.line),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows,this.line);const e={width:this.line.size().width-10,height:this.line.size().height-10};this.group.size(e),this.render.attractTool.alignLinesClear(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Bl.name]),super.drawEnd(e,{x:Math.min(...this.line.points().reduce((t,e,n)=>(n%2==0&&t.push(e),t),[])),y:Math.min(...this.line.points().reduce((t,e,n)=>(n%2==1&&t.push(e),t),[]))})}static updateAnchor(t,n){const r=n.attrs.anchors??[],i=n.find(".anchor")??[],o=n.findOne(".graph");if(o){let t=o.attrs.manualPoints??[];const s=o.points(),a=[[s[0],s[1]],...t.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[s[s.length-2],s[s.length-1]]];r.splice(2);const h=i.splice(2);for(const e of h)e.remove(),e.destroy();t=[];for(let e=a.length-1;e>0;e--)a.splice(e,0,[]);for(let i=1;i<a.length-1;i++){const o={type:n.attrs.graphType,adjustType:"manual",name:"anchor",groupId:n.id(),manualIndex:i,adjusted:!1};if(0===a[i].length){o.adjusted=!1;const t=a[i-1],r=a[i+1],s=new e.Circle({adjustType:o.adjustType,anchorType:o.type,name:o.name,manualIndex:o.manualIndex,radius:0,x:(t[0]+r[0])/2,y:(t[1]+r[1])/2,anchor:o});n.add(s)}else{o.adjusted=!0;const r=new e.Circle({adjustType:o.adjustType,anchorType:o.type,name:o.name,manualIndex:o.manualIndex,adjusted:!0,radius:0,x:a[i][0],y:a[i][1],anchor:o});n.add(r),t.push({x:a[i][0],y:a[i][1],index:o.manualIndex})}r.push(o)}o.setAttr("manualPoints",t),n.setAttr("anchors",r)}}static adjustStart(e,n,r,i){const{x:o,y:s}=n.position(),a=n.findOne(".graph");if(a&&"number"==typeof r.manualIndex){const h=a.attrs.manualPoints??[];r.adjusted||(h.push({x:i.x-o,y:i.y-s,index:r.manualIndex}),a.setAttr("manualPoints",h)),t.updateAnchor(e,n)}}};r(Jl,"size",100);let Ql=Jl;const tc=class t extends Ul{constructor(t,n){function i(t,e,n,r,i){const o=i*(Math.PI/180),s=Math.cos(o),a=Math.sin(o),h=n-t,d=r-e;return{x:s*h-a*d+t,y:a*h+s*d+e}}function o(t,e,n,r,o,s){const a=n+12,h=r-6,d=n+12,u=r+6,l=180*Math.atan2(s-r,o-n)/Math.PI,c=i(n,r,a,h,l),f=i(n,r,d,u,l);t.beginPath(),t.moveTo(n,r),t.lineTo(c.x,c.y),t.lineTo(f.x,f.y),t.lineTo(n,r),t.lineTo(c.x,c.y),t.strokeShape(e),t.fillShape(e)}super(t,n,{type:Vl.Bezier,anchors:[{adjustType:"start"},{adjustType:"end"}].map(t=>({adjustType:t.adjustType})),linkAnchors:[{x:0,y:0,alias:"start"},{x:0,y:0,alias:"end"}]}),r(this,"line"),this.line=new e.Arrow({name:"graph",x:0,y:0,stroke:this.render.getPageSettings().stroke,strokeWidth:this.render.getPageSettings().strokeWidth,fill:this.render.getPageSettings().stroke,points:[],pointerAtBeginning:!0,pointerAtEnding:!0,lineJoin:"miter",hitStrokeWidth:10,sceneFunc:(t,n)=>{if(n instanceof e.Arrow){const e=n.points();e.length/2==4?(t.beginPath(),t.moveTo(e[0],e[1]),t.bezierCurveTo(e[2],e[3],e[4],e[5],e[6],e[7]),t.strokeShape(n),t.closePath(),n.pointerAtBeginning()&&o(t,n,e[0],e[1],e[2],e[3]),n.pointerAtEnding()&&o(t,n,e[6],e[7],e[4],e[5])):e.length/2==3?(t.beginPath(),t.moveTo(e[0],e[1]),t.quadraticCurveTo(e[2],e[3],e[4],e[5]),t.strokeShape(n),t.closePath(),n.pointerAtBeginning()&&o(t,n,e[0],e[1],e[2],e[3]),n.pointerAtEnding()&&o(t,n,e[4],e[5],e[2],e[3])):(t.beginPath(),t.moveTo(e[0],e[1]),t.lineTo(e[2],e[3]),t.strokeShape(n),t.closePath(),n.pointerAtBeginning()&&o(t,n,e[0],e[1],e[2],e[3]),n.pointerAtEnding()&&o(t,n,e[2],e[3],e[0],e[1]))}}}),this.group.size({width:1,height:1}),this.group.add(this.line),this.group.position(this.dropPoint)}static updateAnchorShadows(t,e,n){if(n){const t=n.points();for(const n of e)switch(n.attrs.adjustType){case"start":n.position({x:t[0],y:t[1]});break;case"end":n.position({x:t[t.length-2],y:t[t.length-1]})}}}static updateLinkAnchorShadows(t,e,n){if(n){const t=n.points();for(const n of e)switch(n.attrs.alias){case"start":n.position({x:t[0],y:t[1]});break;case"end":n.position({x:t[t.length-2],y:t[t.length-1]})}}}static calculateAngle(t,e){if(!isNaN(t)&&!isNaN(e)){return Math.atan2(t,e)*(180/Math.PI)}return 0}static createAnchorShapes(n,r,i,o){const s=n.getStageState(),a=r.findOne(".graph");if(a){const o=a.points();for(const a of i){let h=0;const{anchor:d,anchorShadow:u}=a,l=n.toStageValue(u.getAbsolutePosition().x-s.x),c=n.toStageValue(u.getAbsolutePosition().y-s.y);if("manual"===d.adjustType){const t=new e.Circle({name:"anchor",anchor:d,fill:d.adjusted?"rgba(0,0,0,0.4)":"rgba(0,0,255,0.4)",radius:n.toStageValue(5),strokeWidth:0,x:l,y:c,rotation:r.getAbsoluteRotation(),visible:(r.attrs.adjusting||!0===r.attrs.hover)&&(d.adjusted||i.length<=6)});t.on("mouseenter",()=>{document.body.style.cursor="move",r.setAttr("hover",!0),r.setAttr("hoverAnchor",!0)}),t.on("mouseleave",()=>{document.body.style.cursor=t.attrs.adjusting?"move":"default",r.setAttr("hover",!1),r.setAttr("hoverAnchor",!1),n.redraw([rc.name])}),a.shape=t}else{"start"===d.adjustType?h=t.calculateAngle(o[2]-o[0],o[3]-o[1]):"end"===d.adjustType&&(h=t.calculateAngle(o[o.length-2]-o[o.length-4],o[o.length-1]-o[o.length-3]));const i=Math.cos(h*Math.PI/180),s=Math.sin(h*Math.PI/180),u=n.toStageValue(n.pointSize-20),f=u*s,g=u*i,p=new e.Circle({name:"anchor",anchor:d,fill:"rgba(0,0,255,0.4)",radius:n.toStageValue(5),strokeWidth:0,x:l,y:c,offsetX:"start"===d.adjustType?f:"end"===d.adjustType?-f:0,offsetY:"start"===d.adjustType?g:"end"===d.adjustType?-g:0,rotation:r.getAbsoluteRotation(),visible:r.attrs.adjusting||!0===r.attrs.hover});p.on("mouseenter",()=>{document.body.style.cursor="move",r.setAttr("hover",!0),r.setAttr("hoverAnchor",!0)}),p.on("mouseleave",()=>{document.body.style.cursor=p.attrs.adjusting?"move":"default",r.setAttr("hover",!1),r.setAttr("hoverAnchor",!1),n.redraw([rc.name])}),a.shape=p}}}return{anchorAndShadows:i}}static rotatePoint(t,e,n,r,i){const o=i*Math.PI/180;return{x:Math.cos(o)*(t-n)-Math.sin(o)*(e-r)+n,y:Math.sin(o)*(t-n)+Math.cos(o)*(e-r)+r}}static adjust(e,n,r,i,o,s,a,h){var d,u,l,c,f,g;const p=n.findOne(".graph"),y=r.findOne(".graph"),m=n.find(".anchor")??[],v=r.find(".anchor")??[],x=n.find(".link-anchor")??[];if(p&&y){const s=e.getStageState();{const[e,o,s,h]=[Math.round(n.rotation()),null==(d=i.attrs.anchor)?void 0:d.adjustType,a.x,a.y],{x:g,y:y,width:x,height:w}=r.getClientRect(),{x:b,y:S}=n.position(),[_,A]=[g+x/2,y+w/2],{x:k,y:j}=t.rotatePoint(s,h,_,A,-e),{x:I,y:T}=t.rotatePoint(b,S,_,A,-e),P=p.points(),M=p.attrs.manualPoints??[];if("manual"===o){if(void 0!==(null==(u=i.attrs.anchor)?void 0:u.manualIndex)){const t=(null==(l=i.attrs.anchor)?void 0:l.adjusted)?null==(c=i.attrs.anchor)?void 0:c.manualIndex:(null==(f=i.attrs.anchor)?void 0:f.manualIndex)+1,e=M.findIndex(e=>e.index===t);e>-1&&(M[e].x=(k-I)/n.scaleX(),M[e].y=(j-T)/n.scaleY());const r=[[P[0],P[1]],...M.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[P[P.length-2],P[P.length-1]]];p.setAttr("manualPoints",M),p.points(bt.flatten(r));const o=m.find(e=>"manual"===e.attrs.adjustType&&e.attrs.manualIndex===t);o&&o.position({x:(k-I)/n.scaleX(),y:(j-T)/n.scaleY()})}}else{const t=m.find(t=>t.attrs.adjustType===o),e=v.find(t=>t.attrs.adjustType===o);if(t&&e){const t=[[P[0],P[1]],...M.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[P[P.length-2],P[P.length-1]]];switch(o){case"start":t[0]=[(k-I)/n.scaleX(),(j-T)/n.scaleY()],p.points(bt.flatten(t));break;case"end":t[t.length-1]=[(k-I)/n.scaleX(),(j-T)/n.scaleY()],p.points(bt.flatten(t))}}}}t.updateAnchor(e,n),t.updateAnchorShadows(n,m,p),t.updateLinkAnchorShadows(n,x,p);for(const t of m)for(const{shape:r}of o)if(r&&(null==(g=r.attrs.anchor)?void 0:g.adjustType)===t.attrs.adjustType){const i=n.find(".anchor").find(e=>e.attrs.adjustType===t.attrs.adjustType);i&&(r.position({x:e.toStageValue(i.getAbsolutePosition().x-s.x),y:e.toStageValue(i.getAbsolutePosition().y-s.y)}),r.rotation(n.getAbsoluteRotation()))}e.redraw([rc.name,Fl.name,Bl.name])}const w=p.points().reduce((t,e,n)=>(n%2==0&&t.push(e),t),[]),b=p.points().reduce((t,e,n)=>(n%2==1&&t.push(e),t),[]),S=Math.min(...w),_=Math.max(...w),A=Math.min(...b),k=Math.max(...b);Ul.adjust(e,n,r,i,o,s,a,h,{width:_-S,height:k-A},{x:S,y:A})}static draw(e,n,r){const i=e.attrs.anchors??[],o=e.find(".anchor"),s=i.map(t=>({anchor:t,anchorShadow:o.find(e=>e.attrs.adjustType===t.adjustType&&e.attrs.manualIndex===t.manualIndex)})).filter(t=>void 0!==t.anchorShadow);return t.createAnchorShapes(n,e,s,r)}drawMove(e){const n=e.x-this.dropPoint.x,r=e.y-this.dropPoint.y,i=[[this.line.x(),this.line.y()],[this.line.x()+n,this.line.y()+r]];this.line.points(bt.flatten(i)),t.updateAnchorShadows(this.group,this.anchorShadows,this.line),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows,this.line),this.render.redraw([rc.name,Fl.name,Bl.name])}drawEnd(){if(this.line.width()<=10&&this.line.height()<=10){const e=t.size,n=e,r=[[this.line.x(),this.line.y()],[this.line.x()+e,this.line.y()+n]];this.line.points(bt.flatten(r))}t.updateAnchor(this.render,this.group),t.updateAnchorShadows(this.group,this.anchorShadows,this.line),t.updateLinkAnchorShadows(this.group,this.linkAnchorShadows,this.line);const e={width:this.line.size().width-10,height:this.line.size().height-10};this.group.size(e),this.render.attractTool.alignLinesClear(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Bl.name]),super.drawEnd(e,{x:Math.min(...this.line.points().reduce((t,e,n)=>(n%2==0&&t.push(e),t),[])),y:Math.min(...this.line.points().reduce((t,e,n)=>(n%2==1&&t.push(e),t),[]))})}static updateAnchor(t,n){const r=n.attrs.anchors??[],i=n.find(".anchor")??[],o=n.findOne(".graph");if(o){let t=o.attrs.manualPoints??[];const s=o.points(),a=[[s[0],s[1]],...t.sort((t,e)=>t.index-e.index).map(t=>[t.x,t.y]),[s[s.length-2],s[s.length-1]]];r.splice(2);const h=i.splice(2);for(const e of h)e.remove(),e.destroy();t=[];for(let e=a.length-1;e>0;e--)a.splice(e,0,[]);for(let i=1;i<a.length-1;i++){const o={type:n.attrs.graphType,adjustType:"manual",name:"anchor",groupId:n.id(),manualIndex:i,adjusted:!1};if(0===a[i].length){o.adjusted=!1;const t=a[i-1],r=a[i+1],s=new e.Circle({adjustType:o.adjustType,anchorType:o.type,name:o.name,manualIndex:o.manualIndex,radius:0,x:(t[0]+r[0])/2,y:(t[1]+r[1])/2,anchor:o});n.add(s)}else{o.adjusted=!0;const r=new e.Circle({adjustType:o.adjustType,anchorType:o.type,name:o.name,manualIndex:o.manualIndex,adjusted:!0,radius:0,x:a[i][0],y:a[i][1],anchor:o});n.add(r),t.push({x:a[i][0],y:a[i][1],index:o.manualIndex})}r.push(o)}o.setAttr("manualPoints",t),n.setAttr("anchors",r)}}static adjustStart(e,n,r,i){const{x:o,y:s}=n.position(),a=n.findOne(".graph");if(a&&"number"==typeof r.manualIndex){const h=a.attrs.manualPoints??[];r.adjusted||(h.push({x:i.x-o,y:i.y-s,index:r.manualIndex}),a.setAttr("manualPoints",h)),t.updateAnchor(e,n)}}};r(tc,"size",100);let ec=tc;const nc=class t extends Il{constructor(t,e,n){super(t,e),r(this,"option"),r(this,"on",{}),r(this,"state",{adjusting:!1,adjustGroupId:"",startPointCurrent:{x:0,y:0}}),this.option=n,this.group.name(this.constructor.name)}getStagePoint(t=!1){const e=this.render.stage.getPointerPosition();if(e){const n=this.render.getStageState();if(t){const{pos:t}=this.render.attractTool.attractPoint(e);return{x:this.render.toStageValue(t.x-n.x),y:this.render.toStageValue(t.y-n.y)}}return{x:this.render.toStageValue(e.x-n.x),y:this.render.toStageValue(e.y-n.y)}}return null}draw(){this.clear();const e=this.render.layer.find(".asset").filter(t=>t.attrs.assetType===Cl.Graph);for(const n of e)if(!n.attrs.selected){let e=[];switch(n.attrs.graphType){case Vl.Circle:{const t=Zl.draw(n,this.render,this.state.adjustAnchor);e=t.anchorAndShadows}break;case Vl.Rect:{const t=$l.draw(n,this.render,this.state.adjustAnchor);e=t.anchorAndShadows}break;case Vl.Line:{const t=Kl.draw(n,this.render,this.state.adjustAnchor);e=t.anchorAndShadows}break;case Vl.Curve:{const t=Ql.draw(n,this.render,this.state.adjustAnchor);e=t.anchorAndShadows}break;case Vl.Bezier:{const t=ec.draw(n,this.render,this.state.adjustAnchor);e=t.anchorAndShadows}}for(const r of e){const{shape:i}=r;i&&(i.on("mousedown",()=>{var t;const e=this.getStagePoint();if(e&&(this.state.adjusting=!0,this.state.adjustAnchor=i.attrs.anchor,this.state.adjustGroupId=n.id(),this.state.startPointCurrent=e,this.state.graphCurrent=n,this.state.graphCurrentSnap=n.clone(),n.setAttr("adjusting",!0),i.setAttr("adjusting",!0),this.state.adjustAnchor))switch(null==(t=i.attrs.anchor)?void 0:t.type){case Vl.Line:Kl.adjustStart(this.render,n,this.state.adjustAnchor,e);break;case Vl.Curve:Ql.adjustStart(this.render,n,this.state.adjustAnchor,e);break;case Vl.Bezier:ec.adjustStart(this.render,n,this.state.adjustAnchor,e)}}),this.render.stage.on("mousemove",()=>{var r;if(this.state.adjusting&&this.state.graphCurrent&&this.state.graphCurrentSnap&&i.attrs.adjusting){const o=this.getStagePoint(!0);if(o){switch(null==(r=i.attrs.anchor)?void 0:r.type){case Vl.Circle:Zl.adjust(this.render,n,this.state.graphCurrentSnap,i,e,this.state.startPointCurrent,o,n.findOne(".hoverRect"));break;case Vl.Rect:$l.adjust(this.render,n,this.state.graphCurrentSnap,i,e,this.state.startPointCurrent,o,n.findOne(".hoverRect"));break;case Vl.Line:Kl.adjust(this.render,n,this.state.graphCurrentSnap,i,e,this.state.startPointCurrent,o,n.findOne(".hoverRect"));break;case Vl.Curve:Ql.adjust(this.render,n,this.state.graphCurrentSnap,i,e,this.state.startPointCurrent,o,n.findOne(".hoverRect"));break;case Vl.Bezier:ec.adjust(this.render,n,this.state.graphCurrentSnap,i,e,this.state.startPointCurrent,o,n.findOne(".hoverRect"))}this.render.redraw([t.name,Fl.name,Bl.name])}}}),this.render.stage.on("mouseup",()=>{var r;n.setAttr("adjusting",!1),n.setAttr("hover",!1),n.setAttr("hoverAnchor",!1),this.state.adjusting&&(this.render.updateHistory(),this.render.redraw([t.name,Fl.name,Bl.name])),this.state.adjusting=!1,this.state.adjustAnchor=void 0,this.state.adjustGroupId="";for(const{shape:t}of e)t&&t.setAttr("adjusting",!1);document.body.style.cursor="default",null==(r=this.state.graphCurrentSnap)||r.destroy(),this.render.attractTool.alignLinesClear()}),this.group.add(i))}}}};r(nc,"name","Graph");let rc=nc;class ic{constructor(t){r(this,"render"),r(this,"mousedownRight",!1),r(this,"mousedownStagePos",{x:0,y:0}),r(this,"mousedownPointerPos",{x:0,y:0}),r(this,"handlers",{stage:{mousedown:t=>{var e;if(!(null==(e=this.render.draws[Fl.name])?void 0:e.state.linkManualing)&&!this.render.graphType&&(t.evt.button===jl.右键||t.evt.ctrlKey&&t.evt.button===jl.左键)){const t=this.render.getStageState();this.mousedownRight=!0,this.render.changeDraggable(!1),this.mousedownStagePos={x:t.x,y:t.y};const e=this.render.stage.getPointerPosition();e&&(this.mousedownPointerPos={x:e.x,y:e.y}),document.body.style.cursor="pointer"}},mouseup:()=>{this.mousedownRight=!1,this.render.changeDraggable(!this.render.config.readonly),document.body.style.cursor="default"},mousemove:()=>{if(this.mousedownRight){const t=this.render.stage.getPointerPosition();if(t){const e=t.x-this.mousedownPointerPos.x,n=t.y-this.mousedownPointerPos.y;this.render.stage.position({x:this.mousedownStagePos.x+e,y:this.mousedownStagePos.y+n}),this.render.redraw([El.name,rc.name,Fl.name,Rl.name,Bl.name])}}}}}),this.render=t}}r(ic,"name","Drag");class oc{constructor(t){r(this,"render"),r(this,"scaleBy",.1),r(this,"scaleMin",.2),r(this,"scaleMax",5),r(this,"handlers",{stage:{wheel:t=>{const{scale:e}=this.render.getStageState(),n=t.evt.ctrlKey,r=n?e+(t.evt.deltaY<0?this.scaleBy:-this.scaleBy):e,i=Math.max(this.scaleMin,Math.min(this.scaleMax,r));if(i!==e){const n=this.render.stage.getPosition(),r={x:t.evt.offsetX,y:t.evt.offsetY},o={x:(r.x-n.x)/e,y:(r.y-n.y)/e},s={x:-(o.x*i-r.x),y:-(o.y*i-r.y)};this.render.emit("scale-change",i),this.render.stage.scale({x:i,y:i}),this.render.stage.position(s)}else if(!n){const e=this.render.stage.getPosition();this.render.stage.position({x:e.x-t.evt.deltaX,y:e.y-t.evt.deltaY})}this.render.redraw([El.name,rc.name,Fl.name,Rl.name,Ll.name,Bl.name])}}}),this.render=t}}r(oc,"name","Zoom");class sc{constructor(t){r(this,"render"),r(this,"handlers",{dom:{dragenter:t=>{this.render.stage.setPointersPositions(t),this.render.redraw([Ll.name])},dragover:t=>{this.render.stage.setPointersPositions(t),this.render.redraw([Ll.name])},drop:t=>{var n,r,i;const o=null==(n=t.dataTransfer)?void 0:n.getData("src");let s=[];const a=(null==(r=t.dataTransfer)?void 0:r.getData("points"))??"[]";try{s=JSON.parse(a)}catch(d){}const h=null==(i=t.dataTransfer)?void 0:i.getData("type");if(o&&h){const n=this.render.getStageState();this.render.stage.setPointersPositions(t);const r=this.render.stage.getPointerPosition();r&&this.render.assetTool[h===Ol.svg?"loadSvg":h===Ol.gif?"loadGif":"json"===h?"loadJson":"loadImg"](o).then(t=>{let i=null,o=[];t instanceof e.Image?(i=new e.Group({id:Nl(),width:t.width(),height:t.height(),name:"asset",assetType:Cl.Image,draggable:!0,imageType:"json"!==h?h===Ol.svg?Ol.svg:h===Ol.gif?Ol.gif:Ol.other:void 0}),this.render.setAssetSettings(i,this.render.getAssetSettings(),!1),i.add(t),o=[{x:0,y:i.height()/2,direction:"left"},{x:i.width(),y:i.height()/2,direction:"right"},{x:i.width()/2,y:0,direction:"top"},{x:i.width()/2,y:i.height(),direction:"bottom"}]):(t.id(Nl()),t.setAttrs({name:"asset",assetType:Cl.Json,draggable:!0}),i=t,this.render.linkTool.groupIdCover(i)),t.setAttrs({x:0,y:0}),this.render.layer.add(i);const a=this.render.toStageValue(r.x-n.x)-i.width()/2,d=this.render.toStageValue(r.y-n.y)-i.height()/2;i.setAttrs({x:a,y:d}),this.render.setAssetSettings(i,this.render.getAssetSettings(i),!1),Array.isArray(s)&&s.length>0&&(o=s),i.setAttrs({points:o.map(t=>({...t,id:Nl(),groupId:i.id(),visible:!1,pairs:[],direction:t.direction}))});for(const n of i.getAttr("points")??[])i.add(new e.Circle({name:"link-anchor",id:n.id,x:n.x,y:n.y,radius:this.render.toStageValue(1),stroke:"rgba(0,0,255,1)",strokeWidth:this.render.toStageValue(2),visible:!1,direction:n.direction}));i.on("mouseenter",()=>{this.render.linkTool.pointsVisible(!0,i)}),i.add(new e.Rect({id:"hoverRect",width:t.width(),height:t.height(),fill:"rgba(0,255,0,0.3)",visible:!1})),i.on("mouseleave",()=>{var t;this.render.linkTool.pointsVisible(!1,i),null==(t=i.findOne("#hoverRect"))||t.visible(!1)}),this.render.updateHistory(),this.render.redraw([Bl.name])})}}}}),this.render=t}}r(sc,"name","DragOutside");class ac{constructor(t){r(this,"render"),r(this,"selectRectStartX",0),r(this,"selectRectStartY",0),r(this,"selectRectEndX",0),r(this,"selectRectEndY",0),r(this,"selecting",!1),r(this,"transformerMousedownPos",{x:0,y:0}),r(this,"alignLines",[]),r(this,"lastRotation",0),r(this,"handlers",{stage:{mousedown:t=>{if(!this.render.graphType){const n=t.target.getParent();if(t.target===this.render.stage){if(this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear(),t.evt.button===jl.左键&&!t.evt.ctrlKey){const t=this.render.stage.getPointerPosition();t&&(this.selectRectStartX=t.x,this.selectRectStartY=t.y,this.selectRectEndX=t.x,this.selectRectEndY=t.y),this.render.selectRect.width(0),this.render.selectRect.height(0),this.selecting=!0}this.render.linkTool.pointsVisible(!1)}else if(n instanceof e.Transformer);else if(n instanceof e.Group)if(t.evt.button!==jl.左键||t.evt.ctrlKey)this.render.selectionTool.selectingClear();else if(!this.render.ignore(n)&&!this.render.ignoreDraw(t.target))if(t.evt.ctrlKey||t.evt.metaKey)this.render.selectionTool.select([...this.render.selectionTool.selectingNodes,n]);else{this.render.selectionTool.select([n]);const t=n.getClientRect();this.transformerMousedownPos={x:t.x,y:t.y}}}},mousemove:()=>{const t=this.render.getStageState();if(this.selecting){const e=this.render.stage.getPointerPosition();e&&(this.selectRectEndX=e.x,this.selectRectEndY=e.y),this.render.selectRect.setAttrs({visible:!0,x:this.render.toStageValue(Math.min(this.selectRectStartX,this.selectRectEndX)-t.x),y:this.render.toStageValue(Math.min(this.selectRectStartY,this.selectRectEndY)-t.y),width:this.render.toStageValue(Math.abs(this.selectRectEndX-this.selectRectStartX)),height:this.render.toStageValue(Math.abs(this.selectRectEndY-this.selectRectStartY))})}},mouseup:()=>{const t=this.render.selectRect.getClientRect();if(t.width>0&&t.height>0){const n=this.render.layer.getChildren(t=>!this.render.ignore(t)).filter(n=>e.Util.haveIntersection(t,n.getClientRect()));this.render.selectionTool.select(n)}this.render.selectRect.setAttrs({visible:!1,x:0,y:0,width:0,height:0}),this.selecting=!1}},transformer:{mousedown:t=>{if(this.render.transformer.getActiveAnchor())this.reset();else if(t.evt.ctrlKey||t.evt.metaKey){if(this.render.selectionTool.selectingNodes.length>0){const t=this.render.stage.getPointerPosition();if(t){const n=[],r=[];let i=!1;for(const o of this.render.selectionTool.selectingNodes.sort((t,e)=>e.zIndex()-t.zIndex()))!i&&e.Util.haveIntersection(o.getClientRect(),{...t,width:1,height:1})?(r.unshift(o),i=!0):n.unshift(o);if(r.length>0)this.render.selectionTool.select(n);else{let n=!1;const r=[];for(const i of this.render.layer.getChildren().filter(t=>!this.render.ignore(t)).sort((t,e)=>e.zIndex()-t.zIndex()))!n&&e.Util.haveIntersection(i.getClientRect(),{...t,width:1,height:1})&&(r.unshift(i),n=!0);r.length>0&&this.render.selectionTool.select([...this.render.selectionTool.selectingNodes,...r])}}}}else this.render.selectionTool.selectingNodes.length>0&&this.reset()},transformstart:()=>{const t=this.render.transformer.findOne(".back");t&&(this.lastRotation=t.getAbsoluteRotation())},transform:()=>{const t=this.render.transformer.findOne(".back");if(t){const e=this.render.getStageState(),{x:n,y:r,width:i,height:o}=t.getClientRect(),s=t.getAbsoluteRotation()-this.lastRotation,a=n+i/2,h=r+o/2,d=this.render.transformer.nodes(),u=d.reduce((t,e)=>t.concat(Array.isArray(e.getAttr("points"))?e.getAttr("points"):[]),[]).reduce((t,e)=>t.concat(e.pairs?e.pairs.filter(t=>!t.disabled):[]),[]);for(const t of u){const n=d.find(e=>e.id()===t.from.groupId),r=d.find(e=>e.id()===t.to.groupId);if(n&&r&&n.attrs.manualPointsMap&&n.attrs.manualPointsMapBefore){let r=n.attrs.manualPointsMap[t.id];const i=n.attrs.manualPointsMapBefore[t.id];Array.isArray(r)&&Array.isArray(i)&&(r=i.map(t=>{const{x:n,y:r}=this.rotatePoint(this.render.toBoardValue(t.x)+e.x,this.render.toBoardValue(t.y)+e.y,a,h,s);return{x:this.render.toStageValue(n-e.x),y:this.render.toStageValue(r-e.y)}}),n.setAttr("manualPointsMap",{...n.attrs.manualPointsMap,[t.id]:r}))}}for(const t of d)this.render.setAssetSettings(t,this.render.getAssetSettings(t),!1);this.render.emit("asset-position-change",d),this.render.emit("asset-rotation-change",d)}this.render.redraw([rc.name,Fl.name,Bl.name])},transformend:()=>{this.reset(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Bl.name])},dragstart:()=>{},dragmove:()=>{const t=this.render.transformer.findOne(".back").getClientRect(),{pos:e,isAttract:n}=this.render.attractTool.attractTransformer(t);n&&this.selectingNodesPositionByOffset({x:this.render.toStageValue(e.x-this.transformerMousedownPos.x),y:this.render.toStageValue(e.y-this.transformerMousedownPos.y)});const r=this.render.transformer.nodes(),i=r.reduce((t,e)=>t.concat(Array.isArray(e.getAttr("points"))?e.getAttr("points"):[]),[]).reduce((t,e)=>t.concat(e.pairs?e.pairs.filter(t=>!t.disabled):[]),[]);for(const o of i){const i=r.find(t=>t.id()===o.from.groupId),s=r.find(t=>t.id()===o.to.groupId);if(i&&s&&i.attrs.manualPointsMap&&i.attrs.manualPointsMapBefore){let r=i.attrs.manualPointsMap[o.id];const s=i.attrs.manualPointsMapBefore[o.id];Array.isArray(r)&&Array.isArray(s)&&(r=n?s.map(t=>({x:t.x+this.render.toStageValue(e.x-this.transformerMousedownPos.x),y:t.y+this.render.toStageValue(e.y-this.transformerMousedownPos.y)})):s.map(e=>({x:e.x+this.render.toStageValue(t.x-this.transformerMousedownPos.x),y:e.y+this.render.toStageValue(t.y-this.transformerMousedownPos.y)})),i.setAttr("manualPointsMap",{...i.attrs.manualPointsMap,[o.id]:r}))}}for(const o of r)this.render.setAssetSettings(o,this.render.getAssetSettings(o),!1);this.render.emit("asset-position-change",r),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])},dragend:()=>{this.reset(),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])},mousemove:()=>{var t,n;const r=this.render.stage.getPointerPosition();if(r){const i=this.render.transformer.nodes();for(const n of i)n instanceof e.Group&&(null==(t=n.findOne("#hoverRect"))||t.visible(!1));if(i.length>1){i.sort((t,e)=>e.zIndex()-t.zIndex());const t=i.find(t=>e.Util.haveIntersection({...r,width:1,height:1},t.getClientRect()));t&&t instanceof e.Group&&(null==(n=t.findOne("#hoverRect"))||n.visible(!0))}}},mouseleave:()=>{var t;for(const n of this.render.transformer.nodes())n instanceof e.Group&&(null==(t=n.findOne("#hoverRect"))||t.visible(!1))}}}),r(this,"transformerConfig",{anchorDragBoundFunc:(t,e)=>{if(!this.render.config.readonly&&this.render.config.attractResize){const t=this.render.transformer.getActiveAnchor();if(t&&"rotater"!==t){const t=this.render.getStageState(),n=this.render.toStageValue(e.x-t.x),r=Math.round(n/this.render.bgSize)*this.render.bgSize,i=Math.abs(n-r)<5,o=this.render.toStageValue(e.y-t.y),s=Math.round(o/this.render.bgSize)*this.render.bgSize,a=Math.abs(o-s)<5;if(i||a)return{x:i?this.render.toBoardValue(r)+t.x:e.x,y:a?this.render.toBoardValue(s)+t.y:e.y}}}return e}}),this.render=t}alignLinesClear(){for(const t of this.alignLines)t.destroy();this.alignLines=[]}selectingNodesPositionByOffset(t){for(const e of this.render.selectionTool.selectingNodes)if(e.attrs.nodeMousedownPos){const n=e.attrs.nodeMousedownPos.x+t.x,r=e.attrs.nodeMousedownPos.y+t.y;e.x(n),e.y(r)}}selectingNodesPositionReset(){for(const t of this.render.selectionTool.selectingNodes)t.attrs.nodeMousedownPos&&(t.attrs.nodeMousedownPos.x=t.x(),t.attrs.nodeMousedownPos.y=t.y())}transformerStateReset(){const t=this.render.transformer.findOne(".back").getClientRect();this.transformerMousedownPos={x:t.x,y:t.y};const e=this.render.transformer.nodes(),n=e.reduce((t,e)=>t.concat(Array.isArray(e.getAttr("points"))?e.getAttr("points"):[]),[]).reduce((t,e)=>t.concat(e.pairs?e.pairs.filter(t=>!t.disabled):[]),[]);for(const r of n){const t=e.find(t=>t.id()===r.from.groupId),n=e.find(t=>t.id()===r.to.groupId);t&&n&&t.setAttr("manualPointsMapBefore",t.getAttr("manualPointsMap")??{})}}reset(){this.render.attractTool.alignLinesClear(),this.transformerStateReset(),this.selectingNodesPositionReset()}rotatePoint(t,e,n,r,i){const o=i*Math.PI/180;return{x:Math.cos(o)*(t-n)-Math.sin(o)*(e-r)+n,y:Math.sin(o)*(t-n)+Math.cos(o)*(e-r)+r}}}r(ac,"name","Selection");class hc{constructor(t){r(this,"render"),r(this,"speed",1),r(this,"speedMax",20),r(this,"change",bt.debounce(()=>{this.render.updateHistory()},200)),r(this,"handlers",{dom:{keydown:t=>{t.ctrlKey||Object.values(Tl).map(t=>t.toString()).includes(t.code)&&(t.code===Tl.上?this.render.selectionTool.selectingNodesMove({x:0,y:-this.speed}):t.code===Tl.左?this.render.selectionTool.selectingNodesMove({x:-this.speed,y:0}):t.code===Tl.右?this.render.selectionTool.selectingNodesMove({x:this.speed,y:0}):t.code===Tl.下&&this.render.selectionTool.selectingNodesMove({x:0,y:this.speed}),this.speed<this.speedMax&&this.speed++,this.change(),this.render.redraw([rc.name,Fl.name,Xl.name,Rl.name,Bl.name]))},keyup:()=>{this.speed=1}}}),this.render=t}}r(hc,"name","KeyMove");class dc{constructor(t){r(this,"render"),r(this,"handlers",{dom:{keydown:t=>{this.render.config.readonly||(t.ctrlKey||t.metaKey?t.code===Pl.C?this.render.copyTool.pasteStart():t.code===Pl.V?this.render.copyTool.pasteEnd():t.code===Pl.Z?t.shiftKey?this.render.nextHistory():this.render.prevHistory():t.code===Pl.A&&this.render.selectionTool.selectAll():t.code===Pl.删除||t.code===Pl.Backspace?(this.render.remove(this.render.selectionTool.selectingNodes),this.render.linkTool.remove()):t.code===Pl.Esc&&(this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear())),t.code===Pl.R&&(t.ctrlKey||t.metaKey)&&window.location.reload()}}}),this.render=t}}r(dc,"name","Shutcut");class uc{constructor(t){r(this,"render"),r(this,"handlers",{stage:{mouseup:()=>{var t,e;const n=null==(t=this.render.draws[Fl.name])?void 0:t.state;n&&(null==(e=n.linkingLine)||e.line.destroy(),n.linkingLine=null)},mousemove:()=>{var t;const e=null==(t=this.render.draws[Fl.name])?void 0:t.state;if(e){const t=this.render.stage.getPointerPosition();if(t){const n=this.render.getStageState();if(e.linkingLine){const{circle:r,line:i}=e.linkingLine;i.points(bt.flatten([[r.x(),r.y()],[this.render.toStageValue(t.x-n.x),this.render.toStageValue(t.y-n.y)]]))}}}}}}),this.render=t}}r(uc,"name","Link");class lc{constructor(t){r(this,"render"),r(this,"graphing",!1),r(this,"currentGraph"),r(this,"handlers",{stage:{mousedown:t=>{if(this.render.graphType&&t.target===this.render.stage){this.graphing=!0,this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear();const t=this.getStagePoint();t&&(this.render.graphType===Vl.Circle?this.currentGraph=new Zl(this.render,t):this.render.graphType===Vl.Rect?this.currentGraph=new $l(this.render,t):this.render.graphType===Vl.Line?this.currentGraph=new Kl(this.render,t):this.render.graphType===Vl.Curve?this.currentGraph=new Ql(this.render,t):this.render.graphType===Vl.Bezier&&(this.currentGraph=new ec(this.render,t)),this.currentGraph&&this.render.setAssetSettings(this.currentGraph.group,this.render.getAssetSettings(this.currentGraph.group),!1))}},mousemove:()=>{if(this.graphing&&this.currentGraph){const t=this.getStagePoint(!0);t&&this.currentGraph.drawMove(t)}},mouseup:()=>{this.graphing&&(this.currentGraph&&this.currentGraph.drawEnd(),this.graphing=!1,this.render.changeGraphType(),this.render.attractTool.alignLinesClear(),this.render.redraw([rc.name]))}}}),this.render=t}getStagePoint(t=!1){const e=this.render.stage.getPointerPosition();if(e){const n=this.render.getStageState();if(t){const{pos:t}=this.render.attractTool.attractPoint(e);return{x:this.render.toStageValue(t.x-n.x),y:this.render.toStageValue(t.y-n.y)}}return{x:this.render.toStageValue(e.x-n.x),y:this.render.toStageValue(e.y-n.y)}}return null}}r(lc,"name","Graph");class cc{constructor(t){r(this,"render"),r(this,"group",null),r(this,"handlers",{stage:{mousedown:t=>{if(this.render.texting&&t.target===this.render.stage){this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear();const t=this.getStagePoint();if(t){this.group=new e.Group({id:Nl(),name:"asset",assetType:Cl.Text,draggable:!1,position:t});const n=this.render.getAssetSettings();this.group.setAttr("assetSettings",n);const r=new e.Text({text:n.text,fill:n.textFill,fontSize:n.fontSize,draggable:!1}),i=new e.Rect({width:r.width(),height:r.height()});this.group.add(i),this.group.add(r),this.render.layer.add(this.group)}}},mouseup:()=>{this.group&&this.render.texting&&this.render.selectionTool.select([this.group]),this.render.changeTexting(!1)}},transformer:{dblclick:()=>{}}}),this.render=t}getStagePoint(t=!1){const e=this.render.stage.getPointerPosition();if(e){const n=this.render.getStageState();if(t){const{pos:t}=this.render.attractTool.attractPoint(e);return{x:this.render.toStageValue(t.x-n.x),y:this.render.toStageValue(t.y-n.y)}}return{x:this.render.toStageValue(e.x-n.x),y:this.render.toStageValue(e.y-n.y)}}return null}}r(cc,"name","Text");const fc=window.gifler;class gc{constructor(t){r(this,"render"),this.render=t}async loadSvgXML(t){const n=new Blob([t],{type:"image/svg+xml"}),r=URL.createObjectURL(n);return new Promise(n=>{e.Image.fromURL(r,e=>{e.setAttrs({svgXML:t}),n(e)})})}async loadSvg(t){const e=await(await fetch(t)).text();return this.loadSvgXML(this.render.setSvgXMLSettings(e,this.render.getAssetSettings()))}async loadGif(t){return new Promise(n=>{const r=document.createElement("img");r.onload=()=>{const i=document.createElement("canvas");i.width=r.naturalWidth,i.height=r.naturalHeight;fc(t).frames(i,(t,e)=>{var n;t.drawImage(e.buffer,e.x,e.y),this.render.layer.draw(),null==(n=this.render.draws[Bl.name])||n.layer.draw()}),r.remove(),n(new e.Image({image:i,gif:t}))},r.src=t})}async loadImg(t){return new Promise(n=>{e.Image.fromURL(t,e=>{e.setAttrs({src:t}),n(e)})})}async loadJson(t){var n,r,i;try{const o=JSON.parse(await(await fetch(t)).text()),s=o.children;this.render.linkTool.jsonIdCover(s);const a=new e.Stage({container:document.createElement("div")}),h=new e.Layer;a.add(h);const d=JSON.parse(a.toJSON());d.children[0].children=[o];const u=e.Node.create(JSON.stringify(d),document.createElement("div")),l=u.children[0].children[0];a.destroy(),l.remove(),u.destroy();const c=[{target:l}];for(;c.length>0;){const t=c.shift();if(t){const o=t.target;if(o instanceof e.Image)if(o.attrs.svgXML){const t=await this.loadSvgXML(o.attrs.svgXML);t.listening(!1),null==(n=o.parent)||n.add(t),o.remove()}else if(o.attrs.gif){const t=await this.loadGif(o.attrs.gif);t.listening(!1),null==(r=o.parent)||r.add(t),o.remove()}else if(o.attrs.src){const t=await this.loadImg(o.attrs.src);t.listening(!1),null==(i=o.parent)||i.add(t),o.remove()}(o instanceof e.Stage||o instanceof e.Layer||o instanceof e.Group)&&c.push(...o.getChildren().map(t=>({target:t,parent:o})))}}const f=new e.Rect({id:"click-mask",width:l.width(),height:l.height()});return l.add(f),f.zIndex(1),l}catch(o){return new e.Group}}}r(gc,"name","AssetTool");class pc{constructor(t){r(this,"render"),r(this,"selectingNodes",[]),this.render=t}selectingClear(t=!1){this.selectingNodes.length>0&&!t&&this.render.emit("selection-change",[]),this.render.transformer.nodes([]);for(const e of[...this.selectingNodes].sort((t,e)=>t.attrs.lastZIndex-e.attrs.lastZIndex))e.setAttrs({listening:!0,opacity:e.attrs.lastOpacity??1,zIndex:e.attrs.lastZIndex});for(const e of this.selectingNodes)e.setAttrs({nodeMousedownPos:void 0,lastOpacity:void 0,lastZIndex:void 0,selectingZIndex:void 0,selected:!1});this.selectingNodes=[],this.render.linkTool.pointsVisible(!1),this.render.redraw([rc.name,Fl.name])}select(t){if(t.length>1)this.render.transformer.resizeEnabled(!1),this.render.transformer.rotateEnabled(!1);else if(1===t.length){const e=t[0];this.render.transformer.resizeEnabled(e.attrs.assetType!==Cl.Graph),this.render.transformer.rotateEnabled(e.attrs.assetType!==Cl.Graph||e.attrs.graphType!==Vl.Line&&e.attrs.graphType!==Vl.Curve&&e.attrs.graphType!==Vl.Bezier)}else this.render.transformer.resizeEnabled(!0);if(this.render.linkTool.selectingClear(),this.render.emit("selection-change",t),this.selectingClear(!0),t.length>0){const e=Math.max(...this.render.layer.getChildren(t=>!this.render.ignore(t)).map(t=>t.zIndex()));for(const n of t)n.setAttrs({nodeMousedownPos:n.position(),lastOpacity:n.opacity(),lastZIndex:n.zIndex(),selectingZIndex:void 0,selected:!0,listening:!1,opacity:.8*n.opacity()});for(const n of t.sort((t,e)=>t.zIndex()-e.zIndex()))n.setAttrs({zIndex:e});this.selectingNodes=t,this.render.transformer.nodes(this.selectingNodes)}this.render.redraw([rc.name,Fl.name])}selectingNodesMove(t){for(const e of this.render.selectionTool.selectingNodes)e.x(e.x()+t.x),e.y(e.y()+t.y);this.render.emit("asset-position-change",this.render.selectionTool.selectingNodes)}selectAll(){const t=this.render.layer.find(".asset");this.select(t)}}r(pc,"name","SelectionTool");class yc{constructor(t){r(this,"render"),r(this,"pasteCache",[]),r(this,"pasteCount",1),this.render=t}pasteStart(){this.pasteCache=this.render.selectionTool.selectingNodes.map(t=>{const e=t.clone();return e.setAttrs({listening:!0,opacity:e.attrs.lastOpacity??1}),e.setAttrs({nodeMousedownPos:void 0,lastOpacity:void 0,lastZIndex:void 0,selectingZIndex:void 0,selected:!1}),e}),this.pasteCount=1}pasteEnd(){this.pasteCache.length>0&&(this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear(),this.copy(this.pasteCache),this.pasteCount++)}nodesIdCover(t){let n=[...t];const r=new Map;for(;n.length>0;){const t=n.shift();if(t){if(Array.isArray(t.attrs.points))for(const e of t.attrs.points){if(Array.isArray(e.pairs))for(const t of e.pairs)r.has(t.id)||r.set(t.id,"pr:"+Nl()),t.from.groupId&&!r.has(t.from.groupId)&&r.set(t.from.groupId,"g:"+Nl()),t.to.groupId&&!r.has(t.to.groupId)&&r.set(t.to.groupId,"g:"+Nl()),t.from.pointId&&!r.has(t.from.pointId)&&r.set(t.from.pointId,"p:"+Nl()),t.to.pointId&&!r.has(t.to.pointId)&&r.set(t.to.pointId,"p:"+Nl());e.id&&(r.has(e.id)||r.set(e.id,"p:"+Nl())),e.groupId&&(r.has(e.groupId)||r.set(e.groupId,"g:"+Nl()))}if(Array.isArray(t.attrs.anchors))for(const e of t.attrs.anchors)e.groupId&&!r.has(e.groupId)&&r.set(e.groupId,"g:"+Nl());t.id()&&(r.has(t.id())||r.set(t.id(),"n:"+Nl())),t instanceof e.Group&&Array.isArray(t.children)&&n.push(...t.children)}}for(n=[...t];n.length>0;){const t=n.shift();if(t){if(r.has(t.id())&&t.id(r.get(t.id())),Array.isArray(t.attrs.points)){t.attrs.points=bt.cloneDeep(t.attrs.points??[]);for(const n of t.attrs.points){if(Array.isArray(n.pairs))for(const t of n.pairs)t.id=r.get(t.id),r.has(t.from.groupId)&&(t.from.groupId=r.get(t.from.groupId)),r.has(t.to.groupId)&&(t.to.groupId=r.get(t.to.groupId)),r.has(t.from.pointId)&&(t.from.pointId=r.get(t.from.pointId)),r.has(t.to.pointId)&&(t.to.pointId=r.get(t.to.pointId));if(r.has(n.id)){if(t instanceof e.Group){const e=t.findOne(`#${n.id}`);null==e||e.id(r.get(n.id))}n.id=r.get(n.id),n.visible=!1}r.has(n.groupId)&&(n.groupId=r.get(n.groupId))}}if(Array.isArray(t.attrs.anchors)){t.attrs.anchors=bt.cloneDeep(t.attrs.anchors??[]);for(const e of t.attrs.anchors)r.has(e.groupId)&&(e.groupId=r.get(e.groupId))}t instanceof e.Group&&Array.isArray(t.children)&&n.push(...t.children)}}for(const i of t)if(i instanceof e.Group&&(i.off("mouseenter"),i.on("mouseenter",()=>{this.render.linkTool.pointsVisible(!0,i)}),i.off("mouseleave"),i.on("mouseleave",()=>{var t;this.render.linkTool.pointsVisible(!1,i),null==(t=i.findOne("#hoverRect"))||t.visible(!1)}),i.setAttrs({x:i.x()+this.render.toStageValue(this.render.bgSize)*this.pasteCount,y:i.y()+this.render.toStageValue(this.render.bgSize)*this.pasteCount}),i.attrs.manualPointsMap)){const t={};for(const e in i.attrs.manualPointsMap)t[r.get(e)]=i.attrs.manualPointsMap[e];for(const e in t){const n=t[e];Array.isArray(n)&&(t[e]=n.map(t=>({x:t.x+this.render.toStageValue(this.render.bgSize)*this.pasteCount,y:t.y+this.render.toStageValue(this.render.bgSize)*this.pasteCount})))}i.setAttr("manualPointsMap",t)}}copy(t){const n=[];for(const r of t){if(r instanceof e.Transformer){const t=[...this.render.selectionTool.selectingNodes];return this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear(),void this.copy(t)}n.push(r.clone())}this.nodesIdCover(n),this.render.layer.add(...n),this.render.selectionTool.select(n),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])}}r(yc,"name","CopyTool");class mc{constructor(t){r(this,"render"),this.render=t}positionFit(){const t=[...this.render.layer.getChildren(),...this.render.layerCover.find(".link-line")];let n=1/0,r=-1/0,i=1/0,o=-1/0;const s=this.render.getStageState();for(const g of t)if(g instanceof e.Group){const{x:t,y:e,width:a,height:h}=(t=>({x:this.render.toStageValue(t.x-s.x),y:this.render.toStageValue(t.y-s.y),width:this.render.toStageValue(t.width),height:this.render.toStageValue(t.height)}))(g.getClientRect());t<n&&(n=t),t+a>r&&(r=t+a),e<i&&(i=e),e+h>o&&(o=e+h)}else if(g instanceof e.Line&&"link-line"===g.name()){const t=g.points();for(let e=0;e<t.length;e+=2){const[s,a]=[t[e],t[e+1]];s<n&&(n=s-1),s>r&&(r=s+1),a<i&&(i=a-1),a>o&&(o=a+1)}}n===1/0&&(n=(this.render.stage.width()-this.render.rulerSize)/2),r===-1/0&&(r=n),i===1/0&&(i=(this.render.stage.height()-this.render.rulerSize)/2),o===-1/0&&(o=i);const a=r-n,h=o-i,d=a/h,u=this.render.stage.width()-(this.render.config.readonly?0:this.render.rulerSize),l=this.render.stage.height()-(this.render.config.readonly?0:this.render.rulerSize),c=u/l;let f=1;c>d?f=l/h:c<d&&(f=u/a),f=Math.max(.2,f),f=Math.floor(100*f)/100,a<=u&&h<=l&&(f=1),this.render.stage.setAttrs({scale:{x:f,y:f},position:{x:(this.render.config.readonly?0:this.render.rulerSize)-n*f+(u-a*f)/2,y:(this.render.config.readonly?0:this.render.rulerSize)-i*f+(l-h*f)/2}}),this.render.emit("scale-change",f),this.render.redraw([El.name,rc.name,Fl.name,Rl.name,Ll.name,Bl.name])}positionZoomReset(){this.render.stage.setAttrs({scale:{x:1,y:1}}),this.render.emit("scale-change",1),this.positionReset()}positionReset(){this.render.stage.setAttrs({x:this.render.rulerSize,y:this.render.rulerSize}),this.render.redraw([El.name,rc.name,Fl.name,Rl.name,Ll.name,Bl.name])}updateCenter(t=0,e=0){const n=this.render.getStageState(),r=this.render.layer.getChildren(t=>!this.render.ignore(t));let i=0,o=0;for(const s of r){const t=s.x(),e=s.y();t<i&&(i=t),e<o&&(o=e)}this.render.stage.setAttrs({x:n.width/2-this.render.toBoardValue(i)-this.render.toBoardValue(t)+this.render.rulerSize,y:n.height/2-this.render.toBoardValue(o)-this.render.toBoardValue(e)+this.render.rulerSize}),this.render.redraw([El.name,rc.name,Fl.name,Rl.name,Ll.name,Bl.name])}}r(mc,"name","PositionTool");class vc{constructor(t){r(this,"render"),this.render=t}getNodes(t){const n=[];for(const r of t)r instanceof e.Transformer?n.push(...this.render.selectionTool.selectingNodes):n.push(r);return n}getMaxZIndex(){return Math.max(...this.render.layer.getChildren(t=>!this.render.ignore(t)).map(t=>t.zIndex()))}getMinZIndex(){return Math.min(...this.render.layer.getChildren(t=>!this.render.ignore(t)).map(t=>t.zIndex()))}updateSelectingZIndex(t){for(const e of t)e.setAttrs({selectingZIndex:e.zIndex()})}resetSelectingZIndex(t){t.sort((t,e)=>t.zIndex()-e.zIndex());for(const e of t)e.zIndex(e.attrs.selectingZIndex)}updateLastZindex(t){for(const e of t)e.setAttrs({lastZIndex:e.zIndex()})}up(t){const e=this.getMaxZIndex(),n=this.getNodes(t).sort((t,e)=>e.zIndex()-t.zIndex());let r=null;if(this.render.selectionTool.selectingNodes.length>0){this.updateSelectingZIndex(n);for(const t of n)t.attrs.lastZIndex<e&&(null===r||t.attrs.lastZIndex<r.attrs.lastZIndex-1)&&t.setAttrs({lastZIndex:t.attrs.lastZIndex+1}),r=t;this.resetSelectingZIndex(n)}else{for(const t of n)t.zIndex()<e&&(null===r||t.zIndex()<r.zIndex()-1)&&t.zIndex(t.zIndex()+1),r=t;this.updateLastZindex(n),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])}}down(t){const e=this.getMinZIndex(),n=this.getNodes(t).sort((t,e)=>t.zIndex()-e.zIndex());let r=null;if(this.render.selectionTool.selectingNodes.length>0){this.updateSelectingZIndex(n);for(const t of n)t.attrs.lastZIndex>e&&(null===r||t.attrs.lastZIndex>r.attrs.lastZIndex+1)&&t.setAttrs({lastZIndex:t.attrs.lastZIndex-1}),r=t;this.resetSelectingZIndex(n)}else{for(const t of n)t.zIndex()>e&&(null===r||t.zIndex()>r.zIndex()+1)&&t.zIndex(t.zIndex()-1),r=t;this.updateLastZindex(n),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])}}top(t){let e=this.getMaxZIndex();const n=this.getNodes(t).sort((t,e)=>e.zIndex()-t.zIndex());if(this.render.selectionTool.selectingNodes.length>0){this.updateSelectingZIndex(n);for(const t of n)t.setAttrs({lastZIndex:e--});this.resetSelectingZIndex(n)}else{for(const t of n)t.zIndex(e);this.updateLastZindex(n),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])}}bottom(t){let e=this.getMinZIndex();const n=this.getNodes(t).sort((t,e)=>t.zIndex()-e.zIndex());if(this.render.selectionTool.selectingNodes.length>0){this.updateSelectingZIndex(n);for(const t of n)t.setAttrs({lastZIndex:e++});this.resetSelectingZIndex(n)}else{for(const t of n)t.zIndex(e);this.updateLastZindex(n),this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])}}}function xc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}r(vc,"name","ZIndexTool");var wc,bc={exports:{}};
12
+ /*!!
13
+ * Canvas 2 Svg v1.0.15
14
+ * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document.
15
+ *
16
+ * Licensed under the MIT license:
17
+ * http://www.opensource.org/licenses/mit-license.php
18
+ *
19
+ * Author:
20
+ * Kerry Liu
21
+ *
22
+ * Copyright (c) 2014 Gliffy Inc.
23
+ */wc=bc,function(){var t,e,n,r,i;function o(t,e){var n,r=Object.keys(e);for(n=0;n<r.length;n++)t=t.replace(new RegExp("\\{"+r[n]+"\\}","gi"),e[r[n]]);return t}function s(t){var e,n,r;if(!t)throw new Error("cannot create a random attribute name for an undefined object");e="ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz",n="";do{for(n="",r=0;r<12;r++)n+=e[Math.floor(51*Math.random())]}while(t[n]);return n}function a(t){var e={alphabetic:"alphabetic",hanging:"hanging",top:"text-before-edge",bottom:"text-after-edge",middle:"central"};return e[t]||e.alphabetic}i=function(t,e){var n,r,i,o={};for(t=t.split(","),e=e||10,n=0;n<t.length;n+=2)r="&"+t[n+1]+";",i=parseInt(t[n],e),o[r]="&#"+i+";";return o["\\xa0"]="&#160;",o}("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),t={strokeStyle:{svgAttr:"stroke",canvas:"#000000",svg:"none",apply:"stroke"},fillStyle:{svgAttr:"fill",canvas:"#000000",svg:null,apply:"fill"},lineCap:{svgAttr:"stroke-linecap",canvas:"butt",svg:"butt",apply:"stroke"},lineJoin:{svgAttr:"stroke-linejoin",canvas:"miter",svg:"miter",apply:"stroke"},miterLimit:{svgAttr:"stroke-miterlimit",canvas:10,svg:4,apply:"stroke"},lineWidth:{svgAttr:"stroke-width",canvas:1,svg:1,apply:"stroke"},globalAlpha:{svgAttr:"opacity",canvas:1,svg:1,apply:"fill stroke"},font:{canvas:"10px sans-serif"},shadowColor:{canvas:"#000000"},shadowOffsetX:{canvas:0},shadowOffsetY:{canvas:0},shadowBlur:{canvas:0},textAlign:{canvas:"start"},textBaseline:{canvas:"alphabetic"}},(n=function(t,e){this.__root=t,this.__ctx=e}).prototype.addColorStop=function(t,e){var n,r=this.__ctx.__createElement("stop");r.setAttribute("offset",t),-1!==e.indexOf("rgba")?(n=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(e),r.setAttribute("stop-color",o("rgb({r},{g},{b})",{r:n[1],g:n[2],b:n[3]})),r.setAttribute("stop-opacity",n[4])):r.setAttribute("stop-color",e),this.__root.appendChild(r)},r=function(t,e){this.__root=t,this.__ctx=e},e=function(t){var n,r={width:500,height:500,enableMirroring:!1};if(arguments.length>1?((n=r).width=arguments[0],n.height=arguments[1]):n=t||r,!(this instanceof e))return new e(n);this.width=n.width||r.width,this.height=n.height||r.height,this.enableMirroring=void 0!==n.enableMirroring?n.enableMirroring:r.enableMirroring,this.canvas=this,this.__document=n.document||document,this.__canvas=this.__document.createElement("canvas"),this.__ctx=this.__canvas.getContext("2d"),this.__setDefaultStyles(),this.__stack=[this.__getStyleState()],this.__groupStack=[],this.__root=this.__document.createElementNS("http://www.w3.org/2000/svg","svg"),this.__root.setAttribute("version",1.1),this.__root.setAttribute("xmlns","http://www.w3.org/2000/svg"),this.__root.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),this.__root.setAttribute("width",this.width),this.__root.setAttribute("height",this.height),this.__ids={},this.__defs=this.__document.createElementNS("http://www.w3.org/2000/svg","defs"),this.__root.appendChild(this.__defs),this.__currentElement=this.__document.createElementNS("http://www.w3.org/2000/svg","g"),this.__root.appendChild(this.__currentElement)},e.prototype.__createElement=function(t,e,n){void 0===e&&(e={});var r,i,o=this.__document.createElementNS("http://www.w3.org/2000/svg",t),s=Object.keys(e);for(n&&(o.setAttribute("fill","none"),o.setAttribute("stroke","none")),r=0;r<s.length;r++)i=s[r],o.setAttribute(i,e[i]);return o},e.prototype.__setDefaultStyles=function(){var e,n,r=Object.keys(t);for(e=0;e<r.length;e++)this[n=r[e]]=t[n].canvas},e.prototype.__applyStyleState=function(t){var e,n,r=Object.keys(t);for(e=0;e<r.length;e++)this[n=r[e]]=t[n]},e.prototype.__getStyleState=function(){var e,n,r={},i=Object.keys(t);for(e=0;e<i.length;e++)r[n=i[e]]=this[n];return r},e.prototype.__applyStyleToCurrentElement=function(e){var i,s,a,h,d,u=Object.keys(t);for(i=0;i<u.length;i++)if(s=t[u[i]],a=this[u[i]],s.apply)if(-1!==s.apply.indexOf("fill")&&a instanceof r){if(a.__ctx)for(;a.__ctx.__defs.childNodes.length;)h=a.__ctx.__defs.childNodes[0].getAttribute("id"),this.__ids[h]=h,this.__defs.appendChild(a.__ctx.__defs.childNodes[0]);this.__currentElement.setAttribute("fill",o("url(#{id})",{id:a.__root.getAttribute("id")}))}else-1!==s.apply.indexOf("fill")&&a instanceof n?this.__currentElement.setAttribute("fill",o("url(#{id})",{id:a.__root.getAttribute("id")})):-1!==s.apply.indexOf(e)&&s.svg!==a&&("stroke"!==s.svgAttr&&"fill"!==s.svgAttr||-1===a.indexOf("rgba")?this.__currentElement.setAttribute(s.svgAttr,a):(d=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?\.?\d*)\s*\)/gi.exec(a),this.__currentElement.setAttribute(s.svgAttr,o("rgb({r},{g},{b})",{r:d[1],g:d[2],b:d[3]})),this.__currentElement.setAttribute(s.svgAttr+"-opacity",d[4])))},e.prototype.__closestGroupOrSvg=function(t){return"g"===(t=t||this.__currentElement).nodeName||"svg"===t.nodeName?t:this.__closestGroupOrSvg(t.parentNode)},e.prototype.getSerializedSvg=function(t){var e,n,r,o,s,a=(new XMLSerializer).serializeToString(this.__root);if(/xmlns="http:\/\/www\.w3\.org\/2000\/svg".+xmlns="http:\/\/www\.w3\.org\/2000\/svg/gi.test(a)&&(a=a.replace('xmlns="http://www.w3.org/2000/svg','xmlns:xlink="http://www.w3.org/1999/xlink')),t)for(e=Object.keys(i),n=0;n<e.length;n++)r=e[n],o=i[r],(s=new RegExp(r,"gi")).test(a)&&(a=a.replace(s,o));return a},e.prototype.getSvg=function(){return this.__root},e.prototype.save=function(){var t=this.__createElement("g"),e=this.__closestGroupOrSvg();this.__groupStack.push(e),e.appendChild(t),this.__currentElement=t,this.__stack.push(this.__getStyleState())},e.prototype.restore=function(){this.__currentElement=this.__groupStack.pop();var t=this.__stack.pop();this.__applyStyleState(t)},e.prototype.__addTransform=function(t){var e=this.__closestGroupOrSvg();if(e.childNodes.length>0){var n=this.__createElement("g");e.appendChild(n),this.__currentElement=n}var r=this.__currentElement.getAttribute("transform");r?r+=" ":r="",r+=t,this.__currentElement.setAttribute("transform",r)},e.prototype.scale=function(t,e){void 0===e&&(e=t),this.__addTransform(o("scale({x},{y})",{x:t,y:e}))},e.prototype.rotate=function(t){var e=180*t/Math.PI;this.__addTransform(o("rotate({angle},{cx},{cy})",{angle:e,cx:0,cy:0}))},e.prototype.translate=function(t,e){this.__addTransform(o("translate({x},{y})",{x:t,y:e}))},e.prototype.transform=function(t,e,n,r,i,s){this.__addTransform(o("matrix({a},{b},{c},{d},{e},{f})",{a:t,b:e,c:n,d:r,e:i,f:s}))},e.prototype.beginPath=function(){var t;this.__currentDefaultPath="",this.__currentPosition={},t=this.__createElement("path",{},!0),this.__closestGroupOrSvg().appendChild(t),this.__currentElement=t},e.prototype.__applyCurrentDefaultPath=function(){if("path"!==this.__currentElement.nodeName)throw new Error("Attempted to apply path command to node "+this.__currentElement.nodeName);var t=this.__currentDefaultPath;this.__currentElement.setAttribute("d",t)},e.prototype.__addPathCommand=function(t){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=t},e.prototype.moveTo=function(t,e){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.__currentPosition={x:t,y:e},this.__addPathCommand(o("M {x} {y}",{x:t,y:e}))},e.prototype.closePath=function(){this.__addPathCommand("Z")},e.prototype.lineTo=function(t,e){this.__currentPosition={x:t,y:e},this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(o("L {x} {y}",{x:t,y:e})):this.__addPathCommand(o("M {x} {y}",{x:t,y:e}))},e.prototype.bezierCurveTo=function(t,e,n,r,i,s){this.__currentPosition={x:i,y:s},this.__addPathCommand(o("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:t,cp1y:e,cp2x:n,cp2y:r,x:i,y:s}))},e.prototype.quadraticCurveTo=function(t,e,n,r){this.__currentPosition={x:n,y:r},this.__addPathCommand(o("Q {cpx} {cpy} {x} {y}",{cpx:t,cpy:e,x:n,y:r}))};var h=function(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]};e.prototype.arcTo=function(t,e,n,r,i){var o=this.__currentPosition&&this.__currentPosition.x,s=this.__currentPosition&&this.__currentPosition.y;if(void 0!==o&&void 0!==s){if(i<0)throw new Error("IndexSizeError: The radius provided ("+i+") is negative.");if(o===t&&s===e||t===n&&e===r||0===i)this.lineTo(t,e);else{var a=h([o-t,s-e]),d=h([n-t,r-e]);if(a[0]*d[1]!==a[1]*d[0]){var u=a[0]*d[0]+a[1]*d[1],l=Math.acos(Math.abs(u)),c=h([a[0]+d[0],a[1]+d[1]]),f=i/Math.sin(l/2),g=t+f*c[0],p=e+f*c[1],y=[-a[1],a[0]],m=[d[1],-d[0]],v=function(t){var e=t[0];return t[1]>=0?Math.acos(e):-Math.acos(e)},x=v(y),w=v(m);this.lineTo(g+y[0]*i,p+y[1]*i),this.arc(g,p,i,x,w)}else this.lineTo(t,e)}}},e.prototype.stroke=function(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke")},e.prototype.fill=function(){"path"===this.__currentElement.nodeName&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill")},e.prototype.rect=function(t,e,n,r){"path"!==this.__currentElement.nodeName&&this.beginPath(),this.moveTo(t,e),this.lineTo(t+n,e),this.lineTo(t+n,e+r),this.lineTo(t,e+r),this.lineTo(t,e),this.closePath()},e.prototype.fillRect=function(t,e,n,r){var i;i=this.__createElement("rect",{x:t,y:e,width:n,height:r},!0),this.__closestGroupOrSvg().appendChild(i),this.__currentElement=i,this.__applyStyleToCurrentElement("fill")},e.prototype.strokeRect=function(t,e,n,r){var i;i=this.__createElement("rect",{x:t,y:e,width:n,height:r},!0),this.__closestGroupOrSvg().appendChild(i),this.__currentElement=i,this.__applyStyleToCurrentElement("stroke")},e.prototype.clearRect=function(t,e,n,r){var i,o=this.__closestGroupOrSvg();i=this.__createElement("rect",{x:t,y:e,width:n,height:r,fill:"#FFFFFF"},!0),o.appendChild(i)},e.prototype.createLinearGradient=function(t,e,r,i){var o=this.__createElement("linearGradient",{id:s(this.__ids),x1:t+"px",x2:r+"px",y1:e+"px",y2:i+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(o),new n(o,this)},e.prototype.createRadialGradient=function(t,e,r,i,o,a){var h=this.__createElement("radialGradient",{id:s(this.__ids),cx:i+"px",cy:o+"px",r:a+"px",fx:t+"px",fy:e+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(h),new n(h,this)},e.prototype.__parseFont=function(){var t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\"\sa-z]+?)\s*$/i.exec(this.font),e={style:t[1]||"normal",size:t[4]||"10px",family:t[6]||"sans-serif",weight:t[3]||"normal",decoration:t[2]||"normal",href:null};return"underline"===this.__fontUnderline&&(e.decoration="underline"),this.__fontHref&&(e.href=this.__fontHref),e},e.prototype.__wrapTextLink=function(t,e){if(t.href){var n=this.__createElement("a");return n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.href),n.appendChild(e),n}return e},e.prototype.__applyText=function(t,e,n,r){var i,o,s=this.__parseFont(),h=this.__closestGroupOrSvg(),d=this.__createElement("text",{"font-family":s.family,"font-size":s.size,"font-style":s.style,"font-weight":s.weight,"text-decoration":s.decoration,x:e,y:n,"text-anchor":(i=this.textAlign,o={left:"start",right:"end",center:"middle",start:"start",end:"end"},o[i]||o.start),"dominant-baseline":a(this.textBaseline)},!0);d.appendChild(this.__document.createTextNode(t)),this.__currentElement=d,this.__applyStyleToCurrentElement(r),h.appendChild(this.__wrapTextLink(s,d))},e.prototype.fillText=function(t,e,n){this.__applyText(t,e,n,"fill")},e.prototype.strokeText=function(t,e,n){this.__applyText(t,e,n,"stroke")},e.prototype.measureText=function(t){return this.__ctx.font=this.font,this.__ctx.measureText(t)},e.prototype.arc=function(t,e,n,r,i,s){if(r!==i){(r%=2*Math.PI)==(i%=2*Math.PI)&&(i=(i+2*Math.PI-.001*(s?-1:1))%(2*Math.PI));var a=t+n*Math.cos(i),h=e+n*Math.sin(i),d=t+n*Math.cos(r),u=e+n*Math.sin(r),l=s?0:1,c=0,f=i-r;f<0&&(f+=2*Math.PI),c=s?f>Math.PI?0:1:f>Math.PI?1:0,this.lineTo(d,u),this.__addPathCommand(o("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:n,ry:n,xAxisRotation:0,largeArcFlag:c,sweepFlag:l,endX:a,endY:h})),this.__currentPosition={x:a,y:h}}},e.prototype.clip=function(){var t=this.__closestGroupOrSvg(),e=this.__createElement("clipPath"),n=s(this.__ids),r=this.__createElement("g");t.removeChild(this.__currentElement),e.setAttribute("id",n),e.appendChild(this.__currentElement),this.__defs.appendChild(e),t.setAttribute("clip-path",o("url(#{id})",{id:n})),t.appendChild(r),this.__currentElement=r},e.prototype.drawImage=function(){var t,n,r,i,o,s,a,h,d,u,l,c,f,g,p=Array.prototype.slice.call(arguments),y=p[0],m=0,v=0;if(3===p.length)t=p[1],n=p[2],r=o=y.width,i=s=y.height;else if(5===p.length)t=p[1],n=p[2],r=p[3],i=p[4],o=y.width,s=y.height;else{if(9!==p.length)throw new Error("Inavlid number of arguments passed to drawImage: "+arguments.length);m=p[1],v=p[2],o=p[3],s=p[4],t=p[5],n=p[6],r=p[7],i=p[8]}if(a=this.__closestGroupOrSvg(),l=this.__currentElement,y instanceof e){for(d=(h=y.getSvg()).childNodes[0];d.childNodes.length;)g=d.childNodes[0].getAttribute("id"),this.__ids[g]=g,this.__defs.appendChild(d.childNodes[0]);u=h.childNodes[1],a.appendChild(u),this.__currentElement=u,this.translate(t,n),this.__currentElement=l}else"CANVAS"!==y.nodeName&&"IMG"!==y.nodeName||((c=this.__createElement("image")).setAttribute("width",r),c.setAttribute("height",i),c.setAttribute("preserveAspectRatio","none"),(m||v||o!==y.width||s!==y.height)&&((f=this.__document.createElement("canvas")).width=r,f.height=i,f.getContext("2d").drawImage(y,m,v,o,s,0,0,r,i),y=f),c.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===y.nodeName?y.toDataURL():y.getAttribute("src")),a.appendChild(c),this.__currentElement=c,this.translate(t,n),this.__currentElement=l)},e.prototype.createPattern=function(t,n){var i,o=this.__document.createElementNS("http://www.w3.org/2000/svg","pattern"),a=s(this.__ids);return o.setAttribute("id",a),o.setAttribute("width",t.width),o.setAttribute("height",t.height),"CANVAS"===t.nodeName||"IMG"===t.nodeName?((i=this.__document.createElementNS("http://www.w3.org/2000/svg","image")).setAttribute("width",t.width),i.setAttribute("height",t.height),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","CANVAS"===t.nodeName?t.toDataURL():t.getAttribute("src")),o.appendChild(i),this.__defs.appendChild(o)):t instanceof e&&(o.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(o)),new r(o,this)},e.prototype.drawFocusRing=function(){},e.prototype.createImageData=function(){},e.prototype.getImageData=function(){},e.prototype.putImageData=function(){},e.prototype.globalCompositeOperation=function(){},e.prototype.setTransform=function(){},"object"==typeof window&&(window.C2S=e),wc.exports=e}();const Sc=xc(bc.exports);Sc.prototype.__applyCurrentDefaultPath=function(){if("g"===this.__currentElement.nodeName){const t=this.__currentElement.querySelector("g");if(t){const e=t.getAttribute("transform");if(e){const t=e.match(/scale\(([^),]+),([^)]+)\)/);if(t){const[e,n]=[parseFloat(t[1]),parseFloat(t[2])];let r=this.__currentDefaultPath;const i=/A ([^ ]+) ([^ ]+) /,o=r.match(i);if(o){const[t,s]=[parseFloat(o[1]),parseFloat(o[2])];r=r.replace(i,`A ${t*e} ${s*n} `);const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d",r),a.setAttribute("fill","none"),this.__currentElement.append(a)}}}else{const t=this.__currentDefaultPath,e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d",t),e.setAttribute("fill","none"),this.__currentElement.append(e)}}return}if("path"!==this.__currentElement.nodeName)throw new Error("Attempted to apply path command to node "+this.__currentElement.nodeName);{const t=this.__currentDefaultPath;this.__currentElement.setAttribute("d",t)}};class _c{constructor(t){r(this,"render"),this.render=t}getView(t=!1){const n=this.render.stage.clone(),r=n.find("#main")[0],i=n.find("#cover")[0],o=n.getChildren();if(n.removeChildren(),r&&i){let o=r.getChildren(t=>!this.render.ignore(t));for(const t of o){t.listening(!0),t.draggable(!this.render.config.readonly);for(const e of t.children)this.render.ignoreSelect(e)&&e.remove()}if(t){const t=i.children.find(t=>t.attrs.name===Fl.name);t&&(o=o.concat(t.children.filter(t=>"link-line"===t.attrs.name)))}const s=new e.Layer;s.add(...o),o=s.getChildren();for(const t of o)t.attrs.nodeMousedownPos&&t.setAttrs({opacity:n.attrs.lastOpacity??1});n.add(s),r.removeChildren(),i.removeChildren()}return o.forEach(t=>t.destroy()),n}save(){const t=this.getView(),e=t.toJSON();return t.destroy(),e}loadImage(t){return new Promise(e=>{const n=new Image;n.onload=()=>{e(n)},n.onerror=()=>{e(null)},n.src=t})}async restoreImage(t=[]){for(const n of t)if(n instanceof e.Group)await this.restoreImage(n.getChildren());else if(n instanceof e.Image)if(n.attrs.svgXML){const t=new Blob([n.attrs.svgXML],{type:"image/svg+xml"}),e=URL.createObjectURL(t),r=await this.loadImage(e);r&&n.image(r)}else if(n.attrs.gif){const t=await this.render.assetTool.loadGif(n.attrs.gif);t&&n.image(t.image())}else if(n.attrs.src){const t=await this.loadImage(n.attrs.src);t&&n.image(t)}}async restore(t,n=!1){try{this.render.emit("loading",!0),this.render.selectionTool.selectingClear(),this.render.linkTool.selectingClear(),this.render.layer.getChildren().forEach(t=>{t.destroy()}),this.render.layer.removeChildren();const r=document.createElement("div"),i=e.Node.create(t,r),o=i.getChildren()[0].getChildren();await this.restoreImage(o);for(const t of o)t.draggable(!this.render.config.readonly),t.off("mouseenter"),t.on("mouseenter",()=>{this.render.linkTool.pointsVisible(!0,t)}),t.add(new e.Rect({id:"hoverRect",width:t.width(),height:t.height(),fill:"rgba(0,255,0,0.3)",visible:!1})),t.off("mouseleave"),t.on("mouseleave",()=>{var e;this.render.linkTool.pointsVisible(!1,t),null==(e=t.findOne("#hoverRect"))||e.visible(!1)});this.render.layer.add(...o),this.render.stage.setAttr("pageSettings",i.attrs.pageSettings),this.render.emit("page-settings-change",this.render.getPageSettings()),this.render.updateBackground(),n||this.render.updateHistory(),this.render.linkTool.pointsVisible(!1),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name]),i.destroy()}catch(r){}finally{this.render.emit("loading",!1)}}getImage(t=1,n){const r=this.getAssetView(),i=new e.Layer,o=new e.Rect({listening:!1});o.setAttrs({x:0,y:0,width:r.width(),height:r.height(),fill:n??this.render.getPageSettings().background}),i.add(o);const s=r.getChildren();r.removeChildren(),r.add(i),r.add(s[0],...s.slice(1));const a=r.toDataURL({pixelRatio:t});return r.destroy(),a}getAssetImage(t=1,n){const r=this.getAssetView(),i=new e.Layer,o=new e.Rect({listening:!1});o.setAttrs({x:-r.x(),y:-r.y(),width:r.width(),height:r.height(),fill:n??this.render.getPageSettings().background}),i.add(o);const s=r.getChildren();r.removeChildren(),r.add(i),r.add(s[0],...s.slice(1));const a=r.toDataURL({pixelRatio:t});return r.destroy(),a}blobToBase64(t,e){return new Promise(n=>{const r=new File([t],"image",{type:e}),i=new FileReader;i.readAsDataURL(r),i.onload=function(){n(this.result??"")}})}parseSvgImage(t){return new Promise(e=>{t.length>0?Promise.all(t.map(t=>fetch(t))).then(t=>{Promise.all(t.map(t=>t.text())).then(t=>{e(t)})}):e([])})}parseOtherImage(t){return new Promise(e=>{t.length>0?Promise.all(t.map(t=>fetch(t))).then(t=>{Promise.all(t.map(t=>t.blob())).then(t=>{Promise.all(t.map(t=>this.blobToBase64(t,"image/*"))).then(t=>{e(t)})})}):e([])})}parseImage(t){return new Promise(e=>{const n=t.match(new RegExp('(?<=xlink:href=")blob:https?:\\/\\/[^"]+(?=")',"g"))??[],r=t.match(new RegExp('(?<=xlink:href=")(?<!blob:)[^"]+(?=")',"g"))??[];Promise.all([this.parseSvgImage(n),this.parseOtherImage(r)]).then(([i,o])=>{n.forEach((e,n)=>{var r;t=t.replace(new RegExp(`<image[^><]* xlink:href="${e}"[^><]*/>`),(null==(r=i[n].match(/<svg[^><]*>.*<\/svg>/))?void 0:r[0])??"")}),r.forEach((e,n)=>{t=t.replace(`"${e}"`,`"${o[n]}"`)}),e(t)})})}async getSvg(){const t=this.getAssetView(),e=t.children[0],n=e.canvas.context._context;if(n){const r=new Sc({ctx:n,...e.size()});e.canvas.context._context=r,e.draw();let i=r.getSerializedSvg();i=i.replace(/(<defs\/><g><rect fill=")([^"]+)(")/,`$1${this.render.getPageSettings().background}$3`);const o=await this.parseImage(i);return t.destroy(),o}return Promise.resolve('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="0" height="0"></svg>')}getAssetView(){const t=this.getView(!0),n=[...t.getChildren()[0].getChildren()];let r=1/0,i=-1/0,o=1/0,s=-1/0,a=1/0,h=1/0;const d=this.render.getStageState();for(const u of n)if(u instanceof e.Group){const{x:t,y:n,width:l,height:c}=(t=>({x:this.render.toStageValue(t.x-d.x),y:this.render.toStageValue(t.y-d.y),width:this.render.toStageValue(t.width),height:this.render.toStageValue(t.height)}))(u.getClientRect());if(t<r&&(r=t),t+l>i&&(i=t+l),n<o&&(o=n),n+c>s&&(s=n+c),t<a&&(a=t),n<h&&(h=n),u instanceof e.Group){const t=u.findOne("#click-mask");t&&t.destroy()}}else if(u instanceof e.Line&&"link-line"===u.name()){const t=u.points();for(let e=0;e<t.length;e+=2){const[n,d]=[t[e],t[e+1]];n<r&&(r=n-1),n>i&&(i=n+1),d<o&&(o=d-1),d>s&&(s=d+1),n<a&&(a=n-1),d<h&&(h=d-1)}}for(const u of n)if(u instanceof e.Group)u.x(u.x()-a),u.y(u.y()-h);else if(u instanceof e.Line&&"link-line"===u.name()){const t=u.points();for(let e=0;e<t.length;e+=2)t[e]=t[e]-a,t[e+1]=t[e+1]-h;u.points(t)}return t.x(0),t.y(0),t.width(i-r),t.height(s-o),t.scale({x:1,y:1}),t}getAsset(){const t=this.getAssetView(),e=this.render.getBackground();e.width(t.width()),e.height(t.height()),t.children[0].add(e),e.moveToBottom();const n=t.toJSON(),r=JSON.parse(n),i=r.children[0].children;for(const s of i)"asset"===s.attrs.name&&(s.attrs.name="sub-asset"),s.attrs.selected&&(s.attrs.selected=!1);this.render.linkTool.jsonIdCover(i);const o=JSON.stringify({...r.children[0],className:"Group",attrs:{width:t.width(),height:t.height(),x:0,y:0}});return t.destroy(),o}}r(_c,"name","ImportExportTool");class Ac{constructor(t){r(this,"render"),this.render=t}getAlignRect(t){const e=this.render.getStageState();let n=0,r=0,i=0,o=0;const s=t.getClientRect();return[n,r,i,o]=[this.render.toStageValue(s.width),this.render.toStageValue(s.height),this.render.toStageValue(s.x-e.x),this.render.toStageValue(s.y-e.y)],{width:n,height:r,x:i,y:o}}getAlignPoints(t){let e=0,n=0,r=0,i=0;if(void 0===t)return this.getAlignPoints(this.render.transformer);{const o=this.getAlignRect(t);[e,n,r,i]=[o.width,o.height,o.x,o.y]}return{[Ml.垂直居中]:r+e/2,[Ml.左对齐]:r,[Ml.右对齐]:r+e,[Ml.水平居中]:i+n/2,[Ml.上对齐]:i,[Ml.下对齐]:i+n}}align(t,e){const n=this.getAlignPoints(e)[t],r=this.render.transformer.nodes().filter(t=>t!==e);for(const i of r){const e=this.getAlignRect(i),[r,o,s,a]=[e.width,e.height,e.x,e.y];switch(t){case Ml.垂直居中:{const t=s+r/2;i.x(i.x()+(n-t))}break;case Ml.水平居中:{const t=a+o/2;i.y(i.y()+(n-t))}break;case Ml.左对齐:{const t=s;i.x(i.x()+(n-t))}break;case Ml.右对齐:{const t=s+r;i.x(i.x()+(n-t))}break;case Ml.上对齐:{const t=a;i.y(i.y()+(n-t))}break;case Ml.下对齐:{const t=a+o;i.y(i.y()+(n-t))}}}this.render.updateHistory(),this.render.redraw([rc.name,Fl.name,Rl.name,Bl.name])}}r(Ac,"name","AlignTool");class kc{constructor(t){r(this,"render"),r(this,"linkCurrent"),this.render=t}pointsVisible(t,e){var n;if(!this.render.config.readonly){const r=e??this.render.layer;for(const e of[...["asset","sub-asset"].includes(r.name())?[r]:[],...r.find(".asset"),...r.find(".sub-asset")]){const n=e.getAttr("points")??[];e.setAttrs({points:n.map(e=>({...e,visible:t}))})}(null==(n=this.render.draws[Fl.name])?void 0:n.state.linkManualing)||this.render.redraw([Fl.name,Rl.name,Bl.name])}}remove(t){const e=t??this.linkCurrent;if(e){const{groupId:t,pointId:n,pairId:r}=e.getAttrs();if(t&&n&&r){const e=this.render.layer.findOne(`#${t}`);if(e){const t=(e.getAttr("points")??[]).find(t=>t.id===n);if(t){const n=(t.pairs??[]).findIndex(t=>t.id===r);if(n>-1){const r=t.pairs.splice(n,1)[0];e.attrs.manualPointsMap&&e.attrs.manualPointsMap[r.id]&&e.setAttr("manualPointsMap",{...e.attrs.manualPointsMap,[r.id]:void 0}),this.render.redraw([Fl.name,Rl.name,Bl.name])}}}}}}jsonIdCover(t){let e=[...t];const n=new Map;for(;e.length>0;){const t=e.shift();if(t){if(Array.isArray(t.attrs.points))for(const e of t.attrs.points){if(Array.isArray(e.pairs))for(const t of e.pairs)t.from.groupId&&!n.has(t.from.groupId)&&n.set(t.from.groupId,"g:"+Nl()),t.to.groupId&&!n.has(t.to.groupId)&&n.set(t.to.groupId,"g:"+Nl()),t.from.pointId&&!n.has(t.from.pointId)&&n.set(t.from.pointId,"p:"+Nl()),t.to.pointId&&!n.has(t.to.pointId)&&n.set(t.to.pointId,"p:"+Nl());e.id&&(n.has(e.id)||n.set(e.id,"p:"+Nl())),e.groupId&&(n.has(e.groupId)||n.set(e.groupId,"g:"+Nl()))}t.attrs.id&&(n.has(t.attrs.id)||n.set(t.attrs.id,"n:"+Nl())),Array.isArray(t.children)&&e.push(...t.children)}}for(e=[...t];e.length>0;){const t=e.shift();if(t){if(n.has(t.attrs.id)&&(t.attrs.id=n.get(t.attrs.id)),Array.isArray(t.attrs.points))for(const e of t.attrs.points){if(Array.isArray(e.pairs))for(const t of e.pairs)t.disabled=!0,t.id&&(t.id="pr:"+Nl()),n.has(t.from.groupId)&&(t.from.groupId=n.get(t.from.groupId)),n.has(t.to.groupId)&&(t.to.groupId=n.get(t.to.groupId)),n.has(t.from.pointId)&&(t.from.pointId=n.get(t.from.pointId)),n.has(t.to.pointId)&&(t.to.pointId=n.get(t.to.pointId));if(n.has(e.id)){const r=t.children.find(t=>t.attrs.id===e.id);e.id=n.get(e.id),r&&(r.attrs.id=e.id)}n.has(e.groupId)&&(e.groupId=n.get(e.groupId))}Array.isArray(t.children)&&e.push(...t.children)}}}groupIdCover(t){const e=t.id(),n=t.find(".sub-asset");for(;n.length>0;){const t=n.shift();if(t){const r=t.attrs.points;if(Array.isArray(r))for(const t of r){t.rawGroupId=t.groupId,t.groupId=e;for(const n of t.pairs)n.from.rawGroupId=n.from.groupId,n.from.groupId=e,n.to.rawGroupId=n.to.groupId,n.to.groupId=e}n.push(...t.find(".sub-asset"))}}}select(t){this.render.selectionTool.selectingClear(),this.linkCurrent=t,this.render.emit("link-selection-change",this.linkCurrent),this.render.redraw([Fl.name,Rl.name])}selectingClear(){this.linkCurrent=void 0,this.render.emit("link-selection-change",void 0),this.render.redraw([Fl.name,Rl.name])}}r(kc,"name","LinkTool");class jc{constructor(t){r(this,"render"),r(this,"alignLines",[]),r(this,"attractPoint",t=>{this.alignLinesClear();const n=this.render.getStageState();let r=t.x,i=t.y,o=!1,s=null,a=null;if(!this.render.config.readonly&&this.render.config.attractNode){const t=[{value:this.render.toStageValue(r-n.x)}],h=[{value:this.render.toStageValue(i-n.y)}];let d=1/0,u=[],l=1/0,c=[];for(let e=0;e<t.length-1;e++)if(void 0===t[e].id&&void 0!==t[e+1].id||void 0!==t[e].id&&void 0===t[e+1].id){const n=Math.abs(t[e].value-t[e+1].value);n<d?(d=n,u=[[t[e],t[e+1]]]):n===d&&u.push([t[e],t[e+1]])}for(let e=0;e<h.length-1;e++)if(void 0===h[e].id&&void 0!==h[e+1].id||void 0!==h[e].id&&void 0===h[e+1].id){const t=Math.abs(h[e].value-h[e+1].value);t<l?(l=t,c=[[h[e],h[e+1]]]):t===l&&c.push([h[e],h[e+1]])}if(u[0]&&Math.abs(u[0][0].value-u[0][1].value)<this.render.bgSize/2&&(s=u[0]),c[0]&&Math.abs(c[0][0].value-c[0][1].value)<this.render.bgSize/2&&(a=c[0]),2===(null==s?void 0:s.length)){for(const r of u){const t=r.find(t=>void 0!==t.id);if(t){const r=new e.Line({points:bt.flatten([[t.value,this.render.toStageValue(-n.y)],[t.value,this.render.toStageValue(this.render.stage.height()-n.y)]]),stroke:"blue",strokeWidth:this.render.toStageValue(1),dash:[4,4],listening:!1});this.alignLines.push(r),this.render.layerCover.add(r)}}const t=s.find(t=>void 0===t.id),i=s.find(t=>void 0!==t.id);t&&i&&(r-=this.render.toBoardValue(t.value-i.value),o=!0)}if(2===(null==a?void 0:a.length)){for(const i of c){const t=i.find(t=>void 0!==t.id);if(t){const r=new e.Line({points:bt.flatten([[this.render.toStageValue(-n.x),t.value],[this.render.toStageValue(this.render.stage.width()-n.x),t.value]]),stroke:"blue",strokeWidth:this.render.toStageValue(1),dash:[4,4],listening:!1});this.alignLines.push(r),this.render.layerCover.add(r)}}const t=a.find(t=>void 0===t.id),r=a.find(t=>void 0!==t.id);t&&r&&(i-=this.render.toBoardValue(t.value-r.value),o=!0)}}if(!this.render.config.readonly&&this.render.config.attractBg){if(null===s){const t=this.render.toStageValue(r-n.x),e=Math.round(t/this.render.bgSize)*this.render.bgSize,i=Math.abs(t-e),s=this.render.toStageValue(r-n.x),a=Math.round(s/this.render.bgSize)*this.render.bgSize,h=Math.abs(s-a),d=n.width,u=Math.abs(s-d);for(const l of[{type:"leftX",value:i},{type:"rightX",value:h},{type:"stageRightX",value:u}].sort((t,e)=>t.value-e.value))if(l.value<5){"stageRightX"===l.type?r=this.render.toBoardValue(d)+n.x:"leftX"===l.type?r=this.render.toBoardValue(e)+n.x:"rightX"===l.type&&(r=this.render.toBoardValue(a)+n.x),o=!0;break}}if(null===a){const t=this.render.toStageValue(i-n.y),e=Math.round(t/this.render.bgSize)*this.render.bgSize,r=Math.abs(t-e),s=this.render.toStageValue(i-n.y),a=Math.round(s/this.render.bgSize)*this.render.bgSize,h=Math.abs(s-a),d=n.height,u=Math.abs(s-d);for(const l of[{type:"topY",value:r},{type:"bottomY",value:h},{type:"stageBottomY",value:u}].sort((t,e)=>t.value-e.value))if(l.value<5){"stageBottomY"===l.type?i=this.render.toBoardValue(d)+n.y:"topY"===l.type?i=this.render.toBoardValue(e)+n.y:"bottomY"===l.type&&(i=this.render.toBoardValue(a)+n.y),o=!0;break}}}return{pos:{x:r,y:i},isAttract:o}}),r(this,"attractTransformer",t=>{this.alignLinesClear();const n=this.render.getStageState(),r=this.render.transformer.width(),i=this.render.transformer.height();let o=t.x,s=t.y,a=!1,h=null,d=null;if(!this.render.config.readonly&&this.render.config.attractNode){const{sortX:r,sortY:i}=this.getSortItems(t);let u=1/0,l=[],c=1/0,f=[];for(let t=0;t<r.length-1;t++)if(void 0===r[t].id&&void 0!==r[t+1].id||void 0!==r[t].id&&void 0===r[t+1].id){const e=Math.abs(r[t].value-r[t+1].value);e<u?(u=e,l=[[r[t],r[t+1]]]):e===u&&l.push([r[t],r[t+1]])}for(let t=0;t<i.length-1;t++)if(void 0===i[t].id&&void 0!==i[t+1].id||void 0!==i[t].id&&void 0===i[t+1].id){const e=Math.abs(i[t].value-i[t+1].value);e<c?(c=e,f=[[i[t],i[t+1]]]):e===c&&f.push([i[t],i[t+1]])}if(l[0]&&Math.abs(l[0][0].value-l[0][1].value)<this.render.bgSize/2&&(h=l[0]),f[0]&&Math.abs(f[0][0].value-f[0][1].value)<this.render.bgSize/2&&(d=f[0]),2===(null==h?void 0:h.length)){for(const i of l){const t=i.find(t=>void 0!==t.id);if(t){const r=new e.Line({points:bt.flatten([[t.value,this.render.toStageValue(-n.y)],[t.value,this.render.toStageValue(this.render.stage.height()-n.y)]]),stroke:"blue",strokeWidth:this.render.toStageValue(1),dash:[4,4],listening:!1});this.alignLines.push(r),this.render.layerCover.add(r)}}const t=h.find(t=>void 0===t.id),r=h.find(t=>void 0!==t.id);t&&r&&(o-=this.render.toBoardValue(t.value-r.value),a=!0)}if(2===(null==d?void 0:d.length)){for(const i of f){const t=i.find(t=>void 0!==t.id);if(t){const r=new e.Line({points:bt.flatten([[this.render.toStageValue(-n.x),t.value],[this.render.toStageValue(this.render.stage.width()-n.x),t.value]]),stroke:"blue",strokeWidth:this.render.toStageValue(1),dash:[4,4],listening:!1});this.alignLines.push(r),this.render.layerCover.add(r)}}const t=d.find(t=>void 0===t.id),r=d.find(t=>void 0!==t.id);t&&r&&(s-=this.render.toBoardValue(t.value-r.value),a=!0)}}if(!this.render.config.readonly&&this.render.config.attractBg){if(null===h){const t=this.render.toStageValue(o-n.x),e=Math.round(t/this.render.bgSize)*this.render.bgSize,i=Math.abs(t-e),s=this.render.toStageValue(o+r-n.x),h=Math.round(s/this.render.bgSize)*this.render.bgSize,d=Math.abs(s-h),u=n.width,l=Math.abs(s-u);for(const c of[{type:"leftX",value:i},{type:"rightX",value:d},{type:"stageRightX",value:l}].sort((t,e)=>t.value-e.value))if(c.value<5){"stageRightX"===c.type?o=this.render.toBoardValue(u)+n.x-r:"leftX"===c.type?o=this.render.toBoardValue(e)+n.x:"rightX"===c.type&&(o=this.render.toBoardValue(h)+n.x-r),a=!0;break}}if(null===d){const t=this.render.toStageValue(s-n.y),e=Math.round(t/this.render.bgSize)*this.render.bgSize,r=Math.abs(t-e),o=this.render.toStageValue(s+i-n.y),h=Math.round(o/this.render.bgSize)*this.render.bgSize,d=Math.abs(o-h),u=n.height,l=Math.abs(o-u);for(const c of[{type:"topY",value:r},{type:"bottomY",value:d},{type:"stageBottomY",value:l}].sort((t,e)=>t.value-e.value))if(c.value<5){"stageBottomY"===c.type?s=this.render.toBoardValue(u)+n.y-i:"topY"===c.type?s=this.render.toBoardValue(e)+n.y:"bottomY"===c.type&&(s=this.render.toBoardValue(h)+n.y-i),a=!0;break}}}return{pos:{x:o,y:s},isAttract:a}}),this.render=t}alignLinesClear(){for(const t of this.alignLines)t.destroy();this.alignLines=[]}getSortItems(t){const e=this.render.getStageState(),n=[],r=[];n.push({value:this.render.toStageValue(t.x-e.x)},{value:this.render.toStageValue(t.x-e.x+t.width/2)},{value:this.render.toStageValue(t.x-e.x+t.width)}),r.push({value:this.render.toStageValue(t.y-e.y)},{value:this.render.toStageValue(t.y-e.y+t.height/2)},{value:this.render.toStageValue(t.y-e.y+t.height)});const i=this.render.selectionTool.selectingNodes.map(t=>t._id),o=this.render.layer.find(".asset").filter(t=>!i.includes(t._id));for(const s of o){const t=s.getClientRect();n.push({id:s._id,value:this.render.toStageValue(t.x-e.x)},{id:s._id,value:this.render.toStageValue(t.x-e.x+t.width/2)},{id:s._id,value:this.render.toStageValue(t.x-e.x+t.width)}),r.push({id:s._id,value:this.render.toStageValue(t.y-e.y)},{id:s._id,value:this.render.toStageValue(t.y-e.y+t.height/2)},{id:s._id,value:this.render.toStageValue(t.y-e.y+t.height)})}return n.sort((t,e)=>t.value-e.value),r.sort((t,e)=>t.value-e.value),{sortX:n,sortY:r}}}r(jc,"name","AttractTool");const Ic=class t{constructor(t,n){var i;r(this,"stage"),r(this,"layer",new e.Layer({id:"main"})),r(this,"layerFloor",new e.Layer),r(this,"layerCover",new e.Layer({id:"cover"})),r(this,"config"),r(this,"draws",{}),r(this,"assetTool"),r(this,"selectionTool"),r(this,"copyTool"),r(this,"positionTool"),r(this,"zIndexTool"),r(this,"importExportTool"),r(this,"alignTool"),r(this,"linkTool"),r(this,"attractTool"),r(this,"groupTransformer",new e.Group),r(this,"transformer",new e.Transformer({shouldOverdrawWholeArea:!0,borderDash:[4,4],padding:1,rotationSnaps:[0,45,90,135,180,225,270,315,360],flipEnabled:!1})),r(this,"selectRect",new e.Rect({id:"selectRect",fill:"rgba(0,0,255,0.1)",visible:!1})),r(this,"handlers",{}),r(this,"bgSize",20),r(this,"rulerSize",0),r(this,"previewSize",.2),r(this,"pointSize",6),r(this,"history",[]),r(this,"historyIndex",-1),r(this,"debug",!1),r(this,"graphType"),r(this,"texting",!1),r(this,"emitter",{all:i=i||new Map,on:function(t,e){var n=i.get(t);n?n.push(e):i.set(t,[e])},off:function(t,e){var n=i.get(t);n&&(e?n.splice(n.indexOf(e)>>>0,1):i.set(t,[]))},emit:function(t,e){var n=i.get(t);n&&n.slice().map(function(t){t(e)}),(n=i.get("*"))&&n.slice().map(function(n){n(t,e)})}}),r(this,"on"),r(this,"off"),r(this,"emit"),this.config=n,this.on=this.emitter.on.bind(this.emitter),this.off=this.emitter.off.bind(this.emitter),this.emit=this.emitter.emit.bind(this.emitter),this.config.showRuler&&(this.rulerSize=40),this.stage=new e.Stage({container:t,x:this.rulerSize,y:this.rulerSize,width:n.width,height:n.height}),this.groupTransformer.add(this.transformer),this.groupTransformer.add(this.selectRect),this.layerCover.add(this.groupTransformer),this.config.showBg&&(this.draws[El.name]=new El(this,this.layerFloor,{size:this.bgSize,readonly:this.config.readonly??!1})),this.draws[Fl.name]=new Fl(this,this.layerCover,{size:this.pointSize}),this.draws[Xl.name]=new Xl(this,this.layerCover,{size:this.pointSize}),!this.config.readonly&&this.config.showRuler&&(this.draws[Rl.name]=new Rl(this,this.layerCover,{size:this.rulerSize})),!this.config.readonly&&this.config.showRefLine&&(this.draws[Ll.name]=new Ll(this,this.layerCover,{padding:this.rulerSize})),this.config.showContextmenu&&(this.draws[Wl.name]=new Wl(this,this.layerCover,{})),!this.config.readonly&&this.config.showPreview&&(this.draws[Bl.name]=new Bl(this,this.layerCover,{size:this.previewSize})),this.draws[rc.name]=new rc(this,this.layerCover,{}),this.assetTool=new gc(this),this.selectionTool=new pc(this),this.copyTool=new yc(this),this.positionTool=new mc(this),this.zIndexTool=new vc(this),this.importExportTool=new _c(this),this.alignTool=new Ac(this),this.linkTool=new kc(this),this.attractTool=new jc(this),this.handlers[ic.name]=new ic(this),this.handlers[oc.name]=new oc(this),this.config.readonly||(this.handlers[sc.name]=new sc(this),this.handlers[ac.name]=new ac(this),this.handlers[hc.name]=new hc(this),this.handlers[uc.name]=new uc(this),this.handlers[lc.name]=new lc(this),this.handlers[cc.name]=new cc(this)),!this.config.readonly&&this.config.showRefLine&&void 0!==this.draws[Ll.name]&&(this.handlers[Ll.name]=this.draws[Ll.name]),this.handlers[dc.name]=new dc(this),this.init(),this.config.configJson&&this.importExportTool.restore(this.config.configJson)}changeDebug(t){var e,n,r,i,o,s;return this.debug=t,this.emit("debug-change",this.debug),null==(e=this.draws[Fl.name])||e.init(),null==(n=this.draws[Xl.name])||n.init(),null==(r=this.draws[Rl.name])||r.init(),null==(i=this.draws[Ll.name])||i.init(),null==(o=this.draws[Wl.name])||o.init(),null==(s=this.draws[Bl.name])||s.init(),this.debug}init(){var t,e,n,r,i,o,s;this.stage.add(this.layerFloor),null==(t=this.draws[El.name])||t.init(),this.stage.add(this.layer),this.stage.add(this.layerCover),null==(e=this.draws[Fl.name])||e.init(),null==(n=this.draws[Xl.name])||n.init(),null==(r=this.draws[Rl.name])||r.init(),null==(i=this.draws[Ll.name])||i.init(),null==(o=this.draws[Wl.name])||o.init(),null==(s=this.draws[Bl.name])||s.init(),this.eventBind(),this.updateHistory()}resize(t,e){this.stage.setAttrs({width:t,height:e}),this.redraw()}remove(t){for(const n of t)if(n instanceof e.Transformer)this.remove(this.selectionTool.selectingNodes);else{const t=n.id();for(const e of this.layer.getChildren())if(e.id()!==t&&Array.isArray(e.attrs.points)){for(const n of e.attrs.points)Array.isArray(n.pairs)&&(e.attrs.manualPointsMap&&n.pairs.filter(e=>e.from.groupId===t||e.to.groupId===t).forEach(t=>{e.attrs.manualPointsMap[t.id]=void 0}),n.pairs=n.pairs.filter(e=>e.from.groupId!==t&&e.to.groupId!==t));e.setAttr("points",e.attrs.points)}n.destroy()}t.length>0&&(this.selectionTool.selectingClear(),this.linkTool.selectingClear(),this.updateHistory(),this.redraw())}prevHistory(){const t=this.history[this.historyIndex-1];t&&(this.importExportTool.restore(t,!0),this.historyIndex--,this.emit("history-change",{records:bt.clone(this.history),index:this.historyIndex}))}nextHistory(){const t=this.history[this.historyIndex+1];t&&(this.importExportTool.restore(t,!0),this.historyIndex++,this.emit("history-change",{records:bt.clone(this.history),index:this.historyIndex}))}updateHistory(){this.history.splice(this.historyIndex+1),this.history.push(this.importExportTool.save()),this.historyIndex=this.history.length-1,this.emit("history-change",{records:bt.clone(this.history),index:this.historyIndex})}eventBind(){var t,e;for(const r of["mousedown","mouseup","mousemove","wheel","contextmenu","pointerclick"])this.stage.on(r,t=>{var e,n,i,o,s,a,h,d,u;null==(e=null==t?void 0:t.evt)||e.preventDefault();for(const l in this.draws)null==(s=null==(o=null==(i=null==(n=this.draws[l])?void 0:n.handlers)?void 0:i.stage)?void 0:o[r])||s.call(o,t);for(const l in this.handlers)null==(u=null==(d=null==(h=null==(a=this.handlers[l])?void 0:a.handlers)?void 0:h.stage)?void 0:d[r])||u.call(d,t)});const n=this.stage.container();n.tabIndex=1,n.focus();for(const r of["mouseenter","dragenter","mousemove","mouseout","dragenter","dragover","drop","keydown","keyup"])n.addEventListener(r,t=>{var e,n,i,o,s,a,h,d;null==t||t.preventDefault(),["mouseenter","dragenter"].includes(r)&&this.stage.container().focus();for(const u in this.draws)null==(o=null==(i=null==(n=null==(e=this.draws[u])?void 0:e.handlers)?void 0:n.dom)?void 0:i[r])||o.call(i,t);for(const u in this.handlers)null==(d=null==(h=null==(a=null==(s=this.handlers[u])?void 0:s.handlers)?void 0:a.dom)?void 0:h[r])||d.call(h,t)});for(const r of["mousedown","transformstart","transform","transformend","dragstart","dragmove","dragend","mousemove","mouseleave","dblclick"])this.transformer.on(r,t=>{var e,n,i,o,s,a,h,d,u;null==(e=null==t?void 0:t.evt)||e.preventDefault();for(const l in this.draws)null==(s=null==(o=null==(i=null==(n=this.draws[l])?void 0:n.handlers)?void 0:i.transformer)?void 0:o[r])||s.call(o,t);for(const l in this.handlers)null==(u=null==(d=null==(h=null==(a=this.handlers[l])?void 0:a.handlers)?void 0:h.transformer)?void 0:d[r])||u.call(d,t)});(null==(e=null==(t=this.handlers[ac.name])?void 0:t.transformerConfig)?void 0:e.anchorDragBoundFunc)&&this.transformer.anchorDragBoundFunc(this.handlers[ac.name].transformerConfig.anchorDragBoundFunc)}getStageState(){return{width:this.stage.width()-this.rulerSize,height:this.stage.height()-this.rulerSize,scale:this.stage.scaleX(),x:this.stage.x(),y:this.stage.y()}}toStageValue(t){return t/this.stage.scaleX()}toBoardValue(t){return t*this.stage.scaleX()}ignore(t){return!(t instanceof e.Group)||this.ignoreSelect(t)||this.ignoreDraw(t)||this.ignoreLink(t)}ignoreSelect(t){return"selectRect"===t.id()||"hoverRect"===t.id()}ignoreDraw(t){return t.name()===El.name||t.name()===Rl.name||t.name()===Ll.name||t.name()===Wl.name||t.name()===Bl.name||t.name()===Fl.name||t.name()===Xl.name||t.name()===rc.name}ignoreLink(t){return"link-anchor"===t.name()||"linking-line"===t.name()||"link-point"===t.name()||"link-line"===t.name()||"link-manual-point"===t.name()}redraw(t){var e,n;const r=[El.name,rc.name,Fl.name,Xl.name,Rl.name,Ll.name,Bl.name,Wl.name];if(Array.isArray(t)&&!this.debug)for(const i of r)t.includes(i)&&(null==(e=this.draws[i])||e.draw());else for(const i of r)null==(n=this.draws[i])||n.draw()}changeDraggable(t){this.layer.children.forEach(e=>{e.draggable(t)})}changeGraphType(t){t&&(this.texting=!1,this.emit("texting-change",this.texting)),this.graphType=t,this.emit("graph-type-change",this.graphType),this.changeDraggable(!this.config.readonly&&void 0===this.graphType)}changeTexting(t){t&&(this.graphType=void 0,this.emit("graph-type-change",this.graphType)),this.texting=t,this.emit("texting-change",this.texting),document.body.style.cursor=this.texting?"text":"default"}getPageSettings(){return this.stage.attrs.pageSettings??{...t.PageSettingsDefault}}setPageSettings(t,e=!1){this.stage.setAttr("pageSettings",t),this.updateBackground(),e&&this.updateHistory()}getBackground(){var t;return null==(t=this.draws[El.name])?void 0:t.layer.findOne(`.${El.name}__background`)}updateBackground(){var t,e,n,r;const i=this.getBackground();i&&i.fill(this.getPageSettings().background??"transparent"),null==(t=this.draws[El.name])||t.draw(),null==(e=this.draws[rc.name])||e.draw(),null==(n=this.draws[Fl.name])||n.draw(),null==(r=this.draws[Bl.name])||r.draw()}getAssetSettings(e){const n=(null==e?void 0:e.attrs.assetSettings)??{...t.AssetSettingsDefault};return{...n,stroke:n.stroke||this.getPageSettings().stroke,strokeWidth:n.strokeWidth||this.getPageSettings().strokeWidth,fontSize:n.fontSize||this.getPageSettings().fontSize,textFill:n.textFill||this.getPageSettings().textFill,fill:n.fill||((null==e?void 0:e.attrs.assetType)===Cl.Graph?"transparent":this.getPageSettings().fill),x:parseFloat(((null==e?void 0:e.position().x)??0).toFixed(1)),y:parseFloat(((null==e?void 0:e.position().y)??0).toFixed(1)),rotation:parseFloat(((null==e?void 0:e.rotation())??0).toFixed(1)),tension:(null==e?void 0:e.attrs.assetType)===Cl.Graph&&(null==e?void 0:e.attrs.graphType)===Vl.Curve?n.tension:void 0}}setSvgXMLSettings(t,e){const n=t.match(/<(circle|ellipse|line|path|polygon|rect|text|textPath|tref|tspan)[^>/]*\/?>/g),r=/ stroke="([^"]*)"/,i=/ fill="([^"]*)"/;for(const o of n??[]){let n=o;e.stroke&&(n=r.test(o)?n.replace(r,` stroke="${e.stroke}"`):n.replace(/(<[^>/]*)(\/?>)/,`$1 stroke="${e.stroke}" $2`)),e.fill&&(n=i.test(o)?n.replace(i,` fill="${e.fill}"`):n.replace(/(<[^>/]*)(\/?>)/,`$1 fill="${e.fill}" $2`)),t=t.replace(o,n)}return t}rotatePoint({x:t,y:e},n){const r=Math.cos(n),i=Math.sin(n);return{x:t*r-e*i,y:e*r+t*i}}rotateAroundCenter(t,n){const r={x:-t.width()/2,y:-t.height()/2},i=this.rotatePoint(r,e.getAngle(t.rotation())),o=this.rotatePoint(r,e.getAngle(n)),s=o.x-i.x,a=o.y-i.y;t.rotation(n),t.x(t.x()+s),t.y(t.y()+a)}async setAssetSettings(t,n,r=!1){var i,o,s,a,h;if(t.setAttr("assetSettings",n),t instanceof e.Group){if(t.attrs.imageType===Ol.svg){const r=t.children[0];if(r instanceof e.Image&&r.attrs.svgXML){const t=await this.assetTool.loadSvgXML(this.setSvgXMLSettings(r.attrs.svgXML,n));null==(i=r.parent)||i.add(t),r.remove(),r.destroy(),t.zIndex(0)}}else if(t.attrs.assetType===Cl.Graph){const r=t.findOne(".graph");r instanceof e.Shape&&(r.strokeWidth(n.strokeWidth),r.stroke(n.stroke),r instanceof e.Arrow?r.fill(n.stroke):r.fill(n.fill),r instanceof e.Arrow&&(r.pointerAtBeginning(n.arrowStart),r.pointerAtEnding(n.arrowEnd)),r instanceof e.Arrow&&t.attrs.graphType===Vl.Curve&&r.tension(n.tension))}else if(t.attrs.assetType===Cl.Text){const r=t.findOne("Text"),i=t.findOne("Rect");if(r instanceof e.Text&&i instanceof e.Rect){let e=!1;r.fontSize()===n.fontSize&&r.text()===n.text||(e=!0),r.fill(n.textFill),r.fontSize(n.fontSize),r.text(n.text),i.fill(r.text().trim()?"":"rgba(0,0,0,0.1)"),i.width(Math.max(r.width(),n.fontSize)),i.height(Math.max(r.height(),n.fontSize)),e&&this.selectionTool.select([t])}}if(Math.abs(n.rotation-t.rotation())>=.1)this.rotateAroundCenter(t,n.rotation),this.emit("asset-position-change",[t]);else{const e=this.getAssetSettings(t);t.position({x:parseFloat(n.x.toFixed(1)),y:parseFloat(n.y.toFixed(1))}),n.x===e.x&&n.y===e.y||this.emit("asset-position-change",[t])}}r&&this.updateHistory(),null==(o=this.draws[El.name])||o.draw(),null==(s=this.draws[rc.name])||s.draw(),null==(a=this.draws[Fl.name])||a.draw(),null==(h=this.draws[Bl.name])||h.draw()}async setLinkSettings(t,e,n=!1){var r,i,o,s;const a=this.layer.findOne(`#${t.attrs.groupId}`);if(Array.isArray(null==a?void 0:a.attrs.points)){const n=(null==a?void 0:a.attrs.points).find(e=>e.id===t.attrs.pointId);if(n){const r=n.pairs.find(e=>e.id===t.attrs.pairId);r&&(r.style={...r.style,...e},a.setAttr("points",null==a?void 0:a.attrs.points))}}n&&this.updateHistory(),null==(r=this.draws[El.name])||r.draw(),null==(i=this.draws[rc.name])||i.draw(),null==(o=this.draws[Fl.name])||o.draw(),null==(s=this.draws[Bl.name])||s.draw()}getLinkSettings(e){let n;if(e){const t=this.layer.findOne(`#${e.attrs.groupId}`);if(Array.isArray(null==t?void 0:t.attrs.points)){const r=(null==t?void 0:t.attrs.points).find(t=>t.id===e.attrs.pointId);if(r){const t=r.pairs.find(t=>t.id===e.attrs.pairId);t&&(n=t.style)}}}const r=n??{...t.LinkSettingsDefault};return{...r,stroke:r.stroke||this.getPageSettings().linkStroke,strokeWidth:r.strokeWidth||this.getPageSettings().linkStrokeWidth}}};r(Ic,"PageSettingsDefault",{background:"transparent",stroke:"rgb(0,0,0)",strokeWidth:1,fill:"rgb(0,0,0)",linkStroke:"rgb(0,0,0)",linkStrokeWidth:1,fontSize:24,textFill:"rgb(0,0,0)"}),r(Ic,"AssetSettingsDefault",{stroke:"",strokeWidth:0,fill:"",arrowStart:!1,arrowEnd:!1,fontSize:0,textFill:"",text:"Text",x:0,y:0,rotation:0,tension:0}),r(Ic,"LinkSettingsDefault",{stroke:"",strokeWidth:0,arrowStart:!1,arrowEnd:!1,tension:0});let Tc=Ic;const Pc={Render:Tc};t.AlignType=Ml,t.AssetType=Cl,t.BaseDraw=Il,t.GraphType=Vl,t.ImageType=Ol,t.LinkType=zl,t.MouseButton=jl,t.MoveKey=Tl,t.Render=Tc,t.ShutcutKey=Pl,t.default=Pc,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
24
+ //# sourceMappingURL=webtopo.umd.js.map