/**
 * Copyright 2018 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as s,html as t,css as e}from"../../../lit/index.js";import{SimpleColorsSuper as i}from"../simple-colors.js";import{SimplePickerBehaviors as r}from"../../simple-picker/simple-picker.js";class SimpleColorsPicker extends(r(i(s))){static get styles(){return[super.styles,e`
        :host {
          display: inline-block;
        }
        :host([hidden]) {
          display: none;
        }
        .row {
          width: 100%;
        }
      `]}constructor(){super(),this.allowNull=!0,this.shades=!1,this.options=this._getOptions(this.colors,this.shades,this.dark)}updated(s){super.updated&&super.updated(s),s.forEach(((s,t)=>{"colors"===t&&(this.options=this._getOptions(this.colors,this.shades,this.dark)),"shades"===t&&(this.options=this._getOptions(this.colors,this.shades,this.dark),this.hideOptionLabels=this.shades),"dark"===t&&(this.options=this._getOptions(this.colors,this.shades,this.dark))})),void 0!==this.__ready&&this._fireChangeEvent()}static get properties(){return{...super.properties,shades:{type:Boolean,reflect:!0}}}static get tag(){return"simple-colors-picker"}firstUpdated(s){super.firstUpdated&&super.firstUpdated(s),this.__ready=!0}_getOptions(s,t,e){let i=[],r=!1!==e?"dark":"default";if(!1===t)i=Object.keys(this.colors).map((s=>[{alt:s,value:s}])),i.unshift([{alt:"none",value:null}]);else{let t=Object.keys(s);for(let e=0;e<s[t[0]].length;e++){let t=Object.keys(s).map((s=>{let t=s+"-"+(e+1),i="--simple-colors-"+r+"-theme-"+t;return{alt:t,style:"background-color: var("+i+")",value:i}}));i.push(t)}}return i}_fireChangeEvent(){this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this}))}}export{SimpleColorsPicker};customElements.define(SimpleColorsPicker.tag,SimpleColorsPicker);