Format return dates in the Home Assistant timezone

This commit is contained in:
2026-09-20 12:24:36 -04:00
parent f42fc0fc65
commit 745d18c041
2 changed files with 172 additions and 104 deletions
+133 -101
View File
@@ -1,4 +1,4 @@
const z = globalThis, F = z.ShadowRoot && (z.ShadyCSS === void 0 || z.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, j = /* @__PURE__ */ Symbol(), K = /* @__PURE__ */ new WeakMap();
const T = globalThis, L = T.ShadowRoot && (T.ShadyCSS === void 0 || T.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, j = /* @__PURE__ */ Symbol(), K = /* @__PURE__ */ new WeakMap();
let ct = class {
constructor(t, e, n) {
if (this._$cssResult$ = !0, n !== j) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
@@ -7,7 +7,7 @@ let ct = class {
get styleSheet() {
let t = this.o;
const e = this.t;
if (F && t === void 0) {
if (L && t === void 0) {
const n = e !== void 0 && e.length === 1;
n && (t = K.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), n && K.set(e, t));
}
@@ -25,17 +25,17 @@ const $ = (s) => new ct(typeof s == "string" ? s : s + "", void 0, j), _t = (s,
})(i) + s[r + 1], s[0]);
return new ct(e, s, j);
}, $t = (s, t) => {
if (F) s.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
if (L) s.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
else for (const e of t) {
const n = document.createElement("style"), i = z.litNonce;
const n = document.createElement("style"), i = T.litNonce;
i !== void 0 && n.setAttribute("nonce", i), n.textContent = e.cssText, s.appendChild(n);
}
}, J = F ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
}, J = L ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
let e = "";
for (const n of t.cssRules) e += n.cssText;
return $(e);
})(s) : s;
const { is: vt, defineProperty: qt, getOwnPropertyDescriptor: xt, getOwnPropertyNames: wt, getOwnPropertySymbols: At, getPrototypeOf: kt } = Object, T = globalThis, G = T.trustedTypes, Et = G ? G.emptyScript : "", Ct = T.reactiveElementPolyfillSupport, E = (s, t) => s, I = { toAttribute(s, t) {
const { is: vt, defineProperty: qt, getOwnPropertyDescriptor: xt, getOwnPropertyNames: wt, getOwnPropertySymbols: At, getPrototypeOf: kt } = Object, M = globalThis, G = M.trustedTypes, Et = G ? G.emptyScript : "", Ct = M.reactiveElementPolyfillSupport, E = (s, t) => s, F = { toAttribute(s, t) {
switch (t) {
case Boolean:
s = s ? Et : null;
@@ -63,8 +63,8 @@ const { is: vt, defineProperty: qt, getOwnPropertyDescriptor: xt, getOwnProperty
}
}
return e;
} }, ht = (s, t) => !vt(s, t), X = { attribute: !0, type: String, converter: I, reflect: !1, useDefault: !1, hasChanged: ht };
Symbol.metadata ??= /* @__PURE__ */ Symbol("metadata"), T.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
} }, ht = (s, t) => !vt(s, t), X = { attribute: !0, type: String, converter: F, reflect: !1, useDefault: !1, hasChanged: ht };
Symbol.metadata ??= /* @__PURE__ */ Symbol("metadata"), M.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
let x = class extends HTMLElement {
static addInitializer(t) {
this._$Ei(), (this.l ??= []).push(t);
@@ -85,8 +85,8 @@ let x = class extends HTMLElement {
this[e] = a;
} };
return { get: i, set(a) {
const p = i?.call(this);
r?.call(this, a), this.requestUpdate(t, p, n);
const l = i?.call(this);
r?.call(this, a), this.requestUpdate(t, l, n);
}, configurable: !0, enumerable: !0 };
}
static getPropertyOptions(t) {
@@ -162,17 +162,17 @@ let x = class extends HTMLElement {
_$ET(t, e) {
const n = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, n);
if (i !== void 0 && n.reflect === !0) {
const r = (n.converter?.toAttribute !== void 0 ? n.converter : I).toAttribute(e, n.type);
const r = (n.converter?.toAttribute !== void 0 ? n.converter : F).toAttribute(e, n.type);
this._$Em = t, r == null ? this.removeAttribute(i) : this.setAttribute(i, r), this._$Em = null;
}
}
_$AK(t, e) {
const n = this.constructor, i = n._$Eh.get(t);
if (i !== void 0 && this._$Em !== i) {
const r = n.getPropertyOptions(i), a = typeof r.converter == "function" ? { fromAttribute: r.converter } : r.converter?.fromAttribute !== void 0 ? r.converter : I;
const r = n.getPropertyOptions(i), a = typeof r.converter == "function" ? { fromAttribute: r.converter } : r.converter?.fromAttribute !== void 0 ? r.converter : F;
this._$Em = i;
const p = a.fromAttribute(e, r.type);
this[i] = p ?? this._$Ej?.get(i) ?? p, this._$Em = null;
const l = a.fromAttribute(e, r.type);
this[i] = l ?? this._$Ej?.get(i) ?? l, this._$Em = null;
}
}
requestUpdate(t, e, n, i = !1, r) {
@@ -208,8 +208,8 @@ let x = class extends HTMLElement {
}
const n = this.constructor.elementProperties;
if (n.size > 0) for (const [i, r] of n) {
const { wrapped: a } = r, p = this[i];
a !== !0 || this._$AL.has(i) || p === void 0 || this.C(i, void 0, r, p);
const { wrapped: a } = r, l = this[i];
a !== !0 || this._$AL.has(i) || l === void 0 || this.C(i, void 0, r, l);
}
}
let t = !1;
@@ -246,23 +246,23 @@ let x = class extends HTMLElement {
firstUpdated(t) {
}
};
x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[E("elementProperties")] = /* @__PURE__ */ new Map(), x[E("finalized")] = /* @__PURE__ */ new Map(), Ct?.({ ReactiveElement: x }), (T.reactiveElementVersions ??= []).push("2.1.2");
const B = globalThis, Y = (s) => s, O = B.trustedTypes, tt = O ? O.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, ut = "$lit$", y = `lit$${Math.random().toFixed(9).slice(2)}$`, ft = "?" + y, St = `<${ft}>`, q = document, C = () => q.createComment(""), S = (s) => s === null || typeof s != "object" && typeof s != "function", Q = Array.isArray, Nt = (s) => Q(s) || typeof s?.[Symbol.iterator] == "function", H = `[
\f\r]`, k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, et = /-->/g, nt = />/g, b = RegExp(`>|${H}(?:([^\\s"'>=/]+)(${H}*=${H}*(?:[^
x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[E("elementProperties")] = /* @__PURE__ */ new Map(), x[E("finalized")] = /* @__PURE__ */ new Map(), Ct?.({ ReactiveElement: x }), (M.reactiveElementVersions ??= []).push("2.1.2");
const B = globalThis, Y = (s) => s, z = B.trustedTypes, tt = z ? z.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, ut = "$lit$", y = `lit$${Math.random().toFixed(9).slice(2)}$`, ft = "?" + y, St = `<${ft}>`, q = document, C = () => q.createComment(""), S = (s) => s === null || typeof s != "object" && typeof s != "function", Q = Array.isArray, Nt = (s) => Q(s) || typeof s?.[Symbol.iterator] == "function", D = `[
\f\r]`, k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, et = /-->/g, nt = />/g, b = RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g"), st = /'/g, it = /"/g, gt = /^(?:script|style|textarea|title)$/i, Pt = (s) => (t, ...e) => ({ _$litType$: s, strings: t, values: e }), g = Pt(1), w = /* @__PURE__ */ Symbol.for("lit-noChange"), c = /* @__PURE__ */ Symbol.for("lit-nothing"), rt = /* @__PURE__ */ new WeakMap(), _ = q.createTreeWalker(q, 129);
function mt(s, t) {
if (!Q(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
return tt !== void 0 ? tt.createHTML(t) : t;
}
const zt = (s, t) => {
const Tt = (s, t) => {
const e = s.length - 1, n = [];
let i, r = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", a = k;
for (let p = 0; p < e; p++) {
const o = s[p];
let d, h, l = -1, f = 0;
for (; f < o.length && (a.lastIndex = f, h = a.exec(o), h !== null); ) f = a.lastIndex, a === k ? h[1] === "!--" ? a = et : h[1] !== void 0 ? a = nt : h[2] !== void 0 ? (gt.test(h[2]) && (i = RegExp("</" + h[2], "g")), a = b) : h[3] !== void 0 && (a = b) : a === b ? h[0] === ">" ? (a = i ?? k, l = -1) : h[1] === void 0 ? l = -2 : (l = a.lastIndex - h[2].length, d = h[1], a = h[3] === void 0 ? b : h[3] === '"' ? it : st) : a === it || a === st ? a = b : a === et || a === nt ? a = k : (a = b, i = void 0);
const u = a === b && s[p + 1].startsWith("/>") ? " " : "";
r += a === k ? o + St : l >= 0 ? (n.push(d), o.slice(0, l) + ut + o.slice(l) + y + u) : o + y + (l === -2 ? p : u);
for (let l = 0; l < e; l++) {
const o = s[l];
let d, h, p = -1, f = 0;
for (; f < o.length && (a.lastIndex = f, h = a.exec(o), h !== null); ) f = a.lastIndex, a === k ? h[1] === "!--" ? a = et : h[1] !== void 0 ? a = nt : h[2] !== void 0 ? (gt.test(h[2]) && (i = RegExp("</" + h[2], "g")), a = b) : h[3] !== void 0 && (a = b) : a === b ? h[0] === ">" ? (a = i ?? k, p = -1) : h[1] === void 0 ? p = -2 : (p = a.lastIndex - h[2].length, d = h[1], a = h[3] === void 0 ? b : h[3] === '"' ? it : st) : a === it || a === st ? a = b : a === et || a === nt ? a = k : (a = b, i = void 0);
const u = a === b && s[l + 1].startsWith("/>") ? " " : "";
r += a === k ? o + St : p >= 0 ? (n.push(d), o.slice(0, p) + ut + o.slice(p) + y + u) : o + y + (p === -2 ? l : u);
}
return [mt(s, r + (s[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), n];
};
@@ -271,29 +271,29 @@ class N {
let i;
this.parts = [];
let r = 0, a = 0;
const p = t.length - 1, o = this.parts, [d, h] = zt(t, e);
const l = t.length - 1, o = this.parts, [d, h] = Tt(t, e);
if (this.el = N.createElement(d, n), _.currentNode = this.el.content, e === 2 || e === 3) {
const l = this.el.content.firstChild;
l.replaceWith(...l.childNodes);
const p = this.el.content.firstChild;
p.replaceWith(...p.childNodes);
}
for (; (i = _.nextNode()) !== null && o.length < p; ) {
for (; (i = _.nextNode()) !== null && o.length < l; ) {
if (i.nodeType === 1) {
if (i.hasAttributes()) for (const l of i.getAttributeNames()) if (l.endsWith(ut)) {
const f = h[a++], u = i.getAttribute(l).split(y), m = /([.?@])?(.*)/.exec(f);
o.push({ type: 1, index: r, name: m[2], strings: u, ctor: m[1] === "." ? Tt : m[1] === "?" ? Mt : m[1] === "@" ? Ut : M }), i.removeAttribute(l);
} else l.startsWith(y) && (o.push({ type: 6, index: r }), i.removeAttribute(l));
if (i.hasAttributes()) for (const p of i.getAttributeNames()) if (p.endsWith(ut)) {
const f = h[a++], u = i.getAttribute(p).split(y), m = /([.?@])?(.*)/.exec(f);
o.push({ type: 1, index: r, name: m[2], strings: u, ctor: m[1] === "." ? Ot : m[1] === "?" ? Mt : m[1] === "@" ? Ut : U }), i.removeAttribute(p);
} else p.startsWith(y) && (o.push({ type: 6, index: r }), i.removeAttribute(p));
if (gt.test(i.tagName)) {
const l = i.textContent.split(y), f = l.length - 1;
const p = i.textContent.split(y), f = p.length - 1;
if (f > 0) {
i.textContent = O ? O.emptyScript : "";
for (let u = 0; u < f; u++) i.append(l[u], C()), _.nextNode(), o.push({ type: 2, index: ++r });
i.append(l[f], C());
i.textContent = z ? z.emptyScript : "";
for (let u = 0; u < f; u++) i.append(p[u], C()), _.nextNode(), o.push({ type: 2, index: ++r });
i.append(p[f], C());
}
}
} else if (i.nodeType === 8) if (i.data === ft) o.push({ type: 2, index: r });
else {
let l = -1;
for (; (l = i.data.indexOf(y, l + 1)) !== -1; ) o.push({ type: 7, index: r }), l += y.length - 1;
let p = -1;
for (; (p = i.data.indexOf(y, p + 1)) !== -1; ) o.push({ type: 7, index: r }), p += y.length - 1;
}
r++;
}
@@ -309,7 +309,7 @@ function A(s, t, e = s, n) {
const r = S(t) ? void 0 : t._$litDirective$;
return i?.constructor !== r && (i?._$AO?.(!1), r === void 0 ? i = void 0 : (i = new r(s), i._$AT(s, e, n)), n !== void 0 ? (e._$Co ??= [])[n] = i : e._$Cl = i), i !== void 0 && (t = A(s, i._$AS(s, t.values), i, n)), t;
}
class Ot {
class zt {
constructor(t, e) {
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
}
@@ -322,11 +322,11 @@ class Ot {
u(t) {
const { el: { content: e }, parts: n } = this._$AD, i = (t?.creationScope ?? q).importNode(e, !0);
_.currentNode = i;
let r = _.nextNode(), a = 0, p = 0, o = n[0];
let r = _.nextNode(), a = 0, l = 0, o = n[0];
for (; o !== void 0; ) {
if (a === o.index) {
let d;
o.type === 2 ? d = new P(r, r.nextSibling, this, t) : o.type === 1 ? d = new o.ctor(r, o.name, o.strings, this, t) : o.type === 6 && (d = new Ht(r, this, t)), this._$AV.push(d), o = n[++p];
o.type === 2 ? d = new P(r, r.nextSibling, this, t) : o.type === 1 ? d = new o.ctor(r, o.name, o.strings, this, t) : o.type === 6 && (d = new Ht(r, this, t)), this._$AV.push(d), o = n[++l];
}
a !== o?.index && (r = _.nextNode(), a++);
}
@@ -371,7 +371,7 @@ class P {
const { values: e, _$litType$: n } = t, i = typeof n == "number" ? this._$AC(t) : (n.el === void 0 && (n.el = N.createElement(mt(n.h, n.h[0]), this.options)), n);
if (this._$AH?._$AD === i) this._$AH.p(e);
else {
const r = new Ot(i, this), a = r.u(this.options);
const r = new zt(i, this), a = r.u(this.options);
r.p(e), this.T(a), this._$AH = r;
}
}
@@ -396,7 +396,7 @@ class P {
this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
}
}
class M {
class U {
get tagName() {
return this.element.tagName;
}
@@ -411,9 +411,9 @@ class M {
let a = !1;
if (r === void 0) t = A(this, t, e, 0), a = !S(t) || t !== this._$AH && t !== w, a && (this._$AH = t);
else {
const p = t;
const l = t;
let o, d;
for (t = r[0], o = 0; o < r.length - 1; o++) d = A(this, p[n + o], e, o), d === w && (d = this._$AH[o]), a ||= !S(d) || d !== this._$AH[o], d === c ? t = c : t !== c && (t += (d ?? "") + r[o + 1]), this._$AH[o] = d;
for (t = r[0], o = 0; o < r.length - 1; o++) d = A(this, l[n + o], e, o), d === w && (d = this._$AH[o]), a ||= !S(d) || d !== this._$AH[o], d === c ? t = c : t !== c && (t += (d ?? "") + r[o + 1]), this._$AH[o] = d;
}
a && !i && this.j(t);
}
@@ -421,7 +421,7 @@ class M {
t === c ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
}
}
class Tt extends M {
class Ot extends U {
constructor() {
super(...arguments), this.type = 3;
}
@@ -429,7 +429,7 @@ class Tt extends M {
this.element[this.name] = t === c ? void 0 : t;
}
}
class Mt extends M {
class Mt extends U {
constructor() {
super(...arguments), this.type = 4;
}
@@ -437,7 +437,7 @@ class Mt extends M {
this.element.toggleAttribute(this.name, !!t && t !== c);
}
}
class Ut extends M {
class Ut extends U {
constructor(t, e, n, i, r) {
super(t, e, n, i, r), this.type = 5;
}
@@ -504,7 +504,7 @@ function V(s) {
window.customCards = window.customCards ?? [], window.customCards.push(s);
}
const at = /* @__PURE__ */ new Map();
function L(s, t) {
function O(s, t) {
const e = `${s ?? "local"}|${JSON.stringify(t)}`, n = at.get(e);
if (n)
return n;
@@ -519,18 +519,18 @@ function L(s, t) {
}
return at.set(e, i), i;
}
function Lt(s) {
function Ft(s) {
const t = s?.config;
if (!t || typeof t != "object")
return;
const e = t.time_zone;
return typeof e == "string" && e.trim() ? e.trim() : void 0;
}
function D(s, t) {
return `${L(t, { weekday: "long" }).format(s)}, ${L(t, { month: "short", day: "numeric" }).format(s)}`;
function R(s, t) {
return `${O(t, { weekday: "long" }).format(s)}, ${O(t, { month: "short", day: "numeric" }).format(s)}`;
}
function Ft(s, t) {
return L(t, {
function Lt(s, t) {
return O(t, {
hour: "numeric",
minute: "2-digit",
hour12: !0
@@ -572,7 +572,7 @@ const jt = {
function ot(s) {
return typeof s == "string" ? s.trim() : "";
}
function R(s, t) {
function I(s, t) {
if (s == null || s === "")
return t;
const e = typeof s == "number" ? s : Number(s);
@@ -587,26 +587,55 @@ function pt(s) {
function Qt(s) {
return s.split(/[-_]+/).filter(Boolean).map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" ");
}
function Wt(s) {
function Wt(s, t) {
const e = O(t, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hourCycle: "h23"
}).formatToParts(new Date(s)), n = (r) => {
const a = e.find((l) => l.type === r);
return a ? Number(a.value) : Number.NaN;
}, i = Date.UTC(
n("year"),
n("month") - 1,
n("day"),
n("hour"),
n("minute"),
n("second")
);
return Number.isFinite(i) ? i - s : 0;
}
function Vt(s, t) {
if (typeof s != "string")
return null;
const t = s.split("-");
if (t.length !== 3)
const e = s.split("-");
if (e.length !== 3)
return null;
const [e, n, i] = t.map((a) => Number(a));
if (!e || !n || !i)
const [n, i, r] = e.map((o) => Number(o));
if (!n || !i || !r)
return null;
const r = new Date(e, n - 1, i);
return Number.isNaN(r.getTime()) ? null : r;
if (!t) {
const o = new Date(n, i - 1, r);
return Number.isNaN(o.getTime()) ? null : o;
}
let a = Date.UTC(n, i - 1, r);
for (let o = 0; o < 2; o += 1)
a -= Wt(a, t);
const l = new Date(a);
return Number.isNaN(l.getTime()) ? null : l;
}
function Vt(s) {
function Zt(s) {
const t = jt[s];
return t || s.charAt(0).toUpperCase() + s.slice(1);
}
function Zt(s, t) {
function Kt(s, t) {
return Bt[s] ?? t;
}
const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Kt = "polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%)", Jt = _t`
const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Jt = "polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%)", Gt = _t`
* {
box-sizing: border-box;
}
@@ -678,7 +707,7 @@ const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Kt = "polygon(50%
justify-content: center;
width: 34px;
height: 34px;
clip-path: ${$(Kt)};
clip-path: ${$(Jt)};
background: var(--nq-brand-gradient);
}
@@ -945,7 +974,7 @@ const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Kt = "polygon(50%
font-weight: 800;
line-height: 1;
}
`, Gt = g`<svg
`, Xt = g`<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
@@ -956,7 +985,7 @@ const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Kt = "polygon(50%
>
<circle cx="12" cy="12" r="10"></circle>
<path d="m9 12 2 2 4-4"></path>
</svg>`, Xt = g`<svg
</svg>`, Yt = g`<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
@@ -967,7 +996,7 @@ const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Kt = "polygon(50%
>
<path d="M3.5 21 12 3.5 20.5 21"></path>
<path d="M9 21l3-8 3 8"></path>
</svg>`, Yt = g`<svg
</svg>`, te = g`<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
@@ -983,13 +1012,13 @@ const dt = "polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%)", Kt = "polygon(50%
<path d="M15.947 12.65a4 4 0 0 0-5.925-4.128"></path>
<path d="M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z"></path>
</svg>`;
class te extends v {
class ee extends v {
static properties = {
hass: { attribute: !1 },
_config: { state: !0 },
_now: { state: !0 }
};
static styles = [$(yt), Jt];
static styles = [$(yt), Gt];
hass;
_config;
_now = /* @__PURE__ */ new Date();
@@ -1026,7 +1055,7 @@ class te extends v {
</span>
<span class="rule"></span>
</div>
<p class="kicker">The Party · ${D(this._now, this._timeZone())}</p>
<p class="kicker">The Party · ${R(this._now, this._timeZone())}</p>
<div class="plates">
${this._plates().map((t) => this._renderPlate(t))}
</div>
@@ -1037,7 +1066,7 @@ class te extends v {
`;
}
_timeZone() {
return Lt(this.hass);
return Ft(this.hass);
}
_state(t) {
const n = this.hass?.states?.[t];
@@ -1061,27 +1090,30 @@ class te extends v {
`sensor.nestquest_${t}_completion_pct_today`
), r = this._state(
`binary_sensor.nestquest_${t}_present_today`
), a = e?.attributes ?? {}, p = pt(R(e?.state, 0)), o = pt(R(n?.state, 0)), d = i ? R(i.state, Number.NaN) : Number.NaN, h = Number.isFinite(d) ? lt(d) : p > 0 ? lt(o / p * 100) : 0;
let l = !0;
), a = e?.attributes ?? {}, l = pt(I(e?.state, 0)), o = pt(I(n?.state, 0)), d = i ? I(i.state, Number.NaN) : Number.NaN, h = Number.isFinite(d) ? lt(d) : l > 0 ? lt(o / l * 100) : 0;
let p = !0;
const f = a.present;
typeof f == "boolean" ? l = f : r && (l = String(r.state ?? "").trim().toLowerCase() === "on");
typeof f == "boolean" ? p = f : r && (p = String(r.state ?? "").trim().toLowerCase() === "on");
let u = "";
const m = a.child_name;
if (typeof m == "string" && m.trim())
u = m.trim();
else {
const U = r?.attributes?.child_name;
typeof U == "string" && U.trim() && (u = U.trim());
const H = r?.attributes?.child_name;
typeof H == "string" && H.trim() && (u = H.trim());
}
u || (u = Qt(t));
const Z = Wt(r?.attributes?.next_present), bt = Z ? `Returns ${D(Z, this._timeZone())}` : null;
const Z = Vt(
r?.attributes?.next_present,
this._timeZone()
), bt = Z ? `Returns ${R(Z, this._timeZone())}` : null;
return {
slug: t,
name: u,
initial: (u.charAt(0) || "?").toUpperCase(),
present: l,
present: p,
completed: o,
due: p,
due: l,
pct: h,
returns: bt
};
@@ -1101,7 +1133,7 @@ class te extends v {
</span>
<span class="name">${t.name}</span>
<span class="pill">
${Gt}
${Xt}
<span>Home today</span>
</span>
<span class="progress-line">
@@ -1120,7 +1152,7 @@ class te extends v {
</span>
<span class="name">${t.name}</span>
<span class="pill away">
${Xt}
${Yt}
<span>On travels</span>
</span>
<span class="progress-line">${t.returns ?? "Returns —"}</span>
@@ -1144,9 +1176,9 @@ class te extends v {
return null;
const i = e.attributes ?? {};
let r = null, a = null;
const p = i.forecast;
if (Array.isArray(p) && p.length > 0) {
const o = p[0];
const l = i.forecast;
if (Array.isArray(l) && l.length > 0) {
const o = l[0];
if (o && typeof o == "object") {
const d = o;
r = this._optionalNumber(d.temperature), a = this._optionalNumber(d.templow);
@@ -1170,15 +1202,15 @@ class te extends v {
if (!t)
return g`
<div class="dock">
<span class="date">${D(this._now, this._timeZone())}</span>
<span class="date">${R(this._now, this._timeZone())}</span>
<span class="divider"></span>
<span class="clock">${Ft(this._now, this._timeZone())}</span>
<span class="clock">${Lt(this._now, this._timeZone())}</span>
</div>
`;
const e = Vt(t.condition), n = Zt(t.condition, e), i = t.temperature === null ? c : g`<span class="temp">${Math.round(t.temperature)}°</span>`, r = t.high === null || t.low === null ? null : `${Math.round(t.high)}° / ${Math.round(t.low)}°`;
const e = Zt(t.condition), n = Kt(t.condition, e), i = t.temperature === null ? c : g`<span class="temp">${Math.round(t.temperature)}°</span>`, r = t.high === null || t.low === null ? null : `${Math.round(t.high)}° / ${Math.round(t.low)}°`;
return g`
<div class="dock">
${Yt}
${te}
${i}
<span class="divider"></span>
<span class="condition">
@@ -1190,13 +1222,13 @@ class te extends v {
`;
}
}
customElements.define("nestquest-party-board-card", te);
customElements.define("nestquest-party-board-card", ee);
V({
type: "nestquest-party-board-card",
name: "NestQuest Party Board",
description: "Kids' attract screen for present and away adventurers."
});
class ee extends v {
class ne extends v {
static properties = {
hass: { attribute: !1 },
_config: { state: !0 }
@@ -1216,19 +1248,19 @@ class ee extends v {
return g`<div>NestQuest Quest Log</div>`;
}
}
customElements.define("nestquest-quest-log-card", ee);
customElements.define("nestquest-quest-log-card", ne);
V({
type: "nestquest-quest-log-card",
name: "NestQuest Quest Log",
description: "One child's daily quests, grouped by window."
});
const ne = ":host{--nq-brand-blue: #3B3AB8;--nq-brand-purple: #A035CC;--nq-brand-gradient: linear-gradient(135deg, var(--nq-brand-blue), var(--nq-brand-purple));--nq-brand-gradient-h: linear-gradient(90deg, var(--nq-brand-blue), var(--nq-brand-purple));--nq-a-page: #F4F4F6;--nq-a-surface: #FFFFFF;--nq-a-surface-subtle: #FAFAFA;--nq-a-selected: #EBEBF8;--nq-a-border: #E4E4EA;--nq-a-divider: #EDEDF1;--nq-a-ink: #18181D;--nq-a-ink-secondary: #52525E;--nq-a-ink-tertiary: #70707E;--nq-a-success: #15803D;--nq-a-danger: #DC2626;--nq-a-danger-strong: #B91C1C;--nq-a-danger-bg: #FEE2E2;--nq-a-warning-ink: #92400E;--nq-a-warning-ink-2: #78350F;--nq-a-warning-bg: #FEF3C7;--nq-a-warning-border: rgba(217,119,6,.35);--nq-a-info-bg: #DBEAFE;--nq-a-info-ink: #1E3A8A;--nq-a-info-icon: #1D4ED8;--nq-a-reversal: #7D28A0;--nq-a-font: Nunito, system-ui, sans-serif;--nq-a-size-screen: 24px;--nq-a-size-hero: 32px;--nq-a-size-card-title: 19px;--nq-a-size-stat: 22px;--nq-a-size-row: 13.5px;--nq-a-size-meta: 11px;--nq-a-size-label: 10px;--nq-a-track-label: .1em;--nq-a-density-page-pad: 14px 16px 92px;--nq-a-density-gap: 10px;--nq-a-density-card-pad: 13px;--nq-a-density-row-pad: 11px 13px;--nq-a-density-radius: 8px;--nq-a-density-shadow: none;--nq-a-tabbar-height: 70px;--nq-a-tap-min: 44px;--nq-a-radius-pill: 9999px;--nq-a-radius-sheet: 20px 20px 0 0;--nq-a-sheet-shadow: 0 -8px 28px rgba(9,9,11,.18);--nq-a-progress-height: 6px;--nq-ease-out: cubic-bezier(0, 0, .2, 1);--nq-dur-micro: .12s;--nq-dur-base: .2s;--nq-dur-modal: .35s}";
class se extends v {
const se = ":host{--nq-brand-blue: #3B3AB8;--nq-brand-purple: #A035CC;--nq-brand-gradient: linear-gradient(135deg, var(--nq-brand-blue), var(--nq-brand-purple));--nq-brand-gradient-h: linear-gradient(90deg, var(--nq-brand-blue), var(--nq-brand-purple));--nq-a-page: #F4F4F6;--nq-a-surface: #FFFFFF;--nq-a-surface-subtle: #FAFAFA;--nq-a-selected: #EBEBF8;--nq-a-border: #E4E4EA;--nq-a-divider: #EDEDF1;--nq-a-ink: #18181D;--nq-a-ink-secondary: #52525E;--nq-a-ink-tertiary: #70707E;--nq-a-success: #15803D;--nq-a-danger: #DC2626;--nq-a-danger-strong: #B91C1C;--nq-a-danger-bg: #FEE2E2;--nq-a-warning-ink: #92400E;--nq-a-warning-ink-2: #78350F;--nq-a-warning-bg: #FEF3C7;--nq-a-warning-border: rgba(217,119,6,.35);--nq-a-info-bg: #DBEAFE;--nq-a-info-ink: #1E3A8A;--nq-a-info-icon: #1D4ED8;--nq-a-reversal: #7D28A0;--nq-a-font: Nunito, system-ui, sans-serif;--nq-a-size-screen: 24px;--nq-a-size-hero: 32px;--nq-a-size-card-title: 19px;--nq-a-size-stat: 22px;--nq-a-size-row: 13.5px;--nq-a-size-meta: 11px;--nq-a-size-label: 10px;--nq-a-track-label: .1em;--nq-a-density-page-pad: 14px 16px 92px;--nq-a-density-gap: 10px;--nq-a-density-card-pad: 13px;--nq-a-density-row-pad: 11px 13px;--nq-a-density-radius: 8px;--nq-a-density-shadow: none;--nq-a-tabbar-height: 70px;--nq-a-tap-min: 44px;--nq-a-radius-pill: 9999px;--nq-a-radius-sheet: 20px 20px 0 0;--nq-a-sheet-shadow: 0 -8px 28px rgba(9,9,11,.18);--nq-a-progress-height: 6px;--nq-ease-out: cubic-bezier(0, 0, .2, 1);--nq-dur-micro: .12s;--nq-dur-base: .2s;--nq-dur-modal: .35s}";
class ie extends v {
static properties = {
hass: { attribute: !1 },
_config: { state: !0 }
};
static styles = [$(ne)];
static styles = [$(se)];
hass;
_config;
setConfig(t) {
@@ -1243,14 +1275,14 @@ class se extends v {
return g`<div>NestQuest Admin</div>`;
}
}
customElements.define("nestquest-admin-card", se);
customElements.define("nestquest-admin-card", ie);
V({
type: "nestquest-admin-card",
name: "NestQuest Admin",
description: "Parent phone view for today, tasks, schedule, and history."
});
const ie = "/nestquest-static/nestquest-fonts.css";
const re = "/nestquest-static/nestquest-fonts.css";
if (!document.querySelector('link[data-nq-fonts=""]')) {
const s = document.createElement("link");
s.rel = "stylesheet", s.href = ie, s.dataset.nqFonts = "", document.head.appendChild(s);
s.rel = "stylesheet", s.href = re, s.dataset.nqFonts = "", document.head.appendChild(s);
}
+39 -3
View File
@@ -140,7 +140,32 @@ function titleCaseSlug(slug: string): string {
.join(" ");
}
function parseIsoDate(value: unknown): Date | null {
function zoneOffsetMs(instant: number, timeZone: string): number {
const parts = zonedFormatter(timeZone, {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hourCycle: "h23",
}).formatToParts(new Date(instant));
const read = (type: Intl.DateTimeFormatPartTypes): number => {
const part = parts.find((entry) => entry.type === type);
return part ? Number(part.value) : Number.NaN;
};
const asUtc = Date.UTC(
read("year"),
read("month") - 1,
read("day"),
read("hour"),
read("minute"),
read("second")
);
return Number.isFinite(asUtc) ? asUtc - instant : 0;
}
function parseIsoDate(value: unknown, timeZone?: string): Date | null {
if (typeof value !== "string") {
return null;
}
@@ -152,7 +177,15 @@ function parseIsoDate(value: unknown): Date | null {
if (!year || !month || !day) {
return null;
}
const date = new Date(year, month - 1, day);
if (!timeZone) {
const local = new Date(year, month - 1, day);
return Number.isNaN(local.getTime()) ? null : local;
}
let utcMs = Date.UTC(year, month - 1, day);
for (let pass = 0; pass < 2; pass += 1) {
utcMs -= zoneOffsetMs(utcMs, timeZone);
}
const date = new Date(utcMs);
return Number.isNaN(date.getTime()) ? null : date;
}
@@ -702,7 +735,10 @@ export class NestQuestPartyBoardCard extends LitElement {
name = titleCaseSlug(slug);
}
const returnsDate = parseIsoDate(presence?.attributes?.next_present);
const returnsDate = parseIsoDate(
presence?.attributes?.next_present,
this._timeZone()
);
const returns = returnsDate
? `Returns ${formatDay(returnsDate, this._timeZone())}`
: null;