UNPKG

catjs

Version:

(Mobile) Web Automation Framework

2 lines 72 kB
function RGBColor(a){this.ok=!1,"#"==a.charAt(0)&&(a=a.substr(1,6)),a=a.replace(/ /g,""),a=a.toLowerCase();var b={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var c in b)a==c&&(a=b[c]);for(var d=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(a){return[parseInt(a[1]),parseInt(a[2]),parseInt(a[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)]}}],e=0;e<d.length;e++){var f=d[e].re,g=d[e].process,h=f.exec(a);h&&(channels=g(h),this.r=channels[0],this.g=channels[1],this.b=channels[2],this.ok=!0)}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var a=this.r.toString(16),b=this.g.toString(16),c=this.b.toString(16);return 1==a.length&&(a="0"+a),1==b.length&&(b="0"+b),1==c.length&&(c="0"+c),"#"+a+b+c},this.getHelpXML=function(){for(var a=new Array,c=0;c<d.length;c++)for(var e=d[c].example,f=0;f<e.length;f++)a[a.length]=e[f];for(var g in b)a[a.length]=g;var h=document.createElement("ul");h.setAttribute("id","rgbcolor-examples");for(var c=0;c<a.length;c++)try{var i=document.createElement("li"),j=new RGBColor(a[c]),k=document.createElement("div");k.style.cssText="margin: 3px; border: 1px solid black; background:"+j.toHex()+"; "+"color:"+j.toHex(),k.appendChild(document.createTextNode("test"));var l=document.createTextNode(" "+a[c]+" -> "+j.toRGB()+" -> "+j.toHex());i.appendChild(k),i.appendChild(l),h.appendChild(i)}catch(m){}return h}}function stackBlurImage(a,b,c,d){var e=document.getElementById(a),f=e.naturalWidth,g=e.naturalHeight,h=document.getElementById(b);h.style.width=f+"px",h.style.height=g+"px",h.width=f,h.height=g;var i=h.getContext("2d");i.clearRect(0,0,f,g),i.drawImage(e,0,0),isNaN(c)||1>c||(d?stackBlurCanvasRGBA(b,0,0,f,g,c):stackBlurCanvasRGB(b,0,0,f,g,c))}function stackBlurCanvasRGBA(a,b,c,d,e,f){if(!(isNaN(f)||1>f)){f|=0;var i,g=document.getElementById(a),h=g.getContext("2d");try{try{i=h.getImageData(b,c,d,e)}catch(j){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"),i=h.getImageData(b,c,d,e)}catch(j){throw alert("Cannot access local image"),new Error("unable to access local image data: "+j)}}}catch(j){throw alert("Cannot access image"),new Error("unable to access image data: "+j)}var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,k=i.data,J=f+f+1,L=d-1,M=e-1,N=f+1,O=N*(N+1)/2,P=new BlurStack,Q=P;for(n=1;J>n;n++)if(Q=Q.next=new BlurStack,n==N)var R=Q;Q.next=P;var S=null,T=null;r=q=0;var U=mul_table[f],V=shg_table[f];for(m=0;e>m;m++){for(A=B=C=D=s=t=u=v=0,w=N*(E=k[q]),x=N*(F=k[q+1]),y=N*(G=k[q+2]),z=N*(H=k[q+3]),s+=O*E,t+=O*F,u+=O*G,v+=O*H,Q=P,n=0;N>n;n++)Q.r=E,Q.g=F,Q.b=G,Q.a=H,Q=Q.next;for(n=1;N>n;n++)o=q+((n>L?L:n)<<2),s+=(Q.r=E=k[o])*(I=N-n),t+=(Q.g=F=k[o+1])*I,u+=(Q.b=G=k[o+2])*I,v+=(Q.a=H=k[o+3])*I,A+=E,B+=F,C+=G,D+=H,Q=Q.next;for(S=P,T=R,l=0;d>l;l++)k[q+3]=H=v*U>>V,0!=H?(H=255/H,k[q]=(s*U>>V)*H,k[q+1]=(t*U>>V)*H,k[q+2]=(u*U>>V)*H):k[q]=k[q+1]=k[q+2]=0,s-=w,t-=x,u-=y,v-=z,w-=S.r,x-=S.g,y-=S.b,z-=S.a,o=r+((o=l+f+1)<L?o:L)<<2,A+=S.r=k[o],B+=S.g=k[o+1],C+=S.b=k[o+2],D+=S.a=k[o+3],s+=A,t+=B,u+=C,v+=D,S=S.next,w+=E=T.r,x+=F=T.g,y+=G=T.b,z+=H=T.a,A-=E,B-=F,C-=G,D-=H,T=T.next,q+=4;r+=d}for(l=0;d>l;l++){for(B=C=D=A=t=u=v=s=0,q=l<<2,w=N*(E=k[q]),x=N*(F=k[q+1]),y=N*(G=k[q+2]),z=N*(H=k[q+3]),s+=O*E,t+=O*F,u+=O*G,v+=O*H,Q=P,n=0;N>n;n++)Q.r=E,Q.g=F,Q.b=G,Q.a=H,Q=Q.next;for(p=d,n=1;f>=n;n++)q=p+l<<2,s+=(Q.r=E=k[q])*(I=N-n),t+=(Q.g=F=k[q+1])*I,u+=(Q.b=G=k[q+2])*I,v+=(Q.a=H=k[q+3])*I,A+=E,B+=F,C+=G,D+=H,Q=Q.next,M>n&&(p+=d);for(q=l,S=P,T=R,m=0;e>m;m++)o=q<<2,k[o+3]=H=v*U>>V,H>0?(H=255/H,k[o]=(s*U>>V)*H,k[o+1]=(t*U>>V)*H,k[o+2]=(u*U>>V)*H):k[o]=k[o+1]=k[o+2]=0,s-=w,t-=x,u-=y,v-=z,w-=S.r,x-=S.g,y-=S.b,z-=S.a,o=l+((o=m+N)<M?o:M)*d<<2,s+=A+=S.r=k[o],t+=B+=S.g=k[o+1],u+=C+=S.b=k[o+2],v+=D+=S.a=k[o+3],S=S.next,w+=E=T.r,x+=F=T.g,y+=G=T.b,z+=H=T.a,A-=E,B-=F,C-=G,D-=H,T=T.next,q+=d}h.putImageData(i,b,c)}}function stackBlurCanvasRGB(a,b,c,d,e,f){if(!(isNaN(f)||1>f)){f|=0;var i,g=document.getElementById(a),h=g.getContext("2d");try{try{i=h.getImageData(b,c,d,e)}catch(j){try{netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"),i=h.getImageData(b,c,d,e)}catch(j){throw alert("Cannot access local image"),new Error("unable to access local image data: "+j)}}}catch(j){throw alert("Cannot access image"),new Error("unable to access image data: "+j)}var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,k=i.data,F=f+f+1,H=d-1,I=e-1,J=f+1,K=J*(J+1)/2,L=new BlurStack,M=L;for(n=1;F>n;n++)if(M=M.next=new BlurStack,n==J)var N=M;M.next=L;var O=null,P=null;r=q=0;var Q=mul_table[f],R=shg_table[f];for(m=0;e>m;m++){for(y=z=A=s=t=u=0,v=J*(B=k[q]),w=J*(C=k[q+1]),x=J*(D=k[q+2]),s+=K*B,t+=K*C,u+=K*D,M=L,n=0;J>n;n++)M.r=B,M.g=C,M.b=D,M=M.next;for(n=1;J>n;n++)o=q+((n>H?H:n)<<2),s+=(M.r=B=k[o])*(E=J-n),t+=(M.g=C=k[o+1])*E,u+=(M.b=D=k[o+2])*E,y+=B,z+=C,A+=D,M=M.next;for(O=L,P=N,l=0;d>l;l++)k[q]=s*Q>>R,k[q+1]=t*Q>>R,k[q+2]=u*Q>>R,s-=v,t-=w,u-=x,v-=O.r,w-=O.g,x-=O.b,o=r+((o=l+f+1)<H?o:H)<<2,y+=O.r=k[o],z+=O.g=k[o+1],A+=O.b=k[o+2],s+=y,t+=z,u+=A,O=O.next,v+=B=P.r,w+=C=P.g,x+=D=P.b,y-=B,z-=C,A-=D,P=P.next,q+=4;r+=d}for(l=0;d>l;l++){for(z=A=y=t=u=s=0,q=l<<2,v=J*(B=k[q]),w=J*(C=k[q+1]),x=J*(D=k[q+2]),s+=K*B,t+=K*C,u+=K*D,M=L,n=0;J>n;n++)M.r=B,M.g=C,M.b=D,M=M.next;for(p=d,n=1;f>=n;n++)q=p+l<<2,s+=(M.r=B=k[q])*(E=J-n),t+=(M.g=C=k[q+1])*E,u+=(M.b=D=k[q+2])*E,y+=B,z+=C,A+=D,M=M.next,I>n&&(p+=d);for(q=l,O=L,P=N,m=0;e>m;m++)o=q<<2,k[o]=s*Q>>R,k[o+1]=t*Q>>R,k[o+2]=u*Q>>R,s-=v,t-=w,u-=x,v-=O.r,w-=O.g,x-=O.b,o=l+((o=m+J)<I?o:I)*d<<2,s+=y+=O.r=k[o],t+=z+=O.g=k[o+1],u+=A+=O.b=k[o+2],O=O.next,v+=B=P.r,w+=C=P.g,x+=D=P.b,y-=B,z-=C,A-=D,P=P.next,q+=d}h.putImageData(i,b,c)}}function BlurStack(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var mul_table=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],shg_table=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];!function(){function j(a){var i=[0,0,0],j=function(b,c){var d=a.match(b);null!=d&&(i[c]+=d.length,a=a.replace(b," "))};return a=a.replace(/:not\(([^\)]*)\)/g," $1 "),a=a.replace(/{[^]*/gm," "),j(b,1),j(c,0),j(d,1),j(e,2),j(f,1),j(g,1),a=a.replace(/[\*\s\+>~]/g," "),a=a.replace(/[#\.]/g," "),j(h,2),i.join("")}function k(b){var c={opts:b};c.FRAMERATE=30,c.MAX_VIRTUAL_PIXELS=3e4,c.log=function(){},1==c.opts.log&&"undefined"!=typeof console&&(c.log=function(a){console.log(a)}),c.init=function(a){var b=0;c.UniqueId=function(){return b++,"canvg"+b},c.Definitions={},c.Styles={},c.StylesSpecificity={},c.Animations=[],c.Images=[],c.ctx=a,c.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(a,b){this.viewPorts.push({width:a,height:b})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(a){return null!=a&&"number"==typeof a?a:"x"==a?this.width():"y"==a?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}},c.init(),c.ImagesLoaded=function(){for(var a=0;a<c.Images.length;a++)if(!c.Images[a].loaded)return!1;return!0},c.trim=function(a){return a.replace(/^\s+|\s+$/g,"")},c.compressSpaces=function(a){return a.replace(/[\s\r\t\n]+/gm," ")},c.ajax=function(a){var b;return b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),b?(b.open("GET",a,!1),b.send(null),b.responseText):null},c.parseXml=function(a){if("undefined"!=typeof Windows&&"undefined"!=typeof Windows.Data&&"undefined"!=typeof Windows.Data.Xml){var b=new Windows.Data.Xml.Dom.XmlDocument,c=new Windows.Data.Xml.Dom.XmlLoadSettings;return c.prohibitDtd=!1,b.loadXml(a,c),b}if(window.DOMParser){var d=new DOMParser;return d.parseFromString(a,"text/xml")}a=a.replace(/<!DOCTYPE svg[^>]*>/,"");var b=new ActiveXObject("Microsoft.XMLDOM");return b.async="false",b.loadXML(a),b},c.Property=function(a,b){this.name=a,this.value=b},c.Property.prototype.getValue=function(){return this.value},c.Property.prototype.hasValue=function(){return null!=this.value&&""!==this.value},c.Property.prototype.numValue=function(){if(!this.hasValue())return 0;var a=parseFloat(this.value);return(this.value+"").match(/%$/)&&(a/=100),a},c.Property.prototype.valueOrDefault=function(a){return this.hasValue()?this.value:a},c.Property.prototype.numValueOrDefault=function(a){return this.hasValue()?this.numValue():a},c.Property.prototype.addOpacity=function(a){var b=this.value;if(null!=a.value&&""!=a.value&&"string"==typeof this.value){var d=new RGBColor(this.value);d.ok&&(b="rgba("+d.r+", "+d.g+", "+d.b+", "+a.numValue()+")")}return new c.Property(this.name,b)},c.Property.prototype.getDefinition=function(){var a=this.value.match(/#([^\)'"]+)/);return a&&(a=a[1]),a||(a=this.value),c.Definitions[a]},c.Property.prototype.isUrlDefinition=function(){return 0==this.value.indexOf("url(")},c.Property.prototype.getFillStyleDefinition=function(a,b){var d=this.getDefinition();if(null!=d&&d.createGradient)return d.createGradient(c.ctx,a,b);if(null!=d&&d.createPattern){if(d.getHrefAttribute().hasValue()){var e=d.attribute("patternTransform");d=d.getHrefAttribute().getDefinition(),e.hasValue()&&(d.attribute("patternTransform",!0).value=e.value)}return d.createPattern(c.ctx,a)}return null},c.Property.prototype.getDPI=function(){return 96},c.Property.prototype.getEM=function(a){var b=12,d=new c.Property("fontSize",c.Font.Parse(c.ctx.font).fontSize);return d.hasValue()&&(b=d.toPixels(a)),b},c.Property.prototype.getUnits=function(){var a=this.value+"";return a.replace(/[0-9\.\-]/g,"")},c.Property.prototype.toPixels=function(a,b){if(!this.hasValue())return 0;var d=this.value+"";if(d.match(/em$/))return this.numValue()*this.getEM(a);if(d.match(/ex$/))return this.numValue()*this.getEM(a)/2;if(d.match(/px$/))return this.numValue();if(d.match(/pt$/))return this.numValue()*this.getDPI(a)*(1/72);if(d.match(/pc$/))return 15*this.numValue();if(d.match(/cm$/))return this.numValue()*this.getDPI(a)/2.54;if(d.match(/mm$/))return this.numValue()*this.getDPI(a)/25.4;if(d.match(/in$/))return this.numValue()*this.getDPI(a);if(d.match(/%$/))return this.numValue()*c.ViewPort.ComputeSize(a);var e=this.numValue();return b&&1>e?e*c.ViewPort.ComputeSize(a):e},c.Property.prototype.toMilliseconds=function(){if(!this.hasValue())return 0;var a=this.value+"";return a.match(/s$/)?1e3*this.numValue():a.match(/ms$/)?this.numValue():this.numValue()},c.Property.prototype.toRadians=function(){if(!this.hasValue())return 0;var a=this.value+"";return a.match(/deg$/)?this.numValue()*(Math.PI/180):a.match(/grad$/)?this.numValue()*(Math.PI/200):a.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)};var d={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};return c.Property.prototype.toTextBaseline=function(){return this.hasValue()?d[this.value]:null},c.Font=new function(){this.Styles="normal|italic|oblique|inherit",this.Variants="normal|small-caps|inherit",this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",this.CreateFont=function(a,b,d,e,f,g){var h=null!=g?this.Parse(g):this.CreateFont("","","","","",c.ctx.font);return{fontFamily:f||h.fontFamily,fontSize:e||h.fontSize,fontStyle:a||h.fontStyle,fontWeight:d||h.fontWeight,fontVariant:b||h.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var a=this;this.Parse=function(b){for(var d={},e=c.trim(c.compressSpaces(b||"")).split(" "),f={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},g="",h=0;h<e.length;h++)f.fontStyle||-1==a.Styles.indexOf(e[h])?f.fontVariant||-1==a.Variants.indexOf(e[h])?f.fontWeight||-1==a.Weights.indexOf(e[h])?f.fontSize?"inherit"!=e[h]&&(g+=e[h]):("inherit"!=e[h]&&(d.fontSize=e[h].split("/")[0]),f.fontStyle=f.fontVariant=f.fontWeight=f.fontSize=!0):("inherit"!=e[h]&&(d.fontWeight=e[h]),f.fontStyle=f.fontVariant=f.fontWeight=!0):("inherit"!=e[h]&&(d.fontVariant=e[h]),f.fontStyle=f.fontVariant=!0):("inherit"!=e[h]&&(d.fontStyle=e[h]),f.fontStyle=!0);return""!=g&&(d.fontFamily=g),d}},c.ToNumberArray=function(a){for(var b=c.trim(c.compressSpaces((a||"").replace(/,/g," "))).split(" "),d=0;d<b.length;d++)b[d]=parseFloat(b[d]);return b},c.Point=function(a,b){this.x=a,this.y=b},c.Point.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)},c.Point.prototype.applyTransform=function(a){var b=this.x*a[0]+this.y*a[2]+a[4],c=this.x*a[1]+this.y*a[3]+a[5];this.x=b,this.y=c},c.CreatePoint=function(a){var b=c.ToNumberArray(a);return new c.Point(b[0],b[1])},c.CreatePath=function(a){for(var b=c.ToNumberArray(a),d=[],e=0;e<b.length;e+=2)d.push(new c.Point(b[e],b[e+1]));return d},c.BoundingBox=function(a,b,c,d){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN,this.x=function(){return this.x1},this.y=function(){return this.y1},this.width=function(){return this.x2-this.x1},this.height=function(){return this.y2-this.y1},this.addPoint=function(a,b){null!=a&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=a,this.x2=a),a<this.x1&&(this.x1=a),a>this.x2&&(this.x2=a)),null!=b&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=b,this.y2=b),b<this.y1&&(this.y1=b),b>this.y2&&(this.y2=b))},this.addX=function(a){this.addPoint(a,null)},this.addY=function(a){this.addPoint(null,a)},this.addBoundingBox=function(a){this.addPoint(a.x1,a.y1),this.addPoint(a.x2,a.y2)},this.addQuadraticCurve=function(a,b,c,d,e,f){var g=a+2/3*(c-a),h=b+2/3*(d-b),i=g+1/3*(e-a),j=h+1/3*(f-b);this.addBezierCurve(a,b,g,i,h,j,e,f)},this.addBezierCurve=function(a,b,c,d,e,f,g,h){var j=[a,b],k=[c,d],l=[e,f],m=[g,h];for(this.addPoint(j[0],j[1]),this.addPoint(m[0],m[1]),i=0;1>=i;i++){var n=function(a){return Math.pow(1-a,3)*j[i]+3*Math.pow(1-a,2)*a*k[i]+3*(1-a)*Math.pow(a,2)*l[i]+Math.pow(a,3)*m[i]},o=6*j[i]-12*k[i]+6*l[i],p=-3*j[i]+9*k[i]-9*l[i]+3*m[i],q=3*k[i]-3*j[i];if(0!=p){var s=Math.pow(o,2)-4*q*p;if(!(0>s)){var t=(-o+Math.sqrt(s))/(2*p);t>0&&1>t&&(0==i&&this.addX(n(t)),1==i&&this.addY(n(t)));var u=(-o-Math.sqrt(s))/(2*p);u>0&&1>u&&(0==i&&this.addX(n(u)),1==i&&this.addY(n(u)))}}else{if(0==o)continue;var r=-q/o;r>0&&1>r&&(0==i&&this.addX(n(r)),1==i&&this.addY(n(r)))}}},this.isPointInBox=function(a,b){return this.x1<=a&&a<=this.x2&&this.y1<=b&&b<=this.y2},this.addPoint(a,b),this.addPoint(c,d)},c.Transform=function(a){var b=this;this.Type={},this.Type.translate=function(a){this.p=c.CreatePoint(a),this.apply=function(a){a.translate(this.p.x||0,this.p.y||0)},this.unapply=function(a){a.translate(-1*this.p.x||0,-1*this.p.y||0)},this.applyToPoint=function(a){a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},this.Type.rotate=function(a){var b=c.ToNumberArray(a);this.angle=new c.Property("angle",b[0]),this.cx=b[1]||0,this.cy=b[2]||0,this.apply=function(a){a.translate(this.cx,this.cy),a.rotate(this.angle.toRadians()),a.translate(-this.cx,-this.cy)},this.unapply=function(a){a.translate(this.cx,this.cy),a.rotate(-1*this.angle.toRadians()),a.translate(-this.cx,-this.cy)},this.applyToPoint=function(a){var b=this.angle.toRadians();a.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]),a.applyTransform([Math.cos(b),Math.sin(b),-Math.sin(b),Math.cos(b),0,0]),a.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}},this.Type.scale=function(a){this.p=c.CreatePoint(a),this.apply=function(a){a.scale(this.p.x||1,this.p.y||this.p.x||1)},this.unapply=function(a){a.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)},this.applyToPoint=function(a){a.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}},this.Type.matrix=function(a){this.m=c.ToNumberArray(a),this.apply=function(a){a.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])},this.unapply=function(a){var b=this.m[0],c=this.m[2],d=this.m[4],e=this.m[1],f=this.m[3],g=this.m[5],h=0,i=0,j=1,k=1/(b*(f*j-g*i)-c*(e*j-g*h)+d*(e*i-f*h));a.transform(k*(f*j-g*i),k*(g*h-e*j),k*(d*i-c*j),k*(b*j-d*h),k*(c*g-d*f),k*(d*e-b*g))},this.applyToPoint=function(a){a.applyTransform(this.m)}},this.Type.SkewBase=function(a){this.base=b.Type.matrix,this.base(a),this.angle=new c.Property("angle",a)},this.Type.SkewBase.prototype=new this.Type.matrix,this.Type.skewX=function(a){this.base=b.Type.SkewBase,this.base(a),this.m=[1,0,Math.tan(this.angle.toRadians()),1,0,0]},this.Type.skewX.prototype=new this.Type.SkewBase,this.Type.skewY=function(a){this.base=b.Type.SkewBase,this.base(a),this.m=[1,Math.tan(this.angle.toRadians()),0,1,0,0]},this.Type.skewY.prototype=new this.Type.SkewBase,this.transforms=[],this.apply=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].apply(a)},this.unapply=function(a){for(var b=this.transforms.length-1;b>=0;b--)this.transforms[b].unapply(a)},this.applyToPoint=function(a){for(var b=0;b<this.transforms.length;b++)this.transforms[b].applyToPoint(a)};for(var d=c.trim(c.compressSpaces(a)).replace(/\)([a-zA-Z])/g,") $1").replace(/\)(\s?,\s?)/g,") ").split(/\s(?=[a-z])/),e=0;e<d.length;e++){var f=c.trim(d[e].split("(")[0]),g=d[e].split("(")[1].replace(")",""),h=new this.Type[f](g);h.type=f,this.transforms.push(h)}},c.AspectRatio=function(a,b,d,e,f,g,h,i,j,k){b=c.compressSpaces(b),b=b.replace(/^defer\s/,"");var l=b.split(" ")[0]||"xMidYMid",m=b.split(" ")[1]||"meet",n=d/e,o=f/g,p=Math.min(n,o),q=Math.max(n,o);"meet"==m&&(e*=p,g*=p),"slice"==m&&(e*=q,g*=q),j=new c.Property("refX",j),k=new c.Property("refY",k),j.hasValue()&&k.hasValue()?a.translate(-p*j.toPixels("x"),-p*k.toPixels("y")):(l.match(/^xMid/)&&("meet"==m&&p==o||"slice"==m&&q==o)&&a.translate(d/2-e/2,0),l.match(/YMid$/)&&("meet"==m&&p==n||"slice"==m&&q==n)&&a.translate(0,f/2-g/2),l.match(/^xMax/)&&("meet"==m&&p==o||"slice"==m&&q==o)&&a.translate(d-e,0),l.match(/YMax$/)&&("meet"==m&&p==n||"slice"==m&&q==n)&&a.translate(0,f-g)),"none"==l?a.scale(n,o):"meet"==m?a.scale(p,p):"slice"==m&&a.scale(q,q),a.translate(null==h?0:-h,null==i?0:-i)},c.Element={},c.EmptyProperty=new c.Property("EMPTY",""),c.Element.ElementBase=function(b){if(this.attributes={},this.styles={},this.stylesSpecificity={},this.children=[],this.attribute=function(a,b){var d=this.attributes[a];return null!=d?d:(1==b&&(d=new c.Property(a,""),this.attributes[a]=d),d||c.EmptyProperty)},this.getHrefAttribute=function(){for(var a in this.attributes)if(a.match(/:href$/))return this.attributes[a];return c.EmptyProperty},this.style=function(a,b,d){var e=this.styles[a];if(null!=e)return e;var f=this.attribute(a);if(null!=f&&f.hasValue())return this.styles[a]=f,f;if(1!=d){var g=this.parent;if(null!=g){var h=g.style(a);if(null!=h&&h.hasValue())return h}}return 1==b&&(e=new c.Property(a,""),this.styles[a]=e),e||c.EmptyProperty},this.render=function(a){if("none"!=this.style("display").value&&"hidden"!=this.style("visibility").value){if(a.save(),this.attribute("mask").hasValue()){var b=this.attribute("mask").getDefinition();null!=b&&b.apply(a,this)}else if(this.style("filter").hasValue()){var c=this.style("filter").getDefinition();null!=c&&c.apply(a,this)}else this.setContext(a),this.renderChildren(a),this.clearContext(a);a.restore()}},this.setContext=function(){},this.clearContext=function(){},this.renderChildren=function(a){for(var b=0;b<this.children.length;b++)this.children[b].render(a)},this.addChild=function(a,b){var d=a;b&&(d=c.CreateElement(a)),d.parent=this,"title"!=d.type&&this.children.push(d)},this.addStylesFromStyleDefinition=function(){for(var d in c.Styles)if(a(b,d)){var e=c.Styles[d],f=c.StylesSpecificity[d];if(null!=e)for(var g in e){var h=this.stylesSpecificity[g];"undefined"==typeof h&&(h="000"),f>h&&(this.styles[g]=e[g],this.stylesSpecificity[g]=f)}}},null!=b&&1==b.nodeType){for(var d=0;d<b.attributes.length;d++){var e=b.attributes[d];this.attributes[e.nodeName]=new c.Property(e.nodeName,e.value)}if(this.addStylesFromStyleDefinition(),this.attribute("style").hasValue())for(var f=this.attribute("style").value.split(";"),d=0;d<f.length;d++)if(""!=c.trim(f[d])){var g=f[d].split(":"),h=c.trim(g[0]),i=c.trim(g[1]);this.styles[h]=new c.Property(h,i)}this.attribute("id").hasValue()&&null==c.Definitions[this.attribute("id").value]&&(c.Definitions[this.attribute("id").value]=this);for(var d=0;d<b.childNodes.length;d++){var j=b.childNodes[d];if(1==j.nodeType&&this.addChild(j,!0),this.captureTextNodes&&(3==j.nodeType||4==j.nodeType)){var k=j.value||j.text||j.textContent||"";""!=c.compressSpaces(k)&&this.addChild(new c.Element.tspan(j),!1)}}}},c.Element.RenderedElementBase=function(a){this.base=c.Element.ElementBase,this.base(a),this.setContext=function(a){if(this.style("fill").isUrlDefinition()){var b=this.style("fill").getFillStyleDefinition(this,this.style("fill-opacity"));null!=b&&(a.fillStyle=b)}else if(this.style("fill").hasValue()){var d=this.style("fill");"currentColor"==d.value&&(d.value=this.style("color").value),"inherit"!=d.value&&(a.fillStyle="none"==d.value?"rgba(0,0,0,0)":d.value)}if(this.style("fill-opacity").hasValue()){var d=new c.Property("fill",a.fillStyle);d=d.addOpacity(this.style("fill-opacity")),a.fillStyle=d.value}if(this.style("stroke").isUrlDefinition()){var b=this.style("stroke").getFillStyleDefinition(this,this.style("stroke-opacity"));null!=b&&(a.strokeStyle=b)}else if(this.style("stroke").hasValue()){var e=this.style("stroke");"currentColor"==e.value&&(e.value=this.style("color").value),"inherit"!=e.value&&(a.strokeStyle="none"==e.value?"rgba(0,0,0,0)":e.value)}if(this.style("stroke-opacity").hasValue()){var e=new c.Property("stroke",a.strokeStyle);e=e.addOpacity(this.style("stroke-opacity")),a.strokeStyle=e.value}if(this.style("stroke-width").hasValue()){var f=this.style("stroke-width").toPixels();a.lineWidth=0==f?.001:f}if(this.style("stroke-linecap").hasValue()&&(a.lineCap=this.style("stroke-linecap").value),this.style("stroke-linejoin").hasValue()&&(a.lineJoin=this.style("stroke-linejoin").value),this.style("stroke-miterlimit").hasValue()&&(a.miterLimit=this.style("stroke-miterlimit").value),this.style("stroke-dasharray").hasValue()&&"none"!=this.style("stroke-dasharray").value){var g=c.ToNumberArray(this.style("stroke-dasharray").value);"undefined"!=typeof a.setLineDash?a.setLineDash(g):"undefined"!=typeof a.webkitLineDash?a.webkitLineDash=g:"undefined"==typeof a.mozDash||1==g.length&&0==g[0]||(a.mozDash=g);var h=this.style("stroke-dashoffset").numValueOrDefault(1);"undefined"!=typeof a.lineDashOffset?a.lineDashOffset=h:"undefined"!=typeof a.webkitLineDashOffset?a.webkitLineDashOffset=h:"undefined"!=typeof a.mozDashOffset&&(a.mozDashOffset=h)}if("undefined"!=typeof a.font&&(a.font=c.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").toPixels()+"px":"",this.style("font-family").value).toString()),this.attribute("transform").hasValue()){var i=new c.Transform(this.attribute("transform").value);i.apply(a)}if(this.attribute("clip-path",!1,!0).hasValue()){var j=this.attribute("clip-path",!1,!0).getDefinition();null!=j&&j.apply(a)}this.style("opacity").hasValue()&&(a.globalAlpha=this.style("opacity").numValue())}},c.Element.RenderedElementBase.prototype=new c.Element.ElementBase,c.Element.PathElementBase=function(a){this.base=c.Element.RenderedElementBase,this.base(a),this.path=function(a){return null!=a&&a.beginPath(),new c.BoundingBox},this.renderChildren=function(a){this.path(a),c.Mouse.checkPath(this,a),""!=a.fillStyle&&("inherit"!=this.style("fill-rule").valueOrDefault("inherit")?a.fill(this.style("fill-rule").value):a.fill()),""!=a.strokeStyle&&a.stroke();var b=this.getMarkers();if(null!=b){if(this.style("marker-start").isUrlDefinition()){var d=this.style("marker-start").getDefinition();d.render(a,b[0][0],b[0][1])}if(this.style("marker-mid").isUrlDefinition())for(var d=this.style("marker-mid").getDefinition(),e=1;e<b.length-1;e++)d.render(a,b[e][0],b[e][1]);if(this.style("marker-end").isUrlDefinition()){var d=this.style("marker-end").getDefinition();d.render(a,b[b.length-1][0],b[b.length-1][1])}}},this.getBoundingBox=function(){return this.path()},this.getMarkers=function(){return null}},c.Element.PathElementBase.prototype=new c.Element.RenderedElementBase,c.Element.svg=function(a){this.base=c.Element.RenderedElementBase,this.base(a),this.baseClearContext=this.clearContext,this.clearContext=function(a){this.baseClearContext(a),c.ViewPort.RemoveCurrent()},this.baseSetContext=this.setContext,this.setContext=function(a){a.strokeStyle="rgba(0,0,0,0)",a.lineCap="butt",a.lineJoin="miter",a.miterLimit=4,"undefined"!=typeof a.font&&"undefined"!=typeof window.getComputedStyle&&(a.font=window.getComputedStyle(a.canvas).getPropertyValue("font")),this.baseSetContext(a),this.attribute("x").hasValue()||(this.attribute("x",!0).value=0),this.attribute("y").hasValue()||(this.attribute("y",!0).value=0),a.translate(this.attribute("x").toPixels("x"),this.attribute("y").toPixels("y"));var b=c.ViewPort.width(),d=c.ViewPort.height();if(this.attribute("width").hasValue()||(this.attribute("width",!0).value="100%"),this.attribute("height").hasValue()||(this.attribute("height",!0).value="100%"),"undefined"==typeof this.root){b=this.attribute("width").toPixels("x"),d=this.attribute("height").toPixels("y");var e=0,f=0;this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()&&(e=-this.attribute("refX").toPixels("x"),f=-this.attribute("refY").toPixels("y")),"visible"!=this.attribute("overflow").valueOrDefault("hidden")&&(a.beginPath(),a.moveTo(e,f),a.lineTo(b,f),a.lineTo(b,d),a.lineTo(e,d),a.closePath(),a.clip())}if(c.ViewPort.SetCurrent(b,d),this.attribute("viewBox").hasValue()){var g=c.ToNumberArray(this.attribute("viewBox").value),h=g[0],i=g[1];b=g[2],d=g[3],c.AspectRatio(a,this.attribute("preserveAspectRatio").value,c.ViewPort.width(),b,c.ViewPort.height(),d,h,i,this.attribute("refX").value,this.attribute("refY").value),c.ViewPort.RemoveCurrent(),c.ViewPort.SetCurrent(g[2],g[3])}}},c.Element.svg.prototype=new c.Element.RenderedElementBase,c.Element.rect=function(a){this.base=c.Element.PathElementBase,this.base(a),this.path=function(a){var b=this.attribute("x").toPixels("x"),d=this.attribute("y").toPixels("y"),e=this.attribute("width").toPixels("x"),f=this.attribute("height").toPixels("y"),g=this.attribute("rx").toPixels("x"),h=this.attribute("ry").toPixels("y");return this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue()&&(h=g),this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue()&&(g=h),g=Math.min(g,e/2),h=Math.min(h,f/2),null!=a&&(a.beginPath(),a.moveTo(b+g,d),a.lineTo(b+e-g,d),a.quadraticCurveTo(b+e,d,b+e,d+h),a.lineTo(b+e,d+f-h),a.quadraticCurveTo(b+e,d+f,b+e-g,d+f),a.lineTo(b+g,d+f),a.quadraticCurveTo(b,d+f,b,d+f-h),a.lineTo(b,d+h),a.quadraticCurveTo(b,d,b+g,d),a.closePath()),new c.BoundingBox(b,d,b+e,d+f)}},c.Element.rect.prototype=new c.Element.PathElementBase,c.Element.circle=function(a){this.base=c.Element.PathElementBase,this.base(a),this.path=function(a){var b=this.attribute("cx").toPixels("x"),d=this.attribute("cy").toPixels("y"),e=this.attribute("r").toPixels();return null!=a&&(a.beginPath(),a.arc(b,d,e,0,2*Math.PI,!0),a.closePath()),new c.BoundingBox(b-e,d-e,b+e,d+e) }},c.Element.circle.prototype=new c.Element.PathElementBase,c.Element.ellipse=function(a){this.base=c.Element.PathElementBase,this.base(a),this.path=function(a){var b=4*((Math.sqrt(2)-1)/3),d=this.attribute("rx").toPixels("x"),e=this.attribute("ry").toPixels("y"),f=this.attribute("cx").toPixels("x"),g=this.attribute("cy").toPixels("y");return null!=a&&(a.beginPath(),a.moveTo(f,g-e),a.bezierCurveTo(f+b*d,g-e,f+d,g-b*e,f+d,g),a.bezierCurveTo(f+d,g+b*e,f+b*d,g+e,f,g+e),a.bezierCurveTo(f-b*d,g+e,f-d,g+b*e,f-d,g),a.bezierCurveTo(f-d,g-b*e,f-b*d,g-e,f,g-e),a.closePath()),new c.BoundingBox(f-d,g-e,f+d,g+e)}},c.Element.ellipse.prototype=new c.Element.PathElementBase,c.Element.line=function(a){this.base=c.Element.PathElementBase,this.base(a),this.getPoints=function(){return[new c.Point(this.attribute("x1").toPixels("x"),this.attribute("y1").toPixels("y")),new c.Point(this.attribute("x2").toPixels("x"),this.attribute("y2").toPixels("y"))]},this.path=function(a){var b=this.getPoints();return null!=a&&(a.beginPath(),a.moveTo(b[0].x,b[0].y),a.lineTo(b[1].x,b[1].y)),new c.BoundingBox(b[0].x,b[0].y,b[1].x,b[1].y)},this.getMarkers=function(){var a=this.getPoints(),b=a[0].angleTo(a[1]);return[[a[0],b],[a[1],b]]}},c.Element.line.prototype=new c.Element.PathElementBase,c.Element.polyline=function(a){this.base=c.Element.PathElementBase,this.base(a),this.points=c.CreatePath(this.attribute("points").value),this.path=function(a){var b=new c.BoundingBox(this.points[0].x,this.points[0].y);null!=a&&(a.beginPath(),a.moveTo(this.points[0].x,this.points[0].y));for(var d=1;d<this.points.length;d++)b.addPoint(this.points[d].x,this.points[d].y),null!=a&&a.lineTo(this.points[d].x,this.points[d].y);return b},this.getMarkers=function(){for(var a=[],b=0;b<this.points.length-1;b++)a.push([this.points[b],this.points[b].angleTo(this.points[b+1])]);return a.push([this.points[this.points.length-1],a[a.length-1][1]]),a}},c.Element.polyline.prototype=new c.Element.PathElementBase,c.Element.polygon=function(a){this.base=c.Element.polyline,this.base(a),this.basePath=this.path,this.path=function(a){var b=this.basePath(a);return null!=a&&(a.lineTo(this.points[0].x,this.points[0].y),a.closePath()),b}},c.Element.polygon.prototype=new c.Element.polyline,c.Element.path=function(a){this.base=c.Element.PathElementBase,this.base(a);var b=this.attribute("d").value;b=b.replace(/,/gm," ");for(var d=0;2>d;d++)b=b.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");b=b.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2"),b=b.replace(/([0-9])([+\-])/gm,"$1 $2");for(var d=0;2>d;d++)b=b.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");b=b.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 "),b=c.compressSpaces(b),b=c.trim(b),this.PathParser=new function(a){this.tokens=a.split(" "),this.reset=function(){this.i=-1,this.command="",this.previousCommand="",this.start=new c.Point(0,0),this.control=new c.Point(0,0),this.current=new c.Point(0,0),this.points=[],this.angles=[]},this.isEnd=function(){return this.i>=this.tokens.length-1},this.isCommandOrEnd=function(){return this.isEnd()?!0:null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},this.getToken=function(){return this.i++,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var a=new c.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(a)},this.getAsControlPoint=function(){var a=this.getPoint();return this.control=a,a},this.getAsCurrentPoint=function(){var a=this.getPoint();return this.current=a,a},this.getReflectedControlPoint=function(){if("c"!=this.previousCommand.toLowerCase()&&"s"!=this.previousCommand.toLowerCase()&&"q"!=this.previousCommand.toLowerCase()&&"t"!=this.previousCommand.toLowerCase())return this.current;var a=new c.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y);return a},this.makeAbsolute=function(a){return this.isRelativeCommand()&&(a.x+=this.current.x,a.y+=this.current.y),a},this.addMarker=function(a,b,c){null!=c&&this.angles.length>0&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(c)),this.addMarkerAngle(a,null==b?null:b.angleTo(a))},this.addMarkerAngle=function(a,b){this.points.push(a),this.angles.push(b)},this.getMarkerPoints=function(){return this.points},this.getMarkerAngles=function(){for(var a=0;a<this.angles.length;a++)if(null==this.angles[a])for(var b=a+1;b<this.angles.length;b++)if(null!=this.angles[b]){this.angles[a]=this.angles[b];break}return this.angles}}(b),this.path=function(a){var b=this.PathParser;b.reset();var d=new c.BoundingBox;for(null!=a&&a.beginPath();!b.isEnd();)switch(b.nextCommand(),b.command){case"M":case"m":var e=b.getAsCurrentPoint();for(b.addMarker(e),d.addPoint(e.x,e.y),null!=a&&a.moveTo(e.x,e.y),b.start=b.current;!b.isCommandOrEnd();){var e=b.getAsCurrentPoint();b.addMarker(e,b.start),d.addPoint(e.x,e.y),null!=a&&a.lineTo(e.x,e.y)}break;case"L":case"l":for(;!b.isCommandOrEnd();){var f=b.current,e=b.getAsCurrentPoint();b.addMarker(e,f),d.addPoint(e.x,e.y),null!=a&&a.lineTo(e.x,e.y)}break;case"H":case"h":for(;!b.isCommandOrEnd();){var g=new c.Point((b.isRelativeCommand()?b.current.x:0)+b.getScalar(),b.current.y);b.addMarker(g,b.current),b.current=g,d.addPoint(b.current.x,b.current.y),null!=a&&a.lineTo(b.current.x,b.current.y)}break;case"V":case"v":for(;!b.isCommandOrEnd();){var g=new c.Point(b.current.x,(b.isRelativeCommand()?b.current.y:0)+b.getScalar());b.addMarker(g,b.current),b.current=g,d.addPoint(b.current.x,b.current.y),null!=a&&a.lineTo(b.current.x,b.current.y)}break;case"C":case"c":for(;!b.isCommandOrEnd();){var h=b.current,i=b.getPoint(),j=b.getAsControlPoint(),k=b.getAsCurrentPoint();b.addMarker(k,j,i),d.addBezierCurve(h.x,h.y,i.x,i.y,j.x,j.y,k.x,k.y),null!=a&&a.bezierCurveTo(i.x,i.y,j.x,j.y,k.x,k.y)}break;case"S":case"s":for(;!b.isCommandOrEnd();){var h=b.current,i=b.getReflectedControlPoint(),j=b.getAsControlPoint(),k=b.getAsCurrentPoint();b.addMarker(k,j,i),d.addBezierCurve(h.x,h.y,i.x,i.y,j.x,j.y,k.x,k.y),null!=a&&a.bezierCurveTo(i.x,i.y,j.x,j.y,k.x,k.y)}break;case"Q":case"q":for(;!b.isCommandOrEnd();){var h=b.current,j=b.getAsControlPoint(),k=b.getAsCurrentPoint();b.addMarker(k,j,j),d.addQuadraticCurve(h.x,h.y,j.x,j.y,k.x,k.y),null!=a&&a.quadraticCurveTo(j.x,j.y,k.x,k.y)}break;case"T":case"t":for(;!b.isCommandOrEnd();){var h=b.current,j=b.getReflectedControlPoint();b.control=j;var k=b.getAsCurrentPoint();b.addMarker(k,j,j),d.addQuadraticCurve(h.x,h.y,j.x,j.y,k.x,k.y),null!=a&&a.quadraticCurveTo(j.x,j.y,k.x,k.y)}break;case"A":case"a":for(;!b.isCommandOrEnd();){var h=b.current,l=b.getScalar(),m=b.getScalar(),n=b.getScalar()*(Math.PI/180),o=b.getScalar(),p=b.getScalar(),k=b.getAsCurrentPoint(),q=new c.Point(Math.cos(n)*(h.x-k.x)/2+Math.sin(n)*(h.y-k.y)/2,-Math.sin(n)*(h.x-k.x)/2+Math.cos(n)*(h.y-k.y)/2),r=Math.pow(q.x,2)/Math.pow(l,2)+Math.pow(q.y,2)/Math.pow(m,2);r>1&&(l*=Math.sqrt(r),m*=Math.sqrt(r));var s=(o==p?-1:1)*Math.sqrt((Math.pow(l,2)*Math.pow(m,2)-Math.pow(l,2)*Math.pow(q.y,2)-Math.pow(m,2)*Math.pow(q.x,2))/(Math.pow(l,2)*Math.pow(q.y,2)+Math.pow(m,2)*Math.pow(q.x,2)));isNaN(s)&&(s=0);var t=new c.Point(s*l*q.y/m,s*-m*q.x/l),u=new c.Point((h.x+k.x)/2+Math.cos(n)*t.x-Math.sin(n)*t.y,(h.y+k.y)/2+Math.sin(n)*t.x+Math.cos(n)*t.y),v=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2))},w=function(a,b){return(a[0]*b[0]+a[1]*b[1])/(v(a)*v(b))},x=function(a,b){return(a[0]*b[1]<a[1]*b[0]?-1:1)*Math.acos(w(a,b))},y=x([1,0],[(q.x-t.x)/l,(q.y-t.y)/m]),z=[(q.x-t.x)/l,(q.y-t.y)/m],A=[(-q.x-t.x)/l,(-q.y-t.y)/m],B=x(z,A);w(z,A)<=-1&&(B=Math.PI),w(z,A)>=1&&(B=0);var C=1-p?1:-1,D=y+C*(B/2),E=new c.Point(u.x+l*Math.cos(D),u.y+m*Math.sin(D));if(b.addMarkerAngle(E,D-C*Math.PI/2),b.addMarkerAngle(k,D-C*Math.PI),d.addPoint(k.x,k.y),null!=a){var w=l>m?l:m,F=l>m?1:l/m,G=l>m?m/l:1;a.translate(u.x,u.y),a.rotate(n),a.scale(F,G),a.arc(0,0,w,y,y+B,1-p),a.scale(1/F,1/G),a.rotate(-n),a.translate(-u.x,-u.y)}}break;case"Z":case"z":null!=a&&a.closePath(),b.current=b.start}return d},this.getMarkers=function(){for(var a=this.PathParser.getMarkerPoints(),b=this.PathParser.getMarkerAngles(),c=[],d=0;d<a.length;d++)c.push([a[d],b[d]]);return c}},c.Element.path.prototype=new c.Element.PathElementBase,c.Element.pattern=function(a){this.base=c.Element.ElementBase,this.base(a),this.createPattern=function(a){var d=this.attribute("width").toPixels("x",!0),e=this.attribute("height").toPixels("y",!0),f=new c.Element.svg;f.attributes.viewBox=new c.Property("viewBox",this.attribute("viewBox").value),f.attributes.width=new c.Property("width",d+"px"),f.attributes.height=new c.Property("height",e+"px"),f.attributes.transform=new c.Property("transform",this.attribute("patternTransform").value),f.children=this.children;var g=document.createElement("canvas");g.width=d,g.height=e;var h=g.getContext("2d");this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&h.translate(this.attribute("x").toPixels("x",!0),this.attribute("y").toPixels("y",!0));for(var i=-1;1>=i;i++)for(var j=-1;1>=j;j++)h.save(),h.translate(i*g.width,j*g.height),f.render(h),h.restore();var k=a.createPattern(g,"repeat");return k}},c.Element.pattern.prototype=new c.Element.ElementBase,c.Element.marker=function(a){this.base=c.Element.ElementBase,this.base(a),this.baseRender=this.render,this.render=function(a,b,d){a.translate(b.x,b.y),"auto"==this.attribute("orient").valueOrDefault("auto")&&a.rotate(d),"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&a.scale(a.lineWidth,a.lineWidth),a.save();var e=new c.Element.svg;e.attributes.viewBox=new c.Property("viewBox",this.attribute("viewBox").value),e.attributes.refX=new c.Property("refX",this.attribute("refX").value),e.attributes.refY=new c.Property("refY",this.attribute("refY").value),e.attributes.width=new c.Property("width",this.attribute("markerWidth").value),e.attributes.height=new c.Property("height",this.attribute("markerHeight").value),e.attributes.fill=new c.Property("fill",this.attribute("fill").valueOrDefault("black")),e.attributes.stroke=new c.Property("stroke",this.attribute("stroke").valueOrDefault("none")),e.children=this.children,e.render(a),a.restore(),"strokeWidth"==this.attribute("markerUnits").valueOrDefault("strokeWidth")&&a.scale(1/a.lineWidth,1/a.lineWidth),"auto"==this.attribute("orient").valueOrDefault("auto")&&a.rotate(-d),a.translate(-b.x,-b.y)}},c.Element.marker.prototype=new c.Element.ElementBase,c.Element.defs=function(a){this.base=c.Element.ElementBase,this.base(a),this.render=function(){}},c.Element.defs.prototype=new c.Element.ElementBase,c.Element.GradientBase=function(a){this.base=c.Element.ElementBase,this.base(a),this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox"),this.stops=[];for(var b=0;b<this.children.length;b++){var d=this.children[b];"stop"==d.type&&this.stops.push(d)}this.getGradient=function(){},this.createGradient=function(a,b,d){var e=this;this.getHrefAttribute().hasValue()&&(e=this.getHrefAttribute().getDefinition());var f=function(a){if(d.hasValue()){var b=new c.Property("color",a);return b.addOpacity(d).value}return a},g=this.getGradient(a,b);if(null==g)return f(e.stops[e.stops.length-1].color);for(var h=0;h<e.stops.length;h++)g.addColorStop(e.stops[h].offset,f(e.stops[h].color));if(this.attribute("gradientTransform").hasValue()){var i=c.ViewPort.viewPorts[0],j=new c.Element.rect;j.attributes.x=new c.Property("x",-c.MAX_VIRTUAL_PIXELS/3),j.attributes.y=new c.Property("y",-c.MAX_VIRTUAL_PIXELS/3),j.attributes.width=new c.Property("width",c.MAX_VIRTUAL_PIXELS),j.attributes.height=new c.Property("height",c.MAX_VIRTUAL_PIXELS);var k=new c.Element.g;k.attributes.transform=new c.Property("transform",this.attribute("gradientTransform").value),k.children=[j];var l=new c.Element.svg;l.attributes.x=new c.Property("x",0),l.attributes.y=new c.Property("y",0),l.attributes.width=new c.Property("width",i.width),l.attributes.height=new c.Property("height",i.height),l.children=[k];var m=document.createElement("canvas");m.width=i.width,m.height=i.height;var n=m.getContext("2d");return n.fillStyle=g,l.render(n),n.createPattern(m,"no-repeat")}return g}},c.Element.GradientBase.prototype=new c.Element.ElementBase,c.Element.linearGradient=function(a){this.base=c.Element.GradientBase,this.base(a),this.getGradient=function(a,b){var c="objectBoundingBox"==this.gradientUnits?b.getBoundingBox():null;this.attribute("x1").hasValue()||this.attribute("y1").hasValue()||this.attribute("x2").hasValue()||this.attribute("y2").hasValue()||(this.attribute("x1",!0).value=0,this.attribute("y1",!0).value=0,this.attribute("x2",!0).value=1,this.attribute("y2",!0).value=0);var d="objectBoundingBox"==this.gradientUnits?c.x()+c.width()*this.attribute("x1").numValue():this.attribute("x1").toPixels("x"),e="objectBoundingBox"==this.gradientUnits?c.y()+c.height()*this.attribute("y1").numValue():this.attribute("y1").toPixels("y"),f="objectBoundingBox"==this.gradientUnits?c.x()+c.width()*this.attribute("x2").numValue():this.attribute("x2").toPixels("x"),g="objectBoundingBox"==this.gradientUnits?c.y()+c.height()*this.attribute("y2").numValue():this.attribute("y2").toPixels("y");return d==f&&e==g?null:a.createLinearGradient(d,e,f,g)}},c.Element.linearGradient.prototype=new c.Element.GradientBase,c.Element.radialGradient=function(a){this.base=c.Element.GradientBase,this.base(a),this.getGradient=function(a,b){var c=b.getBoundingBox();this.attribute("cx").hasValue()||(this.attribute("cx",!0).value="50%"),this.attribute("cy").hasValue()||(this.attribute("cy",!0).value="50%"),this.attribute("r").hasValue()||(this.attribute("r",!0).value="50%");var d="objectBoundingBox"==this.gradientUnits?c.x()+c.width()*this.attribute("cx").numValue():this.attribute("cx").toPixels("x"),e="objectBoundingBox"==this.gradientUnits?c.y()+c.height()*this.attribute("cy").numValue():this.attribute("cy").toPixels("y"),f=d,g=e;this.attribute("fx").hasValue()&&(f="objectBoundingBox"==this.gradientUnits?c.x()+c.width()*this.attribute("fx").numValue():this.attribute("fx").toPixels("x")),this.attribute("fy").hasValue()&&(g="objectBoundingBox"==this.gradientUnits?c.y()+c.height()*this.attribute("fy").numValue():this.attribute("fy").toPixels("y"));var h="objectBoundingBox"==this.gradientUnits?(c.width()+c.height())/2*this.attribute("r").numValue():this.attribute("r").toPixels();return a.createRadialGradient(f,g,0,d,e,h)}},c.Element.radialGradient.prototype=new c.Element.GradientBase,c.Element.stop=function(a){this.base=c.Element.ElementBase,this.base(a),this.offset=this.attribute("offset").numValue(),this.offset<0&&(this.offset=0),this.offset>1&&(this.offset=1);var b=this.style("stop-color",!0);""===b.value&&(b.value="#000"),this.style("stop-opacity").hasValue()&&(b=b.addOpacity(this.style("stop-opacity"))),this.color=b.value},c.Element.stop.prototype=new c.Element.ElementBase,c.Element.AnimateBase=function(a){this.base=c.Element.ElementBase,this.base(a),c.Animations.push(this),this.duration=0,this.begin=this.attribute("begin").toMilliseconds(),this.maxDuration=this.begin+this.attribute("dur").toMilliseconds(),this.getProperty=function(){var a=this.attribute("attributeType").value,b=this.attribute("attributeName").value;return"CSS"==a?this.parent.style(b,!0):this.parent.attribute(b,!0)},this.initialValue=null,this.initialUnits="",this.removed=!1,this.calcValue=function(){return""},this.update=function(a){if(null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits()),this.duration>this.maxDuration){if("indefinite"==this.attribute("repeatCount").value||"indefinite"==this.attribute("repeatDur").value)this.duration=0;else if("freeze"!=this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"==this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration=this.duration+a;var b=!1;if(this.begin<this.duration){var c=this.calcValue();if(this.attribute("type").hasValue()){var d=this.attribute("type").value;c=d+"("+c+")"}this.getProperty().value=c,b=!0}return b},this.from=this.attribute("from"),this.to=this.attribute("to"),this.values=this.attribute("values"),this.values.hasValue()&&(this.values.value=this.values.value.split(";")),this.progress=function(){var a={progress:(this.duration-this.begin)/(this.maxDuration-this.begin)};if(this.values.hasValue()){var b=a.progress*(this.values.value.length-1),d=Math.floor(b),e=Math.ceil(b);a.from=new c.Property("from",parseFloat(this.values.value[d])),a.to=new c.Property("to",parseFloat(this.values.value[e])),a.progress=(b-d)/(e-d)}else a.from=this.from,a.to=this.to;return a}},c.Element.AnimateBase.prototype=new c.Element.ElementBase,c.Element.animate=function(a){this.base=c.Element.AnimateBase,this.base(a),this.calcValue=function(){var a=this.progress(),b=a.from.numValue()+(a.to.numValue()-a.from.numValue())*a.progress;return b+this.initialUnits}},c.Element.animate.prototype=new c.Element.AnimateBase,c.Element.animateColor=function(a){this.base=c.Element.AnimateBase,this.base(a),this.calcValue=function(){var a=this.progress(),b=new RGBColor(a.from.value),c=new RGBColor(a.to.value);if(b.ok&&c.ok){var d=b.r+(c.r-b.r)*a.progress,e=b.g+(c.g-b.g)*a.progress,f=b.b+(c.b-b.b)*a.progress;return"rgb("+parseInt(d,10)+","+parseInt(e,10)+","+parseInt(f,10)+")"}return this.attribute("from").value}},c.Element.animateColor.prototype=new c.Element.AnimateBase,c.Element.animateTransform=funct