@justanarthur/modo-ui-notch 0.2.0 → 0.4.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.
Files changed (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +29 -5
  3. package/blocks/activities/agenda/index.tsx +438 -181
  4. package/blocks/activities/clock/examples.mdx +89 -0
  5. package/blocks/activities/clock/index.tsx +917 -0
  6. package/blocks/activities/now-playing/examples.mdx +40 -13
  7. package/blocks/activities/now-playing/index.tsx +399 -120
  8. package/blocks/activities/weather/examples.mdx +123 -0
  9. package/blocks/activities/weather/index.tsx +863 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +22 -4
  12. package/blocks/app/settings-window/examples.mdx +14 -2
  13. package/blocks/app/settings-window/index.tsx +33 -10
  14. package/blocks/system/clipboard/examples.mdx +91 -0
  15. package/blocks/system/clipboard/index.tsx +773 -0
  16. package/blocks/system/recent-files/examples.mdx +80 -0
  17. package/blocks/system/recent-files/index.tsx +627 -0
  18. package/blocks/system/system-stats/examples.mdx +46 -9
  19. package/blocks/system/system-stats/index.tsx +445 -104
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +465 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +2 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +3 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +4 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +3 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +3 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +3 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +3 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +32 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +104 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-0ym9mcqc.d.ts} +10 -6
  62. package/dist/shared/chunk-2b6gpn8k.js +444 -0
  63. package/dist/shared/chunk-3hcnf4yx.js +481 -0
  64. package/dist/shared/chunk-42wab62s.d.ts +197 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-6tnq6p89.d.ts} +9 -1
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-93dtpjz7.js +789 -0
  69. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  70. package/dist/shared/chunk-a6njb8db.d.ts +129 -0
  71. package/dist/shared/chunk-ab8mdg0n.d.ts +149 -0
  72. package/dist/shared/chunk-evqpf92s.d.ts +168 -0
  73. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  74. package/dist/shared/chunk-gcyspvgr.js +582 -0
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/chunk-gkj0hjrn.d.ts +136 -0
  77. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  78. package/dist/shared/chunk-n739am8j.d.ts +112 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/chunk-nwzpekvy.js +774 -0
  81. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  82. package/dist/shared/chunk-sbrtesdg.d.ts +138 -0
  83. package/dist/shared/chunk-swc7dqpw.d.ts +115 -0
  84. package/dist/shared/chunk-t9wqhgzt.js +765 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/{chunk-mp1nx0ez.js → chunk-wayv5rhr.js} +15 -4
  87. package/dist/shared/chunk-wf0jtzhs.js +295 -0
  88. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  89. package/dist/shared/chunk-yq5svpk7.js +524 -0
  90. package/dist/shared/{chunk-s33y1pcq.js → chunk-z3tj1ydg.js} +23 -10
  91. package/dist/styles.css +151 -49
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +113 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +78 -44
  100. package/mock/files.tsx +83 -0
  101. package/mock/island-content.tsx +79 -122
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +49 -0
  105. package/mock/weather.tsx +135 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -0,0 +1,774 @@
