// 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/_base/lang dojo/_base/html dojo/on dojo/_base/Color dijit/TooltipDialog dijit/popup jimu/dijit/ColorPalette jimu/utils".split(" "),function(k,l,m,e,d,f,h,n,g,p,q){return k([l,m],{baseClass:"jimu-color-pickerPopup",declaredClass:"jimu.dijit.ColorPickerPopup",templateString:'\x3cdiv class\x3d"jimu-color-picker"\x3e\x3c/div\x3e',_isTooltipDialogOpened:!1,color:null,showLabel:!1,around:null,_ENABLE:!0,recordUID:"",postCreate:function(){this.inherited(arguments);
this._createTooltipDialog(this.domNode);this._hideTooltipDialog()},destroy:function(){g.close(this.tooltipDialog);this.picker.destroy();this.tooltipDialog.destroy();this.inherited(arguments)},enable:function(){this._ENABLE=!0;d.removeClass(this.domNode,"disable")},disable:function(){this._ENABLE=!1;d.addClass(this.domNode,"disable")},isPartOfPopup:function(a){var b=this.tooltipDialog.domNode;return a===b||d.isDescendant(a,b)},hideTooltipDialog:function(){this._hideTooltipDialog()},showTooltipDialog:function(){this._showTooltipDialog()},
initUI:function(){this.picker.initUI()},isOpen:function(){return this._isTooltipDialogOpened},_showTooltipDialog:function(){g.open({parent:this.getParent(),popup:this.tooltipDialog,around:this.around?this.around:this.domNode,orient:this.orient});this._isTooltipDialogOpened=!0},_hideTooltipDialog:function(){g.hide(this.tooltipDialog);this._isTooltipDialogOpened=!1},_createTooltipDialog:function(){var a=d.create("div");this.tooltipDialog=new n({content:a});d.addClass(this.tooltipDialog.domNode,"jimu-color-picker-popup-dialog");
var b=new p({appearance:{showTransparent:!1,showColorPalette:!0,showCoustom:!0,showColorPickerOK:!0,showColorPickerApply:!0,showCoustomRecord:!0,closeDialogWhenChange:!0},recordUID:this.recordUID,onChange:e.hitch(this,function(c){c&&(c=new h(c),this.setColor(c),this.onChange(c))})});b.placeAt(a);b.startup();this.own(f(b,"close",e.hitch(this,function(){this._hideTooltipDialog()})));this.own(f(b,"change-style",e.hitch(this,function(){this._hideTooltipDialog();this._showTooltipDialog()})));this.own(f(this.domNode,
"click",e.hitch(this,function(c){c.stopPropagation();c.preventDefault();this._isTooltipDialogOpened?this._hideTooltipDialog():!1!==this._ENABLE&&this._showTooltipDialog()})));this.own(f(document,"click",e.hitch(this,function(c){this.isPartOfPopup(c.srcElement||c.target)||this._hideTooltipDialog()})));this.picker=b},setColor:function(a){if(a instanceof h){null===this.color&&!0===this.showLabel&&this._changeLabel(a);var b=a.toHex();this.color=a;d.setStyle(this.domNode,"backgroundColor",b);this.picker&&
(this.picker.refreshRecords(),this.picker.setColor(b,!1,!0));this.showLabel&&this._changeLabel(this.color)}},getColor:function(){return this.color},_changeLabel:function(a){d.empty(this.domNode);d.create("span",{innerHTML:a.toHex(),className:"color-label",style:{color:q.invertColor(a.toHex())}},this.domNode)},onChange:function(a){a&&this.showLabel&&this._changeLabel(a)},changeColor:function(){this.picker&&this.picker.changeColor();this.showLabel&&this._changeLabel(this.color)},setTitle:function(a){this.domNode.title=
a},getTooltipDialog:function(){return this.tooltipDialog||null}})});