// 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/declare jimu/BaseWidget dojo/_base/lang dojo/on dojo/dom-construct dojo/_base/array jimu/symbolUtils esri/symbols/jsonUtils dijit/popup dijit/TooltipDialog dojo/_base/html dojo/keys dojo/query dijit/focus".split(" "),function(m,n,e,f,c,p,q,r,k,t,u,g,v,l){return m([n],{_tooltipDialog:null,selectedSymbol:null,symbolData:[],constructor:function(a){e.mixin(this,a)},postCreate:function(){this.symbolData||(this.symbolData=[]);this._createSelectedSymbolNode();this._hideTooltipDialog();
this.symbolData&&0<this.symbolData.length&&(this._createTooltipDialog(),this.symbolData[1].isDefault?this.selectSymbol(this.symbolData[1]):this.selectSymbol(this.symbolData[0]));this.own(f(document.body,"click",e.hitch(this,function(a){this.isPartOfPopup(a.target||a.srcElement)||this._hideTooltipDialog()})))},setDefault:function(){this.symbolData&&1<this.symbolData.length&&this.symbolData[1].isDefault?this.selectSymbol(this.symbolData[1]):this.selectSymbol(this.symbolData[0])},_createSelectedSymbolNode:function(){var a=
c.create("div",{},this.domNode);this.selectedSymbolNode=c.create("div",{"class":"esriCTSelectedSymbol"},a)},_createTooltipDialog:function(){var a=this._createSymbolListMenu();this._tooltipDialog=new t({content:a,"class":"esriCTSymbolPopup"});this.own(f(this.domNode,"click",e.hitch(this,function(b){b.stopPropagation();b.preventDefault();this._isTooltipDialogOpened?this._hideTooltipDialog():this._showTooltipDialog()})));this.own(f(this.domNode,"keydown",e.hitch(this,function(b){if(b.keyCode===g.ENTER||
b.keyCode===g.SPACE)this._isTooltipDialogOpened?this._hideTooltipDialog():this._showTooltipDialog()})));this.own(f(document.body,"click",e.hitch(this,function(b){this.isPartOfPopup(b.target||b.srcElement)||this._hideTooltipDialog()})))},_createSymbolListMenu:function(){var a=c.create("div",{"class":"esriCTSymbolListContainer"},null);var b=c.create("div",{"class":"esriCTSymbolListContent",role:"menu"},a);p.forEach(this.symbolData,e.hitch(this,function(d){var h=c.create("div",{"class":"esriCTSymbolOption",
title:d.label,tabindex:"0",role:"menuitem","aria-label":d.label},b);this._attachRowClick(h,d);var w=c.create("div",{"class":"esriCTSymbolIcon"},h);c.create("div",{"class":"esriCTSymbolName",innerHTML:d.label},h);h=c.create("div",{},w);this._createSymbol(d,h)}));return a},_attachRowClick:function(a,b){this.own(f(a,"click",e.hitch(this,function(){this.selectSymbol(b);this.hideOnSelect&&this._hideTooltipDialog()})));this.own(f(a,"keydown",e.hitch(this,function(d){if(d.keyCode===g.ENTER||d.keyCode===
g.SPACE||d.keyCode===g.ESCAPE)this.selectSymbol(b),this.hideOnSelect&&(this._hideTooltipDialog(),l.focus(this.domNode))})))},_createSymbol:function(a,b){a&&(a=r.fromJson(a.symbol),(a=q.createSymbolNode(a))||(a=c.create("div")),c.place(a,b))},selectSymbol:function(a){c.empty(this.selectedSymbolNode);this.selectedSymbol={label:a.label||a.type,type:a.type,symbol:a.symbol};this._createSymbol(this.selectedSymbol,this.selectedSymbolNode);this.onSelect(a)},destroy:function(){k.close(this._tooltipDialog);
this._tooltipDialog.destroy();this.inherited(arguments)},isPartOfPopup:function(a){var b=this._tooltipDialog.domNode;return a===b||u.isDescendant(a,b)},onSelect:function(a){return a},_showTooltipDialog:function(){k.open({parent:this.getParent(),popup:this._tooltipDialog,around:this.domNode,"class":"esriCTSymbolPopup"});this._isTooltipDialogOpened=!0;this.focusFirstSymbolOption()},_hideTooltipDialog:function(){k.close(this._tooltipDialog);this._isTooltipDialogOpened=!1},focusFirstSymbolOption:function(){var a=
v(".esriCTSymbolOption",this._tooltipDialog.domNode);l.focus(a[0])}})});