1
+ "use client";
2
+
3
+ import {
4
+ IslandFlash2
5
+ } from "./chunk-ndf79pv5.js";
6
+ import {
7
+ widget_default
8
+ } from "./chunk-wf0jtzhs.js";
9
+ import {
10
+ MINUTE2,
11
+ useEdgeClock2
12
+ } from "./chunk-gb56m10p.js";
13
+
14
+ // blocks/activities/weather/index.tsx
15
+ import Button from "@justanarthur/modo-ui/components/actions/button";
16
+ import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
17
+ import { useSize } from "@justanarthur/modo-ui/lib/size-context";
18
+ import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
19
+ import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
20
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
21
+ import Skeleton from "@justanarthur/modo-ui/primitives/content/skeleton";
22
+ import ScrollArea from "@justanarthur/modo-ui/primitives/layout/scroll-area";
23
+ import {
24
+ ArrowDown,
25
+ ArrowUp,
26
+ Cloud,
27
+ CloudDrizzle,
28
+ CloudFog,
29
+ CloudHail,
30
+ CloudLightning,
31
+ CloudMoon,
32
+ CloudOff,
33
+ CloudRain,
34
+ CloudRainWind,
35
+ CloudSnow,
36
+ CloudSun,
37
+ Droplets,
38
+ LocateOff,
39
+ MapPin,
40
+ Moon,
41
+ RotateCw,
42
+ Sun,
43
+ Sunrise,
44
+ Sunset,
45
+ Thermometer,
46
+ Umbrella,
47
+ WifiOff,
48
+ Wind
49
+ } from "lucide-react";
50
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
51
+ /*!
52
+ * Local addition: a notch app's weather, the temperature now, the next
53
+ * hours and tomorrow, with the location and loading states around it and a
54
+ * flash before rain. Presentational: the forecast comes in as props, shaped
55
+ * so a host can fill it from Open-Meteo (`conditionFromCode` reads its WMO
56
+ * weather codes).
57
+ */
58
+ var LABEL = {
59
+ clear: "Clear",
60
+ "partly-cloudy": "Partly cloudy",
61
+ cloudy: "Cloudy",
62
+ fog: "Fog",
63
+ drizzle: "Drizzle",
64
+ rain: "Rain",
65
+ "heavy-rain": "Heavy rain",
66
+ sleet: "Sleet",
67
+ snow: "Snow",
68
+ thunderstorm: "Thunderstorm"
69
+ };
70
+ var GLYPH = {
71
+ clear: Sun,
72
+ "partly-cloudy": CloudSun,
73
+ cloudy: Cloud,
74
+ fog: CloudFog,
75
+ drizzle: CloudDrizzle,
76
+ rain: CloudRain,
77
+ "heavy-rain": CloudRainWind,
78
+ sleet: CloudHail,
79
+ snow: CloudSnow,
80
+ thunderstorm: CloudLightning
81
+ };
82
+ var HUE = {
83
+ clear: "text-status-warning",
84
+ "partly-cloudy": "text-status-warning",
85
+ cloudy: "text-foreground",
86
+ fog: "text-foreground",
87
+ drizzle: "text-status-info",
88
+ rain: "text-status-info",
89
+ "heavy-rain": "text-status-info",
90
+ sleet: "text-status-info",
91
+ snow: "text-foreground",
92
+ thunderstorm: "text-status-info"
93
+ };
94
+ var HERO_GLYPH = { default: 30, compact: 24 };
95
+ var STRIP_GLYPH = { default: 16, compact: 14 };
96
+ var SHEET_GLYPH = { default: 44, compact: 36 };
97
+ var WET = 30;
98
+ var HOURS = 6;
99
+ var DAY_HOURS = 24;
100
+ var WEEK = 7;
101
+ function conditionFromCode2(code) {
102
+ if (code === 0)
103
+ return "clear";
104
+ if (code <= 2)
105
+ return "partly-cloudy";
106
+ if (code === 3)
107
+ return "cloudy";
108
+ if (code === 45 || code === 48)
109
+ return "fog";
110
+ if (code >= 51 && code <= 55)
111
+ return "drizzle";
112
+ if (code === 56 || code === 57 || code === 66 || code === 67)
113
+ return "sleet";
114
+ if (code === 65 || code === 82)
115
+ return "heavy-rain";
116
+ if (code >= 61 && code <= 63 || code === 80 || code === 81)
117
+ return "rain";
118
+ if (code >= 71 && code <= 77 || code === 85 || code === 86)
119
+ return "snow";
120
+ if (code >= 95)
121
+ return "thunderstorm";
122
+ return "cloudy";
123
+ }
124
+ function glyphFor(condition, isDay = true) {
125
+ if (!isDay && condition === "clear")
126
+ return Moon;
127
+ if (!isDay && condition === "partly-cloudy")
128
+ return CloudMoon;
129
+ return GLYPH[condition];
130
+ }
131
+ function hueFor(condition, isDay = true) {
132
+ if (!isDay && (condition === "clear" || condition === "partly-cloudy"))
133
+ return "text-foreground";
134
+ return HUE[condition];
135
+ }
136
+ var degrees = (celsius, unit) => Math.round(unit === "fahrenheit" ? celsius * 9 / 5 + 32 : celsius);
137
+ var temp = (celsius, unit) => `${degrees(celsius, unit)}°`;
138
+ var speed = (kmh, unit) => unit === "fahrenheit" ? `${Math.round(kmh / 1.609)} mph` : `${Math.round(kmh)} km/h`;
139
+ var hourOf = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric" });
140
+ var clockOf = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" });
141
+ function uvLevel(uv) {
142
+ if (uv < 3)
143
+ return "Low";
144
+ if (uv < 6)
145
+ return "Moderate";
146
+ if (uv < 8)
147
+ return "High";
148
+ if (uv < 11)
149
+ return "Very high";
150
+ return "Extreme";
151
+ }
152
+ function ago(ms) {
153
+ const minutes = Math.floor(ms / MINUTE2);
154
+ if (minutes < 1)
155
+ return "Just now";
156
+ if (minutes < 60)
157
+ return `${minutes} min ago`;
158
+ return `${Math.floor(minutes / 60)} h ago`;
159
+ }
160
+ function rainAhead(current, hours) {
161
+ if (HUE[current.condition] === "text-status-info")
162
+ return;
163
+ return hours.find((hour) => (hour.precipitation ?? 0) >= 50);
164
+ }
165
+ function Glyph({ condition, isDay, size, className }) {
166
+ const Icon = glyphFor(condition, isDay);
167
+ return /* @__PURE__ */ jsx(Icon, {
168
+ "aria-hidden": true,
169
+ size,
170
+ strokeWidth: 1.5,
171
+ className: cn("shrink-0", className)
172
+ });
173
+ }
174
+ function Hours({ hours, unit, locale }) {
175
+ const size = useSize();
176
+ const wet = hours.some((hour) => (hour.precipitation ?? 0) >= WET);
177
+ return /* @__PURE__ */ jsx("div", {
178
+ className: "flex min-w-0 justify-between",
179
+ children: hours.map((hour, i) => /* @__PURE__ */ jsxs("div", {
180
+ className: "flex min-w-0 flex-1 flex-col items-center gap-1 tabular-nums",
181
+ children: [
182
+ /* @__PURE__ */ jsx("span", {
183
+ className: "whitespace-nowrap text-caption text-muted-foreground",
184
+ children: i === 0 ? "Now" : hourOf(hour.time, locale)
185
+ }),
186
+ /* @__PURE__ */ jsx(Glyph, {
187
+ condition: hour.condition,
188
+ isDay: hour.isDay,
189
+ size: STRIP_GLYPH[size.variant],
190
+ className: "text-foreground"
191
+ }),
192
+ /* @__PURE__ */ jsx("span", {
193
+ className: "text-body text-foreground",
194
+ children: temp(hour.temperature, unit)
195
+ }),
196
+ wet && /* @__PURE__ */ jsx("span", {
197
+ className: "h-4 text-caption text-status-info",
198
+ children: (hour.precipitation ?? 0) >= WET && `${hour.precipitation}%`
199
+ })
200
+ ]
201
+ }, hour.time))
202
+ });
203
+ }
204
+ function Tomorrow({ day, unit }) {
205
+ return /* @__PURE__ */ jsx(widget_default.Row, {
206
+ leading: "Tomorrow",
207
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
208
+ children: [
209
+ (day.precipitation ?? 0) >= WET && /* @__PURE__ */ jsxs("span", {
210
+ className: "text-status-info",
211
+ children: [
212
+ day.precipitation,
213
+ "%"
214
+ ]
215
+ }),
216
+ /* @__PURE__ */ jsx("span", {
217
+ className: "text-foreground",
218
+ children: temp(day.high, unit)
219
+ }),
220
+ /* @__PURE__ */ jsx("span", {
221
+ children: temp(day.low, unit)
222
+ })
223
+ ]
224
+ }),
225
+ children: /* @__PURE__ */ jsxs("span", {
226
+ className: "flex min-w-0 items-center gap-2",
227
+ children: [
228
+ /* @__PURE__ */ jsx(Glyph, {
229
+ condition: day.condition,
230
+ size: 14,
231
+ className: "text-muted-foreground"
232
+ }),
233
+ /* @__PURE__ */ jsx("span", {
234
+ className: "truncate",
235
+ children: LABEL[day.condition]
236
+ })
237
+ ]
238
+ })
239
+ });
240
+ }
241
+ function HourStrip({ hours, unit, locale }) {
242
+ const size = useSize();
243
+ const temperatures = hours.map((hour) => hour.temperature);
244
+ const low = Math.min(...temperatures);
245
+ const wet = hours.some((hour) => (hour.precipitation ?? 0) >= WET);
246
+ return /* @__PURE__ */ jsx(ScrollArea, {
247
+ orientation: "horizontal",
248
+ viewportClassName: "scroll-fade-x",
249
+ children: /* @__PURE__ */ jsxs("div", {
250
+ className: "flex w-max flex-col gap-1.5 pb-3 tabular-nums",
251
+ children: [
252
+ /* @__PURE__ */ jsx("div", {
253
+ className: "flex",
254
+ children: hours.map((hour, i) => /* @__PURE__ */ jsxs("div", {
255
+ className: "flex w-12 shrink-0 flex-col items-center gap-1.5",
256
+ children: [
257
+ /* @__PURE__ */ jsx("span", {
258
+ className: "whitespace-nowrap text-caption text-muted-foreground",
259
+ children: i === 0 ? "Now" : hourOf(hour.time, locale)
260
+ }),
261
+ /* @__PURE__ */ jsx(Glyph, {
262
+ condition: hour.condition,
263
+ isDay: hour.isDay,
264
+ size: STRIP_GLYPH[size.variant],
265
+ className: hueFor(hour.condition, hour.isDay)
266
+ })
267
+ ]
268
+ }, hour.time))
269
+ }),
270
+ /* @__PURE__ */ jsx("div", {
271
+ className: "px-6",
272
+ children: /* @__PURE__ */ jsx(Sparkline, {
273
+ values: temperatures.map((value) => value - low),
274
+ max: Math.max(...temperatures) - low,
275
+ label: `Temperature over the next ${hours.length} hours`,
276
+ tone: "muted"
277
+ })
278
+ }),
279
+ /* @__PURE__ */ jsx("div", {
280
+ className: "flex",
281
+ children: hours.map((hour) => /* @__PURE__ */ jsxs("div", {
282
+ className: "flex w-12 shrink-0 flex-col items-center gap-0.5",
283
+ children: [
284
+ /* @__PURE__ */ jsx("span", {
285
+ className: "text-body text-foreground",
286
+ children: temp(hour.temperature, unit)
287
+ }),
288
+ wet && /* @__PURE__ */ jsx("span", {
289
+ className: "h-4 text-caption text-status-info",
290
+ children: (hour.precipitation ?? 0) >= WET && `${hour.precipitation}%`
291
+ })
292
+ ]
293
+ }, hour.time))
294
+ })
295
+ ]
296
+ })
297
+ });
298
+ }
299
+ function Week({ days, unit, locale }) {
300
+ const low = Math.min(...days.map((day) => day.low));
301
+ const span = Math.max(...days.map((day) => day.high)) - low || 1;
302
+ return days.map((day, i) => /* @__PURE__ */ jsxs("div", {
303
+ className: "flex h-8 min-w-0 items-center gap-3 text-body tabular-nums",
304
+ children: [
305
+ /* @__PURE__ */ jsx("span", {
306
+ className: "w-12 shrink-0 truncate text-foreground",
307
+ children: i === 0 ? "Today" : new Date(day.date).toLocaleDateString(locale, { weekday: "short" })
308
+ }),
309
+ /* @__PURE__ */ jsx(Glyph, {
310
+ condition: day.condition,
311
+ size: 16,
312
+ className: hueFor(day.condition)
313
+ }),
314
+ /* @__PURE__ */ jsx("span", {
315
+ className: "w-9 shrink-0 text-caption text-status-info",
316
+ children: (day.precipitation ?? 0) >= WET && `${day.precipitation}%`
317
+ }),
318
+ /* @__PURE__ */ jsx("span", {
319
+ className: "w-8 shrink-0 text-right text-muted-foreground",
320
+ children: temp(day.low, unit)
321
+ }),
322
+ /* @__PURE__ */ jsx("span", {
323
+ className: "relative h-1 min-w-12 flex-1 rounded-full bg-active",
324
+ children: /* @__PURE__ */ jsx("span", {
325
+ className: "absolute inset-y-0 rounded-full bg-foreground",
326
+ style: { left: `${(day.low - low) / span * 100}%`, width: `${(day.high - day.low) / span * 100}%` }
327
+ })
328
+ }),
329
+ /* @__PURE__ */ jsx("span", {
330
+ className: "w-8 shrink-0 text-foreground",
331
+ children: temp(day.high, unit)
332
+ })
333
+ ]
334
+ }, day.date));
335
+ }
336
+ function Detail({ icon: Icon, label, children }) {
337
+ return /* @__PURE__ */ jsxs("div", {
338
+ className: "flex h-8 min-w-0 items-center gap-2 text-body",
339
+ children: [
340
+ /* @__PURE__ */ jsx(Icon, {
341
+ "aria-hidden": true,
342
+ size: 14,
343
+ strokeWidth: 1.5,
344
+ className: "shrink-0 text-muted-foreground"
345
+ }),
346
+ /* @__PURE__ */ jsx("span", {
347
+ className: "min-w-0 flex-1 truncate text-muted-foreground",
348
+ children: label
349
+ }),
350
+ /* @__PURE__ */ jsx("span", {
351
+ className: "shrink-0 whitespace-nowrap tabular-nums text-foreground",
352
+ children
353
+ })
354
+ ]
355
+ });
356
+ }
357
+ function Loading({ location, className }) {
358
+ return /* @__PURE__ */ jsx(widget_default, {
359
+ className,
360
+ aside: /* @__PURE__ */ jsxs("div", {
361
+ "aria-hidden": true,
362
+ className: "flex flex-col gap-3",
363
+ children: [
364
+ /* @__PURE__ */ jsx(Skeleton, {
365
+ className: "h-3 w-20"
366
+ }),
367
+ /* @__PURE__ */ jsx("div", {
368
+ className: "flex justify-between",
369
+ children: Array.from({ length: HOURS }, (_, i) => /* @__PURE__ */ jsx(Skeleton, {
370
+ className: "h-14 w-7"
371
+ }, i))
372
+ }),
373
+ /* @__PURE__ */ jsx(Skeleton, {
374
+ className: "h-3 w-full"
375
+ })
376
+ ]
377
+ }),
378
+ children: /* @__PURE__ */ jsxs("div", {
379
+ "aria-busy": true,
380
+ className: "flex min-w-0 flex-col gap-2",
381
+ children: [
382
+ /* @__PURE__ */ jsx(widget_default.Header, {
383
+ icon: MapPin,
384
+ children: location ?? "Finding you…"
385
+ }),
386
+ /* @__PURE__ */ jsx(Skeleton, {
387
+ className: "h-8 w-28"
388
+ }),
389
+ /* @__PURE__ */ jsx(Skeleton, {
390
+ className: "h-4 w-40"
391
+ }),
392
+ /* @__PURE__ */ jsx(Skeleton, {
393
+ className: "h-3 w-56"
394
+ })
395
+ ]
396
+ })
397
+ });
398
+ }
399
+ function WeatherLeading2({ current }) {
400
+ return /* @__PURE__ */ jsx(Glyph, {
401
+ condition: current.condition,
402
+ isDay: current.isDay,
403
+ size: 16,
404
+ className: hueFor(current.condition, current.isDay)
405
+ });
406
+ }
407
+ function WeatherTrailing2({ current, unit = "celsius" }) {
408
+ return /* @__PURE__ */ jsx("span", {
409
+ className: "text-caption weight-semibold text-foreground tabular-nums",
410
+ children: temp(current.temperature, unit)
411
+ });
412
+ }
413
+ function WeatherMinimal2({ current }) {
414
+ const level = useLift(1);
415
+ return /* @__PURE__ */ jsx("span", {
416
+ role: "img",
417
+ "aria-label": LABEL[current.condition],
418
+ className: cn("flex size-6 items-center justify-center rounded-full", SURFACE_BG[level], hueFor(current.condition, current.isDay)),
419
+ children: /* @__PURE__ */ jsx(Glyph, {
420
+ condition: current.condition,
421
+ isDay: current.isDay,
422
+ size: 14
423
+ })
424
+ });
425
+ }
426
+ var ALERT_TILE = {
427
+ notice: "bg-status-info/16 text-status-info",
428
+ warning: "bg-status-warning/16 text-status-warning",
429
+ severe: "bg-status-error/16 text-status-error"
430
+ };
431
+ function WeatherAlert2({
432
+ condition,
433
+ startsAt,
434
+ title,
435
+ caption,
436
+ severity = "notice",
437
+ actionLabel = "Details",
438
+ onAction
439
+ }) {
440
+ const now = useEdgeClock2(startsAt ?? 0, startsAt !== undefined && title === undefined, MINUTE2);
441
+ const left = startsAt === undefined ? 0 : Math.ceil((startsAt - now) / MINUTE2);
442
+ const heading = title ?? (left > 0 ? `${LABEL[condition]} in ${left} min` : `${LABEL[condition]} now`);
443
+ return /* @__PURE__ */ jsx(IslandFlash2, {
444
+ icon: /* @__PURE__ */ jsx("span", {
445
+ className: cn("flex size-9 items-center justify-center rounded-lg", ALERT_TILE[severity]),
446
+ children: /* @__PURE__ */ jsx(Glyph, {
447
+ condition,
448
+ size: 16
449
+ })
450
+ }),
451
+ title: heading,
452
+ caption,
453
+ action: onAction && /* @__PURE__ */ jsx(Button, {
454
+ variant: "secondary",
455
+ size: "compact",
456
+ onClick: onAction,
457
+ children: actionLabel
458
+ })
459
+ });
460
+ }
461
+ var Weather2 = Object.assign(function Weather({
462
+ location,
463
+ current,
464
+ hours = [],
465
+ days = [],
466
+ unit = "celsius",
467
+ access = "granted",
468
+ status = "ready",
469
+ now: nowProp,
470
+ locale,
471
+ onRefresh,
472
+ onRequestAccess,
473
+ onOpenSettings,
474
+ layout = "fit",
475
+ className
476
+ }) {
477
+ const size = useSize();
478
+ const ticking = useEdgeClock2(current?.time ?? 0, nowProp === undefined, MINUTE2);
479
+ const now = nowProp ?? ticking;
480
+ if (access === "undetermined")
481
+ return /* @__PURE__ */ jsx(widget_default.Message, {
482
+ icon: MapPin,
483
+ title: "Weather where you are",
484
+ description: "The temperature now, the next hours and tomorrow, for your location.",
485
+ actions: /* @__PURE__ */ jsx(Button, {
486
+ variant: "primary",
487
+ size: "compact",
488
+ onClick: onRequestAccess,
489
+ children: "Allow location"
490
+ }),
491
+ className
492
+ });
493
+ if (access === "denied")
494
+ return /* @__PURE__ */ jsx(widget_default.Message, {
495
+ icon: LocateOff,
496
+ title: "Location access is off",
497
+ description: "Turn it on in System Settings › Privacy & Security › Location Services.",
498
+ actions: /* @__PURE__ */ jsx(Button, {
499
+ variant: "secondary",
500
+ size: "compact",
501
+ onClick: onOpenSettings,
502
+ children: "Open System Settings"
503
+ }),
504
+ className
505
+ });
506
+ if (!current && status === "error")
507
+ return /* @__PURE__ */ jsx(widget_default.Message, {
508
+ icon: CloudOff,
509
+ title: "Couldn't load the weather",
510
+ description: "The forecast service didn't answer. It tries again on its own in a few minutes.",
511
+ actions: onRefresh && /* @__PURE__ */ jsx(Button, {
512
+ variant: "secondary",
513
+ size: "compact",
514
+ onClick: onRefresh,
515
+ children: "Try again"
516
+ }),
517
+ className
518
+ });
519
+ if (!current && status === "offline")
520
+ return /* @__PURE__ */ jsx(widget_default.Message, {
521
+ icon: WifiOff,
522
+ title: "You're offline",
523
+ description: "The forecast loads as soon as you're back online.",
524
+ className
525
+ });
526
+ if (!current)
527
+ return /* @__PURE__ */ jsx(Loading, {
528
+ location,
529
+ className
530
+ });
531
+ const hourStart = new Date(now).setMinutes(0, 0, 0);
532
+ const ahead = hours.filter((hour) => hour.time >= hourStart).sort((a, b) => a.time - b.time);
533
+ const [today, tomorrow] = days;
534
+ const rain = rainAhead(current, ahead);
535
+ const fresh = ago(Math.max(0, now - current.time));
536
+ const freshness = status === "offline" ? `Offline · ${fresh}` : status === "error" ? `Not updated · ${fresh}` : fresh;
537
+ const feels = current.apparent !== undefined && `Feels like ${temp(current.apparent, unit)}`;
538
+ const soon = rain && `${LABEL[rain.condition]} around ${hourOf(rain.time, locale)}`;
539
+ const header = /* @__PURE__ */ jsx(widget_default.Header, {
540
+ icon: MapPin,
541
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
542
+ children: [
543
+ /* @__PURE__ */ jsx("span", {
544
+ className: "whitespace-nowrap pr-1 text-caption",
545
+ children: freshness
546
+ }),
547
+ onRefresh && /* @__PURE__ */ jsx(widget_default.Action, {
548
+ icon: RotateCw,
549
+ label: "Refresh",
550
+ onClick: onRefresh
551
+ })
552
+ ]
553
+ }),
554
+ children: location ?? "Current location"
555
+ });
556
+ if (layout === "tall") {
557
+ const week = days.slice(0, WEEK);
558
+ return /* @__PURE__ */ jsxs(widget_default.Sheet, {
559
+ className,
560
+ children: [
561
+ /* @__PURE__ */ jsxs("div", {
562
+ className: "flex min-w-0 flex-col gap-2",
563
+ children: [
564
+ header,
565
+ /* @__PURE__ */ jsxs("div", {
566
+ className: "flex min-w-0 items-center gap-5",
567
+ children: [
568
+ /* @__PURE__ */ jsxs("div", {
569
+ className: "flex shrink-0 items-center gap-3",
570
+ children: [
571
+ /* @__PURE__ */ jsx(Glyph, {
572
+ condition: current.condition,
573
+ isDay: current.isDay,
574
+ size: SHEET_GLYPH[size.variant],
575
+ className: hueFor(current.condition, current.isDay)
576
+ }),
577
+ /* @__PURE__ */ jsx(widget_default.Figure, {
578
+ value: degrees(current.temperature, unit),
579
+ unit: unit === "fahrenheit" ? "°F" : "°C"
580
+ })
581
+ ]
582
+ }),
583
+ /* @__PURE__ */ jsxs("div", {
584
+ className: "flex min-w-0 flex-1 flex-col gap-0.5",
585
+ children: [
586
+ /* @__PURE__ */ jsx(widget_default.Title, {
587
+ children: LABEL[current.condition]
588
+ }),
589
+ today && /* @__PURE__ */ jsx(widget_default.Subtitle, {
590
+ children: [`H ${temp(today.high, unit)}`, `L ${temp(today.low, unit)}`, soon].filter(Boolean).join(" · ")
591
+ })
592
+ ]
593
+ })
594
+ ]
595
+ })
596
+ ]
597
+ }),
598
+ ahead.length > 1 && /* @__PURE__ */ jsx(widget_default.Section, {
599
+ label: "Next 24 hours",
600
+ children: /* @__PURE__ */ jsx(HourStrip, {
601
+ hours: ahead.slice(0, DAY_HOURS),
602
+ unit,
603
+ locale
604
+ })
605
+ }),
606
+ /* @__PURE__ */ jsxs("div", {
607
+ className: "flex min-w-0 items-start gap-5",
608
+ children: [
609
+ week.length > 0 && /* @__PURE__ */ jsx(widget_default.Section, {
610
+ label: `${week.length}-day forecast`,
611
+ className: "flex-1",
612
+ children: /* @__PURE__ */ jsx(Week, {
613
+ days: week,
614
+ unit,
615
+ locale
616
+ })
617
+ }),
618
+ /* @__PURE__ */ jsxs(widget_default.Section, {
619
+ label: "Details",
620
+ className: "w-[38%] shrink-0 border-l border-border pl-5",
621
+ children: [
622
+ current.apparent !== undefined && /* @__PURE__ */ jsx(Detail, {
623
+ icon: Thermometer,
624
+ label: "Feels like",
625
+ children: temp(current.apparent, unit)
626
+ }),
627
+ today?.precipitation !== undefined && /* @__PURE__ */ jsxs(Detail, {
628
+ icon: Umbrella,
629
+ label: "Chance of rain",
630
+ children: [
631
+ today.precipitation,
632
+ "%"
633
+ ]
634
+ }),
635
+ current.wind !== undefined && /* @__PURE__ */ jsx(Detail, {
636
+ icon: Wind,
637
+ label: "Wind",
638
+ children: speed(current.wind, unit)
639
+ }),
640
+ current.humidity !== undefined && /* @__PURE__ */ jsxs(Detail, {
641
+ icon: Droplets,
642
+ label: "Humidity",
643
+ children: [
644
+ Math.round(current.humidity),
645
+ "%"
646
+ ]
647
+ }),
648
+ current.uv !== undefined && /* @__PURE__ */ jsxs(Detail, {
649
+ icon: Sun,
650
+ label: "UV index",
651
+ children: [
652
+ Math.round(current.uv),
653
+ " · ",
654
+ uvLevel(current.uv)
655
+ ]
656
+ }),
657
+ today?.sunrise !== undefined && /* @__PURE__ */ jsx(Detail, {
658
+ icon: Sunrise,
659
+ label: "Sunrise",
660
+ children: clockOf(today.sunrise, locale)
661
+ }),
662
+ today?.sunset !== undefined && /* @__PURE__ */ jsx(Detail, {
663
+ icon: Sunset,
664
+ label: "Sunset",
665
+ children: clockOf(today.sunset, locale)
666
+ })
667
+ ]
668
+ })
669
+ ]
670
+ })
671
+ ]
672
+ });
673
+ }
674
+ return /* @__PURE__ */ jsxs(widget_default, {
675
+ className,
676
+ aside: ahead.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
677
+ children: [
678
+ /* @__PURE__ */ jsx(widget_default.Section, {
679
+ label: "Next hours",
680
+ children: /* @__PURE__ */ jsx(Hours, {
681
+ hours: ahead.slice(0, HOURS),
682
+ unit,
683
+ locale
684
+ })
685
+ }),
686
+ tomorrow && /* @__PURE__ */ jsx("div", {
687
+ className: "mt-1.5",
688
+ children: /* @__PURE__ */ jsx(Tomorrow, {
689
+ day: tomorrow,
690
+ unit
691
+ })
692
+ })
693
+ ]
694
+ }),
695
+ children: [
696
+ header,
697
+ /* @__PURE__ */ jsxs("div", {
698
+ className: "flex min-w-0 items-center gap-2.5",
699
+ children: [
700
+ /* @__PURE__ */ jsx(Glyph, {
701
+ condition: current.condition,
702
+ isDay: current.isDay,
703
+ size: HERO_GLYPH[size.variant],
704
+ className: hueFor(current.condition, current.isDay)
705
+ }),
706
+ /* @__PURE__ */ jsx(widget_default.Figure, {
707
+ value: degrees(current.temperature, unit),
708
+ unit: unit === "fahrenheit" ? "°F" : "°C"
709
+ })
710
+ ]
711
+ }),
712
+ /* @__PURE__ */ jsxs("div", {
713
+ className: "flex min-w-0 flex-col gap-0.5",
714
+ children: [
715
+ /* @__PURE__ */ jsx(widget_default.Title, {
716
+ children: LABEL[current.condition]
717
+ }),
718
+ (feels || soon) && /* @__PURE__ */ jsx(widget_default.Subtitle, {
719
+ children: [feels, soon].filter(Boolean).join(" · ")
720
+ })
721
+ ]
722
+ }),
723
+ /* @__PURE__ */ jsxs(widget_default.Meta, {
724
+ className: "mt-1",
725
+ children: [
726
+ today && /* @__PURE__ */ jsxs(Fragment, {
727
+ children: [
728
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
729
+ icon: ArrowUp,
730
+ children: temp(today.high, unit)
731
+ }),
732
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
733
+ icon: ArrowDown,
734
+ children: temp(today.low, unit)
735
+ })
736
+ ]
737
+ }),
738
+ today?.precipitation !== undefined && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
739
+ icon: Umbrella,
740
+ children: [
741
+ today.precipitation,
742
+ "%"
743
+ ]
744
+ }),
745
+ current.wind !== undefined && /* @__PURE__ */ jsx(widget_default.MetaItem, {
746
+ icon: Wind,
747
+ children: speed(current.wind, unit)
748
+ }),
749
+ current.humidity !== undefined && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
750
+ icon: Droplets,
751
+ children: [
752
+ Math.round(current.humidity),
753
+ "%"
754
+ ]
755
+ }),
756
+ current.uv !== undefined && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
757
+ icon: Sun,
758
+ children: [
759
+ "UV ",
760
+ Math.round(current.uv)
761
+ ]
762
+ })
763
+ ]
764
+ })
765
+ ]
766
+ });
767
+ }, {
768
+ Leading: WeatherLeading2,
769
+ Trailing: WeatherTrailing2,
770
+ Minimal: WeatherMinimal2,
771
+ Alert: WeatherAlert2
772
+ });
773
+ var weather_default = Weather2;
774
+ export { conditionFromCode2, WeatherLeading2, WeatherTrailing2, WeatherMinimal2, WeatherAlert2, Weather2, weather_default };