//>>built
define("dojox/gfx/canvas","./_base dojo/_base/lang dojo/_base/array dojo/_base/declare dojo/_base/window dojo/dom-geometry dojo/dom ./shape ./path ./arc ./matrix ./decompose ./bezierutils".split(" "),function(x,G,O,t,H,V,W,r,I,R,J,A,M){function N(c,b,a,d,e,g,f,k,m,l){var u=b.length,q=0;if(l){var v=l.l/e;q=l.i}else v=b[0]/e;for(;g<f;){if(g+v>f){var K={l:(g+v-f)*e,i:q};v=f-g}q%2||(c.beginPath(),c.arc(a,d,e,g,g+v,k),m&&c.stroke());g+=v;++q;v=b[q%u]/e}return K}function S(c,b,a,d){var e=0,g=0,f=0;if(d){var k=
d.l;f=d.i}else k=b[0];for(;1>g;)g=M.tAtLength(c,k),1==g&&(e=M.computeLength(c),e={l:k-e,i:f}),c=M.splitBezierAtT(c,g),f%2||a.push(c[0]),c=c[1],++f,k=b[f%b.length];return e}function w(c,b,a,d){var e=[b.last.x,b.last.y].concat(a),g=!(c instanceof Array);a=4===a.length?"quadraticCurveTo":"bezierCurveTo";var f=[];b=S(e,b.canvasDash,f,d);for(d=0;d<f.length;++d)e=f[d],g?(c.moveTo(e[0],e[1]),c[a].apply(c,e.slice(2))):(c.push("moveTo",[e[0],e[1]]),c.push(a,e.slice(2)));return b}function n(c,b,a,d,e,g,f){var k=
0,m=0,l=0,u=M.distance(a,d,e,g),q=0;b=b.canvasDash;var v=a,K=d,X=!(c instanceof Array);f?(l=f.l,q=f.i):l+=b[0];for(;.01<Math.abs(1-m);){l>u&&(k={l:l-u,i:q},l=u);m=l/u;f=a+(e-a)*m;var P=d+(g-d)*m;q++%2||(X?(c.moveTo(v,K),c.lineTo(f,P)):(c.push("moveTo",[v,K]),c.push("lineTo",[f,P])));v=f;K=P;l+=b[q%b.length]}return k}var h=x.canvas={},D=null,B=J.multiplyPoint,y=Math.PI,T=2*y,z=y/2;A=G.extend;if(H.global.CanvasRenderingContext2D){H=H.doc.createElement("canvas").getContext("2d");var L="function"==typeof H.setLineDash,
Y="function"==typeof H.fillText}var U={solid:"none",shortdash:[4,1],shortdot:[1,1],shortdashdot:[4,1,1,1],shortdashdotdot:[4,1,1,1,1,1],dot:[1,3],dash:[4,3],longdash:[8,3],dashdot:[4,3,1,3],longdashdot:[8,3,1,3],longdashdotdot:[8,3,1,3,1,3]};h.Shape=t("dojox.gfx.canvas.Shape",r.Shape,{_render:function(c){c.save();this._renderTransform(c);this._renderClip(c);this._renderShape(c);this._renderFill(c,!0);this._renderStroke(c,!0);c.restore()},_renderClip:function(c){this.canvasClip&&(this.canvasClip.render(c),
c.clip())},_renderTransform:function(c){if("canvasTransform"in this){var b=this.canvasTransform;c.translate(b.dx,b.dy);c.rotate(b.angle2);c.scale(b.sx,b.sy);c.rotate(b.angle1)}},_renderShape:function(c){},_renderFill:function(c,b){if("canvasFill"in this){var a=this.fillStyle;if("canvasFillImage"in this){var d=a.width,e=a.height,g=this.canvasFillImage.width,f=this.canvasFillImage.height,k=Math.min(d==g?1:d/g,e==f?1:e/f),m=(d-k*g)/2,l=(e-k*f)/2;D.width=d;D.height=e;var u=D.getContext("2d");u.clearRect(0,
0,d,e);u.drawImage(this.canvasFillImage,0,0,g,f,m,l,k*g,k*f);this.canvasFill=c.createPattern(D,"repeat");delete this.canvasFillImage}c.fillStyle=this.canvasFill;b&&("pattern"!==a.type||0===a.x&&0===a.y||c.translate(a.x,a.y),c.fill())}else c.fillStyle="rgba(0,0,0,0.0)"},_renderStroke:function(c,b){var a=this.strokeStyle;a?(c.strokeStyle=a.color.toString(),c.lineWidth=a.width,c.lineCap=a.cap,"number"==typeof a.join?(c.lineJoin="miter",c.miterLimit=a.join):c.lineJoin=a.join,this.canvasDash?L?(c.setLineDash(this.canvasDash),
b&&c.stroke()):this._renderDashedStroke(c,b):b&&c.stroke()):b||(c.strokeStyle="rgba(0,0,0,0.0)")},_renderDashedStroke:function(c,b){},getEventSource:function(){return null},on:function(){},connect:function(){},disconnect:function(){},canvasClip:null,setClip:function(c){this.inherited(arguments);var b=c?"width"in c?"rect":"cx"in c?"ellipse":"points"in c?"polyline":"d"in c?"path":null:null;if(c&&!b)return this;this.canvasClip=c?Z(b,c):null;this.parent&&this.parent._makeDirty();return this}});var Z=
function(c,b){switch(c){case "ellipse":return{canvasEllipse:Q({shape:b}),render:function(a){return h.Ellipse.prototype._renderShape.call(this,a)}};case "rect":return{shape:G.delegate(b,{r:0}),render:function(a){return h.Rect.prototype._renderShape.call(this,a)}};case "path":return{canvasPath:aa(b),render:function(a){this.canvasPath._renderShape(a)}};case "polyline":return{canvasPolyline:b.points,render:function(a){return h.Polyline.prototype._renderShape.call(this,a)}}}return null},aa=function(c){var b=
new dojox.gfx.canvas.Path;b.canvasPath=[];b._setPath(c.d);return b},E=function(c,b,a){var d=c.prototype[b];c.prototype[b]=a?function(){this.parent&&this.parent._makeDirty();d.apply(this,arguments);a.call(this);return this}:function(){this.parent&&this.parent._makeDirty();return d.apply(this,arguments)}};E(h.Shape,"setTransform",function(){this.matrix?this.canvasTransform=x.decompose(this.matrix):delete this.canvasTransform});E(h.Shape,"setFill",function(){var c=this.fillStyle;if(c){if("object"==typeof c&&
"type"in c){var b=this.surface.rawNode.getContext("2d");switch(c.type){case "linear":case "radial":var a="linear"==c.type?b.createLinearGradient(c.x1,c.y1,c.x2,c.y2):b.createRadialGradient(c.cx,c.cy,0,c.cx,c.cy,c.r);O.forEach(c.colors,function(d){a.addColorStop(d.offset,x.normalizeColor(d.color).toString())});break;case "pattern":D||(D=document.createElement("canvas")),b=new Image,this.surface.downloadImage(b,c.src),this.canvasFillImage=b}}else a=c.toString();this.canvasFill=a}else delete this.canvasFill});
E(h.Shape,"setStroke",function(){var c=this.strokeStyle;if(c){var b=this.strokeStyle.style.toLowerCase();b in U&&(b=U[b]);if(b instanceof Array){this.canvasDash=b=b.slice();var a;for(a=0;a<b.length;++a)b[a]*=c.width;if("butt"!=c.cap){for(a=0;a<b.length;a+=2)b[a]-=c.width,1>b[a]&&(b[a]=1);for(a=1;a<b.length;a+=2)b[a]+=c.width}}else delete this.canvasDash}else delete this.canvasDash;this._needsDash=!L&&!!this.canvasDash});E(h.Shape,"setShape");h.Group=t("dojox.gfx.canvas.Group",h.Shape,{constructor:function(){r.Container._init.call(this)},
_render:function(c){c.save();this._renderTransform(c);this._renderClip(c);for(var b=0;b<this.children.length;++b)this.children[b]._render(c);c.restore()},destroy:function(){r.Container.clear.call(this,!0);h.Shape.prototype.destroy.apply(this,arguments)}});h.Rect=t("dojox.gfx.canvas.Rect",[h.Shape,r.Rect],{_renderShape:function(c){var b=this.shape,a=Math.min(b.r,b.height/2,b.width/2),d=b.x,e=d+b.width,g=b.y;b=g+b.height;var f=d+a,k=e-a,m=g+a,l=b-a;c.beginPath();c.moveTo(f,g);a?(c.arc(k,m,a,-z,0,!1),
c.arc(k,l,a,0,z,!1),c.arc(f,l,a,z,y,!1),c.arc(f,m,a,y,y+z,!1)):(c.lineTo(k,g),c.lineTo(e,l),c.lineTo(f,b),c.lineTo(d,m));c.closePath()},_renderDashedStroke:function(c,b){var a=this.shape,d=Math.min(a.r,a.height/2,a.width/2),e=a.x,g=e+a.width,f=a.y,k=f+a.height,m=e+d,l=g-d,u=f+d,q=k-d;d?(c.beginPath(),a=n(c,this,m,f,l,f),b&&c.stroke(),a=N(c,this.canvasDash,l,u,d,-z,0,!1,b,a),c.beginPath(),a=n(c,this,g,u,g,q,a),b&&c.stroke(),a=N(c,this.canvasDash,l,q,d,0,z,!1,b,a),c.beginPath(),a=n(c,this,l,k,m,k,a),
b&&c.stroke(),a=N(c,this.canvasDash,m,q,d,z,y,!1,b,a),c.beginPath(),a=n(c,this,e,q,e,u,a),b&&c.stroke(),N(c,this.canvasDash,m,u,d,y,y+z,!1,b,a)):(c.beginPath(),a=n(c,this,m,f,l,f),a=n(c,this,l,f,g,q,a),a=n(c,this,g,q,m,k,a),n(c,this,m,k,e,u,a),b&&c.stroke())}});var C=[];(function(){var c=R.curvePI4;C.push(c.s,c.c1,c.c2,c.e);for(var b=45;360>b;b+=45){var a=J.rotateg(b);C.push(B(a,c.c1),B(a,c.c2),B(a,c.e))}})();var Q=function(c){var b=[],a=c.shape,d=J.normalize([J.translate(a.cx,a.cy),J.scale(a.rx,
a.ry)]);var e=B(d,C[0]);b.push([e.x,e.y]);for(a=1;a<C.length;a+=3){var g=B(d,C[a]);var f=B(d,C[a+1]);e=B(d,C[a+2]);b.push([g.x,g.y,f.x,f.y,e.x,e.y])}if(c._needsDash){e=[];g=b[0];for(a=1;a<b.length;++a)f=[],S(g.concat(b[a]),c.canvasDash,f),g=[b[a][4],b[a][5]],e.push(f);c._dashedPoints=e}return b};h.Ellipse=t("dojox.gfx.canvas.Ellipse",[h.Shape,r.Ellipse],{setShape:function(){this.inherited(arguments);this.canvasEllipse=Q(this);return this},setStroke:function(){this.inherited(arguments);L||(this.canvasEllipse=
Q(this));return this},_renderShape:function(c){var b=this.canvasEllipse,a;c.beginPath();c.moveTo.apply(c,b[0]);for(a=1;a<b.length;++a)c.bezierCurveTo.apply(c,b[a]);c.closePath()},_renderDashedStroke:function(c,b){var a=this._dashedPoints;c.beginPath();for(var d=0;d<a.length;++d)for(var e=a[d],g=0;g<e.length;++g){var f=e[g];c.moveTo(f[0],f[1]);c.bezierCurveTo(f[2],f[3],f[4],f[5],f[6],f[7])}b&&c.stroke()}});h.Circle=t("dojox.gfx.canvas.Circle",[h.Shape,r.Circle],{_renderShape:function(c){var b=this.shape;
c.beginPath();c.arc(b.cx,b.cy,b.r,0,T,1)},_renderDashedStroke:function(c,b){var a=this.shape,d=0,e=this.canvasDash.length;for(i=0;d<T;){var g=this.canvasDash[i%e]/a.r;i%2||(c.beginPath(),c.arc(a.cx,a.cy,a.r,d,d+g,0),b&&c.stroke());d+=g;++i}}});h.Line=t("dojox.gfx.canvas.Line",[h.Shape,r.Line],{_renderShape:function(c){var b=this.shape;c.beginPath();c.moveTo(b.x1,b.y1);c.lineTo(b.x2,b.y2)},_renderDashedStroke:function(c,b){var a=this.shape;c.beginPath();n(c,this,a.x1,a.y1,a.x2,a.y2);b&&c.stroke()}});
h.Polyline=t("dojox.gfx.canvas.Polyline",[h.Shape,r.Polyline],{setShape:function(){this.inherited(arguments);var c=this.shape.points,b=c[0],a;this.bbox=null;this._normalizePoints();if(c.length)if("number"==typeof b)b=c;else for(b=[],a=0;a<c.length;++a){var d=c[a];b.push(d.x,d.y)}else b=[];this.canvasPolyline=b;return this},_renderShape:function(c){var b=this.canvasPolyline;if(b.length){c.beginPath();c.moveTo(b[0],b[1]);for(var a=2;a<b.length;a+=2)c.lineTo(b[a],b[a+1])}},_renderDashedStroke:function(c,
b){var a=this.canvasPolyline,d=0;c.beginPath();for(var e=0;e<a.length;e+=2)d=n(c,this,a[e],a[e+1],a[e+2],a[e+3],d);b&&c.stroke()}});h.Image=t("dojox.gfx.canvas.Image",[h.Shape,r.Image],{setShape:function(){this.inherited(arguments);var c=new Image;this.surface.downloadImage(c,this.shape.src);this.canvasImage=c;return this},_renderShape:function(c){var b=this.shape;c.drawImage(this.canvasImage,b.x,b.y,b.width,b.height)}});h.Text=t("dojox.gfx.canvas.Text",[h.Shape,r.Text],{_setFont:function(){this.fontStyle?
this.canvasFont=x.makeFontString(this.fontStyle):delete this.canvasFont},getTextWidth:function(){var c=this.shape,b=0;if(c.text){var a=this.surface.rawNode.getContext("2d");a.save();this._renderTransform(a);this._renderFill(a,!1);this._renderStroke(a,!1);this.canvasFont&&(a.font=this.canvasFont);b=a.measureText(c.text).width;a.restore()}return b},_render:function(c){c.save();this._renderTransform(c);this._renderFill(c,!1);this._renderStroke(c,!1);this._renderShape(c);c.restore()},_renderShape:function(c){var b=
this.shape;b.text&&(c.textAlign="middle"===b.align?"center":b.align,this.canvasFont&&(c.font=this.canvasFont),this.canvasFill&&c.fillText(b.text,b.x,b.y),this.strokeStyle&&(c.beginPath(),c.strokeText(b.text,b.x,b.y),c.closePath()))}});E(h.Text,"setFont");Y||h.Text.extend({getTextWidth:function(){return 0},getBoundingBox:function(){return null},_renderShape:function(){}});var ba={M:"_moveToA",m:"_moveToR",L:"_lineToA",l:"_lineToR",H:"_hLineToA",h:"_hLineToR",V:"_vLineToA",v:"_vLineToR",C:"_curveToA",
c:"_curveToR",S:"_smoothCurveToA",s:"_smoothCurveToR",Q:"_qCurveToA",q:"_qCurveToR",T:"_qSmoothCurveToA",t:"_qSmoothCurveToR",A:"_arcTo",a:"_arcTo",Z:"_closePath",z:"_closePath"};h.Path=t("dojox.gfx.canvas.Path",[h.Shape,I.Path],{constructor:function(){this.lastControl={}},setShape:function(){this.canvasPath=[];this._dashedPath=[];return this.inherited(arguments)},setStroke:function(){this.inherited(arguments);L||(this.segmented=!1,this._confirmSegmented());return this},_setPath:function(){this._dashResidue=
null;this.inherited(arguments)},_updateWithSegment:function(c){var b=G.clone(this.last);this[ba[c.action]](this.canvasPath,c.action,c.args,this._needsDash?this._dashedPath:null);this.last=b;this.inherited(arguments)},_renderShape:function(c){var b=this.canvasPath;c.beginPath();for(var a=0;a<b.length;a+=2)c[b[a]].apply(c,b[a+1])},_renderDashedStroke:L?function(){}:function(c,b){var a=this._dashedPath;c.beginPath();for(var d=0;d<a.length;d+=2)c[a[d]].apply(c,a[d+1]);b&&c.stroke()},_moveToA:function(c,
b,a,d){c.push("moveTo",[a[0],a[1]]);d&&d.push("moveTo",[a[0],a[1]]);for(b=2;b<a.length;b+=2)c.push("lineTo",[a[b],a[b+1]]),d&&(this._dashResidue=n(d,this,a[b-2],a[b-1],a[b],a[b+1],this._dashResidue));this.last.x=a[a.length-2];this.last.y=a[a.length-1];this.lastControl={}},_moveToR:function(c,b,a,d){b="x"in this.last?[this.last.x+=a[0],this.last.y+=a[1]]:[this.last.x=a[0],this.last.y=a[1]];c.push("moveTo",b);d&&d.push("moveTo",b);for(b=2;b<a.length;b+=2)c.push("lineTo",[this.last.x+=a[b],this.last.y+=
a[b+1]]),d&&(this._dashResidue=n(d,this,d[d.length-1][0],d[d.length-1][1],this.last.x,this.last.y,this._dashResidue));this.lastControl={}},_lineToA:function(c,b,a,d){for(b=0;b<a.length;b+=2)d&&(this._dashResidue=n(d,this,this.last.x,this.last.y,a[b],a[b+1],this._dashResidue)),c.push("lineTo",[a[b],a[b+1]]);this.last.x=a[a.length-2];this.last.y=a[a.length-1];this.lastControl={}},_lineToR:function(c,b,a,d){for(b=0;b<a.length;b+=2)c.push("lineTo",[this.last.x+=a[b],this.last.y+=a[b+1]]),d&&(this._dashResidue=
n(d,this,d[d.length-1][0],d[d.length-1][1],this.last.x,this.last.y,this._dashResidue));this.lastControl={}},_hLineToA:function(c,b,a,d){for(b=0;b<a.length;++b)c.push("lineTo",[a[b],this.last.y]),d&&(this._dashResidue=n(d,this,d[d.length-1][0],d[d.length-1][1],a[b],this.last.y,this._dashResidue));this.last.x=a[a.length-1];this.lastControl={}},_hLineToR:function(c,b,a,d){for(b=0;b<a.length;++b)c.push("lineTo",[this.last.x+=a[b],this.last.y]),d&&(this._dashResidue=n(d,this,d[d.length-1][0],d[d.length-
1][1],this.last.x,this.last.y,this._dashResidue));this.lastControl={}},_vLineToA:function(c,b,a,d){for(b=0;b<a.length;++b)c.push("lineTo",[this.last.x,a[b]]),d&&(this._dashResidue=n(d,this,d[d.length-1][0],d[d.length-1][1],this.last.x,a[b],this._dashResidue));this.last.y=a[a.length-1];this.lastControl={}},_vLineToR:function(c,b,a,d){for(b=0;b<a.length;++b)c.push("lineTo",[this.last.x,this.last.y+=a[b]]),d&&(this._dashResidue=n(d,this,d[d.length-1][0],d[d.length-1][1],this.last.x,this.last.y,this._dashResidue));
this.lastControl={}},_curveToA:function(c,b,a,d){for(b=0;b<a.length;b+=6)c.push("bezierCurveTo",a.slice(b,b+6)),d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue));this.last.x=a[a.length-2];this.last.y=a[a.length-1];this.lastControl.x=a[a.length-4];this.lastControl.y=a[a.length-3];this.lastControl.type="C"},_curveToR:function(c,b,a,d){for(b=0;b<a.length;b+=6)c.push("bezierCurveTo",[this.last.x+a[b],this.last.y+a[b+1],this.lastControl.x=this.last.x+a[b+2],this.lastControl.y=this.last.y+
a[b+3],this.last.x+a[b+4],this.last.y+a[b+5]]),d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue)),this.last.x+=a[b+4],this.last.y+=a[b+5];this.lastControl.type="C"},_smoothCurveToA:function(c,b,a,d){for(b=0;b<a.length;b+=4){var e="C"==this.lastControl.type;c.push("bezierCurveTo",[e?2*this.last.x-this.lastControl.x:this.last.x,e?2*this.last.y-this.lastControl.y:this.last.y,a[b],a[b+1],a[b+2],a[b+3]]);d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue));this.lastControl.x=
a[b];this.lastControl.y=a[b+1];this.lastControl.type="C"}this.last.x=a[a.length-2];this.last.y=a[a.length-1]},_smoothCurveToR:function(c,b,a,d){for(b=0;b<a.length;b+=4){var e="C"==this.lastControl.type;c.push("bezierCurveTo",[e?2*this.last.x-this.lastControl.x:this.last.x,e?2*this.last.y-this.lastControl.y:this.last.y,this.last.x+a[b],this.last.y+a[b+1],this.last.x+a[b+2],this.last.y+a[b+3]]);d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue));this.lastControl.x=this.last.x+a[b];this.lastControl.y=
this.last.y+a[b+1];this.lastControl.type="C";this.last.x+=a[b+2];this.last.y+=a[b+3]}},_qCurveToA:function(c,b,a,d){for(b=0;b<a.length;b+=4)c.push("quadraticCurveTo",a.slice(b,b+4));d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue));this.last.x=a[a.length-2];this.last.y=a[a.length-1];this.lastControl.x=a[a.length-4];this.lastControl.y=a[a.length-3];this.lastControl.type="Q"},_qCurveToR:function(c,b,a,d){for(b=0;b<a.length;b+=4)c.push("quadraticCurveTo",[this.lastControl.x=this.last.x+
a[b],this.lastControl.y=this.last.y+a[b+1],this.last.x+a[b+2],this.last.y+a[b+3]]),d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue)),this.last.x+=a[b+2],this.last.y+=a[b+3];this.lastControl.type="Q"},_qSmoothCurveToA:function(c,b,a,d){for(b=0;b<a.length;b+=2){var e="Q"==this.lastControl.type;c.push("quadraticCurveTo",[this.lastControl.x=e?2*this.last.x-this.lastControl.x:this.last.x,this.lastControl.y=e?2*this.last.y-this.lastControl.y:this.last.y,a[b],a[b+1]]);d&&(this._dashResidue=
w(d,this,c[c.length-1],this._dashResidue));this.lastControl.type="Q"}this.last.x=a[a.length-2];this.last.y=a[a.length-1]},_qSmoothCurveToR:function(c,b,a,d){for(b=0;b<a.length;b+=2){var e="Q"==this.lastControl.type;c.push("quadraticCurveTo",[this.lastControl.x=e?2*this.last.x-this.lastControl.x:this.last.x,this.lastControl.y=e?2*this.last.y-this.lastControl.y:this.last.y,this.last.x+a[b],this.last.y+a[b+1]]);d&&(this._dashResidue=w(d,this,c[c.length-1],this._dashResidue));this.lastControl.type="Q";
this.last.x+=a[b];this.last.y+=a[b+1]}},_arcTo:function(c,b,a,d){b="a"==b;for(var e=0;e<a.length;e+=7){var g=a[e+5],f=a[e+6];b&&(g+=this.last.x,f+=this.last.y);var k=R.arcAsBezier(this.last,a[e],a[e+1],a[e+2],a[e+3]?1:0,a[e+4]?1:0,g,f);O.forEach(k,function(m){c.push("bezierCurveTo",m)});d&&(this._dashResidue=w(d,this,p,this._dashResidue));this.last.x=g;this.last.y=f}this.lastControl={}},_closePath:function(c,b,a,d){c.push("closePath",[]);d&&(this._dashResidue=n(d,this,this.last.x,this.last.y,d[1][0],
d[1][1],this._dashResidue));this.lastControl={}}});O.forEach("moveTo lineTo hLineTo vLineTo curveTo smoothCurveTo qCurveTo qSmoothCurveTo arcTo closePath".split(" "),function(c){E(h.Path,c)});h.TextPath=t("dojox.gfx.canvas.TextPath",[h.Shape,I.TextPath],{_renderShape:function(c){},_setText:function(){},_setFont:function(){}});h.Surface=t("dojox.gfx.canvas.Surface",r.Surface,{constructor:function(){r.Container._init.call(this);this.pendingImageCount=0;this.makeDirty()},destroy:function(){r.Container.clear.call(this,
!0);this.inherited(arguments)},setDimensions:function(c,b){this.width=x.normalizedLength(c);this.height=x.normalizedLength(b);if(!this.rawNode)return this;var a=!1;this.rawNode.width!=this.width&&(this.rawNode.width=this.width,a=!0);this.rawNode.height!=this.height&&(this.rawNode.height=this.height,a=!0);a&&this.makeDirty();return this},getDimensions:function(){return this.rawNode?{width:this.rawNode.width,height:this.rawNode.height}:null},_render:function(c){!this.rawNode||!c&&this.pendingImageCount||
(c=this.rawNode.getContext("2d"),c.clearRect(0,0,this.rawNode.width,this.rawNode.height),this.render(c),"pendingRender"in this&&(clearTimeout(this.pendingRender),delete this.pendingRender))},render:function(c){c.save();for(var b=0;b<this.children.length;++b)this.children[b]._render(c);c.restore()},makeDirty:function(){this.pendingImagesCount||"pendingRender"in this||this._batch||(this.pendingRender=setTimeout(G.hitch(this,this._render),0))},downloadImage:function(c,b){var a=G.hitch(this,this.onImageLoad);
!this.pendingImageCount++&&"pendingRender"in this&&(clearTimeout(this.pendingRender),delete this.pendingRender);c.onload=a;c.onerror=a;c.onabort=a;c.src=b},onImageLoad:function(){--this.pendingImageCount||(this.onImagesLoaded(),this._render())},onImagesLoaded:function(){},getEventSource:function(){return null},connect:function(){},disconnect:function(){},on:function(){}});h.createSurface=function(c,b,a){if(!b&&!a){var d=V.position(c);b=b||d.w;a=a||d.h}"number"==typeof b&&(b+="px");"number"==typeof a&&
(a+="px");d=new h.Surface;c=W.byId(c);var e=c.ownerDocument.createElement("canvas");e.width=x.normalizedLength(b);e.height=x.normalizedLength(a);c.appendChild(e);d.rawNode=e;d._parent=c;return d.surface=d};var F=r.Container;t={openBatch:function(){++this._batch;return this},closeBatch:function(){this._batch=0<this._batch?--this._batch:0;this._makeDirty();return this},_makeDirty:function(){this._batch||this.surface.makeDirty()},add:function(c){this._makeDirty();return F.add.apply(this,arguments)},
remove:function(c,b){this._makeDirty();return F.remove.apply(this,arguments)},clear:function(){this._makeDirty();return F.clear.apply(this,arguments)},getBoundingBox:F.getBoundingBox,_moveChildToFront:function(c){this._makeDirty();return F._moveChildToFront.apply(this,arguments)},_moveChildToBack:function(c){this._makeDirty();return F._moveChildToBack.apply(this,arguments)}};I={createObject:function(c,b){var a=new c;a.surface=this.surface;a.setShape(b);this.add(a);return a}};A(h.Group,t);A(h.Group,
r.Creator);A(h.Group,I);A(h.Surface,t);A(h.Surface,r.Creator);A(h.Surface,I);h.fixTarget=function(c,b){return!0};return h});