text: /*!
  * image2D - 🍇 使用ECMAScript绘制二维图片。Drawing Two-Dimensional Pictures Using ECMAScript.
  * git+https://github.com/hai2007/image2D.git
  *
  * For online documents, please visit
  * https://hai2007.gitee.io/image2d/index.html
  *
  * author 你好2007
  *
  * version 1.16.4
  *
  * build Thu Apr 11 2019
  *
  * Copyright hai2007 < https://hai2007.gitee.io/sweethome/ >
  * Released under the MIT license
  *
  * Date:Sat Apr 16 2022 19:16:09 GMT+0800 (GMT+08:00)
  */
  
  "use strict";var _typeof=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol==="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};(function(){"use strict";var f=function t(e,r){for(var n in r){try{e[n]=r[n]}catch(t){throw new Error("Illegal property value！")}}return e};var u={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var m={whitespace:"[\\x20\\t\\r\\n\\f]",blank:"[\\n\\f\\r]",identifier:"(?:\\\\.|[\\w-]|[^\0-\\xa0])+"};var a=["href","title","show","type","role","actuate"];function r(t){var e=typeof t==="undefined"?"undefined":_typeof(t);return t!=null&&(e==="object"||e==="function")}var e=Object.prototype.toString;function n(t){if(t==null){return t===undefined?"[object Undefined]":"[object Null]"}return e.call(t)}function t(t){return typeof t==="number"||t!==null&&(typeof t==="undefined"?"undefined":_typeof(t))==="object"&&n(t)==="[object Number]"}function i(t){var e=typeof t==="undefined"?"undefined":_typeof(t);return e==="string"||e==="object"&&t!=null&&!Array.isArray(t)&&n(t)==="[object String]"}function o(t){if(!r(t)){return false}var e=n(t);return e==="[object Function]"||e==="[object AsyncFunction]"||e==="[object GeneratorFunction]"||e==="[object Proxy]"}function l(t){if(t===null||(typeof t==="undefined"?"undefined":_typeof(t))!=="object"||n(t)!="[object Object]"){return false}if(Object.getPrototypeOf(t)===null){return true}var e=t;while(Object.getPrototypeOf(e)!==null){e=Object.getPrototypeOf(e)}return Object.getPrototypeOf(t)===e}var s=function t(e,r){return r!==null&&(typeof r==="undefined"?"undefined":_typeof(r))==="object"&&e.indexOf(r.nodeType)>-1&&!l(r)};var c=r;var h=t;var b=i;var x=o;var d=function t(e){return Array.isArray(e)};var _=function t(e){return s([1,9,11],e)};var v=function t(e){return s([3],e)};var p=function t(e,r){if("innerHTML"in SVGElement.prototype===false||"innerHTML"in SVGSVGElement.prototype===false){var n=document.createElement("div");n.innerHTML=r;var o=function t(e){var r=document.createElementNS(u.svg,e.tagName.toLowerCase());var n=e.attributes;for(var i=0;n&&i<n.length;i++){if(a.indexOf(n[i].nodeName)>=0){r.setAttributeNS(u.xlink,"xlink:"+n[i].nodeName,e.getAttribute(n[i].nodeName))}else{r.setAttribute(n[i].nodeName,e.getAttribute(n[i].nodeName))}}return r};var i=o(n.firstChild);(function t(e,r){var n=e.firstChild;if(v(n)){r.textContent=e.innerText;return}while(n){var i=o(n);r.appendChild(i);if(n.firstChild)t(n,i);n=n.nextSibling}})(n.firstChild,i);e.appendChild(i)}else{e.innerHTML=r}};var g=function t(e,r){var n=void 0,i=void 0,o="div";if(r==="html"||r==="HTML"){if(/^<tr[> ]/.test(e)){o="tbody"}else if(/^<th[> ]/.test(e)||/^<td[> ]/.test(e)){o="tr"}else if(/^<thead[> ]/.test(e)||/^<tbody[> ]/.test(e)){o="table"}n=document.createElement(o);n.innerHTML=e;if(!/</.test(n.innerHTML)){throw new Error("This template cannot be generated using div as a container:"+e+"\nPlease contact us: https://github.com/hai2007/image2D/issues")}}else{n=document.createElementNS(u.svg,"svg");p(n,e)}i=n.childNodes;for(var a=0;a<i.length;a++){if(_(i[a]))return i[a]}};function k(t,e){if(new RegExp("^"+m.identifier+"$").test(t))t="<"+t+"></"+t+">";var r=/^<([^(>| )]+)/.exec(t)[1];if("canvas"===r.toLowerCase())e="HTML";if(!b(e)&&["div","span","p","em","i","table","ul","ol","dl","dt","li","dd","form","input","button","textarea","header","footer","article","section","h1","h2","h3","h4","h5","h6","image","video","iframe","object","style","script","link","tr","td","th","tbody","thead"].indexOf(r.toLowerCase())>=0)e="HTML";return g(t,e)}function w(t,e){if(b(e)||b(t)){t=t.trim().replace(new RegExp(m.blank,"g"),"");if(typeof e=="string"||/^</.test(t)){var r=k(t,e);if(_(r))return[r];else return[]}else if(t==="*"){return e.getElementsByTagName("*")}var n=t.match(new RegExp("#"+m.identifier,"g"));if(n){var i=document.getElementById(n[0].replace("#",""));if(_(i))return[i];else return[]}var o=t.match(new RegExp("\\."+m.identifier,"g")),a=t.match(new RegExp("^"+m.identifier));if(a||o){var f=e.getElementsByTagName(a?a[0]:"*"),u=[];for(var l=0;l<f.length;l++){var s=" "+f[l].getAttribute("class")+" ",c=true;for(var h=0;o&&h<o.length;h++){if(!s.match(" "+o[h].replace(".","")+" ")){c=false;break}}if(c)u.push(f[l])}return u}else{throw new Error("Unsupported selector:"+t)}}else if(_(t)){return[t]}else if(t&&(t.constructor===Array||t.constructor===HTMLCollection||t.constructor===NodeList)){var d=[];for(var v=0;v<t.length;v++){if(_(t[v]))d.push(t[v]);else if(t[v]&&t[v].constructor===T){for(var p=0;p<t[v].length;p++){d.push(t[v][p])}}}return d}else if(t&&t.constructor===T){return t}else if(x(t)){var g=e.getElementsByTagName("*"),w=[];for(var y=0;y<g.length;y++){if(t(g[y]))w.push(g[y])}return w}else{throw new Error("Unknown selector:"+t)}}var T=function t(e,r){return new t.prototype.init(e,r)};T.prototype.init=function(t,e){this.context=e=e||document;var r=w(t,e),n=void 0;for(n=0;n<r.length;n++){this[n]=r[n]}this.length=r.length;return this};T.prototype.extend=T.extend=function(){var t=arguments[0]||{};var e=arguments[1]||{};var r=arguments.length;if(r===1){e=t;t=this}if(!c(t)){t={}}for(var n in e){try{t[n]=e[n]}catch(t){throw new Error("Illegal property key："+n+"！")}}return t};T.prototype.init.prototype=T.prototype;function y(t){var l=t||{},s,n;var i=function t(){var a=[],f=0,u=0;(function t(e,r){if(r>u)u=r;var n;for(n=0;n<e.children.length;n++){t(s[e.children[n]],r+1)}s[e.id].left=r+.5;if(n==0){if(a[r]==undefined)a[r]=-.5;if(a[r-1]==undefined)a[r-1]=-.5;s[e.id].top=a[r]+1;var i=a[r]+1+(s[e.pid].children.length-1)*.5;if(i-1<a[r-1])s[e.id].top=a[r-1]+1-(s[e.pid].children.length-1)*.5}else{s[e.id].top=(s[e.children[0]].top+s[e.children[n-1]].top)*.5}if(s[e.id].top<=a[r]){var o=a[r]+1-s[e.id].top;(function t(e,r){s[e].top+=o;if(a[r]<s[e].top)a[r]=s[e].top;var n;for(n=0;n<s[e].children.length;n++){t(s[e].children[n],r+1)}})(e.id,r)}a[r]=s[e.id].top;if(s[e.id].top+.5>f)f=s[e.id].top+.5})(s[n],0);return{node:s,root:n,size:f,deep:u+1}};var o=function t(o){var a={};var e=l.root(o),f,r;f=r=l.id(e);a[f]={data:e,pid:null,id:f,children:[]};var u=1;(function t(e,r){var n=l.child(e,o),i;u+=n?n.length:0;for(i=0;n&&i<n.length;i++){f=l.id(n[i]);a[r].children.push(f);a[f]={data:n[i],pid:r,id:f,children:[]};t(n[i],f)}})(e,f);return{value:[r,a],num:u}};var e=function t(e){var r=o(e);s=r.value[1];n=r.value[0];if(r.num==1){s[n].left=.5;s[n].top=.5;return{deep:1,node:s,root:n,size:1}}return i()};e.root=function(t){l.root=t;return e};e.child=function(t){l.child=t;return e};e.id=function(t){l.id=t;return e};return e}var M=function t(e,r,n,i,o){var a=Math.cos(n),f=Math.sin(n);return[+((i-e)*a-(o-r)*f+e).toFixed(7),+((i-e)*f+(o-r)*a+r).toFixed(7)]};var E=function t(e,r,n,i,o){var a=Math.sqrt(e*e+r*r);return[+(e*n/a+i).toFixed(7),+(r*n/a+o).toFixed(7)]};var C=function t(e,r,n,i,o){return[+(n*(i-e)+e).toFixed(7),+(n*(o-r)+r).toFixed(7)]};var P=function t(o){o=f({d:[1,1],c:[0,0],p:[0,0]},o);var a={rotate:function t(e){var r=o.d[0]+o.p[0],n=o.d[1]+o.p[1];var i=M(o.p[0],o.p[1],e,r,n);o.d=[i[0]-o.p[0],i[1]-o.p[1]];return a},move:function t(e){o.p=E(o.d[0],o.d[1],e,o.p[0],o.p[1]);return a},scale:function t(e){o.p=C(o.c[0],o.c[1],e,o.p[0],o.p[1]);return a},value:function t(){return o.p}};return a};function S(m){m=f({"begin-deg":0,deg:Math.PI*2},m);var b=y().root(m.root).child(m.child).id(m.id);var e=function t(e){var r=b(e);for(var n in r.node){r.node[n].deep=r.node[n].left-.5}if(m.type==="LR"||m.type==="RL"){var i=m.width/r.deep;if("RL"===m.type)i*=-1;var o=m.height/(r.size- -.5);for(var a in r.node){var f=r.node[a];r.node[a].left=+(("RL"==m.type?m.width:0)- -f.left*i).toFixed(7);r.node[a].top=+(f.top*o).toFixed(7)}}else if(m.type==="TB"||m.type==="BT"){var u=m.height/r.deep;if("BT"==m.type)u*=-1;var l=m.width/(r.size- -.5);var s=void 0,c=void 0;for(var h in r.node){var d=r.node[h];s=d.left;c=d.top;r.node[h].top=+(("BT"==m.type?m.height:0)- -s*u).toFixed(7);r.node[h].left=+(c*l).toFixed(7)}}else if(m.type==="circle"){if(r.deep==1&&r.size==1){r.node[r.root].left=m.cx;r.node[r.root].top=m.cy}else{var v=m.radius/(r.deep-1);var p=m.deg/(r.size- -.5);for(var g in r.node){var w=r.node[g];r.node[g].deg=(m["begin-deg"]- -p*w.top)%(Math.PI*2);var y=M(m.cx,m.cy,r.node[g].deg,m.cx- -v*(w.left-.5),m.cy);r.node[g].left=+y[0];r.node[g].top=+y[1]}}}if(x(m.drawer)){m.drawer(r);return t}else{return r}};e.config=function(t){m=f(m,t);return e};e.drawer=function(t){m.drawer=t;return e};return e}function A(u){u=f({"begin-deg":-Math.PI/2,deg:Math.PI*2,radius:[]},u);if(!x(u.value)){throw new Error("config.value must be a function!")}var e=function t(e){var r=0,n=[],i=0;for(var o in e){n.push({value:u.value(e[o],o,r),data:e[o],key:o,index:r,dots:[]});i+=n[r].value;r+=1}for(r=0;r<n.length;r++){n[r].beginDeg=r===0?u["begin-deg"]:n[r-1].beginDeg+n[r-1].deg;var a=n[r].value/i;n[r].deg=a*u.deg;n[r].percent=new Number(a*100).toFixed(2)}if(h(u.cx)&&h(u.cy)){for(r=0;r<u.radius.length;r++){for(var f=0;f<n.length;f++){n[f].dots.push(M(u.cx,u.cy,n[f].beginDeg+n[f].deg*.5,u.cx+u.radius[r],u.cy))}}}if(x(u.drawer)){u.drawer(n);return t}else{return n}};e.config=function(t){u=f(u,t);return e};e.drawer=function(t){u.drawer=t;return e};return e}function L(t,e,r,n){n=n||0;var i=Math.sqrt(e*e+r*r+n*n);return[1,0,0,0,0,1,0,0,0,0,1,0,e*t/i,r*t/i,n*t/i,1]}function N(t){var e=Math.sin(t),r=Math.cos(t);return[r,e,0,0,-e,r,0,0,0,0,1,0,0,0,0,1]}function I(t,e,r,n,i,o){n=n||0;i=i||0;o=o||0;return[t,0,0,0,0,e,0,0,0,0,r,0,n-n*t,i-i*e,o-o*r,1]}function j(t,e,r,n,i,o){if(typeof t==="number"&&typeof e==="number"){if(typeof r!=="number"){r=0;n=t;i=e;o=1}else if(typeof n!=="number"||typeof i!=="number"||typeof o!=="number"){n=t;i=e;o=r;t=0;e=0;r=0}if(t==n&&e==i&&r==o)throw new Error("It's not a legitimate ray!");var a=Math.sqrt((n-t)*(n-t)+(i-e)*(i-e)),f=a!=0?(i-e)/a:1,u=a!=0?(n-t)/a:0,l=(n-t)*u+(i-e)*f,s=o-r,c=Math.sqrt(l*l+s*s),h=c!=0?s/c:1,d=c!=0?l/c:0;return[[f,h*u,u*d,0,-u,f*h,f*d,0,0,-d,h,0,e*u-t*f,r*d-t*u*h-e*f*h,-t*u*d-e*f*d-r*h,1],[f,-u,0,0,h*u,h*f,-d,0,u*d,f*d,h,0,t,e,r,1]]}else{throw new Error("a1 and b1 is required!")}}var D=function t(e,r){var n=[];for(var i=0;i<4;i++){for(var o=0;o<r.length/4;o++){n[o*4+i]=e[i]*r[o*4]+e[i+4]*r[o*4+1]+e[i+8]*r[o*4+2]+e[i+12]*r[o*4+3]}}return n};function R(t){var l=t||[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var s={move:function t(e,r,n,i){l=D(L(e,r,n,i),l);return s},rotate:function t(e,r,n,i,o,a,f){var u=j(r,n,i,o,a,f);l=D(D(D(u[1],N(e)),u[0]),l);return s},scale:function t(e,r,n,i,o,a){l=D(I(e,r,n,i,o,a),l);return s},multiply:function t(e,r){l=r?D(l,e):D(e,l);return s},use:function t(e,r,n,i){n=n||0;i=i||1;var o=D(l,[e,r,n,i]);o[0]=+o[0].toFixed(7);o[1]=+o[1].toFixed(7);o[2]=+o[2].toFixed(7);o[3]=+o[3].toFixed(7);return o},value:function t(){return l}};return s}var F=[];var z=13;var H=400;var B=null;function O(e,t,r){if(arguments.length<2)t=H;var u={timer:function t(e,r,n){if(!e){throw new Error("Tick is required!")}var i=(new Date).valueOf()+"_"+(Math.random()*1e3).toFixed(0);F.push({id:i,createTime:new Date,tick:e,duration:r,callback:n});u.start();return i},start:function t(){if(!B){B=setInterval(u.tick,z)}},tick:function t(){var e,r,t,n,i,o,a,f=F;F=[];F.length=0;for(r=0;r<f.length;r++){i=f[r];e=i.createTime;t=i.tick;o=i.duration;n=i.callback;a=(+new Date-e)/o;a=a>1?1:a;t(a);if(a<1&&i.id){F.push(i)}else if(n){n(a)}}if(F.length<=0){u.stop()}},stop:function t(){if(B){clearInterval(B);B=null}}};var n=u.timer(function(t){e(t)},t,r);return function(){var t;for(t in F){if(F[t].id==n){F[t].id=undefined;return}}}}function W(t,e){for(var r in e){try{t[r]=e[r]}catch(t){throw new Error("Illegal property value！")}}return t}function G(u){u=W({u:.5},u);var l,s,c;var h=function t(e){if(l){var r=(e-s)/(c-s),n=r*r,i=r*n;var o=i*l[0]+n*l[1]+r*l[2]+l[3];return o*(c-s)}else throw new Error("You shoud first set the position!")};h.setP=function(t,e,r,n,i,o){if(t<r){s=t;c=r;var a=u.u*i,f=u.u*o;e/=r-t;n/=r-t;l=[2*e-2*n+a+f,3*n-3*e-2*a-f,a,e]}else throw new Error("The point x-position should be increamented!");return h};return h}function $(e,t,r,n){if(!x(r)){n=r;r=false}var i={ease:[.25,.1,.5,1],"ease-in":[.5,0,.75,.6],"ease-in-out":[.43,.01,.58,1],"ease-out":[.25,.6,.5,1],linear:"default"}[n]||n;var o=function t(e){return e};if(i&&d(i)&&i.length==4){o=G({u:1}).setP(0,0,1,1,i[1]/i[0],(1-i[3])/(1-i[2]))}return O(function(t){e(o(t))},t,function(t){if(x(r)){if(t!=1)t=o(t);r(t)}})}function V(i){i=f({t:0},i);var o=void 0,r=void 0;var a=function t(e){if(o){r=-1;while(r+1<o.x.length&&(e>o.x[r+1]||r==-1&&e>=o.x[r+1])){r+=1}if(r==-1||r>=o.h.length)throw new Error("Coordinate crossing!");return o.h[r](e)}else{throw new Error("You shoud first set the position!")}};a.setT=function(t){if(typeof t==="number"){i.t=t}else{throw new Error("Expecting a figure!")}return a};a.setP=function(t){o={x:[],h:[]};var e=void 0,r=(t[1][1]-t[0][1])/(t[1][0]-t[0][0]),n=void 0;o.x[0]=t[0][0];for(e=1;e<t.length;e++){if(t[e][0]<=t[e-1][0])throw new Error("The point position should be increamented!");o.x[e]=t[e][0];n=e<t.length-1?(t[e+1][1]-t[e-1][1])/(t[e+1][0]-t[e-1][0]):(t[e][1]-t[e-1][1])/(t[e][0]-t[e-1][0]);o.h[e-1]=G({u:(1-i.t)*.5}).setP(t[e-1][0],t[e-1][1],t[e][0],t[e][1],r,n);r=n}return a};return a}function q(t,e){var r=document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(t,null):t.currentStyle;return b(e)?r.getPropertyValue(e):r}var U=function t(e){var r=document.getElementsByTagName("head")[0];r.style["color"]=e;var n=q(r,"color");var i=n.replace(/^rgba?\(([^)]+)\)$/,"$1").split(new RegExp("\\,"+m.whitespace));return[+i[0],+i[1],+i[2],i[3]==undefined?1:+i[3]]};var X=function t(e,r){if(!(r&&r>=0&&r<=1))r=1;var n=[];for(var i=1;i<=e;i++){n.push("rgba("+(Math.random(1)*230+20).toFixed(0)+","+(Math.random(1)*230+20).toFixed(0)+","+(Math.random(1)*230+20).toFixed(0)+","+r+")")}return n};var Y=function t(e,r){if(!(r&&r>=0&&r<=1))r=1;var n=["rgba(84,112,198,"+r+")","rgba(145,204,117,"+r+")","rgba(250,200,88,"+r+")","rgba(238,102,102,"+r+")","rgba(115,192,222,"+r+")","rgba(59,162,114,"+r+")","rgba(252,132,82,"+r+")","rgba(154,96,180,"+r+")","rgba(234,124,204,"+r+")"];var i=[];if(e<=n.length){return n}else{if(e%n.length==0){for(var o=0;o<e/n.length;o++){i=i.concat(n)}}else{for(var a=1;a<e/n.length;a++){i=i.concat(n)}if(e%n.length==1){i=i.concat(n[4])}else{for(var f=0;f<e%n.length;f++){i=i.concat(n[f])}}}}return i};var Z=function t(e,r){if(window.attachEvent){for(var n=0;n<this.length;n++){this[n].attachEvent("on"+e,r)}}else{for(var i=0;i<this.length;i++){this[i].addEventListener(e,r,false)}}return this};var Q=function t(e,r){if(window.detachEvent){for(var n=0;n<this.length;n++){this[n].detachEvent("on"+e,r)}}else{for(var i=0;i<this.length;i++){this[i].removeEventListener(e,r,false)}}return this};var J=function t(e){var r=this[0].getBoundingClientRect();if(!e||!e.clientX)throw new Error("Event is necessary!");return{x:e.clientX-r.left,y:e.clientY-r.top}};var K=function t(e){e=e||window.event;if(e.stopPropagation){e.stopPropagation()}else{e.cancelBubble=true}return this};var tt=function t(e){e=e||window.event;if(e.preventDefault){e.preventDefault()}else{e.returnValue=false}return this};var et=function t(e,r,n,i){var o=Math.cos(e),a=Math.sin(e);return[r,n*o-i*a,n*a+i*o]},rt=function t(e,r,n,i){var o=Math.cos(e),a=Math.sin(e);return[i*a+r*o,n,i*o-r*a]},nt=function t(e,r,n,i){var o=Math.cos(e),a=Math.sin(e);return[r*o-n*a,r*a+n*o,i]};var it=[];function ot(t,e,r){it=rt((360-r)/180*Math.PI,100*t.scale,0,0);it=nt(e/180*Math.PI,it[0],it[1],it[2]);it=nt((90-t.center[0])/180*Math.PI,it[0],it[1],it[2]);it=et((90-t.center[1])/180*Math.PI,it[0],it[1],it[2]);return[-it[0],it[1],it[2]]}function at(t){var n=f({type:"eoap",scale:1,center:[107,36]},t);var e=function t(e,r){switch(n.type){case"eoap":{return ot(n,e,r)}default:{throw new Error("Map type configuration error!")}}};e.config=function(t){n=f(n,t);return e};return e}function ft(t,e,r){if(t<e){var n=e;e=t;t=n}else if(t==e){return[t]}var i=(t+".").split(".")[1].length;var o=(e+".").split(".")[1].length;var a=i>o?i:o;var f=function(t){var e=t<100&&t>-100?10:.1;var r=1,n=t;while(e==10?n>=-100&&n<=100:n<=-100||n>=100){r*=e;n*=e}return r}(t-e);var u=+(Math.ceil((t-e)*f/r)/f).toFixed(a);if(u<=0)return[e,t];var l=Math.floor(e/u)*u;var s=[],c;s.push(l);for(c=1;s[s.length-1]<t;c++){s.push(+(l+u*c).toFixed(a))}s[0]=+l.toFixed(a);var h=[s[0]];for(var d=1;d<s.length;d++){if(h[h.length-1]!=s[d]){h.push(s[d])}}return h}function ut(t,e){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5;var n=ft(t,e,r);return{min:n[0],max:n[n.length-1],distance:n.length<=1?0:n[1]-n[0],num:n.length-1,ruler:n}}var lt=function t(e,r){var n=w(e,r||document);if(n.length>0){for(var i=0;i<this.length;i++){n[0].appendChild(this[i])}}else{throw new Error("Target empty!")}return this};var st=function t(e,r){var n=w(e,r||document);if(n.length>0){for(var i=0;i<this.length;i++){n[0].insertBefore(this[i],n[0].childNodes[0])}}else{throw new Error("Target empty!")}return this};var ct=function t(e,r){var n=w(e,r||document);if(n.length>0){for(var i=0;i<this.length;i++){n[0].parentNode.insertBefore(this[i],n[0].nextSibling)}}else{throw new Error("Target empty!")}return this};var ht=function t(e,r){var n=w(e,r||document);if(n.length>0){for(var i=0;i<this.length;i++){n[0].parentNode.insertBefore(this[i],n[0])}}else{throw new Error("Target empty!")}return this};var dt=function t(){for(var e=0;e<this.length;e++){this[e].parentNode.removeChild(this[e])}return this};var vt=function t(e){var r=[];for(var n=0;n<this.length;n++){if(e(n,T(this[n])))r.push(this[n])}return T(r)};var pt=function t(e){if(arguments.length>0){for(var r=0;r<this.length;r++){this[r].textContent=e}return this}if(this.length<=0)throw new Error("Target empty!");return this[0].textContent};var gt=function t(e){if(arguments.length>0){for(var r=0;r<this.length;r++){if(/[a-z]/.test(this[r].tagName)){p(this[r],e)}else{this[r].innerHTML=e}}return this}if(this.length<=0)throw new Error("Target empty!");return this[0].innerHTML};var wt=function t(e){if(this.length<=0)throw new Error("Target empty!");var r=void 0,n=void 0,i=this[0];if(e=="content"){n=i.clientWidth-(q(i,"padding-left")+"").replace("px","")-(q(i,"padding-right")+"").replace("px","");r=i.clientHeight-(q(i,"padding-top")+"").replace("px","")-(q(i,"padding-bottom")+"").replace("px","")}else if(e=="padding"){n=i.clientWidth;r=i.clientHeight}else if(e=="border"){n=i.offsetWidth;r=i.offsetHeight}else if(e=="scroll"){n=i.scrollWidth;r=i.scrollHeight}else{n=i.offsetWidth;r=i.offsetHeight}return{width:n,height:r}};function yt(){if(arguments.length<=1&&(arguments.length<=0||_typeof(arguments[0])!=="object")){if(this.length<=0)throw new Error("Target empty!");return q(this[0],arguments[0])}for(var t=0;t<this.length;t++){if(arguments.length===1){for(var e in arguments[0]){this[t].style[e]=arguments[0][e]}}else this[t].style[arguments[0]]=arguments[1]}return this}var mt=function t(e,r,n){if(/[a-z]/.test(e.tagName)&&a.indexOf(r)>=0){e.setAttributeNS(u.xlink,"xlink:"+r,n)}else e.setAttribute(r,n)};function bt(){if(arguments.length===1&&_typeof(arguments[0])!=="object"){if(this.length<=0)throw new Error("Target empty!");return this[0].getAttribute(arguments[0])}else if(arguments.length>0){for(var t=0;t<this.length;t++){if(arguments.length===1){for(var e in arguments[0]){mt(this[t],e,arguments[0][e])}}else mt(this[t],arguments[0],arguments[1])}}return this}var xt=function t(e,r){if(arguments.length<=0){if(this.length<=0)throw new Error("Target empty!");return this[0].__data__}for(var n=0;n<this.length;n++){this[n].__data__=typeof r==="function"?r(e,n):e}return this};var _t=function t(e,r){if(arguments.length<=0){var n=[];for(var i=0;i<this.length;i++){n[i]=this[i].__data__}return n}var o=[],a=void 0;for(a=0;a<this.length&&a<e.length;a++){this[a].__data__=typeof r==="function"?r(e[a],a):e[a];o.push(this[a])}var f=T(o);f.__enter__=[];for(;a<e.length;a++){f.__enter__.push(typeof r==="function"?r(e[a],a):e[a])}f.__exit__=[];for(;a<this.length;a++){f.__exit__.push(this[a])}return f};var kt=function t(e,r){if(!this.__enter__||this.__enter__.constructor!==Array)throw new Error("Not a data node object to be balanced!");var n=[];for(var i=0;i<this.__enter__.length;i++){n[i]=k(e,r);n[i].__data__=this.__enter__[i]}delete this.__enter__;return T(n)};var Tt=function t(){if(!this.__exit__||this.__exit__.constructor!==Array)throw new Error("Not a data node object to be balanced!");var e=T(this.__exit__);delete this.__exit__;return e};var Mt=function t(e){for(var r=0;r<this.length;r++){e(this[r].__data__,r,T(this[r]))}return this};function Et(t,e,r,n,i,o,a){if(e<0){t+=e;e*=-1}var f=[],u=void 0;u=M(0,0,t,i,0);f[0]=u[0];f[1]=u[1];u=M(0,0,e,u[0],u[1]);f[2]=u[0];f[3]=u[1];u=M(0,0,t,o,0);f[4]=u[0];f[5]=u[1];u=M(0,0,e,u[0],u[1]);f[6]=u[0];f[7]=u[1];a(t,t+e,f[0]+r,f[1]+n,f[4]+r,f[5]+n,f[2]+r,f[3]+n,f[6]+r,f[7]+n,(o-i)*.5)}var Ct=function t(e,r,n,i,o){e.beginPath();e.translate(n,i);e.rotate(o);e.font=r["font-size"]+"px "+r["font-family"];return e};var Pt=function t(c,h,d,v,p,g,e,r){if(p>g){var n=p;p=g;g=n}e=e%(Math.PI*2);if(r>=Math.PI*1.999999||r<=-Math.PI*1.999999){r=Math.PI*2}else{r=r%(Math.PI*2)}Et(e,r,d,v,p,g,function(t,e,r,n,i,o,a,f,u,l,s){if(s<0)s=-s;c.beginPath();c.moveTo(r,n);c.arc(d,v,p,t,e,false);if(h["arc-end-cap"]=="round")c.arc((a+u)*.5,(f+l)*.5,s,e-Math.PI,e,true);else if(h["arc-end-cap"]=="-round")c.arc((a+u)*.5,(f+l)*.5,s,e-Math.PI,e,false);else c.lineTo(u,l);c.arc(d,v,g,e,t,true);if(h["arc-start-cap"]=="round")c.arc((r+i)*.5,(n+o)*.5,s,t,t-Math.PI,true);else if(h["arc-start-cap"]=="-round")c.arc((r+i)*.5,(n+o)*.5,s,t,t-Math.PI,false);else c.lineTo(r,n)});if(h["arc-start-cap"]=="butt")c.closePath();return c};var St=function t(e,r,n,i){e.beginPath();e.moveTo(r+i,n);e.arc(r,n,i,0,Math.PI*2);return e};var At=function t(e,r,n,i,o){e.beginPath();e.rect(r,n,i,o);return e};var Lt=function t(e,r,n,i,o){var a=e.createLinearGradient(r,n,i,o);var f={value:function t(){return a},addColorStop:function t(e,r){a.addColorStop(e,r);return f}};return f};var Nt=function t(e,r,n,i){var o=e.createRadialGradient(r,n,0,r,n,i);var a={value:function t(){return o},addColorStop:function t(e,r){o.addColorStop(e,r);return a}};return a};function It(s,t){var c=s.getContext("2d");var e=s.__image2D__layer__=="yes";var r=e?s.getAttribute("width"):s.clientWidth,n=e?s.getAttribute("height"):s.clientHeight;if(r==0||n==0){if(!t)console.warn("Canvas is hidden or size is zero!");if(s.__image2D__noLayer_getSize__=="yes"){r=s.width/2;n=s.height/2}else{r=s.width;n=s.height;s.__image2D__noLayer_getSize__="yes"}}s.style.width=r+"px";s.style.height=n+"px";s.setAttribute("width",r*2);s.setAttribute("height",n*2);c.scale(2,2);c.textBaseline="middle";c.textAlign="left";var f={"font-size":"16","font-family":"sans-serif","arc-start-cap":"butt","arc-end-cap":"butt"};var i=function t(e,r){if(e=="lineDash"){try{c.setLineDash(r)}catch(t){console.error(t)}}else if(f[e]){f[e]=r}else{c[e]=r}};var h={config:function t(){if(arguments.length===1){if(_typeof(arguments[0])!=="object")return c[arguments[0]];for(var e in arguments[0]){i(e,arguments[0][e])}}else if(arguments.length===2){i(arguments[0],arguments[1])}return h},fillText:function t(e,r,n,i){c.save();Ct(c,f,r,n,i||0).fillText(e,0,0);c.restore();return h},strokeText:function t(e,r,n,i){c.save();Ct(c,f,r,n,i||0).strokeText(e,0,0);c.restore();return h},fullText:function t(e,r,n,i){c.save();Ct(c,f,r,n,i||0);c.fillText(e,0,0);c.strokeText(e,0,0);c.restore();return h},beginPath:function t(){c.beginPath();return h},closePath:function t(){c.closePath();return h},moveTo:function t(e,r){c.moveTo(e,r);return h},lineTo:function t(e,r){c.lineTo(e,r);return h},arc:function t(e,r,n,i,o){c.arc(e,r,n,i,i+o,o<0);return h},fill:function t(){c.fill();return h},stroke:function t(){c.stroke();return h},full:function t(){c.fill();c.stroke();return h},save:function t(){c.save();return h},restore:function t(){c.restore();return h},quadraticCurveTo:function t(e,r,n,i){c.quadraticCurveTo(e,r,n,i);return h},bezierCurveTo:function t(e,r,n,i,o,a){c.bezierCurveTo(e,r,n,i,o,a);return h},clearRect:function t(e,r,n,i){c.clearRect(e||0,r||0,n||s.getAttribute("width")/2,i||s.getAttribute("height")/2);return h},toDataURL:function t(){return s.toDataURL()},drawImage:function t(e,r,n,i,o,a,f,u,l){r=r||0;n=n||0;a=a||0;f=f||0;u=u?u*2:s.getAttribute("width");l=l?l*2:s.getAttribute("height");if(e.nodeName=="CANVAS"){u=u/2;l=l/2;i=i?i*2:s.getAttribute("width");o=o?o*2:s.getAttribute("height")}else{i=(i||e.width)*2;o=(o||e.height)*2}c.drawImage(e,r,n,i,o,a,f,u,l);return h},fillArc:function t(e,r,n,i,o,a){Pt(c,f,e,r,n,i,o,a).fill();return h},strokeArc:function t(e,r,n,i,o,a){Pt(c,f,e,r,n,i,o,a).stroke();return h},fullArc:function t(e,r,n,i,o,a){Pt(c,f,e,r,n,i,o,a);c.fill();c.stroke();return h},fillCircle:function t(e,r,n){St(c,e,r,n).fill();return h},strokeCircle:function t(e,r,n){St(c,e,r,n).stroke();return h},fullCircle:function t(e,r,n){St(c,e,r,n);c.fill();c.stroke();return h},fillRect:function t(e,r,n,i){At(c,e,r,n,i).fill();return h},strokeRect:function t(e,r,n,i){At(c,e,r,n,i).stroke();return h},fullRect:function t(e,r,n,i){At(c,e,r,n,i);c.fill();c.stroke();return h},createLinearGradient:function t(e,r,n,i){return Lt(c,e,r,n,i)},createRadialGradient:function t(e,r,n){return Nt(c,e,r,n)},translate:function t(e,r){c.translate(e,r);return h},rotate:function t(e){c.rotate(e);return h},scale:function t(e,r){r=r||e;c.scale(e,r);return h}};return h}function jt(t,e){if(t==="textAlign"){return{left:"start",right:"end",center:"middle"}[e]||e}return e}var Dt=function t(e,r,n,i,o){if(!e||e.length<=0||e[0].nodeName.toLowerCase()!=="text")throw new Error("Need a <text> !");o=o%(Math.PI*2);e.attr("dy",{top:r["font-size"]*.5,middle:0,bottom:-r["font-size"]*.5}[r.textBaseline]).css({"text-anchor":r.textAlign,"dominant-baseline":"central","font-size":r["font-size"]+"px","font-family":r["font-family"]}).attr({x:n,y:i});return{transform:"rotate("+o*180/Math.PI+","+n+","+i+")"}};var Rt=function t(d,v,e,r,p,g,n,i){if(!d||d.length<=0||d[0].nodeName.toLowerCase()!=="path")throw new Error("Need a <path> !");n=n%(Math.PI*2);if(p>g){var o=p;p=g;g=o}if(i>=Math.PI*1.999999||i<=-Math.PI*1.999999){i=Math.PI*1.999999}else{i=i%(Math.PI*2)}Et(n,i,e,r,p,g,function(t,e,r,n,i,o,a,f,u,l,s){var c=e-t>Math.PI?1:0,h="M"+r+" "+n;if(s<0)s=-s;h+="A"+p+" "+p+" 0 "+c+" 1 "+a+" "+f;if(v["arc-end-cap"]=="round")h+="A"+s+" "+s+" "+" 0 1 0 "+u+" "+l;else if(v["arc-end-cap"]=="-round")h+="A"+s+" "+s+" "+" 0 1 1 "+u+" "+l;else h+="L"+u+" "+l;h+="A"+g+" "+g+" 0 "+c+" 0 "+i+" "+o;if(v["arc-start-cap"]=="round")h+="A"+s+" "+s+" "+" 0 1 0 "+r+" "+n;else if(v["arc-start-cap"]=="-round")h+="A"+s+" "+s+" "+" 0 1 1 "+r+" "+n;else h+="L"+r+" "+n;if(v["arc-start-cap"]=="butt")h+="Z";d.attr("d",h)});return d};var Ft=function t(e,r,n,i){if(!e||e.length<=0||e[0].nodeName.toLowerCase()!=="circle")throw new Error("Need a <circle> !");e.attr({cx:r,cy:n,r:i});return e};var zt=function t(e,r){if(!e||e.length<=0||e[0].nodeName.toLowerCase()!=="path")throw new Error("Need a <path> !");e.attr("d",r);return e};var Ht=function t(e,r,n,i,o){if(!e||e.length<=0||e[0].nodeName.toLowerCase()!=="rect")throw new Error("Need a <rect> !");if(o<0){o*=-1;n-=o}if(i<0){i*=-1;r-=i}e.attr({x:r,y:n,width:i,height:o});return e};var Bt=function t(e){var r=e.getElementsByTagName("defs");if(r.length<=0){r=[k("<defs>","SVG")];e.appendChild(r[0])}return r[0]};var Ot=function t(e,r,n,i,o,a){var f=Bt(r);var u="image2D-lg-"+(new Date).valueOf()+"-"+Math.random();var l=k('<linearGradient id="'+u+'" x1="'+n+'%" y1="'+i+'%" x2="'+o+'%" y2="'+a+'%"></linearGradient>');f.appendChild(l);var s={value:function t(){return"url(#"+u+")"},addColorStop:function t(e,r){l.appendChild(k('<stop offset="'+e*100+'%" style="stop-color:'+r+';" />'));return s}};return s};var Wt=function t(e,r,n,i,o){var a=Bt(r);var f="image2D-rg-"+(new Date).valueOf()+"-"+Math.random();var u=k('<radialGradient id="'+f+'" cx="'+n+'%" cy="'+i+'%" r="'+o+'%"></radialGradient>');a.appendChild(u);var l={value:function t(){return"url(#"+f+")"},addColorStop:function t(e,r){u.appendChild(k('<stop offset="'+e*100+'%" style="stop-color:'+r+';" />'));return l}};return l};function Gt(o,t){var f=void 0;if(t)f=T(t,o);var u={fillStyle:"#000",strokeStyle:"#000",lineWidth:1,textAlign:"start",textBaseline:"middle","font-size":"16","font-family":"sans-serif","arc-start-cap":"butt","arc-end-cap":"butt",lineDash:[]};var l="",s=[];var e=[],c="";var h={config:function t(){if(arguments.length===1){if(_typeof(arguments[0])!=="object")return u[arguments[0]];for(var e in arguments[0]){u[e]=jt(e,arguments[0][e])}}else if(arguments.length===2)u[arguments[0]]=jt(arguments[0],arguments[1]);return h},bind:function t(e){f=T(e,o);return h},appendTo:function t(e){f.appendTo(e||o,o);return h},prependTo:function t(e){f.prependTo(e||o,o);return h},afterTo:function t(e){f.afterTo(e||o,o);return h},beforeTo:function t(e){f.beforeTo(e||o,o);return h},beginPath:function t(){l="";s=[];return h},closePath:function t(){l+="Z";return h},moveTo:function t(e,r){l+="M"+e+" "+r;s=[e,r];return h},lineTo:function t(e,r){l+=(l==""?"M":"L")+e+" "+r;s=[e,r];return h},arc:function t(e,r,n,i,o){var a=M(e,r,i,e+n,r);var f=M(e,r,i+o,e+n,r);i=i/Math.PI*180;o=o/Math.PI*180;if(l==""){l+="M"+a[0]+","+a[1]}else if(a[0]!=s[0]||a[1]!=s[1]){l+="L"+a[0]+","+a[1]}l+="A"+n+","+n+" 0 "+(o>180||o<-180?1:0)+","+(o>0?1:0)+" "+f[0]+","+f[1];return h},fill:function t(){zt(f,l).attr("transform",c).attr("fill",u.fillStyle);return h},stroke:function t(){zt(f,l).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:"none","stroke-dasharray":u.lineDash.join(",")});return h},full:function t(){zt(f,l).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:u.fillStyle,"stroke-dasharray":u.lineDash.join(",")});return h},save:function t(){e.push(c);return h},restore:function t(){if(e.length>0)c=e.pop();return h},quadraticCurveTo:function t(e,r,n,i){l+="Q"+e+" "+r+","+n+" "+i;return h},bezierCurveTo:function t(e,r,n,i,o,a){l+="C"+e+" "+r+","+n+" "+i+","+o+" "+a;return h},fillText:function t(e,r,n,i){var o=Dt(f,u,r,n,i||0);f.attr("transform",c+o.transform).attr("fill",u.fillStyle)[0].textContent=e;return h},strokeText:function t(e,r,n,i){var o=Dt(f,u,r,n,i||0);f.attr("transform",c+o.transform).attr({stroke:u.strokeStyle,fill:"none","stroke-dasharray":u.lineDash.join(",")})[0].textContent=e;return h},fullText:function t(e,r,n,i){var o=Dt(f,u,r,n,i||0);f.attr("transform",c+o.transform).attr({stroke:u.strokeStyle,fill:u.fillStyle,"stroke-dasharray":u.lineDash.join(",")})[0].textContent=e;return h},fillArc:function t(e,r,n,i,o,a){Rt(f,u,e,r,n,i,o,a).attr("transform",c).attr("fill",u.fillStyle);return h},strokeArc:function t(e,r,n,i,o,a){Rt(f,u,e,r,n,i,o,a).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:"none","stroke-dasharray":u.lineDash.join(",")});return h},fullArc:function t(e,r,n,i,o,a){Rt(f,u,e,r,n,i,o,a).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:u.fillStyle,"stroke-dasharray":u.lineDash.join(",")});return h},fillCircle:function t(e,r,n){Ft(f,e,r,n).attr("transform",c).attr("fill",u.fillStyle);return h},strokeCircle:function t(e,r,n){Ft(f,e,r,n).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:"none","stroke-dasharray":u.lineDash.join(",")});return h},fullCircle:function t(e,r,n){Ft(f,e,r,n).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:u.fillStyle,"stroke-dasharray":u.lineDash.join(",")});return h},fillRect:function t(e,r,n,i){Ht(f,e,r,n,i).attr("transform",c).attr("fill",u.fillStyle);return h},strokeRect:function t(e,r,n,i){Ht(f,e,r,n,i).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:"none","stroke-dasharray":u.lineDash.join(",")});return h},fullRect:function t(e,r,n,i){Ht(f,e,r,n,i).attr("transform",c).attr({"stroke-width":u.lineWidth,stroke:u.strokeStyle,fill:u.fillStyle,"stroke-dasharray":u.lineDash.join(",")});return h},createLinearGradient:function t(e,r,n,i){return Ot(f,o,e,r,n,i)},createRadialGradient:function t(e,r,n){return Wt(f,o,e,r,n)},translate:function t(e,r){c+=" translate("+e+","+r+")";return h},rotate:function t(e){e=e%(Math.PI*2);c+=" rotate("+e/Math.PI*180+")";return h},scale:function t(e,r){r=r||e;c+=" scale("+e+","+r+")";return h}};return h}function $t(){if(!_(this[0]))throw new Error("Target empty!");var t=this[0],e=t.nodeName.toLowerCase();if(e==="canvas")return It(t,arguments[0]);if(e==="svg")return Gt(t,arguments[0]);throw new Error("Painter is not a function!")}function Vt(){if(!_(this[0]))throw new Error("Target empty!");if(this[0].nodeName.toLowerCase()!=="canvas")throw new Error("Layer is not a function!");var r=this.painter(),n={},i=[];var o=this[0].clientWidth,a=this[0].clientHeight;var f={painter:function t(e){if(!n[e]){n[e]={visible:true};n[e].canvas=document.createElement("canvas");n[e].canvas.setAttribute("width",o);n[e].canvas.setAttribute("height",a);n[e].canvas.__image2D__layer__="yes";n[e].painter=T(n[e].canvas).painter();i.push(e)}return n[e].painter},delete:function t(e){for(var r=0;r<i.length;r++){if(i[r]===e){i.splice(r,1);break}}delete n[e];return f},update:function t(){r.clearRect(0,0,o,a);r.save();for(var e=0;e<i.length;e++){if(n[i[e]].visible)r.drawImage(n[i[e]].canvas,0,0,o,a,0,0,o,a)}r.restore();return f},hidden:function t(e){n[e].visible=false;return f},show:function t(e){n[e].visible=true;return f}};return f}T.extend({treeLayout:S,pieLayout:A,Matrix4:R,rotate:M,move:E,scale:C,dot:P,animation:$,cardinal:V,formatColor:U,getRandomColors:X,getLoopColors:Y,stopPropagation:K,preventDefault:tt,map:at,ruler:ut});T.prototype.extend({appendTo:lt,prependTo:st,afterTo:ct,beforeTo:ht,remove:dt,filter:vt,text:pt,html:gt,size:wt,css:yt,attr:bt,datum:xt,data:_t,enter:kt,exit:Tt,loop:Mt,bind:Z,unbind:Q,position:J,painter:$t,layer:Vt});T.fn=T.prototype;if((typeof module==="undefined"?"undefined":_typeof(module))==="object"&&_typeof(module.exports)==="object"){module.exports=T}else{var qt=window.image2D,Ut=window.$$;T.noConflict=function(t){if(window.$$===T){window.$$=Ut}if(t&&window.image2D===T){window.image2D=qt}return T};window.image2D=window.$$=T}})();