// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/lang dojo/on dojo/_base/html dojo/keys dojo/query esri/lang dijit/Tooltip dojo/dom-geometry jimu/utils".split(" "),function(h,q,m,t,u,y,z,A,n){var r={TabindexForSplash:1,TabindexForSkipLinks:101,TabindexRangeForController:1E4,TabindexRangeForWidget:200,_setTabindex:function(b,d){function p(a,g){a&&("undefined"!==typeof a.bottom&&(a.top=g.h-a.bottom-100,delete a.bottom),"undefined"!==typeof a.right&&(a.left=g.w-a.right-100,delete a.right))}function v(a,g,w){g=h.clone(g.position||
g.panel&&g.panel.position);w=h.clone(w.position||w.panel&&w.panel.position);p(g,a);p(w,a);return g.top===w.top?g.left-w.left:g.top-w.top}var f=[],k=[],x=!1,c=null;d?b.visitElement(function(a,g){g.isOnScreen&&(g=a.position||a.panel&&a.panel.position)&&!Array.isArray(a.widgets)&&"widgetOnScreen"===a.gid&&a.visible&&("browser"===g.relativeTo?(f.push(a),"Splash"===a.name&&(x=!0)):k.push(a))}):b.visitElement(function(a,g){g.isOnScreen&&(g=a.position||a.panel&&a.panel.position)&&("widgetOnScreen"===a.gid&&
a.visible||!a.visible&&a.panel)&&("browser"===g.relativeTo?("AttributeTable"===a.name?c=a:f.push(a),"Splash"===a.name&&(x=!0)):k.push(a))});b=A.getMarginBox(this.layoutId);var l=A.getMarginBox(this.mapId);f=f.sort(h.hitch(this,v,b));k=k.sort(h.hitch(this,v,l));d?f.unshift(this.map):f.push(this.map);c&&k.push(c);var e=r.TabindexForSplash;x?f.every(function(a){return"Splash"===a.name?(a.tabIndex=e,!1):!0}):(b=u("#skipContainer")[0],m.setAttr(b,"tabindex",e+""),this.own(q(b,"focus",h.hitch(this,function(){n.focusOnFirstSkipLink()}))));
this._initSkipLinks(d,f,c);e+=r.TabindexRangeForWidget;d?(f.forEach(function(a){"Splash"!==a.name&&(a.tabIndex=e,e=a.isController?e+r.TabindexRangeForController:e+r.TabindexRangeForWidget)}),e=this._initGridLayoutPanels(e),this._initGridMapEvents(e)):(f.forEach(function(a){"Splash"!==a.name&&(a.inPanel?a.tabIndexJimu=e:"map"===a.id?a.container.tabIndex=e:a.tabIndex=e,e=a.isController?e+r.TabindexRangeForController:e+r.TabindexRangeForWidget)}),this._initAbsoluteMapEvents());b=u(".trapLinkNode");d=
b[0];this.lastTrapNode=b[1];b=y.substitute({value:window.jimuNls.skips.skips},window.jimuNls.skips.tabAway);m.setAttr(this.lastTrapNode,"aria-label",b);n.addTooltipByDomNode(z,this.lastTrapNode,b);this.own(q(d,"focus",h.hitch(this,function(a){n.tryToFocusSplashWidget(a)||this.lastTrapNode.focus()})));this.own(q(this.lastTrapNode,"keydown",h.hitch(this,function(a){a.shiftKey&&a.keyCode===t.TAB&&(a.preventDefault(),n.focusOnFirstSkipLink())})));e+=1E3;k.forEach(function(a){a.inPanel?a.tabIndexJimu=
e:a.tabIndex=e;e=a.isController?e+r.TabindexRangeForController:e+r.TabindexRangeForWidget})},_initGridLayoutPanels:function(b){var d=u(".lm_item.lm_stack",this.layoutContainer);window._panelHandler=d.on("focus",h.hitch(this,function(f){window._panelHandler&&window._panelHandler.remove();n.tryToFocusSplashWidget(f)||n.focusOnFirstSkipLink()}));for(var p=0;p<=d.length-1;p++){var v=d[p];v.tabIndex=b-1;this.own(q(v,"keydown",h.hitch(this,function(f,k){m.hasClass(k.target,"lm_stack")?k.keyCode===t.ENTER?
(f=u(".jimu-widget",f)[0])&&(m.hasClass(f.parentNode,"map")?this.map.container.focus():n.focusFirstFocusNode(f)):k.keyCode!==t.TAB||k.shiftKey||f.nextSibling||f.parentNode.nextSibling||(k.preventDefault(),this.lastTrapNode.focus()):k.keyCode===t.ESCAPE&&f.focus()},v)))}return b},_initMapAttrs:function(b){b&&m.setAttr(this.map.container,"tabindex",b);m.setAttr(this.map.container,"aria-label",window.jimuNls.common.mapArea);n.addTooltipByDomNode(z,this.map.container,window.jimuNls.common.mapArea)},_initGridMapEvents:function(b){this._initMapAttrs(b);
this.own(q(this.map.container,"keydown",h.hitch(this,function(d){"map"===m.getAttr(d.target,"id")&&d.shiftKey&&d.keyCode===t.TAB&&d.preventDefault()})));this.own(q(this.map.container,"focus",h.hitch(this,function(d){n.isInNavMode()&&"map"===m.getAttr(d.target,"id")&&(d=document.getElementById("map_container"),d.addEventListener("mouseover",function(){}),d.simulateEvent=new MouseEvent("mouseover",{view:window,bubbles:!0,cancelable:!0}),this.map.isKeyboardNavigationOrigin=this.map.isKeyboardNavigation,
d.dispatchEvent(d.simulateEvent)&&this.map.enableKeyboardNavigation())})));this.own(q(this.map.container,"blur",h.hitch(this,function(d){n.isInNavMode()&&"map"===m.getAttr(d.target,"id")&&(document.getElementById("map_container").removeEventListener("mouseover",function(){}),this.map.isKeyboardNavigationOrigin||this.map.disableKeyboardNavigation())})))},_initAbsoluteMapEvents:function(){this._initMapAttrs();this.own(q(this.map.container,"keydown",h.hitch(this,function(b){"map"===m.getAttr(b.target,
"id")&&b.keyCode===t.ESCAPE&&n.trapToNextFocusContainer(this.map.container)})));window.isMoveFocusWhenInit=!0;this.own(q(this.map.container,"focus",h.hitch(this,function(b){n.isInNavMode()&&"map"===m.getAttr(b.target,"id")&&!this.widgetManager._resetFirstFocusNode()&&(b=document.getElementById("map_container"),b.addEventListener("mouseover",function(){}),b.simulateEvent=new MouseEvent("mouseover",{view:window,bubbles:!0,cancelable:!0}),this.map.isKeyboardNavigationOrigin=this.map.isKeyboardNavigation,
b.dispatchEvent(b.simulateEvent)&&this.map.enableKeyboardNavigation())})));this.own(q(this.map.container,"blur",h.hitch(this,function(b){n.isInNavMode()&&"map"===m.getAttr(b.target,"id")&&!this.widgetManager._resetFirstFocusNode()&&(document.getElementById("map_container").removeEventListener("mouseover",function(){}),this.map.isKeyboardNavigationOrigin||this.map.disableKeyboardNavigation())})))},_initSkipLinks:function(b,d,p){var v=r.TabindexForSkipLinks,f=window.jimuNls.skips,k="",x=u("#skipContainer")[0];
m.setAttr(x,"aria-label",f.skips);d.forEach(function(c){if("Splash"!==c.name){if("map"===c.id)var l=f.map;else if(c.panel&&c.widgets){if(0===c.widgets.length)return;l=c.isOnScreen?f.sidePanel:c.label}else{if(c.inPanel)return;l=y.substitute({value:c.label},f.skipTo)}k+='\x3cli\x3e\x3ca role\x3d"link" id\x3d"skip_'+c.id+'" aria-hidden\x3d"true" tabindex\x3d"'+v+'"\x3e'+l+"\x3c/a\x3e\x3c/li\x3e"}});p&&(d=y.substitute({value:p.label},f.skipTo),k+='\x3cli\x3e\x3ca role\x3d"link" id\x3d"skip_'+p.id+'" aria-hidden\x3d"true" tabindex\x3d"'+
v+'"\x3e'+d+"\x3c/a\x3e\x3c/li\x3e");x.innerHTML="\x3cul\x3e"+k+"\x3c/ul\x3e";p=u("a",x);this.own(q(p,"focus",h.hitch(this,function(c){window._panelHandler&&window._panelHandler.remove();this.widgetManager._resetFirstFocusNode()||m.setAttr(c.target,"aria-hidden","false")})));this.own(q(p,"blur",h.hitch(this,function(c){m.setAttr(c.target,"aria-hidden","true")})));this.own(q(p,"keydown",h.hitch(this,function(c){if(c.keyCode===t.ENTER){c=c.target.id.split("skip_")[1];var l=u("#"+c)[0];l||(l=u("#"+c+
"_panel")[0]);l.focus()}else{var e;b&&(e=u(".lm_item.lm_stack",this.layoutContainer));!c.target.parentNode.previousSibling&&c.shiftKey&&c.keyCode===t.TAB?(c.preventDefault(),b?l=e[e.length-1]:(c=n.getFrameNodesByAsc(),l=c[c.length-1])):c.keyCode===t.ESCAPE&&(l=n.trapToNextFocusContainer(x),b&&!l&&(l=e[0]));l&&l.focus()}})))}};return r});