@cos-design/weather-background 4.0.0 → 4.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/vue/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createElementBlock as e, defineComponent as t, onMounted as n, onUnmounted as r, openBlock as i, ref as a, watch as o } from "vue";
2
- import { applyCanvasHostBox as s, bindPrefersReducedMotion as c, bindVisibilityPause as l, observeElementSize as u, optionsFingerprint as d, prefersReducedMotion as f, resolveCanvasBoxSize as p } from "@cos-design/shared";
2
+ import { applyCanvasHostBox as s, bindPrefersReducedMotion as c, bindVisibilityPause as l, observeElementSize as u, prefersReducedMotion as d, resolveCanvasBoxSize as f } from "@cos-design/shared";
3
3
  import './vue.css';//#region src/components/weatherBackground/day-cycle.ts
4
- var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
4
+ var p = (e) => Math.min(1, Math.max(0, e)), m = (e) => {
5
5
  let t = e.replace("#", "").trim(), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
6
6
  if (n.length !== 6) return [
7
7
  80,
@@ -18,17 +18,17 @@ var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
18
18
  r >> 8 & 255,
19
19
  r & 255
20
20
  ];
21
- }, g = ([e, t, n]) => {
21
+ }, h = ([e, t, n]) => {
22
22
  let r = (e) => Math.min(255, Math.max(0, Math.round(e))).toString(16).padStart(2, "0");
23
23
  return `#${r(e)}${r(t)}${r(n)}`;
24
- }, _ = (e, t, n) => e + (t - e) * n, v = (e, t, n) => [
25
- _(e[0], t[0], n),
26
- _(e[1], t[1], n),
27
- _(e[2], t[2], n)
28
- ], y = (e, t, n) => g(v(h(e), h(t), m(n))), b = (e) => {
29
- let t = m(e);
24
+ }, g = (e, t, n) => e + (t - e) * n, _ = (e, t, n) => [
25
+ g(e[0], t[0], n),
26
+ g(e[1], t[1], n),
27
+ g(e[2], t[2], n)
28
+ ], v = (e, t, n) => h(_(m(e), m(t), p(n))), y = (e) => {
29
+ let t = p(e);
30
30
  return t * t * (3 - 2 * t);
31
- }, x = (e = Date.now()) => {
31
+ }, b = (e = Date.now()) => {
32
32
  let t = new Date(e), n = new Date(t);
33
33
  n.setHours(6, 0, 0, 0);
34
34
  let r = new Date(t);
@@ -36,52 +36,52 @@ var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
36
36
  sunrise: n.getTime(),
37
37
  sunset: r.getTime()
38
38
  };
