//>>built define("dojo/_base/lang dojo/_base/declare dojo/has dojo/on dojo/aspect dojo/touch dojo/_base/Color dojo/dom dojo/dom-geometry dojo/_base/window ./_base ./canvas ./shape ./matrix".split(" "),function(n,g,l,p,x,z,y,u,v,A,q,k,B,r){function w(a){var c={},b;for(b in a)c[b]="function"===typeof a[b]?n.hitch(a,b):a[b];return c}l.add("dom-mutableEvents",function(){var a=document.createEvent("UIEvents");try{return Object.defineProperty?Object.defineProperty(a,"type",{value:"foo"}):a.type="foo","foo"===a.type}catch(c){return!1}}); var d=q.canvasWithEvents={};d.Shape=g("dojox.gfx.canvasWithEvents.Shape",k.Shape,{_testInputs:function(a,c){if(this.clip||!this.canvasFill&&this.strokeStyle)this._hitTestPixel(a,c);else{this._renderShape(a);for(var b=c.length,h=this.getTransform(),e=0;e=a.x&&c<=a.x+a.width&&b>=a.y&&b<=a.y+a.height?this:null}});d.Text=g("dojox.gfx.canvasWithEvents.Text",[d.Shape,k.Text],{_testInputs:function(a,c){return this._hitTestPixel(a,c)}});d.Rect=g("dojox.gfx.canvasWithEvents.Rect",[d.Shape,k.Rect], {});d.Circle=g("dojox.gfx.canvasWithEvents.Circle",[d.Shape,k.Circle],{});d.Ellipse=g("dojox.gfx.canvasWithEvents.Ellipse",[d.Shape,k.Ellipse],{});d.Line=g("dojox.gfx.canvasWithEvents.Line",[d.Shape,k.Line],{});d.Polyline=g("dojox.gfx.canvasWithEvents.Polyline",[d.Shape,k.Polyline],{});d.Path=g("dojox.gfx.canvasWithEvents.Path",[d.Shape,k.Path],{});d.TextPath=g("dojox.gfx.canvasWithEvents.TextPath",[d.Shape,k.TextPath],{});var m=null;d.Surface=g("dojox.gfx.canvasWithEvents.Surface",k.Surface,{constructor:function(){this._elementUnderPointer= null},fixTarget:function(a){var c=this;return function(b){var d;if(m)if(l("dom-mutableEvents"))Object.defineProperties(b,m);else for(d in b=w(b),m)b[d]=m[d].value;else{var e=c.getEventSource()._dojoElementFromPoint((b.changedTouches?b.changedTouches[0]:b).pageX,(b.changedTouches?b.changedTouches[0]:b).pageY);l("dom-mutableEvents")?Object.defineProperties(b,{target:{value:e,configurable:!0,enumerable:!0},gfxTarget:{value:e.shape,configurable:!0,enumerable:!0}}):(b=w(b),b.target=e,b.gfxTarget=e.shape)}if(l("touch")){if(b.changedTouches&& b.changedTouches[0])for(d in e=b.changedTouches[0],e)b[d]||(l("dom-mutableEvents")?Object.defineProperty(b,d,{value:e[d],configurable:!0,enumerable:!0}):b[d]=e[d]);b.corrected=b}return a.call(this,b)}},_checkPointer:function(a){function c(c,b,e){for(var d=a.bubbles,f=0,h;h=c[f];++f)m={target:{value:b,configurable:!0,enumerable:!0},gfxTarget:{value:b.shape,configurable:!0,enumerable:!0},relatedTarget:{value:e,configurable:!0,enumerable:!0}},Object.defineProperty(a,"bubbles",{value:h.bubbles,configurable:!0, enumerable:!0}),p.emit(g,h.type,a),m=null;Object.defineProperty(a,"bubbles",{value:d,configurable:!0,enumerable:!0})}var b=[{type:"mouseout",bubbles:!0},{type:"MSPointerOut",bubbles:!0},{type:"pointerout",bubbles:!0},{type:"mouseleave",bubbles:!1},{type:"dojotouchout",bubbles:!0}],d=[{type:"mouseover",bubbles:!0},{type:"MSPointerOver",bubbles:!0},{type:"pointerover",bubbles:!0},{type:"mouseenter",bubbles:!1},{type:"dojotouchover",bubbles:!0}],e=a.target,f=this._elementUnderPointer,g=this.getEventSource(); f!==e&&(f&&f!==g&&c(b,f,e),(this._elementUnderPointer=e)&&e!==g&&c(d,e,f))},getEventSource:function(){return this.rawNode},on:function(a,c){return p(this.getEventSource(),a,c)},connect:function(a,c,b){"on"==a.substring(0,2)&&(a=a.substring(2));return this.on(a,b?n.hitch(c,b):c)},disconnect:function(a){a.remove()},_initMirrorCanvas:function(){this._initMirrorCanvas=function(){};var a=this.getEventSource(),c=this.mirrorCanvas=a.ownerDocument.createElement("canvas");c.width=1;c.height=1;c.style.position= "absolute";c.style.left=c.style.top="-99999px";a.parentNode.appendChild(c);c="mousemove";l("pointer-events")?c="pointermove":l("touch-events")&&(c="touchmove");p(a,c,n.hitch(this,"_checkPointer"))},destroy:function(){this.mirrorCanvas&&(this.mirrorCanvas.parentNode.removeChild(this.mirrorCanvas),this.mirrorCanvas=null);this.inherited(arguments)}});d.createSurface=function(a,c,b){if(!c&&!b){var h=v.position(a);c=c||h.w;b=b||h.h}"number"===typeof c&&(c+="px");"number"===typeof b&&(b+="px");var e=new d.Surface, h=u.byId(a);a=h.ownerDocument.createElement("canvas");a.width=q.normalizedLength(c);a.height=q.normalizedLength(b);h.appendChild(a);e.rawNode=a;e._parent=h;e.surface=e;q._base._fixMsTouchAction(e);var f=a.addEventListener,g=a.removeEventListener,k=[];c=function(a,c,b){e._initMirrorCanvas();var d=e.fixTarget(c);k.push({original:c,actual:d});f.call(this,a,d,b)};b=function(a,c,b){for(var e=0,d;d=k[e];++e)if(d.original===c){g.call(this,a,d.actual,b);k.splice(e,1);break}};try{Object.defineProperties(a, {addEventListener:{value:c,enumerable:!0,configurable:!0},removeEventListener:{value:b}})}catch(t){a.addEventListener=c,a.removeEventListener=b}a._dojoElementFromPoint=function(a,c){if(!e.mirrorCanvas)return this;var b=v.position(this,!0);a-=b.x;c-=b.y;var d=e.mirrorCanvas,b=d.getContext("2d"),f=e.children;b.clearRect(0,0,d.width,d.height);b.save();b.strokeStyle="rgba(127,127,127,1.0)";b.fillStyle="rgba(127,127,127,1.0)";b.pickingMode=!0;a=[{x:a,y:c}];for(c=f.length-1;0<=c&&(f[c]._testInputs(b,a), !a[0].target);c--);b.restore();return a[0]&&a[0].target?a[0].target.rawNode:this};return e};g={createObject:function(){var a=this.inherited(arguments),c={};a.rawNode={shape:a,ownerDocument:a.surface.rawNode.ownerDocument,parentNode:a.parent?a.parent.rawNode:null,addEventListener:function(b,d){for(var e=c[b]=c[b]||[],f=0,g;g=e[f];++f)if(g.listener===d)return;e.push({listener:d,handle:x.after(this,"on"+b,a.surface.fixTarget(d),!0)})},removeEventListener:function(a,d){if(a=c[a])for(var b=0,f;f=a[b];++b)if(f.listener=== d){f.handle.remove();a.splice(b,1);break}}};return a}};d.Group.extend(g);d.Surface.extend(g);return d});