jointjs
Version:
JavaScript diagramming library
8 lines (6 loc) • 432 kB
JavaScript
/*! JointJS v3.4.4 (2021-09-27) - 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("lodash"),require("jquery")):"function"==typeof define&&define.amd?define(["exports","backbone","lodash","jquery"],e):e((t=t||self).joint={},t.Backbone,t._,t.$)}(this,function(t,a,i,S){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a,i=i&&i.hasOwnProperty("default")?i.default:i,S=S&&S.hasOwnProperty("default")?S.default:S;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},u=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")(),s=function(t){try{return!!t()}catch(t){return!0}},l=!s(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),o={}.propertyIsEnumerable,c=Object.getOwnPropertyDescriptor,h={f:c&&!o.call({1:2},1)?function(t){var e=c(this,t);return!!e&&e.enumerable}:o},C=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},g={}.toString,d=function(t){return g.call(t).slice(8,-1)},f="".split,w=s(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},m=function(t){return w(p(t))},I=function(t){return"object"==typeof t?null!==t:"function"==typeof t},A=function(t,e){if(!I(t))return t;var i,n;if(e&&"function"==typeof(i=t.toString)&&!I(n=i.call(t)))return n;if("function"==typeof(i=t.valueOf)&&!I(n=i.call(t)))return n;if(!e&&"function"==typeof(i=t.toString)&&!I(n=i.call(t)))return n;throw TypeError("Can't convert object to primitive value")},v={}.hasOwnProperty,y=function(t,e){return v.call(t,e)},b=u.document,N=I(b)&&I(b.createElement),M=function(t){return N?b.createElement(t):{}},x=!l&&!s(function(){return 7!=Object.defineProperty(M("div"),"a",{get:function(){return 7}}).a}),k=Object.getOwnPropertyDescriptor,D={f:l?k:function(t,e){if(t=m(t),e=A(e,!0),x)try{return k(t,e)}catch(t){}if(y(t,e))return C(!h.f.call(t,e),t[e])}},z=function(t){if(!I(t))throw TypeError(String(t)+" is not an object");return t},T=Object.defineProperty,L={f:l?T:function(t,e,i){if(z(t),e=A(e,!0),z(i),x)try{return T(t,e,i)}catch(t){}if("get"in i||"set"in i)throw TypeError("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},j=l?function(t,e,i){return L.f(t,e,C(1,i))}:function(t,e,i){return t[e]=i,t},P=function(e,i){try{j(u,e,i)}catch(t){u[e]=i}return i},Z="__core-js_shared__",G=u[Z]||P(Z,{}),B=Function.toString;"function"!=typeof G.inspectSource&&(G.inspectSource=function(t){return B.call(t)});var O,E,R,Y=G.inspectSource,W=u.WeakMap,U="function"==typeof W&&/native code/.test(Y(W)),F=n(function(t){(t.exports=function(t,e){return G[t]||(G[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),X=0,V=Math.random(),H=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++X+V).toString(36)},J=F("keys"),_=function(t){return J[t]||(J[t]=H(t))},Q={},K=u.WeakMap;if(U){var q=G.state||(G.state=new K),$=q.get,tt=q.has,et=q.set;O=function(t,e){return e.facade=t,et.call(q,t,e),e},E=function(t){return $.call(q,t)||{}},R=function(t){return tt.call(q,t)}}else{var it=_("state");Q[it]=!0,O=function(t,e){return e.facade=t,j(t,it,e),e},E=function(t){return y(t,it)?t[it]:{}},R=function(t){return y(t,it)}}var nt,rt={set:O,get:E,has:R,enforce:function(t){return R(t)?E(t):O(t,{})},getterFor:function(i){return function(t){var e;if(!I(t)||(e=E(t)).type!==i)throw TypeError("Incompatible receiver, "+i+" required");return e}}},ot=n(function(t){var e=rt.get,l=rt.enforce,c=String(String).split("String");(t.exports=function(t,e,i,n){var r,o=!!n&&!!n.unsafe,a=!!n&&!!n.enumerable,s=!!n&&!!n.noTargetGet;"function"==typeof i&&("string"!=typeof e||y(i,"name")||j(i,"name",e),(r=l(i)).source||(r.source=c.join("string"==typeof e?e:""))),t!==u?(o?!s&&t[e]&&(a=!0):delete t[e],a?t[e]=i:j(t,e,i)):a?t[e]=i:P(e,i)})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Y(this)})}),at=u,st=function(t){return"function"==typeof t?t:void 0},lt=function(t,e){return arguments.length<2?st(at[t])||st(u[t]):at[t]&&at[t][e]||u[t]&&u[t][e]},ct=Math.ceil,ut=Math.floor,ht=function(t){return isNaN(t=+t)?0:(0<t?ut:ct)(t)},gt=Math.min,dt=function(t){return 0<t?gt(ht(t),9007199254740991):0},ft=Math.max,pt=Math.min,mt=function(c){return function(t,e,i){var n,r,o,a=m(t),s=dt(a.length),l=(n=s,(r=ht(i))<0?ft(r+n,0):pt(r,n));if(c&&e!=e){for(;l<s;)if((o=a[l++])!=o)return!0}else for(;l<s;l++)if((c||l in a)&&a[l]===e)return c||l||0;return!c&&-1}},It={includes:mt(!0),indexOf:mt(!1)},At=It.indexOf,vt=function(t,e){var i,n=m(t),r=0,o=[];for(i in n)!y(Q,i)&&y(n,i)&&o.push(i);for(;e.length>r;)y(n,i=e[r++])&&(~At(o,i)||o.push(i));return o},Ct=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],wt=Ct.concat("length","prototype"),yt={f:Object.getOwnPropertyNames||function(t){return vt(t,wt)}},bt={f:Object.getOwnPropertySymbols},Nt=lt("Reflect","ownKeys")||function(t){var e=yt.f(z(t)),i=bt.f;return i?e.concat(i(t)):e},Mt=function(t,e){for(var i=Nt(e),n=L.f,r=D.f,o=0;o<i.length;o++){var a=i[o];y(t,a)||n(t,a,r(e,a))}},xt=/#|\.prototype\./,St=function(t,e){var i=Dt[kt(t)];return i==Tt||i!=zt&&("function"==typeof e?s(e):!!e)},kt=St.normalize=function(t){return String(t).replace(xt,".").toLowerCase()},Dt=St.data={},zt=St.NATIVE="N",Tt=St.POLYFILL="P",Lt=St,jt=D.f,Pt=function(t,e){var i,n,r,o,a,s=t.target,l=t.global,c=t.stat;if(i=l?u:c?u[s]||P(s,{}):(u[s]||{}).prototype)for(n in e){if(o=e[n],r=t.noTargetGet?(a=jt(i,n))&&a.value:i[n],!Lt(l?n:s+(c?".":"#")+n,t.forced)&&void 0!==r){if(typeof o==typeof r)continue;Mt(o,r)}(t.sham||r&&r.sham)&&j(o,"sham",!0),ot(i,n,o,t)}},Zt=!!Object.getOwnPropertySymbols&&!s(function(){return!String(Symbol())}),Gt=Zt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Bt=F("wks"),Ot=u.Symbol,Et=Gt?Ot:Ot&&Ot.withoutSetter||H,Rt=function(t){return y(Bt,t)||(Zt&&y(Ot,t)?Bt[t]=Ot[t]:Bt[t]=Et("Symbol."+t)),Bt[t]},Yt=Object.keys||function(t){return vt(t,Ct)},Wt=l?Object.defineProperties:function(t,e){z(t);for(var i,n=Yt(e),r=n.length,o=0;o<r;)L.f(t,i=n[o++],e[i]);return t},Ut=lt("document","documentElement"),Ft="prototype",Xt="script",Vt=_("IE_PROTO"),Ht=function(){},Jt=function(t){return"<script>"+t+"</"+Xt+">"},_t=function(){try{nt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}var t,e;_t=nt?function(t){t.write(Jt("")),t.close();var e=t.parentWindow.Object;return t=null,e}(nt):((e=M("iframe")).style.display="none",Ut.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(Jt("document.F=Object")),t.close(),t.F);for(var i=Ct.length;i--;)delete _t[Ft][Ct[i]];return _t()};Q[Vt]=!0;var Qt=Object.create||function(t,e){var i;return null!==t?(Ht[Ft]=z(t),i=new Ht,Ht[Ft]=null,i[Vt]=t):i=_t(),void 0===e?i:Wt(i,e)},Kt=Rt("unscopables"),qt=Array.prototype;null==qt[Kt]&&L.f(qt,Kt,{configurable:!0,value:Qt(null)});var $t=function(t){qt[Kt][t]=!0},te=Object.defineProperty,ee={},ie=function(t){throw t},ne=function(t,e){if(y(ee,t))return ee[t];e||(e={});var i=[][t],n=!!y(e,"ACCESSORS")&&e.ACCESSORS,r=y(e,0)?e[0]:ie,o=y(e,1)?e[1]:void 0;return ee[t]=!!i&&!s(function(){if(n&&!l)return!0;var t={length:-1};n?te(t,1,{enumerable:!0,get:ie}):t[1]=1,i.call(t,r,o)})},re=It.includes,oe=ne("indexOf",{ACCESSORS:!0,1:0});Pt({target:"Array",proto:!0,forced:!oe},{includes:function(t){return re(this,t,1<arguments.length?arguments[1]:void 0)}}),$t("includes");var ae=function(n,r,t){if(function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function")}(n),void 0===r)return n;switch(t){case 0:return function(){return n.call(r)};case 1:return function(t){return n.call(r,t)};case 2:return function(t,e){return n.call(r,t,e)};case 3:return function(t,e,i){return n.call(r,t,e,i)}}return function(){return n.apply(r,arguments)}},se=Function.call,le=function(t,e,i){return ae(se,u[t].prototype[e],i)},ce=(le("Array","includes"),function(t){return Object(p(t))}),ue=Array.isArray||function(t){return"Array"==d(t)},he=Rt("species"),ge=function(t,e){var i;return ue(t)&&("function"!=typeof(i=t.constructor)||i!==Array&&!ue(i.prototype)?I(i)&&null===(i=i[he])&&(i=void 0):i=void 0),new(void 0===i?Array:i)(0===e?0:e)},de=[].push,fe=function(d){var f=1==d,p=2==d,m=3==d,I=4==d,A=6==d,v=7==d,C=5==d||A;return function(t,e,i,n){for(var r,o,a=ce(t),s=w(a),l=ae(e,i,3),c=dt(s.length),u=0,h=n||ge,g=f?h(t,c):p||v?h(t,0):void 0;u<c;u++)if((C||u in s)&&(o=l(r=s[u],u,a),d))if(f)g[u]=o;else if(o)switch(d){case 3:return!0;case 5:return r;case 6:return u;case 2:de.call(g,r)}else switch(d){case 4:return!1;case 7:de.call(g,r)}return A?-1:m||I?I:g}},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)},me=pe.find,Ie="find",Ae=!0,ve=ne(Ie);Ie in[]&&Array(1)[Ie](function(){Ae=!1}),Pt({target:"Array",proto:!0,forced:Ae||!ve},{find:function(t){return me(this,t,1<arguments.length?arguments[1]:void 0)}}),$t(Ie);le("Array","find");var Ce,we,ye,be=function(s){return function(t,e){var i,n,r=String(p(t)),o=ht(e),a=r.length;return o<0||a<=o?s?"":void 0:(i=r.charCodeAt(o))<55296||56319<i||o+1===a||(n=r.charCodeAt(o+1))<56320||57343<n?s?r.charAt(o):i:s?r.slice(o,o+2):n-56320+(i-55296<<10)+65536}},Ne={codeAt:be(!1),charAt:be(!0)},Me=!s(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),xe=_("IE_PROTO"),Se=Object.prototype,ke=Me?Object.getPrototypeOf:function(t){return t=ce(t),y(t,xe)?t[xe]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?Se:null},De=Rt("iterator"),ze=!1;[].keys&&("next"in(ye=[].keys())?(we=ke(ke(ye)))!==Object.prototype&&(Ce=we):ze=!0);var Te=null==Ce||s(function(){var t={};return Ce[De].call(t)!==t});Te&&(Ce={}),y(Ce,De)||j(Ce,De,function(){return this});var Le={IteratorPrototype:Ce,BUGGY_SAFARI_ITERATORS:ze},je=L.f,Pe=Rt("toStringTag"),Ze=function(t,e,i){t&&!y(t=i?t:t.prototype,Pe)&&je(t,Pe,{configurable:!0,value:e})},Ge={},Be=Le.IteratorPrototype,Oe=function(){return this},Ee=Object.setPrototypeOf||("__proto__"in{}?function(){var i,n=!1,t={};try{(i=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),n=t instanceof Array}catch(t){}return function(t,e){return z(t),function(t){if(!I(t)&&null!==t)throw TypeError("Can't set "+String(t)+" as a prototype")}(e),n?i.call(t,e):t.__proto__=e,t}}():void 0),Re=Le.IteratorPrototype,Ye=Le.BUGGY_SAFARI_ITERATORS,We=Rt("iterator"),Ue="values",Fe="entries",Xe=function(){return this},Ve=Ne.charAt,He="String Iterator",Je=rt.set,_e=rt.getterFor(He);!function(t,e,i,n,r,o,a){var s,l,c;l=n,c=e+" Iterator",(s=i).prototype=Qt(Be,{next:C(1,l)}),Ze(s,c,!1),Ge[c]=Oe;var u,h,g,d=function(t){if(t===r&&A)return A;if(!Ye&&t in m)return m[t];switch(t){case"keys":case Ue:case Fe:return function(){return new i(this,t)}}return function(){return new i(this)}},f=e+" Iterator",p=!1,m=t.prototype,I=m[We]||m["@@iterator"]||r&&m[r],A=!Ye&&I||d(r),v="Array"==e&&m.entries||I;if(v&&(u=ke(v.call(new t)),Re!==Object.prototype&&u.next&&(ke(u)!==Re&&(Ee?Ee(u,Re):"function"!=typeof u[We]&&j(u,We,Xe)),Ze(u,f,!0))),r==Ue&&I&&I.name!==Ue&&(p=!0,A=function(){return I.call(this)}),m[We]!==A&&j(m,We,A),Ge[e]=A,r)if(h={values:d(Ue),keys:o?A:d("keys"),entries:d(Fe)},a)for(g in h)!Ye&&!p&&g in m||ot(m,g,h[g]);else Pt({target:e,proto:!0,forced:Ye||p},h)}(String,"String",function(t){Je(this,{type:He,string:String(t),index:0})},function(){var t,e=_e(this),i=e.string,n=e.index;return n>=i.length?{value:void 0,done:!0}:(t=Ve(i,n),e.index+=t.length,{value:t,done:!1})});var Qe=function(e,t,i,n){try{return n?t(z(i)[0],i[1]):t(i)}catch(t){throw function(t){var e=t.return;if(void 0!==e)z(e.call(t)).value}(e),t}},Ke=Rt("iterator"),qe=Array.prototype,$e=function(t,e,i){var n=A(e);n in t?L.f(t,n,C(0,i)):t[n]=i},ti={};ti[Rt("toStringTag")]="z";var ei="[object z]"===String(ti),ii=Rt("toStringTag"),ni="Arguments"==d(function(){return arguments}()),ri=ei?d:function(t){var e,i,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),ii))?i:ni?d(e):"Object"==(n=d(e))&&"function"==typeof e.callee?"Arguments":n},oi=Rt("iterator"),ai=Rt("iterator"),si=!1;try{var li=0,ci={next:function(){return{done:!!li++}},return:function(){si=!0}};ci[ai]=function(){return this},Array.from(ci,function(){throw 2})}catch(t){}var ui=!function(t,e){if(!e&&!si)return!1;var i=!1;try{var n={};n[ai]=function(){return{next:function(){return{done:i=!0}}}},t(n)}catch(t){}return i}(function(t){Array.from(t)});Pt({target:"Array",stat:!0,forced:ui},{from:function(t){var e,i,n,r,o,a,s,l=ce(t),c="function"==typeof this?this:Array,u=arguments.length,h=1<u?arguments[1]:void 0,g=void 0!==h,d=function(t){if(null!=t)return t[oi]||t["@@iterator"]||Ge[ri(t)]}(l),f=0;if(g&&(h=ae(h,2<u?arguments[2]:void 0,2)),null!=d&&(c!=Array||void 0===(s=d)||Ge.Array!==s&&qe[Ke]!==s))for(o=(r=d.call(l)).next,i=new c;!(n=o.call(r)).done;f++)a=g?Qe(r,h,[n.value,f],!0):n.value,$e(i,f,a);else for(i=new c(e=dt(l.length));f<e;f++)a=g?h(l[f],f):l[f],$e(i,f,a);return i.length=f,i}});at.Array.from;var hi=pe.findIndex,gi="findIndex",di=!0,fi=ne(gi);gi in[]&&Array(1)[gi](function(){di=!1}),Pt({target:"Array",proto:!0,forced:di||!fi},{findIndex:function(t){return hi(this,t,1<arguments.length?arguments[1]:void 0)}}),$t(gi);le("Array","findIndex"),n(function(t,e){!function(){var t=e,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function l(t){this.message=t}(l.prototype=new Error).name="InvalidCharacterError",t.btoa||(t.btoa=function(t){for(var e,i,n=String(t),r=0,o=s,a="";n.charAt(0|r)||(o="=",r%1);a+=o.charAt(63&e>>8-r%1*8)){if(255<(i=n.charCodeAt(r+=.75)))throw new l("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|i}return a}),t.atob||(t.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new l("'atob' failed: The string to be decoded is not correctly encoded.");for(var i,n,r=0,o=0,a="";n=e.charAt(o++);~n&&(i=r%4?64*i+n:n,r++%4)?a+=String.fromCharCode(255&i>>(-2*r&6)):0)n=s.indexOf(n);return a})}()});Pt({target:"Number",stat:!0},{isNaN:function(t){return t!=t}});at.Number.isNaN;var pi=u.isFinite,mi=Number.isFinite||function(t){return"number"==typeof t&&pi(t)};Pt({target:"Number",stat:!0},{isFinite:mi});at.Number.isFinite;var Ii=Rt("match"),Ai=function(t){if(I(e=t)&&(void 0!==(i=e[Ii])?i:"RegExp"==d(e)))throw TypeError("The method doesn't accept regular expressions");var e,i;return t},vi=Rt("match"),Ci=function(e){var i=/./;try{"/./"[e](i)}catch(t){try{return i[vi]=!1,"/./"[e](i)}catch(t){}}return!1};Pt({target:"String",proto:!0,forced:!Ci("includes")},{includes:function(t){return!!~String(p(this)).indexOf(Ai(t),1<arguments.length?arguments[1]:void 0)}});le("String","includes");var wi,yi=D.f,bi="".startsWith,Ni=Math.min,Mi=Ci("startsWith"),xi=!(Mi||(!(wi=yi(String.prototype,"startsWith"))||wi.writable));Pt({target:"String",proto:!0,forced:!xi&&!Mi},{startsWith:function(t){var e=String(p(this));Ai(t);var i=dt(Ni(1<arguments.length?arguments[1]:void 0,e.length)),n=String(t);return bi?bi.call(e,n,i):e.slice(i,i+n.length)===n}});le("String","startsWith");!function(){function n(t,e){return this.slice(t,e)}function r(t,e){arguments.length<2&&(e=0);for(var i=0,n=t.length;i<n;++i,++e)this[e]=255&t[i]}function t(t){var e;if("number"==typeof t){e=new Array(t);for(var i=0;i<t;++i)e[i]=0}else e=t.slice(0);return e.subarray=n,(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 Si=Math.round,ki=Math.floor,Di=Math.PI,zi=function(t){return t%360+(t<0?360:0)},Ti=function(t,e){return e*Si(t/e)},Li=function(t){return 180*t/Di%360},ji=function(t,e){return(t=(e=e||!1)?t:t%360)*Di/180},Pi=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){var i=t;t=e,e=i}return ki(Math.random()*(e-t+1)+t)},Zi=Math.cos,Gi=Math.sin,Bi=Math.atan2,Oi=function(t,e){var i=ji(t.y),n=ji(e.y),r=t.x,o=e.x,a=ji(o-r),s=Gi(a)*Zi(n),l=Zi(i)*Gi(n)-Gi(i)*Zi(n)*Zi(a),c=Li(Bi(s,l))-22.5;return c<0&&(c+=360),["NE","E","SE","S","SW","W","NW","N"][c=parseInt(c/45)]},Ei=function(t,e){var i=t.x,n=t.y;return(i-=e.x)*i+(n-=e.y)*n},Ri=function(t,e){return Math.sqrt(Ei(t,e))},Yi=Math.abs,Wi=Math.cos,Ui=Math.sin,Fi=Math.sqrt,Xi=Math.min,Vi=Math.max,Hi=Math.atan2,Ji=Math.round,_i=Math.pow,Qi=Math.PI,Ki=function(t,e){if(!(this instanceof Ki))return new Ki(t,e);if("string"==typeof t){var i=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(i[0]),e=parseFloat(i[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};Ki.fromPolar=function(t,e,i){i=new Ki(i);var n=Yi(t*Wi(e)),r=Yi(t*Ui(e)),o=zi(Li(e));return o<90?r=-r:o<180?(n=-n,r=-r):o<270&&(n=-n),new Ki(i.x+n,i.y+r)},Ki.random=function(t,e,i,n){return new Ki(Pi(t,e),Pi(i,n))},Ki.prototype={chooseClosest:function(t){var e=t.length;if(1===e)return new Ki(t[0]);for(var i=null,n=1/0,r=0;r<e;r++){var o=new Ki(t[r]),a=this.squaredDistance(o);a<n&&(i=o,n=a)}return i},adhereToRect:function(t){return t.containsPoint(this)||(this.x=Xi(Vi(this.x,t.x),t.x+t.width),this.y=Xi(Vi(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var i=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return i<0&&(i+=360),i},bearing:function(t){return Oi(this,t)},changeInAngle:function(t,e,i){return this.clone().offset(-t,-e).theta(i)-this.theta(i)},clone:function(){return new Ki(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 Ki(this.x-(t||0),this.y-(e||0))},distance:function(t){return Ri(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 i=this.x,n=this.y;return new Ki((1-e)*i+e*t.x,(1-e)*n+e*t.y)},magnitude:function(){return Fi(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return Yi(t.x-this.x)+Yi(t.y-this.y)},move:function(t,e){var i=ji(new Ki(t).theta(this));return this.offset(Wi(i)*e,-Ui(i)*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 Ki(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new Ki(0,0),e=ji(zi(-e));var i=Wi(e),n=Ui(e),r=i*(this.x-t.x)-n*(this.y-t.y)+t.x,o=n*(this.x-t.x)+i*(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=_i(10,t)}return this.x=Ji(this.x*e)/e,this.y=Ji(this.y*e)/e,this},scale:function(t,e,i){return i=i&&new Ki(i)||new Ki(0,0),this.x=i.x+t*(this.x-i.x),this.y=i.y+e*(this.y-i.y),this},snapToGrid:function(t,e){return this.x=Ti(this.x,t),this.y=Ti(this.y,e||t),this},squaredDistance:function(t){return Ei(this,t)},theta:function(t){var e=-((t=new Ki(t)).y-this.y),i=t.x-this.x,n=Hi(e,i);return n<0&&(n=2*Qi+n),180*n/Qi},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new Ki(t)||new Ki(0,0);var e=this.x,i=this.y;return this.x=Fi((e-t.x)*(e-t.x)+(i-t.y)*(i-t.y)),this.y=ji(t.theta(new Ki(e,i))),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 Ki(0,0).angleBetween(this,t)}},Ki.prototype.translate=Ki.prototype.offset;var qi=Ki,$i=Math.max,tn=Math.min,en=function(t,e){return this instanceof en?t instanceof en?new en(t.start,t.end):(this.start=new Ki(t),void(this.end=new Ki(e))):new en(t,e)};en.prototype={angle:function(){var t=new Ki(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=tn(this.start.x,this.end.x),e=tn(this.start.y,this.end.y),i=$i(this.start.x,this.end.x),n=$i(this.start.y,this.end.y);return new mn(t,e,i-t,n-e)},bearing:function(){return Oi(this.start,this.end)},clone:function(){return new en(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 en(this.start,t).vector()),i=tn(1,$i(0,e/this.squaredLength()));return i!=i?0:i},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,i=this.end;if(0!==e.cross(t,i))return!1;var n=this.length();return!(new en(e,t).length()>n)&&!(new en(t,i).length()>n)},divideAt:function(t){var e=this.pointAt(t);return[new en(this.start,e),new en(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new en(this.start,e),new en(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 i=t.intersectionWithLine(this,e);return i&&t instanceof en&&(i=i[0]),i}return null},intersectionWithLine:function(t){var e=new Ki(this.end.x-this.start.x,this.end.y-this.start.y),i=new Ki(t.end.x-t.start.x,t.end.y-t.start.y),n=e.x*i.y-e.y*i.x,r=new Ki(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*i.y-r.y*i.x,a=r.x*e.y-r.y*e.x;if(0===n||o*n<0||a*n<0)return null;if(0<n){if(n<o||n<a)return null}else if(o<n||a<n)return null;return[new Ki(this.start.x+o*e.x/n,this.start.y+o*e.y/n)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Ri(this.start,this.end)},midpoint:function(){return new Ki((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 i=e.start,n=e.end,r=i.clone().rotate(n,270),o=n.clone().rotate(i,90);return i.move(o,t),n.move(r,t),e},pointAt:function(t){var e=this.start,i=this.end;return t<=0?e.clone():1<=t?i.clone():e.lerp(i,t)},pointAtLength:function(t){var e=this.start,i=this.end,n=!0;t<0&&(n=!1,t=-t);var r=this.length();return r<=t?n?i.clone():e.clone():this.pointAt((n?t:r-t)/r)},pointOffset:function(t){t=new Ki(t);var e=this.start,i=this.end;return((i.x-e.x)*(t.y-e.y)-(i.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,i){return this.start.scale(t,e,i),this.end.scale(t,e,i),this},setLength:function(t){var e=this.length();if(!e)return this;var i=t/e;return this.scale(i,i,this.start)},squaredLength:function(){return Ei(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,i=this.end,n=this.pointAt(t),r=new en(e,i);return r.translate(n.x-e.x,n.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,i=this.end,n=this.pointAtLength(t),r=new en(e,i);return r.translate(n.x-e.x,n.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 Ki(this.end.x-this.start.x,this.end.y-this.start.y)}},en.prototype.intersection=en.prototype.intersect;var nn=en,rn=Math.sqrt,on=Math.round,an=Math.pow,sn=function(t,e,i){return this instanceof sn?t instanceof sn?new sn(new Ki(t.x,t.y),t.a,t.b):(t=new Ki(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=i)):new sn(t,e,i)};sn.fromRect=function(t){return t=new mn(t),new sn(t.center(),t.width/2,t.height/2)},sn.prototype={bbox:function(){return new mn(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new Ki(this.x,this.y)},clone:function(){return new sn(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=[],i=t.start,n=t.end,r=this.a,o=this.b,a=t.vector(),s=i.difference(new Ki(this)),l=new Ki(a.x/(r*r),a.y/(o*o)),c=new Ki(s.x/(r*r),s.y/(o*o)),u=a.dot(l),h=a.dot(c),g=h*h-u*(s.dot(c)-1);if(g<0)return null;if(0<g){var d=rn(g),f=(-h-d)/u,p=(-h+d)/u;if((f<0||1<f)&&(p<0||1<p))return null;0<=f&&f<=1&&e.push(i.lerp(n,f)),0<=p&&p<=1&&e.push(i.lerp(n,p))}else{var m=-h/u;if(!(0<=m&&m<=1))return null;e.push(i.lerp(n,m))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new Ki(t),e&&t.rotate(new Ki(this.x,this.y),e);var i,n=t.x-this.x,r=t.y-this.y;if(0===n)return i=this.bbox().pointNearestToPoint(t),e?i.rotate(new Ki(this.x,this.y),-e):i;var o=r/n,a=o*o,s=this.a*this.a,l=this.b*this.b,c=rn(1/(1/s+a/l)),u=o*(c=n<0?-c:c);return i=new Ki(this.x+c,this.y+u),e?i.rotate(new Ki(this.x,this.y),-e):i},normalizedDistance:function(t){var e=t.x,i=t.y,n=this.a,r=this.b,o=this.x,a=this.y;return(e-o)*(e-o)/(n*n)+(i-a)*(i-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=an(10,t)}return this.x=on(this.x*e)/e,this.y=on(this.y*e)/e,this.a=on(this.a*e)/e,this.b=on(this.b*e)/e,this},tangentTheta:function(t){var e,i,n=t.x,r=t.y,o=this.a,a=this.b,s=this.bbox().center(),l=s.x,c=s.y,u=n>s.x+o/2,h=n<s.x-o/2;return u||h?i=o*o/(n-l)-o*o*(r-c)*((e=n>s.x?r-30:r+30)-c)/(a*a*(n-l))+l:e=a*a/(r-c)-a*a*(n-l)*((i=r>s.y?n+30:n-30)-l)/(o*o*(r-c))+c,new Ki(i,e).theta(t)},toString:function(){return new Ki(this.x,this.y).toString()+" "+this.a+" "+this.b}};var ln=sn,cn=Math.abs,un=Math.cos,hn=Math.sin,gn=Math.min,dn=Math.max,fn=Math.round,pn=Math.pow,mn=function(t,e,i,n){if(!(this instanceof mn))return new mn(t,e,i,n);Object(t)===t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===i?0:i,this.height=void 0===n?0:n};mn.fromEllipse=function(t){return t=new sn(t),new mn(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},mn.fromPointUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var i,n,r,o,a=new Ki;i=n=1/0,r=o=-1/0;for(var s=0;s<t.length;s++){a.update(t[s]);var l=a.x,c=a.y;l<i&&(i=l),r<l&&(r=l),c<n&&(n=c),o<c&&(o=c)}return new mn(i,n,r-i,o-n)},mn.fromRectUnion=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(0===t.length)return null;var i,n,r,o,a=new mn;i=n=1/0,r=o=-1/0;for(var s=0;s<t.length;s++){a.update(t[s]);var l=a.x,c=a.y,u=l+a.width,h=c+a.height;l<i&&(i=l),r<u&&(r=u),c<n&&(n=c),o<h&&(o=h)}return new mn(i,n,r-i,o-n)},mn.prototype={bbox:function(t){if(!t)return this.clone();var e=ji(t),i=cn(hn(e)),n=cn(un(e)),r=this.width*n+this.height*i,o=this.width*i+this.height*n;return new mn(this.x+(this.width-r)/2,this.y+(this.height-o)/2,r,o)},bottomLeft:function(){return new Ki(this.x,this.y+this.height)},bottomLine:function(){return new en(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new Ki(this.x+this.width/2,this.y+this.height)},center:function(){return new Ki(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new mn(this)},containsPoint:function(t){return(t=new Ki(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 mn(this).normalize(),i=new mn(t).normalize(),n=e.width,r=e.height,o=i.width,a=i.height;if(!(n&&r&&o&&a))return!1;var s=e.x,l=e.y,c=i.x,u=i.y;return o+=c,n+=s,a+=u,r+=l,s<=c&&o<=n&&l<=u&&a<=r},corner:function(){return new Ki(this.x+this.width,this.y+this.height)},equals:function(t){var e=new mn(this).normalize(),i=new mn(t).normalize();return e.x===i.x&&e.y===i.y&&e.width===i.width&&e.height===i.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(),i=this.corner(),n=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||n.x>=i.x||n.y>=i.y)return null;var o=dn(e.x,n.x),a=dn(e.y,n.y);return new mn(o,a,gn(i.x,r.x)-o,gn(i.y,r.y)-a)},intersectionWithLine:function(t){var e,i,n=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],r=[],o=[],a=n.length;for(i=0;i<a;i++)null!==(e=t.intersect(n[i]))&&o.indexOf(e.toString())<0&&(r.push(e),o.push(e.toString()));return 0<r.length?r:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new Ki(t);var i,n=new Ki(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(n,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new en(n,t),a=r.length-1;0<=a;--a){var s=r[a].intersection(o);if(null!==s){i=s;break}}return i&&e&&i.rotate(n,-e),i},leftLine:function(){return new en(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new Ki(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var i,n,r,o,a,s,l,c;t=new mn(t),e||(e=t.center());var u=e.x,h=e.y;i=n=r=o=a=s=l=c=1/0;var g=t.topLeft();g.x<u&&(i=(this.x-u)/(g.x-u)),g.y<h&&(a=(this.y-h)/(g.y-h));var d=t.bottomRight();d.x>u&&(n=(this.x+this.width-u)/(d.x-u)),d.y>h&&(s=(this.y+this.height-h)/(d.y-h));var f=t.topRight();f.x>u&&(r=(this.x+this.width-u)/(f.x-u)),f.y<h&&(l=(this.y-h)/(f.y-h));var p=t.bottomLeft();return p.x<u&&(o=(this.x-u)/(p.x-u)),p.y>h&&(c=(this.y+this.height-h)/(p.y-h)),{sx:gn(i,n,r,o),sy:gn(a,s,l,c)}},maxRectUniformScaleToFit:function(t,e){var i=this.maxRectScaleToFit(t,e);return gn(i.sx,i.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,i=this.width,n=this.height;return this.width<0&&(t=this.x+this.width,i=-this.width),this.height<0&&(e=this.y+this.height,n=-this.height),this.x=t,this.y=e,this.width=i,this.height=n,this},offset:function(t,e){return Ki.prototype.offset.call(this,t,e)},origin:function(){return new Ki(this.x,this.y)},pointNearestToPoint:function(t){if(t=new Ki(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new Ki(this.x+this.width,t.y);case"left":return new Ki(this.x,t.y);case"bottom":return new Ki(t.x,this.y+this.height);case"top":return new Ki(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new en(this.topRight(),this.bottomRight())},rightMiddle:function(){return new Ki(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=pn(10,t)}return this.x=fn(this.x*e)/e,this.y=fn(this.y*e)/e,this.width=fn(this.width*e)/e,this.height=fn(this.height*e)/e,this},scale:function(t,e,i){return i=this.origin().scale(t,e,i),this.x=i.x,this.y=i.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new Ki(t)).x-this.x,i=this.x+this.width-t.x,n=t.y-this.y,r=e,o="left";return i<r&&(r=i,o="right"),n<r&&(r=n,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var i=this.origin().snapToGrid(t,e),n=this.corner().snapToGrid(t,e);return this.x=i.x,this.y=i.y,this.width=n.x-i.x,this.height=n.y-i.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new en(this.topLeft(),this.topRight())},topMiddle:function(){return new Ki(this.x+this.width/2,this.y)},topRight:function(){return new Ki(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return mn.fromRectUnion(this,t)},update:function(t,e,i,n){return Object(t)===t&&(e=t.y,i=t.width,n=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=i||0,this.height=n||0,this}},mn.prototype.bottomRight=mn.prototype.corner,mn.prototype.topLeft=mn.prototype.origin,mn.prototype.translate=mn.prototype.offset;var In=mn,An=Math.abs,vn=function(t){return this instanceof vn?"string"==typeof t?new vn.parse(t):void(this.points=Array.isArray(t)?t.map(Ki):[]):new vn(t)};vn.parse=function(t){if(""===(t=t.trim()))return new vn;for(var e=[],i=t.split(/\s*,\s*|\s+/),n=i.length,r=0;r<n;r+=2)e.push({x:+i[r],y:+i[r+1]});return new vn(e)},vn.prototype={bbox:function(){var t=1/0,e=-1/0,i=1/0,n=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var a=0;a<o;a++){var s=r[a],l=s.x,c=s.y;l<t&&(t=l),e<l&&(e=l),c<i&&(i=c),n<c&&(n=c)}return new mn(t,i,e-t,n-i)},clone:function(){var t=this.points,e=t.length;if(0===e)return new vn;for(var i=[],n=0;n<e;n++){var r=t[n].clone();i.push(r)}return new vn(i)},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,i=this.points,n=i.length;if(0===n)return 0;if(1===n)return 0;for(var r=1/0,o=0,a=n-1,s=0;s<a;s++){var l=new en(i[s],i[s+1]),c=l.length(),u=l.closestPointNormalizedLength(t),h=l.pointAt(u).squaredDistance(t);h<r&&(r=h,e=o+u*c),o+=c}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var i=this.length();return 0===i?0:e/i},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,i=e.length;if(0===i)return!1;for(var n=t.x,r=t.y,o=i-1,a=0,s=0;a<i;a++){var l=e[o],c=e[a];if(t.equals(l))return!0;var u=new en(l,c);if(u.containsPoint(t))return!0;if(r<=l.y&&r>c.y||r>l.y&&r<=c.y){var h=l.x-n>c.x-n?l.x-n:c.x-n;if(0<=h){var g=new Ki(n+h,r),d=new en(t,g);u.intersect(d)&&s++}}o=a}return s%2==1},convexHull:function(){var t,e,i,n=this.points,r=n.length;if(0===r)return new vn;for(t=0;t<r;t++)void 0===i?i=n[t]:n[t].y<i.y?i=n[t]:n[t].y===i.y&&n[t].x>i.x&&(i=n[t]);var o=[];for(t=0;t<r;t++){var a=i.theta(n[t]);0===a&&(a=360);var s=[n[t],t,a];o.push(s)}if(o.sort(function(t,e){var i=t[2]-e[2];return 0===i&&(i=e[1]-t[1]),i}),2<o.length){var l=o[o.length-1];o.unshift(l)}for(var c,u,h,g,d,f,p,m={},I=[];0!==o.length;)if(u=(c=o.pop())[0],!m.hasOwnProperty(c[0]+"@@"+c[1]))for(var A=!1;!A;)if(I.length<2)I.push(c),A=!0;else{g=(h=I.pop())[0];var v=(f=(d=I.pop())[0]).cross(g,u);if(v<0)I.push(d),I.push(h),I.push(c),A=!0;else if(0===v){var C=g.angleBetween(f,u);An(C-180)<1e-10?(m[h[0]+"@@"+h[1]]=g,I.push(d)):g.equals(u)||f.equals(g)?(m[h[0]+"@@"+h[1]]=g,I.push(d)):An((C+1)%360-1)<1e-10&&(I.push(d),o.push(h))}else m[h[0]+"@@"+h[1]]=g,I.push(d)}2<I.length&&I.pop();var w=-1;for(e=I.length,t=0;t<e;t++){var y=I[t][1];(void 0===p||y<p)&&(p=y,w=t)}var b=[];if(0<w){var N=I.slice(w),M=I.slice(0,w);b=N.concat(M)}else b=I;var x=[];for(e=b.length,t=0;t<e;t++)x.push(b[t][0]);return new vn(x)},equals:function(t){if(!t)return!1;var e=this.points,i=t.points,n=e.length;if(i.length!==n)return!1;for(var r=0;r<n;r++){var o=e[r],a=t.points[r];if(!o.equals(a))return!1}return!0},intersectionWithLine:function(t){for(var e=new en(t),i=[],n=this.points,r=0,o=n.length-1;r<o;r++){var a=n[r],s=n[r+1],l=new en(a,s),c=e.intersectionWithLine(l);c&&i.push(c[0])}return 0<i.length?i:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var i=e-1,n=0;n<i;n++){var r=t[n],o=t[n+1];if(new en(r,o).isDifferentiable())return!0}return!1},length:function(){var t=this.points,e=t.length;if(0===e)return 0;for(var i=0,n=e-1,r=0;r<n;r++)i+=t[r].distance(t[r+1]);return i},pointAt:function(t){var e=this.points,i=e.length;if(0===i)return null;if(1===i)return e[0].clone();if(t<=0)return e[0].clone();if(1<=t)return e[i-1].clone();var n=this.length()*t;return this.pointAtLength(n)},pointAtLength:function(t){var e=this.points,i=e.length;if(0===i)return null;if(1===i)return e[0].clone();var n=!0;t<0&&(n=!1,t=-t);for(var r=0,o=i-1,a=0;a<o;a++){var s=n?a:o-1-a,l=e[s],c=e[s+1],u=new en(l,c),h=l.distance(c);if(t<=r+h)return u.pointAtLength((n?1:-1)*(t-r));r+=h}return(n?e[i-1]:e[0]).clone()},round:function(t){for(var e=this.points,i=e.length,n=0;n<i;n++)e[n].round(t);return this},scale:function(t,e,i){for(var n=this.points,r=n.length,o=0;o<r;o++)n[o].scale(t,e,i);return this},simplify:function(t){void 0===t&&(t={});var e=this.points;if(e.length<3)return this;for(var i=t.threshold||0,n=0;e[n+2];){var r=n+1,o=n+2,a=e[n],s=e[r],l=e[o];new en(a,l).closestPoint(s).distance(s)<=i?e.splice(r,1):n+=1}return this},tangentAt:function(t){var e=this.points.length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),1<t&&(t=1);var i=this.length()*t;return this.tangentAtLength(i)},tangentAtLength:function(t){var e=this.points,i=e.length;if(0===i)return null;if(1===i)return null;var n,r=!0;t<0&&(r=!1,t=-t);for(var o=0,a=i-1,s=0;s<a;s++){var l=r?s:a-1-s,c=e[l],u=e[l+1],h=new en(c,u),g=c.distance(u);if(h.isDifferentiable()){if(t<=o+g)return h.tangentAtLength((r?1:-1)*(t-o));n=h}o+=g}if(n){var d=r?1:0;return n.tangentAt(d)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var i=this.points,n=i.length,r=0;r<n;r++)i[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var i="",n=0;n<e;n++){var r=t[n];i+=r.x+","+r.y+" "}return i.trim()}},Object.defineProperty(vn.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(vn.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});var Cn=Math.abs,wn=Math.sqrt,yn=Math.min,bn=Math.max,Nn=Math.pow,Mn=function(t,e,i,n){return this instanceof Mn?t instanceof Mn?new Mn(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new Ki(t),this.controlPoint1=new Ki(e),this.controlPoint2=new Ki(i),void(this.end=new Ki(n))):new Mn(t,e,i,n)};Mn.throughPoints=function(){function l(t){var e=t.length,i=[],n=[],r=2;i[0]=t[0]/r;for(var o=1;o<e;o++)n[o]=1/r,r=(o<e-1?4:3.5)-n[o],i[o]=(t[o]-i[o-1])/r;for(o=1;o<e;o++)i[e-o-1]-=n[e-o]*i[e-o];return i}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,i=[],n=[],r=t.length-1;if(1==r)return i[0]=new Ki((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new Ki(2*i[0].x-t[0].x,2*i[0].y-t[0].y),[i,n];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=l(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=l(o);for(e=0;e<r;e++)i.push(new Ki(a[e],s[e])),e<r-1?n.push(new Ki(2*t[e+1].x-a[e+1],2*t[e+1].y-s[e+1])):n.push(new Ki((t[r].x+a[r-1])/2,(t[r].y+s[r-1])/2));return[i,n]}(t),i=[],n=e[0].length,r=0;r<n;r++){var o=new Ki(e[0][r].x,e[0][r].y),a=new Ki(e[1][r].x,e[1][r].y);i.push(new Mn(t[r],o,a,t[r+1]))}return i}}(),Mn.prototype={bbox:function(){for(var t,e,i,n,r,o,a,s,l=this.start,c=this.controlPoint1,u=this.controlPoint2,h=this.end,g=l.x,d=l.y,f=c.x,p=c.y,m=u.x,I=u.y,A=h.x,v=h.y,C=new Array,w=new Array,y=[new Array,new Array],b=0;b<2;++b)if(i=0===b?(e=6*g-12*f+6*m,t=-3*g+9*f-9*m+3*A,3*f-3*g):(e=6*d-12*p+6*I,t=-3*d+9*p-9*I+3*v,3*p-3*d),Cn(t)<1e-12){if(Cn(e)<1e-12)continue;0<(n=-i/e)&&n<1&&w.push(n)}else s=wn(a=e*e-4*i*t),a<0||(0<(r=(-e+s)/(2*t))&&r<1&&w.push(r),0<(o=(-e-s)/(2*t))&&o<1&&w.push(o));for(var N,M,x,S=w.length,k=S;S--;)M=(N=1-(n=w[S]))*N*N*g+3*N*N*n*f+3*N*n*n*m+n*n*n*A,y[0][S]=M,x=N*N*N*d+3*N*N*n*p+3*N*n*n*I+n*n*n*v,y[1][S]=x,C[S]={X:M,Y:x};w[k]=0,w[k+1]=1,C[k]={X:g,Y:d},C[k+1]={X:A,Y:v},y[0][k]=g,y[1][k]=d,y[0][k+1]=A,y[1][k+1]=v,w.length=k+2,y[0].length=k+2,y[1].length=k+2,C.length=k+2;var D=yn.apply(null,y[0]),z=yn.apply(null,y[1]),T=bn.apply(null,y[0]),L=bn.apply(null,y[1]);return new mn(D,z,T-D,L-z)},clone:function(){return new Mn(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:i,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:i}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,n),n)},closestPointNormalizedLength:function(t,e){var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:i,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:i}):e.subdivisions},r=this.closestPointLength(t,n);if(!r)return 0;var o=this.length(n);return 0===o?0:r/o},closestPointT:function(t,e){for(var i,n,r,o,a,s,l,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,u=void 0===e.subdivisions?this.getSubdivisions({precision:c}):e.subdivisions,h=u.length,g=h?1/h:0,d=0;d<h;d++){var f=u[d],p=f.start.distance(t),m=f.end.distance(t),I=p+m;(!l||I<l)&&(n=d*g,r=(d+1)*g,o=p,a=m,s=(i=f).start.distance(f.end),l=I)}for(var A=Nn(10,-c);;){var v=o?Cn(o-a)/o:0,C=a?Cn(o-a)/a:0;if(v<A||C<A||(!o||o<s*A||(!a||a<s*A)))return o<=a?n:r;var w=i.divide(.5);g/=2;var y=w[0].start.distance(t),b=w[0].end.distance(t),N=y+b,M=w[1].start.distance(t),x=w[1].end.distance(t);a=N<=M+x?(i=w[0],r-=g,o=y,b):(i=w[1],n+=g,o=M,x)}},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 i=this.tAt(t,e);return this.divideAtT(i)},divideAtLength:function(t,e){var i=this.tAtLength(t,e);return this.divideAtT(i)},divideAtT:function(t){var e=this.start,i=this.controlPoint1,n=this.controlPoint2,r=this.end;if(t<=0)return[new Mn(e,e,e,e),new Mn(e,i,n,r)];if(1<=t)return[new Mn(e,i,n,r),new Mn(r,r,r,r)];var o=this.getSkeletonPoints(t),a=o.startControlPoint1,s=o.startControlPoint2,l=o.divider,c=o.dividerControlPoint1,u=o.dividerControlPoint2;return[new Mn(e,a,s,l),new Mn(l,c,u,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,i=this.controlPoint1,n=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:i.clone(),dividerControlPoint2:n.clone()};if(1<=t)return{startControlPoint1:i.clone(),startControlPoint2:n.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new en(e,i).pointAt(t),a=new en(i,n).pointAt(t),s=new en(n,r).pointAt(t),l=new en(o,a).pointAt(t),c=new en(a,s).pointAt(t);return{startControlPoint1:o,startControlPoint2:l,divider:new en(l,c).pointAt(t),dividerControlPoint1:c,dividerControlPoint2:s}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,i=[new Mn(this.start,this.controlPoint1,this.controlPoint2,this.end)];if(0===e)return i;for(var n=this.endpointDistance(),r=Nn(10,-e),o=0;;){o+=1;for(var a=[],s=i.length,l=0;l<s;l++){var c=i[l].divide(.5);a.push(c[0],c[1])}for(var u=0,h=a.length,g=0;g<h;g++){u+=a[g].endpointDistance()}if(1<o&&(0!==u?(u-n)/u:0)<r)return a;i=a,n=u}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,i=this.controlPoint2,n=this.end;return!(t.equals(e)&&e.equals(i)&&i.equals(n))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,i=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,n=0,r=i.length,o=0;o<r;o++){n+=i[o].endpointDistance()}return n},lengthAtT:function(t,e){if(t<=0)return 0;var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:i})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(1<=t)return this.end.clone();var i=this.tAt(t,e);return this.pointAtT(i)},pointAtLength:function(t,e){var i=this.tAtLength(t,e);return this.pointAtT(i)},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,i){return this.start.scale(t,e,i),this.controlPoint1.scale(t,e,i),this.controlPoint2.scale(t,e,i),this.end.scale(t,e,i),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var i=this.tAt(t,e);return this.tangentAtT(i)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var i=this.tAtLength(t,e);return this.tangentAtT(i)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var e=this.getSkeletonPoints(t),i=e.startControlPoint2,n=e.dividerControlPoint1,r=e.divider,o=new en(i,n);return o.translate(r.x-i.x,r.y-i.y),o},tAt:function(t,e){if(t<=0)return 0;if(1<=t)return 1;var i=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:i,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:i}):e.subdivisions},r=this.length(n)*t;return this.tAtLength(r,n)},tAtLength:function(t,e){var i=!0;t<0&&(i=!1,t=-t);for(var n,r,o,a,s,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,c=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u={precision:l,subdivisions:c},h=0,g=c.length,d=1/g,f=0;f<g;f++){var p=i?f:g-1-f,m=c[f],I=m.endpointDistance();if(t<=h+I){n=m,r=p*d,o=(p+1)*d,a=i?t-h:I+h-t,s=i?I+h-t:t-h;break}h+=I}if(!n)return i?1:0;for(var A=this.length(u),v=Nn(10,-l);;){var C,w;if((0!==A?a/A:0)<v)return r;if((0!==A?s/A:0)<v)return o;var y=n.divide(.5);d/=2;var b=y[0].endpointDistance(),N=y[1].endpointDistance();w=a<=b?(n=y[0],o-=d,b-(C=a)):(n=y[1],r+=d,N-(C=a-b)),a=C,s=w}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,i=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,n=[i[0].start.clone()],r=i.length,o=0;o<r;o++){var a=i[o];n.push(a.end.clone())}return n},toPolyline:function(t){return new vn(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}},Mn.prototype.divide=Mn.prototype.divideAtT;var xn=function(t){if(!(this instanceof xn))return new xn(t);if("string"==typeof t)return new xn.parse(t);var e,i;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(i=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(e=0;e<i;e++){var n=t[e];this.appendSegment(n)}else{var r=null;for(e=0;e<i;e++){var o=t[e];if(!(o instanceof en||o instanceof Mn))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(xn.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(xn.createSegment("M",o.start)),o instanceof en?this.appendSegment(xn.createSegment("L",o.end)):o instanceof Mn&&this.appendSegment(xn.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof en)this.appendSegment(xn.createSegment("M",t.start)),this.appendSegment(xn.createSegment("L",t.end));else if(t instanceof Mn)this.appendSegment(xn.createSegment("M",t.start)),this.appendSegment(xn.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof vn))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(i=t.points.length,e=0;e<i;e++){var a=t.points[e];0===e?this.appendSegment(xn.createSegment("M",a)):this.appendSegment(xn.createSegment("L",a))}}else;};function Sn(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}function kn(t){var e,i,n=arguments,r=[];for(i=arguments.length,e=1;e<i;e++)r.push(n[e]);if(!t)throw new Error("Missing a parent object.");var o=Object.create(t);for(i=r.length,e=0;e<i;e++){var a,s,l=r[e];for(s in l)l.hasOwnProperty(s)&&(delete o[s],a=Object.getOwnPropertyDescriptor(l,s),Object.defineProperty(o,s,a))}return o}xn.parse=function(t){if(!t)return new xn;for(var e=new xn,i=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),n=i.length,r=0;r<n;r++){var o=i[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),a=xn.createSegment.apply(this,o);e.appendSegment(a)}return e},xn.createSegment=function(t){var e=arguments;if(!t)throw new Error("Type must be provided.");var i=xn.segmentTypes[t];if(!i)throw new Error(t+" is not a recognized path segment type.");for(var n=[],r=arguments.length,o=1;o<r;o++)n.push(e[o]);return Sn(i,n)},xn.prototype={appendSegment:function(t){var e,i=this.segments,n=i.length,r=0!==n?i[n-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,a=0;a<o;a++){var s=t[a];e=this.prepareSegment(s,r,null),i.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),i.push(e)}},bbox:function(){var t,e=this.segments,i=e.length;if(0===i)return null;for(var n=0;n<i;n++){var r=e[n];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var a=e[i-1];return new mn(a.end.x,a.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,i=new xn,n=0;n<e;n++){var r=t[n].clone();i.appendSeg