@joint/core 4.0.2 → 4.0.3
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 +1 -1
- package/dist/geometry.js +1 -1
- package/dist/geometry.min.js +1 -1
- package/dist/joint.d.ts +3 -1
- package/dist/joint.js +37 -13
- package/dist/joint.min.js +2 -2
- package/dist/joint.nowrap.js +37 -13
- package/dist/joint.nowrap.min.js +2 -2
- package/dist/vectorizer.js +1 -1
- package/dist/vectorizer.min.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +3 -2
- package/src/dia/CellView.mjs +11 -6
- package/src/dia/layers/GridLayer.mjs +6 -2
- package/src/dia/ports.mjs +7 -0
- package/src/linkTools/Arrowhead.mjs +3 -1
- package/src/mvc/View.mjs +9 -7
- package/types/joint.d.ts +2 -0
package/dist/joint.nowrap.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! JointJS v4.0.
|
|
1
|
+
/*! JointJS v4.0.3 (2024-05-14) - JavaScript diagramming library
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
5
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
6
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
7
|
*/
|
|
8
|
-
var joint=function(t){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t,e){return t(e={exports:{}},e.exports),e.exports}var i=function(t){return t&&t.Math==Math&&t},h=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof e&&e)||function(){return this}()||Function("return this")(),a=function(t){try{return!!t()}catch(t){return!0}},s=!a(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),r={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,u={f:o&&!r.call({1:2},1)?function(t){var e=o(this,t);return!!e&&e.enumerable}:r},w=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},l={}.toString,c=function(t){return l.call(t).slice(8,-1)},d="".split,x=a(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==c(t)?d.call(t,""):Object(t)}:Object,f=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},p=function(t){return x(f(t))},g=function(t){return"object"==typeof t?null!==t:"function"==typeof t},v=function(t,e){if(!g(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!g(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!g(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!g(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},m={}.hasOwnProperty,y=function(t,e){return m.call(t,e)},b=h.document,A=g(b)&&g(b.createElement),T=function(t){return A?b.createElement(t):{}},P=!s&&!a(function(){return 7!=Object.defineProperty(T("div"),"a",{get:function(){return 7}}).a}),E=Object.getOwnPropertyDescriptor,S={f:s?E:function(t,e){if(t=p(t),e=v(e,!0),P)try{return E(t,e)}catch(t){}if(y(t,e))return w(!u.f.call(t,e),t[e])}},k=function(t){if(!g(t))throw TypeError(String(t)+" is not an object");return t},M=Object.defineProperty,L={f:s?M:function(t,e,n){if(k(t),e=v(e,!0),k(n),P)try{return M(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}},C=s?function(t,e,n){return L.f(t,e,w(1,n))}:function(t,e,n){return t[e]=n,t},_=function(e,n){try{C(h,e,n)}catch(t){h[e]=n}return n},N="__core-js_shared__",O=h[N]||_(N,{}),R=Function.toString;"function"!=typeof O.inspectSource&&(O.inspectSource=function(t){return R.call(t)});var F,B,V,I=O.inspectSource,D=h.WeakMap,j="function"==typeof D&&/native code/.test(I(D)),z=n(function(t){(t.exports=function(t,e){return O[t]||(O[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),G=0,U=Math.random(),H=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++G+U).toString(36)},q=z("keys"),W=function(t){return q[t]||(q[t]=H(t))},Y={},X=h.WeakMap;if(j){var $=O.state||(O.state=new X),Z=$.get,J=$.has,K=$.set;F=function(t,e){return e.facade=t,K.call($,t,e),e},B=function(t){return Z.call($,t)||{}},V=function(t){return J.call($,t)}}else{var Q=W("state");Y[Q]=!0,F=function(t,e){return e.facade=t,C(t,Q,e),e},B=function(t){return y(t,Q)?t[Q]:{}},V=function(t){return y(t,Q)}}var tt,et={set:F,get:B,has:V,enforce:function(t){return V(t)?B(t):F(t,{})},getterFor:function(n){return function(t){var e;if(!g(t)||(e=B(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},nt=n(function(t){var e=et.get,u=et.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,a=!!i&&!!i.enumerable,s=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||y(n,"name")||C(n,"name",e),(r=u(n)).source||(r.source=l.join("string"==typeof e?e:""))),t!==h?(o?!s&&t[e]&&(a=!0):delete t[e],a?t[e]=n:C(t,e,n)):a?t[e]=n:_(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||I(this)})}),it=h,rt=function(t){return"function"==typeof t?t:void 0},ot=function(t,e){return arguments.length<2?rt(it[t])||rt(h[t]):it[t]&&it[t][e]||h[t]&&h[t][e]},at=Math.ceil,st=Math.floor,ut=function(t){return isNaN(t=+t)?0:(0<t?st:at)(t)},lt=Math.min,ht=function(t){return 0<t?lt(ut(t),9007199254740991):0},ct=Math.max,dt=Math.min,ft=function(l){return function(t,e,n){var i,r,o,a=p(t),s=ht(a.length),u=(i=s,(r=ut(n))<0?ct(r+i,0):dt(r,i));if(l&&e!=e){for(;u<s;)if((o=a[u++])!=o)return!0}else for(;u<s;u++)if((l||u in a)&&a[u]===e)return l||u||0;return!l&&-1}},pt={includes:ft(!0),indexOf:ft(!1)},gt=pt.indexOf,vt=function(t,e){var n,i=p(t),r=0,o=[];for(n in i)!y(Y,n)&&y(i,n)&&o.push(n);for(;e.length>r;)y(i,n=e[r++])&&(~gt(o,n)||o.push(n));return o},mt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],yt=mt.concat("length","prototype"),bt={f:Object.getOwnPropertyNames||function(t){return vt(t,yt)}},wt={f:Object.getOwnPropertySymbols},xt=ot("Reflect","ownKeys")||function(t){var e=bt.f(k(t)),n=wt.f;return n?e.concat(n(t)):e},At=function(t,e){for(var n=xt(e),i=L.f,r=S.f,o=0;o<n.length;o++){var a=n[o];y(t,a)||i(t,a,r(e,a))}},Tt=/#|\.prototype\./,Pt=function(t,e){var n=St[Et(t)];return n==Mt||n!=kt&&("function"==typeof e?a(e):!!e)},Et=Pt.normalize=function(t){return String(t).replace(Tt,".").toLowerCase()},St=Pt.data={},kt=Pt.NATIVE="N",Mt=Pt.POLYFILL="P",Lt=Pt,Ct=S.f,_t=function(t,e){var n,i,r,o,a,s=t.target,u=t.global,l=t.stat;if(n=u?h:l?h[s]||_(s,{}):(h[s]||{}).prototype)for(i in e){if(o=e[i],r=t.noTargetGet?(a=Ct(n,i))&&a.value:n[i],!Lt(u?i:s+(l?".":"#")+i,t.forced)&&void 0!==r){if(typeof o==typeof r)continue;At(o,r)}(t.sham||r&&r.sham)&&C(o,"sham",!0),nt(n,i,o,t)}},Nt=!!Object.getOwnPropertySymbols&&!a(function(){return!String(Symbol())}),Ot=Nt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Rt=z("wks"),Ft=h.Symbol,Bt=Ot?Ft:Ft&&Ft.withoutSetter||H,Vt=function(t){return y(Rt,t)||(Nt&&y(Ft,t)?Rt[t]=Ft[t]:Rt[t]=Bt("Symbol."+t)),Rt[t]},It=Object.keys||function(t){return vt(t,mt)},Dt=s?Object.defineProperties:function(t,e){k(t);for(var n,i=It(e),r=i.length,o=0;o<r;)L.f(t,n=i[o++],e[n]);return t},jt=ot("document","documentElement"),zt="prototype",Gt="script",Ut=W("IE_PROTO"),Ht=function(){},qt=function(t){return"<script>"+t+"</"+Gt+">"},Wt=function(){try{tt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;Wt=tt?function(t){t.write(qt("")),t.close();var e=t.parentWindow.Object;return t=null,e}(tt):((e=T("iframe")).style.display="none",jt.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(qt("document.F=Object")),t.close(),t.F);for(var n=mt.length;n--;)delete Wt[zt][mt[n]];return Wt()};Y[Ut]=!0;var Yt=Object.create||function(t,e){var n;return null!==t?(Ht[zt]=k(t),n=new Ht,Ht[zt]=null,n[Ut]=t):n=Wt(),void 0===e?n:Dt(n,e)},Xt=Vt("unscopables"),$t=Array.prototype;null==$t[Xt]&&L.f($t,Xt,{configurable:!0,value:Yt(null)});var Zt=function(t){$t[Xt][t]=!0},Jt=Object.defineProperty,Kt={},Qt=function(t){throw t},te=function(t,e){if(y(Kt,t))return Kt[t];e||(e={});var n=[][t],i=!!y(e,"ACCESSORS")&&e.ACCESSORS,r=y(e,0)?e[0]:Qt,o=y(e,1)?e[1]:void 0;return Kt[t]=!!n&&!a(function(){if(i&&!s)return!0;var t={length:-1};i?Jt(t,1,{enumerable:!0,get:Qt}):t[1]=1,n.call(t,r,o)})},ee=pt.includes,ne=te("indexOf",{ACCESSORS:!0,1:0});_t({target:"Array",proto:!0,forced:!ne},{includes:function(t){return ee(this,t,1<arguments.length?arguments[1]:void 0)}}),Zt("includes");var ie=function(i,r,t){if(function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function")}(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)}},re=Function.call,oe=function(t,e,n){return ie(re,h[t].prototype[e],n)},ae=(oe("Array","includes"),function(t){return Object(f(t))}),se=Array.isArray||function(t){return"Array"==c(t)},ue=Vt("species"),le=function(t,e){var n;return se(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!se(n.prototype)?g(n)&&null===(n=n[ue])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},he=[].push,ce=function(f){var p=1==f,g=2==f,v=3==f,m=4==f,y=6==f,b=7==f,w=5==f||y;return function(t,e,n,i){for(var r,o,a=ae(t),s=x(a),u=ie(e,n,3),l=ht(s.length),h=0,c=i||le,d=p?c(t,l):g||b?c(t,0):void 0;h<l;h++)if((w||h in s)&&(o=u(r=s[h],h,a),f))if(p)d[h]=o;else if(o)switch(f){case 3:return!0;case 5:return r;case 6:return h;case 2:he.call(d,r)}else switch(f){case 4:return!1;case 7:he.call(d,r)}return y?-1:v||m?m:d}},de={forEach:ce(0),map:ce(1),filter:ce(2),some:ce(3),every:ce(4),find:ce(5),findIndex:ce(6),filterOut:ce(7)},fe=de.find,pe="find",ge=!0,ve=te(pe);pe in[]&&Array(1)[pe](function(){ge=!1}),_t({target:"Array",proto:!0,forced:ge||!ve},{find:function(t){return fe(this,t,1<arguments.length?arguments[1]:void 0)}}),Zt(pe);oe("Array","find");var me,ye,be,we=function(s){return function(t,e){var n,i,r=String(f(t)),o=ut(e),a=r.length;return o<0||a<=o?s?"":void 0:(n=r.charCodeAt(o))<55296||56319<n||o+1===a||(i=r.charCodeAt(o+1))<56320||57343<i?s?r.charAt(o):n:s?r.slice(o,o+2):i-56320+(n-55296<<10)+65536}},xe={codeAt:we(!1),charAt:we(!0)},Ae=!a(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Te=W("IE_PROTO"),Pe=Object.prototype,Ee=Ae?Object.getPrototypeOf:function(t){return t=ae(t),y(t,Te)?t[Te]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Pe:null},Se=Vt("iterator"),ke=!1;[].keys&&("next"in(be=[].keys())?(ye=Ee(Ee(be)))!==Object.prototype&&(me=ye):ke=!0);var Me=null==me||a(function(){var t={};return me[Se].call(t)!==t});Me&&(me={}),y(me,Se)||C(me,Se,function(){return this});var Le={IteratorPrototype:me,BUGGY_SAFARI_ITERATORS:ke},Ce=L.f,_e=Vt("toStringTag"),Ne=function(t,e,n){t&&!y(t=n?t:t.prototype,_e)&&Ce(t,_e,{configurable:!0,value:e})},Oe={},Re=Le.IteratorPrototype,Fe=function(){return this},Be=Object.setPrototypeOf||("__proto__"in{}?function(){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 k(t),function(t){if(!g(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(e),i?n.call(t,e):t.__proto__=e,t}}():void 0),Ve=Le.IteratorPrototype,Ie=Le.BUGGY_SAFARI_ITERATORS,De=Vt("iterator"),je="values",ze="entries",Ge=function(){return this},Ue=xe.charAt,He="String Iterator",qe=et.set,We=et.getterFor(He);!function(t,e,n,i,r,o,a){var s,u,l;u=i,l=e+" Iterator",(s=n).prototype=Yt(Re,{next:w(1,u)}),Ne(s,l,!1),Oe[l]=Fe;var h,c,d,f=function(t){if(t===r&&y)return y;if(!Ie&&t in v)return v[t];switch(t){case"keys":case je:case ze:return function(){return new n(this,t)}}return function(){return new n(this)}},p=e+" Iterator",g=!1,v=t.prototype,m=v[De]||v["@@iterator"]||r&&v[r],y=!Ie&&m||f(r),b="Array"==e&&v.entries||m;if(b&&(h=Ee(b.call(new t)),Ve!==Object.prototype&&h.next&&(Ee(h)!==Ve&&(Be?Be(h,Ve):"function"!=typeof h[De]&&C(h,De,Ge)),Ne(h,p,!0))),r==je&&m&&m.name!==je&&(g=!0,y=function(){return m.call(this)}),v[De]!==y&&C(v,De,y),Oe[e]=y,r)if(c={values:f(je),keys:o?y:f("keys"),entries:f(ze)},a)for(d in c)!Ie&&!g&&d in v||nt(v,d,c[d]);else _t({target:e,proto:!0,forced:Ie||g},c)}(String,"String",function(t){qe(this,{type:He,string:String(t),index:0})},function(){var t,e=We(this),n=e.string,i=e.index;return i>=n.length?{value:void 0,done:!0}:(t=Ue(n,i),e.index+=t.length,{value:t,done:!1})});var Ye=function(e,t,n,i){try{return i?t(k(n)[0],n[1]):t(n)}catch(t){throw function(t){var e=t.return;if(void 0!==e)k(e.call(t)).value}(e),t}},Xe=Vt("iterator"),$e=Array.prototype,Ze=function(t,e,n){var i=v(e);i in t?L.f(t,i,w(0,n)):t[i]=n},Je={};Je[Vt("toStringTag")]="z";var Ke="[object z]"===String(Je),Qe=Vt("toStringTag"),tn="Arguments"==c(function(){return arguments}()),en=Ke?c:function(t){var e,n,i;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Qe))?n:tn?c(e):"Object"==(i=c(e))&&"function"==typeof e.callee?"Arguments":i},nn=Vt("iterator"),rn=Vt("iterator"),on=!1;try{var an=0,sn={next:function(){return{done:!!an++}},return:function(){on=!0}};sn[rn]=function(){return this},Array.from(sn,function(){throw 2})}catch(t){}var un=!function(t,e){if(!e&&!on)return!1;var n=!1;try{var i={};i[rn]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n}(function(t){Array.from(t)});_t({target:"Array",stat:!0,forced:un},{from:function(t){var e,n,i,r,o,a,s,u=ae(t),l="function"==typeof this?this:Array,h=arguments.length,c=1<h?arguments[1]:void 0,d=void 0!==c,f=function(t){if(null!=t)return t[nn]||t["@@iterator"]||Oe[en(t)]}(u),p=0;if(d&&(c=ie(c,2<h?arguments[2]:void 0,2)),null!=f&&(l!=Array||void 0===(s=f)||Oe.Array!==s&&$e[Xe]!==s))for(o=(r=f.call(u)).next,n=new l;!(i=o.call(r)).done;p++)a=d?Ye(r,c,[i.value,p],!0):i.value,Ze(n,p,a);else for(n=new l(e=ht(u.length));p<e;p++)a=d?c(u[p],p):u[p],Ze(n,p,a);return n.length=p,n}});it.Array.from;var ln=de.findIndex,hn="findIndex",cn=!0,dn=te(hn);hn in[]&&Array(1)[hn](function(){cn=!1}),_t({target:"Array",proto:!0,forced:cn||!dn},{findIndex:function(t){return ln(this,t,1<arguments.length?arguments[1]:void 0)}}),Zt(hn);oe("Array","findIndex"),n(function(t,e){!function(){var t=e,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function u(t){this.message=t}(u.prototype=new Error).name="InvalidCharacterError",t.btoa||(t.btoa=function(t){for(var e,n,i=String(t),r=0,o=s,a="";i.charAt(0|r)||(o="=",r%1);a+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new u("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return a}),t.atob||(t.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,a="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)?a+=String.fromCharCode(255&n>>(-2*r&6)):0)i=s.indexOf(i);return a})}()});_t({target:"Number",stat:!0},{isNaN:function(t){return t!=t}});it.Number.isNaN;var fn=h.isFinite,pn=Number.isFinite||function(t){return"number"==typeof t&&fn(t)};_t({target:"Number",stat:!0},{isFinite:pn});it.Number.isFinite;var gn=Vt("match"),vn=function(t){if(g(e=t)&&(void 0!==(n=e[gn])?n:"RegExp"==c(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t},mn=Vt("match"),yn=function(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[mn]=!1,"/./"[e](n)}catch(t){}}return!1};_t({target:"String",proto:!0,forced:!yn("includes")},{includes:function(t){return!!~String(f(this)).indexOf(vn(t),1<arguments.length?arguments[1]:void 0)}});oe("String","includes");var bn,wn=S.f,xn="".startsWith,An=Math.min,Tn=yn("startsWith"),Pn=!(Tn||(!(bn=wn(String.prototype,"startsWith"))||bn.writable));_t({target:"String",proto:!0,forced:!Pn&&!Tn},{startsWith:function(t){var e=String(f(this));vn(t);var n=ht(An(1<arguments.length?arguments[1]:void 0,e.length)),i=String(t);return xn?xn.call(e,i,n):e.slice(n,n+i.length)===i}});oe("String","startsWith");!function(){function i(t,e){return this.slice(t,e)}function r(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function t(t){var e;if("number"==typeof t){e=new Array(t);for(var n=0;n<t;++n)e[n]=0}else e=t.slice(0);return e.subarray=i,(e.buffer=e).byteLength=e.length,e.set=r,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Uint8Array=t,window.Uint32Array=t,window.Int32Array=t)}();var En={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},Sn=Object.keys(En).map(function(t){return En[t]}).join(""),kn="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",Mn=/\s/g,Ln=new RegExp("^("+kn+"\\*)?(["+Sn+"])(/"+kn+")?([-+]{1,2}"+kn+")?$","g");function Cn(t){throw new Error("Invalid calc() expression: "+t)}function _n(t,e){var n=Ln.exec(t.replace(Mn,""));n||Cn(t),Ln.lastIndex=0;var i=n[1],r=n[2],o=n[3],a=n[4],s=e.x,u=e.y,l=e.width,h=e.height,c=0;switch(r){case En.width:c=l;break;case En.height:c=h;break;case En.x:c=s;break;case En.y:c=u;break;case En.minimum:c=Math.min(h,l);break;case En.maximum:c=Math.max(h,l);break;case En.diagonal:c=Math.sqrt(h*h+l*l)}return i&&(c*=parseFloat(i)),o&&(c/=parseFloat(o.slice(1))),a&&(c+=function(t){if(!t)return 0;switch(t[0]){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(a)),c}function Nn(t){return"string"==typeof t&&t.includes("calc")}var On="calc(",Rn=On.length;function Fn(t,e){for(var n=t,i=0;;){var r=n.indexOf(On,i);if(-1===r)return n;var o=r+Rn,a=1;t:for(;;){switch(n[o]){case"(":a++;break;case")":if(0===--a)break t;break;case void 0:Cn(n)}o++}var s=n.slice(r+Rn,o);Nn(s)&&(s=Fn(s,e));var u=String(_n(s,e));n=n.slice(0,r)+u+n.slice(o+1),i=r+u.length}}var Bn=Math.round,Vn=Math.floor,In=Math.PI,Dn=function(t){return t%360+(t<0?360:0)},jn=function(t,e){return e*Bn(t/e)},zn=function(t){return 180*t/In%360},Gn=function(t,e){return(t=(e=e||!1)?t:t%360)*In/180},Un=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){var n=t;t=e,e=n}return Vn(Math.random()*(e-t+1)+t)},Hn=Math.cos,qn=Math.sin,Wn=Math.atan2,Yn=function(t,e){var n=Gn(t.y),i=Gn(e.y),r=t.x,o=e.x,a=Gn(o-r),s=qn(a)*Hn(i),u=Hn(n)*qn(i)-qn(n)*Hn(i)*Hn(a),l=zn(Wn(s,u))-22.5;return l<0&&(l+=360),["NE","E","SE","S","SW","W","NW","N"][l=parseInt(l/45)]},Xn=function(t,e){var n=t.x,i=t.y;return(n-=e.x)*n+(i-=e.y)*i},$n=function(t,e){return Math.sqrt(Xn(t,e))},Zn={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},Jn=Math.abs,Kn=Math.cos,Qn=Math.sin,ti=Math.sqrt,ei=Math.min,ni=Math.max,ii=Math.atan2,ri=Math.round,oi=Math.pow,ai=Math.PI,si=function(t,e){if(!(this instanceof si))return new si(t,e);if("string"==typeof t){var n=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(n[0]),e=parseFloat(n[1])}else Object(t)===t&&(e=t.y,t=t.x);this.x=void 0===t?0:t,this.y=void 0===e?0:e};si.fromPolar=function(t,e,n){n=new si(n);var i=Jn(t*Kn(e)),r=Jn(t*Qn(e)),o=Dn(zn(e));return o<90?r=-r:o<180?(i=-i,r=-r):o<270&&(i=-i),new si(n.x+i,n.y+r)},si.random=function(t,e,n,i){return new si(Un(t,e),Un(n,i))},si.prototype={type:Zn.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new si(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new si(t[r]),a=this.squaredDistance(o);a<i&&(n=o,i=a)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=ei(ni(this.x,t.x),t.x+t.width),this.y=ei(ni(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var n=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return Yn(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new si(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 si(this.x-(t||0),this.y-(e||0))},distance:function(t){return $n(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 si((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ti(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return Jn(t.x-this.x)+Jn(t.y-this.y)},move:function(t,e){var n=Gn(new si(t).theta(this));return this.offset(Kn(n)*e,-Qn(n)*e)},normalize:function(t){var e=(t||1)/this.magnitude();return this.scale(e,e)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new si(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new si(0,0),e=Gn(Dn(-e));var n=Kn(e),i=Qn(e),r=n*(this.x-t.x)-i*(this.y-t.y)+t.x,o=i*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=r,this.y=o,this},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=oi(10,t)}return this.x=ri(this.x*e)/e,this.y=ri(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new si(n)||new si(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=jn(this.x,t),this.y=jn(this.y,e||t),this},squaredDistance:function(t){return Xn(this,t)},theta:function(t){var e=-((t=new si(t)).y-this.y),n=t.x-this.x,i=ii(e,n);return i<0&&(i=2*ai+i),180*i/ai},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new si(t)||new si(0,0);var e=this.x,n=this.y;return this.x=ti((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Gn(t.theta(new si(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 si(0,0).angleBetween(this,t)}},si.prototype.translate=si.prototype.offset;var ui=si,li=Math.max,hi=Math.min,ci=function(t,e){return this instanceof ci?t instanceof ci?new ci(t.start,t.end):(this.start=new si(t),void(this.end=new si(e))):new ci(t,e)};ci.prototype={type:Zn.Line,angle:function(){var t=new si(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=hi(this.start.x,this.end.x),e=hi(this.start.y,this.end.y),n=li(this.start.x,this.end.x),i=li(this.start.y,this.end.y);return new Ei(t,e,n-t,i-e)},bearing:function(){return Yn(this.start,this.end)},clone:function(){return new ci(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){var e=this.vector().dot(new ci(this.start,t).vector()),n=hi(1,li(0,e/this.squaredLength()));return n!=n?0:n},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,n=this.end;if(0!==e.cross(t,n))return!1;var i=this.length();return!(new ci(e,t).length()>i)&&!(new ci(t,n).length()>i)},divideAt:function(t){var e=this.pointAt(t);return[new ci(this.start,e),new ci(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new ci(this.start,e),new ci(e,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){if(t&&t.intersectionWithLine){var n=t.intersectionWithLine(this,e);return n&&t instanceof ci&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new si(this.end.x-this.start.x,this.end.y-this.start.y),n=new si(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,r=new si(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,a=r.x*e.y-r.y*e.x;if(0===i||o*i<0||a*i<0)return null;if(0<i){if(i<o||i<a)return null}else if(o<i||a<i)return null;return[new si(this.start.x+o*e.x/i,this.start.y+o*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return $n(this.start,this.end)},midpoint:function(){return new si((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e=this.clone();if(!this.isDifferentiable())return e;var n=e.start,i=e.end,r=n.clone().rotate(i,270),o=i.clone().rotate(n,90);return n.move(o,t),i.move(r,t),e},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0;t<0&&(i=!1,t=-t);var r=this.length();return r<=t?i?n.clone():e.clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new si(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();if(!e)return this;var n=t/e;return this.scale(n,n,this.start)},squaredLength:function(){return Xn(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAt(t),r=new ci(e,n);return r.translate(i.x-e.x,i.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAtLength(t),r=new ci(e,n);return r.translate(i.x-e.x,i.y-e.y),r},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new si(this.end.x-this.start.x,this.end.y-this.start.y)}},ci.prototype.intersection=ci.prototype.intersect;var di=ci,fi=Math.sqrt,pi=Math.round,gi=Math.pow,vi=function(t,e,n){return this instanceof vi?t instanceof vi?new vi(new si(t.x,t.y),t.a,t.b):(t=new si(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new vi(t,e,n)};vi.fromRect=function(t){return t=new Ei(t),new vi(t.center(),t.width/2,t.height/2)},vi.prototype={type:Zn.Ellipse,bbox:function(){return new Ei(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new si(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,a=t.vector(),s=n.difference(new si(this)),u=new si(a.x/(r*r),a.y/(o*o)),l=new si(s.x/(r*r),s.y/(o*o)),h=a.dot(u),c=a.dot(l),d=c*c-h*(s.dot(l)-1);if(d<0)return null;if(0<d){var f=fi(d),p=(-c-f)/h,g=(-c+f)/h;if((p<0||1<p)&&(g<0||1<g))return null;0<=p&&p<=1&&e.push(n.lerp(i,p)),0<=g&&g<=1&&e.push(n.lerp(i,g))}else{var v=-c/h;if(!(0<=v&&v<=1))return null;e.push(n.lerp(i,v))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new si(t),e&&t.rotate(new si(this.x,this.y),e);var n,i=t.x-this.x,r=t.y-this.y;if(0===i)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new si(this.x,this.y),-e):n;var o=r/i,a=o*o,s=this.a*this.a,u=this.b*this.b,l=fi(1/(1/s+a/u)),h=o*(l=i<0?-l:l);return n=new si(this.x+l,this.y+h),e?n.rotate(new si(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,i=this.a,r=this.b,o=this.x,a=this.y;return(e-o)*(e-o)/(i*i)+(n-a)*(n-a)/(r*r)},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=gi(10,t)}return this.x=pi(this.x*e)/e,this.y=pi(this.y*e)/e,this.a=pi(this.a*e)/e,this.b=pi(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,a=this.b,s=this.bbox().center(),u=s.x,l=s.y,h=i>s.x+o/2,c=i<s.x-o/2;return h||c?n=o*o/(i-u)-o*o*(r-l)*((e=i>s.x?r-30:r+30)-l)/(a*a*(i-u))+u:e=a*a/(r-l)-a*a*(i-u)*((n=r>s.y?i+30:i-30)-u)/(o*o*(r-l))+l,new si(n,e).theta(t)},toString:function(){return new si(this.x,this.y).toString()+" "+this.a+" "+this.b}};var mi=vi,yi=Math.abs,bi=Math.cos,wi=Math.sin,xi=Math.min,Ai=Math.max,Ti=Math.round,Pi=Math.pow,Ei=function(t,e,n,i){if(!(this instanceof Ei))return new Ei(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};Ei.fromEllipse=function(t){return t=new vi(t),new Ei(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},Ei.fromPointUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var n,i,r,o,a=new si;n=i=1/0,r=o=-1/0;for(var s=0;s<t.length;s++){a.update(t[s]);var u=a.x,l=a.y;u<n&&(n=u),r<u&&(r=u),l<i&&(i=l),o<l&&(o=l)}return new Ei(n,i,r-n,o-i)},Ei.fromRectUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var n,i,r,o,a=new Ei;n=i=1/0,r=o=-1/0;for(var s=0;s<t.length;s++){a.update(t[s]);var u=a.x,l=a.y,h=u+a.width,c=l+a.height;u<n&&(n=u),r<h&&(r=h),l<i&&(i=l),o<c&&(o=c)}return new Ei(n,i,r-n,o-i)},Ei.prototype={type:Zn.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;var e=this.width,n=this.height,i=Gn(t),r=yi(wi(i)),o=yi(bi(i)),a=e*o+n*r,s=e*r+n*o;return this.x+=(e-a)/2,this.y+=(n-s)/2,this.width=a,this.height=s,this},bottomLeft:function(){return new si(this.x,this.y+this.height)},bottomLine:function(){return new ci(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new si(this.x+this.width/2,this.y+this.height)},center:function(){return new si(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new Ei(this)},containsPoint:function(t){return t instanceof si||(t=new si(t)),t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new Ei(this).normalize(),n=new Ei(t).normalize(),i=e.width,r=e.height,o=n.width,a=n.height;if(!(i&&r&&o&&a))return!1;var s=e.x,u=e.y,l=n.x,h=n.y;return o+=l,i+=s,a+=h,r+=u,s<=l&&o<=i&&u<=h&&a<=r},corner:function(){return new si(this.x+this.width,this.y+this.height)},equals:function(t){var e=new Ei(this).normalize(),n=new Ei(t).normalize();return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),n=this.corner(),i=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||i.x>=n.x||i.y>=n.y)return null;var o=Ai(e.x,i.x),a=Ai(e.y,i.y);return new Ei(o,a,xi(n.x,r.x)-o,xi(n.y,r.y)-a)},intersectionWithLine:function(t){var e,n,i=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],r=[],o=[],a=i.length;for(n=0;n<a;n++)null!==(e=t.intersect(i[n]))&&o.indexOf(e.toString())<0&&(r.push(e),o.push(e.toString()));return 0<r.length?r:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new si(t);var n,i=new si(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(i,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new ci(i,t),a=r.length-1;0<=a;--a){var s=r[a].intersection(o);if(null!==s){n=s;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new ci(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new si(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,i,r,o,a,s,u,l;t=new Ei(t),e||(e=t.center());var h=e.x,c=e.y;n=i=r=o=a=s=u=l=1/0;var d=t.topLeft();d.x<h&&(n=(this.x-h)/(d.x-h)),d.y<c&&(a=(this.y-c)/(d.y-c));var f=t.bottomRight();f.x>h&&(i=(this.x+this.width-h)/(f.x-h)),f.y>c&&(s=(this.y+this.height-c)/(f.y-c));var p=t.topRight();p.x>h&&(r=(this.x+this.width-h)/(p.x-h)),p.y<c&&(u=(this.y-c)/(p.y-c));var g=t.bottomLeft();return g.x<h&&(o=(this.x-h)/(g.x-h)),g.y>c&&(l=(this.y+this.height-c)/(g.y-c)),{sx:xi(n,i,r,o),sy:xi(a,s,u,l)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return xi(n.sx,n.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return si.prototype.offset.call(this,t,e)},origin:function(){return new si(this.x,this.y)},pointNearestToPoint:function(t){if(t=new si(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new si(this.x+this.width,t.y);case"left":return new si(this.x,t.y);case"bottom":return new si(t.x,this.y+this.height);case"top":return new si(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new ci(this.topRight(),this.bottomRight())},rightMiddle:function(){return new si(this.x+this.width,this.y+this.height/2)},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Pi(10,t)}return this.x=Ti(this.x*e)/e,this.y=Ti(this.y*e)/e,this.width=Ti(this.width*e)/e,this.height=Ti(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 si(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r=e,o="left";return n<r&&(r=n,o="right"),i<r&&(r=i,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),i=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=i.x-n.x,this.height=i.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new ci(this.topLeft(),this.topRight())},topMiddle:function(){return new si(this.x+this.width/2,this.y)},topRight:function(){return new si(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return Ei.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}},Ei.prototype.bottomRight=Ei.prototype.corner,Ei.prototype.topLeft=Ei.prototype.origin,Ei.prototype.translate=Ei.prototype.offset;var Si=Ei;function ki(t){var e=t.trim();if(""===e)return[];for(var n=[],i=e.split(/\b\s*,\s*|,\s*|\s+/),r=i.length,o=0;o<r;o+=2)n.push({x:+i[o],y:+i[o+1]});return n}function Mi(t){var e=t.length;if(0===e)return[];for(var n=[],i=0;i<e;i++){var r=t[i].clone();n.push(r)}return n}function Li(t){var e,n,i,r=Math.abs,o=t.length;if(0===o)return[];for(e=0;e<o;e++)void 0===i?i=t[e]:t[e].y<i.y?i=t[e]:t[e].y===i.y&&t[e].x>i.x&&(i=t[e]);var a=[];for(e=0;e<o;e++){var s=i.theta(t[e]);0===s&&(s=360);var u=[t[e],e,s];a.push(u)}if(a.sort(function(t,e){var n=t[2]-e[2];return 0===n&&(n=e[1]-t[1]),n}),2<a.length){var l=a[a.length-1];a.unshift(l)}for(var h,c,d,f,p,g,v,m={},y=[];0!==a.length;)if(c=(h=a.pop())[0],!m.hasOwnProperty(h[0]+"@@"+h[1]))for(var b=!1;!b;)if(y.length<2)y.push(h),b=!0;else{f=(d=y.pop())[0];var w=(g=(p=y.pop())[0]).cross(f,c);if(w<0)y.push(p),y.push(d),y.push(h),b=!0;else if(0===w){var x=f.angleBetween(g,c);r(x-180)<1e-10?(m[d[0]+"@@"+d[1]]=f,y.push(p)):f.equals(c)||g.equals(f)?(m[d[0]+"@@"+d[1]]=f,y.push(p)):r((x+1)%360-1)<1e-10&&(y.push(p),a.push(d))}else m[d[0]+"@@"+d[1]]=f,y.push(p)}2<y.length&&y.pop();var A=-1;for(n=y.length,e=0;e<n;e++){var T=y[e][1];(void 0===v||T<v)&&(v=T,A=e)}var P=[];if(0<A){var E=y.slice(A),S=y.slice(0,A);P=E.concat(S)}else P=y;var k=[];for(n=P.length,e=0;e<n;e++)k.push(P[e][0]);return k}var Ci=function(t){return this instanceof Ci?"string"==typeof t?new Ci.parse(t):void(this.points=Array.isArray(t)?t.map(si):[]):new Ci(t)};Ci.parse=function(t){return new Ci(ki(t))},Ci.fromRect=function(t){return new Ci([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},Ci.prototype={type:Zn.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 a=0;a<o;a++){var s=r[a],u=s.x,l=s.y;u<t&&(t=u),e<u&&(e=u),l<n&&(n=l),i<l&&(i=l)}return new Ei(t,n,e-t,i-n)},clone:function(){return new Ci(Mi(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,a=i-1,s=0;s<a;s++){var u=new ci(n[s],n[s+1]),l=u.length(),h=u.closestPointNormalizedLength(t),c=u.pointAt(h).squaredDistance(t);c<r&&(r=c,e=o+h*l),o+=l}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var n=this.length();return 0===n?0:e/n},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,a=0,s=0,u=new ci,l=new ci,h=new si;a<n;a++){var c=e[o],d=e[a];if(t.equals(c))return!0;if(u.start=c,u.end=d,u.containsPoint(t))return!0;if(r<=c.y&&r>d.y||r>c.y&&r<=d.y){var f=c.x-i>d.x-i?c.x-i:d.x-i;0<=f&&(h.x=i+f,h.y=r,l.start=t,l.end=h,u.intersect(l)&&s++)}o=a}return s%2==1},close:function(){var t=this.start,e=this.end,n=this.points;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new Ci(Li(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],a=t.points[r];if(!o.equals(a))return!1}return!0},intersectionWithLine:function(t){for(var e=new ci(t),n=[],i=this.lengthPoints(),r=new ci,o=0,a=i.length-1;o<a;o++){r.start=i[o],r.end=i[o+1];var s=e.intersectionWithLine(r);s&&n.push(s[0])}return 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var n=new ci,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();if(t<=0)return e[0].clone();if(1<=t)return e[n-1].clone();var i=this.length()*t;return this.pointAtLength(i)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var i=!0;t<0&&(i=!1,t=-t);for(var r=0,o=n-1,a=0;a<o;a++){var s=i?a:o-1-a,u=e[s],l=e[s+1],h=new ci(u,l),c=u.distance(l);if(t<=r+c)return h.pointAtLength((i?1:-1)*(t-r));r+=c}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(t){void 0===t&&(t={});var e=this.points;if(e.length<3)return this;for(var n=t.threshold||1e-10,i=0;e[i+2];){var r=i+1,o=i+2,a=e[i],s=e[r],u=e[o];new ci(a,u).closestPoint(s).distance(s)<=n?e.splice(r,1):i+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),1<t&&(t=1);var n=this.length()*t;return this.tangentAtLength(n)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;var i,r=!0;t<0&&(r=!1,t=-t);for(var o=0,a=n-1,s=0;s<a;s++){var u=r?s:a-1-s,l=e[u],h=e[u+1],c=new ci(l,h),d=l.distance(h);if(c.isDifferentiable()){if(t<=o+d)return c.tangentAtLength((r?1:-1)*(t-o));i=c}o+=d}if(i){var f=r?1:0;return i.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(Ci.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(Ci.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});var _i=Math.abs,Ni=Math.sqrt,Oi=Math.min,Ri=Math.max,Fi=Math.pow,Bi=function(t,e,n,i){return this instanceof Bi?t instanceof Bi?new Bi(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new si(t),this.controlPoint1=new si(e),this.controlPoint2=new si(n),void(this.end=new si(i))):new Bi(t,e,n,i)};function Vi(t){var e,n,i=arguments,r=[];for(n=arguments.length,e=1;e<n;e++)r.push(i[e]);if(!t)throw new Error("Missing a parent object.");var o=Object.create(t);for(n=r.length,e=0;e<n;e++){var a,s,u=r[e];for(s in u)u.hasOwnProperty(s)&&(delete o[s],a=Object.getOwnPropertyDescriptor(u,s),Object.defineProperty(o,s,a))}return o}Bi.throughPoints=function(){function u(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}return function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=function(t){var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new si((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new si(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var a=u(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var s=u(o);for(e=0;e<r;e++)n.push(new si(a[e],s[e])),e<r-1?i.push(new si(2*t[e+1].x-a[e+1],2*t[e+1].y-s[e+1])):i.push(new si((t[r].x+a[r-1])/2,(t[r].y+s[r-1])/2));return[n,i]}(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new si(e[0][r].x,e[0][r].y),a=new si(e[1][r].x,e[1][r].y);n.push(new Bi(t[r],o,a,t[r+1]))}return n}}(),Bi.prototype={type:Zn.Curve,bbox:function(){for(var t,e,n,i,r,o,a,s,u=this.start,l=this.controlPoint1,h=this.controlPoint2,c=this.end,d=u.x,f=u.y,p=l.x,g=l.y,v=h.x,m=h.y,y=c.x,b=c.y,w=new Array,x=new Array,A=[new Array,new Array],T=0;T<2;++T)if(n=0===T?(e=6*d-12*p+6*v,t=-3*d+9*p-9*v+3*y,3*p-3*d):(e=6*f-12*g+6*m,t=-3*f+9*g-9*m+3*b,3*g-3*f),_i(t)<1e-12){if(_i(e)<1e-12)continue;0<(i=-n/e)&&i<1&&x.push(i)}else s=Ni(a=e*e-4*n*t),a<0||(0<(r=(-e+s)/(2*t))&&r<1&&x.push(r),0<(o=(-e-s)/(2*t))&&o<1&&x.push(o));for(var P,E,S,k=x.length,M=k;k--;)E=(P=1-(i=x[k]))*P*P*d+3*P*P*i*p+3*P*i*i*v+i*i*i*y,A[0][k]=E,S=P*P*P*f+3*P*P*i*g+3*P*i*i*m+i*i*i*b,A[1][k]=S,w[k]={X:E,Y:S};x[M]=0,x[M+1]=1,w[M]={X:d,Y:f},w[M+1]={X:y,Y:b},A[0][M]=d,A[1][M]=f,A[0][M+1]=y,A[1][M+1]=b,x.length=M+2,A[0].length=M+2,A[1].length=M+2,w.length=M+2;var L=Oi.apply(null,A[0]),C=Oi.apply(null,A[1]),_=Ri.apply(null,A[0]),N=Ri.apply(null,A[1]);return new Ei(L,C,_-L,N-C)},clone:function(){return new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.closestPointLength(t,i);if(!r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){for(var n,i,r,o,a,s,u,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,c=h.length,d=c?1/c:0,f=0;f<c;f++){var p=h[f],g=p.start.distance(t),v=p.end.distance(t),m=g+v;(!u||m<u)&&(i=f*d,r=(f+1)*d,o=g,a=v,s=(n=p).start.distance(p.end),u=m)}for(var y=Fi(10,-l);;){var b=o?_i(o-a)/o:0,w=a?_i(o-a)/a:0;if(b<y||w<y||(!o||o<s*y||(!a||a<s*y)))return o<=a?i:r;var x=n.divide(.5);d/=2;var A=x[0].start.distance(t),T=x[0].end.distance(t),P=A+T,E=x[1].start.distance(t),S=x[1].end.distance(t);a=P<=E+S?(n=x[0],r-=d,o=A,T):(n=x[1],i+=d,o=E,S)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(1<=t)return this.divideAtT(1);var n=this.tAt(t,e);return this.divideAtT(n)},divideAtLength:function(t,e){var n=this.tAtLength(t,e);return this.divideAtT(n)},divideAtT:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return[new Bi(e,e,e,e),new Bi(e,n,i,r)];if(1<=t)return[new Bi(e,n,i,r),new Bi(r,r,r,r)];var o=this.getSkeletonPoints(t),a=o.startControlPoint1,s=o.startControlPoint2,u=o.divider,l=o.dividerControlPoint1,h=o.dividerControlPoint2;return[new Bi(e,a,s,u),new Bi(u,l,h,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()};if(1<=t)return{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new ci(e,n).pointAt(t),a=new ci(n,i).pointAt(t),s=new ci(i,r).pointAt(t),u=new ci(o,a).pointAt(t),l=new ci(a,s).pointAt(t);return{startControlPoint1:o,startControlPoint2:u,divider:new ci(u,l).pointAt(t),dividerControlPoint1:l,dividerControlPoint2:s}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,i=this.controlPoint1,r=this.controlPoint2,o=this.end,a=[new Bi(n,i,r,o)];if(0===e)return a;if(!this.isDifferentiable())return a;var s=this.endpointDistance(),u=Fi(10,-e),l=2;0===i.cross(n,o)&&0===r.cross(n,o)&&(l=2*e);for(var h=0;;){h+=1;for(var c=[],d=a.length,f=0;f<d;f++){var p=a[f].divide(.5);c.push(p[0],p[1])}for(var g=0,v=c.length,m=0;m<v;m++){g+=c[m].endpointDistance()}if(l<=h)if((0!==g?(g-s)/g:0)<u)return c;a=c,s=g}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++){i+=n[o].endpointDistance()}return i},lengthAtT:function(t,e){if(t<=0)return 0;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();var n=this.tAt(t,e);return this.pointAtT(n)},pointAtLength:function(t,e){var n=this.tAtLength(t,e);return this.pointAtT(n)},pointAtT:function(t){return t<=0?this.start.clone():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);var n=this.tAt(t,e);return this.tangentAtT(n)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var n=this.tAtLength(t,e);return this.tangentAtT(n)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var e=this.getSkeletonPoints(t),n=e.startControlPoint2,i=e.dividerControlPoint1,r=e.divider,o=new ci(n,i);return o.translate(r.x-n.x,r.y-n.y),o},tAt:function(t,e){if(t<=0)return 0;if(1<=t)return 1;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.length(i)*t;return this.tAtLength(r,i)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var i,r,o,a,s,u=void 0===(e=e||{}).precision?this.PRECISION:e.precision,l=void 0===e.subdivisions?this.getSubdivisions({precision:u}):e.subdivisions,h={precision:u,subdivisions:l},c=0,d=l.length,f=1/d,p=0;p<d;p++){var g=n?p:d-1-p,v=l[p],m=v.endpointDistance();if(t<=c+m){i=v,r=g*f,o=(g+1)*f,a=n?t-c:m+c-t,s=n?m+c-t:t-c;break}c+=m}if(!i)return n?1:0;for(var y=this.length(h),b=Fi(10,-u);;){var w,x;if((0!==y?a/y:0)<b)return r;if((0!==y?s/y:0)<b)return o;var A=i.divide(.5);f/=2;var T=A[0].endpointDistance(),P=A[1].endpointDistance();x=a<=T?(i=A[0],o-=f,T-(w=a)):(i=A[1],r+=f,P-(w=a-T)),a=w,s=x}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var a=n[o];i.push(a.end.clone())}return i},toPolyline:function(t){return new Ci(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}},Bi.prototype.divide=Bi.prototype.divideAtT;var Ii=function(t){if(!(this instanceof Ii))return new Ii(t);if("string"==typeof t)return new Ii.parse(t);var e,n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(e=0;e<n;e++){var i=t[e];this.appendSegment(i)}else{var r=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof ci||o instanceof Bi))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(Ii.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(Ii.createSegment("M",o.start)),o instanceof ci?this.appendSegment(Ii.createSegment("L",o.end)):o instanceof Bi&&this.appendSegment(Ii.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof ci)this.appendSegment(Ii.createSegment("M",t.start)),this.appendSegment(Ii.createSegment("L",t.end));else if(t instanceof Bi)this.appendSegment(Ii.createSegment("M",t.start)),this.appendSegment(Ii.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof Ci))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(n=t.points.length,e=0;e<n;e++){var a=t.points[e];0===e?this.appendSegment(Ii.createSegment("M",a)):this.appendSegment(Ii.createSegment("L",a))}}else;};function Di(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}Ii.parse=function(t){if(!t)return new Ii;for(var e=new Ii,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),a=Ii.createSegment.apply(this,o);e.appendSegment(a)}return e},Ii.createSegment=function(t){var e=arguments;if(!t)throw new Error("Type must be provided.");var n=Ii.segmentTypes[t];if(!n)throw new Error(t+" is not a recognized path segment type.");for(var i=[],r=arguments.length,o=1;o<r;o++)i.push(e[o]);return Di(n,i)},Ii.prototype={type:Zn.Path,appendSegment:function(t){var e,n=this.segments,i=n.length,r=0!==i?n[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,a=0;a<o;a++){var s=t[a];e=this.prepareSegment(s,r,null),n.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),n.push(e)}},bbox:function(){var t,e=this.segments,n=e.length;if(0===n)return null;for(var i=0;i<n;i++){var r=e[i];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var a=e[n-1];return new Ei(a.end.x,a.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,n=new Ii,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){var n=this.closestPointT(t,e);return n?this.pointAtT(n):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointT(t,i);return r?this.lengthAtT(r,i):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointLength(t,i);if(0===r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,s=1/0,u=0;u<i;u++){var l=n[u],h=a[u];if(l.isVisible){var c=l.closestPointT(t,{precision:o,subdivisions:h}),d=l.pointAtT(c),f=new ci(d,t).squaredLength();f<s&&(r={segmentIndex:u,value:c},s=f)}}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,s=1/0,u=0;u<i;u++){var l=n[u],h=a[u];if(l.isDifferentiable()){var c=l.closestPointT(t,{precision:o,subdivisions:h}),d=l.pointAtT(c),f=new ci(d,t).squaredLength();f<s&&(r=l.tangentAtT(c),s=f)}}return r||null},containsPoint:function(t,e){var n=this.toPolylines(e);if(!n)return!1;for(var i=n.length,r=0,o=0;o<i;o++){n[o].containsPoint(t)&&r++}return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),1<t&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.divideAtLength(r,i)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;var i=!0;t<0&&(i=!1,t=-t);var r,o,a,s,u,l,h,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,d=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:c}):e.segmentSubdivisions,f=0;for(r=0;r<n;r++){var p=i?r:n-1-r;o=this.getSegment(p);var g=d[p],v=o.length({precision:c,subdivisions:g});if(o.isDifferentiable()&&(u=o,l=p,t<=f+v)){s=p,a=o.divideAtLength((i?1:-1)*(t-f),{precision:c,subdivisions:g});break}f+=v}if(!u)return null;a||(s=l,h=i?1:0,a=u.divideAtT(h));var m=this.clone();m.replaceSegment(s,a);var y=s,b=s+1,w=s+2;a[0].isDifferentiable()||(m.removeSegment(y),b-=1,w-=1);var x=m.getSegment(b).start;m.insertSegment(b,Ii.createSegment("M",x)),w+=1,a[1].isDifferentiable()||(m.removeSegment(w-1),w-=1);var A=w-y-1;for(r=w;r<m.segments.length;r++){var T=this.getSegment(r-A);if("Z"===(o=m.getSegment(r)).type&&!T.subpathStartSegment.end.equals(o.subpathStartSegment.end)){var P=Ii.createSegment("L",T.end);m.replaceSegment(r,P)}}return[new Ii(m.segments.slice(0,b)),new Ii(m.segments.slice(b))]},equals:function(t){if(!t)return!1;var e=this.segments,n=t.segments,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],a=n[r];if(o.type!==a.type||!o.equals(a))return!1}return!0},getSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),n<=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 a=e[o].getSubdivisions({precision:i});r.push(a)}return r},getSubpaths:function(){for(var t=this.clone().validate().segments,e=t.length,n=[],i=0;i<e;i++){var r=t[i];r.isSubpathStart?n.push(new Ii(r)):n[n.length-1].appendSegment(r)}return n},insertSegment:function(t,e){var n,i=this.segments,r=i.length;if(t<0&&(t=r+t+1),r<t||t<0)throw new Error("Index out of range.");var o=null,a=null;if(0!==r&&(a=1<=t?(o=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,u=0;u<s;u++){var l=e[u];n=this.prepareSegment(l,o,a),i.splice(t+u,0,n),o=n}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,o,a),i.splice(t,0,n)}},intersectionWithLine:function(t,e){var n=null,i=this.toPolylines(e);if(!i)return null;for(var r=0,o=i.length;r<o;r++){var a=i[r],s=t.intersect(a);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,a=0;a<n;a++){var s=e[a],u=r[a];o+=s.length({subdivisions:u})}return o},lengthAtT:function(t,e){var n=this.segments,i=n.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;var o=t.value;i<=r?(r=i-1,o=1):o<0?o=0:1<o&&(o=1);for(var a,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,u=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<r;h++){var c=n[h];a=u[h],l+=c.length({precisison:s,subdivisions:a})}return c=n[r],a=u[r],l+=c.lengthAtT(o,{precisison:s,subdivisions:a})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.pointAtLength(r,i)},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();var r=!0;t<0&&(r=!1,t=-t);for(var o,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,u=0,l=0;l<i;l++){var h=r?l:i-1-l,c=n[h],d=s[h],f=c.length({precision:a,subdivisions:d});if(c.isVisible){if(t<=u+f)return c.pointAtLength((r?1:-1)*(t-u),{precision:a,subdivisions:d});o=c}u+=f}return o?r?o.end:o.start:n[i-1].end.clone()},pointAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].pointAtT(0);if(n<=i)return e[n-1].pointAtT(1);var r=t.value;return r<0?r=0:1<r&&(r=1),e[i].pointAtT(r)},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);var i=t;return t.isSubpathStart&&(t.subpathStartSegment=t,i=n),i&&this.updateSubpathStartSegment(i),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),n<=t||t<0)throw new Error("Index out of range.");var i=e.splice(t,1)[0],r=i.previousSegment,o=i.nextSegment;r&&(r.nextSegment=o),o&&(o.previousSegment=r),i.isSubpathStart&&o&&this.updateSubpathStartSegment(o)},replaceSegment:function(t,e){var n,i=this.segments,r=i.length;if(0===r)throw new Error("Path has no segments.");if(t<0&&(t=r+t),r<=t||t<0)throw new Error("Index out of range.");var o=i[t],a=o.previousSegment,s=o.nextSegment,u=o.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var l=e.length,h=0;h<l;h++){var c=e[h];n=this.prepareSegment(c,a,s),i.splice(t+h,0,n),a=n,u&&n.isSubpathStart&&(u=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,a,s),i.splice(t,1,n),u&&n.isSubpathStart&&(u=!1)}u&&s&&this.updateSubpathStartSegment(s)},round:function(t){for(var e=this.segments,n=e.length,i=0;i<n;i++){e[i].round(t)}return this},scale:function(t,e,n){for(var i=this.segments,r=i.length,o=0;o<r;o++){i[o].scale(t,e,n)}return this},segmentAt:function(t,e){var n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null},segmentAtLength:function(t,e){var n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),1<t&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.segmentIndexAtLength(r,i)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,s=null,u=0,l=0;l<i;l++){var h=r?l:i-1-l,c=n[h],d=a[h],f=c.length({precision:o,subdivisions:d});if(c.isVisible){if(t<=u+f)return h;s=h}u+=f}return s},serialize:function(){if(!this.isValid())throw new Error("Invalid path segments.");return this.toString()},tangentAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),1<t&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.tangentAtLength(r,i)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,u=0,l=0;l<i;l++){var h=r?l:i-1-l,c=n[h],d=s[h],f=c.length({precision:a,subdivisions:d});if(c.isDifferentiable()){if(t<=u+f)return c.tangentAtLength((r?1:-1)*(t-u),{precision:a,subdivisions:d});o=c}u+=f}if(o){var p=r?1:0;return o.tangentAtT(p)}return null},tangentAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].tangentAtT(0);if(n<=i)return e[n-1].tangentAtT(1);var r=t.value;return r<0?r=0:1<r&&(r=1),e[i].tangentAtT(r)},toPoints:function(t){var e=this.segments,n=e.length;if(0===n)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=[],a=[],s=0;s<n;s++){var u=e[s];if(u.isVisible){var l=r[s];if(0<l.length){var h=l.map(function(t){return t.start});Array.prototype.push.apply(a,h)}else a.push(u.start)}else 0<a.length&&(a.push(e[s-1].end),o.push(a),a=[])}return 0<a.length&&(a.push(this.end),o.push(a)),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 Ci(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,Ii.createSegment("M",0,0)),this}},Object.defineProperty(Ii.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(Ii.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}});var ji={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return 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(ji,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(ji,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(ji,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}});var zi=function(){for(var t,e,n=arguments,i=[],r=arguments.length,o=0;o<r;o++)i.push(n[o]);if(!(this instanceof zi))return Di(zi,i);if(0===r)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(i[0]instanceof ci){if(1===r)return this.end=i[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+r+" lines provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(2===r)return this.end=new si(+i[0],+i[1]),this;if(r<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+r+" coordinates provided).");var a;for(t=[],o=0;o<r;o+=2)a=i.slice(o,o+2),t.push(Di(zi,a));return t}if(1===r)return this.end=new si(i[0]),this;for(t=[],o=0;o<r;o+=1)e=i[o],t.push(new zi(e));return t},Gi={clone:function(){return new zi(this.end)},divideAt:function(t){var e=new ci(this.start,this.end).divideAt(t);return[new zi(e[0]),new zi(e[1])]},divideAtLength:function(t){var e=new ci(this.start,this.end).divideAtLength(t);return[new zi(e[0]),new zi(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Gi,"type",{configurable:!0,enumerable:!0,value:"L"}),zi.prototype=Vi(ji,ci.prototype,Gi);var Ui=function(){for(var t,e,n=arguments,i=[],r=arguments.length,o=0;o<r;o++)i.push(n[o]);if(!(this instanceof Ui))return Di(Ui,i);if(0===r)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(i[0]instanceof Bi){if(1===r)return this.controlPoint1=i[0].controlPoint1.clone(),this.controlPoint2=i[0].controlPoint2.clone(),this.end=i[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+r+" curves provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(6===r)return this.controlPoint1=new si(+i[0],+i[1]),this.controlPoint2=new si(+i[2],+i[3]),this.end=new si(+i[4],+i[5]),this;if(r<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+r+" coordinates provided).");var a;for(t=[],o=0;o<r;o+=6)a=i.slice(o,o+6),t.push(Di(Ui,a));return t}if(3===r)return this.controlPoint1=new si(i[0]),this.controlPoint2=new si(i[1]),this.end=new si(i[2]),this;if(r<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+r+" points provided).");for(t=[],o=0;o<r;o+=3)e=i.slice(o,o+3),t.push(Di(Ui,e));return t},Hi={clone:function(){return new Ui(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){var n=new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Ui(n[0]),new Ui(n[1])]},divideAtLength:function(t,e){var n=new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Ui(n[0]),new Ui(n[1])]},divideAtT:function(t){var e=new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Ui(e[0]),new Ui(e[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,n=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+n.x+" "+n.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}};Object.defineProperty(Hi,"type",{configurable:!0,enumerable:!0,value:"C"}),Ui.prototype=Vi(ji,Bi.prototype,Hi);var qi=function(){for(var t,e,n=arguments,i=[],r=arguments.length,o=0;o<r;o++)i.push(n[o]);if(!(this instanceof qi))return Di(qi,i);if(0===r)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(i[0]instanceof ci){if(1===r)return this.end=i[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+r+" lines provided).")}if(i[0]instanceof Bi){if(1===r)return this.end=i[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+r+" curves provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(2===r)return this.end=new si(+i[0],+i[1]),this;if(r<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+r+" coordinates provided).");var a;for(t=[],o=0;o<r;o+=2)a=i.slice(o,o+2),0===o?t.push(Di(qi,a)):t.push(Di(zi,a));return t}if(1===r)return this.end=new si(i[0]),this;for(t=[],o=0;o<r;o+=1)e=i[o],0===o?t.push(new qi(e)):t.push(new zi(e));return t},Wi={bbox:function(){return null},clone:function(){return new qi(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(Wi,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Wi,"type",{configurable:!0,enumerable:!0,value:"M"}),qi.prototype=Vi(ji,Wi);var Yi=function(){for(var t=arguments,e=[],n=arguments.length,i=0;i<n;i++)e.push(t[i]);if(!(this instanceof Yi))return Di(Yi,e);if(0<n)throw new Error("Closepath constructor expects no arguments.");return this},Xi={clone:function(){return new Yi},divideAt:function(t){var e=new ci(this.start,this.end).divideAt(t);return[e[1].isDifferentiable()?new zi(e[0]):this.clone(),new zi(e[1])]},divideAtLength:function(t){var e=new ci(this.start,this.end).divideAtLength(t);return[e[1].isDifferentiable()?new zi(e[0]):this.clone(),new zi(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment)&&!this.start.equals(this.end)},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}};Object.defineProperty(Xi,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),Object.defineProperty(Xi,"type",{configurable:!0,enumerable:!0,value:"Z"}),Yi.prototype=Vi(ji,ci.prototype,Xi);var $i=Ii.segmentTypes={L:zi,C:Ui,M:qi,Z:Yi,z:Yi};Ii.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys($i).join("")+",.]*$"),Ii.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)};var Zi={curveThroughPoints:function(t){return console.warn("deprecated"),new Ii(Bi.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new si((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new si(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var a=this.getFirstControlPoints(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var s=this.getFirstControlPoints(o);for(e=0;e<r;e++)n.push(new si(a[e],s[e])),e<r-1?i.push(new si(2*t[e+1].x-a[e+1],2*t[e+1].y-s[e+1])):i.push(new si((t[r].x+a[r-1])/2,(t[r].y+s[r-1])/2));return[n,i]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new Bi(t,e,n,i);return function(t){var e=r.divide(t);return[{p0:e[0].start,p1:e[0].controlPoint1,p2:e[0].controlPoint2,p3:e[0].end},{p0:e[1].start,p1:e[1].controlPoint1,p2:e[1].controlPoint2,p3:e[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n},getInversionSolver:function(t,e,n,i){console.warn("deprecated");var r=new Bi(t,e,n,i);return function(t){return r.closestPointT(t)}}},Ji=function(t){return this instanceof Ji?"string"==typeof t?new Ji.parse(t):void(this.points=Array.isArray(t)?t.map(si):[]):new Ji(t)};function Ki(t,e){var n=t.start.x,i=t.start.y,r=t.end.x,o=t.end.y,a=e.start.x,s=e.start.y,u=r-n,l=o-i,h=e.end.x-a,c=e.end.y-s,d=n-a,f=i-s,p=u*c-h*l,g=(u*f-l*d)/p,v=(h*f-c*d)/p;return 0<=g&&g<=1&&0<=v&&v<=1}function Qi(t,e){var n=t.a,i=t.b,r=t.x,o=t.y,a=e.start.x-r,s=e.end.x-r,u=e.start.y-o,l=n*n,h=i*i,c=s-a,d=e.end.y-o-u,f=c*c/l+d*d/h,p=2*a*c/l+2*u*d/h,g=p*p-4*f*(a*a/l+u*u/h-1);if(0===g){var v=-p/2/f;return 0<=v&&v<=1}if(0<g){var m=Math.sqrt(g),y=(-p+m)/2/f,b=(-p-m)/2/f;return 0<=y&&y<=1||0<=b&&b<=1}return!1}function tr(t,e){return function(t,e,n,i){var r=Math.cos,o=Math.sin,a=o(e),s=r(e),u=o(i),l=r(i),h=a*a,c=s*s,d=a*s,f=u*u,p=l*l,g=u*l,v=t.a*t.a,m=t.b*t.b,y=n.a*n.a,b=n.b*n.b,w=v*h+m*c,x=y*f+b*p,A=v*c+m*h,T=y*p+b*f,P=2*(m-v)*d,E=2*(b-y)*g,S=-2*w*t.x-P*t.y,k=-2*x*n.x-E*n.y,M=-P*t.x-2*A*t.y,L=-E*n.x-2*T*n.y,C=w*t.x*t.x+A*t.y*t.y+P*t.x*t.y-v*m,_=x*n.x*n.x+T*n.y*n.y+E*n.x*n.y-y*b;E/=2,k/=2,L/=2;var N=Sr([[w,P/=2,S/=2],[P,A,M/=2],[S,M,C]]),O=Sr([[x,E,k],[E,T,L],[k,L,_]]),R=.33333333*(Sr([[x,P,S],[E,A,M],[k,M,C]])+Sr([[w,E,S],[P,T,M],[S,L,C]])+Sr([[w,P,k],[P,A,L],[S,M,_]])),F=.33333333*(Sr([[w,E,k],[P,T,L],[S,L,_]])+Sr([[x,P,k],[E,A,L],[k,M,_]])+Sr([[x,E,S],[E,T,M],[k,L,C]])),B=Er([[N,R],[R,F]]),V=Er([[N,F],[R,O]]),I=Er([[R,F],[F,O]]);if(0<Er([[2*B,V],[V,2*I]])&&(0<F||0<R))return!1;return!0}(t,0,e,0)}function er(t,e){var n=e.start,i=e.end,r=t.x,o=t.y,a=t.width,s=t.height;return!(n.x>r+a&&i.x>r+a||n.x<r&&i.x<r||n.y>o+s&&i.y>o+s||n.y<o&&i.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||(Ki(t.topLine(),e)||Ki(t.rightLine(),e)||Ki(t.bottomLine(),e)||Ki(t.leftLine(),e)))}function nr(t,e){return!!ir(t,Ei.fromEllipse(e))&&lr(Ji.fromRect(t),e)}function ir(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 rr(t,e){return br(t,e,{interior:!1})}function or(t,e){return wr(t,e,{interior:!1})}function ar(t,e){return xr(t,e,{interior:!1})}function sr(t,e){return Tr(t,e,{interior:!1})}function ur(t,e){return br(t,e,{interior:!0})}function lr(t,e){return wr(t,e,{interior:!0})}function hr(t,e){return xr(t,e,{interior:!0})}function cr(t,e){return Tr(t,e,{interior:!0})}function dr(t,e){return Pr(t,e,{interior:!0})}function fr(t,n,i){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?ur(e,n):rr(e,n)})}function pr(t,n,i){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?lr(e,n):or(e,n)})}function gr(t,e,n){return mr(t,Ji.fromRect(e),n)}function vr(t,e,n){return Ar(t,e,n,{interior:!1})}function mr(t,e,n){return Ar(t,e,n,{interior:!0})}function yr(t,n,i,r){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?mr(n,e,r):vr(n,e,r)})}function br(t,e,n){void 0===n&&(n={});var i,r=n.interior;if(void 0===r&&(r=!1),r){if(t.containsPoint(e.start))return!0;var o=t.start,a=t.end,s=t.points;i=a.equals(o)?s:s.concat([o])}else i=t.points;for(var u=i.length,l=new ci,h=0;h<u-1;h++)if(l.start=i[h],l.end=i[h+1],Ki(e,l))return!0;return!1}function wr(t,e,n){void 0===n&&(n={});var i,r=t.start,o=t.end,a=t.points;if(e.containsPoint(r))return!0;var s=n.interior;if(void 0===s&&(s=!1),s){if(t.containsPoint(e.center()))return!0;i=o.equals(r)?a:a.concat([r])}else i=a;for(var u=i.length,l=new ci,h=0;h<u-1;h++)if(l.start=i[h],l.end=i[h+1],Qi(e,l))return!0;return!1}function xr(t,e,n){return Pr(t,Ji.fromRect(e),n)}function Ar(t,n,i,r){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?Pr(n,e,r):Tr(n,e,r)})}function Tr(t,e,n){void 0===n&&(n={});var i,r=n.interior;if(void 0===r&&(r=!1),r){var o=e.start;if(t.containsPoint(o))return!0;i=t.clone().close()}else i=t;for(var a=e.points,s=a.length,u=new ci,l=0;l<s-1;l++)if(u.start=a[l],u.end=a[l+1],rr(i,u))return!0;return!1}function Pr(t,e,n){return e.containsPoint(t.start)||Tr(t,e.clone().close(),n)}function Er(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function Sr(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]}Ji.parse=function(t){return new Ji(ki(t))},Ji.fromRect=function(t){return new Ji([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},Ji.prototype=Vi(Ci.prototype,{type:Zn.Polygon,clone:function(){return new Ji(Mi(this.points))},convexHull:function(){return new Ji(Li(this.points))},lengthPoints:function(){var t=this.start,e=this.end,n=this.points;return n.length<=1||t.equals(e)?n:n.concat([t.clone()])}});var kr={exists:function t(e,n,i,r){switch(e.type){case Zn.Line:switch(n.type){case Zn.Line:return Ki(e,n)}break;case Zn.Ellipse:switch(n.type){case Zn.Line:return Qi(e,n);case Zn.Ellipse:return tr(e,n)}break;case Zn.Rect:switch(n.type){case Zn.Line:return er(e,n);case Zn.Ellipse:return nr(e,n);case Zn.Rect:return ir(e,n)}break;case Zn.Polyline:switch(n.type){case Zn.Line:return rr(e,n);case Zn.Ellipse:return or(e,n);case Zn.Rect:return ar(e,n);case Zn.Polyline:return sr(e,n)}break;case Zn.Polygon:switch(n.type){case Zn.Line:return ur(e,n);case Zn.Ellipse:return lr(e,n);case Zn.Rect:return hr(e,n);case Zn.Polyline:return cr(e,n);case Zn.Polygon:return dr(e,n)}break;case Zn.Path:switch(n.type){case Zn.Line:return fr(e,n,i);case Zn.Ellipse:return pr(e,n,i);case Zn.Rect:return gr(e,n,i);case Zn.Polyline:return vr(e,n,i);case Zn.Polygon:return mr(e,n,i);case Zn.Path:return yr(e,n,i,r)}}switch(n.type){case Zn.Ellipse:case Zn.Rect:case Zn.Polyline:case Zn.Polygon:case Zn.Path:return t(n,e,r,i);default:throw Error("The intersection for "+e+" and "+n+" could not be found.")}},lineWithLine:Ki,ellipseWithLine:Qi,ellipseWithEllipse:tr,rectWithLine:er,rectWithEllipse:nr,rectWithRect:ir,polylineWithLine:rr,polylineWithEllipse:or,polylineWithRect:ar,polylineWithPolyline:sr,polygonWithLine:ur,polygonWithEllipse:lr,polygonWithRect:hr,polygonWithPolyline:cr,polygonWithPolygon:dr,pathWithLine:fr,pathWithEllipse:pr,pathWithRect:gr,pathWithPolyline:vr,pathWithPolygon:mr,pathWithPath:yr},Mr={intersection:kr,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}},normalizeAngle:Dn,snapToGrid:jn,toDeg:zn,toRad:Gn,random:Un,bezier:Zi,Curve:Bi,Ellipse:vi,ellipse:mi,Line:ci,line:di,Path:Ii,Point:si,point:ui,Polyline:Ci,Polygon:Ji,Rect:Ei,rect:Si,types:Zn},Lr="[object Arguments]",Cr="[object Array]",_r="[object Boolean]",Nr="[object Date]",Or="[object Error]",Rr="[object Map]",Fr="[object Number]",Br="[object Object]",Vr="[object RegExp]",Ir="[object Set]",Dr="[object String]",jr="[object Symbol]",zr="[object ArrayBuffer]",Gr="[object DataView]",Ur="[object Float32Array]",Hr="[object Float64Array]",qr="[object Int8Array]",Wr="[object Int16Array]",Yr="[object Int32Array]",Xr="[object Uint8Array]",$r="[object Uint8ClampedArray]",Zr="[object Uint16Array]",Jr="[object Uint32Array]",Kr={"[object Arguments]":!0,"[object Array]":!0,"[object ArrayBuffer]":!0,"[object DataView]":!0,"[object Boolean]":!0,"[object Date]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Map]":!0,"[object Number]":!0,"[object Object]":!0,"[object RegExp]":!0,"[object Set]":!0,"[object String]":!0,"[object Symbol]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Error]":!1,"[object Function]":!1,"[object WeakMap]":!1},Qr="\\ud800-\\udfff",to="\\u2700-\\u27bf",eo="a-z\\xdf-\\xf6\\xf8-\\xff",no="A-Z\\xc0-\\xd6\\xd8-\\xde",io="\\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",ro="["+io+"]",oo="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ao="["+to+"]",so="["+eo+"]",uo="[^"+Qr+io+"\\d"+to+eo+no+"]",lo="\\ud83c[\\udffb-\\udfff]",ho="[^"+Qr+"]",co="(?:\\ud83c[\\udde6-\\uddff]){2}",fo="[\\ud800-\\udbff][\\udc00-\\udfff]",po="["+no+"]",go="(?:"+so+"|"+uo+")",vo="(?:"+po+"|"+uo+")",mo="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",yo="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",bo="(?:"+oo+"|"+lo+")"+"?",wo="[\\ufe0e\\ufe0f]?",xo=wo+bo+("(?:\\u200d(?:"+[ho,co,fo].join("|")+")"+(wo+bo)+")*"),Ao="(?:"+[ao,co,fo].join("|")+")"+xo,To=RegExp([po+"?"+so+"+"+mo+"(?="+[ro,po,"$"].join("|")+")",vo+"+"+yo+"(?="+[ro,po+go,"$"].join("|")+")",po+"?"+go+"+"+mo,po+"+"+yo,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",Ao].join("|"),"g"),Po="__hash_undefined__",Eo=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,So="(?:"+[""+ho+oo+"?",oo,co,fo,"["+Qr+"]"].join("|")+")",ko=RegExp(lo+"(?="+lo+")|"+(So+xo),"g"),Mo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lo=/^\w*$/,Co=".".charCodeAt(0),_o=/\\(\\)?/g,No=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),Oo=/^(?: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 ]/),Fo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Bo=function(t){return ko.test(t)},Vo=function(t){return Bo(t)?t.match(ko)||[]:t.split("")},Io=function(e){return null==e?[]:Do(e).map(function(t){return e[t]})},Do=function(t){return Xo(t)?jo(t):Object.keys(Object(t))},jo=function(t,e){for(var n=Array.isArray(t),i=!n&&Uo(t)&&Jo(t)===Lr,r=!n&&!i&&ia(t),o=n||i||r,a=t.length,s=new Array(o?a:0),u=o?-1:a;++u<a;)s[u]=""+u;for(var l in t)!e&&!hasOwnProperty.call(t,l)||o&&("length"===l||ka(l,a))||s.push(l);return s},zo=function(t,e){for(var n=t.length;n--;)if(Go(t[n][0],e))return n;return-1},Go=function(t,e){return t===e||t!=t&&e!=e},Uo=function(t){return null!=t&&"object"==typeof t},Ho=function(t,e,n){if(!hs(n))return!1;var i=typeof e;return!!("number"==i?Xo(n)&&-1<e&&e<n.length:"string"==i&&e in n)&&Go(n[e],t)},qo=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},Wo=function(t,e,n){var i=t[e];hasOwnProperty.call(t,e)&&Go(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Yo=function(t,e,n){for(var i=-1,r=e.length;++i<r;){var o=e[i];Wo(n,o,t[o])}return n},Xo=function(t){return null!=t&&"function"!=typeof t&&"number"==typeof t.length&&-1<t.length&&t.length%1==0},$o=function(t){return"symbol"==typeof t||Uo(t)&&Jo(t)===jr},Zo=function(t,e){var n=-1,i=t.length;for(e||(e=new Array(i));++n<i;)e[n]=t[n];return e},Jo=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)},Ko=function(t){var e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Qo=function(t,e){var n=e?Ko(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)},ta=function(t){return"function"!=typeof t.constructor||qo(t)?{}:Object.create(Object.getPrototypeOf(t))},ea=function(e){return null==e?[]:(e=Object(e),Object.getOwnPropertySymbols(e).filter(function(t){return propertyIsEnumerable.call(e,t)}))};var na=function(t,e,n){var i,r,o,a,s=t.constructor;switch(e){case zr:return Ko(t);case _r:case Nr:return new s(+t);case Gr:return o=t,a=n?Ko(o.buffer):o.buffer,new o.constructor(a,o.byteOffset,o.byteLength);case Ur:case Hr:case qr:case Wr:case Yr:case Xr:case $r:case Zr:case Jr:return Qo(t,n);case Rr:return new s(t);case Fr:case Dr:return new s(t);case Vr:return(r=new(i=t).constructor(i.source,/\w*$/.exec(i))).lastIndex=i.lastIndex,r;case Ir:return new s;case jr:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}},ia=function(t){return Uo(t)&&Eo.test(Jo(t))},ra=function(t){var e=Object.keys(t);return Array.isArray(t)||null==t||e.push.apply(e,ea(Object(t))),e},oa=function(t){for(var e=[];t;)e.push.apply(e,ea(t)),t=Object.getPrototypeOf(Object(t));return e},aa=function(t){var e=[];for(var n in t)e.push(n);return Array.isArray(t)||e.push.apply(e,oa(t)),e},sa=function(t,e){var n=t.__data__;return La(e)?n["string"==typeof e?"string":"hash"]:n.map},ua=function(t,e,n){return t===e||(null==t||null==e||!Uo(t)&&!Uo(e)?t!=t&&e!=e:la(t,e,ua,n))},la=function(t,e,n,i){var r=Array.isArray(t),o=Array.isArray(e),a=r?Cr:Jo(t),s=o?Cr:Jo(e),u=(a=a==Lr?Br:a)==Br,l=(s=s==Lr?Br:s)==Br,h=a==s;if(h&&!u)return i||(i=new rs),r||ia(t)?ha(t,e,!1,n,i):pa(t,e,a,n,i);var c=u&&hasOwnProperty.call(t,"__wrapped__"),d=l&&hasOwnProperty.call(e,"__wrapped__");if(c||d){var f=c?t.value():t,p=d?e.value():e;return i||(i=new rs),n(f,p,i)}return!!h&&(i||(i=new rs),function(t,e,n,i){var r,o=ra(t),a=o.length;if(a!=ra(e).length)return!1;for(var s=a;s--;)if(r=o[s],!hasOwnProperty.call(e,r))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var h,c=!0;for(i.set(t,e),i.set(e,t);++s<a;){var d=t[r=o[s]],f=e[r];if(d!==f&&!n(d,f,i)){c=!1;break}h||(h="constructor"==r)}if(c&&!h){var p=t.constructor,g=e.constructor;p!=g&&"constructor"in t&&"constructor"in e&&!("function"==typeof p&&p instanceof p&&"function"==typeof g&&g instanceof g)&&(c=!1)}return i.delete(t),i.delete(e),c}(t,e,n,i))},ha=function(e,i,t,r,o){var n=e.length,a=i.length;if(n!=a)return!1;var s=o.get(e),u=o.get(i);if(s&&u)return s==i&&u==e;var l=-1,h=!0,c=t?new us:void 0;o.set(e,i),o.set(i,e);for(var d=function(){var n=e[l],t=i[l];if(c){if(!ca(i,function(t,e){if(!da(c,e)&&(n===t||r(n,t,o)))return c.push(e)}))return h=!1,"break"}else if(n!==t&&!r(n,t,o))return h=!1,"break"};++l<n;){if("break"===d())break}return o.delete(e),o.delete(i),h},ca=function(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1},da=function(t,e){return t.has(e)},fa=function(t,e,n,i){return!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i))},pa=function(t,e,n,i,r){switch(n){case Gr:return t.byteLength==e.byteLength&&t.byteOffset==e.byteOffset&&(t=t.buffer,e=e.buffer,fa(t,e,i,r));case zr:return fa(t,e,i,r);case _r:case Nr:case Fr:return Go(+t,+e);case Or:return t.name==e.name&&t.message==e.message;case Vr:case Dr:return t==""+e;case Rr:var o=ga;case Ir:if(o||(o=va),t.size!=e.size)return!1;var a=r.get(t);if(a)return a==e;r.set(t,e);var s=ha(o(t),o(e),!0,i,r);return r.delete(t),s;case jr:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},ga=function(t){var n=-1,i=Array(t.size);return t.forEach(function(t,e){i[++n]=[e,t]}),i},va=function(t){var e=-1,n=new Array(t.size);return t.forEach(function(t){n[++e]=t}),n},ma=function(t,e){if(Array.isArray(t))return!1;var n=typeof t;return!("number"!==n&&"boolean"!==n&&null!=t&&!$o(t))||(Lo.test(t)||!Mo.test(t)||null!=e&&t in Object(e))},ya=function(t,e){return Array.isArray(t)?t:ma(t,e)?[t]:(o=[],(n=""+t).charCodeAt(0)===Co&&o.push(""),n.replace(No,function(t,e,n,i){var r=t;n?r=i.replace(_o,"$1"):e&&(r=e.trim()),o.push(r)}),o);var n,o},ba=function(t,e){for(var n=0,i=(e=ya(e,t)).length;null!=t&&n<i;)t=t[Aa(e[n])],n++;return n&&n==i?t:void 0};function wa(t,e){if(t!==e){var n=void 0!==t,i=null===t,r=t==t,o=$o(t),a=void 0!==e,s=null===e,u=e==e,l=$o(e);if(!s&&!l&&!o&&e<t||o&&a&&u&&!s&&!l||i&&a&&u||!n&&u||!r)return 1;if(!i&&!o&&!l&&t<e||l&&n&&r&&!i&&!o||s&&n&&r||!a&&r||!u)return-1}return 0}var xa=function(t,e){var n=function(t,e){return!!(null==t?0:t.length)&&-1<t.indexOf(e)},i=!0,r=[],o=e.length;if(!t.length)return r;200<=e.length&&(i=!(n=function(t,e){return t.has(e)}),e=new us(e));t:for(var a in t){var s=t[a],u=s;if(s=0!==s?s:0,i&&u==u){for(var l=o;l--;)if(e[l]===u)continue t;r.push(s)}else n(e,u)||r.push(s)}return r},Aa=function(t){if("string"==typeof t||$o(t))return t;var e=""+t;return"0"==e&&1/t==-1/0?"-0":e},Ta=function(n,i,r,o,a,t,e,s){var u;if(void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===o&&(o=!0),a&&(u=e?a(n,t,e,s):a(n)),void 0!==u)return u;if(!hs(n))return n;var l,h,c,d,f,p=Array.isArray(n),g=Jo(n);if(p){if(d=(c=n).length,f=new c.constructor(d),d&&"string"==typeof c[0]&&hasOwnProperty.call(c,"index")&&(f.index=c.index,f.input=c.input),u=f,!i)return Zo(n,u)}else{var v="function"==typeof n;if(g===Br||g===Lr||v&&!e){if(u=r||v?{}:ta(n),!i)return r?Pa(n,Yo(n,Object.keys(n),u)):(l=n,h=Object.assign(u,n),Yo(l,ea(l),h))}else{if(v||!Kr[g])return e?n:{};u=na(n,g,i)}}s||(s=new rs);var m,y,b=s.get(n);if(b)return b;if(s.set(n,u),Uo(m=n)&&Jo(m)==Rr)return n.forEach(function(t,e){u.set(e,Ta(t,i,r,o,a,e,n,s))}),u;if(Uo(y=n)&&Jo(y)==Ir)return n.forEach(function(t){u.add(Ta(t,i,r,o,a,t,n,s))}),u;if(ia(n))return u;var w=p?void 0:(o?r?aa:ra:r?Ca:Do)(n);return(w||n).forEach(function(t,e){w&&(t=n[e=t]),Wo(u,e,Ta(t,i,r,o,a,e,n,s))}),u},Pa=function(t,e){return Yo(t,oa(t),e)},Ea=function(t,e){return e.length<2?t:ba(t,e.slice(0,-1))},Sa=function(t,e,n){if(!hs(t))return t;for(var i=(e=ya(e,t)).length,r=i-1,o=-1,a=t;null!=a&&++o<i;){var s=Aa(e[o]),u=n;if(o!=r){var l=a[s];(u=void 0)===u&&(u=hs(l)?l:ka(e[o+1])?[]:{})}Wo(a,s,u),a=a[s]}return t},ka=function(t,e){var n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"===n||"symbol"!==n&&Oo.test(t))&&-1<t&&t%1==0&&t<e},Ma=function(t,e){e=ya(e,t),t=Ea(t,e);var n=e[e.length-1];return null==t||delete t[Aa(n)]},La=function(t){var e=typeof t;return"string"===e||"number"===e||"symbol"===e||"boolean"===e?"__proto__"!==t:null===t},Ca=function(t){var e=[];for(var n in t)e.push(n);return e},_a=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function Na(u,l){return void 0===l&&(l=!1),function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];var i=-1,r=e.length,o=1<r?e[r-1]:void 0,a=2<r?e[2]:void 0;for(o=3<u.length&&"function"==typeof o?(r--,o):l?function(t,e){if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,a&&Ho(e[0],e[1],a)&&(o=r<3?void 0:o,r=1),t=Object(t);++i<r;){var s=e[i];s&&u(t,s,i,o)}return t}}var Oa=function(i,r,o,a,s){i!==r&&Gs(r,function(t,e){if(hs(t))s||(s=new rs),Ra(i,r,e,o,Oa,a,s);else{var n=a?a(i[e],t,""+e,i,r,s):void 0;void 0===n&&(n=t),Fa(i,e,n)}},Ca)},Ra=function(t,e,n,i,r,o,a){var s=_a(t,n),u=_a(e,n),l=a.get(u);if(l)Fa(t,n,l);else{var h=o?o(s,u,""+n,t,e,a):void 0,c=void 0===h;if(c){var d=Array.isArray(u),f=!d&&ia(u);h=u,d||f?h=Array.isArray(s)?s:Uo(s)&&Xo(s)?Zo(s):f?Qo(u,!(c=!1)):[]:Ls(u)||Ka(u)?Ka(h=s)?h=function(t){t=Object(t);var e={};for(var n in t)e[n]=t[n];return e}(s):"function"!=typeof s&&hs(s)||(h=ta(u)):c=!1}c&&(a.set(u,h),r(h,u,i,o,a),a.delete(u)),Fa(t,n,h)}},Fa=function(t,e,n){(void 0===n||Go(t[e],n))&&(void 0!==n||e in t)||Wo(t,e,n)};var Ba=function(t,e){return t&&function(t,e,n){for(var i=Object(t),r=n(t),o=r.length,a=-1;o--;){var s=r[++a];if(!1===e(i[s],s,i))break}return t}(t,e,Do)},Va=function(t,e){if(null==t)return t;if(!Xo(t))return Ba(t,e);for(var n=t.length,i=Object(t),r=-1;++r<n&&!1!==e(i[r],r,i););return t};var Ia=Set&&1/va(new Set([void 0,-0]))[1]==1/0?function(t){return new Set(t)}:function(){};function Da(t,e,n,i,r,o){return hs(t)&&hs(e)&&(o.set(e,t),Oa(t,e,void 0,Da,o),o.delete(e)),t}function ja(t,n,i){n=n.length?n.map(function(e){return Array.isArray(e)?function(t){return ba(t,1===e.length?e[0]:e)}:e}):[function(t){return t}];var r=-1,o=-1,a=Xo(t)?new Array(t.length):[];return Va(t,function(e){var t=n.map(function(t){return t(e)});a[++o]={criteria:t,index:++r,value:e}}),function(t,e){var n=t.length;t.sort(e);for(;n--;)t[n]=t[n].value;return t}(a,function(t,e){return function(t,e,n){for(var i=-1,r=t.criteria,o=e.criteria,a=r.length,s=n.length;++i<a;){var u=i<s?n[i]:null,l=(u&&"function"==typeof u?u:wa)(r[i],o[i]);if(l)return u&&"function"!=typeof u?l*("desc"==u?-1:1):l}return t.index-e.index}(t,e,i)})}function za(t){return t==t&&!hs(t)}function Ga(e,n){return function(t){return null!=t&&(t[e]===n&&(void 0!==n||e in Object(t)))}}function Ua(t,e){return null!=t&&es(t,e,ts)}function Ha(e){var n=function(t){var e=Do(t),n=e.length;for(;n--;){var i=e[n],r=t[i];e[n]=[i,r,za(r)]}return e}(e);return 1===n.length&&n[0][2]?Ga(n[0][0],n[0][1]):function(t){return t===e||function(t,e,n,i){var r,o,a=n.length,s=a,u=!i;if(null==t)return!s;t=Object(t);for(;a--;)if(r=n[a],u&&r[2]?r[1]!==t[r[0]]:!(r[0]in t))return!1;for(;++a<s;){var l=(r=n[a])[0],h=t[l],c=r[1];if(u&&r[2]){if(void 0===h&&!(l in t))return!1}else{var d=new rs;if(i&&(o=i(h,c,l,t,e,d)),!(void 0===o?ua(c,h,d):o))return!1}}return!0}(t,e,n)}}function qa(t){return ma(t)?(n=Aa(t),function(t){return null==t?void 0:t[n]}):(e=t,function(t){return ba(t,e)});var e,n}function Wa(t){return"function"==typeof t?t:null==t?function(t){return t}:"object"==typeof t?Array.isArray(t)?(n=t[0],i=t[1],ma(n)&&za(i)?Ga(Aa(n),i):function(t){var e=ba(t,n);return void 0===e&&e===i?Ua(t,n):ua(i,e)}):Ha(t):qa(t);var n,i}function Ya(){var t=Wa;return arguments.length?t(arguments[0],arguments[1]):t}var Xa=function(t,e,n,i){var r=-1,o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},$a=function(t,i,r,o,e){return e(t,function(t,e,n){r=o?(o=!1,t):i(r,t,e,n)}),r};var Za=function(t){return Array.isArray(t)||Ka(t)||!(!t||!t[Symbol.isConcatSpreadable])};var Ja,Ka=function(t){return Uo(t)&&"[object Arguments]"==Jo(t)},Qa=function(t,e,n){for(var i=-1,r=e.length,o={};++i<r;){var a=e[i],s=ba(t,a);n(s,a)&&Sa(o,ya(a,t),s)}return o},ts=function(t,e){return null!=t&&e in Object(t)},es=function(t,e,n){for(var i,r=-1,o=(e=ya(e,t)).length,a=!1;++r<o;){var s=Aa(e[r]);if(!(a=null!=t&&n(t,s)))break;t=t[s]}return a||++r!=o?a:!!(o=null==t?0:t.length)&&("number"==typeof(i=o)&&-1<i&&i%1==0&&i<=Number.MAX_SAFE_INTEGER)&&ka(s,o)&&(Array.isArray(t)||Ka(t))},ns=function(t,e){return void 0!==e?t.match(e)||[]:(Ro(t)?t.match(To):t.match(Fo))||[]},is=(Ja="toUpperCase",function(t){if(!t)return"";var e,n,i,r,o=Bo(t)?Vo(t):void 0,a=o?o[0]:t[0],s=o?(e=o,n=1,r=e.length,i=void 0===i?r:i,!n&&r<=i?e:e.slice(n,i)).join(""):t.slice(1);return a[Ja]()+s});var rs=function(t){var e=this.__data__=new os(t);this.size=e.size};rs.prototype.clear=function(){this.__data__=new os,this.size=0},rs.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},rs.prototype.get=function(t){return this.__data__.get(t)},rs.prototype.has=function(t){return this.__data__.has(t)},rs.prototype.set=function(t,e){var n=this.__data__;if(n instanceof os){var i=n.__data__;if(i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new as(i)}return n.set(t,e),this.size=n.size,this};var os=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}};os.prototype.clear=function(){this.__data__=[],this.size=0},os.prototype.delete=function(t){var e=this.__data__,n=zo(e,t);return!(n<0)&&(n==e.length-1?e.pop():e.splice(n,1),--this.size,!0)},os.prototype.get=function(t){var e=this.__data__,n=zo(e,t);return n<0?void 0:e[n][1]},os.prototype.has=function(t){return-1<zo(this.__data__,t)},os.prototype.set=function(t,e){var n=this.__data__,i=zo(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var as=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}};as.prototype.clear=function(){this.size=0,this.__data__={hash:new ss,map:new Map,string:new ss}},as.prototype.delete=function(t){var e=sa(this,t).delete(t);return this.size-=e?1:0,e},as.prototype.get=function(t){return sa(this,t).get(t)},as.prototype.has=function(t){return sa(this,t).has(t)},as.prototype.set=function(t,e){var n=sa(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};var ss=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}};ss.prototype.clear=function(){this.__data__=Object.create(null),this.size=0},ss.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ss.prototype.get=function(t){var e=this.__data__[t];return e===Po?void 0:e},ss.prototype.has=function(t){return void 0!==this.__data__[t]},ss.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?Po:e,this};var us=function(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new as;++e<n;)this.add(t[e])};us.prototype.add=function(t){return this.__data__.set(t,Po),this},us.prototype.has=function(t){return this.__data__.has(t)},us.prototype.push=us.prototype.add;var ls=function(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&e.call(t)===_r},hs=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},cs=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Fr},ds=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Dr},fs=Na(function(t,e){if(qo(e)||Xo(e))Yo(e,Do(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&Wo(t,n,e[n])}),ps=fs,gs=ps,vs=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];var i=-1,r=e.length,o=2<r?e[2]:void 0;for(o&&Ho(e[0],e[1],o)&&(r=1);++i<r;){var a=e[i];if(null!=a)for(var s=Object.keys(a),u=s.length,l=-1;++l<u;){var h=s[l],c=t[h];(void 0===c||Go(c,Object.prototype[h])&&!hasOwnProperty.call(t,h))&&(t[h]=a[h])}}return t},ms=vs,ys=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.push(void 0,Da),Ws.apply(void 0,t)},bs=ys,ws=function(t,e){for(var n=[],i=arguments.length-2;0<i--;)n[i]=arguments[i+2];var r=-1,o="function"==typeof e,a=Xo(t)?new Array(t.length):[];return Va(t,function(t){a[++r]=o?e.apply(t,n):xs.apply(void 0,[t,e].concat(n))}),a},xs=function(t,e){for(var n=[],i=arguments.length-2;0<i--;)n[i]=arguments[i+2];e=ya(e,t);var r,o,a=null==(t=Ea(t,e))?t:t[Aa((r=e,o=null==r?0:r.length,o?r[o-1]:void 0))];return null==a?void 0:a.apply(t,n)},As=function(t,e,n){var i=0,r=null==t?0:t.length;if(0==r)return 0;for(var o=(e=(n=Ya(n,2))(e))!=e,a=null===e,s=$o(e),u=void 0===e;i<r;){var l=Math.floor((i+r)/2),h=n(t[l]),c=void 0!==h,d=null===h,f=h==h,p=$o(h);(o?f:u?f&&c:a?f&&c&&!d:s?f&&c&&!d&&!p:!d&&!p&&h<e)?i=l+1:r=l}return Math.min(r,4294967294)},Ts=function(t,e){var n=-1,i=function(t,e){return!!(null==t?0:t.length)&&-1<t.indexOf(e)};e=Ya(e,2);var r=!0,o=t.length,a=[],s=a;if(200<=o){var u=e?null:Ia(t);if(u)return va(u);r=!1,i=function(t,e){return t.has(e)},s=new us}else s=e?[]:a;t:for(;++n<o;){var l=t[n],h=e?e(l):l;if(l=0!==l?l:0,r&&h==h){for(var c=s.length;c--;)if(s[c]===h)continue t;e&&s.push(h),a.push(l)}else i(s,h)||(s!==a&&s.push(h),a.push(l))}return a},Ps=function(t){return Ta(t)},Es=function(t){return Ta(t,!0)},Ss=function(t){if(null==t)return!0;if(Xo(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||ia(t)||Ka(t)))return!t.length;var e=Jo(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(qo(t))return!function(t){if(!qo(t))return Object.keys(t);var e=[];for(var n in Object(t))hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t).length;for(var n in t)if(hasOwnProperty.call(t,n))return!1;return!0},ks=function(t,e){return ua(t,e)},Ms=function(t){return"function"==typeof t},Ls=function(t){if(!Uo(t)||"[object Object]"!=Jo(t))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},Cs=function(t){if(!t)return[];if(Xo(t))return ds(t)?Vo(t):Zo(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=Jo(t);return(r==Rr?ga:r==Ir?va:Io)(t)};function _s(i,o,t){if("function"!=typeof i)throw new TypeError("Expected a function");var a,s,r,u,l,h,c=0,d=!1,f=!1,e=!0,n=!o&&0!==o&&window&&"function"==typeof window.requestAnimationFrame;function p(t){var e=a,n=s;return a=s=void 0,c=t,u=i.apply(n,e)}function g(t,e){return n?(window.cancelAnimationFrame(l),window.requestAnimationFrame(t)):setTimeout(t,e)}function v(t){var e=t-h;return void 0===h||o<=e||e<0||f&&r<=t-c}function m(){var t,e,n,i=Date.now();if(v(i))return y(i);l=g(m,(e=(t=i)-c,n=o-(t-h),f?Math.min(n,r-e):n))}function y(t){return l=void 0,e&&a?p(t):(a=s=void 0,u)}function b(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n,i=Date.now(),r=v(i);if(a=t,s=this,h=i,r){if(void 0===l)return c=n=h,l=g(m,o),d?p(n):u;if(f)return l=g(m,o),p(h)}return void 0===l&&(l=g(m,o)),u}return o=+o||0,hs(t)&&(d=!!t.leading,r=(f="maxWait"in t)?Math.max(+t.maxWait||0,o):r,e="trailing"in t?!!t.trailing:e),b.cancel=function(){void 0!==l&&function(t){if(n)return window.cancelAnimationFrame(t);clearTimeout(t)}(l),a=h=s=l=void(c=0)},b.flush=function(){return void 0===l?u:y(Date.now())},b.pending=function(){return void 0!==l},b}var Ns=function(t,i){return i=Ya(i,2),function(t,e,n){return(Array.isArray(t)?Xa:$a)(t,e,n,arguments.length<3,Va)}(t,function(t,e,n){return n=i(e),hasOwnProperty.call(t,n)?t[n].push(e):Wo(t,n,[e]),t},{})},Os=function(t,e){if(void 0===e&&(e=[]),null==t)return[];var n=e.length;return 1<n&&Ho(t,e[0],e[1])?e=[]:2<n&&Ho(e[0],e[1],e[2])&&(e=[e[0]]),Array.isArray(e)||(e=[Ya(e,2)]),ja(t,e.flat(1),[])},Rs=function(t){return(null==t?0:t.length)?function t(e,n,i,r,o){var a=-1,s=e.length;for(i||(i=Za),o||(o=[]);++a<s;){var u=e[a];0<n&&i(u)?1<n?t(u,n-1,i,r,o):o.push.apply(o,u):r||(o[o.length]=u)}return o}(t,1/0):[]},Fs=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];return Xo(t)?xa(t,e):[]},Bs=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];return Uo(t)&&Xo(t)?xa(t,e.flat(1)):[]},Vs=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t.flat(1);return Ts(n)},Is=function(t,e){if(null==t)return!1;"string"==typeof e&&(e=e.split("."));for(var n=-1,i=t;++n<e.length;){if(!i||!hasOwnProperty.call(i,e[n]))return!1;i=i[e[n]]}return!0},Ds=function(t,e,n){var i=-1,r=(e=ya(e,t)).length;for(r||(r=1,t=void 0);++i<r;){var o=null==t?void 0:t[Aa(e[i])];void 0===o&&(i=r,o=n),t="function"==typeof o?o.call(t):o}return t},js=function(e){for(var t=[],n=arguments.length-1;0<n--;)t[n]=arguments[n+1];var i={};if(null==e)return i;var r=!1;t=t.flat(1).map(function(t){return t=ya(t,e),r||(r=1<t.length),t}),Yo(e,aa(e),i),r&&(i=Ta(i,!0,!0,!0,function(t){return Ls(t)?void 0:t}));for(var o=t.length;o--;)Ma(i,t[o]);return i},zs=function(t){for(var n,e,i=[],r=arguments.length-1;0<r--;)i[r]=arguments[r+1];return null==t?{}:(n=t,e=i.flat(1/0),Qa(n,e,function(t,e){return Ua(n,e)}))},Gs=function(t,e){void 0===e&&(e=function(t){return t});for(var n=-1,i=Object(t),r=Xo(t)?jo(t,!0):Ca(t),o=r.length;o--;){var a=r[++n];if(!1===e(i[a],a,i))break}},Us=function(t){return void 0===t&&(t=""),ns((""+t).replace(/['\u2019]/g,"")).reduce(function(t,e,n){return e=e.toLowerCase(),t+(n?is(e):e)},"")},Hs=0,qs=function(t){return void 0===t&&(t=""),""+t+ ++Hs},Ws=Na(function(t,e,n,i){Oa(t,e,n,i)},!0),Ys=function(){this.map=new WeakMap};Ys.prototype.has=function(t,e){return void 0===e?this.map.has(t):e in this.map.get(t)},Ys.prototype.create=function(t){return this.has(t)||this.map.set(t,Object.create(null)),this.get(t)},Ys.prototype.get=function(t,e){if(this.has(t)){var n=this.map.get(t);return void 0===e?n:n[e]}},Ys.prototype.set=function(t,e,n){if(void 0!==e){var i=this.create(t);"string"==typeof e?i[e]=n:Object.assign(i,e)}},Ys.prototype.remove=function(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])};var Xs=new Ys,$s=new Ys,Zs=function(t,e){if(!(this instanceof Zs))return new Zs(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?Js:Ks,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&Object.assign(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this.envelope=!0};function Js(){return!0}function Ks(){return!1}Zs.prototype={constructor:Zs,isDefaultPrevented:Ks,isPropagationStopped:Ks,isImmediatePropagationStopped:Ks,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=Js,t&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=Js,t&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=Js,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(function(t){return e=t,void Object.defineProperty(Zs.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})}});var e});var Qs="undefined"!=typeof window?window.document:null,tu=Qs&&Qs.documentElement,eu=/^([^.]*)(?:\.(.+)|)/,nu=/[^\x20\t\r\n\f]+/g,iu=function(t){return new iu.Dom(t)};iu.fn=iu.prototype={constructor:iu,length:0},iu.guid=1,iu.data=$s,iu.merge=function(t,e){for(var n=+e.length,i=t.length,r=0;r<n;r++)t[i++]=e[r];return t.length=i,t},iu.parseHTML=function(t){var e=Qs.implementation.createHTMLDocument(),n=e.createElement("base");n.href=Qs.location.href,e.head.appendChild(n),e.body.innerHTML=t;for(var i=e.getElementsByTagName("script"),r=0;r<i.length;r++)i[r].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(iu.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),iu.fn.toArray=function(){return Array.from(this)},iu.fn.pushStack=function(t){var e=iu.merge(this.constructor(),t);return e.prevObject=this,e},iu.fn.find=function(t){var e=this[0],n=this.pushStack([]);if(!e)return n;var i=e.nodeType;return 1!==i&&9!==i&&11!==i||("string"!=typeof t?e!==t&&e.contains(t)&&iu.merge(n,[t]):iu.merge(n,e.querySelectorAll(t))),n},iu.fn.add=function(t,e){var n=iu(t,e).toArray(),i=this.toArray(),r=this.pushStack([]);return iu.merge(r,Ts(i.concat(n))),r},iu.fn.addBack=function(){return this.add(this.prevObject)},iu.fn.filter=function(t){for(var e=[],n=0;n<this.length;n++){var i=this[n];i.matches(t)&&e.push(i)}return this.pushStack(e)};var ru=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;var ou=function(t){if(!t)return this;if("function"==typeof t)throw new Error("function not supported");if(1<arguments.length)throw new Error("selector with context not supported");if(t.nodeType)return this[0]=t,this.length=1,this;var e,n;if("<"===(n=t+"")[0]&&">"===n[n.length-1]&&3<=n.length)e=[null,t,null];else{if("string"!=typeof t)return iu.merge(this,t);e=ru.exec(t)}if(!e||!e[1])return au.find(t);if(e[1])return iu.merge(this,iu.parseHTML(e[1])),this;var i=Qs.getElementById(e[2]);return i&&(this[0]=i,this.length=1),this};(iu.Dom=ou).prototype=iu.fn,iu.Event=Zs,iu.event={special:Object.create(null)},iu.event.has=function(t,e){var n=Xs.get(t,"events");return!!n&&(!e||Array.isArray(n[e])&&0<n[e].length)},iu.event.on=function(t,e,n,i,r,o){if("object"==typeof e){for(var a in"string"!=typeof n&&(i=i||n,n=void 0),e)iu.event.on(t,a,n,i,e[a],o);return t}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!r)return t;if(1===o){var s=r;(r=function(t){return iu().off(t),s.apply(this,arguments)}).guid=s.guid||(s.guid=iu.guid++)}for(var u=0;u<t.length;u++)iu.event.add(t[u],e,r,i,n)},iu.event.add=function(e,t,n,i,r){if("object"==typeof e){var o,a,s,u=Xs.create(e);n.handler&&(n=(o=n).handler,r=o.selector),r&&tu.matches(r),n.guid||(n.guid=iu.guid++),(a=u.events)||(a=u.events=Object.create(null)),(s=u.handle)||(s=u.handle=function(t){return void 0!==iu?iu.event.dispatch.apply(e,arguments):void 0});for(var l=(t||"").match(nu)||[""],h=l.length;h--;){var c=eu.exec(l[h]),d=c[1],f=c[2];if(void 0===f&&(f=""),d){var p=f.split(".").sort(),g=iu.event.special[d],v=g&&(r?g.delegateType:g.bindType)||d;g=iu.event.special[v];var m=Object.assign({type:v,origType:d,data:i,handler:n,guid:n.guid,selector:r,namespace:p.join(".")},o),y=void 0;(y=a[v])||((y=a[v]=[]).delegateCount=0,g&&g.setup&&!1!==g.setup.call(e,i,p,s)||e.addEventListener&&e.addEventListener(v,s)),g&&g.add&&(g.add.call(e,m),m.handler.guid||(m.handler.guid=n.guid)),r?y.splice(y.delegateCount++,0,m):y.push(m)}}}},iu.event.remove=function(t,e,n,i,r){var o=Xs.get(t);if(o&&o.events){for(var a=o.events,s=(e||"").match(nu)||[""],u=s.length;u--;){var l=eu.exec(s[u]),h=l[1],c=l[2];if(void 0===c&&(c=""),h){var d=iu.event.special[h],f=d&&(i?d.delegateType:d.bindType)||h,p=a[f];if(p&&0!==p.length){for(var g=c.split(".").sort(),v=c?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=p.length,y=m;y--;){var b=p[y];!r&&h!==b.origType||n&&n.guid!==b.guid||v&&!v.test(b.namespace)||i&&i!==b.selector&&("**"!==i||!b.selector)||(p.splice(y,1),b.selector&&p.delegateCount--,d&&d.remove&&d.remove.call(t,b))}m&&0===p.length&&(d&&d.teardown&&!1!==d.teardown.call(t,g,o.handle)||t.removeEventListener&&t.removeEventListener(f,o.handle),delete a[f])}}else for(var w in a)iu.event.remove(t,w+s[u],n,i,!0)}Ss(a)&&(Xs.remove(t,"handle"),Xs.remove(t,"events"))}},iu.event.dispatch=function(t){var e=iu.event.fix(t);e.delegateTarget=this;var n=Array.from(arguments);n[0]=e;var i=Xs.get(this,"events"),r=i&&i[e.type]||[],o=iu.event.special[e.type];if(!o||!o.preDispatch||!1!==o.preDispatch.call(this,e)){for(var a,s=iu.event.handlers.call(this,e,r),u=0;(a=s[u++])&&!e.isPropagationStopped();){e.currentTarget=a.elem;for(var l=0,h=void 0;(h=a.handlers[l++])&&!e.isImmediatePropagationStopped();){e.handleObj=h,e.data=h.data;var c=iu.event.special[h.origType],d=(c&&c.handle?c.handle:h.handler).apply(a.elem,n);void 0!==d&&!1===(e.result=d)&&(e.preventDefault(),e.stopPropagation())}}return o&&o.postDispatch&&o.postDispatch.call(this,e),e.result}},iu.event.handlers=function(t,e){var n=e.delegateCount,i=[];if(n&&!("click"===t.type&&1<=t.button))for(var r=t.target;r!==this;r=r.parentNode||this)if(1===r.nodeType&&("click"!==t.type||!0!==r.disabled)){for(var o=[],a={},s=0;s<n;s++){var u=e[s],l=u.selector+" ";void 0===a[l]&&(a[l]=r.matches(l)),a[l]&&o.push(u)}o.length&&i.push({elem:r,handlers:o})}return n<e.length&&i.push({elem:this,handlers:e.slice(n)}),i},iu.event.fix=function(t){return t.envelope?t:new Zs(t)};var au=iu(Qs),su=function(){if(!("object"==typeof window&&!!window.SVGAngle))return function(){throw new Error("SVG is required to use Vectorizer.")};var F={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},t=Math,g=t.PI,o=t.atan2,a=t.sqrt,c=t.min,d=t.max,v=t.cos,m=t.sin,B=function(t,e,n){if(!(this instanceof B))return B.apply(Object.create(B.prototype),arguments);if(t){if(B.isV(t)&&(t=t.node),e=e||{},B.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=B.createSvgDocument();else if("<"===t[0]){var i=B.createSvgDocument(t);if(1<i.childNodes.length){var r,o,a=[];for(r=0,o=i.childNodes.length;r<o;r++){var s=i.childNodes[r];a.push(new B(document.importNode(s,!0)))}return a}t=document.importNode(i.firstChild,!0)}else t=document.createElementNS(F.svg,t);B.ensureId(t)}return this.node=t,this.setAttributes(e),n&&this.append(n),this}},e=B.prototype;function V(t,e,n){n||(n={});for(var i=n.includeAnnotationIndices,r=n.eol,o=n.lineHeight,a=n.baseSize,s=0,u={},l=e.length-1,h=0;h<=l;h++){var c=e[h],d=null;if(B.isObject(c)){var f=c.attrs,p=B("tspan",f),g=p.node,v=c.t;r&&h===l&&(v+=r),g.textContent=v;var m=f.class;m&&p.addClass(m),i&&p.attr("annotations",c.annotations),d=parseFloat(f["font-size"]),isFinite(d)||(d=a),d&&s<d&&(s=d)}else r&&h===l&&(c+=r),g=document.createTextNode(c||" "),a&&s<a&&(s=a);t.appendChild(g)}return s&&(u.maxFontSize=s),o?u.lineHeight=o:s&&(u.lineHeight=1.2*s),u}Object.defineProperty(e,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),e.getTransformToElement=function(t){var e=this.node;if(B.isSVGGraphicsElement(t)&&B.isSVGGraphicsElement(e)){var n=B.toNode(t).getScreenCTM(),i=e.getScreenCTM();if(n&&i)return n.inverse().multiply(i)}return B.createSVGMatrix()},e.transform=function(t,e){var n=this.node;if(B.isUndefined(t))return B.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",B.matrixToTransformString(t));var i=B.createSVGTransform(t);return n.transform.baseVal.appendItem(i),this},e.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=B.parseTransformString(i);if(i=r.value,B.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();var o="translate("+(n.absolute?t:r.translate.tx+t)+","+(n.absolute?e:r.translate.ty+e)+")";return this.attr("transform",(o+" "+i).trim()),this},e.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=B.parseTransformString(r);if(r=o.value,B.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;var a="rotate("+(i.absolute?t:o.rotate.angle+t)+(void 0!==e&&void 0!==n?","+e+","+n:"")+")";return this.attr("transform",(r+" "+a).trim()),this},e.scale=function(t,e){e=B.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=B.parseTransformString(n);if(n=i.value,B.isUndefined(t))return i.scale;n=n.replace(/scale\([^)]*\)/g,"").trim();var r="scale("+t+","+e+")";return this.attr("transform",(n+" "+r).trim()),this},e.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new Ei(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(t)return new Ei(n);var o=this.getTransformToElement(e||r);return B.transformRect(n,o)},e.getBBox=function(t){var e,n={},i=this.node;if(!i.ownerSVGElement||!B.isSVGGraphicsElement(i))return new Ei(0,0,0,0);if(t&&(t.target&&(n.target=B.toNode(t.target)),t.recursive&&(n.recursive=t.recursive)),n.recursive){var r=this.children(),o=r.length;if(0===o)return this.getBBox({target:n.target,recursive:!1});n.target||(n.target=this);for(var a=0;a<o;a++){var s,u=r[a];s=0===u.children().length?u.getBBox({target:n.target,recursive:!1}):u.getBBox({target:n.target,recursive:!0}),e=e?e.union(s):s}return e}try{e=i.getBBox()}catch(t){e={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(n.target){var l=this.getTransformToElement(n.target);return B.transformRect(e,l)}return new Ei(e)};var I=/em$/;function D(t,e){var n=parseFloat(t);return I.test(t)?n*e:n}e.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");t=B.sanitizeText(t),e||(e={});var n=e.displayEmpty,i=e.eol,r=e.textPath,o=e.textVerticalAnchor,a="middle"===o||"bottom"===o||"top"===o,s=e.x;void 0===s&&(s=this.attr("x")||0);var u=e.includeAnnotationIndices,l=e.annotations;l&&!B.isArray(l)&&(l=[l]);var h=e.lineHeight,c="auto"===h,d=c?"1.5em":h||"1em";this.empty(),this.attr({"xml:space":"preserve",display:t||n?null:"none"});var f=parseFloat(this.attr("font-size"));f||(f=16,(a||l)&&this.attr("font-size",f));var p,g=document;p=r?("string"==typeof r&&(r={d:r}),function(t,e){t||(t={});var n=B("textPath"),i=t.d;if(i&&void 0===t["xlink:href"]){var r=B("path").attr("d",i).appendTo(e.defs());n.attr("xlink:href","#"+r.id)}return B.isObject(t)&&n.attr(t),n.node}(r,this)):g.createDocumentFragment();for(var v,m=0,y=t.split("\n"),b=[],w=0,x=y.length-1;w<=x;w++){var A,T=d,P="v-line",E=g.createElementNS(F.svg,"tspan"),S=y[w];if(S)if(l){var k=B.annotateString(S,l,{offset:-m,includeAnnotationIndices:u}),M=(A=V(E,k,{includeAnnotationIndices:u,eol:w!==x&&i,lineHeight:c?null:d,baseSize:f})).lineHeight;M&&c&&0!==w&&(T=M),0===w&&(v=.8*A.maxFontSize)}else i&&w!==x&&(S+=i),E.textContent=S;else{E.textContent="-",P+=" v-empty-line";var L=E.style;if(L.fillOpacity=0,L.strokeOpacity=0,l){A={};for(var C=f,_=(k=B.findAnnotationsAtIndex(l,m)).length;0<_;_--){var N=k[_-1].attrs;if(N&&"font-size"in N){var O=parseFloat(N["font-size"]);if(isFinite(O)){C=O;break}}}c&&(0<w?T=1.2*C:v=.8*C),E.setAttribute("font-size",C),A.maxFontSize=C}}A&&b.push(A),0<w&&E.setAttribute("dy",T),(0<w||r)&&E.setAttribute("x",s),E.className.baseVal=P,p.appendChild(E),m+=S.length+1}if(a)if(l)T=function(t,e,n,i){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],a=D(o.maxFontSize,n)||n,s=0,u=D(i,n),l=1;l<r;l++)s+=D((o=e[l]).lineHeight,n)||u;var h,c=D(o.maxFontSize,n)||n;switch(t){case"middle":h=a/2-.15*c-s/2;break;case"bottom":h=-.25*c-s;break;default:case"top":h=.8*a}return h}(o,b,f,d);else if("top"===o)T="0.8em";else{var R;switch(0<x?(R=parseFloat(d)||1,R*=x,I.test(d)||(R/=f)):R=0,o){case"middle":T=.3-R/2+"em";break;case"bottom":T=-R-.3+"em"}}else 0===o?T="0em":o?T=o:(T=0,null===this.attr("y")&&this.attr("y",v||"0.8em"));return p.firstChild.setAttribute("dy",T),this.append(p),this},e.removeAttr=function(t){var e=s[t],n=B.qualifyAttr(e),i=n.ns,r=n.local,o=this.node;return i?o.hasAttributeNS(i,r)&&o.removeAttributeNS(i,r):o.hasAttribute(e)&&o.removeAttribute(e),this},e.attr=function(t,e){if(B.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(B.isString(t)&&B.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},e.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",B.normalizePathData(this.attr("d"))),this},e.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},e.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},e.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},e.append=function(t){B.isArray(t)||(t=[t]);for(var e=0,n=t.length;e<n;e++)this.node.appendChild(B.toNode(t[e]));return this},e.prepend=function(t){var e=this.node.firstChild;return e?B(e).before(t):this.append(t)},e.before=function(t){var e=this.node,n=e.parentNode;if(n){B.isArray(t)||(t=[t]);for(var i=0,r=t.length;i<r;i++)n.insertBefore(B.toNode(t[i]),e)}return this},e.appendTo=function(t){return B.toNode(t).appendChild(this.node),this},e.svg=function(){return this.node instanceof window.SVGSVGElement?this:B(this.node.ownerSVGElement)},e.tagName=function(){return this.node.tagName.toUpperCase()},e.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?B(e):B("defs").appendTo(t)},e.clone=function(){var t=B(this.node.cloneNode(!0));return t.node.id=B.uniqueId(),t},e.findOne=function(t){var e=this.node.querySelector(t);return e?B(e):void 0},e.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(B(n[i]));return e},e.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++){1===t[n].nodeType&&e.push(B(t[n]))}return e},e.parent=function(){return B(this.node.parentNode)||null},e.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},e.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=B(i);if(r.hasClass(t))return r;i=i.parentNode}return null},e.contains=function(t){var e=this.node,n=B.toNode(t),i=n&&n.parentNode;return e===i||!!(i&&1===i.nodeType&&16&e.compareDocumentPosition(i))},e.toLocalPoint=function(t,e){var n=this.svg().node,i=n.createSVGPoint();i.x=t,i.y=e;try{var r=i.matrixTransform(n.getScreenCTM().inverse()),o=this.getTransformToElement(n).inverse()}catch(t){return i}return r.matrixTransform(o)},e.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},e.translateAndAutoOrient=function(t,e,n){t=new si(t),e=new si(e),n||(n=this.svg());var i=this.scale();this.attr("transform","");var r=this.getBBox({target:n}).scale(i.sx,i.sy),o=B.createSVGTransform();o.setTranslate(-r.x-r.width/2,-r.y-r.height/2);var a=B.createSVGTransform(),s=t.angleBetween(e,t.clone().offset(1,0));s&&a.setRotate(s,0,0);var u=B.createSVGTransform(),l=t.clone().move(e,r.width/2);u.setTranslate(2*t.x-l.x,2*t.y-l.y);var h=this.getTransformToElement(n),c=B.createSVGTransform();return c.setMatrix(u.matrix.multiply(a.matrix.multiply(o.matrix.multiply(h.scale(i.sx,i.sy))))),this.attr("transform",B.matrixToTransformString(c.matrix)),this},e.animateAlongPath=function(t,e){e=B.toNode(e);var n=B.ensureId(e),i=B("animateMotion",t),r=B("mpath",{"xlink:href":"#"+n});i.append(r),this.append(i);try{i.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling")){var o=i.node;o.animators=[];var a=o.getAttribute("id");a&&(id2anim[a]=o);for(var s=getTargets(o),u=0,l=s.length;u<l;u++){var h=s[u],c=new Animator(o,h,u);animators.push(c),(o.animators[u]=c).register()}}}return this};var n=/[^\x20\t\r\n\f]+/g;function r(t){return B.isString(t)&&t.trim().match(n)||[]}e.hasClass=function(t){return!!B.isString(t)&&this.node.classList.contains(t.trim())},e.addClass=function(t){var e;return(e=this.node.classList).add.apply(e,r(t)),this},e.removeClass=function(t){var e;return(e=this.node.classList).remove.apply(e,r(t)),this},e.toggleClass=function(t,e){for(var n=r(t),i=0;i<n.length;i++)this.node.classList.toggle(n[i],e);return this},e.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},e.convertToPath=function(){var t=B("path");t.attr(this.attr());var e=this.convertToPathData();return e&&t.attr("d",e),t},e.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return B.convertLineToPathData(this.node);case"POLYGON":return B.convertPolygonToPathData(this.node);case"POLYLINE":return B.convertPolylineToPathData(this.node);case"ELLIPSE":return B.convertEllipseToPathData(this.node);case"CIRCLE":return B.convertCircleToPathData(this.node);case"RECT":return B.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},B.prototype.toGeometryShape=function(){var t,e,n,i,r,o,a,s,u,l,h,c,d,f,p;switch(this.tagName()){case"RECT":return t=parseFloat(this.attr("x"))||0,e=parseFloat(this.attr("y"))||0,n=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new Ei(t,e,n,i);case"CIRCLE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,a=parseFloat(this.attr("r"))||0,new vi({x:r,y:o},a,a);case"ELLIPSE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,u=parseFloat(this.attr("ry"))||0,new vi({x:r,y:o},s,u);case"POLYLINE":return l=B.getPointsFromSvgNode(this),new Ci(l);case"POLYGON":return 1<(l=B.getPointsFromSvgNode(this)).length&&l.push(l[0]),new Ci(l);case"PATH":return h=this.attr("d"),Ii.isDataSupported(h)||(h=B.normalizePathData(h)),new Ii(h);case"LINE":return c=parseFloat(this.attr("x1"))||0,f=parseFloat(this.attr("y1"))||0,d=parseFloat(this.attr("x2"))||0,p=parseFloat(this.attr("y2"))||0,new ci({x:c,y:f},{x:d,y:p})}return this.getBBox()},e.findIntersection=function(t,e){var n=this.svg().node;e=e||n;var i=this.getBBox({target:e}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){var o,a=this.tagName();if("RECT"===a){var s=new Ei(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),u=this.getTransformToElement(e),l=B.decomposeMatrix(u),h=n.createSVGTransform();h.setRotate(-l.rotation,r.x,r.y);var c=B.transformRect(s,h.matrix.multiply(u));o=new Ei(c).intersectionWithLineFromCenterToPoint(t,l.rotation)}else if("PATH"===a||"POLYGON"===a||"POLYLINE"===a||"CIRCLE"===a||"ELLIPSE"===a){var d,f,p,g,v,m=("PATH"===a?this:this.convertToPath()).sample(),y=1/0,b=[];for(d=0;d<m.length;d++)f=m[d],p=(p=B.createSVGPoint(f.x,f.y)).matrixTransform(this.getTransformToElement(e)),(v=(f=new si(p)).distance(r)+(g=1.1*f.distance(t)))<y?(y=v,b=[{sample:f,refDistance:g}]):v<y+1&&b.push({sample:f,refDistance:g});b.sort(function(t,e){return t.refDistance-e.refDistance}),b[0]&&(o=b[0].sample)}return o}},e.setAttribute=function(t,e){var n=this.node;if(null===e)return this.removeAttr(t),this;var i=s[t],r=B.qualifyAttr(i).ns;return r?n.setAttributeNS(r,i,e):"id"===i?n.id=e:n.setAttribute(i,e),this},B.createSvgDocument=function(t){if(t){var e='<svg xmlns="'+F.svg+'" xmlns:xlink="'+F.xlink+'" version="1.1">'+t+"</svg>";return B.parseXML(e,{async:!1}).documentElement}var n=document.createElementNS(F.svg,"svg");return n.setAttributeNS(F.xmlns,"xmlns:xlink",F.xlink),n.setAttribute("version","1.1"),n},B.createSVGStyle=function(t){return B("style",{type:"text/css"},[B.createCDATASection(t)]).node},B.createCDATASection=function(t){return void 0===t&&(t=""),document.implementation.createDocument(null,"xml",null).createCDATASection(t)},B.idCounter=0,B.uniqueId=function(){return"v-"+ ++B.idCounter},B.toNode=function(t){return B.isV(t)?t.node:t.nodeName&&t||t[0]},B.ensureId=function(t){return(t=B.toNode(t)).id||(t.id=B.uniqueId())},B.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},B.isUndefined=function(t){return void 0===t},B.isString=function(t){return"string"==typeof t},B.isObject=function(t){return t&&"object"==typeof t},B.isArray=Array.isArray,B.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;B.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch(t){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};var i=Object.create(null);["baseFrequency","baseProfile","clipPathUnits","contentScriptType","contentStyleType","diffuseConstant","edgeMode","externalResourcesRequired","filterRes","filterUnits","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach(function(t){return i[t]=t}),i.xlinkShow="xlink:show",i.xlinkRole="xlink:role",i.xlinkActuate="xlink:actuate",i.xlinkHref="xlink:href",i.xlinkType="xlink:type",i.xlinkTitle="xlink:title",i.xmlBase="xml:base",i.xmlLang="xml:lang",i.xmlSpace="xml:space";var s=new Proxy(i,{get:function(t,e){return B.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e}});Object.defineProperty(B,"attributeNames",{enumerable:!0,value:s,writable:!1}),Object.defineProperty(B,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),B.qualifyAttr=function(t){if(-1===t.indexOf(":"))return{ns:null,local:t};var e=t.split(":");return{ns:F[e[0]],local:e[1]}},B.transformSeparatorRegex=/[ ,]+/,B.transformRegex=/\b\w+\([^()]+\)/g,B.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,B.transformTranslateRegex=/\btranslate\(([^()]+)\)/,B.transformRotateRegex=/\brotate\(([^()]+)\)/,B.transformScaleRegex=/\bscale\(([^()]+)\)/,B.transformStringToMatrix=function(t){var e=B.createSVGMatrix(),n=t&&t.match(B.transformRegex);if(!n)return e;for(var i=n.length,r=0;r<i;r++){var o=n[r].match(B.transformFunctionRegex);if(o){var a=void 0,s=void 0,u=void 0,l=void 0,h=void 0,c=B.createSVGMatrix(),d=o[1].toLowerCase(),f=o[2].split(B.transformSeparatorRegex);switch(d){case"scale":a=parseFloat(f[0]),s=void 0===f[1]?a:parseFloat(f[1]),c=c.scaleNonUniform(a,s);break;case"translate":u=parseFloat(f[0]),l=parseFloat(f[1]),c=c.translate(u,l);break;case"rotate":h=parseFloat(f[0]),u=parseFloat(f[1])||0,l=parseFloat(f[2])||0,c=0!==u||0!==l?c.translate(u,l).rotate(h).translate(-u,-l):c.rotate(h);break;case"skewx":h=parseFloat(f[0]),c=c.skewX(h);break;case"skewy":h=parseFloat(f[0]),c=c.skewY(h);break;case"matrix":c.a=parseFloat(f[0]),c.b=parseFloat(f[1]),c.c=parseFloat(f[2]),c.d=parseFloat(f[3]),c.e=parseFloat(f[4]),c.f=parseFloat(f[5]);break;default:continue}e=e.multiply(c)}}return e},B.matrixToTransformString=function(t){return t||(t=!0),"matrix("+(void 0!==t.a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},B.parseTransformString=function(t){var e,n,i;if(t){var r=B.transformSeparatorRegex;if(0<=t.trim().indexOf("matrix")){var o=B.transformStringToMatrix(t),a=B.decomposeMatrix(o);e=[a.translateX,a.translateY],i=[a.scaleX,a.scaleY],n=[a.rotation];var s=[];0===e[0]&&0===e[1]||s.push("translate("+e+")"),1===i[0]&&1===i[1]||s.push("scale("+i+")"),0!==n[0]&&s.push("rotate("+n+")"),t=s.join(" ")}else{var u=t.match(B.transformTranslateRegex);u&&(e=u[1].split(r));var l=t.match(B.transformRotateRegex);l&&(n=l[1].split(r));var h=t.match(B.transformScaleRegex);h&&(i=h[1].split(r))}}var c=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:e&&e[0]?parseInt(e[0],10):0,ty:e&&e[1]?parseInt(e[1],10):0},rotate:{angle:n&&n[0]?parseInt(n[0],10):0,cx:n&&n[1]?parseInt(n[1],10):void 0,cy:n&&n[2]?parseInt(n[2],10):void 0},scale:{sx:c,sy:i&&i[1]?parseFloat(i[1]):c}}},B.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c+0,y:e.x*t.b+e.y*t.d+0}},B.decomposeMatrix=function(t){var e=B.deltaTransformPoint(t,{x:0,y:1}),n=B.deltaTransformPoint(t,{x:1,y:0}),i=180/g*o(e.y,e.x)-90,r=180/g*o(n.y,n.x);return{translateX:t.e,translateY:t.f,scaleX:a(t.a*t.a+t.b*t.b),scaleY:a(t.c*t.c+t.d*t.d),skewX:i,skewY:r,rotation:i}},B.matrixToScale=function(t){var e,n,i,r;return t?(e=B.isUndefined(t.a)?1:t.a,r=B.isUndefined(t.d)?1:t.d,n=t.b,i=t.c):e=r=1,{sx:n?a(e*e+n*n):e,sy:i?a(i*i+r*r):r}},B.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=B.deltaTransformPoint(t,e)),{angle:Dn(zn(o(e.y,e.x))-90)}},B.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},B.isV=function(t){return t instanceof B},B.isVElement=B.isV,B.isSVGGraphicsElement=function(t){return!!t&&((t=B.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM)};var f=B("svg").node;return B.createSVGMatrix=function(t){var e=f.createSVGMatrix();for(var n in t)e[n]=t[n];return e},B.createSVGTransform=function(t){return B.isUndefined(t)?f.createSVGTransform():(t instanceof SVGMatrix||(t=B.createSVGMatrix(t)),f.createSVGTransformFromMatrix(t))},B.createSVGPoint=function(t,e){var n=f.createSVGPoint();return n.x=t,n.y=e,n},B.transformRect=function(t,e){var n=f.createSVGPoint();n.x=t.x,n.y=t.y;var i=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y;var r=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y+t.height;var o=n.matrixTransform(e);n.x=t.x,n.y=t.y+t.height;var a=n.matrixTransform(e),s=c(i.x,r.x,o.x,a.x),u=d(i.x,r.x,o.x,a.x),l=c(i.y,r.y,o.y,a.y),h=d(i.y,r.y,o.y,a.y);return new Ei(s,l,u-s,h-l)},B.transformPoint=function(t,e){return new si(B.createSVGPoint(t.x,t.y).matrixTransform(e))},B.transformLine=function(t,e){return new ci(B.transformPoint(t.start,e),B.transformPoint(t.end,e))},B.transformPolyline=function(t,e){var n=t instanceof Ci?t.points:t;B.isArray(n)||(n=[]);for(var i=[],r=0,o=n.length;r<o;r++)i[r]=B.transformPoint(n[r],e);return new Ci(i)},B.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},B.createSlicePathData=function(t,e,n,i){var r=2*g-1e-6,o=t,a=e,s=n,u=i,l=(u<s&&(l=s,s=u,u=l),u-s),h=l<g?"0":"1",c=v(s),d=m(s),f=v(u),p=m(u);return r<=l?o?"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"M0,"+o+"A"+o+","+o+" 0 1,0 0,"+-o+"A"+o+","+o+" 0 1,0 0,"+o+"Z":"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z":o?"M"+a*c+","+a*d+"A"+a+","+a+" 0 "+h+",1 "+a*f+","+a*p+"L"+o*f+","+o*p+"A"+o+","+o+" 0 "+h+",0 "+o*c+","+o*d+"Z":"M"+a*c+","+a*d+"A"+a+","+a+" 0 "+h+",1 "+a*f+","+a*p+"L0,0Z"},B.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?B.isObject(t[n])&&B.isObject(e[n])?t[n]=B.mergeAttrs(t[n],e[n]):B.isObject(t[n])?t[n]=B.mergeAttrs(t[n],B.styleToObject(e[n])):B.isObject(e[n])?t[n]=B.mergeAttrs(B.styleToObject(t[n]),e[n]):t[n]=B.mergeAttrs(B.styleToObject(t[n]),B.styleToObject(e[n])):t[n]=e[n];return t},B.annotateString=function(t,e,n){e=e||[];for(var i,r,o,a=(n=n||{}).offset||0,s=[],u=[],l=0;l<t.length;l++){r=u[l]=t[l];for(var h=0;h<e.length;h++){var c=e[h],d=c.start+a,f=c.end+a;d<=l&&l<f&&(B.isObject(r)?r.attrs=B.mergeAttrs(B.mergeAttrs({},r.attrs),c.attrs):r=u[l]={t:t[l],attrs:c.attrs},n.includeAnnotationIndices&&(r.annotations||(r.annotations=[])).push(h))}(o=u[l-1])?B.isObject(r)&&B.isObject(o)?JSON.stringify(r.attrs)===JSON.stringify(o.attrs)?i.t+=r.t:(s.push(i),i=r):i=B.isObject(r)?(s.push(i),r):B.isObject(o)?(s.push(i),r):(i||"")+r:i=r}return i&&s.push(i),s},B.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&n.push(t)}),n},B.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},B.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},B.convertLineToPathData=function(t){return["M",(t=B(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},B.convertPolygonToPathData=function(t){var e=B.getPointsFromSvgNode(t);return 0===e.length?null:B.svgPointsToPath(e)+" Z"},B.convertPolylineToPathData=function(t){var e=B.getPointsFromSvgNode(t);return 0===e.length?null:B.svgPointsToPath(e)},B.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")},B.getPointsFromSvgNode=function(t){var e=[],n=(t=B.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},B.KAPPA=.551784,B.convertCircleToPathData=function(t){t=B(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("r")),r=i*B.KAPPA;return["M",e,n-i,"C",e+r,n-i,e+i,n-r,e+i,n,"C",e+i,n+r,e+r,n+i,e,n+i,"C",e-r,n+i,e-i,n+r,e-i,n,"C",e-i,n-r,e-r,n-i,e,n-i,"Z"].join(" ")},B.convertEllipseToPathData=function(t){t=B(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),r=parseFloat(t.attr("ry"))||i,o=i*B.KAPPA,a=r*B.KAPPA;return["M",e,n-r,"C",e+o,n-r,e+i,n-a,e+i,n,"C",e+i,n+a,e+o,n+r,e,n+r,"C",e-o,n+r,e-i,n+a,e-i,n,"C",e-i,n-a,e-o,n-r,e,n-r,"Z"].join(" ")},B.convertRectToPathData=function(t){return t=B(t),B.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})},B.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=c(t.rx||t["top-rx"]||0,i/2),a=c(t.rx||t["bottom-rx"]||0,i/2),s=c(t.ry||t["top-ry"]||0,r/2),u=c(t.ry||t["bottom-ry"]||0,r/2);return(o||a||s||u?["M",e,n+s,"v",r-s-u,"a",a,u,0,0,0,a,u,"h",i-2*a,"a",a,u,0,0,0,a,-u,"v",-(r-u-s),"a",o,s,0,0,0,-o,-s,"h",-(i-2*o),"a",o,s,0,0,0,-o,s,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"]).join(" ")},B.normalizePathData=function(){var 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",g=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),v=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),e=Math,U=e.PI,H=e.sin,q=e.cos,W=e.tan,Y=e.asin,X=e.sqrt,$=e.abs;function d(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 Z(t,e,n){return{x:t*q(n)-e*H(n),y:t*H(n)+e*q(n)}}function f(t){if(Array.isArray(t)&&Array.isArray(t&&t[0])||(t=function(t){if(!t)return null;var o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},a=[];return String(t).replace(g,function(t,e,n){var i=[],r=e.toLowerCase();for(n.replace(v,function(t,e){e&&i.push(+e)}),"m"===r&&2<i.length&&(a.push([e].concat(i.splice(0,2))),r="l",e="m"===e?"l":"L");i.length>=o[r]&&(a.push([e].concat(i.splice(0,o[r]))),o[r]););}),a}(t)),!t||!t.length)return[["M",0,0]];for(var e,n=[],i=0,r=0,o=0,a=0,s=t.length,u=0;u<s;u++){var l=[];n.push(l);var h,c,d=t[u];if((e=d[0])!=e.toUpperCase())switch(l[0]=e.toUpperCase(),l[0]){case"A":l[1]=d[1],l[2]=d[2],l[3]=d[3],l[4]=d[4],l[5]=d[5],l[6]=+d[6]+i,l[7]=+d[7]+r;break;case"V":l[1]=+d[1]+r;break;case"H":l[1]=+d[1]+i;break;case"M":for(o=+d[1]+i,a=+d[2]+r,h=d.length,c=1;c<h;c++)l[c]=+d[c]+(c%2?i:r);break;default:for(h=d.length,c=1;c<h;c++)l[c]=+d[c]+(c%2?i:r)}else for(var f=d.length,p=0;p<f;p++)l[p]=d[p];switch(l[0]){case"Z":i=+o,r=+a;break;case"H":i=l[1];break;case"V":r=l[1];break;case"M":o=l[l.length-2],a=l[l.length-1],i=l[l.length-2],r=l[l.length-1];break;default:i=l[l.length-2],r=l[l.length-1]}}return n}function n(t){var i=f(t),e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function n(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(function t(e,n,i,r,o,a,s,u,l,h){var c,d=120*U/180,f=U/180*(+o||0),p=[];if(h)T=h[0],P=h[1],x=h[2],A=h[3];else{e=(c=Z(e,n,-f)).x,n=c.y;var g=(e-(u=(c=Z(u,l,-f)).x))/2,v=(n-(l=c.y))/2,m=g*g/(i*i)+v*v/(r*r);1<m&&(i*=m=X(m),r*=m);var y=i*i,b=r*r,w=(a==s?-1:1)*X($((y*b-y*v*v-b*g*g)/(y*v*v+b*g*g)));if(!Number.isFinite(w))return[e,n,u,l,u,l];var x=w*i*v/r+(e+u)/2,A=w*-r*g/i+(n+l)/2,T=Y(((n-A)/r).toFixed(9)),P=Y(((l-A)/r).toFixed(9));(T=e<x?U-T:T)<0&&(T=2*U+T),(P=u<x?U-P:P)<0&&(P=2*U+P),s&&P<T&&(T-=2*U),!s&&T<P&&(P-=2*U)}var E=P-T;if($(E)>d){var S=P,k=u,M=l;p=t(u=x+i*q(P=T+d*(s&&T<P?1:-1)),l=A+r*H(P),i,r,o,0,s,k,M,[P,S,x,A])}E=P-T;var L=q(T),C=H(T),_=q(P),N=H(P),O=W(E/4),R=4/3*(i*O),F=4/3*(r*O),B=[e,n],V=[e+R*C,n-F*L],I=[u+R*N,l-F*_],D=[u,l];if(V[0]=2*B[0]-V[0],V[1]=2*B[1]-V[1],h)return[V,I,D].concat(p);for(var j=[],z=(p=[V,I,D].concat(p).join().split(",")).length,G=0;G<z;G++)j[G]=G%2?Z(p[G-1],p[G],f).y:Z(p[G],p[G+1],f).x;return j}.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(d(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(d(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}function r(t,e){if(7<t[e].length){t[e].shift();for(var n=t[e];n.length;)o[e]="A",t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),u=i.length}}for(var o=[],a="",s="",u=i.length,l=0;l<u;l++){i[l]&&(a=i[l][0]),"C"!==a&&(o[l]=a,0<l&&(s=o[l-1])),i[l]=n(i[l],e,s),"A"!==o[l]&&"C"===a&&(o[l]="C"),r(i,l);var h=i[l],c=h.length;e.x=h[c-2],e.y=h[c-1],e.bx=parseFloat(h[c-4])||e.x,e.by=parseFloat(h[c-3])||e.y}return i[0][0]&&"M"===i[0][0]||i.unshift(["M",0,0]),i}return function(t){return n(t).join(",").split(",").join(" ")}}(),B.namespace=F,B.g=Mr,B}();function uu(t){for(var e=t.length;e--;)lu(t[e])}function lu(t){iu.event.remove(t),Xs.remove(t),$s.remove(t)}function hu(t){for(var e=0;e<t.length;e++){var n=t[e];n.parentNode&&n.parentNode.removeChild(n)}}var cu={};function du(t,e,n){for(var i=0;i<e.length;i++){var r=e[i];su.prototype[t].apply({node:r},n)}}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach(function(t){cu[t]=!0});var fu={remove:function(){for(var t=0;t<this.length;t++){var e=this[t];lu(e),uu(e.getElementsByTagName("*"))}return hu(this),this},detach:function(){return hu(this),this},empty:function(){for(var t=0;t<this.length;t++){var e=this[t];1===e.nodeType&&(uu(e.getElementsByTagName("*")),e.textContent="")}return this},clone:function(){for(var t=[],e=0;e<this.length;e++)t.push(this[e].cloneNode(!0));return this.pushStack(t)},html:function(t){var e=this[0];return e?0===arguments.length?e.innerHTML:void 0===t?this:(uu(Xs,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t?(e.innerHTML="",this.append(t)):(e.innerHTML=t,this)):null},append:function(){for(var i=this,t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this[0];return r&&t.forEach(function(t){var e,n;t&&("string"==typeof t?r.append.apply(r,iu.parseHTML(t)):"[object Object]"===t.toString()?(e=i).append.apply(e,Array.from(t)):Array.isArray(t)?(n=i).append.apply(n,t):r.appendChild(t))}),this},prepend:function(){for(var i=this,t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this[0];return r&&t.forEach(function(t){var e,n;t&&("string"==typeof t?r.prepend.apply(r,iu.parseHTML(t)):"[object Object]"===t.toString()?(e=i).prepend.apply(e,Array.from(t)):Array.isArray(t)?(n=i).prepend.apply(n,t):r.insertBefore(t,r.firstChild))}),this},appendTo:function(t){return iu(t).append(this),this},prependTo:function(t){return iu(t).prepend(this),this},css:function(t,e){var n,i,r,o;if("string"==typeof t){if(void 0===e){var a=this[0];return a?a.style[t]:null}(n={})[t]=e}else{if(!t)throw new Error("no styles provided");n=t}for(var s in n)if(n.hasOwnProperty(s))for(var u=0;u<this.length;u++)i=this[u],"number"==typeof(o=n[r=s])&&cu[Us(r)]&&(o+="px"),i.style[r]=o;return this},data:function(t,e){if(arguments.length<2){var n=this[0];return n?void 0===t?n.dataset:n.dataset[t]:null}for(var i=0;i<this.length;i++)this[i].dataset[t]=e;return this},removeClass:function(){return du("removeClass",this,arguments),this},addClass:function(){return du("addClass",this,arguments),this},toggleClass:function(){return du("toggleClass",this,arguments),this},hasClass:function(){var t=this[0];return!!t&&su.prototype.hasClass.apply({node:t},arguments)},children:function(e){for(var t=[],n=0;n<this.length;n++){var i=this[n],r=Array.from(i.children);"string"==typeof e&&(r=r.filter(function(t){return t.matches(e)})),t.push.apply(t,r)}return this.pushStack(t)},closest:function(t){for(var e=[],n=0;n<this.length;n++){var i=this[n];if("string"==typeof t){var r=i.closest(t);r&&e.push(r)}else{var o=iu(t)[0];o&&o.contains(i)&&e.push(o)}}return this.pushStack(e)},on:function(t,e,n,i){return iu.event.on(this,t,e,n,i),this},one:function(t,e,n,i){return iu.event.on(this,t,e,n,i,1),this},off:function(t,e,n){if(t&&t.preventDefault&&t.handleObj){var i=t.handleObj;return iu(t.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this}if("object"==typeof t){for(var r in t)this.off(r,e,t[r]);return this}!1!==e&&"function"!=typeof e||(n=e,e=void 0);for(var o=0;o<this.length;o++)iu.event.remove(this[o],t,n,e);return this},width:function(){var t=this[0];if(t===window)return t.document.documentElement.clientWidth;if(t){var e=window.getComputedStyle(t),n=t.offsetWidth,i=parseFloat(e.borderTopWidth);return n-parseFloat(e.borderBottomWidth)-i-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)}},height:function(){var t=this[0];if(t===window)return t.document.documentElement.clientHeight;if(t){var e=window.getComputedStyle(t);return t.offsetHeight-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}},position:function(){var t=this[0];if(t){var e,n,i,r=iu(t),o={top:0,left:0};if("fixed"===r.css("position"))n=t.getBoundingClientRect();else{n=r.offset(),i=t.ownerDocument,e=t.offsetParent||i.documentElement;for(var a=iu(e),s=a.css("position")||"static";e&&(e===i.body||e===i.documentElement)&&"static"===s;)e=e.parentNode;if(e&&e!==t&&1===e.nodeType){var u=window.getComputedStyle(e),l=parseFloat(u.borderTopWidth)||0,h=parseFloat(u.borderLeftWidth)||0;(o=a.offset()).top+=l,o.left+=h}}var c=parseFloat(window.getComputedStyle(t).marginTop)||0,d=parseFloat(window.getComputedStyle(t).marginLeft)||0;return{top:n.top-o.top-c,left:n.left-o.left-d}}},offset:function(t){var e=this[0];if(void 0===t){if(!e)return null;if(!e.getClientRects().length)return{top:0,left:0};var n=e.getBoundingClientRect();return{top:n.top+window.scrollY,left:n.left+window.scrollX}}if(!e)return this;var i=window.getComputedStyle(e);"static"===i.position&&this.css("position","relative");var r=this.offset(),o=t.top-r.top,a=t.left-r.left;return this.css({top:(parseFloat(i.top)||0)+o+"px",left:(parseFloat(i.left)||0)+a+"px"}),this}},pu="animationFrameId",gu={};function vu(u,l,t){void 0===t&&(t={});var h=t.duration;void 0===h&&(h=400);var c=t.easing;void 0===c&&(c="ease-in-out");var d=t.delay;void 0===d&&(d=0);var f=t.complete,e=setTimeout(function(){var e=iu(u),n=!1,i="transitionend";h/=1e3,d/=1e3;var t={};if("string"==typeof l)t["animation-name"]=l,t["animation-duration"]=h+"s",t["animation-delay"]=d+"s",t["animation-timing-function"]=c,i="animationend";else{var r=[];for(var o in l)l.hasOwnProperty(o)&&(t[o]=l[o],r.push(o));0<h&&(t["transition-property"]=r.join(", "),t["transition-duration"]=h+"s",t["transition-delay"]=d+"s",t["transition-timing-function"]=c)}var a=function(t){if(t){if(t.target!==t.currentTarget)return;t.target.removeEventListener(i,a)}else u.removeEventListener(i,a);n=!0,e.css(gu),f&&f.call(u)};if(0<h){u.addEventListener(i,a);var s=setTimeout(function(){n||a(null)},1e3*(h+d)+25);Xs.set(u,pu,{id:s,stop:function(){clearTimeout(s),u.removeEventListener(i,a)}})}e.css(t),h<=0&&a(null)});Xs.set(u,pu,{stop:function(){return clearTimeout(e)}})}gu["transition-property"]=gu["transition-duration"]=gu["transition-delay"]=gu["transition-timing-function"]=gu["animation-name"]=gu["animation-duration"]=gu["animation-delay"]=gu["animation-timing-function"]="";var mu={animate:function(t,e){void 0===e&&(e={}),this.stop();for(var n=0;n<this.length;n++)vu(this[n],t,e);return this},stop:function(){for(var t=0;t<this.length;t++){var e=this[t],n=Xs.get(e,pu);n&&(n.stop(),Xs.remove(e,pu))}return this.css(gu),this}},yu={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},bu={disabled:"disabled",value:"value",text:"textContent"};var wu={prop:function(t,e){if(!t)throw new Error("no property provided");if(1===arguments.length){var n=this[0];return n?n[t]:null}if(void 0===e)return this;for(var i=0;i<this.length;i++)this[i][t]=e;return this},attr:function(t,e){var n;if("string"==typeof t){if(void 0===e){var i=this[0];return 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)){var o=n[r];if(bu[r]){this.prop(bu[r],o);continue}for(var a=0;a<this.length;a++)null===o?this[a].removeAttribute(r):this[a].setAttribute(r,o)}return this}};Object.keys(yu).forEach(function(i){wu[i]=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];return(t=this).prop.apply(t,[yu[i]].concat(e))}});var xu={useCSSSelectors:!1,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300},Au=Object.create(null);Au.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach(function(t){var e=t[0],r=t[1];Au[e]={delegateType:r,bindType:r,handle:function(t){var e,n=t.relatedTarget,i=t.handleObj;return n&&this.contains(n)||(t.type=i.origType,e=i.handler.apply(this,arguments),t.type=r),e}}});var Tu=xu.doubleTapInterval;Au.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t){for(var e,n=[],i=arguments.length-1;0<i--;)n[i]=arguments[i+1];var r=t.handleObj,o=t.target,a=iu.data.create(o),s=(new Date).getTime(),u="lastTouch"in a?s-a.lastTouch:0;u<Tu&&30<u?(a.lastTouch=null,t.type=r.origType,(e=r.handler).call.apply(e,[this,t].concat(n))):a.lastTouch=s}},Object.assign(iu.fn,fu),Object.assign(iu.fn,mu),Object.assign(iu.fn,wu),Object.assign(iu.event.special,Au);var Pu,Eu,Su=function(t){return t?t.toString().split(" ").map(function(t){return t.substr(0,xu.classNamePrefix.length)!==xu.classNamePrefix&&(t=xu.classNamePrefix+t),t}).join(" "):t},ku=function(t,e){var b={},w={},x=su.namespace.svg,n=e||x,i=document.createDocumentFragment(),A=function(t,e,n){for(var i=0;i<t.length;i++){var r=t[i];if("string"!=typeof r){if(!r.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var o=r.tagName,a=void 0;r.hasOwnProperty("namespaceURI")&&(n=r.namespaceURI),a=document.createElementNS(n,o);var s=n===x,u=s?su(a):iu(a),l=r.attributes;l&&u.attr(l);var h=r.style;if(h&&iu(a).css(h),r.hasOwnProperty("className")){var c=r.className;s?a.className.baseVal=c:a.className=c}if(r.hasOwnProperty("textContent")&&(a.textContent=r.textContent),r.hasOwnProperty("selector")){var d=r.selector;if(b[d])throw new Error("json-dom-parser: selector must be unique");b[d]=a,u.attr("joint-selector",d)}if(r.hasOwnProperty("groupSelector")){var f=r.groupSelector;Array.isArray(f)||(f=[f]);for(var p=0;p<f.length;p++){var g=f[p],v=w[g];v||(v=w[g]=[]),v.push(a)}}e.appendChild(a);var m=r.children;Array.isArray(m)&&A(m,a,n)}else{var y=document.createTextNode(r);e.appendChild(y)}}};return A(t,i,n),{fragment:i,selectors:b,groupSelectors:w}},Mu=function(t){var e=0;if(0===t.length)return e;for(var n=0;n<t.length;n++){e=(e<<5)-e+t.charCodeAt(n),e&=e}return e},Lu=function(t,e,n){for(var i,r=Array.isArray(e)?e:e.split(n||"/"),o=0,a=r.length;o<a;){if(i=r[o++],!(Object(t)===t&&i in t))return;t=t[i]}return t},Cu=function(t,e){return"string"!=typeof e&&"number"!=typeof e&&(e=String(e)),("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!==e},_u=function(t,e,n,i){for(var r=Array.isArray(e)?e:e.split(i||"/"),o=r.length-1,a=t,s=0;s<o;s++){var u=r[s];if(!Cu(a,u))return t;a=a[u]||(a[u]={})}return a[r[o]]=n,t},Nu=function(t,e,n){for(var i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1,o=t,a=0;a<r;a++){var s=i[a];if(!Cu(o,s))return t;var u=o[s];if(!u)return t;o=u}return delete o[i[r]],t},Ou=function(t,e,n){e=e||"/";var i={};for(var r in t)if(t.hasOwnProperty(r)){var o="object"==typeof t[r];if(o&&n&&n(t[r])&&(o=!1),o){var a=Ou(t[r],e,n);for(var s in a)a.hasOwnProperty(s)&&(i[r+e+s]=a[s])}else i[r]=t[r]}return i},Ru=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},Fu=function(t){return Fu.id=Fu.id||1,void 0===t?"j_"+Fu.id++:(t.id=void 0===t.id?"j_"+Fu.id++:t.id,t.id)},Bu=function(t){if(t.normalized)return t;var e=t.originalEvent,n=t.target,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(var r in i)void 0===t[r]&&(t[r]=i[r]);if(n){var o=n.correspondingUseElement;o&&(t.target=o)}return t.normalized=!0,t},Vu=function(t){var 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,e=n,n=r=0),i&&!e&&(e=i<1?-1:1),r&&!n&&(n=r<1?-1:1),{spinX:e,spinY:n,deltaX:i,deltaY:r}},Iu=function(t,e){return e<t?e:t<-e?-e:t},Du=function(){var r;if("undefined"!=typeof window&&(r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!r){var o=0;r=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o)),i=setTimeout(function(){t(e+n)},n);return o=e+n,i}}return function(t,e){for(var n=[],i=arguments.length-2;0<i--;)n[i]=arguments[i+2];return r(void 0!==e?t.bind.apply(t,[e].concat(n)):t)}}(),ju=((Eu="undefined"!=typeof window)&&(Pu=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),Pu=Pu||clearTimeout,Eu?Pu.bind(window):Pu),zu=function(t){return ds(t)&&"%"===t.slice(-1)},Gu=function(t,e){var n=parseFloat(t);if(Number.isNaN(n))return null;var i,r={};if(r.value=n,null==e)i="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;i=e.join("|")}else ds(e)&&(i=e);var o,a=(o=new RegExp("(?:\\d+(?:\\.\\d+)*)("+i+")$").exec(t))?o[1]:null;return null===a?null:(r.unit=a,r)},Uu=0;function Hu(t,e){for(var n=t.split(e),i=1,r=0,o=n.length-1;r<o;r++){var a=[];(0<r||""!==n[0])&&a.push(Uu),a.push(e),(r<o-1||""!==n[o])&&a.push(Uu),n.splice.apply(n,[i,0].concat(a)),i+=a.length+1}return n.filter(function(t){return""!==t})}function qu(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}}var Wu,Yu=function(t,e,n,i){void 0===n&&(n={}),void 0===i&&(i={});var r=e.width,o=e.height,a=i.svgDocument||su("svg").node,s=su("tspan").node,u=su("text").attr(n).append(s).node,l=document.createTextNode("");u.style.opacity=0,u.style.display="block",s.style.display="block",s.appendChild(l),a.appendChild(u),i.svgDocument||document.body.appendChild(a);var h=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;cs(g)||(g=1/0);var v,m,y,b=t.split(c),w=[],x=[];h&&su(s).attr("xml:space","preserve");for(var A=0,T=0,P=b.length;A<P;A++){var E=b[A];if((E||h)&&"string"==typeof E){var S=!1;if(f&&0<=E.indexOf(f)){if(1<E.length){var k=Hu(b[A],f);b.splice.apply(b,[A,1].concat(k)),A--,P=b.length;continue}if(h&&"string"==typeof b[A-1]){b.splice(A,Uu,"",Uu),P+=2,A--;continue}x[++T]=h&&"string"!=typeof b[A+1]?void 0:"",S=!0}if(!S){var M=void 0;if(M=h?void 0!==x[T]?x[T]+d+E:E:x[T]?x[T]+d+E:E,l.data=M,s.getComputedTextLength()<=r)x[T]=M,(v||m)&&(w[T++]=!0,m=v=0);else{if(!x[T]||v){var L=!!v;if(v=E.length-1,L||!v){if(!v){if(!x[T]){x=[];break}b.splice(A,2,E+b[A+1]),P--,w[T++]=!0,A--;continue}b[A]=E.substring(0,v);var C=b[A+1];b[A+1]=E.substring(v)+(void 0===C||C===Uu?"":C)}else{if(m)b.splice(A,2,b[A]+b[A+1]),m=0;else{var _=E.search(p);-1<_&&_!==E.length-1&&0!==_&&(m=_+1,v=0),b.splice(A,1,E.substring(0,m||v),E.substring(m||v)),P++}T&&!w[T-1]&&T--}h&&""===x[T]||A--;continue}T++,A--}}var N=null;if(x.length>g)N=g-1;else if(void 0!==o){if(void 0===y&&""!==l.data)if("auto"===n.lineHeight)y=qu({value:1.5,unit:"em"},u);else y=qu(Gu(n.lineHeight,["em","px",""]),u);y*x.length>o&&(N=Math.floor(o/y)-1)}if(null!==N){x.splice(N+1);var O=i.ellipsis;if(!O||N<0)break;"string"!=typeof O&&(O="\u2026");var R=x[N];if(!R&&!S)break;var F,B,V=R.length;do{if(B=R[V],F=R.substring(0,V),B?B.match(c)&&(F+=B):F+=d,F+=O,l.data=F,s.getComputedTextLength()<=r){x[N]=F;break}V--}while(0<=V);break}}}return i.svgDocument?a.removeChild(u):document.body.removeChild(a),x.join(f)},Xu=function(t,e){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(t,e);else{var n=window.URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n)}},$u=function(t){t=t.replace(/\s/g,"");var e,n=(t=decodeURIComponent(t)).indexOf(","),i=t.slice(0,n),r=i.split(":")[1].split(";")[0],o=t.slice(n+1);e=0<=i.indexOf("base64")?atob(o):unescape(encodeURIComponent(o));for(var a=new Uint8Array(e.length),s=0;s<e.length;s++)a[s]=e.charCodeAt(s);return new Blob([a],{type:r})},Zu=function(t,e){var n=(t=iu(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},Ju=function(t){if(Object(t)===t)return e=n=i=r=0,isFinite(t.vertical)&&(e=i=+t.vertical),isFinite(t.horizontal)&&(n=r=+t.horizontal),isFinite(t.top)&&(e=+t.top),isFinite(t.right)&&(n=+t.right),isFinite(t.bottom)&&(i=+t.bottom),isFinite(t.left)&&(r=+t.left),{top:e,right:n,bottom:i,left:r};var e,n,i,r,o=0;return isFinite(t)&&(o=+t),{top:o,right:o,bottom:o,left:o}},Ku={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(1<=t)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e=0,n=1;;e+=n,n/=2)if((7-4*e)/11<=t){var i=(11-6*e-11*t)/4;return-i*i+n*n}},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(n,i,r){return i=i||0,r=r||1,function(t){var e=n(t);return e<i?i:r<e?r:e}},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)}}},Qu={number:function(e,t){var n=t-e;return function(t){return e+n*t}},object:function(r,o){var a=Object.keys(r);return function(t){var e,n,i={};for(e=a.length-1;-1!=e;e--)i[n=a[e]]=r[n]+(o[n]-r[n])*t;return i}},hexColor:function(t,e){var n=parseInt(t.slice(1),16),i=parseInt(e.slice(1),16),r=255&n,o=(255&i)-r,a=65280&n,s=(65280&i)-a,u=16711680&n,l=(16711680&i)-u;return function(t){return"#"+(1<<24|r+o*t&255|a+s*t&65280|u+l*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),r=n.exec(t),o=r[1].indexOf("."),a=0<o?r[1].length-o-1:0;e=+i[1];var s=+r[1]-e,u=i[2];return function(t){return(e+s*t).toFixed(a)+u}}},tl={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return nl('<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 nl('<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 nl('<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 nl(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},sepia:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},saturate:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-e})},hueRotate:function(t){return nl('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:1-e})},brightness:function(t){return nl('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:.5-e/2})}},el={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var n=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),i=n[1]||" ",r=n[2]||">",a=n[3]||"",s=n[4]||"",u=n[5],l=+n[6],h=n[7],c=n[8],d=n[9],f=1,p="",g="",v=!1;switch(c&&(c=+c.substring(1)),(u||"0"===i&&"="===r)&&(u=i="0",r="=",h&&(l-=Math.floor((l-1)/4))),d){case"n":h=!0,d="g";break;case"%":f=100,g="%",d="f";break;case"p":f=100,g="%",d="r";break;case"b":case"o":case"x":case"X":"#"===s&&(p="0"+d.toLowerCase());break;case"c":case"d":v=!0,c=0;break;case"s":f=-1,d="r"}"$"===s&&(p=o.currency[0],g=o.currency[1]),"r"!=d||c||(d="g"),null!=c&&("g"==d?c=Math.max(1,Math.min(21,c)):"e"!=d&&"f"!=d||(c=Math.max(0,Math.min(20,c))));var m=u&&h;if(v&&e%1)return"";var y=e<0||0===e&&1/e<0?(e=-e,"-"):a,b=g;if(f<0){var w=this.prefix(e,c);e=w.scale(e),b=w.symbol+g}else e*=f;var x=(e=this.convert(d,e,c)).lastIndexOf("."),A=x<0?e:e.substring(0,x),T=x<0?"":o.decimal+e.substring(x+1);function P(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)}!u&&h&&o.grouping&&(A=P(A));var E=p.length+A.length+T.length+(m?0:y.length),S=E<l?new Array(E=l-E+1).join(i):"";return m&&(A=P(S+A)),y+=p,e=A+T,("<"===r?y+e+S:">"===r?S+y+e:"^"===r?S.substring(0,E>>=1)+y+e+S.substring(E):y+(m?e:S+e))+b},string:function(t,e){for(var n,i="{",r=!1,o=[];-1!==(n=t.indexOf(i));){var a,s,u;if(a=t.slice(0,n),r){u=(s=a.split(":")).shift().split("."),a=e;for(var l=0;l<u.length;l++)a=a[u[l]];s.length&&(a=this.number(s,a))}o.push(a),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]}},nl=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:""})}},il=function(){},rl={},ol=/\s+/,al=function(t,e,n,i,r){var o,a=0;if(n&&"object"==typeof n){void 0!==i&&"context"in r&&void 0===r.context&&(r.context=i);for(o=Object.keys(n);a<o.length;a++)e=al(t,e,o[a],n[o[a]],r)}else if(n&&ol.test(n))for(o=n.split(ol);a<o.length;a++)e=t(e,o[a],i,r);else e=t(e,n,i,r);return e};rl.on=function(t,e,n){(this._events=al(sl,this._events||{},t,e,{context:n,ctx:this,listening:Wu}),Wu)&&(((this._listeners||(this._listeners={}))[Wu.id]=Wu).interop=!1);return this},rl.listenTo=function(t,e,n){if(!t)return this;var i=t._listenId||(t._listenId=qs("l")),r=this._listeningTo||(this._listeningTo={}),o=Wu=r[i];o||(this._listenId||(this._listenId=qs("l")),o=Wu=r[i]=new pl(this,t));var a=ul(t,e,n,this);if(Wu=void 0,a)throw a;return o.interop&&o.on(e,n),this};var sl=function(t,e,n,i){if(n){var r=t[e]||(t[e]=[]),o=i.context,a=i.ctx,s=i.listening;s&&s.count++,r.push({callback:n,context:o,ctx:o||a,listening:s})}return t},ul=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}};rl.off=function(t,e,n){return this._events&&(this._events=al(ll,this._events,t,e,{context:n,listeners:this._listeners})),this},rl.stopListening=function(t,e,n){var i=this._listeningTo;if(!i)return this;for(var r=t?[t._listenId]:Object.keys(i),o=0;o<r.length;o++){var a=i[r[o]];if(!a)break;a.obj.off(e,n,this),a.interop&&a.off(e,n)}return Ss(i)&&(this._listeningTo=void 0),this};var ll=function(t,e,n,i){if(t){var r,o=i.context,a=i.listeners,s=0;if(e||o||n){for(r=e?[e]:Object.keys(t);s<r.length;s++){var u=t[e=r[s]];if(!u)break;for(var l=[],h=0;h<u.length;h++){var c=u[h];if(n&&n!==c.callback&&n!==c.callback._callback||o&&o!==c.context)l.push(c);else{var d=c.listening;d&&d.off(e,n)}}l.length?t[e]=l:delete t[e]}return t}if(null!=a)for(r=Object.keys(a);s<r.length;s++)a[r[s]].cleanup()}};rl.once=function(t,e,n){var i=al(hl,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(i,e,n)},rl.listenToOnce=function(t,e,n){var i=al(hl,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,i)};var hl=function(t,e,n,i){if(n){var r=t[e]=cl(function(){i(e,r),n.apply(this,arguments)});r._callback=n}return t},cl=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}};rl.trigger=function(t){var e=arguments;if(!this._events)return this;for(var n=Math.max(0,arguments.length-1),i=Array(n),r=0;r<n;r++)i[r]=e[r+1];return al(dl,this._events,t,void 0,i),this};var dl=function(t,e,n,i){if(t){var r=t[e],o=t.all;r&&o&&(o=o.slice()),r&&fl(r,i),o&&fl(o,[e].concat(i))}return t},fl=function(t,e){var n,i=-1,r=t.length,o=e[0],a=e[1],s=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,a);return;case 3:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,a,s);return;default:for(;++i<r;)(n=t[i]).callback.apply(n.ctx,e);return}},pl=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};pl.prototype.on=rl.on,pl.prototype.off=function(t,e){(this.interop?(this._events=al(ll,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count))&&this.cleanup()},pl.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},rl.bind=rl.on,rl.unbind=rl.off;var gl=function(t,e){var n,i=this;return n=t&&Is(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)},fs(n,i,e),n.prototype=Object.assign(Object.create(i.prototype),t),(n.prototype.constructor=n).__super__=i.prototype,n},vl=function(n,i,t,r){Gs(t,function(t,e){i[e]&&(n.prototype[e]=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],ml(t,this),e)};case 4:return function(t,e,n){return i[r](this[o],ml(t,this),e,n)};default:return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this[o]),i[r].apply(i,t)}}}(i,t,e,r))})},ml=function(e,t){return Ms(e)?e:hs(e)&&!t._isModel(e)?yl(e):ds(e)?function(t){return t.get(e)}:e},yl=function(t){var e=Ha(Ta(t,!0));return function(t){return e(t.attributes)}},bl=function(t,e){var n=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=qs(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection);var i=Ds(this,"defaults");n=ms(fs({},i,n),i),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};function wl(t){t=Ts(t);var a=Cs(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return Cs(t).forEach(function(t){var e=a[t.id];if(e.isLink()){var n=e.source(),i=e.target();n.id&&a[n.id]&&e.prop("source/id",a[n.id].id),i.id&&a[i.id]&&e.prop("target/id",a[i.id].id)}var r=t.get("parent");r&&a[r]&&e.set("parent",a[r].id);var o=Cs(t.get("embeds")).reduce(function(t,e){return a[e]&&t.push(a[e].id),t},[]);Ss(o)||e.set("embeds",o)}),a}fs(bl.prototype,rl,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return Ps(this.attributes)},get:function(t){return this.attributes[t]},has:function(t){return null!=this.get(t)},set:function(t,e,n){if(null==t)return this;var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;var r=n.unset,o=n.silent,a=[],s=this._changing;this._changing=!0,s||(this._previousAttributes=Ps(this.attributes),this.changed={});var u=this.attributes,l=this.changed,h=this._previousAttributes;for(var c in i)e=i[c],ks(u[c],e)||a.push(c),ks(h[c],e)?delete l[c]:l[c]=e,r?delete u[c]:u[c]=e;if(this.idAttribute in i){var d=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,d,n)}if(!o){a.length&&(this._pending=n);for(var f=0;f<a.length;f++)this.trigger("change:"+a[f],this,u[a[f]],n)}if(s)return this;if(!o)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,fs({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,fs({},t,{unset:!0}))},hasChanged:function(t){return null==t?!Ss(this.changed):Is(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&Ps(this.changed);var e,n=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var o=t[r];ks(n[r],o)||(i[r]=o,e=!0)}return!!e&&i},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return Ps(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},fs({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=fs({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return!n||(this.trigger("invalid",this,n,fs(e,{validationError:n})),!1)}}),bl.extend=gl;var xl=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce(function(t,e){return t[e]=!0,t},{}),Al={qualify:function(t){return Ls(t)},set:function(e,t,i){Object.keys(e).forEach(function(t){if(xl[t]&&t in i){var 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}})}};function Tl(a,s,u){return function(t,e){var n,i=zu(t);if(t=parseFloat(t),i&&(t/=100),isFinite(t)){var r=e[u]();n=i||0<t&&t<1?r[a]+e[s]*t:r[a]+t}var o=si();return o[a]=n||0,o}}function Pl(o,a){return function(t,e){var n=zu(t);t=parseFloat(t),n&&(t/=100);var i={};if(isFinite(t)){var r=n||0<=t&&t<=1?t*e[a]:Math.max(t+e[a],0);i[o]=r}return i}}var El,Sl,kl={"ref-x":{position:Tl("x","width","origin")},"ref-y":{position:Tl("y","height","origin")},"ref-dx":{position:Tl("x","width","corner")},"ref-dy":{position:Tl("y","height","corner")},"ref-width":{set:Pl("width","width")},"ref-height":{set:Pl("height","height")},"ref-rx":{set:Pl("rx","width")},"ref-ry":{set:Pl("ry","height")},"ref-cx":{set:Pl("cx","width")},"ref-cy":{set:Pl("cy","height")},"ref-r-inscribed":{set:(El=Pl("r","width"),Sl=Pl("r","height"),function(t,e){return(e.height>e.width?El:Sl)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n=zu(t);t=parseFloat(t),n&&(t/=100);var i,r=Math.sqrt(e.height*e.height+e.width*e.width);return isFinite(t)&&(i=n||0<=t&&t<=1?t*r:Math.max(t+r,0)),{r:i}}}};function Ml(t,e,n){return void 0!==n.text}kl.refX=kl["ref-x"],kl.refY=kl["ref-y"],kl["ref-x2"]=kl["ref-x"],kl["ref-y2"]=kl["ref-y"],kl["ref-width2"]=kl["ref-width"],kl["ref-height2"]=kl["ref-height"],kl["ref-r"]=kl["ref-r-inscribed"];var Ll={"line-height":{qualify:Ml},"text-vertical-anchor":{qualify:Ml},"text-path":{qualify:Ml},annotations:{qualify:Ml},eol:{qualify:Ml},"display-empty":{qualify:Ml},text:{qualify:function(t,e,n){var i=n["text-wrap"];return!i||!Ls(i)},set:function(t,e,n,i){var r="joint-text",o=iu.data.get(n,r),a=i["line-height"],s=i["text-vertical-anchor"],u=i["display-empty"],l=i["font-size"],h=i.annotations,c=i.eol,d=i.x,f=i["text-path"],p=JSON.stringify([t,a,h,s,c,u,f,d,l]);if(void 0===o||o!==p){if(l&&n.setAttribute("font-size",l),hs(f)){var g=f.selector;if("string"==typeof g){var v=this.findNode(g);v instanceof SVGPathElement&&(f=fs({"xlink:href":"#"+v.id},f))}}su(n).text(""+t,{lineHeight:a,annotations:h,textPath:f,x:d,textVerticalAnchor:s,eol:c,displayEmpty:u}),iu.data.set(n,r,p)}}},"text-wrap":{qualify:Ls,set:function(t,e,n,i){var r={},o=t.width||0;zu(o)?r.width=e.width*parseFloat(o)/100:Nn(o)?r.width=Number(Fn(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o;var a,s=t.height||0;zu(s)?r.height=e.height*parseFloat(s)/100:Nn(s)?r.height=Number(Fn(s,e)):null===t.height||(r.height=s<=0?e.height+s:s);var u=t.text;if(void 0===u&&(u=i.text),void 0!==u){var l=t.breakText||Yu,h=getComputedStyle(n);a=l(""+u,r,{"font-weight":h.fontWeight,"font-family":h.fontFamily,"text-transform":h.textTransform,"font-size":h.fontSize,"letter-spacing":h.letterSpacing,lineHeight:i["line-height"]},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces})}else a="";Ll.text.set.call(this,a,e,n,i)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,n){var i="joint-title",r=iu.data.get(n,i);if(void 0===r||r!==t){if(iu.data.set(n,i,t),"title"===n.tagName)return void(n.textContent=t);var o=n.firstElementChild;if(o&&"title"===o.tagName)o.textContent=t;else{var a=document.createElementNS(n.namespaceURI,"title");a.textContent=t,n.insertBefore(a,o)}}}}};function Cl(r,o){var a=new si(1,0);return function(t){var e,n,i=this[r](t);return i?(n=o.rotate?i.vector().vectorAngle(a):0,e=i.start):(e=this.path.start,n=0),0===n?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+n+")"}}}function _l(){return this.model.isLink()}var Nl={connection:{qualify:_l,set:function(t){var e,n=t.stubs;if(void 0===n&&(n=0),isFinite(n)&&0!==n){var i;i=n<0?(this.getConnectionLength()+n)/2:n;var r=this.getConnection(),o=this.getConnectionSubdivisions(),a=r.divideAtLength(i,{segmentSubdivisions:o}),s=r.divideAtLength(-i,{segmentSubdivisions:o});a&&s&&(e=a[0].serialize()+" "+s[1].serialize())}return{d:e||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:_l,set:Cl("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:_l,set:Cl("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:_l,set:Cl("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:_l,set:Cl("getTangentAtRatio",{rotate:!1})}};function Ol(d,t){var f="joint-shape",p=t&&t.resetOffset;return function(t,e,n){var i=iu.data.get(n,f);if(!i||i.value!==t){var r=d(t);i={value:t,shape:r,shapeBBox:r.bbox()},iu.data.set(n,f,i)}var o=i.shape.clone(),a=i.shapeBBox.clone(),s=a.origin(),u=e.origin();a.x=u.x,a.y=u.y;var l=e.maxRectScaleToFit(a,u),h=0===a.width||0===e.width?1:l.sx,c=0===a.height||0===e.height?1:l.sy;return o.scale(h,c,s),p&&o.translate(-s.x,-s.y),o}}function Rl(t){var i=Ol(function(t){return new Ii(su.normalizePathData(t))},t);return function(t,e,n){return{d:i(t,e,n).serialize()}}}function Fl(t){var i=Ol(Ci,t);return function(t,e,n){return{points:i(t,e,n).serialize()}}}Nl["at-connection-length"]=Nl["at-connection-length-keep-gradient"],Nl["at-connection-ratio"]=Nl["at-connection-ratio-keep-gradient"];var Bl={"ref-d-reset-offset":{set:Rl({resetOffset:!0})},"ref-d-keep-offset":{set:Rl({resetOffset:!1})},"ref-points-reset-offset":{set:Fl({resetOffset:!0})},"ref-points-keep-offset":{set:Fl({resetOffset:!1})}};function Vl(t){var e={},n=t.stroke;"string"==typeof n&&(e.stroke=n,e.fill=n);var i=t["stroke-opacity"];return void 0===i&&(i=t.opacity),void 0!==i&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Il(t){var e=this.paper;return"url(#"+("pattern"===t.type?e.definePattern(t):e.defineGradient(t))+")"}Bl["ref-d"]=Bl["ref-d-reset-offset"],Bl["ref-points"]=Bl["ref-points-reset-offset"];var Dl={"source-marker":{qualify:Ls,set:function(t,e,n,i){return t=fs(Vl(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:Ls,set:function(t,e,n,i){return t=fs(Vl(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:Ls,set:function(t,e,n,i){return t=fs(Vl(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:Ls,set:Il},stroke:{qualify:Ls,set:Il},filter:{qualify:Ls,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function jl(r,o,a){return function(t,e){var n;n="middle"===t?e[o]/2:t===a?e[o]:isFinite(t)?-1<t&&t<1?-e[o]*t:-t:zu(t)?e[o]*parseFloat(t)/100:0;var i=new si;return i[r]=-(e[r]+n),i}}var zl={"x-alignment":{offset:jl("x","width","right")},"y-alignment":{offset:jl("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function Gl(r){return function(t,e,n){var i=su(n);i.attr(r)!==t&&i.attr(r,t)}}var Ul={ref:{},href:{set:Gl("href")},"xlink:href":{set:Gl("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:Ls,set:function(t,e,n){iu(n).css(t)}},html:{set:function(t,e,n){iu(n).html(t+"")}},props:Al};fs(Ul,kl),fs(Ul,Ll),fs(Ul,Nl),fs(Ul,Bl),fs(Ul,Dl),fs(Ul,zl);var Hl=Ul,ql=function(t,e){if(Array.isArray(t))return e},Wl=bl.extend({constructor:function(t,e){var n,i=t||{};if("function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=qs("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(i=this.parse(i,e)||{}),n=Ds(this,"defaults")){var r=(!e||!0!==e.mergeArrays)&&ql;i=Ws({},n,i,r)}this.set(i,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(){var e=Ds(this.constructor.prototype,"defaults").attrs||{},t=this.attributes.attrs,o={};Gs(t,function(t,i){var r=e[i];Gs(t,function(t,n){hs(t)&&!Array.isArray(t)?Gs(t,function(t,e){r&&r[n]&&ks(r[n][e],t)||(o[i]=o[i]||{},(o[i][n]||(o[i][n]={}))[e]=t)}):r&&ks(r[n],t)||(o[i]=o[i]||{},o[i][n]=t)})});var n=Es(js(this.attributes,"attrs"));return n.attrs=o,n},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:function(){return Ru()},processPorts:function(){var t=this.ports,n={};Gs(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})});var i={};(Gs(t,function(t,e){n[e]||(i[e]=!0)}),this.graph&&!Ss(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(t){void 0===t&&(t={});var e=this.graph,n=this.collection;if(!e)return n&&n.remove(this,t),this;e.startBatch("remove");var i=this.getParentCell();i&&i.unembed(this,t);for(var r=this.getEmbeddedCells(),o=0,a=r.length;o<a;o++){var s=r[o];s&&s.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(n){var t=this.graph;if(t){var e;(n=ms(n||{},{foregroundEmbeds:!0})).deep?(e=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==n.breadthFirst,sortSiblings:n.foregroundEmbeds})).unshift(this):e=[this];var i=n.foregroundEmbeds?e:Os(e,function(t){return t.z()}),r=t.maxZIndex()-e.length+1,o=t.get("cells"),a=o.toArray().indexOf(i[0])!==o.length-e.length;a||(a=i.some(function(t,e){return t.z()!==r+e})),a&&(this.startBatch("to-front"),r+=e.length,i.forEach(function(t,e){t.set("z",r+e,n)}),this.stopBatch("to-front"))}return this},toBack:function(n){var t=this.graph;if(t){var e;(n=ms(n||{},{foregroundEmbeds:!0})).deep?(e=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==n.breadthFirst,sortSiblings:n.foregroundEmbeds})).unshift(this):e=[this];var i=n.foregroundEmbeds?e:Os(e,function(t){return t.z()}),r=t.minZIndex(),o=0!==t.get("cells").toArray().indexOf(i[0]);o||(o=i.some(function(t,e){return t.z()!==r+e})),o&&(this.startBatch("to-back"),r-=e.length,i.forEach(function(t,e){t.set("z",r+e,n)}),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){var n=this,i=Array.isArray(t)?t:[t];if(!this.canEmbed(i))throw new Error("Recursive embedding not allowed.");if(i.some(function(t){return t.isEmbedded()&&n.id!==t.parent()}))throw new Error("Embedding of already embedded cells is not allowed.");return this._embedCells(i,e),this},unembed:function(t,e){var n=Array.isArray(t)?t:[t];return this._unembedCells(n,e),this},canEmbed:function(t){var e=this;return(Array.isArray(t)?t:[t]).every(function(t){return e!==t&&!e.isEmbeddedIn(t)})},_embedCells:function(t,e){var n=this;this.startBatch("embed");var i=fs([],this.get("embeds"));t.forEach(function(t){i[t.isLink()?"unshift":"push"](t.id),t.parent(n.id,e)}),this.set("embeds",Ts(i),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(function(t){return t.unset("parent",e)}),this.set("embeds",Fs.apply(void 0,[this.get("embeds")].concat(t.map(function(t){return 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)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(t=t||{},!this.graph)return[];if(t.deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);var e=this.get("embeds");if(Ss(e))return[];var n=e.map(this.graph.getCell,this.graph);return t.sortSiblings&&(n=Os(n,function(t){return t.z()})),n},_getEmbeddedCellsBfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.shift();e.push(i);var r=i.getEmbeddedCells({sortSiblings:t});n.push.apply(n,r)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.pop();e.push(i);for(var r=i.getEmbeddedCells({sortSiblings:t}),o=r.length-1;0<=o;--o)n.push(r[o])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=ds(t)?t:t.id,i=this.parent();if(e=fs({deep:!0},e),this.graph&&e.deep){for(;i;){if(i===n)return!0;i=this.graph.getCell(i).parent()}return!1}return i===n},isEmbedded:function(){return!!this.parent()},clone:function(t){if((t=t||{}).deep)return Cs(wl([this].concat(this.getEmbeddedCells({deep:!0}))));var e=bl.prototype.clone.apply(this,arguments);return e.set(this.getIdAttribute(),this.generateId()),e.unset("embeds"),e.unset("parent"),e},prop:function(t,e,n){var i=ds(t);if(i||Array.isArray(t)){if(1<arguments.length){var r,o,a=(o=i?(r=t).split("/"):(r=t.join("/"),t.slice()))[0],s=o.length,u=n||{};u.propertyPath=r,u.propertyValue=e,u.propertyPathArray=o,"rewrite"in u||(u.rewrite=!1);for(var l={},h=l,c=a,d=1;d<s;d++){var f=o[d],p=Number.isFinite(i?Number(f):f);h=h[c]=p?[]:{},c=f}l=_u(l,o,e,"/");var g=Ws({},this.attributes);u.rewrite&&Nu(g,r,"/");var v=Ws(g,l);return this.set(a,v[a],u)}return Lu(this.attributes,t,"/")}var m=e||{};m.propertyPath=null,m.propertyValue=t,m.propertyPathArray=[],"rewrite"in m||(m.rewrite=!1);var y={};for(var b in t){var w=Ws({},{changedValue:this.attributes[b]},{changedValue:t[b]}).changedValue;y[b]=w}return this.set(y,m)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];if("attrs"===i&&(e.dirty=!0),1===n.length)return this.unset(t,e);var r=n.slice(1),o=this.get(i);return null==o?this:(o=Es(o),Nu(o,r,"/"),this.set(i,o,e))},attr:function(t,e,n){var i=Array.from(arguments);return 0===i.length?this.get("attrs"):(Array.isArray(t)?i[0]=["attrs"].concat(t):ds(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(r,e,o,n){var i=this;n=n||"/",o=fs({duration:100,delay:10,timingFunction:Ku.linear,valueFunction:Qu.number},o);var a,s,u=0,l=function(t){var e,n,i;(n=(t-=u=u||t)/o.duration)<1?this._transitionIds[r]=e=Du(l):(n=1,delete this._transitionIds[r]),i=a(o.timingFunction(n)),o.transitionId=e,this.prop(r,i,o),e||this.trigger("transition:end",this,r)}.bind(this),h=this._scheduledTransitionIds;return s=setTimeout(function(t){h[r]&&(h[r]=Fs(h[r],s),0===h[r].length&&delete h[r]),i.stopPendingTransitions(r,n),a=o.valueFunction(Lu(i.attributes,r,n),e),i._transitionIds[r]=Du(t),i.trigger("transition:start",i,r)},o.delay,l),h[r]||(h[r]=[]),h[r].push(s),s},getTransitions:function(){return Vs(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e){void 0===e&&(e="/");var n=this._scheduledTransitionIds;void 0===n&&(n={});var i=Object.keys(n);if(t){var r=t.split(e);i=i.filter(function(t){return ks(r,t.split(e).slice(0,r.length))})}return i.forEach(function(t){n[t].forEach(function(t){return clearTimeout(t)}),delete n[t]}),this},stopPendingTransitions:function(t,e){var n=this;void 0===e&&(e="/");var i=this._transitionIds;void 0===i&&(i={});var r=Object.keys(i);if(t){var o=t.split(e);r=r.filter(function(t){return ks(o,t.split(e).slice(0,o.length))})}r.forEach(function(t){var e=i[t];ju(e),delete i[t],n.trigger("transition:end",n,t)})},stopTransitions:function(t,e){return void 0===e&&(e="/"),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,fs({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,fs({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new si(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new si},getBBox:function(){return new Ei(0,0,0,0)},getPointRotatedAroundCenter:function(t,e,n){var i=new si(e,n);return t&&i.rotate(this.getBBox().center(),t),i},getAbsolutePointFromRelative:function(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute:function(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,n=Hl;return e&&e[t]||n[t]},define:function(t,e,n,i){n=fs({defaults:bs({type:t},e,this.prototype.defaults)},n);var r=this.extend(n,i);return void 0!==joint&&Is(joint,"shapes")&&_u(joint.shapes,t,r,"."),r}}),Yl=function(e,t,n){if(ds(n)){if(!Xl[n])throw new Error('Unknown wrapper: "'+n+'"');n=Xl[n]}if(!Ms(n))throw new Error("Wrapper must be a function.");Cs(t).forEach(function(t){e[t]=n(e[t])})},Xl={cells:function(r){return function(){var t=Array.from(arguments),e=t.length,n=0<e&&t[0]||[],i=1<e&&t[e-1]||{};return Array.isArray(n)||(i instanceof Wl?n=t:n instanceof Wl&&(1<t.length&&t.pop(),n=t)),i instanceof Wl&&(i={}),r.call(this,n,i)}}};var $l={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 Zl(t,e){var n=new Ei(t);switch(e){case void 0:throw new Error("Position required");case $l.LEFT:case"leftMiddle":return n.leftMiddle();case $l.RIGHT:case"rightMiddle":return n.rightMiddle();case $l.TOP:case"topMiddle":return n.topMiddle();case $l.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case $l.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case $l.TOP_RIGHT:case"topRight":return n.topRight();case $l.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case $l.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case $l.CENTER:return n.center();default:throw new Error("Unknown position: "+e)}}var Jl={getRectPoint:Zl,wrapWith:Yl,wrappers:Xl,addClassNamePrefix:Su,removeClassNamePrefix:function(t){return t?t.toString().split(" ").map(function(t){return t.substr(0,xu.classNamePrefix.length)===xu.classNamePrefix&&(t=t.substr(xu.classNamePrefix.length)),t}).join(" "):t},parseDOMJSON:ku,hashCode:Mu,getByPath:Lu,setByPath:_u,unsetByPath:Nu,flattenObject:Ou,uuid:Ru,guid:Fu,toKebabCase:function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},normalizeEvent:Bu,normalizeWheel:Vu,cap:Iu,nextFrame:Du,cancelFrame:ju,isPercentage:zu,parseCssNumeric:Gu,breakText:Yu,sanitizeHTML:function(t){var e=iu.parseHTML("<div>"+t+"</div>")[0];return Array.from(e.getElementsByTagName("*")).forEach(function(n){n.getAttributeNames().forEach(function(t){var e=n.getAttribute(t);(t.startsWith("on")||e.startsWith("javascript:"))&&n.removeAttribute(t)})}),e.innerHTML},downloadBlob:Xu,downloadDataUri:function(t,e){var n=$u(t);Xu(n,e)},dataUriToBlob:$u,imageToDataUri:function(r,t){if(!r||"data:"===r.substr(0,"data:".length))return setTimeout(function(){t(null,r)},0);var e=new XMLHttpRequest;e.open("GET",r,!0),e.addEventListener("error",function(){t(new Error("Failed to load image "+r))}),e.responseType=window.FileReader?"blob":"arraybuffer",e.addEventListener("load",function(){window.FileReader?function(t,n){if(200===t.status){var e=new FileReader;e.onload=function(t){var e=t.target.result;n(null,e)},e.onerror=function(){n(new Error("Failed to load image "+r))},e.readAsDataURL(t.response)}else n(new Error("Failed to load image "+r))}(e,t):function(t,e){if(200===t.status){var n=new Uint8Array(t.response),i=r.split(".").pop()||"png";e(null,"data:image/"+({svg:"svg+xml"}[i]||i)+";base64,"+btoa(function(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("")}(n)))}else e(new Error("Failed to load image "+r))}(e,t)}),e.send()},getElementBBox:function(t){var e=iu(t);if(0===e.length)throw new Error("Element not found");var n=e[0],i=n.ownerDocument,r=n.getBoundingClientRect(),o=0,a=0;if(n.ownerSVGElement){var s=su(n),u=s.getBBox({target:s.svg()});o=r.width-u.width,a=r.height-u.height}return{x:r.left+window.pageXOffset-i.documentElement.offsetLeft+o/2,y:r.top+window.pageYOffset-i.documentElement.offsetTop+a/2,width:r.width-o,height:r.height-a}},sortElements:Zu,setAttributesBySelector:function(t,e){var i=iu(t);Gs(e,function(t,e){var n=i.find(e).addBack().filter(e);Is(t,"class")&&(n.addClass(t.class),t=js(t,"class")),n.attr(t)})},normalizeSides:Ju,timing:Ku,interpolate:Qu,filter:tl,format:el,template:nl,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],o=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[o])return Ms(t[o])?t[o]():t[o]}}t=t||e.body,n(e,"FullscreenElement")||n(e,"FullScreenElement")?n(e,"ExitFullscreen")||n(e,"CancelFullScreen"):n(t,"RequestFullscreen")||n(t,"RequestFullScreen")},isBoolean:ls,isObject:hs,isNumber:cs,isString:ds,mixin:ps,deepMixin:gs,supplement:vs,defaults:ms,deepSupplement:ys,defaultsDeep:bs,assign:fs,invoke:ws,invokeProperty:xs,sortedIndex:As,uniq:Ts,clone:Ps,cloneDeep:Es,isEmpty:Ss,isEqual:ks,isFunction:Ms,isPlainObject:Ls,toArray:Cs,debounce:_s,groupBy:Ns,sortBy:Os,flattenDeep:Rs,without:Fs,difference:Bs,intersection:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t.map(function(t){return Uo(t)&&Xo(t)?t:[]});return n.length&&n[0]===t[0]?function(t){for(var e,n=function(t,e){return!(null==t||!t.length)&&-1<t.indexOf(e)},i=function(t,e){return t.has(e)},r=t[0].length,o=t.length,a=new Array(o),s=[],u=1/0,l=o;l--;)e=t[l],u=Math.min(e.length,u),a[l]=120<=r&&120<=e.length?new us(l&&e):void 0;e=t[0];var h=-1,c=a[0];t:for(;++h<r&&s.length<u;){var d=e[h],f=d;if(d=0!==d?d:0,!(c?i(c,f):n(s,f))){for(l=o;--l;){var p=a[l];if(!(p?i(p,f):n(t[l],f)))continue t}c&&c.push(f),s.push(d)}}return s}(n):[]},union:Vs,has:Is,result:Ds,omit:js,pick:zs,bindAll:function(e){for(var t=[],n=arguments.length-1;0<n--;)t[n]=arguments[n+1];return t.flat(1).forEach(function(t){t=Aa(t),Wo(e,t,e[t].bind(e))}),e},forIn:Gs,camelCase:Us,uniqueId:qs,merge:Ws,noop:il,cloneCells:wl,svg:function(t){for(var n=[],e=arguments.length-1;0<e--;)n[e]=arguments[e+1];var i=[];return t.forEach(function(t,e){i.push(t),e in n&&i.push(n[e])}),function(t){var e,n,i=new DOMParser,r="<svg>"+t.trim()+"</svg>";if(i.parseFromString(r.replace(/@/g,""),"application/xml").getElementsByTagName("parsererror")[0])throw new Error("Invalid SVG markup");return e=i.parseFromString(r,"text/html").querySelector("svg"),n=[],Array.from(e.children).forEach(function(t){n.push(function n(t){var e={},i=t.tagName,r=t.attributes,o=t.namespaceURI,a=t.style,s=t.childNodes;e.namespaceURI=o,e.tagName=o===su.namespace.xhtml?i.toLowerCase():i;for(var u={},l=a.length;l--;){var h=a[l];u[h]=a.getPropertyValue(h)}e.style=u;var c=r.getNamedItem("@selector");c&&(e.selector=c.value,r.removeNamedItem("@selector"));var d=r.getNamedItem("@group-selector");if(d){var f=d.value.split(",");e.groupSelector=f.map(function(t){return t.trim()}),r.removeNamedItem("@group-selector")}var p=r.getNamedItem("class");p&&(e.className=p.value);var g=[];s.forEach(function(t){switch(t.nodeType){case Node.TEXT_NODE:var e=t.data.replace(/\s\s+/g," ");e.trim()&&g.push(e);break;case Node.ELEMENT_NODE:g.push(n(t))}}),g.length&&(e.children=g);var v={};return Array.from(r).forEach(function(t){var e=t.name,n=t.value;v[e]=n}),0<Object.keys(v).length&&(e.attributes=v),e}(t))}),n}(i.join(""))}};function Kl(t,e,n){var i=t.toJSON();return i.angle=e||0,ms({},n,i)}function Ql(t,e,n,r){return t.map(function(t,e,n){var i=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&i.offset(t.dx||0,t.dy||0),Kl(i.round(),0,eh(r,t))},di(e,n))}function th(t,a,s,u){var l=a.center(),h=a.width/a.height,c=a.topMiddle(),d=vi.fromRect(a);return t.map(function(t,e,n){var i=s+u(e,n.length),r=c.clone().rotate(l,-i).scale(h,1,l),o=t.compensateRotation?-d.tangentTheta(r):0;return(t.dx||t.dy)&&r.offset(t.dx||0,t.dy||0),t.dr&&r.move(l,t.dr),Kl(r.round(),o,eh(a,t))})}function eh(t,e){var n=e.x,i=e.y,r=e.angle;return zu(n)?n=parseFloat(n)/100*t.width:Nn(n)&&(n=Number(Fn(n,t))),zu(i)?i=parseFloat(i)/100*t.height:Nn(i)&&(i=Number(Fn(i,t))),{x:n,y:i,angle:r}}function nh(t,e){var n=eh(t,e),i=n.x,r=n.y;return new si(i||0,r||0)}var ih={absolute:function(t,n){return t.map(function(t){var e=nh(n,t).round().toJSON();return e.angle=t.angle||0,e})},fn:function(t,e,n){return n.fn(t,e,n)},line:function(t,e,n){return Ql(t,nh(e,n.start||e.origin()),nh(e,n.end||e.corner()),e)},left:function(t,e,n){return Ql(t,e.origin(),e.bottomLeft(),e)},right:function(t,e,n){return Ql(t,e.topRight(),e.corner(),e)},top:function(t,e,n){return Ql(t,e.origin(),e.topRight(),e)},bottom:function(t,e,n){return Ql(t,e.bottomLeft(),e.corner(),e)},ellipseSpread:function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return th(t,e,i,function(t){return t*r})},ellipse:function(t,e,n){var i=n.startAngle||0,r=n.step||20;return th(t,e,i,function(t,e){return(t+.5-e/2)*r})}};function rh(t,e){return bs({},t,e,{x:0,y:0,angle:0,attrs:{}})}function oh(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 ah(t,e,n,i){i=ms({},i,{offset:15});var r,o,a,s,u=e.center().theta(t),l=i.offset,h=0,c=oh(e),d=c[0],f=c[1],p=c[2],g=c[3];u<f||p<u?(a=".3em",r=l,o=0,s="start"):u<d?(r=0,o=-l,a=n?(h=-90,s="start",".3em"):(s="middle","0")):u<g?(a=".3em",r=-l,o=0,s="end"):(r=0,o=l,a=n?(h=90,s="start",".3em"):(s="middle",".6em"));var v=Math.round;return rh(i,{x:v(r),y:v(o),angle:h,attrs:{labelText:{y:a,textAnchor:s}}})}function sh(t,e,n,i){i=ms({},i,{offset:15});var r,o,a,s,u=e.center().theta(t),l=i.offset,h=0,c=oh(e),d=c[0],f=c[1],p=c[2],g=c[3];u<f||p<u?(a=".3em",r=-l,o=0,s="end"):u<d?(r=0,o=l,a=n?(h=90,s="start",".3em"):(s="middle",".6em")):u<g?(a=".3em",r=l,o=0,s="start"):(r=0,o=-l,a=n?(h=-90,s="start",".3em"):(s="middle","0"));var v=Math.round;return rh(i,{x:v(r),y:v(o),angle:h,attrs:{labelText:{y:a,textAnchor:s}}})}function uh(t,e,n){n=ms({},n,{offset:20});var i,r=ui(0,0),o=-t.theta(r),a=o,s=t.clone().move(r,n.offset).difference(t).round(),u=".3em";(o+90)%180==0?(i=e?"end":"middle",e||-270!==o||(u="0em")):-270<o&&o<-90?(i="start",a=o-180):i="end";var l=Math.round;return rh(n,{x:l(s.x),y:l(s.y),angle:e?a:0,attrs:{labelText:{y:u,textAnchor:i}}})}var lh={manual:function(t,e,n){return rh(n)},left:function(t,e,n){return rh(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},right:function(t,e,n){return rh(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},top:function(t,e,n){return rh(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},bottom:function(t,e,n){return rh(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},outsideOriented:function(t,e,n){return ah(t,e,!0,n)},outside:function(t,e,n){return ah(t,e,!1,n)},insideOriented:function(t,e,n){return sh(t,e,!0,n)},inside:function(t,e,n){return sh(t,e,!1,n)},radial:function(t,e,n){return uh(t.difference(e.center()),!1,n)},radialOriented:function(t,e,n){return uh(t.difference(e.center()),!0,n)}},hh=function(t){var e=Es(t)||{};this.ports=[],this.groups={},this.portLayoutNamespace=ih,this.portLabelLayoutNamespace=lh,this._init(e)};hh.prototype={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,r){var e=this.getGroup(t),n=this.getPortsByGroup(t),i=e.position||{},o=i.name,a=this.portLayoutNamespace;a[o]||(o="left");var s=i.args||{},u=n.map(function(t){return t&&t.position&&t.position.args}),l=a[o](u,r,s),h={ports:n,result:[]};return Cs(l).reduce(function(t,e,n){var i=t.ports[n];return t.result.push({portId:i.id,portTransformation:e,labelTransformation:this._getPortLabelLayout(i,si(e),r),portAttrs:i.attrs,portSize:i.size,labelSize:i.label.size}),t}.bind(this),h),h.result},_getPortLabelLayout:function(t,e,n){var i=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return i[r]?i[r](e,n,t.label.position.args):null},_init:function(t){if(hs(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=Cs(t.items),a=0,s=o.length;a<s;a++)this.ports.push(this._evaluatePort(o[a]))},_evaluateGroup:function(t){return Ws(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=fs({},t),n=this.getGroup(t.group);return e.markup=e.markup||n.markup,e.attrs=Ws({},n.attrs,e.attrs),e.position=this._createPositionNode(n,e),e.label=Ws({},n.label,this._getLabel(e)),e.z=this._getZIndex(n,e),e.size=fs({},n.size,e.size),e},_getZIndex:function(t,e){return cs(e.z)?e.z:cs(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return Ws({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={};Ms(t)?(n="fn",i.fn=t):ds(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):hs(t)&&(n=t.name,fs(i,t.args));var r={args:i};return n&&(r.name=n),r},_getLabel:function(t,e){var n=t.label||{},i=n;return i.position=this._getPosition(n.position,e),i}};var ch={_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={};Cs(t.items).forEach(function(t){e[t.id]=!0});var n=this.previous("ports")||{},i={};Cs(n.items).forEach(function(t){e[t.id]||(i[t.id]=!0)});var r=this.graph;r&&!Ss(i)&&(r.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),r.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()}))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&0<t.length},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return Es(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=Cs(this.prop(["ports","items"])).filter(function(t){return t.group===e});return Es(t)},getPort:function(e){return Es(Cs(this.prop("ports/items")).find(function(t){return t.id&&t.id===e}))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,Ei(this.size())).reduce(function(t,e){var n=e.portTransformation;return t[e.portId]={x:n.x,y:n.y,angle:n.angle},t},{})},getPortIndex:function(t){var e=hs(t)?t.id:t;return this._isValidPortId(e)?Cs(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!hs(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=fs([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){var i="number"==typeof t?t:this.getPortIndex(t);if(!hs(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var r=fs([],this.prop("ports/items"));return r.splice(i,0,e),this.prop("ports/items",r,n),this},portProp:function(t,e,n,i){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);var o=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?o[0]=["ports","items",r].concat(e):ds(e)?o[0]=["ports/items/",r,"/",e].join(""):(o=["ports/items/"+r],Ls(e)&&(o.push(e),o.push(n))),this.prop.apply(this,o)},_validatePorts:function(){var t=this.get("ports")||{},e=[],n=Cs((t=t||{}).items);return n.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),Ts(n,"id").length!==n.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!hs(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",fs([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var n=e||{},i=this.getPortIndex(t);if(-1!==i){var r=fs([],this.prop(["ports","items"]));r.splice(i,1),n.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],r,n),this.stopBatch("port-remove")}return this},removePorts:function(t,e){var n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;i=fs([],this.prop(["ports","items"])).filter(function(n){return!t.some(function(t){var e=hs(t)?t.id:t;return n.id===e})})}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 hh(this.get("ports"));var n=this._portSettingsData.getPorts();if(t){var i=n.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),r=t.filter(function(e){if(!n.find(function(t){return t.id===e.id}))return e});0<r.length&&this.trigger("ports:remove",this,r),0<i.length&&this.trigger("ports:add",this,i)}}},dh={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 n=[],i=this._getContainerElement(),t=0,e=i.node.childNodes.length;t<e;t++)n.push(i.node.childNodes[t]);var r=Ns(this.model._portSettingsData.getPorts(),"z");Cs(r.auto).forEach(function(t){var e=this._getPortElement(t);i.append(e),n.push(e)},this);for(var o=Object.keys(r),a=0;a<o.length;a++){var s=o[a];if("auto"!==s){var u=parseInt(s,10);this._appendPorts(r[s],u,n)}}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),r=Cs(t).map(this._getPortElement,this);n[e]||e<0?su(n[Math.max(e,0)]).before(r):i.append(r)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){var n=this._portElementsCache[t];if(!n)return[];if(!e)return[n.portContentElement.node];var i=n.portElement.node,r=n.portSelectors;return this.findBySelector(e,i,r)},findPortNode:function(t,e){var n=this.findPortNodes(t,e)[0];return void 0===n&&(n=null),n},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){ws(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){var e,n,i,r,o=su(this.portContainerMarkup).addClass("joint-port"),a=this._getPortMarkup(t);if(Array.isArray(a)){var s=this.parseDOMJSON(a,o.node),u=s.fragment;e=1<u.childNodes.length?su("g").append(u):su(u.firstChild),r=s.selectors}else e=su(a),Array.isArray(e)&&(e=su("g").append(e));if(!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group});var l,h=this._getPortLabelMarkup(t.label);if(Array.isArray(h)){var c=this.parseDOMJSON(h,o.node),d=c.fragment,f=c.selectors,p=d.childNodes.length;0<p&&(i=f,n=1===p?su(d.firstChild):su("g").append(d))}else n=su(h),Array.isArray(n)&&(n=su("g").append(n));if(r&&i){for(var g in i)if(r[g]&&g!==this.selector)throw new Error("ElementView: selectors within port must be unique.");l=fs({},r,i)}else l=r||i||{};var v="labelText";if("portRoot"in l||(l.portRoot=e.node),n){var m=n.node;if("labelRoot"in l||(l.labelRoot=m),!(v in l)){var y="TEXT"===n.tagName()?m:Array.from(m.querySelectorAll("text"));l[v]=y,i||(i={}),i[v]=y}}return o.append(e.addClass("joint-port-body")),n&&o.append(n.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:n,portSelectors:l,portLabelSelectors:i,portContentElement:e,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=Ei(this.model.size()),n=this.model._portSettingsData.getGroupPortsMetrics(t,e),i=0,r=n.length;i<r;i++){var o=n[i],a=o.portId,s=this._portElementsCache[a]||{},u=o.portTransformation,l=o.labelTransformation;l&&s.portLabelElement&&(this.updateDOMSubtreeAttributes(s.portLabelElement.node,l.attrs,{rootBBox:new Ei(o.labelSize),selectors:s.portLabelSelectors}),this.applyPortTransform(s.portLabelElement,l,-u.angle||0)),this.updateDOMSubtreeAttributes(s.portElement.node,o.portAttrs,{rootBBox:new Ei(o.portSize),selectors:s.portSelectors}),this.applyPortTransform(s.portElement,u)}},applyPortTransform:function(t,e,n){var i=su.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},fh=Wl.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),Wl.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){var i,r=cs(e),o=(n=(r?n:t)||{}).parentRelative,a=n.deep,s=n.restrictedArea;if(o){if(!this.graph)throw new Error("Element must be part of a graph.");var u=this.getParentCell();u&&!u.isLink()&&(i=u.get("position"))}if(r){if(i&&(t+=i.x,e+=i.y),a||s){var l=this.get("position"),h=l.x,c=l.y;this.translate(t-h,e-c,n)}else this.set("position",{x:t,y:e},n);return this}var d=si(this.get("position"));return o?d.difference(i):d},translate:function(t,e,n){if(e=e||0,0===(t=t||0)&&0===e)return this;(n=n||{}).translateBy=n.translateBy||this.id;var i=this.get("position")||{x:0,y:0},r=n.restrictedArea;if(r&&n.translateBy===this.id)if("function"==typeof r){var o=r.call(this,i.x+t,i.y+e,n);t=o.x-i.x,e=o.y-i.y}else{var a=this.getBBox({deep:!0}),s=i.x-a.x,u=i.y-a.y,l=Math.max(r.x+s,Math.min(r.x+r.width+s-a.width,i.x+t)),h=Math.max(r.y+u,Math.min(r.y+r.height+u-a.height,i.y+e));t=l-i.x,e=h-i.y}var c={x:i.x+t,y:i.y+e};return n.tx=t,n.ty=e,n.transition?(hs(n.transition)||(n.transition={}),this.transition("position",c,fs({},n.transition,{valueFunction:Qu.object})),ws(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",c,n),ws(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}:(hs(t)&&(n=e,e=cs(t.height)?t.height:i.height,t=cs(t.width)?t.width:i.width),this.resize(t,e,n))},resize:function(t,e,n){if(n=n||{},this.startBatch("resize",n),n.direction){var i=this.get("size");switch(n.direction){case"left":case"right":e=i.height;break;case"top":case"bottom":t=i.width}var r,o=Dn(this.get("angle")||0),a=this.getBBox();if(o){var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction];n.absolute&&(s+=Math.floor((o+45)/90),s%=4);var u=a[["bottomLeft","corner","topRight","origin"][s]](),l=si(u).rotate(a.center(),-o),h=Math.sqrt(t*t+e*e)/2,c=s*Math.PI/2;c+=Math.atan(s%2==0?e/t:t/e),c-=Gn(o);var d=si.fromPolar(h,c,l);r=si(d).offset(t/-2,e/-2)}else switch(r=a.topLeft(),n.direction){case"top":case"top-right":r.offset(0,a.height-e);break;case"left":case"bottom-left":r.offset(a.width-t,0);break;case"top-left":r.offset(a.width-t,a.height-e)}this.set("size",{width:t,height:e},n),this.position(r.x,r.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){var r=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(r.x,r.y,i),this.resize(r.width,r.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t){void 0===t&&(t={});if(!this.graph)throw new Error("Element must be part of a graph.");var e=this.getEmbeddedCells().filter(function(t){return t.isElement()});return 0===e.length||(this.startBatch("fit-embeds",t),t.deep&&ws(e,"fitToChildren",t),this._fitToElements(Object.assign({elements:e},t)),this.stopBatch("fit-embeds")),this},fitParent:function(t){void 0===t&&(t={});if(!this.graph)throw new Error("Element must be part of a graph.");if(t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id))return this;var e=this.getParentCell();if(!e||!e.isElement())return this;var n=e.getEmbeddedCells().filter(function(t){return t.isElement()});return 0===n.length||(this.startBatch("fit-parent",t),e._fitToElements(Object.assign({elements:n},t)),t.deep&&e.fitParent(t),this.stopBatch("fit-parent")),this},_fitToElements:function(t){void 0===t&&(t={});var e=this.graph.getCellsBBox(t.elements);if(e){var n=t.expandOnly,i=t.shrinkOnly;if(!n||!i){var r=e.x,o=e.y,a=e.width,s=e.height,u=Ju(t.padding),l=u.left,h=u.right,c=u.top,d=u.bottom,f=new Ei(r-=l,o-=c,a+=l+h,s+=d+c);if(n)f=this.getBBox().union(f);else if(i){var p=this.getBBox().intersect(f);if(!p)return;f=p}this.set({position:{x:f.x,y:f.y},size:{width:f.width,height:f.height}},t)}}},rotate:function(t,e,n,i){if(n){var r=this.getBBox().center(),o=this.get("size"),a=this.get("position");r.rotate(n,this.get("angle")-t);var s=r.x-o.width/2-a.x,u=r.y-o.height/2-a.y;this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(a.x+s,a.y+u,i),this.rotate(t,e,null,i),this.stopBatch("rotate")}else this.set("angle",e?t:(this.get("angle")+t)%360,i);return this},angle:function(){return Dn(this.get("angle")||0)},getBBox:function(t){void 0===t&&(t={});var e=this.graph,n=this.attributes,i=t.deep,r=t.rotate;if(i&&e){var o=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return o.push(this),e.getCellsBBox(o,t)}var a=n.angle;void 0===a&&(a=0);var s=n.position,u=s.x,l=s.y,h=n.size,c=h.width,d=h.height,f=new Ei(u,l,c,d);return r&&f.rotateAroundCenter(a),f},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),r=t.get(e);if(!r)return i;var o=r.port;if(!o||!this.hasPort(o))return i;var a=this.portProp(o,["group"]),s=this.getPortsPositions(a),u=new si(s[o]).offset(n.origin()),l=this.angle();return l&&u.rotate(i,-l),u}});fs(fh.prototype,ch);var ph=Wl.extend({defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,x:"calc(x)",y:"calc(y)",width:"calc(w)",height:"calc(h)"}},position:{distance:.5}}},defaults:{source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,n){return void 0===t?Ps(this.get("source")):(r=t instanceof Wl?((i=Ps(e)||{}).id=t.id,n):Ls(t)?(i=t,e):((i=Ps(e)||{}).x=t.x,i.y=t.y,n),this.set("source",i,r));var i,r},target:function(t,e,n){return void 0===t?Ps(this.get("target")):(r=t instanceof Wl?((i=Ps(e)||{}).id=t.id,n):Ls(t)?(i=t,e):((i=Ps(e)||{}).x=t.x,i.y=t.y,n),this.set("target",i,r));var i,r},router:function(t,e,n){if(void 0===t){var i=this.get("router");return i?"object"==typeof i?Ps(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},a=r?e:n;return this.set("router",o,a)},connector:function(t,e,n){if(void 0===t){var i=this.get("connector");return i?"object"==typeof i?Ps(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},a=r?e:n;return this.set("connector",o,a)},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){if(!e)throw new Error("dia.Link: no label provided");var i=this.labels(),r=i.length;return(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),i.splice(t,0,e),this.labels(i,n)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var n=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.labels(n,e)},vertex:function(t,e,n){var i=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1)return this.prop(["vertices",t]);var r=this._normalizeVertex(e);return this.prop(["vertices",t],r,n)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var n=[],i=0;i<t.length;i++){var r=t[i],o=this._normalizeVertex(r);n.push(o)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){if(!e)throw new Error("dia.Link: no vertex provided");var i=this.vertices(),r=i.length;(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1);var o=this._normalizeVertex(e);return i.splice(t,0,o),this.vertices(i,n)},removeVertex:function(t,e){var n=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.vertices(n,e)},_normalizeVertex:function(t){return!Ls(t)?{x:t.x,y:t.y}:t},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 si(t).scale(e,n,i).toJSON()},t)},applyToPoints:function(t,e){if(!Ms(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var n={},i=this.attributes,r=i.source,o=i.target;r.id||(n.source=t(r)),o.id||(n.target=t(o));var a=this.vertices();return 0<a.length&&(n.vertices=a.map(t)),this.set(n,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new si(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new si(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint()].concat(this.vertices().map(si),[this.getTargetPoint()]);return new Ci(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e;if(this.graph){var n=this.getSourceElement(),i=this.getTargetElement(),r=this.getParentCell();n&&i&&(e=n===i||n.isEmbeddedIn(i)?i:i.isEmbeddedIn(n)?n:this.graph.getCommonAncestor(n,i)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)}return e},hasLoop:function(t){t=t||{};var e=this.attributes,n=e.source,i=e.target,r=n.id,o=i.id;if(!r||!o)return!1;var a=r===o;if(!a&&t.deep&&this.graph){var s=this.getSourceCell(),u=this.getTargetCell();a=s.isEmbeddedIn(u)||u.isEmbeddedIn(s)}return a},getSourceCell:function(){var t=this.graph,e=this.attributes.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getSourceCell()}while(t&&t.isLink());return t},getTargetCell:function(){var t=this.graph,e=this.attributes.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getTargetCell()}while(t&&t.isLink());return t},getRelationshipAncestor:function(){var t;if(this.graph){var e=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t});t=this.graph.getCommonAncestor.apply(this.graph,e)}return t||null},isRelationshipEmbeddedIn:function(t){var e=ds(t)||cs(t)?t:t.id,n=this.getRelationshipAncestor();return!!n&&(n.id===e||n.isEmbeddedIn(e))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var n=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&n}}),gh={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var n=this._results[t];if(void 0!==n)return n;try{n=e()}catch(t){n=!1}return this._results[t]=n}},vh=fh.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"}]}),mh=fh.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"}]}),yh=fh.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"}]}),bh=fh.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"}]}),wh=fh.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"}]}),xh=fh.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"}]}),Ah=fh.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"}]}),Th=fh.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"}]}),Ph=fh.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"}]}),Eh=fh.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"}]}),Sh=fh.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"}]}),kh=fh.define("standard.Cylinder",{attrs:{root:{cursor:"move"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{cx:"calc(w/2)",cy:10,rx:"calc(w/2)",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var n={lateralArea:t},i=zu(t)?"calc("+parseFloat(t)/100+"*h)":t,r={cy:i,ry:i};return this.attr({body:n,top:r},e)}},{attributes:{"lateral-area":{set:function(t,e){var n=zu(t);n&&(t=parseFloat(t)/100);var i=e.x,r=e.y,o=e.width,a=e.height,s=o/2,u=n?a*t:t,l=su.KAPPA,h=l*s,c=l*(n?a*t:t),d=i+o/2,f=i+o,p=r+u,g=p-u,v=r+a-u,m=r+a;return{d:["M",i,p,"L",i,v,"C",i,v+c,d-h,m,d,m,"C",d+h,m,f,v+c,f,v,"L",f,p,"C",f,p-c,d+h,g,d,g,"C",d-h,g,i,p-c,i,p,"Z"].join(" ")}}}}}),Mh=gh.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"}},Lh={standard:{Rectangle:vh,Circle:mh,Ellipse:yh,Path:bh,Polygon:wh,Polyline:xh,Image:Ah,BorderedImage:Th,EmbeddedImage:Ph,InscribedImage:Eh,HeaderedRectangle:Sh,Cylinder:kh,TextBlock:fh.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"},Mh]},{attributes:{text:{set:function(t,e,n,i){if(!(n instanceof HTMLElement)){var r=i.style||{},o={text:t,width:-5,height:"100%"},a=fs({"text-vertical-anchor":"middle"},r);return Hl["text-wrap"].set.call(this,o,e,n,a),{fill:r.color||null}}n.textContent=t},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),Link:ph.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"}}]}),DoubleLink:ph.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"}}]}),ShadowLink:ph.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"}}]})}},Ch={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},_h=Object.values(Ch),Nh=function(t,e,n,i){void 0===n&&(n=[]),void 0===i&&(i={});var r=i.cornerType;void 0===r&&(r=Ch.POINT);var o=i.cornerRadius;void 0===o&&(o=10);var a=i.cornerPreserveAspectRatio;void 0===a&&(a=!1);var s=i.precision;void 0===s&&(s=1);var u,l=i.raw;if(void 0===l&&(l=!1),-1===_h.indexOf(r))throw new Error("Invalid `cornerType` provided to `straight` connector.");if(r!==Ch.POINT&&o){var h;(u=new Ii).appendSegment(Ii.createSegment("M",t));for(var c=n.length,d=0;d<c;d++){var f=new si(n[d]),p=n[d-1]||t,g=n[d+1]||e,v=h||f.distance(p)/2;h=f.distance(g)/2;var m=void 0,y=void 0;a?m=y=-Math.min(o,v,h):(m=-Math.min(o,v),y=-Math.min(o,h));var b=f.clone().move(p,m).round(s),w=f.clone().move(g,y).round(s);switch(u.appendSegment(Ii.createSegment("L",b)),r){case Ch.CUBIC:var x=new si(1/3*b.x+2/3*f.x,2/3*f.y+1/3*b.y),A=new si(1/3*w.x+2/3*f.x,2/3*f.y+1/3*w.y);u.appendSegment(Ii.createSegment("C",x,A,w));break;case Ch.LINE:u.appendSegment(Ii.createSegment("L",w));break;case Ch.GAP:u.appendSegment(Ii.createSegment("M",w))}}u.appendSegment(Ii.createSegment("L",e))}else{var T=[t].concat(n).concat([e]),P=new Ci(T);u=new Ii(P)}return l?u:u.serialize()},Oh=["arc","gap","cubic"],Rh=["smooth"],Fh=1/3,Bh=2/3;function Vh(t,e){var n=t.x,i=t.y,r=e.x,o=e.y;if(r<n){var a=n;n=r,r=a,a=i,i=o,o=a}if(o<i){var s=n;n=r,r=s,s=i,i=o,o=s}return[new si(n,i),new si(r,o)]}function Ih(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]=di(e,i)),t},[])}function Dh(t,e){return di(t,e).squaredLength()}function jh(k,M,L,C){var _,N=new Ii;return _=Ii.createSegment("M",k[0].start),N.appendSegment(_),Cs(k).forEach(function(t,e){if(t.isJump){var n,i,r,o;if("arc"===L){n=-90,i=t.start.difference(t.end);var a=Number(i.x<0||0===i.x&&i.y<0);a&&(n+=180);var s,u=t.midpoint(),l=new ci(u,t.end).rotate(u,n);r=(s=new ci(t.start,u)).pointAt(2/3).rotate(t.start,n),o=l.pointAt(1/3).rotate(l.end,-n),_=Ii.createSegment("C",r,o,l.end),N.appendSegment(_),s=new ci(u,t.end),r=l.pointAt(1/3).rotate(l.end,n),o=s.pointAt(1/3).rotate(t.end,-n),_=Ii.createSegment("C",r,o,t.end),N.appendSegment(_)}else if("gap"===L)_=Ii.createSegment("M",t.end),N.appendSegment(_);else if("cubic"===L){n=t.start.theta(t.end);var h=.6*M,c=1.35*M;i=t.start.difference(t.end),(a=Number(i.x<0||0===i.x&&i.y<0))&&(c*=-1),r=si(t.start.x+h,t.start.y+c).rotate(t.start,n),o=si(t.end.x-h,t.end.y+c).rotate(t.end,n),_=Ii.createSegment("C",r,o,t.end),N.appendSegment(_)}}else{var d=k[e+1];0==C||!d||d.isJump?(_=Ii.createSegment("L",t.end),N.appendSegment(_)):(f=C,p=N,g=t.end,v=t.start,m=d.end,b=g.distance(v)/2,w=g.distance(m)/2,x=-Math.min(f,b),A=-Math.min(f,w),T=g.clone().move(v,x).round(),P=g.clone().move(m,A).round(),E=new si(Fh*T.x+Bh*g.x,Bh*g.y+Fh*T.y),S=new si(Fh*P.x+Bh*g.x,Bh*g.y+Fh*P.y),y=Ii.createSegment("L",T),p.appendSegment(y),y=Ii.createSegment("C",E,S,P),p.appendSegment(y))}var f,p,g,v,m,y,b,w,x,A,T,P,E,S}),N}var zh={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},Gh={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},Uh=function(t,e,n,i,r){void 0===n&&(n=[]),void 0===i&&(i={});var o=Boolean(i.raw),a=i.direction;void 0===a&&(a=zh.AUTO);var s=i.precision;void 0===s&&(s=3);var u={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new si(i.sourceTangent):null,targetTangent:i.targetTangent?new si(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?u.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?u.sourceDirection=new si(1,0).rotate(null,i.sourceDirection):u.sourceDirection=i.sourceDirection?new si(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?u.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?u.targetDirection=new si(1,0).rotate(null,i.targetDirection):u.targetDirection=i.targetDirection?new si(i.targetDirection).normalize():null;var l,h,c=[t].concat(n,[e]).map(function(t){return new si(t)});if(u.sourceTangent)l=u.sourceTangent;else{var d=function(t,e,n,i){if(i.sourceDirection)switch(i.sourceDirection){case Gh.UP:return new si(0,-1);case Gh.DOWN:return new si(0,1);case Gh.LEFT:return new si(-1,0);case Gh.RIGHT:return new si(1,0);case Gh.AUTO:return Hh(t,e,i);case Gh.CLOSEST_POINT:return Wh(t,e,i);case Gh.OUTWARDS:return Xh(t,e,i);default:return i.sourceDirection}switch(n){case zh.HORIZONTAL:return function(t,e,n){var i,r,o,a=t.sourceBBox;if(t.sourceView)if(r=t.sourceView.model.angle(),n.rotate&&r){var s=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),u=e[0].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[0]);else i=a.x>e[1].x?"right":"left";switch(i){case"left":o=new si(-1,0);break;case"right":default:o=new si(1,0)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.VERTICAL:return function(t,e,n){var i,r,o,a=t.sourceBBox;if(t.sourceView)if(r=t.sourceView.model.angle(),n.rotate&&r){var s=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),u=e[0].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[0]);else i=a.y>e[1].y?"bottom":"top";switch(i){case"top":o=new si(0,-1);break;case"bottom":default:o=new si(0,1)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.CLOSEST_POINT:return Wh(t,e,i);case zh.OUTWARDS:return Xh(t,e,i);case zh.AUTO:default:return Hh(t,e,i)}}(r,c,a,u),f=c[0].distance(c[1])*u.coeff,p=Jh(d,c[1].difference(c[0]).normalize());if(p>Math.PI/4){var g=f+(p-Math.PI/4)*u.angleTangentCoefficient;l=d.clone().scale(g,g)}else l=d.clone().scale(f,f)}if(u.targetTangent)h=u.targetTangent;else{var v=function(t,e,n,i){if(i.targetDirection)switch(i.targetDirection){case Gh.UP:return new si(0,-1);case Gh.DOWN:return new si(0,1);case Gh.LEFT:return new si(-1,0);case Gh.RIGHT:return new si(1,0);case Gh.AUTO:return qh(t,e,i);case Gh.CLOSEST_POINT:return Yh(t,e,i);case Gh.OUTWARDS:return $h(t,e,i);default:return i.targetDirection}switch(n){case zh.HORIZONTAL:return function(t,e,n){var i,r,o,a=t.targetBBox;if(t.targetView)if(r=t.targetView.model.angle(),n.rotate&&r){var s=t.targetView.getNodeUnrotatedBBox(t.targetView.el),u=e[e.length-1].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[e.length-1]);else i=a.x>e[e.length-2].x?"left":"right";switch(i){case"left":o=new si(-1,0);break;case"right":default:o=new si(1,0)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.VERTICAL:return function(t,e,n){var i,r,o,a=t.targetBBox;if(t.targetView)if(r=t.targetView.model.angle(),n.rotate&&r){var s=t.targetView.getNodeUnrotatedBBox(t.targetView.el),u=e[e.length-1].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[e.length-1]);else i=a.y>e[e.length-2].y?"top":"bottom";switch(i){case"top":o=new si(0,-1);break;case"bottom":default:o=new si(0,1)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.CLOSEST_POINT:return Yh(t,e,i);case zh.OUTWARDS:return $h(t,e,i);case zh.AUTO:default:return qh(t,e,i)}}(r,c,a,u),m=c.length-1,y=c[m-1].distance(c[m])*u.coeff,b=Jh(v,c[m-1].difference(c[m]).normalize());if(b>Math.PI/4){var w=y+(b-Math.PI/4)*u.angleTangentCoefficient;h=v.clone().scale(w,w)}else h=v.clone().scale(y,y)}var x=function(t,e,n,i){for(var r=i.tau,o=i.coeff,a=[],s=[],u=[],l=t.length-1,h=0;h<l;h++)a[h]=t[h].distance(t[h+1]);s[0]=e,s[l]=n;for(var c=1;c<l;c++){var d=void 0,f=void 0;d=1===c?t[c-1].clone().offset(s[c-1].x,s[c-1].y):t[c-1].clone(),f=c===l-1?t[c+1].clone().offset(s[c+1].x,s[c+1].y):t[c+1].clone();var p=d.difference(t[c]).normalize(),g=f.difference(t[c]).normalize(),v=Jh(p,g),m=(Math.PI-v)/2,y=void 0,b=Kh(p,g),w=void 0;w=Kh(t[c].difference(t[c+1]),t[c].difference(t[c-1])),b<0&&(m=-m),v<Math.PI/2&&(m<0&&w<0||0<m&&0<w)&&(m-=Math.PI),Zh(y=g.clone(),m);var x=y.clone(),A=y.clone(),T=a[c-1]*o,P=a[c]*o;x.scale(T,T),A.scale(P,P),s[c]=[x,A]}for(var E=0;E<l;E++){var S=void 0,k=void 0;S=0===E?t[E+1].difference(s[E].x/r,s[E].y/r):t[E+1].difference(s[E][1].x/r,s[E][1].y/r),k=E===l-1?t[E].clone().offset(s[E+1].x/r,s[E+1].y/r):t[E].difference(s[E+1][0].x/r,s[E+1][0].y/r),u[E]=[S,t[E],t[E+1],k]}return u}(c,l,h,u).map(function(t){return function(t,e){var n=e.tau,i=new si;i.x=t[1].x+(t[2].x-t[0].x)/(6*n),i.y=t[1].y+(t[2].y-t[0].y)/(6*n);var r=new si;return r.x=t[2].x+(t[3].x-t[1].x)/(6*n),r.y=t[2].y+(t[3].y-t[1].y)/(6*n),new Bi(t[1],i,r,t[2])}(t,u)}),A=new Ii(x).round(s);return o?A:A.serialize()};function Hh(t,e,n){var i,r,o,a=t.sourceBBox;if(t.sourceView)if(r=t.sourceView.model.angle(),n.rotate&&r){var s=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),u=e[0].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[0]);else i=a.sideNearestToPoint(e[1]);switch(i){case"top":o=new si(0,-1);break;case"bottom":o=new si(0,1);break;case"right":o=new si(1,0);break;case"left":o=new si(-1,0)}return n.rotate&&r&&o.rotate(null,-r),o}function qh(t,e,n){var i,r,o,a=t.targetBBox;if(t.targetView)if(r=t.targetView.model.angle(),n.rotate&&r){var s=t.targetView.getNodeUnrotatedBBox(t.targetView.el),u=e[e.length-1].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[e.length-1]);else i=a.sideNearestToPoint(e[e.length-2]);switch(i){case"top":o=new si(0,-1);break;case"bottom":o=new si(0,1);break;case"right":o=new si(1,0);break;case"left":o=new si(-1,0)}return n.rotate&&r&&o.rotate(null,-r),o}function Wh(t,e,n){return e[1].difference(e[0]).normalize()}function Yh(t,e,n){var i=e.length-1;return e[i-1].difference(e[i]).normalize()}function Xh(t,e,n){var i=t.sourceBBox.center();return e[0].difference(i).normalize()}function $h(t,e,n){var i=t.targetBBox.center();return e[e.length-1].difference(i).normalize()}function Zh(t,e){var n=Math.cos(e),i=Math.sin(e),r=n*t.x-i*t.y,o=i*t.x+n*t.y;t.x=r,t.y=o}function Jh(t,e){var n=t.dot(e)/(t.magnitude()*e.magnitude());return n<-1&&(n=-1),1<n&&(n=1),Math.acos(n)}function Kh(t,e){return t.x*e.y-t.y*e.x}Uh.Directions=zh,Uh.TangentDirections=Gh;var Qh={straight:Nh,jumpover:function(t,e,n,i){!function(t){var e=t.paper,n=e._jumpOverUpdateList;if(null==n){n=e._jumpOverUpdateList=[];var i=e.model;i.on("batch:stop",function(){this.hasActiveBatch()||function(t){for(var e=t._jumpOverUpdateList,n=0;n<e.length;n++){var i=e[n],r=i.getFlag(i.constructor.Flags.CONNECTOR);i.requestUpdate(r)}}(e)}),i.on("reset",function(){n=e._jumpOverUpdateList=[]})}n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",function(){n.splice(n.indexOf(t),1)}))}(this);var r=i.raw,o=i.size||5,a=i.jump&&(""+i.jump).toLowerCase(),s=i.radius||0,u=i.ignoreConnectors||Rh;-1===Oh.indexOf(a)&&(a=Oh[0]);var l=this.paper,h=l.model.getLinks();if(1===h.length)return jh(Ih(t,e,n),o,a,s);var d=this.model,c=h.indexOf(d),f=l.options.defaultConnector||{},p=h.filter(function(t,e){var n=t.get("connector")||f;return!(Cs(u).includes(n.name)||c<e&&"jumpover"===n.name)}),g=p.map(function(t){return l.findViewByModel(t)}),v=Ih(t,e,n),y=g.map(function(t){return null==t?[]:t===this?v:Ih(t.sourcePoint,t.targetPoint,t.route)},this),m=jh(v.reduce(function(t,m){var l,h,c,e=p.reduce(function(t,e,n){if(e!==d){var i=y[n].slice(),r=i.findIndex(function(t){return n=t,i=Vh((e=m).start,e.end),r=i[0],o=r.x,a=r.y,s=i[1],u=s.x,l=s.y,h=Vh(n.start,n.end),c=h[0],d=c.x,f=c.y,p=h[1],g=p.x,v=p.y,o<=g&&d<=u&&a<=v&&f<=l;var e,n,i,r,o,a,s,u,l,h,c,d,f,p,g,v});-1<r&&m.containsPoint(i[r].end)&&i.splice(r+1,1);var o=(a=m,Cs(i).reduce(function(t,e){var n=a.intersection(e);return n&&t.push(n),t},[]));t.push.apply(t,o)}var a;return t},[]).sort(function(t,e){return Dh(m.start,t)-Dh(m.start,e)});return 0<e.length?t.push.apply(t,(l=m,c=o,(h=e).reduce(function(t,e,n){if(!0===e.skip)return t;var i=t.pop()||l,r=ui(e).move(i.start,-c),o=ui(e).move(i.start,+c),a=h[n+1];if(null!=a){var s=o.distance(a);s<=c&&(o=a.move(i.start,s),a.skip=!0)}else if(r.distance(i.end)<2*c+1)return t.push(i),t;if(o.distance(i.start)<2*c+1)return t.push(i),t;var u=di(r,o);return u.isJump=!0,t.push(di(i.start,r),u,di(o,i.end)),t},[]))):t.push(m),t},[]),o,a,s);return r?m:m.serialize()},normal:function(t,e,n,i){void 0===n&&(n=[]),void 0===i&&(i={});var r=i.raw;return Nh(t,e,n,{cornerType:"point",raw:r})},rounded:function(t,e,n,i){void 0===n&&(n=[]),void 0===i&&(i={});var r=i.radius;void 0===r&&(r=10);var o=i.raw;return Nh(t,e,n,{cornerType:"cubic",cornerRadius:r,precision:0,raw:o})},smooth:function(t,e,n,i){var r,o=i&&i.raw;if(n&&0!==n.length){var a=[t].concat(n).concat([e]),s=Bi.throughPoints(a);r=new Ii(s)}else{var u;if(r=new Ii,u=Ii.createSegment("M",t),r.appendSegment(u),Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)){var l=(t.x+e.x)/2;u=Ii.createSegment("C",l,t.y,l,e.y,e.x,e.y),r.appendSegment(u)}else{var h=(t.y+e.y)/2;u=Ii.createSegment("C",t.x,h,e.x,h,e.x,e.y),r.appendSegment(u)}}return o?r:r.serialize()},curve:Uh},tc=function(t){this.cid=qs("view"),this.preinitialize.apply(this,arguments),fs(this,zs(t,nc)),this._ensureElement(),this.initialize.apply(this,arguments)},ec=/^(\S+)\s*(.*)$/,nc=["model","collection","el","id","attributes","className","tagName","events"];fs(tc.prototype,rl,{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 iu?t:iu(t),this.el=this.$el[0]},delegateEvents:function(t){if(t||(t=Ds(this,"events")),!t)return this;for(var e in this.undelegateEvents(),t){var n=t[e];if(Ms(n)||(n=this[n]),n){var i=e.match(ec);this.delegate(i[1],i[2],n.bind(this))}}return this},delegate:function(t,e,n){return this.$el.on(t+".delegateEvents"+this.cid,e,n),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,n){return this.$el.off(t+".delegateEvents"+this.cid,e,n),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){if(this.el)this.setElement(Ds(this,"el"));else{var t=fs({},Ds(this,"attributes"));this.id&&(t.id=Ds(this,"id")),this.className&&(t.class=Ds(this,"className")),this.setElement(this._createElement(Ds(this,"tagName"))),this._setAttributes(t)}},_setAttributes:function(t){this.$el.attr(t)}}),tc.extend=gl;var ic={},rc=tc.extend({options:{},theme:null,themeClassNamePrefix:Su("theme-"),requireSetThemeOverride:!1,defaultTheme:xu.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=fs({},this.options,t),tc.call(this,t)},initialize:function(){(ic[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){this.svgElement?this.vel.remove():this.$el.remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){if(t||(t=Ds(this,"children")),t){var e=this.svgElement,n=su.namespace[e?"svg":"xhtml"],i=ku(t,n);(e?this.vel:this.$el).empty().append(i.fragment),this.childNodes=i.selectors}return this},findAttribute:function(t,e){for(var n=e;n&&1===n.nodeType;){var i=n.getAttribute(t);if(i)return i;if(n===this.el)return null;n=n.parentNode}return null},_ensureElement:function(){if(this.el)this.setElement(Ds(this,"el"));else{var t=Ds(this,"tagName"),e=fs({},Ds(this,"attributes")),n=fs({},Ds(this,"style"));this.id&&(e.id=Ds(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)}this._ensureElClassName()},_setAttributes:function(t){this.svgElement?this.vel.attr(t):this.$el.attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(su.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof iu?t:iu(t),this.el=this.$el[0],this.svgElement&&(this.vel=su(this.el))},_ensureElClassName:function(){var t=Ds(this,"className");if(t){var e=Su(t);this.svgElement?this.vel.removeClass(t).addClass(e):this.$el.removeClass(t).addClass(e)}},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.addClass(e):this.$el.addClass(e),this},removeThemeClassName:function(t){t=t||this.theme;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.removeClass(e):this.$el.removeClass(e),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),ic[this.cid]=null,tc.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(!e)return this;n||(n={});var i=this.getEventNamespace();for(var r in e){var o=e[r];"function"!=typeof o&&(o=this[o]),o&&iu(t).on(r+i,n,o.bind(this))}return this},undelegateElementEvents:function(t){return iu(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t||(t=Ds(this,"documentEvents")),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var n=t.data,i="__"+this.cid+"__";return void 0===e?n&&n[i]||{}:(n||(n=t.data={}),n[i]||(n[i]={}),fs(n[i],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&fs({},t[0])||{},n=t[1]&&fs({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,tc.extend.call(this,e,n)}}),oc=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.callbackArguments=t};oc.prototype.listenTo=function(i,t){for(var r=this,e=[],n=arguments.length-2;0<n--;)e[n]=arguments[n+2];var o=this.callbackArguments;if(su.isObject(t)){var a=e[0];void 0===a&&(a=null),Object.entries(t).forEach(function(t){var e=t[0],n=t[1];"function"==typeof n&&((a||0<o.length)&&(n=n.bind.apply(n,[a].concat(o))),rl.listenTo.call(r,i,e,n))})}else if("string"==typeof t&&"function"==typeof e[0]){var s=e[0],u=e[1];void 0===u&&(u=null),(u||0<o.length)&&(s=s.bind.apply(s,[u].concat(o))),rl.listenTo.call(this,i,t,s)}};var ac=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,fs({silent:!0},e))},sc={add:!0,remove:!0,merge:!0},uc={add:!0,remove:!(oc.prototype.stopListening=function(){rl.stopListening.call(this)})},lc=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var i,r=Array(t.length-n),o=e.length;for(i=0;i<r.length;i++)r[i]=t[i+n];for(i=0;i<o;i++)t[i+n]=e[i];for(i=0;i<r.length;i++)t[i+o+n]=r[i]};fs(ac.prototype,rl,{model:bl,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(t,e){return this.set(t,fs({merge:!1},e,uc))},remove:function(t,e){e=fs({},e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=this._removeModels(t,e);return!e.silent&&i.length&&(e.changes={added:[],merged:[],removed:i},this.trigger("update",this,e)),n?i[0]:i},set:function(t,e){if(null!=t){e=fs({},sc,e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=e.at;null!=i&&(i=+i),i>this.length&&(i=this.length),i<0&&(i+=this.length+1);var r,o,a=[],s=[],u=[],l=[],h={},c=e.add,d=e.merge,f=e.remove,p=!1,g=this.comparator&&null==i&&!1!==e.sort,v=ds(this.comparator)?this.comparator:null;for(o=0;o<t.length;o++){r=t[o];var m=this.get(r);if(m){if(d&&r!==m){var y=this._isModel(r)?r.attributes:r;m.set(y,e),u.push(m),g&&!p&&(p=m.hasChanged(v))}h[m.cid]||(h[m.cid]=!0,a.push(m)),t[o]=m}else c&&(r=t[o]=this._prepareModel(r,e))&&(s.push(r),this._addReference(r,e),h[r.cid]=!0,a.push(r))}if(f){for(o=0;o<this.length;o++)h[(r=this.models[o]).cid]||l.push(r);l.length&&this._removeModels(l,e)}var b=!1,w=!g&&c&&f;if(a.length&&w?(b=this.length!==a.length||this.models.some(function(t,e){return t!==a[e]}),this.models.length=0,lc(this.models,a,0),this.length=this.models.length):s.length&&(g&&(p=!0),lc(this.models,s,null==i?this.length:i),this.length=this.models.length),p&&this.sort({silent:!0}),!e.silent){for(o=0;o<s.length;o++)null!=i&&(e.index=i+o),(r=s[o]).trigger("add",r,this,e);(p||b)&&this.trigger("sort",this,e),(s.length||l.length||u.length)&&(e.changes={added:s,removed:l,merged:u},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?Ps(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,fs({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,fs({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,fs({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 Ms(e)&&(e=e.bind(this)),1===n||ds(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 cc(this,dc)},keys:function(){return new cc(this,fc)},entries:function(){return new cc(this,pc)},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){return void 0===e&&(e=this.first()),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):(n=((e=e?Ps(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,n.validationError,e),!1):n;var n},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r=this.get(t[i]);if(r){var o=this.models.indexOf(r);this.models.splice(o,1),this.length--,delete this._byId[r.cid];var a=this.modelId(r.attributes,r.idAttribute);null!=a&&delete this._byId[a],e.silent||(e.index=o,r.trigger("remove",r,this,e)),n.push(r),this._removeReference(r,e)}}return 0<t.length&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof bl},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,i){if(e){if(("add"===t||"remove"===t)&&n!==this)return;if("changeId"===t){var r=this.modelId(e.previousAttributes(),e.idAttribute),o=this.modelId(e.attributes,e.idAttribute);null!=r&&delete this._byId[r],null!=o&&(this._byId[o]=e)}}this.trigger.apply(this,arguments)}});var hc="function"==typeof Symbol&&Symbol.iterator;hc&&(ac.prototype[hc]=ac.prototype.values);var cc=function(t,e){this._collection=t,this._kind=e,this._index=0},dc=1,fc=2,pc=3;hc&&(cc.prototype[hc]=function(){return this}),cc.prototype.next=function(){if(this._collection){if(this._index<this._collection.length){var t,e=this._collection.at(this._index);if(this._index++,this._kind===dc)t=e;else{var n=this._collection.modelId(e.attributes,e.idAttribute);t=this._kind===fc?n:[n,e]}return{value:t,done:!1}}this._collection=void 0}return{value:void 0,done:!0}};var gc,vc,mc,yc;vc=(gc=[ac,{toArray:1,sortBy:3},"models"])[0],mc=gc[1],yc=gc[2],vl(vc,{sortBy:Os,toArray:Cs},mc,yc),ac.extend=gl;var bc={Data:Ys,$:iu,views:ic,View:rc,Listener:oc,Events:rl,Collection:ac,Model:bl,ViewBase:tc,Event:Zs};function wc(t){return t?Array.isArray(t)?t:[t]:[]}var xc=rc.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:function(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:function(){this.updateRequested=!1;var t=this.cellView,e=this.nodeSelector;return t.isMounted()?(this.update(t,e),this.mount(),this.transform()):this.postponedUpdate=!0,0},findNode:function(t,e){var n;if(void 0===e&&(e=null),"string"==typeof e)n=t.findNode(e);else if(Ls(e)){var i=t.model.isLink(),r=e.label;void 0===r&&(r=null);var o=e.port,a=e.selector;n=i&&null!==r?t.findLabelNode(r,a):!i&&o?t.findPortNode(o,a):t.findNode(a)}else e&&((n=su.toNode(e))instanceof SVGElement||(n=null));return n||null},getNodeMatrix:function(t,e){var n=this.options.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:function(){var t=this.MOUNTABLE,e=this.cellView,n=this.el,i=this.options,r=this.transformGroup,o=this.detachedTransformGroup,a=this.postponedUpdate,s=this.nodeSelector;if(t&&!r){if(a)return this.update(e,s),void this.transform();var u,l=e.vel,h=e.paper,c=i.layer;if(c)o?(u=o,this.detachedTransformGroup=null):u=su("g").addClass("highlight-transform").append(n),this.transformGroup=u,h.getLayerView(c).insertSortedNode(u.node,i.z);else n.parentNode&&!n.nextSibling||l.append(n)}},unmount:function(){var t=this.MOUNTABLE,e=this.transformGroup,n=this.vel;t&&(e?(this.transformGroup=null,(this.detachedTransformGroup=e).remove()):n.remove())},transform:function(){var t=this.transformGroup,e=this.cellView,n=this.updateRequested;if(t&&!e.model.isLink()&&!n){var i=e.getRootTranslateMatrix(),r=e.getRootRotateMatrix(),o=i.multiply(r);t.attr("transform",su.matrixToTransformString(o))}},update:function(){var t=this.node,e=this.cellView,n=this.nodeSelector,i=this.updateRequested,r=this.id;if(!i){this.postponedUpdate=!1;var o=this.node=this.findNode(e,n);t&&this.unhighlight(e,t),o?(this.highlight(e,o),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this))}},onRemove:function(){var t=this.node,e=this.cellView,n=this.id,i=this.constructor;t&&this.unhighlight(e,t),this.unmount(),i._removeRef(e,n)},highlight:function(t,e){},unhighlight:function(t,e){},listenToUpdateAttributes:function(t){var e=Ds(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange:function(){var t=this.cellView;if(t){var e=t.model,n=t.paper;Ds(this,"UPDATE_ATTRIBUTES").some(function(t){return e.hasChanged(t)})&&n.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){var i=this.uniqueId(e,n);this.remove(t,i)},get:function(t,e){void 0===e&&(e=null);var n=t.cid,i=this._views[n];if(null===e){var r=[];if(!i)return r;for(var o in i){var a=i[o];a instanceof this&&r.push(a)}return r}if(!i)return null;if(e in i){var s=i[e];if(s instanceof this)return s}return null},add:function(t,e,n,i){if(void 0===i&&(i={}),!n)throw new Error("dia.HighlighterView: An ID required.");var r=xc.get(t,n);r&&r.remove();var o=new this(i);return o.id=n,this._addRef(t,n,o),o.requestUpdate(t,e),o.listenToUpdateAttributes(t),o},_addRef:function(t,e,n){var i=t.cid,r=this._views,o=r[i];o||(o=r[i]={}),o[e]=n},_removeRef:function(t,e){var n=t.cid,i=this._views,r=i[n];if(r){for(var o in e&&delete r[e],r)return;delete i[n]}},remove:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){t.remove()})},removeAll:function(t,e){void 0===e&&(e=null);var n=this._views;for(var i in n)for(var r in n[i]){var o=n[i][r];o.cellView.paper===t&&o instanceof this&&(null===e||r===e)&&o.remove()}},update:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1),wc(this.get(t,e)).forEach(function(t){(n||t.UPDATABLE)&&t.update()})},transform:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){t.UPDATABLE&&t.transform()})},unmount:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){return t.unmount()})},mount:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){return t.mount()})},uniqueId:function(t,e){return void 0===e&&(e=""),su.ensureId(t)+JSON.stringify(e)}}),Ac=xc.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:function(e,n){var i,r=this.options,t=r.useFirstSubpath;try{var o=su(n);if(i=o.convertToPathData().trim(),"PATH"===o.tagName()&&t){var a=i.search(/.M/i)+1;0<a&&(i=i.substr(0,a))}}catch(t){var s=e.getNodeBoundingRect(n);i=su.rectToPath(fs({},r,s.toJSON()))}return i},highlightConnection:function(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode:function(t,e){var n=this.vel,i=this.options,r=i.padding,o=i.layer,a=this.getNodeMatrix(t,e);if(r){o||e!==t.el||n.remove();var s=t.getNodeBoundingRect(e),u=s.x+s.width/2,l=s.y+s.height/2;s=su.transformRect(s,a);var h=Math.max(s.width,1),c=Math.max(s.height,1),d=(h+r)/h,f=(c+r)/c,p=su.createSVGMatrix({a:d,b:0,c:0,d:f,e:u-d*u,f:l-f*l});a=a.multiply(p)}n.attr({d:this.getPathData(t,e),transform:su.matrixToTransformString(a)})},highlight:function(t,e){var n=this.vel,i=this.options;n.attr(i.attrs),i.nonScalingStroke&&n.attr("vector-effect","non-scaling-stroke"),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}});var Tc=xc.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:function(t,e){var n=this.MASK_CHILD_ATTRIBUTE_BLACKLIST,i=this.MASK_REPLACE_TAGS,r=this.MASK_REMOVE_TAGS,o=e.tagName();if(!su.isSVGGraphicsElement(e)||r.includes(o))return e.remove(),!1;if(i.includes(o)){var a=t.vel.findOne("#"+e.id);if(a){var s=a.node,u=t.getNodeBoundingRect(s);t.model.isElement()&&(u=su.transformRect(u,t.getNodeMatrix(s)));var l=su("rect",u.toJSON()),h=u.center(),c=h.x,d=h.y,f=a.rotate(),p=f.angle,g=f.cx;void 0===g&&(g=c);var v=f.cy;void 0===v&&(v=d),p&&l.rotate(p,g,v),e.parent().append(l)}return e.remove(),!1}return n.forEach(function(t){"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)}),!0},transformMaskRoot:function(t,e){this.MASK_ROOT_ATTRIBUTE_BLACKLIST.forEach(function(t){e.removeAttr(t)})},getMaskShape:function(e,t){var n,i=this,r=this.options,o=this.MASK_REPLACE_TAGS,a=r.deep,s=t.tagName();if("G"===s){if(!a)return null;(function(t,e){for(var n=t.children();0<n.length;){var i=n.shift();e(i)&&n.push.apply(n,i.children())}})(n=t.clone(),function(t){return i.transformMaskChild(e,t)})}else{if(o.includes(s))return null;n=t.clone()}return this.transformMaskRoot(e,n),n},getMaskId:function(){return"highlight-mask-"+this.cid},getMask:function(t,e){var n=this.VISIBLE,i=this.INVISIBLE,r=this.options,o=r.padding,a=r.attrs,s=parseFloat(su("g").attr(a).attr("stroke-width")),u="none"!==e.attr("fill"),l=parseFloat(e.attr("stroke-width"));isNaN(l)&&(l=1);var h=l+2*o,c=h+2*s,d=this.getMaskShape(t,e);if(!d){var f=t.getNodeBoundingRect(e.node);f.inflate(f.width?0:.5,f.height?0:.5),d=su("rect",f.toJSON())}return d.attr(a),su("mask",{id:this.getMaskId()}).append([d.clone().attr({fill:u?n:"none",stroke:n,"stroke-width":c}),d.clone().attr({fill:u?i:"none",stroke:i,"stroke-width":h})])},removeMask:function(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask:function(t,e){t.defs.appendChild(e.node)},highlight:function(t,e){var n=this.options,i=this.vel,r=n.padding,o=n.attrs,a=n.maskClip;void 0===a&&(a=20);var s=n.layer,u="stroke"in o?o.stroke:"#000000";s||e!==t.el||i.remove();var l=t.getNodeBoundingRect(e).inflate(r+a),h=this.getNodeMatrix(t,e),c=this.getMask(t,su(e));this.addMask(t.paper,c),i.attr(l.toJSON()),i.attr({transform:su.matrixToTransformString(h),mask:"url(#"+c.id+")",fill:u})},unhighlight:function(t){this.removeMask(t.paper)}}),Pc=xc.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){var n=this.options.alphaValue;void 0===n&&(n=.3),e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),Ec=Su("highlighted"),Sc=xc.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:Ec},highlight:function(t,e){su(e).addClass(this.options.className)},unhighlight:function(t,e){su(e).removeClass(this.options.className)}},{className:Ec}),kc={ROW:"row",COLUMN:"column"},Mc={stroke:Ac,mask:Tc,opacity:Pc,addClass:Sc,list:xc.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight:function(t,e){var o=this,n=t.model,i=this.options,a=i.attribute,r=i.size;void 0===r&&(r=20);var s=i.gap;void 0===s&&(s=5);var u=i.direction;if(void 0===u&&(u=kc.ROW),!a)throw new Error("List: attribute is required");var l="number"==typeof r?{width:r,height:r}:r,h=u===kc.ROW,c=h?l.width:l.height,d=n.get(a);Array.isArray(d)||(d=[]);var f=this._prevItems||[],p=d.map(function(t,e){return ks(f[e],d[e])});if(f.length!==d.length||p.some(function(t){return!t})){var g=this.vel.children(),v=d.map(function(t,e){var n=e in g?g[e].node:null;if(p[e])return n;var i=o.createListItem(t,l,n);if(!i)return null;if(!(i instanceof SVGElement))throw new Error("List: item must be an SVGElement");i.dataset.index=e,i.dataset.attribute=a;var r=e*(c+s);return i.setAttribute("transform",h?"translate("+r+", 0)":"translate(0, "+r+")"),i});this.vel.empty().append(v),this._prevItems=d}var m=d.length,y=0===m?0:m*c+(m-1)*s,b=h?{width:y,height:l.height}:{width:l.width,height:y};this.position(n,b)},position:function(t,e){var n=this.vel,i=this.options,r=i.margin;void 0===r&&(r=5);var o=i.position;void 0===o&&(o="top-left");var a=t.size(),s=a.width,u=a.height,l=Ju(r),h=l.left,c=l.right,d=l.top,f=l.bottom,p=Zl(new Ei(h,d,s-(h+c),u-(d+f)),o),g=p.x,v=p.y;switch(o){case $l.CENTER:case $l.TOP:case $l.BOTTOM:g-=e.width/2;break;case $l.RIGHT:case $l.BOTTOM_RIGHT:case $l.TOP_RIGHT:g-=e.width}switch(o){case $l.CENTER:case $l.RIGHT:case $l.LEFT:v-=e.height/2;break;case $l.BOTTOM:case $l.BOTTOM_RIGHT:case $l.BOTTOM_LEFT:v-=e.height}n.attr("transform","translate("+g+", "+v+")")}},{Directions:kc,Positions:$l})};function Lc(t,e,n){if(Ls(n)){var i=n.x,r=n.y;if(isFinite(r)){var o=new ci(e,t).parallel(r);e=o.start,t=o.end}n=i}if(!isFinite(n))return t;var a=t.distance(e);return 0===n&&0<a?t:t.move(e,-Math.min(n,a-1))}function Cc(t){var e=t.getAttribute("stroke-width");return null===e?0:parseFloat(e)||0}function _c(t,e,n,i){var r=e.getNodeBBox(n);i.stroke&&r.inflate(Cc(n)/2);var o=t.intersect(r);return Lc(o?t.start.chooseClosest(o):t.end,t.start,i.offset)}var Nc="segmentSubdivisons",Oc="shapeBBox";var Rc={anchor:function(t,e,n,i){var r=i.offset,o=i.alignOffset,a=i.align;return a&&function(t,e,n){var i,r,o,a;void 0===n&&(n=0);var s=t.start,u=t.end;switch(e){case"left":i="x",r=u,o=s,a=-1;break;case"right":i="x",r=s,o=u,a=1;break;case"top":i="y",r=u,o=s,a=-1;break;case"bottom":i="y",r=s,o=u,a=1;break;default:return}s[i]<u[i]?r[i]=o[i]:o[i]=r[i],isFinite(n)&&(r[i]+=a*n,o[i]+=a*n)}(t,a,o),Lc(t.end,t.start,r)},bbox:_c,rectangle:function(t,e,n,i){var r=e.model.angle();if(0===r)return _c(t,e,n,i);var o=e.getNodeUnrotatedBBox(n);i.stroke&&o.inflate(Cc(n)/2);var a=o.center(),s=t.clone().rotate(a,r),u=s.setLength(1e6).intersect(o);return Lc(u?s.start.chooseClosest(u).rotate(a,-r):t.end,t.start,i.offset)},boundary:function(t,e,n,i){var r,o,a=i.selector,s=t.end;if(r="string"==typeof a?e.findNode(a):!1===a?n:Array.isArray(a)?Lu(n,a):function(t){if(!t)return null;var e=t;do{var n=e.tagName;if("string"!=typeof n)return null;if("G"===(n=n.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==n)break;e=e.nextElementSibling}}while(e);return e}(n),!su.isSVGGraphicsElement(r)){if(r===n||!su.isSVGGraphicsElement(n))return s;r=n}var u,l=e.getNodeShape(r),h=e.getNodeMatrix(r),c=e.getRootTranslateMatrix(),d=e.getRootRotateMatrix(),f=c.multiply(d).multiply(h),p=f.inverse(),g=su.transformLine(t,p),v=g.start.clone(),m=e.getNodeData(r);if(!1===i.insideout&&(m[Oc]||(m[Oc]=l.bbox()),m[Oc].containsPoint(v)))return s;if(l instanceof Ii){var y=i.precision||2;m[Nc]||(m[Nc]=l.getSegmentSubdivisions({precision:y})),u={precision:y,segmentSubdivisions:m[Nc]}}!0===i.extrapolate&&g.setLength(1e6),(o=g.intersect(l,u))?su.isArray(o)&&(o=v.chooseClosest(o)):!0===i.sticky&&(o=l instanceof Ei?l.pointNearestToPoint(v):l instanceof vi?l.intersectionWithLineFromCenterToPoint(v):l.closestPoint(v,u));var b=o?su.transformPoint(o,f):s,w=i.offset||0;return i.stroke&&(w+=Cc(r)/2),Lc(b,t.start,w)}};function Fc(t,e){if(0===e)return"0%";return Math.round(t/e*100*1e3)/1e3+"%"}function Bc(r){return function(t,e,n,i){return(e.isNodeConnection(n)?Ic:Vc)(r,t,e,n,i)}}function Vc(t,e,n,i,r){var o=n.model.angle(),a=n.getNodeUnrotatedBBox(i),s=n.model.getBBox().center();r.rotate(s,o);var u=r.x-a.x,l=r.y-a.y;return t&&(u=Fc(u,a.width),l=Fc(l,a.height)),e.anchor={name:"topLeft",args:{dx:u,dy:l,rotate:!0}},e}function Ic(t,e,n,i,r){var o=n.getConnection();if(!o)return e;var a=o.closestPointLength(r);if(t){var s=o.length();e.anchor={name:"connectionRatio",args:{ratio:a/s}}}else e.anchor={name:"connectionLength",args:{length:a}};return e}var Dc=il,jc=Bc(!1),zc=Bc(!0),Gc={useDefaults:Dc,pinAbsolute:jc,pinRelative:zc},Uc={N:"S",S:"N",E:"W",W:"E"},Hc={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function qc(t,e,n){var i=new si(t.x,e.y);return n.containsPoint(i)&&(i=new si(e.x,t.y)),i}function Wc(t,e){return t["W"===e||"E"===e?"width":"height"]}function Yc(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 Xc(t){return new Ei(t.x,t.y,0,0)}function $c(t){var e=Ju(t.padding||t.elementPadding||20);return{x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}function Zc(t,e){return t.sourceBBox.clone().moveAndExpand($c(e))}function Jc(t,e){return t.targetBBox.clone().moveAndExpand($c(e))}function Kc(t,e,n){var i=new si(t.x,e.y),r=new si(e.x,t.y),o=Yc(t,i),a=Yc(t,r),s=Uc[n],u=o===n||o!==s&&(a===s||a!==n)?i:r;return{points:[u],direction:Yc(u,e)}}function Qc(t,e,n){var i=qc(t,e,n);return{points:[i],direction:Yc(i,e)}}function td(e,t,n,i){var r,o={},a=[new si(e.x,t.y),new si(t.x,e.y)],s=a.filter(function(t){return!n.containsPoint(t)}),u=s.filter(function(t){return Yc(t,e)!==i});if(0<u.length)r=(r=u.filter(function(t){return Yc(e,t)===i}).pop())||u[0],o.points=[r],o.direction=Yc(r,t);else{r=Bs(a,s)[0];var l=new si(t).move(r,-Wc(n,i)/2),h=qc(l,e,n);o.points=[h,l],o.direction=Yc(l,t)}return o}function ed(t,e,n,i){var r=Qc(e,t,i),o=r.points[0];if(n.containsPoint(o)){var a=(r=Qc(t,e,n)).points[0];if(i.containsPoint(a)){var s=new si(t).move(a,-Wc(n,Yc(t,a))/2),u=new si(e).move(o,-Wc(i,Yc(e,o))/2),l=new ci(s,u).midpoint(),h=Qc(t,l,n),c=Kc(l,e,h.direction);r.points=[h.points[0],c.points[0]],r.direction=c.direction}}return r}function nd(t,e,n,i,r){var o,a,s,u={},l=n.union(i).inflate(1),h=l.center().distance(e)>l.center().distance(t),c=h?e:t,d=h?t:e;return a=qc(o=r?(o=si.fromPolar(l.width+l.height,Hc[r],c),l.pointNearestToPoint(o).move(o,-1)):l.pointNearestToPoint(c).move(c,1),d,l),o.round().equals(a.round())?(a=si.fromPolar(l.width+l.height,Gn(o.theta(c))+Math.PI/2,d),s=qc(o,a=l.pointNearestToPoint(a).move(d,1).round(),l),u.points=h?[a,s,o]:[o,s,a]):u.points=h?[a,o]:[o,a],u.direction=Yc(h?o:a,e),u}function id(t,e,n){var i,r,o,a,s,u=Zc(n,e),l=Jc(n,e),h=(r=e,(i=n).sourceAnchor?i.sourceAnchor:Zc(i,r).center()),c=(a=e,(o=n).targetAnchor?o.targetAnchor:Jc(o,a).center());u=u.union(Xc(h)),l=l.union(Xc(c)),(t=Cs(t).map(si)).unshift(h),t.push(c);for(var d=[],f=0,p=t.length-1;f<p;f++){var g=null,v=t[f],m=t[f+1],y=!!Yc(v,m);if(0===f)f+1===p?u.intersect(l.clone().inflate(1))?g=nd(v,m,u,l):y||(g=ed(v,m,u,l)):u.containsPoint(m)?g=nd(v,m,u,Xc(m).moveAndExpand($c(e))):y||(g=Qc(v,m,u));else if(f+1===p){var b=y&&Yc(m,v)===s;l.containsPoint(v)||b?g=nd(v,m,Xc(v).moveAndExpand($c(e)),l,s):y||(g=td(v,m,l,s))}else y||(g=Kc(v,m,s));s=g?(Array.prototype.push.apply(d,g.points),g.direction):Yc(v,m),f+1<p&&d.push(m)}return d}var rd={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(!Ms(id))throw new Error("Manhattan requires the orthogonal router as default fallback.");return id(t,fs({},rd,e),n)},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function od(t){this.map={},this.options=t,this.mapGridSize=100}function ad(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function sd(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function ud(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function ld(t,e){return t.sourceAnchor?t.sourceAnchor:sd(t,e).center()}function hd(t,e,n,i,r){var o,a,s,u,l,h,c,d,f,p,g=360/n,v=t.theta((o=t,a=e,s=i,u=r.step,l=a.x-o.x,h=a.y-o.y,c=l/s.x,d=h/s.y,f=c*u,p=d*u,new si(o.x+f,o.y+p))),m=Dn(v+g/2);return g*Math.floor(m/g)}function cd(t,e){var n=Math.abs(t-e);return 180<n?360-n:n}function dd(t,e){if(!t)return e;var n=Math.abs(t),i=Math.round(n/e);return i?e+(n-i*e)/i:n}function fd(t,e){return t.round(e)}function pd(t,e,n){return fd((i=t.clone(),o=(r=e).source,a=jn(i.x-o.x,r.x)+o.x,s=jn(i.y-o.y,r.y)+o.y,new si(a,s)),n);var i,r,o,a,s}function gd(t){return t.clone().toString()}function vd(t){return new si(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function md(t,e,n,i,r,o,a){for(var s,u=[],l=vd(r.difference(n)),h=gd(n),c=t[h];c;){var d=vd((s=e[h]).difference(c));d.equals(l)||(u.unshift(s),l=d),c=t[h=gd(c)]}var f=e[h];return vd(f.difference(i)).equals(l)||u.unshift(f),u}function yd(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 bd(d,f,t,p,e){var g=e.precision,v=e.directionMap,m=d.difference(f.center()),n=hs(v)?Object.keys(v):[],y=Cs(t),i=n.reduce(function(t,e){if(y.includes(e)){for(var n,i=v[e],r=new si(d.x+i.x*(Math.abs(m.x)+f.width),d.y+i.y*(Math.abs(m.y)+f.height)),o=new ci(d,r).intersect(f)||[],a=o.length,s=null,u=0;u<a;u++){var l=o[u],h=d.squaredDistance(l);(void 0===n||n<h)&&(n=h,s=l)}if(s){var c=pd(s,p,g);f.containsPoint(c)&&(c=pd(c.offset(i.x*p.x,i.y*p.y),p,g)),t.push(c)}}return t},[]);return f.containsPoint(d)||i.push(pd(d,p,g)),i}function wd(t,e,n,i){var r,o,a,s,u=i.precision;r=fd(t instanceof Ei?ld(this,i).clone():t.clone(),u),o=fd(e instanceof Ei?(a=this,s=i,a.targetAnchor?a.targetAnchor:ud(a,s).center()).clone():e.clone(),u);var l,h,c,d,f,p,g,v,m,y,b=(l=i.step,c=o,{source:(h=r).clone(),x:dd(c.x-h.x,l),y:dd(c.y-h.y,l)});if(p=t instanceof Ei?bd(d=r,t,i.startDirections,b,i):[d=r],g=e instanceof Ei?bd(f=o,e,i.endDirections,b,i):[f=o],p=p.filter(function(t){return!n(t)}),g=g.filter(function(t){return!n(t)}),0<p.length&&0<g.length){for(var w=new ad,x={},A={},T={},P=0,E=p.length;P<E;P++){var S=p[P],k=gd(S);w.add(k,yd(S,g)),x[k]=S,T[k]=0}var M,L,C=i.previousDirectionAngle,_=void 0===C,N=i.directions;v=b,y=(m=i).step,Cs(m.directions).forEach(function(t){t.gridOffsetX=t.offsetX/y*v.x,t.gridOffsetY=t.offsetY/y*v.y});for(var O=N.length,R=Cs(g).reduce(function(t,e){var n=gd(e);return t.push(n),t},[]),F=i.maximumLoops;!w.isEmpty()&&0<F;){var B,V=w.pop(),I=x[V],D=A[V],j=T[V],z=void 0===D,G=I.equals(d);B=z?_?G?null:hd(d,I,O,b,i):C:hd(D,I,O,b,i);var U=p.length===g.length;if(U)for(var H=0;H<p.length;H++)if(!p[H].equals(g[H])){U=!1;break}if(!(z&&U)&&0<=R.indexOf(V))return i.previousDirectionAngle=B,md(A,x,I,d,f);for(P=0;P<O;P++){var q=(M=N[P]).angle;if(L=cd(B,q),_&&G||!(L>i.maxAllowedDirectionChange)){var W=pd(I.clone().offset(M.gridOffsetX,M.gridOffsetY),b,u),Y=gd(W);if(!w.isClose(Y)&&!n(W)){if(0<=R.indexOf(Y))if(!W.equals(f))if(cd(q,hd(W,f,O,b,i))>i.maxAllowedDirectionChange)continue;var X=j+M.cost+(G?0:i.penalties[L]);(!w.isOpen(Y)||X<T[Y])&&(x[Y]=W,A[Y]=I,T[Y]=X,w.add(Y,X+yd(W,g)))}}}F--}}return i.fallbackRoute.call(this,d,f,i)}function xd(t,e,n){!function(t){if(t.directions=Ds(t,"directions"),t.penalties=Ds(t,"penalties"),t.paddingBox=Ds(t,"paddingBox"),t.padding=Ds(t,"padding"),t.padding){var e=Ju(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}Cs(t.directions).forEach(function(t){var e=new si(0,0),n=new si(t.offsetX,t.offsetY);t.angle=Dn(e.theta(n))})}(e),n.options.perpendicular=!!e.perpendicular;var i,r=sd(n,e),o=ud(n,e),a=ld(n,e);if("function"==typeof e.isPointObstacle)i=e.isPointObstacle;else{var s=new od(e);s.build(n.paper.model,n.model),i=function(t){return!s.isPointAccessible(t)}}for(var u,l,h=Cs(t).map(si),c=[],d=a,f=0,p=h.length;f<=p;f++){var g=null;if(l=u||r,!(u=h[f]))if(u=o,(!n.model.get("source").id||!n.model.get("target").id)&&Ms(e.draggingRoute)){var v=l===r?a:l,m=u.origin();g=e.draggingRoute.call(n,v,m,e)}if(null===(g=g||wd.call(n,l,u,i,e)))return e.fallbackRouter(t,e,n);var y=g[0];y&&y.equals(d)&&g.shift(),d=g[g.length-1]||d,Array.prototype.push.apply(c,g)}return c}od.prototype.build=function(r,o){var c=this.options,d=Cs(c.excludeEnds).reduce(function(t,e){var n=o.get(e);if(n){var i=r.getCell(n.id);i&&t.push(i)}return t},[]),f=[],t=r.getCell(o.get("source").id);t&&(f=Vs(f,t.getAncestors().map(function(t){return t.id})));var e=r.getCell(o.get("target").id);e&&(f=Vs(f,e.getAncestors().map(function(t){return t.id})));var p=this.mapGridSize;return r.getElements().reduce(function(t,e){var n=Cs(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),a=o.origin().snapToGrid(p),s=o.corner().snapToGrid(p),u=a.x;u<=s.x;u+=p)for(var l=a.y;l<=s.y;l+=p){var h=u+"@"+l;t[h]=t[h]||[],t[h].push(o)}return t},this.map),this},od.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return Cs(this.map[t]).every(function(t){return!t.containsPoint(e)})},ad.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;var n=As(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(n,0,t)},ad.prototype.remove=function(t){this.hash[t]=this.CLOSE},ad.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},ad.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},ad.prototype.isEmpty=function(){return 0===this.items.length},ad.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};var Ad=function(t,e,n){return xd(t,fs({},rd,e),n)},Td={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},a={x:t.x,y:e.y};if(90<i%180){var s=o;o=a,a=s}var u=i%90<45?o:a,l=new ci(t,u),h=90*Math.ceil(i/90),c=si.fromPolar(l.squaredLength(),Gn(h+135),u),d=new ci(e,c),f=l.intersection(d),p=f||e,g=f?p:t,v=360/n.directions.length,m=g.theta(e),y=Dn(m+v/2),b=v*Math.floor(y/v);return n.previousDirectionAngle=b,p&&r.push(p.round()),r.push(e),r}},Pd={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Ed=[Pd.LEFT,Pd.RIGHT,Pd.TOP,Pd.BOTTOM],Sd={};Sd[Pd.LEFT]=Pd.RIGHT,Sd[Pd.RIGHT]=Pd.LEFT,Sd[Pd.TOP]=Pd.BOTTOM,Sd[Pd.BOTTOM]=Pd.TOP;var kd=[Pd.TOP,Pd.BOTTOM],Md={0:Pd.RIGHT,180:Pd.LEFT,270:Pd.TOP,90:Pd.BOTTOM};function Ld(t){return t.angle()}function Cd(t){return new Ci(t).simplify({threshold:1}).points}function _d(t,e){var n,i,r=t.point,o=t.x0,a=t.y0,s=t.view,u=t.bbox,l=t.direction,h=e.point,c=e.x0,d=e.y0,f=e.view,p=e.bbox,g=e.direction;if(s)n=s.model.isLink()?Od(h,r,s):l===Pd.ANCHOR_SIDE?u.sideNearestToPoint(r):l===Pd.MAGNET_SIDE?s.model.getBBox().sideNearestToPoint(r):l;else{var v=new Ei(o,a,0,0);n=Ed.includes(l)?l:v.sideNearestToPoint(h)}if(f)i=f.model.isLink()?Od(r,h,f):g===Pd.ANCHOR_SIDE?p.sideNearestToPoint(h):g===Pd.MAGNET_SIDE?f.model.getBBox().sideNearestToPoint(h):g;else{var m=new Ei(c,d,0,0);i=Ed.includes(g)?g:m.sideNearestToPoint(r)}return[n,i]}function Nd(t,e,n){var i,r,o,a,s,u,l,h,c,d,f,p,g,v,m,y,b,w,x,A,T,P,E,S,k,M,L,C,_,N,O,R,F,B,V,I,D,j,z,G,U,H,q,W,Y,X,$,Z,J,K,Q,tt,et,nt,it,rt,ot,at,st,ut,lt,ht,ct,dt,ft,pt;switch(_d(t,e)[0]){case Pd.TOP:return tt=e,et=n,nt=(Q=t).x0,it=Q.y0,rt=Q.width,ot=Q.height,at=Q.point,st=Q.margin,ut=it+ot,lt=nt-st,ht=nt+rt+st,ct=it-st,dt=at.x,ft=tt.x0,pt=tt.y0,ft===dt&&pt<it?Pd.BOTTOM:ft<dt&&pt<ct?et.point.x===dt?Pd.BOTTOM:Pd.RIGHT:dt<ft&&pt<ct?et.point.x===dt?Pd.BOTTOM:Pd.LEFT:ft<lt&&it<=pt?Pd.TOP:ht<ft&&it<=pt?Pd.TOP:lt<=ft&&ft<=dt&&ut<pt?et.point.x<ft?Pd.RIGHT:Pd.LEFT:ft<=ht&&dt<=ft&&ut<pt?et.point.x<ft?Pd.RIGHT:Pd.LEFT:Pd.TOP;case Pd.RIGHT:return V=e,I=n,D=(B=t).y0,j=B.x0,z=B.width,G=B.height,U=B.point,H=B.margin,W=(q=j+z)+H,Y=D-H,X=D+G+H,$=U.x,Z=U.y,J=V.x0,K=V.y0,$<J&&K===Z?Pd.LEFT:W<=J&&K<Z?Pd.BOTTOM:W<=J&&Z<K?Pd.TOP:J<=q&&K<=Y?Pd.RIGHT:J<=q&&X<=K?Pd.RIGHT:J<j&&Y<=K&&K<=Z?I.point.y<K?Pd.BOTTOM:Pd.TOP:J<j&&K<=X&&Z<=K?I.point.y<K?Pd.BOTTOM:Pd.TOP:Pd.RIGHT;case Pd.BOTTOM:return x=e,A=n,T=(w=t).x0,P=w.y0,E=w.width,S=w.height,k=w.point,M=w.margin,C=T-M,_=T+E+M,N=(L=P+S)+M,O=k.x,R=x.x0,F=x.y0,R===O&&L<F?Pd.TOP:R<O&&N<F?A.point.x===O?Pd.TOP:Pd.RIGHT:O<R&&N<F?A.point.x===O?Pd.TOP:Pd.LEFT:R<C&&F<=L?Pd.BOTTOM:_<R&&F<=L?Pd.BOTTOM:C<=R&&R<=O&&F<P?A.point.x<R?Pd.RIGHT:Pd.LEFT:R<=_&&O<=R&&F<P?A.point.x<R?Pd.RIGHT:Pd.LEFT:Pd.BOTTOM;case Pd.LEFT:return r=e,o=n,a=(i=t).y0,s=i.x0,u=i.width,l=i.height,h=i.point,c=i.margin,d=s+u,f=s-c,p=a-c,g=a+l+c,v=h.x,m=h.y,y=r.x0,b=r.y0,y<v&&b===m?Pd.RIGHT:y<=f&&b<m?Pd.BOTTOM:y<=f&&m<b?Pd.TOP:s<=y&&b<=p?Pd.LEFT:s<=y&&g<=b?Pd.LEFT:d<y&&p<=b&&b<=m?o.point.y<b?Pd.BOTTOM:Pd.TOP:d<y&&b<=g&&m<=b?o.point.y<b?Pd.BOTTOM:Pd.TOP:Pd.LEFT}}function Od(t,e,n){var i=n.getTangentAtLength(n.getClosestPointLength(e)),r=90*Math.round(Ld(i)/90);if(r%180==0&&t.y===e.y)return t.x<e.x?Pd.LEFT:Pd.RIGHT;if(t.x===e.x)return t.y<e.y?Pd.TOP:Pd.BOTTOM;switch(r){case 0:case 180:case 360:return t.y<e.y?Pd.TOP:Pd.BOTTOM;case 90:case 270:return t.x<e.x?Pd.LEFT:Pd.RIGHT}}function Rd(t,e,n,i,r,o,a){i===Pd.AUTO&&(i=r?Pd.MAGNET_SIDE:Pd.ANCHOR_SIDE);var s=t&&t.model.isElement(),u=s?Ei.fromRectUnion(n,t.model.getBBox()):o,l=u.x,h=u.y,c=u.width;void 0===c&&(c=0);var d=u.height;return void 0===d&&(d=0),{point:e,x0:l,y0:h,view:t,bbox:n,width:c,height:d,direction:i,margin:s?a:0}}function Fd(t){var e=t.x,n=t.y,i=new si(e,n);return{point:i,x0:i.x,y0:i.y,view:null,bbox:new Ei(e,n,0,0),width:0,height:0,direction:null,margin:0}}function Bd(t,e,n){var i=e.point.clone(),r=e.x0,o=e.y0,a=e.width,s=e.height;switch(t){case"left":i.x=r-n;break;case"right":i.x=r+a+n;break;case"top":i.y=o-n;break;case"bottom":i.y=o+s+n}return i}function Vd(t,e,n){void 0===n&&(n={});var i=t.point,r=t.x0,o=t.y0,a=t.width,s=t.height,u=t.margin,l=e.point,h=e.x0,c=e.y0,d=e.width,f=e.height,p=e.margin,g=n.targetInSourceBBox;void 0===g&&(g=!1);var v=h+d,m=c+f,y=r+a,b=o+s,w=r-u,x=y+u,A=o-u,T=b+u,P=h-p,E=v+p,S=c-p,k=m+p,M=_d(t,e),L=M[0],C=M[1],_=Bd(L,{point:i,x0:r,y0:o,width:a,height:s},u),N=Bd(C,{point:l,x0:h,y0:c,width:d,height:f},p),O=_.x,R=_.y,F=N.x,B=N.y,V=((r+y)/2<(h+v)/2?y+h:v+r)/2,I=((o+b)/2<(c+m)/2?b+c:m+o)/2,D=new Ei(r,o,a,s),j=new Ei(h,c,d,f),z=D.clone().inflate(u),G=j.clone().inflate(p);if("left"===L&&"right"===C){if(w<=E){var U=I;return O<=P&&(A<=m&&B<R?U=Math.min(S,A):c<=T&&R<=B&&(U=Math.max(k,T))),[{x:O,y:R},{x:O,y:U},{x:F,y:U},{x:F,y:B}]}var H=(O+F)/2;return[{x:H,y:R},{x:H,y:B}]}if("right"===L&&"left"===C){if(P<=O){var q=I;return v<O&&(A<=m&&B<R?q=Math.min(S,A):c<=T&&R<=B&&(q=Math.max(k,T))),[{x:O,y:R},{x:O,y:q},{x:F,y:q},{x:F,y:B}]}var W=(O+F)/2;return[{x:W,y:R},{x:W,y:B}]}if("top"===L&&"bottom"===C){var Y=kr.rectWithRect(z,j);if(R<B){var X=V,$=R;return Y&&($=Math.min($,S)),w<=v&&F<O?X=Math.min(P,w):h<=x&&O<=F&&(X=Math.max(E,x)),[{x:O,y:$},{x:X,y:$},{x:X,y:B},{x:F,y:B}]}var Z=(R+B)/2;return[{x:O,y:Z},{x:F,y:Z}]}if("bottom"===L&&"top"===C){var J=kr.rectWithRect(z,j);if(B<R){var K=V,Q=R;return J&&(Q=Math.max(Q,k)),w<=v&&F<O?K=Math.min(P,w):h<=x&&O<=F&&(K=Math.max(E,x)),[{x:O,y:Q},{x:K,y:Q},{x:K,y:B},{x:F,y:B}]}var tt=(R+B)/2;return[{x:O,y:tt},{x:F,y:tt}]}if("top"===L&&"top"===C){var et;if(g||kr.rectWithRect(z,j)||R<=c&&(z.bottomRight().x<=F||z.bottomLeft().x>=F)||c<=R&&(G.bottomRight().x<=O||G.bottomLeft().x>=O))return[{x:O,y:Math.min(R,B)},{x:F,y:Math.min(R,B)}];var nt=Math.min((b+c)/2,B),it=Math.min((o+m)/2,R);return[{x:O,y:it},{x:et=B<R?O<F?Math.min(O,P):Math.max(O,E):O<=F?Math.max(F,x):Math.min(F,w),y:it},{x:et,y:nt},{x:F,y:nt}]}if("bottom"===L&&"bottom"===C){var rt;if(g||kr.rectWithRect(z,j)||B<=R&&(z.topRight().x<=F||z.topLeft().x>=F)||R<=B&&(G.topRight().x<=O||G.topLeft().x>=O))return[{x:O,y:Math.max(R,B)},{x:F,y:Math.max(R,B)}];var ot=Math.max((o+m)/2,B),at=Math.max((b+c)/2,R);return[{x:O,y:at},{x:rt=R<B?O<F?Math.min(O,P):Math.max(O,E):O<=F?Math.max(F,x):Math.min(F,w),y:at},{x:rt,y:ot},{x:F,y:ot}]}if("left"===L&&"left"===C){var st;if(g||kr.rectWithRect(z,j)||O<=F&&(z.bottomRight().y<=B||z.topRight().y>=B)||F<=O&&(G.bottomRight().y<=R||G.topRight().y>=R))return[{x:Math.min(O,F),y:R},{x:Math.min(O,F),y:B}];var ut=Math.min((y+h)/2,F),lt=Math.min((r+v)/2,O);return[{x:lt,y:R},{x:lt,y:st=O<F?B<=R?Math.min(A,B):Math.max(T,B):R<=B?Math.min(S,R):Math.max(k,R)},{x:ut,y:st},{x:ut,y:B}]}if("right"===L&&"right"===C){var ht;if(g||kr.rectWithRect(z,j)||F<=O&&(z.bottomLeft().y<=B||z.topLeft().y>=B)||O<=F&&(G.bottomLeft().y<=R||G.topLeft().y>=R))return[{x:Math.max(O,F),y:R},{x:Math.max(O,F),y:B}];var ct=Math.max((r+v)/2,F),dt=Math.max((y+h)/2,O);return[{x:dt,y:R},{x:dt,y:ht=F<=O?B<=R?Math.min(A,B):Math.max(T,B):R<=B?Math.min(S,R):Math.max(k,R)},{x:ct,y:ht},{x:ct,y:B}]}if("top"===L&&"right"===C){if(z.containsPoint(l)){if(O<=E){var ft=Math.max(O+u,F),pt=Math.min(A,S);return[{x:O,y:pt},{x:ft,y:pt},{x:ft,y:B}]}var gt=(O-u+F)/2;return[{x:O,y:R},{x:gt,y:R},{x:gt,y:B}]}if(B<A){if(O<F){var vt=S;return k<=A&&O<=E&&(vt=I),[{x:O,y:vt},{x:F,y:vt},{x:F,y:B}]}return[{x:O,y:B}]}var mt=Math.max(V,E);if(F<O&&B<=b)return[{x:O,y:R},{x:mt,y:R},{x:mt,y:B}];if(w<mt&&R<m){var yt=Math.min(A,S),bt=Math.max(x,E);return[{x:O,y:yt},{x:bt,y:yt},{x:bt,y:B}]}return[{x:O,y:R},{x:mt,y:R},{x:mt,y:B}]}if("top"===L&&"left"===C){if(z.containsPoint(l)){if(P<=O){var wt=Math.min(O-u,F),xt=Math.min(A,S);return[{x:O,y:xt},{x:wt,y:xt},{x:wt,y:B}]}var At=(O+u+F)/2;return[{x:O,y:R},{x:At,y:R},{x:At,y:B}]}if(B<A){if(F<O){var Tt=S;return k<=A&&P<=O&&(Tt=I),[{x:O,y:Tt},{x:F,y:Tt},{x:F,y:B}]}return[{x:O,y:B}]}var Pt=Math.min(P,V);if(O<F&&B<=b)return[{x:O,y:R},{x:Pt,y:R},{x:Pt,y:B}];if(Pt<x&&R<m){var Et=Math.min(A,S),St=Math.min(w,P);return[{x:O,y:Et},{x:St,y:Et},{x:St,y:B}]}return[{x:O,y:R},{x:Pt,y:R},{x:Pt,y:B}]}if("bottom"===L&&"right"===C){if(z.containsPoint(l)){if(O<=E){var kt=Math.max(O+u,F),Mt=Math.max(T,k);return[{x:O,y:Mt},{x:kt,y:Mt},{x:kt,y:B}]}var Lt=(O-u+F)/2;return[{x:O,y:R},{x:Lt,y:R},{x:Lt,y:B}]}if(T<B){if(O<F){var Ct=k;return T<=S&&O<=E&&(Ct=I),[{x:O,y:Ct},{x:F,y:Ct},{x:F,y:B}]}return[{x:O,y:B}]}var _t=Math.max(V,E);if(F<O&&o<=B)return[{x:O,y:R},{x:_t,y:R},{x:_t,y:B}];if(w<_t&&c<R){var Nt=Math.max(T,k),Ot=Math.max(x,E);return[{x:O,y:Nt},{x:Ot,y:Nt},{x:Ot,y:B}]}return[{x:O,y:R},{x:_t,y:R},{x:_t,y:B}]}if("bottom"===L&&"left"===C){if(z.containsPoint(l)){if(P<=O){var Rt=Math.min(O-u,F),Ft=Math.max(T,k);return[{x:O,y:Ft},{x:Rt,y:Ft},{x:Rt,y:B}]}var Bt=(O+u+F)/2;return[{x:O,y:R},{x:Bt,y:R},{x:Bt,y:B}]}if(T<B){if(F<O){var Vt=k;return T<=S&&P<=O&&(Vt=I),[{x:O,y:Vt},{x:F,y:Vt},{x:F,y:B}]}return[{x:O,y:B}]}var It=Math.min(P,V);if(O<F&&o<=B)return[{x:O,y:R},{x:It,y:R},{x:It,y:B}];if(It<x&&c<R){var Dt=Math.max(T,k),jt=Math.min(w,P);return[{x:O,y:Dt},{x:jt,y:Dt},{x:jt,y:B}]}return[{x:O,y:R},{x:It,y:R},{x:It,y:B}]}if("left"===L&&"bottom"===C){if(z.containsPoint(l)){if(R<=k){var zt=Math.min(w,P),Gt=Math.max(R+u,B);return[{x:zt,y:R},{x:zt,y:Gt},{x:F,y:Gt}]}var Ut=(R-u+B)/2;return[{x:O,y:R},{x:O,y:Ut},{x:F,y:Ut}]}if(F<w){if(R<B){var Ht=P;return E<=w&&R<=k&&(Ht=V),[{x:Ht,y:R},{x:Ht,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var qt=Math.max(k,I);if(B<R&&F<=y)return[{x:O,y:R},{x:O,y:qt},{x:F,y:qt}];if(A<qt&&O<v){var Wt=Math.min(w,P),Yt=Math.max(T,k);return[{x:Wt,y:R},{x:Wt,y:Yt},{x:F,y:Yt}]}return[{x:O,y:R},{x:O,y:qt},{x:F,y:qt}]}if("left"===L&&"top"===C){if(z.containsPoint(l)){if(S<=R){var Xt=Math.min(R-u,B),$t=Math.min(w,P);return[{x:$t,y:R},{x:$t,y:Xt},{x:F,y:Xt}]}var Zt=(R+u+B)/2;return[{x:O,y:R},{x:O,y:Zt},{x:F,y:Zt}]}if(F<w){if(B<R){var Jt=P;return E<=w&&S<=R&&(Jt=V),[{x:Jt,y:R},{x:Jt,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var Kt=Math.min(S,I);if(R<B&&F<=y)return[{x:O,y:R},{x:O,y:Kt},{x:F,y:Kt}];if(Kt<T&&O<v){var Qt=Math.min(w,P),te=Math.min(A,S);return[{x:Qt,y:R},{x:Qt,y:te},{x:F,y:te}]}return[{x:O,y:R},{x:O,y:Kt},{x:F,y:Kt}]}if("right"===L&&"top"===C){if(z.containsPoint(l)){if(S<=R){var ee=Math.max(x,E),ne=Math.min(R-u,B);return[{x:ee,y:R},{x:ee,y:ne},{x:F,y:ne}]}var ie=(R+u+B)/2;return[{x:O,y:R},{x:O,y:ie},{x:F,y:ie}]}if(x<F){if(B<R){var re=E;return x<=P&&S<=R&&(re=V),[{x:re,y:R},{x:re,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var oe=Math.min(S,I);if(R<B&&r<=F)return[{x:O,y:R},{x:O,y:oe},{x:F,y:oe}];if(oe<T&&h<O){var ae=Math.max(x,E),se=Math.min(A,S);return[{x:ae,y:R},{x:ae,y:se},{x:F,y:se}]}return[{x:O,y:R},{x:O,y:oe},{x:F,y:oe}]}if("right"===L&&"bottom"===C){if(z.containsPoint(l)){if(R<=k){var ue=Math.max(x,E),le=Math.max(R+u,B);return[{x:ue,y:R},{x:ue,y:le},{x:F,y:le}]}var he=(R-u+B)/2;return[{x:O,y:R},{x:O,y:he},{x:F,y:he}]}if(x<F){if(R<B){var ce=E;return x<=P&&R<=k&&(ce=V),[{x:ce,y:R},{x:ce,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var de=Math.max(k,I);if(B<R&&r<=F)return[{x:O,y:R},{x:O,y:de},{x:F,y:de}];if(A<de&&h<O){var fe=Math.max(x,E),pe=Math.max(T,k);return[{x:fe,y:R},{x:fe,y:pe},{x:F,y:pe}]}return[{x:O,y:R},{x:O,y:de},{x:F,y:de}]}}function Id(t,e,n){var i=e.sourceDirection;void 0===i&&(i=Pd.AUTO);var r=e.targetDirection;void 0===r&&(r=Pd.AUTO);var o=e.margin||20,a=e.useVertices||!1,s=!!n.model.source().port,u=Rd(n.sourceView,n.sourceAnchor,n.sourceBBox,i,s,n.sourceAnchor,o),l=!!n.model.target().port,h=Rd(n.targetView,n.targetAnchor,n.targetBBox,r,l,n.targetAnchor,o),c=[];if(!a||0===t.length)return Cd(Vd(u,h));var d=t.map(function(t){return Fd(t)}),f=d[0];if(u.view&&u.view.model.isElement()&&u.view.model.getBBox().inflate(o).containsPoint(f.point)){var p=_d(u,f)[0],g=p,v=Fd(u.point);v.margin=o,v.direction=p,f.direction=g,c.push.apply(c,Vd(v,f,{targetInSourceBBox:!0}).concat([f.point]))}else{var m=Nd(u,f,d[1]||h);f.direction=m,c.push.apply(c,Vd(u,f).concat([f.point]))}for(var y=0;y<d.length-1;y++){var b=d[y],w=d[y+1],x=Ld(new ci(b.point,w.point));if(x%90!=0){var A=Dd(b,w),T=A[0],P=A[1];b.direction=T,w.direction=P,c.push.apply(c,Vd(b,w).concat([w.point]))}else{var E=Md[x],S=Sd[E];if(E!==b.direction)c.push(b.point,w.point),w.direction=S;else{var k=Dn(x-90),M=0,L=0;90===k?L=-o:180===k?M=-o:270===k?L=o:0===k&&(M=o);var C={x:b.point.x+M,y:b.point.y+L},_={x:w.point.x+M,y:w.point.y+L},N=new ci(w.point,_);w.direction=Md[Ld(N)],c.push(b.point,C,_,w.point)}}}var O=d[d.length-1];if(h.view&&h.view.model.isElement())if(h.view.model.getBBox().inflate(o).containsPoint(O.point)){var R=Dd(O,h)[0],F=Fd(h.point),B=_d(O,h)[1];F.margin=o,F.direction=B,O.direction=R,c.push.apply(c,Vd(O,F))}else{var V=Cd(c),I=new ci(V[V.length-2],O.point),D=Md[Math.round(Ld(I))];O.direction=D;var j=Vd(O,h),z=Cd(j.concat([h.point])),G=z[0],U=z[1],H=new ci(G,U),q=Math.round(Ld(H)),W=Md[q];W!==D&&D===Sd[W]&&(O.margin=o,j=Vd(O,h)),c.push.apply(c,j)}else{var Y=Dd(O,h)[0];O.direction=Y,c.push.apply(c,Vd(O,h))}return Cd(c)}function Dd(t,e){var n=t.direction,i=kd.includes(n),r=t.direction,o=e.direction;if(i){var a=t.point.y>e.point.y,s=e.point.x-t.point.x;n===Pd.BOTTOM?(r=a?Sd[n]:0<=s?Pd.RIGHT:Pd.LEFT,0<s?o=a?Pd.LEFT:Pd.TOP:s<0&&(o=a?Pd.RIGHT:Pd.TOP)):(r=a?0<=s?Pd.RIGHT:Pd.LEFT:Sd[n],0<s?o=a?Pd.BOTTOM:Pd.LEFT:s<0&&(o=a?Pd.BOTTOM:Pd.RIGHT))}else{var u=t.point.x>e.point.x,l=e.point.y-t.point.y;n===Pd.RIGHT?(r=u?Sd[n]:0<=l?Pd.BOTTOM:Pd.TOP,0<l?o=u?Pd.TOP:Pd.LEFT:l<0&&(o=u?Pd.BOTTOM:Pd.LEFT)):(r=u?0<=l?Pd.BOTTOM:Pd.TOP:Sd[n],0<l?o=u?Pd.RIGHT:Pd.TOP:l<0&&(o=u?Pd.RIGHT:Pd.BOTTOM))}return[r,o]}Id.Directions=Pd;var jd={normal:function(t,e,n){return t},oneSide:function(t,e,n){var i,r,o,a=e.side||"bottom",s=Ju(e.padding||40),u=n.sourceBBox,l=n.targetBBox,h=u.center(),c=l.center();switch(a){case"bottom":o=1,i="y",r="height";break;case"top":o=-1,i="y",r="height";break;case"left":o=-1,i="x",r="width";break;case"right":o=1,i="x",r="width";break;default:throw new Error("Router: invalid side")}return h[i]+=o*(u[r]/2+s[a]),c[i]+=o*(l[r]/2+s[a]),0<o*(h[i]-c[i])?c[i]=h[i]:h[i]=c[i],[h].concat(t,c)},orthogonal:id,manhattan:Ad,metro:function(t,e,n){if(!Ms(Ad))throw new Error("Metro requires the manhattan router.");return Ad(t,fs({},Td,e),n)},rightAngle:Id};function zd(a){return function(t,e,n,i){if(n instanceof Element){var r,o=this.paper.findView(n);if(o)if(o.isNodeConnection(n))r=Gd(o,"fixedAt"in i?i.fixedAt:"50%");else r=o.getNodeBBox(n).center();else r=new si;return a.call(this,t,e,r,i)}return a.apply(this,arguments)}}function Gd(t,e){var n=parseFloat(e);return zu(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}var Ud=zd(function(t,e,n,i){var r=t.getConnection(),o=t.getConnectionSubdivisions(),a=new ci(n.clone().offset(0,1e6),n.clone().offset(0,-1e6)),s=new ci(n.clone().offset(1e6,0),n.clone().offset(-1e6,0)),u=a.intersect(r,{segmentSubdivisions:o}),l=s.intersect(r,{segmentSubdivisions:o}),h=[];return u&&Array.prototype.push.apply(h,u),l&&Array.prototype.push.apply(h,l),0<h.length?n.chooseClosest(h):"fallbackAt"in i?Gd(t,i.fallbackAt):Hd(t,e,n,i)}),Hd=zd(function(t,e,n,i){var r=t.getClosestPoint(n);return r||new si}),qd={resolveRef:zd,connectionRatio:function(t,e,n,i){var r="ratio"in i?i.ratio:.5;return t.getPointAtRatio(r)},connectionLength:function(t,e,n,i){var r="length"in i?i.length:20;return t.getPointAtLength(r)},connectionPerpendicular:Ud,connectionClosest:Hd};function Wd(c){return function(t,e,n,i){var r=!!i.rotate,o=r?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),a=o[c](),s=i.dx;if(s){var u=zu(s);s=parseFloat(s),isFinite(s)&&(u&&(s/=100,s*=o.width),a.x+=s)}var l=i.dy;if(l){var h=zu(l);l=parseFloat(l),isFinite(l)&&(h&&(l/=100,l*=o.height),a.y+=l)}return r?a.rotate(t.model.getBBox().center(),-t.model.angle()):a}}var Yd={center:Wd("center"),top:Wd("topMiddle"),bottom:Wd("bottomMiddle"),left:Wd("leftMiddle"),right:Wd("rightMiddle"),topLeft:Wd("origin"),topRight:Wd("topRight"),bottomLeft:Wd("bottomLeft"),bottomRight:Wd("corner"),perpendicular:zd(function(t,e,n,i){var r=t.model.angle(),o=t.getNodeBBox(e),a=o.center(),s=o.origin(),u=o.corner(),l=i.padding;if(isFinite(l)||(l=0),s.y+l<=n.y&&n.y<=u.y-l){var h=n.y-a.y;a.x+=0===r||180===r?0:1*h/Math.tan(Gn(r)),a.y+=h}else if(s.x+l<=n.x&&n.x<=u.x-l){var c=n.x-a.x;a.y+=90===r||270===r?0:c*Math.tan(Gn(r)),a.x+=c}return a}),midSide:zd(function(t,e,n,i){var r,o,a,s=!!i.rotate;s?(r=t.getNodeUnrotatedBBox(e),a=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e);var u,l=i.padding;switch(isFinite(l)&&r.inflate(l),s&&n.rotate(a,o),r.sideNearestToPoint(n)){case"left":u=r.leftMiddle();break;case"right":u=r.rightMiddle();break;case"top":u=r.topMiddle();break;case"bottom":u=r.bottomMiddle()}return s?u.rotate(a,-o):u}),modelCenter:function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)}},Xd=ac.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace=void 0!==joint&&Is(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var n=e.collection,i=n.cellNamespace,r=t.type,o=Lu(i,r,".");if(!o)throw new Error("dia.Graph: Could not find cell constructor for type: '"+r+"'. Make sure to add the constructor to 'cellNamespace'.");var a=new o(t,e);return e.dry||(a.graph=n.graph),a},comparator:function(t){return t.get("z")||0}}),$d=bl.extend({initialize:function(t,e){var n=new Xd([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});bl.prototype.set.call(this,"cells",n),n.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},n.on("add",this._restructureOnAdd,this),n.on("remove",this._restructureOnRemove,this),n.on("reset",this._restructureOnReset,this),n.on("change:source",this._restructureOnChangeSource,this),n.on("change:target",this._restructureOnChangeTarget,this),n.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){if(t.isLink()){this._edges[t.id]=!0;var e=t.attributes,n=e.source,i=e.target;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0),i.id&&((this._in[i.id]||(this._in[i.id]={}))[t.id]=!0)}else this._nodes[t.id]=!0},_restructureOnRemove:function(t){if(t.isLink()){delete this._edges[t.id];var e=t.attributes,n=e.source,i=e.target;n.id&&this._out[n.id]&&this._out[n.id][t.id]&&delete this._out[n.id][t.id],i.id&&this._in[i.id]&&this._in[i.id][t.id]&&delete this._in[i.id][t.id]}else delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source");e.id&&this._out[e.id]&&delete this._out[e.id][t.id];var n=t.attributes.source;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target");e.id&&this._in[e.id]&&delete this._in[e.id][t.id];var n=t.get("target");n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=bl.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(!t.cells)throw new Error("Graph JSON must contain cells array.");return this.set(t,e)},set:function(t,e,n){var i;return"object"==typeof t?(i=t,n=e):(i={})[t]=e,i.hasOwnProperty("cells")&&(this.resetCells(i.cells,n),i=js(i,"cells")),bl.prototype.set.call(this,i,n)},clear:function(t){t=fs({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);for(var n=e.sortBy(function(t){return t.isLink()?1:2});n.shift().remove(t),0<n.length;);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var n;if(t instanceof bl?(n=t.attributes,t.graph||e&&e.dry||(t.graph=this)):n=t,!ds(n.type))throw new TypeError("dia.Graph: cell type must be a string.");return t},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof bl?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=Rs(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach(function(t){this.addCell(t,e),e.position--},this),this.stopBatch("add",e)),this},resetCells:function(t,e){var n=Cs(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(n,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),ws(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,n){(n=n||{}).clear||(n.disconnectLinks?this.disconnectLinks(t,n):this.removeLinks(t,n)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").toArray().filter(function(t){return t.isElement()})},getLinks:function(){return this.get("cells").toArray().filter(function(t){return t.isLink()})},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,s){var r=(s=s||{}).indirect,o=s.inbound,a=s.outbound;void 0===o&&void 0===a&&(o=a=!0);var u=[],l={};function h(i,t){if(Gs(i.getOutboundEdges(t.id),function(t,e){if(!l[e]){var n=i.getCell(e);u.push(n),l[e]=!0,r&&(o&&c(i,n),a&&h(i,n))}}.bind(i)),r&&t.isLink()){var e=t.getTargetCell();e&&e.isLink()&&(l[e.id]||(u.push(e),h(i,e)))}}function c(i,t){if(Gs(i.getInboundEdges(t.id),function(t,e){if(!l[e]){var n=i.getCell(e);u.push(n),l[e]=!0,r&&(o&&c(i,n),a&&h(i,n))}}.bind(i)),r&&t.isLink()){var e=t.getSourceCell();e&&e.isLink()&&(l[e.id]||(u.push(e),c(i,e)))}}if(a&&h(this,t),o&&c(this,t),s.deep){var e=t.getEmbeddedCells({deep:!0}),d={};e.forEach(function(t){t.isElement()&&(d[t.id]=!0)}),e.forEach(function(t){t.isLink()||(a&&Gs(this.getOutboundEdges(t.id),function(t,e){if(!l[e]){var n=this.getCell(e).attributes,i=n.source,r=n.target,o=i.id,a=r.id;if(!s.includeEnclosed&&o&&d[o]&&a&&d[a])return;u.push(this.getCell(e)),l[e]=!0}}.bind(this)),o&&Gs(this.getInboundEdges(t.id),function(t,e){if(!l[e]){var n=this.getCell(e).attributes,i=n.source,r=n.target,o=i.id,a=r.id;if(!s.includeEnclosed&&o&&d[o]&&a&&d[a])return;u.push(this.getCell(e)),l[e]=!0}}.bind(this)))},this)}return u},getNeighbors:function(u,l){l||(l={});var h=l.inbound,c=l.outbound;void 0===h&&void 0===c&&(h=c=!0);var t=this.getConnectedLinks(u,l).reduce(function(t,e){var n=e.attributes,i=n.source,r=n.target,o=e.hasLoop(l);if(h&&Is(i,"id")&&!t[i.id]){var a=this.getCell(i.id);a.isElement()&&(!o&&(!a||a===u||l.deep&&a.isEmbeddedIn(u))||(t[i.id]=a))}if(c&&Is(r,"id")&&!t[r.id]){var s=this.getCell(r.id);s.isElement()&&(!o&&(!s||s===u||l.deep&&s.isEmbeddedIn(u))||(t[r.id]=s))}return t}.bind(this),{});if(u.isLink()){if(h){var e=u.getSourceCell();e&&e.isElement()&&!t[e.id]&&(t[e.id]=e)}if(c){var n=u.getTargetCell();n&&n.isElement()&&!t[n.id]&&(t[n.id]=n)}}return Cs(t)},getCommonAncestor:function(){var t=Array.from(arguments).map(function(t){for(var e=[],n=t.get("parent");n;)e.push(n),n=this.getCell(n).get("parent");return e},this);t=t.sort(function(t,e){return t.length-e.length});var e=Cs(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)},fs({},t,{outbound:!0})),n},cloneCells:wl,cloneSubgraph:function(t,e){var n=this.getSubgraph(t,e);return this.cloneCells(n)},getSubgraph:function(t,e){e=e||{};var a=[],s={},u=[],n=[];return Cs(t).forEach(function(t){(s[t.id]||(a.push(t),(s[t.id]=t).isLink()?n.push(t):u.push(t)),e.deep)&&t.getEmbeddedCells({deep:!0}).forEach(function(t){s[t.id]||(a.push(t),(s[t.id]=t).isLink()?n.push(t):u.push(t))})}),n.forEach(function(t){var e=t.attributes,n=e.source,i=e.target;if(n.id&&!s[n.id]){var r=this.getCell(n.id);a.push(r),s[r.id]=r,u.push(r)}if(i.id&&!s[i.id]){var o=this.getCell(i.id);a.push(this.getCell(i.id)),s[o.id]=o,u.push(o)}},this),u.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var e=t.attributes,n=e.source,i=e.target;!s[t.id]&&n.id&&s[n.id]&&i.id&&s[i.id]&&(a.push(t),s[t.id]=t)})},this),a},getPredecessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},fs({},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){void 0===n&&(n={});var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var a=o.shift();if(!i[a.id]&&!(i[a.id]=!0)!==e.call(this,a,r[a.id]))for(var s=this.getNeighbors(a,n),u=0,l=s.length;u<l;u++){var h=s[u];r[h.id]=r[a.id]+1,o.push(h)}}},dfs:function(t,e,n){void 0===n&&(n={});var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var a=o.pop();if(!i[a.id]&&!(i[a.id]=!0)!==e.call(this,a,r[a.id]))for(var s=this.getNeighbors(a,n),u=o.length,l=0,h=s.length;l<h;l++){var c=s[l];r[c.id]=r[a.id]+1,o.splice(u,0,c)}}},getSources:function(){var n=[];return Gs(this._nodes,function(t,e){this._in[e]&&!Ss(this._in[e])||n.push(this.getCell(e))}.bind(this)),n},getSinks:function(){var n=[];return Gs(this._nodes,function(t,e){this._out[e]&&!Ss(this._out[e])||n.push(this.getCell(e))}.bind(this)),n},isSource:function(t){return!this._in[t.id]||Ss(this._in[t.id])},isSink:function(t){return!this._out[t.id]||Ss(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,r,e){var o=(e=e||{}).inbound,a=e.outbound;void 0===o&&void 0===a&&(o=a=!0);var s=!1;return this.getConnectedLinks(t,e).forEach(function(t){var e=t.attributes,n=e.source,i=e.target;return o&&Is(n,"id")&&n.id===r.id?!(s=!0):a&&Is(i,"id")&&i.id===r.id?!(s=!0):void 0}),s},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){ws(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(e){return this.getElements().filter(function(t){return t.getBBox({rotate:!0}).containsPoint(e)})},findModelsInArea:function(t,e){void 0===e&&(e={});var n=new Ei(t),i=e.strict;void 0===i&&(i=!1);var r=i?"containsRect":"intersect";return this.getElements().filter(function(t){return n[r](t.getBBox({rotate:!0}))})},findModelsUnderElement:function(e,t){void 0===t&&(t={});var n=t.searchBy;void 0===n&&(n="bbox");var i=e.getBBox().rotateAroundCenter(e.angle());return("bbox"===n?this.findModelsInArea(i):this.findModelsFromPoint(Zl(i,n))).filter(function(t){return e.id!==t.id&&!t.isEmbeddedIn(e)})},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e){void 0===e&&(e={});var i=e.rotate;return void 0===i&&(i=!0),Cs(t).reduce(function(t,e){var n=e.getBBox({rotate:i});return n?t?t.union(n):n:t},null)},translate:function(t,e,n){var i=this.getCells().filter(function(t){return!t.isEmbedded()});return ws(i,"translate",t,e,n),this},resize:function(t,e,n){return this.resizeCells(t,e,this.getCells(),n)},resizeCells:function(t,e,n,i){var r=this.getCellsBBox(n);if(r){var o=Math.max(t/r.width,0),a=Math.max(e/r.height,0);ws(n,"scale",o,a,r.origin(),i)}return this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",fs({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",fs({},e,{batchName:t}))},hasActiveBatch:function(t){var e=this._batches;return(0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t]).some(function(t){return 0<e[t]})}},{validations:{multiLinks:function(t,e){var n=e.attributes,r=n.source,o=n.target;if(r.id&&o.id){var i=e.getSourceCell();if(i)if(1<t.getConnectedLinks(i,{outbound:!0}).filter(function(t){var e=t.attributes,n=e.source,i=e.target;return n&&n.id===r.id&&(!n.port||n.port===r.port)&&i&&i.id===o.id&&(!i.port||i.port===o.port)}).length)return!1}return!0},linkPinning:function(t,e){var n=e.attributes,i=n.source,r=n.target;return i.id&&r.id}}});Yl($d.prototype,["resetCells","addCells","removeCells"],Xl.cells);var Zd={GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"},Jd=rc.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return Su(this.options.name+"-layer")},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(t){var e=this.el,n=this.pivotNodes;(t=+t)||(t=0);var i=n[t];if(i)return i;i=n[t]=document.createComment("z-index:"+(t+1));var r=-1/0;for(var o in n)(o=+o)<t&&r<o&&(r=o);if(r!==-1/0){var a=n[r];e.insertBefore(i,a.nextSibling)}else e.insertBefore(i,e.firstChild);return i},removePivots:function(){var t=this.el,e=this.pivotNodes;for(var n in e)t.removeChild(e[n]);this.pivotNodes={}}}),Kd=["transform","x","y","cx","cy","dx","dy","x1","y1","x2","y2","points","d","r","rx","ry","width","height","stroke-width","font-size"].reduce(function(t,e){return t[e]=!0,t},{}),Qd=["r","rx","ry","width","height","stroke-width","font-size"].reduce(function(t,e){return t[e]=!0,t},{});function tf(t,e){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=ef(i,t[i],e));return n}function ef(t,e,n){if(t in Kd&&Nn(e)){var i=Fn(e,n);return t in Qd&&(i=Math.max(0,i)),i}return e}var nf={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},rf=rc.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={},r={},o=0,a=Ds(this,"presentationAttributes");for(var s in a)if(a.hasOwnProperty(s)){var u=a[s];for(Array.isArray(u)||(u=[u]),t=0,e=u.length;t<e;t++){var l=i[n=u[t]];l||(l=i[n]=1<<o++),r[s]|=l}}var h=Ds(this,"initFlag");for(Array.isArray(h)||(h=[h]),t=0,e=h.length;t<e;t++)i[n=h[t]]||(i[n]=1<<o++);if(25<o)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=i,this._presentationAttributes=r},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var n=0;if(Array.isArray(t))for(var i=0,r=t.length;i<r;i++)n|=e[t[i]];else n|=e[t];return n},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||Fu(this),rc.call(this,t)},initialize:function(){this.setFlags(),rc.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){var n=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&n&&(e.dirty&&this.hasFlag(n,"UPDATE")&&(n|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(n,e))},requestUpdate:function(t,e){var n=this.paper;n&&0<t&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n=ku(t),i=n.selectors,r=n.groupSelectors;for(var o in r){if(i[o])throw new Error("dia.CellView: ambiguous group selector");i[o]=r[o]}if(e){var a=this.selector;if(i[a])throw new Error("dia.CellView: ambiguous root selector.");i[a]=e}return{fragment:n.fragment,selectors:i}},can:function(t){var e=Ms(this.options.interactive)?this.options.interactive(this):this.options.interactive;return hs(e)&&!1!==e[t]||ls(e)&&!1!==e},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){var i=n[t];if(i)return Array.isArray(i)?i:[i]}return this.useCSSSelectors?iu(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){var e=this.findNodes(t)[0];return void 0===e&&(e=null),e},notify:function(t){if(this.paper){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e))}},getBBox:function(t){var e;if(t&&t.useModelGeometry){var n=this.model;e=n.getBBox().bbox(n.angle())}else e=this.getNodeBBox(this.el);return this.paper.localToPaperRect(e)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),i=this.getNodeMatrix(t);return su.transformRect(e,n.multiply(i))},getNodeRotateMatrix:function(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():su.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return su.transformRect(e,i.multiply(n))},getRootTranslateMatrix:function(){var t=this.model.position();return su.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t=su.createSVGMatrix(),e=this.model,n=e.angle();if(n){var i=e.getBBox(),r=i.width/2,o=i.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t},_notifyHighlight:function(t,e,n){void 0===n&&(n={});var i,r=this.el;if(i="string"==typeof e?this.findNode(e)||r:void 0===(i=this.$(e)[0])?r:i,n.partial=i!==r,void 0===n.type){var o;switch(!0){case n.embedding:o=nf.EMBEDDING;break;case n.connecting:o=nf.CONNECTING;break;case n.magnetAvailability:o=nf.MAGNET_AVAILABILITY;break;case n.elementAvailability:o=nf.ELEMENT_AVAILABILITY;break;default:o=nf.DEFAULT}n.type=o}return this.notify(t,i,n),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e){return void 0===e&&(e={}),this._notifyHighlight("cell:unhighlight",t,e)},findMagnet:function(t){var e=this.el,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;n=n.parentNode}while(n)},findProxyNode:function(t,e){t||(t=this.el);var n=t.getAttribute(e+"-selector");if(n){var i=this.findNode(n);if(i)return i}return t},getSelector:function(t,e){var n;if(t===this.el)return"string"==typeof e&&(n=":scope > "+e),n;if(t){var i=su(t).index()+1;n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)}return n},addLinkFromMagnet:function(t,e,n){var i=this.paper,r=i.model,o=i.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,n,o,"source"),target:{x:e,y:n}}).addTo(r,{async:!1,ui:!0}),o.findView(i)},getLinkEnd:function(t){for(var e,n=[],i=arguments.length-1;0<i--;)n[i]=arguments[i+1];var r=this.model,o=r.id,a=this.findAttribute("port",t),s=t.getAttribute("joint-selector"),u={id:o};return null!=s&&(u.magnet=s),null!=a?(u.port=a,r.hasPort(a)||s||(u.selector=this.getSelector(t))):null==s&&this.el!==t&&(u.selector=this.getSelector(t)),(e=this).customizeLinkEnd.apply(e,[u,t].concat(n))},customizeLinkEnd:function(t,e,n,i,r,o){var a=this.paper,s=a.options.connectionStrategy;if("function"==typeof s){var u=s.call(a,t,this,e,new si(n,i),r,o,a);if(u)return u}return t},getMagnetFromLinkEnd:function(t){var e,n=t.port,i=t.magnet,r=this.model;return e=null!=n&&r.isElement()&&r.hasPort(n)?this.findPortNode(n,i)||this.el:(i||(i=t.selector),i||null==n||(i='[port="'+n+'"]'),this.findNode(i)),this.findProxyNode(e,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");var r=this.addLinkFromMagnet(e,n,i);r.notifyPointerdown(t,n,i),r.eventData(t,r.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:r})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var o=this.paper,a=o.options.magnetThreshold,s=this.getEventTarget(t),u=i.targetMagnet;if("onleave"===a){if(u===s||su(u).contains(s))return}else if(o.eventData(t).mousemoved<=a)return;this.dragLinkStart(t,u,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){Ss(e)||(t instanceof SVGElement?su(t).attr(e):iu(t).attr(e))},processNodeAttributes:function(t,e){var n,i,r,o,a,s,u,l,h,c=[],d={};for(n in e)e.hasOwnProperty(n)&&(d[su.attributeNames[n]]=e[n]);for(n in d)d.hasOwnProperty(n)&&(i=d[n],!(r=this.getAttributeDefinition(n))||Ms(r.qualify)&&!r.qualify.call(this,i,t,d,this)?(s||(s={}),s[n]=i):(ds(r.set)&&(s||(s={}),s[r.set]=i),null!==i&&c.push(n,r)));for(o=0,a=c.length;o<a;o+=2)n=c[o],r=c[o+1],i=e[n],Ms(r.set)&&(u||(u={}),u[n]=i),Ms(r.position)&&(l||(l={}),l[n]=i),Ms(r.offset)&&(h||(h={}),h[n]=i);return{raw:d,normal:s,set:u,position:l,offset:h}},updateRelativeAttributes:function(t,e,n,i){var r,o;i||(i={});var a=tf(e.raw||{},n),s=e.normal||{};for(var u in s)s[u]=a[u];var l=e.set,h=e.position,c=e.offset;for(r in l){o=a[r];var d=this.getAttributeDefinition(r).set.call(this,o,n.clone(),t,a,this);hs(d)?fs(s,d):void 0!==d&&(s[r]=d)}if(t instanceof HTMLElement)this.setNodeAttributes(t,s);else{var f,p,g,v=s.transform,m=su.transformStringToMatrix(v),y=si(m.e,m.f);if(v&&(s=js(s,"transform"),m.e=m.f=0),h||c){var b=this.getNodeScale(t,i.scalableNode);f=b.sx,p=b.sy}var w=!1;for(r in h)o=a[r],(g=this.getAttributeDefinition(r).position.call(this,o,n.clone(),t,a,this))&&(y.offset(si(g).scale(f,p)),w||(w=!0));this.setNodeAttributes(t,s);var x=!1;if(c){var A=this.getNodeBoundingRect(t);if(0<A.width&&0<A.height){var T=su.transformRect(A,m).scale(1/f,1/p);for(r in c)o=a[r],(g=this.getAttributeDefinition(r).offset.call(this,o,T,t,a,this))&&(y.offset(si(g).scale(f,p)),x||(x=!0))}}(void 0!==v||w||x)&&(y.round(1),m.e=y.x,m.f=y.y,t.setAttribute("transform",su.matrixToTransformString(m)))}},getNodeScale:function(t,e){var n,i;if(e&&e.contains(t)){var r=e.scale();n=1/r.sx,i=1/r.sy}else i=n=1;return{sx:n,sy:i}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};var n=su.ensureId(t),i=e[n];return i||(i=e[n]={}),i},getNodeData:function(t){var e=this.nodeCache(t);return e.data||(e.data={}),e.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=su(t).getBBox()),new Ei(e.boundingRect)},getNodeMatrix:function(t){var e=this.nodeCache(t);if(void 0===e.magnetMatrix){var n,i=this.rotatableNode,r=this.el;n=i&&i.contains(t)?i:r,e.magnetMatrix=su(t).getTransformToElement(n)}return su.createSVGMatrix(e.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=su(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,a,s,u={},l=[];for(var h in t)if(t.hasOwnProperty(h)&&(a=t[h],Ls(a))){var c=n[h]=this.findBySelector(h,e,i);for(r=0,o=c.length;r<o;r++){var d=c[r];s=su.ensureId(d);var f=i&&i[h]===d,p=u[s];if(p){p.array||(l.push(s),p.array=!0,p.attributes=[p.attributes],p.selectedLength=[p.selectedLength]);var g=p.attributes,v=p.selectedLength;if(f)g.unshift(a),v.unshift(-1);else{var m=As(v,o);g.splice(m,0,a),v.splice(m,0,o)}}else u[s]={attributes:a,selectedLength:f?-1:o,node:d,array:!1}}}for(r=0,o=l.length;r<o;r++)(a=u[s=l[r]]).attributes=Ws.apply(void 0,[{}].concat(a.attributes.reverse()));return u},getEventTarget:function(t,e){void 0===e&&(e={});var n=t.target,i=t.type,r=t.clientX;void 0===r&&(r=0);var o=t.clientY;return void 0===o&&(o=0),e.fromPoint||"touchmove"===i||"touchend"===i||"pointerId"in t&&n.hasPointerCapture(t.pointerId)?document.elementFromPoint(r,o):n},updateDOMSubtreeAttributes:function(t,e,n){n||(n={}),n.rootBBox||(n.rootBBox=Ei()),n.selectors||(n.selectors=this.selectors);var i,r,o,a,s,u={},l={},h=[],c=[],d=n.roAttributes,f=this.findNodesAttributes(d||e,t,u,n.selectors),p=d?this.findNodesAttributes(e,t,u,n.selectors):f;for(var g in f)if(o=(a=f[g]).attributes,r=a.node,(s=this.processNodeAttributes(r,o)).set||s.position||s.offset||s.raw.ref){var v,m=p[g]&&p[g].attributes,y=m&&void 0===o.ref?m.ref:o.ref;if(y){if(!(v=(u[y]||this.findBySelector(y,t,n.selectors))[0]))throw new Error('dia.CellView: "'+y+'" reference does not exist.')}else v=null;if(i={node:r,refNode:v,processedAttributes:s,allAttributes:m},v){var b=c.findIndex(function(t){return t.refNode===r});-1<b?c.splice(b,0,i):c.push(i)}else h.push(i)}else this.setNodeAttributes(r,tf(s.normal,n.rootBBox));h.push.apply(h,c);for(var w=0,x=h.length;w<x;w++){i=h[w],r=i.node;var A=(v=i.refNode)?su.ensureId(v):"",T=l[A];T||(T=l[A]=v?su(v).getBBox({target:of(r,v)}):n.rootBBox),d?(s=this.processNodeAttributes(r,i.allAttributes),this.mergeProcessedAttributes(s,i.processedAttributes)):s=i.processedAttributes,this.updateRelativeAttributes(r,s,T,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),fs(t.set,e.set),fs(t.position,e.position),fs(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:function(t){t||(this.mountTools(),xc.mount(this))},onDetach:function(){this.unmountTools(),xc.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:function(){var t=this._toolsView;return t&&t.unmount(),this},mountTools:function(){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(){xc.remove(this)},updateHighlighters:function(t){void 0===t&&(t=!1),xc.update(this,null,t)},transformHighlighters:function(){xc.transform(this)},preventDefaultInteraction:function(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented:function(t){var e=this.eventData(t).defaultInteractionPrevented;return void 0===e&&(e=!1),e},pointerdblclick:function(t,e,n){this.notify("cell:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){this.notify("cell:pointerclick",t,e,n)},contextmenu:function(t,e,n){this.notify("cell:contextmenu",t,e,n)},pointerdown:function(t,e,n){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:function(t){var e=this.paper,n=this.model;if(e.isAsync()){if(n.isLink()){var i=n.getSourceElement();if(i){var r=e.findViewByModel(i);r&&(e.dumpView(r),e.checkViewVisibility(r))}var o=n.getTargetElement();if(o){var a=e.findViewByModel(o);a&&(e.dumpView(a),e.checkViewVisibility(a))}}e.dumpView(this),e.checkViewVisibility(this)}var s=this.getEventTarget(t,{fromPoint:!0}),u=e.findView(s);u!==this&&(this.mouseleave(t),u&&u.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Flags:{TOOLS:"TOOLS"},Highlighting:nf,addPresentationAttributes:function(t){return Ws({},Ds(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)?Ts(t.concat(e)):void 0})},evalAttribute:ef});function of(t,e){var n=t;do{if(n.contains(e))return n;n=n.parentNode}while(n);return null}Object.defineProperty(rf.prototype,"useCSSSelectors",{get:function(){var t=this.model.useCSSSelectors;return void 0!==t?t:xu.useCSSSelectors}});var af={TOOLS:rf.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},sf="move",uf="magnet",lf=rf.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=rf.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){rf.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[af.UPDATE],position:[af.TRANSLATE,af.TOOLS],size:[af.RESIZE,af.PORTS,af.TOOLS],angle:[af.ROTATE,af.TOOLS],markup:[af.RENDER],ports:[af.PORTS]},initFlag:[af.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){var n=this.useCSSSelectors;this.hasFlag(t,af.PORTS)&&(this._removePorts(),this._cleanPortsCache());var i=!1;if(this.hasFlag(t,af.RENDER))this.render(),this.updateTools(e),this.updateHighlighters(!0),i=!0,t=this.removeFlag(t,[af.RENDER,af.UPDATE,af.RESIZE,af.TRANSLATE,af.ROTATE,af.PORTS,af.TOOLS]);else{var r=!1;this.hasFlag(t,af.RESIZE)&&(this.resize(e),r=!0,t=this.removeFlag(t,[af.RESIZE,af.UPDATE]),n&&(t=this.removeFlag(t,af.PORTS))),this.hasFlag(t,af.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,af.UPDATE),r=!0,n&&(t=this.removeFlag(t,af.PORTS))),this.hasFlag(t,af.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,af.TRANSLATE),i=!0),this.hasFlag(t,af.ROTATE)&&(this.rotate(),t=this.removeFlag(t,af.ROTATE),i=!0),this.hasFlag(t,af.PORTS)&&(this._renderPorts(),r=!0,t=this.removeFlag(t,af.PORTS)),r&&this.updateHighlighters(!1)}return i&&this.transformHighlighters(),this.hasFlag(t,af.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,af.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var n=this.useCSSSelectors;n&&this._removePorts();var i=this.model,r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new Ei(i.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),n&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.ElementView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el),n=this.selectors=e.selectors;this.rotatableNode=su(n[this.rotatableSelector])||null,this.scalableNode=su(n[this.scalableSelector])||null,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(su(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),this.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;var n=t.size;return"rotate("+e+","+n.width/2+","+n.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,n=e.angle(),i=e.size(),r=this.scalableNode,o=!1;0<r.node.getElementsByTagName("path").length&&(o=!0);var a=r.getBBox({recursive:o}),s=i.width/(a.width||1),u=i.height/(a.height||1);r.attr("transform","scale("+s+","+u+")");var l=this.rotatableNode,h=l&&l.attr("transform");if(h){l.attr("transform",h+" rotate("+-n+","+i.width/2+","+i.height/2+")");var c=r.getBBox({target:this.paper.cells});e.set("position",{x:c.x,y:c.y},fs({updateHandled:!0},t)),this.translate(),this.rotate()}this.update()},prepareEmbedding:function(t){void 0===t&&(t={});var e=t.model||this.model,n=(t.paper||this.paper).model,i=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=n.getConnectedLinks(e,{deep:!0,includeEnclosed:!0});[e].concat(r,o).forEach(function(t){return i[t.id]=t.attributes.z}),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0});var a=n.getElements().reduce(function(t,e){return Math.max(t,e.attributes.z||0)},0);o.forEach(function(t){t.attributes.z<=a&&t.set("z",a+1,{ui:!0})}),e.stopBatch("to-front");var s=e.parent();s?(n.getCell(s).unembed(e,{ui:!0}),t.initialParentId=s):t.initialParentId=null},processEmbedding:function(t,e,n,i){void 0===t&&(t={});var r,o=t.model||this.model,a=t.paper||this.paper,s=a.model,u=a.options,l=u.findParentBy,h=u.frontParentOnly,c=u.validateEmbedding;r=(r=Ms(l)?Cs(l.call(s,this,e,n,i)):"pointer"===l?Cs(s.findModelsFromPoint({x:n,y:i})):s.findModelsUnderElement(o,{searchBy:l})).filter(function(t){return t instanceof Wl&&o.id!==t.id&&!t.isEmbeddedIn(o)}),h&&(r=r.slice(-1));for(var d=null,f=t.candidateEmbedView,p=r.length-1;0<=p;p--){var g=r[p];if(f&&f.model.id==g.id){d=f;break}var v=g.findView(a);if(!Ms(c)||c.call(a,this,v)){d=v;break}}d&&d!=f&&(this.clearEmbedding(t),t.candidateEmbedView=d.highlight(d.findProxyNode(null,"container"),{embedding:!0})),!d&&f&&this.clearEmbedding(t)},clearEmbedding:function(t){t||(t={});var e=t.candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t){void 0===t&&(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 r=i.options.validateUnembedding;if(t.initialParentId&&"function"==typeof r&&!r.call(i,this))return void this._disallowUnembed(t)}i.model.getConnectedLinks(n,{deep:!0}).forEach(function(t){t.reparent({ui:!0})})},_disallowUnembed:function(t){var e=t.model,n=t.whenNotAllowed;void 0===n&&(n="revert");var i=e||this.model,r=(t.paper||this.paper).model;switch(n){case"remove":i.remove({ui:!0});break;case"revert":var o=t.initialParentId,a=t.initialPosition,s=t.initialZIndices;if(a){var u=a.x,l=a.y;i.position(u,l,{deep:!0,ui:!0})}s&&Object.keys(s).forEach(function(t){var e=r.getCell(t);e&&e.set("z",s[t],{ui:!0})});var h=r.getCell(o);h&&h.embed(i,{ui:!0})}},getDelegatedView:function(){for(var t=this,e=t.model,n=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=n.findViewByModel(e)}return null},findProxyNode:function(t,e){t||(t=this.el);var n=t.getAttribute(e+"-selector");if(n){var i=this.findAttribute("port",t);if(i){var r=this.findPortNode(i,n);if(r)return r}else{var o=this.findNode(n);if(o)return o}}return t},notifyPointerdown:function(t,e,n){rf.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove:function(t,e,n){rf.prototype.pointermove.call(this,t,e,n),this.notify("element:pointermove",t,e,n)},notifyPointerup:function(t,e,n){this.notify("element:pointerup",t,e,n),rf.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){rf.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){rf.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){rf.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),r=i.targetMagnet,o=i.action,a=i.delegatedView;switch(r&&this.magnetpointermove(t,r,e,n),o){case uf:this.dragMagnet(t,e,n);break;case sf:(a||this).drag(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){var i=this.eventData(t),r=i.targetMagnet,o=i.action,a=i.delegatedView;switch(r&&this.magnetpointerup(t,r,e,n),o){case uf:this.dragMagnetEnd(t,e,n);break;case sf:(a||this).dragEnd(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){rf.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){rf.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){rf.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){rf.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){rf.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){if(!this.isDefaultInteractionPrevented(t)){var i=this.getDelegatedView();if(i&&i.can("elementMove")){this.eventData(t,{action:sf,delegatedView:i});var 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=this.paper,r=t.isPropagationStopped();if(r&&this.eventData(t,{preventPointerEvents:!0}),!this.isDefaultInteractionPrevented(t)&&this.can("addLinkFromMagnet")){var o=this.eventData(t).targetMagnet;void 0===o&&(o=t.currentTarget),t.stopPropagation(),i.options.validateMagnet.call(i,this,o,t)?(i.options.magnetThreshold<=0&&this.dragLinkStart(t,o,e,n),this.eventData(t,{action:uf})):r?this.dragStart(t,e,n):this.pointerdown(t,e,n)}},drag:function(t,e,n){var i=this.paper,r=i.options.gridSize,o=this.model,a=this.eventData(t),s=a.pointerOffset,u=a.restrictedArea,l=a.embedding,h=jn(e+s.x,r),c=jn(n+s.y,r);o.position(h,c,{restrictedArea:u,deep:!0,ui:!0}),i.options.embeddingMode&&(l||(this.prepareEmbedding(a),l=!0),this.processEmbedding(a,t,e,n)),this.eventData(t,{embedding:l})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){var i=this.eventData(t);i.embedding&&this.finalizeEmbedding(i)},dragMagnetEnd:function(t,e,n){this.dragLinkEnd(t,e,n)},magnetpointerclick:function(t,e,n,i){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,n,i)}},{Flags:af});fs(lf.prototype,dh);var hf={TOOLS:rf.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},cf=rf.extend({className:function(){var t=rf.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(){rf.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[hf.RENDER],attrs:[hf.UPDATE],router:[hf.UPDATE],connector:[hf.CONNECTOR],labels:[hf.LABELS],labelMarkup:[hf.LABELS],vertices:[hf.UPDATE],source:[hf.SOURCE,hf.UPDATE],target:[hf.TARGET,hf.UPDATE]},initFlag:[hf.RENDER,hf.SOURCE,hf.TARGET,hf.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e||(e={}),this.hasFlag(t,hf.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,hf.SOURCE)}if(this.hasFlag(t,hf.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,hf.TARGET)}var n=this.paper,i=this.sourceView,r=this.targetView;if(n&&(i&&!n.isViewMounted(i)||r&&!n.isViewMounted(r)))return t;if(this.hasFlag(t,hf.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),t=this.removeFlag(t,[hf.RENDER,hf.UPDATE,hf.LABELS,hf.TOOLS,hf.CONNECTOR]);var o=!1,a=this.model,s=a.attributes,u=this.hasFlag(t,hf.LABELS);u&&(this.onLabelsChange(a,s.labels,e),t=this.removeFlag(t,hf.LABELS),o=!0);var l=this.hasFlag(t,hf.UPDATE),h=this.hasFlag(t,hf.CONNECTOR);return(l||h)&&(l?e.translateBy&&a.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[hf.UPDATE,hf.TOOLS,hf.CONNECTOR]),o=!(u=!1)),u&&this.updateLabelPositions(),o&&this.updateHighlighters(),this.hasFlag(t,hf.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,hf.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(hf.UPDATE),t)},isLabelsRenderRequired:function(t){void 0===t&&(t={});var e=this.model.previous("labels");if(!e)return!0;if("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,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.LinkView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el);this.selectors=e.selectors,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=su(t);Array.isArray(e)||(e=[e]),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=su(t),n=document.createDocumentFragment();if(Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var o=e[i].node;n.appendChild(o)}else n.appendChild(e.node);return{fragment:n,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e,n=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=n.childNodes;return(e=1<i.length||"G"!==i[0].nodeName.toUpperCase()?su("g").append(n):su(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,n=this._labelCache={},i=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],a=o.length;if(0===a)return e&&e.remove(),this;e?e.empty():(e=t.labels=su("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(Su(Ds(this,"className"))),e.attr("model-id",r.id)));for(var s=0;s<a;s++){var u,l,h=o[s],c=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup));if(c)u=c.node,l=c.selectors;else{var d=r._builtins.defaultLabel,f=this._normalizeLabelMarkup(this._getLabelMarkup(d.markup)),p=r._getDefaultLabel(),g=this._normalizeLabelMarkup(this._getLabelMarkup(p.markup))||f;u=g.node,l=g.selectors}u.setAttribute("label-idx",s),e.append(u),n[s]=u;var v=this.selector;if(l[v])throw new Error("dia.LinkView: ambiguous label root selector.");l[v]=u,i[s]=l}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){var t=this.el,e=this.paper,n=this.model,i=this._V,r=this.options,o=i.labels;if(o&&n.hasLabels()){var a=o.node;r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(a,n.get("z")):a.parentNode!==t&&t.appendChild(a)}},unmountLabels:function(){var t=this.options,e=this._V;if(e){var n=e.labels;n&&t.labelsLayer&&n.remove()}},findLabelNodes:function(t,e){var n=this._labelCache[t];if(!n)return[];var i=this._labelSelectors[t];return this.findBySelector(e,n,i)},findLabelNode:function(t,e){var n=this.findLabelNodes(t,e)[0];return void 0===n&&(n=null),n},_mergeLabelAttrs:function(t,e,n,i){return null===e?null:void 0!==e?t?Ws({},n,e):Ws({},i,n,e):null===n?null:void 0!==n?t?n:Ws({},i,n):t?void 0:i},_mergeLabelSize:function(t,e){return null===t?null:void 0!==t?Ws({},e,t):null===e?null:void 0!==e?e:void 0},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,r=t._getDefaultLabel(),o=r.markup,a=r.attrs,s=r.size,u=0,l=e.length;u<l;u++){var h=this._labelCache[u];h.setAttribute("cursor",n?"move":"default");var c=this._labelSelectors[u],d=e[u],f=d.markup,p=d.attrs,g=d.size,v=this._mergeLabelAttrs(f||o,p,a,i),m=this._mergeLabelSize(g,s);this.updateDOMSubtreeAttributes(h,v,{rootBBox:new Ei(m),selectors:c})}return this},removeRedundantLinearVertices:function(t){var e=this.model,n=e.vertices(),i=[this.sourceAnchor].concat(n,[this.targetAnchor]),r=i.length,o=new Ci(i);o.simplify({threshold:.001});var a=o.points.map(function(t){return t.toJSON()}),s=a.length;return r===s?0:(e.vertices(a.slice(1,s-1),t),r-s)},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 si(this.sourceAnchor);case"target":return new si(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new si(this.sourcePoint);case"target":return new si(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(!e)break;return this.sourceMagnet||e.el;case"target":var n=this.targetView;if(!n)break;return this.targetMagnet||n.el;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var n=this.route,i=this.path;if(n&&i){var r=new Ci(n);r.translate(t,e),this.route=r.points,this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e),i.translate(t,e),this.updateDOM()}},updateDOM:function(){var t=this.el,e=this.model,n=this.selectors;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){var t=this.model.vertices(),e=this.findAnchors(t),n=this.sourceAnchor=e.source,i=this.targetAnchor=e.target,r=this.findRoute(t);this.route=r;var o=this.findConnectionPoints(r,n,i);this.sourcePoint=o.source,this.targetPoint=o.target},updatePath:function(){var t=this.route,e=this.sourcePoint,n=this.targetPoint,i=this.findPath(t,e.clone(),n.clone());this.path=i},findAnchorsOrdered:function(t,e,n,i){var r,o,a,s,u=this.model,l=u.get(t),h=u.get(n),c=this.getEndView(t),d=this.getEndView(n),f=this.getEndMagnet(t),p=this.getEndMagnet(n);r=c?(a=e?new si(e):d?p:new si(h),this.getAnchor(l.anchor,c,f,a,t)):new si(l),o=d?(s=new si(i||r),this.getAnchor(h.anchor,d,p,s,n)):new si(h);var g={};return g[t]=r,g[n]=o,g},findAnchors:function(t){var e=this.model,n=t[0],i=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",i,"source",n):this.findAnchorsOrdered("source",n,"target",i)},findConnectionPoints:function(t,e,n){var i,r,o,a,s=t[0],u=t[t.length-1],l=this.model,h=l.get("source"),c=l.get("target"),d=this.sourceView,f=this.targetView,p=this.paper.options;if(d&&!d.isNodeConnection(this.sourceMagnet)){i=this.sourceMagnet||d.el;var g=h.connectionPoint||p.defaultConnectionPoint,v=new ci(s||n,e);o=this.getConnectionPoint(g,d,i,v,"source")}else o=e;if(f&&!f.isNodeConnection(this.targetMagnet)){r=this.targetMagnet||f.el;var m=c.connectionPoint||p.defaultConnectionPoint,y=new ci(u||e,n);a=this.getConnectionPoint(m,f,r,y,"target")}else a=n;return{source:o,target:a}},getAnchor:function(t,e,n,i,r){var o,a=e.isNodeConnection(n),s=this.paper.options;if(t||(t=a?s.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor),!t)throw new Error("Anchor required.");if("function"==typeof t)o=t;else{var u=t.name;if("function"!=typeof(o=s[a?"linkAnchorNamespace":"anchorNamespace"][u]))throw new Error("Unknown anchor: "+u)}var l=o.call(this,e,n,i,t.args||{},r,this);return l?l.round(this.decimalsRounding):new si},getConnectionPoint:function(t,e,n,i,r){var o,a,s=i.end,u=this.paper.options;if(!t)return s;if("function"==typeof t)a=t;else{var l=t.name;if("function"!=typeof(a=u.connectionPointNamespace[l]))throw new Error("Unknown connection point: "+l)}return(o=a.call(this,i,e,n,t.args||{},r,this))?o.round(this.decimalsRounding):s},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,n=t._getDefaultLabel(),i=this._normalizeLabelPosition(n.position);return Ws({},e,i)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},_mergeLabelPositionProperty:function(t,e){return null===t?null:void 0===t?null===e?null:e:Ws({},e,t)},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model.get("labels")||[];if(!t.length)return this;for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r=this._labelCache[n];if(r){var o=t[n],a=this._normalizeLabelPosition(o.position),s=this._mergeLabelPositionProperty(a,e),u=this._getLabelTransformationMatrix(s);r.setAttribute("transform",su.matrixToTransformString(u)),this._cleanLabelMatrices(n)}}return this},_cleanLabelMatrices:function(t){var e=this.metrics,n=this._labelSelectors[t];if(n)for(var i in n){var r=n[i].id;r&&r in e&&delete e[r].magnetMatrix}},updateEndProperties:function(t){var e=this.model,n=this.paper,i=t+"View",r=e.get(t),o=r&&r.id;if(!o)return this[i]=null,this.updateEndMagnet(t),!0;var a=n.getModelById(o);if(!a)throw new Error("LinkView: invalid "+t+" cell.");var s=a.findView(n);return!!s&&(this[i]=s,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){var e=t+"Magnet",n=this.getEndView(t);if(n){var i=n.getMagnetFromLinkEnd(this.model.get(t));i===n.el&&(i=null),this[e]=i}else this[e]=null},_getLabelPositionProperty:function(t){return this.model.label(t).position||{}},_getLabelPositionAngle:function(t){return this._getLabelPositionProperty(t).angle||0},_getLabelPositionArgs:function(t){return this._getLabelPositionProperty(t).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:Ws({},e,t)},addLabel:function(t,e,n,i){var r,o,a,s=0;a="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);var u=this._getDefaultLabelPositionArgs(),l=a,h=this._mergeLabelPositionArgs(l,u),c={position:this.getLabelPosition(r,o,s,h)};return this.model.insertLabel(-1,c,a),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,o=i?t.y:e,a=i?e:n,s={x:r,y:o},u=this.getVertexIndex(r,o);return this.model.insertVertex(u,s,a),u},sendToken:function(t,e,n){var i,r,o;o=hs(e)?(i=e.duration,r="reverse"===e.direction,e.connection):(i=e,r=!1,null);var a={dur:(i=i||1e3)+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};r&&(a.keyPoints="1;0",a.keyTimes="0;1");var s,u,l,h=su(t);if("string"==typeof o)s=this.findNode(o);else{var c=this._V;s=c.connection?c.connection.node:this.el.querySelector("path")}if(!(s instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");h.appendTo(this.paper.cells).animateAlongPath(a,s),setTimeout((u=h,l=n,function(){u.remove(),"function"==typeof l&&l()}),i)},findRoute:function(t){t||(t=[]);var e=this.paper.options.routerNamespace||jd,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(si);n=i}var r=Ms(n)?n:e[n.name];if(!Ms(r))throw new Error('dia.LinkView: unknown router: "'+n.name+'".');var o=n.args||{},a=r.call(this,t,o,this);return a||t.map(si)},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||Qh,r=this.model.connector(),o=this.paper.options.defaultConnector;r||(r=o||{});var a=Ms(r)?r:i[r.name];if(!Ms(a))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');var s=Ps(r.args||{});s.raw=!0;var u=a.call(this,e,n,t,s,this);return"string"==typeof u&&(u=new Ii(su.normalizePathData(u))),u},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;var n=t.serialize();return e.data=n},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;var n=t.getSegmentSubdivisions();return e.segmentSubdivisions=n},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;var n=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=n},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?(zu(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={},a=0;(r="number"==typeof n?(a=n,i):n)&&(o.args=r);var s,u,l=!(r&&r.absoluteDistance),h=r&&r.absoluteDistance&&r.reverseDistance,c=r&&r.absoluteOffset,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=new si(t,e),g=d.closestPointT(p,f),v=d.lengthAtT(g,f);if(l&&(v=v/this.getConnectionLength()||0),h&&(v=-1*(this.getConnectionLength()-v)||1),o.distance=v,c||(s=d.tangentAtT(g)),s)u=s.pointOffset(p);else{var m=d.pointAtT(g),y=p.difference(m);u={x:y.x,y:y.y}}return o.offset=u,o.angle=a,o},_getLabelTransformationMatrix:function(t){var e,n=0,i={};if("number"==typeof t)e=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},e=t.distance,n=t.angle||0}var r=0<e&&e<=1,o=0,a={x:0,y:0};if(t.offset){var s=t.offset;"number"==typeof s&&(o=s),s.x&&(a.x=s.x),s.y&&(a.y=s.y)}var u,l=0!==a.x||0!==a.y||0===o,h=i.keepGradient,c=i.ensureLegibility,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=r?e*this.getConnectionLength():e,g=d.tangentAtLength(p,f),v=n;if(g){if(l)(u=g.start.clone()).offset(a);else{var m=g.clone();m.rotate(g.start,-90),m.setLength(o),u=m.end}h&&(v=g.angle()+n,c&&(v=Dn((v+90)%180-90)))}else u=d.start.clone(),l&&u.offset(a);return su.createSVGMatrix().translate(u.x,u.y).rotate(v)},getLabelCoordinates:function(t){var e=this._getLabelTransformationMatrix(t);return new si(e.e,e.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new si(t,e)),r=0,o=n.length;r<o;r++){var a=n[r];if(i<this.getClosestPointLength(a))break}return r},notifyPointerdown:function(t,e,n){rf.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove:function(t,e,n){rf.prototype.pointermove.call(this,t,e,n),this.notify("link:pointermove",t,e,n)},notifyPointerup:function(t,e,n){this.notify("link:pointerup",t,e,n),rf.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){rf.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){rf.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){rf.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&&fs(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){rf.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){rf.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){rf.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){rf.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){rf.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,n,i)},onlabel:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragLabelStart(t,e,n),this.eventData(t).stopPropagation&&t.stopPropagation()},dragLabelStart:function(t,e,n){if(this.can("labelMove")){if(this.isDefaultInteractionPrevented(t))return;var i=t.currentTarget,r=parseInt(i.getAttribute("label-idx"),10),o=this._getDefaultLabelPositionProperty(),a=this._normalizeLabelPosition(this._getLabelPositionProperty(r)),s=this._mergeLabelPositionProperty(a,o),u=this.getLabelCoordinates(s),l=u.x-e,h=u.y-n,c=this._getLabelPositionAngle(r),d=this._getLabelPositionArgs(r),f=this._getDefaultLabelPositionArgs(),p=this._mergeLabelPositionArgs(d,f);this.eventData(t,{action:"label-move",labelIdx:r,dx:l,dy:h,positionAngle:c,positionArgs:p,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){if(this.can("arrowheadMove")){var i=t.target.getAttribute("end"),r=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0});this.eventData(t,r)}},dragStart:function(t,e,n){this.isDefaultInteractionPrevented(t)||this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:n})},dragLabel:function(t,e,n){var i=this.eventData(t),r={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)};this.paper.options.snapLabels&&delete r.position.offset;var o={ui:!0};this.paper.isAsync()&&"touchmove"===t.type&&(o.async=!1),this.model.label(i.labelIdx,r,o)},dragArrowhead:function(t,e,n){this.paper.options.snapLinks?!this._snapArrowhead(t,e,n)&&this.paper.options.snapLinksSelf&&this._snapArrowheadSelf(t,e,n):this.paper.options.snapLinksSelf?this._snapArrowheadSelf(t,e,n):this._connectArrowhead(this.getEventTarget(t),e,n,this.eventData(t))},drag:function(t,e,n){var i=this.eventData(t);this.model.translate(e-i.dx,n-i.dy,{ui:!0}),this.eventData(t,{dx:e,dy:n})},dragLabelEnd:function(){},dragArrowheadEnd:function(t,e,n){var i=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(i):this._connectArrowheadEnd(i,e,n),r.linkAllowed(this)?(this._finishEmbedding(i),this._notifyConnectEvent(i,t)):this._disallow(i),this._afterArrowheadMove(i)},dragEnd:function(){},_disallow:function(t){switch(t.whenNotAllowed){case"remove":this.model.remove({ui:!0});break;case"revert":default:this.model.set(t.arrowhead,t.initialEnd,{ui:!0})}},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var n=t.arrowhead,i=t.initialEnd,r=this.model.prop(n);if(r&&!ph.endsEqual(i,r)){var o=this.paper;i.id&&this.notify("link:disconnect",e,o.findViewByModel(i.id),t.initialMagnet,n),r.id&&this.notify("link:connect",e,o.findViewByModel(r.id),t.magnetUnderPointer,n)}},_snapToPoints:function(t,e,n){for(var i=null,r=1/0,o=null,a=1/0,s=t.x,u=t.y,l=0;l<e.length;l++){var h=Math.abs(e[l].x-t.x);h<r&&(r=h,i=e[l]);var c=Math.abs(e[l].y-t.y);c<a&&(a=c,o=e[l])}return r<n&&(s=i.x),a<n&&(u=o.y),{x:s,y:u}},_snapArrowheadSelf:function(t,e,n){var i=this.paper,r=this.model,o=i.options.snapLinksSelf,a=this.eventData(t),s=o.radius||20,u=this.getEndAnchor("source"===a.arrowhead?"target":"source"),l=r.vertices(),h=[u].concat(l),c=this._snapToPoints({x:e,y:n},h,s),d=i.localToClientPoint(c);this._connectArrowhead(document.elementFromPoint(d.x,d.y),c.x,c.y,this.eventData(t))},_snapArrowhead:function(t,e,n){var r=this.paper,i=r.options,o=i.snapLinks,a=i.connectionStrategy,s=this.eventData(t),u=!1,l=o.radius||50,h=r.findViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l}),c=s.closestView||null,d=s.closestMagnet||null,f=s.magnetProxy||null;s.closestView=s.closestMagnet=s.magnetProxy=null;var p,g=Number.MAX_VALUE,v=new si(e,n);h.forEach(function(i){var e=[];"false"!==i.el.getAttribute("magnet")&&e.push({bbox:i.model.getBBox(),magnet:i.el}),i.$("[magnet]").toArray().forEach(function(t){e.push({bbox:i.getNodeBBox(t),magnet:t})}),e.forEach(function(t){var e=t.magnet,n=t.bbox.center().squaredDistance(v);n<g&&((d===e||r.options.validateConnection.apply(r,s.validateConnectionArgs(i,i.el===e?null:e)))&&(g=n,s.closestView=i,s.closestMagnet=e))})},this);var m=null,y=s.closestView,b=s.closestMagnet;b&&(m=s.magnetProxy=y.findProxyNode(b,"highlighter"));var w=s.arrowhead,x=d!==b;if(c&&x&&c.unhighlight(f,{connecting:!0,snapping:!0}),y){var A=s.prevEnd,T=s.prevX,P=s.prevY;if(s.prevX=e,s.prevY=n,u=!0,!x&&("function"!=typeof a||T===e&&P===n))return u;if(p=y.getLinkEnd(b,e,n,this.model,w),!x&&ks(A,p))return u;s.prevEnd=p,x&&y.highlight(m,{connecting:!0,snapping:!0})}else p={x:e,y:n};return this.model.set(w,p||{x:e,y:n},{ui:!0}),c&&this.notify("link:snap:disconnect",t,c,d,w),y&&this.notify("link:snap:connect",t,y,b,w),u},_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=this.paper,o=this.model;if(i.eventTarget!==t){i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0});var a=i.viewUnderPointer=r.findView(t);if(a){var s=i.magnetUnderPointer=a.findMagnet(t),u=i.magnetProxy=a.findProxyNode(s,"highlighter");s&&this.paper.options.validateConnection.apply(r,i.validateConnectionArgs(a,s))?u&&a.highlight(u,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)}else i.magnetUnderPointer=null,i.magnetProxy=null}i.eventTarget=t,o.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t,e,n){void 0===t&&(t={});var i=this.model,r=t.viewUnderPointer,o=t.magnetUnderPointer,a=t.magnetProxy,s=t.arrowhead;if(o&&a&&r){r.unhighlight(a,{connecting:!0});var u=r.getLinkEnd(o,e,n,i,s);i.set(s,u,{ui:!0})}},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,n=[];n[4]=t,n[5]=this;var i=0,r=0;e="source"===t?(i=2,"target"):(r=2,"source");var o=this.model.get(e);if(o.id){var a=n[i]=this.paper.findViewByModel(o.id),s=a.getMagnetFromLinkEnd(o);s===a.el&&(s=void 0),n[i+1]=s}return function(t,e){return n[r]=t,n[r+1]=t.el===e?void 0:e,n}},_markAvailableMagnets:function(t){function e(t,e){var n=t.paper;return n.options.validateConnection.apply(n,this.validateConnectionArgs(t,e))}var n=this.paper,i=n.model.getCells();t.marked={};for(var r=0,o=i.length;r<o;r++){var a=i[r].findView(n);if(a){var s=Array.prototype.slice.call(a.el.querySelectorAll("[magnet]"));"false"!==a.el.getAttribute("magnet")&&s.push(a.el);var u=s.filter(e.bind(t,a));if(0<u.length){for(var l=0,h=u.length;l<h;l++)a.highlight(u[l],{magnetAvailability:!0});a.highlight(null,{elementAvailability:!0}),t.marked[a.model.id]=u}}}},_unmarkAvailableMagnets:function(t){for(var e,n,i=Object.keys(t.marked),r=0,o=i.length;r<o;r++){e=i[r],n=t.marked[e];var a=this.paper.findViewByModel(e);if(a){for(var s=0,u=n.length;s<u;s++)a.unhighlight(n[s],{magnetAvailability:!0});a.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){e||(e={});var n={action:"arrowhead-move",arrowhead:t,whenNotAllowed:e.whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:Ps(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(n),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=n),n},onMount:function(){rf.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){rf.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){rf.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:hf});Object.defineProperty(cf.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t){var e=this.model.source();return new Ei(e.x,e.y)}var n=this.sourceMagnet;return t.isNodeConnection(n)?new Ei(this.sourceAnchor):t.getNodeBBox(n||t.el)}}),Object.defineProperty(cf.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t){var e=this.model.target();return new Ei(e.x,e.y)}var n=this.targetMagnet;return t.isNodeConnection(n)?new Ei(this.targetAnchor):t.getNodeBBox(n||t.el)}});var df=Jd.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init:function(){Jd.prototype.init.apply(this,arguments);var t=this.options.paper;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid:function(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings:function(t){var e=this,n=[];t&&(Array.isArray(t)?t:[t||{}]).forEach(function(t){n.push.apply(n,e._resolveDrawGridOption(t))});return n},removeGrid:function(){var t=this._gridCache;t&&(t.root.remove(),this._gridCache=null)},renderGrid:function(){var a=this.options.paper,t=this._gridSettings;if(this.removeGrid(),0!==t.length){var s=a.options.drawGridSize||a.options.gridSize;if(!(s<=1)){var u=this._getGridRefs();t.forEach(function(t,e){var n,i="pattern_"+e,r=Ws({},t),o=r.scaleFactor;void 0===o&&(o=1),r.width=s*o||1,r.height=s*o||1,u.exist(i)?n=u.get(i):(n=su("pattern",{id:i,patternUnits:"userSpaceOnUse"},su(r.markup)),u.add(i,n)),Ms(r.render)&&r.render(n.node.firstChild,r,a),n.attr({width:r.width,height:r.height})}),u.root.appendTo(this.el),this.updateGrid()}}},updateGrid:function(){var t=this._gridCache,e=this._gridSettings,i=this.options.paper;if(t){var n=t.root,r=t.patterns,o=i.getArea(),a=o.x,s=o.y,u=o.width,l=o.height;for(var h in n.attr({x:a,y:s,width:u,height:l}),r){r[h].attr({x:-a,y:-s})}e.forEach(function(t,e){if(Ms(t.update)){var n=r["pattern_"+e];t.update(n.node.firstChild,t,i)}})}},_getGridRefs:function(){var t=this._gridCache;if(t)return t;var i=su("defs"),r=su("svg",{width:"100%",height:"100%"},[i]);return t=this._gridCache={root:r,patterns:{},add:function(t,e){var n=su("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]}}},_resolveDrawGridOption:function(t){var e=this.options.patterns;if(ds(t)&&Array.isArray(e[t]))return e[t].map(function(t){return fs({},t)});var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if(i||r||n.markup||(r="dot"),r&&Array.isArray(e[r])){var o=e[r].map(function(t){return fs({},t)}),a=Array.isArray(n.args)?n.args:[n.args||{}];ms(a[0],js(t,"args"));for(var s=0;s<a.length;s++)o[s]&&fs(o[s],a[s]);return o}return i?n:[n]}}),ff={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},pf=9007199254740991,gf=rf.Highlighting,vf={};vf[gf.DEFAULT]={name:"stroke",options:{padding:3}},vf[gf.MAGNET_AVAILABILITY]={name:"addClass",options:{className:"available-magnet"}},vf[gf.ELEMENT_AVAILABILITY]={name:"addClass",options:{className:"available-cell"}};var mf=[{name:Zd.GRID},{name:Zd.BACK},{name:Zd.CELLS},{name:Zd.LABELS},{name:Zd.FRONT},{name:Zd.TOOLS}],yf=rc.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:lf,linkView:cf,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:vf,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){var t=this.model.get("cells").cellNamespace,e=Lu(t,["standard","Link"]);if(!e)throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.");return new e},defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"boundary"},connectionStrategy:null,validateMagnet:function(t,e,n){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,n,i,r,o){return("target"===r?n:t)instanceof lf},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:ff.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:Mc,anchorNamespace:Yd,linkAnchorNamespace:qd,connectionPointNamespace:Rc,overflow:!1},events:{dblclick:"pointerdblclick",dbltap:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},stylesheet:"\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n ",svg:null,viewport:null,defs:null,tools:null,layers:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],FORM_CONTROL_TAG_NAMES:["TEXTAREA","INPUT","BUTTON","SELECT","OPTION"],GUARDED_TAG_NAMES:["SELECT"],MIN_SCALE:1e-6,init:function(){var t=this.options;t.cellViewNamespace||(t.cellViewNamespace=void 0!==joint&&Is(joint,"shapes")?joint.shapes:null);var e=this.model=t.model||new $d;this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&ju(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()||!cs(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){var i=this.findViewByModel(t);i&&this.requestViewUpdate(i,i.FLAG_REMOVE,i.UPDATE_PRIORITY,n)},onCellChange:function(t,e){if(t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===ff.APPROX){var n=this.findViewByModel(t);n&&this.requestViewUpdate(n,n.FLAG_INSERT,n.UPDATE_PRIORITY,e)}},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){if(!this.isFrozen()){var e=t&&t.batchName,n=this.model;if(!this.isAsync()){var i=this.UPDATE_DELAYING_BATCHES;i.includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t)}var r=this.SORT_DELAYING_BATCHES;r.includes(e)&&!n.hasActiveBatch(r)&&this.sortViews()}},cloneOptions:function(){var t=this.options,e=t.defaultConnector,n=t.defaultRouter,i=t.defaultConnectionPoint,r=t.defaultAnchor,o=t.defaultLinkAnchor,a=t.highlighting,s=t.cellViewNamespace,u=t.interactive;!s&&void 0!==joint&&Is(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),Ms(e)||(t.defaultConnector=Es(e)),Ms(n)||(t.defaultRouter=Es(n)),Ms(i)||(t.defaultConnectionPoint=Es(i)),Ms(r)||(t.defaultAnchor=Es(r)),Ms(o)||(t.defaultLinkAnchor=Es(o)),Ls(u)&&(t.interactive=fs({},u)),Ls(a)&&(t.highlighting=bs({},a,vf))},children:function(){var t=su.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:Su("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:Su("layers"),selector:"layers"}]}]},hasLayerView:function(t){return t in this._layers},getLayerView:function(t){var e=this._layers;if(t in e)return e[t];throw new Error('dia.Paper: Unknown layer "'+t+'"')},getLayerNode:function(t){return this.getLayerView(t).el},render:function(){this.renderChildren();var t=this.el,e=this.childNodes,n=this.options,i=this.stylesheet,r=e.svg,o=e.defs,a=e.layers;return t.style.position="relative",r.style.overflow=n.overflow?"visible":"hidden",this.svg=r,this.defs=o,this.layers=a,this.renderLayers(),su.ensureId(r),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&su(this.svg).prepend(su.createSVGStyle(t))},createLayer:function(t){switch(t){case Zd.GRID:return new df({name:t,paper:this,patterns:this.constructor.gridPatterns});default:return new Jd({name:t})}},renderLayers:function(t){var i=this;void 0===t&&(t=mf),this.removeLayers(),t.forEach(function(t){var e=t.name,n=(t.sorted,i.createLayer(e));i.layers.appendChild(n.el),i._layers[e]=n});var e=this.getLayerView(Zd.CELLS),n=this.getLayerView(Zd.TOOLS),r=this.getLayerView(Zd.LABELS);this.tools=n.el,this.cells=this.viewport=e.el,e.vel.addClass(Su("viewport")),r.vel.addClass(Su("viewport")),e.el.style.webkitUserSelect="none",e.el.style.userSelect="none",r.el.style.webkitUserSelect="none",r.el.style.userSelect="none"},removeLayers:function(){var e=this._layers;Object.keys(e).forEach(function(t){e[t].remove(),delete e[t]})},resetLayers:function(){var e=this._layers;Object.keys(e).forEach(function(t){e[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?su.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 i=this.matrix(),r=i.a,o=i.d,a=i.e,s=i.f;if((t=Math.max(t||0,this.MIN_SCALE))===r&&t===o)return this;var u=su.createSVGMatrix().translate(a-e.x*(t-r),s-e.y*(t-o)).scale(t,t);return this.matrix(u,n),this},translate:function(t,e,n){var i=this.matrix();return void 0===t?su.matrixToTranslate(i):(t||(t=0),e||(e=0),i.e===t&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e){void 0===e&&(e={});var n=this.layers;if(void 0===t){var i=n.getAttribute("transform");return(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=n.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),su.createSVGMatrix(t)}var r=this.matrix(),o=su.createSVGMatrix(t),a=this._viewportTransformString,s=su.matrixToTransformString(o);if(s===a)return this;if(!a&&su.matrixToTransformString()===s)return this;var u=o.a,l=o.d,h=o.e,c=o.f;return n.setAttribute("transform",s),this._viewportMatrix=o,this._viewportTransformString=n.getAttribute("transform"),u===r.a&&l===r.d||this.trigger("scale",u,l,e),h===r.e&&c===r.f||this.trigger("translate",h,c,e),this.trigger("transform",o,e),this},clientMatrix:function(){return su.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof rf)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,a=r.length;o<a;o++){var s=r[o],u=this.findViewByModel(s);if(u){var l=["UPDATE"];s.getTargetCell()===i&&l.push("TARGET"),s.getSourceCell()===i&&l.push("SOURCE");var h=Math.max(e+1,u.UPDATE_PRIORITY);this.scheduleViewUpdate(u,u.getFlag(l),h,n)}}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof rf))return!1;var n=t.model;if(n.isElement())return!1;if(0==(e&t.getFlag(["SOURCE","TARGET"]))){var i={silent:!0},r=0,o=this.findViewByModel(n.getSourceCell());o&&!this.isViewMounted(o)&&(r=this.dumpView(o,i),t.updateEndMagnet("source"));var a=0,s=this.findViewByModel(n.getTargetCell());if(s&&!this.isViewMounted(s)&&(a=this.dumpView(s,i),t.updateEndMagnet("target")),0===r&&0===a)return!this.dumpView(t,i)}return!1},requestViewUpdate:function(t,e,n,i){i||(i={}),this.scheduleViewUpdate(t,e,n,i);var r=this.isAsync();if(!(this.isFrozen()||r&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES))){var o=this.updateViews(i);r&&this.notifyAfterRender(o,i)}},scheduleViewUpdate:function(t,e,n,i){var r=this._updates,o=this.options;r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze());var a=t.FLAG_REMOVE,s=t.FLAG_INSERT,u=t.UPDATE_PRIORITY,l=t.cid,h=r.priorities[n];if(h||(h=r.priorities[n]={}),u<n)for(var c=n-1;u<=c;c--){var d=r.priorities[c];d&&l in d&&(h[l]|=d[l],delete d[l])}var f=h[l]||0;if((f&e)!==e){f||r.count++,e&a&&f&s?h[l]^=s:e&s&&f&a&&(h[l]^=a),h[l]|=e;var p=o.onViewUpdate;"function"==typeof p&&p.call(this,t,e,n,i||{},this)}},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,n=t.cid,i=e.priorities[t.UPDATE_PRIORITY],r=this.registerMountedView(t)|i[n];return delete i[n],r},dumpView:function(t,e){void 0===e&&(e={});var n=this.dumpViewUpdate(t);if(!n)return 0;var i=!e.silent;i&&this.notifyBeforeRender(e);var r=this.updateView(t,n,e);if(i){var o={updated:1,priority:t.UPDATE_PRIORITY};this.notifyAfterRender(o,e)}return r},updateView:function(t,e,n){if(!t)return 0;var i=t.FLAG_REMOVE,r=t.FLAG_INSERT,o=t.FLAG_INIT,a=t.model;if(t instanceof rf){if(e&i)return this.removeView(a),0;if(e&r){var s=!!(e&o);s&&(e^=o),this.insertView(t,s),e^=r}}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){var n=this.findViewByModel(t);return n?(this.dumpView(n,e),n):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;if(e in n.unmounted)return 0;var i=n.unmounted[e]|=t.FLAG_INSERT;return n.unmountedCids.push(e),delete n.mounted[e],i},registerMountedView:function(t){var e=t.cid,n=this._updates;if(e in n.mounted)return 0;n.mounted[e]=!0,n.mountedCids.push(e);var i=n.unmounted[e]||0;return delete n.unmounted[e],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){var e=ms({},t,{viewport:null});this.checkViewport(e),this.updateViews(e)},updateViews:function(t){var e;this.notifyBeforeRender(t);for(var n=0,i=0,r=pf;i++,n+=(e=this.updateViewsBatch(t)).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(){for(var t=this._updates.priorities,e=Object.keys(t),n=e.length;0<n&&n--;)for(var i in t[e[n]])return!0;return!1},updateViewsAsync:function(t,e){t||(t={}),e||(e={processed:0,priority:pf});var n=this._updates,i=this.options,r=n.id;if(r){ju(r),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);var o=this.updateViewsBatch(t),a=ms({},t,{mountBatchSize:1e3-o.mounted,unmountBatchSize:1e3-o.unmounted}),s=this.checkViewport(a),u=s.unmounted,l=s.mounted,h=e.processed,c=n.count;0<o.updated?(h+=o.updated+o.unmounted,o.processed=h,e.priority=Math.min(o.priority,e.priority),o.empty&&0===l?(o.unmounted+=u,o.mounted+=l,o.priority=e.priority,this.notifyAfterRender(o,t),e.processed=0,e.priority=pf,n.count=0):e.processed=h):n.idle||i.autoFreeze&&(this.freeze(),n.idle=!0,this.trigger("render:idle",t));var d=t.progress;if(c&&"function"==typeof d&&d.call(this,o.empty,h,c,o,this),n.id!==r)return}if(n.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");n.id=Du(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t){void 0===t&&(t={});var e=t.beforeRender;"function"!=typeof e&&"function"!=typeof(e=this.options.beforeRender)||e.call(this,t,this)},notifyAfterRender:function(t,e){void 0===e&&(e={});var n=e.afterRender;"function"!=typeof n&&(n=this.options.afterRender),"function"==typeof n&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){t||(t={});var e=t.batchSize||1/0,n=this._updates,i=0,r=0,o=0,a=0,s=pf,u=!0,l=this.options,h=n.priorities,c="viewport"in t?t.viewport:l.viewport;"function"!=typeof c&&(c=null);var d=l.onViewPostponed;"function"!=typeof d&&(d=null);var f=Object.keys(h);t:for(var p=0,g=f.length;p<g;p++){var v=+f[p],m=h[v];for(var y in m){if(e<=i){u=!1;break t}var b=ic[y];if(b){var w=m[y];if(0==(w&b.FLAG_REMOVE)){var x=y in n.unmounted;if(b.DETACHABLE&&c&&!c.call(this,b,!x,this)){x||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[y]|=w,delete m[y],o++;continue}x&&(w|=b.FLAG_INSERT,a++),w|=this.registerMountedView(b)}var A=this.updateView(b,w,t);0<A&&(m[y]=A,!d||!d.call(this,b,A,this)||m[y])?(r++,u=!1):(v<s&&(s=v),i++,delete m[y])}else delete m[y]}}return{priority:s,updated:i,postponed:r,unmounted:o,mounted:a,empty:u}},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]=ic[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]=ic[e[r]];return i},checkUnmountedViews:function(t,e){e||(e={});var n=0;"function"!=typeof t&&(t=null);for(var i=("mountBatchSize"in e?e.mountBatchSize:1/0),r=this._updates,o=r.unmountedCids,a=r.unmounted,s=0,u=Math.min(o.length,i);s<u;s++){var l=o[s];if(l in a){var h=ic[l];if(h)if(h.DETACHABLE&&t&&!t.call(this,h,!1,this))o.push(l);else{n++;var c=this.registerMountedView(h);c&&this.scheduleViewUpdate(h,c,h.UPDATE_PRIORITY,{mounting:!0})}}}return o.splice(0,s),n},checkMountedViews:function(t,e){e||(e={});var n=0;if("function"!=typeof t)return n;for(var i=("unmountBatchSize"in e?e.unmountBatchSize:1/0),r=this._updates,o=r.mountedCids,a=r.mounted,s=0,u=Math.min(o.length,i);s<u;s++){var l=o[s];if(l in a){var h=ic[l];if(h)if(h.DETACHABLE&&!t.call(this,h,!0,this))n++,this.registerUnmountedView(h)&&this.detachView(h);else o.push(l)}}return o.splice(0,s),n},checkViewVisibility:function(t,e){void 0===e&&(e={});var n="viewport"in e?e.viewport:this.options.viewport;"function"!=typeof n&&(n=null);var i=this._updates,r=i.mounted,o=i.unmounted,a=!t.DETACHABLE||!n||n.call(this,t,!1,this),s=!1,u=!1;if(t.cid in r&&!a){this.registerUnmountedView(t)&&this.detachView(t);var l=i.mountedCids.indexOf(t.cid);i.mountedCids.splice(l,1),s=!0}if(!s&&t.cid in o&&a){var h=i.unmountedCids.indexOf(t.cid);i.unmountedCids.splice(h,1);var c=this.registerMountedView(t);c&&this.scheduleViewUpdate(t,c,t.UPDATE_PRIORITY,{mounting:!0}),u=!0}return{mounted:u?1:0,unmounted:s?1:0}},checkViewport:function(t){var e=ms({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n="viewport"in e?e.viewport:this.options.viewport,i=this.checkMountedViews(n,e);if(0<i){var r=this._updates.unmountedCids;e.mountBatchSize=Math.min(r.length-i,e.mountBatchSize)}return{mounted:this.checkUnmountedViews(n,e),unmounted:i}},freeze:function(t){t||(t={});var e=this._updates,n=t.key,i=this.options.frozen,r=e.freezeKey;if(n&&n!==r){if(i&&r)return;e.freezeKey=n,e.keyFrozen=i}this.options.frozen=!0;var o=e.id;e.id=null,this.isAsync()&&o&&ju(o)},unfreeze:function(t){t||(t={});var e=this._updates,n=t.key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===ff.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,n=t.height;return cs(e)||(e=this.el.clientWidth),cs(n)||(n=this.el.clientHeight),{width:e,height:n}},setDimensions:function(t,e,n){void 0===n&&(n={});var i=this.options,r=i.width,o=i.height,a=void 0===t?r:t,s=void 0===e?o:e;if(r!==a||o!==s){i.width=a,i.height=s,this._setDimensions();var u=this.getComputedSize();this.trigger("resize",u.width,u.height,n)}},_setDimensions:function(){var t=this.options,e=t.width,n=t.height;cs(e)&&(e=Math.round(e)+"px"),cs(n)&&(n=Math.round(n)+"px"),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=hs(t)?t:fs({gridWidth:t,gridHeight:e,padding:n},i);var r=this.getFitToContentArea(i),o=r.x,a=r.y,s=r.width,u=r.height,l=this.scale(),h=l.sx,c=l.sy;return this.translate(-o*h,-a*c,i),this.setDimensions(s*h,u*c,i),new Ei(o,a,s,u)},getFitToContentArea:function(t){void 0===t&&(t={});var e=t.gridWidth||1,n=t.gridHeight||1,i=Ju(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,n),a=t.maxWidth||Number.MAX_VALUE,s=t.maxHeight||Number.MAX_VALUE,u=t.allowNewOrigin,l="contentArea"in t?new Ei(t.contentArea):this.getContentArea(t),h=this.scale(),c=h.sx,d=h.sy;l.x*=c,l.y*=d,l.width*=c,l.height*=d;var f=Math.ceil((l.width+l.x)/e),p=Math.ceil((l.height+l.y)/n);t.allowNegativeBottomRight||(f=Math.max(f,1),p=Math.max(p,1)),f*=e,p*=n;var g=0;("negative"===u&&l.x<0||"positive"===u&&0<=l.x||"any"===u)&&(g=Math.ceil(-l.x/e)*e,f+=g+=i.left);var v=0;return("negative"===u&&l.y<0||"positive"===u&&0<=l.y||"any"===u)&&(v=Math.ceil(-l.y/n)*n,p+=v+=i.top),f+=i.right,p+=i.bottom,f=Math.max(f,r),p=Math.max(p,o),f=Math.min(f,a),p=Math.min(p,s),new Ei(-g/c,-v/d,f/c,p/d)},transformToFitContent:function(t){var e,n;if(t||(t={}),"contentArea"in t){var i=t.contentArea;e=this.localToPaperRect(i),n=new si(i)}else e=this.getContentBBox(t),n=this.paperToLocalPoint(e);if(e.width&&e.height){ms(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});var r,o=Ju(t.padding),a=t.minScaleX||t.minScale,s=t.maxScaleX||t.maxScale,u=t.minScaleY||t.minScale,l=t.maxScaleY||t.maxScale;if(t.fittingBBox)r=t.fittingBBox;else{var h=this.translate(),c=this.getComputedSize();r={x:h.tx,y:h.ty,width:c.width,height:c.height}}r=new Ei(r).moveAndExpand({x:o.left,y:o.top,width:-o.left-o.right,height:-o.top-o.bottom});var d=this.matrix(),f=d.a,p=d.d,g=d.e,v=d.f,m=r.width/e.width*f,y=r.height/e.height*p;if(t.preserveAspectRatio&&(m=y=Math.min(m,y)),t.scaleGrid){var b=t.scaleGrid;m=b*Math.floor(m/b),y=b*Math.floor(y/b)}var w=(m=Math.min(s,Math.max(a,m)))/f,x=(y=Math.min(l,Math.max(u,y)))/p,A=r.x-n.x*m-g,T=r.y-n.y*y-v;switch(t.verticalAlign){case"middle":T+=(r.height-e.height*x)/2;break;case"bottom":T+=r.height-e.height*x}switch(t.horizontalAlign){case"middle":A+=(r.width-e.width*w)/2;break;case"right":A+=r.width-e.width*w}d.a=m,d.d=y,d.e=A,d.f=T,this.matrix(d,t)}},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new Ei:su(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=this.options.restrictTranslate;return Ms(n)?n.apply(this,t):!0===n?this.getArea():n?new Ei(n):null},createViewForModel:function(t){var e,n,i=this.options,r=i.cellViewNamespace,o=t.get("type")+"View",a=Lu(r,o,".");return n=t.isLink()?(e=i.linkView,cf):(e=i.elementView,lf),new(e.prototype instanceof tc?a||e:e.call(this,t)||a||n)({model:t,interactive:i.interactive,labelsLayer:!0===i.labelsLayer?Zd.LABELS:i.labelsLayer})},removeView:function(t){var e=t.id,n=this._views,i=this._updates,r=n[e];if(r){var o=r.cid,a=i.mounted,s=i.unmounted;r.remove(),delete n[e],delete a[o],delete s[o]}return r},renderView:function(t,e){var n,i,r=t.id,o=this._views,a=!0;return r in o&&((n=o[r]).model===t?(i=n.FLAG_INSERT,a=!1):this.removeView(t)),a&&(i=((n=o[r]=this.createViewForModel(t)).paper=this).registerUnmountedView(n)|this.FLAG_INIT|n.getFlag(Ds(n,"initFlag"))),this.requestViewUpdate(n,i,n.UPDATE_PRIORITY,e),n},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(){ws(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(function(t){return t.getAttribute("model-id")}),a=this.model.get("cells");Zu(t,function(t,e){var n=a.get(t.getAttribute("model-id")),i=a.get(e.getAttribute("model-id")),r=n.attributes.z||0,o=i.attributes.z||0;return r===o?0:r<o?-1:1})},insertView:function(t,e){var n=this.getLayerView(Zd.CELLS),i=t.el,r=t.model;switch(this.options.sorting){case ff.APPROX:n.insertSortedNode(i,r.get("z"));break;case ff.EXACT:default:n.insertNode(i)}t.onMount(e)},detachView:function(t){t.unmount(),t.onDetach()},findView:function(t){var e=ds(t)?this.cells.querySelector(t):t instanceof iu?t[0]:t,n=this.findAttribute("model-id",e);if(n)return this._views[n]},findViewByModel:function(t){var e=ds(t)||cs(t)?t:t&&t.id;return this._views[e]},findViewsFromPoint:function(e){return e=new si(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=ms(t||{},{strict:!1}),e=new Ei(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)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t){for(var e,n=[],i=arguments.length-1;0<i--;)n[i]=arguments[i+1];"string"==typeof t&&(e=this).trigger.apply(e,["tools:event",t].concat(n))},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.matrix())},localToPaperRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.matrix())},paperToLocalPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.matrix().inverse())},localToClientPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.clientMatrix())},localToClientRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.clientMatrix())},clientToLocalPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,n,i){return this.localToPaperRect(t,e,n,i).offset(this.pageOffset())},pageToLocalPoint:function(t,e){var n=new si(t,e).difference(this.pageOffset());return this.paperToLocalPoint(n)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),o=new Ei(t,e,n,i);return o.x-=r.x,o.y-=r.y,this.paperToLocalRect(o)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new si(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof cf))throw new Error("Must provide a linkView.");var e=t.model,n=this.options,i=this.model,r=i.constructor.validations;return!(!n.multiLinks&&!r.multiLinks.call(this,i,e))&&(!(!n.linkPinning&&!r.linkPinning.call(this,i,e))&&!("function"==typeof n.allowLink&&!n.allowLink.call(this,t,this)))},getDefaultLink:function(t,e){return Ms(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t){void 0===t&&(t={});var e=t.highlighter,n=t.type,i=this.options,r=i.highlighting,o=i.highlighterNamespace;if(void 0===e){if(!r)return!1;if(n&&!1===(e=r[n]))return!1;e||(e=r.default)}if(!e)return!1;ds(e)&&(e={name:e});var a=e.name,s=o[a];if(!s)throw new Error('Unknown highlighter ("'+a+'")');if("function"!=typeof s.highlight)throw new Error('Highlighter ("'+a+'") is missing required highlight() method');if("function"!=typeof s.unhighlight)throw new Error('Highlighter ("'+a+'") is missing required unhighlight() method');return{highlighter:s,options:e.options||{},name:a}},onCellHighlight:function(t,e,n){var i=this.resolveHighlighter(n);if(i){var r=i.highlighter,o=i.options;r.highlight(t,e,o)}},onCellUnhighlight:function(t,e,n){var i=this.resolveHighlighter(n);if(i){var r=i.highlighter,o=i.options;r.unhighlight(t,e,o)}},pointerdblclick:function(t){t.preventDefault(),t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerdblclick(t,n.x,n.y):this.trigger("blank:pointerdblclick",t,n.x,n.y)}},pointerclick:function(t){if(this.eventData(t).mousemoved<=this.options.clickThreshold){t=Bu(t);var e=this.findView(t.target);if(this.guard(t,e))return;var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerclick(t,n.x,n.y):this.trigger("blank:pointerclick",t,n.x,n.y)}},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.contextMenuFired?this.contextMenuFired=!1:(t=Bu(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.contextmenu(t,n.x,n.y):this.trigger("blank:contextmenu",t,n.x,n.y)}},pointerdown:function(t){var e=(t=Bu(t)).target,n=t.button,i=this.findView(e),r=2===n;if(i){if(!r&&this.guard(t,i))return;var o=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName);this.options.preventDefaultViewAction&&!o&&t.preventDefault(),o&&i.preventDefaultInteraction(t);var a=this.customEventTrigger(t,i);if(a){if(a.isPropagationStopped())return;t.data=a.data}var s=e.closest("[magnet]");if(s&&i.el!==s&&i.el.contains(s)){var u=Bu(new iu.Event(t.originalEvent,{data:t.data,currentTarget:s}));if(this.onmagnet(u),u.isDefaultPrevented()&&t.preventDefault(),u.isPropagationStopped()){if(r)return;return void this.delegateDragEvents(i,u.data)}t.data=u.data}}if(r){this.contextMenuFired=!0;var l=new iu.Event(t.originalEvent,{type:"contextmenu",data:t.data});this.contextMenuTrigger(l)}else{var h=this.snapToGrid(t.clientX,t.clientY);i?i.pointerdown(t,h.x,h.y):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,h.x,h.y)),this.delegateDragEvents(i,t.data)}},pointermove:function(t){var e=this.eventData(t);if(e.mousemoved||(e.mousemoved=0,this.undelegateEvents()),!(++e.mousemoved<=this.options.moveThreshold)){t=Bu(t);var n=this.snapToGrid(t.clientX,t.clientY),i=e.sourceView;i?i.pointermove(t,n.x,n.y):this.trigger("blank:pointermove",t,n.x,n.y),this.eventData(t,e)}},pointerup:function(t){this.undelegateDocumentEvents();var e=Bu(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 iu.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseover(t);else{if(this.el===t.target)return;this.trigger("blank:mouseover",t)}},mouseout:function(t){t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseout(t);else{if(this.el===t.target)return;this.trigger("blank:mouseout",t)}},mouseenter:function(t){var e=(t=Bu(t)).target,n=t.relatedTarget,i=t.currentTarget,r=this.findView(e);if(!this.guard(t,r)){var o=this.findView(n);if(r){if(o===r)return;if(r.mouseenter(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseenter",t)}},mouseleave:function(t){var e=(t=Bu(t)).target,n=t.relatedTarget,i=t.currentTarget,r=this.findView(e);if(!this.guard(t,r)){var o=this.findView(n);if(r){if(o===r)return;if(r.mouseleave(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseleave",t)}},_processMouseWheelEvtBuf:_s(function(){var t=this._mw_evt_buffer,e=t.event,n=t.deltas.reduce(function(t,e){return t+Iu(e,50)},0),i=Math.pow(.995,n),r=this.clientToLocalPoint(e.clientX,e.clientY),o=r.x,a=r.y;this.trigger("paper:pinch",e,o,a,i),this._mw_evt_buffer={event:null,deltas:[]}},20,{maxWait:20}),mousewheel:function(t){t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=t.originalEvent,i=this.snapToGrid(n.clientX,n.clientY),r=Vu(n),o=r.deltaX,a=r.deltaY,s=this._events["paper:pinch"];if(t.ctrlKey&&s&&0<s.length)n.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(a),this._processMouseWheelEvtBuf();else{var u=Math.max(-1,Math.min(1,n.wheelDelta));e?e.mousewheel(t,i.x,i.y,u):this.trigger("blank:mousewheel",t,i.x,i.y,u),this.trigger("paper:pan",t,o,a)}}},onevent:function(t){var e=t.currentTarget,n=e.getAttribute("event");if(n){var i=this.findView(e);if(i){if(t=Bu(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);i.onevent(t,n,r.x,r.y)}}},magnetEvent:function(t,e){var n=t.currentTarget;if(n.getAttribute("magnet")){var i=this.findView(n);if(i){if(t=Bu(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);e.call(this,i,t,n,r.x,r.y)}}},onmagnet:function(t){if(2===t.button){this.contextMenuFired=!0,this.magnetContextMenuFired=!0;var e=new iu.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget});this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()}else this.magnetEvent(t,function(t,e,n,i,r){t.onmagnet(e,i,r)})},magnetpointerdblclick:function(t){this.magnetEvent(t,function(t,e,n,i,r){t.magnetpointerdblclick(e,n,i,r)})},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetContextMenuFired?this.magnetContextMenuFired=!1:this.magnetContextMenuTrigger(t)},magnetContextMenuTrigger:function(t){this.magnetEvent(t,function(t,e,n,i,r){t.magnetcontextmenu(e,n,i,r)})},onlabel:function(t){var e=t.currentTarget,n=this.findView(e);if(n&&(t=Bu(t),!this.guard(t,n))){var i=this.customEventTrigger(t,n,e);if(i){if(i.isPropagationStopped())return;t.data=i.data}var r=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,r.x,r.y)}},getPointerArgs:function(t){var e=Bu(t),n=this.snapToGrid(e.clientX,e.clientY);return[e,n.x,n.y]},delegateDragEvents:function(t,e){e||(e={}),this.eventData({data:e},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){if("mousedown"===t.type&&2===t.button)return!0;if(this.options.guard&&this.options.guard(t,e))return!0;if(t.data&&void 0!==t.data.guarded)return t.data.guarded;var n=t.target;return!!this.GUARDED_TAG_NAMES.includes(n.tagName)||!(e&&e.model&&e.model instanceof Wl)&&(this.el!==n&&!this.svg.contains(n))},setGridSize:function(t){var e=this.options;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(Zd.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(Zd.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",n=t.size||"auto auto",i=this.scale(),r=this.translate();hs(e)&&(e=r.tx+i.sx*(e.x||0)+"px "+(r.ty+i.sy*(e.y||0))+"px");hs(n)&&(n=(n=new Ei(n).scale(i.sx,i.sy)).width+"px "+n.height+"px");var o=this.childNodes.background;o.style.backgroundSize=n,o.style.backgroundPosition=e},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var n,i=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,a=Math.abs(e.quality)||1,s=this.constructor.backgroundPatterns[Us(r)];if(Ms(s)){t.width*=a,t.height*=a;var u=s(t,e);if(!(u instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=u.toDataURL("image/png"),r="repeat",hs(i)?(i.width*=u.width/t.width,i.height*=u.height/t.height):void 0===i&&(e.size={width:u.width/a,height:u.height/a})}else n=t.src,void 0===i&&(e.size={width:t.width,height:t.height});this.childNodes.background.style.opacity=o,this.childNodes.background.style.backgroundRepeat=r,this.childNodes.background.style.backgroundImage="url("+n+")",this.updateBackgroundImage(e)}}else this.childNodes.background.style.backgroundImage=""},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){if(t=t||{},this.updateBackgroundColor(t.color),t.image){t=this._background=Es(t),Fu(t);var e=document.createElement("img");e.onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image}else this.drawBackgroundImage(null),this._background=null;return this},setInteractivity:function(t){this.options.interactive=t,ws(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!hs(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name;if(e||(e=n+this.svg.id+Mu(JSON.stringify(t))),!this.isDefined(e)){var i=tl,r=i[n]&&i[n](t.args||{});if(!r)throw new Error("Non-existing filter "+n);var o=fs({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});su(r,o).appendTo(this.defs)}return e},defineGradient:function(t){if(!hs(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");var e=this.svg,n=this.defs,i=t.type,r=t.id;void 0===r&&(r=i+e.id+Mu(JSON.stringify(t)));var o=t.stops,a=t.attrs;if(void 0===a&&(a={}),this.isDefined(r))return r;var s=Cs(o).map(function(t){var e=t.offset,n=t.color,i=t.opacity;return su("stop").attr({offset:e,"stop-color":n,"stop-opacity":Number.isFinite(i)?i:1})}),u=su(i,a,s);return u.id=r,u.appendTo(n),r},definePattern:function(t){if(!hs(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e=this.svg,n=this.defs,i=t.id;void 0===i&&(i=e.id+Mu(JSON.stringify(t)));var r=t.markup,o=t.attrs;if(void 0===o&&(o={}),!r)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(i))return i;var a=su("pattern",{patternUnits:"userSpaceOnUse"});if(a.id=i,a.attr(o),"string"==typeof r)a.append(su(r));else{var s=ku(r).fragment;a.append(s)}return a.appendTo(n),i},defineMarker:function(t){if(!hs(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");var e=this.svg,n=this.defs,i=t.id;void 0===i&&(i=e.id+Mu(JSON.stringify(t)));var r=t.markup,o=t.attrs;void 0===o&&(o={});var a=t.markerUnits;if(void 0===a&&(a="userSpaceOnUse"),this.isDefined(i))return i;var s,u=su("marker",{orient:"auto",overflow:"visible",markerUnits:a});if(u.id=i,u.attr(o),r){var l;if("string"==typeof r)l=su(r),l=Array.isArray(l)?l:[l];else{var h=ku(r).fragment;l=su(h).children()}s=1<l.length?su("g").append(l):l[0]}else{var c=t.type;void 0===c&&(c="path"),s=su(c)}var d=js(t,"type","id","markup","attrs","markerUnits");return Object.keys(d).forEach(function(t){var e=d[t],n=s.attr(t);if(null==n)s.attr(t,e);else switch(t){case"transform":s.attr(t,e+" "+n)}}),s.appendTo(u),u.appendTo(n),i},customEventTrigger:function(t,e,n){void 0===n&&(n=e.el);var i=t.target.closest("[event]");if(i&&n!==i&&e.el.contains(i)){var r=Bu(new iu.Event(t.originalEvent,{data:t.data,currentTarget:i}));return this.onevent(r),r.isDefaultPrevented()&&t.preventDefault(),r}return null}},{sorting:ff,Layers:Zd,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,n,i),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,n,i),e},flipX:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(2*n,0),r.scale(-1,1),r.drawImage(t,0,0,n,i),e},flipY:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(0,2*i),r.scale(1,-1),r.drawImage(t,0,0,n,i),e},watermark:function(t,e){e=e||{};var n=t.width,i=t.height,r=document.createElement("canvas");r.width=3*n,r.height=3*i;for(var o=r.getContext("2d"),a=cs(e.watermarkAngle)?-e.watermarkAngle:-20,s=Gn(a),u=r.width/4,l=r.height/4,h=0;h<4;h++)for(var c=0;c<4;c++)0<(h+c)%2&&(o.setTransform(1,0,0,1,(2*h-1)*u,(2*c-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){su(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){su(t).attr({fill:e.color})},update:function(t,e,n){var i=n.scale(),r=i.sx,o=i.sy,a=r<=1?e.thickness:e.thickness/r,s=o<=1?e.thickness:e.thickness/o;su(t).attr({width:a,height:s})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=0<=i-o&&0<=r-o?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",su(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=0<=i-o&&0<=r-o?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",su(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=0<=i-o&&0<=r-o?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",su(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}]}}),bf=rc.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){var e=this.paper,n=this.relatedView;return!e||!n||e.guard(t,n)}}),wf=rc.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=fs(this.options,t)).tools;if(!Array.isArray(e))return this;var n=t.relatedView;if(!(n instanceof rf))return this;for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var a=e[r];a instanceof bf&&(a.configure(n,this),this.vel.append(a.el),i.push(a))}return this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t||(t={});var e=this.tools;if(!e)return this;for(var n=this.isRendered,i=0,r=e.length;i<r;i++){var o=e[i];n?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return this.isMounted()||this.mount(),n||(this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,n=t.length;e<n;e++)t[e].remove();this.tools=null},mount:function(){var t=this.options,e=this.el,n=t.relatedView,i=t.layer;void 0===i&&(i=Zd.TOOLS);var r=t.z;return n&&(i?n.paper.getLayerView(i).insertSortedNode(e,r):n.el.appendChild(e)),this}}),xf={Graph:$d,attributes:Hl,LayersNames:Zd,PaperLayer:Jd,Cell:Wl,CellView:rf,Element:fh,ElementView:lf,Link:ph,LinkView:cf,Paper:yf,ToolView:bf,ToolsView:wf,HighlighterView:xc},Af=rc.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 n=this.vel,i=this.options.scale,r=su.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()}}),Tf=bf.extend({name:"vertices",options:{handleClass:Af,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,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},onRender:function(){return this.options.vertexAdding&&(this.renderChildren(),this.updatePath()),this.resetHandles(),this.renderHandles(),this},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 e=this,t=this.relatedView.model.vertices(),n=0,i=t.length;n<i;n++){var r=t[n],o=new this.options.handleClass({index:n,paper:this.paper,scale:this.options.scale,guard:function(t){return e.guard(t)}});o.render(),o.position(r.x,r.y),this.simulateRelatedView(o.el),o.vel.appendTo(this.el),this.handles.push(o),this.startHandleListening(o)}},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.childNodes.connection;t&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var e=this.options,n=e.vertexRemoving;void 0===n&&(n=!0);var i=e.vertexMoving;void 0===i&&(i=!0),i&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),n&&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,r=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:new si(i),next:new si(r)}},onHandleWillChange:function(t,e){this.focus();var n=this.relatedView,i=this.options;n.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerdown.apply(n,n.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var n=this.options,i=this.relatedView,r=t.options.index,o=i.paper.getPointerArgs(e),a=o[0],s=o[1],u=o[2],l={x:s,y:u};this.snapVertex(l,r),i.model.vertex(r,l,{ui:!0,tool:this.cid}),t.position(l.x,l.y),n.stopPropagation||i.notifyPointermove(a,s,u)},onHandleChanged:function(t,e){var n=this.options,i=this.relatedView;if(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});var r=i.paper.getPointerArgs(e),o=r[0],a=r[1],s=r[2];n.stopPropagation||i.notifyPointerup(o,a,s),i.checkMouseleave(o)}else i.checkMouseleave(Bu(e))},snapVertex:function(t,e){var n=this.options.snapRadius;if(0<n){var i=this.getNeighborPoints(e),r=i.prev,o=i.next;Math.abs(t.x-r.x)<n?t.x=r.x:Math.abs(t.x-o.x)<n&&(t.x=o.x),Math.abs(t.y-r.y)<n?t.y=i.prev.y:Math.abs(t.y-o.y)<n&&(t.y=o.y)}},onHandleRemove:function(t,e){var n=t.options.index,i=this.relatedView;i.model.removeVertex(n,{ui:!0}),this.options.vertexAdding&&this.updatePath(),i.checkMouseleave(Bu(e))},onPathPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=Bu(t),n=this.paper.snapToGrid(e.clientX,e.clientY).toJSON(),i=this.relatedView;i.model.startBatch("vertex-add",{ui:!0,tool:this.cid});var r=i.getVertexIndex(n.x,n.y);this.snapVertex(n,r),i.model.insertVertex(r,n,{ui:!0,tool:this.cid}),this.update();var o=this.handles[r];this.eventData(e,{vertexAdded:!0}),o.onPointerDown(e)}},onRemove:function(){this.resetHandles()}},{VertexHandle:Af});function Pf(t,e){var n=t.model;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}function Ef(t,e,n){return zc.call(this.paper,{},e,n,t,this.model).anchor}var Sf=rc.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,o=su.createSVGMatrix().translate(t,e).rotate(n);r&&(o=o.scale(r));var a=this.childNodes.handle;a.setAttribute("transform",su.matrixToTransformString(o)),a.setAttribute("cursor",n%180==0?"row-resize":"col-resize");var s=i.getClosestPoint(new si(t,e)),u=this.childNodes.line;u.setAttribute("x1",t),u.setAttribute("y1",e),u.setAttribute("x2",s.x),u.setAttribute("y2",s.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"}}),kf=bf.extend({name:"segments",precision:.5,options:{handleClass:Sf,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:Ef,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],a=this.renderHandle(r,o);this.simulateRelatedView(a.el),this.handles.push(a),a.options.index=n}return this},renderHandle:function(t,e){var n=this,i=new this.options.handleClass({paper:this.paper,scale:this.options.scale,guard:function(t){return n.guard(t)}});return i.render(),this.updateHandle(i,t,e),i.vel.appendTo(this.el),this.startHandleListening(i),i},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(),o=t.options.axis,a=r[i-2]||n.sourceAnchor,s=r[i+1]||n.targetAnchor,u=this.options.snapRadius;return Math.abs(e[o]-a[o])<u?e[o]=a[o]:Math.abs(e[o]-s[o])<u&&(e[o]=s[o]),e},onHandleChanging:function(t,e){var n=this.options,i=this.eventData(e),r=this.relatedView,o=r.paper,a=t.options.index-1,s=Bu(e),u=o.snapToGrid(s.clientX,s.clientY),l=this.snapHandle(t,u.clone(),i),h=t.options.axis,c=this.options.snapHandle?0:u[h]-l[h],d=r.model,f=Es(d.vertices()),p=this.options.anchor;"function"!=typeof p&&(p=null);var g=t.options.index,v=[r.sourcePoint.clone()].concat(f,[r.targetPoint.clone()]),m=0;if(0<=g-1){var y=v[g-1],b=v[g];new ci(y,b).vector().theta()%90!=0&&(f.splice(g-1,0,i.originalVertices[g-1]),m++,this.shiftHandleIndexes(1))}var w=f[a+m],x=f[a+1+m];if(g+2<v.length){var A=v[g+1],T=v[g+2];if(new ci(A,T).vector().theta()%90!=0){var P=1===i.originalVertices.length,E=P?0:g,S=i.firstHandleShifted&&!P?1:0,k=1+m;f.splice(g+k,0,i.originalVertices[E-S])}}var M=r.sourceView,L=r.sourceBBox,C=!1,_=!1;if(w?0===a?L.containsPoint(w)?(f.shift(),this.shiftHandleIndexes(-1),C=!0):(w[h]=l[h],_=!0):w[h]=l[h]:((w=r.sourceAnchor.toJSON())[h]=l[h],L.containsPoint(w)?(w[h]=l[h],C=!0):(f.unshift(w),this.shiftHandleIndexes(1),_=i.firstHandleShifted=!0)),p&&M){if(C){var N=i.sourceAnchor.clone();N[h]=l[h];var O=p.call(r,N,M,r.sourceMagnet||M.el,"source",r);this.resetAnchor("source",O)}_&&this.resetAnchor("source",i.sourceAnchorDef)}var R=r.targetView,F=r.targetBBox,B=!1,V=!1;if(x?a===f.length-2?F.containsPoint(x)?(f.pop(),B=!0):(x[h]=l[h],V=!0):x[h]=l[h]:((x=r.targetAnchor.toJSON())[h]=l[h],F.containsPoint(x)?B=!0:(f.push(x),V=!0)),p&&R){if(B){var I=i.targetAnchor.clone();I[h]=l[h];var D=p.call(r,I,R,r.targetMagnet||R.el,"target",r);this.resetAnchor("target",D)}V&&this.resetAnchor("target",i.targetAnchorDef)}if(f.some(function(t){return!t}))throw new Error("Segments: incompatible router in use");d.vertices(f,{ui:!0,tool:this.cid}),this.updateHandle(t,w,x,c),n.stopPropagation||r.notifyPointermove(s,u.x,u.y)},onHandleChangeStart:function(t,e){var n=this.options,i=this.handles,r=this.relatedView,o=r.model,a=r.paper,s=t.options.index;if(Array.isArray(i)){for(var u=0,l=i.length;u<l;u++)u!==s&&i[u].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:Ps(o.prop(["source","anchor"])),targetAnchorDef:Ps(o.prop(["target","anchor"])),originalVertices:Es(o.vertices()),firstHandleShifted:!1}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||r.notifyPointerdown.apply(r,a.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var n=this.options,i=this.relatedView,r=i.paper,o=i.model;n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid});var a=Bu(e),s=r.snapToGrid(a.clientX,a.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerup(a,s.x,s.y),i.checkMouseleave(a)},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;if(r||o){var a=new ci(e,n);if(a.length()<this.options.segmentLengthThreshold)t.hide();else{var s=a.midpoint(),u=r?"x":"y";s[u]+=i||0;var l=a.vector().vectorAngle(new si(1,0));t.position(s.x,s.y,l,this.relatedView),t.show(),t.options.axis=u}}else t.hide()},onRemove:function(){this.resetHandles()}},{SegmentHandle:Sf}),Mf=bf.extend({tagName:"path",xAxisVector:new si(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{scale:null},onRender:function(){this.update()},update:function(){var t,e,n=this.ratio,i=this.relatedView,r=i.getTangentAtRatio(n);if(e=r?(t=r.start,r.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(n),0),!t)return this;var o=su.createSVGMatrix().translate(t.x,t.y).rotate(e),a=this.options.scale;return a&&(o=o.scale(a)),this.vel.transform(o,{absolute:!0}),this},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.relatedView;e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),e.paper.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none"}},onPointerMove:function(t){var e=Bu(t),n=this.paper.snapToGrid(e.clientX,e.clientY);this.relatedView.pointermove(e,n.x,n.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,i=Bu(t),r=n.snapToGrid(i.clientX,i.clientY);e.pointerup(i,r.x,r.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),Lf=Mf.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"}}),Cf=Mf.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=bf.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 t=this.relatedView,e=this.options,n=this.vel,i=e.useModelGeometry,r=e.rotate,o=Ju(e.padding),a=Pf(t,i).moveAndExpand({x:-o.left,y:-o.top,width:o.left+o.right,height:o.top+o.bottom}),s=t.model;if(s.isElement()){var u=s.angle();if(u)if(r){var l=s.getBBox().center();n.rotate(u,l.x,l.y,{absolute:!0})}else a=a.bbox(u)}return n.attr(a.toJSON()),this}}),Nf=bf.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){var a=o.options.snapRadius,s="source"===i,u=s?0:-1,l=this.model.vertex(u)||this.getEndAnchor(s?"target":"source");return l&&(Math.abs(l.x-t.x)<a&&(t.x=l.x),Math.abs(l.y-t.y)<a&&(t.y=l.y)),t},anchor:Ef,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 e=t.anchor;if(e){var n=this.relatedView,i=this.type,r=n.getEndAnchor(i),o=this.options,a=n.model.prop([i,"anchor"]),s="translate("+r.x+","+r.y+")";o.scale&&(s+=" scale("+o.scale+")"),e.setAttribute("transform",s);var u=a?o.customAnchorAttributes:o.defaultAnchorAttributes;for(var l in u)e.setAttribute(l,u[l])}}},updateArea:function(){var t=this.childNodes;if(t){var e=t.area;if(e){var n,i,r,o=this.relatedView,a=this.type,s=o.getEndView(a),u=s.model,l=o.getEndMagnet(a),h=this.options.areaPadding;isFinite(h)||(h=0),s.isNodeConnection(l)?(i=0,r=(n=s.getNodeBBox(l)).center()):(n=s.getNodeUnrotatedBBox(l),i=u.angle(),r=n.center(),i&&r.rotate(u.getBBox().center(),-i)),n.inflate(h),e.setAttribute("x",-n.width/2),e.setAttribute("y",-n.height/2),e.setAttribute("width",n.width),e.setAttribute("height",n.height),e.setAttribute("transform","translate("+r.x+","+r.y+") rotate("+i+")")}}},toggleArea:function(t){var e=this.childNodes;if(e){var n=e.area;n&&(n.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=this.relatedView,i=this.type,r=n.getEndView(i),o=r.model,a=n.getEndMagnet(i),s=Bu(t),u=this.paper.clientToLocalPoint(s.clientX,s.clientY),l=this.options.snap;if("function"==typeof l&&(u=l.call(n,u,r,a,i,n,this),u=new si(u)),this.options.restrictArea)if(r.isNodeConnection(a)){var h=r.getClosestPoint(u);h&&(u=h)}else{var c=r.getNodeUnrotatedBBox(a),d=o.angle(),f=o.getBBox().center(),p=u.clone().rotate(f,d);c.containsPoint(p)||(u=c.pointNearestToPoint(p).rotate(f,-d))}var g=this.options.anchor;"function"==typeof g&&(e=g.call(n,u,r,a,i,n)),this.resetAnchor(e),this.update()},onPointerUp:function(t){var e=Bu(t);this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1);var n=this.relatedView;this.options.redundancyRemoval&&n.removeRedundantLinearVertices({ui:!0,tool:this.cid}),n.checkMouseleave(e),n.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(!0===t&&(t=null),this.resetAnchor(Es(t)),this.update())}}),Of=Nf.extend({name:"source-anchor",type:"source"}),Rf=Nf.extend({name:"target-anchor",type:"target"}),Ff=bf.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(){this.vel.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix:function(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix:function(){var t=this.relatedView,e=this.options,n=e.x;void 0===n&&(n=0);var i=e.y;void 0===i&&(i=0);var r=e.offset;void 0===r&&(r={});var o=e.useModelGeometry,a=e.rotate,s=e.scale,u=Pf(t,o),l=t.model.angle();a||(u=u.bbox(l));var h=r.x;void 0===h&&(h=0);var c=r.y;void 0===c&&(c=0),zu(n)?n=parseFloat(n)/100*u.width:Nn(n)&&(n=Number(Fn(n,u))),zu(i)?i=parseFloat(i)/100*u.height:Nn(i)&&(i=Number(Fn(i,u)));var d=su.createSVGMatrix().translate(u.x+u.width/2,u.y+u.height/2);return a&&(d=d.rotate(l)),d=d.translate(n+h-u.width/2,i+c-u.height/2),s&&(d=d.scale(s)),d},getLinkMatrix:function(){var t=this.relatedView,e=this.options,n=e.offset;void 0===n&&(n=0);var i=e.distance;void 0===i&&(i=0);var r,o,a,s=e.rotate,u=e.scale;a=(r=zu(i)?t.getTangentAtRatio(parseFloat(i)/100):t.getTangentAtLength(i))?(o=r.start,r.vector().vectorAngle(new si(1,0))||0):(o=t.getConnection().start,0);var l=su.createSVGMatrix().translate(o.x,o.y).rotate(a).translate(0,n);return s||(l=l.rotate(-a)),u&&(l=l.scale(u)),l},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.options.action;"function"==typeof e&&e.call(this.relatedView,t,this.relatedView,this)}}}),Bf=Ff.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})}}}),Vf=Ff.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:function(t){return t.el},action:function(t,e,n){return n.dragstart(t)}},getMagnetNode:function(){var t,e=this.options,n=this.relatedView,i=e.magnet;switch(typeof i){case"function":t=i.call(this,n,this);break;case"string":t=n.findNode(i);break;default:t=i}if(t||(t=n.el),t instanceof SVGElement)return t;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var e=this.paper,n=this.relatedView,i=Bu(t),r=e.clientToLocalPoint(i.clientX,i.clientY),o=r.x,a=r.y;n.dragLinkStart(i,this.getMagnetNode(),o,a),e.undelegateEvents(),this.delegateDocumentEvents(null,i.data),this.focus()},drag:function(t){var e=this.paper,n=this.relatedView,i=Bu(t),r=e.snapToGrid(i.clientX,i.clientY),o=r.x,a=r.y;n.dragLink(i,o,a)},dragend:function(t){var e=this.paper,n=this.relatedView,i=Bu(t),r=e.snapToGrid(i.clientX,i.clientY),o=r.x,a=r.y;n.dragLinkEnd(i,o,a),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),n.checkMouseleave(i)}}),If=Vf.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:function(){var t=this.options,e=this.defaultMarkup;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"},Vf.prototype.events),onRender:function(){this.renderChildren(),this.update()},trackPath:null,update:function(){var t=this.childNodes;this.trackPath=this.getTrackPath(),Vf.prototype.update.apply(this,arguments),t.track.setAttribute("d",this.trackPath.serialize())},position:function(){var t=this.el;this.childNodes.button.setAttribute("transform",su.matrixToTransformString(this.getButtonMatrix())),t.setAttribute("transform",su.matrixToTransformString(this.getTrackMatrix()))},getButtonMatrix:function(){var t=this.options,e=this.trackPath,n=t.offset;void 0===n&&(n=0);var i=t.distance;void 0===i&&(i=0);var r,o,a,s=t.rotate,u=t.scale;a=(r=zu(i)?e.tangentAtRatio(parseFloat(i)/100):e.tangentAtLength(i))?(o=r.start,r.vector().vectorAngle(new si(1,0))||0):(o=e.start,0);var l=su.createSVGMatrix().translate(o.x,o.y).rotate(a).translate(0,n);return s||(l=l.rotate(-a)),u&&(l=l.scale(u)),l},getTrackPath:function(){return this.relatedView.getConnection()},getTrackMatrix:function(){return su.createSVGMatrix()},getTrackRatioFromEvent:function(t){var e=this.relatedView,n=this.trackPath,i=e.paper.clientToLocalPoint(t.clientX,t.clientY),r=su.transformPoint(i,this.getTrackMatrix().inverse());return n.closestPointLength(r)},canShowButton:function(){return iu.event.has(this.paper.el)},showButton:function(){this.childNodes.button.style.display="block"},hideButton:function(){this.childNodes.button.style.display=""},onMousemove:function(t){if(this.trackPath){this.options.distance=this.getTrackRatioFromEvent(t),this.position()}},onMouseenter:function(){this.canShowButton()&&this.showButton()},onMouseleave:function(){this.hideButton()}}),Df={Vertices:Tf,Segments:kf,TargetArrowhead:Lf,SourceArrowhead:Cf,Boundary:_f,SourceAnchor:Of,TargetAnchor:Rf,Button:Ff,Remove:Bf,Connect:Vf,HoverConnect:If},jf=bf.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 t=this.childNodes,e=t.handle,n=t.extras;if(!e)throw new Error("Control: markup selector `handle` is required");return this.updateHandle(e),n&&this.updateExtras(n),this},updateHandle:function(t){var e=this.relatedView,n=this.options,i=e.model,r=this.getPosition(e,this),o=i.getAbsolutePointFromRelative(r),a=n.handleAttributes,s=n.scale,u="translate("+o.x+","+o.y+")";if(s&&(u+=" scale("+s+")"),t.setAttribute("transform",u),a)for(var l in a)t.setAttribute(l,a[l])},updateExtras:function(t){var e=this.relatedView,n=this.options,i=this.options.selector;if(i){var r=e.findNode(i);if(!r)throw new Error("Control: invalid selector.");var o=n.padding;isFinite(o)||(o=0);var a=e.getNodeUnrotatedBBox(r),s=e.model,u=s.angle(),l=a.center();u&&l.rotate(s.getBBox().center(),-u),a.inflate(o),t.setAttribute("x",-a.width/2),t.setAttribute("y",-a.height/2),t.setAttribute("width",a.width),t.setAttribute("height",a.height),t.setAttribute("transform","translate("+l.x+","+l.y+") rotate("+u+")")}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var e=this.relatedView,n=this.paper;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 e=this.relatedView,n=this.paper,i=e.model,r=Bu(t),o=r.clientX,a=r.clientY,s=n.clientToLocalPoint(o,a),u=i.getRelativePointFromAbsolute(s);this.setPosition(e,u,this),this.update()},onPointerUp:function(t){var e=this.relatedView;this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.relatedView;this.resetPosition(t,this),this.update()}}),zf=If.extend({getTrackPath:function(){var t=this.relatedView,e=this.options,n=e.useModelGeometry,i=e.trackPath;(void 0===i&&(i="M 0 0 H calc(w) V calc(h) H 0 Z"),"function"==typeof i&&(i=i.call(this,t)),Nn(i))&&(i=Fn(i,Pf(t,n)));return new Ii(su.normalizePathData(i))},getTrackMatrix:function(){var t=this.relatedView,e=this.options,n=e.useModelGeometry,i=e.rotate,r=Pf(t,n),o=t.model.angle();i||(r=r.bbox(o));var a=su.createSVGMatrix().translate(r.x+r.width/2,r.y+r.height/2);return i&&(a=a.rotate(o)),a=a.translate(-r.width/2,-r.height/2)}}),Gf={Button:Ff,Remove:Bf,Connect:Vf,Boundary:_f,HoverConnect:zf,Control:jf},Uf=su,Hf={PortLabel:lh,Port:ih};return t.V=su,t.Vectorizer=Uf,t.anchors=Yd,t.config=xu,t.connectionPoints=Rc,t.connectionStrategies=Gc,t.connectors=Qh,t.dia=xf,t.elementTools=Gf,t.env=gh,t.format={},t.g=Mr,t.highlighters=Mc,t.layout=Hf,t.linkAnchors=qd,t.linkTools=Df,t.mvc=bc,t.routers=jd,t.setTheme=function(t,e){ws(ic,"setTheme",t,e=e||{}),rc.prototype.defaultTheme=t},t.shapes=Lh,t.ui={},t.util=Jl,t.version="4.0.2",t}({});if(void 0!==joint)var g=joint.g,V=joint.V,Vectorizer=joint.V;
|
|
8
|
+
var joint=function(t){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t,e){return t(e={exports:{}},e.exports),e.exports}var i=function(t){return t&&t.Math==Math&&t},h=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof e&&e)||function(){return this}()||Function("return this")(),a=function(t){try{return!!t()}catch(t){return!0}},s=!a(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),r={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,u={f:o&&!r.call({1:2},1)?function(t){var e=o(this,t);return!!e&&e.enumerable}:r},w=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},l={}.toString,c=function(t){return l.call(t).slice(8,-1)},d="".split,x=a(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==c(t)?d.call(t,""):Object(t)}:Object,f=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},p=function(t){return x(f(t))},g=function(t){return"object"==typeof t?null!==t:"function"==typeof t},v=function(t,e){if(!g(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!g(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!g(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!g(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},m={}.hasOwnProperty,y=function(t,e){return m.call(t,e)},b=h.document,A=g(b)&&g(b.createElement),P=function(t){return A?b.createElement(t):{}},T=!s&&!a(function(){return 7!=Object.defineProperty(P("div"),"a",{get:function(){return 7}}).a}),E=Object.getOwnPropertyDescriptor,S={f:s?E:function(t,e){if(t=p(t),e=v(e,!0),T)try{return E(t,e)}catch(t){}if(y(t,e))return w(!u.f.call(t,e),t[e])}},k=function(t){if(!g(t))throw TypeError(String(t)+" is not an object");return t},M=Object.defineProperty,L={f:s?M:function(t,e,n){if(k(t),e=v(e,!0),k(n),T)try{return M(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}},C=s?function(t,e,n){return L.f(t,e,w(1,n))}:function(t,e,n){return t[e]=n,t},_=function(e,n){try{C(h,e,n)}catch(t){h[e]=n}return n},N="__core-js_shared__",O=h[N]||_(N,{}),R=Function.toString;"function"!=typeof O.inspectSource&&(O.inspectSource=function(t){return R.call(t)});var F,B,V,I=O.inspectSource,D=h.WeakMap,j="function"==typeof D&&/native code/.test(I(D)),z=n(function(t){(t.exports=function(t,e){return O[t]||(O[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),G=0,U=Math.random(),H=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++G+U).toString(36)},q=z("keys"),W=function(t){return q[t]||(q[t]=H(t))},Y={},X=h.WeakMap;if(j){var $=O.state||(O.state=new X),Z=$.get,J=$.has,K=$.set;F=function(t,e){return e.facade=t,K.call($,t,e),e},B=function(t){return Z.call($,t)||{}},V=function(t){return J.call($,t)}}else{var Q=W("state");Y[Q]=!0,F=function(t,e){return e.facade=t,C(t,Q,e),e},B=function(t){return y(t,Q)?t[Q]:{}},V=function(t){return y(t,Q)}}var tt,et={set:F,get:B,has:V,enforce:function(t){return V(t)?B(t):F(t,{})},getterFor:function(n){return function(t){var e;if(!g(t)||(e=B(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},nt=n(function(t){var e=et.get,u=et.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,a=!!i&&!!i.enumerable,s=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||y(n,"name")||C(n,"name",e),(r=u(n)).source||(r.source=l.join("string"==typeof e?e:""))),t!==h?(o?!s&&t[e]&&(a=!0):delete t[e],a?t[e]=n:C(t,e,n)):a?t[e]=n:_(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||I(this)})}),it=h,rt=function(t){return"function"==typeof t?t:void 0},ot=function(t,e){return arguments.length<2?rt(it[t])||rt(h[t]):it[t]&&it[t][e]||h[t]&&h[t][e]},at=Math.ceil,st=Math.floor,ut=function(t){return isNaN(t=+t)?0:(0<t?st:at)(t)},lt=Math.min,ht=function(t){return 0<t?lt(ut(t),9007199254740991):0},ct=Math.max,dt=Math.min,ft=function(l){return function(t,e,n){var i,r,o,a=p(t),s=ht(a.length),u=(i=s,(r=ut(n))<0?ct(r+i,0):dt(r,i));if(l&&e!=e){for(;u<s;)if((o=a[u++])!=o)return!0}else for(;u<s;u++)if((l||u in a)&&a[u]===e)return l||u||0;return!l&&-1}},pt={includes:ft(!0),indexOf:ft(!1)},gt=pt.indexOf,vt=function(t,e){var n,i=p(t),r=0,o=[];for(n in i)!y(Y,n)&&y(i,n)&&o.push(n);for(;e.length>r;)y(i,n=e[r++])&&(~gt(o,n)||o.push(n));return o},mt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],yt=mt.concat("length","prototype"),bt={f:Object.getOwnPropertyNames||function(t){return vt(t,yt)}},wt={f:Object.getOwnPropertySymbols},xt=ot("Reflect","ownKeys")||function(t){var e=bt.f(k(t)),n=wt.f;return n?e.concat(n(t)):e},At=function(t,e){for(var n=xt(e),i=L.f,r=S.f,o=0;o<n.length;o++){var a=n[o];y(t,a)||i(t,a,r(e,a))}},Pt=/#|\.prototype\./,Tt=function(t,e){var n=St[Et(t)];return n==Mt||n!=kt&&("function"==typeof e?a(e):!!e)},Et=Tt.normalize=function(t){return String(t).replace(Pt,".").toLowerCase()},St=Tt.data={},kt=Tt.NATIVE="N",Mt=Tt.POLYFILL="P",Lt=Tt,Ct=S.f,_t=function(t,e){var n,i,r,o,a,s=t.target,u=t.global,l=t.stat;if(n=u?h:l?h[s]||_(s,{}):(h[s]||{}).prototype)for(i in e){if(o=e[i],r=t.noTargetGet?(a=Ct(n,i))&&a.value:n[i],!Lt(u?i:s+(l?".":"#")+i,t.forced)&&void 0!==r){if(typeof o==typeof r)continue;At(o,r)}(t.sham||r&&r.sham)&&C(o,"sham",!0),nt(n,i,o,t)}},Nt=!!Object.getOwnPropertySymbols&&!a(function(){return!String(Symbol())}),Ot=Nt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Rt=z("wks"),Ft=h.Symbol,Bt=Ot?Ft:Ft&&Ft.withoutSetter||H,Vt=function(t){return y(Rt,t)||(Nt&&y(Ft,t)?Rt[t]=Ft[t]:Rt[t]=Bt("Symbol."+t)),Rt[t]},It=Object.keys||function(t){return vt(t,mt)},Dt=s?Object.defineProperties:function(t,e){k(t);for(var n,i=It(e),r=i.length,o=0;o<r;)L.f(t,n=i[o++],e[n]);return t},jt=ot("document","documentElement"),zt="prototype",Gt="script",Ut=W("IE_PROTO"),Ht=function(){},qt=function(t){return"<script>"+t+"</"+Gt+">"},Wt=function(){try{tt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;Wt=tt?function(t){t.write(qt("")),t.close();var e=t.parentWindow.Object;return t=null,e}(tt):((e=P("iframe")).style.display="none",jt.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(qt("document.F=Object")),t.close(),t.F);for(var n=mt.length;n--;)delete Wt[zt][mt[n]];return Wt()};Y[Ut]=!0;var Yt=Object.create||function(t,e){var n;return null!==t?(Ht[zt]=k(t),n=new Ht,Ht[zt]=null,n[Ut]=t):n=Wt(),void 0===e?n:Dt(n,e)},Xt=Vt("unscopables"),$t=Array.prototype;null==$t[Xt]&&L.f($t,Xt,{configurable:!0,value:Yt(null)});var Zt=function(t){$t[Xt][t]=!0},Jt=Object.defineProperty,Kt={},Qt=function(t){throw t},te=function(t,e){if(y(Kt,t))return Kt[t];e||(e={});var n=[][t],i=!!y(e,"ACCESSORS")&&e.ACCESSORS,r=y(e,0)?e[0]:Qt,o=y(e,1)?e[1]:void 0;return Kt[t]=!!n&&!a(function(){if(i&&!s)return!0;var t={length:-1};i?Jt(t,1,{enumerable:!0,get:Qt}):t[1]=1,n.call(t,r,o)})},ee=pt.includes,ne=te("indexOf",{ACCESSORS:!0,1:0});_t({target:"Array",proto:!0,forced:!ne},{includes:function(t){return ee(this,t,1<arguments.length?arguments[1]:void 0)}}),Zt("includes");var ie=function(i,r,t){if(function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function")}(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)}},re=Function.call,oe=function(t,e,n){return ie(re,h[t].prototype[e],n)},ae=(oe("Array","includes"),function(t){return Object(f(t))}),se=Array.isArray||function(t){return"Array"==c(t)},ue=Vt("species"),le=function(t,e){var n;return se(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!se(n.prototype)?g(n)&&null===(n=n[ue])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},he=[].push,ce=function(f){var p=1==f,g=2==f,v=3==f,m=4==f,y=6==f,b=7==f,w=5==f||y;return function(t,e,n,i){for(var r,o,a=ae(t),s=x(a),u=ie(e,n,3),l=ht(s.length),h=0,c=i||le,d=p?c(t,l):g||b?c(t,0):void 0;h<l;h++)if((w||h in s)&&(o=u(r=s[h],h,a),f))if(p)d[h]=o;else if(o)switch(f){case 3:return!0;case 5:return r;case 6:return h;case 2:he.call(d,r)}else switch(f){case 4:return!1;case 7:he.call(d,r)}return y?-1:v||m?m:d}},de={forEach:ce(0),map:ce(1),filter:ce(2),some:ce(3),every:ce(4),find:ce(5),findIndex:ce(6),filterOut:ce(7)},fe=de.find,pe="find",ge=!0,ve=te(pe);pe in[]&&Array(1)[pe](function(){ge=!1}),_t({target:"Array",proto:!0,forced:ge||!ve},{find:function(t){return fe(this,t,1<arguments.length?arguments[1]:void 0)}}),Zt(pe);oe("Array","find");var me,ye,be,we=function(s){return function(t,e){var n,i,r=String(f(t)),o=ut(e),a=r.length;return o<0||a<=o?s?"":void 0:(n=r.charCodeAt(o))<55296||56319<n||o+1===a||(i=r.charCodeAt(o+1))<56320||57343<i?s?r.charAt(o):n:s?r.slice(o,o+2):i-56320+(n-55296<<10)+65536}},xe={codeAt:we(!1),charAt:we(!0)},Ae=!a(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Pe=W("IE_PROTO"),Te=Object.prototype,Ee=Ae?Object.getPrototypeOf:function(t){return t=ae(t),y(t,Pe)?t[Pe]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Te:null},Se=Vt("iterator"),ke=!1;[].keys&&("next"in(be=[].keys())?(ye=Ee(Ee(be)))!==Object.prototype&&(me=ye):ke=!0);var Me=null==me||a(function(){var t={};return me[Se].call(t)!==t});Me&&(me={}),y(me,Se)||C(me,Se,function(){return this});var Le={IteratorPrototype:me,BUGGY_SAFARI_ITERATORS:ke},Ce=L.f,_e=Vt("toStringTag"),Ne=function(t,e,n){t&&!y(t=n?t:t.prototype,_e)&&Ce(t,_e,{configurable:!0,value:e})},Oe={},Re=Le.IteratorPrototype,Fe=function(){return this},Be=Object.setPrototypeOf||("__proto__"in{}?function(){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 k(t),function(t){if(!g(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(e),i?n.call(t,e):t.__proto__=e,t}}():void 0),Ve=Le.IteratorPrototype,Ie=Le.BUGGY_SAFARI_ITERATORS,De=Vt("iterator"),je="values",ze="entries",Ge=function(){return this},Ue=xe.charAt,He="String Iterator",qe=et.set,We=et.getterFor(He);!function(t,e,n,i,r,o,a){var s,u,l;u=i,l=e+" Iterator",(s=n).prototype=Yt(Re,{next:w(1,u)}),Ne(s,l,!1),Oe[l]=Fe;var h,c,d,f=function(t){if(t===r&&y)return y;if(!Ie&&t in v)return v[t];switch(t){case"keys":case je:case ze:return function(){return new n(this,t)}}return function(){return new n(this)}},p=e+" Iterator",g=!1,v=t.prototype,m=v[De]||v["@@iterator"]||r&&v[r],y=!Ie&&m||f(r),b="Array"==e&&v.entries||m;if(b&&(h=Ee(b.call(new t)),Ve!==Object.prototype&&h.next&&(Ee(h)!==Ve&&(Be?Be(h,Ve):"function"!=typeof h[De]&&C(h,De,Ge)),Ne(h,p,!0))),r==je&&m&&m.name!==je&&(g=!0,y=function(){return m.call(this)}),v[De]!==y&&C(v,De,y),Oe[e]=y,r)if(c={values:f(je),keys:o?y:f("keys"),entries:f(ze)},a)for(d in c)!Ie&&!g&&d in v||nt(v,d,c[d]);else _t({target:e,proto:!0,forced:Ie||g},c)}(String,"String",function(t){qe(this,{type:He,string:String(t),index:0})},function(){var t,e=We(this),n=e.string,i=e.index;return i>=n.length?{value:void 0,done:!0}:(t=Ue(n,i),e.index+=t.length,{value:t,done:!1})});var Ye=function(e,t,n,i){try{return i?t(k(n)[0],n[1]):t(n)}catch(t){throw function(t){var e=t.return;if(void 0!==e)k(e.call(t)).value}(e),t}},Xe=Vt("iterator"),$e=Array.prototype,Ze=function(t,e,n){var i=v(e);i in t?L.f(t,i,w(0,n)):t[i]=n},Je={};Je[Vt("toStringTag")]="z";var Ke="[object z]"===String(Je),Qe=Vt("toStringTag"),tn="Arguments"==c(function(){return arguments}()),en=Ke?c:function(t){var e,n,i;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),Qe))?n:tn?c(e):"Object"==(i=c(e))&&"function"==typeof e.callee?"Arguments":i},nn=Vt("iterator"),rn=Vt("iterator"),on=!1;try{var an=0,sn={next:function(){return{done:!!an++}},return:function(){on=!0}};sn[rn]=function(){return this},Array.from(sn,function(){throw 2})}catch(t){}var un=!function(t,e){if(!e&&!on)return!1;var n=!1;try{var i={};i[rn]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n}(function(t){Array.from(t)});_t({target:"Array",stat:!0,forced:un},{from:function(t){var e,n,i,r,o,a,s,u=ae(t),l="function"==typeof this?this:Array,h=arguments.length,c=1<h?arguments[1]:void 0,d=void 0!==c,f=function(t){if(null!=t)return t[nn]||t["@@iterator"]||Oe[en(t)]}(u),p=0;if(d&&(c=ie(c,2<h?arguments[2]:void 0,2)),null!=f&&(l!=Array||void 0===(s=f)||Oe.Array!==s&&$e[Xe]!==s))for(o=(r=f.call(u)).next,n=new l;!(i=o.call(r)).done;p++)a=d?Ye(r,c,[i.value,p],!0):i.value,Ze(n,p,a);else for(n=new l(e=ht(u.length));p<e;p++)a=d?c(u[p],p):u[p],Ze(n,p,a);return n.length=p,n}});it.Array.from;var ln=de.findIndex,hn="findIndex",cn=!0,dn=te(hn);hn in[]&&Array(1)[hn](function(){cn=!1}),_t({target:"Array",proto:!0,forced:cn||!dn},{findIndex:function(t){return ln(this,t,1<arguments.length?arguments[1]:void 0)}}),Zt(hn);oe("Array","findIndex"),n(function(t,e){!function(){var t=e,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function u(t){this.message=t}(u.prototype=new Error).name="InvalidCharacterError",t.btoa||(t.btoa=function(t){for(var e,n,i=String(t),r=0,o=s,a="";i.charAt(0|r)||(o="=",r%1);a+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new u("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return a}),t.atob||(t.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new u("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,a="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)?a+=String.fromCharCode(255&n>>(-2*r&6)):0)i=s.indexOf(i);return a})}()});_t({target:"Number",stat:!0},{isNaN:function(t){return t!=t}});it.Number.isNaN;var fn=h.isFinite,pn=Number.isFinite||function(t){return"number"==typeof t&&fn(t)};_t({target:"Number",stat:!0},{isFinite:pn});it.Number.isFinite;var gn=Vt("match"),vn=function(t){if(g(e=t)&&(void 0!==(n=e[gn])?n:"RegExp"==c(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t},mn=Vt("match"),yn=function(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[mn]=!1,"/./"[e](n)}catch(t){}}return!1};_t({target:"String",proto:!0,forced:!yn("includes")},{includes:function(t){return!!~String(f(this)).indexOf(vn(t),1<arguments.length?arguments[1]:void 0)}});oe("String","includes");var bn,wn=S.f,xn="".startsWith,An=Math.min,Pn=yn("startsWith"),Tn=!(Pn||(!(bn=wn(String.prototype,"startsWith"))||bn.writable));_t({target:"String",proto:!0,forced:!Tn&&!Pn},{startsWith:function(t){var e=String(f(this));vn(t);var n=ht(An(1<arguments.length?arguments[1]:void 0,e.length)),i=String(t);return xn?xn.call(e,i,n):e.slice(n,n+i.length)===i}});oe("String","startsWith");!function(){function i(t,e){return this.slice(t,e)}function r(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function t(t){var e;if("number"==typeof t){e=new Array(t);for(var n=0;n<t;++n)e[n]=0}else e=t.slice(0);return e.subarray=i,(e.buffer=e).byteLength=e.length,e.set=r,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Uint8Array=t,window.Uint32Array=t,window.Int32Array=t)}();var En={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},Sn=Object.keys(En).map(function(t){return En[t]}).join(""),kn="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",Mn=/\s/g,Ln=new RegExp("^("+kn+"\\*)?(["+Sn+"])(/"+kn+")?([-+]{1,2}"+kn+")?$","g");function Cn(t){throw new Error("Invalid calc() expression: "+t)}function _n(t,e){var n=Ln.exec(t.replace(Mn,""));n||Cn(t),Ln.lastIndex=0;var i=n[1],r=n[2],o=n[3],a=n[4],s=e.x,u=e.y,l=e.width,h=e.height,c=0;switch(r){case En.width:c=l;break;case En.height:c=h;break;case En.x:c=s;break;case En.y:c=u;break;case En.minimum:c=Math.min(h,l);break;case En.maximum:c=Math.max(h,l);break;case En.diagonal:c=Math.sqrt(h*h+l*l)}return i&&(c*=parseFloat(i)),o&&(c/=parseFloat(o.slice(1))),a&&(c+=function(t){if(!t)return 0;switch(t[0]){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(a)),c}function Nn(t){return"string"==typeof t&&t.includes("calc")}var On="calc(",Rn=On.length;function Fn(t,e){for(var n=t,i=0;;){var r=n.indexOf(On,i);if(-1===r)return n;var o=r+Rn,a=1;t:for(;;){switch(n[o]){case"(":a++;break;case")":if(0===--a)break t;break;case void 0:Cn(n)}o++}var s=n.slice(r+Rn,o);Nn(s)&&(s=Fn(s,e));var u=String(_n(s,e));n=n.slice(0,r)+u+n.slice(o+1),i=r+u.length}}var Bn=Math.round,Vn=Math.floor,In=Math.PI,Dn=function(t){return t%360+(t<0?360:0)},jn=function(t,e){return e*Bn(t/e)},zn=function(t){return 180*t/In%360},Gn=function(t,e){return(t=(e=e||!1)?t:t%360)*In/180},Un=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){var n=t;t=e,e=n}return Vn(Math.random()*(e-t+1)+t)},Hn=Math.cos,qn=Math.sin,Wn=Math.atan2,Yn=function(t,e){var n=Gn(t.y),i=Gn(e.y),r=t.x,o=e.x,a=Gn(o-r),s=qn(a)*Hn(i),u=Hn(n)*qn(i)-qn(n)*Hn(i)*Hn(a),l=zn(Wn(s,u))-22.5;return l<0&&(l+=360),["NE","E","SE","S","SW","W","NW","N"][l=parseInt(l/45)]},Xn=function(t,e){var n=t.x,i=t.y;return(n-=e.x)*n+(i-=e.y)*i},$n=function(t,e){return Math.sqrt(Xn(t,e))},Zn={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},Jn=Math.abs,Kn=Math.cos,Qn=Math.sin,ti=Math.sqrt,ei=Math.min,ni=Math.max,ii=Math.atan2,ri=Math.round,oi=Math.pow,ai=Math.PI,si=function(t,e){if(!(this instanceof si))return new si(t,e);if("string"==typeof t){var n=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(n[0]),e=parseFloat(n[1])}else Object(t)===t&&(e=t.y,t=t.x);this.x=void 0===t?0:t,this.y=void 0===e?0:e};si.fromPolar=function(t,e,n){n=new si(n);var i=Jn(t*Kn(e)),r=Jn(t*Qn(e)),o=Dn(zn(e));return o<90?r=-r:o<180?(i=-i,r=-r):o<270&&(i=-i),new si(n.x+i,n.y+r)},si.random=function(t,e,n,i){return new si(Un(t,e),Un(n,i))},si.prototype={type:Zn.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new si(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new si(t[r]),a=this.squaredDistance(o);a<i&&(n=o,i=a)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=ei(ni(this.x,t.x),t.x+t.width),this.y=ei(ni(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var n=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return Yn(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new si(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 si(this.x-(t||0),this.y-(e||0))},distance:function(t){return $n(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 si((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ti(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return Jn(t.x-this.x)+Jn(t.y-this.y)},move:function(t,e){var n=Gn(new si(t).theta(this));return this.offset(Kn(n)*e,-Qn(n)*e)},normalize:function(t){var e=(t||1)/this.magnitude();return this.scale(e,e)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new si(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new si(0,0),e=Gn(Dn(-e));var n=Kn(e),i=Qn(e),r=n*(this.x-t.x)-i*(this.y-t.y)+t.x,o=i*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=r,this.y=o,this},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=oi(10,t)}return this.x=ri(this.x*e)/e,this.y=ri(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new si(n)||new si(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=jn(this.x,t),this.y=jn(this.y,e||t),this},squaredDistance:function(t){return Xn(this,t)},theta:function(t){var e=-((t=new si(t)).y-this.y),n=t.x-this.x,i=ii(e,n);return i<0&&(i=2*ai+i),180*i/ai},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new si(t)||new si(0,0);var e=this.x,n=this.y;return this.x=ti((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Gn(t.theta(new si(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 si(0,0).angleBetween(this,t)}},si.prototype.translate=si.prototype.offset;var ui=si,li=Math.max,hi=Math.min,ci=function(t,e){return this instanceof ci?t instanceof ci?new ci(t.start,t.end):(this.start=new si(t),void(this.end=new si(e))):new ci(t,e)};ci.prototype={type:Zn.Line,angle:function(){var t=new si(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=hi(this.start.x,this.end.x),e=hi(this.start.y,this.end.y),n=li(this.start.x,this.end.x),i=li(this.start.y,this.end.y);return new Ei(t,e,n-t,i-e)},bearing:function(){return Yn(this.start,this.end)},clone:function(){return new ci(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){var e=this.vector().dot(new ci(this.start,t).vector()),n=hi(1,li(0,e/this.squaredLength()));return n!=n?0:n},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,n=this.end;if(0!==e.cross(t,n))return!1;var i=this.length();return!(new ci(e,t).length()>i)&&!(new ci(t,n).length()>i)},divideAt:function(t){var e=this.pointAt(t);return[new ci(this.start,e),new ci(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new ci(this.start,e),new ci(e,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){if(t&&t.intersectionWithLine){var n=t.intersectionWithLine(this,e);return n&&t instanceof ci&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new si(this.end.x-this.start.x,this.end.y-this.start.y),n=new si(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,r=new si(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,a=r.x*e.y-r.y*e.x;if(0===i||o*i<0||a*i<0)return null;if(0<i){if(i<o||i<a)return null}else if(o<i||a<i)return null;return[new si(this.start.x+o*e.x/i,this.start.y+o*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return $n(this.start,this.end)},midpoint:function(){return new si((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e=this.clone();if(!this.isDifferentiable())return e;var n=e.start,i=e.end,r=n.clone().rotate(i,270),o=i.clone().rotate(n,90);return n.move(o,t),i.move(r,t),e},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0;t<0&&(i=!1,t=-t);var r=this.length();return r<=t?i?n.clone():e.clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new si(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();if(!e)return this;var n=t/e;return this.scale(n,n,this.start)},squaredLength:function(){return Xn(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAt(t),r=new ci(e,n);return r.translate(i.x-e.x,i.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAtLength(t),r=new ci(e,n);return r.translate(i.x-e.x,i.y-e.y),r},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new si(this.end.x-this.start.x,this.end.y-this.start.y)}},ci.prototype.intersection=ci.prototype.intersect;var di=ci,fi=Math.sqrt,pi=Math.round,gi=Math.pow,vi=function(t,e,n){return this instanceof vi?t instanceof vi?new vi(new si(t.x,t.y),t.a,t.b):(t=new si(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new vi(t,e,n)};vi.fromRect=function(t){return t=new Ei(t),new vi(t.center(),t.width/2,t.height/2)},vi.prototype={type:Zn.Ellipse,bbox:function(){return new Ei(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new si(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,a=t.vector(),s=n.difference(new si(this)),u=new si(a.x/(r*r),a.y/(o*o)),l=new si(s.x/(r*r),s.y/(o*o)),h=a.dot(u),c=a.dot(l),d=c*c-h*(s.dot(l)-1);if(d<0)return null;if(0<d){var f=fi(d),p=(-c-f)/h,g=(-c+f)/h;if((p<0||1<p)&&(g<0||1<g))return null;0<=p&&p<=1&&e.push(n.lerp(i,p)),0<=g&&g<=1&&e.push(n.lerp(i,g))}else{var v=-c/h;if(!(0<=v&&v<=1))return null;e.push(n.lerp(i,v))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new si(t),e&&t.rotate(new si(this.x,this.y),e);var n,i=t.x-this.x,r=t.y-this.y;if(0===i)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new si(this.x,this.y),-e):n;var o=r/i,a=o*o,s=this.a*this.a,u=this.b*this.b,l=fi(1/(1/s+a/u)),h=o*(l=i<0?-l:l);return n=new si(this.x+l,this.y+h),e?n.rotate(new si(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,i=this.a,r=this.b,o=this.x,a=this.y;return(e-o)*(e-o)/(i*i)+(n-a)*(n-a)/(r*r)},round:function(t){var e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=gi(10,t)}return this.x=pi(this.x*e)/e,this.y=pi(this.y*e)/e,this.a=pi(this.a*e)/e,this.b=pi(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,a=this.b,s=this.bbox().center(),u=s.x,l=s.y,h=i>s.x+o/2,c=i<s.x-o/2;return h||c?n=o*o/(i-u)-o*o*(r-l)*((e=i>s.x?r-30:r+30)-l)/(a*a*(i-u))+u:e=a*a/(r-l)-a*a*(i-u)*((n=r>s.y?i+30:i-30)-u)/(o*o*(r-l))+l,new si(n,e).theta(t)},toString:function(){return new si(this.x,this.y).toString()+" "+this.a+" "+this.b}};var mi=vi,yi=Math.abs,bi=Math.cos,wi=Math.sin,xi=Math.min,Ai=Math.max,Pi=Math.round,Ti=Math.pow,Ei=function(t,e,n,i){if(!(this instanceof Ei))return new Ei(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};Ei.fromEllipse=function(t){return t=new vi(t),new Ei(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},Ei.fromPointUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var n,i,r,o,a=new si;n=i=1/0,r=o=-1/0;for(var s=0;s<t.length;s++){a.update(t[s]);var u=a.x,l=a.y;u<n&&(n=u),r<u&&(r=u),l<i&&(i=l),o<l&&(o=l)}return new Ei(n,i,r-n,o-i)},Ei.fromRectUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var n,i,r,o,a=new Ei;n=i=1/0,r=o=-1/0;for(var s=0;s<t.length;s++){a.update(t[s]);var u=a.x,l=a.y,h=u+a.width,c=l+a.height;u<n&&(n=u),r<h&&(r=h),l<i&&(i=l),o<c&&(o=c)}return new Ei(n,i,r-n,o-i)},Ei.prototype={type:Zn.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;var e=this.width,n=this.height,i=Gn(t),r=yi(wi(i)),o=yi(bi(i)),a=e*o+n*r,s=e*r+n*o;return this.x+=(e-a)/2,this.y+=(n-s)/2,this.width=a,this.height=s,this},bottomLeft:function(){return new si(this.x,this.y+this.height)},bottomLine:function(){return new ci(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new si(this.x+this.width/2,this.y+this.height)},center:function(){return new si(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new Ei(this)},containsPoint:function(t){return t instanceof si||(t=new si(t)),t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new Ei(this).normalize(),n=new Ei(t).normalize(),i=e.width,r=e.height,o=n.width,a=n.height;if(!(i&&r&&o&&a))return!1;var s=e.x,u=e.y,l=n.x,h=n.y;return o+=l,i+=s,a+=h,r+=u,s<=l&&o<=i&&u<=h&&a<=r},corner:function(){return new si(this.x+this.width,this.y+this.height)},equals:function(t){var e=new Ei(this).normalize(),n=new Ei(t).normalize();return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),n=this.corner(),i=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||i.x>=n.x||i.y>=n.y)return null;var o=Ai(e.x,i.x),a=Ai(e.y,i.y);return new Ei(o,a,xi(n.x,r.x)-o,xi(n.y,r.y)-a)},intersectionWithLine:function(t){var e,n,i=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],r=[],o=[],a=i.length;for(n=0;n<a;n++)null!==(e=t.intersect(i[n]))&&o.indexOf(e.toString())<0&&(r.push(e),o.push(e.toString()));return 0<r.length?r:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new si(t);var n,i=new si(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(i,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new ci(i,t),a=r.length-1;0<=a;--a){var s=r[a].intersection(o);if(null!==s){n=s;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new ci(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new si(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,i,r,o,a,s,u,l;t=new Ei(t),e||(e=t.center());var h=e.x,c=e.y;n=i=r=o=a=s=u=l=1/0;var d=t.topLeft();d.x<h&&(n=(this.x-h)/(d.x-h)),d.y<c&&(a=(this.y-c)/(d.y-c));var f=t.bottomRight();f.x>h&&(i=(this.x+this.width-h)/(f.x-h)),f.y>c&&(s=(this.y+this.height-c)/(f.y-c));var p=t.topRight();p.x>h&&(r=(this.x+this.width-h)/(p.x-h)),p.y<c&&(u=(this.y-c)/(p.y-c));var g=t.bottomLeft();return g.x<h&&(o=(this.x-h)/(g.x-h)),g.y>c&&(l=(this.y+this.height-c)/(g.y-c)),{sx:xi(n,i,r,o),sy:xi(a,s,u,l)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return xi(n.sx,n.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return si.prototype.offset.call(this,t,e)},origin:function(){return new si(this.x,this.y)},pointNearestToPoint:function(t){if(t=new si(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new si(this.x+this.width,t.y);case"left":return new si(this.x,t.y);case"bottom":return new si(t.x,this.y+this.height);case"top":return new si(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new ci(this.topRight(),this.bottomRight())},rightMiddle:function(){return new si(this.x+this.width,this.y+this.height/2)},round:function(t){var 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 si(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r=e,o="left";return n<r&&(r=n,o="right"),i<r&&(r=i,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),i=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=i.x-n.x,this.height=i.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new ci(this.topLeft(),this.topRight())},topMiddle:function(){return new si(this.x+this.width/2,this.y)},topRight:function(){return new si(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return Ei.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}},Ei.prototype.bottomRight=Ei.prototype.corner,Ei.prototype.topLeft=Ei.prototype.origin,Ei.prototype.translate=Ei.prototype.offset;var Si=Ei;function ki(t){var e=t.trim();if(""===e)return[];for(var n=[],i=e.split(/\b\s*,\s*|,\s*|\s+/),r=i.length,o=0;o<r;o+=2)n.push({x:+i[o],y:+i[o+1]});return n}function Mi(t){var e=t.length;if(0===e)return[];for(var n=[],i=0;i<e;i++){var r=t[i].clone();n.push(r)}return n}function Li(t){var e,n,i,r=Math.abs,o=t.length;if(0===o)return[];for(e=0;e<o;e++)void 0===i?i=t[e]:t[e].y<i.y?i=t[e]:t[e].y===i.y&&t[e].x>i.x&&(i=t[e]);var a=[];for(e=0;e<o;e++){var s=i.theta(t[e]);0===s&&(s=360);var u=[t[e],e,s];a.push(u)}if(a.sort(function(t,e){var n=t[2]-e[2];return 0===n&&(n=e[1]-t[1]),n}),2<a.length){var l=a[a.length-1];a.unshift(l)}for(var h,c,d,f,p,g,v,m={},y=[];0!==a.length;)if(c=(h=a.pop())[0],!m.hasOwnProperty(h[0]+"@@"+h[1]))for(var b=!1;!b;)if(y.length<2)y.push(h),b=!0;else{f=(d=y.pop())[0];var w=(g=(p=y.pop())[0]).cross(f,c);if(w<0)y.push(p),y.push(d),y.push(h),b=!0;else if(0===w){var x=f.angleBetween(g,c);r(x-180)<1e-10?(m[d[0]+"@@"+d[1]]=f,y.push(p)):f.equals(c)||g.equals(f)?(m[d[0]+"@@"+d[1]]=f,y.push(p)):r((x+1)%360-1)<1e-10&&(y.push(p),a.push(d))}else m[d[0]+"@@"+d[1]]=f,y.push(p)}2<y.length&&y.pop();var A=-1;for(n=y.length,e=0;e<n;e++){var P=y[e][1];(void 0===v||P<v)&&(v=P,A=e)}var T=[];if(0<A){var E=y.slice(A),S=y.slice(0,A);T=E.concat(S)}else T=y;var k=[];for(n=T.length,e=0;e<n;e++)k.push(T[e][0]);return k}var Ci=function(t){return this instanceof Ci?"string"==typeof t?new Ci.parse(t):void(this.points=Array.isArray(t)?t.map(si):[]):new Ci(t)};Ci.parse=function(t){return new Ci(ki(t))},Ci.fromRect=function(t){return new Ci([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},Ci.prototype={type:Zn.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 a=0;a<o;a++){var s=r[a],u=s.x,l=s.y;u<t&&(t=u),e<u&&(e=u),l<n&&(n=l),i<l&&(i=l)}return new Ei(t,n,e-t,i-n)},clone:function(){return new Ci(Mi(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,a=i-1,s=0;s<a;s++){var u=new ci(n[s],n[s+1]),l=u.length(),h=u.closestPointNormalizedLength(t),c=u.pointAt(h).squaredDistance(t);c<r&&(r=c,e=o+h*l),o+=l}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var n=this.length();return 0===n?0:e/n},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,a=0,s=0,u=new ci,l=new ci,h=new si;a<n;a++){var c=e[o],d=e[a];if(t.equals(c))return!0;if(u.start=c,u.end=d,u.containsPoint(t))return!0;if(r<=c.y&&r>d.y||r>c.y&&r<=d.y){var f=c.x-i>d.x-i?c.x-i:d.x-i;0<=f&&(h.x=i+f,h.y=r,l.start=t,l.end=h,u.intersect(l)&&s++)}o=a}return s%2==1},close:function(){var t=this.start,e=this.end,n=this.points;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new Ci(Li(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],a=t.points[r];if(!o.equals(a))return!1}return!0},intersectionWithLine:function(t){for(var e=new ci(t),n=[],i=this.lengthPoints(),r=new ci,o=0,a=i.length-1;o<a;o++){r.start=i[o],r.end=i[o+1];var s=e.intersectionWithLine(r);s&&n.push(s[0])}return 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var n=new ci,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();if(t<=0)return e[0].clone();if(1<=t)return e[n-1].clone();var i=this.length()*t;return this.pointAtLength(i)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var i=!0;t<0&&(i=!1,t=-t);for(var r=0,o=n-1,a=0;a<o;a++){var s=i?a:o-1-a,u=e[s],l=e[s+1],h=new ci(u,l),c=u.distance(l);if(t<=r+c)return h.pointAtLength((i?1:-1)*(t-r));r+=c}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(t){void 0===t&&(t={});var e=this.points;if(e.length<3)return this;for(var n=t.threshold||1e-10,i=0;e[i+2];){var r=i+1,o=i+2,a=e[i],s=e[r],u=e[o];new ci(a,u).closestPoint(s).distance(s)<=n?e.splice(r,1):i+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),1<t&&(t=1);var n=this.length()*t;return this.tangentAtLength(n)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;var i,r=!0;t<0&&(r=!1,t=-t);for(var o=0,a=n-1,s=0;s<a;s++){var u=r?s:a-1-s,l=e[u],h=e[u+1],c=new ci(l,h),d=l.distance(h);if(c.isDifferentiable()){if(t<=o+d)return c.tangentAtLength((r?1:-1)*(t-o));i=c}o+=d}if(i){var f=r?1:0;return i.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(Ci.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(Ci.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});var _i=Math.abs,Ni=Math.sqrt,Oi=Math.min,Ri=Math.max,Fi=Math.pow,Bi=function(t,e,n,i){return this instanceof Bi?t instanceof Bi?new Bi(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new si(t),this.controlPoint1=new si(e),this.controlPoint2=new si(n),void(this.end=new si(i))):new Bi(t,e,n,i)};function Vi(t){var e,n,i=arguments,r=[];for(n=arguments.length,e=1;e<n;e++)r.push(i[e]);if(!t)throw new Error("Missing a parent object.");var o=Object.create(t);for(n=r.length,e=0;e<n;e++){var a,s,u=r[e];for(s in u)u.hasOwnProperty(s)&&(delete o[s],a=Object.getOwnPropertyDescriptor(u,s),Object.defineProperty(o,s,a))}return o}Bi.throughPoints=function(){function u(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}return function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=function(t){var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new si((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new si(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var a=u(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var s=u(o);for(e=0;e<r;e++)n.push(new si(a[e],s[e])),e<r-1?i.push(new si(2*t[e+1].x-a[e+1],2*t[e+1].y-s[e+1])):i.push(new si((t[r].x+a[r-1])/2,(t[r].y+s[r-1])/2));return[n,i]}(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new si(e[0][r].x,e[0][r].y),a=new si(e[1][r].x,e[1][r].y);n.push(new Bi(t[r],o,a,t[r+1]))}return n}}(),Bi.prototype={type:Zn.Curve,bbox:function(){for(var t,e,n,i,r,o,a,s,u=this.start,l=this.controlPoint1,h=this.controlPoint2,c=this.end,d=u.x,f=u.y,p=l.x,g=l.y,v=h.x,m=h.y,y=c.x,b=c.y,w=new Array,x=new Array,A=[new Array,new Array],P=0;P<2;++P)if(n=0===P?(e=6*d-12*p+6*v,t=-3*d+9*p-9*v+3*y,3*p-3*d):(e=6*f-12*g+6*m,t=-3*f+9*g-9*m+3*b,3*g-3*f),_i(t)<1e-12){if(_i(e)<1e-12)continue;0<(i=-n/e)&&i<1&&x.push(i)}else s=Ni(a=e*e-4*n*t),a<0||(0<(r=(-e+s)/(2*t))&&r<1&&x.push(r),0<(o=(-e-s)/(2*t))&&o<1&&x.push(o));for(var T,E,S,k=x.length,M=k;k--;)E=(T=1-(i=x[k]))*T*T*d+3*T*T*i*p+3*T*i*i*v+i*i*i*y,A[0][k]=E,S=T*T*T*f+3*T*T*i*g+3*T*i*i*m+i*i*i*b,A[1][k]=S,w[k]={X:E,Y:S};x[M]=0,x[M+1]=1,w[M]={X:d,Y:f},w[M+1]={X:y,Y:b},A[0][M]=d,A[1][M]=f,A[0][M+1]=y,A[1][M+1]=b,x.length=M+2,A[0].length=M+2,A[1].length=M+2,w.length=M+2;var L=Oi.apply(null,A[0]),C=Oi.apply(null,A[1]),_=Ri.apply(null,A[0]),N=Ri.apply(null,A[1]);return new Ei(L,C,_-L,N-C)},clone:function(){return new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.closestPointLength(t,i);if(!r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){for(var n,i,r,o,a,s,u,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,c=h.length,d=c?1/c:0,f=0;f<c;f++){var p=h[f],g=p.start.distance(t),v=p.end.distance(t),m=g+v;(!u||m<u)&&(i=f*d,r=(f+1)*d,o=g,a=v,s=(n=p).start.distance(p.end),u=m)}for(var y=Fi(10,-l);;){var b=o?_i(o-a)/o:0,w=a?_i(o-a)/a:0;if(b<y||w<y||(!o||o<s*y||(!a||a<s*y)))return o<=a?i:r;var x=n.divide(.5);d/=2;var A=x[0].start.distance(t),P=x[0].end.distance(t),T=A+P,E=x[1].start.distance(t),S=x[1].end.distance(t);a=T<=E+S?(n=x[0],r-=d,o=A,P):(n=x[1],i+=d,o=E,S)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(1<=t)return this.divideAtT(1);var n=this.tAt(t,e);return this.divideAtT(n)},divideAtLength:function(t,e){var n=this.tAtLength(t,e);return this.divideAtT(n)},divideAtT:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return[new Bi(e,e,e,e),new Bi(e,n,i,r)];if(1<=t)return[new Bi(e,n,i,r),new Bi(r,r,r,r)];var o=this.getSkeletonPoints(t),a=o.startControlPoint1,s=o.startControlPoint2,u=o.divider,l=o.dividerControlPoint1,h=o.dividerControlPoint2;return[new Bi(e,a,s,u),new Bi(u,l,h,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()};if(1<=t)return{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new ci(e,n).pointAt(t),a=new ci(n,i).pointAt(t),s=new ci(i,r).pointAt(t),u=new ci(o,a).pointAt(t),l=new ci(a,s).pointAt(t);return{startControlPoint1:o,startControlPoint2:u,divider:new ci(u,l).pointAt(t),dividerControlPoint1:l,dividerControlPoint2:s}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,i=this.controlPoint1,r=this.controlPoint2,o=this.end,a=[new Bi(n,i,r,o)];if(0===e)return a;if(!this.isDifferentiable())return a;var s=this.endpointDistance(),u=Fi(10,-e),l=2;0===i.cross(n,o)&&0===r.cross(n,o)&&(l=2*e);for(var h=0;;){h+=1;for(var c=[],d=a.length,f=0;f<d;f++){var p=a[f].divide(.5);c.push(p[0],p[1])}for(var g=0,v=c.length,m=0;m<v;m++){g+=c[m].endpointDistance()}if(l<=h)if((0!==g?(g-s)/g:0)<u)return c;a=c,s=g}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++){i+=n[o].endpointDistance()}return i},lengthAtT:function(t,e){if(t<=0)return 0;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();var n=this.tAt(t,e);return this.pointAtT(n)},pointAtLength:function(t,e){var n=this.tAtLength(t,e);return this.pointAtT(n)},pointAtT:function(t){return t<=0?this.start.clone():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);var n=this.tAt(t,e);return this.tangentAtT(n)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var n=this.tAtLength(t,e);return this.tangentAtT(n)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var e=this.getSkeletonPoints(t),n=e.startControlPoint2,i=e.dividerControlPoint1,r=e.divider,o=new ci(n,i);return o.translate(r.x-n.x,r.y-n.y),o},tAt:function(t,e){if(t<=0)return 0;if(1<=t)return 1;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.length(i)*t;return this.tAtLength(r,i)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var i,r,o,a,s,u=void 0===(e=e||{}).precision?this.PRECISION:e.precision,l=void 0===e.subdivisions?this.getSubdivisions({precision:u}):e.subdivisions,h={precision:u,subdivisions:l},c=0,d=l.length,f=1/d,p=0;p<d;p++){var g=n?p:d-1-p,v=l[p],m=v.endpointDistance();if(t<=c+m){i=v,r=g*f,o=(g+1)*f,a=n?t-c:m+c-t,s=n?m+c-t:t-c;break}c+=m}if(!i)return n?1:0;for(var y=this.length(h),b=Fi(10,-u);;){var w,x;if((0!==y?a/y:0)<b)return r;if((0!==y?s/y:0)<b)return o;var A=i.divide(.5);f/=2;var P=A[0].endpointDistance(),T=A[1].endpointDistance();x=a<=P?(i=A[0],o-=f,P-(w=a)):(i=A[1],r+=f,T-(w=a-P)),a=w,s=x}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var a=n[o];i.push(a.end.clone())}return i},toPolyline:function(t){return new Ci(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}},Bi.prototype.divide=Bi.prototype.divideAtT;var Ii=function(t){if(!(this instanceof Ii))return new Ii(t);if("string"==typeof t)return new Ii.parse(t);var e,n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(e=0;e<n;e++){var i=t[e];this.appendSegment(i)}else{var r=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof ci||o instanceof Bi))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(Ii.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(Ii.createSegment("M",o.start)),o instanceof ci?this.appendSegment(Ii.createSegment("L",o.end)):o instanceof Bi&&this.appendSegment(Ii.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof ci)this.appendSegment(Ii.createSegment("M",t.start)),this.appendSegment(Ii.createSegment("L",t.end));else if(t instanceof Bi)this.appendSegment(Ii.createSegment("M",t.start)),this.appendSegment(Ii.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof Ci))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(n=t.points.length,e=0;e<n;e++){var a=t.points[e];0===e?this.appendSegment(Ii.createSegment("M",a)):this.appendSegment(Ii.createSegment("L",a))}}else;};function Di(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}Ii.parse=function(t){if(!t)return new Ii;for(var e=new Ii,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),a=Ii.createSegment.apply(this,o);e.appendSegment(a)}return e},Ii.createSegment=function(t){var e=arguments;if(!t)throw new Error("Type must be provided.");var n=Ii.segmentTypes[t];if(!n)throw new Error(t+" is not a recognized path segment type.");for(var i=[],r=arguments.length,o=1;o<r;o++)i.push(e[o]);return Di(n,i)},Ii.prototype={type:Zn.Path,appendSegment:function(t){var e,n=this.segments,i=n.length,r=0!==i?n[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,a=0;a<o;a++){var s=t[a];e=this.prepareSegment(s,r,null),n.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),n.push(e)}},bbox:function(){var t,e=this.segments,n=e.length;if(0===n)return null;for(var i=0;i<n;i++){var r=e[i];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var a=e[n-1];return new Ei(a.end.x,a.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,n=new Ii,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){var n=this.closestPointT(t,e);return n?this.pointAtT(n):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointT(t,i);return r?this.lengthAtT(r,i):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointLength(t,i);if(0===r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,s=1/0,u=0;u<i;u++){var l=n[u],h=a[u];if(l.isVisible){var c=l.closestPointT(t,{precision:o,subdivisions:h}),d=l.pointAtT(c),f=new ci(d,t).squaredLength();f<s&&(r={segmentIndex:u,value:c},s=f)}}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,s=1/0,u=0;u<i;u++){var l=n[u],h=a[u];if(l.isDifferentiable()){var c=l.closestPointT(t,{precision:o,subdivisions:h}),d=l.pointAtT(c),f=new ci(d,t).squaredLength();f<s&&(r=l.tangentAtT(c),s=f)}}return r||null},containsPoint:function(t,e){var n=this.toPolylines(e);if(!n)return!1;for(var i=n.length,r=0,o=0;o<i;o++){n[o].containsPoint(t)&&r++}return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),1<t&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.divideAtLength(r,i)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;var i=!0;t<0&&(i=!1,t=-t);var r,o,a,s,u,l,h,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,d=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:c}):e.segmentSubdivisions,f=0;for(r=0;r<n;r++){var p=i?r:n-1-r;o=this.getSegment(p);var g=d[p],v=o.length({precision:c,subdivisions:g});if(o.isDifferentiable()&&(u=o,l=p,t<=f+v)){s=p,a=o.divideAtLength((i?1:-1)*(t-f),{precision:c,subdivisions:g});break}f+=v}if(!u)return null;a||(s=l,h=i?1:0,a=u.divideAtT(h));var m=this.clone();m.replaceSegment(s,a);var y=s,b=s+1,w=s+2;a[0].isDifferentiable()||(m.removeSegment(y),b-=1,w-=1);var x=m.getSegment(b).start;m.insertSegment(b,Ii.createSegment("M",x)),w+=1,a[1].isDifferentiable()||(m.removeSegment(w-1),w-=1);var A=w-y-1;for(r=w;r<m.segments.length;r++){var P=this.getSegment(r-A);if("Z"===(o=m.getSegment(r)).type&&!P.subpathStartSegment.end.equals(o.subpathStartSegment.end)){var T=Ii.createSegment("L",P.end);m.replaceSegment(r,T)}}return[new Ii(m.segments.slice(0,b)),new Ii(m.segments.slice(b))]},equals:function(t){if(!t)return!1;var e=this.segments,n=t.segments,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],a=n[r];if(o.type!==a.type||!o.equals(a))return!1}return!0},getSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),n<=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 a=e[o].getSubdivisions({precision:i});r.push(a)}return r},getSubpaths:function(){for(var t=this.clone().validate().segments,e=t.length,n=[],i=0;i<e;i++){var r=t[i];r.isSubpathStart?n.push(new Ii(r)):n[n.length-1].appendSegment(r)}return n},insertSegment:function(t,e){var n,i=this.segments,r=i.length;if(t<0&&(t=r+t+1),r<t||t<0)throw new Error("Index out of range.");var o=null,a=null;if(0!==r&&(a=1<=t?(o=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,u=0;u<s;u++){var l=e[u];n=this.prepareSegment(l,o,a),i.splice(t+u,0,n),o=n}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,o,a),i.splice(t,0,n)}},intersectionWithLine:function(t,e){var n=null,i=this.toPolylines(e);if(!i)return null;for(var r=0,o=i.length;r<o;r++){var a=i[r],s=t.intersect(a);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,a=0;a<n;a++){var s=e[a],u=r[a];o+=s.length({subdivisions:u})}return o},lengthAtT:function(t,e){var n=this.segments,i=n.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;var o=t.value;i<=r?(r=i-1,o=1):o<0?o=0:1<o&&(o=1);for(var a,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,u=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<r;h++){var c=n[h];a=u[h],l+=c.length({precisison:s,subdivisions:a})}return c=n[r],a=u[r],l+=c.lengthAtT(o,{precisison:s,subdivisions:a})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.pointAtLength(r,i)},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();var r=!0;t<0&&(r=!1,t=-t);for(var o,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,u=0,l=0;l<i;l++){var h=r?l:i-1-l,c=n[h],d=s[h],f=c.length({precision:a,subdivisions:d});if(c.isVisible){if(t<=u+f)return c.pointAtLength((r?1:-1)*(t-u),{precision:a,subdivisions:d});o=c}u+=f}return o?r?o.end:o.start:n[i-1].end.clone()},pointAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].pointAtT(0);if(n<=i)return e[n-1].pointAtT(1);var r=t.value;return r<0?r=0:1<r&&(r=1),e[i].pointAtT(r)},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);var i=t;return t.isSubpathStart&&(t.subpathStartSegment=t,i=n),i&&this.updateSubpathStartSegment(i),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),n<=t||t<0)throw new Error("Index out of range.");var i=e.splice(t,1)[0],r=i.previousSegment,o=i.nextSegment;r&&(r.nextSegment=o),o&&(o.previousSegment=r),i.isSubpathStart&&o&&this.updateSubpathStartSegment(o)},replaceSegment:function(t,e){var n,i=this.segments,r=i.length;if(0===r)throw new Error("Path has no segments.");if(t<0&&(t=r+t),r<=t||t<0)throw new Error("Index out of range.");var o=i[t],a=o.previousSegment,s=o.nextSegment,u=o.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var l=e.length,h=0;h<l;h++){var c=e[h];n=this.prepareSegment(c,a,s),i.splice(t+h,0,n),a=n,u&&n.isSubpathStart&&(u=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,a,s),i.splice(t,1,n),u&&n.isSubpathStart&&(u=!1)}u&&s&&this.updateSubpathStartSegment(s)},round:function(t){for(var e=this.segments,n=e.length,i=0;i<n;i++){e[i].round(t)}return this},scale:function(t,e,n){for(var i=this.segments,r=i.length,o=0;o<r;o++){i[o].scale(t,e,n)}return this},segmentAt:function(t,e){var n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null},segmentAtLength:function(t,e){var n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),1<t&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.segmentIndexAtLength(r,i)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,s=null,u=0,l=0;l<i;l++){var h=r?l:i-1-l,c=n[h],d=a[h],f=c.length({precision:o,subdivisions:d});if(c.isVisible){if(t<=u+f)return h;s=h}u+=f}return s},serialize:function(){if(!this.isValid())throw new Error("Invalid path segments.");return this.toString()},tangentAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),1<t&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.tangentAtLength(r,i)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,u=0,l=0;l<i;l++){var h=r?l:i-1-l,c=n[h],d=s[h],f=c.length({precision:a,subdivisions:d});if(c.isDifferentiable()){if(t<=u+f)return c.tangentAtLength((r?1:-1)*(t-u),{precision:a,subdivisions:d});o=c}u+=f}if(o){var p=r?1:0;return o.tangentAtT(p)}return null},tangentAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].tangentAtT(0);if(n<=i)return e[n-1].tangentAtT(1);var r=t.value;return r<0?r=0:1<r&&(r=1),e[i].tangentAtT(r)},toPoints:function(t){var e=this.segments,n=e.length;if(0===n)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=[],a=[],s=0;s<n;s++){var u=e[s];if(u.isVisible){var l=r[s];if(0<l.length){var h=l.map(function(t){return t.start});Array.prototype.push.apply(a,h)}else a.push(u.start)}else 0<a.length&&(a.push(e[s-1].end),o.push(a),a=[])}return 0<a.length&&(a.push(this.end),o.push(a)),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 Ci(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,Ii.createSegment("M",0,0)),this}},Object.defineProperty(Ii.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(Ii.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}});var ji={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return 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(ji,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(ji,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(ji,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}});var zi=function(){for(var t,e,n=arguments,i=[],r=arguments.length,o=0;o<r;o++)i.push(n[o]);if(!(this instanceof zi))return Di(zi,i);if(0===r)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(i[0]instanceof ci){if(1===r)return this.end=i[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+r+" lines provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(2===r)return this.end=new si(+i[0],+i[1]),this;if(r<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+r+" coordinates provided).");var a;for(t=[],o=0;o<r;o+=2)a=i.slice(o,o+2),t.push(Di(zi,a));return t}if(1===r)return this.end=new si(i[0]),this;for(t=[],o=0;o<r;o+=1)e=i[o],t.push(new zi(e));return t},Gi={clone:function(){return new zi(this.end)},divideAt:function(t){var e=new ci(this.start,this.end).divideAt(t);return[new zi(e[0]),new zi(e[1])]},divideAtLength:function(t){var e=new ci(this.start,this.end).divideAtLength(t);return[new zi(e[0]),new zi(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Gi,"type",{configurable:!0,enumerable:!0,value:"L"}),zi.prototype=Vi(ji,ci.prototype,Gi);var Ui=function(){for(var t,e,n=arguments,i=[],r=arguments.length,o=0;o<r;o++)i.push(n[o]);if(!(this instanceof Ui))return Di(Ui,i);if(0===r)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(i[0]instanceof Bi){if(1===r)return this.controlPoint1=i[0].controlPoint1.clone(),this.controlPoint2=i[0].controlPoint2.clone(),this.end=i[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+r+" curves provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(6===r)return this.controlPoint1=new si(+i[0],+i[1]),this.controlPoint2=new si(+i[2],+i[3]),this.end=new si(+i[4],+i[5]),this;if(r<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+r+" coordinates provided).");var a;for(t=[],o=0;o<r;o+=6)a=i.slice(o,o+6),t.push(Di(Ui,a));return t}if(3===r)return this.controlPoint1=new si(i[0]),this.controlPoint2=new si(i[1]),this.end=new si(i[2]),this;if(r<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+r+" points provided).");for(t=[],o=0;o<r;o+=3)e=i.slice(o,o+3),t.push(Di(Ui,e));return t},Hi={clone:function(){return new Ui(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){var n=new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Ui(n[0]),new Ui(n[1])]},divideAtLength:function(t,e){var n=new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Ui(n[0]),new Ui(n[1])]},divideAtT:function(t){var e=new Bi(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Ui(e[0]),new Ui(e[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,n=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+n.x+" "+n.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}};Object.defineProperty(Hi,"type",{configurable:!0,enumerable:!0,value:"C"}),Ui.prototype=Vi(ji,Bi.prototype,Hi);var qi=function(){for(var t,e,n=arguments,i=[],r=arguments.length,o=0;o<r;o++)i.push(n[o]);if(!(this instanceof qi))return Di(qi,i);if(0===r)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(i[0]instanceof ci){if(1===r)return this.end=i[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+r+" lines provided).")}if(i[0]instanceof Bi){if(1===r)return this.end=i[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+r+" curves provided).")}if("string"==typeof i[0]||"number"==typeof i[0]){if(2===r)return this.end=new si(+i[0],+i[1]),this;if(r<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+r+" coordinates provided).");var a;for(t=[],o=0;o<r;o+=2)a=i.slice(o,o+2),0===o?t.push(Di(qi,a)):t.push(Di(zi,a));return t}if(1===r)return this.end=new si(i[0]),this;for(t=[],o=0;o<r;o+=1)e=i[o],0===o?t.push(new qi(e)):t.push(new zi(e));return t},Wi={bbox:function(){return null},clone:function(){return new qi(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(Wi,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Wi,"type",{configurable:!0,enumerable:!0,value:"M"}),qi.prototype=Vi(ji,Wi);var Yi=function(){for(var t=arguments,e=[],n=arguments.length,i=0;i<n;i++)e.push(t[i]);if(!(this instanceof Yi))return Di(Yi,e);if(0<n)throw new Error("Closepath constructor expects no arguments.");return this},Xi={clone:function(){return new Yi},divideAt:function(t){var e=new ci(this.start,this.end).divideAt(t);return[e[1].isDifferentiable()?new zi(e[0]):this.clone(),new zi(e[1])]},divideAtLength:function(t){var e=new ci(this.start,this.end).divideAtLength(t);return[e[1].isDifferentiable()?new zi(e[0]):this.clone(),new zi(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment)&&!this.start.equals(this.end)},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}};Object.defineProperty(Xi,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),Object.defineProperty(Xi,"type",{configurable:!0,enumerable:!0,value:"Z"}),Yi.prototype=Vi(ji,ci.prototype,Xi);var $i=Ii.segmentTypes={L:zi,C:Ui,M:qi,Z:Yi,z:Yi};Ii.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys($i).join("")+",.]*$"),Ii.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)};var Zi={curveThroughPoints:function(t){return console.warn("deprecated"),new Ii(Bi.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new si((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new si(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var a=this.getFirstControlPoints(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var s=this.getFirstControlPoints(o);for(e=0;e<r;e++)n.push(new si(a[e],s[e])),e<r-1?i.push(new si(2*t[e+1].x-a[e+1],2*t[e+1].y-s[e+1])):i.push(new si((t[r].x+a[r-1])/2,(t[r].y+s[r-1])/2));return[n,i]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new Bi(t,e,n,i);return function(t){var e=r.divide(t);return[{p0:e[0].start,p1:e[0].controlPoint1,p2:e[0].controlPoint2,p3:e[0].end},{p0:e[1].start,p1:e[1].controlPoint1,p2:e[1].controlPoint2,p3:e[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n},getInversionSolver:function(t,e,n,i){console.warn("deprecated");var r=new Bi(t,e,n,i);return function(t){return r.closestPointT(t)}}},Ji=function(t){return this instanceof Ji?"string"==typeof t?new Ji.parse(t):void(this.points=Array.isArray(t)?t.map(si):[]):new Ji(t)};function Ki(t,e){var n=t.start.x,i=t.start.y,r=t.end.x,o=t.end.y,a=e.start.x,s=e.start.y,u=r-n,l=o-i,h=e.end.x-a,c=e.end.y-s,d=n-a,f=i-s,p=u*c-h*l,g=(u*f-l*d)/p,v=(h*f-c*d)/p;return 0<=g&&g<=1&&0<=v&&v<=1}function Qi(t,e){var n=t.a,i=t.b,r=t.x,o=t.y,a=e.start.x-r,s=e.end.x-r,u=e.start.y-o,l=n*n,h=i*i,c=s-a,d=e.end.y-o-u,f=c*c/l+d*d/h,p=2*a*c/l+2*u*d/h,g=p*p-4*f*(a*a/l+u*u/h-1);if(0===g){var v=-p/2/f;return 0<=v&&v<=1}if(0<g){var m=Math.sqrt(g),y=(-p+m)/2/f,b=(-p-m)/2/f;return 0<=y&&y<=1||0<=b&&b<=1}return!1}function tr(t,e){return function(t,e,n,i){var r=Math.cos,o=Math.sin,a=o(e),s=r(e),u=o(i),l=r(i),h=a*a,c=s*s,d=a*s,f=u*u,p=l*l,g=u*l,v=t.a*t.a,m=t.b*t.b,y=n.a*n.a,b=n.b*n.b,w=v*h+m*c,x=y*f+b*p,A=v*c+m*h,P=y*p+b*f,T=2*(m-v)*d,E=2*(b-y)*g,S=-2*w*t.x-T*t.y,k=-2*x*n.x-E*n.y,M=-T*t.x-2*A*t.y,L=-E*n.x-2*P*n.y,C=w*t.x*t.x+A*t.y*t.y+T*t.x*t.y-v*m,_=x*n.x*n.x+P*n.y*n.y+E*n.x*n.y-y*b;E/=2,k/=2,L/=2;var N=Sr([[w,T/=2,S/=2],[T,A,M/=2],[S,M,C]]),O=Sr([[x,E,k],[E,P,L],[k,L,_]]),R=.33333333*(Sr([[x,T,S],[E,A,M],[k,M,C]])+Sr([[w,E,S],[T,P,M],[S,L,C]])+Sr([[w,T,k],[T,A,L],[S,M,_]])),F=.33333333*(Sr([[w,E,k],[T,P,L],[S,L,_]])+Sr([[x,T,k],[E,A,L],[k,M,_]])+Sr([[x,E,S],[E,P,M],[k,L,C]])),B=Er([[N,R],[R,F]]),V=Er([[N,F],[R,O]]),I=Er([[R,F],[F,O]]);if(0<Er([[2*B,V],[V,2*I]])&&(0<F||0<R))return!1;return!0}(t,0,e,0)}function er(t,e){var n=e.start,i=e.end,r=t.x,o=t.y,a=t.width,s=t.height;return!(n.x>r+a&&i.x>r+a||n.x<r&&i.x<r||n.y>o+s&&i.y>o+s||n.y<o&&i.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||(Ki(t.topLine(),e)||Ki(t.rightLine(),e)||Ki(t.bottomLine(),e)||Ki(t.leftLine(),e)))}function nr(t,e){return!!ir(t,Ei.fromEllipse(e))&&lr(Ji.fromRect(t),e)}function ir(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 rr(t,e){return br(t,e,{interior:!1})}function or(t,e){return wr(t,e,{interior:!1})}function ar(t,e){return xr(t,e,{interior:!1})}function sr(t,e){return Pr(t,e,{interior:!1})}function ur(t,e){return br(t,e,{interior:!0})}function lr(t,e){return wr(t,e,{interior:!0})}function hr(t,e){return xr(t,e,{interior:!0})}function cr(t,e){return Pr(t,e,{interior:!0})}function dr(t,e){return Tr(t,e,{interior:!0})}function fr(t,n,i){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?ur(e,n):rr(e,n)})}function pr(t,n,i){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?lr(e,n):or(e,n)})}function gr(t,e,n){return mr(t,Ji.fromRect(e),n)}function vr(t,e,n){return Ar(t,e,n,{interior:!1})}function mr(t,e,n){return Ar(t,e,n,{interior:!0})}function yr(t,n,i,r){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?mr(n,e,r):vr(n,e,r)})}function br(t,e,n){void 0===n&&(n={});var i,r=n.interior;if(void 0===r&&(r=!1),r){if(t.containsPoint(e.start))return!0;var o=t.start,a=t.end,s=t.points;i=a.equals(o)?s:s.concat([o])}else i=t.points;for(var u=i.length,l=new ci,h=0;h<u-1;h++)if(l.start=i[h],l.end=i[h+1],Ki(e,l))return!0;return!1}function wr(t,e,n){void 0===n&&(n={});var i,r=t.start,o=t.end,a=t.points;if(e.containsPoint(r))return!0;var s=n.interior;if(void 0===s&&(s=!1),s){if(t.containsPoint(e.center()))return!0;i=o.equals(r)?a:a.concat([r])}else i=a;for(var u=i.length,l=new ci,h=0;h<u-1;h++)if(l.start=i[h],l.end=i[h+1],Qi(e,l))return!0;return!1}function xr(t,e,n){return Tr(t,Ji.fromRect(e),n)}function Ar(t,n,i,r){return t.getSubpaths().some(function(t){var e=t.toPolylines(i)[0];return"Z"===t.getSegment(-1).type?Tr(n,e,r):Pr(n,e,r)})}function Pr(t,e,n){void 0===n&&(n={});var i,r=n.interior;if(void 0===r&&(r=!1),r){var o=e.start;if(t.containsPoint(o))return!0;i=t.clone().close()}else i=t;for(var a=e.points,s=a.length,u=new ci,l=0;l<s-1;l++)if(u.start=a[l],u.end=a[l+1],rr(i,u))return!0;return!1}function Tr(t,e,n){return e.containsPoint(t.start)||Pr(t,e.clone().close(),n)}function Er(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function Sr(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]}Ji.parse=function(t){return new Ji(ki(t))},Ji.fromRect=function(t){return new Ji([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},Ji.prototype=Vi(Ci.prototype,{type:Zn.Polygon,clone:function(){return new Ji(Mi(this.points))},convexHull:function(){return new Ji(Li(this.points))},lengthPoints:function(){var t=this.start,e=this.end,n=this.points;return n.length<=1||t.equals(e)?n:n.concat([t.clone()])}});var kr={exists:function t(e,n,i,r){switch(e.type){case Zn.Line:switch(n.type){case Zn.Line:return Ki(e,n)}break;case Zn.Ellipse:switch(n.type){case Zn.Line:return Qi(e,n);case Zn.Ellipse:return tr(e,n)}break;case Zn.Rect:switch(n.type){case Zn.Line:return er(e,n);case Zn.Ellipse:return nr(e,n);case Zn.Rect:return ir(e,n)}break;case Zn.Polyline:switch(n.type){case Zn.Line:return rr(e,n);case Zn.Ellipse:return or(e,n);case Zn.Rect:return ar(e,n);case Zn.Polyline:return sr(e,n)}break;case Zn.Polygon:switch(n.type){case Zn.Line:return ur(e,n);case Zn.Ellipse:return lr(e,n);case Zn.Rect:return hr(e,n);case Zn.Polyline:return cr(e,n);case Zn.Polygon:return dr(e,n)}break;case Zn.Path:switch(n.type){case Zn.Line:return fr(e,n,i);case Zn.Ellipse:return pr(e,n,i);case Zn.Rect:return gr(e,n,i);case Zn.Polyline:return vr(e,n,i);case Zn.Polygon:return mr(e,n,i);case Zn.Path:return yr(e,n,i,r)}}switch(n.type){case Zn.Ellipse:case Zn.Rect:case Zn.Polyline:case Zn.Polygon:case Zn.Path:return t(n,e,r,i);default:throw Error("The intersection for "+e+" and "+n+" could not be found.")}},lineWithLine:Ki,ellipseWithLine:Qi,ellipseWithEllipse:tr,rectWithLine:er,rectWithEllipse:nr,rectWithRect:ir,polylineWithLine:rr,polylineWithEllipse:or,polylineWithRect:ar,polylineWithPolyline:sr,polygonWithLine:ur,polygonWithEllipse:lr,polygonWithRect:hr,polygonWithPolyline:cr,polygonWithPolygon:dr,pathWithLine:fr,pathWithEllipse:pr,pathWithRect:gr,pathWithPolyline:vr,pathWithPolygon:mr,pathWithPath:yr},Mr={intersection:kr,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}},normalizeAngle:Dn,snapToGrid:jn,toDeg:zn,toRad:Gn,random:Un,bezier:Zi,Curve:Bi,Ellipse:vi,ellipse:mi,Line:ci,line:di,Path:Ii,Point:si,point:ui,Polyline:Ci,Polygon:Ji,Rect:Ei,rect:Si,types:Zn},Lr="[object Arguments]",Cr="[object Array]",_r="[object Boolean]",Nr="[object Date]",Or="[object Error]",Rr="[object Map]",Fr="[object Number]",Br="[object Object]",Vr="[object RegExp]",Ir="[object Set]",Dr="[object String]",jr="[object Symbol]",zr="[object ArrayBuffer]",Gr="[object DataView]",Ur="[object Float32Array]",Hr="[object Float64Array]",qr="[object Int8Array]",Wr="[object Int16Array]",Yr="[object Int32Array]",Xr="[object Uint8Array]",$r="[object Uint8ClampedArray]",Zr="[object Uint16Array]",Jr="[object Uint32Array]",Kr={"[object Arguments]":!0,"[object Array]":!0,"[object ArrayBuffer]":!0,"[object DataView]":!0,"[object Boolean]":!0,"[object Date]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Map]":!0,"[object Number]":!0,"[object Object]":!0,"[object RegExp]":!0,"[object Set]":!0,"[object String]":!0,"[object Symbol]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Error]":!1,"[object Function]":!1,"[object WeakMap]":!1},Qr="\\ud800-\\udfff",to="\\u2700-\\u27bf",eo="a-z\\xdf-\\xf6\\xf8-\\xff",no="A-Z\\xc0-\\xd6\\xd8-\\xde",io="\\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",ro="["+io+"]",oo="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ao="["+to+"]",so="["+eo+"]",uo="[^"+Qr+io+"\\d"+to+eo+no+"]",lo="\\ud83c[\\udffb-\\udfff]",ho="[^"+Qr+"]",co="(?:\\ud83c[\\udde6-\\uddff]){2}",fo="[\\ud800-\\udbff][\\udc00-\\udfff]",po="["+no+"]",go="(?:"+so+"|"+uo+")",vo="(?:"+po+"|"+uo+")",mo="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",yo="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",bo="(?:"+oo+"|"+lo+")"+"?",wo="[\\ufe0e\\ufe0f]?",xo=wo+bo+("(?:\\u200d(?:"+[ho,co,fo].join("|")+")"+(wo+bo)+")*"),Ao="(?:"+[ao,co,fo].join("|")+")"+xo,Po=RegExp([po+"?"+so+"+"+mo+"(?="+[ro,po,"$"].join("|")+")",vo+"+"+yo+"(?="+[ro,po+go,"$"].join("|")+")",po+"?"+go+"+"+mo,po+"+"+yo,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",Ao].join("|"),"g"),To="__hash_undefined__",Eo=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,So="(?:"+[""+ho+oo+"?",oo,co,fo,"["+Qr+"]"].join("|")+")",ko=RegExp(lo+"(?="+lo+")|"+(So+xo),"g"),Mo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lo=/^\w*$/,Co=".".charCodeAt(0),_o=/\\(\\)?/g,No=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),Oo=/^(?: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 ]/),Fo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Bo=function(t){return ko.test(t)},Vo=function(t){return Bo(t)?t.match(ko)||[]:t.split("")},Io=function(e){return null==e?[]:Do(e).map(function(t){return e[t]})},Do=function(t){return Xo(t)?jo(t):Object.keys(Object(t))},jo=function(t,e){for(var n=Array.isArray(t),i=!n&&Uo(t)&&Jo(t)===Lr,r=!n&&!i&&ia(t),o=n||i||r,a=t.length,s=new Array(o?a:0),u=o?-1:a;++u<a;)s[u]=""+u;for(var l in t)!e&&!hasOwnProperty.call(t,l)||o&&("length"===l||ka(l,a))||s.push(l);return s},zo=function(t,e){for(var n=t.length;n--;)if(Go(t[n][0],e))return n;return-1},Go=function(t,e){return t===e||t!=t&&e!=e},Uo=function(t){return null!=t&&"object"==typeof t},Ho=function(t,e,n){if(!hs(n))return!1;var i=typeof e;return!!("number"==i?Xo(n)&&-1<e&&e<n.length:"string"==i&&e in n)&&Go(n[e],t)},qo=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},Wo=function(t,e,n){var i=t[e];hasOwnProperty.call(t,e)&&Go(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Yo=function(t,e,n){for(var i=-1,r=e.length;++i<r;){var o=e[i];Wo(n,o,t[o])}return n},Xo=function(t){return null!=t&&"function"!=typeof t&&"number"==typeof t.length&&-1<t.length&&t.length%1==0},$o=function(t){return"symbol"==typeof t||Uo(t)&&Jo(t)===jr},Zo=function(t,e){var n=-1,i=t.length;for(e||(e=new Array(i));++n<i;)e[n]=t[n];return e},Jo=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)},Ko=function(t){var e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Qo=function(t,e){var n=e?Ko(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)},ta=function(t){return"function"!=typeof t.constructor||qo(t)?{}:Object.create(Object.getPrototypeOf(t))},ea=function(e){return null==e?[]:(e=Object(e),Object.getOwnPropertySymbols(e).filter(function(t){return propertyIsEnumerable.call(e,t)}))};var na=function(t,e,n){var i,r,o,a,s=t.constructor;switch(e){case zr:return Ko(t);case _r:case Nr:return new s(+t);case Gr:return o=t,a=n?Ko(o.buffer):o.buffer,new o.constructor(a,o.byteOffset,o.byteLength);case Ur:case Hr:case qr:case Wr:case Yr:case Xr:case $r:case Zr:case Jr:return Qo(t,n);case Rr:return new s(t);case Fr:case Dr:return new s(t);case Vr:return(r=new(i=t).constructor(i.source,/\w*$/.exec(i))).lastIndex=i.lastIndex,r;case Ir:return new s;case jr:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}},ia=function(t){return Uo(t)&&Eo.test(Jo(t))},ra=function(t){var e=Object.keys(t);return Array.isArray(t)||null==t||e.push.apply(e,ea(Object(t))),e},oa=function(t){for(var e=[];t;)e.push.apply(e,ea(t)),t=Object.getPrototypeOf(Object(t));return e},aa=function(t){var e=[];for(var n in t)e.push(n);return Array.isArray(t)||e.push.apply(e,oa(t)),e},sa=function(t,e){var n=t.__data__;return La(e)?n["string"==typeof e?"string":"hash"]:n.map},ua=function(t,e,n){return t===e||(null==t||null==e||!Uo(t)&&!Uo(e)?t!=t&&e!=e:la(t,e,ua,n))},la=function(t,e,n,i){var r=Array.isArray(t),o=Array.isArray(e),a=r?Cr:Jo(t),s=o?Cr:Jo(e),u=(a=a==Lr?Br:a)==Br,l=(s=s==Lr?Br:s)==Br,h=a==s;if(h&&!u)return i||(i=new rs),r||ia(t)?ha(t,e,!1,n,i):pa(t,e,a,n,i);var c=u&&hasOwnProperty.call(t,"__wrapped__"),d=l&&hasOwnProperty.call(e,"__wrapped__");if(c||d){var f=c?t.value():t,p=d?e.value():e;return i||(i=new rs),n(f,p,i)}return!!h&&(i||(i=new rs),function(t,e,n,i){var r,o=ra(t),a=o.length;if(a!=ra(e).length)return!1;for(var s=a;s--;)if(r=o[s],!hasOwnProperty.call(e,r))return!1;var u=i.get(t),l=i.get(e);if(u&&l)return u==e&&l==t;var h,c=!0;for(i.set(t,e),i.set(e,t);++s<a;){var d=t[r=o[s]],f=e[r];if(d!==f&&!n(d,f,i)){c=!1;break}h||(h="constructor"==r)}if(c&&!h){var p=t.constructor,g=e.constructor;p!=g&&"constructor"in t&&"constructor"in e&&!("function"==typeof p&&p instanceof p&&"function"==typeof g&&g instanceof g)&&(c=!1)}return i.delete(t),i.delete(e),c}(t,e,n,i))},ha=function(e,i,t,r,o){var n=e.length,a=i.length;if(n!=a)return!1;var s=o.get(e),u=o.get(i);if(s&&u)return s==i&&u==e;var l=-1,h=!0,c=t?new us:void 0;o.set(e,i),o.set(i,e);for(var d=function(){var n=e[l],t=i[l];if(c){if(!ca(i,function(t,e){if(!da(c,e)&&(n===t||r(n,t,o)))return c.push(e)}))return h=!1,"break"}else if(n!==t&&!r(n,t,o))return h=!1,"break"};++l<n;){if("break"===d())break}return o.delete(e),o.delete(i),h},ca=function(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1},da=function(t,e){return t.has(e)},fa=function(t,e,n,i){return!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i))},pa=function(t,e,n,i,r){switch(n){case Gr:return t.byteLength==e.byteLength&&t.byteOffset==e.byteOffset&&(t=t.buffer,e=e.buffer,fa(t,e,i,r));case zr:return fa(t,e,i,r);case _r:case Nr:case Fr:return Go(+t,+e);case Or:return t.name==e.name&&t.message==e.message;case Vr:case Dr:return t==""+e;case Rr:var o=ga;case Ir:if(o||(o=va),t.size!=e.size)return!1;var a=r.get(t);if(a)return a==e;r.set(t,e);var s=ha(o(t),o(e),!0,i,r);return r.delete(t),s;case jr:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},ga=function(t){var n=-1,i=Array(t.size);return t.forEach(function(t,e){i[++n]=[e,t]}),i},va=function(t){var e=-1,n=new Array(t.size);return t.forEach(function(t){n[++e]=t}),n},ma=function(t,e){if(Array.isArray(t))return!1;var n=typeof t;return!("number"!==n&&"boolean"!==n&&null!=t&&!$o(t))||(Lo.test(t)||!Mo.test(t)||null!=e&&t in Object(e))},ya=function(t,e){return Array.isArray(t)?t:ma(t,e)?[t]:(o=[],(n=""+t).charCodeAt(0)===Co&&o.push(""),n.replace(No,function(t,e,n,i){var r=t;n?r=i.replace(_o,"$1"):e&&(r=e.trim()),o.push(r)}),o);var n,o},ba=function(t,e){for(var n=0,i=(e=ya(e,t)).length;null!=t&&n<i;)t=t[Aa(e[n])],n++;return n&&n==i?t:void 0};function wa(t,e){if(t!==e){var n=void 0!==t,i=null===t,r=t==t,o=$o(t),a=void 0!==e,s=null===e,u=e==e,l=$o(e);if(!s&&!l&&!o&&e<t||o&&a&&u&&!s&&!l||i&&a&&u||!n&&u||!r)return 1;if(!i&&!o&&!l&&t<e||l&&n&&r&&!i&&!o||s&&n&&r||!a&&r||!u)return-1}return 0}var xa=function(t,e){var n=function(t,e){return!!(null==t?0:t.length)&&-1<t.indexOf(e)},i=!0,r=[],o=e.length;if(!t.length)return r;200<=e.length&&(i=!(n=function(t,e){return t.has(e)}),e=new us(e));t:for(var a in t){var s=t[a],u=s;if(s=0!==s?s:0,i&&u==u){for(var l=o;l--;)if(e[l]===u)continue t;r.push(s)}else n(e,u)||r.push(s)}return r},Aa=function(t){if("string"==typeof t||$o(t))return t;var e=""+t;return"0"==e&&1/t==-1/0?"-0":e},Pa=function(n,i,r,o,a,t,e,s){var u;if(void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===o&&(o=!0),a&&(u=e?a(n,t,e,s):a(n)),void 0!==u)return u;if(!hs(n))return n;var l,h,c,d,f,p=Array.isArray(n),g=Jo(n);if(p){if(d=(c=n).length,f=new c.constructor(d),d&&"string"==typeof c[0]&&hasOwnProperty.call(c,"index")&&(f.index=c.index,f.input=c.input),u=f,!i)return Zo(n,u)}else{var v="function"==typeof n;if(g===Br||g===Lr||v&&!e){if(u=r||v?{}:ta(n),!i)return r?Ta(n,Yo(n,Object.keys(n),u)):(l=n,h=Object.assign(u,n),Yo(l,ea(l),h))}else{if(v||!Kr[g])return e?n:{};u=na(n,g,i)}}s||(s=new rs);var m,y,b=s.get(n);if(b)return b;if(s.set(n,u),Uo(m=n)&&Jo(m)==Rr)return n.forEach(function(t,e){u.set(e,Pa(t,i,r,o,a,e,n,s))}),u;if(Uo(y=n)&&Jo(y)==Ir)return n.forEach(function(t){u.add(Pa(t,i,r,o,a,t,n,s))}),u;if(ia(n))return u;var w=p?void 0:(o?r?aa:ra:r?Ca:Do)(n);return(w||n).forEach(function(t,e){w&&(t=n[e=t]),Wo(u,e,Pa(t,i,r,o,a,e,n,s))}),u},Ta=function(t,e){return Yo(t,oa(t),e)},Ea=function(t,e){return e.length<2?t:ba(t,e.slice(0,-1))},Sa=function(t,e,n){if(!hs(t))return t;for(var i=(e=ya(e,t)).length,r=i-1,o=-1,a=t;null!=a&&++o<i;){var s=Aa(e[o]),u=n;if(o!=r){var l=a[s];(u=void 0)===u&&(u=hs(l)?l:ka(e[o+1])?[]:{})}Wo(a,s,u),a=a[s]}return t},ka=function(t,e){var n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"===n||"symbol"!==n&&Oo.test(t))&&-1<t&&t%1==0&&t<e},Ma=function(t,e){e=ya(e,t),t=Ea(t,e);var n=e[e.length-1];return null==t||delete t[Aa(n)]},La=function(t){var e=typeof t;return"string"===e||"number"===e||"symbol"===e||"boolean"===e?"__proto__"!==t:null===t},Ca=function(t){var e=[];for(var n in t)e.push(n);return e},_a=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function Na(u,l){return void 0===l&&(l=!1),function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];var i=-1,r=e.length,o=1<r?e[r-1]:void 0,a=2<r?e[2]:void 0;for(o=3<u.length&&"function"==typeof o?(r--,o):l?function(t,e){if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,a&&Ho(e[0],e[1],a)&&(o=r<3?void 0:o,r=1),t=Object(t);++i<r;){var s=e[i];s&&u(t,s,i,o)}return t}}var Oa=function(i,r,o,a,s){i!==r&&Gs(r,function(t,e){if(hs(t))s||(s=new rs),Ra(i,r,e,o,Oa,a,s);else{var n=a?a(i[e],t,""+e,i,r,s):void 0;void 0===n&&(n=t),Fa(i,e,n)}},Ca)},Ra=function(t,e,n,i,r,o,a){var s=_a(t,n),u=_a(e,n),l=a.get(u);if(l)Fa(t,n,l);else{var h=o?o(s,u,""+n,t,e,a):void 0,c=void 0===h;if(c){var d=Array.isArray(u),f=!d&&ia(u);h=u,d||f?h=Array.isArray(s)?s:Uo(s)&&Xo(s)?Zo(s):f?Qo(u,!(c=!1)):[]:Ls(u)||Ka(u)?Ka(h=s)?h=function(t){t=Object(t);var e={};for(var n in t)e[n]=t[n];return e}(s):"function"!=typeof s&&hs(s)||(h=ta(u)):c=!1}c&&(a.set(u,h),r(h,u,i,o,a),a.delete(u)),Fa(t,n,h)}},Fa=function(t,e,n){(void 0===n||Go(t[e],n))&&(void 0!==n||e in t)||Wo(t,e,n)};var Ba=function(t,e){return t&&function(t,e,n){for(var i=Object(t),r=n(t),o=r.length,a=-1;o--;){var s=r[++a];if(!1===e(i[s],s,i))break}return t}(t,e,Do)},Va=function(t,e){if(null==t)return t;if(!Xo(t))return Ba(t,e);for(var n=t.length,i=Object(t),r=-1;++r<n&&!1!==e(i[r],r,i););return t};var Ia=Set&&1/va(new Set([void 0,-0]))[1]==1/0?function(t){return new Set(t)}:function(){};function Da(t,e,n,i,r,o){return hs(t)&&hs(e)&&(o.set(e,t),Oa(t,e,void 0,Da,o),o.delete(e)),t}function ja(t,n,i){n=n.length?n.map(function(e){return Array.isArray(e)?function(t){return ba(t,1===e.length?e[0]:e)}:e}):[function(t){return t}];var r=-1,o=-1,a=Xo(t)?new Array(t.length):[];return Va(t,function(e){var t=n.map(function(t){return t(e)});a[++o]={criteria:t,index:++r,value:e}}),function(t,e){var n=t.length;t.sort(e);for(;n--;)t[n]=t[n].value;return t}(a,function(t,e){return function(t,e,n){for(var i=-1,r=t.criteria,o=e.criteria,a=r.length,s=n.length;++i<a;){var u=i<s?n[i]:null,l=(u&&"function"==typeof u?u:wa)(r[i],o[i]);if(l)return u&&"function"!=typeof u?l*("desc"==u?-1:1):l}return t.index-e.index}(t,e,i)})}function za(t){return t==t&&!hs(t)}function Ga(e,n){return function(t){return null!=t&&(t[e]===n&&(void 0!==n||e in Object(t)))}}function Ua(t,e){return null!=t&&es(t,e,ts)}function Ha(e){var n=function(t){var e=Do(t),n=e.length;for(;n--;){var i=e[n],r=t[i];e[n]=[i,r,za(r)]}return e}(e);return 1===n.length&&n[0][2]?Ga(n[0][0],n[0][1]):function(t){return t===e||function(t,e,n,i){var r,o,a=n.length,s=a,u=!i;if(null==t)return!s;t=Object(t);for(;a--;)if(r=n[a],u&&r[2]?r[1]!==t[r[0]]:!(r[0]in t))return!1;for(;++a<s;){var l=(r=n[a])[0],h=t[l],c=r[1];if(u&&r[2]){if(void 0===h&&!(l in t))return!1}else{var d=new rs;if(i&&(o=i(h,c,l,t,e,d)),!(void 0===o?ua(c,h,d):o))return!1}}return!0}(t,e,n)}}function qa(t){return ma(t)?(n=Aa(t),function(t){return null==t?void 0:t[n]}):(e=t,function(t){return ba(t,e)});var e,n}function Wa(t){return"function"==typeof t?t:null==t?function(t){return t}:"object"==typeof t?Array.isArray(t)?(n=t[0],i=t[1],ma(n)&&za(i)?Ga(Aa(n),i):function(t){var e=ba(t,n);return void 0===e&&e===i?Ua(t,n):ua(i,e)}):Ha(t):qa(t);var n,i}function Ya(){var t=Wa;return arguments.length?t(arguments[0],arguments[1]):t}var Xa=function(t,e,n,i){var r=-1,o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},$a=function(t,i,r,o,e){return e(t,function(t,e,n){r=o?(o=!1,t):i(r,t,e,n)}),r};var Za=function(t){return Array.isArray(t)||Ka(t)||!(!t||!t[Symbol.isConcatSpreadable])};var Ja,Ka=function(t){return Uo(t)&&"[object Arguments]"==Jo(t)},Qa=function(t,e,n){for(var i=-1,r=e.length,o={};++i<r;){var a=e[i],s=ba(t,a);n(s,a)&&Sa(o,ya(a,t),s)}return o},ts=function(t,e){return null!=t&&e in Object(t)},es=function(t,e,n){for(var i,r=-1,o=(e=ya(e,t)).length,a=!1;++r<o;){var s=Aa(e[r]);if(!(a=null!=t&&n(t,s)))break;t=t[s]}return a||++r!=o?a:!!(o=null==t?0:t.length)&&("number"==typeof(i=o)&&-1<i&&i%1==0&&i<=Number.MAX_SAFE_INTEGER)&&ka(s,o)&&(Array.isArray(t)||Ka(t))},ns=function(t,e){return void 0!==e?t.match(e)||[]:(Ro(t)?t.match(Po):t.match(Fo))||[]},is=(Ja="toUpperCase",function(t){if(!t)return"";var e,n,i,r,o=Bo(t)?Vo(t):void 0,a=o?o[0]:t[0],s=o?(e=o,n=1,r=e.length,i=void 0===i?r:i,!n&&r<=i?e:e.slice(n,i)).join(""):t.slice(1);return a[Ja]()+s});var rs=function(t){var e=this.__data__=new os(t);this.size=e.size};rs.prototype.clear=function(){this.__data__=new os,this.size=0},rs.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},rs.prototype.get=function(t){return this.__data__.get(t)},rs.prototype.has=function(t){return this.__data__.has(t)},rs.prototype.set=function(t,e){var n=this.__data__;if(n instanceof os){var i=n.__data__;if(i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new as(i)}return n.set(t,e),this.size=n.size,this};var os=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}};os.prototype.clear=function(){this.__data__=[],this.size=0},os.prototype.delete=function(t){var e=this.__data__,n=zo(e,t);return!(n<0)&&(n==e.length-1?e.pop():e.splice(n,1),--this.size,!0)},os.prototype.get=function(t){var e=this.__data__,n=zo(e,t);return n<0?void 0:e[n][1]},os.prototype.has=function(t){return-1<zo(this.__data__,t)},os.prototype.set=function(t,e){var n=this.__data__,i=zo(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var as=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}};as.prototype.clear=function(){this.size=0,this.__data__={hash:new ss,map:new Map,string:new ss}},as.prototype.delete=function(t){var e=sa(this,t).delete(t);return this.size-=e?1:0,e},as.prototype.get=function(t){return sa(this,t).get(t)},as.prototype.has=function(t){return sa(this,t).has(t)},as.prototype.set=function(t,e){var n=sa(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};var ss=function(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}};ss.prototype.clear=function(){this.__data__=Object.create(null),this.size=0},ss.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ss.prototype.get=function(t){var e=this.__data__[t];return e===To?void 0:e},ss.prototype.has=function(t){return void 0!==this.__data__[t]},ss.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?To:e,this};var us=function(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new as;++e<n;)this.add(t[e])};us.prototype.add=function(t){return this.__data__.set(t,To),this},us.prototype.has=function(t){return this.__data__.has(t)},us.prototype.push=us.prototype.add;var ls=function(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&e.call(t)===_r},hs=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},cs=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Fr},ds=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Dr},fs=Na(function(t,e){if(qo(e)||Xo(e))Yo(e,Do(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&Wo(t,n,e[n])}),ps=fs,gs=ps,vs=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];var i=-1,r=e.length,o=2<r?e[2]:void 0;for(o&&Ho(e[0],e[1],o)&&(r=1);++i<r;){var a=e[i];if(null!=a)for(var s=Object.keys(a),u=s.length,l=-1;++l<u;){var h=s[l],c=t[h];(void 0===c||Go(c,Object.prototype[h])&&!hasOwnProperty.call(t,h))&&(t[h]=a[h])}}return t},ms=vs,ys=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.push(void 0,Da),Ws.apply(void 0,t)},bs=ys,ws=function(t,e){for(var n=[],i=arguments.length-2;0<i--;)n[i]=arguments[i+2];var r=-1,o="function"==typeof e,a=Xo(t)?new Array(t.length):[];return Va(t,function(t){a[++r]=o?e.apply(t,n):xs.apply(void 0,[t,e].concat(n))}),a},xs=function(t,e){for(var n=[],i=arguments.length-2;0<i--;)n[i]=arguments[i+2];e=ya(e,t);var r,o,a=null==(t=Ea(t,e))?t:t[Aa((r=e,o=null==r?0:r.length,o?r[o-1]:void 0))];return null==a?void 0:a.apply(t,n)},As=function(t,e,n){var i=0,r=null==t?0:t.length;if(0==r)return 0;for(var o=(e=(n=Ya(n,2))(e))!=e,a=null===e,s=$o(e),u=void 0===e;i<r;){var l=Math.floor((i+r)/2),h=n(t[l]),c=void 0!==h,d=null===h,f=h==h,p=$o(h);(o?f:u?f&&c:a?f&&c&&!d:s?f&&c&&!d&&!p:!d&&!p&&h<e)?i=l+1:r=l}return Math.min(r,4294967294)},Ps=function(t,e){var n=-1,i=function(t,e){return!!(null==t?0:t.length)&&-1<t.indexOf(e)};e=Ya(e,2);var r=!0,o=t.length,a=[],s=a;if(200<=o){var u=e?null:Ia(t);if(u)return va(u);r=!1,i=function(t,e){return t.has(e)},s=new us}else s=e?[]:a;t:for(;++n<o;){var l=t[n],h=e?e(l):l;if(l=0!==l?l:0,r&&h==h){for(var c=s.length;c--;)if(s[c]===h)continue t;e&&s.push(h),a.push(l)}else i(s,h)||(s!==a&&s.push(h),a.push(l))}return a},Ts=function(t){return Pa(t)},Es=function(t){return Pa(t,!0)},Ss=function(t){if(null==t)return!0;if(Xo(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||ia(t)||Ka(t)))return!t.length;var e=Jo(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(qo(t))return!function(t){if(!qo(t))return Object.keys(t);var e=[];for(var n in Object(t))hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t).length;for(var n in t)if(hasOwnProperty.call(t,n))return!1;return!0},ks=function(t,e){return ua(t,e)},Ms=function(t){return"function"==typeof t},Ls=function(t){if(!Uo(t)||"[object Object]"!=Jo(t))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},Cs=function(t){if(!t)return[];if(Xo(t))return ds(t)?Vo(t):Zo(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=Jo(t);return(r==Rr?ga:r==Ir?va:Io)(t)};function _s(i,o,t){if("function"!=typeof i)throw new TypeError("Expected a function");var a,s,r,u,l,h,c=0,d=!1,f=!1,e=!0,n=!o&&0!==o&&window&&"function"==typeof window.requestAnimationFrame;function p(t){var e=a,n=s;return a=s=void 0,c=t,u=i.apply(n,e)}function g(t,e){return n?(window.cancelAnimationFrame(l),window.requestAnimationFrame(t)):setTimeout(t,e)}function v(t){var e=t-h;return void 0===h||o<=e||e<0||f&&r<=t-c}function m(){var t,e,n,i=Date.now();if(v(i))return y(i);l=g(m,(e=(t=i)-c,n=o-(t-h),f?Math.min(n,r-e):n))}function y(t){return l=void 0,e&&a?p(t):(a=s=void 0,u)}function b(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n,i=Date.now(),r=v(i);if(a=t,s=this,h=i,r){if(void 0===l)return c=n=h,l=g(m,o),d?p(n):u;if(f)return l=g(m,o),p(h)}return void 0===l&&(l=g(m,o)),u}return o=+o||0,hs(t)&&(d=!!t.leading,r=(f="maxWait"in t)?Math.max(+t.maxWait||0,o):r,e="trailing"in t?!!t.trailing:e),b.cancel=function(){void 0!==l&&function(t){if(n)return window.cancelAnimationFrame(t);clearTimeout(t)}(l),a=h=s=l=void(c=0)},b.flush=function(){return void 0===l?u:y(Date.now())},b.pending=function(){return void 0!==l},b}var Ns=function(t,i){return i=Ya(i,2),function(t,e,n){return(Array.isArray(t)?Xa:$a)(t,e,n,arguments.length<3,Va)}(t,function(t,e,n){return n=i(e),hasOwnProperty.call(t,n)?t[n].push(e):Wo(t,n,[e]),t},{})},Os=function(t,e){if(void 0===e&&(e=[]),null==t)return[];var n=e.length;return 1<n&&Ho(t,e[0],e[1])?e=[]:2<n&&Ho(e[0],e[1],e[2])&&(e=[e[0]]),Array.isArray(e)||(e=[Ya(e,2)]),ja(t,e.flat(1),[])},Rs=function(t){return(null==t?0:t.length)?function t(e,n,i,r,o){var a=-1,s=e.length;for(i||(i=Za),o||(o=[]);++a<s;){var u=e[a];0<n&&i(u)?1<n?t(u,n-1,i,r,o):o.push.apply(o,u):r||(o[o.length]=u)}return o}(t,1/0):[]},Fs=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];return Xo(t)?xa(t,e):[]},Bs=function(t){for(var e=[],n=arguments.length-1;0<n--;)e[n]=arguments[n+1];return Uo(t)&&Xo(t)?xa(t,e.flat(1)):[]},Vs=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t.flat(1);return Ps(n)},Is=function(t,e){if(null==t)return!1;"string"==typeof e&&(e=e.split("."));for(var n=-1,i=t;++n<e.length;){if(!i||!hasOwnProperty.call(i,e[n]))return!1;i=i[e[n]]}return!0},Ds=function(t,e,n){var i=-1,r=(e=ya(e,t)).length;for(r||(r=1,t=void 0);++i<r;){var o=null==t?void 0:t[Aa(e[i])];void 0===o&&(i=r,o=n),t="function"==typeof o?o.call(t):o}return t},js=function(e){for(var t=[],n=arguments.length-1;0<n--;)t[n]=arguments[n+1];var i={};if(null==e)return i;var r=!1;t=t.flat(1).map(function(t){return t=ya(t,e),r||(r=1<t.length),t}),Yo(e,aa(e),i),r&&(i=Pa(i,!0,!0,!0,function(t){return Ls(t)?void 0:t}));for(var o=t.length;o--;)Ma(i,t[o]);return i},zs=function(t){for(var n,e,i=[],r=arguments.length-1;0<r--;)i[r]=arguments[r+1];return null==t?{}:(n=t,e=i.flat(1/0),Qa(n,e,function(t,e){return Ua(n,e)}))},Gs=function(t,e){void 0===e&&(e=function(t){return t});for(var n=-1,i=Object(t),r=Xo(t)?jo(t,!0):Ca(t),o=r.length;o--;){var a=r[++n];if(!1===e(i[a],a,i))break}},Us=function(t){return void 0===t&&(t=""),ns((""+t).replace(/['\u2019]/g,"")).reduce(function(t,e,n){return e=e.toLowerCase(),t+(n?is(e):e)},"")},Hs=0,qs=function(t){return void 0===t&&(t=""),""+t+ ++Hs},Ws=Na(function(t,e,n,i){Oa(t,e,n,i)},!0),Ys=function(){this.map=new WeakMap};Ys.prototype.has=function(t,e){return void 0===e?this.map.has(t):e in this.map.get(t)},Ys.prototype.create=function(t){return this.has(t)||this.map.set(t,Object.create(null)),this.get(t)},Ys.prototype.get=function(t,e){if(this.has(t)){var n=this.map.get(t);return void 0===e?n:n[e]}},Ys.prototype.set=function(t,e,n){if(void 0!==e){var i=this.create(t);"string"==typeof e?i[e]=n:Object.assign(i,e)}},Ys.prototype.remove=function(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])};var Xs=new Ys,$s=new Ys,Zs=function(t,e){if(!(this instanceof Zs))return new Zs(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?Js:Ks,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&Object.assign(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this.envelope=!0};function Js(){return!0}function Ks(){return!1}Zs.prototype={constructor:Zs,isDefaultPrevented:Ks,isPropagationStopped:Ks,isImmediatePropagationStopped:Ks,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=Js,t&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=Js,t&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=Js,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(function(t){return e=t,void Object.defineProperty(Zs.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})}});var e});var Qs="undefined"!=typeof window?window.document:null,tu=Qs&&Qs.documentElement,eu=/^([^.]*)(?:\.(.+)|)/,nu=/[^\x20\t\r\n\f]+/g,iu=function(t){return new iu.Dom(t)};iu.fn=iu.prototype={constructor:iu,length:0},iu.guid=1,iu.data=$s,iu.merge=function(t,e){for(var n=+e.length,i=t.length,r=0;r<n;r++)t[i++]=e[r];return t.length=i,t},iu.parseHTML=function(t){var e=Qs.implementation.createHTMLDocument(),n=e.createElement("base");n.href=Qs.location.href,e.head.appendChild(n),e.body.innerHTML=t;for(var i=e.getElementsByTagName("script"),r=0;r<i.length;r++)i[r].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(iu.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),iu.fn.toArray=function(){return Array.from(this)},iu.fn.pushStack=function(t){var e=iu.merge(this.constructor(),t);return e.prevObject=this,e},iu.fn.find=function(t){var e=this[0],n=this.pushStack([]);if(!e)return n;var i=e.nodeType;return 1!==i&&9!==i&&11!==i||("string"!=typeof t?e!==t&&e.contains(t)&&iu.merge(n,[t]):iu.merge(n,e.querySelectorAll(t))),n},iu.fn.add=function(t,e){var n=iu(t,e).toArray(),i=this.toArray(),r=this.pushStack([]);return iu.merge(r,Ps(i.concat(n))),r},iu.fn.addBack=function(){return this.add(this.prevObject)},iu.fn.filter=function(t){for(var e=[],n=0;n<this.length;n++){var i=this[n];i.matches(t)&&e.push(i)}return this.pushStack(e)};var ru=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;var ou=function(t){if(!t)return this;if("function"==typeof t)throw new Error("function not supported");if(1<arguments.length)throw new Error("selector with context not supported");if(t.nodeType)return this[0]=t,this.length=1,this;var e,n;if("<"===(n=t+"")[0]&&">"===n[n.length-1]&&3<=n.length)e=[null,t,null];else{if("string"!=typeof t)return iu.merge(this,t);e=ru.exec(t)}if(!e||!e[1])return au.find(t);if(e[1])return iu.merge(this,iu.parseHTML(e[1])),this;var i=Qs.getElementById(e[2]);return i&&(this[0]=i,this.length=1),this};(iu.Dom=ou).prototype=iu.fn,iu.Event=Zs,iu.event={special:Object.create(null)},iu.event.has=function(t,e){var n=Xs.get(t,"events");return!!n&&(!e||Array.isArray(n[e])&&0<n[e].length)},iu.event.on=function(t,e,n,i,r,o){if("object"==typeof e){for(var a in"string"!=typeof n&&(i=i||n,n=void 0),e)iu.event.on(t,a,n,i,e[a],o);return t}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!r)return t;if(1===o){var s=r;(r=function(t){return iu().off(t),s.apply(this,arguments)}).guid=s.guid||(s.guid=iu.guid++)}for(var u=0;u<t.length;u++)iu.event.add(t[u],e,r,i,n)},iu.event.add=function(e,t,n,i,r){if("object"==typeof e){var o,a,s,u=Xs.create(e);n.handler&&(n=(o=n).handler,r=o.selector),r&&tu.matches(r),n.guid||(n.guid=iu.guid++),(a=u.events)||(a=u.events=Object.create(null)),(s=u.handle)||(s=u.handle=function(t){return void 0!==iu?iu.event.dispatch.apply(e,arguments):void 0});for(var l=(t||"").match(nu)||[""],h=l.length;h--;){var c=eu.exec(l[h]),d=c[1],f=c[2];if(void 0===f&&(f=""),d){var p=f.split(".").sort(),g=iu.event.special[d],v=g&&(r?g.delegateType:g.bindType)||d;g=iu.event.special[v];var m=Object.assign({type:v,origType:d,data:i,handler:n,guid:n.guid,selector:r,namespace:p.join(".")},o),y=void 0;(y=a[v])||((y=a[v]=[]).delegateCount=0,g&&g.setup&&!1!==g.setup.call(e,i,p,s)||e.addEventListener&&e.addEventListener(v,s)),g&&g.add&&(g.add.call(e,m),m.handler.guid||(m.handler.guid=n.guid)),r?y.splice(y.delegateCount++,0,m):y.push(m)}}}},iu.event.remove=function(t,e,n,i,r){var o=Xs.get(t);if(o&&o.events){for(var a=o.events,s=(e||"").match(nu)||[""],u=s.length;u--;){var l=eu.exec(s[u]),h=l[1],c=l[2];if(void 0===c&&(c=""),h){var d=iu.event.special[h],f=d&&(i?d.delegateType:d.bindType)||h,p=a[f];if(p&&0!==p.length){for(var g=c.split(".").sort(),v=c?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=p.length,y=m;y--;){var b=p[y];!r&&h!==b.origType||n&&n.guid!==b.guid||v&&!v.test(b.namespace)||i&&i!==b.selector&&("**"!==i||!b.selector)||(p.splice(y,1),b.selector&&p.delegateCount--,d&&d.remove&&d.remove.call(t,b))}m&&0===p.length&&(d&&d.teardown&&!1!==d.teardown.call(t,g,o.handle)||t.removeEventListener&&t.removeEventListener(f,o.handle),delete a[f])}}else for(var w in a)iu.event.remove(t,w+s[u],n,i,!0)}Ss(a)&&(Xs.remove(t,"handle"),Xs.remove(t,"events"))}},iu.event.dispatch=function(t){var e=iu.event.fix(t);e.delegateTarget=this;var n=Array.from(arguments);n[0]=e;var i=Xs.get(this,"events"),r=i&&i[e.type]||[],o=iu.event.special[e.type];if(!o||!o.preDispatch||!1!==o.preDispatch.call(this,e)){for(var a,s=iu.event.handlers.call(this,e,r),u=0;(a=s[u++])&&!e.isPropagationStopped();){e.currentTarget=a.elem;for(var l=0,h=void 0;(h=a.handlers[l++])&&!e.isImmediatePropagationStopped();){e.handleObj=h,e.data=h.data;var c=iu.event.special[h.origType],d=(c&&c.handle?c.handle:h.handler).apply(a.elem,n);void 0!==d&&!1===(e.result=d)&&(e.preventDefault(),e.stopPropagation())}}return o&&o.postDispatch&&o.postDispatch.call(this,e),e.result}},iu.event.handlers=function(t,e){var n=e.delegateCount,i=[];if(n&&!("click"===t.type&&1<=t.button))for(var r=t.target;r!==this;r=r.parentNode||this)if(1===r.nodeType&&("click"!==t.type||!0!==r.disabled)){for(var o=[],a={},s=0;s<n;s++){var u=e[s],l=u.selector+" ";void 0===a[l]&&(a[l]=r.matches(l)),a[l]&&o.push(u)}o.length&&i.push({elem:r,handlers:o})}return n<e.length&&i.push({elem:this,handlers:e.slice(n)}),i},iu.event.fix=function(t){return t.envelope?t:new Zs(t)};var au=iu(Qs),su=function(){if(!("object"==typeof window&&!!window.SVGAngle))return function(){throw new Error("SVG is required to use Vectorizer.")};var F={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},t=Math,g=t.PI,o=t.atan2,a=t.sqrt,c=t.min,d=t.max,v=t.cos,m=t.sin,B=function(t,e,n){if(!(this instanceof B))return B.apply(Object.create(B.prototype),arguments);if(t){if(B.isV(t)&&(t=t.node),e=e||{},B.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=B.createSvgDocument();else if("<"===t[0]){var i=B.createSvgDocument(t);if(1<i.childNodes.length){var r,o,a=[];for(r=0,o=i.childNodes.length;r<o;r++){var s=i.childNodes[r];a.push(new B(document.importNode(s,!0)))}return a}t=document.importNode(i.firstChild,!0)}else t=document.createElementNS(F.svg,t);B.ensureId(t)}return this.node=t,this.setAttributes(e),n&&this.append(n),this}},e=B.prototype;function V(t,e,n){n||(n={});for(var i=n.includeAnnotationIndices,r=n.eol,o=n.lineHeight,a=n.baseSize,s=0,u={},l=e.length-1,h=0;h<=l;h++){var c=e[h],d=null;if(B.isObject(c)){var f=c.attrs,p=B("tspan",f),g=p.node,v=c.t;r&&h===l&&(v+=r),g.textContent=v;var m=f.class;m&&p.addClass(m),i&&p.attr("annotations",c.annotations),d=parseFloat(f["font-size"]),isFinite(d)||(d=a),d&&s<d&&(s=d)}else r&&h===l&&(c+=r),g=document.createTextNode(c||" "),a&&s<a&&(s=a);t.appendChild(g)}return s&&(u.maxFontSize=s),o?u.lineHeight=o:s&&(u.lineHeight=1.2*s),u}Object.defineProperty(e,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),e.getTransformToElement=function(t){var e=this.node;if(B.isSVGGraphicsElement(t)&&B.isSVGGraphicsElement(e)){var n=B.toNode(t).getScreenCTM(),i=e.getScreenCTM();if(n&&i)return n.inverse().multiply(i)}return B.createSVGMatrix()},e.transform=function(t,e){var n=this.node;if(B.isUndefined(t))return B.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",B.matrixToTransformString(t));var i=B.createSVGTransform(t);return n.transform.baseVal.appendItem(i),this},e.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=B.parseTransformString(i);if(i=r.value,B.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();var o="translate("+(n.absolute?t:r.translate.tx+t)+","+(n.absolute?e:r.translate.ty+e)+")";return this.attr("transform",(o+" "+i).trim()),this},e.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=B.parseTransformString(r);if(r=o.value,B.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;var a="rotate("+(i.absolute?t:o.rotate.angle+t)+(void 0!==e&&void 0!==n?","+e+","+n:"")+")";return this.attr("transform",(r+" "+a).trim()),this},e.scale=function(t,e){e=B.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=B.parseTransformString(n);if(n=i.value,B.isUndefined(t))return i.scale;n=n.replace(/scale\([^)]*\)/g,"").trim();var r="scale("+t+","+e+")";return this.attr("transform",(n+" "+r).trim()),this},e.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new Ei(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(t)return new Ei(n);var o=this.getTransformToElement(e||r);return B.transformRect(n,o)},e.getBBox=function(t){var e,n={},i=this.node;if(!i.ownerSVGElement||!B.isSVGGraphicsElement(i))return new Ei(0,0,0,0);if(t&&(t.target&&(n.target=B.toNode(t.target)),t.recursive&&(n.recursive=t.recursive)),n.recursive){var r=this.children(),o=r.length;if(0===o)return this.getBBox({target:n.target,recursive:!1});n.target||(n.target=this);for(var a=0;a<o;a++){var s,u=r[a];s=0===u.children().length?u.getBBox({target:n.target,recursive:!1}):u.getBBox({target:n.target,recursive:!0}),e=e?e.union(s):s}return e}try{e=i.getBBox()}catch(t){e={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(n.target){var l=this.getTransformToElement(n.target);return B.transformRect(e,l)}return new Ei(e)};var I=/em$/;function D(t,e){var n=parseFloat(t);return I.test(t)?n*e:n}e.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");t=B.sanitizeText(t),e||(e={});var n=e.displayEmpty,i=e.eol,r=e.textPath,o=e.textVerticalAnchor,a="middle"===o||"bottom"===o||"top"===o,s=e.x;void 0===s&&(s=this.attr("x")||0);var u=e.includeAnnotationIndices,l=e.annotations;l&&!B.isArray(l)&&(l=[l]);var h=e.lineHeight,c="auto"===h,d=c?"1.5em":h||"1em";this.empty(),this.attr({"xml:space":"preserve",display:t||n?null:"none"});var f=parseFloat(this.attr("font-size"));f||(f=16,(a||l)&&this.attr("font-size",f));var p,g=document;p=r?("string"==typeof r&&(r={d:r}),function(t,e){t||(t={});var n=B("textPath"),i=t.d;if(i&&void 0===t["xlink:href"]){var r=B("path").attr("d",i).appendTo(e.defs());n.attr("xlink:href","#"+r.id)}return B.isObject(t)&&n.attr(t),n.node}(r,this)):g.createDocumentFragment();for(var v,m=0,y=t.split("\n"),b=[],w=0,x=y.length-1;w<=x;w++){var A,P=d,T="v-line",E=g.createElementNS(F.svg,"tspan"),S=y[w];if(S)if(l){var k=B.annotateString(S,l,{offset:-m,includeAnnotationIndices:u}),M=(A=V(E,k,{includeAnnotationIndices:u,eol:w!==x&&i,lineHeight:c?null:d,baseSize:f})).lineHeight;M&&c&&0!==w&&(P=M),0===w&&(v=.8*A.maxFontSize)}else i&&w!==x&&(S+=i),E.textContent=S;else{E.textContent="-",T+=" v-empty-line";var L=E.style;if(L.fillOpacity=0,L.strokeOpacity=0,l){A={};for(var C=f,_=(k=B.findAnnotationsAtIndex(l,m)).length;0<_;_--){var N=k[_-1].attrs;if(N&&"font-size"in N){var O=parseFloat(N["font-size"]);if(isFinite(O)){C=O;break}}}c&&(0<w?P=1.2*C:v=.8*C),E.setAttribute("font-size",C),A.maxFontSize=C}}A&&b.push(A),0<w&&E.setAttribute("dy",P),(0<w||r)&&E.setAttribute("x",s),E.className.baseVal=T,p.appendChild(E),m+=S.length+1}if(a)if(l)P=function(t,e,n,i){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],a=D(o.maxFontSize,n)||n,s=0,u=D(i,n),l=1;l<r;l++)s+=D((o=e[l]).lineHeight,n)||u;var h,c=D(o.maxFontSize,n)||n;switch(t){case"middle":h=a/2-.15*c-s/2;break;case"bottom":h=-.25*c-s;break;default:case"top":h=.8*a}return h}(o,b,f,d);else if("top"===o)P="0.8em";else{var R;switch(0<x?(R=parseFloat(d)||1,R*=x,I.test(d)||(R/=f)):R=0,o){case"middle":P=.3-R/2+"em";break;case"bottom":P=-R-.3+"em"}}else 0===o?P="0em":o?P=o:(P=0,null===this.attr("y")&&this.attr("y",v||"0.8em"));return p.firstChild.setAttribute("dy",P),this.append(p),this},e.removeAttr=function(t){var e=s[t],n=B.qualifyAttr(e),i=n.ns,r=n.local,o=this.node;return i?o.hasAttributeNS(i,r)&&o.removeAttributeNS(i,r):o.hasAttribute(e)&&o.removeAttribute(e),this},e.attr=function(t,e){if(B.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(B.isString(t)&&B.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},e.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",B.normalizePathData(this.attr("d"))),this},e.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},e.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},e.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},e.append=function(t){B.isArray(t)||(t=[t]);for(var e=0,n=t.length;e<n;e++)this.node.appendChild(B.toNode(t[e]));return this},e.prepend=function(t){var e=this.node.firstChild;return e?B(e).before(t):this.append(t)},e.before=function(t){var e=this.node,n=e.parentNode;if(n){B.isArray(t)||(t=[t]);for(var i=0,r=t.length;i<r;i++)n.insertBefore(B.toNode(t[i]),e)}return this},e.appendTo=function(t){return B.toNode(t).appendChild(this.node),this},e.svg=function(){return this.node instanceof window.SVGSVGElement?this:B(this.node.ownerSVGElement)},e.tagName=function(){return this.node.tagName.toUpperCase()},e.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?B(e):B("defs").appendTo(t)},e.clone=function(){var t=B(this.node.cloneNode(!0));return t.node.id=B.uniqueId(),t},e.findOne=function(t){var e=this.node.querySelector(t);return e?B(e):void 0},e.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(B(n[i]));return e},e.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++){1===t[n].nodeType&&e.push(B(t[n]))}return e},e.parent=function(){return B(this.node.parentNode)||null},e.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},e.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=B(i);if(r.hasClass(t))return r;i=i.parentNode}return null},e.contains=function(t){var e=this.node,n=B.toNode(t),i=n&&n.parentNode;return e===i||!!(i&&1===i.nodeType&&16&e.compareDocumentPosition(i))},e.toLocalPoint=function(t,e){var n=this.svg().node,i=n.createSVGPoint();i.x=t,i.y=e;try{var r=i.matrixTransform(n.getScreenCTM().inverse()),o=this.getTransformToElement(n).inverse()}catch(t){return i}return r.matrixTransform(o)},e.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},e.translateAndAutoOrient=function(t,e,n){t=new si(t),e=new si(e),n||(n=this.svg());var i=this.scale();this.attr("transform","");var r=this.getBBox({target:n}).scale(i.sx,i.sy),o=B.createSVGTransform();o.setTranslate(-r.x-r.width/2,-r.y-r.height/2);var a=B.createSVGTransform(),s=t.angleBetween(e,t.clone().offset(1,0));s&&a.setRotate(s,0,0);var u=B.createSVGTransform(),l=t.clone().move(e,r.width/2);u.setTranslate(2*t.x-l.x,2*t.y-l.y);var h=this.getTransformToElement(n),c=B.createSVGTransform();return c.setMatrix(u.matrix.multiply(a.matrix.multiply(o.matrix.multiply(h.scale(i.sx,i.sy))))),this.attr("transform",B.matrixToTransformString(c.matrix)),this},e.animateAlongPath=function(t,e){e=B.toNode(e);var n=B.ensureId(e),i=B("animateMotion",t),r=B("mpath",{"xlink:href":"#"+n});i.append(r),this.append(i);try{i.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling")){var o=i.node;o.animators=[];var a=o.getAttribute("id");a&&(id2anim[a]=o);for(var s=getTargets(o),u=0,l=s.length;u<l;u++){var h=s[u],c=new Animator(o,h,u);animators.push(c),(o.animators[u]=c).register()}}}return this};var n=/[^\x20\t\r\n\f]+/g;function r(t){return B.isString(t)&&t.trim().match(n)||[]}e.hasClass=function(t){return!!B.isString(t)&&this.node.classList.contains(t.trim())},e.addClass=function(t){var e;return(e=this.node.classList).add.apply(e,r(t)),this},e.removeClass=function(t){var e;return(e=this.node.classList).remove.apply(e,r(t)),this},e.toggleClass=function(t,e){for(var n=r(t),i=0;i<n.length;i++)this.node.classList.toggle(n[i],e);return this},e.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},e.convertToPath=function(){var t=B("path");t.attr(this.attr());var e=this.convertToPathData();return e&&t.attr("d",e),t},e.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return B.convertLineToPathData(this.node);case"POLYGON":return B.convertPolygonToPathData(this.node);case"POLYLINE":return B.convertPolylineToPathData(this.node);case"ELLIPSE":return B.convertEllipseToPathData(this.node);case"CIRCLE":return B.convertCircleToPathData(this.node);case"RECT":return B.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},B.prototype.toGeometryShape=function(){var t,e,n,i,r,o,a,s,u,l,h,c,d,f,p;switch(this.tagName()){case"RECT":return t=parseFloat(this.attr("x"))||0,e=parseFloat(this.attr("y"))||0,n=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new Ei(t,e,n,i);case"CIRCLE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,a=parseFloat(this.attr("r"))||0,new vi({x:r,y:o},a,a);case"ELLIPSE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,u=parseFloat(this.attr("ry"))||0,new vi({x:r,y:o},s,u);case"POLYLINE":return l=B.getPointsFromSvgNode(this),new Ci(l);case"POLYGON":return 1<(l=B.getPointsFromSvgNode(this)).length&&l.push(l[0]),new Ci(l);case"PATH":return h=this.attr("d"),Ii.isDataSupported(h)||(h=B.normalizePathData(h)),new Ii(h);case"LINE":return c=parseFloat(this.attr("x1"))||0,f=parseFloat(this.attr("y1"))||0,d=parseFloat(this.attr("x2"))||0,p=parseFloat(this.attr("y2"))||0,new ci({x:c,y:f},{x:d,y:p})}return this.getBBox()},e.findIntersection=function(t,e){var n=this.svg().node;e=e||n;var i=this.getBBox({target:e}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){var o,a=this.tagName();if("RECT"===a){var s=new Ei(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),u=this.getTransformToElement(e),l=B.decomposeMatrix(u),h=n.createSVGTransform();h.setRotate(-l.rotation,r.x,r.y);var c=B.transformRect(s,h.matrix.multiply(u));o=new Ei(c).intersectionWithLineFromCenterToPoint(t,l.rotation)}else if("PATH"===a||"POLYGON"===a||"POLYLINE"===a||"CIRCLE"===a||"ELLIPSE"===a){var d,f,p,g,v,m=("PATH"===a?this:this.convertToPath()).sample(),y=1/0,b=[];for(d=0;d<m.length;d++)f=m[d],p=(p=B.createSVGPoint(f.x,f.y)).matrixTransform(this.getTransformToElement(e)),(v=(f=new si(p)).distance(r)+(g=1.1*f.distance(t)))<y?(y=v,b=[{sample:f,refDistance:g}]):v<y+1&&b.push({sample:f,refDistance:g});b.sort(function(t,e){return t.refDistance-e.refDistance}),b[0]&&(o=b[0].sample)}return o}},e.setAttribute=function(t,e){var n=this.node;if(null===e)return this.removeAttr(t),this;var i=s[t],r=B.qualifyAttr(i).ns;return r?n.setAttributeNS(r,i,e):"id"===i?n.id=e:n.setAttribute(i,e),this},B.createSvgDocument=function(t){if(t){var e='<svg xmlns="'+F.svg+'" xmlns:xlink="'+F.xlink+'" version="1.1">'+t+"</svg>";return B.parseXML(e,{async:!1}).documentElement}var n=document.createElementNS(F.svg,"svg");return n.setAttributeNS(F.xmlns,"xmlns:xlink",F.xlink),n.setAttribute("version","1.1"),n},B.createSVGStyle=function(t){return B("style",{type:"text/css"},[B.createCDATASection(t)]).node},B.createCDATASection=function(t){return void 0===t&&(t=""),document.implementation.createDocument(null,"xml",null).createCDATASection(t)},B.idCounter=0,B.uniqueId=function(){return"v-"+ ++B.idCounter},B.toNode=function(t){return B.isV(t)?t.node:t.nodeName&&t||t[0]},B.ensureId=function(t){return(t=B.toNode(t)).id||(t.id=B.uniqueId())},B.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},B.isUndefined=function(t){return void 0===t},B.isString=function(t){return"string"==typeof t},B.isObject=function(t){return t&&"object"==typeof t},B.isArray=Array.isArray,B.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;B.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch(t){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};var i=Object.create(null);["baseFrequency","baseProfile","clipPathUnits","contentScriptType","contentStyleType","diffuseConstant","edgeMode","externalResourcesRequired","filterRes","filterUnits","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach(function(t){return i[t]=t}),i.xlinkShow="xlink:show",i.xlinkRole="xlink:role",i.xlinkActuate="xlink:actuate",i.xlinkHref="xlink:href",i.xlinkType="xlink:type",i.xlinkTitle="xlink:title",i.xmlBase="xml:base",i.xmlLang="xml:lang",i.xmlSpace="xml:space";var s=new Proxy(i,{get:function(t,e){return B.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e}});Object.defineProperty(B,"attributeNames",{enumerable:!0,value:s,writable:!1}),Object.defineProperty(B,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),B.qualifyAttr=function(t){if(-1===t.indexOf(":"))return{ns:null,local:t};var e=t.split(":");return{ns:F[e[0]],local:e[1]}},B.transformSeparatorRegex=/[ ,]+/,B.transformRegex=/\b\w+\([^()]+\)/g,B.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,B.transformTranslateRegex=/\btranslate\(([^()]+)\)/,B.transformRotateRegex=/\brotate\(([^()]+)\)/,B.transformScaleRegex=/\bscale\(([^()]+)\)/,B.transformStringToMatrix=function(t){var e=B.createSVGMatrix(),n=t&&t.match(B.transformRegex);if(!n)return e;for(var i=n.length,r=0;r<i;r++){var o=n[r].match(B.transformFunctionRegex);if(o){var a=void 0,s=void 0,u=void 0,l=void 0,h=void 0,c=B.createSVGMatrix(),d=o[1].toLowerCase(),f=o[2].split(B.transformSeparatorRegex);switch(d){case"scale":a=parseFloat(f[0]),s=void 0===f[1]?a:parseFloat(f[1]),c=c.scaleNonUniform(a,s);break;case"translate":u=parseFloat(f[0]),l=parseFloat(f[1]),c=c.translate(u,l);break;case"rotate":h=parseFloat(f[0]),u=parseFloat(f[1])||0,l=parseFloat(f[2])||0,c=0!==u||0!==l?c.translate(u,l).rotate(h).translate(-u,-l):c.rotate(h);break;case"skewx":h=parseFloat(f[0]),c=c.skewX(h);break;case"skewy":h=parseFloat(f[0]),c=c.skewY(h);break;case"matrix":c.a=parseFloat(f[0]),c.b=parseFloat(f[1]),c.c=parseFloat(f[2]),c.d=parseFloat(f[3]),c.e=parseFloat(f[4]),c.f=parseFloat(f[5]);break;default:continue}e=e.multiply(c)}}return e},B.matrixToTransformString=function(t){return t||(t=!0),"matrix("+(void 0!==t.a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},B.parseTransformString=function(t){var e,n,i;if(t){var r=B.transformSeparatorRegex;if(0<=t.trim().indexOf("matrix")){var o=B.transformStringToMatrix(t),a=B.decomposeMatrix(o);e=[a.translateX,a.translateY],i=[a.scaleX,a.scaleY],n=[a.rotation];var s=[];0===e[0]&&0===e[1]||s.push("translate("+e+")"),1===i[0]&&1===i[1]||s.push("scale("+i+")"),0!==n[0]&&s.push("rotate("+n+")"),t=s.join(" ")}else{var u=t.match(B.transformTranslateRegex);u&&(e=u[1].split(r));var l=t.match(B.transformRotateRegex);l&&(n=l[1].split(r));var h=t.match(B.transformScaleRegex);h&&(i=h[1].split(r))}}var c=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:e&&e[0]?parseInt(e[0],10):0,ty:e&&e[1]?parseInt(e[1],10):0},rotate:{angle:n&&n[0]?parseInt(n[0],10):0,cx:n&&n[1]?parseInt(n[1],10):void 0,cy:n&&n[2]?parseInt(n[2],10):void 0},scale:{sx:c,sy:i&&i[1]?parseFloat(i[1]):c}}},B.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c+0,y:e.x*t.b+e.y*t.d+0}},B.decomposeMatrix=function(t){var e=B.deltaTransformPoint(t,{x:0,y:1}),n=B.deltaTransformPoint(t,{x:1,y:0}),i=180/g*o(e.y,e.x)-90,r=180/g*o(n.y,n.x);return{translateX:t.e,translateY:t.f,scaleX:a(t.a*t.a+t.b*t.b),scaleY:a(t.c*t.c+t.d*t.d),skewX:i,skewY:r,rotation:i}},B.matrixToScale=function(t){var e,n,i,r;return t?(e=B.isUndefined(t.a)?1:t.a,r=B.isUndefined(t.d)?1:t.d,n=t.b,i=t.c):e=r=1,{sx:n?a(e*e+n*n):e,sy:i?a(i*i+r*r):r}},B.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=B.deltaTransformPoint(t,e)),{angle:Dn(zn(o(e.y,e.x))-90)}},B.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},B.isV=function(t){return t instanceof B},B.isVElement=B.isV,B.isSVGGraphicsElement=function(t){return!!t&&((t=B.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM)};var f=B("svg").node;return B.createSVGMatrix=function(t){var e=f.createSVGMatrix();for(var n in t)e[n]=t[n];return e},B.createSVGTransform=function(t){return B.isUndefined(t)?f.createSVGTransform():(t instanceof SVGMatrix||(t=B.createSVGMatrix(t)),f.createSVGTransformFromMatrix(t))},B.createSVGPoint=function(t,e){var n=f.createSVGPoint();return n.x=t,n.y=e,n},B.transformRect=function(t,e){var n=f.createSVGPoint();n.x=t.x,n.y=t.y;var i=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y;var r=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y+t.height;var o=n.matrixTransform(e);n.x=t.x,n.y=t.y+t.height;var a=n.matrixTransform(e),s=c(i.x,r.x,o.x,a.x),u=d(i.x,r.x,o.x,a.x),l=c(i.y,r.y,o.y,a.y),h=d(i.y,r.y,o.y,a.y);return new Ei(s,l,u-s,h-l)},B.transformPoint=function(t,e){return new si(B.createSVGPoint(t.x,t.y).matrixTransform(e))},B.transformLine=function(t,e){return new ci(B.transformPoint(t.start,e),B.transformPoint(t.end,e))},B.transformPolyline=function(t,e){var n=t instanceof Ci?t.points:t;B.isArray(n)||(n=[]);for(var i=[],r=0,o=n.length;r<o;r++)i[r]=B.transformPoint(n[r],e);return new Ci(i)},B.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},B.createSlicePathData=function(t,e,n,i){var r=2*g-1e-6,o=t,a=e,s=n,u=i,l=(u<s&&(l=s,s=u,u=l),u-s),h=l<g?"0":"1",c=v(s),d=m(s),f=v(u),p=m(u);return r<=l?o?"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"M0,"+o+"A"+o+","+o+" 0 1,0 0,"+-o+"A"+o+","+o+" 0 1,0 0,"+o+"Z":"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z":o?"M"+a*c+","+a*d+"A"+a+","+a+" 0 "+h+",1 "+a*f+","+a*p+"L"+o*f+","+o*p+"A"+o+","+o+" 0 "+h+",0 "+o*c+","+o*d+"Z":"M"+a*c+","+a*d+"A"+a+","+a+" 0 "+h+",1 "+a*f+","+a*p+"L0,0Z"},B.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?B.isObject(t[n])&&B.isObject(e[n])?t[n]=B.mergeAttrs(t[n],e[n]):B.isObject(t[n])?t[n]=B.mergeAttrs(t[n],B.styleToObject(e[n])):B.isObject(e[n])?t[n]=B.mergeAttrs(B.styleToObject(t[n]),e[n]):t[n]=B.mergeAttrs(B.styleToObject(t[n]),B.styleToObject(e[n])):t[n]=e[n];return t},B.annotateString=function(t,e,n){e=e||[];for(var i,r,o,a=(n=n||{}).offset||0,s=[],u=[],l=0;l<t.length;l++){r=u[l]=t[l];for(var h=0;h<e.length;h++){var c=e[h],d=c.start+a,f=c.end+a;d<=l&&l<f&&(B.isObject(r)?r.attrs=B.mergeAttrs(B.mergeAttrs({},r.attrs),c.attrs):r=u[l]={t:t[l],attrs:c.attrs},n.includeAnnotationIndices&&(r.annotations||(r.annotations=[])).push(h))}(o=u[l-1])?B.isObject(r)&&B.isObject(o)?JSON.stringify(r.attrs)===JSON.stringify(o.attrs)?i.t+=r.t:(s.push(i),i=r):i=B.isObject(r)?(s.push(i),r):B.isObject(o)?(s.push(i),r):(i||"")+r:i=r}return i&&s.push(i),s},B.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&n.push(t)}),n},B.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},B.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},B.convertLineToPathData=function(t){return["M",(t=B(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},B.convertPolygonToPathData=function(t){var e=B.getPointsFromSvgNode(t);return 0===e.length?null:B.svgPointsToPath(e)+" Z"},B.convertPolylineToPathData=function(t){var e=B.getPointsFromSvgNode(t);return 0===e.length?null:B.svgPointsToPath(e)},B.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")},B.getPointsFromSvgNode=function(t){var e=[],n=(t=B.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},B.KAPPA=.551784,B.convertCircleToPathData=function(t){t=B(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("r")),r=i*B.KAPPA;return["M",e,n-i,"C",e+r,n-i,e+i,n-r,e+i,n,"C",e+i,n+r,e+r,n+i,e,n+i,"C",e-r,n+i,e-i,n+r,e-i,n,"C",e-i,n-r,e-r,n-i,e,n-i,"Z"].join(" ")},B.convertEllipseToPathData=function(t){t=B(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),r=parseFloat(t.attr("ry"))||i,o=i*B.KAPPA,a=r*B.KAPPA;return["M",e,n-r,"C",e+o,n-r,e+i,n-a,e+i,n,"C",e+i,n+a,e+o,n+r,e,n+r,"C",e-o,n+r,e-i,n+a,e-i,n,"C",e-i,n-a,e-o,n-r,e,n-r,"Z"].join(" ")},B.convertRectToPathData=function(t){return t=B(t),B.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})},B.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=c(t.rx||t["top-rx"]||0,i/2),a=c(t.rx||t["bottom-rx"]||0,i/2),s=c(t.ry||t["top-ry"]||0,r/2),u=c(t.ry||t["bottom-ry"]||0,r/2);return(o||a||s||u?["M",e,n+s,"v",r-s-u,"a",a,u,0,0,0,a,u,"h",i-2*a,"a",a,u,0,0,0,a,-u,"v",-(r-u-s),"a",o,s,0,0,0,-o,-s,"h",-(i-2*o),"a",o,s,0,0,0,-o,s,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"]).join(" ")},B.normalizePathData=function(){var 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",g=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),v=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),e=Math,U=e.PI,H=e.sin,q=e.cos,W=e.tan,Y=e.asin,X=e.sqrt,$=e.abs;function d(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 Z(t,e,n){return{x:t*q(n)-e*H(n),y:t*H(n)+e*q(n)}}function f(t){if(Array.isArray(t)&&Array.isArray(t&&t[0])||(t=function(t){if(!t)return null;var o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},a=[];return String(t).replace(g,function(t,e,n){var i=[],r=e.toLowerCase();for(n.replace(v,function(t,e){e&&i.push(+e)}),"m"===r&&2<i.length&&(a.push([e].concat(i.splice(0,2))),r="l",e="m"===e?"l":"L");i.length>=o[r]&&(a.push([e].concat(i.splice(0,o[r]))),o[r]););}),a}(t)),!t||!t.length)return[["M",0,0]];for(var e,n=[],i=0,r=0,o=0,a=0,s=t.length,u=0;u<s;u++){var l=[];n.push(l);var h,c,d=t[u];if((e=d[0])!=e.toUpperCase())switch(l[0]=e.toUpperCase(),l[0]){case"A":l[1]=d[1],l[2]=d[2],l[3]=d[3],l[4]=d[4],l[5]=d[5],l[6]=+d[6]+i,l[7]=+d[7]+r;break;case"V":l[1]=+d[1]+r;break;case"H":l[1]=+d[1]+i;break;case"M":for(o=+d[1]+i,a=+d[2]+r,h=d.length,c=1;c<h;c++)l[c]=+d[c]+(c%2?i:r);break;default:for(h=d.length,c=1;c<h;c++)l[c]=+d[c]+(c%2?i:r)}else for(var f=d.length,p=0;p<f;p++)l[p]=d[p];switch(l[0]){case"Z":i=+o,r=+a;break;case"H":i=l[1];break;case"V":r=l[1];break;case"M":o=l[l.length-2],a=l[l.length-1],i=l[l.length-2],r=l[l.length-1];break;default:i=l[l.length-2],r=l[l.length-1]}}return n}function n(t){var i=f(t),e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function n(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(function t(e,n,i,r,o,a,s,u,l,h){var c,d=120*U/180,f=U/180*(+o||0),p=[];if(h)P=h[0],T=h[1],x=h[2],A=h[3];else{e=(c=Z(e,n,-f)).x,n=c.y;var g=(e-(u=(c=Z(u,l,-f)).x))/2,v=(n-(l=c.y))/2,m=g*g/(i*i)+v*v/(r*r);1<m&&(i*=m=X(m),r*=m);var y=i*i,b=r*r,w=(a==s?-1:1)*X($((y*b-y*v*v-b*g*g)/(y*v*v+b*g*g)));if(!Number.isFinite(w))return[e,n,u,l,u,l];var x=w*i*v/r+(e+u)/2,A=w*-r*g/i+(n+l)/2,P=Y(((n-A)/r).toFixed(9)),T=Y(((l-A)/r).toFixed(9));(P=e<x?U-P:P)<0&&(P=2*U+P),(T=u<x?U-T:T)<0&&(T=2*U+T),s&&T<P&&(P-=2*U),!s&&P<T&&(T-=2*U)}var E=T-P;if($(E)>d){var S=T,k=u,M=l;p=t(u=x+i*q(T=P+d*(s&&P<T?1:-1)),l=A+r*H(T),i,r,o,0,s,k,M,[T,S,x,A])}E=T-P;var L=q(P),C=H(P),_=q(T),N=H(T),O=W(E/4),R=4/3*(i*O),F=4/3*(r*O),B=[e,n],V=[e+R*C,n-F*L],I=[u+R*N,l-F*_],D=[u,l];if(V[0]=2*B[0]-V[0],V[1]=2*B[1]-V[1],h)return[V,I,D].concat(p);for(var j=[],z=(p=[V,I,D].concat(p).join().split(",")).length,G=0;G<z;G++)j[G]=G%2?Z(p[G-1],p[G],f).y:Z(p[G],p[G+1],f).x;return j}.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(d(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(d(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}function r(t,e){if(7<t[e].length){t[e].shift();for(var n=t[e];n.length;)o[e]="A",t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),u=i.length}}for(var o=[],a="",s="",u=i.length,l=0;l<u;l++){i[l]&&(a=i[l][0]),"C"!==a&&(o[l]=a,0<l&&(s=o[l-1])),i[l]=n(i[l],e,s),"A"!==o[l]&&"C"===a&&(o[l]="C"),r(i,l);var h=i[l],c=h.length;e.x=h[c-2],e.y=h[c-1],e.bx=parseFloat(h[c-4])||e.x,e.by=parseFloat(h[c-3])||e.y}return i[0][0]&&"M"===i[0][0]||i.unshift(["M",0,0]),i}return function(t){return n(t).join(",").split(",").join(" ")}}(),B.namespace=F,B.g=Mr,B}();function uu(t){for(var e=t.length;e--;)lu(t[e])}function lu(t){iu.event.remove(t),Xs.remove(t),$s.remove(t)}function hu(t){for(var e=0;e<t.length;e++){var n=t[e];n.parentNode&&n.parentNode.removeChild(n)}}var cu={};function du(t,e,n){for(var i=0;i<e.length;i++){var r=e[i];su.prototype[t].apply({node:r},n)}}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach(function(t){cu[t]=!0});var fu={remove:function(){for(var t=0;t<this.length;t++){var e=this[t];lu(e),uu(e.getElementsByTagName("*"))}return hu(this),this},detach:function(){return hu(this),this},empty:function(){for(var t=0;t<this.length;t++){var e=this[t];1===e.nodeType&&(uu(e.getElementsByTagName("*")),e.textContent="")}return this},clone:function(){for(var t=[],e=0;e<this.length;e++)t.push(this[e].cloneNode(!0));return this.pushStack(t)},html:function(t){var e=this[0];return e?0===arguments.length?e.innerHTML:void 0===t?this:(uu(Xs,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t?(e.innerHTML="",this.append(t)):(e.innerHTML=t,this)):null},append:function(){for(var i=this,t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this[0];return r&&t.forEach(function(t){var e,n;t&&("string"==typeof t?r.append.apply(r,iu.parseHTML(t)):"[object Object]"===t.toString()?(e=i).append.apply(e,Array.from(t)):Array.isArray(t)?(n=i).append.apply(n,t):r.appendChild(t))}),this},prepend:function(){for(var i=this,t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this[0];return r&&t.forEach(function(t){var e,n;t&&("string"==typeof t?r.prepend.apply(r,iu.parseHTML(t)):"[object Object]"===t.toString()?(e=i).prepend.apply(e,Array.from(t)):Array.isArray(t)?(n=i).prepend.apply(n,t):r.insertBefore(t,r.firstChild))}),this},appendTo:function(t){return iu(t).append(this),this},prependTo:function(t){return iu(t).prepend(this),this},css:function(t,e){var n,i,r,o;if("string"==typeof t){if(void 0===e){var a=this[0];return a?a.style[t]:null}(n={})[t]=e}else{if(!t)throw new Error("no styles provided");n=t}for(var s in n)if(n.hasOwnProperty(s))for(var u=0;u<this.length;u++)i=this[u],"number"==typeof(o=n[r=s])&&cu[Us(r)]&&(o+="px"),i.style[r]=o;return this},data:function(t,e){if(arguments.length<2){var n=this[0];return n?void 0===t?n.dataset:n.dataset[t]:null}for(var i=0;i<this.length;i++)this[i].dataset[t]=e;return this},removeClass:function(){return du("removeClass",this,arguments),this},addClass:function(){return du("addClass",this,arguments),this},toggleClass:function(){return du("toggleClass",this,arguments),this},hasClass:function(){var t=this[0];return!!t&&su.prototype.hasClass.apply({node:t},arguments)},children:function(e){for(var t=[],n=0;n<this.length;n++){var i=this[n],r=Array.from(i.children);"string"==typeof e&&(r=r.filter(function(t){return t.matches(e)})),t.push.apply(t,r)}return this.pushStack(t)},closest:function(t){for(var e=[],n=0;n<this.length;n++){var i=this[n];if("string"==typeof t){var r=i.closest(t);r&&e.push(r)}else{var o=iu(t)[0];o&&o.contains(i)&&e.push(o)}}return this.pushStack(e)},on:function(t,e,n,i){return iu.event.on(this,t,e,n,i),this},one:function(t,e,n,i){return iu.event.on(this,t,e,n,i,1),this},off:function(t,e,n){if(t&&t.preventDefault&&t.handleObj){var i=t.handleObj;return iu(t.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this}if("object"==typeof t){for(var r in t)this.off(r,e,t[r]);return this}!1!==e&&"function"!=typeof e||(n=e,e=void 0);for(var o=0;o<this.length;o++)iu.event.remove(this[o],t,n,e);return this},width:function(){var t=this[0];if(t===window)return t.document.documentElement.clientWidth;if(t){var e=window.getComputedStyle(t),n=t.offsetWidth,i=parseFloat(e.borderTopWidth);return n-parseFloat(e.borderBottomWidth)-i-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)}},height:function(){var t=this[0];if(t===window)return t.document.documentElement.clientHeight;if(t){var e=window.getComputedStyle(t);return t.offsetHeight-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}},position:function(){var t=this[0];if(t){var e,n,i,r=iu(t),o={top:0,left:0};if("fixed"===r.css("position"))n=t.getBoundingClientRect();else{n=r.offset(),i=t.ownerDocument,e=t.offsetParent||i.documentElement;for(var a=iu(e),s=a.css("position")||"static";e&&(e===i.body||e===i.documentElement)&&"static"===s;)e=e.parentNode;if(e&&e!==t&&1===e.nodeType){var u=window.getComputedStyle(e),l=parseFloat(u.borderTopWidth)||0,h=parseFloat(u.borderLeftWidth)||0;(o=a.offset()).top+=l,o.left+=h}}var c=parseFloat(window.getComputedStyle(t).marginTop)||0,d=parseFloat(window.getComputedStyle(t).marginLeft)||0;return{top:n.top-o.top-c,left:n.left-o.left-d}}},offset:function(t){var e=this[0];if(void 0===t){if(!e)return null;if(!e.getClientRects().length)return{top:0,left:0};var n=e.getBoundingClientRect();return{top:n.top+window.scrollY,left:n.left+window.scrollX}}if(!e)return this;var i=window.getComputedStyle(e);"static"===i.position&&this.css("position","relative");var r=this.offset(),o=t.top-r.top,a=t.left-r.left;return this.css({top:(parseFloat(i.top)||0)+o+"px",left:(parseFloat(i.left)||0)+a+"px"}),this}},pu="animationFrameId",gu={};function vu(u,l,t){void 0===t&&(t={});var h=t.duration;void 0===h&&(h=400);var c=t.easing;void 0===c&&(c="ease-in-out");var d=t.delay;void 0===d&&(d=0);var f=t.complete,e=setTimeout(function(){var e=iu(u),n=!1,i="transitionend";h/=1e3,d/=1e3;var t={};if("string"==typeof l)t["animation-name"]=l,t["animation-duration"]=h+"s",t["animation-delay"]=d+"s",t["animation-timing-function"]=c,i="animationend";else{var r=[];for(var o in l)l.hasOwnProperty(o)&&(t[o]=l[o],r.push(o));0<h&&(t["transition-property"]=r.join(", "),t["transition-duration"]=h+"s",t["transition-delay"]=d+"s",t["transition-timing-function"]=c)}var a=function(t){if(t){if(t.target!==t.currentTarget)return;t.target.removeEventListener(i,a)}else u.removeEventListener(i,a);n=!0,e.css(gu),f&&f.call(u)};if(0<h){u.addEventListener(i,a);var s=setTimeout(function(){n||a(null)},1e3*(h+d)+25);Xs.set(u,pu,{id:s,stop:function(){clearTimeout(s),u.removeEventListener(i,a)}})}e.css(t),h<=0&&a(null)});Xs.set(u,pu,{stop:function(){return clearTimeout(e)}})}gu["transition-property"]=gu["transition-duration"]=gu["transition-delay"]=gu["transition-timing-function"]=gu["animation-name"]=gu["animation-duration"]=gu["animation-delay"]=gu["animation-timing-function"]="";var mu={animate:function(t,e){void 0===e&&(e={}),this.stop();for(var n=0;n<this.length;n++)vu(this[n],t,e);return this},stop:function(){for(var t=0;t<this.length;t++){var e=this[t],n=Xs.get(e,pu);n&&(n.stop(),Xs.remove(e,pu))}return this.css(gu),this}},yu={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},bu={disabled:"disabled",value:"value",text:"textContent"};var wu={prop:function(t,e){if(!t)throw new Error("no property provided");if(1===arguments.length){var n=this[0];return n?n[t]:null}if(void 0===e)return this;for(var i=0;i<this.length;i++)this[i][t]=e;return this},attr:function(t,e){var n;if("string"==typeof t){if(void 0===e){var i=this[0];return 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)){var o=n[r];if(bu[r]){this.prop(bu[r],o);continue}for(var a=0;a<this.length;a++)null===o?this[a].removeAttribute(r):this[a].setAttribute(r,o)}return this}};Object.keys(yu).forEach(function(i){wu[i]=function(){for(var t,e=[],n=arguments.length;n--;)e[n]=arguments[n];return(t=this).prop.apply(t,[yu[i]].concat(e))}});var xu={useCSSSelectors:!1,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300},Au=Object.create(null);Au.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach(function(t){var e=t[0],r=t[1];Au[e]={delegateType:r,bindType:r,handle:function(t){var e,n=t.relatedTarget,i=t.handleObj;return n&&this.contains(n)||(t.type=i.origType,e=i.handler.apply(this,arguments),t.type=r),e}}});var Pu=xu.doubleTapInterval;Au.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t){for(var e,n=[],i=arguments.length-1;0<i--;)n[i]=arguments[i+1];var r=t.handleObj,o=t.target,a=iu.data.create(o),s=(new Date).getTime(),u="lastTouch"in a?s-a.lastTouch:0;u<Pu&&30<u?(a.lastTouch=null,t.type=r.origType,(e=r.handler).call.apply(e,[this,t].concat(n))):a.lastTouch=s}},Object.assign(iu.fn,fu),Object.assign(iu.fn,mu),Object.assign(iu.fn,wu),Object.assign(iu.event.special,Au);var Tu,Eu,Su=function(t){return t?t.toString().split(" ").map(function(t){return t.substr(0,xu.classNamePrefix.length)!==xu.classNamePrefix&&(t=xu.classNamePrefix+t),t}).join(" "):t},ku=function(t,e){var b={},w={},x=su.namespace.svg,n=e||x,i=document.createDocumentFragment(),A=function(t,e,n){for(var i=0;i<t.length;i++){var r=t[i];if("string"!=typeof r){if(!r.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var o=r.tagName,a=void 0;r.hasOwnProperty("namespaceURI")&&(n=r.namespaceURI),a=document.createElementNS(n,o);var s=n===x,u=s?su(a):iu(a),l=r.attributes;l&&u.attr(l);var h=r.style;if(h&&iu(a).css(h),r.hasOwnProperty("className")){var c=r.className;s?a.className.baseVal=c:a.className=c}if(r.hasOwnProperty("textContent")&&(a.textContent=r.textContent),r.hasOwnProperty("selector")){var d=r.selector;if(b[d])throw new Error("json-dom-parser: selector must be unique");b[d]=a,u.attr("joint-selector",d)}if(r.hasOwnProperty("groupSelector")){var f=r.groupSelector;Array.isArray(f)||(f=[f]);for(var p=0;p<f.length;p++){var g=f[p],v=w[g];v||(v=w[g]=[]),v.push(a)}}e.appendChild(a);var m=r.children;Array.isArray(m)&&A(m,a,n)}else{var y=document.createTextNode(r);e.appendChild(y)}}};return A(t,i,n),{fragment:i,selectors:b,groupSelectors:w}},Mu=function(t){var e=0;if(0===t.length)return e;for(var n=0;n<t.length;n++){e=(e<<5)-e+t.charCodeAt(n),e&=e}return e},Lu=function(t,e,n){for(var i,r=Array.isArray(e)?e:e.split(n||"/"),o=0,a=r.length;o<a;){if(i=r[o++],!(Object(t)===t&&i in t))return;t=t[i]}return t},Cu=function(t,e){return"string"!=typeof e&&"number"!=typeof e&&(e=String(e)),("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!==e},_u=function(t,e,n,i){for(var r=Array.isArray(e)?e:e.split(i||"/"),o=r.length-1,a=t,s=0;s<o;s++){var u=r[s];if(!Cu(a,u))return t;a=a[u]||(a[u]={})}return a[r[o]]=n,t},Nu=function(t,e,n){for(var i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1,o=t,a=0;a<r;a++){var s=i[a];if(!Cu(o,s))return t;var u=o[s];if(!u)return t;o=u}return delete o[i[r]],t},Ou=function(t,e,n){e=e||"/";var i={};for(var r in t)if(t.hasOwnProperty(r)){var o="object"==typeof t[r];if(o&&n&&n(t[r])&&(o=!1),o){var a=Ou(t[r],e,n);for(var s in a)a.hasOwnProperty(s)&&(i[r+e+s]=a[s])}else i[r]=t[r]}return i},Ru=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})},Fu=function(t){return Fu.id=Fu.id||1,void 0===t?"j_"+Fu.id++:(t.id=void 0===t.id?"j_"+Fu.id++:t.id,t.id)},Bu=function(t){if(t.normalized)return t;var e=t.originalEvent,n=t.target,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(var r in i)void 0===t[r]&&(t[r]=i[r]);if(n){var o=n.correspondingUseElement;o&&(t.target=o)}return t.normalized=!0,t},Vu=function(t){var 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,e=n,n=r=0),i&&!e&&(e=i<1?-1:1),r&&!n&&(n=r<1?-1:1),{spinX:e,spinY:n,deltaX:i,deltaY:r}},Iu=function(t,e){return e<t?e:t<-e?-e:t},Du=function(){var r;if("undefined"!=typeof window&&(r=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!r){var o=0;r=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-o)),i=setTimeout(function(){t(e+n)},n);return o=e+n,i}}return function(t,e){for(var n=[],i=arguments.length-2;0<i--;)n[i]=arguments[i+2];return r(void 0!==e?t.bind.apply(t,[e].concat(n)):t)}}(),ju=((Eu="undefined"!=typeof window)&&(Tu=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),Tu=Tu||clearTimeout,Eu?Tu.bind(window):Tu),zu=function(t){return ds(t)&&"%"===t.slice(-1)},Gu=function(t,e){var n=parseFloat(t);if(Number.isNaN(n))return null;var i,r={};if(r.value=n,null==e)i="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;i=e.join("|")}else ds(e)&&(i=e);var o,a=(o=new RegExp("(?:\\d+(?:\\.\\d+)*)("+i+")$").exec(t))?o[1]:null;return null===a?null:(r.unit=a,r)},Uu=0;function Hu(t,e){for(var n=t.split(e),i=1,r=0,o=n.length-1;r<o;r++){var a=[];(0<r||""!==n[0])&&a.push(Uu),a.push(e),(r<o-1||""!==n[o])&&a.push(Uu),n.splice.apply(n,[i,0].concat(a)),i+=a.length+1}return n.filter(function(t){return""!==t})}function qu(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}}var Wu,Yu=function(t,e,n,i){void 0===n&&(n={}),void 0===i&&(i={});var r=e.width,o=e.height,a=i.svgDocument||su("svg").node,s=su("tspan").node,u=su("text").attr(n).append(s).node,l=document.createTextNode("");u.style.opacity=0,u.style.display="block",s.style.display="block",s.appendChild(l),a.appendChild(u),i.svgDocument||document.body.appendChild(a);var h=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;cs(g)||(g=1/0);var v,m,y,b=t.split(c),w=[],x=[];h&&su(s).attr("xml:space","preserve");for(var A=0,P=0,T=b.length;A<T;A++){var E=b[A];if((E||h)&&"string"==typeof E){var S=!1;if(f&&0<=E.indexOf(f)){if(1<E.length){var k=Hu(b[A],f);b.splice.apply(b,[A,1].concat(k)),A--,T=b.length;continue}if(h&&"string"==typeof b[A-1]){b.splice(A,Uu,"",Uu),T+=2,A--;continue}x[++P]=h&&"string"!=typeof b[A+1]?void 0:"",S=!0}if(!S){var M=void 0;if(M=h?void 0!==x[P]?x[P]+d+E:E:x[P]?x[P]+d+E:E,l.data=M,s.getComputedTextLength()<=r)x[P]=M,(v||m)&&(w[P++]=!0,m=v=0);else{if(!x[P]||v){var L=!!v;if(v=E.length-1,L||!v){if(!v){if(!x[P]){x=[];break}b.splice(A,2,E+b[A+1]),T--,w[P++]=!0,A--;continue}b[A]=E.substring(0,v);var C=b[A+1];b[A+1]=E.substring(v)+(void 0===C||C===Uu?"":C)}else{if(m)b.splice(A,2,b[A]+b[A+1]),m=0;else{var _=E.search(p);-1<_&&_!==E.length-1&&0!==_&&(m=_+1,v=0),b.splice(A,1,E.substring(0,m||v),E.substring(m||v)),T++}P&&!w[P-1]&&P--}h&&""===x[P]||A--;continue}P++,A--}}var N=null;if(x.length>g)N=g-1;else if(void 0!==o){if(void 0===y&&""!==l.data)if("auto"===n.lineHeight)y=qu({value:1.5,unit:"em"},u);else y=qu(Gu(n.lineHeight,["em","px",""]),u);y*x.length>o&&(N=Math.floor(o/y)-1)}if(null!==N){x.splice(N+1);var O=i.ellipsis;if(!O||N<0)break;"string"!=typeof O&&(O="\u2026");var R=x[N];if(!R&&!S)break;var F,B,V=R.length;do{if(B=R[V],F=R.substring(0,V),B?B.match(c)&&(F+=B):F+=d,F+=O,l.data=F,s.getComputedTextLength()<=r){x[N]=F;break}V--}while(0<=V);break}}}return i.svgDocument?a.removeChild(u):document.body.removeChild(a),x.join(f)},Xu=function(t,e){if(window.navigator.msSaveBlob)window.navigator.msSaveBlob(t,e);else{var n=window.URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n)}},$u=function(t){t=t.replace(/\s/g,"");var e,n=(t=decodeURIComponent(t)).indexOf(","),i=t.slice(0,n),r=i.split(":")[1].split(";")[0],o=t.slice(n+1);e=0<=i.indexOf("base64")?atob(o):unescape(encodeURIComponent(o));for(var a=new Uint8Array(e.length),s=0;s<e.length;s++)a[s]=e.charCodeAt(s);return new Blob([a],{type:r})},Zu=function(t,e){var n=(t=iu(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},Ju=function(t){if(Object(t)===t)return e=n=i=r=0,isFinite(t.vertical)&&(e=i=+t.vertical),isFinite(t.horizontal)&&(n=r=+t.horizontal),isFinite(t.top)&&(e=+t.top),isFinite(t.right)&&(n=+t.right),isFinite(t.bottom)&&(i=+t.bottom),isFinite(t.left)&&(r=+t.left),{top:e,right:n,bottom:i,left:r};var e,n,i,r,o=0;return isFinite(t)&&(o=+t),{top:o,right:o,bottom:o,left:o}},Ku={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(1<=t)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e=0,n=1;;e+=n,n/=2)if((7-4*e)/11<=t){var i=(11-6*e-11*t)/4;return-i*i+n*n}},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(n,i,r){return i=i||0,r=r||1,function(t){var e=n(t);return e<i?i:r<e?r:e}},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)}}},Qu={number:function(e,t){var n=t-e;return function(t){return e+n*t}},object:function(r,o){var a=Object.keys(r);return function(t){var e,n,i={};for(e=a.length-1;-1!=e;e--)i[n=a[e]]=r[n]+(o[n]-r[n])*t;return i}},hexColor:function(t,e){var n=parseInt(t.slice(1),16),i=parseInt(e.slice(1),16),r=255&n,o=(255&i)-r,a=65280&n,s=(65280&i)-a,u=16711680&n,l=(16711680&i)-u;return function(t){return"#"+(1<<24|r+o*t&255|a+s*t&65280|u+l*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),r=n.exec(t),o=r[1].indexOf("."),a=0<o?r[1].length-o-1:0;e=+i[1];var s=+r[1]-e,u=i[2];return function(t){return(e+s*t).toFixed(a)+u}}},tl={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return nl('<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 nl('<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 nl('<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 nl(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},sepia:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},saturate:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-e})},hueRotate:function(t){return nl('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:1-e})},brightness:function(t){return nl('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return nl('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:.5-e/2})}},el={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var n=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),i=n[1]||" ",r=n[2]||">",a=n[3]||"",s=n[4]||"",u=n[5],l=+n[6],h=n[7],c=n[8],d=n[9],f=1,p="",g="",v=!1;switch(c&&(c=+c.substring(1)),(u||"0"===i&&"="===r)&&(u=i="0",r="=",h&&(l-=Math.floor((l-1)/4))),d){case"n":h=!0,d="g";break;case"%":f=100,g="%",d="f";break;case"p":f=100,g="%",d="r";break;case"b":case"o":case"x":case"X":"#"===s&&(p="0"+d.toLowerCase());break;case"c":case"d":v=!0,c=0;break;case"s":f=-1,d="r"}"$"===s&&(p=o.currency[0],g=o.currency[1]),"r"!=d||c||(d="g"),null!=c&&("g"==d?c=Math.max(1,Math.min(21,c)):"e"!=d&&"f"!=d||(c=Math.max(0,Math.min(20,c))));var m=u&&h;if(v&&e%1)return"";var y=e<0||0===e&&1/e<0?(e=-e,"-"):a,b=g;if(f<0){var w=this.prefix(e,c);e=w.scale(e),b=w.symbol+g}else e*=f;var x=(e=this.convert(d,e,c)).lastIndexOf("."),A=x<0?e:e.substring(0,x),P=x<0?"":o.decimal+e.substring(x+1);function T(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)}!u&&h&&o.grouping&&(A=T(A));var E=p.length+A.length+P.length+(m?0:y.length),S=E<l?new Array(E=l-E+1).join(i):"";return m&&(A=T(S+A)),y+=p,e=A+P,("<"===r?y+e+S:">"===r?S+y+e:"^"===r?S.substring(0,E>>=1)+y+e+S.substring(E):y+(m?e:S+e))+b},string:function(t,e){for(var n,i="{",r=!1,o=[];-1!==(n=t.indexOf(i));){var a,s,u;if(a=t.slice(0,n),r){u=(s=a.split(":")).shift().split("."),a=e;for(var l=0;l<u.length;l++)a=a[u[l]];s.length&&(a=this.number(s,a))}o.push(a),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]}},nl=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:""})}},il=function(){},rl={},ol=/\s+/,al=function(t,e,n,i,r){var o,a=0;if(n&&"object"==typeof n){void 0!==i&&"context"in r&&void 0===r.context&&(r.context=i);for(o=Object.keys(n);a<o.length;a++)e=al(t,e,o[a],n[o[a]],r)}else if(n&&ol.test(n))for(o=n.split(ol);a<o.length;a++)e=t(e,o[a],i,r);else e=t(e,n,i,r);return e};rl.on=function(t,e,n){(this._events=al(sl,this._events||{},t,e,{context:n,ctx:this,listening:Wu}),Wu)&&(((this._listeners||(this._listeners={}))[Wu.id]=Wu).interop=!1);return this},rl.listenTo=function(t,e,n){if(!t)return this;var i=t._listenId||(t._listenId=qs("l")),r=this._listeningTo||(this._listeningTo={}),o=Wu=r[i];o||(this._listenId||(this._listenId=qs("l")),o=Wu=r[i]=new pl(this,t));var a=ul(t,e,n,this);if(Wu=void 0,a)throw a;return o.interop&&o.on(e,n),this};var sl=function(t,e,n,i){if(n){var r=t[e]||(t[e]=[]),o=i.context,a=i.ctx,s=i.listening;s&&s.count++,r.push({callback:n,context:o,ctx:o||a,listening:s})}return t},ul=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}};rl.off=function(t,e,n){return this._events&&(this._events=al(ll,this._events,t,e,{context:n,listeners:this._listeners})),this},rl.stopListening=function(t,e,n){var i=this._listeningTo;if(!i)return this;for(var r=t?[t._listenId]:Object.keys(i),o=0;o<r.length;o++){var a=i[r[o]];if(!a)break;a.obj.off(e,n,this),a.interop&&a.off(e,n)}return Ss(i)&&(this._listeningTo=void 0),this};var ll=function(t,e,n,i){if(t){var r,o=i.context,a=i.listeners,s=0;if(e||o||n){for(r=e?[e]:Object.keys(t);s<r.length;s++){var u=t[e=r[s]];if(!u)break;for(var l=[],h=0;h<u.length;h++){var c=u[h];if(n&&n!==c.callback&&n!==c.callback._callback||o&&o!==c.context)l.push(c);else{var d=c.listening;d&&d.off(e,n)}}l.length?t[e]=l:delete t[e]}return t}if(null!=a)for(r=Object.keys(a);s<r.length;s++)a[r[s]].cleanup()}};rl.once=function(t,e,n){var i=al(hl,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(i,e,n)},rl.listenToOnce=function(t,e,n){var i=al(hl,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,i)};var hl=function(t,e,n,i){if(n){var r=t[e]=cl(function(){i(e,r),n.apply(this,arguments)});r._callback=n}return t},cl=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}};rl.trigger=function(t){var e=arguments;if(!this._events)return this;for(var n=Math.max(0,arguments.length-1),i=Array(n),r=0;r<n;r++)i[r]=e[r+1];return al(dl,this._events,t,void 0,i),this};var dl=function(t,e,n,i){if(t){var r=t[e],o=t.all;r&&o&&(o=o.slice()),r&&fl(r,i),o&&fl(o,[e].concat(i))}return t},fl=function(t,e){var n,i=-1,r=t.length,o=e[0],a=e[1],s=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,a);return;case 3:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,a,s);return;default:for(;++i<r;)(n=t[i]).callback.apply(n.ctx,e);return}},pl=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};pl.prototype.on=rl.on,pl.prototype.off=function(t,e){(this.interop?(this._events=al(ll,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count))&&this.cleanup()},pl.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},rl.bind=rl.on,rl.unbind=rl.off;var gl=function(t,e){var n,i=this;return n=t&&Is(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)},fs(n,i,e),n.prototype=Object.assign(Object.create(i.prototype),t),(n.prototype.constructor=n).__super__=i.prototype,n},vl=function(n,i,t,r){Gs(t,function(t,e){i[e]&&(n.prototype[e]=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],ml(t,this),e)};case 4:return function(t,e,n){return i[r](this[o],ml(t,this),e,n)};default:return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this[o]),i[r].apply(i,t)}}}(i,t,e,r))})},ml=function(e,t){return Ms(e)?e:hs(e)&&!t._isModel(e)?yl(e):ds(e)?function(t){return t.get(e)}:e},yl=function(t){var e=Ha(Pa(t,!0));return function(t){return e(t.attributes)}},bl=function(t,e){var n=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=qs(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection);var i=Ds(this,"defaults");n=ms(fs({},i,n),i),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};function wl(t){t=Ps(t);var a=Cs(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return Cs(t).forEach(function(t){var e=a[t.id];if(e.isLink()){var n=e.source(),i=e.target();n.id&&a[n.id]&&e.prop("source/id",a[n.id].id),i.id&&a[i.id]&&e.prop("target/id",a[i.id].id)}var r=t.get("parent");r&&a[r]&&e.set("parent",a[r].id);var o=Cs(t.get("embeds")).reduce(function(t,e){return a[e]&&t.push(a[e].id),t},[]);Ss(o)||e.set("embeds",o)}),a}fs(bl.prototype,rl,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return Ts(this.attributes)},get:function(t){return this.attributes[t]},has:function(t){return null!=this.get(t)},set:function(t,e,n){if(null==t)return this;var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;var r=n.unset,o=n.silent,a=[],s=this._changing;this._changing=!0,s||(this._previousAttributes=Ts(this.attributes),this.changed={});var u=this.attributes,l=this.changed,h=this._previousAttributes;for(var c in i)e=i[c],ks(u[c],e)||a.push(c),ks(h[c],e)?delete l[c]:l[c]=e,r?delete u[c]:u[c]=e;if(this.idAttribute in i){var d=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,d,n)}if(!o){a.length&&(this._pending=n);for(var f=0;f<a.length;f++)this.trigger("change:"+a[f],this,u[a[f]],n)}if(s)return this;if(!o)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,fs({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,fs({},t,{unset:!0}))},hasChanged:function(t){return null==t?!Ss(this.changed):Is(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&Ts(this.changed);var e,n=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var o=t[r];ks(n[r],o)||(i[r]=o,e=!0)}return!!e&&i},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return Ts(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},fs({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=fs({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return!n||(this.trigger("invalid",this,n,fs(e,{validationError:n})),!1)}}),bl.extend=gl;var xl=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce(function(t,e){return t[e]=!0,t},{}),Al={qualify:function(t){return Ls(t)},set:function(e,t,i){Object.keys(e).forEach(function(t){if(xl[t]&&t in i){var 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}})}};function Pl(a,s,u){return function(t,e){var n,i=zu(t);if(t=parseFloat(t),i&&(t/=100),isFinite(t)){var r=e[u]();n=i||0<t&&t<1?r[a]+e[s]*t:r[a]+t}var o=si();return o[a]=n||0,o}}function Tl(o,a){return function(t,e){var n=zu(t);t=parseFloat(t),n&&(t/=100);var i={};if(isFinite(t)){var r=n||0<=t&&t<=1?t*e[a]:Math.max(t+e[a],0);i[o]=r}return i}}var El,Sl,kl={"ref-x":{position:Pl("x","width","origin")},"ref-y":{position:Pl("y","height","origin")},"ref-dx":{position:Pl("x","width","corner")},"ref-dy":{position:Pl("y","height","corner")},"ref-width":{set:Tl("width","width")},"ref-height":{set:Tl("height","height")},"ref-rx":{set:Tl("rx","width")},"ref-ry":{set:Tl("ry","height")},"ref-cx":{set:Tl("cx","width")},"ref-cy":{set:Tl("cy","height")},"ref-r-inscribed":{set:(El=Tl("r","width"),Sl=Tl("r","height"),function(t,e){return(e.height>e.width?El:Sl)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n=zu(t);t=parseFloat(t),n&&(t/=100);var i,r=Math.sqrt(e.height*e.height+e.width*e.width);return isFinite(t)&&(i=n||0<=t&&t<=1?t*r:Math.max(t+r,0)),{r:i}}}};function Ml(t,e,n){return void 0!==n.text}kl.refX=kl["ref-x"],kl.refY=kl["ref-y"],kl["ref-x2"]=kl["ref-x"],kl["ref-y2"]=kl["ref-y"],kl["ref-width2"]=kl["ref-width"],kl["ref-height2"]=kl["ref-height"],kl["ref-r"]=kl["ref-r-inscribed"];var Ll={"line-height":{qualify:Ml},"text-vertical-anchor":{qualify:Ml},"text-path":{qualify:Ml},annotations:{qualify:Ml},eol:{qualify:Ml},"display-empty":{qualify:Ml},text:{qualify:function(t,e,n){var i=n["text-wrap"];return!i||!Ls(i)},set:function(t,e,n,i){var r="joint-text",o=iu.data.get(n,r),a=i["line-height"],s=i["text-vertical-anchor"],u=i["display-empty"],l=i["font-size"],h=i.annotations,c=i.eol,d=i.x,f=i["text-path"],p=JSON.stringify([t,a,h,s,c,u,f,d,l]);if(void 0===o||o!==p){if(l&&n.setAttribute("font-size",l),hs(f)){var g=f.selector;if("string"==typeof g){var v=this.findNode(g);v instanceof SVGPathElement&&(f=fs({"xlink:href":"#"+v.id},f))}}su(n).text(""+t,{lineHeight:a,annotations:h,textPath:f,x:d,textVerticalAnchor:s,eol:c,displayEmpty:u}),iu.data.set(n,r,p)}}},"text-wrap":{qualify:Ls,set:function(t,e,n,i){var r={},o=t.width||0;zu(o)?r.width=e.width*parseFloat(o)/100:Nn(o)?r.width=Number(Fn(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o;var a,s=t.height||0;zu(s)?r.height=e.height*parseFloat(s)/100:Nn(s)?r.height=Number(Fn(s,e)):null===t.height||(r.height=s<=0?e.height+s:s);var u=t.text;if(void 0===u&&(u=i.text),void 0!==u){var l=t.breakText||Yu,h=getComputedStyle(n);a=l(""+u,r,{"font-weight":h.fontWeight,"font-family":h.fontFamily,"text-transform":h.textTransform,"font-size":h.fontSize,"letter-spacing":h.letterSpacing,lineHeight:i["line-height"]},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces})}else a="";Ll.text.set.call(this,a,e,n,i)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,n){var i="joint-title",r=iu.data.get(n,i);if(void 0===r||r!==t){if(iu.data.set(n,i,t),"title"===n.tagName)return void(n.textContent=t);var o=n.firstElementChild;if(o&&"title"===o.tagName)o.textContent=t;else{var a=document.createElementNS(n.namespaceURI,"title");a.textContent=t,n.insertBefore(a,o)}}}}};function Cl(r,o){var a=new si(1,0);return function(t){var e,n,i=this[r](t);return i?(n=o.rotate?i.vector().vectorAngle(a):0,e=i.start):(e=this.path.start,n=0),0===n?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+n+")"}}}function _l(){return this.model.isLink()}var Nl={connection:{qualify:_l,set:function(t){var e,n=t.stubs;if(void 0===n&&(n=0),isFinite(n)&&0!==n){var i;i=n<0?(this.getConnectionLength()+n)/2:n;var r=this.getConnection(),o=this.getConnectionSubdivisions(),a=r.divideAtLength(i,{segmentSubdivisions:o}),s=r.divideAtLength(-i,{segmentSubdivisions:o});a&&s&&(e=a[0].serialize()+" "+s[1].serialize())}return{d:e||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:_l,set:Cl("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:_l,set:Cl("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:_l,set:Cl("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:_l,set:Cl("getTangentAtRatio",{rotate:!1})}};function Ol(d,t){var f="joint-shape",p=t&&t.resetOffset;return function(t,e,n){var i=iu.data.get(n,f);if(!i||i.value!==t){var r=d(t);i={value:t,shape:r,shapeBBox:r.bbox()},iu.data.set(n,f,i)}var o=i.shape.clone(),a=i.shapeBBox.clone(),s=a.origin(),u=e.origin();a.x=u.x,a.y=u.y;var l=e.maxRectScaleToFit(a,u),h=0===a.width||0===e.width?1:l.sx,c=0===a.height||0===e.height?1:l.sy;return o.scale(h,c,s),p&&o.translate(-s.x,-s.y),o}}function Rl(t){var i=Ol(function(t){return new Ii(su.normalizePathData(t))},t);return function(t,e,n){return{d:i(t,e,n).serialize()}}}function Fl(t){var i=Ol(Ci,t);return function(t,e,n){return{points:i(t,e,n).serialize()}}}Nl["at-connection-length"]=Nl["at-connection-length-keep-gradient"],Nl["at-connection-ratio"]=Nl["at-connection-ratio-keep-gradient"];var Bl={"ref-d-reset-offset":{set:Rl({resetOffset:!0})},"ref-d-keep-offset":{set:Rl({resetOffset:!1})},"ref-points-reset-offset":{set:Fl({resetOffset:!0})},"ref-points-keep-offset":{set:Fl({resetOffset:!1})}};function Vl(t){var e={},n=t.stroke;"string"==typeof n&&(e.stroke=n,e.fill=n);var i=t["stroke-opacity"];return void 0===i&&(i=t.opacity),void 0!==i&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Il(t){var e=this.paper;return"url(#"+("pattern"===t.type?e.definePattern(t):e.defineGradient(t))+")"}Bl["ref-d"]=Bl["ref-d-reset-offset"],Bl["ref-points"]=Bl["ref-points-reset-offset"];var Dl={"source-marker":{qualify:Ls,set:function(t,e,n,i){return t=fs(Vl(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:Ls,set:function(t,e,n,i){return t=fs(Vl(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:Ls,set:function(t,e,n,i){return t=fs(Vl(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:Ls,set:Il},stroke:{qualify:Ls,set:Il},filter:{qualify:Ls,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function jl(r,o,a){return function(t,e){var n;n="middle"===t?e[o]/2:t===a?e[o]:isFinite(t)?-1<t&&t<1?-e[o]*t:-t:zu(t)?e[o]*parseFloat(t)/100:0;var i=new si;return i[r]=-(e[r]+n),i}}var zl={"x-alignment":{offset:jl("x","width","right")},"y-alignment":{offset:jl("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function Gl(r){return function(t,e,n){var i=su(n);i.attr(r)!==t&&i.attr(r,t)}}var Ul={ref:{},href:{set:Gl("href")},"xlink:href":{set:Gl("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:Ls,set:function(t,e,n){iu(n).css(t)}},html:{set:function(t,e,n){iu(n).html(t+"")}},props:Al};fs(Ul,kl),fs(Ul,Ll),fs(Ul,Nl),fs(Ul,Bl),fs(Ul,Dl),fs(Ul,zl);var Hl=Ul,ql=function(t,e){if(Array.isArray(t))return e},Wl=bl.extend({constructor:function(t,e){var n,i=t||{};if("function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=qs("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(i=this.parse(i,e)||{}),n=Ds(this,"defaults")){var r=(!e||!0!==e.mergeArrays)&&ql;i=Ws({},n,i,r)}this.set(i,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(){var e=Ds(this.constructor.prototype,"defaults").attrs||{},t=this.attributes.attrs,o={};Gs(t,function(t,i){var r=e[i];Gs(t,function(t,n){hs(t)&&!Array.isArray(t)?Gs(t,function(t,e){r&&r[n]&&ks(r[n][e],t)||(o[i]=o[i]||{},(o[i][n]||(o[i][n]={}))[e]=t)}):r&&ks(r[n],t)||(o[i]=o[i]||{},o[i][n]=t)})});var n=Es(js(this.attributes,"attrs"));return n.attrs=o,n},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:function(){return Ru()},processPorts:function(){var t=this.ports,n={};Gs(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})});var i={};(Gs(t,function(t,e){n[e]||(i[e]=!0)}),this.graph&&!Ss(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(t){void 0===t&&(t={});var e=this.graph,n=this.collection;if(!e)return n&&n.remove(this,t),this;e.startBatch("remove");var i=this.getParentCell();i&&i.unembed(this,t);for(var r=this.getEmbeddedCells(),o=0,a=r.length;o<a;o++){var s=r[o];s&&s.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(n){var t=this.graph;if(t){var e;(n=ms(n||{},{foregroundEmbeds:!0})).deep?(e=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==n.breadthFirst,sortSiblings:n.foregroundEmbeds})).unshift(this):e=[this];var i=n.foregroundEmbeds?e:Os(e,function(t){return t.z()}),r=t.maxZIndex()-e.length+1,o=t.get("cells"),a=o.toArray().indexOf(i[0])!==o.length-e.length;a||(a=i.some(function(t,e){return t.z()!==r+e})),a&&(this.startBatch("to-front"),r+=e.length,i.forEach(function(t,e){t.set("z",r+e,n)}),this.stopBatch("to-front"))}return this},toBack:function(n){var t=this.graph;if(t){var e;(n=ms(n||{},{foregroundEmbeds:!0})).deep?(e=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==n.breadthFirst,sortSiblings:n.foregroundEmbeds})).unshift(this):e=[this];var i=n.foregroundEmbeds?e:Os(e,function(t){return t.z()}),r=t.minZIndex(),o=0!==t.get("cells").toArray().indexOf(i[0]);o||(o=i.some(function(t,e){return t.z()!==r+e})),o&&(this.startBatch("to-back"),r-=e.length,i.forEach(function(t,e){t.set("z",r+e,n)}),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){var n=this,i=Array.isArray(t)?t:[t];if(!this.canEmbed(i))throw new Error("Recursive embedding not allowed.");if(i.some(function(t){return t.isEmbedded()&&n.id!==t.parent()}))throw new Error("Embedding of already embedded cells is not allowed.");return this._embedCells(i,e),this},unembed:function(t,e){var n=Array.isArray(t)?t:[t];return this._unembedCells(n,e),this},canEmbed:function(t){var e=this;return(Array.isArray(t)?t:[t]).every(function(t){return e!==t&&!e.isEmbeddedIn(t)})},_embedCells:function(t,e){var n=this;this.startBatch("embed");var i=fs([],this.get("embeds"));t.forEach(function(t){i[t.isLink()?"unshift":"push"](t.id),t.parent(n.id,e)}),this.set("embeds",Ps(i),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(function(t){return t.unset("parent",e)}),this.set("embeds",Fs.apply(void 0,[this.get("embeds")].concat(t.map(function(t){return 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)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(t=t||{},!this.graph)return[];if(t.deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);var e=this.get("embeds");if(Ss(e))return[];var n=e.map(this.graph.getCell,this.graph);return t.sortSiblings&&(n=Os(n,function(t){return t.z()})),n},_getEmbeddedCellsBfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.shift();e.push(i);var r=i.getEmbeddedCells({sortSiblings:t});n.push.apply(n,r)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.pop();e.push(i);for(var r=i.getEmbeddedCells({sortSiblings:t}),o=r.length-1;0<=o;--o)n.push(r[o])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=ds(t)?t:t.id,i=this.parent();if(e=fs({deep:!0},e),this.graph&&e.deep){for(;i;){if(i===n)return!0;i=this.graph.getCell(i).parent()}return!1}return i===n},isEmbedded:function(){return!!this.parent()},clone:function(t){if((t=t||{}).deep)return Cs(wl([this].concat(this.getEmbeddedCells({deep:!0}))));var e=bl.prototype.clone.apply(this,arguments);return e.set(this.getIdAttribute(),this.generateId()),e.unset("embeds"),e.unset("parent"),e},prop:function(t,e,n){var i=ds(t);if(i||Array.isArray(t)){if(1<arguments.length){var r,o,a=(o=i?(r=t).split("/"):(r=t.join("/"),t.slice()))[0],s=o.length,u=n||{};u.propertyPath=r,u.propertyValue=e,u.propertyPathArray=o,"rewrite"in u||(u.rewrite=!1);for(var l={},h=l,c=a,d=1;d<s;d++){var f=o[d],p=Number.isFinite(i?Number(f):f);h=h[c]=p?[]:{},c=f}l=_u(l,o,e,"/");var g=Ws({},this.attributes);u.rewrite&&Nu(g,r,"/");var v=Ws(g,l);return this.set(a,v[a],u)}return Lu(this.attributes,t,"/")}var m=e||{};m.propertyPath=null,m.propertyValue=t,m.propertyPathArray=[],"rewrite"in m||(m.rewrite=!1);var y={};for(var b in t){var w=Ws({},{changedValue:this.attributes[b]},{changedValue:t[b]}).changedValue;y[b]=w}return this.set(y,m)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];if("attrs"===i&&(e.dirty=!0),1===n.length)return this.unset(t,e);var r=n.slice(1),o=this.get(i);return null==o?this:(o=Es(o),Nu(o,r,"/"),this.set(i,o,e))},attr:function(t,e,n){var i=Array.from(arguments);return 0===i.length?this.get("attrs"):(Array.isArray(t)?i[0]=["attrs"].concat(t):ds(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(r,e,o,n){var i=this;n=n||"/",o=fs({duration:100,delay:10,timingFunction:Ku.linear,valueFunction:Qu.number},o);var a,s,u=0,l=function(t){var e,n,i;(n=(t-=u=u||t)/o.duration)<1?this._transitionIds[r]=e=Du(l):(n=1,delete this._transitionIds[r]),i=a(o.timingFunction(n)),o.transitionId=e,this.prop(r,i,o),e||this.trigger("transition:end",this,r)}.bind(this),h=this._scheduledTransitionIds;return s=setTimeout(function(t){h[r]&&(h[r]=Fs(h[r],s),0===h[r].length&&delete h[r]),i.stopPendingTransitions(r,n),a=o.valueFunction(Lu(i.attributes,r,n),e),i._transitionIds[r]=Du(t),i.trigger("transition:start",i,r)},o.delay,l),h[r]||(h[r]=[]),h[r].push(s),s},getTransitions:function(){return Vs(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e){void 0===e&&(e="/");var n=this._scheduledTransitionIds;void 0===n&&(n={});var i=Object.keys(n);if(t){var r=t.split(e);i=i.filter(function(t){return ks(r,t.split(e).slice(0,r.length))})}return i.forEach(function(t){n[t].forEach(function(t){return clearTimeout(t)}),delete n[t]}),this},stopPendingTransitions:function(t,e){var n=this;void 0===e&&(e="/");var i=this._transitionIds;void 0===i&&(i={});var r=Object.keys(i);if(t){var o=t.split(e);r=r.filter(function(t){return ks(o,t.split(e).slice(0,o.length))})}r.forEach(function(t){var e=i[t];ju(e),delete i[t],n.trigger("transition:end",n,t)})},stopTransitions:function(t,e){return void 0===e&&(e="/"),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,fs({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,fs({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new si(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new si},getBBox:function(){return new Ei(0,0,0,0)},getPointRotatedAroundCenter:function(t,e,n){var i=new si(e,n);return t&&i.rotate(this.getBBox().center(),t),i},getAbsolutePointFromRelative:function(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute:function(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,n=Hl;return e&&e[t]||n[t]},define:function(t,e,n,i){n=fs({defaults:bs({type:t},e,this.prototype.defaults)},n);var r=this.extend(n,i);return void 0!==joint&&Is(joint,"shapes")&&_u(joint.shapes,t,r,"."),r}}),Yl=function(e,t,n){if(ds(n)){if(!Xl[n])throw new Error('Unknown wrapper: "'+n+'"');n=Xl[n]}if(!Ms(n))throw new Error("Wrapper must be a function.");Cs(t).forEach(function(t){e[t]=n(e[t])})},Xl={cells:function(r){return function(){var t=Array.from(arguments),e=t.length,n=0<e&&t[0]||[],i=1<e&&t[e-1]||{};return Array.isArray(n)||(i instanceof Wl?n=t:n instanceof Wl&&(1<t.length&&t.pop(),n=t)),i instanceof Wl&&(i={}),r.call(this,n,i)}}};var $l={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 Zl(t,e){var n=new Ei(t);switch(e){case void 0:throw new Error("Position required");case $l.LEFT:case"leftMiddle":return n.leftMiddle();case $l.RIGHT:case"rightMiddle":return n.rightMiddle();case $l.TOP:case"topMiddle":return n.topMiddle();case $l.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case $l.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case $l.TOP_RIGHT:case"topRight":return n.topRight();case $l.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case $l.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case $l.CENTER:return n.center();default:throw new Error("Unknown position: "+e)}}var Jl={getRectPoint:Zl,wrapWith:Yl,wrappers:Xl,addClassNamePrefix:Su,removeClassNamePrefix:function(t){return t?t.toString().split(" ").map(function(t){return t.substr(0,xu.classNamePrefix.length)===xu.classNamePrefix&&(t=t.substr(xu.classNamePrefix.length)),t}).join(" "):t},parseDOMJSON:ku,hashCode:Mu,getByPath:Lu,setByPath:_u,unsetByPath:Nu,flattenObject:Ou,uuid:Ru,guid:Fu,toKebabCase:function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},normalizeEvent:Bu,normalizeWheel:Vu,cap:Iu,nextFrame:Du,cancelFrame:ju,isPercentage:zu,parseCssNumeric:Gu,breakText:Yu,sanitizeHTML:function(t){var e=iu.parseHTML("<div>"+t+"</div>")[0];return Array.from(e.getElementsByTagName("*")).forEach(function(n){n.getAttributeNames().forEach(function(t){var e=n.getAttribute(t);(t.startsWith("on")||e.startsWith("javascript:"))&&n.removeAttribute(t)})}),e.innerHTML},downloadBlob:Xu,downloadDataUri:function(t,e){var n=$u(t);Xu(n,e)},dataUriToBlob:$u,imageToDataUri:function(r,t){if(!r||"data:"===r.substr(0,"data:".length))return setTimeout(function(){t(null,r)},0);var e=new XMLHttpRequest;e.open("GET",r,!0),e.addEventListener("error",function(){t(new Error("Failed to load image "+r))}),e.responseType=window.FileReader?"blob":"arraybuffer",e.addEventListener("load",function(){window.FileReader?function(t,n){if(200===t.status){var e=new FileReader;e.onload=function(t){var e=t.target.result;n(null,e)},e.onerror=function(){n(new Error("Failed to load image "+r))},e.readAsDataURL(t.response)}else n(new Error("Failed to load image "+r))}(e,t):function(t,e){if(200===t.status){var n=new Uint8Array(t.response),i=r.split(".").pop()||"png";e(null,"data:image/"+({svg:"svg+xml"}[i]||i)+";base64,"+btoa(function(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("")}(n)))}else e(new Error("Failed to load image "+r))}(e,t)}),e.send()},getElementBBox:function(t){var e=iu(t);if(0===e.length)throw new Error("Element not found");var n=e[0],i=n.ownerDocument,r=n.getBoundingClientRect(),o=0,a=0;if(n.ownerSVGElement){var s=su(n),u=s.getBBox({target:s.svg()});o=r.width-u.width,a=r.height-u.height}return{x:r.left+window.pageXOffset-i.documentElement.offsetLeft+o/2,y:r.top+window.pageYOffset-i.documentElement.offsetTop+a/2,width:r.width-o,height:r.height-a}},sortElements:Zu,setAttributesBySelector:function(t,e){var i=iu(t);Gs(e,function(t,e){var n=i.find(e).addBack().filter(e);Is(t,"class")&&(n.addClass(t.class),t=js(t,"class")),n.attr(t)})},normalizeSides:Ju,timing:Ku,interpolate:Qu,filter:tl,format:el,template:nl,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],o=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[o])return Ms(t[o])?t[o]():t[o]}}t=t||e.body,n(e,"FullscreenElement")||n(e,"FullScreenElement")?n(e,"ExitFullscreen")||n(e,"CancelFullScreen"):n(t,"RequestFullscreen")||n(t,"RequestFullScreen")},isBoolean:ls,isObject:hs,isNumber:cs,isString:ds,mixin:ps,deepMixin:gs,supplement:vs,defaults:ms,deepSupplement:ys,defaultsDeep:bs,assign:fs,invoke:ws,invokeProperty:xs,sortedIndex:As,uniq:Ps,clone:Ts,cloneDeep:Es,isEmpty:Ss,isEqual:ks,isFunction:Ms,isPlainObject:Ls,toArray:Cs,debounce:_s,groupBy:Ns,sortBy:Os,flattenDeep:Rs,without:Fs,difference:Bs,intersection:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=t.map(function(t){return Uo(t)&&Xo(t)?t:[]});return n.length&&n[0]===t[0]?function(t){for(var e,n=function(t,e){return!(null==t||!t.length)&&-1<t.indexOf(e)},i=function(t,e){return t.has(e)},r=t[0].length,o=t.length,a=new Array(o),s=[],u=1/0,l=o;l--;)e=t[l],u=Math.min(e.length,u),a[l]=120<=r&&120<=e.length?new us(l&&e):void 0;e=t[0];var h=-1,c=a[0];t:for(;++h<r&&s.length<u;){var d=e[h],f=d;if(d=0!==d?d:0,!(c?i(c,f):n(s,f))){for(l=o;--l;){var p=a[l];if(!(p?i(p,f):n(t[l],f)))continue t}c&&c.push(f),s.push(d)}}return s}(n):[]},union:Vs,has:Is,result:Ds,omit:js,pick:zs,bindAll:function(e){for(var t=[],n=arguments.length-1;0<n--;)t[n]=arguments[n+1];return t.flat(1).forEach(function(t){t=Aa(t),Wo(e,t,e[t].bind(e))}),e},forIn:Gs,camelCase:Us,uniqueId:qs,merge:Ws,noop:il,cloneCells:wl,svg:function(t){for(var n=[],e=arguments.length-1;0<e--;)n[e]=arguments[e+1];var i=[];return t.forEach(function(t,e){i.push(t),e in n&&i.push(n[e])}),function(t){var e,n,i=new DOMParser,r="<svg>"+t.trim()+"</svg>";if(i.parseFromString(r.replace(/@/g,""),"application/xml").getElementsByTagName("parsererror")[0])throw new Error("Invalid SVG markup");return e=i.parseFromString(r,"text/html").querySelector("svg"),n=[],Array.from(e.children).forEach(function(t){n.push(function n(t){var e={},i=t.tagName,r=t.attributes,o=t.namespaceURI,a=t.style,s=t.childNodes;e.namespaceURI=o,e.tagName=o===su.namespace.xhtml?i.toLowerCase():i;for(var u={},l=a.length;l--;){var h=a[l];u[h]=a.getPropertyValue(h)}e.style=u;var c=r.getNamedItem("@selector");c&&(e.selector=c.value,r.removeNamedItem("@selector"));var d=r.getNamedItem("@group-selector");if(d){var f=d.value.split(",");e.groupSelector=f.map(function(t){return t.trim()}),r.removeNamedItem("@group-selector")}var p=r.getNamedItem("class");p&&(e.className=p.value);var g=[];s.forEach(function(t){switch(t.nodeType){case Node.TEXT_NODE:var e=t.data.replace(/\s\s+/g," ");e.trim()&&g.push(e);break;case Node.ELEMENT_NODE:g.push(n(t))}}),g.length&&(e.children=g);var v={};return Array.from(r).forEach(function(t){var e=t.name,n=t.value;v[e]=n}),0<Object.keys(v).length&&(e.attributes=v),e}(t))}),n}(i.join(""))}};function Kl(t,e,n){var i=t.toJSON();return i.angle=e||0,ms({},n,i)}function Ql(t,e,n,r){return t.map(function(t,e,n){var i=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&i.offset(t.dx||0,t.dy||0),Kl(i.round(),0,eh(r,t))},di(e,n))}function th(t,a,s,u){var l=a.center(),h=a.width/a.height,c=a.topMiddle(),d=vi.fromRect(a);return t.map(function(t,e,n){var i=s+u(e,n.length),r=c.clone().rotate(l,-i).scale(h,1,l),o=t.compensateRotation?-d.tangentTheta(r):0;return(t.dx||t.dy)&&r.offset(t.dx||0,t.dy||0),t.dr&&r.move(l,t.dr),Kl(r.round(),o,eh(a,t))})}function eh(t,e){var n=e.x,i=e.y,r=e.angle;return zu(n)?n=parseFloat(n)/100*t.width:Nn(n)&&(n=Number(Fn(n,t))),zu(i)?i=parseFloat(i)/100*t.height:Nn(i)&&(i=Number(Fn(i,t))),{x:n,y:i,angle:r}}function nh(t,e){var n=eh(t,e),i=n.x,r=n.y;return new si(i||0,r||0)}var ih={absolute:function(t,n){return t.map(function(t){var e=nh(n,t).round().toJSON();return e.angle=t.angle||0,e})},fn:function(t,e,n){return n.fn(t,e,n)},line:function(t,e,n){return Ql(t,nh(e,n.start||e.origin()),nh(e,n.end||e.corner()),e)},left:function(t,e,n){return Ql(t,e.origin(),e.bottomLeft(),e)},right:function(t,e,n){return Ql(t,e.topRight(),e.corner(),e)},top:function(t,e,n){return Ql(t,e.origin(),e.topRight(),e)},bottom:function(t,e,n){return Ql(t,e.bottomLeft(),e.corner(),e)},ellipseSpread:function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return th(t,e,i,function(t){return t*r})},ellipse:function(t,e,n){var i=n.startAngle||0,r=n.step||20;return th(t,e,i,function(t,e){return(t+.5-e/2)*r})}};function rh(t,e){return bs({},t,e,{x:0,y:0,angle:0,attrs:{}})}function oh(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 ah(t,e,n,i){i=ms({},i,{offset:15});var r,o,a,s,u=e.center().theta(t),l=i.offset,h=0,c=oh(e),d=c[0],f=c[1],p=c[2],g=c[3];u<f||p<u?(a=".3em",r=l,o=0,s="start"):u<d?(r=0,o=-l,a=n?(h=-90,s="start",".3em"):(s="middle","0")):u<g?(a=".3em",r=-l,o=0,s="end"):(r=0,o=l,a=n?(h=90,s="start",".3em"):(s="middle",".6em"));var v=Math.round;return rh(i,{x:v(r),y:v(o),angle:h,attrs:{labelText:{y:a,textAnchor:s}}})}function sh(t,e,n,i){i=ms({},i,{offset:15});var r,o,a,s,u=e.center().theta(t),l=i.offset,h=0,c=oh(e),d=c[0],f=c[1],p=c[2],g=c[3];u<f||p<u?(a=".3em",r=-l,o=0,s="end"):u<d?(r=0,o=l,a=n?(h=90,s="start",".3em"):(s="middle",".6em")):u<g?(a=".3em",r=l,o=0,s="start"):(r=0,o=-l,a=n?(h=-90,s="start",".3em"):(s="middle","0"));var v=Math.round;return rh(i,{x:v(r),y:v(o),angle:h,attrs:{labelText:{y:a,textAnchor:s}}})}function uh(t,e,n){n=ms({},n,{offset:20});var i,r=ui(0,0),o=-t.theta(r),a=o,s=t.clone().move(r,n.offset).difference(t).round(),u=".3em";(o+90)%180==0?(i=e?"end":"middle",e||-270!==o||(u="0em")):-270<o&&o<-90?(i="start",a=o-180):i="end";var l=Math.round;return rh(n,{x:l(s.x),y:l(s.y),angle:e?a:0,attrs:{labelText:{y:u,textAnchor:i}}})}var lh={manual:function(t,e,n){return rh(n)},left:function(t,e,n){return rh(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},right:function(t,e,n){return rh(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},top:function(t,e,n){return rh(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},bottom:function(t,e,n){return rh(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},outsideOriented:function(t,e,n){return ah(t,e,!0,n)},outside:function(t,e,n){return ah(t,e,!1,n)},insideOriented:function(t,e,n){return sh(t,e,!0,n)},inside:function(t,e,n){return sh(t,e,!1,n)},radial:function(t,e,n){return uh(t.difference(e.center()),!1,n)},radialOriented:function(t,e,n){return uh(t.difference(e.center()),!0,n)}},hh=function(t){var e=Es(t)||{};this.ports=[],this.groups={},this.portLayoutNamespace=ih,this.portLabelLayoutNamespace=lh,this._init(e)};hh.prototype={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,r){var e=this.getGroup(t),n=this.getPortsByGroup(t),i=e.position||{},o=i.name,a=this.portLayoutNamespace;a[o]||(o="left");var s=i.args||{},u=n.map(function(t){return t&&t.position&&t.position.args}),l=a[o](u,r,s),h={ports:n,result:[]};return Cs(l).reduce(function(t,e,n){var i=t.ports[n];return t.result.push({portId:i.id,portTransformation:e,labelTransformation:this._getPortLabelLayout(i,si(e),r),portAttrs:i.attrs,portSize:i.size,labelSize:i.label.size}),t}.bind(this),h),h.result},_getPortLabelLayout:function(t,e,n){var i=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return i[r]?i[r](e,n,t.label.position.args):null},_init:function(t){if(hs(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=Cs(t.items),a=0,s=o.length;a<s;a++)this.ports.push(this._evaluatePort(o[a]))},_evaluateGroup:function(t){return Ws(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=fs({},t),n=this.getGroup(t.group);return e.markup=e.markup||n.markup,e.attrs=Ws({},n.attrs,e.attrs),e.position=this._createPositionNode(n,e),e.label=Ws({},n.label,this._getLabel(e)),e.z=this._getZIndex(n,e),e.size=fs({},n.size,e.size),e},_getZIndex:function(t,e){return cs(e.z)?e.z:cs(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return Ws({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={};Ms(t)?(n="fn",i.fn=t):ds(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):hs(t)&&(n=t.name,fs(i,t.args));var r={args:i};return n&&(r.name=n),r},_getLabel:function(t,e){var n=t.label||{},i=n;return i.position=this._getPosition(n.position,e),i}};var ch={_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={};Cs(t.items).forEach(function(t){e[t.id]=!0});var n=this.previous("ports")||{},i={};Cs(n.items).forEach(function(t){e[t.id]||(i[t.id]=!0)});var r=this.graph;r&&!Ss(i)&&(r.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),r.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()}))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&0<t.length},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return Es(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=Cs(this.prop(["ports","items"])).filter(function(t){return t.group===e});return Es(t)},getPort:function(e){return Es(Cs(this.prop("ports/items")).find(function(t){return t.id&&t.id===e}))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,Ei(this.size())).reduce(function(t,e){var n=e.portTransformation;return t[e.portId]={x:n.x,y:n.y,angle:n.angle},t},{})},getPortIndex:function(t){var e=hs(t)?t.id:t;return this._isValidPortId(e)?Cs(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!hs(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=fs([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){var i="number"==typeof t?t:this.getPortIndex(t);if(!hs(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var r=fs([],this.prop("ports/items"));return r.splice(i,0,e),this.prop("ports/items",r,n),this},portProp:function(t,e,n,i){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);var o=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?o[0]=["ports","items",r].concat(e):ds(e)?o[0]=["ports/items/",r,"/",e].join(""):(o=["ports/items/"+r],Ls(e)&&(o.push(e),o.push(n))),this.prop.apply(this,o)},_validatePorts:function(){var t=this.get("ports")||{},e=[],n=Cs((t=t||{}).items);return n.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),Ps(n,"id").length!==n.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!hs(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",fs([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var n=e||{},i=this.getPortIndex(t);if(-1!==i){var r=fs([],this.prop(["ports","items"]));r.splice(i,1),n.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],r,n),this.stopBatch("port-remove")}return this},removePorts:function(t,e){var n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;i=fs([],this.prop(["ports","items"])).filter(function(n){return!t.some(function(t){var e=hs(t)?t.id:t;return n.id===e})})}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 hh(this.get("ports"));var n=this._portSettingsData.getPorts();if(t){var i=n.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),r=t.filter(function(e){if(!n.find(function(t){return t.id===e.id}))return e});0<r.length&&this.trigger("ports:remove",this,r),0<i.length&&this.trigger("ports:add",this,i)}}},dh={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 n=[],i=this._getContainerElement(),t=0,e=i.node.childNodes.length;t<e;t++)n.push(i.node.childNodes[t]);var r=Ns(this.model._portSettingsData.getPorts(),"z");Cs(r.auto).forEach(function(t){var e=this._getPortElement(t);i.append(e),n.push(e)},this);for(var o=Object.keys(r),a=0;a<o.length;a++){var s=o[a];if("auto"!==s){var u=parseInt(s,10);this._appendPorts(r[s],u,n)}}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),r=Cs(t).map(this._getPortElement,this);n[e]||e<0?su(n[Math.max(e,0)]).before(r):i.append(r)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){var n=this._portElementsCache[t];if(!n)return[];if(!e)return[n.portContentElement.node];var i=n.portElement.node,r=n.portSelectors;return this.findBySelector(e,i,r)},findPortNode:function(t,e){var n=this.findPortNodes(t,e)[0];return void 0===n&&(n=null),n},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){ws(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){var e,n,i,r,o=su(this.portContainerMarkup).addClass("joint-port"),a=this._getPortMarkup(t);if(Array.isArray(a)){var s=this.parseDOMJSON(a,o.node),u=s.fragment;e=1<u.childNodes.length?su("g").append(u):su(u.firstChild),r=s.selectors}else e=su(a),Array.isArray(e)&&(e=su("g").append(e));if(!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group}),cs(t.id)&&e.attr("port-id-type","number");var l,h=this._getPortLabelMarkup(t.label);if(Array.isArray(h)){var c=this.parseDOMJSON(h,o.node),d=c.fragment,f=c.selectors,p=d.childNodes.length;0<p&&(i=f,n=1===p?su(d.firstChild):su("g").append(d))}else n=su(h),Array.isArray(n)&&(n=su("g").append(n));if(r&&i){for(var g in i)if(r[g]&&g!==this.selector)throw new Error("ElementView: selectors within port must be unique.");l=fs({},r,i)}else l=r||i||{};var v="labelText";if("portRoot"in l||(l.portRoot=e.node),n){var m=n.node;if("labelRoot"in l||(l.labelRoot=m),!(v in l)){var y="TEXT"===n.tagName()?m:Array.from(m.querySelectorAll("text"));l[v]=y,i||(i={}),i[v]=y}}return o.append(e.addClass("joint-port-body")),n&&o.append(n.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:n,portSelectors:l,portLabelSelectors:i,portContentElement:e,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=Ei(this.model.size()),n=this.model._portSettingsData.getGroupPortsMetrics(t,e),i=0,r=n.length;i<r;i++){var o=n[i],a=o.portId,s=this._portElementsCache[a]||{},u=o.portTransformation,l=o.labelTransformation;l&&s.portLabelElement&&(this.updateDOMSubtreeAttributes(s.portLabelElement.node,l.attrs,{rootBBox:new Ei(o.labelSize),selectors:s.portLabelSelectors}),this.applyPortTransform(s.portLabelElement,l,-u.angle||0)),this.updateDOMSubtreeAttributes(s.portElement.node,o.portAttrs,{rootBBox:new Ei(o.portSize),selectors:s.portSelectors}),this.applyPortTransform(s.portElement,u)}},applyPortTransform:function(t,e,n){var i=su.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},fh=Wl.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),Wl.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){var i,r=cs(e),o=(n=(r?n:t)||{}).parentRelative,a=n.deep,s=n.restrictedArea;if(o){if(!this.graph)throw new Error("Element must be part of a graph.");var u=this.getParentCell();u&&!u.isLink()&&(i=u.get("position"))}if(r){if(i&&(t+=i.x,e+=i.y),a||s){var l=this.get("position"),h=l.x,c=l.y;this.translate(t-h,e-c,n)}else this.set("position",{x:t,y:e},n);return this}var d=si(this.get("position"));return o?d.difference(i):d},translate:function(t,e,n){if(e=e||0,0===(t=t||0)&&0===e)return this;(n=n||{}).translateBy=n.translateBy||this.id;var i=this.get("position")||{x:0,y:0},r=n.restrictedArea;if(r&&n.translateBy===this.id)if("function"==typeof r){var o=r.call(this,i.x+t,i.y+e,n);t=o.x-i.x,e=o.y-i.y}else{var a=this.getBBox({deep:!0}),s=i.x-a.x,u=i.y-a.y,l=Math.max(r.x+s,Math.min(r.x+r.width+s-a.width,i.x+t)),h=Math.max(r.y+u,Math.min(r.y+r.height+u-a.height,i.y+e));t=l-i.x,e=h-i.y}var c={x:i.x+t,y:i.y+e};return n.tx=t,n.ty=e,n.transition?(hs(n.transition)||(n.transition={}),this.transition("position",c,fs({},n.transition,{valueFunction:Qu.object})),ws(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",c,n),ws(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}:(hs(t)&&(n=e,e=cs(t.height)?t.height:i.height,t=cs(t.width)?t.width:i.width),this.resize(t,e,n))},resize:function(t,e,n){if(n=n||{},this.startBatch("resize",n),n.direction){var i=this.get("size");switch(n.direction){case"left":case"right":e=i.height;break;case"top":case"bottom":t=i.width}var r,o=Dn(this.get("angle")||0),a=this.getBBox();if(o){var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction];n.absolute&&(s+=Math.floor((o+45)/90),s%=4);var u=a[["bottomLeft","corner","topRight","origin"][s]](),l=si(u).rotate(a.center(),-o),h=Math.sqrt(t*t+e*e)/2,c=s*Math.PI/2;c+=Math.atan(s%2==0?e/t:t/e),c-=Gn(o);var d=si.fromPolar(h,c,l);r=si(d).offset(t/-2,e/-2)}else switch(r=a.topLeft(),n.direction){case"top":case"top-right":r.offset(0,a.height-e);break;case"left":case"bottom-left":r.offset(a.width-t,0);break;case"top-left":r.offset(a.width-t,a.height-e)}this.set("size",{width:t,height:e},n),this.position(r.x,r.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){var r=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(r.x,r.y,i),this.resize(r.width,r.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t){void 0===t&&(t={});if(!this.graph)throw new Error("Element must be part of a graph.");var e=this.getEmbeddedCells().filter(function(t){return t.isElement()});return 0===e.length||(this.startBatch("fit-embeds",t),t.deep&&ws(e,"fitToChildren",t),this._fitToElements(Object.assign({elements:e},t)),this.stopBatch("fit-embeds")),this},fitParent:function(t){void 0===t&&(t={});if(!this.graph)throw new Error("Element must be part of a graph.");if(t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id))return this;var e=this.getParentCell();if(!e||!e.isElement())return this;var n=e.getEmbeddedCells().filter(function(t){return t.isElement()});return 0===n.length||(this.startBatch("fit-parent",t),e._fitToElements(Object.assign({elements:n},t)),t.deep&&e.fitParent(t),this.stopBatch("fit-parent")),this},_fitToElements:function(t){void 0===t&&(t={});var e=this.graph.getCellsBBox(t.elements);if(e){var n=t.expandOnly,i=t.shrinkOnly;if(!n||!i){var r=e.x,o=e.y,a=e.width,s=e.height,u=Ju(t.padding),l=u.left,h=u.right,c=u.top,d=u.bottom,f=new Ei(r-=l,o-=c,a+=l+h,s+=d+c);if(n)f=this.getBBox().union(f);else if(i){var p=this.getBBox().intersect(f);if(!p)return;f=p}this.set({position:{x:f.x,y:f.y},size:{width:f.width,height:f.height}},t)}}},rotate:function(t,e,n,i){if(n){var r=this.getBBox().center(),o=this.get("size"),a=this.get("position");r.rotate(n,this.get("angle")-t);var s=r.x-o.width/2-a.x,u=r.y-o.height/2-a.y;this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(a.x+s,a.y+u,i),this.rotate(t,e,null,i),this.stopBatch("rotate")}else this.set("angle",e?t:(this.get("angle")+t)%360,i);return this},angle:function(){return Dn(this.get("angle")||0)},getBBox:function(t){void 0===t&&(t={});var e=this.graph,n=this.attributes,i=t.deep,r=t.rotate;if(i&&e){var o=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return o.push(this),e.getCellsBBox(o,t)}var a=n.angle;void 0===a&&(a=0);var s=n.position,u=s.x,l=s.y,h=n.size,c=h.width,d=h.height,f=new Ei(u,l,c,d);return r&&f.rotateAroundCenter(a),f},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),r=t.get(e);if(!r)return i;var o=r.port;if(!o||!this.hasPort(o))return i;var a=this.portProp(o,["group"]),s=this.getPortsPositions(a),u=new si(s[o]).offset(n.origin()),l=this.angle();return l&&u.rotate(i,-l),u}});fs(fh.prototype,ch);var ph=Wl.extend({defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,x:"calc(x)",y:"calc(y)",width:"calc(w)",height:"calc(h)"}},position:{distance:.5}}},defaults:{source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,n){return void 0===t?Ts(this.get("source")):(r=t instanceof Wl?((i=Ts(e)||{}).id=t.id,n):Ls(t)?(i=t,e):((i=Ts(e)||{}).x=t.x,i.y=t.y,n),this.set("source",i,r));var i,r},target:function(t,e,n){return void 0===t?Ts(this.get("target")):(r=t instanceof Wl?((i=Ts(e)||{}).id=t.id,n):Ls(t)?(i=t,e):((i=Ts(e)||{}).x=t.x,i.y=t.y,n),this.set("target",i,r));var i,r},router:function(t,e,n){if(void 0===t){var i=this.get("router");return i?"object"==typeof i?Ts(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},a=r?e:n;return this.set("router",o,a)},connector:function(t,e,n){if(void 0===t){var i=this.get("connector");return i?"object"==typeof i?Ts(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},a=r?e:n;return this.set("connector",o,a)},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){if(!e)throw new Error("dia.Link: no label provided");var i=this.labels(),r=i.length;return(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),i.splice(t,0,e),this.labels(i,n)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var n=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.labels(n,e)},vertex:function(t,e,n){var i=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1)return this.prop(["vertices",t]);var r=this._normalizeVertex(e);return this.prop(["vertices",t],r,n)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var n=[],i=0;i<t.length;i++){var r=t[i],o=this._normalizeVertex(r);n.push(o)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){if(!e)throw new Error("dia.Link: no vertex provided");var i=this.vertices(),r=i.length;(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1);var o=this._normalizeVertex(e);return i.splice(t,0,o),this.vertices(i,n)},removeVertex:function(t,e){var n=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.vertices(n,e)},_normalizeVertex:function(t){return!Ls(t)?{x:t.x,y:t.y}:t},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 si(t).scale(e,n,i).toJSON()},t)},applyToPoints:function(t,e){if(!Ms(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var n={},i=this.attributes,r=i.source,o=i.target;r.id||(n.source=t(r)),o.id||(n.target=t(o));var a=this.vertices();return 0<a.length&&(n.vertices=a.map(t)),this.set(n,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new si(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new si(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint()].concat(this.vertices().map(si),[this.getTargetPoint()]);return new Ci(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e;if(this.graph){var n=this.getSourceElement(),i=this.getTargetElement(),r=this.getParentCell();n&&i&&(e=n===i||n.isEmbeddedIn(i)?i:i.isEmbeddedIn(n)?n:this.graph.getCommonAncestor(n,i)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)}return e},hasLoop:function(t){t=t||{};var e=this.attributes,n=e.source,i=e.target,r=n.id,o=i.id;if(!r||!o)return!1;var a=r===o;if(!a&&t.deep&&this.graph){var s=this.getSourceCell(),u=this.getTargetCell();a=s.isEmbeddedIn(u)||u.isEmbeddedIn(s)}return a},getSourceCell:function(){var t=this.graph,e=this.attributes.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getSourceCell()}while(t&&t.isLink());return t},getTargetCell:function(){var t=this.graph,e=this.attributes.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getTargetCell()}while(t&&t.isLink());return t},getRelationshipAncestor:function(){var t;if(this.graph){var e=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t});t=this.graph.getCommonAncestor.apply(this.graph,e)}return t||null},isRelationshipEmbeddedIn:function(t){var e=ds(t)||cs(t)?t:t.id,n=this.getRelationshipAncestor();return!!n&&(n.id===e||n.isEmbeddedIn(e))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var n=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&n}}),gh={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var n=this._results[t];if(void 0!==n)return n;try{n=e()}catch(t){n=!1}return this._results[t]=n}},vh=fh.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"}]}),mh=fh.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"}]}),yh=fh.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"}]}),bh=fh.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"}]}),wh=fh.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"}]}),xh=fh.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"}]}),Ah=fh.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"}]}),Ph=fh.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"}]}),Th=fh.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"}]}),Eh=fh.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"}]}),Sh=fh.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"}]}),kh=fh.define("standard.Cylinder",{attrs:{root:{cursor:"move"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{cx:"calc(w/2)",cy:10,rx:"calc(w/2)",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var n={lateralArea:t},i=zu(t)?"calc("+parseFloat(t)/100+"*h)":t,r={cy:i,ry:i};return this.attr({body:n,top:r},e)}},{attributes:{"lateral-area":{set:function(t,e){var n=zu(t);n&&(t=parseFloat(t)/100);var i=e.x,r=e.y,o=e.width,a=e.height,s=o/2,u=n?a*t:t,l=su.KAPPA,h=l*s,c=l*(n?a*t:t),d=i+o/2,f=i+o,p=r+u,g=p-u,v=r+a-u,m=r+a;return{d:["M",i,p,"L",i,v,"C",i,v+c,d-h,m,d,m,"C",d+h,m,f,v+c,f,v,"L",f,p,"C",f,p-c,d+h,g,d,g,"C",d-h,g,i,p-c,i,p,"Z"].join(" ")}}}}}),Mh=gh.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"}},Lh={standard:{Rectangle:vh,Circle:mh,Ellipse:yh,Path:bh,Polygon:wh,Polyline:xh,Image:Ah,BorderedImage:Ph,EmbeddedImage:Th,InscribedImage:Eh,HeaderedRectangle:Sh,Cylinder:kh,TextBlock:fh.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"},Mh]},{attributes:{text:{set:function(t,e,n,i){if(!(n instanceof HTMLElement)){var r=i.style||{},o={text:t,width:-5,height:"100%"},a=fs({"text-vertical-anchor":"middle"},r);return Hl["text-wrap"].set.call(this,o,e,n,a),{fill:r.color||null}}n.textContent=t},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),Link:ph.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"}}]}),DoubleLink:ph.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"}}]}),ShadowLink:ph.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"}}]})}},Ch={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},_h=Object.values(Ch),Nh=function(t,e,n,i){void 0===n&&(n=[]),void 0===i&&(i={});var r=i.cornerType;void 0===r&&(r=Ch.POINT);var o=i.cornerRadius;void 0===o&&(o=10);var a=i.cornerPreserveAspectRatio;void 0===a&&(a=!1);var s=i.precision;void 0===s&&(s=1);var u,l=i.raw;if(void 0===l&&(l=!1),-1===_h.indexOf(r))throw new Error("Invalid `cornerType` provided to `straight` connector.");if(r!==Ch.POINT&&o){var h;(u=new Ii).appendSegment(Ii.createSegment("M",t));for(var c=n.length,d=0;d<c;d++){var f=new si(n[d]),p=n[d-1]||t,g=n[d+1]||e,v=h||f.distance(p)/2;h=f.distance(g)/2;var m=void 0,y=void 0;a?m=y=-Math.min(o,v,h):(m=-Math.min(o,v),y=-Math.min(o,h));var b=f.clone().move(p,m).round(s),w=f.clone().move(g,y).round(s);switch(u.appendSegment(Ii.createSegment("L",b)),r){case Ch.CUBIC:var x=new si(1/3*b.x+2/3*f.x,2/3*f.y+1/3*b.y),A=new si(1/3*w.x+2/3*f.x,2/3*f.y+1/3*w.y);u.appendSegment(Ii.createSegment("C",x,A,w));break;case Ch.LINE:u.appendSegment(Ii.createSegment("L",w));break;case Ch.GAP:u.appendSegment(Ii.createSegment("M",w))}}u.appendSegment(Ii.createSegment("L",e))}else{var P=[t].concat(n).concat([e]),T=new Ci(P);u=new Ii(T)}return l?u:u.serialize()},Oh=["arc","gap","cubic"],Rh=["smooth"],Fh=1/3,Bh=2/3;function Vh(t,e){var n=t.x,i=t.y,r=e.x,o=e.y;if(r<n){var a=n;n=r,r=a,a=i,i=o,o=a}if(o<i){var s=n;n=r,r=s,s=i,i=o,o=s}return[new si(n,i),new si(r,o)]}function Ih(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]=di(e,i)),t},[])}function Dh(t,e){return di(t,e).squaredLength()}function jh(k,M,L,C){var _,N=new Ii;return _=Ii.createSegment("M",k[0].start),N.appendSegment(_),Cs(k).forEach(function(t,e){if(t.isJump){var n,i,r,o;if("arc"===L){n=-90,i=t.start.difference(t.end);var a=Number(i.x<0||0===i.x&&i.y<0);a&&(n+=180);var s,u=t.midpoint(),l=new ci(u,t.end).rotate(u,n);r=(s=new ci(t.start,u)).pointAt(2/3).rotate(t.start,n),o=l.pointAt(1/3).rotate(l.end,-n),_=Ii.createSegment("C",r,o,l.end),N.appendSegment(_),s=new ci(u,t.end),r=l.pointAt(1/3).rotate(l.end,n),o=s.pointAt(1/3).rotate(t.end,-n),_=Ii.createSegment("C",r,o,t.end),N.appendSegment(_)}else if("gap"===L)_=Ii.createSegment("M",t.end),N.appendSegment(_);else if("cubic"===L){n=t.start.theta(t.end);var h=.6*M,c=1.35*M;i=t.start.difference(t.end),(a=Number(i.x<0||0===i.x&&i.y<0))&&(c*=-1),r=si(t.start.x+h,t.start.y+c).rotate(t.start,n),o=si(t.end.x-h,t.end.y+c).rotate(t.end,n),_=Ii.createSegment("C",r,o,t.end),N.appendSegment(_)}}else{var d=k[e+1];0==C||!d||d.isJump?(_=Ii.createSegment("L",t.end),N.appendSegment(_)):(f=C,p=N,g=t.end,v=t.start,m=d.end,b=g.distance(v)/2,w=g.distance(m)/2,x=-Math.min(f,b),A=-Math.min(f,w),P=g.clone().move(v,x).round(),T=g.clone().move(m,A).round(),E=new si(Fh*P.x+Bh*g.x,Bh*g.y+Fh*P.y),S=new si(Fh*T.x+Bh*g.x,Bh*g.y+Fh*T.y),y=Ii.createSegment("L",P),p.appendSegment(y),y=Ii.createSegment("C",E,S,T),p.appendSegment(y))}var f,p,g,v,m,y,b,w,x,A,P,T,E,S}),N}var zh={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},Gh={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},Uh=function(t,e,n,i,r){void 0===n&&(n=[]),void 0===i&&(i={});var o=Boolean(i.raw),a=i.direction;void 0===a&&(a=zh.AUTO);var s=i.precision;void 0===s&&(s=3);var u={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new si(i.sourceTangent):null,targetTangent:i.targetTangent?new si(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?u.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?u.sourceDirection=new si(1,0).rotate(null,i.sourceDirection):u.sourceDirection=i.sourceDirection?new si(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?u.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?u.targetDirection=new si(1,0).rotate(null,i.targetDirection):u.targetDirection=i.targetDirection?new si(i.targetDirection).normalize():null;var l,h,c=[t].concat(n,[e]).map(function(t){return new si(t)});if(u.sourceTangent)l=u.sourceTangent;else{var d=function(t,e,n,i){if(i.sourceDirection)switch(i.sourceDirection){case Gh.UP:return new si(0,-1);case Gh.DOWN:return new si(0,1);case Gh.LEFT:return new si(-1,0);case Gh.RIGHT:return new si(1,0);case Gh.AUTO:return Hh(t,e,i);case Gh.CLOSEST_POINT:return Wh(t,e,i);case Gh.OUTWARDS:return Xh(t,e,i);default:return i.sourceDirection}switch(n){case zh.HORIZONTAL:return function(t,e,n){var i,r,o,a=t.sourceBBox;if(t.sourceView)if(r=t.sourceView.model.angle(),n.rotate&&r){var s=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),u=e[0].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[0]);else i=a.x>e[1].x?"right":"left";switch(i){case"left":o=new si(-1,0);break;case"right":default:o=new si(1,0)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.VERTICAL:return function(t,e,n){var i,r,o,a=t.sourceBBox;if(t.sourceView)if(r=t.sourceView.model.angle(),n.rotate&&r){var s=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),u=e[0].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[0]);else i=a.y>e[1].y?"bottom":"top";switch(i){case"top":o=new si(0,-1);break;case"bottom":default:o=new si(0,1)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.CLOSEST_POINT:return Wh(t,e,i);case zh.OUTWARDS:return Xh(t,e,i);case zh.AUTO:default:return Hh(t,e,i)}}(r,c,a,u),f=c[0].distance(c[1])*u.coeff,p=Jh(d,c[1].difference(c[0]).normalize());if(p>Math.PI/4){var g=f+(p-Math.PI/4)*u.angleTangentCoefficient;l=d.clone().scale(g,g)}else l=d.clone().scale(f,f)}if(u.targetTangent)h=u.targetTangent;else{var v=function(t,e,n,i){if(i.targetDirection)switch(i.targetDirection){case Gh.UP:return new si(0,-1);case Gh.DOWN:return new si(0,1);case Gh.LEFT:return new si(-1,0);case Gh.RIGHT:return new si(1,0);case Gh.AUTO:return qh(t,e,i);case Gh.CLOSEST_POINT:return Yh(t,e,i);case Gh.OUTWARDS:return $h(t,e,i);default:return i.targetDirection}switch(n){case zh.HORIZONTAL:return function(t,e,n){var i,r,o,a=t.targetBBox;if(t.targetView)if(r=t.targetView.model.angle(),n.rotate&&r){var s=t.targetView.getNodeUnrotatedBBox(t.targetView.el),u=e[e.length-1].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[e.length-1]);else i=a.x>e[e.length-2].x?"left":"right";switch(i){case"left":o=new si(-1,0);break;case"right":default:o=new si(1,0)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.VERTICAL:return function(t,e,n){var i,r,o,a=t.targetBBox;if(t.targetView)if(r=t.targetView.model.angle(),n.rotate&&r){var s=t.targetView.getNodeUnrotatedBBox(t.targetView.el),u=e[e.length-1].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[e.length-1]);else i=a.y>e[e.length-2].y?"top":"bottom";switch(i){case"top":o=new si(0,-1);break;case"bottom":default:o=new si(0,1)}n.rotate&&r&&o.rotate(null,-r);return o}(t,e,i);case zh.CLOSEST_POINT:return Yh(t,e,i);case zh.OUTWARDS:return $h(t,e,i);case zh.AUTO:default:return qh(t,e,i)}}(r,c,a,u),m=c.length-1,y=c[m-1].distance(c[m])*u.coeff,b=Jh(v,c[m-1].difference(c[m]).normalize());if(b>Math.PI/4){var w=y+(b-Math.PI/4)*u.angleTangentCoefficient;h=v.clone().scale(w,w)}else h=v.clone().scale(y,y)}var x=function(t,e,n,i){for(var r=i.tau,o=i.coeff,a=[],s=[],u=[],l=t.length-1,h=0;h<l;h++)a[h]=t[h].distance(t[h+1]);s[0]=e,s[l]=n;for(var c=1;c<l;c++){var d=void 0,f=void 0;d=1===c?t[c-1].clone().offset(s[c-1].x,s[c-1].y):t[c-1].clone(),f=c===l-1?t[c+1].clone().offset(s[c+1].x,s[c+1].y):t[c+1].clone();var p=d.difference(t[c]).normalize(),g=f.difference(t[c]).normalize(),v=Jh(p,g),m=(Math.PI-v)/2,y=void 0,b=Kh(p,g),w=void 0;w=Kh(t[c].difference(t[c+1]),t[c].difference(t[c-1])),b<0&&(m=-m),v<Math.PI/2&&(m<0&&w<0||0<m&&0<w)&&(m-=Math.PI),Zh(y=g.clone(),m);var x=y.clone(),A=y.clone(),P=a[c-1]*o,T=a[c]*o;x.scale(P,P),A.scale(T,T),s[c]=[x,A]}for(var E=0;E<l;E++){var S=void 0,k=void 0;S=0===E?t[E+1].difference(s[E].x/r,s[E].y/r):t[E+1].difference(s[E][1].x/r,s[E][1].y/r),k=E===l-1?t[E].clone().offset(s[E+1].x/r,s[E+1].y/r):t[E].difference(s[E+1][0].x/r,s[E+1][0].y/r),u[E]=[S,t[E],t[E+1],k]}return u}(c,l,h,u).map(function(t){return function(t,e){var n=e.tau,i=new si;i.x=t[1].x+(t[2].x-t[0].x)/(6*n),i.y=t[1].y+(t[2].y-t[0].y)/(6*n);var r=new si;return r.x=t[2].x+(t[3].x-t[1].x)/(6*n),r.y=t[2].y+(t[3].y-t[1].y)/(6*n),new Bi(t[1],i,r,t[2])}(t,u)}),A=new Ii(x).round(s);return o?A:A.serialize()};function Hh(t,e,n){var i,r,o,a=t.sourceBBox;if(t.sourceView)if(r=t.sourceView.model.angle(),n.rotate&&r){var s=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),u=e[0].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[0]);else i=a.sideNearestToPoint(e[1]);switch(i){case"top":o=new si(0,-1);break;case"bottom":o=new si(0,1);break;case"right":o=new si(1,0);break;case"left":o=new si(-1,0)}return n.rotate&&r&&o.rotate(null,-r),o}function qh(t,e,n){var i,r,o,a=t.targetBBox;if(t.targetView)if(r=t.targetView.model.angle(),n.rotate&&r){var s=t.targetView.getNodeUnrotatedBBox(t.targetView.el),u=e[e.length-1].clone();u.rotate(a.center(),r),i=s.sideNearestToPoint(u)}else i=a.sideNearestToPoint(e[e.length-1]);else i=a.sideNearestToPoint(e[e.length-2]);switch(i){case"top":o=new si(0,-1);break;case"bottom":o=new si(0,1);break;case"right":o=new si(1,0);break;case"left":o=new si(-1,0)}return n.rotate&&r&&o.rotate(null,-r),o}function Wh(t,e,n){return e[1].difference(e[0]).normalize()}function Yh(t,e,n){var i=e.length-1;return e[i-1].difference(e[i]).normalize()}function Xh(t,e,n){var i=t.sourceBBox.center();return e[0].difference(i).normalize()}function $h(t,e,n){var i=t.targetBBox.center();return e[e.length-1].difference(i).normalize()}function Zh(t,e){var n=Math.cos(e),i=Math.sin(e),r=n*t.x-i*t.y,o=i*t.x+n*t.y;t.x=r,t.y=o}function Jh(t,e){var n=t.dot(e)/(t.magnitude()*e.magnitude());return n<-1&&(n=-1),1<n&&(n=1),Math.acos(n)}function Kh(t,e){return t.x*e.y-t.y*e.x}Uh.Directions=zh,Uh.TangentDirections=Gh;var Qh={straight:Nh,jumpover:function(t,e,n,i){!function(t){var e=t.paper,n=e._jumpOverUpdateList;if(null==n){n=e._jumpOverUpdateList=[];var i=e.model;i.on("batch:stop",function(){this.hasActiveBatch()||function(t){for(var e=t._jumpOverUpdateList,n=0;n<e.length;n++){var i=e[n],r=i.getFlag(i.constructor.Flags.CONNECTOR);i.requestUpdate(r)}}(e)}),i.on("reset",function(){n=e._jumpOverUpdateList=[]})}n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",function(){n.splice(n.indexOf(t),1)}))}(this);var r=i.raw,o=i.size||5,a=i.jump&&(""+i.jump).toLowerCase(),s=i.radius||0,u=i.ignoreConnectors||Rh;-1===Oh.indexOf(a)&&(a=Oh[0]);var l=this.paper,h=l.model.getLinks();if(1===h.length)return jh(Ih(t,e,n),o,a,s);var d=this.model,c=h.indexOf(d),f=l.options.defaultConnector||{},p=h.filter(function(t,e){var n=t.get("connector")||f;return!(Cs(u).includes(n.name)||c<e&&"jumpover"===n.name)}),g=p.map(function(t){return l.findViewByModel(t)}),v=Ih(t,e,n),y=g.map(function(t){return null==t?[]:t===this?v:Ih(t.sourcePoint,t.targetPoint,t.route)},this),m=jh(v.reduce(function(t,m){var l,h,c,e=p.reduce(function(t,e,n){if(e!==d){var i=y[n].slice(),r=i.findIndex(function(t){return n=t,i=Vh((e=m).start,e.end),r=i[0],o=r.x,a=r.y,s=i[1],u=s.x,l=s.y,h=Vh(n.start,n.end),c=h[0],d=c.x,f=c.y,p=h[1],g=p.x,v=p.y,o<=g&&d<=u&&a<=v&&f<=l;var e,n,i,r,o,a,s,u,l,h,c,d,f,p,g,v});-1<r&&m.containsPoint(i[r].end)&&i.splice(r+1,1);var o=(a=m,Cs(i).reduce(function(t,e){var n=a.intersection(e);return n&&t.push(n),t},[]));t.push.apply(t,o)}var a;return t},[]).sort(function(t,e){return Dh(m.start,t)-Dh(m.start,e)});return 0<e.length?t.push.apply(t,(l=m,c=o,(h=e).reduce(function(t,e,n){if(!0===e.skip)return t;var i=t.pop()||l,r=ui(e).move(i.start,-c),o=ui(e).move(i.start,+c),a=h[n+1];if(null!=a){var s=o.distance(a);s<=c&&(o=a.move(i.start,s),a.skip=!0)}else if(r.distance(i.end)<2*c+1)return t.push(i),t;if(o.distance(i.start)<2*c+1)return t.push(i),t;var u=di(r,o);return u.isJump=!0,t.push(di(i.start,r),u,di(o,i.end)),t},[]))):t.push(m),t},[]),o,a,s);return r?m:m.serialize()},normal:function(t,e,n,i){void 0===n&&(n=[]),void 0===i&&(i={});var r=i.raw;return Nh(t,e,n,{cornerType:"point",raw:r})},rounded:function(t,e,n,i){void 0===n&&(n=[]),void 0===i&&(i={});var r=i.radius;void 0===r&&(r=10);var o=i.raw;return Nh(t,e,n,{cornerType:"cubic",cornerRadius:r,precision:0,raw:o})},smooth:function(t,e,n,i){var r,o=i&&i.raw;if(n&&0!==n.length){var a=[t].concat(n).concat([e]),s=Bi.throughPoints(a);r=new Ii(s)}else{var u;if(r=new Ii,u=Ii.createSegment("M",t),r.appendSegment(u),Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)){var l=(t.x+e.x)/2;u=Ii.createSegment("C",l,t.y,l,e.y,e.x,e.y),r.appendSegment(u)}else{var h=(t.y+e.y)/2;u=Ii.createSegment("C",t.x,h,e.x,h,e.x,e.y),r.appendSegment(u)}}return o?r:r.serialize()},curve:Uh},tc=function(t){this.cid=qs("view"),this.preinitialize.apply(this,arguments),fs(this,zs(t,nc)),this._ensureElement(),this.initialize.apply(this,arguments)},ec=/^(\S+)\s*(.*)$/,nc=["model","collection","el","id","attributes","className","tagName","events"];fs(tc.prototype,rl,{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 iu?t:iu(t),this.el=this.$el[0]},delegateEvents:function(t){if(t||(t=Ds(this,"events")),!t)return this;for(var e in this.undelegateEvents(),t){var n=t[e];if(Ms(n)||(n=this[n]),n){var i=e.match(ec);this.delegate(i[1],i[2],n.bind(this))}}return this},delegate:function(t,e,n){return this.$el.on(t+".delegateEvents"+this.cid,e,n),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,n){return this.$el.off(t+".delegateEvents"+this.cid,e,n),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){if(this.el)this.setElement(Ds(this,"el"));else{var t=fs({},Ds(this,"attributes"));this.id&&(t.id=Ds(this,"id")),this.className&&(t.class=Ds(this,"className")),this.setElement(this._createElement(Ds(this,"tagName"))),this._setAttributes(t)}},_setAttributes:function(t){this.$el.attr(t)}}),tc.extend=gl;var ic={},rc=tc.extend({options:{},theme:null,themeClassNamePrefix:Su("theme-"),requireSetThemeOverride:!1,defaultTheme:xu.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=fs({},this.options,t),tc.call(this,t)},initialize:function(){(ic[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){this.svgElement?this.vel.remove():this.$el.remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){if(t||(t=Ds(this,"children")),t){var e=this.svgElement,n=su.namespace[e?"svg":"xhtml"],i=ku(t,n);(e?this.vel:this.$el).empty().append(i.fragment),this.childNodes=i.selectors}return this},findAttributeNode:function(t,e){for(var n=e;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){var n=this.findAttributeNode(t,e);return n&&n.getAttribute(t)},_ensureElement:function(){if(this.el)this.setElement(Ds(this,"el"));else{var t=Ds(this,"tagName"),e=fs({},Ds(this,"attributes")),n=fs({},Ds(this,"style"));this.id&&(e.id=Ds(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)}this._ensureElClassName()},_setAttributes:function(t){this.svgElement?this.vel.attr(t):this.$el.attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(su.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof iu?t:iu(t),this.el=this.$el[0],this.svgElement&&(this.vel=su(this.el))},_ensureElClassName:function(){var t=Ds(this,"className");if(t){var e=Su(t);this.svgElement?this.vel.removeClass(t).addClass(e):this.$el.removeClass(t).addClass(e)}},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.addClass(e):this.$el.addClass(e),this},removeThemeClassName:function(t){t=t||this.theme;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.removeClass(e):this.$el.removeClass(e),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),ic[this.cid]=null,tc.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(!e)return this;n||(n={});var i=this.getEventNamespace();for(var r in e){var o=e[r];"function"!=typeof o&&(o=this[o]),o&&iu(t).on(r+i,n,o.bind(this))}return this},undelegateElementEvents:function(t){return iu(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t||(t=Ds(this,"documentEvents")),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var n=t.data,i="__"+this.cid+"__";return void 0===e?n&&n[i]||{}:(n||(n=t.data={}),n[i]||(n[i]={}),fs(n[i],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&fs({},t[0])||{},n=t[1]&&fs({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,tc.extend.call(this,e,n)}}),oc=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];this.callbackArguments=t};oc.prototype.listenTo=function(i,t){for(var r=this,e=[],n=arguments.length-2;0<n--;)e[n]=arguments[n+2];var o=this.callbackArguments;if(su.isObject(t)){var a=e[0];void 0===a&&(a=null),Object.entries(t).forEach(function(t){var e=t[0],n=t[1];"function"==typeof n&&((a||0<o.length)&&(n=n.bind.apply(n,[a].concat(o))),rl.listenTo.call(r,i,e,n))})}else if("string"==typeof t&&"function"==typeof e[0]){var s=e[0],u=e[1];void 0===u&&(u=null),(u||0<o.length)&&(s=s.bind.apply(s,[u].concat(o))),rl.listenTo.call(this,i,t,s)}};var ac=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,fs({silent:!0},e))},sc={add:!0,remove:!0,merge:!0},uc={add:!0,remove:!(oc.prototype.stopListening=function(){rl.stopListening.call(this)})},lc=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var i,r=Array(t.length-n),o=e.length;for(i=0;i<r.length;i++)r[i]=t[i+n];for(i=0;i<o;i++)t[i+n]=e[i];for(i=0;i<r.length;i++)t[i+o+n]=r[i]};fs(ac.prototype,rl,{model:bl,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(t,e){return this.set(t,fs({merge:!1},e,uc))},remove:function(t,e){e=fs({},e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=this._removeModels(t,e);return!e.silent&&i.length&&(e.changes={added:[],merged:[],removed:i},this.trigger("update",this,e)),n?i[0]:i},set:function(t,e){if(null!=t){e=fs({},sc,e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=e.at;null!=i&&(i=+i),i>this.length&&(i=this.length),i<0&&(i+=this.length+1);var r,o,a=[],s=[],u=[],l=[],h={},c=e.add,d=e.merge,f=e.remove,p=!1,g=this.comparator&&null==i&&!1!==e.sort,v=ds(this.comparator)?this.comparator:null;for(o=0;o<t.length;o++){r=t[o];var m=this.get(r);if(m){if(d&&r!==m){var y=this._isModel(r)?r.attributes:r;m.set(y,e),u.push(m),g&&!p&&(p=m.hasChanged(v))}h[m.cid]||(h[m.cid]=!0,a.push(m)),t[o]=m}else c&&(r=t[o]=this._prepareModel(r,e))&&(s.push(r),this._addReference(r,e),h[r.cid]=!0,a.push(r))}if(f){for(o=0;o<this.length;o++)h[(r=this.models[o]).cid]||l.push(r);l.length&&this._removeModels(l,e)}var b=!1,w=!g&&c&&f;if(a.length&&w?(b=this.length!==a.length||this.models.some(function(t,e){return t!==a[e]}),this.models.length=0,lc(this.models,a,0),this.length=this.models.length):s.length&&(g&&(p=!0),lc(this.models,s,null==i?this.length:i),this.length=this.models.length),p&&this.sort({silent:!0}),!e.silent){for(o=0;o<s.length;o++)null!=i&&(e.index=i+o),(r=s[o]).trigger("add",r,this,e);(p||b)&&this.trigger("sort",this,e),(s.length||l.length||u.length)&&(e.changes={added:s,removed:l,merged:u},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?Ts(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,fs({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,fs({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,fs({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 Ms(e)&&(e=e.bind(this)),1===n||ds(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 cc(this,dc)},keys:function(){return new cc(this,fc)},entries:function(){return new cc(this,pc)},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){return void 0===e&&(e=this.first()),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):(n=((e=e?Ts(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,n.validationError,e),!1):n;var n},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r=this.get(t[i]);if(r){var o=this.models.indexOf(r);this.models.splice(o,1),this.length--,delete this._byId[r.cid];var a=this.modelId(r.attributes,r.idAttribute);null!=a&&delete this._byId[a],e.silent||(e.index=o,r.trigger("remove",r,this,e)),n.push(r),this._removeReference(r,e)}}return 0<t.length&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof bl},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,i){if(e){if(("add"===t||"remove"===t)&&n!==this)return;if("changeId"===t){var r=this.modelId(e.previousAttributes(),e.idAttribute),o=this.modelId(e.attributes,e.idAttribute);null!=r&&delete this._byId[r],null!=o&&(this._byId[o]=e)}}this.trigger.apply(this,arguments)}});var hc="function"==typeof Symbol&&Symbol.iterator;hc&&(ac.prototype[hc]=ac.prototype.values);var cc=function(t,e){this._collection=t,this._kind=e,this._index=0},dc=1,fc=2,pc=3;hc&&(cc.prototype[hc]=function(){return this}),cc.prototype.next=function(){if(this._collection){if(this._index<this._collection.length){var t,e=this._collection.at(this._index);if(this._index++,this._kind===dc)t=e;else{var n=this._collection.modelId(e.attributes,e.idAttribute);t=this._kind===fc?n:[n,e]}return{value:t,done:!1}}this._collection=void 0}return{value:void 0,done:!0}};var gc,vc,mc,yc;vc=(gc=[ac,{toArray:1,sortBy:3},"models"])[0],mc=gc[1],yc=gc[2],vl(vc,{sortBy:Os,toArray:Cs},mc,yc),ac.extend=gl;var bc={Data:Ys,$:iu,views:ic,View:rc,Listener:oc,Events:rl,Collection:ac,Model:bl,ViewBase:tc,Event:Zs};function wc(t){return t?Array.isArray(t)?t:[t]:[]}var xc=rc.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:function(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:function(){this.updateRequested=!1;var t=this.cellView,e=this.nodeSelector;return t.isMounted()?(this.update(t,e),this.mount(),this.transform()):this.postponedUpdate=!0,0},findNode:function(t,e){var n;if(void 0===e&&(e=null),"string"==typeof e)n=t.findNode(e);else if(Ls(e)){var i=t.model.isLink(),r=e.label;void 0===r&&(r=null);var o=e.port,a=e.selector;n=i&&null!==r?t.findLabelNode(r,a):!i&&o?t.findPortNode(o,a):t.findNode(a)}else e&&((n=su.toNode(e))instanceof SVGElement||(n=null));return n||null},getNodeMatrix:function(t,e){var n=this.options.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:function(){var t=this.MOUNTABLE,e=this.cellView,n=this.el,i=this.options,r=this.transformGroup,o=this.detachedTransformGroup,a=this.postponedUpdate,s=this.nodeSelector;if(t&&!r){if(a)return this.update(e,s),void this.transform();var u,l=e.vel,h=e.paper,c=i.layer;if(c)o?(u=o,this.detachedTransformGroup=null):u=su("g").addClass("highlight-transform").append(n),this.transformGroup=u,h.getLayerView(c).insertSortedNode(u.node,i.z);else n.parentNode&&!n.nextSibling||l.append(n)}},unmount:function(){var t=this.MOUNTABLE,e=this.transformGroup,n=this.vel;t&&(e?(this.transformGroup=null,(this.detachedTransformGroup=e).remove()):n.remove())},transform:function(){var t=this.transformGroup,e=this.cellView,n=this.updateRequested;if(t&&!e.model.isLink()&&!n){var i=e.getRootTranslateMatrix(),r=e.getRootRotateMatrix(),o=i.multiply(r);t.attr("transform",su.matrixToTransformString(o))}},update:function(){var t=this.node,e=this.cellView,n=this.nodeSelector,i=this.updateRequested,r=this.id;if(!i){this.postponedUpdate=!1;var o=this.node=this.findNode(e,n);t&&this.unhighlight(e,t),o?(this.highlight(e,o),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this))}},onRemove:function(){var t=this.node,e=this.cellView,n=this.id,i=this.constructor;t&&this.unhighlight(e,t),this.unmount(),i._removeRef(e,n)},highlight:function(t,e){},unhighlight:function(t,e){},listenToUpdateAttributes:function(t){var e=Ds(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange:function(){var t=this.cellView;if(t){var e=t.model,n=t.paper;Ds(this,"UPDATE_ATTRIBUTES").some(function(t){return e.hasChanged(t)})&&n.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){var i=this.uniqueId(e,n);this.remove(t,i)},get:function(t,e){void 0===e&&(e=null);var n=t.cid,i=this._views[n];if(null===e){var r=[];if(!i)return r;for(var o in i){var a=i[o];a instanceof this&&r.push(a)}return r}if(!i)return null;if(e in i){var s=i[e];if(s instanceof this)return s}return null},add:function(t,e,n,i){if(void 0===i&&(i={}),!n)throw new Error("dia.HighlighterView: An ID required.");var r=xc.get(t,n);r&&r.remove();var o=new this(i);return o.id=n,this._addRef(t,n,o),o.requestUpdate(t,e),o.listenToUpdateAttributes(t),o},_addRef:function(t,e,n){var i=t.cid,r=this._views,o=r[i];o||(o=r[i]={}),o[e]=n},_removeRef:function(t,e){var n=t.cid,i=this._views,r=i[n];if(r){for(var o in e&&delete r[e],r)return;delete i[n]}},remove:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){t.remove()})},removeAll:function(t,e){void 0===e&&(e=null);var n=this._views;for(var i in n)for(var r in n[i]){var o=n[i][r];o.cellView.paper===t&&o instanceof this&&(null===e||r===e)&&o.remove()}},update:function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1),wc(this.get(t,e)).forEach(function(t){(n||t.UPDATABLE)&&t.update()})},transform:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){t.UPDATABLE&&t.transform()})},unmount:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){return t.unmount()})},mount:function(t,e){void 0===e&&(e=null),wc(this.get(t,e)).forEach(function(t){return t.mount()})},uniqueId:function(t,e){return void 0===e&&(e=""),su.ensureId(t)+JSON.stringify(e)}}),Ac=xc.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:function(e,n){var i,r=this.options,t=r.useFirstSubpath;try{var o=su(n);if(i=o.convertToPathData().trim(),"PATH"===o.tagName()&&t){var a=i.search(/.M/i)+1;0<a&&(i=i.substr(0,a))}}catch(t){var s=e.getNodeBoundingRect(n);i=su.rectToPath(fs({},r,s.toJSON()))}return i},highlightConnection:function(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode:function(t,e){var n=this.vel,i=this.options,r=i.padding,o=i.layer,a=this.getNodeMatrix(t,e);if(r){o||e!==t.el||n.remove();var s=t.getNodeBoundingRect(e),u=s.x+s.width/2,l=s.y+s.height/2;s=su.transformRect(s,a);var h=Math.max(s.width,1),c=Math.max(s.height,1),d=(h+r)/h,f=(c+r)/c,p=su.createSVGMatrix({a:d,b:0,c:0,d:f,e:u-d*u,f:l-f*l});a=a.multiply(p)}n.attr({d:this.getPathData(t,e),transform:su.matrixToTransformString(a)})},highlight:function(t,e){var n=this.vel,i=this.options;n.attr(i.attrs),i.nonScalingStroke&&n.attr("vector-effect","non-scaling-stroke"),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}});var Pc=xc.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:function(t,e){var n=this.MASK_CHILD_ATTRIBUTE_BLACKLIST,i=this.MASK_REPLACE_TAGS,r=this.MASK_REMOVE_TAGS,o=e.tagName();if(!su.isSVGGraphicsElement(e)||r.includes(o))return e.remove(),!1;if(i.includes(o)){var a=t.vel.findOne("#"+e.id);if(a){var s=a.node,u=t.getNodeBoundingRect(s);t.model.isElement()&&(u=su.transformRect(u,t.getNodeMatrix(s)));var l=su("rect",u.toJSON()),h=u.center(),c=h.x,d=h.y,f=a.rotate(),p=f.angle,g=f.cx;void 0===g&&(g=c);var v=f.cy;void 0===v&&(v=d),p&&l.rotate(p,g,v),e.parent().append(l)}return e.remove(),!1}return n.forEach(function(t){"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)}),!0},transformMaskRoot:function(t,e){this.MASK_ROOT_ATTRIBUTE_BLACKLIST.forEach(function(t){e.removeAttr(t)})},getMaskShape:function(e,t){var n,i=this,r=this.options,o=this.MASK_REPLACE_TAGS,a=r.deep,s=t.tagName();if("G"===s){if(!a)return null;(function(t,e){for(var n=t.children();0<n.length;){var i=n.shift();e(i)&&n.push.apply(n,i.children())}})(n=t.clone(),function(t){return i.transformMaskChild(e,t)})}else{if(o.includes(s))return null;n=t.clone()}return this.transformMaskRoot(e,n),n},getMaskId:function(){return"highlight-mask-"+this.cid},getMask:function(t,e){var n=this.VISIBLE,i=this.INVISIBLE,r=this.options,o=r.padding,a=r.attrs,s=parseFloat(su("g").attr(a).attr("stroke-width")),u="none"!==e.attr("fill"),l=parseFloat(e.attr("stroke-width"));isNaN(l)&&(l=1);var h=l+2*o,c=h+2*s,d=this.getMaskShape(t,e);if(!d){var f=t.getNodeBoundingRect(e.node);f.inflate(f.width?0:.5,f.height?0:.5),d=su("rect",f.toJSON())}return d.attr(a),su("mask",{id:this.getMaskId()}).append([d.clone().attr({fill:u?n:"none",stroke:n,"stroke-width":c}),d.clone().attr({fill:u?i:"none",stroke:i,"stroke-width":h})])},removeMask:function(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask:function(t,e){t.defs.appendChild(e.node)},highlight:function(t,e){var n=this.options,i=this.vel,r=n.padding,o=n.attrs,a=n.maskClip;void 0===a&&(a=20);var s=n.layer,u="stroke"in o?o.stroke:"#000000";s||e!==t.el||i.remove();var l=t.getNodeBoundingRect(e).inflate(r+a),h=this.getNodeMatrix(t,e),c=this.getMask(t,su(e));this.addMask(t.paper,c),i.attr(l.toJSON()),i.attr({transform:su.matrixToTransformString(h),mask:"url(#"+c.id+")",fill:u})},unhighlight:function(t){this.removeMask(t.paper)}}),Tc=xc.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){var n=this.options.alphaValue;void 0===n&&(n=.3),e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),Ec=Su("highlighted"),Sc=xc.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:Ec},highlight:function(t,e){su(e).addClass(this.options.className)},unhighlight:function(t,e){su(e).removeClass(this.options.className)}},{className:Ec}),kc={ROW:"row",COLUMN:"column"},Mc={stroke:Ac,mask:Pc,opacity:Tc,addClass:Sc,list:xc.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight:function(t,e){var o=this,n=t.model,i=this.options,a=i.attribute,r=i.size;void 0===r&&(r=20);var s=i.gap;void 0===s&&(s=5);var u=i.direction;if(void 0===u&&(u=kc.ROW),!a)throw new Error("List: attribute is required");var l="number"==typeof r?{width:r,height:r}:r,h=u===kc.ROW,c=h?l.width:l.height,d=n.get(a);Array.isArray(d)||(d=[]);var f=this._prevItems||[],p=d.map(function(t,e){return ks(f[e],d[e])});if(f.length!==d.length||p.some(function(t){return!t})){var g=this.vel.children(),v=d.map(function(t,e){var n=e in g?g[e].node:null;if(p[e])return n;var i=o.createListItem(t,l,n);if(!i)return null;if(!(i instanceof SVGElement))throw new Error("List: item must be an SVGElement");i.dataset.index=e,i.dataset.attribute=a;var r=e*(c+s);return i.setAttribute("transform",h?"translate("+r+", 0)":"translate(0, "+r+")"),i});this.vel.empty().append(v),this._prevItems=d}var m=d.length,y=0===m?0:m*c+(m-1)*s,b=h?{width:y,height:l.height}:{width:l.width,height:y};this.position(n,b)},position:function(t,e){var n=this.vel,i=this.options,r=i.margin;void 0===r&&(r=5);var o=i.position;void 0===o&&(o="top-left");var a=t.size(),s=a.width,u=a.height,l=Ju(r),h=l.left,c=l.right,d=l.top,f=l.bottom,p=Zl(new Ei(h,d,s-(h+c),u-(d+f)),o),g=p.x,v=p.y;switch(o){case $l.CENTER:case $l.TOP:case $l.BOTTOM:g-=e.width/2;break;case $l.RIGHT:case $l.BOTTOM_RIGHT:case $l.TOP_RIGHT:g-=e.width}switch(o){case $l.CENTER:case $l.RIGHT:case $l.LEFT:v-=e.height/2;break;case $l.BOTTOM:case $l.BOTTOM_RIGHT:case $l.BOTTOM_LEFT:v-=e.height}n.attr("transform","translate("+g+", "+v+")")}},{Directions:kc,Positions:$l})};function Lc(t,e,n){if(Ls(n)){var i=n.x,r=n.y;if(isFinite(r)){var o=new ci(e,t).parallel(r);e=o.start,t=o.end}n=i}if(!isFinite(n))return t;var a=t.distance(e);return 0===n&&0<a?t:t.move(e,-Math.min(n,a-1))}function Cc(t){var e=t.getAttribute("stroke-width");return null===e?0:parseFloat(e)||0}function _c(t,e,n,i){var r=e.getNodeBBox(n);i.stroke&&r.inflate(Cc(n)/2);var o=t.intersect(r);return Lc(o?t.start.chooseClosest(o):t.end,t.start,i.offset)}var Nc="segmentSubdivisons",Oc="shapeBBox";var Rc={anchor:function(t,e,n,i){var r=i.offset,o=i.alignOffset,a=i.align;return a&&function(t,e,n){var i,r,o,a;void 0===n&&(n=0);var s=t.start,u=t.end;switch(e){case"left":i="x",r=u,o=s,a=-1;break;case"right":i="x",r=s,o=u,a=1;break;case"top":i="y",r=u,o=s,a=-1;break;case"bottom":i="y",r=s,o=u,a=1;break;default:return}s[i]<u[i]?r[i]=o[i]:o[i]=r[i],isFinite(n)&&(r[i]+=a*n,o[i]+=a*n)}(t,a,o),Lc(t.end,t.start,r)},bbox:_c,rectangle:function(t,e,n,i){var r=e.model.angle();if(0===r)return _c(t,e,n,i);var o=e.getNodeUnrotatedBBox(n);i.stroke&&o.inflate(Cc(n)/2);var a=o.center(),s=t.clone().rotate(a,r),u=s.setLength(1e6).intersect(o);return Lc(u?s.start.chooseClosest(u).rotate(a,-r):t.end,t.start,i.offset)},boundary:function(t,e,n,i){var r,o,a=i.selector,s=t.end;if(r="string"==typeof a?e.findNode(a):!1===a?n:Array.isArray(a)?Lu(n,a):function(t){if(!t)return null;var e=t;do{var n=e.tagName;if("string"!=typeof n)return null;if("G"===(n=n.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==n)break;e=e.nextElementSibling}}while(e);return e}(n),!su.isSVGGraphicsElement(r)){if(r===n||!su.isSVGGraphicsElement(n))return s;r=n}var u,l=e.getNodeShape(r),h=e.getNodeMatrix(r),c=e.getRootTranslateMatrix(),d=e.getRootRotateMatrix(),f=c.multiply(d).multiply(h),p=f.inverse(),g=su.transformLine(t,p),v=g.start.clone(),m=e.getNodeData(r);if(!1===i.insideout&&(m[Oc]||(m[Oc]=l.bbox()),m[Oc].containsPoint(v)))return s;if(l instanceof Ii){var y=i.precision||2;m[Nc]||(m[Nc]=l.getSegmentSubdivisions({precision:y})),u={precision:y,segmentSubdivisions:m[Nc]}}!0===i.extrapolate&&g.setLength(1e6),(o=g.intersect(l,u))?su.isArray(o)&&(o=v.chooseClosest(o)):!0===i.sticky&&(o=l instanceof Ei?l.pointNearestToPoint(v):l instanceof vi?l.intersectionWithLineFromCenterToPoint(v):l.closestPoint(v,u));var b=o?su.transformPoint(o,f):s,w=i.offset||0;return i.stroke&&(w+=Cc(r)/2),Lc(b,t.start,w)}};function Fc(t,e){if(0===e)return"0%";return Math.round(t/e*100*1e3)/1e3+"%"}function Bc(r){return function(t,e,n,i){return(e.isNodeConnection(n)?Ic:Vc)(r,t,e,n,i)}}function Vc(t,e,n,i,r){var o=n.model.angle(),a=n.getNodeUnrotatedBBox(i),s=n.model.getBBox().center();r.rotate(s,o);var u=r.x-a.x,l=r.y-a.y;return t&&(u=Fc(u,a.width),l=Fc(l,a.height)),e.anchor={name:"topLeft",args:{dx:u,dy:l,rotate:!0}},e}function Ic(t,e,n,i,r){var o=n.getConnection();if(!o)return e;var a=o.closestPointLength(r);if(t){var s=o.length();e.anchor={name:"connectionRatio",args:{ratio:a/s}}}else e.anchor={name:"connectionLength",args:{length:a}};return e}var Dc=il,jc=Bc(!1),zc=Bc(!0),Gc={useDefaults:Dc,pinAbsolute:jc,pinRelative:zc},Uc={N:"S",S:"N",E:"W",W:"E"},Hc={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function qc(t,e,n){var i=new si(t.x,e.y);return n.containsPoint(i)&&(i=new si(e.x,t.y)),i}function Wc(t,e){return t["W"===e||"E"===e?"width":"height"]}function Yc(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 Xc(t){return new Ei(t.x,t.y,0,0)}function $c(t){var e=Ju(t.padding||t.elementPadding||20);return{x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}function Zc(t,e){return t.sourceBBox.clone().moveAndExpand($c(e))}function Jc(t,e){return t.targetBBox.clone().moveAndExpand($c(e))}function Kc(t,e,n){var i=new si(t.x,e.y),r=new si(e.x,t.y),o=Yc(t,i),a=Yc(t,r),s=Uc[n],u=o===n||o!==s&&(a===s||a!==n)?i:r;return{points:[u],direction:Yc(u,e)}}function Qc(t,e,n){var i=qc(t,e,n);return{points:[i],direction:Yc(i,e)}}function td(e,t,n,i){var r,o={},a=[new si(e.x,t.y),new si(t.x,e.y)],s=a.filter(function(t){return!n.containsPoint(t)}),u=s.filter(function(t){return Yc(t,e)!==i});if(0<u.length)r=(r=u.filter(function(t){return Yc(e,t)===i}).pop())||u[0],o.points=[r],o.direction=Yc(r,t);else{r=Bs(a,s)[0];var l=new si(t).move(r,-Wc(n,i)/2),h=qc(l,e,n);o.points=[h,l],o.direction=Yc(l,t)}return o}function ed(t,e,n,i){var r=Qc(e,t,i),o=r.points[0];if(n.containsPoint(o)){var a=(r=Qc(t,e,n)).points[0];if(i.containsPoint(a)){var s=new si(t).move(a,-Wc(n,Yc(t,a))/2),u=new si(e).move(o,-Wc(i,Yc(e,o))/2),l=new ci(s,u).midpoint(),h=Qc(t,l,n),c=Kc(l,e,h.direction);r.points=[h.points[0],c.points[0]],r.direction=c.direction}}return r}function nd(t,e,n,i,r){var o,a,s,u={},l=n.union(i).inflate(1),h=l.center().distance(e)>l.center().distance(t),c=h?e:t,d=h?t:e;return a=qc(o=r?(o=si.fromPolar(l.width+l.height,Hc[r],c),l.pointNearestToPoint(o).move(o,-1)):l.pointNearestToPoint(c).move(c,1),d,l),o.round().equals(a.round())?(a=si.fromPolar(l.width+l.height,Gn(o.theta(c))+Math.PI/2,d),s=qc(o,a=l.pointNearestToPoint(a).move(d,1).round(),l),u.points=h?[a,s,o]:[o,s,a]):u.points=h?[a,o]:[o,a],u.direction=Yc(h?o:a,e),u}function id(t,e,n){var i,r,o,a,s,u=Zc(n,e),l=Jc(n,e),h=(r=e,(i=n).sourceAnchor?i.sourceAnchor:Zc(i,r).center()),c=(a=e,(o=n).targetAnchor?o.targetAnchor:Jc(o,a).center());u=u.union(Xc(h)),l=l.union(Xc(c)),(t=Cs(t).map(si)).unshift(h),t.push(c);for(var d=[],f=0,p=t.length-1;f<p;f++){var g=null,v=t[f],m=t[f+1],y=!!Yc(v,m);if(0===f)f+1===p?u.intersect(l.clone().inflate(1))?g=nd(v,m,u,l):y||(g=ed(v,m,u,l)):u.containsPoint(m)?g=nd(v,m,u,Xc(m).moveAndExpand($c(e))):y||(g=Qc(v,m,u));else if(f+1===p){var b=y&&Yc(m,v)===s;l.containsPoint(v)||b?g=nd(v,m,Xc(v).moveAndExpand($c(e)),l,s):y||(g=td(v,m,l,s))}else y||(g=Kc(v,m,s));s=g?(Array.prototype.push.apply(d,g.points),g.direction):Yc(v,m),f+1<p&&d.push(m)}return d}var rd={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(!Ms(id))throw new Error("Manhattan requires the orthogonal router as default fallback.");return id(t,fs({},rd,e),n)},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function od(t){this.map={},this.options=t,this.mapGridSize=100}function ad(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function sd(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function ud(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function ld(t,e){return t.sourceAnchor?t.sourceAnchor:sd(t,e).center()}function hd(t,e,n,i,r){var o,a,s,u,l,h,c,d,f,p,g=360/n,v=t.theta((o=t,a=e,s=i,u=r.step,l=a.x-o.x,h=a.y-o.y,c=l/s.x,d=h/s.y,f=c*u,p=d*u,new si(o.x+f,o.y+p))),m=Dn(v+g/2);return g*Math.floor(m/g)}function cd(t,e){var n=Math.abs(t-e);return 180<n?360-n:n}function dd(t,e){if(!t)return e;var n=Math.abs(t),i=Math.round(n/e);return i?e+(n-i*e)/i:n}function fd(t,e){return t.round(e)}function pd(t,e,n){return fd((i=t.clone(),o=(r=e).source,a=jn(i.x-o.x,r.x)+o.x,s=jn(i.y-o.y,r.y)+o.y,new si(a,s)),n);var i,r,o,a,s}function gd(t){return t.clone().toString()}function vd(t){return new si(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function md(t,e,n,i,r,o,a){for(var s,u=[],l=vd(r.difference(n)),h=gd(n),c=t[h];c;){var d=vd((s=e[h]).difference(c));d.equals(l)||(u.unshift(s),l=d),c=t[h=gd(c)]}var f=e[h];return vd(f.difference(i)).equals(l)||u.unshift(f),u}function yd(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 bd(d,f,t,p,e){var g=e.precision,v=e.directionMap,m=d.difference(f.center()),n=hs(v)?Object.keys(v):[],y=Cs(t),i=n.reduce(function(t,e){if(y.includes(e)){for(var n,i=v[e],r=new si(d.x+i.x*(Math.abs(m.x)+f.width),d.y+i.y*(Math.abs(m.y)+f.height)),o=new ci(d,r).intersect(f)||[],a=o.length,s=null,u=0;u<a;u++){var l=o[u],h=d.squaredDistance(l);(void 0===n||n<h)&&(n=h,s=l)}if(s){var c=pd(s,p,g);f.containsPoint(c)&&(c=pd(c.offset(i.x*p.x,i.y*p.y),p,g)),t.push(c)}}return t},[]);return f.containsPoint(d)||i.push(pd(d,p,g)),i}function wd(t,e,n,i){var r,o,a,s,u=i.precision;r=fd(t instanceof Ei?ld(this,i).clone():t.clone(),u),o=fd(e instanceof Ei?(a=this,s=i,a.targetAnchor?a.targetAnchor:ud(a,s).center()).clone():e.clone(),u);var l,h,c,d,f,p,g,v,m,y,b=(l=i.step,c=o,{source:(h=r).clone(),x:dd(c.x-h.x,l),y:dd(c.y-h.y,l)});if(p=t instanceof Ei?bd(d=r,t,i.startDirections,b,i):[d=r],g=e instanceof Ei?bd(f=o,e,i.endDirections,b,i):[f=o],p=p.filter(function(t){return!n(t)}),g=g.filter(function(t){return!n(t)}),0<p.length&&0<g.length){for(var w=new ad,x={},A={},P={},T=0,E=p.length;T<E;T++){var S=p[T],k=gd(S);w.add(k,yd(S,g)),x[k]=S,P[k]=0}var M,L,C=i.previousDirectionAngle,_=void 0===C,N=i.directions;v=b,y=(m=i).step,Cs(m.directions).forEach(function(t){t.gridOffsetX=t.offsetX/y*v.x,t.gridOffsetY=t.offsetY/y*v.y});for(var O=N.length,R=Cs(g).reduce(function(t,e){var n=gd(e);return t.push(n),t},[]),F=i.maximumLoops;!w.isEmpty()&&0<F;){var B,V=w.pop(),I=x[V],D=A[V],j=P[V],z=void 0===D,G=I.equals(d);B=z?_?G?null:hd(d,I,O,b,i):C:hd(D,I,O,b,i);var U=p.length===g.length;if(U)for(var H=0;H<p.length;H++)if(!p[H].equals(g[H])){U=!1;break}if(!(z&&U)&&0<=R.indexOf(V))return i.previousDirectionAngle=B,md(A,x,I,d,f);for(T=0;T<O;T++){var q=(M=N[T]).angle;if(L=cd(B,q),_&&G||!(L>i.maxAllowedDirectionChange)){var W=pd(I.clone().offset(M.gridOffsetX,M.gridOffsetY),b,u),Y=gd(W);if(!w.isClose(Y)&&!n(W)){if(0<=R.indexOf(Y))if(!W.equals(f))if(cd(q,hd(W,f,O,b,i))>i.maxAllowedDirectionChange)continue;var X=j+M.cost+(G?0:i.penalties[L]);(!w.isOpen(Y)||X<P[Y])&&(x[Y]=W,A[Y]=I,P[Y]=X,w.add(Y,X+yd(W,g)))}}}F--}}return i.fallbackRoute.call(this,d,f,i)}function xd(t,e,n){!function(t){if(t.directions=Ds(t,"directions"),t.penalties=Ds(t,"penalties"),t.paddingBox=Ds(t,"paddingBox"),t.padding=Ds(t,"padding"),t.padding){var e=Ju(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}Cs(t.directions).forEach(function(t){var e=new si(0,0),n=new si(t.offsetX,t.offsetY);t.angle=Dn(e.theta(n))})}(e),n.options.perpendicular=!!e.perpendicular;var i,r=sd(n,e),o=ud(n,e),a=ld(n,e);if("function"==typeof e.isPointObstacle)i=e.isPointObstacle;else{var s=new od(e);s.build(n.paper.model,n.model),i=function(t){return!s.isPointAccessible(t)}}for(var u,l,h=Cs(t).map(si),c=[],d=a,f=0,p=h.length;f<=p;f++){var g=null;if(l=u||r,!(u=h[f]))if(u=o,(!n.model.get("source").id||!n.model.get("target").id)&&Ms(e.draggingRoute)){var v=l===r?a:l,m=u.origin();g=e.draggingRoute.call(n,v,m,e)}if(null===(g=g||wd.call(n,l,u,i,e)))return e.fallbackRouter(t,e,n);var y=g[0];y&&y.equals(d)&&g.shift(),d=g[g.length-1]||d,Array.prototype.push.apply(c,g)}return c}od.prototype.build=function(r,o){var c=this.options,d=Cs(c.excludeEnds).reduce(function(t,e){var n=o.get(e);if(n){var i=r.getCell(n.id);i&&t.push(i)}return t},[]),f=[],t=r.getCell(o.get("source").id);t&&(f=Vs(f,t.getAncestors().map(function(t){return t.id})));var e=r.getCell(o.get("target").id);e&&(f=Vs(f,e.getAncestors().map(function(t){return t.id})));var p=this.mapGridSize;return r.getElements().reduce(function(t,e){var n=Cs(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),a=o.origin().snapToGrid(p),s=o.corner().snapToGrid(p),u=a.x;u<=s.x;u+=p)for(var l=a.y;l<=s.y;l+=p){var h=u+"@"+l;t[h]=t[h]||[],t[h].push(o)}return t},this.map),this},od.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return Cs(this.map[t]).every(function(t){return!t.containsPoint(e)})},ad.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;var n=As(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(n,0,t)},ad.prototype.remove=function(t){this.hash[t]=this.CLOSE},ad.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},ad.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},ad.prototype.isEmpty=function(){return 0===this.items.length},ad.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};var Ad=function(t,e,n){return xd(t,fs({},rd,e),n)},Pd={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},a={x:t.x,y:e.y};if(90<i%180){var s=o;o=a,a=s}var u=i%90<45?o:a,l=new ci(t,u),h=90*Math.ceil(i/90),c=si.fromPolar(l.squaredLength(),Gn(h+135),u),d=new ci(e,c),f=l.intersection(d),p=f||e,g=f?p:t,v=360/n.directions.length,m=g.theta(e),y=Dn(m+v/2),b=v*Math.floor(y/v);return n.previousDirectionAngle=b,p&&r.push(p.round()),r.push(e),r}},Td={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Ed=[Td.LEFT,Td.RIGHT,Td.TOP,Td.BOTTOM],Sd={};Sd[Td.LEFT]=Td.RIGHT,Sd[Td.RIGHT]=Td.LEFT,Sd[Td.TOP]=Td.BOTTOM,Sd[Td.BOTTOM]=Td.TOP;var kd=[Td.TOP,Td.BOTTOM],Md={0:Td.RIGHT,180:Td.LEFT,270:Td.TOP,90:Td.BOTTOM};function Ld(t){return t.angle()}function Cd(t){return new Ci(t).simplify({threshold:1}).points}function _d(t,e){var n,i,r=t.point,o=t.x0,a=t.y0,s=t.view,u=t.bbox,l=t.direction,h=e.point,c=e.x0,d=e.y0,f=e.view,p=e.bbox,g=e.direction;if(s)n=s.model.isLink()?Od(h,r,s):l===Td.ANCHOR_SIDE?u.sideNearestToPoint(r):l===Td.MAGNET_SIDE?s.model.getBBox().sideNearestToPoint(r):l;else{var v=new Ei(o,a,0,0);n=Ed.includes(l)?l:v.sideNearestToPoint(h)}if(f)i=f.model.isLink()?Od(r,h,f):g===Td.ANCHOR_SIDE?p.sideNearestToPoint(h):g===Td.MAGNET_SIDE?f.model.getBBox().sideNearestToPoint(h):g;else{var m=new Ei(c,d,0,0);i=Ed.includes(g)?g:m.sideNearestToPoint(r)}return[n,i]}function Nd(t,e,n){var i,r,o,a,s,u,l,h,c,d,f,p,g,v,m,y,b,w,x,A,P,T,E,S,k,M,L,C,_,N,O,R,F,B,V,I,D,j,z,G,U,H,q,W,Y,X,$,Z,J,K,Q,tt,et,nt,it,rt,ot,at,st,ut,lt,ht,ct,dt,ft,pt;switch(_d(t,e)[0]){case Td.TOP:return tt=e,et=n,nt=(Q=t).x0,it=Q.y0,rt=Q.width,ot=Q.height,at=Q.point,st=Q.margin,ut=it+ot,lt=nt-st,ht=nt+rt+st,ct=it-st,dt=at.x,ft=tt.x0,pt=tt.y0,ft===dt&&pt<it?Td.BOTTOM:ft<dt&&pt<ct?et.point.x===dt?Td.BOTTOM:Td.RIGHT:dt<ft&&pt<ct?et.point.x===dt?Td.BOTTOM:Td.LEFT:ft<lt&&it<=pt?Td.TOP:ht<ft&&it<=pt?Td.TOP:lt<=ft&&ft<=dt&&ut<pt?et.point.x<ft?Td.RIGHT:Td.LEFT:ft<=ht&&dt<=ft&&ut<pt?et.point.x<ft?Td.RIGHT:Td.LEFT:Td.TOP;case Td.RIGHT:return V=e,I=n,D=(B=t).y0,j=B.x0,z=B.width,G=B.height,U=B.point,H=B.margin,W=(q=j+z)+H,Y=D-H,X=D+G+H,$=U.x,Z=U.y,J=V.x0,K=V.y0,$<J&&K===Z?Td.LEFT:W<=J&&K<Z?Td.BOTTOM:W<=J&&Z<K?Td.TOP:J<=q&&K<=Y?Td.RIGHT:J<=q&&X<=K?Td.RIGHT:J<j&&Y<=K&&K<=Z?I.point.y<K?Td.BOTTOM:Td.TOP:J<j&&K<=X&&Z<=K?I.point.y<K?Td.BOTTOM:Td.TOP:Td.RIGHT;case Td.BOTTOM:return x=e,A=n,P=(w=t).x0,T=w.y0,E=w.width,S=w.height,k=w.point,M=w.margin,C=P-M,_=P+E+M,N=(L=T+S)+M,O=k.x,R=x.x0,F=x.y0,R===O&&L<F?Td.TOP:R<O&&N<F?A.point.x===O?Td.TOP:Td.RIGHT:O<R&&N<F?A.point.x===O?Td.TOP:Td.LEFT:R<C&&F<=L?Td.BOTTOM:_<R&&F<=L?Td.BOTTOM:C<=R&&R<=O&&F<T?A.point.x<R?Td.RIGHT:Td.LEFT:R<=_&&O<=R&&F<T?A.point.x<R?Td.RIGHT:Td.LEFT:Td.BOTTOM;case Td.LEFT:return r=e,o=n,a=(i=t).y0,s=i.x0,u=i.width,l=i.height,h=i.point,c=i.margin,d=s+u,f=s-c,p=a-c,g=a+l+c,v=h.x,m=h.y,y=r.x0,b=r.y0,y<v&&b===m?Td.RIGHT:y<=f&&b<m?Td.BOTTOM:y<=f&&m<b?Td.TOP:s<=y&&b<=p?Td.LEFT:s<=y&&g<=b?Td.LEFT:d<y&&p<=b&&b<=m?o.point.y<b?Td.BOTTOM:Td.TOP:d<y&&b<=g&&m<=b?o.point.y<b?Td.BOTTOM:Td.TOP:Td.LEFT}}function Od(t,e,n){var i=n.getTangentAtLength(n.getClosestPointLength(e)),r=90*Math.round(Ld(i)/90);if(r%180==0&&t.y===e.y)return t.x<e.x?Td.LEFT:Td.RIGHT;if(t.x===e.x)return t.y<e.y?Td.TOP:Td.BOTTOM;switch(r){case 0:case 180:case 360:return t.y<e.y?Td.TOP:Td.BOTTOM;case 90:case 270:return t.x<e.x?Td.LEFT:Td.RIGHT}}function Rd(t,e,n,i,r,o,a){i===Td.AUTO&&(i=r?Td.MAGNET_SIDE:Td.ANCHOR_SIDE);var s=t&&t.model.isElement(),u=s?Ei.fromRectUnion(n,t.model.getBBox()):o,l=u.x,h=u.y,c=u.width;void 0===c&&(c=0);var d=u.height;return void 0===d&&(d=0),{point:e,x0:l,y0:h,view:t,bbox:n,width:c,height:d,direction:i,margin:s?a:0}}function Fd(t){var e=t.x,n=t.y,i=new si(e,n);return{point:i,x0:i.x,y0:i.y,view:null,bbox:new Ei(e,n,0,0),width:0,height:0,direction:null,margin:0}}function Bd(t,e,n){var i=e.point.clone(),r=e.x0,o=e.y0,a=e.width,s=e.height;switch(t){case"left":i.x=r-n;break;case"right":i.x=r+a+n;break;case"top":i.y=o-n;break;case"bottom":i.y=o+s+n}return i}function Vd(t,e,n){void 0===n&&(n={});var i=t.point,r=t.x0,o=t.y0,a=t.width,s=t.height,u=t.margin,l=e.point,h=e.x0,c=e.y0,d=e.width,f=e.height,p=e.margin,g=n.targetInSourceBBox;void 0===g&&(g=!1);var v=h+d,m=c+f,y=r+a,b=o+s,w=r-u,x=y+u,A=o-u,P=b+u,T=h-p,E=v+p,S=c-p,k=m+p,M=_d(t,e),L=M[0],C=M[1],_=Bd(L,{point:i,x0:r,y0:o,width:a,height:s},u),N=Bd(C,{point:l,x0:h,y0:c,width:d,height:f},p),O=_.x,R=_.y,F=N.x,B=N.y,V=((r+y)/2<(h+v)/2?y+h:v+r)/2,I=((o+b)/2<(c+m)/2?b+c:m+o)/2,D=new Ei(r,o,a,s),j=new Ei(h,c,d,f),z=D.clone().inflate(u),G=j.clone().inflate(p);if("left"===L&&"right"===C){if(w<=E){var U=I;return O<=T&&(A<=m&&B<R?U=Math.min(S,A):c<=P&&R<=B&&(U=Math.max(k,P))),[{x:O,y:R},{x:O,y:U},{x:F,y:U},{x:F,y:B}]}var H=(O+F)/2;return[{x:H,y:R},{x:H,y:B}]}if("right"===L&&"left"===C){if(T<=O){var q=I;return v<O&&(A<=m&&B<R?q=Math.min(S,A):c<=P&&R<=B&&(q=Math.max(k,P))),[{x:O,y:R},{x:O,y:q},{x:F,y:q},{x:F,y:B}]}var W=(O+F)/2;return[{x:W,y:R},{x:W,y:B}]}if("top"===L&&"bottom"===C){var Y=kr.rectWithRect(z,j);if(R<B){var X=V,$=R;return Y&&($=Math.min($,S)),w<=v&&F<O?X=Math.min(T,w):h<=x&&O<=F&&(X=Math.max(E,x)),[{x:O,y:$},{x:X,y:$},{x:X,y:B},{x:F,y:B}]}var Z=(R+B)/2;return[{x:O,y:Z},{x:F,y:Z}]}if("bottom"===L&&"top"===C){var J=kr.rectWithRect(z,j);if(B<R){var K=V,Q=R;return J&&(Q=Math.max(Q,k)),w<=v&&F<O?K=Math.min(T,w):h<=x&&O<=F&&(K=Math.max(E,x)),[{x:O,y:Q},{x:K,y:Q},{x:K,y:B},{x:F,y:B}]}var tt=(R+B)/2;return[{x:O,y:tt},{x:F,y:tt}]}if("top"===L&&"top"===C){var et;if(g||kr.rectWithRect(z,j)||R<=c&&(z.bottomRight().x<=F||z.bottomLeft().x>=F)||c<=R&&(G.bottomRight().x<=O||G.bottomLeft().x>=O))return[{x:O,y:Math.min(R,B)},{x:F,y:Math.min(R,B)}];var nt=Math.min((b+c)/2,B),it=Math.min((o+m)/2,R);return[{x:O,y:it},{x:et=B<R?O<F?Math.min(O,T):Math.max(O,E):O<=F?Math.max(F,x):Math.min(F,w),y:it},{x:et,y:nt},{x:F,y:nt}]}if("bottom"===L&&"bottom"===C){var rt;if(g||kr.rectWithRect(z,j)||B<=R&&(z.topRight().x<=F||z.topLeft().x>=F)||R<=B&&(G.topRight().x<=O||G.topLeft().x>=O))return[{x:O,y:Math.max(R,B)},{x:F,y:Math.max(R,B)}];var ot=Math.max((o+m)/2,B),at=Math.max((b+c)/2,R);return[{x:O,y:at},{x:rt=R<B?O<F?Math.min(O,T):Math.max(O,E):O<=F?Math.max(F,x):Math.min(F,w),y:at},{x:rt,y:ot},{x:F,y:ot}]}if("left"===L&&"left"===C){var st;if(g||kr.rectWithRect(z,j)||O<=F&&(z.bottomRight().y<=B||z.topRight().y>=B)||F<=O&&(G.bottomRight().y<=R||G.topRight().y>=R))return[{x:Math.min(O,F),y:R},{x:Math.min(O,F),y:B}];var ut=Math.min((y+h)/2,F),lt=Math.min((r+v)/2,O);return[{x:lt,y:R},{x:lt,y:st=O<F?B<=R?Math.min(A,B):Math.max(P,B):R<=B?Math.min(S,R):Math.max(k,R)},{x:ut,y:st},{x:ut,y:B}]}if("right"===L&&"right"===C){var ht;if(g||kr.rectWithRect(z,j)||F<=O&&(z.bottomLeft().y<=B||z.topLeft().y>=B)||O<=F&&(G.bottomLeft().y<=R||G.topLeft().y>=R))return[{x:Math.max(O,F),y:R},{x:Math.max(O,F),y:B}];var ct=Math.max((r+v)/2,F),dt=Math.max((y+h)/2,O);return[{x:dt,y:R},{x:dt,y:ht=F<=O?B<=R?Math.min(A,B):Math.max(P,B):R<=B?Math.min(S,R):Math.max(k,R)},{x:ct,y:ht},{x:ct,y:B}]}if("top"===L&&"right"===C){if(z.containsPoint(l)){if(O<=E){var ft=Math.max(O+u,F),pt=Math.min(A,S);return[{x:O,y:pt},{x:ft,y:pt},{x:ft,y:B}]}var gt=(O-u+F)/2;return[{x:O,y:R},{x:gt,y:R},{x:gt,y:B}]}if(B<A){if(O<F){var vt=S;return k<=A&&O<=E&&(vt=I),[{x:O,y:vt},{x:F,y:vt},{x:F,y:B}]}return[{x:O,y:B}]}var mt=Math.max(V,E);if(F<O&&B<=b)return[{x:O,y:R},{x:mt,y:R},{x:mt,y:B}];if(w<mt&&R<m){var yt=Math.min(A,S),bt=Math.max(x,E);return[{x:O,y:yt},{x:bt,y:yt},{x:bt,y:B}]}return[{x:O,y:R},{x:mt,y:R},{x:mt,y:B}]}if("top"===L&&"left"===C){if(z.containsPoint(l)){if(T<=O){var wt=Math.min(O-u,F),xt=Math.min(A,S);return[{x:O,y:xt},{x:wt,y:xt},{x:wt,y:B}]}var At=(O+u+F)/2;return[{x:O,y:R},{x:At,y:R},{x:At,y:B}]}if(B<A){if(F<O){var Pt=S;return k<=A&&T<=O&&(Pt=I),[{x:O,y:Pt},{x:F,y:Pt},{x:F,y:B}]}return[{x:O,y:B}]}var Tt=Math.min(T,V);if(O<F&&B<=b)return[{x:O,y:R},{x:Tt,y:R},{x:Tt,y:B}];if(Tt<x&&R<m){var Et=Math.min(A,S),St=Math.min(w,T);return[{x:O,y:Et},{x:St,y:Et},{x:St,y:B}]}return[{x:O,y:R},{x:Tt,y:R},{x:Tt,y:B}]}if("bottom"===L&&"right"===C){if(z.containsPoint(l)){if(O<=E){var kt=Math.max(O+u,F),Mt=Math.max(P,k);return[{x:O,y:Mt},{x:kt,y:Mt},{x:kt,y:B}]}var Lt=(O-u+F)/2;return[{x:O,y:R},{x:Lt,y:R},{x:Lt,y:B}]}if(P<B){if(O<F){var Ct=k;return P<=S&&O<=E&&(Ct=I),[{x:O,y:Ct},{x:F,y:Ct},{x:F,y:B}]}return[{x:O,y:B}]}var _t=Math.max(V,E);if(F<O&&o<=B)return[{x:O,y:R},{x:_t,y:R},{x:_t,y:B}];if(w<_t&&c<R){var Nt=Math.max(P,k),Ot=Math.max(x,E);return[{x:O,y:Nt},{x:Ot,y:Nt},{x:Ot,y:B}]}return[{x:O,y:R},{x:_t,y:R},{x:_t,y:B}]}if("bottom"===L&&"left"===C){if(z.containsPoint(l)){if(T<=O){var Rt=Math.min(O-u,F),Ft=Math.max(P,k);return[{x:O,y:Ft},{x:Rt,y:Ft},{x:Rt,y:B}]}var Bt=(O+u+F)/2;return[{x:O,y:R},{x:Bt,y:R},{x:Bt,y:B}]}if(P<B){if(F<O){var Vt=k;return P<=S&&T<=O&&(Vt=I),[{x:O,y:Vt},{x:F,y:Vt},{x:F,y:B}]}return[{x:O,y:B}]}var It=Math.min(T,V);if(O<F&&o<=B)return[{x:O,y:R},{x:It,y:R},{x:It,y:B}];if(It<x&&c<R){var Dt=Math.max(P,k),jt=Math.min(w,T);return[{x:O,y:Dt},{x:jt,y:Dt},{x:jt,y:B}]}return[{x:O,y:R},{x:It,y:R},{x:It,y:B}]}if("left"===L&&"bottom"===C){if(z.containsPoint(l)){if(R<=k){var zt=Math.min(w,T),Gt=Math.max(R+u,B);return[{x:zt,y:R},{x:zt,y:Gt},{x:F,y:Gt}]}var Ut=(R-u+B)/2;return[{x:O,y:R},{x:O,y:Ut},{x:F,y:Ut}]}if(F<w){if(R<B){var Ht=T;return E<=w&&R<=k&&(Ht=V),[{x:Ht,y:R},{x:Ht,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var qt=Math.max(k,I);if(B<R&&F<=y)return[{x:O,y:R},{x:O,y:qt},{x:F,y:qt}];if(A<qt&&O<v){var Wt=Math.min(w,T),Yt=Math.max(P,k);return[{x:Wt,y:R},{x:Wt,y:Yt},{x:F,y:Yt}]}return[{x:O,y:R},{x:O,y:qt},{x:F,y:qt}]}if("left"===L&&"top"===C){if(z.containsPoint(l)){if(S<=R){var Xt=Math.min(R-u,B),$t=Math.min(w,T);return[{x:$t,y:R},{x:$t,y:Xt},{x:F,y:Xt}]}var Zt=(R+u+B)/2;return[{x:O,y:R},{x:O,y:Zt},{x:F,y:Zt}]}if(F<w){if(B<R){var Jt=T;return E<=w&&S<=R&&(Jt=V),[{x:Jt,y:R},{x:Jt,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var Kt=Math.min(S,I);if(R<B&&F<=y)return[{x:O,y:R},{x:O,y:Kt},{x:F,y:Kt}];if(Kt<P&&O<v){var Qt=Math.min(w,T),te=Math.min(A,S);return[{x:Qt,y:R},{x:Qt,y:te},{x:F,y:te}]}return[{x:O,y:R},{x:O,y:Kt},{x:F,y:Kt}]}if("right"===L&&"top"===C){if(z.containsPoint(l)){if(S<=R){var ee=Math.max(x,E),ne=Math.min(R-u,B);return[{x:ee,y:R},{x:ee,y:ne},{x:F,y:ne}]}var ie=(R+u+B)/2;return[{x:O,y:R},{x:O,y:ie},{x:F,y:ie}]}if(x<F){if(B<R){var re=E;return x<=T&&S<=R&&(re=V),[{x:re,y:R},{x:re,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var oe=Math.min(S,I);if(R<B&&r<=F)return[{x:O,y:R},{x:O,y:oe},{x:F,y:oe}];if(oe<P&&h<O){var ae=Math.max(x,E),se=Math.min(A,S);return[{x:ae,y:R},{x:ae,y:se},{x:F,y:se}]}return[{x:O,y:R},{x:O,y:oe},{x:F,y:oe}]}if("right"===L&&"bottom"===C){if(z.containsPoint(l)){if(R<=k){var ue=Math.max(x,E),le=Math.max(R+u,B);return[{x:ue,y:R},{x:ue,y:le},{x:F,y:le}]}var he=(R-u+B)/2;return[{x:O,y:R},{x:O,y:he},{x:F,y:he}]}if(x<F){if(R<B){var ce=E;return x<=T&&R<=k&&(ce=V),[{x:ce,y:R},{x:ce,y:B},{x:F,y:B}]}return[{x:F,y:R}]}var de=Math.max(k,I);if(B<R&&r<=F)return[{x:O,y:R},{x:O,y:de},{x:F,y:de}];if(A<de&&h<O){var fe=Math.max(x,E),pe=Math.max(P,k);return[{x:fe,y:R},{x:fe,y:pe},{x:F,y:pe}]}return[{x:O,y:R},{x:O,y:de},{x:F,y:de}]}}function Id(t,e,n){var i=e.sourceDirection;void 0===i&&(i=Td.AUTO);var r=e.targetDirection;void 0===r&&(r=Td.AUTO);var o=e.margin||20,a=e.useVertices||!1,s=!!n.model.source().port,u=Rd(n.sourceView,n.sourceAnchor,n.sourceBBox,i,s,n.sourceAnchor,o),l=!!n.model.target().port,h=Rd(n.targetView,n.targetAnchor,n.targetBBox,r,l,n.targetAnchor,o),c=[];if(!a||0===t.length)return Cd(Vd(u,h));var d=t.map(function(t){return Fd(t)}),f=d[0];if(u.view&&u.view.model.isElement()&&u.view.model.getBBox().inflate(o).containsPoint(f.point)){var p=_d(u,f)[0],g=p,v=Fd(u.point);v.margin=o,v.direction=p,f.direction=g,c.push.apply(c,Vd(v,f,{targetInSourceBBox:!0}).concat([f.point]))}else{var m=Nd(u,f,d[1]||h);f.direction=m,c.push.apply(c,Vd(u,f).concat([f.point]))}for(var y=0;y<d.length-1;y++){var b=d[y],w=d[y+1],x=Ld(new ci(b.point,w.point));if(x%90!=0){var A=Dd(b,w),P=A[0],T=A[1];b.direction=P,w.direction=T,c.push.apply(c,Vd(b,w).concat([w.point]))}else{var E=Md[x],S=Sd[E];if(E!==b.direction)c.push(b.point,w.point),w.direction=S;else{var k=Dn(x-90),M=0,L=0;90===k?L=-o:180===k?M=-o:270===k?L=o:0===k&&(M=o);var C={x:b.point.x+M,y:b.point.y+L},_={x:w.point.x+M,y:w.point.y+L},N=new ci(w.point,_);w.direction=Md[Ld(N)],c.push(b.point,C,_,w.point)}}}var O=d[d.length-1];if(h.view&&h.view.model.isElement())if(h.view.model.getBBox().inflate(o).containsPoint(O.point)){var R=Dd(O,h)[0],F=Fd(h.point),B=_d(O,h)[1];F.margin=o,F.direction=B,O.direction=R,c.push.apply(c,Vd(O,F))}else{var V=Cd(c),I=new ci(V[V.length-2],O.point),D=Md[Math.round(Ld(I))];O.direction=D;var j=Vd(O,h),z=Cd(j.concat([h.point])),G=z[0],U=z[1],H=new ci(G,U),q=Math.round(Ld(H)),W=Md[q];W!==D&&D===Sd[W]&&(O.margin=o,j=Vd(O,h)),c.push.apply(c,j)}else{var Y=Dd(O,h)[0];O.direction=Y,c.push.apply(c,Vd(O,h))}return Cd(c)}function Dd(t,e){var n=t.direction,i=kd.includes(n),r=t.direction,o=e.direction;if(i){var a=t.point.y>e.point.y,s=e.point.x-t.point.x;n===Td.BOTTOM?(r=a?Sd[n]:0<=s?Td.RIGHT:Td.LEFT,0<s?o=a?Td.LEFT:Td.TOP:s<0&&(o=a?Td.RIGHT:Td.TOP)):(r=a?0<=s?Td.RIGHT:Td.LEFT:Sd[n],0<s?o=a?Td.BOTTOM:Td.LEFT:s<0&&(o=a?Td.BOTTOM:Td.RIGHT))}else{var u=t.point.x>e.point.x,l=e.point.y-t.point.y;n===Td.RIGHT?(r=u?Sd[n]:0<=l?Td.BOTTOM:Td.TOP,0<l?o=u?Td.TOP:Td.LEFT:l<0&&(o=u?Td.BOTTOM:Td.LEFT)):(r=u?0<=l?Td.BOTTOM:Td.TOP:Sd[n],0<l?o=u?Td.RIGHT:Td.TOP:l<0&&(o=u?Td.RIGHT:Td.BOTTOM))}return[r,o]}Id.Directions=Td;var jd={normal:function(t,e,n){return t},oneSide:function(t,e,n){var i,r,o,a=e.side||"bottom",s=Ju(e.padding||40),u=n.sourceBBox,l=n.targetBBox,h=u.center(),c=l.center();switch(a){case"bottom":o=1,i="y",r="height";break;case"top":o=-1,i="y",r="height";break;case"left":o=-1,i="x",r="width";break;case"right":o=1,i="x",r="width";break;default:throw new Error("Router: invalid side")}return h[i]+=o*(u[r]/2+s[a]),c[i]+=o*(l[r]/2+s[a]),0<o*(h[i]-c[i])?c[i]=h[i]:h[i]=c[i],[h].concat(t,c)},orthogonal:id,manhattan:Ad,metro:function(t,e,n){if(!Ms(Ad))throw new Error("Metro requires the manhattan router.");return Ad(t,fs({},Pd,e),n)},rightAngle:Id};function zd(a){return function(t,e,n,i){if(n instanceof Element){var r,o=this.paper.findView(n);if(o)if(o.isNodeConnection(n))r=Gd(o,"fixedAt"in i?i.fixedAt:"50%");else r=o.getNodeBBox(n).center();else r=new si;return a.call(this,t,e,r,i)}return a.apply(this,arguments)}}function Gd(t,e){var n=parseFloat(e);return zu(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}var Ud=zd(function(t,e,n,i){var r=t.getConnection(),o=t.getConnectionSubdivisions(),a=new ci(n.clone().offset(0,1e6),n.clone().offset(0,-1e6)),s=new ci(n.clone().offset(1e6,0),n.clone().offset(-1e6,0)),u=a.intersect(r,{segmentSubdivisions:o}),l=s.intersect(r,{segmentSubdivisions:o}),h=[];return u&&Array.prototype.push.apply(h,u),l&&Array.prototype.push.apply(h,l),0<h.length?n.chooseClosest(h):"fallbackAt"in i?Gd(t,i.fallbackAt):Hd(t,e,n,i)}),Hd=zd(function(t,e,n,i){var r=t.getClosestPoint(n);return r||new si}),qd={resolveRef:zd,connectionRatio:function(t,e,n,i){var r="ratio"in i?i.ratio:.5;return t.getPointAtRatio(r)},connectionLength:function(t,e,n,i){var r="length"in i?i.length:20;return t.getPointAtLength(r)},connectionPerpendicular:Ud,connectionClosest:Hd};function Wd(c){return function(t,e,n,i){var r=!!i.rotate,o=r?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),a=o[c](),s=i.dx;if(s){var u=zu(s);s=parseFloat(s),isFinite(s)&&(u&&(s/=100,s*=o.width),a.x+=s)}var l=i.dy;if(l){var h=zu(l);l=parseFloat(l),isFinite(l)&&(h&&(l/=100,l*=o.height),a.y+=l)}return r?a.rotate(t.model.getBBox().center(),-t.model.angle()):a}}var Yd={center:Wd("center"),top:Wd("topMiddle"),bottom:Wd("bottomMiddle"),left:Wd("leftMiddle"),right:Wd("rightMiddle"),topLeft:Wd("origin"),topRight:Wd("topRight"),bottomLeft:Wd("bottomLeft"),bottomRight:Wd("corner"),perpendicular:zd(function(t,e,n,i){var r=t.model.angle(),o=t.getNodeBBox(e),a=o.center(),s=o.origin(),u=o.corner(),l=i.padding;if(isFinite(l)||(l=0),s.y+l<=n.y&&n.y<=u.y-l){var h=n.y-a.y;a.x+=0===r||180===r?0:1*h/Math.tan(Gn(r)),a.y+=h}else if(s.x+l<=n.x&&n.x<=u.x-l){var c=n.x-a.x;a.y+=90===r||270===r?0:c*Math.tan(Gn(r)),a.x+=c}return a}),midSide:zd(function(t,e,n,i){var r,o,a,s=!!i.rotate;s?(r=t.getNodeUnrotatedBBox(e),a=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e);var u,l=i.padding;switch(isFinite(l)&&r.inflate(l),s&&n.rotate(a,o),r.sideNearestToPoint(n)){case"left":u=r.leftMiddle();break;case"right":u=r.rightMiddle();break;case"top":u=r.topMiddle();break;case"bottom":u=r.bottomMiddle()}return s?u.rotate(a,-o):u}),modelCenter:function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)}},Xd=ac.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace=void 0!==joint&&Is(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var n=e.collection,i=n.cellNamespace,r=t.type,o=Lu(i,r,".");if(!o)throw new Error("dia.Graph: Could not find cell constructor for type: '"+r+"'. Make sure to add the constructor to 'cellNamespace'.");var a=new o(t,e);return e.dry||(a.graph=n.graph),a},comparator:function(t){return t.get("z")||0}}),$d=bl.extend({initialize:function(t,e){var n=new Xd([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});bl.prototype.set.call(this,"cells",n),n.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},n.on("add",this._restructureOnAdd,this),n.on("remove",this._restructureOnRemove,this),n.on("reset",this._restructureOnReset,this),n.on("change:source",this._restructureOnChangeSource,this),n.on("change:target",this._restructureOnChangeTarget,this),n.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){if(t.isLink()){this._edges[t.id]=!0;var e=t.attributes,n=e.source,i=e.target;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0),i.id&&((this._in[i.id]||(this._in[i.id]={}))[t.id]=!0)}else this._nodes[t.id]=!0},_restructureOnRemove:function(t){if(t.isLink()){delete this._edges[t.id];var e=t.attributes,n=e.source,i=e.target;n.id&&this._out[n.id]&&this._out[n.id][t.id]&&delete this._out[n.id][t.id],i.id&&this._in[i.id]&&this._in[i.id][t.id]&&delete this._in[i.id][t.id]}else delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source");e.id&&this._out[e.id]&&delete this._out[e.id][t.id];var n=t.attributes.source;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target");e.id&&this._in[e.id]&&delete this._in[e.id][t.id];var n=t.get("target");n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=bl.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(!t.cells)throw new Error("Graph JSON must contain cells array.");return this.set(t,e)},set:function(t,e,n){var i;return"object"==typeof t?(i=t,n=e):(i={})[t]=e,i.hasOwnProperty("cells")&&(this.resetCells(i.cells,n),i=js(i,"cells")),bl.prototype.set.call(this,i,n)},clear:function(t){t=fs({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);for(var n=e.sortBy(function(t){return t.isLink()?1:2});n.shift().remove(t),0<n.length;);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var n;if(t instanceof bl?(n=t.attributes,t.graph||e&&e.dry||(t.graph=this)):n=t,!ds(n.type))throw new TypeError("dia.Graph: cell type must be a string.");return t},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof bl?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=Rs(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach(function(t){this.addCell(t,e),e.position--},this),this.stopBatch("add",e)),this},resetCells:function(t,e){var n=Cs(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(n,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),ws(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,n){(n=n||{}).clear||(n.disconnectLinks?this.disconnectLinks(t,n):this.removeLinks(t,n)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").toArray().filter(function(t){return t.isElement()})},getLinks:function(){return this.get("cells").toArray().filter(function(t){return t.isLink()})},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,s){var r=(s=s||{}).indirect,o=s.inbound,a=s.outbound;void 0===o&&void 0===a&&(o=a=!0);var u=[],l={};function h(i,t){if(Gs(i.getOutboundEdges(t.id),function(t,e){if(!l[e]){var n=i.getCell(e);u.push(n),l[e]=!0,r&&(o&&c(i,n),a&&h(i,n))}}.bind(i)),r&&t.isLink()){var e=t.getTargetCell();e&&e.isLink()&&(l[e.id]||(u.push(e),h(i,e)))}}function c(i,t){if(Gs(i.getInboundEdges(t.id),function(t,e){if(!l[e]){var n=i.getCell(e);u.push(n),l[e]=!0,r&&(o&&c(i,n),a&&h(i,n))}}.bind(i)),r&&t.isLink()){var e=t.getSourceCell();e&&e.isLink()&&(l[e.id]||(u.push(e),c(i,e)))}}if(a&&h(this,t),o&&c(this,t),s.deep){var e=t.getEmbeddedCells({deep:!0}),d={};e.forEach(function(t){t.isElement()&&(d[t.id]=!0)}),e.forEach(function(t){t.isLink()||(a&&Gs(this.getOutboundEdges(t.id),function(t,e){if(!l[e]){var n=this.getCell(e).attributes,i=n.source,r=n.target,o=i.id,a=r.id;if(!s.includeEnclosed&&o&&d[o]&&a&&d[a])return;u.push(this.getCell(e)),l[e]=!0}}.bind(this)),o&&Gs(this.getInboundEdges(t.id),function(t,e){if(!l[e]){var n=this.getCell(e).attributes,i=n.source,r=n.target,o=i.id,a=r.id;if(!s.includeEnclosed&&o&&d[o]&&a&&d[a])return;u.push(this.getCell(e)),l[e]=!0}}.bind(this)))},this)}return u},getNeighbors:function(u,l){l||(l={});var h=l.inbound,c=l.outbound;void 0===h&&void 0===c&&(h=c=!0);var t=this.getConnectedLinks(u,l).reduce(function(t,e){var n=e.attributes,i=n.source,r=n.target,o=e.hasLoop(l);if(h&&Is(i,"id")&&!t[i.id]){var a=this.getCell(i.id);a.isElement()&&(!o&&(!a||a===u||l.deep&&a.isEmbeddedIn(u))||(t[i.id]=a))}if(c&&Is(r,"id")&&!t[r.id]){var s=this.getCell(r.id);s.isElement()&&(!o&&(!s||s===u||l.deep&&s.isEmbeddedIn(u))||(t[r.id]=s))}return t}.bind(this),{});if(u.isLink()){if(h){var e=u.getSourceCell();e&&e.isElement()&&!t[e.id]&&(t[e.id]=e)}if(c){var n=u.getTargetCell();n&&n.isElement()&&!t[n.id]&&(t[n.id]=n)}}return Cs(t)},getCommonAncestor:function(){var t=Array.from(arguments).map(function(t){for(var e=[],n=t.get("parent");n;)e.push(n),n=this.getCell(n).get("parent");return e},this);t=t.sort(function(t,e){return t.length-e.length});var e=Cs(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)},fs({},t,{outbound:!0})),n},cloneCells:wl,cloneSubgraph:function(t,e){var n=this.getSubgraph(t,e);return this.cloneCells(n)},getSubgraph:function(t,e){e=e||{};var a=[],s={},u=[],n=[];return Cs(t).forEach(function(t){(s[t.id]||(a.push(t),(s[t.id]=t).isLink()?n.push(t):u.push(t)),e.deep)&&t.getEmbeddedCells({deep:!0}).forEach(function(t){s[t.id]||(a.push(t),(s[t.id]=t).isLink()?n.push(t):u.push(t))})}),n.forEach(function(t){var e=t.attributes,n=e.source,i=e.target;if(n.id&&!s[n.id]){var r=this.getCell(n.id);a.push(r),s[r.id]=r,u.push(r)}if(i.id&&!s[i.id]){var o=this.getCell(i.id);a.push(this.getCell(i.id)),s[o.id]=o,u.push(o)}},this),u.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var e=t.attributes,n=e.source,i=e.target;!s[t.id]&&n.id&&s[n.id]&&i.id&&s[i.id]&&(a.push(t),s[t.id]=t)})},this),a},getPredecessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},fs({},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){void 0===n&&(n={});var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var a=o.shift();if(!i[a.id]&&!(i[a.id]=!0)!==e.call(this,a,r[a.id]))for(var s=this.getNeighbors(a,n),u=0,l=s.length;u<l;u++){var h=s[u];r[h.id]=r[a.id]+1,o.push(h)}}},dfs:function(t,e,n){void 0===n&&(n={});var i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var a=o.pop();if(!i[a.id]&&!(i[a.id]=!0)!==e.call(this,a,r[a.id]))for(var s=this.getNeighbors(a,n),u=o.length,l=0,h=s.length;l<h;l++){var c=s[l];r[c.id]=r[a.id]+1,o.splice(u,0,c)}}},getSources:function(){var n=[];return Gs(this._nodes,function(t,e){this._in[e]&&!Ss(this._in[e])||n.push(this.getCell(e))}.bind(this)),n},getSinks:function(){var n=[];return Gs(this._nodes,function(t,e){this._out[e]&&!Ss(this._out[e])||n.push(this.getCell(e))}.bind(this)),n},isSource:function(t){return!this._in[t.id]||Ss(this._in[t.id])},isSink:function(t){return!this._out[t.id]||Ss(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,r,e){var o=(e=e||{}).inbound,a=e.outbound;void 0===o&&void 0===a&&(o=a=!0);var s=!1;return this.getConnectedLinks(t,e).forEach(function(t){var e=t.attributes,n=e.source,i=e.target;return o&&Is(n,"id")&&n.id===r.id?!(s=!0):a&&Is(i,"id")&&i.id===r.id?!(s=!0):void 0}),s},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){ws(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(e){return this.getElements().filter(function(t){return t.getBBox({rotate:!0}).containsPoint(e)})},findModelsInArea:function(t,e){void 0===e&&(e={});var n=new Ei(t),i=e.strict;void 0===i&&(i=!1);var r=i?"containsRect":"intersect";return this.getElements().filter(function(t){return n[r](t.getBBox({rotate:!0}))})},findModelsUnderElement:function(e,t){void 0===t&&(t={});var n=t.searchBy;void 0===n&&(n="bbox");var i=e.getBBox().rotateAroundCenter(e.angle());return("bbox"===n?this.findModelsInArea(i):this.findModelsFromPoint(Zl(i,n))).filter(function(t){return e.id!==t.id&&!t.isEmbeddedIn(e)})},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e){void 0===e&&(e={});var i=e.rotate;return void 0===i&&(i=!0),Cs(t).reduce(function(t,e){var n=e.getBBox({rotate:i});return n?t?t.union(n):n:t},null)},translate:function(t,e,n){var i=this.getCells().filter(function(t){return!t.isEmbedded()});return ws(i,"translate",t,e,n),this},resize:function(t,e,n){return this.resizeCells(t,e,this.getCells(),n)},resizeCells:function(t,e,n,i){var r=this.getCellsBBox(n);if(r){var o=Math.max(t/r.width,0),a=Math.max(e/r.height,0);ws(n,"scale",o,a,r.origin(),i)}return this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",fs({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",fs({},e,{batchName:t}))},hasActiveBatch:function(t){var e=this._batches;return(0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t]).some(function(t){return 0<e[t]})}},{validations:{multiLinks:function(t,e){var n=e.attributes,r=n.source,o=n.target;if(r.id&&o.id){var i=e.getSourceCell();if(i)if(1<t.getConnectedLinks(i,{outbound:!0}).filter(function(t){var e=t.attributes,n=e.source,i=e.target;return n&&n.id===r.id&&(!n.port||n.port===r.port)&&i&&i.id===o.id&&(!i.port||i.port===o.port)}).length)return!1}return!0},linkPinning:function(t,e){var n=e.attributes,i=n.source,r=n.target;return i.id&&r.id}}});Yl($d.prototype,["resetCells","addCells","removeCells"],Xl.cells);var Zd={GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"},Jd=rc.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return Su(this.options.name+"-layer")},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(t){var e=this.el,n=this.pivotNodes;(t=+t)||(t=0);var i=n[t];if(i)return i;i=n[t]=document.createComment("z-index:"+(t+1));var r=-1/0;for(var o in n)(o=+o)<t&&r<o&&(r=o);if(r!==-1/0){var a=n[r];e.insertBefore(i,a.nextSibling)}else e.insertBefore(i,e.firstChild);return i},removePivots:function(){var t=this.el,e=this.pivotNodes;for(var n in e)t.removeChild(e[n]);this.pivotNodes={}}}),Kd=["transform","x","y","cx","cy","dx","dy","x1","y1","x2","y2","points","d","r","rx","ry","width","height","stroke-width","font-size"].reduce(function(t,e){return t[e]=!0,t},{}),Qd=["r","rx","ry","width","height","stroke-width","font-size"].reduce(function(t,e){return t[e]=!0,t},{});function tf(t,e){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=ef(i,t[i],e));return n}function ef(t,e,n){if(t in Kd&&Nn(e)){var i=Fn(e,n);return t in Qd&&(i=Math.max(0,i)),i}return e}var nf={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},rf=rc.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={},r={},o=0,a=Ds(this,"presentationAttributes");for(var s in a)if(a.hasOwnProperty(s)){var u=a[s];for(Array.isArray(u)||(u=[u]),t=0,e=u.length;t<e;t++){var l=i[n=u[t]];l||(l=i[n]=1<<o++),r[s]|=l}}var h=Ds(this,"initFlag");for(Array.isArray(h)||(h=[h]),t=0,e=h.length;t<e;t++)i[n=h[t]]||(i[n]=1<<o++);if(25<o)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=i,this._presentationAttributes=r},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var n=0;if(Array.isArray(t))for(var i=0,r=t.length;i<r;i++)n|=e[t[i]];else n|=e[t];return n},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||Fu(this),rc.call(this,t)},initialize:function(){this.setFlags(),rc.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){var n=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&n&&(e.dirty&&this.hasFlag(n,"UPDATE")&&(n|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(n,e))},requestUpdate:function(t,e){var n=this.paper;n&&0<t&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n=ku(t),i=n.selectors,r=n.groupSelectors;for(var o in r){if(i[o])throw new Error("dia.CellView: ambiguous group selector");i[o]=r[o]}if(e){var a=this.selector;if(i[a])throw new Error("dia.CellView: ambiguous root selector.");i[a]=e}return{fragment:n.fragment,selectors:i}},can:function(t){var e=Ms(this.options.interactive)?this.options.interactive(this):this.options.interactive;return hs(e)&&!1!==e[t]||ls(e)&&!1!==e},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){var i=n[t];if(i)return Array.isArray(i)?i:[i]}return this.useCSSSelectors?iu(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){var e=this.findNodes(t)[0];return void 0===e&&(e=null),e},notify:function(t){if(this.paper){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e))}},getBBox:function(t){var e;if(t&&t.useModelGeometry){var n=this.model;e=n.getBBox().bbox(n.angle())}else e=this.getNodeBBox(this.el);return this.paper.localToPaperRect(e)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),i=this.getNodeMatrix(t);return su.transformRect(e,n.multiply(i))},getNodeRotateMatrix:function(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():su.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return su.transformRect(e,i.multiply(n))},getRootTranslateMatrix:function(){var t=this.model.position();return su.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t=su.createSVGMatrix(),e=this.model,n=e.angle();if(n){var i=e.getBBox(),r=i.width/2,o=i.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t},_notifyHighlight:function(t,e,n){void 0===n&&(n={});var i,r=this.el;if(i="string"==typeof e?this.findNode(e)||r:void 0===(i=this.$(e)[0])?r:i,n.partial=i!==r,void 0===n.type){var o;switch(!0){case n.embedding:o=nf.EMBEDDING;break;case n.connecting:o=nf.CONNECTING;break;case n.magnetAvailability:o=nf.MAGNET_AVAILABILITY;break;case n.elementAvailability:o=nf.ELEMENT_AVAILABILITY;break;default:o=nf.DEFAULT}n.type=o}return this.notify(t,i,n),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e){return void 0===e&&(e={}),this._notifyHighlight("cell:unhighlight",t,e)},findMagnet:function(t){var e=this.el,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;n=n.parentNode}while(n)},findProxyNode:function(t,e){t||(t=this.el);var n=t.getAttribute(e+"-selector");if(n){var i=this.findNode(n);if(i)return i}return t},getSelector:function(t,e){var n;if(t===this.el)return"string"==typeof e&&(n=":scope > "+e),n;if(t){var i=su(t).index()+1;n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)}return n},addLinkFromMagnet:function(t,e,n){var i=this.paper,r=i.model,o=i.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,n,o,"source"),target:{x:e,y:n}}).addTo(r,{async:!1,ui:!0}),o.findView(i)},getLinkEnd:function(t){for(var e,n=[],i=arguments.length-1;0<i--;)n[i]=arguments[i+1];var r=this.model,o=r.id,a=this.findAttributeNode("port",t),s=t.getAttribute("joint-selector"),u={id:o};if(null!=s&&(u.magnet=s),null!=a){var l=a.getAttribute("port");"number"===a.getAttribute("port-id-type")&&(l=parseInt(l,10)),u.port=l,r.hasPort(l)||s||(u.selector=this.getSelector(t))}else null==s&&this.el!==t&&(u.selector=this.getSelector(t));return(e=this).customizeLinkEnd.apply(e,[u,t].concat(n))},customizeLinkEnd:function(t,e,n,i,r,o){var a=this.paper,s=a.options.connectionStrategy;if("function"==typeof s){var u=s.call(a,t,this,e,new si(n,i),r,o,a);if(u)return u}return t},getMagnetFromLinkEnd:function(t){var e,n=t.port,i=t.magnet,r=this.model;return e=null!=n&&r.isElement()&&r.hasPort(n)?this.findPortNode(n,i)||this.el:(i||(i=t.selector),i||null==n||(i='[port="'+n+'"]'),this.findNode(i)),this.findProxyNode(e,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");var r=this.addLinkFromMagnet(e,n,i);r.notifyPointerdown(t,n,i),r.eventData(t,r.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:r})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var o=this.paper,a=o.options.magnetThreshold,s=this.getEventTarget(t),u=i.targetMagnet;if("onleave"===a){if(u===s||su(u).contains(s))return}else if(o.eventData(t).mousemoved<=a)return;this.dragLinkStart(t,u,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){Ss(e)||(t instanceof SVGElement?su(t).attr(e):iu(t).attr(e))},processNodeAttributes:function(t,e){var n,i,r,o,a,s,u,l,h,c=[],d={};for(n in e)e.hasOwnProperty(n)&&(d[su.attributeNames[n]]=e[n]);for(n in d)d.hasOwnProperty(n)&&(i=d[n],!(r=this.getAttributeDefinition(n))||Ms(r.qualify)&&!r.qualify.call(this,i,t,d,this)?(s||(s={}),s[n]=i):(ds(r.set)&&(s||(s={}),s[r.set]=i),null!==i&&c.push(n,r)));for(o=0,a=c.length;o<a;o+=2)n=c[o],r=c[o+1],i=e[n],Ms(r.set)&&(u||(u={}),u[n]=i),Ms(r.position)&&(l||(l={}),l[n]=i),Ms(r.offset)&&(h||(h={}),h[n]=i);return{raw:d,normal:s,set:u,position:l,offset:h}},updateRelativeAttributes:function(t,e,n,i){var r,o;i||(i={});var a=tf(e.raw||{},n),s=e.normal||{};for(var u in s)s[u]=a[u];var l=e.set,h=e.position,c=e.offset;for(r in l){o=a[r];var d=this.getAttributeDefinition(r).set.call(this,o,n.clone(),t,a,this);hs(d)?fs(s,d):void 0!==d&&(s[r]=d)}if(t instanceof HTMLElement)this.setNodeAttributes(t,s);else{var f,p,g,v=s.transform,m=su.transformStringToMatrix(v),y=si(m.e,m.f);if(v&&(s=js(s,"transform"),m.e=m.f=0),h||c){var b=this.getNodeScale(t,i.scalableNode);f=b.sx,p=b.sy}var w=!1;for(r in h)o=a[r],(g=this.getAttributeDefinition(r).position.call(this,o,n.clone(),t,a,this))&&(y.offset(si(g).scale(f,p)),w||(w=!0));this.setNodeAttributes(t,s);var x=!1;if(c){var A=this.getNodeBoundingRect(t);if(0<A.width&&0<A.height){var P=su.transformRect(A,m).scale(1/f,1/p);for(r in c)o=a[r],(g=this.getAttributeDefinition(r).offset.call(this,o,P,t,a,this))&&(y.offset(si(g).scale(f,p)),x||(x=!0))}}(void 0!==v||w||x)&&(y.round(1),m.e=y.x,m.f=y.y,t.setAttribute("transform",su.matrixToTransformString(m)))}},getNodeScale:function(t,e){var n,i;if(e&&e.contains(t)){var r=e.scale();n=1/r.sx,i=1/r.sy}else i=n=1;return{sx:n,sy:i}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};var n=su.ensureId(t),i=e[n];return i||(i=e[n]={}),i},getNodeData:function(t){var e=this.nodeCache(t);return e.data||(e.data={}),e.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=su(t).getBBox()),new Ei(e.boundingRect)},getNodeMatrix:function(t){var e=this.nodeCache(t);if(void 0===e.magnetMatrix){var n,i=this.rotatableNode,r=this.el;n=i&&i.contains(t)?i:r,e.magnetMatrix=su(t).getTransformToElement(n)}return su.createSVGMatrix(e.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=su(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,a,s,u={},l=[];for(var h in t)if(t.hasOwnProperty(h)&&(a=t[h],Ls(a))){var c=n[h]=this.findBySelector(h,e,i);for(r=0,o=c.length;r<o;r++){var d=c[r];s=su.ensureId(d);var f=i&&i[h]===d,p=u[s];if(p){p.array||(l.push(s),p.array=!0,p.attributes=[p.attributes],p.selectedLength=[p.selectedLength]);var g=p.attributes,v=p.selectedLength;if(f)g.unshift(a),v.unshift(-1);else{var m=As(v,o);g.splice(m,0,a),v.splice(m,0,o)}}else u[s]={attributes:a,selectedLength:f?-1:o,node:d,array:!1}}}for(r=0,o=l.length;r<o;r++)(a=u[s=l[r]]).attributes=Ws.apply(void 0,[{}].concat(a.attributes.reverse()));return u},getEventTarget:function(t,e){void 0===e&&(e={});var n=t.target,i=t.type,r=t.clientX;void 0===r&&(r=0);var o=t.clientY;return void 0===o&&(o=0),e.fromPoint||"touchmove"===i||"touchend"===i||"pointerId"in t&&n.hasPointerCapture(t.pointerId)?document.elementFromPoint(r,o):n},updateDOMSubtreeAttributes:function(t,e,n){n||(n={}),n.rootBBox||(n.rootBBox=Ei()),n.selectors||(n.selectors=this.selectors);var i,r,o,a,s,u={},l={},h=[],c=[],d=n.roAttributes,f=this.findNodesAttributes(d||e,t,u,n.selectors),p=d?this.findNodesAttributes(e,t,u,n.selectors):f;for(var g in f)if(o=(a=f[g]).attributes,r=a.node,(s=this.processNodeAttributes(r,o)).set||s.position||s.offset||s.raw.ref){var v,m=p[g]&&p[g].attributes,y=m&&void 0===o.ref?m.ref:o.ref;if(y){if(!(v=(u[y]||this.findBySelector(y,t,n.selectors))[0]))throw new Error('dia.CellView: "'+y+'" reference does not exist.')}else v=null;if(i={node:r,refNode:v,processedAttributes:s,allAttributes:m},v){var b=c.findIndex(function(t){return t.refNode===r});-1<b?c.splice(b,0,i):c.push(i)}else h.push(i)}else this.setNodeAttributes(r,tf(s.normal,n.rootBBox));h.push.apply(h,c);for(var w=0,x=h.length;w<x;w++){i=h[w],r=i.node;var A=(v=i.refNode)?su.ensureId(v):"",P=l[A];P||(P=l[A]=v?su(v).getBBox({target:of(r,v)}):n.rootBBox),d?(s=this.processNodeAttributes(r,i.allAttributes),this.mergeProcessedAttributes(s,i.processedAttributes)):s=i.processedAttributes,this.updateRelativeAttributes(r,s,P,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),fs(t.set,e.set),fs(t.position,e.position),fs(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:function(t){t||(this.mountTools(),xc.mount(this))},onDetach:function(){this.unmountTools(),xc.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:function(){var t=this._toolsView;return t&&t.unmount(),this},mountTools:function(){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(){xc.remove(this)},updateHighlighters:function(t){void 0===t&&(t=!1),xc.update(this,null,t)},transformHighlighters:function(){xc.transform(this)},preventDefaultInteraction:function(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented:function(t){var e=this.eventData(t).defaultInteractionPrevented;return void 0===e&&(e=!1),e},pointerdblclick:function(t,e,n){this.notify("cell:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){this.notify("cell:pointerclick",t,e,n)},contextmenu:function(t,e,n){this.notify("cell:contextmenu",t,e,n)},pointerdown:function(t,e,n){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:function(t){var e=this.paper,n=this.model;if(e.isAsync()){if(n.isLink()){var i=n.getSourceElement();if(i){var r=e.findViewByModel(i);r&&(e.dumpView(r),e.checkViewVisibility(r))}var o=n.getTargetElement();if(o){var a=e.findViewByModel(o);a&&(e.dumpView(a),e.checkViewVisibility(a))}}e.dumpView(this),e.checkViewVisibility(this)}var s=this.getEventTarget(t,{fromPoint:!0}),u=e.findView(s);u!==this&&(this.mouseleave(t),u&&u.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Flags:{TOOLS:"TOOLS"},Highlighting:nf,addPresentationAttributes:function(t){return Ws({},Ds(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)?Ps(t.concat(e)):void 0})},evalAttribute:ef});function of(t,e){var n=t;do{if(n.contains(e))return n;n=n.parentNode}while(n);return null}Object.defineProperty(rf.prototype,"useCSSSelectors",{get:function(){var t=this.model.useCSSSelectors;return void 0!==t?t:xu.useCSSSelectors}});var af={TOOLS:rf.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},sf="move",uf="magnet",lf=rf.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=rf.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){rf.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[af.UPDATE],position:[af.TRANSLATE,af.TOOLS],size:[af.RESIZE,af.PORTS,af.TOOLS],angle:[af.ROTATE,af.TOOLS],markup:[af.RENDER],ports:[af.PORTS]},initFlag:[af.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){var n=this.useCSSSelectors;this.hasFlag(t,af.PORTS)&&(this._removePorts(),this._cleanPortsCache());var i=!1;if(this.hasFlag(t,af.RENDER))this.render(),this.updateTools(e),this.updateHighlighters(!0),i=!0,t=this.removeFlag(t,[af.RENDER,af.UPDATE,af.RESIZE,af.TRANSLATE,af.ROTATE,af.PORTS,af.TOOLS]);else{var r=!1;this.hasFlag(t,af.RESIZE)&&(this.resize(e),r=!0,t=this.removeFlag(t,[af.RESIZE,af.UPDATE]),n&&(t=this.removeFlag(t,af.PORTS))),this.hasFlag(t,af.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,af.UPDATE),r=!0,n&&(t=this.removeFlag(t,af.PORTS))),this.hasFlag(t,af.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,af.TRANSLATE),i=!0),this.hasFlag(t,af.ROTATE)&&(this.rotate(),t=this.removeFlag(t,af.ROTATE),i=!0),this.hasFlag(t,af.PORTS)&&(this._renderPorts(),r=!0,t=this.removeFlag(t,af.PORTS)),r&&this.updateHighlighters(!1)}return i&&this.transformHighlighters(),this.hasFlag(t,af.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,af.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var n=this.useCSSSelectors;n&&this._removePorts();var i=this.model,r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new Ei(i.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),n&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.ElementView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el),n=this.selectors=e.selectors;this.rotatableNode=su(n[this.rotatableSelector])||null,this.scalableNode=su(n[this.scalableSelector])||null,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(su(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),this.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;var n=t.size;return"rotate("+e+","+n.width/2+","+n.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,n=e.angle(),i=e.size(),r=this.scalableNode,o=!1;0<r.node.getElementsByTagName("path").length&&(o=!0);var a=r.getBBox({recursive:o}),s=i.width/(a.width||1),u=i.height/(a.height||1);r.attr("transform","scale("+s+","+u+")");var l=this.rotatableNode,h=l&&l.attr("transform");if(h){l.attr("transform",h+" rotate("+-n+","+i.width/2+","+i.height/2+")");var c=r.getBBox({target:this.paper.cells});e.set("position",{x:c.x,y:c.y},fs({updateHandled:!0},t)),this.translate(),this.rotate()}this.update()},prepareEmbedding:function(t){void 0===t&&(t={});var e=t.model||this.model,n=(t.paper||this.paper).model,i=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=n.getConnectedLinks(e,{deep:!0,includeEnclosed:!0});[e].concat(r,o).forEach(function(t){return i[t.id]=t.attributes.z}),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0});var a=n.getElements().reduce(function(t,e){return Math.max(t,e.attributes.z||0)},0);o.forEach(function(t){t.attributes.z<=a&&t.set("z",a+1,{ui:!0})}),e.stopBatch("to-front");var s=e.parent();s?(n.getCell(s).unembed(e,{ui:!0}),t.initialParentId=s):t.initialParentId=null},processEmbedding:function(t,e,n,i){void 0===t&&(t={});var r,o=t.model||this.model,a=t.paper||this.paper,s=a.model,u=a.options,l=u.findParentBy,h=u.frontParentOnly,c=u.validateEmbedding;r=(r=Ms(l)?Cs(l.call(s,this,e,n,i)):"pointer"===l?Cs(s.findModelsFromPoint({x:n,y:i})):s.findModelsUnderElement(o,{searchBy:l})).filter(function(t){return t instanceof Wl&&o.id!==t.id&&!t.isEmbeddedIn(o)}),h&&(r=r.slice(-1));for(var d=null,f=t.candidateEmbedView,p=r.length-1;0<=p;p--){var g=r[p];if(f&&f.model.id==g.id){d=f;break}var v=g.findView(a);if(!Ms(c)||c.call(a,this,v)){d=v;break}}d&&d!=f&&(this.clearEmbedding(t),t.candidateEmbedView=d.highlight(d.findProxyNode(null,"container"),{embedding:!0})),!d&&f&&this.clearEmbedding(t)},clearEmbedding:function(t){t||(t={});var e=t.candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t){void 0===t&&(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 r=i.options.validateUnembedding;if(t.initialParentId&&"function"==typeof r&&!r.call(i,this))return void this._disallowUnembed(t)}i.model.getConnectedLinks(n,{deep:!0}).forEach(function(t){t.reparent({ui:!0})})},_disallowUnembed:function(t){var e=t.model,n=t.whenNotAllowed;void 0===n&&(n="revert");var i=e||this.model,r=(t.paper||this.paper).model;switch(n){case"remove":i.remove({ui:!0});break;case"revert":var o=t.initialParentId,a=t.initialPosition,s=t.initialZIndices;if(a){var u=a.x,l=a.y;i.position(u,l,{deep:!0,ui:!0})}s&&Object.keys(s).forEach(function(t){var e=r.getCell(t);e&&e.set("z",s[t],{ui:!0})});var h=r.getCell(o);h&&h.embed(i,{ui:!0})}},getDelegatedView:function(){for(var t=this,e=t.model,n=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=n.findViewByModel(e)}return null},findProxyNode:function(t,e){t||(t=this.el);var n=t.getAttribute(e+"-selector");if(n){var i=this.findAttribute("port",t);if(i){var r=this.findPortNode(i,n);if(r)return r}else{var o=this.findNode(n);if(o)return o}}return t},notifyPointerdown:function(t,e,n){rf.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove:function(t,e,n){rf.prototype.pointermove.call(this,t,e,n),this.notify("element:pointermove",t,e,n)},notifyPointerup:function(t,e,n){this.notify("element:pointerup",t,e,n),rf.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){rf.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){rf.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){rf.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),r=i.targetMagnet,o=i.action,a=i.delegatedView;switch(r&&this.magnetpointermove(t,r,e,n),o){case uf:this.dragMagnet(t,e,n);break;case sf:(a||this).drag(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){var i=this.eventData(t),r=i.targetMagnet,o=i.action,a=i.delegatedView;switch(r&&this.magnetpointerup(t,r,e,n),o){case uf:this.dragMagnetEnd(t,e,n);break;case sf:(a||this).dragEnd(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){rf.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){rf.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){rf.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){rf.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){rf.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){if(!this.isDefaultInteractionPrevented(t)){var i=this.getDelegatedView();if(i&&i.can("elementMove")){this.eventData(t,{action:sf,delegatedView:i});var 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=this.paper,r=t.isPropagationStopped();if(r&&this.eventData(t,{preventPointerEvents:!0}),!this.isDefaultInteractionPrevented(t)&&this.can("addLinkFromMagnet")){var o=this.eventData(t).targetMagnet;void 0===o&&(o=t.currentTarget),t.stopPropagation(),i.options.validateMagnet.call(i,this,o,t)?(i.options.magnetThreshold<=0&&this.dragLinkStart(t,o,e,n),this.eventData(t,{action:uf})):r?this.dragStart(t,e,n):this.pointerdown(t,e,n)}},drag:function(t,e,n){var i=this.paper,r=i.options.gridSize,o=this.model,a=this.eventData(t),s=a.pointerOffset,u=a.restrictedArea,l=a.embedding,h=jn(e+s.x,r),c=jn(n+s.y,r);o.position(h,c,{restrictedArea:u,deep:!0,ui:!0}),i.options.embeddingMode&&(l||(this.prepareEmbedding(a),l=!0),this.processEmbedding(a,t,e,n)),this.eventData(t,{embedding:l})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){var i=this.eventData(t);i.embedding&&this.finalizeEmbedding(i)},dragMagnetEnd:function(t,e,n){this.dragLinkEnd(t,e,n)},magnetpointerclick:function(t,e,n,i){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,n,i)}},{Flags:af});fs(lf.prototype,dh);var hf={TOOLS:rf.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},cf=rf.extend({className:function(){var t=rf.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(){rf.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[hf.RENDER],attrs:[hf.UPDATE],router:[hf.UPDATE],connector:[hf.CONNECTOR],labels:[hf.LABELS],labelMarkup:[hf.LABELS],vertices:[hf.UPDATE],source:[hf.SOURCE,hf.UPDATE],target:[hf.TARGET,hf.UPDATE]},initFlag:[hf.RENDER,hf.SOURCE,hf.TARGET,hf.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e||(e={}),this.hasFlag(t,hf.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,hf.SOURCE)}if(this.hasFlag(t,hf.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,hf.TARGET)}var n=this.paper,i=this.sourceView,r=this.targetView;if(n&&(i&&!n.isViewMounted(i)||r&&!n.isViewMounted(r)))return t;if(this.hasFlag(t,hf.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),t=this.removeFlag(t,[hf.RENDER,hf.UPDATE,hf.LABELS,hf.TOOLS,hf.CONNECTOR]);var o=!1,a=this.model,s=a.attributes,u=this.hasFlag(t,hf.LABELS);u&&(this.onLabelsChange(a,s.labels,e),t=this.removeFlag(t,hf.LABELS),o=!0);var l=this.hasFlag(t,hf.UPDATE),h=this.hasFlag(t,hf.CONNECTOR);return(l||h)&&(l?e.translateBy&&a.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[hf.UPDATE,hf.TOOLS,hf.CONNECTOR]),o=!(u=!1)),u&&this.updateLabelPositions(),o&&this.updateHighlighters(),this.hasFlag(t,hf.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,hf.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(hf.UPDATE),t)},isLabelsRenderRequired:function(t){void 0===t&&(t={});var e=this.model.previous("labels");if(!e)return!0;if("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,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.LinkView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el);this.selectors=e.selectors,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=su(t);Array.isArray(e)||(e=[e]),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=su(t),n=document.createDocumentFragment();if(Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var o=e[i].node;n.appendChild(o)}else n.appendChild(e.node);return{fragment:n,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e,n=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=n.childNodes;return(e=1<i.length||"G"!==i[0].nodeName.toUpperCase()?su("g").append(n):su(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,n=this._labelCache={},i=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],a=o.length;if(0===a)return e&&e.remove(),this;e?e.empty():(e=t.labels=su("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(Su(Ds(this,"className"))),e.attr("model-id",r.id)));for(var s=0;s<a;s++){var u,l,h=o[s],c=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup));if(c)u=c.node,l=c.selectors;else{var d=r._builtins.defaultLabel,f=this._normalizeLabelMarkup(this._getLabelMarkup(d.markup)),p=r._getDefaultLabel(),g=this._normalizeLabelMarkup(this._getLabelMarkup(p.markup))||f;u=g.node,l=g.selectors}u.setAttribute("label-idx",s),e.append(u),n[s]=u;var v=this.selector;if(l[v])throw new Error("dia.LinkView: ambiguous label root selector.");l[v]=u,i[s]=l}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){var t=this.el,e=this.paper,n=this.model,i=this._V,r=this.options,o=i.labels;if(o&&n.hasLabels()){var a=o.node;r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(a,n.get("z")):a.parentNode!==t&&t.appendChild(a)}},unmountLabels:function(){var t=this.options,e=this._V;if(e){var n=e.labels;n&&t.labelsLayer&&n.remove()}},findLabelNodes:function(t,e){var n=this._labelCache[t];if(!n)return[];var i=this._labelSelectors[t];return this.findBySelector(e,n,i)},findLabelNode:function(t,e){var n=this.findLabelNodes(t,e)[0];return void 0===n&&(n=null),n},_mergeLabelAttrs:function(t,e,n,i){return null===e?null:void 0!==e?t?Ws({},n,e):Ws({},i,n,e):null===n?null:void 0!==n?t?n:Ws({},i,n):t?void 0:i},_mergeLabelSize:function(t,e){return null===t?null:void 0!==t?Ws({},e,t):null===e?null:void 0!==e?e:void 0},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,r=t._getDefaultLabel(),o=r.markup,a=r.attrs,s=r.size,u=0,l=e.length;u<l;u++){var h=this._labelCache[u];h.setAttribute("cursor",n?"move":"default");var c=this._labelSelectors[u],d=e[u],f=d.markup,p=d.attrs,g=d.size,v=this._mergeLabelAttrs(f||o,p,a,i),m=this._mergeLabelSize(g,s);this.updateDOMSubtreeAttributes(h,v,{rootBBox:new Ei(m),selectors:c})}return this},removeRedundantLinearVertices:function(t){var e=this.model,n=e.vertices(),i=[this.sourceAnchor].concat(n,[this.targetAnchor]),r=i.length,o=new Ci(i);o.simplify({threshold:.001});var a=o.points.map(function(t){return t.toJSON()}),s=a.length;return r===s?0:(e.vertices(a.slice(1,s-1),t),r-s)},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 si(this.sourceAnchor);case"target":return new si(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new si(this.sourcePoint);case"target":return new si(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(!e)break;return this.sourceMagnet||e.el;case"target":var n=this.targetView;if(!n)break;return this.targetMagnet||n.el;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0);var n=this.route,i=this.path;if(n&&i){var r=new Ci(n);r.translate(t,e),this.route=r.points,this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e),i.translate(t,e),this.updateDOM()}},updateDOM:function(){var t=this.el,e=this.model,n=this.selectors;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){var t=this.model.vertices(),e=this.findAnchors(t),n=this.sourceAnchor=e.source,i=this.targetAnchor=e.target,r=this.findRoute(t);this.route=r;var o=this.findConnectionPoints(r,n,i);this.sourcePoint=o.source,this.targetPoint=o.target},updatePath:function(){var t=this.route,e=this.sourcePoint,n=this.targetPoint,i=this.findPath(t,e.clone(),n.clone());this.path=i},findAnchorsOrdered:function(t,e,n,i){var r,o,a,s,u=this.model,l=u.get(t),h=u.get(n),c=this.getEndView(t),d=this.getEndView(n),f=this.getEndMagnet(t),p=this.getEndMagnet(n);r=c?(a=e?new si(e):d?p:new si(h),this.getAnchor(l.anchor,c,f,a,t)):new si(l),o=d?(s=new si(i||r),this.getAnchor(h.anchor,d,p,s,n)):new si(h);var g={};return g[t]=r,g[n]=o,g},findAnchors:function(t){var e=this.model,n=t[0],i=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",i,"source",n):this.findAnchorsOrdered("source",n,"target",i)},findConnectionPoints:function(t,e,n){var i,r,o,a,s=t[0],u=t[t.length-1],l=this.model,h=l.get("source"),c=l.get("target"),d=this.sourceView,f=this.targetView,p=this.paper.options;if(d&&!d.isNodeConnection(this.sourceMagnet)){i=this.sourceMagnet||d.el;var g=h.connectionPoint||p.defaultConnectionPoint,v=new ci(s||n,e);o=this.getConnectionPoint(g,d,i,v,"source")}else o=e;if(f&&!f.isNodeConnection(this.targetMagnet)){r=this.targetMagnet||f.el;var m=c.connectionPoint||p.defaultConnectionPoint,y=new ci(u||e,n);a=this.getConnectionPoint(m,f,r,y,"target")}else a=n;return{source:o,target:a}},getAnchor:function(t,e,n,i,r){var o,a=e.isNodeConnection(n),s=this.paper.options;if(t||(t=a?s.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor),!t)throw new Error("Anchor required.");if("function"==typeof t)o=t;else{var u=t.name;if("function"!=typeof(o=s[a?"linkAnchorNamespace":"anchorNamespace"][u]))throw new Error("Unknown anchor: "+u)}var l=o.call(this,e,n,i,t.args||{},r,this);return l?l.round(this.decimalsRounding):new si},getConnectionPoint:function(t,e,n,i,r){var o,a,s=i.end,u=this.paper.options;if(!t)return s;if("function"==typeof t)a=t;else{var l=t.name;if("function"!=typeof(a=u.connectionPointNamespace[l]))throw new Error("Unknown connection point: "+l)}return(o=a.call(this,i,e,n,t.args||{},r,this))?o.round(this.decimalsRounding):s},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,n=t._getDefaultLabel(),i=this._normalizeLabelPosition(n.position);return Ws({},e,i)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},_mergeLabelPositionProperty:function(t,e){return null===t?null:void 0===t?null===e?null:e:Ws({},e,t)},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model.get("labels")||[];if(!t.length)return this;for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r=this._labelCache[n];if(r){var o=t[n],a=this._normalizeLabelPosition(o.position),s=this._mergeLabelPositionProperty(a,e),u=this._getLabelTransformationMatrix(s);r.setAttribute("transform",su.matrixToTransformString(u)),this._cleanLabelMatrices(n)}}return this},_cleanLabelMatrices:function(t){var e=this.metrics,n=this._labelSelectors[t];if(n)for(var i in n){var r=n[i].id;r&&r in e&&delete e[r].magnetMatrix}},updateEndProperties:function(t){var e=this.model,n=this.paper,i=t+"View",r=e.get(t),o=r&&r.id;if(!o)return this[i]=null,this.updateEndMagnet(t),!0;var a=n.getModelById(o);if(!a)throw new Error("LinkView: invalid "+t+" cell.");var s=a.findView(n);return!!s&&(this[i]=s,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){var e=t+"Magnet",n=this.getEndView(t);if(n){var i=n.getMagnetFromLinkEnd(this.model.get(t));i===n.el&&(i=null),this[e]=i}else this[e]=null},_getLabelPositionProperty:function(t){return this.model.label(t).position||{}},_getLabelPositionAngle:function(t){return this._getLabelPositionProperty(t).angle||0},_getLabelPositionArgs:function(t){return this._getLabelPositionProperty(t).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:Ws({},e,t)},addLabel:function(t,e,n,i){var r,o,a,s=0;a="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);var u=this._getDefaultLabelPositionArgs(),l=a,h=this._mergeLabelPositionArgs(l,u),c={position:this.getLabelPosition(r,o,s,h)};return this.model.insertLabel(-1,c,a),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,o=i?t.y:e,a=i?e:n,s={x:r,y:o},u=this.getVertexIndex(r,o);return this.model.insertVertex(u,s,a),u},sendToken:function(t,e,n){var i,r,o;o=hs(e)?(i=e.duration,r="reverse"===e.direction,e.connection):(i=e,r=!1,null);var a={dur:(i=i||1e3)+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};r&&(a.keyPoints="1;0",a.keyTimes="0;1");var s,u,l,h=su(t);if("string"==typeof o)s=this.findNode(o);else{var c=this._V;s=c.connection?c.connection.node:this.el.querySelector("path")}if(!(s instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");h.appendTo(this.paper.cells).animateAlongPath(a,s),setTimeout((u=h,l=n,function(){u.remove(),"function"==typeof l&&l()}),i)},findRoute:function(t){t||(t=[]);var e=this.paper.options.routerNamespace||jd,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(si);n=i}var r=Ms(n)?n:e[n.name];if(!Ms(r))throw new Error('dia.LinkView: unknown router: "'+n.name+'".');var o=n.args||{},a=r.call(this,t,o,this);return a||t.map(si)},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||Qh,r=this.model.connector(),o=this.paper.options.defaultConnector;r||(r=o||{});var a=Ms(r)?r:i[r.name];if(!Ms(a))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');var s=Ts(r.args||{});s.raw=!0;var u=a.call(this,e,n,t,s,this);return"string"==typeof u&&(u=new Ii(su.normalizePathData(u))),u},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;var n=t.serialize();return e.data=n},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;var n=t.getSegmentSubdivisions();return e.segmentSubdivisions=n},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;var n=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=n},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?(zu(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={},a=0;(r="number"==typeof n?(a=n,i):n)&&(o.args=r);var s,u,l=!(r&&r.absoluteDistance),h=r&&r.absoluteDistance&&r.reverseDistance,c=r&&r.absoluteOffset,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=new si(t,e),g=d.closestPointT(p,f),v=d.lengthAtT(g,f);if(l&&(v=v/this.getConnectionLength()||0),h&&(v=-1*(this.getConnectionLength()-v)||1),o.distance=v,c||(s=d.tangentAtT(g)),s)u=s.pointOffset(p);else{var m=d.pointAtT(g),y=p.difference(m);u={x:y.x,y:y.y}}return o.offset=u,o.angle=a,o},_getLabelTransformationMatrix:function(t){var e,n=0,i={};if("number"==typeof t)e=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},e=t.distance,n=t.angle||0}var r=0<e&&e<=1,o=0,a={x:0,y:0};if(t.offset){var s=t.offset;"number"==typeof s&&(o=s),s.x&&(a.x=s.x),s.y&&(a.y=s.y)}var u,l=0!==a.x||0!==a.y||0===o,h=i.keepGradient,c=i.ensureLegibility,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=r?e*this.getConnectionLength():e,g=d.tangentAtLength(p,f),v=n;if(g){if(l)(u=g.start.clone()).offset(a);else{var m=g.clone();m.rotate(g.start,-90),m.setLength(o),u=m.end}h&&(v=g.angle()+n,c&&(v=Dn((v+90)%180-90)))}else u=d.start.clone(),l&&u.offset(a);return su.createSVGMatrix().translate(u.x,u.y).rotate(v)},getLabelCoordinates:function(t){var e=this._getLabelTransformationMatrix(t);return new si(e.e,e.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new si(t,e)),r=0,o=n.length;r<o;r++){var a=n[r];if(i<this.getClosestPointLength(a))break}return r},notifyPointerdown:function(t,e,n){rf.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove:function(t,e,n){rf.prototype.pointermove.call(this,t,e,n),this.notify("link:pointermove",t,e,n)},notifyPointerup:function(t,e,n){this.notify("link:pointerup",t,e,n),rf.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){rf.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){rf.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){rf.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&&fs(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){rf.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){rf.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){rf.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){rf.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){rf.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,n,i)},onlabel:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragLabelStart(t,e,n),this.eventData(t).stopPropagation&&t.stopPropagation()},dragLabelStart:function(t,e,n){if(this.can("labelMove")){if(this.isDefaultInteractionPrevented(t))return;var i=t.currentTarget,r=parseInt(i.getAttribute("label-idx"),10),o=this._getDefaultLabelPositionProperty(),a=this._normalizeLabelPosition(this._getLabelPositionProperty(r)),s=this._mergeLabelPositionProperty(a,o),u=this.getLabelCoordinates(s),l=u.x-e,h=u.y-n,c=this._getLabelPositionAngle(r),d=this._getLabelPositionArgs(r),f=this._getDefaultLabelPositionArgs(),p=this._mergeLabelPositionArgs(d,f);this.eventData(t,{action:"label-move",labelIdx:r,dx:l,dy:h,positionAngle:c,positionArgs:p,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){if(this.can("arrowheadMove")){var i=t.target.getAttribute("end"),r=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0});this.eventData(t,r)}},dragStart:function(t,e,n){this.isDefaultInteractionPrevented(t)||this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:n})},dragLabel:function(t,e,n){var i=this.eventData(t),r={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)};this.paper.options.snapLabels&&delete r.position.offset;var o={ui:!0};this.paper.isAsync()&&"touchmove"===t.type&&(o.async=!1),this.model.label(i.labelIdx,r,o)},dragArrowhead:function(t,e,n){this.paper.options.snapLinks?!this._snapArrowhead(t,e,n)&&this.paper.options.snapLinksSelf&&this._snapArrowheadSelf(t,e,n):this.paper.options.snapLinksSelf?this._snapArrowheadSelf(t,e,n):this._connectArrowhead(this.getEventTarget(t),e,n,this.eventData(t))},drag:function(t,e,n){var i=this.eventData(t);this.model.translate(e-i.dx,n-i.dy,{ui:!0}),this.eventData(t,{dx:e,dy:n})},dragLabelEnd:function(){},dragArrowheadEnd:function(t,e,n){var i=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(i):this._connectArrowheadEnd(i,e,n),r.linkAllowed(this)?(this._finishEmbedding(i),this._notifyConnectEvent(i,t)):this._disallow(i),this._afterArrowheadMove(i)},dragEnd:function(){},_disallow:function(t){switch(t.whenNotAllowed){case"remove":this.model.remove({ui:!0});break;case"revert":default:this.model.set(t.arrowhead,t.initialEnd,{ui:!0})}},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var n=t.arrowhead,i=t.initialEnd,r=this.model.prop(n);if(r&&!ph.endsEqual(i,r)){var o=this.paper;i.id&&this.notify("link:disconnect",e,o.findViewByModel(i.id),t.initialMagnet,n),r.id&&this.notify("link:connect",e,o.findViewByModel(r.id),t.magnetUnderPointer,n)}},_snapToPoints:function(t,e,n){for(var i=null,r=1/0,o=null,a=1/0,s=t.x,u=t.y,l=0;l<e.length;l++){var h=Math.abs(e[l].x-t.x);h<r&&(r=h,i=e[l]);var c=Math.abs(e[l].y-t.y);c<a&&(a=c,o=e[l])}return r<n&&(s=i.x),a<n&&(u=o.y),{x:s,y:u}},_snapArrowheadSelf:function(t,e,n){var i=this.paper,r=this.model,o=i.options.snapLinksSelf,a=this.eventData(t),s=o.radius||20,u=this.getEndAnchor("source"===a.arrowhead?"target":"source"),l=r.vertices(),h=[u].concat(l),c=this._snapToPoints({x:e,y:n},h,s),d=i.localToClientPoint(c);this._connectArrowhead(document.elementFromPoint(d.x,d.y),c.x,c.y,this.eventData(t))},_snapArrowhead:function(t,e,n){var r=this.paper,i=r.options,o=i.snapLinks,a=i.connectionStrategy,s=this.eventData(t),u=!1,l=o.radius||50,h=r.findViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l}),c=s.closestView||null,d=s.closestMagnet||null,f=s.magnetProxy||null;s.closestView=s.closestMagnet=s.magnetProxy=null;var p,g=Number.MAX_VALUE,v=new si(e,n);h.forEach(function(i){var e=[];"false"!==i.el.getAttribute("magnet")&&e.push({bbox:i.model.getBBox(),magnet:i.el}),i.$("[magnet]").toArray().forEach(function(t){e.push({bbox:i.getNodeBBox(t),magnet:t})}),e.forEach(function(t){var e=t.magnet,n=t.bbox.center().squaredDistance(v);n<g&&((d===e||r.options.validateConnection.apply(r,s.validateConnectionArgs(i,i.el===e?null:e)))&&(g=n,s.closestView=i,s.closestMagnet=e))})},this);var m=null,y=s.closestView,b=s.closestMagnet;b&&(m=s.magnetProxy=y.findProxyNode(b,"highlighter"));var w=s.arrowhead,x=d!==b;if(c&&x&&c.unhighlight(f,{connecting:!0,snapping:!0}),y){var A=s.prevEnd,P=s.prevX,T=s.prevY;if(s.prevX=e,s.prevY=n,u=!0,!x&&("function"!=typeof a||P===e&&T===n))return u;if(p=y.getLinkEnd(b,e,n,this.model,w),!x&&ks(A,p))return u;s.prevEnd=p,x&&y.highlight(m,{connecting:!0,snapping:!0})}else p={x:e,y:n};return this.model.set(w,p||{x:e,y:n},{ui:!0}),c&&this.notify("link:snap:disconnect",t,c,d,w),y&&this.notify("link:snap:connect",t,y,b,w),u},_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=this.paper,o=this.model;if(i.eventTarget!==t){i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0});var a=i.viewUnderPointer=r.findView(t);if(a){var s=i.magnetUnderPointer=a.findMagnet(t),u=i.magnetProxy=a.findProxyNode(s,"highlighter");s&&this.paper.options.validateConnection.apply(r,i.validateConnectionArgs(a,s))?u&&a.highlight(u,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)}else i.magnetUnderPointer=null,i.magnetProxy=null}i.eventTarget=t,o.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t,e,n){void 0===t&&(t={});var i=this.model,r=t.viewUnderPointer,o=t.magnetUnderPointer,a=t.magnetProxy,s=t.arrowhead;if(o&&a&&r){r.unhighlight(a,{connecting:!0});var u=r.getLinkEnd(o,e,n,i,s);i.set(s,u,{ui:!0})}},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,n=[];n[4]=t,n[5]=this;var i=0,r=0;e="source"===t?(i=2,"target"):(r=2,"source");var o=this.model.get(e);if(o.id){var a=n[i]=this.paper.findViewByModel(o.id),s=a.getMagnetFromLinkEnd(o);s===a.el&&(s=void 0),n[i+1]=s}return function(t,e){return n[r]=t,n[r+1]=t.el===e?void 0:e,n}},_markAvailableMagnets:function(t){function e(t,e){var n=t.paper;return n.options.validateConnection.apply(n,this.validateConnectionArgs(t,e))}var n=this.paper,i=n.model.getCells();t.marked={};for(var r=0,o=i.length;r<o;r++){var a=i[r].findView(n);if(a){var s=Array.prototype.slice.call(a.el.querySelectorAll("[magnet]"));"false"!==a.el.getAttribute("magnet")&&s.push(a.el);var u=s.filter(e.bind(t,a));if(0<u.length){for(var l=0,h=u.length;l<h;l++)a.highlight(u[l],{magnetAvailability:!0});a.highlight(null,{elementAvailability:!0}),t.marked[a.model.id]=u}}}},_unmarkAvailableMagnets:function(t){for(var e,n,i=Object.keys(t.marked),r=0,o=i.length;r<o;r++){e=i[r],n=t.marked[e];var a=this.paper.findViewByModel(e);if(a){for(var s=0,u=n.length;s<u;s++)a.unhighlight(n[s],{magnetAvailability:!0});a.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){e||(e={});var n={action:"arrowhead-move",arrowhead:t,whenNotAllowed:e.whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:Ts(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(n),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=n),n},onMount:function(){rf.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){rf.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){rf.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:hf});Object.defineProperty(cf.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t){var e=this.model.source();return new Ei(e.x,e.y)}var n=this.sourceMagnet;return t.isNodeConnection(n)?new Ei(this.sourceAnchor):t.getNodeBBox(n||t.el)}}),Object.defineProperty(cf.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t){var e=this.model.target();return new Ei(e.x,e.y)}var n=this.targetMagnet;return t.isNodeConnection(n)?new Ei(this.targetAnchor):t.getNodeBBox(n||t.el)}});var df=Jd.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init:function(){Jd.prototype.init.apply(this,arguments);var t=this.options.paper;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid:function(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings:function(t){var e=this,n=[];t&&(Array.isArray(t)?t:[t||{}]).forEach(function(t){n.push.apply(n,e._resolveDrawGridOption(t))});return n},removeGrid:function(){var t=this._gridCache;t&&(t.root.remove(),this._gridCache=null)},renderGrid:function(){var a=this,s=this.options.paper,t=this._gridSettings;if(this.removeGrid(),0!==t.length){var u=s.options.drawGridSize||s.options.gridSize;if(!(u<=1)){var l=this._getGridRefs();t.forEach(function(t,e){var n,i=a._getPatternId(e),r=Ws({},t),o=r.scaleFactor;void 0===o&&(o=1),r.width=u*o||1,r.height=u*o||1,l.exist(i)?n=l.get(i):(n=su("pattern",{id:i,patternUnits:"userSpaceOnUse"},su(r.markup)),l.add(i,n)),Ms(r.render)&&r.render(n.node.firstChild,r,s),n.attr({width:r.width,height:r.height})}),l.root.appendTo(this.el),this.updateGrid()}}},updateGrid:function(){var i=this,t=this._gridCache,e=this._gridSettings,r=this.options.paper;if(t){var n=t.root,o=t.patterns,a=r.getArea(),s=a.x,u=a.y,l=a.width,h=a.height;for(var c in n.attr({x:s,y:u,width:l,height:h}),o){o[c].attr({x:-s,y:-u})}e.forEach(function(t,e){if(Ms(t.update)){var n=o[i._getPatternId(e)];t.update(n.node.firstChild,t,r)}})}},_getPatternId:function(t){return"pattern_"+this.options.paper.cid+"_"+t},_getGridRefs:function(){var t=this._gridCache;if(t)return t;var i=su("defs"),r=su("svg",{width:"100%",height:"100%"},[i]);return t=this._gridCache={root:r,patterns:{},add:function(t,e){var n=su("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]}}},_resolveDrawGridOption:function(t){var e=this.options.patterns;if(ds(t)&&Array.isArray(e[t]))return e[t].map(function(t){return fs({},t)});var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if(i||r||n.markup||(r="dot"),r&&Array.isArray(e[r])){var o=e[r].map(function(t){return fs({},t)}),a=Array.isArray(n.args)?n.args:[n.args||{}];ms(a[0],js(t,"args"));for(var s=0;s<a.length;s++)o[s]&&fs(o[s],a[s]);return o}return i?n:[n]}}),ff={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},pf=9007199254740991,gf=rf.Highlighting,vf={};vf[gf.DEFAULT]={name:"stroke",options:{padding:3}},vf[gf.MAGNET_AVAILABILITY]={name:"addClass",options:{className:"available-magnet"}},vf[gf.ELEMENT_AVAILABILITY]={name:"addClass",options:{className:"available-cell"}};var mf=[{name:Zd.GRID},{name:Zd.BACK},{name:Zd.CELLS},{name:Zd.LABELS},{name:Zd.FRONT},{name:Zd.TOOLS}],yf=rc.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:lf,linkView:cf,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:vf,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){var t=this.model.get("cells").cellNamespace,e=Lu(t,["standard","Link"]);if(!e)throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.");return new e},defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"boundary"},connectionStrategy:null,validateMagnet:function(t,e,n){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,n,i,r,o){return("target"===r?n:t)instanceof lf},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:ff.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:Mc,anchorNamespace:Yd,linkAnchorNamespace:qd,connectionPointNamespace:Rc,overflow:!1},events:{dblclick:"pointerdblclick",dbltap:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},stylesheet:"\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n ",svg:null,viewport:null,defs:null,tools:null,layers:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],FORM_CONTROL_TAG_NAMES:["TEXTAREA","INPUT","BUTTON","SELECT","OPTION"],GUARDED_TAG_NAMES:["SELECT"],MIN_SCALE:1e-6,init:function(){var t=this.options;t.cellViewNamespace||(t.cellViewNamespace=void 0!==joint&&Is(joint,"shapes")?joint.shapes:null);var e=this.model=t.model||new $d;this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&ju(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()||!cs(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){var i=this.findViewByModel(t);i&&this.requestViewUpdate(i,i.FLAG_REMOVE,i.UPDATE_PRIORITY,n)},onCellChange:function(t,e){if(t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===ff.APPROX){var n=this.findViewByModel(t);n&&this.requestViewUpdate(n,n.FLAG_INSERT,n.UPDATE_PRIORITY,e)}},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){if(!this.isFrozen()){var e=t&&t.batchName,n=this.model;if(!this.isAsync()){var i=this.UPDATE_DELAYING_BATCHES;i.includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t)}var r=this.SORT_DELAYING_BATCHES;r.includes(e)&&!n.hasActiveBatch(r)&&this.sortViews()}},cloneOptions:function(){var t=this.options,e=t.defaultConnector,n=t.defaultRouter,i=t.defaultConnectionPoint,r=t.defaultAnchor,o=t.defaultLinkAnchor,a=t.highlighting,s=t.cellViewNamespace,u=t.interactive;!s&&void 0!==joint&&Is(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),Ms(e)||(t.defaultConnector=Es(e)),Ms(n)||(t.defaultRouter=Es(n)),Ms(i)||(t.defaultConnectionPoint=Es(i)),Ms(r)||(t.defaultAnchor=Es(r)),Ms(o)||(t.defaultLinkAnchor=Es(o)),Ls(u)&&(t.interactive=fs({},u)),Ls(a)&&(t.highlighting=bs({},a,vf))},children:function(){var t=su.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:Su("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:Su("layers"),selector:"layers"}]}]},hasLayerView:function(t){return t in this._layers},getLayerView:function(t){var e=this._layers;if(t in e)return e[t];throw new Error('dia.Paper: Unknown layer "'+t+'"')},getLayerNode:function(t){return this.getLayerView(t).el},render:function(){this.renderChildren();var t=this.el,e=this.childNodes,n=this.options,i=this.stylesheet,r=e.svg,o=e.defs,a=e.layers;return t.style.position="relative",r.style.overflow=n.overflow?"visible":"hidden",this.svg=r,this.defs=o,this.layers=a,this.renderLayers(),su.ensureId(r),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&su(this.svg).prepend(su.createSVGStyle(t))},createLayer:function(t){switch(t){case Zd.GRID:return new df({name:t,paper:this,patterns:this.constructor.gridPatterns});default:return new Jd({name:t})}},renderLayers:function(t){var i=this;void 0===t&&(t=mf),this.removeLayers(),t.forEach(function(t){var e=t.name,n=(t.sorted,i.createLayer(e));i.layers.appendChild(n.el),i._layers[e]=n});var e=this.getLayerView(Zd.CELLS),n=this.getLayerView(Zd.TOOLS),r=this.getLayerView(Zd.LABELS);this.tools=n.el,this.cells=this.viewport=e.el,e.vel.addClass(Su("viewport")),r.vel.addClass(Su("viewport")),e.el.style.webkitUserSelect="none",e.el.style.userSelect="none",r.el.style.webkitUserSelect="none",r.el.style.userSelect="none"},removeLayers:function(){var e=this._layers;Object.keys(e).forEach(function(t){e[t].remove(),delete e[t]})},resetLayers:function(){var e=this._layers;Object.keys(e).forEach(function(t){e[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?su.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 i=this.matrix(),r=i.a,o=i.d,a=i.e,s=i.f;if((t=Math.max(t||0,this.MIN_SCALE))===r&&t===o)return this;var u=su.createSVGMatrix().translate(a-e.x*(t-r),s-e.y*(t-o)).scale(t,t);return this.matrix(u,n),this},translate:function(t,e,n){var i=this.matrix();return void 0===t?su.matrixToTranslate(i):(t||(t=0),e||(e=0),i.e===t&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e){void 0===e&&(e={});var n=this.layers;if(void 0===t){var i=n.getAttribute("transform");return(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=n.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),su.createSVGMatrix(t)}var r=this.matrix(),o=su.createSVGMatrix(t),a=this._viewportTransformString,s=su.matrixToTransformString(o);if(s===a)return this;if(!a&&su.matrixToTransformString()===s)return this;var u=o.a,l=o.d,h=o.e,c=o.f;return n.setAttribute("transform",s),this._viewportMatrix=o,this._viewportTransformString=n.getAttribute("transform"),u===r.a&&l===r.d||this.trigger("scale",u,l,e),h===r.e&&c===r.f||this.trigger("translate",h,c,e),this.trigger("transform",o,e),this},clientMatrix:function(){return su.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof rf)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,a=r.length;o<a;o++){var s=r[o],u=this.findViewByModel(s);if(u){var l=["UPDATE"];s.getTargetCell()===i&&l.push("TARGET"),s.getSourceCell()===i&&l.push("SOURCE");var h=Math.max(e+1,u.UPDATE_PRIORITY);this.scheduleViewUpdate(u,u.getFlag(l),h,n)}}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof rf))return!1;var n=t.model;if(n.isElement())return!1;if(0==(e&t.getFlag(["SOURCE","TARGET"]))){var i={silent:!0},r=0,o=this.findViewByModel(n.getSourceCell());o&&!this.isViewMounted(o)&&(r=this.dumpView(o,i),t.updateEndMagnet("source"));var a=0,s=this.findViewByModel(n.getTargetCell());if(s&&!this.isViewMounted(s)&&(a=this.dumpView(s,i),t.updateEndMagnet("target")),0===r&&0===a)return!this.dumpView(t,i)}return!1},requestViewUpdate:function(t,e,n,i){i||(i={}),this.scheduleViewUpdate(t,e,n,i);var r=this.isAsync();if(!(this.isFrozen()||r&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES))){var o=this.updateViews(i);r&&this.notifyAfterRender(o,i)}},scheduleViewUpdate:function(t,e,n,i){var r=this._updates,o=this.options;r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze());var a=t.FLAG_REMOVE,s=t.FLAG_INSERT,u=t.UPDATE_PRIORITY,l=t.cid,h=r.priorities[n];if(h||(h=r.priorities[n]={}),u<n)for(var c=n-1;u<=c;c--){var d=r.priorities[c];d&&l in d&&(h[l]|=d[l],delete d[l])}var f=h[l]||0;if((f&e)!==e){f||r.count++,e&a&&f&s?h[l]^=s:e&s&&f&a&&(h[l]^=a),h[l]|=e;var p=o.onViewUpdate;"function"==typeof p&&p.call(this,t,e,n,i||{},this)}},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,n=t.cid,i=e.priorities[t.UPDATE_PRIORITY],r=this.registerMountedView(t)|i[n];return delete i[n],r},dumpView:function(t,e){void 0===e&&(e={});var n=this.dumpViewUpdate(t);if(!n)return 0;var i=!e.silent;i&&this.notifyBeforeRender(e);var r=this.updateView(t,n,e);if(i){var o={updated:1,priority:t.UPDATE_PRIORITY};this.notifyAfterRender(o,e)}return r},updateView:function(t,e,n){if(!t)return 0;var i=t.FLAG_REMOVE,r=t.FLAG_INSERT,o=t.FLAG_INIT,a=t.model;if(t instanceof rf){if(e&i)return this.removeView(a),0;if(e&r){var s=!!(e&o);s&&(e^=o),this.insertView(t,s),e^=r}}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){var n=this.findViewByModel(t);return n?(this.dumpView(n,e),n):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;if(e in n.unmounted)return 0;var i=n.unmounted[e]|=t.FLAG_INSERT;return n.unmountedCids.push(e),delete n.mounted[e],i},registerMountedView:function(t){var e=t.cid,n=this._updates;if(e in n.mounted)return 0;n.mounted[e]=!0,n.mountedCids.push(e);var i=n.unmounted[e]||0;return delete n.unmounted[e],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){var e=ms({},t,{viewport:null});this.checkViewport(e),this.updateViews(e)},updateViews:function(t){var e;this.notifyBeforeRender(t);for(var n=0,i=0,r=pf;i++,n+=(e=this.updateViewsBatch(t)).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(){for(var t=this._updates.priorities,e=Object.keys(t),n=e.length;0<n&&n--;)for(var i in t[e[n]])return!0;return!1},updateViewsAsync:function(t,e){t||(t={}),e||(e={processed:0,priority:pf});var n=this._updates,i=this.options,r=n.id;if(r){ju(r),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);var o=this.updateViewsBatch(t),a=ms({},t,{mountBatchSize:1e3-o.mounted,unmountBatchSize:1e3-o.unmounted}),s=this.checkViewport(a),u=s.unmounted,l=s.mounted,h=e.processed,c=n.count;0<o.updated?(h+=o.updated+o.unmounted,o.processed=h,e.priority=Math.min(o.priority,e.priority),o.empty&&0===l?(o.unmounted+=u,o.mounted+=l,o.priority=e.priority,this.notifyAfterRender(o,t),e.processed=0,e.priority=pf,n.count=0):e.processed=h):n.idle||i.autoFreeze&&(this.freeze(),n.idle=!0,this.trigger("render:idle",t));var d=t.progress;if(c&&"function"==typeof d&&d.call(this,o.empty,h,c,o,this),n.id!==r)return}if(n.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");n.id=Du(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t){void 0===t&&(t={});var e=t.beforeRender;"function"!=typeof e&&"function"!=typeof(e=this.options.beforeRender)||e.call(this,t,this)},notifyAfterRender:function(t,e){void 0===e&&(e={});var n=e.afterRender;"function"!=typeof n&&(n=this.options.afterRender),"function"==typeof n&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){t||(t={});var e=t.batchSize||1/0,n=this._updates,i=0,r=0,o=0,a=0,s=pf,u=!0,l=this.options,h=n.priorities,c="viewport"in t?t.viewport:l.viewport;"function"!=typeof c&&(c=null);var d=l.onViewPostponed;"function"!=typeof d&&(d=null);var f=Object.keys(h);t:for(var p=0,g=f.length;p<g;p++){var v=+f[p],m=h[v];for(var y in m){if(e<=i){u=!1;break t}var b=ic[y];if(b){var w=m[y];if(0==(w&b.FLAG_REMOVE)){var x=y in n.unmounted;if(b.DETACHABLE&&c&&!c.call(this,b,!x,this)){x||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[y]|=w,delete m[y],o++;continue}x&&(w|=b.FLAG_INSERT,a++),w|=this.registerMountedView(b)}var A=this.updateView(b,w,t);0<A&&(m[y]=A,!d||!d.call(this,b,A,this)||m[y])?(r++,u=!1):(v<s&&(s=v),i++,delete m[y])}else delete m[y]}}return{priority:s,updated:i,postponed:r,unmounted:o,mounted:a,empty:u}},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]=ic[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]=ic[e[r]];return i},checkUnmountedViews:function(t,e){e||(e={});var n=0;"function"!=typeof t&&(t=null);for(var i=("mountBatchSize"in e?e.mountBatchSize:1/0),r=this._updates,o=r.unmountedCids,a=r.unmounted,s=0,u=Math.min(o.length,i);s<u;s++){var l=o[s];if(l in a){var h=ic[l];if(h)if(h.DETACHABLE&&t&&!t.call(this,h,!1,this))o.push(l);else{n++;var c=this.registerMountedView(h);c&&this.scheduleViewUpdate(h,c,h.UPDATE_PRIORITY,{mounting:!0})}}}return o.splice(0,s),n},checkMountedViews:function(t,e){e||(e={});var n=0;if("function"!=typeof t)return n;for(var i=("unmountBatchSize"in e?e.unmountBatchSize:1/0),r=this._updates,o=r.mountedCids,a=r.mounted,s=0,u=Math.min(o.length,i);s<u;s++){var l=o[s];if(l in a){var h=ic[l];if(h)if(h.DETACHABLE&&!t.call(this,h,!0,this))n++,this.registerUnmountedView(h)&&this.detachView(h);else o.push(l)}}return o.splice(0,s),n},checkViewVisibility:function(t,e){void 0===e&&(e={});var n="viewport"in e?e.viewport:this.options.viewport;"function"!=typeof n&&(n=null);var i=this._updates,r=i.mounted,o=i.unmounted,a=!t.DETACHABLE||!n||n.call(this,t,!1,this),s=!1,u=!1;if(t.cid in r&&!a){this.registerUnmountedView(t)&&this.detachView(t);var l=i.mountedCids.indexOf(t.cid);i.mountedCids.splice(l,1),s=!0}if(!s&&t.cid in o&&a){var h=i.unmountedCids.indexOf(t.cid);i.unmountedCids.splice(h,1);var c=this.registerMountedView(t);c&&this.scheduleViewUpdate(t,c,t.UPDATE_PRIORITY,{mounting:!0}),u=!0}return{mounted:u?1:0,unmounted:s?1:0}},checkViewport:function(t){var e=ms({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n="viewport"in e?e.viewport:this.options.viewport,i=this.checkMountedViews(n,e);if(0<i){var r=this._updates.unmountedCids;e.mountBatchSize=Math.min(r.length-i,e.mountBatchSize)}return{mounted:this.checkUnmountedViews(n,e),unmounted:i}},freeze:function(t){t||(t={});var e=this._updates,n=t.key,i=this.options.frozen,r=e.freezeKey;if(n&&n!==r){if(i&&r)return;e.freezeKey=n,e.keyFrozen=i}this.options.frozen=!0;var o=e.id;e.id=null,this.isAsync()&&o&&ju(o)},unfreeze:function(t){t||(t={});var e=this._updates,n=t.key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===ff.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,n=t.height;return cs(e)||(e=this.el.clientWidth),cs(n)||(n=this.el.clientHeight),{width:e,height:n}},setDimensions:function(t,e,n){void 0===n&&(n={});var i=this.options,r=i.width,o=i.height,a=void 0===t?r:t,s=void 0===e?o:e;if(r!==a||o!==s){i.width=a,i.height=s,this._setDimensions();var u=this.getComputedSize();this.trigger("resize",u.width,u.height,n)}},_setDimensions:function(){var t=this.options,e=t.width,n=t.height;cs(e)&&(e=Math.round(e)+"px"),cs(n)&&(n=Math.round(n)+"px"),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=hs(t)?t:fs({gridWidth:t,gridHeight:e,padding:n},i);var r=this.getFitToContentArea(i),o=r.x,a=r.y,s=r.width,u=r.height,l=this.scale(),h=l.sx,c=l.sy;return this.translate(-o*h,-a*c,i),this.setDimensions(s*h,u*c,i),new Ei(o,a,s,u)},getFitToContentArea:function(t){void 0===t&&(t={});var e=t.gridWidth||1,n=t.gridHeight||1,i=Ju(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,n),a=t.maxWidth||Number.MAX_VALUE,s=t.maxHeight||Number.MAX_VALUE,u=t.allowNewOrigin,l="contentArea"in t?new Ei(t.contentArea):this.getContentArea(t),h=this.scale(),c=h.sx,d=h.sy;l.x*=c,l.y*=d,l.width*=c,l.height*=d;var f=Math.ceil((l.width+l.x)/e),p=Math.ceil((l.height+l.y)/n);t.allowNegativeBottomRight||(f=Math.max(f,1),p=Math.max(p,1)),f*=e,p*=n;var g=0;("negative"===u&&l.x<0||"positive"===u&&0<=l.x||"any"===u)&&(g=Math.ceil(-l.x/e)*e,f+=g+=i.left);var v=0;return("negative"===u&&l.y<0||"positive"===u&&0<=l.y||"any"===u)&&(v=Math.ceil(-l.y/n)*n,p+=v+=i.top),f+=i.right,p+=i.bottom,f=Math.max(f,r),p=Math.max(p,o),f=Math.min(f,a),p=Math.min(p,s),new Ei(-g/c,-v/d,f/c,p/d)},transformToFitContent:function(t){var e,n;if(t||(t={}),"contentArea"in t){var i=t.contentArea;e=this.localToPaperRect(i),n=new si(i)}else e=this.getContentBBox(t),n=this.paperToLocalPoint(e);if(e.width&&e.height){ms(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});var r,o=Ju(t.padding),a=t.minScaleX||t.minScale,s=t.maxScaleX||t.maxScale,u=t.minScaleY||t.minScale,l=t.maxScaleY||t.maxScale;if(t.fittingBBox)r=t.fittingBBox;else{var h=this.translate(),c=this.getComputedSize();r={x:h.tx,y:h.ty,width:c.width,height:c.height}}r=new Ei(r).moveAndExpand({x:o.left,y:o.top,width:-o.left-o.right,height:-o.top-o.bottom});var d=this.matrix(),f=d.a,p=d.d,g=d.e,v=d.f,m=r.width/e.width*f,y=r.height/e.height*p;if(t.preserveAspectRatio&&(m=y=Math.min(m,y)),t.scaleGrid){var b=t.scaleGrid;m=b*Math.floor(m/b),y=b*Math.floor(y/b)}var w=(m=Math.min(s,Math.max(a,m)))/f,x=(y=Math.min(l,Math.max(u,y)))/p,A=r.x-n.x*m-g,P=r.y-n.y*y-v;switch(t.verticalAlign){case"middle":P+=(r.height-e.height*x)/2;break;case"bottom":P+=r.height-e.height*x}switch(t.horizontalAlign){case"middle":A+=(r.width-e.width*w)/2;break;case"right":A+=r.width-e.width*w}d.a=m,d.d=y,d.e=A,d.f=P,this.matrix(d,t)}},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new Ei:su(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var n=this.options.restrictTranslate;return Ms(n)?n.apply(this,t):!0===n?this.getArea():n?new Ei(n):null},createViewForModel:function(t){var e,n,i=this.options,r=i.cellViewNamespace,o=t.get("type")+"View",a=Lu(r,o,".");return n=t.isLink()?(e=i.linkView,cf):(e=i.elementView,lf),new(e.prototype instanceof tc?a||e:e.call(this,t)||a||n)({model:t,interactive:i.interactive,labelsLayer:!0===i.labelsLayer?Zd.LABELS:i.labelsLayer})},removeView:function(t){var e=t.id,n=this._views,i=this._updates,r=n[e];if(r){var o=r.cid,a=i.mounted,s=i.unmounted;r.remove(),delete n[e],delete a[o],delete s[o]}return r},renderView:function(t,e){var n,i,r=t.id,o=this._views,a=!0;return r in o&&((n=o[r]).model===t?(i=n.FLAG_INSERT,a=!1):this.removeView(t)),a&&(i=((n=o[r]=this.createViewForModel(t)).paper=this).registerUnmountedView(n)|this.FLAG_INIT|n.getFlag(Ds(n,"initFlag"))),this.requestViewUpdate(n,i,n.UPDATE_PRIORITY,e),n},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(){ws(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(function(t){return t.getAttribute("model-id")}),a=this.model.get("cells");Zu(t,function(t,e){var n=a.get(t.getAttribute("model-id")),i=a.get(e.getAttribute("model-id")),r=n.attributes.z||0,o=i.attributes.z||0;return r===o?0:r<o?-1:1})},insertView:function(t,e){var n=this.getLayerView(Zd.CELLS),i=t.el,r=t.model;switch(this.options.sorting){case ff.APPROX:n.insertSortedNode(i,r.get("z"));break;case ff.EXACT:default:n.insertNode(i)}t.onMount(e)},detachView:function(t){t.unmount(),t.onDetach()},findView:function(t){var e=ds(t)?this.cells.querySelector(t):t instanceof iu?t[0]:t,n=this.findAttribute("model-id",e);if(n)return this._views[n]},findViewByModel:function(t){var e=ds(t)||cs(t)?t:t&&t.id;return this._views[e]},findViewsFromPoint:function(e){return e=new si(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=ms(t||{},{strict:!1}),e=new Ei(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)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t){for(var e,n=[],i=arguments.length-1;0<i--;)n[i]=arguments[i+1];"string"==typeof t&&(e=this).trigger.apply(e,["tools:event",t].concat(n))},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.matrix())},localToPaperRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.matrix())},paperToLocalPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.matrix().inverse())},localToClientPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.clientMatrix())},localToClientRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.clientMatrix())},clientToLocalPoint:function(t,e){var n=new si(t,e);return su.transformPoint(n,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){var r=new Ei(t,e,n,i);return su.transformRect(r,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,n,i){return this.localToPaperRect(t,e,n,i).offset(this.pageOffset())},pageToLocalPoint:function(t,e){var n=new si(t,e).difference(this.pageOffset());return this.paperToLocalPoint(n)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),o=new Ei(t,e,n,i);return o.x-=r.x,o.y-=r.y,this.paperToLocalRect(o)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new si(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof cf))throw new Error("Must provide a linkView.");var e=t.model,n=this.options,i=this.model,r=i.constructor.validations;return!(!n.multiLinks&&!r.multiLinks.call(this,i,e))&&(!(!n.linkPinning&&!r.linkPinning.call(this,i,e))&&!("function"==typeof n.allowLink&&!n.allowLink.call(this,t,this)))},getDefaultLink:function(t,e){return Ms(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t){void 0===t&&(t={});var e=t.highlighter,n=t.type,i=this.options,r=i.highlighting,o=i.highlighterNamespace;if(void 0===e){if(!r)return!1;if(n&&!1===(e=r[n]))return!1;e||(e=r.default)}if(!e)return!1;ds(e)&&(e={name:e});var a=e.name,s=o[a];if(!s)throw new Error('Unknown highlighter ("'+a+'")');if("function"!=typeof s.highlight)throw new Error('Highlighter ("'+a+'") is missing required highlight() method');if("function"!=typeof s.unhighlight)throw new Error('Highlighter ("'+a+'") is missing required unhighlight() method');return{highlighter:s,options:e.options||{},name:a}},onCellHighlight:function(t,e,n){var i=this.resolveHighlighter(n);if(i){var r=i.highlighter,o=i.options;r.highlight(t,e,o)}},onCellUnhighlight:function(t,e,n){var i=this.resolveHighlighter(n);if(i){var r=i.highlighter,o=i.options;r.unhighlight(t,e,o)}},pointerdblclick:function(t){t.preventDefault(),t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerdblclick(t,n.x,n.y):this.trigger("blank:pointerdblclick",t,n.x,n.y)}},pointerclick:function(t){if(this.eventData(t).mousemoved<=this.options.clickThreshold){t=Bu(t);var e=this.findView(t.target);if(this.guard(t,e))return;var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerclick(t,n.x,n.y):this.trigger("blank:pointerclick",t,n.x,n.y)}},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.contextMenuFired?this.contextMenuFired=!1:(t=Bu(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.contextmenu(t,n.x,n.y):this.trigger("blank:contextmenu",t,n.x,n.y)}},pointerdown:function(t){var e=(t=Bu(t)).target,n=t.button,i=this.findView(e),r=2===n;if(i){if(!r&&this.guard(t,i))return;var o=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName);this.options.preventDefaultViewAction&&!o&&t.preventDefault(),o&&i.preventDefaultInteraction(t);var a=this.customEventTrigger(t,i);if(a){if(a.isPropagationStopped())return;t.data=a.data}var s=e.closest("[magnet]");if(s&&i.el!==s&&i.el.contains(s)){var u=Bu(new iu.Event(t.originalEvent,{data:t.data,currentTarget:s}));if(this.onmagnet(u),u.isDefaultPrevented()&&t.preventDefault(),u.isPropagationStopped()){if(r)return;return void this.delegateDragEvents(i,u.data)}t.data=u.data}}if(r){this.contextMenuFired=!0;var l=new iu.Event(t.originalEvent,{type:"contextmenu",data:t.data});this.contextMenuTrigger(l)}else{var h=this.snapToGrid(t.clientX,t.clientY);i?i.pointerdown(t,h.x,h.y):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,h.x,h.y)),this.delegateDragEvents(i,t.data)}},pointermove:function(t){var e=this.eventData(t);if(e.mousemoved||(e.mousemoved=0,this.undelegateEvents()),!(++e.mousemoved<=this.options.moveThreshold)){t=Bu(t);var n=this.snapToGrid(t.clientX,t.clientY),i=e.sourceView;i?i.pointermove(t,n.x,n.y):this.trigger("blank:pointermove",t,n.x,n.y),this.eventData(t,e)}},pointerup:function(t){this.undelegateDocumentEvents();var e=Bu(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 iu.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseover(t);else{if(this.el===t.target)return;this.trigger("blank:mouseover",t)}},mouseout:function(t){t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseout(t);else{if(this.el===t.target)return;this.trigger("blank:mouseout",t)}},mouseenter:function(t){var e=(t=Bu(t)).target,n=t.relatedTarget,i=t.currentTarget,r=this.findView(e);if(!this.guard(t,r)){var o=this.findView(n);if(r){if(o===r)return;if(r.mouseenter(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseenter",t)}},mouseleave:function(t){var e=(t=Bu(t)).target,n=t.relatedTarget,i=t.currentTarget,r=this.findView(e);if(!this.guard(t,r)){var o=this.findView(n);if(r){if(o===r)return;if(r.mouseleave(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseleave",t)}},_processMouseWheelEvtBuf:_s(function(){var t=this._mw_evt_buffer,e=t.event,n=t.deltas.reduce(function(t,e){return t+Iu(e,50)},0),i=Math.pow(.995,n),r=this.clientToLocalPoint(e.clientX,e.clientY),o=r.x,a=r.y;this.trigger("paper:pinch",e,o,a,i),this._mw_evt_buffer={event:null,deltas:[]}},20,{maxWait:20}),mousewheel:function(t){t=Bu(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=t.originalEvent,i=this.snapToGrid(n.clientX,n.clientY),r=Vu(n),o=r.deltaX,a=r.deltaY,s=this._events["paper:pinch"];if(t.ctrlKey&&s&&0<s.length)n.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(a),this._processMouseWheelEvtBuf();else{var u=Math.max(-1,Math.min(1,n.wheelDelta));e?e.mousewheel(t,i.x,i.y,u):this.trigger("blank:mousewheel",t,i.x,i.y,u),this.trigger("paper:pan",t,o,a)}}},onevent:function(t){var e=t.currentTarget,n=e.getAttribute("event");if(n){var i=this.findView(e);if(i){if(t=Bu(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);i.onevent(t,n,r.x,r.y)}}},magnetEvent:function(t,e){var n=t.currentTarget;if(n.getAttribute("magnet")){var i=this.findView(n);if(i){if(t=Bu(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);e.call(this,i,t,n,r.x,r.y)}}},onmagnet:function(t){if(2===t.button){this.contextMenuFired=!0,this.magnetContextMenuFired=!0;var e=new iu.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget});this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()}else this.magnetEvent(t,function(t,e,n,i,r){t.onmagnet(e,i,r)})},magnetpointerdblclick:function(t){this.magnetEvent(t,function(t,e,n,i,r){t.magnetpointerdblclick(e,n,i,r)})},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetContextMenuFired?this.magnetContextMenuFired=!1:this.magnetContextMenuTrigger(t)},magnetContextMenuTrigger:function(t){this.magnetEvent(t,function(t,e,n,i,r){t.magnetcontextmenu(e,n,i,r)})},onlabel:function(t){var e=t.currentTarget,n=this.findView(e);if(n&&(t=Bu(t),!this.guard(t,n))){var i=this.customEventTrigger(t,n,e);if(i){if(i.isPropagationStopped())return;t.data=i.data}var r=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,r.x,r.y)}},getPointerArgs:function(t){var e=Bu(t),n=this.snapToGrid(e.clientX,e.clientY);return[e,n.x,n.y]},delegateDragEvents:function(t,e){e||(e={}),this.eventData({data:e},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){if("mousedown"===t.type&&2===t.button)return!0;if(this.options.guard&&this.options.guard(t,e))return!0;if(t.data&&void 0!==t.data.guarded)return t.data.guarded;var n=t.target;return!!this.GUARDED_TAG_NAMES.includes(n.tagName)||!(e&&e.model&&e.model instanceof Wl)&&(this.el!==n&&!this.svg.contains(n))},setGridSize:function(t){var e=this.options;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(Zd.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(Zd.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",n=t.size||"auto auto",i=this.scale(),r=this.translate();hs(e)&&(e=r.tx+i.sx*(e.x||0)+"px "+(r.ty+i.sy*(e.y||0))+"px");hs(n)&&(n=(n=new Ei(n).scale(i.sx,i.sy)).width+"px "+n.height+"px");var o=this.childNodes.background;o.style.backgroundSize=n,o.style.backgroundPosition=e},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var n,i=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,a=Math.abs(e.quality)||1,s=this.constructor.backgroundPatterns[Us(r)];if(Ms(s)){t.width*=a,t.height*=a;var u=s(t,e);if(!(u instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=u.toDataURL("image/png"),r="repeat",hs(i)?(i.width*=u.width/t.width,i.height*=u.height/t.height):void 0===i&&(e.size={width:u.width/a,height:u.height/a})}else n=t.src,void 0===i&&(e.size={width:t.width,height:t.height});this.childNodes.background.style.opacity=o,this.childNodes.background.style.backgroundRepeat=r,this.childNodes.background.style.backgroundImage="url("+n+")",this.updateBackgroundImage(e)}}else this.childNodes.background.style.backgroundImage=""},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){if(t=t||{},this.updateBackgroundColor(t.color),t.image){t=this._background=Es(t),Fu(t);var e=document.createElement("img");e.onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image}else this.drawBackgroundImage(null),this._background=null;return this},setInteractivity:function(t){this.options.interactive=t,ws(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!hs(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name;if(e||(e=n+this.svg.id+Mu(JSON.stringify(t))),!this.isDefined(e)){var i=tl,r=i[n]&&i[n](t.args||{});if(!r)throw new Error("Non-existing filter "+n);var o=fs({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});su(r,o).appendTo(this.defs)}return e},defineGradient:function(t){if(!hs(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");var e=this.svg,n=this.defs,i=t.type,r=t.id;void 0===r&&(r=i+e.id+Mu(JSON.stringify(t)));var o=t.stops,a=t.attrs;if(void 0===a&&(a={}),this.isDefined(r))return r;var s=Cs(o).map(function(t){var e=t.offset,n=t.color,i=t.opacity;return su("stop").attr({offset:e,"stop-color":n,"stop-opacity":Number.isFinite(i)?i:1})}),u=su(i,a,s);return u.id=r,u.appendTo(n),r},definePattern:function(t){if(!hs(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e=this.svg,n=this.defs,i=t.id;void 0===i&&(i=e.id+Mu(JSON.stringify(t)));var r=t.markup,o=t.attrs;if(void 0===o&&(o={}),!r)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(i))return i;var a=su("pattern",{patternUnits:"userSpaceOnUse"});if(a.id=i,a.attr(o),"string"==typeof r)a.append(su(r));else{var s=ku(r).fragment;a.append(s)}return a.appendTo(n),i},defineMarker:function(t){if(!hs(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");var e=this.svg,n=this.defs,i=t.id;void 0===i&&(i=e.id+Mu(JSON.stringify(t)));var r=t.markup,o=t.attrs;void 0===o&&(o={});var a=t.markerUnits;if(void 0===a&&(a="userSpaceOnUse"),this.isDefined(i))return i;var s,u=su("marker",{orient:"auto",overflow:"visible",markerUnits:a});if(u.id=i,u.attr(o),r){var l;if("string"==typeof r)l=su(r),l=Array.isArray(l)?l:[l];else{var h=ku(r).fragment;l=su(h).children()}s=1<l.length?su("g").append(l):l[0]}else{var c=t.type;void 0===c&&(c="path"),s=su(c)}var d=js(t,"type","id","markup","attrs","markerUnits");return Object.keys(d).forEach(function(t){var e=d[t],n=s.attr(t);if(null==n)s.attr(t,e);else switch(t){case"transform":s.attr(t,e+" "+n)}}),s.appendTo(u),u.appendTo(n),i},customEventTrigger:function(t,e,n){void 0===n&&(n=e.el);var i=t.target.closest("[event]");if(i&&n!==i&&e.el.contains(i)){var r=Bu(new iu.Event(t.originalEvent,{data:t.data,currentTarget:i}));return this.onevent(r),r.isDefaultPrevented()&&t.preventDefault(),r}return null}},{sorting:ff,Layers:Zd,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,n,i),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,n,i),e},flipX:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(2*n,0),r.scale(-1,1),r.drawImage(t,0,0,n,i),e},flipY:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(0,2*i),r.scale(1,-1),r.drawImage(t,0,0,n,i),e},watermark:function(t,e){e=e||{};var n=t.width,i=t.height,r=document.createElement("canvas");r.width=3*n,r.height=3*i;for(var o=r.getContext("2d"),a=cs(e.watermarkAngle)?-e.watermarkAngle:-20,s=Gn(a),u=r.width/4,l=r.height/4,h=0;h<4;h++)for(var c=0;c<4;c++)0<(h+c)%2&&(o.setTransform(1,0,0,1,(2*h-1)*u,(2*c-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){su(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){su(t).attr({fill:e.color})},update:function(t,e,n){var i=n.scale(),r=i.sx,o=i.sy,a=r<=1?e.thickness:e.thickness/r,s=o<=1?e.thickness:e.thickness/o;su(t).attr({width:a,height:s})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=0<=i-o&&0<=r-o?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",su(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=0<=i-o&&0<=r-o?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",su(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=0<=i-o&&0<=r-o?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",su(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}]}}),bf=rc.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){var e=this.paper,n=this.relatedView;return!e||!n||e.guard(t,n)}}),wf=rc.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=fs(this.options,t)).tools;if(!Array.isArray(e))return this;var n=t.relatedView;if(!(n instanceof rf))return this;for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var a=e[r];a instanceof bf&&(a.configure(n,this),this.vel.append(a.el),i.push(a))}return this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t||(t={});var e=this.tools;if(!e)return this;for(var n=this.isRendered,i=0,r=e.length;i<r;i++){var o=e[i];n?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return this.isMounted()||this.mount(),n||(this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,n=t.length;e<n;e++)t[e].remove();this.tools=null},mount:function(){var t=this.options,e=this.el,n=t.relatedView,i=t.layer;void 0===i&&(i=Zd.TOOLS);var r=t.z;return n&&(i?n.paper.getLayerView(i).insertSortedNode(e,r):n.el.appendChild(e)),this}}),xf={Graph:$d,attributes:Hl,LayersNames:Zd,PaperLayer:Jd,Cell:Wl,CellView:rf,Element:fh,ElementView:lf,Link:ph,LinkView:cf,Paper:yf,ToolView:bf,ToolsView:wf,HighlighterView:xc},Af=rc.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 n=this.vel,i=this.options.scale,r=su.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()}}),Pf=bf.extend({name:"vertices",options:{handleClass:Af,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,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},onRender:function(){return this.options.vertexAdding&&(this.renderChildren(),this.updatePath()),this.resetHandles(),this.renderHandles(),this},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 e=this,t=this.relatedView.model.vertices(),n=0,i=t.length;n<i;n++){var r=t[n],o=new this.options.handleClass({index:n,paper:this.paper,scale:this.options.scale,guard:function(t){return e.guard(t)}});o.render(),o.position(r.x,r.y),this.simulateRelatedView(o.el),o.vel.appendTo(this.el),this.handles.push(o),this.startHandleListening(o)}},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.childNodes.connection;t&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var e=this.options,n=e.vertexRemoving;void 0===n&&(n=!0);var i=e.vertexMoving;void 0===i&&(i=!0),i&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),n&&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,r=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:new si(i),next:new si(r)}},onHandleWillChange:function(t,e){this.focus();var n=this.relatedView,i=this.options;n.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerdown.apply(n,n.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var n=this.options,i=this.relatedView,r=t.options.index,o=i.paper.getPointerArgs(e),a=o[0],s=o[1],u=o[2],l={x:s,y:u};this.snapVertex(l,r),i.model.vertex(r,l,{ui:!0,tool:this.cid}),t.position(l.x,l.y),n.stopPropagation||i.notifyPointermove(a,s,u)},onHandleChanged:function(t,e){var n=this.options,i=this.relatedView;if(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});var r=i.paper.getPointerArgs(e),o=r[0],a=r[1],s=r[2];n.stopPropagation||i.notifyPointerup(o,a,s),i.checkMouseleave(o)}else i.checkMouseleave(Bu(e))},snapVertex:function(t,e){var n=this.options.snapRadius;if(0<n){var i=this.getNeighborPoints(e),r=i.prev,o=i.next;Math.abs(t.x-r.x)<n?t.x=r.x:Math.abs(t.x-o.x)<n&&(t.x=o.x),Math.abs(t.y-r.y)<n?t.y=i.prev.y:Math.abs(t.y-o.y)<n&&(t.y=o.y)}},onHandleRemove:function(t,e){var n=t.options.index,i=this.relatedView;i.model.removeVertex(n,{ui:!0}),this.options.vertexAdding&&this.updatePath(),i.checkMouseleave(Bu(e))},onPathPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=Bu(t),n=this.paper.snapToGrid(e.clientX,e.clientY).toJSON(),i=this.relatedView;i.model.startBatch("vertex-add",{ui:!0,tool:this.cid});var r=i.getVertexIndex(n.x,n.y);this.snapVertex(n,r),i.model.insertVertex(r,n,{ui:!0,tool:this.cid}),this.update();var o=this.handles[r];this.eventData(e,{vertexAdded:!0}),o.onPointerDown(e)}},onRemove:function(){this.resetHandles()}},{VertexHandle:Af});function Tf(t,e){var n=t.model;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}function Ef(t,e,n){return zc.call(this.paper,{},e,n,t,this.model).anchor}var Sf=rc.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,o=su.createSVGMatrix().translate(t,e).rotate(n);r&&(o=o.scale(r));var a=this.childNodes.handle;a.setAttribute("transform",su.matrixToTransformString(o)),a.setAttribute("cursor",n%180==0?"row-resize":"col-resize");var s=i.getClosestPoint(new si(t,e)),u=this.childNodes.line;u.setAttribute("x1",t),u.setAttribute("y1",e),u.setAttribute("x2",s.x),u.setAttribute("y2",s.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"}}),kf=bf.extend({name:"segments",precision:.5,options:{handleClass:Sf,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:Ef,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],a=this.renderHandle(r,o);this.simulateRelatedView(a.el),this.handles.push(a),a.options.index=n}return this},renderHandle:function(t,e){var n=this,i=new this.options.handleClass({paper:this.paper,scale:this.options.scale,guard:function(t){return n.guard(t)}});return i.render(),this.updateHandle(i,t,e),i.vel.appendTo(this.el),this.startHandleListening(i),i},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(),o=t.options.axis,a=r[i-2]||n.sourceAnchor,s=r[i+1]||n.targetAnchor,u=this.options.snapRadius;return Math.abs(e[o]-a[o])<u?e[o]=a[o]:Math.abs(e[o]-s[o])<u&&(e[o]=s[o]),e},onHandleChanging:function(t,e){var n=this.options,i=this.eventData(e),r=this.relatedView,o=r.paper,a=t.options.index-1,s=Bu(e),u=o.snapToGrid(s.clientX,s.clientY),l=this.snapHandle(t,u.clone(),i),h=t.options.axis,c=this.options.snapHandle?0:u[h]-l[h],d=r.model,f=Es(d.vertices()),p=this.options.anchor;"function"!=typeof p&&(p=null);var g=t.options.index,v=[r.sourcePoint.clone()].concat(f,[r.targetPoint.clone()]),m=0;if(0<=g-1){var y=v[g-1],b=v[g];new ci(y,b).vector().theta()%90!=0&&(f.splice(g-1,0,i.originalVertices[g-1]),m++,this.shiftHandleIndexes(1))}var w=f[a+m],x=f[a+1+m];if(g+2<v.length){var A=v[g+1],P=v[g+2];if(new ci(A,P).vector().theta()%90!=0){var T=1===i.originalVertices.length,E=T?0:g,S=i.firstHandleShifted&&!T?1:0,k=1+m;f.splice(g+k,0,i.originalVertices[E-S])}}var M=r.sourceView,L=r.sourceBBox,C=!1,_=!1;if(w?0===a?L.containsPoint(w)?(f.shift(),this.shiftHandleIndexes(-1),C=!0):(w[h]=l[h],_=!0):w[h]=l[h]:((w=r.sourceAnchor.toJSON())[h]=l[h],L.containsPoint(w)?(w[h]=l[h],C=!0):(f.unshift(w),this.shiftHandleIndexes(1),_=i.firstHandleShifted=!0)),p&&M){if(C){var N=i.sourceAnchor.clone();N[h]=l[h];var O=p.call(r,N,M,r.sourceMagnet||M.el,"source",r);this.resetAnchor("source",O)}_&&this.resetAnchor("source",i.sourceAnchorDef)}var R=r.targetView,F=r.targetBBox,B=!1,V=!1;if(x?a===f.length-2?F.containsPoint(x)?(f.pop(),B=!0):(x[h]=l[h],V=!0):x[h]=l[h]:((x=r.targetAnchor.toJSON())[h]=l[h],F.containsPoint(x)?B=!0:(f.push(x),V=!0)),p&&R){if(B){var I=i.targetAnchor.clone();I[h]=l[h];var D=p.call(r,I,R,r.targetMagnet||R.el,"target",r);this.resetAnchor("target",D)}V&&this.resetAnchor("target",i.targetAnchorDef)}if(f.some(function(t){return!t}))throw new Error("Segments: incompatible router in use");d.vertices(f,{ui:!0,tool:this.cid}),this.updateHandle(t,w,x,c),n.stopPropagation||r.notifyPointermove(s,u.x,u.y)},onHandleChangeStart:function(t,e){var n=this.options,i=this.handles,r=this.relatedView,o=r.model,a=r.paper,s=t.options.index;if(Array.isArray(i)){for(var u=0,l=i.length;u<l;u++)u!==s&&i[u].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:Ts(o.prop(["source","anchor"])),targetAnchorDef:Ts(o.prop(["target","anchor"])),originalVertices:Es(o.vertices()),firstHandleShifted:!1}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||r.notifyPointerdown.apply(r,a.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var n=this.options,i=this.relatedView,r=i.paper,o=i.model;n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid});var a=Bu(e),s=r.snapToGrid(a.clientX,a.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerup(a,s.x,s.y),i.checkMouseleave(a)},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;if(r||o){var a=new ci(e,n);if(a.length()<this.options.segmentLengthThreshold)t.hide();else{var s=a.midpoint(),u=r?"x":"y";s[u]+=i||0;var l=a.vector().vectorAngle(new si(1,0));t.position(s.x,s.y,l,this.relatedView),t.show(),t.options.axis=u}}else t.hide()},onRemove:function(){this.resetHandles()}},{SegmentHandle:Sf}),Mf=bf.extend({tagName:"path",xAxisVector:new si(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{scale:null},onRender:function(){this.update()},update:function(){var t,e,n=this.ratio,i=this.relatedView,r=i.getTangentAtRatio(n);if(e=r?(t=r.start,r.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(n),0),!t)return this;var o=su.createSVGMatrix().translate(t.x,t.y).rotate(e),a=this.options.scale;return a&&(o=o.scale(a)),this.vel.transform(o,{absolute:!0}),this},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.relatedView,n=e.paper;e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),n.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none",e.notifyPointerdown.apply(e,n.getPointerArgs(t))}},onPointerMove:function(t){var e=Bu(t),n=this.paper.snapToGrid(e.clientX,e.clientY);this.relatedView.pointermove(e,n.x,n.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,i=Bu(t),r=n.snapToGrid(i.clientX,i.clientY);e.pointerup(i,r.x,r.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),Lf=Mf.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"}}),Cf=Mf.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=bf.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 t=this.relatedView,e=this.options,n=this.vel,i=e.useModelGeometry,r=e.rotate,o=Ju(e.padding),a=Tf(t,i).moveAndExpand({x:-o.left,y:-o.top,width:o.left+o.right,height:o.top+o.bottom}),s=t.model;if(s.isElement()){var u=s.angle();if(u)if(r){var l=s.getBBox().center();n.rotate(u,l.x,l.y,{absolute:!0})}else a=a.bbox(u)}return n.attr(a.toJSON()),this}}),Nf=bf.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){var a=o.options.snapRadius,s="source"===i,u=s?0:-1,l=this.model.vertex(u)||this.getEndAnchor(s?"target":"source");return l&&(Math.abs(l.x-t.x)<a&&(t.x=l.x),Math.abs(l.y-t.y)<a&&(t.y=l.y)),t},anchor:Ef,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 e=t.anchor;if(e){var n=this.relatedView,i=this.type,r=n.getEndAnchor(i),o=this.options,a=n.model.prop([i,"anchor"]),s="translate("+r.x+","+r.y+")";o.scale&&(s+=" scale("+o.scale+")"),e.setAttribute("transform",s);var u=a?o.customAnchorAttributes:o.defaultAnchorAttributes;for(var l in u)e.setAttribute(l,u[l])}}},updateArea:function(){var t=this.childNodes;if(t){var e=t.area;if(e){var n,i,r,o=this.relatedView,a=this.type,s=o.getEndView(a),u=s.model,l=o.getEndMagnet(a),h=this.options.areaPadding;isFinite(h)||(h=0),s.isNodeConnection(l)?(i=0,r=(n=s.getNodeBBox(l)).center()):(n=s.getNodeUnrotatedBBox(l),i=u.angle(),r=n.center(),i&&r.rotate(u.getBBox().center(),-i)),n.inflate(h),e.setAttribute("x",-n.width/2),e.setAttribute("y",-n.height/2),e.setAttribute("width",n.width),e.setAttribute("height",n.height),e.setAttribute("transform","translate("+r.x+","+r.y+") rotate("+i+")")}}},toggleArea:function(t){var e=this.childNodes;if(e){var n=e.area;n&&(n.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=this.relatedView,i=this.type,r=n.getEndView(i),o=r.model,a=n.getEndMagnet(i),s=Bu(t),u=this.paper.clientToLocalPoint(s.clientX,s.clientY),l=this.options.snap;if("function"==typeof l&&(u=l.call(n,u,r,a,i,n,this),u=new si(u)),this.options.restrictArea)if(r.isNodeConnection(a)){var h=r.getClosestPoint(u);h&&(u=h)}else{var c=r.getNodeUnrotatedBBox(a),d=o.angle(),f=o.getBBox().center(),p=u.clone().rotate(f,d);c.containsPoint(p)||(u=c.pointNearestToPoint(p).rotate(f,-d))}var g=this.options.anchor;"function"==typeof g&&(e=g.call(n,u,r,a,i,n)),this.resetAnchor(e),this.update()},onPointerUp:function(t){var e=Bu(t);this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1);var n=this.relatedView;this.options.redundancyRemoval&&n.removeRedundantLinearVertices({ui:!0,tool:this.cid}),n.checkMouseleave(e),n.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(!0===t&&(t=null),this.resetAnchor(Es(t)),this.update())}}),Of=Nf.extend({name:"source-anchor",type:"source"}),Rf=Nf.extend({name:"target-anchor",type:"target"}),Ff=bf.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(){this.vel.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix:function(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix:function(){var t=this.relatedView,e=this.options,n=e.x;void 0===n&&(n=0);var i=e.y;void 0===i&&(i=0);var r=e.offset;void 0===r&&(r={});var o=e.useModelGeometry,a=e.rotate,s=e.scale,u=Tf(t,o),l=t.model.angle();a||(u=u.bbox(l));var h=r.x;void 0===h&&(h=0);var c=r.y;void 0===c&&(c=0),zu(n)?n=parseFloat(n)/100*u.width:Nn(n)&&(n=Number(Fn(n,u))),zu(i)?i=parseFloat(i)/100*u.height:Nn(i)&&(i=Number(Fn(i,u)));var d=su.createSVGMatrix().translate(u.x+u.width/2,u.y+u.height/2);return a&&(d=d.rotate(l)),d=d.translate(n+h-u.width/2,i+c-u.height/2),s&&(d=d.scale(s)),d},getLinkMatrix:function(){var t=this.relatedView,e=this.options,n=e.offset;void 0===n&&(n=0);var i=e.distance;void 0===i&&(i=0);var r,o,a,s=e.rotate,u=e.scale;a=(r=zu(i)?t.getTangentAtRatio(parseFloat(i)/100):t.getTangentAtLength(i))?(o=r.start,r.vector().vectorAngle(new si(1,0))||0):(o=t.getConnection().start,0);var l=su.createSVGMatrix().translate(o.x,o.y).rotate(a).translate(0,n);return s||(l=l.rotate(-a)),u&&(l=l.scale(u)),l},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.options.action;"function"==typeof e&&e.call(this.relatedView,t,this.relatedView,this)}}}),Bf=Ff.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})}}}),Vf=Ff.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:function(t){return t.el},action:function(t,e,n){return n.dragstart(t)}},getMagnetNode:function(){var t,e=this.options,n=this.relatedView,i=e.magnet;switch(typeof i){case"function":t=i.call(this,n,this);break;case"string":t=n.findNode(i);break;default:t=i}if(t||(t=n.el),t instanceof SVGElement)return t;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var e=this.paper,n=this.relatedView,i=Bu(t),r=e.clientToLocalPoint(i.clientX,i.clientY),o=r.x,a=r.y;n.dragLinkStart(i,this.getMagnetNode(),o,a),e.undelegateEvents(),this.delegateDocumentEvents(null,i.data),this.focus()},drag:function(t){var e=this.paper,n=this.relatedView,i=Bu(t),r=e.snapToGrid(i.clientX,i.clientY),o=r.x,a=r.y;n.dragLink(i,o,a)},dragend:function(t){var e=this.paper,n=this.relatedView,i=Bu(t),r=e.snapToGrid(i.clientX,i.clientY),o=r.x,a=r.y;n.dragLinkEnd(i,o,a),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),n.checkMouseleave(i)}}),If=Vf.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:function(){var t=this.options,e=this.defaultMarkup;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"},Vf.prototype.events),onRender:function(){this.renderChildren(),this.update()},trackPath:null,update:function(){var t=this.childNodes;this.trackPath=this.getTrackPath(),Vf.prototype.update.apply(this,arguments),t.track.setAttribute("d",this.trackPath.serialize())},position:function(){var t=this.el;this.childNodes.button.setAttribute("transform",su.matrixToTransformString(this.getButtonMatrix())),t.setAttribute("transform",su.matrixToTransformString(this.getTrackMatrix()))},getButtonMatrix:function(){var t=this.options,e=this.trackPath,n=t.offset;void 0===n&&(n=0);var i=t.distance;void 0===i&&(i=0);var r,o,a,s=t.rotate,u=t.scale;a=(r=zu(i)?e.tangentAtRatio(parseFloat(i)/100):e.tangentAtLength(i))?(o=r.start,r.vector().vectorAngle(new si(1,0))||0):(o=e.start,0);var l=su.createSVGMatrix().translate(o.x,o.y).rotate(a).translate(0,n);return s||(l=l.rotate(-a)),u&&(l=l.scale(u)),l},getTrackPath:function(){return this.relatedView.getConnection()},getTrackMatrix:function(){return su.createSVGMatrix()},getTrackRatioFromEvent:function(t){var e=this.relatedView,n=this.trackPath,i=e.paper.clientToLocalPoint(t.clientX,t.clientY),r=su.transformPoint(i,this.getTrackMatrix().inverse());return n.closestPointLength(r)},canShowButton:function(){return iu.event.has(this.paper.el)},showButton:function(){this.childNodes.button.style.display="block"},hideButton:function(){this.childNodes.button.style.display=""},onMousemove:function(t){if(this.trackPath){this.options.distance=this.getTrackRatioFromEvent(t),this.position()}},onMouseenter:function(){this.canShowButton()&&this.showButton()},onMouseleave:function(){this.hideButton()}}),Df={Vertices:Pf,Segments:kf,TargetArrowhead:Lf,SourceArrowhead:Cf,Boundary:_f,SourceAnchor:Of,TargetAnchor:Rf,Button:Ff,Remove:Bf,Connect:Vf,HoverConnect:If},jf=bf.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 t=this.childNodes,e=t.handle,n=t.extras;if(!e)throw new Error("Control: markup selector `handle` is required");return this.updateHandle(e),n&&this.updateExtras(n),this},updateHandle:function(t){var e=this.relatedView,n=this.options,i=e.model,r=this.getPosition(e,this),o=i.getAbsolutePointFromRelative(r),a=n.handleAttributes,s=n.scale,u="translate("+o.x+","+o.y+")";if(s&&(u+=" scale("+s+")"),t.setAttribute("transform",u),a)for(var l in a)t.setAttribute(l,a[l])},updateExtras:function(t){var e=this.relatedView,n=this.options,i=this.options.selector;if(i){var r=e.findNode(i);if(!r)throw new Error("Control: invalid selector.");var o=n.padding;isFinite(o)||(o=0);var a=e.getNodeUnrotatedBBox(r),s=e.model,u=s.angle(),l=a.center();u&&l.rotate(s.getBBox().center(),-u),a.inflate(o),t.setAttribute("x",-a.width/2),t.setAttribute("y",-a.height/2),t.setAttribute("width",a.width),t.setAttribute("height",a.height),t.setAttribute("transform","translate("+l.x+","+l.y+") rotate("+u+")")}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var e=this.relatedView,n=this.paper;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 e=this.relatedView,n=this.paper,i=e.model,r=Bu(t),o=r.clientX,a=r.clientY,s=n.clientToLocalPoint(o,a),u=i.getRelativePointFromAbsolute(s);this.setPosition(e,u,this),this.update()},onPointerUp:function(t){var e=this.relatedView;this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.relatedView;this.resetPosition(t,this),this.update()}}),zf=If.extend({getTrackPath:function(){var t=this.relatedView,e=this.options,n=e.useModelGeometry,i=e.trackPath;(void 0===i&&(i="M 0 0 H calc(w) V calc(h) H 0 Z"),"function"==typeof i&&(i=i.call(this,t)),Nn(i))&&(i=Fn(i,Tf(t,n)));return new Ii(su.normalizePathData(i))},getTrackMatrix:function(){var t=this.relatedView,e=this.options,n=e.useModelGeometry,i=e.rotate,r=Tf(t,n),o=t.model.angle();i||(r=r.bbox(o));var a=su.createSVGMatrix().translate(r.x+r.width/2,r.y+r.height/2);return i&&(a=a.rotate(o)),a=a.translate(-r.width/2,-r.height/2)}}),Gf={Button:Ff,Remove:Bf,Connect:Vf,Boundary:_f,HoverConnect:zf,Control:jf},Uf=su,Hf={PortLabel:lh,Port:ih};return t.V=su,t.Vectorizer=Uf,t.anchors=Yd,t.config=xu,t.connectionPoints=Rc,t.connectionStrategies=Gc,t.connectors=Qh,t.dia=xf,t.elementTools=Gf,t.env=gh,t.format={},t.g=Mr,t.highlighters=Mc,t.layout=Hf,t.linkAnchors=qd,t.linkTools=Df,t.mvc=bc,t.routers=jd,t.setTheme=function(t,e){ws(ic,"setTheme",t,e=e||{}),rc.prototype.defaultTheme=t},t.shapes=Lh,t.ui={},t.util=Jl,t.version="4.0.3",t}({});if(void 0!==joint)var g=joint.g,V=joint.V,Vectorizer=joint.V;
|