@joint/core 4.2.0-alpha.0 → 4.2.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/geometry.js +2 -2
- package/dist/geometry.min.js +3 -2
- package/dist/joint.d.ts +280 -149
- package/dist/joint.js +1427 -475
- package/dist/joint.min.js +4 -3
- package/dist/joint.nowrap.js +1427 -475
- package/dist/joint.nowrap.min.js +4 -3
- package/dist/vectorizer.js +21 -8
- package/dist/vectorizer.min.js +4 -3
- package/dist/version.mjs +1 -1
- package/package.json +7 -7
- package/src/V/index.mjs +20 -5
- package/src/alg/Deque.mjs +126 -0
- package/src/cellTools/Boundary.mjs +15 -13
- package/src/cellTools/Button.mjs +7 -5
- package/src/cellTools/Control.mjs +37 -14
- package/src/cellTools/HoverConnect.mjs +5 -1
- package/src/cellTools/helpers.mjs +44 -3
- package/src/config/index.mjs +8 -0
- package/src/dia/Cell.mjs +26 -10
- package/src/dia/CellView.mjs +7 -0
- package/src/dia/Element.mjs +4 -2
- package/src/dia/ElementView.mjs +2 -1
- package/src/dia/HighlighterView.mjs +22 -0
- package/src/dia/LinkView.mjs +118 -98
- package/src/dia/Paper.mjs +697 -209
- package/src/dia/ToolView.mjs +4 -0
- package/src/dia/ToolsView.mjs +12 -3
- package/src/dia/attributes/text.mjs +4 -2
- package/src/dia/ports.mjs +202 -82
- package/src/elementTools/HoverConnect.mjs +14 -8
- package/src/env/index.mjs +6 -3
- package/src/layout/ports/port.mjs +30 -15
- package/src/layout/ports/portLabel.mjs +1 -1
- package/src/mvc/View.mjs +4 -0
- package/src/mvc/ViewBase.mjs +1 -1
- package/types/geometry.d.ts +64 -60
- package/types/joint.d.ts +205 -88
- package/types/vectorizer.d.ts +11 -1
package/dist/joint.nowrap.min.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/*! JointJS v4.2.0-alpha.
|
|
2
|
-
|
|
1
|
+
/*! JointJS v4.2.0-alpha.1 (2025-09-25) - JavaScript diagramming library
|
|
3
2
|
|
|
4
3
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
4
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
5
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
6
|
*/
|
|
8
|
-
var g,V,Vectorizer,joint=(t=>{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function M(t,e){return t(e={exports:{}},e.exports),e.exports}function N(t){return t&&t.Math==Math&&t}function O(t){try{return!!t()}catch(t){return!0}}function I(t){return St(_t(t))}function F(e,n){try{jt(yt,e,n)}catch(t){yt[e]=n}return n}function D(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++qt+$t).toString(36)}function z(t){return Wt[t]||(Wt[t]=D(t))}function j(t){return"function"==typeof t?t:void 0}function G(t,e){return arguments.length<2?j(Jt[t])||j(yt[t]):Jt[t]&&Jt[t][e]||yt[t]&&yt[t][e]}function U(t){return 0<t?ee(te(t),9007199254740991):0}function H(a){return function(t,e,n){var i,r=I(t),o=U(r.length),s=((t,e)=>(t=te(t))<0?ne(t+e,0):ie(t,e))(n,o);if(a&&e!=e){for(;s<o;)if((i=r[s++])!=i)return!0}else for(;s<o;s++)if((a||s in r)&&r[s]===e)return a||s||0;return!a&&-1}}function q(t,e){var n,i=I(t),r=0,o=[];for(n in i)!Mt(Yt,n)&&Mt(i,n)&&o.push(n);for(;e.length>r;)!Mt(i,n=e[r++])||~re(o,n)||o.push(n);return o}function $(t,e){return(t=de[ce(t)])==pe||t!=fe&&("function"==typeof e?O(e):!!e)}function W(t,e){var n,i,r,o=t.target,s=t.global,a=t.stat,l=s?yt:a?yt[o]||F(o,{}):(yt[o]||{}).prototype;if(l)for(n in e){if(i=e[n],r=t.noTargetGet?(r=me(l,n))&&r.value:l[n],!ge(s?n:o+(a?".":"#")+n,t.forced)&&void 0!==r){if(typeof i==typeof r)continue;g=p=f=d=c=u=h=void 0;for(var h=i,u=r,c=he(u),d=zt.f,f=Ft.f,p=0;p<c.length;p++){var g=c[p];Mt(h,g)||d(h,g,f(u,g))}}(t.sham||r&&r.sham)&&jt(i,"sham",!0),Zt(l,n,i,t)}}function Y(t){return Mt(ye,t)||(ve&&Mt(be,t)?ye[t]=be[t]:ye[t]=xe("Symbol."+t)),ye[t]}function X(){}function Z(t){Ne[Me][t]=!0}function J(t){throw t}function K(t,e){var n,i,r,o;return Mt(Re,t)?Re[t]:(n=[][t],i=!!Mt(e=e||{},"ACCESSORS")&&e.ACCESSORS,r=Mt(e,0)?e[0]:J,o=Mt(e,1)?e[1]:void 0,Re[t]=!!n&&!O(function(){if(i&&!bt)return 1;var t={length:-1};i?Oe(t,1,{enumerable:!0,get:J}):t[1]=1,n.call(t,r,o)}))}function Q(i,r,t){if(Ve(i),void 0===r)return i;switch(t){case 0:return function(){return i.call(r)};case 1:return function(t){return i.call(r,t)};case 2:return function(t,e){return i.call(r,t,e)};case 3:return function(t,e,n){return i.call(r,t,e,n)}}return function(){return i.apply(r,arguments)}}function nt(t,e,n){return Q(Fe,yt[t].prototype[e],n)}function it(t){return Object(_t(t))}function rt(t,e){var n;return new(void 0===(n=Be(t)&&("function"==typeof(n=t.constructor)&&(n===Array||Be(n.prototype))||Lt(n)&&null===(n=n[De]))?void 0:n)?Array:n)(0===e?0:e)}function ot(d){var f=1==d,p=2==d,g=3==d,m=4==d,v=6==d,y=7==d,b=5==d||v;return function(t,e,n,i){for(var r,o,s=it(t),a=St(s),l=Q(e,n,3),h=U(a.length),u=0,e=i||rt,c=f?e(t,h):p||y?e(t,0):void 0;u<h;u++)if((b||u in a)&&(o=l(r=a[u],u,s),d))if(f)c[u]=o;else if(o)switch(d){case 3:return!0;case 5:return r;case 6:return u;case 2:ze.call(c,r)}else switch(d){case 4:return!1;case 7:ze.call(c,r)}return v?-1:g||m?m:c}}function st(r){return function(t,e){var n,t=String(_t(t)),e=te(e),i=t.length;return e<0||i<=e?r?"":void 0:(n=t.charCodeAt(e))<55296||56319<n||e+1===i||(i=t.charCodeAt(e+1))<56320||57343<i?r?t.charAt(e):n:r?t.slice(e,e+2):i-56320+(n-55296<<10)+65536}}function at(){return this}var lt,ht,ut,ct,dt,ft,pt,gt,mt,vt,yt=N("object"==typeof globalThis&&globalThis)||N("object"==typeof window&&window)||N("object"==typeof self&&self)||N("object"==typeof e&&e)||function(){return this}()||Function("return this")(),bt=!O(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),e={}.propertyIsEnumerable,xt=Object.getOwnPropertyDescriptor,wt={f:xt&&!e.call({1:2},1)?function(t){t=xt(this,t);return!!t&&t.enumerable}:e},At=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Pt={}.toString,Et=function(t){return Pt.call(t).slice(8,-1)},Tt="".split,St=O(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==Et(t)?Tt.call(t,""):Object(t)}:Object,_t=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},Lt=function(t){return"object"==typeof t?null!==t:"function"==typeof t},kt=function(t,e){if(!Lt(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t))||"function"==typeof(n=t.valueOf)&&!Lt(i=n.call(t))||!e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},Ct={}.hasOwnProperty,Mt=function(t,e){return Ct.call(t,e)},Nt=yt.document,Ot=Lt(Nt)&&Lt(Nt.createElement),Rt=function(t){return Ot?Nt.createElement(t):{}},It=!bt&&!O(function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a}),Vt=Object.getOwnPropertyDescriptor,Ft={f:bt?Vt:function(t,e){if(t=I(t),e=kt(e,!0),It)try{return Vt(t,e)}catch(t){}if(Mt(t,e))return At(!wt.f.call(t,e),t[e])}},Bt=function(t){if(Lt(t))return t;throw TypeError(String(t)+" is not an object")},Dt=Object.defineProperty,zt={f:bt?Dt:function(t,e,n){if(Bt(t),e=kt(e,!0),Bt(n),It)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},jt=bt?function(t,e,n){return zt.f(t,e,At(1,n))}:function(t,e,n){return t[e]=n,t},Gt=yt[e="__core-js_shared__"]||F(e,{}),Ut=Function.toString,Ht=("function"!=typeof Gt.inspectSource&&(Gt.inspectSource=function(t){return Ut.call(t)}),Gt.inspectSource),e="function"==typeof(e=yt.WeakMap)&&/native code/.test(Ht(e)),n=M(function(t){(t.exports=function(t,e){return Gt[t]||(Gt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),qt=0,$t=Math.random(),Wt=n("keys"),Yt={},i=yt.WeakMap,Xt=(pt=e?(lt=Gt.state||(Gt.state=new i),ht=lt.get,ut=lt.has,ct=lt.set,dt=function(t,e){return e.facade=t,ct.call(lt,t,e),e},ft=function(t){return ht.call(lt,t)||{}},function(t){return ut.call(lt,t)}):(gt=z("state"),Yt[gt]=!0,dt=function(t,e){return e.facade=t,jt(t,gt,e),e},ft=function(t){return Mt(t,gt)?t[gt]:{}},function(t){return Mt(t,gt)}),{set:dt,get:ft,has:pt,enforce:function(t){return pt(t)?ft(t):dt(t,{})},getterFor:function(e){return function(t){if(Lt(t)&&(t=ft(t)).type===e)return t;throw TypeError("Incompatible receiver, "+e+" required")}}}),Zt=M(function(t){var e=Xt.get,a=Xt.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,s=!!i&&!!i.enumerable,i=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||Mt(n,"name")||jt(n,"name",e),(r=a(n)).source||(r.source=l.join("string"==typeof e?e:""))),t===yt?s?t[e]=n:F(e,n):(o?!i&&t[e]&&(s=!0):delete t[e],s?t[e]=n:jt(t,e,n))})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Ht(this)})}),Jt=yt,Kt=Math.ceil,Qt=Math.floor,te=function(t){return isNaN(t=+t)?0:(0<t?Qt:Kt)(t)},ee=Math.min,ne=Math.max,ie=Math.min,re=(e={includes:H(!0),indexOf:H(!1)}).indexOf,oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],se=oe.concat("length","prototype"),ae={f:Object.getOwnPropertyNames||function(t){return q(t,se)}},le={f:Object.getOwnPropertySymbols},he=G("Reflect","ownKeys")||function(t){var e=ae.f(Bt(t)),n=le.f;return n?e.concat(n(t)):e},ue=/#|\.prototype\./,ce=$.normalize=function(t){return String(t).replace(ue,".").toLowerCase()},de=$.data={},fe=$.NATIVE="N",pe=$.POLYFILL="P",ge=$,me=Ft.f,ve=!!Object.getOwnPropertySymbols&&!O(function(){return!String(Symbol())}),i=ve&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=n("wks"),be=yt.Symbol,xe=i?be:be&&be.withoutSetter||D,we=Object.keys||function(t){return q(t,oe)},Ae=bt?Object.defineProperties:function(t,e){Bt(t);for(var n,i=we(e),r=i.length,o=0;o<r;)zt.f(t,n=i[o++],e[n]);return t},Pe=G("document","documentElement"),Ee=">",Te="<",Se="prototype",_e="script",Le=z("IE_PROTO"),ke=function(t){return Te+_e+Ee+t+Te+"/"+_e+Ee},Ce=function(){try{mt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}Ce=mt?((t=mt).write(ke("")),t.close(),e=t.parentWindow.Object,t=null,e):(t=Rt("iframe"),e="java"+_e+":",t.style.display="none",Pe.appendChild(t),t.src=String(e),(e=t.contentWindow.document).open(),e.write(ke("document.F=Object")),e.close(),e.F);for(var t,e,n=oe.length;n--;)delete Ce[Se][oe[n]];return Ce()},n=(Yt[Le]=!0,Object.create||function(t,e){var n;return null!==t?(X[Se]=Bt(t),n=new X,X[Se]=null,n[Le]=t):n=Ce(),void 0===e?n:Ae(n,e)}),Me=Y("unscopables"),Ne=Array.prototype,Oe=(null==Ne[Me]&&zt.f(Ne,Me,{configurable:!0,value:n(null)}),Object.defineProperty),Re={},Ie=e.includes,i=K("indexOf",{ACCESSORS:!0,1:0}),Ve=(W({target:"Array",proto:!0,forced:!i},{includes:function(t){return Ie(this,t,1<arguments.length?arguments[1]:void 0)}}),Z("includes"),function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}),Fe=Function.call,Be=(nt("Array","includes"),Array.isArray||function(t){return"Array"==Et(t)}),De=Y("species"),ze=[].push,je=(e={forEach:ot(0),map:ot(1),filter:ot(2),some:ot(3),every:ot(4),find:ot(5),findIndex:ot(6),filterOut:ot(7)}).find,Ge=!0,Ue=K(i="find"),Ue=(i in[]&&Array(1)[i](function(){Ge=!1}),W({target:"Array",proto:!0,forced:Ge||!Ue},{find:function(t){return je(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(i),nt("Array","find"),{codeAt:st(!1),charAt:st(!0)}),i=!O(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),He=z("IE_PROTO"),qe=Object.prototype,i=i?Object.getPrototypeOf:function(t){return t=it(t),Mt(t,He)?t[He]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?qe:null},$e=Y("iterator"),r=!1,We=([].keys&&("next"in(We=[].keys())?(We=i(i(We)))!==Object.prototype&&(vt=We):r=!0),null==vt||O(function(){var t={};return vt[$e].call(t)!==t})),We=(Mt(vt=We?{}:vt,$e)||jt(vt,$e,function(){return this}),{IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:r}),Ye=zt.f,Xe=Y("toStringTag"),r=function(t,e,n){t&&!Mt(t=n?t:t.prototype,Xe)&&Ye(t,Xe,{configurable:!0,value:e})},Ze={},Je=We.IteratorPrototype,o=function(){return this},Ke=Object.setPrototypeOf||("__proto__"in{}?(()=>{var n,i=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),i=t instanceof Array}catch(t){}return function(t,e){return Bt(t),(t=>{if(Lt(t)||null===t)return;throw TypeError("Can't set "+String(t)+" as a prototype")})(e),i?n.call(t,e):t.__proto__=e,t}})():void 0),s=We.IteratorPrototype,Qe=We.BUGGY_SAFARI_ITERATORS,We=Y("iterator"),tn="values",en="entries",nn=Ue.charAt,rn="String Iterator",on=Xt.set,sn=Xt.getterFor(rn),Ue=String,an=function(t){on(this,{type:rn,string:String(t),index:0})},a=function(){var t=sn(this),e=t.string,n=t.index;return n>=e.length?{value:void 0,done:!0}:(e=nn(e,n),t.index+=e.length,{value:e,done:!1})},ln=void 0,hn=void 0,l=void 0;function un(t){if(t===ln&&mn)return mn;if(!Qe&&t in pn)return pn[t];switch(t){case"keys":case tn:case en:return function(){return new an(this,t)}}return function(){return new an(this)}}u=Zr="String",u+=" Iterator",(C=an).prototype=n(Je,{next:At(1,a)}),r(C,u,!1,!0),Ze[u]=o;var cn,dn,a=Zr+" Iterator",fn=!1,pn=Ue.prototype,gn=pn[We]||pn["@@iterator"]||ln&&pn[ln],mn=!Qe&&gn||un(ln);if((C="Array"==Zr&&pn.entries||gn)&&(u=i(C.call(new Ue)),s!==Object.prototype)&&u.next&&(i(u)!==s&&(Ke?Ke(u,s):"function"!=typeof u[We]&&jt(u,We,at)),r(u,a,!0,!0)),ln==tn&&gn&&gn.name!==tn&&(fn=!0,mn=function(){return gn.call(this)}),pn[We]!==mn&&jt(pn,We,mn),Ze[Zr]=mn,ln)if(cn={values:un(tn),keys:hn?mn:un("keys"),entries:un(en)},l)for(dn in cn)!Qe&&!fn&&dn in pn||Zt(pn,dn,cn[dn]);else W({target:Zr,proto:!0,forced:Qe||fn},cn);function vn(t,e,n){(e=kt(e))in t?zt.f(t,e,At(0,n)):t[e]=n}var yn=function(t){var e=t.return;if(void 0!==e)return Bt(e.call(t)).value},bn=Y("iterator"),xn=Array.prototype,Je=((n={})[Y("toStringTag")]="z","[object z]"===String(n)),wn=Y("toStringTag"),An="Arguments"==Et(function(){return arguments}()),Pn=Je?Et:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=((t,e)=>{try{return t[e]}catch(t){}})(t=Object(t),wn))?e:An?Et(t):"Object"==(e=Et(t))&&"function"==typeof t.callee?"Arguments":e},En=Y("iterator"),Tn=Y("iterator"),Sn=!1;try{var _n=0,h={next:function(){return{done:!!_n++}},return:function(){Sn=!0}};h[Tn]=function(){return this},Array.from(h,function(){throw 2})}catch(t){}function Ln(t){if(Lt(e=t)&&(void 0!==(n=e[On])?!!n:"RegExp"==Et(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t}function kn(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Rn]=!1,"/./"[e](n)}catch(t){}}return!1}var o=!((t,e)=>{if(!e&&!Sn)return!1;var n=!1;try{var i={};i[Tn]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n})(function(t){Array.from(t)}),Cn=(W({target:"Array",stat:!0,forced:o},{from:function(t){var e,n,i,r,o,s,a=it(t),t="function"==typeof this?this:Array,l=arguments.length,h=1<l?arguments[1]:void 0,u=void 0!==h,c=(t=>{if(null!=t)return t[En]||t["@@iterator"]||Ze[Pn(t)]})(a),d=0;if(u&&(h=Q(h,2<l?arguments[2]:void 0,2)),null!=c&&(t!=Array||void 0===(l=c)||Ze.Array!==l&&xn[bn]!==l))for(o=(r=c.call(a)).next,n=new t;!(i=o.call(r)).done;d++)s=u?((e,t,n,i)=>{try{return i?t(Bt(n)[0],n[1]):t(n)}catch(t){throw yn(e),t}})(r,h,[i.value,d],!0):i.value,vn(n,d,s);else for(n=new t(e=U(a.length));d<e;d++)s=u?h(a[d],d):a[d],vn(n,d,s);return n.length=d,n}}),Jt.Array.from,e.findIndex),Mn=!0,Ue=K(C="findIndex"),Nn=(C in[]&&Array(1)[C](function(){Mn=!1}),W({target:"Array",proto:!0,forced:Mn||!Ue},{findIndex:function(t){return Cn(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(C),nt("Array","findIndex"),M(function(t,e){function a(t){this.message=t}var l;e=e,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",(a.prototype=new Error).name="InvalidCharacterError",e.btoa||(e.btoa=function(t){for(var e,n,i=String(t),r=0,o=l,s="";i.charAt(0|r)||(o="=",r%1);s+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return s}),e.atob||(e.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)&&(s+=String.fromCharCode(255&n>>(-2*r&6))))i=l.indexOf(i);return s})}),W({target:"Number",stat:!0},{isNaN:function(t){return t!=t}}),Jt.Number.isNaN,yt.isFinite),i=Number.isFinite||function(t){return"number"==typeof t&&Nn(t)},On=(W({target:"Number",stat:!0},{isFinite:i}),Jt.Number.isFinite,Y("match")),Rn=Y("match"),Ke=(W({target:"String",proto:!0,forced:!kn("includes")},{includes:function(t){return!!~String(_t(this)).indexOf(Ln(t),1<arguments.length?arguments[1]:void 0)}}),nt("String","includes"),Ft.f),In="".startsWith,Vn=Math.min,u=!((s=kn("startsWith"))||!(r=Ke(String.prototype,"startsWith"))||r.writable);function Fn(t,e){return this.slice(t,e)}function Bn(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function Dn(t){if("number"==typeof t)for(var e=new Array(t),n=0;n<t;++n)e[n]=0;else e=t.slice(0);return e.subarray=Fn,(e.buffer=e).byteLength=e.length,e.set=Bn,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}W({target:"String",proto:!0,forced:!u&&!s},{startsWith:function(t){var e=String(_t(this)),n=(Ln(t),U(Vn(1<arguments.length?arguments[1]:void 0,e.length))),t=String(t);return In?In.call(e,t,n):e.slice(n,n+t.length)===t}}),nt("String","startsWith"),"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Uint8Array=Dn,window.Uint32Array=Dn,window.Int32Array=Dn);let{round:zn,floor:jn,PI:Gn}=Math;function Un(t){return 180*t/Gn%360}function Hn(t,e){var n;return void 0===e?(e=void 0===t?1:t,t=0):e<t&&(n=t,t=e,e=n),jn(Math.random()*(e-t+1)+t)}function qn(t,e){var n=Zn(t.y),i=Zn(e.y),t=t.x,e=e.x,e=Zn(e-t),t=Kn(e)*Jn(i),n=Jn(n)*Kn(i)-Kn(n)*Jn(i)*Jn(e);return(i=Un(Qn(t,n))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function $n(t,e){var n=t.x,t=t.y;return(n-=e.x)*n+(t-=e.y)*t}function Wn(t,e){return Math.sqrt($n(t,e))}let Yn=function(t){return t%360+(t<0?360:0)},Xn=function(t,e){return e*zn(t/e)},Zn=function(t,e){return(t=(e=e||!1)?t:t%360)*Gn/180},{cos:Jn,sin:Kn,atan2:Qn}=Math,c={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:ti,cos:ei,sin:ni,sqrt:ii,min:ri,max:oi,atan2:si,round:ai,pow:li,PI:hi}=Math,A=function(t,e){if(!(this instanceof A))return new A(t,e);var n;"string"==typeof t?(n=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(n[0]),e=parseFloat(n[1])):Object(t)===t&&(e=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e},ui=(A.fromPolar=function(t,e,n){n=new A(n);var i=ti(t*ei(e)),t=ti(t*ni(e)),e=Yn(Un(e));return e<90?t=-t:e<180?(i=-i,t=-t):e<270&&(i=-i),new A(n.x+i,n.y+t)},A.random=function(t,e,n,i){return new A(Hn(t,e),Hn(n,i))},A.prototype={type:c.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new A(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new A(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=ri(oi(this.x,t.x),t.x+t.width),this.y=ri(oi(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){e=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return e<0&&(e+=360),e},bearing:function(t){return qn(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new A(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 A(this.x-(t||0),this.y-(e||0))},distance:function(t){return Wn(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 A((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ii(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return ti(t.x-this.x)+ti(t.y-this.y)},move:function(t,e){t=Zn(new A(t).theta(this));return this.offset(ei(t)*e,-ni(t)*e)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},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 A(t).move(this,this.distance(t))},rotate:function(t,e){var n,i;return 0!==e&&(t=t||new A(0,0),e=Zn(Yn(-e)),n=ei(e),e=ni(e),i=n*(this.x-t.x)-e*(this.y-t.y)+t.x,e=e*(this.x-t.x)+n*(this.y-t.y)+t.y,this.x=i,this.y=e),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=li(10,t)}return this.x=ai(this.x*e)/e,this.y=ai(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new A(n)||new A(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=Xn(this.x,t),this.y=Xn(this.y,e||t),this},squaredDistance:function(t){return $n(this,t)},theta:function(t){var e=-((t=new A(t)).y-this.y),t=t.x-this.x,e=si(e,t);return 180*(e=e<0?2*hi+e:e)/hi},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new A(t)||new A(0,0);var e=this.x,n=this.y;return this.x=ii((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Zn(t.theta(new A(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 A(0,0).angleBetween(this,t)}},A.prototype.translate=A.prototype.offset,A),{max:ci,min:di}=Math,P=function(t,e){return this instanceof P?t instanceof P?new P(t.start,t.end):(this.start=new A(t),void(this.end=new A(e))):new P(t,e)},fi=(P.prototype={type:c.Line,angle:function(){var t=new A(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=di(this.start.x,this.end.x),e=di(this.start.y,this.end.y),n=ci(this.start.x,this.end.x),i=ci(this.start.y,this.end.y);return new tt(t,e,n-t,i-e)},bearing:function(){return qn(this.start,this.end)},clone:function(){return new P(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){t=this.vector().dot(new P(this.start,t).vector()),t=di(1,ci(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e,n=this.start,i=this.end;return 0===n.cross(t,i)&&(e=this.length(),!(new P(n,t).length()>e||new P(t,i).length()>e))},divideAt:function(t){t=this.pointAt(t);return[new P(this.start,t),new P(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new P(this.start,t),new P(t,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){return t&&t.intersectionWithLine?(e=t.intersectionWithLine(this,e))&&t instanceof P?e[0]:e:null},intersectionWithLine:function(t){var e=new A(this.end.x-this.start.x,this.end.y-this.start.y),n=new A(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,t=new A(t.start.x-this.start.x,t.start.y-this.start.y),n=t.x*n.y-t.y*n.x,t=t.x*e.y-t.y*e.x;if(0==i||n*i<0||t*i<0)return null;if(0<i){if(i<n||i<t)return null}else if(n<i||t<i)return null;return[new A(this.start.x+n*e.x/i,this.start.y+n*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Wn(this.start,this.end)},midpoint:function(){return new A((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e,n,i,r,o=this.clone();return this.isDifferentiable()&&({start:e,end:n}=o,i=e.clone().rotate(n,270),r=n.clone().rotate(e,90),e.move(r,t),n.move(i,t)),o},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?n:e).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new A(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();return e?this.scale(t=t/e,t,this.start):this},squaredLength:function(){return $n(this.start,this.end)},tangentAt:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAt(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},tangentAtLength:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAtLength(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},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 A(this.end.x-this.start.x,this.end.y-this.start.y)}},P.prototype.intersection=P.prototype.intersect,P),{sqrt:pi,round:gi,pow:mi}=Math,vi=function(t,e,n){return this instanceof vi?t instanceof vi?new vi(new A(t.x,t.y),t.a,t.b):(t=new A(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new vi(t,e,n)},{abs:yi,cos:bi,sin:xi,min:wi,max:Ai,round:Pi,pow:Ei}=(vi.fromRect=function(t){return t=new tt(t),new vi(t.center(),t.width/2,t.height/2)},vi.prototype={type:c.Ellipse,bbox:function(){return new tt(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new A(this.x,this.y)},clone:function(){return new vi(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,t=t.vector(),s=n.difference(new A(this)),a=new A(t.x/(r*r),t.y/(o*o)),r=new A(s.x/(r*r),s.y/(o*o)),o=t.dot(a),a=t.dot(r),t=a*a-o*(s.dot(r)-1);if(t<0)return null;if(0<t){s=pi(t),r=(-a-s)/o,t=(-a+s)/o;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&e.push(n.lerp(i,r)),0<=t&&t<=1&&e.push(n.lerp(i,t))}else{s=-a/o;if(!(0<=s&&s<=1))return null;e.push(n.lerp(i,s))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t),e&&t.rotate(new A(this.x,this.y),e);var n,i,r,o=t.x-this.x,s=t.y-this.y;return r=0==o?this.bbox().pointNearestToPoint(t):(s=(t=s/o)*t,i=this.a*this.a,n=this.b*this.b,i=pi(1/(1/i+s/n)),s=t*(i=o<0?-i:i),new A(this.x+i,this.y+s)),e?r.rotate(new A(this.x,this.y),-e):r},normalizedDistance:function(t){var e=t.x,t=t.y,n=this.a,i=this.b,r=this.x,o=this.y;return(e-r)*(e-r)/(n*n)+(t-o)*(t-o)/(i*i)},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=mi(10,t)}return this.x=gi(this.x*e)/e,this.y=gi(this.y*e)/e,this.a=gi(this.a*e)/e,this.b=gi(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,h=a.y;return a.x+o/2<i||i<a.x-o/2?n=o*o/(i-l)-o*o*(r-h)*((e=i>a.x?r-30:r+30)-h)/(s*s*(i-l))+l:e=s*s/(r-h)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-h))+h,new A(n,e).theta(t)},toString:function(){return new A(this.x,this.y).toString()+" "+this.a+" "+this.b}},a=vi,Math),tt=function(t,e,n,i){if(!(this instanceof tt))return new tt(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};function Ti(t){t=t.trim();if(""===t)return[];var e=[],n=t.split(/\b\s*,\s*|,\s*|\s+/),i=n.length;for(let t=0;t<i;t+=2)e.push({x:+n[t],y:+n[t+1]});return e}function Si(e){var n=e.length;if(0===n)return[];var i=[];for(let t=0;t<n;t++){var r=e[t].clone();i.push(r)}return i}function _i(t){var e,n=Math.abs,i=t.length;if(0===i)return[];for(o=0;o<i;o++)(void 0===e||t[o].y<e.y||t[o].y===e.y&&t[o].x>e.x)&&(e=t[o]);for(var r=[],o=0;o<i;o++){var s=e.theta(t[o]),s=(0===s&&(s=360),[t[o],o,s]);r.push(s)}r.sort(function(t,e){var n=t[2]-e[2];return n=0===n?e[1]-t[1]:n}),2<r.length&&r.unshift(r[r.length-1]);for(var a,l,h,u={},c=[];0!==r.length;)if(l=(a=r.pop())[0],!u.hasOwnProperty(a[0]+"@@"+a[1]))for(var d,f,p,g,m,v=!1;!v;)c.length<2?(c.push(a),v=!0):(f=(d=c.pop())[0],(m=(g=(p=c.pop())[0]).cross(f,l))<0?(c.push(p),c.push(d),c.push(a),v=!0):0!==m||n((m=f.angleBetween(g,l))-180)<1e-10||f.equals(l)||g.equals(f)?(u[d[0]+"@@"+d[1]]=f,c.push(p)):n((m+1)%360-1)<1e-10&&(c.push(p),r.push(d)));2<c.length&&c.pop();var y=-1,b=c.length;for(o=0;o<b;o++){var x=c[o][1];(void 0===h||x<h)&&(h=x,y=o)}var w,A,P=[],E=[];for(b=(P=0<y?(w=c.slice(y),A=c.slice(0,y),w.concat(A)):c).length,o=0;o<b;o++)E.push(P[o][0]);return E}tt.fromEllipse=function(t){return t=new vi(t),new tt(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},tt.fromPointUnion=function(...e){if(0===e.length)return null;var n=new A;let i,r,o,s;i=r=1/0,o=s=-1/0;for(let t=0;t<e.length;t++){n.update(e[t]);var a=n.x,l=n.y;a<i&&(i=a),a>o&&(o=a),l<r&&(r=l),l>s&&(s=l)}return new tt(i,r,o-i,s-r)},tt.fromRectUnion=function(...e){if(0===e.length)return null;var n=new tt;let i,r,o,s;i=r=1/0,o=s=-1/0;for(let t=0;t<e.length;t++){n.update(e[t]);var a=n.x,l=n.y,h=a+n.width,u=l+n.height;a<i&&(i=a),h>o&&(o=h),l<r&&(r=l),u>s&&(s=u)}return new tt(i,r,o-i,s-r)},tt.prototype={type:c.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var e,n,i,r;return t&&({width:i,height:e}=this,t=Zn(t),r=i*(n=yi(xi(t)))+e*(t=yi(bi(t))),this.x+=(i-(i=i*t+e*n))/2,this.y+=(e-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new A(this.x,this.y+this.height)},bottomLine:function(){return new P(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new A(this.x+this.width/2,this.y+this.height)},center:function(){return new A(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new tt(this)},containsPoint:function(t,e){let n,i;return t&&"string"!=typeof t?{x:n=0,y:i=0}=t:{x:n,y:i}=new A(t),e&&e.strict?n>this.x&&n<this.x+this.width&&i>this.y&&i<this.y+this.height:n>=this.x&&n<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var e,n,i=new tt(this).normalize(),t=new tt(t).normalize(),r=i.width,o=i.height,s=t.width,a=t.height;return!!(r&&o&&s&&a)&&(e=i.x,i=i.y,s+=n=t.x,r+=e,a+=t=t.y,o+=i,e<=n)&&s<=r&&i<=t&&a<=o},corner:function(){return new A(this.x+this.width,this.y+this.height)},equals:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize();return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.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,n=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=n.x||t.y<=n.y||r.x>=i.x||r.y>=i.y?null:(e=Ai(n.x,r.x),n=Ai(n.y,r.y),new tt(e,n,wi(i.x,t.x)-e,wi(i.y,t.y)-n))},intersectionWithLine:function(t){for(var e,n=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],o=n.length,s=0;s<o;s++)null!==(e=t.intersect(n[s]))&&r.indexOf(e.toString())<0&&(i.push(e),r.push(e.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t);for(var n,i=new A(this.x+this.width/2,this.y+this.height/2),r=(e&&t.rotate(i,e),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),o=new P(i,t),s=r.length-1;0<=s;--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 P(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new A(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){t=new tt(t);var n,i,r,o,s,a,l,h=(e=e||t.center()).x,e=e.y,u=n=i=r=o=s=a=l=1/0,c=t.topLeft(),c=(c.x<h&&(u=(this.x-h)/(c.x-h)),c.y<e&&(o=(this.y-e)/(c.y-e)),t.bottomRight()),c=(c.x>h&&(n=(this.x+this.width-h)/(c.x-h)),e<c.y&&(s=(this.y+this.height-e)/(c.y-e)),t.topRight()),c=(c.x>h&&(i=(this.x+this.width-h)/(c.x-h)),c.y<e&&(a=(this.y-e)/(c.y-e)),t.bottomLeft());return c.x<h&&(r=(this.x-h)/(c.x-h)),e<c.y&&(l=(this.y+this.height-e)/(c.y-e)),{sx:wi(u,n,i,r),sy:wi(o,s,a,l)}},maxRectUniformScaleToFit:function(t,e){t=this.maxRectScaleToFit(t,e);return wi(t.sx,t.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},moveAroundPoint:function(t,e){t=this.center().rotate(t,e);return this.x=t.x-this.width/2,this.y=t.y-this.height/2,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 A.prototype.offset.call(this,t,e)},origin:function(){return new A(this.x,this.y)},pointNearestToPoint:function(t){if(t=new A(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new A(this.x+this.width,t.y);case"left":return new A(this.x,t.y);case"bottom":return new A(t.x,this.y+this.height);case"top":return new A(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new P(this.topRight(),this.bottomRight())},rightMiddle:function(){return new A(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=Ei(10,t)}return this.x=Pi(this.x*e)/e,this.y=Pi(this.y*e)/e,this.width=Pi(this.width*e)/e,this.height=Pi(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 A(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r="left";return n<e&&(e=n,r="right"),i<e&&(e=i,r="top"),r=this.y+this.height-t.y<e?"bottom":r},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),t=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=t.x-n.x,this.height=t.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new P(this.topLeft(),this.topRight())},topMiddle:function(){return new A(this.x+this.width/2,this.y)},topRight:function(){return new A(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return tt.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}},tt.prototype.bottomRight=tt.prototype.corner,tt.prototype.topLeft=tt.prototype.origin,tt.prototype.translate=tt.prototype.offset,hn=tt;let x=function(t){return this instanceof x?"string"==typeof t?new x.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new x(t)},{abs:Li,sqrt:ki,min:Ci,max:Mi,pow:Ni}=(x.parse=function(t){return new x(Ti(t))},x.fromRect=function(t){return new x([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},x.prototype={type:c.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,a=a.y;l<t&&(t=l),e<l&&(e=l),a<n&&(n=a),i<a&&(i=a)}return new tt(t,n,e-t,i-n)},clone:function(){return new x(Si(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},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 P(n[a],n[a+1]),h=l.length(),u=l.closestPointNormalizedLength(t),l=l.pointAt(u).squaredDistance(t);l<r&&(r=l,e=o+u*h),o+=h}return e},closestPointNormalizedLength:function(t){var e,t=this.closestPointLength(t);return 0===t||0===(e=this.length())?0:t/e},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},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 P,h=new P,u=new A;s<n;s++){var c=e[o],d=e[s];if(t.equals(c))return!0;if(l.start=c,l.end=d,l.containsPoint(t))return!0;(r<=c.y&&r>d.y||r>c.y&&r<=d.y)&&0<=(c=c.x-i>d.x-i?c.x-i:d.x-i)&&(u.x=i+c,u.y=r,h.start=t,h.end=u,l.intersect(h))&&a++,o=s}return a%2==1},close:function(){var{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 x(_i(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 P(t),n=[],i=this.lengthPoints(),r=new P,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 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0!==e)for(var n=new P,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;return 0===n?null:1===n||t<=0?e[0].clone():1<=t?e[n-1].clone():(e=this.length(),this.pointAtLength(e*t))},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],a=e[a+1],h=new P(l,a),l=l.distance(a);if(t<=r+l)return h.pointAtLength((i?1:-1)*(t-r));r+=l}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(e={}){var n=this.points;if(!(n.length<3)){var i=e.threshold||1e-10;let t=0;for(;n[t+2];){var r=t,o=t+1,s=t+2,r=n[r],a=n[o],s=n[s];new P(r,s).closestPoint(a).distance(a)<=i?n.splice(o,1):t+=1}}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;1<(t=t<0?0:t)&&(t=1);e=this.length();return this.tangentAtLength(e*t)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;for(var i,r=!0,o=(t<0&&(r=!1,t=-t),0),s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,h=e[l],l=e[l+1],u=new P(h,l),h=h.distance(l);if(u.isDifferentiable()){if(t<=o+h)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=h}return i?i.tangentAt(r?1:0):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(x.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(x.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}}),Math),v=function(t,e,n,i){return this instanceof v?t instanceof v?new v(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new A(t),this.controlPoint1=new A(e),this.controlPoint2=new A(n),void(this.end=new A(i))):new v(t,e,n,i)};function Oi(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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}function Ri(t){for(var e=[],n=arguments.length,i=1;i<n;i++)e.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=e.length,i=0;i<n;i++){var o,s,a=e[i];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}v.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=(t=>{var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=Oi(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=Oi(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]})(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new A(e[0][r].x,e[0][r].y),s=new A(e[1][r].x,e[1][r].y);n.push(new v(t[r],o,s,t[r+1]))}return n},v.prototype={type:c.Curve,bbox:function(){for(var t,e,n,i,r,o=this.start,s=this.controlPoint1,a=this.controlPoint2,l=this.end,h=o.x,u=o.y,c=s.x,d=s.y,f=a.x,p=a.y,g=l.x,m=l.y,v=new Array,y=new Array,b=[new Array,new Array],x=0;x<2;++x)i=0===x?(e=6*h-12*c+6*f,t=-3*h+9*c-9*f+3*g,3*c-3*h):(e=6*u-12*d+6*p,t=-3*u+9*d-9*p+3*m,3*d-3*u),Li(t)<1e-12?Li(e)<1e-12||0<(n=-i/e)&&n<1&&y.push(n):(i=e*e-4*i*t,r=ki(i),i<0||(0<(i=(-e+r)/(2*t))&&i<1&&y.push(i),0<(i=(-e-r)/(2*t))&&i<1&&y.push(i)));for(var w,A,P=y.length,o=P;P--;)n=y[P],b[0][P]=w=(A=1-n)*A*A*h+3*A*A*n*c+3*A*n*n*f+n*n*n*g,b[1][P]=A=A*A*A*u+3*A*A*n*d+3*A*n*n*p+n*n*n*m,v[P]={X:w,Y:A};y[o]=0,y[o+1]=1,v[o]={X:h,Y:u},v[o+1]={X:g,Y:m},b[0][o]=h,b[1][o]=u,b[0][o+1]=g,b[1][o+1]=m,y.length=o+2,b[0].length=o+2,b[1].length=o+2,v.length=o+2;s=Ci.apply(null,b[0]),a=Ci.apply(null,b[1]),l=Mi.apply(null,b[0]),o=Mi.apply(null,b[1]);return new tt(s,a,l-s,o-a)},clone:function(){return new v(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,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,n),n)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.closestPointLength(t,n);return!e||0===(t=this.length(n))?0:e/t},closestPointT:function(t,e){for(var n,i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u=h.length,c=u?1/u:0,d=0;d<u;d++){var f=h[d],p=f.start.distance(t),g=f.end.distance(t),m=p+g;(!a||m<a)&&(i=d*c,r=(d+1)*c,o=p,E=g,s=(n=f).start.distance(f.end),a=m)}for(var v=Ni(10,-l);;){var y=o?Li(o-E)/o:0,b=E?Li(o-E)/E:0;if(y<v||b<v||(!o||o<s*v||(!E||E<s*v)))return o<=E?i:r;var y=n.divide(.5),b=(c/=2,y[0].start.distance(t)),x=y[0].end.distance(t),w=b+x,A=y[1].start.distance(t),P=y[1].end.distance(t),E=w<=A+P?(n=y[0],r-=c,o=b,x):(n=y[1],i+=c,o=A,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){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,e),this.divideAtT(t))},divideAtLength:function(t,e){t=this.tAtLength(t,e);return this.divideAtT(t)},divideAtT:function(t){var e,n,i=this.start,r=this.controlPoint1,o=this.controlPoint2,s=this.end;return t<=0?[new v(i,i,i,i),new v(i,r,o,s)]:1<=t?[new v(i,r,o,s),new v(s,s,s,s)]:(o=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,e=r.divider,n=r.dividerControlPoint1,r=r.dividerControlPoint2,[new v(i,o,t,e),new v(e,n,r,s)])},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;return t<=0?{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(e=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),i=new P(i,r).pointAt(t),r=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),{startControlPoint1:e,startControlPoint2:r,divider:new P(r,n).pointAt(t),dividerControlPoint1:n,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end,o=[new v(e,n,i,r)];if(0===t)return o;if(!this.isDifferentiable())return o;for(var s=this.endpointDistance(),a=Ni(10,-t),l=2,h=(0===n.cross(e,r)&&0===i.cross(e,r)&&(l=2*t),0);;){h+=1;for(var u=[],c=o.length,d=0;d<c;d++){var f=o[d].divide(.5);u.push(f[0],f[1])}for(var p=0,g=u.length,m=0;m<g;m++)p+=u[m].endpointDistance();if(l<=h)if((0!==p?(p-s)/p:0)<a)return u;o=u,s=p}},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){return t<=0?0:(e=void 0===(e=e||{}).precision?this.PRECISION:e.precision,this.divide(t)[0].length({precision:e}))},pointAt:function(t,e){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,e),this.pointAtT(t))},pointAtLength:function(t,e){t=this.tAtLength(t,e);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?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:1<t&&(t=1);t=this.tAt(t,e);return this.tangentAtT(t)},tangentAtLength:function(t,e){return this.isDifferentiable()?(t=this.tAtLength(t,e),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),e=t.startControlPoint2,n=t.dividerControlPoint1,t=t.divider,n=new P(e,n);return n.translate(t.x-e.x,t.y-e.y),n},tAt:function(t,e){var n;return t<=0?0:1<=t?1:(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.length(n),this.tAtLength(e*t,n))},tAtLength:function(t,e){for(var n,i,r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.subdivisions?this.getSubdivisions({precision:s}):e.subdivisions,e={precision:s,subdivisions:a},l=0,h=a.length,u=1/h,c=0;c<h;c++){var d=o?c:h-1-c,f=a[c],p=f.endpointDistance();if(t<=l+p){n=f,i=d*u,r=(d+1)*u,w=o?t-l:p+l-t,A=o?p+l-t:t-l;break}l+=p}if(!n)return o?1:0;for(var g=this.length(e),m=Ni(10,-s);;){var v,y=0!==g?w/g:0;if(y<m)return i;if((0!==g?A/g:0)<m)return r;var y=n.divide(.5),b=(u/=2,y[0].endpointDistance()),x=y[1].endpointDistance(),y=w<=b?(n=y[0],r-=u,b-(v=w)):(n=y[1],i+=u,x-(v=w-b)),w=v,A=y}},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 x(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}},v.prototype.divide=v.prototype.divideAtT;let V=function(t){if(!(this instanceof V))return new V(t);if("string"==typeof t)return new V.parse(t);var e;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(e=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(r=0;r<e;r++){var n=t[r];this.appendSegment(n)}else for(var i=null,r=0;r<e;r++){var o=t[r];if(!(o instanceof P||o instanceof v))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(V.createSegment("M",o.start)),i&&!i.end.equals(o.start)&&this.appendSegment(V.createSegment("M",o.start)),o instanceof P?this.appendSegment(V.createSegment("L",o.end)):o instanceof v&&this.appendSegment(V.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),i=o}else if(t.isSegment)this.appendSegment(t);else if(t instanceof P)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("L",t.end));else if(t instanceof v)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof x))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(e=t.points.length,r=0;r<e;r++){var s=t.points[r];0===r?this.appendSegment(V.createSegment("M",s)):this.appendSegment(V.createSegment("L",s))}}};function Ii(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}function Vi(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Vi))return Ii(Vi,t);if(0===e)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(t[0]instanceof P){if(1===e)return this.end=t[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" lines provided).")}if("string"==typeof t[0]||"number"==typeof t[0]){if(2===e)return this.end=new A(+t[0],+t[1]),this;if(e<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" coordinates provided).");for(var i,r=[],n=0;n<e;n+=2)i=t.slice(n,n+2),r.push(Ii(Vi,i))}else{if(1===e)return this.end=new A(t[0]),this;for(r=[],n=0;n<e;n+=1)r.push(new Vi(t[n]))}return r}function Fi(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Fi))return Ii(Fi,e);if(0===n)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(e[0]instanceof v){if(1===n)return this.controlPoint1=e[0].controlPoint1.clone(),this.controlPoint2=e[0].controlPoint2.clone(),this.end=e[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(6===n)return this.controlPoint1=new A(+e[0],+e[1]),this.controlPoint2=new A(+e[2],+e[3]),this.end=new A(+e[4],+e[5]),this;if(n<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=6)r=e.slice(i,i+6),o.push(Ii(Fi,r))}else{if(3===n)return this.controlPoint1=new A(e[0]),this.controlPoint2=new A(e[1]),this.end=new A(e[2]),this;if(n<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" points provided).");for(o=[],i=0;i<n;i+=3)t=e.slice(i,i+3),o.push(Ii(Fi,t))}return o}function Bi(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Bi))return Ii(Bi,e);if(0===n)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(e[0]instanceof P){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" lines provided).")}if(e[0]instanceof v){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(2===n)return this.end=new A(+e[0],+e[1]),this;if(n<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=2)r=e.slice(i,i+2),0===i?o.push(Ii(Bi,r)):o.push(Ii(Vi,r))}else{if(1===n)return this.end=new A(e[0]),this;for(o=[],i=0;i<n;i+=1)t=e[i],0===i?o.push(new Bi(t)):o.push(new Vi(t))}return o}function Di(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Di))return Ii(Di,t);if(0<e)throw new Error("Closepath constructor expects no arguments.");return this}V.parse=function(t){if(!t)return new V;for(var e=new V,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),o=V.createSegment.apply(this,o);e.appendSegment(o)}return e},V.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=V.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 Ii(e,n)},V.prototype={type:c.Path,appendSegment:function(t){var e=this.segments,n=e.length,i=0!==n?e[n-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 r=t.length,o=0;o<r;o++){var s=t[o],a=this.prepareSegment(s,i,null);e.push(a),i=a}}else{if(!t||!t.isSegment)throw new Error("Segment required.");a=this.prepareSegment(t,i,null),e.push(a)}},bbox:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n,i=0;i<e;i++){var r,o=t[i];o.isVisible&&(o=o.bbox(),r=r?r.union(o):o)}return r||(n=t[e-1],new tt(n.end.x,n.end.y,0,0))},clone:function(){for(var t=this.segments,e=t.length,n=new V,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){t=this.closestPointT(t,e);return t?this.pointAtT(t):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointT(t,n);return e?this.lengthAtT(e,n):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointLength(t,n);return 0===e||0===(t=this.length(n))?0:e/t},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 h=n[l],u=s[l];h.isVisible&&(u=h.closestPointT(t,{precision:o,subdivisions:u}),h=h.pointAtT(u),(h=new P(h,t).squaredLength())<a)&&(r={segmentIndex:l,value:u},a=h)}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 h,u=n[l],c=s[l];u.isDifferentiable()&&(c=u.closestPointT(t,{precision:o,subdivisions:c}),h=u.pointAtT(c),(h=new P(h,t).squaredLength())<a)&&(r=u.tangentAtT(c),a=h)}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;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.divideAtLength(e*t,n)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;for(var i,r,o,s,a=!0,l=(t<0&&(a=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),h=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:l}):e.segmentSubdivisions,u=0,c=0;c<n;c++){var d=a?c:n-1-c,f=this.getSegment(d),p=h[d],g=f.length({precision:l,subdivisions:p});if(f.isDifferentiable()&&(o=f,s=d,t<=u+g)){r=d,i=f.divideAtLength((a?1:-1)*(t-u),{precision:l,subdivisions:p});break}u+=g}if(!o)return null;i||(r=s,i=o.divideAtT(a?1:0));var m=this.clone(),e=(m.replaceSegment(r,i),r),v=r+1,y=r+2,b=(i[0].isDifferentiable()||(m.removeSegment(e),--v,--y),m.getSegment(v).start),x=(m.insertSegment(v,V.createSegment("M",b)),y+=1,i[1].isDifferentiable()||(m.removeSegment(y-1),--y),y-e-1);for(c=y;c<m.segments.length;c++){var w=this.getSegment(c-x);"Z"!==(f=m.getSegment(c)).type||w.subpathStartSegment.end.equals(f.subpathStartSegment.end)||(w=V.createSegment("L",w.end),m.replaceSegment(c,w))}return[new V(m.segments.slice(0,v)),new V(m.segments.slice(v))]},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(n<=(t=t<0?n+t:t)||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(){var e=this.clone().validate().segments,n=e.length,i=[];for(let t=0;t<n;t++){var r=e[t];r.isSubpathStart?i.push(new V(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,e){var n=this.segments,i=n.length;if(i<(t=t<0?i+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,o=null;if(0!==i&&(o=1<=t?(r=n[t-1]).nextSegment:n[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,a=0;a<s;a++){var l=e[a],h=this.prepareSegment(l,r,o);n.splice(t+a,0,h),r=h}}else{if(!e||!e.isSegment)throw new Error("Segment required.");h=this.prepareSegment(e,r,o),n.splice(t,0,h)}},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],s=t.intersect(s);s&&(n=n||[],Array.isArray(s)?Array.prototype.push.apply(n,s):n.push(s))}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;for(var t=t.value,o=(i<=r?(r=i-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=0,l=0;l<r;l++){var h=n[l],u=s[l];a+=h.length({precisison:o,subdivisions:u})}return u=s[r],a+=(h=n[r]).lengthAtT(t,{precisison:o,subdivisions:u})},pointAt:function(t,e){var n;return 0===this.segments.length?null:t<=0?this.start.clone():1<=t?this.end.clone():(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n),this.pointAtLength(e*t,n))},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isVisible){if(t<=l+d)return c.pointAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?o?r.end:r.start:n[i-1].end.clone()},pointAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].pointAtT(0):i<=e?n[i-1].pointAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].pointAtT(i))},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);e=t;return t.isSubpathStart&&(t.subpathStartSegment=t,e=n),e&&this.updateSubpathStartSegment(e),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(n<=(t=t<0?n+t:t)||t<0)throw new Error("Index out of range.");n=e.splice(t,1)[0],e=n.previousSegment,t=n.nextSegment;e&&(e.nextSegment=t),t&&(t.previousSegment=e),n.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,e){var n=this.segments,i=n.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");var i=n[t],r=i.previousSegment,o=i.nextSegment,s=i.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");n.splice(t,1);for(var a=e.length,l=0;l<a;l++){var h=e[l],u=this.prepareSegment(h,r,o);n.splice(t+l,0,u),r=u,s&&u.isSubpathStart&&(s=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");u=this.prepareSegment(e,r,o),n.splice(t,1,u),s&&u.isSubpathStart&&(s=!1)}s&&o&&this.updateSubpathStartSegment(o)},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){t=this.segmentIndexAt(t,e);return t?this.getSegment(t):null},segmentAtLength:function(t,e){t=this.segmentIndexAtLength(t,e);return t?this.getSegment(t):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.segmentIndexAtLength(e*t,n)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r=!0,o=(t<0&&(r=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,h=0;h<i;h++){var u=r?h:i-1-h,c=n[u],d=s[u],d=c.length({precision:o,subdivisions:d});if(c.isVisible){if(t<=l+d)return u;a=u}l+=d}return a},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.tangentAtLength(e*t,n)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isDifferentiable()){if(t<=l+d)return c.tangentAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?r.tangentAtT(o?1:0):null},tangentAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].tangentAtT(0):i<=e?n[i-1].tangentAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].tangentAtT(i))},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,h=e[a];h.isVisible?0<(l=r[a]).length?(l=l.map(function(t){return t.start}),Array.prototype.push.apply(s,l)):s.push(h.start):0<s.length&&(s.push(e[a-1].end),o.push(s),s=[])}return 0<s.length&&(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 x(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,t=(e=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,V.createSegment("M",0,0)),this}},Object.defineProperty(V.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(V.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;0<=n;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}}),l={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){var e;return t<=0?0:(e=this.length(),1<=t?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(l,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(l,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;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.)")}}),Object.defineProperty(l,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),Zr={clone:function(){return new Vi(this.end)},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[new Vi(t[0]),new Vi(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[new Vi(t[0]),new Vi(t[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(Zr,"type",{configurable:!0,enumerable:!0,value:"L"}),Vi.prototype=Ri(l,P.prototype,Zr),n={clone:function(){return new Fi(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Fi(t[0]),new Fi(t[1])]},divideAtLength:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Fi(t[0]),new Fi(t[1])]},divideAtT:function(t){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Fi(t[0]),new Fi(t[1])]},isDifferentiable:function(){var t,e,n,i;return!(!this.previousSegment||(t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end,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(n,"type",{configurable:!0,enumerable:!0,value:"C"}),Fi.prototype=Ri(l,v.prototype,n),Je={bbox:function(){return null},clone:function(){return new Bi(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(Je,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Je,"type",{configurable:!0,enumerable:!0,value:"M"}),Bi.prototype=Ri(l,Je),h={clone:function(){return new Di},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new Vi(t[0]):this.clone(),new Vi(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new Vi(t[0]):this.clone(),new Vi(t[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(h,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;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.)")}}),Object.defineProperty(h,"type",{configurable:!0,enumerable:!0,value:"Z"}),Di.prototype=Ri(l,P.prototype,h),o=V.segmentTypes={L:Vi,C:Fi,M:Bi,Z:Di,z:Di},V.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(o).join("")+",.]*$"),V.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},e={curveThroughPoints:function(t){return console.warn("deprecated"),new V(v.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=this.getFirstControlPoints(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=this.getFirstControlPoints(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new v(t,e,n,i);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);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 v(t,e,n,i);return function(t){return r.closestPointT(t)}}};let zi=function(t){return this instanceof zi?"string"==typeof t?new zi.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new zi(t)};function ji(t,e){var n=t.start.x,i=t.start.y,r=t.end.x,t=t.end.y,o=e.start.x,s=e.start.y,r=r-n,t=t-i,a=e.end.x-o,e=e.end.y-s,n=n-o,o=i-s,i=r*e-a*t,s=(r*o-t*n)/i,r=(a*o-e*n)/i;return 0<=s&&s<=1&&0<=r&&r<=1}function Gi(t,e){var n=t.a,i=t.b,r=t.x,t=t.y,o=e.start.x-r,r=e.end.x-r,s=e.start.y-t,n=n*n,i=i*i,r=r-o,e=e.end.y-t-s,t=r*r/n+e*e/i,r=2*o*r/n+2*s*e/i,e=r*r-4*t*(o*o/n+s*s/i-1);return 0==e?0<=(o=-r/2/t)&&o<=1:0<e&&(s=(-r-(n=Math.sqrt(e)))/2/t,0<=(i=(-r+n)/2/t)&&i<=1||0<=s&&s<=1)}function Ui(L,k){{var C=0,M=0;let{cos:t,sin:e}=Math,n=e(C),i=t(C),r=e(M),o=t(M),s=n*n,a=i*i,l=n*i,h=r*r,u=o*o,c=r*o,d=L.a*L.a,f=L.b*L.b,p=k.a*k.a,g=k.b*k.b,m=d*s+f*a,v=p*h+g*u,y=d*a+f*s,b=p*u+g*h,x=2*(f-d)*l,w=2*(g-p)*c,A=-2*m*L.x-x*L.y,P=-2*v*k.x-w*k.y,E=-x*L.x-2*y*L.y,T=-w*k.x-2*b*k.y,S=m*L.x*L.x+y*L.y*L.y+x*L.x*L.y-d*f,_=v*k.x*k.x+b*k.y*k.y+w*k.x*k.y-p*g;x/=2,w/=2,A/=2,P/=2,E/=2,T/=2;var C=gr([[m,x,A],[x,y,E],[A,E,S]]),M=gr([[v,w,P],[w,b,T],[P,T,_]]),L=.33333333*(gr([[v,x,A],[w,y,E],[P,E,S]])+gr([[m,w,A],[x,b,E],[A,T,S]])+gr([[m,x,P],[x,y,T],[A,E,_]])),k=.33333333*(gr([[m,w,P],[x,b,T],[A,T,_]])+gr([[v,x,P],[w,y,T],[P,E,_]])+gr([[v,w,A],[w,b,E],[P,T,S]])),N=pr([[C,L],[L,k]]),C=pr([[C,k],[L,M]]),M=pr([[L,k],[k,M]]);return!(0<(N=pr([[2*N,C],[C,2*M]]))&&(0<k||0<L))}}function Hi(t,e){var{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))||ji(t.topLine(),e)||ji(t.rightLine(),e)||ji(t.bottomLine(),e)||ji(t.leftLine(),e))}function qi(t,e){return!!$i(t,tt.fromEllipse(e))&&Ki(zi.fromRect(t),e)}function $i(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 Wi(t,e){return lr(t,e,{interior:!1})}function Yi(t,e){return hr(t,e,{interior:!1})}function Xi(t,e){return ur(t,e,{interior:!1})}function Zi(t,e){return dr(t,e,{interior:!1})}function Ji(t,e){return lr(t,e,{interior:!0})}function Ki(t,e){return hr(t,e,{interior:!0})}function Qi(t,e){return ur(t,e,{interior:!0})}function tr(t,e){return dr(t,e,{interior:!0})}function er(t,e){return fr(t,e,{interior:!0})}function nr(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ji:Wi)(e,n)})}function ir(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ki:Yi)(e,n)})}function rr(t,e,n){return sr(t,zi.fromRect(e),n)}function or(t,e,n){return cr(t,e,n,{interior:!1})}function sr(t,e,n){return cr(t,e,n,{interior:!0})}function ar(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?sr:or)(n,e,r)})}function lr(t,e,n={}){var{interior:n=!1}=n;let i;if(n){if(t.containsPoint(e.start))return!0;var{start:n,end:r,points:o}=t;i=r.equals(n)?o:[...o,n]}else i=t.points;var s=i.length,a=new P;for(let t=0;t<s-1;t++)if(a.start=i[t],a.end=i[t+1],ji(e,a))return!0;return!1}function hr(t,e,n={}){var{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;var{interior:n=!1}=n;if(n){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;var a=s.length,l=new P;for(let t=0;t<a-1;t++)if(l.start=s[t],l.end=s[t+1],Gi(e,l))return!0;return!1}function ur(t,e,n){return fr(t,zi.fromRect(e),n)}function cr(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?fr:dr)(n,e,r)})}function dr(t,e,n={}){var{interior:n=!1}=n;let i;if(n){n=e.start;if(t.containsPoint(n))return!0;i=t.clone().close()}else i=t;var r=e.points,o=r.length,s=new P;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Wi(i,s))return!0;return!1}function fr(t,e,n){return e.containsPoint(t.start)||dr(t,e.clone().close(),n)}function pr(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function gr(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]}zi.parse=function(t){return new zi(Ti(t))},zi.fromRect=function(t){return new zi([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},zi.prototype=Ri(x.prototype,{type:c.Polygon,clone:function(){return new zi(Si(this.points))},convexHull:function(){return new zi(_i(this.points))},lengthPoints:function(){var{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});let mr={__proto__:null,ellipseWithEllipse:Ui,ellipseWithLine:Gi,exists:function t(e,n,i,r){switch(e.type){case c.Line:if(n.type===c.Line)return ji(e,n);break;case c.Ellipse:switch(n.type){case c.Line:return Gi(e,n);case c.Ellipse:return Ui(e,n)}break;case c.Rect:switch(n.type){case c.Line:return Hi(e,n);case c.Ellipse:return qi(e,n);case c.Rect:return $i(e,n)}break;case c.Polyline:switch(n.type){case c.Line:return Wi(e,n);case c.Ellipse:return Yi(e,n);case c.Rect:return Xi(e,n);case c.Polyline:return Zi(e,n)}break;case c.Polygon:switch(n.type){case c.Line:return Ji(e,n);case c.Ellipse:return Ki(e,n);case c.Rect:return Qi(e,n);case c.Polyline:return tr(e,n);case c.Polygon:return er(e,n)}break;case c.Path:switch(n.type){case c.Line:return nr(e,n,i);case c.Ellipse:return ir(e,n,i);case c.Rect:return rr(e,n,i);case c.Polyline:return or(e,n,i);case c.Polygon:return sr(e,n,i);case c.Path:return ar(e,n,i,r)}}switch(n.type){case c.Ellipse:case c.Rect:case c.Polyline:case c.Polygon:case c.Path:return t(n,e,r,i);default:throw Error(`The intersection for ${e} and ${n} could not be found.`)}},lineWithLine:ji,pathWithEllipse:ir,pathWithLine:nr,pathWithPath:ar,pathWithPolygon:sr,pathWithPolyline:or,pathWithRect:rr,polygonWithEllipse:Ki,polygonWithLine:Ji,polygonWithPolygon:er,polygonWithPolyline:tr,polygonWithRect:Qi,polylineWithEllipse:Yi,polylineWithLine:Wi,polylineWithPolyline:Zi,polylineWithRect:Xi,rectWithEllipse:qi,rectWithLine:Hi,rectWithRect:$i},vr=mr;var yr={__proto__:null,Curve:v,Ellipse:vi,Line:P,Path:V,Point:A,Polygon:zi,Polyline:x,Rect:tt,bezier:e,ellipse:a,intersection:vr,line:fi,normalizeAngle:Yn,point:ui,random:Hn,rect:hn,scale:{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}},snapToGrid:Xn,toDeg:Un,toRad:Zn,types:c};let br="[object Arguments]",xr="[object Array]",wr="[object Boolean]",Ar="[object Date]",Pr="[object Error]",Er="[object Map]",Tr="[object Number]",Sr="[object Null]",_r="[object Object]",Lr="[object RegExp]",kr="[object Set]",Cr="[object String]",Mr="[object Symbol]",Nr="[object Undefined]",Or="[object ArrayBuffer]",Rr="[object DataView]",Ir="[object Float32Array]",Vr="[object Float64Array]",Fr="[object Int8Array]",Br="[object Int16Array]",Dr="[object Int32Array]",zr="[object Uint8Array]",jr="[object Uint8ClampedArray]",Gr="[object Uint16Array]",Ur="[object Uint32Array]",Hr={[br]:!0,[xr]:!0,[Or]:!0,[Rr]:!0,[wr]:!0,[Ar]:!0,[Ir]:!0,[Vr]:!0,[Fr]:!0,[Br]:!0,[Dr]:!0,[Er]:!0,[Tr]:!0,[_r]:!0,[Lr]:!0,[kr]:!0,[Cr]:!0,[Mr]:!0,[zr]:!0,[jr]:!0,[Gr]:!0,[Ur]:!0,[Pr]:!1,"[object Function]":!1,"[object WeakMap]":!1},qr=(u=`[${r="\\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"}]`,s="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Zr=`[${C="\\u2700-\\u27bf"}]`,l="\\ud83c[\\udffb-\\udfff]",hn=`(?:${n=`[${i="a-z\\xdf-\\xf6\\xf8-\\xff"}]`}|${Je=`[^${Ue="\\ud800-\\udfff"}${r+"\\d"+C+i+(Ke="A-Z\\xc0-\\xd6\\xd8-\\xde")}]`})`,r=`(?:${a=`[${Ke}]`}|${Je})`,C="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",i="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Je=(Je="[\\ufe0e\\ufe0f]?")+(Ke="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?")+`(?:\\u200d(?:${[h=`[^${Ue}]`,o="(?:\\ud83c[\\udde6-\\uddff]){2}",e="[\\ud800-\\udbff][\\udc00-\\udfff]"].join("|")})${Je+Ke})*`,Ke=`(?:${[Zr,o,e].join("|")})`+Je,RegExp([`${a}?${n}+${C}(?=${[u,a,"$"].join("|")})`,r+`+${i}(?=${[u,a+hn,"$"].join("|")})`,a+`?${hn}+`+C,a+"+"+i,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",Ke].join("|"),"g")),$r=200,Wr="__hash_undefined__",Yr=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;var Xr,Zr=`(?:${[h+s+"?",s,o,e,`[${Ue}]`].join("|")})`;let Jr=RegExp(l+`(?=${l})|`+Zr+Je,"g"),Kr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qr=/^\w*$/,to=".".charCodeAt(0),eo=/\\(\\)?/g,no=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=/^(?:0|[1-9]\d*)$/,ro=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 ]/),oo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,so=t=>Jr.test(t),ao=t=>t.match(Jr)||[],lo=t=>t.split(""),ho=t=>(so(t)?ao:lo)(t),uo=e=>null==e?[]:co(e).map(t=>e[t]),co=t=>Po(t)?fo(t):Object.keys(Object(t)),fo=(t,e)=>{var n,i=Array.isArray(t),r=!i&&mo(t)&&_o(t)===br,o=!i&&!r&&Io(t),s=i||r||o,a=t.length,l=new Array(s?a:0);let h=s?-1:a;for(;++h<a;)l[h]=""+h;for(n in t)!e&&!hasOwnProperty.call(t,n)||s&&("length"===n||as(n,a))||l.push(n);return l},po=(t,e)=>{let n=t.length;for(;n--;)if(go(t[n][0],e))return n;return-1},go=(t,e)=>t===e||t!=t&&e!=e,mo=t=>null!=t&&"object"==typeof t,vo=(t,e,n)=>{var i;return!!w(n)&&!!("number"==(i=typeof e)?Po(n)&&-1<e&&e<n.length:"string"==i&&e in n)&&go(n[e],t)},yo=t=>mo(t)&&_o(t)==kr,bo=t=>mo(t)&&_o(t)==Er,xo=t=>{var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},wo=(t,e,n)=>{var i=t[e];hasOwnProperty.call(t,e)&&go(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Ao=(t,e,n)=>{let i=-1;for(var r=e.length;++i<r;){var o=e[i];wo(n,o,t[o])}return n},Po=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&-1<t.length&&t.length%1==0,Eo=t=>"symbol"==typeof t||mo(t)&&_o(t)===Mr,To=t=>{var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n},So=(t,e)=>{let n=-1;var i=t.length;for(e=e||new Array(i);++n<i;)e[n]=t[n];return e},_o=t=>null==t?void 0===t?Nr:Sr:Object.prototype.toString.call(t),Lo=t=>{var e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},ko=(t,e)=>{e=e?Lo(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)},Co=t=>{var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},Mo=t=>"function"!=typeof t.constructor||xo(t)?{}:Object.create(Object.getPrototypeOf(t)),No=e=>null==e?[]:(e=Object(e),Object.getOwnPropertySymbols(e).filter(t=>propertyIsEnumerable.call(e,t))),Oo=(t,e)=>Ao(t,No(t),e),Ro=(t,e,n)=>{var i,r,o=t.constructor;switch(e){case Or:return Lo(t);case wr:case Ar:return new o(+t);case Rr:return i=t,r=(r=n)?Lo(i.buffer):i.buffer,new i.constructor(r,i.byteOffset,i.byteLength);case Ir:case Vr:case Fr:case Br:case Dr:case zr:case jr:case Gr:case Ur:return ko(t,n);case Er:return new o(t);case Tr:case Cr:return new o(t);case Lr:return Co(t);case kr:return new o;case Mr:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}},Io=t=>mo(t)&&Yr.test(_o(t)),Vo=t=>{var e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...No(Object(t))),e},Fo=t=>{for(var e=[];t;)e.push(...No(t)),t=Object.getPrototypeOf(Object(t));return e},Bo=t=>{var e,n=[];for(e in t)n.push(e);return Array.isArray(t)||n.push(...Fo(t)),n},Do=({__data__:t},e)=>(t=>{const e=typeof t;return e==="string"||e==="number"||e==="symbol"||e==="boolean"?t!=="__proto__":t===null})(e)?t["string"==typeof e?"string":"hash"]:t.map,zo=(t,e,n,i)=>{var r=Vo(t),o=r.length;if(o!=Vo(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;var l=i.get(t),h=i.get(e);if(l&&h)return l==e&&h==t;let u=!0;i.set(t,e),i.set(e,t);let c;for(;++a<o;){var d=t[s=r[a]],f=e[s];if(d!==f&&!n(d,f,i)){u=!1;break}c=c||"constructor"==s}return u&&!c&&(l=t.constructor)!=(h=e.constructor)&&"constructor"in t&&"constructor"in e&&!("function"==typeof l&&l instanceof l&&"function"==typeof h&&h instanceof h)&&(u=!1),i.delete(t),i.delete(e),u},jo=(t,e,n)=>t===e||(null==t||null==e||!mo(t)&&!mo(e)?t!=t&&e!=e:Go(t,e,jo,n)),Go=(t,e,n,i)=>{var r=Array.isArray(t),o=Array.isArray(e),s=r?xr:_o(t),o=o?xr:_o(e),s=s==br?_r:s,o=o==br?_r:o,a=s==_r,l=o==_r,o=s==o;return o&&!a?(i=i||new Ds,r||Io(t)?Uo(t,e,!1,n,i):Wo(t,e,s,n,i)):(r=a&&hasOwnProperty.call(t,"__wrapped__"),s=l&&hasOwnProperty.call(e,"__wrapped__"),r||s?n(r?t.value():t,s?e.value():e,i=i||new Ds):o&&(i=i||new Ds,zo(t,e,n,i)))},Uo=(t,e,n,i,r)=>{var o=t.length,s=e.length;if(o!=s)return!1;var s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,h=!0,u=n?new Us:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n=t[l];var c=e[l];if(u){if(!Ho(e,(t,e)=>{if(!qo(u,e)&&(n===t||i(n,t,r)))return u.push(e)})){h=!1;break}}else if(n!==c&&!i(n,c,r)){h=!1;break}}return r.delete(t),r.delete(e),h},Ho=(t,e)=>{let n=-1;for(var i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1},qo=(t,e)=>t.has(e),$o=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),Wo=(t,e,n,i,r)=>{switch(n){case Rr:return t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset?!1:(t=t.buffer,e=e.buffer,$o(t,e,i,r));case Or:return $o(t,e,i,r);case wr:case Ar:case Tr:return go(+t,+e);case Pr:return t.name==e.name&&t.message==e.message;case Lr:case Cr:return t==""+e;case Er:var o=Yo;case kr:if(o=o||Xo,t.size!=e.size)return!1;var s=r.get(t);if(s)return s==e;r.set(t,e);s=Uo(o(t),o(e),!0,i,r);return r.delete(t),s;case Mr:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},Yo=t=>{let n=-1,i=Array(t.size);return t.forEach((t,e)=>{i[++n]=[e,t]}),i},Xo=t=>{let e=-1,n=new Array(t.size);return t.forEach(t=>{n[++e]=t}),n},Zo=(t,e)=>{var n;return!Array.isArray(t)&&(!("number"!=(n=typeof t)&&"boolean"!=n&&null!=t&&!Eo(t))||Qr.test(t)||!Kr.test(t)||null!=e&&t in Object(e))},Jo=t=>{let o=[];return t.charCodeAt(0)===to&&o.push(""),t.replace(no,(t,e,n,i)=>{let r=t;n?r=i.replace(eo,"$1"):e&&(r=e.trim()),o.push(r)}),o},Ko=(t,e)=>Array.isArray(t)?t:Zo(t,e)?[t]:Jo(""+t),Qo=(t,e)=>{let n=0;for(var i=(e=Ko(e,t)).length;null!=t&&n<i;)t=t[ns(e[n])],n++;return n&&n==i?t:void 0};function ts(t,e){if(t!==e){var n=void 0!==t,i=null===t,r=t==t,o=Eo(t),s=void 0!==e,a=null===e,l=e==e,h=Eo(e);if(!a&&!h&&!o&&e<t||o&&s&&l&&!a&&!h||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!h&&t<e||h&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}let es=(t,e)=>{let n=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),i=!0;var r=[],o=e.length;if(t.length){e.length>=$r&&(n=(t,e)=>t.has(e),i=!1,e=new Us(e));t:for(var s in t){var a=s=t[s],s=0!==s?s:0;if(i&&a==a){let t=o;for(;t--;)if(e[t]===a)continue t;r.push(s)}else n(e,a)||r.push(s)}}return r},ns=t=>{var e;return"string"==typeof t||Eo(t)?t:"0"==(e=""+t)&&1/t==-1/0?"-0":e},is=(i,r=!1,o=!1,s=!0,a,t,e,l)=>{let h;if(void 0===(h=a?e?a(i,t,e,l):a(i):h)){if(!w(i))return i;var t=Array.isArray(i),n=_o(i);if(t){if(h=To(i),!r)return So(i,h)}else{var u="function"==typeof i;if(n===_r||n===br||u&&!e){if(h=o||u?{}:Mo(i),!r)return o?rs(i,Ao(i,Object.keys(i),h)):Oo(i,Object.assign(h,i))}else{if(u||!Hr[n])return e?i:{};h=Ro(i,n,r)}}u=(l=l||new Ds).get(i);if(u)return u;if(l.set(i,h),bo(i))i.forEach((t,e)=>{h.set(e,is(t,r,o,s,a,e,i,l))});else if(yo(i))i.forEach(t=>{h.add(is(t,r,o,s,a,t,i,l))});else if(!Io(i)){e=s?o?Bo:Vo:o?ls:co;let n=t?void 0:e(i);(n||i).forEach((t,e)=>{n&&(t=i[e=t]),wo(h,e,is(t,r,o,s,a,e,i,l))})}}return h},rs=(t,e)=>Ao(t,Fo(t),e),os=(t,e)=>e.length<2?t:Qo(t,e.slice(0,-1)),ss=(t,i,r)=>{if(w(t)){var o=(i=Ko(i,t)).length,s=o-1;let e=-1,n=t;for(;null!=n&&++e<o;){var a,l=ns(i[e]);let t=r;e!=s&&(a=n[l],(t=void 0)===t)&&(t=w(a)?a:as(i[e+1])?[]:{}),wo(n,l,t),n=n[l]}}return t},as=(t,e)=>{var n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"==n||"symbol"!=n&&io.test(t))&&-1<t&&t%1==0&&t<e},ls=t=>{var e,n=[];for(e in t)n.push(e);return n},hs=t=>{var e,n={};for(e in t=Object(t))n[e]=t[e];return n},us=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function cs(a,l=!1){return(t,...e)=>{let n=-1,i=e.length,r=1<i?e[i-1]:void 0;var o=2<i?e[2]:void 0;for(r=3<a.length&&"function"==typeof r?(i--,r):l?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,o&&vo(e[0],e[1],o)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var s=e[n];s&&a(t,s,n,r)}return t}}let ds=(i,r,t,o,s)=>{i!==r&&fa(r,(e,n)=>{if(w(e))s=s||new Ds,fs(i,r,n,t,ds,o,s);else{let t=o?o(i[n],e,""+n,i,r,s):void 0;void 0===t&&(t=e),ps(i,n,t)}})},fs=(n,i,r,o,s,a,l)=>{var h=us(n,r),u=us(i,r),c=l.get(u);if(c)ps(n,r,c);else{let t=a?a(h,u,""+r,n,i,l):void 0,e=void 0===t;e&&(i=!(c=Array.isArray(u))&&Io(u),t=u,c||i?t=Array.isArray(h)?h:mo(h)&&Po(h)?So(h):i?(e=!1,ko(u,!0)):[]:y(u)||Cs(u)?(t=h,Cs(h)?t=hs(h):"function"!=typeof h&&w(h)||(t=Mo(u))):e=!1),e&&(l.set(u,t),s(t,u,o,a,l),l.delete(u)),ps(n,r,t)}},ps=(t,e,n)=>{(void 0===n||go(t[e],n))&&(void 0!==n||e in t)||wo(t,e,n)},gs=(t,e)=>t&&((t,e,n)=>{var i=Object(t),r=n(t);let o=r.length,s=-1;for(;o--;){var a=r[++s];if(!1===e(i[a],a,i))break}return t})(t,e,co),ms=(e,n)=>{if(null!=e){if(!Po(e))return gs(e,n);var i=e.length,r=Object(e);let t=-1;for(;++t<i&&!1!==n(r[t],t,r););}return e},vs=Set&&1/Xo(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function ys(t,e,n,i,r,o){return w(t)&&w(e)&&(o.set(e,t),ds(t,e,void 0,ys,o),o.delete(e)),t}function bs(e,n,u){n=n.length?n.map(e=>Array.isArray(e)?t=>Qo(t,1===e.length?e[0]:e):e):[t=>t];let i=-1,r=-1,o=Po(e)?new Array(e.length):[];ms(e,e=>{var t=n.map(t=>t(e));o[++r]={criteria:t,index:++i,value:e}});{var s=o;e=(e,n)=>{{var i=u;let t=-1;for(var r=e.criteria,o=n.criteria,s=r.length,a=i.length;++t<s;){var l=t<a?i[t]:null,h=(l&&"function"==typeof l?l:ts)(r[t],o[t]);if(h)return l&&"function"!=typeof l?h*("desc"==l?-1:1):h}return e.index-n.index}};let t=s.length;for(s.sort(e);t--;)s[t]=s[t].value;return s}}function xs(t){return t==t&&!w(t)}function ws(e,n){return t=>null!=t&&t[e]===n&&(void 0!==n||e in Object(t))}function As(t,e){return null!=t&&Rs(t,e,Os)}function Ps(e){let n=(t=>{let e=co(t),n=e.length;for(;n--;){var i=e[n],r=t[i];e[n]=[i,r,xs(r)]}return e})(e);return 1===n.length&&n[0][2]?ws(n[0][0],n[0][1]):t=>t===e||((t,e,n,i)=>{let r=n.length,o=r,s=!i;if(null==t)return!o;let a,l;for(t=Object(t);r--;)if(a=n[r],s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1;for(;++r<o;){var h=(a=n[r])[0],u=t[h],c=a[1];if(s&&a[2]){if(void 0===u&&!(h in t))return!1}else{var d=new Ds;if(!(void 0===(l=i?i(u,c,h,t,e,d):l)?jo(c,u,d):l))return!1}}return!0})(t,e,n)}function Es(t){return Zo(t)?(n=ns(t),t=>null==t?void 0:t[n]):(e=t,t=>Qo(t,e));var e,n}function Ts(t){var n,i;return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(n=t[0],i=t[1],Zo(n)&&xs(i)?ws(ns(n),i):t=>{var e=Qo(t,n);return void 0===e&&e===i?As(t,n):jo(i,e)}):Ps(t):Es(t)}function Ss(t,e){var n=Ts;return arguments.length?n(t,e):n}let _s=(t,e,n,i)=>{let r=-1;var o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},Ls=(t,i,r,o,e)=>(e(t,(t,e,n)=>{r=o?(o=!1,t):i(r,t,e,n)}),r),ks=t=>Array.isArray(t)||Cs(t)||!(!t||!t[Symbol.isConcatSpreadable]),Cs=t=>mo(t)&&"[object Arguments]"==_o(t),Ms=(t,e,n)=>{let i=-1;for(var r=e.length,o={};++i<r;){var s=e[i],a=Qo(t,s);n(a,s)&&ss(o,Ko(s,t),a)}return o},Ns=t=>"number"==typeof t&&-1<t&&t%1==0&&t<=Number.MAX_SAFE_INTEGER,Os=(t,e)=>null!=t&&e in Object(t),Rs=(t,e,n)=>{for(var i=-1,r=(e=Ko(e,t)).length,o=!1;++i<r;){var s=ns(e[i]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++i!=r?o:!!(r=null==t?0:t.length)&&Ns(r)&&as(s,r)&&(Array.isArray(t)||Cs(t))},Is=t=>t.match(oo),Vs=t=>t.match(qr),Fs=(t,e)=>void 0===e?(ro(t)?Vs:Is)(t)||[]:t.match(e)||[],Bs=(Xr="toUpperCase",t=>{var e,n,i,r,o;return t?(e=((n=so(t)?ho(t):void 0)||t)[0],o=n?(i=1,o=(n=n).length,r=void 0===r?o:r,(!i&&o<=r?n:n.slice(i,r)).join("")):t.slice(1),e[Xr]()+o):""});class Ds{constructor(t){t=this.__data__=new zs(t);this.size=t.size}clear(){this.__data__=new zs,this.size=0}delete(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof zs){var i=n.__data__;if(i.length<$r-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new js(i)}return n.set(t,e),this.size=n.size,this}}class zs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=[],this.size=0}delete(t){var e=this.__data__,t=po(e,t);return!(t<0||(t==e.length-1?e.pop():e.splice(t,1),--this.size,0))}get(t){var e=this.__data__,t=po(e,t);return t<0?void 0:e[t][1]}has(t){return-1<po(this.__data__,t)}set(t,e){var n=this.__data__,i=po(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class js{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.size=0,this.__data__={hash:new Gs,map:new Map,string:new Gs}}delete(t){t=Do(this,t).delete(t);return this.size-=t?1:0,t}get(t){return Do(this,t).get(t)}has(t){return Do(this,t).has(t)}set(t,e){var n=Do(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Gs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){t=this.has(t)&&delete this.__data__[t];return this.size-=t?1:0,t}get(t){t=this.__data__[t];return t===Wr?void 0:t}has(t){return void 0!==this.__data__[t]}set(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?Wr:e,this}}class Us{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.__data__=new js;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,Wr),this}has(t){return this.__data__.has(t)}}function Hs(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&e.call(t)===wr}function qs(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Tr}Us.prototype.push=Us.prototype.add;let w=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},E=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Cr},T=cs((t,e)=>{if(xo(e)||Po(e))Ao(e,co(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&wo(t,n,e[n])}),$s=(n=T,r=n,u=(e,...t)=>{let n=-1,i=t.length;var r=2<i?t[2]:void 0;for(r&&vo(t[0],t[1],r)&&(i=1);++n<i;){var o=t[n];if(null!=o){var s=Object.keys(o),a=s.length;let t=-1;for(;++t<a;){var l=s[t],h=e[l];(void 0===h||go(h,Object.prototype[l])&&!hasOwnProperty.call(e,l))&&(e[l]=o[l])}}}return e});function Ws(...t){return t.push(void 0,ys),_.apply(void 0,t)}let Ys=Ws,Xs=(t,e,...n)=>{let i=-1,r="function"==typeof e,o=Po(t)?new Array(t.length):[];return ms(t,t=>{o[++i]=r?e.apply(t,n):Zs(t,e,...n)}),o},Zs=(t,e,...n)=>{e=Ko(e,t);var i,e=null==(t=os(t,e))?t:t[ns((i=null==(e=e)?0:e.length)?e[i-1]:void 0)];return null==e?void 0:e.apply(t,n)},Js=(e,n,i)=>{let r=0,o=null==e?0:e.length;if(0==o)return 0;for(var s=(n=(i=Ss(i,2))(n))!=n,a=null===n,l=Eo(n),h=void 0===n;r<o;){let t;var u=Math.floor((r+o)/2),c=i(e[u]),d=void 0!==c,f=null===c,p=c==c,g=Eo(c);(t=s?p:h?p&&d:a?p&&d&&!f:l?p&&d&&!f&&!g:!f&&!g&&c<n)?r=u+1:o=u}return Math.min(o,4294967294)},Ks=(t,e)=>{let n=-1,i=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),r=(e=Ss(e,2),!0);var o=t.length,s=[];let a=s;if(o>=$r){var l=e?null:vs(t);if(l)return Xo(l);r=!1,i=(t,e)=>t.has(e),a=new Us}else a=e?[]:s;t:for(;++n<o;){var h=t[n],u=e?e(h):h,h=0!==h?h:0;if(r&&u==u){let t=a.length;for(;t--;)if(a[t]===u)continue t;e&&a.push(u),s.push(h)}else i(a,u)||(a!==s&&a.push(u),s.push(h))}return s},Qs=t=>is(t),ta=t=>is(t,!0),ea=t=>{if(null!=t){if(Po(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Io(t)||Cs(t)))return!t.length;var e,n=_o(t);if("[object Map]"==n||"[object Set]"==n)return!t.size;if(xo(t))return!(t=>{if(!xo(t))return Object.keys(t);var e,n=[];for(e in Object(t))hasOwnProperty.call(t,e)&&"constructor"!=e&&n.push(e);return n})(t).length;for(e in t)if(hasOwnProperty.call(t,e))return!1}return!0},na=(t,e)=>jo(t,e),b=t=>"function"==typeof t,y=t=>{if(!mo(t)||"[object Object]"!=_o(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},et=t=>{if(!t)return[];if(Po(t))return(E(t)?ho:So)(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){for(var e,n=t[Symbol.iterator](),i=[];!(e=n.next()).done;)i.push(e.value);return i}var r=_o(t);return(r==Er?Yo:r==kr?Xo:uo)(t)};function ia(i,r,t){if("function"!=typeof i)throw new TypeError("Expected a function");let o,s,n,a,l,h,u=0,c=!1,d=!1,e=!0,f=!r&&0!==r&&window&&"function"==typeof window.requestAnimationFrame;function p(t){var e=o,n=s;return o=s=void 0,u=t,a=i.apply(n,e)}function g(t,e){return f?(window.cancelAnimationFrame(l),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){var e=t-h,t=t-u;return void 0===h||r<=e||e<0||d&&t>=n}function v(){var t,e=Date.now();if(m(e))return y(e);l=g(v,(t=(e=e)-h,e-=u,t=r-t,d?Math.min(t,n-e):t))}function y(t){return l=void 0,e&&o?p(t):(o=s=void 0,a)}function b(...t){var e=Date.now(),n=m(e);if(o=t,s=this,h=e,n){if(void 0===l)return t=h,u=t,l=g(v,r),c?p(t):a;if(d)return l=g(v,r),p(h)}return void 0===l&&(l=g(v,r)),a}return r=+r||0,w(t)&&(c=!!t.leading,d="maxWait"in t,n=d?Math.max(+t.maxWait||0,r):n,e="trailing"in t?!!t.trailing:e),b.cancel=()=>{void 0!==l&&(t=>{if(f)return window.cancelAnimationFrame(t);clearTimeout(t)})(l),u=0,o=h=s=l=void 0},b.flush=()=>void 0===l?a:y(Date.now()),b.pending=()=>void 0!==l,b}let ra=(t,i)=>(i=Ss(i,2),function(t,e,n){return(Array.isArray(t)?_s:Ls)(t,e,n,arguments.length<3,ms)}(t,(t,e)=>{var n=i(e);return hasOwnProperty.call(t,n)?t[n].push(e):wo(t,n,[e]),t},{})),oa=(t,e=[])=>{var n;return null==t?[]:(1<(n=e.length)&&vo(t,e[0],e[1])?e=[]:2<n&&vo(e[0],e[1],e[2])&&(e=[e[0]]),bs(t,(e=Array.isArray(e)?e:[Ss(e,2)]).flat(1),[]))},sa=t=>(null==t?0:t.length)?function t(e,n,i,r,o){let s=-1;var a=e.length;for(i=i||ks,o=o||[];++s<a;){var l=e[s];0<n&&i(l)?1<n?t(l,n-1,i,r,o):o.push(...l):r||(o[o.length]=l)}return o}(t,1/0):[],aa=(t,...e)=>Po(t)?es(t,e):[],la=(t,...e)=>mo(t)&&Po(t)?es(t,e.flat(1)):[],ha=(...t)=>{t=t.flat(1);return Ks(t)},ua=(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},S=(e,n,i)=>{let r=-1,o=(n=Ko(n,e)).length;for(o||(o=1,e=void 0);++r<o;){let t=null==e?void 0:e[ns(n[r])];void 0===t&&(r=o,t=i),e="function"==typeof t?t.call(e):t}return e},ca=(n,...i)=>{let r={};if(null!=n){let e=!1,t=(i=i.flat(1).map(t=>(t=Ko(t,n),e=e||1<t.length,t)),Ao(n,Bo(n),r),e&&(r=is(r,!0,!0,!0,t=>y(t)?void 0:t)),i.length);for(;t--;){s=o=void 0;var o=r,s=i[t];s=Ko(s,o),o=os(o,s),s=s[s.length-1],null!=o&&delete o[ns(s)]}}return r},da=(t,...e)=>{return null==t?{}:(n=t,t=e.flat(1/0),Ms(n,t,(t,e)=>As(n,e)));var n},fa=(t,e=t=>t)=>{let n=-1;var i=Object(t),r=Po(t)?fo(t,!0):ls(t);let o=r.length;for(;o--;){var s=r[++n];if(!1===e(i[s],s,i))break}},pa=(t="")=>Fs((""+t).replace(/['\u2019]/g,"")).reduce((t,e,n)=>(e=e.toLowerCase(),t+(n?Bs(e):e)),""),ga=0,ma=(t="")=>""+t+ ++ga,_=cs((t,e,n,i)=>{ds(t,e,n,i)},!0);class va{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 t=this.map.get(t),void 0===e?t:t[e]}set(t,e,n){void 0!==e&&(t=this.create(t),"string"==typeof e?t[e]=n:Object.assign(t,e))}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}}function ya(t,e){if(!(this instanceof ya))return new ya(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?wa:Aa,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}let ba=new va,xa=new va;function wa(){return!0}function Aa(){return!1}ya.prototype={constructor:ya,isDefaultPrevented:Aa,isPropagationStopped:Aa,isImmediatePropagationStopped:Aa,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=wa,t&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=wa,t&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=wa,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=>{var e;e=t,Object.defineProperty(ya.prototype,e,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[e]:void 0},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})});let Pa="undefined"!=typeof window?window.document:null,Ea=Pa&&Pa.documentElement,Ta=/^([^.]*)(?:\.(.+)|)/,Sa=/[^\x20\t\r\n\f]+/g,L=function(t){return new L.Dom(t)},_a=(L.fn=L.prototype={constructor:L,length:0},L.guid=1,L.data=xa,L.merge=function(e,n){var i=+n.length;let r=e.length;for(let t=0;t<i;t++)e[r++]=n[t];return e.length=r,e},L.parseHTML=function(t){var e=Pa.implementation.createHTMLDocument(),n=e.createElement("base"),i=(n.href=Pa.location.href,e.head.appendChild(n),e.body.innerHTML=t,e.getElementsByTagName("script"));for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(L.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),L.fn.toArray=function(){return Array.from(this)},L.fn.pushStack=function(t){t=L.merge(this.constructor(),t);return t.prevObject=this,t},L.fn.find=function(t){var e,[n]=this,i=this.pushStack([]);return n&&(e=n.nodeType,1!==e&&9!==e&&11!==e||("string"!=typeof t?n!==t&&n.contains(t)&&L.merge(i,[t]):L.merge(i,n.querySelectorAll(t)))),i},L.fn.add=function(t){var t=L(t).toArray(),e=this.toArray(),n=this.pushStack([]);return L.merge(n,Ks(e.concat(t))),n},L.fn.addBack=function(){return this.add(this.prevObject)},L.fn.filter=function(e){var n=[];for(let t=0;t<this.length;t++){var i=this[t];i.matches(e)&&n.push(i)}return this.pushStack(n)},/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/);function La(e){if(e){if("function"==typeof e)throw new Error("function not supported");if(1<arguments.length)throw new Error("selector with context not supported");if(e.nodeType)this[0]=e,this.length=1;else{let t;if("<"===(n=e+"")[0]&&">"===n[n.length-1]&&3<=n.length)t=[null,e,null];else{if("string"!=typeof e)return L.merge(this,e);t=_a.exec(e)}var n;if(!t||!t[1])return ka.find(e);t[1]?L.merge(this,L.parseHTML(t[1])):(n=Pa.getElementById(t[2]))&&(this[0]=n,this.length=1)}}return this}(L.Dom=La).prototype=L.fn,L.Event=ya,L.event={special:Object.create(null)},L.event.has=function(t,e){t=ba.get(t,"events");return!!t&&(!e||Array.isArray(t[e])&&0<t[e].length)},L.event.on=function(e,n,i,r,o,t){if("object"==typeof n){for(var s in"string"!=typeof i&&(r=r||i,i=void 0),n)L.event.on(e,s,i,r,n[s],t);return e}if(null==r&&null==o?(o=i,r=i=void 0):null==o&&("string"==typeof i?(o=r,r=void 0):(o=r,r=i,i=void 0)),!o)return e;if(1===t){let e=o;(o=function(t){return L().off(t),e.apply(this,arguments)}).guid=e.guid||(e.guid=L.guid++)}for(let t=0;t<e.length;t++)L.event.add(e[t],n,o,r,i)},L.event.add=function(r,o,s,a,l){if("object"==typeof r){var h=ba.create(r);let e;s.handler&&(s=(e=s).handler,l=e.selector),l&&Ea.matches(l),s.guid||(s.guid=L.guid++);let n;n=(n=h.events)||(h.events=Object.create(null));let i;i=(i=h.handle)||(h.handle=function(t){return void 0!==L?L.event.dispatch.apply(r,arguments):void 0});var u=(o||"").match(Sa)||[""];let t=u.length;for(;t--;){var[,c,d=""]=Ta.exec(u[t]);if(c){var d=d.split(".").sort(),f=(p=L.event.special[c])&&(l?p.delegateType:p.bindType)||c,p=L.event.special[f],c=Object.assign({type:f,origType:c,data:a,handler:s,guid:s.guid,selector:l,namespace:d.join(".")},e);let t;(t=n[f])||((t=n[f]=[]).delegateCount=0,p&&p.setup&&!1!==p.setup.call(r,a,d,i))||r.addEventListener&&r.addEventListener(f,i),p&&p.add&&(p.add.call(r,c),c.handler.guid||(c.handler.guid=s.guid)),l?t.splice(t.delegateCount++,0,c):t.push(c)}}}},L.event.remove=function(e,n,i,r,o){var s=ba.get(e);if(s&&s.events){var a=s.events,l=(n||"").match(Sa)||[""];let t=l.length;for(;t--;){var[,h,u=""]=Ta.exec(l[t]);if(h){var c=L.event.special[h],d=c&&(r?c.delegateType:c.bindType)||h,f=a[d];if(f&&0!==f.length){var p=u.split(".").sort(),g=u?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,u=f.length;let t=u;for(;t--;){var m=f[t];!o&&h!==m.origType||i&&i.guid!==m.guid||g&&!g.test(m.namespace)||r&&r!==m.selector&&("**"!==r||!m.selector)||(f.splice(t,1),m.selector&&f.delegateCount--,c&&c.remove&&c.remove.call(e,m))}u&&0===f.length&&(c&&c.teardown&&!1!==c.teardown.call(e,p,s.handle)||e.removeEventListener&&e.removeEventListener(d,s.handle),delete a[d])}}else for(var v in a)L.event.remove(e,v+l[t],i,r,!0)}ea(a)&&(ba.remove(e,"handle"),ba.remove(e,"events"))}},L.event.dispatch=function(e){var n=L.event.fix(e),i=(n.delegateTarget=this,Array.from(arguments)),e=(i[0]=n,ba.get(this,"events")),e=e&&e[n.type]||[],r=L.event.special[n.type];if(!r||!r.preDispatch||!1!==r.preDispatch.call(this,n)){var o,s,a=L.event.handlers.call(this,n,e);let t=0;for(;(o=a[t++])&&!n.isPropagationStopped();){n.currentTarget=o.elem;let t=0;for(;(s=o.handlers[t++])&&!n.isImmediatePropagationStopped();){n.handleObj=s,n.data=s.data;var l=L.event.special[s.origType];let t;l=(t=l&&l.handle?l.handle:s.handler).apply(o.elem,i);void 0!==l&&!1===(n.result=l)&&(n.preventDefault(),n.stopPropagation())}}return r&&r.postDispatch&&r.postDispatch.call(this,n),n.result}},L.event.handlers=function(t,n){var i=n.delegateCount,r=[];if(i&&!("click"===t.type&&1<=t.button))for(let e=t.target;e!==this;e=e.parentNode||this)if(1===e.nodeType&&("click"!==t.type||!0!==e.disabled)){var o=[],s={};for(let t=0;t<i;t++){var a=n[t],l=a.selector+" ";void 0===s[l]&&(s[l]=e.matches(l)),s[l]&&o.push(a)}o.length&&r.push({elem:e,handlers:o})}return i<n.length&&r.push({elem:this,handlers:n.slice(i)}),r},L.event.fix=function(t){return t.envelope?t:new ya(t)};let ka=L(Pa),Ca="http://www.w3.org/2000/svg",Ma="http://www.w3.org/2000/xmlns/",Na="http://www.w3.org/1999/xlink";var Oa,Ra,Ia={__proto__:null,svg:Ca,xhtml:"http://www.w3.org/1999/xhtml",xlink:Na,xml:"http://www.w3.org/XML/1998/namespace",xmlns:Ma};let Va="object"==typeof window&&!!window.SVGAngle,Fa=Va?Da():null,Ba=Va?za("g"):null;function Da(){var t=za("svg");return t.setAttributeNS(Ma,"xmlns:xlink",Na),t.setAttribute("version","1.1"),t}function za(t){return document.createElementNS(Ca,t)}function ja(t,e){let n=t;do{if(n.contains(e))return n}while(n=n.parentNode);return null}function Ga(){return Fa.createSVGMatrix()}function Ua(t={}){var e=Fa.createSVGMatrix();return t&&("a"in t&&(e.a=t.a),"b"in t&&(e.b=t.b),"c"in t&&(e.c=t.c),"d"in t&&(e.d=t.d),"e"in t&&(e.e=t.e),"f"in t)&&(e.f=t.f),e}function Ha(t){t=t.transform.baseVal.consolidate();return t?t.matrix:null}function qa(t,e){var n=Fa.createSVGTransform(),e=Wa(e)?e:Ua(e);n.setMatrix(e),t.transform.baseVal.appendItem(n)}let $a="[object SVGMatrix]";function Wa(t){return Object.prototype.toString.call(t)===$a}function Ya(t={}){var{a:t=1,b:e=0,c:n=0,d:i=1,e:r=0,f:o=0}=t;return`matrix(${t},${e},${n},${i},${r},${o})`}function Xa(t,e){var n=[];let i=e;for(;i&&i.nodeType===Node.ELEMENT_NODE&&i!==t;){var r=Ha(i);r&&n.unshift(r),i=i.parentNode}return n.reduce((t,e)=>t.multiply(e),Ga())}let R=(()=>{if(!Va)return function(){throw new Error("SVG is required to use Vectorizer.")};function N(t,e,n){if(!(this instanceof N))return N.apply(Object.create(N.prototype),arguments);if(t){if(N.isV(t)&&(t=t.node),e=e||{},N.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=N.createSvgDocument();else if("<"===t[0]){var i=N.createSvgDocument(t);if(1<i.childNodes.length){for(var r=[],o=0,s=i.childNodes.length;o<s;o++){var a=i.childNodes[o];r.push(new N(document.importNode(a,!0)))}return r}t=document.importNode(i.firstChild,!0)}else t=za(t);N.ensureId(t)}return this.node=t,this.setAttributes(e),n&&this.append(n),this}}var h=(t=Math).PI,i=t.atan2,o=t.sqrt,l=t.min,a=t.max,u=t.cos,c=t.sin,t=N.prototype;Object.defineProperty(t,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),t.getTransformToElement=function(t,e){var n,i,r=this.node,t=N.toNode(t);let o;return(o=N.isSVGGraphicsElement(t)&&N.isSVGGraphicsElement(r)?e&&e.safe?(e=r)===(n=t)?Ga():(i=e.compareDocumentPosition(n))&Node.DOCUMENT_POSITION_CONTAINED_BY?Xa(e,n).inverse():i&Node.DOCUMENT_POSITION_CONTAINS?Xa(n,e):(i=ja(e,n))?(e=Xa(i,e),Xa(i,n).inverse().multiply(e)):null:(i=t,((n=r).ownerSVGElement||n)===(i.ownerSVGElement||i)&&(i=i.getScreenCTM())&&(n=n.getScreenCTM())?i.inverse().multiply(n):null):o)||Ga()},t.transform=function(t,e){var n=this.node;return N.isUndefined(t)?Ha(n)||Ga():(e&&e.absolute?n.setAttribute("transform",Ya(t)):qa(n,t),this)},t.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=N.parseTransformString(i),i=r.value;if(N.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();t=n.absolute?t:r.translate.tx+t,n=n.absolute?e:r.translate.ty+e;return this.attr("transform",("translate("+t+","+n+")"+" "+i).trim()),this},t.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=N.parseTransformString(r),r=o.value;if(N.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;i=i.absolute?t:o.rotate.angle+t;return this.attr("transform",(r+" "+("rotate("+i+(void 0!==e&&void 0!==n?","+e+","+n:"")+")")).trim()),this},t.scale=function(t,e){e=N.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=N.parseTransformString(n),n=i.value;return N.isUndefined(t)?i.scale:(n=n.replace(/scale\([^)]*\)/g,"").trim(),this.attr("transform",(n+" "+("scale("+t+","+e+")")).trim()),this)},t.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new tt(0,0,0,0);try{n=i.getBBox()}catch{n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}return t?new tt(n):(i=this.getTransformToElement(e||r),N.transformRect(n,i))},t.getBBox=function(t){var e={},n=this.node;if(!n.ownerSVGElement||!N.isSVGGraphicsElement(n))return new tt(0,0,0,0);if(t&&(t.target&&(e.target=N.toNode(t.target)),t.recursive)&&(e.recursive=t.recursive),e.recursive){var i=this.children(),r=i.length;if(0===r)return this.getBBox({target:e.target,recursive:!1});e.target||(e.target=this);for(var o=0;o<r;o++)var s=i[o],s=0===s.children().length?s.getBBox({target:e.target,recursive:!1}):s.getBBox({target:e.target,recursive:!0}),a=a?a.union(s):s;return a}try{a=n.getBBox()}catch{a={x:n.clientLeft,y:n.clientTop,width:n.clientWidth,height:n.clientHeight}}return e.target?(t=this.getTransformToElement(e.target),N.transformRect(a,t)):new tt(a)};var y,b,E,T,S,_,L,k,C,O=/em$/;function R(t,e){var n=parseFloat(t);return O.test(t)?n*e:n}t.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");t=N.sanitizeText(t);for(var n,i,r,o,s=(e=e||{}).displayEmpty,a=e.eol,l=e.textPath,h=e.textVerticalAnchor,u="middle"===h||"bottom"===h||"top"===h,c=e.x,d=(void 0===c&&(c=this.attr("x")||0),e.includeAnnotationIndices),f=e.annotations,e=(f&&!N.isArray(f)&&(f=[f]),e.lineHeight),p="auto"===e,g=p?"1.5em":e||"1em",m=(this.empty(),this.attr({"xml:space":"preserve",display:t||s?null:"none"}),parseFloat(this.attr("font-size"))),v=(!m&&(m=16,u||f)&&this.attr("font-size",m),document),y=l?(e=this,s=(s=l="string"==typeof l?{d:l}:l)||{},n=N("textPath"),(i=s.d)&&void 0===s["xlink:href"]&&(i=N("path").attr("d",i).appendTo(e.defs()),n.attr("xlink:href","#"+i.id)),N.isObject(s)&&n.attr(s),n.node):v.createDocumentFragment(),b=0,x=t.split("\n"),w=[],A=0,P=x.length-1;A<=P;A++){var E,T,S=g,_="v-line",L=v.createElementNS(Ca,"tspan"),k=x[A];if(k)f?((C=(T=((t,e,n)=>{for(var i=(n=n||{}).includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,n={},l=e.length-1,h=0;h<=l;h++){var u,c,d,f,p=e[h],g=null;N.isObject(p)?(u=p.attrs,d=(c=N("tspan",u)).node,f=p.t,r&&h===l&&(f+=r),d.textContent=f,(f=u.class)&&c.addClass(f),i&&c.attr("annotations",p.annotations),g=parseFloat(u["font-size"]),(g=isFinite(g)?g:s)&&a<g&&(a=g)):(r&&h===l&&(p+=r),d=document.createTextNode(p||" "),s&&a<s&&(a=s)),t.appendChild(d)}return a&&(n.maxFontSize=a),o?n.lineHeight=o:a&&(n.lineHeight=1.2*a),n})(L,E=N.annotateString(k,f,{offset:-b,includeAnnotationIndices:d}),{includeAnnotationIndices:d,eol:A!==P&&a,lineHeight:p?null:g,baseSize:m})).lineHeight)&&p&&0!==A&&(S=C),0===A&&(r=.8*T.maxFontSize)):(a&&A!==P&&(k+=a),L.textContent=k);else{L.textContent="-",_+=" v-empty-line";var C=L.style;if(C.fillOpacity=0,C.strokeOpacity=0,f){T={};let e=m;for(let t=(E=N.findAnnotationsAtIndex(f,b)).length;0<t;t--){var M=E[t-1].attrs;if(M&&"font-size"in M){M=parseFloat(M["font-size"]);if(isFinite(M)){e=M;break}}}p&&(0<A?S=1.2*e:r=.8*e),L.setAttribute("font-size",e),T.maxFontSize=e}}T&&w.push(T),0<A&&L.setAttribute("dy",S),(0<A||l)&&L.setAttribute("x",c),L.className.baseVal=_,y.appendChild(L),b+=k.length+1}if(u)if(f)S=((t,e,n,i)=>{if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=R(o.maxFontSize,n)||n,a=0,l=R(i,n),h=1;h<r;h++)a+=R((o=e[h]).lineHeight,n)||l;var u,c=R(o.maxFontSize,n)||n;switch(t){case"middle":u=s/2-.15*c-a/2;break;case"bottom":u=-.25*c-a;break;default:u=.8*s}return u})(h,w,m,g);else if("top"===h)S="0.8em";else switch(0<P?(o=parseFloat(g)||1,o*=P,O.test(g)||(o/=m)):o=0,h){case"middle":S=.3-o/2+"em";break;case"bottom":S=-o-.3+"em"}else 0===h?S="0em":h?S=h:(S=0,null===this.attr("y")&&this.attr("y",r||"0.8em"));return y.firstChild.setAttribute("dy",S),this.append(y),this},t.removeAttr=function(t){var t=s[t],{ns:e,local:n}=N.qualifyAttr(t),i=this.node;return e?i.hasAttributeNS(e,n)&&i.removeAttributeNS(e,n):i.hasAttribute(t)&&i.removeAttribute(t),this},t.attr=function(t,e){if(N.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(N.isString(t)&&N.isUndefined(e))return this.node.getAttribute(s[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},t.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",N.normalizePathData(this.attr("d"))),this},t.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},t.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},t.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},t.append=function(t){for(var e=0,n=(t=N.isArray(t)?t:[t]).length;e<n;e++)this.node.appendChild(N.toNode(t[e]));return this},t.prepend=function(t){var e=this.node.firstChild;return e?N(e).before(t):this.append(t)},t.before=function(t){var e=this.node,n=e.parentNode;if(n)for(var i=0,r=(t=N.isArray(t)?t:[t]).length;i<r;i++)n.insertBefore(N.toNode(t[i]),e);return this},t.appendTo=function(t){return N.toNode(t).appendChild(this.node),this},t.svg=function(){return this.node instanceof window.SVGSVGElement?this:N(this.node.ownerSVGElement)},t.tagName=function(){return this.node.tagName.toUpperCase()},t.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?N(e):N("defs").appendTo(t)},t.clone=function(){var t=N(this.node.cloneNode(!0));return t.node.id=N.uniqueId(),t},t.findOne=function(t){t=this.node.querySelector(t);return t?N(t):void 0},t.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(N(n[i]));return e},t.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(N(t[n]));return e},t.parent=function(){return N(this.node.parentNode)||null},t.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},t.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=N(i);if(r.hasClass(t))return r;i=i.parentNode}return null},t.contains=function(t){var e=this.node,t=N.toNode(t),t=t&&t.parentNode;return e===t||!!(t&&1===t.nodeType&&16&e.compareDocumentPosition(t))},t.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{return i}return r.matrixTransform(o)},t.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},t.translateAndAutoOrient=function(t,e,n){t=new A(t),e=new A(e),n=n||this.svg();var i=this.scale(),r=(this.attr("transform",""),this.getBBox({target:n}).scale(i.sx,i.sy)),o=N.createSVGTransform(),s=(o.setTranslate(-r.x-r.width/2,-r.y-r.height/2),N.createSVGTransform()),a=t.angleBetween(e,t.clone().offset(1,0)),a=(a&&s.setRotate(a,0,0),N.createSVGTransform()),e=t.clone().move(e,r.width/2),r=(a.setTranslate(2*t.x-e.x,2*t.y-e.y),this.getTransformToElement(n)),t=N.createSVGTransform();return t.setMatrix(a.matrix.multiply(s.matrix.multiply(o.matrix.multiply(r.scale(i.sx,i.sy))))),this.attr("transform",Ya(t.matrix)),this},t.animateAlongPath=function(t,e){e=N.toNode(e);e=N.ensureId(e),t=N("animateMotion",t),e=N("mpath",{"xlink:href":"#"+e});t.append(e),this.append(t);try{t.node.beginElement()}catch{if("fake"===document.documentElement.getAttribute("smiling"))for(var n=t.node,e=(n.animators=[],n.getAttribute("id")),i=(e&&(id2anim[e]=n),getTargets(n)),r=0,o=i.length;r<o;r++){var s=i[r],s=new Animator(n,s,r);animators.push(s),(n.animators[r]=s).register()}}return this};let e=/[^\x20\t\r\n\f]+/g;function r(t){return N.isString(t)&&t.trim().match(e)||[]}t.hasClass=function(t){return!!N.isString(t)&&this.node.classList.contains(t.trim())},t.addClass=function(t){return this.node.classList.add(...r(t)),this},t.removeClass=function(t){return this.node.classList.remove(...r(t)),this},t.toggleClass=function(t,e){var n=r(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},t.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},t.convertToPath=function(){var t=N("path"),e=(t.attr(this.attr()),this.convertToPathData());return e&&t.attr("d",e),t},t.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return N.convertLineToPathData(this.node);case"POLYGON":return N.convertPolygonToPathData(this.node);case"POLYLINE":return N.convertPolylineToPathData(this.node);case"ELLIPSE":return N.convertEllipseToPathData(this.node);case"CIRCLE":return N.convertCircleToPathData(this.node);case"RECT":return N.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},N.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s;switch(this.tagName()){case"RECT":return i=parseFloat(this.attr("x"))||0,s=parseFloat(this.attr("y"))||0,t=parseFloat(this.attr("width"))||0,n=parseFloat(this.attr("height"))||0,new tt(i,s,t,n);case"CIRCLE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,i=parseFloat(this.attr("r"))||0,new vi({x:o,y:r},i,i);case"ELLIPSE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,t=parseFloat(this.attr("ry"))||0,new vi({x:o,y:r},s,t);case"POLYLINE":return e=N.getPointsFromSvgNode(this),new x(e);case"POLYGON":return 1<(e=N.getPointsFromSvgNode(this)).length&&e.push(e[0]),new x(e);case"PATH":return n=this.attr("d"),V.isDataSupported(n)||(n=N.normalizePathData(n)),new V(n);case"LINE":return i=parseFloat(this.attr("x1"))||0,o=parseFloat(this.attr("y1"))||0,r=parseFloat(this.attr("x2"))||0,s=parseFloat(this.attr("y2"))||0,new P({x:i,y:o},{x:r,y:s})}return this.getBBox()},t.findIntersection=function(t,e){var n=this.svg().node,i=this.getBBox({target:e=e||n}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){i=this.tagName();if("RECT"===i)var o=new tt(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),s=this.getTransformToElement(e),a=N.decomposeMatrix(s),n=n.createSVGTransform(),o=(n.setRotate(-a.rotation,r.x,r.y),N.transformRect(o,n.matrix.multiply(s))),s=new tt(o).intersectionWithLineFromCenterToPoint(t,a.rotation);else if("PATH"===i||"POLYGON"===i||"POLYLINE"===i||"CIRCLE"===i||"ELLIPSE"===i){for(var l,h,u,c=("PATH"===i?this:this.convertToPath()).sample(),d=1/0,f=[],p=0;p<c.length;p++)l=c[p],h=(h=N.createSVGPoint(l.x,l.y)).matrixTransform(this.getTransformToElement(e)),(u=(l=new A(h)).distance(r)+(h=1.1*l.distance(t)))<d?(d=u,f=[{sample:l,refDistance:h}]):u<d+1&&f.push({sample:l,refDistance:h});f.sort(function(t,e){return t.refDistance-e.refDistance}),f[0]&&(s=f[0].sample)}return s}},t.setAttribute=function(t,e){var n,i=this.node;return null===e?this.removeAttr(t):(t=s[t],n=N.qualifyAttr(t).ns,n?i.setAttributeNS(n,t,e):"id"===t?i.id=e:i.setAttribute(t,e)),this},N.createSvgDocument=function(t){return t?(t=`<svg xmlns="${Ca}" xmlns:xlink="${Na}" version="1.1">${t}</svg>`,t=N.parseXML(t,{async:!1}).documentElement,t):Da()},N.createSVGStyle=function(t){t=N("style",{type:"text/css"},[N.createCDATASection(t)]).node;return t},N.createCDATASection=function(t=""){return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},N.idCounter=0,N.uniqueId=function(){return"v-"+ ++N.idCounter},N.toNode=function(t){return N.isV(t)?t.node:t.nodeName&&t||t[0]},N.ensureId=function(t){return(t=N.toNode(t)).id||(t.id=N.uniqueId())},N.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},N.isUndefined=function(t){return void 0===t},N.isString=function(t){return"string"==typeof t},N.isObject=function(t){return t&&"object"==typeof t},N.isArray=Array.isArray,N.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;N.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch{n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};let n=Object.create(null),s=(["attributeName","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","repeatCount","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach(t=>n[t]=t),n.xlinkShow="xlink:show",n.xlinkRole="xlink:role",n.xlinkActuate="xlink:actuate",n.xlinkHref="xlink:href",n.xlinkType="xlink:type",n.xlinkTitle="xlink:title",n.xmlBase="xml:base",n.xmlLang="xml:lang",n.xmlSpace="xml:space",new Proxy(n,{get(t,e){return N.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e}}));function f(t,e,n,i,r,o){return[1/3*t+2/3*n,1/3*e+2/3*i,1/3*r+2/3*n,1/3*o+2/3*i,r,o]}function M(t,e,n){return{x:t*S(n)-e*T(n),y:t*T(n)+e*S(n)}}function I(t,e,n,i,r,o,s,a,l,h){var u=120*E/180,c=E/180*(+r||0),d=[];if(h)b=h[0],x=h[1],v=h[2],y=h[3];else{t=(p=M(t,e,-c)).x,e=p.y;var f=(t-(a=(p=M(a,l,-c)).x))/2,p=(e-(l=p.y))/2,g=f*f/(n*n)+p*p/(i*i),g=(1<g&&(n*=g=k(g),i*=g),n*n),m=i*i,o=(o==s?-1:1)*k(C((g*m-g*p*p-m*f*f)/(g*p*p+m*f*f)));if(!Number.isFinite(o))return[t,e,a,l,a,l];var v=o*n*p/i+(t+a)/2,y=o*-i*f/n+(e+l)/2,b=L(((e-y)/i).toFixed(9)),x=L(((l-y)/i).toFixed(9));(b=t<v?E-b:b)<0&&(b=2*E+b),(x=a<v?E-x:x)<0&&(x=2*E+x),s&&x<b&&(b-=2*E),!s&&b<x&&(x-=2*E)}C(x-b)>u&&(g=x,m=a,p=l,d=I(a=v+n*S(x=b+u*(s&&b<x?1:-1)),l=y+i*T(x),n,i,r,0,s,m,p,[x,g,v,y])),o=x-b;f=S(b),u=T(b),r=S(x),s=T(x),m=_(o/4),p=4/3*(n*m),g=4/3*(i*m),v=[t,e],y=[t+p*u,e-g*f],b=[a+p*s,l-g*r],x=[a,l];if(y[0]=2*v[0]-y[0],y[1]=2*v[1]-y[1],h)return[y,b,x].concat(d);for(var w=[],A=(d=[y,b,x].concat(d).join().split(",")).length,P=0;P<A;P++)w[P]=P%2?M(d[P-1],d[P],c).y:M(d[P],d[P+1],c).x;return w}function p(t){var e,o,s;if(!(t=Array.isArray(t)&&Array.isArray(t&&t[0])?t:(e=t)?(o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=[],String(e).replace(y,function(t,e,n){var i=[],r=e.toLowerCase();for(n.replace(b,function(t,e){e&&i.push(+e)}),"m"===r&&2<i.length&&(s.push([e].concat(i.splice(0,2))),r="l",e="m"===e?"l":"L");o[r]<=i.length&&(s.push([e].concat(i.splice(0,o[r]))),o[r]););}),s):null)||!t.length)return[["M",0,0]];for(var n=[],i=0,r=0,a=0,l=0,h=t.length,u=0;u<h;u++){var c,d,f=[],p=(n.push(f),t[u]),g=p[0];if(g!=g.toUpperCase())switch(f[0]=g.toUpperCase(),f[0]){case"A":f[1]=p[1],f[2]=p[2],f[3]=p[3],f[4]=p[4],f[5]=p[5],f[6]=+p[6]+i,f[7]=+p[7]+r;break;case"V":f[1]=+p[1]+r;break;case"H":f[1]=+p[1]+i;break;case"M":for(a=+p[1]+i,l=+p[2]+r,c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r);break;default:for(c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r)}else for(var m=p.length,v=0;v<m;v++)f[v]=p[v];switch(f[0]){case"Z":i=+a,r=+l;break;case"H":i=f[1];break;case"V":r=f[1];break;case"M":a=f[f.length-2],l=f[f.length-1],i=f[f.length-2],r=f[f.length-1];break;default:i=f[f.length-2],r=f[f.length-1]}}return n}function d(t){var e=p(t),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};for(var i=[],r="",o="",s=e.length,a=0;a<s;a++){"C"!==(r=e[a]?e[a][0]:r)&&(i[a]=r,0<a)&&(o=i[a-1]),e[a]=((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(I.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":r="C"===n||"S"===n?(i=2*e.x-e.bx,2*e.y-e.by):(i=e.x,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(f(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(f(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})(e[a],n,o),"A"!==i[a]&&"C"===r&&(i[a]="C"),u=h=l=void 0;var l=e,h=a;if(7<l[h].length){l[h].shift();for(var u=l[h];u.length;)i[h]="A",l.splice(h++,0,["C"].concat(u.splice(0,6)));l.splice(h,1),s=e.length}var c=e[a],d=c.length;n.x=c[d-2],n.y=c[d-1],n.bx=parseFloat(c[d-4])||n.x,n.by=parseFloat(c[d-3])||n.y}return e[0][0]&&"M"===e[0][0]||e.unshift(["M",0,0]),e}return Object.defineProperty(N,"attributeNames",{enumerable:!0,value:s,writable:!1}),Object.defineProperty(N,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),N.qualifyAttr=function(t){var e;return-1!==t.indexOf(":")?(e=t.split(":"),{ns:Ia[e[0]],local:e[1]}):{ns:null,local:t}},N.transformSeparatorRegex=/[ ,]+/,N.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,N.transformTranslateRegex=/\btranslate\(([^()]+)\)/,N.transformRotateRegex=/\brotate\(([^()]+)\)/,N.transformScaleRegex=/\bscale\(([^()]+)\)/,N.transformStringToMatrix=function(t){let e;return(e=N.isString(t)?(t=t,Ba.setAttribute("transform",t),Ha(Ba)):e)||Ga()},N.matrixToTransformString=Ya,N.parseTransformString=function(t){t&&(e=N.transformSeparatorRegex,0<=t.trim().indexOf("matrix")?(r=N.transformStringToMatrix(t),n=[(r=N.decomposeMatrix(r)).translateX,r.translateY],i=[r.scaleX,r.scaleY],r=[r.rotation],o=[],0===n[0]&&0===n[1]||o.push("translate("+n+")"),1===i[0]&&1===i[1]||o.push("scale("+i+")"),0!==r[0]&&o.push("rotate("+r+")"),t=o.join(" ")):((o=t.match(N.transformTranslateRegex))&&(n=o[1].split(e)),(o=t.match(N.transformRotateRegex))&&(r=o[1].split(e)),(o=t.match(N.transformScaleRegex))&&(i=o[1].split(e))));var e,n,i,r,o=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:n&&n[0]?parseInt(n[0],10):0,ty:n&&n[1]?parseInt(n[1],10):0},rotate:{angle:r&&r[0]?parseInt(r[0],10):0,cx:r&&r[1]?parseInt(r[1],10):void 0,cy:r&&r[2]?parseInt(r[2],10):void 0},scale:{sx:o,sy:i&&i[1]?parseFloat(i[1]):o}}},N.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c,y:e.x*t.b+e.y*t.d}},N.decomposeMatrix=function(t){var e=N.deltaTransformPoint(t,{x:0,y:1}),n=N.deltaTransformPoint(t,{x:1,y:0}),e=180/h*i(e.y,e.x)-90,n=180/h*i(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:e,skewY:n,rotation:e}},N.matrixToScale=function(t){var e,n,i,r;return t?(e=N.isUndefined(t.a)?1:t.a,r=N.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}},N.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=N.deltaTransformPoint(t,e)),{angle:Yn(Un(i(e.y,e.x))-90)}},N.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},N.isVElement=N.isV=function(t){return t instanceof N},N.isSVGGraphicsElement=function(t){return!!t&&(t=N.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM},N.createSVGMatrix=Ua,N.createSVGTransform=function(t){return N.isUndefined(t)?Fa.createSVGTransform():(Wa(t)||(t=Ua(t)),Fa.createSVGTransformFromMatrix(t))},N.createSVGPoint=function(t,e){var n=Fa.createSVGPoint();return n.x=t,n.y=e,n},N.transformRect=function(t,e){var n=Fa.createSVGPoint(),i=(n.x=t.x,n.y=t.y,n.matrixTransform(e)),r=(n.x=t.x+t.width,n.y=t.y,n.matrixTransform(e)),o=(n.x=t.x+t.width,n.y=t.y+t.height,n.matrixTransform(e)),t=(n.x=t.x,n.y=t.y+t.height,n.matrixTransform(e)),n=l(i.x,r.x,o.x,t.x),e=a(i.x,r.x,o.x,t.x),s=l(i.y,r.y,o.y,t.y),i=a(i.y,r.y,o.y,t.y);return new tt(n,s,e-n,i-s)},N.transformPoint=function(t,e){return new A(N.createSVGPoint(t.x,t.y).matrixTransform(e))},N.transformLine=function(t,e){return new P(N.transformPoint(t.start,e),N.transformPoint(t.end,e))},N.transformPolyline=function(t,e){for(var n=t instanceof x?t.points:t,i=[],r=0,o=(n=N.isArray(n)?n:[]).length;r<o;r++)i[r]=N.transformPoint(n[r],e);return new x(i)},N.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},N.createSlicePathData=function(t,e,n,i){var r=2*h-1e-6,o=(i<n&&(o=n,n=i,i=o),i-n),s=o<h?"0":"1",a=u(n),n=c(n),l=u(i),i=c(i);return r<=o?t?"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":t?"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L"+t*l+","+t*i+"A"+t+","+t+" 0 "+s+",0 "+t*a+","+t*n+"Z":"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L0,0Z"},N.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?N.isObject(t[n])&&N.isObject(e[n])?t[n]=N.mergeAttrs(t[n],e[n]):N.isObject(t[n])?t[n]=N.mergeAttrs(t[n],N.styleToObject(e[n])):N.isObject(e[n])?t[n]=N.mergeAttrs(N.styleToObject(t[n]),e[n]):t[n]=N.mergeAttrs(N.styleToObject(t[n]),N.styleToObject(e[n])):t[n]=e[n];return t},N.annotateString=function(t,e,n){e=e||[];for(var i,r,o=(n=n||{}).offset||0,s=[],a=[],l=0;l<t.length;l++){for(var h=a[l]=t[l],u=0;u<e.length;u++){var c=e[u];c.start+o<=l&&l<c.end+o&&(N.isObject(h)?h.attrs=N.mergeAttrs(N.mergeAttrs({},h.attrs),c.attrs):h=a[l]={t:t[l],attrs:c.attrs},n.includeAnnotationIndices)&&(h.annotations||(h.annotations=[])).push(u)}(r=a[l-1])?N.isObject(h)&&N.isObject(r)?JSON.stringify(h.attrs)===JSON.stringify(r.attrs)?i.t+=h.t:(s.push(i),i=h):i=N.isObject(h)||N.isObject(r)?(s.push(i),h):(i||"")+h:i=h}return i&&s.push(i),s},N.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&n.push(t)}),n},N.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},N.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},N.convertLineToPathData=function(t){return["M",(t=N(t)).attr("x1")||"0",t.attr("y1")||"0","L",t.attr("x2")||"0",t.attr("y2")||"0"].join(" ")},N.convertPolygonToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)+" Z"},N.convertPolylineToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)},N.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")},N.getPointsFromSvgNode=function(t){var e=[],n=(t=N.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},N.KAPPA=.551784,N.convertCircleToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,t=parseFloat(t.attr("r")),i=t*N.KAPPA;return["M",e,n-t,"C",e+i,n-t,e+t,n-i,e+t,n,"C",e+t,n+i,e+i,n+t,e,n+t,"C",e-i,n+t,e-t,n+i,e-t,n,"C",e-t,n-i,e-i,n-t,e,n-t,"Z"].join(" ")},N.convertEllipseToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),t=parseFloat(t.attr("ry"))||i,r=i*N.KAPPA,o=t*N.KAPPA;return["M",e,n-t,"C",e+r,n-t,e+i,n-o,e+i,n,"C",e+i,n+o,e+r,n+t,e,n+t,"C",e-r,n+t,e-i,n+o,e-i,n,"C",e-i,n-o,e-r,n-t,e,n-t,"Z"].join(" ")},N.convertRectToPathData=function(t){return t=N(t),N.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})},N.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=l(t.rx||t["top-rx"]||0,i/2),s=l(t.rx||t["bottom-rx"]||0,i/2),a=l(t.ry||t["top-ry"]||0,r/2),t=l(t.ry||t["bottom-ry"]||0,r/2),s=o||s||a||t?["M",e,n+a,"v",r-a-t,"a",s,t,0,0,0,s,t,"h",i-2*s,"a",s,t,0,0,0,s,-t,"v",-(r-t-a),"a",o,a,0,0,0,-o,-a,"h",-(i-2*o),"a",o,a,0,0,0,-o,a,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"];return s.join(" ")},N.normalizePathData=(t="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",y=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),b=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),t=Math,E=t.PI,T=t.sin,S=t.cos,_=t.tan,L=t.asin,k=t.sqrt,C=t.abs,function(t){return d(t).join(",").split(",").join(" ")}),N.getCommonAncestor=function(t,e){return t&&e?ja(N.toNode(t),N.toNode(e)):null},N.namespace={...Ia},N.g=yr,N})();function Za(t){let e=t.length;for(;e--;)Ja(t[e])}function Ja(t){L.event.remove(t),ba.remove(t),xa.remove(t)}function Ka(e){for(let t=0;t<e.length;t++){var n=e[t];n.parentNode&&n.parentNode.removeChild(n)}}let Qa={};function tl(e,n,i){for(let t=0;t<n.length;t++){var r=n[t];R.prototype[e].apply({node:r},i)}}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach(t=>{Qa[t]=!0});let el={__proto__:null,addClass:function(){return tl("addClass",this,arguments),this},append:function(...t){let[e]=this;return e&&t.forEach(t=>{t&&("string"==typeof t?e.append(...L.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))}),this},appendTo:function(t){return L(t).append(this),this},children:function(n){var i=[];for(let e=0;e<this.length;e++){var r=this[e];let t=Array.from(r.children);"string"==typeof n&&(t=t.filter(t=>t.matches(n))),i.push(...t)}return this.pushStack(i)},clone:function(){var e=[];for(let t=0;t<this.length;t++)e.push(this[t].cloneNode(!0));return this.pushStack(e)},closest:function(e){var n=[];for(let t=0;t<this.length;t++){var i,r=this[t];"string"==typeof e?(i=r.closest(e))&&n.push(i):([i]=L(e),i&&i.contains(r)&&n.push(i))}return this.pushStack(n)},css:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.style[t]:null;n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let e in n)if(n.hasOwnProperty(e))for(let t=0;t<this.length;t++)r=this[t],o=e,"number"==typeof(s=n[e])&&Qa[pa(o)]&&(s+="px"),r.style[o]=s;var r,o,s;return this},data:function(e,n){var t;if(arguments.length<2)return[t]=this,t?void 0===e?t.dataset:t.dataset[e]:null;for(let t=0;t<this.length;t++)this[t].dataset[e]=n;return this},detach:function(){return Ka(this),this},empty:function(){for(let t=0;t<this.length;t++){var e=this[t];1===e.nodeType&&(Za(e.getElementsByTagName("*")),e.textContent="")}return this},hasClass:function(){var[t]=this;return!!t&&R.prototype.hasClass.apply({node:t},arguments)},height:function(){var t,[e]=this;return e===window?e.document.documentElement.clientHeight:e?(t=window.getComputedStyle(e),e.offsetHeight-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)):void 0},html:function(t){var[e]=this;if(!e)return null;if(0===arguments.length)return e.innerHTML;if(void 0!==t){if(Za(e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t)return e.innerHTML="",this.append(t);e.innerHTML=t}return this},off:function(e,n,i){var t;if(e&&e.preventDefault&&e.handleObj)t=e.handleObj,L(e.delegateTarget).off(t.namespace?t.origType+"."+t.namespace:t.origType,t.selector,t.handler);else if("object"==typeof e)for(var r in e)this.off(r,n,e[r]);else{!1!==n&&"function"!=typeof n||(i=n,n=void 0);for(let t=0;t<this.length;t++)L.event.remove(this[t],e,i,n)}return this},offset:function(t){var e,n,[i]=this;return void 0===t?i?i.getClientRects().length?{top:(e=i.getBoundingClientRect()).top+window.scrollY,left:e.left+window.scrollX}:{top:0,left:0}:null:(i&&("static"===(e=window.getComputedStyle(i)).position&&this.css("position","relative"),i=this.offset(),n=t.top-i.top,t=t.left-i.left,this.css({top:(parseFloat(e.top)||0)+n+"px",left:(parseFloat(e.left)||0)+t+"px"})),this)},on:function(t,e,n,i){return L.event.on(this,t,e,n,i),this},one:function(t,e,n,i){return L.event.on(this,t,e,n,i,1),this},position:function(){var[i]=this;if(i){var r,o=L(i);let t,e,n={top:0,left:0};if("fixed"===o.css("position"))e=i.getBoundingClientRect();else{e=o.offset(),r=i.ownerDocument,t=i.offsetParent||r.documentElement;for(var s=t=>{t=getComputedStyle(t).position;return"static"===t};t&&t!==r.documentElement&&s(t);)t=t.offsetParent||r.documentElement;t&&t!==i&&1===t.nodeType&&!s(t)&&(o=window.getComputedStyle(t),a=parseFloat(o.borderTopWidth)||0,o=parseFloat(o.borderLeftWidth)||0,(n=L(t).offset()).top+=a,n.left+=o)}var a=parseFloat(window.getComputedStyle(i).marginTop)||0,o=parseFloat(window.getComputedStyle(i).marginLeft)||0;return{top:e.top-n.top-a,left:e.left-n.left-o}}},prepend:function(...t){let[e]=this;return e&&t.forEach(t=>{t&&("string"==typeof t?e.prepend(...L.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))}),this},prependTo:function(t){return L(t).prepend(this),this},remove:function(){for(let t=0;t<this.length;t++){var e=this[t];Ja(e),Za(e.getElementsByTagName("*"))}return Ka(this),this},removeClass:function(){return tl("removeClass",this,arguments),this},toggleClass:function(){return tl("toggleClass",this,arguments),this},width:function(){var t,e,[n]=this;return n===window?n.document.documentElement.clientWidth:n?(t=window.getComputedStyle(n),n=n.offsetWidth,e=parseFloat(t.borderTopWidth),n-parseFloat(t.borderBottomWidth)-e-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)):void 0}},nl="animationFrameId",il={},rl=(il["transition-property"]=il["transition-duration"]=il["transition-delay"]=il["transition-timing-function"]=il["animation-name"]=il["animation-duration"]=il["animation-delay"]=il["animation-timing-function"]="",{__proto__:null,animate:function(e,n={}){this.stop();for(let t=0;t<this.length;t++)((a,l,t={})=>{let{duration:h=400,easing:u="ease-in-out",delay:c=0,complete:d}=t,e=setTimeout(function(){let e=L(a),n=!1,i="transitionend";h/=1e3,c/=1e3;var t={};if("string"==typeof l)t["animation-name"]=l,t["animation-duration"]=h+"s",t["animation-delay"]=c+"s",t["animation-timing-function"]=u,i="animationend";else{var r,o=[];for(r in l)l.hasOwnProperty(r)&&(t[r]=l[r],o.push(r));0<h&&(t["transition-property"]=o.join(", "),t["transition-duration"]=h+"s",t["transition-delay"]=c+"s",t["transition-timing-function"]=u)}let s=function(t){if(t){if(t.target!==t.currentTarget)return;t.target.removeEventListener(i,s)}else a.removeEventListener(i,s);n=!0,e.css(il),d&&d.call(a)};if(0<h){a.addEventListener(i,s);let t=setTimeout(function(){n||s(null)},1e3*(h+c)+25);ba.set(a,nl,{id:t,stop:()=>{clearTimeout(t),a.removeEventListener(i,s)}})}e.css(t),h<=0&&s(null)});ba.set(a,nl,{stop:()=>clearTimeout(e)})})(this[t],e,n);return this},stop:function(){for(let t=0;t<this.length;t++){var e=this[t],n=ba.get(e,nl);n&&(n.stop(),ba.remove(e,nl))}return this.css(il),this}}),ol={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},sl={disabled:"disabled",value:"value",text:"textContent"};function al(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,hl.classNamePrefix.length)!==hl.classNamePrefix?hl.classNamePrefix+t:t}).join(" ")}let ll={prop:function(e,n){if(!e)throw new Error("no property provided");var t;if(1===arguments.length)return[t]=this,t?t[e]:null;if(void 0!==n)for(let t=0;t<this.length;t++)this[t][e]=n;return this},attr:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.getAttribute(t):null;n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(var r in n)if(n.hasOwnProperty(r)){let e=n[r];if(sl[r])this.prop(sl[r],e);else for(let t=0;t<this.length;t++)null===e?this[t].removeAttribute(r):this[t].setAttribute(r,e)}return this}},hl=(Object.keys(ol).forEach(e=>{ll[e]=function(...t){return this.prop(ol[e],...t)}}),{useCSSSelectors:!1,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300}),ul=Object.create(null),cl=(ul.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach(([t,r])=>{ul[t]={delegateType:r,bindType:r,handle:function(t){var e=t.relatedTarget,n=t.handleObj;let i;return e&&this.contains(e)||(t.type=n.origType,i=n.handler.apply(this,arguments),t.type=r),i}}}),hl.doubleTapInterval);function dl(t,e){let d={},f={},p=R.namespace.svg;var e=e||p,n=document.createDocumentFragment();function g(e,n,i){for(let t=0;t<e.length;t++){var r=e[t];if("string"==typeof r){var o=document.createTextNode(r);n.appendChild(o)}else{if(!r.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var o=r.tagName,s=r.hasOwnProperty("namespaceURI")?r.namespaceURI:i,a=document.createElementNS(s,o),l=s===p,h=(l?R:L)(a),u=r.attributes,u=(u&&h.attr(u),r.style);if(u&&L(a).css(u),r.hasOwnProperty("className")&&(u=r.className,l?a.className.baseVal=u:a.className=u),r.hasOwnProperty("textContent")&&(a.textContent=r.textContent),r.hasOwnProperty("selector")){l=r.selector;if(d[l])throw new Error("json-dom-parser: selector must be unique");d[l]=a,h.attr("joint-selector",l)}if(r.hasOwnProperty("groupSelector")){let n=r.groupSelector;Array.isArray(n)||(n=[n]);for(let e=0;e<n.length;e++){var c=n[e];let t=f[c];(t=t||(f[c]=[])).push(a)}}n.appendChild(a);u=r.children;Array.isArray(u)&&g(u,a,s)}}}return g(t,n,e),{fragment:n,selectors:d,groupSelectors:f}}function fl(e){let n=0;if(0!==e.length)for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return n}function pl(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}function gl(t,e){return("constructor"!==(e="string"!=typeof e&&"number"!=typeof e?String(e):e)||"function"!=typeof t[e])&&"__proto__"!==e}function ml(e,t,n,i){var r=Array.isArray(t)?t:t.split(i||"/"),o=r.length-1;let s=e,a=0;for(;a<o;a++){var l=r[a];if(!gl(s,l))return e;let t=s[l];s=t||(s[l]={})}return s[r[o]]=n,e}function vl(t,e,n){var i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){var a=i[s];if(!gl(o,a))return t;a=o[a];if(!a)return t;o=a}return delete o[i[r]],t}function yl(t,e,n){e=e||"/";var i,r={};for(i in t)if(t.hasOwnProperty(i)){var o="object"==typeof t[i];if(o=o&&n&&n(t[i])?!1:o){var s,a=yl(t[i],e,n);for(s in a)a.hasOwnProperty(s)&&(r[i+e+s]=a[s])}else r[i]=t[i]}return r}function bl(){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)})}function xl(t){return xl.id=xl.id||1,void 0===t?"j_"+xl.id++:(t.id=void 0===t.id?"j_"+xl.id++:t.id,t.id)}function k(t){if(!t.normalized){var{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(var r in i)void 0===t[r]&&(t[r]=i[r]);n&&(e=n.correspondingUseElement)&&(t.target=e),t.normalized=!0}return t}function wl(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}}function Al(t,e){return e<t?e:t<-e?-e:t}function Pl(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 E(e)&&(i=e);return n=i,null===(e=(n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+n+")$").exec(t))?n[1]:null)?null:(r.unit=e,r)}ul.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t,...e){var{handleObj:n,target:i}=t,i=L.data.create(i),r=(new Date).getTime(),o="lastTouch"in i?r-i.lastTouch:0;o<cl&&30<o?(i.lastTouch=null,t.type=n.origType,n.handler.call(this,t,...e)):i.lastTouch=r}},Object.assign(L.fn,el),Object.assign(L.fn,rl),Object.assign(L.fn,ll),Object.assign(L.event.special,ul),(Ra="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame:Ra)||(Oa=0,Ra=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-Oa)),i=setTimeout(function(){t(e+n)},n);return Oa=e+n,i});let El=function(t,e,...n){return Ra(void 0!==e?t.bind(e,...n):t)},Tl=(hn="undefined"!=typeof window,f=(f=hn?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame:f)||clearTimeout,hn?f.bind(window):f),Sl=function(t){return E(t)&&"%"===t.slice(-1)},_l=0;function Ll(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}}function kl(t,e,n={},i={}){var r,o=e.width,s=e.height,e=i.svgDocument||R("svg").node,a=R("tspan").node,l=R("text").attr(n).append(a).node,h=document.createTextNode(""),u=(l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(h),e.appendChild(l),i.svgDocument||document.body.appendChild(e),i.preserveSpaces),c=i.separator||""===i.separator?i.separator:" ",d="string"==typeof c?c:" ",f=i.eol||"\n",p=i.hyphen?new RegExp(i.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=i.maxLineCount,m=(qs(g)||(g=1/0),t.split(c)),v=[],y=[];u&&R(a).attr("xml:space","preserve");for(var b=0,x=0,w=m.length;b<w;b++){var A=m[b];if((A||u)&&"string"==typeof A){var P=!1;if(f&&0<=A.indexOf(f)){if(1<A.length){var E=((t,n)=>{var i=t.split(n);let r=1;for(let t=0,e=i.length-1;t<e;t++){var o=[];(0<t||""!==i[0])&&o.push(_l),o.push(n),(t<e-1||""!==i[e])&&o.push(_l),i.splice(r,0,...o),r+=o.length+1}return i.filter(t=>""!==t)})(m[b],f);m.splice(b,1,...E),b--,w=m.length;continue}if(u&&"string"==typeof m[b-1]){m.splice(b,_l,"",_l),w+=2,b--;continue}y[++x]=u&&"string"!=typeof m[b+1]?void 0:"",P=!0}if(!P){let t;if(t=u?void 0!==y[x]?y[x]+d+A:A:y[x]?y[x]+d+A:A,h.data=t,a.getComputedTextLength()<=o)y[x]=t,(T||r)&&(v[x++]=!0,r=T=0);else{if(!y[x]||T){var E=!!T,T=A.length-1;if(E||!T){if(!T){if(!y[x]){y=[];break}m.splice(b,2,A+m[b+1]),w--,v[x++]=!0,b--;continue}m[b]=A.substring(0,T);var S=m[b+1];m[b+1]=A.substring(T)+(void 0===S||S===_l?"":S)}else r?(m.splice(b,2,m[b]+m[b+1]),r=0):(-1<(S=A.search(p))&&S!==A.length-1&&0!==S&&(r=S+1,T=0),m.splice(b,1,A.substring(0,r||T),A.substring(r||T)),w++),x&&!v[x-1]&&x--;u&&""===y[x]||b--;continue}x++,b--}}var _,L=null;if(y.length>g?L=g-1:void 0!==s&&(_=void 0===_&&""!==h.data?"auto"===n.lineHeight?Ll({value:1.5,unit:"em"},l):Ll(Pl(n.lineHeight,["em","px",""]),l):_)*y.length>s&&(L=Math.floor(s/_)-1),null!==L){y.splice(L+1);var k=i.ellipsis;if(!k||L<0)break;"string"!=typeof k&&(k="\u2026");var C=y[L];if(!C&&!P)break;var M,N,O=C.length;do{if(N=C[O],M=C.substring(0,O),N?N.match(c)&&(M+=N):M+=d,M+=k,h.data=M,a.getComputedTextLength()<=o){y[L]=M;break}}while(0<=--O);break}}}return i.svgDocument?e.removeChild(l):document.body.removeChild(e),y.join(f)}function Cl(t,e){var n;window.navigator.msSaveBlob?window.navigator.msSaveBlob(t,e):(t=window.URL.createObjectURL(t),(n=document.createElement("a")).href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(t))}function Ml(t){t=t.replace(/\s/g,"");for(var e=(t=decodeURIComponent(t)).indexOf(","),n=t.slice(0,e),i=n.split(":")[1].split(";")[0],t=t.slice(e+1),r=0<=n.indexOf("base64")?atob(t):unescape(encodeURIComponent(t)),o=new Uint8Array(r.length),s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return new Blob([o],{type:i})}function Nl(t,e){var n=(t=L(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(e);for(var i=0;i<n.length;i++)n[i].call(t[i]);return t}let Ol=function(t){var e,n,i,r;return Object(t)!==t?(r=0,{top:r=isFinite(t)?+t:r,right:r,bottom:r,left:r}):(e=n=i=r=0,isFinite(t.vertical)&&(e=i=+t.vertical),isFinite(t.horizontal)&&(n=r=+t.horizontal),{top:e=isFinite(t.top)?+t.top:e,right:n=isFinite(t.right)?+t.right:n,bottom:i=isFinite(t.bottom)?+t.bottom:i,left:r=isFinite(t.left)?+t.left:r})},Rl={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){var e,n;return t<=0?0:1<=t?1:(n=(e=t*t)*t,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,n=0,i=1;;n+=i,i/=2){1;if((7-4*n)/11<=t)return-(e=(11-6*n-11*t)/4)*e+i*i}},reverse:function(e){return function(t){return 1-e(1-t)}},reflect:function(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}},clamp:function(e,n,i){return n=n||0,i=i||1,function(t){t=e(t);return t<n?n:i<t?i:t}},back:function(e){return e=e||1.70158,function(t){return t*t*((e+1)*t-e)}},elastic:function(e){return e=e||1.5,function(t){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e/3*t)}}},Il={number:function(e,t){var n=t-e;return function(t){return e+n*t}},object:function(r,o){var s=Object.keys(r);return function(t){for(var e,n={},i=s.length-1;-1!=i;i--)n[e=s[i]]=r[e]+(o[e]-r[e])*t;return n}},hexColor:function(t,e){var t=parseInt(t.slice(1),16),e=parseInt(e.slice(1),16),n=255&t,i=(255&e)-n,r=65280&t,o=(65280&e)-r,s=16711680&t,a=(16711680&e)-s;return function(t){return"#"+(1<<24|n+i*t&255|r+o*t&65280|s+a*t&16711680).toString(16).slice(1)}},unit:function(e,t){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(e),n=n.exec(t),t=n[1].indexOf("."),r=0<t?n[1].length-t-1:0,o=(e=+i[1],+n[1]-e),s=i[2];return function(t){return(e+o*t).toFixed(r)+s}}},Vl={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return Fl('<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 Fl('<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 Fl('<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 Fl(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){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<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-t),b:.7152-.7152*(1-t),c:.0722-.0722*(1-t),d:.2126-.2126*(1-t),e:.7152+.2848*(1-t),f:.0722-.0722*(1-t),g:.2126-.2126*(1-t),h:.0722+.9278*(1-t)})},sepia:function(t){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<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-t),b:.769-.769*(1-t),c:.189-.189*(1-t),d:.349-.349*(1-t),e:.686+.314*(1-t),f:.168-.168*(1-t),g:.272-.272*(1-t),h:.534-.534*(1-t),i:.131+.869*(1-t)})},saturate:function(t){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-t})},hueRotate:function(t){return Fl('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:t,amount2:1-t})},brightness:function(t){return Fl('<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){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<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:t,amount2:.5-t/2})}},Fl=(C={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var t=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),n=t[1]||" ",i=t[2]||">",r=t[3]||"",s=t[4]||"",a=t[5],l=+t[6],h=t[7],u=t[8],c=t[9],d=1,f="",p="",g=!1,u=u&&+u.substring(1);switch((a||"0"===n&&"="===i)&&(a=n="0",i="=",h)&&(l-=Math.floor((l-1)/4)),c){case"n":h=!0,c="g";break;case"%":d=100,p="%",c="f";break;case"p":d=100,p="%",c="r";break;case"b":case"o":case"x":case"X":"#"===s&&(f="0"+c.toLowerCase());break;case"c":case"d":g=!0,u=0;break;case"s":d=-1,c="r"}"$"===s&&(f=o.currency[0],p=o.currency[1]),"r"!=c||u||(c="g"),null!=u&&("g"==c?u=Math.max(1,Math.min(21,u)):"e"!=c&&"f"!=c||(u=Math.max(0,Math.min(20,u))));t=a&&h;if(g&&e%1)return"";var r=e<0||0===e&&1/e<0?(e=-e,"-"):r,m=p,v=(d<0?(e=(v=this.prefix(e,u)).scale(e),m=v.symbol+p):e*=d,(e=this.convert(c,e,u)).lastIndexOf(".")),y=v<0?e:e.substring(0,v),v=v<0?"":o.decimal+e.substring(v+1);function b(t){for(var e=t.length,n=[],i=0,r=o.grouping[0];0<e&&0<r;)n.push(t.substring(e-=r,e+r)),r=o.grouping[i=(i+1)%o.grouping.length];return n.reverse().join(o.thousands)}!a&&h&&o.grouping&&(y=b(y));a=f.length+y.length+v.length+(t?0:r.length),l=a<l?new Array(a=l-a+1).join(n):"";return r+=f,e=(y=t?b(l+y):y)+v,("<"===i?r+e+l:">"===i?l+r+e:"^"===i?l.substring(0,a>>=1)+r+e+l.substring(a):r+(t?e:l+e))+m},string:function(t,e){for(var n,i="{",r=!1,o=[];-1!==(n=t.indexOf(i));){if(l=t.slice(0,n),r){for(var s,a=(s=l.split(":")).shift().split("."),l=e,h=0;h<a.length;h++)l=l[a[h]];s.length&&(l=this.number(s,l))}o.push(l),t=t.slice(n+1),i=(r=!r)?"}":"{"}return o.push(t),o.join("")},convert:function(t,e,n){switch(t){case"b":return e.toString(2);case"c":return String.fromCharCode(e);case"o":return e.toString(8);case"x":return e.toString(16);case"X":return e.toString(16).toUpperCase();case"g":return e.toPrecision(n);case"e":return e.toExponential(n);case"f":return e.toFixed(n);case"r":return(e=this.round(e,this.precision(e,n))).toFixed(Math.max(0,Math.min(20,this.precision(e*(1+1e-15),n))));default:return e+""}},round:function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},precision:function(t,e){return e-(t?Math.ceil(Math.log(t)/Math.LN10):1)},prefix:function(t,e){var n=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(function(t,e){var n=Math.pow(10,3*Math.abs(8-e));return{scale:8<e?function(t){return t/n}:function(t){return t*n},symbol:t}}),i=0;return t&&(t<0&&(t*=-1),e&&(t=this.round(t,this.precision(t,e))),i=1+Math.floor(1e-12+Math.log(t)/Math.LN10),i=Math.max(-24,Math.min(24,3*Math.floor((i<=0?i+1:i-1)/3)))),n[8+i/3]}},function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(i){return i=i||{},t.replace(e,function(t){for(var e=Array.from(arguments).slice(1,4).find(function(t){return!!t}).split("."),n=i[e.shift()];void 0!==n&&e.length;)n=n[e.shift()];return void 0!==n?n:""})}});function Bl(t,e,n){var{maxDepth:n=Number.POSITIVE_INFINITY}=n||{};return function o(s,a,l,h){if(l===h)return{};let u={};return Object.keys(s).forEach(t=>{var e,n,i=s[t],r=a[t];!Array.isArray(i)&&!Array.isArray(r)&&w(i)&&w(r)?(n=o(i,r,e=l+1,h),0<Object.keys(n).length?u[t]=n:0!==l&&e!==h||(u[t]={})):na(i,r)||(u[t]=i)}),u}(t,e,0,n)}function Dl(){}function zl(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=zl(t,e,o[s],n[o[s]],r)}else if(n&&Wl.test(n))for(o=n.split(Wl);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e}function jl(t,e){var n=this,i=t&&ua(t,"constructor")?t.constructor:function(){return n.apply(this,arguments)};return T(i,n,e),i.prototype=Object.assign(Object.create(n.prototype),t),(i.prototype.constructor=i).__super__=n.prototype,i}function Gl(t,e){var t=t||{},n=(e=e||{},this.preinitialize.apply(this,arguments),this.cid=ma(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),S(this,"defaults")),t=$s(T({},n,t),n);this.set(t,e),this.changed={},this.initialize.apply(this,arguments)}var Ul,Hl,ql,$l={},Wl=/\s+/,Yl=($l.on=function(t,e,n){return this._events=zl(Yl,this._events||{},t,e,{context:n,ctx:this,listening:Ul}),Ul&&(((this._listeners||(this._listeners={}))[Ul.id]=Ul).interop=!1),this},$l.listenTo=function(t,e,n){if(t){var i=t._listenId||(t._listenId=ma("l")),r=this._listeningTo||(this._listeningTo={}),o=Ul=r[i],r=(o||(this._listenId||(this._listenId=ma("l")),o=Ul=r[i]=new eh(this,t)),Xl(t,e,n,this));if(Ul=void 0,r)throw r;o.interop&&o.on(e,n)}return this},function(t,e,n,i){var r,o;return n&&(e=t[e]||(t[e]=[]),r=i.context,o=i.ctx,(i=i.listening)&&i.count++,e.push({callback:n,context:r,ctx:r||o,listening:i})),t}),Xl=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}},Zl=($l.off=function(t,e,n){return this._events&&(this._events=zl(Zl,this._events,t,e,{context:n,listeners:this._listeners})),this},$l.stopListening=function(t,e,n){var i=this._listeningTo;if(i){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)}ea(i)&&(this._listeningTo=void 0)}return this},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 h=[],u=0;u<l.length;u++){var c=l[u];n&&n!==c.callback&&n!==c.callback._callback||o&&o!==c.context?h.push(c):(c=c.listening)&&c.off(e,n)}h.length?t[e]=h:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}}),Jl=($l.once=function(t,e,n){var i=zl(Jl,{},t,e,this.off.bind(this));return this.on(i,e="string"==typeof t&&null==n?void 0:e,n)},$l.listenToOnce=function(t,e,n){e=zl(Jl,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,e)},function(t,e,n,i){var r;return n&&((r=t[e]=Kl(function(){i(e,r),n.apply(this,arguments)}))._callback=n),t}),Kl=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return 0<--n&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}},Ql=($l.trigger=function(t){if(this._events){for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];zl(Ql,this._events,t,void 0,n)}return this},function(t,e,n,i){var r,o;return t&&(r=t[e],o=t.all,r&&(o=o&&o.slice()),r&&th(r,i),o)&&th(o,[e].concat(i)),t}),th=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}},eh=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0},nh=(eh.prototype.on=$l.on,eh.prototype.off=function(t,e){t=this.interop?(this._events=zl(Zl,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count);t&&this.cleanup()},eh.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},$l.bind=$l.on,$l.unbind=$l.off,function(i,t,r,o){switch(t){case 1:return function(){return i[r](this[o])};case 2:return function(t){return i[r](this[o],t)};case 3:return function(t,e){return i[r](this[o],ih(t,this),e)};case 4:return function(t,e,n){return i[r](this[o],ih(t,this),e,n)};default:return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this[o]),i[r].apply(i,t)}}}),ih=function(e,t){return b(e)?e:w(e)&&!t._isModel(e)?rh(e):E(e)?function(t){return t.get(e)}:e},rh=function(t){t=t;var e=Ps(is(t,!0));return function(t){return e(t.attributes)}};function oh(t){t=Ks(t);let r=et(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return et(t).forEach(function(t){var e=r[t.id],n=(e.isLink()&&(n=e.source(),i=e.target(),n.id&&r[n.id]&&e.prop("source/id",r[n.id].id),i.id)&&r[i.id]&&e.prop("target/id",r[i.id].id),t.get("parent")),i=(n&&r[n]&&e.set("parent",r[n].id),et(t.get("embeds")).reduce(function(t,e){return r[e]&&t.push(r[e].id),t},[]));ea(i)||e.set("embeds",i)}),r}T(Gl.prototype,$l,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return Qs(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){var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,!this._validate(i,n=n||{}))return!1;var r,o,s=n.unset,t=n.silent,a=[],l=this._changing,h=(this._changing=!0,l||(this._previousAttributes=Qs(this.attributes),this.changed={}),this.attributes),u=this.changed,c=this._previousAttributes;for(r in i)e=i[r],na(h[r],e)||a.push(r),na(c[r],e)?delete u[r]:u[r]=e,s?delete h[r]:h[r]=e;if(this.idAttribute in i&&(o=this.id,this.id=this.get(this.idAttribute),this.trigger("changeId",this,o,n)),!t){a.length&&(this._pending=n);for(var d=0;d<a.length;d++)this.trigger("change:"+a[d],this,h[a[d]],n)}if(!l){if(!t)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);this._pending=!1,this._changing=!1}}return this},unset:function(t,e){return this.set(t,void 0,T({},e,{unset:!0}))},clear:function(t){var e,n={};for(e in this.attributes)n[e]=void 0;return this.set(n,T({},t,{unset:!0}))},hasChanged:function(t){return null==t?!ea(this.changed):ua(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&Qs(this.changed);var e,n,i=this._changing?this._previousAttributes:this.attributes,r={};for(n in t){var o=t[n];na(i[n],o)||(r[n]=o,e=!0)}return!!e&&r},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return Qs(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},T({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=T({},this.attributes,t);t=this.validationError=this.validate(t,e)||null;return!t||(this.trigger("invalid",this,t,T(e,{validationError:t})),!1)}}),Gl.extend=jl;let sh=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce((t,e)=>(t[e]=!0,t),{});function ah(r,o,s){return function(t,e){var n,i=Sl(t),i=(t=parseFloat(t),i&&(t/=100),isFinite(t)&&(n=e[s](),n=i||0<t&&t<1?n[r]+e[o]*t:n[r]+t),A());return i[r]=n||0,i}}function lh(r,o){return function(t,e){var n=Sl(t),i=(t=parseFloat(t),n&&(t/=100),{});return isFinite(t)&&(n=n||0<=t&&t<=1?t*e[o]:Math.max(t+e[o],0),i[r]=n),i}}a={qualify:function(t){return y(t)},set:function(e,t,i){Object.keys(e).forEach(function(t){if(sh[t]&&t in i){let n=e[t];"SELECT"===i.tagName&&Array.isArray(n)?Array.from(i.options).forEach(function(t,e){t.selected=n.includes(t.value)}):i[t]=n}})}},(i={"ref-x":{position:ah("x","width","origin")},"ref-y":{position:ah("y","height","origin")},"ref-dx":{position:ah("x","width","corner")},"ref-dy":{position:ah("y","height","corner")},"ref-width":{set:lh("width","width")},"ref-height":{set:lh("height","height")},"ref-rx":{set:lh("rx","width")},"ref-ry":{set:lh("ry","height")},"ref-cx":{set:lh("cx","width")},"ref-cy":{set:lh("cy","height")},"ref-r-inscribed":{set:(Hl=lh("r","width"),ql=lh("r","height"),function(t,e){return(e.height>e.width?Hl:ql)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n,i=Sl(t),e=(t=parseFloat(t),i&&(t/=100),Math.sqrt(e.height*e.height+e.width*e.width));return{r:n=isFinite(t)?i||0<=t&&t<=1?t*e:Math.max(t+e,0):n}}}}).refX=i["ref-x"],i.refY=i["ref-y"],i["ref-x2"]=i["ref-x"],i["ref-y2"]=i["ref-y"],i["ref-width2"]=i["ref-width"],i["ref-height2"]=i["ref-height"],i["ref-r"]=i["ref-r-inscribed"];let hh={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},uh=(Ke=Object.keys(hh).map(t=>hh[t]).join(""),h="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",/\s/g),ch=new RegExp(`^(${h}\\*)?([${Ke}])(/${h})?([-+]{1,2}${h})?$`,"g");function dh(t){throw new Error("Invalid calc() expression: "+t)}function fh(t,e){var n=ch.exec(t.replace(uh,"")),[,t,n,i,r]=(n||dh(t),ch.lastIndex=0,n),{x:o,y:s,width:a,height:l}=e;let h=0;switch(n){case hh.width:h=a;break;case hh.height:h=l;break;case hh.x:h=o;break;case hh.y:h=s;break;case hh.minimum:h=Math.min(l,a);break;case hh.maximum:h=Math.max(l,a);break;case hh.diagonal:h=Math.sqrt(l*l+a*a)}return t&&(h*=parseFloat(t)),i&&(h/=parseFloat(i.slice(1))),r&&(h+=(t=>{if(!t)return 0;var[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)})(r)),h}function ph(t){return"string"==typeof t&&t.includes("calc")}let gh="calc(",mh=gh.length;function vh(t,i){let r=t,o=0;for(;;){var s=r.indexOf(gh,o);if(-1===s)return r;let t=s+mh,e=1;t:for(;;){switch(r[t]){case"(":e++;break;case")":if(0===--e)break t;break;case void 0:dh(r)}t++}let n=r.slice(s+mh,t);ph(n)&&(n=vh(n,i));var a=String(fh(n,i));r=r.slice(0,s)+a+r.slice(t+1),o=s+a.length}}function yh(t,e,n){return void 0!==n.text}let bh=["font-weight","font-family","font-size","letter-spacing","text-transform"],xh={"line-height":{qualify:yh},"text-vertical-anchor":{qualify:yh},"text-path":{qualify:yh},annotations:{qualify:yh},eol:{qualify:yh},"display-empty":{qualify:yh},text:{qualify:function(t,e,n){n=n["text-wrap"];return!n||!y(n)},unset:function(t){t.textContent=""},set:function(t,e,n,i){var r="joint-text",o=L.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],h=i["font-size"],u=i.annotations,c=i.eol,d=i.x;let f=i["text-path"];i=JSON.stringify([t,s,u,a,c,l,f,d,h]);void 0!==o&&o===i||(h&&n.setAttribute("font-size",h),w(f)&&"string"==typeof(o=f.selector)&&(h=this.findNode(o))instanceof SVGPathElement&&(f=T({"xlink:href":"#"+h.id},f)),R(n).text(""+t,{lineHeight:s,annotations:u,textPath:f,x:d,textVerticalAnchor:a,eol:c,displayEmpty:l}),L.data.set(n,r,i))}},"text-wrap":{qualify:y,set:function(e,t,n,i){var r={},o=e.width||0,o=(Sl(o)?r.width=t.width*parseFloat(o)/100:ph(o)?r.width=Number(vh(o,t)):null===e.width?r.width=1/0:r.width=o<=0?t.width+o:o,e.height||0),o=(Sl(o)?r.height=t.height*parseFloat(o)/100:ph(o)?r.height=Number(vh(o,t)):null!==e.height&&(r.height=o<=0?t.height+o:o),e.text);if(void 0!==(o=void 0===o?i.text:o)){var s=e.breakText||kl,a=getComputedStyle(n),l={};for(let t=0;t<bh.length;t++){var h=bh[t];h in i&&n.setAttribute(h,i[h]),l[h]=a[h]}l.lineHeight=i["line-height"];let t=this.paper.svg;s=s(""+o,r,l,{svgDocument:t=t.checkVisibility()?t:null,ellipsis:e.ellipsis,hyphen:e.hyphen,separator:e.separator,maxLineCount:e.maxLineCount,preserveSpaces:e.preserveSpaces})}else s="";xh.text.set.call(this,s,t,n,i)},FONT_ATTRIBUTES:bh},title:{qualify:function(t,e){return e instanceof SVGElement},unset:function(t){L.data.remove(t,"joint-title");t=t.firstElementChild;t&&t.remove()},set:function(t,e,n){var i="joint-title",r=L.data.get(n,i);void 0!==r&&r===t||(L.data.set(n,i,t),"title"===n.tagName?n.textContent=t:(r=n.firstElementChild)&&"title"===r.tagName?r.textContent=t:((i=document.createElementNS(n.namespaceURI,"title")).textContent=t,n.insertBefore(i,r)))}}};function wh(i,r){var o=new A(1,0);return function(t){var e,n,t=this[i](t);return t?(n=r.rotate?t.vector().vectorAngle(o):0,e=t.start):(e=this.path.start,n=0),0===n?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+n+")"}}}function Ah(){return this.model.isLink()}function Ph(s,t){var a="joint-shape",l=t&&t.resetOffset;return function(t,e,n){var i=L.data.get(n,a),t=(i&&i.value===t||(i={value:t,shape:t=s(t),shapeBBox:t.bbox()},L.data.set(n,a,i)),i.shape.clone()),n=i.shapeBBox.clone(),i=n.origin(),r=e.origin(),r=(n.x=r.x,n.y=r.y,e.maxRectScaleToFit(n,r)),o=0===n.width||0===e.width?1:r.sx,n=0===n.height||0===e.height?1:r.sy;return t.scale(o,n,i),l&&t.translate(-i.x,-i.y),t}}function Eh(t){var i=Ph(function(t){return new V(R.normalizePathData(t))},t);return function(t,e,n){return{d:i(t,e,n).serialize()}}}function Th(t){var i=Ph(x,t);return function(t,e,n){return{points:i(t,e,n).serialize()}}}function Sh(t){var e={},n=t.stroke,n=("string"==typeof n&&(e.stroke=n,e.fill=n),t["stroke-opacity"]);return void 0!==(n=void 0===n?t.opacity:n)&&(e["stroke-opacity"]=n,e["fill-opacity"]=n),e}function _h(t){var e=this.paper;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}function Lh(i,r,o){return function(t,e){var t="middle"===t?e[r]/2:t===o?e[r]:isFinite(t)?-1<t&&t<1?-e[r]*t:-t:Sl(t)?e[r]*parseFloat(t)/100:0,n=new A;return n[i]=-(e[i]+t),n}}function kh(i){return function(t,e,n){n=R(n);n.attr(i)!==t&&n.attr(i,t)}}function Ch(t,e){if(Array.isArray(t))return ta(e)}(s={connection:{qualify:Ah,unset:"d",set:function({stubs:e=0}){let n;if(isFinite(e)&&0!==e){let t;t=e<0?(this.getConnectionLength()+e)/2:e;var e=this.getConnection(),i=this.getConnectionSubdivisions(),r=e.divideAtLength(t,{segmentSubdivisions:i}),e=e.divideAtLength(-t,{segmentSubdivisions:i});r&&e&&(n=r[0].serialize()+" "+e[1].serialize())}return{d:n||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:Ah,unset:"transform",set:wh("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:Ah,unset:"transform",set:wh("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:Ah,unset:"transform",set:wh("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:Ah,unset:"transform",set:wh("getTangentAtRatio",{rotate:!1})}})["at-connection-length"]=s["at-connection-length-keep-gradient"],s["at-connection-ratio"]=s["at-connection-ratio-keep-gradient"],(o={"ref-d-reset-offset":{unset:"d",set:Eh({resetOffset:!0})},"ref-d-keep-offset":{unset:"d",set:Eh({resetOffset:!1})},"ref-points-reset-offset":{unset:"points",set:Th({resetOffset:!0})},"ref-points-keep-offset":{unset:"points",set:Th({resetOffset:!1})}})["ref-d"]=o["ref-d-reset-offset"],o["ref-points"]=o["ref-points-reset-offset"],e={"source-marker":{qualify:y,unset:"marker-start",set:function(t,e,n,i){return t=T(Sh(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:y,unset:"marker-end",set:function(t,e,n,i){return t=T(Sh(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:y,unset:"marker-mid",set:function(t,e,n,i){return t=T(Sh(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:y,set:_h},stroke:{qualify:y,set:_h},filter:{qualify:y,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}},Ue={"x-alignment":{offset:Lh("x","width","right")},"y-alignment":{offset:Lh("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}},l={ref:{},href:{set:kh("href")},"xlink:href":{set:kh("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:y,set:function(t,e,n){L(n).css(t)}},html:{unset:function(t){L(t).empty()},set:function(t,e,n){L(n).html(t+"")}},props:a},T(l,i),T(l,xh),T(l,s),T(l,o),T(l,e),T(l,Ue);let Mh=l;function Nh(t){for(var e in t){var n=t[e];w(n)&&!Array.isArray(n)&&ea(n)&&delete t[e]}}let Oh=Gl.extend({constructor:function(t,e){var n,i,t=t||{};"function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=ma("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(t=this.parse(t,e)||{}),(n=S(this,"defaults"))&&(i=(!e||!0!==e.mergeArrays)&&Ch,t=_({},n,t,i)),this.set(t,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(t){var{ignoreDefaults:t,ignoreEmptyAttributes:e=!1}=t||{};let n=S(this.constructor.prototype,"defaults");if(!1===t){let t=ta(this.attributes);return e&&Nh(t),t}let i={};var r=ta(this.attributes);!0===t?i=n:(Array.isArray(t)?t:["attrs"]).forEach(t=>{i[t]=n[t]||{}});let o=Bl(r,ca(i,"id","type"),{maxDepth:4});return e&&Nh(o),o},initialize:function(t){var 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:bl,processPorts:function(){var t=this.ports,n={},i=(fa(this.get("attrs"),function(t,e){t&&t.port&&(void 0!==t.port.id?n[t.port.id]=t.port:n[t.port]={id:t.port})}),{});fa(t,function(t,e){n[e]||(i[e]=!0)}),this.graph&&!ea(i)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),this.graph.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()})),this.ports=n},remove:function(n={}){var{graph:t,collection:e}=this;if(t){t.startBatch("remove");var i=this.getParentCell(),r=(i&&i.unembed(this,n),this.getEmbeddedCells());for(let t=0,e=r.length;t<e;t++){var o=r[t];o&&o.remove(n)}this.trigger("remove",this,t.attributes.cells,n),t.stopBatch("remove")}else e&&e.remove(this,n);return this},toFront:function(i){var r=this.graph;if(r){let t;(i=$s(i||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==i.breadthFirst,sortSiblings:i.foregroundEmbeds})).unshift(this):t=[this];var o=i.foregroundEmbeds?t:oa(t,t=>t.z());let n=r.maxZIndex()-t.length+1;r=r.get("cells");let e=r.toArray().indexOf(o[0])!==r.length-t.length;(e=e||o.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-front"),n+=t.length,o.forEach(function(t,e){t.set("z",n+e,i)}),this.stopBatch("to-front"))}return this},toBack:function(r){var o=this.graph;if(o){let t;(r=$s(r||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==r.breadthFirst,sortSiblings:r.foregroundEmbeds})).unshift(this):t=[this];var s=r.foregroundEmbeds?t:oa(t,t=>t.z());let n=o.minZIndex(),e=o.get("cells"),i=0!==e.toArray().indexOf(s[0]);(i=i||s.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-back"),n-=t.length,s.forEach(function(t,e){t.set("z",n+e,r)}),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={}){let n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(e.reparent)Ks(n.map(t=>t.getParentCell())).forEach(t=>{t&&t._unembedCells(n,e)});else 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){t=Array.isArray(t)?t:[t];return this._unembedCells(t,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every(t=>this!==t&&!this.isEmbeddedIn(t))},_embedCells:function(t,e){this.startBatch("embed");let n=T([],this.get("embeds"));t.forEach(t=>{n[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)}),this.set("embeds",Ks(n),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(t=>t.unset("parent",e)),this.set("embeds",aa(this.get("embeds"),...t.map(t=>t.id)),e),this.stopBatch("unembed")},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(this.graph)for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(!this.graph)return[];if((t=t||{}).deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);var e=this.get("embeds");if(ea(e))return[];let n=e.map(this.graph.getCell,this.graph);return n=t.sortSiblings?oa(n,t=>t.z()):n},_getEmbeddedCellsBfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.shift(),i=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));n.push(...i)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.pop(),r=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));for(let t=r.length-1;0<=t;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=E(t)?t:t.id,i=this.parent();if(e=T({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){return(t=t||{}).deep?et(oh([this].concat(this.getEmbeddedCells({deep:!0})))):((t=Gl.prototype.clone.apply(this,arguments)).set(this.getIdAttribute(),this.generateId()),t.unset("embeds"),t.unset("parent"),t)},prop:function(e,n,i){var r=E(e);if(r||Array.isArray(e)){if(1<arguments.length){var o=r?(p=e).split("/"):(p=e.join("/"),e.slice()),s=o[0],a=o.length;let t=i||{};t.propertyPath=p,t.propertyValue=n,t.propertyPathArray=o,"rewrite"in t||(t.rewrite=!1);for(var l=i={},h=s,u=1;u<a;u++)var c=o[u],d=Number.isFinite(r?Number(c):c),l=l[h]=d?[]:{},h=c;var i=ml(i,o,n,"/"),f=_({},this.attributes),p=(t.rewrite&&vl(f,p,"/"),_(f,i));return this.set(s,p[s],t)}return pl(this.attributes,e,"/")}let t=n||{};t.propertyPath=null,t.propertyValue=e,t.propertyPathArray=[],"rewrite"in t||(t.rewrite=!1);var g,m={};for(g in e){var v=_({},{changedValue:this.attributes[g]},{changedValue:e[g]}).changedValue;m[g]=v}return this.set(m,t)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];return"attrs"===i&&(e.dirty=!0),1===n.length?this.unset(t,e):(t=n.slice(1),null==(n=this.get(i))?this:(n=ta(n),vl(n,t,"/"),this.set(i,n,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):E(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(n,e,i,r){r=r||"/";var o,t={duration:100,delay:10,timingFunction:Rl.linear,valueFunction:Il.number},s=(i=T(t,i),0),a=function(t){var e;(t=(t-=s=s||t)/i.duration)<1?this._transitionIds[n]=e=El(a):(t=1,delete this._transitionIds[n]),t=o(i.timingFunction(t)),i.transitionId=e,this.prop(n,t,i),e||this.trigger("transition:end",this,n)}.bind(this);let l=this._scheduledTransitionIds,h;return h=setTimeout(t=>{l[n]&&(l[n]=aa(l[n],h),0===l[n].length)&&delete l[n],this.stopPendingTransitions(n,r),o=i.valueFunction(pl(this.attributes,n,r),e),this._transitionIds[n]=El(t),this.trigger("transition:start",this,n)},i.delay,a),l[n]||(l[n]=[]),l[n].push(h),h},getTransitions:function(){return ha(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,n="/"){let{_scheduledTransitionIds:e={}}=this,i=Object.keys(e);if(t){let e=t.split(n);i=i.filter(t=>na(e,t.split(n).slice(0,e.length)))}return i.forEach(t=>{e[t].forEach(t=>clearTimeout(t)),delete e[t]}),this},stopPendingTransitions(t,n="/"){let{_transitionIds:i={}}=this,r=Object.keys(i);if(t){let e=t.split(n);r=r.filter(t=>na(e,t.split(n).slice(0,e.length)))}r.forEach(t=>{var e=i[t];Tl(e),delete i[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,T({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,T({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(t)for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new A(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new A},getBBox:function(){return new tt(0,0,0,0)},getCenter:function(){return this.getBBox().center()},getPointRotatedAroundCenter(t,e,n){e=new A(e,n);return t&&e.rotate(this.getCenter(),t),e},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=Mh;return e&&e[t]||n[t]},define:function(t,e,n,i){n=T({defaults:Ys({type:t},e,this.prototype.defaults)},n);e=this.extend(n,i);return void 0!==joint&&ua(joint,"shapes")&&ml(joint.shapes,t,e,"."),e}});function Rh(e,t,n){if(E(n)){if(!Ih[n])throw new Error('Unknown wrapper: "'+n+'"');n=Ih[n]}if(!b(n))throw new Error("Wrapper must be a function.");et(t).forEach(function(t){e[t]=n(e[t])})}let Ih={cells:function(i){return function(){var t=Array.from(arguments),e=t.length,n=0<e&&t[0]||[],e=1<e&&t[e-1]||{};return Array.isArray(n)||(e instanceof Oh?n=t:n instanceof Oh&&(1<t.length&&t.pop(),n=t)),e instanceof Oh&&(e={}),i.call(this,n,e)}}},d={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 Vh(t,e){var n=new tt(t);switch(e){case void 0:throw new Error("Position required");case d.LEFT:case"leftMiddle":return n.leftMiddle();case d.RIGHT:case"rightMiddle":return n.rightMiddle();case d.TOP:case"topMiddle":return n.topMiddle();case d.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case d.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case d.TOP_RIGHT:case"topRight":return n.topRight();case d.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case d.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case d.CENTER:return n.center();default:throw new Error("Unknown position: "+e)}}function Fh(t,e,n){t=t.toJSON();return t.angle=e||0,$s({},n,t)}function Bh(t,e,n,i){return t.map(function(t,e,n){e=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&e.offset(t.dx||0,t.dy||0),Fh(e.round(),0,zh(i,t))},fi(e,n))}function Dh(t,i,r,o){var s=i.center(),a=i.width/i.height,l=i.topMiddle(),h=vi.fromRect(i);return t.map(function(t,e,n){e=r+o(e,n.length),n=l.clone().rotate(s,-e).scale(a,1,s),e=t.compensateRotation?-h.tangentTheta(n):0;return(t.dx||t.dy)&&n.offset(t.dx||0,t.dy||0),t.dr&&n.move(s,t.dr),Fh(n.round(),e,zh(i,t))})}function zh(t,e){let{x:n,y:i,angle:r}=e;return Sl(n)?n=parseFloat(n)/100*t.width:ph(n)&&(n=Number(vh(n,t))),Sl(i)?i=parseFloat(i)/100*t.height:ph(i)&&(i=Number(vh(i,t))),{x:n,y:i,angle:r}}function jh(t,e){var{x:t,y:e}=zh(t,e);return new A(t||0,e||0)}Zr={__proto__:null,addClassNamePrefix:al,assign:T,bindAll:(e,...t)=>(t.flat(1).forEach(t=>{t=ns(t),wo(e,t,e[t].bind(e))}),e),breakText:kl,camelCase:pa,cancelFrame:Tl,cap:Al,clone:Qs,cloneCells:oh,cloneDeep:ta,dataUriToBlob:Ml,debounce:ia,deepMixin:r,deepSupplement:Ws,defaults:$s,defaultsDeep:Ys,difference:la,downloadBlob:Cl,downloadDataUri:function(t,e){t=Ml(t);Cl(t,e)},evalCalcExpression:vh,evalCalcFormula:fh,filter:Vl,flattenDeep:sa,flattenObject:yl,forIn:fa,format:C,getByPath:pl,getElementBBox:function(t){t=L(t);if(0===t.length)throw new Error("Element not found");var t=t[0],e=t.ownerDocument,n=t.getBoundingClientRect(),i=0,r=0;return t.ownerSVGElement&&(t=(t=R(t)).getBBox({target:t.svg()}),i=n.width-t.width,r=n.height-t.height),{x:n.left+window.pageXOffset-e.documentElement.offsetLeft+i/2,y:n.top+window.pageYOffset-e.documentElement.offsetTop+r/2,width:n.width-i,height:n.height-r}},getRectPoint:Vh,groupBy:ra,guid:xl,has:ua,hashCode:fl,imageToDataUri:function(i,r){if(!i||"data:"===i.substr(0,"data:".length))return setTimeout(function(){r(null,i)},0);function o(t,e){var n;200===t.status?(t=new Uint8Array(t.response),e(null,"data:image/"+({svg:"svg+xml"}[n=i.split(".").pop()||"png"]||n)+";base64,"+btoa((t=>{for(var e=[],n=0;n<t.length;n+=32768)e.push(String.fromCharCode.apply(null,t.subarray(n,n+32768)));return e.join("")})(t)))):e(new Error("Failed to load image "+i))}var s=new XMLHttpRequest;s.open("GET",i,!0),s.addEventListener("error",function(){r(new Error("Failed to load image "+i))}),s.responseType=window.FileReader?"blob":"arraybuffer",s.addEventListener("load",function(){var t,e,n;window.FileReader?(e=r,200===(t=s).status?((n=new FileReader).onload=function(t){t=t.target.result;e(null,t)},n.onerror=function(){e(new Error("Failed to load image "+i))},n.readAsDataURL(t.response)):e(new Error("Failed to load image "+i))):o(s,r)}),s.send()},interpolate:Il,intersection:(...t)=>{var e=t.map(t=>mo(t)&&Po(t)?t:[]);return e.length&&e[0]===t[0]?(t=>{var e=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),n=(t,e)=>t.has(e),i=t[0].length,r=t.length,o=new Array(r),s=[];let a,l=1/0,h=r;for(;h--;)a=t[h],l=Math.min(a.length,l),o[h]=120<=i&&120<=a.length?new Us(h&&a):void 0;a=t[0];let u=-1;var c=o[0];t:for(;++u<i&&s.length<l;){var d=f=a[u],f=0!==f?f:0;if(!(c?n(c,d):e(s,d))){for(h=r;--h;){var p=o[h];if(!(p?n(p,d):e(t[h],d)))continue t}c&&c.push(d),s.push(f)}}return s})(e):[]},invoke:Xs,invokeProperty:Zs,isBoolean:Hs,isCalcExpression:ph,isEmpty:ea,isEqual:na,isFunction:b,isNumber:qs,isObject:w,isPercentage:Sl,isPlainObject:y,isString:E,merge:_,mixin:n,nextFrame:El,noop:Dl,normalizeEvent:k,normalizeSides:Ol,normalizeWheel:wl,objectDifference:Bl,omit:ca,parseCssNumeric:Pl,parseDOMJSON:dl,pick:da,removeClassNamePrefix:function(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,hl.classNamePrefix.length)===hl.classNamePrefix?t.substr(hl.classNamePrefix.length):t}).join(" ")},result:S,sanitizeHTML:function(t){var[t]=L.parseHTML("<div>"+t+"</div>");return Array.from(t.getElementsByTagName("*")).forEach(function(n){n.getAttributeNames().forEach(function(t){var e=n.getAttribute(t);(t.startsWith("on")||e.startsWith("javascript:")||e.startsWith("data:")||e.startsWith("vbscript:"))&&n.removeAttribute(t)})}),t.innerHTML},setAttributesBySelector:function(t,e){var n=L(t);fa(e,function(t,e){e=n.find(e).addBack().filter(e);ua(t,"class")&&(e.addClass(t.class),t=ca(t,"class")),e.attr(t)})},setByPath:ml,sortBy:oa,sortElements:Nl,sortedIndex:Js,supplement:u,svg:function(t,...n){let i=[];t.forEach((t,e)=>{i.push(t),e in n&&i.push(n[e])});var t=i.join(""),r=new DOMParser,t=`<svg>${t.trim()}</svg>`,e=r.parseFromString(t.replace(/@/g,""),"application/xml");if(e.getElementsByTagName("parsererror")[0])throw new Error("Invalid SVG markup");r=(e=r.parseFromString(t,"text/html")).querySelector("svg");{t=r;let e=[];return Array.from(t.children).forEach(t=>{e.push(function t(e){let n={};let{tagName:i,attributes:r,namespaceURI:o,style:s,childNodes:a}=e;n.namespaceURI=o;n.tagName=o===R.namespace.xhtml?i.toLowerCase():i;let l={};for(var h=s.length;h--;){var u=s[h];l[u]=s.getPropertyValue(u)}n.style=l;let c=r.getNamedItem("@selector");c&&(n.selector=c.value,r.removeNamedItem("@selector"));let d=r.getNamedItem("@group-selector");if(d){let t=d.value.split(",");n.groupSelector=t.map(t=>t.trim()),r.removeNamedItem("@group-selector")}let f=r.getNamedItem("class");f&&(n.className=f.value);let p=[];a.forEach(e=>{switch(e.nodeType){case Node.TEXT_NODE:{let t=e.data.replace(/\s\s+/g," ");t.trim()&&p.push(t);break}case Node.ELEMENT_NODE:p.push(t(e))}});p.length&&(n.children=p);let g={};Array.from(r).forEach(t=>{let{name:e,value:n}=t;g[e]=n});0<Object.keys(g).length&&(n.attributes=g);return n}(t))}),e}},template:Fl,timing:Rl,toArray:et,toKebabCase:function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},toggleFullScreen:function(t){var e=window.top.document;function n(t,e){for(var n=["webkit","moz","ms","o",""],i=0;i<n.length;i++){var r=n[i],r=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[r])return b(t[r])?t[r]():t[r]}}t=t||e.body,n(e,"FullscreenElement")||n(e,"FullScreenElement")?n(e,"ExitFullscreen")||n(e,"CancelFullScreen"):n(t,"RequestFullscreen")||n(t,"RequestFullScreen")},union:ha,uniq:Ks,uniqueId:ma,unsetByPath:vl,uuid:bl,without:aa,wrapWith:Rh,wrappers:Ih};var Gh={__proto__:null,absolute:function(t,n){return t.map(t=>{var e=jh(n,t).round().toJSON();return e.angle=t.angle||0,e})},bottom:function(t,e,n){return Bh(t,e.bottomLeft(),e.corner(),e)},ellipse:function(t,e,n){var i=n.startAngle||0,r=n.step||20;return Dh(t,e,i,function(t,e){return(t+.5-e/2)*r})},ellipseSpread:function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return Dh(t,e,i,function(t){return t*r})},fn:function(t,e,n){return n.fn(t,e,n)},left:function(t,e,n){return Bh(t,e.origin(),e.bottomLeft(),e)},line:function(t,e,n){return Bh(t,jh(e,n.start||e.origin()),jh(e,n.end||e.corner()),e)},right:function(t,e,n){return Bh(t,e.topRight(),e.corner(),e)},top:function(t,e,n){return Bh(t,e.origin(),e.topRight(),e)}};function Uh(t,e){return Ys({},t,e,{x:0,y:0,angle:0,attrs:{}})}function Hh(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 qh(t,e,n,i){i=$s({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=Hh(e),u=(t<u||c<t?(s=".3em",r=l,o=0,a="start"):t<e?(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")):t<d?(s=".3em",r=-l,o=0,a="end"):(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")),Math.round);return Uh(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function $h(t,e,n,i){i=$s({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=Hh(e),u=(t<u||c<t?(s=".3em",r=-l,o=0,a="end"):t<e?(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")):t<d?(s=".3em",r=l,o=0,a="start"):(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")),Math.round);return Uh(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Wh(t,e,n){n=$s({},n,{offset:20});var i,r=ui(0,0),o=-t.theta(r),s=o,r=t.clone().move(r,n.offset).difference(t).round(),t=".3em",o=((90+o)%180==0?(i=e?"end":"middle",e||-270!=o||(t="0em")):-270<o&&o<-90?(i="start",s=o-180):i="end",Math.round);return Uh(n,{x:o(r.x),y:o(r.y),angle:e?s:0,attrs:{labelText:{y:t,textAnchor:i}}})}function Yh(t){t=ta(t)||{},this.ports=[],this.portsMap={},this.groups={},this.portLayoutNamespace=Gh,this.portLabelLayoutNamespace=Xh,this.metrics={},this.metricsKey=null,this._init(t)}var Xh={__proto__:null,bottom:function(t,e,n){return Uh(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},inside:function(t,e,n){return $h(t,e,!1,n)},insideOriented:function(t,e,n){return $h(t,e,!0,n)},left:function(t,e,n){return Uh(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},manual:function(t,e,n){return Uh(n)},outside:function(t,e,n){return qh(t,e,!1,n)},outsideOriented:function(t,e,n){return qh(t,e,!0,n)},radial:function(t,e,n){return Wh(t.difference(e.center()),!1,n)},radialOriented:function(t,e,n){return Wh(t.difference(e.center()),!0,n)},right:function(t,e,n){return Uh(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},top:function(t,e,n){return Uh(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})}},Je=(Yh.prototype={hasPort:function(t){return t in this.portsMap},getPort:function(t){var e=this.portsMap[t];if(e)return e;throw new Error("Element: unable to find port with id "+t)},getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(e){return this.ports.filter(function(t){return t.group===e})},getGroupPortsMetrics:function(t,e){var{x:e=0,y:n=0,width:i=0,height:r=0}=e,o=e+`:${n}:${i}:`+r;return this.metricsKey!==o&&(this.metrics={},this.metricsKey=o),(o=this.metrics[t])||(o=this.resolveGroupPortsMetrics(t,new tt(e,n,i,r)),this.metrics[t]=o),o},resolveGroupPortsMetrics:function(t,o){var e=this.getGroup(t),t=this.getPortsByGroup(t),e=e.position||{},n=e.name,i=this.portLayoutNamespace,e=(i[n]||(n="left"),e.args||{}),r=t.map(function(t){return t&&t.position&&t.position.args}),i=i[n](r,o,e),n={ports:t,result:{}};return et(i).reduce((t,e,n)=>{var i=t.ports[n],r=i.id;return t.result[r]={index:n,portId:r,portTransformation:e,labelTransformation:this._getPortLabelLayout(i,A(e),o),portAttrs:i.attrs,portSize:i.size,labelSize:i.label.size},t},n),n.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(w(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=et(t.items),s=0,a=o.length;s<a;s++){var l=this._evaluatePort(o[s]);this.ports.push(l),this.portsMap[l.id]=l}},_evaluateGroup:function(t){return _(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=T({},t),t=this.getGroup(t.group);return e.markup=e.markup||t.markup,e.attrs=_({},t.attrs,e.attrs),e.position=this._createPositionNode(t,e),e.label=_({},t.label,this._getLabel(e)),e.z=this._getZIndex(t,e),e.size=T({},t.size,e.size),e},_getZIndex:function(t,e){return qs(e.z)?e.z:qs(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return _({name:"left",args:{}},t.position,{args:(null!=e.position&&null!=e.position.args?e.position:e).args})},_getPosition:function(t,e){var n,i={},e=(b(t)?(n="fn",i.fn=t):E(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):w(t)&&(n=t.name,T(i,t.args)),{args:i});return n&&(e.name=n),e},_getLabel:function(t,e){var t=t.label||{},n=t;return n.position=this._getPosition(t.position,e),n}},{_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={},t=(et(t.items).forEach(function(t){e[t.id]=!0}),this.previous("ports")||{}),n={},t=(et(t.items).forEach(function(t){e[t.id]||(n[t.id]=!0)}),this.graph);t&&!ea(n)&&(t.getConnectedLinks(this,{inbound:!0}).forEach(function(t){n[t.get("target").port]&&t.remove()}),t.getConnectedLinks(this,{outbound:!0}).forEach(function(t){n[t.get("source").port]&&t.remove()}))},hasPorts:function(){return 0<this._portSettingsData.getPorts().length},hasPort:function(t){return this._portSettingsData.hasPort(t)},getPorts:function(){return ta(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=et(this.prop(["ports","items"])).filter(t=>t.group===e);return ta(t)},getPort:function(e){var t=et(this.prop("ports/items")).find(t=>t.id&&t.id===e);return ta(t)},getPortGroupNames:function(){return Object.keys(this._portSettingsData.groups)},getPortsPositions:function(t){var e,n=this.getGroupPortsMetrics(t),i={};for(e in n){var{x:r,y:o,angle:s}=n[e].portTransformation;i[e]={x:r,y:o,angle:s}}return i},getPortMetrics:function(t){var e=this._portSettingsData.getPort(t);return this.getGroupPortsMetrics(e.group)[t]},getGroupPortsMetrics:function(t){return this._portSettingsData.getGroupPortsMetrics(t,this.size())},getPortRelativePosition:function(t){var{x:t,y:e,angle:n}=this.getPortMetrics(t).portTransformation;return{x:t,y:e,angle:n}},getPortRelativeRect(t){var{portTransformation:{x:t,y:e,angle:n},portSize:{width:i,height:r}}=this.getPortMetrics(t);return{x:t-i/2,y:e-r/2,width:i,height:r,angle:n}},getPortCenter(t){var e=this.getBBox(),t=this.getPortRelativePosition(t),t=new A(t).offset(e.x,e.y),n=this.angle();return n&&t.rotate(e.center(),-n),t},getPortBBox:function(t,e){var t=this.getPortRelativeRect(t),n=this.getBBox(),t=new tt(t),i=(t.offset(n.x,n.y),this.angle());return i&&t.moveAroundPoint(n.center(),-i),e&&e.rotate&&t.rotateAroundCenter(i),t},getPortIndex:function(t){var e=w(t)?t.id:t;return this._isValidPortId(e)?et(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!w(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=T([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){t="number"==typeof t?t:this.getPortIndex(t);if(!w(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var i=T([],this.prop("ports/items"));return i.splice(t,0,e),this.prop("ports/items",i,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);t=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?t[0]=["ports","items",r].concat(e):E(e)?t[0]=["ports/items/",r,"/",e].join(""):(t=["ports/items/"+r],y(e)&&(t.push(e),t.push(n))),this.prop.apply(this,t)},_validatePorts:function(){var t=this.get("ports")||{},e=[],t=t||{},t=et(t.items);return t.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),Ks(t,"id").length!==t.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!w(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",T([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var n,e=e||{},t=this.getPortIndex(t);return-1!==t&&((n=T([],this.prop(["ports","items"]))).splice(t,1),e.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],n,e),this.stopBatch("port-remove")),this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;e=T([],this.prop(["ports","items"]));i=e.filter(function(e){return!t.some(function(t){t=w(t)?t.id:t;return e.id===t})})}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(0<e.length)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Yh(this.get("ports"));var n,i=this._portSettingsData.getPorts();t&&(e=i.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),0<(n=t.filter(function(e){if(!i.find(function(t){return t.id===e.id}))return e})).length&&this.trigger("ports:remove",this,n),0<e.length)&&this.trigger("ports:add",this,e)}}),hn={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 e=[],n=this._getContainerElement(),t=0,i=n.node.childNodes.length;t<i;t++)e.push(n.node.childNodes[t]);for(var r=ra(this.model._portSettingsData.getPorts(),"z"),o=(et(r.auto).forEach(function(t){t=this._getPortElement(t);n.append(t),e.push(t)},this),Object.keys(r)),s=0;s<o.length;s++){var a,l=o[s];"auto"!==l&&(a=parseInt(l,10),this._appendPorts(r[l],a,e))}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),t=et(t).map(this._getPortElement,this);n[e]||e<0?R(n[Math.max(e,0)]).before(t):i.append(t)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){var n,t=this._portElementsCache[t];return t?e?(n=t.portElement.node,this.findBySelector(e,n,t.portSelectors)):[t.portContentElement.node]:[]},findPortNode:function(t,e){var[t=null]=this.findPortNodes(t,e);return t},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){Xs(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r,o=R(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t),a,l;if(Array.isArray(s)?(l=(a=this.parseDOMJSON(s,o.node)).fragment,e=1<l.childNodes.length?R("g").append(l):R(l.firstChild),r=a.selectors):(e=R(s),Array.isArray(e)&&(e=R("g").append(e))),!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group}),qs(t.id)&&e.attr("port-id-type","number");var h,u=this._getPortLabelMarkup(t.label);if(Array.isArray(u)?({fragment:f,selectors:p}=this.parseDOMJSON(u,o.node),0<(d=f.childNodes.length)&&(i=p,n=1===d?R(f.firstChild):R("g").append(f))):(n=R(u),Array.isArray(n)&&(n=R("g").append(n))),r&&i){for(var c in i)if(r[c]&&c!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=T({},r,i)}else h=r||i||{};var d,f,p="labelText";return"portRoot"in h||(h.portRoot=e.node),n&&(d=n.node,"labelRoot"in h||(h.labelRoot=d),p in h||(f="TEXT"===n.tagName()?d:Array.from(d.querySelectorAll("text")),h[p]=f,(i=i||{})[p]=f)),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){var n=this.model.getGroupPortsMetrics(t),i=Object.keys(n);for(let t=0,e=i.length;t<e;t++){var r=i[t],o=n[r],r=this._portElementsCache[r]||{},s=o.portTransformation,a=o.labelTransformation;a&&r.portLabelElement&&(this.updateDOMSubtreeAttributes(r.portLabelElement.node,a.attrs,{rootBBox:new tt(o.labelSize),selectors:r.portLabelSelectors}),this.applyPortTransform(r.portLabelElement,a,-s.angle||0)),this.updateDOMSubtreeAttributes(r.portElement.node,o.portAttrs,{rootBBox:new tt(o.portSize),selectors:r.portSelectors}),this.applyPortTransform(r.portElement,s)}},applyPortTransform:function(t,e,n){n=R.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(n,{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}},f=Oh.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),Oh.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){var i=qs(e),{parentRelative:r,deep:o,restrictedArea:s}=n=(i?n:t)||{};let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");var l=this.getParentCell();l&&!l.isLink()&&(a=l.get("position"))}return i?(a&&(t+=a.x,e+=a.y),o||s?({x:l,y:i}=this.get("position"),this.translate(t-l,e-i,n)):this.set("position",{x:t,y:e},n),this):(o=A(this.get("position")),r?o.difference(a):o)},translate:function(t,e,n){var i,r,o,s,a;return e=e||0,0===(t=t||0)&&0===e||((n=n||{}).translateBy=n.translateBy||this.id,i=this.get("position")||{x:0,y:0},(s=n.restrictedArea)&&n.translateBy===this.id&&(e="function"==typeof s?(t=(r=s.call(this,i.x+t,i.y+e,n)).x-i.x,r.y-i.y):(r=this.getBBox({deep:!0}),o=i.x-r.x,a=i.y-r.y,o=Math.max(s.x+o,Math.min(s.x+s.width+o-r.width,i.x+t)),s=Math.max(s.y+a,Math.min(s.y+s.height+a-r.height,i.y+e)),t=o-i.x,s-i.y)),a={x:i.x+t,y:i.y+e},n.tx=t,n.ty=e,n.transition?(w(n.transition)||(n.transition={}),this.transition("position",a,T({},n.transition,{valueFunction:Il.object})),Xs(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",a,n),Xs(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}:(w(t)&&(n=e,e=(qs(t.height)?t:i).height,t=(qs(t.width)?t:i).width),this.resize(t,e,n))},resize:function(t,e,n){if(this.startBatch("resize",n=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=Yn(this.get("angle")||0),o=this.getBBox();if(r)var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction],a=o[["bottomLeft","corner","topRight","origin"][s=n.absolute?(s+Math.floor((r+45)/90))%4:s]](),a=A(a).rotate(o.center(),-r),l=Math.sqrt(t*t+e*e)/2,h=s*Math.PI/2,s=(h=(h+=Math.atan(s%2==0?e/t:t/e))-Zn(r),A.fromPolar(l,h,a)),u=A(s).offset(t/-2,e/-2);else switch(u=o.topLeft(),n.direction){case"top":case"top-right":u.offset(0,o.height-e);break;case"left":case"bottom-left":u.offset(o.width-t,0);break;case"top-left":u.offset(o.width-t,o.height-e)}this.set("size",{width:t,height:e},n),this.position(u.x,u.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){t=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(t.x,t.y,i),this.resize(t.width,t.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t={}){var e=this.graph;if(e)return e=this._getFilteredChildElements(t.filter),this.startBatch("fit-embeds",t),t.deep&&Xs(e,"fitToChildren",ca(t,"minRect")),this._fitToElements(Object.assign({elements:e},t)),this.stopBatch("fit-embeds"),this;throw new Error("Element must be part of a graph.")},fitParent:function(t={}){var e,n=this.graph;if(n)return t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id)||(n=this.getParentCell())&&n.isElement()&&(e=n._getFilteredChildElements(t.filter),this.startBatch("fit-parent",t),n._fitToElements(Object.assign({elements:e},t)),t.deep&&n.fitParent(ca(t,"minRect")),this.stopBatch("fit-parent")),this;throw new Error("Element must be part of a graph.")},_getFilteredChildElements:function(e){let t;return t="function"==typeof e?t=>t.isElement()&&e(t):t=>t.isElement(),this.getEmbeddedCells().filter(t)},_fitToElements:function(n={}){let i=null;n.minRect&&(i=new tt(n.minRect));var r=this.graph.getCellsBBox(n.elements);if(r){var{expandOnly:o,shrinkOnly:s}=n;if(o&&s)this._setBBox(i,n);else{var{x:r,y:a,width:l,height:h}=r,{left:u,right:c,top:d,bottom:f}=Ol(n.padding);r-=u,a-=d,l+=u+c,h+=f+d;let t=new tt(r,a,l,h);if(o)t=this.getBBox().union(t);else if(s){u=this.getBBox().intersect(t);if(!u)return void this._setBBox(i,n);t=u}let e=t;i&&(e=e.union(i)),this._setBBox(e,n)}}else this._setBBox(i,n)},_setBBox:function(t,e){var n,i,r;t&&({x:t,y:n,width:i,height:r}=t,this.set({position:{x:t,y:n},size:{width:i,height:r}},e))},rotate:function(t,e,n,i){var r,o,s,a;return n?(a=this.getCenter(),r=this.get("size"),o=this.get("position"),a.rotate(n,this.get("angle")-t),s=a.x-r.width/2-o.x,a=a.y-r.height/2-o.y,this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(o.x+s,o.y+a,i),this.rotate(t,e,null,i),this.stopBatch("rotate")):this.set("angle",e?t:(this.get("angle")+t)%360,i),this},angle:function(){return Yn(this.get("angle")||0)},getBBox:function(t={}){var e,{graph:n,attributes:i}=this,{deep:r,rotate:o}=t;return r&&n?((r=this.getEmbeddedCells({deep:!0,breadthFirst:!0})).push(this),n.getCellsBBox(r,t)):({angle:n=0,position:{x:r,y:t},size:{width:i,height:e}}=i,r=new tt(r,t,i,e),o&&r.rotateAroundCenter(n),r)},getCenter:function(){var{position:{x:t,y:e},size:{width:n,height:i}}=this.attributes;return new A(t+n/2,e+i/2)},getPointFromConnectedLink:function(t,e){var n=this.getBBox().center(),t=t.get(e);return t&&(e=t.port)&&this.hasPort(e)?this.getPortCenter(e):n}});T(f.prototype,Je);let Zh=Oh.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){var i;return void 0===t?Qs(this.get("source")):t instanceof Oh?((i=Qs(e)||{}).id=t.id,this.set("source",i,n)):y(t)?this.set("source",i=t,e):((i=Qs(e)||{}).x=t.x,i.y=t.y,this.set("source",i,n))},target:function(t,e,n){var i;return void 0===t?Qs(this.get("target")):t instanceof Oh?((i=Qs(e)||{}).id=t.id,this.set("target",i,n)):y(t)?this.set("target",i=t,e):((i=Qs(e)||{}).x=t.x,i.y=t.y,this.set("target",i,n))},router:function(t,e,n){var i;return void 0===t?(i=this.get("router"))?"object"==typeof i?Qs(i):i:null:this.set("router",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},connector:function(t,e,n){var i;return void 0===t?(i=this.get("connector"))?"object"==typeof i?Qs(i):i:null:this.set("connector",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},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(){var t=this.attributes.labels;return Array.isArray(t)&&0<t.length},insertLabel:function(t,e,n){var i,r;if(e)return r=(i=this.labels()).length,t=isFinite(t)&&null!==t?0|t:r,i.splice(t=t<0?r+t+1:t,0,e),this.labels(i,n);throw new Error("dia.Link: no label provided")},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();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["vertices",t]):(i=this._normalizeVertex(e),this.prop(["vertices",t],i,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],r=this._normalizeVertex(r);n.push(r)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){var i,r;if(e)return r=(i=this.vertices()).length,(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),r=this._normalizeVertex(e),i.splice(t,0,r),this.vertices(i,n);throw new Error("dia.Link: no vertex provided")},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 y(t)?t:{x:t.x,y:t.y}},translate:function(e,n,t){return(t=t||{}).translateBy=t.translateBy||this.id,t.tx=e,t.ty=n,this.applyToPoints(function(t){return{x:(t.x||0)+e,y:(t.y||0)+n}},t)},scale:function(e,n,i,t){return this.applyToPoints(function(t){return A(t).scale(e,n,i).toJSON()},t)},applyToPoints:function(t,e){var n,i,r;if(b(t))return n={},{source:r,target:i}=this.attributes,r.id||(n.source=t(r)),i.id||(n.target=t(i)),0<(r=this.vertices()).length&&(n.vertices=r.map(t)),this.set(n,e);throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.")},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new A(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new A(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint(),...this.vertices().map(A),this.getTargetPoint()];return new x(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e,n,i,r;return this.graph&&(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),e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,e=e.id,n=n.id;return!(!e||!n)&&(!(e=e===n)&&t.deep&&this.graph&&(n=this.getSourceCell(),t=this.getTargetCell(),e=n.isEmbeddedIn(t)||t.isEmbeddedIn(n)),e)},getSourceCell:function(){var{graph:t,attributes:e}=this,e=e.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getSourceCell())&&t.isLink());return t},getTargetCell:function(){var{graph:t,attributes:e}=this,e=e.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getTargetCell())&&t.isLink());return t},getRelationshipAncestor:function(){var t;return this.graph&&(t=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t}),t=this.graph.getCommonAncestor.apply(this.graph,t)),t||null},isRelationshipEmbeddedIn:function(t){var t=E(t)||qs(t)?t:t.id,e=this.getRelationshipAncestor();return!!e&&(e.id===t||e.isEmbeddedIn(t))},_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}}),Jh={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))},isSafari:function(){return/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)}},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){try{n=e()}catch{n=!1}this._results[t]=n}return n}};function Kh(r,o,s=[],t={}){var{cornerType:a=Qh.POINT,cornerRadius:l=eu,cornerPreserveAspectRatio:h=!1,precision:u=nu,raw:t=!1}=t;if(-1===tu.indexOf(a))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(a!==Qh.POINT&&l){(c=new V).appendSegment(V.createSegment("M",r));let i;var e=s.length;for(let n=0;n<e;n++){var d=new A(s[n]),f=s[n-1]||r,p=s[n+1]||o,g=i||d.distance(f)/2;i=d.distance(p)/2;let t,e;h?t=e=-Math.min(l,g,i):(t=-Math.min(l,g),e=-Math.min(l,i));var m=d.clone().move(f,t).round(u),v=d.clone().move(p,e).round(u);switch(c.appendSegment(V.createSegment("L",m)),a){case Qh.CUBIC:var y=new A(1/3*m.x+2/3*d.x,2/3*d.y+1/3*m.y),b=new A(1/3*v.x+2/3*d.x,2/3*d.y+1/3*v.y);c.appendSegment(V.createSegment("C",y,b,v));break;case Qh.LINE:c.appendSegment(V.createSegment("L",v));break;case Qh.GAP:c.appendSegment(V.createSegment("M",v))}}c.appendSegment(V.createSegment("L",o))}else{var n=[r].concat(s).concat([o]),n=new x(n);c=new V(n)}return t?c:c.serialize()}Ke=f.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"}]}),h=f.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"}]}),a=f.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"}]}),i=f.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"}]}),s=f.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"}]}),o=f.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"}]}),e=f.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"}]}),Ue=f.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"}]}),l=f.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"}]}),r=f.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"}]}),C=f.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"}]}),n=f.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){var n;return void 0===t?this.attr("body/lateralArea"):(n={lateralArea:t},t=Sl(t)?`calc(${parseFloat(t)/100}*h)`:t,this.attr({body:n,top:{cy:t,ry:t}},e))}},{attributes:{"lateral-area":{set:function(t,e){var n=Sl(t),i=(n&&(t=parseFloat(t)/100),e.x),r=e.y,o=e.width,e=e.height,s=o/2,a=n?e*t:t,l=R.KAPPA,s=l*s,l=l*(n?e*t:t),n=i+o/2,t=i+o,o=r+a,h=o-a,a=r+e-a,r=r+e;return{d:["M",i,o,"L",i,a,"C",i,a+l,n-s,r,n,r,"C",n+s,r,t,a+l,t,a,"L",t,o,"C",t,o-l,n+s,h,n,h,"C",n-s,h,i,o-l,i,o,"Z"].join(" ")}},unset:"d"}}}),u=Jh.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"}},Je=f.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"},u]},{attributes:{text:{set:function(t,e,n,i){var r,o;if(!(n instanceof HTMLElement))return i=i.style||{},r={text:t,width:-5,height:"100%"},o=T({"text-vertical-anchor":"middle"},i),Mh["text-wrap"].set.call(this,r,e,n,o),{fill:i.color||null};n.textContent=t},unset:function(t){if(t.textContent="",t instanceof SVGElement)return"fill"},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),u=Zh.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"}}]}),Ue={__proto__:null,standard:{__proto__:null,BorderedImage:Ue,Circle:h,Cylinder:n,DoubleLink:Zh.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"}}]}),Ellipse:a,EmbeddedImage:l,HeaderedRectangle:C,Image:e,InscribedImage:r,Link:u,Path:i,Polygon:s,Polyline:o,Rectangle:Ke,ShadowLink:Zh.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"}}]}),TextBlock:Je}};let Qh={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},tu=Object.values(Qh),eu=10,nu=1;var iu=["arc","gap","cubic"],ru=1,ou=["smooth"],su=1/3,au=2/3;function lu(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;return n>r&&(t=n,n=r,r=t,t=i,i=o,o=t),i>o&&(e=n,n=r,r=e,e=i,i=o,o=e),[new A(n,i),new A(r,o)]}function hu(t,e,n){var r=[].concat(t,n,e);return r.reduce(function(t,e,n){var i=r[n+1];return null!=i&&(t[n]=fi(e,i)),t},[])}function uu(t){var e,r=t.paper,n=r._jumpOverUpdateList;null==n&&(n=r._jumpOverUpdateList=[],(e=r.model).on("batch:stop",function(){if(!this.hasActiveBatch())for(var t=r._jumpOverUpdateList,e=0;e<t.length;e++){var n=t[e],i=n.getFlag(n.constructor.Flags.CONNECTOR);n.requestUpdate(i)}}),e.on("reset",function(){n=r._jumpOverUpdateList=[]})),n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",function(){n.splice(n.indexOf(t),1)}))}function cu(t,e){return fi(t,e).squaredLength()}function du(h,u,c,d){var f=new V,p=V.createSegment("M",h[0].start);return f.appendSegment(p),et(h).forEach(function(t,e){var n,i,r,o,s,a,l;t.isJump?"arc"===c?(s=-90,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(s+=180),r=t.midpoint(),o=new P(r,t.end).rotate(r,s),a=(n=new P(t.start,r)).pointAt(2/3).rotate(t.start,s),l=o.pointAt(1/3).rotate(o.end,-s),p=V.createSegment("C",a,l,o.end),f.appendSegment(p),n=new P(r,t.end),a=o.pointAt(1/3).rotate(o.end,s),l=n.pointAt(1/3).rotate(t.end,-s),p=V.createSegment("C",a,l,t.end),f.appendSegment(p)):"gap"===c?(p=V.createSegment("M",t.end),f.appendSegment(p)):"cubic"===c&&(s=t.start.theta(t.end),r=.6*u,o=1.35*u,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(o*=-1),a=A(t.start.x+r,t.start.y+o).rotate(t.start,s),l=A(t.end.x-r,t.end.y+o).rotate(t.end,s),p=V.createSegment("C",a,l,t.end),f.appendSegment(p)):(n=h[e+1],0==d||!n||n.isJump?(p=V.createSegment("L",t.end),f.appendSegment(p)):(i=d,r=f,o=t.end,s=t.start,a=n.end,l=o.distance(s)/2,e=o.distance(a)/2,l=-Math.min(i,l),i=-Math.min(i,e),e=o.clone().move(s,l).round(),s=o.clone().move(a,i).round(),l=new A(su*e.x+au*o.x,au*o.y+su*e.y),a=new A(su*s.x+au*o.x,au*o.y+su*s.y),i=V.createSegment("L",e),r.appendSegment(i),i=V.createSegment("C",l,a,s),r.appendSegment(i)))}),f}let fu={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},pu={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"};function gu(t,e,n=[],i={},r){var o=Boolean(i.raw),{direction:s=fu.AUTO,precision:a=3}=i;let l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new A(i.sourceTangent):null,targetTangent:i.targetTangent?new A(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new A(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new A(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new A(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new A(i.targetDirection).normalize():null,i=[t,...n,e].map(t=>new A(t));let h;h=l.sourceTangent||(t=((t,e,n,i)=>{if(i.sourceDirection)switch(i.sourceDirection){case pu.UP:return new A(0,-1);case pu.DOWN:return new A(0,1);case pu.LEFT:return new A(-1,0);case pu.RIGHT:return new A(1,0);case pu.AUTO:return mu(t,e,i);case pu.CLOSEST_POINT:return yu(0,e);case pu.OUTWARDS:return xu(t,e);default:return i.sourceDirection}switch(n){case fu.HORIZONTAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.x>e[1].x?"right":"left";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case fu.VERTICAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.y>e[1].y?"bottom":"top";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case fu.CLOSEST_POINT:return yu(0,e);case fu.OUTWARDS:return xu(t,e);default:fu.AUTO;return mu(t,e,i)}})(r,i,s,l),n=i[0].distance(i[1])*l.coeff,(e=Au(t,i[1].difference(i[0]).normalize()))>Math.PI/4?(e=n+(e-Math.PI/4)*l.angleTangentCoefficient,t.clone().scale(e,e)):t.clone().scale(n,n));let u;return u=l.targetTangent||(e=((t,e,n,i)=>{if(i.targetDirection)switch(i.targetDirection){case pu.UP:return new A(0,-1);case pu.DOWN:return new A(0,1);case pu.LEFT:return new A(-1,0);case pu.RIGHT:return new A(1,0);case pu.AUTO:return vu(t,e,i);case pu.CLOSEST_POINT:return bu(0,e);case pu.OUTWARDS:return wu(t,e);default:return i.targetDirection}switch(n){case fu.HORIZONTAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.x>e[e.length-2].x?"left":"right";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case fu.VERTICAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.y>e[e.length-2].y?"top":"bottom";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case fu.CLOSEST_POINT:return bu(0,e);case fu.OUTWARDS:return wu(t,e);default:fu.AUTO;return vu(t,e,i)}})(r,i,s,l),n=i[(t=i.length-1)-1].distance(i[t])*l.coeff,(r=Au(e,i[t-1].difference(i[t]).normalize()))>Math.PI/4?(s=n+(r-Math.PI/4)*l.angleTangentCoefficient,e.clone().scale(s,s)):e.clone().scale(n,n)),t=((r,t,e,n)=>{var{tau:i,coeff:o}=n,s=[],a=[],l=[],h=r.length-1;for(let t=0;t<h;t++)s[t]=r[t].distance(r[t+1]);a[0]=t,a[h]=e;for(let i=1;i<h;i++){let t,e;t=1===i?r[i-1].clone().offset(a[i-1].x,a[i-1].y):r[i-1].clone(),e=i===h-1?r[i+1].clone().offset(a[i+1].x,a[i+1].y):r[i+1].clone();var u=t.difference(r[i]).normalize(),c=e.difference(r[i]).normalize(),d=Au(u,c);let n=(Math.PI-d)/2;var u=Pu(u,c),d=(f=Pu(r[i].difference(r[i+1]),r[i].difference(r[i-1])),u<0&&(n=-n),d<Math.PI/2&&(n<0&&f<0||0<n&&0<f)&&(n-=Math.PI),((t,e)=>{var n=Math.cos(e),e=Math.sin(e),i=n*t.x-e*t.y,e=e*t.x+n*t.y;t.x=i,t.y=e})(u=c.clone(),n),u.clone()),f=u.clone(),c=s[i-1]*o,u=s[i]*o;d.scale(c,c),f.scale(u,u),a[i]=[d,f]}for(let n=0;n<h;n++){let t,e;t=0===n?r[n+1].difference(a[n].x/i,a[n].y/i):r[n+1].difference(a[n][1].x/i,a[n][1].y/i),e=n===h-1?r[n].clone().offset(a[n+1].x/i,a[n+1].y/i):r[n].difference(a[n+1][0].x/i,a[n+1][0].y/i),l[n]=[t,r[n],r[n+1],e]}return l})(i,h,u,l).map(t=>{return t=t,e=(e=l).tau,(n=new A).x=t[1].x+(t[2].x-t[0].x)/(6*e),n.y=t[1].y+(t[2].y-t[0].y)/(6*e),(i=new A).x=t[2].x+(t[3].x-t[1].x)/(6*e),i.y=t[2].y+(t[3].y-t[1].y)/(6*e),new v(t[1],n,i,t[2]);var e,n,i}),r=new V(t).round(a),o?r:r.serialize()}function mu(t,e,n){var i,r=t.sourceBBox;let o,s,a;switch(o=t.sourceView?(s=t.sourceView.model.angle(),n.rotate&&s?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(i=e[0].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[0])):r.sideNearestToPoint(e[1])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function vu(t,e,n){var i,r=t.targetBBox;let o,s,a;switch(o=t.targetView?(s=t.targetView.model.angle(),n.rotate&&s?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(i=e[e.length-1].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[e.length-1])):r.sideNearestToPoint(e[e.length-2])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function yu(t,e){return e[1].difference(e[0]).normalize()}function bu(t,e){var n=e.length-1;return e[n-1].difference(e[n]).normalize()}function xu(t,e){t=t.sourceBBox,t=t.center();return e[0].difference(t).normalize()}function wu(t,e){t=t.targetBBox,t=t.center();return e[e.length-1].difference(t).normalize()}function Au(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return 1<(n=n<-1?-1:n)&&(n=1),Math.acos(n)}function Pu(t,e){return t.x*e.y-t.y*e.x}function Eu(t){this.cid=ma("view"),this.preinitialize.apply(this,arguments),T(this,da(t,_u)),this._ensureElement(),this.initialize.apply(this,arguments)}gu.Directions=fu,gu.TangentDirections=pu;var Tu={__proto__:null,curve:gu,jumpover:function(t,e,n,i){uu(this);var r,o,s,u,a,c,l=i.raw,d=i.size||5,h=i.jump&&(""+i.jump).toLowerCase(),f=i.radius||0,p=i.ignoreConnectors||ou,g=(-1===iu.indexOf(h)&&(h=iu[0]),this.paper),i=g.model.getLinks();return 1===i.length?du(hu(t,e,n),d,h,f):(r=this.model,o=i.indexOf(r),s=g.options.defaultConnector||{},i=(u=i.filter(function(t,e){t=t.get("connector")||s;return!(et(p).includes(t.name)||o<e&&"jumpover"===t.name)})).map(function(t){return g.findViewByModel(t)}),a=hu(t,e,n),c=i.map(function(t){return null==t?[]:t===this?a:hu(t.sourcePoint,t.targetPoint,t.route)},this),t=du(a.reduce(function(t,l){var s,a,h,e=u.reduce(function(t,e,n){var i;return e!==r&&(-1<(n=(e=c[n].slice()).findIndex(t=>{var[{x:e,y:n},{x:i,y:r}]=lu((e=l).start,e.end),[{x:t,y:o},{x:s,y:a}]=lu(t.start,t.end);return e<=s&&t<=i&&(n<=a&&o<=r)}))&&l.containsPoint(e[n].end)&&e.splice(n+1,1),i=l,n=e,e=et(n).reduce(function(t,e){e=i.intersection(e);return e&&t.push(e),t},[]),t.push.apply(t,e)),t},[]).sort(function(t,e){return cu(l.start,t)-cu(l.start,e)});return 0<e.length?t.push.apply(t,(s=l,h=d,(a=e).reduce(function(t,e,n){if(!0!==e.skip){var i=t.pop()||s,r=ui(e).move(i.start,-h),e=ui(e).move(i.start,+h),n=a[n+1];if(null!=n){var o=e.distance(n);o<=h&&(e=n.move(i.start,o),n.skip=!0)}else if(r.distance(i.end)<2*h+ru)return t.push(i),t;e.distance(i.start)<2*h+ru?t.push(i):((o=fi(r,e)).isJump=!0,t.push(fi(i.start,r),o,fi(e,i.end)))}return t},[]))):t.push(l),t},[]),d,h,f),l?t:t.serialize())},normal:function(t,e,n=[],i={}){i=i.raw,i={cornerType:"point",raw:i};return Kh(t,e,n,i)},rounded:function(t,e,n=[],i={}){var{radius:i=10,raw:r}=i,i={cornerType:"cubic",cornerRadius:i,precision:0,raw:r};return Kh(t,e,n,i)},smooth:function(t,e,n,i){var r,o,i=i&&i.raw;return n&&0!==n.length?(n=[t].concat(n).concat([e]),n=v.throughPoints(n),r=new V(n)):(r=new V,n=V.createSegment("M",t),r.appendSegment(n),n=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?(o=(t.x+e.x)/2,V.createSegment("C",o,t.y,o,e.y,e.x,e.y)):(o=(t.y+e.y)/2,V.createSegment("C",t.x,o,e.x,o,e.x,e.y)),r.appendSegment(n)),i?r:r.serialize()},straight:Kh},Su=/^(\S+)\s*(.*)$/,_u=["model","collection","el","id","attributes","className","tagName","events","style"];T(Eu.prototype,$l,{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 L?t:L(t),this.el=this.$el[0]},delegateEvents:function(t){if(t=t||S(this,"events"))for(var e in this.undelegateEvents(),t){var n=t[e];(n=b(n)?n:this[n])&&(e=e.match(Su),this.delegate(e[1],e[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(){var t;this.el?this.setElement(S(this,"el")):(t=T({},S(this,"attributes")),this.id&&(t.id=S(this,"id")),this.className&&(t.class=S(this,"className")),this.setElement(this._createElement(S(this,"tagName"))),this._setAttributes(t))},_setAttributes:function(t){this.$el.attr(t)}}),Eu.extend=jl;let Lu={},ku=Eu.extend({options:{},theme:null,themeClassNamePrefix:al("theme-"),requireSetThemeOverride:!1,defaultTheme:hl.defaultTheme,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=T({},this.options,t),Eu.call(this,t)},initialize:function(){(Lu[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){(this.svgElement?this.vel:this.$el).remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){var e,n;return(t=t||S(this,"children"))&&(e=this.svgElement,n=R.namespace[e?"svg":"xhtml"],t=dl(t,n),(e?this.vel:this.$el).empty().append(t.fragment),this.childNodes=t.selectors),this},findAttributeNode:function(t,e){let n=e;for(;n&&1===n.nodeType;){if(n.getAttribute(t))return n;if(n===this.el)return null;n=n.parentNode}return null},findAttribute:function(t,e){e=this.findAttributeNode(t,e);return e&&e.getAttribute(t)},_ensureElement:function(){var t,e,n;this.el?this.setElement(S(this,"el")):(t=S(this,"tagName"),e=T({},S(this,"attributes")),n=T({},S(this,"style")),this.id&&(e.id=S(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)),this._ensureElClassName()},_setAttributes:function(t){(this.svgElement?this.vel:this.$el).attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(R.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof L?t:L(t),this.el=this.$el[0],this.svgElement&&(this.vel=R(this.el))},_ensureElClassName:function(){var t,e=S(this,"className");e&&(t=al(e),(this.svgElement?this.vel:this.$el).removeClass(e).addClass(t))},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){return(t=t||this.theme)&&(t=this.themeClassNamePrefix+t,(this.svgElement?this.vel:this.$el).addClass(t)),this},removeThemeClassName:function(t){t=t||this.theme;t=this.themeClassNamePrefix+t;return(this.svgElement?this.vel:this.$el).removeClass(t),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),Lu[this.cid]=null,Eu.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(e){n=n||{};var i,r=this.getEventNamespace();for(i in e){var o=e[i];(o="function"!=typeof o?this[o]:o)&&L(t).on(i+r,n,o.bind(this))}}return this},undelegateElementEvents:function(t){return L(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t=t||S(this,"documentEvents"),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){var n,i;if(t)return n=t.data,i="__"+this.cid+"__",void 0===e?n&&n[i]||{}:((n=n||(t.data={}))[i]||(n[i]={}),T(n[i],e),this);throw new Error("eventData(): event object required.")},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]&&T({},t[0])||{},t=t[1]&&T({},t[1])||{},n=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof n&&n.apply(this,arguments),this.render.__render__===n&&this.onRender(),this},e.render.__render__=n,Eu.extend.call(this,e,t)}});function Cu(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,T({silent:!0},e))}function Mu(t,e,n){n=Math.min(Math.max(n,0),t.length);for(var i=Array(t.length-n),r=e.length,o=0;o<i.length;o++)i[o]=t[o+n];for(o=0;o<r;o++)t[o+n]=e[o];for(o=0;o<i.length;o++)t[o+r+n]=i[o]}var Nu,Ou,Ru,Iu={add:!0,remove:!0,merge:!0},Vu={add:!0,remove:!1};T(Cu.prototype,$l,{model:Gl,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(t,e){return this.set(t,T({merge:!1},e,Vu))},remove:function(t,e){e=T({},e);var n=!Array.isArray(t),t=(t=n?[t]:t.slice(),this._removeModels(t,e));return!e.silent&&t.length&&(e.changes={added:[],merged:[],removed:t},this.trigger("update",this,e)),n?t[0]:t},set:function(t,e){if(null!=t){e=T({},Iu,e);for(var n=!Array.isArray(t),i=(t=n?[t]:t.slice(),e.at),r=((i=(i=null!=i?+i:i)>this.length?this.length:i)<0&&(i+=this.length+1),[]),o=[],s=[],a=[],l={},h=e.add,u=e.merge,c=e.remove,d=!1,f=this.comparator&&null==i&&!1!==e.sort,p=E(this.comparator)?this.comparator:null,g=0;g<t.length;g++){var m,v=t[g],y=this.get(v);y?(u&&v!==y&&(m=this._isModel(v)?v.attributes:v,y.set(m,e),s.push(y),f)&&!d&&(d=y.hasChanged(p)),l[y.cid]||(l[y.cid]=!0,r.push(y)),t[g]=y):h&&(v=t[g]=this._prepareModel(v,e))&&(o.push(v),this._addReference(v,e),l[v.cid]=!0,r.push(v))}if(c){for(g=0;g<this.length;g++)l[(v=this.models[g]).cid]||a.push(v);a.length&&this._removeModels(a,e)}var b=!1;if(r.length&&(!f&&h&&c)?(b=this.length!==r.length||this.models.some(function(t,e){return t!==r[e]}),this.models.length=0,Mu(this.models,r,0),this.length=this.models.length):o.length&&(f&&(d=!0),Mu(this.models,o,null==i?this.length:i),this.length=this.models.length),d&&this.sort({silent:!0}),!e.silent){for(g=0;g<o.length;g++)null!=i&&(e.index=i+g),(v=o[g]).trigger("add",v,this,e);(d||b)&&this.trigger("sort",this,e),(o.length||a.length||s.length)&&(e.changes={added:o,removed:a,merged:s},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?Qs(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,T({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,T({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,T({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 b(e)&&(e=e.bind(this)),1===n||E(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 Fu(this,Bu)},keys:function(){return new Fu(this,Du)},entries:function(){return new Fu(this,zu)},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):(t=((e=e?Qs(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,t.validationError,e),!1):t},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r,o,s=this.get(t[i]);s&&(r=this.models.indexOf(s),this.models.splice(r,1),this.length--,delete this._byId[s.cid],null!=(o=this.modelId(s.attributes,s.idAttribute))&&delete this._byId[o],e.silent||(e.index=r,s.trigger("remove",s,this,e)),n.push(s),this._removeReference(s,e))}return 0<t.length&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof Gl},_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;"changeId"===t&&(n=this.modelId(e.previousAttributes(),e.idAttribute),t=this.modelId(e.attributes,e.idAttribute),null!=n&&delete this._byId[n],null!=t)&&(this._byId[t]=e)}this.trigger.apply(this,arguments)}});(h="function"==typeof Symbol&&Symbol.iterator)&&(Cu.prototype[h]=Cu.prototype.values);var Fu=function(t,e){this._collection=t,this._kind=e,this._index=0},Bu=1,Du=2,zu=3;function ju(t){return t?Array.isArray(t)?t:[t]:[]}h&&(Fu.prototype[h]=function(){return this}),Fu.prototype.next=function(){if(this._collection){var t,e;if(this._index<this._collection.length)return t=this._collection.at(this._index),this._index++,{value:this._kind===Bu?t:(e=this._collection.modelId(t.attributes,t.idAttribute),this._kind===Du?e:[e,t]),done:!1};this._collection=void 0}return{value:void 0,done:!0}},l=(a=n=[Cu,{toArray:1,sortBy:3},"models"])[0],a=n[2],C={sortBy:oa,toArray:et},Nu=l,Ou=C,l=n[1],Ru=a,fa(l,function(t,e){Ou[e]&&(Nu.prototype[e]=nh(Ou,t,e,Ru))}),Cu.extend=jl,e={__proto__:null,$:L,Collection:Cu,Data:va,Event:ya,Events:$l,Listener:class{constructor(...t){this.callbackArguments=t}listenTo(i,r,...o){let s=this.callbackArguments;if(r&&"object"==typeof r){let[n=null]=o;Object.entries(r).forEach(([t,e])=>{"function"==typeof e&&((n||0<s.length)&&(e=e.bind(n,...s)),$l.listenTo.call(this,i,t,e))})}else if("string"==typeof r&&"function"==typeof o[0]){let[t,e=null]=o;(e||0<s.length)&&(t=t.bind(e,...s)),$l.listenTo.call(this,i,r,t)}}stopListening(){$l.stopListening.call(this)}},Model:Gl,View:ku,ViewBase:Eu,views:Lu};let Gu=ku.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){var n=t.paper;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;var{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform()):this.postponedUpdate=!0,0},findNode(t,e=null){let n;var i,r,o,s;return"string"==typeof e?n=t.findNode(e):y(e)?(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)):!e||(n=R.toNode(e))instanceof SVGElement&&t.el.contains(n)||(n=null),n||null},getNodeMatrix(t,e){var n=this.options,n=n.layer,i=t.rotatableNode,r=t.getNodeMatrix(e);return i?n?i.contains(e)?r:t.getRootRotateMatrix().inverse().multiply(r):t.getNodeRotateMatrix(e).multiply(r):r},mount(){var{MOUNTABLE:e,cellView:t,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(e&&!r)if(s)this.update(t,a),this.transform();else{var e=t.paper,{layer:r,z:s}=i;if(r){let t;o?(t=o,this.detachedTransformGroup=null):t=R("g").addClass("highlight-transform").append(n),this.transformGroup=t,e.getLayerView(r).insertSortedNode(t.node,s)}else{a=t.el.children[Math.max(s,0)],i=qs(s)&&a,o=i?n===a:!n.nextElementSibling;n.parentNode&&o||(i?t.el.insertBefore(n,a):t.el.appendChild(n))}}},unmount(){var{MOUNTABLE:t,transformGroup:e,vel:n,options:i}=this;t&&(i.layer?e&&(this.transformGroup=null,(this.detachedTransformGroup=e).remove()):n.remove())},transform(){var{transformGroup:t,cellView:e,updateRequested:n}=this;!t||e.model.isLink()||n||(n=e.getRootTranslateMatrix(),e=e.getRootRotateMatrix(),n=n.multiply(e),t.attr("transform",R.matrixToTransformString(n)))},update(){var{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;i||(this.postponedUpdate=!1,i=this.node=this.findNode(e,n),t&&this.unhighlight(e,t),i?(this.highlight(e,i),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this)))},onRemove(){var{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){var e=S(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){var n=this.cellView;if(n){let{model:e,paper:t}=n;S(this,"UPDATE_ATTRIBUTES").some(t=>e.hasChanged(t))&&t.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}}},{_views:{},highlight:function(t,e,n){var i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){e=this.uniqueId(e,n);this.remove(t,e)},get(t,e=null){var t=t.cid,n=this._views,i=n[t];if(null===e){var r=[];if(i)for(var o in i){o=i[o];o instanceof this&&r.push(o)}return r}if(i&&e in i){n=i[e];if(n instanceof this)return n}return null},add(t,e,n,i={}){var r;if(n)return(r=Gu.get(t,n))&&r.remove(),(r=new this(i)).id=n,this._addRef(t,n,r),r.requestUpdate(t,e),r.listenToUpdateAttributes(t),r;throw new Error("dia.HighlighterView: An ID required.")},_addRef(t,e,n){var t=t.cid,i=this._views;let r=i[t];(r=r||(i[t]={}))[e]=n},_removeRef(t,e){var t=t.cid,n=this._views,i=n[t];if(i){for(var r in e&&delete i[e],i)return;delete n[t]}},remove(t,e=null){ju(this.get(t,e)).forEach(t=>{t.remove()})},getAll(t,e=null){var n,i=[],r=this._views;for(n in r)for(var o in r[n]){var s=r[n][o];s.cellView.paper===t&&s instanceof this&&(null===e||o===e)&&i.push(s)}return i},removeAll(t,e=null){this.getAll(t,e).forEach(t=>t.remove())},update(t,e=null,n=!1){ju(this.get(t,e)).forEach(t=>{(n||t.UPDATABLE)&&t.update()})},transform(t,e=null){ju(this.get(t,e)).forEach(t=>{t.UPDATABLE&&t.transform()})},unmount(t,e=null){ju(this.get(t,e)).forEach(t=>t.unmount())},mount(t,e=null){ju(this.get(t,e)).forEach(t=>t.mount())},uniqueId(t,e=""){return R.ensureId(t)+JSON.stringify(e)}}),Uu=(r=Gu.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){var n=this.options,i=n.useFirstSubpath;let r;try{var o,s=R(e);r=s.convertToPathData().trim(),"PATH"===s.tagName()&&i&&0<(o=r.search(/.M/i)+1)&&(r=r.substr(0,o))}catch{s=t.getNodeBoundingRect(e);r=R.rectToPath(T({},n,s.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){var n,i,r,{vel:o,options:s}=this,{padding:s,layer:a}=s;let l=this.getNodeMatrix(t,e);s&&(a||e!==t.el||o.remove(),n=(a=t.getNodeBoundingRect(e)).x+a.width/2,i=a.y+a.height/2,a=R.transformRect(a,l),r=((r=Math.max(a.width,1))+s)/r,s=((a=Math.max(a.height,1))+s)/a,a=R.createSVGMatrix({a:r,b:0,c:0,d:s,e:n-r*n,f:i-s*i}),l=l.multiply(a)),o.attr({d:this.getPathData(t,e),transform:R.matrixToTransformString(l)})},highlight(t,e){var{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)}}),u=Gu.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:20,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(e,n){var{MASK_CHILD_ATTRIBUTE_BLACKLIST:t,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=n.tagName();if(!R.isSVGGraphicsElement(n)||r.includes(o))return n.remove(),!1;if(i.includes(o)){r=e.vel.findOne("#"+n.id);if(r){i=r.node;let t=e.getNodeBoundingRect(i);e.model.isElement()&&(t=R.transformRect(t,e.getNodeMatrix(i)));var o=R("rect",t.toJSON()),{x:e,y:i}=t.center(),{angle:r,cx:e=e,cy:i=i}=r.rotate();r&&o.rotate(r,e,i),n.parent().append(o)}return n.remove(),!1}return t.forEach(t=>{"fill"===t&&"none"===n.attr("fill")||n.removeAttr(t)}),!0},transformMaskRoot(t,e){var n=this.MASK_ROOT_ATTRIBUTE_BLACKLIST;n.forEach(t=>{e.removeAttr(t)})},getMaskShape(e,t){var{options:n,MASK_REPLACE_TAGS:i}=this,n=n.deep,r=t.tagName();let o;if("G"===r){if(!n)return null;for(var n=o=t.clone(),s=t=>this.transformMaskChild(e,t),a=n.children();0<a.length;){var l=a.shift();s(l)&&a.push(...l.children())}}else{if(i.includes(r))return null;o=t.clone()}return this.transformMaskRoot(e,o),o},getMaskId(){return"highlight-mask-"+this.cid},getMask(t,e){var{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:r,attrs:o}=r,s=parseFloat(R("g").attr(o).attr("stroke-width")),a="none"!==e.attr("fill");let l=parseFloat(e.attr("stroke-width"));r=(l=isNaN(l)?1:l)+2*r,s=r+2*s;let h=this.getMaskShape(t,e);return h||((t=t.getNodeBoundingRect(e.node)).inflate(t.width?0:.5,t.height?0:.5),h=R("rect",t.toJSON())),h.attr(o),R("mask",{id:this.getMaskId()}).append([h.clone().attr({fill:a?n:"none",stroke:n,"stroke-width":s}),h.clone().attr({fill:a?i:"none",stroke:i,"stroke-width":r})])},removeMask(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){var{options:n,vel:i}=this,{padding:n,attrs:r,maskClip:o=20,layer:s}=n,r="stroke"in r?r.stroke:"#000000",s=(s||e!==t.el||i.remove(),t.getNodeBoundingRect(e).inflate(n+o)),n=this.getNodeMatrix(t,e),o=this.getMask(t,R(e));this.addMask(t.paper,o),i.attr(s.toJSON()),i.attr({transform:R.matrixToTransformString(n),mask:`url(#${o.id})`,fill:r})},unhighlight(t){this.removeMask(t.paper)}}),i=Gu.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){var{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),s=al("highlighted"),o=Gu.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:s},highlight:function(t,e){R(e).addClass(this.options.className)},unhighlight:function(t,e){R(e).removeClass(this.options.className)}},{className:s}),{ROW:"row",COLUMN:"column"});function Hu(t,e,n){var i,r,o;return y(n)&&({x:i,y:o}=n,isFinite(o)&&({start:o,end:r}=new P(e,t).parallel(o),e=o,t=r),n=i),!isFinite(n)||(o=t.distance(e),0===n&&0<o)?t:t.move(e,-Math.min(n,o-1))}function qu(t){t=t.getAttribute("stroke-width");return null!==t&&parseFloat(t)||0}function $u(t,e,n,i){e=i.useModelGeometry?Wu(e,n,!0):e.getNodeBBox(n),i.stroke&&e.inflate(qu(n)/2),n=t.intersect(e);return Hu(n?t.start.chooseClosest(n):t.end,t.start,i.offset)}function Wu(t,e,n){var i=t.model,t=t.findAttribute("port",e);return i.hasPort(t)?i.getPortBBox(t,{rotate:n}):i.getBBox({rotate:n})}Ke={__proto__:null,addClass:o,list:Gu.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){t=t.model;let{attribute:r,size:n=20,gap:o=5,direction:i=Uu.ROW}=this.options;if(!r)throw new Error("List: attribute is required");let s="number"==typeof n?{width:n,height:n}:n,a=i===Uu.ROW,l=a?s.width:s.height,h=t.get(r),u=(Array.isArray(h)||(h=[]),this._prevItems||[]),c=h.map((t,e)=>na(u[e],h[e]));if(u.length!==h.length||c.some(t=>!t)){let i=this.vel.children();var d=h.map((t,e)=>{var n=e in i?i[e].node:null;if(c[e])return n;t=this.createListItem(t,s,n);if(!t)return null;if(!(t instanceof SVGElement))throw new Error("List: item must be an SVGElement");t.dataset.index=e,t.dataset.attribute=r;n=e*(l+o);return t.setAttribute("transform",a?`translate(${n}, 0)`:`translate(0, ${n})`),t});this.vel.empty().append(d),this._prevItems=h}d=h.length,d=0===d?0:d*l+(d-1)*o,d=a?{width:d,height:s.height}:{width:s.width,height:d};this.position(t,d)},position(t,e){var{vel:n,options:i}=this,{margin:i=5,position:r="top-left"}=i,{width:t,height:o}=t.size(),{left:i,right:s,top:a,bottom:l}=Ol(i);let{x:h,y:u}=Vh(new tt(i,a,t-(i+s),o-(a+l)),r);switch(r){case d.CENTER:case d.TOP:case d.BOTTOM:h-=e.width/2;break;case d.RIGHT:case d.BOTTOM_RIGHT:case d.TOP_RIGHT:h-=e.width}switch(r){case d.CENTER:case d.RIGHT:case d.LEFT:u-=e.height/2;break;case d.BOTTOM:case d.BOTTOM_RIGHT:case d.BOTTOM_LEFT:u-=e.height}n.attr("transform",`translate(${h}, ${u})`)}},{Directions:Uu,Positions:d}),mask:u,opacity:i,stroke:r};var Yu="segmentSubdivisons",Xu="shapeBBox";function Zu(t,e){return 0===e?"0%":Math.round(t/e*100*1e3)/1e3+"%"}function Ju(r){return function(t,e,n,i){return(e.isNodeConnection(n)?Qu:Ku)(r,t,e,n,i)}}function Ku(t,e,n,i,r){var o=n.model.angle(),i=n.getNodeUnrotatedBBox(i),n=n.model.getCenter(),n=(r.rotate(n,o),r.x-i.x),o=r.y-i.y;return t&&(n=Zu(n,i.width),o=Zu(o,i.height)),e.anchor={name:"topLeft",args:{dx:n,dy:o,rotate:!0}},e}function Qu(t,e,n,i,r){n=n.getConnection();return n&&(r=n.closestPointLength(r),t?(t=n.length(),e.anchor={name:"connectionRatio",args:{ratio:r/t}}):e.anchor={name:"connectionLength",args:{length:r}}),e}h=Ju(!(Je={__proto__:null,anchor:function(t,e,n,i){var{offset:i,alignOffset:r,align:o}=i;return o&&((t,e,n=0)=>{let i,r,o,s;var{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,o,r),Hu(t.end,t.start,i)},bbox:$u,boundary:function(t,e,n,i){var r=i.selector,o=t.end,r="string"==typeof r?e.findNode(r):!1===r?n:Array.isArray(r)?pl(n,r):(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);if(!R.isSVGGraphicsElement(r)){if(r===n||!R.isSVGGraphicsElement(n))return o;r=n}var s,n=e.getNodeShape(r),a=e.getNodeMatrix(r),l=e.getRootTranslateMatrix(),h=e.getRootRotateMatrix(),h=(l=l.multiply(h).multiply(a)).inverse(),h=(a=R.transformLine(t,h)).start.clone(),e=e.getNodeData(r);return!1===i.insideout&&(e[Xu]||(e[Xu]=n.bbox()),e[Xu].containsPoint(h))?o:(n instanceof V&&(s=i.precision||2,e[Yu]||(e[Yu]=n.getSegmentSubdivisions({precision:s})),s={precision:s,segmentSubdivisions:e[Yu]}),!0===i.extrapolate&&a.setLength(1e6),(e=a.intersect(n,s))?R.isArray(e)&&(e=h.chooseClosest(e)):!0===i.sticky&&(e=n instanceof tt?n.pointNearestToPoint(h):n instanceof vi?n.intersectionWithLineFromCenterToPoint(h):n.closestPoint(h,s)),a=e?R.transformPoint(e,l):o,n=i.offset||0,i.stroke&&(n+=qu(r)/2),Hu(a,t.start,n))},rectangle:function(t,e,n,i){var r,o=e.model.angle();return 0===o?$u(t,e,n,i):(e=i.useModelGeometry?Wu(e,n,!1):e.getNodeUnrotatedBBox(n),i.stroke&&e.inflate(qu(n)/2),n=e.center(),Hu((e=(r=t.clone().rotate(n,o)).setLength(1e6).intersect(e))?r.start.chooseClosest(e).rotate(n,-o):t.end,t.start,i.offset))}}));let tc=Ju(!0),ec={__proto__:null,pinAbsolute:h,pinRelative:tc,useDefaults:Dl};var nc={N:"S",S:"N",E:"W",W:"E"},ic={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function rc(t,e,n){var i=new A(t.x,e.y);return i=n.containsPoint(i)?new A(e.x,t.y):i}function oc(t,e){return t["W"===e||"E"===e?"width":"height"]}function sc(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 ac(t){return new tt(t.x,t.y,0,0)}function lc(t){t=Ol(t.padding||t.elementPadding||20);return{x:-t.left,y:-t.top,width:t.left+t.right,height:t.top+t.bottom}}function hc(t,e){return t.sourceBBox.clone().moveAndExpand(lc(e))}function uc(t,e){return t.targetBBox.clone().moveAndExpand(lc(e))}function cc(t,e,n){var i=new A(t.x,e.y),r=new A(e.x,t.y),o=sc(t,i),t=sc(t,r),s=nc[n],o=o===n||o!==s&&(t===s||t!==n)?i:r;return{points:[o],direction:sc(o,e)}}function dc(t,e,n){t=rc(t,e,n);return{points:[t],direction:sc(t,e)}}function fc(t,e,n,i,r){var o={},n=n.union(i).inflate(1),i=n.center().distance(e)>n.center().distance(t),s=i?e:t,t=i?t:e,a=r?(a=A.fromPolar(n.width+n.height,ic[r],s),n.pointNearestToPoint(a).move(a,-1)):n.pointNearestToPoint(s).move(s,1),r=rc(a,t,n);return a.round().equals(r.round())?(r=A.fromPolar(n.width+n.height,Zn(a.theta(s))+Math.PI/2,t),s=rc(a,r=n.pointNearestToPoint(r).move(t,1).round(),n),o.points=i?[r,s,a]:[a,s,r]):o.points=i?[r,a]:[a,r],o.direction=sc(i?a:r,e),o}function pc(t,e,n){var i,r,o=hc(n,e),s=uc(n,e),a=(i=e,(a=n).sourceAnchor||hc(a,i).center()),n=(i=e,(n=n).targetAnchor||uc(n,i).center()),o=o.union(ac(a)),s=s.union(ac(n));(t=et(t).map(A)).unshift(a),t.push(n);for(var l,h,u,c,d,f,p=[],g=0,m=t.length-1;g<m;g++){var v,y=null,b=t[g],x=t[g+1],w=!!sc(b,x);0===g?g+1===m?o.intersect(s.clone().inflate(1))?y=fc(b,x,o,s):w||(h=o,f=d=c=void 0,d=dc(v=x,l=b,u=s),f=d.points[0],h.containsPoint(f)&&(c=(d=dc(l,v,h)).points[0],u.containsPoint(c))&&(c=new A(l).move(c,-oc(h,sc(l,c))/2),u=new A(v).move(f,-oc(u,sc(v,f))/2),u=cc(f=new P(c,u).midpoint(),v,(c=dc(l,f,h)).direction),d.points=[c.points[0],u.points[0]],d.direction=u.direction),y=d):o.containsPoint(x)?y=fc(b,x,o,ac(x).moveAndExpand(lc(e))):w||(y=dc(b,x,o)):g+1===m?(v=w&&sc(x,b)===r,s.containsPoint(b)||v?y=fc(b,x,ac(b).moveAndExpand(lc(e)),s,r):w||(y=((e,t,n,i)=>{var r,o={},s=[new A(e.x,t.y),new A(t.x,e.y)],a=s.filter(function(t){return!n.containsPoint(t)}),l=a.filter(function(t){return sc(t,e)!==i});return 0<l.length?(r=(r=l.filter(function(t){return sc(e,t)===i}).pop())||l[0],o.points=[r],o.direction=sc(r,t)):(r=la(s,a)[0],s=rc(l=new A(t).move(r,-oc(n,i)/2),e,n),o.points=[s,l],o.direction=sc(l,t)),o})(b,x,s,r))):w||(y=cc(b,x,r)),r=y?(Array.prototype.push.apply(p,y.points),y.direction):sc(b,x),g+1<m&&p.push(x)}return p}var gc={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(b(pc))return pc(t,T({},gc,e),n);throw new Error("Manhattan requires the orthogonal router as default fallback.")},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function mc(t){this.map={},this.options=t,this.mapGridSize=100}function vc(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function yc(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function bc(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function xc(t,e){return t.sourceAnchor||yc(t,e).center()}function wc(t,e,n,i,r){var o,n=360/n,i=t.theta((t=t,e=e,r=(r=r).step,o=e.x-t.x,e=e.y-t.y,o=o/i.x*r,e=e/i.y*r,new A(t.x+o,t.y+e))),r=Yn(i+n/2);return n*Math.floor(r/n)}function Ac(t,e){t=Math.abs(t-e);return 180<t?360-t:t}function Pc(t,e){var n;return t?(t=Math.abs(t),(n=Math.round(t/e))?e+(t-n*e)/n:t):e}function Ec(t,e){return t.round(e)}function Tc(t,e,n){return Ec((t=t.clone(),i=(e=e).source,r=Xn(t.x-i.x,e.x)+i.x,t=Xn(t.y-i.y,e.y)+i.y,new A(r,t)),n);var i,r}function Sc(t){return t.clone().toString()}function _c(t){return new A(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function Lc(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 kc(u,c,t,d,e){var f=e.precision,p=e.directionMap,g=u.difference(c.center()),e=w(p)?Object.keys(p):[],m=et(t),t=e.reduce(function(t,e){if(m.includes(e)){for(var n,e=p[e],i=new A(u.x+e.x*(Math.abs(g.x)+c.width),u.y+e.y*(Math.abs(g.y)+c.height)),r=new P(u,i).intersect(c)||[],o=r.length,s=null,a=0;a<o;a++){var l=r[a],h=u.squaredDistance(l);(void 0===n||n<h)&&(n=h,s=l)}s&&(i=Tc(s,d,f),c.containsPoint(i)&&(i=Tc(i.offset(e.x*d.x,e.y*d.y),d,f)),t.push(i))}return t},[]);return c.containsPoint(u)||t.push(Tc(u,d,f)),t}function Cc(t,e,n,i){var r,o,s,a,l,h,u,c=i.precision,d=t instanceof tt?Ec(xc(this,i).clone(),c):Ec(t.clone(),c),f=e instanceof tt?Ec((r=i,((f=this).targetAnchor||bc(f,r).center()).clone()),c):Ec(e.clone(),c),p=(r=i.step,h=f,{source:(o=d).clone(),x:Pc(h.x-o.x,r),y:Pc(h.y-o.y,r)}),g=t instanceof tt?kc(s=d,t,i.startDirections,p,i):[s=d],m=e instanceof tt?kc(a=f,e,i.endDirections,p,i):[a=f];if(g=g.filter(t=>!n(t)),m=m.filter(t=>!n(t)),0<g.length&&0<m.length){for(var v=new vc,y={},b={},x={},w=0,V=g.length;w<V;w++){var A=g[w],P=Sc(A);v.add(P,Lc(A,m)),y[P]=A,x[P]=0}for(var F=i.previousDirectionAngle,B=void 0===F,D=i.directions,E=(l=p,u=(h=i).step,et(h.directions).forEach(function(t){t.gridOffsetX=t.offsetX/u*l.x,t.gridOffsetY=t.offsetY/u*l.y}),D.length),z=et(m).reduce(function(t,e){e=Sc(e);return t.push(e),t},[]),j=i.maximumLoops;!v.isEmpty()&&0<j;){var T=v.pop(),S=y[T],_=b[T],G=x[T],L=void 0===_,U=S.equals(s),H=L?B?U?null:wc(s,S,E,p,i):F:wc(_,S,E,p,i),q=g.length===m.length;if(q)for(var k=0;k<g.length;k++)if(!g[k].equals(m[k])){q=!1;break}if(!(L&&q)&&0<=z.indexOf(T)){i.previousDirectionAngle=H;for(var $=b,W=y,_=S,L=s,T=a,Y=[],X=_c(T.difference(_)),C=Sc(_),M=$[C];M;){var Z,J=_c((Z=W[C]).difference(M));J.equals(X)||(Y.unshift(Z),X=J),M=$[C=Sc(M)]}return _c((T=W[C]).difference(L)).equals(X)||Y.unshift(T),Y}for(w=0;w<E;w++){var N,K=(N=D[w]).angle,Q=Ac(H,K);if(B&&U||!(Q>i.maxAllowedDirectionChange)){var O=Tc(S.clone().offset(N.gridOffsetX,N.gridOffsetY),p,c),R=Sc(O);if(!v.isClose(R)&&!n(O)){if(0<=z.indexOf(R)){var I=O.equals(a);if(!I)if(Ac(K,wc(O,a,E,p,i))>i.maxAllowedDirectionChange)continue}I=G+N.cost+(U?0:i.penalties[Q]);(!v.isOpen(R)||I<x[R])&&(y[R]=O,b[R]=S,v.add(R,(x[R]=I)+Lc(O,m)))}}}j--}}return i.fallbackRoute.call(this,s,a,i)}function Mc(t,n,i){(e=n).directions=S(e,"directions"),e.penalties=S(e,"penalties"),e.paddingBox=S(e,"paddingBox"),e.padding=S(e,"padding"),e.padding&&(r=Ol(e.padding),e.paddingBox={x:-r.left,y:-r.top,width:r.left+r.right,height:r.top+r.bottom}),et(e.directions).forEach(function(t){var e=new A(0,0),n=new A(t.offsetX,t.offsetY);t.angle=Yn(e.theta(n))}),i.options.perpendicular=!!n.perpendicular;var e,r,o=yc(i,n),s=bc(i,n),a=xc(i,n);let l;if("function"==typeof n.isPointObstacle)l=n.isPointObstacle;else{let e=new mc(n);e.build(i.paper.model,i.model),l=t=>!e.isPointAccessible(t)}for(var h=et(t).map(A),u=[],c=a,d=0,f=h.length;d<=f;d++){var p,g,m=null,v=p||o;if((p=h[d])||(p=s,i.model.get("source").id&&i.model.get("target").id)||!b(n.draggingRoute)||(y=v===o?a:v,g=p.origin(),m=n.draggingRoute.call(i,y,g,n)),null===(m=m||Cc.call(i,v,p,l,n)))return n.fallbackRouter(t,n,i);var y=m[0];y&&y.equals(c)&&m.shift(),c=m[m.length-1]||c,Array.prototype.push.apply(u,m)}return u}function Nc(t,e,n){return Mc(t,T({},gc,e),n)}mc.prototype.build=function(n,i){var c=this.options,d=et(c.excludeEnds).reduce(function(t,e){var e=i.get(e);return e&&(e=n.getCell(e.id))&&t.push(e),t},[]),f=[],t=n.getCell(i.get("source").id),t=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),n.getCell(i.get("target").id)),p=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),this.mapGridSize);return n.getElements().reduce(function(t,e){var n=et(c.excludeTypes).includes(e.get("type")),i=d.find(function(t){return t.id===e.id}),r=f.includes(e.id);if(!(n||i||r))for(var o=e.getBBox().moveAndExpand(c.paddingBox),s=o.origin().snapToGrid(p),a=o.corner().snapToGrid(p),l=s.x;l<=a.x;l+=p)for(var h=s.y;h<=a.y;h+=p){var u=l+"@"+h;t[u]=t[u]||[],t[u].push(o)}return t},this.map),this},mc.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return et(this.map[t]).every(function(t){return!t.containsPoint(e)})},vc.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;e=Js(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(e,0,t)},vc.prototype.remove=function(t){this.hash[t]=this.CLOSE},vc.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},vc.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},vc.prototype.isEmpty=function(){return 0===this.items.length},vc.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};var Oc={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},a=(90<i%180&&(a=o,o=s,s=a),i%90<45?o:s),o=new P(t,a),s=90*Math.ceil(i/90),i=A.fromPolar(o.squaredLength(),Zn(135+s),a),s=new P(e,i),a=o.intersection(s),i=a||e,o=a?i:t,s=360/n.directions.length,a=o.theta(e),t=Yn(a+s/2),o=s*Math.floor(t/s);return n.previousDirectionAngle=o,i&&r.push(i.round()),r.push(e),r}};let B={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Rc=[B.LEFT,B.RIGHT,B.TOP,B.BOTTOM],Ic={[B.LEFT]:B.RIGHT,[B.RIGHT]:B.LEFT,[B.TOP]:B.BOTTOM,[B.BOTTOM]:B.TOP},Vc=[B.TOP,B.BOTTOM],Fc={0:B.RIGHT,180:B.LEFT,270:B.TOP,90:B.BOTTOM};function Bc(t){return t.angle()}function Dc(t){return new x(t).simplify({threshold:1}).points}function zc(t,e){var{point:t,x0:n,y0:i,view:r,bbox:o,direction:s}=t,{point:e,x0:a,y0:l,view:h,bbox:u,direction:c}=e;let d;d=r?r.model.isLink()?Gc(e,t,r):s===B.ANCHOR_SIDE?o.sideNearestToPoint(t):s===B.MAGNET_SIDE?r.model.getBBox().sideNearestToPoint(t):s:(o=new tt(n,i,0,0),Rc.includes(s)?s:o.sideNearestToPoint(e));let f;return f=h?h.model.isLink()?Gc(t,e,h):c===B.ANCHOR_SIDE?u.sideNearestToPoint(e):c===B.MAGNET_SIDE?h.model.getBBox().sideNearestToPoint(e):c:(r=new tt(a,l,0,0),Rc.includes(c)?c:r.sideNearestToPoint(t)),[d,f]}function jc(t,e,n){var[i]=zc(t,e);switch(i){case B.TOP:var r=e,o=n,{x0:s,y0:a,width:l,height:h,point:u,margin:c}=s=t,h=a+h,d=s-c,s=s+l+c,l=a-c,c=u.x,{x0:u,y0:r}=r;return u===c&&r<a?B.BOTTOM:u<c&&r<l?o.point.x===c?B.BOTTOM:B.RIGHT:c<u&&r<l?o.point.x===c?B.BOTTOM:B.LEFT:u<d&&l<r||s<u&&l<r?B.TOP:d<=u&&u<=c&&h<r||u<=s&&c<=u&&h<r?o.point.x<u?B.RIGHT:B.LEFT:B.BOTTOM;case B.RIGHT:var a=e,l=n,{y0:d,x0:s,width:c,height:h,point:r,margin:o}=d=t,c=s+c+o,u=d-o,d=d+h+o,{x:h,y:o}=r,{x0:r,y0:a}=a;return h<r&&a===o?B.LEFT:c<=r&&a<o?B.BOTTOM:c<=r&&o<a?B.TOP:r<=c&&a<u||r<=c&&d<a?B.RIGHT:r<s&&u<=a&&a<=o||r<s&&a<=d&&o<=a?l.point.y<a?B.BOTTOM:B.TOP:B.LEFT;case B.BOTTOM:var f=e,p=n,{x0:g,y0:m,width:v,height:y,point:b,margin:x}=g=t,w=g-x,g=g+v+x,v=(y=m+y)+x,x=b.x,{x0:b,y0:f}=f;return b===x&&y<f?B.TOP:b<x&&v<f?p.point.x===x?B.TOP:B.RIGHT:x<b&&v<f?p.point.x===x?B.TOP:B.LEFT:b<w&&f<v||g<b&&f<v?B.BOTTOM:w<=b&&b<=x&&f<m||b<=g&&x<=b&&f<m?p.point.x<b?B.RIGHT:B.LEFT:B.TOP;case B.LEFT:var y=e,v=n,{y0:w,x0:g,width:x,height:f,point:m,margin:p}=w=t,x=g+x,g=g-p,b=w-p,w=w+f+p,{x:f,y:p}=m,{x0:m,y0:y}=y;return m<f&&y===p?B.RIGHT:m<=g&&y<p?B.BOTTOM:m<=g&&p<y?B.TOP:g<=m&&y<b||g<=m&&w<y?B.LEFT:x<m&&b<=y&&y<=p||x<m&&y<=w&&p<=y?v.point.y<y?B.BOTTOM:B.TOP:B.RIGHT}}function Gc(t,e,n){n=n.getTangentAtLength(n.getClosestPointLength(e)),n=90*Math.round(Bc(n)/90);if(n%180==0&&t.y===e.y)return t.x<e.x?B.LEFT:B.RIGHT;if(t.x===e.x)return t.y<e.y?B.TOP:B.BOTTOM;switch(n){case 0:case 180:case 360:return t.y<e.y?B.TOP:B.BOTTOM;case 90:case 270:return t.x<e.x?B.LEFT:B.RIGHT}}function Uc(t,e,n,i,r,o,s){i===B.AUTO&&(i=r?B.MAGNET_SIDE:B.ANCHOR_SIDE);var r=t&&t.model.isElement(),{x:o,y:a,width:l=0,height:h=0}=r?tt.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:o,y0:a,view:t,bbox:n,width:l,height:h,direction:i,margin:r?s:0}}function Hc(t,e,n){var 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 qc(t,e,{dx:n=0,dy:i=0}){var r={x:t.point.x+n,y:t.point.y+i},n={x:e.point.x+n,y:e.point.y+i};return[t.point,r,n,e.point]}function $c(t,e,n,i){n=Yn(n-90);let r=0,o=0;90===n?o=-i:180===n?r=-i:270===n?o=i:0===n&&(r=i);n=qc(t,e,{dx:r,dy:o}),i=n[2],t=new P(e.point,i);return{loopRoute:n,continueDirection:Fc[Bc(t)]}}function Wc(t,e,n){switch(e){case B.LEFT:t.inflate(0,n).moveAndExpand({x:-n,width:n});break;case B.RIGHT:t.inflate(0,n).moveAndExpand({width:n});break;case B.TOP:t.inflate(n,0).moveAndExpand({y:-n,height:n});break;case B.BOTTOM:t.inflate(n,0).moveAndExpand({height:n})}return t}function Yc(i,r,e={}){var{point:o,x0:s,y0:a,width:l,height:n,margin:t}=i,{point:V,x0:h,y0:u,width:c,height:d,margin:f}=r,{targetInSourceBBox:e=!1}=e,p=h+c,g=u+d,m=s+l,v=a+n,y=s-t,b=m+t,x=a-t,w=v+t,A=h-f,P=p+f,E=u-f,T=g+f,[S,_]=zc(i,r),o=Hc(S,{point:o,x0:s,y0:a,width:l,height:n},t),L=Hc(_,{point:V,x0:h,y0:u,width:c,height:d},f),{x:k,y:C}=o,{x:M,y:N}=L,O=((s+m)/2<(h+p)/2?m+h:p+s)/2,F=((a+v)/2<(u+g)/2?v+u:g+a)/2,l=new tt(s,a,l,n),n=new tt(h,u,c,d),c=l.clone().inflate(t),d=n.clone().inflate(f),l=Object.assign({},i,{x1:m,y1:v,outsidePoint:o,direction:S}),f=Object.assign({},r,{x1:p,y1:g,outsidePoint:L,direction:_}),[i,r]=((t,e)=>{var{x0:n,x1:i,outsidePoint:r}=t,{x0:o,x1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.y0<e.y0?t:e)===t?e:t,i=t.direction===B.TOP?n:o,l=i.x0,h=i.x1),s=r.x,e=a.x,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f),[l,f]=((t,e)=>{var{y0:n,y1:i,outsidePoint:r}=t,{y0:o,y1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.x0<e.x0?t:e)===t?e:t,i=t.direction===B.LEFT?n:o,l=i.y0,h=i.y1),s=r.y,e=a.y,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f);if("left"===S&&"right"===_){var R=c.containsPoint(L),I=d.containsPoint(o);if(R||I)return[{x:k,y:C},{x:k,y:R=(C+N)/2},{x:M,y:R},{x:M,y:N}];if(y<M){let t=F,e=k,n=M;var I=l<f;return(t>=x&&t<=w||t>=E&&t<=T)&&(E<=w&&I?t=Math.min(E,x):x<=T&&!I&&(t=Math.max(T,w)),e=Math.min(k,A),n=Math.max(M,b),I&&C<u||!I&&g<C?e=k:(I&&N<a||!I&&v<N)&&(n=M)),[{x:e,y:C},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var R=(k+M)/2;return[{x:R,y:C},{x:R,y:N}]}if("right"===S&&"left"===_){var I=c.containsPoint(L),R=d.containsPoint(o);if(I||R)return[{x:k,y:C},{x:k,y:I=(C+N)/2},{x:M,y:I},{x:M,y:N}];if(M<b){let t=F,e=k,n=M;var R=l<f;return(t>=x&&t<=w||t>=E&&t<=T)&&(E<=w&&R?t=Math.min(E,x):x<=T&&!R&&(t=Math.max(T,w)),e=Math.max(k,P),n=Math.min(M,y),R&&C<u||!R&&g<C?e=k:(R&&N<a||!R&&v<N)&&(n=M)),[{x:e,y:C},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var I=(k+M)/2;return[{x:I,y:C},{x:I,y:N}]}if("top"===S&&"bottom"===_){var R=c.containsPoint(L),I=d.containsPoint(o);if(R||I)return[{x:k,y:C},{x:R=(k+M)/2,y:C},{x:R,y:N},{x:M,y:N}];if(x<N){let t=O,e=C,n=N;I=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&I?t=Math.min(A,y):y<=P&&!I&&(t=Math.max(P,b)),e=Math.min(C,E),n=Math.max(N,w),I&&k<h||!I&&p<k?e=C:(I&&M<s||!I&&m<M)&&(n=N)),[{x:k,y:e},{x:t,y:e},{x:t,y:n},{x:M,y:n}]}R=(C+N)/2;return[{x:k,y:R},{x:M,y:R}]}if("bottom"===S&&"top"===_){I=c.containsPoint(L),R=d.containsPoint(o);if(I||R)return[{x:k,y:C},{x:L=(k+M)/2,y:C},{x:L,y:N},{x:M,y:N}];if(N<w){let t=O,e=C,n=N;var o=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&o?t=Math.min(A,y):y<=P&&!o&&(t=Math.max(P,b)),e=Math.max(C,T),n=Math.min(N,x),o&&k<h||!o&&p<k?e=C:(o&&M<s||!o&&m<M)&&(n=N)),[{x:k,y:e},{x:t,y:e},{x:t,y:n},{x:M,y:n}]}I=(C+N)/2;return[{x:k,y:I},{x:M,y:I}]}if("top"===S&&"top"===_){if((e||vr.rectWithRect(c,n)||C<=u&&(c.bottomRight().x<=M||c.bottomLeft().x>=M)||u<=C&&(d.bottomRight().x<=k||d.bottomLeft().x>=k))&&k!==M)return[{x:k,y:Math.min(C,N)},{x:M,y:Math.min(C,N)}];let t;var R=Math.min((v+u)/2,N),L=Math.min((a+g)/2,C);return[{x:k,y:L},{x:t=N<C?i<r?Math.min(k,A):Math.max(k,P):i<r?Math.min(M,y):Math.max(M,b),y:L},{x:t,y:R},{x:M,y:R}]}if("bottom"===S&&"bottom"===_){if((e||vr.rectWithRect(c,n)||N<=C&&(c.topRight().x<=M||c.topLeft().x>=M)||C<=N&&(d.topRight().x<=k||d.topLeft().x>=k))&&k!==M)return[{x:k,y:Math.max(C,N)},{x:M,y:Math.max(C,N)}];let t;o=Math.max((a+g)/2,N),I=Math.max((v+u)/2,C);return[{x:k,y:I},{x:t=C<N?i<r?Math.min(k,A):Math.max(k,P):i<r?Math.min(M,y):Math.max(M,b),y:I},{x:t,y:o},{x:M,y:o}]}if("left"===S&&"left"===_){if((e||vr.rectWithRect(c,n)||k<=M&&(c.bottomRight().y<=N||c.topRight().y>=N)||M<=k&&(d.bottomRight().y<=C||d.topRight().y>=C))&&C!==N)return[{x:Math.min(k,M),y:C},{x:Math.min(k,M),y:N}];let t;L=Math.min((m+h)/2,M),R=Math.min((s+p)/2,k);return[{x:R,y:C},{x:R,y:t=k<M?l<=f?Math.min(x,N):Math.max(w,N):l<=f?Math.min(E,C):Math.max(T,C)},{x:L,y:t},{x:L,y:N}]}if("right"===S&&"right"===_){if((e||vr.rectWithRect(c,n)||M<=k&&(c.bottomLeft().y<=N||c.topLeft().y>=N)||k<=M&&(d.bottomLeft().y<=C||d.topLeft().y>=C))&&C!==N)return[{x:Math.max(k,M),y:C},{x:Math.max(k,M),y:N}];let t;var i=Math.max((s+p)/2,M),r=Math.max((m+h)/2,k);return[{x:r,y:C},{x:r,y:t=M<=k?l<=f?Math.min(x,N):Math.max(w,N):l<=f?Math.min(E,C):Math.max(T,C)},{x:i,y:t},{x:i,y:N}]}if("top"===S&&"right"===_){if(c.containsPoint(V))return k<=P?(I=Math.max(k+t,M),[{x:k,y:o=Math.min(x,E)},{x:I,y:o},{x:I,y:N}]):[{x:k,y:C},{x:R=(k-t+M)/2,y:C},{x:R,y:N}];if(N<x){if(k<M){let t=T<=x&&k<=P?F:E;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}L=Math.max(O,P);return M<k&&N<=v?[{x:k,y:C},{x:L,y:C},{x:L,y:N}]:y<L&&C<g?[{x:k,y:e=Math.min(x,E)},{x:n=Math.max(b,P),y:e},{x:n,y:N}]:[{x:k,y:C},{x:L,y:C},{x:L,y:N}]}if("top"===S&&"left"===_){if(c.containsPoint(V))return A<=k?(d=Math.min(k-t,M),[{x:k,y:r=Math.min(x,E)},{x:d,y:r},{x:d,y:N}]):[{x:k,y:C},{x:l=(k+t+M)/2,y:C},{x:l,y:N}];if(N<x){if(M<k){let t=T<=x&&A<=k?F:E;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}f=Math.min(A,O);return k<M&&N<=v?[{x:k,y:C},{x:f,y:C},{x:f,y:N}]:f<b&&C<g?[{x:k,y:i=Math.min(x,E)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:k,y:C},{x:f,y:C},{x:f,y:N}]}if("bottom"===S&&"right"===_){if(c.containsPoint(V))return k<=P?(I=Math.max(k+t,M),[{x:k,y:R=Math.max(w,T)},{x:I,y:R},{x:I,y:N}]):[{x:k,y:C},{x:e=(k-t+M)/2,y:C},{x:e,y:N}];if(w<N){if(k<M){let t=w<=E&&k<=P?F:T;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}n=Math.max(O,P);return M<k&&a<=N?[{x:k,y:C},{x:n,y:C},{x:n,y:N}]:y<n&&u<C?[{x:k,y:L=Math.max(w,T)},{x:r=Math.max(b,P),y:L},{x:r,y:N}]:[{x:k,y:C},{x:n,y:C},{x:n,y:N}]}if("bottom"===S&&"left"===_){if(c.containsPoint(V))return A<=k?(d=Math.min(k-t,M),[{x:k,y:l=Math.max(w,T)},{x:d,y:l},{x:d,y:N}]):[{x:k,y:C},{x:v=(k+t+M)/2,y:C},{x:v,y:N}];if(w<N){if(M<k){let t=w<=E&&A<=k?F:T;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}var g=Math.min(A,O);return k<M&&a<=N?[{x:k,y:C},{x:g,y:C},{x:g,y:N}]:g<b&&u<C?[{x:k,y:i=Math.max(w,T)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:k,y:C},{x:g,y:C},{x:g,y:N}]}if("left"===S&&"bottom"===_){if(c.containsPoint(V))return C<=T?[{x:f=Math.min(y,A),y:C},{x:f,y:R=Math.max(C+t,N)},{x:M,y:R}]:[{x:k,y:C},{x:k,y:I=(C-t+N)/2},{x:M,y:I}];if(M<y){if(C<N){let t=P<=y&&C<=T?O:A;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}e=Math.max(T,F);return N<C&&M<=m?[{x:k,y:C},{x:k,y:e},{x:M,y:e}]:x<e&&k<p?[{x:L=Math.min(y,A),y:C},{x:L,y:r=Math.max(w,T)},{x:M,y:r}]:[{x:k,y:C},{x:k,y:e},{x:M,y:e}]}if("left"===S&&"top"===_){if(c.containsPoint(V))return E<=C?(n=Math.min(C-t,N),[{x:l=Math.min(y,A),y:C},{x:l,y:n},{x:M,y:n}]):[{x:k,y:C},{x:k,y:d=(C+t+N)/2},{x:M,y:d}];if(M<y){if(N<C){let t=P<=y&&E<=C?O:A;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}v=Math.min(E,F);return C<N&&M<=m?[{x:k,y:C},{x:k,y:v},{x:M,y:v}]:v<w&&k<p?[{x:a=Math.min(y,A),y:C},{x:a,y:u=Math.min(x,E)},{x:M,y:u}]:[{x:k,y:C},{x:k,y:v},{x:M,y:v}]}if("right"===S&&"top"===_){if(c.containsPoint(V))return E<=C?[{x:i=Math.max(b,P),y:C},{x:i,y:o=Math.min(C-t,N)},{x:M,y:o}]:[{x:k,y:C},{x:k,y:g=(C+t+N)/2},{x:M,y:g}];if(b<M){if(N<C){let t=b<=A&&E<=C?O:P;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}f=Math.min(E,F);return C<N&&s<=M?[{x:k,y:C},{x:k,y:f},{x:M,y:f}]:f<w&&h<k?[{x:R=Math.max(b,P),y:C},{x:R,y:I=Math.min(x,E)},{x:M,y:I}]:[{x:k,y:C},{x:k,y:f},{x:M,y:f}]}if("right"===S&&"bottom"===_){if(c.containsPoint(V))return C<=T?[{x:L=Math.max(b,P),y:C},{x:L,y:r=Math.max(C+t,N)},{x:M,y:r}]:[{x:k,y:C},{x:k,y:e=(C-t+N)/2},{x:M,y:e}];if(b<M){if(C<N){let t=b<=A&&C<=T?O:P;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}l=Math.max(T,F);return N<C&&s<=M?[{x:k,y:C},{x:k,y:l},{x:M,y:l}]:x<l&&h<k?[{x:n=Math.max(b,P),y:C},{x:n,y:d=Math.max(w,T)},{x:M,y:d}]:[{x:k,y:C},{x:k,y:l},{x:M,y:l}]}}function Xc(t,e,n){var i=t===B.LEFT||t===B.RIGHT;let r=0,o=0;switch(Yn(Math.round(e))){case 0:case 90:r=i?0:n,o=i?n:0;break;case 180:case 270:r=i?0:-n,o=i?-n:0}return{dx:r,dy:o}}function Zc(n,i,r){var{sourceDirection:o=B.AUTO,targetDirection:s=B.AUTO}=i,a=i.margin||20,i=i.useVertices||!1,l=!!r.model.source().port,o=Uc(r.sourceView,r.sourceAnchor,r.sourceBBox,o,l,r.sourceAnchor,a),l=!!r.model.target().port,s=Uc(r.targetView,r.targetAnchor,r.targetBBox,s,l,r.targetAnchor,a),h=[];if(!i||0===n.length)return Dc(Yc(o,s));var e=n.map(t=>{return{x:t,y:e}=[t][0],{point:n=new A(t,e),x0:n.x,y0:n.y,view:null,bbox:new tt(t,e,0,0),width:0,height:0,direction:null,margin:0};var e,n}),[l]=e,[r]=zc(o,l),i=o.view&&o.view.model.isElement(),n=i?Wc(o.view.model.getBBox(),r,a):null;let t=!!i&&n.containsPoint(l.point);t?(n=(i=Hc(r,o,a)).equals(l.point),y=o.point.x===l.point.x,v=o.point.y===l.point.y,y=y&&(r===B.TOP||r===B.BOTTOM),v=v&&(r===B.LEFT||r===B.RIGHT),g=(m=new P(o.point,i)).containsPoint(l.point),v=t&&(v||y),n?(h.push(o.point,l.point),l.direction=Ic[r]):g||v?({dx:y,dy:n}=Xc(r,Bc(g?m:new P(o.point,l.point)),a),g=(v=qc({point:i},l,{dx:y,dy:n}))[2],m=new P(l.point,g),i=Fc[Bc(m)],l.direction=i,h.push(...v)):(l.direction=r,l.margin=a,h.push(...Yc(o,l,{targetInSourceBBox:!0}),l.point))):(y=jc(o,l,e[1]||s),l.direction=y,h.push(...Yc(o,l),l.point));for(let t=0;t<e.length-1;t++){var u,c,d=e[t],f=e[t+1],p=Bc(new P(d.point,f.point));p%90==0?(c=Fc[p],u=Dc([...h,d.point]),u=new P(u[u.length-2],u[u.length-1]),u=Fc[Math.round(Bc(u))],c!==Ic[u]?(h.push(d.point,f.point),[,c]=zc(d,f),f.direction=c):({loopRoute:u,continueDirection:c}=$c(d,f,p,a),f.direction=c,h.push(...u))):([p,c]=Jc(d,f),d.direction=p,f.direction=c,h.push(...Yc(d,f),f.point))}n=e[e.length-1];if(s.view&&s.view.model.isElement()){var[,g]=zc(n,s),m=Hc(g,s,a),i=Dc([...h,n.point]),v=new P(i[i.length-2],i[i.length-1]),r=Math.round(Bc(v)),y=Fc[r],o=m.equals(n.point);if(!o||y===g){n.direction=y;let t=Yc(n,s);var[l,i]=Dc([...t,s.point]),v=new P(l,i),l=Math.round(Bc(v)),i=Fc[l],v=Wc(s.view.model.getBBox(),g,a),l=n.point.x===s.point.x,b=n.point.y===s.point.y;let e=v.containsPoint(n.point);v=l&&(g===B.TOP||g===B.BOTTOM),l=b&&(g===B.LEFT||g===B.RIGHT);!o&&e&&(l||v)?({dx:b,dy:o}=Xc(g,r,a),t=qc(n,{point:m},{dx:b,dy:o})):e&&g!==Ic[y]?(n.margin=a,n.direction=g,t=Yc(n,s)):i!==y&&y===Ic[i]&&(n.margin=a,t=Yc(n,s)),h.push(...t)}}else{l=n,v=s,r=Bc(new P(l.point,v.point));r%90==0?(m=Fc[r],b=Dc(h),o=new P(b[b.length-2],l.point),g=Fc[Math.round(Bc(o))],m!==Ic[g]?h.push(l.point):(y=$c(l,v,r,a).loopRoute,y.pop(),h.push(...y))):([i,n]=Jc(l,v),l.direction=i,v.direction=n,h.push(...Yc(l,v)))}return Dc(h)}function Jc(t,e){var n,i=t.direction,r=Vc.includes(i);let o=t.direction,s=e.direction;return r?(r=t.point.y>e.point.y,n=e.point.x-t.point.x,i===B.BOTTOM?(o=r?Ic[i]:0<=n?B.RIGHT:B.LEFT,0<n?s=r?B.LEFT:B.TOP:n<0&&(s=r?B.RIGHT:B.TOP)):(o=r?0<=n?B.RIGHT:B.LEFT:Ic[i],0<n?s=r?B.BOTTOM:B.LEFT:n<0&&(s=r?B.BOTTOM:B.RIGHT))):(n=t.point.x>e.point.x,r=e.point.y-t.point.y,i===B.RIGHT?(o=n?Ic[i]:0<=r?B.BOTTOM:B.TOP,0<r?s=n?B.TOP:B.LEFT:r<0&&(s=n?B.BOTTOM:B.LEFT)):(o=n?0<=r?B.BOTTOM:B.TOP:Ic[i],0<r?s=n?B.RIGHT:B.TOP:r<0&&(s=n?B.RIGHT:B.BOTTOM))),[o,s]}Zc.Directions=B;var Kc={__proto__:null,manhattan:Nc,metro:function(t,e,n){if(b(Nc))return Nc(t,T({},Oc,e),n);throw new Error("Metro requires the manhattan router.")},normal:function(t,e,n){return t},oneSide:function(t,e,n){var i,r,o,s=e.side||"bottom",e=Ol(e.padding||40),a=n.sourceBBox,n=n.targetBBox,l=a.center(),h=n.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 l[i]+=o*(a[r]/2+e[s]),h[i]+=o*(n[r]/2+e[s]),0<o*(l[i]-h[i])?h[i]=l[i]:l[i]=h[i],[l].concat(t,h)},orthogonal:pc,rightAngle:Zc};function Qc(a){return function(t,e,n,i,r,o){var s;return n instanceof Element?(s=(s=this.paper.findView(n))?s.isNodeConnection(n)?td(s,"fixedAt"in i?i.fixedAt:"50%"):s.getNodeBBox(n).center():new A,a.call(this,t,e,s,i,r,o)):a.apply(this,arguments)}}function td(t,e){var n=parseFloat(e);return Sl(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}C=Qc(function(t,e,n,i){var r=t.getConnection(),o=t.getConnectionSubdivisions(),s=new P(n.clone().offset(0,1e6),n.clone().offset(0,-1e6)),a=new P(n.clone().offset(1e6,0),n.clone().offset(-1e6,0)),s=s.intersect(r,{segmentSubdivisions:o}),a=a.intersect(r,{segmentSubdivisions:o}),r=[];return s&&Array.prototype.push.apply(r,s),a&&Array.prototype.push.apply(r,a),0<r.length?n.chooseClosest(r):"fallbackAt"in i?td(t,i.fallbackAt):ed(t,e,n,i)});let ed=Qc(function(t,e,n,i){return(t=t.getClosestPoint(n))||new A}),nd={__proto__:null,connectionClosest:ed,connectionLength:function(t,e,n,i){return i="length"in i?i.length:20,t.getPointAtLength(i)},connectionPerpendicular:C,connectionRatio:function(t,e,n,i){return i="ratio"in i?i.ratio:.5,t.getPointAtRatio(i)},resolveRef:Qc},id={LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom"},rd={PREFER_HORIZONTAL:"prefer-horizontal",PREFER_VERTICAL:"prefer-vertical",HORIZONTAL:"horizontal",VERTICAL:"vertical",AUTO:"auto"};function od(t,e,n,i){e=e.get(n).port;return t.hasPort(e)?t.getPortBBox(e,{rotate:i}):t.getBBox({rotate:i})}function sd(f){return function(t,e,n,i,r,o){var s=!!i.rotate,a=t.model,o=o.model,l=a.angle();let h,u;i.useModelGeometry?(h=od(a,o,r,!s),u=h.center()):(u=a.getCenter(),h=s?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e));o=h[f]();let c=i.dx,d=(c&&(r=Sl(c),c=!r&&ph(c)?Number(vh(c,h)):parseFloat(c),isFinite(c))&&(r&&(c=(c/=100)*h.width),o.x+=c),i.dy);return d&&(a=Sl(d),d=!a&&ph(d)?Number(vh(d,h)):parseFloat(d),isFinite(d))&&(a&&(d=(d/=100)*h.height),o.y+=d),s?o.rotate(u,-l):o}}n=sd("center"),a=sd("topMiddle"),l=sd("bottomMiddle"),s=sd("leftMiddle"),o=sd("rightMiddle"),u=sd("origin"),i=sd("topRight"),r=Qc(function(t,e,n,i,r,o){var s=t.model,a=s.angle();let l,h=(s=(l=i.useModelGeometry?od(s,o.model,r,!0):t.getNodeBBox(e)).center(),o=l.origin(),r=l.corner(),i.padding),u,c;return isFinite(h)||(h=0),o.y+h<=n.y&&n.y<=r.y-h?(u=n.y-s.y,s.x+=0===a||180===a?0:u/Math.tan(Zn(a)),s.y+=u):o.x+h<=n.x&&n.x<=r.x-h&&(c=n.x-s.x,s.y+=90===a||270===a?0:c*Math.tan(Zn(a)),s.x+=c),s}),h={__proto__:null,bottom:l,bottomLeft:sd("bottomLeft"),bottomRight:sd("corner"),center:n,left:s,midSide:Qc(function(t,e,n,i,r,o){var s,a,l=!!i.rotate,h=t.model.angle(),u=t.model.getCenter(),o=(i.useModelGeometry?u=(s=od(t.model,o.model,r,!l)).center():s=l?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),i.padding);switch(isFinite(o)&&s.inflate(o),l&&n.rotate(u,h),((t,e,n)=>{var{preferenceThreshold:i=0,mode:n}=n,{x:r,y:o}=e,{x:s,y:a,width:l,height:h}=t;switch(n){case rd.PREFER_VERTICAL:var{top:u,bottom:c}=Ol(i);if(a-u<o&&o<a+h+c)return r<s+l/2?id.LEFT:id.RIGHT;case rd.VERTICAL:return o<a+h/2?id.TOP:id.BOTTOM;case rd.PREFER_HORIZONTAL:var{left:u,right:c}=Ol(i);if(s-u<r&&r<s+l+c)return o<a+h/2?id.TOP:id.BOTTOM;case rd.HORIZONTAL:return r<s+l/2?id.LEFT:id.RIGHT;default:rd.AUTO;return t.sideNearestToPoint(e)}})(s,n,i)){case id.LEFT:a=s.leftMiddle();break;case id.RIGHT:a=s.rightMiddle();break;case id.TOP:a=s.topMiddle();break;case id.BOTTOM:a=s.bottomMiddle()}return l?a.rotate(u,-h):a}),modelCenter:function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)},perpendicular:r,right:o,top:a,topLeft:u,topRight:i};let ad=Cu.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace=void 0!==joint&&ua(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var n=e.collection.cellNamespace,i=t.type,n=pl(n,i,".");if(n)return new n(t,e);throw new Error(`dia.Graph: Could not find cell constructor for type: '${i}'. Make sure to add the constructor to 'cellNamespace'.`)},_addReference:function(t,e){Cu.prototype._addReference.apply(this,arguments),e.dry||t.graph||(t.graph=this.graph)},_removeReference:function(t,e){Cu.prototype._removeReference.apply(this,arguments),e.dry||t.graph!==this.graph||(t.graph=null)},comparator:function(t){return t.get("z")||0}}),ld=Gl.extend({initialize:function(t,e){e=e||{};e=new ad([],{model:e.cellModel,cellNamespace:e.cellNamespace,graph:this});Gl.prototype.set.call(this,"cells",e),e.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},e.on("add",this._restructureOnAdd,this),e.on("remove",this._restructureOnRemove,this),e.on("reset",this._restructureOnReset,this),e.on("change:source",this._restructureOnChangeSource,this),e.on("change:target",this._restructureOnChangeTarget,this),e.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){var e,n;t.isLink()?(this._edges[t.id]=!0,{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)):this._nodes[t.id]=!0},_restructureOnRemove:function(t){var e,n;t.isLink()?(delete this._edges[t.id],{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]):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=(e.id&&this._out[e.id]&&delete this._out[e.id][t.id],t.attributes.source);e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target"),e=(e.id&&this._in[e.id]&&delete this._in[e.id][t.id],t.get("target"));e.id&&((this._in[e.id]||(this._in[e.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(t={}){var e=Gl.prototype.toJSON.apply(this,arguments);return e.cells=this.get("cells").toJSON(t.cellAttributes),e},fromJSON:function(t,e){if(t.cells)return this.set(t,e);throw new Error("Graph JSON must contain cells array.")},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=ca(i,"cells")),Gl.prototype.set.call(this,i,n)},clear:function(t){t=T({},t,{clear:!0});var e=this.get("cells");if(0!==e.length){this.startBatch("clear",t);for(var n=e.sortBy(function(t){return t.isLink()?1:2});n.shift().remove(t),0<n.length;);this.stopBatch("clear")}return this},_prepareCell:function(t){let e;if(e=t instanceof Gl?t.attributes:t,E(e.type))return t;throw new TypeError("dia.Graph: cell type must be a string.")},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 Gl?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=sa(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){t=et(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(t,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),Xs(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})},transferCellEmbeds:function(t,e,n={}){var i="transfer-embeds",t=(this.startBatch(i),t.getEmbeddedCells());e.embed(t,{...n,reparent:!0}),this.stopBatch(i)},transferCellConnectedLinks:function(e,n,i={}){var t="transfer-connected-links";this.startBatch(t),this.getConnectedLinks(e,i).forEach(t=>{t.getSourceCell()===e&&t.prop(["source","id"],n.id,i),t.getTargetCell()===e&&t.prop(["target","id"],n.id,i)}),this.stopBatch(t)},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,r){var o,s=(r=r||{}).indirect,a=r.inbound,l=r.outbound,h=(void 0===a&&void 0===l&&(a=l=!0),[]),u={};function c(i,t){fa(i.getOutboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getTargetCell())&&t.isLink()&&(u[t.id]||(h.push(t),c(i,t)))}function d(i,t){fa(i.getInboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getSourceCell())&&t.isLink()&&(u[t.id]||(h.push(t),d(i,t)))}return l&&c(this,t),a&&d(this,t),r.deep&&(t=t.getEmbeddedCells({deep:!0}),o={},t.forEach(function(t){t.isElement()&&(o[t.id]=!0)}),t.forEach(function(t){t.isLink()||(l&&fa(this.getOutboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)),a&&fa(this.getInboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)))},this)),h},getNeighbors:function(o,s){var t,a=(s=s||{}).inbound,l=s.outbound,e=(void 0===a&&void 0===l&&(a=l=!0),this.getConnectedLinks(o,s).reduce(function(t,e){var n,{source:i,target:r}=e.attributes,e=e.hasLoop(s);return a&&ua(i,"id")&&!t[i.id]&&(n=this.getCell(i.id)).isElement()&&(e||!(!n||n===o||s.deep&&n.isEmbeddedIn(o)))&&(t[i.id]=n),l&&ua(r,"id")&&!t[r.id]&&(i=this.getCell(r.id)).isElement()&&(e||!(!i||i===o||s.deep&&i.isEmbeddedIn(o)))&&(t[r.id]=i),t}.bind(this),{}));return o.isLink()&&(a&&(t=o.getSourceCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),l)&&(t=o.getTargetCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),et(e)},getCommonAncestor:function(){var t=(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)).sort(function(t,e){return t.length-e.length}),e=et(t.shift()).find(function(e){return t.every(function(t){return t.includes(e)})});return this.getCell(e)},getSuccessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},T({},t,{outbound:!0})),n},cloneCells:oh,cloneSubgraph:function(t,e){t=this.getSubgraph(t,e);return this.cloneCells(t)},getSubgraph:function(t,e){e=e||{};var i=[],r={},n=[],o=[];return et(t).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t))})}),o.forEach(function(t){var{source:t,target:e}=t.attributes;t.id&&!r[t.id]&&(t=this.getCell(t.id),i.push(t),r[t.id]=t,n.push(t)),e.id&&!r[e.id]&&(t=this.getCell(e.id),i.push(this.getCell(e.id)),r[t.id]=t,n.push(t))},this),n.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var{source:e,target:n}=t.attributes;!r[t.id]&&e.id&&r[e.id]&&n.id&&r[n.id]&&(i.push(t),r[t.id]=t)})},this),i},getPredecessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},T({},t,{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={}){var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.shift();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n);for(let t=0,e=a.length;t<e;t++){var l=a[t];r[l.id]=r[s.id]+1,o.push(l)}}}},dfs:function(t,e,n={}){var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.pop();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n),l=o.length;for(let t=0,e=a.length;t<e;t++){var h=a[t];r[h.id]=r[s.id]+1,o.splice(l,0,h)}}}},getSources:function(){var n=[];return fa(this._nodes,function(t,e){this._in[e]&&!ea(this._in[e])||n.push(this.getCell(e))}.bind(this)),n},getSinks:function(){var n=[];return fa(this._nodes,function(t,e){this._out[e]&&!ea(this._out[e])||n.push(this.getCell(e))}.bind(this)),n},isSource:function(t){return!this._in[t.id]||ea(this._in[t.id])},isSink:function(t){return!this._out[t.id]||ea(this._out[t.id])},isSuccessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{outbound:!0}),i},isPredecessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{inbound:!0}),i},isNeighbor:function(t,n,e){var i=(e=e||{}).inbound,r=e.outbound,o=(void 0===i&&void 0===r&&(i=r=!0),!1);return this.getConnectedLinks(t,e).forEach(function(t){var{source:t,target:e}=t.attributes;return i&&ua(t,"id")&&t.id===n.id||r&&ua(e,"id")&&e.id===n.id?!(o=!0):void 0}),o},disconnectLinks:function(e,n){this.getConnectedLinks(e).forEach(function(t){t.set(t.attributes.source.id===e.id?"source":"target",{x:0,y:0},n)})},removeLinks:function(t,e){Xs(this.getConnectedLinks(t),"remove",e)},findElementsAtPoint:function(t,e){return this._filterAtPoint(this.getElements(),t,e)},findLinksAtPoint:function(t,e){return this._filterAtPoint(this.getLinks(),t,e)},findCellsAtPoint:function(t,e){return this._filterAtPoint(this.getCells(),t,e)},_filterAtPoint:function(t,e,n={}){return t.filter(t=>t.getBBox({rotate:!0}).containsPoint(e,n))},findElementsInArea:function(t,e={}){return this._filterInArea(this.getElements(),t,e)},findLinksInArea:function(t,e={}){return this._filterInArea(this.getLinks(),t,e)},findCellsInArea:function(t,e={}){return this._filterInArea(this.getCells(),t,e)},_filterInArea:function(t,e,n={}){let i=new tt(e);var{strict:e=!1}=n;let r=e?"containsRect":"intersect";return t.filter(t=>i[r](t.getBBox({rotate:!0})))},findElementsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getElements(),t,e)},findLinksUnderElement:function(t,e){return this._filterCellsUnderElement(this.getLinks(),t,e)},findCellsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getCells(),t,e)},_isValidElementUnderElement:function(t,e){return t.id!==e.id&&!t.isEmbeddedIn(e)},_isValidLinkUnderElement:function(t,e){return t.source().id!==e.id&&t.target().id!==e.id&&!t.isEmbeddedIn(e)},_validateCellsUnderElement:function(t,e){return t.filter(t=>t.isLink()?this._isValidLinkUnderElement(t,e):this._isValidElementUnderElement(t,e))},_getFindUnderElementGeometry:function(t,e="bbox"){t=t.getBBox({rotate:!0});return"bbox"!==e?Vh(t,e):t},_filterCellsUnderElement:function(t,e,n={}){var i=this._getFindUnderElementGeometry(e,n.searchBy),t=i.type===c.Point?this._filterAtPoint(t,i):this._filterInArea(t,i,n);return this._validateCellsUnderElement(t,e)},findModelsInArea:function(t,e){return this.findElementsInArea(t,e)},findModelsFromPoint:function(t){return this.findElementsAtPoint(t)},findModelsUnderElement:function(t,e){return this.findElementsUnderElement(t,e)},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e={}){let{rotate:n=!0}=e;return et(t).reduce(function(t,e){e=e.getBBox({rotate:n});return e?t?t.union(e):e:t},null)},translate:function(t,e,n){var i=this.getCells().filter(function(t){return!t.isEmbedded()});return Xs(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);return r&&(t=Math.max(t/r.width,0),e=Math.max(e/r.height,0),Xs(n,"scale",t,e,r.origin(),i)),this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",T({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",T({},e,{batchName:t}))},hasActiveBatch:function(t){let e=this._batches,n;return(n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t]).some(t=>0<e[t])}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){e=e.getSourceCell();if(e)if(1<t.getConnectedLinks(e,{outbound:!0}).filter(function(t){var{source:t,target:e}=t.attributes;return t&&t.id===n.id&&(!t.port||t.port===n.port)&&e&&e.id===i.id&&(!e.port||e.port===i.port)}).length)return!1}return!0},linkPinning:function(t,e){var{source:e,target:n}=e.attributes;return e.id&&n.id}}}),hd=(Rh(ld.prototype,["resetCells","addCells","removeCells"],Ih.cells),{GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"}),ud=ku.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){var t=this.options.name;return t?al(t+"-layer"):null},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){var e=this.el;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(e){var{el:n,pivotNodes:i}=this,r=i[e=(e=+e)||0];if(!r){r=i[e]=document.createComment("z-index:"+(e+1));let t=-1/0;for(var o in i)(o=+o)<e&&o>t&&(t=o);t!==-1/0?(i=i[t],n.insertBefore(r,i.nextSibling)):n.insertBefore(r,n.firstChild)}return r},removePivots:function(){var t,{el:e,pivotNodes:n}=this;for(t in n)e.removeChild(n[t]);this.pivotNodes={}},isEmpty:function(){return 0===this.el.children.length}}),cd=["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),{}),dd=["r","rx","ry","width","height","stroke-width","font-size"].reduce((t,e)=>(t[e]=!0,t),{});function fd(t,e){var n,i={};for(n in t)t.hasOwnProperty(n)&&(i[n]=pd(n,t[n],e));return i}function pd(e,n,i){if(e in cd&&ph(n)){let t=vh(n,i);return t=e in dd?Math.max(0,t):t}return n}let gd={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},p=ku.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var i=["cell"],t=this.model.get("type");return t&&t.toLowerCase().split(".").forEach(function(t,e,n){i.push("type-"+n.slice(0,e+1).join("-"))}),i.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e={},n={},i=0,r=S(this,"presentationAttributes");for(t in r)if(r.hasOwnProperty(t))for(var o=r[t],s=0,a=(o=Array.isArray(o)?o:[o]).length;s<a;s++){var l,h=(h=e[l=o[s]])||(e[l]=1<<i++);n[t]|=h}var u=S(this,"initFlag");for(s=0,a=(u=Array.isArray(u)?u:[u]).length;s<a;s++)e[l=u[s]]||(e[l]=1<<i++);if(25<i)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=e,this._presentationAttributes=n},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||xl(this),ku.call(this,t)},initialize:function(){this.setFlags(),ku.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){t=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&t&&(e.dirty&&this.hasFlag(t,"UPDATE")&&(t|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(t,e))},requestUpdate:function(t,e){var n=this.paper;n&&0<t&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n,t=dl(t),i=t.selectors,r=t.groupSelectors;for(n in r){if(i[n])throw new Error("dia.CellView: ambiguous group selector");i[n]=r[n]}if(e){var o=this.selector;if(i[o])throw new Error("dia.CellView: ambiguous root selector.");i[o]=e}return{fragment:t.fragment,selectors:i}},can:function(t){var e=b(this.options.interactive)?this.options.interactive(this):this.options.interactive;return w(e)&&!1!==e[t]||Hs(e)&&!1!==e},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){n=n[t];if(n)return Array.isArray(n)?n:[n]}return this.useCSSSelectors?L(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){var[t=null]=this.findNodes(t);return t},notify:function(t){var e;this.paper&&(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){return t=t&&t.useModelGeometry?(t=this.model).getBBox().bbox(t.angle()):this.getNodeBBox(this.el),this.paper.localToPaperRect(t)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),t=this.getNodeMatrix(t);return R.transformRect(e,n.multiply(t))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():R.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),t=this.getNodeMatrix(t),n=this.getRootTranslateMatrix();return R.transformRect(e,n.multiply(t))},getRootTranslateMatrix:function(){var t=this.model.position();return R.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t,e=R.createSVGMatrix(),n=this.model,i=n.angle();return i&&(t=(n=n.getBBox()).width/2,e=e.translate(t,n=n.height/2).rotate(i).translate(-t,-n)),e},_notifyHighlight:function(t,e,n={}){var i=this.el;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=gd.EMBEDDING;break;case n.connecting:t=gd.CONNECTING;break;case n.magnetAvailability:t=gd.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=gd.ELEMENT_AVAILABILITY;break;default:t=gd.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){var e=this.el;let n=this.$(t)[0];n=n||e;do{var i=n.getAttribute("magnet"),r=n===e;if((i||r)&&"false"!==i)return n;if(r)return}while(n=n.parentNode)},findProxyNode:function(t,e){e=(t=t||this.el).getAttribute(e+"-selector");if(e){e=this.findNode(e);if(e)return e}return t},getSelector:function(t,e){var n,i;return t===this.el?"string"==typeof e?":scope > "+e:i:(t&&(n=R(t).index()+1,i=t.tagName+":nth-child("+n+")",e&&(i+=" > "+e),i=this.getSelector(t.parentNode,i)),i)},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(e,...t){var n=this.model,i=n.id,r=this.findAttributeNode("port",e),o=e.getAttribute("joint-selector"),i={id:i};if(null!=o&&(i.magnet=o),null!=r){let t=r.getAttribute("port");"number"===r.getAttribute("port-id-type")&&(t=parseInt(t,10)),i.port=t,n.hasPort(t)||o||(i.selector=this.getSelector(e))}else null==o&&this.el!==e&&(i.selector=this.getSelector(e));return this.customizeLinkEnd(i,e,...t)},customizeLinkEnd:function(t,e,n,i,r,o){var s=this.paper,a=s.options.connectionStrategy;if("function"==typeof a){a=a.call(s,t,this,e,new A(n,i),r,o,s);if(a)return a}return t},getMagnetFromLinkEnd:function(t){var e=t.port,n=t.magnet,i=this.model,i=null!=e&&i.isElement()&&i.hasPort(e)?this.findPortNode(e,n)||this.el:(n=n||t.selector,this.findNode(n=n||null==e?n:'[port="'+e+'"]'));return this.findProxyNode(i,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");e=this.addLinkFromMagnet(e,n,i);e.notifyPointerdown(t,n,i),e.eventData(t,e.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:e})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var r=this.paper,o=r.options.magnetThreshold,s=this.getEventTarget(t),i=i.targetMagnet;if("onleave"===o){if(i===s||R(i).contains(s))return}else if(r.eventData(t).mousemoved<=o)return;this.dragLinkStart(t,i,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){ea(e)||(t instanceof SVGElement?R:L)(t).attr(e)},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,h,u,c=[],d={};for(n in e)e.hasOwnProperty(n)&&(d[R.attributeNames[n]]=e[n]);for(n in d)if(d.hasOwnProperty(n))if(i=d[n],r=this.getAttributeDefinition(n))if(null===i){let e;if(e=(e=!(e=b(r.unset)?r.unset.call(this,t,d,this):r.unset)&&E(r.set)?r.set:e)||n,E(e)&&e)a=a||{},e in a||(a[e]=i);else if(Array.isArray(e)&&0<e.length)for(a=a||{},o=0,s=e.length;o<s;o++){let t=e[o];t in a||(a[t]=i)}}else!b(r.qualify)||r.qualify.call(this,i,t,d,this)?(E(r.set)&&((a=a||{})[r.set]=i),c.push(n,r)):(a=a||{})[n]=i;else(a=a||{})[n]=i;for(o=0,s=c.length;o<s;o+=2)r=c[o+1],i=e[n=c[o]],b(r.set)&&((l=l||{})[n]=i),b(r.position)&&((h=h||{})[n]=i),b(r.offset)&&((u=u||{})[n]=i);return{raw:d,normal:a,set:l,position:h,offset:u}},updateRelativeAttributes:function(t,e,n,i){i=i||{};var r,o,s=fd(e.raw||{},n),a=e.normal||{};for(o in a)a[o]=s[o];var l=e.position,h=e.offset;for(r in e.set){var u=s[r],c=this.getAttributeDefinition(r).set.call(this,u,n.clone(),t,s,this);w(c)?T(a,c):void 0!==c&&(a[r]=c)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,e=a.transform,g=R.transformStringToMatrix(e),m=A(g.e,g.f),v=(e&&(a=ca(a,"transform"),g.e=g.f=0),(l||h)&&(f=(i=this.getNodeScale(t,i.scalableNode)).sx,p=i.sy),!1);for(r in l)u=s[r],(d=this.getAttributeDefinition(r).position.call(this,u,n.clone(),t,s,this))&&(m.offset(A(d).scale(f,p)),v=v||!0);this.setNodeAttributes(t,a);var y=!1;if(h){i=this.getNodeBoundingRect(t);if(0<i.width&&0<i.height){var b=R.transformRect(i,g).scale(1/f,1/p);for(r in h)u=s[r],(d=this.getAttributeDefinition(r).offset.call(this,u,b,t,s,this))&&(m.offset(A(d).scale(f,p)),y=y||!0)}}(void 0!==e||v||y)&&(m.round(1),g.e=m.x,g.f=m.y,t.setAttribute("transform",R.matrixToTransformString(g)))}},getNodeScale:function(t,e){var n;return e=e&&e.contains(t)?(n=1/(t=e.scale()).sx,1/t.sy):n=1,{sx:n,sy:e}},cleanNodesCache:function(){this.metrics={}},cleanNodeCache:function(t){t=t.id;t&&delete this.metrics[t]},nodeCache:function(t){var e=this.metrics;return e?e[t=R.ensureId(t)]||(e[t]={}):{}},getNodeData:function(t){t=this.nodeCache(t);return t.data||(t.data={}),t.data},getNodeBoundingRect:function(t){var e,n=this.nodeCache(t);return void 0===n.boundingRect&&(e=this.paper.options.measureNode,n.boundingRect="function"==typeof e?e(t,this):R(t).getBBox()),new tt(n.boundingRect)},getNodeMatrix:function(e){var n=this.nodeCache(e);if(void 0===n.magnetMatrix){var{rotatableNode:i,el:r}=this;let t;t=i&&i.contains(e)?i:r,n.magnetMatrix=R(e).getTransformToElement(t,{safe:!e.checkVisibility()})}return R.createSVGMatrix(n.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=R(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=[];for(o in t)if(t.hasOwnProperty(o)&&(r=t[o],y(r)))for(var l=n[o]=this.findBySelector(o,e,i),h=0,u=l.length;h<u;h++){var c,d,f=l[h],p=R.ensureId(f),g=i&&i[o]===f,m=s[p];m?(m.array||(a.push(p),m.array=!0,m.attributes=[m.attributes],m.selectedLength=[m.selectedLength]),c=m.attributes,m=m.selectedLength,g?(c.unshift(r),m.unshift(-1)):(d=Js(m,u),c.splice(d,0,r),m.splice(d,0,u))):s[p]={attributes:r,selectedLength:g?-1:u,node:f,array:!1}}for(h=0,u=a.length;h<u;h++)(r=s[p=a[h]]).attributes=_({},...r.attributes.reverse());return s},getEventTarget:function(t,e={}){var{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||{}).rootBBox||(n.rootBBox=tt()),n.selectors||(n.selectors=this.selectors);var i,r,o={},s={},a=[],l=[],h=n.roAttributes,u=this.findNodesAttributes(h||e,t,o,n.selectors),c=h?this.findNodesAttributes(e,t,o,n.selectors):u;for(r in u)if(f=(d=u[r]).attributes,y=d.node,(i=this.processNodeAttributes(y,f)).set||i.position||i.offset||i.raw.ref){var d=c[r]&&c[r].attributes,f=(d&&void 0===f.ref?d:f).ref;if(f){if(!(g=(o[f]||this.findBySelector(f,t,n.selectors))[0]))throw new Error('dia.CellView: "'+f+'" reference does not exist.')}else g=null;p={node:y,refNode:g,processedAttributes:i,allAttributes:d},g?-1<(f=l.findIndex(function(t){return t.refNode===y}))?l.splice(f,0,p):l.push(p):a.push(p)}else this.setNodeAttributes(y,fd(i.normal,n.rootBBox));a.push(...l);for(let e=0,t=a.length;e<t;e++){var p,g,m,v,y=(p=a[e]).node,b=(g=p.refNode)?R.ensureId(g):"";let t=s[b];t||(t=g?(m=this.getNodeBoundingRect(g),v=R(g).getTransformToElement(R.getCommonAncestor(y,g)),R.transformRect(m,v)):n.rootBBox,s[b]=t),h?(i=this.processNodeAttributes(y,p.allAttributes),this.mergeProcessedAttributes(i,p.processedAttributes)):i=p.processedAttributes,this.updateRelativeAttributes(y,i,t,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),T(t.set,e.set),T(t.position,e.position),T(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(),Gu.mount(this))},onDetach(){this.unmountTools(),Gu.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).configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){var t=this._toolsView;return t&&t.unmount(),this},mountTools(){var 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(){Gu.remove(this)},updateHighlighters:function(t=!1){Gu.update(this,null,t)},transformHighlighters:function(){Gu.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){var{defaultInteractionPrevented:t=!1}=this.eventData(t);return t},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){var i=this.model,r=i.graph;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){var i=this.eventData(t).graph;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){var{paper:e,model:n}=this,i=(e.isAsync()&&(n.isLink()&&((i=n.getSourceElement())&&(i=e.findViewByModel(i))&&(e.dumpView(i),e.checkViewVisibility(i)),i=n.getTargetElement())&&(n=e.findViewByModel(i))&&(e.dumpView(n),e.checkViewVisibility(n)),e.dumpView(this),e.checkViewVisibility(this)),this.getEventTarget(t,{fromPoint:!0})),n=e.findView(i);n!==this&&(this.mouseleave(t),n)&&n.mouseenter(t)},setInteractivity:function(t){this.options.interactive=t},isIntersecting:function(t,e){return vr.exists(t,this.getNodeBBox(this.el),e)},isEnclosedIn:function(t){return t.containsRect(this.getNodeBBox(this.el))},isInArea:function(t,e={}){return e.strict?this.isEnclosedIn(t):this.isIntersecting(t)},isAtPoint:function(t,e){return this.getNodeBBox(this.el).containsPoint(t,e)}},{Flags:{TOOLS:"TOOLS"},Highlighting:gd,addPresentationAttributes:function(t){return _({},S(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)?Ks(t.concat(e)):void 0})},evalAttribute:pd}),g=(Object.defineProperty(p.prototype,"useCSSSelectors",{get(){var t=this.model.useCSSSelectors;return void 0!==t?t:hl.useCSSSelectors}}),{TOOLS:p.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"}),md={MOVE:"move",MAGNET:"magnet"},vd=p.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=p.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){p.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[g.UPDATE],position:[g.TRANSLATE,g.TOOLS],size:[g.RESIZE,g.PORTS,g.TOOLS],angle:[g.ROTATE,g.TOOLS],markup:[g.RENDER],ports:[g.PORTS]},initFlag:[g.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(e,n){var i=this.useCSSSelectors;this.hasFlag(e,g.PORTS)&&(this._removePorts(),this._cleanPortsCache());let r=!1;if(this.hasFlag(e,g.RENDER))this.render(),this.updateTools(n),this.updateHighlighters(!0),r=!0,e=this.removeFlag(e,[g.RENDER,g.UPDATE,g.RESIZE,g.TRANSLATE,g.ROTATE,g.PORTS,g.TOOLS]);else{let t=!1;this.hasFlag(e,g.RESIZE)&&(this.resize(n),t=!0,e=this.removeFlag(e,[g.RESIZE,g.UPDATE]),i)&&(e=this.removeFlag(e,g.PORTS)),this.hasFlag(e,g.UPDATE)&&(this.update(this.model,null,n),e=this.removeFlag(e,g.UPDATE),t=!0,i)&&(e=this.removeFlag(e,g.PORTS)),this.hasFlag(e,g.TRANSLATE)&&(this.translate(),e=this.removeFlag(e,g.TRANSLATE),r=!0),this.hasFlag(e,g.ROTATE)&&(this.rotate(),e=this.removeFlag(e,g.ROTATE),r=!0),this.hasFlag(e,g.PORTS)&&(this._renderPorts(),t=!0,e=this.removeFlag(e,g.PORTS)),t&&this.updateHighlighters(!1)}return r&&this.transformHighlighters(),this.hasFlag(e,g.TOOLS)&&(this.updateTools(n),e=this.removeFlag(e,g.TOOLS)),e},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var n=this.useCSSSelectors,i=(n&&this._removePorts(),this.model),r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new tt(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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.ElementView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var t=this.parseDOMJSON(t,this.el),e=this.selectors=t.selectors;this.rotatableNode=R(e[this.rotatableSelector])||null,this.scalableNode=R(e[this.scalableSelector])||null,this.vel.append(t.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(R(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(){this.rotatableNode?(this.rgRotate(),this.update()):this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var{x:t,y:e}=this.model.position();return`translate(${t},${e})`},getRotateString:function(){var t,e,n=this.model.angle();return n?({width:t,height:e}=this.model.size(),`rotate(${n},${t/2},${e/2})`):null},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,o=(0<r.node.getElementsByTagName("path").length&&(o=!0),r.getBBox({recursive:o})),s=i.width/(o.width||1),o=i.height/(o.height||1),s=(r.attr("transform","scale("+s+","+o+")"),this.rotatableNode),o=s&&s.attr("transform");o&&(s.attr("transform",o+" rotate("+-n+","+i.width/2+","+i.height/2+")"),s=r.getBBox({target:this.paper.cells}),e.set("position",{x:s.x,y:s.y},T({updateHandled:!0},t)),this.translate(),this.rotate()),this.update()},prepareEmbedding:function(t={}){var e=t.model||this.model,n=(t.paper||this.paper).model;let i=t.initialZIndices={};var 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});let 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");r=e.parent();r?(n.getCell(r).unembed(e,{ui:!0}),t.initialParentId=r):t.initialParentId=null},processEmbedding:function(t={},e,n,i){let r=t.model||this.model;var o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:h}=o.options;let u,c=(u=(u=b(a)?et(a.call(s,this,e,n,i)):"pointer"===a?s.findElementsAtPoint({x:n,y:i}):s.findElementsUnderElement(r,{searchBy:a})).filter(t=>t instanceof Oh&&r.id!==t.id&&!t.isEmbeddedIn(r)),l&&(u=u.slice(-1)),null);var d=t.candidateEmbedView;for(let t=u.length-1;0<=t;t--){var f=u[t];if(d&&d.model.id==f.id){c=d;break}f=f.findView(o);if(!b(h)||h.call(o,this,f)){c=f;break}}c&&c!=d&&(this.clearEmbedding(t),t.candidateEmbedView=c.highlight(c.findProxyNode(null,"container"),{embedding:!0})),!c&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){var e=(t=t||{}).candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t={}){var 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{var e=i.options.validateUnembedding,r=t.initialParentId;if(r&&"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(i){var{model:t,whenNotAllowed:e="revert"}=i,r=t||this.model;let o=(i.paper||this.paper).model;switch(e){case"remove":r.remove({ui:!0});break;case"revert":{let{initialParentId:t,initialPosition:e,initialZIndices:n}=i;e&&({x:a,y:s}=e,r.position(a,s,{deep:!0,ui:!0})),n&&Object.keys(n).forEach(t=>{var e=o.getCell(t);e&&e.set("z",n[t],{ui:!0})});var s,a=o.getCell(t);a&&a.embed(r,{ui:!0});break}}},getTargetParentView:function(t){var{candidateEmbedView:t=null}=this.eventData(t);return t},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){e=(t=t||this.el).getAttribute(e+"-selector");if(e){var n=this.findAttribute("port",t);if(n){n=this.findPortNode(n,e);if(n)return n}else{n=this.findNode(e);if(n)return n}}return t},notifyPointerdown(t,e,n){p.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){p.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),p.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){p.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){p.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){p.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){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case md.MAGNET:this.dragMagnet(t,e,n);break;case md.MOVE:(s||this).drag(t,e,n);default:i.preventPointerEvents||this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case md.MAGNET:this.dragMagnetEnd(t,e,n);break;case md.MOVE:(s||this).dragEnd(t,e,n);default:i.preventPointerEvents||this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){p.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){p.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){p.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){p.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){p.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){var i=t.currentTarget;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){var i,r;this.isDefaultInteractionPrevented(t)||(i=this.getDelegatedView())&&i.can("elementMove")&&(this.eventData(t,{action:md.MOVE,delegatedView:i}),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){var i,r=this.paper,o=t.isPropagationStopped();o&&this.eventData(t,{preventPointerEvents:!0}),!this.isDefaultInteractionPrevented(t)&&this.can("addLinkFromMagnet")&&({targetMagnet:i=t.currentTarget}=this.eventData(t),t.stopPropagation(),r.options.validateMagnet.call(r,this,i,t)?(r.options.magnetThreshold<=0&&this.dragLinkStart(t,i,e,n),this.eventData(t,{action:md.MAGNET})):o?this.dragStart(t,e,n):this.pointerdown(t,e,n))},snapToGrid:function(t,e,n){var i=this.paper.options.gridSize;return{x:Xn(e,i),y:Xn(n,i)}},drag:function(t,e,n){var i=this.paper,r=this.model,o=this.eventData(t),{pointerOffset:s,restrictedArea:a,embedding:l}=o,{x:s,y:h}=this.snapToGrid(t,e+s.x,n+s.y);r.position(s,h,{restrictedArea:a,deep:!0,ui:!0}),i.options.embeddingMode&&(l||(this.prepareEmbedding(o),l=!0),this.processEmbedding(o,t,e,n)),this.eventData(t,{embedding:l})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){t=this.eventData(t);t.embedding&&this.finalizeEmbedding(t)},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:g}),m=(T(vd.prototype,hn),{TOOLS:p.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"}),yd=p.extend({className:function(){var t=p.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(){p.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[m.RENDER],attrs:[m.UPDATE],router:[m.UPDATE],connector:[m.CONNECTOR],labels:[m.LABELS,m.TOOLS],labelMarkup:[m.LABELS],vertices:[m.UPDATE],source:[m.SOURCE,m.UPDATE],target:[m.TARGET,m.UPDATE]},initFlag:[m.RENDER,m.SOURCE,m.TARGET,m.TOOLS],UPDATE_PRIORITY:1,EPSILON:1e-6,confirmUpdate:function(n,i){if(i=i||{},this.hasFlag(n,m.SOURCE)){if(!this.updateEndProperties("source"))return n;n=this.removeFlag(n,m.SOURCE)}if(this.hasFlag(n,m.TARGET)){if(!this.updateEndProperties("target"))return n;n=this.removeFlag(n,m.TARGET)}var{paper:r,sourceView:o,targetView:s}=this;if(!r||!(o&&!r.isViewMounted(o)||s&&!r.isViewMounted(s)))if(this.hasFlag(n,m.RENDER))this.render(),this.updateHighlighters(!0),this.updateTools(i),n=this.removeFlag(n,[m.RENDER,m.UPDATE,m.LABELS,m.TOOLS,m.CONNECTOR]),Jh.test("isSafari")&&this.__fixSafariBug268376();else{let t=!1;o=this.model,r=o.attributes;let e=this.hasFlag(n,m.LABELS);e&&(this.onLabelsChange(o,r.labels,i),n=this.removeFlag(n,m.LABELS),t=!0);s=this.hasFlag(n,m.UPDATE),r=this.hasFlag(n,m.CONNECTOR);(s||r)&&(s?i.translateBy&&o.isRelationshipEmbeddedIn(i.translateBy)?this.translate(i.tx,i.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(i),n=this.removeFlag(n,[m.UPDATE,m.TOOLS,m.CONNECTOR]),e=!1,t=!0),e&&this.updateLabelPositions(),t&&this.updateHighlighters(),this.hasFlag(n,m.TOOLS)&&(this.updateTools(i),n=this.removeFlag(n,m.TOOLS))}return n},__fixSafariBug268376:function(){var n=this.el,i=Array.from(n.childNodes),r=document.createDocumentFragment();for(let t=0,e=i.length;t<e;t++)n.removeChild(i[t]),r.appendChild(i[t]);n.appendChild(r)},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(m.UPDATE),t)},isLabelsRenderRequired:function(t={}){var e=this.model.previous("labels");if(e&&"propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(1<i)if(!!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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.LinkView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){t=this.parseDOMJSON(t,this.el);this.selectors=t.selectors,this.vel.append(t.fragment)},renderStringMarkup:function(t){t=R(t);Array.isArray(t)||(t=[t]),this.vel.append(t)},_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=R(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())return(n=1<(e=n.childNodes).length||"G"!==e[0].nodeName.toUpperCase()?R("g").append(n):R(e[0])).addClass("label"),{node:n.node,selectors:t.selectors};throw new Error("dia.LinkView: invalid label markup.")}},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)e&&e.remove();else{e?e.empty():(e=t.labels=R("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(al(S(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,h=o[a],h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=(h=(h?(l=h.node,h):(h=r._builtins.defaultLabel,h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=r._getDefaultLabel(),l=(u=this._normalizeLabelMarkup(this._getLabelMarkup(u.markup))||h).node,u)).selectors,l.setAttribute("label-idx",a),e.append(l),n[a]=l,this.selector);if(h[u])throw new Error("dia.LinkView: ambiguous label root selector.");h[u]=l,i[a]=h}e.parent()||this.mountLabels(),this.updateLabels()}return this},mountLabels:function(){var{el:t,paper:e,model:n,_V:i,options:r}=this,i=i.labels;i&&n.hasLabels()&&(i=i.node,r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(i,n.get("z")):i.parentNode!==t&&t.appendChild(i))},unmountLabels:function(){var{options:t,_V:e}=this;e&&(e=e.labels,e)&&t.labelsLayer&&e.remove()},findLabelNodes:function(t,e){var n=this._labelCache[t];return n?(t=this._labelSelectors[t],this.findBySelector(e,n,t)):[]},findLabelNode:function(t,e){var[t=null]=this.findLabelNodes(t,e);return t},_mergeLabelAttrs:function(t,e,n,i){return null===e?null:void 0===e?null===n?null:void 0===n?t?void 0:i:t?n:_({},i,n):t?_({},n,e):_({},i,n,e)},_mergeLabelSize:function(t,e){return null===t?null:void 0===t?null===e?null:void 0===e?void 0:e:_({},e,t)},updateLabels:function(){if(this._V.labels){this.paper.options.labelLayer||this.cleanNodeCache(this.el);for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,t=t._getDefaultLabel(),r=t.markup,o=t.attrs,s=t.size,a=0,l=e.length;a<l;a++){var h=this._labelCache[a],u=(h.setAttribute("cursor",n?"move":"default"),this._labelSelectors[a]),c=e[a],d=c.markup,f=c.size,d=this._mergeLabelAttrs(d||r,c.attrs,o,i),c=this._mergeLabelSize(f,s);this.updateDOMSubtreeAttributes(h,d,{rootBBox:new tt(c),selectors:u})}}return this},removeRedundantLinearVertices:function(t){var e=this.model,n=e.vertices(),n=[this.sourceAnchor,...n,this.targetAnchor],i=n.length,n=new x(n),n=(n.simplify({threshold:.001}),n.points.map(t=>t.toJSON())),r=n.length;return i===r?0:(e.vertices(n.slice(1,r-1),t),i-r)},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 A(this.sourceAnchor);case"target":return new A(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new A(this.sourcePoint);case"target":return new A(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(e)return this.sourceMagnet||e.el;break;case"target":e=this.targetView;if(e)return this.targetMagnet||e.el;break;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){var{route:n,path:i}=this;n&&i&&((n=new x(n)).translate(t,e),this.route=n.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(){var{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){var t=this.model,t=t.vertices(),e=this.findAnchors(t),n=this.sourceAnchor=e.source,e=this.targetAnchor=e.target,t=this.findRoute(t),t=(this.route=t,this.findConnectionPoints(t,n,e));this.sourcePoint=t.source,this.targetPoint=t.target},updatePath:function(){var{route:t,sourcePoint:e,targetPoint:n}=this,t=this.findPath(t,e.clone(),n.clone());this.path=t},findAnchorsOrdered:function(t,e,n,i){var r=this.model,o=r.get(t),r=r.get(n),s=this.getEndView(t),a=this.getEndView(n),l=this.getEndMagnet(t),h=this.getEndMagnet(n),s=s?(e=e?new A(e):a?h:new A(r),this.getAnchor(o.anchor,s,l,e,t)):new A(o),e=a?(l=new A(i||s),this.getAnchor(r.anchor,a,h,l,n)):new A(r),o={};return o[t]=s,o[n]=e,o},findAnchors:function(t){var e=this.model,n=t[0],t=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",t,"source",n):this.findAnchorsOrdered("source",n,"target",t)},findConnectionPoints:function(t,e,n){var i,r=t[0],t=t[t.length-1],o=this.model,s=o.get("source"),o=o.get("target"),a=this.sourceView,l=this.targetView,h=this.paper.options;return{source:a&&!a.isNodeConnection(this.sourceMagnet)?(i=this.sourceMagnet||a.el,s=s.connectionPoint||h.defaultConnectionPoint,r=r||n,r=new P(r,e),this.getConnectionPoint(s,a,i,r,"source")):e,target:l&&!l.isNodeConnection(this.targetMagnet)?(s=this.targetMagnet||l.el,a=o.connectionPoint||h.defaultConnectionPoint,i=t||e,r=new P(i,n),this.getConnectionPoint(a,l,s,r,"target")):n}},getAnchor:function(t,e,n,i,r){var o=e.isNodeConnection(n),s=this.paper.options;if(!(t=t||(o?s.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor)))throw new Error("Anchor required.");if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s[o?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}s=a.call(this,e,n,i,t.args||{},r,this);return s?s.round(this.decimalsRounding):new A},getConnectionPoint:function(t,e,n,i,r){var o=i.end,s=this.paper.options;if(!t)return o;if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s.connectionPointNamespace[l]))throw new Error("Unknown connection point: "+l)}return(s=a.call(this,i,e,n,t.args||{},r,this))?s.round(this.decimalsRounding):o},isIntersecting:function(t,e){var n=this.getConnection();return!!n&&vr.exists(t,n,e,{segmentSubdivisions:this.getConnectionSubdivisions()})},isEnclosedIn:function(t){var e=this.getConnection();return!!e&&!!(e=e.bbox())&&t.containsRect(e)},isAtPoint:function(t){t=new tt(t);return t.inflate(this.EPSILON),this.isIntersecting(t)},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,t=t._getDefaultLabel(),t=this._normalizeLabelPosition(t.position);return _({},e,t)},_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:_({},e,t)},updateLabelPositions:function(){if(this._V.labels&&this.path){var t=this.model.get("labels")||[];if(t.length)for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r,o=this._labelCache[n];o&&(r=t[n],r=this._normalizeLabelPosition(r.position),r=this._mergeLabelPositionProperty(r,e),r=this._getLabelTransformationMatrix(r),o.setAttribute("transform",R.matrixToTransformString(r)),this._cleanLabelMatrices(n))}}return this},_cleanLabelMatrices:function(t){var{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(var r in i){r=i[r].id;r&&r in e&&delete e[r].magnetMatrix}},updateEndProperties:function(t){var{model:e,paper:n}=this,i=t+"View",e=e.get(t),e=e&&e.id;if(e){if(!(e=n.getModelById(e)))throw new Error("LinkView: invalid "+t+" cell.");if(!(e=e.findView(n)))return!1;this[i]=e}else this[i]=null;return this.updateEndMagnet(t),!0},updateEndMagnet:function(e){var n=e+"Magnet",i=this.getEndView(e);if(i){let t=i.getMagnetFromLinkEnd(this.model.get(e));t===i.el&&(t=null),this[n]=t}else this[n]=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:_({},e,t)},addLabel:function(t,e,n,i){var r,o,s=0,t="number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(s=e,n):e):(r=t,o=e,"number"==typeof n?(s=n,i):n),e=this._getDefaultLabelPositionArgs(),i=t,n=this._mergeLabelPositionArgs(i,e),i={position:this.getLabelPosition(r,o,s,n)};return this.model.insertLabel(-1,i,t),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,t=i?t.y:e,i=i?e:n,e={x:r,y:t},n=this.getVertexIndex(r,t);return this.model.insertVertex(n,e,i),n},sendToken:function(t,e,n){var i,r,e=w(e)?(o=e.duration,a="reverse"===e.direction,e.connection):(o=e,a=!1,null),o=o||1e3,s={dur:o+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"},a=(a&&(s.keyPoints="1;0",s.keyTimes="0;1"),R(t));if(!((e="string"==typeof e?this.findNode(e):(t=this._V).connection?t.connection.node:this.el.querySelector("path"))instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");a.appendTo(this.paper.cells).animateAlongPath(s,e),setTimeout((i=a,r=n,function(){i.remove(),"function"==typeof r&&r()}),o)},findRoute:function(t){t=t||[];var e=this.paper.options.routerNamespace||Kc,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(A);n=i}i=b(n)?n:e[n.name];if(b(i))return e=n.args||{},i.call(this,t,e,this)||t.map(A);throw new Error('dia.LinkView: unknown router: "'+n.name+'".')},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||Tu,r=this.model.connector(),o=this.paper.options.defaultConnector,r=r||o||{},o=b(r)?r:i[r.name];if(b(o))return(i=Qs(r.args||{})).raw=!0,"string"==typeof(o=o.call(this,e,n,t,i,this))?new V(R.normalizePathData(o)):o;throw new Error('dia.LinkView: unknown connector: "'+r.name+'".')},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("data")?t.data:(e=e.serialize(),t.data=e):null},getConnectionSubdivisions:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("segmentSubdivisions")?t.segmentSubdivisions:(e=e.getSegmentSubdivisions(),t.segmentSubdivisions=e):null},getConnectionLength:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("length")?t.length:(e=e.length({segmentSubdivisions:this.getConnectionSubdivisions()}),t.length=e):0},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?(Sl(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,i="number"==typeof n?(s=n,i):n,n=(i&&(o.args=i),!(i&&i.absoluteDistance)),a=i&&i.absoluteDistance&&i.reverseDistance,i=i&&i.absoluteOffset,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},t=new A(t,e),e=l.closestPointT(t,h),h=l.lengthAtT(e,h);return n&&(h=h/this.getConnectionLength()||0),a&&(h=-1*(this.getConnectionLength()-h)||1),o.distance=h,h=(r=i?r:l.tangentAtT(e))?r.pointOffset(t):(n=l.pointAtT(e),{x:(a=t.difference(n)).x,y:a.y}),o.offset=h,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e=0,n={};if("number"==typeof t)u=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");n=t.args||{},u=t.distance,e=t.angle||0}var i,r=0<u&&u<=1,o=0,s={x:0,y:0},t=(t.offset&&("number"==typeof(t=t.offset)&&(o=t),t.x&&(s.x=t.x),t.y)&&(s.y=t.y),0!==s.x||0!==s.y||0===o),a=n.keepGradient,n=n.ensureLegibility,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},r=r?u*this.getConnectionLength():u,u=l.tangentAtLength(r,h),r=e;return u?(t?(i=u.start.clone()).offset(s):((h=u.clone()).rotate(u.start,-90),h.setLength(o),i=h.end),a&&(r=u.angle()+e,n)&&(r=Yn((r+90)%180-90))):(i=l.start.clone(),t&&i.offset(s)),R.createSVGMatrix().translate(i.x,i.y).rotate(r)},getLabelCoordinates:function(t){t=this._getLabelTransformationMatrix(t);return new A(t.e,t.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new A(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){p.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){p.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),p.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){p.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){p.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){p.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&&T(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){p.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){p.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){p.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){p.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){p.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,i=parseInt(i.getAttribute("label-idx"),10),r=this._getDefaultLabelPositionProperty(),o=this._normalizeLabelPosition(this._getLabelPositionProperty(i)),o=this._mergeLabelPositionProperty(o,r),r=this.getLabelCoordinates(o),o=r.x-e,e=r.y-n,r=this._getLabelPositionAngle(i),n=this._getLabelPositionArgs(i),s=this._getDefaultLabelPositionArgs(),n=this._mergeLabelPositionArgs(n,s);this.eventData(t,{action:"label-move",labelIdx:i,dx:o,dy:e,positionAngle:r,positionArgs:n,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){var i;this.can("arrowheadMove")&&(i=t.target.getAttribute("end"),i=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0}),this.eventData(t,i))},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),e={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)},n=(this.paper.options.snapLabels&&delete e.position.offset,{ui:!0});this.paper.isAsync()&&"touchmove"===t.type&&(n.async=!1),this.model.label(i.labelIdx,e,n)},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,i=t.arrowhead,r=t.initialEnd,o=this.model.prop(i);o&&!Zh.endsEqual(r,o)&&(n=this.paper,r.id&&this.notify("link:disconnect",e,n.findViewByModel(r.id),t.initialMagnet,i),o.id)&&this.notify("link:connect",e,n.findViewByModel(o.id),t.magnetUnderPointer,i)},_snapToPoints:function(e,n,t){let i=null,r=1/0,o=null,s=1/0,a=e.x,l=e.y;for(let t=0;t<n.length;t++){var h=Math.abs(n[t].x-e.x),h=(h<r&&(r=h,i=n[t]),Math.abs(n[t].y-e.y));h<s&&(s=h,o=n[t])}return r<t&&(a=i.x),s<t&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){var{paper:i,model:r}=this,o=i.options.snapLinksSelf,s=this.eventData(t),o=o.radius||20,s=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],r=this._snapToPoints({x:e,y:n},s,o),e=i.localToClientPoint(r);this._connectArrowhead(document.elementFromPoint(e.x,e.y),r.x,r.y,this.eventData(t))},_snapArrowhead:function(t,e,n){let i=this.paper;var{snapLinks:r,connectionStrategy:o}=i.options;let s=this.eventData(t),a=!1,l=r.radius||50,h=i.findElementViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l},r.findInAreaOptions),u=s.closestView||null;var c=s.closestMagnet||null,r=s.magnetProxy||null,d=(s.closestView=s.closestMagnet=s.magnetProxy=null,Number.MAX_VALUE),f=new A(e,n),p=(h.forEach(function(n){let e=[];"false"!==n.el.getAttribute("magnet")&&e.push({bbox:n.model.getBBox(),magnet:n.el}),n.$("[magnet]").toArray().forEach(t=>{e.push({bbox:n.getNodeBBox(t),magnet:t})}),e.forEach(t=>{var{magnet:t,bbox:e}=t,e=e.center().squaredDistance(f);e<d&&(c===t||i.options.validateConnection.apply(i,s.validateConnectionArgs(n,n.el===t?null:t)))&&(d=e,s.closestView=n,s.closestMagnet=t)})},this),null),g=s.closestView,m=s.closestMagnet,v=(m&&(p=s.magnetProxy=g.findProxyNode(m,"highlighter")),s.arrowhead),y=c!==m;if(u&&y&&u.unhighlight(r,{connecting:!0,snapping:!0}),g){var{prevEnd:r,prevX:b,prevY:x}=s;if(s.prevX=e,s.prevY=n,a=!0,!y&&("function"!=typeof o||b===e&&x===n))return a;if(b=g.getLinkEnd(m,e,n,this.model,v),!y&&na(r,b))return a;s.prevEnd=b,y&&g.highlight(p,{connecting:!0,snapping:!0})}else b={x:e,y:n};return this.model.set(v,b||{x:e,y:n},{ui:!0}),u&&this.notify("link:snap:disconnect",t,u,c,v),g&&this.notify("link:snap:connect",t,g,m,v),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){var r,o,s,{paper:a,model:l}=this;i.eventTarget!==t&&(i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0}),(r=i.viewUnderPointer=a.findView(t))&&(o=i.magnetUnderPointer=r.findMagnet(t),s=i.magnetProxy=r.findProxyNode(o,"highlighter"),o)&&this.paper.options.validateConnection.apply(a,i.validateConnectionArgs(r,o))?s&&r.highlight(s,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)),i.eventTarget=t,l.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t={},e,n){var i=this.model,{viewUnderPointer:t,magnetUnderPointer:r,magnetProxy:o,arrowhead:s}=t;r&&o&&t&&(t.unhighlight(o,{connecting:!0}),o=t.getLinkEnd(r,e,n,i,s),i.set(s,o,{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=[],i=(n[4]=t,0),r=0,t="source"===t?(i=2,"target"):(r=2,"source"),t=(n[5]=this).model.get(t);return t.id&&((t=(e=n[i]=this.paper.findViewByModel(t.id)).getMagnetFromLinkEnd(t))===e.el&&(t=void 0),n[i+1]=t),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]")),l=("false"!==s.el.getAttribute("magnet")&&a.push(s.el),a.filter(e.bind(t,s)));if(0<l.length){for(var h=0,u=l.length;h<u;h++)s.highlight(l[h],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e=Object.keys(t.marked),n=0,i=e.length;n<i;n++){var r=e[n],o=t.marked[r],s=this.paper.findViewByModel(r);if(s){for(var a=0,l=o.length;a<l;a++)s.unhighlight(o[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){t={action:"arrowhead-move",arrowhead:t,whenNotAllowed:(e=e||{}).whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:Qs(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(t),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=t),t},onMount:function(){p.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){p.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){p.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:m}),bd=(Object.defineProperty(yd.prototype,"sourceBBox",{enumerable:!0,get:function(){var t,e=this.sourceView;return e?(t=this.sourceMagnet,e.isNodeConnection(t)?new tt(this.sourceAnchor):e.getNodeBBox(t||e.el)):(t=this.model.source(),new tt(t.x,t.y))}}),Object.defineProperty(yd.prototype,"targetBBox",{enumerable:!0,get:function(){var t,e=this.targetView;return e?(t=this.targetMagnet,e.isNodeConnection(t)?new tt(this.targetAnchor):e.getNodeBBox(t||e.el)):(t=this.model.target(),new tt(t.x,t.y))}}),ud.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){ud.prototype.init.apply(this,arguments);var{paper:t}=this.options;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){let e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach(t=>{e.push(...this._resolveDrawGridOption(t))}),e},removeGrid(){var t=this._gridCache;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){let{paper:s}=this.options;var t=this._gridSettings;if(this.removeGrid(),0!==t.length){let o=s.options.drawGridSize||s.options.gridSize;if(!(o<=1)){let r=this._getGridRefs();t.forEach((t,e)=>{var e=this._getPatternId(e),t=_({},t),{scaleFactor:n=1}=t;t.width=o*n||1,t.height=o*n||1;let i;r.exist(e)?i=r.get(e):(i=R("pattern",{id:e,patternUnits:"userSpaceOnUse"},R(t.markup)),r.add(e,i)),b(t.render)&&t.render(i.node.firstChild,t,s),i.attr({width:t.width,height:t.height})}),r.root.appendTo(this.el),this.updateGrid()}}},updateGrid(){let{_gridCache:e,_gridSettings:i,options:{paper:r}}=this;if(e){let{root:t,patterns:n}=e;var o,{x:s,y:a,width:l,height:h}=r.getArea();for(o in t.attr({x:s,y:a,width:l,height:h}),n)n[o].attr({x:-s,y:-a});i.forEach((t,e)=>{b(t.update)&&(e=n[this._getPatternId(e)],t.update(e.node.firstChild,t,r))})}},_getPatternId(t){return`pattern_${this.options.paper.cid}_`+t},_getGridRefs(){var t=this._gridCache;if(!t){let i=R("defs"),r=R("svg",{width:"100%",height:"100%"},[i]);t=this._gridCache={root:r,patterns:{},add:function(t,e){var n=R("rect",{width:"100%",height:"100%",fill:`url(#${t})`});i.append(e),r.append(n),this.patterns[t]=e},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}}}return t},_resolveDrawGridOption(t){var e=this.options.patterns;if(E(t)&&Array.isArray(e[t]))return e[t].map(function(t){return T({},t)});var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if((r=i||r||n.markup?r:"dot")&&Array.isArray(e[r])){var o=e[r].map(function(t){return T({},t)}),s=Array.isArray(n.args)?n.args:[n.args||{}];$s(s[0],ca(t,"args"));for(var a=0;a<s.length;a++)o[a]&&T(o[a],s[a]);return o}return i?n:[n]},isEmpty(){var t=this._gridCache;return this.el.children.length===(t?1:0)}})),xd={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},wd=9007199254740991,Ad={[(C=p.Highlighting).DEFAULT]:{name:"stroke",options:{padding:3}},[C.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[C.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},Pd=[{name:hd.GRID},{name:hd.BACK},{name:hd.CELLS},{name:hd.LABELS},{name:hd.FRONT},{name:hd.TOOLS}],Ed=(l=ku.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:vd,linkView:yd,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:Ad,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){var t=this.model.get("cells").cellNamespace,t=pl(t,["standard","Link"]);if(t)return new t;throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.")},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 vd},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:xd.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:Ke,anchorNamespace:h,linkAnchorNamespace:nd,connectionPointNamespace:Je,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,DEFAULT_FIND_BUFFER:200,DEFAULT_CELL_LAYER:hd.CELLS,init:function(){var t=this.options,t=(t.cellViewNamespace||(t.cellViewNamespace=void 0!==joint&&ua(joint,"shapes")?joint.shapes:null),this.model=t.model||new ld);this._layers={viewsMap:{},namesMap:{},order:[]},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(t.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&Tl(this._updates.id),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()||!qs(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){t=this.findViewByModel(t);t&&this.requestViewUpdate(t,t.FLAG_REMOVE,t.UPDATE_PRIORITY,n)},onCellChange:function(t,e){t!==this.model.attributes.cells&&(t.hasChanged("layer")||t.hasChanged("z")&&this.options.sorting===xd.APPROX)&&(t=this.findViewByModel(t))&&this.requestViewUpdate(t,t.FLAG_INSERT,t.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){var e,n,i;this.isFrozen()||(e=t&&t.batchName,n=this.model,this.isAsync()||(i=this.UPDATE_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t),(i=this.SORT_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.sortViews())},cloneOptions:function(){var t=this.options,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&void 0!==joint&&ua(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),b(e)||(t.defaultConnector=ta(e)),b(n)||(t.defaultRouter=ta(n)),b(i)||(t.defaultConnectionPoint=ta(i)),b(r)||(t.defaultAnchor=ta(r)),b(o)||(t.defaultLinkAnchor=ta(o)),y(l)&&(t.interactive=T({},l)),y(s)&&(t.highlighting=Ys({},s,Ad))},children:function(){var t=R.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:al("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:al("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers.viewsMap},getLayerView(t){var{viewsMap:e}=this._layers;if(t in e)return e[t];throw new Error(`dia.Paper: Unknown layer "${t}".`)},getLayerNode(t){return this.getLayerView(t).el},_removeLayer(t){this._unregisterLayer(t),t.remove()},_unregisterLayer(t){var{viewsMap:e,namesMap:n,order:i}=this._layers,r=this._getLayerName(t);i.splice(i.indexOf(r),1),delete n[t.cid],delete e[r]},_registerLayer(t,e,n){var{viewsMap:i,namesMap:r,order:o}=this._layers;n?(n=this._getLayerName(n),o.splice(o.indexOf(n),0,t)):o.push(t),r[(i[t]=e).cid]=t},_getLayerView(t){var{namesMap:e,viewsMap:n}=this._layers;return t instanceof ud?t.cid in e?t:null:t in n?n[t]:null},_getLayerName(t){var{namesMap:e}=this._layers;return e[t.cid]},_requireLayerView(t){var e=this._getLayerView(t);if(e)return e;throw t instanceof ud?new Error("dia.Paper: The layer is not registered."):new Error(`dia.Paper: Unknown layer "${t}".`)},hasLayer(t){return null!==this._getLayerView(t)},removeLayer(t){t=this._requireLayerView(t);if(!t.isEmpty())throw new Error("dia.Paper: The layer is not empty.");this._removeLayer(t)},addLayer(t,e,n={}){if(!t||"string"!=typeof t)throw new Error("dia.Paper: The layer name must be provided.");if(this._getLayerView(t))throw new Error(`dia.Paper: The layer "${t}" already exists.`);if(!(e instanceof ud))throw new Error("dia.Paper: The layer view is not an instance of dia.PaperLayer.");var n=n.insertBefore;n?(n=this._requireLayerView(n),this._registerLayer(t,e,n),this.layers.insertBefore(e.el,n.el)):(this._registerLayer(t,e,null),this.layers.appendChild(e.el))},moveLayer(t,e){var n,t=this._requireLayerView(t);t!==this._getLayerView(e)&&(n=this._getLayerName(t),this._unregisterLayer(t),this.addLayer(n,t,{insertBefore:e}))},getLayerNames(){return this._layers.order.slice()},getLayers(){return this.getLayerNames().map(t=>this.getLayerView(t))},render:function(){this.renderChildren();var{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:e,defs:r,layers:o}=e;return t.style.position="relative",e.style.overflow=n.overflow?"visible":"hidden",this.svg=e,this.defs=r,this.layers=o,this.renderLayers(),R.ensureId(e),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&R(this.svg).prepend(R.createSVGStyle(t))},createLayer(t){return t!==hd.GRID?new ud({name:t}):new bd({name:t,paper:this,patterns:this.constructor.gridPatterns})},renderLayer:function(t){var e=this.createLayer(t);return this.addLayer(t,e),e},renderLayers:function(t=Pd){this.removeLayers(),t.forEach(({name:t})=>this.renderLayer(t));var t=this.getLayerView(hd.CELLS),e=this.getLayerView(hd.TOOLS),n=this.getLayerView(hd.LABELS);this.tools=e.el,this.cells=this.viewport=t.el,t.vel.addClass(al("viewport")),n.vel.addClass(al("viewport")),t.el.style.webkitUserSelect="none",t.el.style.userSelect="none",n.el.style.webkitUserSelect="none",n.el.style.userSelect="none"},removeLayers:function(){var{viewsMap:t}=this._layers;Object.values(t).forEach(t=>this._removeLayer(t))},resetLayers:function(){var{viewsMap:t}=this._layers;Object.values(t).forEach(t=>t.removePivots())},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){var i=this.matrix();return void 0===t?R.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){var{a:i,d:r,e:o,f:s}=this.matrix();return(t=Math.max(t||0,this.MIN_SCALE))===i&&t===r||(o=R.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t),this.matrix(o,n)),this},translate:function(t,e,n){var i=this.matrix();return void 0===t?R.matrixToTranslate(i):(e=e||0,i.e===(t=t||0)&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e={}){var n,i,r,o,s,a,l=this.layers;return void 0===t?(n=l.getAttribute("transform"),(this._viewportTransformString||null)===n?t=this._viewportMatrix:(t=l.getCTM(),this._viewportMatrix=t,this._viewportTransformString=n),R.createSVGMatrix(t)):(n=this.matrix(),t=R.createSVGMatrix(t),r=this._viewportTransformString,(i=R.matrixToTransformString(t))===r||!r&&R.matrixToTransformString()===i||({a:r,d:o,e:s,f:a}=t,l.setAttribute("transform",i),this._viewportMatrix=t,this._viewportTransformString=l.getAttribute("transform"),r===n.a&&o===n.d||this.trigger("scale",r,o,e),s===n.e&&a===n.f||this.trigger("translate",s,a,e),this.trigger("transform",t,e)),this)},clientMatrix:function(){return R.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof p)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a,l=r[o],h=this.findViewByModel(l);h&&(a=["UPDATE"],l.getTargetCell()===i&&a.push("TARGET"),l.getSourceCell()===i&&a.push("SOURCE"),l=Math.max(e+1,h.UPDATE_PRIORITY),this.scheduleViewUpdate(h,h.getFlag(a),l,n))}},forcePostponedViewUpdate:function(t,e){if(t&&t instanceof p){var n=t.model;if(!n.isElement()&&0==(e&t.getFlag(["SOURCE","TARGET"]))){var e={silent:!0},i=0,r=this.findViewByModel(n.getSourceCell()),r=(r&&!this.isViewMounted(r)&&(i=this.dumpView(r,e),t.updateEndMagnet("source")),0),n=this.findViewByModel(n.getTargetCell());if(n&&!this.isViewMounted(n)&&(r=this.dumpView(n,e),t.updateEndMagnet("target")),0===i&&0===r)return!this.dumpView(t,e)}}return!1},requestViewUpdate:function(t,e,n,i){this.scheduleViewUpdate(t,e,n,i=i||{});t=this.isAsync();this.isFrozen()||t&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES)||(e=this.updateViews(i),t&&this.notifyAfterRender(e,i))},scheduleViewUpdate:function(t,e,n,i){var{_updates:r,options:o}=this,{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:h}=(r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze()),t);let u=r.priorities[n];if(u=u||(r.priorities[n]={}),l<n)for(let t=n-1;t>=l;t--){var c=r.priorities[t];c&&h in c&&(u[h]|=c[h],delete c[h])}var d=u[h]||0;(d&e)!==e&&(d||r.count++,e&s&&d&a?u[h]^=a:e&a&&d&s&&(u[h]^=s),u[h]|=e,"function"==typeof(a=o.onViewUpdate))&&a.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){var e,n;return t?(n=this._updates,e=t.cid,n=n.priorities[t.UPDATE_PRIORITY],t=this.registerMountedView(t)|n[e],delete n[e],t):0},dumpView:function(t,e={}){var n,i=this.dumpViewUpdate(t);return i?((n=!e.silent)&&this.notifyBeforeRender(e),i=this.updateView(t,i,e),n&&(n={updated:1,priority:t.UPDATE_PRIORITY},this.notifyAfterRender(n,e)),i):0},updateView:function(t,e,n){if(!t)return 0;var{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof p){if(e&i)return this.removeView(s),0;e&r&&((i=!!(e&o))&&(e^=o),this.insertView(t,i),e^=r)}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){t=this.findViewByModel(t);return t?(this.dumpView(t,e),t):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;return e in n.unmounted?0:(t=n.unmounted[e]|=t.FLAG_INSERT,n.unmountedCids.push(e),delete n.mounted[e],t)},registerMountedView:function(t){var t=t.cid,e=this._updates;if(t in e.mounted)return 0;e.mounted[t]=!0,e.mountedCids.push(t);var n=e.unmounted[t]||0;return delete e.unmounted[t],n},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){t=$s({},t,{viewport:null});this.checkViewport(t),this.updateViews(t)},updateViews:function(t){var e;this.notifyBeforeRender(t);let n=0,i=0,r=wd;for(;i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r),!e.empty;);var o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){var t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;0<n&&n--;)for(var i in t[e[n]])return!0;return!1},updateViewsAsync:function(e,n){e=e||{},n=n||{processed:0,priority:wd};var{_updates:i,options:r}=this,o=i.id;if(o){Tl(o),0===n.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(e);var s=this.updateViewsBatch(e),a=$s({},e,{mountBatchSize:1e3-s.mounted,unmountBatchSize:1e3-s.unmounted}),a=this.checkViewport(a),l=a.unmounted,a=a.mounted;let t=n.processed;var h=i.count,l=(0<s.updated?(t+=s.updated+s.unmounted,s.processed=t,n.priority=Math.min(s.priority,n.priority),s.empty&&0===a?(s.unmounted+=l,s.mounted+=a,s.priority=n.priority,this.notifyAfterRender(s,e),n.processed=0,n.priority=wd,i.count=0):n.processed=t):i.idle||r.autoFreeze&&(this.freeze(),i.idle=!0,this.trigger("render:idle",e)),e.progress);if(h&&"function"==typeof l&&l.call(this,s.empty,t,h,s,this),i.id!==o)return}if(i.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");i.id=El(this.updateViewsAsync,this,e,n)},notifyBeforeRender:function(t={}){let e=t.beforeRender;"function"!=typeof e&&"function"!=typeof(e=this.options.beforeRender)||e.call(this,t,this)},notifyAfterRender:function(t,e={}){let n=e.afterRender;"function"==typeof(n="function"!=typeof n?this.options.afterRender:n)&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){var e=(t=t||{}).batchSize||1/0,n=this._updates,i=0,r=0,o=0,s=0,a=wd,l=!0,h=this.options,u=n.priorities,c=("viewport"in t?t:h).viewport,d=("function"!=typeof c&&(c=null),h.onViewPostponed),f=("function"!=typeof d&&(d=null),Object.keys(u));t:for(var p=0,g=f.length;p<g;p++){var m,v=+f[p],y=u[v];for(m in y){if(e<=i){l=!1;break t}var b=Lu[m];if(b){var x=y[m];if(0==(x&b.FLAG_REMOVE)){var w=m in n.unmounted;if(b.DETACHABLE&&c&&!c.call(this,b,!w,this)){w||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[m]|=x,delete y[m],o++;continue}w&&(x|=b.FLAG_INSERT,s++),x|=this.registerMountedView(b)}w=this.updateView(b,x,t);0<w&&(y[m]=w,!d||!d.call(this,b,w,this)||y[m])?(r++,l=!1):(v<a&&(a=v),i++,delete y[m])}else delete y[m]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){for(var t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n),r=0;r<n;r++)i[r]=Lu[e[r]];return i},getMountedViews:function(){for(var t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n),r=0;r<n;r++)i[r]=Lu[e[r]];return i},checkUnmountedViews:function(t,e){for(var n=0,e=("function"!=typeof t&&(t=null),"mountBatchSize"in(e=e||{})?e.mountBatchSize:1/0),i=this._updates,r=i.unmountedCids,o=i.unmounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&(l=Lu[h])&&(l.DETACHABLE&&t&&!t.call(this,l,!1,this)?r.push(h):(n++,(h=this.registerMountedView(l))&&this.scheduleViewUpdate(l,h,l.UPDATE_PRIORITY,{mounting:!0})))}return r.splice(0,s),n},checkMountedViews:function(t,e){e=e||{};var n=0;if("function"==typeof t){for(var e=("unmountBatchSize"in e?e.unmountBatchSize:1/0),i=this._updates,r=i.mountedCids,o=i.mounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&(l=Lu[h])&&(!l.DETACHABLE||t.call(this,l,!0,this)?r.push(h):(n++,this.registerUnmountedView(l)&&this.detachView(l)))}r.splice(0,s)}return n},checkViewVisibility:function(e,n={}){let t=("viewport"in n?n:this.options).viewport;"function"!=typeof t&&(t=null);var i,n=this._updates,{mounted:r,unmounted:o}=n,s=!e.DETACHABLE||!t||t.call(this,e,!1,this);let a=!1,l=!1;if(e.cid in r&&!s){let t=this.registerUnmountedView(e);t&&this.detachView(e);var r=n.mountedCids.indexOf(e.cid);n.mountedCids.splice(r,1),a=!0}return!a&&e.cid in o&&s&&(r=n.unmountedCids.indexOf(e.cid),n.unmountedCids.splice(r,1),(i=this.registerMountedView(e))&&this.scheduleViewUpdate(e,i,e.UPDATE_PRIORITY,{mounting:!0}),l=!0),{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e,t=$s({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n=("viewport"in t?t:this.options).viewport,i=this.checkMountedViews(n,t);return 0<i&&(e=this._updates.unmountedCids,t.mountBatchSize=Math.min(e.length-i,t.mountBatchSize)),{mounted:this.checkUnmountedViews(n,t),unmounted:i}},freeze:function(t){var e=this._updates,t=(t=t||{}).key,n=this.options.frozen,i=e.freezeKey;if(t&&t!==i){if(n&&i)return;e.freezeKey=t,e.keyFrozen=n}this.options.frozen=!0;i=e.id;e.id=null,this.isAsync()&&i&&Tl(i)},unfreeze:function(t){var e=this._updates,n=(t=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===xd.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,t=t.height;return{width:e=qs(e)?e:this.el.clientWidth,height:t=qs(t)?t:this.el.clientHeight}},setDimensions:function(t,e,n={}){var i=this.options,{width:r,height:o}=i,t=void 0===t?r:t,e=void 0===e?o:e;r===t&&o===e||(i.width=t,i.height=e,this._setDimensions(),r=this.getComputedSize(),this.trigger("resize",r.width,r.height,n))},_setDimensions:function(){var t=this.options;let e=t.width,n=t.height;qs(e)&&(e=Math.round(e)+"px"),qs(n)&&(n=Math.round(n)+"px"),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=w(t)?t:T({gridWidth:t,gridHeight:e,padding:n},i);var{x:t,y:e,width:n,height:r}=this.getFitToContentArea(i),{sx:o,sy:s}=this.scale();return this.translate(-t*o,-e*s,i),this.setDimensions(n*o,r*s,i),new tt(t,e,n,r)},getFitToContentArea:function(t={}){var e=t.gridWidth||1,n=t.gridHeight||1,i=Ol(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,h="contentArea"in t?new tt(t.contentArea):this.getContentArea(t),{sx:u,sy:c}=this.scale();h.x*=u,h.y*=c,h.width*=u,h.height*=c;let d=Math.ceil((h.width+h.x)/e),f=Math.ceil((h.height+h.y)/n),p=(t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n,0),g=(("negative"===l&&h.x<0||"positive"===l&&0<=h.x||"any"===l)&&(p=Math.ceil(-h.x/e)*e,p+=i.left,d+=p),0);return("negative"===l&&h.y<0||"positive"===l&&0<=h.y||"any"===l)&&(g=Math.ceil(-h.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 tt(-p/u,-g/c,d/u,f/c)},transformToFitContent:function(o){o=o||{};let s,a;if(a="contentArea"in o?(l=o.contentArea,s=this.localToPaperRect(l),new A(l)):(s=this.getContentBBox(o),this.paperToLocalPoint(s)),s.width&&s.height){$s(o,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});var l=Ol(o.padding),h=o.minScaleX||o.minScale,u=o.maxScaleX||o.maxScale,c=o.minScaleY||o.minScale,d=o.maxScaleY||o.maxScale;let t;t=o.fittingBBox||(p=this.translate(),g=this.getComputedSize(),{x:p.tx,y:p.ty,width:g.width,height:g.height}),t=new tt(t).moveAndExpand({x:l.left,y:l.top,width:-l.left-l.right,height:-l.top-l.bottom});var f,p=this.matrix(),{a:g,d:l,e:m,f:v}=p;let e=t.width/s.width*g,n=t.height/s.height*l;o.preserveAspectRatio&&(e=n=Math.min(e,n)),o.scaleGrid&&(f=o.scaleGrid,e=f*Math.floor(e/f),n=f*Math.floor(n/f)),e=Math.min(u,Math.max(h,e)),n=Math.min(d,Math.max(c,n));const y=e/g,b=n/l;let i=t.x-a.x*e-m,r=t.y-a.y*n-v;switch(o.verticalAlign){case"middle":r+=(t.height-s.height*b)/2;break;case"bottom":r+=t.height-s.height*b}switch(o.horizontalAlign){case"middle":i+=(t.width-s.width*y)/2;break;case"right":i+=t.width-s.width*y}p.a=e,p.d=n,p.e=i,p.f=r,this.matrix(p,o)}},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new tt:R(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(...t){var e=this.options.restrictTranslate;let n;return n=b(e)?e.apply(this,t):!0===e?this.getArea():e?new tt(e):null},createViewForModel:function(t){var e,n=this.options,i=n.cellViewNamespace,r=t.get("type")+"View",i=pl(i,r,"."),r=t.isLink()?(e=n.linkView,yd):(e=n.elementView,vd);return new(e.prototype instanceof Eu?i||e:e.call(this,t)||i||r)({model:t,interactive:n.interactive,labelsLayer:!0===n.labelsLayer?hd.LABELS:n.labelsLayer})},removeView:function(t){var e,n,t=t.id,{_views:i,_updates:r}=this,o=i[t];return o&&(e=o.cid,{mounted:r,unmounted:n}=r,o.remove(),delete i[t],delete r[e],delete n[e]),o},renderView:function(t,e){var n=t.id,i=this._views;let r,o,s=!0;return n in i&&((r=i[n]).model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&((r=i[n]=this.createViewForModel(t)).paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(S(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();var 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(){Xs(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")),n=this.model.get("cells");Nl(t,function(t,e){t=n.get(t.getAttribute("model-id")),e=n.get(e.getAttribute("model-id")),t=t.attributes.z||0,e=e.attributes.z||0;return t===e?0:t<e?-1:1})},insertView:function(t,e){var{el:n,model:i}=t,r=i.get("layer")||this.DEFAULT_CELL_LAYER,r=this.getLayerView(r);this.options.sorting===xd.APPROX?r.insertSortedNode(n,i.get("z")):(xd,r.insertNode(n)),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){t=E(t)?this.cells.querySelector(t):t instanceof L?t[0]:t,t=this.findAttribute("model-id",t);if(t)return this._views[t]},findViewByModel:function(t){t=E(t)||qs(t)?t:t&&t.id;return this._views[t]},findViewsFromPoint:function(e){return e=new A(e),this.model.getElements().map(this.findViewByModel,this).filter(function(t){return t&&t.vel.getBBox({target:this.cells}).containsPoint(e)},this)},findViewsInArea:function(e,t){t=$s(t||{},{strict:!1}),e=new tt(e);var n=this.model.getElements().map(this.findViewByModel,this),i=t.strict?"containsRect":"intersect";return n.filter(function(t){return t&&e[i](t.vel.getBBox({target:this.cells}))},this)},findElementViewsInArea(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findElementsInArea(t,e),e)},findLinkViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findLinksInArea(t,e),e)},findCellViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findCellsInArea(t,e),e)},findElementViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findElementsInArea(t),e)},findLinkViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findLinksInArea(t),e)},findCellViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findCellsInArea(t),e)},_findInExtendedArea:function(t,e,n={}){var{buffer:i=this.DEFAULT_FIND_BUFFER}=n;return e(new tt(t).inflate(i),n).map(t=>this.findViewByModel(t))},_filterViewsInArea:function(t,e,n={}){let i=new tt(t);return this._findInExtendedArea(i,e,n).filter(t=>!!t&&t.isInArea(i,n))},_filterViewsAtPoint:function(e,t,n={}){var i=new tt(e);return this._findInExtendedArea(i,t,n).filter(t=>!!t&&t.isAtPoint(e,n))},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){t=new A(t,e);return R.transformPoint(t,this.matrix())},localToPaperRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix())},paperToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix().inverse())},localToClientPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix())},localToClientRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.clientMatrix())},clientToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,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){t=new A(t,e).difference(this.pageOffset());return this.paperToLocalPoint(t)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),t=new tt(t,e,n,i);return t.x-=r.x,t.y-=r.y,this.paperToLocalRect(t)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new A(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){var e,n,i,r;if(t instanceof yd)return e=t.model,n=this.options,r=(i=this.model).constructor.validations,!(!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));throw new Error("Must provide a linkView.")},getDefaultLink:function(t,e){return b(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t={}){let{highlighter:e,type:n}=t;var{highlighting:t,highlighterNamespace:i}=this.options;if(void 0===e){if(!t)return!1;if(n&&!1===(e=t[n]))return!1;e=e||t.default}if(!e)return!1;t=(e=E(e)?{name:e}:e).name,i=i[t];if(!i)throw new Error('Unknown highlighter ("'+t+'")');if("function"!=typeof i.highlight)throw new Error('Highlighter ("'+t+'") is missing required highlight() method');if("function"!=typeof i.unhighlight)throw new Error('Highlighter ("'+t+'") is missing required unhighlight() method');return{highlighter:i,options:e.options||{},name:t}},onCellHighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.highlight(t,e,i))},onCellUnhighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.unhighlight(t,e,i))},pointerdblclick:function(t){t.preventDefault(),t=k(t);var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.pointerdblclick(t,e.x,e.y):this.trigger("blank:pointerdblclick",t,e.x,e.y))},pointerclick:function(t){var e,n;this.eventData(t).mousemoved<=this.options.clickThreshold&&(t=k(t),e=this.findView(t.target),this.guard(t,e)||(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=k(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.contextmenu(t,e.x,e.y):this.trigger("blank:contextmenu",t,e.x,e.y))},pointerdown:function(t){var{target:e,button:n}=t=k(t),i=this.findView(e),n=2===n;if(i){if(!n&&this.guard(t,i))return;var r=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName),r=(this.options.preventDefaultViewAction&&!r&&t.preventDefault(),r&&i.preventDefaultInteraction(t),this.customEventTrigger(t,i));if(r){if(r.isPropagationStopped())return;t.data=r.data}r=e.closest("[magnet]");if(r&&i.el!==r&&i.el.contains(r)){var e=k(new L.Event(t.originalEvent,{data:t.data,currentTarget:r}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped())return n?void 0:void this.delegateDragEvents(i,e.data);t.data=e.data}}n?(this.contextMenuFired=!0,r=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data}),this.contextMenuTrigger(r)):(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,n,i=this.eventData(t);i.mousemoved||(i.mousemoved=0,this.undelegateEvents()),++i.mousemoved<=this.options.moveThreshold||(t=k(t),e=this.snapToGrid(t.clientX,t.clientY),(n=i.sourceView)?n.pointermove(t,e.x,e.y):this.trigger("blank:pointermove",t,e.x,e.y),this.eventData(t,i))},pointerup:function(t){this.undelegateDocumentEvents();var e=k(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 L.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=k(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseover(t):this.el!==t.target&&this.trigger("blank:mouseover",t))},mouseout:function(t){t=k(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseout(t):this.el!==t.target&&this.trigger("blank:mouseout",t))},mouseenter:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=k(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseenter(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseenter",t)}},mouseleave:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=k(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseleave(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseleave",t)}},_processMouseWheelEvtBuf:ia(function(){var{event:t,deltas:e}=this._mw_evt_buffer,e=e.reduce((t,e)=>t+Al(e,50),0),e=Math.pow(.995,e),{x:n,y:i}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,n,i,e),this._mw_evt_buffer={event:null,deltas:[]}},20,{maxWait:20}),mousewheel:function(t){t=k(t);var e,n,i,r,o,s=this.findView(t.target);this.guard(t,s)||(e=t.originalEvent,n=this.snapToGrid(e.clientX,e.clientY),{deltaX:i,deltaY:r}=wl(e),o=this._events["paper:pinch"],t.ctrlKey&&o&&0<o.length?(e.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(r),this._processMouseWheelEvtBuf()):(o=Math.max(-1,Math.min(1,e.wheelDelta)),s?s.mousewheel(t,n.x,n.y,o):this.trigger("blank:mousewheel",t,n.x,n.y,o),this.trigger("paper:pan",t,i,r)))},onevent:function(t){var e,n=t.currentTarget,i=n.getAttribute("event");i&&(n=this.findView(n))&&(t=k(t),this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n.onevent(t,i,e.x,e.y)))},magnetEvent:function(t,e){var n,i,r=t.currentTarget;r.getAttribute("magnet")&&(n=this.findView(r))&&(t=k(t),this.guard(t,n)||(i=this.snapToGrid(t.clientX,t.clientY),e.call(this,n,t,r,i.x,i.y)))},onmagnet:function(t){var e;2===t.button?(this.contextMenuFired=!0,this.magnetContextMenuFired=!0,e=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget}),this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()):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&&(t=k(t),!this.guard(t,n))){e=this.customEventTrigger(t,n,e);if(e){if(e.isPropagationStopped())return;t.data=e.data}e=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,e.x,e.y)}},getPointerArgs(t){var t=k(t),{x:e,y:n}=this.snapToGrid(t.clientX,t.clientY);return[t,e,n]},delegateDragEvents:function(t,e){this.eventData({data:e=e||{}},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){return"mousedown"===t.type&&2===t.button||!(!this.options.guard||!this.options.guard(t,e))||(t.data&&void 0!==t.data.guarded?t.data.guarded:(t=t.target,!!this.GUARDED_TAG_NAMES.includes(t.tagName)||!(e&&e.model&&e.model instanceof Oh||this.el===t||this.svg.contains(t))))},setGridSize:function(t){var e=this.options;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(hd.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(hd.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",t=t.size||"auto auto",n=this.scale(),i=this.translate(),i=(w(e)&&(e=i.tx+n.sx*(e.x||0)+"px "+(i.ty+n.sy*(e.y||0))+"px"),w(t)&&(t=(t=new tt(t).scale(n.sx,n.sy)).width+"px "+t.height+"px"),this.childNodes).background;i.style.backgroundSize=t,i.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[pa(r)];if(b(a)){t.width*=s,t.height*=s;a=a(t,e);if(!(a instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=a.toDataURL("image/png"),r="repeat",w(i)?(i.width*=a.width/t.width,i.height*=a.height/t.height):void 0===i&&(e.size={width:a.width/s,height:a.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){var e;return this.updateBackgroundColor((t=t||{}).color),t.image?(t=this._background=ta(t),xl(t),(e=document.createElement("img")).onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image):(this.drawBackgroundImage(null),this._background=null),this},setInteractivity:function(t){this.options.interactive=t,Xs(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!w(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name,e=e||n+this.svg.id+fl(JSON.stringify(t));if(!this.isDefined(e)){var i=Vl,i=i[n]&&i[n](t.args||{});if(!i)throw new Error("Non-existing filter "+n);n=T({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});R(i,n).appendTo(this.defs)}return e},defineGradient:function(t){var e,n,i,r;if(w(t))return{svg:n,defs:e}=this,{type:r,id:n=r+n.id+fl(JSON.stringify(t)),stops:t,attrs:i={}}=t,this.isDefined(n)||(t=et(t).map(({offset:t,color:e,opacity:n})=>R("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1})),(r=R(r,i,t)).id=n,r.appendTo(e)),n;throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.")},definePattern:function(t){if(!w(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e,{svg:n,defs:i}=this,{id:n=n.id+fl(JSON.stringify(t)),markup:t,attrs:r={}}=t;if(t)return this.isDefined(n)||((e=R("pattern",{patternUnits:"userSpaceOnUse"})).id=n,e.attr(r),"string"==typeof t?e.append(R(t)):(r=dl(t).fragment,e.append(r)),e.appendTo(i)),n;throw new TypeError("dia.Paper: definePattern() requires markup.")},defineMarker:function(t){if(!w(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");var{svg:e,defs:n}=this,{id:e=e.id+fl(JSON.stringify(t)),markup:o,attrs:s={},markerUnits:a="userSpaceOnUse"}=t;if(!this.isDefined(e)){a=R("marker",{orient:"auto",overflow:"visible",markerUnits:a});a.id=e,a.attr(s);let i;if(o){let t;t="string"==typeof o?(t=R(o),Array.isArray(t)?t:[t]):(s=dl(o).fragment,R(s).children()),i=1<t.length?R("g").append(t):t[0]}else{var{type:o="path"}=t;i=R(o)}let r=ca(t,"type","id","markup","attrs","markerUnits");Object.keys(r).forEach(t=>{var e=r[t],n=i.attr(t);null==n?i.attr(t,e):"transform"===t&&i.attr(t,e+" "+n)}),i.appendTo(a),a.appendTo(n)}return e},customEventTrigger:function(t,e,n=e.el){var i=t.target.closest("[event]");return i&&n!==i&&e.el.contains(i)?(n=k(new L.Event(t.originalEvent,{data:t.data,currentTarget:i})),this.onevent(n),n.isDefaultPrevented()&&t.preventDefault(),n):null}},{sorting:xd,Layers:hd,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height,r=(e.width=2*n,e.height=2*i,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,r=(e.width=2*n,e.height=i,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,r=(e.width=n,e.height=2*i,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||{};for(var n=t.width,i=t.height,r=document.createElement("canvas"),o=(r.width=3*n,r.height=3*i,r.getContext("2d")),e=qs(e.watermarkAngle)?-e.watermarkAngle:-20,s=Zn(e),a=r.width/4,l=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)0<(h+u)%2&&(o.setTransform(1,0,0,1,(2*h-1)*a,(2*u-1)*l),o.rotate(s),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({fill:e.color})},update:function(t,e,n){var{sx:n,sy:i}=n.scale(),n=n<=1?e.thickness:e.thickness/n,e=i<=1?e.thickness:e.thickness/i;R(t).attr({width:n,height:e})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}]}}),ku.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,_visibleExplicit:!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},updateVisibility:function(){var t=this.computeVisibility();this.el.style.display=t?"":"none",this._visible=t},computeVisibility(){var t;return!!this.isExplicitlyVisible()&&(t=this.options.visibility,"function"!=typeof t||!!t.call(this,this.relatedView,this))},show:function(){this._visibleExplicit=!0,this.updateVisibility()},hide:function(){this._visibleExplicit=!1,this.updateVisibility()},isExplicitlyVisible:function(){return!!this._visibleExplicit},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){var{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}}));function Td(t,e){var n=t.model;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}function Sd(t,e,n){return tc.call(this.paper,{},e,n,t,this.model).anchor}n=ku.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=T(this.options,t)).tools;if(Array.isArray(e)){var n=t.relatedView;if(n instanceof p){for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof Ed&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS"))}}return this},getName:function(){return this.options.name},update:function(e){e=e||{};var n=this.tools;if(n){var i=n.length,t=this.isRendered;for(let t=0;t<i;t++){var r=n[t];r.updateVisibility(),r.isVisible()&&this.ensureToolRendered(n,t)&&e.tool!==r.cid&&r.update()}!this.isRendered&&0<i||(this.isMounted()||this.mount(),t)||this.blurTool()}return this},ensureToolRendered(t,e){return this.isRendered||(this.isRendered=Array(t.length).fill(!1)),!(!this.isRendered[e]&&(t[e].render(),this.isRendered[e]=!0))},focusTool:function(t){var e=this.tools;if(e)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)for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isExplicitlyVisible()||(r.show(),r.isVisible()&&this.ensureToolRendered(e,n)&&r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null),this.isMounted()||this.mount(),this},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(){var{options:t,el:e}=this,{relatedView:t,layer:n=hd.TOOLS,z:i}=t;return t&&(n?t.paper.getLayerView(n).insertSortedNode(e,i):t.el.appendChild(e)),this}}),s={__proto__:null,Cell:Oh,CellView:p,Element:f,ElementView:vd,Graph:ld,HighlighterView:Gu,LayersNames:hd,Link:Zh,LinkView:yd,Paper:l,PaperLayer:ud,ToolView:Ed,ToolsView:n,attributes:Mh},r=ku.extend({tagName:"circle",svgElement:!0,className:"marker-vertex",events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onDoubleClick",dbltap:"onDoubleClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},attributes:{r:6,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move"},position:function(t,e){var{vel:n,options:i}=this,i=i.scale;let r=R.createSVGMatrix().translate(t,e);i&&(r=r.scale(i)),n.transform(r,{absolute:!0})},onPointerDown:function(t){this.options.guard(t)||(t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.trigger("will-change",this,t))},onPointerMove:function(t){this.trigger("changing",this,t)},onDoubleClick:function(t){this.trigger("remove",this,t)},onPointerUp:function(t){this.trigger("changed",this,t),this.undelegateDocumentEvents(),this.options.paper.delegateEvents()}}),o=Ed.extend({name:"vertices",options:{handleClass:r,snapRadius:20,redundancyRemoval:!0,vertexAdding:!0,stopPropagation:!0,scale:null},children:[{tagName:"path",selector:"connection",className:"joint-vertices-path",attributes:{fill:"none",stroke:"transparent","stroke-width":10,cursor:"cell"}}],handles:null,interactiveLinkNode:null,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},linkEvents:{mousedown:"onLinkPointerDown",touchstart:"onLinkPointerDown"},onRender:function(){var t=this.options.vertexAdding;return t&&({interactiveLinkNode:t=null}=t,t?this.delegateLinkEvents(t):(this.renderChildren(),this.updatePath())),this.resetHandles(),this.renderHandles(),this},delegateLinkEvents:function(t){this.undelegateLinkEvents();var e=this.relatedView.findNode(t);e?(e.classList.add("joint-vertices-path"),this.interactiveLinkNode=e,this.delegateElementEvents(e,this.linkEvents)):console.warn(`Interactive link node "${t}" not found.`)},undelegateLinkEvents:function(){var t=this.interactiveLinkNode;t&&(this.undelegateElementEvents(t),t.classList.remove("joint-vertices-path"),this.interactiveLinkNode=null)},update:function(){return this.relatedView.model.vertices().length===this.handles.length?this.updateHandles():(this.resetHandles(),this.renderHandles()),this.options.vertexAdding&&this.updatePath(),this},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},renderHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=new this.options.handleClass({index:e,paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});r.render(),r.position(i.x,i.y),this.simulateRelatedView(r.el),r.vel.appendTo(this.el),this.handles.push(r),this.startHandleListening(r)}},updateHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=this.handles[e];if(!r)return;r.position(i.x,i.y)}},updatePath:function(){var t;this.interactiveLinkNode||(t=this.childNodes.connection)&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var{vertexRemoving:e=!0,vertexMoving:n=!0}=this.options;n&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),e&&this.listenTo(t,"remove",this.onHandleRemove)},getNeighborPoints:function(t){var e=this.relatedView,n=e.model.vertices(),i=0<t?n[t-1]:e.sourceAnchor,n=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:new A(i),next:new A(n)}},onHandleWillChange:function(t,e){this.focus();var{relatedView:n,options:i}=this;n.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerdown(...n.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var{options:n,relatedView:i}=this,r=t.options.index,[e,o,s]=i.paper.getPointerArgs(e),a={x:o,y:s};this.snapVertex(a,r),i.model.vertex(r,a,{ui:!0,tool:this.cid}),t.position(a.x,a.y),n.stopPropagation||i.notifyPointermove(e,o,s)},onHandleChanged:function(t,e){var{options:n,relatedView:i}=this,[e,r,o]=(n.vertexAdding&&this.updatePath(),n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid})&&this.render(),this.blur(),i.model.stopBatch("vertex-move",{ui:!0,tool:this.cid}),this.eventData(e).vertexAdded&&i.model.stopBatch("vertex-add",{ui:!0,tool:this.cid}),i.paper.getPointerArgs(e));n.stopPropagation||i.notifyPointerup(e,r,o),i.checkMouseleave(e)},snapVertex:function(t,e){var n,i,r=this.options.snapRadius;0<r&&(n=(e=this.getNeighborPoints(e)).prev,i=e.next,Math.abs(t.x-n.x)<r?t.x=n.x:Math.abs(t.x-i.x)<r&&(t.x=i.x),Math.abs(t.y-n.y)<r?t.y=e.prev.y:Math.abs(t.y-i.y)<r&&(t.y=i.y))},onHandleRemove:function(t,e){var t=t.options.index,n=this.relatedView;n.model.removeVertex(t,{ui:!0}),this.options.vertexAdding&&this.updatePath(),n.checkMouseleave(k(e))},onPathPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),t=k(t),e=this.paper.snapToGrid(t.clientX,t.clientY).toJSON(),(i=this.relatedView).model.startBatch("vertex-add",{ui:!0,tool:this.cid}),n=i.getVertexIndex(e.x,e.y),this.snapVertex(e,n),i.model.insertVertex(n,e,{ui:!0,tool:this.cid}),this.update(),i=this.handles[n],this.eventData(t,{vertexAdded:!0}),i.onPointerDown(t))},onLinkPointerDown:function(t){this.relatedView.preventDefaultInteraction(t),this.onPathPointerDown(t)},onRemove:function(){this.resetHandles(),this.undelegateLinkEvents()}},{VertexHandle:r}),a=ku.extend({tagName:"g",svgElement:!0,className:"marker-segment",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},children:[{tagName:"line",selector:"line",attributes:{stroke:"#33334F","stroke-width":2,fill:"none","pointer-events":"none"}},{tagName:"rect",selector:"handle",attributes:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2}}],onRender:function(){this.renderChildren()},position:function(t,e,n,i){var r=this.options.scale;let o=R.createSVGMatrix().translate(t,e).rotate(n);r&&(o=o.scale(r));r=this.childNodes.handle,r.setAttribute("transform",R.matrixToTransformString(o)),r.setAttribute("cursor",n%180==0?"row-resize":"col-resize"),r=i.getClosestPoint(new A(t,e)),n=this.childNodes.line;n.setAttribute("x1",t),n.setAttribute("y1",e),n.setAttribute("x2",r.x),n.setAttribute("y2",r.y)},onPointerDown:function(t){this.options.guard(t)||(this.trigger("change:start",this,t),t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data))},onPointerMove:function(t){this.trigger("changing",this,t)},onPointerUp:function(t){this.undelegateDocumentEvents(),this.options.paper.delegateEvents(),this.trigger("change:end",this,t)},show:function(){this.el.style.display=""},hide:function(){this.el.style.display="none"}}),u=Ed.extend({name:"segments",precision:.5,options:{handleClass:a,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:Sd,snapRadius:10,snapHandle:!0,stopPropagation:!0},handles:null,onRender:function(){this.resetHandles();var t=this.relatedView,e=t.model.vertices();e.unshift(t.sourcePoint),e.push(t.targetPoint);for(var n=0,i=e.length;n<i-1;n++){var r=e[n],o=e[n+1],r=this.renderHandle(r,o);this.simulateRelatedView(r.el),this.handles.push(r),r.options.index=n}return this},renderHandle:function(t,e){var n=new this.options.handleClass({paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});return n.render(),this.updateHandle(n,t,e),n.vel.appendTo(this.el),this.startHandleListening(n),n},update:function(){return this.render(),this},startHandleListening:function(t){this.listenTo(t,"change:start",this.onHandleChangeStart),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"change:end",this.onHandleChangeEnd)},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},shiftHandleIndexes:function(t){for(var e=this.handles,n=0,i=e.length;n<i;n++)e[n].options.index+=t},resetAnchor:function(t,e){var n=this.relatedView.model;e?n.prop([t,"anchor"],e,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([t,"anchor"],{ui:!0,tool:this.cid})},snapHandle:function(t,e,n){var i=t.options.index,r=this.relatedView.model.vertices(),t=t.options.axis,o=r[i-2]||n.sourceAnchor,r=r[i+1]||n.targetAnchor,i=this.options.snapRadius;return Math.abs(e[t]-o[t])<i?e[t]=o[t]:Math.abs(e[t]-r[t])<i&&(e[t]=r[t]),e},onHandleChanging:function(t,e){var n=this.options,i=this.eventData(e),r=this.relatedView,o=r.paper,s=t.options.index-1,e=k(e),o=o.snapToGrid(e.clientX,e.clientY),a=this.snapHandle(t,o.clone(),i),l=t.options.axis,h=this.options.snapHandle?0:o[l]-a[l],u=r.model,c=ta(u.vertices()),d=this.options.anchor,f=("function"!=typeof d&&(d=null),t.options.index),p=[r.sourcePoint.clone(),...c,r.targetPoint.clone()];let g=0;0<=f-1&&(m=p[f-1],v=p[f],new P(m,v).vector().theta()%90!=0)&&(c.splice(f-1,0,i.originalVertices[f-1]),g++,this.shiftHandleIndexes(1));var m=c[s+g],v=c[1+s+g],y=(f+2<p.length&&(b=p[f+1],p=p[f+2],new P(b,p).vector().theta()%90!=0)&&(b=1===i.originalVertices.length,p=i.firstHandleShifted&&!b?1:0,y=1+g,c.splice(f+y,0,i.originalVertices[(b?0:f)-p])),r.sourceView),b=r.sourceBBox,f=!1,p=!1,b=(m?0==s?b.containsPoint(m)?(c.shift(),this.shiftHandleIndexes(-1),f=!0):(m[l]=a[l],p=!0):m[l]=a[l]:((m=r.sourceAnchor.toJSON())[l]=a[l],b.containsPoint(m)?(m[l]=a[l],f=!0):(c.unshift(m),this.shiftHandleIndexes(1),p=i.firstHandleShifted=!0)),d&&y&&(f&&((b=i.sourceAnchor.clone())[l]=a[l],f=d.call(r,b,y,r.sourceMagnet||y.el,"source",r),this.resetAnchor("source",f)),p)&&this.resetAnchor("source",i.sourceAnchorDef),r.targetView),y=r.targetBBox,f=!1,p=!1;if(v?s==c.length-2?y.containsPoint(v)?(c.pop(),f=!0):(v[l]=a[l],p=!0):v[l]=a[l]:((v=r.targetAnchor.toJSON())[l]=a[l],y.containsPoint(v)?f=!0:(c.push(v),p=!0)),d&&b&&(f&&((s=i.targetAnchor.clone())[l]=a[l],y=d.call(r,s,b,r.targetMagnet||b.el,"target",r),this.resetAnchor("target",y)),p)&&this.resetAnchor("target",i.targetAnchorDef),c.some(t=>!t))throw new Error("Segments: incompatible router in use");u.vertices(c,{ui:!0,tool:this.cid}),this.updateHandle(t,m,v,h),n.stopPropagation||r.notifyPointermove(e,o.x,o.y)},onHandleChangeStart:function(t,e){var{options:n,handles:i,relatedView:r}=this,{model:o,paper:s}=r,a=t.options.index;if(Array.isArray(i)){for(var l=0,h=i.length;l<h;l++)l!==a&&i[l].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:Qs(o.prop(["source","anchor"])),targetAnchorDef:Qs(o.prop(["target","anchor"])),originalVertices:ta(o.vertices()),firstHandleShifted:!1}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||r.notifyPointerdown(...s.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var{options:n,relatedView:i}=this,{paper:r,model:o}=i,e=(n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid}),k(e)),r=r.snapToGrid(e.clientX,e.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerup(e,r.x,r.y),i.checkMouseleave(e)},updateHandle:function(t,e,n,i){var r=Math.abs(e.x-n.x)<this.precision,o=Math.abs(e.y-n.y)<this.precision;!r&&!o||(o=new P(e,n)).length()<this.options.segmentLengthThreshold?t.hide():((e=o.midpoint())[n=r?"x":"y"]+=i||0,r=o.vector().vectorAngle(new A(1,0)),t.position(e.x,e.y,r,this.relatedView),t.show(),t.options.axis=n)},onRemove:function(){this.resetHandles()}},{SegmentHandle:a}),i=Ed.extend({tagName:"path",xAxisVector:new A(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=this.ratio,n=this.relatedView,i=n.getTangentAtRatio(e),i=i?(t=i.start,i.vector().vectorAngle(this.xAxisVector)||0):(t=n.getPointAtRatio(e),0);return t&&(n=R.createSVGMatrix().translate(t.x,t.y).rotate(i),e=this.options.scale,e&&(n=n.scale(e)),this.vel.transform(n,{absolute:!0})),this},onPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n=(e=this.relatedView).paper,e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),i=t.data||(t.data={}),this.delegateDocumentEvents(null,i),n.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none",e.notifyPointerdown(...n.getPointerArgs(t)))},onPointerMove:function(t){var t=k(t),e=this.paper.snapToGrid(t.clientX,t.clientY);this.relatedView.pointermove(t,e.x,e.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,t=k(t),i=n.snapToGrid(t.clientX,t.clientY);e.pointerup(t,i.x,i.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),hn=i.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"}}),C=i.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"}}),f=Ed.extend({tagName:"g",type:null,children:[{tagName:"circle",selector:"anchor",attributes:{cursor:"pointer"}},{tagName:"rect",selector:"area",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{snap:function(t,e,n,i,r,o){return o=o.options.snapRadius,i="source"===i,(i=this.model.vertex(i?0:-1)||this.getEndAnchor(i?"target":"source"))&&(Math.abs(i.x-t.x)<o&&(t.x=i.x),Math.abs(i.y-t.y)<o)&&(t.y=i.y),t},anchor:Sd,scale:null,resetAnchor:!0,customAnchorAttributes:{"stroke-width":4,stroke:"#33334F",fill:"#FFFFFF",r:5},defaultAnchorAttributes:{"stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6},areaPadding:6,snapRadius:10,restrictArea:!0,redundancyRemoval:!0},onRender:function(){this.renderChildren(),this.toggleArea(!1),this.update()},update:function(){var t=this.type;return this.relatedView.getEndView(t)?(this.updateAnchor(),this.updateArea(),this.el.style.display=""):this.el.style.display="none",this},updateAnchor:function(){var t=this.childNodes;if(t){var s=t.anchor;if(s){let t=this.relatedView,e=this.type,n=t.getEndAnchor(e),i=this.options,r=t.model.prop([e,"anchor"]),o=`translate(${n.x},${n.y})`;i.scale&&(o+=` scale(${i.scale})`),s.setAttribute("transform",o);var a,l=r?i.customAnchorAttributes:i.defaultAnchorAttributes;for(a in l)s.setAttribute(a,l[a])}}},updateArea:function(){var t,e,n,i,r,o,s,a=this.childNodes;a&&(a=a.area)&&(n=this.relatedView,i=this.type,e=(t=n.getEndView(i)).model,n=n.getEndMagnet(i),i=this.options.areaPadding,isFinite(i)||(i=0),t.isNodeConnection(n)?(o=0,s=(r=t.getNodeBBox(n)).center()):(r=t.getNodeUnrotatedBBox(n),o=e.angle(),s=r.center(),o&&s.rotate(e.getCenter(),-o)),r.inflate(i),a.setAttribute("x",-r.width/2),a.setAttribute("y",-r.height/2),a.setAttribute("width",r.width),a.setAttribute("height",r.height),a.setAttribute("transform","translate("+s.x+","+s.y+") rotate("+o+")"))},toggleArea:function(t){var e=this.childNodes;e&&(e=e.area)&&(e.style.display=t?"":"none")},onPointerDown:function(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),this.paper.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleArea(this.options.restrictArea),this.relatedView.model.startBatch("anchor-move",{ui:!0,tool:this.cid}))},resetAnchor:function(t){var e=this.type,n=this.relatedView.model;t?n.prop([e,"anchor"],t,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([e,"anchor"],{ui:!0,tool:this.cid})},onPointerMove:function(t){var e,n,i,r=this.relatedView,o=this.type,s=r.getEndView(o),a=s.model,l=r.getEndMagnet(o),t=k(t),t=this.paper.clientToLocalPoint(t.clientX,t.clientY),h=this.options.snap,h=("function"==typeof h&&(t=h.call(r,t,s,l,o,r,this),t=new A(t)),this.options.restrictArea&&(s.isNodeConnection(l)?(h=s.getClosestPoint(t))&&(t=h):(h=s.getNodeUnrotatedBBox(l),e=a.angle(),a=a.getCenter(),n=t.clone().rotate(a,e),h.containsPoint(n)||(t=h.pointNearestToPoint(n).rotate(a,-e)))),this.options.anchor);"function"==typeof h&&(i=h.call(r,t,s,l,o,r)),this.resetAnchor(i),this.update()},onPointerUp:function(t){var t=k(t),e=(this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1),this.relatedView);this.options.redundancyRemoval&&e.removeRedundantLinearVertices({ui:!0,tool:this.cid}),e.checkMouseleave(t),e.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(!0===t&&(t=null),this.resetAnchor(ta(t)),this.update())}}),l=f.extend({name:"source-anchor",type:"source"}),n=f.extend({name:"target-anchor",type:"target"});let _d=Ed.extend({tagName:"g",children:[{tagName:"circle",selector:"handle",attributes:{cursor:"pointer","stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6}},{tagName:"rect",selector:"extras",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{handleAttributes:null,selector:"root",padding:6,scale:null},getPosition:function(){},setPosition:function(){},resetPosition:function(){},onRender:function(){this.renderChildren(),this.toggleExtras(!1),this.update()},update:function(){var{handle:t,extras:e}=this.childNodes;if(t)return this.updateHandle(t),e&&this.updateExtras(e),this;throw new Error("Control: markup selector `handle` is required")},updateHandle:function(t){var{relatedView:e,options:n}=this,i=e.model,e=this.getPosition(e,this),i=i.getAbsolutePointFromRelative(e),{handleAttributes:r,scale:e}=n;let o=`translate(${i.x},${i.y})`;if(e&&(o+=` scale(${e})`),t.setAttribute("transform",o),r)for(var s in r)t.setAttribute(s,r[s])},updateExtras:function(e){var{relatedView:n,options:i}=this,r=this.options.selector;if(r){r=n.findNode(r);if(!r)throw new Error("Control: invalid selector.");let t=i.padding;isFinite(t)||(t=0);var i=n.getNodeUnrotatedBBox(r),r=n.model,n=r.angle(),o=i.center();n&&o.rotate(r.getCenter(),-n),i.inflate(t),e.setAttribute("x",-i.width/2),e.setAttribute("y",-i.height/2),e.setAttribute("width",i.width),e.setAttribute("height",i.height),e.setAttribute("transform",`translate(${o.x},${o.y}) rotate(${n})`)}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var{relatedView:e,paper:n}=this;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleExtras(!0),e.model.startBatch("control-move",{ui:!0,tool:this.cid}))},onPointerMove:function(t){var{relatedView:e,paper:n}=this,i=e.model,{clientX:r,clientY:o}=k(t),n=n.clientToLocalPoint(r,o),r=i.getRelativePointFromAbsolute(n);this.setPosition(e,r,t),this.update()},onPointerUp:function(t){var{relatedView:e,paper:n}=this;n.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(t){var e=this.relatedView;this.resetPosition(e,t),this.update()}}),Ld=(r=_d.extend({xAxisVector:new A(1,0),children(){var{buttonColor:t="#333",iconColor:e="#fff",outlineColor:n="#fff"}=this.options;return[{selector:"handle",tagName:"g",attributes:{cursor:"grab"},children:[{tagName:"circle",attributes:{r:10,fill:t,stroke:n}},{tagName:"path",attributes:{d:"M -5 0 A 5 5 0 1 1 0 5",fill:"transparent",stroke:e,strokeWidth:2,strokeLinecap:"round"}},{tagName:"path",attributes:{d:"M -3 5 L 0 2.5 0 7.5 Z",fill:e,stroke:e,strokeWidth:1,transform:"rotate(-5, -3, 5)"}}]}]},getPosition(t){var{offset:e=0}=this.options,{x:e=0,y:n=0}="number"==typeof e?{x:0,y:e}:e,i=this.getLabel(),i=this.getLabelPosition(i),r=t.getLabelCoordinates(i);let{angle:o=0,args:s={}}=i;s.keepGradient&&(i=t.getTangentAtRatio(t.getClosestPointRatio(r)))&&(o+=i.vector().vectorAngle(this.xAxisVector)||0);t=(new DOMMatrix).translate(r.x,r.y).rotate(o).translate(e,n);return new A(t.e,t.f)},computeVisibility(){return _d.prototype.computeVisibility.apply(this,arguments)&&!!this.getLabel()},setPosition(t,e){var n=t.model,i=this.getLabel();i&&(i=this.getLabelPosition(i),t=90-t.getLabelCoordinates(i).theta(e),i=this.getLabelIndex(),n.prop(["labels",i,"position","angle"],t))},resetPosition(t){var t=t.model,e=this.getLabelIndex();t.prop(["labels",e,"position","angle"],0)},getLabelIndex(){return this.options.labelIndex||0},getLabel(){return this.relatedView.model.label(this.getLabelIndex())||null},getLabelPosition(t){var e=this.relatedView,t=e._normalizeLabelPosition(t.position);return e._mergeLabelPositionProperty(t,e._getDefaultLabelPositionProperty())}}),a=Ed.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(){var t=this.vel;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){var{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=Td(t,o);var e=t.model.angle(),{x:t=0,y:h=0}=(s||(l=l.bbox(e)),r);Sl(n)?n=parseFloat(n)/100*l.width:ph(n)&&(n=Number(vh(n,l))),Sl(i)?i=parseFloat(i)/100*l.height:ph(i)&&(i=Number(vh(i,l)));let u=R.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return u=(u=s?u.rotate(e):u).translate(n+t-l.width/2,i+h-l.height/2),u=a?u.scale(a):u},getLinkMatrix(){var{relatedView:t,options:e}=this,{offset:e=0,distance:n=0,rotate:i,scale:r}=e,n="function"==typeof n?n.call(this,t,this):n;let o,s,a,l=(o=Sl(n)?t.getTangentAtRatio(parseFloat(n)/100):t.getTangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=t.getConnection().start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,e));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},onPointerDown:function(t){var e;this.guard(t)||(t.stopPropagation(),t.preventDefault(),"function"==typeof(e=this.options.action)&&e.call(this.relatedView,t,this.relatedView,this))}}),i=a.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})}}}),f=Ed.extend({name:"boundary",tagName:"rect",options:{padding:10,useModelGeometry:!1},attributes:{fill:"none",stroke:"#33334F","stroke-width":.5,"stroke-dasharray":"5, 5","pointer-events":"none"},onRender:function(){this.update()},update:function(){var{relatedView:t,options:e,vel:n}=this,{useModelGeometry:i,rotate:r}=e,e=Ol(e.padding);let o=Td(t,i).moveAndExpand({x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}),s=t.model,a,l;return s.isElement()&&(a=s.angle())&&(r?(l=s.getCenter(),n.rotate(a,l.x,l.y,{absolute:!0})):o=o.bbox(a)),n.attr(o.toJSON()),this}}),a.extend({name:"connect",documentEvents:{mousemove:"drag",touchmove:"drag",mouseup:"dragend",touchend:"dragend",touchcancel:"dragend"},children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2,"pointer-events":"none"}}],options:{distance:80,offset:0,magnet:t=>t.el,action:(t,e,n)=>n.dragstart(t)},getMagnetNode:function(){var{options:t,relatedView:e}=this,n=t.magnet;let i;switch(typeof n){case"function":i=n.call(this,e,this);break;case"string":i=e.findNode(n);break;default:i=n}if((i=i||e.el)instanceof SVGElement)return i;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var{paper:e,relatedView:n}=this,t=k(t),{x:i,y:r}=e.clientToLocalPoint(t.clientX,t.clientY);n.dragLinkStart(t,this.getMagnetNode(),i,r),e.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.focus()},drag:function(t){var{paper:e,relatedView:n}=this,t=k(t),{x:e,y:i}=e.snapToGrid(t.clientX,t.clientY);n.dragLink(t,e,i)},dragend:function(t){var{paper:e,relatedView:n}=this,t=k(t),{x:i,y:r}=e.snapToGrid(t.clientX,t.clientY);n.dragLinkEnd(t,i,r),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),n.checkMouseleave(t)}}));var kd=Ld.extend({name:"hover-connect",defaultMarkup:[{tagName:"circle",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2}}],children(){var{options:t,defaultMarkup:e}=this;return[{tagName:"path",selector:"track",attributes:{fill:"none",stroke:"transparent","stroke-width":t.trackWidth||15,cursor:"pointer"}},{tagName:"g",selector:"button",attributes:{"pointer-events":"none",display:"none"},children:t.markup||e}]},events:Object.assign({mousemove:"onMousemove",mouseenter:"onMouseenter",mouseleave:"onMouseleave"},Ld.prototype.events),onRender:function(){this.renderChildren(),this.update()},trackPath:null,update(){var t=this.childNodes;this.trackPath=this.getTrackPath(),Ld.prototype.update.apply(this,arguments),t.track.setAttribute("d",this.trackPath.serialize())},position(){var{el:t,childNodes:e}=this;e.button.setAttribute("transform",R.matrixToTransformString(this.getButtonMatrix())),t.setAttribute("transform",R.matrixToTransformString(this.getTrackMatrix()))},getButtonMatrix(){var{options:t,trackPath:e}=this,{offset:t=0,distance:n=0,rotate:i,scale:r}=t;let o,s,a,l=(o=Sl(n)?e.tangentAtRatio(parseFloat(n)/100):e.tangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=e.start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,t));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},getTrackPath(){return this.relatedView.getConnection()},getTrackMatrix(){return R.createSVGMatrix()},getTrackRatioFromEvent(t){var{relatedView:e,trackPath:n}=this,e=e.paper.clientToLocalPoint(t.clientX,t.clientY),t=R.transformPoint(e,this.getTrackMatrix().inverse());return n.closestPointLength(t)},canShowButton(){return L.event.has(this.paper.el)},showButton(){this.childNodes.button.style.display="block"},hideButton(){this.childNodes.button.style.display=""},onMousemove(t){var e=this.trackPath;e&&(e=this.options,e.distance=this.getTrackRatioFromEvent(t),this.position())},onMouseenter(){this.canShowButton()&&this.showButton()},onMouseleave(){this.hideButton()}}),r={__proto__:null,Boundary:f,Button:a,Connect:Ld,Control:_d,HoverConnect:kd,Remove:i,RotateLabel:r,Segments:u,SourceAnchor:l,SourceArrowhead:C,TargetAnchor:n,TargetArrowhead:hn,Vertices:o},u=kd.extend({getTrackPath(){var{relatedView:t,options:e}=this;let{useModelGeometry:n,trackPath:i="M 0 0 H calc(w) V calc(h) H 0 Z"}=e;return ph(i="function"==typeof i?i.call(this,t):i)&&(e=Td(t,n),i=vh(i,e)),new V(R.normalizePathData(i))},getTrackMatrix(){var{relatedView:t,options:e}=this,{useModelGeometry:e,rotate:n}=e;let i=Td(t,e);e=t.model.angle();n||(i=i.bbox(e));let r=R.createSVGMatrix().translate(i.x+i.width/2,i.y+i.height/2);return r=(r=n?r.rotate(e):r).translate(-i.width/2,-i.height/2)}}),l={__proto__:null,Boundary:f,Button:a,Connect:Ld,Control:_d,HoverConnect:u,Remove:i},C=R,n={PortLabel:Xh,Port:Gh};return t.V=R,t.Vectorizer=C,t.anchors=h,t.config=hl,t.connectionPoints=Je,t.connectionStrategies=ec,t.connectors=Tu,t.dia=s,t.elementTools=l,t.env=Jh,t.format={},t.g=yr,t.highlighters=Ke,t.layout=n,t.linkAnchors=nd,t.linkTools=r,t.mvc=e,t.routers=Kc,t.setTheme=function(t,e){e=e||{},Xs(Lu,"setTheme",t,e),ku.prototype.defaultTheme=t},t.shapes=Ue,t.ui={},t.util=Zr,t.version="4.2.0-alpha.0",t})({});void 0!==joint&&(g=joint.g,V=joint.V,Vectorizer=joint.V);
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
var g,V,Vectorizer,joint=(t=>{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function M(t,e){return t(e={exports:{}},e.exports),e.exports}function N(t){return t&&t.Math==Math&&t}function O(t){try{return!!t()}catch(t){return!0}}function V(t){return St(_t(t))}function F(e,n){try{jt(yt,e,n)}catch(t){yt[e]=n}return n}function D(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++qt+$t).toString(36)}function z(t){return Wt[t]||(Wt[t]=D(t))}function j(t){return"function"==typeof t?t:void 0}function G(t,e){return arguments.length<2?j(Jt[t])||j(yt[t]):Jt[t]&&Jt[t][e]||yt[t]&&yt[t][e]}function U(t){return 0<t?ee(te(t),9007199254740991):0}function H(a){return function(t,e,n){var i,r=V(t),o=U(r.length),s=((t,e)=>(t=te(t))<0?ne(t+e,0):ie(t,e))(n,o);if(a&&e!=e){for(;s<o;)if((i=r[s++])!=i)return!0}else for(;s<o;s++)if((a||s in r)&&r[s]===e)return a||s||0;return!a&&-1}}function q(t,e){var n,i=V(t),r=0,o=[];for(n in i)!Mt(Yt,n)&&Mt(i,n)&&o.push(n);for(;e.length>r;)!Mt(i,n=e[r++])||~re(o,n)||o.push(n);return o}function $(t,e){return(t=de[ce(t)])==pe||t!=fe&&("function"==typeof e?O(e):!!e)}function W(t,e){var n,i,r,o=t.target,s=t.global,a=t.stat,l=s?yt:a?yt[o]||F(o,{}):(yt[o]||{}).prototype;if(l)for(n in e){if(i=e[n],r=t.noTargetGet?(r=me(l,n))&&r.value:l[n],!ge(s?n:o+(a?".":"#")+n,t.forced)&&void 0!==r){if(typeof i==typeof r)continue;g=p=f=d=c=u=h=void 0;for(var h=i,u=r,c=he(u),d=zt.f,f=Ft.f,p=0;p<c.length;p++){var g=c[p];Mt(h,g)||d(h,g,f(u,g))}}(t.sham||r&&r.sham)&&jt(i,"sham",!0),Zt(l,n,i,t)}}function Y(t){return Mt(ye,t)||(ve&&Mt(be,t)?ye[t]=be[t]:ye[t]=we("Symbol."+t)),ye[t]}function X(){}function Z(t){Ne[Me][t]=!0}function J(t){throw t}function K(t,e){var n,i,r,o;return Mt(Re,t)?Re[t]:(n=[][t],i=!!Mt(e=e||{},"ACCESSORS")&&e.ACCESSORS,r=Mt(e,0)?e[0]:J,o=Mt(e,1)?e[1]:void 0,Re[t]=!!n&&!O(function(){if(i&&!bt)return 1;var t={length:-1};i?Oe(t,1,{enumerable:!0,get:J}):t[1]=1,n.call(t,r,o)}))}function Q(i,r,t){if(Ie(i),void 0===r)return i;switch(t){case 0:return function(){return i.call(r)};case 1:return function(t){return i.call(r,t)};case 2:return function(t,e){return i.call(r,t,e)};case 3:return function(t,e,n){return i.call(r,t,e,n)}}return function(){return i.apply(r,arguments)}}function nt(t,e,n){return Q(Fe,yt[t].prototype[e],n)}function it(t){return Object(_t(t))}function rt(t,e){var n;return new(void 0===(n=Be(t)&&("function"==typeof(n=t.constructor)&&(n===Array||Be(n.prototype))||Lt(n)&&null===(n=n[De]))?void 0:n)?Array:n)(0===e?0:e)}function ot(d){var f=1==d,p=2==d,g=3==d,m=4==d,v=6==d,y=7==d,b=5==d||v;return function(t,e,n,i){for(var r,o,s=it(t),a=St(s),l=Q(e,n,3),h=U(a.length),u=0,e=i||rt,c=f?e(t,h):p||y?e(t,0):void 0;u<h;u++)if((b||u in a)&&(o=l(r=a[u],u,s),d))if(f)c[u]=o;else if(o)switch(d){case 3:return!0;case 5:return r;case 6:return u;case 2:ze.call(c,r)}else switch(d){case 4:return!1;case 7:ze.call(c,r)}return v?-1:g||m?m:c}}function st(r){return function(t,e){var n,t=String(_t(t)),e=te(e),i=t.length;return e<0||i<=e?r?"":void 0:(n=t.charCodeAt(e))<55296||56319<n||e+1===i||(i=t.charCodeAt(e+1))<56320||57343<i?r?t.charAt(e):n:r?t.slice(e,e+2):i-56320+(n-55296<<10)+65536}}function at(){return this}var lt,ht,ut,ct,dt,ft,pt,gt,mt,vt,yt=N("object"==typeof globalThis&&globalThis)||N("object"==typeof window&&window)||N("object"==typeof self&&self)||N("object"==typeof e&&e)||function(){return this}()||Function("return this")(),bt=!O(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),e={}.propertyIsEnumerable,wt=Object.getOwnPropertyDescriptor,xt={f:wt&&!e.call({1:2},1)?function(t){t=wt(this,t);return!!t&&t.enumerable}:e},At=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Pt={}.toString,Tt=function(t){return Pt.call(t).slice(8,-1)},Et="".split,St=O(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==Tt(t)?Et.call(t,""):Object(t)}:Object,_t=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},Lt=function(t){return"object"==typeof t?null!==t:"function"==typeof t},kt=function(t,e){if(!Lt(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t))||"function"==typeof(n=t.valueOf)&&!Lt(i=n.call(t))||!e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},Ct={}.hasOwnProperty,Mt=function(t,e){return Ct.call(t,e)},Nt=yt.document,Ot=Lt(Nt)&&Lt(Nt.createElement),Rt=function(t){return Ot?Nt.createElement(t):{}},Vt=!bt&&!O(function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a}),It=Object.getOwnPropertyDescriptor,Ft={f:bt?It:function(t,e){if(t=V(t),e=kt(e,!0),Vt)try{return It(t,e)}catch(t){}if(Mt(t,e))return At(!xt.f.call(t,e),t[e])}},Bt=function(t){if(Lt(t))return t;throw TypeError(String(t)+" is not an object")},Dt=Object.defineProperty,zt={f:bt?Dt:function(t,e,n){if(Bt(t),e=kt(e,!0),Bt(n),Vt)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},jt=bt?function(t,e,n){return zt.f(t,e,At(1,n))}:function(t,e,n){return t[e]=n,t},Gt=yt[e="__core-js_shared__"]||F(e,{}),Ut=Function.toString,Ht=("function"!=typeof Gt.inspectSource&&(Gt.inspectSource=function(t){return Ut.call(t)}),Gt.inspectSource),e="function"==typeof(e=yt.WeakMap)&&/native code/.test(Ht(e)),n=M(function(t){(t.exports=function(t,e){return Gt[t]||(Gt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),qt=0,$t=Math.random(),Wt=n("keys"),Yt={},i=yt.WeakMap,Xt=(pt=e?(lt=Gt.state||(Gt.state=new i),ht=lt.get,ut=lt.has,ct=lt.set,dt=function(t,e){return e.facade=t,ct.call(lt,t,e),e},ft=function(t){return ht.call(lt,t)||{}},function(t){return ut.call(lt,t)}):(gt=z("state"),Yt[gt]=!0,dt=function(t,e){return e.facade=t,jt(t,gt,e),e},ft=function(t){return Mt(t,gt)?t[gt]:{}},function(t){return Mt(t,gt)}),{set:dt,get:ft,has:pt,enforce:function(t){return pt(t)?ft(t):dt(t,{})},getterFor:function(e){return function(t){if(Lt(t)&&(t=ft(t)).type===e)return t;throw TypeError("Incompatible receiver, "+e+" required")}}}),Zt=M(function(t){var e=Xt.get,a=Xt.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,s=!!i&&!!i.enumerable,i=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||Mt(n,"name")||jt(n,"name",e),(r=a(n)).source||(r.source=l.join("string"==typeof e?e:""))),t===yt?s?t[e]=n:F(e,n):(o?!i&&t[e]&&(s=!0):delete t[e],s?t[e]=n:jt(t,e,n))})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Ht(this)})}),Jt=yt,Kt=Math.ceil,Qt=Math.floor,te=function(t){return isNaN(t=+t)?0:(0<t?Qt:Kt)(t)},ee=Math.min,ne=Math.max,ie=Math.min,re=(e={includes:H(!0),indexOf:H(!1)}).indexOf,oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],se=oe.concat("length","prototype"),ae={f:Object.getOwnPropertyNames||function(t){return q(t,se)}},le={f:Object.getOwnPropertySymbols},he=G("Reflect","ownKeys")||function(t){var e=ae.f(Bt(t)),n=le.f;return n?e.concat(n(t)):e},ue=/#|\.prototype\./,ce=$.normalize=function(t){return String(t).replace(ue,".").toLowerCase()},de=$.data={},fe=$.NATIVE="N",pe=$.POLYFILL="P",ge=$,me=Ft.f,ve=!!Object.getOwnPropertySymbols&&!O(function(){return!String(Symbol())}),i=ve&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=n("wks"),be=yt.Symbol,we=i?be:be&&be.withoutSetter||D,xe=Object.keys||function(t){return q(t,oe)},Ae=bt?Object.defineProperties:function(t,e){Bt(t);for(var n,i=xe(e),r=i.length,o=0;o<r;)zt.f(t,n=i[o++],e[n]);return t},Pe=G("document","documentElement"),Te=">",Ee="<",Se="prototype",_e="script",Le=z("IE_PROTO"),ke=function(t){return Ee+_e+Te+t+Ee+"/"+_e+Te},Ce=function(){try{mt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}Ce=mt?((t=mt).write(ke("")),t.close(),e=t.parentWindow.Object,t=null,e):(t=Rt("iframe"),e="java"+_e+":",t.style.display="none",Pe.appendChild(t),t.src=String(e),(e=t.contentWindow.document).open(),e.write(ke("document.F=Object")),e.close(),e.F);for(var t,e,n=oe.length;n--;)delete Ce[Se][oe[n]];return Ce()},n=(Yt[Le]=!0,Object.create||function(t,e){var n;return null!==t?(X[Se]=Bt(t),n=new X,X[Se]=null,n[Le]=t):n=Ce(),void 0===e?n:Ae(n,e)}),Me=Y("unscopables"),Ne=Array.prototype,Oe=(null==Ne[Me]&&zt.f(Ne,Me,{configurable:!0,value:n(null)}),Object.defineProperty),Re={},Ve=e.includes,i=K("indexOf",{ACCESSORS:!0,1:0}),Ie=(W({target:"Array",proto:!0,forced:!i},{includes:function(t){return Ve(this,t,1<arguments.length?arguments[1]:void 0)}}),Z("includes"),function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}),Fe=Function.call,Be=(nt("Array","includes"),Array.isArray||function(t){return"Array"==Tt(t)}),De=Y("species"),ze=[].push,je=(e={forEach:ot(0),map:ot(1),filter:ot(2),some:ot(3),every:ot(4),find:ot(5),findIndex:ot(6),filterOut:ot(7)}).find,Ge=!0,Ue=K(i="find"),Ue=(i in[]&&Array(1)[i](function(){Ge=!1}),W({target:"Array",proto:!0,forced:Ge||!Ue},{find:function(t){return je(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(i),nt("Array","find"),{codeAt:st(!1),charAt:st(!0)}),i=!O(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),He=z("IE_PROTO"),qe=Object.prototype,i=i?Object.getPrototypeOf:function(t){return t=it(t),Mt(t,He)?t[He]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?qe:null},$e=Y("iterator"),r=!1,We=([].keys&&("next"in(We=[].keys())?(We=i(i(We)))!==Object.prototype&&(vt=We):r=!0),null==vt||O(function(){var t={};return vt[$e].call(t)!==t})),We=(Mt(vt=We?{}:vt,$e)||jt(vt,$e,function(){return this}),{IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:r}),Ye=zt.f,Xe=Y("toStringTag"),r=function(t,e,n){t&&!Mt(t=n?t:t.prototype,Xe)&&Ye(t,Xe,{configurable:!0,value:e})},Ze={},Je=We.IteratorPrototype,o=function(){return this},Ke=Object.setPrototypeOf||("__proto__"in{}?(()=>{var n,i=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),i=t instanceof Array}catch(t){}return function(t,e){return Bt(t),(t=>{if(Lt(t)||null===t)return;throw TypeError("Can't set "+String(t)+" as a prototype")})(e),i?n.call(t,e):t.__proto__=e,t}})():void 0),s=We.IteratorPrototype,Qe=We.BUGGY_SAFARI_ITERATORS,We=Y("iterator"),tn="values",en="entries",nn=Ue.charAt,rn="String Iterator",on=Xt.set,sn=Xt.getterFor(rn),Ue=String,an=function(t){on(this,{type:rn,string:String(t),index:0})},a=function(){var t=sn(this),e=t.string,n=t.index;return n>=e.length?{value:void 0,done:!0}:(e=nn(e,n),t.index+=e.length,{value:e,done:!1})},ln=void 0,hn=void 0,l=void 0;function un(t){if(t===ln&&mn)return mn;if(!Qe&&t in pn)return pn[t];switch(t){case"keys":case tn:case en:return function(){return new an(this,t)}}return function(){return new an(this)}}u=Zr="String",u+=" Iterator",(C=an).prototype=n(Je,{next:At(1,a)}),r(C,u,!1,!0),Ze[u]=o;var cn,dn,a=Zr+" Iterator",fn=!1,pn=Ue.prototype,gn=pn[We]||pn["@@iterator"]||ln&&pn[ln],mn=!Qe&&gn||un(ln);if((C="Array"==Zr&&pn.entries||gn)&&(u=i(C.call(new Ue)),s!==Object.prototype)&&u.next&&(i(u)!==s&&(Ke?Ke(u,s):"function"!=typeof u[We]&&jt(u,We,at)),r(u,a,!0,!0)),ln==tn&&gn&&gn.name!==tn&&(fn=!0,mn=function(){return gn.call(this)}),pn[We]!==mn&&jt(pn,We,mn),Ze[Zr]=mn,ln)if(cn={values:un(tn),keys:hn?mn:un("keys"),entries:un(en)},l)for(dn in cn)!Qe&&!fn&&dn in pn||Zt(pn,dn,cn[dn]);else W({target:Zr,proto:!0,forced:Qe||fn},cn);function vn(t,e,n){(e=kt(e))in t?zt.f(t,e,At(0,n)):t[e]=n}var yn=function(t){var e=t.return;if(void 0!==e)return Bt(e.call(t)).value},bn=Y("iterator"),wn=Array.prototype,Je=((n={})[Y("toStringTag")]="z","[object z]"===String(n)),xn=Y("toStringTag"),An="Arguments"==Tt(function(){return arguments}()),Pn=Je?Tt:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=((t,e)=>{try{return t[e]}catch(t){}})(t=Object(t),xn))?e:An?Tt(t):"Object"==(e=Tt(t))&&"function"==typeof t.callee?"Arguments":e},Tn=Y("iterator"),En=Y("iterator"),Sn=!1;try{var _n=0,h={next:function(){return{done:!!_n++}},return:function(){Sn=!0}};h[En]=function(){return this},Array.from(h,function(){throw 2})}catch(t){}function Ln(t){if(Lt(e=t)&&(void 0!==(n=e[On])?!!n:"RegExp"==Tt(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t}function kn(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Rn]=!1,"/./"[e](n)}catch(t){}}return!1}var o=!((t,e)=>{if(!e&&!Sn)return!1;var n=!1;try{var i={};i[En]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n})(function(t){Array.from(t)}),Cn=(W({target:"Array",stat:!0,forced:o},{from:function(t){var e,n,i,r,o,s,a=it(t),t="function"==typeof this?this:Array,l=arguments.length,h=1<l?arguments[1]:void 0,u=void 0!==h,c=(t=>{if(null!=t)return t[Tn]||t["@@iterator"]||Ze[Pn(t)]})(a),d=0;if(u&&(h=Q(h,2<l?arguments[2]:void 0,2)),null!=c&&(t!=Array||void 0===(l=c)||Ze.Array!==l&&wn[bn]!==l))for(o=(r=c.call(a)).next,n=new t;!(i=o.call(r)).done;d++)s=u?((e,t,n,i)=>{try{return i?t(Bt(n)[0],n[1]):t(n)}catch(t){throw yn(e),t}})(r,h,[i.value,d],!0):i.value,vn(n,d,s);else for(n=new t(e=U(a.length));d<e;d++)s=u?h(a[d],d):a[d],vn(n,d,s);return n.length=d,n}}),Jt.Array.from,e.findIndex),Mn=!0,Ue=K(C="findIndex"),Nn=(C in[]&&Array(1)[C](function(){Mn=!1}),W({target:"Array",proto:!0,forced:Mn||!Ue},{findIndex:function(t){return Cn(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(C),nt("Array","findIndex"),M(function(t,e){function a(t){this.message=t}var l;e=e,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",(a.prototype=new Error).name="InvalidCharacterError",e.btoa||(e.btoa=function(t){for(var e,n,i=String(t),r=0,o=l,s="";i.charAt(0|r)||(o="=",r%1);s+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return s}),e.atob||(e.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)&&(s+=String.fromCharCode(255&n>>(-2*r&6))))i=l.indexOf(i);return s})}),W({target:"Number",stat:!0},{isNaN:function(t){return t!=t}}),Jt.Number.isNaN,yt.isFinite),i=Number.isFinite||function(t){return"number"==typeof t&&Nn(t)},On=(W({target:"Number",stat:!0},{isFinite:i}),Jt.Number.isFinite,Y("match")),Rn=Y("match"),Ke=(W({target:"String",proto:!0,forced:!kn("includes")},{includes:function(t){return!!~String(_t(this)).indexOf(Ln(t),1<arguments.length?arguments[1]:void 0)}}),nt("String","includes"),Ft.f),Vn="".startsWith,In=Math.min,u=!((s=kn("startsWith"))||!(r=Ke(String.prototype,"startsWith"))||r.writable);function Fn(t,e){return this.slice(t,e)}function Bn(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function Dn(t){if("number"==typeof t)for(var e=new Array(t),n=0;n<t;++n)e[n]=0;else e=t.slice(0);return e.subarray=Fn,(e.buffer=e).byteLength=e.length,e.set=Bn,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}W({target:"String",proto:!0,forced:!u&&!s},{startsWith:function(t){var e=String(_t(this)),n=(Ln(t),U(In(1<arguments.length?arguments[1]:void 0,e.length))),t=String(t);return Vn?Vn.call(e,t,n):e.slice(n,n+t.length)===t}}),nt("String","startsWith"),"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Uint8Array=Dn,window.Uint32Array=Dn,window.Int32Array=Dn);let{round:zn,floor:jn,PI:Gn}=Math;function Un(t){return 180*t/Gn%360}function Hn(t,e){var n;return void 0===e?(e=void 0===t?1:t,t=0):e<t&&(n=t,t=e,e=n),jn(Math.random()*(e-t+1)+t)}function qn(t,e){var n=Zn(t.y),i=Zn(e.y),t=t.x,e=e.x,e=Zn(e-t),t=Kn(e)*Jn(i),n=Jn(n)*Kn(i)-Kn(n)*Jn(i)*Jn(e);return(i=Un(Qn(t,n))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function $n(t,e){var n=t.x,t=t.y;return(n-=e.x)*n+(t-=e.y)*t}function Wn(t,e){return Math.sqrt($n(t,e))}let Yn=function(t){return t%360+(t<0?360:0)},Xn=function(t,e){return e*zn(t/e)},Zn=function(t,e){return(t=(e=e||!1)?t:t%360)*Gn/180},{cos:Jn,sin:Kn,atan2:Qn}=Math,c={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:ti,cos:ei,sin:ni,sqrt:ii,min:ri,max:oi,atan2:si,round:ai,pow:li,PI:hi}=Math,A=function(t,e){if(!(this instanceof A))return new A(t,e);var n;"string"==typeof t?(n=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(n[0]),e=parseFloat(n[1])):Object(t)===t&&(e=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e},ui=(A.fromPolar=function(t,e,n){n=new A(n);var i=ti(t*ei(e)),t=ti(t*ni(e)),e=Yn(Un(e));return e<90?t=-t:e<180?(i=-i,t=-t):e<270&&(i=-i),new A(n.x+i,n.y+t)},A.random=function(t,e,n,i){return new A(Hn(t,e),Hn(n,i))},A.prototype={type:c.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new A(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new A(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=ri(oi(this.x,t.x),t.x+t.width),this.y=ri(oi(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){e=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return e<0&&(e+=360),e},bearing:function(t){return qn(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new A(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 A(this.x-(t||0),this.y-(e||0))},distance:function(t){return Wn(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 A((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ii(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return ti(t.x-this.x)+ti(t.y-this.y)},move:function(t,e){t=Zn(new A(t).theta(this));return this.offset(ei(t)*e,-ni(t)*e)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},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 A(t).move(this,this.distance(t))},rotate:function(t,e){var n,i;return 0!==e&&(t=t||new A(0,0),e=Zn(Yn(-e)),n=ei(e),e=ni(e),i=n*(this.x-t.x)-e*(this.y-t.y)+t.x,e=e*(this.x-t.x)+n*(this.y-t.y)+t.y,this.x=i,this.y=e),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=li(10,t)}return this.x=ai(this.x*e)/e,this.y=ai(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new A(n)||new A(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=Xn(this.x,t),this.y=Xn(this.y,e||t),this},squaredDistance:function(t){return $n(this,t)},theta:function(t){var e=-((t=new A(t)).y-this.y),t=t.x-this.x,e=si(e,t);return 180*(e=e<0?2*hi+e:e)/hi},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new A(t)||new A(0,0);var e=this.x,n=this.y;return this.x=ii((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Zn(t.theta(new A(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 A(0,0).angleBetween(this,t)}},A.prototype.translate=A.prototype.offset,A),{max:ci,min:di}=Math,P=function(t,e){return this instanceof P?t instanceof P?new P(t.start,t.end):(this.start=new A(t),void(this.end=new A(e))):new P(t,e)},fi=(P.prototype={type:c.Line,angle:function(){var t=new A(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=di(this.start.x,this.end.x),e=di(this.start.y,this.end.y),n=ci(this.start.x,this.end.x),i=ci(this.start.y,this.end.y);return new tt(t,e,n-t,i-e)},bearing:function(){return qn(this.start,this.end)},clone:function(){return new P(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){t=this.vector().dot(new P(this.start,t).vector()),t=di(1,ci(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e,n=this.start,i=this.end;return 0===n.cross(t,i)&&(e=this.length(),!(new P(n,t).length()>e||new P(t,i).length()>e))},divideAt:function(t){t=this.pointAt(t);return[new P(this.start,t),new P(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new P(this.start,t),new P(t,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){return t&&t.intersectionWithLine?(e=t.intersectionWithLine(this,e))&&t instanceof P?e[0]:e:null},intersectionWithLine:function(t){var e=new A(this.end.x-this.start.x,this.end.y-this.start.y),n=new A(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,t=new A(t.start.x-this.start.x,t.start.y-this.start.y),n=t.x*n.y-t.y*n.x,t=t.x*e.y-t.y*e.x;if(0==i||n*i<0||t*i<0)return null;if(0<i){if(i<n||i<t)return null}else if(n<i||t<i)return null;return[new A(this.start.x+n*e.x/i,this.start.y+n*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Wn(this.start,this.end)},midpoint:function(){return new A((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e,n,i,r,o=this.clone();return this.isDifferentiable()&&({start:e,end:n}=o,i=e.clone().rotate(n,270),r=n.clone().rotate(e,90),e.move(r,t),n.move(i,t)),o},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?n:e).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new A(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();return e?this.scale(t=t/e,t,this.start):this},squaredLength:function(){return $n(this.start,this.end)},tangentAt:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAt(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},tangentAtLength:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAtLength(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},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 A(this.end.x-this.start.x,this.end.y-this.start.y)}},P.prototype.intersection=P.prototype.intersect,P),{sqrt:pi,round:gi,pow:mi}=Math,vi=function(t,e,n){return this instanceof vi?t instanceof vi?new vi(new A(t.x,t.y),t.a,t.b):(t=new A(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new vi(t,e,n)},{abs:yi,cos:bi,sin:wi,min:xi,max:Ai,round:Pi,pow:Ti}=(vi.fromRect=function(t){return t=new tt(t),new vi(t.center(),t.width/2,t.height/2)},vi.prototype={type:c.Ellipse,bbox:function(){return new tt(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new A(this.x,this.y)},clone:function(){return new vi(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,t=t.vector(),s=n.difference(new A(this)),a=new A(t.x/(r*r),t.y/(o*o)),r=new A(s.x/(r*r),s.y/(o*o)),o=t.dot(a),a=t.dot(r),t=a*a-o*(s.dot(r)-1);if(t<0)return null;if(0<t){s=pi(t),r=(-a-s)/o,t=(-a+s)/o;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&e.push(n.lerp(i,r)),0<=t&&t<=1&&e.push(n.lerp(i,t))}else{s=-a/o;if(!(0<=s&&s<=1))return null;e.push(n.lerp(i,s))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t),e&&t.rotate(new A(this.x,this.y),e);var n,i,r,o=t.x-this.x,s=t.y-this.y;return r=0==o?this.bbox().pointNearestToPoint(t):(s=(t=s/o)*t,i=this.a*this.a,n=this.b*this.b,i=pi(1/(1/i+s/n)),s=t*(i=o<0?-i:i),new A(this.x+i,this.y+s)),e?r.rotate(new A(this.x,this.y),-e):r},normalizedDistance:function(t){var e=t.x,t=t.y,n=this.a,i=this.b,r=this.x,o=this.y;return(e-r)*(e-r)/(n*n)+(t-o)*(t-o)/(i*i)},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=mi(10,t)}return this.x=gi(this.x*e)/e,this.y=gi(this.y*e)/e,this.a=gi(this.a*e)/e,this.b=gi(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,h=a.y;return a.x+o/2<i||i<a.x-o/2?n=o*o/(i-l)-o*o*(r-h)*((e=i>a.x?r-30:r+30)-h)/(s*s*(i-l))+l:e=s*s/(r-h)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-h))+h,new A(n,e).theta(t)},toString:function(){return new A(this.x,this.y).toString()+" "+this.a+" "+this.b}},a=vi,Math),tt=function(t,e,n,i){if(!(this instanceof tt))return new tt(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};function Ei(t){t=t.trim();if(""===t)return[];var e=[],n=t.split(/\b\s*,\s*|,\s*|\s+/),i=n.length;for(let t=0;t<i;t+=2)e.push({x:+n[t],y:+n[t+1]});return e}function Si(e){var n=e.length;if(0===n)return[];var i=[];for(let t=0;t<n;t++){var r=e[t].clone();i.push(r)}return i}function _i(t){var e,n=Math.abs,i=t.length;if(0===i)return[];for(o=0;o<i;o++)(void 0===e||t[o].y<e.y||t[o].y===e.y&&t[o].x>e.x)&&(e=t[o]);for(var r=[],o=0;o<i;o++){var s=e.theta(t[o]),s=(0===s&&(s=360),[t[o],o,s]);r.push(s)}r.sort(function(t,e){var n=t[2]-e[2];return n=0===n?e[1]-t[1]:n}),2<r.length&&r.unshift(r[r.length-1]);for(var a,l,h,u={},c=[];0!==r.length;)if(l=(a=r.pop())[0],!u.hasOwnProperty(a[0]+"@@"+a[1]))for(var d,f,p,g,m,v=!1;!v;)c.length<2?(c.push(a),v=!0):(f=(d=c.pop())[0],(m=(g=(p=c.pop())[0]).cross(f,l))<0?(c.push(p),c.push(d),c.push(a),v=!0):0!==m||n((m=f.angleBetween(g,l))-180)<1e-10||f.equals(l)||g.equals(f)?(u[d[0]+"@@"+d[1]]=f,c.push(p)):n((m+1)%360-1)<1e-10&&(c.push(p),r.push(d)));2<c.length&&c.pop();var y=-1,b=c.length;for(o=0;o<b;o++){var w=c[o][1];(void 0===h||w<h)&&(h=w,y=o)}var x,A,P=[],T=[];for(b=(P=0<y?(x=c.slice(y),A=c.slice(0,y),x.concat(A)):c).length,o=0;o<b;o++)T.push(P[o][0]);return T}tt.fromEllipse=function(t){return t=new vi(t),new tt(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},tt.fromPointUnion=function(...e){if(0===e.length)return null;var n=new A;let i,r,o,s;i=r=1/0,o=s=-1/0;for(let t=0;t<e.length;t++){n.update(e[t]);var a=n.x,l=n.y;a<i&&(i=a),a>o&&(o=a),l<r&&(r=l),l>s&&(s=l)}return new tt(i,r,o-i,s-r)},tt.fromRectUnion=function(...e){if(0===e.length)return null;var n=new tt;let i,r,o,s;i=r=1/0,o=s=-1/0;for(let t=0;t<e.length;t++){n.update(e[t]);var a=n.x,l=n.y,h=a+n.width,u=l+n.height;a<i&&(i=a),h>o&&(o=h),l<r&&(r=l),u>s&&(s=u)}return new tt(i,r,o-i,s-r)},tt.prototype={type:c.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var e,n,i,r;return t&&({width:i,height:e}=this,t=Zn(t),r=i*(n=yi(wi(t)))+e*(t=yi(bi(t))),this.x+=(i-(i=i*t+e*n))/2,this.y+=(e-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new A(this.x,this.y+this.height)},bottomLine:function(){return new P(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new A(this.x+this.width/2,this.y+this.height)},center:function(){return new A(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new tt(this)},containsPoint:function(t,e){let n,i;return t&&"string"!=typeof t?{x:n=0,y:i=0}=t:{x:n,y:i}=new A(t),e&&e.strict?n>this.x&&n<this.x+this.width&&i>this.y&&i<this.y+this.height:n>=this.x&&n<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var e,n,i=new tt(this).normalize(),t=new tt(t).normalize(),r=i.width,o=i.height,s=t.width,a=t.height;return!!(r&&o&&s&&a)&&(e=i.x,i=i.y,s+=n=t.x,r+=e,a+=t=t.y,o+=i,e<=n)&&s<=r&&i<=t&&a<=o},corner:function(){return new A(this.x+this.width,this.y+this.height)},equals:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize();return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.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,n=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=n.x||t.y<=n.y||r.x>=i.x||r.y>=i.y?null:(e=Ai(n.x,r.x),n=Ai(n.y,r.y),new tt(e,n,xi(i.x,t.x)-e,xi(i.y,t.y)-n))},intersectionWithLine:function(t){for(var e,n=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],o=n.length,s=0;s<o;s++)null!==(e=t.intersect(n[s]))&&r.indexOf(e.toString())<0&&(i.push(e),r.push(e.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t);for(var n,i=new A(this.x+this.width/2,this.y+this.height/2),r=(e&&t.rotate(i,e),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),o=new P(i,t),s=r.length-1;0<=s;--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 P(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new A(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){t=new tt(t);var n,i,r,o,s,a,l,h=(e=e||t.center()).x,e=e.y,u=n=i=r=o=s=a=l=1/0,c=t.topLeft(),c=(c.x<h&&(u=(this.x-h)/(c.x-h)),c.y<e&&(o=(this.y-e)/(c.y-e)),t.bottomRight()),c=(c.x>h&&(n=(this.x+this.width-h)/(c.x-h)),e<c.y&&(s=(this.y+this.height-e)/(c.y-e)),t.topRight()),c=(c.x>h&&(i=(this.x+this.width-h)/(c.x-h)),c.y<e&&(a=(this.y-e)/(c.y-e)),t.bottomLeft());return c.x<h&&(r=(this.x-h)/(c.x-h)),e<c.y&&(l=(this.y+this.height-e)/(c.y-e)),{sx:xi(u,n,i,r),sy:xi(o,s,a,l)}},maxRectUniformScaleToFit:function(t,e){t=this.maxRectScaleToFit(t,e);return xi(t.sx,t.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},moveAroundPoint:function(t,e){t=this.center().rotate(t,e);return this.x=t.x-this.width/2,this.y=t.y-this.height/2,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 A.prototype.offset.call(this,t,e)},origin:function(){return new A(this.x,this.y)},pointNearestToPoint:function(t){if(t=new A(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new A(this.x+this.width,t.y);case"left":return new A(this.x,t.y);case"bottom":return new A(t.x,this.y+this.height);case"top":return new A(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new P(this.topRight(),this.bottomRight())},rightMiddle:function(){return new A(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=Ti(10,t)}return this.x=Pi(this.x*e)/e,this.y=Pi(this.y*e)/e,this.width=Pi(this.width*e)/e,this.height=Pi(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 A(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r="left";return n<e&&(e=n,r="right"),i<e&&(e=i,r="top"),r=this.y+this.height-t.y<e?"bottom":r},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),t=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=t.x-n.x,this.height=t.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new P(this.topLeft(),this.topRight())},topMiddle:function(){return new A(this.x+this.width/2,this.y)},topRight:function(){return new A(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return tt.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}},tt.prototype.bottomRight=tt.prototype.corner,tt.prototype.topLeft=tt.prototype.origin,tt.prototype.translate=tt.prototype.offset,hn=tt;let w=function(t){return this instanceof w?"string"==typeof t?new w.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new w(t)},{abs:Li,sqrt:ki,min:Ci,max:Mi,pow:Ni}=(w.parse=function(t){return new w(Ei(t))},w.fromRect=function(t){return new w([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},w.prototype={type:c.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,a=a.y;l<t&&(t=l),e<l&&(e=l),a<n&&(n=a),i<a&&(i=a)}return new tt(t,n,e-t,i-n)},clone:function(){return new w(Si(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},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 P(n[a],n[a+1]),h=l.length(),u=l.closestPointNormalizedLength(t),l=l.pointAt(u).squaredDistance(t);l<r&&(r=l,e=o+u*h),o+=h}return e},closestPointNormalizedLength:function(t){var e,t=this.closestPointLength(t);return 0===t||0===(e=this.length())?0:t/e},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},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 P,h=new P,u=new A;s<n;s++){var c=e[o],d=e[s];if(t.equals(c))return!0;if(l.start=c,l.end=d,l.containsPoint(t))return!0;(r<=c.y&&r>d.y||r>c.y&&r<=d.y)&&0<=(c=c.x-i>d.x-i?c.x-i:d.x-i)&&(u.x=i+c,u.y=r,h.start=t,h.end=u,l.intersect(h))&&a++,o=s}return a%2==1},close:function(){var{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 w(_i(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 P(t),n=[],i=this.lengthPoints(),r=new P,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 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0!==e)for(var n=new P,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;return 0===n?null:1===n||t<=0?e[0].clone():1<=t?e[n-1].clone():(e=this.length(),this.pointAtLength(e*t))},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],a=e[a+1],h=new P(l,a),l=l.distance(a);if(t<=r+l)return h.pointAtLength((i?1:-1)*(t-r));r+=l}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(e={}){var n=this.points;if(!(n.length<3)){var i=e.threshold||1e-10;let t=0;for(;n[t+2];){var r=t,o=t+1,s=t+2,r=n[r],a=n[o],s=n[s];new P(r,s).closestPoint(a).distance(a)<=i?n.splice(o,1):t+=1}}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;1<(t=t<0?0:t)&&(t=1);e=this.length();return this.tangentAtLength(e*t)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;for(var i,r=!0,o=(t<0&&(r=!1,t=-t),0),s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,h=e[l],l=e[l+1],u=new P(h,l),h=h.distance(l);if(u.isDifferentiable()){if(t<=o+h)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=h}return i?i.tangentAt(r?1:0):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(w.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(w.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}}),Math),v=function(t,e,n,i){return this instanceof v?t instanceof v?new v(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new A(t),this.controlPoint1=new A(e),this.controlPoint2=new A(n),void(this.end=new A(i))):new v(t,e,n,i)};function Oi(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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}function Ri(t){for(var e=[],n=arguments.length,i=1;i<n;i++)e.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=e.length,i=0;i<n;i++){var o,s,a=e[i];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}v.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=(t=>{var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=Oi(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=Oi(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]})(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new A(e[0][r].x,e[0][r].y),s=new A(e[1][r].x,e[1][r].y);n.push(new v(t[r],o,s,t[r+1]))}return n},v.prototype={type:c.Curve,bbox:function(){for(var t,e,n,i,r,o=this.start,s=this.controlPoint1,a=this.controlPoint2,l=this.end,h=o.x,u=o.y,c=s.x,d=s.y,f=a.x,p=a.y,g=l.x,m=l.y,v=new Array,y=new Array,b=[new Array,new Array],w=0;w<2;++w)i=0===w?(e=6*h-12*c+6*f,t=-3*h+9*c-9*f+3*g,3*c-3*h):(e=6*u-12*d+6*p,t=-3*u+9*d-9*p+3*m,3*d-3*u),Li(t)<1e-12?Li(e)<1e-12||0<(n=-i/e)&&n<1&&y.push(n):(i=e*e-4*i*t,r=ki(i),i<0||(0<(i=(-e+r)/(2*t))&&i<1&&y.push(i),0<(i=(-e-r)/(2*t))&&i<1&&y.push(i)));for(var x,A,P=y.length,o=P;P--;)n=y[P],b[0][P]=x=(A=1-n)*A*A*h+3*A*A*n*c+3*A*n*n*f+n*n*n*g,b[1][P]=A=A*A*A*u+3*A*A*n*d+3*A*n*n*p+n*n*n*m,v[P]={X:x,Y:A};y[o]=0,y[o+1]=1,v[o]={X:h,Y:u},v[o+1]={X:g,Y:m},b[0][o]=h,b[1][o]=u,b[0][o+1]=g,b[1][o+1]=m,y.length=o+2,b[0].length=o+2,b[1].length=o+2,v.length=o+2;s=Ci.apply(null,b[0]),a=Ci.apply(null,b[1]),l=Mi.apply(null,b[0]),o=Mi.apply(null,b[1]);return new tt(s,a,l-s,o-a)},clone:function(){return new v(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,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,n),n)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.closestPointLength(t,n);return!e||0===(t=this.length(n))?0:e/t},closestPointT:function(t,e){for(var n,i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u=h.length,c=u?1/u:0,d=0;d<u;d++){var f=h[d],p=f.start.distance(t),g=f.end.distance(t),m=p+g;(!a||m<a)&&(i=d*c,r=(d+1)*c,o=p,T=g,s=(n=f).start.distance(f.end),a=m)}for(var v=Ni(10,-l);;){var y=o?Li(o-T)/o:0,b=T?Li(o-T)/T:0;if(y<v||b<v||(!o||o<s*v||(!T||T<s*v)))return o<=T?i:r;var y=n.divide(.5),b=(c/=2,y[0].start.distance(t)),w=y[0].end.distance(t),x=b+w,A=y[1].start.distance(t),P=y[1].end.distance(t),T=x<=A+P?(n=y[0],r-=c,o=b,w):(n=y[1],i+=c,o=A,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){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,e),this.divideAtT(t))},divideAtLength:function(t,e){t=this.tAtLength(t,e);return this.divideAtT(t)},divideAtT:function(t){var e,n,i=this.start,r=this.controlPoint1,o=this.controlPoint2,s=this.end;return t<=0?[new v(i,i,i,i),new v(i,r,o,s)]:1<=t?[new v(i,r,o,s),new v(s,s,s,s)]:(o=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,e=r.divider,n=r.dividerControlPoint1,r=r.dividerControlPoint2,[new v(i,o,t,e),new v(e,n,r,s)])},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;return t<=0?{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(e=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),i=new P(i,r).pointAt(t),r=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),{startControlPoint1:e,startControlPoint2:r,divider:new P(r,n).pointAt(t),dividerControlPoint1:n,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end,o=[new v(e,n,i,r)];if(0===t)return o;if(!this.isDifferentiable())return o;for(var s=this.endpointDistance(),a=Ni(10,-t),l=2,h=(0===n.cross(e,r)&&0===i.cross(e,r)&&(l=2*t),0);;){h+=1;for(var u=[],c=o.length,d=0;d<c;d++){var f=o[d].divide(.5);u.push(f[0],f[1])}for(var p=0,g=u.length,m=0;m<g;m++)p+=u[m].endpointDistance();if(l<=h)if((0!==p?(p-s)/p:0)<a)return u;o=u,s=p}},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){return t<=0?0:(e=void 0===(e=e||{}).precision?this.PRECISION:e.precision,this.divide(t)[0].length({precision:e}))},pointAt:function(t,e){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,e),this.pointAtT(t))},pointAtLength:function(t,e){t=this.tAtLength(t,e);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?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:1<t&&(t=1);t=this.tAt(t,e);return this.tangentAtT(t)},tangentAtLength:function(t,e){return this.isDifferentiable()?(t=this.tAtLength(t,e),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),e=t.startControlPoint2,n=t.dividerControlPoint1,t=t.divider,n=new P(e,n);return n.translate(t.x-e.x,t.y-e.y),n},tAt:function(t,e){var n;return t<=0?0:1<=t?1:(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.length(n),this.tAtLength(e*t,n))},tAtLength:function(t,e){for(var n,i,r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.subdivisions?this.getSubdivisions({precision:s}):e.subdivisions,e={precision:s,subdivisions:a},l=0,h=a.length,u=1/h,c=0;c<h;c++){var d=o?c:h-1-c,f=a[c],p=f.endpointDistance();if(t<=l+p){n=f,i=d*u,r=(d+1)*u,x=o?t-l:p+l-t,A=o?p+l-t:t-l;break}l+=p}if(!n)return o?1:0;for(var g=this.length(e),m=Ni(10,-s);;){var v,y=0!==g?x/g:0;if(y<m)return i;if((0!==g?A/g:0)<m)return r;var y=n.divide(.5),b=(u/=2,y[0].endpointDistance()),w=y[1].endpointDistance(),y=x<=b?(n=y[0],r-=u,b-(v=x)):(n=y[1],i+=u,w-(v=x-b)),x=v,A=y}},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 w(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}},v.prototype.divide=v.prototype.divideAtT;let I=function(t){if(!(this instanceof I))return new I(t);if("string"==typeof t)return new I.parse(t);var e;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(e=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(r=0;r<e;r++){var n=t[r];this.appendSegment(n)}else for(var i=null,r=0;r<e;r++){var o=t[r];if(!(o instanceof P||o instanceof v))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(I.createSegment("M",o.start)),i&&!i.end.equals(o.start)&&this.appendSegment(I.createSegment("M",o.start)),o instanceof P?this.appendSegment(I.createSegment("L",o.end)):o instanceof v&&this.appendSegment(I.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),i=o}else if(t.isSegment)this.appendSegment(t);else if(t instanceof P)this.appendSegment(I.createSegment("M",t.start)),this.appendSegment(I.createSegment("L",t.end));else if(t instanceof v)this.appendSegment(I.createSegment("M",t.start)),this.appendSegment(I.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof w))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(e=t.points.length,r=0;r<e;r++){var s=t.points[r];0===r?this.appendSegment(I.createSegment("M",s)):this.appendSegment(I.createSegment("L",s))}}};function Vi(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}function Ii(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Ii))return Vi(Ii,t);if(0===e)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(t[0]instanceof P){if(1===e)return this.end=t[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" lines provided).")}if("string"==typeof t[0]||"number"==typeof t[0]){if(2===e)return this.end=new A(+t[0],+t[1]),this;if(e<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" coordinates provided).");for(var i,r=[],n=0;n<e;n+=2)i=t.slice(n,n+2),r.push(Vi(Ii,i))}else{if(1===e)return this.end=new A(t[0]),this;for(r=[],n=0;n<e;n+=1)r.push(new Ii(t[n]))}return r}function Fi(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Fi))return Vi(Fi,e);if(0===n)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(e[0]instanceof v){if(1===n)return this.controlPoint1=e[0].controlPoint1.clone(),this.controlPoint2=e[0].controlPoint2.clone(),this.end=e[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(6===n)return this.controlPoint1=new A(+e[0],+e[1]),this.controlPoint2=new A(+e[2],+e[3]),this.end=new A(+e[4],+e[5]),this;if(n<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=6)r=e.slice(i,i+6),o.push(Vi(Fi,r))}else{if(3===n)return this.controlPoint1=new A(e[0]),this.controlPoint2=new A(e[1]),this.end=new A(e[2]),this;if(n<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" points provided).");for(o=[],i=0;i<n;i+=3)t=e.slice(i,i+3),o.push(Vi(Fi,t))}return o}function Bi(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Bi))return Vi(Bi,e);if(0===n)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(e[0]instanceof P){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" lines provided).")}if(e[0]instanceof v){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(2===n)return this.end=new A(+e[0],+e[1]),this;if(n<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=2)r=e.slice(i,i+2),0===i?o.push(Vi(Bi,r)):o.push(Vi(Ii,r))}else{if(1===n)return this.end=new A(e[0]),this;for(o=[],i=0;i<n;i+=1)t=e[i],0===i?o.push(new Bi(t)):o.push(new Ii(t))}return o}function Di(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Di))return Vi(Di,t);if(0<e)throw new Error("Closepath constructor expects no arguments.");return this}I.parse=function(t){if(!t)return new I;for(var e=new I,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),o=I.createSegment.apply(this,o);e.appendSegment(o)}return e},I.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=I.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 Vi(e,n)},I.prototype={type:c.Path,appendSegment:function(t){var e=this.segments,n=e.length,i=0!==n?e[n-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 r=t.length,o=0;o<r;o++){var s=t[o],a=this.prepareSegment(s,i,null);e.push(a),i=a}}else{if(!t||!t.isSegment)throw new Error("Segment required.");a=this.prepareSegment(t,i,null),e.push(a)}},bbox:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n,i=0;i<e;i++){var r,o=t[i];o.isVisible&&(o=o.bbox(),r=r?r.union(o):o)}return r||(n=t[e-1],new tt(n.end.x,n.end.y,0,0))},clone:function(){for(var t=this.segments,e=t.length,n=new I,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){t=this.closestPointT(t,e);return t?this.pointAtT(t):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointT(t,n);return e?this.lengthAtT(e,n):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointLength(t,n);return 0===e||0===(t=this.length(n))?0:e/t},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 h=n[l],u=s[l];h.isVisible&&(u=h.closestPointT(t,{precision:o,subdivisions:u}),h=h.pointAtT(u),(h=new P(h,t).squaredLength())<a)&&(r={segmentIndex:l,value:u},a=h)}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 h,u=n[l],c=s[l];u.isDifferentiable()&&(c=u.closestPointT(t,{precision:o,subdivisions:c}),h=u.pointAtT(c),(h=new P(h,t).squaredLength())<a)&&(r=u.tangentAtT(c),a=h)}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;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.divideAtLength(e*t,n)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;for(var i,r,o,s,a=!0,l=(t<0&&(a=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),h=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:l}):e.segmentSubdivisions,u=0,c=0;c<n;c++){var d=a?c:n-1-c,f=this.getSegment(d),p=h[d],g=f.length({precision:l,subdivisions:p});if(f.isDifferentiable()&&(o=f,s=d,t<=u+g)){r=d,i=f.divideAtLength((a?1:-1)*(t-u),{precision:l,subdivisions:p});break}u+=g}if(!o)return null;i||(r=s,i=o.divideAtT(a?1:0));var m=this.clone(),e=(m.replaceSegment(r,i),r),v=r+1,y=r+2,b=(i[0].isDifferentiable()||(m.removeSegment(e),--v,--y),m.getSegment(v).start),w=(m.insertSegment(v,I.createSegment("M",b)),y+=1,i[1].isDifferentiable()||(m.removeSegment(y-1),--y),y-e-1);for(c=y;c<m.segments.length;c++){var x=this.getSegment(c-w);"Z"!==(f=m.getSegment(c)).type||x.subpathStartSegment.end.equals(f.subpathStartSegment.end)||(x=I.createSegment("L",x.end),m.replaceSegment(c,x))}return[new I(m.segments.slice(0,v)),new I(m.segments.slice(v))]},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(n<=(t=t<0?n+t:t)||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(){var e=this.clone().validate().segments,n=e.length,i=[];for(let t=0;t<n;t++){var r=e[t];r.isSubpathStart?i.push(new I(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,e){var n=this.segments,i=n.length;if(i<(t=t<0?i+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,o=null;if(0!==i&&(o=1<=t?(r=n[t-1]).nextSegment:n[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,a=0;a<s;a++){var l=e[a],h=this.prepareSegment(l,r,o);n.splice(t+a,0,h),r=h}}else{if(!e||!e.isSegment)throw new Error("Segment required.");h=this.prepareSegment(e,r,o),n.splice(t,0,h)}},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],s=t.intersect(s);s&&(n=n||[],Array.isArray(s)?Array.prototype.push.apply(n,s):n.push(s))}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;for(var t=t.value,o=(i<=r?(r=i-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=0,l=0;l<r;l++){var h=n[l],u=s[l];a+=h.length({precisison:o,subdivisions:u})}return u=s[r],a+=(h=n[r]).lengthAtT(t,{precisison:o,subdivisions:u})},pointAt:function(t,e){var n;return 0===this.segments.length?null:t<=0?this.start.clone():1<=t?this.end.clone():(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n),this.pointAtLength(e*t,n))},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isVisible){if(t<=l+d)return c.pointAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?o?r.end:r.start:n[i-1].end.clone()},pointAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].pointAtT(0):i<=e?n[i-1].pointAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].pointAtT(i))},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);e=t;return t.isSubpathStart&&(t.subpathStartSegment=t,e=n),e&&this.updateSubpathStartSegment(e),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(n<=(t=t<0?n+t:t)||t<0)throw new Error("Index out of range.");n=e.splice(t,1)[0],e=n.previousSegment,t=n.nextSegment;e&&(e.nextSegment=t),t&&(t.previousSegment=e),n.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,e){var n=this.segments,i=n.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");var i=n[t],r=i.previousSegment,o=i.nextSegment,s=i.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");n.splice(t,1);for(var a=e.length,l=0;l<a;l++){var h=e[l],u=this.prepareSegment(h,r,o);n.splice(t+l,0,u),r=u,s&&u.isSubpathStart&&(s=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");u=this.prepareSegment(e,r,o),n.splice(t,1,u),s&&u.isSubpathStart&&(s=!1)}s&&o&&this.updateSubpathStartSegment(o)},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){t=this.segmentIndexAt(t,e);return t?this.getSegment(t):null},segmentAtLength:function(t,e){t=this.segmentIndexAtLength(t,e);return t?this.getSegment(t):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.segmentIndexAtLength(e*t,n)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r=!0,o=(t<0&&(r=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,h=0;h<i;h++){var u=r?h:i-1-h,c=n[u],d=s[u],d=c.length({precision:o,subdivisions:d});if(c.isVisible){if(t<=l+d)return u;a=u}l+=d}return a},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.tangentAtLength(e*t,n)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isDifferentiable()){if(t<=l+d)return c.tangentAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?r.tangentAtT(o?1:0):null},tangentAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].tangentAtT(0):i<=e?n[i-1].tangentAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].tangentAtT(i))},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,h=e[a];h.isVisible?0<(l=r[a]).length?(l=l.map(function(t){return t.start}),Array.prototype.push.apply(s,l)):s.push(h.start):0<s.length&&(s.push(e[a-1].end),o.push(s),s=[])}return 0<s.length&&(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 w(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,t=(e=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,I.createSegment("M",0,0)),this}},Object.defineProperty(I.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(I.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;0<=n;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}}),l={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){var e;return t<=0?0:(e=this.length(),1<=t?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(l,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(l,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;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.)")}}),Object.defineProperty(l,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),Zr={clone:function(){return new Ii(this.end)},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[new Ii(t[0]),new Ii(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[new Ii(t[0]),new Ii(t[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(Zr,"type",{configurable:!0,enumerable:!0,value:"L"}),Ii.prototype=Ri(l,P.prototype,Zr),n={clone:function(){return new Fi(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Fi(t[0]),new Fi(t[1])]},divideAtLength:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Fi(t[0]),new Fi(t[1])]},divideAtT:function(t){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Fi(t[0]),new Fi(t[1])]},isDifferentiable:function(){var t,e,n,i;return!(!this.previousSegment||(t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end,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(n,"type",{configurable:!0,enumerable:!0,value:"C"}),Fi.prototype=Ri(l,v.prototype,n),Je={bbox:function(){return null},clone:function(){return new Bi(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(Je,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Je,"type",{configurable:!0,enumerable:!0,value:"M"}),Bi.prototype=Ri(l,Je),h={clone:function(){return new Di},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new Ii(t[0]):this.clone(),new Ii(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new Ii(t[0]):this.clone(),new Ii(t[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(h,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;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.)")}}),Object.defineProperty(h,"type",{configurable:!0,enumerable:!0,value:"Z"}),Di.prototype=Ri(l,P.prototype,h),o=I.segmentTypes={L:Ii,C:Fi,M:Bi,Z:Di,z:Di},I.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(o).join("")+",.]*$"),I.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},e={curveThroughPoints:function(t){return console.warn("deprecated"),new I(v.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=this.getFirstControlPoints(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=this.getFirstControlPoints(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new v(t,e,n,i);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);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 v(t,e,n,i);return function(t){return r.closestPointT(t)}}};let zi=function(t){return this instanceof zi?"string"==typeof t?new zi.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new zi(t)};function ji(t,e){var n=t.start.x,i=t.start.y,r=t.end.x,t=t.end.y,o=e.start.x,s=e.start.y,r=r-n,t=t-i,a=e.end.x-o,e=e.end.y-s,n=n-o,o=i-s,i=r*e-a*t,s=(r*o-t*n)/i,r=(a*o-e*n)/i;return 0<=s&&s<=1&&0<=r&&r<=1}function Gi(t,e){var n=t.a,i=t.b,r=t.x,t=t.y,o=e.start.x-r,r=e.end.x-r,s=e.start.y-t,n=n*n,i=i*i,r=r-o,e=e.end.y-t-s,t=r*r/n+e*e/i,r=2*o*r/n+2*s*e/i,e=r*r-4*t*(o*o/n+s*s/i-1);return 0==e?0<=(o=-r/2/t)&&o<=1:0<e&&(s=(-r-(n=Math.sqrt(e)))/2/t,0<=(i=(-r+n)/2/t)&&i<=1||0<=s&&s<=1)}function Ui(L,k){{var C=0,M=0;let{cos:t,sin:e}=Math,n=e(C),i=t(C),r=e(M),o=t(M),s=n*n,a=i*i,l=n*i,h=r*r,u=o*o,c=r*o,d=L.a*L.a,f=L.b*L.b,p=k.a*k.a,g=k.b*k.b,m=d*s+f*a,v=p*h+g*u,y=d*a+f*s,b=p*u+g*h,w=2*(f-d)*l,x=2*(g-p)*c,A=-2*m*L.x-w*L.y,P=-2*v*k.x-x*k.y,T=-w*L.x-2*y*L.y,E=-x*k.x-2*b*k.y,S=m*L.x*L.x+y*L.y*L.y+w*L.x*L.y-d*f,_=v*k.x*k.x+b*k.y*k.y+x*k.x*k.y-p*g;w/=2,x/=2,A/=2,P/=2,T/=2,E/=2;var C=gr([[m,w,A],[w,y,T],[A,T,S]]),M=gr([[v,x,P],[x,b,E],[P,E,_]]),L=.33333333*(gr([[v,w,A],[x,y,T],[P,T,S]])+gr([[m,x,A],[w,b,T],[A,E,S]])+gr([[m,w,P],[w,y,E],[A,T,_]])),k=.33333333*(gr([[m,x,P],[w,b,E],[A,E,_]])+gr([[v,w,P],[x,y,E],[P,T,_]])+gr([[v,x,A],[x,b,T],[P,E,S]])),N=pr([[C,L],[L,k]]),C=pr([[C,k],[L,M]]),M=pr([[L,k],[k,M]]);return!(0<(N=pr([[2*N,C],[C,2*M]]))&&(0<k||0<L))}}function Hi(t,e){var{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))||ji(t.topLine(),e)||ji(t.rightLine(),e)||ji(t.bottomLine(),e)||ji(t.leftLine(),e))}function qi(t,e){return!!$i(t,tt.fromEllipse(e))&&Ki(zi.fromRect(t),e)}function $i(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 Wi(t,e){return lr(t,e,{interior:!1})}function Yi(t,e){return hr(t,e,{interior:!1})}function Xi(t,e){return ur(t,e,{interior:!1})}function Zi(t,e){return dr(t,e,{interior:!1})}function Ji(t,e){return lr(t,e,{interior:!0})}function Ki(t,e){return hr(t,e,{interior:!0})}function Qi(t,e){return ur(t,e,{interior:!0})}function tr(t,e){return dr(t,e,{interior:!0})}function er(t,e){return fr(t,e,{interior:!0})}function nr(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ji:Wi)(e,n)})}function ir(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ki:Yi)(e,n)})}function rr(t,e,n){return sr(t,zi.fromRect(e),n)}function or(t,e,n){return cr(t,e,n,{interior:!1})}function sr(t,e,n){return cr(t,e,n,{interior:!0})}function ar(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?sr:or)(n,e,r)})}function lr(t,e,n={}){var{interior:n=!1}=n;let i;if(n){if(t.containsPoint(e.start))return!0;var{start:n,end:r,points:o}=t;i=r.equals(n)?o:[...o,n]}else i=t.points;var s=i.length,a=new P;for(let t=0;t<s-1;t++)if(a.start=i[t],a.end=i[t+1],ji(e,a))return!0;return!1}function hr(t,e,n={}){var{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;var{interior:n=!1}=n;if(n){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;var a=s.length,l=new P;for(let t=0;t<a-1;t++)if(l.start=s[t],l.end=s[t+1],Gi(e,l))return!0;return!1}function ur(t,e,n){return fr(t,zi.fromRect(e),n)}function cr(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?fr:dr)(n,e,r)})}function dr(t,e,n={}){var{interior:n=!1}=n;let i;if(n){n=e.start;if(t.containsPoint(n))return!0;i=t.clone().close()}else i=t;var r=e.points,o=r.length,s=new P;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Wi(i,s))return!0;return!1}function fr(t,e,n){return e.containsPoint(t.start)||dr(t,e.clone().close(),n)}function pr(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function gr(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]}zi.parse=function(t){return new zi(Ei(t))},zi.fromRect=function(t){return new zi([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},zi.prototype=Ri(w.prototype,{type:c.Polygon,clone:function(){return new zi(Si(this.points))},convexHull:function(){return new zi(_i(this.points))},lengthPoints:function(){var{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});let mr={__proto__:null,ellipseWithEllipse:Ui,ellipseWithLine:Gi,exists:function t(e,n,i,r){switch(e.type){case c.Line:if(n.type===c.Line)return ji(e,n);break;case c.Ellipse:switch(n.type){case c.Line:return Gi(e,n);case c.Ellipse:return Ui(e,n)}break;case c.Rect:switch(n.type){case c.Line:return Hi(e,n);case c.Ellipse:return qi(e,n);case c.Rect:return $i(e,n)}break;case c.Polyline:switch(n.type){case c.Line:return Wi(e,n);case c.Ellipse:return Yi(e,n);case c.Rect:return Xi(e,n);case c.Polyline:return Zi(e,n)}break;case c.Polygon:switch(n.type){case c.Line:return Ji(e,n);case c.Ellipse:return Ki(e,n);case c.Rect:return Qi(e,n);case c.Polyline:return tr(e,n);case c.Polygon:return er(e,n)}break;case c.Path:switch(n.type){case c.Line:return nr(e,n,i);case c.Ellipse:return ir(e,n,i);case c.Rect:return rr(e,n,i);case c.Polyline:return or(e,n,i);case c.Polygon:return sr(e,n,i);case c.Path:return ar(e,n,i,r)}}switch(n.type){case c.Ellipse:case c.Rect:case c.Polyline:case c.Polygon:case c.Path:return t(n,e,r,i);default:throw Error(`The intersection for ${e} and ${n} could not be found.`)}},lineWithLine:ji,pathWithEllipse:ir,pathWithLine:nr,pathWithPath:ar,pathWithPolygon:sr,pathWithPolyline:or,pathWithRect:rr,polygonWithEllipse:Ki,polygonWithLine:Ji,polygonWithPolygon:er,polygonWithPolyline:tr,polygonWithRect:Qi,polylineWithEllipse:Yi,polylineWithLine:Wi,polylineWithPolyline:Zi,polylineWithRect:Xi,rectWithEllipse:qi,rectWithLine:Hi,rectWithRect:$i},vr=mr;var yr={__proto__:null,Curve:v,Ellipse:vi,Line:P,Path:I,Point:A,Polygon:zi,Polyline:w,Rect:tt,bezier:e,ellipse:a,intersection:vr,line:fi,normalizeAngle:Yn,point:ui,random:Hn,rect:hn,scale:{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}},snapToGrid:Xn,toDeg:Un,toRad:Zn,types:c};let br="[object Arguments]",wr="[object Array]",xr="[object Boolean]",Ar="[object Date]",Pr="[object Error]",Tr="[object Map]",Er="[object Number]",Sr="[object Null]",_r="[object Object]",Lr="[object RegExp]",kr="[object Set]",Cr="[object String]",Mr="[object Symbol]",Nr="[object Undefined]",Or="[object ArrayBuffer]",Rr="[object DataView]",Vr="[object Float32Array]",Ir="[object Float64Array]",Fr="[object Int8Array]",Br="[object Int16Array]",Dr="[object Int32Array]",zr="[object Uint8Array]",jr="[object Uint8ClampedArray]",Gr="[object Uint16Array]",Ur="[object Uint32Array]",Hr={[br]:!0,[wr]:!0,[Or]:!0,[Rr]:!0,[xr]:!0,[Ar]:!0,[Vr]:!0,[Ir]:!0,[Fr]:!0,[Br]:!0,[Dr]:!0,[Tr]:!0,[Er]:!0,[_r]:!0,[Lr]:!0,[kr]:!0,[Cr]:!0,[Mr]:!0,[zr]:!0,[jr]:!0,[Gr]:!0,[Ur]:!0,[Pr]:!1,"[object Function]":!1,"[object WeakMap]":!1},qr=(u=`[${r="\\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"}]`,s="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",Zr=`[${C="\\u2700-\\u27bf"}]`,l="\\ud83c[\\udffb-\\udfff]",hn=`(?:${n=`[${i="a-z\\xdf-\\xf6\\xf8-\\xff"}]`}|${Je=`[^${Ue="\\ud800-\\udfff"}${r+"\\d"+C+i+(Ke="A-Z\\xc0-\\xd6\\xd8-\\xde")}]`})`,r=`(?:${a=`[${Ke}]`}|${Je})`,C="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",i="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Je=(Je="[\\ufe0e\\ufe0f]?")+(Ke="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?")+`(?:\\u200d(?:${[h=`[^${Ue}]`,o="(?:\\ud83c[\\udde6-\\uddff]){2}",e="[\\ud800-\\udbff][\\udc00-\\udfff]"].join("|")})${Je+Ke})*`,Ke=`(?:${[Zr,o,e].join("|")})`+Je,RegExp([`${a}?${n}+${C}(?=${[u,a,"$"].join("|")})`,r+`+${i}(?=${[u,a+hn,"$"].join("|")})`,a+`?${hn}+`+C,a+"+"+i,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",Ke].join("|"),"g")),$r=200,Wr="__hash_undefined__",Yr=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;var Xr,Zr=`(?:${[h+s+"?",s,o,e,`[${Ue}]`].join("|")})`;let Jr=RegExp(l+`(?=${l})|`+Zr+Je,"g"),Kr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qr=/^\w*$/,to=".".charCodeAt(0),eo=/\\(\\)?/g,no=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=/^(?:0|[1-9]\d*)$/,ro=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 ]/),oo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,so=t=>Jr.test(t),ao=t=>t.match(Jr)||[],lo=t=>t.split(""),ho=t=>(so(t)?ao:lo)(t),uo=e=>null==e?[]:co(e).map(t=>e[t]),co=t=>Po(t)?fo(t):Object.keys(Object(t)),fo=(t,e)=>{var n,i=Array.isArray(t),r=!i&&mo(t)&&_o(t)===br,o=!i&&!r&&Vo(t),s=i||r||o,a=t.length,l=new Array(s?a:0);let h=s?-1:a;for(;++h<a;)l[h]=""+h;for(n in t)!e&&!hasOwnProperty.call(t,n)||s&&("length"===n||as(n,a))||l.push(n);return l},po=(t,e)=>{let n=t.length;for(;n--;)if(go(t[n][0],e))return n;return-1},go=(t,e)=>t===e||t!=t&&e!=e,mo=t=>null!=t&&"object"==typeof t,vo=(t,e,n)=>{var i;return!!x(n)&&!!("number"==(i=typeof e)?Po(n)&&-1<e&&e<n.length:"string"==i&&e in n)&&go(n[e],t)},yo=t=>mo(t)&&_o(t)==kr,bo=t=>mo(t)&&_o(t)==Tr,wo=t=>{var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},xo=(t,e,n)=>{var i=t[e];hasOwnProperty.call(t,e)&&go(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Ao=(t,e,n)=>{let i=-1;for(var r=e.length;++i<r;){var o=e[i];xo(n,o,t[o])}return n},Po=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&-1<t.length&&t.length%1==0,To=t=>"symbol"==typeof t||mo(t)&&_o(t)===Mr,Eo=t=>{var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n},So=(t,e)=>{let n=-1;var i=t.length;for(e=e||new Array(i);++n<i;)e[n]=t[n];return e},_o=t=>null==t?void 0===t?Nr:Sr:Object.prototype.toString.call(t),Lo=t=>{var e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},ko=(t,e)=>{e=e?Lo(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)},Co=t=>{var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},Mo=t=>"function"!=typeof t.constructor||wo(t)?{}:Object.create(Object.getPrototypeOf(t)),No=e=>null==e?[]:(e=Object(e),Object.getOwnPropertySymbols(e).filter(t=>propertyIsEnumerable.call(e,t))),Oo=(t,e)=>Ao(t,No(t),e),Ro=(t,e,n)=>{var i,r,o=t.constructor;switch(e){case Or:return Lo(t);case xr:case Ar:return new o(+t);case Rr:return i=t,r=(r=n)?Lo(i.buffer):i.buffer,new i.constructor(r,i.byteOffset,i.byteLength);case Vr:case Ir:case Fr:case Br:case Dr:case zr:case jr:case Gr:case Ur:return ko(t,n);case Tr:return new o(t);case Er:case Cr:return new o(t);case Lr:return Co(t);case kr:return new o;case Mr:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}},Vo=t=>mo(t)&&Yr.test(_o(t)),Io=t=>{var e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...No(Object(t))),e},Fo=t=>{for(var e=[];t;)e.push(...No(t)),t=Object.getPrototypeOf(Object(t));return e},Bo=t=>{var e,n=[];for(e in t)n.push(e);return Array.isArray(t)||n.push(...Fo(t)),n},Do=({__data__:t},e)=>(t=>{const e=typeof t;return e==="string"||e==="number"||e==="symbol"||e==="boolean"?t!=="__proto__":t===null})(e)?t["string"==typeof e?"string":"hash"]:t.map,zo=(t,e,n,i)=>{var r=Io(t),o=r.length;if(o!=Io(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;var l=i.get(t),h=i.get(e);if(l&&h)return l==e&&h==t;let u=!0;i.set(t,e),i.set(e,t);let c;for(;++a<o;){var d=t[s=r[a]],f=e[s];if(d!==f&&!n(d,f,i)){u=!1;break}c=c||"constructor"==s}return u&&!c&&(l=t.constructor)!=(h=e.constructor)&&"constructor"in t&&"constructor"in e&&!("function"==typeof l&&l instanceof l&&"function"==typeof h&&h instanceof h)&&(u=!1),i.delete(t),i.delete(e),u},jo=(t,e,n)=>t===e||(null==t||null==e||!mo(t)&&!mo(e)?t!=t&&e!=e:Go(t,e,jo,n)),Go=(t,e,n,i)=>{var r=Array.isArray(t),o=Array.isArray(e),s=r?wr:_o(t),o=o?wr:_o(e),s=s==br?_r:s,o=o==br?_r:o,a=s==_r,l=o==_r,o=s==o;return o&&!a?(i=i||new Ds,r||Vo(t)?Uo(t,e,!1,n,i):Wo(t,e,s,n,i)):(r=a&&hasOwnProperty.call(t,"__wrapped__"),s=l&&hasOwnProperty.call(e,"__wrapped__"),r||s?n(r?t.value():t,s?e.value():e,i=i||new Ds):o&&(i=i||new Ds,zo(t,e,n,i)))},Uo=(t,e,n,i,r)=>{var o=t.length,s=e.length;if(o!=s)return!1;var s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,h=!0,u=n?new Us:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n=t[l];var c=e[l];if(u){if(!Ho(e,(t,e)=>{if(!qo(u,e)&&(n===t||i(n,t,r)))return u.push(e)})){h=!1;break}}else if(n!==c&&!i(n,c,r)){h=!1;break}}return r.delete(t),r.delete(e),h},Ho=(t,e)=>{let n=-1;for(var i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1},qo=(t,e)=>t.has(e),$o=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),Wo=(t,e,n,i,r)=>{switch(n){case Rr:return t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset?!1:(t=t.buffer,e=e.buffer,$o(t,e,i,r));case Or:return $o(t,e,i,r);case xr:case Ar:case Er:return go(+t,+e);case Pr:return t.name==e.name&&t.message==e.message;case Lr:case Cr:return t==""+e;case Tr:var o=Yo;case kr:if(o=o||Xo,t.size!=e.size)return!1;var s=r.get(t);if(s)return s==e;r.set(t,e);s=Uo(o(t),o(e),!0,i,r);return r.delete(t),s;case Mr:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},Yo=t=>{let n=-1,i=Array(t.size);return t.forEach((t,e)=>{i[++n]=[e,t]}),i},Xo=t=>{let e=-1,n=new Array(t.size);return t.forEach(t=>{n[++e]=t}),n},Zo=(t,e)=>{var n;return!Array.isArray(t)&&(!("number"!=(n=typeof t)&&"boolean"!=n&&null!=t&&!To(t))||Qr.test(t)||!Kr.test(t)||null!=e&&t in Object(e))},Jo=t=>{let o=[];return t.charCodeAt(0)===to&&o.push(""),t.replace(no,(t,e,n,i)=>{let r=t;n?r=i.replace(eo,"$1"):e&&(r=e.trim()),o.push(r)}),o},Ko=(t,e)=>Array.isArray(t)?t:Zo(t,e)?[t]:Jo(""+t),Qo=(t,e)=>{let n=0;for(var i=(e=Ko(e,t)).length;null!=t&&n<i;)t=t[ns(e[n])],n++;return n&&n==i?t:void 0};function ts(t,e){if(t!==e){var n=void 0!==t,i=null===t,r=t==t,o=To(t),s=void 0!==e,a=null===e,l=e==e,h=To(e);if(!a&&!h&&!o&&e<t||o&&s&&l&&!a&&!h||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!h&&t<e||h&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}let es=(t,e)=>{let n=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),i=!0;var r=[],o=e.length;if(t.length){e.length>=$r&&(n=(t,e)=>t.has(e),i=!1,e=new Us(e));t:for(var s in t){var a=s=t[s],s=0!==s?s:0;if(i&&a==a){let t=o;for(;t--;)if(e[t]===a)continue t;r.push(s)}else n(e,a)||r.push(s)}}return r},ns=t=>{var e;return"string"==typeof t||To(t)?t:"0"==(e=""+t)&&1/t==-1/0?"-0":e},is=(i,r=!1,o=!1,s=!0,a,t,e,l)=>{let h;if(void 0===(h=a?e?a(i,t,e,l):a(i):h)){if(!x(i))return i;var t=Array.isArray(i),n=_o(i);if(t){if(h=Eo(i),!r)return So(i,h)}else{var u="function"==typeof i;if(n===_r||n===br||u&&!e){if(h=o||u?{}:Mo(i),!r)return o?rs(i,Ao(i,Object.keys(i),h)):Oo(i,Object.assign(h,i))}else{if(u||!Hr[n])return e?i:{};h=Ro(i,n,r)}}u=(l=l||new Ds).get(i);if(u)return u;if(l.set(i,h),bo(i))i.forEach((t,e)=>{h.set(e,is(t,r,o,s,a,e,i,l))});else if(yo(i))i.forEach(t=>{h.add(is(t,r,o,s,a,t,i,l))});else if(!Vo(i)){e=s?o?Bo:Io:o?ls:co;let n=t?void 0:e(i);(n||i).forEach((t,e)=>{n&&(t=i[e=t]),xo(h,e,is(t,r,o,s,a,e,i,l))})}}return h},rs=(t,e)=>Ao(t,Fo(t),e),os=(t,e)=>e.length<2?t:Qo(t,e.slice(0,-1)),ss=(t,i,r)=>{if(x(t)){var o=(i=Ko(i,t)).length,s=o-1;let e=-1,n=t;for(;null!=n&&++e<o;){var a,l=ns(i[e]);let t=r;e!=s&&(a=n[l],(t=void 0)===t)&&(t=x(a)?a:as(i[e+1])?[]:{}),xo(n,l,t),n=n[l]}}return t},as=(t,e)=>{var n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"==n||"symbol"!=n&&io.test(t))&&-1<t&&t%1==0&&t<e},ls=t=>{var e,n=[];for(e in t)n.push(e);return n},hs=t=>{var e,n={};for(e in t=Object(t))n[e]=t[e];return n},us=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function cs(a,l=!1){return(t,...e)=>{let n=-1,i=e.length,r=1<i?e[i-1]:void 0;var o=2<i?e[2]:void 0;for(r=3<a.length&&"function"==typeof r?(i--,r):l?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,o&&vo(e[0],e[1],o)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var s=e[n];s&&a(t,s,n,r)}return t}}let ds=(i,r,t,o,s)=>{i!==r&&fa(r,(e,n)=>{if(x(e))s=s||new Ds,fs(i,r,n,t,ds,o,s);else{let t=o?o(i[n],e,""+n,i,r,s):void 0;void 0===t&&(t=e),ps(i,n,t)}})},fs=(n,i,r,o,s,a,l)=>{var h=us(n,r),u=us(i,r),c=l.get(u);if(c)ps(n,r,c);else{let t=a?a(h,u,""+r,n,i,l):void 0,e=void 0===t;e&&(i=!(c=Array.isArray(u))&&Vo(u),t=u,c||i?t=Array.isArray(h)?h:mo(h)&&Po(h)?So(h):i?(e=!1,ko(u,!0)):[]:y(u)||Cs(u)?(t=h,Cs(h)?t=hs(h):"function"!=typeof h&&x(h)||(t=Mo(u))):e=!1),e&&(l.set(u,t),s(t,u,o,a,l),l.delete(u)),ps(n,r,t)}},ps=(t,e,n)=>{(void 0===n||go(t[e],n))&&(void 0!==n||e in t)||xo(t,e,n)},gs=(t,e)=>t&&((t,e,n)=>{var i=Object(t),r=n(t);let o=r.length,s=-1;for(;o--;){var a=r[++s];if(!1===e(i[a],a,i))break}return t})(t,e,co),ms=(e,n)=>{if(null!=e){if(!Po(e))return gs(e,n);var i=e.length,r=Object(e);let t=-1;for(;++t<i&&!1!==n(r[t],t,r););}return e},vs=Set&&1/Xo(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function ys(t,e,n,i,r,o){return x(t)&&x(e)&&(o.set(e,t),ds(t,e,void 0,ys,o),o.delete(e)),t}function bs(e,n,u){n=n.length?n.map(e=>Array.isArray(e)?t=>Qo(t,1===e.length?e[0]:e):e):[t=>t];let i=-1,r=-1,o=Po(e)?new Array(e.length):[];ms(e,e=>{var t=n.map(t=>t(e));o[++r]={criteria:t,index:++i,value:e}});{var s=o;e=(e,n)=>{{var i=u;let t=-1;for(var r=e.criteria,o=n.criteria,s=r.length,a=i.length;++t<s;){var l=t<a?i[t]:null,h=(l&&"function"==typeof l?l:ts)(r[t],o[t]);if(h)return l&&"function"!=typeof l?h*("desc"==l?-1:1):h}return e.index-n.index}};let t=s.length;for(s.sort(e);t--;)s[t]=s[t].value;return s}}function ws(t){return t==t&&!x(t)}function xs(e,n){return t=>null!=t&&t[e]===n&&(void 0!==n||e in Object(t))}function As(t,e){return null!=t&&Rs(t,e,Os)}function Ps(e){let n=(t=>{let e=co(t),n=e.length;for(;n--;){var i=e[n],r=t[i];e[n]=[i,r,ws(r)]}return e})(e);return 1===n.length&&n[0][2]?xs(n[0][0],n[0][1]):t=>t===e||((t,e,n,i)=>{let r=n.length,o=r,s=!i;if(null==t)return!o;let a,l;for(t=Object(t);r--;)if(a=n[r],s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1;for(;++r<o;){var h=(a=n[r])[0],u=t[h],c=a[1];if(s&&a[2]){if(void 0===u&&!(h in t))return!1}else{var d=new Ds;if(!(void 0===(l=i?i(u,c,h,t,e,d):l)?jo(c,u,d):l))return!1}}return!0})(t,e,n)}function Ts(t){return Zo(t)?(n=ns(t),t=>null==t?void 0:t[n]):(e=t,t=>Qo(t,e));var e,n}function Es(t){var n,i;return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(n=t[0],i=t[1],Zo(n)&&ws(i)?xs(ns(n),i):t=>{var e=Qo(t,n);return void 0===e&&e===i?As(t,n):jo(i,e)}):Ps(t):Ts(t)}function Ss(t,e){var n=Es;return arguments.length?n(t,e):n}let _s=(t,e,n,i)=>{let r=-1;var o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},Ls=(t,i,r,o,e)=>(e(t,(t,e,n)=>{r=o?(o=!1,t):i(r,t,e,n)}),r),ks=t=>Array.isArray(t)||Cs(t)||!(!t||!t[Symbol.isConcatSpreadable]),Cs=t=>mo(t)&&"[object Arguments]"==_o(t),Ms=(t,e,n)=>{let i=-1;for(var r=e.length,o={};++i<r;){var s=e[i],a=Qo(t,s);n(a,s)&&ss(o,Ko(s,t),a)}return o},Ns=t=>"number"==typeof t&&-1<t&&t%1==0&&t<=Number.MAX_SAFE_INTEGER,Os=(t,e)=>null!=t&&e in Object(t),Rs=(t,e,n)=>{for(var i=-1,r=(e=Ko(e,t)).length,o=!1;++i<r;){var s=ns(e[i]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++i!=r?o:!!(r=null==t?0:t.length)&&Ns(r)&&as(s,r)&&(Array.isArray(t)||Cs(t))},Vs=t=>t.match(oo),Is=t=>t.match(qr),Fs=(t,e)=>void 0===e?(ro(t)?Is:Vs)(t)||[]:t.match(e)||[],Bs=(Xr="toUpperCase",t=>{var e,n,i,r,o;return t?(e=((n=so(t)?ho(t):void 0)||t)[0],o=n?(i=1,o=(n=n).length,r=void 0===r?o:r,(!i&&o<=r?n:n.slice(i,r)).join("")):t.slice(1),e[Xr]()+o):""});class Ds{constructor(t){t=this.__data__=new zs(t);this.size=t.size}clear(){this.__data__=new zs,this.size=0}delete(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof zs){var i=n.__data__;if(i.length<$r-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new js(i)}return n.set(t,e),this.size=n.size,this}}class zs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=[],this.size=0}delete(t){var e=this.__data__,t=po(e,t);return!(t<0||(t==e.length-1?e.pop():e.splice(t,1),--this.size,0))}get(t){var e=this.__data__,t=po(e,t);return t<0?void 0:e[t][1]}has(t){return-1<po(this.__data__,t)}set(t,e){var n=this.__data__,i=po(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class js{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.size=0,this.__data__={hash:new Gs,map:new Map,string:new Gs}}delete(t){t=Do(this,t).delete(t);return this.size-=t?1:0,t}get(t){return Do(this,t).get(t)}has(t){return Do(this,t).has(t)}set(t,e){var n=Do(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Gs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){t=this.has(t)&&delete this.__data__[t];return this.size-=t?1:0,t}get(t){t=this.__data__[t];return t===Wr?void 0:t}has(t){return void 0!==this.__data__[t]}set(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?Wr:e,this}}class Us{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.__data__=new js;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,Wr),this}has(t){return this.__data__.has(t)}}function Hs(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&e.call(t)===xr}function qs(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Er}Us.prototype.push=Us.prototype.add;let x=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},T=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Cr},E=cs((t,e)=>{if(wo(e)||Po(e))Ao(e,co(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&xo(t,n,e[n])}),$s=(n=E,r=n,u=(e,...t)=>{let n=-1,i=t.length;var r=2<i?t[2]:void 0;for(r&&vo(t[0],t[1],r)&&(i=1);++n<i;){var o=t[n];if(null!=o){var s=Object.keys(o),a=s.length;let t=-1;for(;++t<a;){var l=s[t],h=e[l];(void 0===h||go(h,Object.prototype[l])&&!hasOwnProperty.call(e,l))&&(e[l]=o[l])}}}return e});function Ws(...t){return t.push(void 0,ys),_.apply(void 0,t)}let Ys=Ws,Xs=(t,e,...n)=>{let i=-1,r="function"==typeof e,o=Po(t)?new Array(t.length):[];return ms(t,t=>{o[++i]=r?e.apply(t,n):Zs(t,e,...n)}),o},Zs=(t,e,...n)=>{e=Ko(e,t);var i,e=null==(t=os(t,e))?t:t[ns((i=null==(e=e)?0:e.length)?e[i-1]:void 0)];return null==e?void 0:e.apply(t,n)},Js=(e,n,i)=>{let r=0,o=null==e?0:e.length;if(0==o)return 0;for(var s=(n=(i=Ss(i,2))(n))!=n,a=null===n,l=To(n),h=void 0===n;r<o;){let t;var u=Math.floor((r+o)/2),c=i(e[u]),d=void 0!==c,f=null===c,p=c==c,g=To(c);(t=s?p:h?p&&d:a?p&&d&&!f:l?p&&d&&!f&&!g:!f&&!g&&c<n)?r=u+1:o=u}return Math.min(o,4294967294)},Ks=(t,e)=>{let n=-1,i=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),r=(e=Ss(e,2),!0);var o=t.length,s=[];let a=s;if(o>=$r){var l=e?null:vs(t);if(l)return Xo(l);r=!1,i=(t,e)=>t.has(e),a=new Us}else a=e?[]:s;t:for(;++n<o;){var h=t[n],u=e?e(h):h,h=0!==h?h:0;if(r&&u==u){let t=a.length;for(;t--;)if(a[t]===u)continue t;e&&a.push(u),s.push(h)}else i(a,u)||(a!==s&&a.push(u),s.push(h))}return s},Qs=t=>is(t),ta=t=>is(t,!0),ea=t=>{if(null!=t){if(Po(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Vo(t)||Cs(t)))return!t.length;var e,n=_o(t);if("[object Map]"==n||"[object Set]"==n)return!t.size;if(wo(t))return!(t=>{if(!wo(t))return Object.keys(t);var e,n=[];for(e in Object(t))hasOwnProperty.call(t,e)&&"constructor"!=e&&n.push(e);return n})(t).length;for(e in t)if(hasOwnProperty.call(t,e))return!1}return!0},na=(t,e)=>jo(t,e),b=t=>"function"==typeof t,y=t=>{if(!mo(t)||"[object Object]"!=_o(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},et=t=>{if(!t)return[];if(Po(t))return(T(t)?ho:So)(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){for(var e,n=t[Symbol.iterator](),i=[];!(e=n.next()).done;)i.push(e.value);return i}var r=_o(t);return(r==Tr?Yo:r==kr?Xo:uo)(t)};function ia(i,r,t){if("function"!=typeof i)throw new TypeError("Expected a function");let o,s,n,a,l,h,u=0,c=!1,d=!1,e=!0,f=!r&&0!==r&&window&&"function"==typeof window.requestAnimationFrame;function p(t){var e=o,n=s;return o=s=void 0,u=t,a=i.apply(n,e)}function g(t,e){return f?(window.cancelAnimationFrame(l),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){var e=t-h,t=t-u;return void 0===h||r<=e||e<0||d&&t>=n}function v(){var t,e=Date.now();if(m(e))return y(e);l=g(v,(t=(e=e)-h,e-=u,t=r-t,d?Math.min(t,n-e):t))}function y(t){return l=void 0,e&&o?p(t):(o=s=void 0,a)}function b(...t){var e=Date.now(),n=m(e);if(o=t,s=this,h=e,n){if(void 0===l)return t=h,u=t,l=g(v,r),c?p(t):a;if(d)return l=g(v,r),p(h)}return void 0===l&&(l=g(v,r)),a}return r=+r||0,x(t)&&(c=!!t.leading,d="maxWait"in t,n=d?Math.max(+t.maxWait||0,r):n,e="trailing"in t?!!t.trailing:e),b.cancel=()=>{void 0!==l&&(t=>{if(f)return window.cancelAnimationFrame(t);clearTimeout(t)})(l),u=0,o=h=s=l=void 0},b.flush=()=>void 0===l?a:y(Date.now()),b.pending=()=>void 0!==l,b}let ra=(t,i)=>(i=Ss(i,2),function(t,e,n){return(Array.isArray(t)?_s:Ls)(t,e,n,arguments.length<3,ms)}(t,(t,e)=>{var n=i(e);return hasOwnProperty.call(t,n)?t[n].push(e):xo(t,n,[e]),t},{})),oa=(t,e=[])=>{var n;return null==t?[]:(1<(n=e.length)&&vo(t,e[0],e[1])?e=[]:2<n&&vo(e[0],e[1],e[2])&&(e=[e[0]]),bs(t,(e=Array.isArray(e)?e:[Ss(e,2)]).flat(1),[]))},sa=t=>(null==t?0:t.length)?function t(e,n,i,r,o){let s=-1;var a=e.length;for(i=i||ks,o=o||[];++s<a;){var l=e[s];0<n&&i(l)?1<n?t(l,n-1,i,r,o):o.push(...l):r||(o[o.length]=l)}return o}(t,1/0):[],aa=(t,...e)=>Po(t)?es(t,e):[],la=(t,...e)=>mo(t)&&Po(t)?es(t,e.flat(1)):[],ha=(...t)=>{t=t.flat(1);return Ks(t)},ua=(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},S=(e,n,i)=>{let r=-1,o=(n=Ko(n,e)).length;for(o||(o=1,e=void 0);++r<o;){let t=null==e?void 0:e[ns(n[r])];void 0===t&&(r=o,t=i),e="function"==typeof t?t.call(e):t}return e},ca=(n,...i)=>{let r={};if(null!=n){let e=!1,t=(i=i.flat(1).map(t=>(t=Ko(t,n),e=e||1<t.length,t)),Ao(n,Bo(n),r),e&&(r=is(r,!0,!0,!0,t=>y(t)?void 0:t)),i.length);for(;t--;){s=o=void 0;var o=r,s=i[t];s=Ko(s,o),o=os(o,s),s=s[s.length-1],null!=o&&delete o[ns(s)]}}return r},da=(t,...e)=>{return null==t?{}:(n=t,t=e.flat(1/0),Ms(n,t,(t,e)=>As(n,e)));var n},fa=(t,e=t=>t)=>{let n=-1;var i=Object(t),r=Po(t)?fo(t,!0):ls(t);let o=r.length;for(;o--;){var s=r[++n];if(!1===e(i[s],s,i))break}},pa=(t="")=>Fs((""+t).replace(/['\u2019]/g,"")).reduce((t,e,n)=>(e=e.toLowerCase(),t+(n?Bs(e):e)),""),ga=0,ma=(t="")=>""+t+ ++ga,_=cs((t,e,n,i)=>{ds(t,e,n,i)},!0);class va{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 t=this.map.get(t),void 0===e?t:t[e]}set(t,e,n){void 0!==e&&(t=this.create(t),"string"==typeof e?t[e]=n:Object.assign(t,e))}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}}function ya(t,e){if(!(this instanceof ya))return new ya(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?xa:Aa,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}let ba=new va,wa=new va;function xa(){return!0}function Aa(){return!1}ya.prototype={constructor:ya,isDefaultPrevented:Aa,isPropagationStopped:Aa,isImmediatePropagationStopped:Aa,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=xa,t&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=xa,t&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=xa,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=>{var e;e=t,Object.defineProperty(ya.prototype,e,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[e]:void 0},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})});let Pa="undefined"!=typeof window?window.document:null,Ta=Pa&&Pa.documentElement,Ea=/^([^.]*)(?:\.(.+)|)/,Sa=/[^\x20\t\r\n\f]+/g,L=function(t){return new L.Dom(t)},_a=(L.fn=L.prototype={constructor:L,length:0},L.guid=1,L.data=wa,L.merge=function(e,n){var i=+n.length;let r=e.length;for(let t=0;t<i;t++)e[r++]=n[t];return e.length=r,e},L.parseHTML=function(t){var e=Pa.implementation.createHTMLDocument(),n=e.createElement("base"),i=(n.href=Pa.location.href,e.head.appendChild(n),e.body.innerHTML=t,e.getElementsByTagName("script"));for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(L.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),L.fn.toArray=function(){return Array.from(this)},L.fn.pushStack=function(t){t=L.merge(this.constructor(),t);return t.prevObject=this,t},L.fn.find=function(t){var e,[n]=this,i=this.pushStack([]);return n&&(e=n.nodeType,1!==e&&9!==e&&11!==e||("string"!=typeof t?n!==t&&n.contains(t)&&L.merge(i,[t]):L.merge(i,n.querySelectorAll(t)))),i},L.fn.add=function(t){var t=L(t).toArray(),e=this.toArray(),n=this.pushStack([]);return L.merge(n,Ks(e.concat(t))),n},L.fn.addBack=function(){return this.add(this.prevObject)},L.fn.filter=function(e){var n=[];for(let t=0;t<this.length;t++){var i=this[t];i.matches(e)&&n.push(i)}return this.pushStack(n)},/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/);function La(e){if(e){if("function"==typeof e)throw new Error("function not supported");if(1<arguments.length)throw new Error("selector with context not supported");if(e.nodeType)this[0]=e,this.length=1;else{let t;if("<"===(n=e+"")[0]&&">"===n[n.length-1]&&3<=n.length)t=[null,e,null];else{if("string"!=typeof e)return L.merge(this,e);t=_a.exec(e)}var n;if(!t||!t[1])return ka.find(e);t[1]?L.merge(this,L.parseHTML(t[1])):(n=Pa.getElementById(t[2]))&&(this[0]=n,this.length=1)}}return this}(L.Dom=La).prototype=L.fn,L.Event=ya,L.event={special:Object.create(null)},L.event.has=function(t,e){t=ba.get(t,"events");return!!t&&(!e||Array.isArray(t[e])&&0<t[e].length)},L.event.on=function(e,n,i,r,o,t){if("object"==typeof n){for(var s in"string"!=typeof i&&(r=r||i,i=void 0),n)L.event.on(e,s,i,r,n[s],t);return e}if(null==r&&null==o?(o=i,r=i=void 0):null==o&&("string"==typeof i?(o=r,r=void 0):(o=r,r=i,i=void 0)),!o)return e;if(1===t){let e=o;(o=function(t){return L().off(t),e.apply(this,arguments)}).guid=e.guid||(e.guid=L.guid++)}for(let t=0;t<e.length;t++)L.event.add(e[t],n,o,r,i)},L.event.add=function(r,o,s,a,l){if("object"==typeof r){var h=ba.create(r);let e;s.handler&&(s=(e=s).handler,l=e.selector),l&&Ta.matches(l),s.guid||(s.guid=L.guid++);let n;n=(n=h.events)||(h.events=Object.create(null));let i;i=(i=h.handle)||(h.handle=function(t){return void 0!==L?L.event.dispatch.apply(r,arguments):void 0});var u=(o||"").match(Sa)||[""];let t=u.length;for(;t--;){var[,c,d=""]=Ea.exec(u[t]);if(c){var d=d.split(".").sort(),f=(p=L.event.special[c])&&(l?p.delegateType:p.bindType)||c,p=L.event.special[f],c=Object.assign({type:f,origType:c,data:a,handler:s,guid:s.guid,selector:l,namespace:d.join(".")},e);let t;(t=n[f])||((t=n[f]=[]).delegateCount=0,p&&p.setup&&!1!==p.setup.call(r,a,d,i))||r.addEventListener&&r.addEventListener(f,i),p&&p.add&&(p.add.call(r,c),c.handler.guid||(c.handler.guid=s.guid)),l?t.splice(t.delegateCount++,0,c):t.push(c)}}}},L.event.remove=function(e,n,i,r,o){var s=ba.get(e);if(s&&s.events){var a=s.events,l=(n||"").match(Sa)||[""];let t=l.length;for(;t--;){var[,h,u=""]=Ea.exec(l[t]);if(h){var c=L.event.special[h],d=c&&(r?c.delegateType:c.bindType)||h,f=a[d];if(f&&0!==f.length){var p=u.split(".").sort(),g=u?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,u=f.length;let t=u;for(;t--;){var m=f[t];!o&&h!==m.origType||i&&i.guid!==m.guid||g&&!g.test(m.namespace)||r&&r!==m.selector&&("**"!==r||!m.selector)||(f.splice(t,1),m.selector&&f.delegateCount--,c&&c.remove&&c.remove.call(e,m))}u&&0===f.length&&(c&&c.teardown&&!1!==c.teardown.call(e,p,s.handle)||e.removeEventListener&&e.removeEventListener(d,s.handle),delete a[d])}}else for(var v in a)L.event.remove(e,v+l[t],i,r,!0)}ea(a)&&(ba.remove(e,"handle"),ba.remove(e,"events"))}},L.event.dispatch=function(e){var n=L.event.fix(e),i=(n.delegateTarget=this,Array.from(arguments)),e=(i[0]=n,ba.get(this,"events")),e=e&&e[n.type]||[],r=L.event.special[n.type];if(!r||!r.preDispatch||!1!==r.preDispatch.call(this,n)){var o,s,a=L.event.handlers.call(this,n,e);let t=0;for(;(o=a[t++])&&!n.isPropagationStopped();){n.currentTarget=o.elem;let t=0;for(;(s=o.handlers[t++])&&!n.isImmediatePropagationStopped();){n.handleObj=s,n.data=s.data;var l=L.event.special[s.origType];let t;l=(t=l&&l.handle?l.handle:s.handler).apply(o.elem,i);void 0!==l&&!1===(n.result=l)&&(n.preventDefault(),n.stopPropagation())}}return r&&r.postDispatch&&r.postDispatch.call(this,n),n.result}},L.event.handlers=function(t,n){var i=n.delegateCount,r=[];if(i&&!("click"===t.type&&1<=t.button))for(let e=t.target;e!==this;e=e.parentNode||this)if(1===e.nodeType&&("click"!==t.type||!0!==e.disabled)){var o=[],s={};for(let t=0;t<i;t++){var a=n[t],l=a.selector+" ";void 0===s[l]&&(s[l]=e.matches(l)),s[l]&&o.push(a)}o.length&&r.push({elem:e,handlers:o})}return i<n.length&&r.push({elem:this,handlers:n.slice(i)}),r},L.event.fix=function(t){return t.envelope?t:new ya(t)};let ka=L(Pa),Ca="http://www.w3.org/2000/svg",Ma="http://www.w3.org/2000/xmlns/",Na="http://www.w3.org/1999/xlink";var Oa,Ra,Va={__proto__:null,svg:Ca,xhtml:"http://www.w3.org/1999/xhtml",xlink:Na,xml:"http://www.w3.org/XML/1998/namespace",xmlns:Ma};let Ia="object"==typeof window&&!!window.SVGAngle,Fa=Ia?Da():null,Ba=Ia?za("g"):null;function Da(){var t=za("svg");return t.setAttributeNS(Ma,"xmlns:xlink",Na),t.setAttribute("version","1.1"),t}function za(t){return document.createElementNS(Ca,t)}function ja(t,e){let n=t;do{if(n.contains(e))return n}while(n=n.parentNode);return null}function Ga(){return Fa.createSVGMatrix()}function Ua(t={}){var e=Fa.createSVGMatrix();return t&&("a"in t&&(e.a=t.a),"b"in t&&(e.b=t.b),"c"in t&&(e.c=t.c),"d"in t&&(e.d=t.d),"e"in t&&(e.e=t.e),"f"in t)&&(e.f=t.f),e}function Ha(t){t=t.transform.baseVal.consolidate();return t?t.matrix:null}function qa(t,e){var n=Fa.createSVGTransform(),e=Wa(e)?e:Ua(e);n.setMatrix(e),t.transform.baseVal.appendItem(n)}let $a="[object SVGMatrix]";function Wa(t){return Object.prototype.toString.call(t)===$a}function Ya(t={}){var{a:t=1,b:e=0,c:n=0,d:i=1,e:r=0,f:o=0}=t;return`matrix(${t},${e},${n},${i},${r},${o})`}function Xa(t,e){var n=[];let i=e;for(;i&&i.nodeType===Node.ELEMENT_NODE&&i!==t;){var r=Ha(i);r&&n.unshift(r),i=i.parentNode}return n.reduce((t,e)=>t.multiply(e),Ga())}let R=(()=>{if(!Ia)return function(){throw new Error("SVG is required to use Vectorizer.")};function N(t,e,n){if(!(this instanceof N))return N.apply(Object.create(N.prototype),arguments);if(t){if(N.isV(t)&&(t=t.node),e=e||{},N.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=N.createSvgDocument();else if("<"===t[0]){var i=N.createSvgDocument(t);if(1<i.childNodes.length){for(var r=[],o=0,s=i.childNodes.length;o<s;o++){var a=i.childNodes[o];r.push(new N(document.importNode(a,!0)))}return r}t=document.importNode(i.firstChild,!0)}else t=za(t);N.ensureId(t)}return this.node=t,this.setAttributes(e),n&&this.append(n),this}}var h=(t=Math).PI,i=t.atan2,o=t.sqrt,l=t.min,a=t.max,u=t.cos,c=t.sin,t=N.prototype;Object.defineProperty(t,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),t.getTransformToElement=function(t,e){var n,i,r=this.node,t=N.toNode(t);let o;return(o=N.isSVGGraphicsElement(t)&&N.isSVGGraphicsElement(r)?e&&e.safe?(e=r)===(n=t)?Ga():(i=e.compareDocumentPosition(n))&Node.DOCUMENT_POSITION_CONTAINED_BY?Xa(e,n).inverse():i&Node.DOCUMENT_POSITION_CONTAINS?Xa(n,e):(i=ja(e,n))?(e=Xa(i,e),Xa(i,n).inverse().multiply(e)):null:(i=t,((n=r).ownerSVGElement||n)===(i.ownerSVGElement||i)&&(i=i.getScreenCTM())&&(n=n.getScreenCTM())?i.inverse().multiply(n):null):o)||Ga()},t.transform=function(t,e){var n=this.node;return N.isUndefined(t)?Ha(n)||Ga():(e&&e.absolute?n.setAttribute("transform",Ya(t)):qa(n,t),this)},t.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=N.parseTransformString(i),i=r.value;if(N.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();t=n.absolute?t:r.translate.tx+t,n=n.absolute?e:r.translate.ty+e;return this.attr("transform",("translate("+t+","+n+")"+" "+i).trim()),this},t.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=N.parseTransformString(r),r=o.value;if(N.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;i=i.absolute?t:o.rotate.angle+t;return this.attr("transform",(r+" "+("rotate("+i+(void 0!==e&&void 0!==n?","+e+","+n:"")+")")).trim()),this},t.scale=function(t,e){e=N.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=N.parseTransformString(n),n=i.value;return N.isUndefined(t)?i.scale:(n=n.replace(/scale\([^)]*\)/g,"").trim(),this.attr("transform",(n+" "+("scale("+t+","+e+")")).trim()),this)},t.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new tt(0,0,0,0);try{n=i.getBBox()}catch{n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}return t?new tt(n):(i=this.getTransformToElement(e||r),N.transformRect(n,i))},t.getBBox=function(t){var e={},n=this.node;if(!n.ownerSVGElement||!N.isSVGGraphicsElement(n))return new tt(0,0,0,0);if(t&&(t.target&&(e.target=N.toNode(t.target)),t.recursive)&&(e.recursive=t.recursive),e.recursive){var i=this.children(),r=i.length;if(0===r)return this.getBBox({target:e.target,recursive:!1});e.target||(e.target=this);for(var o=0;o<r;o++)var s=i[o],s=0===s.children().length?s.getBBox({target:e.target,recursive:!1}):s.getBBox({target:e.target,recursive:!0}),a=a?a.union(s):s;return a}try{a=n.getBBox()}catch{a={x:n.clientLeft,y:n.clientTop,width:n.clientWidth,height:n.clientHeight}}return e.target?(t=this.getTransformToElement(e.target),N.transformRect(a,t)):new tt(a)};var y,b,T,E,S,_,L,k,C,O=/em$/;function R(t,e){var n=parseFloat(t);return O.test(t)?n*e:n}t.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");null==t&&(t=""),(e=e||{}).useNoBreakSpace&&(t=N.sanitizeText(t));for(var n,i,r,o,s=e.displayEmpty,a=e.eol,l=e.textPath,h=e.textVerticalAnchor,u="middle"===h||"bottom"===h||"top"===h,c=e.x,d=(void 0===c&&(c=this.attr("x")||0),e.includeAnnotationIndices),f=e.annotations,e=(f&&!N.isArray(f)&&(f=[f]),e.lineHeight),p="auto"===e,g=p?"1.5em":e||"1em",m=(this.empty(),this.attr({"xml:space":"preserve",display:t||s?null:"none"}),parseFloat(this.attr("font-size"))),v=(!m&&(m=16,u||f)&&this.attr("font-size",m),document),y=l?(e=this,s=(s=l="string"==typeof l?{d:l}:l)||{},n=N("textPath"),(i=s.d)&&void 0===s["xlink:href"]&&(i=N("path").attr("d",i).appendTo(e.defs()),n.attr("xlink:href","#"+i.id)),N.isObject(s)&&n.attr(s),n.node):v.createDocumentFragment(),b=0,w=t.split("\n"),x=[],A=0,P=w.length-1;A<=P;A++){var T,E,S=g,_="v-line",L=v.createElementNS(Ca,"tspan"),k=w[A];if(k)f?((C=(E=((t,e,n)=>{for(var i=(n=n||{}).includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,n={},l=e.length-1,h=0;h<=l;h++){var u,c,d,f,p=e[h],g=null;N.isObject(p)?(u=p.attrs,d=(c=N("tspan",u)).node,f=p.t,r&&h===l&&(f+=r),d.textContent=f,(f=u.class)&&c.addClass(f),i&&c.attr("annotations",p.annotations),g=parseFloat(u["font-size"]),(g=isFinite(g)?g:s)&&a<g&&(a=g)):(r&&h===l&&(p+=r),d=document.createTextNode(p||" "),s&&a<s&&(a=s)),t.appendChild(d)}return a&&(n.maxFontSize=a),o?n.lineHeight=o:a&&(n.lineHeight=1.2*a),n})(L,T=N.annotateString(k,f,{offset:-b,includeAnnotationIndices:d}),{includeAnnotationIndices:d,eol:A!==P&&a,lineHeight:p?null:g,baseSize:m})).lineHeight)&&p&&0!==A&&(S=C),0===A&&(r=.8*E.maxFontSize)):(a&&A!==P&&(k+=a),L.textContent=k);else{L.textContent="-",_+=" v-empty-line";var C=L.style;if(C.fillOpacity=0,C.strokeOpacity=0,f){E={};let e=m;for(let t=(T=N.findAnnotationsAtIndex(f,b)).length;0<t;t--){var M=T[t-1].attrs;if(M&&"font-size"in M){M=parseFloat(M["font-size"]);if(isFinite(M)){e=M;break}}}p&&(0<A?S=1.2*e:r=.8*e),L.setAttribute("font-size",e),E.maxFontSize=e}}E&&x.push(E),0<A&&L.setAttribute("dy",S),(0<A||l)&&L.setAttribute("x",c),L.className.baseVal=_,y.appendChild(L),b+=k.length+1}if(u)if(f)S=((t,e,n,i)=>{if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=R(o.maxFontSize,n)||n,a=0,l=R(i,n),h=1;h<r;h++)a+=R((o=e[h]).lineHeight,n)||l;var u,c=R(o.maxFontSize,n)||n;switch(t){case"middle":u=s/2-.15*c-a/2;break;case"bottom":u=-.25*c-a;break;default:u=.8*s}return u})(h,x,m,g);else if("top"===h)S="0.8em";else switch(0<P?(o=parseFloat(g)||1,o*=P,O.test(g)||(o/=m)):o=0,h){case"middle":S=.3-o/2+"em";break;case"bottom":S=-o-.3+"em"}else 0===h?S="0em":h?S=h:(S=0,null===this.attr("y")&&this.attr("y",r||"0.8em"));return y.firstChild.setAttribute("dy",S),this.append(y),this},t.removeAttr=function(t){var t=s[t],{ns:e,local:n}=N.qualifyAttr(t),i=this.node;return e?i.hasAttributeNS(e,n)&&i.removeAttributeNS(e,n):i.hasAttribute(t)&&i.removeAttribute(t),this},t.attr=function(t,e){if(N.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(N.isString(t)&&N.isUndefined(e))return this.node.getAttribute(s[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},t.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",N.normalizePathData(this.attr("d"))),this},t.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},t.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},t.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},t.append=function(t){for(var e=0,n=(t=N.isArray(t)?t:[t]).length;e<n;e++)this.node.appendChild(N.toNode(t[e]));return this},t.prepend=function(t){var e=this.node.firstChild;return e?N(e).before(t):this.append(t)},t.before=function(t){var e=this.node,n=e.parentNode;if(n)for(var i=0,r=(t=N.isArray(t)?t:[t]).length;i<r;i++)n.insertBefore(N.toNode(t[i]),e);return this},t.appendTo=function(t){return N.toNode(t).appendChild(this.node),this},t.svg=function(){return this.node instanceof window.SVGSVGElement?this:N(this.node.ownerSVGElement)},t.tagName=function(){return this.node.tagName.toUpperCase()},t.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?N(e):N("defs").appendTo(t)},t.clone=function(){var t=N(this.node.cloneNode(!0));return t.node.id=N.uniqueId(),t},t.findOne=function(t){t=this.node.querySelector(t);return t?N(t):void 0},t.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(N(n[i]));return e},t.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(N(t[n]));return e},t.parent=function(){return N(this.node.parentNode)||null},t.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},t.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=N(i);if(r.hasClass(t))return r;i=i.parentNode}return null},t.contains=function(t){var e=this.node,t=N.toNode(t),t=t&&t.parentNode;return e===t||!!(t&&1===t.nodeType&&16&e.compareDocumentPosition(t))},t.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{return i}return r.matrixTransform(o)},t.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},t.translateAndAutoOrient=function(t,e,n){t=new A(t),e=new A(e),n=n||this.svg();var i=this.scale(),r=(this.attr("transform",""),this.getBBox({target:n}).scale(i.sx,i.sy)),o=N.createSVGTransform(),s=(o.setTranslate(-r.x-r.width/2,-r.y-r.height/2),N.createSVGTransform()),a=t.angleBetween(e,t.clone().offset(1,0)),a=(a&&s.setRotate(a,0,0),N.createSVGTransform()),e=t.clone().move(e,r.width/2),r=(a.setTranslate(2*t.x-e.x,2*t.y-e.y),this.getTransformToElement(n)),t=N.createSVGTransform();return t.setMatrix(a.matrix.multiply(s.matrix.multiply(o.matrix.multiply(r.scale(i.sx,i.sy))))),this.attr("transform",Ya(t.matrix)),this},t.animateAlongPath=function(t,e){e=N.toNode(e);e=N.ensureId(e),t=N("animateMotion",t),e=N("mpath",{"xlink:href":"#"+e});t.append(e),this.append(t);try{t.node.beginElement()}catch{if("fake"===document.documentElement.getAttribute("smiling"))for(var n=t.node,e=(n.animators=[],n.getAttribute("id")),i=(e&&(id2anim[e]=n),getTargets(n)),r=0,o=i.length;r<o;r++){var s=i[r],s=new Animator(n,s,r);animators.push(s),(n.animators[r]=s).register()}}return this};let e=/[^\x20\t\r\n\f]+/g;function r(t){return N.isString(t)&&t.trim().match(e)||[]}t.hasClass=function(t){return!!N.isString(t)&&this.node.classList.contains(t.trim())},t.addClass=function(t){return this.node.classList.add(...r(t)),this},t.removeClass=function(t){return this.node.classList.remove(...r(t)),this},t.toggleClass=function(t,e){var n=r(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},t.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},t.convertToPath=function(){var t=N("path"),e=(t.attr(this.attr()),this.convertToPathData());return e&&t.attr("d",e),t},t.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return N.convertLineToPathData(this.node);case"POLYGON":return N.convertPolygonToPathData(this.node);case"POLYLINE":return N.convertPolylineToPathData(this.node);case"ELLIPSE":return N.convertEllipseToPathData(this.node);case"CIRCLE":return N.convertCircleToPathData(this.node);case"RECT":return N.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},N.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s;switch(this.tagName()){case"RECT":return i=parseFloat(this.attr("x"))||0,s=parseFloat(this.attr("y"))||0,t=parseFloat(this.attr("width"))||0,n=parseFloat(this.attr("height"))||0,new tt(i,s,t,n);case"CIRCLE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,i=parseFloat(this.attr("r"))||0,new vi({x:o,y:r},i,i);case"ELLIPSE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,t=parseFloat(this.attr("ry"))||0,new vi({x:o,y:r},s,t);case"POLYLINE":return e=N.getPointsFromSvgNode(this),new w(e);case"POLYGON":return 1<(e=N.getPointsFromSvgNode(this)).length&&e.push(e[0]),new w(e);case"PATH":return n=this.attr("d"),I.isDataSupported(n)||(n=N.normalizePathData(n)),new I(n);case"LINE":return i=parseFloat(this.attr("x1"))||0,o=parseFloat(this.attr("y1"))||0,r=parseFloat(this.attr("x2"))||0,s=parseFloat(this.attr("y2"))||0,new P({x:i,y:o},{x:r,y:s})}return this.getBBox()},t.findIntersection=function(t,e){var n=this.svg().node,i=this.getBBox({target:e=e||n}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){i=this.tagName();if("RECT"===i)var o=new tt(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),s=this.getTransformToElement(e),a=N.decomposeMatrix(s),n=n.createSVGTransform(),o=(n.setRotate(-a.rotation,r.x,r.y),N.transformRect(o,n.matrix.multiply(s))),s=new tt(o).intersectionWithLineFromCenterToPoint(t,a.rotation);else if("PATH"===i||"POLYGON"===i||"POLYLINE"===i||"CIRCLE"===i||"ELLIPSE"===i){for(var l,h,u,c=("PATH"===i?this:this.convertToPath()).sample(),d=1/0,f=[],p=0;p<c.length;p++)l=c[p],h=(h=N.createSVGPoint(l.x,l.y)).matrixTransform(this.getTransformToElement(e)),(u=(l=new A(h)).distance(r)+(h=1.1*l.distance(t)))<d?(d=u,f=[{sample:l,refDistance:h}]):u<d+1&&f.push({sample:l,refDistance:h});f.sort(function(t,e){return t.refDistance-e.refDistance}),f[0]&&(s=f[0].sample)}return s}},t.setAttribute=function(t,e){var n,i=this.node;return null===e?this.removeAttr(t):(t=s[t],n=N.qualifyAttr(t).ns,n?i.setAttributeNS(n,t,e):"id"===t?i.id=e:i.setAttribute(t,e)),this},N.createSvgDocument=function(t){return t?(t=`<svg xmlns="${Ca}" xmlns:xlink="${Na}" version="1.1">${t}</svg>`,t=N.parseXML(t,{async:!1}).documentElement,t):Da()},N.createSVGStyle=function(t){t=N("style",{type:"text/css"},[N.createCDATASection(t)]).node;return t},N.createCDATASection=function(t=""){return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},N.idCounter=0,N.uniqueId=function(){return"v-"+ ++N.idCounter},N.toNode=function(t){return N.isV(t)?t.node:t.nodeName&&t||t[0]},N.ensureId=function(t){return(t=N.toNode(t)).id||(t.id=N.uniqueId())},N.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},N.isUndefined=function(t){return void 0===t},N.isString=function(t){return"string"==typeof t},N.isObject=function(t){return t&&"object"==typeof t},N.isArray=Array.isArray,N.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;N.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch{n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};let n=Object.create(null),s=(["attributeName","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","repeatCount","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach(t=>n[t]=t),n.xlinkShow="xlink:show",n.xlinkRole="xlink:role",n.xlinkActuate="xlink:actuate",n.xlinkHref="xlink:href",n.xlinkType="xlink:type",n.xlinkTitle="xlink:title",n.xmlBase="xml:base",n.xmlLang="xml:lang",n.xmlSpace="xml:space",new Proxy(n,{get(t,e){return N.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e}}));function f(t,e,n,i,r,o){return[1/3*t+2/3*n,1/3*e+2/3*i,1/3*r+2/3*n,1/3*o+2/3*i,r,o]}function M(t,e,n){return{x:t*S(n)-e*E(n),y:t*E(n)+e*S(n)}}function V(t,e,n,i,r,o,s,a,l,h){var u=120*T/180,c=T/180*(+r||0),d=[];if(h)b=h[0],w=h[1],v=h[2],y=h[3];else{t=(p=M(t,e,-c)).x,e=p.y;var f=(t-(a=(p=M(a,l,-c)).x))/2,p=(e-(l=p.y))/2,g=f*f/(n*n)+p*p/(i*i),g=(1<g&&(n*=g=k(g),i*=g),n*n),m=i*i,o=(o==s?-1:1)*k(C((g*m-g*p*p-m*f*f)/(g*p*p+m*f*f)));if(!Number.isFinite(o))return[t,e,a,l,a,l];var v=o*n*p/i+(t+a)/2,y=o*-i*f/n+(e+l)/2,b=L(((e-y)/i).toFixed(9)),w=L(((l-y)/i).toFixed(9));(b=t<v?T-b:b)<0&&(b=2*T+b),(w=a<v?T-w:w)<0&&(w=2*T+w),s&&w<b&&(b-=2*T),!s&&b<w&&(w-=2*T)}C(w-b)>u&&(g=w,m=a,p=l,d=V(a=v+n*S(w=b+u*(s&&b<w?1:-1)),l=y+i*E(w),n,i,r,0,s,m,p,[w,g,v,y])),o=w-b;f=S(b),u=E(b),r=S(w),s=E(w),m=_(o/4),p=4/3*(n*m),g=4/3*(i*m),v=[t,e],y=[t+p*u,e-g*f],b=[a+p*s,l-g*r],w=[a,l];if(y[0]=2*v[0]-y[0],y[1]=2*v[1]-y[1],h)return[y,b,w].concat(d);for(var x=[],A=(d=[y,b,w].concat(d).join().split(",")).length,P=0;P<A;P++)x[P]=P%2?M(d[P-1],d[P],c).y:M(d[P],d[P+1],c).x;return x}function p(t){var e,o,s;if(!(t=Array.isArray(t)&&Array.isArray(t&&t[0])?t:(e=t)?(o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=[],String(e).replace(y,function(t,e,n){var i=[],r=e.toLowerCase();for(n.replace(b,function(t,e){e&&i.push(+e)}),"m"===r&&2<i.length&&(s.push([e].concat(i.splice(0,2))),r="l",e="m"===e?"l":"L");o[r]<=i.length&&(s.push([e].concat(i.splice(0,o[r]))),o[r]););}),s):null)||!t.length)return[["M",0,0]];for(var n=[],i=0,r=0,a=0,l=0,h=t.length,u=0;u<h;u++){var c,d,f=[],p=(n.push(f),t[u]),g=p[0];if(g!=g.toUpperCase())switch(f[0]=g.toUpperCase(),f[0]){case"A":f[1]=p[1],f[2]=p[2],f[3]=p[3],f[4]=p[4],f[5]=p[5],f[6]=+p[6]+i,f[7]=+p[7]+r;break;case"V":f[1]=+p[1]+r;break;case"H":f[1]=+p[1]+i;break;case"M":for(a=+p[1]+i,l=+p[2]+r,c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r);break;default:for(c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r)}else for(var m=p.length,v=0;v<m;v++)f[v]=p[v];switch(f[0]){case"Z":i=+a,r=+l;break;case"H":i=f[1];break;case"V":r=f[1];break;case"M":a=f[f.length-2],l=f[f.length-1],i=f[f.length-2],r=f[f.length-1];break;default:i=f[f.length-2],r=f[f.length-1]}}return n}function d(t){var e=p(t),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};for(var i=[],r="",o="",s=e.length,a=0;a<s;a++){"C"!==(r=e[a]?e[a][0]:r)&&(i[a]=r,0<a)&&(o=i[a-1]),e[a]=((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(V.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":r="C"===n||"S"===n?(i=2*e.x-e.bx,2*e.y-e.by):(i=e.x,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(f(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(f(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})(e[a],n,o),"A"!==i[a]&&"C"===r&&(i[a]="C"),u=h=l=void 0;var l=e,h=a;if(7<l[h].length){l[h].shift();for(var u=l[h];u.length;)i[h]="A",l.splice(h++,0,["C"].concat(u.splice(0,6)));l.splice(h,1),s=e.length}var c=e[a],d=c.length;n.x=c[d-2],n.y=c[d-1],n.bx=parseFloat(c[d-4])||n.x,n.by=parseFloat(c[d-3])||n.y}return e[0][0]&&"M"===e[0][0]||e.unshift(["M",0,0]),e}return Object.defineProperty(N,"attributeNames",{enumerable:!0,value:s,writable:!1}),Object.defineProperty(N,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),N.qualifyAttr=function(t){var e;return-1!==t.indexOf(":")?(e=t.split(":"),{ns:Va[e[0]],local:e[1]}):{ns:null,local:t}},N.transformSeparatorRegex=/[ ,]+/,N.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,N.transformTranslateRegex=/\btranslate\(([^()]+)\)/,N.transformRotateRegex=/\brotate\(([^()]+)\)/,N.transformScaleRegex=/\bscale\(([^()]+)\)/,N.transformStringToMatrix=function(t){let e;return(e=N.isString(t)?(t=t,Ba.setAttribute("transform",t),Ha(Ba)):e)||Ga()},N.matrixToTransformString=Ya,N.parseTransformString=function(t){t&&(e=N.transformSeparatorRegex,0<=t.trim().indexOf("matrix")?(r=N.transformStringToMatrix(t),n=[(r=N.decomposeMatrix(r)).translateX,r.translateY],i=[r.scaleX,r.scaleY],r=[r.rotation],o=[],0===n[0]&&0===n[1]||o.push("translate("+n+")"),1===i[0]&&1===i[1]||o.push("scale("+i+")"),0!==r[0]&&o.push("rotate("+r+")"),t=o.join(" ")):((o=t.match(N.transformTranslateRegex))&&(n=o[1].split(e)),(o=t.match(N.transformRotateRegex))&&(r=o[1].split(e)),(o=t.match(N.transformScaleRegex))&&(i=o[1].split(e))));var e,n,i,r,o=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:n&&n[0]?parseInt(n[0],10):0,ty:n&&n[1]?parseInt(n[1],10):0},rotate:{angle:r&&r[0]?parseInt(r[0],10):0,cx:r&&r[1]?parseInt(r[1],10):void 0,cy:r&&r[2]?parseInt(r[2],10):void 0},scale:{sx:o,sy:i&&i[1]?parseFloat(i[1]):o}}},N.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c,y:e.x*t.b+e.y*t.d}},N.decomposeMatrix=function(t){var e=N.deltaTransformPoint(t,{x:0,y:1}),n=N.deltaTransformPoint(t,{x:1,y:0}),e=180/h*i(e.y,e.x)-90,n=180/h*i(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:e,skewY:n,rotation:e}},N.matrixToScale=function(t){var e,n,i,r;return t?(e=N.isUndefined(t.a)?1:t.a,r=N.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}},N.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=N.deltaTransformPoint(t,e)),{angle:Yn(Un(i(e.y,e.x))-90)}},N.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},N.isVElement=N.isV=function(t){return t instanceof N},N.isSVGGraphicsElement=function(t){return!!t&&(t=N.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM},N.createSVGMatrix=Ua,N.createSVGTransform=function(t){return N.isUndefined(t)?Fa.createSVGTransform():(Wa(t)||(t=Ua(t)),Fa.createSVGTransformFromMatrix(t))},N.createSVGPoint=function(t,e){var n=Fa.createSVGPoint();return n.x=t,n.y=e,n},N.transformRect=function(t,e){var n=Fa.createSVGPoint(),i=(n.x=t.x,n.y=t.y,n.matrixTransform(e)),r=(n.x=t.x+t.width,n.y=t.y,n.matrixTransform(e)),o=(n.x=t.x+t.width,n.y=t.y+t.height,n.matrixTransform(e)),t=(n.x=t.x,n.y=t.y+t.height,n.matrixTransform(e)),n=l(i.x,r.x,o.x,t.x),e=a(i.x,r.x,o.x,t.x),s=l(i.y,r.y,o.y,t.y),i=a(i.y,r.y,o.y,t.y);return new tt(n,s,e-n,i-s)},N.transformPoint=function(t,e){return new A(N.createSVGPoint(t.x,t.y).matrixTransform(e))},N.transformLine=function(t,e){return new P(N.transformPoint(t.start,e),N.transformPoint(t.end,e))},N.transformPolyline=function(t,e){for(var n=t instanceof w?t.points:t,i=[],r=0,o=(n=N.isArray(n)?n:[]).length;r<o;r++)i[r]=N.transformPoint(n[r],e);return new w(i)},N.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},N.createSlicePathData=function(t,e,n,i){var r=2*h-1e-6,o=(i<n&&(o=n,n=i,i=o),i-n),s=o<h?"0":"1",a=u(n),n=c(n),l=u(i),i=c(i);return r<=o?t?"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":t?"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L"+t*l+","+t*i+"A"+t+","+t+" 0 "+s+",0 "+t*a+","+t*n+"Z":"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L0,0Z"},N.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?N.isObject(t[n])&&N.isObject(e[n])?t[n]=N.mergeAttrs(t[n],e[n]):N.isObject(t[n])?t[n]=N.mergeAttrs(t[n],N.styleToObject(e[n])):N.isObject(e[n])?t[n]=N.mergeAttrs(N.styleToObject(t[n]),e[n]):t[n]=N.mergeAttrs(N.styleToObject(t[n]),N.styleToObject(e[n])):t[n]=e[n];return t},N.annotateString=function(t,e,n){e=e||[];for(var i,r,o=(n=n||{}).offset||0,s=[],a=[],l=0;l<t.length;l++){for(var h=a[l]=t[l],u=0;u<e.length;u++){var c=e[u];c.start+o<=l&&l<c.end+o&&(N.isObject(h)?h.attrs=N.mergeAttrs(N.mergeAttrs({},h.attrs),c.attrs):h=a[l]={t:t[l],attrs:c.attrs},n.includeAnnotationIndices)&&(h.annotations||(h.annotations=[])).push(u)}(r=a[l-1])?N.isObject(h)&&N.isObject(r)?JSON.stringify(h.attrs)===JSON.stringify(r.attrs)?i.t+=h.t:(s.push(i),i=h):i=N.isObject(h)||N.isObject(r)?(s.push(i),h):(i||"")+h:i=h}return i&&s.push(i),s},N.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&n.push(t)}),n},N.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},N.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},N.convertLineToPathData=function(t){return["M",(t=N(t)).attr("x1")||"0",t.attr("y1")||"0","L",t.attr("x2")||"0",t.attr("y2")||"0"].join(" ")},N.convertPolygonToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)+" Z"},N.convertPolylineToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)},N.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")},N.getPointsFromSvgNode=function(t){var e=[],n=(t=N.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},N.KAPPA=.551784,N.convertCircleToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,t=parseFloat(t.attr("r")),i=t*N.KAPPA;return["M",e,n-t,"C",e+i,n-t,e+t,n-i,e+t,n,"C",e+t,n+i,e+i,n+t,e,n+t,"C",e-i,n+t,e-t,n+i,e-t,n,"C",e-t,n-i,e-i,n-t,e,n-t,"Z"].join(" ")},N.convertEllipseToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),t=parseFloat(t.attr("ry"))||i,r=i*N.KAPPA,o=t*N.KAPPA;return["M",e,n-t,"C",e+r,n-t,e+i,n-o,e+i,n,"C",e+i,n+o,e+r,n+t,e,n+t,"C",e-r,n+t,e-i,n+o,e-i,n,"C",e-i,n-o,e-r,n-t,e,n-t,"Z"].join(" ")},N.convertRectToPathData=function(t){return t=N(t),N.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})},N.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=l(t.rx||t["top-rx"]||0,i/2),s=l(t.rx||t["bottom-rx"]||0,i/2),a=l(t.ry||t["top-ry"]||0,r/2),t=l(t.ry||t["bottom-ry"]||0,r/2),s=o||s||a||t?["M",e,n+a,"v",r-a-t,"a",s,t,0,0,0,s,t,"h",i-2*s,"a",s,t,0,0,0,s,-t,"v",-(r-t-a),"a",o,a,0,0,0,-o,-a,"h",-(i-2*o),"a",o,a,0,0,0,-o,a,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"];return s.join(" ")},N.normalizePathData=(t="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",y=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),b=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),t=Math,T=t.PI,E=t.sin,S=t.cos,_=t.tan,L=t.asin,k=t.sqrt,C=t.abs,function(t){return d(t).join(",").split(",").join(" ")}),N.getCommonAncestor=function(t,e){return t&&e?ja(N.toNode(t),N.toNode(e)):null},N.namespace={...Va},N.g=yr,N})();function Za(t){let e=t.length;for(;e--;)Ja(t[e])}function Ja(t){L.event.remove(t),ba.remove(t),wa.remove(t)}function Ka(e){for(let t=0;t<e.length;t++){var n=e[t];n.parentNode&&n.parentNode.removeChild(n)}}let Qa={};function tl(e,n,i){for(let t=0;t<n.length;t++){var r=n[t];R.prototype[e].apply({node:r},i)}}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach(t=>{Qa[t]=!0});let el={__proto__:null,addClass:function(){return tl("addClass",this,arguments),this},append:function(...t){let[e]=this;return e&&t.forEach(t=>{t&&("string"==typeof t?e.append(...L.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))}),this},appendTo:function(t){return L(t).append(this),this},children:function(n){var i=[];for(let e=0;e<this.length;e++){var r=this[e];let t=Array.from(r.children);"string"==typeof n&&(t=t.filter(t=>t.matches(n))),i.push(...t)}return this.pushStack(i)},clone:function(){var e=[];for(let t=0;t<this.length;t++)e.push(this[t].cloneNode(!0));return this.pushStack(e)},closest:function(e){var n=[];for(let t=0;t<this.length;t++){var i,r=this[t];"string"==typeof e?(i=r.closest(e))&&n.push(i):([i]=L(e),i&&i.contains(r)&&n.push(i))}return this.pushStack(n)},css:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.style[t]:null;n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let e in n)if(n.hasOwnProperty(e))for(let t=0;t<this.length;t++)r=this[t],o=e,"number"==typeof(s=n[e])&&Qa[pa(o)]&&(s+="px"),r.style[o]=s;var r,o,s;return this},data:function(e,n){var t;if(arguments.length<2)return[t]=this,t?void 0===e?t.dataset:t.dataset[e]:null;for(let t=0;t<this.length;t++)this[t].dataset[e]=n;return this},detach:function(){return Ka(this),this},empty:function(){for(let t=0;t<this.length;t++){var e=this[t];1===e.nodeType&&(Za(e.getElementsByTagName("*")),e.textContent="")}return this},hasClass:function(){var[t]=this;return!!t&&R.prototype.hasClass.apply({node:t},arguments)},height:function(){var t,[e]=this;return e===window?e.document.documentElement.clientHeight:e?(t=window.getComputedStyle(e),e.offsetHeight-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)):void 0},html:function(t){var[e]=this;if(!e)return null;if(0===arguments.length)return e.innerHTML;if(void 0!==t){if(Za(e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t)return e.innerHTML="",this.append(t);e.innerHTML=t}return this},off:function(e,n,i){var t;if(e&&e.preventDefault&&e.handleObj)t=e.handleObj,L(e.delegateTarget).off(t.namespace?t.origType+"."+t.namespace:t.origType,t.selector,t.handler);else if("object"==typeof e)for(var r in e)this.off(r,n,e[r]);else{!1!==n&&"function"!=typeof n||(i=n,n=void 0);for(let t=0;t<this.length;t++)L.event.remove(this[t],e,i,n)}return this},offset:function(t){var e,n,[i]=this;return void 0===t?i?i.getClientRects().length?{top:(e=i.getBoundingClientRect()).top+window.scrollY,left:e.left+window.scrollX}:{top:0,left:0}:null:(i&&("static"===(e=window.getComputedStyle(i)).position&&this.css("position","relative"),i=this.offset(),n=t.top-i.top,t=t.left-i.left,this.css({top:(parseFloat(e.top)||0)+n+"px",left:(parseFloat(e.left)||0)+t+"px"})),this)},on:function(t,e,n,i){return L.event.on(this,t,e,n,i),this},one:function(t,e,n,i){return L.event.on(this,t,e,n,i,1),this},position:function(){var[i]=this;if(i){var r,o=L(i);let t,e,n={top:0,left:0};if("fixed"===o.css("position"))e=i.getBoundingClientRect();else{e=o.offset(),r=i.ownerDocument,t=i.offsetParent||r.documentElement;for(var s=t=>{t=getComputedStyle(t).position;return"static"===t};t&&t!==r.documentElement&&s(t);)t=t.offsetParent||r.documentElement;t&&t!==i&&1===t.nodeType&&!s(t)&&(o=window.getComputedStyle(t),a=parseFloat(o.borderTopWidth)||0,o=parseFloat(o.borderLeftWidth)||0,(n=L(t).offset()).top+=a,n.left+=o)}var a=parseFloat(window.getComputedStyle(i).marginTop)||0,o=parseFloat(window.getComputedStyle(i).marginLeft)||0;return{top:e.top-n.top-a,left:e.left-n.left-o}}},prepend:function(...t){let[e]=this;return e&&t.forEach(t=>{t&&("string"==typeof t?e.prepend(...L.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))}),this},prependTo:function(t){return L(t).prepend(this),this},remove:function(){for(let t=0;t<this.length;t++){var e=this[t];Ja(e),Za(e.getElementsByTagName("*"))}return Ka(this),this},removeClass:function(){return tl("removeClass",this,arguments),this},toggleClass:function(){return tl("toggleClass",this,arguments),this},width:function(){var t,e,[n]=this;return n===window?n.document.documentElement.clientWidth:n?(t=window.getComputedStyle(n),n=n.offsetWidth,e=parseFloat(t.borderTopWidth),n-parseFloat(t.borderBottomWidth)-e-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)):void 0}},nl="animationFrameId",il={},rl=(il["transition-property"]=il["transition-duration"]=il["transition-delay"]=il["transition-timing-function"]=il["animation-name"]=il["animation-duration"]=il["animation-delay"]=il["animation-timing-function"]="",{__proto__:null,animate:function(e,n={}){this.stop();for(let t=0;t<this.length;t++)((a,l,t={})=>{let{duration:h=400,easing:u="ease-in-out",delay:c=0,complete:d}=t,e=setTimeout(function(){let e=L(a),n=!1,i="transitionend";h/=1e3,c/=1e3;var t={};if("string"==typeof l)t["animation-name"]=l,t["animation-duration"]=h+"s",t["animation-delay"]=c+"s",t["animation-timing-function"]=u,i="animationend";else{var r,o=[];for(r in l)l.hasOwnProperty(r)&&(t[r]=l[r],o.push(r));0<h&&(t["transition-property"]=o.join(", "),t["transition-duration"]=h+"s",t["transition-delay"]=c+"s",t["transition-timing-function"]=u)}let s=function(t){if(t){if(t.target!==t.currentTarget)return;t.target.removeEventListener(i,s)}else a.removeEventListener(i,s);n=!0,e.css(il),d&&d.call(a)};if(0<h){a.addEventListener(i,s);let t=setTimeout(function(){n||s(null)},1e3*(h+c)+25);ba.set(a,nl,{id:t,stop:()=>{clearTimeout(t),a.removeEventListener(i,s)}})}e.css(t),h<=0&&s(null)});ba.set(a,nl,{stop:()=>clearTimeout(e)})})(this[t],e,n);return this},stop:function(){for(let t=0;t<this.length;t++){var e=this[t],n=ba.get(e,nl);n&&(n.stop(),ba.remove(e,nl))}return this.css(il),this}}),ol={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},sl={disabled:"disabled",value:"value",text:"textContent"};function al(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,hl.classNamePrefix.length)!==hl.classNamePrefix?hl.classNamePrefix+t:t}).join(" ")}let ll={prop:function(e,n){if(!e)throw new Error("no property provided");var t;if(1===arguments.length)return[t]=this,t?t[e]:null;if(void 0!==n)for(let t=0;t<this.length;t++)this[t][e]=n;return this},attr:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.getAttribute(t):null;n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(var r in n)if(n.hasOwnProperty(r)){let e=n[r];if(sl[r])this.prop(sl[r],e);else for(let t=0;t<this.length;t++)null===e?this[t].removeAttribute(r):this[t].setAttribute(r,e)}return this}},hl=(Object.keys(ol).forEach(e=>{ll[e]=function(...t){return this.prop(ol[e],...t)}}),{cellMergeStrategy:null,cellDefaultsMergeStrategy:null,useCSSSelectors:!1,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300}),ul=Object.create(null),cl=(ul.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach(([t,r])=>{ul[t]={delegateType:r,bindType:r,handle:function(t){var e=t.relatedTarget,n=t.handleObj;let i;return e&&this.contains(e)||(t.type=n.origType,i=n.handler.apply(this,arguments),t.type=r),i}}}),hl.doubleTapInterval);function dl(t,e){let d={},f={},p=R.namespace.svg;var e=e||p,n=document.createDocumentFragment();function g(e,n,i){for(let t=0;t<e.length;t++){var r=e[t];if("string"==typeof r){var o=document.createTextNode(r);n.appendChild(o)}else{if(!r.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var o=r.tagName,s=r.hasOwnProperty("namespaceURI")?r.namespaceURI:i,a=document.createElementNS(s,o),l=s===p,h=(l?R:L)(a),u=r.attributes,u=(u&&h.attr(u),r.style);if(u&&L(a).css(u),r.hasOwnProperty("className")&&(u=r.className,l?a.className.baseVal=u:a.className=u),r.hasOwnProperty("textContent")&&(a.textContent=r.textContent),r.hasOwnProperty("selector")){l=r.selector;if(d[l])throw new Error("json-dom-parser: selector must be unique");d[l]=a,h.attr("joint-selector",l)}if(r.hasOwnProperty("groupSelector")){let n=r.groupSelector;Array.isArray(n)||(n=[n]);for(let e=0;e<n.length;e++){var c=n[e];let t=f[c];(t=t||(f[c]=[])).push(a)}}n.appendChild(a);u=r.children;Array.isArray(u)&&g(u,a,s)}}}return g(t,n,e),{fragment:n,selectors:d,groupSelectors:f}}function fl(e){let n=0;if(0!==e.length)for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return n}function pl(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}function gl(t,e){return("constructor"!==(e="string"!=typeof e&&"number"!=typeof e?String(e):e)||"function"!=typeof t[e])&&"__proto__"!==e}function ml(e,t,n,i){var r=Array.isArray(t)?t:t.split(i||"/"),o=r.length-1;let s=e,a=0;for(;a<o;a++){var l=r[a];if(!gl(s,l))return e;let t=s[l];s=t||(s[l]={})}return s[r[o]]=n,e}function vl(t,e,n){var i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){var a=i[s];if(!gl(o,a))return t;a=o[a];if(!a)return t;o=a}return delete o[i[r]],t}function yl(t,e,n){e=e||"/";var i,r={};for(i in t)if(t.hasOwnProperty(i)){var o="object"==typeof t[i];if(o=o&&n&&n(t[i])?!1:o){var s,a=yl(t[i],e,n);for(s in a)a.hasOwnProperty(s)&&(r[i+e+s]=a[s])}else r[i]=t[i]}return r}function bl(){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)})}function wl(t){return wl.id=wl.id||1,void 0===t?"j_"+wl.id++:(t.id=void 0===t.id?"j_"+wl.id++:t.id,t.id)}function k(t){if(!t.normalized){var{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(var r in i)void 0===t[r]&&(t[r]=i[r]);n&&(e=n.correspondingUseElement)&&(t.target=e),t.normalized=!0}return t}function xl(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}}function Al(t,e){return e<t?e:t<-e?-e:t}function Pl(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 T(e)&&(i=e);return n=i,null===(e=(n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+n+")$").exec(t))?n[1]:null)?null:(r.unit=e,r)}ul.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t,...e){var{handleObj:n,target:i}=t,i=L.data.create(i),r=(new Date).getTime(),o="lastTouch"in i?r-i.lastTouch:0;o<cl&&30<o?(i.lastTouch=null,t.type=n.origType,n.handler.call(this,t,...e)):i.lastTouch=r}},Object.assign(L.fn,el),Object.assign(L.fn,rl),Object.assign(L.fn,ll),Object.assign(L.event.special,ul),(Ra="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame:Ra)||(Oa=0,Ra=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-Oa)),i=setTimeout(function(){t(e+n)},n);return Oa=e+n,i});let Tl=function(t,e,...n){return Ra(void 0!==e?t.bind(e,...n):t)},El=(hn="undefined"!=typeof window,f=(f=hn?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame:f)||clearTimeout,hn?f.bind(window):f),Sl=function(t){return T(t)&&"%"===t.slice(-1)},_l=0;function Ll(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}}function kl(t,e,n={},i={}){var r,o=e.width,s=e.height,e=i.svgDocument||R("svg").node,a=R("tspan").node,l=R("text").attr(n).append(a).node,h=document.createTextNode(""),u=(l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(h),e.appendChild(l),i.svgDocument||document.body.appendChild(e),i.preserveSpaces),c=i.separator||""===i.separator?i.separator:" ",d="string"==typeof c?c:" ",f=i.eol||"\n",p=i.hyphen?new RegExp(i.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=i.maxLineCount,m=(qs(g)||(g=1/0),t.split(c)),v=[],y=[];u&&R(a).attr("xml:space","preserve");for(var b=0,w=0,x=m.length;b<x;b++){var A=m[b];if((A||u)&&"string"==typeof A){var P=!1;if(f&&0<=A.indexOf(f)){if(1<A.length){var T=((t,n)=>{var i=t.split(n);let r=1;for(let t=0,e=i.length-1;t<e;t++){var o=[];(0<t||""!==i[0])&&o.push(_l),o.push(n),(t<e-1||""!==i[e])&&o.push(_l),i.splice(r,0,...o),r+=o.length+1}return i.filter(t=>""!==t)})(m[b],f);m.splice(b,1,...T),b--,x=m.length;continue}if(u&&"string"==typeof m[b-1]){m.splice(b,_l,"",_l),x+=2,b--;continue}y[++w]=u&&"string"!=typeof m[b+1]?void 0:"",P=!0}if(!P){let t;if(t=u?void 0!==y[w]?y[w]+d+A:A:y[w]?y[w]+d+A:A,h.data=t,a.getComputedTextLength()<=o)y[w]=t,(E||r)&&(v[w++]=!0,r=E=0);else{if(!y[w]||E){var T=!!E,E=A.length-1;if(T||!E){if(!E){if(!y[w]){y=[];break}m.splice(b,2,A+m[b+1]),x--,v[w++]=!0,b--;continue}m[b]=A.substring(0,E);var S=m[b+1];m[b+1]=A.substring(E)+(void 0===S||S===_l?"":S)}else r?(m.splice(b,2,m[b]+m[b+1]),r=0):(-1<(S=A.search(p))&&S!==A.length-1&&0!==S&&(r=S+1,E=0),m.splice(b,1,A.substring(0,r||E),A.substring(r||E)),x++),w&&!v[w-1]&&w--;u&&""===y[w]||b--;continue}w++,b--}}var _,L=null;if(y.length>g?L=g-1:void 0!==s&&(_=void 0===_&&""!==h.data?"auto"===n.lineHeight?Ll({value:1.5,unit:"em"},l):Ll(Pl(n.lineHeight,["em","px",""]),l):_)*y.length>s&&(L=Math.floor(s/_)-1),null!==L){y.splice(L+1);var k=i.ellipsis;if(!k||L<0)break;"string"!=typeof k&&(k="\u2026");var C=y[L];if(!C&&!P)break;var M,N,O=C.length;do{if(N=C[O],M=C.substring(0,O),N?N.match(c)&&(M+=N):M+=d,M+=k,h.data=M,a.getComputedTextLength()<=o){y[L]=M;break}}while(0<=--O);break}}}return i.svgDocument?e.removeChild(l):document.body.removeChild(e),y.join(f)}function Cl(t,e){var n;window.navigator.msSaveBlob?window.navigator.msSaveBlob(t,e):(t=window.URL.createObjectURL(t),(n=document.createElement("a")).href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(t))}function Ml(t){t=t.replace(/\s/g,"");for(var e=(t=decodeURIComponent(t)).indexOf(","),n=t.slice(0,e),i=n.split(":")[1].split(";")[0],t=t.slice(e+1),r=0<=n.indexOf("base64")?atob(t):unescape(encodeURIComponent(t)),o=new Uint8Array(r.length),s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return new Blob([o],{type:i})}function Nl(t,e){var n=(t=L(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(e);for(var i=0;i<n.length;i++)n[i].call(t[i]);return t}let Ol=function(t){var e,n,i,r;return Object(t)!==t?(r=0,{top:r=isFinite(t)?+t:r,right:r,bottom:r,left:r}):(e=n=i=r=0,isFinite(t.vertical)&&(e=i=+t.vertical),isFinite(t.horizontal)&&(n=r=+t.horizontal),{top:e=isFinite(t.top)?+t.top:e,right:n=isFinite(t.right)?+t.right:n,bottom:i=isFinite(t.bottom)?+t.bottom:i,left:r=isFinite(t.left)?+t.left:r})},Rl={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){var e,n;return t<=0?0:1<=t?1:(n=(e=t*t)*t,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,n=0,i=1;;n+=i,i/=2){1;if((7-4*n)/11<=t)return-(e=(11-6*n-11*t)/4)*e+i*i}},reverse:function(e){return function(t){return 1-e(1-t)}},reflect:function(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}},clamp:function(e,n,i){return n=n||0,i=i||1,function(t){t=e(t);return t<n?n:i<t?i:t}},back:function(e){return e=e||1.70158,function(t){return t*t*((e+1)*t-e)}},elastic:function(e){return e=e||1.5,function(t){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e/3*t)}}},Vl={number:function(e,t){var n=t-e;return function(t){return e+n*t}},object:function(r,o){var s=Object.keys(r);return function(t){for(var e,n={},i=s.length-1;-1!=i;i--)n[e=s[i]]=r[e]+(o[e]-r[e])*t;return n}},hexColor:function(t,e){var t=parseInt(t.slice(1),16),e=parseInt(e.slice(1),16),n=255&t,i=(255&e)-n,r=65280&t,o=(65280&e)-r,s=16711680&t,a=(16711680&e)-s;return function(t){return"#"+(1<<24|n+i*t&255|r+o*t&65280|s+a*t&16711680).toString(16).slice(1)}},unit:function(e,t){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(e),n=n.exec(t),t=n[1].indexOf("."),r=0<t?n[1].length-t-1:0,o=(e=+i[1],+n[1]-e),s=i[2];return function(t){return(e+o*t).toFixed(r)+s}}},Il={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return Fl('<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 Fl('<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 Fl('<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 Fl(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){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<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-t),b:.7152-.7152*(1-t),c:.0722-.0722*(1-t),d:.2126-.2126*(1-t),e:.7152+.2848*(1-t),f:.0722-.0722*(1-t),g:.2126-.2126*(1-t),h:.0722+.9278*(1-t)})},sepia:function(t){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<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-t),b:.769-.769*(1-t),c:.189-.189*(1-t),d:.349-.349*(1-t),e:.686+.314*(1-t),f:.168-.168*(1-t),g:.272-.272*(1-t),h:.534-.534*(1-t),i:.131+.869*(1-t)})},saturate:function(t){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-t})},hueRotate:function(t){return Fl('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:t,amount2:1-t})},brightness:function(t){return Fl('<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){t=Number.isFinite(t.amount)?t.amount:1;return Fl('<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:t,amount2:.5-t/2})}},Fl=(C={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var t=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),n=t[1]||" ",i=t[2]||">",r=t[3]||"",s=t[4]||"",a=t[5],l=+t[6],h=t[7],u=t[8],c=t[9],d=1,f="",p="",g=!1,u=u&&+u.substring(1);switch((a||"0"===n&&"="===i)&&(a=n="0",i="=",h)&&(l-=Math.floor((l-1)/4)),c){case"n":h=!0,c="g";break;case"%":d=100,p="%",c="f";break;case"p":d=100,p="%",c="r";break;case"b":case"o":case"x":case"X":"#"===s&&(f="0"+c.toLowerCase());break;case"c":case"d":g=!0,u=0;break;case"s":d=-1,c="r"}"$"===s&&(f=o.currency[0],p=o.currency[1]),"r"!=c||u||(c="g"),null!=u&&("g"==c?u=Math.max(1,Math.min(21,u)):"e"!=c&&"f"!=c||(u=Math.max(0,Math.min(20,u))));t=a&&h;if(g&&e%1)return"";var r=e<0||0===e&&1/e<0?(e=-e,"-"):r,m=p,v=(d<0?(e=(v=this.prefix(e,u)).scale(e),m=v.symbol+p):e*=d,(e=this.convert(c,e,u)).lastIndexOf(".")),y=v<0?e:e.substring(0,v),v=v<0?"":o.decimal+e.substring(v+1);function b(t){for(var e=t.length,n=[],i=0,r=o.grouping[0];0<e&&0<r;)n.push(t.substring(e-=r,e+r)),r=o.grouping[i=(i+1)%o.grouping.length];return n.reverse().join(o.thousands)}!a&&h&&o.grouping&&(y=b(y));a=f.length+y.length+v.length+(t?0:r.length),l=a<l?new Array(a=l-a+1).join(n):"";return r+=f,e=(y=t?b(l+y):y)+v,("<"===i?r+e+l:">"===i?l+r+e:"^"===i?l.substring(0,a>>=1)+r+e+l.substring(a):r+(t?e:l+e))+m},string:function(t,e){for(var n,i="{",r=!1,o=[];-1!==(n=t.indexOf(i));){if(l=t.slice(0,n),r){for(var s,a=(s=l.split(":")).shift().split("."),l=e,h=0;h<a.length;h++)l=l[a[h]];s.length&&(l=this.number(s,l))}o.push(l),t=t.slice(n+1),i=(r=!r)?"}":"{"}return o.push(t),o.join("")},convert:function(t,e,n){switch(t){case"b":return e.toString(2);case"c":return String.fromCharCode(e);case"o":return e.toString(8);case"x":return e.toString(16);case"X":return e.toString(16).toUpperCase();case"g":return e.toPrecision(n);case"e":return e.toExponential(n);case"f":return e.toFixed(n);case"r":return(e=this.round(e,this.precision(e,n))).toFixed(Math.max(0,Math.min(20,this.precision(e*(1+1e-15),n))));default:return e+""}},round:function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},precision:function(t,e){return e-(t?Math.ceil(Math.log(t)/Math.LN10):1)},prefix:function(t,e){var n=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(function(t,e){var n=Math.pow(10,3*Math.abs(8-e));return{scale:8<e?function(t){return t/n}:function(t){return t*n},symbol:t}}),i=0;return t&&(t<0&&(t*=-1),e&&(t=this.round(t,this.precision(t,e))),i=1+Math.floor(1e-12+Math.log(t)/Math.LN10),i=Math.max(-24,Math.min(24,3*Math.floor((i<=0?i+1:i-1)/3)))),n[8+i/3]}},function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(i){return i=i||{},t.replace(e,function(t){for(var e=Array.from(arguments).slice(1,4).find(function(t){return!!t}).split("."),n=i[e.shift()];void 0!==n&&e.length;)n=n[e.shift()];return void 0!==n?n:""})}});function Bl(t,e,n){var{maxDepth:n=Number.POSITIVE_INFINITY}=n||{};return function o(s,a,l,h){if(l===h)return{};let u={};return Object.keys(s).forEach(t=>{var e,n,i=s[t],r=a[t];!Array.isArray(i)&&!Array.isArray(r)&&x(i)&&x(r)?(n=o(i,r,e=l+1,h),0<Object.keys(n).length?u[t]=n:0!==l&&e!==h||(u[t]={})):na(i,r)||(u[t]=i)}),u}(t,e,0,n)}function Dl(){}function zl(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=zl(t,e,o[s],n[o[s]],r)}else if(n&&Wl.test(n))for(o=n.split(Wl);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e}function jl(t,e){var n=this,i=t&&ua(t,"constructor")?t.constructor:function(){return n.apply(this,arguments)};return E(i,n,e),i.prototype=Object.assign(Object.create(n.prototype),t),(i.prototype.constructor=i).__super__=n.prototype,i}function Gl(t,e){var t=t||{},n=(e=e||{},this.preinitialize.apply(this,arguments),this.cid=ma(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),S(this,"defaults")),t=$s(E({},n,t),n);this.set(t,e),this.changed={},this.initialize.apply(this,arguments)}var Ul,Hl,ql,$l={},Wl=/\s+/,Yl=($l.on=function(t,e,n){return this._events=zl(Yl,this._events||{},t,e,{context:n,ctx:this,listening:Ul}),Ul&&(((this._listeners||(this._listeners={}))[Ul.id]=Ul).interop=!1),this},$l.listenTo=function(t,e,n){if(t){var i=t._listenId||(t._listenId=ma("l")),r=this._listeningTo||(this._listeningTo={}),o=Ul=r[i],r=(o||(this._listenId||(this._listenId=ma("l")),o=Ul=r[i]=new eh(this,t)),Xl(t,e,n,this));if(Ul=void 0,r)throw r;o.interop&&o.on(e,n)}return this},function(t,e,n,i){var r,o;return n&&(e=t[e]||(t[e]=[]),r=i.context,o=i.ctx,(i=i.listening)&&i.count++,e.push({callback:n,context:r,ctx:r||o,listening:i})),t}),Xl=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}},Zl=($l.off=function(t,e,n){return this._events&&(this._events=zl(Zl,this._events,t,e,{context:n,listeners:this._listeners})),this},$l.stopListening=function(t,e,n){var i=this._listeningTo;if(i){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)}ea(i)&&(this._listeningTo=void 0)}return this},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 h=[],u=0;u<l.length;u++){var c=l[u];n&&n!==c.callback&&n!==c.callback._callback||o&&o!==c.context?h.push(c):(c=c.listening)&&c.off(e,n)}h.length?t[e]=h:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}}),Jl=($l.once=function(t,e,n){var i=zl(Jl,{},t,e,this.off.bind(this));return this.on(i,e="string"==typeof t&&null==n?void 0:e,n)},$l.listenToOnce=function(t,e,n){e=zl(Jl,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,e)},function(t,e,n,i){var r;return n&&((r=t[e]=Kl(function(){i(e,r),n.apply(this,arguments)}))._callback=n),t}),Kl=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return 0<--n&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}},Ql=($l.trigger=function(t){if(this._events){for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];zl(Ql,this._events,t,void 0,n)}return this},function(t,e,n,i){var r,o;return t&&(r=t[e],o=t.all,r&&(o=o&&o.slice()),r&&th(r,i),o)&&th(o,[e].concat(i)),t}),th=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}},eh=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0},nh=(eh.prototype.on=$l.on,eh.prototype.off=function(t,e){t=this.interop?(this._events=zl(Zl,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count);t&&this.cleanup()},eh.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},$l.bind=$l.on,$l.unbind=$l.off,function(i,t,r,o){switch(t){case 1:return function(){return i[r](this[o])};case 2:return function(t){return i[r](this[o],t)};case 3:return function(t,e){return i[r](this[o],ih(t,this),e)};case 4:return function(t,e,n){return i[r](this[o],ih(t,this),e,n)};default:return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this[o]),i[r].apply(i,t)}}}),ih=function(e,t){return b(e)?e:x(e)&&!t._isModel(e)?rh(e):T(e)?function(t){return t.get(e)}:e},rh=function(t){t=t;var e=Ps(is(t,!0));return function(t){return e(t.attributes)}};function oh(t){t=Ks(t);let r=et(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return et(t).forEach(function(t){var e=r[t.id],n=(e.isLink()&&(n=e.source(),i=e.target(),n.id&&r[n.id]&&e.prop("source/id",r[n.id].id),i.id)&&r[i.id]&&e.prop("target/id",r[i.id].id),t.get("parent")),i=(n&&r[n]&&e.set("parent",r[n].id),et(t.get("embeds")).reduce(function(t,e){return r[e]&&t.push(r[e].id),t},[]));ea(i)||e.set("embeds",i)}),r}E(Gl.prototype,$l,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return Qs(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){var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,!this._validate(i,n=n||{}))return!1;var r,o,s=n.unset,t=n.silent,a=[],l=this._changing,h=(this._changing=!0,l||(this._previousAttributes=Qs(this.attributes),this.changed={}),this.attributes),u=this.changed,c=this._previousAttributes;for(r in i)e=i[r],na(h[r],e)||a.push(r),na(c[r],e)?delete u[r]:u[r]=e,s?delete h[r]:h[r]=e;if(this.idAttribute in i&&(o=this.id,this.id=this.get(this.idAttribute),this.trigger("changeId",this,o,n)),!t){a.length&&(this._pending=n);for(var d=0;d<a.length;d++)this.trigger("change:"+a[d],this,h[a[d]],n)}if(!l){if(!t)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);this._pending=!1,this._changing=!1}}return this},unset:function(t,e){return this.set(t,void 0,E({},e,{unset:!0}))},clear:function(t){var e,n={};for(e in this.attributes)n[e]=void 0;return this.set(n,E({},t,{unset:!0}))},hasChanged:function(t){return null==t?!ea(this.changed):ua(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&Qs(this.changed);var e,n,i=this._changing?this._previousAttributes:this.attributes,r={};for(n in t){var o=t[n];na(i[n],o)||(r[n]=o,e=!0)}return!!e&&r},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return Qs(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},E({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=E({},this.attributes,t);t=this.validationError=this.validate(t,e)||null;return!t||(this.trigger("invalid",this,t,E(e,{validationError:t})),!1)}}),Gl.extend=jl;let sh=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce((t,e)=>(t[e]=!0,t),{});function ah(r,o,s){return function(t,e){var n,i=Sl(t),i=(t=parseFloat(t),i&&(t/=100),isFinite(t)&&(n=e[s](),n=i||0<t&&t<1?n[r]+e[o]*t:n[r]+t),A());return i[r]=n||0,i}}function lh(r,o){return function(t,e){var n=Sl(t),i=(t=parseFloat(t),n&&(t/=100),{});return isFinite(t)&&(n=n||0<=t&&t<=1?t*e[o]:Math.max(t+e[o],0),i[r]=n),i}}a={qualify:function(t){return y(t)},set:function(e,t,i){Object.keys(e).forEach(function(t){if(sh[t]&&t in i){let n=e[t];"SELECT"===i.tagName&&Array.isArray(n)?Array.from(i.options).forEach(function(t,e){t.selected=n.includes(t.value)}):i[t]=n}})}},(i={"ref-x":{position:ah("x","width","origin")},"ref-y":{position:ah("y","height","origin")},"ref-dx":{position:ah("x","width","corner")},"ref-dy":{position:ah("y","height","corner")},"ref-width":{set:lh("width","width")},"ref-height":{set:lh("height","height")},"ref-rx":{set:lh("rx","width")},"ref-ry":{set:lh("ry","height")},"ref-cx":{set:lh("cx","width")},"ref-cy":{set:lh("cy","height")},"ref-r-inscribed":{set:(Hl=lh("r","width"),ql=lh("r","height"),function(t,e){return(e.height>e.width?Hl:ql)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n,i=Sl(t),e=(t=parseFloat(t),i&&(t/=100),Math.sqrt(e.height*e.height+e.width*e.width));return{r:n=isFinite(t)?i||0<=t&&t<=1?t*e:Math.max(t+e,0):n}}}}).refX=i["ref-x"],i.refY=i["ref-y"],i["ref-x2"]=i["ref-x"],i["ref-y2"]=i["ref-y"],i["ref-width2"]=i["ref-width"],i["ref-height2"]=i["ref-height"],i["ref-r"]=i["ref-r-inscribed"];let hh={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},uh=(Ke=Object.keys(hh).map(t=>hh[t]).join(""),h="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",/\s/g),ch=new RegExp(`^(${h}\\*)?([${Ke}])(/${h})?([-+]{1,2}${h})?$`,"g");function dh(t){throw new Error("Invalid calc() expression: "+t)}function fh(t,e){var n=ch.exec(t.replace(uh,"")),[,t,n,i,r]=(n||dh(t),ch.lastIndex=0,n),{x:o,y:s,width:a,height:l}=e;let h=0;switch(n){case hh.width:h=a;break;case hh.height:h=l;break;case hh.x:h=o;break;case hh.y:h=s;break;case hh.minimum:h=Math.min(l,a);break;case hh.maximum:h=Math.max(l,a);break;case hh.diagonal:h=Math.sqrt(l*l+a*a)}return t&&(h*=parseFloat(t)),i&&(h/=parseFloat(i.slice(1))),r&&(h+=(t=>{if(!t)return 0;var[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)})(r)),h}function ph(t){return"string"==typeof t&&t.includes("calc")}let gh="calc(",mh=gh.length;function vh(t,i){let r=t,o=0;for(;;){var s=r.indexOf(gh,o);if(-1===s)return r;let t=s+mh,e=1;t:for(;;){switch(r[t]){case"(":e++;break;case")":if(0===--e)break t;break;case void 0:dh(r)}t++}let n=r.slice(s+mh,t);ph(n)&&(n=vh(n,i));var a=String(fh(n,i));r=r.slice(0,s)+a+r.slice(t+1),o=s+a.length}}function yh(t,e,n){return void 0!==n.text}let bh=["font-weight","font-family","font-size","letter-spacing","text-transform"],wh={"line-height":{qualify:yh},"text-vertical-anchor":{qualify:yh},"text-path":{qualify:yh},annotations:{qualify:yh},eol:{qualify:yh},"display-empty":{qualify:yh},text:{qualify:function(t,e,n){n=n["text-wrap"];return!n||!y(n)},unset:function(t){t.textContent=""},set:function(t,e,n,i){var r="joint-text",o=L.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],h=i["font-size"],u=i.annotations,c=i.eol,d=i.x;let f=i["text-path"];var i=!0===i["use-no-break-space"],p=JSON.stringify([t,s,u,a,c,l,f,d,h,i]);void 0!==o&&o===p||(h&&n.setAttribute("font-size",h),x(f)&&"string"==typeof(o=f.selector)&&(h=this.findNode(o))instanceof SVGPathElement&&(f=E({"xlink:href":"#"+h.id},f)),R(n).text(""+t,{lineHeight:s,annotations:u,textPath:f,x:d,textVerticalAnchor:a,eol:c,displayEmpty:l,useNoBreakSpace:i}),L.data.set(n,r,p))}},"text-wrap":{qualify:y,set:function(e,t,n,i){var r={},o=e.width||0,o=(Sl(o)?r.width=t.width*parseFloat(o)/100:ph(o)?r.width=Number(vh(o,t)):null===e.width?r.width=1/0:r.width=o<=0?t.width+o:o,e.height||0),o=(Sl(o)?r.height=t.height*parseFloat(o)/100:ph(o)?r.height=Number(vh(o,t)):null!==e.height&&(r.height=o<=0?t.height+o:o),e.text);if(void 0!==(o=void 0===o?i.text:o)){var s=e.breakText||kl,a=getComputedStyle(n),l={};for(let t=0;t<bh.length;t++){var h=bh[t];h in i&&n.setAttribute(h,i[h]),l[h]=a[h]}l.lineHeight=i["line-height"];let t=this.paper.svg;s=s(""+o,r,l,{svgDocument:t=t.checkVisibility()?t:null,ellipsis:e.ellipsis,hyphen:e.hyphen,separator:e.separator,maxLineCount:e.maxLineCount,preserveSpaces:e.preserveSpaces})}else s="";wh.text.set.call(this,s,t,n,i)},FONT_ATTRIBUTES:bh},title:{qualify:function(t,e){return e instanceof SVGElement},unset:function(t){L.data.remove(t,"joint-title");t=t.firstElementChild;t&&t.remove()},set:function(t,e,n){var i="joint-title",r=L.data.get(n,i);void 0!==r&&r===t||(L.data.set(n,i,t),"title"===n.tagName?n.textContent=t:(r=n.firstElementChild)&&"title"===r.tagName?r.textContent=t:((i=document.createElementNS(n.namespaceURI,"title")).textContent=t,n.insertBefore(i,r)))}}};function xh(i,r){var o=new A(1,0);return function(t){var e,n,t=this[i](t);return t?(n=r.rotate?t.vector().vectorAngle(o):0,e=t.start):(e=this.path.start,n=0),0===n?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+n+")"}}}function Ah(){return this.model.isLink()}function Ph(s,t){var a="joint-shape",l=t&&t.resetOffset;return function(t,e,n){var i=L.data.get(n,a),t=(i&&i.value===t||(i={value:t,shape:t=s(t),shapeBBox:t.bbox()},L.data.set(n,a,i)),i.shape.clone()),n=i.shapeBBox.clone(),i=n.origin(),r=e.origin(),r=(n.x=r.x,n.y=r.y,e.maxRectScaleToFit(n,r)),o=0===n.width||0===e.width?1:r.sx,n=0===n.height||0===e.height?1:r.sy;return t.scale(o,n,i),l&&t.translate(-i.x,-i.y),t}}function Th(t){var i=Ph(function(t){return new I(R.normalizePathData(t))},t);return function(t,e,n){return{d:i(t,e,n).serialize()}}}function Eh(t){var i=Ph(w,t);return function(t,e,n){return{points:i(t,e,n).serialize()}}}function Sh(t){var e={},n=t.stroke,n=("string"==typeof n&&(e.stroke=n,e.fill=n),t["stroke-opacity"]);return void 0!==(n=void 0===n?t.opacity:n)&&(e["stroke-opacity"]=n,e["fill-opacity"]=n),e}function _h(t){var e=this.paper;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}function Lh(i,r,o){return function(t,e){var t="middle"===t?e[r]/2:t===o?e[r]:isFinite(t)?-1<t&&t<1?-e[r]*t:-t:Sl(t)?e[r]*parseFloat(t)/100:0,n=new A;return n[i]=-(e[i]+t),n}}function kh(i){return function(t,e,n){n=R(n);n.attr(i)!==t&&n.attr(i,t)}}function Ch(t,e){if(Array.isArray(t))return ta(e)}(s={connection:{qualify:Ah,unset:"d",set:function({stubs:e=0}){let n;if(isFinite(e)&&0!==e){let t;t=e<0?(this.getConnectionLength()+e)/2:e;var e=this.getConnection(),i=this.getConnectionSubdivisions(),r=e.divideAtLength(t,{segmentSubdivisions:i}),e=e.divideAtLength(-t,{segmentSubdivisions:i});r&&e&&(n=r[0].serialize()+" "+e[1].serialize())}return{d:n||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:Ah,unset:"transform",set:xh("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:Ah,unset:"transform",set:xh("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:Ah,unset:"transform",set:xh("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:Ah,unset:"transform",set:xh("getTangentAtRatio",{rotate:!1})}})["at-connection-length"]=s["at-connection-length-keep-gradient"],s["at-connection-ratio"]=s["at-connection-ratio-keep-gradient"],(o={"ref-d-reset-offset":{unset:"d",set:Th({resetOffset:!0})},"ref-d-keep-offset":{unset:"d",set:Th({resetOffset:!1})},"ref-points-reset-offset":{unset:"points",set:Eh({resetOffset:!0})},"ref-points-keep-offset":{unset:"points",set:Eh({resetOffset:!1})}})["ref-d"]=o["ref-d-reset-offset"],o["ref-points"]=o["ref-points-reset-offset"],e={"source-marker":{qualify:y,unset:"marker-start",set:function(t,e,n,i){return t=E(Sh(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:y,unset:"marker-end",set:function(t,e,n,i){return t=E(Sh(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:y,unset:"marker-mid",set:function(t,e,n,i){return t=E(Sh(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:y,set:_h},stroke:{qualify:y,set:_h},filter:{qualify:y,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}},Ue={"x-alignment":{offset:Lh("x","width","right")},"y-alignment":{offset:Lh("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}},l={ref:{},href:{set:kh("href")},"xlink:href":{set:kh("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:y,set:function(t,e,n){L(n).css(t)}},html:{unset:function(t){L(t).empty()},set:function(t,e,n){L(n).html(t+"")}},props:a},E(l,i),E(l,wh),E(l,s),E(l,o),E(l,e),E(l,Ue);let Mh=l;function Nh(t){for(var e in t){var n=t[e];x(n)&&!Array.isArray(n)&&ea(n)&&delete t[e]}}let Oh=Gl.extend({constructor:function(t,e){var n,i,t=t||{};"function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=ma("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(t=this.parse(t,e)||{}),(n=S(this,"defaults"))&&(i=(!e||!0!==e.mergeArrays)&&(hl.cellDefaultsMergeStrategy||Ch),t=_({},n,t,i)),this.set(t,e),this.changed={},e&&e.portLayoutNamespace&&(this.portLayoutNamespace=e.portLayoutNamespace),e&&e.portLabelLayoutNamespace&&(this.portLabelLayoutNamespace=e.portLabelLayoutNamespace),this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(t){var{ignoreDefaults:t,ignoreEmptyAttributes:e=!1}=t||{};let n=S(this.constructor.prototype,"defaults");if(!1===t){let t=ta(this.attributes);return e&&Nh(t),t}let i={};var r=ta(this.attributes);!0===t?i=n:(Array.isArray(t)?t:["attrs"]).forEach(t=>{i[t]=n[t]||{}});let o=Bl(r,ca(i,"id","type"),{maxDepth:4});return e&&Nh(o),o},initialize:function(t){var 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:bl,processPorts:function(){var t=this.ports,n={},i=(fa(this.get("attrs"),function(t,e){t&&t.port&&(void 0!==t.port.id?n[t.port.id]=t.port:n[t.port]={id:t.port})}),{});fa(t,function(t,e){n[e]||(i[e]=!0)}),this.graph&&!ea(i)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),this.graph.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()})),this.ports=n},remove:function(n={}){var{graph:t,collection:e}=this;if(t){t.startBatch("remove");var i=this.getParentCell(),r=(i&&i.unembed(this,n),this.getEmbeddedCells());for(let t=0,e=r.length;t<e;t++){var o=r[t];o&&o.remove(n)}this.trigger("remove",this,t.attributes.cells,n),t.stopBatch("remove")}else e&&e.remove(this,n);return this},toFront:function(i){var r=this.graph;if(r){let t;(i=$s(i||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==i.breadthFirst,sortSiblings:i.foregroundEmbeds})).unshift(this):t=[this];var o=i.foregroundEmbeds?t:oa(t,t=>t.z());let n=r.maxZIndex()-t.length+1;r=r.get("cells");let e=r.toArray().indexOf(o[0])!==r.length-t.length;(e=e||o.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-front"),n+=t.length,o.forEach(function(t,e){t.set("z",n+e,i)}),this.stopBatch("to-front"))}return this},toBack:function(r){var o=this.graph;if(o){let t;(r=$s(r||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==r.breadthFirst,sortSiblings:r.foregroundEmbeds})).unshift(this):t=[this];var s=r.foregroundEmbeds?t:oa(t,t=>t.z());let n=o.minZIndex(),e=o.get("cells"),i=0!==e.toArray().indexOf(s[0]);(i=i||s.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-back"),n-=t.length,s.forEach(function(t,e){t.set("z",n+e,r)}),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={}){let n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(e.reparent)Ks(n.map(t=>t.getParentCell())).forEach(t=>{t&&t._unembedCells(n,e)});else 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){t=Array.isArray(t)?t:[t];return this._unembedCells(t,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every(t=>this!==t&&!this.isEmbeddedIn(t))},_embedCells:function(t,e){this.startBatch("embed");let n=E([],this.get("embeds"));t.forEach(t=>{n[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)}),this.set("embeds",Ks(n),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(t=>t.unset("parent",e)),this.set("embeds",aa(this.get("embeds"),...t.map(t=>t.id)),e),this.stopBatch("unembed")},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(this.graph)for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(!this.graph)return[];if((t=t||{}).deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);var e=this.get("embeds");if(ea(e))return[];let n=e.map(this.graph.getCell,this.graph);return n=t.sortSiblings?oa(n,t=>t.z()):n},_getEmbeddedCellsBfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.shift(),i=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));n.push(...i)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.pop(),r=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));for(let t=r.length-1;0<=t;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=T(t)?t:t.id,i=this.parent();if(e=E({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){return(t=t||{}).deep?et(oh([this].concat(this.getEmbeddedCells({deep:!0})))):((t=new this.constructor(this.attributes,{portLayoutNamespace:this.portLayoutNamespace,portLabelLayoutNamespace:this.portLabelLayoutNamespace})).set(this.getIdAttribute(),this.generateId()),t.unset("embeds"),t.unset("parent"),t)},prop:function(e,n,i){var r=T(e);if(r||Array.isArray(e)){if(1<arguments.length){var o=r?(p=e).split("/"):(p=e.join("/"),e.slice()),s=o[0],a=o.length;let t=i||{};t.propertyPath=p,t.propertyValue=n,t.propertyPathArray=o,"rewrite"in t||(t.rewrite=!1);for(var l=i={},h=s,u=1;u<a;u++)var c=o[u],d=Number.isFinite(r?Number(c):c),l=l[h]=d?[]:{},h=c;var i=ml(i,o,n,"/"),f=_({},this.attributes),p=(t.rewrite&&vl(f,p,"/"),_(f,i,hl.cellMergeStrategy));return this.set(s,p[s],t)}return pl(this.attributes,e,"/")}let t=n||{};t.propertyPath=null,t.propertyValue=e,t.propertyPathArray=[],"rewrite"in t||(t.rewrite=!1);var g,m={};for(g in e){var v=_(_({},{changedValue:this.attributes[g]}),{changedValue:e[g]},hl.cellMergeStrategy).changedValue;m[g]=v}return this.set(m,t)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];return"attrs"===i&&(e.dirty=!0),1===n.length?this.unset(t,e):(t=n.slice(1),null==(n=this.get(i))?this:(n=ta(n),vl(n,t,"/"),this.set(i,n,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):T(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(n,e,i,r){r=r||"/";var o,t={duration:100,delay:10,timingFunction:Rl.linear,valueFunction:Vl.number},s=(i=E(t,i),0),a=function(t){var e;(t=(t-=s=s||t)/i.duration)<1?this._transitionIds[n]=e=Tl(a):(t=1,delete this._transitionIds[n]),t=o(i.timingFunction(t)),i.transitionId=e,this.prop(n,t,i),e||this.trigger("transition:end",this,n)}.bind(this);let l=this._scheduledTransitionIds,h;return h=setTimeout(t=>{l[n]&&(l[n]=aa(l[n],h),0===l[n].length)&&delete l[n],this.stopPendingTransitions(n,r),o=i.valueFunction(pl(this.attributes,n,r),e),this._transitionIds[n]=Tl(t),this.trigger("transition:start",this,n)},i.delay,a),l[n]||(l[n]=[]),l[n].push(h),h},getTransitions:function(){return ha(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,n="/"){let{_scheduledTransitionIds:e={}}=this,i=Object.keys(e);if(t){let e=t.split(n);i=i.filter(t=>na(e,t.split(n).slice(0,e.length)))}return i.forEach(t=>{e[t].forEach(t=>clearTimeout(t)),delete e[t]}),this},stopPendingTransitions(t,n="/"){let{_transitionIds:i={}}=this,r=Object.keys(i);if(t){let e=t.split(n);r=r.filter(t=>na(e,t.split(n).slice(0,e.length)))}r.forEach(t=>{var e=i[t];El(e),delete i[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,E({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,E({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(t)for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new A(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new A},getBBox:function(){return new tt(0,0,0,0)},getCenter:function(){return this.getBBox().center()},getPointRotatedAroundCenter(t,e,n){e=new A(e,n);return t&&e.rotate(this.getCenter(),t),e},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=Mh,e=e&&e[t]||n[t];return void 0!==e?e:null},define:function(t,e,n,i){n=E({defaults:Ys({type:t},e,this.prototype.defaults)},n);e=this.extend(n,i);return void 0!==joint&&ua(joint,"shapes")&&ml(joint.shapes,t,e,"."),e}});function Rh(e,t,n){if(T(n)){if(!Vh[n])throw new Error('Unknown wrapper: "'+n+'"');n=Vh[n]}if(!b(n))throw new Error("Wrapper must be a function.");et(t).forEach(function(t){e[t]=n(e[t])})}let Vh={cells:function(i){return function(){var t=Array.from(arguments),e=t.length,n=0<e&&t[0]||[],e=1<e&&t[e-1]||{};return Array.isArray(n)||(e instanceof Oh?n=t:n instanceof Oh&&(1<t.length&&t.pop(),n=t)),e instanceof Oh&&(e={}),i.call(this,n,e)}}},d={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 Ih(t,e){var n=new tt(t);switch(e){case void 0:throw new Error("Position required");case d.LEFT:case"leftMiddle":return n.leftMiddle();case d.RIGHT:case"rightMiddle":return n.rightMiddle();case d.TOP:case"topMiddle":return n.topMiddle();case d.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case d.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case d.TOP_RIGHT:case"topRight":return n.topRight();case d.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case d.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case d.CENTER:return n.center();default:throw new Error("Unknown position: "+e)}}function Fh(t,e,n,i){if(Sl(i))return parseFloat(i)/100*n[e];if(ph(i))return Number(vh(i,n));if("string"!=typeof i)return i;e=Number(i);if(isNaN(e))throw new TypeError(`Cannot convert port coordinate ${t}: "${i}" to a number`);return e}function Bh(t,e,n){t=t.toJSON();return t.angle=e||0,$s({},n,t)}function Dh(t,e,n,i){return t.map(function(t,e,n){e=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&e.offset(t.dx||0,t.dy||0),Bh(e.round(),0,jh(i,t))},fi(e,n))}function zh(t,i,r,o){var s=i.center(),a=i.width/i.height,l=i.topMiddle(),h=vi.fromRect(i);return t.map(function(t,e,n){e=r+o(e,n.length),n=l.clone().rotate(s,-e).scale(a,1,s),e=t.compensateRotation?-h.tangentTheta(n):0;return(t.dx||t.dy)&&n.offset(t.dx||0,t.dy||0),t.dr&&n.move(s,t.dr),Bh(n.round(),e,jh(i,t))})}function jh(t,e){var{x:e,y:n,angle:i}=e;return{x:Fh("x","width",t,e),y:Fh("y","height",t,n),angle:i}}function Gh(t,e){var{x:t,y:e}=jh(t,e);return new A(t||0,e||0)}Zr={__proto__:null,addClassNamePrefix:al,assign:E,bindAll:(e,...t)=>(t.flat(1).forEach(t=>{t=ns(t),xo(e,t,e[t].bind(e))}),e),breakText:kl,camelCase:pa,cancelFrame:El,cap:Al,clone:Qs,cloneCells:oh,cloneDeep:ta,dataUriToBlob:Ml,debounce:ia,deepMixin:r,deepSupplement:Ws,defaults:$s,defaultsDeep:Ys,difference:la,downloadBlob:Cl,downloadDataUri:function(t,e){t=Ml(t);Cl(t,e)},evalCalcExpression:vh,evalCalcFormula:fh,filter:Il,flattenDeep:sa,flattenObject:yl,forIn:fa,format:C,getByPath:pl,getElementBBox:function(t){t=L(t);if(0===t.length)throw new Error("Element not found");var t=t[0],e=t.ownerDocument,n=t.getBoundingClientRect(),i=0,r=0;return t.ownerSVGElement&&(t=(t=R(t)).getBBox({target:t.svg()}),i=n.width-t.width,r=n.height-t.height),{x:n.left+window.pageXOffset-e.documentElement.offsetLeft+i/2,y:n.top+window.pageYOffset-e.documentElement.offsetTop+r/2,width:n.width-i,height:n.height-r}},getRectPoint:Ih,groupBy:ra,guid:wl,has:ua,hashCode:fl,imageToDataUri:function(i,r){if(!i||"data:"===i.substr(0,"data:".length))return setTimeout(function(){r(null,i)},0);function o(t,e){var n;200===t.status?(t=new Uint8Array(t.response),e(null,"data:image/"+({svg:"svg+xml"}[n=i.split(".").pop()||"png"]||n)+";base64,"+btoa((t=>{for(var e=[],n=0;n<t.length;n+=32768)e.push(String.fromCharCode.apply(null,t.subarray(n,n+32768)));return e.join("")})(t)))):e(new Error("Failed to load image "+i))}var s=new XMLHttpRequest;s.open("GET",i,!0),s.addEventListener("error",function(){r(new Error("Failed to load image "+i))}),s.responseType=window.FileReader?"blob":"arraybuffer",s.addEventListener("load",function(){var t,e,n;window.FileReader?(e=r,200===(t=s).status?((n=new FileReader).onload=function(t){t=t.target.result;e(null,t)},n.onerror=function(){e(new Error("Failed to load image "+i))},n.readAsDataURL(t.response)):e(new Error("Failed to load image "+i))):o(s,r)}),s.send()},interpolate:Vl,intersection:(...t)=>{var e=t.map(t=>mo(t)&&Po(t)?t:[]);return e.length&&e[0]===t[0]?(t=>{var e=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),n=(t,e)=>t.has(e),i=t[0].length,r=t.length,o=new Array(r),s=[];let a,l=1/0,h=r;for(;h--;)a=t[h],l=Math.min(a.length,l),o[h]=120<=i&&120<=a.length?new Us(h&&a):void 0;a=t[0];let u=-1;var c=o[0];t:for(;++u<i&&s.length<l;){var d=f=a[u],f=0!==f?f:0;if(!(c?n(c,d):e(s,d))){for(h=r;--h;){var p=o[h];if(!(p?n(p,d):e(t[h],d)))continue t}c&&c.push(d),s.push(f)}}return s})(e):[]},invoke:Xs,invokeProperty:Zs,isBoolean:Hs,isCalcExpression:ph,isEmpty:ea,isEqual:na,isFunction:b,isNumber:qs,isObject:x,isPercentage:Sl,isPlainObject:y,isString:T,merge:_,mixin:n,nextFrame:Tl,noop:Dl,normalizeEvent:k,normalizeSides:Ol,normalizeWheel:xl,objectDifference:Bl,omit:ca,parseCssNumeric:Pl,parseDOMJSON:dl,pick:da,removeClassNamePrefix:function(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,hl.classNamePrefix.length)===hl.classNamePrefix?t.substr(hl.classNamePrefix.length):t}).join(" ")},result:S,sanitizeHTML:function(t){var[t]=L.parseHTML("<div>"+t+"</div>");return Array.from(t.getElementsByTagName("*")).forEach(function(n){n.getAttributeNames().forEach(function(t){var e=n.getAttribute(t);(t.startsWith("on")||e.startsWith("javascript:")||e.startsWith("data:")||e.startsWith("vbscript:"))&&n.removeAttribute(t)})}),t.innerHTML},setAttributesBySelector:function(t,e){var n=L(t);fa(e,function(t,e){e=n.find(e).addBack().filter(e);ua(t,"class")&&(e.addClass(t.class),t=ca(t,"class")),e.attr(t)})},setByPath:ml,sortBy:oa,sortElements:Nl,sortedIndex:Js,supplement:u,svg:function(t,...n){let i=[];t.forEach((t,e)=>{i.push(t),e in n&&i.push(n[e])});var t=i.join(""),r=new DOMParser,t=`<svg>${t.trim()}</svg>`,e=r.parseFromString(t.replace(/@/g,""),"application/xml");if(e.getElementsByTagName("parsererror")[0])throw new Error("Invalid SVG markup");r=(e=r.parseFromString(t,"text/html")).querySelector("svg");{t=r;let e=[];return Array.from(t.children).forEach(t=>{e.push(function t(e){let n={};let{tagName:i,attributes:r,namespaceURI:o,style:s,childNodes:a}=e;n.namespaceURI=o;n.tagName=o===R.namespace.xhtml?i.toLowerCase():i;let l={};for(var h=s.length;h--;){var u=s[h];l[u]=s.getPropertyValue(u)}n.style=l;let c=r.getNamedItem("@selector");c&&(n.selector=c.value,r.removeNamedItem("@selector"));let d=r.getNamedItem("@group-selector");if(d){let t=d.value.split(",");n.groupSelector=t.map(t=>t.trim()),r.removeNamedItem("@group-selector")}let f=r.getNamedItem("class");f&&(n.className=f.value);let p=[];a.forEach(e=>{switch(e.nodeType){case Node.TEXT_NODE:{let t=e.data.replace(/\s\s+/g," ");t.trim()&&p.push(t);break}case Node.ELEMENT_NODE:p.push(t(e))}});p.length&&(n.children=p);let g={};Array.from(r).forEach(t=>{let{name:e,value:n}=t;g[e]=n});0<Object.keys(g).length&&(n.attributes=g);return n}(t))}),e}},template:Fl,timing:Rl,toArray:et,toKebabCase:function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},toggleFullScreen:function(t){var e=window.top.document;function n(t,e){for(var n=["webkit","moz","ms","o",""],i=0;i<n.length;i++){var r=n[i],r=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[r])return b(t[r])?t[r]():t[r]}}t=t||e.body,n(e,"FullscreenElement")||n(e,"FullScreenElement")?n(e,"ExitFullscreen")||n(e,"CancelFullScreen"):n(t,"RequestFullscreen")||n(t,"RequestFullScreen")},union:ha,uniq:Ks,uniqueId:ma,unsetByPath:vl,uuid:bl,without:aa,wrapWith:Rh,wrappers:Vh};var Uh={__proto__:null,absolute:function(t,n,e){return t.map(t=>{var e=Gh(n,t).round().toJSON();return e.angle=t.angle||0,e})},bottom:function(t,e,n){return Dh(t,e.bottomLeft(),e.corner(),e)},ellipse:function(t,e,n){var i=n.startAngle||0,r=n.step||20;return zh(t,e,i,function(t,e){return(t+.5-e/2)*r})},ellipseSpread:function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return zh(t,e,i,function(t){return t*r})},fn:function(t,e,n){return n.fn(t,e,n)},left:function(t,e,n){return Dh(t,e.origin(),e.bottomLeft(),e)},line:function(t,e,n){return Dh(t,Gh(e,n.start||e.origin()),Gh(e,n.end||e.corner()),e)},right:function(t,e,n){return Dh(t,e.topRight(),e.corner(),e)},top:function(t,e,n){return Dh(t,e.origin(),e.topRight(),e)}};function Hh(t,e){return Ys({},t,e,{x:0,y:0,angle:0,attrs:{}})}function qh(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 $h(t,e,n,i){i=$s({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=qh(e),u=(t<u||c<t?(s=".3em",r=l,o=0,a="start"):t<e?(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")):t<d?(s=".3em",r=-l,o=0,a="end"):(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")),Math.round);return Hh(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Wh(t,e,n,i){i=$s({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=qh(e),u=(t<u||c<t?(s=".3em",r=-l,o=0,a="end"):t<e?(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")):t<d?(s=".3em",r=l,o=0,a="start"):(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")),Math.round);return Hh(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Yh(t,e,n){n=$s({},n,{offset:20});var i,r=ui(0,0),o=-t.theta(r),s=o,r=t.clone().move(r,n.offset).difference(t).round(),t=".3em",o=((90+o)%180==0?(i=e?"end":"middle",e||-270!=o||(t="0em")):-270<o&&o<-90?(i="start",s=o-180):i="end",Math.round);return Hh(n,{x:o(r.x),y:o(r.y),angle:e?s:0,attrs:{labelText:{y:t,textAnchor:i}}})}var Xh={__proto__:null,bottom:function(t,e,n){return Hh(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},inside:function(t,e,n){return Wh(t,e,!1,n)},insideOriented:function(t,e,n){return Wh(t,e,!0,n)},left:function(t,e,n){return Hh(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},manual:function(t,e,n){return Hh(n)},outside:function(t,e,n){return $h(t,e,!1,n)},outsideOriented:function(t,e,n){return $h(t,e,!0,n)},radial:function(t,e,n){return Yh(t.difference(e.center()),!1,n)},radialOriented:function(t,e,n){return Yh(t.difference(e.center()),!0,n)},right:function(t,e,n){return Hh(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},top:function(t,e,n){return Hh(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})}};function Zh(t){var{portLayoutNamespace:e=Uh,portLabelLayoutNamespace:n=Xh}=t,t=ta(t.get("ports"))||{};this.ports=[],this.portsMap={},this.groups={},this.portLayoutNamespace=e,this.portLabelLayoutNamespace=n,this.metrics={},this.metricsKey=null,this._init(t)}Zh.prototype={hasPort:function(t){return t in this.portsMap},getPort:function(t){var e=this.portsMap[t];if(e)return e;throw new Error("Element: unable to find port with id "+t)},getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(e){return this.ports.filter(function(t){return t.group===e})},getGroupPortsMetrics:function(t,e){var{x:e=0,y:n=0,width:i=0,height:r=0}=e,o=e+`:${n}:${i}:`+r;return this.metricsKey!==o&&(this.metrics={},this.metricsKey=o),(o=this.metrics[t])||(o=this.resolveGroupPortsMetrics(t,new tt(e,n,i,r)),this.metrics[t]=o),o},resolveGroupPortsMetrics:function(t,o){var e=void 0===t,n=this.getGroup(t),t=this.getPortsByGroup(t),i=t.map(function(t){return t&&t.position&&t.position.args});let r;r=e?(e=this._evaluateGroup({}),this._getGroupPortTransformations(e,i,o)):this._getGroupPortTransformations(n,i,o);e={ports:t,result:{}};return et(r).reduce((t,e,n)=>{var i=t.ports[n],r=i.id;return t.result[r]={index:n,portId:r,portTransformation:e,labelTransformation:this._getPortLabelTransformation(i,A(e),o),portAttrs:i.attrs,portSize:i.size,labelSize:i.label.size},t},e),e.result},_getGroupPortTransformations:function(t,e,n){var t=t.position||{},i=t.args||{};return(0,t.layoutCallback)(e,n,i)},_getPortLabelTransformation:function(t,e,n){var t=t.label.position||{},i=t.args||{},t=t.layoutCallback;return t?t(e,n,i):null},_init:function(t){if(x(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=et(t.items),s=0,a=o.length;s<a;s++){var l=this._evaluatePort(o[s]);this.ports.push(l),this.portsMap[l.id]=l}},_evaluateGroup:function(t){return _({},t,{position:this._evaluateGroupPositionProperty(t),label:this._evaluateGroupLabelProperty(t)})},_evaluateGroupPositionProperty:function(t){var e=this.portLayoutNamespace,t=t.position;if(void 0===t)return{layoutCallback:this._resolveLayoutCallbackOrThrow(e,"left","Default port group")};if(b(t))return{layoutCallback:t};if(x(t))return t.name?{layoutCallback:this._resolveLayoutCallbackOrThrow(e,t.name,"Provided port group"),args:t.args}:{layoutCallback:this._resolveLayoutCallbackOrThrow(e,"left","Default port group"),args:t.args};if(T(t))return{layoutCallback:this._resolveLayoutCallbackOrThrow(e,t,"Provided port group")};if(Array.isArray(t))return{layoutCallback:this._resolveLayoutCallbackOrThrow(e,"absolute","Default absolute port group"),args:{x:t[0],y:t[1]}};throw new Error("dia.Element: Provided port group position value has an invalid type.")},_evaluateGroupLabelProperty:function(t){t=t.label;return t?_({},t,{position:this._evaluateGroupLabelPositionProperty(t)}):{position:this._evaluateGroupLabelPositionProperty({})}},_evaluateGroupLabelPositionProperty:function(t){var e=this.portLabelLayoutNamespace,t=t.position;if(void 0===t)return{layoutCallback:this._resolveLayoutCallbackOrThrow(e,"left","Default port group label")};if(b(t))return{layoutCallback:t};if(x(t))return t.name?{layoutCallback:this._resolveLayoutCallbackOrThrow(e,t.name,"Provided port group label"),args:t.args}:{layoutCallback:this._resolveLayoutCallbackOrThrow(e,"left","Default port group label"),args:t.args};throw new Error("dia.Element: Provided port group label position value has an invalid type.")},_evaluatePort:function(t){var e=this.getGroup(t.group),t=E({},t);return t.markup=t.markup||e.markup,t.attrs=_({},e.attrs,t.attrs),t.position=this._evaluatePortPositionProperty(e,t),t.label=this._evaluatePortLabelProperty(e,t),t.z=this._evaluatePortZProperty(e,t),t.size=E({},e.size,t.size),t},_evaluatePortPositionProperty:function(t,e){return{args:_({},null!=t.position?t.position.args:{},(null!=e.position&&null!=e.position.args?e.position:e).args)}},_evaluatePortLabelProperty:function(t,e){t=t.label,e=e.label;return e?_({},t,_({},e,{position:this._evaluatePortLabelPositionProperty(e)})):E({},t)},_evaluatePortLabelPositionProperty:function(t){var e=this.portLabelLayoutNamespace,t=t.position;if(void 0===t)return{};if(b(t))return{layoutCallback:t};if(x(t))return t.name?{layoutCallback:this._resolveLayoutCallbackOrThrow(e,t.name,"Provided port label"),args:t.args}:{args:t.args};throw new Error("dia.Element: Provided port label position value has an invalid type.")},_evaluatePortZProperty:function(t,e){return qs(e.z)?e.z:qs(t.z)||"auto"===t.z?t.z:"auto"},_resolveLayoutCallbackOrThrow:function(t,e,n){t=t[e];if(t)return t;throw new Error(`dia.Element: ${n} layout name is not recognized.`)}};var Je={_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={},t=(et(t.items).forEach(function(t){e[t.id]=!0}),this.previous("ports")||{}),n={},t=(et(t.items).forEach(function(t){e[t.id]||(n[t.id]=!0)}),this.graph);t&&!ea(n)&&(t.getConnectedLinks(this,{inbound:!0}).forEach(function(t){n[t.get("target").port]&&t.remove()}),t.getConnectedLinks(this,{outbound:!0}).forEach(function(t){n[t.get("source").port]&&t.remove()}))},hasPorts:function(){return 0<this._portSettingsData.getPorts().length},hasPort:function(t){return this._portSettingsData.hasPort(t)},getPorts:function(){return ta(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=et(this.prop(["ports","items"])).filter(t=>t.group===e);return ta(t)},getPort:function(e){var t=et(this.prop("ports/items")).find(t=>t.id&&t.id===e);return ta(t)},getPortGroupNames:function(){return Object.keys(this._portSettingsData.groups)},getPortsPositions:function(t){var e,n=this.getGroupPortsMetrics(t),i={};for(e in n){var{x:r,y:o,angle:s}=n[e].portTransformation;i[e]={x:r,y:o,angle:s}}return i},getPortMetrics:function(t){var e=this._portSettingsData.getPort(t);return this.getGroupPortsMetrics(e.group)[t]},getGroupPortsMetrics:function(t){return this._portSettingsData.getGroupPortsMetrics(t,this.size())},getPortRelativePosition:function(t){var{x:t,y:e,angle:n}=this.getPortMetrics(t).portTransformation;return{x:t,y:e,angle:n}},getPortRelativeRect(t){var{portTransformation:{x:t,y:e,angle:n},portSize:{width:i,height:r}}=this.getPortMetrics(t);return{x:t-i/2,y:e-r/2,width:i,height:r,angle:n}},getPortCenter(t){var e=this.getBBox(),t=this.getPortRelativePosition(t),t=new A(t).offset(e.x,e.y),n=this.angle();return n&&t.rotate(e.center(),-n),t},getPortBBox:function(t,e){var t=this.getPortRelativeRect(t),n=this.getBBox(),t=new tt(t),i=(t.offset(n.x,n.y),this.angle());return i&&t.moveAroundPoint(n.center(),-i),e&&e.rotate&&t.rotateAroundCenter(i),t},getPortIndex:function(t){var e=x(t)?t.id:t;return this._isValidPortId(e)?et(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!x(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=E([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){t="number"==typeof t?t:this.getPortIndex(t);if(!x(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var i=E([],this.prop("ports/items"));return i.splice(t,0,e),this.prop("ports/items",i,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);t=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?t[0]=["ports","items",r].concat(e):T(e)?t[0]=["ports/items/",r,"/",e].join(""):(t=["ports/items/"+r],y(e)&&(t.push(e),t.push(n))),this.prop.apply(this,t)},_validatePorts:function(){var t=this.get("ports")||{},e=[],t=t||{},t=et(t.items);return t.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),Ks(t,"id").length!==t.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!x(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",E([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var n,e=e||{},t=this.getPortIndex(t);return-1!==t&&((n=E([],this.prop(["ports","items"]))).splice(t,1),e.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],n,e),this.stopBatch("port-remove")),this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;e=E([],this.prop(["ports","items"]));i=e.filter(function(e){return!t.some(function(t){t=x(t)?t.id:t;return e.id===t})})}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(0<e.length)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Zh(this);var n,i=this._portSettingsData.getPorts();t&&(e=i.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),0<(n=t.filter(function(e){if(!i.find(function(t){return t.id===e.id}))return e})).length&&this.trigger("ports:remove",this,n),0<e.length)&&this.trigger("ports:add",this,e)}},hn={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 e=[],n=this._getContainerElement(),t=0,i=n.node.childNodes.length;t<i;t++)e.push(n.node.childNodes[t]);for(var r=ra(this.model._portSettingsData.getPorts(),"z"),o=(et(r.auto).forEach(function(t){t=this._getPortElement(t);n.append(t),e.push(t)},this),Object.keys(r)),s=0;s<o.length;s++){var a,l=o[s];"auto"!==l&&(a=parseInt(l,10),this._appendPorts(r[l],a,e))}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),t=et(t).map(this._getPortElement,this);n[e]||e<0?R(n[Math.max(e,0)]).before(t):i.append(t)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){var n,t=this._portElementsCache[t];return t?e?(n=t.portElement.node,this.findBySelector(e,n,t.portSelectors)):[t.portContentElement.node]:[]},findPortNode:function(t,e){var[t=null]=this.findPortNodes(t,e);return t},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){Xs(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r,o=R(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t),a,l;if(Array.isArray(s)?(l=(a=this.parseDOMJSON(s,o.node)).fragment,e=1<l.childNodes.length?R("g").append(l):R(l.firstChild),r=a.selectors):(e=R(s),Array.isArray(e)&&(e=R("g").append(e))),!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group}),qs(t.id)&&e.attr("port-id-type","number");var h,u=this._getPortLabelMarkup(t.label);if(Array.isArray(u)?({fragment:f,selectors:p}=this.parseDOMJSON(u,o.node),0<(d=f.childNodes.length)&&(i=p,n=1===d?R(f.firstChild):R("g").append(f))):(n=R(u),Array.isArray(n)&&(n=R("g").append(n))),r&&i){for(var c in i)if(r[c]&&c!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=E({},r,i)}else h=r||i||{};var d,f,p="labelText";return"portRoot"in h||(h.portRoot=e.node),n&&(d=n.node,"labelRoot"in h||(h.labelRoot=d),p in h||(f="TEXT"===n.tagName()?d:Array.from(d.querySelectorAll("text")),h[p]=f,(i=i||{})[p]=f)),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){var n=this.model.getGroupPortsMetrics(t),i=Object.keys(n);for(let t=0,e=i.length;t<e;t++){var r=i[t],o=n[r],r=this._portElementsCache[r]||{},s=o.portTransformation,a=o.labelTransformation;a&&r.portLabelElement&&(this.updateDOMSubtreeAttributes(r.portLabelElement.node,a.attrs,{rootBBox:new tt(o.labelSize),selectors:r.portLabelSelectors}),this.applyPortTransform(r.portLabelElement,a,-s.angle||0)),this.updateDOMSubtreeAttributes(r.portElement.node,o.portAttrs,{rootBBox:new tt(o.portSize),selectors:r.portSelectors}),this.applyPortTransform(r.portElement,s)}},applyPortTransform:function(t,e,n){n=R.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(n,{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}},f=Oh.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),Oh.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){var i=qs(e),{parentRelative:r,deep:o,restrictedArea:s}=n=(i?n:t)||{};let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");var l=this.getParentCell();l&&!l.isLink()&&(a=l.get("position"))}return i?(a&&(t+=a.x,e+=a.y),o||s?({x:l,y:i}=this.get("position"),this.translate(t-l,e-i,n)):this.set("position",{x:t,y:e},n),this):(o=A(this.get("position")),r?o.difference(a):o)},translate:function(t,e,n){var i,r,o,s,a;return e=e||0,0===(t=t||0)&&0===e||((n=n||{}).translateBy=n.translateBy||this.id,i=this.get("position")||{x:0,y:0},(s=n.restrictedArea)&&n.translateBy===this.id&&(e="function"==typeof s?(t=(r=s.call(this,i.x+t,i.y+e,n)).x-i.x,r.y-i.y):(r=this.getBBox({deep:!0}),o=i.x-r.x,a=i.y-r.y,o=Math.max(s.x+o,Math.min(s.x+s.width+o-r.width,i.x+t)),s=Math.max(s.y+a,Math.min(s.y+s.height+a-r.height,i.y+e)),t=o-i.x,s-i.y)),a={x:i.x+t,y:i.y+e},n.tx=t,n.ty=e,n.transition?(x(n.transition)||(n.transition={}),this.transition("position",a,E({},n.transition,{valueFunction:Vl.object})),Xs(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",a,n),Xs(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}:(x(t)&&(n=e,e=(qs(t.height)?t:i).height,t=(qs(t.width)?t:i).width),this.resize(t,e,n))},resize:function(t,e,n){if(this.startBatch("resize",n=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=Yn(this.get("angle")||0),o=this.getBBox();if(r)var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction],a=o[["bottomLeft","corner","topRight","origin"][s=n.absolute?(s+Math.floor((r+45)/90))%4:s]](),a=A(a).rotate(o.center(),-r),l=Math.sqrt(t*t+e*e)/2,h=s*Math.PI/2,s=(h=(h+=Math.atan(s%2==0?e/t:t/e))-Zn(r),A.fromPolar(l,h,a)),u=A(s).offset(t/-2,e/-2);else switch(u=o.topLeft(),n.direction){case"top":case"top-right":u.offset(0,o.height-e);break;case"left":case"bottom-left":u.offset(o.width-t,0);break;case"top-left":u.offset(o.width-t,o.height-e)}this.set("size",{width:t,height:e},n),this.position(u.x,u.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){t=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(t.x,t.y,i),this.resize(t.width,t.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t={}){var e=this.graph;if(e)return e=this._getFilteredChildElements(t.filter),this.startBatch("fit-embeds",t),t.deep&&Xs(e,"fitToChildren",ca(t,"minRect")),this._fitToElements(Object.assign({elements:e},t)),this.stopBatch("fit-embeds"),this;throw new Error("Element must be part of a graph.")},fitParent:function(t={}){var e,n=this.graph;if(n)return t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id)||(n=this.getParentCell())&&n.isElement()&&(e=n._getFilteredChildElements(t.filter),this.startBatch("fit-parent",t),n._fitToElements(Object.assign({elements:e},t)),t.deep&&n.fitParent(ca(t,"minRect")),this.stopBatch("fit-parent")),this;throw new Error("Element must be part of a graph.")},_getFilteredChildElements:function(e){let t;return t="function"==typeof e?t=>t.isElement()&&e(t):t=>t.isElement(),this.getEmbeddedCells().filter(t)},_fitToElements:function(n={}){let i=null;n.minRect&&(r=E(this.getBBox(),n.minRect),i=new tt(r));var r=this.graph.getCellsBBox(n.elements);if(r){var{expandOnly:o,shrinkOnly:s}=n;if(o&&s)this._setBBox(i,n);else{var{x:r,y:a,width:l,height:h}=r,{left:u,right:c,top:d,bottom:f}=Ol(n.padding);r-=u,a-=d,l+=u+c,h+=f+d;let t=new tt(r,a,l,h);if(o)t=this.getBBox().union(t);else if(s){u=this.getBBox().intersect(t);if(!u)return void this._setBBox(i,n);t=u}let e=t;i&&(e=e.union(i)),this._setBBox(e,n)}}else this._setBBox(i,n)},_setBBox:function(t,e){var n,i,r;t&&({x:t,y:n,width:i,height:r}=t,this.set({position:{x:t,y:n},size:{width:i,height:r}},e))},rotate:function(t,e,n,i){var r,o,s,a;return n?(a=this.getCenter(),r=this.get("size"),o=this.get("position"),a.rotate(n,this.get("angle")-t),s=a.x-r.width/2-o.x,a=a.y-r.height/2-o.y,this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(o.x+s,o.y+a,i),this.rotate(t,e,null,i),this.stopBatch("rotate")):this.set("angle",e?t:(this.get("angle")+t)%360,i),this},angle:function(){return Yn(this.get("angle")||0)},getBBox:function(t={}){var e,{graph:n,attributes:i}=this,{deep:r,rotate:o}=t;return r&&n?((r=this.getEmbeddedCells({deep:!0,breadthFirst:!0})).push(this),n.getCellsBBox(r,t)):({angle:n=0,position:{x:r,y:t},size:{width:i,height:e}}=i,r=new tt(r,t,i,e),o&&r.rotateAroundCenter(n),r)},getCenter:function(){var{position:{x:t,y:e},size:{width:n,height:i}}=this.attributes;return new A(t+n/2,e+i/2)},getPointFromConnectedLink:function(t,e){var n=this.getBBox().center(),t=t.get(e);return t&&(e=t.port)&&this.hasPort(e)?this.getPortCenter(e):n}});E(f.prototype,Je);let Jh=Oh.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){var i;return void 0===t?Qs(this.get("source")):t instanceof Oh?((i=Qs(e)||{}).id=t.id,this.set("source",i,n)):y(t)?this.set("source",i=t,e):((i=Qs(e)||{}).x=t.x,i.y=t.y,this.set("source",i,n))},target:function(t,e,n){var i;return void 0===t?Qs(this.get("target")):t instanceof Oh?((i=Qs(e)||{}).id=t.id,this.set("target",i,n)):y(t)?this.set("target",i=t,e):((i=Qs(e)||{}).x=t.x,i.y=t.y,this.set("target",i,n))},router:function(t,e,n){var i;return void 0===t?(i=this.get("router"))?"object"==typeof i?Qs(i):i:null:this.set("router",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},connector:function(t,e,n){var i;return void 0===t?(i=this.get("connector"))?"object"==typeof i?Qs(i):i:null:this.set("connector",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},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(){var t=this.attributes.labels;return Array.isArray(t)&&0<t.length},insertLabel:function(t,e,n){var i,r;if(e)return r=(i=this.labels()).length,t=isFinite(t)&&null!==t?0|t:r,i.splice(t=t<0?r+t+1:t,0,e),this.labels(i,n);throw new Error("dia.Link: no label provided")},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();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["vertices",t]):(i=this._normalizeVertex(e),this.prop(["vertices",t],i,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],r=this._normalizeVertex(r);n.push(r)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){var i,r;if(e)return r=(i=this.vertices()).length,(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),r=this._normalizeVertex(e),i.splice(t,0,r),this.vertices(i,n);throw new Error("dia.Link: no vertex provided")},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 y(t)?t:{x:t.x,y:t.y}},translate:function(e,n,t){return(t=t||{}).translateBy=t.translateBy||this.id,t.tx=e,t.ty=n,this.applyToPoints(function(t){return{x:(t.x||0)+e,y:(t.y||0)+n}},t)},scale:function(e,n,i,t){return this.applyToPoints(function(t){return A(t).scale(e,n,i).toJSON()},t)},applyToPoints:function(t,e){var n,i,r;if(b(t))return n={},{source:r,target:i}=this.attributes,r.id||(n.source=t(r)),i.id||(n.target=t(i)),0<(r=this.vertices()).length&&(n.vertices=r.map(t)),this.set(n,e);throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.")},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new A(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new A(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint(),...this.vertices().map(A),this.getTargetPoint()];return new w(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e,n,i,r;return this.graph&&(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),e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,e=e.id,n=n.id;return!(!e||!n)&&(!(e=e===n)&&t.deep&&this.graph&&(n=this.getSourceCell(),t=this.getTargetCell(),e=n.isEmbeddedIn(t)||t.isEmbeddedIn(n)),e)},getSourceCell:function(){var{graph:t,attributes:e}=this,e=e.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getSourceCell())&&t.isLink());return t},getTargetCell:function(){var{graph:t,attributes:e}=this,e=e.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getTargetCell())&&t.isLink());return t},getRelationshipAncestor:function(){var t;return this.graph&&(t=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t}),t=this.graph.getCommonAncestor.apply(this.graph,t)),t||null},isRelationshipEmbeddedIn:function(t){var t=T(t)||qs(t)?t:t.id,e=this.getRelationshipAncestor();return!!e&&(e.id===t||e.isEmbeddedIn(t))},_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}}),Kh={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))},isAppleWebKit:function(){var t=navigator.userAgent,e=/applewebkit/i.test(t),t=/chrome/i.test(t);return e&&!t}},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){try{n=e()}catch{n=!1}this._results[t]=n}return n}};function Qh(r,o,s=[],t={}){var{cornerType:a=tu.POINT,cornerRadius:l=nu,cornerPreserveAspectRatio:h=!1,precision:u=iu,raw:t=!1}=t;if(-1===eu.indexOf(a))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(a!==tu.POINT&&l){(c=new I).appendSegment(I.createSegment("M",r));let i;var e=s.length;for(let n=0;n<e;n++){var d=new A(s[n]),f=s[n-1]||r,p=s[n+1]||o,g=i||d.distance(f)/2;i=d.distance(p)/2;let t,e;h?t=e=-Math.min(l,g,i):(t=-Math.min(l,g),e=-Math.min(l,i));var m=d.clone().move(f,t).round(u),v=d.clone().move(p,e).round(u);switch(c.appendSegment(I.createSegment("L",m)),a){case tu.CUBIC:var y=new A(1/3*m.x+2/3*d.x,2/3*d.y+1/3*m.y),b=new A(1/3*v.x+2/3*d.x,2/3*d.y+1/3*v.y);c.appendSegment(I.createSegment("C",y,b,v));break;case tu.LINE:c.appendSegment(I.createSegment("L",v));break;case tu.GAP:c.appendSegment(I.createSegment("M",v))}}c.appendSegment(I.createSegment("L",o))}else{var n=[r].concat(s).concat([o]),n=new w(n);c=new I(n)}return t?c:c.serialize()}Ke=f.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"}]}),h=f.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"}]}),a=f.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"}]}),i=f.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"}]}),s=f.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"}]}),o=f.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"}]}),e=f.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"}]}),Ue=f.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"}]}),l=f.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"}]}),r=f.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"}]}),C=f.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"}]}),n=f.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){var n;return void 0===t?this.attr("body/lateralArea"):(n={lateralArea:t},t=Sl(t)?`calc(${parseFloat(t)/100}*h)`:t,this.attr({body:n,top:{cy:t,ry:t}},e))}},{attributes:{"lateral-area":{set:function(t,e){var n=Sl(t),i=(n&&(t=parseFloat(t)/100),e.x),r=e.y,o=e.width,e=e.height,s=o/2,a=n?e*t:t,l=R.KAPPA,s=l*s,l=l*(n?e*t:t),n=i+o/2,t=i+o,o=r+a,h=o-a,a=r+e-a,r=r+e;return{d:["M",i,o,"L",i,a,"C",i,a+l,n-s,r,n,r,"C",n+s,r,t,a+l,t,a,"L",t,o,"C",t,o-l,n+s,h,n,h,"C",n-s,h,i,o-l,i,o,"Z"].join(" ")}},unset:"d"}}}),u=Kh.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"}},Je=f.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"},u]},{attributes:{text:{set:function(t,e,n,i){var r,o;if(!(n instanceof HTMLElement))return i=i.style||{},r={text:t,width:-5,height:"100%"},o=E({"text-vertical-anchor":"middle"},i),Mh["text-wrap"].set.call(this,r,e,n,o),{fill:i.color||null};n.textContent=t},unset:function(t){if(t.textContent="",t instanceof SVGElement)return"fill"},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),u=Jh.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"}}]}),Ue={__proto__:null,standard:{__proto__:null,BorderedImage:Ue,Circle:h,Cylinder:n,DoubleLink:Jh.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"}}]}),Ellipse:a,EmbeddedImage:l,HeaderedRectangle:C,Image:e,InscribedImage:r,Link:u,Path:i,Polygon:s,Polyline:o,Rectangle:Ke,ShadowLink:Jh.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"}}]}),TextBlock:Je}};let tu={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},eu=Object.values(tu),nu=10,iu=1;var ru=["arc","gap","cubic"],ou=1,su=["smooth"],au=1/3,lu=2/3;function hu(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;return n>r&&(t=n,n=r,r=t,t=i,i=o,o=t),i>o&&(e=n,n=r,r=e,e=i,i=o,o=e),[new A(n,i),new A(r,o)]}function uu(t,e,n){var r=[].concat(t,n,e);return r.reduce(function(t,e,n){var i=r[n+1];return null!=i&&(t[n]=fi(e,i)),t},[])}function cu(t){var e,r=t.paper,n=r._jumpOverUpdateList;null==n&&(n=r._jumpOverUpdateList=[],(e=r.model).on("batch:stop",function(){if(!this.hasActiveBatch())for(var t=r._jumpOverUpdateList,e=0;e<t.length;e++){var n=t[e],i=n.getFlag(n.constructor.Flags.CONNECTOR);n.requestUpdate(i)}}),e.on("reset",function(){n=r._jumpOverUpdateList=[]})),n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",function(){n.splice(n.indexOf(t),1)}))}function du(t,e){return fi(t,e).squaredLength()}function fu(h,u,c,d){var f=new I,p=I.createSegment("M",h[0].start);return f.appendSegment(p),et(h).forEach(function(t,e){var n,i,r,o,s,a,l;t.isJump?"arc"===c?(s=-90,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(s+=180),r=t.midpoint(),o=new P(r,t.end).rotate(r,s),a=(n=new P(t.start,r)).pointAt(2/3).rotate(t.start,s),l=o.pointAt(1/3).rotate(o.end,-s),p=I.createSegment("C",a,l,o.end),f.appendSegment(p),n=new P(r,t.end),a=o.pointAt(1/3).rotate(o.end,s),l=n.pointAt(1/3).rotate(t.end,-s),p=I.createSegment("C",a,l,t.end),f.appendSegment(p)):"gap"===c?(p=I.createSegment("M",t.end),f.appendSegment(p)):"cubic"===c&&(s=t.start.theta(t.end),r=.6*u,o=1.35*u,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(o*=-1),a=A(t.start.x+r,t.start.y+o).rotate(t.start,s),l=A(t.end.x-r,t.end.y+o).rotate(t.end,s),p=I.createSegment("C",a,l,t.end),f.appendSegment(p)):(n=h[e+1],0==d||!n||n.isJump?(p=I.createSegment("L",t.end),f.appendSegment(p)):(i=d,r=f,o=t.end,s=t.start,a=n.end,l=o.distance(s)/2,e=o.distance(a)/2,l=-Math.min(i,l),i=-Math.min(i,e),e=o.clone().move(s,l).round(),s=o.clone().move(a,i).round(),l=new A(au*e.x+lu*o.x,lu*o.y+au*e.y),a=new A(au*s.x+lu*o.x,lu*o.y+au*s.y),i=I.createSegment("L",e),r.appendSegment(i),i=I.createSegment("C",l,a,s),r.appendSegment(i)))}),f}let pu={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},gu={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"};function mu(t,e,n=[],i={},r){var o=Boolean(i.raw),{direction:s=pu.AUTO,precision:a=3}=i;let l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new A(i.sourceTangent):null,targetTangent:i.targetTangent?new A(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new A(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new A(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new A(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new A(i.targetDirection).normalize():null,i=[t,...n,e].map(t=>new A(t));let h;h=l.sourceTangent||(t=((t,e,n,i)=>{if(i.sourceDirection)switch(i.sourceDirection){case gu.UP:return new A(0,-1);case gu.DOWN:return new A(0,1);case gu.LEFT:return new A(-1,0);case gu.RIGHT:return new A(1,0);case gu.AUTO:return vu(t,e,i);case gu.CLOSEST_POINT:return bu(0,e);case gu.OUTWARDS:return xu(t,e);default:return i.sourceDirection}switch(n){case pu.HORIZONTAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.x>e[1].x?"right":"left";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case pu.VERTICAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.y>e[1].y?"bottom":"top";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case pu.CLOSEST_POINT:return bu(0,e);case pu.OUTWARDS:return xu(t,e);default:pu.AUTO;return vu(t,e,i)}})(r,i,s,l),n=i[0].distance(i[1])*l.coeff,(e=Pu(t,i[1].difference(i[0]).normalize()))>Math.PI/4?(e=n+(e-Math.PI/4)*l.angleTangentCoefficient,t.clone().scale(e,e)):t.clone().scale(n,n));let u;return u=l.targetTangent||(e=((t,e,n,i)=>{if(i.targetDirection)switch(i.targetDirection){case gu.UP:return new A(0,-1);case gu.DOWN:return new A(0,1);case gu.LEFT:return new A(-1,0);case gu.RIGHT:return new A(1,0);case gu.AUTO:return yu(t,e,i);case gu.CLOSEST_POINT:return wu(0,e);case gu.OUTWARDS:return Au(t,e);default:return i.targetDirection}switch(n){case pu.HORIZONTAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.x>e[e.length-2].x?"left":"right";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case pu.VERTICAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.y>e[e.length-2].y?"top":"bottom";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case pu.CLOSEST_POINT:return wu(0,e);case pu.OUTWARDS:return Au(t,e);default:pu.AUTO;return yu(t,e,i)}})(r,i,s,l),n=i[(t=i.length-1)-1].distance(i[t])*l.coeff,(r=Pu(e,i[t-1].difference(i[t]).normalize()))>Math.PI/4?(s=n+(r-Math.PI/4)*l.angleTangentCoefficient,e.clone().scale(s,s)):e.clone().scale(n,n)),t=((r,t,e,n)=>{var{tau:i,coeff:o}=n,s=[],a=[],l=[],h=r.length-1;for(let t=0;t<h;t++)s[t]=r[t].distance(r[t+1]);a[0]=t,a[h]=e;for(let i=1;i<h;i++){let t,e;t=1===i?r[i-1].clone().offset(a[i-1].x,a[i-1].y):r[i-1].clone(),e=i===h-1?r[i+1].clone().offset(a[i+1].x,a[i+1].y):r[i+1].clone();var u=t.difference(r[i]).normalize(),c=e.difference(r[i]).normalize(),d=Pu(u,c);let n=(Math.PI-d)/2;var u=Tu(u,c),d=(f=Tu(r[i].difference(r[i+1]),r[i].difference(r[i-1])),u<0&&(n=-n),d<Math.PI/2&&(n<0&&f<0||0<n&&0<f)&&(n-=Math.PI),((t,e)=>{var n=Math.cos(e),e=Math.sin(e),i=n*t.x-e*t.y,e=e*t.x+n*t.y;t.x=i,t.y=e})(u=c.clone(),n),u.clone()),f=u.clone(),c=s[i-1]*o,u=s[i]*o;d.scale(c,c),f.scale(u,u),a[i]=[d,f]}for(let n=0;n<h;n++){let t,e;t=0===n?r[n+1].difference(a[n].x/i,a[n].y/i):r[n+1].difference(a[n][1].x/i,a[n][1].y/i),e=n===h-1?r[n].clone().offset(a[n+1].x/i,a[n+1].y/i):r[n].difference(a[n+1][0].x/i,a[n+1][0].y/i),l[n]=[t,r[n],r[n+1],e]}return l})(i,h,u,l).map(t=>{return t=t,e=(e=l).tau,(n=new A).x=t[1].x+(t[2].x-t[0].x)/(6*e),n.y=t[1].y+(t[2].y-t[0].y)/(6*e),(i=new A).x=t[2].x+(t[3].x-t[1].x)/(6*e),i.y=t[2].y+(t[3].y-t[1].y)/(6*e),new v(t[1],n,i,t[2]);var e,n,i}),r=new I(t).round(a),o?r:r.serialize()}function vu(t,e,n){var i,r=t.sourceBBox;let o,s,a;switch(o=t.sourceView?(s=t.sourceView.model.angle(),n.rotate&&s?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(i=e[0].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[0])):r.sideNearestToPoint(e[1])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function yu(t,e,n){var i,r=t.targetBBox;let o,s,a;switch(o=t.targetView?(s=t.targetView.model.angle(),n.rotate&&s?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(i=e[e.length-1].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[e.length-1])):r.sideNearestToPoint(e[e.length-2])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function bu(t,e){return e[1].difference(e[0]).normalize()}function wu(t,e){var n=e.length-1;return e[n-1].difference(e[n]).normalize()}function xu(t,e){t=t.sourceBBox,t=t.center();return e[0].difference(t).normalize()}function Au(t,e){t=t.targetBBox,t=t.center();return e[e.length-1].difference(t).normalize()}function Pu(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return 1<(n=n<-1?-1:n)&&(n=1),Math.acos(n)}function Tu(t,e){return t.x*e.y-t.y*e.x}function Eu(t){this.cid=t&&t.cid||ma("view"),this.preinitialize.apply(this,arguments),E(this,da(t,Lu)),this._ensureElement(),this.initialize.apply(this,arguments)}mu.Directions=pu,mu.TangentDirections=gu;var Su={__proto__:null,curve:mu,jumpover:function(t,e,n,i){cu(this);var r,o,s,u,a,c,l=i.raw,d=i.size||5,h=i.jump&&(""+i.jump).toLowerCase(),f=i.radius||0,p=i.ignoreConnectors||su,g=(-1===ru.indexOf(h)&&(h=ru[0]),this.paper),i=g.model.getLinks();return 1===i.length?fu(uu(t,e,n),d,h,f):(r=this.model,o=i.indexOf(r),s=g.options.defaultConnector||{},i=(u=i.filter(function(t,e){t=t.get("connector")||s;return!(et(p).includes(t.name)||o<e&&"jumpover"===t.name)})).map(function(t){return g.findViewByModel(t)}),a=uu(t,e,n),c=i.map(function(t){return null==t?[]:t===this?a:uu(t.sourcePoint,t.targetPoint,t.route)},this),t=fu(a.reduce(function(t,l){var s,a,h,e=u.reduce(function(t,e,n){var i;return e!==r&&(-1<(n=(e=c[n].slice()).findIndex(t=>{var[{x:e,y:n},{x:i,y:r}]=hu((e=l).start,e.end),[{x:t,y:o},{x:s,y:a}]=hu(t.start,t.end);return e<=s&&t<=i&&(n<=a&&o<=r)}))&&l.containsPoint(e[n].end)&&e.splice(n+1,1),i=l,n=e,e=et(n).reduce(function(t,e){e=i.intersection(e);return e&&t.push(e),t},[]),t.push.apply(t,e)),t},[]).sort(function(t,e){return du(l.start,t)-du(l.start,e)});return 0<e.length?t.push.apply(t,(s=l,h=d,(a=e).reduce(function(t,e,n){if(!0!==e.skip){var i=t.pop()||s,r=ui(e).move(i.start,-h),e=ui(e).move(i.start,+h),n=a[n+1];if(null!=n){var o=e.distance(n);o<=h&&(e=n.move(i.start,o),n.skip=!0)}else if(r.distance(i.end)<2*h+ou)return t.push(i),t;e.distance(i.start)<2*h+ou?t.push(i):((o=fi(r,e)).isJump=!0,t.push(fi(i.start,r),o,fi(e,i.end)))}return t},[]))):t.push(l),t},[]),d,h,f),l?t:t.serialize())},normal:function(t,e,n=[],i={}){i=i.raw,i={cornerType:"point",raw:i};return Qh(t,e,n,i)},rounded:function(t,e,n=[],i={}){var{radius:i=10,raw:r}=i,i={cornerType:"cubic",cornerRadius:i,precision:0,raw:r};return Qh(t,e,n,i)},smooth:function(t,e,n,i){var r,o,i=i&&i.raw;return n&&0!==n.length?(n=[t].concat(n).concat([e]),n=v.throughPoints(n),r=new I(n)):(r=new I,n=I.createSegment("M",t),r.appendSegment(n),n=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?(o=(t.x+e.x)/2,I.createSegment("C",o,t.y,o,e.y,e.x,e.y)):(o=(t.y+e.y)/2,I.createSegment("C",t.x,o,e.x,o,e.x,e.y)),r.appendSegment(n)),i?r:r.serialize()},straight:Qh},_u=/^(\S+)\s*(.*)$/,Lu=["model","collection","el","id","attributes","className","tagName","events","style"];E(Eu.prototype,$l,{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 L?t:L(t),this.el=this.$el[0]},delegateEvents:function(t){if(t=t||S(this,"events"))for(var e in this.undelegateEvents(),t){var n=t[e];(n=b(n)?n:this[n])&&(e=e.match(_u),this.delegate(e[1],e[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(){var t;this.el?this.setElement(S(this,"el")):(t=E({},S(this,"attributes")),this.id&&(t.id=S(this,"id")),this.className&&(t.class=S(this,"className")),this.setElement(this._createElement(S(this,"tagName"))),this._setAttributes(t))},_setAttributes:function(t){this.$el.attr(t)}}),Eu.extend=jl;let ku={},Cu=Eu.extend({options:{},theme:null,themeClassNamePrefix:al("theme-"),requireSetThemeOverride:!1,defaultTheme:hl.defaultTheme,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=E({},this.options,t),Eu.call(this,t)},initialize:function(){(ku[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){(this.svgElement?this.vel:this.$el).remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){var e,n;return(t=t||S(this,"children"))&&(e=this.svgElement,n=R.namespace[e?"svg":"xhtml"],t=dl(t,n),(e?this.vel:this.$el).empty().append(t.fragment),this.childNodes=t.selectors),this},findAttributeNode:function(t,e){let n=e;for(;n&&1===n.nodeType;){if(n.getAttribute(t))return n;if(n===this.el)return null;n=n.parentNode}return null},findAttribute:function(t,e){e=this.findAttributeNode(t,e);return e&&e.getAttribute(t)},_ensureElement:function(){var t,e,n;this.el?this.setElement(S(this,"el")):(t=S(this,"tagName"),e=E({},S(this,"attributes")),n=E({},S(this,"style")),this.id&&(e.id=S(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)),this._ensureElClassName()},_setAttributes:function(t){(this.svgElement?this.vel:this.$el).attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(R.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof L?t:L(t),this.el=this.$el[0],this.svgElement&&(this.vel=R(this.el))},_ensureElClassName:function(){var t,e=S(this,"className");e&&(t=al(e),(this.svgElement?this.vel:this.$el).removeClass(e).addClass(t))},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){return(t=t||this.theme)&&(t=this.themeClassNamePrefix+t,(this.svgElement?this.vel:this.$el).addClass(t)),this},removeThemeClassName:function(t){t=t||this.theme;t=this.themeClassNamePrefix+t;return(this.svgElement?this.vel:this.$el).removeClass(t),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),ku[this.cid]=null,Eu.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(e){n=n||{};var i,r=this.getEventNamespace();for(i in e){var o=e[i];(o="function"!=typeof o?this[o]:o)&&L(t).on(i+r,n,o.bind(this))}}return this},undelegateElementEvents:function(t){return L(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t=t||S(this,"documentEvents"),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){var n,i;if(t)return n=t.data,i="__"+this.cid+"__",void 0===e?n&&n[i]||{}:((n=n||(t.data={}))[i]||(n[i]={}),E(n[i],e),this);throw new Error("eventData(): event object required.")},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]&&E({},t[0])||{},t=t[1]&&E({},t[1])||{},n=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof n&&n.apply(this,arguments),this.render.__render__===n&&this.onRender(),this},e.render.__render__=n,Eu.extend.call(this,e,t)}});function Mu(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,E({silent:!0},e))}function Nu(t,e,n){n=Math.min(Math.max(n,0),t.length);for(var i=Array(t.length-n),r=e.length,o=0;o<i.length;o++)i[o]=t[o+n];for(o=0;o<r;o++)t[o+n]=e[o];for(o=0;o<i.length;o++)t[o+r+n]=i[o]}var Ou,Ru,Vu,Iu={add:!0,remove:!0,merge:!0},Fu={add:!0,remove:!1};E(Mu.prototype,$l,{model:Gl,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(t,e){return this.set(t,E({merge:!1},e,Fu))},remove:function(t,e){e=E({},e);var n=!Array.isArray(t),t=(t=n?[t]:t.slice(),this._removeModels(t,e));return!e.silent&&t.length&&(e.changes={added:[],merged:[],removed:t},this.trigger("update",this,e)),n?t[0]:t},set:function(t,e){if(null!=t){e=E({},Iu,e);for(var n=!Array.isArray(t),i=(t=n?[t]:t.slice(),e.at),r=((i=(i=null!=i?+i:i)>this.length?this.length:i)<0&&(i+=this.length+1),[]),o=[],s=[],a=[],l={},h=e.add,u=e.merge,c=e.remove,d=!1,f=this.comparator&&null==i&&!1!==e.sort,p=T(this.comparator)?this.comparator:null,g=0;g<t.length;g++){var m,v=t[g],y=this.get(v);y?(u&&v!==y&&(m=this._isModel(v)?v.attributes:v,y.set(m,e),s.push(y),f)&&!d&&(d=y.hasChanged(p)),l[y.cid]||(l[y.cid]=!0,r.push(y)),t[g]=y):h&&(v=t[g]=this._prepareModel(v,e))&&(o.push(v),this._addReference(v,e),l[v.cid]=!0,r.push(v))}if(c){for(g=0;g<this.length;g++)l[(v=this.models[g]).cid]||a.push(v);a.length&&this._removeModels(a,e)}var b=!1;if(r.length&&(!f&&h&&c)?(b=this.length!==r.length||this.models.some(function(t,e){return t!==r[e]}),this.models.length=0,Nu(this.models,r,0),this.length=this.models.length):o.length&&(f&&(d=!0),Nu(this.models,o,null==i?this.length:i),this.length=this.models.length),d&&this.sort({silent:!0}),!e.silent){for(g=0;g<o.length;g++)null!=i&&(e.index=i+g),(v=o[g]).trigger("add",v,this,e);(d||b)&&this.trigger("sort",this,e),(o.length||a.length||s.length)&&(e.changes={added:o,removed:a,merged:s},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?Qs(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,E({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,E({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,E({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 b(e)&&(e=e.bind(this)),1===n||T(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 Bu(this,Du)},keys:function(){return new Bu(this,zu)},entries:function(){return new Bu(this,ju)},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):(t=((e=e?Qs(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,t.validationError,e),!1):t},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r,o,s=this.get(t[i]);s&&(r=this.models.indexOf(s),this.models.splice(r,1),this.length--,delete this._byId[s.cid],null!=(o=this.modelId(s.attributes,s.idAttribute))&&delete this._byId[o],e.silent||(e.index=r,s.trigger("remove",s,this,e)),n.push(s),this._removeReference(s,e))}return 0<t.length&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof Gl},_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;"changeId"===t&&(n=this.modelId(e.previousAttributes(),e.idAttribute),t=this.modelId(e.attributes,e.idAttribute),null!=n&&delete this._byId[n],null!=t)&&(this._byId[t]=e)}this.trigger.apply(this,arguments)}});(h="function"==typeof Symbol&&Symbol.iterator)&&(Mu.prototype[h]=Mu.prototype.values);var Bu=function(t,e){this._collection=t,this._kind=e,this._index=0},Du=1,zu=2,ju=3;function Gu(t){return t?Array.isArray(t)?t:[t]:[]}h&&(Bu.prototype[h]=function(){return this}),Bu.prototype.next=function(){if(this._collection){var t,e;if(this._index<this._collection.length)return t=this._collection.at(this._index),this._index++,{value:this._kind===Du?t:(e=this._collection.modelId(t.attributes,t.idAttribute),this._kind===zu?e:[e,t]),done:!1};this._collection=void 0}return{value:void 0,done:!0}},l=(a=n=[Mu,{toArray:1,sortBy:3},"models"])[0],a=n[2],C={sortBy:oa,toArray:et},Ou=l,Ru=C,l=n[1],Vu=a,fa(l,function(t,e){Ru[e]&&(Ou.prototype[e]=nh(Ru,t,e,Vu))}),Mu.extend=jl,e={__proto__:null,$:L,Collection:Mu,Data:va,Event:ya,Events:$l,Listener:class{constructor(...t){this.callbackArguments=t}listenTo(i,r,...o){let s=this.callbackArguments;if(r&&"object"==typeof r){let[n=null]=o;Object.entries(r).forEach(([t,e])=>{"function"==typeof e&&((n||0<s.length)&&(e=e.bind(n,...s)),$l.listenTo.call(this,i,t,e))})}else if("string"==typeof r&&"function"==typeof o[0]){let[t,e=null]=o;(e||0<s.length)&&(t=t.bind(e,...s)),$l.listenTo.call(this,i,r,t)}}stopListening(){$l.stopListening.call(this)}},Model:Gl,View:Cu,ViewBase:Eu,views:ku};let Uu=Cu.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){var n=t.paper;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;var{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform()):this.postponedUpdate=!0,0},findNode(t,e=null){let n;var i,r,o,s;return"string"==typeof e?n=t.findNode(e):y(e)?(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)):!e||(n=R.toNode(e))instanceof SVGElement&&t.el.contains(n)||(n=null),n||null},getNodeMatrix(t,e){var n=this.options,n=n.layer,i=t.rotatableNode,r=t.getNodeMatrix(e);return i?n?i.contains(e)?r:t.getRootRotateMatrix().inverse().multiply(r):t.getNodeRotateMatrix(e).multiply(r):r},mount(){var{MOUNTABLE:e,cellView:t,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(e&&!r)if(s)this.update(t,a),this.transform();else{var e=t.paper,{layer:r,z:s}=i;if(r){let t;o?(t=o,this.detachedTransformGroup=null):t=R("g").addClass("highlight-transform").append(n),this.transformGroup=t,e.getLayerView(r).insertSortedNode(t.node,s)}else{a=t.el.children[Math.max(s,0)],i=qs(s)&&a,o=i?n===a:!n.nextElementSibling;n.parentNode&&o||(i?t.el.insertBefore(n,a):t.el.appendChild(n))}}},unmount(){var{MOUNTABLE:t,transformGroup:e,vel:n,options:i}=this;t&&(i.layer?e&&(this.transformGroup=null,(this.detachedTransformGroup=e).remove()):n.remove())},transform(){var{transformGroup:t,cellView:e,updateRequested:n}=this;!t||e.model.isLink()||n||(n=e.getRootTranslateMatrix(),e=e.getRootRotateMatrix(),n=n.multiply(e),t.attr("transform",R.matrixToTransformString(n)))},update(){var{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;i||(this.postponedUpdate=!1,i=this.node=this.findNode(e,n),t&&this.unhighlight(e,t),i?(this.highlight(e,i),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this)))},onRemove(){var{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){var e=S(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){var n=this.cellView;if(n){let{model:e,paper:t}=n;S(this,"UPDATE_ATTRIBUTES").some(t=>e.hasChanged(t))&&t.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}}},{_views:{},highlight:function(t,e,n){var i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){e=this.uniqueId(e,n);this.remove(t,e)},get(t,e=null){var t=t.cid,n=this._views,i=n[t];if(null===e){var r=[];if(i)for(var o in i){o=i[o];o instanceof this&&r.push(o)}return r}if(i&&e in i){n=i[e];if(n instanceof this)return n}return null},has(t,e=null){var t=t.cid,n=this._views,i=n[t];if(i){if(null!==e)return e in i&&i[e]instanceof this;for(var r in i)if(i[r]instanceof this)return!0}return!1},add(t,e,n,i={}){var r;if(n)return(r=Uu.get(t,n))&&r.remove(),(r=new this(i)).id=n,this._addRef(t,n,r),r.requestUpdate(t,e),r.listenToUpdateAttributes(t),r;throw new Error("dia.HighlighterView: An ID required.")},_addRef(t,e,n){var t=t.cid,i=this._views;let r=i[t];(r=r||(i[t]={}))[e]=n},_removeRef(t,e){var t=t.cid,n=this._views,i=n[t];if(i){for(var r in e&&delete i[e],i)return;delete n[t]}},remove(t,e=null){Gu(this.get(t,e)).forEach(t=>{t.remove()})},getAll(t,e=null){var n,i=[],r=this._views;for(n in r)for(var o in r[n]){var s=r[n][o];s.cellView.paper===t&&s instanceof this&&(null===e||o===e)&&i.push(s)}return i},removeAll(t,e=null){this.getAll(t,e).forEach(t=>t.remove())},update(t,e=null,n=!1){Gu(this.get(t,e)).forEach(t=>{(n||t.UPDATABLE)&&t.update()})},transform(t,e=null){Gu(this.get(t,e)).forEach(t=>{t.UPDATABLE&&t.transform()})},unmount(t,e=null){Gu(this.get(t,e)).forEach(t=>t.unmount())},mount(t,e=null){Gu(this.get(t,e)).forEach(t=>t.mount())},uniqueId(t,e=""){return R.ensureId(t)+JSON.stringify(e)}}),Hu=(r=Uu.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){var n=this.options,i=n.useFirstSubpath;let r;try{var o,s=R(e);r=s.convertToPathData().trim(),"PATH"===s.tagName()&&i&&0<(o=r.search(/.M/i)+1)&&(r=r.substr(0,o))}catch{s=t.getNodeBoundingRect(e);r=R.rectToPath(E({},n,s.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){var n,i,r,{vel:o,options:s}=this,{padding:s,layer:a}=s;let l=this.getNodeMatrix(t,e);s&&(a||e!==t.el||o.remove(),n=(a=t.getNodeBoundingRect(e)).x+a.width/2,i=a.y+a.height/2,a=R.transformRect(a,l),r=((r=Math.max(a.width,1))+s)/r,s=((a=Math.max(a.height,1))+s)/a,a=R.createSVGMatrix({a:r,b:0,c:0,d:s,e:n-r*n,f:i-s*i}),l=l.multiply(a)),o.attr({d:this.getPathData(t,e),transform:R.matrixToTransformString(l)})},highlight(t,e){var{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)}}),u=Uu.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:20,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(e,n){var{MASK_CHILD_ATTRIBUTE_BLACKLIST:t,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=n.tagName();if(!R.isSVGGraphicsElement(n)||r.includes(o))return n.remove(),!1;if(i.includes(o)){r=e.vel.findOne("#"+n.id);if(r){i=r.node;let t=e.getNodeBoundingRect(i);e.model.isElement()&&(t=R.transformRect(t,e.getNodeMatrix(i)));var o=R("rect",t.toJSON()),{x:e,y:i}=t.center(),{angle:r,cx:e=e,cy:i=i}=r.rotate();r&&o.rotate(r,e,i),n.parent().append(o)}return n.remove(),!1}return t.forEach(t=>{"fill"===t&&"none"===n.attr("fill")||n.removeAttr(t)}),!0},transformMaskRoot(t,e){var n=this.MASK_ROOT_ATTRIBUTE_BLACKLIST;n.forEach(t=>{e.removeAttr(t)})},getMaskShape(e,t){var{options:n,MASK_REPLACE_TAGS:i}=this,n=n.deep,r=t.tagName();let o;if("G"===r){if(!n)return null;for(var n=o=t.clone(),s=t=>this.transformMaskChild(e,t),a=n.children();0<a.length;){var l=a.shift();s(l)&&a.push(...l.children())}}else{if(i.includes(r))return null;o=t.clone()}return this.transformMaskRoot(e,o),o},getMaskId(){return"highlight-mask-"+this.cid},getMask(t,e){var{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:r,attrs:o}=r,s=parseFloat(R("g").attr(o).attr("stroke-width")),a="none"!==e.attr("fill");let l=parseFloat(e.attr("stroke-width"));r=(l=isNaN(l)?1:l)+2*r,s=r+2*s;let h=this.getMaskShape(t,e);return h||((t=t.getNodeBoundingRect(e.node)).inflate(t.width?0:.5,t.height?0:.5),h=R("rect",t.toJSON())),h.attr(o),R("mask",{id:this.getMaskId()}).append([h.clone().attr({fill:a?n:"none",stroke:n,"stroke-width":s}),h.clone().attr({fill:a?i:"none",stroke:i,"stroke-width":r})])},removeMask(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){var{options:n,vel:i}=this,{padding:n,attrs:r,maskClip:o=20,layer:s}=n,r="stroke"in r?r.stroke:"#000000",s=(s||e!==t.el||i.remove(),t.getNodeBoundingRect(e).inflate(n+o)),n=this.getNodeMatrix(t,e),o=this.getMask(t,R(e));this.addMask(t.paper,o),i.attr(s.toJSON()),i.attr({transform:R.matrixToTransformString(n),mask:`url(#${o.id})`,fill:r})},unhighlight(t){this.removeMask(t.paper)}}),i=Uu.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){var{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),s=al("highlighted"),o=Uu.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:s},highlight:function(t,e){R(e).addClass(this.options.className)},unhighlight:function(t,e){R(e).removeClass(this.options.className)}},{className:s}),{ROW:"row",COLUMN:"column"});function qu(t,e,n){var i,r,o;return y(n)&&({x:i,y:o}=n,isFinite(o)&&({start:o,end:r}=new P(e,t).parallel(o),e=o,t=r),n=i),!isFinite(n)||(o=t.distance(e),0===n&&0<o)?t:t.move(e,-Math.min(n,o-1))}function $u(t){t=t.getAttribute("stroke-width");return null!==t&&parseFloat(t)||0}function Wu(t,e,n,i){e=i.useModelGeometry?Yu(e,n,!0):e.getNodeBBox(n),i.stroke&&e.inflate($u(n)/2),n=t.intersect(e);return qu(n?t.start.chooseClosest(n):t.end,t.start,i.offset)}function Yu(t,e,n){var i=t.model,t=t.findAttribute("port",e);return i.hasPort(t)?i.getPortBBox(t,{rotate:n}):i.getBBox({rotate:n})}Ke={__proto__:null,addClass:o,list:Uu.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){t=t.model;let{attribute:r,size:n=20,gap:o=5,direction:i=Hu.ROW}=this.options;if(!r)throw new Error("List: attribute is required");let s="number"==typeof n?{width:n,height:n}:n,a=i===Hu.ROW,l=a?s.width:s.height,h=t.get(r),u=(Array.isArray(h)||(h=[]),this._prevItems||[]),c=h.map((t,e)=>na(u[e],h[e]));if(u.length!==h.length||c.some(t=>!t)){let i=this.vel.children();var d=h.map((t,e)=>{var n=e in i?i[e].node:null;if(c[e])return n;t=this.createListItem(t,s,n);if(!t)return null;if(!(t instanceof SVGElement))throw new Error("List: item must be an SVGElement");t.dataset.index=e,t.dataset.attribute=r;n=e*(l+o);return t.setAttribute("transform",a?`translate(${n}, 0)`:`translate(0, ${n})`),t});this.vel.empty().append(d),this._prevItems=h}d=h.length,d=0===d?0:d*l+(d-1)*o,d=a?{width:d,height:s.height}:{width:s.width,height:d};this.position(t,d)},position(t,e){var{vel:n,options:i}=this,{margin:i=5,position:r="top-left"}=i,{width:t,height:o}=t.size(),{left:i,right:s,top:a,bottom:l}=Ol(i);let{x:h,y:u}=Ih(new tt(i,a,t-(i+s),o-(a+l)),r);switch(r){case d.CENTER:case d.TOP:case d.BOTTOM:h-=e.width/2;break;case d.RIGHT:case d.BOTTOM_RIGHT:case d.TOP_RIGHT:h-=e.width}switch(r){case d.CENTER:case d.RIGHT:case d.LEFT:u-=e.height/2;break;case d.BOTTOM:case d.BOTTOM_RIGHT:case d.BOTTOM_LEFT:u-=e.height}n.attr("transform",`translate(${h}, ${u})`)}},{Directions:Hu,Positions:d}),mask:u,opacity:i,stroke:r};var Xu="segmentSubdivisons",Zu="shapeBBox";function Ju(t,e){return 0===e?"0%":Math.round(t/e*100*1e3)/1e3+"%"}function Ku(r){return function(t,e,n,i){return(e.isNodeConnection(n)?tc:Qu)(r,t,e,n,i)}}function Qu(t,e,n,i,r){var o=n.model.angle(),i=n.getNodeUnrotatedBBox(i),n=n.model.getCenter(),n=(r.rotate(n,o),r.x-i.x),o=r.y-i.y;return t&&(n=Ju(n,i.width),o=Ju(o,i.height)),e.anchor={name:"topLeft",args:{dx:n,dy:o,rotate:!0}},e}function tc(t,e,n,i,r){n=n.getConnection();return n&&(r=n.closestPointLength(r),t?(t=n.length(),e.anchor={name:"connectionRatio",args:{ratio:r/t}}):e.anchor={name:"connectionLength",args:{length:r}}),e}h=Ku(!(Je={__proto__:null,anchor:function(t,e,n,i){var{offset:i,alignOffset:r,align:o}=i;return o&&((t,e,n=0)=>{let i,r,o,s;var{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,o,r),qu(t.end,t.start,i)},bbox:Wu,boundary:function(t,e,n,i){var r=i.selector,o=t.end,r="string"==typeof r?e.findNode(r):!1===r?n:Array.isArray(r)?pl(n,r):(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);if(!R.isSVGGraphicsElement(r)){if(r===n||!R.isSVGGraphicsElement(n))return o;r=n}var s,n=e.getNodeShape(r),a=e.getNodeMatrix(r),l=e.getRootTranslateMatrix(),h=e.getRootRotateMatrix(),h=(l=l.multiply(h).multiply(a)).inverse(),h=(a=R.transformLine(t,h)).start.clone(),e=e.getNodeData(r);return!1===i.insideout&&(e[Zu]||(e[Zu]=n.bbox()),e[Zu].containsPoint(h))?o:(n instanceof I&&(s=i.precision||2,e[Xu]||(e[Xu]=n.getSegmentSubdivisions({precision:s})),s={precision:s,segmentSubdivisions:e[Xu]}),!0===i.extrapolate&&a.setLength(1e6),(e=a.intersect(n,s))?R.isArray(e)&&(e=h.chooseClosest(e)):!0===i.sticky&&(e=n instanceof tt?n.pointNearestToPoint(h):n instanceof vi?n.intersectionWithLineFromCenterToPoint(h):n.closestPoint(h,s)),a=e?R.transformPoint(e,l):o,n=i.offset||0,i.stroke&&(n+=$u(r)/2),qu(a,t.start,n))},rectangle:function(t,e,n,i){var r,o=e.model.angle();return 0===o?Wu(t,e,n,i):(e=i.useModelGeometry?Yu(e,n,!1):e.getNodeUnrotatedBBox(n),i.stroke&&e.inflate($u(n)/2),n=e.center(),qu((e=(r=t.clone().rotate(n,o)).setLength(1e6).intersect(e))?r.start.chooseClosest(e).rotate(n,-o):t.end,t.start,i.offset))}}));let ec=Ku(!0),nc={__proto__:null,pinAbsolute:h,pinRelative:ec,useDefaults:Dl};var ic={N:"S",S:"N",E:"W",W:"E"},rc={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function oc(t,e,n){var i=new A(t.x,e.y);return i=n.containsPoint(i)?new A(e.x,t.y):i}function sc(t,e){return t["W"===e||"E"===e?"width":"height"]}function ac(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 lc(t){return new tt(t.x,t.y,0,0)}function hc(t){t=Ol(t.padding||t.elementPadding||20);return{x:-t.left,y:-t.top,width:t.left+t.right,height:t.top+t.bottom}}function uc(t,e){return t.sourceBBox.clone().moveAndExpand(hc(e))}function cc(t,e){return t.targetBBox.clone().moveAndExpand(hc(e))}function dc(t,e,n){var i=new A(t.x,e.y),r=new A(e.x,t.y),o=ac(t,i),t=ac(t,r),s=ic[n],o=o===n||o!==s&&(t===s||t!==n)?i:r;return{points:[o],direction:ac(o,e)}}function fc(t,e,n){t=oc(t,e,n);return{points:[t],direction:ac(t,e)}}function pc(t,e,n,i,r){var o={},n=n.union(i).inflate(1),i=n.center().distance(e)>n.center().distance(t),s=i?e:t,t=i?t:e,a=r?(a=A.fromPolar(n.width+n.height,rc[r],s),n.pointNearestToPoint(a).move(a,-1)):n.pointNearestToPoint(s).move(s,1),r=oc(a,t,n);return a.round().equals(r.round())?(r=A.fromPolar(n.width+n.height,Zn(a.theta(s))+Math.PI/2,t),s=oc(a,r=n.pointNearestToPoint(r).move(t,1).round(),n),o.points=i?[r,s,a]:[a,s,r]):o.points=i?[r,a]:[a,r],o.direction=ac(i?a:r,e),o}function gc(t,e,n){var i,r,o=uc(n,e),s=cc(n,e),a=(i=e,(a=n).sourceAnchor||uc(a,i).center()),n=(i=e,(n=n).targetAnchor||cc(n,i).center()),o=o.union(lc(a)),s=s.union(lc(n));(t=et(t).map(A)).unshift(a),t.push(n);for(var l,h,u,c,d,f,p=[],g=0,m=t.length-1;g<m;g++){var v,y=null,b=t[g],w=t[g+1],x=!!ac(b,w);0===g?g+1===m?o.intersect(s.clone().inflate(1))?y=pc(b,w,o,s):x||(h=o,f=d=c=void 0,d=fc(v=w,l=b,u=s),f=d.points[0],h.containsPoint(f)&&(c=(d=fc(l,v,h)).points[0],u.containsPoint(c))&&(c=new A(l).move(c,-sc(h,ac(l,c))/2),u=new A(v).move(f,-sc(u,ac(v,f))/2),u=dc(f=new P(c,u).midpoint(),v,(c=fc(l,f,h)).direction),d.points=[c.points[0],u.points[0]],d.direction=u.direction),y=d):o.containsPoint(w)?y=pc(b,w,o,lc(w).moveAndExpand(hc(e))):x||(y=fc(b,w,o)):g+1===m?(v=x&&ac(w,b)===r,s.containsPoint(b)||v?y=pc(b,w,lc(b).moveAndExpand(hc(e)),s,r):x||(y=((e,t,n,i)=>{var r,o={},s=[new A(e.x,t.y),new A(t.x,e.y)],a=s.filter(function(t){return!n.containsPoint(t)}),l=a.filter(function(t){return ac(t,e)!==i});return 0<l.length?(r=(r=l.filter(function(t){return ac(e,t)===i}).pop())||l[0],o.points=[r],o.direction=ac(r,t)):(r=la(s,a)[0],s=oc(l=new A(t).move(r,-sc(n,i)/2),e,n),o.points=[s,l],o.direction=ac(l,t)),o})(b,w,s,r))):x||(y=dc(b,w,r)),r=y?(Array.prototype.push.apply(p,y.points),y.direction):ac(b,w),g+1<m&&p.push(w)}return p}var mc={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(b(gc))return gc(t,E({},mc,e),n);throw new Error("Manhattan requires the orthogonal router as default fallback.")},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function vc(t){this.map={},this.options=t,this.mapGridSize=100}function yc(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function bc(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function wc(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function xc(t,e){return t.sourceAnchor||bc(t,e).center()}function Ac(t,e,n,i,r){var o,n=360/n,i=t.theta((t=t,e=e,r=(r=r).step,o=e.x-t.x,e=e.y-t.y,o=o/i.x*r,e=e/i.y*r,new A(t.x+o,t.y+e))),r=Yn(i+n/2);return n*Math.floor(r/n)}function Pc(t,e){t=Math.abs(t-e);return 180<t?360-t:t}function Tc(t,e){var n;return t?(t=Math.abs(t),(n=Math.round(t/e))?e+(t-n*e)/n:t):e}function Ec(t,e){return t.round(e)}function Sc(t,e,n){return Ec((t=t.clone(),i=(e=e).source,r=Xn(t.x-i.x,e.x)+i.x,t=Xn(t.y-i.y,e.y)+i.y,new A(r,t)),n);var i,r}function _c(t){return t.clone().toString()}function Lc(t){return new A(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function kc(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 Cc(u,c,t,d,e){var f=e.precision,p=e.directionMap,g=u.difference(c.center()),e=x(p)?Object.keys(p):[],m=et(t),t=e.reduce(function(t,e){if(m.includes(e)){for(var n,e=p[e],i=new A(u.x+e.x*(Math.abs(g.x)+c.width),u.y+e.y*(Math.abs(g.y)+c.height)),r=new P(u,i).intersect(c)||[],o=r.length,s=null,a=0;a<o;a++){var l=r[a],h=u.squaredDistance(l);(void 0===n||n<h)&&(n=h,s=l)}s&&(i=Sc(s,d,f),c.containsPoint(i)&&(i=Sc(i.offset(e.x*d.x,e.y*d.y),d,f)),t.push(i))}return t},[]);return c.containsPoint(u)||t.push(Sc(u,d,f)),t}function Mc(t,e,n,i){var r,o,s,a,l,h,u,c=i.precision,d=t instanceof tt?Ec(xc(this,i).clone(),c):Ec(t.clone(),c),f=e instanceof tt?Ec((r=i,((f=this).targetAnchor||wc(f,r).center()).clone()),c):Ec(e.clone(),c),p=(r=i.step,h=f,{source:(o=d).clone(),x:Tc(h.x-o.x,r),y:Tc(h.y-o.y,r)}),g=t instanceof tt?Cc(s=d,t,i.startDirections,p,i):[s=d],m=e instanceof tt?Cc(a=f,e,i.endDirections,p,i):[a=f];if(g=g.filter(t=>!n(t)),m=m.filter(t=>!n(t)),0<g.length&&0<m.length){for(var v=new yc,y={},b={},w={},x=0,I=g.length;x<I;x++){var A=g[x],P=_c(A);v.add(P,kc(A,m)),y[P]=A,w[P]=0}for(var F=i.previousDirectionAngle,B=void 0===F,D=i.directions,T=(l=p,u=(h=i).step,et(h.directions).forEach(function(t){t.gridOffsetX=t.offsetX/u*l.x,t.gridOffsetY=t.offsetY/u*l.y}),D.length),z=et(m).reduce(function(t,e){e=_c(e);return t.push(e),t},[]),j=i.maximumLoops;!v.isEmpty()&&0<j;){var E=v.pop(),S=y[E],_=b[E],G=w[E],L=void 0===_,U=S.equals(s),H=L?B?U?null:Ac(s,S,T,p,i):F:Ac(_,S,T,p,i),q=g.length===m.length;if(q)for(var k=0;k<g.length;k++)if(!g[k].equals(m[k])){q=!1;break}if(!(L&&q)&&0<=z.indexOf(E)){i.previousDirectionAngle=H;for(var $=b,W=y,_=S,L=s,E=a,Y=[],X=Lc(E.difference(_)),C=_c(_),M=$[C];M;){var Z,J=Lc((Z=W[C]).difference(M));J.equals(X)||(Y.unshift(Z),X=J),M=$[C=_c(M)]}return Lc((E=W[C]).difference(L)).equals(X)||Y.unshift(E),Y}for(x=0;x<T;x++){var N,K=(N=D[x]).angle,Q=Pc(H,K);if(B&&U||!(Q>i.maxAllowedDirectionChange)){var O=Sc(S.clone().offset(N.gridOffsetX,N.gridOffsetY),p,c),R=_c(O);if(!v.isClose(R)&&!n(O)){if(0<=z.indexOf(R)){var V=O.equals(a);if(!V)if(Pc(K,Ac(O,a,T,p,i))>i.maxAllowedDirectionChange)continue}V=G+N.cost+(U?0:i.penalties[Q]);(!v.isOpen(R)||V<w[R])&&(y[R]=O,b[R]=S,v.add(R,(w[R]=V)+kc(O,m)))}}}j--}}return i.fallbackRoute.call(this,s,a,i)}function Nc(t,n,i){(e=n).directions=S(e,"directions"),e.penalties=S(e,"penalties"),e.paddingBox=S(e,"paddingBox"),e.padding=S(e,"padding"),e.padding&&(r=Ol(e.padding),e.paddingBox={x:-r.left,y:-r.top,width:r.left+r.right,height:r.top+r.bottom}),et(e.directions).forEach(function(t){var e=new A(0,0),n=new A(t.offsetX,t.offsetY);t.angle=Yn(e.theta(n))}),i.options.perpendicular=!!n.perpendicular;var e,r,o=bc(i,n),s=wc(i,n),a=xc(i,n);let l;if("function"==typeof n.isPointObstacle)l=n.isPointObstacle;else{let e=new vc(n);e.build(i.paper.model,i.model),l=t=>!e.isPointAccessible(t)}for(var h=et(t).map(A),u=[],c=a,d=0,f=h.length;d<=f;d++){var p,g,m=null,v=p||o;if((p=h[d])||(p=s,i.model.get("source").id&&i.model.get("target").id)||!b(n.draggingRoute)||(y=v===o?a:v,g=p.origin(),m=n.draggingRoute.call(i,y,g,n)),null===(m=m||Mc.call(i,v,p,l,n)))return n.fallbackRouter(t,n,i);var y=m[0];y&&y.equals(c)&&m.shift(),c=m[m.length-1]||c,Array.prototype.push.apply(u,m)}return u}function Oc(t,e,n){return Nc(t,E({},mc,e),n)}vc.prototype.build=function(n,i){var c=this.options,d=et(c.excludeEnds).reduce(function(t,e){var e=i.get(e);return e&&(e=n.getCell(e.id))&&t.push(e),t},[]),f=[],t=n.getCell(i.get("source").id),t=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),n.getCell(i.get("target").id)),p=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),this.mapGridSize);return n.getElements().reduce(function(t,e){var n=et(c.excludeTypes).includes(e.get("type")),i=d.find(function(t){return t.id===e.id}),r=f.includes(e.id);if(!(n||i||r))for(var o=e.getBBox().moveAndExpand(c.paddingBox),s=o.origin().snapToGrid(p),a=o.corner().snapToGrid(p),l=s.x;l<=a.x;l+=p)for(var h=s.y;h<=a.y;h+=p){var u=l+"@"+h;t[u]=t[u]||[],t[u].push(o)}return t},this.map),this},vc.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return et(this.map[t]).every(function(t){return!t.containsPoint(e)})},yc.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;e=Js(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(e,0,t)},yc.prototype.remove=function(t){this.hash[t]=this.CLOSE},yc.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},yc.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},yc.prototype.isEmpty=function(){return 0===this.items.length},yc.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};var Rc={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},a=(90<i%180&&(a=o,o=s,s=a),i%90<45?o:s),o=new P(t,a),s=90*Math.ceil(i/90),i=A.fromPolar(o.squaredLength(),Zn(135+s),a),s=new P(e,i),a=o.intersection(s),i=a||e,o=a?i:t,s=360/n.directions.length,a=o.theta(e),t=Yn(a+s/2),o=s*Math.floor(t/s);return n.previousDirectionAngle=o,i&&r.push(i.round()),r.push(e),r}};let B={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Vc=[B.LEFT,B.RIGHT,B.TOP,B.BOTTOM],Ic={[B.LEFT]:B.RIGHT,[B.RIGHT]:B.LEFT,[B.TOP]:B.BOTTOM,[B.BOTTOM]:B.TOP},Fc=[B.TOP,B.BOTTOM],Bc={0:B.RIGHT,180:B.LEFT,270:B.TOP,90:B.BOTTOM};function Dc(t){return t.angle()}function zc(t){return new w(t).simplify({threshold:1}).points}function jc(t,e){var{point:t,x0:n,y0:i,view:r,bbox:o,direction:s}=t,{point:e,x0:a,y0:l,view:h,bbox:u,direction:c}=e;let d;d=r?r.model.isLink()?Uc(e,t,r):s===B.ANCHOR_SIDE?o.sideNearestToPoint(t):s===B.MAGNET_SIDE?r.model.getBBox().sideNearestToPoint(t):s:(o=new tt(n,i,0,0),Vc.includes(s)?s:o.sideNearestToPoint(e));let f;return f=h?h.model.isLink()?Uc(t,e,h):c===B.ANCHOR_SIDE?u.sideNearestToPoint(e):c===B.MAGNET_SIDE?h.model.getBBox().sideNearestToPoint(e):c:(r=new tt(a,l,0,0),Vc.includes(c)?c:r.sideNearestToPoint(t)),[d,f]}function Gc(t,e,n){var[i]=jc(t,e);switch(i){case B.TOP:var r=e,o=n,{x0:s,y0:a,width:l,height:h,point:u,margin:c}=s=t,h=a+h,d=s-c,s=s+l+c,l=a-c,c=u.x,{x0:u,y0:r}=r;return u===c&&r<a?B.BOTTOM:u<c&&r<l?o.point.x===c?B.BOTTOM:B.RIGHT:c<u&&r<l?o.point.x===c?B.BOTTOM:B.LEFT:u<d&&l<r||s<u&&l<r?B.TOP:d<=u&&u<=c&&h<r||u<=s&&c<=u&&h<r?o.point.x<u?B.RIGHT:B.LEFT:B.BOTTOM;case B.RIGHT:var a=e,l=n,{y0:d,x0:s,width:c,height:h,point:r,margin:o}=d=t,c=s+c+o,u=d-o,d=d+h+o,{x:h,y:o}=r,{x0:r,y0:a}=a;return h<r&&a===o?B.LEFT:c<=r&&a<o?B.BOTTOM:c<=r&&o<a?B.TOP:r<=c&&a<u||r<=c&&d<a?B.RIGHT:r<s&&u<=a&&a<=o||r<s&&a<=d&&o<=a?l.point.y<a?B.BOTTOM:B.TOP:B.LEFT;case B.BOTTOM:var f=e,p=n,{x0:g,y0:m,width:v,height:y,point:b,margin:w}=g=t,x=g-w,g=g+v+w,v=(y=m+y)+w,w=b.x,{x0:b,y0:f}=f;return b===w&&y<f?B.TOP:b<w&&v<f?p.point.x===w?B.TOP:B.RIGHT:w<b&&v<f?p.point.x===w?B.TOP:B.LEFT:b<x&&f<v||g<b&&f<v?B.BOTTOM:x<=b&&b<=w&&f<m||b<=g&&w<=b&&f<m?p.point.x<b?B.RIGHT:B.LEFT:B.TOP;case B.LEFT:var y=e,v=n,{y0:x,x0:g,width:w,height:f,point:m,margin:p}=x=t,w=g+w,g=g-p,b=x-p,x=x+f+p,{x:f,y:p}=m,{x0:m,y0:y}=y;return m<f&&y===p?B.RIGHT:m<=g&&y<p?B.BOTTOM:m<=g&&p<y?B.TOP:g<=m&&y<b||g<=m&&x<y?B.LEFT:w<m&&b<=y&&y<=p||w<m&&y<=x&&p<=y?v.point.y<y?B.BOTTOM:B.TOP:B.RIGHT}}function Uc(t,e,n){n=n.getTangentAtLength(n.getClosestPointLength(e)),n=90*Math.round(Dc(n)/90);if(n%180==0&&t.y===e.y)return t.x<e.x?B.LEFT:B.RIGHT;if(t.x===e.x)return t.y<e.y?B.TOP:B.BOTTOM;switch(n){case 0:case 180:case 360:return t.y<e.y?B.TOP:B.BOTTOM;case 90:case 270:return t.x<e.x?B.LEFT:B.RIGHT}}function Hc(t,e,n,i,r,o,s){i===B.AUTO&&(i=r?B.MAGNET_SIDE:B.ANCHOR_SIDE);var r=t&&t.model.isElement(),{x:o,y:a,width:l=0,height:h=0}=r?tt.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:o,y0:a,view:t,bbox:n,width:l,height:h,direction:i,margin:r?s:0}}function qc(t,e,n){var 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 $c(t,e,{dx:n=0,dy:i=0}){var r={x:t.point.x+n,y:t.point.y+i},n={x:e.point.x+n,y:e.point.y+i};return[t.point,r,n,e.point]}function Wc(t,e,n,i){n=Yn(n-90);let r=0,o=0;90===n?o=-i:180===n?r=-i:270===n?o=i:0===n&&(r=i);n=$c(t,e,{dx:r,dy:o}),i=n[2],t=new P(e.point,i);return{loopRoute:n,continueDirection:Bc[Dc(t)]}}function Yc(t,e,n){switch(e){case B.LEFT:t.inflate(0,n).moveAndExpand({x:-n,width:n});break;case B.RIGHT:t.inflate(0,n).moveAndExpand({width:n});break;case B.TOP:t.inflate(n,0).moveAndExpand({y:-n,height:n});break;case B.BOTTOM:t.inflate(n,0).moveAndExpand({height:n})}return t}function Xc(i,r,e={}){var{point:o,x0:s,y0:a,width:l,height:n,margin:t}=i,{point:I,x0:h,y0:u,width:c,height:d,margin:f}=r,{targetInSourceBBox:e=!1}=e,p=h+c,g=u+d,m=s+l,v=a+n,y=s-t,b=m+t,w=a-t,x=v+t,A=h-f,P=p+f,T=u-f,E=g+f,[S,_]=jc(i,r),o=qc(S,{point:o,x0:s,y0:a,width:l,height:n},t),L=qc(_,{point:I,x0:h,y0:u,width:c,height:d},f),{x:k,y:C}=o,{x:M,y:N}=L,O=((s+m)/2<(h+p)/2?m+h:p+s)/2,F=((a+v)/2<(u+g)/2?v+u:g+a)/2,l=new tt(s,a,l,n),n=new tt(h,u,c,d),c=l.clone().inflate(t),d=n.clone().inflate(f),l=Object.assign({},i,{x1:m,y1:v,outsidePoint:o,direction:S}),f=Object.assign({},r,{x1:p,y1:g,outsidePoint:L,direction:_}),[i,r]=((t,e)=>{var{x0:n,x1:i,outsidePoint:r}=t,{x0:o,x1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.y0<e.y0?t:e)===t?e:t,i=t.direction===B.TOP?n:o,l=i.x0,h=i.x1),s=r.x,e=a.x,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f),[l,f]=((t,e)=>{var{y0:n,y1:i,outsidePoint:r}=t,{y0:o,y1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.x0<e.x0?t:e)===t?e:t,i=t.direction===B.LEFT?n:o,l=i.y0,h=i.y1),s=r.y,e=a.y,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f);if("left"===S&&"right"===_){var R=c.containsPoint(L),V=d.containsPoint(o);if(R||V)return[{x:k,y:C},{x:k,y:R=(C+N)/2},{x:M,y:R},{x:M,y:N}];if(y<M){let t=F,e=k,n=M;var V=l<f;return(t>=w&&t<=x||t>=T&&t<=E)&&(T<=x&&V?t=Math.min(T,w):w<=E&&!V&&(t=Math.max(E,x)),e=Math.min(k,A),n=Math.max(M,b),V&&C<u||!V&&g<C?e=k:(V&&N<a||!V&&v<N)&&(n=M)),[{x:e,y:C},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var R=(k+M)/2;return[{x:R,y:C},{x:R,y:N}]}if("right"===S&&"left"===_){var V=c.containsPoint(L),R=d.containsPoint(o);if(V||R)return[{x:k,y:C},{x:k,y:V=(C+N)/2},{x:M,y:V},{x:M,y:N}];if(M<b){let t=F,e=k,n=M;var R=l<f;return(t>=w&&t<=x||t>=T&&t<=E)&&(T<=x&&R?t=Math.min(T,w):w<=E&&!R&&(t=Math.max(E,x)),e=Math.max(k,P),n=Math.min(M,y),R&&C<u||!R&&g<C?e=k:(R&&N<a||!R&&v<N)&&(n=M)),[{x:e,y:C},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var V=(k+M)/2;return[{x:V,y:C},{x:V,y:N}]}if("top"===S&&"bottom"===_){var R=c.containsPoint(L),V=d.containsPoint(o);if(R||V)return[{x:k,y:C},{x:R=(k+M)/2,y:C},{x:R,y:N},{x:M,y:N}];if(w<N){let t=O,e=C,n=N;V=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&V?t=Math.min(A,y):y<=P&&!V&&(t=Math.max(P,b)),e=Math.min(C,T),n=Math.max(N,x),V&&k<h||!V&&p<k?e=C:(V&&M<s||!V&&m<M)&&(n=N)),[{x:k,y:e},{x:t,y:e},{x:t,y:n},{x:M,y:n}]}R=(C+N)/2;return[{x:k,y:R},{x:M,y:R}]}if("bottom"===S&&"top"===_){V=c.containsPoint(L),R=d.containsPoint(o);if(V||R)return[{x:k,y:C},{x:L=(k+M)/2,y:C},{x:L,y:N},{x:M,y:N}];if(N<x){let t=O,e=C,n=N;var o=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&o?t=Math.min(A,y):y<=P&&!o&&(t=Math.max(P,b)),e=Math.max(C,E),n=Math.min(N,w),o&&k<h||!o&&p<k?e=C:(o&&M<s||!o&&m<M)&&(n=N)),[{x:k,y:e},{x:t,y:e},{x:t,y:n},{x:M,y:n}]}V=(C+N)/2;return[{x:k,y:V},{x:M,y:V}]}if("top"===S&&"top"===_){if((e||vr.rectWithRect(c,n)||C<=u&&(c.bottomRight().x<=M||c.bottomLeft().x>=M)||u<=C&&(d.bottomRight().x<=k||d.bottomLeft().x>=k))&&k!==M)return[{x:k,y:Math.min(C,N)},{x:M,y:Math.min(C,N)}];let t;var R=Math.min((v+u)/2,N),L=Math.min((a+g)/2,C);return[{x:k,y:L},{x:t=N<C?i<r?Math.min(k,A):Math.max(k,P):i<r?Math.min(M,y):Math.max(M,b),y:L},{x:t,y:R},{x:M,y:R}]}if("bottom"===S&&"bottom"===_){if((e||vr.rectWithRect(c,n)||N<=C&&(c.topRight().x<=M||c.topLeft().x>=M)||C<=N&&(d.topRight().x<=k||d.topLeft().x>=k))&&k!==M)return[{x:k,y:Math.max(C,N)},{x:M,y:Math.max(C,N)}];let t;o=Math.max((a+g)/2,N),V=Math.max((v+u)/2,C);return[{x:k,y:V},{x:t=C<N?i<r?Math.min(k,A):Math.max(k,P):i<r?Math.min(M,y):Math.max(M,b),y:V},{x:t,y:o},{x:M,y:o}]}if("left"===S&&"left"===_){if((e||vr.rectWithRect(c,n)||k<=M&&(c.bottomRight().y<=N||c.topRight().y>=N)||M<=k&&(d.bottomRight().y<=C||d.topRight().y>=C))&&C!==N)return[{x:Math.min(k,M),y:C},{x:Math.min(k,M),y:N}];let t;L=Math.min((m+h)/2,M),R=Math.min((s+p)/2,k);return[{x:R,y:C},{x:R,y:t=k<M?l<=f?Math.min(w,N):Math.max(x,N):l<=f?Math.min(T,C):Math.max(E,C)},{x:L,y:t},{x:L,y:N}]}if("right"===S&&"right"===_){if((e||vr.rectWithRect(c,n)||M<=k&&(c.bottomLeft().y<=N||c.topLeft().y>=N)||k<=M&&(d.bottomLeft().y<=C||d.topLeft().y>=C))&&C!==N)return[{x:Math.max(k,M),y:C},{x:Math.max(k,M),y:N}];let t;var i=Math.max((s+p)/2,M),r=Math.max((m+h)/2,k);return[{x:r,y:C},{x:r,y:t=M<=k?l<=f?Math.min(w,N):Math.max(x,N):l<=f?Math.min(T,C):Math.max(E,C)},{x:i,y:t},{x:i,y:N}]}if("top"===S&&"right"===_){if(c.containsPoint(I))return k<=P?(V=Math.max(k+t,M),[{x:k,y:o=Math.min(w,T)},{x:V,y:o},{x:V,y:N}]):[{x:k,y:C},{x:R=(k-t+M)/2,y:C},{x:R,y:N}];if(N<w){if(k<M){let t=E<=w&&k<=P?F:T;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}L=Math.max(O,P);return M<k&&N<=v?[{x:k,y:C},{x:L,y:C},{x:L,y:N}]:y<L&&C<g?[{x:k,y:e=Math.min(w,T)},{x:n=Math.max(b,P),y:e},{x:n,y:N}]:[{x:k,y:C},{x:L,y:C},{x:L,y:N}]}if("top"===S&&"left"===_){if(c.containsPoint(I))return A<=k?(d=Math.min(k-t,M),[{x:k,y:r=Math.min(w,T)},{x:d,y:r},{x:d,y:N}]):[{x:k,y:C},{x:l=(k+t+M)/2,y:C},{x:l,y:N}];if(N<w){if(M<k){let t=E<=w&&A<=k?F:T;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}f=Math.min(A,O);return k<M&&N<=v?[{x:k,y:C},{x:f,y:C},{x:f,y:N}]:f<b&&C<g?[{x:k,y:i=Math.min(w,T)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:k,y:C},{x:f,y:C},{x:f,y:N}]}if("bottom"===S&&"right"===_){if(c.containsPoint(I))return k<=P?(V=Math.max(k+t,M),[{x:k,y:R=Math.max(x,E)},{x:V,y:R},{x:V,y:N}]):[{x:k,y:C},{x:e=(k-t+M)/2,y:C},{x:e,y:N}];if(x<N){if(k<M){let t=x<=T&&k<=P?F:E;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}n=Math.max(O,P);return M<k&&a<=N?[{x:k,y:C},{x:n,y:C},{x:n,y:N}]:y<n&&u<C?[{x:k,y:L=Math.max(x,E)},{x:r=Math.max(b,P),y:L},{x:r,y:N}]:[{x:k,y:C},{x:n,y:C},{x:n,y:N}]}if("bottom"===S&&"left"===_){if(c.containsPoint(I))return A<=k?(d=Math.min(k-t,M),[{x:k,y:l=Math.max(x,E)},{x:d,y:l},{x:d,y:N}]):[{x:k,y:C},{x:v=(k+t+M)/2,y:C},{x:v,y:N}];if(x<N){if(M<k){let t=x<=T&&A<=k?F:E;return[{x:k,y:t},{x:M,y:t},{x:M,y:N}]}return[{x:k,y:N}]}var g=Math.min(A,O);return k<M&&a<=N?[{x:k,y:C},{x:g,y:C},{x:g,y:N}]:g<b&&u<C?[{x:k,y:i=Math.max(x,E)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:k,y:C},{x:g,y:C},{x:g,y:N}]}if("left"===S&&"bottom"===_){if(c.containsPoint(I))return C<=E?[{x:f=Math.min(y,A),y:C},{x:f,y:R=Math.max(C+t,N)},{x:M,y:R}]:[{x:k,y:C},{x:k,y:V=(C-t+N)/2},{x:M,y:V}];if(M<y){if(C<N){let t=P<=y&&C<=E?O:A;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}e=Math.max(E,F);return N<C&&M<=m?[{x:k,y:C},{x:k,y:e},{x:M,y:e}]:w<e&&k<p?[{x:L=Math.min(y,A),y:C},{x:L,y:r=Math.max(x,E)},{x:M,y:r}]:[{x:k,y:C},{x:k,y:e},{x:M,y:e}]}if("left"===S&&"top"===_){if(c.containsPoint(I))return T<=C?(n=Math.min(C-t,N),[{x:l=Math.min(y,A),y:C},{x:l,y:n},{x:M,y:n}]):[{x:k,y:C},{x:k,y:d=(C+t+N)/2},{x:M,y:d}];if(M<y){if(N<C){let t=P<=y&&T<=C?O:A;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}v=Math.min(T,F);return C<N&&M<=m?[{x:k,y:C},{x:k,y:v},{x:M,y:v}]:v<x&&k<p?[{x:a=Math.min(y,A),y:C},{x:a,y:u=Math.min(w,T)},{x:M,y:u}]:[{x:k,y:C},{x:k,y:v},{x:M,y:v}]}if("right"===S&&"top"===_){if(c.containsPoint(I))return T<=C?[{x:i=Math.max(b,P),y:C},{x:i,y:o=Math.min(C-t,N)},{x:M,y:o}]:[{x:k,y:C},{x:k,y:g=(C+t+N)/2},{x:M,y:g}];if(b<M){if(N<C){let t=b<=A&&T<=C?O:P;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}f=Math.min(T,F);return C<N&&s<=M?[{x:k,y:C},{x:k,y:f},{x:M,y:f}]:f<x&&h<k?[{x:R=Math.max(b,P),y:C},{x:R,y:V=Math.min(w,T)},{x:M,y:V}]:[{x:k,y:C},{x:k,y:f},{x:M,y:f}]}if("right"===S&&"bottom"===_){if(c.containsPoint(I))return C<=E?[{x:L=Math.max(b,P),y:C},{x:L,y:r=Math.max(C+t,N)},{x:M,y:r}]:[{x:k,y:C},{x:k,y:e=(C-t+N)/2},{x:M,y:e}];if(b<M){if(C<N){let t=b<=A&&C<=E?O:P;return[{x:t,y:C},{x:t,y:N},{x:M,y:N}]}return[{x:M,y:C}]}l=Math.max(E,F);return N<C&&s<=M?[{x:k,y:C},{x:k,y:l},{x:M,y:l}]:w<l&&h<k?[{x:n=Math.max(b,P),y:C},{x:n,y:d=Math.max(x,E)},{x:M,y:d}]:[{x:k,y:C},{x:k,y:l},{x:M,y:l}]}}function Zc(t,e,n){var i=t===B.LEFT||t===B.RIGHT;let r=0,o=0;switch(Yn(Math.round(e))){case 0:case 90:r=i?0:n,o=i?n:0;break;case 180:case 270:r=i?0:-n,o=i?-n:0}return{dx:r,dy:o}}function Jc(n,i,r){var{sourceDirection:o=B.AUTO,targetDirection:s=B.AUTO}=i,a=i.margin||20,i=i.useVertices||!1,l=!!r.model.source().port,o=Hc(r.sourceView,r.sourceAnchor,r.sourceBBox,o,l,r.sourceAnchor,a),l=!!r.model.target().port,s=Hc(r.targetView,r.targetAnchor,r.targetBBox,s,l,r.targetAnchor,a),h=[];if(!i||0===n.length)return zc(Xc(o,s));var e=n.map(t=>{return{x:t,y:e}=[t][0],{point:n=new A(t,e),x0:n.x,y0:n.y,view:null,bbox:new tt(t,e,0,0),width:0,height:0,direction:null,margin:0};var e,n}),[l]=e,[r]=jc(o,l),i=o.view&&o.view.model.isElement(),n=i?Yc(o.view.model.getBBox(),r,a):null;let t=!!i&&n.containsPoint(l.point);t?(n=(i=qc(r,o,a)).equals(l.point),y=o.point.x===l.point.x,v=o.point.y===l.point.y,y=y&&(r===B.TOP||r===B.BOTTOM),v=v&&(r===B.LEFT||r===B.RIGHT),g=(m=new P(o.point,i)).containsPoint(l.point),v=t&&(v||y),n?(h.push(o.point,l.point),l.direction=Ic[r]):g||v?({dx:y,dy:n}=Zc(r,Dc(g?m:new P(o.point,l.point)),a),g=(v=$c({point:i},l,{dx:y,dy:n}))[2],m=new P(l.point,g),i=Bc[Dc(m)],l.direction=i,h.push(...v)):(l.direction=r,l.margin=a,h.push(...Xc(o,l,{targetInSourceBBox:!0}),l.point))):(y=Gc(o,l,e[1]||s),l.direction=y,h.push(...Xc(o,l),l.point));for(let t=0;t<e.length-1;t++){var u,c,d=e[t],f=e[t+1],p=Dc(new P(d.point,f.point));p%90==0?(c=Bc[p],u=zc([...h,d.point]),u=new P(u[u.length-2],u[u.length-1]),u=Bc[Math.round(Dc(u))],c!==Ic[u]?(h.push(d.point,f.point),[,c]=jc(d,f),f.direction=c):({loopRoute:u,continueDirection:c}=Wc(d,f,p,a),f.direction=c,h.push(...u))):([p,c]=Kc(d,f),d.direction=p,f.direction=c,h.push(...Xc(d,f),f.point))}n=e[e.length-1];if(s.view&&s.view.model.isElement()){var[,g]=jc(n,s),m=qc(g,s,a),i=zc([...h,n.point]),v=new P(i[i.length-2],i[i.length-1]),r=Math.round(Dc(v)),y=Bc[r],o=m.equals(n.point);if(!o||y===g){n.direction=y;let t=Xc(n,s);var[l,i]=zc([...t,s.point]),v=new P(l,i),l=Math.round(Dc(v)),i=Bc[l],v=Yc(s.view.model.getBBox(),g,a),l=n.point.x===s.point.x,b=n.point.y===s.point.y;let e=v.containsPoint(n.point);v=l&&(g===B.TOP||g===B.BOTTOM),l=b&&(g===B.LEFT||g===B.RIGHT);!o&&e&&(l||v)?({dx:b,dy:o}=Zc(g,r,a),t=$c(n,{point:m},{dx:b,dy:o})):e&&g!==Ic[y]?(n.margin=a,n.direction=g,t=Xc(n,s)):i!==y&&y===Ic[i]&&(n.margin=a,t=Xc(n,s)),h.push(...t)}}else{l=n,v=s,r=Dc(new P(l.point,v.point));r%90==0?(m=Bc[r],b=zc(h),o=new P(b[b.length-2],l.point),g=Bc[Math.round(Dc(o))],m!==Ic[g]?h.push(l.point):(y=Wc(l,v,r,a).loopRoute,y.pop(),h.push(...y))):([i,n]=Kc(l,v),l.direction=i,v.direction=n,h.push(...Xc(l,v)))}return zc(h)}function Kc(t,e){var n,i=t.direction,r=Fc.includes(i);let o=t.direction,s=e.direction;return r?(r=t.point.y>e.point.y,n=e.point.x-t.point.x,i===B.BOTTOM?(o=r?Ic[i]:0<=n?B.RIGHT:B.LEFT,0<n?s=r?B.LEFT:B.TOP:n<0&&(s=r?B.RIGHT:B.TOP)):(o=r?0<=n?B.RIGHT:B.LEFT:Ic[i],0<n?s=r?B.BOTTOM:B.LEFT:n<0&&(s=r?B.BOTTOM:B.RIGHT))):(n=t.point.x>e.point.x,r=e.point.y-t.point.y,i===B.RIGHT?(o=n?Ic[i]:0<=r?B.BOTTOM:B.TOP,0<r?s=n?B.TOP:B.LEFT:r<0&&(s=n?B.BOTTOM:B.LEFT)):(o=n?0<=r?B.BOTTOM:B.TOP:Ic[i],0<r?s=n?B.RIGHT:B.TOP:r<0&&(s=n?B.RIGHT:B.BOTTOM))),[o,s]}Jc.Directions=B;var Qc={__proto__:null,manhattan:Oc,metro:function(t,e,n){if(b(Oc))return Oc(t,E({},Rc,e),n);throw new Error("Metro requires the manhattan router.")},normal:function(t,e,n){return t},oneSide:function(t,e,n){var i,r,o,s=e.side||"bottom",e=Ol(e.padding||40),a=n.sourceBBox,n=n.targetBBox,l=a.center(),h=n.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 l[i]+=o*(a[r]/2+e[s]),h[i]+=o*(n[r]/2+e[s]),0<o*(l[i]-h[i])?h[i]=l[i]:l[i]=h[i],[l].concat(t,h)},orthogonal:gc,rightAngle:Jc};function td(a){return function(t,e,n,i,r,o){var s;return n instanceof Element?(s=(s=this.paper.findView(n))?s.isNodeConnection(n)?ed(s,"fixedAt"in i?i.fixedAt:"50%"):s.getNodeBBox(n).center():new A,a.call(this,t,e,s,i,r,o)):a.apply(this,arguments)}}function ed(t,e){var n=parseFloat(e);return Sl(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}C=td(function(t,e,n,i){var r=t.getConnection(),o=t.getConnectionSubdivisions(),s=new P(n.clone().offset(0,1e6),n.clone().offset(0,-1e6)),a=new P(n.clone().offset(1e6,0),n.clone().offset(-1e6,0)),s=s.intersect(r,{segmentSubdivisions:o}),a=a.intersect(r,{segmentSubdivisions:o}),r=[];return s&&Array.prototype.push.apply(r,s),a&&Array.prototype.push.apply(r,a),0<r.length?n.chooseClosest(r):"fallbackAt"in i?ed(t,i.fallbackAt):nd(t,e,n,i)});let nd=td(function(t,e,n,i){return(t=t.getClosestPoint(n))||new A}),id={__proto__:null,connectionClosest:nd,connectionLength:function(t,e,n,i){return i="length"in i?i.length:20,t.getPointAtLength(i)},connectionPerpendicular:C,connectionRatio:function(t,e,n,i){return i="ratio"in i?i.ratio:.5,t.getPointAtRatio(i)},resolveRef:td},rd={LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom"},od={PREFER_HORIZONTAL:"prefer-horizontal",PREFER_VERTICAL:"prefer-vertical",HORIZONTAL:"horizontal",VERTICAL:"vertical",AUTO:"auto"};function sd(t,e,n,i){e=e.get(n).port;return t.hasPort(e)?t.getPortBBox(e,{rotate:i}):t.getBBox({rotate:i})}function ad(f){return function(t,e,n,i,r,o){var s=!!i.rotate,a=t.model,o=o.model,l=a.angle();let h,u;i.useModelGeometry?(h=sd(a,o,r,!s),u=h.center()):(u=a.getCenter(),h=s?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e));o=h[f]();let c=i.dx,d=(c&&(r=Sl(c),c=!r&&ph(c)?Number(vh(c,h)):parseFloat(c),isFinite(c))&&(r&&(c=(c/=100)*h.width),o.x+=c),i.dy);return d&&(a=Sl(d),d=!a&&ph(d)?Number(vh(d,h)):parseFloat(d),isFinite(d))&&(a&&(d=(d/=100)*h.height),o.y+=d),s?o.rotate(u,-l):o}}n=ad("center"),a=ad("topMiddle"),l=ad("bottomMiddle"),s=ad("leftMiddle"),o=ad("rightMiddle"),u=ad("origin"),i=ad("topRight"),r=td(function(t,e,n,i,r,o){var s=t.model,a=s.angle();let l,h=(s=(l=i.useModelGeometry?sd(s,o.model,r,!0):t.getNodeBBox(e)).center(),o=l.origin(),r=l.corner(),i.padding),u,c;return isFinite(h)||(h=0),o.y+h<=n.y&&n.y<=r.y-h?(u=n.y-s.y,s.x+=0===a||180===a?0:u/Math.tan(Zn(a)),s.y+=u):o.x+h<=n.x&&n.x<=r.x-h&&(c=n.x-s.x,s.y+=90===a||270===a?0:c*Math.tan(Zn(a)),s.x+=c),s}),h={__proto__:null,bottom:l,bottomLeft:ad("bottomLeft"),bottomRight:ad("corner"),center:n,left:s,midSide:td(function(t,e,n,i,r,o){var s,a,l=!!i.rotate,h=t.model.angle(),u=t.model.getCenter(),o=(i.useModelGeometry?u=(s=sd(t.model,o.model,r,!l)).center():s=l?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),i.padding);switch(isFinite(o)&&s.inflate(o),l&&n.rotate(u,h),((t,e,n)=>{var{preferenceThreshold:i=0,mode:n}=n,{x:r,y:o}=e,{x:s,y:a,width:l,height:h}=t;switch(n){case od.PREFER_VERTICAL:var{top:u,bottom:c}=Ol(i);if(a-u<o&&o<a+h+c)return r<s+l/2?rd.LEFT:rd.RIGHT;case od.VERTICAL:return o<a+h/2?rd.TOP:rd.BOTTOM;case od.PREFER_HORIZONTAL:var{left:u,right:c}=Ol(i);if(s-u<r&&r<s+l+c)return o<a+h/2?rd.TOP:rd.BOTTOM;case od.HORIZONTAL:return r<s+l/2?rd.LEFT:rd.RIGHT;default:od.AUTO;return t.sideNearestToPoint(e)}})(s,n,i)){case rd.LEFT:a=s.leftMiddle();break;case rd.RIGHT:a=s.rightMiddle();break;case rd.TOP:a=s.topMiddle();break;case rd.BOTTOM:a=s.bottomMiddle()}return l?a.rotate(u,-h):a}),modelCenter:function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)},perpendicular:r,right:o,top:a,topLeft:u,topRight:i};let ld=Mu.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace=void 0!==joint&&ua(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var n=e.collection.cellNamespace,i=t.type,n=pl(n,i,".");if(n)return new n(t,e);throw new Error(`dia.Graph: Could not find cell constructor for type: '${i}'. Make sure to add the constructor to 'cellNamespace'.`)},_addReference:function(t,e){Mu.prototype._addReference.apply(this,arguments),e.dry||t.graph||(t.graph=this.graph)},_removeReference:function(t,e){Mu.prototype._removeReference.apply(this,arguments),e.dry||t.graph!==this.graph||(t.graph=null)},comparator:function(t){return t.get("z")||0}}),hd=Gl.extend({initialize:function(t,e){e=e||{};e=new ld([],{model:e.cellModel,cellNamespace:e.cellNamespace,graph:this});Gl.prototype.set.call(this,"cells",e),e.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},e.on("add",this._restructureOnAdd,this),e.on("remove",this._restructureOnRemove,this),e.on("reset",this._restructureOnReset,this),e.on("change:source",this._restructureOnChangeSource,this),e.on("change:target",this._restructureOnChangeTarget,this),e.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){var e,n;t.isLink()?(this._edges[t.id]=!0,{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)):this._nodes[t.id]=!0},_restructureOnRemove:function(t){var e,n;t.isLink()?(delete this._edges[t.id],{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]):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=(e.id&&this._out[e.id]&&delete this._out[e.id][t.id],t.attributes.source);e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target"),e=(e.id&&this._in[e.id]&&delete this._in[e.id][t.id],t.get("target"));e.id&&((this._in[e.id]||(this._in[e.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(t={}){var e=Gl.prototype.toJSON.apply(this,arguments);return e.cells=this.get("cells").toJSON(t.cellAttributes),e},fromJSON:function(t,e){if(t.cells)return this.set(t,e);throw new Error("Graph JSON must contain cells array.")},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=ca(i,"cells")),Gl.prototype.set.call(this,i,n)},clear:function(t){t=E({},t,{clear:!0});var e=this.get("cells");if(0!==e.length){this.startBatch("clear",t);for(var n=e.sortBy(function(t){return t.isLink()?1:2});n.shift().remove(t),0<n.length;);this.stopBatch("clear")}return this},_prepareCell:function(t){let e;if(e=t instanceof Gl?t.attributes:t,T(e.type))return t;throw new TypeError("dia.Graph: cell type must be a string.")},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 Gl?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=sa(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){t=et(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(t,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),Xs(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})},transferCellEmbeds:function(t,e,n={}){var i="transfer-embeds",t=(this.startBatch(i),t.getEmbeddedCells());e.embed(t,{...n,reparent:!0}),this.stopBatch(i)},transferCellConnectedLinks:function(e,n,i={}){var t="transfer-connected-links";this.startBatch(t),this.getConnectedLinks(e,i).forEach(t=>{t.getSourceCell()===e&&t.prop(["source","id"],n.id,i),t.getTargetCell()===e&&t.prop(["target","id"],n.id,i)}),this.stopBatch(t)},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,r){var o,s=(r=r||{}).indirect,a=r.inbound,l=r.outbound,h=(void 0===a&&void 0===l&&(a=l=!0),[]),u={};function c(i,t){fa(i.getOutboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getTargetCell())&&t.isLink()&&(u[t.id]||(h.push(t),c(i,t)))}function d(i,t){fa(i.getInboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getSourceCell())&&t.isLink()&&(u[t.id]||(h.push(t),d(i,t)))}return l&&c(this,t),a&&d(this,t),r.deep&&(t=t.getEmbeddedCells({deep:!0}),o={},t.forEach(function(t){t.isElement()&&(o[t.id]=!0)}),t.forEach(function(t){t.isLink()||(l&&fa(this.getOutboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)),a&&fa(this.getInboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)))},this)),h},getNeighbors:function(o,s){var t,a=(s=s||{}).inbound,l=s.outbound,e=(void 0===a&&void 0===l&&(a=l=!0),this.getConnectedLinks(o,s).reduce(function(t,e){var n,{source:i,target:r}=e.attributes,e=e.hasLoop(s);return a&&ua(i,"id")&&!t[i.id]&&(n=this.getCell(i.id)).isElement()&&(e||!(!n||n===o||s.deep&&n.isEmbeddedIn(o)))&&(t[i.id]=n),l&&ua(r,"id")&&!t[r.id]&&(i=this.getCell(r.id)).isElement()&&(e||!(!i||i===o||s.deep&&i.isEmbeddedIn(o)))&&(t[r.id]=i),t}.bind(this),{}));return o.isLink()&&(a&&(t=o.getSourceCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),l)&&(t=o.getTargetCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),et(e)},getCommonAncestor:function(){var t=(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)).sort(function(t,e){return t.length-e.length}),e=et(t.shift()).find(function(e){return t.every(function(t){return t.includes(e)})});return this.getCell(e)},getSuccessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},E({},t,{outbound:!0})),n},cloneCells:oh,cloneSubgraph:function(t,e){t=this.getSubgraph(t,e);return this.cloneCells(t)},getSubgraph:function(t,e){e=e||{};var i=[],r={},n=[],o=[];return et(t).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t))})}),o.forEach(function(t){var{source:t,target:e}=t.attributes;t.id&&!r[t.id]&&(t=this.getCell(t.id),i.push(t),r[t.id]=t,n.push(t)),e.id&&!r[e.id]&&(t=this.getCell(e.id),i.push(this.getCell(e.id)),r[t.id]=t,n.push(t))},this),n.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var{source:e,target:n}=t.attributes;!r[t.id]&&e.id&&r[e.id]&&n.id&&r[n.id]&&(i.push(t),r[t.id]=t)})},this),i},getPredecessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},E({},t,{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={}){var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.shift();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n);for(let t=0,e=a.length;t<e;t++){var l=a[t];r[l.id]=r[s.id]+1,o.push(l)}}}},dfs:function(t,e,n={}){var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.pop();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n),l=o.length;for(let t=0,e=a.length;t<e;t++){var h=a[t];r[h.id]=r[s.id]+1,o.splice(l,0,h)}}}},getSources:function(){var n=[];return fa(this._nodes,function(t,e){this._in[e]&&!ea(this._in[e])||n.push(this.getCell(e))}.bind(this)),n},getSinks:function(){var n=[];return fa(this._nodes,function(t,e){this._out[e]&&!ea(this._out[e])||n.push(this.getCell(e))}.bind(this)),n},isSource:function(t){return!this._in[t.id]||ea(this._in[t.id])},isSink:function(t){return!this._out[t.id]||ea(this._out[t.id])},isSuccessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{outbound:!0}),i},isPredecessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{inbound:!0}),i},isNeighbor:function(t,n,e){var i=(e=e||{}).inbound,r=e.outbound,o=(void 0===i&&void 0===r&&(i=r=!0),!1);return this.getConnectedLinks(t,e).forEach(function(t){var{source:t,target:e}=t.attributes;return i&&ua(t,"id")&&t.id===n.id||r&&ua(e,"id")&&e.id===n.id?!(o=!0):void 0}),o},disconnectLinks:function(e,n){this.getConnectedLinks(e).forEach(function(t){t.set(t.attributes.source.id===e.id?"source":"target",{x:0,y:0},n)})},removeLinks:function(t,e){Xs(this.getConnectedLinks(t),"remove",e)},findElementsAtPoint:function(t,e){return this._filterAtPoint(this.getElements(),t,e)},findLinksAtPoint:function(t,e){return this._filterAtPoint(this.getLinks(),t,e)},findCellsAtPoint:function(t,e){return this._filterAtPoint(this.getCells(),t,e)},_filterAtPoint:function(t,e,n={}){return t.filter(t=>t.getBBox({rotate:!0}).containsPoint(e,n))},findElementsInArea:function(t,e={}){return this._filterInArea(this.getElements(),t,e)},findLinksInArea:function(t,e={}){return this._filterInArea(this.getLinks(),t,e)},findCellsInArea:function(t,e={}){return this._filterInArea(this.getCells(),t,e)},_filterInArea:function(t,e,n={}){let i=new tt(e);var{strict:e=!1}=n;let r=e?"containsRect":"intersect";return t.filter(t=>i[r](t.getBBox({rotate:!0})))},findElementsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getElements(),t,e)},findLinksUnderElement:function(t,e){return this._filterCellsUnderElement(this.getLinks(),t,e)},findCellsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getCells(),t,e)},_isValidElementUnderElement:function(t,e){return t.id!==e.id&&!t.isEmbeddedIn(e)},_isValidLinkUnderElement:function(t,e){return t.source().id!==e.id&&t.target().id!==e.id&&!t.isEmbeddedIn(e)},_validateCellsUnderElement:function(t,e){return t.filter(t=>t.isLink()?this._isValidLinkUnderElement(t,e):this._isValidElementUnderElement(t,e))},_getFindUnderElementGeometry:function(t,e="bbox"){t=t.getBBox({rotate:!0});return"bbox"!==e?Ih(t,e):t},_filterCellsUnderElement:function(t,e,n={}){var i=this._getFindUnderElementGeometry(e,n.searchBy),t=i.type===c.Point?this._filterAtPoint(t,i):this._filterInArea(t,i,n);return this._validateCellsUnderElement(t,e)},findModelsInArea:function(t,e){return this.findElementsInArea(t,e)},findModelsFromPoint:function(t){return this.findElementsAtPoint(t)},findModelsUnderElement:function(t,e){return this.findElementsUnderElement(t,e)},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e={}){let{rotate:n=!0}=e;return et(t).reduce(function(t,e){e=e.getBBox({rotate:n});return e?t?t.union(e):e:t},null)},translate:function(t,e,n){var i=this.getCells().filter(function(t){return!t.isEmbedded()});return Xs(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);return r&&(t=Math.max(t/r.width,0),e=Math.max(e/r.height,0),Xs(n,"scale",t,e,r.origin(),i)),this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",E({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",E({},e,{batchName:t}))},hasActiveBatch:function(t){let e=this._batches,n;return(n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t]).some(t=>0<e[t])}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){e=e.getSourceCell();if(e)if(1<t.getConnectedLinks(e,{outbound:!0}).filter(function(t){var{source:t,target:e}=t.attributes;return t&&t.id===n.id&&(!t.port||t.port===n.port)&&e&&e.id===i.id&&(!e.port||e.port===i.port)}).length)return!1}return!0},linkPinning:function(t,e){var{source:e,target:n}=e.attributes;return e.id&&n.id}}}),ud=(Rh(hd.prototype,["resetCells","addCells","removeCells"],Vh.cells),{GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"}),cd=Cu.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){var t=this.options.name;return t?al(t+"-layer"):null},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){var e=this.el;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(e){var{el:n,pivotNodes:i}=this,r=i[e=(e=+e)||0];if(!r){r=i[e]=document.createComment("z-index:"+(e+1));let t=-1/0;for(var o in i)(o=+o)<e&&o>t&&(t=o);t!==-1/0?(i=i[t],n.insertBefore(r,i.nextSibling)):n.insertBefore(r,n.firstChild)}return r},removePivots:function(){var t,{el:e,pivotNodes:n}=this;for(t in n)e.removeChild(n[t]);this.pivotNodes={}},isEmpty:function(){return 0===this.el.children.length}}),dd=["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),{}),fd=["r","rx","ry","width","height","stroke-width","font-size"].reduce((t,e)=>(t[e]=!0,t),{});function pd(t,e){var n,i={};for(n in t)t.hasOwnProperty(n)&&(i[n]=gd(n,t[n],e));return i}function gd(e,n,i){if(e in dd&&ph(n)){let t=vh(n,i);return t=e in fd?Math.max(0,t):t}return n}let md={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},p=Cu.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var i=["cell"],t=this.model.get("type");return t&&t.toLowerCase().split(".").forEach(function(t,e,n){i.push("type-"+n.slice(0,e+1).join("-"))}),i.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e={},n={},i=0,r=S(this,"presentationAttributes");for(t in r)if(r.hasOwnProperty(t))for(var o=r[t],s=0,a=(o=Array.isArray(o)?o:[o]).length;s<a;s++){var l,h=(h=e[l=o[s]])||(e[l]=1<<i++);n[t]|=h}var u=S(this,"initFlag");for(s=0,a=(u=Array.isArray(u)?u:[u]).length;s<a;s++)e[l=u[s]]||(e[l]=1<<i++);if(25<i)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=e,this._presentationAttributes=n},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||wl(this),Cu.call(this,t)},initialize:function(){this.setFlags(),Cu.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){t=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&t&&(e.dirty&&this.hasFlag(t,"UPDATE")&&(t|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(t,e))},requestUpdate:function(t,e){var n=this.paper;n&&0<t&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n,t=dl(t),i=t.selectors,r=t.groupSelectors;for(n in r){if(i[n])throw new Error("dia.CellView: ambiguous group selector");i[n]=r[n]}if(e){var o=this.selector;if(i[o])throw new Error("dia.CellView: ambiguous root selector.");i[o]=e}return{fragment:t.fragment,selectors:i}},can:function(t){var e=b(this.options.interactive)?this.options.interactive(this):this.options.interactive;return x(e)&&!1!==e[t]||Hs(e)&&!1!==e},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){n=n[t];if(n)return Array.isArray(n)?n:[n]}return this.useCSSSelectors?L(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){var[t=null]=this.findNodes(t);return t},notify:function(t){var e;this.paper&&(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){return t=t&&t.useModelGeometry?(t=this.model).getBBox().bbox(t.angle()):this.getNodeBBox(this.el),this.paper.localToPaperRect(t)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),t=this.getNodeMatrix(t);return R.transformRect(e,n.multiply(t))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():R.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),t=this.getNodeMatrix(t),n=this.getRootTranslateMatrix();return R.transformRect(e,n.multiply(t))},getRootTranslateMatrix:function(){var t=this.model.position();return R.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t,e=R.createSVGMatrix(),n=this.model,i=n.angle();return i&&(t=(n=n.getBBox()).width/2,e=e.translate(t,n=n.height/2).rotate(i).translate(-t,-n)),e},_notifyHighlight:function(t,e,n={}){var i=this.el;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=md.EMBEDDING;break;case n.connecting:t=md.CONNECTING;break;case n.magnetAvailability:t=md.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=md.ELEMENT_AVAILABILITY;break;default:t=md.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){var e=this.el;let n=this.$(t)[0];n=n||e;do{var i=n.getAttribute("magnet"),r=n===e;if((i||r)&&"false"!==i)return n;if(r)return}while(n=n.parentNode)},findProxyNode:function(t,e){e=(t=t||this.el).getAttribute(e+"-selector");if(e){e=this.findNode(e);if(e)return e}return t},getSelector:function(t,e){var n,i;return t===this.el?"string"==typeof e?":scope > "+e:i:(t&&(n=R(t).index()+1,i=t.tagName+":nth-child("+n+")",e&&(i+=" > "+e),i=this.getSelector(t.parentNode,i)),i)},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(e,...t){var n=this.model,i=n.id,r=this.findAttributeNode("port",e),o=e.getAttribute("joint-selector"),i={id:i};if(null!=o&&(i.magnet=o),null!=r){let t=r.getAttribute("port");"number"===r.getAttribute("port-id-type")&&(t=parseInt(t,10)),i.port=t,n.hasPort(t)||o||(i.selector=this.getSelector(e))}else null==o&&this.el!==e&&(i.selector=this.getSelector(e));return this.customizeLinkEnd(i,e,...t)},customizeLinkEnd:function(t,e,n,i,r,o){var s=this.paper,a=s.options.connectionStrategy;if("function"==typeof a){a=a.call(s,t,this,e,new A(n,i),r,o,s);if(a)return a}return t},getMagnetFromLinkEnd:function(t){var e=t.port,n=t.magnet,i=this.model,i=null!=e&&i.isElement()&&i.hasPort(e)?this.findPortNode(e,n)||this.el:(n=n||t.selector,this.findNode(n=n||null==e?n:'[port="'+e+'"]'));return this.findProxyNode(i,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");e=this.addLinkFromMagnet(e,n,i);e.notifyPointerdown(t,n,i),e.eventData(t,e.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:e})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var r=this.paper,o=r.options.magnetThreshold,s=this.getEventTarget(t),i=i.targetMagnet;if("onleave"===o){if(i===s||R(i).contains(s))return}else if(r.eventData(t).mousemoved<=o)return;this.dragLinkStart(t,i,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){ea(e)||(t instanceof SVGElement?R:L)(t).attr(e)},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,h,u,c=[],d={};for(n in e)e.hasOwnProperty(n)&&(d[R.attributeNames[n]]=e[n]);for(n in d)if(d.hasOwnProperty(n))if(i=d[n],r=this.getAttributeDefinition(n))if(null===i){let e;if(e=(e=!(e=b(r.unset)?r.unset.call(this,t,d,this):r.unset)&&T(r.set)?r.set:e)||n,T(e)&&e)a=a||{},e in a||(a[e]=i);else if(Array.isArray(e)&&0<e.length)for(a=a||{},o=0,s=e.length;o<s;o++){let t=e[o];t in a||(a[t]=i)}}else!b(r.qualify)||r.qualify.call(this,i,t,d,this)?(T(r.set)&&((a=a||{})[r.set]=i),c.push(n,r)):(a=a||{})[n]=i;else(a=a||{})[n]=i;for(o=0,s=c.length;o<s;o+=2)r=c[o+1],i=e[n=c[o]],b(r.set)&&((l=l||{})[n]=i),b(r.position)&&((h=h||{})[n]=i),b(r.offset)&&((u=u||{})[n]=i);return{raw:d,normal:a,set:l,position:h,offset:u}},updateRelativeAttributes:function(t,e,n,i){i=i||{};var r,o,s=pd(e.raw||{},n),a=e.normal||{};for(o in a)a[o]=s[o];var l=e.position,h=e.offset;for(r in e.set){var u=s[r],c=this.getAttributeDefinition(r).set.call(this,u,n.clone(),t,s,this);x(c)?E(a,c):void 0!==c&&(a[r]=c)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,e=a.transform,g=R.transformStringToMatrix(e),m=A(g.e,g.f),v=(e&&(a=ca(a,"transform"),g.e=g.f=0),(l||h)&&(f=(i=this.getNodeScale(t,i.scalableNode)).sx,p=i.sy),!1);for(r in l)u=s[r],(d=this.getAttributeDefinition(r).position.call(this,u,n.clone(),t,s,this))&&(m.offset(A(d).scale(f,p)),v=v||!0);this.setNodeAttributes(t,a);var y=!1;if(h){i=this.getNodeBoundingRect(t);if(0<i.width&&0<i.height){var b=R.transformRect(i,g).scale(1/f,1/p);for(r in h)u=s[r],(d=this.getAttributeDefinition(r).offset.call(this,u,b,t,s,this))&&(m.offset(A(d).scale(f,p)),y=y||!0)}}(void 0!==e||v||y)&&(m.round(1),g.e=m.x,g.f=m.y,t.setAttribute("transform",R.matrixToTransformString(g)))}},getNodeScale:function(t,e){var n;return e=e&&e.contains(t)?(n=1/(t=e.scale()).sx,1/t.sy):n=1,{sx:n,sy:e}},cleanNodesCache:function(){this.metrics={}},cleanNodeCache:function(t){t=t.id;t&&delete this.metrics[t]},nodeCache:function(t){var e=this.metrics;return e?e[t=R.ensureId(t)]||(e[t]={}):{}},getNodeData:function(t){t=this.nodeCache(t);return t.data||(t.data={}),t.data},getNodeBoundingRect:function(t){var e,n=this.nodeCache(t);return void 0===n.boundingRect&&(e=this.paper.options.measureNode,n.boundingRect="function"==typeof e?e(t,this):R(t).getBBox()),new tt(n.boundingRect)},getNodeMatrix:function(e){var n=this.nodeCache(e);if(void 0===n.magnetMatrix){var{rotatableNode:i,el:r}=this;let t;t=i&&i.contains(e)?i:r,n.magnetMatrix=R(e).getTransformToElement(t,{safe:!e.checkVisibility()})}return R.createSVGMatrix(n.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=R(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=[];for(o in t)if(t.hasOwnProperty(o)&&(r=t[o],y(r)))for(var l=n[o]=this.findBySelector(o,e,i),h=0,u=l.length;h<u;h++){var c,d,f=l[h],p=R.ensureId(f),g=i&&i[o]===f,m=s[p];m?(m.array||(a.push(p),m.array=!0,m.attributes=[m.attributes],m.selectedLength=[m.selectedLength]),c=m.attributes,m=m.selectedLength,g?(c.unshift(r),m.unshift(-1)):(d=Js(m,u),c.splice(d,0,r),m.splice(d,0,u))):s[p]={attributes:r,selectedLength:g?-1:u,node:f,array:!1}}for(h=0,u=a.length;h<u;h++)(r=s[p=a[h]]).attributes=_({},...r.attributes.reverse());return s},getEventTarget:function(t,e={}){var{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||{}).rootBBox||(n.rootBBox=tt()),n.selectors||(n.selectors=this.selectors);var i,r,o={},s={},a=[],l=[],h=n.roAttributes,u=this.findNodesAttributes(h||e,t,o,n.selectors),c=h?this.findNodesAttributes(e,t,o,n.selectors):u;for(r in u)if(f=(d=u[r]).attributes,y=d.node,(i=this.processNodeAttributes(y,f)).set||i.position||i.offset||i.raw.ref){var d=c[r]&&c[r].attributes,f=(d&&void 0===f.ref?d:f).ref;if(f){if(!(g=(o[f]||this.findBySelector(f,t,n.selectors))[0]))throw new Error('dia.CellView: "'+f+'" reference does not exist.')}else g=null;p={node:y,refNode:g,processedAttributes:i,allAttributes:d},g?-1<(f=l.findIndex(function(t){return t.refNode===y}))?l.splice(f,0,p):l.push(p):a.push(p)}else this.setNodeAttributes(y,pd(i.normal,n.rootBBox));a.push(...l);for(let e=0,t=a.length;e<t;e++){var p,g,m,v,y=(p=a[e]).node,b=(g=p.refNode)?R.ensureId(g):"";let t=s[b];t||(t=g?(m=this.getNodeBoundingRect(g),v=R(g).getTransformToElement(R.getCommonAncestor(y,g)),R.transformRect(m,v)):n.rootBBox,s[b]=t),h?(i=this.processNodeAttributes(y,p.allAttributes),this.mergeProcessedAttributes(i,p.processedAttributes)):i=p.processedAttributes,this.updateRelativeAttributes(y,i,t,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),E(t.set,e.set),E(t.position,e.position),E(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(),Uu.mount(this))},onDetach(){this.unmountTools(),Uu.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).configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){var t=this._toolsView;return t&&t.unmount(),this},mountTools(){var 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(){Uu.remove(this)},updateHighlighters:function(t=!1){Uu.update(this,null,t)},transformHighlighters:function(){Uu.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){var{defaultInteractionPrevented:t=!1}=this.eventData(t);return t},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){var i=this.model,r=i.graph;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){var i=this.eventData(t).graph;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){var{paper:e,model:n}=this,i=(e.isAsync()&&(n.isLink()&&((i=n.getSourceElement())&&(i=e.findViewByModel(i))&&(e.dumpView(i),e.checkViewVisibility(i)),i=n.getTargetElement())&&(n=e.findViewByModel(i))&&(e.dumpView(n),e.checkViewVisibility(n)),e.dumpView(this),e.checkViewVisibility(this)),this.getEventTarget(t,{fromPoint:!0})),n=e.findView(i);n!==this&&(this.mouseleave(t),n)&&n.mouseenter(t)},setInteractivity:function(t){this.options.interactive=t},isIntersecting:function(t,e){return vr.exists(t,this.getNodeBBox(this.el),e)},isEnclosedIn:function(t){return t.containsRect(this.getNodeBBox(this.el))},isInArea:function(t,e={}){return e.strict?this.isEnclosedIn(t):this.isIntersecting(t)},isAtPoint:function(t,e){return this.getNodeBBox(this.el).containsPoint(t,e)}},{Flags:{TOOLS:"TOOLS"},Highlighting:md,addPresentationAttributes:function(t){return _({},S(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)?Ks(t.concat(e)):void 0})},evalAttribute:gd}),vd=(Object.defineProperty(p.prototype,"useCSSSelectors",{get(){var t=this.model.useCSSSelectors;return void 0!==t?t:hl.useCSSSelectors}}),Symbol("joint.cellViewMarker")),g=(Object.defineProperty(p.prototype,vd,{value:!0}),{TOOLS:p.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"}),yd={MOVE:"move",MAGNET:"magnet"},bd=p.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=p.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){p.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[g.UPDATE],position:[g.TRANSLATE,g.TOOLS],size:[g.RESIZE,g.PORTS,g.TOOLS],angle:[g.ROTATE,g.TOOLS],markup:[g.RENDER],ports:[g.PORTS]},initFlag:[g.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(e,n){var i=this.useCSSSelectors;this.hasFlag(e,g.PORTS)&&(this._removePorts(),this._cleanPortsCache());let r=!1;if(this.hasFlag(e,g.RENDER))this.render(),this.updateTools(n),this.updateHighlighters(!0),r=!0,e=this.removeFlag(e,[g.RENDER,g.UPDATE,g.RESIZE,g.TRANSLATE,g.ROTATE,g.PORTS,g.TOOLS]);else{let t=!1;this.hasFlag(e,g.RESIZE)&&(this.resize(n),t=!0,e=this.removeFlag(e,[g.RESIZE,g.UPDATE]),i)&&(e=this.removeFlag(e,g.PORTS)),this.hasFlag(e,g.UPDATE)&&(this.update(this.model,null,n),e=this.removeFlag(e,g.UPDATE),t=!0,i)&&(e=this.removeFlag(e,g.PORTS)),this.hasFlag(e,g.TRANSLATE)&&(this.translate(),e=this.removeFlag(e,g.TRANSLATE),r=!0),this.hasFlag(e,g.ROTATE)&&(this.rotate(),e=this.removeFlag(e,g.ROTATE),r=!0),this.hasFlag(e,g.PORTS)&&(this._renderPorts(),t=!0,e=this.removeFlag(e,g.PORTS)),t&&this.updateHighlighters(!1)}return r&&this.transformHighlighters(),this.hasFlag(e,g.TOOLS)&&(this.updateTools(n),e=this.removeFlag(e,g.TOOLS)),e},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var n=this.useCSSSelectors,i=(n&&this._removePorts(),this.model),r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new tt(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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.ElementView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var t=this.parseDOMJSON(t,this.el),e=this.selectors=t.selectors;this.rotatableNode=R(e[this.rotatableSelector])||null,this.scalableNode=R(e[this.scalableSelector])||null,this.vel.append(t.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(R(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(){this.rotatableNode?(this.rgRotate(),this.update()):this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var{x:t,y:e}=this.model.position();return`translate(${t},${e})`},getRotateString:function(){var t,e,n=this.model.angle();return n?({width:t,height:e}=this.model.size(),`rotate(${n},${t/2},${e/2})`):null},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,o=(0<r.node.getElementsByTagName("path").length&&(o=!0),r.getBBox({recursive:o})),s=i.width/(o.width||1),o=i.height/(o.height||1),s=(r.attr("transform","scale("+s+","+o+")"),this.rotatableNode),o=s&&s.attr("transform");o&&(s.attr("transform",o+" rotate("+-n+","+i.width/2+","+i.height/2+")"),s=r.getBBox({target:this.paper.cells}),e.set("position",{x:s.x,y:s.y},E({updateHandled:!0},t)),this.translate(),this.rotate()),this.update()},prepareEmbedding:function(t={}){var e=t.model||this.model,n=(t.paper||this.paper).model;let i=t.initialZIndices={};var 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});let 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");r=e.parent();r?(n.getCell(r).unembed(e,{ui:!0}),t.initialParentId=r):t.initialParentId=t.initialParentId||null},processEmbedding:function(t={},e,n,i){let r=t.model||this.model;var o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:h}=o.options;let u,c=(u=(u=b(a)?et(a.call(s,this,e,n,i)):"pointer"===a?s.findElementsAtPoint({x:n,y:i}):s.findElementsUnderElement(r,{searchBy:a})).filter(t=>t instanceof Oh&&r.id!==t.id&&!t.isEmbeddedIn(r)),l&&(u=u.slice(-1)),null);var d=t.candidateEmbedView;for(let t=u.length-1;0<=t;t--){var f=u[t];if(d&&d.model.id==f.id){c=d;break}f=f.findView(o);if(!b(h)||h.call(o,this,f)){c=f;break}}c&&c!=d&&(this.clearEmbedding(t),t.candidateEmbedView=c.highlight(c.findProxyNode(null,"container"),{embedding:!0})),!c&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){var e=(t=t||{}).candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t={}){var 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{var e=i.options.validateUnembedding,r=t.initialParentId;if(r&&"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(i){var{model:t,whenNotAllowed:e="revert"}=i,r=t||this.model;let o=(i.paper||this.paper).model;switch(e){case"remove":r.remove({ui:!0});break;case"revert":{let{initialParentId:t,initialPosition:e,initialZIndices:n}=i;e&&({x:a,y:s}=e,r.position(a,s,{deep:!0,ui:!0})),n&&Object.keys(n).forEach(t=>{var e=o.getCell(t);e&&e.set("z",n[t],{ui:!0})});var s,a=o.getCell(t);a&&a.embed(r,{ui:!0});break}}},getTargetParentView:function(t){var{candidateEmbedView:t=null}=this.eventData(t);return t},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){e=(t=t||this.el).getAttribute(e+"-selector");if(e){var n=this.findAttribute("port",t);if(n){n=this.findPortNode(n,e);if(n)return n}else{n=this.findNode(e);if(n)return n}}return t},notifyPointerdown(t,e,n){p.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){p.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),p.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){p.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){p.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){p.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){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case yd.MAGNET:this.dragMagnet(t,e,n);break;case yd.MOVE:(s||this).drag(t,e,n);default:i.preventPointerEvents||this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case yd.MAGNET:this.dragMagnetEnd(t,e,n);break;case yd.MOVE:(s||this).dragEnd(t,e,n);default:i.preventPointerEvents||this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){p.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){p.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){p.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){p.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){p.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){var i=t.currentTarget;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){var i,r;this.isDefaultInteractionPrevented(t)||(i=this.getDelegatedView())&&i.can("elementMove")&&(this.eventData(t,{action:yd.MOVE,delegatedView:i}),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){var i,r=this.paper,o=t.isPropagationStopped();o&&this.eventData(t,{preventPointerEvents:!0}),!this.isDefaultInteractionPrevented(t)&&this.can("addLinkFromMagnet")&&({targetMagnet:i=t.currentTarget}=this.eventData(t),t.stopPropagation(),r.options.validateMagnet.call(r,this,i,t)?(r.options.magnetThreshold<=0&&this.dragLinkStart(t,i,e,n),this.eventData(t,{action:yd.MAGNET})):o?this.dragStart(t,e,n):this.pointerdown(t,e,n))},snapToGrid:function(t,e,n){var i=this.paper.options.gridSize;return{x:Xn(e,i),y:Xn(n,i)}},drag:function(t,e,n){var i=this.paper,r=this.model,o=this.eventData(t),{pointerOffset:s,restrictedArea:a,embedding:l}=o,{x:s,y:h}=this.snapToGrid(t,e+s.x,n+s.y);r.position(s,h,{restrictedArea:a,deep:!0,ui:!0}),i.options.embeddingMode&&(l||(this.prepareEmbedding(o),l=!0),this.processEmbedding(o,t,e,n)),this.eventData(t,{embedding:l})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){t=this.eventData(t);t.embedding&&this.finalizeEmbedding(t)},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:g}),m=(E(bd.prototype,hn),{TOOLS:p.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"}),wd=p.extend({className:function(){var t=p.prototype.className.apply(this).split(" ");return t.push("link"),t.join(" ")},_labelCache:null,_labelSelectors:null,_V:null,_sourceMagnet:null,_targetMagnet:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(){p.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[m.RENDER],attrs:[m.UPDATE],router:[m.UPDATE],connector:[m.CONNECTOR],labels:[m.LABELS,m.TOOLS],labelMarkup:[m.LABELS],vertices:[m.UPDATE],source:[m.SOURCE,m.UPDATE],target:[m.TARGET,m.UPDATE]},initFlag:[m.RENDER,m.SOURCE,m.TARGET,m.TOOLS],UPDATE_PRIORITY:1,EPSILON:1e-6,confirmUpdate:function(n,i={}){var{paper:r,model:o}=this,s=o.attributes,{source:{id:a},target:{id:t}}=s;if(this.hasFlag(n,m.SOURCE)&&(this._sourceMagnet=null,this.checkEndModel("source",a),n=this.removeFlag(n,m.SOURCE)),this.hasFlag(n,m.TARGET)&&(this._targetMagnet=null,this.checkEndModel("target",t),n=this.removeFlag(n,m.TARGET)),!r||!(a&&!r.isCellVisible(a)||t&&!r.isCellVisible(t)))if(this.hasFlag(n,m.RENDER))this.render(),this.updateHighlighters(!0),this.updateTools(i),n=this.removeFlag(n,[m.RENDER,m.UPDATE,m.LABELS,m.TOOLS,m.CONNECTOR]),Kh.test("isAppleWebKit")&&this.__fixWebKitBug268376();else{let t=!1,e=this.hasFlag(n,m.LABELS);e&&(this.onLabelsChange(o,s.labels,i),n=this.removeFlag(n,m.LABELS),t=!0);a=this.hasFlag(n,m.UPDATE),r=this.hasFlag(n,m.CONNECTOR);(a||r)&&(a?i.translateBy&&o.isRelationshipEmbeddedIn(i.translateBy)?this.translate(i.tx,i.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(i),n=this.removeFlag(n,[m.UPDATE,m.TOOLS,m.CONNECTOR]),e=!1,t=!0),e&&this.updateLabelPositions(),t&&this.updateHighlighters(),this.hasFlag(n,m.TOOLS)&&(this.updateTools(i),n=this.removeFlag(n,m.TOOLS))}return n},__fixWebKitBug268376:function(){var n=this.el,i=Array.from(n.childNodes),r=document.createDocumentFragment();for(let t=0,e=i.length;t<e;t++)n.removeChild(i[t]),r.appendChild(i[t]);n.appendChild(r)},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(m.UPDATE),t)},isLabelsRenderRequired:function(t={}){var e=this.model.previous("labels");if(e&&"propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(1<i)if(!!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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.LinkView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){t=this.parseDOMJSON(t,this.el);this.selectors=t.selectors,this.vel.append(t.fragment)},renderStringMarkup:function(t){t=R(t);Array.isArray(t)||(t=[t]),this.vel.append(t)},_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=R(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())return(n=1<(e=n.childNodes).length||"G"!==e[0].nodeName.toUpperCase()?R("g").append(n):R(e[0])).addClass("label"),{node:n.node,selectors:t.selectors};throw new Error("dia.LinkView: invalid label markup.")}},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)e&&e.remove();else{e?e.empty():(e=t.labels=R("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(al(S(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,h=o[a],h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=(h=(h?(l=h.node,h):(h=r._builtins.defaultLabel,h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=r._getDefaultLabel(),l=(u=this._normalizeLabelMarkup(this._getLabelMarkup(u.markup))||h).node,u)).selectors,l.setAttribute("label-idx",a),e.append(l),n[a]=l,this.selector);if(h[u])throw new Error("dia.LinkView: ambiguous label root selector.");h[u]=l,i[a]=h}e.parent()||this.mountLabels(),this.updateLabels()}return this},mountLabels:function(){var{el:t,paper:e,model:n,_V:i,options:r}=this,i=i.labels;i&&n.hasLabels()&&(i=i.node,r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(i,n.get("z")):i.parentNode!==t&&t.appendChild(i))},unmountLabels:function(){var{options:t,_V:e}=this;e&&(e=e.labels,e)&&t.labelsLayer&&e.remove()},findLabelNodes:function(t,e){var n=this._labelCache[t];return n?(t=this._labelSelectors[t],this.findBySelector(e,n,t)):[]},findLabelNode:function(t,e){var[t=null]=this.findLabelNodes(t,e);return t},_mergeLabelAttrs:function(t,e,n,i){return null===e?null:void 0===e?null===n?null:void 0===n?t?void 0:i:t?n:_({},i,n):t?_({},n,e):_({},i,n,e)},_mergeLabelSize:function(t,e){return null===t?null:void 0===t?null===e?null:void 0===e?void 0:e:_({},e,t)},updateLabels:function(){if(this._V.labels){this.paper.options.labelLayer||this.cleanNodeCache(this.el);for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,t=t._getDefaultLabel(),r=t.markup,o=t.attrs,s=t.size,a=0,l=e.length;a<l;a++){var h=this._labelCache[a],u=(h.setAttribute("cursor",n?"move":"default"),this._labelSelectors[a]),c=e[a],d=c.markup,f=c.size,d=this._mergeLabelAttrs(d||r,c.attrs,o,i),c=this._mergeLabelSize(f,s);this.updateDOMSubtreeAttributes(h,d,{rootBBox:new tt(c),selectors:u})}}return this},removeRedundantLinearVertices:function(t){var e=this.model,n=e.vertices(),n=[this.sourceAnchor,...n,this.targetAnchor],i=n.length,n=new w(n),n=(n.simplify({threshold:.001}),n.points.map(t=>t.toJSON())),r=n.length;return i===r?0:(e.vertices(n.slice(1,r-1),t),i-r)},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 A(this.sourceAnchor);case"target":return new A(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new A(this.sourcePoint);case"target":return new A(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(e)return this.sourceMagnet||e.el;break;case"target":e=this.targetView;if(e)return this.targetMagnet||e.el;break;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){var{route:n,path:i}=this;n&&i&&((n=new w(n)).translate(t,e),this.route=n.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(){var{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){var t=this.model,t=t.vertices(),e=this.findAnchors(t),n=this.sourceAnchor=e.source,e=this.targetAnchor=e.target,t=this.findRoute(t),t=(this.route=t,this.findConnectionPoints(t,n,e));this.sourcePoint=t.source,this.targetPoint=t.target},updatePath:function(){var{route:t,sourcePoint:e,targetPoint:n}=this,t=this.findPath(t,e.clone(),n.clone());this.path=t},findAnchorsOrdered:function(t,e,n,i){var r=this.model,o=r.get(t),r=r.get(n),s=this.getEndView(t),a=this.getEndView(n),l=this.getEndMagnet(t),h=this.getEndMagnet(n),s=s?(e=e?new A(e):a?h:new A(r),this.getAnchor(o.anchor,s,l,e,t)):new A(o),e=a?(l=new A(i||s),this.getAnchor(r.anchor,a,h,l,n)):new A(r),o={};return o[t]=s,o[n]=e,o},findAnchors:function(t){var e=this.model,n=t[0],t=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",t,"source",n):this.findAnchorsOrdered("source",n,"target",t)},findConnectionPoints:function(t,e,n){var i,r=t[0],t=t[t.length-1],o=this.model,s=o.get("source"),o=o.get("target"),a=this.sourceView,l=this.targetView,h=this.paper.options;return{source:a&&!a.isNodeConnection(this.sourceMagnet)?(i=this.sourceMagnet||a.el,s=s.connectionPoint||h.defaultConnectionPoint,r=r||n,r=new P(r,e),this.getConnectionPoint(s,a,i,r,"source")):e,target:l&&!l.isNodeConnection(this.targetMagnet)?(s=this.targetMagnet||l.el,a=o.connectionPoint||h.defaultConnectionPoint,i=t||e,r=new P(i,n),this.getConnectionPoint(a,l,s,r,"target")):n}},getAnchor:function(t,e,n,i,r){var o=e.isNodeConnection(n),s=this.paper.options;if(!(t=t||(o?s.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor)))throw new Error("Anchor required.");if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s[o?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}s=a.call(this,e,n,i,t.args||{},r,this);return s?s.round(this.decimalsRounding):new A},getConnectionPoint:function(t,e,n,i,r){var o=i.end,s=this.paper.options;if(!t)return o;if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s.connectionPointNamespace[l]))throw new Error("Unknown connection point: "+l)}return(s=a.call(this,i,e,n,t.args||{},r,this))?s.round(this.decimalsRounding):o},isIntersecting:function(t,e){var n=this.getConnection();return!!n&&vr.exists(t,n,e,{segmentSubdivisions:this.getConnectionSubdivisions()})},isEnclosedIn:function(t){var e=this.getConnection();return!!e&&!!(e=e.bbox())&&t.containsRect(e)},isAtPoint:function(t){t=new tt(t);return t.inflate(this.EPSILON),this.isIntersecting(t)},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,t=t._getDefaultLabel(),t=this._normalizeLabelPosition(t.position);return _({},e,t)},_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:_({},e,t)},updateLabelPositions:function(){if(this._V.labels&&this.path){var t=this.model.get("labels")||[];if(t.length)for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r,o=this._labelCache[n];o&&(r=t[n],r=this._normalizeLabelPosition(r.position),r=this._mergeLabelPositionProperty(r,e),r=this._getLabelTransformationMatrix(r),o.setAttribute("transform",R.matrixToTransformString(r)),this._cleanLabelMatrices(n))}}return this},_cleanLabelMatrices:function(t){var{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(var r in i){r=i[r].id;r&&r in e&&delete e[r].magnetMatrix}},checkEndModel:function(t,e){if(e&&!this.paper.getModelById(e))throw new Error(`LinkView: invalid ${t} cell.`)},_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:_({},e,t)},addLabel:function(t,e,n,i){var r,o,s=0,t="number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(s=e,n):e):(r=t,o=e,"number"==typeof n?(s=n,i):n),e=this._getDefaultLabelPositionArgs(),i=t,n=this._mergeLabelPositionArgs(i,e),i={position:this.getLabelPosition(r,o,s,n)};return this.model.insertLabel(-1,i,t),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,t=i?t.y:e,i=i?e:n,e={x:r,y:t},n=this.getVertexIndex(r,t);return this.model.insertVertex(n,e,i),n},sendToken:function(t,e,n){var i,r,e=x(e)?(o=e.duration,a="reverse"===e.direction,e.connection):(o=e,a=!1,null),o=o||1e3,s={dur:o+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"},a=(a&&(s.keyPoints="1;0",s.keyTimes="0;1"),R(t));if(!((e="string"==typeof e?this.findNode(e):(t=this._V).connection?t.connection.node:this.el.querySelector("path"))instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");a.appendTo(this.paper.cells).animateAlongPath(s,e),setTimeout((i=a,r=n,function(){i.remove(),"function"==typeof r&&r()}),o)},findRoute:function(t){t=t||[];var e=this.paper.options.routerNamespace||Qc,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(A);n=i}i=b(n)?n:e[n.name];if(b(i))return e=n.args||{},i.call(this,t,e,this)||t.map(A);throw new Error('dia.LinkView: unknown router: "'+n.name+'".')},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||Su,r=this.model.connector(),o=this.paper.options.defaultConnector,r=r||o||{},o=b(r)?r:i[r.name];if(b(o))return(i=Qs(r.args||{})).raw=!0,"string"==typeof(o=o.call(this,e,n,t,i,this))?new I(R.normalizePathData(o)):o;throw new Error('dia.LinkView: unknown connector: "'+r.name+'".')},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("data")?t.data:(e=e.serialize(),t.data=e):null},getConnectionSubdivisions:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("segmentSubdivisions")?t.segmentSubdivisions:(e=e.getSegmentSubdivisions(),t.segmentSubdivisions=e):null},getConnectionLength:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("length")?t.length:(e=e.length({segmentSubdivisions:this.getConnectionSubdivisions()}),t.length=e):0},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?(Sl(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,i="number"==typeof n?(s=n,i):n,n=(i&&(o.args=i),!(i&&i.absoluteDistance)),a=i&&i.absoluteDistance&&i.reverseDistance,i=i&&i.absoluteOffset,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},t=new A(t,e),e=l.closestPointT(t,h),h=l.lengthAtT(e,h);return n&&(h=h/this.getConnectionLength()||0),a&&(h=-1*(this.getConnectionLength()-h)||1),o.distance=h,h=(r=i?r:l.tangentAtT(e))?r.pointOffset(t):(n=l.pointAtT(e),{x:(a=t.difference(n)).x,y:a.y}),o.offset=h,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e=0,n={};if("number"==typeof t)u=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");n=t.args||{},u=t.distance,e=t.angle||0}var i,r=0<u&&u<=1,o=0,s={x:0,y:0},t=(t.offset&&("number"==typeof(t=t.offset)&&(o=t),t.x&&(s.x=t.x),t.y)&&(s.y=t.y),0!==s.x||0!==s.y||0===o),a=n.keepGradient,n=n.ensureLegibility,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},r=r?u*this.getConnectionLength():u,u=l.tangentAtLength(r,h),r=e;return u?(t?(i=u.start.clone()).offset(s):((h=u.clone()).rotate(u.start,-90),h.setLength(o),i=h.end),a&&(r=u.angle()+e,n)&&(r=Yn((r+90)%180-90))):(i=l.start.clone(),t&&i.offset(s)),R.createSVGMatrix().translate(i.x,i.y).rotate(r)},getLabelCoordinates:function(t){t=this._getLabelTransformationMatrix(t);return new A(t.e,t.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new A(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){p.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){p.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),p.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){p.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){p.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){p.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&&E(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){p.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){p.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){p.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){p.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){p.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,i=parseInt(i.getAttribute("label-idx"),10),r=this._getDefaultLabelPositionProperty(),o=this._normalizeLabelPosition(this._getLabelPositionProperty(i)),o=this._mergeLabelPositionProperty(o,r),r=this.getLabelCoordinates(o),o=r.x-e,e=r.y-n,r=this._getLabelPositionAngle(i),n=this._getLabelPositionArgs(i),s=this._getDefaultLabelPositionArgs(),n=this._mergeLabelPositionArgs(n,s);this.eventData(t,{action:"label-move",labelIdx:i,dx:o,dy:e,positionAngle:r,positionArgs:n,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){var i;this.can("arrowheadMove")&&(i=t.target.getAttribute("end"),i=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0}),this.eventData(t,i))},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),e={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)},n=(this.paper.options.snapLabels&&delete e.position.offset,{ui:!0});this.paper.isAsync()&&"touchmove"===t.type&&(n.async=!1),this.model.label(i.labelIdx,e,n)},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,i=t.arrowhead,r=t.initialEnd,o=this.model.prop(i);o&&!Jh.endsEqual(r,o)&&(n=this.paper,r.id&&this.notify("link:disconnect",e,n.findViewByModel(r.id),t.initialMagnet,i),o.id)&&this.notify("link:connect",e,n.findViewByModel(o.id),t.magnetUnderPointer,i)},_snapToPoints:function(e,n,t){let i=null,r=1/0,o=null,s=1/0,a=e.x,l=e.y;for(let t=0;t<n.length;t++){var h=Math.abs(n[t].x-e.x),h=(h<r&&(r=h,i=n[t]),Math.abs(n[t].y-e.y));h<s&&(s=h,o=n[t])}return r<t&&(a=i.x),s<t&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){var{paper:i,model:r}=this,o=i.options.snapLinksSelf,s=this.eventData(t),o=o.radius||20,s=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],r=this._snapToPoints({x:e,y:n},s,o),e=i.localToClientPoint(r);this._connectArrowhead(document.elementFromPoint(e.x,e.y),r.x,r.y,this.eventData(t))},_snapArrowhead:function(t,e,n){let i=this.paper;var{snapLinks:r,connectionStrategy:o}=i.options;let s=this.eventData(t),a=!1;var l=r.radius||50,r=r.findInAreaOptions,h=s.closestView||null;let u=s.closestMagnet||null;var c=s.magnetProxy||null,l=(s.closestView=s.closestMagnet=s.magnetProxy=null,i.findClosestMagnetToPoint({x:e,y:n},{radius:l,findInAreaOptions:r,filter:(t,e)=>t!==this&&(u===e||i.options.validateConnection.apply(i,s.validateConnectionArgs(t,t.el===e?null:e)))})),r=(s.closestView=l?l.view:null,s.closestMagnet=l?l.magnet:null,null),l=s.closestView,d=s.closestMagnet,f=(d&&(r=s.magnetProxy=l.findProxyNode(d,"highlighter")),s.arrowhead),p=u!==d;if(h&&p&&h.unhighlight(c,{connecting:!0,snapping:!0}),l){var{prevEnd:c,prevX:g,prevY:m}=s;if(s.prevX=e,s.prevY=n,a=!0,!p&&("function"!=typeof o||g===e&&m===n))return a;if(g=l.getLinkEnd(d,e,n,this.model,f),!p&&na(c,g))return a;s.prevEnd=g,p&&l.highlight(r,{connecting:!0,snapping:!0})}else g={x:e,y:n};return this.model.set(f,g||{x:e,y:n},{ui:!0}),h&&this.notify("link:snap:disconnect",t,h,u,f),l&&this.notify("link:snap:connect",t,l,d,f),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){var r,o,s,{paper:a,model:l}=this;i.eventTarget!==t&&(i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0}),(r=i.viewUnderPointer=a.findView(t))&&(o=i.magnetUnderPointer=r.findMagnet(t),s=i.magnetProxy=r.findProxyNode(o,"highlighter"),o)&&this.paper.options.validateConnection.apply(a,i.validateConnectionArgs(r,o))?s&&r.highlight(s,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)),i.eventTarget=t,l.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t={},e,n){var i=this.model,{viewUnderPointer:t,magnetUnderPointer:r,magnetProxy:o,arrowhead:s}=t;r&&o&&t&&(t.unhighlight(o,{connecting:!0}),o=t.getLinkEnd(r,e,n,i,s),i.set(s,o,{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=[],i=(n[4]=t,0),r=0,t="source"===t?(i=2,"target"):(r=2,"source"),t=(n[5]=this).model.get(t);return t.id&&((t=(e=n[i]=this.paper.findViewByModel(t.id)).getMagnetFromLinkEnd(t))===e.el&&(t=void 0),n[i+1]=t),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]")),l=("false"!==s.el.getAttribute("magnet")&&a.push(s.el),a.filter(e.bind(t,s)));if(0<l.length){for(var h=0,u=l.length;h<u;h++)s.highlight(l[h],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e=Object.keys(t.marked),n=0,i=e.length;n<i;n++){var r=e[n],o=t.marked[r],s=this.paper.findViewByModel(r);if(s){for(var a=0,l=o.length;a<l;a++)s.unhighlight(o[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){t={action:"arrowhead-move",arrowhead:t,whenNotAllowed:(e=e||{}).whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:Qs(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(t),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=t),t},onMount:function(){p.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){p.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){p.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:m});Object.defineProperty(wd.prototype,"sourceView",{enumerable:!0,get:function(){var t=this.model.attributes.source;return t.id&&this.paper?this.paper.findViewByModel(t.id):null}}),Object.defineProperty(wd.prototype,"targetView",{enumerable:!0,get:function(){var t=this.model.attributes.target;return t.id&&this.paper?this.paper.findViewByModel(t.id):null}}),Object.defineProperty(wd.prototype,"sourceMagnet",{enumerable:!0,get:function(){var t=this.sourceView;if(!t)return null;let e=null;var n=this._sourceMagnet;return e=n&&t.el.contains(n)?n:t.getMagnetFromLinkEnd(this.model.attributes.source),(this._sourceMagnet=e)===t.el?null:e}}),Object.defineProperty(wd.prototype,"targetMagnet",{enumerable:!0,get:function(){var t=this.targetView;if(!t)return null;let e=null;var n=this._targetMagnet;return e=n&&t.el.contains(n)?n:t.getMagnetFromLinkEnd(this.model.attributes.target),(this._targetMagnet=e)===t.el?null:e}}),Object.defineProperty(wd.prototype,"sourceBBox",{enumerable:!0,get:function(){var t,e=this.sourceView;return e?(t=this.sourceMagnet,e.isNodeConnection(t)?new tt(this.sourceAnchor):e.getNodeBBox(t||e.el)):(t=this.model.source(),new tt(t.x,t.y))}}),Object.defineProperty(wd.prototype,"targetBBox",{enumerable:!0,get:function(){var t,e=this.targetView;return e?(t=this.targetMagnet,e.isNodeConnection(t)?new tt(this.targetAnchor):e.getNodeBBox(t||e.el)):(t=this.model.target(),new tt(t.x,t.y))}});class xd{constructor(){this.head=null,this.tail=null,this.map=new Map}keys(){let t=this.head;for(var e=[];t;)e.push(t.key),t=t.next;return e}popHead(){var t;return this.head?(t=this.head,this.map.delete(t.key),this.head=t.next,this.head?this.head.prev=null:this.tail=null,t):null}pushTail(t,e){if(this.map.has(t))throw new Error(`Key "${t}" already exists in the deque.`);e={key:t,value:e,prev:null,next:null};this.map.set(t,e),this.tail?((this.tail.next=e).prev=this.tail,this.tail=e):this.head=this.tail=e}moveToHead(t){t=this.map.get(t);t&&t!==this.head&&(t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this.tail&&(this.tail=t.prev),t===this.head&&(this.head=t.next),t.prev=null,t.next=this.head,this.head&&(this.head.prev=t),this.head=t,!this.tail)&&(this.tail=t)}peekHead(){return this.head||null}rotate(){this.head&&this.head.next&&(this.tail.next=this.head,this.head.prev=this.tail,this.tail=this.head,this.head=this.head.next,this.tail.next=null,this.head.prev=null)}delete(t){var e=this.map.get(t);e&&(e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,this.map.delete(t))}has(t){return this.map.has(t)}get(t){return this.map.get(t)||null}get length(){return this.map.size}}let Ad=cd.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){cd.prototype.init.apply(this,arguments);var{paper:t}=this.options;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){let e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach(t=>{e.push(...this._resolveDrawGridOption(t))}),e},removeGrid(){var t=this._gridCache;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){let{paper:s}=this.options;var t=this._gridSettings;if(this.removeGrid(),0!==t.length){let o=s.options.drawGridSize||s.options.gridSize;if(!(o<=1)){let r=this._getGridRefs();t.forEach((t,e)=>{var e=this._getPatternId(e),t=_({},t),{scaleFactor:n=1}=t;t.width=o*n||1,t.height=o*n||1;let i;r.exist(e)?i=r.get(e):(i=R("pattern",{id:e,patternUnits:"userSpaceOnUse"},R(t.markup)),r.add(e,i)),b(t.render)&&t.render(i.node.firstChild,t,s),i.attr({width:t.width,height:t.height})}),r.root.appendTo(this.el),this.updateGrid()}}},updateGrid(){let{_gridCache:e,_gridSettings:i,options:{paper:r}}=this;if(e){let{root:t,patterns:n}=e;var o,{x:s,y:a,width:l,height:h}=r.getArea();for(o in t.attr({x:s,y:a,width:l,height:h}),n)n[o].attr({x:-s,y:-a});i.forEach((t,e)=>{b(t.update)&&(e=n[this._getPatternId(e)],t.update(e.node.firstChild,t,r))})}},_getPatternId(t){return`pattern_${this.options.paper.cid}_`+t},_getGridRefs(){var t=this._gridCache;if(!t){let i=R("defs"),r=R("svg",{width:"100%",height:"100%"},[i]);t=this._gridCache={root:r,patterns:{},add:function(t,e){var n=R("rect",{width:"100%",height:"100%",fill:`url(#${t})`});i.append(e),r.append(n),this.patterns[t]=e},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}}}return t},_resolveDrawGridOption(t){var e=this.options.patterns;if(T(t)&&Array.isArray(e[t]))return e[t].map(function(t){return E({},t)});var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if((r=i||r||n.markup?r:"dot")&&Array.isArray(e[r])){var o=e[r].map(function(t){return E({},t)}),s=Array.isArray(n.args)?n.args:[n.args||{}];$s(s[0],ca(t,"args"));for(var a=0;a<s.length;a++)o[a]&&E(o[a],s[a]);return o}return i?n:[n]},isEmpty(){var t=this._gridCache;return this.el.children.length===(t?1:0)}}),Pd={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},Td=9007199254740991,Ed={[(C=p.Highlighting).DEFAULT]:{name:"stroke",options:{padding:3}},[C.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[C.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},Sd=[{name:ud.GRID},{name:ud.BACK},{name:ud.CELLS},{name:ud.LABELS},{name:ud.FRONT},{name:ud.TOOLS}],_d=Symbol("joint.cellViewPlaceholderMarker"),Ld=(l=Cu.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:bd,linkView:wd,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:Ed,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){var t=this.model.get("cells").cellNamespace,t=pl(t,["standard","Link"]);if(t)return new t;throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.")},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 bd},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:Pd.APPROX,frozen:!1,autoFreeze:!1,viewManagement:!1,onViewUpdate:function(t,e,n,i,r){e&(r.FLAG_INSERT|r.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:Ke,anchorNamespace:h,linkAnchorNamespace:id,connectionPointNamespace:Je,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,DEFAULT_FIND_BUFFER:200,DEFAULT_CELL_LAYER:ud.CELLS,FLAG_INSERT:1<<30,FLAG_REMOVE:1<<29,FLAG_INIT:1<<28,init:function(){var t=this.options,e=(t.cellViewNamespace||(t.cellViewNamespace=void 0!==joint&&ua(joint,"shapes")?joint.shapes:null),this.model=t.model||new hd);this.legacyMode=!t.viewManagement,this._layers={viewsMap:{},namesMap:{},order:[]},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._viewPlaceholders={},this._idToCid={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models)},_resetUpdates:function(){return this._updates&&this._updates.id&&El(this._updates.id),this._updates={id:null,priorities:[{},{},{}],unmountedList:new xd,mountedList:new xd,count:0,keyFrozen:!1,freezeKey:null,sort:!1,disabled:!1,idle:!1,freshAfterReset:!0}},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()||!qs(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){t=this._getCellViewLike(t);t&&(t[_d]?this._unregisterCellViewPlaceholder(t):this.requestViewUpdate(t,this.FLAG_REMOVE,t.UPDATE_PRIORITY,n))},onCellChange:function(t,e){t!==this.model.attributes.cells&&(t.hasChanged("layer")||t.hasChanged("z")&&this.options.sorting===Pd.APPROX)&&(t=this._getCellViewLike(t))&&this.requestViewUpdate(t,this.FLAG_INSERT,t.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){var e,n,i;this.isFrozen()||this.isIdle()||(e=t&&t.batchName,n=this.model,this.isAsync()||(i=this.UPDATE_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t),(i=this.SORT_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.sortViews())},cloneOptions:function(){var t=this.options,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&void 0!==joint&&ua(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),b(e)||(t.defaultConnector=ta(e)),b(n)||(t.defaultRouter=ta(n)),b(i)||(t.defaultConnectionPoint=ta(i)),b(r)||(t.defaultAnchor=ta(r)),b(o)||(t.defaultLinkAnchor=ta(o)),y(l)&&(t.interactive=E({},l)),y(s)&&(t.highlighting=Ys({},s,Ed)),t.viewManagement=$s({},t.viewManagement,{lazyInitialize:!!t.viewManagement,initializeUnmounted:!1,disposeHidden:!1})},children:function(){var t=R.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:al("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:al("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers.viewsMap},getLayerView(t){var{viewsMap:e}=this._layers;if(t in e)return e[t];throw new Error(`dia.Paper: Unknown layer "${t}".`)},getLayerNode(t){return this.getLayerView(t).el},_removeLayer(t){this._unregisterLayer(t),t.remove()},_unregisterLayer(t){var{viewsMap:e,namesMap:n,order:i}=this._layers,r=this._getLayerName(t);i.splice(i.indexOf(r),1),delete n[t.cid],delete e[r]},_registerLayer(t,e,n){var{viewsMap:i,namesMap:r,order:o}=this._layers;n?(n=this._getLayerName(n),o.splice(o.indexOf(n),0,t)):o.push(t),r[(i[t]=e).cid]=t},_getLayerView(t){var{namesMap:e,viewsMap:n}=this._layers;return t instanceof cd?t.cid in e?t:null:t in n?n[t]:null},_getLayerName(t){var{namesMap:e}=this._layers;return e[t.cid]},_requireLayerView(t){var e=this._getLayerView(t);if(e)return e;throw t instanceof cd?new Error("dia.Paper: The layer is not registered."):new Error(`dia.Paper: Unknown layer "${t}".`)},hasLayer(t){return null!==this._getLayerView(t)},removeLayer(t){t=this._requireLayerView(t);if(!t.isEmpty())throw new Error("dia.Paper: The layer is not empty.");this._removeLayer(t)},addLayer(t,e,n={}){if(!t||"string"!=typeof t)throw new Error("dia.Paper: The layer name must be provided.");if(this._getLayerView(t))throw new Error(`dia.Paper: The layer "${t}" already exists.`);if(!(e instanceof cd))throw new Error("dia.Paper: The layer view is not an instance of dia.PaperLayer.");var n=n.insertBefore;n?(n=this._requireLayerView(n),this._registerLayer(t,e,n),this.layers.insertBefore(e.el,n.el)):(this._registerLayer(t,e,null),this.layers.appendChild(e.el))},moveLayer(t,e){var n,t=this._requireLayerView(t);t!==this._getLayerView(e)&&(n=this._getLayerName(t),this._unregisterLayer(t),this.addLayer(n,t,{insertBefore:e}))},getLayerNames(){return this._layers.order.slice()},getLayers(){return this.getLayerNames().map(t=>this.getLayerView(t))},render:function(){this.renderChildren();var{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:e,defs:r,layers:o}=e;return t.style.position="relative",e.style.overflow=n.overflow?"visible":"hidden",this.svg=e,this.defs=r,this.layers=o,this.renderLayers(),R.ensureId(e),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&R(this.svg).prepend(R.createSVGStyle(t))},createLayer(t){return t!==ud.GRID?new cd({name:t}):new Ad({name:t,paper:this,patterns:this.constructor.gridPatterns})},renderLayer:function(t){var e=this.createLayer(t);return this.addLayer(t,e),e},renderLayers:function(t=Sd){this.removeLayers(),t.forEach(({name:t})=>this.renderLayer(t));var t=this.getLayerView(ud.CELLS),e=this.getLayerView(ud.TOOLS),n=this.getLayerView(ud.LABELS);this.tools=e.el,this.cells=this.viewport=t.el,t.vel.addClass(al("viewport")),n.vel.addClass(al("viewport")),t.el.style.webkitUserSelect="none",t.el.style.userSelect="none",n.el.style.webkitUserSelect="none",n.el.style.userSelect="none"},removeLayers:function(){var{viewsMap:t}=this._layers;Object.values(t).forEach(t=>this._removeLayer(t))},resetLayers:function(){var{viewsMap:t}=this._layers;Object.values(t).forEach(t=>t.removePivots())},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){var i=this.matrix();return void 0===t?R.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){var{a:i,d:r,e:o,f:s}=this.matrix();return(t=Math.max(t||0,this.MIN_SCALE))===i&&t===r||(o=R.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t),this.matrix(o,n)),this},translate:function(t,e,n){var i=this.matrix();return void 0===t?R.matrixToTranslate(i):(e=e||0,i.e===(t=t||0)&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e={}){var n,i,r,o,s,a,l=this.layers;return void 0===t?(n=l.getAttribute("transform"),(this._viewportTransformString||null)===n?t=this._viewportMatrix:(t=l.getCTM(),this._viewportMatrix=t,this._viewportTransformString=n),R.createSVGMatrix(t)):(n=this.matrix(),t=R.createSVGMatrix(t),r=this._viewportTransformString,(i=R.matrixToTransformString(t))===r||!r&&R.matrixToTransformString()===i||({a:r,d:o,e:s,f:a}=t,l.setAttribute("transform",i),this._viewportMatrix=t,this._viewportTransformString=l.getAttribute("transform"),r===n.a&&o===n.d||this.trigger("scale",r,o,e),s===n.e&&a===n.f||this.trigger("translate",s,a,e),this.trigger("transform",t,e)),this)},clientMatrix:function(){return R.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof p)for(var t=t.model,i=this.model.getConnectedLinks(t),r=0,o=i.length;r<o;r++){var s,a=i[r],a=this._getCellViewLike(a);!a||a[_d]||(s=Math.max(e+1,a.UPDATE_PRIORITY),this.scheduleViewUpdate(a,a.getFlag(wd.Flags.UPDATE),s,n))}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof p))return!1;var n=t.model;if(n.isElement())return!1;var i={silent:!0};let r=0;var o=n.getSourceCell();o&&!this.isCellVisible(o)&&(o=this.findViewByModel(o),r=this.dumpView(o,i));let s=0;o=n.getTargetCell();return o&&!this.isCellVisible(o)&&(n=this.findViewByModel(o),s=this.dumpView(n,i)),0===r&&0===s&&!this.dumpView(t,i)},requestViewUpdate:function(t,e,n,i){this.scheduleViewUpdate(t,e,n,i=i||{});t=this.isAsync();this.isFrozen()||t&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES)||(e=this.updateViews(i),t&&this.notifyAfterRender(e,i))},scheduleViewUpdate:function(t,e,n,i){var{_updates:r,options:o}=this,{FLAG_REMOVE:s,FLAG_INSERT:a}=(r.idle&&o.autoFreeze&&(this.legacyMode?this.unfreeze():this.wakeUp()),this),{UPDATE_PRIORITY:l,cid:h}=t;let u=r.priorities[n];if(u=u||(r.priorities[n]={}),l<n)for(let t=n-1;t>=l;t--){var c=r.priorities[t];c&&h in c&&(u[h]|=c[h],delete c[h])}var d=u[h]||0;(d&e)!==e&&(d||r.count++,e&s&&d&a?u[h]^=a:e&a&&d&s&&(u[h]^=s),u[h]|=e,"function"==typeof(a=o.onViewUpdate))&&a.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){var e,n;return t?(n=this._updates,e=t.cid,n=n.priorities[t.UPDATE_PRIORITY],t=this.registerMountedView(t)|n[e],delete n[e],t):0},dumpView:function(t,e={}){var n=this.dumpViewUpdate(t);if(!n)return 0;this.notifyBeforeRender(e);n=this.updateView(t,n,e),t={updated:1,priority:t.UPDATE_PRIORITY};return this.notifyAfterRender(t,e),n},updateView:function(t,e,n){if(!t)return 0;var{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o}=this,s=t.model;if(t[vd]){if(e&i)return this.removeView(s),0;e&r&&((i=!!(e&o))&&(e^=o),this.insertView(t,i),e^=r)}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){t=this.findViewByModel(t);return t?(this.dumpView(t,e),t):null},registerUnmountedView:function(t){var e,t=t.cid,n=this._updates;return n.unmountedList.has(t)?0:(e=this.FLAG_INSERT,n.unmountedList.pushTail(t,e),n.mountedList.delete(t),e)},registerMountedView:function(t){var e,t=t.cid,n=this._updates;return n.mountedList.has(t)?0:(e=(e=n.unmountedList.get(t))?e.value:0,n.unmountedList.delete(t),n.mountedList.pushTail(t),e)},isCellVisible:function(t){t=t&&this._idToCid[t.id||t];return!!t&&this.isViewMounted(t)},isViewMounted:function(t){if(!t)return!1;let e;return e=t[vd]||t[_d]?t.cid:t,this._updates.mountedList.has(e)},dumpViews:function(t){t=$s({},t,{cellVisibility:null,viewport:null});this.updateCellsVisibility(t)},updateViews:function(t={}){this.notifyBeforeRender(t);var e=this.updateViewsBatch({...t,batchSize:1/0}),e={updated:e.updated,priority:e.priority,batches:Number.isFinite(t.batchSize)?Math.ceil(e.updated/t.batchSize):1};return this.notifyAfterRender(e,t),e},hasScheduledUpdates:function(){var t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;0<n&&n--;)for(var i in t[e[n]])return!0;return!1},updateViewsAsync:function(e,n){e=e||{},n=n||{processed:0,priority:Td,checkedUnmounted:0,checkedMounted:0};var{_updates:i,options:r}=this,{id:o,mountedList:s,unmountedList:a,freshAfterReset:l}=i;let t=!0;if(o?(El(o),l&&(i.freshAfterReset=!1,this.legacyMode||0!==s.length||0!==a.length||(this.updateViews(),t=!1))):t=!1,t){0===n.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(e);var l=this.updateViewsBatch(e),h=$s({},e,{mountBatchSize:1e3-l.mounted,unmountBatchSize:1e3-l.unmounted}),u=this.scheduleCellsVisibilityUpdate(h),c=u.unmounted,u=u.mounted;let t=n.processed;var d=i.count,c=(0<l.updated?(t+=l.updated+l.unmounted,l.processed=t,n.priority=Math.min(l.priority,n.priority),l.empty&&0===u?(l.unmounted+=c,l.mounted+=u,l.priority=n.priority,this.notifyAfterRender(l,e),n.processed=0,n.priority=Td,i.count=0):n.processed=t,n.checkedUnmounted=0,n.checkedMounted=0):(n.checkedUnmounted+=Math.max(h.mountBatchSize,0),n.checkedMounted+=Math.max(h.unmountBatchSize,0),r.autoFreeze&&!this.hasScheduledUpdates()&&n.checkedUnmounted>=a.length&&n.checkedMounted>=s.length&&(this.freeze(),i.idle={wakeUpOptions:e},this.trigger("render:idle",e))),e.progress);if(d&&"function"==typeof c&&c.call(this,l.empty,t,d,l,this),i.id!==o)return}if(i.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");i.id=Tl(this.updateViewsAsync,this,e,n)},notifyBeforeRender:function(e={}){if(!e.silent){let t=e.beforeRender;"function"!=typeof t&&"function"!=typeof(t=this.options.beforeRender)||t.call(this,e,this)}},notifyAfterRender:function(e,n={}){if(!n.silent){let t=n.afterRender;"function"==typeof(t="function"!=typeof t?this.options.afterRender:t)&&t.call(this,e,n,this),this.trigger("render:done",e,n)}},prioritizeCellViewMount:function(t){var e;return!(!t||!(t=this._idToCid[t.id||t])||(e=this._updates.unmountedList,!e.has(t))||(e.moveToHead(t),0))},prioritizeCellViewUnmount:function(t){var e;return!(!t||!(t=this._idToCid[t.id||t])||(e=this._updates.mountedList,!e.has(t))||(e.moveToHead(t),0))},_evalCellVisibility:function(t,e,n){return!n||!t.DETACHABLE||(this.legacyMode?n.call(this,t,e,this):!t[vd]&&!t[_d]||(t.model.graph!==this.model?e:n.call(this,t.model,e,this)))},_getCellVisibilityCallback:function(t){var e=this.options;if(this.legacyMode){var n=("viewport"in t?t:e).viewport;if("function"==typeof n)return n}else{n=("cellVisibility"in t?t:e).cellVisibility;if("function"==typeof n)return n}return null},updateViewsBatch:function(t){var e=(t=t||{}).batchSize||1/0,n=this._updates,i=0,r=0,o=0,s=0,a=Td,l=!0,h=this.options,u=n.priorities,c=this._getCellVisibilityCallback(t),d=h.onViewPostponed,f=("function"!=typeof d&&(d=null),Object.keys(u));t:for(var p=0,g=f.length;p<g;p++){var m,v=+f[p],y=u[v];for(m in y){if(e<=i){l=!1;break t}var b=ku[m];if(b||(b=this._viewPlaceholders[m])){var w=y[m];if(0==(w&this.FLAG_REMOVE)){var x=!n.unmountedList.has(m);if(!this._evalCellVisibility(b,x,c)){x?(this.registerUnmountedView(b),this._hideView(b)):this._mergeUnmountedViewScheduledUpdates(m,w),delete y[m],o++;continue}b[_d]&&(b=this._resolveCellViewPlaceholder(b),w|=this.getCellViewInitFlag(b)),x||(w|=this.FLAG_INSERT,s++),w|=this.registerMountedView(b)}else if(b[_d])continue;x=this.updateView(b,w,t);0<x&&(y[m]=x,!d||!d.call(this,b,x,this)||y[m])?(r++,l=!1):(v<a&&(a=v),i++,delete y[m])}else delete y[m]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getCellViewInitFlag:function(t){return this.FLAG_INIT|t.getFlag(S(t,"initFlag"))},getUnmountedViews:function(){var t,e=this._updates,n=new Array(e.unmountedList.length);let i=0;for(t of e.unmountedList.keys())n[i++]=ku[t]||this._viewPlaceholders[t];return n},getMountedViews:function(){var t,e=this._updates,n=new Array(e.mountedList.length);let i=0;for(t of e.mountedList.keys())n[i++]=ku[t]||this._viewPlaceholders[t];return n},checkUnmountedViews:function(t,e){for(var n=0,e=("function"!=typeof t&&(t=null),"mountBatchSize"in(e=e||{})?e.mountBatchSize:1/0),i=this._updates.unmountedList,r=0,o=Math.min(i.length,e);r<o;r++){var s,a=i.peekHead().key,a=ku[a]||this._viewPlaceholders[a];a&&(this._evalCellVisibility(a,!1,t)?(s=i.popHead().value,n++,(s=this.registerMountedView(a)|s)&&this.scheduleViewUpdate(a,s,a.UPDATE_PRIORITY,{mounting:!0})):i.rotate())}return n},checkMountedViews:function(t,e){e=e||{};var n=0;if("function"==typeof t)for(var e=("unmountBatchSize"in e?e.unmountBatchSize:1/0),i=this._updates.mountedList,r=0,o=Math.min(i.length,e);r<o;r++){var s=i.peekHead().key,s=ku[s];s?this._evalCellVisibility(s,!0,t)?i.rotate():(i.popHead(),n++,this.registerUnmountedView(s)&&this._hideView(s)):i.popHead()}return n},checkViewVisibility:function(t,e={}){var e=this._getCellVisibilityCallback(e),{mountedList:n,unmountedList:i}=this._updates,e=this._evalCellVisibility(t,!1,e);let r=!1,o=!1;return n.has(t.cid)&&!e&&(this.registerUnmountedView(t)&&this._hideView(t),n.delete(t.cid),r=!0),!r&&i.has(t.cid)&&e&&(n=i.get(t.cid),i.delete(t.cid),(e=n.value|this.registerMountedView(t))&&this.scheduleViewUpdate(t,e,t.UPDATE_PRIORITY,{mounting:!0}),o=!0),{mounted:o?1:0,unmounted:r?1:0}},updateCellVisibility:function(t,e={}){var n=this._getCellViewLike(t);n&&0<this.checkViewVisibility(n,e).mounted&&this.requireView(t,e)},updateCellsVisibility:function(t={}){this.scheduleCellsVisibilityUpdate(t);this.updateViews({...t,cellVisibility:(t,e)=>e})},scheduleCellsVisibilityUpdate(t){var t=$s({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),e=this._getCellVisibilityCallback(t),n=this.checkMountedViews(e,t),i=(0<n&&(i=this._updates.unmountedList,t.mountBatchSize=Math.min(i.length-n,t.mountBatchSize)),this.checkUnmountedViews(e,t));return{mounted:i,unmounted:n}},checkViewport:function(t){return this.scheduleCellsVisibilityUpdate(t)},freeze:function(t){var e=this._updates,t=(t=t||{}).key,n=this.options.frozen,i=e.freezeKey;if(t&&t!==i){if(n&&i)return;e.freezeKey=t,e.keyFrozen=n}this.options.frozen=!0;i=e.id;e.id=null,this.legacyMode||(e.idle=!1),this.isAsync()&&i&&El(i)},unfreeze:function(t){var e=this._updates,n=(t=t||{}).key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen)||(e.idle=!1,this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1))},wakeUp:function(){this.isIdle()&&this.unfreeze(this._updates.idle.wakeUpOptions)},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen&&!this.isIdle()},isIdle:function(){return!this.legacyMode&&!(!this._updates||!this._updates.idle)},isExactSorting:function(){return this.options.sorting===Pd.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,t=t.height;return{width:e=qs(e)?e:this.el.clientWidth,height:t=qs(t)?t:this.el.clientHeight}},setDimensions:function(t,e,n={}){var i=this.options,{width:r,height:o}=i,t=void 0===t?r:t,e=void 0===e?o:e;r===t&&o===e||(i.width=t,i.height=e,this._setDimensions(),r=this.getComputedSize(),this.trigger("resize",r.width,r.height,n))},_setDimensions:function(){var t=this.options;let e=t.width,n=t.height;qs(e)&&(e=Math.round(e)+"px"),qs(n)&&(n=Math.round(n)+"px"),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=x(t)?t:E({gridWidth:t,gridHeight:e,padding:n},i);var{x:t,y:e,width:n,height:r}=this.getFitToContentArea(i),{sx:o,sy:s}=this.scale();return this.translate(-t*o,-e*s,i),this.setDimensions(n*o,r*s,i),new tt(t,e,n,r)},getFitToContentArea:function(t={}){var e=t.gridWidth||1,n=t.gridHeight||1,i=Ol(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,h="contentArea"in t?new tt(t.contentArea):this.getContentArea(t),{sx:u,sy:c}=this.scale();h.x*=u,h.y*=c,h.width*=u,h.height*=c;let d=Math.ceil((h.width+h.x)/e),f=Math.ceil((h.height+h.y)/n),p=(t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n,0),g=(("negative"===l&&h.x<0||"positive"===l&&0<=h.x||"any"===l)&&(p=Math.ceil(-h.x/e)*e,p+=i.left,d+=p),0);return("negative"===l&&h.y<0||"positive"===l&&0<=h.y||"any"===l)&&(g=Math.ceil(-h.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 tt(-p/u,-g/c,d/u,f/c)},transformToFitContent:function(o){o=o||{};let s,a;if(a="contentArea"in o?(l=o.contentArea,s=this.localToPaperRect(l),new A(l)):(s=this.getContentBBox(o),this.paperToLocalPoint(s)),s.width&&s.height){$s(o,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});var l=Ol(o.padding),h=o.minScaleX||o.minScale,u=o.maxScaleX||o.maxScale,c=o.minScaleY||o.minScale,d=o.maxScaleY||o.maxScale;let t;t=o.fittingBBox||(p=this.translate(),g=this.getComputedSize(),{x:p.tx,y:p.ty,width:g.width,height:g.height}),t=new tt(t).moveAndExpand({x:l.left,y:l.top,width:-l.left-l.right,height:-l.top-l.bottom});var f,p=this.matrix(),{a:g,d:l,e:m,f:v}=p;let e=t.width/s.width*g,n=t.height/s.height*l;o.preserveAspectRatio&&(e=n=Math.min(e,n)),o.scaleGrid&&(f=o.scaleGrid,e=f*Math.floor(e/f),n=f*Math.floor(n/f)),e=Math.min(u,Math.max(h,e)),n=Math.min(d,Math.max(c,n));const y=e/g,b=n/l;let i=t.x-a.x*e-m,r=t.y-a.y*n-v;switch(o.verticalAlign){case"middle":r+=(t.height-s.height*b)/2;break;case"bottom":r+=t.height-s.height*b}switch(o.horizontalAlign){case"middle":i+=(t.width-s.width*y)/2;break;case"right":i+=t.width-s.width*y}p.a=e,p.d=n,p.e=i,p.f=r,this.matrix(p,o)}},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new tt:R(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(...t){var e=this.options.restrictTranslate;let n;return n=b(e)?e.apply(this,t):!0===e?this.getArea():e?new tt(e):null},_resolveCellViewPlaceholder:function(t){var{model:e,viewClass:n,cid:i}=t,n=this._initializeCellView(n,e,i);return this._registerCellView(n),this._unregisterCellViewPlaceholder(t),n},_registerCellViewPlaceholder:function(t,e=ma("view")){var n=this._resolveCellViewClass(t),t={[_d]:!0,cid:e,model:t,DETACHABLE:!0,viewClass:n,UPDATE_PRIORITY:n.prototype.UPDATE_PRIORITY};return this._viewPlaceholders[e]=t},_registerCellView:function(t){(t.paper=this)._views[t.model.id]=t},_unregisterCellViewPlaceholder:function(t){delete this._viewPlaceholders[t.cid]},_initializeCellView:function(t,e,n){var i=this.options,{interactive:i,labelsLayer:r}=i;return new t({cid:n,model:e,interactive:i,labelsLayer:!0===r?ud.LABELS:r})},_resolveCellViewClass:function(t){var e=this.options,n=e.cellViewNamespace,i=t.get("type")+"View",n=pl(n,i,".");let r,o;return o=t.isLink()?(r=e.linkView,wd):(r=e.elementView,bd),r.prototype instanceof Eu?n||r:r.call(this,t)||n||o},_getCellViewLike:function(t){let e;if(T(t)||qs(t))e=t;else{if(!t)return null;e=t.id}var t=this._views[e];return t||((t=this._idToCid[e])?this._viewPlaceholders[t]:null)},createViewForModel:function(t,e){return this._initializeCellView(this._resolveCellViewClass(t),t,e)},removeView:function(t){var e,n,t=t.id,{_views:i,_updates:r}=this,o=i[t];return o&&(e=o.cid,{mountedList:r,unmountedList:n}=r,o.remove(),delete i[t],delete this._idToCid[t],r.delete(e),n.delete(e)),o},renderView:function(t,e){var n=t.id,i=this._views;let r,o,s=!0;if(n in i&&((r=i[n]).model===t?(o=this.FLAG_INSERT,s=!1):this.removeView(t)),s){i=this.options.viewManagement,n=ma("view");if(this._idToCid[t.id]=n,i.lazyInitialize?(r=this._registerCellViewPlaceholder(t,n),o=this.registerUnmountedView(r)):(r=this.createViewForModel(t,n),this._registerCellView(r),o=this.registerUnmountedView(r),o|=this.getCellViewInitFlag(r)),i.initializeUnmounted)return this._mergeUnmountedViewScheduledUpdates(n,o),r}return this.requestViewUpdate(r,o,r.UPDATE_PRIORITY,e),r},_mergeUnmountedViewScheduledUpdates:function(t,e){var n=this._updates.unmountedList,n=n.get(t);n&&(n.value|=e)},onImageDragStart:function(){return!1},resetViews:function(t,e){e=e||{},t=t||[];var n=(this.legacyMode?this.options.autoFreeze:this.isIdle())?null:"reset";this._resetUpdates(),this.removeViews(),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(){for(var t in this._views){t=this._views[t];t&&t.remove()}this._views={},this._viewPlaceholders={},this._idToCid={}},sortViews:function(){this.isExactSorting()&&(this.isFrozen()||this.isIdle()?this._updates.sort=!0:this.sortViewsExact())},sortViewsExact:function(){var t=Array.from(this.cells.childNodes).filter(t=>t.getAttribute("model-id")),n=this.model.get("cells");Nl(t,function(t,e){t=n.get(t.getAttribute("model-id")),e=n.get(e.getAttribute("model-id")),t=t.attributes.z||0,e=e.attributes.z||0;return t===e?0:t<e?-1:1})},insertView:function(t,e){var{el:n,model:i}=t,r=i.get("layer")||this.DEFAULT_CELL_LAYER,r=this.getLayerView(r);this.options.sorting===Pd.APPROX?r.insertSortedNode(n,i.get("z")):(Pd,r.insertNode(n)),t.onMount(e)},_hideView:function(t){t&&!t[_d]&&(t[vd]?this._hideCellView(t):t.unmount())},_hideCellView:function(t){this.options.viewManagement.disposeHidden&&this._disposeCellView(t)||this._detachCellView(t)},_disposeCellView:function(t){var e;return!Uu.has(t)&&!t.hasTools()&&(e=t.model,t.remove(),delete this._views[e.id],this._registerCellViewPlaceholder(e,t.cid),!0)},disposeHiddenCellViews:function(){var t;if(!this.legacyMode)for(t of this._updates.unmountedList.keys()){var e=ku[t];e&&this._disposeCellView(e)}},_detachCellView(t){t.unmount(),t.onDetach()},findView:function(t){t=T(t)?this.cells.querySelector(t):t instanceof L?t[0]:t,t=this.findAttribute("model-id",t);if(t)return this._views[t]},findViewByModel:function(t){var e,t=this._getCellViewLike(t);if(t)return t[vd]?t:(t=this._resolveCellViewPlaceholder(t),e=this.getCellViewInitFlag(t),this.isViewMounted(t)?this.scheduleViewUpdate(t,e,t.UPDATE_PRIORITY,{isolate:!0}):this._mergeUnmountedViewScheduledUpdates(t.cid,e),t)},findViewsFromPoint:function(e){return e=new A(e),this.model.getElements().map(this.findViewByModel,this).filter(function(t){return t&&t.vel.getBBox({target:this.cells}).containsPoint(e)},this)},findViewsInArea:function(e,t){t=$s(t||{},{strict:!1}),e=new tt(e);var n=this.model.getElements().map(this.findViewByModel,this),i=t.strict?"containsRect":"intersect";return n.filter(function(t){return t&&e[i](t.vel.getBBox({target:this.cells}))},this)},findElementViewsInArea(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findElementsInArea(t,e),e)},findLinkViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findLinksInArea(t,e),e)},findCellViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findCellsInArea(t,e),e)},findElementViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findElementsInArea(t),e)},findLinkViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findLinksInArea(t),e)},findCellViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findCellsInArea(t),e)},findClosestMagnetToPoint:function(t,e={}){let o=Number.MAX_SAFE_INTEGER,s=-1/0,a=new A(t),l=e.radius||Number.MAX_SAFE_INTEGER;t=this.findCellViewsInArea({x:a.x-l,y:a.y-l,width:2*l,height:2*l},e.findInAreaOptions);let h="function"==typeof e.filter?e.filter:null,u=null,c=null;return t.forEach(i=>{let r=[];var t,e=i.model;"false"!==i.el.getAttribute("magnet")&&(e.isLink()?(t=i.getConnection(),r.push({priority:0,distance:t.closestPoint(a).squaredDistance(a),magnet:i.el})):r.push({priority:e.getAncestors().length,distance:e.getBBox().center().squaredDistance(a),magnet:i.el})),i.$("[magnet]").toArray().forEach(t=>{var e=i.getNodeBBox(t);let n=e.pointNearestToPoint(a).squaredDistance(a);(n=e.containsPoint(a)?-Number.MAX_SAFE_INTEGER+n:n)<=l*l&&r.push({priority:Number.MAX_SAFE_INTEGER,distance:n,magnet:t})}),r.forEach(t=>{var{magnet:t,distance:e,priority:n}=t;!(n>s||n===s&&e<o)||h&&!h(i,t)||(s=n,o=e,u=i,c=t)})}),u?{view:u,magnet:c}:null},_findInExtendedArea:function(t,e,n={}){var{buffer:i=this.DEFAULT_FIND_BUFFER}=n;return e(new tt(t).inflate(i),n).map(t=>this.findViewByModel(t))},_filterViewsInArea:function(t,e,n={}){let i=new tt(t);return this._findInExtendedArea(i,e,n).filter(t=>!!t&&t.isInArea(i,n))},_filterViewsAtPoint:function(e,t,n={}){var i=new tt(e);return this._findInExtendedArea(i,t,n).filter(t=>!!t&&t.isAtPoint(e,n))},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){t=new A(t,e);return R.transformPoint(t,this.matrix())},localToPaperRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix())},paperToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix().inverse())},localToClientPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix())},localToClientRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.clientMatrix())},clientToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,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){t=new A(t,e).difference(this.pageOffset());return this.paperToLocalPoint(t)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),t=new tt(t,e,n,i);return t.x-=r.x,t.y-=r.y,this.paperToLocalRect(t)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new A(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){var e,n,i,r;if(t instanceof wd)return e=t.model,n=this.options,r=(i=this.model).constructor.validations,!(!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));throw new Error("Must provide a linkView.")},getDefaultLink:function(t,e){return b(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t={}){let{highlighter:e,type:n}=t;var{highlighting:t,highlighterNamespace:i}=this.options;if(void 0===e){if(!t)return!1;if(n&&!1===(e=t[n]))return!1;e=e||t.default}if(!e)return!1;t=(e=T(e)?{name:e}:e).name,i=i[t];if(!i)throw new Error('Unknown highlighter ("'+t+'")');if("function"!=typeof i.highlight)throw new Error('Highlighter ("'+t+'") is missing required highlight() method');if("function"!=typeof i.unhighlight)throw new Error('Highlighter ("'+t+'") is missing required unhighlight() method');return{highlighter:i,options:e.options||{},name:t}},onCellHighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.highlight(t,e,i))},onCellUnhighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.unhighlight(t,e,i))},pointerdblclick:function(t){t.preventDefault(),t=k(t);var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.pointerdblclick(t,e.x,e.y):this.trigger("blank:pointerdblclick",t,e.x,e.y))},pointerclick:function(t){var e,n;this.eventData(t).mousemoved<=this.options.clickThreshold&&(t=k(t),e=this.findView(t.target),this.guard(t,e)||(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=k(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.contextmenu(t,e.x,e.y):this.trigger("blank:contextmenu",t,e.x,e.y))},pointerdown:function(t){var{target:e,button:n}=t=k(t),i=this.findView(e),n=2===n;if(i){if(!n&&this.guard(t,i))return;var r=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName),r=(this.options.preventDefaultViewAction&&!r&&t.preventDefault(),r&&i.preventDefaultInteraction(t),this.customEventTrigger(t,i));if(r){if(r.isPropagationStopped())return;t.data=r.data}r=e.closest("[magnet]");if(r&&i.el!==r&&i.el.contains(r)){var e=k(new L.Event(t.originalEvent,{data:t.data,currentTarget:r}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped())return n?void 0:void this.delegateDragEvents(i,e.data);t.data=e.data}}n?(this.contextMenuFired=!0,r=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data}),this.contextMenuTrigger(r)):(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,n,i=this.eventData(t);i.mousemoved||(i.mousemoved=0,this.undelegateEvents()),++i.mousemoved<=this.options.moveThreshold||(t=k(t),e=this.snapToGrid(t.clientX,t.clientY),(n=i.sourceView)?(n=this.findViewByModel(n.model)).pointermove(t,e.x,e.y):this.trigger("blank:pointermove",t,e.x,e.y),this.eventData(t,i))},pointerup:function(t){this.undelegateDocumentEvents();var e=k(t),n=this.snapToGrid(e.clientX,e.clientY),i=this.eventData(t).sourceView;i?(i=this.findViewByModel(i.model)).pointerup(e,n.x,n.y):this.trigger("blank:pointerup",e,n.x,n.y),e.isPropagationStopped()||this.pointerclick(new L.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=k(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseover(t):this.el!==t.target&&this.trigger("blank:mouseover",t))},mouseout:function(t){t=k(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseout(t):this.el!==t.target&&this.trigger("blank:mouseout",t))},mouseenter:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=k(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseenter(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseenter",t)}},mouseleave:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=k(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseleave(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseleave",t)}},_processMouseWheelEvtBuf:ia(function(){var{event:t,deltas:e}=this._mw_evt_buffer,e=e.reduce((t,e)=>t+Al(e,50),0),e=Math.pow(.995,e),{x:n,y:i}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,n,i,e),this._mw_evt_buffer={event:null,deltas:[]}},20,{maxWait:20}),mousewheel:function(t){t=k(t);var e,n,i,r,o,s=this.findView(t.target);this.guard(t,s)||(e=t.originalEvent,n=this.snapToGrid(e.clientX,e.clientY),{deltaX:i,deltaY:r}=xl(e),o=this._events["paper:pinch"],t.ctrlKey&&o&&0<o.length?(e.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(r),this._processMouseWheelEvtBuf()):(o=Math.max(-1,Math.min(1,e.wheelDelta)),s?s.mousewheel(t,n.x,n.y,o):this.trigger("blank:mousewheel",t,n.x,n.y,o),this.trigger("paper:pan",t,i,r)))},onevent:function(t){var e,n=t.currentTarget,i=n.getAttribute("event");i&&(n=this.findView(n))&&(t=k(t),this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n.onevent(t,i,e.x,e.y)))},magnetEvent:function(t,e){var n,i,r=t.currentTarget;r.getAttribute("magnet")&&(n=this.findView(r))&&(t=k(t),this.guard(t,n)||(i=this.snapToGrid(t.clientX,t.clientY),e.call(this,n,t,r,i.x,i.y)))},onmagnet:function(t){var e;2===t.button?(this.contextMenuFired=!0,this.magnetContextMenuFired=!0,e=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget}),this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()):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&&(t=k(t),!this.guard(t,n))){e=this.customEventTrigger(t,n,e);if(e){if(e.isPropagationStopped())return;t.data=e.data}e=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,e.x,e.y)}},getPointerArgs(t){var t=k(t),{x:e,y:n}=this.snapToGrid(t.clientX,t.clientY);return[t,e,n]},delegateDragEvents:function(t,e){this.eventData({data:e=e||{}},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){return"mousedown"===t.type&&2===t.button||!(!this.options.guard||!this.options.guard(t,e))||(t.data&&void 0!==t.data.guarded?t.data.guarded:(t=t.target,!!this.GUARDED_TAG_NAMES.includes(t.tagName)||!(e&&e.model&&e.model instanceof Oh||this.el===t||this.svg.contains(t))))},setGridSize:function(t){var e=this.options;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(ud.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(ud.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",t=t.size||"auto auto",n=this.scale(),i=this.translate(),i=(x(e)&&(e=i.tx+n.sx*(e.x||0)+"px "+(i.ty+n.sy*(e.y||0))+"px"),x(t)&&(t=(t=new tt(t).scale(n.sx,n.sy)).width+"px "+t.height+"px"),this.childNodes).background;i.style.backgroundSize=t,i.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[pa(r)];if(b(a)){t.width*=s,t.height*=s;a=a(t,e);if(!(a instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=a.toDataURL("image/png"),r="repeat",x(i)?(i.width*=a.width/t.width,i.height*=a.height/t.height):void 0===i&&(e.size={width:a.width/s,height:a.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){var e;return this.updateBackgroundColor((t=t||{}).color),t.image?(t=this._background=ta(t),wl(t),(e=document.createElement("img")).onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image):(this.drawBackgroundImage(null),this._background=null),this},setInteractivity:function(t){this.options.interactive=t,Xs(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!x(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name,e=e||n+this.svg.id+fl(JSON.stringify(t));if(!this.isDefined(e)){var i=Il,i=i[n]&&i[n](t.args||{});if(!i)throw new Error("Non-existing filter "+n);n=E({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});R(i,n).appendTo(this.defs)}return e},defineGradient:function(t){var e,n,i,r;if(x(t))return{svg:n,defs:e}=this,{type:r,id:n=r+n.id+fl(JSON.stringify(t)),stops:t,attrs:i={}}=t,this.isDefined(n)||(t=et(t).map(({offset:t,color:e,opacity:n})=>R("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1})),(r=R(r,i,t)).id=n,r.appendTo(e)),n;throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.")},definePattern:function(t){if(!x(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e,{svg:n,defs:i}=this,{id:n=n.id+fl(JSON.stringify(t)),markup:t,attrs:r={}}=t;if(t)return this.isDefined(n)||((e=R("pattern",{patternUnits:"userSpaceOnUse"})).id=n,e.attr(r),"string"==typeof t?e.append(R(t)):(r=dl(t).fragment,e.append(r)),e.appendTo(i)),n;throw new TypeError("dia.Paper: definePattern() requires markup.")},defineMarker:function(t){if(!x(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");var{svg:e,defs:n}=this,{id:e=e.id+fl(JSON.stringify(t)),markup:o,attrs:s={},markerUnits:a="userSpaceOnUse"}=t;if(!this.isDefined(e)){a=R("marker",{orient:"auto",overflow:"visible",markerUnits:a});a.id=e,a.attr(s);let i;if(o){let t;t="string"==typeof o?(t=R(o),Array.isArray(t)?t:[t]):(s=dl(o).fragment,R(s).children()),i=1<t.length?R("g").append(t):t[0]}else{var{type:o="path"}=t;i=R(o)}let r=ca(t,"type","id","markup","attrs","markerUnits");Object.keys(r).forEach(t=>{var e=r[t],n=i.attr(t);null==n?i.attr(t,e):"transform"===t&&i.attr(t,e+" "+n)}),i.appendTo(a),a.appendTo(n)}return e},customEventTrigger:function(t,e,n=e.el){var i=t.target.closest("[event]");return i&&n!==i&&e.el.contains(i)?(n=k(new L.Event(t.originalEvent,{data:t.data,currentTarget:i})),this.onevent(n),n.isDefaultPrevented()&&t.preventDefault(),n):null}},{sorting:Pd,Layers:ud,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height,r=(e.width=2*n,e.height=2*i,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,r=(e.width=2*n,e.height=i,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,r=(e.width=n,e.height=2*i,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||{};for(var n=t.width,i=t.height,r=document.createElement("canvas"),o=(r.width=3*n,r.height=3*i,r.getContext("2d")),e=qs(e.watermarkAngle)?-e.watermarkAngle:-20,s=Zn(e),a=r.width/4,l=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)0<(h+u)%2&&(o.setTransform(1,0,0,1,(2*h-1)*a,(2*u-1)*l),o.rotate(s),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({fill:e.color})},update:function(t,e,n){var{sx:n,sy:i}=n.scale(),n=n<=1?e.thickness:e.thickness/n,e=i<=1?e.thickness:e.thickness/i;R(t).attr({width:n,height:e})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}]}}),Cu.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,_visibleExplicit:!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},updateVisibility:function(){var t=this.computeVisibility();this.el.style.display=t?"":"none",this._visible=t},computeVisibility(){var t;return!!this.isExplicitlyVisible()&&(t=this.options.visibility,"function"!=typeof t||!!t.call(this,this.relatedView,this))},show:function(){this._visibleExplicit=!0,this.updateVisibility()},hide:function(){this._visibleExplicit=!1,this.updateVisibility()},isExplicitlyVisible:function(){return!!this._visibleExplicit},isVisible:function(){return!!this._visible},isOverlay:function(){return!!this.parentView&&this.parentView.hasLayer()},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){var{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}}));function kd(t,{useModelGeometry:e=!1,relative:n=!1,el:i=t.el}={}){var r=t.model;let o;return o=e?r.getBBox():r.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(i),n&&(e=r.position(),o.x-=e.x,o.y-=e.y),o}function Cd(t){var e=!t.isOverlay();let{useModelGeometry:n,rotate:i,...r}=t.options;return{...r,useModelGeometry:n||e,rotate:i||e,relative:e}}function Md(t,e,n){return ec.call(this.paper,{},e,n,t,this.model).anchor}n=Cu.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=E(this.options,t)).tools;if(Array.isArray(e)){var n=t.relatedView;if(n instanceof p){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))}this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS"))}}return this},getName:function(){return this.options.name},update:function(e){e=e||{};var n=this.tools;if(n){var i=n.length,t=this.isRendered;for(let t=0;t<i;t++){var r=n[t];r.updateVisibility(),r.isVisible()&&this.ensureToolRendered(n,t)&&e.tool!==r.cid&&r.update()}!this.isRendered&&0<i||(this.isMounted()||this.mount(),t)||this.blurTool()}return this},ensureToolRendered(t,e){return this.isRendered||(this.isRendered=Array(t.length).fill(!1)),!(!this.isRendered[e]&&(t[e].render(),this.isRendered[e]=!0))},focusTool:function(t){var e=this.tools;if(e)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)for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isExplicitlyVisible()||(r.show(),r.isVisible()&&this.ensureToolRendered(e,n)&&r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null),this.isMounted()||this.mount(),this},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},getLayer(){var{layer:t=ud.TOOLS}=this.options;return t},hasLayer(){return!!this.getLayer()},mount:function(){var{options:t,el:e}=this,{relatedView:t,z:n}=t;return t&&(this.hasLayer()?t.paper.getLayerView(this.getLayer()).insertSortedNode(e,n):t.el.appendChild(e)),this}}),s={__proto__:null,CELL_VIEW_MARKER:vd,Cell:Oh,CellView:p,Element:f,ElementView:bd,Graph:hd,HighlighterView:Uu,LayersNames:ud,Link:Jh,LinkView:wd,Paper:l,PaperLayer:cd,ToolView:Ld,ToolsView:n,attributes:Mh},r=Cu.extend({tagName:"circle",svgElement:!0,className:"marker-vertex",events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onDoubleClick",dbltap:"onDoubleClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},attributes:{r:6,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move"},position:function(t,e){var{vel:n,options:i}=this,i=i.scale;let r=R.createSVGMatrix().translate(t,e);i&&(r=r.scale(i)),n.transform(r,{absolute:!0})},onPointerDown:function(t){this.options.guard(t)||(t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.trigger("will-change",this,t))},onPointerMove:function(t){this.trigger("changing",this,t)},onDoubleClick:function(t){this.trigger("remove",this,t)},onPointerUp:function(t){this.trigger("changed",this,t),this.undelegateDocumentEvents(),this.options.paper.delegateEvents()}}),o=Ld.extend({name:"vertices",options:{handleClass:r,snapRadius:20,redundancyRemoval:!0,vertexAdding:!0,stopPropagation:!0,scale:null},children:[{tagName:"path",selector:"connection",className:"joint-vertices-path",attributes:{fill:"none",stroke:"transparent","stroke-width":10,cursor:"cell"}}],handles:null,interactiveLinkNode:null,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},linkEvents:{mousedown:"onLinkPointerDown",touchstart:"onLinkPointerDown"},onRender:function(){var t=this.options.vertexAdding;return t&&({interactiveLinkNode:t=null}=t,t?this.delegateLinkEvents(t):(this.renderChildren(),this.updatePath())),this.resetHandles(),this.renderHandles(),this},delegateLinkEvents:function(t){this.undelegateLinkEvents();var e=this.relatedView.findNode(t);e?(e.classList.add("joint-vertices-path"),this.interactiveLinkNode=e,this.delegateElementEvents(e,this.linkEvents)):console.warn(`Interactive link node "${t}" not found.`)},undelegateLinkEvents:function(){var t=this.interactiveLinkNode;t&&(this.undelegateElementEvents(t),t.classList.remove("joint-vertices-path"),this.interactiveLinkNode=null)},update:function(){return this.relatedView.model.vertices().length===this.handles.length?this.updateHandles():(this.resetHandles(),this.renderHandles()),this.options.vertexAdding&&this.updatePath(),this},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},renderHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=new this.options.handleClass({index:e,paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});r.render(),r.position(i.x,i.y),this.simulateRelatedView(r.el),r.vel.appendTo(this.el),this.handles.push(r),this.startHandleListening(r)}},updateHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=this.handles[e];if(!r)return;r.position(i.x,i.y)}},updatePath:function(){var t;this.interactiveLinkNode||(t=this.childNodes.connection)&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var{vertexRemoving:e=!0,vertexMoving:n=!0}=this.options;n&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),e&&this.listenTo(t,"remove",this.onHandleRemove)},getNeighborPoints:function(t){var e=this.relatedView,n=e.model.vertices(),i=0<t?n[t-1]:e.sourceAnchor,n=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:new A(i),next:new A(n)}},onHandleWillChange:function(t,e){this.focus();var{relatedView:n,options:i}=this;n.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerdown(...n.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var{options:n,relatedView:i}=this,r=t.options.index,[e,o,s]=i.paper.getPointerArgs(e),a={x:o,y:s};this.snapVertex(a,r),i.model.vertex(r,a,{ui:!0,tool:this.cid}),t.position(a.x,a.y),n.stopPropagation||i.notifyPointermove(e,o,s)},onHandleChanged:function(t,e){var{options:n,relatedView:i}=this,[e,r,o]=(n.vertexAdding&&this.updatePath(),n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid})&&this.render(),this.blur(),i.model.stopBatch("vertex-move",{ui:!0,tool:this.cid}),this.eventData(e).vertexAdded&&i.model.stopBatch("vertex-add",{ui:!0,tool:this.cid}),i.paper.getPointerArgs(e));n.stopPropagation||i.notifyPointerup(e,r,o),i.checkMouseleave(e)},snapVertex:function(t,e){var n,i,r=this.options.snapRadius;0<r&&(n=(e=this.getNeighborPoints(e)).prev,i=e.next,Math.abs(t.x-n.x)<r?t.x=n.x:Math.abs(t.x-i.x)<r&&(t.x=i.x),Math.abs(t.y-n.y)<r?t.y=e.prev.y:Math.abs(t.y-i.y)<r&&(t.y=i.y))},onHandleRemove:function(t,e){var t=t.options.index,n=this.relatedView;n.model.removeVertex(t,{ui:!0}),this.options.vertexAdding&&this.updatePath(),n.checkMouseleave(k(e))},onPathPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),t=k(t),e=this.paper.snapToGrid(t.clientX,t.clientY).toJSON(),(i=this.relatedView).model.startBatch("vertex-add",{ui:!0,tool:this.cid}),n=i.getVertexIndex(e.x,e.y),this.snapVertex(e,n),i.model.insertVertex(n,e,{ui:!0,tool:this.cid}),this.update(),i=this.handles[n],this.eventData(t,{vertexAdded:!0}),i.onPointerDown(t))},onLinkPointerDown:function(t){this.relatedView.preventDefaultInteraction(t),this.onPathPointerDown(t)},onRemove:function(){this.resetHandles(),this.undelegateLinkEvents()}},{VertexHandle:r}),a=Cu.extend({tagName:"g",svgElement:!0,className:"marker-segment",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},children:[{tagName:"line",selector:"line",attributes:{stroke:"#33334F","stroke-width":2,fill:"none","pointer-events":"none"}},{tagName:"rect",selector:"handle",attributes:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2}}],onRender:function(){this.renderChildren()},position:function(t,e,n,i){var r=this.options.scale;let o=R.createSVGMatrix().translate(t,e).rotate(n);r&&(o=o.scale(r));r=this.childNodes.handle,r.setAttribute("transform",R.matrixToTransformString(o)),r.setAttribute("cursor",n%180==0?"row-resize":"col-resize"),r=i.getClosestPoint(new A(t,e)),n=this.childNodes.line;n.setAttribute("x1",t),n.setAttribute("y1",e),n.setAttribute("x2",r.x),n.setAttribute("y2",r.y)},onPointerDown:function(t){this.options.guard(t)||(this.trigger("change:start",this,t),t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data))},onPointerMove:function(t){this.trigger("changing",this,t)},onPointerUp:function(t){this.undelegateDocumentEvents(),this.options.paper.delegateEvents(),this.trigger("change:end",this,t)},show:function(){this.el.style.display=""},hide:function(){this.el.style.display="none"}}),u=Ld.extend({name:"segments",precision:.5,options:{handleClass:a,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:Md,snapRadius:10,snapHandle:!0,stopPropagation:!0},handles:null,onRender:function(){this.resetHandles();var t=this.relatedView,e=t.model.vertices();e.unshift(t.sourcePoint),e.push(t.targetPoint);for(var n=0,i=e.length;n<i-1;n++){var r=e[n],o=e[n+1],r=this.renderHandle(r,o);this.simulateRelatedView(r.el),this.handles.push(r),r.options.index=n}return this},renderHandle:function(t,e){var n=new this.options.handleClass({paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});return n.render(),this.updateHandle(n,t,e),n.vel.appendTo(this.el),this.startHandleListening(n),n},update:function(){return this.render(),this},startHandleListening:function(t){this.listenTo(t,"change:start",this.onHandleChangeStart),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"change:end",this.onHandleChangeEnd)},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},shiftHandleIndexes:function(t){for(var e=this.handles,n=0,i=e.length;n<i;n++)e[n].options.index+=t},resetAnchor:function(t,e){var n=this.relatedView.model;e?n.prop([t,"anchor"],e,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([t,"anchor"],{ui:!0,tool:this.cid})},snapHandle:function(t,e,n){var i=t.options.index,r=this.relatedView.model.vertices(),t=t.options.axis,o=r[i-2]||n.sourceAnchor,r=r[i+1]||n.targetAnchor,i=this.options.snapRadius;return Math.abs(e[t]-o[t])<i?e[t]=o[t]:Math.abs(e[t]-r[t])<i&&(e[t]=r[t]),e},onHandleChanging:function(t,e){var n=this.options,i=this.eventData(e),r=this.relatedView,o=r.paper,s=t.options.index-1,e=k(e),o=o.snapToGrid(e.clientX,e.clientY),a=this.snapHandle(t,o.clone(),i),l=t.options.axis,h=this.options.snapHandle?0:o[l]-a[l],u=r.model,c=ta(u.vertices()),d=this.options.anchor,f=("function"!=typeof d&&(d=null),t.options.index),p=[r.sourcePoint.clone(),...c,r.targetPoint.clone()];let g=0;0<=f-1&&(m=p[f-1],v=p[f],new P(m,v).vector().theta()%90!=0)&&(c.splice(f-1,0,i.originalVertices[f-1]),g++,this.shiftHandleIndexes(1));var m=c[s+g],v=c[1+s+g],y=(f+2<p.length&&(b=p[f+1],p=p[f+2],new P(b,p).vector().theta()%90!=0)&&(b=1===i.originalVertices.length,p=i.firstHandleShifted&&!b?1:0,y=1+g,c.splice(f+y,0,i.originalVertices[(b?0:f)-p])),r.sourceView),b=r.sourceBBox,f=!1,p=!1,b=(m?0==s?b.containsPoint(m)?(c.shift(),this.shiftHandleIndexes(-1),f=!0):(m[l]=a[l],p=!0):m[l]=a[l]:((m=r.sourceAnchor.toJSON())[l]=a[l],b.containsPoint(m)?(m[l]=a[l],f=!0):(c.unshift(m),this.shiftHandleIndexes(1),p=i.firstHandleShifted=!0)),d&&y&&(f&&((b=i.sourceAnchor.clone())[l]=a[l],f=d.call(r,b,y,r.sourceMagnet||y.el,"source",r),this.resetAnchor("source",f)),p)&&this.resetAnchor("source",i.sourceAnchorDef),r.targetView),y=r.targetBBox,f=!1,p=!1;if(v?s==c.length-2?y.containsPoint(v)?(c.pop(),f=!0):(v[l]=a[l],p=!0):v[l]=a[l]:((v=r.targetAnchor.toJSON())[l]=a[l],y.containsPoint(v)?f=!0:(c.push(v),p=!0)),d&&b&&(f&&((s=i.targetAnchor.clone())[l]=a[l],y=d.call(r,s,b,r.targetMagnet||b.el,"target",r),this.resetAnchor("target",y)),p)&&this.resetAnchor("target",i.targetAnchorDef),c.some(t=>!t))throw new Error("Segments: incompatible router in use");u.vertices(c,{ui:!0,tool:this.cid}),this.updateHandle(t,m,v,h),n.stopPropagation||r.notifyPointermove(e,o.x,o.y)},onHandleChangeStart:function(t,e){var{options:n,handles:i,relatedView:r}=this,{model:o,paper:s}=r,a=t.options.index;if(Array.isArray(i)){for(var l=0,h=i.length;l<h;l++)l!==a&&i[l].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:Qs(o.prop(["source","anchor"])),targetAnchorDef:Qs(o.prop(["target","anchor"])),originalVertices:ta(o.vertices()),firstHandleShifted:!1}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||r.notifyPointerdown(...s.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var{options:n,relatedView:i}=this,{paper:r,model:o}=i,e=(n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid}),k(e)),r=r.snapToGrid(e.clientX,e.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerup(e,r.x,r.y),i.checkMouseleave(e)},updateHandle:function(t,e,n,i){var r=Math.abs(e.x-n.x)<this.precision,o=Math.abs(e.y-n.y)<this.precision;!r&&!o||(o=new P(e,n)).length()<this.options.segmentLengthThreshold?t.hide():((e=o.midpoint())[n=r?"x":"y"]+=i||0,r=o.vector().vectorAngle(new A(1,0)),t.position(e.x,e.y,r,this.relatedView),t.show(),t.options.axis=n)},onRemove:function(){this.resetHandles()}},{SegmentHandle:a}),i=Ld.extend({tagName:"path",xAxisVector:new A(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=this.ratio,n=this.relatedView,i=n.getTangentAtRatio(e),i=i?(t=i.start,i.vector().vectorAngle(this.xAxisVector)||0):(t=n.getPointAtRatio(e),0);return t&&(n=R.createSVGMatrix().translate(t.x,t.y).rotate(i),e=this.options.scale,e&&(n=n.scale(e)),this.vel.transform(n,{absolute:!0})),this},onPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n=(e=this.relatedView).paper,e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),i=t.data||(t.data={}),this.delegateDocumentEvents(null,i),n.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none",e.notifyPointerdown(...n.getPointerArgs(t)))},onPointerMove:function(t){var t=k(t),e=this.paper.snapToGrid(t.clientX,t.clientY);this.relatedView.pointermove(t,e.x,e.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,t=k(t),i=n.snapToGrid(t.clientX,t.clientY);e.pointerup(t,i.x,i.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),hn=i.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"}}),C=i.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"}}),f=Ld.extend({tagName:"g",type:null,children:[{tagName:"circle",selector:"anchor",attributes:{cursor:"pointer"}},{tagName:"rect",selector:"area",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{snap:function(t,e,n,i,r,o){return o=o.options.snapRadius,i="source"===i,(i=this.model.vertex(i?0:-1)||this.getEndAnchor(i?"target":"source"))&&(Math.abs(i.x-t.x)<o&&(t.x=i.x),Math.abs(i.y-t.y)<o)&&(t.y=i.y),t},anchor:Md,scale:null,resetAnchor:!0,customAnchorAttributes:{"stroke-width":4,stroke:"#33334F",fill:"#FFFFFF",r:5},defaultAnchorAttributes:{"stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6},areaPadding:6,snapRadius:10,restrictArea:!0,redundancyRemoval:!0},onRender:function(){this.renderChildren(),this.toggleArea(!1),this.update()},update:function(){var t=this.type;return this.relatedView.getEndView(t)?(this.updateAnchor(),this.updateArea(),this.el.style.display=""):this.el.style.display="none",this},updateAnchor:function(){var t=this.childNodes;if(t){var s=t.anchor;if(s){let t=this.relatedView,e=this.type,n=t.getEndAnchor(e),i=this.options,r=t.model.prop([e,"anchor"]),o=`translate(${n.x},${n.y})`;i.scale&&(o+=` scale(${i.scale})`),s.setAttribute("transform",o);var a,l=r?i.customAnchorAttributes:i.defaultAnchorAttributes;for(a in l)s.setAttribute(a,l[a])}}},updateArea:function(){var t,e,n,i,r,o,s,a=this.childNodes;a&&(a=a.area)&&(n=this.relatedView,i=this.type,e=(t=n.getEndView(i)).model,n=n.getEndMagnet(i),i=this.options.areaPadding,isFinite(i)||(i=0),t.isNodeConnection(n)?(o=0,s=(r=t.getNodeBBox(n)).center()):(r=t.getNodeUnrotatedBBox(n),o=e.angle(),s=r.center(),o&&s.rotate(e.getCenter(),-o)),r.inflate(i),a.setAttribute("x",-r.width/2),a.setAttribute("y",-r.height/2),a.setAttribute("width",r.width),a.setAttribute("height",r.height),a.setAttribute("transform","translate("+s.x+","+s.y+") rotate("+o+")"))},toggleArea:function(t){var e=this.childNodes;e&&(e=e.area)&&(e.style.display=t?"":"none")},onPointerDown:function(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),this.paper.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleArea(this.options.restrictArea),this.relatedView.model.startBatch("anchor-move",{ui:!0,tool:this.cid}))},resetAnchor:function(t){var e=this.type,n=this.relatedView.model;t?n.prop([e,"anchor"],t,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([e,"anchor"],{ui:!0,tool:this.cid})},onPointerMove:function(t){var e,n,i,r=this.relatedView,o=this.type,s=r.getEndView(o),a=s.model,l=r.getEndMagnet(o),t=k(t),t=this.paper.clientToLocalPoint(t.clientX,t.clientY),h=this.options.snap,h=("function"==typeof h&&(t=h.call(r,t,s,l,o,r,this),t=new A(t)),this.options.restrictArea&&(s.isNodeConnection(l)?(h=s.getClosestPoint(t))&&(t=h):(h=s.getNodeUnrotatedBBox(l),e=a.angle(),a=a.getCenter(),n=t.clone().rotate(a,e),h.containsPoint(n)||(t=h.pointNearestToPoint(n).rotate(a,-e)))),this.options.anchor);"function"==typeof h&&(i=h.call(r,t,s,l,o,r)),this.resetAnchor(i),this.update()},onPointerUp:function(t){var t=k(t),e=(this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1),this.relatedView);this.options.redundancyRemoval&&e.removeRedundantLinearVertices({ui:!0,tool:this.cid}),e.checkMouseleave(t),e.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(!0===t&&(t=null),this.resetAnchor(ta(t)),this.update())}}),l=f.extend({name:"source-anchor",type:"source"}),n=f.extend({name:"target-anchor",type:"target"});let Nd=Ld.extend({tagName:"g",children:[{tagName:"circle",selector:"handle",attributes:{cursor:"pointer","stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6}},{tagName:"rect",selector:"extras",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{handleAttributes:null,selector:"root",padding:6,scale:null},getPosition:function(){},setPosition:function(){},resetPosition:function(){},onRender:function(){this.renderChildren(),this.toggleExtras(!1),this.update()},update:function(){var{handle:t,extras:e}=this.childNodes;if(t)return this.updateHandle(t),e&&this.updateExtras(e),this;throw new Error("Control: markup selector `handle` is required")},updateHandle:function(t){var{handleAttributes:e}=this.options;if(t.setAttribute("transform",this.getHandleTransformString()),e)for(var n in e)t.setAttribute(n,e[n])},getHandleTransformString(){var{relatedView:t,options:e}=this,e=e.scale,n=t.model,t=this.getPosition(t,this),n=this.isOverlay()?n.getAbsolutePointFromRelative(t):t;let i=`translate(${n.x},${n.y})`;return e&&(i+=` scale(${e})`),i},updateExtras:function(n){var{relatedView:i,options:r}=this,{selector:o,relative:s,useModelGeometry:a}=Cd(this);if(o){let t;if(a)"root"!==o&&console.warn("Control: selector will be ignored when `useModelGeometry` is used."),t=kd(i,{useModelGeometry:a,relative:s});else{a=i.findNode(o);if(!a)throw new Error("Control: invalid selector.");t=kd(i,{el:a})}let e=r.padding;isFinite(e)||(e=0);o=i.model,a=s?0:o.angle(),r=t.center();a&&r.rotate(o.getCenter(),-a),t.inflate(e),n.setAttribute("x",-t.width/2),n.setAttribute("y",-t.height/2),n.setAttribute("width",t.width),n.setAttribute("height",t.height),n.setAttribute("transform",`translate(${r.x},${r.y}) rotate(${a})`)}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var{relatedView:e,paper:n}=this;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleExtras(!0),e.model.startBatch("control-move",{ui:!0,tool:this.cid}))},onPointerMove:function(t){var{relatedView:e,paper:n}=this,i=e.model,{clientX:r,clientY:o}=k(t),n=n.clientToLocalPoint(r,o),r=i.getRelativePointFromAbsolute(n);this.setPosition(e,r,t),this.update()},onPointerUp:function(t){var{relatedView:e,paper:n}=this;n.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(t){var e=this.relatedView;this.resetPosition(e,t),this.update()}}),Od=(r=Nd.extend({xAxisVector:new A(1,0),children(){var{buttonColor:t="#333",iconColor:e="#fff",outlineColor:n="#fff"}=this.options;return[{selector:"handle",tagName:"g",attributes:{cursor:"grab"},children:[{tagName:"circle",attributes:{r:10,fill:t,stroke:n}},{tagName:"path",attributes:{d:"M -5 0 A 5 5 0 1 1 0 5",fill:"transparent",stroke:e,strokeWidth:2,strokeLinecap:"round"}},{tagName:"path",attributes:{d:"M -3 5 L 0 2.5 0 7.5 Z",fill:e,stroke:e,strokeWidth:1,transform:"rotate(-5, -3, 5)"}}]}]},getPosition(t){var{offset:e=0}=this.options,{x:e=0,y:n=0}="number"==typeof e?{x:0,y:e}:e,i=this.getLabel(),i=this.getLabelPosition(i),r=t.getLabelCoordinates(i);let{angle:o=0,args:s={}}=i;s.keepGradient&&(i=t.getTangentAtRatio(t.getClosestPointRatio(r)))&&(o+=i.vector().vectorAngle(this.xAxisVector)||0);t=(new DOMMatrix).translate(r.x,r.y).rotate(o).translate(e,n);return new A(t.e,t.f)},computeVisibility(){return Nd.prototype.computeVisibility.apply(this,arguments)&&!!this.getLabel()},setPosition(t,e){var n=t.model,i=this.getLabel();i&&(i=this.getLabelPosition(i),t=90-t.getLabelCoordinates(i).theta(e),i=this.getLabelIndex(),n.prop(["labels",i,"position","angle"],t))},resetPosition(t){var t=t.model,e=this.getLabelIndex();t.prop(["labels",e,"position","angle"],0)},getLabelIndex(){return this.options.labelIndex||0},getLabel(){return this.relatedView.model.label(this.getLabelIndex())||null},getLabelPosition(t){var e=this.relatedView,t=e._normalizeLabelPosition(t.position);return e._mergeLabelPositionProperty(t,e._getDefaultLabelPositionProperty())}}),a=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(){var t=this.vel;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){var t=this.relatedView;let{x:e=0,y:n=0,offset:i={},useModelGeometry:r,rotate:o,scale:s,relative:a}=Cd(this),l=kd(t,{useModelGeometry:r,relative:a});var t=t.model.angle(),{x:h=0,y:u=0}=(o||(l=l.bbox(t)),i);Sl(e)?e=parseFloat(e)/100*l.width:ph(e)&&(e=Number(vh(e,l))),Sl(n)?n=parseFloat(n)/100*l.height:ph(n)&&(n=Number(vh(n,l)));let c=R.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return c=(c=o&&!a?c.rotate(t):c).translate(e+h-l.width/2,n+u-l.height/2),c=s?c.scale(s):c},getLinkMatrix(){var{relatedView:t,options:e}=this,{offset:e=0,distance:n=0,rotate:i,scale:r}=e,n="function"==typeof n?n.call(this,t,this):n;let o,s,a,l=(o=Sl(n)?t.getTangentAtRatio(parseFloat(n)/100):t.getTangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=t.getConnection().start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,e));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},onPointerDown:function(t){var e;this.guard(t)||(t.stopPropagation(),t.preventDefault(),"function"==typeof(e=this.options.action)&&e.call(this.relatedView,t,this.relatedView,this))}}),i=a.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})}}}),f=Ld.extend({name:"boundary",tagName:"rect",options:{padding:10,useModelGeometry:!1},attributes:{fill:"none",stroke:"#33334F","stroke-width":.5,"stroke-dasharray":"5, 5","pointer-events":"none"},onRender:function(){this.update()},update:function(){var{relatedView:t,vel:e}=this,{useModelGeometry:n,rotate:i,relative:r,padding:o}=Cd(this),o=Ol(o);let s=kd(t,{useModelGeometry:n,relative:r}).moveAndExpand({x:-o.left,y:-o.top,width:o.left+o.right,height:o.top+o.bottom});n=t.model;return n.isElement()&&!r&&(o=n.angle())&&(i?(t=n.getCenter(),e.rotate(o,t.x,t.y,{absolute:!0})):s=s.bbox(o)),e.attr(s.toJSON()),this}}),a.extend({name:"connect",documentEvents:{mousemove:"drag",touchmove:"drag",mouseup:"dragend",touchend:"dragend",touchcancel:"dragend"},children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2,"pointer-events":"none"}}],options:{distance:80,offset:0,magnet:t=>t.el,action:(t,e,n)=>n.dragstart(t)},getMagnetNode:function(){var{options:t,relatedView:e}=this,n=t.magnet;let i;switch(typeof n){case"function":i=n.call(this,e,this);break;case"string":i=e.findNode(n);break;default:i=n}if((i=i||e.el)instanceof SVGElement)return i;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var{paper:e,relatedView:n}=this,t=k(t),{x:i,y:r}=e.clientToLocalPoint(t.clientX,t.clientY);n.dragLinkStart(t,this.getMagnetNode(),i,r),e.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.focus()},drag:function(t){var{paper:e,relatedView:n}=this,t=k(t),{x:e,y:i}=e.snapToGrid(t.clientX,t.clientY);n.dragLink(t,e,i)},dragend:function(t){var{paper:e,relatedView:n}=this,t=k(t),{x:i,y:r}=e.snapToGrid(t.clientX,t.clientY);n.dragLinkEnd(t,i,r),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),n.checkMouseleave(t)}}));var Rd=Od.extend({name:"hover-connect",defaultMarkup:[{tagName:"circle",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2}}],children(){var{options:t,defaultMarkup:e}=this;return[{tagName:"path",selector:"track",attributes:{fill:"none",stroke:"transparent","stroke-width":t.trackWidth||15,cursor:"pointer"}},{tagName:"g",selector:"button",attributes:{"pointer-events":"none",display:"none"},children:t.markup||e}]},events:Object.assign({mousemove:"onMousemove",mouseenter:"onMouseenter",mouseleave:"onMouseleave"},Od.prototype.events),onRender:function(){this.renderChildren(),this.update()},trackPath:null,update(){var t=this.childNodes;this.trackPath=this.getTrackPath(),Od.prototype.update.apply(this,arguments),t.track.setAttribute("d",this.trackPath.serialize())},position(){var{el:t,childNodes:e}=this;e.button.setAttribute("transform",R.matrixToTransformString(this.getButtonMatrix())),t.setAttribute("transform",R.matrixToTransformString(this.getTrackMatrix()))},getButtonMatrix(){var{options:t,trackPath:e}=this,{offset:t=0,distance:n=0,rotate:i,scale:r}=t;let o,s,a,l=(o=Sl(n)?e.tangentAtRatio(parseFloat(n)/100):e.tangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=e.start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,t));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},getTrackPath(){return this.relatedView.getConnection()},getTrackMatrix(){return R.createSVGMatrix()},getTrackMatrixAbsolute(){return this.getTrackMatrix()},getTrackRatioFromEvent(t){var{relatedView:e,trackPath:n}=this,e=e.paper.clientToLocalPoint(t.clientX,t.clientY),t=R.transformPoint(e,this.getTrackMatrixAbsolute().inverse());return n.closestPointLength(t)},canShowButton(){return L.event.has(this.paper.el)},showButton(){this.childNodes.button.style.display="block"},hideButton(){this.childNodes.button.style.display=""},onMousemove(t){var e=this.trackPath;e&&(e=this.options,e.distance=this.getTrackRatioFromEvent(t),this.position())},onMouseenter(){this.canShowButton()&&this.showButton()},onMouseleave(){this.hideButton()}}),r={__proto__:null,Boundary:f,Button:a,Connect:Od,Control:Nd,HoverConnect:Rd,Remove:i,RotateLabel:r,Segments:u,SourceAnchor:l,SourceArrowhead:C,TargetAnchor:n,TargetArrowhead:hn,Vertices:o},u=Rd.extend({getTrackPath(){var t=this.relatedView;let{useModelGeometry:e,relative:n,trackPath:i="M 0 0 H calc(w) V calc(h) H 0 Z"}=Cd(this);return ph(i="function"==typeof i?i.call(this,t):i)&&(t=kd(t,{useModelGeometry:e,relative:n}),i=vh(i,t)),new I(R.normalizePathData(i))},getTrackMatrix(){return this.isOverlay()?this.getTrackMatrixAbsolute():R.createSVGMatrix()},getTrackMatrixAbsolute(){var t=this.relatedView,{useModelGeometry:e,rotate:n}=Cd(this);let i=kd(t,{useModelGeometry:e});e=t.model.angle();n||(i=i.bbox(e));let r=R.createSVGMatrix().translate(i.x+i.width/2,i.y+i.height/2);return r=(r=n?r.rotate(e):r).translate(-i.width/2,-i.height/2)}}),l={__proto__:null,Boundary:f,Button:a,Connect:Od,Control:Nd,HoverConnect:u,Remove:i},C=R,n={PortLabel:Xh,Port:Uh};return t.V=R,t.Vectorizer=C,t.anchors=h,t.config=hl,t.connectionPoints=Je,t.connectionStrategies=nc,t.connectors=Su,t.dia=s,t.elementTools=l,t.env=Kh,t.format={},t.g=yr,t.highlighters=Ke,t.layout=n,t.linkAnchors=id,t.linkTools=r,t.mvc=e,t.routers=Qc,t.setTheme=function(t,e){e=e||{},Xs(ku,"setTheme",t,e),Cu.prototype.defaultTheme=t},t.shapes=Ue,t.ui={},t.util=Zr,t.version="4.2.0-alpha.1",t})({});void 0!==joint&&(g=joint.g,V=joint.V,Vectorizer=joint.V);
|