iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 49.4 kB
JavaScript
/*! For license information please see 41865.7ba75865ea0ea8fd.js.LICENSE.txt */
export const __rspack_esm_id=41865;export const __rspack_esm_ids=[41865];export const __webpack_modules__={90433(e,t,i){i.d(t,{Vy:()=>o,fI:()=>n,ux:()=>r});var a=i(22786),s=i(79468);function o(e,t){const i=e%54+1;return t.getPropertyValue(`--color-${i}`)}function n(e,t){const i=t.getPropertyValue(`--graph-color-${e+1}`)||o(e,t);return(0,s.RQ)(i)}const r=(0,a.A)(e=>Array.from({length:54},(t,i)=>n(i,e)),(e,t)=>e[0].getPropertyValue("--graph-color-1")===t[0].getPropertyValue("--graph-color-1")&&e[0].getPropertyValue("--color-1")===t[0].getPropertyValue("--color-1"))},90409(e,t,i){i.d(t,{A:()=>a});i(18111),i(61701);function a(e){const t=e.split(":").map(Number);return 3600*t[0]+60*t[1]+t[2]}},27167(e,t,i){i.d(t,{A:()=>s});const a=e=>e<10?`0${e}`:e;function s(e){const t=Math.floor(e/3600),i=Math.floor(e%3600/60),s=Math.floor(e%3600%60);return t>0?`${t}:${a(i)}:${a(s)}`:i>0?`${i}:${a(s)}`:s>0?""+s:null}},15090(e,t,i){i.d(t,{nP:()=>c,vB:()=>r});i(44114),i(18111),i(22489),i(61701),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var a=i(22675),s=i(52220),o=i(71727),n=i(69093);const r={alarm_control_panel:["armed_away","armed_custom_bypass","armed_home","armed_night","armed_vacation","arming","disarmed","disarming","pending","triggered"],alert:["on","off","idle"],assist_satellite:["idle","listening","responding","processing"],automation:["on","off"],binary_sensor:["on","off"],button:[],calendar:["on","off"],camera:["idle","recording","streaming"],cover:["closed","closing","open","opening"],device_tracker:["home","not_home"],fan:["on","off"],humidifier:["on","off"],infrared:[],input_boolean:["on","off"],input_button:[],lawn_mower:["error","paused","mowing","returning","docked"],light:["on","off"],lock:["jammed","locked","locking","unlocked","unlocking","opening","open"],media_player:["off","on","idle","playing","paused","standby","buffering"],person:["home","not_home"],plant:["ok","problem"],radio_frequency:[],remote:["on","off"],scene:[],schedule:["on","off"],script:["on","off"],siren:["on","off"],sun:["above_horizon","below_horizon"],switch:["on","off"],timer:["active","idle","paused"],update:["on","off"],vacuum:["cleaning","docked","error","idle","paused","returning"],valve:["closed","closing","open","opening"],weather:["clear-night","cloudy","exceptional","fog","hail","lightning-rainy","lightning","partlycloudy","pouring","rainy","snowy-rainy","snowy","sunny","windy-variant","windy"]},l={alarm_control_panel:{code_format:["number","text"]},binary_sensor:{device_class:["battery","battery_charging","co","cold","connectivity","door","garage_door","gas","heat","light","lock","moisture","motion","moving","occupancy","opening","plug","power","presence","problem","running","safety","smoke","sound","tamper","update","vibration","window"]},button:{device_class:["restart","update"]},camera:{frontend_stream_type:["hls","web_rtc"]},climate:{hvac_action:["off","idle","preheating","defrosting","heating","cooling","drying","fan"]},cover:{device_class:["awning","blind","curtain","damper","door","garage","gate","shade","shutter","window"]},device_tracker:{source_type:["bluetooth","bluetooth_le","gps","router"]},fan:{direction:["forward","reverse"]},humidifier:{device_class:["humidifier","dehumidifier"],action:["off","idle","humidifying","drying"]},media_player:{device_class:["tv","speaker","receiver"],media_content_type:["album","app","artist","channel","channels","composer","contributing_artist","episode","game","genre","image","movie","music","playlist","podcast","season","track","tvshow","url","video"],repeat:["off","one","all"]},number:{device_class:["temperature"]},sensor:{device_class:["apparent_power","aqi","battery","carbon_dioxide","carbon_monoxide","current","date","duration","energy","frequency","gas","humidity","illuminance","monetary","nitrogen_dioxide","nitrogen_monoxide","nitrous_oxide","ozone","ph","pm1","pm10","pm25","pm4","power_factor","power","pressure","reactive_power","signal_strength","sulphur_dioxide","temperature","timestamp","uptime","volatile_organic_compounds","volatile_organic_compounds_parts","voltage","volume_flow_rate"],state_class:["measurement","total","total_increasing"]},switch:{device_class:["outlet","switch"]},update:{device_class:["firmware"]},water_heater:{away_mode:["on","off"]}},c=(e,t,i=void 0)=>{const c=(0,n.t)(t),d=[];switch(d.push(...((e,t,i)=>{const n=[];switch(i||n.push(a.Hh,a.HV),!i&&t in r?n.push(...r[t]):i&&t in l&&i in l[t]&&n.push(...l[t][i]),t){case"device_tracker":case"person":i||n.push(...Object.entries(e.states).filter(([e,t])=>"zone"===(0,o.m)(e)&&"zone.home"!==e&&t.attributes.friendly_name).map(([e,t])=>t.attributes.friendly_name).sort((t,i)=>(0,s.xL)(t,i,e.locale.language)))}return n})(e,c,i)),c){case"climate":i?"fan_mode"===i?d.push(...t.attributes.fan_modes):"preset_mode"===i?d.push(...t.attributes.preset_modes):"swing_mode"===i?d.push(...t.attributes.swing_modes):"swing_horizontal_mode"===i&&d.push(...t.attributes.swing_horizontal_modes):d.push(...t.attributes.hvac_modes);break;case"event":"event_type"===i&&d.push(...t.attributes.event_types);break;case"fan":"preset_mode"===i&&d.push(...t.attributes.preset_modes);break;case"humidifier":"mode"===i&&d.push(...t.attributes.available_modes);break;case"input_select":case"select":i||d.push(...t.attributes.options);break;case"light":"effect"===i&&t.attributes.effect_list?d.push(...t.attributes.effect_list):"color_mode"===i&&t.attributes.supported_color_modes&&d.push(...t.attributes.supported_color_modes);break;case"media_player":"sound_mode"===i?d.push(...t.attributes.sound_mode_list):"source"===i&&d.push(...t.attributes.source_list);break;case"remote":"current_activity"===i&&d.push(...t.attributes.activity_list);break;case"sensor":i||"enum"!==t.attributes.device_class||d.push(...t.attributes.options);break;case"vacuum":"fan_speed"===i&&d.push(...t.attributes.fan_speed_list);break;case"water_heater":i&&"operation_mode"!==i||d.push(...t.attributes.operation_list)}return[...new Set(d)]}},45010(e,t,i){i.d(t,{U:()=>a});i(74423),i(18111),i(22489),i(61701);function a(e,t){const i=t.filter(t=>t in e).map(t=>[t,e[t]]),a=Object.entries(e).filter(([e])=>!t.includes(e));return Object.fromEntries([...i,...a])}},58548(e,t,i){i.d(t,{A:()=>s});const a=e=>{const t=parseFloat(e);if(isNaN(t))throw new Error(`${e} is not a number`);return t};function s(e){if(!e)return null;try{if(e.endsWith("%"))return{w:100,h:a(e.slice(0,-1))};const t=e.replace(":","x").split("x");return 0===t.length?null:1===t.length?{w:a(t[0]),h:1}:{w:a(t[0]),h:a(t[1])}}catch(e){}return null}},89300(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(5124),o=i(22441),n=i(6412),r=i(18350),l=i(65829),c=(i(67094),e([r,l]));[r,l]=c.then?(await c)():c;const d="M2.2,16.06L3.88,12L2.2,7.94L6.26,6.26L7.94,2.2L12,3.88L16.06,2.2L17.74,6.26L21.8,7.94L20.12,12L21.8,16.06L17.74,17.74L16.06,21.8L12,20.12L7.94,21.8L6.26,17.74L2.2,16.06M13,17V15H11V17H13M13,13V7H11V13H13Z",h="M9,20.42L2.79,14.21L5.62,11.38L9,14.77L18.88,4.88L21.71,7.71L9,20.42Z";class u extends s.WF{render(){const e=this.progress||this._result?"accent":this.appearance;return s.qy` <ha-button .appearance="${e}" .disabled="${this.disabled}" .loading="${this.progress}" .variant="${"success"===this._result?"success":"error"===this._result?"danger":this.variant}" class="${(0,n.H)({result:!!this._result,success:"success"===this._result,error:"error"===this._result})}"> ${this.iconPath?s.qy`<ha-svg-icon .path="${this.iconPath}" slot="start"></ha-svg-icon>`:s.s6} <slot>${this.label}</slot> </ha-button> ${this._result?s.qy` <div class="progress"> ${"success"===this._result?s.qy`<ha-svg-icon .path="${h}"></ha-svg-icon>`:"error"===this._result?s.qy`<ha-svg-icon .path="${d}"></ha-svg-icon>`:s.s6} </div> `:s.s6} `}actionSuccess(){this._setResult("success")}actionError(){this._setResult("error")}_setResult(e){this._result=e,setTimeout(()=>{this._result=void 0},2e3)}constructor(...e){super(...e),this.disabled=!1,this.progress=!1,this.appearance="accent",this.variant="brand"}}u.styles=s.AH`:host{outline:0;display:inline-block;position:relative}:host([progress]){pointer-events:none}.progress{bottom:0;display:flex;justify-content:center;align-items:center;position:absolute;top:0;width:100%}ha-button{width:100%}ha-button.result::part(caret),ha-button.result::part(end),ha-button.result::part(label),ha-button.result::part(spinner),ha-button.result::part(start){visibility:hidden}:host([appearance=brand]) ha-svg-icon{color:var(--white-color)}`,(0,a.Cg)([(0,o.MZ)()],u.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],u.prototype,"disabled",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],u.prototype,"progress",void 0),(0,a.Cg)([(0,o.MZ)()],u.prototype,"appearance",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],u.prototype,"iconPath",void 0),(0,a.Cg)([(0,o.MZ)()],u.prototype,"variant",void 0),(0,a.Cg)([(0,o.wk)()],u.prototype,"_result",void 0),u=(0,a.Cg)([(0,o.EM)("ha-progress-button")],u),t()}catch(e){t(e)}})},1253(e,t,i){i.d(t,{mJ:()=>a});const a=(e,t,i,a,s)=>{const[o]=e,[n,r]=s.viewSize,[l,c]=s.contentSize,d=i instanceof HTMLElement&&"rtl"===getComputedStyle(i).direction,h=o+12,u=o-12-l;let g=d?u:h;(g+l>n||g<0)&&(g=d?h:u),g=Math.max(0,Math.min(g,n-l));return[g,Math.max(0,Math.min(10,r-c))]}},89938(e,t,i){function a(e,t){const i=t-e;return!Number.isFinite(i)||i<=0?1:Math.max(0,Math.ceil(-Math.log10(i/10)))}i.d(t,{G:()=>a})},58234(e,t,i){i.a(e,async function(e,t){try{i(18111),i(20116);var a=i(62826),s=i(5124),o=i(22441),n=i(6412),r=i(23832),l=i(27167),c=i(69093),d=i(28978),h=i(15090),u=i(22675),g=i(49141),p=(i(58388),i(93367)),m=e([p]);p=(m.then?(await m)():m)[0];const _="M13 14H11V9H13M13 18H11V16H13M1 21H23L12 2L1 21Z",f=["alarm_control_panel","device_tracker","person"],y=(e,t)=>(0,r.g)(f)(e)&&(0,r.g)(h.vB[e])(t)?`${e}.${t}`:null;class b extends s.WF{connectedCallback(){super.connectedCallback(),this._connected=!0,this._startInterval(this.state)}disconnectedCallback(){super.disconnectedCallback(),this._connected=!1,this._clearInterval()}render(){const e=this.state;if(!e)return s.qy` <ha-label-badge class="warning" label="${this.hass.localize("state_badge.default.error")}" description="${this.hass.localize("state_badge.default.entity_not_found")}"> <ha-svg-icon .path="${_}"></ha-svg-icon> </ha-label-badge> `;const t=(0,c.t)(e),i=this.hass?.entities[e.entity_id],a=this.icon||this._computeShowIcon(t,e,i),o=this.icon?"":this.image?this.image:e.attributes.entity_picture_local||e.attributes.entity_picture,r=o||a?void 0:this._computeValue(t,e,i);return s.qy` <ha-label-badge class="${(0,n.H)({[t]:!0,"has-unit_of_measurement":"unit_of_measurement"in e.attributes})}" .image="${o}" .label="${this._computeLabel(t,e,this._timerTimeRemaining)}" .description="${this.showName?this.name??(0,d.u)(e):void 0}"> ${!o&&a?s.qy`<ha-state-icon .icon="${this.icon}" .stateObj="${e}"></ha-state-icon>`:""} ${!r||o||a?"":s.qy`<span class="${r&&r.length>4?"big":""}">${r}</span>`} </ha-label-badge> `}updated(e){super.updated(e),this._connected&&e.has("state")&&this._startInterval(this.state)}_computeValue(e,t,i){switch(e){case"alarm_control_panel":case"binary_sensor":case"device_tracker":case"person":case"scene":case"sun":case"timer":return null;case"sensor":if("moon"===i?.platform)return null;default:return t.state===u.Hh||t.state===u.HV?"—":this.hass.formatEntityStateToParts(t).find(e=>"value"===e.type)?.value}}_computeShowIcon(e,t,i){if(t.state===u.Hh)return!1;switch(e){case"alarm_control_panel":case"binary_sensor":case"device_tracker":case"person":case"scene":case"sun":case"timer":return!0;case"sensor":return"moon"===i?.platform;default:return!1}}_computeLabel(e,t,i=0){if(t.state===u.Hh||t.state===u.HV)return this.hass.localize(`state_badge.default.${t.state}`);const a=y(e,t.state);return a?this.hass.localize(`state_badge.${a}`):"person"===e||"device_tracker"===e?t.state:"timer"===e?(0,l.A)(i):this.hass.formatEntityStateToParts(t).find(e=>"unit"===e.type)?.value||null}_clearInterval(){this._updateRemaining&&(clearInterval(this._updateRemaining),this._updateRemaining=void 0)}_startInterval(e){this._clearInterval(),e&&"timer"===(0,c.t)(e)&&(this._calculateTimerRemaining(e),"active"===e.state&&(this._updateRemaining=window.setInterval(()=>this._calculateTimerRemaining(this.state),1e3)))}_calculateTimerRemaining(e){this._timerTimeRemaining=(0,g.ls)(e)}constructor(...e){super(...e),this.showName=!1}}b.styles=s.AH`:host{cursor:pointer}.big{font-size:var(--ha-font-size-xs)}ha-label-badge{--ha-label-badge-color:var(--label-badge-red)}ha-label-badge.has-unit_of_measurement{--ha-label-badge-label-text-transform:none}ha-label-badge.binary_sensor{--ha-label-badge-color:var(--label-badge-blue)}.red{--ha-label-badge-color:var(--label-badge-red)}.blue{--ha-label-badge-color:var(--label-badge-blue)}.green{--ha-label-badge-color:var(--label-badge-green)}.yellow{--ha-label-badge-color:var(--label-badge-yellow)}.grey{--ha-label-badge-color:var(--label-badge-grey)}.warning{--ha-label-badge-color:var(--label-badge-yellow)}`,(0,a.Cg)([(0,o.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],b.prototype,"state",void 0),(0,a.Cg)([(0,o.MZ)()],b.prototype,"name",void 0),(0,a.Cg)([(0,o.MZ)()],b.prototype,"icon",void 0),(0,a.Cg)([(0,o.MZ)()],b.prototype,"image",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"show-name",type:Boolean})],b.prototype,"showName",void 0),(0,a.Cg)([(0,o.wk)()],b.prototype,"_timerTimeRemaining",void 0),b=(0,a.Cg)([(0,o.EM)("ha-state-label-badge")],b),t()}catch(e){t(e)}})},71938(e,t,i){i.a(e,async function(e,t){try{i(74423),i(18111),i(22489),i(61701);var a=i(62826),s=i(5124),o=i(22441),n=i(75751),r=i(1087),l=i(81423),c=e([l]);l=(c.then?(await c)():c)[0];class d extends s.WF{render(){if(!this.hass)return s.s6;const e=this.ignoreRestrictionsOnFirstStatistic&&this._currentStatistics.length<=1,t=e?void 0:this.includeStatisticsUnitOfMeasurement,i=e?void 0:this.includeUnitClass,a=e?void 0:this.includeDeviceClass,o=e?void 0:this.statisticTypes;return s.qy` ${this.label?s.qy`<label>${this.label}</label>`:s.s6} ${(0,n.u)(this._currentStatistics,e=>e,e=>s.qy` <div> <ha-statistic-picker .curValue="${e}" .hass="${this.hass}" .includeStatisticsUnitOfMeasurement="${t}" .includeUnitClass="${i}" .includeDeviceClass="${a}" .value="${e}" .statisticTypes="${o}" .statisticIds="${this.statisticIds}" .excludeStatistics="${this.value}" .allowCustomEntity="${this.allowCustomEntity}" .canEdit="${this.canEdit}" -changed="${this._statisticChanged}" -statistics-element="${this._editItem}"></ha-statistic-picker> </div> `)} <div> <ha-statistic-picker .hass="${this.hass}" .includeStatisticsUnitOfMeasurement="${this.includeStatisticsUnitOfMeasurement}" .includeUnitClass="${this.includeUnitClass}" .includeDeviceClass="${this.includeDeviceClass}" .statisticTypes="${this.statisticTypes}" .statisticIds="${this.statisticIds}" .placeholder="${this.placeholder}" .excludeStatistics="${this.value}" .allowCustomEntity="${this.allowCustomEntity}" -changed="${this._addStatistic}"></ha-statistic-picker> </div> `}_editItem(e){const t=e.detail.statisticId,i=this._currentStatistics.findIndex(e=>e===t);(0,r.r)(this,"edit-detail-element",{subElementConfig:{index:i,type:"row"}})}get _currentStatistics(){return this.value||[]}async _updateStatistics(e){this.value=e,(0,r.r)(this,"value-changed",{value:e})}_statisticChanged(e){e.stopPropagation();const t=e.currentTarget.curValue,i=e.detail.value;if(i===t)return;const a=this._currentStatistics;i&&!a.includes(i)?this._updateStatistics(a.map(e=>e===t?i:e)):this._updateStatistics(a.filter(e=>e!==t))}async _addStatistic(e){e.stopPropagation();const t=e.detail.value;if(!t)return;if(e.currentTarget.value="",!t)return;const i=this._currentStatistics;i.includes(t)||this._updateStatistics([...i,t])}constructor(...e){super(...e),this.ignoreRestrictionsOnFirstStatistic=!1}}d.styles=s.AH`:host{display:block}ha-statistic-picker{display:block;width:100%;margin-top:8px}label{display:block;margin-bottom:0 0 8px}`,(0,a.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({type:Array})],d.prototype,"value",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],d.prototype,"statisticIds",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"statistic-types"})],d.prototype,"statisticTypes",void 0),(0,a.Cg)([(0,o.MZ)({type:String})],d.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)({type:String})],d.prototype,"placeholder",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,attribute:"allow-custom-entity"})],d.prototype,"allowCustomEntity",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"include-statistics-unit-of-measurement"})],d.prototype,"includeStatisticsUnitOfMeasurement",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"include-unit-class"})],d.prototype,"includeUnitClass",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"include-device-class"})],d.prototype,"includeDeviceClass",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,attribute:"ignore-restrictions-on-first-statistic"})],d.prototype,"ignoreRestrictionsOnFirstStatistic",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"can-edit",type:Boolean})],d.prototype,"canEdit",void 0),d=(0,a.Cg)([(0,o.EM)("ha-statistics-picker")],d),t()}catch(e){t(e)}})},58388(e,t,i){var a=i(62826),s=i(5124),o=i(22441),n=i(6412);class r extends s.WF{render(){return s.qy` <div class="badge-container"> <div class="label-badge" id="badge"> <div class="value"> <slot></slot> </div> ${this.label?s.qy` <div class="${(0,n.H)({label:!0,big:this.label.length>5})}"> <span>${this.label}</span> </div> `:""} </div> ${this.description?s.qy`<div class="title">${this.description}</div>`:""} </div> `}static get styles(){return[s.AH`.badge-container{display:inline-block;text-align:center;vertical-align:top;padding:var(--ha-label-badge-padding,0 0 0 0)}.label-badge{position:relative;display:block;margin:0 auto;width:var(--ha-label-badge-size,2.5em);text-align:center;height:var(--ha-label-badge-size,2.5em);line-height:var(--ha-label-badge-size, 2.5em);font-size:var(--ha-label-badge-font-size, 1.5em);border-radius:var(--ha-label-badge-border-radius,50%);border:.1em solid var(--ha-label-badge-color,var(--primary-color));color:var(--label-badge-text-color,#4c4c4c);white-space:nowrap;background-color:var(--label-badge-background-color,#fff);background-size:cover;transition:border .3s ease-in-out}.label-badge .label.big span{font-size:90%;padding:10% 12% 7% 12%}.label-badge .value{font-size:90%;overflow:hidden;text-overflow:ellipsis}.label-badge .label{position:absolute;bottom:-1em;left:-.2em;right:-.2em;line-height:1em;font-size:.5em}.label-badge .label span{box-sizing:border-box;max-width:100%;display:inline-block;background-color:var(--ha-label-badge-color,var(--primary-color));color:var(--ha-label-badge-label-color,#fff);border-radius:var(--ha-border-radius-lg);padding:9% 16% 8% 16%;font-weight:var(--ha-font-weight-medium);overflow:hidden;text-transform:uppercase;text-overflow:ellipsis;transition:background-color .3s ease-in-out;text-transform:var(--ha-label-badge-label-text-transform,uppercase)}.badge-container .title{margin-top:1em;font-size:var(--ha-label-badge-title-font-size, .9em);width:var(--ha-label-badge-title-width,5em);font-weight:var(--ha-label-badge-title-font-weight,var(--ha-font-weight-normal));overflow:hidden;text-overflow:ellipsis;line-height:normal}`]}updated(e){super.updated(e),e.has("image")&&(this.shadowRoot.getElementById("badge").style.backgroundImage=this.image?`url(${this.image})`:"")}}(0,a.Cg)([(0,o.MZ)()],r.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)()],r.prototype,"description",void 0),(0,a.Cg)([(0,o.MZ)()],r.prototype,"image",void 0),r=(0,a.Cg)([(0,o.EM)("ha-label-badge")],r)},17022(e,t,i){i.d(t,{A1:()=>a,CY:()=>n,Fn:()=>s,Jz:()=>l,St:()=>r,VA:()=>d,WI:()=>h,iY:()=>c,xw:()=>o});const a=(e,t)=>e.callWS({type:"media_source/resolve_media",media_content_id:t}),s=(e,t)=>e.callWS({type:"media_source/browse_media",media_content_id:t}),o="__MANUAL_ENTRY__",n=e=>e.startsWith(o),r=e=>e.startsWith("media-source://"),l=e=>e.startsWith("media-source://media_source"),c=e=>e.startsWith("media-source://image_upload"),d=async(e,t,i)=>{const a=new FormData;a.append("media_content_id",t),a.append("file",i);const s=await e.fetchWithAuth("/api/media_source/local_source/upload",{method:"POST",body:a});if(413===s.status)throw new Error(`Uploaded file is too large (${i.name})`);if(200!==s.status)throw new Error("Unknown error");return s.json()},h=async(e,t)=>e.callWS({type:"media_source/local_source/remove",media_content_id:t})},49141(e,t,i){i.d(t,{CR:()=>n,PF:()=>d,kL:()=>o,ls:()=>c,pZ:()=>l,r9:()=>r});var a=i(90409),s=i(27167);const o=e=>e.callWS({type:"timer/list"}),n=(e,t)=>e.callWS({type:"timer/create",...t}),r=(e,t,i)=>e.callWS({type:"timer/update",timer_id:t,...i}),l=(e,t)=>e.callWS({type:"timer/delete",timer_id:t}),c=e=>{if(!e.attributes.remaining)return;let t=(0,a.A)(e.attributes.remaining);if("active"===e.state){const i=(new Date).getTime(),a=new Date(e.attributes.finishes_at).getTime();t=Math.max((a-i)/1e3,0)}return t},d=(e,t,i)=>{if(!t)return null;if("idle"===t.state||0===i)return e.formatEntityState(t);let a=(0,s.A)(i||0)||"0";return"paused"===t.state&&(a=`${a} (${e.formatEntityState(t)})`),a}},9169(e,t,i){i.d(t,{j:()=>a});const a=["relative","total","date","time","datetime"]},84043(e,t,i){i.a(e,async function(e,a){try{i.d(t,{d:()=>g});i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var s=i(98743),o=(i(16732),i(9578)),n=i(51007),r=i(37696),l=i(10792),c=i(14097),d=i(34128),h=e([s,o,n,r,l,c]);[s,o,n,r,l,c]=h.then?(await h)():h;const u=new Set(["conditional","icon","image","service-button","state-badge","state-icon","state-label"]),g=e=>("action-button"===e.type&&(e={...e,type:"service-button"}),(0,d.Ue)("element",e,u));a()}catch(e){a(e)}})},82743(e,t,i){i.a(e,async function(e,a){try{i.d(t,{j:()=>p});i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var s=i(98743),o=(i(16732),i(9578)),n=i(51007),r=i(37696),l=i(10792),c=i(14097),d=i(34128),h=e([s,o,n,r,l,c]);[s,o,n,r,l,c]=h.then?(await h)():h;const u=new Set(["conditional","icon","image","service-button","state-badge","state-icon","state-label"]),g={},p=e=>(0,d.gh)("action-button"===e?"service-button":e,"element",u,g);a()}catch(e){a(e)}})},98809(e,t,i){i.a(e,async function(e,t){try{i(74423),i(18111),i(22489),i(61701);var a=i(62826),s=i(5124),o=i(22441),n=i(22786),r=i(63533),l=i(1087),c=i(71727),d=i(52763),h=i(20507),u=e([d]);d=(u.then?(await u)():u)[0];const g={none:{},"entity-id":{},"last-changed":{},"last-updated":{},"last-triggered":{domains:["automation","script"]},area:{},position:{domains:["cover"]},state:{},"tilt-position":{domains:["cover"]},brightness:{domains:["light"]}};class p extends s.WF{setConfig(e){(0,r.vA)(e,h.l),this._config=e}render(){if(!this.hass||!this._config)return s.s6;const e=this.schema||this._schema(this._config.entity,this.hass.localize);return s.qy` <ha-form .hass="${this.hass}" .data="${this._config}" .schema="${e}" .computeLabel="${this._computeLabelCallback}" -changed="${this._valueChanged}"></ha-form> `}_valueChanged(e){(0,l.r)(this,"config-changed",{config:e.detail.value})}constructor(...e){super(...e),this._schema=(0,n.A)((e,t)=>{const i=(0,c.m)(e);return[{name:"entity",required:!0,selector:{entity:{}}},{name:"name",selector:{entity_name:{}},context:{entity:"entity"}},{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}},{name:"secondary_info",selector:{select:{options:Object.keys(g).filter(e=>!("domains"in g[e])||"domains"in g[e]&&g[e].domains.includes(i)).map(e=>({value:e,label:t(`ui.panel.lovelace.editor.card.entities.secondary_info_values.${e}`)}))}}}]}),this._computeLabelCallback=e=>"secondary_info"===e.name?this.hass.localize(`ui.panel.lovelace.editor.card.entity-row.${e.name}`):this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)}}(0,a.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"schema",void 0),(0,a.Cg)([(0,o.wk)()],p.prototype,"_config",void 0),p=(0,a.Cg)([(0,o.EM)("hui-generic-entity-row-editor")],p),t()}catch(e){t(e)}})},9562(e,t,i){i.a(e,async function(e,a){try{i.r(t),i.d(t,{HuiStatisticsGraphCardEditor:()=>S});i(18111),i(22489),i(20116),i(7588),i(61701),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var s=i(62826),o=i(5124),n=i(22441),r=i(22786),l=i(63533),c=i(44537),d=i(1087),h=i(19459),u=i(36525),g=i(71938),p=i(52763),m=i(23528),_=i(3515),f=i(20939),y=i(81287),b=i(84698),v=i(20507),C=i(27538),w=e([g,p,y,_,u]);[g,p,y,_,u]=w.then?(await w)():w;const E=(0,l.KC)([(0,l.eu)("state"),(0,l.eu)("sum"),(0,l.eu)("change"),(0,l.eu)("min"),(0,l.eu)("max"),(0,l.eu)("mean")]),$=(0,l.kp)(b.H,(0,l.Ik)({entities:(0,l.YO)(v.z),title:(0,l.lq)((0,l.Yj)()),days_to_show:(0,l.lq)((0,l.ai)()),period:(0,l.lq)((0,l.KC)([(0,l.eu)("5minute"),(0,l.eu)("hour"),(0,l.eu)("day"),(0,l.eu)("week"),(0,l.eu)("month"),(0,l.eu)("year"),(0,l.eu)("auto")])),chart_type:(0,l.lq)((0,l.KC)([(0,l.eu)("line"),(0,l.eu)("line-stack"),(0,l.eu)("bar"),(0,l.eu)("bar-stack")])),stat_types:(0,l.lq)((0,l.KC)([(0,l.YO)(E),E])),unit:(0,l.lq)((0,l.Yj)()),hide_legend:(0,l.lq)((0,l.zM)()),expand_legend:(0,l.lq)((0,l.zM)()),logarithmic_scale:(0,l.lq)((0,l.zM)()),min_y_axis:(0,l.lq)((0,l.ai)()),max_y_axis:(0,l.lq)((0,l.ai)()),fit_y_data:(0,l.lq)((0,l.zM)()),energy_date_selection:(0,l.lq)((0,l.zM)()),collection_key:(0,l.lq)((0,l.Yj)())})),M=["line","line-stack","bar","bar-stack"],k=["5minute","hour","day","week","month","year"],x=[...k,"auto"],q=["mean","min","max","sum","state","change"];class S extends o.WF{setConfig(e){(0,l.vA)(e,$),this._config=e,this._configEntities=e.entities?(0,f.L)(e.entities,!1).map(e=>e.entity):[]}willUpdate(e){e.has("_configEntities")&&!(0,h.b)(this._configEntities,e.get("_configEntities"))&&(this._metaDatas=void 0,this._configEntities?.length&&this._getStatisticsMetaData(this._configEntities))}render(){if(!this.hass||!this._config)return o.s6;if(this._subElementEditorConfig)return o.qy` <hui-sub-element-editor .hass="${this.hass}" .config="${this._subElementEditorConfig}" .form="${this._subForm(this.hass.localize)}" -back="${this._goBack}" -changed="${this._handleSubEntityChanged}"> </hui-sub-element-editor> `;const e=this._schema(this.hass.localize,this._configEntities,this._metaDatas,void 0!==this._config.min_y_axis||void 0!==this._config.max_y_axis,!!this._config.hide_legend,!!this._config.energy_date_selection),t=this._config.stat_types?(0,c.e)(this._config.stat_types):q.filter(e=>this._metaDatas?.some(t=>(0,m.nN)(t,e))),i={chart_type:"line",period:this._config.energy_date_selection?"auto":"hour",...this._config,stat_types:t},a=this._metaDatas?.[0]?.unit_class,s=a?void 0:this._metaDatas?.[0]?.statistics_unit_of_measurement;return o.qy` <ha-form .hass="${this.hass}" .data="${i}" .schema="${e}" .computeLabel="${this._computeLabelCallback}" .computeHelper="${this._computeHelperCallback}" -changed="${this._valueChanged}"></ha-form> <ha-statistics-picker .hass="${this.hass}" .placeholder="${this.hass.localize("ui.panel.lovelace.editor.card.statistics-graph.pick_statistic")}" .label="${this.hass.localize("ui.panel.lovelace.editor.card.statistics-graph.picked_statistic")}" .includeStatisticsUnitOfMeasurement="${s}" .includeUnitClass="${a}" .ignoreRestrictionsOnFirstStatistic="${!0}" .value="${this._configEntities}" .configValue="${"entities"}" can-edit -changed="${this._entitiesChanged}" -detail-element="${this._editDetailElement}"></ha-statistics-picker> `}_goBack(){this._subElementEditorConfig=void 0}_editDetailElement(e){const t=e.detail.subElementConfig.index;let i=this._config.entities[t];"string"==typeof i&&(i={entity:i}),this._subElementEditorConfig={...e.detail.subElementConfig,elementConfig:i}}_valueChanged(e){const t=this._orderProperties(e.detail.value);(0,d.r)(this,"config-changed",{config:t})}async _entitiesChanged(e){const t=e.detail.value.map(e=>this._config.entities.find(t=>"string"!=typeof t&&t.entity===e)??e);let i={...this._config,entities:t};i=await this._cleanConfig(i),i=this._orderProperties(i),(0,d.r)(this,"config-changed",{config:i})}async _handleSubEntityChanged(e){e.stopPropagation();const t=e.detail.config,i=this._subElementEditorConfig.index,a=[...this._config.entities];a[i]=t;let s=this._config;s={...s,entities:a},s=await this._cleanConfig(s),s=this._orderProperties(s),this._config=s,this._subElementEditorConfig={...this._subElementEditorConfig,elementConfig:{...this._config.entities[i]}},(0,d.r)(this,"config-changed",{config:s})}async _cleanConfig(e){const t=e.entities.map(e=>"string"==typeof e?e:e.entity??void 0);t.some(e=>(0,m.OQ)(e))&&"5minute"===e.period&&delete e.period;const i=e.stat_types||e.unit?await(0,m.Wr)(this.hass,t):void 0;return e.stat_types&&e.entities.length&&(e.stat_types=(0,c.e)(e.stat_types).filter(e=>i.some(t=>(0,m.nN)(t,e))),e.stat_types.length||delete e.stat_types),e.unit&&!i.some(t=>(0,m.JE)(this.hass,t?.statistic_id,t)===e.unit)&&delete e.unit,e}_orderProperties(e){return(0,C.i)(e,$)}constructor(...e){super(...e),this._getStatisticsMetaData=async e=>{this._metaDatas=await(0,m.Wr)(this.hass,e||[])},this._schema=(0,r.A)((e,t,i,a,s,o)=>{const n=new Set;i?.forEach(e=>{const t=(0,m.JE)(this.hass,e.statistic_id,e);t&&n.add(t)});return[{name:"title",selector:{text:{}}},{name:"",type:"grid",schema:[{name:"",type:"grid",schema:[{name:"chart_type",required:!0,type:"select",options:M.map(t=>[t,e(`ui.panel.lovelace.editor.card.statistics-graph.chart_type_labels.${t}`)])},...o?[]:[{name:"days_to_show",default:_.DEFAULT_DAYS_TO_SHOW,selector:{number:{min:1,mode:"box"}}}]]},{name:"period",required:!0,selector:{select:{mode:"list",options:(o?x:k).map(i=>({value:i,label:e(`ui.panel.lovelace.editor.card.statistics-graph.periods.${i}`),disabled:"5minute"===i&&t?.some(e=>(0,m.OQ)(e))}))}}}]},{name:"",type:"grid",schema:[...o?[{type:"string",name:"collection_key",required:!1}]:[],{name:"energy_date_selection",required:!1,selector:{boolean:{}}}]},{name:"",type:"grid",schema:[{name:"stat_types",required:!0,selector:{select:{multiple:!0,mode:"list",options:q.map(t=>({value:t,label:e(`ui.panel.lovelace.editor.card.statistics-graph.stat_type_labels.${t}`),disabled:!i||!i.some(e=>(0,m.nN)(e,u.n[t]))}))}}},{name:"",type:"grid",schema:[{name:"min_y_axis",required:!1,selector:{number:{mode:"box",step:"any"}}},{name:"max_y_axis",required:!1,selector:{number:{mode:"box",step:"any"}}},...a?[{name:"fit_y_data",required:!1,selector:{boolean:{}}}]:[],{name:"logarithmic_scale",required:!1,selector:{boolean:{}}},{name:"hide_legend",required:!1,selector:{boolean:{}}},...s?[]:[{name:"expand_legend",required:!1,selector:{boolean:{}}}]]}]},...n.size>1?[{name:"unit",required:!1,selector:{select:{options:Array.from(n).map(e=>({value:e,label:e}))}}}]:[]]}),this._subForm=(0,r.A)(e=>({schema:[{name:"entity",required:!0,selector:{statistic:{}}},{name:"name",selector:{entity_name:{}},context:{entity:"entity"}},{name:"color",selector:{ui_color:{}}}],computeLabel:t=>{switch(t.name){case"entity":return e("ui.panel.lovelace.editor.card.statistics-graph.picked_statistic");case"name":case"color":return e(`ui.panel.lovelace.editor.card.generic.${t.name}`);default:return}}})),this._computeHelperCallback=e=>{if("collection_key"===e.name)return this.hass.localize("ui.panel.lovelace.editor.card.generic.collection_key_description")},this._computeLabelCallback=e=>{switch(e.name){case"chart_type":case"stat_types":case"period":case"unit":case"hide_legend":case"expand_legend":case"logarithmic_scale":case"min_y_axis":case"max_y_axis":case"fit_y_data":return this.hass.localize(`ui.panel.lovelace.editor.card.statistics-graph.${e.name}`);default:return this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)}}}}S.styles=o.AH`ha-statistics-picker{width:100%}`,(0,s.Cg)([(0,n.MZ)({attribute:!1})],S.prototype,"hass",void 0),(0,s.Cg)([(0,n.wk)()],S.prototype,"_config",void 0),(0,s.Cg)([(0,n.wk)()],S.prototype,"_configEntities",void 0),(0,s.Cg)([(0,n.wk)()],S.prototype,"_metaDatas",void 0),(0,s.Cg)([(0,n.wk)()],S.prototype,"_subElementEditorConfig",void 0),S=(0,s.Cg)([(0,n.EM)("hui-statistics-graph-card-editor")],S),a()}catch(e){a(e)}})},27538(e,t,i){i.d(t,{i:()=>s});i(18111),i(61701);var a=i(45010);const s=(e,t)=>{const i=Object.keys(t.schema),s=["entity","name","color"];let o={...(0,a.U)(e,i)};const n=e.entities.map(e=>"string"!=typeof e?(0,a.U)(e,s):e);return o={...o,entities:n},o}},88528(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(22441),o=i(94225),n=i(63277),r=i(98809),l=e([r,n,o]);[r,n,o]=l.then?(await l)():l;const c="generic-row";class d extends n.U{get configElementType(){return!this.value?.type&&"entity"in this.value?c:"perform-action"===this.value?.type?"call-service":this.value?.type}async getConfigElement(){if(this.configElementType===c)return document.createElement("hui-generic-entity-row-editor");const e=await(0,o.t)(this.configElementType);return e&&e.getConfigElement?e.getConfigElement():void 0}}d=(0,a.Cg)([(0,s.EM)("hui-row-element-editor")],d),t()}catch(e){t(e)}})},10903(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(22441),o=i(13174),n=i(63277),r=e([n,o]);[n,o]=r.then?(await r)():r;class l extends n.U{async getConfigElement(){const e=await(0,o.h)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}async getConfigForm(){const e=await(0,o.h)(this.configElementType);if(e&&e.getConfigForm)return e.getConfigForm()}}l=(0,a.Cg)([(0,s.EM)("hui-card-feature-element-editor")],l),t()}catch(e){t(e)}})},39039(e,t,i){i.d(t,{r:()=>a});class a extends Error{constructor(e,t,i){super(e),this.name="GUISupportError",this.warnings=t,this.errors=i}}},49288(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(22441),o=i(83938),n=i(63277),r=e([n]);n=(r.then?(await r)():r)[0];class l extends n.U{async getConfigElement(){const e=await(0,o.l)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}}l=(0,a.Cg)([(0,s.EM)("hui-headerfooter-element-editor")],l),t()}catch(e){t(e)}})},6870(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(22441),o=i(72669),n=i(63277),r=e([n,o]);[n,o]=r.then?(await r)():r;class l extends n.U{get configElementType(){return this.value?.type||"entity"}async getConfigElement(){const e=await(0,o.U)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}async getConfigForm(){const e=await(0,o.U)(this.configElementType);if(e&&e.getConfigForm)return e.getConfigForm()}}l=(0,a.Cg)([(0,s.EM)("hui-heading-badge-element-editor")],l),t()}catch(e){t(e)}})},91322(e,t,i){i.a(e,async function(e,a){try{i.d(t,{m:()=>_});i(18111),i(7588),i(61701);var s=i(62826),o=i(5124),n=i(22441),r=i(74985),l=i(1087),c=i(78978),d=i(19459),h=i(38962),u=i(65829),g=i(10763),p=i(39039),m=e([h,u,g]);[h,u,g]=m.then?(await m)():m;class _ extends o.WF{get value(){return this._config}set value(e){this._config&&(0,d.b)(e,this._config,{compareSymbols:!0})||(this._config=e,this._errors=void 0,this._setConfig())}_setConfig(){if(!this._errors&&!this._yamlError)try{this._updateConfigElement()}catch(e){this._errors=[e.message]}this.updateComplete.then(()=>{(0,l.r)(this,"config-changed",{config:this.value,error:this._errors?.join(", "),guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})})}get hasWarning(){return void 0!==this._warnings&&this._warnings.length>0}get hasError(){return this._yamlError||void 0!==this._errors&&this._errors.length>0}get GUImode(){return this._guiMode}set GUImode(e){this._guiMode=e,this.updateComplete.then(()=>{(0,l.r)(this,"GUImode-changed",{guiMode:e,guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})})}toggleMode(){this.GUImode||this._yamlEditor?.disableCodeEditorFullscreen(),this.GUImode=!this.GUImode}focusYamlEditor(){this._configElement?.focusYamlEditor&&this._configElement.focusYamlEditor(),this._yamlEditor&&this._yamlEditor.focus()}async getConfigElement(){}async getConfigForm(){}renderConfigElement(){return o.qy`${this._configElement}`}_renderSubElement(){return o.qy` <hui-sub-element-editor .hass="${this.hass}" .config="${this._subElementEditorConfig}" -back="${this._goBack}" -changed="${this._subElementChanged}"> </hui-sub-element-editor> `}_subElementChanged(e){e.stopPropagation();const t=e.detail.config;this._subElementEditorConfig={...this._subElementEditorConfig,elementConfig:t},this._subElementEditorConfig.saveElementConfig?.(t)}_goBack(e){e.stopPropagation(),this._subElementEditorConfig=void 0}async _editSubElement(e){e.stopPropagation(),await Promise.all([i.e(92769),i.e(3283),i.e(80131),i.e(70183),i.e(67218),i.e(58416),i.e(99788),i.e(58303),i.e(21543),i.e(22398),i.e(46601),i.e(51455),i.e(26092),i.e(8851),i.e(59704),i.e(25322),i.e(90790),i.e(59532),i.e(55076),i.e(36332),i.e(77563),i.e(15862),i.e(99143),i.e(97500),i.e(12009),i.e(66990),i.e(20282),i.e(87857),i.e(92363),i.e(84240)]).then(i.bind(i,81287)),this._subElementEditorConfig={type:e.detail.type,elementConfig:e.detail.config,context:e.detail.context,saveElementConfig:e.detail.saveConfig}}render(){return o.qy` <div class="wrapper"> ${this.GUImode?o.qy` <div class="gui-editor" -sub-element="${this._editSubElement}"> ${this._loading?o.qy` <ha-spinner class="center margin-bot"></ha-spinner> `:(0,r.P)(this._subElementEditorConfig?this._renderSubElement():this.renderConfigElement())} </div> `:o.qy` <div class="yaml-editor"> <ha-yaml-editor .defaultValue="${this._config}" autofocus .inDialog="${this.inDialog}" -changed="${this._handleYAMLChanged}" ="${this._ignoreKeydown}" dir="ltr"></ha-yaml-editor> </div> `} ${!1===this._guiSupported&&!1===this._loading?o.qy` <ha-alert alert-type="info" .title="${this.hass.localize("ui.errors.config.visual_editor_not_supported")}"> ${this.hass.localize("ui.errors.config.visual_editor_not_supported_reason_type")} <br> ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} </ha-alert> `:o.s6} ${this._errors?.length?o.qy` <ha-alert alert-type="error" .title="${this.hass.localize("ui.errors.config.configuration_error")}"> <ul> ${this._errors.map(e=>o.qy`<li>${e}</li>`)} </ul> </ha-alert> `:o.s6} ${this.hasWarning?o.qy` <ha-alert alert-type="warning" .title="${this.hass.localize("ui.errors.config.visual_editor_not_supported")}"> <ul> ${this._warnings.map(e=>o.qy`<li>${e}</li>`)} </ul> ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} </ha-alert> `:o.s6} </div> `}updated(e){super.updated(e),this._configElement&&e.has("hass")&&(this._configElement.hass=this.hass),this._configElement&&"lovelace"in this._configElement&&e.has("lovelace")&&(this._configElement.lovelace=this.lovelace),this._configElement&&e.has("context")&&(this._configElement.context=this.context)}_handleUIConfigChanged(e){if(e.stopPropagation(),!this.GUImode)return;const t=e.detail.config;Object.keys(t).forEach(e=>{void 0===t[e]&&delete t[e]}),this.value=t}_handleYAMLChanged(e){e.stopPropagation(),e.detail.isValid?(this._config=e.detail.value,this._errors=void 0,this._yamlError=!1):this._yamlError=!0,this._setConfig()}async unloadConfigElement(){this._configElement=void 0,this._guiSupported=void 0}async loadConfigElement(){if(this._configElement)return;let e=await this.getConfigElement();if(!e){const t=await this.getConfigForm();if(t){await i.e(15106).then(i.bind(i,15737)),e=document.createElement("hui-form-editor");const{schema:a,assertConfig:s,computeLabel:o,computeHelper:n}=t;e.schema=a,o&&(e.computeLabel=o),n&&(e.computeHelper=n),s&&(e.assertConfig=s)}}e?(e.hass=this.hass,"lovelace"in e&&(e.lovelace=this.lovelace),e.context=this.context,e.addEventListener("config-changed",e=>this._handleUIConfigChanged(e)),this._guiSupported=!0):this._guiSupported=!1,this._configElement=e}async _updateConfigElement(){if(!this.value)return;const e=++this._loadCount;try{if(this._errors=void 0,this._warnings=void 0,await this.loadConfigElement(),this._configElement)try{this._configElement.setConfig(this.value)}catch(e){const t=(0,c._)(this.hass,e);throw new p.r("Config is not supported",t.warnings,t.errors)}else this._guiSupported=!1,this.GUImode=!1}catch(t){if(e!==this._loadCount)return;t instanceof p.r?(this._warnings=t.warnings??[t.message],this._errors=t.errors||void 0):this._errors=[t.message],this.GUImode=!1}finally{this._loading=!1}}_ignoreKeydown(e){e.stopPropagation()}constructor(...e){super(...e),this.inDialog=!1,this._guiMode=!0,this._loading=!1,this._yamlError=!1,this._loadCount=0}}_.styles=o.AH`:host{display:flex}.wrapper{width:100%}.gui-editor,.yaml-editor{padding:8px 0px}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}ha-spinner{display:block;margin:auto}`,(0,s.Cg)([(0,n.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],_.prototype,"lovelace",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],_.prototype,"context",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean,attribute:"in-dialog"})],_.prototype,"inDialog",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_config",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_configElement",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_subElementEditorConfig",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_guiMode",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_errors",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_warnings",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_guiSupported",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_loading",void 0),(0,s.Cg)([(0,n.wk)()],_.prototype,"_yamlError",void 0),(0,s.Cg)([(0,n.P)("ha-yaml-editor")],_.prototype,"_yamlEditor",void 0),a()}catch(e){a(e)}})},98161(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(22441),o=i(91322),n=e([o]);o=(n.then?(await n)():n)[0];class r extends o.m{async getConfigForm(){return this.form}updated(e){if(super.updated(e),e.has("form")&&this._configElement){const{schema:e,assertConfig:t,computeLabel:i,computeHelper:a}=this.form;this._configElement.schema=e,i&&(this._configElement.computeLabel=i),a&&(this._configElement.computeHelper=a),t&&(this._configElement.assertConfig=t)}}}(0,a.Cg)([(0,s.MZ)({attribute:!1})],r.prototype,"form",void 0),r=(0,a.Cg)([(0,s.EM)("hui-form-element-editor")],r),t()}catch(e){t(e)}})},81287(e,t,i){i.a(e,async function(e,a){try{i.r(t),i.d(t,{HuiSubElementEditor:()=>b});var s=i(62826),o=i(5124),n=i(22441),r=i(1087),l=i(26300),c=i(45100),d=i(88528),h=i(10903),u=i(49288),g=i(6870),p=i(98161),m=i(3548),_=e([l,c,d,h,u,g,p,m]);[l,c,d,h,u,g,p,m]=_.then?(await _)():_;const f="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z",y="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z";class b extends o.WF{render(){const e=this.config.elementConfig&&"type"in this.config.elementConfig?this.config.elementConfig.type:"";return o.qy` <div class="header"> <div class="back-title"> <ha-icon-button-prev .label="${this.hass.localize("ui.common.back")}" ="${this._goBack}"></ha-icon-button-prev> <span slot="title"> ${"element"===this.config?.type?this.hass.localize("ui.panel.lovelace.editor.sub-element-editor.types.element_type",{type:this.hass.localize(`ui.panel.lovelace.editor.card.picture-elements.element_types.${e}`)||e}):this.hass.localize(`ui.panel.lovelace.editor.sub-element-editor.types.${this.config?.type}`)} </span> </div> <ha-icon-button class="gui-mode-button" ="${this._toggleMode}" .disabled="${!this._guiModeAvailable}" .label="${this.hass.localize(this._guiMode?"ui.panel.lovelace.editor.edit_card.show_code_editor":"ui.panel.lovelace.editor.edit_card.show_visual_editor")}" .path="${this._guiMode?f:y}"></ha-icon-button> </div> ${this._renderEditor()} `}_renderEditor(){const e=this.config.type;if(this.form)return o.qy` <hui-form-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .form="${this.form}" .context="${this.config.context}" -changed="${this._handleConfigChanged}"></hui-form-element-editor> `;switch(e){case"row":return o.qy` <hui-row-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}"></hui-row-element-editor> `;case"header":case"footer":return o.qy` <hui-headerfooter-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}"></hui-headerfooter-element-editor> `;case"element":return o.qy` <hui-picture-element-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}"></hui-picture-element-element-editor> `;case"feature":return o.qy` <hui-card-feature-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}"></hui-card-feature-element-editor> `;case"heading-badge":return o.qy` <hui-heading-badge-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}"></hui-heading-badge-element-editor> `;default:return o.s6}}_goBack(){(0,r.r)(this,"go-back")}_toggleMode(){this._editorElement?.toggleMode()}_handleGUIModeChanged(e){e.stopPropagation(),this._guiMode=e.detail.guiMode,this._guiModeAvailable=e.detail.guiModeAvailable}_handleConfigChanged(e){this._guiModeAvailable=e.detail.guiModeAvailable}constructor(...e){super(...e),this._guiModeAvailable=!0,this._guiMode=!0}}b.styles=o.AH`.header{display:flex;justify-content:space-between;align-items:center}.back-title{display:flex;align-items:center;font-size:var(--ha-font-size-l)}`,(0,s.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"config",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"form",void 0),(0,s.Cg)([(0,n.wk)()],b.prototype,"_guiModeAvailable",void 0),(0,s.Cg)([(0,n.wk)()],b.prototype,"_guiMode",void 0),(0,s.Cg)([(0,n.P)(".editor")],b.prototype,"_editorElement",void 0),b=(0,s.Cg)([(0,n.EM)("hui-sub-element-editor")],b),a()}catch(e){a(e)}})},63277(e,t,i){i.a(e,async function(e,a){try{i.d(t,{U:()=>l});var s=i(62826),o=i(22441),n=i(91322),r=e([n]);n=(r.then?(await r)():r)[0];class l extends n.m{get configElementType(){return this.value?this.value.type:void 0}async loadConfigElement(){if(this._configElementType!==this.configElementType){if(this.unloadConfigElement(),!this.configElementType)throw new Error(this.hass.localize("ui.errors.config.no_type_provided"));this._configElementType=this.configElementType}return super.loadConfigElement()}}(0,s.Cg)([(0,o.wk)()],l.prototype,"_configElementType",void 0),a()}catch(e){a(e)}})},3548(e,t,i){i.a(e,async function(e,t){try{var a=i(62826),s=i(22441),o=i(63277),n=i(82743),r=e([o,n]);[o,n]=r.then?(await r)():r;class l extends o.U{get configElementType(){return"action-button"===this.value?.type?"service-button":this.value?.type}async getConfigElement(){const e=await(0,n.j)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}}l=(0,a.Cg)([(0,s.EM)("hui-picture-element-element-editor")],l),t()}catch(e){t(e)}})},84698(e,t,i){i.d(t,{H:()=>s});var a=i(63533);const s=(0,a.Ik)({type:(0,a.Yj)(),view_layout:(0,a.bz)(),layout_options:(0,a.bz)(),grid_options:(0,a.bz)(),visibility:(0,a.bz)(),disabled:(0,a.lq)((0,a.zM)())})},20507(e,t,i){i.d(t,{l:()=>r,z:()=>l});var a=i(63533),s=i(9169),o=i(91408),n=i(44155);const r=(0,a.KC)([(0,a.Ik)({entity:(0,a.Yj)(),name:(0,a.lq)(n.q),icon:(0,a.lq)((0,a.Yj)()),image:(0,a.lq)((0,a.Yj)()),secondary_info:(0,a.lq)((0,a.Yj)()),format:(0,a.lq)((0,a.vP)(s.j)),state_color:(0,a.lq)((0,a.zM)()),tap_action:(0,a.lq)(o.kn),hold_action:(0,a.lq)(o.kn),double_tap_action:(0,a.lq)(o.kn),confirmation:(0,a.lq)(o.dk),show_last_changed:(0,a.lq)((0,a.zM)()),show_state:(0,a.lq)((0,a.zM)())}),(0,a.Yj)()]),l=(0,a.KC)([(0,a.Ik)({entity:(0,a.Yj)(),name:(0,a.lq)(n.q),color:(0,a.lq)((0,a.Yj)())}),(0,a.Yj)()])},6116(e,t,i){i.d(t,{o:()=>o});var a=i(6439),s=i(83339);function o(e,t,i){const o=(0,s.b)(e,t)/6e4;return(0,a.u)(i?.roundingMethod)(o)}},74985(e,t,i){i.d(t,{P:()=>r});i(88454),i(29452);var a=i(5055),s=i(42017),o=i(63937);const n=e=>(0,o.ps)(e)?e._$litType$.h:e.strings,r=(0,s.u$)(class extends s.WL{render(e){return[e]}update(e,[t]){const i=(0,o.qb)(this.it)?n(this.it):null,s=(0,o.qb)(t)?n(t):null;if(null!==i&&(null===s||i!==s)){const t=(0,o.cN)(e).pop();let s=this.et.get(i);if(void 0===s){const e=document.createDocumentFragment();s=(0,a.XX)(a.s6,e),s.setConnected(!1),this.et.set(i,s)}(0,o.mY)(s,[t]),(0,o.Dx)(s,void 0,t)}if(null!==s){if(null===i||i!==s){const t=this.et.get(s);if(void 0!==t){const i=(0,o.cN)(t).pop();(0,o.Jz)(e),(0,o.Dx)(e,void 0,i),(0,o.mY)(e,[i])}}this.it=t}else this.it=void 0;return this.render(t)}constructor(e){super(e),this.et=new WeakMap}})}};