jointjs
Version:
JavaScript diagramming library
8 lines (6 loc) • 419 kB
JavaScript
/*! JointJS v3.7.7 (2023-11-07) - JavaScript diagramming library
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
if(function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("backbone"),require("jquery")):"function"==typeof define&&define.amd?define(["exports","backbone","jquery"],e):e((t=t||self).joint={},t.Backbone,t.$)}(this,function(t,l,P){"use strict";l=l&&l.hasOwnProperty("default")?l.default:l,P=P&&P.hasOwnProperty("default")?P.default:P;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 r=function(t){return t&&t.Math==Math&&t},h=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("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]}),i={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,u={f:o&&!i.call({1:2},1)?function(t){var e=o(this,t);return!!e&&e.enumerable}:i},x=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},c={}.toString,d=function(t){return c.call(t).slice(8,-1)},f="".split,w=a(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==d(t)?f.call(t,""):Object(t)}:Object,p=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},g=function(t){return w(p(t))},v=function(t){return"object"==typeof t?null!==t:"function"==typeof t},m=function(t,e){if(!v(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!v(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!v(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},y={}.hasOwnProperty,b=function(t,e){return y.call(t,e)},A=h.document,T=v(A)&&v(A.createElement),E=function(t){return T?A.createElement(t):{}},S=!s&&!a(function(){return 7!=Object.defineProperty(E("div"),"a",{get:function(){return 7}}).a}),k=Object.getOwnPropertyDescriptor,C={f:s?k:function(t,e){if(t=g(t),e=m(e,!0),S)try{return k(t,e)}catch(t){}if(b(t,e))return x(!u.f.call(t,e),t[e])}},L=function(t){if(!v(t))throw TypeError(String(t)+" is not an object");return t},M=Object.defineProperty,O={f:s?M:function(t,e,n){if(L(t),e=m(e,!0),L(n),S)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}},N=s?function(t,e,n){return O.f(t,e,x(1,n))}:function(t,e,n){return t[e]=n,t},_=function(e,n){try{N(h,e,n)}catch(t){h[e]=n}return n},R="__core-js_shared__",V=h[R]||_(R,{}),F=Function.toString;"function"!=typeof V.inspectSource&&(V.inspectSource=function(t){return F.call(t)});var B,D,I,z=V.inspectSource,j=h.WeakMap,G="function"==typeof j&&/native code/.test(z(j)),U=n(function(t){(t.exports=function(t,e){return V[t]||(V[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),H=0,q=Math.random(),Y=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++H+q).toString(36)},W=U("keys"),X=function(t){return W[t]||(W[t]=Y(t))},$={},Z=h.WeakMap;if(G){var J=V.state||(V.state=new Z),K=J.get,Q=J.has,tt=J.set;B=function(t,e){return e.facade=t,tt.call(J,t,e),e},D=function(t){return K.call(J,t)||{}},I=function(t){return Q.call(J,t)}}else{var et=X("state");$[et]=!0,B=function(t,e){return e.facade=t,N(t,et,e),e},D=function(t){return b(t,et)?t[et]:{}},I=function(t){return b(t,et)}}var nt,rt={set:B,get:D,has:I,enforce:function(t){return I(t)?D(t):B(t,{})},getterFor:function(n){return function(t){var e;if(!v(t)||(e=D(t)).type!==n)throw TypeError("Incompatible receiver, "+n+" required");return e}}},it=n(function(t){var e=rt.get,u=rt.enforce,l=String(String).split("String");(t.exports=function(t,e,n,r){var i,o=!!r&&!!r.unsafe,a=!!r&&!!r.enumerable,s=!!r&&!!r.noTargetGet;"function"==typeof n&&("string"!=typeof e||b(n,"name")||N(n,"name",e),(i=u(n)).source||(i.source=l.join("string"==typeof e?e:""))),t!==h?(o?!s&&t[e]&&(a=!0):delete t[e],a?t[e]=n:N(t,e,n)):a?t[e]=n:_(e,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||z(this)})}),ot=h,at=function(t){return"function"==typeof t?t:void 0},st=function(t,e){return arguments.length<2?at(ot[t])||at(h[t]):ot[t]&&ot[t][e]||h[t]&&h[t][e]},ut=Math.ceil,lt=Math.floor,ht=function(t){return isNaN(t=+t)?0:(0<t?lt:ut)(t)},ct=Math.min,dt=function(t){return 0<t?ct(ht(t),9007199254740991):0},ft=Math.max,pt=Math.min,gt=function(l){return function(t,e,n){var r,i,o,a=g(t),s=dt(a.length),u=(r=s,(i=ht(n))<0?ft(i+r,0):pt(i,r));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}},vt={includes:gt(!0),indexOf:gt(!1)},mt=vt.indexOf,yt=function(t,e){var n,r=g(t),i=0,o=[];for(n in r)!b($,n)&&b(r,n)&&o.push(n);for(;e.length>i;)b(r,n=e[i++])&&(~mt(o,n)||o.push(n));return o},bt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],xt=bt.concat("length","prototype"),wt={f:Object.getOwnPropertyNames||function(t){return yt(t,xt)}},At={f:Object.getOwnPropertySymbols},Pt=st("Reflect","ownKeys")||function(t){var e=wt.f(L(t)),n=At.f;return n?e.concat(n(t)):e},Tt=function(t,e){for(var n=Pt(e),r=O.f,i=C.f,o=0;o<n.length;o++){var a=n[o];b(t,a)||r(t,a,i(e,a))}},Et=/#|\.prototype\./,St=function(t,e){var n=Ct[kt(t)];return n==Mt||n!=Lt&&("function"==typeof e?a(e):!!e)},kt=St.normalize=function(t){return String(t).replace(Et,".").toLowerCase()},Ct=St.data={},Lt=St.NATIVE="N",Mt=St.POLYFILL="P",Ot=St,Nt=C.f,_t=function(t,e){var n,r,i,o,a,s=t.target,u=t.global,l=t.stat;if(n=u?h:l?h[s]||_(s,{}):(h[s]||{}).prototype)for(r in e){if(o=e[r],i=t.noTargetGet?(a=Nt(n,r))&&a.value:n[r],!Ot(u?r:s+(l?".":"#")+r,t.forced)&&void 0!==i){if(typeof o==typeof i)continue;Tt(o,i)}(t.sham||i&&i.sham)&&N(o,"sham",!0),it(n,r,o,t)}},Rt=!!Object.getOwnPropertySymbols&&!a(function(){return!String(Symbol())}),Vt=Rt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ft=U("wks"),Bt=h.Symbol,Dt=Vt?Bt:Bt&&Bt.withoutSetter||Y,It=function(t){return b(Ft,t)||(Rt&&b(Bt,t)?Ft[t]=Bt[t]:Ft[t]=Dt("Symbol."+t)),Ft[t]},zt=Object.keys||function(t){return yt(t,bt)},jt=s?Object.defineProperties:function(t,e){L(t);for(var n,r=zt(e),i=r.length,o=0;o<i;)O.f(t,n=r[o++],e[n]);return t},Gt=st("document","documentElement"),Ut="prototype",Ht="script",qt=X("IE_PROTO"),Yt=function(){},Wt=function(t){return"<script>"+t+"</"+Ht+">"},Xt=function(){try{nt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;Xt=nt?function(t){t.write(Wt("")),t.close();var e=t.parentWindow.Object;return t=null,e}(nt):((e=E("iframe")).style.display="none",Gt.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(Wt("document.F=Object")),t.close(),t.F);for(var n=bt.length;n--;)delete Xt[Ut][bt[n]];return Xt()};$[qt]=!0;var $t=Object.create||function(t,e){var n;return null!==t?(Yt[Ut]=L(t),n=new Yt,Yt[Ut]=null,n[qt]=t):n=Xt(),void 0===e?n:jt(n,e)},Zt=It("unscopables"),Jt=Array.prototype;null==Jt[Zt]&&O.f(Jt,Zt,{configurable:!0,value:$t(null)});var Kt=function(t){Jt[Zt][t]=!0},Qt=Object.defineProperty,te={},ee=function(t){throw t},ne=function(t,e){if(b(te,t))return te[t];e||(e={});var n=[][t],r=!!b(e,"ACCESSORS")&&e.ACCESSORS,i=b(e,0)?e[0]:ee,o=b(e,1)?e[1]:void 0;return te[t]=!!n&&!a(function(){if(r&&!s)return!0;var t={length:-1};r?Qt(t,1,{enumerable:!0,get:ee}):t[1]=1,n.call(t,i,o)})},re=vt.includes,ie=ne("indexOf",{ACCESSORS:!0,1:0});_t({target:"Array",proto:!0,forced:!ie},{includes:function(t){return re(this,t,1<arguments.length?arguments[1]:void 0)}}),Kt("includes");var oe=function(r,i,t){if(function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function")}(r),void 0===i)return r;switch(t){case 0:return function(){return r.call(i)};case 1:return function(t){return r.call(i,t)};case 2:return function(t,e){return r.call(i,t,e)};case 3:return function(t,e,n){return r.call(i,t,e,n)}}return function(){return r.apply(i,arguments)}},ae=Function.call,se=function(t,e,n){return oe(ae,h[t].prototype[e],n)},ue=(se("Array","includes"),function(t){return Object(p(t))}),le=Array.isArray||function(t){return"Array"==d(t)},he=It("species"),ce=function(t,e){var n;return le(t)&&("function"!=typeof(n=t.constructor)||n!==Array&&!le(n.prototype)?v(n)&&null===(n=n[he])&&(n=void 0):n=void 0),new(void 0===n?Array:n)(0===e?0:e)},de=[].push,fe=function(f){var p=1==f,g=2==f,v=3==f,m=4==f,y=6==f,b=7==f,x=5==f||y;return function(t,e,n,r){for(var i,o,a=ue(t),s=w(a),u=oe(e,n,3),l=dt(s.length),h=0,c=r||ce,d=p?c(t,l):g||b?c(t,0):void 0;h<l;h++)if((x||h in s)&&(o=u(i=s[h],h,a),f))if(p)d[h]=o;else if(o)switch(f){case 3:return!0;case 5:return i;case 6:return h;case 2:de.call(d,i)}else switch(f){case 4:return!1;case 7:de.call(d,i)}return y?-1:v||m?m:d}},pe={forEach:fe(0),map:fe(1),filter:fe(2),some:fe(3),every:fe(4),find:fe(5),findIndex:fe(6),filterOut:fe(7)},ge=pe.find,ve="find",me=!0,ye=ne(ve);ve in[]&&Array(1)[ve](function(){me=!1}),_t({target:"Array",proto:!0,forced:me||!ye},{find:function(t){return ge(this,t,1<arguments.length?arguments[1]:void 0)}}),Kt(ve);se("Array","find");var be,xe,we,Ae=function(s){return function(t,e){var n,r,i=String(p(t)),o=ht(e),a=i.length;return o<0||a<=o?s?"":void 0:(n=i.charCodeAt(o))<55296||56319<n||o+1===a||(r=i.charCodeAt(o+1))<56320||57343<r?s?i.charAt(o):n:s?i.slice(o,o+2):r-56320+(n-55296<<10)+65536}},Pe={codeAt:Ae(!1),charAt:Ae(!0)},Te=!a(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Ee=X("IE_PROTO"),Se=Object.prototype,ke=Te?Object.getPrototypeOf:function(t){return t=ue(t),b(t,Ee)?t[Ee]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Se:null},Ce=It("iterator"),Le=!1;[].keys&&("next"in(we=[].keys())?(xe=ke(ke(we)))!==Object.prototype&&(be=xe):Le=!0),(null==be||a(function(){var t={};return be[Ce].call(t)!==t}))&&(be={}),b(be,Ce)||N(be,Ce,function(){return this});var Me={IteratorPrototype:be,BUGGY_SAFARI_ITERATORS:Le},Oe=O.f,Ne=It("toStringTag"),_e=function(t,e,n){t&&!b(t=n?t:t.prototype,Ne)&&Oe(t,Ne,{configurable:!0,value:e})},Re={},Ve=Me.IteratorPrototype,Fe=function(){return this},Be=Object.setPrototypeOf||("__proto__"in{}?function(){var n,r=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),r=t instanceof Array}catch(t){}return function(t,e){return L(t),function(t){if(!v(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(e),r?n.call(t,e):t.__proto__=e,t}}():void 0),De=Me.IteratorPrototype,Ie=Me.BUGGY_SAFARI_ITERATORS,ze=It("iterator"),je="values",Ge="entries",Ue=function(){return this},He=Pe.charAt,qe="String Iterator",Ye=rt.set,We=rt.getterFor(qe);!function(t,e,n,r,i,o,a){var s,u,l;u=r,l=e+" Iterator",(s=n).prototype=$t(Ve,{next:x(1,u)}),_e(s,l,!1),Re[l]=Fe;var h,c,d,f=function(t){if(t===i&&y)return y;if(!Ie&&t in v)return v[t];switch(t){case"keys":case je:case Ge:return function(){return new n(this,t)}}return function(){return new n(this)}},p=e+" Iterator",g=!1,v=t.prototype,m=v[ze]||v["@@iterator"]||i&&v[i],y=!Ie&&m||f(i),b="Array"==e&&v.entries||m;if(b&&(h=ke(b.call(new t)),De!==Object.prototype&&h.next&&(ke(h)!==De&&(Be?Be(h,De):"function"!=typeof h[ze]&&N(h,ze,Ue)),_e(h,p,!0))),i==je&&m&&m.name!==je&&(g=!0,y=function(){return m.call(this)}),v[ze]!==y&&N(v,ze,y),Re[e]=y,i)if(c={values:f(je),keys:o?y:f("keys"),entries:f(Ge)},a)for(d in c)!Ie&&!g&&d in v||it(v,d,c[d]);else _t({target:e,proto:!0,forced:Ie||g},c)}(String,"String",function(t){Ye(this,{type:qe,string:String(t),index:0})},function(){var t,e=We(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=He(n,r),e.index+=t.length,{value:t,done:!1})});var Xe=function(e,t,n,r){try{return r?t(L(n)[0],n[1]):t(n)}catch(t){throw function(t){var e=t.return;if(void 0!==e)L(e.call(t)).value}(e),t}},$e=It("iterator"),Ze=Array.prototype,Je=function(t,e,n){var r=m(e);r in t?O.f(t,r,x(0,n)):t[r]=n},Ke={};Ke[It("toStringTag")]="z";var Qe="[object z]"===String(Ke),tn=It("toStringTag"),en="Arguments"==d(function(){return arguments}()),nn=Qe?d:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),tn))?n:en?d(e):"Object"==(r=d(e))&&"function"==typeof e.callee?"Arguments":r},rn=It("iterator"),on=It("iterator"),an=!1;try{var sn=0,un={next:function(){return{done:!!sn++}},return:function(){an=!0}};un[on]=function(){return this},Array.from(un,function(){throw 2})}catch(t){}var ln=!function(t,e){if(!e&&!an)return!1;var n=!1;try{var r={};r[on]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}(function(t){Array.from(t)});_t({target:"Array",stat:!0,forced:ln},{from:function(t){var e,n,r,i,o,a,s,u=ue(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[rn]||t["@@iterator"]||Re[nn(t)]}(u),p=0;if(d&&(c=oe(c,2<h?arguments[2]:void 0,2)),null!=f&&(l!=Array||void 0===(s=f)||Re.Array!==s&&Ze[$e]!==s))for(o=(i=f.call(u)).next,n=new l;!(r=o.call(i)).done;p++)a=d?Xe(i,c,[r.value,p],!0):r.value,Je(n,p,a);else for(n=new l(e=dt(u.length));p<e;p++)a=d?c(u[p],p):u[p],Je(n,p,a);return n.length=p,n}});ot.Array.from;var hn=pe.findIndex,cn="findIndex",dn=!0,fn=ne(cn);cn in[]&&Array(1)[cn](function(){dn=!1}),_t({target:"Array",proto:!0,forced:dn||!fn},{findIndex:function(t){return hn(this,t,1<arguments.length?arguments[1]:void 0)}}),Kt(cn);se("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,r=String(t),i=0,o=s,a="";r.charAt(0|i)||(o="=",i%1);a+=o.charAt(63&e>>8-i%1*8)){if(255<(n=r.charCodeAt(i+=.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,r,i=0,o=0,a="";r=e.charAt(o++);~r&&(n=i%4?64*n+r:r,i++%4)?a+=String.fromCharCode(255&n>>(-2*i&6)):0)r=s.indexOf(r);return a})}()});_t({target:"Number",stat:!0},{isNaN:function(t){return t!=t}});ot.Number.isNaN;var pn=h.isFinite,gn=Number.isFinite||function(t){return"number"==typeof t&&pn(t)};_t({target:"Number",stat:!0},{isFinite:gn});ot.Number.isFinite;var vn=It("match"),mn=function(t){if(v(e=t)&&(void 0!==(n=e[vn])?n:"RegExp"==d(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t},yn=It("match"),bn=function(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[yn]=!1,"/./"[e](n)}catch(t){}}return!1};_t({target:"String",proto:!0,forced:!bn("includes")},{includes:function(t){return!!~String(p(this)).indexOf(mn(t),1<arguments.length?arguments[1]:void 0)}});se("String","includes");var xn,wn=C.f,An="".startsWith,Pn=Math.min,Tn=bn("startsWith"),En=!(Tn||(!(xn=wn(String.prototype,"startsWith"))||xn.writable));_t({target:"String",proto:!0,forced:!En&&!Tn},{startsWith:function(t){var e=String(p(this));mn(t);var n=dt(Pn(1<arguments.length?arguments[1]:void 0,e.length)),r=String(t);return An?An.call(e,r,n):e.slice(n,n+r.length)===r}});se("String","startsWith");!function(){function r(t,e){return this.slice(t,e)}function i(t,e){arguments.length<2&&(e=0);for(var n=0,r=t.length;n<r;++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=r,(e.buffer=e).byteLength=e.length,e.set=i,"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 Sn=Math.round,kn=Math.floor,Cn=Math.PI,Ln=function(t){return t%360+(t<0?360:0)},Mn=function(t,e){return e*Sn(t/e)},On=function(t){return 180*t/Cn%360},Nn=function(t,e){return(t=(e=e||!1)?t:t%360)*Cn/180},_n=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 kn(Math.random()*(e-t+1)+t)},Rn=Math.cos,Vn=Math.sin,Fn=Math.atan2,Bn=function(t,e){var n=Nn(t.y),r=Nn(e.y),i=t.x,o=e.x,a=Nn(o-i),s=Vn(a)*Rn(r),u=Rn(n)*Vn(r)-Vn(n)*Rn(r)*Rn(a),l=On(Fn(s,u))-22.5;return l<0&&(l+=360),["NE","E","SE","S","SW","W","NW","N"][l=parseInt(l/45)]},Dn=function(t,e){var n=t.x,r=t.y;return(n-=e.x)*n+(r-=e.y)*r},In=function(t,e){return Math.sqrt(Dn(t,e))},zn={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},jn=Math.abs,Gn=Math.cos,Un=Math.sin,Hn=Math.sqrt,qn=Math.min,Yn=Math.max,Wn=Math.atan2,Xn=Math.round,$n=Math.pow,Zn=Math.PI,Jn=function(t,e){if(!(this instanceof Jn))return new Jn(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};Jn.fromPolar=function(t,e,n){n=new Jn(n);var r=jn(t*Gn(e)),i=jn(t*Un(e)),o=Ln(On(e));return o<90?i=-i:o<180?(r=-r,i=-i):o<270&&(r=-r),new Jn(n.x+r,n.y+i)},Jn.random=function(t,e,n,r){return new Jn(_n(t,e),_n(n,r))},Jn.prototype={type:zn.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new Jn(t[0]);for(var n=null,r=1/0,i=0;i<e;i++){var o=new Jn(t[i]),a=this.squaredDistance(o);a<r&&(n=o,r=a)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=qn(Yn(this.x,t.x),t.x+t.width),this.y=qn(Yn(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 Bn(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new Jn(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 Jn(this.x-(t||0),this.y-(e||0))},distance:function(t){return In(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,r=this.y;return new Jn((1-e)*n+e*t.x,(1-e)*r+e*t.y)},magnitude:function(){return Hn(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=Nn(new Jn(t).theta(this));return this.offset(Gn(n)*e,-Un(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 Jn(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new Jn(0,0),e=Nn(Ln(-e));var n=Gn(e),r=Un(e),i=n*(this.x-t.x)-r*(this.y-t.y)+t.x,o=r*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=i,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=$n(10,t)}return this.x=Xn(this.x*e)/e,this.y=Xn(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new Jn(n)||new Jn(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=Mn(this.x,t),this.y=Mn(this.y,e||t),this},squaredDistance:function(t){return Dn(this,t)},theta:function(t){var e=-((t=new Jn(t)).y-this.y),n=t.x-this.x,r=Wn(e,n);return r<0&&(r=2*Zn+r),180*r/Zn},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new Jn(t)||new Jn(0,0);var e=this.x,n=this.y;return this.x=Hn((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Nn(t.theta(new Jn(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 Jn(0,0).angleBetween(this,t)}},Jn.prototype.translate=Jn.prototype.offset;var Kn=Jn,Qn=Math.max,tr=Math.min,er=function(t,e){return this instanceof er?t instanceof er?new er(t.start,t.end):(this.start=new Jn(t),void(this.end=new Jn(e))):new er(t,e)};er.prototype={type:zn.Line,angle:function(){var t=new Jn(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=tr(this.start.x,this.end.x),e=tr(this.start.y,this.end.y),n=Qn(this.start.x,this.end.x),r=Qn(this.start.y,this.end.y);return new gr(t,e,n-t,r-e)},bearing:function(){return Bn(this.start,this.end)},clone:function(){return new er(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 er(this.start,t).vector()),n=tr(1,Qn(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 r=this.length();return!(new er(e,t).length()>r)&&!(new er(t,n).length()>r)},divideAt:function(t){var e=this.pointAt(t);return[new er(this.start,e),new er(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new er(this.start,e),new er(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 er&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new Jn(this.end.x-this.start.x,this.end.y-this.start.y),n=new Jn(t.end.x-t.start.x,t.end.y-t.start.y),r=e.x*n.y-e.y*n.x,i=new Jn(t.start.x-this.start.x,t.start.y-this.start.y),o=i.x*n.y-i.y*n.x,a=i.x*e.y-i.y*e.x;if(0===r||o*r<0||a*r<0)return null;if(0<r){if(r<o||r<a)return null}else if(o<r||a<r)return null;return[new Jn(this.start.x+o*e.x/r,this.start.y+o*e.y/r)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return In(this.start,this.end)},midpoint:function(){return new Jn((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,r=e.end,i=n.clone().rotate(r,270),o=r.clone().rotate(n,90);return n.move(o,t),r.move(i,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,r=!0;t<0&&(r=!1,t=-t);var i=this.length();return i<=t?r?n.clone():e.clone():this.pointAt((r?t:i-t)/i)},pointOffset:function(t){t=new Jn(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 Dn(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,r=this.pointAt(t),i=new er(e,n);return i.translate(r.x-e.x,r.y-e.y),i},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,r=this.pointAtLength(t),i=new er(e,n);return i.translate(r.x-e.x,r.y-e.y),i},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 Jn(this.end.x-this.start.x,this.end.y-this.start.y)}},er.prototype.intersection=er.prototype.intersect;var nr=er,rr=Math.sqrt,ir=Math.round,or=Math.pow,ar=function(t,e,n){return this instanceof ar?t instanceof ar?new ar(new Jn(t.x,t.y),t.a,t.b):(t=new Jn(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new ar(t,e,n)};ar.fromRect=function(t){return t=new gr(t),new ar(t.center(),t.width/2,t.height/2)},ar.prototype={type:zn.Ellipse,bbox:function(){return new gr(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new Jn(this.x,this.y)},clone:function(){return new ar(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,r=t.end,i=this.a,o=this.b,a=t.vector(),s=n.difference(new Jn(this)),u=new Jn(a.x/(i*i),a.y/(o*o)),l=new Jn(s.x/(i*i),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=rr(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(r,p)),0<=g&&g<=1&&e.push(n.lerp(r,g))}else{var v=-c/h;if(!(0<=v&&v<=1))return null;e.push(n.lerp(r,v))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new Jn(t),e&&t.rotate(new Jn(this.x,this.y),e);var n,r=t.x-this.x,i=t.y-this.y;if(0===r)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new Jn(this.x,this.y),-e):n;var o=i/r,a=o*o,s=this.a*this.a,u=this.b*this.b,l=rr(1/(1/s+a/u)),h=o*(l=r<0?-l:l);return n=new Jn(this.x+l,this.y+h),e?n.rotate(new Jn(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,r=this.a,i=this.b,o=this.x,a=this.y;return(e-o)*(e-o)/(r*r)+(n-a)*(n-a)/(i*i)},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=or(10,t)}return this.x=ir(this.x*e)/e,this.y=ir(this.y*e)/e,this.a=ir(this.a*e)/e,this.b=ir(this.b*e)/e,this},tangentTheta:function(t){var e,n,r=t.x,i=t.y,o=this.a,a=this.b,s=this.bbox().center(),u=s.x,l=s.y,h=r>s.x+o/2,c=r<s.x-o/2;return h||c?n=o*o/(r-u)-o*o*(i-l)*((e=r>s.x?i-30:i+30)-l)/(a*a*(r-u))+u:e=a*a/(i-l)-a*a*(r-u)*((n=i>s.y?r+30:r-30)-u)/(o*o*(i-l))+l,new Jn(n,e).theta(t)},toString:function(){return new Jn(this.x,this.y).toString()+" "+this.a+" "+this.b}};var sr=ar,ur=Math.abs,lr=Math.cos,hr=Math.sin,cr=Math.min,dr=Math.max,fr=Math.round,pr=Math.pow,gr=function(t,e,n,r){if(!(this instanceof gr))return new gr(t,e,n,r);Object(t)===t&&(e=t.y,n=t.width,r=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===r?0:r};gr.fromEllipse=function(t){return t=new ar(t),new gr(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},gr.fromPointUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var n,r,i,o,a=new Jn;n=r=1/0,i=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),i<u&&(i=u),l<r&&(r=l),o<l&&(o=l)}return new gr(n,r,i-n,o-r)},gr.fromRectUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var n,r,i,o,a=new gr;n=r=1/0,i=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),i<h&&(i=h),l<r&&(r=l),o<c&&(o=c)}return new gr(n,r,i-n,o-r)},gr.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,r=Nn(t),i=ur(hr(r)),o=ur(lr(r)),a=e*o+n*i,s=e*i+n*o;return this.x+=(e-a)/2,this.y+=(n-s)/2,this.width=a,this.height=s,this},bottomLeft:function(){return new Jn(this.x,this.y+this.height)},bottomLine:function(){return new er(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new Jn(this.x+this.width/2,this.y+this.height)},center:function(){return new Jn(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new gr(this)},containsPoint:function(t){return t instanceof Jn||(t=new Jn(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 gr(this).normalize(),n=new gr(t).normalize(),r=e.width,i=e.height,o=n.width,a=n.height;if(!(r&&i&&o&&a))return!1;var s=e.x,u=e.y,l=n.x,h=n.y;return o+=l,r+=s,a+=h,i+=u,s<=l&&o<=r&&u<=h&&a<=i},corner:function(){return new Jn(this.x+this.width,this.y+this.height)},equals:function(t){var e=new gr(this).normalize(),n=new gr(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(),r=t.origin(),i=t.corner();if(i.x<=e.x||i.y<=e.y||r.x>=n.x||r.y>=n.y)return null;var o=dr(e.x,r.x),a=dr(e.y,r.y);return new gr(o,a,cr(n.x,i.x)-o,cr(n.y,i.y)-a)},intersectionWithLine:function(t){var e,n,r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],o=[],a=r.length;for(n=0;n<a;n++)null!==(e=t.intersect(r[n]))&&o.indexOf(e.toString())<0&&(i.push(e),o.push(e.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new Jn(t);var n,r=new Jn(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(r,e);for(var i=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new er(r,t),a=i.length-1;0<=a;--a){var s=i[a].intersection(o);if(null!==s){n=s;break}}return n&&e&&n.rotate(r,-e),n},leftLine:function(){return new er(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new Jn(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,r,i,o,a,s,u,l;t=new gr(t),e||(e=t.center());var h=e.x,c=e.y;n=r=i=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&&(r=(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&&(i=(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:cr(n,r,i,o),sy:cr(a,s,u,l)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return cr(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,r=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,r=-this.height),this.x=t,this.y=e,this.width=n,this.height=r,this},offset:function(t,e){return Jn.prototype.offset.call(this,t,e)},origin:function(){return new Jn(this.x,this.y)},pointNearestToPoint:function(t){if(t=new Jn(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new Jn(this.x+this.width,t.y);case"left":return new Jn(this.x,t.y);case"bottom":return new Jn(t.x,this.y+this.height);case"top":return new Jn(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new er(this.topRight(),this.bottomRight())},rightMiddle:function(){return new Jn(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=pr(10,t)}return this.x=fr(this.x*e)/e,this.y=fr(this.y*e)/e,this.width=fr(this.width*e)/e,this.height=fr(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 Jn(t)).x-this.x,n=this.x+this.width-t.x,r=t.y-this.y,i=e,o="left";return n<i&&(i=n,o="right"),r<i&&(i=r,o="top"),this.y+this.height-t.y<i&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),r=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=r.x-n.x,this.height=r.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new er(this.topLeft(),this.topRight())},topMiddle:function(){return new Jn(this.x+this.width/2,this.y)},topRight:function(){return new Jn(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return gr.fromRectUnion(this,t)},update:function(t,e,n,r){return Object(t)===t&&(e=t.y,n=t.width,r=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=n||0,this.height=r||0,this}},gr.prototype.bottomRight=gr.prototype.corner,gr.prototype.topLeft=gr.prototype.origin,gr.prototype.translate=gr.prototype.offset;var vr=gr;function mr(t){var e=t.trim();if(""===e)return[];for(var n=[],r=e.split(/\b\s*,\s*|,\s*|\s+/),i=r.length,o=0;o<i;o+=2)n.push({x:+r[o],y:+r[o+1]});return n}function yr(t){var e=t.length;if(0===e)return[];for(var n=[],r=0;r<e;r++){var i=t[r].clone();n.push(i)}return n}function br(t){var e,n,r,i=Math.abs,o=t.length;if(0===o)return[];for(e=0;e<o;e++)void 0===r?r=t[e]:t[e].y<r.y?r=t[e]:t[e].y===r.y&&t[e].x>r.x&&(r=t[e]);var a=[];for(e=0;e<o;e++){var s=r.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 x=(g=(p=y.pop())[0]).cross(f,c);if(x<0)y.push(p),y.push(d),y.push(h),b=!0;else if(0===x){var w=f.angleBetween(g,c);i(w-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)):i((w+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 xr=function(t){return this instanceof xr?"string"==typeof t?new xr.parse(t):void(this.points=Array.isArray(t)?t.map(Jn):[]):new xr(t)};xr.parse=function(t){return new xr(mr(t))},xr.fromRect=function(t){return new xr([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},xr.prototype={type:zn.Polyline,bbox:function(){var t=1/0,e=-1/0,n=1/0,r=-1/0,i=this.points,o=i.length;if(0===o)return null;for(var a=0;a<o;a++){var s=i[a],u=s.x,l=s.y;u<t&&(t=u),e<u&&(e=u),l<n&&(n=l),r<l&&(r=l)}return new gr(t,n,e-t,r-n)},clone:function(){return new xr(yr(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),r=n.length;if(0===r)return 0;if(1===r)return 0;for(var i=1/0,o=0,a=r-1,s=0;s<a;s++){var u=new er(n[s],n[s+1]),l=u.length(),h=u.closestPointNormalizedLength(t),c=u.pointAt(h).squaredDistance(t);c<i&&(i=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 r=t.x,i=t.y,o=n-1,a=0,s=0,u=new er,l=new er,h=new Jn;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(i<=c.y&&i>d.y||i>c.y&&i<=d.y){var f=c.x-r>d.x-r?c.x-r:d.x-r;0<=f&&(h.x=r+f,h.y=i,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 xr(br(this.points))},equals:function(t){if(!t)return!1;var e=this.points,n=t.points,r=e.length;if(n.length!==r)return!1;for(var i=0;i<r;i++){var o=e[i],a=t.points[i];if(!o.equals(a))return!1}return!0},intersectionWithLine:function(t){for(var e=new er(t),n=[],r=this.lengthPoints(),i=new er,o=0,a=r.length-1;o<a;o++){i.start=r[o],i.end=r[o+1];var s=e.intersectionWithLine(i);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 er,r=e-1,i=0;i<r;i++)if(n.start=t[i],n.end=t[i+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,r=e-1,i=0;i<r;i++)n+=t[i].distance(t[i+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 r=this.length()*t;return this.pointAtLength(r)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var r=!0;t<0&&(r=!1,t=-t);for(var i=0,o=n-1,a=0;a<o;a++){var s=r?a:o-1-a,u=e[s],l=e[s+1],h=new er(u,l),c=u.distance(l);if(t<=i+c)return h.pointAtLength((r?1:-1)*(t-i));i+=c}return(r?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,r=0;r<n;r++)e[r].round(t);return this},scale:function(t,e,n){for(var r=this.points,i=r.length,o=0;o<i;o++)r[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,r=0;e[r+2];){var i=r+1,o=r+2,a=e[r],s=e[i],u=e[o];new er(a,u).closestPoint(s).distance(s)<=n?e.splice(i,1):r+=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 r,i=!0;t<0&&(i=!1,t=-t);for(var o=0,a=n-1,s=0;s<a;s++){var u=i?s:a-1-s,l=e[u],h=e[u+1],c=new er(l,h),d=l.distance(h);if(c.isDifferentiable()){if(t<=o+d)return c.tangentAtLength((i?1:-1)*(t-o));r=c}o+=d}if(r){var f=i?1:0;return r.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,r=n.length,i=0;i<r;i++)n[i].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",r=0;r<e;r++){var i=t[r];n+=i.x+","+i.y+" "}return n.trim()}},Object.defineProperty(xr.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(xr.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});var wr=Math.abs,Ar=Math.sqrt,Pr=Math.min,Tr=Math.max,Er=Math.pow,Sr=function(t,e,n,r){return this instanceof Sr?t instanceof Sr?new Sr(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new Jn(t),this.controlPoint1=new Jn(e),this.controlPoint2=new Jn(n),void(this.end=new Jn(r))):new Sr(t,e,n,r)};function kr(t){var e,n,r=arguments,i=[];for(n=arguments.length,e=1;e<n;e++)i.push(r[e]);if(!t)throw new Error("Missing a parent object.");var o=Object.create(t);for(n=i.length,e=0;e<n;e++){var a,s,u=i[e];for(s in u)u.hasOwnProperty(s)&&(delete o[s],a=Object.getOwnPropertyDescriptor(u,s),Object.defineProperty(o,s,a))}return o}Sr.throughPoints=function(){function u(t){var e=t.length,n=[],r=[],i=2;n[0]=t[0]/i;for(var o=1;o<e;o++)r[o]=1/i,i=(o<e-1?4:3.5)-r[o],n[o]=(t[o]-n[o-1])/i;for(o=1;o<e;o++)n[e-o-1]-=r[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=[],r=[],i=t.length-1;if(1==i)return n[0]=new Jn((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),r[0]=new Jn(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,r];var o=[];for(e=1;e<i-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[i-1]=(8*t[i-1].x+t[i].x)/2;var a=u(o);for(e=1;e<i-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[i-1]=(8*t[i-1].y+t[i].y)/2;var s=u(o);for(e=0;e<i;e++)n.push(new Jn(a[e],s[e])),e<i-1?r.push(new Jn(2*t[e+1].x-a[e+1],2*t[e+1].y-s[e+1])):r.push(new Jn((t[i].x+a[i-1])/2,(t[i].y+s[i-1])/2));return[n,r]}(t),n=[],r=e[0].length,i=0;i<r;i++){var o=new Jn(e[0][i].x,e[0][i].y),a=new Jn(e[1][i].x,e[1][i].y);n.push(new Sr(t[i],o,a,t[i+1]))}return n}}(),Sr.prototype={type:zn.Curve,bbox:function(){for(var t,e,n,r,i,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,x=new Array,w=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),wr(t)<1e-12){if(wr(e)<1e-12)continue;0<(r=-n/e)&&r<1&&w.push(r)}else s=Ar(a=e*e-4*n*t),a<0||(0<(i=(-e+s)/(2*t))&&i<1&&w.push(i),0<(o=(-e-s)/(2*t))&&o<1&&w.push(o));for(var T,E,S,k=w.length,C=k;k--;)E=(T=1-(r=w[k]))*T*T*d+3*T*T*r*p+3*T*r*r*v+r*r*r*y,A[0][k]=E,S=T*T*T*f+3*T*T*r*g+3*T*r*r*m+r*r*r*b,A[1][k]=S,x[k]={X:E,Y:S};w[C]=0,w[C+1]=1,x[C]={X:d,Y:f},x[C+1]={X:y,Y:b},A[0][C]=d,A[1][C]=f,A[0][C+1]=y,A[1][C+1]=b,w.length=C+2,A[0].length=C+2,A[1].length=C+2,x.length=C+2;var L=Pr.apply(null,A[0]),M=Pr.apply(null,A[1]),O=Tr.apply(null,A[0]),N=Tr.apply(null,A[1]);return new gr(L,M,O-L,N-M)},clone:function(){return new Sr(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,r={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,r),r)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,r={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},i=this.closestPointLength(t,r);if(!i)return 0;var o=this.length(r);return 0===o?0:i/o},closestPointT:function(t,e){for(var n,r,i,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)&&(r=f*d,i=(f+1)*d,o=g,a=v,s=(n=p).start.distance(p.end),u=m)}for(var y=Er(10,-l);;){var b=o?wr(o-a)/o:0,x=a?wr(o-a)/a:0;if(b<y||x<y||(!o||o<s*y||(!a||a<s*y)))return o<=a?r:i;var w=n.divide(.5);d/=2;var A=w[0].start.distance(t),P=w[0].end.distance(t),T=A+P,E=w[1].start.distance(t),S=w[1].end.distance(t);a=T<=E+S?(n=w[0],i-=d,o=A,P):(n=w[1],r+=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,r=this.controlPoint2,i=this.end;if(t<=0)return[new Sr(e,e,e,e),new Sr(e,n,r,i)];if(1<=t)return[new Sr(e,n,r,i),new Sr(i,i,i,i)];var o=this.getSkeletonPoints(t),a=o.startControlPoint1,s=o.startControlPoint2,u=o.divider,l=o.dividerControlPoint1,h=o.dividerControlPoint2;return[new Sr(e,a,s,u),new Sr(u,l,h,i)]},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,r=this.controlPoint2,i=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:r.clone()};if(1<=t)return{startControlPoint1:n.clone(),startControlPoint2:r.clone(),divider:i.clone(),dividerControlPoint1:i.clone(),dividerControlPoint2:i.clone()};var o=new er(e,n).pointAt(t),a=new er(n,r).pointAt(t),s=new er(r,i).pointAt(t),u=new er(o,a).pointAt(t),l=new er(a,s).pointAt(t);return{startControlPoint1:o,startControlPoint2:u,divider:new er(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,r=this.controlPoint1,i=this.controlPoint2,o=this.end,a=[new Sr(n,r,i,o)];if(0===e)return a;if(!this.isDifferentiable())return a;var s=this.endpointDistance(),u=Er(10,-e),l=2;0===r.cross(n,o)&&0===i.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,r=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(r))},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,r=0,i=n.length,o=0;o<i;o++){r+=n[o].endpointDistance()}return r},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,r=e.dividerControlPoint1,i=e.divider,o=new er(n,r);return o.translate(i.x-n.x,i.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,r={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},i=this.length(r)*t;return this.tAtLength(i,r)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var r,i,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){r=v,i=g*f,o=(g+1)*f,a=n?t-c:m+c-t,s=n?m+c-t:t-c;break}c+=m}if(!r)return n?1:0;for(var y=this.length(h),b=Er(10,-u);;){var x,w;if((0!==y?a/y:0)<b)return i;if((0!==y?s/y:0)<b)return o;var A=r.divide(.5);f/=2;var P=A[0].endpointDistance(),T=A[1].endpointDistance();w=a<=P?(r=A[0],o-=f,P-(x=a)):(r=A[1],i+=f,T-(x=a-P)),a=x,s=w}},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,r=[n[0].start.clone()],i=n.length,o=0;o<i;o++){var a=n[o];r.push(a.end.clone())}return r},toPolyline:function(t){return new xr(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}},Sr.prototype.divide=Sr.prototype.divideAtT;var Cr=function(t){if(!(this instanceof Cr))return new Cr(t);if("string"==typeof t)return new Cr.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 r=t[e];this.appendSegment(r)}else{var i=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof er||o instanceof Sr))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(Cr.createSegment("M",o.start)),i&&!i.end.equals(o.start)&&this.appendSegment(Cr.createSegment("M",o.start)),o instanceof er?this.appendSegment(Cr.createSegment("L",o.end)):o instanceof Sr&&this.appendSegment(Cr.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),i=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof er)this.appendSegment(Cr.createSegment("M",t.start)),this.appendSegment(Cr.createSegment("L",t.end));else if(t instanceof Sr)this.appendSegment(Cr.createSegment("M",t.start)),this.appendSegment(Cr.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof xr))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(Cr.createSegment("M",a)):this.appendSegment(Cr.createSegment("L",a))}}else;};function Lr(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}Cr.parse=function(t){if(!t)return new Cr;for(var e=new Cr,n=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),r=n.length,i=0;i<r;i++){var o=n[i].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),a=Cr.createSegment.apply(this,o);e.appendSegment(a)}return e},Cr.createSegment=function(t){var e=arguments;if(!t)throw new Error("Type must be provided.");var n=Cr.segmentTypes[t];if(!n)throw new Error(t+" is not a recognized path segment type.");for(var r=[],i=arguments.length,o=1;o<i;o++)r.push(e[o]);return Lr(n,r)},Cr.prototype={type:zn.Path,appendSegment:functi