OSDN Git Service

Modify the addEvent method
[sie/sie.git] / sie.js
1 /*SIE under the MIT Lisence
2  */
3 /* Copyright 2016 dhrname and other contributors
4  * http://sie.osdn.jp/
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  * 
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  * 
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 function getDocument(){function t(t){function e(e,n){for(var r=t.getElementsByTagNameNS(i,n),s=0;s<r.length;++s)e.up().init(r.item(s));r=e=void 0}var n=base("$calcMode").$attribute.$setElement,r=n.$animateElement;e(n,"set"),e(r,"animate"),e(r,"animateColor"),e(r.$animateTransformElement,"animateTransform"),e(r.$animateTransformElement.$motionElement,"animateMotion"),t.defaultView.addEventListener("hashchange",function(){var e=t.defaultView.location.hash.slice(1);t.getElementById(e).beginElement()})}var e=document.getElementsByTagName("object"),i="http://www.w3.org/2000/svg";if(e)for(var n=0;n<e.length;++n)t(e[n].getSVGDocument());t(document);var r=__step(),s=function(){window.cancelAnimationRequest&&cancelAnimationRequest(r)};base("$frame").on("pauseAnimation",s),window.addEventListener("unload",s)}function __step(){if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Animation","1.1")||window.navigator.userAgent.toLowerCase().indexOf("edge")){if(window.requestAnimationFrame&&requestAnimationFrame){var t={handle:null};return function(e){function i(){if(!n.isPaused){e++;try{r.setFrame(e),r.$endFrame.setFrame(e)}catch(t){}s.handle=requestAnimationFrame(i)}}var n=base("$frame"),r=n.$svgEvent,s=t;s.handle=requestAnimationFrame(i)}(-1),t}setInterval(function(t){var e=base("$frame").$svgEvent;return function(){t++,e.setFrame(t)}}(-1),1)}}!function(){var t={obj:{up:function(t){var e=Object.create(this);return t?(this[t]=e,e.up=this.up):this.$1=e,e},mix:function(e){if(!e)throw new Error("No arguments error");if("function"!=typeof e){var i=t.__ng_;for(var n in e)i[n]||(this[n]=e[n]);n=i=void 0}else e.call(this,this);return this},on:function(t,e){if(!t)throw new Error("No arguments error");if(/^(?:up|on|mix|of)$/.test(t))throw new Error("Invalid method name error");if("function"!=typeof e)throw new Error("Not support arguments type");var i=this._eventList__,n=this[t];if(this._eventList__){if(!this.hasOwnProperty("_eventList__")){var r=[];r._parent=i,i=this._eventList__=r,r=void 0}}else i=this._eventList__=[];return this[t]&&n.isOn||("function"==typeof n&&(i.push({name:t,func:n}),i._parent=null),this[t]=function(){var e,i=this._eventList__,n=t,r=null,s=null,a=!1;for(i._child=null;e=i._parent;)e._child=i,i=e;for(;i;){for(var l=0,o=i.length;o>l;++l)i[l].name===n&&(r=i[l].func.apply(this,arguments),a||(s=r,a=!0));i=i._child}return i=r=n=a=void 0,s},this[t].isOn=!0),i.push({name:t,func:e}),i=n=e=void 0,this},__args:null,__app:null,of:function(t){if(!t)throw new Error("No arguments error");if(this.hasOwnProperty("__of"))throw new Error("Reset error");var e=this.__args||[];for(var i in t)t.hasOwnProperty(i)&&"call"!==i&&(e[i]||e.push(i),e[i]=this[i]=t[i]);return t.call&&(this.__app={call:t.call}),this.__args=e,this.__of=1,e=i=t=void 0,this},call:function(){if(!this.__app)return this;var t=this.__args,i=this.call;this.call=e;for(var n=0,r=t.length;r>n;++n){var s=t[n],a=this[s];a&&a.call&&(this[s]=a.call(this))}return this.call=i,t=s=a=i=void 0,this.__app.call.apply(this,arguments)}}},e=function(){return this},i={};base=function(e){var n=t,r=i;if(e){if(r[e])return r[e];var s=Object.create(n.obj);return this[e]=r[e]=s,s[e]=s,s}throw new Error("No arguments error")};var n={},r=Object.prototype;for(var s in r)n[s]=!0,i[s]=null;n.constructor=!1,t.__ng_=n,n=r=void 0,base.free=function(){delete t.obj,t=i=e=void 0},Object.create||(Object.create=function(t){var e=function(){};return e.prototype=t,new e})}(),base("$frame").mix({fpms:.024,timelines:[],begin:0,activeTime:Number.MAX_VALUE,currentFrame:0,startAnimation:function(){__step()},isPaused:!1,pauseAnimation:function(){this.isPaused=!0},setFrame:function(t){if(!(t<this.begin||t>=this.begin+this.activeTime)){this.currentFrame=t;for(var e=this.timelines,i=0;i<e.length;++i)e[i]!==this&&e[i].setFrame(t)}},addLine:function(t){if(!t||!t.begin&&0!==t.begin||!t.activeTime&&0!==t.activeTime)return!1;var e=this.timelines;return e.indexOf(t)>=0&&this.removeLine(t),e.push(t),e=void 0,!0},removeLine:function(t){var e=this.timelines,i=e.indexOf(t);i>-1&&e.splice(i,1),e=i=void 0}}).mix(function(t){t.up("$endFrame").mix({timelines:[]}),t.up("$begin").mix({string:"",isResolved:!1,eventTarget:document.documentElement,currentFrame:0,eventOffset:0,repeat:0,accessKey:"",trim:function(t){return t.replace(/[\s\n]+/g,"")},offset:function(t){function e(){return r(1e3,/[\d.]+s$/,/[\d.]+$/)}function i(){return r(6e4,/[\d.]+min$/,/\d\d:[^:]+$/)}function n(){return r(36e5,/\d+:\d\d:/,/[\d.]+h$/)}function r(e,i,n){return e*(a(t.match(i)||"0")||a(t.match(n)||"0"))}t=t||"0";var s=t.charAt(0),a=parseFloat,l=a(t.match(/[\d.]+ms$/)||"0")+e()+i()+n();return"-"===s&&(l*=-1),s=a=e=i=n=void 0,l},event:function(t){if(t=t||"",/[\+\-]/.test(t)&&(t=t.slice(0,t.search(/[\+\-]/))),t.indexOf(".")>-1){var e=t.split(".");return{id:e[1]&&e[0],event:e[0]&&e[1]}}return{id:"",event:t}},parse:function(){this.begin=0,this.isResolved=!1;var t,e=this.trim(this.string),i=e.search(/[\+\-]/),n=null;if("indefinite"===e?this.begin=Number.MAX_VALUE:i>0?(this.begin=this.offset(e.slice(i)),n=this.event(e)):/[^\+\-\d]/.test(e.charAt(0))?n=this.event(e):(this.begin=this.offset(e),this.isResolved=!0),this.repeat=/repeat\((\d+)\)/.test(e)?+RegExp.$1:0,this.accessKey=/accessKey\(([^\)]+?)\)/.test(e)?RegExp.$1:"",this.begin=Math.floor(this.begin*this.fpms),"indefinite"===e);else if(n)if(t=n.id?this.eventTarget.ownerDocument.getElementById(n.id):this.eventTarget,this.eventOffset=this.begin,this.repeat>0)t&&t.addEventListener("repeatEvent",function(t){t.detail===this.repeat&&this.listener(t)}.bind(this),!0);else if(this.accessKey)document.documentElement.addEventListener("keydown",function(t){t["char"]===this.accessKey&&this.listener(t)}.bind(this),!1);else{var r=/^(?:begin|end|repeat)$/.test(n.event)?n.event+"Event":n.event;t&&t.addEventListener(r,this.listener.bind(this),!1)}else this.$frame=this;return s=n=e=i=t=void 0,this},listener:function(t){this.begin=this.eventOffset+this.$frame.currentFrame;var e=this.$activate;e.begin=this.begin,this.activeTime=e.call()||Number.MAX_VALUE,this.simpleDuration=e.simpleDur,e=void 0,this.$frame.addLine(this),this.isResolved=!0}}).up("$activate").of({dur:"indefinite",end:t.$begin.up("$end"),repeatCount:null,repeatDur:null,simpleDur:function(){return"indefinite"!==this.dur&&this.dur?Math.floor(this.offset(this.dur)*this.fpms):null},min:"0",max:"indefinite",resolvedTime:function(){return Date.now()},call:function(){function t(){return a?!0:o?!1:!!(!l&&!u||r&&!u||s&&!h||r&&s)}var e,i="indefinite",n=this.simpleDur,r=this.repeatCount===i,s=this.repeatDur===i,a=this.end===i,l=n||0===n,o=this.end||0===this.end,h=this.repeatCount||0===this.repeatCount,u=this.repeatDur||0===this.repeatDur,m=[],f=Math.floor(this.offset(this.min)*this.fpms),c=this.max===i?null:Math.floor(this.offset(this.max)*this.fpms);if(t())return c?c:null;if(l&&this.repeatCount&&!r&&m.push(n*this.repeatCount),u&&!s&&m.push(Math.floor(this.offset(this.repeatDur)*this.fpms)),o&&!a&&m.push(this.end-this.begin),!l||h||u||m.push(n),i=n=r=isIndefRepeatDurindef=l=o=u=h=t=void 0,1===m.length)e=m[0];else{if(!(m.length>1))return null;e=Math.min.apply(Math,m)}return c&&f>c?e:(f&&f>e&&(e=f),c&&e>c&&(e=c),e)}}),t.$begin.$end.of({call:function(){return this.string?(this.parse(this.string),this.isResolved?this.begin:"indefinite"):null}}).mix({listener:function(t){this.begin<=0&&this.removeLine(this.$begin),this.begin=this.eventOffset+this.$frame.currentFrame;var e=this.$begin.$activate;e.end=this.begin,this.$begin.activeTime=e.call(),this.isResolved=!0,e=void 0}})}),base("$from").of({string:"",numList:function(){var t=this.string.match(/[\-\+]?[\d\.]+(?:[eE][\-\+]?[\d\.]+)?/g)||[];if(t)for(var e=0;e<t.length;++e)t[e]=parseFloat(t[e]);return t},strList:function(){return this.string.replace(/\d[eE][\-\+\d]/g,"").match(/[^\d\-\+\.]+/g)},from:base("$from").up().mix({from:null}),call:function(){if(this.numList.string=this.string,this.numList.length&&0===this.additive[0]&&0===this.accumulate[0]){for(var t=[],e=[],i=0;i<this.numList.length;++i)t[i]=e[i]=0;this.additive=t,this.accumulate=e}if(!this.string||!this.numList.length||!this.strList)return this.numList;var n=this.numList.length<this.strList.length;return/^[\-\+]?[\d\.]/.test(this.string)&&!n&&this.strList.unshift(""),/\d$/.test(this.string)&&!n&&this.strList.push(""),this.numList}}).mix({degit:0,additive:[0],accumulate:[0],advance:function(t){if(0>t||t>1)throw new Error("An Invalid Number Error");if(!this.string)return"";if(!this.from.length)return 1===t?this.string.trim():this.from.string.trim();for(var e="",i=this.numList,n=this.strList,r=this.from,s=this.degit,a=this.additive,l=this.accumulate,o=0,h=i.length;h>o;++o)e+=(t*i[o]+(1-t)*r[o]+a[o]+l[o]).toFixed(s),n&&(e+=n[o+1]);return e=(n?n[0]:"")+e,i=n=r=o=h=s=a=l=void 0,e.trim()},distance:function(t){if(!t)return 0;var e=this.call(),i=t.call?t.call():t,n=0;if(!e||!i)return 0;for(var r=0,s=e.length;s>r;++r)n+=(e[r]-i[r])*(e[r]-i[r]);return Math.sqrt(n)},setAdditive:function(t){if(!t)return 0;var e=this.$from.up();return e.string=t,this.additive=e.call()},setAccumulate:function(t){return!t||isNaN(t)?0:this.accumulate=this.numList.map(function(e){return e*t})}}).up("$to").from=null,base("$calcMode").mix({mode:"linear",keyTime:1,keySplines:null,_f:function(t){var e=this.keyTime;if(0===e&&t)t=0;else{if(!e||!isFinite(e))return this.string;t/=e,t=t>1?Math.floor(t):t}return e=void 0,isNaN(t)?this.string:this.to.advance(t)},funcForDiscrete:function(t){return isNaN(t)?this.string:1===t?this.to.string:this.to.advance(0)}}).of({norm:1,string:"",call:function(){var t=this._f.bind(this);if("linear"===this.mode)return this.to.call(),t;if("paced"===this.mode)return this.keyTime=this.to.distance(this.to.from)/this.norm,t;if("spline"===this.mode){var e=this.keySplines,i=function(t){return Math.PI};if(i.isNotAnimate=!0,!e)return i;for(var n=0,r=NaN;n<e.length;++n){if(r=e[n],isNaN(r))return i;if(0>r||r>1)return i}this.to.call();var s=e[0],a=e[1],l=e[2],o=e[3],h=1,u=1,m=h-3*(l-s),f=3*(l-2*s),c=3*s,d=u-3*(o-a),g=3*(o-2*a),v=3*a,p=Math.qubicnewton;if(!(0!==s&&1!==s||0!==a||1!==l&&0!==l||1!==o))return this.to.call(),t;var b=this.keyTime;return(b||isFinite(b))&&(m*=b,f*=b,c*=b,d*=b,g*=b,v*=b),b=e=s=a=l=o=h=u=void 0,function(e){var i=p(m,f,c,-e,e);return t(d*i*i*i+g*i*i+v*i)}}return"discrete"===this.mode?(this.to.call(),this.funcForDiscrete.bind(this)):void 0}}).to=base("$from").$to,Math.qubicnewton=function(t,e,i,n,r){var s=1e-15,a=t*r*r*r+e*r*r+i*r+n;if(0===a)return r;for(var l=0;100>l;l=l+1|0){var o=3*t*r*r+2*e*r+i;if(!o||s>a&&a>-s)return a=s=void 0,r;r-=a/o,a=t*r*r*r+e*r*r+i*r+n}return r},base("$calcMode").up("$attribute").mix({element:null,$from:base("$from").up(),attrName:"",attrNameSpace:null,defaultValue:"",isDefault:!1,isCSS:!1,mode:"linear",getAttr:function(t,e){var i=null;t.indexOf("xlink:")>-1&&(i="http://www.w3.org/1999/xlink");var n=this._ele.getAttributeNS(i,t);if(this.element){var r=this.element.ownerDocument.defaultView;if("inherit"===n)return r.getComputedStyle(this.element.parentNode,"").getPropertyValue(this.attrName);if("currentColor"===n)return r.getComputedStyle(this._ele,"").getPropertyValue("color")}return n||e},_ele:document.documentElement,hasAttrValues:function(){var t=this._ele;return t?t.hasAttribute("from")||t.hasAttribute("to")||t.hasAttribute("by")||t.hasAttribute("values"):!1},__cacheAttr:"",setAttribute:function(t){var e=this.attrName;if(e&&this.__cacheAttr!==t){this.__cacheAttr=t;var i=this.element;this.isCSS?i.style.setProperty(e,t,""):i.setAttributeNS(this.attrNameSpace,e,t),t=e=i=void 0}},removeAttribute:function(){var t=this.attrName;if(t){var e=this.element;this.isDefault?this.setAttribute(this.defaultValue):(e.removeAttributeNS(this.attrNameSpace,t),this.isCSS&&e.style.setProperty(t,this.defaultValue,"")),this.__cacheAttr="",value=t=e=void 0}},push:function(t){function e(t,e){return"indefinite"!==t.string?function(){}:function(){t.listener({timeStamp:Date.now()});var i=this.ownerDocument.createEvent("MouseEvents");i.initMouseEvent(e+"Event",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,this),this.dispatchEvent(i)}}if(!t||!t.hasAttribute)return null;this.__cacheAttr="",this.element=t.parentNode||null;var i;if((i=t.getAttributeNS(null,"targetElement"))&&(this.element=t.ownerDocument.getElementById(i)),(i=t.getAttribute("xlink:href"))&&(this.element=t.ownerDocument.getElementById(i.slice(1))),this._ele=t,!this.hasAttrValues())return null;this.attrName=this.getAttr("attributeName","");var n=this.attrName,r=this.getAttr("attributeType","auto"),s=this.element&&this.element.ownerDocument.defaultView.getComputedStyle(this.element,"");("CSS"===r||"auto"===r&&this.element&&s.getPropertyValue(n)&&!/^(width|height|transform)$/.test(n))&&(this.isCSS=!0),n.indexOf("xlink")>-1&&(this.attrNameSpace="http://www.w3.org/1999/xlink");var a=this.element;a&&(this._ele=a,this.isDefault=a.hasAttributeNS(this.attrNameSpace,n),this.defaultValue=this.getAttr(n,s.getPropertyValue(n)),this._ele=t);var l=base("$frame"),o=l.$begin,h=o.up().mix({target:t,eventTarget:this.element||o.eventTarget,string:this.getAttr("begin","0"),$activate:o.$activate.up().mix({dur:this.getAttr("dur",null),end:o.$end.up().mix({eventTarget:this.element||o.eventTarget,string:this.getAttr("end",null)}),repeatCount:this.getAttr("repeatCount",null),repeatDur:this.getAttr("repeatDur",null),min:this.getAttr("min","0"),max:this.getAttr("max","indefinite")})}).parse();if(h.$activate.end.$begin=h,t.beginElement=e(h,"begin"),t.endElement=e(h.$activate.end,"end"),h.isResolved){var u=h.begin;h.listener({timeStamp:Date.now()}),h.begin=u}return h.timelines=[],o=t=i=void 0,h},setValues:function(t,e,i,n){var r=this.$from,s=[this.up().mix({to:r.up().mix({from:r.up()})})],a=s[0].to;if(t=t&&t.split(";"),t&&t.length){s=[];for(var l=1;l<t.length;++l)s.push(this.up().mix({to:r.up().mix({from:r.up()})})),a=s[s.length-1].to,a.string=t[l],a.from.string=t[l-1]}else if(i)a.string=i,a.from.string=e||"0";else{if(!n)return null;a.string=n,a.from.string=e||"0";for(var o=a.call(),h=a.from,l=0;l<o.length;++l)o[l]+=h[l]}return r=a=o=h=void 0,s},setKey:function(t){this._ele=t;var e,i,n=this.setValues(this.getAttr("values",null),this.getAttr("from",null),this.getAttr("to",null),this.getAttr("by",null)),r=this.getAttr("keyTimes",null),s=this.getAttr("keySplines",null),a=s&&s.split(";"),l="discrete"===this.mode;if(!l&&r&&n){if(e=this.$from.numList.call({string:r}),e.length&&0!==e[0])return null;if(e.length&&e.length!==n.length+1)return null;for(var o=0;o<n.length;++o)n[o].keyTime=e[o+1]-e[o],a&&(i=this.$from.numList.call({string:a[o]}),n[o].keySplines=i.length?i:null)}else if(!l&&n)for(var h=1/n.length,o=0;o<n.length;++o)n[o].keyTime=h,a&&(i=this.$from.numList.call({string:a[o]}),n[o].keySplines=i.length?i:null);else if(n){if(r){if(e=this.$from.numList.call({string:r}),e.length&&0!==e[0])return null;if(e.length&&e.length!==n.length+1)return null;for(var o=0;o<n.length;++o)n[o].keyTime=e[o+1]-e[o]}else for(var h=1/(n.length+1),o=0;o<n.length;++o)n[o].keyTime=h;n.push(n[n.length-1].up().mix(function(){e&&(this.keyTime=1-e[e.length-1])}).of({call:function(){return function(t){return isNaN(t)?this.string:this.to.advance(1)}.bind(this)}}))}if("paced"===this.mode){var u=0;n.forEach(function(t){u+=t.to.distance(t.to.from)}),n.forEach(function(t){t.norm=u})}return t=r=e=h=a=void 0,n}}).up("$setElement").mix({to:"",_setFrame:function(t){this.state="playing",this.setAttribute(this.to)},state:"idling",timeline:base("$frame").$begin,checkEnd:function(t){var e=this.timeline,i=e.begin+e.activeTime;return!e.isResolved||isNaN(i)?(e=t=void 0,!1):(t<e.begin||t>=i)&&"playing"===this.state?(this.state="idling",e=t=void 0,!0):(e=t=void 0,!1)},_setEndFrame:function(t){this.checkEnd(t)&&"remove"===this.fill&&this.removeAttribute()},tocall:function(){},init:function(t){var e=this.push(t);t&&t.getAttributeNS&&(this._ele=t,this.to=this.getAttr("to",""),this.fill=this.getAttr("fill","remove"));var i=this.element;e&&i&&(this.timeline=e,e.addLine({setFrame:this._setFrame.bind(this),begin:1,activeTime:1}),base("$frame").$endFrame.addLine({setFrame:this._setEndFrame.bind(this),begin:1,activeTime:1})),this.state="idling",e=i=void 0}}).up("$animateElement").mix({funcs:[],tocall:function(t){var e=this.funcs;if("discrete"===this.mode){for(var i="",n=0;n<e.length;++n){var r=e[n];t>=r.startKeyTime&&(i=r(t))}return t=e=r=void 0,i}for(var n=0;n<e.length;++n){var r=e[n];if(r.endKeyTime>=t)return r(t-r.startKeyTime)}return e=n=r=void 0,""},_setFrame:function(t){var e=this.timeline,i=e.simpleDuration,n=i?(t-e.begin)%i/i:0;this.setAttribute(this.tocall(n)),this.state="playing",e=i=n=void 0},_setEndFrame:function(t){if(this.checkEnd(t))if("freeze"===this.fill){var e=this.timeline,i=e.simpleDuration;if(i){var n=e.activeTime%i/i;n=n>1?1:n,n=n||1}else n=0;this.setAttribute(this.tocall(n)),e=i=n=void 0}else this.removeAttribute()},getAttr:function(t,e){var i=this.$attribute.getAttr.apply(this,arguments);return"from"===t&&!i&&this.defaultValue?this.defaultValue:i},_keywords:{aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagree:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},setAdd:function(t,e){if("sum"===t.getAttributeNS(null,"additive")){var i=t.parentNode.getAttributeNS(null,this.attrName);t.addEventListener("beginEvent",function(t){e.forEach(function(t){t.to.setAdditive(i)})},!1)}},setAccum:function(t,e){"sum"===t.getAttributeNS(null,"accumulate")&&t.addEventListener("repeatEvent",function(t){e.forEach(function(e){e.to.call(),e.to.setAccumulate(t.detail)})},!1)},setString:function(){/^(?:display|class|edgeMode|(gradient|marker|pattern|maskContent|mask|patternContent|primitive)Units|in|in2|method|mode|operator|preserveAspectRatio|result|spacing|spreadMethod|stitchTiles|target|type|xlink:href|yChannelSelector|color-interpolation|(clip|fill)-rule|cursor|filter|font-(family|stretch|style|variant)|image-rendering|marker-(end|mid|start)|mask|overflow|pointer-events|shape-rendering|stroke-(linecap|linejoin)|text-(anchor|decoration|rendering)|visibility)$/.test(this.attrName)&&(this.mode="discrete")},degits:1,setValues:function(){var t=this.$attribute.setValues.apply(this,arguments),e=this.degits;return t&&t.forEach(function(t){t.to.degit=e}),e=void 0,t}}).on("init",function(t){var e=/^(?:fill|stroke|stop-color|color)$/.test(this.attrName);e&&(this.degits=0);var i,n=0,r=function(t){return t};if(t&&(this.mode=t.getAttributeNS(null,"calcMode")||"linear",this.setString(),i=this.setKey(t)),e){var s=this._keywords;r=function(t){var e=s[t];if(e)return"rgb("+e.join(", ")+")";if(t&&"#"===t[0]){var i="rgb(",n=parseInt;if(t.length<5)var r=t[1],a=t[2],l=t[3],t="#"+r+r+a+a+l+l;return t.match(/\#(\w{2})(\w{2})(\w{2})/),i+=n(RegExp.$1,16)+", "+n(RegExp.$2,16)+", "+n(RegExp.$3,16)+")",r=a=l=void 0,i}return t}}i&&(this.funcs=i.map(function(t){t.to.string=r(t.to.string),t.to.from.string=r(t.to.from.string);var e=t.call();return e.startKeyTime=n,n=e.endKeyTime=n+t.keyTime,e}).filter(function(t){return this.timeline.isResolved?"spline"!==this.mode||!t.isNotAnimate:!0},this),this.setAdd(t,i),this.setAccum(t,i)),s=r=e=void 0}).up("$animateTransformElement").mix({numberOfList:-1,type:"translate",attrName:"transform",isCSS:!1,isSum:!1,degits:15,joinList:function(t){for(var e=this.element.__transformList,i=0;i<e.length;++i){var n=e[i],r=n.value;n.isSum?t+=" "+r:n.isPlaying&&(t=r)}return t.trim()},tocall:function(t){if(this.numberOfList<0)throw new Error("Number of The List Error");var e=this.element.__transformList[this.numberOfList];return e.value=this.type+"("+this.$animateElement.tocall.call(this,t)+")",e.isPlaying=!0,e.isSum=this.isSum,this.joinList(this.defaultValue||"")},__setAttribute:function(){},_setFrame:function(t){var e=this.element.__transformList,i=!1,n=e.length;if(1!==n&&this.numberOfList<n-1)for(var r=this.numberOfList+1;n>r;++r)e[r].isPlaying&&(i=!0);this.setAttribute=i?this.__setAttribute:this.$animateElement.setAttribute,this.$animateElement._setFrame.call(this,t)},_setEndFrame:function(t){var e=this.element.__transformList;if(this.checkEnd(t)&&"remove"===this.fill&&e)if(this.isSum)e[this.numberOfList]&&(e[this.numberOfList].value="translate(0)");else{e[this.numberOfList]&&(e[this.numberOfList].isPlaying=!1);for(var i=0;i<e.length;++i){var n=e[i];if(n.isPlaying||!n.isRemove)return}this.removeAttribute()}},setAdd:function(){}}).on("init",function(t){if(t&&t.parentNode){this.getAttr=this.$attribute.getAttr,this.type=this.getAttr("type","translate"),this.attrName="transform";var e=this.element;this.isDefault=e.hasAttributeNS(null,"transform"),this.defaultValue=e.getAttributeNS(null,"transform")||"",this.isSum="sum"===this.getAttr("additive","replace"),e.__transformList||(e.__transformList=[],this.numberOfList=-1),this.hasAttrValues()&&this.numberOfList<0&&(this.numberOfList=e.__transformList.length,e.__transformList.push({isPlaying:!1,value:"translate(0)",isSum:this.isSum,isRemove:"remove"===this.fill}))}}).up("$motionElement").mix(function(){this._setFrame=this.$animateElement._setFrame}).mix({numberOfList:-1,mode:"paced",hasAttrValues:function(){return this.$attribute.hasAttrValues.call(this)?!0:this._ele.hasAttribute("path")||this._ele.getElementsByTagNameNS(this.path.namespaceURI,"mpath").length},path:document.createElementNS("http://www.w3.org/2000/svg","path"),rotate:"0",tocall:function(t){return("translate("+this.$animateElement.tocall.call(this,t)+") "+this.joinList(this.defaultValue||"")).trim()},getRotate:function(t,e,i){var n=t.getPathSegAtLength(e),r=t.pathSegList.getItem(n),s=r.pathSegTypeAsLetter,a=Math.PI;if("M"===s){var l=t.pathSegList.getItem(n+1),o=l.pathSegTypeAsLetter;if("M"===o)return"";if("L"===o)return") rotate("+(Math.atan2(l.y-r.y,l.x-r.x)/a*180+i);if("C"===o)return") rotate("+(Math.atan2(l.y1-r.y,l.x1-r.x)/a*180+i)}else{if("L"===s&&n-1>=0){var h=t.pathSegList.getItem(n-1);return") rotate("+(Math.atan2(r.y-h.y,r.x-h.x)/a*180+i)}if("C"===s){var u=t.getPointAtLength(e),m=u.x,f=u.y;return u=t.getPointAtLength(e+1),") rotate("+(Math.atan2(u.y-f,u.x-m)/a*180+i)}}},_tocallForPath:function(t){var e=this.path,i=t*e.getTotalLength(),n=e.getPointAtLength(i),r=0;return"0"===this.rotate?n.x+","+n.y:(r="auto"===this.rotate?0:"auto-reverse"===this.rotate?180:+this.rotate,n.x+","+n.y+this.getRotate(e,i,r))}}).on("init",function(t){if(t&&t.parentNode){this.type="translate",this.isSum=!0,this.mode=this.getAttr("mode","paced"),this.rotate=this.getAttr("rotate","0"),this.path=this.path.cloneNode(!0);var e=t.getElementsByTagNameNS(this.path.namespaceURI,"mpath"),i=(this.element.__transformList,this.$animateElement);if(e.length){var n=t.ownerDocument.getElementById(e[0].getAttributeNS("http://www.w3.org/1999/xlink","href").slice(1));n&&this.path.setAttributeNS(null,"d",n.getAttributeNS(null,"d")),this.$animateElement=i.up().mix({tocall:this._tocallForPath})}else t.hasAttributeNS(null,"path")&&(this.path.setAttributeNS(null,"d",t.getAttributeNS(null,"path")),this.$animateElement=i.up().mix({tocall:this._tocallForPath}))}}),base("$frame").up("$svgEvent").mix({first:null,lastTimeLine:null,setTimeTable:function(){for(var t=this.timelines,e=0,i=null;e<t.length;++e)if(t[e].target&&t[e].isResolved){var n=t[e],r=n.begin,s=n.target,a=n.simpleDuration,l=n.activeTime,o={frame:r,eventType:"begin",target:s,next:{frame:r+l,eventType:"end",target:s,next:null}};if(i)i.next.next=o;else if(this.first){for(var h=this.first;h.next;)h=h.next;h.next=o}else this.first=o;if(i=o,a&&l!==a)for(var u=o,m=r+a,f=1;r+l>m;m+=a,++f)u.next={frame:m,eventType:"repeat",target:s,count:f,next:u.next},u=u.next;n.target=null}t=i=o=r=s=a=l=void 0},$frame:base("$frame"),setFrame:function(t){var e=this.timelines,i=e[e.length-1],n=this.$frame.setFrame(t);this.lastTimeLine!==i&&(this.lastTimeLine=i,this.setTimeTable());var r=this.first,s=r;for(Math.floor;r;){var a=r.frame,l=r.target;if(detail=0,t>=a){"repeat"===r.eventType&&(detail=r.count),s.next=r.next,this.first===r?(s=r.next,this.first=s):s=r;var o=l.ownerDocument.createEvent("MouseEvents");o.initMouseEvent(r.eventType+"Event",!0,!0,window,detail,0,0,0,0,!1,!1,!1,!1,0,l),l.dispatchEvent(o)}else s=r;r=r.next}return r=t=first=a=l=s=detail=void 0,n}}),window.addEventListener&&window.addEventListener("load",getDocument);