extra-map-card 1.3.1 β†’ 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}console.groupCollapsed("%cπŸ“ EXTRA-MAP-CARD πŸ—ΊοΈ%cv1.3.1","background-color: #434347;color: #fff;padding: 2px 4px;border: 1px solid #434347;border-radius: 2px 0 0 2px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #434347;padding: 2px 3px;border: 1px solid #434347; border-radius: 0 2px 2px 0;font-family: Roboto,Verdana,Geneva,sans-serif"),console.info("Lovelace custom map card for Home Assistant"),console.info("Github: git+https://github.com/ngocjohn/extra-map-card.git"),console.info("If you like the card, consider supporting the developer: https://github.com/sponsors/ngocjohn"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);function i(){let e=document.querySelector("home-assistant");if(e=e&&e.shadowRoot,e=e&&e.querySelector("home-assistant-main"),e=e&&e.shadowRoot,e=e&&e.querySelector("app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver"),e=e&&e.shadowRoot||e,e=e&&e.querySelector("ha-panel-lovelace"),e=e&&e.shadowRoot,e=e&&e.querySelector("hui-root"),e){const t=e.lovelace;return t.current_view=e.___curView,t}return null}const r=e=>{let t=e;for(;t;){if("HUI-CARD-OPTIONS"===t.tagName)return t;t=t.parentNode}return t};function n(e){const t=i();return t?(t.setEditMode(!0),new Promise((i=>{setTimeout((()=>{const n=r(e.parentNode);if(!n)return t.setEditMode(!1),void i(null);const o=n.__path,a=`${n.lovelace.urlPath}-${o.join("-")}`;t.setEditMode(!1),i(a)}),100)}))):Promise.reject("Lovelace not found")}const o=e=>2===e.length?{viewIndex:e[0],cardIndex:e[1]}:{viewIndex:e[0],sectionIndex:e[1],cardIndex:e[2]},a=e=>1===e.length?{viewIndex:e[0]}:{viewIndex:e[0],sectionIndex:e[1]},s=e=>e.slice(0,-1),l=(e,t)=>{var i;const{viewIndex:r,sectionIndex:n}=a(t),o=e.views[r];if(!o)throw new Error("View does not exist");if(void 0===n)return o;if(g(o))throw new Error("Can not find section in a strategy view");const s=null===(i=o.sections)||void 0===i?void 0:i[n];if(!s)throw new Error("Section does not exist");return s},c=(e,t)=>{var i;const{viewIndex:r,sectionIndex:n}=a(t),o=e.views[r];if(!o)throw new Error("View does not exist");if(g(o))throw new Error("Can not find cards in a strategy view");if(void 0===n)return o.cards;const s=null===(i=o.sections)||void 0===i?void 0:i[n];if(!s)throw new Error("Section does not exist");if(y(s))throw new Error("Can not find cards in a strategy section");return s.cards},u=(e,t,i)=>{const{viewIndex:r,sectionIndex:n}=a(t);let o=!1;const s=e.views.map(((e,t)=>{if(t!==r)return e;if(void 0===n)return o=!0,i;if(g(e))throw new Error("Can not update section in a strategy view");if(void 0===e.sections)throw new Error("Section does not exist");const a=e.sections.map(((e,t)=>t!==n?e:(o=!0,i)));return Object.assign(Object.assign({},e),{sections:a})}));if(!o)throw new Error("Can not update cards in a non-existing view/section");return Object.assign(Object.assign({},e),{views:s})},h=(e,t,i)=>{const{viewIndex:r,sectionIndex:n}=a(t);let o=!1;const s=e.views.map(((e,t)=>{if(t!==r)return e;if(g(e))throw new Error("Can not update cards in a strategy view");if(void 0===n)return o=!0,Object.assign(Object.assign({},e),{cards:i});if(void 0===e.sections)throw new Error("Section does not exist");const a=e.sections.map(((e,t)=>{if(t!==n)return e;if(y(e))throw new Error("Can not update cards in a strategy section");return o=!0,Object.assign(Object.assign({},e),{cards:i})}));return Object.assign(Object.assign({},e),{sections:a})}));if(!o)throw new Error("Can not update cards in a non-existing view/section");return Object.assign(Object.assign({},e),{views:s})};function p(e){return"strategy"in e}const d=(e,t,i)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:i}),f=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),m=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t});function g(e){return"strategy"in e}function y(e){return"strategy"in e}const _=e=>"string"==typeof e?{type:"entity",entity:e,show_name:!0}:"type"in e&&e.type?e:Object.assign({type:"entity"},e),v=e=>e.sendMessagePromise({type:"lovelace/resources"}),b=(e,t)=>e.callWS(Object.assign({type:"lovelace/resources/create"},t)),x=(e,t,i)=>e.callWS(Object.assign({type:"lovelace/resources/update",resource_id:t},i)),w=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),C=(e,t,i,r)=>{r=r||{},i=null==i?{}:i;const n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=i,e.dispatchEvent(n),n},T=(e,t,i)=>e.subscribeMessage((e=>t(e)),Object.assign({type:"render_template"},i));var A,S;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(A||(A={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(S||(S={}));var M=function(e){if(e.time_format===S.language||e.time_format===S.system){var t=e.time_format===S.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===S.am_pm},E=function(e,t){return P(t).format(e)},P=function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",hour12:M(e)})},I=function(e,t){return k(t).format(e)},k=function(e){return new Intl.DateTimeFormat(e.language,{hour:M(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:M(e)})};function z(e){return e.substr(0,e.indexOf("."))}function L(e){return z(e.entity_id)}const D=["climate","humidifier","input_datetime","thermostat","water_heater","person","device_tracker"];class F{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const R=(e,t)=>!e.states[t]||D.includes(z(t)),B=(e,t,i,r)=>{const n={type:"history/history_during_period",start_time:t.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!r.some((t=>R(e,t)))};return 0!==r.length?e.callWS(Object.assign(Object.assign({},n),{entity_ids:r})):e.callWS(n)},O=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=n?n:!r.some((t=>R(e,t)))},l=new F(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},j=(e,t,i,r,n)=>{const o={type:"history/stream",entity_ids:n,start_time:i.toISOString(),end_time:r.toISOString(),minimal_response:!1,no_attributes:!1,significant_changes_only:!1},a=new F(e);return e.connection.subscribeMessage((e=>t(a.processMessage(e))),o)},$=globalThis,N=$.ShadowRoot&&(void 0===$.ShadyCSS||$.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),U=new WeakMap;let q=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==V)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(N&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=U.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&U.set(t,e))}return e}toString(){return this.cssText}};const Z=e=>new q("string"==typeof e?e:e+"",void 0,V),G=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1]),e[0]);return new q(i,e,V)},H=(e,t)=>{if(N)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=$.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},W=N?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Z(t)})(e):e
1
+ function e(e,t,i,r){var n,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,i,a):n(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}console.groupCollapsed("%cπŸ“ EXTRA-MAP-CARD πŸ—ΊοΈ%cv1.3.3","background-color: #434347;color: #fff;padding: 2px 4px;border: 1px solid #434347;border-radius: 2px 0 0 2px;font-family: Roboto,Verdana,Geneva,sans-serif;text-shadow: 0 1px 0 rgba(1, 1, 1, 0.3)","background-color: transparent;color: #434347;padding: 2px 3px;border: 1px solid #434347; border-radius: 0 2px 2px 0;font-family: Roboto,Verdana,Geneva,sans-serif"),console.info("Lovelace custom map card for Home Assistant"),console.info("Github: git+https://github.com/ngocjohn/extra-map-card.git"),console.info("If you like the card, consider supporting the developer: https://github.com/sponsors/ngocjohn"),console.groupEnd(),"function"==typeof SuppressedError&&SuppressedError;const t=(e,t)=>e&&e.config.components.includes(t);function i(){let e=document.querySelector("home-assistant");if(e=e&&e.shadowRoot,e=e&&e.querySelector("home-assistant-main"),e=e&&e.shadowRoot,e=e&&e.querySelector("app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver"),e=e&&e.shadowRoot||e,e=e&&e.querySelector("ha-panel-lovelace"),e=e&&e.shadowRoot,e=e&&e.querySelector("hui-root"),e){const t=e.lovelace;return t.current_view=e.___curView,t}return null}const r=e=>{let t=e;for(;t;){if("HUI-CARD-OPTIONS"===t.tagName)return t;t=t.parentNode}return t};function n(e){const t=i();return t?(t.setEditMode(!0),new Promise((i=>{setTimeout((()=>{const n=r(e.parentNode);if(!n)return t.setEditMode(!1),void i(null);const o=n.__path,a=`${n.lovelace.urlPath}-${o.join("-")}`;t.setEditMode(!1),i(a)}),100)}))):Promise.reject("Lovelace not found")}const o=e=>2===e.length?{viewIndex:e[0],cardIndex:e[1]}:{viewIndex:e[0],sectionIndex:e[1],cardIndex:e[2]},a=e=>1===e.length?{viewIndex:e[0]}:{viewIndex:e[0],sectionIndex:e[1]},s=e=>e.slice(0,-1),l=(e,t)=>{var i;const{viewIndex:r,sectionIndex:n}=a(t),o=e.views[r];if(!o)throw new Error("View does not exist");if(void 0===n)return o;if(g(o))throw new Error("Can not find section in a strategy view");const s=null===(i=o.sections)||void 0===i?void 0:i[n];if(!s)throw new Error("Section does not exist");return s},c=(e,t)=>{var i;const{viewIndex:r,sectionIndex:n}=a(t),o=e.views[r];if(!o)throw new Error("View does not exist");if(g(o))throw new Error("Can not find cards in a strategy view");if(void 0===n)return o.cards;const s=null===(i=o.sections)||void 0===i?void 0:i[n];if(!s)throw new Error("Section does not exist");if(y(s))throw new Error("Can not find cards in a strategy section");return s.cards},u=(e,t,i)=>{const{viewIndex:r,sectionIndex:n}=a(t);let o=!1;const s=e.views.map(((e,t)=>{if(t!==r)return e;if(void 0===n)return o=!0,i;if(g(e))throw new Error("Can not update section in a strategy view");if(void 0===e.sections)throw new Error("Section does not exist");const a=e.sections.map(((e,t)=>t!==n?e:(o=!0,i)));return Object.assign(Object.assign({},e),{sections:a})}));if(!o)throw new Error("Can not update cards in a non-existing view/section");return Object.assign(Object.assign({},e),{views:s})},h=(e,t,i)=>{const{viewIndex:r,sectionIndex:n}=a(t);let o=!1;const s=e.views.map(((e,t)=>{if(t!==r)return e;if(g(e))throw new Error("Can not update cards in a strategy view");if(void 0===n)return o=!0,Object.assign(Object.assign({},e),{cards:i});if(void 0===e.sections)throw new Error("Section does not exist");const a=e.sections.map(((e,t)=>{if(t!==n)return e;if(y(e))throw new Error("Can not update cards in a strategy section");return o=!0,Object.assign(Object.assign({},e),{cards:i})}));return Object.assign(Object.assign({},e),{sections:a})}));if(!o)throw new Error("Can not update cards in a non-existing view/section");return Object.assign(Object.assign({},e),{views:s})};function p(e){return"strategy"in e}const d=(e,t,i)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:i}),f=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),m=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t});function g(e){return"strategy"in e}function y(e){return"strategy"in e}const _=e=>"string"==typeof e?{type:"entity",entity:e,show_name:!0}:"type"in e&&e.type?e:Object.assign({type:"entity"},e),v=e=>e.sendMessagePromise({type:"lovelace/resources"}),b=(e,t)=>e.callWS(Object.assign({type:"lovelace/resources/create"},t)),x=(e,t,i)=>e.callWS(Object.assign({type:"lovelace/resources/update",resource_id:t},i)),w=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),C=(e,t,i,r)=>{r=r||{},i=null==i?{}:i;const n=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return n.detail=i,e.dispatchEvent(n),n},T=(e,t,i)=>e.subscribeMessage((e=>t(e)),Object.assign({type:"render_template"},i));var A,S;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(A||(A={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(S||(S={}));var M=function(e){if(e.time_format===S.language||e.time_format===S.system){var t=e.time_format===S.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===S.am_pm},E=function(e,t){return P(t).format(e)},P=function(e){return new Intl.DateTimeFormat(e.language,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"2-digit",hour12:M(e)})},I=function(e,t){return k(t).format(e)},k=function(e){return new Intl.DateTimeFormat(e.language,{hour:M(e)?"numeric":"2-digit",minute:"2-digit",second:"2-digit",hour12:M(e)})};function z(e){return e.substr(0,e.indexOf("."))}function L(e){return z(e.entity_id)}const D=["climate","humidifier","input_datetime","thermostat","water_heater","person","device_tracker"];class F{constructor(e,t){this.hass=e,this.hoursToShow=t,this.combinedHistory={}}processMessage(e){if(!this.combinedHistory||!Object.keys(this.combinedHistory).length)return this.combinedHistory=e.states,this.combinedHistory;if(!Object.keys(e.states).length)return this.combinedHistory;const t=this.hoursToShow?((new Date).getTime()-3600*this.hoursToShow*1e3)/1e3:void 0,i={};for(const e of Object.keys(this.combinedHistory))i[e]=[];for(const t of Object.keys(e.states))i[t]=[];for(const r of Object.keys(i)){if(r in this.combinedHistory&&r in e.states){const t=this.combinedHistory[r],n=t[t.length-1];i[r]=t.concat(e.states[r]),e.states[r][0].lu<n.lu&&(i[r]=i[r].sort(((e,t)=>e.lu-t.lu)))}else r in this.combinedHistory?i[r]=this.combinedHistory[r]:i[r]=e.states[r];if(t&&r in this.combinedHistory){const e=i[r].filter((e=>e.lu<t));if(!e.length)continue;if(i[r]=i[r].filter((e=>e.lu>=t)),i[r].length&&i[r][0].lu===t)continue;const n=e[e.length-1];n.lu=t,i[r].unshift(n)}}return this.combinedHistory=i,this.combinedHistory}}const R=(e,t)=>!e.states[t]||D.includes(z(t)),B=(e,t,i,r)=>{const n={type:"history/history_during_period",start_time:t.toISOString(),end_time:i.toISOString(),minimal_response:!0,no_attributes:!r.some((t=>R(e,t)))};return 0!==r.length?e.callWS(Object.assign(Object.assign({},n),{entity_ids:r})):e.callWS(n)},O=(e,t,i,r,n,o=!0,a=!0)=>{const s={type:"history/stream",entity_ids:r,start_time:new Date((new Date).getTime()-3600*i*1e3).toISOString(),minimal_response:o,significant_changes_only:a,no_attributes:null!=n?n:!r.some((t=>R(e,t)))},l=new F(e,i);return e.connection.subscribeMessage((e=>t(l.processMessage(e))),s)},j=(e,t,i,r,n)=>{const o={type:"history/stream",entity_ids:n,start_time:i.toISOString(),end_time:r.toISOString(),minimal_response:!1,no_attributes:!1,significant_changes_only:!1},a=new F(e);return e.connection.subscribeMessage((e=>t(a.processMessage(e))),o)},$=globalThis,N=$.ShadowRoot&&(void 0===$.ShadyCSS||$.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),U=new WeakMap;let q=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==V)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(N&&void 0===e){const i=void 0!==t&&1===t.length;i&&(e=U.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&U.set(t,e))}return e}toString(){return this.cssText}};const Z=e=>new q("string"==typeof e?e:e+"",void 0,V),G=(e,...t)=>{const i=1===e.length?e[0]:t.reduce(((t,i,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1]),e[0]);return new q(i,e,V)},H=(e,t)=>{if(N)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=$.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},W=N?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Z(t)})(e):e
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
@@ -216,12 +216,12 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
216
216
  font-weight: 300;
217
217
  font-size: 16px;
218
218
  max-width: calc(100% - 80px);
