//>>built
define("dijit/focus","dojo/aspect,dojo/_base/declare,dojo/dom,dojo/dom-attr,dojo/dom-construct,dojo/Evented,dojo/_base/lang,dojo/on,dojo/ready,dojo/sniff,dojo/Stateful,dojo/_base/unload,dojo/_base/window,dojo/window,./a11y,./registry,./main".split(","),function(m,s,n,t,o,u,i,k,v,w,x,y,p,q,z,j,l){var r,g=new (s([x,u],{curNode:null,activeStack:[],constructor:function(){var a=i.hitch(this,function(a){n.isDescendant(this.curNode,a)&&this.set("curNode",null);n.isDescendant(this.prevNode,a)&&this.set("prevNode",
null)});m.before(o,"empty",a);m.before(o,"destroy",a)},registerIframe:function(a){return this.registerWin(a.contentWindow,a)},registerWin:function(a,e){var c=this,d=a.document&&a.document.body;if(d){var b=k(d,"mousedown",function(a){c._justMouseDowned=!0;setTimeout(function(){c._justMouseDowned=!1},13);if(!a||!(a.target&&null==a.target.parentNode))c._onTouchNode(e||a.target,"mouse")}),f=k(d,"focusin",function(a){r=(new Date).getTime();if(a.target.tagName){var b=a.target.tagName.toLowerCase();"#document"==
b||"body"==b||(z.isFocusable(a.target)?c._onFocusNode(e||a.target):c._onTouchNode(e||a.target))}}),g=k(d,"focusout",function(a){(new Date).getTime()<r+100||c._onBlurNode(e||a.target)});return{remove:function(){b.remove();f.remove();g.remove();d=b=f=g=null}}}},_onBlurNode:function(){this._clearFocusTimer&&clearTimeout(this._clearFocusTimer);this._clearFocusTimer=setTimeout(i.hitch(this,function(){this.set("prevNode",this.curNode);this.set("curNode",null)}),0);if(!this._justMouseDowned)this._clearActiveWidgetsTimer&&
clearTimeout(this._clearActiveWidgetsTimer),this._clearActiveWidgetsTimer=setTimeout(i.hitch(this,function(){delete this._clearActiveWidgetsTimer;this._setStack([])}),0)},_onTouchNode:function(a,e){this._clearActiveWidgetsTimer&&(clearTimeout(this._clearActiveWidgetsTimer),delete this._clearActiveWidgetsTimer);var c=[];try{for(;a;){var d=t.get(a,"dijitPopupParent");if(d)a=j.byId(d).domNode;else if(a.tagName&&"body"==a.tagName.toLowerCase()){if(a===p.body())break;a=q.get(a.ownerDocument).frameElement}else{var b=
a.getAttribute&&a.getAttribute("widgetId"),f=b&&j.byId(b);f&&!("mouse"==e&&f.get("disabled"))&&c.unshift(b);a=a.parentNode}}}catch(g){}this._setStack(c,e)},_onFocusNode:function(a){a&&9!=a.nodeType&&(this._clearFocusTimer&&(clearTimeout(this._clearFocusTimer),delete this._clearFocusTimer),this._onTouchNode(a),a!=this.curNode&&(this.set("prevNode",this.curNode),this.set("curNode",a)))},_setStack:function(a,e){var c=this.activeStack;this.set("activeStack",a);for(var d=0;d<Math.min(c.length,a.length)&&
!(c[d]!=a[d]);d++);for(var b,f=c.length-1;f>=d;f--)if(b=j.byId(c[f]))b._hasBeenBlurred=!0,b.set("focused",!1),b._focusManager==this&&b._onBlur(e),this.emit("widget-blur",b,e);for(f=d;f<a.length;f++)if(b=j.byId(a[f]))b.set("focused",!0),b._focusManager==this&&b._onFocus(e),this.emit("widget-focus",b,e)},focus:function(a){if(a)try{a.focus()}catch(e){}}}));v(function(){var a=g.registerWin(q.get(p.doc));w("ie")&&y.addOnWindowUnload(function(){a&&(a.remove(),a=null)})});l.focus=function(a){g.focus(a)};
for(var h in g)/^_/.test(h)||(l.focus[h]="function"==typeof g[h]?i.hitch(g,h):g[h]);g.watch(function(a,e,c){l.focus[a]=c});return g});