39
- }, S = (e, t = /* @__PURE__ */ new Date()) => {
39
+ }, x = (e, t = /* @__PURE__ */ new Date()) => {
40
40
  let n = e.trim().match(/^(\d{1,2}):(\d{2})$/);
41
41
  if (!n) return null;
42
42
  let r = Number(n[1]), i = Number(n[2]);
43
43
  if (r < 0 || r > 23 || i < 0 || i > 59) return null;
44
44
  let a = new Date(t);
45
45
  return a.setHours(r, i, 0, 0), a.getTime();
46
- }, C = (e, t = /* @__PURE__ */ new Date()) => S(e ?? "14:00", t) ?? S("14:00", t), w = (e, t) => {
46
+ }, S = (e, t = /* @__PURE__ */ new Date()) => x(e ?? "14:00", t) ?? x("14:00", t), C = (e, t) => {
47
47
  let { sunrise: n, sunset: r } = t;
48
48
  if (!(r > n)) {
49
- let t = x(e);
49
+ let t = b(e);
50
50
  n = t.sunrise, r = t.sunset;
51
51
  }
52
52
  let i = Math.max(1, r - n), a = n + 1440 * 60 * 1e3, o = r - 1440 * 60 * 1e3, s = e >= n && e < r, c;
53
- if (s) c = m((e - n) / i);
53
+ if (s) c = p((e - n) / i);
54
54
  else if (e >= r) {
55
55
  let t = Math.max(1, a - r);
56
- c = m((e - r) / t);
56
+ c = p((e - r) / t);
57
57
  } else {
58
58
  let t = Math.max(1, n - o);
59
- c = m((e - o) / t);
59
+ c = p((e - o) / t);
60
60
  }
61
- let l = s ? Math.sin(Math.PI * c) : 0, u = Math.abs(e - n), d = Math.abs(e - r), f = m(1 - Math.min(u, d) / 45e5);
61
+ let l = s ? Math.sin(Math.PI * c) : 0, u = Math.abs(e - n), d = Math.abs(e - r), f = p(1 - Math.min(u, d) / 45e5);
62
62
  return {
63
63
  isDay: s,
64
64
  arcProgress: c,
65
65
  elevation: l,
66
66
  twilight: f
67
67
  };
68
- }, T = (e, t, n) => {
69
- let r = m(n), i = Math.sin(Math.PI * r);
68
+ }, w = (e, t, n) => {
69
+ let r = p(n), i = Math.sin(Math.PI * r);
70
70
  return {
71
71
  x: e * (.1 + .8 * r),
72
72
  y: t * (.58 - .4 * i)
73
73
  };
74
- }, E = "#e8895c", D = "#f3c98a", O = "#2a1f4a", k = "#c4784a", ee = (e, t, n) => {
74
+ }, T = "#e8895c", E = "#f3c98a", ee = "#2a1f4a", D = "#c4784a", te = (e, t, n) => {
75
75
  if (n.isDay) {
76
- let t = b(n.elevation), r = (1 - t) * .72;
77
- return [y(y(e[0], E, r), "#1a2438", (1 - t) * .12), y(y(e[1], D, r * .85), "#3a4558", (1 - t) * .08)];
76
+ let t = y(n.elevation), r = (1 - t) * .72;
77
+ return [v(v(e[0], T, r), "#1a2438", (1 - t) * .12), v(v(e[1], E, r * .85), "#3a4558", (1 - t) * .08)];
78
78
  }
79
79
  let r = n.twilight;
80
- return [y(t[0], y(O, E, .35), r * .55), y(t[1], y(k, D, .4), r * .7)];
81
- }, te = (e, t, n) => {
80
+ return [v(t[0], v(ee, T, .35), r * .55), v(t[1], v(D, E, .4), r * .7)];
81
+ }, O = (e, t, n) => {
82
82
  let r = e.createLinearGradient(0, 0, 0, t);
83
83
  return r.addColorStop(0, n[0]), r.addColorStop(1, n[1]), r;
84
- }, A = (e) => {
84
+ }, k = (e) => {
85
85
  if (!e.isDay) return {
86
86
  scale: .92 + e.twilight * .06,
87
87
  alpha: .75 + e.twilight * .2
@@ -91,8 +91,8 @@ var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
91
91
  scale: .82 + t * .22,
92
92
  alpha: .65 + t * .35
93
93
  };
94
- }, j = (e) => Math.min(3, Math.max(1, Math.round(e))), ne = (e) => e === "fog", re = (e, t) => {
95
- let n = j(t);
94
+ }, A = (e) => Math.min(3, Math.max(1, Math.round(e))), ne = (e) => e === "fog", re = (e, t) => {
95
+ let n = A(t);
96
96
  return n === 1 ? {
97
97
  ...e,
98
98
  fogBanks: 3,
@@ -113,10 +113,10 @@ var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
113
113
  sun: "dim"
114
114
  };
115
115
  }, ie = (e) => {
116
- let t = j(e);
116
+ let t = A(e);
117
117
  return t === 1 ? .45 : t === 3 ? .95 : .65;
118
- }, M = (e) => e === 45 ? 2 : e === 48 ? 3 : null, ae = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, oe = (e) => Math.min(3, Math.max(1, Math.round(e))), se = (e) => e === "hail", ce = (e) => {
119
- let t = oe(e);
118
+ }, j = (e) => e === 45 ? 2 : e === 48 ? 3 : null, M = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, ae = (e) => Math.min(3, Math.max(1, Math.round(e))), oe = (e) => e === "hail", se = (e) => {
119
+ let t = ae(e);
120
120
  return t === 1 ? {
121
121
  count: 75,
122
122
  sizeMin: .85,
@@ -133,7 +133,7 @@ var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
133
133
  sizeMax: 3.8,
134
134
  speedMul: 1
135
135
  };
136
- }, le = (e) => e === 96 ? 2 : e === 99 ? 3 : null, N = (e) => Math.min(10, Math.max(1, Math.round(e))), P = (e, t, n) => e + (t - e) * n, F = (e) => {
136
+ }, ce = (e) => e === 96 ? 2 : e === 99 ? 3 : null, N = (e) => Math.min(10, Math.max(1, Math.round(e))), P = (e, t, n) => e + (t - e) * n, F = (e) => {
137
137
  let t = N(e);
138
138
  return t <= 2 ? 1 : t <= 4 ? 2 : t <= 6 ? 3 : t <= 8 ? 4 : 5;
139
139
  }, I = [
@@ -142,15 +142,15 @@ var m = (e) => Math.min(1, Math.max(0, e)), h = (e) => {
142
142
  "中雨",
143
143
  "暴雨",
144
144
  "特大暴雨"
145
- ], L = [
145
+ ], le = [
146
146
  "毛毛雪",
147
147
  "小雪",
148
148
  "中雪",
149
149
  "暴雪",
150
150
  "特大暴雪"
151
151
  ];
152
- [...I], [...L];
153
- var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? "rain" : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? "snow" : e, z = (e) => e === "rain" || e === "lightRain" || e === "moderateRain" || e === "heavyRain", B = (e) => e === "snow" || e === "lightSnow" || e === "moderateSnow" || e === "heavySnow", ue = (e) => z(e) || e === "thunderstorm" || e === "sleet", de = (e) => B(e) || e === "sleet", V = (e, t = 5) => e === "lightRain" ? 3 : e === "moderateRain" ? 5 : e === "heavyRain" ? 8 : N(t), H = (e, t = 5) => e === "lightSnow" ? 3 : e === "moderateSnow" ? 5 : e === "heavySnow" ? 8 : N(t), U = (e, t) => t === "rain" ? e <= 2 ? "lightRain" : e === 3 ? "moderateRain" : "heavyRain" : e <= 2 ? "lightSnow" : e === 3 ? "moderateSnow" : "heavySnow", fe = (e, t = 5, n = 5) => e === "rain" ? U(F(t), "rain") : e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? U(F(V(e)), "rain") : e === "snow" ? U(F(n), "snow") : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? U(F(H(e)), "snow") : e, pe = (e, t) => {
152
+ [...I], [...le];
153
+ var L = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? "rain" : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? "snow" : e, R = (e) => e === "rain" || e === "lightRain" || e === "moderateRain" || e === "heavyRain", ue = (e) => e === "snow" || e === "lightSnow" || e === "moderateSnow" || e === "heavySnow", de = (e) => R(e) || e === "thunderstorm" || e === "sleet", fe = (e) => ue(e) || e === "sleet", pe = (e, t = 5) => e === "lightRain" ? 3 : e === "moderateRain" ? 5 : e === "heavyRain" ? 8 : N(t), me = (e, t = 5) => e === "lightSnow" ? 3 : e === "moderateSnow" ? 5 : e === "heavySnow" ? 8 : N(t), z = (e, t) => t === "rain" ? e <= 2 ? "lightRain" : e === 3 ? "moderateRain" : "heavyRain" : e <= 2 ? "lightSnow" : e === 3 ? "moderateSnow" : "heavySnow", he = (e, t = 5, n = 5) => e === "rain" ? z(F(t), "rain") : e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? z(F(pe(e)), "rain") : e === "snow" ? z(F(n), "snow") : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? z(F(me(e)), "snow") : e, ge = (e, t) => {
154
154
  let n = (N(t) - 1) / 9;
155
155
  return {
156
156
  count: Math.round(P(35, 340, n)),
@@ -159,10 +159,10 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
159
159
  alpha: P(.28, .62, n),
160
160
  splash: N(t) >= 5
161
161
  };
162
- }, me = (e) => {
162
+ }, _e = (e) => {
163
163
  let t = (N(e) - 1) / 9;
164
164
  return Math.round(P(30, 360, t));
165
- }, he = (e) => [51, 56].includes(e) ? 2 : [
165
+ }, ve = (e) => [51, 56].includes(e) ? 2 : [
166
166
  61,
167
167
  66,
168
168
  80
@@ -172,8 +172,8 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
172
172
  57,
173
173
  63,
174
174
  81
175
- ].includes(e) ? 5 : [65, 67].includes(e) ? 8 : [82].includes(e) ? 10 : [95].includes(e) ? 7 : null, ge = (e) => [77].includes(e) ? 2 : [71, 85].includes(e) ? 3 : [73].includes(e) ? 5 : [75].includes(e) ? 8 : [86].includes(e) ? 10 : null, W = (e) => Math.min(3, Math.max(1, Math.round(e))), _e = (e) => e === "smog", ve = (e, t) => {
176
- let n = W(t);
175
+ ].includes(e) ? 5 : [65, 67].includes(e) ? 8 : [82].includes(e) ? 10 : [95].includes(e) ? 7 : null, ye = (e) => [77].includes(e) ? 2 : [71, 85].includes(e) ? 3 : [73].includes(e) ? 5 : [75].includes(e) ? 8 : [86].includes(e) ? 10 : null, be = (e) => Math.min(3, Math.max(1, Math.round(e))), xe = (e) => e === "smog", Se = (e, t) => {
176
+ let n = be(t);
177
177
  return n === 1 ? {
178
178
  ...e,
179
179
  fogBanks: 5,
@@ -193,10 +193,10 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
193
193
  cloudAlpha: .35,
194
194
  sun: "dim"
195
195
  };
196
- }, ye = (e) => {
197
- let t = W(e);
196
+ }, Ce = (e) => {
197
+ let t = be(e);
198
198
  return t === 1 ? .55 : t === 3 ? 1.05 : .85;
199
- }, be = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, xe = {
199
+ }, we = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, Te = {
200
200
  0: "sunny",
201
201
  1: "sunny",
202
202
  2: "partlyCloudy",
@@ -225,7 +225,7 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
225
225
  95: "thunderstorm",
226
226
  96: "hail",
227
227
  99: "hail"
228
- }, Se = (e) => R(xe[e] ?? "overcast"), G = {
228
+ }, Ee = (e) => L(Te[e] ?? "overcast"), B = {
229
229
  weather: null,
230
230
  rainLevel: null,
231
231
  snowLevel: null,
@@ -235,21 +235,21 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
235
235
  status: "idle",
236
236
  error: null,
237
237
  current: null
238
- }, Ce = {
239
- ...G,
238
+ }, De = {
239
+ ...B,
240
240
  status: "locating"
241
- }, we = {
242
- ...G,
241
+ }, V = {
242
+ ...B,
243
243
  status: "fetching"
244
- }, Te = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude), K = (e) => {
244
+ }, H = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude), U = (e) => {
245
245
  if (typeof e != "string" || !e) return null;
246
246
  let t = Date.parse(e);
247
247
  return Number.isFinite(t) ? t : null;
248
- }, Ee = (e) => {
248
+ }, Oe = (e) => {
249
249
  if (typeof e != "string" || !e) return null;
250
250
  let t = e.match(/T(\d{2}):(\d{2})/);
251
251
  return t ? `${t[1]}:${t[2]}` : null;
252
- }, De = (e, t) => {
252
+ }, W = (e, t) => {
253
253
  if (e) try {
254
254
  let t = new Intl.DateTimeFormat("en-GB", {
255
255
  timeZone: e,
@@ -260,11 +260,14 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
260
260
  if (n != null && r != null) return `${n.padStart(2, "0")}:${r.padStart(2, "0")}`;
261
261
  } catch {}
262
262
  return t ?? null;
263
- }, q = (e) => ({
264
- ...G,
263
+ }, ke = (e) => !e?.sunrise || !e?.sunset ? null : {
264
+ sunrise: e.sunrise,
265
+ sunset: e.sunset
266
+ }, G = (e) => ({
267
+ ...B,
265
268
  status: "error",
266
269
  error: e
267
- }), Oe = async (e, t, n) => {
270
+ }), Ae = async (e, t, n) => {
268
271
  let r = new URLSearchParams({
269
272
  latitude: String(e),
270
273
  longitude: String(t),
@@ -276,7 +279,7 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
276
279
  if (!i.ok) throw Error(`Open-Meteo 请求失败(HTTP ${i.status})`);
277
280
  let a = await i.json(), o = Number(a?.current?.weather_code);
278
281
  if (Number.isNaN(o)) throw Error("Open-Meteo 返回数据缺少 weather_code");
279
- let s = Number(a?.current?.wind_speed_10m ?? 0), c = K(a?.daily?.sunrise?.[0]), l = K(a?.daily?.sunset?.[0]), u = typeof a?.timezone == "string" ? a.timezone : null, d = Ee(a?.current?.time) ?? De(u), f = Se(o), p = he(o), m = ge(o), h = a?.current?.visibility, g = h != null && Number.isFinite(Number(h)) ? Number(h) : null, _ = f === "fog" ? ae(g) ?? M(o) ?? 2 : null, v = f === "hail" ? le(o) ?? 2 : null, y = f === "smog" ? be(g) ?? 2 : null;
282
+ let s = Number(a?.current?.wind_speed_10m ?? 0), c = U(a?.daily?.sunrise?.[0]), l = U(a?.daily?.sunset?.[0]), u = typeof a?.timezone == "string" ? a.timezone : null, d = Oe(a?.current?.time) ?? W(u), f = Ee(o), p = ve(o), m = ye(o), h = a?.current?.visibility, g = h != null && Number.isFinite(Number(h)) ? Number(h) : null, _ = f === "fog" ? M(g) ?? j(o) ?? 2 : null, v = f === "hail" ? ce(o) ?? 2 : null, y = f === "smog" ? we(g) ?? 2 : null;
280
283
  return {
281
284
  weather: f,
282
285
  rainLevel: p,
@@ -304,36 +307,60 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
304
307
  sunset: l
305
308
  }
306
309
  };
307
- }, ke = (e, t, n) => {
308
- if (!e) return n(G), () => {};
309
- let r = !1, i = new AbortController(), a = Te(t);
310
- n(a ? we : Ce);
310
+ }, K = (e, t, n) => {
311
+ if (!e) return n(B), () => {};
312
+ let r = !1, i = new AbortController(), a = H(t);
313
+ n(a ? V : De);
311
314
  let o = async (e, t) => {
312
315
  try {
313
- let a = await Oe(e, t, i.signal);
316
+ let a = await Ae(e, t, i.signal);
314
317
  r || n(a);
315
318
  } catch (e) {
316
319
  if (r || e instanceof DOMException && e.name === "AbortError") return;
317
- n(q(e instanceof Error ? e.message : "天气获取失败"));
320
+ n(G(e instanceof Error ? e.message : "天气获取失败"));
318
321
  }
319
322
  };
320
323
  return a ? (o(t.latitude, t.longitude), () => {
321
324
  r = !0, i.abort();
322
325
  }) : typeof navigator > "u" || !navigator.geolocation ? (Promise.resolve().then(() => {
323
- r || n(q("当前环境不支持定位"));
326
+ r || n(G("当前环境不支持定位"));
324
327
  }), () => {
325
328
  r = !0;
326
329
  }) : (navigator.geolocation.getCurrentPosition(({ coords: e }) => {
327
- r || (n(we), o(e.latitude, e.longitude));
330
+ r || (n(V), o(e.latitude, e.longitude));
328
331
  }, (e) => {
329
- r || n(q(e.message || "定位失败"));
332
+ r || n(G(e.message || "定位失败"));
330
333
  }, {
331
334
  timeout: 1e4,
332
335
  maximumAge: 600 * 1e3
333
336
  }), () => {
334
337
  r = !0, i.abort();
335
338
  });
336
- }, J = (e) => Math.min(12, Math.max(0, Math.round(e))), Ae = (e) => Math.max(0, J(e) - 2), je = .55, Me = [
339
+ }, q = async (e, t, n) => {
340
+ let r = new URLSearchParams({
341
+ latitude: String(e),
342
+ longitude: String(t),
343
+ daily: "sunrise,sunset",
344
+ timezone: "auto",
345
+ forecast_days: "1"
346
+ }), i = await fetch(`https://api.open-meteo.com/v1/forecast?${r}`, { signal: n });
347
+ if (!i.ok) return null;
348
+ let a = await i.json(), o = U(a?.daily?.sunrise?.[0]), s = U(a?.daily?.sunset?.[0]);
349
+ return o == null || s == null ? null : {
350
+ sunrise: o,
351
+ sunset: s
352
+ };
353
+ }, je = (e, t) => {
354
+ if (!H(e)) return t(null), () => {};
355
+ let n = !1, r = new AbortController();
356
+ return q(e.latitude, e.longitude, r.signal).then((e) => {
357
+ n || t(e);
358
+ }).catch(() => {
359
+ n || t(null);
360
+ }), () => {
361
+ n = !0, r.abort();
362
+ };
363
+ }, J = (e) => Math.min(12, Math.max(0, Math.round(e))), Me = (e) => Math.max(0, J(e) - 2), Ne = .55, Pe = [
337
364
  0,
338
365
  3,
339
366
  8,
@@ -347,7 +374,7 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
347
374
  95,
348
375
  110,
349
376
  125
350
- ], Ne = [
377
+ ], Fe = [
351
378
  1,
352
379
  5,
353
380
  11,
@@ -362,7 +389,7 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
362
389
  117,
363
390
  Infinity
364
391
  ], Y = (e, t, n = 0, r = 0) => {
365
- let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e * je, c = Math.sin(s * .007 + o), l = Math.sin(s * .021 + 1.37 + o * 1.4), u = Math.sin(s * .055 + 2.8 + o * .6), d = 1 + (.5 * c + .35 * l + .15 * u) * (.25 + i * .75), f = Math.sin(s * .012 + o * .8);
392
+ let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e * Ne, c = Math.sin(s * .007 + o), l = Math.sin(s * .021 + 1.37 + o * 1.4), u = Math.sin(s * .055 + 2.8 + o * .6), d = 1 + (.5 * c + .35 * l + .15 * u) * (.25 + i * .75), f = Math.sin(s * .012 + o * .8);
366
393
  f > .72 && (d += (f - .72) * (.8 + i * 2.4)), Math.sin(s * .0095 + .6 + o) < -.55 && (d *= .45 + i * .2), d = Math.max(.12, Math.min(2.25, d));
367
394
  let p = a * (.55 * Math.sin(s * .0088 + o) + .3 * Math.sin(s * .026 + 1.9 + o * 1.1) + .15 * Math.sin(s * .063 + .4));
368
395
  return {
@@ -371,7 +398,7 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
371
398
  ux: Math.cos(p),
372
399
  uy: Math.sin(p)
373
400
  };
374
- }, Pe = (e) => {
401
+ }, Ie = (e) => {
375
402
  let t = J(e);
376
403
  if (t <= 0) return {
377
404
  count: 0,
@@ -382,12 +409,12 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
382
409
  count: Math.floor(3 + n * n * 50),
383
410
  alphaMul: .1 + n * .9
384
411
  };
385
- }, Fe = (e) => Me[J(e)] ?? 16, Ie = (e) => {
412
+ }, Le = (e) => Pe[J(e)] ?? 16, Re = (e) => {
386
413
  let t = Math.max(0, e);
387
- for (let e = 0; e < Ne.length; e++) if (t <= Ne[e]) return e;
414
+ for (let e = 0; e < Fe.length; e++) if (t <= Fe[e]) return e;
388
415
  return 12;
389
- }, Le = (e) => {
390
- let t = Ie(e), n = Ae(t), r = Fe(n), i = Math.max(.04, Math.min(r / 16, 4.2)), { alphaMul: a } = Pe(n), o = i ** .82, s = Math.min(1, (n / 8) ** 1.1), c = (.04 + s * .32) * Math.PI;
416
+ }, ze = (e) => {
417
+ let t = Re(e), n = Me(t), r = Le(n), i = Math.max(.04, Math.min(r / 16, 4.2)), { alphaMul: a } = Ie(n), o = i ** .82, s = Math.min(1, (n / 8) ** 1.1), c = (.04 + s * .32) * Math.PI;
391
418
  return {
392
419
  speedKmh: e,
393
420
  level: t,
@@ -403,17 +430,17 @@ var R = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ?
403
430
  gustiness: s,
404
431
  wander: c
405
432
  };
406
- }, Re = (e) => e.live && e.liveWindKmh != null && Number.isFinite(e.liveWindKmh) ? Math.max(0, e.liveWindKmh) : Fe(e.windLevel);
433
+ }, Be = (e) => e.live && e.liveWindKmh != null && Number.isFinite(e.liveWindKmh) ? Math.max(0, e.liveWindKmh) : Le(e.windLevel);
407
434
  //#endregion
408
435
  //#region src/components/weatherBackground/scene/draw-atmosphere.ts
409
- function ze(e) {
436
+ function Ve(e) {
410
437
  let t = e.windMotion.cloud, { intensity: n, angle: r, uy: i } = e.windField, a = -Math.cos(r);
411
438
  for (let r of e.state.clouds) {
412
439
  let o = Math.abs(r.speed) * t * n;
413
440
  r.x += o * a, r.y += o * i * .12, r.y < -80 && (r.y = -80), r.y > e.height * .55 && (r.y = e.height * .55), r.x - 140 * r.scale > e.width && (r.x = -160 * r.scale), r.x + 180 * r.scale < 0 && (r.x = e.width + 40 * r.scale), e.ctx.drawImage(r.sprite, r.x + r.ox, r.y + r.oy);
414
441
  }
415
442
  }
416
- function Be(e) {
443
+ function He(e) {
417
444
  let t = e.fogSprite;
418
445
  if (!t || e.state.fogBanks.length === 0) return;
419
446
  let { canvas: n, baseR: r } = t, i = e.windMotion.fog, { intensity: a, angle: o, uy: s } = e.windField, c = -Math.cos(o);
@@ -422,7 +449,7 @@ function Be(e) {
422
449
  t.x += o * c, t.y += o * s * .1, t.y < e.height * .02 && (t.y = e.height * .02), t.y > e.height * .95 && (t.y = e.height * .95), c < 0 && t.x + t.rw < 0 && (t.x = e.width + t.rw), c > 0 && t.x - t.rw > e.width && (t.x = -t.rw), e.ctx.save(), e.ctx.translate(t.x, t.y), e.ctx.scale(t.rw / r, t.rh / r), e.ctx.globalAlpha = t.alpha, e.ctx.drawImage(n, -r, -r), e.ctx.restore();
423
450
  }
424
451
  }
425
- function Ve(e) {
452
+ function Ue(e) {
426
453
  if (e.cfg.haze <= 0) return;
427
454
  let t = e.activeWeather === "smog" ? "177, 164, 135" : "220, 226, 232";
428
455
  e.activeNight && (t = e.activeWeather === "smog" ? "82, 74, 54" : "116, 128, 145"), e.ctx.fillStyle = `rgba(${t}, ${e.cfg.haze})`, e.ctx.fillRect(0, 0, e.width, e.height);
@@ -436,7 +463,7 @@ function X(e, t, n, r, i, a) {
436
463
  }
437
464
  //#endregion
438
465
  //#region src/components/weatherBackground/scene/draw-effects.ts
439
- function He(e) {
466
+ function We(e) {
440
467
  if (e.state.windStreaks.length === 0) return;
441
468
  let t = e.windMotion.streak, n = e.windMotion.streakVisibility;
442
469
  if (n <= .02) return;
@@ -451,7 +478,7 @@ function He(e) {
451
478
  }
452
479
  }
453
480
  }
454
- function Ue(e) {
481
+ function Ge(e) {
455
482
  if (e.cfg.lightning) {
456
483
  if (e.state.t >= e.state.nextStrike) {
457
484
  e.state.nextStrike = e.state.t + 150 + Math.random() * 300, e.state.flashAlpha = .5, e.state.boltLife = 9;
@@ -468,7 +495,7 @@ function Ue(e) {
468
495
  }
469
496
  //#endregion
470
497
  //#region src/components/weatherBackground/sprites/hail.ts
471
- var We = 3.2, Ge = (e) => {
498
+ var Ke = 3.2, qe = (e) => {
472
499
  let t = Math.ceil(e * 2.8 + 4), n = document.createElement("canvas");
473
500
  n.width = t, n.height = t;
474
501
  let r = n.getContext("2d"), i = t / 2, a = t / 2, o = 9 + Math.floor(Math.random() * 5), s = Array.from({ length: o }, (t, n) => {
@@ -501,10 +528,10 @@ var We = 3.2, Ge = (e) => {
501
528
  r.beginPath(), r.arc(n, o, e * (.1 + Math.random() * .08), 0, Math.PI * 2), r.fillStyle = "rgba(255, 255, 255, 0.55)", r.fill();
502
529
  }
503
530
  return r.beginPath(), r.ellipse(i - e * .34, a - e * .36, e * .24, e * .17, -.35, 0, Math.PI * 2), r.fillStyle = "rgba(255, 255, 255, 0.78)", r.fill(), n;
504
- }, Ke = (e = 16) => Array.from({ length: e }, () => Ge(We)), qe = (e) => e[Math.floor(Math.random() * e.length)], Je = (e, t, n, r, i = !0, a, o = 1) => {
531
+ }, Je = (e = 16) => Array.from({ length: e }, () => qe(Ke)), Ye = (e) => e[Math.floor(Math.random() * e.length)], Xe = (e, t, n, r, i = !0, a, o = 1) => {
505
532
  let s = a?.min ?? 1.4, c = a?.max ?? 4.8;
506
- e.r = s + Math.random() ** 1.35 * (c - s), e.x = Math.random() * (t + 260) - 130 + (Math.random() - .5) * 40, e.y = i ? -e.r - Math.random() * n * .55 : Math.random() * n, e.vx = (-1.2 - Math.random() * 4.8 + (Math.random() - .5) * 1.2) * o, e.vy = (5.5 + Math.random() * 11) * o, e.bounces = 0, e.opacity = .45 + Math.random() * .55, e.delay = Math.floor(Math.random() * (i ? 110 : 45)), e.gravity = (.11 + Math.random() * .14) * (.9 + o * .1), e.phase = Math.random() * Math.PI * 2, e.gust = (Math.random() - .5) * 1.4, e.maxBounces = +(Math.random() < .62), e.sprite = qe(r), e.drawSize = e.r * 2.8 + 4, e.rotation = Math.random() * Math.PI * 2, e.rotationSpeed = (Math.random() - .5) * .06;
507
- }, Ye = (e, t, n, r, i = 1) => {
533
+ e.r = s + Math.random() ** 1.35 * (c - s), e.x = Math.random() * (t + 260) - 130 + (Math.random() - .5) * 40, e.y = i ? -e.r - Math.random() * n * .55 : Math.random() * n, e.vx = (-1.2 - Math.random() * 4.8 + (Math.random() - .5) * 1.2) * o, e.vy = (5.5 + Math.random() * 11) * o, e.bounces = 0, e.opacity = .45 + Math.random() * .55, e.delay = Math.floor(Math.random() * (i ? 110 : 45)), e.gravity = (.11 + Math.random() * .14) * (.9 + o * .1), e.phase = Math.random() * Math.PI * 2, e.gust = (Math.random() - .5) * 1.4, e.maxBounces = +(Math.random() < .62), e.sprite = Ye(r), e.drawSize = e.r * 2.8 + 4, e.rotation = Math.random() * Math.PI * 2, e.rotationSpeed = (Math.random() - .5) * .06;
534
+ }, Ze = (e, t, n, r, i = 1) => {
508
535
  let a = {
509
536
  x: 0,
510
537
  y: 0,
@@ -523,11 +550,11 @@ var We = 3.2, Ge = (e) => {
523
550
  rotation: 0,
524
551
  rotationSpeed: 0
525
552
  };
526
- return Je(a, e, t, n, Math.random() < .72, r, i), a;
553
+ return Xe(a, e, t, n, Math.random() < .72, r, i), a;
527
554
  };
528
555
  //#endregion
529
556
  //#region src/components/weatherBackground/scene/draw-precipitation.ts
530
- function Xe(e) {
557
+ function Qe(e) {
531
558
  if (!e.cfg.rain) return;
532
559
  let { alpha: t, splash: n } = e.cfg.rain, r = e.cfg.rain.wind * e.windMotion.rain, { intensity: i, angle: a, uy: o } = e.windField, s = r * i * Math.cos(a), c = Math.abs(r) * i * o * .35;
533
560
  e.ctx.strokeStyle = `rgba(214, 228, 240, ${t})`, e.ctx.lineWidth = 1.2, e.ctx.beginPath();
@@ -549,7 +576,7 @@ function Xe(e) {
549
576
  e.ctx.beginPath(), e.ctx.ellipse(n.x, e.height - 3, n.r, n.r * .35, 0, Math.PI, Math.PI * 2), e.ctx.strokeStyle = `rgba(214, 228, 240, ${n.alpha})`, e.ctx.lineWidth = 1, e.ctx.stroke();
550
577
  }
551
578
  }
552
- function Ze(e) {
579
+ function $e(e) {
553
580
  let t = e.windMotion.snowDrift, { intensity: n, angle: r, uy: i } = e.windField, a = t * n * Math.cos(r), o = Math.abs(t) * n * i * .4;
554
581
  for (let t of e.state.flakes) {
555
582
  t.y += t.speed + o, t.x += Math.sin(e.state.t * .02 + t.phase) * (.3 + t.size * .08) + t.drift + a, t.rotation += t.rotationSpeed, t.y - t.drawSize > e.height && (t.y = -t.drawSize, t.x = Math.random() * e.width, t.phase = Math.random() * Math.PI * 2, t.drift = (Math.random() - .5) * .4, t.opacity = .55 + Math.random() * .45), t.x > e.width + 20 && (t.x = -20), t.x < -20 && (t.x = e.width + 20);
@@ -557,7 +584,7 @@ function Ze(e) {
557
584
  e.ctx.save(), e.ctx.globalAlpha = t.opacity, e.ctx.translate(t.x, t.y), e.ctx.rotate(t.rotation), e.ctx.drawImage(t.sprite, -n, -n, t.drawSize, t.drawSize), e.ctx.restore();
558
585
  }
559
586
  }
560
- function Qe(e) {
587
+ function et(e) {
561
588
  if (e.state.hailstones.length === 0) return;
562
589
  let t = e.state.hailPool, n = e.windMotion.hail, r = e.state.t, i = e.windField;
563
590
  for (let a of e.state.hailstones) {
@@ -568,7 +595,7 @@ function Qe(e) {
568
595
  let o = Y(r + a.phase * 12, e.windMotion, a.x, a.y), s = o.intensity * (.4 + .6 * i.intensity), c = o.angle * .5 + i.angle * .5, l = e.windMotion.snowDrift * .45 * s * Math.cos(c), u = Math.abs(e.windMotion.snowDrift) * s * Math.sin(c) * .2, d = a.x, f = a.y;
569
596
  if (a.vy += a.gravity + u * .02, a.vx += a.gust * .004 * n * s + l + (Math.random() - .5) * .08 * n * s, a.x += a.vx + Math.sin(r * .028 + a.phase) * .35, a.y += a.vy, e.ctx.beginPath(), e.ctx.moveTo(d, f), e.ctx.lineTo(a.x, a.y), e.ctx.strokeStyle = `rgba(225, 239, 250, ${a.opacity * .18})`, e.ctx.lineWidth = a.r * .35, e.ctx.stroke(), a.y + a.r >= e.height) if (a.bounces < a.maxBounces) a.y = e.height - a.r, a.vy *= -(.22 + Math.random() * .28), a.vx = a.vx * (.55 + Math.random() * .25) + (Math.random() - .5) * 1.6, a.bounces += 1;
570
597
  else {
571
- Je(a, e.width, e.height, t, !0, e.hailSpec ? {
598
+ Xe(a, e.width, e.height, t, !0, e.hailSpec ? {
572
599
  min: e.hailSpec.sizeMin,
573
600
  max: e.hailSpec.sizeMax
574
601
  } : void 0, e.hailSpec?.speedMul ?? 1);
@@ -580,10 +607,10 @@ function Qe(e) {
580
607
  }
581
608
  //#endregion
582
609
  //#region src/components/weatherBackground/scene/draw-sky.ts
583
- function $e(e) {
610
+ function tt(e) {
584
611
  e.ctx.fillStyle = e.skyGradient, e.ctx.fillRect(0, 0, e.width, e.height);
585
612
  }
586
- function et(e) {
613
+ function nt(e) {
587
614
  if (e.state.stars.length === 0) return;
588
615
  let t = 1;
589
616
  if (e.dayCycle) {
@@ -595,25 +622,25 @@ function et(e) {
595
622
  e.ctx.beginPath(), e.ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2), e.ctx.fillStyle = `rgba(226, 235, 255, ${r * t})`, e.ctx.fill();
596
623
  }
597
624
  }
598
- function tt(e) {
625
+ function rt(e) {
599
626
  let t = e.celestial;
600
627
  if (!t) return;
601
- let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ? A(e.dayCycle) : {
628
+ let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ? k(e.dayCycle) : {
602
629
  scale: 1,
603
630
  alpha: 1
604
631
  }, c = t.half * o * s.scale, l = c * 2;
605
632
  n.save(), n.globalAlpha = s.alpha, n.drawImage(t.canvas, r - c, i - c, l, l), n.restore();
606
633
  }
607
- function nt(e) {
634
+ function it(e) {
608
635
  if (e.activeNight) {
609
- et(e), tt(e);
636
+ nt(e), rt(e);
610
637
  return;
611
638
  }
612
- tt(e);
639
+ rt(e);
613
640
  }
614
641
  //#endregion
615
642
  //#region src/components/weatherBackground/configs.ts
616
- var rt = {
643
+ var at = {
617
644
  sunny: {
618
645
  sky: ["#4a9fe0", "#c8e8fb"],
619
646
  sun: "full",
@@ -945,7 +972,7 @@ var rt = {
945
972
  snowCount: 160,
946
973
  lightning: !1
947
974
  }
948
- }, it = {
975
+ }, ot = {
949
976
  sunny: {
950
977
  sky: ["#0b1a33", "#27476e"],
951
978
  stars: 110
@@ -1014,14 +1041,14 @@ var rt = {
1014
1041
  sky: ["#101a26", "#2e3d4d"],
1015
1042
  stars: 30
1016
1043
  }
1017
- }, at = ([e, t, n]) => [
1044
+ }, st = ([e, t, n]) => [
1018
1045
  Math.round(e * .3 + 18),
1019
1046
  Math.round(t * .3 + 24),
1020
1047
  Math.round(n * .3 + 42)
1021
1048
  ];
1022
1049
  //#endregion
1023
1050
  //#region src/components/weatherBackground/sprites/cloud.ts
1024
- function ot(e, t, n, r) {
1051
+ function ct(e, t, n, r) {
1025
1052
  let [i, a, o] = n, s = Infinity, c = Infinity, l = -Infinity, u = -Infinity;
1026
1053
  for (let n of t) {
1027
1054
  let t = n.dx * e, r = n.dy * e, i = n.r * e;
@@ -1040,12 +1067,12 @@ function ot(e, t, n, r) {
1040
1067
  oy: f
1041
1068
  };
1042
1069
  }
1043
- function st(e, t, n, r, i) {
1070
+ function lt(e, t, n, r, i) {
1044
1071
  let a = .7 + Math.random() * .9, o = 4 + Math.floor(Math.random() * 3), s = Array.from({ length: o }, (e, t) => ({
1045
1072
  dx: (t - o / 2) * 26 + (Math.random() - .5) * 14,
1046
1073
  dy: (Math.random() - .5) * 14,
1047
1074
  r: 22 + Math.random() * 20
1048
- })), { sprite: c, ox: l, oy: u } = ot(a, s, r, i);
1075
+ })), { sprite: c, ox: l, oy: u } = ct(a, s, r, i);
1049
1076
  return {
1050
1077
  x: Math.random() * (e + 240) - 120,
1051
1078
  y: t * .06 + Math.random() * t * n,
@@ -1057,7 +1084,7 @@ function st(e, t, n, r, i) {
1057
1084
  oy: u
1058
1085
  };
1059
1086
  }
1060
- function ct(e, t = 120) {
1087
+ function ut(e, t = 120) {
1061
1088
  let n = t * 2, r = document.createElement("canvas");
1062
1089
  r.width = n, r.height = n;
1063
1090
  let i = r.getContext("2d"), a = i.createRadialGradient(t, t, 0, t, t, t);
@@ -1068,7 +1095,7 @@ function ct(e, t = 120) {
1068
1095
  }
1069
1096
  //#endregion
1070
1097
  //#region src/components/weatherBackground/sprites/celestial.ts
1071
- function lt(e, t) {
1098
+ function dt(e, t) {
1072
1099
  let n = e.sun;
1073
1100
  if (n === "none") return null;
1074
1101
  let r = n === "full" ? 1 : n === "soft" ? .62 : .32, i = t * (n === "full" ? .72 : n === "soft" ? .62 : .5), a = t * (n === "full" ? 7.2 : n === "soft" ? 5.2 : 3.6), o = a;
@@ -1096,7 +1123,7 @@ function lt(e, t) {
1096
1123
  breathAmp: .018
1097
1124
  };
1098
1125
  }
1099
- function ut(e, t, n) {
1126
+ function ft(e, t, n) {
1100
1127
  if (e.sun === "none") return null;
1101
1128
  let r = t * .82, i = e.sun === "dim", a = i ? .45 : 1, o = r * (i ? 4.2 : 6.2), s = Math.ceil(Math.max(o, r * 2.6, r * 1.35) + 2), c = s * 2, l = document.createElement("canvas");
1102
1129
  l.width = c, l.height = c;
@@ -1150,12 +1177,12 @@ function ut(e, t, n) {
1150
1177
  }
1151
1178
  //#endregion
1152
1179
  //#region src/components/weatherBackground/sprites/snow.ts
1153
- var dt = (e) => {
1180
+ var pt = (e) => {
1154
1181
  let t = Math.ceil(e * 2 + 4), n = document.createElement("canvas");
1155
1182
  n.width = t, n.height = t;
1156
1183
  let r = n.getContext("2d"), i = r.createRadialGradient(t / 2, t / 2, 0, t / 2, t / 2, e + 1);
1157
1184
  return i.addColorStop(0, "rgba(255, 255, 255, 1)"), i.addColorStop(.6, "rgba(255, 255, 255, 0.85)"), i.addColorStop(1, "rgba(255, 255, 255, 0)"), r.fillStyle = i, r.fillRect(0, 0, t, t), n;
1158
- }, ft = (e) => {
1185
+ }, mt = (e) => {
1159
1186
  let t = Math.ceil(e * 2 + 6), n = document.createElement("canvas");
1160
1187
  n.width = t, n.height = t;
1161
1188
  let r = n.getContext("2d");
@@ -1182,22 +1209,22 @@ var dt = (e) => {
1182
1209
  r.closePath(), r.stroke();
1183
1210
  }
1184
1211
  return n;
1185
- }, pt = () => ({
1212
+ }, ht = () => ({
1186
1213
  dots: [
1187
1214
  1.2,
1188
1215
  1.6,
1189
1216
  2,
1190
1217
  2.3
1191
- ].map((e) => dt(e)),
1218
+ ].map((e) => pt(e)),
1192
1219
  crystals: [
1193
1220
  2.6,
1194
1221
  3.2,
1195
1222
  3.8,
1196
1223
  4.4,
1197
1224
  5
1198
- ].map((e) => ft(e * 2.4))
1199
- }), mt = (e) => e[Math.floor(Math.random() * e.length)], ht = (e, t, n, r) => {
1200
- let i = 1 + Math.random() ** 1.6 * 4.2, a = i >= 2.4, o = mt(a ? n.crystals : n.dots), s = a ? i * 4.8 + 6 : i * 2 + 4;
1225
+ ].map((e) => mt(e * 2.4))
1226
+ }), gt = (e) => e[Math.floor(Math.random() * e.length)], _t = (e, t, n, r) => {
1227
+ let i = 1 + Math.random() ** 1.6 * 4.2, a = i >= 2.4, o = gt(a ? n.crystals : n.dots), s = a ? i * 4.8 + 6 : i * 2 + 4;
1201
1228
  return {
1202
1229
  x: Math.random() * e,
1203
1230
  y: r ?? Math.random() * t,
@@ -1211,25 +1238,25 @@ var dt = (e) => {
1211
1238
  sprite: o,
1212
1239
  drawSize: s
1213
1240
  };
1214
- }, gt = (e, t) => t ? e === "smog" ? "96, 88, 66" : "138, 150, 168" : e === "smog" ? "168, 155, 126" : "226, 232, 238";
1215
- function _t(e) {
1216
- let { ctx: t, width: n, height: r, activeWeather: i, dayCycleTimes: a = null, sceneTimeMs: o, liveClock: s = !1, windMotion: c, rainLevel: l = 5, snowLevel: u = 5, hailLevel: d = 2, fogLevel: f = 2, smogLevel: p = 2 } = e, m = rt[i], h = (() => {
1241
+ }, vt = (e, t) => t ? e === "smog" ? "96, 88, 66" : "138, 150, 168" : e === "smog" ? "168, 155, 126" : "226, 232, 238";
1242
+ function yt(e) {
1243
+ let { ctx: t, width: n, height: r, activeWeather: i, dayCycleTimes: a = null, sceneTimeMs: o, liveClock: s = !1, windMotion: c, rainLevel: l = 5, snowLevel: u = 5, hailLevel: d = 2, fogLevel: f = 2, smogLevel: p = 2 } = e, m = at[i], h = (() => {
1217
1244
  let e = m;
1218
- return ue(i) && e.rain && (e = {
1245
+ return de(i) && e.rain && (e = {
1219
1246
  ...e,
1220
- rain: pe(e.rain, l)
1221
- }), de(i) && (e = {
1247
+ rain: ge(e.rain, l)
1248
+ }), fe(i) && (e = {
1222
1249
  ...e,
1223
- snowCount: me(u),
1250
+ snowCount: _e(u),
1224
1251
  fogBanks: u >= 7 ? Math.max(e.fogBanks, 3) : e.fogBanks,
1225
1252
  haze: u >= 7 ? Math.max(e.haze, .12) : e.haze
1226
- }), ne(i) && (e = re(e, f)), _e(i) && (e = ve(e, p)), e;
1227
- })(), g = it[i], _ = a ?? null, v = _ ? w(s ? Date.now() : o, _) : null, y = v ? !v.isDay : !1, b = v ? ee(h.sky, g.sky, v) : y ? g.sky : h.sky, x = y ? at(h.cloudColor) : h.cloudColor, S = Math.min(n, r) * .09, C = n * .72, E = r * .26;
1253
+ }), ne(i) && (e = re(e, f)), xe(i) && (e = Se(e, p)), e;
1254
+ })(), g = ot[i], _ = a ?? null, v = _ ? C(s ? Date.now() : o, _) : null, y = v ? !v.isDay : !1, b = v ? te(h.sky, g.sky, v) : y ? g.sky : h.sky, x = y ? st(h.cloudColor) : h.cloudColor, S = Math.min(n, r) * .09, T = n * .72, E = r * .26;
1228
1255
  if (v) {
1229
- let e = T(n, r, v.arcProgress);
1230
- C = e.x, E = e.y;
1256
+ let e = w(n, r, v.arcProgress);
1257
+ T = e.x, E = e.y;
1231
1258
  }
1232
- let D = te(t, r, b), O = [
1259
+ let ee = O(t, r, b), D = [
1233
1260
  {
1234
1261
  dx: -.32,
1235
1262
  dy: .08,
@@ -1250,29 +1277,29 @@ function _t(e) {
1250
1277
  dy: .24,
1251
1278
  r: .07
1252
1279
  }
1253
- ], k = lt(h, S), A = ut(h, S, O), j = y ? A : k, M = y || _ != null ? Array.from({ length: g.stars }, () => ({
1280
+ ], k = dt(h, S), A = ft(h, S, D), j = y ? A : k, M = y || _ != null ? Array.from({ length: g.stars }, () => ({
1254
1281
  x: Math.random() * n,
1255
1282
  y: Math.random() * r * .72,
1256
1283
  r: .4 + Math.random() * 1.1,
1257
1284
  phase: Math.random() * Math.PI * 2,
1258
1285
  speed: .015 + Math.random() * .035
1259
- })) : [], ae = Array.from({ length: h.cloudCount }, () => st(n, r, h.cloudSpread, x, h.cloudAlpha)), oe = h.rain ? Array.from({ length: h.rain.count }, () => ({
1286
+ })) : [], ae = Array.from({ length: h.cloudCount }, () => lt(n, r, h.cloudSpread, x, h.cloudAlpha)), ce = h.rain ? Array.from({ length: h.rain.count }, () => ({
1260
1287
  x: Math.random() * (n + 160) - 80,
1261
1288
  y: Math.random() * r,
1262
1289
  len: 8 + Math.random() * 10,
1263
1290
  speed: h.rain.speed * (.75 + Math.random() * .5)
1264
- })) : [], le = [], N = Array.from({ length: h.fogBanks }, (e, t) => ({
1291
+ })) : [], N = [], P = Array.from({ length: h.fogBanks }, (e, t) => ({
1265
1292
  x: Math.random() * n,
1266
1293
  y: t / Math.max(h.fogBanks - 1, 1) * r * .9 + r * .05,
1267
1294
  rw: n * (.25 + Math.random() * .3),
1268
1295
  rh: r * (.08 + Math.random() * .08),
1269
1296
  speed: (.1 + Math.random() * .25) * (t % 2 == 0 ? 1 : -1),
1270
- alpha: (.1 + Math.random() * .1) * (ne(i) ? ie(f) : _e(i) ? ye(p) : 1)
1271
- })), P = h.fogBanks > 0 ? ct(gt(i, y)) : null, F = h.snowCount > 0 ? pt() : null, I = F == null ? [] : Array.from({ length: h.snowCount }, () => ht(n, r, F)), L = se(i) ? ce(d) : null, R = L == null ? null : Ke(), z = R != null && L != null ? Array.from({ length: L.count }, () => Ye(n, r, R, {
1297
+ alpha: (.1 + Math.random() * .1) * (ne(i) ? ie(f) : xe(i) ? Ce(p) : 1)
1298
+ })), F = h.fogBanks > 0 ? ut(vt(i, y)) : null, I = h.snowCount > 0 ? ht() : null, le = I == null ? [] : Array.from({ length: h.snowCount }, () => _t(n, r, I)), L = oe(i) ? se(d) : null, R = L == null ? null : Je(), ue = R != null && L != null ? Array.from({ length: L.count }, () => Ze(n, r, R, {
1272
1299
  min: L.sizeMin,
1273
1300
  max: L.sizeMax
1274
- }, L.speedMul)) : [], B = (() => {
1275
- let { count: e } = Pe(c.visualLevel);
1301
+ }, L.speedMul)) : [], pe = (() => {
1302
+ let { count: e } = Ie(c.visualLevel);
1276
1303
  return e <= 0 ? [] : Array.from({ length: e }, () => ({
1277
1304
  x: Math.random() * n,
1278
1305
  y: Math.random() * r,
@@ -1283,19 +1310,19 @@ function _t(e) {
1283
1310
  width: .5 + Math.random() * 1.1,
1284
1311
  phase: Math.random() * Math.PI * 2
1285
1312
  }));
1286
- })(), V = [], H = 120 + Math.random() * 240;
1313
+ })(), me = [], z = 120 + Math.random() * 240;
1287
1314
  return {
1288
1315
  sky: b,
1289
1316
  cloudRgb: x,
1290
1317
  cfg: h,
1291
- sunX: C,
1318
+ sunX: T,
1292
1319
  sunY: E,
1293
1320
  sunR: S,
1294
- skyGradient: D,
1321
+ skyGradient: ee,
1295
1322
  celestial: j,
1296
1323
  sunSprite: k,
1297
1324
  moonSprite: A,
1298
- fogSprite: P,
1325
+ fogSprite: F,
1299
1326
  dayCycleTimes: _,
1300
1327
  dayCycle: v,
1301
1328
  sceneTimeMs: o,
@@ -1303,35 +1330,35 @@ function _t(e) {
1303
1330
  hailSpec: L,
1304
1331
  state: {
1305
1332
  stars: M,
1306
- moonCraters: O,
1333
+ moonCraters: D,
1307
1334
  clouds: ae,
1308
- drops: oe,
1309
- splashes: le,
1310
- fogBanks: N,
1311
- flakes: I,
1312
- hailstones: z,
1335
+ drops: ce,
1336
+ splashes: N,
1337
+ fogBanks: P,
1338
+ flakes: le,
1339
+ hailstones: ue,
1313
1340
  hailPool: R ?? [],
1314
- windStreaks: B,
1341
+ windStreaks: pe,
1315
1342
  t: 0,
1316
1343
  flashAlpha: 0,
1317
1344
  boltLife: 0,
1318
- boltPoints: V,
1319
- nextStrike: H
1345
+ boltPoints: me,
1346
+ nextStrike: z
1320
1347
  }
1321
1348
  };
1322
1349
  }
1323
- function vt(e, t) {
1350
+ function bt(e, t) {
1324
1351
  if (!e.dayCycleTimes) return;
1325
- let n = w(e.liveClock ? t ?? Date.now() : e.sceneTimeMs, e.dayCycleTimes), r = it[e.activeWeather], i = ee(e.cfg.sky, r.sky, n), a = T(e.width, e.height, n.arcProgress);
1326
- e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient = te(e.ctx, e.height, i), e.sunX = a.x, e.sunY = a.y, e.celestial = n.isDay ? e.sunSprite : e.moonSprite;
1352
+ let n = C(e.liveClock ? t ?? Date.now() : e.sceneTimeMs, e.dayCycleTimes), r = ot[e.activeWeather], i = te(e.cfg.sky, r.sky, n), a = w(e.width, e.height, n.arcProgress);
1353
+ e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient = O(e.ctx, e.height, i), e.sunX = a.x, e.sunY = a.y, e.celestial = n.isDay ? e.sunSprite : e.moonSprite;
1327
1354
  }
1328
1355
  //#endregion
1329
1356
  //#region src/components/weatherBackground/scene/create-weather-scene.ts
1330
- function yt(e, t) {
1331
- t && (e.state.t += 1), e.windField = Y(e.state.t, e.windMotion), e.dayCycleTimes && vt(e, e.liveClock ? Date.now() : e.sceneTimeMs), $e(e), nt(e), ze(e), Be(e), Ve(e), Xe(e), Ze(e), Qe(e), He(e), Ue(e);
1357
+ function xt(e, t) {
1358
+ t && (e.state.t += 1), e.windField = Y(e.state.t, e.windMotion), e.dayCycleTimes && bt(e, e.liveClock ? Date.now() : e.sceneTimeMs), tt(e), it(e), Ve(e), He(e), Ue(e), Qe(e), $e(e), et(e), We(e), Ge(e);
1332
1359
  }
1333
- function bt(e) {
1334
- let { ctx: t, width: n, height: r, activeWeather: i, activeNight: a, windMotion: o } = e, s = _t(e), u = {
1360
+ function St(e) {
1361
+ let { ctx: t, width: n, height: r, activeWeather: i, activeNight: a, windMotion: o } = e, s = yt(e), u = {
1335
1362
  ctx: t,
1336
1363
  width: n,
1337
1364
  height: r,
@@ -1341,17 +1368,17 @@ function bt(e) {
1341
1368
  windField: Y(0, o),
1342
1369
  ...s
1343
1370
  };
1344
- u.dayCycleTimes && vt(u, u.liveClock ? Date.now() : u.sceneTimeMs);
1345
- let d = document.hidden, p = f(), m = l((e) => {
1346
- d = e;
1371
+ u.dayCycleTimes && bt(u, u.liveClock ? Date.now() : u.sceneTimeMs);
1372
+ let f = document.hidden, p = d(), m = l((e) => {
1373
+ f = e;
1347
1374
  }), h = c((e) => {
1348
1375
  p = e;
1349
1376
  });
1350
- if (p) return yt(u, !1), () => {
1377
+ if (p) return xt(u, !1), () => {
1351
1378
  m(), h();
1352
1379
  };
1353
1380
  let g = 0, _ = () => {
1354
- g = requestAnimationFrame(_), !d && (p || yt(u, !0));
1381
+ g = requestAnimationFrame(_), !f && (p || xt(u, !0));
1355
1382
  };
1356
1383
  return _(), () => {
1357
1384
  cancelAnimationFrame(g), m(), h();
@@ -1360,7 +1387,7 @@ function bt(e) {
1360
1387
  //#endregion
1361
1388
  //#region src/components/weatherBackground/core/engine.ts
1362
1389
  var Z = "cos-weather-background", Q = 800, $ = 450;
1363
- function xt(e, t = {}) {
1390
+ function Ct(e, t = {}) {
1364
1391
  let n = {
1365
1392
  fill: !1,
1366
1393
  weather: "partlyCloudy",
@@ -1375,7 +1402,7 @@ function xt(e, t = {}) {
1375
1402
  loading: !1,
1376
1403
  loadingText: "天气加载中…",
1377
1404
  ...t
1378
- }, r = !1, i = n.width ?? Q, a = n.height ?? $, o = null, c = null, l = null, d = G, f = { current: n.onLiveWeather }, m = document.createElement("div");
1405
+ }, r = !1, i = n.width ?? Q, a = n.height ?? $, o = null, c = null, l = null, d = B, p = { current: n.onLiveWeather }, m = document.createElement("div");
1379
1406
  m.className = Z;
1380
1407
  let h = document.createElement("canvas");
1381
1408
  h.className = `${Z}__canvas`, h.setAttribute("role", "img");
@@ -1391,30 +1418,30 @@ function xt(e, t = {}) {
1391
1418
  width: i,
1392
1419
  height: a
1393
1420
  }), h.style.width = `${i}px`, h.style.height = `${a}px`;
1394
- }, b = (e, t, r) => {
1421
+ }, x = (e, t, r) => {
1395
1422
  g.hidden = !(n.loading || n.live && (d.status === "locating" || d.status === "fetching")), v.textContent = n.loadingText ?? "天气加载中…", h.setAttribute("aria-label", n.ariaLabel ?? `天气背景:${e}${t ? "(夜间)" : ""},${r}级风`);
1396
- }, S = () => {
1423
+ }, w = () => {
1397
1424
  c?.(), c = null;
1398
1425
  let e = window.devicePixelRatio || 1;
1399
1426
  h.width = i * e, h.height = a * e;
1400
1427
  let t = h.getContext("2d");
1401
1428
  if (!t) return;
1402
1429
  t.setTransform(e, 0, 0, e, 0, 0);
1403
- let r = !!n.live, o = R(r && d.weather ? d.weather : n.weather ?? "partlyCloudy"), s = r && d.rainLevel != null ? d.rainLevel : n.rainLevel ?? 5, l = r && d.snowLevel != null ? d.snowLevel : n.snowLevel ?? 5, u = r && d.fogLevel != null ? d.fogLevel : n.fogLevel ?? 2, f = r && d.hailLevel != null ? d.hailLevel : n.hailLevel ?? 2, p = r && d.smogLevel != null ? d.smogLevel : n.smogLevel ?? 2, m = fe(o, s, l), g = C(n.time), _ = d.current?.sunrise ?? null, v = d.current?.sunset ?? null, y = d.current?.windSpeed ?? null, S = r && _ != null && v != null ? {
1430
+ let r = !!n.live, o = L(r && d.weather ? d.weather : n.weather ?? "partlyCloudy"), s = r && d.rainLevel != null ? d.rainLevel : n.rainLevel ?? 5, l = r && d.snowLevel != null ? d.snowLevel : n.snowLevel ?? 5, u = r && d.fogLevel != null ? d.fogLevel : n.fogLevel ?? 2, f = r && d.hailLevel != null ? d.hailLevel : n.hailLevel ?? 2, p = r && d.smogLevel != null ? d.smogLevel : n.smogLevel ?? 2, m = he(o, s, l), g = S(n.time), _ = d.current?.sunrise ?? null, v = d.current?.sunset ?? null, y = d.current?.windSpeed ?? null, w = r && _ != null && v != null ? {
1404
1431
  sunrise: _,
1405
1432
  sunset: v
1406
- } : x(g), T = Le(Re({
1433
+ } : b(g), T = ze(Be({
1407
1434
  live: r,
1408
1435
  windLevel: n.windLevel ?? 3,
1409
1436
  liveWindKmh: y
1410
- })), E = r && d.current ? !d.current.isDay : !w(g, S).isDay;
1411
- b(o, E, T.level), c = bt({
1437
+ })), E = r && d.current ? !d.current.isDay : !C(g, w).isDay;
1438
+ x(o, E, T.level), c = St({
1412
1439
  ctx: t,
1413
1440
  width: i,
1414
1441
  height: a,
1415
1442
  activeWeather: m,
1416
1443
  activeNight: E,
1417
- dayCycleTimes: S,
1444
+ dayCycleTimes: w,
1418
1445
  sceneTimeMs: g,
1419
1446
  liveClock: r,
1420
1447
  windMotion: T,
@@ -1426,22 +1453,22 @@ function xt(e, t = {}) {
1426
1453
  });
1427
1454
  }, T = () => {
1428
1455
  if (l?.(), l = null, !n.live) {
1429
- d = G, S();
1456
+ d = B, w();
1430
1457
  return;
1431
1458
  }
1432
- l = ke(!0, n.latitude != null && n.longitude != null ? {
1459
+ l = K(!0, n.latitude != null && n.longitude != null ? {
1433
1460
  latitude: n.latitude,
1434
1461
  longitude: n.longitude
1435
1462
  } : void 0, (e) => {
1436
- d = e, e.weather && f.current?.(R(e.weather)), S();
1463
+ d = e, e.weather && p.current?.(L(e.weather)), w();
1437
1464
  });
1438
1465
  }, E = () => {
1439
1466
  if (o?.(), o = null, !(n.fill ?? !1)) {
1440
- i = n.width ?? Q, a = n.height ?? $, y(), S();
1467
+ i = n.width ?? Q, a = n.height ?? $, y(), w();
1441
1468
  return;
1442
1469
  }
1443
1470
  o = u(e, (e) => {
1444
- let t = p({
1471
+ let t = f({
1445
1472
  fill: !0,
1446
1473
  width: n.width,
1447
1474
  height: n.height,
@@ -1449,7 +1476,7 @@ function xt(e, t = {}) {
1449
1476
  defaultHeight: $,
1450
1477
  measured: e
1451
1478
  });
1452
- i = t.width, a = t.height, y(), S();
1479
+ i = t.width, a = t.height, y(), w();
1453
1480
  });
1454
1481
  };
1455
1482
  return E(), T(), {
@@ -1458,13 +1485,13 @@ function xt(e, t = {}) {
1458
1485
  n = {
1459
1486
  ...n,
1460
1487
  ...e
1461
- }, f.current = n.onLiveWeather;
1488
+ }, p.current = n.onLiveWeather;
1462
1489
  let r = t.live !== n.live || t.latitude !== n.latitude || t.longitude !== n.longitude;
1463
1490
  if (t.fill !== n.fill || t.width !== n.width || t.height !== n.height) E();
1464
1491
  else if (r) T();
1465
1492
  else {
1466
1493
  let e = (e) => JSON.stringify(e, (e, t) => typeof t == "function" ? void 0 : t);
1467
- e(t) !== e(n) && S();
1494
+ e(t) !== e(n) && w();
1468
1495
  }
1469
1496
  },
1470
1497
  destroy() {
@@ -1474,7 +1501,7 @@ function xt(e, t = {}) {
1474
1501
  }
1475
1502
  //#endregion
1476
1503
  //#region src/components/weatherBackground/vue/WeatherBackground.vue
1477
- var St = /* @__PURE__ */ t({
1504
+ var wt = /* @__PURE__ */ t({
1478
1505
  __name: "WeatherBackground",
1479
1506
  props: {
1480
1507
  width: {},
@@ -1498,20 +1525,66 @@ var St = /* @__PURE__ */ t({
1498
1525
  },
1499
1526
  emits: ["live-weather"],
1500
1527
  setup(t, { expose: s, emit: c }) {
1501
- let l = t, u = c, f = a(), p = null, m = () => ({
1528
+ let l = t, u = c, d = a(), f = null, p = () => ({
1502
1529
  ...l,
1503
1530
  onLiveWeather: (...e) => u("live-weather", ...e)
1504
1531
  });
1505
1532
  return n(() => {
1506
- f.value && (p = xt(f.value, m()));
1507
- }), o(() => d(l), () => p?.update(m())), r(() => {
1508
- p?.destroy(), p = null;
1533
+ d.value && (f = Ct(d.value, p()));
1534
+ }), o(() => ({ ...l }), () => f?.update(p()), { deep: !0 }), r(() => {
1535
+ f?.destroy(), f = null;
1509
1536
  }), s({}), (t, n) => (i(), e("div", {
1510
1537
  ref_key: "hostRef",
1511
- ref: f,
1538
+ ref: d,
1512
1539
  class: "cos-weatherBackground-host"
1513
1540
  }, null, 512));
1514
1541
  }
1515
- });
1542
+ }), Tt = (e, t) => {
1543
+ let n = H(t);
1544
+ return e ? n ? {
1545
+ ...B,
1546
+ status: "fetching"
1547
+ } : {
1548
+ ...B,
1549
+ status: "locating"
1550
+ } : B;
1551
+ };
1552
+ function Et(e = !0, t) {
1553
+ let n = a(Tt(e, t)), i = null, s = () => {
1554
+ i?.(), i = K(e, t, (e) => {
1555
+ n.value = e;
1556
+ });
1557
+ };
1558
+ return o(() => [
1559
+ e,
1560
+ t?.latitude,
1561
+ t?.longitude
1562
+ ], () => {
1563
+ n.value = Tt(e, t), s();
1564
+ }, { immediate: !0 }), r(() => {
1565
+ i?.(), i = null;
1566
+ }), n;
1567
+ }
1568
+ function Dt(e) {
1569
+ let t = a(null);
1570
+ return o(() => [
1571
+ H(e),
1572
+ e?.latitude,
1573
+ e?.longitude
1574
+ ], ([e, n, r], i, a) => {
1575
+ if (!e || n == null || r == null) {
1576
+ t.value = null;
1577
+ return;
1578
+ }
1579
+ let o = new AbortController(), s = !1;
1580
+ q(n, r, o.signal).then((e) => {
1581
+ s || (t.value = e);
1582
+ }).catch(() => {
1583
+ s || (t.value = null);
1584
+ }), a(() => {
1585
+ s = !0, o.abort();
1586
+ });
1587
+ }, { immediate: !0 }), t;
1588
+ }
1516
1589
  //#endregion
1517
- export { St as WeatherBackground };
1590
+ export { B as IDLE_LIVE_WEATHER, wt as WeatherBackground, Ae as fetchLiveWeather, q as fetchSunTimes, W as formatLocalHm, ke as getDayCycleTimesFromLive, H as isValidCoords, Ee as mapWmoCodeToWeatherType, K as subscribeLiveWeather, je as subscribeSunTimes, Et as useLiveWeather, Dt as useSunTimes };