219
- }`,Hh=6371008.8,Wh={centimeters:100*Hh,centimetres:100*Hh,degrees:360/(2*Math.PI),feet:3.28084*Hh,inches:39.37*Hh,kilometers:Hh/1e3,kilometres:Hh/1e3,meters:Hh,metres:Hh,miles:Hh/1609.344,millimeters:1e3*Hh,millimetres:1e3*Hh,nauticalmiles:Hh/1852,radians:1,yards:1.0936*Hh};function Kh(e,t,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=t||{},r.geometry=e,r}function Xh(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tp(e[0])||!tp(e[1]))throw new Error("coordinates must contain numbers");return Kh({type:"Point",coordinates:e},t,i)}function Yh(e,t,i={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return Kh({type:"Polygon",coordinates:e},t,i)}function Jh(e,t="kilometers"){const i=Wh[t];if(!i)throw new Error(t+" units is invalid");return e/i}function Qh(e){return 180*(e%(2*Math.PI))/Math.PI}function ep(e){return e%360*Math.PI/180}function tp(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ip(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function rp(e,t,i,r={}){const n=ip(e),o=ep(n[0]),a=ep(n[1]),s=ep(i),l=Jh(t,r.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s));return Xh([Qh(o+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),Qh(c)],r.properties)}function np(e,t,i={}){const r=i.steps||64,n=i.properties?i.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},o=[];for(let n=0;n<r;n++)o.push(rp(e,t,-360*n/r,i).geometry.coordinates);return o.push(o[0]),Yh([o],n)}var op="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",ap="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",sp="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",lp="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",cp="1.3.1";const up=cp,hp=[{name:"Navigation and city exploration",selector:{select:{options:["STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL"]}}},{name:"Data visualization",selector:{select:{options:["DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT"]}}},{name:"Minimalist and general purpose",selector:{select:{options:["BASIC","BASIC.DARK","BASIC.LIGHT"]}}},{name:"High contrast navigation",selector:{select:{options:["BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL"]}}},{name:"Topographic study",selector:{select:{options:["TOPO","TOPO.SHINY","TOPO.PASTEL","TOPO.TOPOGRAPHIQUE"]}}},{name:"Minimalist",selector:{select:{options:["VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE"]}}},{name:"High contrast",selector:{select:{options:["TONER","TONER.BACKGROUND","TONER.LITE","TONER.LINES"]}}},{name:"Neutral greyscale style with hillshading",selector:{select:{options:["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT"]}}},{name:"Other",selector:{select:{options:["OPENSTREETMAP","OUTDOOR","WINTER","SATELLITE","HYBRID"]}}}],pp=["STREETS","BASIC","BRIGHT","DATAVIZ","VOYAGER","BACKDROP"],dp=()=>hp.reduce(((e,t)=>{const i=t.selector.select.options;return e.concat(i.map((e=>({value:e,label:e}))))}),[]),fp=dp(),mp=0,gp=13,yp=["auto","light","dark"],_p=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:gp,selector:{number:{mode:"box",min:0}}},{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:yp.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show",label:"Hours to Show",default:0,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",default:"",selector:{select:{mode:"dropdown",options:[{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"}]}}},{name:"auto_fit",label:"Auto Fit",default:!1,selector:{boolean:{}}},{name:"fit_zones",label:"Fit Zones",default:!1,selector:{boolean:{}}},{name:"use_more_info",label:"Marker more info",default:!1,selector:{boolean:{}}}],vp={name:"custom_styles",type:"expandable",iconPath:sp,title:"Custom Styles",schema:[{name:"",type:"grid",schema:[{name:"light",label:"Light Style",selector:{select:{mode:"dropdown",options:fp}}},{name:"dark",label:"Dark Style",selector:{select:{mode:"dropdown",options:fp}}}]}]},bp=st((e=>[{name:"",type:"expandable",iconPath:sp,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[..._p]},vp]}])),xp=st((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),wp=st((e=>[...xp(),...bp(e)])),Cp=Symbol.for("constructDateFrom");function Tp(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Cp in e?e[Cp](t):e instanceof Date?new e.constructor(t):new Date(t)}function Ap(e,t){return Tp(e,e)}function Sp(e,...t){const i=Tp.bind(null,t.find((e=>"object"==typeof e)));return t.map(i)}function Mp(e,t){const i=Ap(e);return i.setHours(0,0,0,0),i}function Ep(e){return Tp(e,Date.now())}function Pp(e,t,i){const[r,n]=Sp(i?.in,e,t);return+Mp(r)==+Mp(n)}function Ip(e,t){return Pp(Tp(e,e),Ep(e))}const kp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],zp=1,Lp=8;class Dp{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=kp[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Dp(a,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=kp.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Fp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:a}=this,s=[0,n.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=a){for(let a=h;a<=u;a++){const s=o[2*a],c=o[2*a+1];s>=e&&s<=i&&c>=t&&c<=r&&l.push(n[a])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=e&&d<=i&&f>=t&&f<=r&&l.push(n[p]),(0===c?e<=d:t<=f)&&(s.push(h),s.push(p-1),s.push(1-c)),(0===c?i>=d:r>=f)&&(s.push(p+1),s.push(u),s.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=i*i;for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)jp(n[2*i],n[2*i+1],e,t)<=l&&s.push(r[i]);continue}const p=h+u>>1,d=n[2*p],f=n[2*p+1];jp(d,f,e,t)<=l&&s.push(r[p]),(0===c?e-i<=d:t-i<=f)&&(a.push(h),a.push(p-1),a.push(1-c)),(0===c?e+i>=d:t+i>=f)&&(a.push(p+1),a.push(u),a.push(1-c))}return s}}function Fp(e,t,i,r,n,o){if(n-r<=i)return;const a=r+n>>1;Rp(e,t,a,r,n,o),Fp(e,t,i,r,a-1,1-o),Fp(e,t,i,a+1,n,1-o)}function Rp(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const a=n-r+1,s=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);Rp(e,t,i,Math.max(r,Math.floor(i-s*c/a+u)),Math.min(n,Math.floor(i+(a-s)*c/a+u)),o)}const a=t[2*i+o];let s=r,l=n;for(Bp(e,t,r,i),t[2*n+o]>a&&Bp(e,t,r,n);s<l;){for(Bp(e,t,s,l),s++,l--;t[2*s+o]<a;)s++;for(;t[2*l+o]>a;)l--}t[2*r+o]===a?Bp(e,t,r,l):(l++,Bp(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Bp(e,t,i,r){Op(e,i,r),Op(t,2*i,2*r),Op(t,2*i+1,2*r+1)}function Op(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function jp(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const $p={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Np=Math.fround||(e=>t=>(e[0]=+t,e[0]))(new Float32Array(1)),Vp=2,Up=3,qp=4,Zp=5,Gp=6;class Hp{constructor(e){this.options=Object.assign(Object.create($p),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,a=Np(Xp(r)),s=Np(Yp(n));o.push(a,s,1/0,t,-1,1),this.options.reduce&&o.push(0)}let a=this.trees[r+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=r;e>=i;e--){Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e))}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),a=this.getClusters([-180,r,n,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(Xp(i),Yp(o),Xp(n),Yp(r)),l=a.data,c=[];for(const e of s){const t=this.stride*e;c.push(l[t+5]>1?Wp(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=o[t*this.stride],l=o[t*this.stride+1],c=n.within(s,l,a),u=[];for(const t of c){const i=t*this.stride;o[i+4]===e&&u.push(o[i+5]>1?Wp(o,i,this.clusterProps):this.points[o[i+3]])}if(0===u.length)throw new Error(r);return u}getLeaves(e,t,i){t=t||10,i=i||0;const r=[];return this._appendLeaves(r,e,t,i,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(i-s)/n,c=(i+1+s)/n,u={features:[]};return this._addTileFeatures(r.range((t-s)/n,l,(t+1+s)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_createTree(e){const t=new Dp(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.data=e,t}_addTileFeatures(e,t,i,r,n,o){for(const a of e){const e=a*this.stride,s=t[e+5]>1;let l,c,u;if(s)l=Kp(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=Xp(r),u=Yp(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let p;p=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,a=i/(r*Math.pow(2,t)),s=e.data,l=[],c=this.stride;for(let i=0;i<s.length;i+=c){if(s[i+2]<=t)continue;s[i+2]=t;const r=s[i],u=s[i+1],h=e.within(s[i],s[i+1],a),p=s[i+5];let d=p;for(const e of h){const i=e*c;s[i+2]>t&&(d+=s[i+5])}if(d>p&&d>=o){let e,o=r*p,a=u*p,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(s[l+2]<=t)continue;s[l+2]=t;const u=s[l+5];o+=s[l]*u,a+=s[l+1]*u,s[l+4]=m,n&&(e||(e=this._map(s,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(s,l)))}s[i+4]=m,l.push(o/d,a/d,1/0,m,-1,d),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(s[i+e]);if(d>1)for(const e of h){const i=e*c;if(!(s[i+2]<=t)){s[i+2]=t;for(let e=0;e<c;e++)l.push(s[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function Wp(e,t,i){return{type:"Feature",id:e[t+3],properties:Kp(e,t,i),geometry:{type:"Point",coordinates:[Jp(e[t]),Qp(e[t+1])]}}}function Kp(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],a=-1===o?{}:Object.assign({},i[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}function Xp(e){return e/360+.5}function Yp(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function Jp(e){return 360*(e-.5)}function Qp(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}const ed=window.loadCardHelpers?window.loadCardHelpers():void 0,td=()=>{var e,t,i,r,n,o;customElements.get("ha-entity-marker")||null===(e=customElements.get("hui-map-card"))||void 0===e||e.getConfigElement(),customElements.get("ha-form")||null===(t=customElements.get("hui-button-card"))||void 0===t||t.getConfigElement(),customElements.get("ha-entity-picker")||null===(i=customElements.get("hui-entities-card"))||void 0===i||i.getConfigElement(),customElements.get("ha-card-conditions-editor")||null===(r=customElements.get("hui-conditional-card"))||void 0===r||r.getConfigElement(),customElements.get("ha-form-multi_select")||null===(n=customElements.get("hui-entities-card"))||void 0===n||n.getConfigElement(),customElements.get("hui-entity-editor")||null===(o=customElements.get("hui-glance-card"))||void 0===o||o.getConfigElement()},id=async e=>{if(!customElements.get("ha-entity-marker")){const t={type:"map",entities:e,theme_mode:"auto"};let i;if(window.loadCardHelpers?i=await window.loadCardHelpers():ed&&(i=ed),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var rd,nd,od,ad,sd,ld,cd,ud;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(rd||(rd={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(nd||(nd={})),function(e){e.local="local",e.server="server"}(od||(od={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(ad||(ad={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(sd||(sd={}));const hd=e=>"string"==typeof e?e:e.entity_id,pd=st((async(e,t,i)=>{const r={address:"streetName",locality:"sublocality",municipality:"city"},n=`https://api.maptiler.com/geocoding/${t},${e}.json?key=${i}`;try{const e=await fetch(n);if(!e.ok)throw new Error("Failed to fetch address from MapTiler");const t=await e.json();if(t&&t.features&&t.features.length>0){let e={};if(t.features.forEach((t=>{const i=t.place_type[0];if(r[i]){const n=r[i],o=t.text;"address"===i&&(e.streetNumber=t.address?`${t.address}`:""),e[n]=`${o}`}})),e.streetName&&e.city)return e}return null}catch(e){return console.warn("Error fetching address from MapTiler:",e),null}})),dd=null===(ud=null===(ld=Intl.DateTimeFormat)||void 0===ld?void 0:(cd=ld.call(Intl)).resolvedOptions)||void 0===ud?void 0:ud.call(cd).timeZone,fd=null!=dd?dd:"UTC",md=(e,t)=>e===od.local&&dd?fd:t,gd=st((e=>{if(e.time_format===nd.language||e.time_format===nd.system){const t=e.time_format===nd.language?e.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(t).includes("10")}return e.time_format===nd.am_pm})),yd=(e,t,i)=>_d(t,i.time_zone).format(e),_d=st(((e,t)=>new Intl.DateTimeFormat(e.language,{weekday:"long",hour:gd(e)?"numeric":"2-digit",minute:"2-digit",hour12:gd(e),timeZone:md(e.time_zone,t)}))),vd={dark:ti.STREETS.DARK,light:ti.DATAVIZ.LIGHT,demo:"https://demotiles.maplibre.org/style.json"},bd={backgroundColor:{light:"#fff",dark:"#222222"},fill:{light:"#222222",dark:"#c1c1c1"},boxShadow:{light:"0 0 0 2px rgba(0, 0, 0, 0.1)",dark:"0 0 0 2px rgba(255, 255, 255, 0.1)"},borderTop:{light:"1px solid #ddd",dark:"1px solid #424242"},themeBtn:{light:"mdi:weather-sunny",dark:"mdi:weather-night"}};class xd extends Xe{constructor(){super(...arguments),this.autoFit=!1,this.fitZones=!1,this.zoom=gp,this.themeMode="auto",this.useMoreInfo=!1,this._darkStyle=!1,this._mapItems=[],this._zoneItems=[],this._mapFocusZones=[],this._mapFocusItems=[],this._mapPaths=[],this._mapHelper=yh,this._clusters=[],this._mapClusterItems=[],this._mapClusterFocusItems=[],this._circleLoaded=!1,this._loaded=!1,this._entitiesDrawn=!1,this._createButton=(e,t)=>{const i=document.createElement("div");i.classList.add("maplibregl-ctrl","maplibregl-ctrl-group");const r=document.createElement("button"),n=document.createElement("ha-icon");return n.setAttribute("icon",e),n.style.color="var(--emc-btn-color)",r.appendChild(n),r.title=t,i.appendChild(r),i.style.display="none",i},this.getModeColor=(e,t)=>t?bd[e][t]:this._darkMode?bd[e].dark:bd[e].light}get _darkMode(){return"dark"===this.themeMode||"auto"===this.themeMode&&Boolean(this.hass.themes.darkMode)}async firstUpdated(){await id(this.entities),await new Promise((e=>setTimeout(e,0))),this._initMap()}render(){const e=this._renderLoadError();return ke`
219
+ }`,Hh=6371008.8,Wh={centimeters:100*Hh,centimetres:100*Hh,degrees:360/(2*Math.PI),feet:3.28084*Hh,inches:39.37*Hh,kilometers:Hh/1e3,kilometres:Hh/1e3,meters:Hh,metres:Hh,miles:Hh/1609.344,millimeters:1e3*Hh,millimetres:1e3*Hh,nauticalmiles:Hh/1852,radians:1,yards:1.0936*Hh};function Kh(e,t,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=t||{},r.geometry=e,r}function Xh(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tp(e[0])||!tp(e[1]))throw new Error("coordinates must contain numbers");return Kh({type:"Point",coordinates:e},t,i)}function Yh(e,t,i={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return Kh({type:"Polygon",coordinates:e},t,i)}function Jh(e,t="kilometers"){const i=Wh[t];if(!i)throw new Error(t+" units is invalid");return e/i}function Qh(e){return 180*(e%(2*Math.PI))/Math.PI}function ep(e){return e%360*Math.PI/180}function tp(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ip(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function rp(e,t,i,r={}){const n=ip(e),o=ep(n[0]),a=ep(n[1]),s=ep(i),l=Jh(t,r.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s));return Xh([Qh(o+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),Qh(c)],r.properties)}function np(e,t,i={}){const r=i.steps||64,n=i.properties?i.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},o=[];for(let n=0;n<r;n++)o.push(rp(e,t,-360*n/r,i).geometry.coordinates);return o.push(o[0]),Yh([o],n)}var op="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",ap="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",sp="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",lp="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",cp="1.3.3";const up=cp,hp=[{name:"Navigation and city exploration",selector:{select:{options:["STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL"]}}},{name:"Data visualization",selector:{select:{options:["DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT"]}}},{name:"Minimalist and general purpose",selector:{select:{options:["BASIC","BASIC.DARK","BASIC.LIGHT"]}}},{name:"High contrast navigation",selector:{select:{options:["BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL"]}}},{name:"Topographic study",selector:{select:{options:["TOPO","TOPO.SHINY","TOPO.PASTEL","TOPO.TOPOGRAPHIQUE"]}}},{name:"Minimalist",selector:{select:{options:["VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE"]}}},{name:"High contrast",selector:{select:{options:["TONER","TONER.BACKGROUND","TONER.LITE","TONER.LINES"]}}},{name:"Neutral greyscale style with hillshading",selector:{select:{options:["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT"]}}},{name:"Other",selector:{select:{options:["OPENSTREETMAP","OUTDOOR","WINTER","SATELLITE","HYBRID"]}}}],pp=["STREETS","BASIC","BRIGHT","DATAVIZ","VOYAGER","BACKDROP"],dp=()=>hp.reduce(((e,t)=>{const i=t.selector.select.options;return e.concat(i.map((e=>({value:e,label:e}))))}),[]),fp=dp(),mp=0,gp=13,yp=["auto","light","dark"],_p=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:gp,selector:{number:{mode:"box",min:0}}},{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:yp.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show",label:"Hours to Show",default:0,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",default:"",selector:{select:{mode:"dropdown",options:[{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"}]}}},{name:"auto_fit",label:"Auto Fit",default:!1,selector:{boolean:{}}},{name:"fit_zones",label:"Fit Zones",default:!1,selector:{boolean:{}}},{name:"use_more_info",label:"Marker more info",default:!1,selector:{boolean:{}}}],vp={name:"custom_styles",type:"expandable",iconPath:sp,title:"Custom Styles",schema:[{name:"",type:"grid",schema:[{name:"light",label:"Light Style",selector:{select:{mode:"dropdown",options:fp}}},{name:"dark",label:"Dark Style",selector:{select:{mode:"dropdown",options:fp}}}]}]},bp=st((e=>[{name:"",type:"expandable",iconPath:sp,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[..._p]},vp]}])),xp=st((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),wp=st((e=>[...xp(),...bp(e)])),Cp=Symbol.for("constructDateFrom");function Tp(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Cp in e?e[Cp](t):e instanceof Date?new e.constructor(t):new Date(t)}function Ap(e,t){return Tp(e,e)}function Sp(e,...t){const i=Tp.bind(null,t.find((e=>"object"==typeof e)));return t.map(i)}function Mp(e,t){const i=Ap(e);return i.setHours(0,0,0,0),i}function Ep(e){return Tp(e,Date.now())}function Pp(e,t,i){const[r,n]=Sp(i?.in,e,t);return+Mp(r)==+Mp(n)}function Ip(e,t){return Pp(Tp(e,e),Ep(e))}const kp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],zp=1,Lp=8;class Dp{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=kp[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Dp(a,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=kp.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Fp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:a}=this,s=[0,n.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=a){for(let a=h;a<=u;a++){const s=o[2*a],c=o[2*a+1];s>=e&&s<=i&&c>=t&&c<=r&&l.push(n[a])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=e&&d<=i&&f>=t&&f<=r&&l.push(n[p]),(0===c?e<=d:t<=f)&&(s.push(h),s.push(p-1),s.push(1-c)),(0===c?i>=d:r>=f)&&(s.push(p+1),s.push(u),s.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=i*i;for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)jp(n[2*i],n[2*i+1],e,t)<=l&&s.push(r[i]);continue}const p=h+u>>1,d=n[2*p],f=n[2*p+1];jp(d,f,e,t)<=l&&s.push(r[p]),(0===c?e-i<=d:t-i<=f)&&(a.push(h),a.push(p-1),a.push(1-c)),(0===c?e+i>=d:t+i>=f)&&(a.push(p+1),a.push(u),a.push(1-c))}return s}}function Fp(e,t,i,r,n,o){if(n-r<=i)return;const a=r+n>>1;Rp(e,t,a,r,n,o),Fp(e,t,i,r,a-1,1-o),Fp(e,t,i,a+1,n,1-o)}function Rp(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const a=n-r+1,s=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);Rp(e,t,i,Math.max(r,Math.floor(i-s*c/a+u)),Math.min(n,Math.floor(i+(a-s)*c/a+u)),o)}const a=t[2*i+o];let s=r,l=n;for(Bp(e,t,r,i),t[2*n+o]>a&&Bp(e,t,r,n);s<l;){for(Bp(e,t,s,l),s++,l--;t[2*s+o]<a;)s++;for(;t[2*l+o]>a;)l--}t[2*r+o]===a?Bp(e,t,r,l):(l++,Bp(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Bp(e,t,i,r){Op(e,i,r),Op(t,2*i,2*r),Op(t,2*i+1,2*r+1)}function Op(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function jp(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const $p={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Np=Math.fround||(e=>t=>(e[0]=+t,e[0]))(new Float32Array(1)),Vp=2,Up=3,qp=4,Zp=5,Gp=6;class Hp{constructor(e){this.options=Object.assign(Object.create($p),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,a=Np(Xp(r)),s=Np(Yp(n));o.push(a,s,1/0,t,-1,1),this.options.reduce&&o.push(0)}let a=this.trees[r+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=r;e>=i;e--){Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e))}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),a=this.getClusters([-180,r,n,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(Xp(i),Yp(o),Xp(n),Yp(r)),l=a.data,c=[];for(const e of s){const t=this.stride*e;c.push(l[t+5]>1?Wp(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=o[t*this.stride],l=o[t*this.stride+1],c=n.within(s,l,a),u=[];for(const t of c){const i=t*this.stride;o[i+4]===e&&u.push(o[i+5]>1?Wp(o,i,this.clusterProps):this.points[o[i+3]])}if(0===u.length)throw new Error(r);return u}getLeaves(e,t,i){t=t||10,i=i||0;const r=[];return this._appendLeaves(r,e,t,i,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(i-s)/n,c=(i+1+s)/n,u={features:[]};return this._addTileFeatures(r.range((t-s)/n,l,(t+1+s)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_createTree(e){const t=new Dp(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.data=e,t}_addTileFeatures(e,t,i,r,n,o){for(const a of e){const e=a*this.stride,s=t[e+5]>1;let l,c,u;if(s)l=Kp(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=Xp(r),u=Yp(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let p;p=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,a=i/(r*Math.pow(2,t)),s=e.data,l=[],c=this.stride;for(let i=0;i<s.length;i+=c){if(s[i+2]<=t)continue;s[i+2]=t;const r=s[i],u=s[i+1],h=e.within(s[i],s[i+1],a),p=s[i+5];let d=p;for(const e of h){const i=e*c;s[i+2]>t&&(d+=s[i+5])}if(d>p&&d>=o){let e,o=r*p,a=u*p,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(s[l+2]<=t)continue;s[l+2]=t;const u=s[l+5];o+=s[l]*u,a+=s[l+1]*u,s[l+4]=m,n&&(e||(e=this._map(s,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(s,l)))}s[i+4]=m,l.push(o/d,a/d,1/0,m,-1,d),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(s[i+e]);if(d>1)for(const e of h){const i=e*c;if(!(s[i+2]<=t)){s[i+2]=t;for(let e=0;e<c;e++)l.push(s[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function Wp(e,t,i){return{type:"Feature",id:e[t+3],properties:Kp(e,t,i),geometry:{type:"Point",coordinates:[Jp(e[t]),Qp(e[t+1])]}}}function Kp(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],a=-1===o?{}:Object.assign({},i[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}function Xp(e){return e/360+.5}function Yp(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function Jp(e){return 360*(e-.5)}function Qp(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}const ed=window.loadCardHelpers?window.loadCardHelpers():void 0,td=()=>{var e,t,i,r,n,o;customElements.get("ha-entity-marker")||null===(e=customElements.get("hui-map-card"))||void 0===e||e.getConfigElement(),customElements.get("ha-form")||null===(t=customElements.get("hui-button-card"))||void 0===t||t.getConfigElement(),customElements.get("ha-entity-picker")||null===(i=customElements.get("hui-entities-card"))||void 0===i||i.getConfigElement(),customElements.get("ha-card-conditions-editor")||null===(r=customElements.get("hui-conditional-card"))||void 0===r||r.getConfigElement(),customElements.get("ha-form-multi_select")||null===(n=customElements.get("hui-entities-card"))||void 0===n||n.getConfigElement(),customElements.get("hui-entity-editor")||null===(o=customElements.get("hui-glance-card"))||void 0===o||o.getConfigElement()},id=async e=>{if(!customElements.get("ha-entity-marker")){const t={type:"map",entities:e,theme_mode:"auto"};let i;if(window.loadCardHelpers?i=await window.loadCardHelpers():ed&&(i=ed),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var rd,nd,od,ad,sd,ld,cd,ud;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(rd||(rd={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(nd||(nd={})),function(e){e.local="local",e.server="server"}(od||(od={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(ad||(ad={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(sd||(sd={}));const hd=e=>"string"==typeof e?e:e.entity_id,pd=st((async(e,t,i)=>{const r={address:"streetName",locality:"sublocality",municipality:"city"},n=`https://api.maptiler.com/geocoding/${t},${e}.json?key=${i}`;try{const e=await fetch(n);if(!e.ok)throw new Error("Failed to fetch address from MapTiler");const t=await e.json();if(t&&t.features&&t.features.length>0){let e={};if(t.features.forEach((t=>{const i=t.place_type[0];if(r[i]){const n=r[i],o=t.text;"address"===i&&(e.streetNumber=t.address?`${t.address}`:""),e[n]=`${o}`}})),e.streetName&&e.city)return e}return null}catch(e){return console.warn("Error fetching address from MapTiler:",e),null}})),dd=null===(ud=null===(ld=Intl.DateTimeFormat)||void 0===ld?void 0:(cd=ld.call(Intl)).resolvedOptions)||void 0===ud?void 0:ud.call(cd).timeZone,fd=null!=dd?dd:"UTC",md=(e,t)=>e===od.local&&dd?fd:t,gd=st((e=>{if(e.time_format===nd.language||e.time_format===nd.system){const t=e.time_format===nd.language?e.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(t).includes("10")}return e.time_format===nd.am_pm})),yd=(e,t,i)=>_d(t,i.time_zone).format(e),_d=st(((e,t)=>new Intl.DateTimeFormat(e.language,{weekday:"long",hour:gd(e)?"numeric":"2-digit",minute:"2-digit",hour12:gd(e),timeZone:md(e.time_zone,t)}))),vd={dark:ti.STREETS.DARK,light:ti.DATAVIZ.LIGHT,demo:"https://demotiles.maplibre.org/style.json"},bd={backgroundColor:{light:"#fff",dark:"#222222"},fill:{light:"#222222",dark:"#c1c1c1"},boxShadow:{light:"0 0 0 2px rgba(0, 0, 0, 0.1)",dark:"0 0 0 2px rgba(255, 255, 255, 0.1)"},borderTop:{light:"1px solid #ddd",dark:"1px solid #424242"},themeBtn:{light:"mdi:weather-sunny",dark:"mdi:weather-night"}};class xd extends Xe{constructor(){super(...arguments),this.autoFit=!1,this.fitZones=!1,this.zoom=gp,this.themeMode="auto",this.useMoreInfo=!1,this._darkStyle=!1,this._mapItems=[],this._zoneItems=[],this._mapFocusZones=[],this._mapFocusItems=[],this._mapPaths=[],this._mapHelper=yh,this._clusters=[],this._mapClusterItems=[],this._mapClusterFocusItems=[],this._circleLoaded=!1,this._loaded=!1,this._entitiesDrawn=!1,this._createButton=(e,t)=>{const i=document.createElement("div");i.classList.add("maplibregl-ctrl","maplibregl-ctrl-group");const r=document.createElement("button"),n=document.createElement("ha-icon");return n.setAttribute("icon",e),n.style.color="var(--emc-btn-color)",r.appendChild(n),r.title=t,i.appendChild(r),i.style.display="none",i},this.getModeColor=(e,t)=>t?bd[e][t]:this._darkMode?bd[e].dark:bd[e].light}get _darkMode(){return"dark"===this.themeMode||"auto"===this.themeMode&&Boolean(this.hass.themes.darkMode)}async firstUpdated(){await id(this.entities),await new Promise((e=>setTimeout(e,0))),this._initMap()}render(){const e=this._renderLoadError();return ke`
220
220
  <div class="maptiler-map">
221
221
  ${e}
222
222
  <div id="map"></div>
223
223
  </div>
