@glasshome/widget-sdk 0.5.1 → 1.0.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/data.d.ts +10 -0
- package/dist/framework/dialogs/WidgetDialog.d.ts +3 -0
- package/dist/framework/gestures/use-widget-gestures.d.ts +5 -22
- package/dist/framework/hooks/use-widget-context.d.ts +3 -0
- package/dist/framework/hooks/use-widget-dialog.d.ts +17 -9
- package/dist/framework/theming/tokens.d.ts +9 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +531 -465
- package/dist/schemas.d.ts +6 -106
- package/dist/schemas.js +13 -77
- package/dist/types.d.ts +3 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +206 -122
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { z as A } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import { effect as W, className as
|
|
4
|
-
import { createElementSize as
|
|
5
|
-
import { createContext as
|
|
6
|
-
import { clsx as
|
|
7
|
-
import { twMerge as
|
|
8
|
-
|
|
2
|
+
import { widgetManifestSchema as cn, formatSchemaError as dn } from "@glasshome/widget-contract";
|
|
3
|
+
import { effect as W, className as P, style as ae, template as x, insert as p, createComponent as k, memo as T, setStyleProperty as J, addEventListener as G, use as ke, delegateEvents as Ce } from "solid-js/web";
|
|
4
|
+
import { createElementSize as Se } from "@solid-primitives/resize-observer";
|
|
5
|
+
import { createContext as Me, useContext as se, Show as O, createSignal as V, onMount as De, createMemo as U, splitProps as Te, createEffect as oe, on as ue, onCleanup as le } from "solid-js";
|
|
6
|
+
import { clsx as _e } from "clsx";
|
|
7
|
+
import { twMerge as ze } from "tailwind-merge";
|
|
8
|
+
import { byDomain as gn, useArea as hn, useCamera as fn, useConnection as mn, useCurrency as vn, useEntities as wn, useEntity as pn, useEntityHistory as bn, useEntityStatistics as xn, useForecast as yn, useHassConfig as $n, useLocale as kn, useService as Cn, useStore as Sn, useTemperatureUnit as Mn, useToggle as Dn, useTurnOn as Tn, useUnitSystem as _n } from "@glasshome/sync-layer/solid";
|
|
9
|
+
import { getForecasts as En, getStream as On, getWebRtcClientConfig as Nn, sendWebRtcCandidate as An, startWebRtcSession as Vn, state as Wn, trackEntityHistory as Rn, untrackEntityHistory as Hn } from "@glasshome/sync-layer";
|
|
10
|
+
function fe(e) {
|
|
9
11
|
return A.toJSONSchema(e, {
|
|
10
12
|
override: (t) => {
|
|
11
13
|
const i = A.globalRegistry.get(t.zodSchema);
|
|
@@ -13,17 +15,17 @@ function de(e) {
|
|
|
13
15
|
}
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
|
-
function
|
|
18
|
+
function Ee(e) {
|
|
17
19
|
try {
|
|
18
20
|
return e.parse({});
|
|
19
21
|
} catch {
|
|
20
22
|
return {};
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
return e.configSchema && (e.manifest.schema || (e.manifest.schema =
|
|
25
|
+
function Bt(e) {
|
|
26
|
+
return e.configSchema && (e.manifest.schema || (e.manifest.schema = fe(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = Ee(e.configSchema))), e;
|
|
25
27
|
}
|
|
26
|
-
const
|
|
28
|
+
const Y = {
|
|
27
29
|
/** Background layer (gradients, images, glows) */
|
|
28
30
|
BACKGROUND: 0,
|
|
29
31
|
/** Main content layer (icon, title, text) */
|
|
@@ -32,14 +34,14 @@ const G = {
|
|
|
32
34
|
OVERLAY: 20,
|
|
33
35
|
/** Action layer (buttons, edit controls) */
|
|
34
36
|
ACTIONS: 30
|
|
35
|
-
},
|
|
36
|
-
function
|
|
37
|
-
const e =
|
|
37
|
+
}, Q = Me();
|
|
38
|
+
function Ft() {
|
|
39
|
+
const e = se(Q);
|
|
38
40
|
if (!e)
|
|
39
41
|
throw new Error("useWidgetContext must be used within a Widget component");
|
|
40
42
|
return e;
|
|
41
43
|
}
|
|
42
|
-
const
|
|
44
|
+
const me = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
|
|
43
45
|
* via framework/theming/tokens.ts.
|
|
44
46
|
*
|
|
45
47
|
* All widget-internal visual scale is driven from CSS custom properties +
|
|
@@ -211,22 +213,34 @@ const Se = `/* Authoritative SDK CSS contract. Injected once on first Widget mou
|
|
|
211
213
|
}
|
|
212
214
|
}
|
|
213
215
|
`;
|
|
214
|
-
let
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
let ne = !1, K;
|
|
217
|
+
const ge = /* @__PURE__ */ new WeakSet();
|
|
218
|
+
function Oe() {
|
|
219
|
+
return K || (K = new CSSStyleSheet(), K.replaceSync(
|
|
220
|
+
me.replace(/:root\b/g, ":host").replace(/^\.dark\b/gm, ":host(.dark)")
|
|
221
|
+
)), K;
|
|
222
|
+
}
|
|
223
|
+
function Ne(e) {
|
|
224
|
+
if (typeof ShadowRoot < "u" && e instanceof ShadowRoot) {
|
|
225
|
+
if (ge.has(e)) return;
|
|
226
|
+
const r = Oe();
|
|
227
|
+
e.adoptedStyleSheets.includes(r) || (e.adoptedStyleSheets = [...e.adoptedStyleSheets, r]), ge.add(e);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (ne) return;
|
|
217
231
|
const t = e ?? (typeof document > "u" ? void 0 : document);
|
|
218
232
|
if (!t) return;
|
|
219
233
|
if (t.head.querySelector?.("style[data-glasshome-tokens]")) {
|
|
220
|
-
|
|
234
|
+
ne = !0;
|
|
221
235
|
return;
|
|
222
236
|
}
|
|
223
237
|
const i = t.createElement("style");
|
|
224
|
-
i.setAttribute("data-glasshome-tokens", ""), i.textContent =
|
|
238
|
+
i.setAttribute("data-glasshome-tokens", ""), i.textContent = me, t.head.appendChild(i), ne = !0;
|
|
225
239
|
}
|
|
226
|
-
function
|
|
227
|
-
return
|
|
240
|
+
function R(...e) {
|
|
241
|
+
return ze(_e(e));
|
|
228
242
|
}
|
|
229
|
-
const
|
|
243
|
+
const Ae = {
|
|
230
244
|
id: "classic-glass",
|
|
231
245
|
name: "Classic Glass",
|
|
232
246
|
description: "Default glassmorphism design with blur background and gradient",
|
|
@@ -254,7 +268,7 @@ const De = {
|
|
|
254
268
|
hoverScale: 1.02,
|
|
255
269
|
activeScale: 0.98
|
|
256
270
|
}
|
|
257
|
-
},
|
|
271
|
+
}, Ve = {
|
|
258
272
|
id: "minimal",
|
|
259
273
|
name: "Minimal",
|
|
260
274
|
description: "Clean, minimal design with no background effects",
|
|
@@ -283,7 +297,7 @@ const De = {
|
|
|
283
297
|
active: !1,
|
|
284
298
|
focus: !0
|
|
285
299
|
}
|
|
286
|
-
},
|
|
300
|
+
}, We = {
|
|
287
301
|
id: "compact-horizontal",
|
|
288
302
|
name: "Compact Horizontal",
|
|
289
303
|
description: "Horizontal layout for compact widgets",
|
|
@@ -311,108 +325,108 @@ const De = {
|
|
|
311
325
|
hoverScale: 1.02,
|
|
312
326
|
activeScale: 0.98
|
|
313
327
|
}
|
|
314
|
-
},
|
|
315
|
-
"classic-glass":
|
|
316
|
-
minimal:
|
|
317
|
-
"compact-horizontal":
|
|
328
|
+
}, Re = {
|
|
329
|
+
"classic-glass": Ae,
|
|
330
|
+
minimal: Ve,
|
|
331
|
+
"compact-horizontal": We
|
|
318
332
|
};
|
|
319
|
-
function
|
|
320
|
-
return
|
|
333
|
+
function He(e) {
|
|
334
|
+
return Re[e];
|
|
321
335
|
}
|
|
322
|
-
var
|
|
323
|
-
function
|
|
336
|
+
var Pe = /* @__PURE__ */ x("<div>");
|
|
337
|
+
function Ie(e) {
|
|
324
338
|
return (() => {
|
|
325
|
-
var t =
|
|
339
|
+
var t = Pe();
|
|
326
340
|
return W((i) => {
|
|
327
|
-
var r =
|
|
341
|
+
var r = R("glasshome-widget-slider-fill pointer-events-none absolute inset-0", e.isDragging ? "duration-0" : "transition-all duration-300 ease-out", e.class), n = {
|
|
328
342
|
"--widget-fill-value": e.value,
|
|
329
|
-
"z-index":
|
|
343
|
+
"z-index": Y.BACKGROUND,
|
|
330
344
|
...e.color ? {
|
|
331
345
|
"--widget-icon-color": e.color
|
|
332
346
|
} : {}
|
|
333
347
|
};
|
|
334
|
-
return r !== i.e &&
|
|
348
|
+
return r !== i.e && P(t, i.e = r), i.t = ae(t, n, i.t), i;
|
|
335
349
|
}, {
|
|
336
350
|
e: void 0,
|
|
337
351
|
t: void 0
|
|
338
352
|
}), t;
|
|
339
353
|
})();
|
|
340
354
|
}
|
|
341
|
-
var
|
|
342
|
-
function
|
|
355
|
+
var Le = /* @__PURE__ */ x("<div>");
|
|
356
|
+
function Ue(e) {
|
|
343
357
|
return (() => {
|
|
344
|
-
var t =
|
|
345
|
-
return p(t, () => e.children), W(() =>
|
|
358
|
+
var t = Le();
|
|
359
|
+
return p(t, () => e.children), W(() => P(t, R("glasshome-widget-content", e.class))), t;
|
|
346
360
|
})();
|
|
347
361
|
}
|
|
348
|
-
var
|
|
349
|
-
function
|
|
362
|
+
var je = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-2">'), Be = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-3">'), Fe = /* @__PURE__ */ x('<div><div class="glasshome-widget-icon-glyph flex items-center justify-center">');
|
|
363
|
+
function Ge(e) {
|
|
350
364
|
const t = () => e.entityCount ?? 1;
|
|
351
365
|
return (() => {
|
|
352
|
-
var i =
|
|
353
|
-
return p(i,
|
|
366
|
+
var i = Fe(), r = i.firstChild;
|
|
367
|
+
return p(i, k(O, {
|
|
354
368
|
get when() {
|
|
355
369
|
return t() >= 2;
|
|
356
370
|
},
|
|
357
371
|
get children() {
|
|
358
|
-
return
|
|
372
|
+
return je();
|
|
359
373
|
}
|
|
360
|
-
}), r), p(i,
|
|
374
|
+
}), r), p(i, k(O, {
|
|
361
375
|
get when() {
|
|
362
376
|
return t() >= 3;
|
|
363
377
|
},
|
|
364
378
|
get children() {
|
|
365
|
-
return
|
|
379
|
+
return Be();
|
|
366
380
|
}
|
|
367
381
|
}), r), p(r, () => e.icon), W((n) => {
|
|
368
|
-
var o =
|
|
382
|
+
var o = R("glasshome-widget-icon", "relative flex shrink-0 items-center justify-center pointer-events-none transition-all", e.dimmed && "opacity-50", e.class), u = e.color ? {
|
|
369
383
|
"--widget-icon-color": e.color
|
|
370
384
|
} : void 0;
|
|
371
|
-
return o !== n.e &&
|
|
385
|
+
return o !== n.e && P(i, n.e = o), n.t = ae(i, u, n.t), n;
|
|
372
386
|
}, {
|
|
373
387
|
e: void 0,
|
|
374
388
|
t: void 0
|
|
375
389
|
}), i;
|
|
376
390
|
})();
|
|
377
391
|
}
|
|
378
|
-
var
|
|
379
|
-
function
|
|
392
|
+
var qe = /* @__PURE__ */ x("<p>");
|
|
393
|
+
function Ye(e) {
|
|
380
394
|
return (() => {
|
|
381
|
-
var t =
|
|
395
|
+
var t = qe();
|
|
382
396
|
return p(t, (() => {
|
|
383
|
-
var i =
|
|
397
|
+
var i = T(() => !!e.isUnavailable);
|
|
384
398
|
return () => i() ? "Unavailable" : e.children;
|
|
385
399
|
})()), W((i) => {
|
|
386
|
-
var r =
|
|
387
|
-
return r !== i.e &&
|
|
400
|
+
var r = R("glasshome-widget-status", "relative", e.dimmed && "opacity-40", e.class), n = Y.ACTIONS;
|
|
401
|
+
return r !== i.e && P(t, i.e = r), n !== i.t && J(t, "z-index", i.t = n), i;
|
|
388
402
|
}, {
|
|
389
403
|
e: void 0,
|
|
390
404
|
t: void 0
|
|
391
405
|
}), t;
|
|
392
406
|
})();
|
|
393
407
|
}
|
|
394
|
-
var
|
|
395
|
-
function
|
|
408
|
+
var Ke = /* @__PURE__ */ x('<span class="glasshome-widget-badge shrink-0">'), Xe = /* @__PURE__ */ x("<div><h3 class=glasshome-widget-title>");
|
|
409
|
+
function Je(e) {
|
|
396
410
|
return (() => {
|
|
397
|
-
var t =
|
|
398
|
-
return p(i, () => e.children), p(t,
|
|
411
|
+
var t = Xe(), i = t.firstChild;
|
|
412
|
+
return p(i, () => e.children), p(t, k(O, {
|
|
399
413
|
get when() {
|
|
400
|
-
return
|
|
414
|
+
return T(() => e.badge !== void 0)() && e.badge > 0;
|
|
401
415
|
},
|
|
402
416
|
get children() {
|
|
403
|
-
var r =
|
|
417
|
+
var r = Ke();
|
|
404
418
|
return p(r, () => e.badge), r;
|
|
405
419
|
}
|
|
406
420
|
}), null), W((r) => {
|
|
407
|
-
var n =
|
|
408
|
-
return n !== r.e &&
|
|
421
|
+
var n = R("relative flex items-center gap-2", e.class), o = Y.ACTIONS;
|
|
422
|
+
return n !== r.e && P(t, r.e = n), o !== r.t && J(t, "z-index", r.t = o), r;
|
|
409
423
|
}, {
|
|
410
424
|
e: void 0,
|
|
411
425
|
t: void 0
|
|
412
426
|
}), t;
|
|
413
427
|
})();
|
|
414
428
|
}
|
|
415
|
-
function
|
|
429
|
+
function Qe(e, t = !1) {
|
|
416
430
|
if (e.length === 0)
|
|
417
431
|
return {
|
|
418
432
|
isGroup: !1,
|
|
@@ -428,26 +442,26 @@ function Fe(e, t = !1) {
|
|
|
428
442
|
};
|
|
429
443
|
const i = e.length > 1;
|
|
430
444
|
if (!i) {
|
|
431
|
-
const
|
|
445
|
+
const s = e[0], f = s.state === "on", b = s.attributes?.brightness || 0, C = Math.round(b / 255 * 100);
|
|
432
446
|
return {
|
|
433
447
|
isGroup: !1,
|
|
434
|
-
state:
|
|
435
|
-
isOn:
|
|
436
|
-
isUnavailable:
|
|
437
|
-
brightness:
|
|
438
|
-
brightnessPercent:
|
|
439
|
-
color:
|
|
440
|
-
onCount:
|
|
448
|
+
state: s.state,
|
|
449
|
+
isOn: f,
|
|
450
|
+
isUnavailable: s.state === "unavailable",
|
|
451
|
+
brightness: b,
|
|
452
|
+
brightnessPercent: C,
|
|
453
|
+
color: he(s),
|
|
454
|
+
onCount: f ? 1 : 0,
|
|
441
455
|
totalCount: 1,
|
|
442
|
-
description:
|
|
456
|
+
description: f ? "On" : "Off"
|
|
443
457
|
};
|
|
444
458
|
}
|
|
445
|
-
let r = 0, n = 0, o = 0,
|
|
446
|
-
const
|
|
447
|
-
for (const
|
|
448
|
-
switch (
|
|
459
|
+
let r = 0, n = 0, o = 0, u = 0, d = 0, $ = 0;
|
|
460
|
+
const m = [];
|
|
461
|
+
for (const s of e)
|
|
462
|
+
switch (s.state) {
|
|
449
463
|
case "on":
|
|
450
|
-
r++,
|
|
464
|
+
r++, s.attributes?.brightness !== void 0 && (d += s.attributes.brightness, $++), s.attributes?.rgb_color && m.push(s.attributes.rgb_color);
|
|
451
465
|
break;
|
|
452
466
|
case "off":
|
|
453
467
|
n++;
|
|
@@ -456,34 +470,34 @@ function Fe(e, t = !1) {
|
|
|
456
470
|
o++;
|
|
457
471
|
break;
|
|
458
472
|
case "unavailable":
|
|
459
|
-
|
|
473
|
+
u++;
|
|
460
474
|
break;
|
|
461
475
|
}
|
|
462
|
-
const
|
|
463
|
-
let w,
|
|
464
|
-
t ? v ? (w = "unavailable",
|
|
465
|
-
const
|
|
466
|
-
let
|
|
467
|
-
if (
|
|
468
|
-
const
|
|
469
|
-
|
|
476
|
+
const h = e.length, v = u === h, y = o + u === h, g = r > 0, a = r === h, S = n === h;
|
|
477
|
+
let w, M;
|
|
478
|
+
t ? v ? (w = "unavailable", M = !1) : o > 0 || u > 0 ? (w = "unknown", M = !1) : n > 0 ? (w = "off", M = !1) : (w = "on", M = !0) : v ? (w = "unavailable", M = !1) : y ? (w = "unknown", M = !1) : g ? (w = "on", M = !0) : (w = "off", M = !1);
|
|
479
|
+
const z = $ > 0 ? Math.round(d / $) : 0, I = Math.round(z / 255 * 100);
|
|
480
|
+
let j;
|
|
481
|
+
if (m.length > 0) {
|
|
482
|
+
const s = Math.round(m.reduce((E, D) => E + D[0], 0) / m.length), f = Math.round(m.reduce((E, D) => E + D[1], 0) / m.length), b = Math.round(m.reduce((E, D) => E + D[2], 0) / m.length), C = z / 255;
|
|
483
|
+
j = `rgb(${Math.round(s * C)}, ${Math.round(f * C)}, ${Math.round(b * C)})`;
|
|
470
484
|
} else
|
|
471
|
-
|
|
472
|
-
let
|
|
473
|
-
return a ?
|
|
485
|
+
j = he(e[0]);
|
|
486
|
+
let H;
|
|
487
|
+
return a ? H = "All on" : S ? H = "All off" : r > 0 ? H = `${r} of ${h} on` : H = "Off", {
|
|
474
488
|
isGroup: i,
|
|
475
489
|
state: w,
|
|
476
|
-
isOn:
|
|
490
|
+
isOn: M,
|
|
477
491
|
isUnavailable: w === "unavailable",
|
|
478
|
-
brightness:
|
|
492
|
+
brightness: z,
|
|
479
493
|
brightnessPercent: I,
|
|
480
|
-
color:
|
|
494
|
+
color: j,
|
|
481
495
|
onCount: r,
|
|
482
|
-
totalCount:
|
|
483
|
-
description:
|
|
496
|
+
totalCount: h,
|
|
497
|
+
description: H
|
|
484
498
|
};
|
|
485
499
|
}
|
|
486
|
-
function
|
|
500
|
+
function Ze(e, t = "mean", i = !0) {
|
|
487
501
|
if (e.length === 0)
|
|
488
502
|
return {
|
|
489
503
|
isGroup: !1,
|
|
@@ -494,98 +508,98 @@ function Ge(e, t = "mean", i = !0) {
|
|
|
494
508
|
};
|
|
495
509
|
const r = e.length > 1;
|
|
496
510
|
if (!r) {
|
|
497
|
-
const
|
|
498
|
-
let
|
|
499
|
-
return Number.isNaN(a) || (
|
|
511
|
+
const g = e[0], a = Number.parseFloat(g.state);
|
|
512
|
+
let S = g.state;
|
|
513
|
+
return Number.isNaN(a) || (S = Number.isInteger(a) ? a.toString() : a.toFixed(1)), {
|
|
500
514
|
isGroup: !1,
|
|
501
|
-
state:
|
|
515
|
+
state: S,
|
|
502
516
|
numericValue: Number.isNaN(a) ? null : a,
|
|
503
|
-
isUnavailable:
|
|
504
|
-
unit:
|
|
505
|
-
description:
|
|
517
|
+
isUnavailable: g.state === "unavailable",
|
|
518
|
+
unit: g.unitOfMeasurement ?? void 0,
|
|
519
|
+
description: S
|
|
506
520
|
};
|
|
507
521
|
}
|
|
508
522
|
const n = [], o = [];
|
|
509
|
-
let
|
|
510
|
-
for (const
|
|
511
|
-
if (!
|
|
512
|
-
|
|
513
|
-
entityId:
|
|
523
|
+
let u = 0, d;
|
|
524
|
+
for (const g of e) {
|
|
525
|
+
if (!d && g.unitOfMeasurement && (d = g.unitOfMeasurement), g.state === "unavailable") {
|
|
526
|
+
u++, o.push({
|
|
527
|
+
entityId: g.id,
|
|
514
528
|
value: "unavailable",
|
|
515
|
-
friendly_name:
|
|
529
|
+
friendly_name: g.friendlyName
|
|
516
530
|
});
|
|
517
531
|
continue;
|
|
518
532
|
}
|
|
519
|
-
const a = Number.parseFloat(
|
|
533
|
+
const a = Number.parseFloat(g.state);
|
|
520
534
|
isNaN(a) ? i || o.push({
|
|
521
|
-
entityId:
|
|
522
|
-
value:
|
|
523
|
-
friendly_name:
|
|
535
|
+
entityId: g.id,
|
|
536
|
+
value: g.state,
|
|
537
|
+
friendly_name: g.friendlyName
|
|
524
538
|
}) : (n.push(a), o.push({
|
|
525
|
-
entityId:
|
|
539
|
+
entityId: g.id,
|
|
526
540
|
value: a,
|
|
527
|
-
friendly_name:
|
|
541
|
+
friendly_name: g.friendlyName
|
|
528
542
|
}));
|
|
529
543
|
}
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
544
|
+
const $ = u === e.length, m = n.length === 0;
|
|
545
|
+
if ($ || m)
|
|
532
546
|
return {
|
|
533
547
|
isGroup: r,
|
|
534
|
-
state:
|
|
548
|
+
state: $ ? "unavailable" : "unknown",
|
|
535
549
|
numericValue: null,
|
|
536
|
-
isUnavailable:
|
|
537
|
-
unit:
|
|
538
|
-
description:
|
|
550
|
+
isUnavailable: $,
|
|
551
|
+
unit: d,
|
|
552
|
+
description: $ ? "Unavailable" : "No numeric values",
|
|
539
553
|
memberValues: o
|
|
540
554
|
};
|
|
541
|
-
let
|
|
555
|
+
let h, v;
|
|
542
556
|
switch (t) {
|
|
543
557
|
case "min":
|
|
544
|
-
|
|
558
|
+
h = Math.min(...n), v = "Minimum";
|
|
545
559
|
break;
|
|
546
560
|
case "max":
|
|
547
|
-
|
|
561
|
+
h = Math.max(...n), v = "Maximum";
|
|
548
562
|
break;
|
|
549
563
|
case "mean":
|
|
550
|
-
|
|
564
|
+
h = n.reduce((g, a) => g + a, 0) / n.length, v = "Average";
|
|
551
565
|
break;
|
|
552
566
|
case "median": {
|
|
553
|
-
const
|
|
554
|
-
|
|
567
|
+
const g = [...n].sort((S, w) => S - w), a = Math.floor(g.length / 2);
|
|
568
|
+
h = g.length % 2 === 0 ? (g[a - 1] + g[a]) / 2 : g[a], v = "Median";
|
|
555
569
|
break;
|
|
556
570
|
}
|
|
557
571
|
case "sum":
|
|
558
|
-
|
|
572
|
+
h = n.reduce((g, a) => g + a, 0), v = "Sum";
|
|
559
573
|
break;
|
|
560
574
|
case "last":
|
|
561
|
-
|
|
575
|
+
h = n[n.length - 1], v = "Latest";
|
|
562
576
|
break;
|
|
563
577
|
case "range":
|
|
564
|
-
|
|
578
|
+
h = Math.max(...n) - Math.min(...n), v = "Range";
|
|
565
579
|
break;
|
|
566
580
|
case "product":
|
|
567
|
-
|
|
581
|
+
h = n.reduce((g, a) => g * a, 1), v = "Product";
|
|
568
582
|
break;
|
|
569
583
|
case "std_dev": {
|
|
570
|
-
const
|
|
571
|
-
|
|
584
|
+
const g = n.reduce((S, w) => S + w, 0) / n.length, a = n.reduce((S, w) => S + (w - g) ** 2, 0) / n.length;
|
|
585
|
+
h = Math.sqrt(a), v = "Std Dev";
|
|
572
586
|
break;
|
|
573
587
|
}
|
|
574
588
|
default:
|
|
575
|
-
|
|
589
|
+
h = n.reduce((g, a) => g + a, 0) / n.length, v = "Average";
|
|
576
590
|
}
|
|
577
|
-
const
|
|
591
|
+
const y = Number.isInteger(h) ? h.toString() : h.toFixed(1);
|
|
578
592
|
return {
|
|
579
593
|
isGroup: r,
|
|
580
|
-
state:
|
|
581
|
-
numericValue:
|
|
594
|
+
state: y,
|
|
595
|
+
numericValue: h,
|
|
582
596
|
isUnavailable: !1,
|
|
583
|
-
unit:
|
|
597
|
+
unit: d,
|
|
584
598
|
description: `${v} of ${n.length}`,
|
|
585
599
|
memberValues: o
|
|
586
600
|
};
|
|
587
601
|
}
|
|
588
|
-
function
|
|
602
|
+
function he(e) {
|
|
589
603
|
if (e.state !== "on") return "rgb(100, 100, 100)";
|
|
590
604
|
const i = (e.attributes?.brightness ?? 255) / 255;
|
|
591
605
|
if (e.attributes?.rgb_color) {
|
|
@@ -594,12 +608,12 @@ function se(e) {
|
|
|
594
608
|
}
|
|
595
609
|
if (e.attributes?.color_temp) {
|
|
596
610
|
const n = 1e6 / e.attributes.color_temp / 100;
|
|
597
|
-
let o,
|
|
598
|
-
return n <= 66 ? (o = 255,
|
|
611
|
+
let o, u, d;
|
|
612
|
+
return n <= 66 ? (o = 255, u = n <= 19 ? 0 : 99.4708025861 * Math.log(n - 10) - 161.1195681661, d = n <= 19 ? 0 : n <= 66 ? 138.5177312231 * Math.log(n - 10) - 305.0447927307 : 255) : (o = 329.698727446 * (n - 60) ** -0.1332047592, u = 288.1221695283 * (n - 60) ** -0.0755148492, d = 255), o = Math.max(0, Math.min(255, o)) * i, u = Math.max(0, Math.min(255, u)) * i, d = Math.max(0, Math.min(255, d)) * i, `rgb(${Math.round(o)}, ${Math.round(u)}, ${Math.round(d)})`;
|
|
599
613
|
}
|
|
600
614
|
return `rgb(${Math.round(255 * i)}, ${Math.round(220 * i)}, ${Math.round(180 * i)})`;
|
|
601
615
|
}
|
|
602
|
-
function
|
|
616
|
+
function et(e) {
|
|
603
617
|
if (!e) return !1;
|
|
604
618
|
if (["on", "open", "locked", "home", "playing", "active"].includes(e.state))
|
|
605
619
|
return !0;
|
|
@@ -609,63 +623,66 @@ function qe(e) {
|
|
|
609
623
|
}
|
|
610
624
|
return !1;
|
|
611
625
|
}
|
|
612
|
-
function
|
|
626
|
+
function Gt(e, t, i) {
|
|
613
627
|
return e?.attributes ? e.attributes[t] ?? i : i;
|
|
614
628
|
}
|
|
615
|
-
function
|
|
616
|
-
return e.filter(
|
|
629
|
+
function qt(e) {
|
|
630
|
+
return e.filter(et).length;
|
|
617
631
|
}
|
|
618
|
-
function
|
|
632
|
+
function tt(e, t, i) {
|
|
619
633
|
const { decimals: r, scale: n = !0 } = {};
|
|
620
634
|
if (typeof e == "string")
|
|
621
635
|
return t ? `${e}${t}` : e;
|
|
622
636
|
if (e == null || Number.isNaN(e))
|
|
623
637
|
return t ? `--${t}` : "--";
|
|
624
|
-
let o = e,
|
|
625
|
-
n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (o = e / 1e6,
|
|
626
|
-
let
|
|
627
|
-
return r !== void 0 ?
|
|
638
|
+
let o = e, u = t || "";
|
|
639
|
+
n && t && (t === "W" || t === "kW" || t === "MW") && (e >= 1e6 ? (o = e / 1e6, u = "MW") : e >= 1e3 ? (o = e / 1e3, u = "kW") : u = "W"), n && t && (t === "B" || t === "KB" || t === "MB" || t === "GB") && (e >= 1073741824 ? (o = e / 1073741824, u = "GB") : e >= 1048576 ? (o = e / 1048576, u = "MB") : e >= 1024 ? (o = e / 1024, u = "KB") : u = "B");
|
|
640
|
+
let d;
|
|
641
|
+
return r !== void 0 ? d = o.toFixed(r) : o !== e ? d = o.toFixed(1) : Number.isInteger(e) ? d = e.toString() : d = Number.parseFloat(e.toFixed(2)).toString(), u ? `${d}${u}` : d;
|
|
628
642
|
}
|
|
629
|
-
function
|
|
643
|
+
function nt(e, t) {
|
|
630
644
|
return e == null || isNaN(e) ? null : t === "°C" ? e < 10 ? "Cold" : e < 18 ? "Cool" : e < 24 ? "Comfortable" : e < 28 ? "Warm" : "Hot" : t === "°F" ? e < 50 ? "Cold" : e < 64 ? "Cool" : e < 75 ? "Comfortable" : e < 82 ? "Warm" : "Hot" : t === "%" ? e < 20 ? "Very Low" : e < 40 ? "Low" : e < 60 ? "Medium" : e < 80 ? "High" : "Very High" : t === "ppm" ? e < 400 ? "Excellent" : e < 600 ? "Good" : e < 1e3 ? "Acceptable" : e < 1500 ? "Mediocre" : "Poor" : t === "lx" ? e < 50 ? "Dark" : e < 200 ? "Dim" : e < 500 ? "Moderate" : e < 1e3 ? "Bright" : "Very Bright" : t === "AQI" ? e <= 50 ? "Good" : e <= 100 ? "Moderate" : e <= 150 ? "Unhealthy for Sensitive" : e <= 200 ? "Unhealthy" : e <= 300 ? "Very Unhealthy" : "Hazardous" : t === "dB" ? e < 30 ? "Very Quiet" : e < 50 ? "Quiet" : e < 70 ? "Moderate" : e < 85 ? "Loud" : "Very Loud" : null;
|
|
631
645
|
}
|
|
632
|
-
var
|
|
633
|
-
function
|
|
646
|
+
var it = /* @__PURE__ */ x("<div class=glasshome-widget-subtitle>"), rt = /* @__PURE__ */ x("<div><div class=glasshome-widget-value>");
|
|
647
|
+
function ot(e) {
|
|
634
648
|
return (() => {
|
|
635
|
-
var t =
|
|
636
|
-
return p(i, () =>
|
|
649
|
+
var t = rt(), i = t.firstChild;
|
|
650
|
+
return p(i, () => tt(e.value, e.unit)), p(t, k(O, {
|
|
637
651
|
get when() {
|
|
638
|
-
return
|
|
652
|
+
return T(() => !!e.interpret)() && typeof e.value == "number";
|
|
639
653
|
},
|
|
640
654
|
get children() {
|
|
641
|
-
var r =
|
|
642
|
-
return p(r, () =>
|
|
655
|
+
var r = it();
|
|
656
|
+
return p(r, () => nt(e.value, e.unit)), r;
|
|
643
657
|
}
|
|
644
|
-
}), null), W(() =>
|
|
658
|
+
}), null), W(() => P(t, R("flex flex-col", e.class))), t;
|
|
645
659
|
})();
|
|
646
660
|
}
|
|
647
|
-
var
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
|
|
661
|
+
var at = /* @__PURE__ */ x('<div><div class="relative h-full w-full">'), st = /* @__PURE__ */ x('<div class="glasshome-widget-loading pointer-events-none absolute inset-0 animate-pulse">'), lt = /* @__PURE__ */ x('<div class="flex h-full w-full flex-col items-center justify-center gap-2 text-center">'), ct = /* @__PURE__ */ x('<div class="flex items-center justify-center text-white/30">'), dt = /* @__PURE__ */ x('<h3 class="font-semibold text-sm text-white/60">'), ut = /* @__PURE__ */ x('<p class="text-white/50 text-xs">');
|
|
662
|
+
function gt(e) {
|
|
663
|
+
const t = se(Q), [i, r] = V(), n = Se(i);
|
|
664
|
+
De(() => {
|
|
665
|
+
const a = i()?.getRootNode();
|
|
666
|
+
Ne(typeof ShadowRoot < "u" && a instanceof ShadowRoot || typeof Document < "u" && a instanceof Document ? a : void 0);
|
|
651
667
|
});
|
|
652
|
-
const
|
|
668
|
+
const o = {
|
|
653
669
|
isEditMode: () => e.isEditMode ?? !1,
|
|
654
670
|
updateConfig: t?.updateConfig ?? (() => {
|
|
655
671
|
}),
|
|
672
|
+
registerDialogOpener: t?.registerDialogOpener,
|
|
656
673
|
dimensions: () => ({
|
|
657
674
|
width: n.width ?? 0,
|
|
658
675
|
height: n.height ?? 0
|
|
659
676
|
})
|
|
660
|
-
},
|
|
677
|
+
}, u = U(() => {
|
|
661
678
|
if (e.variant)
|
|
662
|
-
return typeof e.variant == "string" ?
|
|
663
|
-
}),
|
|
679
|
+
return typeof e.variant == "string" ? He(e.variant) : e.variant;
|
|
680
|
+
}), d = U(() => ({
|
|
664
681
|
"container-type": "size",
|
|
665
682
|
"container-name": "widget",
|
|
666
683
|
"touch-action": e.gestures && !e.isEditMode ? e.gestures.touchAction() : void 0,
|
|
667
|
-
...
|
|
668
|
-
...
|
|
684
|
+
...u()?.styles?.container,
|
|
685
|
+
...u()?.styles?.cssVars || {},
|
|
669
686
|
...e.tone ? {
|
|
670
687
|
"--widget-color": `var(--tone-${e.tone})`
|
|
671
688
|
} : {},
|
|
@@ -678,26 +695,26 @@ function ot(e) {
|
|
|
678
695
|
...e.gradient ? {
|
|
679
696
|
"--widget-gradient": e.gradient
|
|
680
697
|
} : {}
|
|
681
|
-
})),
|
|
682
|
-
|
|
683
|
-
},
|
|
684
|
-
|
|
698
|
+
})), $ = () => !!e.gestures && !e.isEditMode, m = (a) => {
|
|
699
|
+
$() && e.gestures?.onPointerEnter(a);
|
|
700
|
+
}, h = (a) => {
|
|
701
|
+
$() && e.gestures?.onPointerDown(a);
|
|
685
702
|
}, v = (a) => {
|
|
686
|
-
|
|
687
|
-
},
|
|
688
|
-
|
|
689
|
-
},
|
|
690
|
-
|
|
703
|
+
$() && e.gestures?.onPointerMove(a);
|
|
704
|
+
}, y = (a) => {
|
|
705
|
+
$() && e.gestures?.onPointerUp(a);
|
|
706
|
+
}, g = (a) => {
|
|
707
|
+
$() && e.gestures?.onPointerCancel(a);
|
|
691
708
|
};
|
|
692
|
-
return
|
|
709
|
+
return k(Q.Provider, {
|
|
693
710
|
value: o,
|
|
694
711
|
get children() {
|
|
695
|
-
var a =
|
|
696
|
-
return
|
|
712
|
+
var a = at(), S = a.firstChild;
|
|
713
|
+
return G(a, "pointercancel", g), G(a, "pointerup", y), G(a, "pointermove", v), G(a, "pointerdown", h), G(a, "pointerenter", m), ke((w) => {
|
|
697
714
|
r(w), e.gestures?.bindElement(w);
|
|
698
|
-
}, a), p(
|
|
699
|
-
var w =
|
|
700
|
-
return () => w() ?
|
|
715
|
+
}, a), p(S, (() => {
|
|
716
|
+
var w = T(() => !!e.emptyState);
|
|
717
|
+
return () => w() ? k(ht, {
|
|
701
718
|
get icon() {
|
|
702
719
|
return e.emptyState.icon;
|
|
703
720
|
},
|
|
@@ -709,14 +726,14 @@ function ot(e) {
|
|
|
709
726
|
}
|
|
710
727
|
}) : e.children;
|
|
711
728
|
})()), p(a, (() => {
|
|
712
|
-
var w =
|
|
729
|
+
var w = T(() => !!e.loading);
|
|
713
730
|
return () => w() && (() => {
|
|
714
|
-
var
|
|
715
|
-
return W((
|
|
731
|
+
var M = st();
|
|
732
|
+
return W((z) => J(M, "z-index", Y.OVERLAY)), M;
|
|
716
733
|
})();
|
|
717
734
|
})(), null), W((w) => {
|
|
718
|
-
var
|
|
719
|
-
return
|
|
735
|
+
var M = R("glasshome-widget", "relative h-full w-full select-none overflow-hidden rounded-xl border border-border/50", u()?.styles?.class, e.class), z = d(), I = Y.CONTENT;
|
|
736
|
+
return M !== w.e && P(a, w.e = M), w.t = ae(a, z, w.t), I !== w.a && J(S, "z-index", w.a = I), w;
|
|
720
737
|
}, {
|
|
721
738
|
e: void 0,
|
|
722
739
|
t: void 0,
|
|
@@ -725,69 +742,71 @@ function ot(e) {
|
|
|
725
742
|
}
|
|
726
743
|
});
|
|
727
744
|
}
|
|
728
|
-
function
|
|
745
|
+
function ht(e) {
|
|
729
746
|
return (() => {
|
|
730
|
-
var t =
|
|
747
|
+
var t = lt();
|
|
731
748
|
return p(t, (() => {
|
|
732
|
-
var i =
|
|
749
|
+
var i = T(() => !!e.icon);
|
|
733
750
|
return () => i() && (() => {
|
|
734
|
-
var r =
|
|
751
|
+
var r = ct();
|
|
735
752
|
return p(r, () => e.icon), r;
|
|
736
753
|
})();
|
|
737
754
|
})(), null), p(t, (() => {
|
|
738
|
-
var i =
|
|
755
|
+
var i = T(() => !!e.title);
|
|
739
756
|
return () => i() && (() => {
|
|
740
|
-
var r =
|
|
757
|
+
var r = dt();
|
|
741
758
|
return p(r, () => e.title), r;
|
|
742
759
|
})();
|
|
743
760
|
})(), null), p(t, (() => {
|
|
744
|
-
var i =
|
|
761
|
+
var i = T(() => !!e.message);
|
|
745
762
|
return () => i() && (() => {
|
|
746
|
-
var r =
|
|
763
|
+
var r = ut();
|
|
747
764
|
return p(r, () => e.message), r;
|
|
748
765
|
})();
|
|
749
766
|
})(), null), t;
|
|
750
767
|
})();
|
|
751
768
|
}
|
|
752
|
-
const B =
|
|
753
|
-
B.Content =
|
|
754
|
-
B.Icon =
|
|
755
|
-
B.Title =
|
|
756
|
-
B.Status =
|
|
757
|
-
B.Value =
|
|
758
|
-
B.SliderFill =
|
|
759
|
-
var
|
|
760
|
-
function
|
|
769
|
+
const B = gt;
|
|
770
|
+
B.Content = Ue;
|
|
771
|
+
B.Icon = Ge;
|
|
772
|
+
B.Title = Je;
|
|
773
|
+
B.Status = Ye;
|
|
774
|
+
B.Value = ot;
|
|
775
|
+
B.SliderFill = Ie;
|
|
776
|
+
var ft = /* @__PURE__ */ x('<span class="inline-flex size-3.5 shrink-0 items-center">'), mt = /* @__PURE__ */ x("<button type=button>"), vt = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z">'), wt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No edit options available'), pt = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><line x1=4 y1=21 x2=4 y2=14></line><line x1=4 y1=10 x2=4 y2=3></line><line x1=12 y1=21 x2=12 y2=12></line><line x1=12 y1=8 x2=12 y2=3></line><line x1=20 y1=21 x2=20 y2=16></line><line x1=20 y1=12 x2=20 y2=3></line><line x1=1 y1=14 x2=7 y2=14></line><line x1=9 y1=8 x2=15 y2=8></line><line x1=17 y1=16 x2=23 y2=16>'), bt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No additional controls'), xt = /* @__PURE__ */ x('<svg xmlns=http://www.w3.org/2000/svg class=size-3.5 fill=none viewBox="0 0 24 24"stroke=currentColor stroke-width=2><path d="m8 2 1.88 1.88"></path><path d="M14.12 3.88 16 2"></path><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"></path><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"></path><path d="M12 20v-9"></path><path d="M6.53 9C4.6 8.8 3 7.1 3 5"></path><path d="M6 13H2"></path><path d="M3 21c0-2.1 1.7-3.9 3.8-4"></path><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"></path><path d="M22 13h-4"></path><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4">'), yt = /* @__PURE__ */ x('<div class="rounded-lg bg-muted/30 p-2 text-center md:p-6"><p class="text-muted-foreground text-sm">No debug information available'), $t = /* @__PURE__ */ x('<div class="min-w-0 shrink-0">'), kt = /* @__PURE__ */ x('<div class="flex items-center gap-2"><div class="flex h-8 items-center rounded-lg border border-border/50 bg-muted/30 p-0.5">'), Ct = /* @__PURE__ */ x('<div class="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">'), St = /* @__PURE__ */ x('<div class="flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3">');
|
|
777
|
+
function Mt(e) {
|
|
761
778
|
return (() => {
|
|
762
|
-
var t =
|
|
763
|
-
return t.$$click = () => e.onClick(), p(t,
|
|
779
|
+
var t = mt();
|
|
780
|
+
return t.$$click = () => e.onClick(), p(t, k(O, {
|
|
764
781
|
get when() {
|
|
765
782
|
return e.isActive;
|
|
766
783
|
},
|
|
767
784
|
get children() {
|
|
768
|
-
var i =
|
|
785
|
+
var i = ft();
|
|
769
786
|
return p(i, () => e.icon), i;
|
|
770
787
|
}
|
|
771
|
-
}), null), p(t, () => e.label, null), W(() =>
|
|
788
|
+
}), null), p(t, () => e.label, null), W(() => P(t, R("flex cursor-pointer items-center justify-center rounded-md px-3 py-1.5 text-xs transition-all duration-300 ease-in-out", e.isActive ? "gap-1.5 bg-foreground/10 font-semibold text-foreground shadow-sm" : "gap-0 text-muted-foreground hover:bg-foreground/5 hover:text-foreground"))), t;
|
|
772
789
|
})();
|
|
773
790
|
}
|
|
774
|
-
function
|
|
775
|
-
const [t] =
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
...
|
|
791
|
+
function Yt(e) {
|
|
792
|
+
const [t] = Te(e, ["open", "onOpenChange", "title", "onSave", "hasUnsavedChanges", "onDelete", "editContent", "controlsContent", "debugContent", "debugData", "tabs", "class", "maxWidth", "defaultTab", "activeTab", "onActiveTabChange", "headerActions", "configSchema", "config", "onConfigSave", "ResponsiveDialog", "ResponsiveDialogContent", "ResponsiveDialogHeader", "ResponsiveDialogTitle", "ResponsiveDialogDescription", "Button", "SchemaForm"]), i = () => !!t.configSchema && !!t.config && !!t.onConfigSave && !!t.SchemaForm, [r, n] = V({}), [o, u] = V(null);
|
|
793
|
+
oe(ue(() => t.config, (c) => {
|
|
794
|
+
c && n({
|
|
795
|
+
...c
|
|
779
796
|
});
|
|
780
|
-
})),
|
|
781
|
-
|
|
797
|
+
})), oe(ue(() => t.configSchema, (c) => {
|
|
798
|
+
c && u(fe(c));
|
|
782
799
|
}));
|
|
783
|
-
const
|
|
784
|
-
!
|
|
800
|
+
const d = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), $ = (c) => {
|
|
801
|
+
!c && t.config && n({
|
|
785
802
|
...t.config
|
|
786
|
-
}), t.onOpenChange(
|
|
787
|
-
},
|
|
803
|
+
}), t.onOpenChange(c);
|
|
804
|
+
}, m = () => {
|
|
788
805
|
t.onConfigSave?.(r());
|
|
789
|
-
}, [
|
|
790
|
-
|
|
806
|
+
}, [h, v] = V(t.defaultTab ?? "controls"), y = () => t.activeTab ?? h(), g = (c) => {
|
|
807
|
+
t.onActiveTabChange ? t.onActiveTabChange(c) : v(c);
|
|
808
|
+
}, a = () => {
|
|
809
|
+
const c = t.maxWidth ?? "3xl";
|
|
791
810
|
return {
|
|
792
811
|
sm: "max-w-sm",
|
|
793
812
|
md: "max-w-md",
|
|
@@ -796,15 +815,15 @@ function jt(e) {
|
|
|
796
815
|
"2xl": "max-w-2xl",
|
|
797
816
|
"3xl": "max-w-3xl",
|
|
798
817
|
"4xl": "max-w-4xl"
|
|
799
|
-
}[
|
|
800
|
-
},
|
|
818
|
+
}[c];
|
|
819
|
+
}, S = () => {
|
|
801
820
|
if (t.tabs) return t.tabs;
|
|
802
|
-
const
|
|
803
|
-
return
|
|
821
|
+
const c = [];
|
|
822
|
+
return c.push({
|
|
804
823
|
id: "edit",
|
|
805
824
|
label: "Edit",
|
|
806
|
-
icon:
|
|
807
|
-
content: t.editContent ?? (i() && o() ?
|
|
825
|
+
icon: vt(),
|
|
826
|
+
content: t.editContent ?? (i() && o() ? k(b, {
|
|
808
827
|
get schema() {
|
|
809
828
|
return o();
|
|
810
829
|
},
|
|
@@ -812,125 +831,125 @@ function jt(e) {
|
|
|
812
831
|
return r();
|
|
813
832
|
},
|
|
814
833
|
onChange: n
|
|
815
|
-
}) :
|
|
816
|
-
}),
|
|
834
|
+
}) : wt())
|
|
835
|
+
}), c.push({
|
|
817
836
|
id: "controls",
|
|
818
837
|
label: "Controls",
|
|
819
|
-
icon:
|
|
820
|
-
content: t.controlsContent ??
|
|
821
|
-
}),
|
|
838
|
+
icon: pt(),
|
|
839
|
+
content: t.controlsContent ?? bt()
|
|
840
|
+
}), c.push({
|
|
822
841
|
id: "debug",
|
|
823
842
|
label: "Debug",
|
|
824
|
-
icon:
|
|
825
|
-
content: t.debugContent ??
|
|
826
|
-
}),
|
|
827
|
-
},
|
|
843
|
+
icon: xt(),
|
|
844
|
+
content: t.debugContent ?? yt()
|
|
845
|
+
}), c;
|
|
846
|
+
}, w = async () => {
|
|
828
847
|
if (t.debugData !== void 0)
|
|
829
848
|
try {
|
|
830
|
-
const
|
|
831
|
-
await navigator.clipboard.writeText(
|
|
849
|
+
const c = typeof t.debugData == "string" ? t.debugData : JSON.stringify(t.debugData, null, 2);
|
|
850
|
+
await navigator.clipboard.writeText(c);
|
|
832
851
|
} catch {
|
|
833
852
|
}
|
|
834
|
-
},
|
|
835
|
-
const
|
|
836
|
-
return
|
|
837
|
-
},
|
|
838
|
-
return
|
|
853
|
+
}, M = () => {
|
|
854
|
+
const c = S();
|
|
855
|
+
return c.find((N) => N.id === y())?.content ?? c[0]?.content;
|
|
856
|
+
}, z = t.ResponsiveDialog, I = t.ResponsiveDialogContent, j = t.ResponsiveDialogHeader, H = t.ResponsiveDialogTitle, s = t.ResponsiveDialogDescription, f = t.Button, b = t.SchemaForm, C = (c) => i() ? $(c) : t.onOpenChange(c), E = () => i() ? d() : t.hasUnsavedChanges, D = () => i() ? m : t.onSave;
|
|
857
|
+
return k(z, {
|
|
839
858
|
get open() {
|
|
840
859
|
return t.open;
|
|
841
860
|
},
|
|
842
|
-
onOpenChange: (
|
|
861
|
+
onOpenChange: (c) => C(c),
|
|
843
862
|
get children() {
|
|
844
|
-
return
|
|
863
|
+
return k(I, {
|
|
845
864
|
get class() {
|
|
846
|
-
return
|
|
865
|
+
return R(a(), t.class);
|
|
847
866
|
},
|
|
848
867
|
get children() {
|
|
849
|
-
return [
|
|
868
|
+
return [k(j, {
|
|
850
869
|
class: "flex flex-row items-center justify-between gap-3",
|
|
851
870
|
get children() {
|
|
852
871
|
return [(() => {
|
|
853
|
-
var
|
|
854
|
-
return p(
|
|
872
|
+
var c = $t();
|
|
873
|
+
return p(c, k(H, {
|
|
855
874
|
class: "truncate leading-tight",
|
|
856
875
|
get children() {
|
|
857
876
|
return t.title;
|
|
858
877
|
}
|
|
859
|
-
}), null), p(
|
|
878
|
+
}), null), p(c, k(s, {
|
|
860
879
|
class: "sr-only",
|
|
861
880
|
children: "Widget configuration dialog"
|
|
862
|
-
}), null),
|
|
881
|
+
}), null), c;
|
|
863
882
|
})(), (() => {
|
|
864
|
-
var
|
|
865
|
-
return p(
|
|
883
|
+
var c = kt(), F = c.firstChild;
|
|
884
|
+
return p(F, () => S().map((N) => k(Mt, {
|
|
866
885
|
get icon() {
|
|
867
|
-
return
|
|
886
|
+
return N.icon;
|
|
868
887
|
},
|
|
869
888
|
get label() {
|
|
870
|
-
return
|
|
889
|
+
return N.label;
|
|
871
890
|
},
|
|
872
891
|
get isActive() {
|
|
873
|
-
return
|
|
892
|
+
return y() === N.id;
|
|
874
893
|
},
|
|
875
|
-
onClick: () =>
|
|
876
|
-
}))), p(
|
|
894
|
+
onClick: () => g(N.id)
|
|
895
|
+
}))), p(c, k(O, {
|
|
877
896
|
get when() {
|
|
878
897
|
return t.headerActions;
|
|
879
898
|
},
|
|
880
899
|
get children() {
|
|
881
900
|
return t.headerActions;
|
|
882
901
|
}
|
|
883
|
-
}), null),
|
|
902
|
+
}), null), c;
|
|
884
903
|
})()];
|
|
885
904
|
}
|
|
886
905
|
}), (() => {
|
|
887
|
-
var
|
|
888
|
-
return p(
|
|
889
|
-
})(),
|
|
906
|
+
var c = Ct();
|
|
907
|
+
return p(c, M), c;
|
|
908
|
+
})(), k(O, {
|
|
890
909
|
get when() {
|
|
891
|
-
return
|
|
910
|
+
return T(() => y() === "edit")() && (D() || t.onDelete) || y() === "debug" && t.debugData !== void 0;
|
|
892
911
|
},
|
|
893
912
|
get children() {
|
|
894
|
-
var
|
|
895
|
-
return p(
|
|
913
|
+
var c = St();
|
|
914
|
+
return p(c, k(O, {
|
|
896
915
|
get when() {
|
|
897
|
-
return
|
|
916
|
+
return T(() => y() === "edit")() && t.onDelete;
|
|
898
917
|
},
|
|
899
918
|
get children() {
|
|
900
|
-
return
|
|
919
|
+
return k(f, {
|
|
901
920
|
size: "sm",
|
|
902
921
|
variant: "destructive",
|
|
903
922
|
onClick: () => t.onDelete?.(),
|
|
904
923
|
children: "Delete"
|
|
905
924
|
});
|
|
906
925
|
}
|
|
907
|
-
}), null), p(
|
|
926
|
+
}), null), p(c, k(O, {
|
|
908
927
|
get when() {
|
|
909
|
-
return
|
|
928
|
+
return T(() => y() === "edit")() && D();
|
|
910
929
|
},
|
|
911
930
|
get children() {
|
|
912
|
-
return
|
|
931
|
+
return k(f, {
|
|
913
932
|
size: "sm",
|
|
914
933
|
get disabled() {
|
|
915
|
-
return !
|
|
934
|
+
return !E();
|
|
916
935
|
},
|
|
917
936
|
onClick: () => D()?.(),
|
|
918
937
|
children: "Save"
|
|
919
938
|
});
|
|
920
939
|
}
|
|
921
|
-
}), null), p(
|
|
940
|
+
}), null), p(c, k(O, {
|
|
922
941
|
get when() {
|
|
923
|
-
return
|
|
942
|
+
return T(() => y() === "debug")() && t.debugData !== void 0;
|
|
924
943
|
},
|
|
925
944
|
get children() {
|
|
926
|
-
return
|
|
945
|
+
return k(f, {
|
|
927
946
|
size: "sm",
|
|
928
947
|
variant: "outline",
|
|
929
|
-
onClick:
|
|
948
|
+
onClick: w,
|
|
930
949
|
children: "Copy"
|
|
931
950
|
});
|
|
932
951
|
}
|
|
933
|
-
}), null),
|
|
952
|
+
}), null), c;
|
|
934
953
|
}
|
|
935
954
|
})];
|
|
936
955
|
}
|
|
@@ -938,175 +957,187 @@ function jt(e) {
|
|
|
938
957
|
}
|
|
939
958
|
});
|
|
940
959
|
}
|
|
941
|
-
|
|
942
|
-
function
|
|
960
|
+
Ce(["click"]);
|
|
961
|
+
function Kt(e) {
|
|
943
962
|
if (typeof IntersectionObserver > "u")
|
|
944
963
|
return () => !1;
|
|
945
|
-
const [t, i] =
|
|
964
|
+
const [t, i] = V(!1), r = new IntersectionObserver((n) => {
|
|
946
965
|
const o = n[0];
|
|
947
966
|
o && i(!o.isIntersecting);
|
|
948
967
|
});
|
|
949
|
-
return
|
|
968
|
+
return oe(() => {
|
|
950
969
|
const n = e();
|
|
951
970
|
r.disconnect(), n && r.observe(n);
|
|
952
|
-
}),
|
|
971
|
+
}), le(() => r.disconnect()), t;
|
|
953
972
|
}
|
|
954
|
-
function
|
|
973
|
+
function Xt() {
|
|
955
974
|
if (typeof window > "u" || typeof window.matchMedia != "function")
|
|
956
975
|
return () => !1;
|
|
957
|
-
const e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, i] =
|
|
958
|
-
return e.addEventListener("change", r),
|
|
976
|
+
const e = window.matchMedia("(prefers-reduced-motion: reduce)"), [t, i] = V(e.matches), r = (n) => i(n.matches);
|
|
977
|
+
return e.addEventListener("change", r), le(() => e.removeEventListener("change", r)), t;
|
|
959
978
|
}
|
|
960
|
-
function
|
|
961
|
-
const [t, i] =
|
|
962
|
-
|
|
979
|
+
function Jt(e = "controls") {
|
|
980
|
+
const [t, i] = V(!1), [r, n] = V(e), o = (d) => {
|
|
981
|
+
n(d ?? e), i(!0);
|
|
982
|
+
}, u = se(Q);
|
|
983
|
+
return u?.registerDialogOpener?.(o), le(() => u?.registerDialogOpener?.(null)), {
|
|
963
984
|
showDialog: t,
|
|
964
985
|
setShowDialog: i,
|
|
965
|
-
openDialog:
|
|
986
|
+
openDialog: o,
|
|
966
987
|
closeDialog: () => i(!1),
|
|
967
988
|
activeTab: r,
|
|
968
|
-
setActiveTab: n
|
|
989
|
+
setActiveTab: n,
|
|
990
|
+
dialogProps: {
|
|
991
|
+
get open() {
|
|
992
|
+
return t();
|
|
993
|
+
},
|
|
994
|
+
onOpenChange: i,
|
|
995
|
+
get activeTab() {
|
|
996
|
+
return r();
|
|
997
|
+
},
|
|
998
|
+
onActiveTabChange: n
|
|
999
|
+
}
|
|
969
1000
|
};
|
|
970
1001
|
}
|
|
971
|
-
function
|
|
972
|
-
const t = e.minEntities ?? 1, i =
|
|
1002
|
+
function Qt(e) {
|
|
1003
|
+
const t = e.minEntities ?? 1, i = U(() => e.entities().length), r = U(() => i() >= t), n = U(() => !r() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), o = U(() => {
|
|
973
1004
|
if (!r()) return;
|
|
974
|
-
const
|
|
975
|
-
if (!
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
978
|
-
return
|
|
979
|
-
if (
|
|
980
|
-
const
|
|
981
|
-
return
|
|
1005
|
+
const d = e.aggregationMode?.();
|
|
1006
|
+
if (!d || d === "none") return;
|
|
1007
|
+
const $ = e.entities();
|
|
1008
|
+
if (d === "light" || d === "binary-sensor" || d === "switch")
|
|
1009
|
+
return Qe($, e.allEntitiesMode);
|
|
1010
|
+
if (d === "sensor") {
|
|
1011
|
+
const m = e.sensorGroupType?.() ?? "mean";
|
|
1012
|
+
return Ze($, m, !0);
|
|
982
1013
|
}
|
|
983
|
-
}),
|
|
1014
|
+
}), u = U(() => r() ? void 0 : e.emptyStateConfig);
|
|
984
1015
|
return {
|
|
985
1016
|
entities: e.entities,
|
|
986
1017
|
groupData: n,
|
|
987
1018
|
aggregatedData: o,
|
|
988
|
-
emptyState:
|
|
1019
|
+
emptyState: u,
|
|
989
1020
|
hasEntities: r,
|
|
990
1021
|
count: i
|
|
991
1022
|
};
|
|
992
1023
|
}
|
|
993
|
-
const
|
|
994
|
-
function
|
|
1024
|
+
const q = 32, l = q / 2, _ = "white", Z = "rgba(0,0,0,0.4)", ce = 2, ee = 3;
|
|
1025
|
+
function Dt(e) {
|
|
995
1026
|
return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
|
|
996
1027
|
}
|
|
997
|
-
function
|
|
998
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${
|
|
1028
|
+
function te(e) {
|
|
1029
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${q}" height="${q}" viewBox="0 0 ${q} ${q}">${e}</svg>`;
|
|
999
1030
|
}
|
|
1000
|
-
const
|
|
1031
|
+
const Tt = te(`
|
|
1001
1032
|
<g transform="translate(6, 2)">
|
|
1002
1033
|
<!-- shadow -->
|
|
1003
|
-
<g stroke="${
|
|
1034
|
+
<g stroke="${Z}" stroke-width="${ee}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1004
1035
|
<path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
|
|
1005
1036
|
</g>
|
|
1006
1037
|
<!-- main -->
|
|
1007
|
-
<g stroke="${
|
|
1038
|
+
<g stroke="${_}" stroke-width="${ce}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1008
1039
|
<path d="M10 8V3a2 2 0 0 1 4 0v10l4.5-4.5a2 2 0 0 1 2.83 2.83L14 18.5c-2 2-4 3.5-8 3.5-3 0-5-2-5-5v-6a2 2 0 0 1 4 0v2"/>
|
|
1009
1040
|
</g>
|
|
1010
1041
|
</g>
|
|
1011
|
-
`),
|
|
1042
|
+
`), _t = te(`
|
|
1012
1043
|
<g>
|
|
1013
|
-
<circle cx="${
|
|
1014
|
-
<circle cx="${
|
|
1015
|
-
<circle cx="${
|
|
1044
|
+
<circle cx="${l}" cy="${l}" r="8" stroke="${Z}" stroke-width="${ee}" fill="none"/>
|
|
1045
|
+
<circle cx="${l}" cy="${l}" r="8" stroke="${_}" stroke-width="1.5" fill="none"/>
|
|
1046
|
+
<circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
|
|
1016
1047
|
</g>
|
|
1017
|
-
`),
|
|
1048
|
+
`), zt = te(`
|
|
1018
1049
|
<g>
|
|
1019
1050
|
<!-- shadow -->
|
|
1020
|
-
<g stroke="${
|
|
1021
|
-
<line x1="6" y1="${
|
|
1022
|
-
<polyline points="10,${
|
|
1023
|
-
<polyline points="22,${
|
|
1051
|
+
<g stroke="${Z}" stroke-width="${ee}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1052
|
+
<line x1="6" y1="${l}" x2="26" y2="${l}"/>
|
|
1053
|
+
<polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
|
|
1054
|
+
<polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
|
|
1024
1055
|
</g>
|
|
1025
1056
|
<!-- main -->
|
|
1026
|
-
<g stroke="${
|
|
1027
|
-
<line x1="6" y1="${
|
|
1028
|
-
<polyline points="10,${
|
|
1029
|
-
<polyline points="22,${
|
|
1057
|
+
<g stroke="${_}" stroke-width="${ce}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1058
|
+
<line x1="6" y1="${l}" x2="26" y2="${l}"/>
|
|
1059
|
+
<polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
|
|
1060
|
+
<polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
|
|
1030
1061
|
</g>
|
|
1031
1062
|
<!-- center grip dots -->
|
|
1032
|
-
<circle cx="${
|
|
1033
|
-
<circle cx="${
|
|
1034
|
-
<circle cx="${
|
|
1063
|
+
<circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
|
|
1064
|
+
<circle cx="${l - 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
|
|
1065
|
+
<circle cx="${l + 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
|
|
1035
1066
|
</g>
|
|
1036
|
-
`),
|
|
1067
|
+
`), Et = te(`
|
|
1037
1068
|
<g>
|
|
1038
1069
|
<!-- shadow -->
|
|
1039
|
-
<g stroke="${
|
|
1040
|
-
<line x1="${
|
|
1041
|
-
<polyline points="${
|
|
1042
|
-
<polyline points="${
|
|
1070
|
+
<g stroke="${Z}" stroke-width="${ee}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1071
|
+
<line x1="${l}" y1="6" x2="${l}" y2="26"/>
|
|
1072
|
+
<polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
|
|
1073
|
+
<polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
|
|
1043
1074
|
</g>
|
|
1044
1075
|
<!-- main -->
|
|
1045
|
-
<g stroke="${
|
|
1046
|
-
<line x1="${
|
|
1047
|
-
<polyline points="${
|
|
1048
|
-
<polyline points="${
|
|
1076
|
+
<g stroke="${_}" stroke-width="${ce}" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
1077
|
+
<line x1="${l}" y1="6" x2="${l}" y2="26"/>
|
|
1078
|
+
<polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
|
|
1079
|
+
<polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
|
|
1049
1080
|
</g>
|
|
1050
1081
|
<!-- center grip dots -->
|
|
1051
|
-
<circle cx="${
|
|
1052
|
-
<circle cx="${
|
|
1053
|
-
<circle cx="${
|
|
1082
|
+
<circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
|
|
1083
|
+
<circle cx="${l}" cy="${l - 5}" r="1" fill="${_}" opacity="0.6"/>
|
|
1084
|
+
<circle cx="${l}" cy="${l + 5}" r="1" fill="${_}" opacity="0.6"/>
|
|
1054
1085
|
</g>
|
|
1055
1086
|
`);
|
|
1056
|
-
function
|
|
1057
|
-
return { css: `${
|
|
1087
|
+
function X(e, t, i) {
|
|
1088
|
+
return { css: `${Dt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
|
|
1058
1089
|
}
|
|
1059
|
-
const
|
|
1060
|
-
tap:
|
|
1061
|
-
hold:
|
|
1062
|
-
slideHorizontal:
|
|
1063
|
-
slideVertical:
|
|
1090
|
+
const L = {
|
|
1091
|
+
tap: X(Tt, 12, 4),
|
|
1092
|
+
hold: X(_t, 16, 16),
|
|
1093
|
+
slideHorizontal: X(zt, l, l),
|
|
1094
|
+
slideVertical: X(Et, l, l)
|
|
1064
1095
|
};
|
|
1065
|
-
function
|
|
1096
|
+
function ie() {
|
|
1066
1097
|
if (typeof window > "u") return null;
|
|
1067
1098
|
const e = window;
|
|
1068
1099
|
return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
|
|
1069
1100
|
}
|
|
1070
|
-
function
|
|
1101
|
+
function re(e) {
|
|
1071
1102
|
if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
|
|
1072
1103
|
try {
|
|
1073
1104
|
navigator.vibrate(e);
|
|
1074
1105
|
} catch {
|
|
1075
1106
|
}
|
|
1076
1107
|
}
|
|
1077
|
-
const
|
|
1108
|
+
const Ot = {
|
|
1078
1109
|
/** Light confirmation — fires when slide gesture arms after user holds still. */
|
|
1079
1110
|
tick() {
|
|
1080
|
-
const e =
|
|
1111
|
+
const e = ie();
|
|
1081
1112
|
if (e) {
|
|
1082
1113
|
e.impact({ style: "Light" }).catch(() => {
|
|
1083
1114
|
});
|
|
1084
1115
|
return;
|
|
1085
1116
|
}
|
|
1086
|
-
|
|
1117
|
+
re(8);
|
|
1087
1118
|
},
|
|
1088
1119
|
/** Medium bump — fires when hold gesture commits (detail opening). */
|
|
1089
1120
|
bump() {
|
|
1090
|
-
const e =
|
|
1121
|
+
const e = ie();
|
|
1091
1122
|
if (e) {
|
|
1092
1123
|
e.impact({ style: "Medium" }).catch(() => {
|
|
1093
1124
|
});
|
|
1094
1125
|
return;
|
|
1095
1126
|
}
|
|
1096
|
-
|
|
1127
|
+
re(20);
|
|
1097
1128
|
},
|
|
1098
1129
|
/** Stronger pulse — reserved for edit-mode pickup (future use). */
|
|
1099
1130
|
pulse() {
|
|
1100
|
-
const e =
|
|
1131
|
+
const e = ie();
|
|
1101
1132
|
if (e) {
|
|
1102
1133
|
e.impact({ style: "Heavy" }).catch(() => {
|
|
1103
1134
|
});
|
|
1104
1135
|
return;
|
|
1105
1136
|
}
|
|
1106
|
-
|
|
1137
|
+
re([0, 15, 40, 15]);
|
|
1107
1138
|
}
|
|
1108
1139
|
};
|
|
1109
|
-
function
|
|
1140
|
+
function Zt(e, t) {
|
|
1110
1141
|
const n = {
|
|
1111
1142
|
isDown: !1,
|
|
1112
1143
|
isTouch: !1,
|
|
@@ -1118,92 +1149,101 @@ function Gt(e, t) {
|
|
|
1118
1149
|
holdTimer: null,
|
|
1119
1150
|
element: null
|
|
1120
1151
|
};
|
|
1121
|
-
let o = null,
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1152
|
+
let o = null, u = null, d = null;
|
|
1153
|
+
const [$, m] = V(null);
|
|
1154
|
+
function h(s) {
|
|
1155
|
+
s !== u && (d && d.disconnect(), d = new ResizeObserver((f) => {
|
|
1156
|
+
const b = f[0];
|
|
1125
1157
|
if (b) {
|
|
1126
|
-
const
|
|
1127
|
-
|
|
1158
|
+
const C = b.borderBoxSize?.[0];
|
|
1159
|
+
C ? o = { width: C.inlineSize, height: C.blockSize } : o = { width: b.contentRect.width, height: b.contentRect.height }, m(o.height > o.width);
|
|
1128
1160
|
}
|
|
1129
|
-
}),
|
|
1161
|
+
}), u = s, d.observe(s), o = { width: s.clientWidth, height: s.clientHeight }, m(o.height > o.width));
|
|
1130
1162
|
}
|
|
1131
|
-
const
|
|
1163
|
+
const v = () => {
|
|
1132
1164
|
n.holdTimer && (clearTimeout(n.holdTimer), n.holdTimer = null);
|
|
1133
|
-
},
|
|
1165
|
+
}, y = () => {
|
|
1134
1166
|
n.isDown = !1, n.hasMoved = !1, n.sliding = !1;
|
|
1135
|
-
},
|
|
1167
|
+
}, g = (s) => {
|
|
1136
1168
|
const b = e().slide;
|
|
1137
|
-
return b?.orientation === "horizontal" ? "horizontal" : b?.orientation === "vertical" ? "vertical" :
|
|
1138
|
-
},
|
|
1139
|
-
const
|
|
1140
|
-
if (!(!
|
|
1141
|
-
if (n.isDown = !0, n.isTouch =
|
|
1142
|
-
const b =
|
|
1169
|
+
return b?.orientation === "horizontal" ? "horizontal" : b?.orientation === "vertical" ? "vertical" : s && (o || h(s), o) ? o.height > o.width ? "vertical" : "horizontal" : (t?.() ?? "horizontal") === "horizontal" ? "horizontal" : "vertical";
|
|
1170
|
+
}, a = (s) => {
|
|
1171
|
+
const f = e();
|
|
1172
|
+
if (!(!f.tap && !f.hold && !f.slide)) {
|
|
1173
|
+
if (n.isDown = !0, n.isTouch = s.pointerType === "touch", n.element = s.currentTarget, h(n.element), n.startX = s.clientX, n.startY = s.clientY, n.startTime = Date.now(), n.hasMoved = !1, n.sliding = !1, f.hold) {
|
|
1174
|
+
const b = f.hold.delay ?? 300;
|
|
1143
1175
|
n.holdTimer = setTimeout(() => {
|
|
1144
|
-
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (
|
|
1176
|
+
n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Ot.bump(), f.hold?.action(), n.isDown = !1);
|
|
1145
1177
|
}, b);
|
|
1146
1178
|
}
|
|
1147
|
-
if (!n.isTouch &&
|
|
1179
|
+
if (!n.isTouch && f.slide)
|
|
1148
1180
|
try {
|
|
1149
|
-
|
|
1181
|
+
s.currentTarget.setPointerCapture(s.pointerId);
|
|
1150
1182
|
} catch {
|
|
1151
1183
|
}
|
|
1152
1184
|
}
|
|
1153
|
-
},
|
|
1185
|
+
}, S = (s) => {
|
|
1154
1186
|
if (!n.isDown) return;
|
|
1155
|
-
const
|
|
1156
|
-
if (Math.sqrt(b * b +
|
|
1157
|
-
const D =
|
|
1187
|
+
const f = e(), b = s.clientX - n.startX, C = s.clientY - n.startY;
|
|
1188
|
+
if (Math.sqrt(b * b + C * C) > 10 && (v(), n.hasMoved = !0), f.slide && n.hasMoved) {
|
|
1189
|
+
const D = s.currentTarget, c = g(D);
|
|
1190
|
+
if (n.isTouch && !n.sliding) {
|
|
1191
|
+
const ye = Math.abs(c === "vertical" ? C : b), $e = Math.abs(c === "vertical" ? b : C);
|
|
1192
|
+
if (ye < $e) return;
|
|
1193
|
+
}
|
|
1158
1194
|
n.sliding = !0;
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1195
|
+
const F = f.slide.min ?? 0, N = f.slide.max ?? 100, ve = N - F, we = c === "vertical" ? -C : b, de = o ?? { width: D.clientWidth, height: D.clientHeight }, pe = c === "vertical" ? de.height : de.width, be = we / pe * ve, xe = Math.max(F, Math.min(N, f.slide.value + be));
|
|
1196
|
+
f.slide.onChange(Math.round(xe)), n.startX = s.clientX, n.startY = s.clientY, s.preventDefault();
|
|
1161
1197
|
}
|
|
1162
|
-
},
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1198
|
+
}, w = (s) => {
|
|
1199
|
+
const f = e(), b = n.isDown, C = Date.now() - n.startTime, E = f.hold?.delay ?? 300;
|
|
1200
|
+
v(), b && f.tap && !n.hasMoved && C < E && f.tap();
|
|
1165
1201
|
try {
|
|
1166
|
-
|
|
1202
|
+
s.currentTarget.releasePointerCapture(s.pointerId);
|
|
1167
1203
|
} catch {
|
|
1168
1204
|
}
|
|
1169
|
-
|
|
1170
|
-
},
|
|
1171
|
-
|
|
1205
|
+
y();
|
|
1206
|
+
}, M = (s) => {
|
|
1207
|
+
v();
|
|
1172
1208
|
try {
|
|
1173
|
-
|
|
1209
|
+
s.currentTarget.releasePointerCapture(s.pointerId);
|
|
1174
1210
|
} catch {
|
|
1175
1211
|
}
|
|
1176
|
-
|
|
1177
|
-
},
|
|
1178
|
-
const
|
|
1179
|
-
if (
|
|
1180
|
-
const b =
|
|
1181
|
-
return b === "horizontal" ?
|
|
1212
|
+
y();
|
|
1213
|
+
}, z = (s) => {
|
|
1214
|
+
const f = e();
|
|
1215
|
+
if (f.slide) {
|
|
1216
|
+
const b = f.slide.orientation;
|
|
1217
|
+
return b === "horizontal" ? L.slideHorizontal.css : b === "vertical" ? L.slideVertical.css : (o || h(s), o && o.height > o.width ? L.slideVertical.css : L.slideHorizontal.css);
|
|
1182
1218
|
}
|
|
1183
|
-
return
|
|
1219
|
+
return f.tap ? L.tap.css : f.hold ? L.hold.css : "";
|
|
1184
1220
|
};
|
|
1185
1221
|
return {
|
|
1186
|
-
onPointerDown:
|
|
1187
|
-
onPointerMove:
|
|
1188
|
-
onPointerUp:
|
|
1189
|
-
onPointerCancel:
|
|
1190
|
-
onPointerEnter: (
|
|
1191
|
-
const
|
|
1192
|
-
n.element =
|
|
1222
|
+
onPointerDown: a,
|
|
1223
|
+
onPointerMove: S,
|
|
1224
|
+
onPointerUp: w,
|
|
1225
|
+
onPointerCancel: M,
|
|
1226
|
+
onPointerEnter: (s) => {
|
|
1227
|
+
const f = s.currentTarget;
|
|
1228
|
+
n.element = f, f.style.cursor = z(f);
|
|
1193
1229
|
},
|
|
1194
|
-
bindElement: (
|
|
1195
|
-
|
|
1230
|
+
bindElement: (s) => {
|
|
1231
|
+
s && (n.element = s, h(s));
|
|
1196
1232
|
},
|
|
1197
1233
|
touchAction: () => {
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1234
|
+
const s = e();
|
|
1235
|
+
if (s.slide) {
|
|
1236
|
+
const f = s.slide.orientation;
|
|
1237
|
+
return f === "vertical" || f !== "horizontal" && ($() ?? (t?.() ?? "horizontal") !== "horizontal") ? "pan-x" : "pan-y";
|
|
1238
|
+
}
|
|
1239
|
+
return s.tap || s.hold ? "manipulation" : "auto";
|
|
1200
1240
|
},
|
|
1201
1241
|
dispose: () => {
|
|
1202
|
-
|
|
1242
|
+
v(), d && (d.disconnect(), d = null), u = null, o = null;
|
|
1203
1243
|
}
|
|
1204
1244
|
};
|
|
1205
1245
|
}
|
|
1206
|
-
const
|
|
1246
|
+
const Nt = {
|
|
1207
1247
|
solar: "oklch(0.74 0.18 60)",
|
|
1208
1248
|
grid: "oklch(0.62 0.12 245)",
|
|
1209
1249
|
battery: "oklch(0.70 0.18 145)",
|
|
@@ -1213,23 +1253,23 @@ const Mt = {
|
|
|
1213
1253
|
// Fault red-orange; used only for faults, never normal consumption.
|
|
1214
1254
|
negative: "oklch(0.64 0.22 27)"
|
|
1215
1255
|
};
|
|
1216
|
-
function
|
|
1256
|
+
function At(e) {
|
|
1217
1257
|
return {
|
|
1218
1258
|
fill: `color-mix(in oklch, ${e} 20%, transparent)`,
|
|
1219
1259
|
stroke: e,
|
|
1220
1260
|
solid: e
|
|
1221
1261
|
};
|
|
1222
1262
|
}
|
|
1223
|
-
const
|
|
1224
|
-
Object.entries(
|
|
1225
|
-
),
|
|
1263
|
+
const en = Object.fromEntries(
|
|
1264
|
+
Object.entries(Nt).map(([e, t]) => [e, At(t)])
|
|
1265
|
+
), tn = A.enum([
|
|
1226
1266
|
"success",
|
|
1227
1267
|
"warning",
|
|
1228
1268
|
"danger",
|
|
1229
1269
|
"info",
|
|
1230
1270
|
"neutral",
|
|
1231
1271
|
"accent"
|
|
1232
|
-
]),
|
|
1272
|
+
]), nn = {
|
|
1233
1273
|
/** Optional display name override (renders as text input) */
|
|
1234
1274
|
title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
|
|
1235
1275
|
/** Multi-select entity picker for a HA domain */
|
|
@@ -1239,68 +1279,94 @@ const qt = Object.fromEntries(
|
|
|
1239
1279
|
/** Area picker dropdown */
|
|
1240
1280
|
areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
|
|
1241
1281
|
};
|
|
1242
|
-
function
|
|
1282
|
+
function rn(e) {
|
|
1243
1283
|
if (e.length < 2) return "";
|
|
1244
1284
|
const t = e[0], i = e[1];
|
|
1245
1285
|
if (!t || !i) return "";
|
|
1246
1286
|
if (e.length === 2) return `M ${t.x} ${t.y} L ${i.x} ${i.y}`;
|
|
1247
|
-
const r = e.length, n = [], o = [],
|
|
1248
|
-
for (let
|
|
1249
|
-
const
|
|
1250
|
-
!
|
|
1287
|
+
const r = e.length, n = [], o = [], u = [];
|
|
1288
|
+
for (let m = 0; m < r - 1; m++) {
|
|
1289
|
+
const h = e[m], v = e[m + 1];
|
|
1290
|
+
!h || !v || (n.push(v.x - h.x), o.push(v.y - h.y), u.push((v.y - h.y) / (v.x - h.x)));
|
|
1251
1291
|
}
|
|
1252
|
-
const
|
|
1253
|
-
for (let
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1256
|
-
3 * (
|
|
1292
|
+
const d = [u[0] ?? 0];
|
|
1293
|
+
for (let m = 1; m < r - 1; m++) {
|
|
1294
|
+
const h = u[m - 1] ?? 0, v = u[m] ?? 0, y = n[m - 1] ?? 0, g = n[m] ?? 0;
|
|
1295
|
+
h * v <= 0 ? d.push(0) : d.push(
|
|
1296
|
+
3 * (y + g) / ((2 * g + y) / h + (g + 2 * y) / v)
|
|
1257
1297
|
);
|
|
1258
1298
|
}
|
|
1259
|
-
|
|
1260
|
-
let
|
|
1261
|
-
for (let
|
|
1262
|
-
const
|
|
1263
|
-
if (!
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1299
|
+
d.push(u[r - 2] ?? 0);
|
|
1300
|
+
let $ = `M ${t.x} ${t.y}`;
|
|
1301
|
+
for (let m = 0; m < r - 1; m++) {
|
|
1302
|
+
const h = e[m], v = e[m + 1];
|
|
1303
|
+
if (!h || !v) continue;
|
|
1304
|
+
const y = (n[m] ?? 0) / 3, g = d[m] ?? 0, a = d[m + 1] ?? 0;
|
|
1305
|
+
$ += ` C ${h.x + y} ${h.y + g * y}, ${v.x - y} ${v.y - a * y}, ${v.x} ${v.y}`;
|
|
1266
1306
|
}
|
|
1267
|
-
return
|
|
1307
|
+
return $;
|
|
1268
1308
|
}
|
|
1269
|
-
function
|
|
1309
|
+
function on() {
|
|
1270
1310
|
return document.documentElement.classList.contains("dark");
|
|
1271
1311
|
}
|
|
1272
|
-
const
|
|
1273
|
-
version:
|
|
1274
|
-
},
|
|
1312
|
+
const Vt = "1.0.0", Wt = {
|
|
1313
|
+
version: Vt
|
|
1314
|
+
}, an = Wt.version;
|
|
1275
1315
|
export {
|
|
1276
|
-
|
|
1277
|
-
|
|
1316
|
+
an as SDK_VERSION,
|
|
1317
|
+
tn as ToneSchema,
|
|
1278
1318
|
B as Widget,
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1319
|
+
Ue as WidgetContent,
|
|
1320
|
+
Q as WidgetCtx,
|
|
1321
|
+
Yt as WidgetDialog,
|
|
1322
|
+
Ge as WidgetIcon,
|
|
1323
|
+
cn as WidgetManifestSchema,
|
|
1324
|
+
Ie as WidgetSliderFill,
|
|
1325
|
+
Ye as WidgetStatus,
|
|
1326
|
+
Je as WidgetTitle,
|
|
1327
|
+
ot as WidgetValue,
|
|
1328
|
+
gn as byDomain,
|
|
1329
|
+
Qe as calculateLightGroup,
|
|
1330
|
+
Ze as calculateSensorGroup,
|
|
1331
|
+
qt as countActiveEntities,
|
|
1332
|
+
Bt as defineWidget,
|
|
1333
|
+
dn as formatSchemaError,
|
|
1334
|
+
Gt as getEntityAttribute,
|
|
1335
|
+
En as getForecasts,
|
|
1336
|
+
On as getStream,
|
|
1337
|
+
Nn as getWebRtcClientConfig,
|
|
1338
|
+
Ne as injectTokens,
|
|
1339
|
+
on as isDark,
|
|
1340
|
+
et as isEntityActive,
|
|
1341
|
+
rn as monotoneCubicPath,
|
|
1342
|
+
An as sendWebRtcCandidate,
|
|
1343
|
+
Vn as startWebRtcSession,
|
|
1344
|
+
Wn as state,
|
|
1345
|
+
en as svgColors,
|
|
1346
|
+
Rn as trackEntityHistory,
|
|
1347
|
+
Hn as untrackEntityHistory,
|
|
1348
|
+
hn as useArea,
|
|
1349
|
+
fn as useCamera,
|
|
1350
|
+
mn as useConnection,
|
|
1351
|
+
vn as useCurrency,
|
|
1352
|
+
wn as useEntities,
|
|
1353
|
+
pn as useEntity,
|
|
1354
|
+
bn as useEntityHistory,
|
|
1355
|
+
xn as useEntityStatistics,
|
|
1356
|
+
yn as useForecast,
|
|
1357
|
+
$n as useHassConfig,
|
|
1358
|
+
Kt as useIntersectionPause,
|
|
1359
|
+
kn as useLocale,
|
|
1360
|
+
Xt as useReducedMotion,
|
|
1361
|
+
Cn as useService,
|
|
1362
|
+
Sn as useStore,
|
|
1363
|
+
Mn as useTemperatureUnit,
|
|
1364
|
+
Dn as useToggle,
|
|
1365
|
+
Tn as useTurnOn,
|
|
1366
|
+
_n as useUnitSystem,
|
|
1367
|
+
Ft as useWidgetContext,
|
|
1368
|
+
Jt as useWidgetDialog,
|
|
1369
|
+
Qt as useWidgetEntityGroup,
|
|
1370
|
+
Zt as useWidgetGestures,
|
|
1371
|
+
nn as widgetFields
|
|
1306
1372
|
};
|