@quandis/qbo4.ui 4.0.1-CI-20240405-163539 → 4.0.1-CI-20240406-034601
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/package.json +1 -1
- package/src/qbo/qbo-api.d.ts +1 -1
- package/src/qbo/qbo-breadcrumb.d.ts +2 -2
- package/src/qbo/qbo-datalist.d.ts +1 -1
- package/src/qbo/qbo-docviewer.d.ts +1 -1
- package/src/qbo/qbo-form-element.d.ts +1 -1
- package/src/qbo/qbo-form-element.ts +117 -117
- package/src/qbo/qbo-link.d.ts +1 -1
- package/src/qbo/qbo-logging.d.ts +1 -1
- package/src/qbo/qbo-mainmenu.d.ts +7 -7
- package/src/qbo/qbo-markdown.d.ts +1 -1
- package/src/qbo/qbo-microphone.d.ts +1 -1
- package/src/qbo/qbo-popover.d.ts +1 -1
- package/src/qbo/qbo-popup-listener.d.ts +1 -1
- package/src/qbo/qbo-popup.d.ts +1 -1
- package/src/qbo/qbo-select.d.ts +1 -1
- package/src/qbo/qbo-sidebar.d.ts +1 -1
- package/src/qbo/qbo-table.d.ts +1 -1
- package/src/qbo/qbo-validate.d.ts +1 -1
- package/src/qbo/qbo-validators.d.ts +37 -37
- package/src/qbo-flowchart/qbo-flowchart.d.ts +1 -1
- package/wwwroot/js/qbo4.ui-code.js +44 -1544
- package/wwwroot/js/qbo4.ui-code.min.js +1 -1
- package/wwwroot/js/qbo4.ui-code.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui-flowchart.js +44 -1544
- package/wwwroot/js/qbo4.ui-flowchart.min.js +2 -2
- package/wwwroot/js/qbo4.ui-flowchart.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui.js +6488 -6454
- package/wwwroot/js/qbo4.ui.min.js +28 -28
- package/wwwroot/js/qbo4.ui.min.js.map +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! For license information please see qbo4.ui-flowchart.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qbo4=e():(t.qbo4=t.qbo4||{},t.qbo4["ui-flowchart"]=e())}(self,(()=>(()=>{var t={630:(t,e,n)=>{var i;!function(t){!function(e){var i="object"==typeof globalThis?globalThis:"object"==typeof n.g?n.g:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=o(t);function o(t,e){return function(n,i){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:i}),e&&e(n,i)}}void 0!==i.Reflect&&(r=o(i.Reflect,r)),function(t,e){var n=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,r=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",s="function"==typeof Object.create,a={__proto__:[]}instanceof Array,l=!s&&!a,c={create:s?function(){return j(Object.create(null))}:a?function(){return j({__proto__:null})}:function(){return j({})},has:l?function(t,e){return n.call(t,e)}:function(t,e){return e in t},get:l?function(t,e){return n.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},h=Object.getPrototypeOf(Function),u="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var i=this._keys.length,r=n+1;r<i;r++)this._keys[r-1]=this._keys[r],this._values[r-1]=this._values[r];return this._keys.length--,this._values.length--,R(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new n(this._keys,this._values,i)},e.prototype.values=function(){return new n(this._keys,this._values,r)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!R(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(R(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function i(t,e){return t}function r(t,e){return e}function s(t,e){return[t,e]}}(),d="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function t(){this._map=new u}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}(),f="function"==typeof WeakMap?WeakMap:function(){var t=16,e=c.create(),i=r();return function(){function t(){this._key=r()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=r()},t}();function r(){var t;do{t="@@WeakMap@@"+a()}while(c.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,i)){if(!e)return;Object.defineProperty(t,i,{value:c.create()})}return t[i]}function s(t,e){for(var n=0;n<e;++n)t[n]=255*Math.random()|0;return t}function a(){var e=function(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):s(e,t),e}return s(new Array(t),t)}(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var n="",i=0;i<t;++i){var r=e[i];4!==i&&6!==i&&8!==i||(n+="-"),r<16&&(n+="0"),n+=r.toString(16).toLowerCase()}return n}}(),p=i?Symbol.for("@reflect-metadata:registry"):void 0,g=function(){var t;return!S(p)&&P(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[p]),S(t)&&(t=function(){var t,n,i,r;S(p)||void 0===e.Reflect||p in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=function(t){var e=t.defineMetadata,n=t.hasOwnMetadata,i=t.getOwnMetadata,r=t.getOwnMetadataKeys,o=t.deleteMetadata,s=new f;return{isProviderFor:function(t,e){var n=s.get(t);return!(S(n)||!n.has(e))||!!r(t,e).length&&(S(n)&&(n=new d,s.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:r,OrdinaryDeleteMetadata:o}}(e.Reflect));var o=new f,s={registerProvider:a,getProvider:c,setProvider:g};return s;function a(e){if(!Object.isExtensible(s))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case S(n):n=e;break;case n===e:break;case S(i):i=e;break;case i===e:break;default:void 0===r&&(r=new d),r.add(e)}}function l(e,o){if(!S(n)){if(n.isProviderFor(e,o))return n;if(!S(i)){if(i.isProviderFor(e,o))return n;if(!S(r))for(var s=I(r);;){var a=D(s);if(!a)return;var l=B(a);if(l.isProviderFor(e,o))return V(s),l}}}if(!S(t)&&t.isProviderFor(e,o))return t}function c(t,e){var n,i=o.get(t);return S(i)||(n=i.get(e)),S(n)?(S(n=l(t,e))||(S(i)&&(i=new u,o.set(t,i)),i.set(e,n)),n):n}function h(t){if(S(t))throw new TypeError;return n===t||i===t||!S(r)&&r.has(t)}function g(t,e,n){if(!h(n))throw new Error("Metadata provider not registered.");var i=c(t,e);if(i!==n){if(!S(i))return!1;var r=o.get(t);S(r)&&(r=new u,o.set(t,r)),r.set(e,n)}return!0}}()),!S(p)&&P(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}(),m=function(t){var e=new f,n={isProviderFor:function(t,n){var i=e.get(t);return!S(i)&&i.has(n)},OrdinaryDefineOwnMetadata:function(t,e,n,r){i(n,r,!0).set(t,e)},OrdinaryHasOwnMetadata:function(t,e,n){var r=i(e,n,!1);return!S(r)&&C(r.has(t))},OrdinaryGetOwnMetadata:function(t,e,n){var r=i(e,n,!1);if(!S(r))return r.get(t)},OrdinaryOwnMetadataKeys:function(t,e){var n=[],r=i(t,e,!1);if(S(r))return n;for(var o=I(r.keys()),s=0;;){var a=D(o);if(!a)return n.length=s,n;var l=B(a);try{n[s]=l}catch(t){try{V(o)}finally{throw t}}s++}},OrdinaryDeleteMetadata:function(t,n,r){var o=i(n,r,!1);if(S(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var s=e.get(n);S(s)||(s.delete(r),0===s.size&&e.delete(s))}return!0}};return g.registerProvider(n),n;function i(i,r,o){var s=e.get(i),a=!1;if(S(s)){if(!o)return;s=new u,e.set(i,s),a=!0}var l=s.get(r);if(S(l)){if(!o)return;if(l=new u,s.set(r,l),!t.setProvider(i,r,n))throw s.delete(r),a&&e.delete(i),new Error("Wrong provider for target.")}return l}}(g);function v(t,e,n){if(y(t,e,n))return!0;var i=$(e);return!_(i)&&v(t,i,n)}function y(t,e,n){var i=z(e,n,!1);return!S(i)&&C(i.OrdinaryHasOwnMetadata(t,e,n))}function b(t,e,n){if(y(t,e,n))return w(t,e,n);var i=$(e);return _(i)?void 0:b(t,i,n)}function w(t,e,n){var i=z(e,n,!1);if(!S(i))return i.OrdinaryGetOwnMetadata(t,e,n)}function x(t,e,n,i){z(n,i,!0).OrdinaryDefineOwnMetadata(t,e,n,i)}function A(t,e){var n=E(t,e),i=$(t);if(null===i)return n;var r=A(i,e);if(r.length<=0)return n;if(n.length<=0)return r;for(var o=new d,s=[],a=0,l=n;a<l.length;a++){var c=l[a];o.has(c)||(o.add(c),s.push(c))}for(var h=0,u=r;h<u.length;h++)c=u[h],o.has(c)||(o.add(c),s.push(c));return s}function E(t,e){var n=z(t,e,!1);return n?n.OrdinaryOwnMetadataKeys(t,e):[]}function T(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function S(t){return void 0===t}function _(t){return null===t}function P(t){return"object"==typeof t?null!==t:"function"==typeof t}function k(t,e){switch(T(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n=3===e?"string":5===e?"number":"default",i=F(t,r);if(void 0!==i){var o=i.call(t,n);if(P(o))throw new TypeError;return o}return function(t,e){if("string"===e){var n=t.toString;if(O(n)&&!P(r=n.call(t)))return r;if(O(i=t.valueOf)&&!P(r=i.call(t)))return r}else{var i;if(O(i=t.valueOf)&&!P(r=i.call(t)))return r;var r,o=t.toString;if(O(o)&&!P(r=o.call(t)))return r}throw new TypeError}(t,"default"===n?"number":n)}function C(t){return!!t}function L(t){var e=k(t,3);return"symbol"==typeof e?e:function(t){return""+t}(e)}function M(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function O(t){return"function"==typeof t}function N(t){return"function"==typeof t}function R(t,e){return t===e||t!=t&&e!=e}function F(t,e){var n=t[e];if(null!=n){if(!O(n))throw new TypeError;return n}}function I(t){var e=F(t,o);if(!O(e))throw new TypeError;var n=e.call(t);if(!P(n))throw new TypeError;return n}function B(t){return t.value}function D(t){var e=t.next();return!e.done&&e}function V(t){var e=t.return;e&&e.call(t)}function $(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===h)return e;if(e!==h)return e;var n=t.prototype,i=n&&Object.getPrototypeOf(n);if(null==i||i===Object.prototype)return e;var r=i.constructor;return"function"!=typeof r||r===t?e:r}function z(t,e,n){var i=g.getProvider(t,e);if(!S(i))return i;if(n){if(g.setProvider(t,e,m))return m;throw new Error("Illegal state.")}}function j(t){return t.__=void 0,delete t.__,t}t("decorate",(function(t,e,n,i){if(S(n)){if(!M(t))throw new TypeError;if(!N(e))throw new TypeError;return function(t,e){for(var n=t.length-1;n>=0;--n){var i=(0,t[n])(e);if(!S(i)&&!_(i)){if(!N(i))throw new TypeError;e=i}}return e}(t,e)}if(!M(t))throw new TypeError;if(!P(e))throw new TypeError;if(!P(i)&&!S(i)&&!_(i))throw new TypeError;return _(i)&&(i=void 0),function(t,e,n,i){for(var r=t.length-1;r>=0;--r){var o=(0,t[r])(e,n,i);if(!S(o)&&!_(o)){if(!P(o))throw new TypeError;i=o}}return i}(t,e,n=L(n),i)})),t("metadata",(function(t,e){return function(n,i){if(!P(n))throw new TypeError;if(!S(i)&&!function(t){switch(T(t)){case 3:case 4:return!0;default:return!1}}(i))throw new TypeError;x(t,e,n,i)}})),t("defineMetadata",(function(t,e,n,i){if(!P(n))throw new TypeError;return S(i)||(i=L(i)),x(t,e,n,i)})),t("hasMetadata",(function(t,e,n){if(!P(e))throw new TypeError;return S(n)||(n=L(n)),v(t,e,n)})),t("hasOwnMetadata",(function(t,e,n){if(!P(e))throw new TypeError;return S(n)||(n=L(n)),y(t,e,n)})),t("getMetadata",(function(t,e,n){if(!P(e))throw new TypeError;return S(n)||(n=L(n)),b(t,e,n)})),t("getOwnMetadata",(function(t,e,n){if(!P(e))throw new TypeError;return S(n)||(n=L(n)),w(t,e,n)})),t("getMetadataKeys",(function(t,e){if(!P(t))throw new TypeError;return S(e)||(e=L(e)),A(t,e)})),t("getOwnMetadataKeys",(function(t,e){if(!P(t))throw new TypeError;return S(e)||(e=L(e)),E(t,e)})),t("deleteMetadata",(function(t,e,n){if(!P(e))throw new TypeError;if(S(n)||(n=L(n)),!P(e))throw new TypeError;S(n)||(n=L(n));var i=z(e,n,!1);return!S(i)&&i.OrdinaryDeleteMetadata(t,e,n)}))}(r,i),void 0===i.Reflect&&(i.Reflect=t)}()}(i||(i={}))}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.r(i),n.d(i,{QboFlowchart:()=>tf});var t={};n.r(t),n.d(t,{ellipseWithEllipse:()=>Cn,ellipseWithLine:()=>kn,exists:()=>_n,lineWithLine:()=>Pn,pathWithEllipse:()=>Un,pathWithLine:()=>jn,pathWithPath:()=>Wn,pathWithPolygon:()=>qn,pathWithPolyline:()=>Hn,pathWithRect:()=>Gn,polygonWithEllipse:()=>Dn,polygonWithLine:()=>Bn,polygonWithPolygon:()=>zn,polygonWithPolyline:()=>$n,polygonWithRect:()=>Vn,polylineWithEllipse:()=>Rn,polylineWithLine:()=>Nn,polylineWithPolyline:()=>In,polylineWithRect:()=>Fn,rectWithEllipse:()=>Mn,rectWithLine:()=>Ln,rectWithRect:()=>On});var e={};n.r(e),n.d(e,{Curve:()=>hn,Ellipse:()=>Ue,Line:()=>De,Path:()=>dn,Point:()=>Re,Polygon:()=>Sn,Polyline:()=>rn,Rect:()=>Je,bezier:()=>Tn,ellipse:()=>Ge,intersection:()=>ni,line:()=>Ve,normalizeAngle:()=>de,point:()=>Fe,random:()=>me,rect:()=>Qe,scale:()=>ue,snapToGrid:()=>fe,toDeg:()=>pe,toRad:()=>ge,types:()=>Ee});var r={};n.r(r),n.d(r,{addClass:()=>qs,append:()=>Is,appendTo:()=>Ds,children:()=>Xs,clone:()=>Rs,closest:()=>Zs,css:()=>js,data:()=>Us,detach:()=>Os,empty:()=>Ns,hasClass:()=>Ys,height:()=>ea,html:()=>Fs,off:()=>Qs,offset:()=>ia,on:()=>Ks,one:()=>Js,position:()=>na,prepend:()=>Bs,prependTo:()=>Vs,remove:()=>Ms,removeClass:()=>Hs,toggleClass:()=>Ws,width:()=>ta});var o={};n.r(o),n.d(o,{animate:()=>sa,stop:()=>la});var s={};n.r(s),n.d(s,{absolute:()=>Xl,bottom:()=>ec,ellipse:()=>ic,ellipseSpread:()=>nc,fn:()=>Zl,left:()=>Jl,line:()=>Kl,right:()=>Ql,top:()=>tc});var a={};n.r(a),n.d(a,{bottom:()=>fc,inside:()=>vc,insideOriented:()=>mc,left:()=>hc,manual:()=>cc,outside:()=>gc,outsideOriented:()=>pc,radial:()=>yc,radialOriented:()=>bc,right:()=>uc,top:()=>dc});var l={};n.r(l),n.d(l,{BorderedImage:()=>Nc,Circle:()=>Pc,Cylinder:()=>Bc,DoubleLink:()=>zc,Ellipse:()=>kc,EmbeddedImage:()=>Rc,HeaderedRectangle:()=>Ic,Image:()=>Oc,InscribedImage:()=>Fc,Link:()=>$c,Path:()=>Cc,Polygon:()=>Lc,Polyline:()=>Mc,Rectangle:()=>_c,ShadowLink:()=>jc,TextBlock:()=>Vc});var c={};n.r(c),n.d(c,{standard:()=>l});var h={};n.r(h),n.d(h,{manhattan:()=>nu,metro:()=>ru,normal:()=>Ah,oneSide:()=>Eh,orthogonal:()=>Dh,rightAngle:()=>wu});var u={};n.r(u),n.d(u,{curve:()=>zu,jumpover:()=>Ru,normal:()=>Fu,rounded:()=>Bu,smooth:()=>Du,straight:()=>Su});var d={};n.r(d),n.d(d,{addClass:()=>sd,list:()=>ld,mask:()=>id,opacity:()=>rd,stroke:()=>ed});var f={};n.r(f),n.d(f,{connectionClosest:()=>pd,connectionLength:()=>hd,connectionPerpendicular:()=>fd,connectionRatio:()=>cd,resolveRef:()=>ud});var p={};n.r(p),n.d(p,{anchor:()=>wd,bbox:()=>xd,boundary:()=>Ed,rectangle:()=>Ad});var g={};n.r(g),n.d(g,{bottom:()=>Pd,bottomLeft:()=>Od,bottomRight:()=>Nd,center:()=>Sd,left:()=>kd,midSide:()=>Fd,modelCenter:()=>Id,perpendicular:()=>Rd,right:()=>Cd,top:()=>_d,topLeft:()=>Ld,topRight:()=>Md}),n(630);const m=window,v=m.ShadowRoot&&(void 0===m.ShadyCSS||m.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,y=Symbol(),b=new WeakMap;class w{constructor(t,e,n){if(this._$cssResult$=!0,n!==y)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(v&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=b.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&b.set(e,t))}return t}toString(){return this.cssText}}const x=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,n,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[i+1]),t[0]);return new w(n,t,y)},A=v?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new w("string"==typeof t?t:t+"",void 0,y))(e)})(t):t;var E;const T=window,S=T.trustedTypes,_=S?S.emptyScript:"",P=T.reactiveElementPolyfillSupport,k={toAttribute(t,e){switch(e){case Boolean:t=t?_:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},C=(t,e)=>e!==t&&(e==e||t==t),L={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:C},M="finalized";class O extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,n)=>{const i=this._$Ep(n,e);void 0!==i&&(this._$Ev.set(i,n),t.push(i))})),t}static createProperty(t,e=L){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const n="symbol"==typeof t?Symbol():"__"+t,i=this.getPropertyDescriptor(t,n,e);void 0!==i&&Object.defineProperty(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){return{get(){return this[e]},set(i){const r=this[t];this[e]=i,this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||L}static finalize(){if(this.hasOwnProperty(M))return!1;this[M]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const n of e)this.createProperty(n,t[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(A(t))}else void 0!==t&&e.push(A(t));return e}static _$Ep(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,n;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(n=t.hostConnected)||void 0===n||n.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{v?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const n=document.createElement("style"),i=m.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=e.cssText,t.appendChild(n)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$EO(t,e,n=L){var i;const r=this.constructor._$Ep(t,n);if(void 0!==r&&!0===n.reflect){const o=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:k).toAttribute(e,n.type);this._$El=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$El=null}}_$AK(t,e){var n;const i=this.constructor,r=i._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=i.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(n=t.converter)||void 0===n?void 0:n.fromAttribute)?t.converter:k;this._$El=r,this[r]=o.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,n){let i=!0;void 0!==t&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||C)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,n))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(n)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(n)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var N;O[M]=!0,O.elementProperties=new Map,O.elementStyles=[],O.shadowRootOptions={mode:"open"},null==P||P({ReactiveElement:O}),(null!==(E=T.reactiveElementVersions)&&void 0!==E?E:T.reactiveElementVersions=[]).push("1.6.3");const R=window,F=R.trustedTypes,I=F?F.createPolicy("lit-html",{createHTML:t=>t}):void 0,B="$lit$",D=`lit$${(Math.random()+"").slice(9)}$`,V="?"+D,$=`<${V}>`,z=document,j=()=>z.createComment(""),U=t=>null===t||"object"!=typeof t&&"function"!=typeof t,G=Array.isArray,H="[ \t\n\f\r]",q=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,W=/-->/g,Y=/>/g,X=RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Z=/'/g,K=/"/g,J=/^(?:script|style|textarea|title)$/i,Q=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),tt=(Q(1),Q(2),Symbol.for("lit-noChange")),et=Symbol.for("lit-nothing"),nt=new WeakMap,it=z.createTreeWalker(z,129,null,!1);function rt(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==I?I.createHTML(e):e}const ot=(t,e)=>{const n=t.length-1,i=[];let r,o=2===e?"<svg>":"",s=q;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(s.lastIndex=h,l=s.exec(n),null!==l);)h=s.lastIndex,s===q?"!--"===l[1]?s=W:void 0!==l[1]?s=Y:void 0!==l[2]?(J.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=X):void 0!==l[3]&&(s=X):s===X?">"===l[0]?(s=null!=r?r:q,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?X:'"'===l[3]?K:Z):s===K||s===Z?s=X:s===W||s===Y?s=q:(s=X,r=void 0);const u=s===X&&t[e+1].startsWith("/>")?" ":"";o+=s===q?n+$:c>=0?(i.push(a),n.slice(0,c)+B+n.slice(c)+D+u):n+D+(-2===c?(i.push(void 0),e):u)}return[rt(t,o+(t[n]||"<?>")+(2===e?"</svg>":"")),i]};class st{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,o=0;const s=t.length-1,a=this.parts,[l,c]=ot(t,e);if(this.el=st.createElement(l,n),it.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(i=it.nextNode())&&a.length<s;){if(1===i.nodeType){if(i.hasAttributes()){const t=[];for(const e of i.getAttributeNames())if(e.endsWith(B)||e.startsWith(D)){const n=c[o++];if(t.push(e),void 0!==n){const t=i.getAttribute(n.toLowerCase()+B).split(D),e=/([.?@])?(.*)/.exec(n);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?ut:"?"===e[1]?ft:"@"===e[1]?pt:ht})}else a.push({type:6,index:r})}for(const e of t)i.removeAttribute(e)}if(J.test(i.tagName)){const t=i.textContent.split(D),e=t.length-1;if(e>0){i.textContent=F?F.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],j()),it.nextNode(),a.push({type:2,index:++r});i.append(t[e],j())}}}else if(8===i.nodeType)if(i.data===V)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf(D,t+1));)a.push({type:7,index:r}),t+=D.length-1}r++}}static createElement(t,e){const n=z.createElement("template");return n.innerHTML=t,n}}function at(t,e,n=t,i){var r,o,s,a;if(e===tt)return e;let l=void 0!==i?null===(r=n._$Co)||void 0===r?void 0:r[i]:n._$Cl;const c=U(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===c?l=void 0:(l=new c(t),l._$AT(t,n,i)),void 0!==i?(null!==(s=(a=n)._$Co)&&void 0!==s?s:a._$Co=[])[i]=l:n._$Cl=l),void 0!==l&&(e=at(t,l._$AS(t,e.values),l,i)),e}class lt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:n},parts:i}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:z).importNode(n,!0);it.currentNode=r;let o=it.nextNode(),s=0,a=0,l=i[0];for(;void 0!==l;){if(s===l.index){let e;2===l.type?e=new ct(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new gt(o,this,t)),this._$AV.push(e),l=i[++a]}s!==(null==l?void 0:l.index)&&(o=it.nextNode(),s++)}return it.currentNode=z,r}v(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class ct{constructor(t,e,n,i){var r;this.type=2,this._$AH=et,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cp=null===(r=null==i?void 0:i.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=at(this,t,e),U(t)?t===et||null==t||""===t?(this._$AH!==et&&this._$AR(),this._$AH=et):t!==this._$AH&&t!==tt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>G(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==et&&U(this._$AH)?this._$AA.nextSibling.data=t:this.$(z.createTextNode(t)),this._$AH=t}g(t){var e;const{values:n,_$litType$:i}=t,r="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=st.createElement(rt(i.h,i.h[0]),this.options)),i);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(n);else{const t=new lt(r,this),e=t.u(this.options);t.v(n),this.$(e),this._$AH=t}}_$AC(t){let e=nt.get(t.strings);return void 0===e&&nt.set(t.strings,e=new st(t)),e}T(t){G(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new ct(this.k(j()),this.k(j()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class ht{constructor(t,e,n,i,r){this.type=1,this._$AH=et,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=et}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,i){const r=this.strings;let o=!1;if(void 0===r)t=at(this,t,e,0),o=!U(t)||t!==this._$AH&&t!==tt,o&&(this._$AH=t);else{const i=t;let s,a;for(t=r[0],s=0;s<r.length-1;s++)a=at(this,i[n+s],e,s),a===tt&&(a=this._$AH[s]),o||(o=!U(a)||a!==this._$AH[s]),a===et?t=et:t!==et&&(t+=(null!=a?a:"")+r[s+1]),this._$AH[s]=a}o&&!i&&this.j(t)}j(t){t===et?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class ut extends ht{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===et?void 0:t}}const dt=F?F.emptyScript:"";class ft extends ht{constructor(){super(...arguments),this.type=4}j(t){t&&t!==et?this.element.setAttribute(this.name,dt):this.element.removeAttribute(this.name)}}class pt extends ht{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){var n;if((t=null!==(n=at(this,t,e,0))&&void 0!==n?n:et)===tt)return;const i=this._$AH,r=t===et&&i!==et||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==et&&(i===et||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==n?n:this.element,t):this._$AH.handleEvent(t)}}class gt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){at(this,t)}}const mt=R.litHtmlPolyfillSupport;var vt;null==mt||mt(st,ct),(null!==(N=R.litHtmlVersions)&&void 0!==N?N:R.litHtmlVersions=[]).push("2.8.0");const yt=window,bt=yt.trustedTypes,wt=bt?bt.createPolicy("lit-html",{createHTML:t=>t}):void 0,xt="$lit$",At=`lit$${(Math.random()+"").slice(9)}$`,Et="?"+At,Tt=`<${Et}>`,St=document,_t=()=>St.createComment(""),Pt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,kt=Array.isArray,Ct="[ \t\n\f\r]",Lt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Mt=/-->/g,Ot=/>/g,Nt=RegExp(`>|${Ct}(?:([^\\s"'>=/]+)(${Ct}*=${Ct}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Rt=/'/g,Ft=/"/g,It=/^(?:script|style|textarea|title)$/i,Bt=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),Dt=Bt(1),Vt=(Bt(2),Symbol.for("lit-noChange")),$t=Symbol.for("lit-nothing"),zt=new WeakMap,jt=St.createTreeWalker(St,129,null,!1);function Ut(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==wt?wt.createHTML(e):e}class Gt{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,o=0;const s=t.length-1,a=this.parts,[l,c]=((t,e)=>{const n=t.length-1,i=[];let r,o=2===e?"<svg>":"",s=Lt;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(s.lastIndex=h,l=s.exec(n),null!==l);)h=s.lastIndex,s===Lt?"!--"===l[1]?s=Mt:void 0!==l[1]?s=Ot:void 0!==l[2]?(It.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=Nt):void 0!==l[3]&&(s=Nt):s===Nt?">"===l[0]?(s=null!=r?r:Lt,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?Nt:'"'===l[3]?Ft:Rt):s===Ft||s===Rt?s=Nt:s===Mt||s===Ot?s=Lt:(s=Nt,r=void 0);const u=s===Nt&&t[e+1].startsWith("/>")?" ":"";o+=s===Lt?n+Tt:c>=0?(i.push(a),n.slice(0,c)+xt+n.slice(c)+At+u):n+At+(-2===c?(i.push(void 0),e):u)}return[Ut(t,o+(t[n]||"<?>")+(2===e?"</svg>":"")),i]})(t,e);if(this.el=Gt.createElement(l,n),jt.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(i=jt.nextNode())&&a.length<s;){if(1===i.nodeType){if(i.hasAttributes()){const t=[];for(const e of i.getAttributeNames())if(e.endsWith(xt)||e.startsWith(At)){const n=c[o++];if(t.push(e),void 0!==n){const t=i.getAttribute(n.toLowerCase()+xt).split(At),e=/([.?@])?(.*)/.exec(n);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Xt:"?"===e[1]?Kt:"@"===e[1]?Jt:Yt})}else a.push({type:6,index:r})}for(const e of t)i.removeAttribute(e)}if(It.test(i.tagName)){const t=i.textContent.split(At),e=t.length-1;if(e>0){i.textContent=bt?bt.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],_t()),jt.nextNode(),a.push({type:2,index:++r});i.append(t[e],_t())}}}else if(8===i.nodeType)if(i.data===Et)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf(At,t+1));)a.push({type:7,index:r}),t+=At.length-1}r++}}static createElement(t,e){const n=St.createElement("template");return n.innerHTML=t,n}}function Ht(t,e,n=t,i){var r,o,s,a;if(e===Vt)return e;let l=void 0!==i?null===(r=n._$Co)||void 0===r?void 0:r[i]:n._$Cl;const c=Pt(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===c?l=void 0:(l=new c(t),l._$AT(t,n,i)),void 0!==i?(null!==(s=(a=n)._$Co)&&void 0!==s?s:a._$Co=[])[i]=l:n._$Cl=l),void 0!==l&&(e=Ht(t,l._$AS(t,e.values),l,i)),e}class qt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:n},parts:i}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:St).importNode(n,!0);jt.currentNode=r;let o=jt.nextNode(),s=0,a=0,l=i[0];for(;void 0!==l;){if(s===l.index){let e;2===l.type?e=new Wt(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new Qt(o,this,t)),this._$AV.push(e),l=i[++a]}s!==(null==l?void 0:l.index)&&(o=jt.nextNode(),s++)}return jt.currentNode=St,r}v(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class Wt{constructor(t,e,n,i){var r;this.type=2,this._$AH=$t,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cp=null===(r=null==i?void 0:i.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ht(this,t,e),Pt(t)?t===$t||null==t||""===t?(this._$AH!==$t&&this._$AR(),this._$AH=$t):t!==this._$AH&&t!==Vt&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>kt(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==$t&&Pt(this._$AH)?this._$AA.nextSibling.data=t:this.$(St.createTextNode(t)),this._$AH=t}g(t){var e;const{values:n,_$litType$:i}=t,r="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=Gt.createElement(Ut(i.h,i.h[0]),this.options)),i);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(n);else{const t=new qt(r,this),e=t.u(this.options);t.v(n),this.$(e),this._$AH=t}}_$AC(t){let e=zt.get(t.strings);return void 0===e&&zt.set(t.strings,e=new Gt(t)),e}T(t){kt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new Wt(this.k(_t()),this.k(_t()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class Yt{constructor(t,e,n,i,r){this.type=1,this._$AH=$t,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=$t}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,i){const r=this.strings;let o=!1;if(void 0===r)t=Ht(this,t,e,0),o=!Pt(t)||t!==this._$AH&&t!==Vt,o&&(this._$AH=t);else{const i=t;let s,a;for(t=r[0],s=0;s<r.length-1;s++)a=Ht(this,i[n+s],e,s),a===Vt&&(a=this._$AH[s]),o||(o=!Pt(a)||a!==this._$AH[s]),a===$t?t=$t:t!==$t&&(t+=(null!=a?a:"")+r[s+1]),this._$AH[s]=a}o&&!i&&this.j(t)}j(t){t===$t?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Xt extends Yt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$t?void 0:t}}const Zt=bt?bt.emptyScript:"";class Kt extends Yt{constructor(){super(...arguments),this.type=4}j(t){t&&t!==$t?this.element.setAttribute(this.name,Zt):this.element.removeAttribute(this.name)}}class Jt extends Yt{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){var n;if((t=null!==(n=Ht(this,t,e,0))&&void 0!==n?n:$t)===Vt)return;const i=this._$AH,r=t===$t&&i!==$t||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==$t&&(i===$t||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==n?n:this.element,t):this._$AH.handleEvent(t)}}class Qt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Ht(this,t)}}const te=yt.litHtmlPolyfillSupport;var ee,ne;null==te||te(Gt,Wt),(null!==(vt=yt.litHtmlVersions)&&void 0!==vt?vt:yt.litHtmlVersions=[]).push("2.8.0");class ie extends O{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const n=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=n.firstChild),n}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,n)=>{var i,r;const o=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:e;let s=o._$litPart$;if(void 0===s){const t=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:null;o._$litPart$=s=new Wt(e.insertBefore(_t(),t),t,void 0,null!=n?n:{})}return s._$AI(t),s})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return Vt}}ie.finalized=!0,ie._$litElement$=!0,null===(ee=globalThis.litElementHydrateSupport)||void 0===ee||ee.call(globalThis,{LitElement:ie});const re=globalThis.litElementPolyfillSupport;null==re||re({LitElement:ie}),(null!==(ne=globalThis.litElementVersions)&&void 0!==ne?ne:globalThis.litElementVersions=[]).push("3.3.3");const oe=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(n){n.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(n){n.createProperty(e.key,t)}};function se(t){return(e,n)=>void 0!==n?((t,e,n)=>{e.constructor.createProperty(n,t)})(t,e,n):oe(t,e)}var ae;null===(ae=window.HTMLSlotElement)||void 0===ae||ae.prototype.assignedElements;const{round:le,floor:ce,PI:he}=Math,ue={linear:function(t,e,n){var i=t[1]-t[0],r=e[1]-e[0];return(n-t[0])/i*r+e[0]||0}},de=function(t){return t%360+(t<0?360:0)},fe=function(t,e){return e*le(t/e)},pe=function(t){return 180*t/he%360},ge=function(t,e){return(t=(e=e||!1)?t:t%360)*he/180},me=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){const n=t;t=e,e=n}return ce(Math.random()*(e-t+1)+t)},{cos:ve,sin:ye,atan2:be}=Math,we=function(t,e){var n=ge(t.y),i=ge(e.y),r=t.x,o=e.x,s=ge(o-r),a=ye(s)*ve(i),l=ve(n)*ye(i)-ye(n)*ve(i)*ve(s),c=pe(be(a,l))-22.5;return c<0&&(c+=360),["NE","E","SE","S","SW","W","NW","N"][c=parseInt(c/45)]},xe=function(t,e){var n=t.x,i=t.y;return(n-=e.x)*n+(i-=e.y)*i},Ae=function(t,e){return Math.sqrt(xe(t,e))},Ee={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:Te,cos:Se,sin:_e,sqrt:Pe,min:ke,max:Ce,atan2:Le,round:Me,pow:Oe,PI:Ne}=Math,Re=function(t,e){if(!(this instanceof Re))return new Re(t,e);if("string"==typeof t){var n=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(n[0]),e=parseFloat(n[1])}else Object(t)===t&&(e=t.y,t=t.x);this.x=void 0===t?0:t,this.y=void 0===e?0:e};Re.fromPolar=function(t,e,n){n=new Re(n);var i=Te(t*Se(e)),r=Te(t*_e(e)),o=de(pe(e));return o<90?r=-r:o<180?(i=-i,r=-r):o<270&&(i=-i),new Re(n.x+i,n.y+r)},Re.random=function(t,e,n,i){return new Re(me(t,e),me(n,i))},Re.prototype={type:Ee.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new Re(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new Re(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=ke(Ce(this.x,t.x),t.x+t.width),this.y=ke(Ce(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var n=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return we(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new Re(this)},cross:function(t,e){return t&&e?(e.x-this.x)*(t.y-this.y)-(e.y-this.y)*(t.x-this.x):NaN},difference:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),new Re(this.x-(t||0),this.y-(e||0))},distance:function(t){return Ae(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,e){var n=this.x,i=this.y;return new Re((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return Pe(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return Te(t.x-this.x)+Te(t.y-this.y)},move:function(t,e){var n=ge(new Re(t).theta(this));return this.offset(Se(n)*e,-_e(n)*e)},normalize:function(t){var e=(t||1)/this.magnitude();return this.scale(e,e)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new Re(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new Re(0,0),e=ge(de(-e));var n=Se(e),i=_e(e),r=n*(this.x-t.x)-i*(this.y-t.y)+t.x,o=i*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=r,this.y=o,this},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Oe(10,t)}return this.x=Me(this.x*e)/e,this.y=Me(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new Re(n)||new Re(0,0),this.x=n.x+t*(this.x-n.x),this.y=n.y+e*(this.y-n.y),this},snapToGrid:function(t,e){return this.x=fe(this.x,t),this.y=fe(this.y,e||t),this},squaredDistance:function(t){return xe(this,t)},theta:function(t){var e=-((t=new Re(t)).y-this.y),n=t.x-this.x,i=Le(e,n);return i<0&&(i=2*Ne+i),180*i/Ne},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new Re(t)||new Re(0,0);var e=this.x,n=this.y;return this.x=Pe((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=ge(t.theta(new Re(e,n))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0,this},vectorAngle:function(t){return new Re(0,0).angleBetween(this,t)}},Re.prototype.translate=Re.prototype.offset;const Fe=Re,{max:Ie,min:Be}=Math,De=function(t,e){return this instanceof De?t instanceof De?new De(t.start,t.end):(this.start=new Re(t),void(this.end=new Re(e))):new De(t,e)};De.prototype={type:Ee.Line,angle:function(){var t=new Re(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=Be(this.start.x,this.end.x),e=Be(this.start.y,this.end.y),n=Ie(this.start.x,this.end.x),i=Ie(this.start.y,this.end.y);return new Je(t,e,n-t,i-e)},bearing:function(){return we(this.start,this.end)},clone:function(){return new De(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){var e=this.vector().dot(new De(this.start,t).vector()),n=Be(1,Ie(0,e/this.squaredLength()));return n!=n?0:n},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,n=this.end;if(0!==e.cross(t,n))return!1;var i=this.length();return!(new De(e,t).length()>i||new De(t,n).length()>i)},divideAt:function(t){var e=this.pointAt(t);return[new De(this.start,e),new De(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new De(this.start,e),new De(e,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){if(t&&t.intersectionWithLine){var n=t.intersectionWithLine(this,e);return n&&t instanceof De&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new Re(this.end.x-this.start.x,this.end.y-this.start.y),n=new Re(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,r=new Re(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,s=r.x*e.y-r.y*e.x;if(0===i||o*i<0||s*i<0)return null;if(i>0){if(o>i||s>i)return null}else if(o<i||s<i)return null;return[new Re(this.start.x+o*e.x/i,this.start.y+o*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Ae(this.start,this.end)},midpoint:function(){return new Re((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){const e=this.clone();if(!this.isDifferentiable())return e;const{start:n,end:i}=e,r=n.clone().rotate(i,270),o=i.clone().rotate(n,90);return n.move(o,t),i.move(r,t),e},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():t>=1?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0;t<0&&(i=!1,t=-t);var r=this.length();return t>=r?i?n.clone():e.clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new Re(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();if(!e)return this;var n=t/e;return this.scale(n,n,this.start)},squaredLength:function(){return xe(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAt(t),r=new De(e,n);return r.translate(i.x-e.x,i.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAtLength(t),r=new De(e,n);return r.translate(i.x-e.x,i.y-e.y),r},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new Re(this.end.x-this.start.x,this.end.y-this.start.y)}},De.prototype.intersection=De.prototype.intersect;const Ve=De,{sqrt:$e,round:ze,pow:je}=Math,Ue=function(t,e,n){return this instanceof Ue?t instanceof Ue?new Ue(new Re(t.x,t.y),t.a,t.b):(t=new Re(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new Ue(t,e,n)};Ue.fromRect=function(t){return t=new Je(t),new Ue(t.center(),t.width/2,t.height/2)},Ue.prototype={type:Ee.Ellipse,bbox:function(){return new Je(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new Re(this.x,this.y)},clone:function(){return new Ue(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.a+=2*t,this.b+=2*e,this},intersectionWithLine:function(t){var e=[],n=t.start,i=t.end,r=this.a,o=this.b,s=t.vector(),a=n.difference(new Re(this)),l=new Re(s.x/(r*r),s.y/(o*o)),c=new Re(a.x/(r*r),a.y/(o*o)),h=s.dot(l),u=s.dot(c),d=u*u-h*(a.dot(c)-1);if(d<0)return null;if(d>0){var f=$e(d),p=(-u-f)/h,g=(-u+f)/h;if((p<0||1<p)&&(g<0||1<g))return null;0<=p&&p<=1&&e.push(n.lerp(i,p)),0<=g&&g<=1&&e.push(n.lerp(i,g))}else{var m=-u/h;if(!(0<=m&&m<=1))return null;e.push(n.lerp(i,m))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new Re(t),e&&t.rotate(new Re(this.x,this.y),e);var n,i=t.x-this.x,r=t.y-this.y;if(0===i)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new Re(this.x,this.y),-e):n;var o=r/i,s=o*o,a=this.a*this.a,l=this.b*this.b,c=$e(1/(1/a+s/l)),h=o*(c=i<0?-c:c);return n=new Re(this.x+c,this.y+h),e?n.rotate(new Re(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,i=this.a,r=this.b,o=this.x,s=this.y;return(e-o)*(e-o)/(i*i)+(n-s)*(n-s)/(r*r)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=je(10,t)}return this.x=ze(this.x*e)/e,this.y=ze(this.y*e)/e,this.a=ze(this.a*e)/e,this.b=ze(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,s=this.b,a=this.bbox().center(),l=a.x,c=a.y,h=i>a.x+o/2,u=i<a.x-o/2;return h||u?n=o*o/(i-l)-o*o*(r-c)*((e=i>a.x?r-30:r+30)-c)/(s*s*(i-l))+l:e=s*s/(r-c)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-c))+c,new Re(n,e).theta(t)},toString:function(){return new Re(this.x,this.y).toString()+" "+this.a+" "+this.b}};const Ge=Ue,{abs:He,cos:qe,sin:We,min:Ye,max:Xe,round:Ze,pow:Ke}=Math,Je=function(t,e,n,i){if(!(this instanceof Je))return new Je(t,e,n,i);Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===n?0:n,this.height=void 0===i?0:i};Je.fromEllipse=function(t){return t=new Ue(t),new Je(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},Je.fromPointUnion=function(...t){if(0===t.length)return null;const e=new Re;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y;a<n&&(n=a),a>r&&(r=a),l<i&&(i=l),l>o&&(o=l)}return new Je(n,i,r-n,o-i)},Je.fromRectUnion=function(...t){if(0===t.length)return null;const e=new Je;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y,c=a+e.width,h=l+e.height;a<n&&(n=a),c>r&&(r=c),l<i&&(i=l),h>o&&(o=h)}return new Je(n,i,r-n,o-i)},Je.prototype={type:Ee.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;const{width:e,height:n}=this,i=ge(t),r=He(We(i)),o=He(qe(i)),s=e*o+n*r,a=e*r+n*o;return this.x+=(e-s)/2,this.y+=(n-a)/2,this.width=s,this.height=a,this},bottomLeft:function(){return new Re(this.x,this.y+this.height)},bottomLine:function(){return new De(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new Re(this.x+this.width/2,this.y+this.height)},center:function(){return new Re(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new Je(this)},containsPoint:function(t){return t instanceof Re||(t=new Re(t)),t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new Je(this).normalize(),n=new Je(t).normalize(),i=e.width,r=e.height,o=n.width,s=n.height;if(!(i&&r&&o&&s))return!1;var a=e.x,l=e.y,c=n.x,h=n.y;return o+=c,i+=a,s+=h,r+=l,a<=c&&o<=i&&l<=h&&s<=r},corner:function(){return new Re(this.x+this.width,this.y+this.height)},equals:function(t){var e=new Je(this).normalize(),n=new Je(t).normalize();return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),n=this.corner(),i=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||i.x>=n.x||i.y>=n.y)return null;var o=Xe(e.x,i.x),s=Xe(e.y,i.y);return new Je(o,s,Ye(n.x,r.x)-o,Ye(n.y,r.y)-s)},intersectionWithLine:function(t){var e,n,i=this,r=[i.topLine(),i.rightLine(),i.bottomLine(),i.leftLine()],o=[],s=[],a=r.length;for(n=0;n<a;n++)null!==(e=t.intersect(r[n]))&&s.indexOf(e.toString())<0&&(o.push(e),s.push(e.toString()));return o.length>0?o:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new Re(t);var n,i=new Re(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(i,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new De(i,t),s=r.length-1;s>=0;--s){var a=r[s].intersection(o);if(null!==a){n=a;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new De(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new Re(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,i,r,o,s,a,l,c;t=new Je(t),e||(e=t.center());var h=e.x,u=e.y;n=i=r=o=s=a=l=c=1/0;var d=t.topLeft();d.x<h&&(n=(this.x-h)/(d.x-h)),d.y<u&&(s=(this.y-u)/(d.y-u));var f=t.bottomRight();f.x>h&&(i=(this.x+this.width-h)/(f.x-h)),f.y>u&&(a=(this.y+this.height-u)/(f.y-u));var p=t.topRight();p.x>h&&(r=(this.x+this.width-h)/(p.x-h)),p.y<u&&(l=(this.y-u)/(p.y-u));var g=t.bottomLeft();return g.x<h&&(o=(this.x-h)/(g.x-h)),g.y>u&&(c=(this.y+this.height-u)/(g.y-u)),{sx:Ye(n,i,r,o),sy:Ye(s,a,l,c)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return Ye(n.sx,n.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return Re.prototype.offset.call(this,t,e)},origin:function(){return new Re(this.x,this.y)},pointNearestToPoint:function(t){if(t=new Re(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new Re(this.x+this.width,t.y);case"left":return new Re(this.x,t.y);case"bottom":return new Re(t.x,this.y+this.height);case"top":return new Re(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new De(this.topRight(),this.bottomRight())},rightMiddle:function(){return new Re(this.x+this.width,this.y+this.height/2)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Ke(10,t)}return this.x=Ze(this.x*e)/e,this.y=Ze(this.y*e)/e,this.width=Ze(this.width*e)/e,this.height=Ze(this.height*e)/e,this},scale:function(t,e,n){return n=this.origin().scale(t,e,n),this.x=n.x,this.y=n.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new Re(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r=e,o="left";return n<r&&(r=n,o="right"),i<r&&(r=i,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),i=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=i.x-n.x,this.height=i.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new De(this.topLeft(),this.topRight())},topMiddle:function(){return new Re(this.x+this.width/2,this.y)},topRight:function(){return new Re(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return Je.fromRectUnion(this,t)},update:function(t,e,n,i){return Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this}},Je.prototype.bottomRight=Je.prototype.corner,Je.prototype.topLeft=Je.prototype.origin,Je.prototype.translate=Je.prototype.offset;const Qe=Je;function tn(t){const e=t.trim();if(""===e)return[];const n=[],i=e.split(/\b\s*,\s*|,\s*|\s+/),r=i.length;for(let t=0;t<r;t+=2)n.push({x:+i[t],y:+i[t+1]});return n}function en(t){const e=t.length;if(0===e)return[];const n=[];for(let i=0;i<e;i++){const e=t[i].clone();n.push(e)}return n}function nn(t){const{abs:e}=Math;var n,i,r,o=t.length;if(0===o)return[];for(n=0;n<o;n++)(void 0===r||t[n].y<r.y||t[n].y===r.y&&t[n].x>r.x)&&(r=t[n]);var s=[];for(n=0;n<o;n++){var a=r.theta(t[n]);0===a&&(a=360);var l=[t[n],n,a];s.push(l)}if(s.sort((function(t,e){var n=t[2]-e[2];return 0===n&&(n=e[1]-t[1]),n})),s.length>2){var c=s[s.length-1];s.unshift(c)}for(var h,u,d,f,p,g,m,v={},y=[];0!==s.length;)if(u=(h=s.pop())[0],!v.hasOwnProperty(h[0]+"@@"+h[1]))for(var b=!1;!b;)if(y.length<2)y.push(h),b=!0;else{f=(d=y.pop())[0];var w=(g=(p=y.pop())[0]).cross(f,u);if(w<0)y.push(p),y.push(d),y.push(h),b=!0;else if(0===w){var x=f.angleBetween(g,u);e(x-180)<1e-10||f.equals(u)||g.equals(f)?(v[d[0]+"@@"+d[1]]=f,y.push(p)):e((x+1)%360-1)<1e-10&&(y.push(p),s.push(d))}else v[d[0]+"@@"+d[1]]=f,y.push(p)}y.length>2&&y.pop();var A=-1;for(i=y.length,n=0;n<i;n++){var E=y[n][1];(void 0===m||E<m)&&(m=E,A=n)}var T=[];if(A>0){var S=y.slice(A),_=y.slice(0,A);T=S.concat(_)}else T=y;var P=[];for(i=T.length,n=0;n<i;n++)P.push(T[n][0]);return P}const rn=function(t){return this instanceof rn?"string"==typeof t?new rn.parse(t):void(this.points=Array.isArray(t)?t.map(Re):[]):new rn(t)};rn.parse=function(t){return new rn(tn(t))},rn.fromRect=function(t){return new rn([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},rn.prototype={type:Ee.Polyline,bbox:function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var s=0;s<o;s++){var a=r[s],l=a.x,c=a.y;l<t&&(t=l),l>e&&(e=l),c<n&&(n=c),c>i&&(i=c)}return new Je(t,n,e-t,i-n)},clone:function(){return new rn(en(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,s=i-1,a=0;a<s;a++){var l=new De(n[a],n[a+1]),c=l.length(),h=l.closestPointNormalizedLength(t),u=l.pointAt(h).squaredDistance(t);u<r&&(r=u,e=o+h*c),o+=c}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var n=this.length();return 0===n?0:e/n},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,s=0,a=0,l=new De,c=new De,h=new Re;s<n;s++){var u=e[o],d=e[s];if(t.equals(u))return!0;if(l.start=u,l.end=d,l.containsPoint(t))return!0;if(r<=u.y&&r>d.y||r>u.y&&r<=d.y){var f=u.x-i>d.x-i?u.x-i:d.x-i;f>=0&&(h.x=i+f,h.y=r,c.start=t,c.end=h,l.intersect(c)&&a++)}o=s}return a%2==1},close:function(){const{start:t,end:e,points:n}=this;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new rn(nn(this.points))},equals:function(t){if(!t)return!1;var e=this.points,n=t.points,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=t.points[r];if(!o.equals(s))return!1}return!0},intersectionWithLine:function(t){for(var e=new De(t),n=[],i=this.lengthPoints(),r=new De,o=0,s=i.length-1;o<s;o++){r.start=i[o],r.end=i[o+1];var a=e.intersectionWithLine(r);a&&n.push(a[0])}return n.length>0?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var n=new De,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();if(t<=0)return e[0].clone();if(t>=1)return e[n-1].clone();var i=this.length()*t;return this.pointAtLength(i)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var i=!0;t<0&&(i=!1,t=-t);for(var r=0,o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],c=e[a+1],h=new De(l,c),u=l.distance(c);if(t<=r+u)return h.pointAtLength((i?1:-1)*(t-r));r+=u}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(t={}){const e=this.points;if(e.length<3)return this;const n=t.threshold||1e-10;let i=0;for(;e[i+2];){const t=i+1,r=i+2,o=e[i],s=e[t],a=e[r];new De(o,a).closestPoint(s).distance(s)<=n?e.splice(t,1):i+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),t>1&&(t=1);var n=this.length()*t;return this.tangentAtLength(n)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;var i,r=!0;t<0&&(r=!1,t=-t);for(var o=0,s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,c=e[l],h=e[l+1],u=new De(c,h),d=c.distance(h);if(u.isDifferentiable()){if(t<=o+d)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=d}if(i){var f=r?1:0;return i.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(rn.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(rn.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});const{abs:on,sqrt:sn,min:an,max:ln,pow:cn}=Math,hn=function(t,e,n,i){return this instanceof hn?t instanceof hn?new hn(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new Re(t),this.controlPoint1=new Re(e),this.controlPoint2=new Re(n),void(this.end=new Re(i))):new hn(t,e,n,i)};function un(t){var e,n,i=[];for(n=arguments.length,e=1;e<n;e++)i.push(arguments[e]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=i.length,e=0;e<n;e++){var o,s,a=i[e];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}hn.throughPoints=function(){function t(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}return function(e){if(!e||Array.isArray(e)&&e.length<2)throw new Error("At least 2 points are required");for(var n=function(e){var n,i=[],r=[],o=e.length-1;if(1==o)return i[0]=new Re((2*e[0].x+e[1].x)/3,(2*e[0].y+e[1].y)/3),r[0]=new Re(2*i[0].x-e[0].x,2*i[0].y-e[0].y),[i,r];var s=[];for(n=1;n<o-1;n++)s[n]=4*e[n].x+2*e[n+1].x;s[0]=e[0].x+2*e[1].x,s[o-1]=(8*e[o-1].x+e[o].x)/2;var a=t(s);for(n=1;n<o-1;++n)s[n]=4*e[n].y+2*e[n+1].y;s[0]=e[0].y+2*e[1].y,s[o-1]=(8*e[o-1].y+e[o].y)/2;var l=t(s);for(n=0;n<o;n++)i.push(new Re(a[n],l[n])),n<o-1?r.push(new Re(2*e[n+1].x-a[n+1],2*e[n+1].y-l[n+1])):r.push(new Re((e[o].x+a[o-1])/2,(e[o].y+l[o-1])/2));return[i,r]}(e),i=[],r=n[0].length,o=0;o<r;o++){var s=new Re(n[0][o].x,n[0][o].y),a=new Re(n[1][o].x,n[1][o].y);i.push(new hn(e[o],s,a,e[o+1]))}return i}}(),hn.prototype={type:Ee.Curve,bbox:function(){for(var t,e,n,i,r,o,s,a,l=this.start,c=this.controlPoint1,h=this.controlPoint2,u=this.end,d=l.x,f=l.y,p=c.x,g=c.y,m=h.x,v=h.y,y=u.x,b=u.y,w=new Array,x=new Array,A=[new Array,new Array],E=0;E<2;++E)if(0===E?(e=6*d-12*p+6*m,t=-3*d+9*p-9*m+3*y,n=3*p-3*d):(e=6*f-12*g+6*v,t=-3*f+9*g-9*v+3*b,n=3*g-3*f),on(t)<1e-12){if(on(e)<1e-12)continue;0<(i=-n/e)&&i<1&&x.push(i)}else a=sn(s=e*e-4*n*t),s<0||(0<(r=(-e+a)/(2*t))&&r<1&&x.push(r),0<(o=(-e-a)/(2*t))&&o<1&&x.push(o));for(var T,S,_,P=x.length,k=P;P--;)S=(T=1-(i=x[P]))*T*T*d+3*T*T*i*p+3*T*i*i*m+i*i*i*y,A[0][P]=S,_=T*T*T*f+3*T*T*i*g+3*T*i*i*v+i*i*i*b,A[1][P]=_,w[P]={X:S,Y:_};x[k]=0,x[k+1]=1,w[k]={X:d,Y:f},w[k+1]={X:y,Y:b},A[0][k]=d,A[1][k]=f,A[0][k+1]=y,A[1][k+1]=b,x.length=k+2,A[0].length=k+2,A[1].length=k+2,w.length=k+2;var C=an.apply(null,A[0]),L=an.apply(null,A[1]),M=ln.apply(null,A[0]),O=ln.apply(null,A[1]);return new Je(C,L,M-C,O-L)},clone:function(){return new hn(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.closestPointLength(t,i);if(!r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){for(var n,i,r,o,s,a,l,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:c}):e.subdivisions,u=h.length,d=u?1/u:0,f=0;f<u;f++){var p=h[f],g=p.start.distance(t),m=p.end.distance(t),v=g+m;(!l||v<l)&&(n=p,i=f*d,r=(f+1)*d,o=g,s=m,a=p.start.distance(p.end),l=v)}for(var y=cn(10,-c);;){var b=o?on(o-s)/o:0,w=s?on(o-s)/s:0;if(b<y||w<y||!o||o<a*y||!s||s<a*y)return o<=s?i:r;var x=n.divide(.5);d/=2;var A=x[0].start.distance(t),E=x[0].end.distance(t),T=A+E,S=x[1].start.distance(t),_=x[1].end.distance(t);T<=S+_?(n=x[0],r-=d,o=A,s=E):(n=x[1],i+=d,o=S,s=_)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(t>=1)return this.divideAtT(1);var n=this.tAt(t,e);return this.divideAtT(n)},divideAtLength:function(t,e){var n=this.tAtLength(t,e);return this.divideAtT(n)},divideAtT:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return[new hn(e,e,e,e),new hn(e,n,i,r)];if(t>=1)return[new hn(e,n,i,r),new hn(r,r,r,r)];var o=this.getSkeletonPoints(t),s=o.startControlPoint1,a=o.startControlPoint2,l=o.divider,c=o.dividerControlPoint1,h=o.dividerControlPoint2;return[new hn(e,s,a,l),new hn(l,c,h,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()};if(t>=1)return{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new De(e,n).pointAt(t),s=new De(n,i).pointAt(t),a=new De(i,r).pointAt(t),l=new De(o,s).pointAt(t),c=new De(s,a).pointAt(t);return{startControlPoint1:o,startControlPoint2:l,divider:new De(l,c).pointAt(t),dividerControlPoint1:c,dividerControlPoint2:a}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,i=this.controlPoint1,r=this.controlPoint2,o=this.end,s=[new hn(n,i,r,o)];if(0===e)return s;if(!this.isDifferentiable())return s;var a=this.endpointDistance(),l=cn(10,-e),c=2;0===i.cross(n,o)&&0===r.cross(n,o)&&(c=2*e);for(var h=0;;){h+=1;for(var u=[],d=s.length,f=0;f<d;f++){var p=s[f].divide(.5);u.push(p[0],p[1])}for(var g=0,m=u.length,v=0;v<m;v++)g+=u[v].endpointDistance();if(h>=c&&(0!==g?(g-a)/g:0)<l)return u;s=u,a=g}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++)i+=n[o].endpointDistance();return i},lengthAtT:function(t,e){if(t<=0)return 0;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=this.tAt(t,e);return this.pointAtT(n)},pointAtLength:function(t,e){var n=this.tAtLength(t,e);return this.pointAtT(n)},pointAtT:function(t){return t<=0?this.start.clone():t>=1?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var n=this.tAt(t,e);return this.tangentAtT(n)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var n=this.tAtLength(t,e);return this.tangentAtT(n)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var e=this.getSkeletonPoints(t),n=e.startControlPoint2,i=e.dividerControlPoint1,r=e.divider,o=new De(n,i);return o.translate(r.x-n.x,r.y-n.y),o},tAt:function(t,e){if(t<=0)return 0;if(t>=1)return 1;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.length(i)*t;return this.tAtLength(r,i)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,c=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,h={precision:l,subdivisions:c},u=0,d=c.length,f=1/d,p=0;p<d;p++){var g=n?p:d-1-p,m=c[p],v=m.endpointDistance();if(t<=u+v){i=m,r=g*f,o=(g+1)*f,s=n?t-u:v+u-t,a=n?v+u-t:t-u;break}u+=v}if(!i)return n?1:0;for(var y=this.length(h),b=cn(10,-l);;){var w,x;if((0!==y?s/y:0)<b)return r;if((0!==y?a/y:0)<b)return o;var A=i.divide(.5);f/=2;var E=A[0].endpointDistance(),T=A[1].endpointDistance();s<=E?(i=A[0],o-=f,x=E-(w=s)):(i=A[1],r+=f,x=T-(w=s-E)),s=w,a=x}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var s=n[o];i.push(s.end.clone())}return i},toPolyline:function(t){return new rn(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}},hn.prototype.divide=hn.prototype.divideAtT;const dn=function(t){if(!(this instanceof dn))return new dn(t);if("string"==typeof t)return new dn.parse(t);var e,n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce((function(t,e){return t.concat(e)}),[])).length,t[0].isSegment)for(e=0;e<n;e++){var i=t[e];this.appendSegment(i)}else{var r=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof De||o instanceof hn))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(dn.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(dn.createSegment("M",o.start)),o instanceof De?this.appendSegment(dn.createSegment("L",o.end)):o instanceof hn&&this.appendSegment(dn.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof De)this.appendSegment(dn.createSegment("M",t.start)),this.appendSegment(dn.createSegment("L",t.end));else if(t instanceof hn)this.appendSegment(dn.createSegment("M",t.start)),this.appendSegment(dn.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof rn))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(n=t.points.length,e=0;e<n;e++){var s=t.points[e];0===e?this.appendSegment(dn.createSegment("M",s)):this.appendSegment(dn.createSegment("L",s))}}};function fn(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}dn.parse=function(t){if(!t)return new dn;for(var e=new dn,n=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=n.length,r=0;r<i;r++){var o=n[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),s=dn.createSegment.apply(this,o);e.appendSegment(s)}return e},dn.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=dn.segmentTypes[t];if(!e)throw new Error(t+" is not a recognized path segment type.");for(var n=[],i=arguments.length,r=1;r<i;r++)n.push(arguments[r]);return fn(e,n)},dn.prototype={type:Ee.Path,appendSegment:function(t){var e,n=this.segments,i=n.length,r=0!==i?n[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,s=0;s<o;s++){var a=t[s];e=this.prepareSegment(a,r,null),n.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),n.push(e)}},bbox:function(){var t,e=this.segments,n=e.length;if(0===n)return null;for(var i=0;i<n;i++){var r=e[i];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var s=e[n-1];return new Je(s.end.x,s.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,n=new dn,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){var n=this.closestPointT(t,e);return n?this.pointAtT(n):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointT(t,i);return r?this.lengthAtT(r,i):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointLength(t,i);if(0===r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],h=s[l];if(c.isVisible){var u=c.closestPointT(t,{precision:o,subdivisions:h}),d=c.pointAtT(u),f=new De(d,t).squaredLength();f<a&&(r={segmentIndex:l,value:u},a=f)}}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],h=s[l];if(c.isDifferentiable()){var u=c.closestPointT(t,{precision:o,subdivisions:h}),d=c.pointAtT(u),f=new De(d,t).squaredLength();f<a&&(r=c.tangentAtT(u),a=f)}}return r||null},containsPoint:function(t,e){var n=this.toPolylines(e);if(!n)return!1;for(var i=n.length,r=0,o=0;o<i;o++)n[o].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.divideAtLength(r,i)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;var i=!0;t<0&&(i=!1,t=-t);var r,o,s,a,l,c,h,u=void 0===(e=e||{}).precision?this.PRECISION:e.precision,d=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:u}):e.segmentSubdivisions,f=0;for(r=0;r<n;r++){var p=i?r:n-1-r;o=this.getSegment(p);var g=d[p],m=o.length({precision:u,subdivisions:g});if(o.isDifferentiable()&&(l=o,c=p,t<=f+m)){a=p,s=o.divideAtLength((i?1:-1)*(t-f),{precision:u,subdivisions:g});break}f+=m}if(!l)return null;s||(a=c,h=i?1:0,s=l.divideAtT(h));var v=this.clone();v.replaceSegment(a,s);var y=a,b=a+1,w=a+2;s[0].isDifferentiable()||(v.removeSegment(y),b-=1,w-=1);var x=v.getSegment(b).start;v.insertSegment(b,dn.createSegment("M",x)),w+=1,s[1].isDifferentiable()||(v.removeSegment(w-1),w-=1);var A=w-y-1;for(r=w;r<v.segments.length;r++){var E=this.getSegment(r-A);if("Z"===(o=v.getSegment(r)).type&&!E.subpathStartSegment.end.equals(o.subpathStartSegment.end)){var T=dn.createSegment("L",E.end);v.replaceSegment(r,T)}}return[new dn(v.segments.slice(0,b)),new dn(v.segments.slice(b))]},equals:function(t){if(!t)return!1;var e=this.segments,n=t.segments,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=n[r];if(o.type!==s.type||!o.equals(s))return!1}return!0},getSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");return e[t]},getSegmentSubdivisions:function(t){for(var e=this.segments,n=e.length,i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],o=0;o<n;o++){var s=e[o].getSubdivisions({precision:i});r.push(s)}return r},getSubpaths:function(){const t=this.clone().validate().segments,e=t.length,n=[];for(let i=0;i<e;i++){const e=t[i];e.isSubpathStart?n.push(new dn(e)):n[n.length-1].appendSegment(e)}return n},insertSegment:function(t,e){var n,i=this.segments,r=i.length;if(t<0&&(t=r+t+1),t>r||t<0)throw new Error("Index out of range.");var o=null,s=null;if(0!==r&&(s=t>=1?(o=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var a=e.length,l=0;l<a;l++){var c=e[l];n=this.prepareSegment(c,o,s),i.splice(t+l,0,n),o=n}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,o,s),i.splice(t,0,n)}},intersectionWithLine:function(t,e){var n=null,i=this.toPolylines(e);if(!i)return null;for(var r=0,o=i.length;r<o;r++){var s=i[r],a=t.intersect(s);a&&(n||(n=[]),Array.isArray(a)?Array.prototype.push.apply(n,a):n.push(a))}return n},isDifferentiable:function(){for(var t=this.segments,e=t.length,n=0;n<e;n++)if(t[n].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var e=this.segments,n=e.length;if(0===n)return 0;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=0,s=0;s<n;s++){var a=e[s],l=r[s];o+=a.length({subdivisions:l})}return o},lengthAtT:function(t,e){var n=this.segments,i=n.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;var o=t.value;r>=i?(r=i-1,o=1):o<0?o=0:o>1&&(o=1);for(var s,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,l=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,c=0,h=0;h<r;h++){var u=n[h];s=l[h],c+=u.length({precisison:a,subdivisions:s})}return u=n[r],s=l[r],c+u.lengthAtT(o,{precisison:a,subdivisions:s})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.pointAtLength(r,i)},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=a[h],f=u.length({precision:s,subdivisions:d});if(u.isVisible){if(t<=l+f)return u.pointAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=u}l+=f}return o?r?o.end:o.start:n[i-1].end.clone()},pointAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].pointAtT(0);if(i>=n)return e[n-1].pointAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].pointAtT(r)},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);var i=t;return t.isSubpathStart&&(t.subpathStartSegment=t,i=n),i&&this.updateSubpathStartSegment(i),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");var i=e.splice(t,1)[0],r=i.previousSegment,o=i.nextSegment;r&&(r.nextSegment=o),o&&(o.previousSegment=r),i.isSubpathStart&&o&&this.updateSubpathStartSegment(o)},replaceSegment:function(t,e){var n,i=this.segments,r=i.length;if(0===r)throw new Error("Path has no segments.");if(t<0&&(t=r+t),t>=r||t<0)throw new Error("Index out of range.");var o=i[t],s=o.previousSegment,a=o.nextSegment,l=o.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var c=e.length,h=0;h<c;h++){var u=e[h];n=this.prepareSegment(u,s,a),i.splice(t+h,0,n),s=n,l&&n.isSubpathStart&&(l=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,s,a),i.splice(t,1,n),l&&n.isSubpathStart&&(l=!1)}l&&a&&this.updateSubpathStartSegment(a)},round:function(t){for(var e=this.segments,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.segments,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},segmentAt:function(t,e){var n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null},segmentAtLength:function(t,e){var n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.segmentIndexAtLength(r,i)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=s[h],f=u.length({precision:o,subdivisions:d});if(u.isVisible){if(t<=l+f)return h;a=h}l+=f}return a},serialize:function(){if(!this.isValid())throw new Error("Invalid path segments.");return this.toString()},tangentAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.tangentAtLength(r,i)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=a[h],f=u.length({precision:s,subdivisions:d});if(u.isDifferentiable()){if(t<=l+f)return u.tangentAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=u}l+=f}if(o){var p=r?1:0;return o.tangentAtT(p)}return null},tangentAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].tangentAtT(0);if(i>=n)return e[n-1].tangentAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].tangentAtT(r)},toPoints:function(t){var e=this.segments,n=e.length;if(0===n)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=[],s=[],a=0;a<n;a++){var l=e[a];if(l.isVisible){var c=r[a];if(c.length>0){var h=c.map((function(t){return t.start}));Array.prototype.push.apply(s,h)}else s.push(l.start)}else s.length>0&&(s.push(e[a-1].end),o.push(s),s=[])}return s.length>0&&(s.push(this.end),o.push(s)),o},toPolylines:function(t){var e=[],n=this.toPoints(t);if(!n)return null;for(var i=0,r=n.length;i<r;i++)e.push(new rn(n[i]));return e},toString:function(){for(var t=this.segments,e=t.length,n="",i=0;i<e;i++)n+=t[i].serialize()+" ";return n.trim()},translate:function(t,e){for(var n=this.segments,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},updateSubpathStartSegment:function(t){for(var e=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=e?e.subpathStartSegment:null,e=t,t=t.nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,dn.createSegment("M",0,0)),this}},Object.defineProperty(dn.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=0;n<e;n++){var i=t[n];if(i.isVisible)return i.start}return t[e-1].end}}),Object.defineProperty(dn.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=e-1;n>=0;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}});var pn={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return t>=1?e:e*t},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}};Object.defineProperty(pn,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(pn,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(pn,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}});var gn=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof gn))return fn(gn,n);if(0===i)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof De){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" lines provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Re(+n[0],+n[1]),this;if(i<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),t.push(fn(gn,o));return t}if(1===i)return this.end=new Re(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],t.push(new gn(e));return t},mn={clone:function(){return new gn(this.end)},divideAt:function(t){var e=new De(this.start,this.end).divideAt(t);return[new gn(e[0]),new gn(e[1])]},divideAtLength:function(t){var e=new De(this.start,this.end).divideAtLength(t);return[new gn(e[0]),new gn(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(mn,"type",{configurable:!0,enumerable:!0,value:"L"}),gn.prototype=un(pn,De.prototype,mn);var vn=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof vn))return fn(vn,n);if(0===i)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(n[0]instanceof hn){if(1===i)return this.controlPoint1=n[0].controlPoint1.clone(),this.controlPoint2=n[0].controlPoint2.clone(),this.end=n[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(6===i)return this.controlPoint1=new Re(+n[0],+n[1]),this.controlPoint2=new Re(+n[2],+n[3]),this.end=new Re(+n[4],+n[5]),this;if(i<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=6)o=n.slice(r,r+6),t.push(fn(vn,o));return t}if(3===i)return this.controlPoint1=new Re(n[0]),this.controlPoint2=new Re(n[1]),this.end=new Re(n[2]),this;if(i<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" points provided).");for(t=[],r=0;r<i;r+=3)e=n.slice(r,r+3),t.push(fn(vn,e));return t},yn={clone:function(){return new vn(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){var n=new hn(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new vn(n[0]),new vn(n[1])]},divideAtLength:function(t,e){var n=new hn(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new vn(n[0]),new vn(n[1])]},divideAtT:function(t){var e=new hn(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new vn(e[0]),new vn(e[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,n=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+n.x+" "+n.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}};Object.defineProperty(yn,"type",{configurable:!0,enumerable:!0,value:"C"}),vn.prototype=un(pn,hn.prototype,yn);var bn=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof bn))return fn(bn,n);if(0===i)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof De){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" lines provided).")}if(n[0]instanceof hn){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Re(+n[0],+n[1]),this;if(i<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),0===r?t.push(fn(bn,o)):t.push(fn(gn,o));return t}if(1===i)return this.end=new Re(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],0===r?t.push(new bn(e)):t.push(new gn(e));return t},wn={bbox:function(){return null},clone:function(){return new bn(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(wn,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(wn,"type",{configurable:!0,enumerable:!0,value:"M"}),bn.prototype=un(pn,wn);var xn=function(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof xn))return fn(xn,t);if(e>0)throw new Error("Closepath constructor expects no arguments.");return this},An={clone:function(){return new xn},divideAt:function(t){var e=new De(this.start,this.end).divideAt(t);return[e[1].isDifferentiable()?new gn(e[0]):this.clone(),new gn(e[1])]},divideAtLength:function(t){var e=new De(this.start,this.end).divideAtLength(t);return[e[1].isDifferentiable()?new gn(e[0]):this.clone(),new gn(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment||this.start.equals(this.end))},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}};Object.defineProperty(An,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),Object.defineProperty(An,"type",{configurable:!0,enumerable:!0,value:"Z"}),xn.prototype=un(pn,De.prototype,An);var En=dn.segmentTypes={L:gn,C:vn,M:bn,Z:xn,z:xn};dn.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(En).join("")+",.]*$"),dn.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)};const Tn={curveThroughPoints:function(t){return console.warn("deprecated"),new dn(hn.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new Re((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new Re(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var s=this.getFirstControlPoints(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var a=this.getFirstControlPoints(o);for(e=0;e<r;e++)n.push(new Re(s[e],a[e])),e<r-1?i.push(new Re(2*t[e+1].x-s[e+1],2*t[e+1].y-a[e+1])):i.push(new Re((t[r].x+s[r-1])/2,(t[r].y+a[r-1])/2));return[n,i]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new hn(t,e,n,i);return function(t){var e=r.divide(t);return[{p0:e[0].start,p1:e[0].controlPoint1,p2:e[0].controlPoint2,p3:e[0].end},{p0:e[1].start,p1:e[1].controlPoint1,p2:e[1].controlPoint2,p3:e[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n},getInversionSolver:function(t,e,n,i){console.warn("deprecated");var r=new hn(t,e,n,i);return function(t){return r.closestPointT(t)}}},Sn=function(t){return this instanceof Sn?"string"==typeof t?new Sn.parse(t):void(this.points=Array.isArray(t)?t.map(Re):[]):new Sn(t)};function _n(t,e,n,i){switch(t.type){case Ee.Line:if(e.type===Ee.Line)return Pn(t,e);break;case Ee.Ellipse:switch(e.type){case Ee.Line:return kn(t,e);case Ee.Ellipse:return Cn(t,e)}break;case Ee.Rect:switch(e.type){case Ee.Line:return Ln(t,e);case Ee.Ellipse:return Mn(t,e);case Ee.Rect:return On(t,e)}break;case Ee.Polyline:switch(e.type){case Ee.Line:return Nn(t,e);case Ee.Ellipse:return Rn(t,e);case Ee.Rect:return Fn(t,e);case Ee.Polyline:return In(t,e)}break;case Ee.Polygon:switch(e.type){case Ee.Line:return Bn(t,e);case Ee.Ellipse:return Dn(t,e);case Ee.Rect:return Vn(t,e);case Ee.Polyline:return $n(t,e);case Ee.Polygon:return zn(t,e)}break;case Ee.Path:switch(e.type){case Ee.Line:return jn(t,e,n);case Ee.Ellipse:return Un(t,e,n);case Ee.Rect:return Gn(t,e,n);case Ee.Polyline:return Hn(t,e,n);case Ee.Polygon:return qn(t,e,n);case Ee.Path:return Wn(t,e,n,i)}}switch(e.type){case Ee.Ellipse:case Ee.Rect:case Ee.Polyline:case Ee.Polygon:case Ee.Path:return _n(e,t,i,n);default:throw Error(`The intersection for ${t} and ${e} could not be found.`)}}function Pn(t,e){const n=t.start.x,i=t.start.y,r=t.end.x,o=t.end.y,s=e.start.x,a=e.start.y,l=r-n,c=o-i,h=e.end.x-s,u=e.end.y-a,d=n-s,f=i-a,p=l*u-h*c,g=(l*f-c*d)/p,m=(h*f-u*d)/p;return g>=0&&g<=1&&m>=0&&m<=1}function kn(t,e){const n=t.a,i=t.b,r=t.x,o=t.y,s=e.start.x-r,a=e.end.x-r,l=e.start.y-o,c=n*n,h=i*i,u=a-s,d=e.end.y-o-l,f=u*u/c+d*d/h,p=2*s*u/c+2*l*d/h,g=p*p-4*f*(s*s/c+l*l/h-1);if(0===g){const t=-p/2/f;return t>=0&&t<=1}if(g>0){const t=Math.sqrt(g),e=(-p+t)/2/f,n=(-p-t)/2/f;return e>=0&&e<=1||n>=0&&n<=1}return!1}function Cn(t,e){return function(t,e,n,i){const{cos:r,sin:o}=Math,s=o(0),a=r(0),l=o(0),c=r(0),h=s*s,u=a*a,d=s*a,f=l*l,p=c*c,g=l*c,m=t.a*t.a,v=t.b*t.b,y=n.a*n.a,b=n.b*n.b,w=m*h+v*u,x=y*f+b*p,A=m*u+v*h,E=y*p+b*f;let T=2*(v-m)*d,S=2*(b-y)*g,_=-2*w*t.x-T*t.y,P=-2*x*n.x-S*n.y,k=-T*t.x-2*A*t.y,C=-S*n.x-2*E*n.y;const L=w*t.x*t.x+A*t.y*t.y+T*t.x*t.y-m*v,M=x*n.x*n.x+E*n.y*n.y+S*n.x*n.y-y*b;T/=2,S/=2,_/=2,P/=2,k/=2,C/=2;const O=ei([[w,T,_],[T,A,k],[_,k,L]]),N=ei([[x,S,P],[S,E,C],[P,C,M]]),R=.33333333*(ei([[x,T,_],[S,A,k],[P,k,L]])+ei([[w,S,_],[T,E,k],[_,C,L]])+ei([[w,T,P],[T,A,C],[_,k,M]])),F=.33333333*(ei([[w,S,P],[T,E,C],[_,C,M]])+ei([[x,T,P],[S,A,C],[P,k,M]])+ei([[x,S,_],[S,E,k],[P,C,L]])),I=ti([[O,R],[R,F]]),B=ti([[O,F],[R,N]]),D=ti([[R,F],[F,N]]);return!(ti([[2*I,B],[B,2*D]])>0&&(F>0||R>0))}(t,0,e)}function Ln(t,e){const{start:n,end:i}=e,{x:r,y:o,width:s,height:a}=t;return!(n.x>r+s&&i.x>r+s||n.x<r&&i.x<r||n.y>o+a&&i.y>o+a||n.y<o&&i.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||Pn(t.topLine(),e)||Pn(t.rightLine(),e)||Pn(t.bottomLine(),e)||Pn(t.leftLine(),e))}function Mn(t,e){return!!On(t,Je.fromEllipse(e))&&Dn(Sn.fromRect(t),e)}function On(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function Nn(t,e){return Yn(t,e,{interior:!1})}function Rn(t,e){return Xn(t,e,{interior:!1})}function Fn(t,e){return Zn(t,e,{interior:!1})}function In(t,e){return Jn(t,e,{interior:!1})}function Bn(t,e){return Yn(t,e,{interior:!0})}function Dn(t,e){return Xn(t,e,{interior:!0})}function Vn(t,e){return Zn(t,e,{interior:!0})}function $n(t,e){return Jn(t,e,{interior:!0})}function zn(t,e){return Qn(t,e,{interior:!0})}function jn(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?Bn(i,e):Nn(i,e)}))}function Un(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?Dn(i,e):Rn(i,e)}))}function Gn(t,e,n){return qn(t,Sn.fromRect(e),n)}function Hn(t,e,n){return Kn(t,e,n,{interior:!1})}function qn(t,e,n){return Kn(t,e,n,{interior:!0})}function Wn(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?qn(e,r,i):Hn(e,r,i)}))}function Yn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){if(t.containsPoint(e.start))return!0;const{start:n,end:i,points:o}=t;r=i.equals(n)?o:[...o,n]}else r=t.points;const{length:o}=r,s=new De;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Pn(e,s))return!0;return!1}function Xn(t,e,n={}){const{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;const{interior:a=!1}=n;if(a){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;const{length:l}=s,c=new De;for(let t=0;t<l-1;t++)if(c.start=s[t],c.end=s[t+1],kn(e,c))return!0;return!1}function Zn(t,e,n){return Qn(t,Sn.fromRect(e),n)}function Kn(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?Qn(e,r,i):Jn(e,r,i)}))}function Jn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){const{start:n}=e;if(t.containsPoint(n))return!0;r=t.clone().close()}else r=t;const o=e.points,{length:s}=o,a=new De;for(let t=0;t<s-1;t++)if(a.start=o[t],a.end=o[t+1],Nn(r,a))return!0;return!1}function Qn(t,e,n){return e.containsPoint(t.start)||Jn(t,e.clone().close(),n)}function ti(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function ei(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}Sn.parse=function(t){return new Sn(tn(t))},Sn.fromRect=function(t){return new Sn([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},Sn.prototype=un(rn.prototype,{type:Ee.Polygon,clone:function(){return new Sn(en(this.points))},convexHull:function(){return new Sn(nn(this.points))},lengthPoints:function(){const{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});const ni=t,ii=function(){if("object"!=typeof window||!window.SVGAngle)return function(){throw new Error("SVG is required to use Vectorizer.")};var t={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},n=Math,i=n.PI,r=n.atan2,o=n.sqrt,s=n.min,a=n.max,l=n.cos,c=n.sin,h=function(e,n,i){if(!(this instanceof h))return h.apply(Object.create(h.prototype),arguments);if(e){if(h.isV(e)&&(e=e.node),n=n||{},h.isString(e)){if("svg"===(e=e.trim()).toLowerCase())e=h.createSvgDocument();else if("<"===e[0]){var r=h.createSvgDocument(e);if(r.childNodes.length>1){var o,s,a=[];for(o=0,s=r.childNodes.length;o<s;o++){var l=r.childNodes[o];a.push(new h(document.importNode(l,!0)))}return a}e=document.importNode(r.firstChild,!0)}else e=document.createElementNS(t.svg,e);h.ensureId(e)}return this.node=e,this.setAttributes(n),i&&this.append(i),this}},u=h.prototype;function d(t,e,n){n||(n={});for(var i=n.includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,l={},c=e.length-1,u=0;u<=c;u++){var d=e[u],f=null;if(h.isObject(d)){var p=d.attrs,g=h("tspan",p),m=g.node,v=d.t;r&&u===c&&(v+=r),m.textContent=v;var y=p.class;y&&g.addClass(y),i&&g.attr("annotations",d.annotations),f=parseFloat(p["font-size"]),isFinite(f)||(f=s),f&&f>a&&(a=f)}else r&&u===c&&(d+=r),m=document.createTextNode(d||" "),s&&s>a&&(a=s);t.appendChild(m)}return a&&(l.maxFontSize=a),o?l.lineHeight=o:a&&(l.lineHeight=1.2*a),l}Object.defineProperty(u,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),u.getTransformToElement=function(t){var e=this.node;if(h.isSVGGraphicsElement(t)&&h.isSVGGraphicsElement(e)){var n=h.toNode(t).getScreenCTM(),i=e.getScreenCTM();if(n&&i)return n.inverse().multiply(i)}return h.createSVGMatrix()},u.transform=function(t,e){var n=this.node;if(h.isUndefined(t))return h.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",h.matrixToTransformString(t));var i=h.createSVGTransform(t);return n.transform.baseVal.appendItem(i),this},u.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=h.parseTransformString(i);if(i=r.value,h.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();var o="translate("+(n.absolute?t:r.translate.tx+t)+","+(n.absolute?e:r.translate.ty+e)+")";return this.attr("transform",(o+" "+i).trim()),this},u.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=h.parseTransformString(r);if(r=o.value,h.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;var s="rotate("+(i.absolute?t:o.rotate.angle+t)+(void 0!==e&&void 0!==n?","+e+","+n:"")+")";return this.attr("transform",(r+" "+s).trim()),this},u.scale=function(t,e){e=h.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=h.parseTransformString(n);if(n=i.value,h.isUndefined(t))return i.scale;n=n.replace(/scale\([^)]*\)/g,"").trim();var r="scale("+t+","+e+")";return this.attr("transform",(n+" "+r).trim()),this},u.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new Je(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(t)return new Je(n);var o=this.getTransformToElement(e||r);return h.transformRect(n,o)},u.getBBox=function(t){var e,n={},i=this.node;if(!i.ownerSVGElement||!h.isSVGGraphicsElement(i))return new Je(0,0,0,0);if(t&&(t.target&&(n.target=h.toNode(t.target)),t.recursive&&(n.recursive=t.recursive)),n.recursive){var r=this.children(),o=r.length;if(0===o)return this.getBBox({target:n.target,recursive:!1});n.target||(n.target=this);for(var s=0;s<o;s++){var a,l=r[s];a=0===l.children().length?l.getBBox({target:n.target,recursive:!1}):l.getBBox({target:n.target,recursive:!0}),e=e?e.union(a):a}return e}try{e=i.getBBox()}catch(t){e={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(n.target){var c=this.getTransformToElement(n.target);return h.transformRect(e,c)}return new Je(e)};var f=/em$/;function p(t,e){var n=parseFloat(t);return f.test(t)?n*e:n}u.text=function(e,n){if(e&&"string"!=typeof e)throw new Error("Vectorizer: text() expects the first argument to be a string.");e=h.sanitizeText(e),n||(n={});var i=n.displayEmpty,r=n.eol,o=n.textPath,s=n.textVerticalAnchor,a="middle"===s||"bottom"===s||"top"===s,l=n.x;void 0===l&&(l=this.attr("x")||0);var c=n.includeAnnotationIndices,u=n.annotations;u&&!h.isArray(u)&&(u=[u]);var g=n.lineHeight,m="auto"===g,v=m?"1.5em":g||"1em";this.empty(),this.attr({"xml:space":"preserve",display:e||i?null:"none"});var y=parseFloat(this.attr("font-size"));y||(y=16,(a||u)&&this.attr("font-size",y));var b,w=document;o?("string"==typeof o&&(o={d:o}),b=function(t,e){t||(t={});var n=h("textPath"),i=t.d;if(i&&void 0===t["xlink:href"]){var r=h("path").attr("d",i).appendTo(e.defs());n.attr("xlink:href","#"+r.id)}return h.isObject(t)&&n.attr(t),n.node}(o,this)):b=w.createDocumentFragment();for(var x,A=0,E=e.split("\n"),T=[],S=0,_=E.length-1;S<=_;S++){var P,k=v,C="v-line",L=w.createElementNS(t.svg,"tspan"),M=E[S];if(M)if(u){var O=h.annotateString(M,u,{offset:-A,includeAnnotationIndices:c}),N=(P=d(L,O,{includeAnnotationIndices:c,eol:S!==_&&r,lineHeight:m?null:v,baseSize:y})).lineHeight;N&&m&&0!==S&&(k=N),0===S&&(x=.8*P.maxFontSize)}else r&&S!==_&&(M+=r),L.textContent=M;else{L.textContent="-",C+=" v-empty-line";var R=L.style;if(R.fillOpacity=0,R.strokeOpacity=0,u){P={};let t=y;for(let e=(O=h.findAnnotationsAtIndex(u,A)).length;e>0;e--){const n=O[e-1].attrs;if(!n||!("font-size"in n))continue;const i=parseFloat(n["font-size"]);if(isFinite(i)){t=i;break}}m&&(S>0?k=1.2*t:x=.8*t),L.setAttribute("font-size",t),P.maxFontSize=t}}P&&T.push(P),S>0&&L.setAttribute("dy",k),(S>0||o)&&L.setAttribute("x",l),L.className.baseVal=C,b.appendChild(L),A+=M.length+1}if(a)if(u)k=function(t,e,n,i){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=p(o.maxFontSize,n)||n,a=0,l=p(i,n),c=1;c<r;c++)a+=p((o=e[c]).lineHeight,n)||l;var h,u=p(o.maxFontSize,n)||n;switch(t){case"middle":h=s/2-.15*u-a/2;break;case"bottom":h=-.25*u-a;break;default:h=.8*s}return h}(s,T,y,v);else if("top"===s)k="0.8em";else{var F;switch(_>0?(F=parseFloat(v)||1,F*=_,f.test(v)||(F/=y)):F=0,s){case"middle":k=.3-F/2+"em";break;case"bottom":k=-F-.3+"em"}}else 0===s?k="0em":s?k=s:(k=0,null===this.attr("y")&&this.attr("y",x||"0.8em"));return b.firstChild.setAttribute("dy",k),this.append(b),this},u.removeAttr=function(t){const e=y[t],{ns:n,local:i}=h.qualifyAttr(e),r=this.node;return n?r.hasAttributeNS(n,i)&&r.removeAttributeNS(n,i):r.hasAttribute(e)&&r.removeAttribute(e),this},u.attr=function(t,e){if(h.isUndefined(t)){for(var n=this.node.attributes,i={},r=0;r<n.length;r++)i[n[r].name]=n[r].value;return i}if(h.isString(t)&&h.isUndefined(e))return this.node.getAttribute(y[t]);if("object"==typeof t)for(var o in t)t.hasOwnProperty(o)&&this.setAttribute(o,t[o]);else this.setAttribute(t,e);return this},u.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",h.normalizePathData(this.attr("d"))),this},u.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},u.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},u.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},u.append=function(t){h.isArray(t)||(t=[t]);for(var e=0,n=t.length;e<n;e++)this.node.appendChild(h.toNode(t[e]));return this},u.prepend=function(t){var e=this.node.firstChild;return e?h(e).before(t):this.append(t)},u.before=function(t){var e=this.node,n=e.parentNode;if(n){h.isArray(t)||(t=[t]);for(var i=0,r=t.length;i<r;i++)n.insertBefore(h.toNode(t[i]),e)}return this},u.appendTo=function(t){return h.toNode(t).appendChild(this.node),this},u.svg=function(){return this.node instanceof window.SVGSVGElement?this:h(this.node.ownerSVGElement)},u.tagName=function(){return this.node.tagName.toUpperCase()},u.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?h(e):h("defs").appendTo(t)},u.clone=function(){var t=h(this.node.cloneNode(!0));return t.node.id=h.uniqueId(),t},u.findOne=function(t){var e=this.node.querySelector(t);return e?h(e):void 0},u.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(h(n[i]));return e},u.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(h(t[n]));return e},u.parent=function(){return h(this.node.parentNode)||null},u.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},u.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=h(i);if(r.hasClass(t))return r;i=i.parentNode}return null},u.contains=function(t){var e=this.node,n=h.toNode(t),i=n&&n.parentNode;return e===i||!!(i&&1===i.nodeType&&16&e.compareDocumentPosition(i))},u.toLocalPoint=function(t,e){var n=this.svg().node,i=n.createSVGPoint();i.x=t,i.y=e;try{var r=i.matrixTransform(n.getScreenCTM().inverse()),o=this.getTransformToElement(n).inverse()}catch(t){return i}return r.matrixTransform(o)},u.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},u.translateAndAutoOrient=function(t,e,n){t=new Re(t),e=new Re(e),n||(n=this.svg());var i=this.scale();this.attr("transform","");var r=this.getBBox({target:n}).scale(i.sx,i.sy),o=h.createSVGTransform();o.setTranslate(-r.x-r.width/2,-r.y-r.height/2);var s=h.createSVGTransform(),a=t.angleBetween(e,t.clone().offset(1,0));a&&s.setRotate(a,0,0);var l=h.createSVGTransform(),c=t.clone().move(e,r.width/2);l.setTranslate(2*t.x-c.x,2*t.y-c.y);var u=this.getTransformToElement(n),d=h.createSVGTransform();return d.setMatrix(l.matrix.multiply(s.matrix.multiply(o.matrix.multiply(u.scale(i.sx,i.sy))))),this.attr("transform",h.matrixToTransformString(d.matrix)),this},u.animateAlongPath=function(t,e){e=h.toNode(e);var n=h.ensureId(e),i=h("animateMotion",t),r=h("mpath",{"xlink:href":"#"+n});i.append(r),this.append(i);try{i.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling")){var o=i.node;o.animators=[];var s=o.getAttribute("id");s&&(id2anim[s]=o);for(var a=getTargets(o),l=0,c=a.length;l<c;l++){var u=a[l],d=new Animator(o,u,l);animators.push(d),o.animators[l]=d,d.register()}}}return this};const g=/[^\x20\t\r\n\f]+/g;function m(t){return h.isString(t)&&t.trim().match(g)||[]}u.hasClass=function(t){return!!h.isString(t)&&this.node.classList.contains(t.trim())},u.addClass=function(t){return this.node.classList.add(...m(t)),this},u.removeClass=function(t){return this.node.classList.remove(...m(t)),this},u.toggleClass=function(t,e){const n=m(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},u.sample=function(t){t=t||1;for(var e,n=this.node,i=n.getTotalLength(),r=[],o=0;o<i;)e=n.getPointAtLength(o),r.push({x:e.x,y:e.y,distance:o}),o+=t;return r},u.convertToPath=function(){var t=h("path");t.attr(this.attr());var e=this.convertToPathData();return e&&t.attr("d",e),t},u.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return h.convertLineToPathData(this.node);case"POLYGON":return h.convertPolygonToPathData(this.node);case"POLYLINE":return h.convertPolylineToPathData(this.node);case"ELLIPSE":return h.convertEllipseToPathData(this.node);case"CIRCLE":return h.convertCircleToPathData(this.node);case"RECT":return h.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},h.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s,a,l,c,u,d,f,p,g;switch(this.tagName()){case"RECT":return t=parseFloat(this.attr("x"))||0,e=parseFloat(this.attr("y"))||0,n=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new Je(t,e,n,i);case"CIRCLE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("r"))||0,new Ue({x:r,y:o},s,s);case"ELLIPSE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,a=parseFloat(this.attr("rx"))||0,l=parseFloat(this.attr("ry"))||0,new Ue({x:r,y:o},a,l);case"POLYLINE":return c=h.getPointsFromSvgNode(this),new rn(c);case"POLYGON":return(c=h.getPointsFromSvgNode(this)).length>1&&c.push(c[0]),new rn(c);case"PATH":return u=this.attr("d"),dn.isDataSupported(u)||(u=h.normalizePathData(u)),new dn(u);case"LINE":return d=parseFloat(this.attr("x1"))||0,p=parseFloat(this.attr("y1"))||0,f=parseFloat(this.attr("x2"))||0,g=parseFloat(this.attr("y2"))||0,new De({x:d,y:p},{x:f,y:g})}return this.getBBox()},u.findIntersection=function(t,e){var n=this.svg().node;e=e||n;var i=this.getBBox({target:e}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){var o,s=this.tagName();if("RECT"===s){var a=new Je(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),l=this.getTransformToElement(e),c=h.decomposeMatrix(l),u=n.createSVGTransform();u.setRotate(-c.rotation,r.x,r.y);var d=h.transformRect(a,u.matrix.multiply(l));o=new Je(d).intersectionWithLineFromCenterToPoint(t,c.rotation)}else if("PATH"===s||"POLYGON"===s||"POLYLINE"===s||"CIRCLE"===s||"ELLIPSE"===s){var f,p,g,m,v,y=("PATH"===s?this:this.convertToPath()).sample(),b=1/0,w=[];for(f=0;f<y.length;f++)p=y[f],g=(g=h.createSVGPoint(p.x,p.y)).matrixTransform(this.getTransformToElement(e)),(v=(p=new Re(g)).distance(r)+(m=1.1*p.distance(t)))<b?(b=v,w=[{sample:p,refDistance:m}]):v<b+1&&w.push({sample:p,refDistance:m});w.sort((function(t,e){return t.refDistance-e.refDistance})),w[0]&&(o=w[0].sample)}return o}},u.setAttribute=function(t,e){const n=this.node;if(null===e)return this.removeAttr(t),this;const i=y[t],{ns:r}=h.qualifyAttr(i);return r?n.setAttributeNS(r,i,e):"id"===i?n.id=e:n.setAttribute(i,e),this},h.createSvgDocument=function(e){if(e){const n=`<svg xmlns="${t.svg}" xmlns:xlink="${t.xlink}" version="1.1">${e}</svg>`,{documentElement:i}=h.parseXML(n,{async:!1});return i}const n=document.createElementNS(t.svg,"svg");return n.setAttributeNS(t.xmlns,"xmlns:xlink",t.xlink),n.setAttribute("version","1.1"),n},h.createSVGStyle=function(t){const{node:e}=h("style",{type:"text/css"},[h.createCDATASection(t)]);return e},h.createCDATASection=function(t=""){return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},h.idCounter=0,h.uniqueId=function(){return"v-"+ ++h.idCounter},h.toNode=function(t){return h.isV(t)?t.node:t.nodeName&&t||t[0]},h.ensureId=function(t){return(t=h.toNode(t)).id||(t.id=h.uniqueId())},h.sanitizeText=function(t){return(t||"").replace(/ /g," ")},h.isUndefined=function(t){return void 0===t},h.isString=function(t){return"string"==typeof t},h.isObject=function(t){return t&&"object"==typeof t},h.isArray=Array.isArray,h.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;h.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch(t){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};const v=Object.create(null);["baseFrequency","baseProfile","clipPathUnits","contentScriptType","contentStyleType","diffuseConstant","edgeMode","externalResourcesRequired","filterRes","filterUnits","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach((t=>v[t]=t)),v.xlinkShow="xlink:show",v.xlinkRole="xlink:role",v.xlinkActuate="xlink:actuate",v.xlinkHref="xlink:href",v.xlinkType="xlink:type",v.xlinkTitle="xlink:title",v.xmlBase="xml:base",v.xmlLang="xml:lang",v.xmlSpace="xml:space";const y=new Proxy(v,{get:(t,e)=>h.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e});Object.defineProperty(h,"attributeNames",{enumerable:!0,value:y,writable:!1}),Object.defineProperty(h,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),h.qualifyAttr=function(e){if(-1!==e.indexOf(":")){var n=e.split(":");return{ns:t[n[0]],local:n[1]}}return{ns:null,local:e}},h.transformSeparatorRegex=/[ ,]+/,h.transformRegex=/\b\w+\([^()]+\)/g,h.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,h.transformTranslateRegex=/\btranslate\(([^()]+)\)/,h.transformRotateRegex=/\brotate\(([^()]+)\)/,h.transformScaleRegex=/\bscale\(([^()]+)\)/,h.transformStringToMatrix=function(t){let e=h.createSVGMatrix();const n=t&&t.match(h.transformRegex);if(!n)return e;const i=n.length;for(let t=0;t<i;t++){const i=n[t].match(h.transformFunctionRegex);if(i){let t,n,r,o,s,a=h.createSVGMatrix();const l=i[1].toLowerCase(),c=i[2].split(h.transformSeparatorRegex);switch(l){case"scale":t=parseFloat(c[0]),n=void 0===c[1]?t:parseFloat(c[1]),a=a.scaleNonUniform(t,n);break;case"translate":r=parseFloat(c[0]),o=parseFloat(c[1]),a=a.translate(r,o);break;case"rotate":s=parseFloat(c[0]),r=parseFloat(c[1])||0,o=parseFloat(c[2])||0,a=0!==r||0!==o?a.translate(r,o).rotate(s).translate(-r,-o):a.rotate(s);break;case"skewx":s=parseFloat(c[0]),a=a.skewX(s);break;case"skewy":s=parseFloat(c[0]),a=a.skewY(s);break;case"matrix":a.a=parseFloat(c[0]),a.b=parseFloat(c[1]),a.c=parseFloat(c[2]),a.d=parseFloat(c[3]),a.e=parseFloat(c[4]),a.f=parseFloat(c[5]);break;default:continue}e=e.multiply(a)}}return e},h.matrixToTransformString=function(t){return t||(t=!0),"matrix("+(void 0!==t.a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},h.parseTransformString=function(t){var e,n,i;if(t){var r=h.transformSeparatorRegex;if(t.trim().indexOf("matrix")>=0){var o=h.transformStringToMatrix(t),s=h.decomposeMatrix(o);e=[s.translateX,s.translateY],i=[s.scaleX,s.scaleY],n=[s.rotation];var a=[];0===e[0]&&0===e[1]||a.push("translate("+e+")"),1===i[0]&&1===i[1]||a.push("scale("+i+")"),0!==n[0]&&a.push("rotate("+n+")"),t=a.join(" ")}else{const o=t.match(h.transformTranslateRegex);o&&(e=o[1].split(r));const s=t.match(h.transformRotateRegex);s&&(n=s[1].split(r));const a=t.match(h.transformScaleRegex);a&&(i=a[1].split(r))}}var l=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:e&&e[0]?parseInt(e[0],10):0,ty:e&&e[1]?parseInt(e[1],10):0},rotate:{angle:n&&n[0]?parseInt(n[0],10):0,cx:n&&n[1]?parseInt(n[1],10):void 0,cy:n&&n[2]?parseInt(n[2],10):void 0},scale:{sx:l,sy:i&&i[1]?parseFloat(i[1]):l}}},h.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c+0,y:e.x*t.b+e.y*t.d+0}},h.decomposeMatrix=function(t){var e=h.deltaTransformPoint(t,{x:0,y:1}),n=h.deltaTransformPoint(t,{x:1,y:0}),s=180/i*r(e.y,e.x)-90,a=180/i*r(n.y,n.x);return{translateX:t.e,translateY:t.f,scaleX:o(t.a*t.a+t.b*t.b),scaleY:o(t.c*t.c+t.d*t.d),skewX:s,skewY:a,rotation:s}},h.matrixToScale=function(t){var e,n,i,r;return t?(e=h.isUndefined(t.a)?1:t.a,r=h.isUndefined(t.d)?1:t.d,n=t.b,i=t.c):e=r=1,{sx:n?o(e*e+n*n):e,sy:i?o(i*i+r*r):r}},h.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=h.deltaTransformPoint(t,e)),{angle:de(pe(r(e.y,e.x))-90)}},h.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},h.isV=function(t){return t instanceof h},h.isVElement=h.isV,h.isSVGGraphicsElement=function(t){return!!t&&(t=h.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM};var b=h("svg").node;return h.createSVGMatrix=function(t){var e=b.createSVGMatrix();for(var n in t)e[n]=t[n];return e},h.createSVGTransform=function(t){return h.isUndefined(t)?b.createSVGTransform():(t instanceof SVGMatrix||(t=h.createSVGMatrix(t)),b.createSVGTransformFromMatrix(t))},h.createSVGPoint=function(t,e){var n=b.createSVGPoint();return n.x=t,n.y=e,n},h.transformRect=function(t,e){var n=b.createSVGPoint();n.x=t.x,n.y=t.y;var i=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y;var r=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y+t.height;var o=n.matrixTransform(e);n.x=t.x,n.y=t.y+t.height;var l=n.matrixTransform(e),c=s(i.x,r.x,o.x,l.x),h=a(i.x,r.x,o.x,l.x),u=s(i.y,r.y,o.y,l.y),d=a(i.y,r.y,o.y,l.y);return new Je(c,u,h-c,d-u)},h.transformPoint=function(t,e){return new Re(h.createSVGPoint(t.x,t.y).matrixTransform(e))},h.transformLine=function(t,e){return new De(h.transformPoint(t.start,e),h.transformPoint(t.end,e))},h.transformPolyline=function(t,e){var n=t instanceof rn?t.points:t;h.isArray(n)||(n=[]);for(var i=[],r=0,o=n.length;r<o;r++)i[r]=h.transformPoint(n[r],e);return new rn(i)},h.styleToObject=function(t){for(var e={},n=t.split(";"),i=0;i<n.length;i++){var r=n[i].split("=");e[r[0].trim()]=r[1].trim()}return e},h.createSlicePathData=function(t,e,n,r){var o=2*i-1e-6,s=t,a=e,h=n,u=r,d=(u<h&&(d=h,h=u,u=d),u-h),f=d<i?"0":"1",p=l(h),g=c(h),m=l(u),v=c(u);return d>=o?s?"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"M0,"+s+"A"+s+","+s+" 0 1,0 0,"+-s+"A"+s+","+s+" 0 1,0 0,"+s+"Z":"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z":s?"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L"+s*m+","+s*v+"A"+s+","+s+" 0 "+f+",0 "+s*p+","+s*g+"Z":"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L0,0Z"},h.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?h.isObject(t[n])&&h.isObject(e[n])?t[n]=h.mergeAttrs(t[n],e[n]):h.isObject(t[n])?t[n]=h.mergeAttrs(t[n],h.styleToObject(e[n])):h.isObject(e[n])?t[n]=h.mergeAttrs(h.styleToObject(t[n]),e[n]):t[n]=h.mergeAttrs(h.styleToObject(t[n]),h.styleToObject(e[n])):t[n]=e[n];return t},h.annotateString=function(t,e,n){e=e||[];for(var i,r,o,s=(n=n||{}).offset||0,a=[],l=[],c=0;c<t.length;c++){r=l[c]=t[c];for(var u=0;u<e.length;u++){var d=e[u],f=d.start+s,p=d.end+s;c>=f&&c<p&&(h.isObject(r)?r.attrs=h.mergeAttrs(h.mergeAttrs({},r.attrs),d.attrs):r=l[c]={t:t[c],attrs:d.attrs},n.includeAnnotationIndices&&(r.annotations||(r.annotations=[])).push(u))}(o=l[c-1])?h.isObject(r)&&h.isObject(o)?JSON.stringify(r.attrs)===JSON.stringify(o.attrs)?i.t+=r.t:(a.push(i),i=r):h.isObject(r)||h.isObject(o)?(a.push(i),i=r):i=(i||"")+r:i=r}return i&&a.push(i),a},h.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach((function(t){t.start<e&&e<=t.end&&n.push(t)})),n},h.findAnnotationsBetweenIndexes=function(t,e,n){var i=[];return t&&t.forEach((function(t){(e>=t.start&&e<t.end||n>t.start&&n<=t.end||t.start>=e&&t.end<n)&&i.push(t)})),i},h.shiftAnnotations=function(t,e,n){return t&&t.forEach((function(t){t.start<e&&t.end>=e?t.end+=n:t.start>=e&&(t.start+=n,t.end+=n)})),t},h.convertLineToPathData=function(t){return["M",(t=h(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},h.convertPolygonToPathData=function(t){var e=h.getPointsFromSvgNode(t);return 0===e.length?null:h.svgPointsToPath(e)+" Z"},h.convertPolylineToPathData=function(t){var e=h.getPointsFromSvgNode(t);return 0===e.length?null:h.svgPointsToPath(e)},h.svgPointsToPath=function(t){for(var e=0,n=t.length;e<n;e++)t[e]=t[e].x+" "+t[e].y;return"M "+t.join(" L")},h.getPointsFromSvgNode=function(t){var e=[],n=(t=h.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},h.KAPPA=.551784,h.convertCircleToPathData=function(t){t=h(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("r")),r=i*h.KAPPA;return["M",e,n-i,"C",e+r,n-i,e+i,n-r,e+i,n,"C",e+i,n+r,e+r,n+i,e,n+i,"C",e-r,n+i,e-i,n+r,e-i,n,"C",e-i,n-r,e-r,n-i,e,n-i,"Z"].join(" ")},h.convertEllipseToPathData=function(t){t=h(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),r=parseFloat(t.attr("ry"))||i,o=i*h.KAPPA,s=r*h.KAPPA;return["M",e,n-r,"C",e+o,n-r,e+i,n-s,e+i,n,"C",e+i,n+s,e+o,n+r,e,n+r,"C",e-o,n+r,e-i,n+s,e-i,n,"C",e-i,n-s,e-o,n-r,e,n-r,"Z"].join(" ")},h.convertRectToPathData=function(t){return t=h(t),h.rectToPath({x:parseFloat(t.attr("x"))||0,y:parseFloat(t.attr("y"))||0,width:parseFloat(t.attr("width"))||0,height:parseFloat(t.attr("height"))||0,rx:parseFloat(t.attr("rx"))||0,ry:parseFloat(t.attr("ry"))||0})},h.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=s(t.rx||t["top-rx"]||0,i/2),a=s(t.rx||t["bottom-rx"]||0,i/2),l=s(t.ry||t["top-ry"]||0,r/2),c=s(t.ry||t["bottom-ry"]||0,r/2);return(o||a||l||c?["M",e,n+l,"v",r-l-c,"a",a,c,0,0,0,a,c,"h",i-2*a,"a",a,c,0,0,0,a,-c,"v",-(r-c-l),"a",o,l,0,0,0,-o,-l,"h",-(i-2*o),"a",o,l,0,0,0,-o,l,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"]).join(" ")},h.normalizePathData=function(){var t="\t\n\v\f\r \u2028\u2029",e=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),n=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),i=Math,r=i.PI,o=i.sin,s=i.cos,a=i.tan,l=i.asin,c=i.sqrt,h=i.abs;function u(t,e,n,i,r,o){var s=1/3,a=2/3;return[s*t+a*n,s*e+a*i,s*r+a*n,s*o+a*i,r,o]}function d(t,e,n){return{x:t*s(n)-e*o(n),y:t*o(n)+e*s(n)}}function f(t,e,n,i,u,p,g,m,v,y){var b,w=120*r/180,x=r/180*(+u||0),A=[];if(y)M=y[0],O=y[1],C=y[2],L=y[3];else{t=(b=d(t,e,-x)).x,e=b.y;var E=(t-(m=(b=d(m,v,-x)).x))/2,T=(e-(v=b.y))/2,S=E*E/(n*n)+T*T/(i*i);S>1&&(n*=S=c(S),i*=S);var _=n*n,P=i*i,k=(p==g?-1:1)*c(h((_*P-_*T*T-P*E*E)/(_*T*T+P*E*E))),C=k*n*T/i+(t+m)/2,L=k*-i*E/n+(e+v)/2,M=l(((e-L)/i).toFixed(9)),O=l(((v-L)/i).toFixed(9));(M=t<C?r-M:M)<0&&(M=2*r+M),(O=m<C?r-O:O)<0&&(O=2*r+O),g&&M>O&&(M-=2*r),!g&&O>M&&(O-=2*r)}var N=O-M;if(h(N)>w){var R=O,F=m,I=v;A=f(m=C+n*s(O=M+w*(g&&O>M?1:-1)),v=L+i*o(O),n,i,u,0,g,F,I,[O,R,C,L])}N=O-M;var B=s(M),D=o(M),V=s(O),$=o(O),z=a(N/4),j=4/3*(n*z),U=4/3*(i*z),G=[t,e],H=[t+j*D,e-U*B],q=[m+j*$,v-U*V],W=[m,v];if(H[0]=2*G[0]-H[0],H[1]=2*G[1]-H[1],y)return[H,q,W].concat(A);for(var Y=[],X=(A=[H,q,W].concat(A).join().split(",")).length,Z=0;Z<X;Z++)Y[Z]=Z%2?d(A[Z-1],A[Z],x).y:d(A[Z],A[Z+1],x).x;return Y}function p(t){var i=function(t){if(Array.isArray(t)&&Array.isArray(t&&t[0])||(t=function(t){if(!t)return null;var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=[];return String(t).replace(e,(function(t,e,o){var s=[],a=e.toLowerCase();for(o.replace(n,(function(t,e){e&&s.push(+e)})),"m"===a&&s.length>2&&(r.push([e].concat(s.splice(0,2))),a="l",e="m"===e?"l":"L");s.length>=i[a]&&(r.push([e].concat(s.splice(0,i[a]))),i[a]););})),r}(t)),!t||!t.length)return[["M",0,0]];for(var i,r=[],o=0,s=0,a=0,l=0,c=t.length,h=0;h<c;h++){var u=[];r.push(u);var d,f,p=t[h];if((i=p[0])!=i.toUpperCase())switch(u[0]=i.toUpperCase(),u[0]){case"A":u[1]=p[1],u[2]=p[2],u[3]=p[3],u[4]=p[4],u[5]=p[5],u[6]=+p[6]+o,u[7]=+p[7]+s;break;case"V":u[1]=+p[1]+s;break;case"H":u[1]=+p[1]+o;break;case"M":for(a=+p[1]+o,l=+p[2]+s,d=p.length,f=1;f<d;f++)u[f]=+p[f]+(f%2?o:s);break;default:for(d=p.length,f=1;f<d;f++)u[f]=+p[f]+(f%2?o:s)}else for(var g=p.length,m=0;m<g;m++)u[m]=p[m];switch(u[0]){case"Z":o=+a,s=+l;break;case"H":o=u[1];break;case"V":s=u[1];break;case"M":a=u[u.length-2],l=u[u.length-1],o=u[u.length-2],s=u[u.length-1];break;default:o=u[u.length-2],s=u[u.length-1]}}return r}(t),r={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function o(t,e,n){var i,r;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(t[0]in{T:1,Q:1}||(e.qx=null,e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=0===parseFloat(t[1])||0===parseFloat(t[2])?["L",t[6],t[7]]:["C"].concat(f.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":"C"===n||"S"===n?(i=2*e.x-e.bx,r=2*e.y-e.by):(i=e.x,r=e.y),t=["C",i,r].concat(t.slice(1));break;case"T":"Q"===n||"T"===n?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"].concat(u(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"].concat(u(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}function s(t,e){if(t[e].length>7){t[e].shift();for(var n=t[e];n.length;)a[e]="A",t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),h=i.length}}for(var a=[],l="",c="",h=i.length,d=0;d<h;d++){i[d]&&(l=i[d][0]),"C"!==l&&(a[d]=l,d>0&&(c=a[d-1])),i[d]=o(i[d],r,c),"A"!==a[d]&&"C"===l&&(a[d]="C"),s(i,d);var p=i[d],g=p.length;r.x=p[g-2],r.y=p[g-1],r.bx=parseFloat(p[g-4])||r.x,r.by=parseFloat(p[g-3])||r.y}return i[0][0]&&"M"===i[0][0]||i.unshift(["M",0,0]),i}return function(t){return p(t).join(",").split(",").join(" ")}}(),h.namespace=t,h.g=e,h}(),ri=ii,oi="[object Arguments]",si="[object Array]",ai="[object Boolean]",li="[object Date]",ci="[object Error]",hi="[object Function]",ui="[object Map]",di="[object Number]",fi="[object Object]",pi="[object RegExp]",gi="[object Set]",mi="[object String]",vi="[object Symbol]",yi="[object WeakMap]",bi="[object ArrayBuffer]",wi="[object DataView]",xi="[object Float32Array]",Ai="[object Float64Array]",Ei="[object Int8Array]",Ti="[object Int16Array]",Si="[object Int32Array]",_i="[object Uint8Array]",Pi="[object Uint8ClampedArray]",ki="[object Uint16Array]",Ci="[object Uint32Array]",Li={[oi]:!0,[si]:!0,[bi]:!0,[wi]:!0,[ai]:!0,[li]:!0,[xi]:!0,[Ai]:!0,[Ei]:!0,[Ti]:!0,[Si]:!0,[ui]:!0,[di]:!0,[fi]:!0,[pi]:!0,[gi]:!0,[mi]:!0,[vi]:!0,[_i]:!0,[Pi]:!0,[ki]:!0,[Ci]:!0,[ci]:!1,[hi]:!1,[yi]:!1},Mi="\\ud800-\\udfff",Oi="\\u2700-\\u27bf",Ni="a-z\\xdf-\\xf6\\xf8-\\xff",Ri="A-Z\\xc0-\\xd6\\xd8-\\xde",Fi="\\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",Ii="['’]",Bi=`[${Fi}]`,Di="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Vi=`[${Oi}]`,$i=`[${Ni}]`,zi=`[^${Mi}${Fi+"\\d"+Oi+Ni+Ri}]`,ji="\\ud83c[\\udffb-\\udfff]",Ui=`[^${Mi}]`,Gi="(?:\\ud83c[\\udde6-\\uddff]){2}",Hi="[\\ud800-\\udbff][\\udc00-\\udfff]",qi=`[${Ri}]`,Wi=`(?:${$i}|${zi})`,Yi=`(?:${qi}|${zi})`,Xi=`(?:${Ii}(?:d|ll|m|re|s|t|ve))?`,Zi=`(?:${Ii}(?:D|LL|M|RE|S|T|VE))?`,Ki=`(?:${Di}|${ji})?`,Ji="[\\ufe0e\\ufe0f]?",Qi=Ji+Ki+`(?:\\u200d(?:${[Ui,Gi,Hi].join("|")})${Ji+Ki})*`,tr=`(?:${[Vi,Gi,Hi].join("|")})${Qi}`,er=RegExp([`${qi}?${$i}+${Xi}(?=${[Bi,qi,"$"].join("|")})`,`${Yi}+${Zi}(?=${[Bi,qi+Wi,"$"].join("|")})`,`${qi}?${Wi}+${Xi}`,`${qi}+${Zi}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",tr].join("|"),"g"),nr="__hash_undefined__",ir=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,rr=`(?:${[`${Ui}${Di}?`,Di,Gi,Hi,`[${Mi}]`].join("|")})`,or=RegExp(`${ji}(?=${ji})|${rr+Qi}`,"g"),sr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ar=/^\w*$/,lr=".".charCodeAt(0),cr=/\\(\\)?/g,hr=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),ur=/^(?:0|[1-9]\d*)$/,dr=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),fr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,pr=t=>or.test(t),gr=t=>pr(t)?(t=>t.match(or)||[])(t):(t=>t.split(""))(t),mr=t=>null==t?[]:vr(t).map((e=>t[e])),vr=t=>_r(t)?yr(t):Object.keys(Object(t)),yr=(t,e)=>{const n=Array.isArray(t),i=!n&&xr(t)&&Cr(t)===oi,r=!n&&!i&&Rr(t),o=n||i||r,s=t.length,a=new Array(o?s:0);let l=o?-1:s;for(;++l<s;)a[l]=`${l}`;for(const n in t)!e&&!hasOwnProperty.call(t,n)||o&&("length"===n||ro(n,s))||a.push(n);return a},br=(t,e)=>{let{length:n}=t;for(;n--;)if(wr(t[n][0],e))return n;return-1},wr=(t,e)=>t===e||t!=t&&e!=e,xr=t=>null!=t&&"object"==typeof t,Ar=(t,e,n)=>{if(!Bo(n))return!1;const i=typeof e;return!!("number"==i?_r(n)&&e>-1&&e<n.length:"string"==i&&e in n)&&wr(n[e],t)},Er=t=>{const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},Tr=(t,e,n)=>{const i=t[e];hasOwnProperty.call(t,e)&&wr(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Sr=(t,e,n)=>{let i=-1;const r=e.length;for(;++i<r;){const r=e[i];Tr(n,r,t[r])}return n},_r=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&t.length>-1&&t.length%1==0,Pr=t=>"symbol"==typeof t||xr(t)&&Cr(t)===vi,kr=(t,e)=>{let n=-1;const i=t.length;for(e||(e=new Array(i));++n<i;)e[n]=t[n];return e},Cr=t=>null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t),Lr=t=>{const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Mr=(t,e)=>{const n=e?Lr(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)},Or=t=>"function"!=typeof t.constructor||Er(t)?{}:Object.create(Object.getPrototypeOf(t)),Nr=t=>null==t?[]:(t=Object(t),Object.getOwnPropertySymbols(t).filter((e=>propertyIsEnumerable.call(t,e)))),Rr=t=>xr(t)&&ir.test(Cr(t)),Fr=t=>{const e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...Nr(Object(t))),e},Ir=t=>{const e=[];for(;t;)e.push(...Nr(t)),t=Object.getPrototypeOf(Object(t));return e},Br=t=>{const e=[];for(const n in t)e.push(n);return Array.isArray(t)||e.push(...Ir(t)),e},Dr=({__data__:t},e)=>{const n=t;return so(e)?n["string"==typeof e?"string":"hash"]:n.map},Vr=(t,e,n)=>t===e||(null==t||null==e||!xr(t)&&!xr(e)?t!=t&&e!=e:$r(t,e,Vr,n)),$r=(t,e,n,i)=>{let r=Array.isArray(t);const o=Array.isArray(e);let s=r?si:Cr(t),a=o?si:Cr(e);s=s==oi?fi:s,a=a==oi?fi:a;let l=s==fi;const c=a==fi,h=s==a;if(h&&!l)return i||(i=new Oo),r||Rr(t)?zr(t,e,!1,n,i):Hr(t,e,s,n,i);const u=l&&hasOwnProperty.call(t,"__wrapped__"),d=c&&hasOwnProperty.call(e,"__wrapped__");if(u||d){const r=u?t.value():t,o=d?e.value():e;return i||(i=new Oo),n(r,o,i)}return!!h&&(i||(i=new Oo),((t,e,n,i)=>{const r=Fr(t),o=r.length;if(o!=Fr(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;const l=i.get(t),c=i.get(e);if(l&&c)return l==e&&c==t;let h,u=!0;for(i.set(t,e),i.set(e,t);++a<o;){s=r[a];const o=t[s],l=e[s];if(o!==l&&!n(o,l,i)){u=!1;break}h||(h="constructor"==s)}if(u&&!h){const n=t.constructor,i=e.constructor;n==i||!("constructor"in t)||!("constructor"in e)||"function"==typeof n&&n instanceof n&&"function"==typeof i&&i instanceof i||(u=!1)}return i.delete(t),i.delete(e),u})(t,e,n,i))},zr=(t,e,n,i,r)=>{const o=t.length;if(o!=e.length)return!1;const s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,c=!0;const h=n?new Io:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n;const o=t[l],s=e[l];if(void 0!==n){if(n)continue;c=!1;break}if(h){if(!jr(e,((t,e)=>{if(!Ur(h,e)&&(o===t||i(o,t,r)))return h.push(e)}))){c=!1;break}}else if(o!==s&&!i(o,s,r)){c=!1;break}}return r.delete(t),r.delete(e),c},jr=(t,e)=>{let n=-1;const i=null==t?0:t.length;for(;++n<i;)if(e(t[n],n,t))return!0;return!1},Ur=(t,e)=>t.has(e),Gr=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),Hr=(t,e,n,i,r)=>{switch(n){case wi:return t.byteLength==e.byteLength&&t.byteOffset==e.byteOffset&&(t=t.buffer,e=e.buffer,Gr(t,e,i,r));case bi:return Gr(t,e,i,r);case ai:case li:case di:return wr(+t,+e);case ci:return t.name==e.name&&t.message==e.message;case pi:case mi:return t==`${e}`;case ui:let n=qr;case gi:if(n||(n=Wr),t.size!=e.size)return!1;const o=r.get(t);if(o)return o==e;r.set(t,e);const s=zr(n(t),n(e),!0,i,r);return r.delete(t),s;case vi:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},qr=t=>{let e=-1,n=Array(t.size);return t.forEach(((t,i)=>{n[++e]=[i,t]})),n},Wr=t=>{let e=-1;const n=new Array(t.size);return t.forEach((t=>{n[++e]=t})),n},Yr=(t,e)=>{if(Array.isArray(t))return!1;const n=typeof t;return!("number"!==n&&"boolean"!==n&&null!=t&&!Pr(t))||ar.test(t)||!sr.test(t)||null!=e&&t in Object(e)},Xr=(t,e)=>Array.isArray(t)?t:Yr(t,e)?[t]:(t=>{const e=[];return t.charCodeAt(0)===lr&&e.push(""),t.replace(hr,((t,n,i,r)=>{let o=t;i?o=r.replace(cr,"$1"):n&&(o=n.trim()),e.push(o)})),e})(`${t}`),Zr=(t,e)=>{let n=0;const i=(e=Xr(e,t)).length;for(;null!=t&&n<i;)t=t[Qr(e[n])],n++;return n&&n==i?t:void 0};function Kr(t,e){if(t!==e){const n=void 0!==t,i=null===t,r=t==t,o=Pr(t),s=void 0!==e,a=null===e,l=e==e,c=Pr(e);if(!a&&!c&&!o&&t>e||o&&s&&l&&!a&&!c||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!c&&t<e||c&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}const Jr=(t,e)=>{let n=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1,i=!0;const r=[],o=e.length;if(!t.length)return r;e.length>=200&&(n=(t,e)=>t.has(e),i=!1,e=new Io(e));t:for(let s in t){let a=t[s];const l=a;if(a=0!==a?a:0,i&&l==l){let t=o;for(;t--;)if(e[t]===l)continue t;r.push(a)}else n(e,l)||r.push(a)}return r},Qr=t=>{if("string"==typeof t||Pr(t))return t;const e=`${t}`;return"0"==e&&1/t==-1/0?"-0":e},to=(t,e=!1,n=!1,i=!0,r,o,s,a)=>{let l;if(r&&(l=s?r(t,o,s,a):r(t)),void 0!==l)return l;if(!Bo(t))return t;const c=Array.isArray(t),h=Cr(t);if(c){if(l=(t=>{const e=t.length;let n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n})(t),!e)return kr(t,l)}else{const i="function"==typeof t;if(h===fi||h===oi||i&&!s){if(l=n||i?{}:Or(t),!e)return n?eo(t,Sr(t,Object.keys(t),l)):((t,e)=>Sr(t,Nr(t),e))(t,Object.assign(l,t))}else{if(i||!Li[h])return s?t:{};l=((t,e,n)=>{const i=t.constructor;switch(e){case bi:return Lr(t);case ai:case li:return new i(+t);case wi:return function(t,e){const n=e?Lr(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case xi:case Ai:case Ei:case Ti:case Si:case _i:case Pi:case ki:case Ci:return Mr(t,n);case ui:case di:case mi:return new i(t);case pi:return(t=>{const e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e})(t);case gi:return new i;case vi:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}})(t,h,e)}}a||(a=new Oo);const u=a.get(t);if(u)return u;if(a.set(t,l),(t=>xr(t)&&Cr(t)==ui)(t))return t.forEach(((o,s)=>{l.set(s,to(o,e,n,i,r,s,t,a))})),l;if((t=>xr(t)&&Cr(t)==gi)(t))return t.forEach((o=>{l.add(to(o,e,n,i,r,o,t,a))})),l;if(Rr(t))return l;const d=c?void 0:(i?n?Br:Fr:n?ao:vr)(t);return(d||t).forEach(((o,s)=>{d&&(o=t[s=o]),Tr(l,s,to(o,e,n,i,r,s,t,a))})),l},eo=(t,e)=>Sr(t,Ir(t),e),no=(t,e)=>e.length<2?t:Zr(t,e.slice(0,-1)),io=(t,e,n)=>{if(!Bo(t))return t;const i=(e=Xr(e,t)).length,r=i-1;let o=-1,s=t;for(;null!=s&&++o<i;){const t=Qr(e[o]);let i=n;if(o!=r){const n=s[t];i=void 0,void 0===i&&(i=Bo(n)?n:ro(e[o+1])?[]:{})}Tr(s,t,i),s=s[t]}return t},ro=(t,e)=>{const n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"===n||"symbol"!==n&&ur.test(t))&&t>-1&&t%1==0&&t<e},oo=(t,e)=>{e=Xr(e,t),t=no(t,e);const n=e[e.length-1];return null==t||delete t[Qr(n)]},so=t=>{const e=typeof t;return"string"===e||"number"===e||"symbol"===e||"boolean"===e?"__proto__"!==t:null===t},ao=t=>{const e=[];for(const n in t)e.push(n);return e},lo=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function co(t,e=!1){return(n,...i)=>{let r=-1,o=i.length,s=o>1?i[o-1]:void 0;const a=o>2?i[2]:void 0;for(s=t.length>3&&"function"==typeof s?(o--,s):e?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,a&&Ar(i[0],i[1],a)&&(s=o<3?void 0:s,o=1),n=Object(n);++r<o;){const e=i[r];e&&t(n,e,r,s)}return n}}const ho=(t,e,n,i,r)=>{t!==e&&cs(e,((o,s)=>{if(Bo(o))r||(r=new Oo),uo(t,e,s,n,ho,i,r);else{let n=i?i(t[s],o,`${s}`,t,e,r):void 0;void 0===n&&(n=o),fo(t,s,n)}}),ao)},uo=(t,e,n,i,r,o,s)=>{const a=lo(t,n),l=lo(e,n),c=s.get(l);if(c)return void fo(t,n,c);let h=o?o(a,l,`${n}`,t,e,s):void 0,u=void 0===h;if(u){const t=Array.isArray(l),e=!t&&Rr(l);h=l,t||e?Array.isArray(a)?h=a:xr(a)&&_r(a)?h=kr(a):e?(u=!1,h=Mr(l,!0)):h=[]:Jo(l)||ko(l)?(h=a,ko(a)?h=(t=>{t=Object(t);const e={};for(const n in t)e[n]=t[n];return e})(a):"function"!=typeof a&&Bo(a)||(h=Or(l))):u=!1}u&&(s.set(l,h),r(h,l,i,o,s),s.delete(l)),fo(t,n,h)},fo=(t,e,n)=>{(void 0!==n&&!wr(t[e],n)||void 0===n&&!(e in t))&&Tr(t,e,n)},po=(t,e)=>{if(null==t)return t;if(!_r(t))return((t,e)=>t&&function(t,e,n){const i=Object(t),r=n(t);let{length:o}=r,s=-1;for(;o--;){const t=r[++s];if(!1===e(i[t],t,i))break}return t}(t,e,vr))(t,e);const n=t.length,i=Object(t);let r=-1;for(;++r<n&&!1!==e(i[r],r,i););return t},go=Set&&1/Wr(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function mo(t,e,n,i,r,o){return Bo(t)&&Bo(e)&&(o.set(e,t),ho(t,e,void 0,mo,o),o.delete(e)),t}function vo(t,e,n){e=e.length?e.map((t=>Array.isArray(t)?e=>Zr(e,1===t.length?t[0]:t):t)):[t=>t];let i=-1,r=-1;const o=_r(t)?new Array(t.length):[];return po(t,(t=>{const n=e.map((e=>e(t)));o[++r]={criteria:n,index:++i,value:t}})),function(t,e){let{length:i}=t;for(t.sort(((t,e)=>function(t,e,n){let i=-1;const r=t.criteria,o=e.criteria,s=r.length,a=n.length;for(;++i<s;){const t=i<a?n[i]:null,e=(t&&"function"==typeof t?t:Kr)(r[i],o[i]);if(e)return t&&"function"!=typeof t?e*("desc"==t?-1:1):e}return t.index-e.index}(t,e,n)));i--;)t[i]=t[i].value;return t}(o)}function yo(t){return t==t&&!Bo(t)}function bo(t,e){return n=>null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}function wo(t,e){return null!=t&&Lo(t,e,Co)}function xo(t){const e=function(t){const e=vr(t);let n=e.length;for(;n--;){const i=e[n],r=t[i];e[n]=[i,r,yo(r)]}return e}(t);return 1===e.length&&e[0][2]?bo(e[0][0],e[0][1]):n=>n===t||function(t,e,n,i){let r=n.length;const o=r;if(null==t)return!o;let s,a;for(t=Object(t);r--;)if(s=n[r],s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1;for(;++r<o;){s=n[r];const e=s[0],i=t[e],o=s[1];if(s[2]){if(void 0===i&&!(e in t))return!1}else{const t=new Oo;if(!(void 0===a?Vr(o,i,t):a))return!1}}return!0}(n,0,e)}function Ao(t){return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(e=t[0],n=t[1],Yr(e)&&yo(n)?bo(Qr(e),n):t=>{const i=Zr(t,e);return void 0===i&&i===n?wo(t,e):Vr(n,i)}):xo(t):function(t){return Yr(t)?(e=Qr(t),t=>null==t?void 0:t[e]):function(t){return e=>Zr(e,t)}(t);var e}(t);var e,n}function Eo(){const t=Ao;return arguments.length?t(arguments[0],arguments[1]):t}const To=(t,e,n,i)=>{let r=-1;const o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},So=(t,e,n,i,r)=>(r(t,((t,r,o)=>{n=i?(i=!1,t):e(n,t,r,o)})),n),_o=t=>Array.isArray(t)||ko(t)||!(!t||!t[Symbol.isConcatSpreadable]);function Po(t,e,n,i,r){let o=-1;const s=t.length;for(n||(n=_o),r||(r=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?Po(a,e-1,n,i,r):r.push(...a):i||(r[r.length]=a)}return r}const ko=t=>xr(t)&&"[object Arguments]"==Cr(t),Co=(t,e)=>null!=t&&e in Object(t),Lo=(t,e,n)=>{for(var i,r=-1,o=(e=Xr(e,t)).length,s=!1;++r<o;){var a=Qr(e[r]);if(!(s=null!=t&&n(t,a)))break;t=t[a]}return s||++r!=o?s:!!(o=null==t?0:t.length)&&"number"==typeof(i=o)&&i>-1&&i%1==0&&i<=Number.MAX_SAFE_INTEGER&&ro(a,o)&&(Array.isArray(t)||ko(t))},Mo=("toUpperCase",t=>{if(!t)return"";const e=pr(t)?gr(t):void 0,n=e?e[0]:t[0],i=e?((t,e,n)=>{const{length:i}=t;return n=void 0===n?i:n,t.slice(1,n)})(e).join(""):t.slice(1);return n.toUpperCase()+i});class Oo{constructor(t){const e=this.__data__=new No(t);this.size=e.size}clear(){this.__data__=new No,this.size=0}delete(t){const e=this.__data__,n=e.delete(t);return this.size=e.size,n}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof No){const i=n.__data__;if(i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Ro(i)}return n.set(t,e),this.size=n.size,this}}class No{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=[],this.size=0}delete(t){const e=this.__data__,n=br(e,t);return!(n<0)&&(n==e.length-1?e.pop():e.splice(n,1),--this.size,!0)}get(t){const e=this.__data__,n=br(e,t);return n<0?void 0:e[n][1]}has(t){return br(this.__data__,t)>-1}set(t,e){const n=this.__data__,i=br(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class Ro{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.size=0,this.__data__={hash:new Fo,map:new Map,string:new Fo}}delete(t){const e=Dr(this,t).delete(t);return this.size-=e?1:0,e}get(t){return Dr(this,t).get(t)}has(t){return Dr(this,t).has(t)}set(t,e){const n=Dr(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Fo{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){const e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}get(t){const e=this.__data__[t];return e===nr?void 0:e}has(t){return void 0!==this.__data__[t]}set(t,e){const n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?nr:e,this}}class Io{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.__data__=new Ro;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,nr),this}has(t){return this.__data__.has(t)}}Io.prototype.push=Io.prototype.add;const Bo=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},Do=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===di},Vo=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===mi},$o=co(((t,e)=>{if(Er(e)||_r(e))Sr(e,vr(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&Tr(t,n,e[n])})),zo=(t,...e)=>{let n=-1,i=e.length;const r=i>2?e[2]:void 0;for(r&&Ar(e[0],e[1],r)&&(i=1);++n<i;){const i=e[n];if(null==i)continue;const r=Object.keys(i),o=r.length;let s=-1;for(;++s<o;){const e=r[s],n=t[e];(void 0===n||wr(n,Object.prototype[e])&&!hasOwnProperty.call(t,e))&&(t[e]=i[e])}}return t},jo=function(...t){return t.push(void 0,mo),fs.apply(void 0,t)},Uo=(t,e,...n)=>{let i=-1;const r="function"==typeof e,o=_r(t)?new Array(t.length):[];return po(t,(t=>{o[++i]=r?e.apply(t,n):Go(t,e,...n)})),o},Go=(t,e,...n)=>{e=Xr(e,t);const i=null==(t=no(t,e))?t:t[Qr(function(t){const e=null==t?0:t.length;return e?t[e-1]:void 0}(e))];return null==i?void 0:i.apply(t,n)},Ho=(t,e,n)=>{let i=0,r=null==t?0:t.length;if(0==r)return 0;const o=(e=(n=Eo(n,2))(e))!=e,s=null===e,a=Pr(e),l=void 0===e;for(;i<r;){let c;const h=Math.floor((i+r)/2),u=n(t[h]),d=void 0!==u,f=null===u,p=u==u,g=Pr(u);c=o?p:l?p&&d:s?p&&d&&!f:a?p&&d&&!f&&!g:!f&&!g&&u<e,c?i=h+1:r=h}return Math.min(r,4294967294)},qo=(t,e)=>{let n=-1,i=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1;e=Eo(e,2);let r=!0;const{length:o}=t,s=[];let a=s;if(o>=200){const n=e?null:go(t);if(n)return Wr(n);r=!1,i=(t,e)=>t.has(e),a=new Io}else a=e?[]:s;t:for(;++n<o;){let o=t[n];const l=e?e(o):o;if(o=0!==o?o:0,r&&l==l){let t=a.length;for(;t--;)if(a[t]===l)continue t;e&&a.push(l),s.push(o)}else i(a,l)||(a!==s&&a.push(l),s.push(o))}return s},Wo=t=>to(t),Yo=t=>to(t,!0),Xo=t=>{if(null==t)return!0;if(_r(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Rr(t)||ko(t)))return!t.length;const e=Cr(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Er(t))return!(t=>{if(!Er(t))return Object.keys(t);var e=[];for(var n in Object(t))hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e})(t).length;for(const e in t)if(hasOwnProperty.call(t,e))return!1;return!0},Zo=(t,e)=>Vr(t,e),Ko=t=>"function"==typeof t,Jo=t=>{if(!xr(t)||"[object Object]"!=Cr(t))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},Qo=t=>{if(!t)return[];if(_r(t))return Vo(t)?gr(t):kr(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){const e=t[Symbol.iterator]();let n;const i=[];for(;!(n=e.next()).done;)i.push(n.value);return i}const e=Cr(t);return(e==ui?qr:e==gi?Wr:mr)(t)},ts=(t,e=[])=>{if(null==t)return[];const n=e.length;return n>1&&Ar(t,e[0],e[1])?e=[]:n>2&&Ar(e[0],e[1],e[2])&&(e=[e[0]]),Array.isArray(e)||(e=[Eo(e,2)]),vo(t,e.flat(1),[])},es=t=>null!=t&&t.length?Po(t,1/0):[],ns=(t,...e)=>_r(t)?Jr(t,e):[],is=(t,...e)=>xr(t)&&_r(t)?Jr(t,e.flat(1)):[],rs=(...t)=>{const e=t.flat(1);return qo(e)},os=(t,e)=>{if(null==t)return!1;"string"==typeof e&&(e=e.split("."));let n=-1,i=t;for(;++n<e.length;){if(!i||!hasOwnProperty.call(i,e[n]))return!1;i=i[e[n]]}return!0},ss=(t,e,n)=>{let i=-1,r=(e=Xr(e,t)).length;for(r||(r=1,t=void 0);++i<r;){let o=null==t?void 0:t[Qr(e[i])];void 0===o&&(i=r,o=n),t="function"==typeof o?o.call(t):o}return t},as=(t,...e)=>{let n={};if(null==t)return n;let i=!1;e=e.flat(1).map((e=>(e=Xr(e,t),i||(i=e.length>1),e))),Sr(t,Br(t),n),i&&(n=to(n,!0,!0,!0,(t=>Jo(t)?void 0:t)));let r=e.length;for(;r--;)oo(n,e[r]);return n},ls=(t,...e)=>null==t?{}:((t,e)=>((t,e,n)=>{let i=-1;const r=e.length,o={};for(;++i<r;){const r=e[i],s=Zr(t,r);n(s,r)&&io(o,Xr(r,t),s)}return o})(t,e,((e,n)=>wo(t,n))))(t,e.flat(1/0)),cs=(t,e=(t=>t))=>{let n=-1;const i=Object(t),r=_r(t)?yr(t,!0):ao(t);let o=r.length;for(;o--;){const t=r[++n];if(!1===e(i[t],t,i))break}},hs=(t="")=>((t,e)=>{if(void 0===e){const e=dr(t)?(t=>t.match(er))(t):(t=>t.match(fr))(t);return e||[]}return t.match(e)||[]})(`${t}`.replace(/['\u2019]/g,"")).reduce(((t,e,n)=>(e=e.toLowerCase(),t+(n?Mo(e):e))),"");let us=0;const ds=(t="")=>`${t}`+ ++us,fs=co(((t,e,n,i)=>{ho(t,e,n,i)}),!0),ps=class{constructor(){this.map=new WeakMap}has(t,e){return void 0===e?this.map.has(t):e in this.map.get(t)}create(t){return this.has(t)||this.map.set(t,Object.create(null)),this.get(t)}get(t,e){if(!this.has(t))return;const n=this.map.get(t);return void 0===e?n:n[e]}set(t,e,n){if(void 0===e)return;const i=this.create(t);"string"==typeof e?i[e]=n:Object.assign(i,e)}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}},gs=new ps,ms=new ps,vs=function(t,e){if(!(this instanceof vs))return new vs(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?ys:bs,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&Object.assign(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this.envelope=!0};function ys(){return!0}function bs(){return!1}vs.prototype={constructor:vs,isDefaultPrevented:bs,isPropagationStopped:bs,isImmediatePropagationStopped:bs,preventDefault:function(){const t=this.originalEvent;this.isDefaultPrevented=ys,t&&t.preventDefault()},stopPropagation:function(){const t=this.originalEvent;this.isPropagationStopped=ys,t&&t.stopPropagation()},stopImmediatePropagation:function(){const t=this.originalEvent;this.isImmediatePropagationStopped=ys,t&&t.stopImmediatePropagation(),this.stopPropagation()}},["altKey","bubbles","cancelable","changedTouches","ctrlKey","detail","eventPhase","metaKey","pageX","pageY","shiftKey","view","char","code","charCode","key","keyCode","button","buttons","clientX","clientY","offsetX","offsetY","pointerId","pointerType","screenX","screenY","targetTouches","toElement","touches","which"].forEach((t=>function(t){Object.defineProperty(vs.prototype,t,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[t]:void 0},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})}(t)));const ws="undefined"!=typeof window?window.document:null,xs=ws&&ws.documentElement,As=/^([^.]*)(?:\.(.+)|)/,Es=/[^\x20\t\r\n\f]+/g,Ts=function(t){return new Ts.Dom(t)};Ts.fn=Ts.prototype={constructor:Ts,length:0},Ts.guid=1,Ts.data=ms,Ts.merge=function(t,e){let n=+e.length,i=t.length;for(let r=0;r<n;r++)t[i++]=e[r];return t.length=i,t},Ts.parseHTML=function(t){const e=ws.implementation.createHTMLDocument(),n=e.createElement("base");n.href=ws.location.href,e.head.appendChild(n),e.body.innerHTML=t;const i=e.getElementsByTagName("script");for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(Ts.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),Ts.fn.toArray=function(){return Array.from(this)},Ts.fn.pushStack=function(t){const e=Ts.merge(this.constructor(),t);return e.prevObject=this,e},Ts.fn.find=function(t){const[e]=this,n=this.pushStack([]);if(!e)return n;const{nodeType:i}=e;return 1!==i&&9!==i&&11!==i||("string"!=typeof t?e!==t&&e.contains(t)&&Ts.merge(n,[t]):Ts.merge(n,e.querySelectorAll(t))),n},Ts.fn.add=function(t,e){const n=Ts(t,e).toArray(),i=this.toArray(),r=this.pushStack([]);return Ts.merge(r,qo(i.concat(n))),r},Ts.fn.addBack=function(){return this.add(this.prevObject)},Ts.fn.filter=function(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];i.matches(t)&&e.push(i)}return this.pushStack(e)};const Ss=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,_s=function(t){if(!t)return this;if("function"==typeof t)throw new Error("function not supported");if(arguments.length>1)throw new Error("selector with context not supported");if(t.nodeType)return this[0]=t,this.length=1,this;let e;if("<"===(n=t+"")[0]&&">"===n[n.length-1]&&n.length>=3)e=[null,t,null];else{if("string"!=typeof t)return Ts.merge(this,t);e=Ss.exec(t)}var n;if(!e||!e[1])return Ps.find(t);if(e[1])return Ts.merge(this,Ts.parseHTML(e[1])),this;const i=ws.getElementById(e[2]);return i&&(this[0]=i,this.length=1),this};Ts.Dom=_s,_s.prototype=Ts.fn,Ts.Event=vs,Ts.event={special:Object.create(null)},Ts.event.has=function(t,e){const n=gs.get(t,"events");return!!n&&(!e||Array.isArray(n[e])&&n[e].length>0)},Ts.event.on=function(t,e,n,i,r,o){if("object"==typeof e){"string"!=typeof n&&(i=i||n,n=void 0);for(let r in e)Ts.event.on(t,r,n,i,e[r],o);return t}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!r)return t;if(1===o){const t=r;r=function(e){return Ts().off(e),t.apply(this,arguments)},r.guid=t.guid||(t.guid=Ts.guid++)}for(let o=0;o<t.length;o++)Ts.event.add(t[o],e,r,i,n)},Ts.event.add=function(t,e,n,i,r){if("object"!=typeof t)return;const o=gs.create(t);let s,a,l;n.handler&&(s=n,n=s.handler,r=s.selector),r&&xs.matches(r),n.guid||(n.guid=Ts.guid++),(a=o.events)||(a=o.events=Object.create(null)),(l=o.handle)||(l=o.handle=function(e){return void 0!==Ts?Ts.event.dispatch.apply(t,arguments):void 0});const c=(e||"").match(Es)||[""];let h=c.length;for(;h--;){const[,e,o=""]=As.exec(c[h]);if(!e)continue;const u=o.split(".").sort();let d=Ts.event.special[e];const f=d&&(r?d.delegateType:d.bindType)||e;d=Ts.event.special[f];const p=Object.assign({type:f,origType:e,data:i,handler:n,guid:n.guid,selector:r,namespace:u.join(".")},s);let g;(g=a[f])||(g=a[f]=[],g.delegateCount=0,d&&d.setup&&!1!==d.setup.call(t,i,u,l)||t.addEventListener&&t.addEventListener(f,l)),d&&d.add&&(d.add.call(t,p),p.handler.guid||(p.handler.guid=n.guid)),r?g.splice(g.delegateCount++,0,p):g.push(p)}},Ts.event.remove=function(t,e,n,i,r){const o=gs.get(t);if(!o||!o.events)return;const s=o.events,a=(e||"").match(Es)||[""];let l=a.length;for(;l--;){const[,e,c=""]=As.exec(a[l]);if(!e){for(const e in s)Ts.event.remove(t,e+a[l],n,i,!0);continue}const h=Ts.event.special[e],u=h&&(i?h.delegateType:h.bindType)||e,d=s[u];if(!d||0===d.length)continue;const f=c.split(".").sort(),p=c?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,g=d.length;let m=g;for(;m--;){const o=d[m];!r&&e!==o.origType||n&&n.guid!==o.guid||p&&!p.test(o.namespace)||i&&i!==o.selector&&("**"!==i||!o.selector)||(d.splice(m,1),o.selector&&d.delegateCount--,h&&h.remove&&h.remove.call(t,o))}g&&0===d.length&&(h&&h.teardown&&!1!==h.teardown.call(t,f,o.handle)||t.removeEventListener&&t.removeEventListener(u,o.handle),delete s[u])}Xo(s)&&(gs.remove(t,"handle"),gs.remove(t,"events"))},Ts.event.dispatch=function(t){const e=this,n=Ts.event.fix(t);n.delegateTarget=e;const i=Array.from(arguments);i[0]=n;const r=gs.get(e,"events"),o=r&&r[n.type]||[],s=Ts.event.special[n.type];if(s&&s.preDispatch&&!1===s.preDispatch.call(e,n))return;const a=Ts.event.handlers.call(e,n,o);let l,c=0;for(;(l=a[c++])&&!n.isPropagationStopped();){n.currentTarget=l.elem;let t,e=0;for(;(t=l.handlers[e++])&&!n.isImmediatePropagationStopped();){n.handleObj=t,n.data=t.data;const e=Ts.event.special[t.origType];let r;r=e&&e.handle?e.handle:t.handler;const o=r.apply(l.elem,i);void 0!==o&&!1===(n.result=o)&&(n.preventDefault(),n.stopPropagation())}}return s&&s.postDispatch&&s.postDispatch.call(e,n),n.result},Ts.event.handlers=function(t,e){const n=e.delegateCount,i=[];if(n&&!("click"===t.type&&t.button>=1))for(let r=t.target;r!==this;r=r.parentNode||this)if(1===r.nodeType&&("click"!==t.type||!0!==r.disabled)){const t=[],o={};for(let i=0;i<n;i++){const n=e[i],s=n.selector+" ";void 0===o[s]&&(o[s]=r.matches(s)),o[s]&&t.push(n)}t.length&&i.push({elem:r,handlers:t})}return n<e.length&&i.push({elem:this,handlers:e.slice(n)}),i},Ts.event.fix=function(t){return t.envelope?t:new vs(t)};const Ps=Ts(ws);function ks(t){let e=t.length;for(;e--;)Cs(t[e])}function Cs(t){Ts.event.remove(t),gs.remove(t),ms.remove(t)}function Ls(t){for(let e=0;e<t.length;e++){const n=t[e];n.parentNode&&n.parentNode.removeChild(n)}}function Ms(){for(let t=0;t<this.length;t++){const e=this[t];Cs(e),ks(e.getElementsByTagName("*"))}return Ls(this),this}function Os(){return Ls(this),this}function Ns(){for(let t=0;t<this.length;t++){const e=this[t];1===e.nodeType&&(ks(e.getElementsByTagName("*")),e.textContent="")}return this}function Rs(){const t=[];for(let e=0;e<this.length;e++)t.push(this[e].cloneNode(!0));return this.pushStack(t)}function Fs(t){const[e]=this;return e?0===arguments.length?e.innerHTML:void 0===t?this:(ks(gs,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t?(e.innerHTML="",this.append(t)):(e.innerHTML=t,this)):null}function Is(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.append(...Ts.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))})),this):this}function Bs(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.prepend(...Ts.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))})),this):this}function Ds(t){return Ts(t).append(this),this}function Vs(t){return Ts(t).prepend(this),this}const $s={};function zs(t,e,n){"number"==typeof n&&$s[hs(e)]&&(n+="px"),t.style[e]=n}function js(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.style[t]:null}n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let t in n)if(n.hasOwnProperty(t))for(let e=0;e<this.length;e++)zs(this[e],t,n[t]);return this}function Us(t,e){if(arguments.length<2){const[e]=this;return e?void 0===t?e.dataset:e.dataset[t]:null}for(let n=0;n<this.length;n++)this[n].dataset[t]=e;return this}function Gs(t,e,n){for(let i=0;i<e.length;i++){const r=e[i];ri.prototype[t].apply({node:r},n)}}function Hs(){return Gs("removeClass",this,arguments),this}function qs(){return Gs("addClass",this,arguments),this}function Ws(){return Gs("toggleClass",this,arguments),this}function Ys(){const[t]=this;return!!t&&ri.prototype.hasClass.apply({node:t},arguments)}function Xs(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];let r=Array.from(i.children);"string"==typeof t&&(r=r.filter((e=>e.matches(t)))),e.push(...r)}return this.pushStack(e)}function Zs(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];if("string"==typeof t){const n=i.closest(t);n&&e.push(n)}else{const[n]=Ts(t);n&&n.contains(i)&&e.push(n)}}return this.pushStack(e)}function Ks(t,e,n,i){return Ts.event.on(this,t,e,n,i),this}function Js(t,e,n,i){return Ts.event.on(this,t,e,n,i,1),this}function Qs(t,e,n){if(t&&t.preventDefault&&t.handleObj){const e=t.handleObj;return Ts(t.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this}if("object"==typeof t){for(let n in t)this.off(n,e,t[n]);return this}!1!==e&&"function"!=typeof e||(n=e,e=void 0);for(let i=0;i<this.length;i++)Ts.event.remove(this[i],t,n,e);return this}function ta(){const[t]=this;if(t===window)return t.document.documentElement.clientWidth;if(!t)return;const e=window.getComputedStyle(t),n=t.offsetWidth,i=parseFloat(e.borderTopWidth);return n-parseFloat(e.borderBottomWidth)-i-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)}function ea(){const[t]=this;if(t===window)return t.document.documentElement.clientHeight;if(!t)return;const e=window.getComputedStyle(t);return t.offsetHeight-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}function na(){const[t]=this;if(!t)return;let e,n,i,r=Ts(t),o={top:0,left:0};if("fixed"===r.css("position"))n=t.getBoundingClientRect();else{n=r.offset(),i=t.ownerDocument,e=t.offsetParent||i.documentElement;const s=Ts(e),a=s.css("position")||"static";for(;e&&(e===i.body||e===i.documentElement)&&"static"===a;)e=e.parentNode;if(e&&e!==t&&1===e.nodeType){const t=window.getComputedStyle(e),n=parseFloat(t.borderTopWidth)||0,i=parseFloat(t.borderLeftWidth)||0;o=s.offset(),o.top+=n,o.left+=i}}const s=parseFloat(window.getComputedStyle(t).marginTop)||0,a=parseFloat(window.getComputedStyle(t).marginLeft)||0;return{top:n.top-o.top-s,left:n.left-o.left-a}}function ia(t){const[e]=this;if(void 0===t){if(!e)return null;if(!e.getClientRects().length)return{top:0,left:0};const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}if(!e)return this;const n=window.getComputedStyle(e);"static"===n.position&&this.css("position","relative");const i=this.offset(),r=t.top-i.top,o=t.left-i.left;return this.css({top:(parseFloat(n.top)||0)+r+"px",left:(parseFloat(n.left)||0)+o+"px"}),this}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach((t=>{$s[t]=!0}));const ra="animationFrameId",oa={};function sa(t,e={}){this.stop();for(let n=0;n<this.length;n++)aa(this[n],t,e);return this}function aa(t,e,n={}){let{duration:i=400,easing:r="ease-in-out",delay:o=0,complete:s}=n;const a=setTimeout((function(){const n=Ts(t);let a=!1,l="transitionend";i/=1e3,o/=1e3;const c={};if("string"==typeof e)c["animation-name"]=e,c["animation-duration"]=i+"s",c["animation-delay"]=o+"s",c["animation-timing-function"]=r,l="animationend";else{const t=[];for(var h in e)e.hasOwnProperty(h)&&(c[h]=e[h],t.push(h));i>0&&(c["transition-property"]=t.join(", "),c["transition-duration"]=i+"s",c["transition-delay"]=o+"s",c["transition-timing-function"]=r)}const u=function(e){if(e){if(e.target!==e.currentTarget)return;e.target.removeEventListener(l,u)}else t.removeEventListener(l,u);a=!0,n.css(oa),s&&s.call(t)};if(i>0){t.addEventListener(l,u);const e=setTimeout((function(){a||u(null)}),1e3*(i+o)+25);gs.set(t,ra,{id:e,stop:()=>{clearTimeout(e),t.removeEventListener(l,u)}})}n.css(c),i<=0&&u(null)}));gs.set(t,ra,{stop:()=>clearTimeout(a)})}function la(){for(let t=0;t<this.length;t++){const e=this[t],n=gs.get(e,ra);n&&(n.stop(),gs.remove(e,ra))}return this.css(oa),this}oa["transition-property"]=oa["transition-duration"]=oa["transition-delay"]=oa["transition-timing-function"]=oa["animation-name"]=oa["animation-duration"]=oa["animation-delay"]=oa["animation-timing-function"]="";const ca={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},ha={disabled:"disabled",value:"value",text:"textContent"},ua={prop:function(t,e){if(!t)throw new Error("no property provided");if(1===arguments.length){const[e]=this;return e?e[t]:null}if(void 0===e)return this;for(let n=0;n<this.length;n++)this[n][t]=e;return this},attr:function(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.getAttribute(t):null}n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(let t in n)if(n.hasOwnProperty(t)){const e=n[t];if(ha[t]){this.prop(ha[t],e);continue}for(let n=0;n<this.length;n++)null===e?this[n].removeAttribute(t):this[n].setAttribute(t,e)}return this}};Object.keys(ca).forEach((t=>{ua[t]=function(...e){return this.prop(ca[t],...e)}}));const da=ua,fa="joint-",pa=Object.create(null),ga=pa;pa.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach((([t,e])=>{pa[t]={delegateType:e,bindType:e,handle:function(t){const n=t.relatedTarget,i=t.handleObj;let r;return n&&this.contains(n)||(t.type=i.origType,r=i.handler.apply(this,arguments),t.type=e),r}}}));pa.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t,...e){const{handleObj:n,target:i}=t,r=Ts.data.create(i),o=(new Date).getTime(),s="lastTouch"in r?o-r.lastTouch:0;s<300&&s>30?(r.lastTouch=null,t.type=n.origType,n.handler.call(this,t,...e)):r.lastTouch=o}},Object.assign(Ts.fn,r),Object.assign(Ts.fn,o),Object.assign(Ts.fn,da),Object.assign(Ts.event.special,ga);const ma=Ts,va=function(t){return t?t.toString().split(" ").map((function(t){return t.substr(0,6)!==fa&&(t=fa+t),t})).join(" "):t},ya=function(t,e){const n={},i={},r=ri.namespace.svg,o=e||r,s=document.createDocumentFragment(),a=function(t,e,o){for(let s=0;s<t.length;s++){const l=t[s];if("string"==typeof l){const t=document.createTextNode(l);e.appendChild(t);continue}if(!l.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");const c=l.tagName;let h;l.hasOwnProperty("namespaceURI")&&(o=l.namespaceURI),h=document.createElementNS(o,c);const u=o===r,d=u?ri(h):ma(h),f=l.attributes;f&&d.attr(f);const p=l.style;if(p&&ma(h).css(p),l.hasOwnProperty("className")){const t=l.className;u?h.className.baseVal=t:h.className=t}if(l.hasOwnProperty("textContent")&&(h.textContent=l.textContent),l.hasOwnProperty("selector")){const t=l.selector;if(n[t])throw new Error("json-dom-parser: selector must be unique");n[t]=h,d.attr("joint-selector",t)}if(l.hasOwnProperty("groupSelector")){let t=l.groupSelector;Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;e++){const n=t[e];let r=i[n];r||(r=i[n]=[]),r.push(h)}}e.appendChild(h);const g=l.children;Array.isArray(g)&&a(g,h,o)}};return a(t,s,o),{fragment:s,selectors:n,groupSelectors:i}},ba=function(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e},wa=function(t,e,n){for(var i,r=Array.isArray(e)?e:e.split(n||"/"),o=0,s=r.length;o<s;){if(i=r[o++],Object(t)!==t||!(i in t))return;t=t[i]}return t},xa=function(t,e){return"string"!=typeof e&&"number"!=typeof e&&(e=String(e)),("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!==e},Aa=function(t,e,n,i){const r=Array.isArray(e)?e:e.split(i||"/"),o=r.length-1;let s=t,a=0;for(;a<o;a++){const e=r[a];if(!xa(s,e))return t;s=s[e]||(s[e]={})}return s[r[o]]=n,t},Ea=function(t,e,n){const i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){const e=i[s];if(!xa(o,e))return t;const n=o[e];if(!n)return t;o=n}return delete o[i[r]],t},Ta=function(t){return Ta.id=Ta.id||1,void 0===t?"j_"+Ta.id++:(t.id=void 0===t.id?"j_"+Ta.id++:t.id,t.id)},Sa=function(t){if(t.normalized)return t;const{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(let e in i)void 0===t[e]&&(t[e]=i[e]);if(n){const e=n.correspondingUseElement;e&&(t.target=e)}return t.normalized=!0,t},_a=function(){var t;if("undefined"!=typeof window&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!t){var e=0;t=function(t){var n=(new Date).getTime(),i=Math.max(0,16-(n-e)),r=setTimeout((function(){t(n+i)}),i);return e=n+i,r}}return function(e,n,...i){return t(void 0!==n?e.bind(n,...i):e)}}(),Pa=((Ca="undefined"!=typeof window)&&(ka=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),ka=ka||clearTimeout,Ca?ka.bind(window):ka);var ka,Ca;const La=function(t){return Vo(t)&&"%"===t.slice(-1)},Ma=function(t,e){var n=parseFloat(t);if(Number.isNaN(n))return null;var i,r={};if(r.value=n,null==e)i="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;i=e.join("|")}else Vo(e)&&(i=e);var o=function(e){var n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+e+")$").exec(t);return n?n[1]:null}(i);return null===o?null:(r.unit=o,r)};function Oa(t,e){const n=t.split(e);let i=1;for(let t=0,r=n.length-1;t<r;t++){const o=[];(t>0||""!==n[0])&&o.push(0),o.push(e),(t<r-1||""!==n[r])&&o.push(0),n.splice(i,0,...o),i+=o.length+1}return n.filter((t=>""!==t))}function Na(t,e){if(null===t)return e.getBBox().height;switch(t.unit){case"em":return e.getBBox().height*t.value;case"px":case"":return t.value}}const Ra=function(t,e,n={},i={}){var r=e.width,o=e.height,s=i.svgDocument||ri("svg").node,a=ri("tspan").node,l=ri("text").attr(n).append(a).node,c=document.createTextNode("");l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(c),s.appendChild(l),i.svgDocument||document.body.appendChild(s);const h=i.preserveSpaces,u=i.separator||""===i.separator?i.separator:" ",d="string"==typeof u?u:" ";var f=i.eol||"\n",p=i.hyphen?new RegExp(i.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=i.maxLineCount;Do(g)||(g=1/0);var m,v,y,b=t.split(u),w=[],x=[];h&&ri(a).attr("xml:space","preserve");for(var A=0,E=0,T=b.length;A<T;A++){var S=b[A];if((S||h)&&"string"==typeof S){var _=!1;if(f&&S.indexOf(f)>=0){if(S.length>1){const t=Oa(b[A],f);b.splice(A,1,...t),A--,T=b.length;continue}if(h&&"string"==typeof b[A-1]){b.splice(A,0,"",0),T+=2,A--;continue}x[++E]=h&&"string"!=typeof b[A+1]?void 0:"",_=!0}if(!_){let t;if(t=h?void 0!==x[E]?x[E]+d+S:S:x[E]?x[E]+d+S:S,c.data=t,a.getComputedTextLength()<=r)x[E]=t,(m||v)&&(w[E++]=!0,m=0,v=0);else{if(!x[E]||m){var P=!!m;if(m=S.length-1,P||!m){if(!m){if(!x[E]){x=[];break}b.splice(A,2,S+b[A+1]),T--,w[E++]=!0,A--;continue}b[A]=S.substring(0,m);const t=b[A+1];b[A+1]=S.substring(m)+(void 0===t||0===t?"":t)}else{if(v)b.splice(A,2,b[A]+b[A+1]),v=0;else{var k=S.search(p);k>-1&&k!==S.length-1&&0!==k&&(v=k+1,m=0),b.splice(A,1,S.substring(0,v||m),S.substring(v||m)),T++}E&&!w[E-1]&&E--}h&&""===x[E]||A--;continue}E++,A--}}var C=null;if(x.length>g?C=g-1:void 0!==o&&(void 0===y&&""!==c.data&&(y="auto"===n.lineHeight?Na({value:1.5,unit:"em"},l):Na(Ma(n.lineHeight,["em","px",""]),l)),y*x.length>o&&(C=Math.floor(o/y)-1)),null!==C){x.splice(C+1);var L=i.ellipsis;if(!L||C<0)break;"string"!=typeof L&&(L="…");var M=x[C];if(!M&&!_)break;var O,N,R=M.length;do{if(N=M[R],O=M.substring(0,R),N?N.match(u)&&(O+=N):O+=d,O+=L,c.data=O,a.getComputedTextLength()<=r){x[C]=O;break}R--}while(R>=0);break}}}return i.svgDocument?s.removeChild(l):document.body.removeChild(s),x.join(f)},Fa=function(t){if(Object(t)!==t){var e=0;return isFinite(t)&&(e=+t),{top:e,right:e,bottom:e,left:e}}var n,i,r,o;return n=i=r=o=0,isFinite(t.vertical)&&(n=r=+t.vertical),isFinite(t.horizontal)&&(i=o=+t.horizontal),isFinite(t.top)&&(n=+t.top),isFinite(t.right)&&(i=+t.right),isFinite(t.bottom)&&(r=+t.bottom),isFinite(t.left)&&(o=+t.left),{top:n,right:i,bottom:r,left:o}},Ia={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11){var i=(11-6*e-11*t)/4;return-i*i+n*n}},reverse:function(t){return function(e){return 1-t(1-e)}},reflect:function(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}},clamp:function(t,e,n){return e=e||0,n=n||1,function(i){var r=t(i);return r<e?e:r>n?n:r}},back:function(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}},elastic:function(t){return t||(t=1.5),function(e){return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*t/3*e)}}},Ba={number:function(t,e){var n=e-t;return function(e){return t+n*e}},object:function(t,e){var n=Object.keys(t);return function(i){var r,o,s={};for(r=n.length-1;-1!=r;r--)s[o=n[r]]=t[o]+(e[o]-t[o])*i;return s}},hexColor:function(t,e){var n=parseInt(t.slice(1),16),i=parseInt(e.slice(1),16),r=255&n,o=(255&i)-r,s=65280&n,a=(65280&i)-s,l=16711680&n,c=(16711680&i)-l;return function(t){return"#"+(1<<24|r+o*t&255|s+a*t&65280|l+c*t&16711680).toString(16).slice(1)}},unit:function(t,e){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(t),r=n.exec(e),o=r[1].indexOf("."),s=o>0?r[1].length-o-1:0;t=+i[1];var a=+r[1]-t,l=i[2];return function(e){return(t+a*e).toFixed(s)+l}}},Da={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return Va('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology in="SourceAlpha" result="morphedOuter" operator="dilate" radius="${outerRadius}" /><feMorphology in="SourceAlpha" result="morphedInner" operator="dilate" radius="${innerRadius}" /><feComposite result="morphedOuterColored" in="colored" in2="morphedOuter" operator="in"/><feComposite operator="xor" in="morphedOuterColored" in2="morphedInner" result="outline"/><feMerge><feMergeNode in="outline"/><feMergeNode in="SourceGraphic"/></feMerge></filter>')({color:t.color||"blue",opacity:Number.isFinite(t.opacity)?t.opacity:1,outerRadius:e+n,innerRadius:e})},highlight:function(t){return Va('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology result="morphed" in="SourceGraphic" operator="dilate" radius="${width}"/><feComposite result="composed" in="colored" in2="morphed" operator="in"/><feGaussianBlur result="blured" in="composed" stdDeviation="${blur}"/><feBlend in="SourceGraphic" in2="blured" mode="normal"/></filter>')({color:t.color||"red",width:Number.isFinite(t.width)?t.width:1,blur:Number.isFinite(t.blur)?t.blur:0,opacity:Number.isFinite(t.opacity)?t.opacity:1})},blur:function(t){var e=Number.isFinite(t.x)?t.x:2;return Va('<filter><feGaussianBlur stdDeviation="${stdDeviation}"/></filter>')({stdDeviation:Number.isFinite(t.y)?[e,t.y]:e})},dropShadow:function(t){var e="SVGFEDropShadowElement"in window?'<filter><feDropShadow stdDeviation="${blur}" dx="${dx}" dy="${dy}" flood-color="${color}" flood-opacity="${opacity}"/></filter>':'<filter><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${dx}" dy="${dy}" result="offsetblur"/><feFlood flood-color="${color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="${opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge></filter>';return Va(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return Va('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},sepia:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return Va('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},saturate:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return Va('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-e})},hueRotate:function(t){return Va('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return Va('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:1-e})},brightness:function(t){return Va('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return Va('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:.5-e/2})}},Va=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(n){return n=n||{},t.replace(e,(function(t){for(var e=Array.from(arguments).slice(1,4).find((function(t){return!!t})).split("."),i=n[e.shift()];void 0!==i&&e.length;)i=i[e.shift()];return void 0!==i?i:""}))}};var $a,za={},ja=/\s+/,Ua=function(t,e,n,i,r){var o,s=0;if(n&&"object"==typeof n){void 0!==i&&"context"in r&&void 0===r.context&&(r.context=i);for(o=Object.keys(n);s<o.length;s++)e=Ua(t,e,o[s],n[o[s]],r)}else if(n&&ja.test(n))for(o=n.split(ja);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e};za.on=function(t,e,n){return this._events=Ua(Ga,this._events||{},t,e,{context:n,ctx:this,listening:$a}),$a&&((this._listeners||(this._listeners={}))[$a.id]=$a,$a.interop=!1),this},za.listenTo=function(t,e,n){if(!t)return this;var i=t._listenId||(t._listenId=ds("l")),r=this._listeningTo||(this._listeningTo={}),o=$a=r[i];o||(this._listenId||(this._listenId=ds("l")),o=$a=r[i]=new Ka(this,t));var s=Ha(t,e,n,this);if($a=void 0,s)throw s;return o.interop&&o.on(e,n),this};var Ga=function(t,e,n,i){if(n){var r=t[e]||(t[e]=[]),o=i.context,s=i.ctx,a=i.listening;a&&a.count++,r.push({callback:n,context:o,ctx:o||s,listening:a})}return t},Ha=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}};za.off=function(t,e,n){return this._events?(this._events=Ua(qa,this._events,t,e,{context:n,listeners:this._listeners}),this):this},za.stopListening=function(t,e,n){var i=this._listeningTo;if(!i)return this;for(var r=t?[t._listenId]:Object.keys(i),o=0;o<r.length;o++){var s=i[r[o]];if(!s)break;s.obj.off(e,n,this),s.interop&&s.off(e,n)}return Xo(i)&&(this._listeningTo=void 0),this};var qa=function(t,e,n,i){if(t){var r,o=i.context,s=i.listeners,a=0;if(e||o||n){for(r=e?[e]:Object.keys(t);a<r.length;a++){var l=t[e=r[a]];if(!l)break;for(var c=[],h=0;h<l.length;h++){var u=l[h];if(n&&n!==u.callback&&n!==u.callback._callback||o&&o!==u.context)c.push(u);else{var d=u.listening;d&&d.off(e,n)}}c.length?t[e]=c:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}};za.once=function(t,e,n){var i=Ua(Wa,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(i,e,n)},za.listenToOnce=function(t,e,n){var i=Ua(Wa,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,i)};var Wa=function(t,e,n,i){if(n){var r=t[e]=Ya((function(){i(e,r),n.apply(this,arguments)}));r._callback=n}return t},Ya=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}};za.trigger=function(t){if(!this._events)return this;for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];return Ua(Xa,this._events,t,void 0,n),this};var Xa=function(t,e,n,i){if(t){var r=t[e],o=t.all;r&&o&&(o=o.slice()),r&&Za(r,i),o&&Za(o,[e].concat(i))}return t},Za=function(t,e){var n,i=-1,r=t.length,o=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++i<r;)(n=t[i]).callback.call(n.ctx);return;case 1:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o);return;case 2:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s);return;case 3:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s,a);return;default:for(;++i<r;)(n=t[i]).callback.apply(n.ctx,e);return}},Ka=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};Ka.prototype.on=za.on,Ka.prototype.off=function(t,e){var n;this.interop?(this._events=Ua(qa,this._events,t,e,{context:void 0,listeners:void 0}),n=!this._events):(this.count--,n=0===this.count),n&&this.cleanup()},Ka.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},za.bind=za.on,za.unbind=za.off;var Ja=function(t,e){var n,i=this;return n=t&&os(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)},$o(n,i,e),n.prototype=Object.assign(Object.create(i.prototype),t),n.prototype.constructor=n,n.__super__=i.prototype,n},Qa=function(t,e){return Ko(t)?t:Bo(t)&&!e._isModel(t)?tl(t):Vo(t)?function(e){return e.get(t)}:t},tl=function(t){var e=xo(to(t,!0));return function(t){return e(t.attributes)}},el=function(t,e){var n=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=ds(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection);var i=ss(this,"defaults");n=zo($o({},i,n),i),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};function nl(t){t=qo(t);const e=Qo(t).reduce((function(t,e){return t[e.id]=e.clone(),t}),{});return Qo(t).forEach((function(t){const n=e[t.id];if(n.isLink()){const t=n.source(),i=n.target();t.id&&e[t.id]&&n.prop("source/id",e[t.id].id),i.id&&e[i.id]&&n.prop("target/id",e[i.id].id)}const i=t.get("parent");i&&e[i]&&n.set("parent",e[i].id);const r=Qo(t.get("embeds")).reduce((function(t,n){return e[n]&&t.push(e[n].id),t}),[]);Xo(r)||n.set("embeds",r)})),e}$o(el.prototype,za,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return Wo(this.attributes)},get:function(t){return this.attributes[t]},has:function(t){return null!=this.get(t)},set:function(t,e,n){if(null==t)return this;var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;var r=n.unset,o=n.silent,s=[],a=this._changing;this._changing=!0,a||(this._previousAttributes=Wo(this.attributes),this.changed={});var l=this.attributes,c=this.changed,h=this._previousAttributes;for(var u in i)e=i[u],Zo(l[u],e)||s.push(u),Zo(h[u],e)?delete c[u]:c[u]=e,r?delete l[u]:l[u]=e;if(this.idAttribute in i){var d=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,d,n)}if(!o){s.length&&(this._pending=n);for(var f=0;f<s.length;f++)this.trigger("change:"+s[f],this,l[s[f]],n)}if(a)return this;if(!o)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,$o({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,$o({},t,{unset:!0}))},hasChanged:function(t){return null==t?!Xo(this.changed):os(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&Wo(this.changed);var e,n=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var o=t[r];Zo(n[r],o)||(i[r]=o,e=!0)}return!!e&&i},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return Wo(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},$o({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=$o({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return!n||(this.trigger("invalid",this,n,$o(e,{validationError:n})),!1)}}),el.extend=Ja;const il=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce(((t,e)=>(t[e]=!0,t)),{}),rl={qualify:function(t){return Jo(t)},set:function(t,e,n){Object.keys(t).forEach((function(e){if(il[e]&&e in n){const i=t[e];"SELECT"===n.tagName&&Array.isArray(i)?Array.from(n.options).forEach((function(t,e){t.selected=i.includes(t.value)})):n[e]=i}}))}};function ol(t,e,n){return function(i,r){var o,s=La(i);if(i=parseFloat(i),s&&(i/=100),isFinite(i)){var a=r[n]();o=s||i>0&&i<1?a[t]+r[e]*i:a[t]+i}var l=Re();return l[t]=o||0,l}}function sl(t,e){return function(n,i){var r=La(n);n=parseFloat(n),r&&(n/=100);var o={};if(isFinite(n)){var s=r||n>=0&&n<=1?n*i[e]:Math.max(n+i[e],0);o[t]=s}return o}}const al={"ref-x":{position:ol("x","width","origin")},"ref-y":{position:ol("y","height","origin")},"ref-dx":{position:ol("x","width","corner")},"ref-dy":{position:ol("y","height","corner")},"ref-width":{set:sl("width","width")},"ref-height":{set:sl("height","height")},"ref-rx":{set:sl("rx","width")},"ref-ry":{set:sl("ry","height")},"ref-cx":{set:sl("cx","width")},"ref-cy":{set:sl("cy","height")},"ref-r-inscribed":{set:(ll=sl("r","width"),cl=sl("r","height"),function(t,e){return(e.height>e.width?ll:cl)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n=La(t);t=parseFloat(t),n&&(t/=100);var i,r=Math.sqrt(e.height*e.height+e.width*e.width);return isFinite(t)&&(i=n||t>=0&&t<=1?t*r:Math.max(t+r,0)),{r:i}}}};var ll,cl;al.refX=al["ref-x"],al.refY=al["ref-y"],al["ref-x2"]=al["ref-x"],al["ref-y2"]=al["ref-y"],al["ref-width2"]=al["ref-width"],al["ref-height2"]=al["ref-height"],al["ref-r"]=al["ref-r-inscribed"];const hl=al,ul={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},dl=Object.keys(ul).map((t=>ul[t])).join(""),fl="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",pl=/\s/g,gl=new RegExp(`^(${fl}\\*)?([${dl}])(/${fl})?([-+]{1,2}${fl})?$`,"g");function ml(t){throw new Error(`Invalid calc() expression: ${t}`)}function vl(t,e){const n=gl.exec(t.replace(pl,""));n||ml(t),gl.lastIndex=0;const[,i,r,o,s]=n,{x:a,y:l,width:c,height:h}=e;let u=0;switch(r){case ul.width:u=c;break;case ul.height:u=h;break;case ul.x:u=a;break;case ul.y:u=l;break;case ul.minimum:u=Math.min(h,c);break;case ul.maximum:u=Math.max(h,c);break;case ul.diagonal:u=Math.sqrt(h*h+c*c)}return i&&(u*=parseFloat(i)),o&&(u/=parseFloat(o.slice(1))),s&&(u+=function(t){if(!t)return 0;const[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(s)),u}function yl(t){return"string"==typeof t&&t.includes("calc")}const bl="calc(",wl=bl.length;function xl(t,e){let n=t,i=0;for(;;){let t=n.indexOf(bl,i);if(-1===t)return n;let r=t+wl,o=1;t:for(;;){switch(n[r]){case"(":o++;break;case")":if(o--,0===o)break t;break;case void 0:ml(n)}r++}let s=n.slice(t+wl,r);yl(s)&&(s=xl(s,e));const a=String(vl(s,e));n=n.slice(0,t)+a+n.slice(r+1),i=t+a.length}}function Al(t,e,n){return void 0!==n.text}const El={"line-height":{qualify:Al},"text-vertical-anchor":{qualify:Al},"text-path":{qualify:Al},annotations:{qualify:Al},eol:{qualify:Al},"display-empty":{qualify:Al},text:{qualify:function(t,e,n){const i=n["text-wrap"];return!i||!Jo(i)},set:function(t,e,n,i){const r="joint-text",o=ma.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],c=i["font-size"],h=i.annotations,u=i.eol,d=i.x;let f=i["text-path"];const p=JSON.stringify([t,s,h,a,u,l,f,d,c]);if(void 0===o||o!==p){if(c&&n.setAttribute("font-size",c),Bo(f)){const t=f.selector;if("string"==typeof t){const e=this.findNode(t);e instanceof SVGPathElement&&(f=$o({"xlink:href":"#"+e.id},f))}}ri(n).text(""+t,{lineHeight:s,annotations:h,textPath:f,x:d,textVerticalAnchor:a,eol:u,displayEmpty:l}),ma.data.set(n,r,p)}}},"text-wrap":{qualify:Jo,set:function(t,e,n,i){var r={},o=t.width||0;La(o)?r.width=e.width*parseFloat(o)/100:yl(o)?r.width=Number(xl(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o;var s,a=t.height||0;La(a)?r.height=e.height*parseFloat(a)/100:yl(a)?r.height=Number(xl(a,e)):null===t.height||(r.height=a<=0?e.height+a:a);var l=t.text;void 0===l&&(l=i.text),s=void 0!==l?(t.breakText||Ra)(""+l,r,{"font-weight":i["font-weight"],"font-size":i["font-size"],"font-family":i["font-family"],lineHeight:i["line-height"],"letter-spacing":i["letter-spacing"]},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces}):"",El.text.set.call(this,s,e,n,i)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,n){var i="joint-title",r=ma.data.get(n,i);if(void 0===r||r!==t){if(ma.data.set(n,i,t),"title"===n.tagName)return void(n.textContent=t);var o=n.firstElementChild;if(o&&"title"===o.tagName)o.textContent=t;else{var s=document.createElementNS(n.namespaceURI,"title");s.textContent=t,n.insertBefore(s,o)}}}}},Tl=El;function Sl(t,e){var n=new Re(1,0);return function(i){var r,o,s=this[t](i);return s?(o=e.rotate?s.vector().vectorAngle(n):0,r=s.start):(r=this.path.start,o=0),0===o?{transform:"translate("+r.x+","+r.y+")"}:{transform:"translate("+r.x+","+r.y+") rotate("+o+")"}}}function _l(){return this.model.isLink()}const Pl={connection:{qualify:_l,set:function({stubs:t=0}){let e;if(isFinite(t)&&0!==t){let n;n=t<0?(this.getConnectionLength()+t)/2:t;const i=this.getConnection(),r=this.getConnectionSubdivisions(),o=i.divideAtLength(n,{segmentSubdivisions:r}),s=i.divideAtLength(-n,{segmentSubdivisions:r});o&&s&&(e=`${o[0].serialize()} ${s[1].serialize()}`)}return{d:e||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:_l,set:Sl("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:_l,set:Sl("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:_l,set:Sl("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:_l,set:Sl("getTangentAtRatio",{rotate:!1})}};Pl["at-connection-length"]=Pl["at-connection-length-keep-gradient"],Pl["at-connection-ratio"]=Pl["at-connection-ratio-keep-gradient"];const kl=Pl;function Cl(t,e){var n="joint-shape",i=e&&e.resetOffset;return function(e,r,o){var s=ma.data.get(o,n);if(!s||s.value!==e){var a=t(e);s={value:e,shape:a,shapeBBox:a.bbox()},ma.data.set(o,n,s)}var l=s.shape.clone(),c=s.shapeBBox.clone(),h=c.origin(),u=r.origin();c.x=u.x,c.y=u.y;var d=r.maxRectScaleToFit(c,u),f=0===c.width||0===r.width?1:d.sx,p=0===c.height||0===r.height?1:d.sy;return l.scale(f,p,h),i&&l.translate(-h.x,-h.y),l}}function Ll(t){var e=Cl((function(t){return new dn(ri.normalizePathData(t))}),t);return function(t,n,i){return{d:e(t,n,i).serialize()}}}function Ml(t){var e=Cl(rn,t);return function(t,n,i){return{points:e(t,n,i).serialize()}}}const Ol={"ref-d-reset-offset":{set:Ll({resetOffset:!0})},"ref-d-keep-offset":{set:Ll({resetOffset:!1})},"ref-points-reset-offset":{set:Ml({resetOffset:!0})},"ref-points-keep-offset":{set:Ml({resetOffset:!1})}};Ol["ref-d"]=Ol["ref-d-reset-offset"],Ol["ref-points"]=Ol["ref-points-reset-offset"];const Nl=Ol;function Rl(t){var e={},n=t.stroke;"string"==typeof n&&(e.stroke=n,e.fill=n);var i=t["stroke-opacity"];return void 0===i&&(i=t.opacity),void 0!==i&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Fl(t){const{paper:e}=this;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}const Il={"source-marker":{qualify:Jo,set:function(t,e,n,i){return t=$o(Rl(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:Jo,set:function(t,e,n,i){return t=$o(Rl(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:Jo,set:function(t,e,n,i){return t=$o(Rl(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:Jo,set:Fl},stroke:{qualify:Jo,set:Fl},filter:{qualify:Jo,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function Bl(t,e,n){return function(i,r){var o;o="middle"===i?r[e]/2:i===n?r[e]:isFinite(i)?i>-1&&i<1?-r[e]*i:-i:La(i)?r[e]*parseFloat(i)/100:0;var s=new Re;return s[t]=-(r[t]+o),s}}const Dl={"x-alignment":{offset:Bl("x","width","right")},"y-alignment":{offset:Bl("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function Vl(t){return function(e,n,i){const r=ri(i);r.attr(t)!==e&&r.attr(t,e)}}const $l={ref:{},href:{set:Vl("href")},"xlink:href":{set:Vl("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:Jo,set:function(t,e,n){ma(n).css(t)}},html:{set:function(t,e,n){ma(n).html(t+"")}},props:rl};$o($l,hl),$o($l,Tl),$o($l,kl),$o($l,Nl),$o($l,Il),$o($l,Dl);const zl=$l,jl=function(t,e){if(Array.isArray(t))return e},Ul=el.extend({constructor:function(t,e){var n,i=t||{};if("function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=ds("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(i=this.parse(i,e)||{}),n=ss(this,"defaults")){const t=(!e||!0!==e.mergeArrays)&&jl;i=fs({},n,i,t)}this.set(i,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(){const t=ss(this.constructor.prototype,"defaults").attrs||{},e=this.attributes.attrs,n={};cs(e,(function(e,i){const r=t[i];cs(e,(function(t,e){Bo(t)&&!Array.isArray(t)?cs(t,(function(t,o){r&&r[e]&&Zo(r[e][o],t)||(n[i]=n[i]||{},(n[i][e]||(n[i][e]={}))[o]=t)})):r&&Zo(r[e],t)||(n[i]=n[i]||{},n[i][e]=t)}))}));const i=Yo(as(this.attributes,"attrs"));return i.attrs=n,i},initialize:function(t){const e=this.getIdAttribute();t&&void 0!==t[e]||this.set(e,this.generateId(),{silent:!0}),this._transitionIds={},this._scheduledTransitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},getIdAttribute:function(){return this.idAttribute||"id"},generateId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},processPorts:function(){var t=this.ports,e={};cs(this.get("attrs"),(function(t,n){t&&t.port&&(void 0!==t.port.id?e[t.port.id]=t.port:e[t.port]={id:t.port})}));var n={};cs(t,(function(t,i){e[i]||(n[i]=!0)})),this.graph&&!Xo(n)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach((function(t){n[t.get("target").port]&&t.remove()})),this.graph.getConnectedLinks(this,{outbound:!0}).forEach((function(t){n[t.get("source").port]&&t.remove()}))),this.ports=e},remove:function(t={}){const{graph:e,collection:n}=this;if(!e)return n&&n.remove(this,t),this;e.startBatch("remove");const i=this.getParentCell();i&&i.unembed(this,t);const r=this.getEmbeddedCells();for(let e=0,n=r.length;e<n;e++){const n=r[e];n&&n.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(t){var e=this.graph;if(e){let n;(t=zo(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:ts(n,(t=>t.z()));let r=e.maxZIndex()-n.length+1;const o=e.get("cells");let s=o.toArray().indexOf(i[0])!==o.length-n.length;s||(s=i.some((function(t,e){return t.z()!==r+e}))),s&&(this.startBatch("to-front"),r+=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-front"))}return this},toBack:function(t){var e=this.graph;if(e){let n;(t=zo(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:ts(n,(t=>t.z()));let r=e.minZIndex(),o=0!==e.get("cells").toArray().indexOf(i[0]);o||(o=i.some((function(t,e){return t.z()!==r+e}))),o&&(this.startBatch("to-back"),r-=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-back"))}return this},parent:function(t,e){return void 0===t?this.get("parent"):this.set("parent",t,e)},embed:function(t,e){const n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(n.some((t=>t.isEmbedded()&&this.id!==t.parent())))throw new Error("Embedding of already embedded cells is not allowed.");return this._embedCells(n,e),this},unembed:function(t,e){const n=Array.isArray(t)?t:[t];return this._unembedCells(n,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every((t=>this!==t&&!this.isEmbeddedIn(t)))},_embedCells:function(t,e){const n="embed";this.startBatch(n);const i=$o([],this.get("embeds"));t.forEach((t=>{i[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)})),this.set("embeds",qo(i),e),this.stopBatch(n)},_unembedCells:function(t,e){const n="unembed";this.startBatch(n),t.forEach((t=>t.unset("parent",e))),this.set("embeds",ns(this.get("embeds"),...t.map((t=>t.id))),e),this.stopBatch(n)},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(!this.graph)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(t=t||{},!this.graph)return[];if(t.deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);const e=this.get("embeds");if(Xo(e))return[];let n=e.map(this.graph.getCell,this.graph);return t.sortSiblings&&(n=ts(n,(t=>t.z()))),n},_getEmbeddedCellsBfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.shift();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});n.push(...r)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.pop();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});for(let t=r.length-1;t>=0;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=Vo(t)?t:t.id,i=this.parent();if(e=$o({deep:!0},e),this.graph&&e.deep){for(;i;){if(i===n)return!0;i=this.graph.getCell(i).parent()}return!1}return i===n},isEmbedded:function(){return!!this.parent()},clone:function(t){if((t=t||{}).deep)return Qo(nl([this].concat(this.getEmbeddedCells({deep:!0}))));var e=el.prototype.clone.apply(this,arguments);return e.set(this.getIdAttribute(),this.generateId()),e.unset("embeds"),e.unset("parent"),e},prop:function(t,e,n){var i=Vo(t);if(i||Array.isArray(t)){if(arguments.length>1){var r,o;i?o=(r=t).split("/"):(r=t.join("/"),o=t.slice());var s=o[0],a=o.length;const m=n||{};m.propertyPath=r,m.propertyValue=e,m.propertyPathArray=o,"rewrite"in m||(m.rewrite=!1);for(var l={},c=l,h=s,u=1;u<a;u++){var d=o[u],f=Number.isFinite(i?Number(d):d);c=c[h]=f?[]:{},h=d}l=Aa(l,o,e,"/");var p=fs({},this.attributes);m.rewrite&&Ea(p,r,"/");var g=fs(p,l);return this.set(s,g[s],m)}return wa(this.attributes,t,"/")}const m=e||{};m.propertyPath=null,m.propertyValue=t,m.propertyPathArray=[],"rewrite"in m||(m.rewrite=!1);const v={};for(const e in t){const{changedValue:n}=fs({},{changedValue:this.attributes[e]},{changedValue:t[e]});v[e]=n}return this.set(v,m)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];if("attrs"===i&&(e.dirty=!0),1===n.length)return this.unset(t,e);var r=n.slice(1),o=this.get(i);return null==o?this:(o=Yo(o),Ea(o,r,"/"),this.set(i,o,e))},attr:function(t,e,n){var i=Array.from(arguments);return 0===i.length?this.get("attrs"):(Array.isArray(t)?i[0]=["attrs"].concat(t):Vo(t)?i[0]="attrs/"+t:i[0]={attrs:t},this.prop.apply(this,i))},removeAttr:function(t,e){return Array.isArray(t)?this.removeProp(["attrs"].concat(t)):this.removeProp("attrs/"+t,e)},transition:function(t,e,n,i){i=i||"/",n=$o({duration:100,delay:10,timingFunction:Ia.linear,valueFunction:Ba.number},n);var r,o=0,s=function(e){var i,a,l;(a=(e-=o=o||e)/n.duration)<1?this._transitionIds[t]=i=_a(s):(a=1,delete this._transitionIds[t]),l=r(n.timingFunction(a)),n.transitionId=i,this.prop(t,l,n),i||this.trigger("transition:end",this,t)}.bind(this);const{_scheduledTransitionIds:a}=this;let l;return l=setTimeout((o=>{a[t]&&(a[t]=ns(a[t],l),0===a[t].length&&delete a[t]),this.stopPendingTransitions(t,i),r=n.valueFunction(wa(this.attributes,t,i),e),this._transitionIds[t]=_a(o),this.trigger("transition:start",this,t)}),n.delay,s),a[t]||(a[t]=[]),a[t].push(l),l},getTransitions:function(){return rs(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e="/"){const{_scheduledTransitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>Zo(n,t.split(e).slice(0,n.length))))}return i.forEach((t=>{n[t].forEach((t=>clearTimeout(t))),delete n[t]})),this},stopPendingTransitions(t,e="/"){const{_transitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>Zo(n,t.split(e).slice(0,n.length))))}i.forEach((t=>{const e=n[t];Pa(e),delete n[t],this.trigger("transition:end",this,t)}))},stopTransitions:function(t,e="/"){return this.stopScheduledTransitions(t,e),this.stopPendingTransitions(t,e),this},addTo:function(t,e){return t.addCell(this,e),this},findView:function(t){return t.findViewByModel(this)},isElement:function(){return!1},isLink:function(){return!1},startBatch:function(t,e){return this.graph&&this.graph.startBatch(t,$o({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,$o({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new Re(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new Re},getBBox:function(){return new Je(0,0,0,0)},getPointRotatedAroundCenter(t,e,n){const i=new Re(e,n);return t&&i.rotate(this.getBBox().center(),t),i},getAbsolutePointFromRelative(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,n=zl;return e&&e[t]||n[t]},define:function(t,e,n,i){n=$o({defaults:jo({type:t},e,this.prototype.defaults)},n);var r=this.extend(n,i);return"undefined"!=typeof joint&&os(joint,"shapes")&&Aa(joint.shapes,t,r,"."),r}});function Gl(t,e,n){var i=t.toJSON();return i.angle=e||0,zo({},n,i)}function Hl(t,e,n,i){return t.map((function(t,e,n){var r=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&r.offset(t.dx||0,t.dy||0),Gl(r.round(),0,Wl(i,t))}),Ve(e,n))}function ql(t,e,n,i){var r=e.center(),o=e.width/e.height,s=e.topMiddle(),a=Ue.fromRect(e);return t.map((function(t,l,c){var h=n+i(l,c.length),u=s.clone().rotate(r,-h).scale(o,1,r),d=t.compensateRotation?-a.tangentTheta(u):0;return(t.dx||t.dy)&&u.offset(t.dx||0,t.dy||0),t.dr&&u.move(r,t.dr),Gl(u.round(),d,Wl(e,t))}))}function Wl(t,e){let{x:n,y:i,angle:r}=e;return La(n)?n=parseFloat(n)/100*t.width:yl(n)&&(n=Number(xl(n,t))),La(i)?i=parseFloat(i)/100*t.height:yl(i)&&(i=Number(xl(i,t))),{x:n,y:i,angle:r}}function Yl(t,e){const{x:n,y:i}=Wl(t,e);return new Re(n||0,i||0)}const Xl=function(t,e){return t.map((t=>{const n=Yl(e,t).round().toJSON();return n.angle=t.angle||0,n}))},Zl=function(t,e,n){return n.fn(t,e,n)},Kl=function(t,e,n){return Hl(t,Yl(e,n.start||e.origin()),Yl(e,n.end||e.corner()),e)},Jl=function(t,e,n){return Hl(t,e.origin(),e.bottomLeft(),e)},Ql=function(t,e,n){return Hl(t,e.topRight(),e.corner(),e)},tc=function(t,e,n){return Hl(t,e.origin(),e.topRight(),e)},ec=function(t,e,n){return Hl(t,e.bottomLeft(),e.corner(),e)},nc=function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return ql(t,e,i,(function(t){return t*r}))},ic=function(t,e,n){var i=n.startAngle||0,r=n.step||20;return ql(t,e,i,(function(t,e){return(t+.5-e/2)*r}))};function rc(t,e){return jo({},t,e,{x:0,y:0,angle:0,attrs:{}})}function oc(t){var e=t.center(),n=e.theta(t.origin()),i=e.theta(t.bottomLeft()),r=e.theta(t.corner());return[n,e.theta(t.topRight()),r,i]}function sc(t,e,n,i){i=zo({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,h=0;const[u,d,f,p]=oc(e);l<d||l>f?(s=".3em",r=c,o=0,a="start"):l<u?(r=0,o=-c,n?(h=-90,a="start",s=".3em"):(a="middle",s="0")):l<p?(s=".3em",r=-c,o=0,a="end"):(r=0,o=c,n?(h=90,a="start",s=".3em"):(a="middle",s=".6em"));var g=Math.round;return rc(i,{x:g(r),y:g(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function ac(t,e,n,i){i=zo({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,h=0;const[u,d,f,p]=oc(e);l<d||l>f?(s=".3em",r=-c,o=0,a="end"):l<u?(r=0,o=c,n?(h=90,a="start",s=".3em"):(a="middle",s=".6em")):l<p?(s=".3em",r=c,o=0,a="start"):(r=0,o=-c,n?(h=-90,a="start",s=".3em"):(a="middle",s="0"));var g=Math.round;return rc(i,{x:g(r),y:g(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function lc(t,e,n){n=zo({},n,{offset:20});var i,r=Fe(0,0),o=-t.theta(r),s=o,a=t.clone().move(r,n.offset).difference(t).round(),l=".3em";(o+90)%180==0?(i=e?"end":"middle",e||-270!==o||(l="0em")):o>-270&&o<-90?(i="start",s=o-180):i="end";var c=Math.round;return rc(n,{x:c(a.x),y:c(a.y),angle:e?s:0,attrs:{labelText:{y:l,textAnchor:i}}})}const cc=function(t,e,n){return rc(n)},hc=function(t,e,n){return rc(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},uc=function(t,e,n){return rc(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},dc=function(t,e,n){return rc(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},fc=function(t,e,n){return rc(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},pc=function(t,e,n){return sc(t,e,!0,n)},gc=function(t,e,n){return sc(t,e,!1,n)},mc=function(t,e,n){return ac(t,e,!0,n)},vc=function(t,e,n){return ac(t,e,!1,n)},yc=function(t,e,n){return lc(t.difference(e.center()),!1,n)},bc=function(t,e,n){return lc(t.difference(e.center()),!0,n)};var wc=function(t){var e=Yo(t)||{};this.ports=[],this.groups={},this.portLayoutNamespace=s,this.portLabelLayoutNamespace=a,this._init(e)};wc.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(t){return this.ports.filter((function(e){return e.group===t}))},getGroupPortsMetrics:function(t,e){var n=this.getGroup(t),i=this.getPortsByGroup(t),r=n.position||{},o=r.name,s=this.portLayoutNamespace;s[o]||(o="left");var a=r.args||{},l=i.map((function(t){return t&&t.position&&t.position.args})),c=s[o](l,e,a),h={ports:i,result:[]};return Qo(c).reduce(function(t,n,i){var r=t.ports[i];return t.result.push({portId:r.id,portTransformation:n,labelTransformation:this._getPortLabelLayout(r,Re(n),e),portAttrs:r.attrs,portSize:r.size,labelSize:r.label.size}),t}.bind(this),h),h.result},_getPortLabelLayout:function(t,e,n){var i=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return i[r]?i[r](e,n,t.label.position.args):null},_init:function(t){if(Bo(t.groups))for(var e=Object.keys(t.groups),n=0,i=e.length;n<i;n++){var r=e[n];this.groups[r]=this._evaluateGroup(t.groups[r])}for(var o=Qo(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return fs(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=$o({},t),n=this.getGroup(t.group);return e.markup=e.markup||n.markup,e.attrs=fs({},n.attrs,e.attrs),e.position=this._createPositionNode(n,e),e.label=fs({},n.label,this._getLabel(e)),e.z=this._getZIndex(n,e),e.size=$o({},n.size,e.size),e},_getZIndex:function(t,e){return Do(e.z)?e.z:Do(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return fs({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={};Ko(t)?(n="fn",i.fn=t):Vo(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):Bo(t)&&(n=t.name,$o(i,t.args));var r={args:i};return n&&(r.name=n),r},_getLabel:function(t,e){var n=t.label||{},i=n;return i.position=this._getPosition(n.position,e),i}};const xc={_initializePorts:function(){this._createPortData(),this.on("change:ports",(function(){this._processRemovedPort(),this._createPortData()}),this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={};Qo(t.items).forEach((function(t){e[t.id]=!0}));var n=this.previous("ports")||{},i={};Qo(n.items).forEach((function(t){e[t.id]||(i[t.id]=!0)}));var r=this.graph;r&&!Xo(i)&&(r.getConnectedLinks(this,{inbound:!0}).forEach((function(t){i[t.get("target").port]&&t.remove()})),r.getConnectedLinks(this,{outbound:!0}).forEach((function(t){i[t.get("source").port]&&t.remove()})))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&t.length>0},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return Yo(this.prop("ports/items"))||[]},getGroupPorts:function(t){const e=Qo(this.prop(["ports","items"])).filter((e=>e.group===t));return Yo(e)},getPort:function(t){return Yo(Qo(this.prop("ports/items")).find((function(e){return e.id&&e.id===t})))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,Je(this.size())).reduce((function(t,e){var n=e.portTransformation;return t[e.portId]={x:n.x,y:n.y,angle:n.angle},t}),{})},getPortIndex:function(t){var e=Bo(t)?t.id:t;return this._isValidPortId(e)?Qo(this.prop("ports/items")).findIndex((function(t){return t.id===e})):-1},addPort:function(t,e){if(!Bo(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=$o([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){const i="number"==typeof t?t:this.getPortIndex(t);if(!Bo(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");const r=$o([],this.prop("ports/items"));return r.splice(i,0,e),this.prop("ports/items",r,n),this},portProp:function(t,e,n,i){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);var o=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?o[0]=["ports","items",r].concat(e):Vo(e)?o[0]=["ports/items/",r,"/",e].join(""):(o=["ports/items/"+r],Jo(e)&&(o.push(e),o.push(n))),this.prop.apply(this,o)},_validatePorts:function(){var t=this.get("ports")||{},e=[],n=Qo((t=t||{}).items);return n.forEach((function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())}),this),qo(n,"id").length!==n.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!Bo(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",$o([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){const n=e||{},i=this.getPortIndex(t);if(-1!==i){const t=$o([],this.prop(["ports","items"]));t.splice(i,1),n.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],t,n),this.stopBatch("port-remove")}return this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;i=$o([],this.prop(["ports","items"])).filter((function(e){return!t.some((function(t){const n=Bo(t)?t.id:t;return e.id===n}))}))}else n=t||{},i=[];return this.startBatch("port-remove"),n.rewrite=!0,this.prop(["ports","items"],i,n),this.stopBatch("port-remove"),this},_createPortData:function(){var t,e=this._validatePorts();if(e.length>0)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new wc(this.get("ports"));var n=this._portSettingsData.getPorts();if(t){var i=n.filter((function(e){if(!t.find((function(t){return t.id===e.id})))return e})),r=t.filter((function(t){if(!n.find((function(e){return e.id===t.id})))return t}));r.length>0&&this.trigger("ports:remove",this,r),i.length>0&&this.trigger("ports:add",this,i)}}},Ac={portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._cleanPortsCache()},_refreshPorts:function(){this._removePorts(),this._cleanPortsCache(),this._renderPorts()},_cleanPortsCache:function(){this._portElementsCache={}},_renderPorts:function(){for(var t=[],e=this._getContainerElement(),n=0,i=e.node.childNodes.length;n<i;n++)t.push(e.node.childNodes[n]);var r,o,s=(r=this.model._portSettingsData.getPorts(),o=Eo(o="z",2),function(t,e,n){return(Array.isArray(t)?To:So)(t,e,n,arguments.length<3,po)}(r,((t,e,n)=>(n=o(e),hasOwnProperty.call(t,n)?t[n].push(e):Tr(t,n,[e]),t)),{})),a="auto";Qo(s[a]).forEach((function(n){var i=this._getPortElement(n);e.append(i),t.push(i)}),this);for(var l=Object.keys(s),c=0;c<l.length;c++){var h=l[c];if(h!==a){var u=parseInt(h,10);this._appendPorts(s[h],u,t)}}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),r=Qo(t).map(this._getPortElement,this);n[e]||e<0?ri(n[Math.max(e,0)]).before(r):i.append(r)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){const n=this._portElementsCache[t];if(!n)return[];if(!e)return[n.portContentElement.node];const i=n.portElement.node,r=n.portSelectors;return this.findBySelector(e,i,r)},findPortNode:function(t,e){const[n=null]=this.findPortNodes(t,e);return n},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){Uo(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r;var o=ri(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t);if(Array.isArray(s)){var a=this.parseDOMJSON(s,o.node),l=a.fragment;e=l.childNodes.length>1?ri("g").append(l):ri(l.firstChild),r=a.selectors}else e=ri(s),Array.isArray(e)&&(e=ri("g").append(e));if(!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group});const c=this._getPortLabelMarkup(t.label);if(Array.isArray(c)){const{fragment:t,selectors:e}=this.parseDOMJSON(c,o.node),r=t.childNodes.length;r>0&&(i=e,n=1===r?ri(t.firstChild):ri("g").append(t))}else n=ri(c),Array.isArray(n)&&(n=ri("g").append(n));var h;if(r&&i){for(var u in i)if(r[u]&&u!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=$o({},r,i)}else h=r||i||{};const d="portRoot",f="labelRoot",p="labelText";if(d in h||(h[d]=e.node),n){const t=n.node;if(f in h||(h[f]=t),!(p in h)){const e="TEXT"===n.tagName()?t:Array.from(t.querySelectorAll("text"));h[p]=e,i||(i={}),i[p]=e}}return o.append(e.addClass("joint-port-body")),n&&o.append(n.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:n,portSelectors:h,portLabelSelectors:i,portContentElement:e,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=Je(this.model.size()),n=this.model._portSettingsData.getGroupPortsMetrics(t,e),i=0,r=n.length;i<r;i++){var o=n[i],s=o.portId,a=this._portElementsCache[s]||{},l=o.portTransformation,c=o.labelTransformation;c&&a.portLabelElement&&(this.updateDOMSubtreeAttributes(a.portLabelElement.node,c.attrs,{rootBBox:new Je(o.labelSize),selectors:a.portLabelSelectors}),this.applyPortTransform(a.portLabelElement,c,-l.angle||0)),this.updateDOMSubtreeAttributes(a.portElement.node,o.portAttrs,{rootBBox:new Je(o.portSize),selectors:a.portSelectors}),this.applyPortTransform(a.portElement,l)}},applyPortTransform:function(t,e,n){var i=ri.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},Ec=Ul.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),Ul.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){const i=Do(e);n=(i?n:t)||{};const{parentRelative:r,deep:o,restrictedArea:s}=n;let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");const t=this.getParentCell();t&&!t.isLink()&&(a=t.get("position"))}if(i){if(a&&(t+=a.x,e+=a.y),o||s){const{x:i,y:r}=this.get("position");this.translate(t-i,e-r,n)}else this.set("position",{x:t,y:e},n);return this}{const t=Re(this.get("position"));return r?t.difference(a):t}},translate:function(t,e,n){if(e=e||0,0===(t=t||0)&&0===e)return this;(n=n||{}).translateBy=n.translateBy||this.id;var i=this.get("position")||{x:0,y:0},r=n.restrictedArea;if(r&&n.translateBy===this.id)if("function"==typeof r){var o=r.call(this,i.x+t,i.y+e,n);t=o.x-i.x,e=o.y-i.y}else{var s=this.getBBox({deep:!0}),a=i.x-s.x,l=i.y-s.y,c=Math.max(r.x+a,Math.min(r.x+r.width+a-s.width,i.x+t)),h=Math.max(r.y+l,Math.min(r.y+r.height+l-s.height,i.y+e));t=c-i.x,e=h-i.y}var u={x:i.x+t,y:i.y+e};return n.tx=t,n.ty=e,n.transition?(Bo(n.transition)||(n.transition={}),this.transition("position",u,$o({},n.transition,{valueFunction:Ba.object})),Uo(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",u,n),Uo(this.getEmbeddedCells(),"translate",t,e,n),this.stopBatch("translate",n)),this},size:function(t,e,n){var i=this.get("size");return void 0===t?{width:i.width,height:i.height}:(Bo(t)&&(n=e,e=Do(t.height)?t.height:i.height,t=Do(t.width)?t.width:i.width),this.resize(t,e,n))},resize:function(t,e,n){if(n=n||{},this.startBatch("resize",n),n.direction){var i=this.get("size");switch(n.direction){case"left":case"right":e=i.height;break;case"top":case"bottom":t=i.width}var r,o=de(this.get("angle")||0),s=this.getBBox();if(o){var a={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction];n.absolute&&(a+=Math.floor((o+45)/90),a%=4);var l=s[["bottomLeft","corner","topRight","origin"][a]](),c=Re(l).rotate(s.center(),-o),h=Math.sqrt(t*t+e*e)/2,u=a*Math.PI/2;u+=Math.atan(a%2==0?e/t:t/e),u-=ge(o);var d=Re.fromPolar(h,u,c);r=Re(d).offset(t/-2,e/-2)}else switch(r=s.topLeft(),n.direction){case"top":case"top-right":r.offset(0,s.height-e);break;case"left":case"bottom-left":r.offset(s.width-t,0);break;case"top-left":r.offset(s.width-t,s.height-e)}this.set("size",{width:t,height:e},n),this.position(r.x,r.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){var r=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(r.x,r.y,i),this.resize(r.width,r.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");const n=this.getEmbeddedCells().filter((t=>t.isElement()));return 0===n.length||(this.startBatch("fit-embeds",t),t.deep&&Uo(n,"fitToChildren",t),this._fitToElements(Object.assign({elements:n},t)),this.stopBatch("fit-embeds")),this},fitParent:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");if(t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id))return this;const n=this.getParentCell();if(!n||!n.isElement())return this;const i=n.getEmbeddedCells().filter((t=>t.isElement()));return 0===i.length||(this.startBatch("fit-parent",t),n._fitToElements(Object.assign({elements:i},t)),t.deep&&n.fitParent(t),this.stopBatch("fit-parent")),this},_fitToElements:function(t={}){const e=this.graph.getCellsBBox(t.elements);if(!e)return;const{expandOnly:n,shrinkOnly:i}=t;if(n&&i)return;let{x:r,y:o,width:s,height:a}=e;const{left:l,right:c,top:h,bottom:u}=Fa(t.padding);r-=l,o-=h,s+=l+c,a+=u+h;let d=new Je(r,o,s,a);if(n)d=this.getBBox().union(d);else if(i){const t=this.getBBox().intersect(d);if(!t)return;d=t}this.set({position:{x:d.x,y:d.y},size:{width:d.width,height:d.height}},t)},rotate:function(t,e,n,i){if(n){var r=this.getBBox().center(),o=this.get("size"),s=this.get("position");r.rotate(n,this.get("angle")-t);var a=r.x-o.width/2-s.x,l=r.y-o.height/2-s.y;this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(s.x+a,s.y+l,i),this.rotate(t,e,null,i),this.stopBatch("rotate")}else this.set("angle",e?t:(this.get("angle")+t)%360,i);return this},angle:function(){return de(this.get("angle")||0)},getBBox:function(t={}){const{graph:e,attributes:n}=this,{deep:i,rotate:r}=t;if(i&&e){const n=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return n.push(this),e.getCellsBBox(n,t)}const{angle:o=0,position:{x:s,y:a},size:{width:l,height:c}}=n,h=new Je(s,a,l,c);return r&&h.rotateAroundCenter(o),h},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),r=t.get(e);if(!r)return i;var o=r.port;if(!o||!this.hasPort(o))return i;var s=this.portProp(o,["group"]),a=this.getPortsPositions(s),l=new Re(a[o]).offset(n.origin()),c=this.angle();return c&&l.rotate(i,-c),l}});$o(Ec.prototype,xc);const Tc=Ul.extend({defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,x:"calc(x)",y:"calc(y)",width:"calc(w)",height:"calc(h)"}},position:{distance:.5}}},defaults:{source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,n){return void 0===t?Wo(this.get("source")):t instanceof Ul?((i=Wo(e)||{}).id=t.id,r=n,this.set("source",i,r)):Jo(t)?(i=t,r=e,this.set("source",i,r)):((i=Wo(e)||{}).x=t.x,i.y=t.y,r=n,this.set("source",i,r));var i,r},target:function(t,e,n){return void 0===t?Wo(this.get("target")):t instanceof Ul?((i=Wo(e)||{}).id=t.id,r=n,this.set("target",i,r)):Jo(t)?(i=t,r=e,this.set("target",i,r)):((i=Wo(e)||{}).x=t.x,i.y=t.y,r=n,this.set("target",i,r));var i,r},router:function(t,e,n){if(void 0===t){var i=this.get("router");return i?"object"==typeof i?Wo(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("router",o,s)},connector:function(t,e,n){if(void 0===t){var i=this.get("connector");return i?"object"==typeof i?Wo(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("connector",o,s)},label:function(t,e,n){var i=this.labels();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["labels",t]):this.prop(["labels",t],e,n)},labels:function(t,e){return 0===arguments.length?(t=this.get("labels"),Array.isArray(t)?t.slice():[]):(Array.isArray(t)||(t=[]),this.set("labels",t,e))},hasLabels:function(){const{labels:t}=this.attributes;return Array.isArray(t)&&t.length>0},insertLabel:function(t,e,n){if(!e)throw new Error("dia.Link: no label provided");var i=this.labels(),r=i.length;return(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),i.splice(t,0,e),this.labels(i,n)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var n=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.labels(n,e)},vertex:function(t,e,n){var i=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1)return this.prop(["vertices",t]);var r=this._normalizeVertex(e);return this.prop(["vertices",t],r,n)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var n=[],i=0;i<t.length;i++){var r=t[i],o=this._normalizeVertex(r);n.push(o)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){if(!e)throw new Error("dia.Link: no vertex provided");var i=this.vertices(),r=i.length;(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1);var o=this._normalizeVertex(e);return i.splice(t,0,o),this.vertices(i,n)},removeVertex:function(t,e){var n=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.vertices(n,e)},_normalizeVertex:function(t){return Jo(t)?t:{x:t.x,y:t.y}},translate:function(t,e,n){return(n=n||{}).translateBy=n.translateBy||this.id,n.tx=t,n.ty=e,this.applyToPoints((function(n){return{x:(n.x||0)+t,y:(n.y||0)+e}}),n)},scale:function(t,e,n,i){return this.applyToPoints((function(i){return Re(i).scale(t,e,n).toJSON()}),i)},applyToPoints:function(t,e){if(!Ko(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var n={},{source:i,target:r}=this.attributes;i.id||(n.source=t(i)),r.id||(n.target=t(r));var o=this.vertices();return o.length>0&&(n.vertices=o.map(t)),this.set(n,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new Re(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new Re(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){const t=[this.getSourcePoint(),...this.vertices().map(Re),this.getTargetPoint()];return new rn(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e;if(this.graph){var n=this.getSourceElement(),i=this.getTargetElement(),r=this.getParentCell();n&&i&&(e=n===i||n.isEmbeddedIn(i)?i:i.isEmbeddedIn(n)?n:this.graph.getCommonAncestor(n,i)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)}return e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,i=e.id,r=n.id;if(!i||!r)return!1;var o=i===r;if(!o&&t.deep&&this.graph){var s=this.getSourceCell(),a=this.getTargetCell();o=s.isEmbeddedIn(a)||a.isEmbeddedIn(s)}return o},getSourceCell:function(){const{graph:t,attributes:e}=this;var n=e.source;return n&&n.id&&t&&t.getCell(n.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getSourceCell()}while(t&&t.isLink());return t},getTargetCell:function(){const{graph:t,attributes:e}=this;var n=e.target;return n&&n.id&&t&&t.getCell(n.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getTargetCell()}while(t&&t.isLink());return t},getRelationshipAncestor:function(){var t;if(this.graph){var e=[this,this.getSourceElement(),this.getTargetElement()].filter((function(t){return!!t}));t=this.graph.getCommonAncestor.apply(this.graph,e)}return t||null},isRelationshipEmbeddedIn:function(t){var e=Vo(t)||Do(t)?t:t.id,n=this.getRelationshipAncestor();return!!n&&(n.id===e||n.isEmbeddedIn(e))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var n=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&n}}),Sc={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var n=this._results[t];if(void 0!==n)return n;try{n=e()}catch(t){n=!1}return this._results[t]=n,n}},_c=Ec.define("standard.Rectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),Pc=Ec.define("standard.Circle",{attrs:{root:{cursor:"move"},body:{cx:"calc(s/2)",cy:"calc(s/2)",r:"calc(s/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),kc=Ec.define("standard.Ellipse",{attrs:{root:{cursor:"move"},body:{cx:"calc(w/2)",cy:"calc(h/2)",rx:"calc(w/2)",ry:"calc(h/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),Cc=Ec.define("standard.Path",{attrs:{root:{cursor:"move"},body:{d:"M 0 0 H calc(w) V calc(h) H 0 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),Lc=Ec.define("standard.Polygon",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),Mc=Ec.define("standard.Polyline",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),Oc=Ec.define("standard.Image",{attrs:{root:{cursor:"move"},image:{width:"calc(w)",height:"calc(h)"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Nc=Ec.define("standard.BorderedImage",{attrs:{root:{cursor:"move"},border:{width:"calc(w)",height:"calc(h)",stroke:"#333333",strokeWidth:2},background:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5,fill:"#FFFFFF"},image:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"background",attributes:{stroke:"none"}},{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Rc=Ec.define("standard.EmbeddedImage",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{width:"calc(0.3*w)",height:"calc(h-20)",x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",x:"calc(0.3*w+20)",y:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Fc=Ec.define("standard.InscribedImage",{attrs:{root:{cursor:"move"},border:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",stroke:"#333333",strokeWidth:2},background:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",fill:"#FFFFFF"},image:{width:"calc(0.68*w)",height:"calc(0.68*h)",x:"calc(0.16*w)",y:"calc(0.16*h)",preserveAspectRatio:"xMidYMid"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"background"},{tagName:"image",selector:"image"},{tagName:"ellipse",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Ic=Ec.define("standard.HeaderedRectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{width:"calc(w)",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]}),Bc=Ec.define("standard.Cylinder",{attrs:{root:{cursor:"move"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{cx:"calc(w/2)",cy:10,rx:"calc(w/2)",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var n={lateralArea:t},i=La(t)?`calc(${parseFloat(t)/100}*h)`:t,r={cy:i,ry:i};return this.attr({body:n,top:r},e)}},{attributes:{"lateral-area":{set:function(t,e){var n=La(t);n&&(t=parseFloat(t)/100);var i=e.x,r=e.y,o=e.width,s=e.height,a=o/2,l=n?s*t:t,c=ri.KAPPA,h=c*a,u=c*(n?s*t:t),d=i+o/2,f=i+o,p=r+l,g=p-l,m=r+s-l,v=r+s;return{d:["M",i,p,"L",i,m,"C",i,m+u,d-h,v,d,v,"C",d+h,v,f,m+u,f,m,"L",f,p,"C",f,p-u,d+h,g,d,g,"C",d-h,g,i,p-u,i,p,"Z"].join(" ")}}}}});var Dc=Sc.test("svgforeignobject")?{tagName:"foreignObject",selector:"foreignObject",attributes:{overflow:"hidden"},children:[{tagName:"div",namespaceURI:"http://www.w3.org/1999/xhtml",selector:"label",style:{width:"100%",height:"100%",position:"static",backgroundColor:"transparent",textAlign:"center",margin:0,padding:"0px 5px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}]}:{tagName:"text",selector:"label",attributes:{"text-anchor":"middle"}};const Vc=Ec.define("standard.TextBlock",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#ffffff",strokeWidth:2},foreignObject:{width:"calc(w)",height:"calc(h)"},label:{style:{fontSize:14}}}},{markup:[{tagName:"rect",selector:"body"},Dc]},{attributes:{text:{set:function(t,e,n,i){if(!(n instanceof HTMLElement)){var r=i.style||{},o={text:t,width:-5,height:"100%"},s=$o({"text-vertical-anchor":"middle"},r);return zl["text-wrap"].set.call(this,o,e,n,s),{fill:r.color||null}}n.textContent=t},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),$c=Tc.define("standard.Link",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 10 -5 0 0 10 5 z"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),zc=Tc.define("standard.DoubleLink",{attrs:{line:{connection:!0,stroke:"#DDDDDD",strokeWidth:4,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"#000000",d:"M 10 -3 10 -10 -2 0 10 10 10 3"}},outline:{connection:!0,stroke:"#000000",strokeWidth:6,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"outline",attributes:{fill:"none",cursor:"pointer"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),jc=Tc.define("standard.ShadowLink",{attrs:{line:{connection:!0,stroke:"#FF0000",strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"none",d:"M 0 -10 -10 0 0 10 z"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}},shadow:{connection:!0,transform:"translate(3,6)",stroke:"#000000",strokeOpacity:.2,strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 0 -10 -10 0 0 10 z",stroke:"none"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}}}},{markup:[{tagName:"path",selector:"shadow",attributes:{fill:"none","pointer-events":"none"}},{tagName:"path",selector:"line",attributes:{fill:"none",cursor:"pointer"}}]}),Uc={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left",TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",CENTER:"center"};function Gc(t,e){const n=new Je(t);switch(e){case void 0:throw new Error("Position required");case Uc.LEFT:case"leftMiddle":return n.leftMiddle();case Uc.RIGHT:case"rightMiddle":return n.rightMiddle();case Uc.TOP:case"topMiddle":return n.topMiddle();case Uc.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case Uc.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case Uc.TOP_RIGHT:case"topRight":return n.topRight();case Uc.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case Uc.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case Uc.CENTER:return n.center();default:throw new Error(`Unknown position: ${e}`)}}var Hc=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,$o({silent:!0},e))},qc={add:!0,remove:!0,merge:!0},Wc={add:!0,remove:!1},Yc=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var i,r=Array(t.length-n),o=e.length;for(i=0;i<r.length;i++)r[i]=t[i+n];for(i=0;i<o;i++)t[i+n]=e[i];for(i=0;i<r.length;i++)t[i+o+n]=r[i]};$o(Hc.prototype,za,{model:el,preinitialize:function(){},initialize:function(){},toJSON:function(t){return this.map((function(e){return e.toJSON(t)}))},add:function(t,e){return this.set(t,$o({merge:!1},e,Wc))},remove:function(t,e){e=$o({},e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=this._removeModels(t,e);return!e.silent&&i.length&&(e.changes={added:[],merged:[],removed:i},this.trigger("update",this,e)),n?i[0]:i},set:function(t,e){if(null!=t){e=$o({},qc,e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=e.at;null!=i&&(i=+i),i>this.length&&(i=this.length),i<0&&(i+=this.length+1);var r,o,s=[],a=[],l=[],c=[],h={},u=e.add,d=e.merge,f=e.remove,p=!1,g=this.comparator&&null==i&&!1!==e.sort,m=Vo(this.comparator)?this.comparator:null;for(o=0;o<t.length;o++){r=t[o];var v=this.get(r);if(v){if(d&&r!==v){var y=this._isModel(r)?r.attributes:r;v.set(y,e),l.push(v),g&&!p&&(p=v.hasChanged(m))}h[v.cid]||(h[v.cid]=!0,s.push(v)),t[o]=v}else u&&(r=t[o]=this._prepareModel(r,e))&&(a.push(r),this._addReference(r,e),h[r.cid]=!0,s.push(r))}if(f){for(o=0;o<this.length;o++)h[(r=this.models[o]).cid]||c.push(r);c.length&&this._removeModels(c,e)}var b=!1,w=!g&&u&&f;if(s.length&&w?(b=this.length!==s.length||this.models.some((function(t,e){return t!==s[e]})),this.models.length=0,Yc(this.models,s,0),this.length=this.models.length):a.length&&(g&&(p=!0),Yc(this.models,a,null==i?this.length:i),this.length=this.models.length),p&&this.sort({silent:!0}),!e.silent){for(o=0;o<a.length;o++)null!=i&&(e.index=i+o),(r=a[o]).trigger("add",r,this,e);(p||b)&&this.trigger("sort",this,e),(a.length||c.length||l.length)&&(e.changes={added:a,removed:c,merged:l},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?Wo(e):{};for(var n=0;n<this.models.length;n++)this._removeReference(this.models[n],e);return e.previousModels=this.models,this._reset(),t=this.add(t,$o({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,$o({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t)},unshift:function(t,e){return this.add(t,$o({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t)},slice:function(){return Array.prototype.slice.apply(this.models,arguments)},get:function(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t,t.idAttribute)]||t.cid&&this._byId[t.cid]},has:function(t){return null!=this.get(t)},at:function(t){return t<0&&(t+=this.length),this.models[t]},sort:function(t){var e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t||(t={});var n=e.length;return Ko(e)&&(e=e.bind(this)),1===n||Vo(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(t,e){return t[e||this.model.prototype.idAttribute||"id"]},values:function(){return new Kc(this,Jc)},keys:function(){return new Kc(this,Qc)},entries:function(){return new Kc(this,th)},each:function(t,e){this.models.forEach(t,e)},filter:function(t,e){return this.models.filter(t,e)},find:function(t,e){return this.models.find(t,e)},findIndex:function(t,e){return this.models.findIndex(t,e)},first:function(){return this.models[0]},includes:function(t){return this.models.includes(t)},last:function(){return this.models[this.models.length-1]},isEmpty:function(){return!this.models.length},map:function(t,e){return this.models.map(t,e)},reduce:function(t,e=this.first()){return this.models.reduce(t,e)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){return this._isModel(t)?(t.collection||(t.collection=this),t):((e=e?Wo(e):{}).collection=this,(n=this.model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,n.validationError,e),!1):n);var n},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r=this.get(t[i]);if(r){var o=this.models.indexOf(r);this.models.splice(o,1),this.length--,delete this._byId[r.cid];var s=this.modelId(r.attributes,r.idAttribute);null!=s&&delete this._byId[s],e.silent||(e.index=o,r.trigger("remove",r,this,e)),n.push(r),this._removeReference(r,e)}}return t.length>0&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof el},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,i){if(e){if(("add"===t||"remove"===t)&&n!==this)return;if("changeId"===t){var r=this.modelId(e.previousAttributes(),e.idAttribute),o=this.modelId(e.attributes,e.idAttribute);null!=r&&delete this._byId[r],null!=o&&(this._byId[o]=e)}}this.trigger.apply(this,arguments)}});var Xc="function"==typeof Symbol&&Symbol.iterator;Xc&&(Hc.prototype[Xc]=Hc.prototype.values);var Zc,Kc=function(t,e){this._collection=t,this._kind=e,this._index=0},Jc=1,Qc=2,th=3;Xc&&(Kc.prototype[Xc]=function(){return this}),Kc.prototype.next=function(){if(this._collection){if(this._index<this._collection.length){var t,e=this._collection.at(this._index);if(this._index++,this._kind===Jc)t=e;else{var n=this._collection.modelId(e.attributes,e.idAttribute);t=this._kind===Qc?n:[n,e]}return{value:t,done:!1}}this._collection=void 0}return{value:void 0,done:!0}},function(t,e,n,i){cs(n,(function(n,r){e[r]&&(t.prototype[r]=function(t,e,n,i){switch(e){case 1:return function(){return t[n](this[i])};case 2:return function(e){return t[n](this[i],e)};case 3:return function(e,r){return t[n](this[i],Qa(e,this),r)};case 4:return function(e,r,o){return t[n](this[i],Qa(e,this),r,o)};default:return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(this[i]),t[n].apply(t,e)}}}(e,n,r,i))}))}((Zc=[Hc,{toArray:1,sortBy:3},"models"])[0],{sortBy:ts,toArray:Qo},Zc[1],Zc[2]),Hc.extend=Ja;const eh={cells:function(t){return function(){var e=Array.from(arguments),n=e.length,i=n>0&&e[0]||[],r=n>1&&e[n-1]||{};return Array.isArray(i)||(r instanceof Ul?i=e:i instanceof Ul&&(e.length>1&&e.pop(),i=e)),r instanceof Ul&&(r={}),t.call(this,i,r)}}},nh=Hc.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&os(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){const n=e.collection,i=n.cellNamespace,{type:r}=t,o=wa(i,r,".");if(!o)throw new Error(`dia.Graph: Could not find cell constructor for type: '${r}'. Make sure to add the constructor to 'cellNamespace'.`);const s=new o(t,e);return e.dry||(s.graph=n.graph),s},comparator:function(t){return t.get("z")||0}}),ih=el.extend({initialize:function(t,e){var n=new nh([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});el.prototype.set.call(this,"cells",n),n.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},n.on("add",this._restructureOnAdd,this),n.on("remove",this._restructureOnRemove,this),n.on("reset",this._restructureOnReset,this),n.on("change:source",this._restructureOnChangeSource,this),n.on("change:target",this._restructureOnChangeTarget,this),n.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){if(t.isLink()){this._edges[t.id]=!0;var{source:e,target:n}=t.attributes;e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0),n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)}else this._nodes[t.id]=!0},_restructureOnRemove:function(t){if(t.isLink()){delete this._edges[t.id];var{source:e,target:n}=t.attributes;e.id&&this._out[e.id]&&this._out[e.id][t.id]&&delete this._out[e.id][t.id],n.id&&this._in[n.id]&&this._in[n.id][t.id]&&delete this._in[n.id][t.id]}else delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source");e.id&&this._out[e.id]&&delete this._out[e.id][t.id];var n=t.attributes.source;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target");e.id&&this._in[e.id]&&delete this._in[e.id][t.id];var n=t.get("target");n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=el.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(!t.cells)throw new Error("Graph JSON must contain cells array.");return this.set(t,e)},set:function(t,e,n){var i;return"object"==typeof t?(i=t,n=e):(i={})[t]=e,i.hasOwnProperty("cells")&&(this.resetCells(i.cells,n),i=as(i,"cells")),el.prototype.set.call(this,i,n)},clear:function(t){t=$o({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);var n=e.sortBy((function(t){return t.isLink()?1:2}));do{n.shift().remove(t)}while(n.length>0);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var n;if(t instanceof el?(n=t.attributes,t.graph||e&&e.dry||(t.graph=this)):n=t,!Vo(n.type))throw new TypeError("dia.Graph: cell type must be a string.");return t},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof el?t.has("z")||t.set("z",this.maxZIndex()+1):void 0===t.z&&(t.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(t,e),e||{}),this)},addCells:function(t,e){return 0===t.length||(t=es(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach((function(t){this.addCell(t,e),e.position--}),this),this.stopBatch("add",e)),this},resetCells:function(t,e){var n=Qo(t).map((function(t){return this._prepareCell(t,e)}),this);return this.get("cells").reset(n,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),Uo(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,n){(n=n||{}).clear||(n.disconnectLinks?this.disconnectLinks(t,n):this.removeLinks(t,n)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").toArray().filter((t=>t.isElement()))},getLinks:function(){return this.get("cells").toArray().filter((t=>t.isLink()))},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,e){var n=(e=e||{}).indirect,i=e.inbound,r=e.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=[],s={};function a(t,e){if(cs(t.getOutboundEdges(e.id),function(e,c){if(!s[c]){var h=t.getCell(c);o.push(h),s[c]=!0,n&&(i&&l(t,h),r&&a(t,h))}}.bind(t)),n&&e.isLink()){var c=e.getTargetCell();c&&c.isLink()&&(s[c.id]||(o.push(c),a(t,c)))}}function l(t,e){if(cs(t.getInboundEdges(e.id),function(e,c){if(!s[c]){var h=t.getCell(c);o.push(h),s[c]=!0,n&&(i&&l(t,h),r&&a(t,h))}}.bind(t)),n&&e.isLink()){var c=e.getSourceCell();c&&c.isLink()&&(s[c.id]||(o.push(c),l(t,c)))}}if(r&&a(this,t),i&&l(this,t),e.deep){var c=t.getEmbeddedCells({deep:!0}),h={};c.forEach((function(t){t.isElement()&&(h[t.id]=!0)})),c.forEach((function(t){t.isLink()||(r&&cs(this.getOutboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&h[l]&&c&&h[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)),i&&cs(this.getInboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&h[l]&&c&&h[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)))}),this)}return o},getNeighbors:function(t,e){e||(e={});var n=e.inbound,i=e.outbound;void 0===n&&void 0===i&&(n=i=!0);var r=this.getConnectedLinks(t,e).reduce(function(r,o){var{source:s,target:a}=o.attributes,l=o.hasLoop(e);if(n&&os(s,"id")&&!r[s.id]){var c=this.getCell(s.id);c.isElement()&&(!l&&(!c||c===t||e.deep&&c.isEmbeddedIn(t))||(r[s.id]=c))}if(i&&os(a,"id")&&!r[a.id]){var h=this.getCell(a.id);h.isElement()&&(!l&&(!h||h===t||e.deep&&h.isEmbeddedIn(t))||(r[a.id]=h))}return r}.bind(this),{});if(t.isLink()){if(n){var o=t.getSourceCell();o&&o.isElement()&&!r[o.id]&&(r[o.id]=o)}if(i){var s=t.getTargetCell();s&&s.isElement()&&!r[s.id]&&(r[s.id]=s)}}return Qo(r)},getCommonAncestor:function(){var t=Array.from(arguments).map((function(t){for(var e=[],n=t.get("parent");n;)e.push(n),n=this.getCell(n).get("parent");return e}),this);t=t.sort((function(t,e){return t.length-e.length}));var e=Qo(t.shift()).find((function(e){return t.every((function(t){return t.includes(e)}))}));return this.getCell(e)},getSuccessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),$o({},e,{outbound:!0})),n},cloneCells:nl,cloneSubgraph:function(t,e){var n=this.getSubgraph(t,e);return this.cloneCells(n)},getSubgraph:function(t,e){e=e||{};var n=[],i={},r=[],o=[];return Qo(t).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t))}))})),o.forEach((function(t){var{source:e,target:o}=t.attributes;if(e.id&&!i[e.id]){var s=this.getCell(e.id);n.push(s),i[s.id]=s,r.push(s)}if(o.id&&!i[o.id]){var a=this.getCell(o.id);n.push(this.getCell(o.id)),i[a.id]=a,r.push(a)}}),this),r.forEach((function(t){this.getConnectedLinks(t,e).forEach((function(t){var{source:e,target:r}=t.attributes;!i[t.id]&&e.id&&i[e.id]&&r.id&&i[r.id]&&(n.push(t),i[t.id]=t)}))}),this),n},getPredecessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),$o({},e,{inbound:!0})),n},search:function(t,e,n){(n=n||{}).breadthFirst?this.bfs(t,e,n):this.dfs(t,e,n)},bfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){var s=o.shift();if(i[s.id])continue;if(i[s.id]=!0,!1===e.call(this,s,r[s.id]))continue;const t=this.getNeighbors(s,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];r[n.id]=r[s.id]+1,o.push(n)}}},dfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){const t=o.pop();if(i[t.id])continue;if(i[t.id]=!0,!1===e.call(this,t,r[t.id]))continue;const s=this.getNeighbors(t,n),a=o.length;for(let e=0,n=s.length;e<n;e++){const n=s[e];r[n.id]=r[t.id]+1,o.splice(a,0,n)}}},getSources:function(){var t=[];return cs(this._nodes,function(e,n){this._in[n]&&!Xo(this._in[n])||t.push(this.getCell(n))}.bind(this)),t},getSinks:function(){var t=[];return cs(this._nodes,function(e,n){this._out[n]&&!Xo(this._out[n])||t.push(this.getCell(n))}.bind(this)),t},isSource:function(t){return!this._in[t.id]||Xo(this._in[t.id])},isSink:function(t){return!this._out[t.id]||Xo(this._out[t.id])},isSuccessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{outbound:!0}),n},isPredecessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{inbound:!0}),n},isNeighbor:function(t,e,n){var i=(n=n||{}).inbound,r=n.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=!1;return this.getConnectedLinks(t,n).forEach((function(t){var{source:n,target:s}=t.attributes;return i&&os(n,"id")&&n.id===e.id||r&&os(s,"id")&&s.id===e.id?(o=!0,!1):void 0})),o},disconnectLinks:function(t,e){this.getConnectedLinks(t).forEach((function(n){n.set(n.attributes.source.id===t.id?"source":"target",{x:0,y:0},e)}))},removeLinks:function(t,e){Uo(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(t){return this.getElements().filter((e=>e.getBBox({rotate:!0}).containsPoint(t)))},findModelsInArea:function(t,e={}){const n=new Je(t),{strict:i=!1}=e,r=i?"containsRect":"intersect";return this.getElements().filter((t=>n[r](t.getBBox({rotate:!0}))))},findModelsUnderElement:function(t,e={}){const{searchBy:n="bbox"}=e,i=t.getBBox().rotateAroundCenter(t.angle());return("bbox"===n?this.findModelsInArea(i):this.findModelsFromPoint(Gc(i,n))).filter((e=>t.id!==e.id&&!e.isEmbeddedIn(t)))},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e={}){const{rotate:n=!0}=e;return Qo(t).reduce((function(t,e){const i=e.getBBox({rotate:n});return i?t?t.union(i):i:t}),null)},translate:function(t,e,n){var i=this.getCells().filter((function(t){return!t.isEmbedded()}));return Uo(i,"translate",t,e,n),this},resize:function(t,e,n){return this.resizeCells(t,e,this.getCells(),n)},resizeCells:function(t,e,n,i){var r=this.getCellsBBox(n);if(r){var o=Math.max(t/r.width,0),s=Math.max(e/r.height,0);Uo(n,"scale",o,s,r.origin(),i)}return this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",$o({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",$o({},e,{batchName:t}))},hasActiveBatch:function(t){const e=this._batches;let n;return n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t],n.some((t=>e[t]>0))}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){var r=e.getSourceCell();if(r&&t.getConnectedLinks(r,{outbound:!0}).filter((function(t){var{source:e,target:r}=t.attributes;return e&&e.id===n.id&&(!e.port||e.port===n.port)&&r&&r.id===i.id&&(!r.port||r.port===i.port)})).length>1)return!1}return!0},linkPinning:function(t,e){var{source:n,target:i}=e.attributes;return n.id&&i.id}}});!function(t,e,n){if(Vo(n)){if(!eh[n])throw new Error('Unknown wrapper: "'+n+'"');n=eh[n]}if(!Ko(n))throw new Error("Wrapper must be a function.");Qo(["resetCells","addCells","removeCells"]).forEach((function(e){t[e]=n(t[e])}))}(ih.prototype,0,eh.cells);var rh=function(t){this.cid=ds("view"),this.preinitialize.apply(this,arguments),$o(this,ls(t,sh)),this._ensureElement(),this.initialize.apply(this,arguments)},oh=/^(\S+)\s*(.*)$/,sh=["model","collection","el","id","attributes","className","tagName","events"];$o(rh.prototype,za,{tagName:"div",$:function(t){return this.$el.find(t)},preinitialize:function(){},initialize:function(){},render:function(){return this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.$el.remove()},setElement:function(t){return this.undelegateEvents(),this._setElement(t),this.delegateEvents(),this},_setElement:function(t){this.$el=t instanceof ma?t:ma(t),this.el=this.$el[0]},delegateEvents:function(t){if(t||(t=ss(this,"events")),!t)return this;for(var e in this.undelegateEvents(),t){var n=t[e];if(Ko(n)||(n=this[n]),n){var i=e.match(oh);this.delegate(i[1],i[2],n.bind(this))}}return this},delegate:function(t,e,n){return this.$el.on(t+".delegateEvents"+this.cid,e,n),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,n){return this.$el.off(t+".delegateEvents"+this.cid,e,n),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){if(this.el)this.setElement(ss(this,"el"));else{var t=$o({},ss(this,"attributes"));this.id&&(t.id=ss(this,"id")),this.className&&(t.class=ss(this,"className")),this.setElement(this._createElement(ss(this,"tagName"))),this._setAttributes(t)}},_setAttributes:function(t){this.$el.attr(t)}}),rh.extend=Ja;const ah={},lh=rh.extend({options:{},theme:null,themeClassNamePrefix:va("theme-"),requireSetThemeOverride:!1,defaultTheme:"default",children:null,childNodes:null,DETACHABLE:!0,UPDATE_PRIORITY:2,FLAG_INSERT:1<<30,FLAG_REMOVE:1<<29,FLAG_INIT:1<<28,constructor:function(t){this.requireSetThemeOverride=t&&!!t.theme,this.options=$o({},this.options,t),rh.call(this,t)},initialize:function(){ah[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){this.svgElement?this.vel.remove():this.$el.remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){if(t||(t=ss(this,"children")),t){var e=this.svgElement,n=ri.namespace[e?"svg":"xhtml"],i=ya(t,n);(e?this.vel:this.$el).empty().append(i.fragment),this.childNodes=i.selectors}return this},findAttribute:function(t,e){for(var n=e;n&&1===n.nodeType;){var i=n.getAttribute(t);if(i)return i;if(n===this.el)return null;n=n.parentNode}return null},_ensureElement:function(){if(this.el)this.setElement(ss(this,"el"));else{var t=ss(this,"tagName"),e=$o({},ss(this,"attributes")),n=$o({},ss(this,"style"));this.id&&(e.id=ss(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)}this._ensureElClassName()},_setAttributes:function(t){this.svgElement?this.vel.attr(t):this.$el.attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(ri.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof ma?t:ma(t),this.el=this.$el[0],this.svgElement&&(this.vel=ri(this.el))},_ensureElClassName:function(){var t=ss(this,"className");if(t){var e=va(t);this.svgElement?this.vel.removeClass(t).addClass(e):this.$el.removeClass(t).addClass(e)}},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.addClass(e):this.$el.addClass(e),this},removeThemeClassName:function(t){t=t||this.theme;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.removeClass(e):this.$el.removeClass(e),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),ah[this.cid]=null,rh.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(!e)return this;n||(n={});var i=this.getEventNamespace();for(var r in e){var o=e[r];"function"!=typeof o&&(o=this[o]),o&&ma(t).on(r+i,n,o.bind(this))}return this},undelegateElementEvents:function(t){return ma(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t||(t=ss(this,"documentEvents")),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var n=t.data,i="__"+this.cid+"__";return void 0===e?n&&n[i]||{}:(n||(n=t.data={}),n[i]||(n[i]={}),$o(n[i],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&$o({},t[0])||{},n=t[1]&&$o({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,rh.extend.call(this,e,n)}});function ch(t){return t?Array.isArray(t)?t:[t]:[]}const hh=lh.extend({tagName:"g",svgElement:!0,className:"highlight",HIGHLIGHT_FLAG:1,UPDATE_PRIORITY:3,DETACHABLE:!1,UPDATABLE:!0,MOUNTABLE:!0,cellView:null,nodeSelector:null,node:null,updateRequested:!1,postponedUpdate:!1,transformGroup:null,detachedTransformGroup:null,requestUpdate(t,e){const{paper:n}=t;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;const{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform(),0):(this.postponedUpdate=!0,0)},findNode(t,e=null){let n;if("string"==typeof e)n=t.findNode(e);else if(Jo(e)){const i=t.model.isLink(),{label:r=null,port:o,selector:s}=e;n=i&&null!==r?t.findLabelNode(r,s):!i&&o?t.findPortNode(o,s):t.findNode(s)}else e&&(n=ri.toNode(e),n instanceof SVGElement||(n=null));return n||null},getNodeMatrix(t,e){const{options:n}=this,{layer:i}=n,{rotatableNode:r}=t,o=t.getNodeMatrix(e);return r?i?r.contains(e)?o:t.getRootRotateMatrix().inverse().multiply(o):t.getNodeRotateMatrix(e).multiply(o):o},mount(){const{MOUNTABLE:t,cellView:e,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(!t||r)return;if(s)return this.update(e,a),void this.transform();const{vel:l,paper:c}=e,{layer:h}=i;if(h){let t;o?(t=o,this.detachedTransformGroup=null):t=ri("g").addClass("highlight-transform").append(n),this.transformGroup=t,c.getLayerView(h).insertSortedNode(t.node,i.z)}else n.parentNode&&!n.nextSibling||l.append(n)},unmount(){const{MOUNTABLE:t,transformGroup:e,vel:n}=this;t&&(e?(this.transformGroup=null,this.detachedTransformGroup=e,e.remove()):n.remove())},transform(){const{transformGroup:t,cellView:e,updateRequested:n}=this;if(!t||e.model.isLink()||n)return;const i=e.getRootTranslateMatrix(),r=e.getRootRotateMatrix(),o=i.multiply(r);t.attr("transform",ri.matrixToTransformString(o))},update(){const{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;if(i)return;this.postponedUpdate=!1;const o=this.node=this.findNode(e,n);t&&this.unhighlight(e,t),o?(this.highlight(e,o),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this))},onRemove(){const{node:t,cellView:e,id:n,constructor:i}=this;t&&this.unhighlight(e,t),this.unmount(),i._removeRef(e,n)},highlight(t,e){},unhighlight(t,e){},listenToUpdateAttributes(t){const e=ss(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){const{cellView:t}=this;if(!t)return;const{model:e,paper:n}=t;ss(this,"UPDATE_ATTRIBUTES").some((t=>e.hasChanged(t)))&&n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}},{_views:{},highlight:function(t,e,n){const i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){const i=this.uniqueId(e,n);this.remove(t,i)},get(t,e=null){const{cid:n}=t,{_views:i}=this,r=i[n];if(null===e){const t=[];if(!r)return t;for(let e in r){const n=r[e];n instanceof this&&t.push(n)}return t}if(!r)return null;if(e in r){const t=r[e];if(t instanceof this)return t}return null},add(t,e,n,i={}){if(!n)throw new Error("dia.HighlighterView: An ID required.");const r=hh.get(t,n);r&&r.remove();const o=new this(i);return o.id=n,this._addRef(t,n,o),o.requestUpdate(t,e),o.listenToUpdateAttributes(t),o},_addRef(t,e,n){const{cid:i}=t,{_views:r}=this;let o=r[i];o||(o=r[i]={}),o[e]=n},_removeRef(t,e){const{cid:n}=t,{_views:i}=this,r=i[n];if(r){e&&delete r[e];for(let t in r)return;delete i[n]}},remove(t,e=null){ch(this.get(t,e)).forEach((t=>{t.remove()}))},removeAll(t,e=null){const{_views:n}=this;for(let i in n)for(let r in n[i]){const o=n[i][r];o.cellView.paper===t&&o instanceof this&&(null===e||r===e)&&o.remove()}},update(t,e=null,n=!1){ch(this.get(t,e)).forEach((t=>{(n||t.UPDATABLE)&&t.update()}))},transform(t,e=null){ch(this.get(t,e)).forEach((t=>{t.UPDATABLE&&t.transform()}))},unmount(t,e=null){ch(this.get(t,e)).forEach((t=>t.unmount()))},mount(t,e=null){ch(this.get(t,e)).forEach((t=>t.mount()))},uniqueId:(t,e="")=>ri.ensureId(t)+JSON.stringify(e)}),uh=["transform","x","y","cx","cy","dx","dy","x1","y1","x2","y2","points","d","r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{}),dh=["r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{});function fh(t,e){const n={};for(let i in t)t.hasOwnProperty(i)&&(n[i]=ph(i,t[i],e));return n}function ph(t,e,n){if(t in uh&&yl(e)){let i=xl(e,n);return t in dh&&(i=Math.max(0,i)),i}return e}const gh={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},mh=lh.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var t=["cell"],e=this.model.get("type");return e&&e.toLowerCase().split(".").forEach((function(e,n,i){t.push("type-"+i.slice(0,n+1).join("-"))})),t.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e,n,i={},r={},o=0,s=ss(this,"presentationAttributes");for(var a in s)if(s.hasOwnProperty(a)){var l=s[a];for(Array.isArray(l)||(l=[l]),t=0,e=l.length;t<e;t++){var c=i[n=l[t]];c||(c=i[n]=1<<o++),r[a]|=c}}var h=ss(this,"initFlag");for(Array.isArray(h)||(h=[h]),t=0,e=h.length;t<e;t++)i[n=h[t]]||(i[n]=1<<o++);if(o>25)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=i,this._presentationAttributes=r},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var n=0;if(Array.isArray(t))for(var i=0,r=t.length;i<r;i++)n|=e[t[i]];else n|=e[t];return n},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||Ta(this),lh.call(this,t)},initialize:function(){this.setFlags(),lh.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){var n=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&n&&(e.dirty&&this.hasFlag(n,"UPDATE")&&(n|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(n,e))},requestUpdate:function(t,e){const{paper:n}=this;n&&t>0&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n=ya(t),i=n.selectors,r=n.groupSelectors;for(var o in r){if(i[o])throw new Error("dia.CellView: ambiguous group selector");i[o]=r[o]}if(e){var s=this.selector;if(i[s])throw new Error("dia.CellView: ambiguous root selector.");i[s]=e}return{fragment:n.fragment,selectors:i}},can:function(t){var e,n,i=Ko(this.options.interactive)?this.options.interactive(this):this.options.interactive;return Bo(i)&&!1!==i[t]||(e=i,n=Object.prototype.toString,(!0===e||!1===e||!!e&&"object"==typeof e&&n.call(e)===ai)&&!1!==i)},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){var i=n[t];if(i)return Array.isArray(i)?i:[i]}return this.useCSSSelectors?ma(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){const[e=null]=this.findNodes(t);return e},notify:function(t){if(this.paper){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e))}},getBBox:function(t){var e;if(t&&t.useModelGeometry){var n=this.model;e=n.getBBox().bbox(n.angle())}else e=this.getNodeBBox(this.el);return this.paper.localToPaperRect(e)},getNodeBBox:function(t){const e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),i=this.getNodeMatrix(t);return ri.transformRect(e,n.multiply(i))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():ri.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return ri.transformRect(e,i.multiply(n))},getRootTranslateMatrix:function(){var t=this.model.position();return ri.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t=ri.createSVGMatrix(),e=this.model,n=e.angle();if(n){var i=e.getBBox(),r=i.width/2,o=i.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t},_notifyHighlight:function(t,e,n={}){const{el:i}=this;let r;if("string"==typeof e?r=this.findNode(e)||i:[r=i]=this.$(e),n.partial=r!==i,void 0===n.type){let t;switch(!0){case n.embedding:t=gh.EMBEDDING;break;case n.connecting:t=gh.CONNECTING;break;case n.magnetAvailability:t=gh.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=gh.ELEMENT_AVAILABILITY;break;default:t=gh.DEFAULT}n.type=t}return this.notify(t,r,n),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e={}){return this._notifyHighlight("cell:unhighlight",t,e)},findMagnet:function(t){const e=this.el;let n=this.$(t)[0];n||(n=e);do{const t=n.getAttribute("magnet"),i=n===e;if((t||i)&&"false"!==t)return n;if(i)return;n=n.parentNode}while(n)},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const t=this.findNode(n);if(t)return t}return t},getSelector:function(t,e){var n;if(t===this.el)return"string"==typeof e&&(n=":scope > "+e),n;if(t){var i=ri(t).index()+1;n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)}return n},addLinkFromMagnet:function(t,e,n){var i=this.paper,r=i.model,o=i.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,n,o,"source"),target:{x:e,y:n}}).addTo(r,{async:!1,ui:!0}),o.findView(i)},getLinkEnd:function(t,...e){var n=this.model,i=n.id,r=this.findAttribute("port",t),o=t.getAttribute("joint-selector"),s={id:i};return null!=o&&(s.magnet=o),null!=r?(s.port=r,n.hasPort(r)||o||(s.selector=this.getSelector(t))):null==o&&this.el!==t&&(s.selector=this.getSelector(t)),this.customizeLinkEnd(s,t,...e)},customizeLinkEnd:function(t,e,n,i,r,o){const{paper:s}=this,{connectionStrategy:a}=s.options;if("function"==typeof a){var l=a.call(s,t,this,e,new Re(n,i),r,o,s);if(l)return l}return t},getMagnetFromLinkEnd:function(t){var e,n=t.port,i=t.magnet,r=this.model;return null!=n&&r.isElement()&&r.hasPort(n)?e=this.findPortNode(n,i)||this.el:(i||(i=t.selector),i||null==n||(i='[port="'+n+'"]'),e=this.findNode(i)),this.findProxyNode(e,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");const r=this.addLinkFromMagnet(e,n,i);r.notifyPointerdown(t,n,i),r.eventData(t,r.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:r})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var o=this.paper,s=o.options.magnetThreshold,a=this.getEventTarget(t),l=i.targetMagnet;if("onleave"===s){if(l===a||ri(l).contains(a))return}else if(o.eventData(t).mousemoved<=s)return;this.dragLinkStart(t,l,e,n)}},dragLinkEnd:function(t,e,n){var i=this.eventData(t).linkView;i&&(i.pointerup(t,e,n),this.model.stopBatch("add-link"))},getAttributeDefinition:function(t){return this.model.constructor.getAttributeDefinition(t)},setNodeAttributes:function(t,e){Xo(e)||(t instanceof SVGElement?ri(t).attr(e):ma(t).attr(e))},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,c,h,u=[];const d={};for(n in e)e.hasOwnProperty(n)&&(d[ri.attributeNames[n]]=e[n]);for(n in d)d.hasOwnProperty(n)&&(i=d[n],!(r=this.getAttributeDefinition(n))||Ko(r.qualify)&&!r.qualify.call(this,i,t,d,this)?(a||(a={}),a[n]=i):(Vo(r.set)&&(a||(a={}),a[r.set]=i),null!==i&&u.push(n,r)));for(o=0,s=u.length;o<s;o+=2)n=u[o],r=u[o+1],i=e[n],Ko(r.set)&&(l||(l={}),l[n]=i),Ko(r.position)&&(c||(c={}),c[n]=i),Ko(r.offset)&&(h||(h={}),h[n]=i);return{raw:d,normal:a,set:l,position:c,offset:h}},updateRelativeAttributes:function(t,e,n,i){var r,o;i||(i={});var s=fh(e.raw||{},n),a=e.normal||{};for(const t in a)a[t]=s[t];var l=e.set,c=e.position,h=e.offset;for(r in l){o=s[r];var u=this.getAttributeDefinition(r).set.call(this,o,n.clone(),t,s,this);Bo(u)?$o(a,u):void 0!==u&&(a[r]=u)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,g=a.transform,m=ri.transformStringToMatrix(g),v=Re(m.e,m.f);if(g&&(a=as(a,"transform"),m.e=m.f=0),c||h){var y=this.getNodeScale(t,i.scalableNode);d=y.sx,f=y.sy}var b=!1;for(r in c)o=s[r],(p=this.getAttributeDefinition(r).position.call(this,o,n.clone(),t,s,this))&&(v.offset(Re(p).scale(d,f)),b||(b=!0));this.setNodeAttributes(t,a);var w=!1;if(h){var x=this.getNodeBoundingRect(t);if(x.width>0&&x.height>0){var A=ri.transformRect(x,m).scale(1/d,1/f);for(r in h)o=s[r],(p=this.getAttributeDefinition(r).offset.call(this,o,A,t,s,this))&&(v.offset(Re(p).scale(d,f)),w||(w=!0))}}(void 0!==g||b||w)&&(v.round(1),m.e=v.x,m.f=v.y,t.setAttribute("transform",ri.matrixToTransformString(m)))}},getNodeScale:function(t,e){var n,i;if(e&&e.contains(t)){var r=e.scale();n=1/r.sx,i=1/r.sy}else n=1,i=1;return{sx:n,sy:i}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};var n=ri.ensureId(t),i=e[n];return i||(i=e[n]={}),i},getNodeData:function(t){var e=this.nodeCache(t);return e.data||(e.data={}),e.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=ri(t).getBBox()),new Je(e.boundingRect)},getNodeMatrix:function(t){const e=this.nodeCache(t);if(void 0===e.magnetMatrix){const{rotatableNode:n,el:i}=this;let r;r=n&&n.contains(t)?n:i,e.magnetMatrix=ri(t).getTransformToElement(r)}return ri.createSVGMatrix(e.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=ri(t).toGeometryShape()),e.geometryShape.clone()},isNodeConnection:function(t){return this.model.isLink()&&(!t||t===this.el)},findNodesAttributes:function(t,e,n,i){var r,o,s,a,l={},c=[];for(var h in t)if(t.hasOwnProperty(h)&&(s=t[h],Jo(s))){var u=n[h]=this.findBySelector(h,e,i);for(r=0,o=u.length;r<o;r++){var d=u[r];a=ri.ensureId(d);var f=i&&i[h]===d,p=l[a];if(p){p.array||(c.push(a),p.array=!0,p.attributes=[p.attributes],p.selectedLength=[p.selectedLength]);var g=p.attributes,m=p.selectedLength;if(f)g.unshift(s),m.unshift(-1);else{var v=Ho(m,o);g.splice(v,0,s),m.splice(v,0,o)}}else l[a]={attributes:s,selectedLength:f?-1:o,node:d,array:!1}}}for(r=0,o=c.length;r<o;r++)(s=l[a=c[r]]).attributes=fs({},...s.attributes.reverse());return l},getEventTarget:function(t,e={}){const{target:n,type:i,clientX:r=0,clientY:o=0}=t;return e.fromPoint||"touchmove"===i||"touchend"===i||"pointerId"in t&&n.hasPointerCapture(t.pointerId)?document.elementFromPoint(r,o):n},updateDOMSubtreeAttributes:function(t,e,n){n||(n={}),n.rootBBox||(n.rootBBox=Je()),n.selectors||(n.selectors=this.selectors);var i,r,o,s,a,l={},c={},h=[],u=[],d=n.roAttributes,f=this.findNodesAttributes(d||e,t,l,n.selectors),p=d?this.findNodesAttributes(e,t,l,n.selectors):f;for(var g in f)if(o=(s=f[g]).attributes,r=s.node,(a=this.processNodeAttributes(r,o)).set||a.position||a.offset||a.raw.ref){var m,v=p[g]&&p[g].attributes,y=v&&void 0===o.ref?v.ref:o.ref;if(y){if(!(m=(l[y]||this.findBySelector(y,t,n.selectors))[0]))throw new Error('dia.CellView: "'+y+'" reference does not exist.')}else m=null;if(i={node:r,refNode:m,processedAttributes:a,allAttributes:v},m){var b=u.findIndex((function(t){return t.refNode===r}));b>-1?u.splice(b,0,i):u.push(i)}else h.push(i)}else this.setNodeAttributes(r,fh(a.normal,n.rootBBox));h.push(...u);for(let t=0,e=h.length;t<e;t++){i=h[t],r=i.node;const e=(m=i.refNode)?ri.ensureId(m):"";let o=c[e];o||(o=c[e]=m?ri(m).getBBox({target:vh(r,m)}):n.rootBBox),d?(a=this.processNodeAttributes(r,i.allAttributes),this.mergeProcessedAttributes(a,i.processedAttributes)):a=i.processedAttributes,this.updateRelativeAttributes(r,a,o,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),$o(t.set,e.set),$o(t.position,e.position),$o(t.offset,e.offset);var n=t.normal&&t.normal.transform;void 0!==n&&e.normal&&(e.normal.transform=n),t.normal=e.normal},onMount(t){t||(this.mountTools(),hh.mount(this))},onDetach(){this.unmountTools(),hh.unmount(this)},onRemove:function(){this.removeTools(),this.removeHighlighters()},_toolsView:null,hasTools:function(t){var e=this._toolsView;return!(!e||t&&e.getName()!==t)},addTools:function(t){return this.removeTools(),t&&(this._toolsView=t,t.configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){const t=this._toolsView;return t&&t.unmount(),this},mountTools(){const t=this._toolsView;return t&&!t.isMounted()&&t.mount(),this},updateTools:function(t){var e=this._toolsView;return e&&e.update(t),this},removeTools:function(){var t=this._toolsView;return t&&(t.remove(),this._toolsView=null),this},hideTools:function(){var t=this._toolsView;return t&&t.hide(),this},showTools:function(){var t=this._toolsView;return t&&t.show(),this},onToolEvent:function(t){switch(t){case"remove":this.removeTools();break;case"hide":this.hideTools();break;case"show":this.showTools()}},removeHighlighters:function(){hh.remove(this)},updateHighlighters:function(t=!1){hh.update(this,null,t)},transformHighlighters:function(){hh.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){const{defaultInteractionPrevented:e=!1}=this.eventData(t);return e},pointerdblclick:function(t,e,n){this.notify("cell:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){this.notify("cell:pointerclick",t,e,n)},contextmenu:function(t,e,n){this.notify("cell:contextmenu",t,e,n)},pointerdown:function(t,e,n){const{model:i}=this,{graph:r}=i;r&&(i.startBatch("pointer"),this.eventData(t,{graph:r})),this.notify("cell:pointerdown",t,e,n)},pointermove:function(t,e,n){this.notify("cell:pointermove",t,e,n)},pointerup:function(t,e,n){const{graph:i}=this.eventData(t);this.notify("cell:pointerup",t,e,n),i&&i.stopBatch("pointer",{cell:this.model})},mouseover:function(t){this.notify("cell:mouseover",t)},mouseout:function(t){this.notify("cell:mouseout",t)},mouseenter:function(t){this.notify("cell:mouseenter",t)},mouseleave:function(t){this.notify("cell:mouseleave",t)},mousewheel:function(t,e,n,i){this.notify("cell:mousewheel",t,e,n,i)},onevent:function(t,e,n,i){this.notify(e,t,n,i)},onmagnet:function(){},magnetpointerdblclick:function(){},magnetcontextmenu:function(){},checkMouseleave(t){const{paper:e,model:n}=this;if(e.isAsync()){if(n.isLink()){const t=n.getSourceElement();if(t){const n=e.findViewByModel(t);n&&(e.dumpView(n),e.checkViewVisibility(n))}const i=n.getTargetElement();if(i){const t=e.findViewByModel(i);t&&(e.dumpView(t),e.checkViewVisibility(t))}}e.dumpView(this),e.checkViewVisibility(this)}const i=this.getEventTarget(t,{fromPoint:!0}),r=e.findView(i);r!==this&&(this.mouseleave(t),r&&r.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Flags:{TOOLS:"TOOLS"},Highlighting:gh,addPresentationAttributes:function(t){return fs({},ss(this.prototype,"presentationAttributes"),t,(function(t,e){if(t&&e)return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),Array.isArray(t)&&Array.isArray(e)?qo(t.concat(e)):void 0}))},evalAttribute:ph});function vh(t,e){let n=t;do{if(n.contains(e))return n;n=n.parentNode}while(n);return null}Object.defineProperty(mh.prototype,"useCSSSelectors",{get(){const t=this.model.useCSSSelectors;return void 0!==t&&t}});const yh={TOOLS:mh.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},bh="move",wh="magnet",xh=mh.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=mh.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){mh.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[yh.UPDATE],position:[yh.TRANSLATE,yh.TOOLS],size:[yh.RESIZE,yh.PORTS,yh.TOOLS],angle:[yh.ROTATE,yh.TOOLS],markup:[yh.RENDER],ports:[yh.PORTS]},initFlag:[yh.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){const{useCSSSelectors:n}=this;this.hasFlag(t,yh.PORTS)&&(this._removePorts(),this._cleanPortsCache());let i=!1;if(this.hasFlag(t,yh.RENDER))this.render(),this.updateTools(e),this.updateHighlighters(!0),i=!0,t=this.removeFlag(t,[yh.RENDER,yh.UPDATE,yh.RESIZE,yh.TRANSLATE,yh.ROTATE,yh.PORTS,yh.TOOLS]);else{let r=!1;this.hasFlag(t,yh.RESIZE)&&(this.resize(e),r=!0,t=this.removeFlag(t,[yh.RESIZE,yh.UPDATE]),n&&(t=this.removeFlag(t,yh.PORTS))),this.hasFlag(t,yh.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,yh.UPDATE),r=!0,n&&(t=this.removeFlag(t,yh.PORTS))),this.hasFlag(t,yh.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,yh.TRANSLATE),i=!0),this.hasFlag(t,yh.ROTATE)&&(this.rotate(),t=this.removeFlag(t,yh.ROTATE),i=!0),this.hasFlag(t,yh.PORTS)&&(this._renderPorts(),r=!0,t=this.removeFlag(t,yh.PORTS)),r&&this.updateHighlighters(!1)}return i&&this.transformHighlighters(),this.hasFlag(t,yh.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,yh.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();const{useCSSSelectors:n}=this;n&&this._removePorts();var i=this.model,r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new Je(i.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),n&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.ElementView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el),n=this.selectors=e.selectors;this.rotatableNode=ri(n[this.rotatableSelector])||null,this.scalableNode=ri(n[this.scalableSelector])||null,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(ri(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),this.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;var n=t.size;return"rotate("+e+","+n.width/2+","+n.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,n=e.angle(),i=e.size(),r=this.scalableNode,o=!1;r.node.getElementsByTagName("path").length>0&&(o=!0);var s=r.getBBox({recursive:o}),a=i.width/(s.width||1),l=i.height/(s.height||1);r.attr("transform","scale("+a+","+l+")");var c=this.rotatableNode,h=c&&c.attr("transform");if(h){c.attr("transform",h+" rotate("+-n+","+i.width/2+","+i.height/2+")");var u=r.getBBox({target:this.paper.cells});e.set("position",{x:u.x,y:u.y},$o({updateHandled:!0},t)),this.translate(),this.rotate()}this.update()},prepareEmbedding:function(t={}){const e=t.model||this.model,n=(t.paper||this.paper).model,i=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=n.getConnectedLinks(e,{deep:!0,includeEnclosed:!0});[e,...r,...o].forEach((t=>i[t.id]=t.attributes.z)),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0});const s=n.getElements().reduce(((t,e)=>Math.max(t,e.attributes.z||0)),0);o.forEach((t=>{t.attributes.z<=s&&t.set("z",s+1,{ui:!0})})),e.stopBatch("to-front");const a=e.parent();a?(n.getCell(a).unembed(e,{ui:!0}),t.initialParentId=a):t.initialParentId=null},processEmbedding:function(t={},e,n,i){const r=t.model||this.model,o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:c}=o.options;let h;h=Ko(a)?Qo(a.call(s,this,e,n,i)):"pointer"===a?Qo(s.findModelsFromPoint({x:n,y:i})):s.findModelsUnderElement(r,{searchBy:a}),h=h.filter((t=>t instanceof Ul&&r.id!==t.id&&!t.isEmbeddedIn(r))),l&&(h=h.slice(-1));let u=null;const d=t.candidateEmbedView;for(let t=h.length-1;t>=0;t--){const e=h[t];if(d&&d.model.id==e.id){u=d;break}{const t=e.findView(o);if(!Ko(c)||c.call(o,this,t)){u=t;break}}}u&&u!=d&&(this.clearEmbedding(t),t.candidateEmbedView=u.highlight(u.findProxyNode(null,"container"),{embedding:!0})),!u&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){t||(t={});var e=t.candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t={}){const e=t.candidateEmbedView,n=t.model||this.model,i=t.paper||this.paper;if(e)e.model.embed(n,{ui:!0}),e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null;else{const{validateUnembedding:e}=i.options,{initialParentId:n}=t;if(n&&"function"==typeof e&&!e.call(i,this))return void this._disallowUnembed(t)}i.model.getConnectedLinks(n,{deep:!0}).forEach((t=>{t.reparent({ui:!0})}))},_disallowUnembed:function(t){const{model:e,whenNotAllowed:n="revert"}=t,i=e||this.model,r=(t.paper||this.paper).model;switch(n){case"remove":i.remove({ui:!0});break;case"revert":{const{initialParentId:e,initialPosition:n,initialZIndices:o}=t;if(n){const{x:t,y:e}=n;i.position(t,e,{deep:!0,ui:!0})}o&&Object.keys(o).forEach((t=>{const e=r.getCell(t);e&&e.set("z",o[t],{ui:!0})}));const s=r.getCell(e);s&&s.embed(i,{ui:!0});break}}},getDelegatedView:function(){for(var t=this,e=t.model,n=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=n.findViewByModel(e)}return null},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const e=this.findAttribute("port",t);if(e){const t=this.findPortNode(e,n);if(t)return t}else{const t=this.findNode(n);if(t)return t}}return t},notifyPointerdown(t,e,n){mh.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){mh.prototype.pointermove.call(this,t,e,n),this.notify("element:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("element:pointerup",t,e,n),mh.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){mh.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){mh.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){mh.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case wh:this.dragMagnet(t,e,n);break;case bh:(s||this).drag(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case wh:this.dragMagnetEnd(t,e,n);break;case bh:(s||this).dragEnd(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){mh.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){mh.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){mh.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){mh.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){mh.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){const{currentTarget:i}=t;this.magnetpointerdown(t,i,e,n),this.eventData(t,{targetMagnet:i}),this.dragMagnetStart(t,e,n)},magnetpointerdown:function(t,e,n,i){this.notify("element:magnet:pointerdown",t,e,n,i)},magnetpointermove:function(t,e,n,i){this.notify("element:magnet:pointermove",t,e,n,i)},magnetpointerup:function(t,e,n,i){this.notify("element:magnet:pointerup",t,e,n,i)},magnetpointerdblclick:function(t,e,n,i){this.notify("element:magnet:pointerdblclick",t,e,n,i)},magnetcontextmenu:function(t,e,n,i){this.notify("element:magnet:contextmenu",t,e,n,i)},dragStart:function(t,e,n){if(this.isDefaultInteractionPrevented(t))return;var i=this.getDelegatedView();if(!i||!i.can("elementMove"))return;this.eventData(t,{action:bh,delegatedView:i});const r=i.model.position();i.eventData(t,{initialPosition:r,pointerOffset:r.difference(e,n),restrictedArea:this.paper.getRestrictedArea(i,e,n)})},dragMagnetStart:function(t,e,n){const{paper:i}=this,r=t.isPropagationStopped();if(r&&this.eventData(t,{preventPointerEvents:!0}),this.isDefaultInteractionPrevented(t)||!this.can("addLinkFromMagnet"))return;const{targetMagnet:o=t.currentTarget}=this.eventData(t);t.stopPropagation(),i.options.validateMagnet.call(i,this,o,t)?(i.options.magnetThreshold<=0&&this.dragLinkStart(t,o,e,n),this.eventData(t,{action:wh})):r?this.dragStart(t,e,n):this.pointerdown(t,e,n)},drag:function(t,e,n){var i=this.paper,r=i.options.gridSize,o=this.model,s=this.eventData(t),{pointerOffset:a,restrictedArea:l,embedding:c}=s,h=fe(e+a.x,r),u=fe(n+a.y,r);o.position(h,u,{restrictedArea:l,deep:!0,ui:!0}),i.options.embeddingMode&&(c||(this.prepareEmbedding(s),c=!0),this.processEmbedding(s,t,e,n)),this.eventData(t,{embedding:c})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){var i=this.eventData(t);i.embedding&&this.finalizeEmbedding(i)},dragMagnetEnd:function(t,e,n){this.dragLinkEnd(t,e,n)},magnetpointerclick:function(t,e,n,i){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,n,i)}},{Flags:yh});$o(xh.prototype,Ac);const Ah=function(t,e,n){return t},Eh=function(t,e,n){var i,r,o,s=e.side||"bottom",a=Fa(e.padding||40),l=n.sourceBBox,c=n.targetBBox,h=l.center(),u=c.center();switch(s){case"bottom":o=1,i="y",r="height";break;case"top":o=-1,i="y",r="height";break;case"left":o=-1,i="x",r="width";break;case"right":o=1,i="x",r="width";break;default:throw new Error("Router: invalid side")}return h[i]+=o*(l[r]/2+a[s]),u[i]+=o*(c[r]/2+a[s]),o*(h[i]-u[i])>0?u[i]=h[i]:h[i]=u[i],[h].concat(t,u)};var Th={N:"S",S:"N",E:"W",W:"E"},Sh={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function _h(t,e,n){var i=new Re(t.x,e.y);return n.containsPoint(i)&&(i=new Re(e.x,t.y)),i}function Ph(t,e){return t["W"===e||"E"===e?"width":"height"]}function kh(t,e){return t.x===e.x?t.y>e.y?"N":"S":t.y===e.y?t.x>e.x?"W":"E":null}function Ch(t){return new Je(t.x,t.y,0,0)}function Lh(t){var e=Fa(t.padding||t.elementPadding||20);return{x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}function Mh(t,e){return t.sourceBBox.clone().moveAndExpand(Lh(e))}function Oh(t,e){return t.targetBBox.clone().moveAndExpand(Lh(e))}function Nh(t,e,n){var i=new Re(t.x,e.y),r=new Re(e.x,t.y),o=kh(t,i),s=kh(t,r),a=Th[n],l=o===n||o!==a&&(s===a||s!==n)?i:r;return{points:[l],direction:kh(l,e)}}function Rh(t,e,n){var i=_h(t,e,n);return{points:[i],direction:kh(i,e)}}function Fh(t,e,n,i){var r,o={},s=[new Re(t.x,e.y),new Re(e.x,t.y)],a=s.filter((function(t){return!n.containsPoint(t)})),l=a.filter((function(e){return kh(e,t)!==i}));if(l.length>0)r=(r=l.filter((function(e){return kh(t,e)===i})).pop())||l[0],o.points=[r],o.direction=kh(r,e);else{r=is(s,a)[0];var c=new Re(e).move(r,-Ph(n,i)/2),h=_h(c,t,n);o.points=[h,c],o.direction=kh(c,e)}return o}function Ih(t,e,n,i){var r=Rh(e,t,i),o=r.points[0];if(n.containsPoint(o)){var s=(r=Rh(t,e,n)).points[0];if(i.containsPoint(s)){var a=new Re(t).move(s,-Ph(n,kh(t,s))/2),l=new Re(e).move(o,-Ph(i,kh(e,o))/2),c=new De(a,l).midpoint(),h=Rh(t,c,n),u=Nh(c,e,h.direction);r.points=[h.points[0],u.points[0]],r.direction=u.direction}}return r}function Bh(t,e,n,i,r){var o,s,a,l={},c=n.union(i).inflate(1),h=c.center().distance(e)>c.center().distance(t),u=h?e:t,d=h?t:e;return r?(o=Re.fromPolar(c.width+c.height,Sh[r],u),o=c.pointNearestToPoint(o).move(o,-1)):o=c.pointNearestToPoint(u).move(u,1),s=_h(o,d,c),o.round().equals(s.round())?(s=Re.fromPolar(c.width+c.height,ge(o.theta(u))+Math.PI/2,d),a=_h(o,s=c.pointNearestToPoint(s).move(d,1).round(),c),l.points=h?[s,a,o]:[o,a,s]):l.points=h?[s,o]:[o,s],l.direction=kh(h?o:s,e),l}function Dh(t,e,n){var i,r=Mh(n,e),o=Oh(n,e),s=function(t,e){return t.sourceAnchor?t.sourceAnchor:Mh(t,e).center()}(n,e),a=function(t,e){return t.targetAnchor?t.targetAnchor:Oh(t,e).center()}(n,e);r=r.union(Ch(s)),o=o.union(Ch(a)),(t=Qo(t).map(Re)).unshift(s),t.push(a);for(var l=[],c=0,h=t.length-1;c<h;c++){var u=null,d=t[c],f=t[c+1],p=!!kh(d,f);if(0===c)c+1===h?r.intersect(o.clone().inflate(1))?u=Bh(d,f,r,o):p||(u=Ih(d,f,r,o)):r.containsPoint(f)?u=Bh(d,f,r,Ch(f).moveAndExpand(Lh(e))):p||(u=Rh(d,f,r));else if(c+1===h){var g=p&&kh(f,d)===i;o.containsPoint(d)||g?u=Bh(d,f,Ch(d).moveAndExpand(Lh(e)),o,i):p||(u=Fh(d,f,o,i))}else p||(u=Nh(d,f,i));u?(Array.prototype.push.apply(l,u.points),i=u.direction):i=kh(d,f),c+1<h&&l.push(f)}return l}var Vh={step:10,maximumLoops:2e3,precision:1,maxAllowedDirectionChange:90,perpendicular:!0,excludeEnds:[],excludeTypes:[],startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},cost:function(){return this.step},directions:function(){var t=this.step,e=this.cost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:-t,offsetY:0,cost:e},{offsetX:0,offsetY:t,cost:e},{offsetX:0,offsetY:-t,cost:e}]},penalties:function(){return{0:0,45:this.step/2,90:this.step/2}},paddingBox:function(){var t=this.step;return{x:-t,y:-t,width:2*t,height:2*t}},isPointObstacle:null,fallbackRouter:function(t,e,n){if(!Ko(Dh))throw new Error("Manhattan requires the orthogonal router as default fallback.");return Dh(t,$o({},Vh,e),n)},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function $h(t){this.map={},this.options=t,this.mapGridSize=100}function zh(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function jh(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function Uh(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function Gh(t,e){return t.sourceAnchor?t.sourceAnchor:jh(t,e).center()}function Hh(t,e,n,i,r){var o=360/n,s=t.theta(function(t,e,n,i){var r=i.step,o=e.x-t.x,s=e.y-t.y,a=o/n.x*r,l=s/n.y*r;return new Re(t.x+a,t.y+l)}(t,e,i,r)),a=de(s+o/2);return o*Math.floor(a/o)}function qh(t,e){var n=Math.abs(t-e);return n>180?360-n:n}function Wh(t,e){if(!t)return e;var n=Math.abs(t),i=Math.round(n/e);return i?e+(n-i*e)/i:n}function Yh(t,e){return t.round(e)}function Xh(t,e,n){return Yh(function(t,e){var n=e.source,i=fe(t.x-n.x,e.x)+n.x,r=fe(t.y-n.y,e.y)+n.y;return new Re(i,r)}(t.clone(),e),n)}function Zh(t){return t.clone().toString()}function Kh(t){return new Re(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function Jh(t,e,n,i,r,o,s){for(var a,l=[],c=Kh(r.difference(n)),h=Zh(n),u=t[h];u;){var d=Kh((a=e[h]).difference(u));d.equals(c)||(l.unshift(a),c=d),u=t[h=Zh(u)]}var f=e[h];return Kh(f.difference(i)).equals(c)||l.unshift(f),l}function Qh(t,e){for(var n=1/0,i=0,r=e.length;i<r;i++){var o=t.manhattanDistance(e[i]);o<n&&(n=o)}return n}function tu(t,e,n,i,r){var o=r.precision,s=r.directionMap,a=t.difference(e.center()),l=Bo(s)?Object.keys(s):[],c=Qo(n),h=l.reduce((function(n,r){if(c.includes(r)){for(var l,h=s[r],u=new Re(t.x+h.x*(Math.abs(a.x)+e.width),t.y+h.y*(Math.abs(a.y)+e.height)),d=new De(t,u).intersect(e)||[],f=d.length,p=null,g=0;g<f;g++){var m=d[g],v=t.squaredDistance(m);(void 0===l||v>l)&&(l=v,p=m)}if(p){var y=Xh(p,i,o);e.containsPoint(y)&&(y=Xh(y.offset(h.x*i.x,h.y*i.y),i,o)),n.push(y)}}return n}),[]);return e.containsPoint(t)||h.push(Xh(t,i,o)),h}function eu(t,e,n,i){var r,o,s=i.precision;r=Yh(t instanceof Je?Gh(this,i).clone():t.clone(),s),o=Yh(e instanceof Je?function(t,e){return t.targetAnchor?t.targetAnchor:Uh(t,e).center()}(this,i).clone():e.clone(),s);var a,l,c,h,u,d,f,p=(a=i.step,c=o,{source:(l=r).clone(),x:Wh(c.x-l.x,a),y:Wh(c.y-l.y,a)});if(d=t instanceof Je?tu(h=r,t,i.startDirections,p,i):[h=r],e instanceof Je?(u=o,f=tu(o,e,i.endDirections,p,i)):f=[u=o],d=d.filter((t=>!n(t))),f=f.filter((t=>!n(t))),d.length>0&&f.length>0){for(var g=new zh,m={},v={},y={},b=0,w=d.length;b<w;b++){var x=d[b],A=Zh(x);g.add(A,Qh(x,f)),m[A]=x,y[A]=0}var E,T,S=i.previousDirectionAngle,_=void 0===S,P=i.directions;!function(t,e,n){var i=n.step;Qo(n.directions).forEach((function(t){t.gridOffsetX=t.offsetX/i*e.x,t.gridOffsetY=t.offsetY/i*e.y}))}(0,p,i);for(var k=P.length,C=Qo(f).reduce((function(t,e){var n=Zh(e);return t.push(n),t}),[]),L=i.maximumLoops;!g.isEmpty()&&L>0;){var M,O=g.pop(),N=m[O],R=v[O],F=y[O],I=void 0===R,B=N.equals(h);M=I?_?B?null:Hh(h,N,k,p,i):S:Hh(R,N,k,p,i);var D=d.length===f.length;if(D)for(var V=0;V<d.length;V++)if(!d[V].equals(f[V])){D=!1;break}if((!I||!D)&&C.indexOf(O)>=0)return i.previousDirectionAngle=M,Jh(v,m,N,h,u);for(b=0;b<k;b++){var $=(E=P[b]).angle;if(T=qh(M,$),_&&B||!(T>i.maxAllowedDirectionChange)){var z=Xh(N.clone().offset(E.gridOffsetX,E.gridOffsetY),p,s),j=Zh(z);if(!g.isClose(j)&&!n(z)){if(C.indexOf(j)>=0&&!z.equals(u)&&qh($,Hh(z,u,k,p,i))>i.maxAllowedDirectionChange)continue;var U=F+E.cost+(B?0:i.penalties[T]);(!g.isOpen(j)||U<y[j])&&(m[j]=z,v[j]=N,y[j]=U,g.add(j,U+Qh(z,f)))}}}L--}}return i.fallbackRoute.call(this,h,u,i)}$h.prototype.build=function(t,e){var n=this.options,i=Qo(n.excludeEnds).reduce((function(n,i){var r=e.get(i);if(r){var o=t.getCell(r.id);o&&n.push(o)}return n}),[]),r=[],o=t.getCell(e.get("source").id);o&&(r=rs(r,o.getAncestors().map((function(t){return t.id}))));var s=t.getCell(e.get("target").id);s&&(r=rs(r,s.getAncestors().map((function(t){return t.id}))));var a=this.mapGridSize;return t.getElements().reduce((function(t,e){var o=Qo(n.excludeTypes).includes(e.get("type")),s=i.find((function(t){return t.id===e.id})),l=r.includes(e.id);if(!(o||s||l))for(var c=e.getBBox().moveAndExpand(n.paddingBox),h=c.origin().snapToGrid(a),u=c.corner().snapToGrid(a),d=h.x;d<=u.x;d+=a)for(var f=h.y;f<=u.y;f+=a){var p=d+"@"+f;t[p]=t[p]||[],t[p].push(c)}return t}),this.map),this},$h.prototype.isPointAccessible=function(t){var e=t.clone().snapToGrid(this.mapGridSize).toString();return Qo(this.map[e]).every((function(e){return!e.containsPoint(t)}))},zh.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;var n=Ho(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(n,0,t)},zh.prototype.remove=function(t){this.hash[t]=this.CLOSE},zh.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},zh.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},zh.prototype.isEmpty=function(){return 0===this.items.length},zh.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};const nu=function(t,e,n){return function(t,e,n){!function(t){if(t.directions=ss(t,"directions"),t.penalties=ss(t,"penalties"),t.paddingBox=ss(t,"paddingBox"),t.padding=ss(t,"padding"),t.padding){var e=Fa(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}Qo(t.directions).forEach((function(t){var e=new Re(0,0),n=new Re(t.offsetX,t.offsetY);t.angle=de(e.theta(n))}))}(e),n.options.perpendicular=!!e.perpendicular;var i=jh(n,e),r=Uh(n,e),o=Gh(n,e);let s;if("function"==typeof e.isPointObstacle)s=e.isPointObstacle;else{const t=new $h(e);t.build(n.paper.model,n.model),s=e=>!t.isPointAccessible(e)}for(var a,l,c=Qo(t).map(Re),h=[],u=o,d=0,f=c.length;d<=f;d++){var p=null;if(l=a||i,!(a=c[d])&&(a=r,(!n.model.get("source").id||!n.model.get("target").id)&&Ko(e.draggingRoute))){var g=l===i?o:l,m=a.origin();p=e.draggingRoute.call(n,g,m,e)}if(null===(p=p||eu.call(n,l,a,s,e)))return e.fallbackRouter(t,e,n);var v=p[0];v&&v.equals(u)&&p.shift(),u=p[p.length-1]||u,Array.prototype.push.apply(h,p)}return h}(t,$o({},Vh,e),n)};var iu={maxAllowedDirectionChange:45,diagonalCost:function(){var t=this.step;return Math.ceil(Math.sqrt(t*t<<1))},directions:function(){var t=this.step,e=this.cost(),n=this.diagonalCost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:t,offsetY:t,cost:n},{offsetX:0,offsetY:t,cost:e},{offsetX:-t,offsetY:t,cost:n},{offsetX:-t,offsetY:0,cost:e},{offsetX:-t,offsetY:-t,cost:n},{offsetX:0,offsetY:-t,cost:e},{offsetX:t,offsetY:-t,cost:n}]},fallbackRoute:function(t,e,n){var i=t.theta(e),r=[],o={x:e.x,y:t.y},s={x:t.x,y:e.y};if(i%180>90){var a=o;o=s,s=a}var l=i%90<45?o:s,c=new De(t,l),h=90*Math.ceil(i/90),u=Re.fromPolar(c.squaredLength(),ge(h+135),l),d=new De(e,u),f=c.intersection(d),p=f||e,g=f?p:t,m=360/n.directions.length,v=g.theta(e),y=de(v+m/2),b=m*Math.floor(y/m);return n.previousDirectionAngle=b,p&&r.push(p.round()),r.push(e),r}};const ru=function(t,e,n){if(!Ko(nu))throw new Error("Metro requires the manhattan router.");return nu(t,$o({},iu,e),n)},ou={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},su=[ou.LEFT,ou.RIGHT,ou.TOP,ou.BOTTOM],au={[ou.LEFT]:ou.RIGHT,[ou.RIGHT]:ou.LEFT,[ou.TOP]:ou.BOTTOM,[ou.BOTTOM]:ou.TOP},lu=[ou.TOP,ou.BOTTOM],cu={0:ou.RIGHT,180:ou.LEFT,270:ou.TOP,90:ou.BOTTOM};function hu(t){return t.angle()}function uu(t){return new rn(t).simplify({threshold:1}).points}function du(t,e){const{point:n,x0:i,y0:r,view:o,bbox:s,direction:a}=t,{point:l,x0:c,y0:h,view:u,bbox:d,direction:f}=e;let p,g;if(o)p=o.model.isLink()?fu(l,n,o):a===ou.ANCHOR_SIDE?s.sideNearestToPoint(n):a===ou.MAGNET_SIDE?o.model.getBBox().sideNearestToPoint(n):a;else{const t=new Je(i,r,0,0);p=su.includes(a)?a:t.sideNearestToPoint(l)}if(u)g=u.model.isLink()?fu(n,l,u):f===ou.ANCHOR_SIDE?d.sideNearestToPoint(l):f===ou.MAGNET_SIDE?u.model.getBBox().sideNearestToPoint(l):f;else{const t=new Je(c,h,0,0);g=su.includes(f)?f:t.sideNearestToPoint(n)}return[p,g]}function fu(t,e,n){const i=n.getTangentAtLength(n.getClosestPointLength(e)),r=90*Math.round(hu(i)/90);if(r%180==0&&t.y===e.y)return t.x<e.x?ou.LEFT:ou.RIGHT;if(t.x===e.x)return t.y<e.y?ou.TOP:ou.BOTTOM;switch(r){case 0:case 180:case 360:return t.y<e.y?ou.TOP:ou.BOTTOM;case 90:case 270:return t.x<e.x?ou.LEFT:ou.RIGHT}}function pu(t,e,n,i,r,o,s){i===ou.AUTO&&(i=r?ou.MAGNET_SIDE:ou.ANCHOR_SIDE);const a=t&&t.model.isElement(),{x:l,y:c,width:h=0,height:u=0}=a?Je.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:l,y0:c,view:t,bbox:n,width:h,height:u,direction:i,margin:a?s:0}}function gu({x:t,y:e}){const n=new Re(t,e);return{point:n,x0:n.x,y0:n.y,view:null,bbox:new Je(t,e,0,0),width:0,height:0,direction:null,margin:0}}function mu(t,e,n){const i=e.point.clone(),{x0:r,y0:o,width:s,height:a}=e;switch(t){case"left":i.x=r-n;break;case"right":i.x=r+s+n;break;case"top":i.y=o-n;break;case"bottom":i.y=o+a+n}return i}function vu(t,e){const{point:n,x0:i,y0:r,view:o,width:s,height:a,margin:l}=t,{point:c,x0:h,y0:u,width:d,height:f,margin:p}=e,g=h+d,m=u+f,v=i+s,y=r+a,b=o&&o.model.isElement(),w=i-l,x=v+l,A=r-l,E=y+l,T=h-p,S=g+p,_=u-p,P=m+p,[k,C]=du(t,e),L=mu(k,{point:n,x0:i,y0:r,width:s,height:a},l),M=mu(C,{point:c,x0:h,y0:u,width:d,height:f},p),{x:O,y:N}=L,{x:R,y:F}=M,I=(u+m)/2,B=((i+v)/2<(h+g)/2?v+h:g+i)/2,D=((r+y)/2<I?y+u:m+r)/2;if("left"===k&&"right"===C){if(w<=S){let t=D;return v<=h&&(m>=A&&F<N?t=Math.min(_,A):u<=E&&F>=N&&(t=Math.max(P,E))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("right"===k&&"left"===C){if(x>=T){let t=D;return O>g&&(m>=A&&F<N?t=Math.min(_,A):u<=E&&F>=N&&(t=Math.max(P,E))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("top"===k&&"bottom"===C){if(N<F){let t=B,e=N;return N<u&&(g>=w&&R<O?t=Math.min(T,w):h<=x&&R>=O&&(t=Math.max(S,x))),[{x:O,y:e},{x:t,y:e},{x:t,y:F},{x:R,y:F}]}const t=(N+F)/2;return[{x:O,y:t},{x:R,y:t}]}if("bottom"===k&&"top"===C){if(N-l>F){let t=B,e=N;return N>m&&(g>=w&&R<O?t=Math.min(T,w):h<=x&&R>=O&&(t=Math.max(S,x))),[{x:O,y:e},{x:t,y:e},{x:t,y:F},{x:R,y:F}]}const t=(N+F)/2;return[{x:O,y:t},{x:R,y:t}]}if("top"===k&&"top"===C){let t,e=Math.min((y+u)/2,F),n=Math.min((r+m)/2,N);if(F<N){if(O>=S||O<=T)return[{x:O,y:Math.min(N,F)},{x:R,y:Math.min(N,F)}];t=R>O?Math.min(O,T):Math.max(O,S)}else{if(R>=x||R<=w)return[{x:O,y:Math.min(N,F)},{x:R,y:Math.min(N,F)}];t=R>=O?Math.max(R,x):Math.min(R,w)}return[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("bottom"===k&&"bottom"===C){let t,e=Math.max((r+m)/2,F),n=Math.max((y+u)/2,N);if(F>N){if(O>=S||O<=T)return[{x:O,y:Math.max(N,F)},{x:R,y:Math.max(N,F)}];t=R>O?Math.min(O,T):Math.max(O,S)}else{if(R>=x||R<=w)return[{x:O,y:Math.max(N,F)},{x:R,y:Math.max(N,F)}];t=R>=O?Math.max(R,x):Math.min(R,w)}return[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("left"===k&&"left"===C){let t,e=Math.min((v+h)/2,R),n=Math.min((i+g)/2,O);return t=R>O?F<=N?Math.min(A,F):Math.max(E,F):F>=N?Math.min(_,N):Math.max(P,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("right"===k&&"right"===C){let t,e=Math.max((i+g)/2,R),n=Math.max((v+h)/2,O);return t=R<O?F<=N?Math.min(A,F):Math.max(E,F):F>=N?Math.min(_,N):Math.max(P,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("top"===k&&"right"===C){if(N>F){if(O<R){let t=D;return(t>I||!b)&&t<P&&O<h&&(t=_),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.max(B,S);if(R<O&&F>r&&F<y)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t>w&&F>r||h>v){const t=Math.min(r-l,u-p),e=Math.max(v+l,g+p);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:Math.max(t,R),y:N},{x:Math.max(t,R),y:F}]}if("top"===k&&"left"===C){if(N>F){if(O>R){let t=D;return(t>I||!b)&&t<P&&O>g&&(t=_),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.min(T,B);if(O<R&&y>=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t<x&&N<m){const t=Math.min(A,_),e=Math.min(w,T);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("bottom"===k&&"right"===C){if(N<F){if(O<R){let t=D;return(t<I||!b)&&t>_&&O<h&&(t=P),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}if(i<R){const t=Math.max(E,P),e=Math.max(x,S);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:B,y:N},{x:B,y:F}]}if("bottom"===k&&"left"===C){if(N<F){if(O>R){let t=D;return(t<I||!b)&&t>_&&O>g&&(t=P),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}if(v>R){const t=Math.max(E,P),e=Math.min(w,T);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:B,y:N},{x:B,y:F}]}if("left"===k&&"bottom"===C){if(O>=R&&N>=P)return[{x:R,y:N}];if(O>=g&&N<F)return[{x:B,y:N},{x:B,y:F},{x:R,y:F}];if(R<v&&m<=r)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=Math.min(T,O),e=Math.max(E,P);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}if("left"===k&&"top"===C){if(O>R&&N<_)return[{x:R,y:N}];if(O>=g&&N>F)return[{x:B,y:N},{x:B,y:F},{x:R,y:F}];if(R<=v&&F>N)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=F<N?Math.min(w,T):w,e=Math.min(A,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}if("right"===k&&"top"===C){if(O<=R&&N<_)return[{x:R,y:N}];if(v<h&&N>F)return[{x:B,y:N},{x:B,y:F},{x:R,y:F}];if(R<O&&u>y)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=Math.max(x,S),e=Math.min(A,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}if("right"===k&&"bottom"===C){if(O<=R&&N>=P)return[{x:R,y:N}];if(O<=T&&N<F)return[{x:B,y:N},{x:B,y:F},{x:R,y:F}];if(R>i&&m<r)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=Math.max(S,O),e=Math.max(E,P);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}}function yu(t,e,n){const{sourceDirection:i=ou.AUTO,targetDirection:r=ou.AUTO}=e,o=e.margin||20,s=e.useVertices||!1,a=!!n.model.source().port,l=pu(n.sourceView,n.sourceAnchor,n.sourceBBox,i,a,n.sourceAnchor,o),c=!!n.model.target().port,h=pu(n.targetView,n.targetAnchor,n.targetBBox,r,c,n.targetAnchor,o);let u=[];if(!s||0===t.length)return uu(vu(l,h));const d=t.map((t=>gu(t))),[f]=d;if(l.view&&l.view.model.isElement()&&l.view.model.getBBox().inflate(o).containsPoint(f.point)){const[t]=du(l,f),e=t,n=gu(l.point);n.margin=o,n.direction=t,f.direction=e,u.push(...vu(n,f),f.point)}else{const t=function(t,e,n){const[i]=du(t,e);switch(i){case ou.TOP:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,h=i-l,u=i+o+l,d=r-l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g<r?ou.BOTTOM:p<f&&g<d?ou.RIGHT:p>f&&g<d?ou.LEFT:p<h&&g>=r||p>u&&g>=r?ou.TOP:p>=h&&p<=f&&g>c||p<=u&&p>=f&&g>c?n.point.x<p?ou.RIGHT:ou.LEFT:ou.TOP}(t,e,n);case ou.RIGHT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,h=c+l,u=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g>f&&m===p?ou.LEFT:g>=h&&m<p?ou.BOTTOM:g>=h&&m>p?ou.TOP:g<=c&&m<=u||g<=c&&m>=d?ou.RIGHT:g<r&&m>=u&&m<=p||g<r&&m<=d&&m>=p?n.point.y<m?ou.BOTTOM:ou.TOP:ou.RIGHT}(t,e,n);case ou.BOTTOM:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,h=i-l,u=i+o+l,d=c+l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g>c?ou.TOP:p<f&&g>d?ou.RIGHT:p>f&&g>d?ou.LEFT:p<h&&g<=c||p>u&&g<=c?ou.BOTTOM:p>=h&&p<=f&&g<r||p<=u&&p>=f&&g<r?n.point.x<p?ou.RIGHT:ou.LEFT:ou.BOTTOM}(t,e,n);case ou.LEFT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,h=r-l,u=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g<f&&m===p?ou.RIGHT:g<=h&&m<p?ou.BOTTOM:g<=h&&m>p?ou.TOP:g>=r&&m<=u||g>=r&&m>=d?ou.LEFT:g>c&&m>=u&&m<=p||g>c&&m<=d&&m>=p?n.point.y<m?ou.BOTTOM:ou.TOP:ou.LEFT}(t,e,n)}}(l,f,d[1]||h);f.direction=t,u.push(...vu(l,f),f.point)}for(let t=0;t<d.length-1;t++){const e=d[t],n=d[t+1],i=hu(new De(e.point,n.point));if(i%90==0){const t=cu[i],r=au[t];if(t!==e.direction)u.push(e.point,n.point),n.direction=r;else{const t=de(i-90);let r=0,s=0;90===t?s=-o:180===t?r=-o:270===t?s=o:0===t&&(r=o);const a={x:e.point.x+r,y:e.point.y+s},l={x:n.point.x+r,y:n.point.y+s},c=new De(n.point,l);n.direction=cu[hu(c)],u.push(e.point,a,l,n.point)}continue}const[r,s]=bu(e,n);e.direction=r,n.direction=s,u.push(...vu(e,n),n.point)}const p=d[d.length-1];if(h.view&&h.view.model.isElement())if(h.view.model.getBBox().inflate(o).containsPoint(p.point)){const[t]=bu(p,h),e=gu(h.point),[,n]=du(p,h);e.margin=o,e.direction=n,p.direction=t,u.push(...vu(p,e))}else{const t=uu(u),e=new De(t[t.length-2],p.point),n=cu[Math.round(hu(e))];p.direction=n;let i=vu(p,h);const[r,s]=uu([...i,h.point]),a=new De(r,s),l=Math.round(hu(a)),c=cu[l];c!==n&&n===au[c]&&(p.margin=o,i=vu(p,h)),u.push(...i)}else{const[t]=bu(p,h);p.direction=t,u.push(...vu(p,h))}return uu(u)}function bu(t,e){const n=t.direction,i=lu.includes(n);let r=t.direction,o=e.direction;if(i){const i=t.point.y>e.point.y,s=e.point.x-t.point.x;n===ou.BOTTOM?(r=i?au[n]:s>=0?ou.RIGHT:ou.LEFT,s>0?o=i?ou.LEFT:ou.TOP:s<0&&(o=i?ou.RIGHT:ou.TOP)):(r=i?s>=0?ou.RIGHT:ou.LEFT:au[n],s>0?o=i?ou.BOTTOM:ou.LEFT:s<0&&(o=i?ou.BOTTOM:ou.RIGHT))}else{const i=t.point.x>e.point.x,s=e.point.y-t.point.y;n===ou.RIGHT?(r=i?au[n]:s>=0?ou.BOTTOM:ou.TOP,s>0?o=i?ou.TOP:ou.LEFT:s<0&&(o=i?ou.BOTTOM:ou.LEFT)):(r=i?s>=0?ou.BOTTOM:ou.TOP:au[n],s>0?o=i?ou.RIGHT:ou.TOP:s<0&&(o=i?ou.RIGHT:ou.BOTTOM))}return[r,o]}yu.Directions=ou;const wu=yu,xu={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},Au=Object.values(xu),Eu=10,Tu=1,Su=function(t,e,n=[],i={}){const{cornerType:r=xu.POINT,cornerRadius:o=Eu,cornerPreserveAspectRatio:s=!1,precision:a=Tu,raw:l=!1}=i;if(-1===Au.indexOf(r))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(r!==xu.POINT&&o){let i;c=new dn,c.appendSegment(dn.createSegment("M",t));const l=n.length;for(let h=0;h<l;h++){const l=new Re(n[h]),u=n[h-1]||t,d=n[h+1]||e,f=i||l.distance(u)/2;let p,g;i=l.distance(d)/2,s?p=g=-Math.min(o,f,i):(p=-Math.min(o,f),g=-Math.min(o,i));const m=l.clone().move(u,p).round(a),v=l.clone().move(d,g).round(a);switch(c.appendSegment(dn.createSegment("L",m)),r){case xu.CUBIC:{const t=1/3,e=2/3,n=new Re(t*m.x+e*l.x,e*l.y+t*m.y),i=new Re(t*v.x+e*l.x,e*l.y+t*v.y);c.appendSegment(dn.createSegment("C",n,i,v));break}case xu.LINE:c.appendSegment(dn.createSegment("L",v));break;case xu.GAP:c.appendSegment(dn.createSegment("M",v))}}c.appendSegment(dn.createSegment("L",e))}else{const i=[t].concat(n).concat([e]),r=new rn(i);c=new dn(r)}return l?c:c.serialize()};var _u=["arc","gap","cubic"],Pu=["smooth"],ku=1/3,Cu=2/3;function Lu(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;if(n>r){let t=n;n=r,r=t,t=i,i=o,o=t}if(i>o){let t=n;n=r,r=t,t=i,i=o,o=t}return[new Re(n,i),new Re(r,o)]}function Mu(t,e,n){var i=[].concat(t,n,e);return i.reduce((function(t,e,n){var r=i[n+1];return null!=r&&(t[n]=Ve(e,r)),t}),[])}function Ou(t,e){return Ve(t,e).squaredLength()}function Nu(t,e,n,i){var r,o=new dn;return r=dn.createSegment("M",t[0].start),o.appendSegment(r),Qo(t).forEach((function(s,a){if(s.isJump){var l,c,h,u;if("arc"===n){l=-90,c=s.start.difference(s.end);var d=Number(c.x<0||0===c.x&&c.y<0);d&&(l+=180);var f,p=s.midpoint(),g=new De(p,s.end).rotate(p,l);h=(f=new De(s.start,p)).pointAt(2/3).rotate(s.start,l),u=g.pointAt(1/3).rotate(g.end,-l),r=dn.createSegment("C",h,u,g.end),o.appendSegment(r),f=new De(p,s.end),h=g.pointAt(1/3).rotate(g.end,l),u=f.pointAt(1/3).rotate(s.end,-l),r=dn.createSegment("C",h,u,s.end),o.appendSegment(r)}else if("gap"===n)r=dn.createSegment("M",s.end),o.appendSegment(r);else if("cubic"===n){l=s.start.theta(s.end);var m=.6*e,v=1.35*e;c=s.start.difference(s.end),(d=Number(c.x<0||0===c.x&&c.y<0))&&(v*=-1),h=Re(s.start.x+m,s.start.y+v).rotate(s.start,l),u=Re(s.end.x-m,s.end.y+v).rotate(s.end,l),r=dn.createSegment("C",h,u,s.end),o.appendSegment(r)}}else{var y=t[a+1];0==i||!y||y.isJump?(r=dn.createSegment("L",s.end),o.appendSegment(r)):function(t,e,n,i,r){var o,s=n.distance(i)/2,a=n.distance(r)/2,l=-Math.min(t,s),c=-Math.min(t,a),h=n.clone().move(i,l).round(),u=n.clone().move(r,c).round(),d=new Re(ku*h.x+Cu*n.x,Cu*n.y+ku*h.y),f=new Re(ku*u.x+Cu*n.x,Cu*n.y+ku*u.y);o=dn.createSegment("L",h),e.appendSegment(o),o=dn.createSegment("C",d,f,u),e.appendSegment(o)}(i,o,s.end,s.start,y.end)}})),o}const Ru=function(t,e,n,i){!function(t){var e=t.paper,n=e._jumpOverUpdateList;if(null==n){n=e._jumpOverUpdateList=[];var i=e.model;i.on("batch:stop",(function(){this.hasActiveBatch()||function(t){for(var e=t._jumpOverUpdateList,n=0;n<e.length;n++){const t=e[n],i=t.getFlag(t.constructor.Flags.CONNECTOR);t.requestUpdate(i)}}(e)})),i.on("reset",(function(){n=e._jumpOverUpdateList=[]}))}n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",(function(){n.splice(n.indexOf(t),1)})))}(this);var r=i.raw,o=i.size||5,s=i.jump&&(""+i.jump).toLowerCase(),a=i.radius||0,l=i.ignoreConnectors||Pu;-1===_u.indexOf(s)&&(s=_u[0]);var c=this.paper,h=c.model.getLinks();if(1===h.length)return Nu(Mu(t,e,n),o,s,a);var u=this.model,d=h.indexOf(u),f=c.options.defaultConnector||{},p=h.filter((function(t,e){var n=t.get("connector")||f;return!(Qo(l).includes(n.name)||e>d&&"jumpover"===n.name)})),g=p.map((function(t){return c.findViewByModel(t)})),m=Mu(t,e,n),v=g.map((function(t){return null==t?[]:t===this?m:Mu(t.sourcePoint,t.targetPoint,t.route)}),this),y=m.reduce((function(t,e){var n=p.reduce((function(t,n,i){if(n!==u){const n=v[i].slice(),r=n.findIndex((t=>function(t,e){const[{x:n,y:i},{x:r,y:o}]=Lu(t.start,t.end),[{x:s,y:a},{x:l,y:c}]=Lu(e.start,e.end);return n<=l&&s<=r&&i<=c&&a<=o}(e,t)));r>-1&&e.containsPoint(n[r].end)&&n.splice(r+1,1);const o=function(t,e){return Qo(e).reduce((function(e,n){var i=t.intersection(n);return i&&e.push(i),e}),[])}(e,n);t.push.apply(t,o)}return t}),[]).sort((function(t,n){return Ou(e.start,t)-Ou(e.start,n)}));return n.length>0?t.push.apply(t,function(t,e,n){return e.reduce((function(i,r,o){if(!0===r.skip)return i;var s=i.pop()||t,a=Fe(r).move(s.start,-n),l=Fe(r).move(s.start,+n),c=e[o+1];if(null!=c){var h=l.distance(c);h<=n&&(l=c.move(s.start,h),c.skip=!0)}else if(a.distance(s.end)<2*n+1)return i.push(s),i;if(l.distance(s.start)<2*n+1)return i.push(s),i;var u=Ve(a,l);return u.isJump=!0,i.push(Ve(s.start,a),u,Ve(l,s.end)),i}),[])}(e,n,o)):t.push(e),t}),[]),b=Nu(y,o,s,a);return r?b:b.serialize()},Fu=function(t,e,n=[],i={}){const{raw:r}=i;return Su(t,e,n,{cornerType:"point",raw:r})},Iu=10,Bu=function(t,e,n=[],i={}){const{radius:r=Iu,raw:o}=i;return Su(t,e,n,{cornerType:"cubic",cornerRadius:r,precision:0,raw:o})},Du=function(t,e,n,i){var r,o=i&&i.raw;if(n&&0!==n.length){var s=[t].concat(n).concat([e]),a=hn.throughPoints(s);r=new dn(a)}else{var l;if(r=new dn,l=dn.createSegment("M",t),r.appendSegment(l),Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)){var c=(t.x+e.x)/2;l=dn.createSegment("C",c,t.y,c,e.y,e.x,e.y),r.appendSegment(l)}else{var h=(t.y+e.y)/2;l=dn.createSegment("C",t.x,h,e.x,h,e.x,e.y),r.appendSegment(l)}}return o?r:r.serialize()},Vu={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},$u={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},zu=function(t,e,n=[],i={},r){const o=Boolean(i.raw),{direction:s=Vu.AUTO,precision:a=3}=i,l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new Re(i.sourceTangent):null,targetTangent:i.targetTangent?new Re(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new Re(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new Re(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new Re(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new Re(i.targetDirection).normalize():null;const c=[t,...n,e].map((t=>new Re(t)));let h,u;if(l.sourceTangent)h=l.sourceTangent;else{const t=function(t,e,n,i){if(i.sourceDirection)switch(i.sourceDirection){case $u.UP:return new Re(0,-1);case $u.DOWN:return new Re(0,1);case $u.LEFT:return new Re(-1,0);case $u.RIGHT:return new Re(1,0);case $u.AUTO:return ju(t,e,i);case $u.CLOSEST_POINT:return Gu(0,e);case $u.OUTWARDS:return qu(t,e);default:return i.sourceDirection}switch(n){case Vu.HORIZONTAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.x>e[1].x?"right":"left";return s=new Re("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case Vu.VERTICAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.y>e[1].y?"bottom":"top";return s=new Re(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case Vu.CLOSEST_POINT:return Gu(0,e);case Vu.OUTWARDS:return qu(t,e);case Vu.AUTO:default:return ju(t,e,i)}}(r,c,s,l),e=c[0].distance(c[1])*l.coeff,n=Xu(t,c[1].difference(c[0]).normalize());if(n>Math.PI/4){const i=e+(n-Math.PI/4)*l.angleTangentCoefficient;h=t.clone().scale(i,i)}else h=t.clone().scale(e,e)}if(l.targetTangent)u=l.targetTangent;else{const t=function(t,e,n,i){if(i.targetDirection)switch(i.targetDirection){case $u.UP:return new Re(0,-1);case $u.DOWN:return new Re(0,1);case $u.LEFT:return new Re(-1,0);case $u.RIGHT:return new Re(1,0);case $u.AUTO:return Uu(t,e,i);case $u.CLOSEST_POINT:return Hu(0,e);case $u.OUTWARDS:return Wu(t,e);default:return i.targetDirection}switch(n){case Vu.HORIZONTAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.x>e[e.length-2].x?"left":"right";return s=new Re("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case Vu.VERTICAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.y>e[e.length-2].y?"top":"bottom";return s=new Re(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case Vu.CLOSEST_POINT:return Hu(0,e);case Vu.OUTWARDS:return Wu(t,e);case Vu.AUTO:default:return Uu(t,e,i)}}(r,c,s,l),e=c.length-1,n=c[e-1].distance(c[e])*l.coeff,i=Xu(t,c[e-1].difference(c[e]).normalize());if(i>Math.PI/4){const e=n+(i-Math.PI/4)*l.angleTangentCoefficient;u=t.clone().scale(e,e)}else u=t.clone().scale(n,n)}const d=function(t,e,n,i){const{tau:r,coeff:o}=i,s=[],a=[],l=[],c=t.length-1;for(let e=0;e<c;e++)s[e]=t[e].distance(t[e+1]);a[0]=e,a[c]=n;for(let e=1;e<c;e++){let n,i;n=1===e?t[e-1].clone().offset(a[e-1].x,a[e-1].y):t[e-1].clone(),i=e===c-1?t[e+1].clone().offset(a[e+1].x,a[e+1].y):t[e+1].clone();const r=n.difference(t[e]).normalize(),l=i.difference(t[e]).normalize(),h=Xu(r,l);let u,d=(Math.PI-h)/2;const f=Zu(r,l);let p;p=Zu(t[e].difference(t[e+1]),t[e].difference(t[e-1])),f<0&&(d=-d),h<Math.PI/2&&(d<0&&p<0||d>0&&p>0)&&(d-=Math.PI),u=l.clone(),Yu(u,d);const g=u.clone(),m=u.clone(),v=s[e-1]*o,y=s[e]*o;g.scale(v,v),m.scale(y,y),a[e]=[g,m]}for(let e=0;e<c;e++){let n,i;n=0===e?t[e+1].difference(a[e].x/r,a[e].y/r):t[e+1].difference(a[e][1].x/r,a[e][1].y/r),i=e===c-1?t[e].clone().offset(a[e+1].x/r,a[e+1].y/r):t[e].difference(a[e+1][0].x/r,a[e+1][0].y/r),l[e]=[n,t[e],t[e+1],i]}return l}(c,h,u,l),f=d.map((t=>function(t,e){const{tau:n}=e,i=new Re;i.x=t[1].x+(t[2].x-t[0].x)/(6*n),i.y=t[1].y+(t[2].y-t[0].y)/(6*n);const r=new Re;return r.x=t[2].x+(t[3].x-t[1].x)/(6*n),r.y=t[2].y+(t[3].y-t[1].y)/(6*n),new hn(t[1],i,r,t[2])}(t,l))),p=new dn(f).round(a);return o?p:p.serialize()};function ju(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.sideNearestToPoint(e[1]);switch(r){case"top":s=new Re(0,-1);break;case"bottom":s=new Re(0,1);break;case"right":s=new Re(1,0);break;case"left":s=new Re(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function Uu(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.sideNearestToPoint(e[e.length-2]);switch(r){case"top":s=new Re(0,-1);break;case"bottom":s=new Re(0,1);break;case"right":s=new Re(1,0);break;case"left":s=new Re(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function Gu(t,e,n){return e[1].difference(e[0]).normalize()}function Hu(t,e,n){const i=e.length-1;return e[i-1].difference(e[i]).normalize()}function qu(t,e,n){const{sourceBBox:i}=t,r=i.center();return e[0].difference(r).normalize()}function Wu(t,e,n){const{targetBBox:i}=t,r=i.center();return e[e.length-1].difference(r).normalize()}function Yu(t,e){const n=Math.cos(e),i=Math.sin(e),r=n*t.x-i*t.y,o=i*t.x+n*t.y;t.x=r,t.y=o}function Xu(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return n<-1&&(n=-1),n>1&&(n=1),Math.acos(n)}function Zu(t,e){return t.x*e.y-t.y*e.x}zu.Directions=Vu,zu.TangentDirections=$u;const Ku={TOOLS:mh.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},Ju=mh.extend({className:function(){var t=mh.prototype.className.apply(this).split(" ");return t.push("link"),t.join(" ")},_labelCache:null,_labelSelectors:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(){mh.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[Ku.RENDER],attrs:[Ku.UPDATE],router:[Ku.UPDATE],connector:[Ku.CONNECTOR],labels:[Ku.LABELS],labelMarkup:[Ku.LABELS],vertices:[Ku.UPDATE],source:[Ku.SOURCE,Ku.UPDATE],target:[Ku.TARGET,Ku.UPDATE]},initFlag:[Ku.RENDER,Ku.SOURCE,Ku.TARGET,Ku.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e||(e={}),this.hasFlag(t,Ku.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,Ku.SOURCE)}if(this.hasFlag(t,Ku.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,Ku.TARGET)}const{paper:n,sourceView:i,targetView:r}=this;if(n&&(i&&!n.isViewMounted(i)||r&&!n.isViewMounted(r)))return t;if(this.hasFlag(t,Ku.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),this.removeFlag(t,[Ku.RENDER,Ku.UPDATE,Ku.LABELS,Ku.TOOLS,Ku.CONNECTOR]);let o=!1;const{model:s}=this,{attributes:a}=s;let l=this.hasFlag(t,Ku.LABELS);l&&(this.onLabelsChange(s,a.labels,e),t=this.removeFlag(t,Ku.LABELS),o=!0);const c=this.hasFlag(t,Ku.UPDATE),h=this.hasFlag(t,Ku.CONNECTOR);return(c||h)&&(c?e.translateBy&&s.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[Ku.UPDATE,Ku.TOOLS,Ku.CONNECTOR]),l=!1,o=!0),l&&this.updateLabelPositions(),o&&this.updateHighlighters(),this.hasFlag(t,Ku.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,Ku.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(Ku.UPDATE),t)},isLabelsRenderRequired:function(t={}){const e=this.model.previous("labels");if(!e)return!0;if("propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(i>1&&e[n[1]]){if(2===i)return"markup"in Object(t.propertyValue);if("markup"!==n[2])return!1}}return!0},onLabelsChange:function(t,e,n){this.isLabelsRenderRequired(n)?this.renderLabels():this.updateLabels()},render:function(){return this.vel.empty(),this.unmountLabels(),this._V={},this.renderMarkup(),this.renderLabels(),this.update(),this},renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.LinkView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el);this.selectors=e.selectors,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=ri(t);Array.isArray(e)||(e=[e]),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=ri(t),n=document.createDocumentFragment();if(Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var o=e[i].node;n.appendChild(o)}else n.appendChild(e.node);return{fragment:n,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e,n=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=n.childNodes;return(e=i.length>1||"G"!==i[0].nodeName.toUpperCase()?ri("g").append(n):ri(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,n=this._labelCache={},i=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],s=o.length;if(0===s)return e&&e.remove(),this;e?e.empty():(e=t.labels=ri("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(va(ss(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,c,h=o[a],u=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup));if(u)l=u.node,c=u.selectors;else{var d=r._builtins.defaultLabel,f=this._normalizeLabelMarkup(this._getLabelMarkup(d.markup)),p=r._getDefaultLabel(),g=this._normalizeLabelMarkup(this._getLabelMarkup(p.markup))||f;l=g.node,c=g.selectors}l.setAttribute("label-idx",a),e.append(l),n[a]=l;var m=this.selector;if(c[m])throw new Error("dia.LinkView: ambiguous label root selector.");c[m]=l,i[a]=c}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){const{el:t,paper:e,model:n,_V:i,options:r}=this,{labels:o}=i;if(!o||!n.hasLabels())return;const{node:s}=o;r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(s,n.get("z")):s.parentNode!==t&&t.appendChild(s)},unmountLabels:function(){const{options:t,_V:e}=this;if(!e)return;const{labels:n}=e;n&&t.labelsLayer&&n.remove()},findLabelNodes:function(t,e){const n=this._labelCache[t];if(!n)return[];const i=this._labelSelectors[t];return this.findBySelector(e,n,i)},findLabelNode:function(t,e){const[n=null]=this.findLabelNodes(t,e);return n},_mergeLabelAttrs:function(t,e,n,i){if(null===e)return null;if(void 0===e){if(null===n)return null;if(void 0===n){if(t)return;return i}return t?n:fs({},i,n)}return t?fs({},n,e):fs({},i,n,e)},_mergeLabelSize:function(t,e){if(null===t)return null;if(void 0===t){if(null===e)return null;if(void 0===e)return;return e}return fs({},e,t)},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,r=t._getDefaultLabel(),o=r.markup,s=r.attrs,a=r.size,l=0,c=e.length;l<c;l++){var h=this._labelCache[l];h.setAttribute("cursor",n?"move":"default");var u=this._labelSelectors[l],d=e[l],f=d.markup,p=d.attrs,g=d.size,m=this._mergeLabelAttrs(f||o,p,s,i),v=this._mergeLabelSize(g,a);this.updateDOMSubtreeAttributes(h,m,{rootBBox:new Je(v),selectors:u})}return this},removeRedundantLinearVertices:function(t){const e=this.model,n=e.vertices(),i=[this.sourceAnchor,...n,this.targetAnchor],r=i.length,o=new rn(i);o.simplify({threshold:.001});const s=o.points.map((t=>t.toJSON())),a=s.length;return r===a?0:(e.vertices(s.slice(1,a-1),t),r-a)},getEndView:function(t){switch(t){case"source":return this.sourceView||null;case"target":return this.targetView||null;default:throw new Error("dia.LinkView: type parameter required.")}},getEndAnchor:function(t){switch(t){case"source":return new Re(this.sourceAnchor);case"target":return new Re(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new Re(this.sourcePoint);case"target":return new Re(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(!e)break;return this.sourceMagnet||e.el;case"target":var n=this.targetView;if(!n)break;return this.targetMagnet||n.el;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t=0,e=0){const{route:n,path:i}=this;if(!n||!i)return;const r=new rn(n);r.translate(t,e),this.route=r.points,this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e),i.translate(t,e),this.updateDOM()},updateDOM(){const{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){const{model:t}=this,e=t.vertices(),n=this.findAnchors(e),i=this.sourceAnchor=n.source,r=this.targetAnchor=n.target,o=this.findRoute(e);this.route=o;var s=this.findConnectionPoints(o,i,r);this.sourcePoint=s.source,this.targetPoint=s.target},updatePath:function(){const{route:t,sourcePoint:e,targetPoint:n}=this,i=this.findPath(t,e.clone(),n.clone());this.path=i},findAnchorsOrdered:function(t,e,n,i){var r,o,s,a,l=this.model,c=l.get(t),h=l.get(n),u=this.getEndView(t),d=this.getEndView(n),f=this.getEndMagnet(t),p=this.getEndMagnet(n);u?(s=e?new Re(e):d?p:new Re(h),r=this.getAnchor(c.anchor,u,f,s,t)):r=new Re(c),d?(a=new Re(i||r),o=this.getAnchor(h.anchor,d,p,a,n)):o=new Re(h);var g={};return g[t]=r,g[n]=o,g},findAnchors:function(t){var e=this.model,n=t[0],i=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",i,"source",n):this.findAnchorsOrdered("source",n,"target",i)},findConnectionPoints:function(t,e,n){var i,r,o,s,a=t[0],l=t[t.length-1],c=this.model,h=c.get("source"),u=c.get("target"),d=this.sourceView,f=this.targetView,p=this.paper.options;if(d&&!d.isNodeConnection(this.sourceMagnet)){i=this.sourceMagnet||d.el;var g=h.connectionPoint||p.defaultConnectionPoint,m=new De(a||n,e);o=this.getConnectionPoint(g,d,i,m,"source")}else o=e;if(f&&!f.isNodeConnection(this.targetMagnet)){r=this.targetMagnet||f.el;var v=u.connectionPoint||p.defaultConnectionPoint,y=new De(l||e,n);s=this.getConnectionPoint(v,f,r,y,"target")}else s=n;return{source:o,target:s}},getAnchor:function(t,e,n,i,r){var o,s=e.isNodeConnection(n),a=this.paper.options;if(t||(t=s?a.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:a.defaultAnchor),!t)throw new Error("Anchor required.");if("function"==typeof t)o=t;else{var l=t.name;if("function"!=typeof(o=a[s?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}var c=o.call(this,e,n,i,t.args||{},r,this);return c?c.round(this.decimalsRounding):new Re},getConnectionPoint:function(t,e,n,i,r){var o,s,a=i.end,l=this.paper.options;if(!t)return a;if("function"==typeof t)s=t;else{var c=t.name;if("function"!=typeof(s=l.connectionPointNamespace[c]))throw new Error("Unknown connection point: "+c)}return(o=s.call(this,i,e,n,t.args||{},r,this))?o.round(this.decimalsRounding):a},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,n=t._getDefaultLabel(),i=this._normalizeLabelPosition(n.position);return fs({},e,i)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},_mergeLabelPositionProperty:function(t,e){return null===t?null:void 0===t?null===e?null:e:fs({},e,t)},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model.get("labels")||[];if(!t.length)return this;for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r=this._labelCache[n];if(r){var o=t[n],s=this._normalizeLabelPosition(o.position),a=this._mergeLabelPositionProperty(s,e),l=this._getLabelTransformationMatrix(a);r.setAttribute("transform",ri.matrixToTransformString(l)),this._cleanLabelMatrices(n)}}return this},_cleanLabelMatrices:function(t){const{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(let t in i){const{id:n}=i[t];n&&n in e&&delete e[n].magnetMatrix}},updateEndProperties:function(t){const{model:e,paper:n}=this,i=`${t}View`,r=e.get(t),o=r&&r.id;if(!o)return this[i]=null,this.updateEndMagnet(t),!0;const s=n.getModelById(o);if(!s)throw new Error("LinkView: invalid "+t+" cell.");const a=s.findView(n);return!!a&&(this[i]=a,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){const e=`${t}Magnet`,n=this.getEndView(t);if(n){let i=n.getMagnetFromLinkEnd(this.model.get(t));i===n.el&&(i=null),this[e]=i}else this[e]=null},_getLabelPositionProperty:function(t){return this.model.label(t).position||{}},_getLabelPositionAngle:function(t){return this._getLabelPositionProperty(t).angle||0},_getLabelPositionArgs:function(t){return this._getLabelPositionProperty(t).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:fs({},e,t)},addLabel:function(t,e,n,i){var r,o,s,a=0;"number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(a=e,s=n):s=e):(r=t,o=e,"number"==typeof n?(a=n,s=i):s=n);var l=this._getDefaultLabelPositionArgs(),c=s,h=this._mergeLabelPositionArgs(c,l),u={position:this.getLabelPosition(r,o,a,h)};return this.model.insertLabel(-1,u,s),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,o=i?t.y:e,s=i?e:n,a={x:r,y:o},l=this.getVertexIndex(r,o);return this.model.insertVertex(l,a,s),l},sendToken:function(t,e,n){var i,r,o;Bo(e)?(i=e.duration,r="reverse"===e.direction,o=e.connection):(i=e,r=!1,o=null);var s={dur:(i=i||1e3)+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};r&&(s.keyPoints="1;0",s.keyTimes="0;1");var a,l=ri(t);if("string"==typeof o)a=this.findNode(o);else{var c=this._V;a=c.connection?c.connection.node:this.el.querySelector("path")}if(!(a instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");l.appendTo(this.paper.cells).animateAlongPath(s,a),setTimeout(function(t,e){return function(){t.remove(),"function"==typeof e&&e()}}(l,n),i)},findRoute:function(t){t||(t=[]);var e=this.paper.options.routerNamespace||h,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(Re);n=i}var r=Ko(n)?n:e[n.name];if(!Ko(r))throw new Error('dia.LinkView: unknown router: "'+n.name+'".');var o=n.args||{};return r.call(this,t,o,this)||t.map(Re)},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||u,r=this.model.connector(),o=this.paper.options.defaultConnector;r||(r=o||{});var s=Ko(r)?r:i[r.name];if(!Ko(s))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');var a=Wo(r.args||{});a.raw=!0;var l=s.call(this,e,n,t,a,this);return"string"==typeof l&&(l=new dn(ri.normalizePathData(l))),l},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;var n=t.serialize();return e.data=n,n},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;var n=t.getSegmentSubdivisions();return e.segmentSubdivisions=n,n},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;var n=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=n,n},getPointAtLength:function(t){var e=this.path;return e?e.pointAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getPointAtRatio:function(t){var e=this.path;return e?(La(t)&&(t=parseFloat(t)/100),e.pointAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()})):null},getTangentAtLength:function(t){var e=this.path;return e?e.tangentAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getTangentAtRatio:function(t){var e=this.path;return e?e.tangentAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPoint:function(t){var e=this.path;return e?e.closestPoint(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointLength:function(t){var e=this.path;return e?e.closestPointLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointRatio:function(t){var e=this.path;return e?e.closestPointNormalizedLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getLabelPosition:function(t,e,n,i){var r,o={},s=0;"number"==typeof n?(s=n,r=i):r=n,r&&(o.args=r);var a,l,c=!(r&&r.absoluteDistance),h=r&&r.absoluteDistance&&r.reverseDistance,u=r&&r.absoluteOffset,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=new Re(t,e),g=d.closestPointT(p,f),m=d.lengthAtT(g,f);if(c&&(m=m/this.getConnectionLength()||0),h&&(m=-1*(this.getConnectionLength()-m)||1),o.distance=m,u||(a=d.tangentAtT(g)),a)l=a.pointOffset(p);else{var v=d.pointAtT(g),y=p.difference(v);l={x:y.x,y:y.y}}return o.offset=l,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e,n=0,i={};if("number"==typeof t)e=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},e=t.distance,n=t.angle||0}var r=e>0&&e<=1,o=0,s={x:0,y:0};if(t.offset){var a=t.offset;"number"==typeof a&&(o=a),a.x&&(s.x=a.x),a.y&&(s.y=a.y)}var l,c=0!==s.x||0!==s.y||0===o,h=i.keepGradient,u=i.ensureLegibility,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=r?e*this.getConnectionLength():e,g=d.tangentAtLength(p,f),m=n;if(g){if(c)(l=g.start.clone()).offset(s);else{var v=g.clone();v.rotate(g.start,-90),v.setLength(o),l=v.end}h&&(m=g.angle()+n,u&&(m=de((m+90)%180-90)))}else l=d.start.clone(),c&&l.offset(s);return ri.createSVGMatrix().translate(l.x,l.y).rotate(m)},getLabelCoordinates:function(t){var e=this._getLabelTransformationMatrix(t);return new Re(e.e,e.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new Re(t,e)),r=0,o=n.length;r<o;r++){var s=n[r];if(i<this.getClosestPointLength(s))break}return r},notifyPointerdown(t,e,n){mh.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){mh.prototype.pointermove.call(this,t,e,n),this.notify("link:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("link:pointerup",t,e,n),mh.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){mh.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){mh.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){mh.prototype.contextmenu.apply(this,arguments),this.notify("link:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){var i=this._dragData;switch(i&&this.eventData(t,i),this.eventData(t).action){case"label-move":this.dragLabel(t,e,n);break;case"arrowhead-move":this.dragArrowhead(t,e,n);break;case"move":this.drag(t,e,n)}i&&$o(i,this.eventData(t)),this.notifyPointermove(t,e,n)},pointerup:function(t,e,n){var i=this._dragData;switch(i&&(this.eventData(t,i),this._dragData=null),this.eventData(t).action){case"label-move":this.dragLabelEnd(t,e,n);break;case"arrowhead-move":this.dragArrowheadEnd(t,e,n);break;case"move":this.dragEnd(t,e,n)}this.notifyPointerup(t,e,n),this.checkMouseleave(t)},mouseover:function(t){mh.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){mh.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){mh.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){mh.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){mh.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,n,i)},onlabel:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragLabelStart(t,e,n),this.eventData(t).stopPropagation&&t.stopPropagation()},dragLabelStart:function(t,e,n){if(this.can("labelMove")){if(this.isDefaultInteractionPrevented(t))return;var i=t.currentTarget,r=parseInt(i.getAttribute("label-idx"),10),o=this._getDefaultLabelPositionProperty(),s=this._normalizeLabelPosition(this._getLabelPositionProperty(r)),a=this._mergeLabelPositionProperty(s,o),l=this.getLabelCoordinates(a),c=l.x-e,h=l.y-n,u=this._getLabelPositionAngle(r),d=this._getLabelPositionArgs(r),f=this._getDefaultLabelPositionArgs(),p=this._mergeLabelPositionArgs(d,f);this.eventData(t,{action:"label-move",labelIdx:r,dx:c,dy:h,positionAngle:u,positionArgs:p,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){if(this.can("arrowheadMove")){var i=t.target.getAttribute("end"),r=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0});this.eventData(t,r)}},dragStart:function(t,e,n){this.isDefaultInteractionPrevented(t)||this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:n})},dragLabel:function(t,e,n){var i=this.eventData(t),r={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)};this.paper.options.snapLabels&&delete r.position.offset;const o={ui:!0};this.paper.isAsync()&&"touchmove"===t.type&&(o.async=!1),this.model.label(i.labelIdx,r,o)},dragArrowhead:function(t,e,n){this.paper.options.snapLinks?!this._snapArrowhead(t,e,n)&&this.paper.options.snapLinksSelf&&this._snapArrowheadSelf(t,e,n):this.paper.options.snapLinksSelf?this._snapArrowheadSelf(t,e,n):this._connectArrowhead(this.getEventTarget(t),e,n,this.eventData(t))},drag:function(t,e,n){var i=this.eventData(t);this.model.translate(e-i.dx,n-i.dy,{ui:!0}),this.eventData(t,{dx:e,dy:n})},dragLabelEnd:function(){},dragArrowheadEnd:function(t,e,n){var i=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(i):this._connectArrowheadEnd(i,e,n),r.linkAllowed(this)?(this._finishEmbedding(i),this._notifyConnectEvent(i,t)):this._disallow(i),this._afterArrowheadMove(i)},dragEnd:function(){},_disallow:function(t){"remove"===t.whenNotAllowed?this.model.remove({ui:!0}):this.model.set(t.arrowhead,t.initialEnd,{ui:!0})},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var n=t.arrowhead,i=t.initialEnd,r=this.model.prop(n);if(r&&!Tc.endsEqual(i,r)){var o=this.paper;i.id&&this.notify("link:disconnect",e,o.findViewByModel(i.id),t.initialMagnet,n),r.id&&this.notify("link:connect",e,o.findViewByModel(r.id),t.magnetUnderPointer,n)}},_snapToPoints:function(t,e,n){let i=null,r=1/0,o=null,s=1/0,a=t.x,l=t.y;for(let n=0;n<e.length;n++){const a=Math.abs(e[n].x-t.x);a<r&&(r=a,i=e[n]);const l=Math.abs(e[n].y-t.y);l<s&&(s=l,o=e[n])}return r<n&&(a=i.x),s<n&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){const{paper:i,model:r}=this,{snapLinksSelf:o}=i.options,s=this.eventData(t),a=o.radius||20,l=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],c=this._snapToPoints({x:e,y:n},l,a),h=i.localToClientPoint(c);this._connectArrowhead(document.elementFromPoint(h.x,h.y),c.x,c.y,this.eventData(t))},_snapArrowhead:function(t,e,n){const{paper:i}=this,{snapLinks:r,connectionStrategy:o}=i.options,s=this.eventData(t);let a=!1;var l=r.radius||50,c=i.findViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l}),h=s.closestView||null,u=s.closestMagnet||null,d=s.magnetProxy||null;s.closestView=s.closestMagnet=s.magnetProxy=null;var f,p=Number.MAX_VALUE,g=new Re(e,n);c.forEach((function(t){const e=[];"false"!==t.el.getAttribute("magnet")&&e.push({bbox:t.model.getBBox(),magnet:t.el}),t.$("[magnet]").toArray().forEach((n=>{e.push({bbox:t.getNodeBBox(n),magnet:n})})),e.forEach((e=>{const{magnet:n,bbox:r}=e,o=r.center().squaredDistance(g);o<p&&(u===n||i.options.validateConnection.apply(i,s.validateConnectionArgs(t,t.el===n?null:n)))&&(p=o,s.closestView=t,s.closestMagnet=n)}))}),this);var m=null,v=s.closestView,y=s.closestMagnet;y&&(m=s.magnetProxy=v.findProxyNode(y,"highlighter"));var b=s.arrowhead,w=u!==y;if(h&&w&&h.unhighlight(d,{connecting:!0,snapping:!0}),v){const{prevEnd:t,prevX:i,prevY:r}=s;if(s.prevX=e,s.prevY=n,a=!0,!w&&("function"!=typeof o||i===e&&r===n))return a;if(f=v.getLinkEnd(y,e,n,this.model,b),!w&&Zo(t,f))return a;s.prevEnd=f,w&&v.highlight(m,{connecting:!0,snapping:!0})}else f={x:e,y:n};return this.model.set(b,f||{x:e,y:n},{ui:!0}),h&&this.notify("link:snap:disconnect",t,h,u,b),v&&this.notify("link:snap:connect",t,v,y,b),a},_snapArrowheadEnd:function(t){var e=t.closestView,n=t.closestMagnet;e&&n&&(e.unhighlight(t.magnetProxy,{connecting:!0,snapping:!0}),t.magnetUnderPointer=e.findMagnet(n)),t.closestView=t.closestMagnet=null},_connectArrowhead:function(t,e,n,i){const{paper:r,model:o}=this;if(i.eventTarget!==t){i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0});const e=i.viewUnderPointer=r.findView(t);if(e){const n=i.magnetUnderPointer=e.findMagnet(t),o=i.magnetProxy=e.findProxyNode(n,"highlighter");n&&this.paper.options.validateConnection.apply(r,i.validateConnectionArgs(e,n))?o&&e.highlight(o,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)}else i.magnetUnderPointer=null,i.magnetProxy=null}i.eventTarget=t,o.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t={},e,n){const{model:i}=this,{viewUnderPointer:r,magnetUnderPointer:o,magnetProxy:s,arrowhead:a}=t;if(!o||!s||!r)return;r.unhighlight(s,{connecting:!0});const l=r.getLinkEnd(o,e,n,i,a);i.set(a,l,{ui:!0})},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,n=[];n[4]=t,n[5]=this;var i=0,r=0;"source"===t?(i=2,e="target"):(r=2,e="source");var o=this.model.get(e);if(o.id){var s=n[i]=this.paper.findViewByModel(o.id),a=s.getMagnetFromLinkEnd(o);a===s.el&&(a=void 0),n[i+1]=a}return function(t,e){return n[r]=t,n[r+1]=t.el===e?void 0:e,n}},_markAvailableMagnets:function(t){function e(t,e){var n=t.paper;return n.options.validateConnection.apply(n,this.validateConnectionArgs(t,e))}var n=this.paper,i=n.model.getCells();t.marked={};for(var r=0,o=i.length;r<o;r++){var s=i[r].findView(n);if(s){var a=Array.prototype.slice.call(s.el.querySelectorAll("[magnet]"));"false"!==s.el.getAttribute("magnet")&&a.push(s.el);var l=a.filter(e.bind(t,s));if(l.length>0){for(var c=0,h=l.length;c<h;c++)s.highlight(l[c],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e,n,i=Object.keys(t.marked),r=0,o=i.length;r<o;r++){e=i[r],n=t.marked[e];var s=this.paper.findViewByModel(e);if(s){for(var a=0,l=n.length;a<l;a++)s.unhighlight(n[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){e||(e={});var n={action:"arrowhead-move",arrowhead:t,whenNotAllowed:e.whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:Wo(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(n),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=n),n},onMount:function(){mh.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){mh.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){mh.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:Ku});Object.defineProperty(Ju.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t){var e=this.model.source();return new Je(e.x,e.y)}var n=this.sourceMagnet;return t.isNodeConnection(n)?new Je(this.sourceAnchor):t.getNodeBBox(n||t.el)}}),Object.defineProperty(Ju.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t){var e=this.model.target();return new Je(e.x,e.y)}var n=this.targetMagnet;return t.isNodeConnection(n)?new Je(this.targetAnchor):t.getNodeBBox(n||t.el)}});const Qu={GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"},td=lh.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return va(`${this.options.name}-layer`)},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){const{el:e}=this;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(t){const{el:e,pivotNodes:n}=this;(t=+t)||(t=0);let i=n[t];if(i)return i;i=n[t]=document.createComment("z-index:"+(t+1));let r=-1/0;for(let e in n)e=+e,e<t&&e>r&&(r=e);if(r!==-1/0){const t=n[r];e.insertBefore(i,t.nextSibling)}else e.insertBefore(i,e.firstChild);return i},removePivots:function(){const{el:t,pivotNodes:e}=this;for(let n in e)t.removeChild(e[n]);this.pivotNodes={}}}),ed=hh.extend({tagName:"path",className:"highlight-stroke",attributes:{"pointer-events":"none",fill:"none"},options:{padding:3,rx:0,ry:0,useFirstSubpath:!1,attrs:{"stroke-width":3,stroke:"#FEB663"}},getPathData(t,e){const{options:n}=this,{useFirstSubpath:i}=n;let r;try{const t=ri(e);if(r=t.convertToPathData().trim(),"PATH"===t.tagName()&&i){const t=r.search(/.M/i)+1;t>0&&(r=r.substr(0,t))}}catch(i){const o=t.getNodeBoundingRect(e);r=ri.rectToPath($o({},n,o.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){const{vel:n,options:i}=this,{padding:r,layer:o}=i;let s=this.getNodeMatrix(t,e);if(r){o||e!==t.el||n.remove();let i=t.getNodeBoundingRect(e);const a=i.x+i.width/2,l=i.y+i.height/2;i=ri.transformRect(i,s);const c=Math.max(i.width,1),h=Math.max(i.height,1),u=(c+r)/c,d=(h+r)/h,f=ri.createSVGMatrix({a:u,b:0,c:0,d,e:a-u*a,f:l-d*l});s=s.multiply(f)}n.attr({d:this.getPathData(t,e),transform:ri.matrixToTransformString(s)})},highlight(t,e){const{vel:n,options:i}=this;n.attr(i.attrs),i.nonScalingStroke&&n.attr("vector-effect","non-scaling-stroke"),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}}),nd=20,id=hh.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:nd,deep:!1,attrs:{stroke:"#FEB663","stroke-width":3,"stroke-linecap":"butt","stroke-linejoin":"miter"}},VISIBLE:"white",INVISIBLE:"black",MASK_ROOT_ATTRIBUTE_BLACKLIST:["marker-start","marker-end","marker-mid","transform","stroke-dasharray","class"],MASK_CHILD_ATTRIBUTE_BLACKLIST:["stroke","fill","stroke-width","stroke-opacity","stroke-dasharray","fill-opacity","marker-start","marker-end","marker-mid","class"],MASK_REPLACE_TAGS:["FOREIGNOBJECT","IMAGE","USE","TEXT","TSPAN","TEXTPATH"],MASK_REMOVE_TAGS:["TEXT","TSPAN","TEXTPATH"],transformMaskChild(t,e){const{MASK_CHILD_ATTRIBUTE_BLACKLIST:n,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=e.tagName();if(!ri.isSVGGraphicsElement(e)||r.includes(o))return e.remove(),!1;if(i.includes(o)){const n=t.vel.findOne(`#${e.id}`);if(n){const{node:i}=n;let r=t.getNodeBoundingRect(i);t.model.isElement()&&(r=ri.transformRect(r,t.getNodeMatrix(i)));const o=ri("rect",r.toJSON()),{x:s,y:a}=r.center(),{angle:l,cx:c=s,cy:h=a}=n.rotate();l&&o.rotate(l,c,h),e.parent().append(o)}return e.remove(),!1}return n.forEach((t=>{"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)})),!0},transformMaskRoot(t,e){const{MASK_ROOT_ATTRIBUTE_BLACKLIST:n}=this;n.forEach((t=>{e.removeAttr(t)}))},getMaskShape(t,e){const{options:n,MASK_REPLACE_TAGS:i}=this,{deep:r}=n,o=e.tagName();let s;if("G"===o){if(!r)return null;s=e.clone(),function(t,e){const n=t.children();for(;n.length>0;){const t=n.shift();e(t)&&n.push(...t.children())}}(s,(e=>this.transformMaskChild(t,e)))}else{if(i.includes(o))return null;s=e.clone()}return this.transformMaskRoot(t,s),s},getMaskId(){return`highlight-mask-${this.cid}`},getMask(t,e){const{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:o,attrs:s}=r,a=parseFloat(ri("g").attr(s).attr("stroke-width")),l="none"!==e.attr("fill");let c=parseFloat(e.attr("stroke-width"));isNaN(c)&&(c=1);const h=c+2*o,u=h+2*a;let d=this.getMaskShape(t,e);if(!d){const n=t.getNodeBoundingRect(e.node);n.inflate(n.width?0:.5,n.height?0:.5),d=ri("rect",n.toJSON())}return d.attr(s),ri("mask",{id:this.getMaskId()}).append([d.clone().attr({fill:l?n:"none",stroke:n,"stroke-width":u}),d.clone().attr({fill:l?i:"none",stroke:i,"stroke-width":h})])},removeMask(t){const e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){const{options:n,vel:i}=this,{padding:r,attrs:o,maskClip:s=nd,layer:a}=n,l="stroke"in o?o.stroke:"#000000";a||e!==t.el||i.remove();const c=t.getNodeBoundingRect(e).inflate(r+s),h=this.getNodeMatrix(t,e),u=this.getMask(t,ri(e));this.addMask(t.paper,u),i.attr(c.toJSON()),i.attr({transform:ri.matrixToTransformString(h),mask:`url(#${u.id})`,fill:l})},unhighlight(t){this.removeMask(t.paper)}}),rd=hh.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){const{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),od=va("highlighted"),sd=hh.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:od},highlight:function(t,e){ri(e).addClass(this.options.className)},unhighlight:function(t,e){ri(e).removeClass(this.options.className)}},{className:od}),ad={ROW:"row",COLUMN:"column"},ld=hh.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){const n=t.model,{attribute:i,size:r=20,gap:o=5,direction:s=ad.ROW}=this.options;if(!i)throw new Error("List: attribute is required");const a="number"==typeof r?{width:r,height:r}:r,l=s===ad.ROW,c=l?a.width:a.height;let h=n.get(i);Array.isArray(h)||(h=[]);const u=this._prevItems||[],d=h.map(((t,e)=>Zo(u[e],h[e])));if(u.length!==h.length||d.some((t=>!t))){const t=this.vel.children(),e=h.map(((e,n)=>{const r=n in t?t[n].node:null;if(d[n])return r;const s=this.createListItem(e,a,r);if(!s)return null;if(!(s instanceof SVGElement))throw new Error("List: item must be an SVGElement");s.dataset.index=n,s.dataset.attribute=i;const h=n*(c+o);return s.setAttribute("transform",l?`translate(${h}, 0)`:`translate(0, ${h})`),s}));this.vel.empty().append(e),this._prevItems=h}const f=h.length,p=0===f?0:f*c+(f-1)*o,g=l?{width:p,height:a.height}:{width:a.width,height:p};this.position(n,g)},position(t,e){const{vel:n,options:i}=this,{margin:r=5,position:o="top-left"}=i,{width:s,height:a}=t.size(),{left:l,right:c,top:h,bottom:u}=Fa(r),d=new Je(l,h,s-(l+c),a-(h+u));let{x:f,y:p}=Gc(d,o);switch(o){case Uc.CENTER:case Uc.TOP:case Uc.BOTTOM:f-=e.width/2;break;case Uc.RIGHT:case Uc.BOTTOM_RIGHT:case Uc.TOP_RIGHT:f-=e.width}switch(o){case Uc.CENTER:case Uc.RIGHT:case Uc.LEFT:p-=e.height/2;break;case Uc.BOTTOM:case Uc.BOTTOM_RIGHT:case Uc.BOTTOM_LEFT:p-=e.height}n.attr("transform",`translate(${f}, ${p})`)}},{Directions:ad,Positions:Uc});function cd(t,e,n,i){var r="ratio"in i?i.ratio:.5;return t.getPointAtRatio(r)}function hd(t,e,n,i){var r="length"in i?i.length:20;return t.getPointAtLength(r)}function ud(t){return function(e,n,i,r){if(i instanceof Element){var o,s=this.paper.findView(i);return o=s?s.isNodeConnection(i)?dd(s,"fixedAt"in r?r.fixedAt:"50%"):s.getNodeBBox(i).center():new Re,t.call(this,e,n,o,r)}return t.apply(this,arguments)}}function dd(t,e){var n=parseFloat(e);return La(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}const fd=ud((function(t,e,n,i){var r=1e6,o=t.getConnection(),s=t.getConnectionSubdivisions(),a=new De(n.clone().offset(0,r),n.clone().offset(0,-r)),l=new De(n.clone().offset(r,0),n.clone().offset(-r,0)),c=a.intersect(o,{segmentSubdivisions:s}),h=l.intersect(o,{segmentSubdivisions:s}),u=[];return c&&Array.prototype.push.apply(u,c),h&&Array.prototype.push.apply(u,h),u.length>0?n.chooseClosest(u):"fallbackAt"in i?dd(t,i.fallbackAt):pd(t,e,n,i)})),pd=ud((function(t,e,n,i){return t.getClosestPoint(n)||new Re}));function gd(t,e,n){if(Jo(n)){const{x:i,y:r}=n;if(isFinite(r)){const n=new De(e,t),{start:i,end:o}=n.parallel(r);e=i,t=o}n=i}if(!isFinite(n))return t;var i=t.distance(e);return 0===n&&i>0?t:t.move(e,-Math.min(n,i-1))}function md(t){var e=t.getAttribute("stroke-width");return null===e?0:parseFloat(e)||0}function vd(t,e,n,i){var r=e.getNodeBBox(n);i.stroke&&r.inflate(md(n)/2);var o=t.intersect(r);return gd(o?t.start.chooseClosest(o):t.end,t.start,i.offset)}var yd="segmentSubdivisons",bd="shapeBBox";const wd=function(t,e,n,i){let{offset:r,alignOffset:o,align:s}=i;return s&&function(t,e,n=0){let i,r,o,s;const{start:a,end:l}=t;switch(e){case"left":i="x",r=l,o=a,s=-1;break;case"right":i="x",r=a,o=l,s=1;break;case"top":i="y",r=l,o=a,s=-1;break;case"bottom":i="y",r=a,o=l,s=1;break;default:return}a[i]<l[i]?r[i]=o[i]:o[i]=r[i],isFinite(n)&&(r[i]+=s*n,o[i]+=s*n)}(t,s,o),gd(t.end,t.start,r)},xd=vd,Ad=function(t,e,n,i){var r=e.model.angle();if(0===r)return vd(t,e,n,i);var o=e.getNodeUnrotatedBBox(n);i.stroke&&o.inflate(md(n)/2);var s=o.center(),a=t.clone().rotate(s,r),l=a.setLength(1e6).intersect(o);return gd(l?a.start.chooseClosest(l).rotate(s,-r):t.end,t.start,i.offset)},Ed=function(t,e,n,i){var r,o,s=i.selector,a=t.end;if(r="string"==typeof s?e.findNode(s):!1===s?n:Array.isArray(s)?wa(n,s):function(t){if(!t)return null;var e=t;do{var n=e.tagName;if("string"!=typeof n)return null;if("G"===(n=n.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==n)break;e=e.nextElementSibling}}while(e);return e}(n),!ri.isSVGGraphicsElement(r)){if(r===n||!ri.isSVGGraphicsElement(n))return a;r=n}var l,c=e.getNodeShape(r),h=e.getNodeMatrix(r),u=e.getRootTranslateMatrix(),d=e.getRootRotateMatrix(),f=u.multiply(d).multiply(h),p=f.inverse(),g=ri.transformLine(t,p),m=g.start.clone(),v=e.getNodeData(r);if(!1===i.insideout&&(v[bd]||(v[bd]=c.bbox()),v[bd].containsPoint(m)))return a;if(c instanceof dn){var y=i.precision||2;v[yd]||(v[yd]=c.getSegmentSubdivisions({precision:y})),l={precision:y,segmentSubdivisions:v[yd]}}!0===i.extrapolate&&g.setLength(1e6),(o=g.intersect(c,l))?ri.isArray(o)&&(o=m.chooseClosest(o)):!0===i.sticky&&(o=c instanceof Je?c.pointNearestToPoint(m):c instanceof Ue?c.intersectionWithLineFromCenterToPoint(m):c.closestPoint(m,l));var b=o?ri.transformPoint(o,f):a,w=i.offset||0;return i.stroke&&(w+=md(r)/2),gd(b,t.start,w)};function Td(t){return function(e,n,i,r){var o=!!r.rotate,s=o?e.getNodeUnrotatedBBox(n):e.getNodeBBox(n),a=s[t](),l=r.dx;if(l){var c=La(l);l=parseFloat(l),isFinite(l)&&(c&&(l/=100,l*=s.width),a.x+=l)}var h=r.dy;if(h){var u=La(h);h=parseFloat(h),isFinite(h)&&(u&&(h/=100,h*=s.height),a.y+=h)}return o?a.rotate(e.model.getBBox().center(),-e.model.angle()):a}}const Sd=Td("center"),_d=Td("topMiddle"),Pd=Td("bottomMiddle"),kd=Td("leftMiddle"),Cd=Td("rightMiddle"),Ld=Td("origin"),Md=Td("topRight"),Od=Td("bottomLeft"),Nd=Td("corner"),Rd=ud((function(t,e,n,i){var r=t.model.angle(),o=t.getNodeBBox(e),s=o.center(),a=o.origin(),l=o.corner(),c=i.padding;if(isFinite(c)||(c=0),a.y+c<=n.y&&n.y<=l.y-c){var h=n.y-s.y;s.x+=0===r||180===r?0:1*h/Math.tan(ge(r)),s.y+=h}else if(a.x+c<=n.x&&n.x<=l.x-c){var u=n.x-s.x;s.y+=90===r||270===r?0:u*Math.tan(ge(r)),s.x+=u}return s})),Fd=ud((function(t,e,n,i){var r,o,s,a=!!i.rotate;a?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e);var l,c=i.padding;switch(isFinite(c)&&r.inflate(c),a&&n.rotate(s,o),r.sideNearestToPoint(n)){case"left":l=r.leftMiddle();break;case"right":l=r.rightMiddle();break;case"top":l=r.topMiddle();break;case"bottom":l=r.bottomMiddle()}return a?l.rotate(s,-o):l})),Id=function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)},Bd=td.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){td.prototype.init.apply(this,arguments);const{options:{paper:t}}=this;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){const e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach((t=>{e.push(...this._resolveDrawGridOption(t))})),e},removeGrid(){const{_gridCache:t}=this;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){const{options:{paper:t}}=this,{_gridSettings:e}=this;if(this.removeGrid(),0===e.length)return;const n=t.options.drawGridSize||t.options.gridSize;if(n<=1)return;const i=this._getGridRefs();e.forEach(((e,r)=>{const o="pattern_"+r,s=fs({},e),{scaleFactor:a=1}=s;let l;s.width=n*a||1,s.height=n*a||1,i.exist(o)?l=i.get(o):(l=ri("pattern",{id:o,patternUnits:"userSpaceOnUse"},ri(s.markup)),i.add(o,l)),Ko(s.render)&&s.render(l.node.firstChild,s,t),l.attr({width:s.width,height:s.height})})),i.root.appendTo(this.el),this.updateGrid()},updateGrid(){const{_gridCache:t,_gridSettings:e,options:{paper:n}}=this;if(!t)return;const{root:i,patterns:r}=t,{x:o,y:s,width:a,height:l}=n.getArea();i.attr({x:o,y:s,width:a,height:l});for(const t in r)r[t].attr({x:-o,y:-s});e.forEach(((t,e)=>{if(Ko(t.update)){const i=r["pattern_"+e];t.update(i.node.firstChild,t,n)}}))},_getGridRefs(){let{_gridCache:t}=this;if(t)return t;const e=ri("defs"),n=ri("svg",{width:"100%",height:"100%"},[e]);return t=this._gridCache={root:n,patterns:{},add:function(t,i){const r=ri("rect",{width:"100%",height:"100%",fill:`url(#${t})`});e.append(i),n.append(r),this.patterns[t]=i},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}},t},_resolveDrawGridOption(t){var e=this.options.patterns;if(Vo(t)&&Array.isArray(e[t]))return e[t].map((function(t){return $o({},t)}));var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if(i||r||n.markup||(r="dot"),r&&Array.isArray(e[r])){var o=e[r].map((function(t){return $o({},t)})),s=Array.isArray(n.args)?n.args:[n.args||{}];zo(s[0],as(t,"args"));for(var a=0;a<s.length;a++)o[a]&&$o(o[a],s[a]);return o}return i?n:[n]}}),Dd={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},Vd=1/0,$d=9007199254740991,zd=mh.Highlighting,jd={[zd.DEFAULT]:{name:"stroke",options:{padding:3}},[zd.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[zd.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},Ud=[{name:Qu.GRID},{name:Qu.BACK},{name:Qu.CELLS},{name:Qu.LABELS},{name:Qu.FRONT},{name:Qu.TOOLS}],Gd=lh.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:xh,linkView:Ju,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:jd,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){const{cellNamespace:t}=this.model.get("cells"),e=wa(t,["standard","Link"]);if(!e)throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.");return new e},defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"boundary"},connectionStrategy:null,validateMagnet:function(t,e,n){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,n,i,r,o){return("target"===r?n:t)instanceof xh},embeddingMode:!1,validateEmbedding:function(t,e){return!0},validateUnembedding:function(t){return!0},findParentBy:"bbox",frontParentOnly:!0,interactive:{labelMove:!1},linkPinning:!0,allowLink:null,clickThreshold:0,moveThreshold:0,magnetThreshold:0,sorting:Dd.APPROX,frozen:!1,autoFreeze:!1,onViewUpdate:function(t,e,n,i,r){e&(t.FLAG_INSERT|t.FLAG_REMOVE)||i.mounting||i.isolate||r.requestConnectedLinksUpdate(t,n,i)},onViewPostponed:function(t,e,n){return n.forcePostponedViewUpdate(t,e)},beforeRender:null,afterRender:null,viewport:null,cellViewNamespace:null,routerNamespace:null,connectorNamespace:null,highlighterNamespace:d,anchorNamespace:g,linkAnchorNamespace:f,connectionPointNamespace:p,overflow:!1},events:{dblclick:"pointerdblclick",dbltap:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},stylesheet:"\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n ",svg:null,viewport:null,defs:null,tools:null,layers:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],FORM_CONTROL_TAG_NAMES:["TEXTAREA","INPUT","BUTTON","SELECT","OPTION"],GUARDED_TAG_NAMES:["SELECT"],MIN_SCALE:1e-6,init:function(){const{options:t}=this;t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&os(joint,"shapes")?joint.shapes:null);const e=this.model=t.model||new ih;this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates={id:null,priorities:[{},{},{}],unmountedCids:[],mountedCids:[],unmounted:{},mounted:{},count:0,keyFrozen:!1,freezeKey:null,sort:!1,disabled:!1,idle:!1}},startListening:function(){var t=this.model;this.listenTo(t,"add",this.onCellAdded).listenTo(t,"remove",this.onCellRemoved).listenTo(t,"change",this.onCellChange).listenTo(t,"reset",this.onGraphReset).listenTo(t,"sort",this.onGraphSort).listenTo(t,"batch:stop",this.onGraphBatchStop),this.on("cell:highlight",this.onCellHighlight).on("cell:unhighlight",this.onCellUnhighlight).on("transform",this.update)},onCellAdded:function(t,e,n){var i=n.position;this.isAsync()||!Do(i)?this.renderView(t,n):(n.maxPosition===i&&this.freeze({key:"addCells"}),this.renderView(t,n),0===i&&this.unfreeze({key:"addCells"}))},onCellRemoved:function(t,e,n){const i=this.findViewByModel(t);i&&this.requestViewUpdate(i,i.FLAG_REMOVE,i.UPDATE_PRIORITY,n)},onCellChange:function(t,e){if(t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===Dd.APPROX){const n=this.findViewByModel(t);n&&this.requestViewUpdate(n,n.FLAG_INSERT,n.UPDATE_PRIORITY,e)}},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){if(!this.isFrozen()){var e=t&&t.batchName,n=this.model;if(!this.isAsync()){var i=this.UPDATE_DELAYING_BATCHES;i.includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t)}var r=this.SORT_DELAYING_BATCHES;r.includes(e)&&!n.hasActiveBatch(r)&&this.sortViews()}},cloneOptions:function(){const{options:t}=this,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&"undefined"!=typeof joint&&os(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),Ko(e)||(t.defaultConnector=Yo(e)),Ko(n)||(t.defaultRouter=Yo(n)),Ko(i)||(t.defaultConnectionPoint=Yo(i)),Ko(r)||(t.defaultAnchor=Yo(r)),Ko(o)||(t.defaultLinkAnchor=Yo(o)),Jo(l)&&(t.interactive=$o({},l)),Jo(s)&&(t.highlighting=jo({},s,jd))},children:function(){var t=ri.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:va("paper-background"),selector:"background",style:{position:"absolute",inset:0}},{namespaceURI:t.svg,tagName:"svg",attributes:{width:"100%",height:"100%","xmlns:xlink":t.xlink},selector:"svg",style:{position:"absolute",inset:0},children:[{tagName:"defs",selector:"defs"},{tagName:"g",className:va("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers},getLayerView(t){const{_layers:e}=this;if(t in e)return e[t];throw new Error(`dia.Paper: Unknown layer "${t}"`)},getLayerNode(t){return this.getLayerView(t).el},render:function(){this.renderChildren();const{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:r,defs:o,layers:s}=e;return t.style.position="relative",r.style.overflow=n.overflow?"visible":"hidden",this.svg=r,this.defs=o,this.layers=s,this.renderLayers(),ri.ensureId(r),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&ri(this.svg).prepend(ri.createSVGStyle(t))},createLayer(t){return t===Qu.GRID?new Bd({name:t,paper:this,patterns:this.constructor.gridPatterns}):new td({name:t})},renderLayers:function(t=Ud){this.removeLayers(),t.forEach((({name:t,sorted:e})=>{const n=this.createLayer(t);this.layers.appendChild(n.el),this._layers[t]=n}));const e=this.getLayerView(Qu.CELLS),n=this.getLayerView(Qu.TOOLS),i=this.getLayerView(Qu.LABELS);this.tools=n.el,this.cells=this.viewport=e.el,e.vel.addClass(va("viewport")),i.vel.addClass(va("viewport")),e.el.style.webkitUserSelect="none",e.el.style.userSelect="none",i.el.style.webkitUserSelect="none",i.el.style.userSelect="none"},removeLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].remove(),delete t[e]}))},resetLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].removePivots()}))},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){const i=this.matrix();return void 0===t?ri.matrixToScale(i):(void 0===e&&(e=t),t=Math.max(t||0,this.MIN_SCALE),e=Math.max(e||0,this.MIN_SCALE),i.a=t,i.d=e,this.matrix(i,n),this)},scaleUniformAtPoint:function(t,e,n){const{a:i,d:r,e:o,f:s}=this.matrix();if((t=Math.max(t||0,this.MIN_SCALE))===i&&t===r)return this;const a=ri.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t);return this.matrix(a,n),this},translate:function(t,e,n){const i=this.matrix();return void 0===t?ri.matrixToTranslate(i):(t||(t=0),e||(e=0),i.e===t&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e={}){var n=this.layers;if(void 0===t){var i=n.getAttribute("transform");return(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=n.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),ri.createSVGMatrix(t)}const r=this.matrix(),o=ri.createSVGMatrix(t),s=this._viewportTransformString,a=ri.matrixToTransformString(o);if(a===s)return this;if(!s&&ri.matrixToTransformString()===a)return this;const{a:l,d:c,e:h,f:u}=o;return n.setAttribute("transform",a),this._viewportMatrix=o,this._viewportTransformString=n.getAttribute("transform"),l===r.a&&c===r.d||this.trigger("scale",l,c,e),h===r.e&&u===r.f||this.trigger("translate",h,u,e),this.trigger("transform",o,e),this},clientMatrix:function(){return ri.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof mh)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a=r[o],l=this.findViewByModel(a);if(l){var c=["UPDATE"];a.getTargetCell()===i&&c.push("TARGET"),a.getSourceCell()===i&&c.push("SOURCE");var h=Math.max(e+1,l.UPDATE_PRIORITY);this.scheduleViewUpdate(l,l.getFlag(c),h,n)}}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof mh))return!1;var n=t.model;if(n.isElement())return!1;if(!(e&t.getFlag(["SOURCE","TARGET"]))){var i={silent:!0},r=0,o=this.findViewByModel(n.getSourceCell());o&&!this.isViewMounted(o)&&(r=this.dumpView(o,i),t.updateEndMagnet("source"));var s=0,a=this.findViewByModel(n.getTargetCell());if(a&&!this.isViewMounted(a)&&(s=this.dumpView(a,i),t.updateEndMagnet("target")),0===r&&0===s)return!this.dumpView(t,i)}return!1},requestViewUpdate:function(t,e,n,i){i||(i={}),this.scheduleViewUpdate(t,e,n,i);var r=this.isAsync();if(!(this.isFrozen()||r&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES))){var o=this.updateViews(i);r&&this.notifyAfterRender(o,i)}},scheduleViewUpdate:function(t,e,n,i){const{_updates:r,options:o}=this;r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze());const{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:c}=t;let h=r.priorities[n];if(h||(h=r.priorities[n]={}),n>l)for(let t=n-1;t>=l;t--){const e=r.priorities[t];e&&c in e&&(h[c]|=e[c],delete e[c])}let u=h[c]||0;if((u&e)===e)return;u||r.count++,e&s&&u&a?h[c]^=a:e&a&&u&s&&(h[c]^=s),h[c]|=e;const d=o.onViewUpdate;"function"==typeof d&&d.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,n=t.cid,i=e.priorities[t.UPDATE_PRIORITY],r=this.registerMountedView(t)|i[n];return delete i[n],r},dumpView:function(t,e={}){const n=this.dumpViewUpdate(t);if(!n)return 0;const i=!e.silent;i&&this.notifyBeforeRender(e);const r=this.updateView(t,n,e);if(i){const n={updated:1,priority:t.UPDATE_PRIORITY};this.notifyAfterRender(n,e)}return r},updateView:function(t,e,n){if(!t)return 0;const{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof mh){if(e&i)return this.removeView(s),0;if(e&r){const n=!!(e&o);n&&(e^=o),this.insertView(t,n),e^=r}}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){var n=this.findViewByModel(t);return n?(this.dumpView(n,e),n):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;if(e in n.unmounted)return 0;var i=n.unmounted[e]|=t.FLAG_INSERT;return n.unmountedCids.push(e),delete n.mounted[e],i},registerMountedView:function(t){var e=t.cid,n=this._updates;if(e in n.mounted)return 0;n.mounted[e]=!0,n.mountedCids.push(e);var i=n.unmounted[e]||0;return delete n.unmounted[e],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){var e=zo({},t,{viewport:null});this.checkViewport(e),this.updateViews(e)},updateViews:function(t){let e;this.notifyBeforeRender(t);let n=0,i=0,r=$d;do{i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r)}while(!e.empty);const o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){const t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;n>0&&n--;)for(let i in t[e[n]])return!0;return!1},updateViewsAsync:function(t,e){t||(t={}),e||(e={processed:0,priority:$d});const{_updates:n,options:i}=this,r=n.id;if(r){Pa(r),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);const o=this.updateViewsBatch(t),s=zo({},t,{mountBatchSize:1e3-o.mounted,unmountBatchSize:1e3-o.unmounted}),a=this.checkViewport(s),l=a.unmounted,c=a.mounted;let h=e.processed;const u=n.count;o.updated>0?(h+=o.updated+o.unmounted,o.processed=h,e.priority=Math.min(o.priority,e.priority),o.empty&&0===c?(o.unmounted+=l,o.mounted+=c,o.priority=e.priority,this.notifyAfterRender(o,t),e.processed=0,e.priority=$d,n.count=0):e.processed=h):n.idle||i.autoFreeze&&(this.freeze(),n.idle=!0,this.trigger("render:idle",t));const d=t.progress;if(u&&"function"==typeof d&&d.call(this,o.empty,h,u,o,this),n.id!==r)return}if(n.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");n.id=_a(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t={}){let e=t.beforeRender;"function"!=typeof e&&(e=this.options.beforeRender,"function"!=typeof e)||e.call(this,t,this)},notifyAfterRender:function(t,e={}){let n=e.afterRender;"function"!=typeof n&&(n=this.options.afterRender),"function"==typeof n&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){t||(t={});var e=t.batchSize||Vd,n=this._updates,i=0,r=0,o=0,s=0,a=$d,l=!0,c=this.options,h=n.priorities,u="viewport"in t?t.viewport:c.viewport;"function"!=typeof u&&(u=null);var d=c.onViewPostponed;"function"!=typeof d&&(d=null);var f=Object.keys(h);t:for(var p=0,g=f.length;p<g;p++){var m=+f[p],v=h[m];for(var y in v){if(i>=e){l=!1;break t}var b=ah[y];if(b){var w=v[y];if(!(w&b.FLAG_REMOVE)){var x=y in n.unmounted;if(b.DETACHABLE&&u&&!u.call(this,b,!x,this)){x||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[y]|=w,delete v[y],o++;continue}x&&(w|=b.FLAG_INSERT,s++),w|=this.registerMountedView(b)}var A=this.updateView(b,w,t);A>0&&(v[y]=A,!d||!d.call(this,b,A,this)||v[y])?(r++,l=!1):(a>m&&(a=m),i++,delete v[y])}else delete v[y]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){const t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=ah[e[r]];return i},getMountedViews:function(){const t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=ah[e[r]];return i},checkUnmountedViews:function(t,e){e||(e={});var n=0;"function"!=typeof t&&(t=null);for(var i=("mountBatchSize"in e?e.mountBatchSize:1/0),r=this._updates,o=r.unmountedCids,s=r.unmounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var h=ah[c];if(h)if(h.DETACHABLE&&t&&!t.call(this,h,!1,this))o.push(c);else{n++;var u=this.registerMountedView(h);u&&this.scheduleViewUpdate(h,u,h.UPDATE_PRIORITY,{mounting:!0})}}}return o.splice(0,a),n},checkMountedViews:function(t,e){e||(e={});var n=0;if("function"!=typeof t)return n;for(var i=("unmountBatchSize"in e?e.unmountBatchSize:1/0),r=this._updates,o=r.mountedCids,s=r.mounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var h=ah[c];h&&(h.DETACHABLE&&!t.call(this,h,!0,this)?(n++,this.registerUnmountedView(h)&&this.detachView(h)):o.push(c))}}return o.splice(0,a),n},checkViewVisibility:function(t,e={}){let n="viewport"in e?e.viewport:this.options.viewport;"function"!=typeof n&&(n=null);const i=this._updates,{mounted:r,unmounted:o}=i,s=!t.DETACHABLE||!n||n.call(this,t,!1,this);let a=!1,l=!1;if(t.cid in r&&!s){this.registerUnmountedView(t)&&this.detachView(t);const e=i.mountedCids.indexOf(t.cid);i.mountedCids.splice(e,1),a=!0}if(!a&&t.cid in o&&s){const e=i.unmountedCids.indexOf(t.cid);i.unmountedCids.splice(e,1);var c=this.registerMountedView(t);c&&this.scheduleViewUpdate(t,c,t.UPDATE_PRIORITY,{mounting:!0}),l=!0}return{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e=zo({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n="viewport"in e?e.viewport:this.options.viewport,i=this.checkMountedViews(n,e);if(i>0){var r=this._updates.unmountedCids;e.mountBatchSize=Math.min(r.length-i,e.mountBatchSize)}return{mounted:this.checkUnmountedViews(n,e),unmounted:i}},freeze:function(t){t||(t={});var e=this._updates,n=t.key,i=this.options.frozen,r=e.freezeKey;if(n&&n!==r){if(i&&r)return;e.freezeKey=n,e.keyFrozen=i}this.options.frozen=!0;var o=e.id;e.id=null,this.isAsync()&&o&&Pa(o)},unfreeze:function(t){t||(t={});var e=this._updates,n=t.key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===Dd.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,n=t.height;return Do(e)||(e=this.el.clientWidth),Do(n)||(n=this.el.clientHeight),{width:e,height:n}},setDimensions:function(t,e,n={}){const{options:i}=this,{width:r,height:o}=i;let s=void 0===t?r:t,a=void 0===e?o:e;if(r===s&&o===a)return;i.width=s,i.height=a,this._setDimensions();const l=this.getComputedSize();this.trigger("resize",l.width,l.height,n)},_setDimensions:function(){const{options:t}=this;let e=t.width,n=t.height;Do(e)&&(e=`${Math.round(e)}px`),Do(n)&&(n=`${Math.round(n)}px`),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=Bo(t)?t:$o({gridWidth:t,gridHeight:e,padding:n},i);const{x:r,y:o,width:s,height:a}=this.getFitToContentArea(i),{sx:l,sy:c}=this.scale();return this.translate(-r*l,-o*c,i),this.setDimensions(s*l,a*c,i),new Je(r,o,s,a)},getFitToContentArea:function(t={}){const e=t.gridWidth||1,n=t.gridHeight||1,i=Fa(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,n),s=t.maxWidth||Number.MAX_VALUE,a=t.maxHeight||Number.MAX_VALUE,l=t.allowNewOrigin,c="contentArea"in t?new Je(t.contentArea):this.getContentArea(t),{sx:h,sy:u}=this.scale();c.x*=h,c.y*=u,c.width*=h,c.height*=u;let d=Math.ceil((c.width+c.x)/e),f=Math.ceil((c.height+c.y)/n);t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n;let p=0;("negative"===l&&c.x<0||"positive"===l&&c.x>=0||"any"===l)&&(p=Math.ceil(-c.x/e)*e,p+=i.left,d+=p);let g=0;return("negative"===l&&c.y<0||"positive"===l&&c.y>=0||"any"===l)&&(g=Math.ceil(-c.y/n)*n,g+=i.top,f+=g),d+=i.right,f+=i.bottom,d=Math.max(d,r),f=Math.max(f,o),d=Math.min(d,s),f=Math.min(f,a),new Je(-p/h,-g/u,d/h,f/u)},transformToFitContent:function(t){let e,n;if(t||(t={}),"contentArea"in t){const i=t.contentArea;e=this.localToPaperRect(i),n=new Re(i)}else e=this.getContentBBox(t),n=this.paperToLocalPoint(e);if(!e.width||!e.height)return;zo(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});const i=Fa(t.padding),r=t.minScaleX||t.minScale,o=t.maxScaleX||t.maxScale,s=t.minScaleY||t.minScale,a=t.maxScaleY||t.maxScale;let l;if(t.fittingBBox)l=t.fittingBBox;else{const t=this.translate(),e=this.getComputedSize();l={x:t.tx,y:t.ty,width:e.width,height:e.height}}l=new Je(l).moveAndExpand({x:i.left,y:i.top,width:-i.left-i.right,height:-i.top-i.bottom});const c=this.matrix(),{a:h,d:u,e:d,f}=c;let p=l.width/e.width*h,g=l.height/e.height*u;if(t.preserveAspectRatio&&(p=g=Math.min(p,g)),t.scaleGrid){const e=t.scaleGrid;p=e*Math.floor(p/e),g=e*Math.floor(g/e)}p=Math.min(o,Math.max(r,p)),g=Math.min(a,Math.max(s,g));const m=p/h,v=g/u;let y=l.x-n.x*p-d,b=l.y-n.y*g-f;switch(t.verticalAlign){case"middle":b+=(l.height-e.height*v)/2;break;case"bottom":b+=l.height-e.height*v}switch(t.horizontalAlign){case"middle":y+=(l.width-e.width*m)/2;break;case"right":y+=l.width-e.width*m}c.a=p,c.d=g,c.e=y,c.f=b,this.matrix(c,t)},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new Je:ri(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(...t){const{restrictTranslate:e}=this.options;let n;return n=Ko(e)?e.apply(this,t):!0===e?this.getArea():e?new Je(e):null,n},createViewForModel:function(t){const{options:e}=this;var n,i,r=e.cellViewNamespace,o=t.get("type")+"View",s=wa(r,o,".");return t.isLink()?(n=e.linkView,i=Ju):(n=e.elementView,i=xh),new(n.prototype instanceof rh?s||n:n.call(this,t)||s||i)({model:t,interactive:e.interactive,labelsLayer:!0===e.labelsLayer?Qu.LABELS:e.labelsLayer})},removeView:function(t){const{id:e}=t,{_views:n,_updates:i}=this,r=n[e];if(r){var{cid:o}=r;const{mounted:t,unmounted:s}=i;r.remove(),delete n[e],delete t[o],delete s[o]}return r},renderView:function(t,e){const{id:n}=t,i=this._views;let r,o,s=!0;return n in i&&(r=i[n],r.model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&(r=i[n]=this.createViewForModel(t),r.paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(ss(r,"initFlag"))),this.requestViewUpdate(r,o,r.UPDATE_PRIORITY,e),r},onImageDragStart:function(){return!1},resetViews:function(t,e){e||(e={}),t||(t=[]),this._resetUpdates(),this.removeViews();const n=this.options.autoFreeze?null:"reset";this.freeze({key:n});for(var i=0,r=t.length;i<r;i++)this.renderView(t[i],e);this.unfreeze({key:n}),this.sortViews()},removeViews:function(){Uo(this._views,"remove"),this._views={}},sortViews:function(){this.isExactSorting()&&(this.isFrozen()?this._updates.sort=!0:this.sortViewsExact())},sortViewsExact:function(){var t=Array.from(this.cells.childNodes).filter((t=>t.getAttribute("model-id"))),e=this.model.get("cells");!function(t,n){var i=(t=ma(t).toArray()).map((function(t){var e=t.parentNode,n=e.insertBefore(document.createTextNode(""),t.nextSibling);return function(){if(e===this)throw new Error("You can't sort elements if any one is a descendant of another.");e.insertBefore(this,n),e.removeChild(n)}}));t.sort((function(t,n){var i=e.get(t.getAttribute("model-id")),r=e.get(n.getAttribute("model-id")),o=i.attributes.z||0,s=r.attributes.z||0;return o===s?0:o<s?-1:1}));for(var r=0;r<i.length;r++)i[r].call(t[r])}(t)},insertView:function(t,e){const n=this.getLayerView(Qu.CELLS),{el:i,model:r}=t;this.options.sorting===Dd.APPROX?n.insertSortedNode(i,r.get("z")):n.insertNode(i),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){var e=Vo(t)?this.cells.querySelector(t):t instanceof ma?t[0]:t,n=this.findAttribute("model-id",e);if(n)return this._views[n]},findViewByModel:function(t){var e=Vo(t)||Do(t)?t:t&&t.id;return this._views[e]},findViewsFromPoint:function(t){return t=new Re(t),this.model.getElements().map(this.findViewByModel,this).filter((function(e){return e&&e.vel.getBBox({target:this.cells}).containsPoint(t)}),this)},findViewsInArea:function(t,e){e=zo(e||{},{strict:!1}),t=new Je(t);var n=this.model.getElements().map(this.findViewByModel,this),i=e.strict?"containsRect":"intersect";return n.filter((function(e){return e&&t[i](e.vel.getBBox({target:this.cells}))}),this)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t,...e){"string"==typeof t&&this.trigger("tools:event",t,...e)},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){var n=new Re(t,e);return ri.transformPoint(n,this.matrix())},localToPaperRect:function(t,e,n,i){var r=new Je(t,e,n,i);return ri.transformRect(r,this.matrix())},paperToLocalPoint:function(t,e){var n=new Re(t,e);return ri.transformPoint(n,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){var r=new Je(t,e,n,i);return ri.transformRect(r,this.matrix().inverse())},localToClientPoint:function(t,e){var n=new Re(t,e);return ri.transformPoint(n,this.clientMatrix())},localToClientRect:function(t,e,n,i){var r=new Je(t,e,n,i);return ri.transformRect(r,this.clientMatrix())},clientToLocalPoint:function(t,e){var n=new Re(t,e);return ri.transformPoint(n,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){var r=new Je(t,e,n,i);return ri.transformRect(r,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,n,i){return this.localToPaperRect(t,e,n,i).offset(this.pageOffset())},pageToLocalPoint:function(t,e){var n=new Re(t,e).difference(this.pageOffset());return this.paperToLocalPoint(n)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),o=new Je(t,e,n,i);return o.x-=r.x,o.y-=r.y,this.paperToLocalRect(o)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new Re(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof Ju))throw new Error("Must provide a linkView.");var e=t.model,n=this.options,i=this.model,r=i.constructor.validations;return!(!n.multiLinks&&!r.multiLinks.call(this,i,e)||!n.linkPinning&&!r.linkPinning.call(this,i,e)||"function"==typeof n.allowLink&&!n.allowLink.call(this,t,this))},getDefaultLink:function(t,e){return Ko(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t={}){let{highlighter:e,type:n}=t;const{highlighting:i,highlighterNamespace:r}=this.options;if(void 0===e){if(!i)return!1;if(n&&(e=i[n],!1===e))return!1;e||(e=i.default)}if(!e)return!1;Vo(e)&&(e={name:e});const o=e.name,s=r[o];if(!s)throw new Error('Unknown highlighter ("'+o+'")');if("function"!=typeof s.highlight)throw new Error('Highlighter ("'+o+'") is missing required highlight() method');if("function"!=typeof s.unhighlight)throw new Error('Highlighter ("'+o+'") is missing required unhighlight() method');return{highlighter:s,options:e.options||{},name:o}},onCellHighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.highlight(t,e,o)},onCellUnhighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.unhighlight(t,e,o)},pointerdblclick:function(t){t.preventDefault(),t=Sa(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerdblclick(t,n.x,n.y):this.trigger("blank:pointerdblclick",t,n.x,n.y)}},pointerclick:function(t){if(this.eventData(t).mousemoved<=this.options.clickThreshold){t=Sa(t);var e=this.findView(t.target);if(this.guard(t,e))return;var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerclick(t,n.x,n.y):this.trigger("blank:pointerclick",t,n.x,n.y)}},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.contextMenuFired?this.contextMenuFired=!1:(t=Sa(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.contextmenu(t,n.x,n.y):this.trigger("blank:contextmenu",t,n.x,n.y)}},pointerdown:function(t){t=Sa(t);const{target:e,button:n}=t,i=this.findView(e),r=2===n;if(i){if(!r&&this.guard(t,i))return;const n=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName);this.options.preventDefaultViewAction&&!n&&t.preventDefault(),n&&i.preventDefaultInteraction(t);const o=this.customEventTrigger(t,i);if(o){if(o.isPropagationStopped())return;t.data=o.data}const s=e.closest("[magnet]");if(s&&i.el!==s&&i.el.contains(s)){const e=Sa(new ma.Event(t.originalEvent,{data:t.data,currentTarget:s}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped()){if(r)return;return void this.delegateDragEvents(i,e.data)}t.data=e.data}}if(r){this.contextMenuFired=!0;const e=new ma.Event(t.originalEvent,{type:"contextmenu",data:t.data});this.contextMenuTrigger(e)}else{const e=this.snapToGrid(t.clientX,t.clientY);i?i.pointerdown(t,e.x,e.y):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,e.x,e.y)),this.delegateDragEvents(i,t.data)}},pointermove:function(t){var e=this.eventData(t);if(e.mousemoved||(e.mousemoved=0,this.undelegateEvents()),!(++e.mousemoved<=this.options.moveThreshold)){t=Sa(t);var n=this.snapToGrid(t.clientX,t.clientY),i=e.sourceView;i?i.pointermove(t,n.x,n.y):this.trigger("blank:pointermove",t,n.x,n.y),this.eventData(t,e)}},pointerup:function(t){this.undelegateDocumentEvents();var e=Sa(t),n=this.snapToGrid(e.clientX,e.clientY),i=this.eventData(t).sourceView;i?i.pointerup(e,n.x,n.y):this.trigger("blank:pointerup",e,n.x,n.y),e.isPropagationStopped()||this.pointerclick(new ma.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=Sa(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseover(t);else{if(this.el===t.target)return;this.trigger("blank:mouseover",t)}},mouseout:function(t){t=Sa(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseout(t);else{if(this.el===t.target)return;this.trigger("blank:mouseout",t)}},mouseenter:function(t){t=Sa(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseenter(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseenter",t)},mouseleave:function(t){t=Sa(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseleave(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseleave",t)},_processMouseWheelEvtBuf:function(t,e,n){if("function"!=typeof t)throw new TypeError("Expected a function");let i,r,o,s,a,l,c=0,h=!1,u=!1,d=!0;const f=!e&&0!==e&&window&&"function"==typeof window.requestAnimationFrame;function p(e){const n=i,o=r;return i=r=void 0,c=e,s=t.apply(o,n),s}function g(t,e){return f?(window.cancelAnimationFrame(a),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){const n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=o}function v(){const t=Date.now();if(m(t))return y(t);a=g(v,function(t){const n=t-c,i=e-(t-l);return u?Math.min(i,o-n):i}(t))}function y(t){return a=void 0,d&&i?p(t):(i=r=void 0,s)}function b(...t){const n=Date.now(),o=m(n);if(i=t,r=this,l=n,o){if(void 0===a)return function(t){return c=t,a=g(v,e),h?p(t):s}(l);if(u)return a=g(v,e),p(l)}return void 0===a&&(a=g(v,e)),s}return e=+e||0,Bo(n)&&(h=!!n.leading,u="maxWait"in n,o=u?Math.max(+n.maxWait||0,e):o,d="trailing"in n?!!n.trailing:d),b.cancel=()=>{void 0!==a&&function(t){if(f)return window.cancelAnimationFrame(t);clearTimeout(t)}(a),c=0,i=l=r=a=void 0},b.flush=()=>void 0===a?s:y(Date.now()),b.pending=()=>void 0!==a,b}((function(){const{event:t,deltas:e}=this._mw_evt_buffer,n=e.reduce(((t,e)=>{return t+((n=e)>50?50:n<-50?-50:n);var n}),0),i=Math.pow(.995,n),{x:r,y:o}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,r,o,i),this._mw_evt_buffer={event:null,deltas:[]}}),20,{maxWait:20}),mousewheel:function(t){t=Sa(t);const e=this.findView(t.target);if(this.guard(t,e))return;const n=t.originalEvent,i=this.snapToGrid(n.clientX,n.clientY),{deltaX:r,deltaY:o}=function(t){let e=0,n=0,i=0,r=0;return"detail"in t&&(n=t.detail),"wheelDelta"in t&&(n=-t.wheelDelta/120),"wheelDeltaY"in t&&(n=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=n,n=0),i="deltaX"in t?t.deltaX:10*e,r="deltaY"in t?t.deltaY:10*n,(i||r)&&t.deltaMode&&(1==t.deltaMode?(i*=40,r*=40):(i*=800,r*=800)),0===t.deltaX&&0!==t.deltaY&&t.shiftKey&&(i=r,r=0,e=n,n=0),i&&!e&&(e=i<1?-1:1),r&&!n&&(n=r<1?-1:1),{spinX:e,spinY:n,deltaX:i,deltaY:r}}(n),s=this._events["paper:pinch"];if(t.ctrlKey&&s&&s.length>0)n.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(o),this._processMouseWheelEvtBuf();else{const s=Math.max(-1,Math.min(1,n.wheelDelta));e?e.mousewheel(t,i.x,i.y,s):this.trigger("blank:mousewheel",t,i.x,i.y,s),this.trigger("paper:pan",t,r,o)}},onevent:function(t){var e=t.currentTarget,n=e.getAttribute("event");if(n){var i=this.findView(e);if(i){if(t=Sa(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);i.onevent(t,n,r.x,r.y)}}},magnetEvent:function(t,e){var n=t.currentTarget;if(n.getAttribute("magnet")){var i=this.findView(n);if(i){if(t=Sa(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);e.call(this,i,t,n,r.x,r.y)}}},onmagnet:function(t){if(2===t.button){this.contextMenuFired=!0,this.magnetContextMenuFired=!0;const e=new ma.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget});this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()}else this.magnetEvent(t,(function(t,e,n,i,r){t.onmagnet(e,i,r)}))},magnetpointerdblclick:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetpointerdblclick(e,n,i,r)}))},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetContextMenuFired?this.magnetContextMenuFired=!1:this.magnetContextMenuTrigger(t)},magnetContextMenuTrigger:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetcontextmenu(e,n,i,r)}))},onlabel:function(t){var e=t.currentTarget,n=this.findView(e);if(!n)return;if(t=Sa(t),this.guard(t,n))return;const i=this.customEventTrigger(t,n,e);if(i){if(i.isPropagationStopped())return;t.data=i.data}var r=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,r.x,r.y)},getPointerArgs(t){const e=Sa(t),{x:n,y:i}=this.snapToGrid(e.clientX,e.clientY);return[e,n,i]},delegateDragEvents:function(t,e){e||(e={}),this.eventData({data:e},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){if("mousedown"===t.type&&2===t.button)return!0;if(this.options.guard&&this.options.guard(t,e))return!0;if(t.data&&void 0!==t.data.guarded)return t.data.guarded;const{target:n}=t;return!!this.GUARDED_TAG_NAMES.includes(n.tagName)||!(e&&e.model&&e.model instanceof Ul)&&this.el!==n&&!this.svg.contains(n)},setGridSize:function(t){const{options:e}=this;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(Qu.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(Qu.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",n=t.size||"auto auto",i=this.scale(),r=this.translate();Bo(e)&&(e=r.tx+i.sx*(e.x||0)+"px "+(r.ty+i.sy*(e.y||0))+"px"),Bo(n)&&(n=(n=new Je(n).scale(i.sx,i.sy)).width+"px "+n.height+"px");const{background:o}=this.childNodes;o.style.backgroundSize=n,o.style.backgroundPosition=e},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var n,i=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,s=Math.abs(e.quality)||1,a=this.constructor.backgroundPatterns[hs(r)];if(Ko(a)){t.width*=s,t.height*=s;var l=a(t,e);if(!(l instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=l.toDataURL("image/png"),r="repeat",Bo(i)?(i.width*=l.width/t.width,i.height*=l.height/t.height):void 0===i&&(e.size={width:l.width/s,height:l.height/s})}else n=t.src,void 0===i&&(e.size={width:t.width,height:t.height});this.childNodes.background.style.opacity=o,this.childNodes.background.style.backgroundRepeat=r,this.childNodes.background.style.backgroundImage=`url(${n})`,this.updateBackgroundImage(e)}}else this.childNodes.background.style.backgroundImage=""},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){if(t=t||{},this.updateBackgroundColor(t.color),t.image){t=this._background=Yo(t),Ta(t);var e=document.createElement("img");e.onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image}else this.drawBackgroundImage(null),this._background=null;return this},setInteractivity:function(t){this.options.interactive=t,Uo(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!Bo(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name;if(e||(e=n+this.svg.id+ba(JSON.stringify(t))),!this.isDefined(e)){var i=Da,r=i[n]&&i[n](t.args||{});if(!r)throw new Error("Non-existing filter "+n);var o=$o({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});ri(r,o).appendTo(this.defs)}return e},defineGradient:function(t){if(!Bo(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{type:i,id:r=i+e.id+ba(JSON.stringify(t)),stops:o,attrs:s={}}=t;if(this.isDefined(r))return r;const a=Qo(o).map((({offset:t,color:e,opacity:n})=>ri("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1}))),l=ri(i,s,a);return l.id=r,l.appendTo(n),r},definePattern:function(t){if(!Bo(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+ba(JSON.stringify(t)),markup:r,attrs:o={}}=t;if(!r)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(i))return i;const s=ri("pattern",{patternUnits:"userSpaceOnUse"});if(s.id=i,s.attr(o),"string"==typeof r)s.append(ri(r));else{const{fragment:t}=ya(r);s.append(t)}return s.appendTo(n),i},defineMarker:function(t){if(!Bo(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+ba(JSON.stringify(t)),markup:r,attrs:o={},markerUnits:s="userSpaceOnUse"}=t;if(this.isDefined(i))return i;const a=ri("marker",{orient:"auto",overflow:"visible",markerUnits:s});let l;if(a.id=i,a.attr(o),r){let t;if("string"==typeof r)t=ri(r),t=Array.isArray(t)?t:[t];else{const{fragment:e}=ya(r);t=ri(e).children()}l=t.length>1?ri("g").append(t):t[0]}else{const{type:e="path"}=t;l=ri(e)}const c=as(t,"type","id","markup","attrs","markerUnits");return Object.keys(c).forEach((t=>{const e=c[t],n=l.attr(t);null==n?l.attr(t,e):"transform"===t&&l.attr(t,e+" "+n)})),l.appendTo(a),a.appendTo(n),i},customEventTrigger:function(t,e,n=e.el){const i=t.target.closest("[event]");if(i&&n!==i&&e.el.contains(i)){const e=Sa(new ma.Event(t.originalEvent,{data:t.data,currentTarget:i}));return this.onevent(e),e.isDefaultPrevented()&&t.preventDefault(),e}return null}},{sorting:Dd,Layers:Qu,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,n,i),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,n,i),e},flipX:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(2*n,0),r.scale(-1,1),r.drawImage(t,0,0,n,i),e},flipY:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(0,2*i),r.scale(1,-1),r.drawImage(t,0,0,n,i),e},watermark:function(t,e){e=e||{};var n=t.width,i=t.height,r=document.createElement("canvas");r.width=3*n,r.height=3*i;for(var o=r.getContext("2d"),s=Do(e.watermarkAngle)?-e.watermarkAngle:-20,a=ge(s),l=r.width/4,c=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)(h+u)%2>0&&(o.setTransform(1,0,0,1,(2*h-1)*l,(2*u-1)*c),o.rotate(a),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){ri(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){ri(t).attr({fill:e.color})},update:function(t,e,n){const{sx:i,sy:r}=n.scale(),o=i<=1?e.thickness:e.thickness/i,s=r<=1?e.thickness:e.thickness/r;ri(t).attr({width:o,height:s})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",ri(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",ri(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",ri(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}]}}),Hd=lh.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){const{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}}),qd=lh.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=$o(this.options,t)).tools;if(!Array.isArray(e))return this;var n=t.relatedView;if(!(n instanceof mh))return this;for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof Hd&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}return this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t||(t={});var e=this.tools;if(!e)return this;for(var n=this.isRendered,i=0,r=e.length;i<r;i++){var o=e[i];n?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return this.isMounted()||this.mount(),n||(this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,n=t.length;e<n;e++)t[e].remove();this.tools=null},mount:function(){const{options:t,el:e}=this,{relatedView:n,layer:i=Qu.TOOLS,z:r}=t;return n&&(i?n.paper.getLayerView(i).insertSortedNode(e,r):n.el.appendChild(e)),this}}),Wd=Hd.extend({name:"button",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},options:{distance:0,offset:0,scale:null,rotate:!1},onRender:function(){this.renderChildren(this.options.markup),this.update()},update:function(){return this.position(),this},position:function(){const{vel:t}=this;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){const{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=function(t,e){const{model:n}=t;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}(t,o);const c=t.model.angle();s||(l=l.bbox(c));const{x:h=0,y:u=0}=r;La(n)?n=parseFloat(n)/100*l.width:yl(n)&&(n=Number(xl(n,l))),La(i)?i=parseFloat(i)/100*l.height:yl(i)&&(i=Number(xl(i,l)));let d=ri.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return s&&(d=d.rotate(c)),d=d.translate(n+h-l.width/2,i+u-l.height/2),a&&(d=d.scale(a)),d},getLinkMatrix(){const{relatedView:t,options:e}=this,{offset:n=0,distance:i=0,rotate:r,scale:o}=e;let s,a,l;s=La(i)?t.getTangentAtRatio(parseFloat(i)/100):t.getTangentAtLength(i),s?(a=s.start,l=s.vector().vectorAngle(new Re(1,0))||0):(a=t.getConnection().start,l=0);let c=ri.createSVGMatrix().translate(a.x,a.y).rotate(l).translate(0,n);return r||(c=c.rotate(-l)),o&&(c=c.scale(o)),c},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.options.action;"function"==typeof e&&e.call(this.relatedView,t,this.relatedView,this)}}}),Yd=Wd.extend({name:"remove",children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#FF1D00",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -3 -3 3 3 M -3 3 3 -3",fill:"none",stroke:"#FFFFFF","stroke-width":2,"pointer-events":"none"}}],options:{distance:60,offset:0,action:function(t,e,n){e.model.remove({ui:!0,tool:n.cid})}}}),Xd=Hd.extend({tagName:"path",xAxisVector:new Re(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{scale:null},onRender:function(){this.update()},update:function(){var t,e,n=this.ratio,i=this.relatedView,r=i.getTangentAtRatio(n);if(r?(t=r.start,e=r.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(n),e=0),!t)return this;var o=ri.createSVGMatrix().translate(t.x,t.y).rotate(e);const{scale:s}=this.options;return s&&(o=o.scale(s)),this.vel.transform(o,{absolute:!0}),this},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.relatedView;e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),e.paper.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none"}},onPointerMove:function(t){var e=Sa(t),n=this.paper.snapToGrid(e.clientX,e.clientY);this.relatedView.pointermove(e,n.x,n.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,i=Sa(t),r=n.snapToGrid(i.clientX,i.clientY);e.pointerup(i,r.x,r.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),Zd=Xd.extend({name:"target-arrowhead",ratio:1,arrowheadType:"target",attributes:{d:"M -10 -8 10 0 -10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"target-arrowhead"}}),Kd=Xd.extend({name:"source-arrowhead",ratio:0,arrowheadType:"source",attributes:{d:"M 10 -8 -10 0 10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"source-arrowhead"}});var Jd=function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},Qd=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};let tf=class extends ie{static{this.styles=x`
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qbo4=e():(t.qbo4=t.qbo4||{},t.qbo4["ui-flowchart"]=e())}(self,(()=>(()=>{var t={630:(t,e,n)=>{var i;!function(t){!function(e){var i="object"==typeof globalThis?globalThis:"object"==typeof n.g?n.g:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=o(t);function o(t,e){return function(n,i){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:i}),e&&e(n,i)}}void 0!==i.Reflect&&(r=o(i.Reflect,r)),function(t,e){var n=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,r=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",s="function"==typeof Object.create,a={__proto__:[]}instanceof Array,l=!s&&!a,c={create:s?function(){return $(Object.create(null))}:a?function(){return $({__proto__:null})}:function(){return $({})},has:l?function(t,e){return n.call(t,e)}:function(t,e){return e in t},get:l?function(t,e){return n.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},u=Object.getPrototypeOf(Function),h="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var i=this._keys.length,r=n+1;r<i;r++)this._keys[r-1]=this._keys[r],this._values[r-1]=this._values[r];return this._keys.length--,this._values.length--,R(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new n(this._keys,this._values,i)},e.prototype.values=function(){return new n(this._keys,this._values,r)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!R(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(R(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function i(t,e){return t}function r(t,e){return e}function s(t,e){return[t,e]}}(),d="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function t(){this._map=new h}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}(),f="function"==typeof WeakMap?WeakMap:function(){var t=16,e=c.create(),i=r();return function(){function t(){this._key=r()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=r()},t}();function r(){var t;do{t="@@WeakMap@@"+a()}while(c.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,i)){if(!e)return;Object.defineProperty(t,i,{value:c.create()})}return t[i]}function s(t,e){for(var n=0;n<e;++n)t[n]=255*Math.random()|0;return t}function a(){var e=function(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):s(e,t),e}return s(new Array(t),t)}(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var n="",i=0;i<t;++i){var r=e[i];4!==i&&6!==i&&8!==i||(n+="-"),r<16&&(n+="0"),n+=r.toString(16).toLowerCase()}return n}}(),p=i?Symbol.for("@reflect-metadata:registry"):void 0,g=function(){var t;return!S(p)&&_(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[p]),S(t)&&(t=function(){var t,n,i,r;S(p)||void 0===e.Reflect||p in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=function(t){var e=t.defineMetadata,n=t.hasOwnMetadata,i=t.getOwnMetadata,r=t.getOwnMetadataKeys,o=t.deleteMetadata,s=new f;return{isProviderFor:function(t,e){var n=s.get(t);return!(S(n)||!n.has(e))||!!r(t,e).length&&(S(n)&&(n=new d,s.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:r,OrdinaryDeleteMetadata:o}}(e.Reflect));var o=new f,s={registerProvider:a,getProvider:c,setProvider:g};return s;function a(e){if(!Object.isExtensible(s))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case S(n):n=e;break;case n===e:break;case S(i):i=e;break;case i===e:break;default:void 0===r&&(r=new d),r.add(e)}}function l(e,o){if(!S(n)){if(n.isProviderFor(e,o))return n;if(!S(i)){if(i.isProviderFor(e,o))return n;if(!S(r))for(var s=B(r);;){var a=D(s);if(!a)return;var l=I(a);if(l.isProviderFor(e,o))return V(s),l}}}if(!S(t)&&t.isProviderFor(e,o))return t}function c(t,e){var n,i=o.get(t);return S(i)||(n=i.get(e)),S(n)?(S(n=l(t,e))||(S(i)&&(i=new h,o.set(t,i)),i.set(e,n)),n):n}function u(t){if(S(t))throw new TypeError;return n===t||i===t||!S(r)&&r.has(t)}function g(t,e,n){if(!u(n))throw new Error("Metadata provider not registered.");var i=c(t,e);if(i!==n){if(!S(i))return!1;var r=o.get(t);S(r)&&(r=new h,o.set(t,r)),r.set(e,n)}return!0}}()),!S(p)&&_(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}(),m=function(t){var e=new f,n={isProviderFor:function(t,n){var i=e.get(t);return!S(i)&&i.has(n)},OrdinaryDefineOwnMetadata:function(t,e,n,r){i(n,r,!0).set(t,e)},OrdinaryHasOwnMetadata:function(t,e,n){var r=i(e,n,!1);return!S(r)&&C(r.has(t))},OrdinaryGetOwnMetadata:function(t,e,n){var r=i(e,n,!1);if(!S(r))return r.get(t)},OrdinaryOwnMetadataKeys:function(t,e){var n=[],r=i(t,e,!1);if(S(r))return n;for(var o=B(r.keys()),s=0;;){var a=D(o);if(!a)return n.length=s,n;var l=I(a);try{n[s]=l}catch(t){try{V(o)}finally{throw t}}s++}},OrdinaryDeleteMetadata:function(t,n,r){var o=i(n,r,!1);if(S(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var s=e.get(n);S(s)||(s.delete(r),0===s.size&&e.delete(s))}return!0}};return g.registerProvider(n),n;function i(i,r,o){var s=e.get(i),a=!1;if(S(s)){if(!o)return;s=new h,e.set(i,s),a=!0}var l=s.get(r);if(S(l)){if(!o)return;if(l=new h,s.set(r,l),!t.setProvider(i,r,n))throw s.delete(r),a&&e.delete(i),new Error("Wrong provider for target.")}return l}}(g);function v(t,e,n){if(y(t,e,n))return!0;var i=z(e);return!P(i)&&v(t,i,n)}function y(t,e,n){var i=j(e,n,!1);return!S(i)&&C(i.OrdinaryHasOwnMetadata(t,e,n))}function b(t,e,n){if(y(t,e,n))return w(t,e,n);var i=z(e);return P(i)?void 0:b(t,i,n)}function w(t,e,n){var i=j(e,n,!1);if(!S(i))return i.OrdinaryGetOwnMetadata(t,e,n)}function x(t,e,n,i){j(n,i,!0).OrdinaryDefineOwnMetadata(t,e,n,i)}function A(t,e){var n=E(t,e),i=z(t);if(null===i)return n;var r=A(i,e);if(r.length<=0)return n;if(n.length<=0)return r;for(var o=new d,s=[],a=0,l=n;a<l.length;a++){var c=l[a];o.has(c)||(o.add(c),s.push(c))}for(var u=0,h=r;u<h.length;u++)c=h[u],o.has(c)||(o.add(c),s.push(c));return s}function E(t,e){var n=j(t,e,!1);return n?n.OrdinaryOwnMetadataKeys(t,e):[]}function T(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function S(t){return void 0===t}function P(t){return null===t}function _(t){return"object"==typeof t?null!==t:"function"==typeof t}function k(t,e){switch(T(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n=3===e?"string":5===e?"number":"default",i=F(t,r);if(void 0!==i){var o=i.call(t,n);if(_(o))throw new TypeError;return o}return function(t,e){if("string"===e){var n=t.toString;if(O(n)&&!_(r=n.call(t)))return r;if(O(i=t.valueOf)&&!_(r=i.call(t)))return r}else{var i;if(O(i=t.valueOf)&&!_(r=i.call(t)))return r;var r,o=t.toString;if(O(o)&&!_(r=o.call(t)))return r}throw new TypeError}(t,"default"===n?"number":n)}function C(t){return!!t}function L(t){var e=k(t,3);return"symbol"==typeof e?e:function(t){return""+t}(e)}function M(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function O(t){return"function"==typeof t}function N(t){return"function"==typeof t}function R(t,e){return t===e||t!=t&&e!=e}function F(t,e){var n=t[e];if(null!=n){if(!O(n))throw new TypeError;return n}}function B(t){var e=F(t,o);if(!O(e))throw new TypeError;var n=e.call(t);if(!_(n))throw new TypeError;return n}function I(t){return t.value}function D(t){var e=t.next();return!e.done&&e}function V(t){var e=t.return;e&&e.call(t)}function z(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var n=t.prototype,i=n&&Object.getPrototypeOf(n);if(null==i||i===Object.prototype)return e;var r=i.constructor;return"function"!=typeof r||r===t?e:r}function j(t,e,n){var i=g.getProvider(t,e);if(!S(i))return i;if(n){if(g.setProvider(t,e,m))return m;throw new Error("Illegal state.")}}function $(t){return t.__=void 0,delete t.__,t}t("decorate",(function(t,e,n,i){if(S(n)){if(!M(t))throw new TypeError;if(!N(e))throw new TypeError;return function(t,e){for(var n=t.length-1;n>=0;--n){var i=(0,t[n])(e);if(!S(i)&&!P(i)){if(!N(i))throw new TypeError;e=i}}return e}(t,e)}if(!M(t))throw new TypeError;if(!_(e))throw new TypeError;if(!_(i)&&!S(i)&&!P(i))throw new TypeError;return P(i)&&(i=void 0),function(t,e,n,i){for(var r=t.length-1;r>=0;--r){var o=(0,t[r])(e,n,i);if(!S(o)&&!P(o)){if(!_(o))throw new TypeError;i=o}}return i}(t,e,n=L(n),i)})),t("metadata",(function(t,e){return function(n,i){if(!_(n))throw new TypeError;if(!S(i)&&!function(t){switch(T(t)){case 3:case 4:return!0;default:return!1}}(i))throw new TypeError;x(t,e,n,i)}})),t("defineMetadata",(function(t,e,n,i){if(!_(n))throw new TypeError;return S(i)||(i=L(i)),x(t,e,n,i)})),t("hasMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=L(n)),v(t,e,n)})),t("hasOwnMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=L(n)),y(t,e,n)})),t("getMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=L(n)),b(t,e,n)})),t("getOwnMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=L(n)),w(t,e,n)})),t("getMetadataKeys",(function(t,e){if(!_(t))throw new TypeError;return S(e)||(e=L(e)),A(t,e)})),t("getOwnMetadataKeys",(function(t,e){if(!_(t))throw new TypeError;return S(e)||(e=L(e)),E(t,e)})),t("deleteMetadata",(function(t,e,n){if(!_(e))throw new TypeError;if(S(n)||(n=L(n)),!_(e))throw new TypeError;S(n)||(n=L(n));var i=j(e,n,!1);return!S(i)&&i.OrdinaryDeleteMetadata(t,e,n)}))}(r,i),void 0===i.Reflect&&(i.Reflect=t)}()}(i||(i={}))}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.r(i),n.d(i,{QboFlowchart:()=>vd});var t={};n.r(t),n.d(t,{ellipseWithEllipse:()=>qe,ellipseWithLine:()=>Ge,exists:()=>$e,lineWithLine:()=>Ue,pathWithEllipse:()=>sn,pathWithLine:()=>on,pathWithPath:()=>un,pathWithPolygon:()=>cn,pathWithPolyline:()=>ln,pathWithRect:()=>an,polygonWithEllipse:()=>tn,polygonWithLine:()=>Qe,polygonWithPolygon:()=>rn,polygonWithPolyline:()=>nn,polygonWithRect:()=>en,polylineWithEllipse:()=>Ze,polylineWithLine:()=>Xe,polylineWithPolyline:()=>Je,polylineWithRect:()=>Ke,rectWithEllipse:()=>We,rectWithLine:()=>He,rectWithRect:()=>Ye});var e={};n.r(e),n.d(e,{Curve:()=>Pe,Ellipse:()=>se,Line:()=>ee,Path:()=>ke,Point:()=>Kt,Polygon:()=>je,Polyline:()=>we,Rect:()=>ge,bezier:()=>ze,ellipse:()=>ae,intersection:()=>bn,line:()=>ne,normalizeAngle:()=>Ct,point:()=>Jt,random:()=>Nt,rect:()=>me,scale:()=>kt,snapToGrid:()=>Lt,toDeg:()=>Mt,toRad:()=>Ot,types:()=>zt});var r={};n.r(r),n.d(r,{addClass:()=>cs,append:()=>Qo,appendTo:()=>es,children:()=>ds,clone:()=>Ko,closest:()=>fs,css:()=>os,data:()=>ss,detach:()=>Xo,empty:()=>Zo,hasClass:()=>hs,height:()=>ys,html:()=>Jo,off:()=>ms,offset:()=>ws,on:()=>ps,one:()=>gs,position:()=>bs,prepend:()=>ts,prependTo:()=>ns,remove:()=>Yo,removeClass:()=>ls,toggleClass:()=>us,width:()=>vs});var o={};n.r(o),n.d(o,{animate:()=>Es,stop:()=>Ss});var s={};n.r(s),n.d(s,{absolute:()=>dl,bottom:()=>yl,ellipse:()=>wl,ellipseSpread:()=>bl,fn:()=>fl,left:()=>gl,line:()=>pl,right:()=>ml,top:()=>vl});var a={};n.r(a),n.d(a,{bottom:()=>Ll,inside:()=>Rl,insideOriented:()=>Nl,left:()=>_l,manual:()=>Pl,outside:()=>Ol,outsideOriented:()=>Ml,radial:()=>Fl,radialOriented:()=>Bl,right:()=>kl,top:()=>Cl});var l={};n.r(l),n.d(l,{BorderedImage:()=>Zl,Circle:()=>Gl,Cylinder:()=>tc,DoubleLink:()=>rc,Ellipse:()=>ql,EmbeddedImage:()=>Kl,HeaderedRectangle:()=>Ql,Image:()=>Xl,InscribedImage:()=>Jl,Link:()=>ic,Path:()=>Hl,Polygon:()=>Wl,Polyline:()=>Yl,Rectangle:()=>Ul,ShadowLink:()=>oc,TextBlock:()=>nc});var c={};n.r(c),n.d(c,{standard:()=>l});var u={};n.r(u),n.d(u,{manhattan:()=>bu,metro:()=>xu,normal:()=>Vc,oneSide:()=>zc,orthogonal:()=>eu,rightAngle:()=>Iu});var h={};n.r(h),n.d(h,{curve:()=>rh,jumpover:()=>Ku,normal:()=>Ju,rounded:()=>th,smooth:()=>eh,straight:()=>$u});var d={};n.r(d),n.d(d,{addClass:()=>Eh,list:()=>Sh,mask:()=>wh,opacity:()=>xh,stroke:()=>yh});var f={};n.r(f),n.d(f,{connectionClosest:()=>Mh,connectionLength:()=>_h,connectionPerpendicular:()=>Lh,connectionRatio:()=>Ph,resolveRef:()=>kh});var p={};n.r(p),n.d(p,{anchor:()=>Ih,bbox:()=>Dh,boundary:()=>zh,rectangle:()=>Vh});var g={};n.r(g),n.d(g,{bottom:()=>Gh,bottomLeft:()=>Xh,bottomRight:()=>Zh,center:()=>$h,left:()=>qh,midSide:()=>Jh,modelCenter:()=>Qh,perpendicular:()=>Kh,right:()=>Hh,top:()=>Uh,topLeft:()=>Wh,topRight:()=>Yh}),n(630);const m=window,v=m.ShadowRoot&&(void 0===m.ShadyCSS||m.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,y=Symbol(),b=new WeakMap;class w{constructor(t,e,n){if(this._$cssResult$=!0,n!==y)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(v&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=b.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&b.set(e,t))}return t}toString(){return this.cssText}}const x=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,n,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[i+1]),t[0]);return new w(n,t,y)},A=v?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new w("string"==typeof t?t:t+"",void 0,y))(e)})(t):t;var E;const T=window,S=T.trustedTypes,P=S?S.emptyScript:"",_=T.reactiveElementPolyfillSupport,k={toAttribute(t,e){switch(e){case Boolean:t=t?P:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},C=(t,e)=>e!==t&&(e==e||t==t),L={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:C},M="finalized";class O extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,n)=>{const i=this._$Ep(n,e);void 0!==i&&(this._$Ev.set(i,n),t.push(i))})),t}static createProperty(t,e=L){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const n="symbol"==typeof t?Symbol():"__"+t,i=this.getPropertyDescriptor(t,n,e);void 0!==i&&Object.defineProperty(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){return{get(){return this[e]},set(i){const r=this[t];this[e]=i,this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||L}static finalize(){if(this.hasOwnProperty(M))return!1;this[M]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const n of e)this.createProperty(n,t[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(A(t))}else void 0!==t&&e.push(A(t));return e}static _$Ep(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,n;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(n=t.hostConnected)||void 0===n||n.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{v?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const n=document.createElement("style"),i=m.litNonce;void 0!==i&&n.setAttribute("nonce",i),n.textContent=e.cssText,t.appendChild(n)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$EO(t,e,n=L){var i;const r=this.constructor._$Ep(t,n);if(void 0!==r&&!0===n.reflect){const o=(void 0!==(null===(i=n.converter)||void 0===i?void 0:i.toAttribute)?n.converter:k).toAttribute(e,n.type);this._$El=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$El=null}}_$AK(t,e){var n;const i=this.constructor,r=i._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=i.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(n=t.converter)||void 0===n?void 0:n.fromAttribute)?t.converter:k;this._$El=r,this[r]=o.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,n){let i=!0;void 0!==t&&(((n=n||this.constructor.getPropertyOptions(t)).hasChanged||C)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,n))):i=!1),!this.isUpdatePending&&i&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(n)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(n)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}var N;O[M]=!0,O.elementProperties=new Map,O.elementStyles=[],O.shadowRootOptions={mode:"open"},null==_||_({ReactiveElement:O}),(null!==(E=T.reactiveElementVersions)&&void 0!==E?E:T.reactiveElementVersions=[]).push("1.6.3");const R=window,F=R.trustedTypes,B=F?F.createPolicy("lit-html",{createHTML:t=>t}):void 0,I="$lit$",D=`lit$${(Math.random()+"").slice(9)}$`,V="?"+D,z=`<${V}>`,j=document,$=()=>j.createComment(""),U=t=>null===t||"object"!=typeof t&&"function"!=typeof t,G=Array.isArray,q="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,W=/-->/g,Y=/>/g,X=RegExp(`>|${q}(?:([^\\s"'>=/]+)(${q}*=${q}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Z=/'/g,K=/"/g,J=/^(?:script|style|textarea|title)$/i,Q=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),tt=Q(1),et=(Q(2),Symbol.for("lit-noChange")),nt=Symbol.for("lit-nothing"),it=new WeakMap,rt=j.createTreeWalker(j,129,null,!1);function ot(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==B?B.createHTML(e):e}const st=(t,e)=>{const n=t.length-1,i=[];let r,o=2===e?"<svg>":"",s=H;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,u=0;for(;u<n.length&&(s.lastIndex=u,l=s.exec(n),null!==l);)u=s.lastIndex,s===H?"!--"===l[1]?s=W:void 0!==l[1]?s=Y:void 0!==l[2]?(J.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=X):void 0!==l[3]&&(s=X):s===X?">"===l[0]?(s=null!=r?r:H,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?X:'"'===l[3]?K:Z):s===K||s===Z?s=X:s===W||s===Y?s=H:(s=X,r=void 0);const h=s===X&&t[e+1].startsWith("/>")?" ":"";o+=s===H?n+z:c>=0?(i.push(a),n.slice(0,c)+I+n.slice(c)+D+h):n+D+(-2===c?(i.push(void 0),e):h)}return[ot(t,o+(t[n]||"<?>")+(2===e?"</svg>":"")),i]};class at{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,o=0;const s=t.length-1,a=this.parts,[l,c]=st(t,e);if(this.el=at.createElement(l,n),rt.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(i=rt.nextNode())&&a.length<s;){if(1===i.nodeType){if(i.hasAttributes()){const t=[];for(const e of i.getAttributeNames())if(e.endsWith(I)||e.startsWith(D)){const n=c[o++];if(t.push(e),void 0!==n){const t=i.getAttribute(n.toLowerCase()+I).split(D),e=/([.?@])?(.*)/.exec(n);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?dt:"?"===e[1]?pt:"@"===e[1]?gt:ht})}else a.push({type:6,index:r})}for(const e of t)i.removeAttribute(e)}if(J.test(i.tagName)){const t=i.textContent.split(D),e=t.length-1;if(e>0){i.textContent=F?F.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],$()),rt.nextNode(),a.push({type:2,index:++r});i.append(t[e],$())}}}else if(8===i.nodeType)if(i.data===V)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf(D,t+1));)a.push({type:7,index:r}),t+=D.length-1}r++}}static createElement(t,e){const n=j.createElement("template");return n.innerHTML=t,n}}function lt(t,e,n=t,i){var r,o,s,a;if(e===et)return e;let l=void 0!==i?null===(r=n._$Co)||void 0===r?void 0:r[i]:n._$Cl;const c=U(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==c&&(null===(o=null==l?void 0:l._$AO)||void 0===o||o.call(l,!1),void 0===c?l=void 0:(l=new c(t),l._$AT(t,n,i)),void 0!==i?(null!==(s=(a=n)._$Co)&&void 0!==s?s:a._$Co=[])[i]=l:n._$Cl=l),void 0!==l&&(e=lt(t,l._$AS(t,e.values),l,i)),e}class ct{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:n},parts:i}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:j).importNode(n,!0);rt.currentNode=r;let o=rt.nextNode(),s=0,a=0,l=i[0];for(;void 0!==l;){if(s===l.index){let e;2===l.type?e=new ut(o,o.nextSibling,this,t):1===l.type?e=new l.ctor(o,l.name,l.strings,this,t):6===l.type&&(e=new mt(o,this,t)),this._$AV.push(e),l=i[++a]}s!==(null==l?void 0:l.index)&&(o=rt.nextNode(),s++)}return rt.currentNode=j,r}v(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class ut{constructor(t,e,n,i){var r;this.type=2,this._$AH=nt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cp=null===(r=null==i?void 0:i.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=lt(this,t,e),U(t)?t===nt||null==t||""===t?(this._$AH!==nt&&this._$AR(),this._$AH=nt):t!==this._$AH&&t!==et&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>G(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==nt&&U(this._$AH)?this._$AA.nextSibling.data=t:this.$(j.createTextNode(t)),this._$AH=t}g(t){var e;const{values:n,_$litType$:i}=t,r="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=at.createElement(ot(i.h,i.h[0]),this.options)),i);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(n);else{const t=new ct(r,this),e=t.u(this.options);t.v(n),this.$(e),this._$AH=t}}_$AC(t){let e=it.get(t.strings);return void 0===e&&it.set(t.strings,e=new at(t)),e}T(t){G(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new ut(this.k($()),this.k($()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var n;for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class ht{constructor(t,e,n,i,r){this.type=1,this._$AH=nt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=nt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,n,i){const r=this.strings;let o=!1;if(void 0===r)t=lt(this,t,e,0),o=!U(t)||t!==this._$AH&&t!==et,o&&(this._$AH=t);else{const i=t;let s,a;for(t=r[0],s=0;s<r.length-1;s++)a=lt(this,i[n+s],e,s),a===et&&(a=this._$AH[s]),o||(o=!U(a)||a!==this._$AH[s]),a===nt?t=nt:t!==nt&&(t+=(null!=a?a:"")+r[s+1]),this._$AH[s]=a}o&&!i&&this.j(t)}j(t){t===nt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class dt extends ht{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===nt?void 0:t}}const ft=F?F.emptyScript:"";class pt extends ht{constructor(){super(...arguments),this.type=4}j(t){t&&t!==nt?this.element.setAttribute(this.name,ft):this.element.removeAttribute(this.name)}}class gt extends ht{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){var n;if((t=null!==(n=lt(this,t,e,0))&&void 0!==n?n:nt)===et)return;const i=this._$AH,r=t===nt&&i!==nt||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==nt&&(i===nt||r);r&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,n;"function"==typeof this._$AH?this._$AH.call(null!==(n=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==n?n:this.element,t):this._$AH.handleEvent(t)}}class mt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){lt(this,t)}}const vt=R.litHtmlPolyfillSupport;var yt,bt;null==vt||vt(at,ut),(null!==(N=R.litHtmlVersions)&&void 0!==N?N:R.litHtmlVersions=[]).push("2.8.0");class wt extends O{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const n=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=n.firstChild),n}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,n)=>{var i,r;const o=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:e;let s=o._$litPart$;if(void 0===s){const t=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:null;o._$litPart$=s=new ut(e.insertBefore($(),t),t,void 0,null!=n?n:{})}return s._$AI(t),s})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return et}}wt.finalized=!0,wt._$litElement$=!0,null===(yt=globalThis.litElementHydrateSupport)||void 0===yt||yt.call(globalThis,{LitElement:wt});const xt=globalThis.litElementPolyfillSupport;null==xt||xt({LitElement:wt}),(null!==(bt=globalThis.litElementVersions)&&void 0!==bt?bt:globalThis.litElementVersions=[]).push("3.3.3");const At=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(n){n.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(n){n.createProperty(e.key,t)}};function Et(t){return(e,n)=>void 0!==n?((t,e,n)=>{e.constructor.createProperty(n,t)})(t,e,n):At(t,e)}var Tt;null===(Tt=window.HTMLSlotElement)||void 0===Tt||Tt.prototype.assignedElements;const{round:St,floor:Pt,PI:_t}=Math,kt={linear:function(t,e,n){var i=t[1]-t[0],r=e[1]-e[0];return(n-t[0])/i*r+e[0]||0}},Ct=function(t){return t%360+(t<0?360:0)},Lt=function(t,e){return e*St(t/e)},Mt=function(t){return 180*t/_t%360},Ot=function(t,e){return(t=(e=e||!1)?t:t%360)*_t/180},Nt=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){const n=t;t=e,e=n}return Pt(Math.random()*(e-t+1)+t)},{cos:Rt,sin:Ft,atan2:Bt}=Math,It=function(t,e){var n=Ot(t.y),i=Ot(e.y),r=t.x,o=e.x,s=Ot(o-r),a=Ft(s)*Rt(i),l=Rt(n)*Ft(i)-Ft(n)*Rt(i)*Rt(s),c=Mt(Bt(a,l))-22.5;return c<0&&(c+=360),["NE","E","SE","S","SW","W","NW","N"][c=parseInt(c/45)]},Dt=function(t,e){var n=t.x,i=t.y;return(n-=e.x)*n+(i-=e.y)*i},Vt=function(t,e){return Math.sqrt(Dt(t,e))},zt={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:jt,cos:$t,sin:Ut,sqrt:Gt,min:qt,max:Ht,atan2:Wt,round:Yt,pow:Xt,PI:Zt}=Math,Kt=function(t,e){if(!(this instanceof Kt))return new Kt(t,e);if("string"==typeof t){var n=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(n[0]),e=parseFloat(n[1])}else Object(t)===t&&(e=t.y,t=t.x);this.x=void 0===t?0:t,this.y=void 0===e?0:e};Kt.fromPolar=function(t,e,n){n=new Kt(n);var i=jt(t*$t(e)),r=jt(t*Ut(e)),o=Ct(Mt(e));return o<90?r=-r:o<180?(i=-i,r=-r):o<270&&(i=-i),new Kt(n.x+i,n.y+r)},Kt.random=function(t,e,n,i){return new Kt(Nt(t,e),Nt(n,i))},Kt.prototype={type:zt.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new Kt(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new Kt(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=qt(Ht(this.x,t.x),t.x+t.width),this.y=qt(Ht(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var n=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return It(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new Kt(this)},cross:function(t,e){return t&&e?(e.x-this.x)*(t.y-this.y)-(e.y-this.y)*(t.x-this.x):NaN},difference:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),new Kt(this.x-(t||0),this.y-(e||0))},distance:function(t){return Vt(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,e){var n=this.x,i=this.y;return new Kt((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return Gt(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return jt(t.x-this.x)+jt(t.y-this.y)},move:function(t,e){var n=Ot(new Kt(t).theta(this));return this.offset($t(n)*e,-Ut(n)*e)},normalize:function(t){var e=(t||1)/this.magnitude();return this.scale(e,e)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new Kt(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new Kt(0,0),e=Ot(Ct(-e));var n=$t(e),i=Ut(e),r=n*(this.x-t.x)-i*(this.y-t.y)+t.x,o=i*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=r,this.y=o,this},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Xt(10,t)}return this.x=Yt(this.x*e)/e,this.y=Yt(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new Kt(n)||new Kt(0,0),this.x=n.x+t*(this.x-n.x),this.y=n.y+e*(this.y-n.y),this},snapToGrid:function(t,e){return this.x=Lt(this.x,t),this.y=Lt(this.y,e||t),this},squaredDistance:function(t){return Dt(this,t)},theta:function(t){var e=-((t=new Kt(t)).y-this.y),n=t.x-this.x,i=Wt(e,n);return i<0&&(i=2*Zt+i),180*i/Zt},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new Kt(t)||new Kt(0,0);var e=this.x,n=this.y;return this.x=Gt((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Ot(t.theta(new Kt(e,n))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0,this},vectorAngle:function(t){return new Kt(0,0).angleBetween(this,t)}},Kt.prototype.translate=Kt.prototype.offset;const Jt=Kt,{max:Qt,min:te}=Math,ee=function(t,e){return this instanceof ee?t instanceof ee?new ee(t.start,t.end):(this.start=new Kt(t),void(this.end=new Kt(e))):new ee(t,e)};ee.prototype={type:zt.Line,angle:function(){var t=new Kt(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=te(this.start.x,this.end.x),e=te(this.start.y,this.end.y),n=Qt(this.start.x,this.end.x),i=Qt(this.start.y,this.end.y);return new ge(t,e,n-t,i-e)},bearing:function(){return It(this.start,this.end)},clone:function(){return new ee(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){var e=this.vector().dot(new ee(this.start,t).vector()),n=te(1,Qt(0,e/this.squaredLength()));return n!=n?0:n},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,n=this.end;if(0!==e.cross(t,n))return!1;var i=this.length();return!(new ee(e,t).length()>i||new ee(t,n).length()>i)},divideAt:function(t){var e=this.pointAt(t);return[new ee(this.start,e),new ee(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new ee(this.start,e),new ee(e,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){if(t&&t.intersectionWithLine){var n=t.intersectionWithLine(this,e);return n&&t instanceof ee&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new Kt(this.end.x-this.start.x,this.end.y-this.start.y),n=new Kt(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,r=new Kt(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,s=r.x*e.y-r.y*e.x;if(0===i||o*i<0||s*i<0)return null;if(i>0){if(o>i||s>i)return null}else if(o<i||s<i)return null;return[new Kt(this.start.x+o*e.x/i,this.start.y+o*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Vt(this.start,this.end)},midpoint:function(){return new Kt((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){const e=this.clone();if(!this.isDifferentiable())return e;const{start:n,end:i}=e,r=n.clone().rotate(i,270),o=i.clone().rotate(n,90);return n.move(o,t),i.move(r,t),e},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():t>=1?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0;t<0&&(i=!1,t=-t);var r=this.length();return t>=r?i?n.clone():e.clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new Kt(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();if(!e)return this;var n=t/e;return this.scale(n,n,this.start)},squaredLength:function(){return Dt(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAt(t),r=new ee(e,n);return r.translate(i.x-e.x,i.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAtLength(t),r=new ee(e,n);return r.translate(i.x-e.x,i.y-e.y),r},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new Kt(this.end.x-this.start.x,this.end.y-this.start.y)}},ee.prototype.intersection=ee.prototype.intersect;const ne=ee,{sqrt:ie,round:re,pow:oe}=Math,se=function(t,e,n){return this instanceof se?t instanceof se?new se(new Kt(t.x,t.y),t.a,t.b):(t=new Kt(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new se(t,e,n)};se.fromRect=function(t){return t=new ge(t),new se(t.center(),t.width/2,t.height/2)},se.prototype={type:zt.Ellipse,bbox:function(){return new ge(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new Kt(this.x,this.y)},clone:function(){return new se(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.a+=2*t,this.b+=2*e,this},intersectionWithLine:function(t){var e=[],n=t.start,i=t.end,r=this.a,o=this.b,s=t.vector(),a=n.difference(new Kt(this)),l=new Kt(s.x/(r*r),s.y/(o*o)),c=new Kt(a.x/(r*r),a.y/(o*o)),u=s.dot(l),h=s.dot(c),d=h*h-u*(a.dot(c)-1);if(d<0)return null;if(d>0){var f=ie(d),p=(-h-f)/u,g=(-h+f)/u;if((p<0||1<p)&&(g<0||1<g))return null;0<=p&&p<=1&&e.push(n.lerp(i,p)),0<=g&&g<=1&&e.push(n.lerp(i,g))}else{var m=-h/u;if(!(0<=m&&m<=1))return null;e.push(n.lerp(i,m))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new Kt(t),e&&t.rotate(new Kt(this.x,this.y),e);var n,i=t.x-this.x,r=t.y-this.y;if(0===i)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new Kt(this.x,this.y),-e):n;var o=r/i,s=o*o,a=this.a*this.a,l=this.b*this.b,c=ie(1/(1/a+s/l)),u=o*(c=i<0?-c:c);return n=new Kt(this.x+c,this.y+u),e?n.rotate(new Kt(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,i=this.a,r=this.b,o=this.x,s=this.y;return(e-o)*(e-o)/(i*i)+(n-s)*(n-s)/(r*r)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=oe(10,t)}return this.x=re(this.x*e)/e,this.y=re(this.y*e)/e,this.a=re(this.a*e)/e,this.b=re(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,s=this.b,a=this.bbox().center(),l=a.x,c=a.y,u=i>a.x+o/2,h=i<a.x-o/2;return u||h?n=o*o/(i-l)-o*o*(r-c)*((e=i>a.x?r-30:r+30)-c)/(s*s*(i-l))+l:e=s*s/(r-c)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-c))+c,new Kt(n,e).theta(t)},toString:function(){return new Kt(this.x,this.y).toString()+" "+this.a+" "+this.b}};const ae=se,{abs:le,cos:ce,sin:ue,min:he,max:de,round:fe,pow:pe}=Math,ge=function(t,e,n,i){if(!(this instanceof ge))return new ge(t,e,n,i);Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===n?0:n,this.height=void 0===i?0:i};ge.fromEllipse=function(t){return t=new se(t),new ge(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},ge.fromPointUnion=function(...t){if(0===t.length)return null;const e=new Kt;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y;a<n&&(n=a),a>r&&(r=a),l<i&&(i=l),l>o&&(o=l)}return new ge(n,i,r-n,o-i)},ge.fromRectUnion=function(...t){if(0===t.length)return null;const e=new ge;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y,c=a+e.width,u=l+e.height;a<n&&(n=a),c>r&&(r=c),l<i&&(i=l),u>o&&(o=u)}return new ge(n,i,r-n,o-i)},ge.prototype={type:zt.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;const{width:e,height:n}=this,i=Ot(t),r=le(ue(i)),o=le(ce(i)),s=e*o+n*r,a=e*r+n*o;return this.x+=(e-s)/2,this.y+=(n-a)/2,this.width=s,this.height=a,this},bottomLeft:function(){return new Kt(this.x,this.y+this.height)},bottomLine:function(){return new ee(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new Kt(this.x+this.width/2,this.y+this.height)},center:function(){return new Kt(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new ge(this)},containsPoint:function(t){return t instanceof Kt||(t=new Kt(t)),t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new ge(this).normalize(),n=new ge(t).normalize(),i=e.width,r=e.height,o=n.width,s=n.height;if(!(i&&r&&o&&s))return!1;var a=e.x,l=e.y,c=n.x,u=n.y;return o+=c,i+=a,s+=u,r+=l,a<=c&&o<=i&&l<=u&&s<=r},corner:function(){return new Kt(this.x+this.width,this.y+this.height)},equals:function(t){var e=new ge(this).normalize(),n=new ge(t).normalize();return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),n=this.corner(),i=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||i.x>=n.x||i.y>=n.y)return null;var o=de(e.x,i.x),s=de(e.y,i.y);return new ge(o,s,he(n.x,r.x)-o,he(n.y,r.y)-s)},intersectionWithLine:function(t){var e,n,i=this,r=[i.topLine(),i.rightLine(),i.bottomLine(),i.leftLine()],o=[],s=[],a=r.length;for(n=0;n<a;n++)null!==(e=t.intersect(r[n]))&&s.indexOf(e.toString())<0&&(o.push(e),s.push(e.toString()));return o.length>0?o:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new Kt(t);var n,i=new Kt(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(i,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new ee(i,t),s=r.length-1;s>=0;--s){var a=r[s].intersection(o);if(null!==a){n=a;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new ee(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new Kt(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,i,r,o,s,a,l,c;t=new ge(t),e||(e=t.center());var u=e.x,h=e.y;n=i=r=o=s=a=l=c=1/0;var d=t.topLeft();d.x<u&&(n=(this.x-u)/(d.x-u)),d.y<h&&(s=(this.y-h)/(d.y-h));var f=t.bottomRight();f.x>u&&(i=(this.x+this.width-u)/(f.x-u)),f.y>h&&(a=(this.y+this.height-h)/(f.y-h));var p=t.topRight();p.x>u&&(r=(this.x+this.width-u)/(p.x-u)),p.y<h&&(l=(this.y-h)/(p.y-h));var g=t.bottomLeft();return g.x<u&&(o=(this.x-u)/(g.x-u)),g.y>h&&(c=(this.y+this.height-h)/(g.y-h)),{sx:he(n,i,r,o),sy:he(s,a,l,c)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return he(n.sx,n.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return Kt.prototype.offset.call(this,t,e)},origin:function(){return new Kt(this.x,this.y)},pointNearestToPoint:function(t){if(t=new Kt(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new Kt(this.x+this.width,t.y);case"left":return new Kt(this.x,t.y);case"bottom":return new Kt(t.x,this.y+this.height);case"top":return new Kt(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new ee(this.topRight(),this.bottomRight())},rightMiddle:function(){return new Kt(this.x+this.width,this.y+this.height/2)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=pe(10,t)}return this.x=fe(this.x*e)/e,this.y=fe(this.y*e)/e,this.width=fe(this.width*e)/e,this.height=fe(this.height*e)/e,this},scale:function(t,e,n){return n=this.origin().scale(t,e,n),this.x=n.x,this.y=n.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new Kt(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r=e,o="left";return n<r&&(r=n,o="right"),i<r&&(r=i,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),i=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=i.x-n.x,this.height=i.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new ee(this.topLeft(),this.topRight())},topMiddle:function(){return new Kt(this.x+this.width/2,this.y)},topRight:function(){return new Kt(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return ge.fromRectUnion(this,t)},update:function(t,e,n,i){return Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this}},ge.prototype.bottomRight=ge.prototype.corner,ge.prototype.topLeft=ge.prototype.origin,ge.prototype.translate=ge.prototype.offset;const me=ge;function ve(t){const e=t.trim();if(""===e)return[];const n=[],i=e.split(/\b\s*,\s*|,\s*|\s+/),r=i.length;for(let t=0;t<r;t+=2)n.push({x:+i[t],y:+i[t+1]});return n}function ye(t){const e=t.length;if(0===e)return[];const n=[];for(let i=0;i<e;i++){const e=t[i].clone();n.push(e)}return n}function be(t){const{abs:e}=Math;var n,i,r,o=t.length;if(0===o)return[];for(n=0;n<o;n++)(void 0===r||t[n].y<r.y||t[n].y===r.y&&t[n].x>r.x)&&(r=t[n]);var s=[];for(n=0;n<o;n++){var a=r.theta(t[n]);0===a&&(a=360);var l=[t[n],n,a];s.push(l)}if(s.sort((function(t,e){var n=t[2]-e[2];return 0===n&&(n=e[1]-t[1]),n})),s.length>2){var c=s[s.length-1];s.unshift(c)}for(var u,h,d,f,p,g,m,v={},y=[];0!==s.length;)if(h=(u=s.pop())[0],!v.hasOwnProperty(u[0]+"@@"+u[1]))for(var b=!1;!b;)if(y.length<2)y.push(u),b=!0;else{f=(d=y.pop())[0];var w=(g=(p=y.pop())[0]).cross(f,h);if(w<0)y.push(p),y.push(d),y.push(u),b=!0;else if(0===w){var x=f.angleBetween(g,h);e(x-180)<1e-10||f.equals(h)||g.equals(f)?(v[d[0]+"@@"+d[1]]=f,y.push(p)):e((x+1)%360-1)<1e-10&&(y.push(p),s.push(d))}else v[d[0]+"@@"+d[1]]=f,y.push(p)}y.length>2&&y.pop();var A=-1;for(i=y.length,n=0;n<i;n++){var E=y[n][1];(void 0===m||E<m)&&(m=E,A=n)}var T=[];if(A>0){var S=y.slice(A),P=y.slice(0,A);T=S.concat(P)}else T=y;var _=[];for(i=T.length,n=0;n<i;n++)_.push(T[n][0]);return _}const we=function(t){return this instanceof we?"string"==typeof t?new we.parse(t):void(this.points=Array.isArray(t)?t.map(Kt):[]):new we(t)};we.parse=function(t){return new we(ve(t))},we.fromRect=function(t){return new we([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},we.prototype={type:zt.Polyline,bbox:function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var s=0;s<o;s++){var a=r[s],l=a.x,c=a.y;l<t&&(t=l),l>e&&(e=l),c<n&&(n=c),c>i&&(i=c)}return new ge(t,n,e-t,i-n)},clone:function(){return new we(ye(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,s=i-1,a=0;a<s;a++){var l=new ee(n[a],n[a+1]),c=l.length(),u=l.closestPointNormalizedLength(t),h=l.pointAt(u).squaredDistance(t);h<r&&(r=h,e=o+u*c),o+=c}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var n=this.length();return 0===n?0:e/n},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,s=0,a=0,l=new ee,c=new ee,u=new Kt;s<n;s++){var h=e[o],d=e[s];if(t.equals(h))return!0;if(l.start=h,l.end=d,l.containsPoint(t))return!0;if(r<=h.y&&r>d.y||r>h.y&&r<=d.y){var f=h.x-i>d.x-i?h.x-i:d.x-i;f>=0&&(u.x=i+f,u.y=r,c.start=t,c.end=u,l.intersect(c)&&a++)}o=s}return a%2==1},close:function(){const{start:t,end:e,points:n}=this;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new we(be(this.points))},equals:function(t){if(!t)return!1;var e=this.points,n=t.points,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=t.points[r];if(!o.equals(s))return!1}return!0},intersectionWithLine:function(t){for(var e=new ee(t),n=[],i=this.lengthPoints(),r=new ee,o=0,s=i.length-1;o<s;o++){r.start=i[o],r.end=i[o+1];var a=e.intersectionWithLine(r);a&&n.push(a[0])}return n.length>0?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var n=new ee,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();if(t<=0)return e[0].clone();if(t>=1)return e[n-1].clone();var i=this.length()*t;return this.pointAtLength(i)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var i=!0;t<0&&(i=!1,t=-t);for(var r=0,o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],c=e[a+1],u=new ee(l,c),h=l.distance(c);if(t<=r+h)return u.pointAtLength((i?1:-1)*(t-r));r+=h}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(t={}){const e=this.points;if(e.length<3)return this;const n=t.threshold||1e-10;let i=0;for(;e[i+2];){const t=i+1,r=i+2,o=e[i],s=e[t],a=e[r];new ee(o,a).closestPoint(s).distance(s)<=n?e.splice(t,1):i+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),t>1&&(t=1);var n=this.length()*t;return this.tangentAtLength(n)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;var i,r=!0;t<0&&(r=!1,t=-t);for(var o=0,s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,c=e[l],u=e[l+1],h=new ee(c,u),d=c.distance(u);if(h.isDifferentiable()){if(t<=o+d)return h.tangentAtLength((r?1:-1)*(t-o));i=h}o+=d}if(i){var f=r?1:0;return i.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(we.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(we.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});const{abs:xe,sqrt:Ae,min:Ee,max:Te,pow:Se}=Math,Pe=function(t,e,n,i){return this instanceof Pe?t instanceof Pe?new Pe(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new Kt(t),this.controlPoint1=new Kt(e),this.controlPoint2=new Kt(n),void(this.end=new Kt(i))):new Pe(t,e,n,i)};function _e(t){var e,n,i=[];for(n=arguments.length,e=1;e<n;e++)i.push(arguments[e]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=i.length,e=0;e<n;e++){var o,s,a=i[e];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}Pe.throughPoints=function(){function t(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}return function(e){if(!e||Array.isArray(e)&&e.length<2)throw new Error("At least 2 points are required");for(var n=function(e){var n,i=[],r=[],o=e.length-1;if(1==o)return i[0]=new Kt((2*e[0].x+e[1].x)/3,(2*e[0].y+e[1].y)/3),r[0]=new Kt(2*i[0].x-e[0].x,2*i[0].y-e[0].y),[i,r];var s=[];for(n=1;n<o-1;n++)s[n]=4*e[n].x+2*e[n+1].x;s[0]=e[0].x+2*e[1].x,s[o-1]=(8*e[o-1].x+e[o].x)/2;var a=t(s);for(n=1;n<o-1;++n)s[n]=4*e[n].y+2*e[n+1].y;s[0]=e[0].y+2*e[1].y,s[o-1]=(8*e[o-1].y+e[o].y)/2;var l=t(s);for(n=0;n<o;n++)i.push(new Kt(a[n],l[n])),n<o-1?r.push(new Kt(2*e[n+1].x-a[n+1],2*e[n+1].y-l[n+1])):r.push(new Kt((e[o].x+a[o-1])/2,(e[o].y+l[o-1])/2));return[i,r]}(e),i=[],r=n[0].length,o=0;o<r;o++){var s=new Kt(n[0][o].x,n[0][o].y),a=new Kt(n[1][o].x,n[1][o].y);i.push(new Pe(e[o],s,a,e[o+1]))}return i}}(),Pe.prototype={type:zt.Curve,bbox:function(){for(var t,e,n,i,r,o,s,a,l=this.start,c=this.controlPoint1,u=this.controlPoint2,h=this.end,d=l.x,f=l.y,p=c.x,g=c.y,m=u.x,v=u.y,y=h.x,b=h.y,w=new Array,x=new Array,A=[new Array,new Array],E=0;E<2;++E)if(0===E?(e=6*d-12*p+6*m,t=-3*d+9*p-9*m+3*y,n=3*p-3*d):(e=6*f-12*g+6*v,t=-3*f+9*g-9*v+3*b,n=3*g-3*f),xe(t)<1e-12){if(xe(e)<1e-12)continue;0<(i=-n/e)&&i<1&&x.push(i)}else a=Ae(s=e*e-4*n*t),s<0||(0<(r=(-e+a)/(2*t))&&r<1&&x.push(r),0<(o=(-e-a)/(2*t))&&o<1&&x.push(o));for(var T,S,P,_=x.length,k=_;_--;)S=(T=1-(i=x[_]))*T*T*d+3*T*T*i*p+3*T*i*i*m+i*i*i*y,A[0][_]=S,P=T*T*T*f+3*T*T*i*g+3*T*i*i*v+i*i*i*b,A[1][_]=P,w[_]={X:S,Y:P};x[k]=0,x[k+1]=1,w[k]={X:d,Y:f},w[k+1]={X:y,Y:b},A[0][k]=d,A[1][k]=f,A[0][k+1]=y,A[1][k+1]=b,x.length=k+2,A[0].length=k+2,A[1].length=k+2,w.length=k+2;var C=Ee.apply(null,A[0]),L=Ee.apply(null,A[1]),M=Te.apply(null,A[0]),O=Te.apply(null,A[1]);return new ge(C,L,M-C,O-L)},clone:function(){return new Pe(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.closestPointLength(t,i);if(!r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){for(var n,i,r,o,s,a,l,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,u=void 0===e.subdivisions?this.getSubdivisions({precision:c}):e.subdivisions,h=u.length,d=h?1/h:0,f=0;f<h;f++){var p=u[f],g=p.start.distance(t),m=p.end.distance(t),v=g+m;(!l||v<l)&&(n=p,i=f*d,r=(f+1)*d,o=g,s=m,a=p.start.distance(p.end),l=v)}for(var y=Se(10,-c);;){var b=o?xe(o-s)/o:0,w=s?xe(o-s)/s:0;if(b<y||w<y||!o||o<a*y||!s||s<a*y)return o<=s?i:r;var x=n.divide(.5);d/=2;var A=x[0].start.distance(t),E=x[0].end.distance(t),T=A+E,S=x[1].start.distance(t),P=x[1].end.distance(t);T<=S+P?(n=x[0],r-=d,o=A,s=E):(n=x[1],i+=d,o=S,s=P)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(t>=1)return this.divideAtT(1);var n=this.tAt(t,e);return this.divideAtT(n)},divideAtLength:function(t,e){var n=this.tAtLength(t,e);return this.divideAtT(n)},divideAtT:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return[new Pe(e,e,e,e),new Pe(e,n,i,r)];if(t>=1)return[new Pe(e,n,i,r),new Pe(r,r,r,r)];var o=this.getSkeletonPoints(t),s=o.startControlPoint1,a=o.startControlPoint2,l=o.divider,c=o.dividerControlPoint1,u=o.dividerControlPoint2;return[new Pe(e,s,a,l),new Pe(l,c,u,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()};if(t>=1)return{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new ee(e,n).pointAt(t),s=new ee(n,i).pointAt(t),a=new ee(i,r).pointAt(t),l=new ee(o,s).pointAt(t),c=new ee(s,a).pointAt(t);return{startControlPoint1:o,startControlPoint2:l,divider:new ee(l,c).pointAt(t),dividerControlPoint1:c,dividerControlPoint2:a}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,i=this.controlPoint1,r=this.controlPoint2,o=this.end,s=[new Pe(n,i,r,o)];if(0===e)return s;if(!this.isDifferentiable())return s;var a=this.endpointDistance(),l=Se(10,-e),c=2;0===i.cross(n,o)&&0===r.cross(n,o)&&(c=2*e);for(var u=0;;){u+=1;for(var h=[],d=s.length,f=0;f<d;f++){var p=s[f].divide(.5);h.push(p[0],p[1])}for(var g=0,m=h.length,v=0;v<m;v++)g+=h[v].endpointDistance();if(u>=c&&(0!==g?(g-a)/g:0)<l)return h;s=h,a=g}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++)i+=n[o].endpointDistance();return i},lengthAtT:function(t,e){if(t<=0)return 0;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=this.tAt(t,e);return this.pointAtT(n)},pointAtLength:function(t,e){var n=this.tAtLength(t,e);return this.pointAtT(n)},pointAtT:function(t){return t<=0?this.start.clone():t>=1?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var n=this.tAt(t,e);return this.tangentAtT(n)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var n=this.tAtLength(t,e);return this.tangentAtT(n)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var e=this.getSkeletonPoints(t),n=e.startControlPoint2,i=e.dividerControlPoint1,r=e.divider,o=new ee(n,i);return o.translate(r.x-n.x,r.y-n.y),o},tAt:function(t,e){if(t<=0)return 0;if(t>=1)return 1;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.length(i)*t;return this.tAtLength(r,i)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,c=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u={precision:l,subdivisions:c},h=0,d=c.length,f=1/d,p=0;p<d;p++){var g=n?p:d-1-p,m=c[p],v=m.endpointDistance();if(t<=h+v){i=m,r=g*f,o=(g+1)*f,s=n?t-h:v+h-t,a=n?v+h-t:t-h;break}h+=v}if(!i)return n?1:0;for(var y=this.length(u),b=Se(10,-l);;){var w,x;if((0!==y?s/y:0)<b)return r;if((0!==y?a/y:0)<b)return o;var A=i.divide(.5);f/=2;var E=A[0].endpointDistance(),T=A[1].endpointDistance();s<=E?(i=A[0],o-=f,x=E-(w=s)):(i=A[1],r+=f,x=T-(w=s-E)),s=w,a=x}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var s=n[o];i.push(s.end.clone())}return i},toPolyline:function(t){return new we(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}},Pe.prototype.divide=Pe.prototype.divideAtT;const ke=function(t){if(!(this instanceof ke))return new ke(t);if("string"==typeof t)return new ke.parse(t);var e,n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce((function(t,e){return t.concat(e)}),[])).length,t[0].isSegment)for(e=0;e<n;e++){var i=t[e];this.appendSegment(i)}else{var r=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof ee||o instanceof Pe))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(ke.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(ke.createSegment("M",o.start)),o instanceof ee?this.appendSegment(ke.createSegment("L",o.end)):o instanceof Pe&&this.appendSegment(ke.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof ee)this.appendSegment(ke.createSegment("M",t.start)),this.appendSegment(ke.createSegment("L",t.end));else if(t instanceof Pe)this.appendSegment(ke.createSegment("M",t.start)),this.appendSegment(ke.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof we))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(n=t.points.length,e=0;e<n;e++){var s=t.points[e];0===e?this.appendSegment(ke.createSegment("M",s)):this.appendSegment(ke.createSegment("L",s))}}};function Ce(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}ke.parse=function(t){if(!t)return new ke;for(var e=new ke,n=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=n.length,r=0;r<i;r++){var o=n[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),s=ke.createSegment.apply(this,o);e.appendSegment(s)}return e},ke.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=ke.segmentTypes[t];if(!e)throw new Error(t+" is not a recognized path segment type.");for(var n=[],i=arguments.length,r=1;r<i;r++)n.push(arguments[r]);return Ce(e,n)},ke.prototype={type:zt.Path,appendSegment:function(t){var e,n=this.segments,i=n.length,r=0!==i?n[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,s=0;s<o;s++){var a=t[s];e=this.prepareSegment(a,r,null),n.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),n.push(e)}},bbox:function(){var t,e=this.segments,n=e.length;if(0===n)return null;for(var i=0;i<n;i++){var r=e[i];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var s=e[n-1];return new ge(s.end.x,s.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,n=new ke,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){var n=this.closestPointT(t,e);return n?this.pointAtT(n):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointT(t,i);return r?this.lengthAtT(r,i):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointLength(t,i);if(0===r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],u=s[l];if(c.isVisible){var h=c.closestPointT(t,{precision:o,subdivisions:u}),d=c.pointAtT(h),f=new ee(d,t).squaredLength();f<a&&(r={segmentIndex:l,value:h},a=f)}}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],u=s[l];if(c.isDifferentiable()){var h=c.closestPointT(t,{precision:o,subdivisions:u}),d=c.pointAtT(h),f=new ee(d,t).squaredLength();f<a&&(r=c.tangentAtT(h),a=f)}}return r||null},containsPoint:function(t,e){var n=this.toPolylines(e);if(!n)return!1;for(var i=n.length,r=0,o=0;o<i;o++)n[o].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.divideAtLength(r,i)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;var i=!0;t<0&&(i=!1,t=-t);var r,o,s,a,l,c,u,h=void 0===(e=e||{}).precision?this.PRECISION:e.precision,d=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:h}):e.segmentSubdivisions,f=0;for(r=0;r<n;r++){var p=i?r:n-1-r;o=this.getSegment(p);var g=d[p],m=o.length({precision:h,subdivisions:g});if(o.isDifferentiable()&&(l=o,c=p,t<=f+m)){a=p,s=o.divideAtLength((i?1:-1)*(t-f),{precision:h,subdivisions:g});break}f+=m}if(!l)return null;s||(a=c,u=i?1:0,s=l.divideAtT(u));var v=this.clone();v.replaceSegment(a,s);var y=a,b=a+1,w=a+2;s[0].isDifferentiable()||(v.removeSegment(y),b-=1,w-=1);var x=v.getSegment(b).start;v.insertSegment(b,ke.createSegment("M",x)),w+=1,s[1].isDifferentiable()||(v.removeSegment(w-1),w-=1);var A=w-y-1;for(r=w;r<v.segments.length;r++){var E=this.getSegment(r-A);if("Z"===(o=v.getSegment(r)).type&&!E.subpathStartSegment.end.equals(o.subpathStartSegment.end)){var T=ke.createSegment("L",E.end);v.replaceSegment(r,T)}}return[new ke(v.segments.slice(0,b)),new ke(v.segments.slice(b))]},equals:function(t){if(!t)return!1;var e=this.segments,n=t.segments,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=n[r];if(o.type!==s.type||!o.equals(s))return!1}return!0},getSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");return e[t]},getSegmentSubdivisions:function(t){for(var e=this.segments,n=e.length,i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],o=0;o<n;o++){var s=e[o].getSubdivisions({precision:i});r.push(s)}return r},getSubpaths:function(){const t=this.clone().validate().segments,e=t.length,n=[];for(let i=0;i<e;i++){const e=t[i];e.isSubpathStart?n.push(new ke(e)):n[n.length-1].appendSegment(e)}return n},insertSegment:function(t,e){var n,i=this.segments,r=i.length;if(t<0&&(t=r+t+1),t>r||t<0)throw new Error("Index out of range.");var o=null,s=null;if(0!==r&&(s=t>=1?(o=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var a=e.length,l=0;l<a;l++){var c=e[l];n=this.prepareSegment(c,o,s),i.splice(t+l,0,n),o=n}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,o,s),i.splice(t,0,n)}},intersectionWithLine:function(t,e){var n=null,i=this.toPolylines(e);if(!i)return null;for(var r=0,o=i.length;r<o;r++){var s=i[r],a=t.intersect(s);a&&(n||(n=[]),Array.isArray(a)?Array.prototype.push.apply(n,a):n.push(a))}return n},isDifferentiable:function(){for(var t=this.segments,e=t.length,n=0;n<e;n++)if(t[n].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var e=this.segments,n=e.length;if(0===n)return 0;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=0,s=0;s<n;s++){var a=e[s],l=r[s];o+=a.length({subdivisions:l})}return o},lengthAtT:function(t,e){var n=this.segments,i=n.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;var o=t.value;r>=i?(r=i-1,o=1):o<0?o=0:o>1&&(o=1);for(var s,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,l=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,c=0,u=0;u<r;u++){var h=n[u];s=l[u],c+=h.length({precisison:a,subdivisions:s})}return h=n[r],s=l[r],c+h.lengthAtT(o,{precisison:a,subdivisions:s})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.pointAtLength(r,i)},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var u=r?c:i-1-c,h=n[u],d=a[u],f=h.length({precision:s,subdivisions:d});if(h.isVisible){if(t<=l+f)return h.pointAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=h}l+=f}return o?r?o.end:o.start:n[i-1].end.clone()},pointAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].pointAtT(0);if(i>=n)return e[n-1].pointAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].pointAtT(r)},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);var i=t;return t.isSubpathStart&&(t.subpathStartSegment=t,i=n),i&&this.updateSubpathStartSegment(i),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");var i=e.splice(t,1)[0],r=i.previousSegment,o=i.nextSegment;r&&(r.nextSegment=o),o&&(o.previousSegment=r),i.isSubpathStart&&o&&this.updateSubpathStartSegment(o)},replaceSegment:function(t,e){var n,i=this.segments,r=i.length;if(0===r)throw new Error("Path has no segments.");if(t<0&&(t=r+t),t>=r||t<0)throw new Error("Index out of range.");var o=i[t],s=o.previousSegment,a=o.nextSegment,l=o.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var c=e.length,u=0;u<c;u++){var h=e[u];n=this.prepareSegment(h,s,a),i.splice(t+u,0,n),s=n,l&&n.isSubpathStart&&(l=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,s,a),i.splice(t,1,n),l&&n.isSubpathStart&&(l=!1)}l&&a&&this.updateSubpathStartSegment(a)},round:function(t){for(var e=this.segments,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.segments,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},segmentAt:function(t,e){var n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null},segmentAtLength:function(t,e){var n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.segmentIndexAtLength(r,i)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,c=0;c<i;c++){var u=r?c:i-1-c,h=n[u],d=s[u],f=h.length({precision:o,subdivisions:d});if(h.isVisible){if(t<=l+f)return u;a=u}l+=f}return a},serialize:function(){if(!this.isValid())throw new Error("Invalid path segments.");return this.toString()},tangentAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.tangentAtLength(r,i)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var u=r?c:i-1-c,h=n[u],d=a[u],f=h.length({precision:s,subdivisions:d});if(h.isDifferentiable()){if(t<=l+f)return h.tangentAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=h}l+=f}if(o){var p=r?1:0;return o.tangentAtT(p)}return null},tangentAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].tangentAtT(0);if(i>=n)return e[n-1].tangentAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].tangentAtT(r)},toPoints:function(t){var e=this.segments,n=e.length;if(0===n)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=[],s=[],a=0;a<n;a++){var l=e[a];if(l.isVisible){var c=r[a];if(c.length>0){var u=c.map((function(t){return t.start}));Array.prototype.push.apply(s,u)}else s.push(l.start)}else s.length>0&&(s.push(e[a-1].end),o.push(s),s=[])}return s.length>0&&(s.push(this.end),o.push(s)),o},toPolylines:function(t){var e=[],n=this.toPoints(t);if(!n)return null;for(var i=0,r=n.length;i<r;i++)e.push(new we(n[i]));return e},toString:function(){for(var t=this.segments,e=t.length,n="",i=0;i<e;i++)n+=t[i].serialize()+" ";return n.trim()},translate:function(t,e){for(var n=this.segments,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},updateSubpathStartSegment:function(t){for(var e=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=e?e.subpathStartSegment:null,e=t,t=t.nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,ke.createSegment("M",0,0)),this}},Object.defineProperty(ke.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=0;n<e;n++){var i=t[n];if(i.isVisible)return i.start}return t[e-1].end}}),Object.defineProperty(ke.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=e-1;n>=0;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}});var Le={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return t>=1?e:e*t},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}};Object.defineProperty(Le,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(Le,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(Le,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}});var Me=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Me))return Ce(Me,n);if(0===i)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof ee){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" lines provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Kt(+n[0],+n[1]),this;if(i<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),t.push(Ce(Me,o));return t}if(1===i)return this.end=new Kt(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],t.push(new Me(e));return t},Oe={clone:function(){return new Me(this.end)},divideAt:function(t){var e=new ee(this.start,this.end).divideAt(t);return[new Me(e[0]),new Me(e[1])]},divideAtLength:function(t){var e=new ee(this.start,this.end).divideAtLength(t);return[new Me(e[0]),new Me(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Oe,"type",{configurable:!0,enumerable:!0,value:"L"}),Me.prototype=_e(Le,ee.prototype,Oe);var Ne=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Ne))return Ce(Ne,n);if(0===i)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(n[0]instanceof Pe){if(1===i)return this.controlPoint1=n[0].controlPoint1.clone(),this.controlPoint2=n[0].controlPoint2.clone(),this.end=n[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(6===i)return this.controlPoint1=new Kt(+n[0],+n[1]),this.controlPoint2=new Kt(+n[2],+n[3]),this.end=new Kt(+n[4],+n[5]),this;if(i<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=6)o=n.slice(r,r+6),t.push(Ce(Ne,o));return t}if(3===i)return this.controlPoint1=new Kt(n[0]),this.controlPoint2=new Kt(n[1]),this.end=new Kt(n[2]),this;if(i<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" points provided).");for(t=[],r=0;r<i;r+=3)e=n.slice(r,r+3),t.push(Ce(Ne,e));return t},Re={clone:function(){return new Ne(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){var n=new Pe(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Ne(n[0]),new Ne(n[1])]},divideAtLength:function(t,e){var n=new Pe(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Ne(n[0]),new Ne(n[1])]},divideAtT:function(t){var e=new Pe(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Ne(e[0]),new Ne(e[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,n=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+n.x+" "+n.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}};Object.defineProperty(Re,"type",{configurable:!0,enumerable:!0,value:"C"}),Ne.prototype=_e(Le,Pe.prototype,Re);var Fe=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Fe))return Ce(Fe,n);if(0===i)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof ee){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" lines provided).")}if(n[0]instanceof Pe){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Kt(+n[0],+n[1]),this;if(i<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),0===r?t.push(Ce(Fe,o)):t.push(Ce(Me,o));return t}if(1===i)return this.end=new Kt(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],0===r?t.push(new Fe(e)):t.push(new Me(e));return t},Be={bbox:function(){return null},clone:function(){return new Fe(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Be,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Be,"type",{configurable:!0,enumerable:!0,value:"M"}),Fe.prototype=_e(Le,Be);var Ie=function(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Ie))return Ce(Ie,t);if(e>0)throw new Error("Closepath constructor expects no arguments.");return this},De={clone:function(){return new Ie},divideAt:function(t){var e=new ee(this.start,this.end).divideAt(t);return[e[1].isDifferentiable()?new Me(e[0]):this.clone(),new Me(e[1])]},divideAtLength:function(t){var e=new ee(this.start,this.end).divideAtLength(t);return[e[1].isDifferentiable()?new Me(e[0]):this.clone(),new Me(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment||this.start.equals(this.end))},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}};Object.defineProperty(De,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),Object.defineProperty(De,"type",{configurable:!0,enumerable:!0,value:"Z"}),Ie.prototype=_e(Le,ee.prototype,De);var Ve=ke.segmentTypes={L:Me,C:Ne,M:Fe,Z:Ie,z:Ie};ke.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(Ve).join("")+",.]*$"),ke.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)};const ze={curveThroughPoints:function(t){return console.warn("deprecated"),new ke(Pe.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new Kt((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new Kt(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var s=this.getFirstControlPoints(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var a=this.getFirstControlPoints(o);for(e=0;e<r;e++)n.push(new Kt(s[e],a[e])),e<r-1?i.push(new Kt(2*t[e+1].x-s[e+1],2*t[e+1].y-a[e+1])):i.push(new Kt((t[r].x+s[r-1])/2,(t[r].y+a[r-1])/2));return[n,i]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new Pe(t,e,n,i);return function(t){var e=r.divide(t);return[{p0:e[0].start,p1:e[0].controlPoint1,p2:e[0].controlPoint2,p3:e[0].end},{p0:e[1].start,p1:e[1].controlPoint1,p2:e[1].controlPoint2,p3:e[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n},getInversionSolver:function(t,e,n,i){console.warn("deprecated");var r=new Pe(t,e,n,i);return function(t){return r.closestPointT(t)}}},je=function(t){return this instanceof je?"string"==typeof t?new je.parse(t):void(this.points=Array.isArray(t)?t.map(Kt):[]):new je(t)};function $e(t,e,n,i){switch(t.type){case zt.Line:if(e.type===zt.Line)return Ue(t,e);break;case zt.Ellipse:switch(e.type){case zt.Line:return Ge(t,e);case zt.Ellipse:return qe(t,e)}break;case zt.Rect:switch(e.type){case zt.Line:return He(t,e);case zt.Ellipse:return We(t,e);case zt.Rect:return Ye(t,e)}break;case zt.Polyline:switch(e.type){case zt.Line:return Xe(t,e);case zt.Ellipse:return Ze(t,e);case zt.Rect:return Ke(t,e);case zt.Polyline:return Je(t,e)}break;case zt.Polygon:switch(e.type){case zt.Line:return Qe(t,e);case zt.Ellipse:return tn(t,e);case zt.Rect:return en(t,e);case zt.Polyline:return nn(t,e);case zt.Polygon:return rn(t,e)}break;case zt.Path:switch(e.type){case zt.Line:return on(t,e,n);case zt.Ellipse:return sn(t,e,n);case zt.Rect:return an(t,e,n);case zt.Polyline:return ln(t,e,n);case zt.Polygon:return cn(t,e,n);case zt.Path:return un(t,e,n,i)}}switch(e.type){case zt.Ellipse:case zt.Rect:case zt.Polyline:case zt.Polygon:case zt.Path:return $e(e,t,i,n);default:throw Error(`The intersection for ${t} and ${e} could not be found.`)}}function Ue(t,e){const n=t.start.x,i=t.start.y,r=t.end.x,o=t.end.y,s=e.start.x,a=e.start.y,l=r-n,c=o-i,u=e.end.x-s,h=e.end.y-a,d=n-s,f=i-a,p=l*h-u*c,g=(l*f-c*d)/p,m=(u*f-h*d)/p;return g>=0&&g<=1&&m>=0&&m<=1}function Ge(t,e){const n=t.a,i=t.b,r=t.x,o=t.y,s=e.start.x-r,a=e.end.x-r,l=e.start.y-o,c=n*n,u=i*i,h=a-s,d=e.end.y-o-l,f=h*h/c+d*d/u,p=2*s*h/c+2*l*d/u,g=p*p-4*f*(s*s/c+l*l/u-1);if(0===g){const t=-p/2/f;return t>=0&&t<=1}if(g>0){const t=Math.sqrt(g),e=(-p+t)/2/f,n=(-p-t)/2/f;return e>=0&&e<=1||n>=0&&n<=1}return!1}function qe(t,e){return function(t,e,n,i){const{cos:r,sin:o}=Math,s=o(0),a=r(0),l=o(0),c=r(0),u=s*s,h=a*a,d=s*a,f=l*l,p=c*c,g=l*c,m=t.a*t.a,v=t.b*t.b,y=n.a*n.a,b=n.b*n.b,w=m*u+v*h,x=y*f+b*p,A=m*h+v*u,E=y*p+b*f;let T=2*(v-m)*d,S=2*(b-y)*g,P=-2*w*t.x-T*t.y,_=-2*x*n.x-S*n.y,k=-T*t.x-2*A*t.y,C=-S*n.x-2*E*n.y;const L=w*t.x*t.x+A*t.y*t.y+T*t.x*t.y-m*v,M=x*n.x*n.x+E*n.y*n.y+S*n.x*n.y-y*b;T/=2,S/=2,P/=2,_/=2,k/=2,C/=2;const O=yn([[w,T,P],[T,A,k],[P,k,L]]),N=yn([[x,S,_],[S,E,C],[_,C,M]]),R=.33333333*(yn([[x,T,P],[S,A,k],[_,k,L]])+yn([[w,S,P],[T,E,k],[P,C,L]])+yn([[w,T,_],[T,A,C],[P,k,M]])),F=.33333333*(yn([[w,S,_],[T,E,C],[P,C,M]])+yn([[x,T,_],[S,A,C],[_,k,M]])+yn([[x,S,P],[S,E,k],[_,C,L]])),B=vn([[O,R],[R,F]]),I=vn([[O,F],[R,N]]),D=vn([[R,F],[F,N]]);return!(vn([[2*B,I],[I,2*D]])>0&&(F>0||R>0))}(t,0,e)}function He(t,e){const{start:n,end:i}=e,{x:r,y:o,width:s,height:a}=t;return!(n.x>r+s&&i.x>r+s||n.x<r&&i.x<r||n.y>o+a&&i.y>o+a||n.y<o&&i.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||Ue(t.topLine(),e)||Ue(t.rightLine(),e)||Ue(t.bottomLine(),e)||Ue(t.leftLine(),e))}function We(t,e){return!!Ye(t,ge.fromEllipse(e))&&tn(je.fromRect(t),e)}function Ye(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function Xe(t,e){return hn(t,e,{interior:!1})}function Ze(t,e){return dn(t,e,{interior:!1})}function Ke(t,e){return fn(t,e,{interior:!1})}function Je(t,e){return gn(t,e,{interior:!1})}function Qe(t,e){return hn(t,e,{interior:!0})}function tn(t,e){return dn(t,e,{interior:!0})}function en(t,e){return fn(t,e,{interior:!0})}function nn(t,e){return gn(t,e,{interior:!0})}function rn(t,e){return mn(t,e,{interior:!0})}function on(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?Qe(i,e):Xe(i,e)}))}function sn(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?tn(i,e):Ze(i,e)}))}function an(t,e,n){return cn(t,je.fromRect(e),n)}function ln(t,e,n){return pn(t,e,n,{interior:!1})}function cn(t,e,n){return pn(t,e,n,{interior:!0})}function un(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?cn(e,r,i):ln(e,r,i)}))}function hn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){if(t.containsPoint(e.start))return!0;const{start:n,end:i,points:o}=t;r=i.equals(n)?o:[...o,n]}else r=t.points;const{length:o}=r,s=new ee;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Ue(e,s))return!0;return!1}function dn(t,e,n={}){const{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;const{interior:a=!1}=n;if(a){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;const{length:l}=s,c=new ee;for(let t=0;t<l-1;t++)if(c.start=s[t],c.end=s[t+1],Ge(e,c))return!0;return!1}function fn(t,e,n){return mn(t,je.fromRect(e),n)}function pn(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?mn(e,r,i):gn(e,r,i)}))}function gn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){const{start:n}=e;if(t.containsPoint(n))return!0;r=t.clone().close()}else r=t;const o=e.points,{length:s}=o,a=new ee;for(let t=0;t<s-1;t++)if(a.start=o[t],a.end=o[t+1],Xe(r,a))return!0;return!1}function mn(t,e,n){return e.containsPoint(t.start)||gn(t,e.clone().close(),n)}function vn(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function yn(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}je.parse=function(t){return new je(ve(t))},je.fromRect=function(t){return new je([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},je.prototype=_e(we.prototype,{type:zt.Polygon,clone:function(){return new je(ye(this.points))},convexHull:function(){return new je(be(this.points))},lengthPoints:function(){const{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});const bn=t,wn=function(){if("object"!=typeof window||!window.SVGAngle)return function(){throw new Error("SVG is required to use Vectorizer.")};var t={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},n=Math,i=n.PI,r=n.atan2,o=n.sqrt,s=n.min,a=n.max,l=n.cos,c=n.sin,u=function(e,n,i){if(!(this instanceof u))return u.apply(Object.create(u.prototype),arguments);if(e){if(u.isV(e)&&(e=e.node),n=n||{},u.isString(e)){if("svg"===(e=e.trim()).toLowerCase())e=u.createSvgDocument();else if("<"===e[0]){var r=u.createSvgDocument(e);if(r.childNodes.length>1){var o,s,a=[];for(o=0,s=r.childNodes.length;o<s;o++){var l=r.childNodes[o];a.push(new u(document.importNode(l,!0)))}return a}e=document.importNode(r.firstChild,!0)}else e=document.createElementNS(t.svg,e);u.ensureId(e)}return this.node=e,this.setAttributes(n),i&&this.append(i),this}},h=u.prototype;function d(t,e,n){n||(n={});for(var i=n.includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,l={},c=e.length-1,h=0;h<=c;h++){var d=e[h],f=null;if(u.isObject(d)){var p=d.attrs,g=u("tspan",p),m=g.node,v=d.t;r&&h===c&&(v+=r),m.textContent=v;var y=p.class;y&&g.addClass(y),i&&g.attr("annotations",d.annotations),f=parseFloat(p["font-size"]),isFinite(f)||(f=s),f&&f>a&&(a=f)}else r&&h===c&&(d+=r),m=document.createTextNode(d||" "),s&&s>a&&(a=s);t.appendChild(m)}return a&&(l.maxFontSize=a),o?l.lineHeight=o:a&&(l.lineHeight=1.2*a),l}Object.defineProperty(h,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),h.getTransformToElement=function(t){var e=this.node;if(u.isSVGGraphicsElement(t)&&u.isSVGGraphicsElement(e)){var n=u.toNode(t).getScreenCTM(),i=e.getScreenCTM();if(n&&i)return n.inverse().multiply(i)}return u.createSVGMatrix()},h.transform=function(t,e){var n=this.node;if(u.isUndefined(t))return u.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",u.matrixToTransformString(t));var i=u.createSVGTransform(t);return n.transform.baseVal.appendItem(i),this},h.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=u.parseTransformString(i);if(i=r.value,u.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();var o="translate("+(n.absolute?t:r.translate.tx+t)+","+(n.absolute?e:r.translate.ty+e)+")";return this.attr("transform",(o+" "+i).trim()),this},h.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=u.parseTransformString(r);if(r=o.value,u.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;var s="rotate("+(i.absolute?t:o.rotate.angle+t)+(void 0!==e&&void 0!==n?","+e+","+n:"")+")";return this.attr("transform",(r+" "+s).trim()),this},h.scale=function(t,e){e=u.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=u.parseTransformString(n);if(n=i.value,u.isUndefined(t))return i.scale;n=n.replace(/scale\([^)]*\)/g,"").trim();var r="scale("+t+","+e+")";return this.attr("transform",(n+" "+r).trim()),this},h.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new ge(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(t)return new ge(n);var o=this.getTransformToElement(e||r);return u.transformRect(n,o)},h.getBBox=function(t){var e,n={},i=this.node;if(!i.ownerSVGElement||!u.isSVGGraphicsElement(i))return new ge(0,0,0,0);if(t&&(t.target&&(n.target=u.toNode(t.target)),t.recursive&&(n.recursive=t.recursive)),n.recursive){var r=this.children(),o=r.length;if(0===o)return this.getBBox({target:n.target,recursive:!1});n.target||(n.target=this);for(var s=0;s<o;s++){var a,l=r[s];a=0===l.children().length?l.getBBox({target:n.target,recursive:!1}):l.getBBox({target:n.target,recursive:!0}),e=e?e.union(a):a}return e}try{e=i.getBBox()}catch(t){e={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(n.target){var c=this.getTransformToElement(n.target);return u.transformRect(e,c)}return new ge(e)};var f=/em$/;function p(t,e){var n=parseFloat(t);return f.test(t)?n*e:n}h.text=function(e,n){if(e&&"string"!=typeof e)throw new Error("Vectorizer: text() expects the first argument to be a string.");e=u.sanitizeText(e),n||(n={});var i=n.displayEmpty,r=n.eol,o=n.textPath,s=n.textVerticalAnchor,a="middle"===s||"bottom"===s||"top"===s,l=n.x;void 0===l&&(l=this.attr("x")||0);var c=n.includeAnnotationIndices,h=n.annotations;h&&!u.isArray(h)&&(h=[h]);var g=n.lineHeight,m="auto"===g,v=m?"1.5em":g||"1em";this.empty(),this.attr({"xml:space":"preserve",display:e||i?null:"none"});var y=parseFloat(this.attr("font-size"));y||(y=16,(a||h)&&this.attr("font-size",y));var b,w=document;o?("string"==typeof o&&(o={d:o}),b=function(t,e){t||(t={});var n=u("textPath"),i=t.d;if(i&&void 0===t["xlink:href"]){var r=u("path").attr("d",i).appendTo(e.defs());n.attr("xlink:href","#"+r.id)}return u.isObject(t)&&n.attr(t),n.node}(o,this)):b=w.createDocumentFragment();for(var x,A=0,E=e.split("\n"),T=[],S=0,P=E.length-1;S<=P;S++){var _,k=v,C="v-line",L=w.createElementNS(t.svg,"tspan"),M=E[S];if(M)if(h){var O=u.annotateString(M,h,{offset:-A,includeAnnotationIndices:c}),N=(_=d(L,O,{includeAnnotationIndices:c,eol:S!==P&&r,lineHeight:m?null:v,baseSize:y})).lineHeight;N&&m&&0!==S&&(k=N),0===S&&(x=.8*_.maxFontSize)}else r&&S!==P&&(M+=r),L.textContent=M;else{L.textContent="-",C+=" v-empty-line";var R=L.style;if(R.fillOpacity=0,R.strokeOpacity=0,h){_={};let t=y;for(let e=(O=u.findAnnotationsAtIndex(h,A)).length;e>0;e--){const n=O[e-1].attrs;if(!n||!("font-size"in n))continue;const i=parseFloat(n["font-size"]);if(isFinite(i)){t=i;break}}m&&(S>0?k=1.2*t:x=.8*t),L.setAttribute("font-size",t),_.maxFontSize=t}}_&&T.push(_),S>0&&L.setAttribute("dy",k),(S>0||o)&&L.setAttribute("x",l),L.className.baseVal=C,b.appendChild(L),A+=M.length+1}if(a)if(h)k=function(t,e,n,i){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=p(o.maxFontSize,n)||n,a=0,l=p(i,n),c=1;c<r;c++)a+=p((o=e[c]).lineHeight,n)||l;var u,h=p(o.maxFontSize,n)||n;switch(t){case"middle":u=s/2-.15*h-a/2;break;case"bottom":u=-.25*h-a;break;default:u=.8*s}return u}(s,T,y,v);else if("top"===s)k="0.8em";else{var F;switch(P>0?(F=parseFloat(v)||1,F*=P,f.test(v)||(F/=y)):F=0,s){case"middle":k=.3-F/2+"em";break;case"bottom":k=-F-.3+"em"}}else 0===s?k="0em":s?k=s:(k=0,null===this.attr("y")&&this.attr("y",x||"0.8em"));return b.firstChild.setAttribute("dy",k),this.append(b),this},h.removeAttr=function(t){const e=y[t],{ns:n,local:i}=u.qualifyAttr(e),r=this.node;return n?r.hasAttributeNS(n,i)&&r.removeAttributeNS(n,i):r.hasAttribute(e)&&r.removeAttribute(e),this},h.attr=function(t,e){if(u.isUndefined(t)){for(var n=this.node.attributes,i={},r=0;r<n.length;r++)i[n[r].name]=n[r].value;return i}if(u.isString(t)&&u.isUndefined(e))return this.node.getAttribute(y[t]);if("object"==typeof t)for(var o in t)t.hasOwnProperty(o)&&this.setAttribute(o,t[o]);else this.setAttribute(t,e);return this},h.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",u.normalizePathData(this.attr("d"))),this},h.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},h.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},h.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},h.append=function(t){u.isArray(t)||(t=[t]);for(var e=0,n=t.length;e<n;e++)this.node.appendChild(u.toNode(t[e]));return this},h.prepend=function(t){var e=this.node.firstChild;return e?u(e).before(t):this.append(t)},h.before=function(t){var e=this.node,n=e.parentNode;if(n){u.isArray(t)||(t=[t]);for(var i=0,r=t.length;i<r;i++)n.insertBefore(u.toNode(t[i]),e)}return this},h.appendTo=function(t){return u.toNode(t).appendChild(this.node),this},h.svg=function(){return this.node instanceof window.SVGSVGElement?this:u(this.node.ownerSVGElement)},h.tagName=function(){return this.node.tagName.toUpperCase()},h.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?u(e):u("defs").appendTo(t)},h.clone=function(){var t=u(this.node.cloneNode(!0));return t.node.id=u.uniqueId(),t},h.findOne=function(t){var e=this.node.querySelector(t);return e?u(e):void 0},h.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(u(n[i]));return e},h.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(u(t[n]));return e},h.parent=function(){return u(this.node.parentNode)||null},h.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},h.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=u(i);if(r.hasClass(t))return r;i=i.parentNode}return null},h.contains=function(t){var e=this.node,n=u.toNode(t),i=n&&n.parentNode;return e===i||!!(i&&1===i.nodeType&&16&e.compareDocumentPosition(i))},h.toLocalPoint=function(t,e){var n=this.svg().node,i=n.createSVGPoint();i.x=t,i.y=e;try{var r=i.matrixTransform(n.getScreenCTM().inverse()),o=this.getTransformToElement(n).inverse()}catch(t){return i}return r.matrixTransform(o)},h.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},h.translateAndAutoOrient=function(t,e,n){t=new Kt(t),e=new Kt(e),n||(n=this.svg());var i=this.scale();this.attr("transform","");var r=this.getBBox({target:n}).scale(i.sx,i.sy),o=u.createSVGTransform();o.setTranslate(-r.x-r.width/2,-r.y-r.height/2);var s=u.createSVGTransform(),a=t.angleBetween(e,t.clone().offset(1,0));a&&s.setRotate(a,0,0);var l=u.createSVGTransform(),c=t.clone().move(e,r.width/2);l.setTranslate(2*t.x-c.x,2*t.y-c.y);var h=this.getTransformToElement(n),d=u.createSVGTransform();return d.setMatrix(l.matrix.multiply(s.matrix.multiply(o.matrix.multiply(h.scale(i.sx,i.sy))))),this.attr("transform",u.matrixToTransformString(d.matrix)),this},h.animateAlongPath=function(t,e){e=u.toNode(e);var n=u.ensureId(e),i=u("animateMotion",t),r=u("mpath",{"xlink:href":"#"+n});i.append(r),this.append(i);try{i.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling")){var o=i.node;o.animators=[];var s=o.getAttribute("id");s&&(id2anim[s]=o);for(var a=getTargets(o),l=0,c=a.length;l<c;l++){var h=a[l],d=new Animator(o,h,l);animators.push(d),o.animators[l]=d,d.register()}}}return this};const g=/[^\x20\t\r\n\f]+/g;function m(t){return u.isString(t)&&t.trim().match(g)||[]}h.hasClass=function(t){return!!u.isString(t)&&this.node.classList.contains(t.trim())},h.addClass=function(t){return this.node.classList.add(...m(t)),this},h.removeClass=function(t){return this.node.classList.remove(...m(t)),this},h.toggleClass=function(t,e){const n=m(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},h.sample=function(t){t=t||1;for(var e,n=this.node,i=n.getTotalLength(),r=[],o=0;o<i;)e=n.getPointAtLength(o),r.push({x:e.x,y:e.y,distance:o}),o+=t;return r},h.convertToPath=function(){var t=u("path");t.attr(this.attr());var e=this.convertToPathData();return e&&t.attr("d",e),t},h.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return u.convertLineToPathData(this.node);case"POLYGON":return u.convertPolygonToPathData(this.node);case"POLYLINE":return u.convertPolylineToPathData(this.node);case"ELLIPSE":return u.convertEllipseToPathData(this.node);case"CIRCLE":return u.convertCircleToPathData(this.node);case"RECT":return u.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},u.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s,a,l,c,h,d,f,p,g;switch(this.tagName()){case"RECT":return t=parseFloat(this.attr("x"))||0,e=parseFloat(this.attr("y"))||0,n=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new ge(t,e,n,i);case"CIRCLE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("r"))||0,new se({x:r,y:o},s,s);case"ELLIPSE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,a=parseFloat(this.attr("rx"))||0,l=parseFloat(this.attr("ry"))||0,new se({x:r,y:o},a,l);case"POLYLINE":return c=u.getPointsFromSvgNode(this),new we(c);case"POLYGON":return(c=u.getPointsFromSvgNode(this)).length>1&&c.push(c[0]),new we(c);case"PATH":return h=this.attr("d"),ke.isDataSupported(h)||(h=u.normalizePathData(h)),new ke(h);case"LINE":return d=parseFloat(this.attr("x1"))||0,p=parseFloat(this.attr("y1"))||0,f=parseFloat(this.attr("x2"))||0,g=parseFloat(this.attr("y2"))||0,new ee({x:d,y:p},{x:f,y:g})}return this.getBBox()},h.findIntersection=function(t,e){var n=this.svg().node;e=e||n;var i=this.getBBox({target:e}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){var o,s=this.tagName();if("RECT"===s){var a=new ge(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),l=this.getTransformToElement(e),c=u.decomposeMatrix(l),h=n.createSVGTransform();h.setRotate(-c.rotation,r.x,r.y);var d=u.transformRect(a,h.matrix.multiply(l));o=new ge(d).intersectionWithLineFromCenterToPoint(t,c.rotation)}else if("PATH"===s||"POLYGON"===s||"POLYLINE"===s||"CIRCLE"===s||"ELLIPSE"===s){var f,p,g,m,v,y=("PATH"===s?this:this.convertToPath()).sample(),b=1/0,w=[];for(f=0;f<y.length;f++)p=y[f],g=(g=u.createSVGPoint(p.x,p.y)).matrixTransform(this.getTransformToElement(e)),(v=(p=new Kt(g)).distance(r)+(m=1.1*p.distance(t)))<b?(b=v,w=[{sample:p,refDistance:m}]):v<b+1&&w.push({sample:p,refDistance:m});w.sort((function(t,e){return t.refDistance-e.refDistance})),w[0]&&(o=w[0].sample)}return o}},h.setAttribute=function(t,e){const n=this.node;if(null===e)return this.removeAttr(t),this;const i=y[t],{ns:r}=u.qualifyAttr(i);return r?n.setAttributeNS(r,i,e):"id"===i?n.id=e:n.setAttribute(i,e),this},u.createSvgDocument=function(e){if(e){const n=`<svg xmlns="${t.svg}" xmlns:xlink="${t.xlink}" version="1.1">${e}</svg>`,{documentElement:i}=u.parseXML(n,{async:!1});return i}const n=document.createElementNS(t.svg,"svg");return n.setAttributeNS(t.xmlns,"xmlns:xlink",t.xlink),n.setAttribute("version","1.1"),n},u.createSVGStyle=function(t){const{node:e}=u("style",{type:"text/css"},[u.createCDATASection(t)]);return e},u.createCDATASection=function(t=""){return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},u.idCounter=0,u.uniqueId=function(){return"v-"+ ++u.idCounter},u.toNode=function(t){return u.isV(t)?t.node:t.nodeName&&t||t[0]},u.ensureId=function(t){return(t=u.toNode(t)).id||(t.id=u.uniqueId())},u.sanitizeText=function(t){return(t||"").replace(/ /g," ")},u.isUndefined=function(t){return void 0===t},u.isString=function(t){return"string"==typeof t},u.isObject=function(t){return t&&"object"==typeof t},u.isArray=Array.isArray,u.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;u.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch(t){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};const v=Object.create(null);["baseFrequency","baseProfile","clipPathUnits","contentScriptType","contentStyleType","diffuseConstant","edgeMode","externalResourcesRequired","filterRes","filterUnits","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach((t=>v[t]=t)),v.xlinkShow="xlink:show",v.xlinkRole="xlink:role",v.xlinkActuate="xlink:actuate",v.xlinkHref="xlink:href",v.xlinkType="xlink:type",v.xlinkTitle="xlink:title",v.xmlBase="xml:base",v.xmlLang="xml:lang",v.xmlSpace="xml:space";const y=new Proxy(v,{get:(t,e)=>u.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e});Object.defineProperty(u,"attributeNames",{enumerable:!0,value:y,writable:!1}),Object.defineProperty(u,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),u.qualifyAttr=function(e){if(-1!==e.indexOf(":")){var n=e.split(":");return{ns:t[n[0]],local:n[1]}}return{ns:null,local:e}},u.transformSeparatorRegex=/[ ,]+/,u.transformRegex=/\b\w+\([^()]+\)/g,u.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,u.transformTranslateRegex=/\btranslate\(([^()]+)\)/,u.transformRotateRegex=/\brotate\(([^()]+)\)/,u.transformScaleRegex=/\bscale\(([^()]+)\)/,u.transformStringToMatrix=function(t){let e=u.createSVGMatrix();const n=t&&t.match(u.transformRegex);if(!n)return e;const i=n.length;for(let t=0;t<i;t++){const i=n[t].match(u.transformFunctionRegex);if(i){let t,n,r,o,s,a=u.createSVGMatrix();const l=i[1].toLowerCase(),c=i[2].split(u.transformSeparatorRegex);switch(l){case"scale":t=parseFloat(c[0]),n=void 0===c[1]?t:parseFloat(c[1]),a=a.scaleNonUniform(t,n);break;case"translate":r=parseFloat(c[0]),o=parseFloat(c[1]),a=a.translate(r,o);break;case"rotate":s=parseFloat(c[0]),r=parseFloat(c[1])||0,o=parseFloat(c[2])||0,a=0!==r||0!==o?a.translate(r,o).rotate(s).translate(-r,-o):a.rotate(s);break;case"skewx":s=parseFloat(c[0]),a=a.skewX(s);break;case"skewy":s=parseFloat(c[0]),a=a.skewY(s);break;case"matrix":a.a=parseFloat(c[0]),a.b=parseFloat(c[1]),a.c=parseFloat(c[2]),a.d=parseFloat(c[3]),a.e=parseFloat(c[4]),a.f=parseFloat(c[5]);break;default:continue}e=e.multiply(a)}}return e},u.matrixToTransformString=function(t){return t||(t=!0),"matrix("+(void 0!==t.a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},u.parseTransformString=function(t){var e,n,i;if(t){var r=u.transformSeparatorRegex;if(t.trim().indexOf("matrix")>=0){var o=u.transformStringToMatrix(t),s=u.decomposeMatrix(o);e=[s.translateX,s.translateY],i=[s.scaleX,s.scaleY],n=[s.rotation];var a=[];0===e[0]&&0===e[1]||a.push("translate("+e+")"),1===i[0]&&1===i[1]||a.push("scale("+i+")"),0!==n[0]&&a.push("rotate("+n+")"),t=a.join(" ")}else{const o=t.match(u.transformTranslateRegex);o&&(e=o[1].split(r));const s=t.match(u.transformRotateRegex);s&&(n=s[1].split(r));const a=t.match(u.transformScaleRegex);a&&(i=a[1].split(r))}}var l=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:e&&e[0]?parseInt(e[0],10):0,ty:e&&e[1]?parseInt(e[1],10):0},rotate:{angle:n&&n[0]?parseInt(n[0],10):0,cx:n&&n[1]?parseInt(n[1],10):void 0,cy:n&&n[2]?parseInt(n[2],10):void 0},scale:{sx:l,sy:i&&i[1]?parseFloat(i[1]):l}}},u.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c+0,y:e.x*t.b+e.y*t.d+0}},u.decomposeMatrix=function(t){var e=u.deltaTransformPoint(t,{x:0,y:1}),n=u.deltaTransformPoint(t,{x:1,y:0}),s=180/i*r(e.y,e.x)-90,a=180/i*r(n.y,n.x);return{translateX:t.e,translateY:t.f,scaleX:o(t.a*t.a+t.b*t.b),scaleY:o(t.c*t.c+t.d*t.d),skewX:s,skewY:a,rotation:s}},u.matrixToScale=function(t){var e,n,i,r;return t?(e=u.isUndefined(t.a)?1:t.a,r=u.isUndefined(t.d)?1:t.d,n=t.b,i=t.c):e=r=1,{sx:n?o(e*e+n*n):e,sy:i?o(i*i+r*r):r}},u.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=u.deltaTransformPoint(t,e)),{angle:Ct(Mt(r(e.y,e.x))-90)}},u.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},u.isV=function(t){return t instanceof u},u.isVElement=u.isV,u.isSVGGraphicsElement=function(t){return!!t&&(t=u.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM};var b=u("svg").node;return u.createSVGMatrix=function(t){var e=b.createSVGMatrix();for(var n in t)e[n]=t[n];return e},u.createSVGTransform=function(t){return u.isUndefined(t)?b.createSVGTransform():(t instanceof SVGMatrix||(t=u.createSVGMatrix(t)),b.createSVGTransformFromMatrix(t))},u.createSVGPoint=function(t,e){var n=b.createSVGPoint();return n.x=t,n.y=e,n},u.transformRect=function(t,e){var n=b.createSVGPoint();n.x=t.x,n.y=t.y;var i=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y;var r=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y+t.height;var o=n.matrixTransform(e);n.x=t.x,n.y=t.y+t.height;var l=n.matrixTransform(e),c=s(i.x,r.x,o.x,l.x),u=a(i.x,r.x,o.x,l.x),h=s(i.y,r.y,o.y,l.y),d=a(i.y,r.y,o.y,l.y);return new ge(c,h,u-c,d-h)},u.transformPoint=function(t,e){return new Kt(u.createSVGPoint(t.x,t.y).matrixTransform(e))},u.transformLine=function(t,e){return new ee(u.transformPoint(t.start,e),u.transformPoint(t.end,e))},u.transformPolyline=function(t,e){var n=t instanceof we?t.points:t;u.isArray(n)||(n=[]);for(var i=[],r=0,o=n.length;r<o;r++)i[r]=u.transformPoint(n[r],e);return new we(i)},u.styleToObject=function(t){for(var e={},n=t.split(";"),i=0;i<n.length;i++){var r=n[i].split("=");e[r[0].trim()]=r[1].trim()}return e},u.createSlicePathData=function(t,e,n,r){var o=2*i-1e-6,s=t,a=e,u=n,h=r,d=(h<u&&(d=u,u=h,h=d),h-u),f=d<i?"0":"1",p=l(u),g=c(u),m=l(h),v=c(h);return d>=o?s?"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"M0,"+s+"A"+s+","+s+" 0 1,0 0,"+-s+"A"+s+","+s+" 0 1,0 0,"+s+"Z":"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z":s?"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L"+s*m+","+s*v+"A"+s+","+s+" 0 "+f+",0 "+s*p+","+s*g+"Z":"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L0,0Z"},u.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?u.isObject(t[n])&&u.isObject(e[n])?t[n]=u.mergeAttrs(t[n],e[n]):u.isObject(t[n])?t[n]=u.mergeAttrs(t[n],u.styleToObject(e[n])):u.isObject(e[n])?t[n]=u.mergeAttrs(u.styleToObject(t[n]),e[n]):t[n]=u.mergeAttrs(u.styleToObject(t[n]),u.styleToObject(e[n])):t[n]=e[n];return t},u.annotateString=function(t,e,n){e=e||[];for(var i,r,o,s=(n=n||{}).offset||0,a=[],l=[],c=0;c<t.length;c++){r=l[c]=t[c];for(var h=0;h<e.length;h++){var d=e[h],f=d.start+s,p=d.end+s;c>=f&&c<p&&(u.isObject(r)?r.attrs=u.mergeAttrs(u.mergeAttrs({},r.attrs),d.attrs):r=l[c]={t:t[c],attrs:d.attrs},n.includeAnnotationIndices&&(r.annotations||(r.annotations=[])).push(h))}(o=l[c-1])?u.isObject(r)&&u.isObject(o)?JSON.stringify(r.attrs)===JSON.stringify(o.attrs)?i.t+=r.t:(a.push(i),i=r):u.isObject(r)||u.isObject(o)?(a.push(i),i=r):i=(i||"")+r:i=r}return i&&a.push(i),a},u.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach((function(t){t.start<e&&e<=t.end&&n.push(t)})),n},u.findAnnotationsBetweenIndexes=function(t,e,n){var i=[];return t&&t.forEach((function(t){(e>=t.start&&e<t.end||n>t.start&&n<=t.end||t.start>=e&&t.end<n)&&i.push(t)})),i},u.shiftAnnotations=function(t,e,n){return t&&t.forEach((function(t){t.start<e&&t.end>=e?t.end+=n:t.start>=e&&(t.start+=n,t.end+=n)})),t},u.convertLineToPathData=function(t){return["M",(t=u(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},u.convertPolygonToPathData=function(t){var e=u.getPointsFromSvgNode(t);return 0===e.length?null:u.svgPointsToPath(e)+" Z"},u.convertPolylineToPathData=function(t){var e=u.getPointsFromSvgNode(t);return 0===e.length?null:u.svgPointsToPath(e)},u.svgPointsToPath=function(t){for(var e=0,n=t.length;e<n;e++)t[e]=t[e].x+" "+t[e].y;return"M "+t.join(" L")},u.getPointsFromSvgNode=function(t){var e=[],n=(t=u.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},u.KAPPA=.551784,u.convertCircleToPathData=function(t){t=u(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("r")),r=i*u.KAPPA;return["M",e,n-i,"C",e+r,n-i,e+i,n-r,e+i,n,"C",e+i,n+r,e+r,n+i,e,n+i,"C",e-r,n+i,e-i,n+r,e-i,n,"C",e-i,n-r,e-r,n-i,e,n-i,"Z"].join(" ")},u.convertEllipseToPathData=function(t){t=u(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),r=parseFloat(t.attr("ry"))||i,o=i*u.KAPPA,s=r*u.KAPPA;return["M",e,n-r,"C",e+o,n-r,e+i,n-s,e+i,n,"C",e+i,n+s,e+o,n+r,e,n+r,"C",e-o,n+r,e-i,n+s,e-i,n,"C",e-i,n-s,e-o,n-r,e,n-r,"Z"].join(" ")},u.convertRectToPathData=function(t){return t=u(t),u.rectToPath({x:parseFloat(t.attr("x"))||0,y:parseFloat(t.attr("y"))||0,width:parseFloat(t.attr("width"))||0,height:parseFloat(t.attr("height"))||0,rx:parseFloat(t.attr("rx"))||0,ry:parseFloat(t.attr("ry"))||0})},u.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=s(t.rx||t["top-rx"]||0,i/2),a=s(t.rx||t["bottom-rx"]||0,i/2),l=s(t.ry||t["top-ry"]||0,r/2),c=s(t.ry||t["bottom-ry"]||0,r/2);return(o||a||l||c?["M",e,n+l,"v",r-l-c,"a",a,c,0,0,0,a,c,"h",i-2*a,"a",a,c,0,0,0,a,-c,"v",-(r-c-l),"a",o,l,0,0,0,-o,-l,"h",-(i-2*o),"a",o,l,0,0,0,-o,l,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"]).join(" ")},u.normalizePathData=function(){var t="\t\n\v\f\r \u2028\u2029",e=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),n=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),i=Math,r=i.PI,o=i.sin,s=i.cos,a=i.tan,l=i.asin,c=i.sqrt,u=i.abs;function h(t,e,n,i,r,o){var s=1/3,a=2/3;return[s*t+a*n,s*e+a*i,s*r+a*n,s*o+a*i,r,o]}function d(t,e,n){return{x:t*s(n)-e*o(n),y:t*o(n)+e*s(n)}}function f(t,e,n,i,h,p,g,m,v,y){var b,w=120*r/180,x=r/180*(+h||0),A=[];if(y)M=y[0],O=y[1],C=y[2],L=y[3];else{t=(b=d(t,e,-x)).x,e=b.y;var E=(t-(m=(b=d(m,v,-x)).x))/2,T=(e-(v=b.y))/2,S=E*E/(n*n)+T*T/(i*i);S>1&&(n*=S=c(S),i*=S);var P=n*n,_=i*i,k=(p==g?-1:1)*c(u((P*_-P*T*T-_*E*E)/(P*T*T+_*E*E))),C=k*n*T/i+(t+m)/2,L=k*-i*E/n+(e+v)/2,M=l(((e-L)/i).toFixed(9)),O=l(((v-L)/i).toFixed(9));(M=t<C?r-M:M)<0&&(M=2*r+M),(O=m<C?r-O:O)<0&&(O=2*r+O),g&&M>O&&(M-=2*r),!g&&O>M&&(O-=2*r)}var N=O-M;if(u(N)>w){var R=O,F=m,B=v;A=f(m=C+n*s(O=M+w*(g&&O>M?1:-1)),v=L+i*o(O),n,i,h,0,g,F,B,[O,R,C,L])}N=O-M;var I=s(M),D=o(M),V=s(O),z=o(O),j=a(N/4),$=4/3*(n*j),U=4/3*(i*j),G=[t,e],q=[t+$*D,e-U*I],H=[m+$*z,v-U*V],W=[m,v];if(q[0]=2*G[0]-q[0],q[1]=2*G[1]-q[1],y)return[q,H,W].concat(A);for(var Y=[],X=(A=[q,H,W].concat(A).join().split(",")).length,Z=0;Z<X;Z++)Y[Z]=Z%2?d(A[Z-1],A[Z],x).y:d(A[Z],A[Z+1],x).x;return Y}function p(t){var i=function(t){if(Array.isArray(t)&&Array.isArray(t&&t[0])||(t=function(t){if(!t)return null;var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=[];return String(t).replace(e,(function(t,e,o){var s=[],a=e.toLowerCase();for(o.replace(n,(function(t,e){e&&s.push(+e)})),"m"===a&&s.length>2&&(r.push([e].concat(s.splice(0,2))),a="l",e="m"===e?"l":"L");s.length>=i[a]&&(r.push([e].concat(s.splice(0,i[a]))),i[a]););})),r}(t)),!t||!t.length)return[["M",0,0]];for(var i,r=[],o=0,s=0,a=0,l=0,c=t.length,u=0;u<c;u++){var h=[];r.push(h);var d,f,p=t[u];if((i=p[0])!=i.toUpperCase())switch(h[0]=i.toUpperCase(),h[0]){case"A":h[1]=p[1],h[2]=p[2],h[3]=p[3],h[4]=p[4],h[5]=p[5],h[6]=+p[6]+o,h[7]=+p[7]+s;break;case"V":h[1]=+p[1]+s;break;case"H":h[1]=+p[1]+o;break;case"M":for(a=+p[1]+o,l=+p[2]+s,d=p.length,f=1;f<d;f++)h[f]=+p[f]+(f%2?o:s);break;default:for(d=p.length,f=1;f<d;f++)h[f]=+p[f]+(f%2?o:s)}else for(var g=p.length,m=0;m<g;m++)h[m]=p[m];switch(h[0]){case"Z":o=+a,s=+l;break;case"H":o=h[1];break;case"V":s=h[1];break;case"M":a=h[h.length-2],l=h[h.length-1],o=h[h.length-2],s=h[h.length-1];break;default:o=h[h.length-2],s=h[h.length-1]}}return r}(t),r={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function o(t,e,n){var i,r;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(t[0]in{T:1,Q:1}||(e.qx=null,e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=0===parseFloat(t[1])||0===parseFloat(t[2])?["L",t[6],t[7]]:["C"].concat(f.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":"C"===n||"S"===n?(i=2*e.x-e.bx,r=2*e.y-e.by):(i=e.x,r=e.y),t=["C",i,r].concat(t.slice(1));break;case"T":"Q"===n||"T"===n?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"].concat(h(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"].concat(h(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}function s(t,e){if(t[e].length>7){t[e].shift();for(var n=t[e];n.length;)a[e]="A",t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),u=i.length}}for(var a=[],l="",c="",u=i.length,d=0;d<u;d++){i[d]&&(l=i[d][0]),"C"!==l&&(a[d]=l,d>0&&(c=a[d-1])),i[d]=o(i[d],r,c),"A"!==a[d]&&"C"===l&&(a[d]="C"),s(i,d);var p=i[d],g=p.length;r.x=p[g-2],r.y=p[g-1],r.bx=parseFloat(p[g-4])||r.x,r.by=parseFloat(p[g-3])||r.y}return i[0][0]&&"M"===i[0][0]||i.unshift(["M",0,0]),i}return function(t){return p(t).join(",").split(",").join(" ")}}(),u.namespace=t,u.g=e,u}(),xn=wn,An="[object Arguments]",En="[object Array]",Tn="[object Boolean]",Sn="[object Date]",Pn="[object Error]",_n="[object Function]",kn="[object Map]",Cn="[object Number]",Ln="[object Object]",Mn="[object RegExp]",On="[object Set]",Nn="[object String]",Rn="[object Symbol]",Fn="[object WeakMap]",Bn="[object ArrayBuffer]",In="[object DataView]",Dn="[object Float32Array]",Vn="[object Float64Array]",zn="[object Int8Array]",jn="[object Int16Array]",$n="[object Int32Array]",Un="[object Uint8Array]",Gn="[object Uint8ClampedArray]",qn="[object Uint16Array]",Hn="[object Uint32Array]",Wn={[An]:!0,[En]:!0,[Bn]:!0,[In]:!0,[Tn]:!0,[Sn]:!0,[Dn]:!0,[Vn]:!0,[zn]:!0,[jn]:!0,[$n]:!0,[kn]:!0,[Cn]:!0,[Ln]:!0,[Mn]:!0,[On]:!0,[Nn]:!0,[Rn]:!0,[Un]:!0,[Gn]:!0,[qn]:!0,[Hn]:!0,[Pn]:!1,[_n]:!1,[Fn]:!1},Yn="\\ud800-\\udfff",Xn="\\u2700-\\u27bf",Zn="a-z\\xdf-\\xf6\\xf8-\\xff",Kn="A-Z\\xc0-\\xd6\\xd8-\\xde",Jn="\\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",Qn="['’]",ti=`[${Jn}]`,ei="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ni=`[${Xn}]`,ii=`[${Zn}]`,ri=`[^${Yn}${Jn+"\\d"+Xn+Zn+Kn}]`,oi="\\ud83c[\\udffb-\\udfff]",si=`[^${Yn}]`,ai="(?:\\ud83c[\\udde6-\\uddff]){2}",li="[\\ud800-\\udbff][\\udc00-\\udfff]",ci=`[${Kn}]`,ui=`(?:${ii}|${ri})`,hi=`(?:${ci}|${ri})`,di=`(?:${Qn}(?:d|ll|m|re|s|t|ve))?`,fi=`(?:${Qn}(?:D|LL|M|RE|S|T|VE))?`,pi=`(?:${ei}|${oi})?`,gi="[\\ufe0e\\ufe0f]?",mi=gi+pi+`(?:\\u200d(?:${[si,ai,li].join("|")})${gi+pi})*`,vi=`(?:${[ni,ai,li].join("|")})${mi}`,yi=RegExp([`${ci}?${ii}+${di}(?=${[ti,ci,"$"].join("|")})`,`${hi}+${fi}(?=${[ti,ci+ui,"$"].join("|")})`,`${ci}?${ui}+${di}`,`${ci}+${fi}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",vi].join("|"),"g"),bi="__hash_undefined__",wi=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,xi=`(?:${[`${si}${ei}?`,ei,ai,li,`[${Yn}]`].join("|")})`,Ai=RegExp(`${oi}(?=${oi})|${xi+mi}`,"g"),Ei=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ti=/^\w*$/,Si=".".charCodeAt(0),Pi=/\\(\\)?/g,_i=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),ki=/^(?:0|[1-9]\d*)$/,Ci=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),Li=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Mi=t=>Ai.test(t),Oi=t=>Mi(t)?(t=>t.match(Ai)||[])(t):(t=>t.split(""))(t),Ni=t=>null==t?[]:Ri(t).map((e=>t[e])),Ri=t=>Ui(t)?Fi(t):Object.keys(Object(t)),Fi=(t,e)=>{const n=Array.isArray(t),i=!n&&Di(t)&&Hi(t)===An,r=!n&&!i&&Ki(t),o=n||i||r,s=t.length,a=new Array(o?s:0);let l=o?-1:s;for(;++l<s;)a[l]=`${l}`;for(const n in t)!e&&!hasOwnProperty.call(t,n)||o&&("length"===n||xr(n,s))||a.push(n);return a},Bi=(t,e)=>{let{length:n}=t;for(;n--;)if(Ii(t[n][0],e))return n;return-1},Ii=(t,e)=>t===e||t!=t&&e!=e,Di=t=>null!=t&&"object"==typeof t,Vi=(t,e,n)=>{if(!Qr(n))return!1;const i=typeof e;return!!("number"==i?Ui(n)&&e>-1&&e<n.length:"string"==i&&e in n)&&Ii(n[e],t)},zi=t=>{const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},ji=(t,e,n)=>{const i=t[e];hasOwnProperty.call(t,e)&&Ii(i,n)&&(void 0!==n||e in t)||(t[e]=n)},$i=(t,e,n)=>{let i=-1;const r=e.length;for(;++i<r;){const r=e[i];ji(n,r,t[r])}return n},Ui=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&t.length>-1&&t.length%1==0,Gi=t=>"symbol"==typeof t||Di(t)&&Hi(t)===Rn,qi=(t,e)=>{let n=-1;const i=t.length;for(e||(e=new Array(i));++n<i;)e[n]=t[n];return e},Hi=t=>null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t),Wi=t=>{const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Yi=(t,e)=>{const n=e?Wi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)},Xi=t=>"function"!=typeof t.constructor||zi(t)?{}:Object.create(Object.getPrototypeOf(t)),Zi=t=>null==t?[]:(t=Object(t),Object.getOwnPropertySymbols(t).filter((e=>propertyIsEnumerable.call(t,e)))),Ki=t=>Di(t)&&wi.test(Hi(t)),Ji=t=>{const e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...Zi(Object(t))),e},Qi=t=>{const e=[];for(;t;)e.push(...Zi(t)),t=Object.getPrototypeOf(Object(t));return e},tr=t=>{const e=[];for(const n in t)e.push(n);return Array.isArray(t)||e.push(...Qi(t)),e},er=({__data__:t},e)=>{const n=t;return Er(e)?n["string"==typeof e?"string":"hash"]:n.map},nr=(t,e,n)=>t===e||(null==t||null==e||!Di(t)&&!Di(e)?t!=t&&e!=e:ir(t,e,nr,n)),ir=(t,e,n,i)=>{let r=Array.isArray(t);const o=Array.isArray(e);let s=r?En:Hi(t),a=o?En:Hi(e);s=s==An?Ln:s,a=a==An?Ln:a;let l=s==Ln;const c=a==Ln,u=s==a;if(u&&!l)return i||(i=new Yr),r||Ki(t)?rr(t,e,!1,n,i):lr(t,e,s,n,i);const h=l&&hasOwnProperty.call(t,"__wrapped__"),d=c&&hasOwnProperty.call(e,"__wrapped__");if(h||d){const r=h?t.value():t,o=d?e.value():e;return i||(i=new Yr),n(r,o,i)}return!!u&&(i||(i=new Yr),((t,e,n,i)=>{const r=Ji(t),o=r.length;if(o!=Ji(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;const l=i.get(t),c=i.get(e);if(l&&c)return l==e&&c==t;let u,h=!0;for(i.set(t,e),i.set(e,t);++a<o;){s=r[a];const o=t[s],l=e[s];if(o!==l&&!n(o,l,i)){h=!1;break}u||(u="constructor"==s)}if(h&&!u){const n=t.constructor,i=e.constructor;n==i||!("constructor"in t)||!("constructor"in e)||"function"==typeof n&&n instanceof n&&"function"==typeof i&&i instanceof i||(h=!1)}return i.delete(t),i.delete(e),h})(t,e,n,i))},rr=(t,e,n,i,r)=>{const o=t.length;if(o!=e.length)return!1;const s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,c=!0;const u=n?new Jr:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n;const o=t[l],s=e[l];if(void 0!==n){if(n)continue;c=!1;break}if(u){if(!or(e,((t,e)=>{if(!sr(u,e)&&(o===t||i(o,t,r)))return u.push(e)}))){c=!1;break}}else if(o!==s&&!i(o,s,r)){c=!1;break}}return r.delete(t),r.delete(e),c},or=(t,e)=>{let n=-1;const i=null==t?0:t.length;for(;++n<i;)if(e(t[n],n,t))return!0;return!1},sr=(t,e)=>t.has(e),ar=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),lr=(t,e,n,i,r)=>{switch(n){case In:return t.byteLength==e.byteLength&&t.byteOffset==e.byteOffset&&(t=t.buffer,e=e.buffer,ar(t,e,i,r));case Bn:return ar(t,e,i,r);case Tn:case Sn:case Cn:return Ii(+t,+e);case Pn:return t.name==e.name&&t.message==e.message;case Mn:case Nn:return t==`${e}`;case kn:let n=cr;case On:if(n||(n=ur),t.size!=e.size)return!1;const o=r.get(t);if(o)return o==e;r.set(t,e);const s=rr(n(t),n(e),!0,i,r);return r.delete(t),s;case Rn:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},cr=t=>{let e=-1,n=Array(t.size);return t.forEach(((t,i)=>{n[++e]=[i,t]})),n},ur=t=>{let e=-1;const n=new Array(t.size);return t.forEach((t=>{n[++e]=t})),n},hr=(t,e)=>{if(Array.isArray(t))return!1;const n=typeof t;return!("number"!==n&&"boolean"!==n&&null!=t&&!Gi(t))||Ti.test(t)||!Ei.test(t)||null!=e&&t in Object(e)},dr=(t,e)=>Array.isArray(t)?t:hr(t,e)?[t]:(t=>{const e=[];return t.charCodeAt(0)===Si&&e.push(""),t.replace(_i,((t,n,i,r)=>{let o=t;i?o=r.replace(Pi,"$1"):n&&(o=n.trim()),e.push(o)})),e})(`${t}`),fr=(t,e)=>{let n=0;const i=(e=dr(e,t)).length;for(;null!=t&&n<i;)t=t[mr(e[n])],n++;return n&&n==i?t:void 0};function pr(t,e){if(t!==e){const n=void 0!==t,i=null===t,r=t==t,o=Gi(t),s=void 0!==e,a=null===e,l=e==e,c=Gi(e);if(!a&&!c&&!o&&t>e||o&&s&&l&&!a&&!c||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!c&&t<e||c&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}const gr=(t,e)=>{let n=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1,i=!0;const r=[],o=e.length;if(!t.length)return r;e.length>=200&&(n=(t,e)=>t.has(e),i=!1,e=new Jr(e));t:for(let s in t){let a=t[s];const l=a;if(a=0!==a?a:0,i&&l==l){let t=o;for(;t--;)if(e[t]===l)continue t;r.push(a)}else n(e,l)||r.push(a)}return r},mr=t=>{if("string"==typeof t||Gi(t))return t;const e=`${t}`;return"0"==e&&1/t==-1/0?"-0":e},vr=(t,e=!1,n=!1,i=!0,r,o,s,a)=>{let l;if(r&&(l=s?r(t,o,s,a):r(t)),void 0!==l)return l;if(!Qr(t))return t;const c=Array.isArray(t),u=Hi(t);if(c){if(l=(t=>{const e=t.length;let n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n})(t),!e)return qi(t,l)}else{const i="function"==typeof t;if(u===Ln||u===An||i&&!s){if(l=n||i?{}:Xi(t),!e)return n?yr(t,$i(t,Object.keys(t),l)):((t,e)=>$i(t,Zi(t),e))(t,Object.assign(l,t))}else{if(i||!Wn[u])return s?t:{};l=((t,e,n)=>{const i=t.constructor;switch(e){case Bn:return Wi(t);case Tn:case Sn:return new i(+t);case In:return function(t,e){const n=e?Wi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case Dn:case Vn:case zn:case jn:case $n:case Un:case Gn:case qn:case Hn:return Yi(t,n);case kn:case Cn:case Nn:return new i(t);case Mn:return(t=>{const e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e})(t);case On:return new i;case Rn:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}})(t,u,e)}}a||(a=new Yr);const h=a.get(t);if(h)return h;if(a.set(t,l),(t=>Di(t)&&Hi(t)==kn)(t))return t.forEach(((o,s)=>{l.set(s,vr(o,e,n,i,r,s,t,a))})),l;if((t=>Di(t)&&Hi(t)==On)(t))return t.forEach((o=>{l.add(vr(o,e,n,i,r,o,t,a))})),l;if(Ki(t))return l;const d=c?void 0:(i?n?tr:Ji:n?Tr:Ri)(t);return(d||t).forEach(((o,s)=>{d&&(o=t[s=o]),ji(l,s,vr(o,e,n,i,r,s,t,a))})),l},yr=(t,e)=>$i(t,Qi(t),e),br=(t,e)=>e.length<2?t:fr(t,e.slice(0,-1)),wr=(t,e,n)=>{if(!Qr(t))return t;const i=(e=dr(e,t)).length,r=i-1;let o=-1,s=t;for(;null!=s&&++o<i;){const t=mr(e[o]);let i=n;if(o!=r){const n=s[t];i=void 0,void 0===i&&(i=Qr(n)?n:xr(e[o+1])?[]:{})}ji(s,t,i),s=s[t]}return t},xr=(t,e)=>{const n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"===n||"symbol"!==n&&ki.test(t))&&t>-1&&t%1==0&&t<e},Ar=(t,e)=>{e=dr(e,t),t=br(t,e);const n=e[e.length-1];return null==t||delete t[mr(n)]},Er=t=>{const e=typeof t;return"string"===e||"number"===e||"symbol"===e||"boolean"===e?"__proto__"!==t:null===t},Tr=t=>{const e=[];for(const n in t)e.push(n);return e},Sr=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function Pr(t,e=!1){return(n,...i)=>{let r=-1,o=i.length,s=o>1?i[o-1]:void 0;const a=o>2?i[2]:void 0;for(s=t.length>3&&"function"==typeof s?(o--,s):e?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,a&&Vi(i[0],i[1],a)&&(s=o<3?void 0:s,o=1),n=Object(n);++r<o;){const e=i[r];e&&t(n,e,r,s)}return n}}const _r=(t,e,n,i,r)=>{t!==e&&Po(e,((o,s)=>{if(Qr(o))r||(r=new Yr),kr(t,e,s,n,_r,i,r);else{let n=i?i(t[s],o,`${s}`,t,e,r):void 0;void 0===n&&(n=o),Cr(t,s,n)}}),Tr)},kr=(t,e,n,i,r,o,s)=>{const a=Sr(t,n),l=Sr(e,n),c=s.get(l);if(c)return void Cr(t,n,c);let u=o?o(a,l,`${n}`,t,e,s):void 0,h=void 0===u;if(h){const t=Array.isArray(l),e=!t&&Ki(l);u=l,t||e?Array.isArray(a)?u=a:Di(a)&&Ui(a)?u=qi(a):e?(h=!1,u=Yi(l,!0)):u=[]:go(l)||Gr(l)?(u=a,Gr(a)?u=(t=>{t=Object(t);const e={};for(const n in t)e[n]=t[n];return e})(a):"function"!=typeof a&&Qr(a)||(u=Xi(l))):h=!1}h&&(s.set(l,u),r(u,l,i,o,s),s.delete(l)),Cr(t,n,u)},Cr=(t,e,n)=>{(void 0!==n&&!Ii(t[e],n)||void 0===n&&!(e in t))&&ji(t,e,n)},Lr=(t,e)=>{if(null==t)return t;if(!Ui(t))return((t,e)=>t&&function(t,e,n){const i=Object(t),r=n(t);let{length:o}=r,s=-1;for(;o--;){const t=r[++s];if(!1===e(i[t],t,i))break}return t}(t,e,Ri))(t,e);const n=t.length,i=Object(t);let r=-1;for(;++r<n&&!1!==e(i[r],r,i););return t},Mr=Set&&1/ur(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function Or(t,e,n,i,r,o){return Qr(t)&&Qr(e)&&(o.set(e,t),_r(t,e,void 0,Or,o),o.delete(e)),t}function Nr(t,e,n){e=e.length?e.map((t=>Array.isArray(t)?e=>fr(e,1===t.length?t[0]:t):t)):[t=>t];let i=-1,r=-1;const o=Ui(t)?new Array(t.length):[];return Lr(t,(t=>{const n=e.map((e=>e(t)));o[++r]={criteria:n,index:++i,value:t}})),function(t,e){let{length:i}=t;for(t.sort(((t,e)=>function(t,e,n){let i=-1;const r=t.criteria,o=e.criteria,s=r.length,a=n.length;for(;++i<s;){const t=i<a?n[i]:null,e=(t&&"function"==typeof t?t:pr)(r[i],o[i]);if(e)return t&&"function"!=typeof t?e*("desc"==t?-1:1):e}return t.index-e.index}(t,e,n)));i--;)t[i]=t[i].value;return t}(o)}function Rr(t){return t==t&&!Qr(t)}function Fr(t,e){return n=>null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}function Br(t,e){return null!=t&&Hr(t,e,qr)}function Ir(t){const e=function(t){const e=Ri(t);let n=e.length;for(;n--;){const i=e[n],r=t[i];e[n]=[i,r,Rr(r)]}return e}(t);return 1===e.length&&e[0][2]?Fr(e[0][0],e[0][1]):n=>n===t||function(t,e,n,i){let r=n.length;const o=r;if(null==t)return!o;let s,a;for(t=Object(t);r--;)if(s=n[r],s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1;for(;++r<o;){s=n[r];const e=s[0],i=t[e],o=s[1];if(s[2]){if(void 0===i&&!(e in t))return!1}else{const t=new Yr;if(!(void 0===a?nr(o,i,t):a))return!1}}return!0}(n,0,e)}function Dr(t){return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(e=t[0],n=t[1],hr(e)&&Rr(n)?Fr(mr(e),n):t=>{const i=fr(t,e);return void 0===i&&i===n?Br(t,e):nr(n,i)}):Ir(t):function(t){return hr(t)?(e=mr(t),t=>null==t?void 0:t[e]):function(t){return e=>fr(e,t)}(t);var e}(t);var e,n}function Vr(){const t=Dr;return arguments.length?t(arguments[0],arguments[1]):t}const zr=(t,e,n,i)=>{let r=-1;const o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},jr=(t,e,n,i,r)=>(r(t,((t,r,o)=>{n=i?(i=!1,t):e(n,t,r,o)})),n),$r=t=>Array.isArray(t)||Gr(t)||!(!t||!t[Symbol.isConcatSpreadable]);function Ur(t,e,n,i,r){let o=-1;const s=t.length;for(n||(n=$r),r||(r=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?Ur(a,e-1,n,i,r):r.push(...a):i||(r[r.length]=a)}return r}const Gr=t=>Di(t)&&"[object Arguments]"==Hi(t),qr=(t,e)=>null!=t&&e in Object(t),Hr=(t,e,n)=>{for(var i,r=-1,o=(e=dr(e,t)).length,s=!1;++r<o;){var a=mr(e[r]);if(!(s=null!=t&&n(t,a)))break;t=t[a]}return s||++r!=o?s:!!(o=null==t?0:t.length)&&"number"==typeof(i=o)&&i>-1&&i%1==0&&i<=Number.MAX_SAFE_INTEGER&&xr(a,o)&&(Array.isArray(t)||Gr(t))},Wr=("toUpperCase",t=>{if(!t)return"";const e=Mi(t)?Oi(t):void 0,n=e?e[0]:t[0],i=e?((t,e,n)=>{const{length:i}=t;return n=void 0===n?i:n,t.slice(1,n)})(e).join(""):t.slice(1);return n.toUpperCase()+i});class Yr{constructor(t){const e=this.__data__=new Xr(t);this.size=e.size}clear(){this.__data__=new Xr,this.size=0}delete(t){const e=this.__data__,n=e.delete(t);return this.size=e.size,n}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof Xr){const i=n.__data__;if(i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Zr(i)}return n.set(t,e),this.size=n.size,this}}class Xr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=[],this.size=0}delete(t){const e=this.__data__,n=Bi(e,t);return!(n<0)&&(n==e.length-1?e.pop():e.splice(n,1),--this.size,!0)}get(t){const e=this.__data__,n=Bi(e,t);return n<0?void 0:e[n][1]}has(t){return Bi(this.__data__,t)>-1}set(t,e){const n=this.__data__,i=Bi(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class Zr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.size=0,this.__data__={hash:new Kr,map:new Map,string:new Kr}}delete(t){const e=er(this,t).delete(t);return this.size-=e?1:0,e}get(t){return er(this,t).get(t)}has(t){return er(this,t).has(t)}set(t,e){const n=er(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Kr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){const e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}get(t){const e=this.__data__[t];return e===bi?void 0:e}has(t){return void 0!==this.__data__[t]}set(t,e){const n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?bi:e,this}}class Jr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.__data__=new Zr;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,bi),this}has(t){return this.__data__.has(t)}}Jr.prototype.push=Jr.prototype.add;const Qr=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},to=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Cn},eo=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Nn},no=Pr(((t,e)=>{if(zi(e)||Ui(e))$i(e,Ri(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&ji(t,n,e[n])})),io=(t,...e)=>{let n=-1,i=e.length;const r=i>2?e[2]:void 0;for(r&&Vi(e[0],e[1],r)&&(i=1);++n<i;){const i=e[n];if(null==i)continue;const r=Object.keys(i),o=r.length;let s=-1;for(;++s<o;){const e=r[s],n=t[e];(void 0===n||Ii(n,Object.prototype[e])&&!hasOwnProperty.call(t,e))&&(t[e]=i[e])}}return t},ro=function(...t){return t.push(void 0,Or),Lo.apply(void 0,t)},oo=(t,e,...n)=>{let i=-1;const r="function"==typeof e,o=Ui(t)?new Array(t.length):[];return Lr(t,(t=>{o[++i]=r?e.apply(t,n):so(t,e,...n)})),o},so=(t,e,...n)=>{e=dr(e,t);const i=null==(t=br(t,e))?t:t[mr(function(t){const e=null==t?0:t.length;return e?t[e-1]:void 0}(e))];return null==i?void 0:i.apply(t,n)},ao=(t,e,n)=>{let i=0,r=null==t?0:t.length;if(0==r)return 0;const o=(e=(n=Vr(n,2))(e))!=e,s=null===e,a=Gi(e),l=void 0===e;for(;i<r;){let c;const u=Math.floor((i+r)/2),h=n(t[u]),d=void 0!==h,f=null===h,p=h==h,g=Gi(h);c=o?p:l?p&&d:s?p&&d&&!f:a?p&&d&&!f&&!g:!f&&!g&&h<e,c?i=u+1:r=u}return Math.min(r,4294967294)},lo=(t,e)=>{let n=-1,i=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1;e=Vr(e,2);let r=!0;const{length:o}=t,s=[];let a=s;if(o>=200){const n=e?null:Mr(t);if(n)return ur(n);r=!1,i=(t,e)=>t.has(e),a=new Jr}else a=e?[]:s;t:for(;++n<o;){let o=t[n];const l=e?e(o):o;if(o=0!==o?o:0,r&&l==l){let t=a.length;for(;t--;)if(a[t]===l)continue t;e&&a.push(l),s.push(o)}else i(a,l)||(a!==s&&a.push(l),s.push(o))}return s},co=t=>vr(t),uo=t=>vr(t,!0),ho=t=>{if(null==t)return!0;if(Ui(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Ki(t)||Gr(t)))return!t.length;const e=Hi(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(zi(t))return!(t=>{if(!zi(t))return Object.keys(t);var e=[];for(var n in Object(t))hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e})(t).length;for(const e in t)if(hasOwnProperty.call(t,e))return!1;return!0},fo=(t,e)=>nr(t,e),po=t=>"function"==typeof t,go=t=>{if(!Di(t)||"[object Object]"!=Hi(t))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},mo=t=>{if(!t)return[];if(Ui(t))return eo(t)?Oi(t):qi(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){const e=t[Symbol.iterator]();let n;const i=[];for(;!(n=e.next()).done;)i.push(n.value);return i}const e=Hi(t);return(e==kn?cr:e==On?ur:Ni)(t)},vo=(t,e=[])=>{if(null==t)return[];const n=e.length;return n>1&&Vi(t,e[0],e[1])?e=[]:n>2&&Vi(e[0],e[1],e[2])&&(e=[e[0]]),Array.isArray(e)||(e=[Vr(e,2)]),Nr(t,e.flat(1),[])},yo=t=>null!=t&&t.length?Ur(t,1/0):[],bo=(t,...e)=>Ui(t)?gr(t,e):[],wo=(t,...e)=>Di(t)&&Ui(t)?gr(t,e.flat(1)):[],xo=(...t)=>{const e=t.flat(1);return lo(e)},Ao=(t,e)=>{if(null==t)return!1;"string"==typeof e&&(e=e.split("."));let n=-1,i=t;for(;++n<e.length;){if(!i||!hasOwnProperty.call(i,e[n]))return!1;i=i[e[n]]}return!0},Eo=(t,e,n)=>{let i=-1,r=(e=dr(e,t)).length;for(r||(r=1,t=void 0);++i<r;){let o=null==t?void 0:t[mr(e[i])];void 0===o&&(i=r,o=n),t="function"==typeof o?o.call(t):o}return t},To=(t,...e)=>{let n={};if(null==t)return n;let i=!1;e=e.flat(1).map((e=>(e=dr(e,t),i||(i=e.length>1),e))),$i(t,tr(t),n),i&&(n=vr(n,!0,!0,!0,(t=>go(t)?void 0:t)));let r=e.length;for(;r--;)Ar(n,e[r]);return n},So=(t,...e)=>null==t?{}:((t,e)=>((t,e,n)=>{let i=-1;const r=e.length,o={};for(;++i<r;){const r=e[i],s=fr(t,r);n(s,r)&&wr(o,dr(r,t),s)}return o})(t,e,((e,n)=>Br(t,n))))(t,e.flat(1/0)),Po=(t,e=(t=>t))=>{let n=-1;const i=Object(t),r=Ui(t)?Fi(t,!0):Tr(t);let o=r.length;for(;o--;){const t=r[++n];if(!1===e(i[t],t,i))break}},_o=(t="")=>((t,e)=>{if(void 0===e){const e=Ci(t)?(t=>t.match(yi))(t):(t=>t.match(Li))(t);return e||[]}return t.match(e)||[]})(`${t}`.replace(/['\u2019]/g,"")).reduce(((t,e,n)=>(e=e.toLowerCase(),t+(n?Wr(e):e))),"");let ko=0;const Co=(t="")=>`${t}`+ ++ko,Lo=Pr(((t,e,n,i)=>{_r(t,e,n,i)}),!0),Mo=class{constructor(){this.map=new WeakMap}has(t,e){return void 0===e?this.map.has(t):e in this.map.get(t)}create(t){return this.has(t)||this.map.set(t,Object.create(null)),this.get(t)}get(t,e){if(!this.has(t))return;const n=this.map.get(t);return void 0===e?n:n[e]}set(t,e,n){if(void 0===e)return;const i=this.create(t);"string"==typeof e?i[e]=n:Object.assign(i,e)}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}},Oo=new Mo,No=new Mo,Ro=function(t,e){if(!(this instanceof Ro))return new Ro(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?Fo:Bo,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&Object.assign(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this.envelope=!0};function Fo(){return!0}function Bo(){return!1}Ro.prototype={constructor:Ro,isDefaultPrevented:Bo,isPropagationStopped:Bo,isImmediatePropagationStopped:Bo,preventDefault:function(){const t=this.originalEvent;this.isDefaultPrevented=Fo,t&&t.preventDefault()},stopPropagation:function(){const t=this.originalEvent;this.isPropagationStopped=Fo,t&&t.stopPropagation()},stopImmediatePropagation:function(){const t=this.originalEvent;this.isImmediatePropagationStopped=Fo,t&&t.stopImmediatePropagation(),this.stopPropagation()}},["altKey","bubbles","cancelable","changedTouches","ctrlKey","detail","eventPhase","metaKey","pageX","pageY","shiftKey","view","char","code","charCode","key","keyCode","button","buttons","clientX","clientY","offsetX","offsetY","pointerId","pointerType","screenX","screenY","targetTouches","toElement","touches","which"].forEach((t=>function(t){Object.defineProperty(Ro.prototype,t,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[t]:void 0},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})}(t)));const Io="undefined"!=typeof window?window.document:null,Do=Io&&Io.documentElement,Vo=/^([^.]*)(?:\.(.+)|)/,zo=/[^\x20\t\r\n\f]+/g,jo=function(t){return new jo.Dom(t)};jo.fn=jo.prototype={constructor:jo,length:0},jo.guid=1,jo.data=No,jo.merge=function(t,e){let n=+e.length,i=t.length;for(let r=0;r<n;r++)t[i++]=e[r];return t.length=i,t},jo.parseHTML=function(t){const e=Io.implementation.createHTMLDocument(),n=e.createElement("base");n.href=Io.location.href,e.head.appendChild(n),e.body.innerHTML=t;const i=e.getElementsByTagName("script");for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(jo.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),jo.fn.toArray=function(){return Array.from(this)},jo.fn.pushStack=function(t){const e=jo.merge(this.constructor(),t);return e.prevObject=this,e},jo.fn.find=function(t){const[e]=this,n=this.pushStack([]);if(!e)return n;const{nodeType:i}=e;return 1!==i&&9!==i&&11!==i||("string"!=typeof t?e!==t&&e.contains(t)&&jo.merge(n,[t]):jo.merge(n,e.querySelectorAll(t))),n},jo.fn.add=function(t,e){const n=jo(t,e).toArray(),i=this.toArray(),r=this.pushStack([]);return jo.merge(r,lo(i.concat(n))),r},jo.fn.addBack=function(){return this.add(this.prevObject)},jo.fn.filter=function(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];i.matches(t)&&e.push(i)}return this.pushStack(e)};const $o=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Uo=function(t){if(!t)return this;if("function"==typeof t)throw new Error("function not supported");if(arguments.length>1)throw new Error("selector with context not supported");if(t.nodeType)return this[0]=t,this.length=1,this;let e;if("<"===(n=t+"")[0]&&">"===n[n.length-1]&&n.length>=3)e=[null,t,null];else{if("string"!=typeof t)return jo.merge(this,t);e=$o.exec(t)}var n;if(!e||!e[1])return Go.find(t);if(e[1])return jo.merge(this,jo.parseHTML(e[1])),this;const i=Io.getElementById(e[2]);return i&&(this[0]=i,this.length=1),this};jo.Dom=Uo,Uo.prototype=jo.fn,jo.Event=Ro,jo.event={special:Object.create(null)},jo.event.has=function(t,e){const n=Oo.get(t,"events");return!!n&&(!e||Array.isArray(n[e])&&n[e].length>0)},jo.event.on=function(t,e,n,i,r,o){if("object"==typeof e){"string"!=typeof n&&(i=i||n,n=void 0);for(let r in e)jo.event.on(t,r,n,i,e[r],o);return t}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!r)return t;if(1===o){const t=r;r=function(e){return jo().off(e),t.apply(this,arguments)},r.guid=t.guid||(t.guid=jo.guid++)}for(let o=0;o<t.length;o++)jo.event.add(t[o],e,r,i,n)},jo.event.add=function(t,e,n,i,r){if("object"!=typeof t)return;const o=Oo.create(t);let s,a,l;n.handler&&(s=n,n=s.handler,r=s.selector),r&&Do.matches(r),n.guid||(n.guid=jo.guid++),(a=o.events)||(a=o.events=Object.create(null)),(l=o.handle)||(l=o.handle=function(e){return void 0!==jo?jo.event.dispatch.apply(t,arguments):void 0});const c=(e||"").match(zo)||[""];let u=c.length;for(;u--;){const[,e,o=""]=Vo.exec(c[u]);if(!e)continue;const h=o.split(".").sort();let d=jo.event.special[e];const f=d&&(r?d.delegateType:d.bindType)||e;d=jo.event.special[f];const p=Object.assign({type:f,origType:e,data:i,handler:n,guid:n.guid,selector:r,namespace:h.join(".")},s);let g;(g=a[f])||(g=a[f]=[],g.delegateCount=0,d&&d.setup&&!1!==d.setup.call(t,i,h,l)||t.addEventListener&&t.addEventListener(f,l)),d&&d.add&&(d.add.call(t,p),p.handler.guid||(p.handler.guid=n.guid)),r?g.splice(g.delegateCount++,0,p):g.push(p)}},jo.event.remove=function(t,e,n,i,r){const o=Oo.get(t);if(!o||!o.events)return;const s=o.events,a=(e||"").match(zo)||[""];let l=a.length;for(;l--;){const[,e,c=""]=Vo.exec(a[l]);if(!e){for(const e in s)jo.event.remove(t,e+a[l],n,i,!0);continue}const u=jo.event.special[e],h=u&&(i?u.delegateType:u.bindType)||e,d=s[h];if(!d||0===d.length)continue;const f=c.split(".").sort(),p=c?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,g=d.length;let m=g;for(;m--;){const o=d[m];!r&&e!==o.origType||n&&n.guid!==o.guid||p&&!p.test(o.namespace)||i&&i!==o.selector&&("**"!==i||!o.selector)||(d.splice(m,1),o.selector&&d.delegateCount--,u&&u.remove&&u.remove.call(t,o))}g&&0===d.length&&(u&&u.teardown&&!1!==u.teardown.call(t,f,o.handle)||t.removeEventListener&&t.removeEventListener(h,o.handle),delete s[h])}ho(s)&&(Oo.remove(t,"handle"),Oo.remove(t,"events"))},jo.event.dispatch=function(t){const e=this,n=jo.event.fix(t);n.delegateTarget=e;const i=Array.from(arguments);i[0]=n;const r=Oo.get(e,"events"),o=r&&r[n.type]||[],s=jo.event.special[n.type];if(s&&s.preDispatch&&!1===s.preDispatch.call(e,n))return;const a=jo.event.handlers.call(e,n,o);let l,c=0;for(;(l=a[c++])&&!n.isPropagationStopped();){n.currentTarget=l.elem;let t,e=0;for(;(t=l.handlers[e++])&&!n.isImmediatePropagationStopped();){n.handleObj=t,n.data=t.data;const e=jo.event.special[t.origType];let r;r=e&&e.handle?e.handle:t.handler;const o=r.apply(l.elem,i);void 0!==o&&!1===(n.result=o)&&(n.preventDefault(),n.stopPropagation())}}return s&&s.postDispatch&&s.postDispatch.call(e,n),n.result},jo.event.handlers=function(t,e){const n=e.delegateCount,i=[];if(n&&!("click"===t.type&&t.button>=1))for(let r=t.target;r!==this;r=r.parentNode||this)if(1===r.nodeType&&("click"!==t.type||!0!==r.disabled)){const t=[],o={};for(let i=0;i<n;i++){const n=e[i],s=n.selector+" ";void 0===o[s]&&(o[s]=r.matches(s)),o[s]&&t.push(n)}t.length&&i.push({elem:r,handlers:t})}return n<e.length&&i.push({elem:this,handlers:e.slice(n)}),i},jo.event.fix=function(t){return t.envelope?t:new Ro(t)};const Go=jo(Io);function qo(t){let e=t.length;for(;e--;)Ho(t[e])}function Ho(t){jo.event.remove(t),Oo.remove(t),No.remove(t)}function Wo(t){for(let e=0;e<t.length;e++){const n=t[e];n.parentNode&&n.parentNode.removeChild(n)}}function Yo(){for(let t=0;t<this.length;t++){const e=this[t];Ho(e),qo(e.getElementsByTagName("*"))}return Wo(this),this}function Xo(){return Wo(this),this}function Zo(){for(let t=0;t<this.length;t++){const e=this[t];1===e.nodeType&&(qo(e.getElementsByTagName("*")),e.textContent="")}return this}function Ko(){const t=[];for(let e=0;e<this.length;e++)t.push(this[e].cloneNode(!0));return this.pushStack(t)}function Jo(t){const[e]=this;return e?0===arguments.length?e.innerHTML:void 0===t?this:(qo(Oo,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t?(e.innerHTML="",this.append(t)):(e.innerHTML=t,this)):null}function Qo(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.append(...jo.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))})),this):this}function ts(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.prepend(...jo.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))})),this):this}function es(t){return jo(t).append(this),this}function ns(t){return jo(t).prepend(this),this}const is={};function rs(t,e,n){"number"==typeof n&&is[_o(e)]&&(n+="px"),t.style[e]=n}function os(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.style[t]:null}n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let t in n)if(n.hasOwnProperty(t))for(let e=0;e<this.length;e++)rs(this[e],t,n[t]);return this}function ss(t,e){if(arguments.length<2){const[e]=this;return e?void 0===t?e.dataset:e.dataset[t]:null}for(let n=0;n<this.length;n++)this[n].dataset[t]=e;return this}function as(t,e,n){for(let i=0;i<e.length;i++){const r=e[i];xn.prototype[t].apply({node:r},n)}}function ls(){return as("removeClass",this,arguments),this}function cs(){return as("addClass",this,arguments),this}function us(){return as("toggleClass",this,arguments),this}function hs(){const[t]=this;return!!t&&xn.prototype.hasClass.apply({node:t},arguments)}function ds(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];let r=Array.from(i.children);"string"==typeof t&&(r=r.filter((e=>e.matches(t)))),e.push(...r)}return this.pushStack(e)}function fs(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];if("string"==typeof t){const n=i.closest(t);n&&e.push(n)}else{const[n]=jo(t);n&&n.contains(i)&&e.push(n)}}return this.pushStack(e)}function ps(t,e,n,i){return jo.event.on(this,t,e,n,i),this}function gs(t,e,n,i){return jo.event.on(this,t,e,n,i,1),this}function ms(t,e,n){if(t&&t.preventDefault&&t.handleObj){const e=t.handleObj;return jo(t.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this}if("object"==typeof t){for(let n in t)this.off(n,e,t[n]);return this}!1!==e&&"function"!=typeof e||(n=e,e=void 0);for(let i=0;i<this.length;i++)jo.event.remove(this[i],t,n,e);return this}function vs(){const[t]=this;if(t===window)return t.document.documentElement.clientWidth;if(!t)return;const e=window.getComputedStyle(t),n=t.offsetWidth,i=parseFloat(e.borderTopWidth);return n-parseFloat(e.borderBottomWidth)-i-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)}function ys(){const[t]=this;if(t===window)return t.document.documentElement.clientHeight;if(!t)return;const e=window.getComputedStyle(t);return t.offsetHeight-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}function bs(){const[t]=this;if(!t)return;let e,n,i,r=jo(t),o={top:0,left:0};if("fixed"===r.css("position"))n=t.getBoundingClientRect();else{n=r.offset(),i=t.ownerDocument,e=t.offsetParent||i.documentElement;const s=jo(e),a=s.css("position")||"static";for(;e&&(e===i.body||e===i.documentElement)&&"static"===a;)e=e.parentNode;if(e&&e!==t&&1===e.nodeType){const t=window.getComputedStyle(e),n=parseFloat(t.borderTopWidth)||0,i=parseFloat(t.borderLeftWidth)||0;o=s.offset(),o.top+=n,o.left+=i}}const s=parseFloat(window.getComputedStyle(t).marginTop)||0,a=parseFloat(window.getComputedStyle(t).marginLeft)||0;return{top:n.top-o.top-s,left:n.left-o.left-a}}function ws(t){const[e]=this;if(void 0===t){if(!e)return null;if(!e.getClientRects().length)return{top:0,left:0};const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}if(!e)return this;const n=window.getComputedStyle(e);"static"===n.position&&this.css("position","relative");const i=this.offset(),r=t.top-i.top,o=t.left-i.left;return this.css({top:(parseFloat(n.top)||0)+r+"px",left:(parseFloat(n.left)||0)+o+"px"}),this}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach((t=>{is[t]=!0}));const xs="animationFrameId",As={};function Es(t,e={}){this.stop();for(let n=0;n<this.length;n++)Ts(this[n],t,e);return this}function Ts(t,e,n={}){let{duration:i=400,easing:r="ease-in-out",delay:o=0,complete:s}=n;const a=setTimeout((function(){const n=jo(t);let a=!1,l="transitionend";i/=1e3,o/=1e3;const c={};if("string"==typeof e)c["animation-name"]=e,c["animation-duration"]=i+"s",c["animation-delay"]=o+"s",c["animation-timing-function"]=r,l="animationend";else{const t=[];for(var u in e)e.hasOwnProperty(u)&&(c[u]=e[u],t.push(u));i>0&&(c["transition-property"]=t.join(", "),c["transition-duration"]=i+"s",c["transition-delay"]=o+"s",c["transition-timing-function"]=r)}const h=function(e){if(e){if(e.target!==e.currentTarget)return;e.target.removeEventListener(l,h)}else t.removeEventListener(l,h);a=!0,n.css(As),s&&s.call(t)};if(i>0){t.addEventListener(l,h);const e=setTimeout((function(){a||h(null)}),1e3*(i+o)+25);Oo.set(t,xs,{id:e,stop:()=>{clearTimeout(e),t.removeEventListener(l,h)}})}n.css(c),i<=0&&h(null)}));Oo.set(t,xs,{stop:()=>clearTimeout(a)})}function Ss(){for(let t=0;t<this.length;t++){const e=this[t],n=Oo.get(e,xs);n&&(n.stop(),Oo.remove(e,xs))}return this.css(As),this}As["transition-property"]=As["transition-duration"]=As["transition-delay"]=As["transition-timing-function"]=As["animation-name"]=As["animation-duration"]=As["animation-delay"]=As["animation-timing-function"]="";const Ps={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},_s={disabled:"disabled",value:"value",text:"textContent"},ks={prop:function(t,e){if(!t)throw new Error("no property provided");if(1===arguments.length){const[e]=this;return e?e[t]:null}if(void 0===e)return this;for(let n=0;n<this.length;n++)this[n][t]=e;return this},attr:function(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.getAttribute(t):null}n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(let t in n)if(n.hasOwnProperty(t)){const e=n[t];if(_s[t]){this.prop(_s[t],e);continue}for(let n=0;n<this.length;n++)null===e?this[n].removeAttribute(t):this[n].setAttribute(t,e)}return this}};Object.keys(Ps).forEach((t=>{ks[t]=function(...e){return this.prop(Ps[t],...e)}}));const Cs=ks,Ls="joint-",Ms=Object.create(null),Os=Ms;Ms.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach((([t,e])=>{Ms[t]={delegateType:e,bindType:e,handle:function(t){const n=t.relatedTarget,i=t.handleObj;let r;return n&&this.contains(n)||(t.type=i.origType,r=i.handler.apply(this,arguments),t.type=e),r}}}));Ms.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t,...e){const{handleObj:n,target:i}=t,r=jo.data.create(i),o=(new Date).getTime(),s="lastTouch"in r?o-r.lastTouch:0;s<300&&s>30?(r.lastTouch=null,t.type=n.origType,n.handler.call(this,t,...e)):r.lastTouch=o}},Object.assign(jo.fn,r),Object.assign(jo.fn,o),Object.assign(jo.fn,Cs),Object.assign(jo.event.special,Os);const Ns=jo,Rs=function(t){return t?t.toString().split(" ").map((function(t){return t.substr(0,6)!==Ls&&(t=Ls+t),t})).join(" "):t},Fs=function(t,e){const n={},i={},r=xn.namespace.svg,o=e||r,s=document.createDocumentFragment(),a=function(t,e,o){for(let s=0;s<t.length;s++){const l=t[s];if("string"==typeof l){const t=document.createTextNode(l);e.appendChild(t);continue}if(!l.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");const c=l.tagName;let u;l.hasOwnProperty("namespaceURI")&&(o=l.namespaceURI),u=document.createElementNS(o,c);const h=o===r,d=h?xn(u):Ns(u),f=l.attributes;f&&d.attr(f);const p=l.style;if(p&&Ns(u).css(p),l.hasOwnProperty("className")){const t=l.className;h?u.className.baseVal=t:u.className=t}if(l.hasOwnProperty("textContent")&&(u.textContent=l.textContent),l.hasOwnProperty("selector")){const t=l.selector;if(n[t])throw new Error("json-dom-parser: selector must be unique");n[t]=u,d.attr("joint-selector",t)}if(l.hasOwnProperty("groupSelector")){let t=l.groupSelector;Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;e++){const n=t[e];let r=i[n];r||(r=i[n]=[]),r.push(u)}}e.appendChild(u);const g=l.children;Array.isArray(g)&&a(g,u,o)}};return a(t,s,o),{fragment:s,selectors:n,groupSelectors:i}},Bs=function(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e},Is=function(t,e,n){for(var i,r=Array.isArray(e)?e:e.split(n||"/"),o=0,s=r.length;o<s;){if(i=r[o++],Object(t)!==t||!(i in t))return;t=t[i]}return t},Ds=function(t,e){return"string"!=typeof e&&"number"!=typeof e&&(e=String(e)),("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!==e},Vs=function(t,e,n,i){const r=Array.isArray(e)?e:e.split(i||"/"),o=r.length-1;let s=t,a=0;for(;a<o;a++){const e=r[a];if(!Ds(s,e))return t;s=s[e]||(s[e]={})}return s[r[o]]=n,t},zs=function(t,e,n){const i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){const e=i[s];if(!Ds(o,e))return t;const n=o[e];if(!n)return t;o=n}return delete o[i[r]],t},js=function(t){return js.id=js.id||1,void 0===t?"j_"+js.id++:(t.id=void 0===t.id?"j_"+js.id++:t.id,t.id)},$s=function(t){if(t.normalized)return t;const{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(let e in i)void 0===t[e]&&(t[e]=i[e]);if(n){const e=n.correspondingUseElement;e&&(t.target=e)}return t.normalized=!0,t},Us=function(){var t;if("undefined"!=typeof window&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!t){var e=0;t=function(t){var n=(new Date).getTime(),i=Math.max(0,16-(n-e)),r=setTimeout((function(){t(n+i)}),i);return e=n+i,r}}return function(e,n,...i){return t(void 0!==n?e.bind(n,...i):e)}}(),Gs=((Hs="undefined"!=typeof window)&&(qs=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),qs=qs||clearTimeout,Hs?qs.bind(window):qs);var qs,Hs;const Ws=function(t){return eo(t)&&"%"===t.slice(-1)},Ys=function(t,e){var n=parseFloat(t);if(Number.isNaN(n))return null;var i,r={};if(r.value=n,null==e)i="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;i=e.join("|")}else eo(e)&&(i=e);var o=function(e){var n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+e+")$").exec(t);return n?n[1]:null}(i);return null===o?null:(r.unit=o,r)};function Xs(t,e){const n=t.split(e);let i=1;for(let t=0,r=n.length-1;t<r;t++){const o=[];(t>0||""!==n[0])&&o.push(0),o.push(e),(t<r-1||""!==n[r])&&o.push(0),n.splice(i,0,...o),i+=o.length+1}return n.filter((t=>""!==t))}function Zs(t,e){if(null===t)return e.getBBox().height;switch(t.unit){case"em":return e.getBBox().height*t.value;case"px":case"":return t.value}}const Ks=function(t,e,n={},i={}){var r=e.width,o=e.height,s=i.svgDocument||xn("svg").node,a=xn("tspan").node,l=xn("text").attr(n).append(a).node,c=document.createTextNode("");l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(c),s.appendChild(l),i.svgDocument||document.body.appendChild(s);const u=i.preserveSpaces,h=i.separator||""===i.separator?i.separator:" ",d="string"==typeof h?h:" ";var f=i.eol||"\n",p=i.hyphen?new RegExp(i.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=i.maxLineCount;to(g)||(g=1/0);var m,v,y,b=t.split(h),w=[],x=[];u&&xn(a).attr("xml:space","preserve");for(var A=0,E=0,T=b.length;A<T;A++){var S=b[A];if((S||u)&&"string"==typeof S){var P=!1;if(f&&S.indexOf(f)>=0){if(S.length>1){const t=Xs(b[A],f);b.splice(A,1,...t),A--,T=b.length;continue}if(u&&"string"==typeof b[A-1]){b.splice(A,0,"",0),T+=2,A--;continue}x[++E]=u&&"string"!=typeof b[A+1]?void 0:"",P=!0}if(!P){let t;if(t=u?void 0!==x[E]?x[E]+d+S:S:x[E]?x[E]+d+S:S,c.data=t,a.getComputedTextLength()<=r)x[E]=t,(m||v)&&(w[E++]=!0,m=0,v=0);else{if(!x[E]||m){var _=!!m;if(m=S.length-1,_||!m){if(!m){if(!x[E]){x=[];break}b.splice(A,2,S+b[A+1]),T--,w[E++]=!0,A--;continue}b[A]=S.substring(0,m);const t=b[A+1];b[A+1]=S.substring(m)+(void 0===t||0===t?"":t)}else{if(v)b.splice(A,2,b[A]+b[A+1]),v=0;else{var k=S.search(p);k>-1&&k!==S.length-1&&0!==k&&(v=k+1,m=0),b.splice(A,1,S.substring(0,v||m),S.substring(v||m)),T++}E&&!w[E-1]&&E--}u&&""===x[E]||A--;continue}E++,A--}}var C=null;if(x.length>g?C=g-1:void 0!==o&&(void 0===y&&""!==c.data&&(y="auto"===n.lineHeight?Zs({value:1.5,unit:"em"},l):Zs(Ys(n.lineHeight,["em","px",""]),l)),y*x.length>o&&(C=Math.floor(o/y)-1)),null!==C){x.splice(C+1);var L=i.ellipsis;if(!L||C<0)break;"string"!=typeof L&&(L="…");var M=x[C];if(!M&&!P)break;var O,N,R=M.length;do{if(N=M[R],O=M.substring(0,R),N?N.match(h)&&(O+=N):O+=d,O+=L,c.data=O,a.getComputedTextLength()<=r){x[C]=O;break}R--}while(R>=0);break}}}return i.svgDocument?s.removeChild(l):document.body.removeChild(s),x.join(f)},Js=function(t){if(Object(t)!==t){var e=0;return isFinite(t)&&(e=+t),{top:e,right:e,bottom:e,left:e}}var n,i,r,o;return n=i=r=o=0,isFinite(t.vertical)&&(n=r=+t.vertical),isFinite(t.horizontal)&&(i=o=+t.horizontal),isFinite(t.top)&&(n=+t.top),isFinite(t.right)&&(i=+t.right),isFinite(t.bottom)&&(r=+t.bottom),isFinite(t.left)&&(o=+t.left),{top:n,right:i,bottom:r,left:o}},Qs={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11){var i=(11-6*e-11*t)/4;return-i*i+n*n}},reverse:function(t){return function(e){return 1-t(1-e)}},reflect:function(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}},clamp:function(t,e,n){return e=e||0,n=n||1,function(i){var r=t(i);return r<e?e:r>n?n:r}},back:function(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}},elastic:function(t){return t||(t=1.5),function(e){return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*t/3*e)}}},ta={number:function(t,e){var n=e-t;return function(e){return t+n*e}},object:function(t,e){var n=Object.keys(t);return function(i){var r,o,s={};for(r=n.length-1;-1!=r;r--)s[o=n[r]]=t[o]+(e[o]-t[o])*i;return s}},hexColor:function(t,e){var n=parseInt(t.slice(1),16),i=parseInt(e.slice(1),16),r=255&n,o=(255&i)-r,s=65280&n,a=(65280&i)-s,l=16711680&n,c=(16711680&i)-l;return function(t){return"#"+(1<<24|r+o*t&255|s+a*t&65280|l+c*t&16711680).toString(16).slice(1)}},unit:function(t,e){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(t),r=n.exec(e),o=r[1].indexOf("."),s=o>0?r[1].length-o-1:0;t=+i[1];var a=+r[1]-t,l=i[2];return function(e){return(t+a*e).toFixed(s)+l}}},ea={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return na('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology in="SourceAlpha" result="morphedOuter" operator="dilate" radius="${outerRadius}" /><feMorphology in="SourceAlpha" result="morphedInner" operator="dilate" radius="${innerRadius}" /><feComposite result="morphedOuterColored" in="colored" in2="morphedOuter" operator="in"/><feComposite operator="xor" in="morphedOuterColored" in2="morphedInner" result="outline"/><feMerge><feMergeNode in="outline"/><feMergeNode in="SourceGraphic"/></feMerge></filter>')({color:t.color||"blue",opacity:Number.isFinite(t.opacity)?t.opacity:1,outerRadius:e+n,innerRadius:e})},highlight:function(t){return na('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology result="morphed" in="SourceGraphic" operator="dilate" radius="${width}"/><feComposite result="composed" in="colored" in2="morphed" operator="in"/><feGaussianBlur result="blured" in="composed" stdDeviation="${blur}"/><feBlend in="SourceGraphic" in2="blured" mode="normal"/></filter>')({color:t.color||"red",width:Number.isFinite(t.width)?t.width:1,blur:Number.isFinite(t.blur)?t.blur:0,opacity:Number.isFinite(t.opacity)?t.opacity:1})},blur:function(t){var e=Number.isFinite(t.x)?t.x:2;return na('<filter><feGaussianBlur stdDeviation="${stdDeviation}"/></filter>')({stdDeviation:Number.isFinite(t.y)?[e,t.y]:e})},dropShadow:function(t){var e="SVGFEDropShadowElement"in window?'<filter><feDropShadow stdDeviation="${blur}" dx="${dx}" dy="${dy}" flood-color="${color}" flood-opacity="${opacity}"/></filter>':'<filter><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${dx}" dy="${dy}" result="offsetblur"/><feFlood flood-color="${color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="${opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge></filter>';return na(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return na('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},sepia:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return na('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},saturate:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return na('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-e})},hueRotate:function(t){return na('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return na('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:1-e})},brightness:function(t){return na('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return na('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:.5-e/2})}},na=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(n){return n=n||{},t.replace(e,(function(t){for(var e=Array.from(arguments).slice(1,4).find((function(t){return!!t})).split("."),i=n[e.shift()];void 0!==i&&e.length;)i=i[e.shift()];return void 0!==i?i:""}))}};var ia,ra={},oa=/\s+/,sa=function(t,e,n,i,r){var o,s=0;if(n&&"object"==typeof n){void 0!==i&&"context"in r&&void 0===r.context&&(r.context=i);for(o=Object.keys(n);s<o.length;s++)e=sa(t,e,o[s],n[o[s]],r)}else if(n&&oa.test(n))for(o=n.split(oa);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e};ra.on=function(t,e,n){return this._events=sa(aa,this._events||{},t,e,{context:n,ctx:this,listening:ia}),ia&&((this._listeners||(this._listeners={}))[ia.id]=ia,ia.interop=!1),this},ra.listenTo=function(t,e,n){if(!t)return this;var i=t._listenId||(t._listenId=Co("l")),r=this._listeningTo||(this._listeningTo={}),o=ia=r[i];o||(this._listenId||(this._listenId=Co("l")),o=ia=r[i]=new pa(this,t));var s=la(t,e,n,this);if(ia=void 0,s)throw s;return o.interop&&o.on(e,n),this};var aa=function(t,e,n,i){if(n){var r=t[e]||(t[e]=[]),o=i.context,s=i.ctx,a=i.listening;a&&a.count++,r.push({callback:n,context:o,ctx:o||s,listening:a})}return t},la=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}};ra.off=function(t,e,n){return this._events?(this._events=sa(ca,this._events,t,e,{context:n,listeners:this._listeners}),this):this},ra.stopListening=function(t,e,n){var i=this._listeningTo;if(!i)return this;for(var r=t?[t._listenId]:Object.keys(i),o=0;o<r.length;o++){var s=i[r[o]];if(!s)break;s.obj.off(e,n,this),s.interop&&s.off(e,n)}return ho(i)&&(this._listeningTo=void 0),this};var ca=function(t,e,n,i){if(t){var r,o=i.context,s=i.listeners,a=0;if(e||o||n){for(r=e?[e]:Object.keys(t);a<r.length;a++){var l=t[e=r[a]];if(!l)break;for(var c=[],u=0;u<l.length;u++){var h=l[u];if(n&&n!==h.callback&&n!==h.callback._callback||o&&o!==h.context)c.push(h);else{var d=h.listening;d&&d.off(e,n)}}c.length?t[e]=c:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}};ra.once=function(t,e,n){var i=sa(ua,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(i,e,n)},ra.listenToOnce=function(t,e,n){var i=sa(ua,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,i)};var ua=function(t,e,n,i){if(n){var r=t[e]=ha((function(){i(e,r),n.apply(this,arguments)}));r._callback=n}return t},ha=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}};ra.trigger=function(t){if(!this._events)return this;for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];return sa(da,this._events,t,void 0,n),this};var da=function(t,e,n,i){if(t){var r=t[e],o=t.all;r&&o&&(o=o.slice()),r&&fa(r,i),o&&fa(o,[e].concat(i))}return t},fa=function(t,e){var n,i=-1,r=t.length,o=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++i<r;)(n=t[i]).callback.call(n.ctx);return;case 1:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o);return;case 2:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s);return;case 3:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s,a);return;default:for(;++i<r;)(n=t[i]).callback.apply(n.ctx,e);return}},pa=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};pa.prototype.on=ra.on,pa.prototype.off=function(t,e){var n;this.interop?(this._events=sa(ca,this._events,t,e,{context:void 0,listeners:void 0}),n=!this._events):(this.count--,n=0===this.count),n&&this.cleanup()},pa.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},ra.bind=ra.on,ra.unbind=ra.off;var ga=function(t,e){var n,i=this;return n=t&&Ao(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)},no(n,i,e),n.prototype=Object.assign(Object.create(i.prototype),t),n.prototype.constructor=n,n.__super__=i.prototype,n},ma=function(t,e){return po(t)?t:Qr(t)&&!e._isModel(t)?va(t):eo(t)?function(e){return e.get(t)}:t},va=function(t){var e=Ir(vr(t,!0));return function(t){return e(t.attributes)}},ya=function(t,e){var n=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=Co(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection);var i=Eo(this,"defaults");n=io(no({},i,n),i),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};function ba(t){t=lo(t);const e=mo(t).reduce((function(t,e){return t[e.id]=e.clone(),t}),{});return mo(t).forEach((function(t){const n=e[t.id];if(n.isLink()){const t=n.source(),i=n.target();t.id&&e[t.id]&&n.prop("source/id",e[t.id].id),i.id&&e[i.id]&&n.prop("target/id",e[i.id].id)}const i=t.get("parent");i&&e[i]&&n.set("parent",e[i].id);const r=mo(t.get("embeds")).reduce((function(t,n){return e[n]&&t.push(e[n].id),t}),[]);ho(r)||n.set("embeds",r)})),e}no(ya.prototype,ra,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return co(this.attributes)},get:function(t){return this.attributes[t]},has:function(t){return null!=this.get(t)},set:function(t,e,n){if(null==t)return this;var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;var r=n.unset,o=n.silent,s=[],a=this._changing;this._changing=!0,a||(this._previousAttributes=co(this.attributes),this.changed={});var l=this.attributes,c=this.changed,u=this._previousAttributes;for(var h in i)e=i[h],fo(l[h],e)||s.push(h),fo(u[h],e)?delete c[h]:c[h]=e,r?delete l[h]:l[h]=e;if(this.idAttribute in i){var d=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,d,n)}if(!o){s.length&&(this._pending=n);for(var f=0;f<s.length;f++)this.trigger("change:"+s[f],this,l[s[f]],n)}if(a)return this;if(!o)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,no({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,no({},t,{unset:!0}))},hasChanged:function(t){return null==t?!ho(this.changed):Ao(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&co(this.changed);var e,n=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var o=t[r];fo(n[r],o)||(i[r]=o,e=!0)}return!!e&&i},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return co(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},no({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=no({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return!n||(this.trigger("invalid",this,n,no(e,{validationError:n})),!1)}}),ya.extend=ga;const wa=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce(((t,e)=>(t[e]=!0,t)),{}),xa={qualify:function(t){return go(t)},set:function(t,e,n){Object.keys(t).forEach((function(e){if(wa[e]&&e in n){const i=t[e];"SELECT"===n.tagName&&Array.isArray(i)?Array.from(n.options).forEach((function(t,e){t.selected=i.includes(t.value)})):n[e]=i}}))}};function Aa(t,e,n){return function(i,r){var o,s=Ws(i);if(i=parseFloat(i),s&&(i/=100),isFinite(i)){var a=r[n]();o=s||i>0&&i<1?a[t]+r[e]*i:a[t]+i}var l=Kt();return l[t]=o||0,l}}function Ea(t,e){return function(n,i){var r=Ws(n);n=parseFloat(n),r&&(n/=100);var o={};if(isFinite(n)){var s=r||n>=0&&n<=1?n*i[e]:Math.max(n+i[e],0);o[t]=s}return o}}const Ta={"ref-x":{position:Aa("x","width","origin")},"ref-y":{position:Aa("y","height","origin")},"ref-dx":{position:Aa("x","width","corner")},"ref-dy":{position:Aa("y","height","corner")},"ref-width":{set:Ea("width","width")},"ref-height":{set:Ea("height","height")},"ref-rx":{set:Ea("rx","width")},"ref-ry":{set:Ea("ry","height")},"ref-cx":{set:Ea("cx","width")},"ref-cy":{set:Ea("cy","height")},"ref-r-inscribed":{set:(Sa=Ea("r","width"),Pa=Ea("r","height"),function(t,e){return(e.height>e.width?Sa:Pa)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n=Ws(t);t=parseFloat(t),n&&(t/=100);var i,r=Math.sqrt(e.height*e.height+e.width*e.width);return isFinite(t)&&(i=n||t>=0&&t<=1?t*r:Math.max(t+r,0)),{r:i}}}};var Sa,Pa;Ta.refX=Ta["ref-x"],Ta.refY=Ta["ref-y"],Ta["ref-x2"]=Ta["ref-x"],Ta["ref-y2"]=Ta["ref-y"],Ta["ref-width2"]=Ta["ref-width"],Ta["ref-height2"]=Ta["ref-height"],Ta["ref-r"]=Ta["ref-r-inscribed"];const _a=Ta,ka={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},Ca=Object.keys(ka).map((t=>ka[t])).join(""),La="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",Ma=/\s/g,Oa=new RegExp(`^(${La}\\*)?([${Ca}])(/${La})?([-+]{1,2}${La})?$`,"g");function Na(t){throw new Error(`Invalid calc() expression: ${t}`)}function Ra(t,e){const n=Oa.exec(t.replace(Ma,""));n||Na(t),Oa.lastIndex=0;const[,i,r,o,s]=n,{x:a,y:l,width:c,height:u}=e;let h=0;switch(r){case ka.width:h=c;break;case ka.height:h=u;break;case ka.x:h=a;break;case ka.y:h=l;break;case ka.minimum:h=Math.min(u,c);break;case ka.maximum:h=Math.max(u,c);break;case ka.diagonal:h=Math.sqrt(u*u+c*c)}return i&&(h*=parseFloat(i)),o&&(h/=parseFloat(o.slice(1))),s&&(h+=function(t){if(!t)return 0;const[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(s)),h}function Fa(t){return"string"==typeof t&&t.includes("calc")}const Ba="calc(",Ia=Ba.length;function Da(t,e){let n=t,i=0;for(;;){let t=n.indexOf(Ba,i);if(-1===t)return n;let r=t+Ia,o=1;t:for(;;){switch(n[r]){case"(":o++;break;case")":if(o--,0===o)break t;break;case void 0:Na(n)}r++}let s=n.slice(t+Ia,r);Fa(s)&&(s=Da(s,e));const a=String(Ra(s,e));n=n.slice(0,t)+a+n.slice(r+1),i=t+a.length}}function Va(t,e,n){return void 0!==n.text}const za={"line-height":{qualify:Va},"text-vertical-anchor":{qualify:Va},"text-path":{qualify:Va},annotations:{qualify:Va},eol:{qualify:Va},"display-empty":{qualify:Va},text:{qualify:function(t,e,n){const i=n["text-wrap"];return!i||!go(i)},set:function(t,e,n,i){const r="joint-text",o=Ns.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],c=i["font-size"],u=i.annotations,h=i.eol,d=i.x;let f=i["text-path"];const p=JSON.stringify([t,s,u,a,h,l,f,d,c]);if(void 0===o||o!==p){if(c&&n.setAttribute("font-size",c),Qr(f)){const t=f.selector;if("string"==typeof t){const e=this.findNode(t);e instanceof SVGPathElement&&(f=no({"xlink:href":"#"+e.id},f))}}xn(n).text(""+t,{lineHeight:s,annotations:u,textPath:f,x:d,textVerticalAnchor:a,eol:h,displayEmpty:l}),Ns.data.set(n,r,p)}}},"text-wrap":{qualify:go,set:function(t,e,n,i){var r={},o=t.width||0;Ws(o)?r.width=e.width*parseFloat(o)/100:Fa(o)?r.width=Number(Da(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o;var s,a=t.height||0;Ws(a)?r.height=e.height*parseFloat(a)/100:Fa(a)?r.height=Number(Da(a,e)):null===t.height||(r.height=a<=0?e.height+a:a);var l=t.text;void 0===l&&(l=i.text),s=void 0!==l?(t.breakText||Ks)(""+l,r,{"font-weight":i["font-weight"],"font-size":i["font-size"],"font-family":i["font-family"],lineHeight:i["line-height"],"letter-spacing":i["letter-spacing"]},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces}):"",za.text.set.call(this,s,e,n,i)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,n){var i="joint-title",r=Ns.data.get(n,i);if(void 0===r||r!==t){if(Ns.data.set(n,i,t),"title"===n.tagName)return void(n.textContent=t);var o=n.firstElementChild;if(o&&"title"===o.tagName)o.textContent=t;else{var s=document.createElementNS(n.namespaceURI,"title");s.textContent=t,n.insertBefore(s,o)}}}}},ja=za;function $a(t,e){var n=new Kt(1,0);return function(i){var r,o,s=this[t](i);return s?(o=e.rotate?s.vector().vectorAngle(n):0,r=s.start):(r=this.path.start,o=0),0===o?{transform:"translate("+r.x+","+r.y+")"}:{transform:"translate("+r.x+","+r.y+") rotate("+o+")"}}}function Ua(){return this.model.isLink()}const Ga={connection:{qualify:Ua,set:function({stubs:t=0}){let e;if(isFinite(t)&&0!==t){let n;n=t<0?(this.getConnectionLength()+t)/2:t;const i=this.getConnection(),r=this.getConnectionSubdivisions(),o=i.divideAtLength(n,{segmentSubdivisions:r}),s=i.divideAtLength(-n,{segmentSubdivisions:r});o&&s&&(e=`${o[0].serialize()} ${s[1].serialize()}`)}return{d:e||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:Ua,set:$a("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:Ua,set:$a("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:Ua,set:$a("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:Ua,set:$a("getTangentAtRatio",{rotate:!1})}};Ga["at-connection-length"]=Ga["at-connection-length-keep-gradient"],Ga["at-connection-ratio"]=Ga["at-connection-ratio-keep-gradient"];const qa=Ga;function Ha(t,e){var n="joint-shape",i=e&&e.resetOffset;return function(e,r,o){var s=Ns.data.get(o,n);if(!s||s.value!==e){var a=t(e);s={value:e,shape:a,shapeBBox:a.bbox()},Ns.data.set(o,n,s)}var l=s.shape.clone(),c=s.shapeBBox.clone(),u=c.origin(),h=r.origin();c.x=h.x,c.y=h.y;var d=r.maxRectScaleToFit(c,h),f=0===c.width||0===r.width?1:d.sx,p=0===c.height||0===r.height?1:d.sy;return l.scale(f,p,u),i&&l.translate(-u.x,-u.y),l}}function Wa(t){var e=Ha((function(t){return new ke(xn.normalizePathData(t))}),t);return function(t,n,i){return{d:e(t,n,i).serialize()}}}function Ya(t){var e=Ha(we,t);return function(t,n,i){return{points:e(t,n,i).serialize()}}}const Xa={"ref-d-reset-offset":{set:Wa({resetOffset:!0})},"ref-d-keep-offset":{set:Wa({resetOffset:!1})},"ref-points-reset-offset":{set:Ya({resetOffset:!0})},"ref-points-keep-offset":{set:Ya({resetOffset:!1})}};Xa["ref-d"]=Xa["ref-d-reset-offset"],Xa["ref-points"]=Xa["ref-points-reset-offset"];const Za=Xa;function Ka(t){var e={},n=t.stroke;"string"==typeof n&&(e.stroke=n,e.fill=n);var i=t["stroke-opacity"];return void 0===i&&(i=t.opacity),void 0!==i&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Ja(t){const{paper:e}=this;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}const Qa={"source-marker":{qualify:go,set:function(t,e,n,i){return t=no(Ka(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:go,set:function(t,e,n,i){return t=no(Ka(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:go,set:function(t,e,n,i){return t=no(Ka(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:go,set:Ja},stroke:{qualify:go,set:Ja},filter:{qualify:go,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function tl(t,e,n){return function(i,r){var o;o="middle"===i?r[e]/2:i===n?r[e]:isFinite(i)?i>-1&&i<1?-r[e]*i:-i:Ws(i)?r[e]*parseFloat(i)/100:0;var s=new Kt;return s[t]=-(r[t]+o),s}}const el={"x-alignment":{offset:tl("x","width","right")},"y-alignment":{offset:tl("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function nl(t){return function(e,n,i){const r=xn(i);r.attr(t)!==e&&r.attr(t,e)}}const il={ref:{},href:{set:nl("href")},"xlink:href":{set:nl("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:go,set:function(t,e,n){Ns(n).css(t)}},html:{set:function(t,e,n){Ns(n).html(t+"")}},props:xa};no(il,_a),no(il,ja),no(il,qa),no(il,Za),no(il,Qa),no(il,el);const rl=il,ol=function(t,e){if(Array.isArray(t))return e},sl=ya.extend({constructor:function(t,e){var n,i=t||{};if("function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=Co("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(i=this.parse(i,e)||{}),n=Eo(this,"defaults")){const t=(!e||!0!==e.mergeArrays)&&ol;i=Lo({},n,i,t)}this.set(i,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(){const t=Eo(this.constructor.prototype,"defaults").attrs||{},e=this.attributes.attrs,n={};Po(e,(function(e,i){const r=t[i];Po(e,(function(t,e){Qr(t)&&!Array.isArray(t)?Po(t,(function(t,o){r&&r[e]&&fo(r[e][o],t)||(n[i]=n[i]||{},(n[i][e]||(n[i][e]={}))[o]=t)})):r&&fo(r[e],t)||(n[i]=n[i]||{},n[i][e]=t)}))}));const i=uo(To(this.attributes,"attrs"));return i.attrs=n,i},initialize:function(t){const e=this.getIdAttribute();t&&void 0!==t[e]||this.set(e,this.generateId(),{silent:!0}),this._transitionIds={},this._scheduledTransitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},getIdAttribute:function(){return this.idAttribute||"id"},generateId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},processPorts:function(){var t=this.ports,e={};Po(this.get("attrs"),(function(t,n){t&&t.port&&(void 0!==t.port.id?e[t.port.id]=t.port:e[t.port]={id:t.port})}));var n={};Po(t,(function(t,i){e[i]||(n[i]=!0)})),this.graph&&!ho(n)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach((function(t){n[t.get("target").port]&&t.remove()})),this.graph.getConnectedLinks(this,{outbound:!0}).forEach((function(t){n[t.get("source").port]&&t.remove()}))),this.ports=e},remove:function(t={}){const{graph:e,collection:n}=this;if(!e)return n&&n.remove(this,t),this;e.startBatch("remove");const i=this.getParentCell();i&&i.unembed(this,t);const r=this.getEmbeddedCells();for(let e=0,n=r.length;e<n;e++){const n=r[e];n&&n.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(t){var e=this.graph;if(e){let n;(t=io(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:vo(n,(t=>t.z()));let r=e.maxZIndex()-n.length+1;const o=e.get("cells");let s=o.toArray().indexOf(i[0])!==o.length-n.length;s||(s=i.some((function(t,e){return t.z()!==r+e}))),s&&(this.startBatch("to-front"),r+=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-front"))}return this},toBack:function(t){var e=this.graph;if(e){let n;(t=io(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:vo(n,(t=>t.z()));let r=e.minZIndex(),o=0!==e.get("cells").toArray().indexOf(i[0]);o||(o=i.some((function(t,e){return t.z()!==r+e}))),o&&(this.startBatch("to-back"),r-=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-back"))}return this},parent:function(t,e){return void 0===t?this.get("parent"):this.set("parent",t,e)},embed:function(t,e){const n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(n.some((t=>t.isEmbedded()&&this.id!==t.parent())))throw new Error("Embedding of already embedded cells is not allowed.");return this._embedCells(n,e),this},unembed:function(t,e){const n=Array.isArray(t)?t:[t];return this._unembedCells(n,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every((t=>this!==t&&!this.isEmbeddedIn(t)))},_embedCells:function(t,e){const n="embed";this.startBatch(n);const i=no([],this.get("embeds"));t.forEach((t=>{i[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)})),this.set("embeds",lo(i),e),this.stopBatch(n)},_unembedCells:function(t,e){const n="unembed";this.startBatch(n),t.forEach((t=>t.unset("parent",e))),this.set("embeds",bo(this.get("embeds"),...t.map((t=>t.id))),e),this.stopBatch(n)},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(!this.graph)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(t=t||{},!this.graph)return[];if(t.deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);const e=this.get("embeds");if(ho(e))return[];let n=e.map(this.graph.getCell,this.graph);return t.sortSiblings&&(n=vo(n,(t=>t.z()))),n},_getEmbeddedCellsBfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.shift();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});n.push(...r)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.pop();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});for(let t=r.length-1;t>=0;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=eo(t)?t:t.id,i=this.parent();if(e=no({deep:!0},e),this.graph&&e.deep){for(;i;){if(i===n)return!0;i=this.graph.getCell(i).parent()}return!1}return i===n},isEmbedded:function(){return!!this.parent()},clone:function(t){if((t=t||{}).deep)return mo(ba([this].concat(this.getEmbeddedCells({deep:!0}))));var e=ya.prototype.clone.apply(this,arguments);return e.set(this.getIdAttribute(),this.generateId()),e.unset("embeds"),e.unset("parent"),e},prop:function(t,e,n){var i=eo(t);if(i||Array.isArray(t)){if(arguments.length>1){var r,o;i?o=(r=t).split("/"):(r=t.join("/"),o=t.slice());var s=o[0],a=o.length;const m=n||{};m.propertyPath=r,m.propertyValue=e,m.propertyPathArray=o,"rewrite"in m||(m.rewrite=!1);for(var l={},c=l,u=s,h=1;h<a;h++){var d=o[h],f=Number.isFinite(i?Number(d):d);c=c[u]=f?[]:{},u=d}l=Vs(l,o,e,"/");var p=Lo({},this.attributes);m.rewrite&&zs(p,r,"/");var g=Lo(p,l);return this.set(s,g[s],m)}return Is(this.attributes,t,"/")}const m=e||{};m.propertyPath=null,m.propertyValue=t,m.propertyPathArray=[],"rewrite"in m||(m.rewrite=!1);const v={};for(const e in t){const{changedValue:n}=Lo({},{changedValue:this.attributes[e]},{changedValue:t[e]});v[e]=n}return this.set(v,m)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];if("attrs"===i&&(e.dirty=!0),1===n.length)return this.unset(t,e);var r=n.slice(1),o=this.get(i);return null==o?this:(o=uo(o),zs(o,r,"/"),this.set(i,o,e))},attr:function(t,e,n){var i=Array.from(arguments);return 0===i.length?this.get("attrs"):(Array.isArray(t)?i[0]=["attrs"].concat(t):eo(t)?i[0]="attrs/"+t:i[0]={attrs:t},this.prop.apply(this,i))},removeAttr:function(t,e){return Array.isArray(t)?this.removeProp(["attrs"].concat(t)):this.removeProp("attrs/"+t,e)},transition:function(t,e,n,i){i=i||"/",n=no({duration:100,delay:10,timingFunction:Qs.linear,valueFunction:ta.number},n);var r,o=0,s=function(e){var i,a,l;(a=(e-=o=o||e)/n.duration)<1?this._transitionIds[t]=i=Us(s):(a=1,delete this._transitionIds[t]),l=r(n.timingFunction(a)),n.transitionId=i,this.prop(t,l,n),i||this.trigger("transition:end",this,t)}.bind(this);const{_scheduledTransitionIds:a}=this;let l;return l=setTimeout((o=>{a[t]&&(a[t]=bo(a[t],l),0===a[t].length&&delete a[t]),this.stopPendingTransitions(t,i),r=n.valueFunction(Is(this.attributes,t,i),e),this._transitionIds[t]=Us(o),this.trigger("transition:start",this,t)}),n.delay,s),a[t]||(a[t]=[]),a[t].push(l),l},getTransitions:function(){return xo(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e="/"){const{_scheduledTransitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>fo(n,t.split(e).slice(0,n.length))))}return i.forEach((t=>{n[t].forEach((t=>clearTimeout(t))),delete n[t]})),this},stopPendingTransitions(t,e="/"){const{_transitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>fo(n,t.split(e).slice(0,n.length))))}i.forEach((t=>{const e=n[t];Gs(e),delete n[t],this.trigger("transition:end",this,t)}))},stopTransitions:function(t,e="/"){return this.stopScheduledTransitions(t,e),this.stopPendingTransitions(t,e),this},addTo:function(t,e){return t.addCell(this,e),this},findView:function(t){return t.findViewByModel(this)},isElement:function(){return!1},isLink:function(){return!1},startBatch:function(t,e){return this.graph&&this.graph.startBatch(t,no({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,no({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new Kt(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new Kt},getBBox:function(){return new ge(0,0,0,0)},getPointRotatedAroundCenter(t,e,n){const i=new Kt(e,n);return t&&i.rotate(this.getBBox().center(),t),i},getAbsolutePointFromRelative(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,n=rl;return e&&e[t]||n[t]},define:function(t,e,n,i){n=no({defaults:ro({type:t},e,this.prototype.defaults)},n);var r=this.extend(n,i);return"undefined"!=typeof joint&&Ao(joint,"shapes")&&Vs(joint.shapes,t,r,"."),r}});function al(t,e,n){var i=t.toJSON();return i.angle=e||0,io({},n,i)}function ll(t,e,n,i){return t.map((function(t,e,n){var r=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&r.offset(t.dx||0,t.dy||0),al(r.round(),0,ul(i,t))}),ne(e,n))}function cl(t,e,n,i){var r=e.center(),o=e.width/e.height,s=e.topMiddle(),a=se.fromRect(e);return t.map((function(t,l,c){var u=n+i(l,c.length),h=s.clone().rotate(r,-u).scale(o,1,r),d=t.compensateRotation?-a.tangentTheta(h):0;return(t.dx||t.dy)&&h.offset(t.dx||0,t.dy||0),t.dr&&h.move(r,t.dr),al(h.round(),d,ul(e,t))}))}function ul(t,e){let{x:n,y:i,angle:r}=e;return Ws(n)?n=parseFloat(n)/100*t.width:Fa(n)&&(n=Number(Da(n,t))),Ws(i)?i=parseFloat(i)/100*t.height:Fa(i)&&(i=Number(Da(i,t))),{x:n,y:i,angle:r}}function hl(t,e){const{x:n,y:i}=ul(t,e);return new Kt(n||0,i||0)}const dl=function(t,e){return t.map((t=>{const n=hl(e,t).round().toJSON();return n.angle=t.angle||0,n}))},fl=function(t,e,n){return n.fn(t,e,n)},pl=function(t,e,n){return ll(t,hl(e,n.start||e.origin()),hl(e,n.end||e.corner()),e)},gl=function(t,e,n){return ll(t,e.origin(),e.bottomLeft(),e)},ml=function(t,e,n){return ll(t,e.topRight(),e.corner(),e)},vl=function(t,e,n){return ll(t,e.origin(),e.topRight(),e)},yl=function(t,e,n){return ll(t,e.bottomLeft(),e.corner(),e)},bl=function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return cl(t,e,i,(function(t){return t*r}))},wl=function(t,e,n){var i=n.startAngle||0,r=n.step||20;return cl(t,e,i,(function(t,e){return(t+.5-e/2)*r}))};function xl(t,e){return ro({},t,e,{x:0,y:0,angle:0,attrs:{}})}function Al(t){var e=t.center(),n=e.theta(t.origin()),i=e.theta(t.bottomLeft()),r=e.theta(t.corner());return[n,e.theta(t.topRight()),r,i]}function El(t,e,n,i){i=io({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,u=0;const[h,d,f,p]=Al(e);l<d||l>f?(s=".3em",r=c,o=0,a="start"):l<h?(r=0,o=-c,n?(u=-90,a="start",s=".3em"):(a="middle",s="0")):l<p?(s=".3em",r=-c,o=0,a="end"):(r=0,o=c,n?(u=90,a="start",s=".3em"):(a="middle",s=".6em"));var g=Math.round;return xl(i,{x:g(r),y:g(o),angle:u,attrs:{labelText:{y:s,textAnchor:a}}})}function Tl(t,e,n,i){i=io({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,u=0;const[h,d,f,p]=Al(e);l<d||l>f?(s=".3em",r=-c,o=0,a="end"):l<h?(r=0,o=c,n?(u=90,a="start",s=".3em"):(a="middle",s=".6em")):l<p?(s=".3em",r=c,o=0,a="start"):(r=0,o=-c,n?(u=-90,a="start",s=".3em"):(a="middle",s="0"));var g=Math.round;return xl(i,{x:g(r),y:g(o),angle:u,attrs:{labelText:{y:s,textAnchor:a}}})}function Sl(t,e,n){n=io({},n,{offset:20});var i,r=Jt(0,0),o=-t.theta(r),s=o,a=t.clone().move(r,n.offset).difference(t).round(),l=".3em";(o+90)%180==0?(i=e?"end":"middle",e||-270!==o||(l="0em")):o>-270&&o<-90?(i="start",s=o-180):i="end";var c=Math.round;return xl(n,{x:c(a.x),y:c(a.y),angle:e?s:0,attrs:{labelText:{y:l,textAnchor:i}}})}const Pl=function(t,e,n){return xl(n)},_l=function(t,e,n){return xl(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},kl=function(t,e,n){return xl(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},Cl=function(t,e,n){return xl(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},Ll=function(t,e,n){return xl(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},Ml=function(t,e,n){return El(t,e,!0,n)},Ol=function(t,e,n){return El(t,e,!1,n)},Nl=function(t,e,n){return Tl(t,e,!0,n)},Rl=function(t,e,n){return Tl(t,e,!1,n)},Fl=function(t,e,n){return Sl(t.difference(e.center()),!1,n)},Bl=function(t,e,n){return Sl(t.difference(e.center()),!0,n)};var Il=function(t){var e=uo(t)||{};this.ports=[],this.groups={},this.portLayoutNamespace=s,this.portLabelLayoutNamespace=a,this._init(e)};Il.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(t){return this.ports.filter((function(e){return e.group===t}))},getGroupPortsMetrics:function(t,e){var n=this.getGroup(t),i=this.getPortsByGroup(t),r=n.position||{},o=r.name,s=this.portLayoutNamespace;s[o]||(o="left");var a=r.args||{},l=i.map((function(t){return t&&t.position&&t.position.args})),c=s[o](l,e,a),u={ports:i,result:[]};return mo(c).reduce(function(t,n,i){var r=t.ports[i];return t.result.push({portId:r.id,portTransformation:n,labelTransformation:this._getPortLabelLayout(r,Kt(n),e),portAttrs:r.attrs,portSize:r.size,labelSize:r.label.size}),t}.bind(this),u),u.result},_getPortLabelLayout:function(t,e,n){var i=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return i[r]?i[r](e,n,t.label.position.args):null},_init:function(t){if(Qr(t.groups))for(var e=Object.keys(t.groups),n=0,i=e.length;n<i;n++){var r=e[n];this.groups[r]=this._evaluateGroup(t.groups[r])}for(var o=mo(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return Lo(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=no({},t),n=this.getGroup(t.group);return e.markup=e.markup||n.markup,e.attrs=Lo({},n.attrs,e.attrs),e.position=this._createPositionNode(n,e),e.label=Lo({},n.label,this._getLabel(e)),e.z=this._getZIndex(n,e),e.size=no({},n.size,e.size),e},_getZIndex:function(t,e){return to(e.z)?e.z:to(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return Lo({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={};po(t)?(n="fn",i.fn=t):eo(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):Qr(t)&&(n=t.name,no(i,t.args));var r={args:i};return n&&(r.name=n),r},_getLabel:function(t,e){var n=t.label||{},i=n;return i.position=this._getPosition(n.position,e),i}};const Dl={_initializePorts:function(){this._createPortData(),this.on("change:ports",(function(){this._processRemovedPort(),this._createPortData()}),this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={};mo(t.items).forEach((function(t){e[t.id]=!0}));var n=this.previous("ports")||{},i={};mo(n.items).forEach((function(t){e[t.id]||(i[t.id]=!0)}));var r=this.graph;r&&!ho(i)&&(r.getConnectedLinks(this,{inbound:!0}).forEach((function(t){i[t.get("target").port]&&t.remove()})),r.getConnectedLinks(this,{outbound:!0}).forEach((function(t){i[t.get("source").port]&&t.remove()})))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&t.length>0},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return uo(this.prop("ports/items"))||[]},getGroupPorts:function(t){const e=mo(this.prop(["ports","items"])).filter((e=>e.group===t));return uo(e)},getPort:function(t){return uo(mo(this.prop("ports/items")).find((function(e){return e.id&&e.id===t})))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,ge(this.size())).reduce((function(t,e){var n=e.portTransformation;return t[e.portId]={x:n.x,y:n.y,angle:n.angle},t}),{})},getPortIndex:function(t){var e=Qr(t)?t.id:t;return this._isValidPortId(e)?mo(this.prop("ports/items")).findIndex((function(t){return t.id===e})):-1},addPort:function(t,e){if(!Qr(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=no([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){const i="number"==typeof t?t:this.getPortIndex(t);if(!Qr(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");const r=no([],this.prop("ports/items"));return r.splice(i,0,e),this.prop("ports/items",r,n),this},portProp:function(t,e,n,i){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);var o=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?o[0]=["ports","items",r].concat(e):eo(e)?o[0]=["ports/items/",r,"/",e].join(""):(o=["ports/items/"+r],go(e)&&(o.push(e),o.push(n))),this.prop.apply(this,o)},_validatePorts:function(){var t=this.get("ports")||{},e=[],n=mo((t=t||{}).items);return n.forEach((function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())}),this),lo(n,"id").length!==n.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!Qr(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",no([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){const n=e||{},i=this.getPortIndex(t);if(-1!==i){const t=no([],this.prop(["ports","items"]));t.splice(i,1),n.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],t,n),this.stopBatch("port-remove")}return this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;i=no([],this.prop(["ports","items"])).filter((function(e){return!t.some((function(t){const n=Qr(t)?t.id:t;return e.id===n}))}))}else n=t||{},i=[];return this.startBatch("port-remove"),n.rewrite=!0,this.prop(["ports","items"],i,n),this.stopBatch("port-remove"),this},_createPortData:function(){var t,e=this._validatePorts();if(e.length>0)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Il(this.get("ports"));var n=this._portSettingsData.getPorts();if(t){var i=n.filter((function(e){if(!t.find((function(t){return t.id===e.id})))return e})),r=t.filter((function(t){if(!n.find((function(e){return e.id===t.id})))return t}));r.length>0&&this.trigger("ports:remove",this,r),i.length>0&&this.trigger("ports:add",this,i)}}},Vl={portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._cleanPortsCache()},_refreshPorts:function(){this._removePorts(),this._cleanPortsCache(),this._renderPorts()},_cleanPortsCache:function(){this._portElementsCache={}},_renderPorts:function(){for(var t=[],e=this._getContainerElement(),n=0,i=e.node.childNodes.length;n<i;n++)t.push(e.node.childNodes[n]);var r,o,s=(r=this.model._portSettingsData.getPorts(),o=Vr(o="z",2),function(t,e,n){return(Array.isArray(t)?zr:jr)(t,e,n,arguments.length<3,Lr)}(r,((t,e,n)=>(n=o(e),hasOwnProperty.call(t,n)?t[n].push(e):ji(t,n,[e]),t)),{})),a="auto";mo(s[a]).forEach((function(n){var i=this._getPortElement(n);e.append(i),t.push(i)}),this);for(var l=Object.keys(s),c=0;c<l.length;c++){var u=l[c];if(u!==a){var h=parseInt(u,10);this._appendPorts(s[u],h,t)}}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),r=mo(t).map(this._getPortElement,this);n[e]||e<0?xn(n[Math.max(e,0)]).before(r):i.append(r)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){const n=this._portElementsCache[t];if(!n)return[];if(!e)return[n.portContentElement.node];const i=n.portElement.node,r=n.portSelectors;return this.findBySelector(e,i,r)},findPortNode:function(t,e){const[n=null]=this.findPortNodes(t,e);return n},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){oo(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r;var o=xn(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t);if(Array.isArray(s)){var a=this.parseDOMJSON(s,o.node),l=a.fragment;e=l.childNodes.length>1?xn("g").append(l):xn(l.firstChild),r=a.selectors}else e=xn(s),Array.isArray(e)&&(e=xn("g").append(e));if(!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group});const c=this._getPortLabelMarkup(t.label);if(Array.isArray(c)){const{fragment:t,selectors:e}=this.parseDOMJSON(c,o.node),r=t.childNodes.length;r>0&&(i=e,n=1===r?xn(t.firstChild):xn("g").append(t))}else n=xn(c),Array.isArray(n)&&(n=xn("g").append(n));var u;if(r&&i){for(var h in i)if(r[h]&&h!==this.selector)throw new Error("ElementView: selectors within port must be unique.");u=no({},r,i)}else u=r||i||{};const d="portRoot",f="labelRoot",p="labelText";if(d in u||(u[d]=e.node),n){const t=n.node;if(f in u||(u[f]=t),!(p in u)){const e="TEXT"===n.tagName()?t:Array.from(t.querySelectorAll("text"));u[p]=e,i||(i={}),i[p]=e}}return o.append(e.addClass("joint-port-body")),n&&o.append(n.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:n,portSelectors:u,portLabelSelectors:i,portContentElement:e,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=ge(this.model.size()),n=this.model._portSettingsData.getGroupPortsMetrics(t,e),i=0,r=n.length;i<r;i++){var o=n[i],s=o.portId,a=this._portElementsCache[s]||{},l=o.portTransformation,c=o.labelTransformation;c&&a.portLabelElement&&(this.updateDOMSubtreeAttributes(a.portLabelElement.node,c.attrs,{rootBBox:new ge(o.labelSize),selectors:a.portLabelSelectors}),this.applyPortTransform(a.portLabelElement,c,-l.angle||0)),this.updateDOMSubtreeAttributes(a.portElement.node,o.portAttrs,{rootBBox:new ge(o.portSize),selectors:a.portSelectors}),this.applyPortTransform(a.portElement,l)}},applyPortTransform:function(t,e,n){var i=xn.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},zl=sl.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),sl.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){const i=to(e);n=(i?n:t)||{};const{parentRelative:r,deep:o,restrictedArea:s}=n;let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");const t=this.getParentCell();t&&!t.isLink()&&(a=t.get("position"))}if(i){if(a&&(t+=a.x,e+=a.y),o||s){const{x:i,y:r}=this.get("position");this.translate(t-i,e-r,n)}else this.set("position",{x:t,y:e},n);return this}{const t=Kt(this.get("position"));return r?t.difference(a):t}},translate:function(t,e,n){if(e=e||0,0===(t=t||0)&&0===e)return this;(n=n||{}).translateBy=n.translateBy||this.id;var i=this.get("position")||{x:0,y:0},r=n.restrictedArea;if(r&&n.translateBy===this.id)if("function"==typeof r){var o=r.call(this,i.x+t,i.y+e,n);t=o.x-i.x,e=o.y-i.y}else{var s=this.getBBox({deep:!0}),a=i.x-s.x,l=i.y-s.y,c=Math.max(r.x+a,Math.min(r.x+r.width+a-s.width,i.x+t)),u=Math.max(r.y+l,Math.min(r.y+r.height+l-s.height,i.y+e));t=c-i.x,e=u-i.y}var h={x:i.x+t,y:i.y+e};return n.tx=t,n.ty=e,n.transition?(Qr(n.transition)||(n.transition={}),this.transition("position",h,no({},n.transition,{valueFunction:ta.object})),oo(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",h,n),oo(this.getEmbeddedCells(),"translate",t,e,n),this.stopBatch("translate",n)),this},size:function(t,e,n){var i=this.get("size");return void 0===t?{width:i.width,height:i.height}:(Qr(t)&&(n=e,e=to(t.height)?t.height:i.height,t=to(t.width)?t.width:i.width),this.resize(t,e,n))},resize:function(t,e,n){if(n=n||{},this.startBatch("resize",n),n.direction){var i=this.get("size");switch(n.direction){case"left":case"right":e=i.height;break;case"top":case"bottom":t=i.width}var r,o=Ct(this.get("angle")||0),s=this.getBBox();if(o){var a={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction];n.absolute&&(a+=Math.floor((o+45)/90),a%=4);var l=s[["bottomLeft","corner","topRight","origin"][a]](),c=Kt(l).rotate(s.center(),-o),u=Math.sqrt(t*t+e*e)/2,h=a*Math.PI/2;h+=Math.atan(a%2==0?e/t:t/e),h-=Ot(o);var d=Kt.fromPolar(u,h,c);r=Kt(d).offset(t/-2,e/-2)}else switch(r=s.topLeft(),n.direction){case"top":case"top-right":r.offset(0,s.height-e);break;case"left":case"bottom-left":r.offset(s.width-t,0);break;case"top-left":r.offset(s.width-t,s.height-e)}this.set("size",{width:t,height:e},n),this.position(r.x,r.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){var r=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(r.x,r.y,i),this.resize(r.width,r.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");const n=this.getEmbeddedCells().filter((t=>t.isElement()));return 0===n.length||(this.startBatch("fit-embeds",t),t.deep&&oo(n,"fitToChildren",t),this._fitToElements(Object.assign({elements:n},t)),this.stopBatch("fit-embeds")),this},fitParent:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");if(t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id))return this;const n=this.getParentCell();if(!n||!n.isElement())return this;const i=n.getEmbeddedCells().filter((t=>t.isElement()));return 0===i.length||(this.startBatch("fit-parent",t),n._fitToElements(Object.assign({elements:i},t)),t.deep&&n.fitParent(t),this.stopBatch("fit-parent")),this},_fitToElements:function(t={}){const e=this.graph.getCellsBBox(t.elements);if(!e)return;const{expandOnly:n,shrinkOnly:i}=t;if(n&&i)return;let{x:r,y:o,width:s,height:a}=e;const{left:l,right:c,top:u,bottom:h}=Js(t.padding);r-=l,o-=u,s+=l+c,a+=h+u;let d=new ge(r,o,s,a);if(n)d=this.getBBox().union(d);else if(i){const t=this.getBBox().intersect(d);if(!t)return;d=t}this.set({position:{x:d.x,y:d.y},size:{width:d.width,height:d.height}},t)},rotate:function(t,e,n,i){if(n){var r=this.getBBox().center(),o=this.get("size"),s=this.get("position");r.rotate(n,this.get("angle")-t);var a=r.x-o.width/2-s.x,l=r.y-o.height/2-s.y;this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(s.x+a,s.y+l,i),this.rotate(t,e,null,i),this.stopBatch("rotate")}else this.set("angle",e?t:(this.get("angle")+t)%360,i);return this},angle:function(){return Ct(this.get("angle")||0)},getBBox:function(t={}){const{graph:e,attributes:n}=this,{deep:i,rotate:r}=t;if(i&&e){const n=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return n.push(this),e.getCellsBBox(n,t)}const{angle:o=0,position:{x:s,y:a},size:{width:l,height:c}}=n,u=new ge(s,a,l,c);return r&&u.rotateAroundCenter(o),u},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),r=t.get(e);if(!r)return i;var o=r.port;if(!o||!this.hasPort(o))return i;var s=this.portProp(o,["group"]),a=this.getPortsPositions(s),l=new Kt(a[o]).offset(n.origin()),c=this.angle();return c&&l.rotate(i,-c),l}});no(zl.prototype,Dl);const jl=sl.extend({defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,x:"calc(x)",y:"calc(y)",width:"calc(w)",height:"calc(h)"}},position:{distance:.5}}},defaults:{source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,n){return void 0===t?co(this.get("source")):t instanceof sl?((i=co(e)||{}).id=t.id,r=n,this.set("source",i,r)):go(t)?(i=t,r=e,this.set("source",i,r)):((i=co(e)||{}).x=t.x,i.y=t.y,r=n,this.set("source",i,r));var i,r},target:function(t,e,n){return void 0===t?co(this.get("target")):t instanceof sl?((i=co(e)||{}).id=t.id,r=n,this.set("target",i,r)):go(t)?(i=t,r=e,this.set("target",i,r)):((i=co(e)||{}).x=t.x,i.y=t.y,r=n,this.set("target",i,r));var i,r},router:function(t,e,n){if(void 0===t){var i=this.get("router");return i?"object"==typeof i?co(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("router",o,s)},connector:function(t,e,n){if(void 0===t){var i=this.get("connector");return i?"object"==typeof i?co(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("connector",o,s)},label:function(t,e,n){var i=this.labels();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["labels",t]):this.prop(["labels",t],e,n)},labels:function(t,e){return 0===arguments.length?(t=this.get("labels"),Array.isArray(t)?t.slice():[]):(Array.isArray(t)||(t=[]),this.set("labels",t,e))},hasLabels:function(){const{labels:t}=this.attributes;return Array.isArray(t)&&t.length>0},insertLabel:function(t,e,n){if(!e)throw new Error("dia.Link: no label provided");var i=this.labels(),r=i.length;return(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),i.splice(t,0,e),this.labels(i,n)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var n=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.labels(n,e)},vertex:function(t,e,n){var i=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1)return this.prop(["vertices",t]);var r=this._normalizeVertex(e);return this.prop(["vertices",t],r,n)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var n=[],i=0;i<t.length;i++){var r=t[i],o=this._normalizeVertex(r);n.push(o)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){if(!e)throw new Error("dia.Link: no vertex provided");var i=this.vertices(),r=i.length;(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1);var o=this._normalizeVertex(e);return i.splice(t,0,o),this.vertices(i,n)},removeVertex:function(t,e){var n=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.vertices(n,e)},_normalizeVertex:function(t){return go(t)?t:{x:t.x,y:t.y}},translate:function(t,e,n){return(n=n||{}).translateBy=n.translateBy||this.id,n.tx=t,n.ty=e,this.applyToPoints((function(n){return{x:(n.x||0)+t,y:(n.y||0)+e}}),n)},scale:function(t,e,n,i){return this.applyToPoints((function(i){return Kt(i).scale(t,e,n).toJSON()}),i)},applyToPoints:function(t,e){if(!po(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var n={},{source:i,target:r}=this.attributes;i.id||(n.source=t(i)),r.id||(n.target=t(r));var o=this.vertices();return o.length>0&&(n.vertices=o.map(t)),this.set(n,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new Kt(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new Kt(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){const t=[this.getSourcePoint(),...this.vertices().map(Kt),this.getTargetPoint()];return new we(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e;if(this.graph){var n=this.getSourceElement(),i=this.getTargetElement(),r=this.getParentCell();n&&i&&(e=n===i||n.isEmbeddedIn(i)?i:i.isEmbeddedIn(n)?n:this.graph.getCommonAncestor(n,i)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)}return e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,i=e.id,r=n.id;if(!i||!r)return!1;var o=i===r;if(!o&&t.deep&&this.graph){var s=this.getSourceCell(),a=this.getTargetCell();o=s.isEmbeddedIn(a)||a.isEmbeddedIn(s)}return o},getSourceCell:function(){const{graph:t,attributes:e}=this;var n=e.source;return n&&n.id&&t&&t.getCell(n.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getSourceCell()}while(t&&t.isLink());return t},getTargetCell:function(){const{graph:t,attributes:e}=this;var n=e.target;return n&&n.id&&t&&t.getCell(n.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getTargetCell()}while(t&&t.isLink());return t},getRelationshipAncestor:function(){var t;if(this.graph){var e=[this,this.getSourceElement(),this.getTargetElement()].filter((function(t){return!!t}));t=this.graph.getCommonAncestor.apply(this.graph,e)}return t||null},isRelationshipEmbeddedIn:function(t){var e=eo(t)||to(t)?t:t.id,n=this.getRelationshipAncestor();return!!n&&(n.id===e||n.isEmbeddedIn(e))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var n=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&n}}),$l={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var n=this._results[t];if(void 0!==n)return n;try{n=e()}catch(t){n=!1}return this._results[t]=n,n}},Ul=zl.define("standard.Rectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),Gl=zl.define("standard.Circle",{attrs:{root:{cursor:"move"},body:{cx:"calc(s/2)",cy:"calc(s/2)",r:"calc(s/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),ql=zl.define("standard.Ellipse",{attrs:{root:{cursor:"move"},body:{cx:"calc(w/2)",cy:"calc(h/2)",rx:"calc(w/2)",ry:"calc(h/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),Hl=zl.define("standard.Path",{attrs:{root:{cursor:"move"},body:{d:"M 0 0 H calc(w) V calc(h) H 0 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),Wl=zl.define("standard.Polygon",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),Yl=zl.define("standard.Polyline",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),Xl=zl.define("standard.Image",{attrs:{root:{cursor:"move"},image:{width:"calc(w)",height:"calc(h)"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Zl=zl.define("standard.BorderedImage",{attrs:{root:{cursor:"move"},border:{width:"calc(w)",height:"calc(h)",stroke:"#333333",strokeWidth:2},background:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5,fill:"#FFFFFF"},image:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"background",attributes:{stroke:"none"}},{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Kl=zl.define("standard.EmbeddedImage",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{width:"calc(0.3*w)",height:"calc(h-20)",x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",x:"calc(0.3*w+20)",y:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Jl=zl.define("standard.InscribedImage",{attrs:{root:{cursor:"move"},border:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",stroke:"#333333",strokeWidth:2},background:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",fill:"#FFFFFF"},image:{width:"calc(0.68*w)",height:"calc(0.68*h)",x:"calc(0.16*w)",y:"calc(0.16*h)",preserveAspectRatio:"xMidYMid"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"background"},{tagName:"image",selector:"image"},{tagName:"ellipse",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Ql=zl.define("standard.HeaderedRectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{width:"calc(w)",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]}),tc=zl.define("standard.Cylinder",{attrs:{root:{cursor:"move"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{cx:"calc(w/2)",cy:10,rx:"calc(w/2)",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var n={lateralArea:t},i=Ws(t)?`calc(${parseFloat(t)/100}*h)`:t,r={cy:i,ry:i};return this.attr({body:n,top:r},e)}},{attributes:{"lateral-area":{set:function(t,e){var n=Ws(t);n&&(t=parseFloat(t)/100);var i=e.x,r=e.y,o=e.width,s=e.height,a=o/2,l=n?s*t:t,c=xn.KAPPA,u=c*a,h=c*(n?s*t:t),d=i+o/2,f=i+o,p=r+l,g=p-l,m=r+s-l,v=r+s;return{d:["M",i,p,"L",i,m,"C",i,m+h,d-u,v,d,v,"C",d+u,v,f,m+h,f,m,"L",f,p,"C",f,p-h,d+u,g,d,g,"C",d-u,g,i,p-h,i,p,"Z"].join(" ")}}}}});var ec=$l.test("svgforeignobject")?{tagName:"foreignObject",selector:"foreignObject",attributes:{overflow:"hidden"},children:[{tagName:"div",namespaceURI:"http://www.w3.org/1999/xhtml",selector:"label",style:{width:"100%",height:"100%",position:"static",backgroundColor:"transparent",textAlign:"center",margin:0,padding:"0px 5px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}]}:{tagName:"text",selector:"label",attributes:{"text-anchor":"middle"}};const nc=zl.define("standard.TextBlock",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#ffffff",strokeWidth:2},foreignObject:{width:"calc(w)",height:"calc(h)"},label:{style:{fontSize:14}}}},{markup:[{tagName:"rect",selector:"body"},ec]},{attributes:{text:{set:function(t,e,n,i){if(!(n instanceof HTMLElement)){var r=i.style||{},o={text:t,width:-5,height:"100%"},s=no({"text-vertical-anchor":"middle"},r);return rl["text-wrap"].set.call(this,o,e,n,s),{fill:r.color||null}}n.textContent=t},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),ic=jl.define("standard.Link",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 10 -5 0 0 10 5 z"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),rc=jl.define("standard.DoubleLink",{attrs:{line:{connection:!0,stroke:"#DDDDDD",strokeWidth:4,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"#000000",d:"M 10 -3 10 -10 -2 0 10 10 10 3"}},outline:{connection:!0,stroke:"#000000",strokeWidth:6,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"outline",attributes:{fill:"none",cursor:"pointer"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),oc=jl.define("standard.ShadowLink",{attrs:{line:{connection:!0,stroke:"#FF0000",strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"none",d:"M 0 -10 -10 0 0 10 z"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}},shadow:{connection:!0,transform:"translate(3,6)",stroke:"#000000",strokeOpacity:.2,strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 0 -10 -10 0 0 10 z",stroke:"none"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}}}},{markup:[{tagName:"path",selector:"shadow",attributes:{fill:"none","pointer-events":"none"}},{tagName:"path",selector:"line",attributes:{fill:"none",cursor:"pointer"}}]}),sc={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left",TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",CENTER:"center"};function ac(t,e){const n=new ge(t);switch(e){case void 0:throw new Error("Position required");case sc.LEFT:case"leftMiddle":return n.leftMiddle();case sc.RIGHT:case"rightMiddle":return n.rightMiddle();case sc.TOP:case"topMiddle":return n.topMiddle();case sc.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case sc.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case sc.TOP_RIGHT:case"topRight":return n.topRight();case sc.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case sc.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case sc.CENTER:return n.center();default:throw new Error(`Unknown position: ${e}`)}}var lc=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,no({silent:!0},e))},cc={add:!0,remove:!0,merge:!0},uc={add:!0,remove:!1},hc=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var i,r=Array(t.length-n),o=e.length;for(i=0;i<r.length;i++)r[i]=t[i+n];for(i=0;i<o;i++)t[i+n]=e[i];for(i=0;i<r.length;i++)t[i+o+n]=r[i]};no(lc.prototype,ra,{model:ya,preinitialize:function(){},initialize:function(){},toJSON:function(t){return this.map((function(e){return e.toJSON(t)}))},add:function(t,e){return this.set(t,no({merge:!1},e,uc))},remove:function(t,e){e=no({},e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=this._removeModels(t,e);return!e.silent&&i.length&&(e.changes={added:[],merged:[],removed:i},this.trigger("update",this,e)),n?i[0]:i},set:function(t,e){if(null!=t){e=no({},cc,e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=e.at;null!=i&&(i=+i),i>this.length&&(i=this.length),i<0&&(i+=this.length+1);var r,o,s=[],a=[],l=[],c=[],u={},h=e.add,d=e.merge,f=e.remove,p=!1,g=this.comparator&&null==i&&!1!==e.sort,m=eo(this.comparator)?this.comparator:null;for(o=0;o<t.length;o++){r=t[o];var v=this.get(r);if(v){if(d&&r!==v){var y=this._isModel(r)?r.attributes:r;v.set(y,e),l.push(v),g&&!p&&(p=v.hasChanged(m))}u[v.cid]||(u[v.cid]=!0,s.push(v)),t[o]=v}else h&&(r=t[o]=this._prepareModel(r,e))&&(a.push(r),this._addReference(r,e),u[r.cid]=!0,s.push(r))}if(f){for(o=0;o<this.length;o++)u[(r=this.models[o]).cid]||c.push(r);c.length&&this._removeModels(c,e)}var b=!1,w=!g&&h&&f;if(s.length&&w?(b=this.length!==s.length||this.models.some((function(t,e){return t!==s[e]})),this.models.length=0,hc(this.models,s,0),this.length=this.models.length):a.length&&(g&&(p=!0),hc(this.models,a,null==i?this.length:i),this.length=this.models.length),p&&this.sort({silent:!0}),!e.silent){for(o=0;o<a.length;o++)null!=i&&(e.index=i+o),(r=a[o]).trigger("add",r,this,e);(p||b)&&this.trigger("sort",this,e),(a.length||c.length||l.length)&&(e.changes={added:a,removed:c,merged:l},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?co(e):{};for(var n=0;n<this.models.length;n++)this._removeReference(this.models[n],e);return e.previousModels=this.models,this._reset(),t=this.add(t,no({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,no({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t)},unshift:function(t,e){return this.add(t,no({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t)},slice:function(){return Array.prototype.slice.apply(this.models,arguments)},get:function(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t,t.idAttribute)]||t.cid&&this._byId[t.cid]},has:function(t){return null!=this.get(t)},at:function(t){return t<0&&(t+=this.length),this.models[t]},sort:function(t){var e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t||(t={});var n=e.length;return po(e)&&(e=e.bind(this)),1===n||eo(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(t,e){return t[e||this.model.prototype.idAttribute||"id"]},values:function(){return new pc(this,gc)},keys:function(){return new pc(this,mc)},entries:function(){return new pc(this,vc)},each:function(t,e){this.models.forEach(t,e)},filter:function(t,e){return this.models.filter(t,e)},find:function(t,e){return this.models.find(t,e)},findIndex:function(t,e){return this.models.findIndex(t,e)},first:function(){return this.models[0]},includes:function(t){return this.models.includes(t)},last:function(){return this.models[this.models.length-1]},isEmpty:function(){return!this.models.length},map:function(t,e){return this.models.map(t,e)},reduce:function(t,e=this.first()){return this.models.reduce(t,e)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){return this._isModel(t)?(t.collection||(t.collection=this),t):((e=e?co(e):{}).collection=this,(n=this.model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,n.validationError,e),!1):n);var n},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r=this.get(t[i]);if(r){var o=this.models.indexOf(r);this.models.splice(o,1),this.length--,delete this._byId[r.cid];var s=this.modelId(r.attributes,r.idAttribute);null!=s&&delete this._byId[s],e.silent||(e.index=o,r.trigger("remove",r,this,e)),n.push(r),this._removeReference(r,e)}}return t.length>0&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof ya},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,i){if(e){if(("add"===t||"remove"===t)&&n!==this)return;if("changeId"===t){var r=this.modelId(e.previousAttributes(),e.idAttribute),o=this.modelId(e.attributes,e.idAttribute);null!=r&&delete this._byId[r],null!=o&&(this._byId[o]=e)}}this.trigger.apply(this,arguments)}});var dc="function"==typeof Symbol&&Symbol.iterator;dc&&(lc.prototype[dc]=lc.prototype.values);var fc,pc=function(t,e){this._collection=t,this._kind=e,this._index=0},gc=1,mc=2,vc=3;dc&&(pc.prototype[dc]=function(){return this}),pc.prototype.next=function(){if(this._collection){if(this._index<this._collection.length){var t,e=this._collection.at(this._index);if(this._index++,this._kind===gc)t=e;else{var n=this._collection.modelId(e.attributes,e.idAttribute);t=this._kind===mc?n:[n,e]}return{value:t,done:!1}}this._collection=void 0}return{value:void 0,done:!0}},function(t,e,n,i){Po(n,(function(n,r){e[r]&&(t.prototype[r]=function(t,e,n,i){switch(e){case 1:return function(){return t[n](this[i])};case 2:return function(e){return t[n](this[i],e)};case 3:return function(e,r){return t[n](this[i],ma(e,this),r)};case 4:return function(e,r,o){return t[n](this[i],ma(e,this),r,o)};default:return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(this[i]),t[n].apply(t,e)}}}(e,n,r,i))}))}((fc=[lc,{toArray:1,sortBy:3},"models"])[0],{sortBy:vo,toArray:mo},fc[1],fc[2]),lc.extend=ga;const yc={cells:function(t){return function(){var e=Array.from(arguments),n=e.length,i=n>0&&e[0]||[],r=n>1&&e[n-1]||{};return Array.isArray(i)||(r instanceof sl?i=e:i instanceof sl&&(e.length>1&&e.pop(),i=e)),r instanceof sl&&(r={}),t.call(this,i,r)}}},bc=lc.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&Ao(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){const n=e.collection,i=n.cellNamespace,{type:r}=t,o=Is(i,r,".");if(!o)throw new Error(`dia.Graph: Could not find cell constructor for type: '${r}'. Make sure to add the constructor to 'cellNamespace'.`);const s=new o(t,e);return e.dry||(s.graph=n.graph),s},comparator:function(t){return t.get("z")||0}}),wc=ya.extend({initialize:function(t,e){var n=new bc([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});ya.prototype.set.call(this,"cells",n),n.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},n.on("add",this._restructureOnAdd,this),n.on("remove",this._restructureOnRemove,this),n.on("reset",this._restructureOnReset,this),n.on("change:source",this._restructureOnChangeSource,this),n.on("change:target",this._restructureOnChangeTarget,this),n.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){if(t.isLink()){this._edges[t.id]=!0;var{source:e,target:n}=t.attributes;e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0),n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)}else this._nodes[t.id]=!0},_restructureOnRemove:function(t){if(t.isLink()){delete this._edges[t.id];var{source:e,target:n}=t.attributes;e.id&&this._out[e.id]&&this._out[e.id][t.id]&&delete this._out[e.id][t.id],n.id&&this._in[n.id]&&this._in[n.id][t.id]&&delete this._in[n.id][t.id]}else delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source");e.id&&this._out[e.id]&&delete this._out[e.id][t.id];var n=t.attributes.source;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target");e.id&&this._in[e.id]&&delete this._in[e.id][t.id];var n=t.get("target");n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=ya.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(!t.cells)throw new Error("Graph JSON must contain cells array.");return this.set(t,e)},set:function(t,e,n){var i;return"object"==typeof t?(i=t,n=e):(i={})[t]=e,i.hasOwnProperty("cells")&&(this.resetCells(i.cells,n),i=To(i,"cells")),ya.prototype.set.call(this,i,n)},clear:function(t){t=no({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);var n=e.sortBy((function(t){return t.isLink()?1:2}));do{n.shift().remove(t)}while(n.length>0);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var n;if(t instanceof ya?(n=t.attributes,t.graph||e&&e.dry||(t.graph=this)):n=t,!eo(n.type))throw new TypeError("dia.Graph: cell type must be a string.");return t},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof ya?t.has("z")||t.set("z",this.maxZIndex()+1):void 0===t.z&&(t.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(t,e),e||{}),this)},addCells:function(t,e){return 0===t.length||(t=yo(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach((function(t){this.addCell(t,e),e.position--}),this),this.stopBatch("add",e)),this},resetCells:function(t,e){var n=mo(t).map((function(t){return this._prepareCell(t,e)}),this);return this.get("cells").reset(n,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),oo(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,n){(n=n||{}).clear||(n.disconnectLinks?this.disconnectLinks(t,n):this.removeLinks(t,n)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").toArray().filter((t=>t.isElement()))},getLinks:function(){return this.get("cells").toArray().filter((t=>t.isLink()))},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,e){var n=(e=e||{}).indirect,i=e.inbound,r=e.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=[],s={};function a(t,e){if(Po(t.getOutboundEdges(e.id),function(e,c){if(!s[c]){var u=t.getCell(c);o.push(u),s[c]=!0,n&&(i&&l(t,u),r&&a(t,u))}}.bind(t)),n&&e.isLink()){var c=e.getTargetCell();c&&c.isLink()&&(s[c.id]||(o.push(c),a(t,c)))}}function l(t,e){if(Po(t.getInboundEdges(e.id),function(e,c){if(!s[c]){var u=t.getCell(c);o.push(u),s[c]=!0,n&&(i&&l(t,u),r&&a(t,u))}}.bind(t)),n&&e.isLink()){var c=e.getSourceCell();c&&c.isLink()&&(s[c.id]||(o.push(c),l(t,c)))}}if(r&&a(this,t),i&&l(this,t),e.deep){var c=t.getEmbeddedCells({deep:!0}),u={};c.forEach((function(t){t.isElement()&&(u[t.id]=!0)})),c.forEach((function(t){t.isLink()||(r&&Po(this.getOutboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&u[l]&&c&&u[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)),i&&Po(this.getInboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&u[l]&&c&&u[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)))}),this)}return o},getNeighbors:function(t,e){e||(e={});var n=e.inbound,i=e.outbound;void 0===n&&void 0===i&&(n=i=!0);var r=this.getConnectedLinks(t,e).reduce(function(r,o){var{source:s,target:a}=o.attributes,l=o.hasLoop(e);if(n&&Ao(s,"id")&&!r[s.id]){var c=this.getCell(s.id);c.isElement()&&(!l&&(!c||c===t||e.deep&&c.isEmbeddedIn(t))||(r[s.id]=c))}if(i&&Ao(a,"id")&&!r[a.id]){var u=this.getCell(a.id);u.isElement()&&(!l&&(!u||u===t||e.deep&&u.isEmbeddedIn(t))||(r[a.id]=u))}return r}.bind(this),{});if(t.isLink()){if(n){var o=t.getSourceCell();o&&o.isElement()&&!r[o.id]&&(r[o.id]=o)}if(i){var s=t.getTargetCell();s&&s.isElement()&&!r[s.id]&&(r[s.id]=s)}}return mo(r)},getCommonAncestor:function(){var t=Array.from(arguments).map((function(t){for(var e=[],n=t.get("parent");n;)e.push(n),n=this.getCell(n).get("parent");return e}),this);t=t.sort((function(t,e){return t.length-e.length}));var e=mo(t.shift()).find((function(e){return t.every((function(t){return t.includes(e)}))}));return this.getCell(e)},getSuccessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),no({},e,{outbound:!0})),n},cloneCells:ba,cloneSubgraph:function(t,e){var n=this.getSubgraph(t,e);return this.cloneCells(n)},getSubgraph:function(t,e){e=e||{};var n=[],i={},r=[],o=[];return mo(t).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t))}))})),o.forEach((function(t){var{source:e,target:o}=t.attributes;if(e.id&&!i[e.id]){var s=this.getCell(e.id);n.push(s),i[s.id]=s,r.push(s)}if(o.id&&!i[o.id]){var a=this.getCell(o.id);n.push(this.getCell(o.id)),i[a.id]=a,r.push(a)}}),this),r.forEach((function(t){this.getConnectedLinks(t,e).forEach((function(t){var{source:e,target:r}=t.attributes;!i[t.id]&&e.id&&i[e.id]&&r.id&&i[r.id]&&(n.push(t),i[t.id]=t)}))}),this),n},getPredecessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),no({},e,{inbound:!0})),n},search:function(t,e,n){(n=n||{}).breadthFirst?this.bfs(t,e,n):this.dfs(t,e,n)},bfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){var s=o.shift();if(i[s.id])continue;if(i[s.id]=!0,!1===e.call(this,s,r[s.id]))continue;const t=this.getNeighbors(s,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];r[n.id]=r[s.id]+1,o.push(n)}}},dfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){const t=o.pop();if(i[t.id])continue;if(i[t.id]=!0,!1===e.call(this,t,r[t.id]))continue;const s=this.getNeighbors(t,n),a=o.length;for(let e=0,n=s.length;e<n;e++){const n=s[e];r[n.id]=r[t.id]+1,o.splice(a,0,n)}}},getSources:function(){var t=[];return Po(this._nodes,function(e,n){this._in[n]&&!ho(this._in[n])||t.push(this.getCell(n))}.bind(this)),t},getSinks:function(){var t=[];return Po(this._nodes,function(e,n){this._out[n]&&!ho(this._out[n])||t.push(this.getCell(n))}.bind(this)),t},isSource:function(t){return!this._in[t.id]||ho(this._in[t.id])},isSink:function(t){return!this._out[t.id]||ho(this._out[t.id])},isSuccessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{outbound:!0}),n},isPredecessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{inbound:!0}),n},isNeighbor:function(t,e,n){var i=(n=n||{}).inbound,r=n.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=!1;return this.getConnectedLinks(t,n).forEach((function(t){var{source:n,target:s}=t.attributes;return i&&Ao(n,"id")&&n.id===e.id||r&&Ao(s,"id")&&s.id===e.id?(o=!0,!1):void 0})),o},disconnectLinks:function(t,e){this.getConnectedLinks(t).forEach((function(n){n.set(n.attributes.source.id===t.id?"source":"target",{x:0,y:0},e)}))},removeLinks:function(t,e){oo(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(t){return this.getElements().filter((e=>e.getBBox({rotate:!0}).containsPoint(t)))},findModelsInArea:function(t,e={}){const n=new ge(t),{strict:i=!1}=e,r=i?"containsRect":"intersect";return this.getElements().filter((t=>n[r](t.getBBox({rotate:!0}))))},findModelsUnderElement:function(t,e={}){const{searchBy:n="bbox"}=e,i=t.getBBox().rotateAroundCenter(t.angle());return("bbox"===n?this.findModelsInArea(i):this.findModelsFromPoint(ac(i,n))).filter((e=>t.id!==e.id&&!e.isEmbeddedIn(t)))},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e={}){const{rotate:n=!0}=e;return mo(t).reduce((function(t,e){const i=e.getBBox({rotate:n});return i?t?t.union(i):i:t}),null)},translate:function(t,e,n){var i=this.getCells().filter((function(t){return!t.isEmbedded()}));return oo(i,"translate",t,e,n),this},resize:function(t,e,n){return this.resizeCells(t,e,this.getCells(),n)},resizeCells:function(t,e,n,i){var r=this.getCellsBBox(n);if(r){var o=Math.max(t/r.width,0),s=Math.max(e/r.height,0);oo(n,"scale",o,s,r.origin(),i)}return this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",no({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",no({},e,{batchName:t}))},hasActiveBatch:function(t){const e=this._batches;let n;return n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t],n.some((t=>e[t]>0))}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){var r=e.getSourceCell();if(r&&t.getConnectedLinks(r,{outbound:!0}).filter((function(t){var{source:e,target:r}=t.attributes;return e&&e.id===n.id&&(!e.port||e.port===n.port)&&r&&r.id===i.id&&(!r.port||r.port===i.port)})).length>1)return!1}return!0},linkPinning:function(t,e){var{source:n,target:i}=e.attributes;return n.id&&i.id}}});!function(t,e,n){if(eo(n)){if(!yc[n])throw new Error('Unknown wrapper: "'+n+'"');n=yc[n]}if(!po(n))throw new Error("Wrapper must be a function.");mo(["resetCells","addCells","removeCells"]).forEach((function(e){t[e]=n(t[e])}))}(wc.prototype,0,yc.cells);var xc=function(t){this.cid=Co("view"),this.preinitialize.apply(this,arguments),no(this,So(t,Ec)),this._ensureElement(),this.initialize.apply(this,arguments)},Ac=/^(\S+)\s*(.*)$/,Ec=["model","collection","el","id","attributes","className","tagName","events"];no(xc.prototype,ra,{tagName:"div",$:function(t){return this.$el.find(t)},preinitialize:function(){},initialize:function(){},render:function(){return this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.$el.remove()},setElement:function(t){return this.undelegateEvents(),this._setElement(t),this.delegateEvents(),this},_setElement:function(t){this.$el=t instanceof Ns?t:Ns(t),this.el=this.$el[0]},delegateEvents:function(t){if(t||(t=Eo(this,"events")),!t)return this;for(var e in this.undelegateEvents(),t){var n=t[e];if(po(n)||(n=this[n]),n){var i=e.match(Ac);this.delegate(i[1],i[2],n.bind(this))}}return this},delegate:function(t,e,n){return this.$el.on(t+".delegateEvents"+this.cid,e,n),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,n){return this.$el.off(t+".delegateEvents"+this.cid,e,n),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){if(this.el)this.setElement(Eo(this,"el"));else{var t=no({},Eo(this,"attributes"));this.id&&(t.id=Eo(this,"id")),this.className&&(t.class=Eo(this,"className")),this.setElement(this._createElement(Eo(this,"tagName"))),this._setAttributes(t)}},_setAttributes:function(t){this.$el.attr(t)}}),xc.extend=ga;const Tc={},Sc=xc.extend({options:{},theme:null,themeClassNamePrefix:Rs("theme-"),requireSetThemeOverride:!1,defaultTheme:"default",children:null,childNodes:null,DETACHABLE:!0,UPDATE_PRIORITY:2,FLAG_INSERT:1<<30,FLAG_REMOVE:1<<29,FLAG_INIT:1<<28,constructor:function(t){this.requireSetThemeOverride=t&&!!t.theme,this.options=no({},this.options,t),xc.call(this,t)},initialize:function(){Tc[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){this.svgElement?this.vel.remove():this.$el.remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){if(t||(t=Eo(this,"children")),t){var e=this.svgElement,n=xn.namespace[e?"svg":"xhtml"],i=Fs(t,n);(e?this.vel:this.$el).empty().append(i.fragment),this.childNodes=i.selectors}return this},findAttribute:function(t,e){for(var n=e;n&&1===n.nodeType;){var i=n.getAttribute(t);if(i)return i;if(n===this.el)return null;n=n.parentNode}return null},_ensureElement:function(){if(this.el)this.setElement(Eo(this,"el"));else{var t=Eo(this,"tagName"),e=no({},Eo(this,"attributes")),n=no({},Eo(this,"style"));this.id&&(e.id=Eo(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)}this._ensureElClassName()},_setAttributes:function(t){this.svgElement?this.vel.attr(t):this.$el.attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(xn.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof Ns?t:Ns(t),this.el=this.$el[0],this.svgElement&&(this.vel=xn(this.el))},_ensureElClassName:function(){var t=Eo(this,"className");if(t){var e=Rs(t);this.svgElement?this.vel.removeClass(t).addClass(e):this.$el.removeClass(t).addClass(e)}},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.addClass(e):this.$el.addClass(e),this},removeThemeClassName:function(t){t=t||this.theme;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.removeClass(e):this.$el.removeClass(e),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),Tc[this.cid]=null,xc.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(!e)return this;n||(n={});var i=this.getEventNamespace();for(var r in e){var o=e[r];"function"!=typeof o&&(o=this[o]),o&&Ns(t).on(r+i,n,o.bind(this))}return this},undelegateElementEvents:function(t){return Ns(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t||(t=Eo(this,"documentEvents")),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var n=t.data,i="__"+this.cid+"__";return void 0===e?n&&n[i]||{}:(n||(n=t.data={}),n[i]||(n[i]={}),no(n[i],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&no({},t[0])||{},n=t[1]&&no({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,xc.extend.call(this,e,n)}});function Pc(t){return t?Array.isArray(t)?t:[t]:[]}const _c=Sc.extend({tagName:"g",svgElement:!0,className:"highlight",HIGHLIGHT_FLAG:1,UPDATE_PRIORITY:3,DETACHABLE:!1,UPDATABLE:!0,MOUNTABLE:!0,cellView:null,nodeSelector:null,node:null,updateRequested:!1,postponedUpdate:!1,transformGroup:null,detachedTransformGroup:null,requestUpdate(t,e){const{paper:n}=t;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;const{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform(),0):(this.postponedUpdate=!0,0)},findNode(t,e=null){let n;if("string"==typeof e)n=t.findNode(e);else if(go(e)){const i=t.model.isLink(),{label:r=null,port:o,selector:s}=e;n=i&&null!==r?t.findLabelNode(r,s):!i&&o?t.findPortNode(o,s):t.findNode(s)}else e&&(n=xn.toNode(e),n instanceof SVGElement||(n=null));return n||null},getNodeMatrix(t,e){const{options:n}=this,{layer:i}=n,{rotatableNode:r}=t,o=t.getNodeMatrix(e);return r?i?r.contains(e)?o:t.getRootRotateMatrix().inverse().multiply(o):t.getNodeRotateMatrix(e).multiply(o):o},mount(){const{MOUNTABLE:t,cellView:e,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(!t||r)return;if(s)return this.update(e,a),void this.transform();const{vel:l,paper:c}=e,{layer:u}=i;if(u){let t;o?(t=o,this.detachedTransformGroup=null):t=xn("g").addClass("highlight-transform").append(n),this.transformGroup=t,c.getLayerView(u).insertSortedNode(t.node,i.z)}else n.parentNode&&!n.nextSibling||l.append(n)},unmount(){const{MOUNTABLE:t,transformGroup:e,vel:n}=this;t&&(e?(this.transformGroup=null,this.detachedTransformGroup=e,e.remove()):n.remove())},transform(){const{transformGroup:t,cellView:e,updateRequested:n}=this;if(!t||e.model.isLink()||n)return;const i=e.getRootTranslateMatrix(),r=e.getRootRotateMatrix(),o=i.multiply(r);t.attr("transform",xn.matrixToTransformString(o))},update(){const{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;if(i)return;this.postponedUpdate=!1;const o=this.node=this.findNode(e,n);t&&this.unhighlight(e,t),o?(this.highlight(e,o),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this))},onRemove(){const{node:t,cellView:e,id:n,constructor:i}=this;t&&this.unhighlight(e,t),this.unmount(),i._removeRef(e,n)},highlight(t,e){},unhighlight(t,e){},listenToUpdateAttributes(t){const e=Eo(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){const{cellView:t}=this;if(!t)return;const{model:e,paper:n}=t;Eo(this,"UPDATE_ATTRIBUTES").some((t=>e.hasChanged(t)))&&n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}},{_views:{},highlight:function(t,e,n){const i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){const i=this.uniqueId(e,n);this.remove(t,i)},get(t,e=null){const{cid:n}=t,{_views:i}=this,r=i[n];if(null===e){const t=[];if(!r)return t;for(let e in r){const n=r[e];n instanceof this&&t.push(n)}return t}if(!r)return null;if(e in r){const t=r[e];if(t instanceof this)return t}return null},add(t,e,n,i={}){if(!n)throw new Error("dia.HighlighterView: An ID required.");const r=_c.get(t,n);r&&r.remove();const o=new this(i);return o.id=n,this._addRef(t,n,o),o.requestUpdate(t,e),o.listenToUpdateAttributes(t),o},_addRef(t,e,n){const{cid:i}=t,{_views:r}=this;let o=r[i];o||(o=r[i]={}),o[e]=n},_removeRef(t,e){const{cid:n}=t,{_views:i}=this,r=i[n];if(r){e&&delete r[e];for(let t in r)return;delete i[n]}},remove(t,e=null){Pc(this.get(t,e)).forEach((t=>{t.remove()}))},removeAll(t,e=null){const{_views:n}=this;for(let i in n)for(let r in n[i]){const o=n[i][r];o.cellView.paper===t&&o instanceof this&&(null===e||r===e)&&o.remove()}},update(t,e=null,n=!1){Pc(this.get(t,e)).forEach((t=>{(n||t.UPDATABLE)&&t.update()}))},transform(t,e=null){Pc(this.get(t,e)).forEach((t=>{t.UPDATABLE&&t.transform()}))},unmount(t,e=null){Pc(this.get(t,e)).forEach((t=>t.unmount()))},mount(t,e=null){Pc(this.get(t,e)).forEach((t=>t.mount()))},uniqueId:(t,e="")=>xn.ensureId(t)+JSON.stringify(e)}),kc=["transform","x","y","cx","cy","dx","dy","x1","y1","x2","y2","points","d","r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{}),Cc=["r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{});function Lc(t,e){const n={};for(let i in t)t.hasOwnProperty(i)&&(n[i]=Mc(i,t[i],e));return n}function Mc(t,e,n){if(t in kc&&Fa(e)){let i=Da(e,n);return t in Cc&&(i=Math.max(0,i)),i}return e}const Oc={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},Nc=Sc.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var t=["cell"],e=this.model.get("type");return e&&e.toLowerCase().split(".").forEach((function(e,n,i){t.push("type-"+i.slice(0,n+1).join("-"))})),t.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e,n,i={},r={},o=0,s=Eo(this,"presentationAttributes");for(var a in s)if(s.hasOwnProperty(a)){var l=s[a];for(Array.isArray(l)||(l=[l]),t=0,e=l.length;t<e;t++){var c=i[n=l[t]];c||(c=i[n]=1<<o++),r[a]|=c}}var u=Eo(this,"initFlag");for(Array.isArray(u)||(u=[u]),t=0,e=u.length;t<e;t++)i[n=u[t]]||(i[n]=1<<o++);if(o>25)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=i,this._presentationAttributes=r},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var n=0;if(Array.isArray(t))for(var i=0,r=t.length;i<r;i++)n|=e[t[i]];else n|=e[t];return n},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||js(this),Sc.call(this,t)},initialize:function(){this.setFlags(),Sc.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){var n=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&n&&(e.dirty&&this.hasFlag(n,"UPDATE")&&(n|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(n,e))},requestUpdate:function(t,e){const{paper:n}=this;n&&t>0&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n=Fs(t),i=n.selectors,r=n.groupSelectors;for(var o in r){if(i[o])throw new Error("dia.CellView: ambiguous group selector");i[o]=r[o]}if(e){var s=this.selector;if(i[s])throw new Error("dia.CellView: ambiguous root selector.");i[s]=e}return{fragment:n.fragment,selectors:i}},can:function(t){var e,n,i=po(this.options.interactive)?this.options.interactive(this):this.options.interactive;return Qr(i)&&!1!==i[t]||(e=i,n=Object.prototype.toString,(!0===e||!1===e||!!e&&"object"==typeof e&&n.call(e)===Tn)&&!1!==i)},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){var i=n[t];if(i)return Array.isArray(i)?i:[i]}return this.useCSSSelectors?Ns(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){const[e=null]=this.findNodes(t);return e},notify:function(t){if(this.paper){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e))}},getBBox:function(t){var e;if(t&&t.useModelGeometry){var n=this.model;e=n.getBBox().bbox(n.angle())}else e=this.getNodeBBox(this.el);return this.paper.localToPaperRect(e)},getNodeBBox:function(t){const e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),i=this.getNodeMatrix(t);return xn.transformRect(e,n.multiply(i))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():xn.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return xn.transformRect(e,i.multiply(n))},getRootTranslateMatrix:function(){var t=this.model.position();return xn.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t=xn.createSVGMatrix(),e=this.model,n=e.angle();if(n){var i=e.getBBox(),r=i.width/2,o=i.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t},_notifyHighlight:function(t,e,n={}){const{el:i}=this;let r;if("string"==typeof e?r=this.findNode(e)||i:[r=i]=this.$(e),n.partial=r!==i,void 0===n.type){let t;switch(!0){case n.embedding:t=Oc.EMBEDDING;break;case n.connecting:t=Oc.CONNECTING;break;case n.magnetAvailability:t=Oc.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=Oc.ELEMENT_AVAILABILITY;break;default:t=Oc.DEFAULT}n.type=t}return this.notify(t,r,n),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e={}){return this._notifyHighlight("cell:unhighlight",t,e)},findMagnet:function(t){const e=this.el;let n=this.$(t)[0];n||(n=e);do{const t=n.getAttribute("magnet"),i=n===e;if((t||i)&&"false"!==t)return n;if(i)return;n=n.parentNode}while(n)},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const t=this.findNode(n);if(t)return t}return t},getSelector:function(t,e){var n;if(t===this.el)return"string"==typeof e&&(n=":scope > "+e),n;if(t){var i=xn(t).index()+1;n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)}return n},addLinkFromMagnet:function(t,e,n){var i=this.paper,r=i.model,o=i.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,n,o,"source"),target:{x:e,y:n}}).addTo(r,{async:!1,ui:!0}),o.findView(i)},getLinkEnd:function(t,...e){var n=this.model,i=n.id,r=this.findAttribute("port",t),o=t.getAttribute("joint-selector"),s={id:i};return null!=o&&(s.magnet=o),null!=r?(s.port=r,n.hasPort(r)||o||(s.selector=this.getSelector(t))):null==o&&this.el!==t&&(s.selector=this.getSelector(t)),this.customizeLinkEnd(s,t,...e)},customizeLinkEnd:function(t,e,n,i,r,o){const{paper:s}=this,{connectionStrategy:a}=s.options;if("function"==typeof a){var l=a.call(s,t,this,e,new Kt(n,i),r,o,s);if(l)return l}return t},getMagnetFromLinkEnd:function(t){var e,n=t.port,i=t.magnet,r=this.model;return null!=n&&r.isElement()&&r.hasPort(n)?e=this.findPortNode(n,i)||this.el:(i||(i=t.selector),i||null==n||(i='[port="'+n+'"]'),e=this.findNode(i)),this.findProxyNode(e,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");const r=this.addLinkFromMagnet(e,n,i);r.notifyPointerdown(t,n,i),r.eventData(t,r.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:r})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var o=this.paper,s=o.options.magnetThreshold,a=this.getEventTarget(t),l=i.targetMagnet;if("onleave"===s){if(l===a||xn(l).contains(a))return}else if(o.eventData(t).mousemoved<=s)return;this.dragLinkStart(t,l,e,n)}},dragLinkEnd:function(t,e,n){var i=this.eventData(t).linkView;i&&(i.pointerup(t,e,n),this.model.stopBatch("add-link"))},getAttributeDefinition:function(t){return this.model.constructor.getAttributeDefinition(t)},setNodeAttributes:function(t,e){ho(e)||(t instanceof SVGElement?xn(t).attr(e):Ns(t).attr(e))},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,c,u,h=[];const d={};for(n in e)e.hasOwnProperty(n)&&(d[xn.attributeNames[n]]=e[n]);for(n in d)d.hasOwnProperty(n)&&(i=d[n],!(r=this.getAttributeDefinition(n))||po(r.qualify)&&!r.qualify.call(this,i,t,d,this)?(a||(a={}),a[n]=i):(eo(r.set)&&(a||(a={}),a[r.set]=i),null!==i&&h.push(n,r)));for(o=0,s=h.length;o<s;o+=2)n=h[o],r=h[o+1],i=e[n],po(r.set)&&(l||(l={}),l[n]=i),po(r.position)&&(c||(c={}),c[n]=i),po(r.offset)&&(u||(u={}),u[n]=i);return{raw:d,normal:a,set:l,position:c,offset:u}},updateRelativeAttributes:function(t,e,n,i){var r,o;i||(i={});var s=Lc(e.raw||{},n),a=e.normal||{};for(const t in a)a[t]=s[t];var l=e.set,c=e.position,u=e.offset;for(r in l){o=s[r];var h=this.getAttributeDefinition(r).set.call(this,o,n.clone(),t,s,this);Qr(h)?no(a,h):void 0!==h&&(a[r]=h)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,g=a.transform,m=xn.transformStringToMatrix(g),v=Kt(m.e,m.f);if(g&&(a=To(a,"transform"),m.e=m.f=0),c||u){var y=this.getNodeScale(t,i.scalableNode);d=y.sx,f=y.sy}var b=!1;for(r in c)o=s[r],(p=this.getAttributeDefinition(r).position.call(this,o,n.clone(),t,s,this))&&(v.offset(Kt(p).scale(d,f)),b||(b=!0));this.setNodeAttributes(t,a);var w=!1;if(u){var x=this.getNodeBoundingRect(t);if(x.width>0&&x.height>0){var A=xn.transformRect(x,m).scale(1/d,1/f);for(r in u)o=s[r],(p=this.getAttributeDefinition(r).offset.call(this,o,A,t,s,this))&&(v.offset(Kt(p).scale(d,f)),w||(w=!0))}}(void 0!==g||b||w)&&(v.round(1),m.e=v.x,m.f=v.y,t.setAttribute("transform",xn.matrixToTransformString(m)))}},getNodeScale:function(t,e){var n,i;if(e&&e.contains(t)){var r=e.scale();n=1/r.sx,i=1/r.sy}else n=1,i=1;return{sx:n,sy:i}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};var n=xn.ensureId(t),i=e[n];return i||(i=e[n]={}),i},getNodeData:function(t){var e=this.nodeCache(t);return e.data||(e.data={}),e.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=xn(t).getBBox()),new ge(e.boundingRect)},getNodeMatrix:function(t){const e=this.nodeCache(t);if(void 0===e.magnetMatrix){const{rotatableNode:n,el:i}=this;let r;r=n&&n.contains(t)?n:i,e.magnetMatrix=xn(t).getTransformToElement(r)}return xn.createSVGMatrix(e.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=xn(t).toGeometryShape()),e.geometryShape.clone()},isNodeConnection:function(t){return this.model.isLink()&&(!t||t===this.el)},findNodesAttributes:function(t,e,n,i){var r,o,s,a,l={},c=[];for(var u in t)if(t.hasOwnProperty(u)&&(s=t[u],go(s))){var h=n[u]=this.findBySelector(u,e,i);for(r=0,o=h.length;r<o;r++){var d=h[r];a=xn.ensureId(d);var f=i&&i[u]===d,p=l[a];if(p){p.array||(c.push(a),p.array=!0,p.attributes=[p.attributes],p.selectedLength=[p.selectedLength]);var g=p.attributes,m=p.selectedLength;if(f)g.unshift(s),m.unshift(-1);else{var v=ao(m,o);g.splice(v,0,s),m.splice(v,0,o)}}else l[a]={attributes:s,selectedLength:f?-1:o,node:d,array:!1}}}for(r=0,o=c.length;r<o;r++)(s=l[a=c[r]]).attributes=Lo({},...s.attributes.reverse());return l},getEventTarget:function(t,e={}){const{target:n,type:i,clientX:r=0,clientY:o=0}=t;return e.fromPoint||"touchmove"===i||"touchend"===i||"pointerId"in t&&n.hasPointerCapture(t.pointerId)?document.elementFromPoint(r,o):n},updateDOMSubtreeAttributes:function(t,e,n){n||(n={}),n.rootBBox||(n.rootBBox=ge()),n.selectors||(n.selectors=this.selectors);var i,r,o,s,a,l={},c={},u=[],h=[],d=n.roAttributes,f=this.findNodesAttributes(d||e,t,l,n.selectors),p=d?this.findNodesAttributes(e,t,l,n.selectors):f;for(var g in f)if(o=(s=f[g]).attributes,r=s.node,(a=this.processNodeAttributes(r,o)).set||a.position||a.offset||a.raw.ref){var m,v=p[g]&&p[g].attributes,y=v&&void 0===o.ref?v.ref:o.ref;if(y){if(!(m=(l[y]||this.findBySelector(y,t,n.selectors))[0]))throw new Error('dia.CellView: "'+y+'" reference does not exist.')}else m=null;if(i={node:r,refNode:m,processedAttributes:a,allAttributes:v},m){var b=h.findIndex((function(t){return t.refNode===r}));b>-1?h.splice(b,0,i):h.push(i)}else u.push(i)}else this.setNodeAttributes(r,Lc(a.normal,n.rootBBox));u.push(...h);for(let t=0,e=u.length;t<e;t++){i=u[t],r=i.node;const e=(m=i.refNode)?xn.ensureId(m):"";let o=c[e];o||(o=c[e]=m?xn(m).getBBox({target:Rc(r,m)}):n.rootBBox),d?(a=this.processNodeAttributes(r,i.allAttributes),this.mergeProcessedAttributes(a,i.processedAttributes)):a=i.processedAttributes,this.updateRelativeAttributes(r,a,o,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),no(t.set,e.set),no(t.position,e.position),no(t.offset,e.offset);var n=t.normal&&t.normal.transform;void 0!==n&&e.normal&&(e.normal.transform=n),t.normal=e.normal},onMount(t){t||(this.mountTools(),_c.mount(this))},onDetach(){this.unmountTools(),_c.unmount(this)},onRemove:function(){this.removeTools(),this.removeHighlighters()},_toolsView:null,hasTools:function(t){var e=this._toolsView;return!(!e||t&&e.getName()!==t)},addTools:function(t){return this.removeTools(),t&&(this._toolsView=t,t.configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){const t=this._toolsView;return t&&t.unmount(),this},mountTools(){const t=this._toolsView;return t&&!t.isMounted()&&t.mount(),this},updateTools:function(t){var e=this._toolsView;return e&&e.update(t),this},removeTools:function(){var t=this._toolsView;return t&&(t.remove(),this._toolsView=null),this},hideTools:function(){var t=this._toolsView;return t&&t.hide(),this},showTools:function(){var t=this._toolsView;return t&&t.show(),this},onToolEvent:function(t){switch(t){case"remove":this.removeTools();break;case"hide":this.hideTools();break;case"show":this.showTools()}},removeHighlighters:function(){_c.remove(this)},updateHighlighters:function(t=!1){_c.update(this,null,t)},transformHighlighters:function(){_c.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){const{defaultInteractionPrevented:e=!1}=this.eventData(t);return e},pointerdblclick:function(t,e,n){this.notify("cell:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){this.notify("cell:pointerclick",t,e,n)},contextmenu:function(t,e,n){this.notify("cell:contextmenu",t,e,n)},pointerdown:function(t,e,n){const{model:i}=this,{graph:r}=i;r&&(i.startBatch("pointer"),this.eventData(t,{graph:r})),this.notify("cell:pointerdown",t,e,n)},pointermove:function(t,e,n){this.notify("cell:pointermove",t,e,n)},pointerup:function(t,e,n){const{graph:i}=this.eventData(t);this.notify("cell:pointerup",t,e,n),i&&i.stopBatch("pointer",{cell:this.model})},mouseover:function(t){this.notify("cell:mouseover",t)},mouseout:function(t){this.notify("cell:mouseout",t)},mouseenter:function(t){this.notify("cell:mouseenter",t)},mouseleave:function(t){this.notify("cell:mouseleave",t)},mousewheel:function(t,e,n,i){this.notify("cell:mousewheel",t,e,n,i)},onevent:function(t,e,n,i){this.notify(e,t,n,i)},onmagnet:function(){},magnetpointerdblclick:function(){},magnetcontextmenu:function(){},checkMouseleave(t){const{paper:e,model:n}=this;if(e.isAsync()){if(n.isLink()){const t=n.getSourceElement();if(t){const n=e.findViewByModel(t);n&&(e.dumpView(n),e.checkViewVisibility(n))}const i=n.getTargetElement();if(i){const t=e.findViewByModel(i);t&&(e.dumpView(t),e.checkViewVisibility(t))}}e.dumpView(this),e.checkViewVisibility(this)}const i=this.getEventTarget(t,{fromPoint:!0}),r=e.findView(i);r!==this&&(this.mouseleave(t),r&&r.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Flags:{TOOLS:"TOOLS"},Highlighting:Oc,addPresentationAttributes:function(t){return Lo({},Eo(this.prototype,"presentationAttributes"),t,(function(t,e){if(t&&e)return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),Array.isArray(t)&&Array.isArray(e)?lo(t.concat(e)):void 0}))},evalAttribute:Mc});function Rc(t,e){let n=t;do{if(n.contains(e))return n;n=n.parentNode}while(n);return null}Object.defineProperty(Nc.prototype,"useCSSSelectors",{get(){const t=this.model.useCSSSelectors;return void 0!==t&&t}});const Fc={TOOLS:Nc.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},Bc="move",Ic="magnet",Dc=Nc.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=Nc.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){Nc.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[Fc.UPDATE],position:[Fc.TRANSLATE,Fc.TOOLS],size:[Fc.RESIZE,Fc.PORTS,Fc.TOOLS],angle:[Fc.ROTATE,Fc.TOOLS],markup:[Fc.RENDER],ports:[Fc.PORTS]},initFlag:[Fc.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){const{useCSSSelectors:n}=this;this.hasFlag(t,Fc.PORTS)&&(this._removePorts(),this._cleanPortsCache());let i=!1;if(this.hasFlag(t,Fc.RENDER))this.render(),this.updateTools(e),this.updateHighlighters(!0),i=!0,t=this.removeFlag(t,[Fc.RENDER,Fc.UPDATE,Fc.RESIZE,Fc.TRANSLATE,Fc.ROTATE,Fc.PORTS,Fc.TOOLS]);else{let r=!1;this.hasFlag(t,Fc.RESIZE)&&(this.resize(e),r=!0,t=this.removeFlag(t,[Fc.RESIZE,Fc.UPDATE]),n&&(t=this.removeFlag(t,Fc.PORTS))),this.hasFlag(t,Fc.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,Fc.UPDATE),r=!0,n&&(t=this.removeFlag(t,Fc.PORTS))),this.hasFlag(t,Fc.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,Fc.TRANSLATE),i=!0),this.hasFlag(t,Fc.ROTATE)&&(this.rotate(),t=this.removeFlag(t,Fc.ROTATE),i=!0),this.hasFlag(t,Fc.PORTS)&&(this._renderPorts(),r=!0,t=this.removeFlag(t,Fc.PORTS)),r&&this.updateHighlighters(!1)}return i&&this.transformHighlighters(),this.hasFlag(t,Fc.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,Fc.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();const{useCSSSelectors:n}=this;n&&this._removePorts();var i=this.model,r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new ge(i.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),n&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.ElementView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el),n=this.selectors=e.selectors;this.rotatableNode=xn(n[this.rotatableSelector])||null,this.scalableNode=xn(n[this.scalableSelector])||null,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(xn(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),this.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;var n=t.size;return"rotate("+e+","+n.width/2+","+n.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,n=e.angle(),i=e.size(),r=this.scalableNode,o=!1;r.node.getElementsByTagName("path").length>0&&(o=!0);var s=r.getBBox({recursive:o}),a=i.width/(s.width||1),l=i.height/(s.height||1);r.attr("transform","scale("+a+","+l+")");var c=this.rotatableNode,u=c&&c.attr("transform");if(u){c.attr("transform",u+" rotate("+-n+","+i.width/2+","+i.height/2+")");var h=r.getBBox({target:this.paper.cells});e.set("position",{x:h.x,y:h.y},no({updateHandled:!0},t)),this.translate(),this.rotate()}this.update()},prepareEmbedding:function(t={}){const e=t.model||this.model,n=(t.paper||this.paper).model,i=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=n.getConnectedLinks(e,{deep:!0,includeEnclosed:!0});[e,...r,...o].forEach((t=>i[t.id]=t.attributes.z)),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0});const s=n.getElements().reduce(((t,e)=>Math.max(t,e.attributes.z||0)),0);o.forEach((t=>{t.attributes.z<=s&&t.set("z",s+1,{ui:!0})})),e.stopBatch("to-front");const a=e.parent();a?(n.getCell(a).unembed(e,{ui:!0}),t.initialParentId=a):t.initialParentId=null},processEmbedding:function(t={},e,n,i){const r=t.model||this.model,o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:c}=o.options;let u;u=po(a)?mo(a.call(s,this,e,n,i)):"pointer"===a?mo(s.findModelsFromPoint({x:n,y:i})):s.findModelsUnderElement(r,{searchBy:a}),u=u.filter((t=>t instanceof sl&&r.id!==t.id&&!t.isEmbeddedIn(r))),l&&(u=u.slice(-1));let h=null;const d=t.candidateEmbedView;for(let t=u.length-1;t>=0;t--){const e=u[t];if(d&&d.model.id==e.id){h=d;break}{const t=e.findView(o);if(!po(c)||c.call(o,this,t)){h=t;break}}}h&&h!=d&&(this.clearEmbedding(t),t.candidateEmbedView=h.highlight(h.findProxyNode(null,"container"),{embedding:!0})),!h&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){t||(t={});var e=t.candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t={}){const e=t.candidateEmbedView,n=t.model||this.model,i=t.paper||this.paper;if(e)e.model.embed(n,{ui:!0}),e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null;else{const{validateUnembedding:e}=i.options,{initialParentId:n}=t;if(n&&"function"==typeof e&&!e.call(i,this))return void this._disallowUnembed(t)}i.model.getConnectedLinks(n,{deep:!0}).forEach((t=>{t.reparent({ui:!0})}))},_disallowUnembed:function(t){const{model:e,whenNotAllowed:n="revert"}=t,i=e||this.model,r=(t.paper||this.paper).model;switch(n){case"remove":i.remove({ui:!0});break;case"revert":{const{initialParentId:e,initialPosition:n,initialZIndices:o}=t;if(n){const{x:t,y:e}=n;i.position(t,e,{deep:!0,ui:!0})}o&&Object.keys(o).forEach((t=>{const e=r.getCell(t);e&&e.set("z",o[t],{ui:!0})}));const s=r.getCell(e);s&&s.embed(i,{ui:!0});break}}},getDelegatedView:function(){for(var t=this,e=t.model,n=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=n.findViewByModel(e)}return null},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const e=this.findAttribute("port",t);if(e){const t=this.findPortNode(e,n);if(t)return t}else{const t=this.findNode(n);if(t)return t}}return t},notifyPointerdown(t,e,n){Nc.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){Nc.prototype.pointermove.call(this,t,e,n),this.notify("element:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("element:pointerup",t,e,n),Nc.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){Nc.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){Nc.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){Nc.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case Ic:this.dragMagnet(t,e,n);break;case Bc:(s||this).drag(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case Ic:this.dragMagnetEnd(t,e,n);break;case Bc:(s||this).dragEnd(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){Nc.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){Nc.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){Nc.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){Nc.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){Nc.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){const{currentTarget:i}=t;this.magnetpointerdown(t,i,e,n),this.eventData(t,{targetMagnet:i}),this.dragMagnetStart(t,e,n)},magnetpointerdown:function(t,e,n,i){this.notify("element:magnet:pointerdown",t,e,n,i)},magnetpointermove:function(t,e,n,i){this.notify("element:magnet:pointermove",t,e,n,i)},magnetpointerup:function(t,e,n,i){this.notify("element:magnet:pointerup",t,e,n,i)},magnetpointerdblclick:function(t,e,n,i){this.notify("element:magnet:pointerdblclick",t,e,n,i)},magnetcontextmenu:function(t,e,n,i){this.notify("element:magnet:contextmenu",t,e,n,i)},dragStart:function(t,e,n){if(this.isDefaultInteractionPrevented(t))return;var i=this.getDelegatedView();if(!i||!i.can("elementMove"))return;this.eventData(t,{action:Bc,delegatedView:i});const r=i.model.position();i.eventData(t,{initialPosition:r,pointerOffset:r.difference(e,n),restrictedArea:this.paper.getRestrictedArea(i,e,n)})},dragMagnetStart:function(t,e,n){const{paper:i}=this,r=t.isPropagationStopped();if(r&&this.eventData(t,{preventPointerEvents:!0}),this.isDefaultInteractionPrevented(t)||!this.can("addLinkFromMagnet"))return;const{targetMagnet:o=t.currentTarget}=this.eventData(t);t.stopPropagation(),i.options.validateMagnet.call(i,this,o,t)?(i.options.magnetThreshold<=0&&this.dragLinkStart(t,o,e,n),this.eventData(t,{action:Ic})):r?this.dragStart(t,e,n):this.pointerdown(t,e,n)},drag:function(t,e,n){var i=this.paper,r=i.options.gridSize,o=this.model,s=this.eventData(t),{pointerOffset:a,restrictedArea:l,embedding:c}=s,u=Lt(e+a.x,r),h=Lt(n+a.y,r);o.position(u,h,{restrictedArea:l,deep:!0,ui:!0}),i.options.embeddingMode&&(c||(this.prepareEmbedding(s),c=!0),this.processEmbedding(s,t,e,n)),this.eventData(t,{embedding:c})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){var i=this.eventData(t);i.embedding&&this.finalizeEmbedding(i)},dragMagnetEnd:function(t,e,n){this.dragLinkEnd(t,e,n)},magnetpointerclick:function(t,e,n,i){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,n,i)}},{Flags:Fc});no(Dc.prototype,Vl);const Vc=function(t,e,n){return t},zc=function(t,e,n){var i,r,o,s=e.side||"bottom",a=Js(e.padding||40),l=n.sourceBBox,c=n.targetBBox,u=l.center(),h=c.center();switch(s){case"bottom":o=1,i="y",r="height";break;case"top":o=-1,i="y",r="height";break;case"left":o=-1,i="x",r="width";break;case"right":o=1,i="x",r="width";break;default:throw new Error("Router: invalid side")}return u[i]+=o*(l[r]/2+a[s]),h[i]+=o*(c[r]/2+a[s]),o*(u[i]-h[i])>0?h[i]=u[i]:u[i]=h[i],[u].concat(t,h)};var jc={N:"S",S:"N",E:"W",W:"E"},$c={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function Uc(t,e,n){var i=new Kt(t.x,e.y);return n.containsPoint(i)&&(i=new Kt(e.x,t.y)),i}function Gc(t,e){return t["W"===e||"E"===e?"width":"height"]}function qc(t,e){return t.x===e.x?t.y>e.y?"N":"S":t.y===e.y?t.x>e.x?"W":"E":null}function Hc(t){return new ge(t.x,t.y,0,0)}function Wc(t){var e=Js(t.padding||t.elementPadding||20);return{x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}function Yc(t,e){return t.sourceBBox.clone().moveAndExpand(Wc(e))}function Xc(t,e){return t.targetBBox.clone().moveAndExpand(Wc(e))}function Zc(t,e,n){var i=new Kt(t.x,e.y),r=new Kt(e.x,t.y),o=qc(t,i),s=qc(t,r),a=jc[n],l=o===n||o!==a&&(s===a||s!==n)?i:r;return{points:[l],direction:qc(l,e)}}function Kc(t,e,n){var i=Uc(t,e,n);return{points:[i],direction:qc(i,e)}}function Jc(t,e,n,i){var r,o={},s=[new Kt(t.x,e.y),new Kt(e.x,t.y)],a=s.filter((function(t){return!n.containsPoint(t)})),l=a.filter((function(e){return qc(e,t)!==i}));if(l.length>0)r=(r=l.filter((function(e){return qc(t,e)===i})).pop())||l[0],o.points=[r],o.direction=qc(r,e);else{r=wo(s,a)[0];var c=new Kt(e).move(r,-Gc(n,i)/2),u=Uc(c,t,n);o.points=[u,c],o.direction=qc(c,e)}return o}function Qc(t,e,n,i){var r=Kc(e,t,i),o=r.points[0];if(n.containsPoint(o)){var s=(r=Kc(t,e,n)).points[0];if(i.containsPoint(s)){var a=new Kt(t).move(s,-Gc(n,qc(t,s))/2),l=new Kt(e).move(o,-Gc(i,qc(e,o))/2),c=new ee(a,l).midpoint(),u=Kc(t,c,n),h=Zc(c,e,u.direction);r.points=[u.points[0],h.points[0]],r.direction=h.direction}}return r}function tu(t,e,n,i,r){var o,s,a,l={},c=n.union(i).inflate(1),u=c.center().distance(e)>c.center().distance(t),h=u?e:t,d=u?t:e;return r?(o=Kt.fromPolar(c.width+c.height,$c[r],h),o=c.pointNearestToPoint(o).move(o,-1)):o=c.pointNearestToPoint(h).move(h,1),s=Uc(o,d,c),o.round().equals(s.round())?(s=Kt.fromPolar(c.width+c.height,Ot(o.theta(h))+Math.PI/2,d),a=Uc(o,s=c.pointNearestToPoint(s).move(d,1).round(),c),l.points=u?[s,a,o]:[o,a,s]):l.points=u?[s,o]:[o,s],l.direction=qc(u?o:s,e),l}function eu(t,e,n){var i,r=Yc(n,e),o=Xc(n,e),s=function(t,e){return t.sourceAnchor?t.sourceAnchor:Yc(t,e).center()}(n,e),a=function(t,e){return t.targetAnchor?t.targetAnchor:Xc(t,e).center()}(n,e);r=r.union(Hc(s)),o=o.union(Hc(a)),(t=mo(t).map(Kt)).unshift(s),t.push(a);for(var l=[],c=0,u=t.length-1;c<u;c++){var h=null,d=t[c],f=t[c+1],p=!!qc(d,f);if(0===c)c+1===u?r.intersect(o.clone().inflate(1))?h=tu(d,f,r,o):p||(h=Qc(d,f,r,o)):r.containsPoint(f)?h=tu(d,f,r,Hc(f).moveAndExpand(Wc(e))):p||(h=Kc(d,f,r));else if(c+1===u){var g=p&&qc(f,d)===i;o.containsPoint(d)||g?h=tu(d,f,Hc(d).moveAndExpand(Wc(e)),o,i):p||(h=Jc(d,f,o,i))}else p||(h=Zc(d,f,i));h?(Array.prototype.push.apply(l,h.points),i=h.direction):i=qc(d,f),c+1<u&&l.push(f)}return l}var nu={step:10,maximumLoops:2e3,precision:1,maxAllowedDirectionChange:90,perpendicular:!0,excludeEnds:[],excludeTypes:[],startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},cost:function(){return this.step},directions:function(){var t=this.step,e=this.cost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:-t,offsetY:0,cost:e},{offsetX:0,offsetY:t,cost:e},{offsetX:0,offsetY:-t,cost:e}]},penalties:function(){return{0:0,45:this.step/2,90:this.step/2}},paddingBox:function(){var t=this.step;return{x:-t,y:-t,width:2*t,height:2*t}},isPointObstacle:null,fallbackRouter:function(t,e,n){if(!po(eu))throw new Error("Manhattan requires the orthogonal router as default fallback.");return eu(t,no({},nu,e),n)},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function iu(t){this.map={},this.options=t,this.mapGridSize=100}function ru(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function ou(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function su(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function au(t,e){return t.sourceAnchor?t.sourceAnchor:ou(t,e).center()}function lu(t,e,n,i,r){var o=360/n,s=t.theta(function(t,e,n,i){var r=i.step,o=e.x-t.x,s=e.y-t.y,a=o/n.x*r,l=s/n.y*r;return new Kt(t.x+a,t.y+l)}(t,e,i,r)),a=Ct(s+o/2);return o*Math.floor(a/o)}function cu(t,e){var n=Math.abs(t-e);return n>180?360-n:n}function uu(t,e){if(!t)return e;var n=Math.abs(t),i=Math.round(n/e);return i?e+(n-i*e)/i:n}function hu(t,e){return t.round(e)}function du(t,e,n){return hu(function(t,e){var n=e.source,i=Lt(t.x-n.x,e.x)+n.x,r=Lt(t.y-n.y,e.y)+n.y;return new Kt(i,r)}(t.clone(),e),n)}function fu(t){return t.clone().toString()}function pu(t){return new Kt(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function gu(t,e,n,i,r,o,s){for(var a,l=[],c=pu(r.difference(n)),u=fu(n),h=t[u];h;){var d=pu((a=e[u]).difference(h));d.equals(c)||(l.unshift(a),c=d),h=t[u=fu(h)]}var f=e[u];return pu(f.difference(i)).equals(c)||l.unshift(f),l}function mu(t,e){for(var n=1/0,i=0,r=e.length;i<r;i++){var o=t.manhattanDistance(e[i]);o<n&&(n=o)}return n}function vu(t,e,n,i,r){var o=r.precision,s=r.directionMap,a=t.difference(e.center()),l=Qr(s)?Object.keys(s):[],c=mo(n),u=l.reduce((function(n,r){if(c.includes(r)){for(var l,u=s[r],h=new Kt(t.x+u.x*(Math.abs(a.x)+e.width),t.y+u.y*(Math.abs(a.y)+e.height)),d=new ee(t,h).intersect(e)||[],f=d.length,p=null,g=0;g<f;g++){var m=d[g],v=t.squaredDistance(m);(void 0===l||v>l)&&(l=v,p=m)}if(p){var y=du(p,i,o);e.containsPoint(y)&&(y=du(y.offset(u.x*i.x,u.y*i.y),i,o)),n.push(y)}}return n}),[]);return e.containsPoint(t)||u.push(du(t,i,o)),u}function yu(t,e,n,i){var r,o,s=i.precision;r=hu(t instanceof ge?au(this,i).clone():t.clone(),s),o=hu(e instanceof ge?function(t,e){return t.targetAnchor?t.targetAnchor:su(t,e).center()}(this,i).clone():e.clone(),s);var a,l,c,u,h,d,f,p=(a=i.step,c=o,{source:(l=r).clone(),x:uu(c.x-l.x,a),y:uu(c.y-l.y,a)});if(d=t instanceof ge?vu(u=r,t,i.startDirections,p,i):[u=r],e instanceof ge?(h=o,f=vu(o,e,i.endDirections,p,i)):f=[h=o],d=d.filter((t=>!n(t))),f=f.filter((t=>!n(t))),d.length>0&&f.length>0){for(var g=new ru,m={},v={},y={},b=0,w=d.length;b<w;b++){var x=d[b],A=fu(x);g.add(A,mu(x,f)),m[A]=x,y[A]=0}var E,T,S=i.previousDirectionAngle,P=void 0===S,_=i.directions;!function(t,e,n){var i=n.step;mo(n.directions).forEach((function(t){t.gridOffsetX=t.offsetX/i*e.x,t.gridOffsetY=t.offsetY/i*e.y}))}(0,p,i);for(var k=_.length,C=mo(f).reduce((function(t,e){var n=fu(e);return t.push(n),t}),[]),L=i.maximumLoops;!g.isEmpty()&&L>0;){var M,O=g.pop(),N=m[O],R=v[O],F=y[O],B=void 0===R,I=N.equals(u);M=B?P?I?null:lu(u,N,k,p,i):S:lu(R,N,k,p,i);var D=d.length===f.length;if(D)for(var V=0;V<d.length;V++)if(!d[V].equals(f[V])){D=!1;break}if((!B||!D)&&C.indexOf(O)>=0)return i.previousDirectionAngle=M,gu(v,m,N,u,h);for(b=0;b<k;b++){var z=(E=_[b]).angle;if(T=cu(M,z),P&&I||!(T>i.maxAllowedDirectionChange)){var j=du(N.clone().offset(E.gridOffsetX,E.gridOffsetY),p,s),$=fu(j);if(!g.isClose($)&&!n(j)){if(C.indexOf($)>=0&&!j.equals(h)&&cu(z,lu(j,h,k,p,i))>i.maxAllowedDirectionChange)continue;var U=F+E.cost+(I?0:i.penalties[T]);(!g.isOpen($)||U<y[$])&&(m[$]=j,v[$]=N,y[$]=U,g.add($,U+mu(j,f)))}}}L--}}return i.fallbackRoute.call(this,u,h,i)}iu.prototype.build=function(t,e){var n=this.options,i=mo(n.excludeEnds).reduce((function(n,i){var r=e.get(i);if(r){var o=t.getCell(r.id);o&&n.push(o)}return n}),[]),r=[],o=t.getCell(e.get("source").id);o&&(r=xo(r,o.getAncestors().map((function(t){return t.id}))));var s=t.getCell(e.get("target").id);s&&(r=xo(r,s.getAncestors().map((function(t){return t.id}))));var a=this.mapGridSize;return t.getElements().reduce((function(t,e){var o=mo(n.excludeTypes).includes(e.get("type")),s=i.find((function(t){return t.id===e.id})),l=r.includes(e.id);if(!(o||s||l))for(var c=e.getBBox().moveAndExpand(n.paddingBox),u=c.origin().snapToGrid(a),h=c.corner().snapToGrid(a),d=u.x;d<=h.x;d+=a)for(var f=u.y;f<=h.y;f+=a){var p=d+"@"+f;t[p]=t[p]||[],t[p].push(c)}return t}),this.map),this},iu.prototype.isPointAccessible=function(t){var e=t.clone().snapToGrid(this.mapGridSize).toString();return mo(this.map[e]).every((function(e){return!e.containsPoint(t)}))},ru.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;var n=ao(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(n,0,t)},ru.prototype.remove=function(t){this.hash[t]=this.CLOSE},ru.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},ru.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},ru.prototype.isEmpty=function(){return 0===this.items.length},ru.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};const bu=function(t,e,n){return function(t,e,n){!function(t){if(t.directions=Eo(t,"directions"),t.penalties=Eo(t,"penalties"),t.paddingBox=Eo(t,"paddingBox"),t.padding=Eo(t,"padding"),t.padding){var e=Js(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}mo(t.directions).forEach((function(t){var e=new Kt(0,0),n=new Kt(t.offsetX,t.offsetY);t.angle=Ct(e.theta(n))}))}(e),n.options.perpendicular=!!e.perpendicular;var i=ou(n,e),r=su(n,e),o=au(n,e);let s;if("function"==typeof e.isPointObstacle)s=e.isPointObstacle;else{const t=new iu(e);t.build(n.paper.model,n.model),s=e=>!t.isPointAccessible(e)}for(var a,l,c=mo(t).map(Kt),u=[],h=o,d=0,f=c.length;d<=f;d++){var p=null;if(l=a||i,!(a=c[d])&&(a=r,(!n.model.get("source").id||!n.model.get("target").id)&&po(e.draggingRoute))){var g=l===i?o:l,m=a.origin();p=e.draggingRoute.call(n,g,m,e)}if(null===(p=p||yu.call(n,l,a,s,e)))return e.fallbackRouter(t,e,n);var v=p[0];v&&v.equals(h)&&p.shift(),h=p[p.length-1]||h,Array.prototype.push.apply(u,p)}return u}(t,no({},nu,e),n)};var wu={maxAllowedDirectionChange:45,diagonalCost:function(){var t=this.step;return Math.ceil(Math.sqrt(t*t<<1))},directions:function(){var t=this.step,e=this.cost(),n=this.diagonalCost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:t,offsetY:t,cost:n},{offsetX:0,offsetY:t,cost:e},{offsetX:-t,offsetY:t,cost:n},{offsetX:-t,offsetY:0,cost:e},{offsetX:-t,offsetY:-t,cost:n},{offsetX:0,offsetY:-t,cost:e},{offsetX:t,offsetY:-t,cost:n}]},fallbackRoute:function(t,e,n){var i=t.theta(e),r=[],o={x:e.x,y:t.y},s={x:t.x,y:e.y};if(i%180>90){var a=o;o=s,s=a}var l=i%90<45?o:s,c=new ee(t,l),u=90*Math.ceil(i/90),h=Kt.fromPolar(c.squaredLength(),Ot(u+135),l),d=new ee(e,h),f=c.intersection(d),p=f||e,g=f?p:t,m=360/n.directions.length,v=g.theta(e),y=Ct(v+m/2),b=m*Math.floor(y/m);return n.previousDirectionAngle=b,p&&r.push(p.round()),r.push(e),r}};const xu=function(t,e,n){if(!po(bu))throw new Error("Metro requires the manhattan router.");return bu(t,no({},wu,e),n)},Au={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Eu=[Au.LEFT,Au.RIGHT,Au.TOP,Au.BOTTOM],Tu={[Au.LEFT]:Au.RIGHT,[Au.RIGHT]:Au.LEFT,[Au.TOP]:Au.BOTTOM,[Au.BOTTOM]:Au.TOP},Su=[Au.TOP,Au.BOTTOM],Pu={0:Au.RIGHT,180:Au.LEFT,270:Au.TOP,90:Au.BOTTOM};function _u(t){return t.angle()}function ku(t){return new we(t).simplify({threshold:1}).points}function Cu(t,e){const{point:n,x0:i,y0:r,view:o,bbox:s,direction:a}=t,{point:l,x0:c,y0:u,view:h,bbox:d,direction:f}=e;let p,g;if(o)p=o.model.isLink()?Lu(l,n,o):a===Au.ANCHOR_SIDE?s.sideNearestToPoint(n):a===Au.MAGNET_SIDE?o.model.getBBox().sideNearestToPoint(n):a;else{const t=new ge(i,r,0,0);p=Eu.includes(a)?a:t.sideNearestToPoint(l)}if(h)g=h.model.isLink()?Lu(n,l,h):f===Au.ANCHOR_SIDE?d.sideNearestToPoint(l):f===Au.MAGNET_SIDE?h.model.getBBox().sideNearestToPoint(l):f;else{const t=new ge(c,u,0,0);g=Eu.includes(f)?f:t.sideNearestToPoint(n)}return[p,g]}function Lu(t,e,n){const i=n.getTangentAtLength(n.getClosestPointLength(e)),r=90*Math.round(_u(i)/90);if(r%180==0&&t.y===e.y)return t.x<e.x?Au.LEFT:Au.RIGHT;if(t.x===e.x)return t.y<e.y?Au.TOP:Au.BOTTOM;switch(r){case 0:case 180:case 360:return t.y<e.y?Au.TOP:Au.BOTTOM;case 90:case 270:return t.x<e.x?Au.LEFT:Au.RIGHT}}function Mu(t,e,n,i,r,o,s){i===Au.AUTO&&(i=r?Au.MAGNET_SIDE:Au.ANCHOR_SIDE);const a=t&&t.model.isElement(),{x:l,y:c,width:u=0,height:h=0}=a?ge.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:l,y0:c,view:t,bbox:n,width:u,height:h,direction:i,margin:a?s:0}}function Ou({x:t,y:e}){const n=new Kt(t,e);return{point:n,x0:n.x,y0:n.y,view:null,bbox:new ge(t,e,0,0),width:0,height:0,direction:null,margin:0}}function Nu(t,e,n){const i=e.point.clone(),{x0:r,y0:o,width:s,height:a}=e;switch(t){case"left":i.x=r-n;break;case"right":i.x=r+s+n;break;case"top":i.y=o-n;break;case"bottom":i.y=o+a+n}return i}function Ru(t,e){const{point:n,x0:i,y0:r,view:o,width:s,height:a,margin:l}=t,{point:c,x0:u,y0:h,width:d,height:f,margin:p}=e,g=u+d,m=h+f,v=i+s,y=r+a,b=o&&o.model.isElement(),w=i-l,x=v+l,A=r-l,E=y+l,T=u-p,S=g+p,P=h-p,_=m+p,[k,C]=Cu(t,e),L=Nu(k,{point:n,x0:i,y0:r,width:s,height:a},l),M=Nu(C,{point:c,x0:u,y0:h,width:d,height:f},p),{x:O,y:N}=L,{x:R,y:F}=M,B=(h+m)/2,I=((i+v)/2<(u+g)/2?v+u:g+i)/2,D=((r+y)/2<B?y+h:m+r)/2;if("left"===k&&"right"===C){if(w<=S){let t=D;return v<=u&&(m>=A&&F<N?t=Math.min(P,A):h<=E&&F>=N&&(t=Math.max(_,E))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("right"===k&&"left"===C){if(x>=T){let t=D;return O>g&&(m>=A&&F<N?t=Math.min(P,A):h<=E&&F>=N&&(t=Math.max(_,E))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("top"===k&&"bottom"===C){if(N<F){let t=I,e=N;return N<h&&(g>=w&&R<O?t=Math.min(T,w):u<=x&&R>=O&&(t=Math.max(S,x))),[{x:O,y:e},{x:t,y:e},{x:t,y:F},{x:R,y:F}]}const t=(N+F)/2;return[{x:O,y:t},{x:R,y:t}]}if("bottom"===k&&"top"===C){if(N-l>F){let t=I,e=N;return N>m&&(g>=w&&R<O?t=Math.min(T,w):u<=x&&R>=O&&(t=Math.max(S,x))),[{x:O,y:e},{x:t,y:e},{x:t,y:F},{x:R,y:F}]}const t=(N+F)/2;return[{x:O,y:t},{x:R,y:t}]}if("top"===k&&"top"===C){let t,e=Math.min((y+h)/2,F),n=Math.min((r+m)/2,N);if(F<N){if(O>=S||O<=T)return[{x:O,y:Math.min(N,F)},{x:R,y:Math.min(N,F)}];t=R>O?Math.min(O,T):Math.max(O,S)}else{if(R>=x||R<=w)return[{x:O,y:Math.min(N,F)},{x:R,y:Math.min(N,F)}];t=R>=O?Math.max(R,x):Math.min(R,w)}return[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("bottom"===k&&"bottom"===C){let t,e=Math.max((r+m)/2,F),n=Math.max((y+h)/2,N);if(F>N){if(O>=S||O<=T)return[{x:O,y:Math.max(N,F)},{x:R,y:Math.max(N,F)}];t=R>O?Math.min(O,T):Math.max(O,S)}else{if(R>=x||R<=w)return[{x:O,y:Math.max(N,F)},{x:R,y:Math.max(N,F)}];t=R>=O?Math.max(R,x):Math.min(R,w)}return[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("left"===k&&"left"===C){let t,e=Math.min((v+u)/2,R),n=Math.min((i+g)/2,O);return t=R>O?F<=N?Math.min(A,F):Math.max(E,F):F>=N?Math.min(P,N):Math.max(_,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("right"===k&&"right"===C){let t,e=Math.max((i+g)/2,R),n=Math.max((v+u)/2,O);return t=R<O?F<=N?Math.min(A,F):Math.max(E,F):F>=N?Math.min(P,N):Math.max(_,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("top"===k&&"right"===C){if(N>F){if(O<R){let t=D;return(t>B||!b)&&t<_&&O<u&&(t=P),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.max(I,S);if(R<O&&F>r&&F<y)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t>w&&F>r||u>v){const t=Math.min(r-l,h-p),e=Math.max(v+l,g+p);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:Math.max(t,R),y:N},{x:Math.max(t,R),y:F}]}if("top"===k&&"left"===C){if(N>F){if(O>R){let t=D;return(t>B||!b)&&t<_&&O>g&&(t=P),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.min(T,I);if(O<R&&y>=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t<x&&N<m){const t=Math.min(A,P),e=Math.min(w,T);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("bottom"===k&&"right"===C){if(N<F){if(O<R){let t=D;return(t<B||!b)&&t>P&&O<u&&(t=_),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}if(i<R){const t=Math.max(E,_),e=Math.max(x,S);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:I,y:N},{x:I,y:F}]}if("bottom"===k&&"left"===C){if(N<F){if(O>R){let t=D;return(t<B||!b)&&t>P&&O>g&&(t=_),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}if(v>R){const t=Math.max(E,_),e=Math.min(w,T);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:I,y:N},{x:I,y:F}]}if("left"===k&&"bottom"===C){if(O>=R&&N>=_)return[{x:R,y:N}];if(O>=g&&N<F)return[{x:I,y:N},{x:I,y:F},{x:R,y:F}];if(R<v&&m<=r)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=Math.min(T,O),e=Math.max(E,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}if("left"===k&&"top"===C){if(O>R&&N<P)return[{x:R,y:N}];if(O>=g&&N>F)return[{x:I,y:N},{x:I,y:F},{x:R,y:F}];if(R<=v&&F>N)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=F<N?Math.min(w,T):w,e=Math.min(A,P);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}if("right"===k&&"top"===C){if(O<=R&&N<P)return[{x:R,y:N}];if(v<u&&N>F)return[{x:I,y:N},{x:I,y:F},{x:R,y:F}];if(R<O&&h>y)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=Math.max(x,S),e=Math.min(A,P);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}if("right"===k&&"bottom"===C){if(O<=R&&N>=_)return[{x:R,y:N}];if(O<=T&&N<F)return[{x:I,y:N},{x:I,y:F},{x:R,y:F}];if(R>i&&m<r)return[{x:O,y:N},{x:O,y:D},{x:R,y:D}];const t=Math.max(S,O),e=Math.max(E,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}}function Fu(t,e,n){const{sourceDirection:i=Au.AUTO,targetDirection:r=Au.AUTO}=e,o=e.margin||20,s=e.useVertices||!1,a=!!n.model.source().port,l=Mu(n.sourceView,n.sourceAnchor,n.sourceBBox,i,a,n.sourceAnchor,o),c=!!n.model.target().port,u=Mu(n.targetView,n.targetAnchor,n.targetBBox,r,c,n.targetAnchor,o);let h=[];if(!s||0===t.length)return ku(Ru(l,u));const d=t.map((t=>Ou(t))),[f]=d;if(l.view&&l.view.model.isElement()&&l.view.model.getBBox().inflate(o).containsPoint(f.point)){const[t]=Cu(l,f),e=t,n=Ou(l.point);n.margin=o,n.direction=t,f.direction=e,h.push(...Ru(n,f),f.point)}else{const t=function(t,e,n){const[i]=Cu(t,e);switch(i){case Au.TOP:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,u=i-l,h=i+o+l,d=r-l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g<r?Au.BOTTOM:p<f&&g<d?Au.RIGHT:p>f&&g<d?Au.LEFT:p<u&&g>=r||p>h&&g>=r?Au.TOP:p>=u&&p<=f&&g>c||p<=h&&p>=f&&g>c?n.point.x<p?Au.RIGHT:Au.LEFT:Au.TOP}(t,e,n);case Au.RIGHT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,u=c+l,h=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g>f&&m===p?Au.LEFT:g>=u&&m<p?Au.BOTTOM:g>=u&&m>p?Au.TOP:g<=c&&m<=h||g<=c&&m>=d?Au.RIGHT:g<r&&m>=h&&m<=p||g<r&&m<=d&&m>=p?n.point.y<m?Au.BOTTOM:Au.TOP:Au.RIGHT}(t,e,n);case Au.BOTTOM:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,u=i-l,h=i+o+l,d=c+l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g>c?Au.TOP:p<f&&g>d?Au.RIGHT:p>f&&g>d?Au.LEFT:p<u&&g<=c||p>h&&g<=c?Au.BOTTOM:p>=u&&p<=f&&g<r||p<=h&&p>=f&&g<r?n.point.x<p?Au.RIGHT:Au.LEFT:Au.BOTTOM}(t,e,n);case Au.LEFT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,u=r-l,h=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g<f&&m===p?Au.RIGHT:g<=u&&m<p?Au.BOTTOM:g<=u&&m>p?Au.TOP:g>=r&&m<=h||g>=r&&m>=d?Au.LEFT:g>c&&m>=h&&m<=p||g>c&&m<=d&&m>=p?n.point.y<m?Au.BOTTOM:Au.TOP:Au.LEFT}(t,e,n)}}(l,f,d[1]||u);f.direction=t,h.push(...Ru(l,f),f.point)}for(let t=0;t<d.length-1;t++){const e=d[t],n=d[t+1],i=_u(new ee(e.point,n.point));if(i%90==0){const t=Pu[i],r=Tu[t];if(t!==e.direction)h.push(e.point,n.point),n.direction=r;else{const t=Ct(i-90);let r=0,s=0;90===t?s=-o:180===t?r=-o:270===t?s=o:0===t&&(r=o);const a={x:e.point.x+r,y:e.point.y+s},l={x:n.point.x+r,y:n.point.y+s},c=new ee(n.point,l);n.direction=Pu[_u(c)],h.push(e.point,a,l,n.point)}continue}const[r,s]=Bu(e,n);e.direction=r,n.direction=s,h.push(...Ru(e,n),n.point)}const p=d[d.length-1];if(u.view&&u.view.model.isElement())if(u.view.model.getBBox().inflate(o).containsPoint(p.point)){const[t]=Bu(p,u),e=Ou(u.point),[,n]=Cu(p,u);e.margin=o,e.direction=n,p.direction=t,h.push(...Ru(p,e))}else{const t=ku(h),e=new ee(t[t.length-2],p.point),n=Pu[Math.round(_u(e))];p.direction=n;let i=Ru(p,u);const[r,s]=ku([...i,u.point]),a=new ee(r,s),l=Math.round(_u(a)),c=Pu[l];c!==n&&n===Tu[c]&&(p.margin=o,i=Ru(p,u)),h.push(...i)}else{const[t]=Bu(p,u);p.direction=t,h.push(...Ru(p,u))}return ku(h)}function Bu(t,e){const n=t.direction,i=Su.includes(n);let r=t.direction,o=e.direction;if(i){const i=t.point.y>e.point.y,s=e.point.x-t.point.x;n===Au.BOTTOM?(r=i?Tu[n]:s>=0?Au.RIGHT:Au.LEFT,s>0?o=i?Au.LEFT:Au.TOP:s<0&&(o=i?Au.RIGHT:Au.TOP)):(r=i?s>=0?Au.RIGHT:Au.LEFT:Tu[n],s>0?o=i?Au.BOTTOM:Au.LEFT:s<0&&(o=i?Au.BOTTOM:Au.RIGHT))}else{const i=t.point.x>e.point.x,s=e.point.y-t.point.y;n===Au.RIGHT?(r=i?Tu[n]:s>=0?Au.BOTTOM:Au.TOP,s>0?o=i?Au.TOP:Au.LEFT:s<0&&(o=i?Au.BOTTOM:Au.LEFT)):(r=i?s>=0?Au.BOTTOM:Au.TOP:Tu[n],s>0?o=i?Au.RIGHT:Au.TOP:s<0&&(o=i?Au.RIGHT:Au.BOTTOM))}return[r,o]}Fu.Directions=Au;const Iu=Fu,Du={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},Vu=Object.values(Du),zu=10,ju=1,$u=function(t,e,n=[],i={}){const{cornerType:r=Du.POINT,cornerRadius:o=zu,cornerPreserveAspectRatio:s=!1,precision:a=ju,raw:l=!1}=i;if(-1===Vu.indexOf(r))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(r!==Du.POINT&&o){let i;c=new ke,c.appendSegment(ke.createSegment("M",t));const l=n.length;for(let u=0;u<l;u++){const l=new Kt(n[u]),h=n[u-1]||t,d=n[u+1]||e,f=i||l.distance(h)/2;let p,g;i=l.distance(d)/2,s?p=g=-Math.min(o,f,i):(p=-Math.min(o,f),g=-Math.min(o,i));const m=l.clone().move(h,p).round(a),v=l.clone().move(d,g).round(a);switch(c.appendSegment(ke.createSegment("L",m)),r){case Du.CUBIC:{const t=1/3,e=2/3,n=new Kt(t*m.x+e*l.x,e*l.y+t*m.y),i=new Kt(t*v.x+e*l.x,e*l.y+t*v.y);c.appendSegment(ke.createSegment("C",n,i,v));break}case Du.LINE:c.appendSegment(ke.createSegment("L",v));break;case Du.GAP:c.appendSegment(ke.createSegment("M",v))}}c.appendSegment(ke.createSegment("L",e))}else{const i=[t].concat(n).concat([e]),r=new we(i);c=new ke(r)}return l?c:c.serialize()};var Uu=["arc","gap","cubic"],Gu=["smooth"],qu=1/3,Hu=2/3;function Wu(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;if(n>r){let t=n;n=r,r=t,t=i,i=o,o=t}if(i>o){let t=n;n=r,r=t,t=i,i=o,o=t}return[new Kt(n,i),new Kt(r,o)]}function Yu(t,e,n){var i=[].concat(t,n,e);return i.reduce((function(t,e,n){var r=i[n+1];return null!=r&&(t[n]=ne(e,r)),t}),[])}function Xu(t,e){return ne(t,e).squaredLength()}function Zu(t,e,n,i){var r,o=new ke;return r=ke.createSegment("M",t[0].start),o.appendSegment(r),mo(t).forEach((function(s,a){if(s.isJump){var l,c,u,h;if("arc"===n){l=-90,c=s.start.difference(s.end);var d=Number(c.x<0||0===c.x&&c.y<0);d&&(l+=180);var f,p=s.midpoint(),g=new ee(p,s.end).rotate(p,l);u=(f=new ee(s.start,p)).pointAt(2/3).rotate(s.start,l),h=g.pointAt(1/3).rotate(g.end,-l),r=ke.createSegment("C",u,h,g.end),o.appendSegment(r),f=new ee(p,s.end),u=g.pointAt(1/3).rotate(g.end,l),h=f.pointAt(1/3).rotate(s.end,-l),r=ke.createSegment("C",u,h,s.end),o.appendSegment(r)}else if("gap"===n)r=ke.createSegment("M",s.end),o.appendSegment(r);else if("cubic"===n){l=s.start.theta(s.end);var m=.6*e,v=1.35*e;c=s.start.difference(s.end),(d=Number(c.x<0||0===c.x&&c.y<0))&&(v*=-1),u=Kt(s.start.x+m,s.start.y+v).rotate(s.start,l),h=Kt(s.end.x-m,s.end.y+v).rotate(s.end,l),r=ke.createSegment("C",u,h,s.end),o.appendSegment(r)}}else{var y=t[a+1];0==i||!y||y.isJump?(r=ke.createSegment("L",s.end),o.appendSegment(r)):function(t,e,n,i,r){var o,s=n.distance(i)/2,a=n.distance(r)/2,l=-Math.min(t,s),c=-Math.min(t,a),u=n.clone().move(i,l).round(),h=n.clone().move(r,c).round(),d=new Kt(qu*u.x+Hu*n.x,Hu*n.y+qu*u.y),f=new Kt(qu*h.x+Hu*n.x,Hu*n.y+qu*h.y);o=ke.createSegment("L",u),e.appendSegment(o),o=ke.createSegment("C",d,f,h),e.appendSegment(o)}(i,o,s.end,s.start,y.end)}})),o}const Ku=function(t,e,n,i){!function(t){var e=t.paper,n=e._jumpOverUpdateList;if(null==n){n=e._jumpOverUpdateList=[];var i=e.model;i.on("batch:stop",(function(){this.hasActiveBatch()||function(t){for(var e=t._jumpOverUpdateList,n=0;n<e.length;n++){const t=e[n],i=t.getFlag(t.constructor.Flags.CONNECTOR);t.requestUpdate(i)}}(e)})),i.on("reset",(function(){n=e._jumpOverUpdateList=[]}))}n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",(function(){n.splice(n.indexOf(t),1)})))}(this);var r=i.raw,o=i.size||5,s=i.jump&&(""+i.jump).toLowerCase(),a=i.radius||0,l=i.ignoreConnectors||Gu;-1===Uu.indexOf(s)&&(s=Uu[0]);var c=this.paper,u=c.model.getLinks();if(1===u.length)return Zu(Yu(t,e,n),o,s,a);var h=this.model,d=u.indexOf(h),f=c.options.defaultConnector||{},p=u.filter((function(t,e){var n=t.get("connector")||f;return!(mo(l).includes(n.name)||e>d&&"jumpover"===n.name)})),g=p.map((function(t){return c.findViewByModel(t)})),m=Yu(t,e,n),v=g.map((function(t){return null==t?[]:t===this?m:Yu(t.sourcePoint,t.targetPoint,t.route)}),this),y=m.reduce((function(t,e){var n=p.reduce((function(t,n,i){if(n!==h){const n=v[i].slice(),r=n.findIndex((t=>function(t,e){const[{x:n,y:i},{x:r,y:o}]=Wu(t.start,t.end),[{x:s,y:a},{x:l,y:c}]=Wu(e.start,e.end);return n<=l&&s<=r&&i<=c&&a<=o}(e,t)));r>-1&&e.containsPoint(n[r].end)&&n.splice(r+1,1);const o=function(t,e){return mo(e).reduce((function(e,n){var i=t.intersection(n);return i&&e.push(i),e}),[])}(e,n);t.push.apply(t,o)}return t}),[]).sort((function(t,n){return Xu(e.start,t)-Xu(e.start,n)}));return n.length>0?t.push.apply(t,function(t,e,n){return e.reduce((function(i,r,o){if(!0===r.skip)return i;var s=i.pop()||t,a=Jt(r).move(s.start,-n),l=Jt(r).move(s.start,+n),c=e[o+1];if(null!=c){var u=l.distance(c);u<=n&&(l=c.move(s.start,u),c.skip=!0)}else if(a.distance(s.end)<2*n+1)return i.push(s),i;if(l.distance(s.start)<2*n+1)return i.push(s),i;var h=ne(a,l);return h.isJump=!0,i.push(ne(s.start,a),h,ne(l,s.end)),i}),[])}(e,n,o)):t.push(e),t}),[]),b=Zu(y,o,s,a);return r?b:b.serialize()},Ju=function(t,e,n=[],i={}){const{raw:r}=i;return $u(t,e,n,{cornerType:"point",raw:r})},Qu=10,th=function(t,e,n=[],i={}){const{radius:r=Qu,raw:o}=i;return $u(t,e,n,{cornerType:"cubic",cornerRadius:r,precision:0,raw:o})},eh=function(t,e,n,i){var r,o=i&&i.raw;if(n&&0!==n.length){var s=[t].concat(n).concat([e]),a=Pe.throughPoints(s);r=new ke(a)}else{var l;if(r=new ke,l=ke.createSegment("M",t),r.appendSegment(l),Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)){var c=(t.x+e.x)/2;l=ke.createSegment("C",c,t.y,c,e.y,e.x,e.y),r.appendSegment(l)}else{var u=(t.y+e.y)/2;l=ke.createSegment("C",t.x,u,e.x,u,e.x,e.y),r.appendSegment(l)}}return o?r:r.serialize()},nh={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},ih={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},rh=function(t,e,n=[],i={},r){const o=Boolean(i.raw),{direction:s=nh.AUTO,precision:a=3}=i,l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new Kt(i.sourceTangent):null,targetTangent:i.targetTangent?new Kt(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new Kt(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new Kt(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new Kt(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new Kt(i.targetDirection).normalize():null;const c=[t,...n,e].map((t=>new Kt(t)));let u,h;if(l.sourceTangent)u=l.sourceTangent;else{const t=function(t,e,n,i){if(i.sourceDirection)switch(i.sourceDirection){case ih.UP:return new Kt(0,-1);case ih.DOWN:return new Kt(0,1);case ih.LEFT:return new Kt(-1,0);case ih.RIGHT:return new Kt(1,0);case ih.AUTO:return oh(t,e,i);case ih.CLOSEST_POINT:return ah(0,e);case ih.OUTWARDS:return ch(t,e);default:return i.sourceDirection}switch(n){case nh.HORIZONTAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.x>e[1].x?"right":"left";return s=new Kt("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case nh.VERTICAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.y>e[1].y?"bottom":"top";return s=new Kt(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case nh.CLOSEST_POINT:return ah(0,e);case nh.OUTWARDS:return ch(t,e);case nh.AUTO:default:return oh(t,e,i)}}(r,c,s,l),e=c[0].distance(c[1])*l.coeff,n=dh(t,c[1].difference(c[0]).normalize());if(n>Math.PI/4){const i=e+(n-Math.PI/4)*l.angleTangentCoefficient;u=t.clone().scale(i,i)}else u=t.clone().scale(e,e)}if(l.targetTangent)h=l.targetTangent;else{const t=function(t,e,n,i){if(i.targetDirection)switch(i.targetDirection){case ih.UP:return new Kt(0,-1);case ih.DOWN:return new Kt(0,1);case ih.LEFT:return new Kt(-1,0);case ih.RIGHT:return new Kt(1,0);case ih.AUTO:return sh(t,e,i);case ih.CLOSEST_POINT:return lh(0,e);case ih.OUTWARDS:return uh(t,e);default:return i.targetDirection}switch(n){case nh.HORIZONTAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.x>e[e.length-2].x?"left":"right";return s=new Kt("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case nh.VERTICAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.y>e[e.length-2].y?"top":"bottom";return s=new Kt(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case nh.CLOSEST_POINT:return lh(0,e);case nh.OUTWARDS:return uh(t,e);case nh.AUTO:default:return sh(t,e,i)}}(r,c,s,l),e=c.length-1,n=c[e-1].distance(c[e])*l.coeff,i=dh(t,c[e-1].difference(c[e]).normalize());if(i>Math.PI/4){const e=n+(i-Math.PI/4)*l.angleTangentCoefficient;h=t.clone().scale(e,e)}else h=t.clone().scale(n,n)}const d=function(t,e,n,i){const{tau:r,coeff:o}=i,s=[],a=[],l=[],c=t.length-1;for(let e=0;e<c;e++)s[e]=t[e].distance(t[e+1]);a[0]=e,a[c]=n;for(let e=1;e<c;e++){let n,i;n=1===e?t[e-1].clone().offset(a[e-1].x,a[e-1].y):t[e-1].clone(),i=e===c-1?t[e+1].clone().offset(a[e+1].x,a[e+1].y):t[e+1].clone();const r=n.difference(t[e]).normalize(),l=i.difference(t[e]).normalize(),u=dh(r,l);let h,d=(Math.PI-u)/2;const f=fh(r,l);let p;p=fh(t[e].difference(t[e+1]),t[e].difference(t[e-1])),f<0&&(d=-d),u<Math.PI/2&&(d<0&&p<0||d>0&&p>0)&&(d-=Math.PI),h=l.clone(),hh(h,d);const g=h.clone(),m=h.clone(),v=s[e-1]*o,y=s[e]*o;g.scale(v,v),m.scale(y,y),a[e]=[g,m]}for(let e=0;e<c;e++){let n,i;n=0===e?t[e+1].difference(a[e].x/r,a[e].y/r):t[e+1].difference(a[e][1].x/r,a[e][1].y/r),i=e===c-1?t[e].clone().offset(a[e+1].x/r,a[e+1].y/r):t[e].difference(a[e+1][0].x/r,a[e+1][0].y/r),l[e]=[n,t[e],t[e+1],i]}return l}(c,u,h,l),f=d.map((t=>function(t,e){const{tau:n}=e,i=new Kt;i.x=t[1].x+(t[2].x-t[0].x)/(6*n),i.y=t[1].y+(t[2].y-t[0].y)/(6*n);const r=new Kt;return r.x=t[2].x+(t[3].x-t[1].x)/(6*n),r.y=t[2].y+(t[3].y-t[1].y)/(6*n),new Pe(t[1],i,r,t[2])}(t,l))),p=new ke(f).round(a);return o?p:p.serialize()};function oh(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.sideNearestToPoint(e[1]);switch(r){case"top":s=new Kt(0,-1);break;case"bottom":s=new Kt(0,1);break;case"right":s=new Kt(1,0);break;case"left":s=new Kt(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function sh(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.sideNearestToPoint(e[e.length-2]);switch(r){case"top":s=new Kt(0,-1);break;case"bottom":s=new Kt(0,1);break;case"right":s=new Kt(1,0);break;case"left":s=new Kt(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function ah(t,e,n){return e[1].difference(e[0]).normalize()}function lh(t,e,n){const i=e.length-1;return e[i-1].difference(e[i]).normalize()}function ch(t,e,n){const{sourceBBox:i}=t,r=i.center();return e[0].difference(r).normalize()}function uh(t,e,n){const{targetBBox:i}=t,r=i.center();return e[e.length-1].difference(r).normalize()}function hh(t,e){const n=Math.cos(e),i=Math.sin(e),r=n*t.x-i*t.y,o=i*t.x+n*t.y;t.x=r,t.y=o}function dh(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return n<-1&&(n=-1),n>1&&(n=1),Math.acos(n)}function fh(t,e){return t.x*e.y-t.y*e.x}rh.Directions=nh,rh.TangentDirections=ih;const ph={TOOLS:Nc.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},gh=Nc.extend({className:function(){var t=Nc.prototype.className.apply(this).split(" ");return t.push("link"),t.join(" ")},_labelCache:null,_labelSelectors:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(){Nc.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[ph.RENDER],attrs:[ph.UPDATE],router:[ph.UPDATE],connector:[ph.CONNECTOR],labels:[ph.LABELS],labelMarkup:[ph.LABELS],vertices:[ph.UPDATE],source:[ph.SOURCE,ph.UPDATE],target:[ph.TARGET,ph.UPDATE]},initFlag:[ph.RENDER,ph.SOURCE,ph.TARGET,ph.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e||(e={}),this.hasFlag(t,ph.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,ph.SOURCE)}if(this.hasFlag(t,ph.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,ph.TARGET)}const{paper:n,sourceView:i,targetView:r}=this;if(n&&(i&&!n.isViewMounted(i)||r&&!n.isViewMounted(r)))return t;if(this.hasFlag(t,ph.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),this.removeFlag(t,[ph.RENDER,ph.UPDATE,ph.LABELS,ph.TOOLS,ph.CONNECTOR]);let o=!1;const{model:s}=this,{attributes:a}=s;let l=this.hasFlag(t,ph.LABELS);l&&(this.onLabelsChange(s,a.labels,e),t=this.removeFlag(t,ph.LABELS),o=!0);const c=this.hasFlag(t,ph.UPDATE),u=this.hasFlag(t,ph.CONNECTOR);return(c||u)&&(c?e.translateBy&&s.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[ph.UPDATE,ph.TOOLS,ph.CONNECTOR]),l=!1,o=!0),l&&this.updateLabelPositions(),o&&this.updateHighlighters(),this.hasFlag(t,ph.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,ph.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(ph.UPDATE),t)},isLabelsRenderRequired:function(t={}){const e=this.model.previous("labels");if(!e)return!0;if("propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(i>1&&e[n[1]]){if(2===i)return"markup"in Object(t.propertyValue);if("markup"!==n[2])return!1}}return!0},onLabelsChange:function(t,e,n){this.isLabelsRenderRequired(n)?this.renderLabels():this.updateLabels()},render:function(){return this.vel.empty(),this.unmountLabels(),this._V={},this.renderMarkup(),this.renderLabels(),this.update(),this},renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.LinkView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el);this.selectors=e.selectors,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=xn(t);Array.isArray(e)||(e=[e]),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=xn(t),n=document.createDocumentFragment();if(Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var o=e[i].node;n.appendChild(o)}else n.appendChild(e.node);return{fragment:n,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e,n=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=n.childNodes;return(e=i.length>1||"G"!==i[0].nodeName.toUpperCase()?xn("g").append(n):xn(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,n=this._labelCache={},i=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],s=o.length;if(0===s)return e&&e.remove(),this;e?e.empty():(e=t.labels=xn("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(Rs(Eo(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,c,u=o[a],h=this._normalizeLabelMarkup(this._getLabelMarkup(u.markup));if(h)l=h.node,c=h.selectors;else{var d=r._builtins.defaultLabel,f=this._normalizeLabelMarkup(this._getLabelMarkup(d.markup)),p=r._getDefaultLabel(),g=this._normalizeLabelMarkup(this._getLabelMarkup(p.markup))||f;l=g.node,c=g.selectors}l.setAttribute("label-idx",a),e.append(l),n[a]=l;var m=this.selector;if(c[m])throw new Error("dia.LinkView: ambiguous label root selector.");c[m]=l,i[a]=c}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){const{el:t,paper:e,model:n,_V:i,options:r}=this,{labels:o}=i;if(!o||!n.hasLabels())return;const{node:s}=o;r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(s,n.get("z")):s.parentNode!==t&&t.appendChild(s)},unmountLabels:function(){const{options:t,_V:e}=this;if(!e)return;const{labels:n}=e;n&&t.labelsLayer&&n.remove()},findLabelNodes:function(t,e){const n=this._labelCache[t];if(!n)return[];const i=this._labelSelectors[t];return this.findBySelector(e,n,i)},findLabelNode:function(t,e){const[n=null]=this.findLabelNodes(t,e);return n},_mergeLabelAttrs:function(t,e,n,i){if(null===e)return null;if(void 0===e){if(null===n)return null;if(void 0===n){if(t)return;return i}return t?n:Lo({},i,n)}return t?Lo({},n,e):Lo({},i,n,e)},_mergeLabelSize:function(t,e){if(null===t)return null;if(void 0===t){if(null===e)return null;if(void 0===e)return;return e}return Lo({},e,t)},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,r=t._getDefaultLabel(),o=r.markup,s=r.attrs,a=r.size,l=0,c=e.length;l<c;l++){var u=this._labelCache[l];u.setAttribute("cursor",n?"move":"default");var h=this._labelSelectors[l],d=e[l],f=d.markup,p=d.attrs,g=d.size,m=this._mergeLabelAttrs(f||o,p,s,i),v=this._mergeLabelSize(g,a);this.updateDOMSubtreeAttributes(u,m,{rootBBox:new ge(v),selectors:h})}return this},removeRedundantLinearVertices:function(t){const e=this.model,n=e.vertices(),i=[this.sourceAnchor,...n,this.targetAnchor],r=i.length,o=new we(i);o.simplify({threshold:.001});const s=o.points.map((t=>t.toJSON())),a=s.length;return r===a?0:(e.vertices(s.slice(1,a-1),t),r-a)},getEndView:function(t){switch(t){case"source":return this.sourceView||null;case"target":return this.targetView||null;default:throw new Error("dia.LinkView: type parameter required.")}},getEndAnchor:function(t){switch(t){case"source":return new Kt(this.sourceAnchor);case"target":return new Kt(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new Kt(this.sourcePoint);case"target":return new Kt(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(!e)break;return this.sourceMagnet||e.el;case"target":var n=this.targetView;if(!n)break;return this.targetMagnet||n.el;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t=0,e=0){const{route:n,path:i}=this;if(!n||!i)return;const r=new we(n);r.translate(t,e),this.route=r.points,this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e),i.translate(t,e),this.updateDOM()},updateDOM(){const{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){const{model:t}=this,e=t.vertices(),n=this.findAnchors(e),i=this.sourceAnchor=n.source,r=this.targetAnchor=n.target,o=this.findRoute(e);this.route=o;var s=this.findConnectionPoints(o,i,r);this.sourcePoint=s.source,this.targetPoint=s.target},updatePath:function(){const{route:t,sourcePoint:e,targetPoint:n}=this,i=this.findPath(t,e.clone(),n.clone());this.path=i},findAnchorsOrdered:function(t,e,n,i){var r,o,s,a,l=this.model,c=l.get(t),u=l.get(n),h=this.getEndView(t),d=this.getEndView(n),f=this.getEndMagnet(t),p=this.getEndMagnet(n);h?(s=e?new Kt(e):d?p:new Kt(u),r=this.getAnchor(c.anchor,h,f,s,t)):r=new Kt(c),d?(a=new Kt(i||r),o=this.getAnchor(u.anchor,d,p,a,n)):o=new Kt(u);var g={};return g[t]=r,g[n]=o,g},findAnchors:function(t){var e=this.model,n=t[0],i=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",i,"source",n):this.findAnchorsOrdered("source",n,"target",i)},findConnectionPoints:function(t,e,n){var i,r,o,s,a=t[0],l=t[t.length-1],c=this.model,u=c.get("source"),h=c.get("target"),d=this.sourceView,f=this.targetView,p=this.paper.options;if(d&&!d.isNodeConnection(this.sourceMagnet)){i=this.sourceMagnet||d.el;var g=u.connectionPoint||p.defaultConnectionPoint,m=new ee(a||n,e);o=this.getConnectionPoint(g,d,i,m,"source")}else o=e;if(f&&!f.isNodeConnection(this.targetMagnet)){r=this.targetMagnet||f.el;var v=h.connectionPoint||p.defaultConnectionPoint,y=new ee(l||e,n);s=this.getConnectionPoint(v,f,r,y,"target")}else s=n;return{source:o,target:s}},getAnchor:function(t,e,n,i,r){var o,s=e.isNodeConnection(n),a=this.paper.options;if(t||(t=s?a.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:a.defaultAnchor),!t)throw new Error("Anchor required.");if("function"==typeof t)o=t;else{var l=t.name;if("function"!=typeof(o=a[s?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}var c=o.call(this,e,n,i,t.args||{},r,this);return c?c.round(this.decimalsRounding):new Kt},getConnectionPoint:function(t,e,n,i,r){var o,s,a=i.end,l=this.paper.options;if(!t)return a;if("function"==typeof t)s=t;else{var c=t.name;if("function"!=typeof(s=l.connectionPointNamespace[c]))throw new Error("Unknown connection point: "+c)}return(o=s.call(this,i,e,n,t.args||{},r,this))?o.round(this.decimalsRounding):a},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,n=t._getDefaultLabel(),i=this._normalizeLabelPosition(n.position);return Lo({},e,i)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},_mergeLabelPositionProperty:function(t,e){return null===t?null:void 0===t?null===e?null:e:Lo({},e,t)},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model.get("labels")||[];if(!t.length)return this;for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r=this._labelCache[n];if(r){var o=t[n],s=this._normalizeLabelPosition(o.position),a=this._mergeLabelPositionProperty(s,e),l=this._getLabelTransformationMatrix(a);r.setAttribute("transform",xn.matrixToTransformString(l)),this._cleanLabelMatrices(n)}}return this},_cleanLabelMatrices:function(t){const{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(let t in i){const{id:n}=i[t];n&&n in e&&delete e[n].magnetMatrix}},updateEndProperties:function(t){const{model:e,paper:n}=this,i=`${t}View`,r=e.get(t),o=r&&r.id;if(!o)return this[i]=null,this.updateEndMagnet(t),!0;const s=n.getModelById(o);if(!s)throw new Error("LinkView: invalid "+t+" cell.");const a=s.findView(n);return!!a&&(this[i]=a,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){const e=`${t}Magnet`,n=this.getEndView(t);if(n){let i=n.getMagnetFromLinkEnd(this.model.get(t));i===n.el&&(i=null),this[e]=i}else this[e]=null},_getLabelPositionProperty:function(t){return this.model.label(t).position||{}},_getLabelPositionAngle:function(t){return this._getLabelPositionProperty(t).angle||0},_getLabelPositionArgs:function(t){return this._getLabelPositionProperty(t).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:Lo({},e,t)},addLabel:function(t,e,n,i){var r,o,s,a=0;"number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(a=e,s=n):s=e):(r=t,o=e,"number"==typeof n?(a=n,s=i):s=n);var l=this._getDefaultLabelPositionArgs(),c=s,u=this._mergeLabelPositionArgs(c,l),h={position:this.getLabelPosition(r,o,a,u)};return this.model.insertLabel(-1,h,s),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,o=i?t.y:e,s=i?e:n,a={x:r,y:o},l=this.getVertexIndex(r,o);return this.model.insertVertex(l,a,s),l},sendToken:function(t,e,n){var i,r,o;Qr(e)?(i=e.duration,r="reverse"===e.direction,o=e.connection):(i=e,r=!1,o=null);var s={dur:(i=i||1e3)+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};r&&(s.keyPoints="1;0",s.keyTimes="0;1");var a,l=xn(t);if("string"==typeof o)a=this.findNode(o);else{var c=this._V;a=c.connection?c.connection.node:this.el.querySelector("path")}if(!(a instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");l.appendTo(this.paper.cells).animateAlongPath(s,a),setTimeout(function(t,e){return function(){t.remove(),"function"==typeof e&&e()}}(l,n),i)},findRoute:function(t){t||(t=[]);var e=this.paper.options.routerNamespace||u,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(Kt);n=i}var r=po(n)?n:e[n.name];if(!po(r))throw new Error('dia.LinkView: unknown router: "'+n.name+'".');var o=n.args||{};return r.call(this,t,o,this)||t.map(Kt)},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||h,r=this.model.connector(),o=this.paper.options.defaultConnector;r||(r=o||{});var s=po(r)?r:i[r.name];if(!po(s))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');var a=co(r.args||{});a.raw=!0;var l=s.call(this,e,n,t,a,this);return"string"==typeof l&&(l=new ke(xn.normalizePathData(l))),l},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;var n=t.serialize();return e.data=n,n},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;var n=t.getSegmentSubdivisions();return e.segmentSubdivisions=n,n},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;var n=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=n,n},getPointAtLength:function(t){var e=this.path;return e?e.pointAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getPointAtRatio:function(t){var e=this.path;return e?(Ws(t)&&(t=parseFloat(t)/100),e.pointAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()})):null},getTangentAtLength:function(t){var e=this.path;return e?e.tangentAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getTangentAtRatio:function(t){var e=this.path;return e?e.tangentAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPoint:function(t){var e=this.path;return e?e.closestPoint(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointLength:function(t){var e=this.path;return e?e.closestPointLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointRatio:function(t){var e=this.path;return e?e.closestPointNormalizedLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getLabelPosition:function(t,e,n,i){var r,o={},s=0;"number"==typeof n?(s=n,r=i):r=n,r&&(o.args=r);var a,l,c=!(r&&r.absoluteDistance),u=r&&r.absoluteDistance&&r.reverseDistance,h=r&&r.absoluteOffset,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=new Kt(t,e),g=d.closestPointT(p,f),m=d.lengthAtT(g,f);if(c&&(m=m/this.getConnectionLength()||0),u&&(m=-1*(this.getConnectionLength()-m)||1),o.distance=m,h||(a=d.tangentAtT(g)),a)l=a.pointOffset(p);else{var v=d.pointAtT(g),y=p.difference(v);l={x:y.x,y:y.y}}return o.offset=l,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e,n=0,i={};if("number"==typeof t)e=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},e=t.distance,n=t.angle||0}var r=e>0&&e<=1,o=0,s={x:0,y:0};if(t.offset){var a=t.offset;"number"==typeof a&&(o=a),a.x&&(s.x=a.x),a.y&&(s.y=a.y)}var l,c=0!==s.x||0!==s.y||0===o,u=i.keepGradient,h=i.ensureLegibility,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=r?e*this.getConnectionLength():e,g=d.tangentAtLength(p,f),m=n;if(g){if(c)(l=g.start.clone()).offset(s);else{var v=g.clone();v.rotate(g.start,-90),v.setLength(o),l=v.end}u&&(m=g.angle()+n,h&&(m=Ct((m+90)%180-90)))}else l=d.start.clone(),c&&l.offset(s);return xn.createSVGMatrix().translate(l.x,l.y).rotate(m)},getLabelCoordinates:function(t){var e=this._getLabelTransformationMatrix(t);return new Kt(e.e,e.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new Kt(t,e)),r=0,o=n.length;r<o;r++){var s=n[r];if(i<this.getClosestPointLength(s))break}return r},notifyPointerdown(t,e,n){Nc.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){Nc.prototype.pointermove.call(this,t,e,n),this.notify("link:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("link:pointerup",t,e,n),Nc.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){Nc.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){Nc.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){Nc.prototype.contextmenu.apply(this,arguments),this.notify("link:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){var i=this._dragData;switch(i&&this.eventData(t,i),this.eventData(t).action){case"label-move":this.dragLabel(t,e,n);break;case"arrowhead-move":this.dragArrowhead(t,e,n);break;case"move":this.drag(t,e,n)}i&&no(i,this.eventData(t)),this.notifyPointermove(t,e,n)},pointerup:function(t,e,n){var i=this._dragData;switch(i&&(this.eventData(t,i),this._dragData=null),this.eventData(t).action){case"label-move":this.dragLabelEnd(t,e,n);break;case"arrowhead-move":this.dragArrowheadEnd(t,e,n);break;case"move":this.dragEnd(t,e,n)}this.notifyPointerup(t,e,n),this.checkMouseleave(t)},mouseover:function(t){Nc.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){Nc.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){Nc.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){Nc.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){Nc.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,n,i)},onlabel:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragLabelStart(t,e,n),this.eventData(t).stopPropagation&&t.stopPropagation()},dragLabelStart:function(t,e,n){if(this.can("labelMove")){if(this.isDefaultInteractionPrevented(t))return;var i=t.currentTarget,r=parseInt(i.getAttribute("label-idx"),10),o=this._getDefaultLabelPositionProperty(),s=this._normalizeLabelPosition(this._getLabelPositionProperty(r)),a=this._mergeLabelPositionProperty(s,o),l=this.getLabelCoordinates(a),c=l.x-e,u=l.y-n,h=this._getLabelPositionAngle(r),d=this._getLabelPositionArgs(r),f=this._getDefaultLabelPositionArgs(),p=this._mergeLabelPositionArgs(d,f);this.eventData(t,{action:"label-move",labelIdx:r,dx:c,dy:u,positionAngle:h,positionArgs:p,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){if(this.can("arrowheadMove")){var i=t.target.getAttribute("end"),r=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0});this.eventData(t,r)}},dragStart:function(t,e,n){this.isDefaultInteractionPrevented(t)||this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:n})},dragLabel:function(t,e,n){var i=this.eventData(t),r={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)};this.paper.options.snapLabels&&delete r.position.offset;const o={ui:!0};this.paper.isAsync()&&"touchmove"===t.type&&(o.async=!1),this.model.label(i.labelIdx,r,o)},dragArrowhead:function(t,e,n){this.paper.options.snapLinks?!this._snapArrowhead(t,e,n)&&this.paper.options.snapLinksSelf&&this._snapArrowheadSelf(t,e,n):this.paper.options.snapLinksSelf?this._snapArrowheadSelf(t,e,n):this._connectArrowhead(this.getEventTarget(t),e,n,this.eventData(t))},drag:function(t,e,n){var i=this.eventData(t);this.model.translate(e-i.dx,n-i.dy,{ui:!0}),this.eventData(t,{dx:e,dy:n})},dragLabelEnd:function(){},dragArrowheadEnd:function(t,e,n){var i=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(i):this._connectArrowheadEnd(i,e,n),r.linkAllowed(this)?(this._finishEmbedding(i),this._notifyConnectEvent(i,t)):this._disallow(i),this._afterArrowheadMove(i)},dragEnd:function(){},_disallow:function(t){"remove"===t.whenNotAllowed?this.model.remove({ui:!0}):this.model.set(t.arrowhead,t.initialEnd,{ui:!0})},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var n=t.arrowhead,i=t.initialEnd,r=this.model.prop(n);if(r&&!jl.endsEqual(i,r)){var o=this.paper;i.id&&this.notify("link:disconnect",e,o.findViewByModel(i.id),t.initialMagnet,n),r.id&&this.notify("link:connect",e,o.findViewByModel(r.id),t.magnetUnderPointer,n)}},_snapToPoints:function(t,e,n){let i=null,r=1/0,o=null,s=1/0,a=t.x,l=t.y;for(let n=0;n<e.length;n++){const a=Math.abs(e[n].x-t.x);a<r&&(r=a,i=e[n]);const l=Math.abs(e[n].y-t.y);l<s&&(s=l,o=e[n])}return r<n&&(a=i.x),s<n&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){const{paper:i,model:r}=this,{snapLinksSelf:o}=i.options,s=this.eventData(t),a=o.radius||20,l=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],c=this._snapToPoints({x:e,y:n},l,a),u=i.localToClientPoint(c);this._connectArrowhead(document.elementFromPoint(u.x,u.y),c.x,c.y,this.eventData(t))},_snapArrowhead:function(t,e,n){const{paper:i}=this,{snapLinks:r,connectionStrategy:o}=i.options,s=this.eventData(t);let a=!1;var l=r.radius||50,c=i.findViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l}),u=s.closestView||null,h=s.closestMagnet||null,d=s.magnetProxy||null;s.closestView=s.closestMagnet=s.magnetProxy=null;var f,p=Number.MAX_VALUE,g=new Kt(e,n);c.forEach((function(t){const e=[];"false"!==t.el.getAttribute("magnet")&&e.push({bbox:t.model.getBBox(),magnet:t.el}),t.$("[magnet]").toArray().forEach((n=>{e.push({bbox:t.getNodeBBox(n),magnet:n})})),e.forEach((e=>{const{magnet:n,bbox:r}=e,o=r.center().squaredDistance(g);o<p&&(h===n||i.options.validateConnection.apply(i,s.validateConnectionArgs(t,t.el===n?null:n)))&&(p=o,s.closestView=t,s.closestMagnet=n)}))}),this);var m=null,v=s.closestView,y=s.closestMagnet;y&&(m=s.magnetProxy=v.findProxyNode(y,"highlighter"));var b=s.arrowhead,w=h!==y;if(u&&w&&u.unhighlight(d,{connecting:!0,snapping:!0}),v){const{prevEnd:t,prevX:i,prevY:r}=s;if(s.prevX=e,s.prevY=n,a=!0,!w&&("function"!=typeof o||i===e&&r===n))return a;if(f=v.getLinkEnd(y,e,n,this.model,b),!w&&fo(t,f))return a;s.prevEnd=f,w&&v.highlight(m,{connecting:!0,snapping:!0})}else f={x:e,y:n};return this.model.set(b,f||{x:e,y:n},{ui:!0}),u&&this.notify("link:snap:disconnect",t,u,h,b),v&&this.notify("link:snap:connect",t,v,y,b),a},_snapArrowheadEnd:function(t){var e=t.closestView,n=t.closestMagnet;e&&n&&(e.unhighlight(t.magnetProxy,{connecting:!0,snapping:!0}),t.magnetUnderPointer=e.findMagnet(n)),t.closestView=t.closestMagnet=null},_connectArrowhead:function(t,e,n,i){const{paper:r,model:o}=this;if(i.eventTarget!==t){i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0});const e=i.viewUnderPointer=r.findView(t);if(e){const n=i.magnetUnderPointer=e.findMagnet(t),o=i.magnetProxy=e.findProxyNode(n,"highlighter");n&&this.paper.options.validateConnection.apply(r,i.validateConnectionArgs(e,n))?o&&e.highlight(o,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)}else i.magnetUnderPointer=null,i.magnetProxy=null}i.eventTarget=t,o.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t={},e,n){const{model:i}=this,{viewUnderPointer:r,magnetUnderPointer:o,magnetProxy:s,arrowhead:a}=t;if(!o||!s||!r)return;r.unhighlight(s,{connecting:!0});const l=r.getLinkEnd(o,e,n,i,a);i.set(a,l,{ui:!0})},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,n=[];n[4]=t,n[5]=this;var i=0,r=0;"source"===t?(i=2,e="target"):(r=2,e="source");var o=this.model.get(e);if(o.id){var s=n[i]=this.paper.findViewByModel(o.id),a=s.getMagnetFromLinkEnd(o);a===s.el&&(a=void 0),n[i+1]=a}return function(t,e){return n[r]=t,n[r+1]=t.el===e?void 0:e,n}},_markAvailableMagnets:function(t){function e(t,e){var n=t.paper;return n.options.validateConnection.apply(n,this.validateConnectionArgs(t,e))}var n=this.paper,i=n.model.getCells();t.marked={};for(var r=0,o=i.length;r<o;r++){var s=i[r].findView(n);if(s){var a=Array.prototype.slice.call(s.el.querySelectorAll("[magnet]"));"false"!==s.el.getAttribute("magnet")&&a.push(s.el);var l=a.filter(e.bind(t,s));if(l.length>0){for(var c=0,u=l.length;c<u;c++)s.highlight(l[c],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e,n,i=Object.keys(t.marked),r=0,o=i.length;r<o;r++){e=i[r],n=t.marked[e];var s=this.paper.findViewByModel(e);if(s){for(var a=0,l=n.length;a<l;a++)s.unhighlight(n[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){e||(e={});var n={action:"arrowhead-move",arrowhead:t,whenNotAllowed:e.whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:co(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(n),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=n),n},onMount:function(){Nc.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){Nc.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){Nc.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:ph});Object.defineProperty(gh.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t){var e=this.model.source();return new ge(e.x,e.y)}var n=this.sourceMagnet;return t.isNodeConnection(n)?new ge(this.sourceAnchor):t.getNodeBBox(n||t.el)}}),Object.defineProperty(gh.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t){var e=this.model.target();return new ge(e.x,e.y)}var n=this.targetMagnet;return t.isNodeConnection(n)?new ge(this.targetAnchor):t.getNodeBBox(n||t.el)}});const mh={GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"},vh=Sc.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return Rs(`${this.options.name}-layer`)},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){const{el:e}=this;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(t){const{el:e,pivotNodes:n}=this;(t=+t)||(t=0);let i=n[t];if(i)return i;i=n[t]=document.createComment("z-index:"+(t+1));let r=-1/0;for(let e in n)e=+e,e<t&&e>r&&(r=e);if(r!==-1/0){const t=n[r];e.insertBefore(i,t.nextSibling)}else e.insertBefore(i,e.firstChild);return i},removePivots:function(){const{el:t,pivotNodes:e}=this;for(let n in e)t.removeChild(e[n]);this.pivotNodes={}}}),yh=_c.extend({tagName:"path",className:"highlight-stroke",attributes:{"pointer-events":"none",fill:"none"},options:{padding:3,rx:0,ry:0,useFirstSubpath:!1,attrs:{"stroke-width":3,stroke:"#FEB663"}},getPathData(t,e){const{options:n}=this,{useFirstSubpath:i}=n;let r;try{const t=xn(e);if(r=t.convertToPathData().trim(),"PATH"===t.tagName()&&i){const t=r.search(/.M/i)+1;t>0&&(r=r.substr(0,t))}}catch(i){const o=t.getNodeBoundingRect(e);r=xn.rectToPath(no({},n,o.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){const{vel:n,options:i}=this,{padding:r,layer:o}=i;let s=this.getNodeMatrix(t,e);if(r){o||e!==t.el||n.remove();let i=t.getNodeBoundingRect(e);const a=i.x+i.width/2,l=i.y+i.height/2;i=xn.transformRect(i,s);const c=Math.max(i.width,1),u=Math.max(i.height,1),h=(c+r)/c,d=(u+r)/u,f=xn.createSVGMatrix({a:h,b:0,c:0,d,e:a-h*a,f:l-d*l});s=s.multiply(f)}n.attr({d:this.getPathData(t,e),transform:xn.matrixToTransformString(s)})},highlight(t,e){const{vel:n,options:i}=this;n.attr(i.attrs),i.nonScalingStroke&&n.attr("vector-effect","non-scaling-stroke"),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}}),bh=20,wh=_c.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:bh,deep:!1,attrs:{stroke:"#FEB663","stroke-width":3,"stroke-linecap":"butt","stroke-linejoin":"miter"}},VISIBLE:"white",INVISIBLE:"black",MASK_ROOT_ATTRIBUTE_BLACKLIST:["marker-start","marker-end","marker-mid","transform","stroke-dasharray","class"],MASK_CHILD_ATTRIBUTE_BLACKLIST:["stroke","fill","stroke-width","stroke-opacity","stroke-dasharray","fill-opacity","marker-start","marker-end","marker-mid","class"],MASK_REPLACE_TAGS:["FOREIGNOBJECT","IMAGE","USE","TEXT","TSPAN","TEXTPATH"],MASK_REMOVE_TAGS:["TEXT","TSPAN","TEXTPATH"],transformMaskChild(t,e){const{MASK_CHILD_ATTRIBUTE_BLACKLIST:n,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=e.tagName();if(!xn.isSVGGraphicsElement(e)||r.includes(o))return e.remove(),!1;if(i.includes(o)){const n=t.vel.findOne(`#${e.id}`);if(n){const{node:i}=n;let r=t.getNodeBoundingRect(i);t.model.isElement()&&(r=xn.transformRect(r,t.getNodeMatrix(i)));const o=xn("rect",r.toJSON()),{x:s,y:a}=r.center(),{angle:l,cx:c=s,cy:u=a}=n.rotate();l&&o.rotate(l,c,u),e.parent().append(o)}return e.remove(),!1}return n.forEach((t=>{"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)})),!0},transformMaskRoot(t,e){const{MASK_ROOT_ATTRIBUTE_BLACKLIST:n}=this;n.forEach((t=>{e.removeAttr(t)}))},getMaskShape(t,e){const{options:n,MASK_REPLACE_TAGS:i}=this,{deep:r}=n,o=e.tagName();let s;if("G"===o){if(!r)return null;s=e.clone(),function(t,e){const n=t.children();for(;n.length>0;){const t=n.shift();e(t)&&n.push(...t.children())}}(s,(e=>this.transformMaskChild(t,e)))}else{if(i.includes(o))return null;s=e.clone()}return this.transformMaskRoot(t,s),s},getMaskId(){return`highlight-mask-${this.cid}`},getMask(t,e){const{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:o,attrs:s}=r,a=parseFloat(xn("g").attr(s).attr("stroke-width")),l="none"!==e.attr("fill");let c=parseFloat(e.attr("stroke-width"));isNaN(c)&&(c=1);const u=c+2*o,h=u+2*a;let d=this.getMaskShape(t,e);if(!d){const n=t.getNodeBoundingRect(e.node);n.inflate(n.width?0:.5,n.height?0:.5),d=xn("rect",n.toJSON())}return d.attr(s),xn("mask",{id:this.getMaskId()}).append([d.clone().attr({fill:l?n:"none",stroke:n,"stroke-width":h}),d.clone().attr({fill:l?i:"none",stroke:i,"stroke-width":u})])},removeMask(t){const e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){const{options:n,vel:i}=this,{padding:r,attrs:o,maskClip:s=bh,layer:a}=n,l="stroke"in o?o.stroke:"#000000";a||e!==t.el||i.remove();const c=t.getNodeBoundingRect(e).inflate(r+s),u=this.getNodeMatrix(t,e),h=this.getMask(t,xn(e));this.addMask(t.paper,h),i.attr(c.toJSON()),i.attr({transform:xn.matrixToTransformString(u),mask:`url(#${h.id})`,fill:l})},unhighlight(t){this.removeMask(t.paper)}}),xh=_c.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){const{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),Ah=Rs("highlighted"),Eh=_c.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:Ah},highlight:function(t,e){xn(e).addClass(this.options.className)},unhighlight:function(t,e){xn(e).removeClass(this.options.className)}},{className:Ah}),Th={ROW:"row",COLUMN:"column"},Sh=_c.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){const n=t.model,{attribute:i,size:r=20,gap:o=5,direction:s=Th.ROW}=this.options;if(!i)throw new Error("List: attribute is required");const a="number"==typeof r?{width:r,height:r}:r,l=s===Th.ROW,c=l?a.width:a.height;let u=n.get(i);Array.isArray(u)||(u=[]);const h=this._prevItems||[],d=u.map(((t,e)=>fo(h[e],u[e])));if(h.length!==u.length||d.some((t=>!t))){const t=this.vel.children(),e=u.map(((e,n)=>{const r=n in t?t[n].node:null;if(d[n])return r;const s=this.createListItem(e,a,r);if(!s)return null;if(!(s instanceof SVGElement))throw new Error("List: item must be an SVGElement");s.dataset.index=n,s.dataset.attribute=i;const u=n*(c+o);return s.setAttribute("transform",l?`translate(${u}, 0)`:`translate(0, ${u})`),s}));this.vel.empty().append(e),this._prevItems=u}const f=u.length,p=0===f?0:f*c+(f-1)*o,g=l?{width:p,height:a.height}:{width:a.width,height:p};this.position(n,g)},position(t,e){const{vel:n,options:i}=this,{margin:r=5,position:o="top-left"}=i,{width:s,height:a}=t.size(),{left:l,right:c,top:u,bottom:h}=Js(r),d=new ge(l,u,s-(l+c),a-(u+h));let{x:f,y:p}=ac(d,o);switch(o){case sc.CENTER:case sc.TOP:case sc.BOTTOM:f-=e.width/2;break;case sc.RIGHT:case sc.BOTTOM_RIGHT:case sc.TOP_RIGHT:f-=e.width}switch(o){case sc.CENTER:case sc.RIGHT:case sc.LEFT:p-=e.height/2;break;case sc.BOTTOM:case sc.BOTTOM_RIGHT:case sc.BOTTOM_LEFT:p-=e.height}n.attr("transform",`translate(${f}, ${p})`)}},{Directions:Th,Positions:sc});function Ph(t,e,n,i){var r="ratio"in i?i.ratio:.5;return t.getPointAtRatio(r)}function _h(t,e,n,i){var r="length"in i?i.length:20;return t.getPointAtLength(r)}function kh(t){return function(e,n,i,r){if(i instanceof Element){var o,s=this.paper.findView(i);return o=s?s.isNodeConnection(i)?Ch(s,"fixedAt"in r?r.fixedAt:"50%"):s.getNodeBBox(i).center():new Kt,t.call(this,e,n,o,r)}return t.apply(this,arguments)}}function Ch(t,e){var n=parseFloat(e);return Ws(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}const Lh=kh((function(t,e,n,i){var r=1e6,o=t.getConnection(),s=t.getConnectionSubdivisions(),a=new ee(n.clone().offset(0,r),n.clone().offset(0,-r)),l=new ee(n.clone().offset(r,0),n.clone().offset(-r,0)),c=a.intersect(o,{segmentSubdivisions:s}),u=l.intersect(o,{segmentSubdivisions:s}),h=[];return c&&Array.prototype.push.apply(h,c),u&&Array.prototype.push.apply(h,u),h.length>0?n.chooseClosest(h):"fallbackAt"in i?Ch(t,i.fallbackAt):Mh(t,e,n,i)})),Mh=kh((function(t,e,n,i){return t.getClosestPoint(n)||new Kt}));function Oh(t,e,n){if(go(n)){const{x:i,y:r}=n;if(isFinite(r)){const n=new ee(e,t),{start:i,end:o}=n.parallel(r);e=i,t=o}n=i}if(!isFinite(n))return t;var i=t.distance(e);return 0===n&&i>0?t:t.move(e,-Math.min(n,i-1))}function Nh(t){var e=t.getAttribute("stroke-width");return null===e?0:parseFloat(e)||0}function Rh(t,e,n,i){var r=e.getNodeBBox(n);i.stroke&&r.inflate(Nh(n)/2);var o=t.intersect(r);return Oh(o?t.start.chooseClosest(o):t.end,t.start,i.offset)}var Fh="segmentSubdivisons",Bh="shapeBBox";const Ih=function(t,e,n,i){let{offset:r,alignOffset:o,align:s}=i;return s&&function(t,e,n=0){let i,r,o,s;const{start:a,end:l}=t;switch(e){case"left":i="x",r=l,o=a,s=-1;break;case"right":i="x",r=a,o=l,s=1;break;case"top":i="y",r=l,o=a,s=-1;break;case"bottom":i="y",r=a,o=l,s=1;break;default:return}a[i]<l[i]?r[i]=o[i]:o[i]=r[i],isFinite(n)&&(r[i]+=s*n,o[i]+=s*n)}(t,s,o),Oh(t.end,t.start,r)},Dh=Rh,Vh=function(t,e,n,i){var r=e.model.angle();if(0===r)return Rh(t,e,n,i);var o=e.getNodeUnrotatedBBox(n);i.stroke&&o.inflate(Nh(n)/2);var s=o.center(),a=t.clone().rotate(s,r),l=a.setLength(1e6).intersect(o);return Oh(l?a.start.chooseClosest(l).rotate(s,-r):t.end,t.start,i.offset)},zh=function(t,e,n,i){var r,o,s=i.selector,a=t.end;if(r="string"==typeof s?e.findNode(s):!1===s?n:Array.isArray(s)?Is(n,s):function(t){if(!t)return null;var e=t;do{var n=e.tagName;if("string"!=typeof n)return null;if("G"===(n=n.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==n)break;e=e.nextElementSibling}}while(e);return e}(n),!xn.isSVGGraphicsElement(r)){if(r===n||!xn.isSVGGraphicsElement(n))return a;r=n}var l,c=e.getNodeShape(r),u=e.getNodeMatrix(r),h=e.getRootTranslateMatrix(),d=e.getRootRotateMatrix(),f=h.multiply(d).multiply(u),p=f.inverse(),g=xn.transformLine(t,p),m=g.start.clone(),v=e.getNodeData(r);if(!1===i.insideout&&(v[Bh]||(v[Bh]=c.bbox()),v[Bh].containsPoint(m)))return a;if(c instanceof ke){var y=i.precision||2;v[Fh]||(v[Fh]=c.getSegmentSubdivisions({precision:y})),l={precision:y,segmentSubdivisions:v[Fh]}}!0===i.extrapolate&&g.setLength(1e6),(o=g.intersect(c,l))?xn.isArray(o)&&(o=m.chooseClosest(o)):!0===i.sticky&&(o=c instanceof ge?c.pointNearestToPoint(m):c instanceof se?c.intersectionWithLineFromCenterToPoint(m):c.closestPoint(m,l));var b=o?xn.transformPoint(o,f):a,w=i.offset||0;return i.stroke&&(w+=Nh(r)/2),Oh(b,t.start,w)};function jh(t){return function(e,n,i,r){var o=!!r.rotate,s=o?e.getNodeUnrotatedBBox(n):e.getNodeBBox(n),a=s[t](),l=r.dx;if(l){var c=Ws(l);l=parseFloat(l),isFinite(l)&&(c&&(l/=100,l*=s.width),a.x+=l)}var u=r.dy;if(u){var h=Ws(u);u=parseFloat(u),isFinite(u)&&(h&&(u/=100,u*=s.height),a.y+=u)}return o?a.rotate(e.model.getBBox().center(),-e.model.angle()):a}}const $h=jh("center"),Uh=jh("topMiddle"),Gh=jh("bottomMiddle"),qh=jh("leftMiddle"),Hh=jh("rightMiddle"),Wh=jh("origin"),Yh=jh("topRight"),Xh=jh("bottomLeft"),Zh=jh("corner"),Kh=kh((function(t,e,n,i){var r=t.model.angle(),o=t.getNodeBBox(e),s=o.center(),a=o.origin(),l=o.corner(),c=i.padding;if(isFinite(c)||(c=0),a.y+c<=n.y&&n.y<=l.y-c){var u=n.y-s.y;s.x+=0===r||180===r?0:1*u/Math.tan(Ot(r)),s.y+=u}else if(a.x+c<=n.x&&n.x<=l.x-c){var h=n.x-s.x;s.y+=90===r||270===r?0:h*Math.tan(Ot(r)),s.x+=h}return s})),Jh=kh((function(t,e,n,i){var r,o,s,a=!!i.rotate;a?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e);var l,c=i.padding;switch(isFinite(c)&&r.inflate(c),a&&n.rotate(s,o),r.sideNearestToPoint(n)){case"left":l=r.leftMiddle();break;case"right":l=r.rightMiddle();break;case"top":l=r.topMiddle();break;case"bottom":l=r.bottomMiddle()}return a?l.rotate(s,-o):l})),Qh=function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)},td=vh.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){vh.prototype.init.apply(this,arguments);const{options:{paper:t}}=this;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){const e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach((t=>{e.push(...this._resolveDrawGridOption(t))})),e},removeGrid(){const{_gridCache:t}=this;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){const{options:{paper:t}}=this,{_gridSettings:e}=this;if(this.removeGrid(),0===e.length)return;const n=t.options.drawGridSize||t.options.gridSize;if(n<=1)return;const i=this._getGridRefs();e.forEach(((e,r)=>{const o="pattern_"+r,s=Lo({},e),{scaleFactor:a=1}=s;let l;s.width=n*a||1,s.height=n*a||1,i.exist(o)?l=i.get(o):(l=xn("pattern",{id:o,patternUnits:"userSpaceOnUse"},xn(s.markup)),i.add(o,l)),po(s.render)&&s.render(l.node.firstChild,s,t),l.attr({width:s.width,height:s.height})})),i.root.appendTo(this.el),this.updateGrid()},updateGrid(){const{_gridCache:t,_gridSettings:e,options:{paper:n}}=this;if(!t)return;const{root:i,patterns:r}=t,{x:o,y:s,width:a,height:l}=n.getArea();i.attr({x:o,y:s,width:a,height:l});for(const t in r)r[t].attr({x:-o,y:-s});e.forEach(((t,e)=>{if(po(t.update)){const i=r["pattern_"+e];t.update(i.node.firstChild,t,n)}}))},_getGridRefs(){let{_gridCache:t}=this;if(t)return t;const e=xn("defs"),n=xn("svg",{width:"100%",height:"100%"},[e]);return t=this._gridCache={root:n,patterns:{},add:function(t,i){const r=xn("rect",{width:"100%",height:"100%",fill:`url(#${t})`});e.append(i),n.append(r),this.patterns[t]=i},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}},t},_resolveDrawGridOption(t){var e=this.options.patterns;if(eo(t)&&Array.isArray(e[t]))return e[t].map((function(t){return no({},t)}));var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if(i||r||n.markup||(r="dot"),r&&Array.isArray(e[r])){var o=e[r].map((function(t){return no({},t)})),s=Array.isArray(n.args)?n.args:[n.args||{}];io(s[0],To(t,"args"));for(var a=0;a<s.length;a++)o[a]&&no(o[a],s[a]);return o}return i?n:[n]}}),ed={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},nd=1/0,id=9007199254740991,rd=Nc.Highlighting,od={[rd.DEFAULT]:{name:"stroke",options:{padding:3}},[rd.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[rd.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},sd=[{name:mh.GRID},{name:mh.BACK},{name:mh.CELLS},{name:mh.LABELS},{name:mh.FRONT},{name:mh.TOOLS}],ad=Sc.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:Dc,linkView:gh,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:od,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){const{cellNamespace:t}=this.model.get("cells"),e=Is(t,["standard","Link"]);if(!e)throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.");return new e},defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"boundary"},connectionStrategy:null,validateMagnet:function(t,e,n){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,n,i,r,o){return("target"===r?n:t)instanceof Dc},embeddingMode:!1,validateEmbedding:function(t,e){return!0},validateUnembedding:function(t){return!0},findParentBy:"bbox",frontParentOnly:!0,interactive:{labelMove:!1},linkPinning:!0,allowLink:null,clickThreshold:0,moveThreshold:0,magnetThreshold:0,sorting:ed.APPROX,frozen:!1,autoFreeze:!1,onViewUpdate:function(t,e,n,i,r){e&(t.FLAG_INSERT|t.FLAG_REMOVE)||i.mounting||i.isolate||r.requestConnectedLinksUpdate(t,n,i)},onViewPostponed:function(t,e,n){return n.forcePostponedViewUpdate(t,e)},beforeRender:null,afterRender:null,viewport:null,cellViewNamespace:null,routerNamespace:null,connectorNamespace:null,highlighterNamespace:d,anchorNamespace:g,linkAnchorNamespace:f,connectionPointNamespace:p,overflow:!1},events:{dblclick:"pointerdblclick",dbltap:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},stylesheet:"\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n ",svg:null,viewport:null,defs:null,tools:null,layers:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],FORM_CONTROL_TAG_NAMES:["TEXTAREA","INPUT","BUTTON","SELECT","OPTION"],GUARDED_TAG_NAMES:["SELECT"],MIN_SCALE:1e-6,init:function(){const{options:t}=this;t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&Ao(joint,"shapes")?joint.shapes:null);const e=this.model=t.model||new wc;this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates={id:null,priorities:[{},{},{}],unmountedCids:[],mountedCids:[],unmounted:{},mounted:{},count:0,keyFrozen:!1,freezeKey:null,sort:!1,disabled:!1,idle:!1}},startListening:function(){var t=this.model;this.listenTo(t,"add",this.onCellAdded).listenTo(t,"remove",this.onCellRemoved).listenTo(t,"change",this.onCellChange).listenTo(t,"reset",this.onGraphReset).listenTo(t,"sort",this.onGraphSort).listenTo(t,"batch:stop",this.onGraphBatchStop),this.on("cell:highlight",this.onCellHighlight).on("cell:unhighlight",this.onCellUnhighlight).on("transform",this.update)},onCellAdded:function(t,e,n){var i=n.position;this.isAsync()||!to(i)?this.renderView(t,n):(n.maxPosition===i&&this.freeze({key:"addCells"}),this.renderView(t,n),0===i&&this.unfreeze({key:"addCells"}))},onCellRemoved:function(t,e,n){const i=this.findViewByModel(t);i&&this.requestViewUpdate(i,i.FLAG_REMOVE,i.UPDATE_PRIORITY,n)},onCellChange:function(t,e){if(t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===ed.APPROX){const n=this.findViewByModel(t);n&&this.requestViewUpdate(n,n.FLAG_INSERT,n.UPDATE_PRIORITY,e)}},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){if(!this.isFrozen()){var e=t&&t.batchName,n=this.model;if(!this.isAsync()){var i=this.UPDATE_DELAYING_BATCHES;i.includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t)}var r=this.SORT_DELAYING_BATCHES;r.includes(e)&&!n.hasActiveBatch(r)&&this.sortViews()}},cloneOptions:function(){const{options:t}=this,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&"undefined"!=typeof joint&&Ao(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),po(e)||(t.defaultConnector=uo(e)),po(n)||(t.defaultRouter=uo(n)),po(i)||(t.defaultConnectionPoint=uo(i)),po(r)||(t.defaultAnchor=uo(r)),po(o)||(t.defaultLinkAnchor=uo(o)),go(l)&&(t.interactive=no({},l)),go(s)&&(t.highlighting=ro({},s,od))},children:function(){var t=xn.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:Rs("paper-background"),selector:"background",style:{position:"absolute",inset:0}},{namespaceURI:t.svg,tagName:"svg",attributes:{width:"100%",height:"100%","xmlns:xlink":t.xlink},selector:"svg",style:{position:"absolute",inset:0},children:[{tagName:"defs",selector:"defs"},{tagName:"g",className:Rs("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers},getLayerView(t){const{_layers:e}=this;if(t in e)return e[t];throw new Error(`dia.Paper: Unknown layer "${t}"`)},getLayerNode(t){return this.getLayerView(t).el},render:function(){this.renderChildren();const{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:r,defs:o,layers:s}=e;return t.style.position="relative",r.style.overflow=n.overflow?"visible":"hidden",this.svg=r,this.defs=o,this.layers=s,this.renderLayers(),xn.ensureId(r),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&xn(this.svg).prepend(xn.createSVGStyle(t))},createLayer(t){return t===mh.GRID?new td({name:t,paper:this,patterns:this.constructor.gridPatterns}):new vh({name:t})},renderLayers:function(t=sd){this.removeLayers(),t.forEach((({name:t,sorted:e})=>{const n=this.createLayer(t);this.layers.appendChild(n.el),this._layers[t]=n}));const e=this.getLayerView(mh.CELLS),n=this.getLayerView(mh.TOOLS),i=this.getLayerView(mh.LABELS);this.tools=n.el,this.cells=this.viewport=e.el,e.vel.addClass(Rs("viewport")),i.vel.addClass(Rs("viewport")),e.el.style.webkitUserSelect="none",e.el.style.userSelect="none",i.el.style.webkitUserSelect="none",i.el.style.userSelect="none"},removeLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].remove(),delete t[e]}))},resetLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].removePivots()}))},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){const i=this.matrix();return void 0===t?xn.matrixToScale(i):(void 0===e&&(e=t),t=Math.max(t||0,this.MIN_SCALE),e=Math.max(e||0,this.MIN_SCALE),i.a=t,i.d=e,this.matrix(i,n),this)},scaleUniformAtPoint:function(t,e,n){const{a:i,d:r,e:o,f:s}=this.matrix();if((t=Math.max(t||0,this.MIN_SCALE))===i&&t===r)return this;const a=xn.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t);return this.matrix(a,n),this},translate:function(t,e,n){const i=this.matrix();return void 0===t?xn.matrixToTranslate(i):(t||(t=0),e||(e=0),i.e===t&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e={}){var n=this.layers;if(void 0===t){var i=n.getAttribute("transform");return(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=n.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),xn.createSVGMatrix(t)}const r=this.matrix(),o=xn.createSVGMatrix(t),s=this._viewportTransformString,a=xn.matrixToTransformString(o);if(a===s)return this;if(!s&&xn.matrixToTransformString()===a)return this;const{a:l,d:c,e:u,f:h}=o;return n.setAttribute("transform",a),this._viewportMatrix=o,this._viewportTransformString=n.getAttribute("transform"),l===r.a&&c===r.d||this.trigger("scale",l,c,e),u===r.e&&h===r.f||this.trigger("translate",u,h,e),this.trigger("transform",o,e),this},clientMatrix:function(){return xn.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof Nc)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a=r[o],l=this.findViewByModel(a);if(l){var c=["UPDATE"];a.getTargetCell()===i&&c.push("TARGET"),a.getSourceCell()===i&&c.push("SOURCE");var u=Math.max(e+1,l.UPDATE_PRIORITY);this.scheduleViewUpdate(l,l.getFlag(c),u,n)}}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof Nc))return!1;var n=t.model;if(n.isElement())return!1;if(!(e&t.getFlag(["SOURCE","TARGET"]))){var i={silent:!0},r=0,o=this.findViewByModel(n.getSourceCell());o&&!this.isViewMounted(o)&&(r=this.dumpView(o,i),t.updateEndMagnet("source"));var s=0,a=this.findViewByModel(n.getTargetCell());if(a&&!this.isViewMounted(a)&&(s=this.dumpView(a,i),t.updateEndMagnet("target")),0===r&&0===s)return!this.dumpView(t,i)}return!1},requestViewUpdate:function(t,e,n,i){i||(i={}),this.scheduleViewUpdate(t,e,n,i);var r=this.isAsync();if(!(this.isFrozen()||r&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES))){var o=this.updateViews(i);r&&this.notifyAfterRender(o,i)}},scheduleViewUpdate:function(t,e,n,i){const{_updates:r,options:o}=this;r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze());const{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:c}=t;let u=r.priorities[n];if(u||(u=r.priorities[n]={}),n>l)for(let t=n-1;t>=l;t--){const e=r.priorities[t];e&&c in e&&(u[c]|=e[c],delete e[c])}let h=u[c]||0;if((h&e)===e)return;h||r.count++,e&s&&h&a?u[c]^=a:e&a&&h&s&&(u[c]^=s),u[c]|=e;const d=o.onViewUpdate;"function"==typeof d&&d.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,n=t.cid,i=e.priorities[t.UPDATE_PRIORITY],r=this.registerMountedView(t)|i[n];return delete i[n],r},dumpView:function(t,e={}){const n=this.dumpViewUpdate(t);if(!n)return 0;const i=!e.silent;i&&this.notifyBeforeRender(e);const r=this.updateView(t,n,e);if(i){const n={updated:1,priority:t.UPDATE_PRIORITY};this.notifyAfterRender(n,e)}return r},updateView:function(t,e,n){if(!t)return 0;const{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof Nc){if(e&i)return this.removeView(s),0;if(e&r){const n=!!(e&o);n&&(e^=o),this.insertView(t,n),e^=r}}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){var n=this.findViewByModel(t);return n?(this.dumpView(n,e),n):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;if(e in n.unmounted)return 0;var i=n.unmounted[e]|=t.FLAG_INSERT;return n.unmountedCids.push(e),delete n.mounted[e],i},registerMountedView:function(t){var e=t.cid,n=this._updates;if(e in n.mounted)return 0;n.mounted[e]=!0,n.mountedCids.push(e);var i=n.unmounted[e]||0;return delete n.unmounted[e],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){var e=io({},t,{viewport:null});this.checkViewport(e),this.updateViews(e)},updateViews:function(t){let e;this.notifyBeforeRender(t);let n=0,i=0,r=id;do{i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r)}while(!e.empty);const o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){const t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;n>0&&n--;)for(let i in t[e[n]])return!0;return!1},updateViewsAsync:function(t,e){t||(t={}),e||(e={processed:0,priority:id});const{_updates:n,options:i}=this,r=n.id;if(r){Gs(r),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);const o=this.updateViewsBatch(t),s=io({},t,{mountBatchSize:1e3-o.mounted,unmountBatchSize:1e3-o.unmounted}),a=this.checkViewport(s),l=a.unmounted,c=a.mounted;let u=e.processed;const h=n.count;o.updated>0?(u+=o.updated+o.unmounted,o.processed=u,e.priority=Math.min(o.priority,e.priority),o.empty&&0===c?(o.unmounted+=l,o.mounted+=c,o.priority=e.priority,this.notifyAfterRender(o,t),e.processed=0,e.priority=id,n.count=0):e.processed=u):n.idle||i.autoFreeze&&(this.freeze(),n.idle=!0,this.trigger("render:idle",t));const d=t.progress;if(h&&"function"==typeof d&&d.call(this,o.empty,u,h,o,this),n.id!==r)return}if(n.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");n.id=Us(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t={}){let e=t.beforeRender;"function"!=typeof e&&(e=this.options.beforeRender,"function"!=typeof e)||e.call(this,t,this)},notifyAfterRender:function(t,e={}){let n=e.afterRender;"function"!=typeof n&&(n=this.options.afterRender),"function"==typeof n&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){t||(t={});var e=t.batchSize||nd,n=this._updates,i=0,r=0,o=0,s=0,a=id,l=!0,c=this.options,u=n.priorities,h="viewport"in t?t.viewport:c.viewport;"function"!=typeof h&&(h=null);var d=c.onViewPostponed;"function"!=typeof d&&(d=null);var f=Object.keys(u);t:for(var p=0,g=f.length;p<g;p++){var m=+f[p],v=u[m];for(var y in v){if(i>=e){l=!1;break t}var b=Tc[y];if(b){var w=v[y];if(!(w&b.FLAG_REMOVE)){var x=y in n.unmounted;if(b.DETACHABLE&&h&&!h.call(this,b,!x,this)){x||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[y]|=w,delete v[y],o++;continue}x&&(w|=b.FLAG_INSERT,s++),w|=this.registerMountedView(b)}var A=this.updateView(b,w,t);A>0&&(v[y]=A,!d||!d.call(this,b,A,this)||v[y])?(r++,l=!1):(a>m&&(a=m),i++,delete v[y])}else delete v[y]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){const t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=Tc[e[r]];return i},getMountedViews:function(){const t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=Tc[e[r]];return i},checkUnmountedViews:function(t,e){e||(e={});var n=0;"function"!=typeof t&&(t=null);for(var i=("mountBatchSize"in e?e.mountBatchSize:1/0),r=this._updates,o=r.unmountedCids,s=r.unmounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var u=Tc[c];if(u)if(u.DETACHABLE&&t&&!t.call(this,u,!1,this))o.push(c);else{n++;var h=this.registerMountedView(u);h&&this.scheduleViewUpdate(u,h,u.UPDATE_PRIORITY,{mounting:!0})}}}return o.splice(0,a),n},checkMountedViews:function(t,e){e||(e={});var n=0;if("function"!=typeof t)return n;for(var i=("unmountBatchSize"in e?e.unmountBatchSize:1/0),r=this._updates,o=r.mountedCids,s=r.mounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var u=Tc[c];u&&(u.DETACHABLE&&!t.call(this,u,!0,this)?(n++,this.registerUnmountedView(u)&&this.detachView(u)):o.push(c))}}return o.splice(0,a),n},checkViewVisibility:function(t,e={}){let n="viewport"in e?e.viewport:this.options.viewport;"function"!=typeof n&&(n=null);const i=this._updates,{mounted:r,unmounted:o}=i,s=!t.DETACHABLE||!n||n.call(this,t,!1,this);let a=!1,l=!1;if(t.cid in r&&!s){this.registerUnmountedView(t)&&this.detachView(t);const e=i.mountedCids.indexOf(t.cid);i.mountedCids.splice(e,1),a=!0}if(!a&&t.cid in o&&s){const e=i.unmountedCids.indexOf(t.cid);i.unmountedCids.splice(e,1);var c=this.registerMountedView(t);c&&this.scheduleViewUpdate(t,c,t.UPDATE_PRIORITY,{mounting:!0}),l=!0}return{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e=io({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n="viewport"in e?e.viewport:this.options.viewport,i=this.checkMountedViews(n,e);if(i>0){var r=this._updates.unmountedCids;e.mountBatchSize=Math.min(r.length-i,e.mountBatchSize)}return{mounted:this.checkUnmountedViews(n,e),unmounted:i}},freeze:function(t){t||(t={});var e=this._updates,n=t.key,i=this.options.frozen,r=e.freezeKey;if(n&&n!==r){if(i&&r)return;e.freezeKey=n,e.keyFrozen=i}this.options.frozen=!0;var o=e.id;e.id=null,this.isAsync()&&o&&Gs(o)},unfreeze:function(t){t||(t={});var e=this._updates,n=t.key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===ed.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,n=t.height;return to(e)||(e=this.el.clientWidth),to(n)||(n=this.el.clientHeight),{width:e,height:n}},setDimensions:function(t,e,n={}){const{options:i}=this,{width:r,height:o}=i;let s=void 0===t?r:t,a=void 0===e?o:e;if(r===s&&o===a)return;i.width=s,i.height=a,this._setDimensions();const l=this.getComputedSize();this.trigger("resize",l.width,l.height,n)},_setDimensions:function(){const{options:t}=this;let e=t.width,n=t.height;to(e)&&(e=`${Math.round(e)}px`),to(n)&&(n=`${Math.round(n)}px`),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=Qr(t)?t:no({gridWidth:t,gridHeight:e,padding:n},i);const{x:r,y:o,width:s,height:a}=this.getFitToContentArea(i),{sx:l,sy:c}=this.scale();return this.translate(-r*l,-o*c,i),this.setDimensions(s*l,a*c,i),new ge(r,o,s,a)},getFitToContentArea:function(t={}){const e=t.gridWidth||1,n=t.gridHeight||1,i=Js(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,n),s=t.maxWidth||Number.MAX_VALUE,a=t.maxHeight||Number.MAX_VALUE,l=t.allowNewOrigin,c="contentArea"in t?new ge(t.contentArea):this.getContentArea(t),{sx:u,sy:h}=this.scale();c.x*=u,c.y*=h,c.width*=u,c.height*=h;let d=Math.ceil((c.width+c.x)/e),f=Math.ceil((c.height+c.y)/n);t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n;let p=0;("negative"===l&&c.x<0||"positive"===l&&c.x>=0||"any"===l)&&(p=Math.ceil(-c.x/e)*e,p+=i.left,d+=p);let g=0;return("negative"===l&&c.y<0||"positive"===l&&c.y>=0||"any"===l)&&(g=Math.ceil(-c.y/n)*n,g+=i.top,f+=g),d+=i.right,f+=i.bottom,d=Math.max(d,r),f=Math.max(f,o),d=Math.min(d,s),f=Math.min(f,a),new ge(-p/u,-g/h,d/u,f/h)},transformToFitContent:function(t){let e,n;if(t||(t={}),"contentArea"in t){const i=t.contentArea;e=this.localToPaperRect(i),n=new Kt(i)}else e=this.getContentBBox(t),n=this.paperToLocalPoint(e);if(!e.width||!e.height)return;io(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});const i=Js(t.padding),r=t.minScaleX||t.minScale,o=t.maxScaleX||t.maxScale,s=t.minScaleY||t.minScale,a=t.maxScaleY||t.maxScale;let l;if(t.fittingBBox)l=t.fittingBBox;else{const t=this.translate(),e=this.getComputedSize();l={x:t.tx,y:t.ty,width:e.width,height:e.height}}l=new ge(l).moveAndExpand({x:i.left,y:i.top,width:-i.left-i.right,height:-i.top-i.bottom});const c=this.matrix(),{a:u,d:h,e:d,f}=c;let p=l.width/e.width*u,g=l.height/e.height*h;if(t.preserveAspectRatio&&(p=g=Math.min(p,g)),t.scaleGrid){const e=t.scaleGrid;p=e*Math.floor(p/e),g=e*Math.floor(g/e)}p=Math.min(o,Math.max(r,p)),g=Math.min(a,Math.max(s,g));const m=p/u,v=g/h;let y=l.x-n.x*p-d,b=l.y-n.y*g-f;switch(t.verticalAlign){case"middle":b+=(l.height-e.height*v)/2;break;case"bottom":b+=l.height-e.height*v}switch(t.horizontalAlign){case"middle":y+=(l.width-e.width*m)/2;break;case"right":y+=l.width-e.width*m}c.a=p,c.d=g,c.e=y,c.f=b,this.matrix(c,t)},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new ge:xn(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(...t){const{restrictTranslate:e}=this.options;let n;return n=po(e)?e.apply(this,t):!0===e?this.getArea():e?new ge(e):null,n},createViewForModel:function(t){const{options:e}=this;var n,i,r=e.cellViewNamespace,o=t.get("type")+"View",s=Is(r,o,".");return t.isLink()?(n=e.linkView,i=gh):(n=e.elementView,i=Dc),new(n.prototype instanceof xc?s||n:n.call(this,t)||s||i)({model:t,interactive:e.interactive,labelsLayer:!0===e.labelsLayer?mh.LABELS:e.labelsLayer})},removeView:function(t){const{id:e}=t,{_views:n,_updates:i}=this,r=n[e];if(r){var{cid:o}=r;const{mounted:t,unmounted:s}=i;r.remove(),delete n[e],delete t[o],delete s[o]}return r},renderView:function(t,e){const{id:n}=t,i=this._views;let r,o,s=!0;return n in i&&(r=i[n],r.model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&(r=i[n]=this.createViewForModel(t),r.paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(Eo(r,"initFlag"))),this.requestViewUpdate(r,o,r.UPDATE_PRIORITY,e),r},onImageDragStart:function(){return!1},resetViews:function(t,e){e||(e={}),t||(t=[]),this._resetUpdates(),this.removeViews();const n=this.options.autoFreeze?null:"reset";this.freeze({key:n});for(var i=0,r=t.length;i<r;i++)this.renderView(t[i],e);this.unfreeze({key:n}),this.sortViews()},removeViews:function(){oo(this._views,"remove"),this._views={}},sortViews:function(){this.isExactSorting()&&(this.isFrozen()?this._updates.sort=!0:this.sortViewsExact())},sortViewsExact:function(){var t=Array.from(this.cells.childNodes).filter((t=>t.getAttribute("model-id"))),e=this.model.get("cells");!function(t,n){var i=(t=Ns(t).toArray()).map((function(t){var e=t.parentNode,n=e.insertBefore(document.createTextNode(""),t.nextSibling);return function(){if(e===this)throw new Error("You can't sort elements if any one is a descendant of another.");e.insertBefore(this,n),e.removeChild(n)}}));t.sort((function(t,n){var i=e.get(t.getAttribute("model-id")),r=e.get(n.getAttribute("model-id")),o=i.attributes.z||0,s=r.attributes.z||0;return o===s?0:o<s?-1:1}));for(var r=0;r<i.length;r++)i[r].call(t[r])}(t)},insertView:function(t,e){const n=this.getLayerView(mh.CELLS),{el:i,model:r}=t;this.options.sorting===ed.APPROX?n.insertSortedNode(i,r.get("z")):n.insertNode(i),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){var e=eo(t)?this.cells.querySelector(t):t instanceof Ns?t[0]:t,n=this.findAttribute("model-id",e);if(n)return this._views[n]},findViewByModel:function(t){var e=eo(t)||to(t)?t:t&&t.id;return this._views[e]},findViewsFromPoint:function(t){return t=new Kt(t),this.model.getElements().map(this.findViewByModel,this).filter((function(e){return e&&e.vel.getBBox({target:this.cells}).containsPoint(t)}),this)},findViewsInArea:function(t,e){e=io(e||{},{strict:!1}),t=new ge(t);var n=this.model.getElements().map(this.findViewByModel,this),i=e.strict?"containsRect":"intersect";return n.filter((function(e){return e&&t[i](e.vel.getBBox({target:this.cells}))}),this)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t,...e){"string"==typeof t&&this.trigger("tools:event",t,...e)},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){var n=new Kt(t,e);return xn.transformPoint(n,this.matrix())},localToPaperRect:function(t,e,n,i){var r=new ge(t,e,n,i);return xn.transformRect(r,this.matrix())},paperToLocalPoint:function(t,e){var n=new Kt(t,e);return xn.transformPoint(n,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){var r=new ge(t,e,n,i);return xn.transformRect(r,this.matrix().inverse())},localToClientPoint:function(t,e){var n=new Kt(t,e);return xn.transformPoint(n,this.clientMatrix())},localToClientRect:function(t,e,n,i){var r=new ge(t,e,n,i);return xn.transformRect(r,this.clientMatrix())},clientToLocalPoint:function(t,e){var n=new Kt(t,e);return xn.transformPoint(n,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){var r=new ge(t,e,n,i);return xn.transformRect(r,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,n,i){return this.localToPaperRect(t,e,n,i).offset(this.pageOffset())},pageToLocalPoint:function(t,e){var n=new Kt(t,e).difference(this.pageOffset());return this.paperToLocalPoint(n)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),o=new ge(t,e,n,i);return o.x-=r.x,o.y-=r.y,this.paperToLocalRect(o)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new Kt(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof gh))throw new Error("Must provide a linkView.");var e=t.model,n=this.options,i=this.model,r=i.constructor.validations;return!(!n.multiLinks&&!r.multiLinks.call(this,i,e)||!n.linkPinning&&!r.linkPinning.call(this,i,e)||"function"==typeof n.allowLink&&!n.allowLink.call(this,t,this))},getDefaultLink:function(t,e){return po(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t={}){let{highlighter:e,type:n}=t;const{highlighting:i,highlighterNamespace:r}=this.options;if(void 0===e){if(!i)return!1;if(n&&(e=i[n],!1===e))return!1;e||(e=i.default)}if(!e)return!1;eo(e)&&(e={name:e});const o=e.name,s=r[o];if(!s)throw new Error('Unknown highlighter ("'+o+'")');if("function"!=typeof s.highlight)throw new Error('Highlighter ("'+o+'") is missing required highlight() method');if("function"!=typeof s.unhighlight)throw new Error('Highlighter ("'+o+'") is missing required unhighlight() method');return{highlighter:s,options:e.options||{},name:o}},onCellHighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.highlight(t,e,o)},onCellUnhighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.unhighlight(t,e,o)},pointerdblclick:function(t){t.preventDefault(),t=$s(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerdblclick(t,n.x,n.y):this.trigger("blank:pointerdblclick",t,n.x,n.y)}},pointerclick:function(t){if(this.eventData(t).mousemoved<=this.options.clickThreshold){t=$s(t);var e=this.findView(t.target);if(this.guard(t,e))return;var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerclick(t,n.x,n.y):this.trigger("blank:pointerclick",t,n.x,n.y)}},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.contextMenuFired?this.contextMenuFired=!1:(t=$s(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.contextmenu(t,n.x,n.y):this.trigger("blank:contextmenu",t,n.x,n.y)}},pointerdown:function(t){t=$s(t);const{target:e,button:n}=t,i=this.findView(e),r=2===n;if(i){if(!r&&this.guard(t,i))return;const n=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName);this.options.preventDefaultViewAction&&!n&&t.preventDefault(),n&&i.preventDefaultInteraction(t);const o=this.customEventTrigger(t,i);if(o){if(o.isPropagationStopped())return;t.data=o.data}const s=e.closest("[magnet]");if(s&&i.el!==s&&i.el.contains(s)){const e=$s(new Ns.Event(t.originalEvent,{data:t.data,currentTarget:s}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped()){if(r)return;return void this.delegateDragEvents(i,e.data)}t.data=e.data}}if(r){this.contextMenuFired=!0;const e=new Ns.Event(t.originalEvent,{type:"contextmenu",data:t.data});this.contextMenuTrigger(e)}else{const e=this.snapToGrid(t.clientX,t.clientY);i?i.pointerdown(t,e.x,e.y):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,e.x,e.y)),this.delegateDragEvents(i,t.data)}},pointermove:function(t){var e=this.eventData(t);if(e.mousemoved||(e.mousemoved=0,this.undelegateEvents()),!(++e.mousemoved<=this.options.moveThreshold)){t=$s(t);var n=this.snapToGrid(t.clientX,t.clientY),i=e.sourceView;i?i.pointermove(t,n.x,n.y):this.trigger("blank:pointermove",t,n.x,n.y),this.eventData(t,e)}},pointerup:function(t){this.undelegateDocumentEvents();var e=$s(t),n=this.snapToGrid(e.clientX,e.clientY),i=this.eventData(t).sourceView;i?i.pointerup(e,n.x,n.y):this.trigger("blank:pointerup",e,n.x,n.y),e.isPropagationStopped()||this.pointerclick(new Ns.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=$s(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseover(t);else{if(this.el===t.target)return;this.trigger("blank:mouseover",t)}},mouseout:function(t){t=$s(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseout(t);else{if(this.el===t.target)return;this.trigger("blank:mouseout",t)}},mouseenter:function(t){t=$s(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseenter(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseenter",t)},mouseleave:function(t){t=$s(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseleave(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseleave",t)},_processMouseWheelEvtBuf:function(t,e,n){if("function"!=typeof t)throw new TypeError("Expected a function");let i,r,o,s,a,l,c=0,u=!1,h=!1,d=!0;const f=!e&&0!==e&&window&&"function"==typeof window.requestAnimationFrame;function p(e){const n=i,o=r;return i=r=void 0,c=e,s=t.apply(o,n),s}function g(t,e){return f?(window.cancelAnimationFrame(a),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){const n=t-l;return void 0===l||n>=e||n<0||h&&t-c>=o}function v(){const t=Date.now();if(m(t))return y(t);a=g(v,function(t){const n=t-c,i=e-(t-l);return h?Math.min(i,o-n):i}(t))}function y(t){return a=void 0,d&&i?p(t):(i=r=void 0,s)}function b(...t){const n=Date.now(),o=m(n);if(i=t,r=this,l=n,o){if(void 0===a)return function(t){return c=t,a=g(v,e),u?p(t):s}(l);if(h)return a=g(v,e),p(l)}return void 0===a&&(a=g(v,e)),s}return e=+e||0,Qr(n)&&(u=!!n.leading,h="maxWait"in n,o=h?Math.max(+n.maxWait||0,e):o,d="trailing"in n?!!n.trailing:d),b.cancel=()=>{void 0!==a&&function(t){if(f)return window.cancelAnimationFrame(t);clearTimeout(t)}(a),c=0,i=l=r=a=void 0},b.flush=()=>void 0===a?s:y(Date.now()),b.pending=()=>void 0!==a,b}((function(){const{event:t,deltas:e}=this._mw_evt_buffer,n=e.reduce(((t,e)=>{return t+((n=e)>50?50:n<-50?-50:n);var n}),0),i=Math.pow(.995,n),{x:r,y:o}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,r,o,i),this._mw_evt_buffer={event:null,deltas:[]}}),20,{maxWait:20}),mousewheel:function(t){t=$s(t);const e=this.findView(t.target);if(this.guard(t,e))return;const n=t.originalEvent,i=this.snapToGrid(n.clientX,n.clientY),{deltaX:r,deltaY:o}=function(t){let e=0,n=0,i=0,r=0;return"detail"in t&&(n=t.detail),"wheelDelta"in t&&(n=-t.wheelDelta/120),"wheelDeltaY"in t&&(n=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=n,n=0),i="deltaX"in t?t.deltaX:10*e,r="deltaY"in t?t.deltaY:10*n,(i||r)&&t.deltaMode&&(1==t.deltaMode?(i*=40,r*=40):(i*=800,r*=800)),0===t.deltaX&&0!==t.deltaY&&t.shiftKey&&(i=r,r=0,e=n,n=0),i&&!e&&(e=i<1?-1:1),r&&!n&&(n=r<1?-1:1),{spinX:e,spinY:n,deltaX:i,deltaY:r}}(n),s=this._events["paper:pinch"];if(t.ctrlKey&&s&&s.length>0)n.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(o),this._processMouseWheelEvtBuf();else{const s=Math.max(-1,Math.min(1,n.wheelDelta));e?e.mousewheel(t,i.x,i.y,s):this.trigger("blank:mousewheel",t,i.x,i.y,s),this.trigger("paper:pan",t,r,o)}},onevent:function(t){var e=t.currentTarget,n=e.getAttribute("event");if(n){var i=this.findView(e);if(i){if(t=$s(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);i.onevent(t,n,r.x,r.y)}}},magnetEvent:function(t,e){var n=t.currentTarget;if(n.getAttribute("magnet")){var i=this.findView(n);if(i){if(t=$s(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);e.call(this,i,t,n,r.x,r.y)}}},onmagnet:function(t){if(2===t.button){this.contextMenuFired=!0,this.magnetContextMenuFired=!0;const e=new Ns.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget});this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()}else this.magnetEvent(t,(function(t,e,n,i,r){t.onmagnet(e,i,r)}))},magnetpointerdblclick:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetpointerdblclick(e,n,i,r)}))},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetContextMenuFired?this.magnetContextMenuFired=!1:this.magnetContextMenuTrigger(t)},magnetContextMenuTrigger:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetcontextmenu(e,n,i,r)}))},onlabel:function(t){var e=t.currentTarget,n=this.findView(e);if(!n)return;if(t=$s(t),this.guard(t,n))return;const i=this.customEventTrigger(t,n,e);if(i){if(i.isPropagationStopped())return;t.data=i.data}var r=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,r.x,r.y)},getPointerArgs(t){const e=$s(t),{x:n,y:i}=this.snapToGrid(e.clientX,e.clientY);return[e,n,i]},delegateDragEvents:function(t,e){e||(e={}),this.eventData({data:e},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){if("mousedown"===t.type&&2===t.button)return!0;if(this.options.guard&&this.options.guard(t,e))return!0;if(t.data&&void 0!==t.data.guarded)return t.data.guarded;const{target:n}=t;return!!this.GUARDED_TAG_NAMES.includes(n.tagName)||!(e&&e.model&&e.model instanceof sl)&&this.el!==n&&!this.svg.contains(n)},setGridSize:function(t){const{options:e}=this;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(mh.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(mh.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",n=t.size||"auto auto",i=this.scale(),r=this.translate();Qr(e)&&(e=r.tx+i.sx*(e.x||0)+"px "+(r.ty+i.sy*(e.y||0))+"px"),Qr(n)&&(n=(n=new ge(n).scale(i.sx,i.sy)).width+"px "+n.height+"px");const{background:o}=this.childNodes;o.style.backgroundSize=n,o.style.backgroundPosition=e},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var n,i=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,s=Math.abs(e.quality)||1,a=this.constructor.backgroundPatterns[_o(r)];if(po(a)){t.width*=s,t.height*=s;var l=a(t,e);if(!(l instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=l.toDataURL("image/png"),r="repeat",Qr(i)?(i.width*=l.width/t.width,i.height*=l.height/t.height):void 0===i&&(e.size={width:l.width/s,height:l.height/s})}else n=t.src,void 0===i&&(e.size={width:t.width,height:t.height});this.childNodes.background.style.opacity=o,this.childNodes.background.style.backgroundRepeat=r,this.childNodes.background.style.backgroundImage=`url(${n})`,this.updateBackgroundImage(e)}}else this.childNodes.background.style.backgroundImage=""},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){if(t=t||{},this.updateBackgroundColor(t.color),t.image){t=this._background=uo(t),js(t);var e=document.createElement("img");e.onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image}else this.drawBackgroundImage(null),this._background=null;return this},setInteractivity:function(t){this.options.interactive=t,oo(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!Qr(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name;if(e||(e=n+this.svg.id+Bs(JSON.stringify(t))),!this.isDefined(e)){var i=ea,r=i[n]&&i[n](t.args||{});if(!r)throw new Error("Non-existing filter "+n);var o=no({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});xn(r,o).appendTo(this.defs)}return e},defineGradient:function(t){if(!Qr(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{type:i,id:r=i+e.id+Bs(JSON.stringify(t)),stops:o,attrs:s={}}=t;if(this.isDefined(r))return r;const a=mo(o).map((({offset:t,color:e,opacity:n})=>xn("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1}))),l=xn(i,s,a);return l.id=r,l.appendTo(n),r},definePattern:function(t){if(!Qr(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+Bs(JSON.stringify(t)),markup:r,attrs:o={}}=t;if(!r)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(i))return i;const s=xn("pattern",{patternUnits:"userSpaceOnUse"});if(s.id=i,s.attr(o),"string"==typeof r)s.append(xn(r));else{const{fragment:t}=Fs(r);s.append(t)}return s.appendTo(n),i},defineMarker:function(t){if(!Qr(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+Bs(JSON.stringify(t)),markup:r,attrs:o={},markerUnits:s="userSpaceOnUse"}=t;if(this.isDefined(i))return i;const a=xn("marker",{orient:"auto",overflow:"visible",markerUnits:s});let l;if(a.id=i,a.attr(o),r){let t;if("string"==typeof r)t=xn(r),t=Array.isArray(t)?t:[t];else{const{fragment:e}=Fs(r);t=xn(e).children()}l=t.length>1?xn("g").append(t):t[0]}else{const{type:e="path"}=t;l=xn(e)}const c=To(t,"type","id","markup","attrs","markerUnits");return Object.keys(c).forEach((t=>{const e=c[t],n=l.attr(t);null==n?l.attr(t,e):"transform"===t&&l.attr(t,e+" "+n)})),l.appendTo(a),a.appendTo(n),i},customEventTrigger:function(t,e,n=e.el){const i=t.target.closest("[event]");if(i&&n!==i&&e.el.contains(i)){const e=$s(new Ns.Event(t.originalEvent,{data:t.data,currentTarget:i}));return this.onevent(e),e.isDefaultPrevented()&&t.preventDefault(),e}return null}},{sorting:ed,Layers:mh,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,n,i),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,n,i),e},flipX:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(2*n,0),r.scale(-1,1),r.drawImage(t,0,0,n,i),e},flipY:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(0,2*i),r.scale(1,-1),r.drawImage(t,0,0,n,i),e},watermark:function(t,e){e=e||{};var n=t.width,i=t.height,r=document.createElement("canvas");r.width=3*n,r.height=3*i;for(var o=r.getContext("2d"),s=to(e.watermarkAngle)?-e.watermarkAngle:-20,a=Ot(s),l=r.width/4,c=r.height/4,u=0;u<4;u++)for(var h=0;h<4;h++)(u+h)%2>0&&(o.setTransform(1,0,0,1,(2*u-1)*l,(2*h-1)*c),o.rotate(a),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){xn(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){xn(t).attr({fill:e.color})},update:function(t,e,n){const{sx:i,sy:r}=n.scale(),o=i<=1?e.thickness:e.thickness/i,s=r<=1?e.thickness:e.thickness/r;xn(t).attr({width:o,height:s})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",xn(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",xn(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",xn(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}]}}),ld=Sc.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){const{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}}),cd=Sc.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=no(this.options,t)).tools;if(!Array.isArray(e))return this;var n=t.relatedView;if(!(n instanceof Nc))return this;for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof ld&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}return this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t||(t={});var e=this.tools;if(!e)return this;for(var n=this.isRendered,i=0,r=e.length;i<r;i++){var o=e[i];n?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return this.isMounted()||this.mount(),n||(this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,n=t.length;e<n;e++)t[e].remove();this.tools=null},mount:function(){const{options:t,el:e}=this,{relatedView:n,layer:i=mh.TOOLS,z:r}=t;return n&&(i?n.paper.getLayerView(i).insertSortedNode(e,r):n.el.appendChild(e)),this}}),ud=ld.extend({name:"button",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},options:{distance:0,offset:0,scale:null,rotate:!1},onRender:function(){this.renderChildren(this.options.markup),this.update()},update:function(){return this.position(),this},position:function(){const{vel:t}=this;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){const{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=function(t,e){const{model:n}=t;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}(t,o);const c=t.model.angle();s||(l=l.bbox(c));const{x:u=0,y:h=0}=r;Ws(n)?n=parseFloat(n)/100*l.width:Fa(n)&&(n=Number(Da(n,l))),Ws(i)?i=parseFloat(i)/100*l.height:Fa(i)&&(i=Number(Da(i,l)));let d=xn.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return s&&(d=d.rotate(c)),d=d.translate(n+u-l.width/2,i+h-l.height/2),a&&(d=d.scale(a)),d},getLinkMatrix(){const{relatedView:t,options:e}=this,{offset:n=0,distance:i=0,rotate:r,scale:o}=e;let s,a,l;s=Ws(i)?t.getTangentAtRatio(parseFloat(i)/100):t.getTangentAtLength(i),s?(a=s.start,l=s.vector().vectorAngle(new Kt(1,0))||0):(a=t.getConnection().start,l=0);let c=xn.createSVGMatrix().translate(a.x,a.y).rotate(l).translate(0,n);return r||(c=c.rotate(-l)),o&&(c=c.scale(o)),c},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.options.action;"function"==typeof e&&e.call(this.relatedView,t,this.relatedView,this)}}}),hd=ud.extend({name:"remove",children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#FF1D00",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -3 -3 3 3 M -3 3 3 -3",fill:"none",stroke:"#FFFFFF","stroke-width":2,"pointer-events":"none"}}],options:{distance:60,offset:0,action:function(t,e,n){e.model.remove({ui:!0,tool:n.cid})}}}),dd=ld.extend({tagName:"path",xAxisVector:new Kt(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{scale:null},onRender:function(){this.update()},update:function(){var t,e,n=this.ratio,i=this.relatedView,r=i.getTangentAtRatio(n);if(r?(t=r.start,e=r.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(n),e=0),!t)return this;var o=xn.createSVGMatrix().translate(t.x,t.y).rotate(e);const{scale:s}=this.options;return s&&(o=o.scale(s)),this.vel.transform(o,{absolute:!0}),this},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.relatedView;e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),e.paper.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none"}},onPointerMove:function(t){var e=$s(t),n=this.paper.snapToGrid(e.clientX,e.clientY);this.relatedView.pointermove(e,n.x,n.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,i=$s(t),r=n.snapToGrid(i.clientX,i.clientY);e.pointerup(i,r.x,r.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),fd=dd.extend({name:"target-arrowhead",ratio:1,arrowheadType:"target",attributes:{d:"M -10 -8 10 0 -10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"target-arrowhead"}}),pd=dd.extend({name:"source-arrowhead",ratio:0,arrowheadType:"source",attributes:{d:"M 10 -8 -10 0 10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"source-arrowhead"}});var gd=function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},md=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};let vd=class extends wt{static{this.styles=x`
|
|
3
3
|
.available-magnet {
|
|
4
4
|
fill: green;
|
|
5
5
|
}
|
|
6
6
|
.available-cell rect {
|
|
7
7
|
stroke-dasharray: 5, 2;
|
|
8
|
-
}`}createRenderRoot(){return this.renderInHost?this:super.createRenderRoot()}constructor(){super(),this.renderInHost=!0,this.paper=null,this.namespace=c,this.height="600px",this.width="100%",this.portRadius=3,this.router="manhattan",this.templateHeight=30,this.templateWidth=80,this.templateSpacing=20,this.gridSize=10,this.gridColor="lightgrey",this.draggedElement=null,this.shapeFactory={Rectangle:t=>new
|
|
8
|
+
}`}createRenderRoot(){return this.renderInHost?this:super.createRenderRoot()}constructor(){super(),this.renderInHost=!0,this.paper=null,this.namespace=c,this.height="600px",this.width="100%",this.portRadius=3,this.router="manhattan",this.templateHeight=30,this.templateWidth=80,this.templateSpacing=20,this.gridSize=10,this.gridColor="lightgrey",this.draggedElement=null,this.shapeFactory={Rectangle:t=>new Ul(t),Polygon:t=>(t.transform={rotate:45},new Ul(t)),Ellipse:t=>new ql(t),Circle:t=>new Gl(t)},this.graph=this.createGraph()}firstUpdated(t){super.firstUpdated(t),this.paper=this.createPaper(this.renderRoot.querySelector("div")),document.addEventListener("keydown",(t=>{t.altKey&&"+"===t.key&&(t.preventDefault(),this.paper.scale(this.paper.scale().sx+.1,this.paper.scale().sy+.1))})),document.addEventListener("keydown",(t=>{t.altKey&&"-"===t.key&&(t.preventDefault(),this.paper.scale(this.paper.scale().sx-.1,this.paper.scale().sy-.1))})),document.addEventListener("keydown",(t=>{t.altKey&&"0"===t.key&&(t.preventDefault(),this.paper.scale())}));const e={label:"New",position:0,height:this.templateHeight,width:this.templateWidth,spacing:this.templateSpacing,color:"white",bgcolor:"blue",element:"Rectangle"};[{label:"Task",bgcolor:"#ADD8E6",color:"black"},{label:"Document",bgcolor:"#90EE90",color:"black"},{label:"Message",bgcolor:"#F08080",color:"black"},{label:"Score",bgcolor:"#E6E6FA",color:"black"},{label:"Ledger",bgcolor:"#FFA07A",color:"black"},{label:"Workflow",bgcolor:"#F5FFFA",color:"black"},{label:"Process",bgcolor:"#FFEBCD",color:"black"},{label:"If/Then",bgcolor:"#F0F8FF",element:"Ellipse",color:"black"},{label:"Poll",bgcolor:"#FFDAB9",element:"Ellipse",color:"black"},{label:"Advanced",bgcolor:"#F0FFF0",color:"black"}].forEach(((t,n)=>{const i=(n+1)*this.templateSpacing+n*this.templateHeight,r=Object.assign(e,{position:i},t);this.createTemplate(r)}))}createGraph(){return new wc({},{cellNamespace:this.namespace})}createPaper(t){const e=this,n=new ad({el:t,model:this.graph,width:e.width,height:e.height,gridSize:e.gridSize,drawGrid:!0,cellViewNamespace:this.namespace,background:{color:e.gridColor},defaultLink:()=>new ic({router:{name:e.router,args:{step:5}}}),interactive:{linkMove:!0},linkPinning:!1,markAvailable:!0,snapLinks:{radius:20},validateConnection:function(t,e,n,i,r,o){return t!==n&&null!==i}});return n.on("link:mouseenter",(t=>{this.showLinkTools(t)})),n.on("link:mouseleave",(t=>{t.removeTools()})),n.on("element:mouseenter",(t=>t.showTools())),n.on("element:mouseleave",(t=>t.hideTools())),n.on("selection:change",(function(t,n){e.graph.getCells().forEach((function(t){t.attr("body/stroke","none")})),t.forEach((function(t){t.attr("body/stroke","red"),t.attr("body/stroke-width",2)}))})),n}createStep(t){const e=this;t.on("element:pointerdown",(function(n){e.draggedElement=t.model.clone(),t.model.attr("body/fill","gray"),e.graph.addCell(e.draggedElement)})),t.on("element:pointerup",(function(){t.model.attr("body/fill",e.draggedElement.attr("body/fill"));var n=t.model.position(),i=e.draggedElement.position();t.model.position(i.x,i.y),e.draggedElement.position(n.x,n.y),e.draggedElement.addPorts([{group:"left"},{group:"top"},{group:"right"},{group:"bottom"}]),e.draggedElement.findView(e.paper).addTools(new cd({tools:[new hd]}))}))}createTemplate(t){const e=this.paper.el.clientWidth-t.spacing-t.width,n=this.shapeFactory[t.element??"Rectangle"]({position:{x:e,y:t.position},size:{width:t.width,height:t.height},attrs:{body:{fill:t.bgcolor??"blue"},label:{text:t.label,fill:t.color??"white"}},ports:{groups:{left:this.createPort("left"),top:this.createPort("top"),right:this.createPort("right"),bottom:this.createPort("bottom")}}});return this.graph.addCell(n),this.createStep(this.paper.findViewByModel(n)),n}createPort(t,e=this.portRadius,n="circle",i="orange",r="blue"){return{position:{name:t},attrs:{portBody:{magnet:!0,r:e,fill:i,stroke:r}},markup:[{tagName:n,selector:"portBody"}]}}showLinkTools(t){var e=new cd({tools:[new pd,new fd,new hd]});t.addTools(e)}render(){return tt`<slot><div></div></slot>`}};var yd;gd([Et({type:Boolean}),md("design:type",Object)],vd.prototype,"renderInHost",void 0),gd([Et({type:Object}),md("design:type",Object)],vd.prototype,"paper",void 0),gd([Et({type:Object}),md("design:type",wc)],vd.prototype,"graph",void 0),gd([Et({type:Object}),md("design:type",Object)],vd.prototype,"namespace",void 0),gd([Et({type:String}),md("design:type",String)],vd.prototype,"height",void 0),gd([Et({type:String}),md("design:type",String)],vd.prototype,"width",void 0),gd([Et({type:Number}),md("design:type",Number)],vd.prototype,"portRadius",void 0),gd([Et({type:String}),md("design:type",Object)],vd.prototype,"router",void 0),gd([Et({type:Number}),md("design:type",Number)],vd.prototype,"templateHeight",void 0),gd([Et({type:Number}),md("design:type",Number)],vd.prototype,"templateWidth",void 0),gd([Et({type:Number}),md("design:type",Number)],vd.prototype,"templateSpacing",void 0),gd([Et({type:Number}),md("design:type",Number)],vd.prototype,"gridSize",void 0),gd([Et({type:String}),md("design:type",String)],vd.prototype,"gridColor",void 0),vd=gd([(yd="qbo-flowchart",t=>"function"==typeof t?((t,e)=>(customElements.define(t,e),e))(yd,t):((t,e)=>{const{kind:n,elements:i}=e;return{kind:n,elements:i,finisher(e){customElements.define(t,e)}}})(yd,t)),md("design:paramtypes",[])],vd)})(),i})()));
|
|
9
9
|
//# sourceMappingURL=qbo4.ui-flowchart.min.js.map
|