UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

110 lines (97 loc) 31.3 kB
/*! For license information please see chunk.8a5cf7b20a1f17c1077b.js.LICENSE.txt */ (self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[4240],{78389:(e,t,r)=>{"use strict";r.d(t,{s:()=>h});var i=r(99602),n=r(55122),s=r(57724);const o=(e,t)=>{var r,i;const n=e.N;if(void 0===n)return!1;for(const e of n)null===(i=(r=e).O)||void 0===i||i.call(r,t,!1),o(e,t);return!0},a=e=>{let t,r;do{if(void 0===(t=e.M))break;r=t.N,r.delete(e),e=t}while(0===(null==r?void 0:r.size))},l=e=>{for(let t;t=e.M;e=t){let r=t.N;if(void 0===r)t.N=r=new Set;else if(r.has(e))break;r.add(e),u(t)}};function c(e){void 0!==this.N?(a(this),this.M=e,l(this)):this.M=e}function d(e,t=!1,r=0){const i=this.H,n=this.N;if(void 0!==n&&0!==n.size)if(t)if(Array.isArray(i))for(let e=r;e<i.length;e++)o(i[e],!1),a(i[e]);else null!=i&&(o(i,!1),a(i));else o(this,e)}const u=e=>{var t,r,i,s;e.type==n.pX.CHILD&&(null!==(t=(i=e).P)&&void 0!==t||(i.P=d),null!==(r=(s=e).Q)&&void 0!==r||(s.Q=c))};class h extends n.Xe{constructor(){super(...arguments),this.isConnected=!0,this.ut=i.Jb,this.N=void 0}T(e,t,r){super.T(e,t,r),l(this)}O(e,t=!0){this.at(e),t&&(o(this,e),a(this))}at(e){var t,r;e!==this.isConnected&&(e?(this.isConnected=!0,this.ut!==i.Jb&&(this.setValue(this.ut),this.ut=i.Jb),null===(t=this.reconnected)||void 0===t||t.call(this)):(this.isConnected=!1,null===(r=this.disconnected)||void 0===r||r.call(this)))}S(e,t){if(!this.isConnected)throw Error(`AsyncDirective ${this.constructor.name} was rendered while its tree was disconnected.`);return super.S(e,t)}setValue(e){if(this.isConnected)if((0,s.OR)(this.Σdt))this.Σdt.I(e,this);else{const t=[...this.Σdt.H];t[this.Σct]=e,this.Σdt.I(t,this,0)}else this.ut=e}disconnected(){}reconnected(){}}},57724:(e,t,r)=>{"use strict";r.d(t,{E_:()=>m,i9:()=>f,_Y:()=>c,pt:()=>s,OR:()=>a,hN:()=>o,ws:()=>p,fk:()=>d,hl:()=>h});var i=r(99602);const{et:n}=i.Vm,s=e=>null===e||"object"!=typeof e&&"function"!=typeof e,o=(e,t)=>{var r,i;return void 0===t?void 0!==(null===(r=e)||void 0===r?void 0:r._$litType$):(null===(i=e)||void 0===i?void 0:i._$litType$)===t},a=e=>void 0===e.strings,l=()=>document.createComment(""),c=(e,t,r)=>{var i;const s=e.A.parentNode,o=void 0===t?e.B:t.A;if(void 0===r){const t=s.insertBefore(l(),o),i=s.insertBefore(l(),o);r=new n(t,i,e,e.options)}else{const t=r.B.nextSibling,n=r.M!==e;if(n&&(null===(i=r.Q)||void 0===i||i.call(r,e),r.M=e),t!==o||n){let e=r.A;for(;e!==t;){const t=e.nextSibling;s.insertBefore(e,o),e=t}}}return r},d=(e,t,r=e)=>(e.I(t,r),e),u={},h=(e,t=u)=>e.H=t,f=e=>e.H,p=e=>{var t;null===(t=e.P)||void 0===t||t.call(e,!1,!0);let r=e.A;const i=e.B.nextSibling;for(;r!==i;){const e=r.nextSibling;r.remove(),r=e}},m=e=>{e.R()}},24731:(e,t,r)=>{"use strict";r.d(t,{s:()=>i.s});var i=r(78389)},76666:(e,t,r)=>{"use strict";r.d(t,{$:()=>i.$});var i=r(81471)},13690:(e,t,r)=>{"use strict";r.d(t,{r:()=>a});var i=r(99602),n=r(55122),s=r(57724);const o=(e,t,r)=>{const i=new Map;for(let n=t;n<=r;n++)i.set(e[n],n);return i},a=(0,n.XM)(class extends n.Xe{constructor(e){if(super(e),e.type!==n.pX.CHILD)throw Error("repeat() can only be used in text expressions")}Mt(e,t,r){let i;void 0===r?r=t:void 0!==t&&(i=t);const n=[],s=[];let o=0;for(const t of e)n[o]=i?i(t,o):o,s[o]=r(t,o),o++;return{values:s,keys:n}}render(e,t,r){return this.Mt(e,t,r).values}update(e,[t,r,n]){var a;const l=(0,s.i9)(e),{values:c,keys:d}=this.Mt(t,r,n);if(!l)return this.Pt=d,c;const u=null!==(a=this.Pt)&&void 0!==a?a:this.Pt=[],h=[];let f,p,m=0,y=l.length-1,v=0,g=c.length-1;for(;m<=y&&v<=g;)if(null===l[m])m++;else if(null===l[y])y--;else if(u[m]===d[v])h[v]=(0,s.fk)(l[m],c[v]),m++,v++;else if(u[y]===d[g])h[g]=(0,s.fk)(l[y],c[g]),y--,g--;else if(u[m]===d[g])h[g]=(0,s.fk)(l[m],c[g]),(0,s._Y)(e,h[g+1],l[m]),m++,g--;else if(u[y]===d[v])h[v]=(0,s.fk)(l[y],c[v]),(0,s._Y)(e,l[m],l[y]),y--,v++;else if(void 0===f&&(f=o(d,v,g),p=o(u,m,y)),f.has(u[m]))if(f.has(u[y])){const t=p.get(d[v]),r=void 0!==t?l[t]:null;if(null===r){const t=(0,s._Y)(e,l[m]);(0,s.fk)(t,c[v]),h[v]=t}else h[v]=(0,s.fk)(r,c[v]),(0,s._Y)(e,l[m],r),l[t]=null;v++}else(0,s.ws)(l[y]),y--;else(0,s.ws)(l[m]),m++;for(;v<=g;){const t=(0,s._Y)(e,h[g+1]);(0,s.fk)(t,c[v]),h[v++]=t}for(;m<=y;){const e=l[m++];null!==e&&(0,s.ws)(e)}return this.Pt=d,(0,s.hl)(e,h),i.Jb}})},5435:(e,t,r)=>{"use strict";r.d(t,{Z:()=>s});const i=[60,60,24,7],n=["second","minute","hour","day"];function s(e,t,r={}){let s=((r.compareTime||new Date).getTime()-e.getTime())/1e3;const o=s>=0?"past":"future";s=Math.abs(s);let a=Math.round(s);if(0===a)return t("ui.components.relative_time.just_now");let l="week";for(let e=0;e<i.length;e++){if(a<i[e]){l=n[e];break}s/=i[e],a=Math.round(s)}return t(!1===r.includeTense?`ui.components.relative_time.duration.${l}`:`ui.components.relative_time.${o}_duration.${l}`,"count",a)}},25516:(e,t,r)=>{"use strict";r.d(t,{i:()=>i});const i=e=>t=>({kind:"method",placement:"prototype",key:t.key,descriptor:{set(e){this[`__${String(t.key)}`]=e},get(){return this[`__${String(t.key)}`]},enumerable:!0,configurable:!0},finisher(r){const i=r.prototype.connectedCallback;r.prototype.connectedCallback=function(){if(i.call(this),this[t.key]){const r=this.renderRoot.querySelector(e);if(!r)return;r.scrollTop=this[t.key]}}}})},43793:(e,t,r)=>{"use strict";r.d(t,{x:()=>i});const i=(e,t)=>e.substring(0,t.length)===t},42952:(e,t,r)=>{"use strict";var i=r(50424),n=r(55358),s=r(5435);function o(){o=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var n=t.placement;if(t.kind===i&&("static"===n||"prototype"===n)){var s="static"===n?e:r;this.defineClassElement(s,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],n={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,n)}),this),e.forEach((function(e){if(!c(e))return r.push(e);var t=this.decorateElement(e,n);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var s=this.decorateConstructor(r,t);return i.push.apply(i,s.finishers),s.finishers=i,s},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],n=e.decorators,s=n.length-1;s>=0;s--){var o=t[e.placement];o.splice(o.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[s])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var n=this.fromClassDescriptor(e),s=this.toClassDescriptor((0,t[i])(n)||n);if(void 0!==s.finisher&&r.push(s.finisher),void 0!==s.elements){e=s.elements;for(var o=0;o<e.length-1;o++)for(var a=o+1;a<e.length;a++)if(e[o].key===e[a].key&&e[o].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[o].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=h(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+i+'"');var n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var s={kind:t,key:r,placement:i,descriptor:Object.assign({},n)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(n,"get","The property descriptor of a field descriptor"),this.disallowProperty(n,"set","The property descriptor of a field descriptor"),this.disallowProperty(n,"value","The property descriptor of a field descriptor"),s.initializer=e.initializer),s},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:u(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=u(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function a(e){var t,r=h(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function l(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function c(e){return e.decorators&&e.decorators.length}function d(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function u(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function h(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function p(e,t,r){return(p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=m(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}!function(e,t,r,i){var n=o();if(i)for(var s=0;s<i.length;s++)n=i[s](n);var u=t((function(e){n.initializeInstanceElements(e,h.elements)}),r),h=n.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===s.key&&e.placement===s.placement},i=0;i<e.length;i++){var n,s=e[i];if("method"===s.kind&&(n=t.find(r)))if(d(s.descriptor)||d(n.descriptor)){if(c(s)||c(n))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");n.descriptor=s.descriptor}else{if(c(s)){if(c(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");n.decorators=s.decorators}l(s,n)}else t.push(s)}return t}(u.d.map(a)),e);n.initializeClassElements(u.F,h.elements),n.runClassFinishers(u.F,h.finishers)}([(0,n.Mo)("ha-relative-time")],(function(e,t){class r extends t{constructor(...t){super(...t),e(this)}}return{F:r,d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"datetime",value:void 0},{kind:"field",key:"_interval",value:void 0},{kind:"method",key:"disconnectedCallback",value:function(){p(m(r.prototype),"disconnectedCallback",this).call(this),this._clearInterval()}},{kind:"method",key:"connectedCallback",value:function(){p(m(r.prototype),"connectedCallback",this).call(this),this.datetime&&this._startInterval()}},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"firstUpdated",value:function(e){p(m(r.prototype),"firstUpdated",this).call(this,e),this._updateRelative()}},{kind:"method",key:"update",value:function(e){p(m(r.prototype),"update",this).call(this,e),this._updateRelative()}},{kind:"method",key:"_clearInterval",value:function(){this._interval&&(window.clearInterval(this._interval),this._interval=void 0)}},{kind:"method",key:"_startInterval",value:function(){this._clearInterval(),this._interval=window.setInterval((()=>this._updateRelative()),6e4)}},{kind:"method",key:"_updateRelative",value:function(){this.datetime?this.innerHTML=(0,s.Z)(new Date(this.datetime),this.hass.localize):this.innerHTML=this.hass.localize("ui.components.relative_time.never")}}]}}),i.fl)},62021:(e,t,r)=>{"use strict";r.d(t,{HD:()=>i,oO:()=>n,p6:()=>s,jt:()=>o});const i=e=>e.callWS({type:"person/list"}),n=(e,t)=>e.callWS({type:"person/create",...t}),s=(e,t,r)=>e.callWS({type:"person/update",person_id:t,...r}),o=(e,t)=>e.callWS({type:"person/delete",person_id:t})},97389:(e,t,r)=>{"use strict";r.d(t,{mA:()=>n,lj:()=>s,U_:()=>o,nV:()=>a,Zm:()=>l});var i=r(43793);const n=(e,t,r,i)=>e.callWS({type:"trace/get",domain:t,item_id:r,run_id:i}),s=(e,t,r)=>e.callWS({type:"trace/list",domain:t,item_id:r}),o=(e,t,r)=>e.callWS({type:"trace/contexts",domain:t,item_id:r}),a=(e,t)=>{const r=t.split("/").reverse();let i=e;for(;r.length;){const e=r.pop(),t=Number(e);if(isNaN(t))i=i[e];else if(Array.isArray(i))i=i[t];else if(0!==t)throw new Error("If config is not an array, can only return index 0")}return i},l=e=>"trigger"===e||(0,i.x)(e,"trigger/")},65253:(e,t,r)=>{"use strict";r.d(t,{Pb:()=>i,CE:()=>n,uh:()=>s,r4:()=>o,Nq:()=>a,h8:()=>l});const i="system-admin",n="system-users",s=async e=>e.callWS({type:"config/auth/list"}),o=async(e,t,r)=>e.callWS({type:"config/auth/create",name:t,group_ids:r}),a=async(e,t,r)=>e.callWS({...r,type:"config/auth/update",user_id:t}),l=async(e,t)=>e.callWS({type:"config/auth/delete",user_id:t})},18873:(e,t,r)=>{"use strict";r.r(t),r.d(t,{HaPanelLogbook:()=>D});var i=r(68546),n=(r(53268),r(12730),r(50424)),s=r(55358),o=r(7323),a=r(87744),l=(r(74535),r(31206),r(44491),r(10983),r(48932),r(55422)),c=r(62021),d=r(97389),u=r(65253),h=(r(27849),r(11654));r(97740);function f(){f=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var n=t.placement;if(t.kind===i&&("static"===n||"prototype"===n)){var s="static"===n?e:r;this.defineClassElement(s,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],n={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,n)}),this),e.forEach((function(e){if(!y(e))return r.push(e);var t=this.decorateElement(e,n);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var s=this.decorateConstructor(r,t);return i.push.apply(i,s.finishers),s.finishers=i,s},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],n=e.decorators,s=n.length-1;s>=0;s--){var o=t[e.placement];o.splice(o.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[s])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var n=this.fromClassDescriptor(e),s=this.toClassDescriptor((0,t[i])(n)||n);if(void 0!==s.finisher&&r.push(s.finisher),void 0!==s.elements){e=s.elements;for(var o=0;o<e.length-1;o++)for(var a=o+1;a<e.length;a++)if(e[o].key===e[a].key&&e[o].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[o].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=k(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+i+'"');var n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var s={kind:t,key:r,placement:i,descriptor:Object.assign({},n)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(n,"get","The property descriptor of a field descriptor"),this.disallowProperty(n,"set","The property descriptor of a field descriptor"),this.disallowProperty(n,"value","The property descriptor of a field descriptor"),s.initializer=e.initializer),s},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:g(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=g(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function p(e){var t,r=k(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function m(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function y(e){return e.decorators&&e.decorators.length}function v(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function g(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function w(e,t,r){return(w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_(e)););return e}(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(r):n.value}})(e,t,r||e)}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}let D=function(e,t,r,i){var n=f();if(i)for(var s=0;s<i.length;s++)n=i[s](n);var o=t((function(e){n.initializeInstanceElements(e,a.elements)}),r),a=n.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===s.key&&e.placement===s.placement},i=0;i<e.length;i++){var n,s=e[i];if("method"===s.kind&&(n=t.find(r)))if(v(s.descriptor)||v(n.descriptor)){if(y(s)||y(n))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");n.descriptor=s.descriptor}else{if(y(s)){if(y(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");n.decorators=s.decorators}m(s,n)}else t.push(s)}return t}(o.d.map(p)),e);return n.initializeClassElements(o.F,a.elements),n.runClassFinishers(o.F,a.finishers)}([(0,s.Mo)("ha-panel-logbook")],(function(e,t){class r extends t{constructor(){super(),e(this);const t=new Date;t.setHours(t.getHours()-2),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),this._startDate=t;const r=new Date;r.setHours(r.getHours()+1),r.setMinutes(0),r.setSeconds(0),r.setMilliseconds(0),this._endDate=r}}return{F:r,d:[{kind:"field",decorators:[(0,s.Cb)()],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)({reflect:!0,type:Boolean})],key:"narrow",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"_startDate",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"_endDate",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"_entityId",value:()=>""},{kind:"field",decorators:[(0,s.Cb)()],key:"_isLoading",value:()=>!1},{kind:"field",decorators:[(0,s.Cb)()],key:"_entries",value:()=>[]},{kind:"field",decorators:[(0,s.Cb)({reflect:!0,type:Boolean})],key:"rtl",value:()=>!1},{kind:"field",decorators:[(0,s.SB)()],key:"_ranges",value:void 0},{kind:"field",key:"_fetchUserDone",value:void 0},{kind:"field",decorators:[(0,s.SB)()],key:"_userIdToName",value:()=>({})},{kind:"field",decorators:[(0,s.SB)()],key:"_traceContexts",value:()=>({})},{kind:"method",key:"render",value:function(){return n.dy` <ha-app-layout> <app-header slot="header" fixed> <app-toolbar> <ha-menu-button .hass=${this.hass} .narrow=${this.narrow} ></ha-menu-button> <div main-title>${this.hass.localize("panel.logbook")}</div> <mwc-icon-button @click=${this._refreshLogbook} .disabled=${this._isLoading} > <ha-svg-icon .path=${i.jcD}></ha-svg-icon> </mwc-icon-button> </app-toolbar> </app-header> ${this._isLoading?n.dy``:""} <div class="filters"> <ha-date-range-picker .hass=${this.hass} ?disabled=${this._isLoading} .startDate=${this._startDate} .endDate=${this._endDate} .ranges=${this._ranges} @change=${this._dateRangeChanged} ></ha-date-range-picker> <ha-entity-picker .hass=${this.hass} .value=${this._entityId} .label=${this.hass.localize("ui.components.entity.entity-picker.entity")} .disabled=${this._isLoading} @change=${this._entityPicked} ></ha-entity-picker> </div> ${this._isLoading?n.dy` <div class="progress-wrapper"> <ha-circular-progress active alt=${this.hass.localize("ui.common.loading")} ></ha-circular-progress> </div> `:n.dy` <ha-logbook .hass=${this.hass} .entries=${this._entries} .userIdToName=${this._userIdToName} .traceContexts=${this._traceContexts} virtualize ></ha-logbook> `} </ha-app-layout> `}},{kind:"method",key:"firstUpdated",value:function(e){w(_(r.prototype),"firstUpdated",this).call(this,e),this.hass.loadBackendTranslation("title"),this._fetchUserDone=this._fetchUserNames();const t=new Date;t.setHours(0,0,0,0);const i=new Date(t);i.setDate(i.getDate()+1),i.setMilliseconds(i.getMilliseconds()-1);const n=new Date(t);n.setDate(t.getDate()-1);const s=new Date(t);s.setMilliseconds(s.getMilliseconds()-1);const o=new Date(t);o.setDate(t.getDate()-t.getDay());const a=new Date(o);a.setDate(o.getDate()+7),a.setMilliseconds(a.getMilliseconds()-1);const l=new Date(t);l.setDate(t.getDate()-t.getDay()-7);const c=new Date(l);c.setDate(l.getDate()+7),c.setMilliseconds(c.getMilliseconds()-1),this._ranges={[this.hass.localize("ui.panel.logbook.ranges.today")]:[t,i],[this.hass.localize("ui.panel.logbook.ranges.yesterday")]:[n,s],[this.hass.localize("ui.panel.logbook.ranges.this_week")]:[o,a],[this.hass.localize("ui.panel.logbook.ranges.last_week")]:[l,c]}}},{kind:"method",key:"updated",value:function(e){if((e.has("_startDate")||e.has("_endDate")||e.has("_entityId"))&&this._getData(),e.has("hass")){const t=e.get("hass");t&&t.language===this.hass.language||(this.rtl=(0,a.HE)(this.hass))}}},{kind:"method",key:"_fetchUserNames",value:async function(){const e={},t=(0,c.HD)(this.hass),r=this.hass.user.is_admin&&(0,u.uh)(this.hass),i=await t;for(const t of i.storage)t.user_id&&(e[t.user_id]=t.name);for(const t of i.config)t.user_id&&(e[t.user_id]=t.name);if(r){const t=await r;for(const r of t)r.id in e||(e[r.id]=r.name)}this._userIdToName=e}},{kind:"method",key:"_dateRangeChanged",value:function(e){this._startDate=e.detail.startDate;const t=e.detail.endDate;0===t.getHours()&&0===t.getMinutes()&&(t.setDate(t.getDate()+1),t.setMilliseconds(t.getMilliseconds()-1)),this._endDate=t}},{kind:"method",key:"_entityPicked",value:function(e){this._entityId=e.target.value}},{kind:"method",key:"_refreshLogbook",value:function(){this._entries=[],(0,l.tf)(this._startDate.toISOString(),this._endDate.toISOString()),this._getData()}},{kind:"method",key:"_getData",value:async function(){this._isLoading=!0;const[e,t]=await Promise.all([(0,l.rM)(this.hass,this._startDate.toISOString(),this._endDate.toISOString(),this._entityId),(0,o.p)(this.hass,"trace")?(0,d.U_)(this.hass):{},this._fetchUserDone]);this._entries=e,this._traceContexts=t,this._isLoading=!1}},{kind:"get",static:!0,key:"styles",value:function(){return[h.Qx,n.iv` ha-logbook, .progress-wrapper { height: calc(100vh - 136px); } :host([narrow]) ha-logbook, :host([narrow]) .progress-wrapper { height: calc(100vh - 198px); } ha-date-range-picker { margin-right: 16px; max-width: 100%; } :host([narrow]) ha-date-range-picker { margin-right: 0; } .progress-wrapper { position: relative; } ha-circular-progress { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); } .filters { display: flex; align-items: flex-end; padding: 0 16px; } :host([narrow]) .filters { flex-wrap: wrap; } ha-entity-picker { display: inline-block; flex-grow: 1; max-width: 400px; } :host([narrow]) ha-entity-picker { max-width: none; width: 100%; } `]}}]}}),n.oi)}}]); //# sourceMappingURL=chunk.8a5cf7b20a1f17c1077b.js.map