`}get hasSlider(){switch(this.attribute){case"position":if("current_position"in this.stateObj.attributes)return!0;if("supported_features"in this.stateObj.attributes&&4&this.stateObj.attributes.supported_features)return!0;case"tilt":if("current_tilt_position"in this.stateObj.attributes)return!0;if("supported_features"in this.stateObj.attributes&&128&this.stateObj.attributes.supported_features)return!0;default:return!1}}get _step(){return 10}}gt.allowed_attributes=["position","tilt"];const bt={light:pt,media_player:class extends ut{get _value(){return this.stateObj.attributes.is_volume_muted?0:Math.round(100*this.stateObj.attributes.volume_level)}set _value(t){t/=100,this._hass.callService("media_player","volume_set",{entity_id:this.stateObj.entity_id,volume_level:t}),t&&this.stateObj.attributes.is_volume_muted&&this._hass.callService("media_player","volume_mute",{entity_id:this.stateObj.entity_id,is_volume_muted:!1})}get isOff(){return"off"===this.stateObj.state}get string(){return this.stateObj.attributes.is_volume_muted?"-":this.stateObj.attributes.volume_level?`${this.value} %`:this._hass.localize("component.media_player.entity_component._.state.off")}get hasToggle(){return!0}_handleMute(){this._hass.callService("media_player","volume_mute",{entity_id:this.stateObj.entity_id,is_volume_muted:!this.stateObj.attributes.is_volume_muted})}renderToggle(t){const e=t.states[this.stateObj.entity_id],s=document.createElement("ha-icon");s.style.display="flex",s.icon=e.attributes.is_volume_muted?"mdi:volume-off":"mdi:volume-high";const i=document.createElement("ha-icon-button");return i.appendChild(s),i.addEventListener("click",(()=>this._handleMute())),this.hasToggle?i:void 0}},climate:class extends ut{get _value(){return this.stateObj.attributes.temperature}set _value(t){this._hass.callService("climate","set_temperature",{entity_id:this.stateObj.entity_id,temperature:t})}get string(){return`${this.value} ${this._hass.config.unit_system.temperature}`}get isOff(){return"off"===this.stateObj.state}get _min(){return this.stateObj.attributes.min_temp}get _max(){return this.stateObj.attributes.max_temp}get _step(){return 1}},water_heater:class extends ut{get _value(){return this.stateObj.attributes.temperature}set _value(t){this._hass.callService("water_heater","set_temperature",{entity_id:this.stateObj.entity_id,temperature:t})}get string(){return`${this.value} ${this._hass.config.unit_system.temperature}`}get isOff(){return"off"===this.stateObj.state}get _min(){return this.stateObj.attributes.min_temp}get _max(){return this.stateObj.attributes.max_temp}get _step(){return 1}},cover:gt,fan:class extends ut{get _value(){return"off"!==this.stateObj.state?this.stateObj.attributes.percentage:0}set _value(t){t>0?this._hass.callService("fan","set_percentage",{entity_id:this.stateObj.entity_id,percentage:t}):this._hass.callService("fan","turn_off",{entity_id:this.stateObj.entity_id})}get string(){return"off"===this.stateObj.state?this._hass.localize("component.light.entity_component._.state.off"):`${this.stateObj.attributes.percentage} %`}get hasSlider(){return"percentage"in this.stateObj.attributes}get _step(){return this.stateObj.attributes.percentage_step}},input_number:class extends ut{get _value(){return this.stateObj.state}set _value(t){this._hass.callService("input_number","set_value",{entity_id:this.stateObj.entity_id,value:t})}get string(){return`${parseFloat(this.stateObj.state)} ${this.stateObj.attributes.unit_of_measurement||""}`.trim()}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return"slider"===this.stateObj.attributes.mode}get _min(){return this.stateObj.attributes.min}get _max(){return this.stateObj.attributes.max}get _step(){return this.stateObj.attributes.step}},input_select:class extends ut{get _value(){return this.stateObj.attributes.options.indexOf(this.stateObj.state)}set _value(t){t in this.stateObj.attributes.options&&this._hass.callService("input_select","select_option",{entity_id:this.stateObj.entity_id,option:this.stateObj.attributes.options[t]})}get string(){return this.stateObj.state}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return this.stateObj.attributes.options&&this.stateObj.attributes.options.length>0}get _max(){return this.stateObj.attributes.options.length-1}get _step(){return 1}},number:class extends ut{get _value(){return this.stateObj.state}set _value(t){this._hass.callService("number","set_value",{entity_id:this.stateObj.entity_id,value:t})}get string(){return`${parseFloat(this.stateObj.state)} ${this.stateObj.attributes.unit_of_measurement||""}`.trim()}get isOff(){return!1}get hasToggle(){return!1}get hasSlider(){return!0}get _min(){return this.stateObj.attributes.min}get _max(){return this.stateObj.attributes.max}get _step(){return this.stateObj.attributes.step}},humidifier:class extends ut{get _value(){return this.stateObj.attributes.humidity}set _value(t){this._hass.callService("humidifier","set_humidity",{entity_id:this.stateObj.entity_id,humidity:t})}get string(){return`${this.value} %`}get isOff(){return"off"===this.stateObj.state}get _min(){return this.stateObj.attributes.min_humidity}get _max(){return this.stateObj.attributes.max_humidity}get _step(){return 1}},timer:class extends ut{constructor(t,e){super(t,e),this._calcvalue=0,this._calcvalue=0,this._interval=window.setInterval((()=>{this._calcvalue=this.calculate_value(),e.requestUpdate()}),1e3)}get _value(){return this._calcvalue}calculate_value(){let t=this.stateObj.attributes.remaining;if(!t)return 0;const e=t.split(":").map(Number);if(t=3600*e[0]+60*e[1]+e[2],"active"===this.stateObj.state){const e=(new Date).getTime(),s=new Date(this.stateObj.last_changed).getTime();t=Math.max(t-(e-s)/1e3,0)}return t}set _value(t){t?this._hass.callService("timer","start",{entity_id:this.stateObj.entity_id,duration:t}):this._hass.callService("timer","finish",{entity_id:this.stateObj.entity_id})}get string(){if("active"===this.stateObj.state){const t=t=>t<10?`0${t}`:`${t}`,e=Math.floor(this.value/3600),s=Math.floor(this.value%3600/60),i=Math.floor(this.value%60);return e>0?`${e}:${t(s)}:${t(i)}`:s>0?`${s}:${t(i)}`:`${i}`}return this._hass.localize("component.timer.entity_component._.state.idle")}get isOff(){return"active"!==this.stateObj.state}get _min(){return 0}get _max(){return 300}get _step(){return 1}}};var ft="17.4.0";class mt extends nt{setConfig(t){this._config=t}_schema(t){var e,s,i;const r=Object.keys(bt);console.log(t,bt[t],null===(e=bt[t])||void 0===e?void 0:e.allowed_attributes);const n=null!==(i=null===(s=bt[t])||void 0===s?void 0:s.allowed_attributes)&&void 0!==i?i:[];return[{name:"entity",required:!0,selector:{entity:{filter:[{domain:r}]}}},{type:"grid",name:"",schema:[{name:"name",selector:{text:{}}},{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}}]},{type:"grid",name:"",schema:[{name:"min",selector:{number:{min:-1e32,max:1e32,mode:"box"}}},{name:"max",selector:{number:{min:-1e32,max:1e32,mode:"box"}}},{name:"step",selector:{number:{min:-1e32,max:1e32,mode:"box"}}}]},{type:"grid",name:"",schema:[{name:"toggle",selector:{boolean:{}}},{name:"hide_state",selector:{boolean:{}}},{name:"hide_when_off",selector:{boolean:{}}},{name:"full_row",selector:{boolean:{}}},{name:"show_icon",selector:{boolean:{}}}]},n.length?{type:"grid",name:"",schema:[{name:"attribute",selector:{select:{options:n}}},{name:"colorize",selector:{boolean:{}}}]}:{}]}render(){var t,e;if(!this.hass||!this._config)return"";const s=this._schema(null===(e=null===(t=this._config.entity)||void 0===t?void 0:t.split("."))||void 0===e?void 0:e[0]);return B`
`}_valueChanged(t){this.dispatchEvent(new CustomEvent("config-changed",{detail:{config:t.detail.value}}))}}t([lt()],mt.prototype,"hass",void 0),t([function(t){return lt({...t,state:!0,attribute:!1})}()],mt.prototype,"_config",void 0),customElements.define("slider-entity-row-editor",mt);class vt extends nt{setConfig(t){if(this._config=t,!t.entity)throw new Error("No entity specified.");const e=t.entity.split(".")[0],s=function(t){return bt[t]}(e);if(!s)throw new Error(`Unsupported entity type: ${e}`);this.ctrl=new s(t,this)}static getConfigElement(){return console.log("GetConfigElement"),document.createElement("slider-entity-row-editor")}async resized(){var t,e;await this.updateComplete,this.shadowRoot&&this.parentElement&&(this.hide_state=this._config.full_row?(null===(t=this.parentElement)||void 0===t?void 0:t.clientWidth)<=180:(null===(e=this.parentElement)||void 0===e?void 0:e.clientWidth)<=335)}async firstUpdated(){await this.resized()}async updated(){var t;if(!this._slider)return;if(await this._slider.updateComplete,this._slider.shadowRoot.querySelector("style.slider-entity-row"))return;const e=document.createElement("style");e.classList.add("slider-entity-row"),e.innerHTML=".container .track::before{background: var(--_inactive-track-color);}\n .container .track::after{background: var(--_active-track-color);}",null===(t=this._slider.shadowRoot)||void 0===t||t.appendChild(e)}async connectedCallback(){super.connectedCallback(),await this.resized()}render(){var t;const e=this.ctrl;if(e.hass=this.hass,!e.stateObj)return B`
${this.hass.localize("ui.panel.lovelace.warning.entity_not_found","entity",this._config.entity)}
`;const s=(null!==(t=e.dir)&&void 0!==t?t:this.hass.translationMetadata.translations[this.hass.language||"en"].isRTL)?"rtl":"ltr",i="unavailable"!==e.stateObj.state&&e.hasSlider&&!(e.isOff&&this._config.hide_when_off),r=this._config.toggle&&e.hasToggle,n=!r&&(!1===this._config.hide_state||!this._config.hide_state&&!this.hide_state&&(!e.isOff||!this._config.hide_when_off)),a=B`
t.stopPropagation()}>
${i?B`
${this._config.colorize&&e.background?B`
`:""}
e.value=this.shadowRoot.querySelector("ha-slider").value}
class=${this._config.full_row||this._config.grow?"full":""}
ignore-bar-touch
>
`:""}
${r?e.renderToggle(this.hass):""}
${n?B`
${"unavailable"===e.stateObj.state?this.hass.localize("state.default.unavailable"):e.string}
`:""}
`;if(this._config.full_row){if(this._config.hide_when_off&&e.isOff)return B``;if(!0===this._config.show_icon){const t=this._config;return B`
${a}
`}return a}return B`
${a}
`}static get styles(){return a`
.wrapper {
display: flex;
align-items: center;
justify-content: flex-end;
flex: 7;
height: 40px;
}
.state {
min-width: 45px;
text-align: end;
}
ha-entity-toggle {
min-width: auto;
margin-left: 8px;
}
ha-slider {
width: 100%;
min-width: 100px;
--paper-slider-secondary-color: transparent;
}
ha-slider:not(.full) {
max-width: 200px;
}
`}}t([lt()],vt.prototype,"hass",void 0),t([lt()],vt.prototype,"hide_state",void 0),t([function(t,e){return(s,i,r)=>{const n=e=>e.renderRoot?.querySelector(t)??null;if(e){const{get:t,set:a}="object"==typeof i?s:r??(()=>{const t=Symbol();return{get(){return this[t]},set(e){this[t]=e}}})();return ct(s,i,{get(){if(e){let e=t.call(this);return void 0===e&&(e=n(this),a.call(this,e)),e}return n(this)}})}return ct(s,i,{get(){return n(this)}})}}("ha-slider")],vt.prototype,"_slider",void 0),customElements.get("slider-entity-row")||(customElements.define("slider-entity-row",vt),console.info(`%cSLIDER-ENTITY-ROW ${ft} IS INSTALLED`,"color: green; font-weight: bold",""));