@glasshome/widget-sdk 1.0.0 → 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/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { z as A } from "zod";
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";
2
+ import { widgetManifestSchema as xn, formatSchemaError as yn } from "@glasshome/widget-contract";
3
+ import { effect as W, className as I, style as le, template as x, insert as p, createComponent as k, memo as T, setStyleProperty as ee, addEventListener as K, use as Se, delegateEvents as Ce } from "solid-js/web";
4
+ import { createElementSize as Me } from "@solid-primitives/resize-observer";
5
+ import { createContext as De, useContext as B, Show as E, createSignal as V, onMount as Te, createMemo as j, splitProps as _e, createEffect as se, on as ge, onCleanup as ce } from "solid-js";
6
+ import { clsx as Oe } from "clsx";
7
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) {
8
+ import { useService as Ee, useToggle as Ne, useTurnOff as Ae, useTurnOn as Ve } from "@glasshome/sync-layer/solid";
9
+ import { byDomain as kn, useArea as Sn, useCamera as Cn, useConnection as Mn, useCurrency as Dn, useEntities as Tn, useEntity as _n, useEntityHistory as On, useEntityStatistics as zn, useForecast as En, useHassConfig as Nn, useLocale as An, useStore as Vn, useTemperatureUnit as Wn, useUnitSystem as Rn } from "@glasshome/sync-layer/solid";
10
+ import { getForecasts as Pn, getStream as In, getWebRtcClientConfig as Ln, sendWebRtcCandidate as Un, startWebRtcSession as jn, state as Bn, trackEntityHistory as Fn, untrackEntityHistory as Gn } from "@glasshome/sync-layer";
11
+ function me(e) {
11
12
  return A.toJSONSchema(e, {
12
13
  override: (t) => {
13
14
  const i = A.globalRegistry.get(t.zodSchema);
@@ -15,17 +16,53 @@ function fe(e) {
15
16
  }
16
17
  });
17
18
  }
18
- function Ee(e) {
19
+ function We(e) {
19
20
  try {
20
21
  return e.parse({});
21
22
  } catch {
22
23
  return {};
23
24
  }
24
25
  }
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;
26
+ function Jt(e) {
27
+ return e.configSchema && (e.manifest.schema || (e.manifest.schema = me(e.configSchema)), e.manifest.defaultConfig || (e.manifest.defaultConfig = We(e.configSchema))), e;
28
+ }
29
+ const P = De();
30
+ function Qt() {
31
+ const e = B(P);
32
+ if (!e)
33
+ throw new Error("useWidgetContext must be used within a Widget component");
34
+ return e;
35
+ }
36
+ function Re(e) {
37
+ const t = Array.isArray(e) ? e[0] : e, i = t?.split(".")[0];
38
+ if (!i) throw new Error(`Invalid entity ID: ${String(t)}`);
39
+ return i;
40
+ }
41
+ function G(e, t) {
42
+ return (i, r = {}) => e(Re(i), t, r, { entity_id: i });
27
43
  }
28
- const Y = {
44
+ function Zt() {
45
+ const e = B(P)?.callService;
46
+ return e ? {
47
+ callService: e,
48
+ turnOn: G(e, "turn_on"),
49
+ turnOff: G(e, "turn_off"),
50
+ toggle: G(e, "toggle")
51
+ } : Ee();
52
+ }
53
+ function en() {
54
+ const e = B(P)?.callService;
55
+ return e ? G(e, "turn_on") : Ve();
56
+ }
57
+ function tn() {
58
+ const e = B(P)?.callService;
59
+ return e ? G(e, "turn_off") : Ae();
60
+ }
61
+ function nn() {
62
+ const e = B(P)?.callService;
63
+ return e ? G(e, "toggle") : Ne();
64
+ }
65
+ const J = {
29
66
  /** Background layer (gradients, images, glows) */
30
67
  BACKGROUND: 0,
31
68
  /** Main content layer (icon, title, text) */
@@ -34,14 +71,7 @@ const Y = {
34
71
  OVERLAY: 20,
35
72
  /** Action layer (buttons, edit controls) */
36
73
  ACTIONS: 30
37
- }, Q = Me();
38
- function Ft() {
39
- const e = se(Q);
40
- if (!e)
41
- throw new Error("useWidgetContext must be used within a Widget component");
42
- return e;
43
- }
44
- const me = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
74
+ }, ve = `/* Authoritative SDK CSS contract. Injected once on first Widget mount
45
75
  * via framework/theming/tokens.ts.
46
76
  *
47
77
  * All widget-internal visual scale is driven from CSS custom properties +
@@ -213,34 +243,34 @@ const me = `/* Authoritative SDK CSS contract. Injected once on first Widget mou
213
243
  }
214
244
  }
215
245
  `;
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) {
246
+ let re = !1, Q;
247
+ const he = /* @__PURE__ */ new WeakSet();
248
+ function He() {
249
+ return Q || (Q = new CSSStyleSheet(), Q.replaceSync(
250
+ ve.replace(/:root\b/g, ":host").replace(/^\.dark\b/gm, ":host(.dark)")
251
+ )), Q;
252
+ }
253
+ function Pe(e) {
224
254
  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);
255
+ if (he.has(e)) return;
256
+ const r = He();
257
+ e.adoptedStyleSheets.includes(r) || (e.adoptedStyleSheets = [...e.adoptedStyleSheets, r]), he.add(e);
228
258
  return;
229
259
  }
230
- if (ne) return;
260
+ if (re) return;
231
261
  const t = e ?? (typeof document > "u" ? void 0 : document);
232
262
  if (!t) return;
233
263
  if (t.head.querySelector?.("style[data-glasshome-tokens]")) {
234
- ne = !0;
264
+ re = !0;
235
265
  return;
236
266
  }
237
267
  const i = t.createElement("style");
238
- i.setAttribute("data-glasshome-tokens", ""), i.textContent = me, t.head.appendChild(i), ne = !0;
268
+ i.setAttribute("data-glasshome-tokens", ""), i.textContent = ve, t.head.appendChild(i), re = !0;
239
269
  }
240
270
  function R(...e) {
241
- return ze(_e(e));
271
+ return ze(Oe(e));
242
272
  }
243
- const Ae = {
273
+ const Ie = {
244
274
  id: "classic-glass",
245
275
  name: "Classic Glass",
246
276
  description: "Default glassmorphism design with blur background and gradient",
@@ -268,7 +298,7 @@ const Ae = {
268
298
  hoverScale: 1.02,
269
299
  activeScale: 0.98
270
300
  }
271
- }, Ve = {
301
+ }, Le = {
272
302
  id: "minimal",
273
303
  name: "Minimal",
274
304
  description: "Clean, minimal design with no background effects",
@@ -297,7 +327,7 @@ const Ae = {
297
327
  active: !1,
298
328
  focus: !0
299
329
  }
300
- }, We = {
330
+ }, Ue = {
301
331
  id: "compact-horizontal",
302
332
  name: "Compact Horizontal",
303
333
  description: "Horizontal layout for compact widgets",
@@ -325,108 +355,108 @@ const Ae = {
325
355
  hoverScale: 1.02,
326
356
  activeScale: 0.98
327
357
  }
328
- }, Re = {
329
- "classic-glass": Ae,
330
- minimal: Ve,
331
- "compact-horizontal": We
358
+ }, je = {
359
+ "classic-glass": Ie,
360
+ minimal: Le,
361
+ "compact-horizontal": Ue
332
362
  };
333
- function He(e) {
334
- return Re[e];
363
+ function Be(e) {
364
+ return je[e];
335
365
  }
336
- var Pe = /* @__PURE__ */ x("<div>");
337
- function Ie(e) {
366
+ var Fe = /* @__PURE__ */ x("<div>");
367
+ function Ge(e) {
338
368
  return (() => {
339
- var t = Pe();
369
+ var t = Fe();
340
370
  return W((i) => {
341
371
  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 = {
342
372
  "--widget-fill-value": e.value,
343
- "z-index": Y.BACKGROUND,
373
+ "z-index": J.BACKGROUND,
344
374
  ...e.color ? {
345
375
  "--widget-icon-color": e.color
346
376
  } : {}
347
377
  };
348
- return r !== i.e && P(t, i.e = r), i.t = ae(t, n, i.t), i;
378
+ return r !== i.e && I(t, i.e = r), i.t = le(t, n, i.t), i;
349
379
  }, {
350
380
  e: void 0,
351
381
  t: void 0
352
382
  }), t;
353
383
  })();
354
384
  }
355
- var Le = /* @__PURE__ */ x("<div>");
356
- function Ue(e) {
385
+ var qe = /* @__PURE__ */ x("<div>");
386
+ function Ye(e) {
357
387
  return (() => {
358
- var t = Le();
359
- return p(t, () => e.children), W(() => P(t, R("glasshome-widget-content", e.class))), t;
388
+ var t = qe();
389
+ return p(t, () => e.children), W(() => I(t, R("glasshome-widget-content", e.class))), t;
360
390
  })();
361
391
  }
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) {
392
+ var Ke = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-2">'), Xe = /* @__PURE__ */ x('<div class="glasshome-widget-icon glasshome-widget-icon-stack glasshome-widget-icon-stack-3">'), Je = /* @__PURE__ */ x('<div><div class="glasshome-widget-icon-glyph flex items-center justify-center">');
393
+ function Qe(e) {
364
394
  const t = () => e.entityCount ?? 1;
365
395
  return (() => {
366
- var i = Fe(), r = i.firstChild;
367
- return p(i, k(O, {
396
+ var i = Je(), r = i.firstChild;
397
+ return p(i, k(E, {
368
398
  get when() {
369
399
  return t() >= 2;
370
400
  },
371
401
  get children() {
372
- return je();
402
+ return Ke();
373
403
  }
374
- }), r), p(i, k(O, {
404
+ }), r), p(i, k(E, {
375
405
  get when() {
376
406
  return t() >= 3;
377
407
  },
378
408
  get children() {
379
- return Be();
409
+ return Xe();
380
410
  }
381
411
  }), r), p(r, () => e.icon), W((n) => {
382
412
  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 ? {
383
413
  "--widget-icon-color": e.color
384
414
  } : void 0;
385
- return o !== n.e && P(i, n.e = o), n.t = ae(i, u, n.t), n;
415
+ return o !== n.e && I(i, n.e = o), n.t = le(i, u, n.t), n;
386
416
  }, {
387
417
  e: void 0,
388
418
  t: void 0
389
419
  }), i;
390
420
  })();
391
421
  }
392
- var qe = /* @__PURE__ */ x("<p>");
393
- function Ye(e) {
422
+ var Ze = /* @__PURE__ */ x("<p>");
423
+ function et(e) {
394
424
  return (() => {
395
- var t = qe();
425
+ var t = Ze();
396
426
  return p(t, (() => {
397
427
  var i = T(() => !!e.isUnavailable);
398
428
  return () => i() ? "Unavailable" : e.children;
399
429
  })()), W((i) => {
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;
430
+ var r = R("glasshome-widget-status", "relative", e.dimmed && "opacity-40", e.class), n = J.ACTIONS;
431
+ return r !== i.e && I(t, i.e = r), n !== i.t && ee(t, "z-index", i.t = n), i;
402
432
  }, {
403
433
  e: void 0,
404
434
  t: void 0
405
435
  }), t;
406
436
  })();
407
437
  }
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) {
438
+ var tt = /* @__PURE__ */ x('<span class="glasshome-widget-badge shrink-0">'), nt = /* @__PURE__ */ x("<div><h3 class=glasshome-widget-title>");
439
+ function it(e) {
410
440
  return (() => {
411
- var t = Xe(), i = t.firstChild;
412
- return p(i, () => e.children), p(t, k(O, {
441
+ var t = nt(), i = t.firstChild;
442
+ return p(i, () => e.children), p(t, k(E, {
413
443
  get when() {
414
444
  return T(() => e.badge !== void 0)() && e.badge > 0;
415
445
  },
416
446
  get children() {
417
- var r = Ke();
447
+ var r = tt();
418
448
  return p(r, () => e.badge), r;
419
449
  }
420
450
  }), null), W((r) => {
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;
451
+ var n = R("relative flex items-center gap-2", e.class), o = J.ACTIONS;
452
+ return n !== r.e && I(t, r.e = n), o !== r.t && ee(t, "z-index", r.t = o), r;
423
453
  }, {
424
454
  e: void 0,
425
455
  t: void 0
426
456
  }), t;
427
457
  })();
428
458
  }
429
- function Qe(e, t = !1) {
459
+ function rt(e, t = !1) {
430
460
  if (e.length === 0)
431
461
  return {
432
462
  isGroup: !1,
@@ -442,15 +472,15 @@ function Qe(e, t = !1) {
442
472
  };
443
473
  const i = e.length > 1;
444
474
  if (!i) {
445
- const s = e[0], f = s.state === "on", b = s.attributes?.brightness || 0, C = Math.round(b / 255 * 100);
475
+ const s = e[0], f = s.state === "on", b = s.attributes?.brightness || 0, S = Math.round(b / 255 * 100);
446
476
  return {
447
477
  isGroup: !1,
448
478
  state: s.state,
449
479
  isOn: f,
450
480
  isUnavailable: s.state === "unavailable",
451
481
  brightness: b,
452
- brightnessPercent: C,
453
- color: he(s),
482
+ brightnessPercent: S,
483
+ color: fe(s),
454
484
  onCount: f ? 1 : 0,
455
485
  totalCount: 1,
456
486
  description: f ? "On" : "Off"
@@ -473,31 +503,31 @@ function Qe(e, t = !1) {
473
503
  u++;
474
504
  break;
475
505
  }
476
- const h = e.length, v = u === h, y = o + u === h, g = r > 0, a = r === h, S = n === h;
506
+ const h = e.length, v = u === h, y = o + u === h, g = r > 0, a = r === h, C = n === h;
477
507
  let w, M;
478
508
  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;
509
+ const O = $ > 0 ? Math.round(d / $) : 0, L = Math.round(O / 255 * 100);
510
+ let F;
481
511
  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)})`;
512
+ const s = Math.round(m.reduce((z, D) => z + D[0], 0) / m.length), f = Math.round(m.reduce((z, D) => z + D[1], 0) / m.length), b = Math.round(m.reduce((z, D) => z + D[2], 0) / m.length), S = O / 255;
513
+ F = `rgb(${Math.round(s * S)}, ${Math.round(f * S)}, ${Math.round(b * S)})`;
484
514
  } else
485
- j = he(e[0]);
515
+ F = fe(e[0]);
486
516
  let H;
487
- return a ? H = "All on" : S ? H = "All off" : r > 0 ? H = `${r} of ${h} on` : H = "Off", {
517
+ return a ? H = "All on" : C ? H = "All off" : r > 0 ? H = `${r} of ${h} on` : H = "Off", {
488
518
  isGroup: i,
489
519
  state: w,
490
520
  isOn: M,
491
521
  isUnavailable: w === "unavailable",
492
- brightness: z,
493
- brightnessPercent: I,
494
- color: j,
522
+ brightness: O,
523
+ brightnessPercent: L,
524
+ color: F,
495
525
  onCount: r,
496
526
  totalCount: h,
497
527
  description: H
498
528
  };
499
529
  }
500
- function Ze(e, t = "mean", i = !0) {
530
+ function ot(e, t = "mean", i = !0) {
501
531
  if (e.length === 0)
502
532
  return {
503
533
  isGroup: !1,
@@ -509,14 +539,14 @@ function Ze(e, t = "mean", i = !0) {
509
539
  const r = e.length > 1;
510
540
  if (!r) {
511
541
  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)), {
542
+ let C = g.state;
543
+ return Number.isNaN(a) || (C = Number.isInteger(a) ? a.toString() : a.toFixed(1)), {
514
544
  isGroup: !1,
515
- state: S,
545
+ state: C,
516
546
  numericValue: Number.isNaN(a) ? null : a,
517
547
  isUnavailable: g.state === "unavailable",
518
548
  unit: g.unitOfMeasurement ?? void 0,
519
- description: S
549
+ description: C
520
550
  };
521
551
  }
522
552
  const n = [], o = [];
@@ -564,7 +594,7 @@ function Ze(e, t = "mean", i = !0) {
564
594
  h = n.reduce((g, a) => g + a, 0) / n.length, v = "Average";
565
595
  break;
566
596
  case "median": {
567
- const g = [...n].sort((S, w) => S - w), a = Math.floor(g.length / 2);
597
+ const g = [...n].sort((C, w) => C - w), a = Math.floor(g.length / 2);
568
598
  h = g.length % 2 === 0 ? (g[a - 1] + g[a]) / 2 : g[a], v = "Median";
569
599
  break;
570
600
  }
@@ -581,7 +611,7 @@ function Ze(e, t = "mean", i = !0) {
581
611
  h = n.reduce((g, a) => g * a, 1), v = "Product";
582
612
  break;
583
613
  case "std_dev": {
584
- const g = n.reduce((S, w) => S + w, 0) / n.length, a = n.reduce((S, w) => S + (w - g) ** 2, 0) / n.length;
614
+ const g = n.reduce((C, w) => C + w, 0) / n.length, a = n.reduce((C, w) => C + (w - g) ** 2, 0) / n.length;
585
615
  h = Math.sqrt(a), v = "Std Dev";
586
616
  break;
587
617
  }
@@ -599,7 +629,7 @@ function Ze(e, t = "mean", i = !0) {
599
629
  memberValues: o
600
630
  };
601
631
  }
602
- function he(e) {
632
+ function fe(e) {
603
633
  if (e.state !== "on") return "rgb(100, 100, 100)";
604
634
  const i = (e.attributes?.brightness ?? 255) / 255;
605
635
  if (e.attributes?.rgb_color) {
@@ -613,7 +643,7 @@ function he(e) {
613
643
  }
614
644
  return `rgb(${Math.round(255 * i)}, ${Math.round(220 * i)}, ${Math.round(180 * i)})`;
615
645
  }
616
- function et(e) {
646
+ function at(e) {
617
647
  if (!e) return !1;
618
648
  if (["on", "open", "locked", "home", "playing", "active"].includes(e.state))
619
649
  return !0;
@@ -623,13 +653,13 @@ function et(e) {
623
653
  }
624
654
  return !1;
625
655
  }
626
- function Gt(e, t, i) {
656
+ function rn(e, t, i) {
627
657
  return e?.attributes ? e.attributes[t] ?? i : i;
628
658
  }
629
- function qt(e) {
630
- return e.filter(et).length;
659
+ function on(e) {
660
+ return e.filter(at).length;
631
661
  }
632
- function tt(e, t, i) {
662
+ function st(e, t, i) {
633
663
  const { decimals: r, scale: n = !0 } = {};
634
664
  if (typeof e == "string")
635
665
  return t ? `${e}${t}` : e;
@@ -640,44 +670,45 @@ function tt(e, t, i) {
640
670
  let d;
641
671
  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;
642
672
  }
643
- function nt(e, t) {
673
+ function lt(e, t) {
644
674
  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;
645
675
  }
646
- var it = /* @__PURE__ */ x("<div class=glasshome-widget-subtitle>"), rt = /* @__PURE__ */ x("<div><div class=glasshome-widget-value>");
647
- function ot(e) {
676
+ var ct = /* @__PURE__ */ x("<div class=glasshome-widget-subtitle>"), dt = /* @__PURE__ */ x("<div><div class=glasshome-widget-value>");
677
+ function ut(e) {
648
678
  return (() => {
649
- var t = rt(), i = t.firstChild;
650
- return p(i, () => tt(e.value, e.unit)), p(t, k(O, {
679
+ var t = dt(), i = t.firstChild;
680
+ return p(i, () => st(e.value, e.unit)), p(t, k(E, {
651
681
  get when() {
652
682
  return T(() => !!e.interpret)() && typeof e.value == "number";
653
683
  },
654
684
  get children() {
655
- var r = it();
656
- return p(r, () => nt(e.value, e.unit)), r;
685
+ var r = ct();
686
+ return p(r, () => lt(e.value, e.unit)), r;
657
687
  }
658
- }), null), W(() => P(t, R("flex flex-col", e.class))), t;
688
+ }), null), W(() => I(t, R("flex flex-col", e.class))), t;
659
689
  })();
660
690
  }
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(() => {
691
+ var gt = /* @__PURE__ */ x('<div><div class="relative h-full w-full">'), ht = /* @__PURE__ */ x('<div class="glasshome-widget-loading pointer-events-none absolute inset-0 animate-pulse">'), ft = /* @__PURE__ */ x('<div class="flex h-full w-full flex-col items-center justify-center gap-2 text-center">'), mt = /* @__PURE__ */ x('<div class="flex items-center justify-center text-white/30">'), vt = /* @__PURE__ */ x('<h3 class="font-semibold text-sm text-white/60">'), wt = /* @__PURE__ */ x('<p class="text-white/50 text-xs">');
692
+ function pt(e) {
693
+ const t = B(P), [i, r] = V(), n = Me(i);
694
+ Te(() => {
665
695
  const a = i()?.getRootNode();
666
- Ne(typeof ShadowRoot < "u" && a instanceof ShadowRoot || typeof Document < "u" && a instanceof Document ? a : void 0);
696
+ Pe(typeof ShadowRoot < "u" && a instanceof ShadowRoot || typeof Document < "u" && a instanceof Document ? a : void 0);
667
697
  });
668
698
  const o = {
669
699
  isEditMode: () => e.isEditMode ?? !1,
670
700
  updateConfig: t?.updateConfig ?? (() => {
671
701
  }),
672
702
  registerDialogOpener: t?.registerDialogOpener,
703
+ callService: t?.callService,
673
704
  dimensions: () => ({
674
705
  width: n.width ?? 0,
675
706
  height: n.height ?? 0
676
707
  })
677
- }, u = U(() => {
708
+ }, u = j(() => {
678
709
  if (e.variant)
679
- return typeof e.variant == "string" ? He(e.variant) : e.variant;
680
- }), d = U(() => ({
710
+ return typeof e.variant == "string" ? Be(e.variant) : e.variant;
711
+ }), d = j(() => ({
681
712
  "container-type": "size",
682
713
  "container-name": "widget",
683
714
  "touch-action": e.gestures && !e.isEditMode ? e.gestures.touchAction() : void 0,
@@ -706,15 +737,15 @@ function gt(e) {
706
737
  }, g = (a) => {
707
738
  $() && e.gestures?.onPointerCancel(a);
708
739
  };
709
- return k(Q.Provider, {
740
+ return k(P.Provider, {
710
741
  value: o,
711
742
  get children() {
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) => {
743
+ var a = gt(), C = a.firstChild;
744
+ return K(a, "pointercancel", g), K(a, "pointerup", y), K(a, "pointermove", v), K(a, "pointerdown", h), K(a, "pointerenter", m), Se((w) => {
714
745
  r(w), e.gestures?.bindElement(w);
715
- }, a), p(S, (() => {
746
+ }, a), p(C, (() => {
716
747
  var w = T(() => !!e.emptyState);
717
- return () => w() ? k(ht, {
748
+ return () => w() ? k(bt, {
718
749
  get icon() {
719
750
  return e.emptyState.icon;
720
751
  },
@@ -728,12 +759,12 @@ function gt(e) {
728
759
  })()), p(a, (() => {
729
760
  var w = T(() => !!e.loading);
730
761
  return () => w() && (() => {
731
- var M = st();
732
- return W((z) => J(M, "z-index", Y.OVERLAY)), M;
762
+ var M = ht();
763
+ return W((O) => ee(M, "z-index", J.OVERLAY)), M;
733
764
  })();
734
765
  })(), null), W((w) => {
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;
766
+ 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), O = d(), L = J.CONTENT;
767
+ return M !== w.e && I(a, w.e = M), w.t = le(a, O, w.t), L !== w.a && ee(C, "z-index", w.a = L), w;
737
768
  }, {
738
769
  e: void 0,
739
770
  t: void 0,
@@ -742,60 +773,60 @@ function gt(e) {
742
773
  }
743
774
  });
744
775
  }
745
- function ht(e) {
776
+ function bt(e) {
746
777
  return (() => {
747
- var t = lt();
778
+ var t = ft();
748
779
  return p(t, (() => {
749
780
  var i = T(() => !!e.icon);
750
781
  return () => i() && (() => {
751
- var r = ct();
782
+ var r = mt();
752
783
  return p(r, () => e.icon), r;
753
784
  })();
754
785
  })(), null), p(t, (() => {
755
786
  var i = T(() => !!e.title);
756
787
  return () => i() && (() => {
757
- var r = dt();
788
+ var r = vt();
758
789
  return p(r, () => e.title), r;
759
790
  })();
760
791
  })(), null), p(t, (() => {
761
792
  var i = T(() => !!e.message);
762
793
  return () => i() && (() => {
763
- var r = ut();
794
+ var r = wt();
764
795
  return p(r, () => e.message), r;
765
796
  })();
766
797
  })(), null), t;
767
798
  })();
768
799
  }
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) {
800
+ const q = pt;
801
+ q.Content = Ye;
802
+ q.Icon = Qe;
803
+ q.Title = it;
804
+ q.Status = et;
805
+ q.Value = ut;
806
+ q.SliderFill = Ge;
807
+ var xt = /* @__PURE__ */ x('<span class="inline-flex size-3.5 shrink-0 items-center">'), yt = /* @__PURE__ */ x("<button type=button>"), $t = /* @__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">'), kt = /* @__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'), St = /* @__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>'), Ct = /* @__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'), Mt = /* @__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">'), Dt = /* @__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'), Tt = /* @__PURE__ */ x('<div class="min-w-0 shrink-0">'), _t = /* @__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">'), Ot = /* @__PURE__ */ x('<div class="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">'), zt = /* @__PURE__ */ x('<div class="flex shrink-0 items-center justify-end gap-2 border-border/50 border-t pt-3">');
808
+ function Et(e) {
778
809
  return (() => {
779
- var t = mt();
780
- return t.$$click = () => e.onClick(), p(t, k(O, {
810
+ var t = yt();
811
+ return t.$$click = () => e.onClick(), p(t, k(E, {
781
812
  get when() {
782
813
  return e.isActive;
783
814
  },
784
815
  get children() {
785
- var i = ft();
816
+ var i = xt();
786
817
  return p(i, () => e.icon), i;
787
818
  }
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;
819
+ }), null), p(t, () => e.label, null), W(() => I(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;
789
820
  })();
790
821
  }
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) => {
822
+ function an(e) {
823
+ const [t] = _e(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);
824
+ se(ge(() => t.config, (c) => {
794
825
  c && n({
795
826
  ...c
796
827
  });
797
- })), oe(ue(() => t.configSchema, (c) => {
798
- c && u(fe(c));
828
+ })), se(ge(() => t.configSchema, (c) => {
829
+ c && u(me(c));
799
830
  }));
800
831
  const d = () => i() && JSON.stringify(r()) !== JSON.stringify(t.config), $ = (c) => {
801
832
  !c && t.config && n({
@@ -816,13 +847,13 @@ function Yt(e) {
816
847
  "3xl": "max-w-3xl",
817
848
  "4xl": "max-w-4xl"
818
849
  }[c];
819
- }, S = () => {
850
+ }, C = () => {
820
851
  if (t.tabs) return t.tabs;
821
852
  const c = [];
822
853
  return c.push({
823
854
  id: "edit",
824
855
  label: "Edit",
825
- icon: vt(),
856
+ icon: $t(),
826
857
  content: t.editContent ?? (i() && o() ? k(b, {
827
858
  get schema() {
828
859
  return o();
@@ -831,17 +862,17 @@ function Yt(e) {
831
862
  return r();
832
863
  },
833
864
  onChange: n
834
- }) : wt())
865
+ }) : kt())
835
866
  }), c.push({
836
867
  id: "controls",
837
868
  label: "Controls",
838
- icon: pt(),
839
- content: t.controlsContent ?? bt()
869
+ icon: St(),
870
+ content: t.controlsContent ?? Ct()
840
871
  }), c.push({
841
872
  id: "debug",
842
873
  label: "Debug",
843
- icon: xt(),
844
- content: t.debugContent ?? yt()
874
+ icon: Mt(),
875
+ content: t.debugContent ?? Dt()
845
876
  }), c;
846
877
  }, w = async () => {
847
878
  if (t.debugData !== void 0)
@@ -851,25 +882,25 @@ function Yt(e) {
851
882
  } catch {
852
883
  }
853
884
  }, M = () => {
854
- const c = S();
885
+ const c = C();
855
886
  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, {
887
+ }, O = t.ResponsiveDialog, L = t.ResponsiveDialogContent, F = t.ResponsiveDialogHeader, H = t.ResponsiveDialogTitle, s = t.ResponsiveDialogDescription, f = t.Button, b = t.SchemaForm, S = (c) => i() ? $(c) : t.onOpenChange(c), z = () => i() ? d() : t.hasUnsavedChanges, D = () => i() ? m : t.onSave;
888
+ return k(O, {
858
889
  get open() {
859
890
  return t.open;
860
891
  },
861
- onOpenChange: (c) => C(c),
892
+ onOpenChange: (c) => S(c),
862
893
  get children() {
863
- return k(I, {
894
+ return k(L, {
864
895
  get class() {
865
896
  return R(a(), t.class);
866
897
  },
867
898
  get children() {
868
- return [k(j, {
899
+ return [k(F, {
869
900
  class: "flex flex-row items-center justify-between gap-3",
870
901
  get children() {
871
902
  return [(() => {
872
- var c = $t();
903
+ var c = Tt();
873
904
  return p(c, k(H, {
874
905
  class: "truncate leading-tight",
875
906
  get children() {
@@ -880,8 +911,8 @@ function Yt(e) {
880
911
  children: "Widget configuration dialog"
881
912
  }), null), c;
882
913
  })(), (() => {
883
- var c = kt(), F = c.firstChild;
884
- return p(F, () => S().map((N) => k(Mt, {
914
+ var c = _t(), Y = c.firstChild;
915
+ return p(Y, () => C().map((N) => k(Et, {
885
916
  get icon() {
886
917
  return N.icon;
887
918
  },
@@ -892,7 +923,7 @@ function Yt(e) {
892
923
  return y() === N.id;
893
924
  },
894
925
  onClick: () => g(N.id)
895
- }))), p(c, k(O, {
926
+ }))), p(c, k(E, {
896
927
  get when() {
897
928
  return t.headerActions;
898
929
  },
@@ -903,15 +934,15 @@ function Yt(e) {
903
934
  })()];
904
935
  }
905
936
  }), (() => {
906
- var c = Ct();
937
+ var c = Ot();
907
938
  return p(c, M), c;
908
- })(), k(O, {
939
+ })(), k(E, {
909
940
  get when() {
910
941
  return T(() => y() === "edit")() && (D() || t.onDelete) || y() === "debug" && t.debugData !== void 0;
911
942
  },
912
943
  get children() {
913
- var c = St();
914
- return p(c, k(O, {
944
+ var c = zt();
945
+ return p(c, k(E, {
915
946
  get when() {
916
947
  return T(() => y() === "edit")() && t.onDelete;
917
948
  },
@@ -923,7 +954,7 @@ function Yt(e) {
923
954
  children: "Delete"
924
955
  });
925
956
  }
926
- }), null), p(c, k(O, {
957
+ }), null), p(c, k(E, {
927
958
  get when() {
928
959
  return T(() => y() === "edit")() && D();
929
960
  },
@@ -931,13 +962,13 @@ function Yt(e) {
931
962
  return k(f, {
932
963
  size: "sm",
933
964
  get disabled() {
934
- return !E();
965
+ return !z();
935
966
  },
936
967
  onClick: () => D()?.(),
937
968
  children: "Save"
938
969
  });
939
970
  }
940
- }), null), p(c, k(O, {
971
+ }), null), p(c, k(E, {
941
972
  get when() {
942
973
  return T(() => y() === "debug")() && t.debugData !== void 0;
943
974
  },
@@ -958,29 +989,29 @@ function Yt(e) {
958
989
  });
959
990
  }
960
991
  Ce(["click"]);
961
- function Kt(e) {
992
+ function sn(e) {
962
993
  if (typeof IntersectionObserver > "u")
963
994
  return () => !1;
964
995
  const [t, i] = V(!1), r = new IntersectionObserver((n) => {
965
996
  const o = n[0];
966
997
  o && i(!o.isIntersecting);
967
998
  });
968
- return oe(() => {
999
+ return se(() => {
969
1000
  const n = e();
970
1001
  r.disconnect(), n && r.observe(n);
971
- }), le(() => r.disconnect()), t;
1002
+ }), ce(() => r.disconnect()), t;
972
1003
  }
973
- function Xt() {
1004
+ function ln() {
974
1005
  if (typeof window > "u" || typeof window.matchMedia != "function")
975
1006
  return () => !1;
976
1007
  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;
1008
+ return e.addEventListener("change", r), ce(() => e.removeEventListener("change", r)), t;
978
1009
  }
979
- function Jt(e = "controls") {
1010
+ function cn(e = "controls") {
980
1011
  const [t, i] = V(!1), [r, n] = V(e), o = (d) => {
981
1012
  n(d ?? e), i(!0);
982
- }, u = se(Q);
983
- return u?.registerDialogOpener?.(o), le(() => u?.registerDialogOpener?.(null)), {
1013
+ }, u = B(P);
1014
+ return u?.registerDialogOpener?.(o), ce(() => u?.registerDialogOpener?.(null)), {
984
1015
  showDialog: t,
985
1016
  setShowDialog: i,
986
1017
  openDialog: o,
@@ -999,19 +1030,19 @@ function Jt(e = "controls") {
999
1030
  }
1000
1031
  };
1001
1032
  }
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(() => {
1033
+ function dn(e) {
1034
+ const t = e.minEntities ?? 1, i = j(() => e.entities().length), r = j(() => i() >= t), n = j(() => !r() || !e.calculateGroupData ? null : e.calculateGroupData(e.entities())), o = j(() => {
1004
1035
  if (!r()) return;
1005
1036
  const d = e.aggregationMode?.();
1006
1037
  if (!d || d === "none") return;
1007
1038
  const $ = e.entities();
1008
1039
  if (d === "light" || d === "binary-sensor" || d === "switch")
1009
- return Qe($, e.allEntitiesMode);
1040
+ return rt($, e.allEntitiesMode);
1010
1041
  if (d === "sensor") {
1011
1042
  const m = e.sensorGroupType?.() ?? "mean";
1012
- return Ze($, m, !0);
1043
+ return ot($, m, !0);
1013
1044
  }
1014
- }), u = U(() => r() ? void 0 : e.emptyStateConfig);
1045
+ }), u = j(() => r() ? void 0 : e.emptyStateConfig);
1015
1046
  return {
1016
1047
  entities: e.entities,
1017
1048
  groupData: n,
@@ -1021,40 +1052,40 @@ function Qt(e) {
1021
1052
  count: i
1022
1053
  };
1023
1054
  }
1024
- const q = 32, l = q / 2, _ = "white", Z = "rgba(0,0,0,0.4)", ce = 2, ee = 3;
1025
- function Dt(e) {
1055
+ const X = 32, l = X / 2, _ = "white", te = "rgba(0,0,0,0.4)", de = 2, ne = 3;
1056
+ function Nt(e) {
1026
1057
  return `url("data:image/svg+xml,${encodeURIComponent(e)}")`;
1027
1058
  }
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>`;
1059
+ function ie(e) {
1060
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${X}" height="${X}" viewBox="0 0 ${X} ${X}">${e}</svg>`;
1030
1061
  }
1031
- const Tt = te(`
1062
+ const At = ie(`
1032
1063
  <g transform="translate(6, 2)">
1033
1064
  <!-- shadow -->
1034
- <g stroke="${Z}" stroke-width="${ee}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1065
+ <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1035
1066
  <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"/>
1036
1067
  </g>
1037
1068
  <!-- main -->
1038
- <g stroke="${_}" stroke-width="${ce}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1069
+ <g stroke="${_}" stroke-width="${de}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1039
1070
  <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"/>
1040
1071
  </g>
1041
1072
  </g>
1042
- `), _t = te(`
1073
+ `), Vt = ie(`
1043
1074
  <g>
1044
- <circle cx="${l}" cy="${l}" r="8" stroke="${Z}" stroke-width="${ee}" fill="none"/>
1075
+ <circle cx="${l}" cy="${l}" r="8" stroke="${te}" stroke-width="${ne}" fill="none"/>
1045
1076
  <circle cx="${l}" cy="${l}" r="8" stroke="${_}" stroke-width="1.5" fill="none"/>
1046
1077
  <circle cx="${l}" cy="${l}" r="1.5" fill="${_}"/>
1047
1078
  </g>
1048
- `), zt = te(`
1079
+ `), Wt = ie(`
1049
1080
  <g>
1050
1081
  <!-- shadow -->
1051
- <g stroke="${Z}" stroke-width="${ee}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1082
+ <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1052
1083
  <line x1="6" y1="${l}" x2="26" y2="${l}"/>
1053
1084
  <polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
1054
1085
  <polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
1055
1086
  </g>
1056
1087
  <!-- main -->
1057
- <g stroke="${_}" stroke-width="${ce}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1088
+ <g stroke="${_}" stroke-width="${de}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1058
1089
  <line x1="6" y1="${l}" x2="26" y2="${l}"/>
1059
1090
  <polyline points="10,${l - 4} 6,${l} 10,${l + 4}"/>
1060
1091
  <polyline points="22,${l - 4} 26,${l} 22,${l + 4}"/>
@@ -1064,16 +1095,16 @@ const Tt = te(`
1064
1095
  <circle cx="${l - 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
1065
1096
  <circle cx="${l + 5}" cy="${l}" r="1" fill="${_}" opacity="0.6"/>
1066
1097
  </g>
1067
- `), Et = te(`
1098
+ `), Rt = ie(`
1068
1099
  <g>
1069
1100
  <!-- shadow -->
1070
- <g stroke="${Z}" stroke-width="${ee}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1101
+ <g stroke="${te}" stroke-width="${ne}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1071
1102
  <line x1="${l}" y1="6" x2="${l}" y2="26"/>
1072
1103
  <polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
1073
1104
  <polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
1074
1105
  </g>
1075
1106
  <!-- main -->
1076
- <g stroke="${_}" stroke-width="${ce}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1107
+ <g stroke="${_}" stroke-width="${de}" fill="none" stroke-linecap="round" stroke-linejoin="round">
1077
1108
  <line x1="${l}" y1="6" x2="${l}" y2="26"/>
1078
1109
  <polyline points="${l - 4},10 ${l},6 ${l + 4},10"/>
1079
1110
  <polyline points="${l - 4},22 ${l},26 ${l + 4},22"/>
@@ -1084,60 +1115,60 @@ const Tt = te(`
1084
1115
  <circle cx="${l}" cy="${l + 5}" r="1" fill="${_}" opacity="0.6"/>
1085
1116
  </g>
1086
1117
  `);
1087
- function X(e, t, i) {
1088
- return { css: `${Dt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
1089
- }
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)
1118
+ function Z(e, t, i) {
1119
+ return { css: `${Nt(e)} ${t} ${i}, auto`, hotspotX: t, hotspotY: i };
1120
+ }
1121
+ const U = {
1122
+ tap: Z(At, 12, 4),
1123
+ hold: Z(Vt, 16, 16),
1124
+ slideHorizontal: Z(Wt, l, l),
1125
+ slideVertical: Z(Rt, l, l)
1095
1126
  };
1096
- function ie() {
1127
+ function oe() {
1097
1128
  if (typeof window > "u") return null;
1098
1129
  const e = window;
1099
1130
  return e.Capacitor?.isNativePlatform?.() ? e.Capacitor.Plugins?.Haptics ?? null : null;
1100
1131
  }
1101
- function re(e) {
1132
+ function ae(e) {
1102
1133
  if (!(typeof navigator > "u" || typeof navigator.vibrate != "function"))
1103
1134
  try {
1104
1135
  navigator.vibrate(e);
1105
1136
  } catch {
1106
1137
  }
1107
1138
  }
1108
- const Ot = {
1139
+ const Ht = {
1109
1140
  /** Light confirmation — fires when slide gesture arms after user holds still. */
1110
1141
  tick() {
1111
- const e = ie();
1142
+ const e = oe();
1112
1143
  if (e) {
1113
1144
  e.impact({ style: "Light" }).catch(() => {
1114
1145
  });
1115
1146
  return;
1116
1147
  }
1117
- re(8);
1148
+ ae(8);
1118
1149
  },
1119
1150
  /** Medium bump — fires when hold gesture commits (detail opening). */
1120
1151
  bump() {
1121
- const e = ie();
1152
+ const e = oe();
1122
1153
  if (e) {
1123
1154
  e.impact({ style: "Medium" }).catch(() => {
1124
1155
  });
1125
1156
  return;
1126
1157
  }
1127
- re(20);
1158
+ ae(20);
1128
1159
  },
1129
1160
  /** Stronger pulse — reserved for edit-mode pickup (future use). */
1130
1161
  pulse() {
1131
- const e = ie();
1162
+ const e = oe();
1132
1163
  if (e) {
1133
1164
  e.impact({ style: "Heavy" }).catch(() => {
1134
1165
  });
1135
1166
  return;
1136
1167
  }
1137
- re([0, 15, 40, 15]);
1168
+ ae([0, 15, 40, 15]);
1138
1169
  }
1139
1170
  };
1140
- function Zt(e, t) {
1171
+ function un(e, t) {
1141
1172
  const n = {
1142
1173
  isDown: !1,
1143
1174
  isTouch: !1,
@@ -1155,8 +1186,8 @@ function Zt(e, t) {
1155
1186
  s !== u && (d && d.disconnect(), d = new ResizeObserver((f) => {
1156
1187
  const b = f[0];
1157
1188
  if (b) {
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);
1189
+ const S = b.borderBoxSize?.[0];
1190
+ S ? o = { width: S.inlineSize, height: S.blockSize } : o = { width: b.contentRect.width, height: b.contentRect.height }, m(o.height > o.width);
1160
1191
  }
1161
1192
  }), u = s, d.observe(s), o = { width: s.clientWidth, height: s.clientHeight }, m(o.height > o.width));
1162
1193
  }
@@ -1173,7 +1204,7 @@ function Zt(e, t) {
1173
1204
  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
1205
  const b = f.hold.delay ?? 300;
1175
1206
  n.holdTimer = setTimeout(() => {
1176
- n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Ot.bump(), f.hold?.action(), n.isDown = !1);
1207
+ n.holdTimer = null, !(!n.isDown || n.hasMoved) && (Ht.bump(), f.hold?.action(), n.isDown = !1);
1177
1208
  }, b);
1178
1209
  }
1179
1210
  if (!n.isTouch && f.slide)
@@ -1182,22 +1213,22 @@ function Zt(e, t) {
1182
1213
  } catch {
1183
1214
  }
1184
1215
  }
1185
- }, S = (s) => {
1216
+ }, C = (s) => {
1186
1217
  if (!n.isDown) return;
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) {
1218
+ const f = e(), b = s.clientX - n.startX, S = s.clientY - n.startY;
1219
+ if (Math.sqrt(b * b + S * S) > 10 && (v(), n.hasMoved = !0), f.slide && n.hasMoved) {
1189
1220
  const D = s.currentTarget, c = g(D);
1190
1221
  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;
1222
+ const $e = Math.abs(c === "vertical" ? S : b), ke = Math.abs(c === "vertical" ? b : S);
1223
+ if ($e < ke) return;
1193
1224
  }
1194
1225
  n.sliding = !0;
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();
1226
+ const Y = f.slide.min ?? 0, N = f.slide.max ?? 100, we = N - Y, pe = c === "vertical" ? -S : b, ue = o ?? { width: D.clientWidth, height: D.clientHeight }, be = c === "vertical" ? ue.height : ue.width, xe = pe / be * we, ye = Math.max(Y, Math.min(N, f.slide.value + xe));
1227
+ f.slide.onChange(Math.round(ye)), n.startX = s.clientX, n.startY = s.clientY, s.preventDefault();
1197
1228
  }
1198
1229
  }, 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();
1230
+ const f = e(), b = n.isDown, S = Date.now() - n.startTime, z = f.hold?.delay ?? 300;
1231
+ v(), b && f.tap && !n.hasMoved && S < z && f.tap();
1201
1232
  try {
1202
1233
  s.currentTarget.releasePointerCapture(s.pointerId);
1203
1234
  } catch {
@@ -1210,22 +1241,22 @@ function Zt(e, t) {
1210
1241
  } catch {
1211
1242
  }
1212
1243
  y();
1213
- }, z = (s) => {
1244
+ }, O = (s) => {
1214
1245
  const f = e();
1215
1246
  if (f.slide) {
1216
1247
  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);
1248
+ return b === "horizontal" ? U.slideHorizontal.css : b === "vertical" ? U.slideVertical.css : (o || h(s), o && o.height > o.width ? U.slideVertical.css : U.slideHorizontal.css);
1218
1249
  }
1219
- return f.tap ? L.tap.css : f.hold ? L.hold.css : "";
1250
+ return f.tap ? U.tap.css : f.hold ? U.hold.css : "";
1220
1251
  };
1221
1252
  return {
1222
1253
  onPointerDown: a,
1223
- onPointerMove: S,
1254
+ onPointerMove: C,
1224
1255
  onPointerUp: w,
1225
1256
  onPointerCancel: M,
1226
1257
  onPointerEnter: (s) => {
1227
1258
  const f = s.currentTarget;
1228
- n.element = f, f.style.cursor = z(f);
1259
+ n.element = f, f.style.cursor = O(f);
1229
1260
  },
1230
1261
  bindElement: (s) => {
1231
1262
  s && (n.element = s, h(s));
@@ -1243,7 +1274,7 @@ function Zt(e, t) {
1243
1274
  }
1244
1275
  };
1245
1276
  }
1246
- const Nt = {
1277
+ const Pt = {
1247
1278
  solar: "oklch(0.74 0.18 60)",
1248
1279
  grid: "oklch(0.62 0.12 245)",
1249
1280
  battery: "oklch(0.70 0.18 145)",
@@ -1253,23 +1284,23 @@ const Nt = {
1253
1284
  // Fault red-orange; used only for faults, never normal consumption.
1254
1285
  negative: "oklch(0.64 0.22 27)"
1255
1286
  };
1256
- function At(e) {
1287
+ function It(e) {
1257
1288
  return {
1258
1289
  fill: `color-mix(in oklch, ${e} 20%, transparent)`,
1259
1290
  stroke: e,
1260
1291
  solid: e
1261
1292
  };
1262
1293
  }
1263
- const en = Object.fromEntries(
1264
- Object.entries(Nt).map(([e, t]) => [e, At(t)])
1265
- ), tn = A.enum([
1294
+ const gn = Object.fromEntries(
1295
+ Object.entries(Pt).map(([e, t]) => [e, It(t)])
1296
+ ), hn = A.enum([
1266
1297
  "success",
1267
1298
  "warning",
1268
1299
  "danger",
1269
1300
  "info",
1270
1301
  "neutral",
1271
1302
  "accent"
1272
- ]), nn = {
1303
+ ]), fn = {
1273
1304
  /** Optional display name override (renders as text input) */
1274
1305
  title: () => A.string().optional().meta({ title: "Title", description: "Optional display name override" }),
1275
1306
  /** Multi-select entity picker for a HA domain */
@@ -1279,7 +1310,7 @@ const en = Object.fromEntries(
1279
1310
  /** Area picker dropdown */
1280
1311
  areaId: () => A.string().optional().meta({ formType: "area-picker", title: "Area" })
1281
1312
  };
1282
- function rn(e) {
1313
+ function mn(e) {
1283
1314
  if (e.length < 2) return "";
1284
1315
  const t = e[0], i = e[1];
1285
1316
  if (!t || !i) return "";
@@ -1306,67 +1337,68 @@ function rn(e) {
1306
1337
  }
1307
1338
  return $;
1308
1339
  }
1309
- function on() {
1340
+ function vn() {
1310
1341
  return document.documentElement.classList.contains("dark");
1311
1342
  }
1312
- const Vt = "1.0.0", Wt = {
1313
- version: Vt
1314
- }, an = Wt.version;
1343
+ const Lt = "1.1.0", Ut = {
1344
+ version: Lt
1345
+ }, wn = Ut.version;
1315
1346
  export {
1316
- an as SDK_VERSION,
1317
- tn as ToneSchema,
1318
- B as Widget,
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
1347
+ wn as SDK_VERSION,
1348
+ hn as ToneSchema,
1349
+ q as Widget,
1350
+ Ye as WidgetContent,
1351
+ P as WidgetCtx,
1352
+ an as WidgetDialog,
1353
+ Qe as WidgetIcon,
1354
+ xn as WidgetManifestSchema,
1355
+ Ge as WidgetSliderFill,
1356
+ et as WidgetStatus,
1357
+ it as WidgetTitle,
1358
+ ut as WidgetValue,
1359
+ kn as byDomain,
1360
+ rt as calculateLightGroup,
1361
+ ot as calculateSensorGroup,
1362
+ on as countActiveEntities,
1363
+ Jt as defineWidget,
1364
+ yn as formatSchemaError,
1365
+ rn as getEntityAttribute,
1366
+ Pn as getForecasts,
1367
+ In as getStream,
1368
+ Ln as getWebRtcClientConfig,
1369
+ Pe as injectTokens,
1370
+ vn as isDark,
1371
+ at as isEntityActive,
1372
+ mn as monotoneCubicPath,
1373
+ Un as sendWebRtcCandidate,
1374
+ jn as startWebRtcSession,
1375
+ Bn as state,
1376
+ gn as svgColors,
1377
+ Fn as trackEntityHistory,
1378
+ Gn as untrackEntityHistory,
1379
+ Sn as useArea,
1380
+ Cn as useCamera,
1381
+ Mn as useConnection,
1382
+ Dn as useCurrency,
1383
+ Tn as useEntities,
1384
+ _n as useEntity,
1385
+ On as useEntityHistory,
1386
+ zn as useEntityStatistics,
1387
+ En as useForecast,
1388
+ Nn as useHassConfig,
1389
+ sn as useIntersectionPause,
1390
+ An as useLocale,
1391
+ ln as useReducedMotion,
1392
+ Zt as useService,
1393
+ Vn as useStore,
1394
+ Wn as useTemperatureUnit,
1395
+ nn as useToggle,
1396
+ tn as useTurnOff,
1397
+ en as useTurnOn,
1398
+ Rn as useUnitSystem,
1399
+ Qt as useWidgetContext,
1400
+ cn as useWidgetDialog,
1401
+ dn as useWidgetEntityGroup,
1402
+ un as useWidgetGestures,
1403
+ fn as widgetFields
1372
1404
  };