// 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 dijit/_WidgetBase dijit/_TemplatedMixin dojo/Evented dojo/_base/lang dojo/_base/html dojo/_base/array dojo/on dojo/query dijit/TooltipDialog dijit/popup dijit/registry jimu/dijit/SymbolChooser jimu/symbolUtils".split(" "),function(l,m,n,p,d,e,h,f,q,r,k,t,u,v){return l([m,n,p],{baseClass:"jimu-symbol-picker",declaredClass:"jimu.dijit.SymbolPicker",templateString:'\x3cdiv\x3e\x3cdiv data-dojo-attach-point\x3d"symbolNode" class\x3d"symbol-node jimu-float-leading"\x3e\x3c/div\x3e\x3cdiv class\x3d"separator jimu-float-leading"\x3e\x3c/div\x3e\x3cdiv class\x3d"jimu-icon jimu-icon-down-arrow-8 jimu-float-leading"\x3e\x3c/div\x3e\x3c/div\x3e',
tooltipDialog:null,_isTooltipDialogOpened:!1,symbol:null,type:null,cropImage:!1,customZIndex:null,postCreate:function(){this.inherited(arguments);this._createTooltipDialog();this._hideTooltipDialog();var a=this.symbolChooser.getSymbol();a&&this._drawSymbol(a)},destroy:function(){this._hideTooltipDialog();this.symbolChooser&&this.symbolChooser.destroy();this.symbolChooser=null;this.inherited(arguments)},_createTooltipDialog:function(){var a=e.create("div");this.tooltipDialog=new r({content:a});this.symbolChooser=
new u({cropImage:this.cropImage,customZIndex:this.customZIndex,symbol:this.symbol,type:this.type});this.symbolChooser.placeAt(a);this.symbolChooser.startup();this.own(f(this.symbolChooser,"change",d.hitch(this,function(b){this._drawSymbol(b);this.emit("change",b)})));this.own(f(this.domNode,"click",d.hitch(this,function(b){b.stopPropagation();b.preventDefault();this._isTooltipDialogOpened?this._hideTooltipDialog():this._showTooltipDialog()})));this.own(f(document.body,"click",d.hitch(this,function(b){var g=
b.target||b.srcElement;b=this._getColorPickers();if(!(0<b.length&&h.some(b,function(w){return w.isPartOfPopup(g)})))if(b=this.tooltipDialog.domNode,b=g===b||e.isDescendant(g,b),this.cropImage&&this.symbolChooser._isCustomImageOptionSelected()){var c=this.symbolChooser.imageChooser,x=c.msgPopupOpen;c.cropPopupOpen||x||b||this._hideTooltipDialog();c.cropPopup&&c.cropPopup.domNode||(c.cropPopupOpen=!1);c.msgPopup&&c.msgPopup.domNode||(c.msgPopupOpen=!1)}else b||this._hideTooltipDialog()})));this.own(f(this.symbolChooser,
"resize",d.hitch(this,function(){this._isTooltipDialogOpened&&(this._hideTooltipDialog(),this._showTooltipDialog())})))},_getColorPickers:function(){var a=q(".jimu-color-picker",this.symbolChooser.domNode);return h.map(a,d.hitch(this,function(b){return t.byNode(b)}))},reset:function(){this.symbol=this.type=null;e.empty(this.symbolNode);this.symbolChooser.reset()},showBySymbol:function(a){this.reset();a&&(this._drawSymbol(a),this.symbolChooser.showBySymbol(a))},showByType:function(a){this.reset();
this.symbolChooser.showByType(a);(a=this.symbolChooser.getSymbol())&&this._drawSymbol(a)},getSymbol:function(){return this.symbolChooser.getSymbol()},_drawSymbol:function(a){e.empty(this.symbolNode);a&&(a=v.createSymbolNode(a,{width:16,height:16}))&&e.place(a,this.symbolNode)},_showTooltipDialog:function(){this.tooltipDialog&&(k.open({parent:this.getParent(),popup:this.tooltipDialog,around:this.domNode}),this._isTooltipDialogOpened=!0)},_hideTooltipDialog:function(){this.tooltipDialog&&(k.close(this.tooltipDialog),
this._isTooltipDialogOpened=!1)}})});