224
- `}_renderLoadError(){if(!this._error)return ke``;const{code:e,message:t}=this._error;return ke` <ha-alert alert-type="${e}" id="error"> ${t} </ha-alert> `}updated(e){var t,i,r,n;if(super.updated(e),!this._loaded)return;let o=!1,a=!1;const s=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities(),o=!0,a=!0;else if(this._loaded&&s&&this.entities)for(const e of this.entities)if(s.states[hd(e)]!==this.hass.states[hd(e)]){this._circleLoaded=!1,this._drawEntities(),o=!0,a=!0;break}if((e.has("_loaded")||this.autoFit&&o)&&this._fitMap(),(e.has("_loaded")||this.paths&&this.paths.length&&a)&&this._drawPaths(),e.has("hass")&&s){if((null===(t=s.themes)||void 0===t?void 0:t.darkMode)!==(null===(i=this.hass.themes)||void 0===i?void 0:i.darkMode)){const e=this._getInitStyle();this._map.setStyle(e,{diff:!1})}}e.has("themeMode")||e.has("hass")&&(!s||(null===(r=s.themes)||void 0===r||r.darkMode,null===(n=this.hass.themes)||void 0===n||n.darkMode))}_drawEntities(){const e=this.hass,t=this._map;if(!t||!e)return;if(this._mapItems.length&&(this._mapItems.forEach((e=>e.remove())),this._mapItems=[],this._mapFocusItems=[]),this._mapClusterItems.length&&(this._clusterIndex=void 0,this._mapClusterItems.forEach((e=>e.remove())),this._mapClusterItems=[],this._mapClusterFocusItems=[]),this._zoneItems.length&&(this._zoneItems.forEach((e=>e.remove())),this._zoneItems=[],this._mapFocusZones=[]),!this.entities)return;this._entitiesDrawn&&(this._entitiesDrawn=!1);const i=[],r=[],n=getComputedStyle(this),o=n.getPropertyValue("--accent-color"),a=n.getPropertyValue("--secondary-text-color"),s=n.getPropertyValue("--dark-primary-color"),l=this._darkStyle?"dark":"light";for(const n of this.entities){const s=e.states[hd(n)];if(!s)continue;const c="string"!=typeof n?n.name:void 0,u=null!=c?c:pt(s),{latitude:h,longitude:p,passive:d,icon:f,radius:m,gps_accuracy:g}=s.attributes;if(!h||!p)continue;const y=[p,h];if("zone"!==L(s))i.push({type:"Feature",geometry:{type:"Point",coordinates:y},properties:{title:u,entity:n,entityId:hd(n),gpsAccuracy:g}});else{let e="";if(f){const t=document.createElement("ha-icon");t.setAttribute("icon",f),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=u,e=t.outerHTML}const i=np(y,m,{steps:150,units:"meters",properties:{color:d?a:o,title:u,opacity:d?.2:.3}});r.push(i);const s=document.createElement("div");s.className=`marker ${l}`,s.innerHTML=e,s.title=u;const c=new Xr({element:s}).setLngLat(y).addTo(t);this._zoneItems.push(c),!this.fitZones||"string"!=typeof n&&!1===n.focus||this._mapFocusZones.push(i.geometry)}}this._clusterIndex=new Hp({radius:100,maxZoom:11}),this._clusterIndex.load(i);const c=t.getBounds().toArray().flat(),u=Math.floor(t.getZoom()),h=this._clusterIndex.getClusters(c,u);for(const i of h){const[n,o]=i.geometry.coordinates;if(i.properties.cluster){const e=i.properties.point_count,r=i.properties.cluster_id,a=document.createElement("div");a.className="cluster-marker",a.innerHTML=`<div><span>${e.toString()}</span></div>`,a.addEventListener("click",(()=>{var e;try{const i=null===(e=this._clusterIndex)||void 0===e?void 0:e.getClusterExpansionZoom(r);void 0!==i&&t.easeTo({center:[n,o],zoom:i})}catch(e){}}));const s=new Xr({element:a}).setLngLat([n,o]).addTo(t);this._mapClusterItems.push(s),this._mapFocusItems.push(s),this._mapClusterFocusItems.push(s),this._mapItems.push(s)}else{const a=i.properties.entity,l=e.states[i.properties.entityId],c=i.properties.title,u=i.properties.gpsAccuracy,h="string"!=typeof a&&"state"===a.label_mode?this.hass.formatEntityState(l):"string"!=typeof a&&"attribute"===a.label_mode&&void 0!==a.attribute?this.hass.formatEntityAttributeValue(l,a.attribute):c.split(" ").map((e=>e[0])).join("").substring(0,3),p=document.createElement("ha-entity-marker");p.hass=this.hass,p.showIcon="string"!=typeof a&&"icon"===a.label_mode,p.entityId=hd(a),p.entityName=h,p.entityPicture=!l.attributes.entity_picture||"string"!=typeof a&&a.label_mode?"":this.hass.hassUrl(l.attributes.entity_picture),"string"!=typeof a&&(p.entityColor=a.color),p.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.preventDefault(),this.useMoreInfo&&C(this,"hass-more-info",{entityId:p.entityId})}),!0);const d=new Xr({element:p}).setLngLat([n,o]).addTo(t);if(this._mapItems.push(d),"string"!=typeof a&&!1===a.focus||this._mapFocusItems.push(d),u){const e=np([n,o],u,{steps:64,units:"meters",properties:{color:s,title:c,opacity:.5}});r.push(e)}}}const p={type:"geojson",data:{type:"FeatureCollection",features:r}};this._circleLoaded||(t.getLayer("circles")&&t.removeLayer("circles"),t.getLayer("circles-stroke")&&t.removeLayer("circles-stroke"),t.getSource("circles")&&t.removeSource("circles"),t.addSource("circles",p),t.addLayer({id:"circles",type:"fill",source:"circles",paint:{"fill-color":["get","color"],"fill-opacity":["get","opacity"]}}),t.addLayer({id:"circles-stroke",type:"line",source:"circles",paint:{"line-color":["get","color"],"line-width":2}}),this._circleLoaded=!0,this._entitiesDrawn=!0)}_computePathTooltip(e,t){let i;return i=e.fullDatetime?E(t.timestamp,this.hass.locale):Ip(t.timestamp)?I(t.timestamp,this.hass.locale):yd(t.timestamp,this.hass.locale,this.hass.config),`<b>${e.name}</b><br><i>${i}</i>`}_drawPaths(){const e=this.hass,t=this._map;if(!t||!e)return;if(!this.paths)return;this._mapPaths.length&&(this._mapPaths.forEach((e=>{t.removeLayer(e.id)})),this._mapPaths=[]);const i=getComputedStyle(this).getPropertyValue("--dark-primary-color"),r=[],n=[];this.paths.forEach((e=>{if(!e.points||e.points.length<2)return;let t,o;e.gradualOpacity&&(t=e.gradualOpacity/(e.points.length-2),o=1-e.gradualOpacity);for(let a=0;a<e.points.length-1;a++){const s=e.points[a].point,l=e.points[a+1].point,c=e.gradualOpacity?o+a*t:void 0,u=this._computePathTooltip(e,e.points[a]),h={type:"Feature",geometry:{type:"Point",coordinates:s},properties:{friendlyName:e.name,color:e.color||i,opacity:c,fillOpacity:c,lastUpdated:e.points[a].timestamp,popupContent:u}};n.push(h);const p={type:"Feature",geometry:{type:"LineString",coordinates:[s,l]},properties:{color:e.color||i,opacity:c,fillOpacity:c}};r.push(p)}}));const o={type:"geojson",data:{type:"FeatureCollection",features:n}},a={type:"geojson",data:{type:"FeatureCollection",features:r}};t.getSource("points")&&t.removeSource("points"),t.getSource("lines")&&t.removeSource("lines"),t.addSource("points",o),t.addSource("lines",a);const s={id:"lines",type:"line",source:"lines",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["get","color"],"line-width":2,"line-opacity":["get","opacity"]}},l={id:"points",type:"circle",source:"points",paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":1,"circle-stroke-color":["get","color"]}};t.addLayer(s),t.addLayer(l),this._mapPaths.push(s,l),this._setupPointInteraction()}_setupPointInteraction(){const e=this._map;if(!e)return;const t=new Yr({closeButton:!1,closeOnClick:!1,offset:8});let i;e.on("mousemove","points",(async r=>{var n;if(e.getZoom()<10)return e.getCanvas().style.cursor="",t.remove(),void(i=void 0);const o=null===(n=r.features)||void 0===n?void 0:n[0];if(!o)return;const a=o.geometry.coordinates.toString();if(i!==a){i=a,e.getCanvas().style.cursor="pointer";const n=r.features[0].geometry.coordinates.slice(),{popupContent:s}=o.properties;for(;Math.abs(r.lngLat.lng-n[0])>180;)n[0]+=r.lngLat.lng>n[0]?360:-360;t.setLngLat(n).setHTML(s).addTo(e);const l=await pd(n[1],n[0],this.apiKey);if(l){const e=`${s}<br>${l.streetName}`;t.isOpen()&&t.setHTML(e)}}})),e.on("mouseleave","points",(()=>{e.getCanvas().style.cursor="",t.remove(),i=void 0}))}_fitMap(e){var t,i,r,n,o;const a=this._map;if(!a)return;if(!this._mapClusterFocusItems.length&&!this._mapFocusItems.length&&!this._mapFocusZones.length)return void this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]);let s=new xh;!this._mapFocusItems||this._mapFocusItems.map((e=>{const t=e.getLngLat();s.extend([t.lng,t.lat])})),null===(t=this._mapFocusZones)||void 0===t||t.forEach((e=>{e.coordinates[0].forEach((e=>{s.extend([e[0],e[1]])}))})),null===(i=this._mapClusterFocusItems)||void 0===i||i.forEach((e=>{s.extend(e.getLngLat())})),s.isEmpty()||(this._fitBounds=s,a.fitBounds(s,{padding:null!==(r=null==e?void 0:e.pad)&&void 0!==r?r:{top:50,right:75,bottom:50,left:50},maxZoom:null!==(n=null==e?void 0:e.zoom)&&void 0!==n?n:this.zoom,animate:null!==(o=null==e?void 0:e.animate)&&void 0!==o&&o,linear:!0}))}_initMap(){const{zoom:e,apiKey:t}=this,i=[this.hass.config.longitude,this.hass.config.latitude],r=t?this._getInitStyle():vd.demo;this.zoom=t?this.zoom:5,this._error=t?void 0:{code:"info",message:"API key is required"};const n=this.shadowRoot.getElementById("map");gr.apiKey=t;const o={geolocateControl:!1,fullscreenControl:!1,navigationControl:!1,attributionControl:!1,fadeDuration:0,canvasContextAttributes:{antialias:!0},maxZoom:20,container:n,zoom:e,style:r,center:i};this._map=new mu(o),this._map.on("load",(async()=>{this._loaded=!0})),this._map.on("style.load",(async()=>{const e=this._map.getStyle().name,t=/dark/i.test(e);this._darkStyle=t,this._changeControlTheme(t?"dark":"light")}));const a=new sn({visualizePitch:!0,visualizeRoll:!0});this._map.addControl(a,"top-right"),this._addMapControl("mdi:image-filter-center-focus","Center","top-right",this._centerMap.bind(this)),this._map.on("styleimagemissing",(e=>{var t;null===(t=this._map)||void 0===t||t.addImage(e.id,{width:0,height:0,data:new Uint8Array(0)})})),this._map.on("error",(e=>{void 0!==e.style&&(this._error={code:"error",message:"Error fetching the map. Please verify your API key and try again."},this._map.setStyle(vd.demo),this.zoom=0)})),this._map.on("zoomend",(async()=>{this._drawEntities()}))}_centerMap(){const e=this._fitBounds;e?this._map.fitBounds(e,{padding:{top:50,right:75,bottom:50,left:50},animate:!0,maxZoom:this.zoom,linear:!0}):(this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]),this._map.setZoom(this.zoom))}_addMapControl(e,t,i,r){this._map.addControl({onAdd:()=>{const i=this._createButton(e,t);return i.style.display="unset",i.addEventListener("click",r),i},onRemove:()=>null},i)}_getInitStyle(){const{light:e,dark:t}=this.customStyles||{},i=e=>{const t=e.split(".");return 2===t.length?ti[t[0]][t[1]]:ti[t[0]]};return this._darkMode?t?i(t):vd.dark:e?i(e):vd.light}_changeControlTheme(e){const t=t=>this.getModeColor(t,e),i=Array.from(this.shadowRoot.querySelectorAll(".maplibregl-ctrl"));for(const e of i){const i=Array.from(e.querySelectorAll("button"));for(const e of i){const i=e;i.style.backgroundColor=t("backgroundColor"),i.style.boxShadow=t("boxShadow");const r=e.querySelector("span");if(r){const e=window.getComputedStyle(r).backgroundImage;if(e.startsWith('url("data:image/svg+xml')){const i=t("fill"),n=e.slice(5,-2),o=decodeURIComponent(n.split(",")[1]).replace(/fill:[^;"]*/g,`fill:${i}`).replace(/fill="[^"]*"/g,`fill="${i}"`),a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`;r.style.backgroundImage=`url("${a}")`}}}}}static get styles(){return[Z(Gh),G`
224
+ `}_renderLoadError(){if(!this._error)return ke``;const{code:e,message:t}=this._error;return ke` <ha-alert alert-type="${e}" id="error"> ${t} </ha-alert> `}updated(e){var t,i,r,n;if(super.updated(e),!this._loaded)return;let o=!1,a=!1;const s=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities(),o=!0,a=!0;else if(this._loaded&&s&&this.entities)for(const e of this.entities)if(s.states[hd(e)]!==this.hass.states[hd(e)]){this._circleLoaded=!1,this._drawEntities(),o=!0,a=!0;break}if((e.has("_loaded")||this.autoFit&&o)&&this._fitMap(),(e.has("_loaded")||e.has("paths")||this.paths&&this.paths.length&&a)&&this._drawPaths(),e.has("hass")&&s){if((null===(t=s.themes)||void 0===t?void 0:t.darkMode)!==(null===(i=this.hass.themes)||void 0===i?void 0:i.darkMode)){const e=this._getInitStyle();this._map.setStyle(e,{diff:!1})}}e.has("themeMode")||e.has("hass")&&(!s||(null===(r=s.themes)||void 0===r||r.darkMode,null===(n=this.hass.themes)||void 0===n||n.darkMode))}_drawEntities(){const e=this.hass,t=this._map;if(!t||!e)return;if(this._mapItems.length&&(this._mapItems.forEach((e=>e.remove())),this._mapItems=[],this._mapFocusItems=[]),this._mapClusterItems.length&&(this._clusterIndex=void 0,this._mapClusterItems.forEach((e=>e.remove())),this._mapClusterItems=[],this._mapClusterFocusItems=[]),this._zoneItems.length&&(this._zoneItems.forEach((e=>e.remove())),this._zoneItems=[],this._mapFocusZones=[]),!this.entities)return;this._entitiesDrawn&&(this._entitiesDrawn=!1);const i=[],r=[],n=getComputedStyle(this),o=n.getPropertyValue("--accent-color"),a=n.getPropertyValue("--secondary-text-color"),s=n.getPropertyValue("--dark-primary-color"),l=this._darkStyle?"dark":"light";for(const n of this.entities){const s=e.states[hd(n)];if(!s)continue;const c="string"!=typeof n?n.name:void 0,u=null!=c?c:pt(s),{latitude:h,longitude:p,passive:d,icon:f,radius:m,gps_accuracy:g}=s.attributes;if(!h||!p)continue;const y=[p,h];if("zone"!==L(s))i.push({type:"Feature",geometry:{type:"Point",coordinates:y},properties:{title:u,entity:n,entityId:hd(n),gpsAccuracy:g}});else{let e="";if(f){const t=document.createElement("ha-icon");t.setAttribute("icon",f),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=u,e=t.outerHTML}const i=np(y,m,{steps:150,units:"meters",properties:{color:d?a:o,title:u,opacity:d?.2:.3}});r.push(i);const s=document.createElement("div");s.className=`marker ${l}`,s.innerHTML=e,s.title=u;const c=new Xr({element:s}).setLngLat(y).addTo(t);this._zoneItems.push(c),!this.fitZones||"string"!=typeof n&&!1===n.focus||this._mapFocusZones.push(i.geometry)}}this._clusterIndex=new Hp({radius:100,maxZoom:11}),this._clusterIndex.load(i);const c=t.getBounds().toArray().flat(),u=Math.floor(t.getZoom()),h=this._clusterIndex.getClusters(c,u);for(const i of h){const[n,o]=i.geometry.coordinates;if(i.properties.cluster){const e=i.properties.point_count,r=i.properties.cluster_id,a=document.createElement("div");a.className="cluster-marker",a.innerHTML=`<div><span>${e.toString()}</span></div>`,a.addEventListener("click",(()=>{var e;try{const i=null===(e=this._clusterIndex)||void 0===e?void 0:e.getClusterExpansionZoom(r);void 0!==i&&t.easeTo({center:[n,o],zoom:i})}catch(e){}}));const s=new Xr({element:a}).setLngLat([n,o]).addTo(t);this._mapClusterItems.push(s),this._mapFocusItems.push(s),this._mapClusterFocusItems.push(s),this._mapItems.push(s)}else{const a=i.properties.entity,l=e.states[i.properties.entityId],c=i.properties.title,u=i.properties.gpsAccuracy,h="string"!=typeof a&&"state"===a.label_mode?this.hass.formatEntityState(l):"string"!=typeof a&&"attribute"===a.label_mode&&void 0!==a.attribute?this.hass.formatEntityAttributeValue(l,a.attribute):c.split(" ").map((e=>e[0])).join("").substring(0,3),p=document.createElement("ha-entity-marker");p.hass=this.hass,p.showIcon="string"!=typeof a&&"icon"===a.label_mode,p.entityId=hd(a),p.entityName=h,p.entityPicture=!l.attributes.entity_picture||"string"!=typeof a&&a.label_mode?"":this.hass.hassUrl(l.attributes.entity_picture),"string"!=typeof a&&(p.entityColor=a.color),p.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.preventDefault(),this.useMoreInfo&&C(this,"hass-more-info",{entityId:p.entityId})}),!0);const d=new Xr({element:p}).setLngLat([n,o]).addTo(t);if(this._mapItems.push(d),"string"!=typeof a&&!1===a.focus||this._mapFocusItems.push(d),u){const e=np([n,o],u,{steps:64,units:"meters",properties:{color:s,title:c,opacity:.5}});r.push(e)}}}const p={type:"geojson",data:{type:"FeatureCollection",features:r}};this._circleLoaded||(t.getLayer("circles")&&t.removeLayer("circles"),t.getLayer("circles-stroke")&&t.removeLayer("circles-stroke"),t.getSource("circles")&&t.removeSource("circles"),t.addSource("circles",p),t.addLayer({id:"circles",type:"fill",source:"circles",paint:{"fill-color":["get","color"],"fill-opacity":["get","opacity"]}}),t.addLayer({id:"circles-stroke",type:"line",source:"circles",paint:{"line-color":["get","color"],"line-width":2}}),this._circleLoaded=!0,this._entitiesDrawn=!0)}_computePathTooltip(e,t){let i;return i=e.fullDatetime?E(t.timestamp,this.hass.locale):Ip(t.timestamp)?I(t.timestamp,this.hass.locale):yd(t.timestamp,this.hass.locale,this.hass.config),`<b>${e.name}</b><br><i>${i}</i>`}_drawPaths(){const e=this.hass,t=this._map;if(!t||!e)return;if(this._mapPaths.length&&(this._mapPaths.forEach((e=>{t.removeLayer(e.id)})),this._mapPaths=[]),!this.paths)return;const i=getComputedStyle(this).getPropertyValue("--dark-primary-color"),r=[],n=[];this.paths.forEach((e=>{if(!e.points||e.points.length<2)return;let t,o;e.gradualOpacity&&(t=e.gradualOpacity/(e.points.length-2),o=1-e.gradualOpacity);for(let a=0;a<e.points.length-1;a++){const s=e.points[a].point,l=e.points[a+1].point,c=e.gradualOpacity?o+a*t:void 0,u=this._computePathTooltip(e,e.points[a]),h={type:"Feature",geometry:{type:"Point",coordinates:s},properties:{friendlyName:e.name,color:e.color||i,opacity:c,fillOpacity:c,lastUpdated:e.points[a].timestamp,popupContent:u}};n.push(h);const p={type:"Feature",geometry:{type:"LineString",coordinates:[s,l]},properties:{color:e.color||i,opacity:c,fillOpacity:c}};r.push(p)}}));const o={type:"geojson",data:{type:"FeatureCollection",features:n}},a={type:"geojson",data:{type:"FeatureCollection",features:r}};t.getSource("points")&&t.removeSource("points"),t.getSource("lines")&&t.removeSource("lines"),t.addSource("points",o),t.addSource("lines",a);const s={id:"lines",type:"line",source:"lines",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["get","color"],"line-width":2,"line-opacity":["get","opacity"]}},l={id:"points",type:"circle",source:"points",paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":1,"circle-stroke-color":["get","color"]}};t.addLayer(s),t.addLayer(l),this._mapPaths.push(s,l),this._setupPointInteraction()}_setupPointInteraction(){const e=this._map;if(!e)return;const t=new Yr({closeButton:!1,closeOnClick:!1,offset:8});let i;e.on("mousemove","points",(async r=>{var n;if(e.getZoom()<10)return e.getCanvas().style.cursor="",t.remove(),void(i=void 0);const o=null===(n=r.features)||void 0===n?void 0:n[0];if(!o)return;const a=o.geometry.coordinates.toString();if(i!==a){i=a,e.getCanvas().style.cursor="pointer";const n=r.features[0].geometry.coordinates.slice(),{popupContent:s}=o.properties;for(;Math.abs(r.lngLat.lng-n[0])>180;)n[0]+=r.lngLat.lng>n[0]?360:-360;t.setLngLat(n).setHTML(s).addTo(e);const l=await pd(n[1],n[0],this.apiKey);if(l){const e=`${s}<br>${l.streetName}`;t.isOpen()&&t.setHTML(e)}}})),e.on("mouseleave","points",(()=>{e.getCanvas().style.cursor="",t.remove(),i=void 0}))}_fitMap(e){var t,i,r,n,o;const a=this._map;if(!a)return;if(!this._mapClusterFocusItems.length&&!this._mapFocusItems.length&&!this._mapFocusZones.length)return void this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]);let s=new xh;!this._mapFocusItems||this._mapFocusItems.map((e=>{const t=e.getLngLat();s.extend([t.lng,t.lat])})),null===(t=this._mapFocusZones)||void 0===t||t.forEach((e=>{e.coordinates[0].forEach((e=>{s.extend([e[0],e[1]])}))})),null===(i=this._mapClusterFocusItems)||void 0===i||i.forEach((e=>{s.extend(e.getLngLat())})),s.isEmpty()||(this._fitBounds=s,a.fitBounds(s,{padding:null!==(r=null==e?void 0:e.pad)&&void 0!==r?r:{top:50,right:75,bottom:50,left:50},maxZoom:null!==(n=null==e?void 0:e.zoom)&&void 0!==n?n:this.zoom,animate:null!==(o=null==e?void 0:e.animate)&&void 0!==o&&o,linear:!0}))}_initMap(){const{zoom:e,apiKey:t}=this,i=[this.hass.config.longitude,this.hass.config.latitude],r=t?this._getInitStyle():vd.demo;this.zoom=t?this.zoom:5,this._error=t?void 0:{code:"info",message:"API key is required"};const n=this.shadowRoot.getElementById("map");gr.apiKey=t;const o={geolocateControl:!1,fullscreenControl:!1,navigationControl:!1,attributionControl:!1,fadeDuration:0,canvasContextAttributes:{antialias:!0},maxZoom:20,container:n,zoom:e,style:r,center:i};this._map=new mu(o),this._map.on("load",(async()=>{this._loaded=!0})),this._map.on("style.load",(async()=>{const e=this._map.getStyle().name,t=/dark/i.test(e);this._darkStyle=t,this._changeControlTheme(t?"dark":"light")}));const a=new sn({visualizePitch:!0,visualizeRoll:!0});this._map.addControl(a,"top-right"),this._addMapControl("mdi:image-filter-center-focus","Center","top-right",this._centerMap.bind(this)),this._map.on("styleimagemissing",(e=>{var t;null===(t=this._map)||void 0===t||t.addImage(e.id,{width:0,height:0,data:new Uint8Array(0)})})),this._map.on("error",(e=>{void 0!==e.style&&(this._error={code:"error",message:"Error fetching the map. Please verify your API key and try again."},this._map.setStyle(vd.demo),this.zoom=0)})),this._map.on("zoomend",(async()=>{this._drawEntities()}))}_centerMap(){const e=this._fitBounds;e?this._map.fitBounds(e,{padding:{top:50,right:75,bottom:50,left:50},animate:!0,maxZoom:this.zoom,linear:!0}):(this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]),this._map.setZoom(this.zoom))}_addMapControl(e,t,i,r){this._map.addControl({onAdd:()=>{const i=this._createButton(e,t);return i.style.display="unset",i.addEventListener("click",r),i},onRemove:()=>null},i)}_getInitStyle(){const{light:e,dark:t}=this.customStyles||{},i=e=>{const t=e.split(".");return 2===t.length?ti[t[0]][t[1]]:ti[t[0]]};return this._darkMode?t?i(t):vd.dark:e?i(e):vd.light}_changeControlTheme(e){const t=t=>this.getModeColor(t,e),i=Array.from(this.shadowRoot.querySelectorAll(".maplibregl-ctrl"));for(const e of i){const i=Array.from(e.querySelectorAll("button"));for(const e of i){const i=e;i.style.backgroundColor=t("backgroundColor"),i.style.boxShadow=t("boxShadow");const r=e.querySelector("span");if(r){const e=window.getComputedStyle(r).backgroundImage;if(e.startsWith('url("data:image/svg+xml')){const i=t("fill"),n=e.slice(5,-2),o=decodeURIComponent(n.split(",")[1]).replace(/fill:[^;"]*/g,`fill:${i}`).replace(/fill="[^"]*"/g,`fill="${i}"`),a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`;r.style.backgroundImage=`url("${a}")`}}}}}static get styles(){return[Z(Gh),G`
225
225
  :host {
226
226
  --tooltip-color: rgba(80, 80, 80, 0.9);
227
227
  }
@@ -325,7 +325,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
325
325
  .maplibregl-ctrl.maplibregl-ctrl-group > button:hover > ha-icon {
326
326
  filter: invert(39%) sepia(77%) saturate(909%) hue-rotate(182deg) brightness(89%) contrast(85%);
327
327
  }
328
- `]}}e([et({attribute:!1})],xd.prototype,"hass",void 0),e([et({attribute:!1})],xd.prototype,"entities",void 0),e([et({attribute:!1})],xd.prototype,"paths",void 0),e([et({attribute:"auto-fit",type:Boolean})],xd.prototype,"autoFit",void 0),e([et({attribute:"fit-zones",type:Boolean})],xd.prototype,"fitZones",void 0),e([et({type:Number})],xd.prototype,"zoom",void 0),e([et({attribute:"theme-mode",type:String})],xd.prototype,"themeMode",void 0),e([et({type:String})],xd.prototype,"apiKey",void 0),e([et({type:Boolean})],xd.prototype,"useMoreInfo",void 0),e([et({type:Object})],xd.prototype,"customStyles",void 0),e([et({attribute:"dark-style",type:Boolean,reflect:!0})],xd.prototype,"_darkStyle",void 0),e([tt()],xd.prototype,"_circleLoaded",void 0),e([tt()],xd.prototype,"_loaded",void 0),e([tt()],xd.prototype,"_entitiesDrawn",void 0),e([tt()],xd.prototype,"_error",void 0),customElements.get("emc-map")||customElements.define("emc-map",xd);class wd extends Xe{constructor(){super(...arguments),this._mapEntities=[],this._colorDict={},this._colorIndex=0,this._zoom=gp,this._getHistoryPaths=st(((e,t)=>{var i,r,n,o;if(!t)return;const a=[];for(const s of Object.keys(t)){if("zone"===z(s))continue;const l=t[s];if(!(null==l?void 0:l.length))continue;const c=[];for(const e of l){const t=e.a.latitude,i=e.a.longitude;if(!t||!i)continue;const r={};r.point=[i,t],r.timestamp=new Date(1e3*e.lu),c.push(r)}const u=null===(i=this._configEntities)||void 0===i?void 0:i.find((e=>e.entity===s)),h=null!==(r=null==u?void 0:u.name)&&void 0!==r?r:s in this.hass.states?pt(this.hass.states[s]):s,p=null!==(n=null==u?void 0:u.color)&&void 0!==n?n:this._getColor(s);a.push({points:c,name:h,fullDatetime:(null!==(o=e.hours_to_show)&&void 0!==o?o:0)>=144,color:p,gradualOpacity:.8})}return a}))}_getAllEntities(){const e=this.hass,t=new Set,i=[];return Object.values(e.states).forEach((e=>{"latitude"in e.attributes&&"longitude"in e.attributes&&(i.push(e.entity_id),"person"===L(e)&&e.attributes.source&&t.add(e.attributes.source))})),i.filter((e=>!t.has(e)))}static async getConfigElement(){return await Promise.resolve().then((function(){return zf})),document.createElement("extra-map-editor")}static getStubConfig(e,t,i){return{type:"custom:extra-map-card",entities:ft(e,2,t,i,["device_tracker"]),theme_mode:"auto",use_more_info:!0}}setConfig(e){var t;if(!e)throw new Error("Invalid configuration");if(!e.show_all&&!(null===(t=e.entities)||void 0===t?void 0:t.length))throw new Error("Either entities or show_all is required");if(e.entities&&!Array.isArray(e.entities))throw new Error("Entities need to be an array");if(e.show_all&&e.entities)throw new Error("Cannot specify show_all and entities at the same time");if(this._config=Object.assign({},e),this._config.default_zoom)this._zoom=this._config.default_zoom;else if(this._config.aspect_ratio){const e=Tt(this._config.aspect_ratio),t=e&&e.w>0&&e.h>0?`${(100*e.h/e.w).toFixed(2)}`:"100";t&&Number(t)<=100?this._zoom=12:this._zoom=gp}this.hass&&e.show_all&&(this._config.entities=this._getAllEntities()),this._configEntities=this._config.entities?yt(this._config.entities):[],this._mapEntities=this._getMapEntities()}getCardSize(){var e;if(!(null===(e=this._config)||void 0===e?void 0:e.aspect_ratio))return 7;const t=Tt(this._config.aspect_ratio),i=t&&t.w>0&&t.h>0?`${(100*t.h/t.w).toFixed(2)}`:"100";return 1+Math.floor(Number(i)/25)||3}getGridOptions(){return{columns:"full",rows:"auto",min_columns:6,min_rows:2}}render(){var e;if(!this._config)return Le;if(this._error)return ke`<ha-alert alert-type="error">
328
+ `]}}e([et({attribute:!1})],xd.prototype,"hass",void 0),e([et({attribute:!1})],xd.prototype,"entities",void 0),e([et({attribute:!1})],xd.prototype,"paths",void 0),e([et({attribute:"auto-fit",type:Boolean})],xd.prototype,"autoFit",void 0),e([et({attribute:"fit-zones",type:Boolean})],xd.prototype,"fitZones",void 0),e([et({type:Number})],xd.prototype,"zoom",void 0),e([et({attribute:"theme-mode",type:String})],xd.prototype,"themeMode",void 0),e([et({type:String})],xd.prototype,"apiKey",void 0),e([et({type:Boolean})],xd.prototype,"useMoreInfo",void 0),e([et({type:Object})],xd.prototype,"customStyles",void 0),e([et({attribute:"dark-style",type:Boolean,reflect:!0})],xd.prototype,"_darkStyle",void 0),e([tt()],xd.prototype,"_circleLoaded",void 0),e([tt()],xd.prototype,"_loaded",void 0),e([tt()],xd.prototype,"_entitiesDrawn",void 0),e([tt()],xd.prototype,"_error",void 0),customElements.get("emc-map")||customElements.define("emc-map",xd);class wd extends Xe{constructor(){super(...arguments),this._mapEntities=[],this._colorDict={},this._colorIndex=0,this._zoom=gp,this._getHistoryPaths=st(((e,t)=>{var i,r,n,o;if(!t)return;const a=[];for(const s of Object.keys(t)){if("zone"===z(s))continue;const l=t[s];if(!(null==l?void 0:l.length))continue;const c=[];for(const e of l){const t=e.a.latitude,i=e.a.longitude;if(!t||!i)continue;const r={};r.point=[i,t],r.timestamp=new Date(1e3*e.lu),c.push(r)}const u=null===(i=this._configEntities)||void 0===i?void 0:i.find((e=>e.entity===s)),h=null!==(r=null==u?void 0:u.name)&&void 0!==r?r:s in this.hass.states?pt(this.hass.states[s]):s,p=null!==(n=null==u?void 0:u.color)&&void 0!==n?n:this._getColor(s);a.push({points:c,name:h,fullDatetime:(null!==(o=e.hours_to_show)&&void 0!==o?o:0)>=144,color:p,gradualOpacity:.8})}return a}))}_getAllEntities(){const e=this.hass,t=new Set,i=[];return Object.values(e.states).forEach((e=>{"latitude"in e.attributes&&"longitude"in e.attributes&&(i.push(e.entity_id),"person"===L(e)&&e.attributes.source&&t.add(e.attributes.source))})),i.filter((e=>!t.has(e)))}static async getConfigElement(){return await Promise.resolve().then((function(){return $f})),document.createElement("extra-map-editor")}static getStubConfig(e,t,i){return{type:"custom:extra-map-card",entities:ft(e,2,t,i,["device_tracker"]),theme_mode:"auto",use_more_info:!0}}setConfig(e){var t;if(!e)throw new Error("Invalid configuration");if(!e.show_all&&!(null===(t=e.entities)||void 0===t?void 0:t.length))throw new Error("Either entities or show_all is required");if(e.entities&&!Array.isArray(e.entities))throw new Error("Entities need to be an array");if(e.show_all&&e.entities)throw new Error("Cannot specify show_all and entities at the same time");if(this._config=Object.assign({},e),this._config.default_zoom)this._zoom=this._config.default_zoom;else if(this._config.aspect_ratio){const e=Tt(this._config.aspect_ratio),t=e&&e.w>0&&e.h>0?`${(100*e.h/e.w).toFixed(2)}`:"100";t&&Number(t)<=100?this._zoom=12:this._zoom=gp}this.hass&&e.show_all&&(this._config.entities=this._getAllEntities()),this._configEntities=this._config.entities?yt(this._config.entities):[],this._mapEntities=this._getMapEntities()}getCardSize(){var e;if(!(null===(e=this._config)||void 0===e?void 0:e.aspect_ratio))return 7;const t=Tt(this._config.aspect_ratio),i=t&&t.w>0&&t.h>0?`${(100*t.h/t.w).toFixed(2)}`:"100";return 1+Math.floor(Number(i)/25)||3}getGridOptions(){return{columns:"full",rows:"auto",min_columns:6,min_rows:2}}render(){var e;if(!this._config)return Le;if(this._error)return ke`<ha-alert alert-type="error">
329
329
  ${this.hass.localize("ui.components.map.error")}: ${this._error.message} (${this._error.code})
330
330
  </ha-alert>`;const t=this._config.theme_mode||(this._config.dark_mode?"dark":"auto"),i=this._config.custom_styles||{};return ke`
331
331
  <ha-card id="card" .header=${this._config.title}>
@@ -356,28 +356,23 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
356
356
  position: relative;
357
357
  height: 100%;
358
358
  }
