extra-map-card 1.0.8 → 1.1.0
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.
- package/dist/components/emc-map.d.ts +3 -1
- package/dist/constants/map-schema.d.ts +215 -0
- package/dist/extra-map-card-bundle.js +99 -9
- package/dist/extra-map-card.d.ts +1 -2
- package/dist/extra-map-editor.d.ts +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +99 -9
- package/dist/types/config.d.ts +1 -2
- package/dist/utilities/has_location.d.ts +2 -0
- package/dist/utilities/index.d.ts +2 -0
- package/dist/utilities/process-editor-entities.d.ts +2 -0
- package/package.json +1 -1
|
@@ -21,9 +21,11 @@ export declare class EmcMap extends LitElement {
|
|
|
21
21
|
private _mapHelper;
|
|
22
22
|
private _fitBounds;
|
|
23
23
|
private _loaded;
|
|
24
|
+
private _error?;
|
|
24
25
|
private get _darkMode();
|
|
25
|
-
protected render(): import("lit-html").TemplateResult<1>;
|
|
26
26
|
protected firstUpdated(): Promise<void>;
|
|
27
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
28
|
+
private _renderLoadError;
|
|
27
29
|
protected updated(changedProps: PropertyValues): void;
|
|
28
30
|
private _drawEntities;
|
|
29
31
|
private _computePathTooltip;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { LocalizeFunc } from 'custom-card-helpers';
|
|
2
|
+
export declare const STYLE_SCHEMA: {
|
|
3
|
+
name: string;
|
|
4
|
+
selector: {
|
|
5
|
+
select: {
|
|
6
|
+
options: string[];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
}[];
|
|
10
|
+
export declare const DARK_AVAILABLE_STYLES: string[];
|
|
11
|
+
export declare const STYLE_OPTIONS: {
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const DEFAULT_HOURS_TO_SHOW = 0;
|
|
16
|
+
export declare const DEFAULT_ZOOM = 14;
|
|
17
|
+
export declare const singleMapConfingSchema: import("memoize-one").MemoizedFn<(localize: LocalizeFunc) => readonly [{
|
|
18
|
+
readonly name: "";
|
|
19
|
+
readonly type: "expandable";
|
|
20
|
+
readonly iconPath: string;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly schema: readonly [{
|
|
23
|
+
readonly name: "";
|
|
24
|
+
readonly type: "grid";
|
|
25
|
+
readonly schema: readonly ({
|
|
26
|
+
name: string;
|
|
27
|
+
label: string;
|
|
28
|
+
selector: {
|
|
29
|
+
text: {};
|
|
30
|
+
number?: undefined;
|
|
31
|
+
select?: undefined;
|
|
32
|
+
boolean?: undefined;
|
|
33
|
+
};
|
|
34
|
+
default?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
name: string;
|
|
37
|
+
label: string;
|
|
38
|
+
default: number;
|
|
39
|
+
selector: {
|
|
40
|
+
number: {
|
|
41
|
+
mode: string;
|
|
42
|
+
min: number;
|
|
43
|
+
};
|
|
44
|
+
text?: undefined;
|
|
45
|
+
select?: undefined;
|
|
46
|
+
boolean?: undefined;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
name: string;
|
|
50
|
+
label: string;
|
|
51
|
+
default: string;
|
|
52
|
+
selector: {
|
|
53
|
+
select: {
|
|
54
|
+
mode: string;
|
|
55
|
+
options: {
|
|
56
|
+
value: string;
|
|
57
|
+
label: string;
|
|
58
|
+
}[];
|
|
59
|
+
};
|
|
60
|
+
text?: undefined;
|
|
61
|
+
number?: undefined;
|
|
62
|
+
boolean?: undefined;
|
|
63
|
+
};
|
|
64
|
+
} | {
|
|
65
|
+
name: string;
|
|
66
|
+
label: string;
|
|
67
|
+
default: boolean;
|
|
68
|
+
selector: {
|
|
69
|
+
boolean: {};
|
|
70
|
+
text?: undefined;
|
|
71
|
+
number?: undefined;
|
|
72
|
+
select?: undefined;
|
|
73
|
+
};
|
|
74
|
+
})[];
|
|
75
|
+
}, {
|
|
76
|
+
name: string;
|
|
77
|
+
type: string;
|
|
78
|
+
iconPath: string;
|
|
79
|
+
title: string;
|
|
80
|
+
schema: {
|
|
81
|
+
name: string;
|
|
82
|
+
type: string;
|
|
83
|
+
schema: {
|
|
84
|
+
name: string;
|
|
85
|
+
label: string;
|
|
86
|
+
selector: {
|
|
87
|
+
select: {
|
|
88
|
+
mode: string;
|
|
89
|
+
options: {
|
|
90
|
+
value: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}[];
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}[];
|
|
96
|
+
}[];
|
|
97
|
+
}];
|
|
98
|
+
}]>;
|
|
99
|
+
export declare const baseMapConfigSchema: import("memoize-one").MemoizedFn<() => readonly [{
|
|
100
|
+
readonly name: "title";
|
|
101
|
+
readonly label: "Title";
|
|
102
|
+
readonly selector: {
|
|
103
|
+
readonly text: {
|
|
104
|
+
readonly type: "text";
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "api_key";
|
|
109
|
+
readonly label: "MapTiler API Key (required)";
|
|
110
|
+
readonly required: true;
|
|
111
|
+
readonly selector: {
|
|
112
|
+
readonly text: {
|
|
113
|
+
readonly type: "text";
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}]>;
|
|
117
|
+
export declare const mapConfigSchema: import("memoize-one").MemoizedFn<(localize: LocalizeFunc) => ({
|
|
118
|
+
readonly name: "";
|
|
119
|
+
readonly type: "expandable";
|
|
120
|
+
readonly iconPath: string;
|
|
121
|
+
readonly title: string;
|
|
122
|
+
readonly schema: readonly [{
|
|
123
|
+
readonly name: "";
|
|
124
|
+
readonly type: "grid";
|
|
125
|
+
readonly schema: readonly ({
|
|
126
|
+
name: string;
|
|
127
|
+
label: string;
|
|
128
|
+
selector: {
|
|
129
|
+
text: {};
|
|
130
|
+
number?: undefined;
|
|
131
|
+
select?: undefined;
|
|
132
|
+
boolean?: undefined;
|
|
133
|
+
};
|
|
134
|
+
default?: undefined;
|
|
135
|
+
} | {
|
|
136
|
+
name: string;
|
|
137
|
+
label: string;
|
|
138
|
+
default: number;
|
|
139
|
+
selector: {
|
|
140
|
+
number: {
|
|
141
|
+
mode: string;
|
|
142
|
+
min: number;
|
|
143
|
+
};
|
|
144
|
+
text?: undefined;
|
|
145
|
+
select?: undefined;
|
|
146
|
+
boolean?: undefined;
|
|
147
|
+
};
|
|
148
|
+
} | {
|
|
149
|
+
name: string;
|
|
150
|
+
label: string;
|
|
151
|
+
default: string;
|
|
152
|
+
selector: {
|
|
153
|
+
select: {
|
|
154
|
+
mode: string;
|
|
155
|
+
options: {
|
|
156
|
+
value: string;
|
|
157
|
+
label: string;
|
|
158
|
+
}[];
|
|
159
|
+
};
|
|
160
|
+
text?: undefined;
|
|
161
|
+
number?: undefined;
|
|
162
|
+
boolean?: undefined;
|
|
163
|
+
};
|
|
164
|
+
} | {
|
|
165
|
+
name: string;
|
|
166
|
+
label: string;
|
|
167
|
+
default: boolean;
|
|
168
|
+
selector: {
|
|
169
|
+
boolean: {};
|
|
170
|
+
text?: undefined;
|
|
171
|
+
number?: undefined;
|
|
172
|
+
select?: undefined;
|
|
173
|
+
};
|
|
174
|
+
})[];
|
|
175
|
+
}, {
|
|
176
|
+
name: string;
|
|
177
|
+
type: string;
|
|
178
|
+
iconPath: string;
|
|
179
|
+
title: string;
|
|
180
|
+
schema: {
|
|
181
|
+
name: string;
|
|
182
|
+
type: string;
|
|
183
|
+
schema: {
|
|
184
|
+
name: string;
|
|
185
|
+
label: string;
|
|
186
|
+
selector: {
|
|
187
|
+
select: {
|
|
188
|
+
mode: string;
|
|
189
|
+
options: {
|
|
190
|
+
value: string;
|
|
191
|
+
label: string;
|
|
192
|
+
}[];
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
}[];
|
|
196
|
+
}[];
|
|
197
|
+
}];
|
|
198
|
+
} | {
|
|
199
|
+
readonly name: "title";
|
|
200
|
+
readonly label: "Title";
|
|
201
|
+
readonly selector: {
|
|
202
|
+
readonly text: {
|
|
203
|
+
readonly type: "text";
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
} | {
|
|
207
|
+
readonly name: "api_key";
|
|
208
|
+
readonly label: "MapTiler API Key (required)";
|
|
209
|
+
readonly required: true;
|
|
210
|
+
readonly selector: {
|
|
211
|
+
readonly text: {
|
|
212
|
+
readonly type: "text";
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
})[]>;
|
|
@@ -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.0
|
|
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.1.0","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}),m=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),f=(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 S,A;!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"}(S||(S={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(A||(A={}));var M=function(e){if(e.time_format===A.language||e.time_format===A.system){var t=e.time_format===A.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===A.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)},N=globalThis,$=N.ShadowRoot&&(void 0===N.ShadyCSS||N.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($&&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($)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=N.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},W=$?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
|
|
@@ -231,11 +231,16 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
231
231
|
* @license
|
|
232
232
|
* Copyright 2018 Google LLC
|
|
233
233
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
234
|
-
*/const gp="important",yp=" !"+gp,_p=mp(class extends fp{constructor(e){if(super(e),e.type!==dp.ATTRIBUTE||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const r=e[i];return null==r?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?i.removeProperty(e):i[e]=null);for(const e in t){const r=t[e];if(null!=r){this.ft.add(e);const t="string"==typeof r&&r.endsWith(yp);e.includes("-")||t?i.setProperty(e,t?r.slice(0,-11):r,t?gp:""):i[e]=r}}return ze}}),vp=window.loadCardHelpers?window.loadCardHelpers():void 0,bp=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():vp&&(i=vp),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var
|
|
235
|
-
<div class="maptiler-map" style="${this._computeMapStyle()}"
|
|
234
|
+
*/const gp="important",yp=" !"+gp,_p=mp(class extends fp{constructor(e){if(super(e),e.type!==dp.ATTRIBUTE||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const r=e[i];return null==r?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?i.removeProperty(e):i[e]=null);for(const e in t){const r=t[e];if(null!=r){this.ft.add(e);const t="string"==typeof r&&r.endsWith(yp);e.includes("-")||t?i.setProperty(e,t?r.slice(0,-11):r,t?gp:""):i[e]=r}}return ze}}),vp=window.loadCardHelpers?window.loadCardHelpers():void 0,bp=()=>{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()},xp=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():vp&&(i=vp),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var wp,Cp,Tp,Sp,Ap,Mp,Ep,Pp;!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"}(wp||(wp={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(Cp||(Cp={})),function(e){e.local="local",e.server="server"}(Tp||(Tp={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(Sp||(Sp={})),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"}(Ap||(Ap={}));const Ip=e=>"string"==typeof e?e:e.entity_id,kp=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}})),zp=null===(Pp=null===(Mp=Intl.DateTimeFormat)||void 0===Mp?void 0:(Ep=Mp.call(Intl)).resolvedOptions)||void 0===Pp?void 0:Pp.call(Ep).timeZone,Lp=null!=zp?zp:"UTC",Dp=(e,t)=>e===Tp.local&&zp?Lp:t,Fp=st((e=>{if(e.time_format===Cp.language||e.time_format===Cp.system){const t=e.time_format===Cp.language?e.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(t).includes("10")}return e.time_format===Cp.am_pm})),Rp=(e,t,i)=>Bp(t,i.time_zone).format(e),Bp=st(((e,t)=>new Intl.DateTimeFormat(e.language,{weekday:"long",hour:Fp(e)?"numeric":"2-digit",minute:"2-digit",hour12:Fp(e),timeZone:Dp(e.time_zone,t)}))),Op={dark:ti.STREETS.DARK,light:ti.STREETS.LIGHT,demo:"https://demotiles.maplibre.org/style.json"},jp={backgroundColor:{light:"#fff",dark:"#222222"},fill:{light:"#333",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"}};let Np=class extends Ke{constructor(){super(...arguments),this.autoFit=!1,this.fitZones=!1,this.zoom=14,this.themeMode="auto",this.blockMoreInfo=!1,this._mapItems=[],this._zoneItems=[],this._mapFocusZones=[],this._mapFocusItems=[],this._mapPaths=[],this._mapHelper=yh,this._loaded=!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=>this._darkMode?jp[e].dark:jp[e].light}get _darkMode(){return"dark"===this.themeMode||"auto"===this.themeMode&&Boolean(this.hass.themes.darkMode)}async firstUpdated(){await xp(this.entities),await new Promise((e=>setTimeout(e,0))),this._initMap()}render(){const e=this._renderLoadError();return ke`
|
|
235
|
+
<div class="maptiler-map" style="${this._computeMapStyle()}">
|
|
236
|
+
${e}
|
|
236
237
|
<div id="map"></div>
|
|
237
238
|
</div>
|
|
238
|
-
`}
|
|
239
|
+
`}_renderLoadError(){if(!this._error)return ke``;const{code:e,message:t}=this._error;return ke`
|
|
240
|
+
<ha-alert alert-type="${e}" id="error">
|
|
241
|
+
${t}
|
|
242
|
+
</ha-alert>
|
|
243
|
+
`}updated(e){var t,i,r,n;if(super.updated(e),!this._loaded)return;let o=!1;const a=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities(),o=!0;else if(this._loaded&&a&&this.entities)for(const e of this.entities)if(a.states[Ip(e)]!==this.hass.states[Ip(e)]){this._drawEntities(),o=!0;break}if((e.has("_loaded")||this.autoFit&&o)&&this._fitMap(),e.has("zoom")&&this._map.setZoom(this.zoom),e.has("hass")&&a){if((null===(t=a.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")&&(!a||(null===(r=a.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._zoneItems.length&&(this._zoneItems.forEach((e=>e.remove())),this._zoneItems=[],this._mapFocusZones=[]),!this.entities)return;const i=[],r=getComputedStyle(this),n=r.getPropertyValue("--accent-color"),o=r.getPropertyValue("--secondary-text-color"),a=r.getPropertyValue("--dark-primary-color"),s=this._darkMode?"dark":"light";for(const r of this.entities){const l=e.states[Ip(r)];if(!l)continue;const c="string"!=typeof r?r.name:void 0,u=null!=c?c:pt(l),{latitude:h,longitude:p,passive:d,icon:m,radius:f,entity_picture:g,gps_accuracy:y}=l.attributes;if(!h||!p)continue;const _=[p,h];if("zone"===L(l)){let e="";if(m){const t=document.createElement("ha-icon");t.setAttribute("icon",m),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=u,e=t.outerHTML}const a=np(_,f,{steps:200,units:"meters",properties:{color:d?o:n,title:u,opacity:d?.2:.3}});i.push(a);const l=document.createElement("div");l.className=`marker ${s}`,l.innerHTML=e,l.title=u;const c=new Xr({element:l}).setLngLat(_).addTo(t);this._zoneItems.push(c),!this.fitZones||"string"!=typeof r&&!1===r.focus||this._mapFocusZones.push(a.geometry);continue}const v="string"!=typeof r&&"state"===r.label_mode?this.hass.formatEntityState(l):"string"!=typeof r&&"attribute"===r.label_mode&&void 0!==r.attribute?this.hass.formatEntityAttributeValue(l,r.attribute):null!=c?c:u.split(" ").map((e=>e[0])).join("").substring(0,3),b=document.createElement("ha-entity-marker");b.hass=this.hass,b.showIcon="string"!=typeof r&&"icon"===r.label_mode,b.entityId=Ip(r),b.entityName=v,b.entityPicture=!g||"string"!=typeof r&&r.label_mode?"":this.hass.hassUrl(g),"string"!=typeof r&&(b.entityColor=r.color),this.blockMoreInfo&&b.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.preventDefault()}),!0);const x=new Xr({element:b}).setLngLat(_).addTo(t);if(this._mapItems.push(x),"string"!=typeof r&&!1===r.focus||this._mapFocusItems.push(x),y){const e=np(_,y,{steps:64,units:"meters",properties:{color:a,title:u,opacity:.5}});i.push(e)}}const l={type:"geojson",data:{type:"FeatureCollection",features:i}};t.getSource("circles")&&(t.removeSource("circles"),t.removeLayer("circles"),t.removeLayer("circles-stroke")),t.addSource("circles",l),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}})}_computePathTooltip(e,t){let i;return i=e.fullDatetime?E(t.timestamp,this.hass.locale):pp(t.timestamp)?I(t.timestamp,this.hass.locale):Rp(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 kp(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._mapFocusItems.length&&!this._mapFocusZones.length)return void this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]);let s=new xh;null===(t=this._mapFocusItems)||void 0===t||t.forEach((e=>{s.extend(e.getLngLat())})),null===(i=this._mapFocusZones)||void 0===i||i.forEach((e=>{e.coordinates[0].forEach((e=>{s.extend([e[0],e[1]])}))})),s.isEmpty()||(this._fitBounds=s,a.fitBounds(s,{padding:null!==(r=null==e?void 0:e.pad)&&void 0!==r?r:100,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():Op.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 fu(o),this._map.on("load",(async()=>{this._loaded=!0})),this._map.on("style.load",(async()=>{this._changeControlTheme(),this._drawPaths()}));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(Op.demo),this.zoom=1)}))}_centerMap(){this._fitMap({zoom:this.zoom,animate:!0})}_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):Op.dark:e?i(e):Op.light}_changeControlTheme(){const e=e=>this.getModeColor(e),t=Array.from(this.shadowRoot.querySelectorAll(".maplibregl-ctrl"));for(const i of t){const t=Array.from(i.querySelectorAll("button"));for(const i of t){const t=i;t.style.backgroundColor=e("backgroundColor"),t.style.boxShadow=e("boxShadow");const r=i.querySelector("span");if(r){const e=window.getComputedStyle(r).backgroundImage;if(e.startsWith('url("data:image/svg+xml')){const t=this.getModeColor("fill"),i=e.slice(5,-2),n=decodeURIComponent(i.split(",")[1]).replace(/fill:[^;"]*/g,`fill:${t}`).replace(/fill="[^"]*"/g,`fill="${t}"`),o=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`;r.style.backgroundImage=`url("${o}")`}}}}}_computeMapStyle(){const e=e=>this.getModeColor(e),t=e("fill"),i=e("backgroundColor"),r=e("boxShadow");return _p({"--emc-btn-bg":i,"--emc-btn-shadow":r,"--emc-btn-color":t})}static get styles(){return[Z(Gh),G`
|
|
239
244
|
:host {
|
|
240
245
|
--tooltip-color: rgba(80, 80, 80, 0.9);
|
|
241
246
|
}
|
|
@@ -243,7 +248,19 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
243
248
|
height: 100%;
|
|
244
249
|
width: 100%;
|
|
245
250
|
}
|
|
246
|
-
|
|
251
|
+
#error {
|
|
252
|
+
position: absolute;
|
|
253
|
+
bottom: 0.5rem;
|
|
254
|
+
left: 50%;
|
|
255
|
+
transform: translateX(-50%);
|
|
256
|
+
background: var(--card-background-color);
|
|
257
|
+
height: fit-content;
|
|
258
|
+
display: flex;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
z-index: 3;
|
|
261
|
+
width: max-content;
|
|
262
|
+
word-wrap: break-word;
|
|
263
|
+
}
|
|
247
264
|
#map {
|
|
248
265
|
position: absolute;
|
|
249
266
|
top: 0;
|
|
@@ -282,7 +299,13 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
282
299
|
.maplibregl-ctrl-bottom-left > .maplibregl-ctrl:not(.maplibregl-map) {
|
|
283
300
|
display: none !important;
|
|
284
301
|
}
|
|
285
|
-
|
|
302
|
+
.mapboxgl-ctrl-group button, .maplibregl-ctrl-group button {
|
|
303
|
+
width: 30px;
|
|
304
|
+
height: 30px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
`]}};e([et({attribute:!1})],Np.prototype,"hass",void 0),e([et({attribute:!1})],Np.prototype,"entities",void 0),e([et({attribute:!1})],Np.prototype,"paths",void 0),e([et({attribute:"auto-fit",type:Boolean})],Np.prototype,"autoFit",void 0),e([et({attribute:"fit-zones",type:Boolean})],Np.prototype,"fitZones",void 0),e([et({type:Number})],Np.prototype,"zoom",void 0),e([et({attribute:"theme-mode",type:String})],Np.prototype,"themeMode",void 0),e([et({type:String})],Np.prototype,"apiKey",void 0),e([et({type:Boolean})],Np.prototype,"blockMoreInfo",void 0),e([et({type:Object})],Np.prototype,"customStyles",void 0),e([tt()],Np.prototype,"_loaded",void 0),e([tt()],Np.prototype,"_error",void 0),Np=e([Ye("emc-map")],Np);var $p="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";const Vp=[{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"]}}}],Up=["STREETS","BASIC","BRIGHT","DATAVIZ","VOYAGER","BACKDROP"],qp=()=>Vp.reduce(((e,t)=>{const i=t.selector.select.options;return e.concat(i.map((e=>({value:e,label:e}))))}),[]),Zp=qp(),Gp=0,Hp=14,Wp=["auto","light","dark"],Kp=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:Hp,selector:{number:{mode:"box",min:0}}},{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:Wp.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:"block_more_info",label:"Block click action",default:!0,selector:{boolean:{}}}],Xp={name:"map_styles",type:"expandable",iconPath:$p,title:"Custom Styles",schema:[{name:"",type:"grid",schema:[{name:"light",label:"Light Style",selector:{select:{mode:"dropdown",options:Zp}}},{name:"dark",label:"Dark Style",selector:{select:{mode:"dropdown",options:Zp}}}]}]},Yp=st((e=>[{name:"",type:"expandable",iconPath:$p,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[...Kp]},Xp]}])),Jp=st((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),Qp=st((e=>[...Jp(),...Yp(e)]));let ed=class extends Ke{constructor(){super(...arguments),this._mapEntities=[],this._colorDict={},this._colorIndex=0,this._getHistoryPaths=st(((e,t)=>{var i,r,n,o;if(!t||null===(i=e.hours_to_show)||void 0===i||!i)return;const a=[];for(const i of Object.keys(t)){if("zone"===z(i))continue;const s=t[i];if(!(null==s?void 0:s.length))continue;const l=[];for(const e of s){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),l.push(r)}const c=null===(r=this._configEntities)||void 0===r?void 0:r.find((e=>e.entity===i)),u=null!==(n=null==c?void 0:c.name)&&void 0!==n?n:i in this.hass.states?pt(this.hass.states[i]):i;a.push({points:l,name:u,fullDatetime:(null!==(o=e.hours_to_show)&&void 0!==o?o:0)>=144,color:this._getColor(i),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 nd})),document.createElement("extra-map-editor")}static getStubConfig(e,t,i){return{type:"custom:extra-map-card",entities:mt(e,2,t,i,["device_tracker"]),theme_mode:"auto",block_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");this._config=Object.assign({},e),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:4,min_columns:6,min_rows:2}}render(){var e,t,i,r;if(!this._config)return Le;if(this._error)return ke`<ha-alert alert-type="error">
|
|
286
309
|
${this.hass.localize("ui.components.map.error")}: ${this._error.message} (${this._error.code})
|
|
287
310
|
</ha-alert>`;const n=this._config.theme_mode||(this._config.dark_mode?"dark":"auto"),o=this._config.custom_styles||{};return ke`
|
|
288
311
|
<ha-card id="card" .header=${this._config.title}>
|
|
@@ -293,7 +316,7 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
293
316
|
.paths=${this._getHistoryPaths(this._config,this._stateHistory)}
|
|
294
317
|
.autoFit=${null!==(e=this._config.auto_fit)&&void 0!==e&&e}
|
|
295
318
|
.fitZones=${null!==(t=this._config.fit_zones)&&void 0!==t&&t}
|
|
296
|
-
.zoom=${null!==(i=this._config.default_zoom)&&void 0!==i?i
|
|
319
|
+
.zoom=${null!==(i=this._config.default_zoom)&&void 0!==i?i:Hp}
|
|
297
320
|
.themeMode=${n}
|
|
298
321
|
.apiKey=${this._config.api_key}
|
|
299
322
|
.blockMoreInfo=${null!==(r=this._config.block_more_info)&&void 0!==r&&r}
|
|
@@ -301,7 +324,7 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
301
324
|
></emc-map>
|
|
302
325
|
</div>
|
|
303
326
|
</ha-card>
|
|
304
|
-
`}shouldUpdate(e){var t;if(!e.has("hass")||e.size>1)return!0;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||((null===(t=this._config)||void 0===t?void 0:t.entities)?wt(this,e):_t(this,e))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=yt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory()}_subscribeHistory(){var e,i,r;t(this.hass,"history")&&!this._subscribed&&null!==(i=null===(e=this._config)||void 0===e?void 0:e.hours_to_show)&&void 0!==i&&i&&(this._subscribed=O(this.hass,(e=>{this._subscribed&&(this._stateHistory=e)}),null!==(r=this._config.hours_to_show)&&void 0!==r?r:0,(this._configEntities||[]).map((e=>e.entity)),!1,!1,!1).catch((e=>{this._subscribed=void 0,this._error=e})))}_unsubscribeHistory(){this._subscribed&&(this._subscribed.then((e=>null==e?void 0:e())),this._subscribed=void 0)}updated(e){var t;(null===(t=this._configEntities)||void 0===t?void 0:t.length)?this._subscribed&&!e.has("_config")||(this._unsubscribeHistory(),this._subscribeHistory()):this._unsubscribeHistory(),e.has("_config")&&this._computePadding()}_computePadding(){const e=this.shadowRoot.getElementById("root"),t="panel"===this.layout||"grid"===this.layout;if(!this._config||t||!e)return;if(!this._config.aspect_ratio)return void(e.style.paddingBottom="100%");e.style.height="auto";const i=Tt(this._config.aspect_ratio);e.style.paddingBottom=i&&i.w>0&&i.h>0?`${(100*i.h/i.w).toFixed(2)}%`:e.style.paddingBottom="100%"}_getColor(e){let t=this._colorDict[e];return t||(t=ct(this._colorIndex),this._colorIndex++,this._colorDict[e]=t,t)}_getMapEntities(){return[...(this._configEntities||[]).map((e=>({entity_id:e.entity,color:this._getColor(e.entity),label_mode:e.label_mode,attribute:e.attribute,focus:e.focus,name:e.name})))]}};
|
|
327
|
+
`}shouldUpdate(e){var t;if(!e.has("hass")||e.size>1)return!0;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||((null===(t=this._config)||void 0===t?void 0:t.entities)?wt(this,e):_t(this,e))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=yt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory()}_subscribeHistory(){var e,i,r;t(this.hass,"history")&&!this._subscribed&&null!==(i=null===(e=this._config)||void 0===e?void 0:e.hours_to_show)&&void 0!==i&&i&&(this._subscribed=O(this.hass,(e=>{this._subscribed&&(this._stateHistory=e)}),null!==(r=this._config.hours_to_show)&&void 0!==r?r:0,(this._configEntities||[]).map((e=>e.entity)),!1,!1,!1).catch((e=>{this._subscribed=void 0,this._error=e})))}_unsubscribeHistory(){this._subscribed&&(this._subscribed.then((e=>null==e?void 0:e())),this._subscribed=void 0)}updated(e){var t;(null===(t=this._configEntities)||void 0===t?void 0:t.length)?this._subscribed&&!e.has("_config")||(this._unsubscribeHistory(),this._subscribeHistory()):this._unsubscribeHistory(),e.has("_config")&&this._computePadding()}_computePadding(){const e=this.shadowRoot.getElementById("root"),t="panel"===this.layout||"grid"===this.layout;if(!this._config||t||!e)return;if(!this._config.aspect_ratio)return void(e.style.paddingBottom="100%");e.style.height="auto";const i=Tt(this._config.aspect_ratio);e.style.paddingBottom=i&&i.w>0&&i.h>0?`${(100*i.h/i.w).toFixed(2)}%`:e.style.paddingBottom="100%"}_getColor(e){let t=this._colorDict[e];return t||(t=ct(this._colorIndex),this._colorIndex++,this._colorDict[e]=t,t)}_getMapEntities(){return[...(this._configEntities||[]).map((e=>({entity_id:e.entity,color:this._getColor(e.entity),label_mode:e.label_mode,attribute:e.attribute,focus:e.focus,name:e.name})))]}};function td(e){return e.map((e=>"string"==typeof e?{entity:e}:e))}ed.styles=G`
|
|
305
328
|
ha-card {
|
|
306
329
|
overflow: hidden;
|
|
307
330
|
width: 100%;
|
|
@@ -313,4 +336,71 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
313
336
|
position: relative;
|
|
314
337
|
height: 100%;
|
|
315
338
|
}
|
|
316
|
-
`,e([et({attribute:!1})],
|
|
339
|
+
`,e([et({attribute:!1})],ed.prototype,"hass",void 0),e([et({attribute:!1})],ed.prototype,"layout",void 0),e([tt()],ed.prototype,"_config",void 0),e([tt()],ed.prototype,"_mapEntities",void 0),e([tt()],ed.prototype,"_error",void 0),e([tt()],ed.prototype,"_stateHistory",void 0),e([rt("emc-map")],ed.prototype,"_mapTiler",void 0),ed=e([Ye("extra-map-card")],ed),window.customCards=window.customCards||[],window.customCards.find((e=>"extra-map-card"===e.type))||window.customCards.push({description:"Extra Map Card using MapTiler",name:"Extra Map Card",preview:!0,type:"extra-map-card"});const id=e=>"latitude"in e.attributes&&"longitude"in e.attributes;let rd=class extends Ke{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(),bp()}disconnectedCallback(){super.disconnectedCallback()}setConfig(e){this._config=e,this._configEntities=e.entities?td(e.entities):[]}render(){if(!this.hass||!this._config)return Le;const e=Qp(this.hass.localize);return ke`
|
|
340
|
+
<ha-form
|
|
341
|
+
.hass=${this.hass}
|
|
342
|
+
.data=${this._config}
|
|
343
|
+
.schema=${e}
|
|
344
|
+
.computeLabel=${this._computeLabelCallback}
|
|
345
|
+
@value-changed=${this._valueChanged}
|
|
346
|
+
>
|
|
347
|
+
</ha-form>
|
|
348
|
+
|
|
349
|
+
<hui-entity-editor
|
|
350
|
+
.hass=${this.hass}
|
|
351
|
+
.entities=${this._configEntities}
|
|
352
|
+
.entityFilter=${id}
|
|
353
|
+
@entities-changed=${this._entitiesValueChanged}
|
|
354
|
+
></hui-entity-editor>
|
|
355
|
+
`}_valueChanged(e){e.stopPropagation(),C(this,"config-changed",{config:e.detail.value})}_entitiesValueChanged(e){e.detail&&e.detail.entities&&(this._config=Object.assign(Object.assign({},this._config),{entities:e.detail.entities}),this._configEntities=td(this._config.entities||[]),C(this,"config-changed",{config:this._config}))}static get styles(){return G`
|
|
356
|
+
.card-config {
|
|
357
|
+
/* Cancels overlapping Margins for HAForm + Card Config options */
|
|
358
|
+
overflow: auto;
|
|
359
|
+
}
|
|
360
|
+
ha-switch {
|
|
361
|
+
padding: 16px 6px;
|
|
362
|
+
}
|
|
363
|
+
.side-by-side {
|
|
364
|
+
display: flex;
|
|
365
|
+
align-items: flex-end;
|
|
366
|
+
}
|
|
367
|
+
.side-by-side > * {
|
|
368
|
+
flex: 1;
|
|
369
|
+
padding-right: 8px;
|
|
370
|
+
padding-inline-end: 8px;
|
|
371
|
+
padding-inline-start: initial;
|
|
372
|
+
}
|
|
373
|
+
.side-by-side > *:last-child {
|
|
374
|
+
flex: 1;
|
|
375
|
+
padding-right: 0;
|
|
376
|
+
padding-inline-end: 0;
|
|
377
|
+
padding-inline-start: initial;
|
|
378
|
+
}
|
|
379
|
+
.suffix {
|
|
380
|
+
margin: 0 8px;
|
|
381
|
+
}
|
|
382
|
+
hui-action-editor,
|
|
383
|
+
ha-select,
|
|
384
|
+
ha-textfield,
|
|
385
|
+
ha-icon-picker {
|
|
386
|
+
margin-top: 8px;
|
|
387
|
+
display: block;
|
|
388
|
+
}
|
|
389
|
+
ha-expansion-panel {
|
|
390
|
+
display: block;
|
|
391
|
+
--expansion-panel-content-padding: 0;
|
|
392
|
+
border-radius: 6px;
|
|
393
|
+
--ha-card-border-radius: 6px;
|
|
394
|
+
}
|
|
395
|
+
ha-expansion-panel .content {
|
|
396
|
+
padding: 12px;
|
|
397
|
+
}
|
|
398
|
+
ha-expansion-panel > *[slot="header"] {
|
|
399
|
+
margin: 0;
|
|
400
|
+
font-size: inherit;
|
|
401
|
+
font-weight: inherit;
|
|
402
|
+
}
|
|
403
|
+
ha-expansion-panel ha-svg-icon {
|
|
404
|
+
color: var(--secondary-text-color);
|
|
405
|
+
}
|
|
406
|
+
`}};e([et({attribute:!1})],rd.prototype,"hass",void 0),e([tt()],rd.prototype,"_config",void 0),e([tt()],rd.prototype,"_configEntities",void 0),rd=e([Ye("extra-map-editor")],rd);var nd=Object.freeze({__proto__:null,get ExtraMapEditor(){return rd}});export{lt as COLORS,Up as DARK_AVAILABLE_STYLES,Gp as DEFAULT_HOURS_TO_SHOW,Hp as DEFAULT_ZOOM,Np as EmcMap,ed as ExtraMapCard,Lp as LOCAL_TIME_ZONE,Zp as STYLE_OPTIONS,Vp as STYLE_SCHEMA,Jp as baseMapConfigSchema,ut as computeObjectId,pt as computeStateName,ht as computeStateNameFromEntityAttributes,b as createResource,f as deleteConfig,w as deleteResource,_ as ensureBadgeConfig,R as entityIdHistoryNeedsAttributes,d as fetchConfig,B as fetchDateWS,v as fetchResources,n as findCardIndex,mt as findEntities,c as findLovelaceCards,l as findLovelaceContainer,C as fireEvent,Rp as formatTimeWeekday,kp as getAddress,ct as getColorByIndex,Ip as getEntityId,i as getLovelace,s as getLovelaceContainerPath,_t as hasConfigChanged,wt as hasConfigOrEntitiesChanged,xt as hasConfigOrEntityChanged,id as hasLocation,t as isComponentLoaded,p as isStrategyDashboard,y as isStrategySection,g as isStrategyView,gt as isValidEntityId,Qp as mapConfigSchema,o as parseLovelaceCardPath,a as parseLovelaceContainerPath,yt as processConfigEntities,td as processEditorEntities,Dp as resolveTimeZone,m as saveConfig,Yp as singleMapConfingSchema,j as subscribeHistory,O as subscribeHistoryStatesTimeWindow,T as subscribeRenderTemplate,h as updateLovelaceCards,u as updateLovelaceContainer,x as updateResource,Fp as useAmPm};
|
package/dist/extra-map-card.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { HomeAssistant, LovelaceCard, LovelaceGridOptions } from '@types';
|
|
|
2
2
|
import { LitElement, TemplateResult, nothing, PropertyValues } from 'lit';
|
|
3
3
|
import { ExtraMapCardConfig } from 'types/config';
|
|
4
4
|
import './components/emc-map';
|
|
5
|
-
export declare const DEFAULT_HOURS_TO_SHOW = 0;
|
|
6
|
-
export declare const DEFAULT_ZOOM = 14;
|
|
7
5
|
export declare class ExtraMapCard extends LitElement implements LovelaceCard {
|
|
8
6
|
hass: HomeAssistant;
|
|
9
7
|
layout?: string;
|
|
@@ -17,6 +15,7 @@ export declare class ExtraMapCard extends LitElement implements LovelaceCard {
|
|
|
17
15
|
private _stateHistory?;
|
|
18
16
|
private _mapTiler?;
|
|
19
17
|
private _getAllEntities;
|
|
18
|
+
static getConfigElement(): Promise<import("./extra-map-editor").ExtraMapEditor>;
|
|
20
19
|
static getStubConfig(hass: HomeAssistant, entities: string[], entitiesFallback: string[]): ExtraMapCardConfig;
|
|
21
20
|
setConfig(config: ExtraMapCardConfig): void;
|
|
22
21
|
getCardSize(): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EntityConfig, ExtraMapCardConfig, HomeAssistant, LovelaceCardEditor } from '@types';
|
|
2
|
+
import { LitElement, nothing } from 'lit';
|
|
3
|
+
export interface EntitiesEditorEvent extends CustomEvent {
|
|
4
|
+
detail: {
|
|
5
|
+
entities?: EntityConfig[];
|
|
6
|
+
item?: any;
|
|
7
|
+
};
|
|
8
|
+
target: EventTarget | null;
|
|
9
|
+
}
|
|
10
|
+
export declare class ExtraMapEditor extends LitElement implements LovelaceCardEditor {
|
|
11
|
+
hass?: HomeAssistant;
|
|
12
|
+
private _config?;
|
|
13
|
+
private _configEntities?;
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
setConfig(config: ExtraMapCardConfig): void;
|
|
17
|
+
protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
18
|
+
private _computeLabelCallback;
|
|
19
|
+
private _valueChanged;
|
|
20
|
+
private _entitiesValueChanged;
|
|
21
|
+
static get styles(): import("lit").CSSResult;
|
|
22
|
+
}
|
|
23
|
+
declare global {
|
|
24
|
+
interface HTMLElementTagNameMap {
|
|
25
|
+
'extra-map-editor': ExtraMapEditor;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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.0
|
|
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.1.0","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}),m=(e,t,i)=>e.callWS({type:"lovelace/config/save",url_path:t,config:i}),f=(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 S,A;!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"}(S||(S={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(A||(A={}));var M=function(e){if(e.time_format===A.language||e.time_format===A.system){var t=e.time_format===A.language?e.language:void 0,i=(new Date).toLocaleString(t);return i.includes("AM")||i.includes("PM")}return e.time_format===A.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)},N=globalThis,$=N.ShadowRoot&&(void 0===N.ShadyCSS||N.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($&&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($)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const i of t){const t=document.createElement("style"),r=N.litNonce;void 0!==r&&t.setAttribute("nonce",r),t.textContent=i.cssText,e.appendChild(t)}},W=$?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
|
|
@@ -231,11 +231,16 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
231
231
|
* @license
|
|
232
232
|
* Copyright 2018 Google LLC
|
|
233
233
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
234
|
-
*/const gp="important",yp=" !"+gp,_p=mp(class extends fp{constructor(e){if(super(e),e.type!==dp.ATTRIBUTE||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const r=e[i];return null==r?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?i.removeProperty(e):i[e]=null);for(const e in t){const r=t[e];if(null!=r){this.ft.add(e);const t="string"==typeof r&&r.endsWith(yp);e.includes("-")||t?i.setProperty(e,t?r.slice(0,-11):r,t?gp:""):i[e]=r}}return ze}}),vp=window.loadCardHelpers?window.loadCardHelpers():void 0,bp=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():vp&&(i=vp),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var
|
|
235
|
-
<div class="maptiler-map" style="${this._computeMapStyle()}"
|
|
234
|
+
*/const gp="important",yp=" !"+gp,_p=mp(class extends fp{constructor(e){if(super(e),e.type!==dp.ATTRIBUTE||"style"!==e.name||e.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const r=e[i];return null==r?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(t)),this.render(t);for(const e of this.ft)null==t[e]&&(this.ft.delete(e),e.includes("-")?i.removeProperty(e):i[e]=null);for(const e in t){const r=t[e];if(null!=r){this.ft.add(e);const t="string"==typeof r&&r.endsWith(yp);e.includes("-")||t?i.setProperty(e,t?r.slice(0,-11):r,t?gp:""):i[e]=r}}return ze}}),vp=window.loadCardHelpers?window.loadCardHelpers():void 0,bp=()=>{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()},xp=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():vp&&(i=vp),!i||!i.createCardElement)return;if(!await i.createCardElement(t))return}};var wp,Cp,Tp,Sp,Ap,Mp,Ep,Pp;!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"}(wp||(wp={})),function(e){e.language="language",e.system="system",e.am_pm="12",e.twenty_four="24"}(Cp||(Cp={})),function(e){e.local="local",e.server="server"}(Tp||(Tp={})),function(e){e.language="language",e.system="system",e.DMY="DMY",e.MDY="MDY",e.YMD="YMD"}(Sp||(Sp={})),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"}(Ap||(Ap={}));const Ip=e=>"string"==typeof e?e:e.entity_id,kp=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}})),zp=null===(Pp=null===(Mp=Intl.DateTimeFormat)||void 0===Mp?void 0:(Ep=Mp.call(Intl)).resolvedOptions)||void 0===Pp?void 0:Pp.call(Ep).timeZone,Lp=null!=zp?zp:"UTC",Dp=(e,t)=>e===Tp.local&&zp?Lp:t,Fp=st((e=>{if(e.time_format===Cp.language||e.time_format===Cp.system){const t=e.time_format===Cp.language?e.language:void 0;return new Date("January 1, 2023 22:00:00").toLocaleString(t).includes("10")}return e.time_format===Cp.am_pm})),Rp=(e,t,i)=>Bp(t,i.time_zone).format(e),Bp=st(((e,t)=>new Intl.DateTimeFormat(e.language,{weekday:"long",hour:Fp(e)?"numeric":"2-digit",minute:"2-digit",hour12:Fp(e),timeZone:Dp(e.time_zone,t)}))),Op={dark:ti.STREETS.DARK,light:ti.STREETS.LIGHT,demo:"https://demotiles.maplibre.org/style.json"},jp={backgroundColor:{light:"#fff",dark:"#222222"},fill:{light:"#333",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"}};let Np=class extends Ke{constructor(){super(...arguments),this.autoFit=!1,this.fitZones=!1,this.zoom=14,this.themeMode="auto",this.blockMoreInfo=!1,this._mapItems=[],this._zoneItems=[],this._mapFocusZones=[],this._mapFocusItems=[],this._mapPaths=[],this._mapHelper=yh,this._loaded=!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=>this._darkMode?jp[e].dark:jp[e].light}get _darkMode(){return"dark"===this.themeMode||"auto"===this.themeMode&&Boolean(this.hass.themes.darkMode)}async firstUpdated(){await xp(this.entities),await new Promise((e=>setTimeout(e,0))),this._initMap()}render(){const e=this._renderLoadError();return ke`
|
|
235
|
+
<div class="maptiler-map" style="${this._computeMapStyle()}">
|
|
236
|
+
${e}
|
|
236
237
|
<div id="map"></div>
|
|
237
238
|
</div>
|
|
238
|
-
`}
|
|
239
|
+
`}_renderLoadError(){if(!this._error)return ke``;const{code:e,message:t}=this._error;return ke`
|
|
240
|
+
<ha-alert alert-type="${e}" id="error">
|
|
241
|
+
${t}
|
|
242
|
+
</ha-alert>
|
|
243
|
+
`}updated(e){var t,i,r,n;if(super.updated(e),!this._loaded)return;let o=!1;const a=e.get("hass");if(e.has("_loaded")||e.has("entities"))this._drawEntities(),o=!0;else if(this._loaded&&a&&this.entities)for(const e of this.entities)if(a.states[Ip(e)]!==this.hass.states[Ip(e)]){this._drawEntities(),o=!0;break}if((e.has("_loaded")||this.autoFit&&o)&&this._fitMap(),e.has("zoom")&&this._map.setZoom(this.zoom),e.has("hass")&&a){if((null===(t=a.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")&&(!a||(null===(r=a.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._zoneItems.length&&(this._zoneItems.forEach((e=>e.remove())),this._zoneItems=[],this._mapFocusZones=[]),!this.entities)return;const i=[],r=getComputedStyle(this),n=r.getPropertyValue("--accent-color"),o=r.getPropertyValue("--secondary-text-color"),a=r.getPropertyValue("--dark-primary-color"),s=this._darkMode?"dark":"light";for(const r of this.entities){const l=e.states[Ip(r)];if(!l)continue;const c="string"!=typeof r?r.name:void 0,u=null!=c?c:pt(l),{latitude:h,longitude:p,passive:d,icon:m,radius:f,entity_picture:g,gps_accuracy:y}=l.attributes;if(!h||!p)continue;const _=[p,h];if("zone"===L(l)){let e="";if(m){const t=document.createElement("ha-icon");t.setAttribute("icon",m),e=t.outerHTML}else{const t=document.createElement("span");t.innerHTML=u,e=t.outerHTML}const a=np(_,f,{steps:200,units:"meters",properties:{color:d?o:n,title:u,opacity:d?.2:.3}});i.push(a);const l=document.createElement("div");l.className=`marker ${s}`,l.innerHTML=e,l.title=u;const c=new Xr({element:l}).setLngLat(_).addTo(t);this._zoneItems.push(c),!this.fitZones||"string"!=typeof r&&!1===r.focus||this._mapFocusZones.push(a.geometry);continue}const v="string"!=typeof r&&"state"===r.label_mode?this.hass.formatEntityState(l):"string"!=typeof r&&"attribute"===r.label_mode&&void 0!==r.attribute?this.hass.formatEntityAttributeValue(l,r.attribute):null!=c?c:u.split(" ").map((e=>e[0])).join("").substring(0,3),b=document.createElement("ha-entity-marker");b.hass=this.hass,b.showIcon="string"!=typeof r&&"icon"===r.label_mode,b.entityId=Ip(r),b.entityName=v,b.entityPicture=!g||"string"!=typeof r&&r.label_mode?"":this.hass.hassUrl(g),"string"!=typeof r&&(b.entityColor=r.color),this.blockMoreInfo&&b.addEventListener("click",(e=>{e.stopImmediatePropagation(),e.preventDefault()}),!0);const x=new Xr({element:b}).setLngLat(_).addTo(t);if(this._mapItems.push(x),"string"!=typeof r&&!1===r.focus||this._mapFocusItems.push(x),y){const e=np(_,y,{steps:64,units:"meters",properties:{color:a,title:u,opacity:.5}});i.push(e)}}const l={type:"geojson",data:{type:"FeatureCollection",features:i}};t.getSource("circles")&&(t.removeSource("circles"),t.removeLayer("circles"),t.removeLayer("circles-stroke")),t.addSource("circles",l),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}})}_computePathTooltip(e,t){let i;return i=e.fullDatetime?E(t.timestamp,this.hass.locale):pp(t.timestamp)?I(t.timestamp,this.hass.locale):Rp(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 kp(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._mapFocusItems.length&&!this._mapFocusZones.length)return void this._map.setCenter([this.hass.config.longitude,this.hass.config.latitude]);let s=new xh;null===(t=this._mapFocusItems)||void 0===t||t.forEach((e=>{s.extend(e.getLngLat())})),null===(i=this._mapFocusZones)||void 0===i||i.forEach((e=>{e.coordinates[0].forEach((e=>{s.extend([e[0],e[1]])}))})),s.isEmpty()||(this._fitBounds=s,a.fitBounds(s,{padding:null!==(r=null==e?void 0:e.pad)&&void 0!==r?r:100,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():Op.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 fu(o),this._map.on("load",(async()=>{this._loaded=!0})),this._map.on("style.load",(async()=>{this._changeControlTheme(),this._drawPaths()}));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(Op.demo),this.zoom=1)}))}_centerMap(){this._fitMap({zoom:this.zoom,animate:!0})}_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):Op.dark:e?i(e):Op.light}_changeControlTheme(){const e=e=>this.getModeColor(e),t=Array.from(this.shadowRoot.querySelectorAll(".maplibregl-ctrl"));for(const i of t){const t=Array.from(i.querySelectorAll("button"));for(const i of t){const t=i;t.style.backgroundColor=e("backgroundColor"),t.style.boxShadow=e("boxShadow");const r=i.querySelector("span");if(r){const e=window.getComputedStyle(r).backgroundImage;if(e.startsWith('url("data:image/svg+xml')){const t=this.getModeColor("fill"),i=e.slice(5,-2),n=decodeURIComponent(i.split(",")[1]).replace(/fill:[^;"]*/g,`fill:${t}`).replace(/fill="[^"]*"/g,`fill="${t}"`),o=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`;r.style.backgroundImage=`url("${o}")`}}}}}_computeMapStyle(){const e=e=>this.getModeColor(e),t=e("fill"),i=e("backgroundColor"),r=e("boxShadow");return _p({"--emc-btn-bg":i,"--emc-btn-shadow":r,"--emc-btn-color":t})}static get styles(){return[Z(Gh),G`
|
|
239
244
|
:host {
|
|
240
245
|
--tooltip-color: rgba(80, 80, 80, 0.9);
|
|
241
246
|
}
|
|
@@ -243,7 +248,19 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
243
248
|
height: 100%;
|
|
244
249
|
width: 100%;
|
|
245
250
|
}
|
|
246
|
-
|
|
251
|
+
#error {
|
|
252
|
+
position: absolute;
|
|
253
|
+
bottom: 0.5rem;
|
|
254
|
+
left: 50%;
|
|
255
|
+
transform: translateX(-50%);
|
|
256
|
+
background: var(--card-background-color);
|
|
257
|
+
height: fit-content;
|
|
258
|
+
display: flex;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
z-index: 3;
|
|
261
|
+
width: max-content;
|
|
262
|
+
word-wrap: break-word;
|
|
263
|
+
}
|
|
247
264
|
#map {
|
|
248
265
|
position: absolute;
|
|
249
266
|
top: 0;
|
|
@@ -282,7 +299,13 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
282
299
|
.maplibregl-ctrl-bottom-left > .maplibregl-ctrl:not(.maplibregl-map) {
|
|
283
300
|
display: none !important;
|
|
284
301
|
}
|
|
285
|
-
|
|
302
|
+
.mapboxgl-ctrl-group button, .maplibregl-ctrl-group button {
|
|
303
|
+
width: 30px;
|
|
304
|
+
height: 30px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
`]}};e([et({attribute:!1})],Np.prototype,"hass",void 0),e([et({attribute:!1})],Np.prototype,"entities",void 0),e([et({attribute:!1})],Np.prototype,"paths",void 0),e([et({attribute:"auto-fit",type:Boolean})],Np.prototype,"autoFit",void 0),e([et({attribute:"fit-zones",type:Boolean})],Np.prototype,"fitZones",void 0),e([et({type:Number})],Np.prototype,"zoom",void 0),e([et({attribute:"theme-mode",type:String})],Np.prototype,"themeMode",void 0),e([et({type:String})],Np.prototype,"apiKey",void 0),e([et({type:Boolean})],Np.prototype,"blockMoreInfo",void 0),e([et({type:Object})],Np.prototype,"customStyles",void 0),e([tt()],Np.prototype,"_loaded",void 0),e([tt()],Np.prototype,"_error",void 0),Np=e([Ye("emc-map")],Np);var $p="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";const Vp=[{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"]}}}],Up=["STREETS","BASIC","BRIGHT","DATAVIZ","VOYAGER","BACKDROP"],qp=()=>Vp.reduce(((e,t)=>{const i=t.selector.select.options;return e.concat(i.map((e=>({value:e,label:e}))))}),[]),Zp=qp(),Gp=0,Hp=14,Wp=["auto","light","dark"],Kp=[{name:"aspect_ratio",label:"Aspect Ratio",selector:{text:{}}},{name:"default_zoom",label:"Default Zoom",default:Hp,selector:{number:{mode:"box",min:0}}},{name:"theme_mode",label:"Theme Mode",default:"auto",selector:{select:{mode:"dropdown",options:Wp.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:"block_more_info",label:"Block click action",default:!0,selector:{boolean:{}}}],Xp={name:"map_styles",type:"expandable",iconPath:$p,title:"Custom Styles",schema:[{name:"",type:"grid",schema:[{name:"light",label:"Light Style",selector:{select:{mode:"dropdown",options:Zp}}},{name:"dark",label:"Dark Style",selector:{select:{mode:"dropdown",options:Zp}}}]}]},Yp=st((e=>[{name:"",type:"expandable",iconPath:$p,title:e("ui.panel.lovelace.editor.card.map.appearance"),schema:[{name:"",type:"grid",schema:[...Kp]},Xp]}])),Jp=st((()=>[{name:"title",label:"Title",selector:{text:{type:"text"}}},{name:"api_key",label:"MapTiler API Key (required)",required:!0,selector:{text:{type:"text"}}}])),Qp=st((e=>[...Jp(),...Yp(e)]));let ed=class extends Ke{constructor(){super(...arguments),this._mapEntities=[],this._colorDict={},this._colorIndex=0,this._getHistoryPaths=st(((e,t)=>{var i,r,n,o;if(!t||null===(i=e.hours_to_show)||void 0===i||!i)return;const a=[];for(const i of Object.keys(t)){if("zone"===z(i))continue;const s=t[i];if(!(null==s?void 0:s.length))continue;const l=[];for(const e of s){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),l.push(r)}const c=null===(r=this._configEntities)||void 0===r?void 0:r.find((e=>e.entity===i)),u=null!==(n=null==c?void 0:c.name)&&void 0!==n?n:i in this.hass.states?pt(this.hass.states[i]):i;a.push({points:l,name:u,fullDatetime:(null!==(o=e.hours_to_show)&&void 0!==o?o:0)>=144,color:this._getColor(i),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 nd})),document.createElement("extra-map-editor")}static getStubConfig(e,t,i){return{type:"custom:extra-map-card",entities:mt(e,2,t,i,["device_tracker"]),theme_mode:"auto",block_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");this._config=Object.assign({},e),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:4,min_columns:6,min_rows:2}}render(){var e,t,i,r;if(!this._config)return Le;if(this._error)return ke`<ha-alert alert-type="error">
|
|
286
309
|
${this.hass.localize("ui.components.map.error")}: ${this._error.message} (${this._error.code})
|
|
287
310
|
</ha-alert>`;const n=this._config.theme_mode||(this._config.dark_mode?"dark":"auto"),o=this._config.custom_styles||{};return ke`
|
|
288
311
|
<ha-card id="card" .header=${this._config.title}>
|
|
@@ -293,7 +316,7 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
293
316
|
.paths=${this._getHistoryPaths(this._config,this._stateHistory)}
|
|
294
317
|
.autoFit=${null!==(e=this._config.auto_fit)&&void 0!==e&&e}
|
|
295
318
|
.fitZones=${null!==(t=this._config.fit_zones)&&void 0!==t&&t}
|
|
296
|
-
.zoom=${null!==(i=this._config.default_zoom)&&void 0!==i?i
|
|
319
|
+
.zoom=${null!==(i=this._config.default_zoom)&&void 0!==i?i:Hp}
|
|
297
320
|
.themeMode=${n}
|
|
298
321
|
.apiKey=${this._config.api_key}
|
|
299
322
|
.blockMoreInfo=${null!==(r=this._config.block_more_info)&&void 0!==r&&r}
|
|
@@ -301,7 +324,7 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
301
324
|
></emc-map>
|
|
302
325
|
</div>
|
|
303
326
|
</ha-card>
|
|
304
|
-
`}shouldUpdate(e){var t;if(!e.has("hass")||e.size>1)return!0;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||((null===(t=this._config)||void 0===t?void 0:t.entities)?wt(this,e):_t(this,e))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=yt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory()}_subscribeHistory(){var e,i,r;t(this.hass,"history")&&!this._subscribed&&null!==(i=null===(e=this._config)||void 0===e?void 0:e.hours_to_show)&&void 0!==i&&i&&(this._subscribed=O(this.hass,(e=>{this._subscribed&&(this._stateHistory=e)}),null!==(r=this._config.hours_to_show)&&void 0!==r?r:0,(this._configEntities||[]).map((e=>e.entity)),!1,!1,!1).catch((e=>{this._subscribed=void 0,this._error=e})))}_unsubscribeHistory(){this._subscribed&&(this._subscribed.then((e=>null==e?void 0:e())),this._subscribed=void 0)}updated(e){var t;(null===(t=this._configEntities)||void 0===t?void 0:t.length)?this._subscribed&&!e.has("_config")||(this._unsubscribeHistory(),this._subscribeHistory()):this._unsubscribeHistory(),e.has("_config")&&this._computePadding()}_computePadding(){const e=this.shadowRoot.getElementById("root"),t="panel"===this.layout||"grid"===this.layout;if(!this._config||t||!e)return;if(!this._config.aspect_ratio)return void(e.style.paddingBottom="100%");e.style.height="auto";const i=Tt(this._config.aspect_ratio);e.style.paddingBottom=i&&i.w>0&&i.h>0?`${(100*i.h/i.w).toFixed(2)}%`:e.style.paddingBottom="100%"}_getColor(e){let t=this._colorDict[e];return t||(t=ct(this._colorIndex),this._colorIndex++,this._colorDict[e]=t,t)}_getMapEntities(){return[...(this._configEntities||[]).map((e=>({entity_id:e.entity,color:this._getColor(e.entity),label_mode:e.label_mode,attribute:e.attribute,focus:e.focus,name:e.name})))]}};
|
|
327
|
+
`}shouldUpdate(e){var t;if(!e.has("hass")||e.size>1)return!0;const i=e.get("hass");return!i||!this._configEntities||(i.themes.darkMode!==this.hass.themes.darkMode||(!!e.has("_stateHistory")||((null===(t=this._config)||void 0===t?void 0:t.entities)?wt(this,e):_t(this,e))))}willUpdate(e){var t,i;super.willUpdate(e),(null===(t=this._config)||void 0===t?void 0:t.show_all)&&!(null===(i=this._config)||void 0===i?void 0:i.entities)&&this.hass&&e.has("hass")&&(this._config.entities=this._getAllEntities(),this._configEntities=yt(this._config.entities),this._mapEntities=this._getMapEntities())}connectedCallback(){var e;super.connectedCallback(),window.ExtraMapCard=this,this.hasUpdated&&(null===(e=this._configEntities)||void 0===e?void 0:e.length)&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory()}_subscribeHistory(){var e,i,r;t(this.hass,"history")&&!this._subscribed&&null!==(i=null===(e=this._config)||void 0===e?void 0:e.hours_to_show)&&void 0!==i&&i&&(this._subscribed=O(this.hass,(e=>{this._subscribed&&(this._stateHistory=e)}),null!==(r=this._config.hours_to_show)&&void 0!==r?r:0,(this._configEntities||[]).map((e=>e.entity)),!1,!1,!1).catch((e=>{this._subscribed=void 0,this._error=e})))}_unsubscribeHistory(){this._subscribed&&(this._subscribed.then((e=>null==e?void 0:e())),this._subscribed=void 0)}updated(e){var t;(null===(t=this._configEntities)||void 0===t?void 0:t.length)?this._subscribed&&!e.has("_config")||(this._unsubscribeHistory(),this._subscribeHistory()):this._unsubscribeHistory(),e.has("_config")&&this._computePadding()}_computePadding(){const e=this.shadowRoot.getElementById("root"),t="panel"===this.layout||"grid"===this.layout;if(!this._config||t||!e)return;if(!this._config.aspect_ratio)return void(e.style.paddingBottom="100%");e.style.height="auto";const i=Tt(this._config.aspect_ratio);e.style.paddingBottom=i&&i.w>0&&i.h>0?`${(100*i.h/i.w).toFixed(2)}%`:e.style.paddingBottom="100%"}_getColor(e){let t=this._colorDict[e];return t||(t=ct(this._colorIndex),this._colorIndex++,this._colorDict[e]=t,t)}_getMapEntities(){return[...(this._configEntities||[]).map((e=>({entity_id:e.entity,color:this._getColor(e.entity),label_mode:e.label_mode,attribute:e.attribute,focus:e.focus,name:e.name})))]}};function td(e){return e.map((e=>"string"==typeof e?{entity:e}:e))}ed.styles=G`
|
|
305
328
|
ha-card {
|
|
306
329
|
overflow: hidden;
|
|
307
330
|
width: 100%;
|
|
@@ -313,4 +336,71 @@ const Ye=e=>(t,i)=>{void 0!==i?i.addInitializer((()=>{customElements.define(e,t)
|
|
|
313
336
|
position: relative;
|
|
314
337
|
height: 100%;
|
|
315
338
|
}
|
|
316
|
-
`,e([et({attribute:!1})],
|
|
339
|
+
`,e([et({attribute:!1})],ed.prototype,"hass",void 0),e([et({attribute:!1})],ed.prototype,"layout",void 0),e([tt()],ed.prototype,"_config",void 0),e([tt()],ed.prototype,"_mapEntities",void 0),e([tt()],ed.prototype,"_error",void 0),e([tt()],ed.prototype,"_stateHistory",void 0),e([rt("emc-map")],ed.prototype,"_mapTiler",void 0),ed=e([Ye("extra-map-card")],ed),window.customCards=window.customCards||[],window.customCards.find((e=>"extra-map-card"===e.type))||window.customCards.push({description:"Extra Map Card using MapTiler",name:"Extra Map Card",preview:!0,type:"extra-map-card"});const id=e=>"latitude"in e.attributes&&"longitude"in e.attributes;let rd=class extends Ke{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(),bp()}disconnectedCallback(){super.disconnectedCallback()}setConfig(e){this._config=e,this._configEntities=e.entities?td(e.entities):[]}render(){if(!this.hass||!this._config)return Le;const e=Qp(this.hass.localize);return ke`
|
|
340
|
+
<ha-form
|
|
341
|
+
.hass=${this.hass}
|
|
342
|
+
.data=${this._config}
|
|
343
|
+
.schema=${e}
|
|
344
|
+
.computeLabel=${this._computeLabelCallback}
|
|
345
|
+
@value-changed=${this._valueChanged}
|
|
346
|
+
>
|
|
347
|
+
</ha-form>
|
|
348
|
+
|
|
349
|
+
<hui-entity-editor
|
|
350
|
+
.hass=${this.hass}
|
|
351
|
+
.entities=${this._configEntities}
|
|
352
|
+
.entityFilter=${id}
|
|
353
|
+
@entities-changed=${this._entitiesValueChanged}
|
|
354
|
+
></hui-entity-editor>
|
|
355
|
+
`}_valueChanged(e){e.stopPropagation(),C(this,"config-changed",{config:e.detail.value})}_entitiesValueChanged(e){e.detail&&e.detail.entities&&(this._config=Object.assign(Object.assign({},this._config),{entities:e.detail.entities}),this._configEntities=td(this._config.entities||[]),C(this,"config-changed",{config:this._config}))}static get styles(){return G`
|
|
356
|
+
.card-config {
|
|
357
|
+
/* Cancels overlapping Margins for HAForm + Card Config options */
|
|
358
|
+
overflow: auto;
|
|
359
|
+
}
|
|
360
|
+
ha-switch {
|
|
361
|
+
padding: 16px 6px;
|
|
362
|
+
}
|
|
363
|
+
.side-by-side {
|
|
364
|
+
display: flex;
|
|
365
|
+
align-items: flex-end;
|
|
366
|
+
}
|
|
367
|
+
.side-by-side > * {
|
|
368
|
+
flex: 1;
|
|
369
|
+
padding-right: 8px;
|
|
370
|
+
padding-inline-end: 8px;
|
|
371
|
+
padding-inline-start: initial;
|
|
372
|
+
}
|
|
373
|
+
.side-by-side > *:last-child {
|
|
374
|
+
flex: 1;
|
|
375
|
+
padding-right: 0;
|
|
376
|
+
padding-inline-end: 0;
|
|
377
|
+
padding-inline-start: initial;
|
|
378
|
+
}
|
|
379
|
+
.suffix {
|
|
380
|
+
margin: 0 8px;
|
|
381
|
+
}
|
|
382
|
+
hui-action-editor,
|
|
383
|
+
ha-select,
|
|
384
|
+
ha-textfield,
|
|
385
|
+
ha-icon-picker {
|
|
386
|
+
margin-top: 8px;
|
|
387
|
+
display: block;
|
|
388
|
+
}
|
|
389
|
+
ha-expansion-panel {
|
|
390
|
+
display: block;
|
|
391
|
+
--expansion-panel-content-padding: 0;
|
|
392
|
+
border-radius: 6px;
|
|
393
|
+
--ha-card-border-radius: 6px;
|
|
394
|
+
}
|
|
395
|
+
ha-expansion-panel .content {
|
|
396
|
+
padding: 12px;
|
|
397
|
+
}
|
|
398
|
+
ha-expansion-panel > *[slot="header"] {
|
|
399
|
+
margin: 0;
|
|
400
|
+
font-size: inherit;
|
|
401
|
+
font-weight: inherit;
|
|
402
|
+
}
|
|
403
|
+
ha-expansion-panel ha-svg-icon {
|
|
404
|
+
color: var(--secondary-text-color);
|
|
405
|
+
}
|
|
406
|
+
`}};e([et({attribute:!1})],rd.prototype,"hass",void 0),e([tt()],rd.prototype,"_config",void 0),e([tt()],rd.prototype,"_configEntities",void 0),rd=e([Ye("extra-map-editor")],rd);var nd=Object.freeze({__proto__:null,get ExtraMapEditor(){return rd}});export{lt as COLORS,Up as DARK_AVAILABLE_STYLES,Gp as DEFAULT_HOURS_TO_SHOW,Hp as DEFAULT_ZOOM,Np as EmcMap,ed as ExtraMapCard,Lp as LOCAL_TIME_ZONE,Zp as STYLE_OPTIONS,Vp as STYLE_SCHEMA,Jp as baseMapConfigSchema,ut as computeObjectId,pt as computeStateName,ht as computeStateNameFromEntityAttributes,b as createResource,f as deleteConfig,w as deleteResource,_ as ensureBadgeConfig,R as entityIdHistoryNeedsAttributes,d as fetchConfig,B as fetchDateWS,v as fetchResources,n as findCardIndex,mt as findEntities,c as findLovelaceCards,l as findLovelaceContainer,C as fireEvent,Rp as formatTimeWeekday,kp as getAddress,ct as getColorByIndex,Ip as getEntityId,i as getLovelace,s as getLovelaceContainerPath,_t as hasConfigChanged,wt as hasConfigOrEntitiesChanged,xt as hasConfigOrEntityChanged,id as hasLocation,t as isComponentLoaded,p as isStrategyDashboard,y as isStrategySection,g as isStrategyView,gt as isValidEntityId,Qp as mapConfigSchema,o as parseLovelaceCardPath,a as parseLovelaceContainerPath,yt as processConfigEntities,td as processEditorEntities,Dp as resolveTimeZone,m as saveConfig,Yp as singleMapConfingSchema,j as subscribeHistory,O as subscribeHistoryStatesTimeWindow,T as subscribeRenderTemplate,h as updateLovelaceCards,u as updateLovelaceContainer,x as updateResource,Fp as useAmPm};
|
package/dist/types/config.d.ts
CHANGED
|
@@ -57,9 +57,8 @@ export interface ExtraMapCardConfig extends LovelaceCardConfig {
|
|
|
57
57
|
default_zoom?: number;
|
|
58
58
|
hours_to_show?: number;
|
|
59
59
|
theme_mode?: ThemeMode;
|
|
60
|
-
light_theme?: string;
|
|
61
|
-
dark_theme?: string;
|
|
62
60
|
show_all?: boolean;
|
|
63
61
|
block_more_info?: boolean;
|
|
64
62
|
custom_styles?: CustomStyles;
|
|
63
|
+
history_period?: 'today' | 'yesterday';
|
|
65
64
|
}
|