UNPKG

iobroker.lovelace

Version:

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

3 lines 35.7 kB
/*! For license information please see chunk.0ec6b90ad2ee74413f9d.js.LICENSE.txt */ (self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[76],{44285:function(e,t,n){"use strict";n(65233);var r,i,o,a=n(9672),s=n(50856),c=n(42687);(0,a.k)({_template:(0,s.d)(r||(i=['\n <style>\n :host {\n display: inline-block;\n overflow: hidden;\n position: relative;\n }\n\n #baseURIAnchor {\n display: none;\n }\n\n #sizedImgDiv {\n position: absolute;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n\n display: none;\n }\n\n #img {\n display: block;\n width: var(--iron-image-width, auto);\n height: var(--iron-image-height, auto);\n }\n\n :host([sizing]) #sizedImgDiv {\n display: block;\n }\n\n :host([sizing]) #img {\n display: none;\n }\n\n #placeholder {\n position: absolute;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n\n background-color: inherit;\n opacity: 1;\n\n @apply --iron-image-placeholder;\n }\n\n #placeholder.faded-out {\n transition: opacity 0.5s linear;\n opacity: 0;\n }\n </style>\n\n <a id="baseURIAnchor" href="#"></a>\n <div id="sizedImgDiv" role="img" hidden$="[[_computeImgDivHidden(sizing)]]" aria-hidden$="[[_computeImgDivARIAHidden(alt)]]" aria-label$="[[_computeImgDivARIALabel(alt, src)]]"></div>\n <img id="img" alt$="[[alt]]" hidden$="[[_computeImgHidden(sizing)]]" crossorigin$="[[crossorigin]]" on-load="_imgOnLoad" on-error="_imgOnError">\n <div id="placeholder" hidden$="[[_computePlaceholderHidden(preload, fade, loading, loaded)]]" class$="[[_computePlaceholderClassName(preload, fade, loading, loaded)]]"></div>\n'],o||(o=i.slice(0)),r=Object.freeze(Object.defineProperties(i,{raw:{value:Object.freeze(o)}})))),is:"iron-image",properties:{src:{type:String,value:""},alt:{type:String,value:null},crossorigin:{type:String,value:null},preventLoad:{type:Boolean,value:!1},sizing:{type:String,value:null,reflectToAttribute:!0},position:{type:String,value:"center"},preload:{type:Boolean,value:!1},placeholder:{type:String,value:null,observer:"_placeholderChanged"},fade:{type:Boolean,value:!1},loaded:{notify:!0,readOnly:!0,type:Boolean,value:!1},loading:{notify:!0,readOnly:!0,type:Boolean,value:!1},error:{notify:!0,readOnly:!0,type:Boolean,value:!1},width:{observer:"_widthChanged",type:Number,value:null},height:{observer:"_heightChanged",type:Number,value:null}},observers:["_transformChanged(sizing, position)","_loadStateObserver(src, preventLoad)"],created:function(){this._resolvedSrc=""},_imgOnLoad:function(){this.$.img.src===this._resolveSrc(this.src)&&(this._setLoading(!1),this._setLoaded(!0),this._setError(!1))},_imgOnError:function(){this.$.img.src===this._resolveSrc(this.src)&&(this.$.img.removeAttribute("src"),this.$.sizedImgDiv.style.backgroundImage="",this._setLoading(!1),this._setLoaded(!1),this._setError(!0))},_computePlaceholderHidden:function(){return!this.preload||!this.fade&&!this.loading&&this.loaded},_computePlaceholderClassName:function(){return this.preload&&this.fade&&!this.loading&&this.loaded?"faded-out":""},_computeImgDivHidden:function(){return!this.sizing},_computeImgDivARIAHidden:function(){return""===this.alt?"true":void 0},_computeImgDivARIALabel:function(){return null!==this.alt?this.alt:""===this.src?"":this._resolveSrc(this.src).replace(/[?|#].*/g,"").split("/").pop()},_computeImgHidden:function(){return!!this.sizing},_widthChanged:function(){this.style.width=isNaN(this.width)?this.width:this.width+"px"},_heightChanged:function(){this.style.height=isNaN(this.height)?this.height:this.height+"px"},_loadStateObserver:function(e,t){var n=this._resolveSrc(e);n!==this._resolvedSrc&&(this._resolvedSrc="",this.$.img.removeAttribute("src"),this.$.sizedImgDiv.style.backgroundImage="",""===e||t?(this._setLoading(!1),this._setLoaded(!1),this._setError(!1)):(this._resolvedSrc=n,this.$.img.src=this._resolvedSrc,this.$.sizedImgDiv.style.backgroundImage='url("'+this._resolvedSrc+'")',this._setLoading(!0),this._setLoaded(!1),this._setError(!1)))},_placeholderChanged:function(){this.$.placeholder.style.backgroundImage=this.placeholder?'url("'+this.placeholder+'")':""},_transformChanged:function(){var e=this.$.sizedImgDiv.style,t=this.$.placeholder.style;e.backgroundSize=t.backgroundSize=this.sizing,e.backgroundPosition=t.backgroundPosition=this.sizing?this.position:"",e.backgroundRepeat=t.backgroundRepeat=this.sizing?"no-repeat":""},_resolveSrc:function(e){var t=(0,c.Kk)(e,this.$.baseURIAnchor.href);return t.length>=2&&"/"===t[0]&&"/"!==t[1]&&(t=(location.origin||location.protocol+"//"+location.host)+t),t}})},52003:function(e,t,n){"use strict";function r(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}n.d(t,{F:function(){return i},C:function(){return o}});var i=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var i,o,s,c,l,u=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=u.length>2&&void 0!==u[2]&&u[2],t.parentNode){e.next=3;break}throw new Error("Cannot setup Leaflet map on disconnected element");case 3:return e.next=5,n.e(6085).then(n.t.bind(n,70208,23));case 5:if((o=e.sent.default).Icon.Default.imagePath="/static/images/leaflet/images/",!i){e.next=10;break}return e.next=10,n.e(7716).then(n.t.bind(n,27716,23));case 10:return s=o.map(t),(c=document.createElement("link")).setAttribute("href","/static/images/leaflet/leaflet.css"),c.setAttribute("rel","stylesheet"),t.parentNode.appendChild(c),s.setView([52.3731339,4.8903147],13),l=a(o,Boolean(r)).addTo(s),e.abrupt("return",[s,o,l]);case 18:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,c,"next",e)}function c(e){r(a,i,o,s,c,"throw",e)}s(void 0)}))});return function(e,n){return t.apply(this,arguments)}}(),o=function(e,t,n,r){return t.removeLayer(n),(n=a(e,r)).addTo(t),n},a=function(e,t){return e.tileLayer("https://{s}.basemaps.cartocdn.com/".concat(t?"dark_all":"light_all","/{z}/{x}/{y}").concat(e.Browser.retina?"@2x.png":".png"),{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>',subdomains:"abcd",minZoom:0,maxZoom:20})}},73589:function(e,t,n){"use strict";n.d(t,{Z:function(){return i}});var r=function(e){var t=parseFloat(e);if(isNaN(t))throw new Error("".concat(e," is not a number"));return t};function i(e){if(!e)return null;try{if(e.endsWith("%"))return{w:100,h:r(e.substr(0,e.length-1))};var t=e.replace(":","x").split("x");return 0===t.length?null:1===t.length?{w:r(t[0]),h:1}:{w:r(t[0]),h:r(t[1])}}catch(n){}return null}},11052:function(e,t,n){"use strict";n.d(t,{I:function(){return d}});var r=n(76389),i=n(47181);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=f(e);if(t){var i=f(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var d=(0,r.o)((function(e){return function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(u,e);var t,n,r,o=l(u);function u(){return a(this,u),o.apply(this,arguments)}return t=u,(n=[{key:"fire",value:function(e,t,n){return n=n||{},(0,i.B)(n.node||this,e,t,n)}}])&&s(t.prototype,n),r&&s(t,r),u}(e)}))},60076:function(e,t,n){"use strict";n.r(t);var r,i,o,a=n(50424),s=n(55358),c=n(76666),l=n(52003),u=n(58831),f=n(22311),d=n(91741),h=n(38346),p=n(73589),y=(n(22098),n(10983),n(58763)),m=(n(73085),n(15688)),v=n(54845),g=n(90271);function _(e){return(_="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function b(e,t){return N(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,i,o=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(c){s=!0,i=c}finally{try{a||null==n.return||n.return()}finally{if(s)throw i}}return o}(e,t)||B(e,t)||T()}function k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=B(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function E(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}function O(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){E(o,r,i,a,s,"next",e)}function s(e){E(o,r,i,a,s,"throw",e)}a(void 0)}))}}function S(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function P(e,t){return(P=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=F(e);if(t){var i=F(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return z(this,n)}}function z(e,t){return!t||"object"!==_(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function I(){I=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!A(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},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,N(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||B(t)||T()).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 n=M(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)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 "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:L(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 n=L(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function R(e){var t,n=M(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 r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function j(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function A(e){return e.decorators&&e.decorators.length}function D(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function L(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function M(e){var t=function(e,t){if("object"!==_(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==_(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===_(t)?t:String(t)}function T(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function B(e,t){if(e){if("string"==typeof e)return $(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?$(e,t):void 0}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function N(e){if(Array.isArray(e))return e}function H(e,t,n){return(H="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=F(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function F(e){return(F=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}!function(e,t,n,r){var i=I();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(D(o.descriptor)||D(i.descriptor)){if(A(o)||A(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(A(o)){if(A(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}j(o,i)}else t.push(o)}return t}(a.d.map(R)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,s.Mo)("hui-map-card")],(function(e,t){var _,E,z,I,R=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&P(e,t)}(r,t);var n=x(r);function r(){var t;S(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(C(t)),t}return r}(t);return{F:R,d:[{kind:"method",static:!0,key:"getConfigElement",value:(I=O(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([n.e(1041),n.e(1657),n.e(4268),n.e(6087),n.e(626),n.e(4535),n.e(6902),n.e(4446)]).then(n.bind(n,44446));case 2:return e.abrupt("return",document.createElement("hui-map-card-editor"));case 3:case"end":return e.stop()}}),e)}))),function(){return I.apply(this,arguments)})},{kind:"method",static:!0,key:"getStubConfig",value:function(e,t,n){return{type:"map",entities:(0,m.j)(e,2,t,n,["device_tracker"])}}},{kind:"field",decorators:[(0,s.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.Cb)({type:Boolean,reflect:!0})],key:"isPanel",value:function(){return!1}},{kind:"field",decorators:[(0,s.Cb)()],key:"_history",value:void 0},{kind:"field",key:"_date",value:void 0},{kind:"field",decorators:[(0,s.Cb)()],key:"_config",value:void 0},{kind:"field",key:"_configEntities",value:void 0},{kind:"field",key:"Leaflet",value:void 0},{kind:"field",key:"_leafletMap",value:void 0},{kind:"field",key:"_tileLayer",value:void 0},{kind:"field",key:"_resizeObserver",value:void 0},{kind:"field",key:"_debouncedResizeListener",value:function(){var e=this;return(0,h.D)((function(){e.isConnected&&e._leafletMap&&e._leafletMap.invalidateSize()}),250,!1)}},{kind:"field",key:"_mapItems",value:function(){return[]}},{kind:"field",key:"_mapZones",value:function(){return[]}},{kind:"field",key:"_mapPaths",value:function(){return[]}},{kind:"field",key:"_colorDict",value:function(){return{}}},{kind:"field",key:"_colorIndex",value:function(){return 0}},{kind:"field",key:"_colors",value:function(){return["#0288D1","#00AA00","#984ea3","#00d2d5","#ff7f00","#af8d00","#7f80cd","#b3e900","#c42e60","#a65628","#f781bf","#8dd3c7"]}},{kind:"method",key:"setConfig",value:function(e){var t;if(!e)throw new Error("Error in card configuration.");if(!(null!==(t=e.entities)&&void 0!==t&&t.length||e.geo_location_sources))throw new Error("Either entities or geo_location_sources must be specified");if(e.entities&&!Array.isArray(e.entities))throw new Error("Entities need to be an array");if(e.geo_location_sources&&!Array.isArray(e.geo_location_sources))throw new Error("Geo_location_sources needs to be an array");this._config=e,this._configEntities=e.entities?(0,g.A)(e.entities):[],this._cleanupHistory()}},{kind:"method",key:"getCardSize",value:function(){var e;if(null===(e=this._config)||void 0===e||!e.aspect_ratio)return 7;var t=(0,p.Z)(this._config.aspect_ratio),n=t&&t.w>0&&t.h>0?"".concat((100*t.h/t.w).toFixed(2)):"100";return 1+Math.floor(Number(n)/25)||3}},{kind:"method",key:"connectedCallback",value:function(){H(F(R.prototype),"connectedCallback",this).call(this),this._attachObserver(),this.hasUpdated&&this.loadMap()}},{kind:"method",key:"disconnectedCallback",value:function(){H(F(R.prototype),"disconnectedCallback",this).call(this),this._leafletMap&&(this._leafletMap.remove(),this._leafletMap=void 0,this.Leaflet=void 0),this._resizeObserver&&this._resizeObserver.unobserve(this._mapEl)}},{kind:"method",key:"render",value:function(){return this._config?(0,a.dy)(i||(i=w(['\n <ha-card id="card" .header=','>\n <div id="root">\n <div\n id="map"\n class=',"\n ></div>\n <ha-icon-button\n @click=",'\n tabindex="0"\n icon="hass:image-filter-center-focus"\n title="Reset focus"\n ></ha-icon-button>\n </div>\n </ha-card>\n '])),this._config.title,(0,c.$)({dark:!0===this._config.dark_mode}),this._fitMap):(0,a.dy)(r||(r=w([""])))}},{kind:"method",key:"shouldUpdate",value:function(e){if(!e.has("hass")||e.size>1)return!0;var t=e.get("hass");if(!t||!this._configEntities)return!0;if(t.themes.darkMode!==this.hass.themes.darkMode)return!0;var n,r=k(this._configEntities);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(t.states[i.entity]!==this.hass.states[i.entity])return!0}}catch(o){r.e(o)}finally{r.f()}return!1}},{kind:"method",key:"firstUpdated",value:function(e){H(F(R.prototype),"firstUpdated",this).call(this,e),this.isConnected&&this.loadMap();var t=this.shadowRoot.getElementById("root");if(this._config&&!this.isPanel&&t)if(this._attachObserver(),this._config.aspect_ratio){var n=(0,p.Z)(this._config.aspect_ratio);t.style.paddingBottom=n&&n.w>0&&n.h>0?"".concat((100*n.h/n.w).toFixed(2),"%"):t.style.paddingBottom="100%"}else t.style.paddingBottom="100%"}},{kind:"method",key:"updated",value:function(e){var t,n;if((e.has("hass")||e.has("_history"))&&(this._drawEntities(),this._fitMap()),e.has("hass")){var r=e.get("hass");r&&r.themes.darkMode!==this.hass.themes.darkMode&&this._replaceTileLayer()}if(e.has("_config")&&void 0!==e.get("_config")&&this.updateMap(e.get("_config")),null!==(t=this._config)&&void 0!==t&&t.hours_to_show&&null!==(n=this._configEntities)&&void 0!==n&&n.length){(e.has("_config")||Date.now()-this._date.getTime()>=6e4)&&this._getHistory()}}},{kind:"get",key:"_mapEl",value:function(){return this.shadowRoot.getElementById("map")}},{kind:"method",key:"loadMap",value:(z=O(regeneratorRuntime.mark((function e(){var t,n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,l.F)(this._mapEl,null!==(t=this._config.dark_mode)&&void 0!==t?t:this.hass.themes.darkMode);case 2:n=e.sent,r=b(n,3),this._leafletMap=r[0],this.Leaflet=r[1],this._tileLayer=r[2],this._drawEntities(),this._leafletMap.invalidateSize(),this._fitMap();case 10:case"end":return e.stop()}}),e,this)}))),function(){return z.apply(this,arguments)})},{kind:"method",key:"_replaceTileLayer",value:function(){var e,t=this._leafletMap,n=this._config,r=this.Leaflet;t&&n&&r&&this._tileLayer&&(this._tileLayer=(0,l.C)(r,t,this._tileLayer,null!==(e=this._config.dark_mode)&&void 0!==e?e:this.hass.themes.darkMode))}},{kind:"method",key:"updateMap",value:function(e){var t=this._leafletMap,n=this._config,r=this.Leaflet;t&&n&&r&&this._tileLayer&&(this._config.dark_mode!==e.dark_mode&&this._replaceTileLayer(),n.entities===e.entities&&n.geo_location_sources===e.geo_location_sources||this._drawEntities(),t.invalidateSize(),this._fitMap())}},{kind:"method",key:"_fitMap",value:function(){if(this._leafletMap&&this.Leaflet&&this._config&&this.hass){var e=this._config.default_zoom;if(0!==this._mapItems.length){var t=this.Leaflet.featureGroup(this._mapItems).getBounds();this._leafletMap.fitBounds(t.pad(.5)),e&&this._leafletMap.getZoom()>e&&this._leafletMap.setZoom(e)}else this._leafletMap.setView(new this.Leaflet.LatLng(this.hass.config.latitude,this.hass.config.longitude),e||14)}}},{kind:"method",key:"_getColor",value:function(e){var t;return this._colorDict[e]?t=this._colorDict[e]:(t=this._colors[this._colorIndex],this._colorIndex=(this._colorIndex+1)%this._colors.length,this._colorDict[e]=t),t}},{kind:"method",key:"_drawEntities",value:function(){var e=this.hass,t=this._leafletMap,n=this._config,r=this.Leaflet;if(e&&t&&n&&r){this._mapItems&&this._mapItems.forEach((function(e){return e.remove()}));var i=this._mapItems=[];this._mapZones&&this._mapZones.forEach((function(e){return e.remove()}));var o=this._mapZones=[];this._mapPaths&&this._mapPaths.forEach((function(e){return e.remove()}));var a=this._mapPaths=[],s=this._configEntities.concat();if(n.geo_location_sources)for(var c=n.geo_location_sources.includes("all"),l=0,h=Object.keys(e.states);l<h.length;l++){var p=h[l],y=e.states[p];"geo_location"===(0,u.M)(p)&&(c||n.geo_location_sources.includes(y.attributes.source))&&s.push({entity:p})}if(this._config.hours_to_show&&this._history){var m,v=k(this._history);try{for(v.s();!(m=v.n()).done;){var g=m.value;if(!((null==g?void 0:g.length)<=1))for(var _=g[0].entity_id,b=g.reduce((function(e,t){var n=t.attributes.latitude,r=t.attributes.longitude;return n&&r&&e.push([n,r]),e}),[]),w=0;w<b.length-1;w++){var E=.2+w*(.8/(b.length-2));a.push(r.circleMarker(b[w],{radius:3,color:this._getColor(_),opacity:E,interactive:!1}));var O=[b[w],b[w+1]];a.push(r.polyline(O,{color:this._getColor(_),opacity:E,interactive:!1}))}}}catch(F){v.e(F)}finally{v.f()}}var S,P=k(s);try{for(P.s();!(S=P.n()).done;){var x=S.value.entity,z=e.states[x];if(z){var C=(0,d.C)(z),I=z.attributes,R=I.latitude,j=I.longitude,A=I.passive,D=I.icon,L=I.radius,M=I.entity_picture,T=I.gps_accuracy;if(R&&j)if("zone"!==(0,f.N)(z)){var B=C.split(" ").map((function(e){return e[0]})).join("").substr(0,3);i.push(r.marker([R,j],{icon:r.divIcon({html:'\n <ha-entity-marker\n entity-id="'.concat(x,'"\n entity-name="').concat(B,'"\n entity-picture="').concat(M||"",'"\n entity-color="').concat(this._getColor(x),'"\n ></ha-entity-marker>\n '),iconSize:[48,48],className:""}),title:(0,d.C)(z)})),T&&i.push(r.circle([R,j],{interactive:!1,color:this._getColor(x),radius:T}))}else{if(A)continue;var $="";if(D){var N=document.createElement("ha-icon");N.setAttribute("icon",D),$=N.outerHTML}else{var H=document.createElement("span");H.innerHTML=C,$=H.outerHTML}o.push(r.marker([R,j],{icon:r.divIcon({html:$,iconSize:[24,24],className:this._config.dark_mode?"dark":!1===this._config.dark_mode?"light":""}),interactive:!1,title:C})),o.push(r.circle([R,j],{interactive:!1,color:"#FF9800",radius:L}))}}}}catch(F){P.e(F)}finally{P.f()}this._mapItems.forEach((function(e){return t.addLayer(e)})),this._mapZones.forEach((function(e){return t.addLayer(e)})),this._mapPaths.forEach((function(e){return t.addLayer(e)}))}}},{kind:"method",key:"_attachObserver",value:(E=O(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._resizeObserver){e.next=4;break}return e.next=3,(0,v.P)();case 3:this._resizeObserver=new ResizeObserver(this._debouncedResizeListener);case 4:this._resizeObserver.observe(this);case 5:case"end":return e.stop()}}),e,this)}))),function(){return E.apply(this,arguments)})},{kind:"method",key:"_getHistory",value:(_=O(regeneratorRuntime.mark((function e(){var t,n,r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._date=new Date,this._configEntities){e.next=3;break}return e.abrupt("return");case 3:return t=this._configEntities.map((function(e){return e.entity})).join(","),n=new Date,(r=new Date).setHours(n.getHours()-this._config.hours_to_show),e.next=12,(0,y.vq)(this.hass,t,r,n,!1,!1,!1);case 12:if(!((i=e.sent).length<1)){e.next=15;break}return e.abrupt("return");case 15:this._history=i;case 16:case"end":return e.stop()}}),e,this)}))),function(){return _.apply(this,arguments)})},{kind:"method",key:"_cleanupHistory",value:function(){if(this._history)if(this._config.hours_to_show<=0)this._history=void 0;else{var e,t=null===(e=this._configEntities)||void 0===e?void 0:e.map((function(e){return e.entity}));this._history=this._history.reduce((function(e,n){var r=n[0].entity_id;return null!=t&&t.includes(r)&&e.push(n),e}),[])}}},{kind:"get",static:!0,key:"styles",value:function(){return(0,a.iv)(o||(o=w(["\n ha-card {\n overflow: hidden;\n width: 100%;\n height: 100%;\n }\n\n #map {\n z-index: 0;\n border: none;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: inherit;\n }\n\n ha-icon-button {\n position: absolute;\n top: 75px;\n left: 3px;\n outline: none;\n }\n\n #root {\n position: relative;\n }\n\n :host([ispanel]) #root {\n height: 100%;\n }\n\n .dark {\n color: #ffffff;\n }\n\n .light {\n color: #000000;\n }\n "])))}}]}}),a.oi)},73085:function(e,t,n){"use strict";n(44285);var r,i=n(50856),o=n(28426);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=h(e);if(t){var i=h(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(d,e);var t,n,o,a=f(d);function d(){return s(this,d),a.apply(this,arguments)}return t=d,o=[{key:"template",get:function(){return(0,i.d)(r||(e=['\n <style include="iron-positioning"></style>\n <style>\n .marker {\n position: relative;\n display: block;\n margin: 0 auto;\n width: 2.5em;\n text-align: center;\n height: 2.5em;\n line-height: 2.5em;\n font-size: 1.5em;\n border-radius: 50%;\n border: 0.1em solid var(--ha-marker-color, var(--primary-color));\n color: var(--primary-text-color);\n background-color: var(--card-background-color);\n }\n iron-image {\n border-radius: 50%;\n }\n </style>\n\n <div class="marker" style$="border-color:{{entityColor}}">\n <template is="dom-if" if="[[entityName]]">[[entityName]]</template>\n <template is="dom-if" if="[[entityPicture]]">\n <iron-image\n sizing="cover"\n class="fit"\n src="[[entityPicture]]"\n ></iron-image>\n </template>\n </div>\n '],t||(t=e.slice(0)),r=Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))));var e,t}},{key:"properties",get:function(){return{hass:{type:Object},entityId:{type:String,value:""},entityName:{type:String,value:null},entityPicture:{type:String,value:null},entityColor:{type:String,value:null}}}}],(n=[{key:"ready",value:function(){var e=this;l(h(d.prototype),"ready",this).call(this),this.addEventListener("click",(function(t){return e.badgeTap(t)}))}},{key:"badgeTap",value:function(e){e.stopPropagation(),this.entityId&&this.fire("hass-more-info",{entityId:this.entityId})}}])&&c(t.prototype,n),o&&c(t,o),d}((0,n(11052).I)(o.H3));customElements.define("ha-entity-marker",p)}}]); //# sourceMappingURL=chunk.0ec6b90ad2ee74413f9d.js.map