359
- `,e([et({attribute:!1})],wd.prototype,"hass",void 0),e([et({attribute:!1})],wd.prototype,"layout",void 0),e([tt()],wd.prototype,"_config",void 0),e([tt()],wd.prototype,"_mapEntities",void 0),e([tt()],wd.prototype,"_stateHistory",void 0),e([tt()],wd.prototype,"_error",void 0),e([rt("emc-map")],wd.prototype,"_mapTiler",void 0),customElements.get("extra-map-card")||customElements.define("extra-map-card",wd),window.customCards=window.customCards||[],window.customCards.find((e=>"extra-map-card"===e.type))||window.customCards.push({type:"extra-map-card",name:"Extra Map Card",description:"Extra Map Card using MapTiler",preview:!0,version:`${up}`});const Td=e=>"latitude"in e.attributes&&"longitude"in e.attributes
360
- /**
361
- * @license
362
- * Copyright 2017 Google LLC
363
- * SPDX-License-Identifier: BSD-3-Clause
364
- */,Ad={CHILD:2},Sd=e=>(...t)=>({_$litDirective$:e,values:t});class Md{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
359
+ `,e([et({attribute:!1})],wd.prototype,"hass",void 0),e([et({attribute:!1})],wd.prototype,"layout",void 0),e([tt()],wd.prototype,"_config",void 0),e([tt()],wd.prototype,"_mapEntities",void 0),e([tt()],wd.prototype,"_stateHistory",void 0),e([tt()],wd.prototype,"_error",void 0),e([rt("emc-map")],wd.prototype,"_mapTiler",void 0),customElements.get("extra-map-card")||customElements.define("extra-map-card",wd),window.customCards=window.customCards||[],window.customCards.find((e=>"extra-map-card"===e.type))||window.customCards.push({type:"extra-map-card",name:"Extra Map Card",description:"Extra Map Card using MapTiler",preview:!0,version:`${up}`});const Td=e=>"latitude"in e.attributes&&"longitude"in e.attributes,Ad="https://cdn.jsdelivr.net/npm/extra-map-card@",Sd="extra-map-card",Md="/dist/extra-map-card-bundle.min.js",Ed="extra-map-card-bundle.min.js";async function Pd(){var e;try{const t=await fetch(`https://registry.npmjs.org/${Sd}`);if(!t.ok)throw new Error("Package not found");return(null===(e=(await t.json())["dist-tags"])||void 0===e?void 0:e.latest)||null}catch(e){return null}}let Id=null;const kd=async e=>Id||(Id=(async()=>{const t=await st(Pd)();if(!t)return;const i=`${Ad}${t}${Md}`,r=(await v(e.connection)).find((e=>e.url.endsWith(Ed)));r&&r.url===i||(r?await x(e,r.id,{res_type:"module",url:i}):await b(e,{res_type:"module",url:i}))})(),Id),zd=()=>{Id=null},Ld={CHILD:2},Dd=e=>(...t)=>({_$litDirective$:e,values:t});class Fd{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
365
360
  /**
366
361
  * @license
367
362
  * Copyright 2020 Google LLC
368
363
  * SPDX-License-Identifier: BSD-3-Clause
369
- */const{I:Ed}=He,Pd=()=>document.createComment(""),Id=(e,t,i)=>{const r=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=r.insertBefore(Pd(),n),o=r.insertBefore(Pd(),n);i=new Ed(t,o,e,e.options)}else{const t=i._$AB.nextSibling,o=i._$AM,a=o!==e;if(a){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==o._$AU&&i._$AP(t)}if(t!==n||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;r.insertBefore(e,n),e=t}}}return i},kd=(e,t,i=e)=>(e._$AI(t,i),e),zd={},Ld=(e,t=zd)=>e._$AH=t,Dd=e=>e._$AH,Fd=e=>{e._$AP?.(!1,!0);let t=e._$AA;const i=e._$AB.nextSibling;for(;t!==i;){const e=t.nextSibling;t.remove(),t=e}},Rd=(e,t,i)=>{const r=new Map;for(let n=t;n<=i;n++)r.set(e[n],n);return r},Bd=Sd(class extends Md{constructor(e){if(super(e),e.type!==Ad.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let r;void 0===i?i=t:void 0!==t&&(r=t);const n=[],o=[];let a=0;for(const t of e)n[a]=r?r(t,a):a,o[a]=i(t,a),a++;return{values:o,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,r]){const n=Dd(e),{values:o,keys:a}=this.dt(t,i,r);if(!Array.isArray(n))return this.ut=a,o;const s=this.ut??=[],l=[];let c,u,h=0,p=n.length-1,d=0,f=o.length-1;for(;h<=p&&d<=f;)if(null===n[h])h++;else if(null===n[p])p--;else if(s[h]===a[d])l[d]=kd(n[h],o[d]),h++,d++;else if(s[p]===a[f])l[f]=kd(n[p],o[f]),p--,f--;else if(s[h]===a[f])l[f]=kd(n[h],o[f]),Id(e,l[f+1],n[h]),h++,f--;else if(s[p]===a[d])l[d]=kd(n[p],o[d]),Id(e,n[h],n[p]),p--,d++;else if(void 0===c&&(c=Rd(a,d,f),u=Rd(s,h,p)),c.has(s[h]))if(c.has(s[p])){const t=u.get(a[d]),i=void 0!==t?n[t]:null;if(null===i){const t=Id(e,n[h]);kd(t,o[d]),l[d]=t}else l[d]=kd(i,o[d]),Id(e,n[h],i),n[t]=null;d++}else Fd(n[p]),p--;else Fd(n[h]),h++;for(;d<=f;){const t=Id(e,l[f+1]);kd(t,o[d]),l[d++]=t}for(;h<=p;){const e=n[h++];null!==e&&Fd(e)}return this.ut=a,Ld(e,l),ze}});
364
+ */const{I:Rd}=He,Bd=()=>document.createComment(""),Od=(e,t,i)=>{const r=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=r.insertBefore(Bd(),n),o=r.insertBefore(Bd(),n);i=new Rd(t,o,e,e.options)}else{const t=i._$AB.nextSibling,o=i._$AM,a=o!==e;if(a){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==o._$AU&&i._$AP(t)}if(t!==n||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;r.insertBefore(e,n),e=t}}}return i},jd=(e,t,i=e)=>(e._$AI(t,i),e),$d={},Nd=(e,t=$d)=>e._$AH=t,Vd=e=>e._$AH,Ud=e=>{e._$AP?.(!1,!0);let t=e._$AA;const i=e._$AB.nextSibling;for(;t!==i;){const e=t.nextSibling;t.remove(),t=e}},qd=(e,t,i)=>{const r=new Map;for(let n=t;n<=i;n++)r.set(e[n],n);return r},Zd=Dd(class extends Fd{constructor(e){if(super(e),e.type!==Ld.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let r;void 0===i?i=t:void 0!==t&&(r=t);const n=[],o=[];let a=0;for(const t of e)n[a]=r?r(t,a):a,o[a]=i(t,a),a++;return{values:o,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,r]){const n=Vd(e),{values:o,keys:a}=this.dt(t,i,r);if(!Array.isArray(n))return this.ut=a,o;const s=this.ut??=[],l=[];let c,u,h=0,p=n.length-1,d=0,f=o.length-1;for(;h<=p&&d<=f;)if(null===n[h])h++;else if(null===n[p])p--;else if(s[h]===a[d])l[d]=jd(n[h],o[d]),h++,d++;else if(s[p]===a[f])l[f]=jd(n[p],o[f]),p--,f--;else if(s[h]===a[f])l[f]=jd(n[h],o[f]),Od(e,l[f+1],n[h]),h++,f--;else if(s[p]===a[d])l[d]=jd(n[p],o[d]),Od(e,n[h],n[p]),p--,d++;else if(void 0===c&&(c=qd(a,d,f),u=qd(s,h,p)),c.has(s[h]))if(c.has(s[p])){const t=u.get(a[d]),i=void 0!==t?n[t]:null;if(null===i){const t=Od(e,n[h]);jd(t,o[d]),l[d]=t}else l[d]=jd(i,o[d]),Od(e,n[h],i),n[t]=null;d++}else Ud(n[p]),p--;else Ud(n[h]),h++;for(;d<=f;){const t=Od(e,l[f+1]);jd(t,o[d]),l[d++]=t}for(;h<=p;){const e=n[h++];null!==e&&Ud(e)}return this.ut=a,Nd(e,l),ze}});
370
365
  /**
371
366
  * @license
372
367
  * Copyright 2017 Google LLC
373
368
  * SPDX-License-Identifier: BSD-3-Clause
374
- */class Od extends Xe{render(){return this.entities&&this.hass?ke`
369
+ */class Gd extends Xe{render(){return this.entities&&this.hass?ke`
375
370
  <h3>
376
371
  ${this.label||`${this.hass.localize("ui.panel.lovelace.editor.card.generic.entities")} (${this.hass.localize("ui.panel.lovelace.editor.card.config.required")})`}
377
372
  </h3>
378
373
  <ha-sortable handle-selector=".handle" @item-moved=${this._itemMoved}>
379
374
  <div>
380
- ${Bd(this.entities,(e=>e.entity),((e,t)=>ke`
375
+ ${Zd(this.entities,(e=>e.entity),((e,t)=>ke`
381
376
  <div class="entity">
382
377
  <div class="handle">
383
378
  <ha-svg-icon .path=${ap}></ha-svg-icon>
@@ -415,7 +410,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
415
410
  .entityFilter=${this.entityFilter}
416
411
  @value-changed=${this._addEntity}
417
412
  ></ha-entity-picker>
418
- `:Le}async _addEntity(e){const t=e.detail.value;if(""===t)return;const i=this.entities.concat({entity:t});e.target.value="",C(this,"entities-changed",{entities:i})}_itemMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,r=this.entities.concat();r.splice(i,0,r.splice(t,1)[0]),C(this,"entities-changed",{entities:r})}_removeItem(e){const t=e.currentTarget.index,i=this.entities.concat();i.splice(t,1),C(this,"entities-changed",{entities:i})}_valueChanged(e){const t=e.detail.value,i=e.target.index,r=this.entities.concat();""===t||void 0===t?r.splice(i,1):r[i]=Object.assign(Object.assign({},r[i]),{entity:t}),C(this,"entities-changed",{entities:r})}_editItem(e){const t=e.currentTarget.index;C(this,"edit-detail-entity",{subEntityConfig:{index:t,elementConfig:this.entities[t]}})}}function jd(e){return jd="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},jd(e)}Od.styles=G`
413
+ `:Le}async _addEntity(e){const t=e.detail.value;if(""===t)return;const i=this.entities.concat({entity:t});e.target.value="",C(this,"entities-changed",{entities:i})}_itemMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,r=this.entities.concat();r.splice(i,0,r.splice(t,1)[0]),C(this,"entities-changed",{entities:r})}_removeItem(e){const t=e.currentTarget.index,i=this.entities.concat();i.splice(t,1),C(this,"entities-changed",{entities:i})}_valueChanged(e){const t=e.detail.value,i=e.target.index,r=this.entities.concat();""===t||void 0===t?r.splice(i,1):r[i]=Object.assign(Object.assign({},r[i]),{entity:t}),C(this,"entities-changed",{entities:r})}_editItem(e){const t=e.currentTarget.index;C(this,"edit-detail-entity",{subEntityConfig:{index:t,elementConfig:this.entities[t]}})}}function Hd(e){return Hd="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},Hd(e)}Gd.styles=G`
419
414
  ha-entity-picker {
420
415
  margin-top: 8px;
421
416
  }
@@ -473,7 +468,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
473
468
  font-size: var(--ha-font-size-s);
474
469
  color: var(--secondary-text-color);
475
470
  }
476
- `,e([et({attribute:!1})],Od.prototype,"hass",void 0),e([et({attribute:!1})],Od.prototype,"entities",void 0),e([et({attribute:!1})],Od.prototype,"entityFilter",void 0),e([et()],Od.prototype,"label",void 0),customElements.get("emc-entity-editor")||customElements.define("emc-entity-editor",Od);var $d=/^\s+/,Nd=/\s+$/;function Vd(e,t){if(t=t||{},(e=e||"")instanceof Vd)return e;if(!(this instanceof Vd))return new Vd(e,t);var i=Ud(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||i.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=i.ok}function Ud(e){var t={r:0,g:0,b:0},i=1,r=null,n=null,o=null,a=!1,s=!1;return"string"==typeof e&&(e=Sf(e)),"object"==jd(e)&&(Af(e.r)&&Af(e.g)&&Af(e.b)?(t=qd(e.r,e.g,e.b),a=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Af(e.h)&&Af(e.s)&&Af(e.v)?(r=xf(e.s),n=xf(e.v),t=Wd(e.h,r,n),a=!0,s="hsv"):Af(e.h)&&Af(e.s)&&Af(e.l)&&(r=xf(e.s),o=xf(e.l),t=Gd(e.h,r,o),a=!0,s="hsl"),e.hasOwnProperty("a")&&(i=e.a)),i=ff(i),{ok:a,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:i}}function qd(e,t,i){return{r:255*mf(e,255),g:255*mf(t,255),b:255*mf(i,255)}}function Zd(e,t,i){e=mf(e,255),t=mf(t,255),i=mf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=(o+a)/2;if(o==a)r=n=0;else{var l=o-a;switch(n=s>.5?l/(2-o-a):l/(o+a),o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,l:s}}function Gd(e,t,i){var r,n,o;function a(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}if(e=mf(e,360),t=mf(t,100),i=mf(i,100),0===t)r=n=o=i;else{var s=i<.5?i*(1+t):i+t-i*t,l=2*i-s;r=a(l,s,e+1/3),n=a(l,s,e),o=a(l,s,e-1/3)}return{r:255*r,g:255*n,b:255*o}}function Hd(e,t,i){e=mf(e,255),t=mf(t,255),i=mf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=o,l=o-a;if(n=0===o?0:l/o,o==a)r=0;else{switch(o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,v:s}}function Wd(e,t,i){e=6*mf(e,360),t=mf(t,100),i=mf(i,100);var r=Math.floor(e),n=e-r,o=i*(1-t),a=i*(1-n*t),s=i*(1-(1-n)*t),l=r%6;return{r:255*[i,a,o,o,s,i][l],g:255*[s,i,i,a,o,o][l],b:255*[o,o,s,i,i,a][l]}}function Kd(e,t,i,r){var n=[bf(Math.round(e).toString(16)),bf(Math.round(t).toString(16)),bf(Math.round(i).toString(16))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function Xd(e,t,i,r,n){var o=[bf(Math.round(e).toString(16)),bf(Math.round(t).toString(16)),bf(Math.round(i).toString(16)),bf(wf(r))];return n&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}function Yd(e,t,i,r){return[bf(wf(r)),bf(Math.round(e).toString(16)),bf(Math.round(t).toString(16)),bf(Math.round(i).toString(16))].join("")}function Jd(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.s-=t/100,i.s=gf(i.s),Vd(i)}function Qd(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.s+=t/100,i.s=gf(i.s),Vd(i)}function ef(e){return Vd(e).desaturate(100)}function tf(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.l+=t/100,i.l=gf(i.l),Vd(i)}function rf(e,t){t=0===t?0:t||10;var i=Vd(e).toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-t/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-t/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-t/100*255))),Vd(i)}function nf(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.l-=t/100,i.l=gf(i.l),Vd(i)}function of(e,t){var i=Vd(e).toHsl(),r=(i.h+t)%360;return i.h=r<0?360+r:r,Vd(i)}function af(e){var t=Vd(e).toHsl();return t.h=(t.h+180)%360,Vd(t)}function sf(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var i=Vd(e).toHsl(),r=[Vd(e)],n=360/t,o=1;o<t;o++)r.push(Vd({h:(i.h+o*n)%360,s:i.s,l:i.l}));return r}function lf(e){var t=Vd(e).toHsl(),i=t.h;return[Vd(e),Vd({h:(i+72)%360,s:t.s,l:t.l}),Vd({h:(i+216)%360,s:t.s,l:t.l})]}function cf(e,t,i){t=t||6,i=i||30;var r=Vd(e).toHsl(),n=360/i,o=[Vd(e)];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,o.push(Vd(r));return o}function uf(e,t){t=t||6;for(var i=Vd(e).toHsv(),r=i.h,n=i.s,o=i.v,a=[],s=1/t;t--;)a.push(Vd({h:r,s:n,v:o})),o=(o+s)%1;return a}Vd.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,i,r=this.toRgb();return e=r.r/255,t=r.g/255,i=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},setAlpha:function(e){return this._a=ff(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Hd(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Hd(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+i+"%, "+r+"%)":"hsva("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=Zd(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Zd(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+i+"%, "+r+"%)":"hsla("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return Kd(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return Xd(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*mf(this._r,255))+"%",g:Math.round(100*mf(this._g,255))+"%",b:Math.round(100*mf(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*mf(this._r,255))+"%, "+Math.round(100*mf(this._g,255))+"%, "+Math.round(100*mf(this._b,255))+"%)":"rgba("+Math.round(100*mf(this._r,255))+"%, "+Math.round(100*mf(this._g,255))+"%, "+Math.round(100*mf(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(pf[Kd(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+Yd(this._r,this._g,this._b,this._a),i=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var n=Vd(e);i="#"+Yd(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+i+")"},toString:function(e){var t=!!e;e=e||this._format;var i=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(i=this.toRgbString()),"prgb"===e&&(i=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(i=this.toHexString()),"hex3"===e&&(i=this.toHexString(!0)),"hex4"===e&&(i=this.toHex8String(!0)),"hex8"===e&&(i=this.toHex8String()),"name"===e&&(i=this.toName()),"hsl"===e&&(i=this.toHslString()),"hsv"===e&&(i=this.toHsvString()),i||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Vd(this.toString())},_applyModification:function(e,t){var i=e.apply(null,[this].concat([].slice.call(t)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(tf,arguments)},brighten:function(){return this._applyModification(rf,arguments)},darken:function(){return this._applyModification(nf,arguments)},desaturate:function(){return this._applyModification(Jd,arguments)},saturate:function(){return this._applyModification(Qd,arguments)},greyscale:function(){return this._applyModification(ef,arguments)},spin:function(){return this._applyModification(of,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(cf,arguments)},complement:function(){return this._applyCombination(af,arguments)},monochromatic:function(){return this._applyCombination(uf,arguments)},splitcomplement:function(){return this._applyCombination(lf,arguments)},triad:function(){return this._applyCombination(sf,[3])},tetrad:function(){return this._applyCombination(sf,[4])}},Vd.fromRatio=function(e,t){if("object"==jd(e)){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]="a"===r?e[r]:xf(e[r]));e=i}return Vd(e,t)},Vd.equals=function(e,t){return!(!e||!t)&&Vd(e).toRgbString()==Vd(t).toRgbString()},Vd.random=function(){return Vd.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Vd.mix=function(e,t,i){i=0===i?0:i||50;var r=Vd(e).toRgb(),n=Vd(t).toRgb(),o=i/100;return Vd({r:(n.r-r.r)*o+r.r,g:(n.g-r.g)*o+r.g,b:(n.b-r.b)*o+r.b,a:(n.a-r.a)*o+r.a})},Vd.readability=function(e,t){var i=Vd(e),r=Vd(t);return(Math.max(i.getLuminance(),r.getLuminance())+.05)/(Math.min(i.getLuminance(),r.getLuminance())+.05)},Vd.isReadable=function(e,t,i){var r,n,o=Vd.readability(e,t);switch(n=!1,(r=Mf(i)).level+r.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7}return n},Vd.mostReadable=function(e,t,i){var r,n,o,a,s=null,l=0;n=(i=i||{}).includeFallbackColors,o=i.level,a=i.size;for(var c=0;c<t.length;c++)(r=Vd.readability(e,t[c]))>l&&(l=r,s=Vd(t[c]));return Vd.isReadable(e,s,{level:o,size:a})||!n?s:(i.includeFallbackColors=!1,Vd.mostReadable(e,["#fff","#000"],i))};var hf=Vd.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},pf=Vd.hexNames=df(hf);function df(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function ff(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function mf(e,t){_f(e)&&(e="100%");var i=vf(e);return e=Math.min(t,Math.max(0,parseFloat(e))),i&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function gf(e){return Math.min(1,Math.max(0,e))}function yf(e){return parseInt(e,16)}function _f(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)}function vf(e){return"string"==typeof e&&-1!=e.indexOf("%")}function bf(e){return 1==e.length?"0"+e:""+e}function xf(e){return e<=1&&(e=100*e+"%"),e}function wf(e){return Math.round(255*parseFloat(e)).toString(16)}function Cf(e){return yf(e)/255}var Tf=function(){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",t="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+t),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+t),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+t),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Af(e){return!!Tf.CSS_UNIT.exec(e)}function Sf(e){e=e.replace($d,"").replace(Nd,"").toLowerCase();var t,i=!1;if(hf[e])e=hf[e],i=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(t=Tf.rgb.exec(e))?{r:t[1],g:t[2],b:t[3]}:(t=Tf.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Tf.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=Tf.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Tf.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=Tf.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Tf.hex8.exec(e))?{r:yf(t[1]),g:yf(t[2]),b:yf(t[3]),a:Cf(t[4]),format:i?"name":"hex8"}:(t=Tf.hex6.exec(e))?{r:yf(t[1]),g:yf(t[2]),b:yf(t[3]),format:i?"name":"hex"}:(t=Tf.hex4.exec(e))?{r:yf(t[1]+""+t[1]),g:yf(t[2]+""+t[2]),b:yf(t[3]+""+t[3]),a:Cf(t[4]+""+t[4]),format:i?"name":"hex8"}:!!(t=Tf.hex3.exec(e))&&{r:yf(t[1]+""+t[1]),g:yf(t[2]+""+t[2]),b:yf(t[3]+""+t[3]),format:i?"name":"hex"}}function Mf(e){var t,i;return"AA"!==(t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==t&&(t="AA"),"small"!==(i=(e.size||"small").toLowerCase())&&"large"!==i&&(i="small"),{level:t,size:i}}const Ef=["name","state","icon","attribute"],Pf=st(((e,t,i)=>[{name:"entity",lebel:"Entity",selector:{entity:{filter:{domain:["device_tracker","person","zone"]}}}},{name:"",type:"grid",schema:[{name:"name",label:"Name",default:"",type:"string"},{name:"icon",label:"Icon",selector:{icon:{}}},...e?[]:[{name:"label_mode",label:"Label Mode",selector:{select:{mode:"dropdown",options:Ef.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"attribute",label:"Attribute",disabled:i,selector:{attribute:{entity_id:t}}}],{name:"focus",label:"Focus",required:!1,type:"boolean"}]}]));class If extends Xe{constructor(){super(...arguments),this._rgbColor=[0,0,0],this._computeLabel=e=>e.label||"",this._colorToRgb=e=>{const t=Vd(e);if(!t.isValid())return[0,0,0];const{r:i,g:r,b:n}=t.toRgb();return[i,r,n]}}firstUpdated(){var e;if(null===(e=this.config.elementConfig)||void 0===e?void 0:e.color){const e=this._colorToRgb(this.config.elementConfig.color);this._rgbColor=e}else{const e=ct(this.config.index||0),t=this._colorToRgb(e);this._rgbColor=t}}render(){return ke`
471
+ `,e([et({attribute:!1})],Gd.prototype,"hass",void 0),e([et({attribute:!1})],Gd.prototype,"entities",void 0),e([et({attribute:!1})],Gd.prototype,"entityFilter",void 0),e([et()],Gd.prototype,"label",void 0);var Wd=/^\s+/,Kd=/\s+$/;function Xd(e,t){if(t=t||{},(e=e||"")instanceof Xd)return e;if(!(this instanceof Xd))return new Xd(e,t);var i=Yd(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||i.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=i.ok}function Yd(e){var t={r:0,g:0,b:0},i=1,r=null,n=null,o=null,a=!1,s=!1;return"string"==typeof e&&(e=Df(e)),"object"==Hd(e)&&(Lf(e.r)&&Lf(e.g)&&Lf(e.b)?(t=Jd(e.r,e.g,e.b),a=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Lf(e.h)&&Lf(e.s)&&Lf(e.v)?(r=Pf(e.s),n=Pf(e.v),t=rf(e.h,r,n),a=!0,s="hsv"):Lf(e.h)&&Lf(e.s)&&Lf(e.l)&&(r=Pf(e.s),o=Pf(e.l),t=ef(e.h,r,o),a=!0,s="hsl"),e.hasOwnProperty("a")&&(i=e.a)),i=wf(i),{ok:a,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:i}}function Jd(e,t,i){return{r:255*Cf(e,255),g:255*Cf(t,255),b:255*Cf(i,255)}}function Qd(e,t,i){e=Cf(e,255),t=Cf(t,255),i=Cf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=(o+a)/2;if(o==a)r=n=0;else{var l=o-a;switch(n=s>.5?l/(2-o-a):l/(o+a),o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,l:s}}function ef(e,t,i){var r,n,o;function a(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}if(e=Cf(e,360),t=Cf(t,100),i=Cf(i,100),0===t)r=n=o=i;else{var s=i<.5?i*(1+t):i+t-i*t,l=2*i-s;r=a(l,s,e+1/3),n=a(l,s,e),o=a(l,s,e-1/3)}return{r:255*r,g:255*n,b:255*o}}function tf(e,t,i){e=Cf(e,255),t=Cf(t,255),i=Cf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=o,l=o-a;if(n=0===o?0:l/o,o==a)r=0;else{switch(o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,v:s}}function rf(e,t,i){e=6*Cf(e,360),t=Cf(t,100),i=Cf(i,100);var r=Math.floor(e),n=e-r,o=i*(1-t),a=i*(1-n*t),s=i*(1-(1-n)*t),l=r%6;return{r:255*[i,a,o,o,s,i][l],g:255*[s,i,i,a,o,o][l],b:255*[o,o,s,i,i,a][l]}}function nf(e,t,i,r){var n=[Ef(Math.round(e).toString(16)),Ef(Math.round(t).toString(16)),Ef(Math.round(i).toString(16))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function of(e,t,i,r,n){var o=[Ef(Math.round(e).toString(16)),Ef(Math.round(t).toString(16)),Ef(Math.round(i).toString(16)),Ef(If(r))];return n&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}function af(e,t,i,r){return[Ef(If(r)),Ef(Math.round(e).toString(16)),Ef(Math.round(t).toString(16)),Ef(Math.round(i).toString(16))].join("")}function sf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.s-=t/100,i.s=Tf(i.s),Xd(i)}function lf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.s+=t/100,i.s=Tf(i.s),Xd(i)}function cf(e){return Xd(e).desaturate(100)}function uf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.l+=t/100,i.l=Tf(i.l),Xd(i)}function hf(e,t){t=0===t?0:t||10;var i=Xd(e).toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-t/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-t/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-t/100*255))),Xd(i)}function pf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.l-=t/100,i.l=Tf(i.l),Xd(i)}function df(e,t){var i=Xd(e).toHsl(),r=(i.h+t)%360;return i.h=r<0?360+r:r,Xd(i)}function ff(e){var t=Xd(e).toHsl();return t.h=(t.h+180)%360,Xd(t)}function mf(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var i=Xd(e).toHsl(),r=[Xd(e)],n=360/t,o=1;o<t;o++)r.push(Xd({h:(i.h+o*n)%360,s:i.s,l:i.l}));return r}function gf(e){var t=Xd(e).toHsl(),i=t.h;return[Xd(e),Xd({h:(i+72)%360,s:t.s,l:t.l}),Xd({h:(i+216)%360,s:t.s,l:t.l})]}function yf(e,t,i){t=t||6,i=i||30;var r=Xd(e).toHsl(),n=360/i,o=[Xd(e)];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,o.push(Xd(r));return o}function _f(e,t){t=t||6;for(var i=Xd(e).toHsv(),r=i.h,n=i.s,o=i.v,a=[],s=1/t;t--;)a.push(Xd({h:r,s:n,v:o})),o=(o+s)%1;return a}Xd.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,i,r=this.toRgb();return e=r.r/255,t=r.g/255,i=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},setAlpha:function(e){return this._a=wf(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=tf(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=tf(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+i+"%, "+r+"%)":"hsva("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=Qd(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Qd(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+i+"%, "+r+"%)":"hsla("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return nf(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return of(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*Cf(this._r,255))+"%",g:Math.round(100*Cf(this._g,255))+"%",b:Math.round(100*Cf(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*Cf(this._r,255))+"%, "+Math.round(100*Cf(this._g,255))+"%, "+Math.round(100*Cf(this._b,255))+"%)":"rgba("+Math.round(100*Cf(this._r,255))+"%, "+Math.round(100*Cf(this._g,255))+"%, "+Math.round(100*Cf(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(bf[nf(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+af(this._r,this._g,this._b,this._a),i=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var n=Xd(e);i="#"+af(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+i+")"},toString:function(e){var t=!!e;e=e||this._format;var i=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(i=this.toRgbString()),"prgb"===e&&(i=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(i=this.toHexString()),"hex3"===e&&(i=this.toHexString(!0)),"hex4"===e&&(i=this.toHex8String(!0)),"hex8"===e&&(i=this.toHex8String()),"name"===e&&(i=this.toName()),"hsl"===e&&(i=this.toHslString()),"hsv"===e&&(i=this.toHsvString()),i||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Xd(this.toString())},_applyModification:function(e,t){var i=e.apply(null,[this].concat([].slice.call(t)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(uf,arguments)},brighten:function(){return this._applyModification(hf,arguments)},darken:function(){return this._applyModification(pf,arguments)},desaturate:function(){return this._applyModification(sf,arguments)},saturate:function(){return this._applyModification(lf,arguments)},greyscale:function(){return this._applyModification(cf,arguments)},spin:function(){return this._applyModification(df,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(yf,arguments)},complement:function(){return this._applyCombination(ff,arguments)},monochromatic:function(){return this._applyCombination(_f,arguments)},splitcomplement:function(){return this._applyCombination(gf,arguments)},triad:function(){return this._applyCombination(mf,[3])},tetrad:function(){return this._applyCombination(mf,[4])}},Xd.fromRatio=function(e,t){if("object"==Hd(e)){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]="a"===r?e[r]:Pf(e[r]));e=i}return Xd(e,t)},Xd.equals=function(e,t){return!(!e||!t)&&Xd(e).toRgbString()==Xd(t).toRgbString()},Xd.random=function(){return Xd.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Xd.mix=function(e,t,i){i=0===i?0:i||50;var r=Xd(e).toRgb(),n=Xd(t).toRgb(),o=i/100;return Xd({r:(n.r-r.r)*o+r.r,g:(n.g-r.g)*o+r.g,b:(n.b-r.b)*o+r.b,a:(n.a-r.a)*o+r.a})},Xd.readability=function(e,t){var i=Xd(e),r=Xd(t);return(Math.max(i.getLuminance(),r.getLuminance())+.05)/(Math.min(i.getLuminance(),r.getLuminance())+.05)},Xd.isReadable=function(e,t,i){var r,n,o=Xd.readability(e,t);switch(n=!1,(r=Ff(i)).level+r.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7}return n},Xd.mostReadable=function(e,t,i){var r,n,o,a,s=null,l=0;n=(i=i||{}).includeFallbackColors,o=i.level,a=i.size;for(var c=0;c<t.length;c++)(r=Xd.readability(e,t[c]))>l&&(l=r,s=Xd(t[c]));return Xd.isReadable(e,s,{level:o,size:a})||!n?s:(i.includeFallbackColors=!1,Xd.mostReadable(e,["#fff","#000"],i))};var vf=Xd.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},bf=Xd.hexNames=xf(vf);function xf(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function wf(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function Cf(e,t){Sf(e)&&(e="100%");var i=Mf(e);return e=Math.min(t,Math.max(0,parseFloat(e))),i&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function Tf(e){return Math.min(1,Math.max(0,e))}function Af(e){return parseInt(e,16)}function Sf(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)}function Mf(e){return"string"==typeof e&&-1!=e.indexOf("%")}function Ef(e){return 1==e.length?"0"+e:""+e}function Pf(e){return e<=1&&(e=100*e+"%"),e}function If(e){return Math.round(255*parseFloat(e)).toString(16)}function kf(e){return Af(e)/255}var zf=function(){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",t="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+t),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+t),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+t),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Lf(e){return!!zf.CSS_UNIT.exec(e)}function Df(e){e=e.replace(Wd,"").replace(Kd,"").toLowerCase();var t,i=!1;if(vf[e])e=vf[e],i=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(t=zf.rgb.exec(e))?{r:t[1],g:t[2],b:t[3]}:(t=zf.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=zf.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=zf.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=zf.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=zf.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=zf.hex8.exec(e))?{r:Af(t[1]),g:Af(t[2]),b:Af(t[3]),a:kf(t[4]),format:i?"name":"hex8"}:(t=zf.hex6.exec(e))?{r:Af(t[1]),g:Af(t[2]),b:Af(t[3]),format:i?"name":"hex"}:(t=zf.hex4.exec(e))?{r:Af(t[1]+""+t[1]),g:Af(t[2]+""+t[2]),b:Af(t[3]+""+t[3]),a:kf(t[4]+""+t[4]),format:i?"name":"hex8"}:!!(t=zf.hex3.exec(e))&&{r:Af(t[1]+""+t[1]),g:Af(t[2]+""+t[2]),b:Af(t[3]+""+t[3]),format:i?"name":"hex"}}function Ff(e){var t,i;return"AA"!==(t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==t&&(t="AA"),"small"!==(i=(e.size||"small").toLowerCase())&&"large"!==i&&(i="small"),{level:t,size:i}}const Rf=["name","state","icon","attribute"],Bf=st(((e,t,i)=>[{name:"entity",lebel:"Entity",selector:{entity:{filter:{domain:["device_tracker","person","zone"]}}}},{name:"",type:"grid",schema:[{name:"name",label:"Name",default:"",type:"string"},{name:"icon",label:"Icon",selector:{icon:{}}},...e?[]:[{name:"label_mode",label:"Label Mode",selector:{select:{mode:"dropdown",options:Rf.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"attribute",label:"Attribute",disabled:i,selector:{attribute:{entity_id:t}}}],{name:"focus",label:"Focus",required:!1,type:"boolean"}]}]));class Of extends Xe{constructor(){super(...arguments),this._rgbColor=[0,0,0],this._computeLabel=e=>e.label||"",this._colorToRgb=e=>{const t=Xd(e);if(!t.isValid())return[0,0,0];const{r:i,g:r,b:n}=t.toRgb();return[i,r,n]}}firstUpdated(){var e;if(null===(e=this.config.elementConfig)||void 0===e?void 0:e.color){const e=this._colorToRgb(this.config.elementConfig.color);this._rgbColor=e}else{const e=ct(this.config.index||0),t=this._colorToRgb(e);this._rgbColor=t}}render(){return ke`
477
472
  <div class="header">
478
473
  <div class="back-title">
479
474
  <ha-icon-button-prev
@@ -484,7 +479,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
484
479
  </div>
485
480
  </div>
486
481
  ${this._renderContent()}
487
- `}_renderContent(){var e;const t=Object.assign({},this.config.elementConfig),i=!!(null===(e=t.entity)||void 0===e?void 0:e.startsWith("zone.")),r="attribute"!==t.label_mode,n=Pf(i,t.entity,r);return ke`
482
+ `}_renderContent(){var e;const t=Object.assign({},this.config.elementConfig),i=!!(null===(e=t.entity)||void 0===e?void 0:e.startsWith("zone.")),r="attribute"!==t.label_mode,n=Bf(i,t.entity,r);return ke`
488
483
  <ha-form
489
484
  .hass=${this.hass}
490
485
  .data=${t}
@@ -500,7 +495,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
500
495
  .required=${!1}
501
496
  @value-changed=${this._colorChanged}
502
497
  ></ha-selector>
503
- `}_goBack(){C(this,"go-back")}_colorChanged(e){if(e.stopPropagation(),!this.config)return;const t=e.detail.value,i=Vd(`rgb(${t.join(",")})`).toHexString(),r=Object.assign({},this.config.elementConfig);r.color=i,this.config=Object.assign(Object.assign({},this.config),{elementConfig:Object.assign(Object.assign({},r),{entity:r.entity||""})}),C(this,"config-changed",{config:this.config}),this._rgbColor=t}_valueChanged(e){e.stopPropagation();let t=e.detail.value;this.config.elementConfig=Object.assign(Object.assign({},this.config.elementConfig),t),C(this,"config-changed",{config:this.config}),this.requestUpdate()}}If.styles=G`
498
+ `}_goBack(){C(this,"go-back")}_colorChanged(e){if(e.stopPropagation(),!this.config)return;const t=e.detail.value,i=Xd(`rgb(${t.join(",")})`).toHexString(),r=Object.assign({},this.config.elementConfig);r.color=i,this.config=Object.assign(Object.assign({},this.config),{elementConfig:Object.assign(Object.assign({},r),{entity:r.entity||""})}),C(this,"config-changed",{config:this.config}),this._rgbColor=t}_valueChanged(e){e.stopPropagation();let t=e.detail.value;this.config.elementConfig=Object.assign(Object.assign({},this.config.elementConfig),t),C(this,"config-changed",{config:this.config}),this.requestUpdate()}}Of.styles=G`
504
499
  .header {
505
500
  display: flex;
506
501
  justify-content: space-between;
@@ -511,7 +506,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
511
506
  align-items: center;
512
507
  font-size: var(--ha-font-size-l);
513
508
  }
514
- `,e([et({attribute:!1})],If.prototype,"hass",void 0),e([et({attribute:!1})],If.prototype,"config",void 0),e([tt()],If.prototype,"_rgbColor",void 0),customElements.get("emc-sub-entity-editor")||customElements.define("emc-sub-entity-editor",If);class kf extends Xe{constructor(){super(...arguments),this._computeLabelCallback=e=>{var t,i;let r=null===(t=this.hass)||void 0===t?void 0:t.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`);return r||(r=null===(i=this.hass)||void 0===i?void 0:i.localize(`ui.panel.lovelace.editor.card.${e.label}`),r||e.label)}}connectedCallback(){super.connectedCallback(),td(),window.ExtraMapEditor=this}disconnectedCallback(){super.disconnectedCallback()}setConfig(e){this._config=e,this._configEntities=e.entities?Cd(e.entities):[]}render(){var e;if(!this.hass||!this._config)return Le;if(this._subEntityEditorConfig)return ke`
509
+ `,e([et({attribute:!1})],Of.prototype,"hass",void 0),e([et({attribute:!1})],Of.prototype,"config",void 0),e([tt()],Of.prototype,"_rgbColor",void 0);class jf extends Xe{constructor(){super(...arguments),this._computeLabelCallback=e=>{var t,i;let r=null===(t=this.hass)||void 0===t?void 0:t.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`);return r||(r=null===(i=this.hass)||void 0===i?void 0:i.localize(`ui.panel.lovelace.editor.card.${e.label}`),r||e.label)}}connectedCallback(){super.connectedCallback(),td(),window.ExtraMapEditor=this}disconnectedCallback(){super.disconnectedCallback()}setConfig(e){this._config=e,this._configEntities=e.entities?Cd(e.entities):[]}render(){var e;if(!this.hass||!this._config)return Le;if(this._subEntityEditorConfig)return ke`
515
510
  <emc-sub-entity-editor
516
511
  .hass=${this.hass}
517
512
  .config=${this._subEntityEditorConfig}
@@ -600,4 +595,4 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
600
595
  justify-content: center;
601
596
  align-items: center;
602
597
  }
603
- `}}e([et({attribute:!1})],kf.prototype,"hass",void 0),e([tt()],kf.prototype,"_config",void 0),e([tt()],kf.prototype,"_configEntities",void 0),e([tt()],kf.prototype,"_subEntityEditorConfig",void 0),customElements.get("extra-map-editor")||customElements.define("extra-map-editor",kf);var zf=Object.freeze({__proto__:null,ExtraMapEditor:kf});export{up as CARD_VERSION,lt as COLORS,pp as DARK_AVAILABLE_STYLES,mp as DEFAULT_HOURS_TO_SHOW,gp as DEFAULT_ZOOM,Od as EmcEntityEditor,xd as EmcMap,If as EmcSubEntityEditor,wd as ExtraMapCard,fd as LOCAL_TIME_ZONE,fp as STYLE_OPTIONS,hp as STYLE_SCHEMA,xp as baseMapConfigSchema,ut as computeObjectId,pt as computeStateName,ht as computeStateNameFromEntityAttributes,b as createResource,m as deleteConfig,w as deleteResource,_ as ensureBadgeConfig,R as entityIdHistoryNeedsAttributes,d as fetchConfig,B as fetchDateWS,v as fetchResources,n as findCardIndex,ft as findEntities,c as findLovelaceCards,l as findLovelaceContainer,C as fireEvent,yd as formatTimeWeekday,pd as getAddress,ct as getColorByIndex,hd as getEntityId,i as getLovelace,s as getLovelaceContainerPath,_t as hasConfigChanged,wt as hasConfigOrEntitiesChanged,xt as hasConfigOrEntityChanged,Td as hasLocation,t as isComponentLoaded,p as isStrategyDashboard,y as isStrategySection,g as isStrategyView,gt as isValidEntityId,wp as mapConfigSchema,o as parseLovelaceCardPath,a as parseLovelaceContainerPath,yt as processConfigEntities,Cd as processEditorEntities,md as resolveTimeZone,f as saveConfig,bp as singleMapConfingSchema,j as subscribeHistory,O as subscribeHistoryStatesTimeWindow,T as subscribeRenderTemplate,h as updateLovelaceCards,u as updateLovelaceContainer,x as updateResource,gd as useAmPm};
598
+ `}}e([et({attribute:!1})],jf.prototype,"hass",void 0),e([tt()],jf.prototype,"_config",void 0),e([tt()],jf.prototype,"_configEntities",void 0),e([tt()],jf.prototype,"_subEntityEditorConfig",void 0);var $f=Object.freeze({__proto__:null,ExtraMapEditor:jf});export{up as CARD_VERSION,lt as COLORS,pp as DARK_AVAILABLE_STYLES,mp as DEFAULT_HOURS_TO_SHOW,gp as DEFAULT_ZOOM,Gd as EmcEntityEditor,xd as EmcMap,Of as EmcSubEntityEditor,wd as ExtraMapCard,fd as LOCAL_TIME_ZONE,fp as STYLE_OPTIONS,hp as STYLE_SCHEMA,kd as addResource,xp as baseMapConfigSchema,ut as computeObjectId,pt as computeStateName,ht as computeStateNameFromEntityAttributes,b as createResource,m as deleteConfig,w as deleteResource,_ as ensureBadgeConfig,R as entityIdHistoryNeedsAttributes,d as fetchConfig,B as fetchDateWS,v as fetchResources,n as findCardIndex,ft as findEntities,c as findLovelaceCards,l as findLovelaceContainer,C as fireEvent,yd as formatTimeWeekday,pd as getAddress,ct as getColorByIndex,hd as getEntityId,i as getLovelace,s as getLovelaceContainerPath,_t as hasConfigChanged,wt as hasConfigOrEntitiesChanged,xt as hasConfigOrEntityChanged,Td as hasLocation,t as isComponentLoaded,p as isStrategyDashboard,y as isStrategySection,g as isStrategyView,gt as isValidEntityId,wp as mapConfigSchema,o as parseLovelaceCardPath,a as parseLovelaceContainerPath,yt as processConfigEntities,Cd as processEditorEntities,zd as resetAddResource,md as resolveTimeZone,f as saveConfig,bp as singleMapConfingSchema,j as subscribeHistory,O as subscribeHistoryStatesTimeWindow,T as subscribeRenderTemplate,h as updateLovelaceCards,u as updateLovelaceContainer,x as updateResource,gd as useAmPm};
package/dist/index.js CHANGED
@@ -216,12 +216,12 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
216
216
  font-weight: 300;
217
217
  font-size: 16px;
218
218
  max-width: calc(100% - 80px);
219
- }`,Hh=6371008.8,Wh={centimeters:100*Hh,centimetres:100*Hh,degrees:360/(2*Math.PI),feet:3.28084*Hh,inches:39.37*Hh,kilometers:Hh/1e3,kilometres:Hh/1e3,meters:Hh,metres:Hh,miles:Hh/1609.344,millimeters:1e3*Hh,millimetres:1e3*Hh,nauticalmiles:Hh/1852,radians:1,yards:1.0936*Hh};function Kh(e,t,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=t||{},r.geometry=e,r}function Xh(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tp(e[0])||!tp(e[1]))throw new Error("coordinates must contain numbers");return Kh({type:"Point",coordinates:e},t,i)}function Yh(e,t,i={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return Kh({type:"Polygon",coordinates:e},t,i)}function Jh(e,t="kilometers"){const i=Wh[t];if(!i)throw new Error(t+" units is invalid");return e/i}function Qh(e){return 180*(e%(2*Math.PI))/Math.PI}function ep(e){return e%360*Math.PI/180}function tp(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ip(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function rp(e,t,i,r={}){const n=ip(e),o=ep(n[0]),a=ep(n[1]),s=ep(i),l=Jh(t,r.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s));return Xh([Qh(o+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),Qh(c)],r.properties)}function np(e,t,i={}){const r=i.steps||64,n=i.properties?i.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},o=[];for(let n=0;n<r;n++)o.push(rp(e,t,-360*n/r,i).geometry.coordinates);return o.push(o[0]),Yh([o],n)}var op="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",ap="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",sp="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",lp="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",cp="1.3.1";const up=cp,hp=[{name:"Navigation and city exploration",selector:{select:{options:["STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL"]}}},{name:"Data visualization",selector:{select:{options:["DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT"]}}},{name:"Minimalist and general purpose",selector:{select:{options:["BASIC","BASIC.DARK","BASIC.LIGHT"]}}},{name:"High contrast navigation",selector:{select:{options:["BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL"]}}},{name:"Topographic study",selector:{select:{options:["TOPO","TOPO.SHINY","TOPO.PASTEL","TOPO.TOPOGRAPHIQUE"]}}},{name:"Minimalist",selector:{select:{options:["VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE"]}}},{name:"High contrast",selector:{select:{options:["TONER","TONER.BACKGROUND","TONER.LITE","TONER.LINES"]}}},{name:"Neutral greyscale style with hillshading",selector:{select:{options:["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT"]}}},{name:"Other",selector:{select:{options:["OPENSTREETMAP","OUTDOOR","WINTER","SATELLITE","HYBRID"]}}}],pp=["STREETS","BASIC","BRIGHT","DATAVIZ","VOYAGER","BACKDROP"],dp=()=>hp.reduce(((e,t)=>{const i=t.selector.select.options;return e.concat(i.map((e=>({value:e,label:e}))))}),[]),fp=dp(),mp=0,gp=13,yp=["auto","light","dark"],_p=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:gp,selector:{number:{mode:"box",min:0}}},{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:yp.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show",label:"Hours to Show",default:0,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",default:"",selector:{select:{mode:"dropdown",options:[{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"}]}}},{name:"auto_fit",label:"Auto Fit",default:!1,selector:{boolean:{}}},{name:"fit_zones",label:"Fit Zones",default:!1,selector:{boolean:{}}},{name:"use_more_info",label:"Marker more info",default:!1,selector:{boolean:{}}}],vp={name:"custom_styles",type:"expandable",iconPath:sp,title:"Custom Styles",schema:[{name:"",type:"grid",schema:[{name:"light",label:"Light Style",selector:{select:{mode:"dropdown",options:fp}}},{name:"dark",label:"Dark Style",selector:{select:{mode:"dropdown",options:fp}}}]}]},bp=st((e=>[{name:"",type:"expandable",iconPath:sp,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[..._p]},vp]}])),xp=st((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),wp=st((e=>[...xp(),...bp(e)])),Cp=Symbol.for("constructDateFrom");function Tp(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Cp in e?e[Cp](t):e instanceof Date?new e.constructor(t):new Date(t)}function Ap(e,t){return Tp(e,e)}function Sp(e,...t){const i=Tp.bind(null,t.find((e=>"object"==typeof e)));return t.map(i)}function Mp(e,t){const i=Ap(e);return i.setHours(0,0,0,0),i}function Ep(e){return Tp(e,Date.now())}function Pp(e,t,i){const[r,n]=Sp(i?.in,e,t);return+Mp(r)==+Mp(n)}function Ip(e,t){return Pp(Tp(e,e),Ep(e))}const kp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],zp=1,Lp=8;class Dp{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=kp[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Dp(a,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=kp.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Fp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:a}=this,s=[0,n.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=a){for(let a=h;a<=u;a++){const s=o[2*a],c=o[2*a+1];s>=e&&s<=i&&c>=t&&c<=r&&l.push(n[a])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=e&&d<=i&&f>=t&&f<=r&&l.push(n[p]),(0===c?e<=d:t<=f)&&(s.push(h),s.push(p-1),s.push(1-c)),(0===c?i>=d:r>=f)&&(s.push(p+1),s.push(u),s.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=i*i;for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)jp(n[2*i],n[2*i+1],e,t)<=l&&s.push(r[i]);continue}const p=h+u>>1,d=n[2*p],f=n[2*p+1];jp(d,f,e,t)<=l&&s.push(r[p]),(0===c?e-i<=d:t-i<=f)&&(a.push(h),a.push(p-1),a.push(1-c)),(0===c?e+i>=d:t+i>=f)&&(a.push(p+1),a.push(u),a.push(1-c))}return s}}function Fp(e,t,i,r,n,o){if(n-r<=i)return;const a=r+n>>1;Rp(e,t,a,r,n,o),Fp(e,t,i,r,a-1,1-o),Fp(e,t,i,a+1,n,1-o)}function Rp(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const a=n-r+1,s=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);Rp(e,t,i,Math.max(r,Math.floor(i-s*c/a+u)),Math.min(n,Math.floor(i+(a-s)*c/a+u)),o)}const a=t[2*i+o];let s=r,l=n;for(Bp(e,t,r,i),t[2*n+o]>a&&Bp(e,t,r,n);s<l;){for(Bp(e,t,s,l),s++,l--;t[2*s+o]<a;)s++;for(;t[2*l+o]>a;)l--}t[2*r+o]===a?Bp(e,t,r,l):(l++,Bp(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Bp(e,t,i,r){Op(e,i,r),Op(t,2*i,2*r),Op(t,2*i+1,2*r+1)}function Op(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function jp(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const $p={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Np=Math.fround||(e=>t=>(e[0]=+t,e[0]))(new Float32Array(1)),Vp=2,Up=3,qp=4,Zp=5,Gp=6;class Hp{constructor(e){this.options=Object.assign(Object.create($p),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,a=Np(Xp(r)),s=Np(Yp(n));o.push(a,s,1/0,t,-1,1),this.options.reduce&&o.push(0)}let a=this.trees[r+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=r;e>=i;e--){Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e))}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),a=this.getClusters([-180,r,n,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(Xp(i),Yp(o),Xp(n),Yp(r)),l=a.data,c=[];for(const e of s){const t=this.stride*e;c.push(l[t+5]>1?Wp(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=o[t*this.stride],l=o[t*this.stride+1],c=n.within(s,l,a),u=[];for(const t of c){const i=t*this.stride;o[i+4]===e&&u.push(o[i+5]>1?Wp(o,i,this.clusterProps):this.points[o[i+3]])}if(0===u.length)throw new Error(r);return u}getLeaves(e,t,i){t=t||10,i=i||0;const r=[];return this._appendLeaves(r,e,t,i,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(i-s)/n,c=(i+1+s)/n,u={features:[]};return this._addTileFeatures(r.range((t-s)/n,l,(t+1+s)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_createTree(e){const t=new Dp(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.data=e,t}_addTileFeatures(e,t,i,r,n,o){for(const a of e){const e=a*this.stride,s=t[e+5]>1;let l,c,u;if(s)l=Kp(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=Xp(r),u=Yp(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let p;p=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,a=i/(r*Math.pow(2,t)),s=e.data,l=[],c=this.stride;for(let i=0;i<s.length;i+=c){if(s[i+2]<=t)continue;s[i+2]=t;const r=s[i],u=s[i+1],h=e.within(s[i],s[i+1],a),p=s[i+5];let d=p;for(const e of h){const i=e*c;s[i+2]>t&&(d+=s[i+5])}if(d>p&&d>=o){let e,o=r*p,a=u*p,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(s[l+2]<=t)continue;s[l+2]=t;const u=s[l+5];o+=s[l]*u,a+=s[l+1]*u,s[l+4]=m,n&&(e||(e=this._map(s,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(s,l)))}s[i+4]=m,l.push(o/d,a/d,1/0,m,-1,d),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(s[i+e]);if(d>1)for(const e of h){const i=e*c;if(!(s[i+2]<=t)){s[i+2]=t;for(let e=0;e<c;e++)l.push(s[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function Wp(e,t,i){return{type:"Feature",id:e[t+3],properties:Kp(e,t,i),geometry:{type:"Point",coordinates:[Jp(e[t]),Qp(e[t+1])]}}}function Kp(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],a=-1===o?{}:Object.assign({},i[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}function Xp(e){return e/360+.5}function Yp(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function Jp(e){return 360*(e-.5)}function Qp(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}const ed=window.loadCardHelpers?window.loadCardHelpers():void 0,td=()=>{var e,t,i,r,n,o;customElements.get("ha-entity-marker")||null===(e=customElements.get("hui-map-card"))||void 0===e||e.getConfigElement(),customElements.get("ha-form")||null===(t=customElements.get("hui-button-card"))||void 0===t||t.getConfigElement(),customElements.get("ha-entity-picker")||null===(i=customElements.get("hui-entities-card"))||void 0===i||i.getConfigElement(),customElements.get("ha-card-conditions-editor")||null===(r=customElements.get("hui-conditional-card"))||void 0===r||r.getConfigElement(),customElements.get("ha-form-multi_select")||null===(n=customElements.get("hui-entities-card"))||void 0===n||n.getConfigElement(),customElements.get("hui-entity-editor")||null===(o=customElements.get("hui-glance-card"))||void 0===o||o.getConfigElement()},id=async e=>{if(!customElements.get("ha-entity-marker")){const t={type:"map",entities:e,theme_mode:"auto"};let i;if(window.loadCardHelpers?i=await window.loadCardHelpers():ed&&(i=ed),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var rd,nd,od,ad,sd,ld,cd,ud;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(rd||(rd={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(nd||(nd={})),function(e){e.local="local",e.server="server"}(od||(od={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(ad||(ad={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(sd||(sd={}));const hd=e=>"string"==typeof e?e:e.entity_id,pd=st((async(e,t,i)=>{const r={address:"streetName",locality:"sublocality",municipality:"city"},n=`https://api.maptiler.com/geocoding/${t},${e}.json?key=${i}`;try{const e=await fetch(n);if(!e.ok)throw new Error("Failed to fetch address from MapTiler");const t=await e.json();if(t&&t.features&&t.features.length>0){let e={};if(t.features.forEach((t=>{const i=t.place_type[0];if(r[i]){const n=r[i],o=t.text;"address"===i&&(e.streetNumber=t.address?`${t.address}`:""),e[n]=`${o}`}})),e.streetName&&e.city)return e}return null}catch(e){return console.warn("Error fetching address from MapTiler:",e),null}})),dd=null===(ud=null===(ld=Intl.DateTimeFormat)||void 0===ld?void 0:(cd=ld.call(Intl)).resolvedOptions)||void 0===ud?void 0:ud.call(cd).timeZone,fd=null!=dd?dd:"UTC",md=(e,t)=>e===od.local&&dd?fd:t,gd=st((e=>{if(e.time_format===nd.language||e.time_format===nd.system){const t=e.time_format===nd.language?e.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(t).includes("10")}return e.time_format===nd.am_pm})),yd=(e,t,i)=>_d(t,i.time_zone).format(e),_d=st(((e,t)=>new Intl.DateTimeFormat(e.language,{weekday:"long",hour:gd(e)?"numeric":"2-digit",minute:"2-digit",hour12:gd(e),timeZone:md(e.time_zone,t)}))),vd={dark:ti.STREETS.DARK,light:ti.DATAVIZ.LIGHT,demo:"https://demotiles.maplibre.org/style.json"},bd={backgroundColor:{light:"#fff",dark:"#222222"},fill:{light:"#222222",dark:"#c1c1c1"},boxShadow:{light:"0 0 0 2px rgba(0, 0, 0, 0.1)",dark:"0 0 0 2px rgba(255, 255, 255, 0.1)"},borderTop:{light:"1px solid #ddd",dark:"1px solid #424242"},themeBtn:{light:"mdi:weather-sunny",dark:"mdi:weather-night"}};class xd extends Xe{constructor(){super(...arguments),this.autoFit=!1,this.fitZones=!1,this.zoom=gp,this.themeMode="auto",this.useMoreInfo=!1,this._darkStyle=!1,this._mapItems=[],this._zoneItems=[],this._mapFocusZones=[],this._mapFocusItems=[],this._mapPaths=[],this._mapHelper=yh,this._clusters=[],this._mapClusterItems=[],this._mapClusterFocusItems=[],this._circleLoaded=!1,this._loaded=!1,this._entitiesDrawn=!1,this._createButton=(e,t)=>{const i=document.createElement("div");i.classList.add("maplibregl-ctrl","maplibregl-ctrl-group");const r=document.createElement("button"),n=document.createElement("ha-icon");return n.setAttribute("icon",e),n.style.color="var(--emc-btn-color)",r.appendChild(n),r.title=t,i.appendChild(r),i.style.display="none",i},this.getModeColor=(e,t)=>t?bd[e][t]:this._darkMode?bd[e].dark:bd[e].light}get _darkMode(){return"dark"===this.themeMode||"auto"===this.themeMode&&Boolean(this.hass.themes.darkMode)}async firstUpdated(){await id(this.entities),await new Promise((e=>setTimeout(e,0))),this._initMap()}render(){const e=this._renderLoadError();return ke`
219
+ }`,Hh=6371008.8,Wh={centimeters:100*Hh,centimetres:100*Hh,degrees:360/(2*Math.PI),feet:3.28084*Hh,inches:39.37*Hh,kilometers:Hh/1e3,kilometres:Hh/1e3,meters:Hh,metres:Hh,miles:Hh/1609.344,millimeters:1e3*Hh,millimetres:1e3*Hh,nauticalmiles:Hh/1852,radians:1,yards:1.0936*Hh};function Kh(e,t,i={}){const r={type:"Feature"};return(0===i.id||i.id)&&(r.id=i.id),i.bbox&&(r.bbox=i.bbox),r.properties=t||{},r.geometry=e,r}function Xh(e,t,i={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tp(e[0])||!tp(e[1]))throw new Error("coordinates must contain numbers");return Kh({type:"Point",coordinates:e},t,i)}function Yh(e,t,i={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return Kh({type:"Polygon",coordinates:e},t,i)}function Jh(e,t="kilometers"){const i=Wh[t];if(!i)throw new Error(t+" units is invalid");return e/i}function Qh(e){return 180*(e%(2*Math.PI))/Math.PI}function ep(e){return e%360*Math.PI/180}function tp(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ip(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function rp(e,t,i,r={}){const n=ip(e),o=ep(n[0]),a=ep(n[1]),s=ep(i),l=Jh(t,r.units),c=Math.asin(Math.sin(a)*Math.cos(l)+Math.cos(a)*Math.sin(l)*Math.cos(s));return Xh([Qh(o+Math.atan2(Math.sin(s)*Math.sin(l)*Math.cos(a),Math.cos(l)-Math.sin(a)*Math.sin(c))),Qh(c)],r.properties)}function np(e,t,i={}){const r=i.steps||64,n=i.properties?i.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},o=[];for(let n=0;n<r;n++)o.push(rp(e,t,-360*n/r,i).geometry.coordinates);return o.push(o[0]),Yh([o],n)}var op="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",ap="M7,19V17H9V19H7M11,19V17H13V19H11M15,19V17H17V19H15M7,15V13H9V15H7M11,15V13H13V15H11M15,15V13H17V15H15M7,11V9H9V11H7M11,11V9H13V11H11M15,11V9H17V11H15M7,7V5H9V7H7M11,7V5H13V7H11M15,7V5H17V7H15Z",sp="M17.5,12A1.5,1.5 0 0,1 16,10.5A1.5,1.5 0 0,1 17.5,9A1.5,1.5 0 0,1 19,10.5A1.5,1.5 0 0,1 17.5,12M14.5,8A1.5,1.5 0 0,1 13,6.5A1.5,1.5 0 0,1 14.5,5A1.5,1.5 0 0,1 16,6.5A1.5,1.5 0 0,1 14.5,8M9.5,8A1.5,1.5 0 0,1 8,6.5A1.5,1.5 0 0,1 9.5,5A1.5,1.5 0 0,1 11,6.5A1.5,1.5 0 0,1 9.5,8M6.5,12A1.5,1.5 0 0,1 5,10.5A1.5,1.5 0 0,1 6.5,9A1.5,1.5 0 0,1 8,10.5A1.5,1.5 0 0,1 6.5,12M12,3A9,9 0 0,0 3,12A9,9 0 0,0 12,21A1.5,1.5 0 0,0 13.5,19.5C13.5,19.11 13.35,18.76 13.11,18.5C12.88,18.23 12.73,17.88 12.73,17.5A1.5,1.5 0 0,1 14.23,16H16A5,5 0 0,0 21,11C21,6.58 16.97,3 12,3Z",lp="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",cp="1.3.3";const up=cp,hp=[{name:"Navigation and city exploration",selector:{select:{options:["STREETS","STREETS.DARK","STREETS.LIGHT","STREETS.PASTEL"]}}},{name:"Data visualization",selector:{select:{options:["DATAVIZ","DATAVIZ.DARK","DATAVIZ.LIGHT"]}}},{name:"Minimalist and general purpose",selector:{select:{options:["BASIC","BASIC.DARK","BASIC.LIGHT"]}}},{name:"High contrast navigation",selector:{select:{options:["BRIGHT","BRIGHT.DARK","BRIGHT.LIGHT","BRIGHT.PASTEL"]}}},{name:"Topographic study",selector:{select:{options:["TOPO","TOPO.SHINY","TOPO.PASTEL","TOPO.TOPOGRAPHIQUE"]}}},{name:"Minimalist",selector:{select:{options:["VOYAGER","VOYAGER.DARK","VOYAGER.LIGHT","VOYAGER.VINTAGE"]}}},{name:"High contrast",selector:{select:{options:["TONER","TONER.BACKGROUND","TONER.LITE","TONER.LINES"]}}},{name:"Neutral greyscale style with hillshading",selector:{select:{options:["BACKDROP","BACKDROP.DARK","BACKDROP.LIGHT"]}}},{name:"Other",selector:{select:{options:["OPENSTREETMAP","OUTDOOR","WINTER","SATELLITE","HYBRID"]}}}],pp=["STREETS","BASIC","BRIGHT","DATAVIZ","VOYAGER","BACKDROP"],dp=()=>hp.reduce(((e,t)=>{const i=t.selector.select.options;return e.concat(i.map((e=>({value:e,label:e}))))}),[]),fp=dp(),mp=0,gp=13,yp=["auto","light","dark"],_p=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:gp,selector:{number:{mode:"box",min:0}}},{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:yp.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"hours_to_show",label:"Hours to Show",default:0,selector:{number:{mode:"box",min:0}}},{name:"history_period",label:"History Period",default:"",selector:{select:{mode:"dropdown",options:[{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"}]}}},{name:"auto_fit",label:"Auto Fit",default:!1,selector:{boolean:{}}},{name:"fit_zones",label:"Fit Zones",default:!1,selector:{boolean:{}}},{name:"use_more_info",label:"Marker more info",default:!1,selector:{boolean:{}}}],vp={name:"custom_styles",type:"expandable",iconPath:sp,title:"Custom Styles",schema:[{name:"",type:"grid",schema:[{name:"light",label:"Light Style",selector:{select:{mode:"dropdown",options:fp}}},{name:"dark",label:"Dark Style",selector:{select:{mode:"dropdown",options:fp}}}]}]},bp=st((e=>[{name:"",type:"expandable",iconPath:sp,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[..._p]},vp]}])),xp=st((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),wp=st((e=>[...xp(),...bp(e)])),Cp=Symbol.for("constructDateFrom");function Tp(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&Cp in e?e[Cp](t):e instanceof Date?new e.constructor(t):new Date(t)}function Ap(e,t){return Tp(e,e)}function Sp(e,...t){const i=Tp.bind(null,t.find((e=>"object"==typeof e)));return t.map(i)}function Mp(e,t){const i=Ap(e);return i.setHours(0,0,0,0),i}function Ep(e){return Tp(e,Date.now())}function Pp(e,t,i){const[r,n]=Sp(i?.in,e,t);return+Mp(r)==+Mp(n)}function Ip(e,t){return Pp(Tp(e,e),Ep(e))}const kp=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],zp=1,Lp=8;class Dp{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=kp[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Dp(a,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=kp.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Fp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:a}=this,s=[0,n.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=a){for(let a=h;a<=u;a++){const s=o[2*a],c=o[2*a+1];s>=e&&s<=i&&c>=t&&c<=r&&l.push(n[a])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=e&&d<=i&&f>=t&&f<=r&&l.push(n[p]),(0===c?e<=d:t<=f)&&(s.push(h),s.push(p-1),s.push(1-c)),(0===c?i>=d:r>=f)&&(s.push(p+1),s.push(u),s.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=i*i;for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)jp(n[2*i],n[2*i+1],e,t)<=l&&s.push(r[i]);continue}const p=h+u>>1,d=n[2*p],f=n[2*p+1];jp(d,f,e,t)<=l&&s.push(r[p]),(0===c?e-i<=d:t-i<=f)&&(a.push(h),a.push(p-1),a.push(1-c)),(0===c?e+i>=d:t+i>=f)&&(a.push(p+1),a.push(u),a.push(1-c))}return s}}function Fp(e,t,i,r,n,o){if(n-r<=i)return;const a=r+n>>1;Rp(e,t,a,r,n,o),Fp(e,t,i,r,a-1,1-o),Fp(e,t,i,a+1,n,1-o)}function Rp(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const a=n-r+1,s=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);Rp(e,t,i,Math.max(r,Math.floor(i-s*c/a+u)),Math.min(n,Math.floor(i+(a-s)*c/a+u)),o)}const a=t[2*i+o];let s=r,l=n;for(Bp(e,t,r,i),t[2*n+o]>a&&Bp(e,t,r,n);s<l;){for(Bp(e,t,s,l),s++,l--;t[2*s+o]<a;)s++;for(;t[2*l+o]>a;)l--}t[2*r+o]===a?Bp(e,t,r,l):(l++,Bp(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function Bp(e,t,i,r){Op(e,i,r),Op(t,2*i,2*r),Op(t,2*i+1,2*r+1)}function Op(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function jp(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const $p={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},Np=Math.fround||(e=>t=>(e[0]=+t,e[0]))(new Float32Array(1)),Vp=2,Up=3,qp=4,Zp=5,Gp=6;class Hp{constructor(e){this.options=Object.assign(Object.create($p),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const i=e[t];if(!i.geometry)continue;const[r,n]=i.geometry.coordinates,a=Np(Xp(r)),s=Np(Yp(n));o.push(a,s,1/0,t,-1,1),this.options.reduce&&o.push(0)}let a=this.trees[r+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=r;e>=i;e--){Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e))}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),a=this.getClusters([-180,r,n,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(Xp(i),Yp(o),Xp(n),Yp(r)),l=a.data,c=[];for(const e of s){const t=this.stride*e;c.push(l[t+5]>1?Wp(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=o[t*this.stride],l=o[t*this.stride+1],c=n.within(s,l,a),u=[];for(const t of c){const i=t*this.stride;o[i+4]===e&&u.push(o[i+5]>1?Wp(o,i,this.clusterProps):this.points[o[i+3]])}if(0===u.length)throw new Error(r);return u}getLeaves(e,t,i){t=t||10,i=i||0;const r=[];return this._appendLeaves(r,e,t,i,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(i-s)/n,c=(i+1+s)/n,u={features:[]};return this._addTileFeatures(r.range((t-s)/n,l,(t+1+s)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_createTree(e){const t=new Dp(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.data=e,t}_addTileFeatures(e,t,i,r,n,o){for(const a of e){const e=a*this.stride,s=t[e+5]>1;let l,c,u;if(s)l=Kp(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=Xp(r),u=Yp(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let p;p=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:o}=this.options,a=i/(r*Math.pow(2,t)),s=e.data,l=[],c=this.stride;for(let i=0;i<s.length;i+=c){if(s[i+2]<=t)continue;s[i+2]=t;const r=s[i],u=s[i+1],h=e.within(s[i],s[i+1],a),p=s[i+5];let d=p;for(const e of h){const i=e*c;s[i+2]>t&&(d+=s[i+5])}if(d>p&&d>=o){let e,o=r*p,a=u*p,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(s[l+2]<=t)continue;s[l+2]=t;const u=s[l+5];o+=s[l]*u,a+=s[l+1]*u,s[l+4]=m,n&&(e||(e=this._map(s,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(s,l)))}s[i+4]=m,l.push(o/d,a/d,1/0,m,-1,d),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(s[i+e]);if(d>1)for(const e of h){const i=e*c;if(!(s[i+2]<=t)){s[i+2]=t;for(let e=0;e<c;e++)l.push(s[i+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function Wp(e,t,i){return{type:"Feature",id:e[t+3],properties:Kp(e,t,i),geometry:{type:"Point",coordinates:[Jp(e[t]),Qp(e[t+1])]}}}function Kp(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],a=-1===o?{}:Object.assign({},i[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}function Xp(e){return e/360+.5}function Yp(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function Jp(e){return 360*(e-.5)}function Qp(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}const ed=window.loadCardHelpers?window.loadCardHelpers():void 0,td=()=>{var e,t,i,r,n,o;customElements.get("ha-entity-marker")||null===(e=customElements.get("hui-map-card"))||void 0===e||e.getConfigElement(),customElements.get("ha-form")||null===(t=customElements.get("hui-button-card"))||void 0===t||t.getConfigElement(),customElements.get("ha-entity-picker")||null===(i=customElements.get("hui-entities-card"))||void 0===i||i.getConfigElement(),customElements.get("ha-card-conditions-editor")||null===(r=customElements.get("hui-conditional-card"))||void 0===r||r.getConfigElement(),customElements.get("ha-form-multi_select")||null===(n=customElements.get("hui-entities-card"))||void 0===n||n.getConfigElement(),customElements.get("hui-entity-editor")||null===(o=customElements.get("hui-glance-card"))||void 0===o||o.getConfigElement()},id=async e=>{if(!customElements.get("ha-entity-marker")){const t={type:"map",entities:e,theme_mode:"auto"};let i;if(window.loadCardHelpers?i=await window.loadCardHelpers():ed&&(i=ed),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var rd,nd,od,ad,sd,ld,cd,ud;!function(e){e.language="language",e.system="system",e.comma_decimal="comma_decimal",e.decimal_comma="decimal_comma",e.space_comma="space_comma",e.none="none"}(rd||(rd={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(nd||(nd={})),function(e){e.local="local",e.server="server"}(od||(od={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(ad||(ad={})),function(e){e.language="language",e.monday="monday",e.tuesday="tuesday",e.wednesday="wednesday",e.thursday="thursday",e.friday="friday",e.saturday="saturday",e.sunday="sunday"}(sd||(sd={}));const hd=e=>"string"==typeof e?e:e.entity_id,pd=st((async(e,t,i)=>{const r={address:"streetName",locality:"sublocality",municipality:"city"},n=`https://api.maptiler.com/geocoding/${t},${e}.json?key=${i}`;try{const e=await fetch(n);if(!e.ok)throw new Error("Failed to fetch address from MapTiler");const t=await e.json();if(t&&t.features&&t.features.length>0){let e={};if(t.features.forEach((t=>{const i=t.place_type[0];if(r[i]){const n=r[i],o=t.text;"address"===i&&(e.streetNumber=t.address?`${t.address}`:""),e[n]=`${o}`}})),e.streetName&&e.city)return e}return null}catch(e){return console.warn("Error fetching address from MapTiler:",e),null}})),dd=null===(ud=null===(ld=Intl.DateTimeFormat)||void 0===ld?void 0:(cd=ld.call(Intl)).resolvedOptions)||void 0===ud?void 0:ud.call(cd).timeZone,fd=null!=dd?dd:"UTC",md=(e,t)=>e===od.local&&dd?fd:t,gd=st((e=>{if(e.time_format===nd.language||e.time_format===nd.system){const t=e.time_format===nd.language?e.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(t).includes("10")}return e.time_format===nd.am_pm})),yd=(e,t,i)=>_d(t,i.time_zone).format(e),_d=st(((e,t)=>new Intl.DateTimeFormat(e.language,{weekday:"long",hour:gd(e)?"numeric":"2-digit",minute:"2-digit",hour12:gd(e),timeZone:md(e.time_zone,t)}))),vd={dark:ti.STREETS.DARK,light:ti.DATAVIZ.LIGHT,demo:"https://demotiles.maplibre.org/style.json"},bd={backgroundColor:{light:"#fff",dark:"#222222"},fill:{light:"#222222",dark:"#c1c1c1"},boxShadow:{light:"0 0 0 2px rgba(0, 0, 0, 0.1)",dark:"0 0 0 2px rgba(255, 255, 255, 0.1)"},borderTop:{light:"1px solid #ddd",dark:"1px solid #424242"},themeBtn:{light:"mdi:weather-sunny",dark:"mdi:weather-night"}};class xd extends Xe{constructor(){super(...arguments),this.autoFit=!1,this.fitZones=!1,this.zoom=gp,this.themeMode="auto",this.useMoreInfo=!1,this._darkStyle=!1,this._mapItems=[],this._zoneItems=[],this._mapFocusZones=[],this._mapFocusItems=[],this._mapPaths=[],this._mapHelper=yh,this._clusters=[],this._mapClusterItems=[],this._mapClusterFocusItems=[],this._circleLoaded=!1,this._loaded=!1,this._entitiesDrawn=!1,this._createButton=(e,t)=>{const i=document.createElement("div");i.classList.add("maplibregl-ctrl","maplibregl-ctrl-group");const r=document.createElement("button"),n=document.createElement("ha-icon");return n.setAttribute("icon",e),n.style.color="var(--emc-btn-color)",r.appendChild(n),r.title=t,i.appendChild(r),i.style.display="none",i},this.getModeColor=(e,t)=>t?bd[e][t]:this._darkMode?bd[e].dark:bd[e].light}get _darkMode(){return"dark"===this.themeMode||"auto"===this.themeMode&&Boolean(this.hass.themes.darkMode)}async firstUpdated(){await id(this.entities),await new Promise((e=>setTimeout(e,0))),this._initMap()}render(){const e=this._renderLoadError();return ke`
220
220
  <div class="maptiler-map">
221
221
  ${e}
222
222
  <div id="map"></div>
223
223
  </div>
224
- `}_renderLoadError(){if(!this._error)return ke``;const{code:e,message:t}=this._error;return ke` <ha-alert alert-type="${e}" id="error"> ${t} </ha-alert> `}updated(e){var t,i,r,n;if(super.updated(e),!this._loaded)return;let o=!1,a=!1;const s=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities(),o=!0,a=!0;else if(this._loaded&&s&&this.entities)for(const e of this.entities)if(s.states[hd(e)]!==this.hass.states[hd(e)]){this._circleLoaded=!1,this._drawEntities(),o=!0,a=!0;break}if((e.has("_loaded")||this.autoFit&&o)&&this._fitMap(),(e.has("_loaded")||this.paths&&this.paths.length&&a)&&this._drawPaths(),e.has("hass")&&s){if((null===(t=s.themes)||void 0===t?void 0:t.darkMode)!==(null===(i=this.hass.themes)||void 0===i?void 0:i.darkMode)){const e=this._getInitStyle();this._map.setStyle(e,{diff:!1})}}e.has("themeMode")||e.has("hass")&&(!s||(null===(r=s.themes)||void 0===r||r.darkMode,null===(n=this.hass.themes)||void 0===n||n.darkMode))}_drawEntities(){const e=this.hass,t=this._map;if(!t||!e)return;if(this._mapItems.length&&(this._mapItems.forEach((e=>e.remove())),this._mapItems=[],this._mapFocusItems=[]),this._mapClusterItems.length&&(this._clusterIndex=void 0,this._mapClusterItems.forEach((e=>e.remove())),this._mapClusterItems=[],this._mapClusterFocusItems=[]),this._zoneItems.length&&(this._zoneItems.forEach((e=>e.remove())),this._zoneItems=[],this._mapFocusZones=[]),!this.entities)return;this._entitiesDrawn&&(this._entitiesDrawn=!1);const i=[],r=[],n=getComputedStyle(this),o=n.getPropertyValue("--accent-color"),a=n.getPropertyValue("--secondary-text-color"),s=n.getPropertyValue("--dark-primary-color"),l=this._darkStyle?"dark":"light";for(const n of this.entities){const s=e.states[hd(n)];if(!s)continue;const c="string"!=typeof n?n.name:void 0,u=null!=c?c:pt(s),{latitude:h,longitude:p,passive:d,icon:f,radius:m,gps_accuracy:g}=s.attributes;if(!h||!p)continue;const y=[p,h];if("zone"!==L(s))i.push({type:"Feature",geometry:{type:"Point",coordinates:y},properties:{title:u,entity:n,entityId:hd(n),gpsAccuracy:g}});else{let e="";if(f){const t=document.createElement("ha-icon");t.setAttribute("icon",f),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=u,e=t.outerHTML}const i=np(y,m,{steps:150,units:"meters",properties:{color:d?a:o,title:u,opacity:d?.2:.3}});r.push(i);const s=document.createElement("div");s.className=`marker ${l}`,s.innerHTML=e,s.title=u;const c=new Xr({element:s}).setLngLat(y).addTo(t);this._zoneItems.push(c),!this.fitZones||"string"!=typeof n&&!1===n.focus||this._mapFocusZones.push(i.geometry)}}this._clusterIndex=new Hp({radius:100,maxZoom:11}),this._clusterIndex.load(i);const c=t.getBounds().toArray().flat(),u=Math.floor(t.getZoom()),h=this._clusterIndex.getClusters(c,u);for(const i of h){const[n,o]=i.geometry.coordinates;if(i.properties.cluster){const e=i.properties.point_count,r=i.properties.cluster_id,a=document.createElement("div");a.className="cluster-marker",a.innerHTML=`<div><span>${e.toString()}</span></div>`,a.addEventListener("click",(()=>{var e;try{const i=null===(e=this._clusterIndex)||void 0===e?void 0:e.getClusterExpansionZoom(r);void 0!==i&&t.easeTo({center:[n,o],zoom:i})}catch(e){}}));const s=new Xr({element:a}).setLngLat([n,o]).addTo(t);this._mapClusterItems.push(s),this._mapFocusItems.push(s),this._mapClusterFocusItems.push(s),this._mapItems.push(s)}else{const a=i.properties.entity,l=e.states[i.properties.entityId],c=i.properties.title,u=i.properties.gpsAccuracy,h="string"!=typeof a&&"state"===a.label_mode?this.hass.formatEntityState(l):"string"!=typeof a&&"attribute"===a.label_mode&&void 0!==a.attribute?this.hass.formatEntityAttributeValue(l,a.attribute):c.split(" ").map((e=>e[0])).join("").substring(0,3),p=document.createElement("ha-entity-marker");p.hass=this.hass,p.showIcon="string"!=typeof a&&"icon"===a.label_mode,p.entityId=hd(a),p.entityName=h,p.entityPicture=!l.attributes.entity_picture||"string"!=typeof a&&a.label_mode?"":this.hass.hassUrl(l.attributes.entity_picture),"string"!=typeof a&&(p.entityColor=a.color),p.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.preventDefault(),this.useMoreInfo&&C(this,"hass-more-info",{entityId:p.entityId})}),!0);const d=new Xr({element:p}).setLngLat([n,o]).addTo(t);if(this._mapItems.push(d),"string"!=typeof a&&!1===a.focus||this._mapFocusItems.push(d),u){const e=np([n,o],u,{steps:64,units:"meters",properties:{color:s,title:c,opacity:.5}});r.push(e)}}}const p={type:"geojson",data:{type:"FeatureCollection",features:r}};this._circleLoaded||(t.getLayer("circles")&&t.removeLayer("circles"),t.getLayer("circles-stroke")&&t.removeLayer("circles-stroke"),t.getSource("circles")&&t.removeSource("circles"),t.addSource("circles",p),t.addLayer({id:"circles",type:"fill",source:"circles",paint:{"fill-color":["get","color"],"fill-opacity":["get","opacity"]}}),t.addLayer({id:"circles-stroke",type:"line",source:"circles",paint:{"line-color":["get","color"],"line-width":2}}),this._circleLoaded=!0,this._entitiesDrawn=!0)}_computePathTooltip(e,t){let i;return i=e.fullDatetime?E(t.timestamp,this.hass.locale):Ip(t.timestamp)?I(t.timestamp,this.hass.locale):yd(t.timestamp,this.hass.locale,this.hass.config),`<b>${e.name}</b><br><i>${i}</i>`}_drawPaths(){const e=this.hass,t=this._map;if(!t||!e)return;if(!this.paths)return;this._mapPaths.length&&(this._mapPaths.forEach((e=>{t.removeLayer(e.id)})),this._mapPaths=[]);const i=getComputedStyle(this).getPropertyValue("--dark-primary-color"),r=[],n=[];this.paths.forEach((e=>{if(!e.points||e.points.length<2)return;let t,o;e.gradualOpacity&&(t=e.gradualOpacity/(e.points.length-2),o=1-e.gradualOpacity);for(let a=0;a<e.points.length-1;a++){const s=e.points[a].point,l=e.points[a+1].point,c=e.gradualOpacity?o+a*t:void 0,u=this._computePathTooltip(e,e.points[a]),h={type:"Feature",geometry:{type:"Point",coordinates:s},properties:{friendlyName:e.name,color:e.color||i,opacity:c,fillOpacity:c,lastUpdated:e.points[a].timestamp,popupContent:u}};n.push(h);const p={type:"Feature",geometry:{type:"LineString",coordinates:[s,l]},properties:{color:e.color||i,opacity:c,fillOpacity:c}};r.push(p)}}));const o={type:"geojson",data:{type:"FeatureCollection",features:n}},a={type:"geojson",data:{type:"FeatureCollection",features:r}};t.getSource("points")&&t.removeSource("points"),t.getSource("lines")&&t.removeSource("lines"),t.addSource("points",o),t.addSource("lines",a);const s={id:"lines",type:"line",source:"lines",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["get","color"],"line-width":2,"line-opacity":["get","opacity"]}},l={id:"points",type:"circle",source:"points",paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":1,"circle-stroke-color":["get","color"]}};t.addLayer(s),t.addLayer(l),this._mapPaths.push(s,l),this._setupPointInteraction()}_setupPointInteraction(){const e=this._map;if(!e)return;const t=new Yr({closeButton:!1,closeOnClick:!1,offset:8});let i;e.on("mousemove","points",(async r=>{var n;if(e.getZoom()<10)return e.getCanvas().style.cursor="",t.remove(),void(i=void 0);const o=null===(n=r.features)||void 0===n?void 0:n[0];if(!o)return;const a=o.geometry.coordinates.toString();if(i!==a){i=a,e.getCanvas().style.cursor="pointer";const n=r.features[0].geometry.coordinates.slice(),{popupContent:s}=o.properties;for(;Math.abs(r.lngLat.lng-n[0])>180;)n[0]+=r.lngLat.lng>n[0]?360:-360;t.setLngLat(n).setHTML(s).addTo(e);const l=await pd(n[1],n[0],this.apiKey);if(l){const e=`${s}<br>${l.streetName}`;t.isOpen()&&t.setHTML(e)}}})),e.on("mouseleave","points",(()=>{e.getCanvas().style.cursor="",t.remove(),i=void 0}))}_fitMap(e){var t,i,r,n,o;const a=this._map;if(!a)return;if(!this._mapClusterFocusItems.length&&!this._mapFocusItems.length&&!this._mapFocusZones.length)return void this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]);let s=new xh;!this._mapFocusItems||this._mapFocusItems.map((e=>{const t=e.getLngLat();s.extend([t.lng,t.lat])})),null===(t=this._mapFocusZones)||void 0===t||t.forEach((e=>{e.coordinates[0].forEach((e=>{s.extend([e[0],e[1]])}))})),null===(i=this._mapClusterFocusItems)||void 0===i||i.forEach((e=>{s.extend(e.getLngLat())})),s.isEmpty()||(this._fitBounds=s,a.fitBounds(s,{padding:null!==(r=null==e?void 0:e.pad)&&void 0!==r?r:{top:50,right:75,bottom:50,left:50},maxZoom:null!==(n=null==e?void 0:e.zoom)&&void 0!==n?n:this.zoom,animate:null!==(o=null==e?void 0:e.animate)&&void 0!==o&&o,linear:!0}))}_initMap(){const{zoom:e,apiKey:t}=this,i=[this.hass.config.longitude,this.hass.config.latitude],r=t?this._getInitStyle():vd.demo;this.zoom=t?this.zoom:5,this._error=t?void 0:{code:"info",message:"API key is required"};const n=this.shadowRoot.getElementById("map");gr.apiKey=t;const o={geolocateControl:!1,fullscreenControl:!1,navigationControl:!1,attributionControl:!1,fadeDuration:0,canvasContextAttributes:{antialias:!0},maxZoom:20,container:n,zoom:e,style:r,center:i};this._map=new mu(o),this._map.on("load",(async()=>{this._loaded=!0})),this._map.on("style.load",(async()=>{const e=this._map.getStyle().name,t=/dark/i.test(e);this._darkStyle=t,this._changeControlTheme(t?"dark":"light")}));const a=new sn({visualizePitch:!0,visualizeRoll:!0});this._map.addControl(a,"top-right"),this._addMapControl("mdi:image-filter-center-focus","Center","top-right",this._centerMap.bind(this)),this._map.on("styleimagemissing",(e=>{var t;null===(t=this._map)||void 0===t||t.addImage(e.id,{width:0,height:0,data:new Uint8Array(0)})})),this._map.on("error",(e=>{void 0!==e.style&&(this._error={code:"error",message:"Error fetching the map. Please verify your API key and try again."},this._map.setStyle(vd.demo),this.zoom=0)})),this._map.on("zoomend",(async()=>{this._drawEntities()}))}_centerMap(){const e=this._fitBounds;e?this._map.fitBounds(e,{padding:{top:50,right:75,bottom:50,left:50},animate:!0,maxZoom:this.zoom,linear:!0}):(this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]),this._map.setZoom(this.zoom))}_addMapControl(e,t,i,r){this._map.addControl({onAdd:()=>{const i=this._createButton(e,t);return i.style.display="unset",i.addEventListener("click",r),i},onRemove:()=>null},i)}_getInitStyle(){const{light:e,dark:t}=this.customStyles||{},i=e=>{const t=e.split(".");return 2===t.length?ti[t[0]][t[1]]:ti[t[0]]};return this._darkMode?t?i(t):vd.dark:e?i(e):vd.light}_changeControlTheme(e){const t=t=>this.getModeColor(t,e),i=Array.from(this.shadowRoot.querySelectorAll(".maplibregl-ctrl"));for(const e of i){const i=Array.from(e.querySelectorAll("button"));for(const e of i){const i=e;i.style.backgroundColor=t("backgroundColor"),i.style.boxShadow=t("boxShadow");const r=e.querySelector("span");if(r){const e=window.getComputedStyle(r).backgroundImage;if(e.startsWith('url("data:image/svg+xml')){const i=t("fill"),n=e.slice(5,-2),o=decodeURIComponent(n.split(",")[1]).replace(/fill:[^;"]*/g,`fill:${i}`).replace(/fill="[^"]*"/g,`fill="${i}"`),a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`;r.style.backgroundImage=`url("${a}")`}}}}}static get styles(){return[Z(Gh),G`
224
+ `}_renderLoadError(){if(!this._error)return ke``;const{code:e,message:t}=this._error;return ke` <ha-alert alert-type="${e}" id="error"> ${t} </ha-alert> `}updated(e){var t,i,r,n;if(super.updated(e),!this._loaded)return;let o=!1,a=!1;const s=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities(),o=!0,a=!0;else if(this._loaded&&s&&this.entities)for(const e of this.entities)if(s.states[hd(e)]!==this.hass.states[hd(e)]){this._circleLoaded=!1,this._drawEntities(),o=!0,a=!0;break}if((e.has("_loaded")||this.autoFit&&o)&&this._fitMap(),(e.has("_loaded")||e.has("paths")||this.paths&&this.paths.length&&a)&&this._drawPaths(),e.has("hass")&&s){if((null===(t=s.themes)||void 0===t?void 0:t.darkMode)!==(null===(i=this.hass.themes)||void 0===i?void 0:i.darkMode)){const e=this._getInitStyle();this._map.setStyle(e,{diff:!1})}}e.has("themeMode")||e.has("hass")&&(!s||(null===(r=s.themes)||void 0===r||r.darkMode,null===(n=this.hass.themes)||void 0===n||n.darkMode))}_drawEntities(){const e=this.hass,t=this._map;if(!t||!e)return;if(this._mapItems.length&&(this._mapItems.forEach((e=>e.remove())),this._mapItems=[],this._mapFocusItems=[]),this._mapClusterItems.length&&(this._clusterIndex=void 0,this._mapClusterItems.forEach((e=>e.remove())),this._mapClusterItems=[],this._mapClusterFocusItems=[]),this._zoneItems.length&&(this._zoneItems.forEach((e=>e.remove())),this._zoneItems=[],this._mapFocusZones=[]),!this.entities)return;this._entitiesDrawn&&(this._entitiesDrawn=!1);const i=[],r=[],n=getComputedStyle(this),o=n.getPropertyValue("--accent-color"),a=n.getPropertyValue("--secondary-text-color"),s=n.getPropertyValue("--dark-primary-color"),l=this._darkStyle?"dark":"light";for(const n of this.entities){const s=e.states[hd(n)];if(!s)continue;const c="string"!=typeof n?n.name:void 0,u=null!=c?c:pt(s),{latitude:h,longitude:p,passive:d,icon:f,radius:m,gps_accuracy:g}=s.attributes;if(!h||!p)continue;const y=[p,h];if("zone"!==L(s))i.push({type:"Feature",geometry:{type:"Point",coordinates:y},properties:{title:u,entity:n,entityId:hd(n),gpsAccuracy:g}});else{let e="";if(f){const t=document.createElement("ha-icon");t.setAttribute("icon",f),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=u,e=t.outerHTML}const i=np(y,m,{steps:150,units:"meters",properties:{color:d?a:o,title:u,opacity:d?.2:.3}});r.push(i);const s=document.createElement("div");s.className=`marker ${l}`,s.innerHTML=e,s.title=u;const c=new Xr({element:s}).setLngLat(y).addTo(t);this._zoneItems.push(c),!this.fitZones||"string"!=typeof n&&!1===n.focus||this._mapFocusZones.push(i.geometry)}}this._clusterIndex=new Hp({radius:100,maxZoom:11}),this._clusterIndex.load(i);const c=t.getBounds().toArray().flat(),u=Math.floor(t.getZoom()),h=this._clusterIndex.getClusters(c,u);for(const i of h){const[n,o]=i.geometry.coordinates;if(i.properties.cluster){const e=i.properties.point_count,r=i.properties.cluster_id,a=document.createElement("div");a.className="cluster-marker",a.innerHTML=`<div><span>${e.toString()}</span></div>`,a.addEventListener("click",(()=>{var e;try{const i=null===(e=this._clusterIndex)||void 0===e?void 0:e.getClusterExpansionZoom(r);void 0!==i&&t.easeTo({center:[n,o],zoom:i})}catch(e){}}));const s=new Xr({element:a}).setLngLat([n,o]).addTo(t);this._mapClusterItems.push(s),this._mapFocusItems.push(s),this._mapClusterFocusItems.push(s),this._mapItems.push(s)}else{const a=i.properties.entity,l=e.states[i.properties.entityId],c=i.properties.title,u=i.properties.gpsAccuracy,h="string"!=typeof a&&"state"===a.label_mode?this.hass.formatEntityState(l):"string"!=typeof a&&"attribute"===a.label_mode&&void 0!==a.attribute?this.hass.formatEntityAttributeValue(l,a.attribute):c.split(" ").map((e=>e[0])).join("").substring(0,3),p=document.createElement("ha-entity-marker");p.hass=this.hass,p.showIcon="string"!=typeof a&&"icon"===a.label_mode,p.entityId=hd(a),p.entityName=h,p.entityPicture=!l.attributes.entity_picture||"string"!=typeof a&&a.label_mode?"":this.hass.hassUrl(l.attributes.entity_picture),"string"!=typeof a&&(p.entityColor=a.color),p.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.preventDefault(),this.useMoreInfo&&C(this,"hass-more-info",{entityId:p.entityId})}),!0);const d=new Xr({element:p}).setLngLat([n,o]).addTo(t);if(this._mapItems.push(d),"string"!=typeof a&&!1===a.focus||this._mapFocusItems.push(d),u){const e=np([n,o],u,{steps:64,units:"meters",properties:{color:s,title:c,opacity:.5}});r.push(e)}}}const p={type:"geojson",data:{type:"FeatureCollection",features:r}};this._circleLoaded||(t.getLayer("circles")&&t.removeLayer("circles"),t.getLayer("circles-stroke")&&t.removeLayer("circles-stroke"),t.getSource("circles")&&t.removeSource("circles"),t.addSource("circles",p),t.addLayer({id:"circles",type:"fill",source:"circles",paint:{"fill-color":["get","color"],"fill-opacity":["get","opacity"]}}),t.addLayer({id:"circles-stroke",type:"line",source:"circles",paint:{"line-color":["get","color"],"line-width":2}}),this._circleLoaded=!0,this._entitiesDrawn=!0)}_computePathTooltip(e,t){let i;return i=e.fullDatetime?E(t.timestamp,this.hass.locale):Ip(t.timestamp)?I(t.timestamp,this.hass.locale):yd(t.timestamp,this.hass.locale,this.hass.config),`<b>${e.name}</b><br><i>${i}</i>`}_drawPaths(){const e=this.hass,t=this._map;if(!t||!e)return;if(this._mapPaths.length&&(this._mapPaths.forEach((e=>{t.removeLayer(e.id)})),this._mapPaths=[]),!this.paths)return;const i=getComputedStyle(this).getPropertyValue("--dark-primary-color"),r=[],n=[];this.paths.forEach((e=>{if(!e.points||e.points.length<2)return;let t,o;e.gradualOpacity&&(t=e.gradualOpacity/(e.points.length-2),o=1-e.gradualOpacity);for(let a=0;a<e.points.length-1;a++){const s=e.points[a].point,l=e.points[a+1].point,c=e.gradualOpacity?o+a*t:void 0,u=this._computePathTooltip(e,e.points[a]),h={type:"Feature",geometry:{type:"Point",coordinates:s},properties:{friendlyName:e.name,color:e.color||i,opacity:c,fillOpacity:c,lastUpdated:e.points[a].timestamp,popupContent:u}};n.push(h);const p={type:"Feature",geometry:{type:"LineString",coordinates:[s,l]},properties:{color:e.color||i,opacity:c,fillOpacity:c}};r.push(p)}}));const o={type:"geojson",data:{type:"FeatureCollection",features:n}},a={type:"geojson",data:{type:"FeatureCollection",features:r}};t.getSource("points")&&t.removeSource("points"),t.getSource("lines")&&t.removeSource("lines"),t.addSource("points",o),t.addSource("lines",a);const s={id:"lines",type:"line",source:"lines",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["get","color"],"line-width":2,"line-opacity":["get","opacity"]}},l={id:"points",type:"circle",source:"points",paint:{"circle-radius":5,"circle-color":["get","color"],"circle-opacity":["get","fillOpacity"],"circle-stroke-width":1,"circle-stroke-color":["get","color"]}};t.addLayer(s),t.addLayer(l),this._mapPaths.push(s,l),this._setupPointInteraction()}_setupPointInteraction(){const e=this._map;if(!e)return;const t=new Yr({closeButton:!1,closeOnClick:!1,offset:8});let i;e.on("mousemove","points",(async r=>{var n;if(e.getZoom()<10)return e.getCanvas().style.cursor="",t.remove(),void(i=void 0);const o=null===(n=r.features)||void 0===n?void 0:n[0];if(!o)return;const a=o.geometry.coordinates.toString();if(i!==a){i=a,e.getCanvas().style.cursor="pointer";const n=r.features[0].geometry.coordinates.slice(),{popupContent:s}=o.properties;for(;Math.abs(r.lngLat.lng-n[0])>180;)n[0]+=r.lngLat.lng>n[0]?360:-360;t.setLngLat(n).setHTML(s).addTo(e);const l=await pd(n[1],n[0],this.apiKey);if(l){const e=`${s}<br>${l.streetName}`;t.isOpen()&&t.setHTML(e)}}})),e.on("mouseleave","points",(()=>{e.getCanvas().style.cursor="",t.remove(),i=void 0}))}_fitMap(e){var t,i,r,n,o;const a=this._map;if(!a)return;if(!this._mapClusterFocusItems.length&&!this._mapFocusItems.length&&!this._mapFocusZones.length)return void this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]);let s=new xh;!this._mapFocusItems||this._mapFocusItems.map((e=>{const t=e.getLngLat();s.extend([t.lng,t.lat])})),null===(t=this._mapFocusZones)||void 0===t||t.forEach((e=>{e.coordinates[0].forEach((e=>{s.extend([e[0],e[1]])}))})),null===(i=this._mapClusterFocusItems)||void 0===i||i.forEach((e=>{s.extend(e.getLngLat())})),s.isEmpty()||(this._fitBounds=s,a.fitBounds(s,{padding:null!==(r=null==e?void 0:e.pad)&&void 0!==r?r:{top:50,right:75,bottom:50,left:50},maxZoom:null!==(n=null==e?void 0:e.zoom)&&void 0!==n?n:this.zoom,animate:null!==(o=null==e?void 0:e.animate)&&void 0!==o&&o,linear:!0}))}_initMap(){const{zoom:e,apiKey:t}=this,i=[this.hass.config.longitude,this.hass.config.latitude],r=t?this._getInitStyle():vd.demo;this.zoom=t?this.zoom:5,this._error=t?void 0:{code:"info",message:"API key is required"};const n=this.shadowRoot.getElementById("map");gr.apiKey=t;const o={geolocateControl:!1,fullscreenControl:!1,navigationControl:!1,attributionControl:!1,fadeDuration:0,canvasContextAttributes:{antialias:!0},maxZoom:20,container:n,zoom:e,style:r,center:i};this._map=new mu(o),this._map.on("load",(async()=>{this._loaded=!0})),this._map.on("style.load",(async()=>{const e=this._map.getStyle().name,t=/dark/i.test(e);this._darkStyle=t,this._changeControlTheme(t?"dark":"light")}));const a=new sn({visualizePitch:!0,visualizeRoll:!0});this._map.addControl(a,"top-right"),this._addMapControl("mdi:image-filter-center-focus","Center","top-right",this._centerMap.bind(this)),this._map.on("styleimagemissing",(e=>{var t;null===(t=this._map)||void 0===t||t.addImage(e.id,{width:0,height:0,data:new Uint8Array(0)})})),this._map.on("error",(e=>{void 0!==e.style&&(this._error={code:"error",message:"Error fetching the map. Please verify your API key and try again."},this._map.setStyle(vd.demo),this.zoom=0)})),this._map.on("zoomend",(async()=>{this._drawEntities()}))}_centerMap(){const e=this._fitBounds;e?this._map.fitBounds(e,{padding:{top:50,right:75,bottom:50,left:50},animate:!0,maxZoom:this.zoom,linear:!0}):(this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]),this._map.setZoom(this.zoom))}_addMapControl(e,t,i,r){this._map.addControl({onAdd:()=>{const i=this._createButton(e,t);return i.style.display="unset",i.addEventListener("click",r),i},onRemove:()=>null},i)}_getInitStyle(){const{light:e,dark:t}=this.customStyles||{},i=e=>{const t=e.split(".");return 2===t.length?ti[t[0]][t[1]]:ti[t[0]]};return this._darkMode?t?i(t):vd.dark:e?i(e):vd.light}_changeControlTheme(e){const t=t=>this.getModeColor(t,e),i=Array.from(this.shadowRoot.querySelectorAll(".maplibregl-ctrl"));for(const e of i){const i=Array.from(e.querySelectorAll("button"));for(const e of i){const i=e;i.style.backgroundColor=t("backgroundColor"),i.style.boxShadow=t("boxShadow");const r=e.querySelector("span");if(r){const e=window.getComputedStyle(r).backgroundImage;if(e.startsWith('url("data:image/svg+xml')){const i=t("fill"),n=e.slice(5,-2),o=decodeURIComponent(n.split(",")[1]).replace(/fill:[^;"]*/g,`fill:${i}`).replace(/fill="[^"]*"/g,`fill="${i}"`),a=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`;r.style.backgroundImage=`url("${a}")`}}}}}static get styles(){return[Z(Gh),G`
225
225
  :host {
226
226
  --tooltip-color: rgba(80, 80, 80, 0.9);
227
227
  }
@@ -325,7 +325,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
325
325
  .maplibregl-ctrl.maplibregl-ctrl-group > button:hover > ha-icon {
326
326
  filter: invert(39%) sepia(77%) saturate(909%) hue-rotate(182deg) brightness(89%) contrast(85%);
327
327
  }
328
- `]}}e([et({attribute:!1})],xd.prototype,"hass",void 0),e([et({attribute:!1})],xd.prototype,"entities",void 0),e([et({attribute:!1})],xd.prototype,"paths",void 0),e([et({attribute:"auto-fit",type:Boolean})],xd.prototype,"autoFit",void 0),e([et({attribute:"fit-zones",type:Boolean})],xd.prototype,"fitZones",void 0),e([et({type:Number})],xd.prototype,"zoom",void 0),e([et({attribute:"theme-mode",type:String})],xd.prototype,"themeMode",void 0),e([et({type:String})],xd.prototype,"apiKey",void 0),e([et({type:Boolean})],xd.prototype,"useMoreInfo",void 0),e([et({type:Object})],xd.prototype,"customStyles",void 0),e([et({attribute:"dark-style",type:Boolean,reflect:!0})],xd.prototype,"_darkStyle",void 0),e([tt()],xd.prototype,"_circleLoaded",void 0),e([tt()],xd.prototype,"_loaded",void 0),e([tt()],xd.prototype,"_entitiesDrawn",void 0),e([tt()],xd.prototype,"_error",void 0),customElements.get("emc-map")||customElements.define("emc-map",xd);class wd extends Xe{constructor(){super(...arguments),this._mapEntities=[],this._colorDict={},this._colorIndex=0,this._zoom=gp,this._getHistoryPaths=st(((e,t)=>{var i,r,n,o;if(!t)return;const a=[];for(const s of Object.keys(t)){if("zone"===z(s))continue;const l=t[s];if(!(null==l?void 0:l.length))continue;const c=[];for(const e of l){const t=e.a.latitude,i=e.a.longitude;if(!t||!i)continue;const r={};r.point=[i,t],r.timestamp=new Date(1e3*e.lu),c.push(r)}const u=null===(i=this._configEntities)||void 0===i?void 0:i.find((e=>e.entity===s)),h=null!==(r=null==u?void 0:u.name)&&void 0!==r?r:s in this.hass.states?pt(this.hass.states[s]):s,p=null!==(n=null==u?void 0:u.color)&&void 0!==n?n:this._getColor(s);a.push({points:c,name:h,fullDatetime:(null!==(o=e.hours_to_show)&&void 0!==o?o:0)>=144,color:p,gradualOpacity:.8})}return a}))}_getAllEntities(){const e=this.hass,t=new Set,i=[];return Object.values(e.states).forEach((e=>{"latitude"in e.attributes&&"longitude"in e.attributes&&(i.push(e.entity_id),"person"===L(e)&&e.attributes.source&&t.add(e.attributes.source))})),i.filter((e=>!t.has(e)))}static async getConfigElement(){return await Promise.resolve().then((function(){return zf})),document.createElement("extra-map-editor")}static getStubConfig(e,t,i){return{type:"custom:extra-map-card",entities:ft(e,2,t,i,["device_tracker"]),theme_mode:"auto",use_more_info:!0}}setConfig(e){var t;if(!e)throw new Error("Invalid configuration");if(!e.show_all&&!(null===(t=e.entities)||void 0===t?void 0:t.length))throw new Error("Either entities or show_all is required");if(e.entities&&!Array.isArray(e.entities))throw new Error("Entities need to be an array");if(e.show_all&&e.entities)throw new Error("Cannot specify show_all and entities at the same time");if(this._config=Object.assign({},e),this._config.default_zoom)this._zoom=this._config.default_zoom;else if(this._config.aspect_ratio){const e=Tt(this._config.aspect_ratio),t=e&&e.w>0&&e.h>0?`${(100*e.h/e.w).toFixed(2)}`:"100";t&&Number(t)<=100?this._zoom=12:this._zoom=gp}this.hass&&e.show_all&&(this._config.entities=this._getAllEntities()),this._configEntities=this._config.entities?yt(this._config.entities):[],this._mapEntities=this._getMapEntities()}getCardSize(){var e;if(!(null===(e=this._config)||void 0===e?void 0:e.aspect_ratio))return 7;const t=Tt(this._config.aspect_ratio),i=t&&t.w>0&&t.h>0?`${(100*t.h/t.w).toFixed(2)}`:"100";return 1+Math.floor(Number(i)/25)||3}getGridOptions(){return{columns:"full",rows:"auto",min_columns:6,min_rows:2}}render(){var e;if(!this._config)return Le;if(this._error)return ke`<ha-alert alert-type="error">
328
+ `]}}e([et({attribute:!1})],xd.prototype,"hass",void 0),e([et({attribute:!1})],xd.prototype,"entities",void 0),e([et({attribute:!1})],xd.prototype,"paths",void 0),e([et({attribute:"auto-fit",type:Boolean})],xd.prototype,"autoFit",void 0),e([et({attribute:"fit-zones",type:Boolean})],xd.prototype,"fitZones",void 0),e([et({type:Number})],xd.prototype,"zoom",void 0),e([et({attribute:"theme-mode",type:String})],xd.prototype,"themeMode",void 0),e([et({type:String})],xd.prototype,"apiKey",void 0),e([et({type:Boolean})],xd.prototype,"useMoreInfo",void 0),e([et({type:Object})],xd.prototype,"customStyles",void 0),e([et({attribute:"dark-style",type:Boolean,reflect:!0})],xd.prototype,"_darkStyle",void 0),e([tt()],xd.prototype,"_circleLoaded",void 0),e([tt()],xd.prototype,"_loaded",void 0),e([tt()],xd.prototype,"_entitiesDrawn",void 0),e([tt()],xd.prototype,"_error",void 0),customElements.get("emc-map")||customElements.define("emc-map",xd);class wd extends Xe{constructor(){super(...arguments),this._mapEntities=[],this._colorDict={},this._colorIndex=0,this._zoom=gp,this._getHistoryPaths=st(((e,t)=>{var i,r,n,o;if(!t)return;const a=[];for(const s of Object.keys(t)){if("zone"===z(s))continue;const l=t[s];if(!(null==l?void 0:l.length))continue;const c=[];for(const e of l){const t=e.a.latitude,i=e.a.longitude;if(!t||!i)continue;const r={};r.point=[i,t],r.timestamp=new Date(1e3*e.lu),c.push(r)}const u=null===(i=this._configEntities)||void 0===i?void 0:i.find((e=>e.entity===s)),h=null!==(r=null==u?void 0:u.name)&&void 0!==r?r:s in this.hass.states?pt(this.hass.states[s]):s,p=null!==(n=null==u?void 0:u.color)&&void 0!==n?n:this._getColor(s);a.push({points:c,name:h,fullDatetime:(null!==(o=e.hours_to_show)&&void 0!==o?o:0)>=144,color:p,gradualOpacity:.8})}return a}))}_getAllEntities(){const e=this.hass,t=new Set,i=[];return Object.values(e.states).forEach((e=>{"latitude"in e.attributes&&"longitude"in e.attributes&&(i.push(e.entity_id),"person"===L(e)&&e.attributes.source&&t.add(e.attributes.source))})),i.filter((e=>!t.has(e)))}static async getConfigElement(){return await Promise.resolve().then((function(){return $f})),document.createElement("extra-map-editor")}static getStubConfig(e,t,i){return{type:"custom:extra-map-card",entities:ft(e,2,t,i,["device_tracker"]),theme_mode:"auto",use_more_info:!0}}setConfig(e){var t;if(!e)throw new Error("Invalid configuration");if(!e.show_all&&!(null===(t=e.entities)||void 0===t?void 0:t.length))throw new Error("Either entities or show_all is required");if(e.entities&&!Array.isArray(e.entities))throw new Error("Entities need to be an array");if(e.show_all&&e.entities)throw new Error("Cannot specify show_all and entities at the same time");if(this._config=Object.assign({},e),this._config.default_zoom)this._zoom=this._config.default_zoom;else if(this._config.aspect_ratio){const e=Tt(this._config.aspect_ratio),t=e&&e.w>0&&e.h>0?`${(100*e.h/e.w).toFixed(2)}`:"100";t&&Number(t)<=100?this._zoom=12:this._zoom=gp}this.hass&&e.show_all&&(this._config.entities=this._getAllEntities()),this._configEntities=this._config.entities?yt(this._config.entities):[],this._mapEntities=this._getMapEntities()}getCardSize(){var e;if(!(null===(e=this._config)||void 0===e?void 0:e.aspect_ratio))return 7;const t=Tt(this._config.aspect_ratio),i=t&&t.w>0&&t.h>0?`${(100*t.h/t.w).toFixed(2)}`:"100";return 1+Math.floor(Number(i)/25)||3}getGridOptions(){return{columns:"full",rows:"auto",min_columns:6,min_rows:2}}render(){var e;if(!this._config)return Le;if(this._error)return ke`<ha-alert alert-type="error">
329
329
  ${this.hass.localize("ui.components.map.error")}: ${this._error.message} (${this._error.code})
330
330
  </ha-alert>`;const t=this._config.theme_mode||(this._config.dark_mode?"dark":"auto"),i=this._config.custom_styles||{};return ke`
331
331
  <ha-card id="card" .header=${this._config.title}>
@@ -356,28 +356,23 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
356
356
  position: relative;
357
357
  height: 100%;
358
358
  }
359
- `,e([et({attribute:!1})],wd.prototype,"hass",void 0),e([et({attribute:!1})],wd.prototype,"layout",void 0),e([tt()],wd.prototype,"_config",void 0),e([tt()],wd.prototype,"_mapEntities",void 0),e([tt()],wd.prototype,"_stateHistory",void 0),e([tt()],wd.prototype,"_error",void 0),e([rt("emc-map")],wd.prototype,"_mapTiler",void 0),customElements.get("extra-map-card")||customElements.define("extra-map-card",wd),window.customCards=window.customCards||[],window.customCards.find((e=>"extra-map-card"===e.type))||window.customCards.push({type:"extra-map-card",name:"Extra Map Card",description:"Extra Map Card using MapTiler",preview:!0,version:`${up}`});const Td=e=>"latitude"in e.attributes&&"longitude"in e.attributes
360
- /**
361
- * @license
362
- * Copyright 2017 Google LLC
363
- * SPDX-License-Identifier: BSD-3-Clause
364
- */,Ad={CHILD:2},Sd=e=>(...t)=>({_$litDirective$:e,values:t});class Md{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
359
+ `,e([et({attribute:!1})],wd.prototype,"hass",void 0),e([et({attribute:!1})],wd.prototype,"layout",void 0),e([tt()],wd.prototype,"_config",void 0),e([tt()],wd.prototype,"_mapEntities",void 0),e([tt()],wd.prototype,"_stateHistory",void 0),e([tt()],wd.prototype,"_error",void 0),e([rt("emc-map")],wd.prototype,"_mapTiler",void 0),customElements.get("extra-map-card")||customElements.define("extra-map-card",wd),window.customCards=window.customCards||[],window.customCards.find((e=>"extra-map-card"===e.type))||window.customCards.push({type:"extra-map-card",name:"Extra Map Card",description:"Extra Map Card using MapTiler",preview:!0,version:`${up}`});const Td=e=>"latitude"in e.attributes&&"longitude"in e.attributes,Ad="https://cdn.jsdelivr.net/npm/extra-map-card@",Sd="extra-map-card",Md="/dist/extra-map-card-bundle.min.js",Ed="extra-map-card-bundle.min.js";async function Pd(){var e;try{const t=await fetch(`https://registry.npmjs.org/${Sd}`);if(!t.ok)throw new Error("Package not found");return(null===(e=(await t.json())["dist-tags"])||void 0===e?void 0:e.latest)||null}catch(e){return null}}let Id=null;const kd=async e=>Id||(Id=(async()=>{const t=await st(Pd)();if(!t)return;const i=`${Ad}${t}${Md}`,r=(await v(e.connection)).find((e=>e.url.endsWith(Ed)));r&&r.url===i||(r?await x(e,r.id,{res_type:"module",url:i}):await b(e,{res_type:"module",url:i}))})(),Id),zd=()=>{Id=null},Ld={CHILD:2},Dd=e=>(...t)=>({_$litDirective$:e,values:t});class Fd{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}
365
360
  /**
366
361
  * @license
367
362
  * Copyright 2020 Google LLC
368
363
  * SPDX-License-Identifier: BSD-3-Clause
369
- */const{I:Ed}=He,Pd=()=>document.createComment(""),Id=(e,t,i)=>{const r=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=r.insertBefore(Pd(),n),o=r.insertBefore(Pd(),n);i=new Ed(t,o,e,e.options)}else{const t=i._$AB.nextSibling,o=i._$AM,a=o!==e;if(a){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==o._$AU&&i._$AP(t)}if(t!==n||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;r.insertBefore(e,n),e=t}}}return i},kd=(e,t,i=e)=>(e._$AI(t,i),e),zd={},Ld=(e,t=zd)=>e._$AH=t,Dd=e=>e._$AH,Fd=e=>{e._$AP?.(!1,!0);let t=e._$AA;const i=e._$AB.nextSibling;for(;t!==i;){const e=t.nextSibling;t.remove(),t=e}},Rd=(e,t,i)=>{const r=new Map;for(let n=t;n<=i;n++)r.set(e[n],n);return r},Bd=Sd(class extends Md{constructor(e){if(super(e),e.type!==Ad.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let r;void 0===i?i=t:void 0!==t&&(r=t);const n=[],o=[];let a=0;for(const t of e)n[a]=r?r(t,a):a,o[a]=i(t,a),a++;return{values:o,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,r]){const n=Dd(e),{values:o,keys:a}=this.dt(t,i,r);if(!Array.isArray(n))return this.ut=a,o;const s=this.ut??=[],l=[];let c,u,h=0,p=n.length-1,d=0,f=o.length-1;for(;h<=p&&d<=f;)if(null===n[h])h++;else if(null===n[p])p--;else if(s[h]===a[d])l[d]=kd(n[h],o[d]),h++,d++;else if(s[p]===a[f])l[f]=kd(n[p],o[f]),p--,f--;else if(s[h]===a[f])l[f]=kd(n[h],o[f]),Id(e,l[f+1],n[h]),h++,f--;else if(s[p]===a[d])l[d]=kd(n[p],o[d]),Id(e,n[h],n[p]),p--,d++;else if(void 0===c&&(c=Rd(a,d,f),u=Rd(s,h,p)),c.has(s[h]))if(c.has(s[p])){const t=u.get(a[d]),i=void 0!==t?n[t]:null;if(null===i){const t=Id(e,n[h]);kd(t,o[d]),l[d]=t}else l[d]=kd(i,o[d]),Id(e,n[h],i),n[t]=null;d++}else Fd(n[p]),p--;else Fd(n[h]),h++;for(;d<=f;){const t=Id(e,l[f+1]);kd(t,o[d]),l[d++]=t}for(;h<=p;){const e=n[h++];null!==e&&Fd(e)}return this.ut=a,Ld(e,l),ze}});
364
+ */const{I:Rd}=He,Bd=()=>document.createComment(""),Od=(e,t,i)=>{const r=e._$AA.parentNode,n=void 0===t?e._$AB:t._$AA;if(void 0===i){const t=r.insertBefore(Bd(),n),o=r.insertBefore(Bd(),n);i=new Rd(t,o,e,e.options)}else{const t=i._$AB.nextSibling,o=i._$AM,a=o!==e;if(a){let t;i._$AQ?.(e),i._$AM=e,void 0!==i._$AP&&(t=e._$AU)!==o._$AU&&i._$AP(t)}if(t!==n||a){let e=i._$AA;for(;e!==t;){const t=e.nextSibling;r.insertBefore(e,n),e=t}}}return i},jd=(e,t,i=e)=>(e._$AI(t,i),e),$d={},Nd=(e,t=$d)=>e._$AH=t,Vd=e=>e._$AH,Ud=e=>{e._$AP?.(!1,!0);let t=e._$AA;const i=e._$AB.nextSibling;for(;t!==i;){const e=t.nextSibling;t.remove(),t=e}},qd=(e,t,i)=>{const r=new Map;for(let n=t;n<=i;n++)r.set(e[n],n);return r},Zd=Dd(class extends Fd{constructor(e){if(super(e),e.type!==Ld.CHILD)throw Error("repeat() can only be used in text expressions")}dt(e,t,i){let r;void 0===i?i=t:void 0!==t&&(r=t);const n=[],o=[];let a=0;for(const t of e)n[a]=r?r(t,a):a,o[a]=i(t,a),a++;return{values:o,keys:n}}render(e,t,i){return this.dt(e,t,i).values}update(e,[t,i,r]){const n=Vd(e),{values:o,keys:a}=this.dt(t,i,r);if(!Array.isArray(n))return this.ut=a,o;const s=this.ut??=[],l=[];let c,u,h=0,p=n.length-1,d=0,f=o.length-1;for(;h<=p&&d<=f;)if(null===n[h])h++;else if(null===n[p])p--;else if(s[h]===a[d])l[d]=jd(n[h],o[d]),h++,d++;else if(s[p]===a[f])l[f]=jd(n[p],o[f]),p--,f--;else if(s[h]===a[f])l[f]=jd(n[h],o[f]),Od(e,l[f+1],n[h]),h++,f--;else if(s[p]===a[d])l[d]=jd(n[p],o[d]),Od(e,n[h],n[p]),p--,d++;else if(void 0===c&&(c=qd(a,d,f),u=qd(s,h,p)),c.has(s[h]))if(c.has(s[p])){const t=u.get(a[d]),i=void 0!==t?n[t]:null;if(null===i){const t=Od(e,n[h]);jd(t,o[d]),l[d]=t}else l[d]=jd(i,o[d]),Od(e,n[h],i),n[t]=null;d++}else Ud(n[p]),p--;else Ud(n[h]),h++;for(;d<=f;){const t=Od(e,l[f+1]);jd(t,o[d]),l[d++]=t}for(;h<=p;){const e=n[h++];null!==e&&Ud(e)}return this.ut=a,Nd(e,l),ze}});
370
365
  /**
371
366
  * @license
372
367
  * Copyright 2017 Google LLC
373
368
  * SPDX-License-Identifier: BSD-3-Clause
374
- */class Od extends Xe{render(){return this.entities&&this.hass?ke`
369
+ */class Gd extends Xe{render(){return this.entities&&this.hass?ke`
375
370
  <h3>
376
371
  ${this.label||`${this.hass.localize("ui.panel.lovelace.editor.card.generic.entities")} (${this.hass.localize("ui.panel.lovelace.editor.card.config.required")})`}
377
372
  </h3>
378
373
  <ha-sortable handle-selector=".handle" @item-moved=${this._itemMoved}>
379
374
  <div>
380
- ${Bd(this.entities,(e=>e.entity),((e,t)=>ke`
375
+ ${Zd(this.entities,(e=>e.entity),((e,t)=>ke`
381
376
  <div class="entity">
382
377
  <div class="handle">
383
378
  <ha-svg-icon .path=${ap}></ha-svg-icon>
@@ -415,7 +410,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
415
410
  .entityFilter=${this.entityFilter}
416
411
  @value-changed=${this._addEntity}
417
412
  ></ha-entity-picker>
418
- `:Le}async _addEntity(e){const t=e.detail.value;if(""===t)return;const i=this.entities.concat({entity:t});e.target.value="",C(this,"entities-changed",{entities:i})}_itemMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,r=this.entities.concat();r.splice(i,0,r.splice(t,1)[0]),C(this,"entities-changed",{entities:r})}_removeItem(e){const t=e.currentTarget.index,i=this.entities.concat();i.splice(t,1),C(this,"entities-changed",{entities:i})}_valueChanged(e){const t=e.detail.value,i=e.target.index,r=this.entities.concat();""===t||void 0===t?r.splice(i,1):r[i]=Object.assign(Object.assign({},r[i]),{entity:t}),C(this,"entities-changed",{entities:r})}_editItem(e){const t=e.currentTarget.index;C(this,"edit-detail-entity",{subEntityConfig:{index:t,elementConfig:this.entities[t]}})}}function jd(e){return jd="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},jd(e)}Od.styles=G`
413
+ `:Le}async _addEntity(e){const t=e.detail.value;if(""===t)return;const i=this.entities.concat({entity:t});e.target.value="",C(this,"entities-changed",{entities:i})}_itemMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,r=this.entities.concat();r.splice(i,0,r.splice(t,1)[0]),C(this,"entities-changed",{entities:r})}_removeItem(e){const t=e.currentTarget.index,i=this.entities.concat();i.splice(t,1),C(this,"entities-changed",{entities:i})}_valueChanged(e){const t=e.detail.value,i=e.target.index,r=this.entities.concat();""===t||void 0===t?r.splice(i,1):r[i]=Object.assign(Object.assign({},r[i]),{entity:t}),C(this,"entities-changed",{entities:r})}_editItem(e){const t=e.currentTarget.index;C(this,"edit-detail-entity",{subEntityConfig:{index:t,elementConfig:this.entities[t]}})}}function Hd(e){return Hd="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},Hd(e)}Gd.styles=G`
419
414
  ha-entity-picker {
420
415
  margin-top: 8px;
421
416
  }
@@ -473,7 +468,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
473
468
  font-size: var(--ha-font-size-s);
474
469
  color: var(--secondary-text-color);
475
470
  }
476
- `,e([et({attribute:!1})],Od.prototype,"hass",void 0),e([et({attribute:!1})],Od.prototype,"entities",void 0),e([et({attribute:!1})],Od.prototype,"entityFilter",void 0),e([et()],Od.prototype,"label",void 0),customElements.get("emc-entity-editor")||customElements.define("emc-entity-editor",Od);var $d=/^\s+/,Nd=/\s+$/;function Vd(e,t){if(t=t||{},(e=e||"")instanceof Vd)return e;if(!(this instanceof Vd))return new Vd(e,t);var i=Ud(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||i.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=i.ok}function Ud(e){var t={r:0,g:0,b:0},i=1,r=null,n=null,o=null,a=!1,s=!1;return"string"==typeof e&&(e=Sf(e)),"object"==jd(e)&&(Af(e.r)&&Af(e.g)&&Af(e.b)?(t=qd(e.r,e.g,e.b),a=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Af(e.h)&&Af(e.s)&&Af(e.v)?(r=xf(e.s),n=xf(e.v),t=Wd(e.h,r,n),a=!0,s="hsv"):Af(e.h)&&Af(e.s)&&Af(e.l)&&(r=xf(e.s),o=xf(e.l),t=Gd(e.h,r,o),a=!0,s="hsl"),e.hasOwnProperty("a")&&(i=e.a)),i=ff(i),{ok:a,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:i}}function qd(e,t,i){return{r:255*mf(e,255),g:255*mf(t,255),b:255*mf(i,255)}}function Zd(e,t,i){e=mf(e,255),t=mf(t,255),i=mf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=(o+a)/2;if(o==a)r=n=0;else{var l=o-a;switch(n=s>.5?l/(2-o-a):l/(o+a),o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,l:s}}function Gd(e,t,i){var r,n,o;function a(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}if(e=mf(e,360),t=mf(t,100),i=mf(i,100),0===t)r=n=o=i;else{var s=i<.5?i*(1+t):i+t-i*t,l=2*i-s;r=a(l,s,e+1/3),n=a(l,s,e),o=a(l,s,e-1/3)}return{r:255*r,g:255*n,b:255*o}}function Hd(e,t,i){e=mf(e,255),t=mf(t,255),i=mf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=o,l=o-a;if(n=0===o?0:l/o,o==a)r=0;else{switch(o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,v:s}}function Wd(e,t,i){e=6*mf(e,360),t=mf(t,100),i=mf(i,100);var r=Math.floor(e),n=e-r,o=i*(1-t),a=i*(1-n*t),s=i*(1-(1-n)*t),l=r%6;return{r:255*[i,a,o,o,s,i][l],g:255*[s,i,i,a,o,o][l],b:255*[o,o,s,i,i,a][l]}}function Kd(e,t,i,r){var n=[bf(Math.round(e).toString(16)),bf(Math.round(t).toString(16)),bf(Math.round(i).toString(16))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function Xd(e,t,i,r,n){var o=[bf(Math.round(e).toString(16)),bf(Math.round(t).toString(16)),bf(Math.round(i).toString(16)),bf(wf(r))];return n&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}function Yd(e,t,i,r){return[bf(wf(r)),bf(Math.round(e).toString(16)),bf(Math.round(t).toString(16)),bf(Math.round(i).toString(16))].join("")}function Jd(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.s-=t/100,i.s=gf(i.s),Vd(i)}function Qd(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.s+=t/100,i.s=gf(i.s),Vd(i)}function ef(e){return Vd(e).desaturate(100)}function tf(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.l+=t/100,i.l=gf(i.l),Vd(i)}function rf(e,t){t=0===t?0:t||10;var i=Vd(e).toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-t/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-t/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-t/100*255))),Vd(i)}function nf(e,t){t=0===t?0:t||10;var i=Vd(e).toHsl();return i.l-=t/100,i.l=gf(i.l),Vd(i)}function of(e,t){var i=Vd(e).toHsl(),r=(i.h+t)%360;return i.h=r<0?360+r:r,Vd(i)}function af(e){var t=Vd(e).toHsl();return t.h=(t.h+180)%360,Vd(t)}function sf(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var i=Vd(e).toHsl(),r=[Vd(e)],n=360/t,o=1;o<t;o++)r.push(Vd({h:(i.h+o*n)%360,s:i.s,l:i.l}));return r}function lf(e){var t=Vd(e).toHsl(),i=t.h;return[Vd(e),Vd({h:(i+72)%360,s:t.s,l:t.l}),Vd({h:(i+216)%360,s:t.s,l:t.l})]}function cf(e,t,i){t=t||6,i=i||30;var r=Vd(e).toHsl(),n=360/i,o=[Vd(e)];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,o.push(Vd(r));return o}function uf(e,t){t=t||6;for(var i=Vd(e).toHsv(),r=i.h,n=i.s,o=i.v,a=[],s=1/t;t--;)a.push(Vd({h:r,s:n,v:o})),o=(o+s)%1;return a}Vd.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,i,r=this.toRgb();return e=r.r/255,t=r.g/255,i=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},setAlpha:function(e){return this._a=ff(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Hd(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Hd(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+i+"%, "+r+"%)":"hsva("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=Zd(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Zd(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+i+"%, "+r+"%)":"hsla("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return Kd(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return Xd(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*mf(this._r,255))+"%",g:Math.round(100*mf(this._g,255))+"%",b:Math.round(100*mf(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*mf(this._r,255))+"%, "+Math.round(100*mf(this._g,255))+"%, "+Math.round(100*mf(this._b,255))+"%)":"rgba("+Math.round(100*mf(this._r,255))+"%, "+Math.round(100*mf(this._g,255))+"%, "+Math.round(100*mf(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(pf[Kd(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+Yd(this._r,this._g,this._b,this._a),i=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var n=Vd(e);i="#"+Yd(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+i+")"},toString:function(e){var t=!!e;e=e||this._format;var i=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(i=this.toRgbString()),"prgb"===e&&(i=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(i=this.toHexString()),"hex3"===e&&(i=this.toHexString(!0)),"hex4"===e&&(i=this.toHex8String(!0)),"hex8"===e&&(i=this.toHex8String()),"name"===e&&(i=this.toName()),"hsl"===e&&(i=this.toHslString()),"hsv"===e&&(i=this.toHsvString()),i||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Vd(this.toString())},_applyModification:function(e,t){var i=e.apply(null,[this].concat([].slice.call(t)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(tf,arguments)},brighten:function(){return this._applyModification(rf,arguments)},darken:function(){return this._applyModification(nf,arguments)},desaturate:function(){return this._applyModification(Jd,arguments)},saturate:function(){return this._applyModification(Qd,arguments)},greyscale:function(){return this._applyModification(ef,arguments)},spin:function(){return this._applyModification(of,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(cf,arguments)},complement:function(){return this._applyCombination(af,arguments)},monochromatic:function(){return this._applyCombination(uf,arguments)},splitcomplement:function(){return this._applyCombination(lf,arguments)},triad:function(){return this._applyCombination(sf,[3])},tetrad:function(){return this._applyCombination(sf,[4])}},Vd.fromRatio=function(e,t){if("object"==jd(e)){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]="a"===r?e[r]:xf(e[r]));e=i}return Vd(e,t)},Vd.equals=function(e,t){return!(!e||!t)&&Vd(e).toRgbString()==Vd(t).toRgbString()},Vd.random=function(){return Vd.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Vd.mix=function(e,t,i){i=0===i?0:i||50;var r=Vd(e).toRgb(),n=Vd(t).toRgb(),o=i/100;return Vd({r:(n.r-r.r)*o+r.r,g:(n.g-r.g)*o+r.g,b:(n.b-r.b)*o+r.b,a:(n.a-r.a)*o+r.a})},Vd.readability=function(e,t){var i=Vd(e),r=Vd(t);return(Math.max(i.getLuminance(),r.getLuminance())+.05)/(Math.min(i.getLuminance(),r.getLuminance())+.05)},Vd.isReadable=function(e,t,i){var r,n,o=Vd.readability(e,t);switch(n=!1,(r=Mf(i)).level+r.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7}return n},Vd.mostReadable=function(e,t,i){var r,n,o,a,s=null,l=0;n=(i=i||{}).includeFallbackColors,o=i.level,a=i.size;for(var c=0;c<t.length;c++)(r=Vd.readability(e,t[c]))>l&&(l=r,s=Vd(t[c]));return Vd.isReadable(e,s,{level:o,size:a})||!n?s:(i.includeFallbackColors=!1,Vd.mostReadable(e,["#fff","#000"],i))};var hf=Vd.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},pf=Vd.hexNames=df(hf);function df(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function ff(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function mf(e,t){_f(e)&&(e="100%");var i=vf(e);return e=Math.min(t,Math.max(0,parseFloat(e))),i&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function gf(e){return Math.min(1,Math.max(0,e))}function yf(e){return parseInt(e,16)}function _f(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)}function vf(e){return"string"==typeof e&&-1!=e.indexOf("%")}function bf(e){return 1==e.length?"0"+e:""+e}function xf(e){return e<=1&&(e=100*e+"%"),e}function wf(e){return Math.round(255*parseFloat(e)).toString(16)}function Cf(e){return yf(e)/255}var Tf=function(){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",t="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+t),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+t),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+t),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Af(e){return!!Tf.CSS_UNIT.exec(e)}function Sf(e){e=e.replace($d,"").replace(Nd,"").toLowerCase();var t,i=!1;if(hf[e])e=hf[e],i=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(t=Tf.rgb.exec(e))?{r:t[1],g:t[2],b:t[3]}:(t=Tf.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Tf.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=Tf.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Tf.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=Tf.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Tf.hex8.exec(e))?{r:yf(t[1]),g:yf(t[2]),b:yf(t[3]),a:Cf(t[4]),format:i?"name":"hex8"}:(t=Tf.hex6.exec(e))?{r:yf(t[1]),g:yf(t[2]),b:yf(t[3]),format:i?"name":"hex"}:(t=Tf.hex4.exec(e))?{r:yf(t[1]+""+t[1]),g:yf(t[2]+""+t[2]),b:yf(t[3]+""+t[3]),a:Cf(t[4]+""+t[4]),format:i?"name":"hex8"}:!!(t=Tf.hex3.exec(e))&&{r:yf(t[1]+""+t[1]),g:yf(t[2]+""+t[2]),b:yf(t[3]+""+t[3]),format:i?"name":"hex"}}function Mf(e){var t,i;return"AA"!==(t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==t&&(t="AA"),"small"!==(i=(e.size||"small").toLowerCase())&&"large"!==i&&(i="small"),{level:t,size:i}}const Ef=["name","state","icon","attribute"],Pf=st(((e,t,i)=>[{name:"entity",lebel:"Entity",selector:{entity:{filter:{domain:["device_tracker","person","zone"]}}}},{name:"",type:"grid",schema:[{name:"name",label:"Name",default:"",type:"string"},{name:"icon",label:"Icon",selector:{icon:{}}},...e?[]:[{name:"label_mode",label:"Label Mode",selector:{select:{mode:"dropdown",options:Ef.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"attribute",label:"Attribute",disabled:i,selector:{attribute:{entity_id:t}}}],{name:"focus",label:"Focus",required:!1,type:"boolean"}]}]));class If extends Xe{constructor(){super(...arguments),this._rgbColor=[0,0,0],this._computeLabel=e=>e.label||"",this._colorToRgb=e=>{const t=Vd(e);if(!t.isValid())return[0,0,0];const{r:i,g:r,b:n}=t.toRgb();return[i,r,n]}}firstUpdated(){var e;if(null===(e=this.config.elementConfig)||void 0===e?void 0:e.color){const e=this._colorToRgb(this.config.elementConfig.color);this._rgbColor=e}else{const e=ct(this.config.index||0),t=this._colorToRgb(e);this._rgbColor=t}}render(){return ke`
471
+ `,e([et({attribute:!1})],Gd.prototype,"hass",void 0),e([et({attribute:!1})],Gd.prototype,"entities",void 0),e([et({attribute:!1})],Gd.prototype,"entityFilter",void 0),e([et()],Gd.prototype,"label",void 0);var Wd=/^\s+/,Kd=/\s+$/;function Xd(e,t){if(t=t||{},(e=e||"")instanceof Xd)return e;if(!(this instanceof Xd))return new Xd(e,t);var i=Yd(e);this._originalInput=e,this._r=i.r,this._g=i.g,this._b=i.b,this._a=i.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||i.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=i.ok}function Yd(e){var t={r:0,g:0,b:0},i=1,r=null,n=null,o=null,a=!1,s=!1;return"string"==typeof e&&(e=Df(e)),"object"==Hd(e)&&(Lf(e.r)&&Lf(e.g)&&Lf(e.b)?(t=Jd(e.r,e.g,e.b),a=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Lf(e.h)&&Lf(e.s)&&Lf(e.v)?(r=Pf(e.s),n=Pf(e.v),t=rf(e.h,r,n),a=!0,s="hsv"):Lf(e.h)&&Lf(e.s)&&Lf(e.l)&&(r=Pf(e.s),o=Pf(e.l),t=ef(e.h,r,o),a=!0,s="hsl"),e.hasOwnProperty("a")&&(i=e.a)),i=wf(i),{ok:a,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:i}}function Jd(e,t,i){return{r:255*Cf(e,255),g:255*Cf(t,255),b:255*Cf(i,255)}}function Qd(e,t,i){e=Cf(e,255),t=Cf(t,255),i=Cf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=(o+a)/2;if(o==a)r=n=0;else{var l=o-a;switch(n=s>.5?l/(2-o-a):l/(o+a),o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,l:s}}function ef(e,t,i){var r,n,o;function a(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}if(e=Cf(e,360),t=Cf(t,100),i=Cf(i,100),0===t)r=n=o=i;else{var s=i<.5?i*(1+t):i+t-i*t,l=2*i-s;r=a(l,s,e+1/3),n=a(l,s,e),o=a(l,s,e-1/3)}return{r:255*r,g:255*n,b:255*o}}function tf(e,t,i){e=Cf(e,255),t=Cf(t,255),i=Cf(i,255);var r,n,o=Math.max(e,t,i),a=Math.min(e,t,i),s=o,l=o-a;if(n=0===o?0:l/o,o==a)r=0;else{switch(o){case e:r=(t-i)/l+(t<i?6:0);break;case t:r=(i-e)/l+2;break;case i:r=(e-t)/l+4}r/=6}return{h:r,s:n,v:s}}function rf(e,t,i){e=6*Cf(e,360),t=Cf(t,100),i=Cf(i,100);var r=Math.floor(e),n=e-r,o=i*(1-t),a=i*(1-n*t),s=i*(1-(1-n)*t),l=r%6;return{r:255*[i,a,o,o,s,i][l],g:255*[s,i,i,a,o,o][l],b:255*[o,o,s,i,i,a][l]}}function nf(e,t,i,r){var n=[Ef(Math.round(e).toString(16)),Ef(Math.round(t).toString(16)),Ef(Math.round(i).toString(16))];return r&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function of(e,t,i,r,n){var o=[Ef(Math.round(e).toString(16)),Ef(Math.round(t).toString(16)),Ef(Math.round(i).toString(16)),Ef(If(r))];return n&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}function af(e,t,i,r){return[Ef(If(r)),Ef(Math.round(e).toString(16)),Ef(Math.round(t).toString(16)),Ef(Math.round(i).toString(16))].join("")}function sf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.s-=t/100,i.s=Tf(i.s),Xd(i)}function lf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.s+=t/100,i.s=Tf(i.s),Xd(i)}function cf(e){return Xd(e).desaturate(100)}function uf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.l+=t/100,i.l=Tf(i.l),Xd(i)}function hf(e,t){t=0===t?0:t||10;var i=Xd(e).toRgb();return i.r=Math.max(0,Math.min(255,i.r-Math.round(-t/100*255))),i.g=Math.max(0,Math.min(255,i.g-Math.round(-t/100*255))),i.b=Math.max(0,Math.min(255,i.b-Math.round(-t/100*255))),Xd(i)}function pf(e,t){t=0===t?0:t||10;var i=Xd(e).toHsl();return i.l-=t/100,i.l=Tf(i.l),Xd(i)}function df(e,t){var i=Xd(e).toHsl(),r=(i.h+t)%360;return i.h=r<0?360+r:r,Xd(i)}function ff(e){var t=Xd(e).toHsl();return t.h=(t.h+180)%360,Xd(t)}function mf(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var i=Xd(e).toHsl(),r=[Xd(e)],n=360/t,o=1;o<t;o++)r.push(Xd({h:(i.h+o*n)%360,s:i.s,l:i.l}));return r}function gf(e){var t=Xd(e).toHsl(),i=t.h;return[Xd(e),Xd({h:(i+72)%360,s:t.s,l:t.l}),Xd({h:(i+216)%360,s:t.s,l:t.l})]}function yf(e,t,i){t=t||6,i=i||30;var r=Xd(e).toHsl(),n=360/i,o=[Xd(e)];for(r.h=(r.h-(n*t>>1)+720)%360;--t;)r.h=(r.h+n)%360,o.push(Xd(r));return o}function _f(e,t){t=t||6;for(var i=Xd(e).toHsv(),r=i.h,n=i.s,o=i.v,a=[],s=1/t;t--;)a.push(Xd({h:r,s:n,v:o})),o=(o+s)%1;return a}Xd.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,i,r=this.toRgb();return e=r.r/255,t=r.g/255,i=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4))},setAlpha:function(e){return this._a=wf(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=tf(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=tf(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+i+"%, "+r+"%)":"hsva("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=Qd(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Qd(this._r,this._g,this._b),t=Math.round(360*e.h),i=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+i+"%, "+r+"%)":"hsla("+t+", "+i+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return nf(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return of(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*Cf(this._r,255))+"%",g:Math.round(100*Cf(this._g,255))+"%",b:Math.round(100*Cf(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*Cf(this._r,255))+"%, "+Math.round(100*Cf(this._g,255))+"%, "+Math.round(100*Cf(this._b,255))+"%)":"rgba("+Math.round(100*Cf(this._r,255))+"%, "+Math.round(100*Cf(this._g,255))+"%, "+Math.round(100*Cf(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(bf[nf(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+af(this._r,this._g,this._b,this._a),i=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var n=Xd(e);i="#"+af(n._r,n._g,n._b,n._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+i+")"},toString:function(e){var t=!!e;e=e||this._format;var i=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(i=this.toRgbString()),"prgb"===e&&(i=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(i=this.toHexString()),"hex3"===e&&(i=this.toHexString(!0)),"hex4"===e&&(i=this.toHex8String(!0)),"hex8"===e&&(i=this.toHex8String()),"name"===e&&(i=this.toName()),"hsl"===e&&(i=this.toHslString()),"hsv"===e&&(i=this.toHsvString()),i||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Xd(this.toString())},_applyModification:function(e,t){var i=e.apply(null,[this].concat([].slice.call(t)));return this._r=i._r,this._g=i._g,this._b=i._b,this.setAlpha(i._a),this},lighten:function(){return this._applyModification(uf,arguments)},brighten:function(){return this._applyModification(hf,arguments)},darken:function(){return this._applyModification(pf,arguments)},desaturate:function(){return this._applyModification(sf,arguments)},saturate:function(){return this._applyModification(lf,arguments)},greyscale:function(){return this._applyModification(cf,arguments)},spin:function(){return this._applyModification(df,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(yf,arguments)},complement:function(){return this._applyCombination(ff,arguments)},monochromatic:function(){return this._applyCombination(_f,arguments)},splitcomplement:function(){return this._applyCombination(gf,arguments)},triad:function(){return this._applyCombination(mf,[3])},tetrad:function(){return this._applyCombination(mf,[4])}},Xd.fromRatio=function(e,t){if("object"==Hd(e)){var i={};for(var r in e)e.hasOwnProperty(r)&&(i[r]="a"===r?e[r]:Pf(e[r]));e=i}return Xd(e,t)},Xd.equals=function(e,t){return!(!e||!t)&&Xd(e).toRgbString()==Xd(t).toRgbString()},Xd.random=function(){return Xd.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Xd.mix=function(e,t,i){i=0===i?0:i||50;var r=Xd(e).toRgb(),n=Xd(t).toRgb(),o=i/100;return Xd({r:(n.r-r.r)*o+r.r,g:(n.g-r.g)*o+r.g,b:(n.b-r.b)*o+r.b,a:(n.a-r.a)*o+r.a})},Xd.readability=function(e,t){var i=Xd(e),r=Xd(t);return(Math.max(i.getLuminance(),r.getLuminance())+.05)/(Math.min(i.getLuminance(),r.getLuminance())+.05)},Xd.isReadable=function(e,t,i){var r,n,o=Xd.readability(e,t);switch(n=!1,(r=Ff(i)).level+r.size){case"AAsmall":case"AAAlarge":n=o>=4.5;break;case"AAlarge":n=o>=3;break;case"AAAsmall":n=o>=7}return n},Xd.mostReadable=function(e,t,i){var r,n,o,a,s=null,l=0;n=(i=i||{}).includeFallbackColors,o=i.level,a=i.size;for(var c=0;c<t.length;c++)(r=Xd.readability(e,t[c]))>l&&(l=r,s=Xd(t[c]));return Xd.isReadable(e,s,{level:o,size:a})||!n?s:(i.includeFallbackColors=!1,Xd.mostReadable(e,["#fff","#000"],i))};var vf=Xd.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},bf=Xd.hexNames=xf(vf);function xf(e){var t={};for(var i in e)e.hasOwnProperty(i)&&(t[e[i]]=i);return t}function wf(e){return e=parseFloat(e),(isNaN(e)||e<0||e>1)&&(e=1),e}function Cf(e,t){Sf(e)&&(e="100%");var i=Mf(e);return e=Math.min(t,Math.max(0,parseFloat(e))),i&&(e=parseInt(e*t,10)/100),Math.abs(e-t)<1e-6?1:e%t/parseFloat(t)}function Tf(e){return Math.min(1,Math.max(0,e))}function Af(e){return parseInt(e,16)}function Sf(e){return"string"==typeof e&&-1!=e.indexOf(".")&&1===parseFloat(e)}function Mf(e){return"string"==typeof e&&-1!=e.indexOf("%")}function Ef(e){return 1==e.length?"0"+e:""+e}function Pf(e){return e<=1&&(e=100*e+"%"),e}function If(e){return Math.round(255*parseFloat(e)).toString(16)}function kf(e){return Af(e)/255}var zf=function(){var e="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)",t="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?",i="[\\s|\\(]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")[,|\\s]+("+e+")\\s*\\)?";return{CSS_UNIT:new RegExp(e),rgb:new RegExp("rgb"+t),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+t),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+t),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Lf(e){return!!zf.CSS_UNIT.exec(e)}function Df(e){e=e.replace(Wd,"").replace(Kd,"").toLowerCase();var t,i=!1;if(vf[e])e=vf[e],i=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};return(t=zf.rgb.exec(e))?{r:t[1],g:t[2],b:t[3]}:(t=zf.rgba.exec(e))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=zf.hsl.exec(e))?{h:t[1],s:t[2],l:t[3]}:(t=zf.hsla.exec(e))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=zf.hsv.exec(e))?{h:t[1],s:t[2],v:t[3]}:(t=zf.hsva.exec(e))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=zf.hex8.exec(e))?{r:Af(t[1]),g:Af(t[2]),b:Af(t[3]),a:kf(t[4]),format:i?"name":"hex8"}:(t=zf.hex6.exec(e))?{r:Af(t[1]),g:Af(t[2]),b:Af(t[3]),format:i?"name":"hex"}:(t=zf.hex4.exec(e))?{r:Af(t[1]+""+t[1]),g:Af(t[2]+""+t[2]),b:Af(t[3]+""+t[3]),a:kf(t[4]+""+t[4]),format:i?"name":"hex8"}:!!(t=zf.hex3.exec(e))&&{r:Af(t[1]+""+t[1]),g:Af(t[2]+""+t[2]),b:Af(t[3]+""+t[3]),format:i?"name":"hex"}}function Ff(e){var t,i;return"AA"!==(t=((e=e||{level:"AA",size:"small"}).level||"AA").toUpperCase())&&"AAA"!==t&&(t="AA"),"small"!==(i=(e.size||"small").toLowerCase())&&"large"!==i&&(i="small"),{level:t,size:i}}const Rf=["name","state","icon","attribute"],Bf=st(((e,t,i)=>[{name:"entity",lebel:"Entity",selector:{entity:{filter:{domain:["device_tracker","person","zone"]}}}},{name:"",type:"grid",schema:[{name:"name",label:"Name",default:"",type:"string"},{name:"icon",label:"Icon",selector:{icon:{}}},...e?[]:[{name:"label_mode",label:"Label Mode",selector:{select:{mode:"dropdown",options:Rf.map((e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})))}}},{name:"attribute",label:"Attribute",disabled:i,selector:{attribute:{entity_id:t}}}],{name:"focus",label:"Focus",required:!1,type:"boolean"}]}]));class Of extends Xe{constructor(){super(...arguments),this._rgbColor=[0,0,0],this._computeLabel=e=>e.label||"",this._colorToRgb=e=>{const t=Xd(e);if(!t.isValid())return[0,0,0];const{r:i,g:r,b:n}=t.toRgb();return[i,r,n]}}firstUpdated(){var e;if(null===(e=this.config.elementConfig)||void 0===e?void 0:e.color){const e=this._colorToRgb(this.config.elementConfig.color);this._rgbColor=e}else{const e=ct(this.config.index||0),t=this._colorToRgb(e);this._rgbColor=t}}render(){return ke`
477
472
  <div class="header">
478
473
  <div class="back-title">
479
474
  <ha-icon-button-prev
@@ -484,7 +479,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
484
479
  </div>
485
480
  </div>
486
481
  ${this._renderContent()}
487
- `}_renderContent(){var e;const t=Object.assign({},this.config.elementConfig),i=!!(null===(e=t.entity)||void 0===e?void 0:e.startsWith("zone.")),r="attribute"!==t.label_mode,n=Pf(i,t.entity,r);return ke`
482
+ `}_renderContent(){var e;const t=Object.assign({},this.config.elementConfig),i=!!(null===(e=t.entity)||void 0===e?void 0:e.startsWith("zone.")),r="attribute"!==t.label_mode,n=Bf(i,t.entity,r);return ke`
488
483
  <ha-form
489
484
  .hass=${this.hass}
490
485
  .data=${t}
@@ -500,7 +495,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
500
495
  .required=${!1}
501
496
  @value-changed=${this._colorChanged}
502
497
  ></ha-selector>
503
- `}_goBack(){C(this,"go-back")}_colorChanged(e){if(e.stopPropagation(),!this.config)return;const t=e.detail.value,i=Vd(`rgb(${t.join(",")})`).toHexString(),r=Object.assign({},this.config.elementConfig);r.color=i,this.config=Object.assign(Object.assign({},this.config),{elementConfig:Object.assign(Object.assign({},r),{entity:r.entity||""})}),C(this,"config-changed",{config:this.config}),this._rgbColor=t}_valueChanged(e){e.stopPropagation();let t=e.detail.value;this.config.elementConfig=Object.assign(Object.assign({},this.config.elementConfig),t),C(this,"config-changed",{config:this.config}),this.requestUpdate()}}If.styles=G`
498
+ `}_goBack(){C(this,"go-back")}_colorChanged(e){if(e.stopPropagation(),!this.config)return;const t=e.detail.value,i=Xd(`rgb(${t.join(",")})`).toHexString(),r=Object.assign({},this.config.elementConfig);r.color=i,this.config=Object.assign(Object.assign({},this.config),{elementConfig:Object.assign(Object.assign({},r),{entity:r.entity||""})}),C(this,"config-changed",{config:this.config}),this._rgbColor=t}_valueChanged(e){e.stopPropagation();let t=e.detail.value;this.config.elementConfig=Object.assign(Object.assign({},this.config.elementConfig),t),C(this,"config-changed",{config:this.config}),this.requestUpdate()}}Of.styles=G`
504
499
  .header {
505
500
  display: flex;
506
501
  justify-content: space-between;
@@ -511,7 +506,7 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
511
506
  align-items: center;
512
507
  font-size: var(--ha-font-size-l);
513
508
  }
514
- `,e([et({attribute:!1})],If.prototype,"hass",void 0),e([et({attribute:!1})],If.prototype,"config",void 0),e([tt()],If.prototype,"_rgbColor",void 0),customElements.get("emc-sub-entity-editor")||customElements.define("emc-sub-entity-editor",If);class kf extends Xe{constructor(){super(...arguments),this._computeLabelCallback=e=>{var t,i;let r=null===(t=this.hass)||void 0===t?void 0:t.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`);return r||(r=null===(i=this.hass)||void 0===i?void 0:i.localize(`ui.panel.lovelace.editor.card.${e.label}`),r||e.label)}}connectedCallback(){super.connectedCallback(),td(),window.ExtraMapEditor=this}disconnectedCallback(){super.disconnectedCallback()}setConfig(e){this._config=e,this._configEntities=e.entities?Cd(e.entities):[]}render(){var e;if(!this.hass||!this._config)return Le;if(this._subEntityEditorConfig)return ke`
509
+ `,e([et({attribute:!1})],Of.prototype,"hass",void 0),e([et({attribute:!1})],Of.prototype,"config",void 0),e([tt()],Of.prototype,"_rgbColor",void 0);class jf extends Xe{constructor(){super(...arguments),this._computeLabelCallback=e=>{var t,i;let r=null===(t=this.hass)||void 0===t?void 0:t.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`);return r||(r=null===(i=this.hass)||void 0===i?void 0:i.localize(`ui.panel.lovelace.editor.card.${e.label}`),r||e.label)}}connectedCallback(){super.connectedCallback(),td(),window.ExtraMapEditor=this}disconnectedCallback(){super.disconnectedCallback()}setConfig(e){this._config=e,this._configEntities=e.entities?Cd(e.entities):[]}render(){var e;if(!this.hass||!this._config)return Le;if(this._subEntityEditorConfig)return ke`
515
510
  <emc-sub-entity-editor
516
511
  .hass=${this.hass}
517
512
  .config=${this._subEntityEditorConfig}
@@ -600,4 +595,4 @@ const Je={attribute:!0,type:String,converter:ae,reflect:!1,hasChanged:se},Qe=(e=
600
595
  justify-content: center;
601
596
  align-items: center;
602
597
  }
603
- `}}e([et({attribute:!1})],kf.prototype,"hass",void 0),e([tt()],kf.prototype,"_config",void 0),e([tt()],kf.prototype,"_configEntities",void 0),e([tt()],kf.prototype,"_subEntityEditorConfig",void 0),customElements.get("extra-map-editor")||customElements.define("extra-map-editor",kf);var zf=Object.freeze({__proto__:null,ExtraMapEditor:kf});export{up as CARD_VERSION,lt as COLORS,pp as DARK_AVAILABLE_STYLES,mp as DEFAULT_HOURS_TO_SHOW,gp as DEFAULT_ZOOM,Od as EmcEntityEditor,xd as EmcMap,If as EmcSubEntityEditor,wd as ExtraMapCard,fd as LOCAL_TIME_ZONE,fp as STYLE_OPTIONS,hp as STYLE_SCHEMA,xp as baseMapConfigSchema,ut as computeObjectId,pt as computeStateName,ht as computeStateNameFromEntityAttributes,b as createResource,m as deleteConfig,w as deleteResource,_ as ensureBadgeConfig,R as entityIdHistoryNeedsAttributes,d as fetchConfig,B as fetchDateWS,v as fetchResources,n as findCardIndex,ft as findEntities,c as findLovelaceCards,l as findLovelaceContainer,C as fireEvent,yd as formatTimeWeekday,pd as getAddress,ct as getColorByIndex,hd as getEntityId,i as getLovelace,s as getLovelaceContainerPath,_t as hasConfigChanged,wt as hasConfigOrEntitiesChanged,xt as hasConfigOrEntityChanged,Td as hasLocation,t as isComponentLoaded,p as isStrategyDashboard,y as isStrategySection,g as isStrategyView,gt as isValidEntityId,wp as mapConfigSchema,o as parseLovelaceCardPath,a as parseLovelaceContainerPath,yt as processConfigEntities,Cd as processEditorEntities,md as resolveTimeZone,f as saveConfig,bp as singleMapConfingSchema,j as subscribeHistory,O as subscribeHistoryStatesTimeWindow,T as subscribeRenderTemplate,h as updateLovelaceCards,u as updateLovelaceContainer,x as updateResource,gd as useAmPm};
598
+ `}}e([et({attribute:!1})],jf.prototype,"hass",void 0),e([tt()],jf.prototype,"_config",void 0),e([tt()],jf.prototype,"_configEntities",void 0),e([tt()],jf.prototype,"_subEntityEditorConfig",void 0);var $f=Object.freeze({__proto__:null,ExtraMapEditor:jf});export{up as CARD_VERSION,lt as COLORS,pp as DARK_AVAILABLE_STYLES,mp as DEFAULT_HOURS_TO_SHOW,gp as DEFAULT_ZOOM,Gd as EmcEntityEditor,xd as EmcMap,Of as EmcSubEntityEditor,wd as ExtraMapCard,fd as LOCAL_TIME_ZONE,fp as STYLE_OPTIONS,hp as STYLE_SCHEMA,kd as addResource,xp as baseMapConfigSchema,ut as computeObjectId,pt as computeStateName,ht as computeStateNameFromEntityAttributes,b as createResource,m as deleteConfig,w as deleteResource,_ as ensureBadgeConfig,R as entityIdHistoryNeedsAttributes,d as fetchConfig,B as fetchDateWS,v as fetchResources,n as findCardIndex,ft as findEntities,c as findLovelaceCards,l as findLovelaceContainer,C as fireEvent,yd as formatTimeWeekday,pd as getAddress,ct as getColorByIndex,hd as getEntityId,i as getLovelace,s as getLovelaceContainerPath,_t as hasConfigChanged,wt as hasConfigOrEntitiesChanged,xt as hasConfigOrEntityChanged,Td as hasLocation,t as isComponentLoaded,p as isStrategyDashboard,y as isStrategySection,g as isStrategyView,gt as isValidEntityId,wp as mapConfigSchema,o as parseLovelaceCardPath,a as parseLovelaceContainerPath,yt as processConfigEntities,Cd as processEditorEntities,zd as resetAddResource,md as resolveTimeZone,f as saveConfig,bp as singleMapConfingSchema,j as subscribeHistory,O as subscribeHistoryStatesTimeWindow,T as subscribeRenderTemplate,h as updateLovelaceCards,u as updateLovelaceContainer,x as updateResource,gd as useAmPm};
@@ -7,3 +7,4 @@ export * from './parse-aspect-ratio';
7
7
  export * from './process-config-entities';
8
8
  export * from './process-editor-entities';
9
9
  export * from './has_location';
10
+ export * from './load-module';
@@ -0,0 +1,3 @@
1
+ import { HomeAssistant } from '@types';
2
+ export declare const addResource: (hass: HomeAssistant) => Promise<void>;
3
+ export declare const resetAddResource: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-map-card",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Lovelace custom map card for Home Assistant",
5
5
  "keywords": [
6
6
  "home-assistant",