iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
22 lines • 43.2 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[52016],{91069:function(t,e,i){i.a(t,async function(t,a){try{i.d(e,{EO:function(){return w},Yq:function(){return C},_U:function(){return x},eE:function(){return k},fU:function(){return $},ol:function(){return y},xo:function(){return b}});var n=i(78016),o=i(31810),r=i(87950),s=i(81977),c=i(36307),l=i(35932),d=i(73983),u=i(6946),h=i(92913),p=i(83339),f=i(77972),_=i(31886),g=i(46927),m=t([_]);_=(m.then?(await m)():m)[0];const v=(t,e,i,a)=>{const n=i(new _.BB(t,e),a);return n instanceof Date?new Date(n.getTime()):n},y=(t,e,i,a,n)=>i.time_zone===g.Wj.server?v(t,a.time_zone,e,n):e(t,n),b=(t,e,i,a,n)=>i.time_zone===g.Wj.server?v(t,a.time_zone,e,n):e(t,n),w=(t,e,i,a,n)=>b(t,i,a,n,a.time_zone===g.Wj.server?new _.BB(e,n.time_zone):e),k=(t,e,i,a,_)=>{let g,m;if(b(t,n.e,a,_)&&b(e,o.c,a,_)){const n=(w(e,t,r.W,a,_)+1)*(i?1:-1);g=y(t,s.P,a,_,n),m=y(y(e,s.P,a,_,n),c.p,a,_)}else if(b(t,t=>(0,l.o)(t).getMilliseconds()===t.getMilliseconds(),a,_)&&b(e,t=>(0,d.D)(t).getMilliseconds()===t.getMilliseconds(),a,_)){const n=(w(e,t,u.c,a,_)+1)*(i?1:-1);g=y(t,h.f,a,_,n),m=y(e,h.f,a,_,n)}else{const n=w(e,t,p.b,a,_)*(i?1:-1);g=y(t,f.A,a,_,n),m=y(e,f.A,a,_,n)}return{start:g,end:m}},x=(t,e)=>{const i=new _.BB(t,e);return new Date(i.getTime())},C=(t,e)=>new _.BB(t,e).toISOString().split("T")[0],$=(t,e)=>new _.BB(t,e).toISOString().split("T")[1].split(".")[0];a()}catch(v){a(v)}})},46223:function(t,e,i){i.a(t,async function(t,a){try{i.d(e,{b:function(){return w}});var n=i(35932),o=i(73983),r=i(92913),s=i(52640),c=i(69137),l=i(35660),d=i(36307),u=i(11650),h=i(15797),p=i(33977),f=i(69748),_=i(55144),g=i(21828),m=i(66708),v=i(91069),y=i(380),b=t([y,v]);[y,v]=b.then?(await b)():b;const w=(t,e,i)=>{const a=new Date,b=(0,y.P)(t);switch(i){case"today":return[(0,v.ol)(a,n.o,t,e,{weekStartsOn:b}),(0,v.ol)(a,o.D,t,e,{weekStartsOn:b})];case"yesterday":return[(0,v.ol)((0,r.f)(a,-1),n.o,t,e,{weekStartsOn:b}),(0,v.ol)((0,r.f)(a,-1),o.D,t,e,{weekStartsOn:b})];case"this_week":return[(0,v.ol)(a,s.k,t,e,{weekStartsOn:b}),(0,v.ol)(a,c.$,t,e,{weekStartsOn:b})];case"this_month":return[(0,v.ol)(a,l.w,t,e),(0,v.ol)(a,d.p,t,e)];case"this_quarter":return[(0,v.ol)(a,u.a,t,e),(0,v.ol)(a,h.j,t,e)];case"this_year":return[(0,v.ol)(a,p.D,t,e),(0,v.ol)(a,f.Q,t,e)];case"now-7d":return[(0,v.ol)(a,_.e,t,e,7),(0,v.ol)(a,_.e,t,e,0)];case"now-30d":return[(0,v.ol)(a,_.e,t,e,30),(0,v.ol)(a,_.e,t,e,0)];case"now-12m":return[(0,v.ol)(a,t=>(0,g.a)((0,l.w)(t),11),t,e),(0,v.ol)(a,d.p,t,e)];case"now-365d":return[(0,v.ol)(a,_.e,t,e,365),(0,v.ol)(a,_.e,t,e,0)];case"now-1h":return[(0,v.ol)(a,m.O,t,e,1),(0,v.ol)(a,m.O,t,e,0)];case"now-12h":return[(0,v.ol)(a,m.O,t,e,12),(0,v.ol)(a,m.O,t,e,0)];case"now-24h":return[(0,v.ol)(a,m.O,t,e,24),(0,v.ol)(a,m.O,t,e,0)]}return[a,a]};a()}catch(w){a(w)}})},80785:function(t,e,i){function a(t){return!!t&&(t instanceof Date&&!isNaN(t.valueOf()))}i.d(e,{A:function(){return a}})},82591:function(t,e,i){i.a(t,async function(t,a){try{i.d(e,{E2:function(){return p},Z8:function(){return f},a3:function(){return v},i:function(){return u},nR:function(){return l}});i(16280);var n=i(74487),o=i(22786),r=i(79791),s=t([n]);n=(s.then?(await s)():s)[0];const c=t=>t<10?`0${t}`:t,l=(t,e)=>{const i=e.days||0,a=e.hours||0,n=e.minutes||0,o=e.seconds||0,r=e.milliseconds||0;return i>0?`${Intl.NumberFormat(t.language,{style:"unit",unit:"day",unitDisplay:"long"}).format(i)} ${a}:${c(n)}:${c(o)}`:a>0?`${a}:${c(n)}:${c(o)}`:n>0?`${n}:${c(o)}`:o>0?Intl.NumberFormat(t.language,{style:"unit",unit:"second",unitDisplay:"long"}).format(o):r>0?Intl.NumberFormat(t.language,{style:"unit",unit:"millisecond",unitDisplay:"long"}).format(r):null},d=(0,o.A)(t=>new Intl.DurationFormat(t.language,{style:"long"})),u=(t,e)=>d(t).format(e),h=(0,o.A)(t=>new Intl.DurationFormat(t.language,{style:"digital",hoursDisplay:"auto"})),p=(t,e)=>h(t).format(e),f=["min","h","d"],_=(0,o.A)(t=>new Intl.DurationFormat(t.language,{style:"narrow",daysDisplay:"always"})),g=(0,o.A)(t=>new Intl.DurationFormat(t.language,{style:"narrow",hoursDisplay:"always"})),m=(0,o.A)(t=>new Intl.DurationFormat(t.language,{style:"narrow",minutesDisplay:"always"})),v=(t,e,i,a)=>{const n=void 0!==a?(0,r.L)(parseFloat(e),a):parseFloat(e);switch(i){case"d":{const e=Math.floor(n),i={days:e,hours:Math.floor(24*(n-e))};return _(t).format(i)}case"h":{const e=Math.floor(n),i={hours:e,minutes:Math.floor(60*(n-e))};return g(t).format(i)}case"min":{const e=Math.floor(n),i={minutes:e,seconds:Math.floor(60*(n-e))};return m(t).format(i)}default:throw new Error("Invalid duration unit")}};a()}catch(c){a(c)}})},53610:function(t,e,i){i.a(t,async function(t,a){try{i.d(e,{computeAttributeNameDisplay:function(){return y},computeAttributeValueDisplay:function(){return m},computeAttributeValueToParts:function(){return v}});i(44114),i(18111),i(61701),i(13579),i(33110),i(27495),i(25440);var n=i(88827),o=i(43248),r=i(80785),s=i(72487),c=i(95747),l=i(20058),d=i(52943),u=i(22682),h=i(6940),p=i(8549),f=i(71727),_=i(69093),g=t([l,n,c,s]);[l,n,c,s]=g.then?(await g)():g;const m=(t,e,i,a,n,o,r)=>v(t,e,i,a,n,o,r).map(t=>t.value).join(""),v=(t,e,i,a,d,g,v)=>{const y=void 0!==v?v:e.attributes[g];if(null==y)return[{type:"value",value:t("state.default.unknown")}];if("number"==typeof y){var b,w;const t=(0,_.t)(e),r=null===(b=n.Tf[t])||void 0===b?void 0:b[g],s=r?r(y,i):(0,l.ZV)(y,i);let c=null===(w=n.rM[t])||void 0===w?void 0:w[g];"weather"===t?c=(0,o.d9)(a,e,g):n.Zn.has(g)&&(c=a.unit_system.temperature);const d=[{type:"value",value:s}];if(c){const t=(0,p.A)(c,i);t&&d.push({type:"literal",value:t}),d.push({type:"unit",value:c})}return d}if("string"==typeof y&&(0,u.$)(y,!0)){if((0,h.F)(y)){const t=new Date(y);if((0,r.A)(t)){return[{type:"value",value:(0,c.yg)(t,i,a)}]}}const t=new Date(y);if((0,r.A)(t))return[{type:"value",value:(0,s.Yq)(t,i,a)}]}if(Array.isArray(y)&&y.some(t=>t instanceof Object)||!Array.isArray(y)&&y instanceof Object)return[{type:"value",value:JSON.stringify(y)}];if(Array.isArray(y)){return[{type:"value",value:y.map(n=>m(t,e,i,a,d,g,n)).join(", ")}]}const k=e.entity_id,x=(0,f.m)(k),C=e.attributes.device_class,$=d[k],D=null==$?void 0:$.translation_key;return[{type:"value",value:D&&t(`component.${$.platform}.entity.${x}.${D}.state_attributes.${g}.state.${y}`)||C&&t(`component.${x}.entity_component.${C}.state_attributes.${g}.state.${y}`)||t(`component.${x}.entity_component._.state_attributes.${g}.state.${y}`)||y}]},y=(t,e,i,a)=>{const n=e.entity_id,o=e.attributes.device_class,r=(0,f.m)(n),s=i[n],c=null==s?void 0:s.translation_key;return c&&t(`component.${s.platform}.entity.${r}.${c}.state_attributes.${a}.name`)||o&&t(`component.${r}.entity_component.${o}.state_attributes.${a}.name`)||t(`component.${r}.entity_component._.state_attributes.${a}.name`)||(0,d.Z)(a.replace(/_/g," ").replace(/\bid\b/g,"ID").replace(/\bip\b/g,"IP").replace(/\bmac\b/g,"MAC").replace(/\bgps\b/g,"GPS"))};a()}catch(m){a(m)}})},15090:function(t,e,i){i.d(e,{nP:function(){return l},vB:function(){return s}});i(44114),i(26910),i(18111),i(22489),i(61701),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953);var a=i(22675),n=i(52220),o=i(71727),r=i(69093);const s={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"]},c={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"]}},l=(t,e,i=void 0)=>{const l=(0,r.t)(e),d=[];switch(d.push(...((t,e,i)=>{const r=[];switch(i||r.push(a.Hh,a.HV),!i&&e in s?r.push(...s[e]):i&&e in c&&i in c[e]&&r.push(...c[e][i]),e){case"device_tracker":case"person":i||r.push(...Object.entries(t.states).filter(([t,e])=>"zone"===(0,o.m)(t)&&"zone.home"!==t&&e.attributes.friendly_name).map(([t,e])=>e.attributes.friendly_name).sort((e,i)=>(0,n.xL)(e,i,t.locale.language)))}return r})(t,l,i)),l){case"climate":i?"fan_mode"===i?d.push(...e.attributes.fan_modes):"preset_mode"===i?d.push(...e.attributes.preset_modes):"swing_mode"===i?d.push(...e.attributes.swing_modes):"swing_horizontal_mode"===i&&d.push(...e.attributes.swing_horizontal_modes):d.push(...e.attributes.hvac_modes);break;case"event":"event_type"===i&&d.push(...e.attributes.event_types);break;case"fan":"preset_mode"===i&&d.push(...e.attributes.preset_modes);break;case"humidifier":"mode"===i&&d.push(...e.attributes.available_modes);break;case"input_select":case"select":i||d.push(...e.attributes.options);break;case"light":"effect"===i&&e.attributes.effect_list?d.push(...e.attributes.effect_list):"color_mode"===i&&e.attributes.supported_color_modes&&d.push(...e.attributes.supported_color_modes);break;case"media_player":"sound_mode"===i?d.push(...e.attributes.sound_mode_list):"source"===i&&d.push(...e.attributes.source_list);break;case"remote":"current_activity"===i&&d.push(...e.attributes.activity_list);break;case"sensor":i||"enum"!==e.attributes.device_class||d.push(...e.attributes.options);break;case"vacuum":"fan_speed"===i&&d.push(...e.attributes.fan_speed_list);break;case"water_heater":i&&"operation_mode"!==i||d.push(...e.attributes.operation_list)}return[...new Set(d)]}},79791:function(t,e,i){i.d(e,{L:function(){return a}});const a=(t,e=2)=>Math.round(t*10**e)/10**e},67258:function(t,e,i){i.d(e,{d:function(){return a}});const a=t=>{switch(t.language){case"cs":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},8549:function(t,e,i){i.d(e,{A:function(){return n}});var a=i(67258);const n=(t,e)=>"°"===t?"":e&&"%"===t?(0,a.d)(e):" "},51758:function(t,e,i){i.d(e,{Z:function(){return a}});const a=t=>{const e=window.location.pathname;return t?e+"?"+t:e}},77796:function(t,e,i){i.d(e,{n:function(){return a}});i(62953);const a=(t,e,i=!0,a=!0)=>{let n,o=0;const r=(...r)=>{const s=()=>{o=!1===i?0:Date.now(),n=void 0,t(...r)},c=Date.now();o||!1!==i||(o=c);const l=e-(c-o);l<=0||l>e?(n&&(clearTimeout(n),n=void 0),o=c,t(...r)):n||!1===a||(n=window.setTimeout(s,l))};return r.cancel=()=>{clearTimeout(n),n=void 0,o=0},r}},34218:function(t,e,i){i.d(e,{P:function(){return a}});i(44114),i(72712),i(18111),i(18237),i(45367),i(92731),i(62953);function a(t,e,i,a,o=!1){if(!t)return[];if(t.length<=e)return t;const r=null!=i?i:n(t[0])[0],s=null!=a?a:n(t[t.length-1])[0],c=Math.ceil((s-r)/Math.floor(e)),l=new Map;for(const u of t){const t=n(u);if(!Array.isArray(t))continue;const e=Number(t[0]),i=Number(t[1]);if(isNaN(e)||isNaN(i))continue;const a=Math.floor((e-r)/c),o=l.get(a);o?o.push({point:u,x:e,y:i}):l.set(a,[{point:u,x:e,y:i}])}const d=[];if(o)for(const[u,h]of l){const t=h.reduce((t,e)=>t+e.y,0)/h.length,e=h.reduce((t,e)=>t+e.x,0)/h.length,i=n(h[0].point),a=Array.isArray(i)?[e,t]:{value:[e,t]};d.push(a)}else for(const[n,u]of l){let t=u[0],e=u[0];for(const i of u)i.y<t.y&&(t=i),i.y>e.y&&(e=i);t.x>e.x&&d.push(e.point),d.push(t.point),t.x<e.x&&d.push(e.point)}return d}function n(t){return t&&"object"==typeof t&&"value"in t?t.value:t}},72190:function(t,e,i){i.d(e,{c:function(){return g}});i(74423),i(45367),i(92731),i(62953);var a=i(90433),n=i(79468),o=i(39274),r=i(71727),s=i(69093),c=i(15090),l=i(52658),d=i(80880),u=i(22675),h=i(86030);const p={media_player:{paused:.5,idle:1},vacuum:{returning:.5}};let f=0;const _=new Map;function g(t,e,i){return function(t,e,i){var a;if(!i||t===u.Hh)return(0,h.a)("--history-unavailable-color",e);if(t===u.HV)return(0,h.a)("--history-unknown-color",e);const s=(0,r.m)(i.entity_id);if(("person"===s||"device_tracker"===s)&&!(c.vB[s]||[]).includes(t))return(0,h.a)(`--state-${s}-${(0,d.Y)(t,"_")}-color`,e);const f=(0,l.mg)(i,t);if(!f)return;const _=(0,h.a)(f,e);if(!_)return;const g=null===(a=p[s])||void 0===a?void 0:a[t];return g?(0,n.zm)((0,o.T)((0,n.Nc)((0,n.xp)(_)),g)):_}(t,e,i)||function(t,e,i){if(!i)return;const n=(0,s.t)(i),o=(c.vB[n]||"sensor"===n&&"enum"===i.attributes.device_class&&i.attributes.options||[]).indexOf(t);return-1!==o?(0,a.fI)(o,e):void 0}(t,e,i)||function(t,e){if(_.has(t))return _.get(t);const i=(0,a.fI)(f,e);return f++,_.set(t,i),i}(t,e)}},59174:function(t,e,i){i.a(t,async function(t,e){try{var a=i(40445),n=i(35211),o=i(5124),r=i(67576),s=i(91450),c=i(22792),l=i(85694),d=i(44144),u=(i(47680),t([l]));l=(u.then?(await u)():u)[0];let h,p,f,_,g,m,v,y=t=>t;class b extends o.WF{render(){if(this.icon)return(0,o.qy)(h||(h=y`<ha-icon .icon="${0}"></ha-icon>`),this.icon);if(!this.domain)return o.s6;if(!this._connection||!this._hassConfig)return this._renderFallback();const t=(0,l._4)(this._connection.connection,this._hassConfig.config,this.domain,this.deviceClass,this.state).then(t=>t?(0,o.qy)(p||(p=y`<ha-icon .icon="${0}"></ha-icon>`),t):this._renderFallback());return(0,o.qy)(f||(f=y`${0}`),(0,s.T)(t))}_renderFallback(){if(this.domain&&this.domain in l.l)return(0,o.qy)(_||(_=y` <ha-svg-icon .path="${0}"></ha-svg-icon> `),l.l[this.domain]);if(this.brandFallback){var t,e;const i=(0,d.MR)({domain:this.domain,type:"icon",darkOptimized:null===(t=this._hassUi)||void 0===t?void 0:t.themes.darkMode},null===(e=this._hassConfig)||void 0===e?void 0:e.auth.data.hassUrl);return(0,o.qy)(g||(g=y` <img alt="" src="${0}" crossorigin="anonymous" referrerpolicy="no-referrer"> `),i)}return(0,o.qy)(m||(m=y`<ha-svg-icon .path="${0}"></ha-svg-icon>`),l.lW)}}b.styles=(0,o.AH)(v||(v=y`img{width:var(--mdc-icon-size,24px)}`)),(0,a.Cg)([(0,r.MZ)()],b.prototype,"domain",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],b.prototype,"deviceClass",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],b.prototype,"state",void 0),(0,a.Cg)([(0,r.MZ)()],b.prototype,"icon",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"brand-fallback",type:Boolean})],b.prototype,"brandFallback",void 0),(0,a.Cg)([(0,r.wk)(),(0,n.Fg)({context:c.WF,subscribe:!0})],b.prototype,"_hassConfig",void 0),(0,a.Cg)([(0,r.wk)(),(0,n.Fg)({context:c.Wq,subscribe:!0})],b.prototype,"_connection",void 0),(0,a.Cg)([(0,r.wk)(),(0,n.Fg)({context:c.EK,subscribe:!0})],b.prototype,"_hassUi",void 0),b=(0,a.Cg)([(0,r.EM)("ha-domain-icon")],b),e()}catch(h){e(h)}})},11382:function(t,e,i){i(3362),i(62953);var a=i(40445),n=i(5124),o=i(67576),r=i(6412),s=i(1087),c=i(12587);i(67094);let l,d,u,h,p=t=>t;class f extends n.WF{render(){const t=this.noCollapse?n.s6:(0,n.qy)(l||(l=p` <ha-svg-icon .path="${0}" class="summary-icon ${0}"></ha-svg-icon> `),"M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",(0,r.H)({expanded:this.expanded}));return(0,n.qy)(d||(d=p` <div class="top ${0}"> <div id="summary" class="${0}" ="${0}" ="${0}" ="${0}" ="${0}" role="button" tabindex="${0}" aria-expanded="${0}" aria-controls="sect1" part="summary"> ${0} <slot name="leading-icon"></slot> <slot name="header"> <div class="header"> ${0} <slot class="secondary" name="secondary">${0}</slot> </div> </slot> <slot name="event"></slot> ${0} <slot name="icons"></slot> </div> </div> <div class="container ${0}" ="${0}" role="region" aria-labelledby="summary" aria-hidden="${0}" tabindex="-1"> ${0} </div> `),(0,r.H)({expanded:this.expanded}),(0,r.H)({noCollapse:this.noCollapse}),this._toggleContainer,this._toggleContainer,this._focusChanged,this._focusChanged,this.noCollapse?-1:0,this.expanded,this.leftChevron?t:n.s6,this.header,this.secondary,this.leftChevron?n.s6:t,(0,r.H)({expanded:this.expanded}),this._handleTransitionEnd,!this.expanded,this._showContent?(0,n.qy)(u||(u=p`<slot></slot>`)):"")}willUpdate(t){super.willUpdate(t),t.has("expanded")&&(this._showContent=this.expanded,setTimeout(()=>{this._container.style.overflow=this.expanded?"initial":"hidden"},300))}_handleTransitionEnd(){this._container.style.removeProperty("height"),this._container.style.overflow=this.expanded?"initial":"hidden",this._showContent=this.expanded}async _toggleContainer(t){if(t.defaultPrevented)return;if("keydown"===t.type&&"Enter"!==t.key&&" "!==t.key)return;if(t.preventDefault(),this.noCollapse)return;const e=!this.expanded;(0,s.r)(this,"expanded-will-change",{expanded:e}),this._container.style.overflow="hidden",e&&(this._showContent=!0,await(0,c.E)());const i=this._container.scrollHeight;this._container.style.height=`${i}px`,e||setTimeout(()=>{this._container.style.height="0px"},0),this.expanded=e,(0,s.r)(this,"expanded-changed",{expanded:this.expanded})}_focusChanged(t){this.noCollapse||this.shadowRoot.querySelector(".top").classList.toggle("focused","focus"===t.type)}constructor(...t){super(...t),this.expanded=!1,this.outlined=!1,this.leftChevron=!1,this.noCollapse=!1,this._showContent=this.expanded}}f.styles=(0,n.AH)(h||(h=p`:host{display:block}.top{display:flex;align-items:center;border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg))}.top.expanded{border-bottom-left-radius:0px;border-bottom-right-radius:0px}.top.focused{background:var(--input-fill-color)}:host([outlined]){box-shadow:none;border-width:1px;border-style:solid;border-color:var(--outline-color);border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg))}.summary-icon{transition:transform 150ms cubic-bezier(.4, 0, .2, 1);direction:var(--direction);margin-left:8px;margin-inline-start:8px;margin-inline-end:initial;border-radius:var(--ha-border-radius-circle)}#summary:focus-visible ha-svg-icon.summary-icon{background-color:var(--ha-color-fill-neutral-normal-active)}::slotted([slot=leading-icon]),:host([left-chevron]) .summary-icon{margin-left:0;margin-right:8px;margin-inline-start:0;margin-inline-end:8px}#summary{flex:1;display:flex;padding:var(--expansion-panel-summary-padding,0 8px);min-height:48px;align-items:center;cursor:pointer;overflow:hidden;font-weight:var(--ha-font-weight-medium);outline:0}#summary.noCollapse{cursor:default}.summary-icon.expanded{transform:rotate(180deg)}.header,::slotted([slot=header]){flex:1;overflow-wrap:anywhere;color:var(--primary-text-color)}.container{padding:var(--expansion-panel-content-padding,0 8px);overflow:hidden;transition:height .3s cubic-bezier(.4, 0, .2, 1);height:0px}.container.expanded{height:auto}.secondary{display:block;color:var(--secondary-text-color);font-size:var(--ha-font-size-s)}`)),(0,a.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],f.prototype,"expanded",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],f.prototype,"outlined",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"left-chevron",type:Boolean,reflect:!0})],f.prototype,"leftChevron",void 0),(0,a.Cg)([(0,o.MZ)({attribute:"no-collapse",type:Boolean,reflect:!0})],f.prototype,"noCollapse",void 0),(0,a.Cg)([(0,o.MZ)()],f.prototype,"header",void 0),(0,a.Cg)([(0,o.MZ)()],f.prototype,"secondary",void 0),(0,a.Cg)([(0,o.wk)()],f.prototype,"_showContent",void 0),(0,a.Cg)([(0,o.P)(".container")],f.prototype,"_container",void 0),f=(0,a.Cg)([(0,o.EM)("ha-expansion-panel")],f)},34127:function(t,e,i){i.a(t,async function(t,e){try{i(62953);var a=i(40445),n=i(52630),o=i(5124),r=i(67576),s=t([n]);n=(s.then?(await s)():s)[0];let c,l=t=>t;class d extends n.A{static get styles(){return[n.A.styles,(0,o.AH)(c||(c=l`:host{--wa-tooltip-background-color:var(
--ha-tooltip-background-color,
var(--ha-color-surface-default)
);--wa-tooltip-content-color:var(
--ha-tooltip-text-color,
var(--primary-text-color)
);--wa-tooltip-font-family:var(
--ha-tooltip-font-family,
var(--ha-font-family-body)
);--wa-tooltip-font-size:var(
--ha-tooltip-font-size,
var(--ha-font-size-m)
);--wa-tooltip-font-weight:var(
--ha-tooltip-font-weight,
var(--ha-font-weight-medium)
);--wa-tooltip-line-height:var(
--ha-tooltip-line-height,
var(--ha-line-height-condensed)
);--wa-tooltip-padding:var(--ha-tooltip-padding, var(--ha-space-2));--wa-tooltip-border-radius:var(
--ha-tooltip-border-radius,
var(--ha-border-radius-md)
);--wa-tooltip-arrow-size:var(--ha-tooltip-arrow-size, 0px);--wa-tooltip-border-width:0px;--wa-z-index-tooltip:1000}.tooltip::part(popup){animation-duration:var(--ha-tooltip-animation-duration, 0)}.body{box-shadow:var(--ha-tooltip-box-shadow,var(--ha-box-shadow-m))}`))]}constructor(...t){super(...t),this.showDelay=350,this.hideDelay=150}}(0,a.Cg)([(0,r.MZ)({attribute:"show-delay",type:Number})],d.prototype,"showDelay",void 0),(0,a.Cg)([(0,r.MZ)({attribute:"hide-delay",type:Number})],d.prototype,"hideDelay",void 0),d=(0,a.Cg)([(0,r.EM)("ha-tooltip")],d),e()}catch(c){e(c)}})},95311:function(t,e,i){i.d(e,{DF:function(){return g},Lo:function(){return k},MH:function(){return h},MM:function(){return m},Qz:function(){return _},Ru:function(){return y},UU:function(){return b},_7:function(){return f},bZ:function(){return p},m0:function(){return u},tD:function(){return w},vX:function(){return v},wY:function(){return x}});var a=i(86518),n=(i(78350),i(74423),i(44114),i(30237),i(18111),i(22489),i(30531),i(7588),i(13579),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953),i(44537)),o=i(69093),r=i(82286),s=i(24367),c=i(58594);const l=["domain","integration","device_class"],d=["integration","manufacturer","model"],u=(t,e,i,a,n,o,r)=>{const s=[],c=[],l=[];return Object.values(i).forEach(i=>{i.labels.includes(e)&&_(t,n,a,i.area_id,o,r)&&l.push(i.area_id)}),Object.values(a).forEach(i=>{i.labels.includes(e)&&g(t.states,Object.values(n),i,o,r)&&c.push(i.id)}),Object.values(n).forEach(i=>{i.labels.includes(e)&&m(t.states[i.entity_id],o,r)&&s.push(i.entity_id)}),{areas:l,devices:c,entities:s}},h=(t,e,i,a,n)=>{const o=[];return Object.values(i).forEach(i=>{i.floor_id===e&&_(t,t.entities,t.devices,i.area_id,a,n)&&o.push(i.area_id)}),{areas:o}},p=(t,e,i,a,n,o)=>{const r=[],s=[];return Object.values(i).forEach(i=>{i.area_id===e&&g(t.states,Object.values(a),i,n,o)&&s.push(i.id)}),Object.values(a).forEach(i=>{i.area_id===e&&m(t.states[i.entity_id],n,o)&&r.push(i.entity_id)}),{devices:s,entities:r}},f=(t,e,i,a,n)=>{const o=[];return Object.values(i).forEach(i=>{i.device_id===e&&m(t.states[i.entity_id],a,n)&&o.push(i.entity_id)}),{entities:o}},_=(t,e,i,a,n,o)=>!!Object.values(i).some(i=>!(i.area_id!==a||!g(t.states,Object.values(e),i,n,o)))||Object.values(e).some(e=>!(e.area_id!==a||!m(t.states[e.entity_id],n,o))),g=(t,e,i,a,o)=>{var r,s;const l=o?(0,c.fk)(o,e):void 0;if(null!==(r=a.target)&&void 0!==r&&r.device&&!(0,n.e)(a.target.device).some(t=>v(t,i,l)))return!1;if(null!==(s=a.target)&&void 0!==s&&s.entity){return e.filter(t=>t.device_id===i.id).some(e=>{const i=t[e.entity_id];return m(i,a,o)})}return!0},m=(t,e,i)=>{var a;return!!t&&(null===(a=e.target)||void 0===a||!a.entity||(0,n.e)(e.target.entity).some(e=>y(e,t,i)))},v=(t,e,i)=>{const{manufacturer:a,model:n,model_id:o,integration:r}=t;if(a&&e.manufacturer!==a)return!1;if(n&&e.model!==n)return!1;if(o&&e.model_id!==o)return!1;var s;if(r&&i&&(null==i||null===(s=i[e.id])||void 0===s||!s.has(r)))return!1;return!0},y=(t,e,i)=>{var a;const{domain:s,device_class:c,supported_features:l,unit_of_measurement:d,integration:u}=t;if(s){const t=(0,o.t)(e);if(Array.isArray(s)?!s.includes(t):t!==s)return!1}if(c){const t=e.attributes.device_class;if(t&&Array.isArray(c)?!c.includes(t):t!==c)return!1}if(l&&!(0,n.e)(l).some(t=>(0,r.$)(e,t)))return!1;if(d){const t=e.attributes.unit_of_measurement;if(!t||(Array.isArray(d)?!d.includes(t):t!==d))return!1}return!u||(null==i||null===(a=i[e.entity_id])||void 0===a?void 0:a.domain)===u},b=t=>{if(!t.entity)return{entity:null};if("filter"in t.entity)return t;const e=t.entity,{domain:i,integration:n,device_class:o}=e,r=(0,a.A)(e,l);return i||n||o?{entity:Object.assign(Object.assign({},r),{},{filter:{domain:i,integration:n,device_class:o}})}:{entity:r}},w=t=>{if(!t.device)return{device:null};if("filter"in t.device)return t;const e=t.device,{integration:i,manufacturer:n,model:o}=e,r=(0,a.A)(e,d);return i||n||o?{device:Object.assign(Object.assign({},r),{},{filter:{integration:i,manufacturer:n,model:o}})}:{device:r}},k=t=>{let e;var i;if("target"in t)e=(0,n.e)(null===(i=t.target)||void 0===i?void 0:i.entity);else if("entity"in t){var a,o;if(null!==(a=t.entity)&&void 0!==a&&a.include_entities)return;e=(0,n.e)(null===(o=t.entity)||void 0===o?void 0:o.filter)}if(!e)return;const r=e.flatMap(t=>t.integration||t.device_class||t.supported_features||!t.domain?[]:(0,n.e)(t.domain).filter(t=>(0,s.z)(t)));return[...new Set(r)]},x=(t,e,i,a,o,r={target:{}})=>{if(!e)return[];const s=new Set((0,n.e)(e.entity_id)),c=new Set((0,n.e)(e.device_id)),l=new Set((0,n.e)(e.area_id)),d=new Set((0,n.e)(e.floor_id));return new Set((0,n.e)(e.label_id)).forEach(e=>{const n=u(t,e,o,a,i,r);n.devices.forEach(t=>c.add(t)),n.entities.forEach(t=>s.add(t)),n.areas.forEach(t=>l.add(t))}),d.forEach(e=>{h(t,e,o,r).areas.forEach(t=>l.add(t))}),l.forEach(e=>{const n=p(t,e,a,i,r);n.devices.forEach(t=>c.add(t)),n.entities.forEach(t=>s.add(t))}),c.forEach(e=>{f(t,e,i,r).entities.forEach(t=>s.add(t))}),Array.from(s)}},42269:function(t,e,i){i.d(e,{p:function(){return n}});var a=i(1087);const n=(t,e)=>(0,a.r)(t,"hass-more-info",e)},24367:function(t,e,i){i.d(e,{L:function(){return n},z:function(){return o}});var a=i(23832);const n=["input_boolean","input_button","input_text","input_number","input_datetime","input_select","counter","timer","schedule"],o=(0,a.g)(n)},49131:function(t,e,i){i.a(t,async function(t,a){try{i.r(e);i(44114),i(26910),i(3362),i(27495),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(25440),i(79978),i(62953),i(3296),i(27208),i(48408),i(14603),i(47566),i(98721);var n=i(40445),o=i(44018),r=i(5124),s=i(67576),c=i(22786),l=i(44537),d=i(93905),u=i(71727),h=i(91926),p=i(51758),f=i(6030),_=i(44439),g=i(66737),m=i(58987),v=i(29823),y=(i(70947),i(26300)),b=i(90248),w=i(2054),k=i(65829),x=i(79286),C=(i(27330),i(25064)),$=i(23528),D=i(95311),H=i(64808),A=i(65063),M=i(14503),L=i(30039),z=i(12496),O=t([_,g,m,v,y,b,w,k,x,$,C]);[_,g,m,v,y,b,w,k,x,$,C]=O.then?(await O)():O;let P,E,V,j,S,I,Z,q,B=t=>t;const F="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",T="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",U="M14.76,20.83L17.6,18L14.76,15.17L16.17,13.76L19,16.57L21.83,13.76L23.24,15.17L20.43,18L23.24,20.83L21.83,22.24L19,19.4L16.17,22.24L14.76,20.83M12,12V19.88C12.04,20.18 11.94,20.5 11.71,20.71C11.32,21.1 10.69,21.1 10.3,20.71L8.29,18.7C8.06,18.47 7.96,18.16 8,17.87V12H7.97L2.21,4.62C1.87,4.19 1.95,3.56 2.38,3.22C2.57,3.08 2.78,3 3,3V3H17V3C17.22,3 17.43,3.08 17.62,3.22C18.05,3.56 18.13,4.19 17.79,4.62L12.03,12H12Z",R="M18 15V18H15V20H18V23H20V20H23V18H20V15H18M13.3 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5V13.3C20.4 13.1 19.7 13 19 13C17.9 13 16.8 13.3 15.9 13.9L14.5 12L11 16.5L8.5 13.5L5 18H13.1C13 18.3 13 18.7 13 19C13 19.7 13.1 20.4 13.3 21Z";class N extends r.WF{connectedCallback(){super.connectedCallback(),this.hasUpdated&&this._getHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory()}_goBack(){(0,h.OE)()}render(){const t=this._getEntityIds().length>0;return(0,r.qy)(P||(P=B` <ha-top-app-bar-fixed .narrow="${0}"> ${0} <h1 class="page-title" slot="title"> ${0} </h1> ${0} <ha-dropdown slot="actionItems" -select="${0}"> <ha-icon-button slot="trigger" .label="${0}" .path="${0}"></ha-icon-button> <ha-dropdown-item value="download" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item value="add-card" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="flex content ha-scrollbar"> <div class="filters"> <ha-date-range-picker ?disabled="${0}" .startDate="${0}" .endDate="${0}" extended-presets time-picker -changed="${0}"></ha-date-range-picker> <ha-target-picker .hass="${0}" .value="${0}" .disabled="${0}" add-on-top -changed="${0}" compact="compact"></ha-target-picker> </div> ${0} </div> </ha-top-app-bar-fixed> `),this.narrow,this._showBack?(0,r.qy)(E||(E=B` <ha-icon-button-arrow-prev slot="navigationIcon" ="${0}"></ha-icon-button-arrow-prev> `),this._goBack):(0,r.qy)(V||(V=B` <ha-menu-button slot="navigationIcon" .hass="${0}" .narrow="${0}"></ha-menu-button> `),this.hass,this.narrow),this.hass.localize("panel.history"),t?(0,r.qy)(j||(j=B` <ha-icon-button slot="actionItems" ="${0}" .disabled="${0}" .path="${0}" .label="${0}"></ha-icon-button> `),this._removeAll,this._isLoading,U,this.hass.localize("ui.panel.history.remove_all")):"",this._handleMenuAction,this.hass.localize("ui.common.menu"),F,this._isLoading,this.hass.localize("ui.panel.history.download_data"),T,this._isLoading,this.hass.localize("ui.panel.history.add_card"),R,this._isLoading,this._startDate,this._endDate,this._dateRangeChanged,this.hass,this._targetPickerValue,this._isLoading,this._targetsChanged,this._isLoading?(0,r.qy)(S||(S=B`<div class="progress-wrapper"> <ha-spinner></ha-spinner> </div>`)):t?(0,r.qy)(Z||(Z=B` <state-history-charts .hass="${0}" .historyData="${0}" .startTime="${0}" .endTime="${0}" .narrow="${0}" sync-charts> </state-history-charts> `),this.hass,this._mungedStateHistory,this._startDate,this._endDate,this.narrow):(0,r.qy)(I||(I=B`<div class="start-search"> ${0} </div>`),this.hass.localize("ui.panel.history.start_search")))}willUpdate(t){if(super.willUpdate(t),(t.has("_stateHistory")||t.has("_statisticsHistory")||t.has("_startDate")||t.has("_endDate")||t.has("_targetPickerValue"))&&(this._statisticsHistory&&this._stateHistory?this._mungedStateHistory=(0,C.tG)(this._stateHistory,this._statisticsHistory):this._mungedStateHistory=this._stateHistory||this._statisticsHistory),this.hasUpdated)return;const e=(0,f.px)(),i=e.entity_id,a=e.device_id,n=e.area_id,o=e.floor_id,r=e.label_id;if((i||a||n||o||r)&&(this._targetPickerValue={}),i){const t=i.split(",");this._targetPickerValue.entity_id=t}if(a){const t=a.split(",");this._targetPickerValue.device_id=t}if(n){const t=n.split(",");this._targetPickerValue.area_id=t}if(o){const t=o.split(",");this._targetPickerValue.floor_id=t}if(r){const t=r.split(",");this._targetPickerValue.label_id=t}const s=e.start_date;s&&(this._startDate=new Date(s));const c=e.end_date;c&&(this._endDate=new Date(c))}firstUpdated(t){super.firstUpdated(t);"1"===(0,f.px)().back&&history.length>1&&(this._showBack=!0,(0,h.oo)((0,p.Z)((0,f.s8)("back")),{replace:!0}))}updated(t){(t.has("_startDate")||t.has("_endDate")||t.has("_targetPickerValue")||!this._stateHistory&&(t.has("_deviceEntityLookup")||t.has("_areaEntityLookup")||t.has("_areaDeviceLookup")))&&(this._getHistory(),this._getStats())}_removeAll(){this._targetPickerValue={},this._updatePath()}async _getStats(){const t=this._getEntityIds();if(0===t.length)return void(this._statisticsHistory=void 0);const e=new Date(this._startDate);let i,a;e.setHours(e.getHours()-1);try{i=await(0,$.sz)(this.hass,e,this._endDate,t,"hour",void 0,["mean","state"])}catch(n){return}try{({numeric_device_classes:a}=await(0,H.KL)(this.hass))}catch(n){return}this._statisticsHistory=(0,C._1)(this.hass,i,t,a,!0)}async _getHistory(){const t=this._getEntityIds();if(0===t.length)return void(this._stateHistory=void 0);this._isLoading=!0,this._subscribed&&this._unsubscribeHistory();const e=new Date,i=Promise.resolve(void 0);let a;this._subscribed=i;try{({numeric_device_classes:a}=await(0,H.KL)(this.hass))}catch(n){return void(this._subscribed===i&&(this._subscribed=void 0,this._isLoading=!1))}this._subscribed===i&&(this._subscribed=(0,C.Jo)(this.hass,e=>{this._isLoading=!1,this._stateHistory=(0,C.Mm)(this.hass,e,t,this.hass.localize,a,!0)},this._startDate,this._endDate,t),this._subscribed.catch(()=>{this._isLoading=!1,this._unsubscribeHistory()}),this._endDate>e&&this._setRedrawTimer())}_setRedrawTimer(){clearInterval(this._interval);const t=new Date,e=this._endDate>t?t:this._endDate,i=(0,o.M)(e,this._startDate);this._interval=window.setInterval(()=>{var t;return null===(t=this._stateHistoryCharts)||void 0===t?void 0:t.requestUpdate()},i<2?1e4:i<10?6e4:3e5)}_unsubscribeHistory(){this._interval&&(clearInterval(this._interval),this._interval=void 0),this._subscribed&&(this._subscribed.then(t=>null==t?void 0:t()).catch(()=>{}),this._subscribed=void 0)}_getEntityIds(){return this.__getEntityIds(this._targetPickerValue,this.hass.entities,this.hass.devices,this.hass.areas)}_dateRangeChanged(t){this._startDate=t.detail.value.startDate,this._endDate=t.detail.value.endDate,this._updatePath()}_targetsChanged(t){this._targetPickerValue=t.detail.value||{},this._updatePath()}_updatePath(){const t={};this._targetPickerValue.entity_id&&(t.entity_id=(0,l.e)(this._targetPickerValue.entity_id).join(",")),this._targetPickerValue.label_id&&(t.label_id=(0,l.e)(this._targetPickerValue.label_id).join(",")),this._targetPickerValue.floor_id&&(t.floor_id=(0,l.e)(this._targetPickerValue.floor_id).join(",")),this._targetPickerValue.area_id&&(t.area_id=(0,l.e)(this._targetPickerValue.area_id).join(",")),this._targetPickerValue.device_id&&(t.device_id=(0,l.e)(this._targetPickerValue.device_id).join(",")),this._startDate&&(t.start_date=this._startDate.toISOString()),this._endDate&&(t.end_date=this._endDate.toISOString()),(0,h.oo)(`/history?${(0,f.KH)(t)}`,{replace:!0})}async _handleMenuAction(t){switch(t.detail.item.value){case"download":this._downloadHistory();break;case"add-card":this._suggestCard()}}_downloadHistory(){if(0===[...this._getEntityIds()].sort().length||!this._mungedStateHistory)return void(0,A.showAlertDialog)(this,{title:this.hass.localize("ui.panel.history.download_data_error"),text:this.hass.localize("ui.panel.history.error_no_data"),warning:!0});const t=[""],e=["entity_id","state","last_changed"],i=new Set,a={climate:{current_temperature:0,hvac_action:0,target_temp_high:0,target_temp_low:0,temperature:0},humidifier:{action:0,current_humidity:0,humidity:0},water_heater:{current_temperature:0,operation_mode:0,temperature:0}},n=t=>new Date(t).toISOString();for(const s of this._mungedStateHistory.line)for(const o of s.data){const r=o.entity_id,s=(0,u.m)(r),c=a[s];if(c&&!i.has(s)){i.add(s);let t=e.length;for(const i of Object.keys(c))e.push(i),c[i]=t,t+=1}if(o.statistics)for(const e of o.statistics)t.push(`${r},${e.state},${n(e.last_changed)}\n`);for(const e of o.states){const i=n(e.last_changed),a=[r,e.state,i];if(e.attributes&&c){const t=e.attributes;for(const[e,i]of Object.entries(c))e in t&&(a[i]=t[e])}t.push(a.join(",")+"\n")}}for(const s of this._mungedStateHistory.timeline){const e=s.entity_id;for(const i of s.data){const a=/,|"/.test(i.state)?`"${i.state.replaceAll('"','""')}"`:i.state;t.push(`${e},${a},${n(i.last_changed)}\n`)}}t[0]=e.join(",")+"\n";const o=new Blob(t,{type:"text/csv"}),r=window.URL.createObjectURL(o);(0,L.R)(r,"history.csv")}_suggestCard(){const t=this._getEntityIds();if(0===t.length||!this._mungedStateHistory)return void(0,A.showAlertDialog)(this,{title:this.hass.localize("ui.panel.history.add_card_error"),text:this.hass.localize("ui.panel.history.error_no_data"),warning:!0});const e=Math.min(this._endDate.getTime(),Date.now()),i=[{title:this.hass.localize("panel.history"),type:"history-graph",hours_to_show:Math.round((e-this._startDate.getTime())/1e3/60/60),entities:t}];(0,z.Q)(this,this.hass,i,{title:this.hass.localize("panel.history"),cards:i},t)}static get styles(){return[M.RF,M.dp,(0,r.AH)(q||(q=B`ha-top-app-bar-fixed{height:100vh;overflow-x:hidden;overflow-y:visible}.page-title{font-size:inherit;margin:inherit;line-height:inherit}.content{height:calc(100vh - var(--header-height,0px) - var(--safe-area-inset-top,0px) - var(--safe-area-inset-bottom,0px));box-sizing:border-box;overflow-x:hidden;padding:0 16px 16px}:host([virtualize]){height:100%;--ha-generic-picker-max-width:400px}.progress-wrapper{position:relative;display:flex;align-items:center;flex-direction:column;padding:16px}.filters{display:flex;align-items:flex-start;margin-top:16px}ha-date-range-picker{margin-right:16px;margin-inline-end:16px;margin-inline-start:initial;max-width:100%;direction:var(--direction)}ha-target-picker{flex:1;max-width:100%;min-width:0}@media all and (max-width:1025px){.filters{flex-direction:column}ha-date-range-picker{width:100%;margin-bottom:8px}}.start-search{padding-top:16px;text-align:center;color:var(--secondary-text-color)}`))]}constructor(){super(),this.narrow=!1,this.rtl=!1,this._targetPickerValue={},this._isLoading=!1,this.__getEntityIds=(0,c.A)((t,e,i,a)=>(0,D.wY)(this.hass,t,e,i,a));const t=new Date;t.setHours(t.getHours()-1,0,0,0),this._startDate=t;const e=new Date;e.setHours(e.getHours()+2,0,0,0),this._endDate=e}}(0,n.Cg)([(0,s.MZ)({attribute:!1})],N.prototype,"hass",void 0),(0,n.Cg)([(0,s.MZ)({reflect:!0,type:Boolean})],N.prototype,"narrow",void 0),(0,n.Cg)([(0,s.MZ)({reflect:!0,type:Boolean})],N.prototype,"rtl",void 0),(0,n.Cg)([(0,s.wk)()],N.prototype,"_startDate",void 0),(0,n.Cg)([(0,s.wk)()],N.prototype,"_endDate",void 0),(0,n.Cg)([(0,s.wk)(),(0,d.I)({key:"historyPickedValue",state:!0,subscribe:!1})],N.prototype,"_targetPickerValue",void 0),(0,n.Cg)([(0,s.wk)()],N.prototype,"_isLoading",void 0),(0,n.Cg)([(0,s.wk)()],N.prototype,"_stateHistory",void 0),(0,n.Cg)([(0,s.wk)()],N.prototype,"_statisticsHistory",void 0),(0,n.Cg)([(0,s.wk)()],N.prototype,"_showBack",void 0),(0,n.Cg)([(0,s.P)("state-history-charts")],N.prototype,"_stateHistoryCharts",void 0),N=(0,n.Cg)([(0,s.EM)("ha-panel-history")],N),a()}catch(P){a(P)}})},12496:function(t,e,i){i.d(e,{Q:function(){return c}});i(18111),i(22489),i(3362),i(62953);var a=i(35952),n=i(71730),o=i(65063),r=i(57150),s=i(85633);const c=async(t,e,i,c,l)=>{var d,u;e.loadFragmentTranslation("lovelace");const h=await(0,n.SJ)(e),p=h.filter(t=>"storage"===t.mode),f=null===(d=e.panels.lovelace)||void 0===d||null===(d=d.config)||void 0===d?void 0:d.mode;if("storage"!==f&&!p.length)return void(0,r.Q)(t,{cardConfig:i,entities:l,yaml:!0});let _,g=null;if("storage"===f)try{_=await(0,a.Dz)(e.connection,null,!1)}catch(m){}if(!_&&p.length)for(const n of p)try{_=await(0,a.Dz)(e.connection,n.url_path,!1),g=n.url_path;break}catch(m){}_?p.length||null!==(u=_.views)&&void 0!==u&&u.length?p.length||1!==_.views.length?(0,s.X)(t,{lovelaceConfig:_,urlPath:g,allowDashboardChange:!0,actionLabel:e.localize("ui.common.next"),dashboards:h,viewSelectedCallback:(n,o,s)=>{(0,r.Q)(t,{cardConfig:i,sectionConfig:c,lovelaceConfig:o,saveConfig:async t=>{try{await(0,a.ql)(e,n,t)}catch(i){alert(e.localize("ui.panel.lovelace.add_entities.saving_failed"))}},path:[s],entities:l})}}):(0,r.Q)(t,{cardConfig:i,sectionConfig:c,lovelaceConfig:_,saveConfig:async t=>{try{await(0,a.ql)(e,null,t)}catch(m){alert(e.localize("ui.panel.lovelace.add_entities.saving_failed"))}},path:[0],entities:l}):(0,o.showAlertDialog)(t,{text:"You don't have any Lovelace views, first create a view in Lovelace."}):h.length>p.length?(0,r.Q)(t,{cardConfig:i,sectionConfig:c,entities:l,yaml:!0}):(0,o.showAlertDialog)(t,{text:"You don't seem to be in control of any dashboard, please take control first."})}},57150:function(t,e,i){i.d(e,{Q:function(){return o}});i(3362),i(62953);var a=i(1087);const n=()=>Promise.all([i.e(92769),i.e(3283),i.e(72130),i.e(85010),i.e(83113),i.e(67218),i.e(98470),i.e(99788),i.e(58303),i.e(21543),i.e(66283),i.e(82134),i.e(46601),i.e(63746),i.e(26092),i.e(39005),i.e(19112),i.e(34310),i.e(30002),i.e(59704),i.e(25322),i.e(53480),i.e(55392),i.e(89747),i.e(71572),i.e(55076),i.e(72453),i.e(36332),i.e(77563),i.e(15862),i.e(41344),i.e(97500),i.e(49625),i.e(40449)]).then(i.bind(i,78305)),o=(t,e)=>{(0,a.r)(t,"show-dialog",{dialogTag:"hui-dialog-suggest-card",dialogImport:n,dialogParams:e})}},85633:function(t,e,i){i.d(e,{X:function(){return n}});i(3362),i(62953);var a=i(1087);const n=(t,e)=>{(0,a.r)(t,"show-dialog",{dialogTag:"hui-dialog-select-view",dialogImport:()=>Promise.all([i.e(44335),i.e(40901)]).then(i.bind(i,54564)),dialogParams:e})}},30039:function(t,e,i){i.d(e,{R:function(){return n}});i(62953),i(3296),i(27208),i(48408),i(14603),i(47566),i(98721);var a=i(16869);const n=(t,e="")=>{const i=document.createElement("a");i.target="_blank",i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.dispatchEvent(new MouseEvent("click")),document.body.removeChild(i),t.startsWith("blob:")&&(a.B?setTimeout(()=>URL.revokeObjectURL(t),1e4):URL.revokeObjectURL(t))}}}]);