@idm-plugin/meteo2 0.6.1 → 0.6.3

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
@@ -25,9 +25,9 @@ class Q0 {
25
25
  * @param source
26
26
  * @param options
27
27
  */
28
- static async queryPointMeteo(M, z, b, A = !1, c = "", o = {}) {
28
+ static async queryPointMeteo(M, z, b, A = !1, c = "", W = {}) {
29
29
  typeof b == "number" && (b = b < 1e12 ? b * 1e3 : b);
30
- const O = L(b), W = {
30
+ const O = L(b), o = {
31
31
  searchParams: {
32
32
  lng: M,
33
33
  lat: z,
@@ -37,14 +37,14 @@ class Q0 {
37
37
  },
38
38
  timeout: 3e4
39
39
  }, Y = L(), n = Y.valueOf();
40
- O.isBefore(Y.subtract(1, "month")) && (s == null || s.warn("[%s] get history meteo on %s: %j", o.requestId, O.format(), W));
41
- const X = "https://aod4idm.idmwx.com/api/ocean/point", q = await Q.get(X, W).json(), T = L().valueOf();
42
- if (s == null || s.info("[%s] get meteo(cost: %d ms) from %s with options: %j", o.requestId, T - n, X, W), (q == null ? void 0 : q.code) === 0)
40
+ O.isBefore(Y.subtract(1, "month")) && (s == null || s.warn("[%s] get history meteo on %s: %j", W.requestId, O.format(), o));
41
+ const X = "https://aod4idm.idmwx.com/api/ocean/point", q = await Q.get(X, o).json(), T = L().valueOf();
42
+ if (s == null || s.info("[%s] get meteo(cost: %d ms) from %s with options: %j", W.requestId, T - n, X, o), (q == null ? void 0 : q.code) === 0)
43
43
  return {
44
44
  ...q.data,
45
45
  source: c
46
46
  };
47
- s == null || s.warn("[%s] get meteo failed: %j", o.requestId, q);
47
+ s == null || s.warn("[%s] get meteo failed: %j", W.requestId, q);
48
48
  }
49
49
  /**
50
50
  * 点查海洋气象要素(指定要素组合)
@@ -60,9 +60,9 @@ class Q0 {
60
60
  * @param source
61
61
  * @param options
62
62
  */
63
- static async queryPointFactor(M, z, b, A = "wind,wave,current,watertemp,visibility", c = "", o = {}) {
63
+ static async queryPointFactor(M, z, b, A = "wind,wave,current,watertemp,visibility", c = "", W = {}) {
64
64
  typeof b == "number" && (b = b < 1e12 ? b * 1e3 : b);
65
- const O = L(b), W = {
65
+ const O = L(b), o = {
66
66
  searchParams: {
67
67
  lng: M,
68
68
  lat: z,
@@ -72,24 +72,24 @@ class Q0 {
72
72
  },
73
73
  timeout: 3e4
74
74
  }, Y = L(), n = Y.valueOf();
75
- O.isBefore(Y.subtract(1, "month")) && (s == null || s.warn("[%s] get history factors on %s: %j", o.requestId, O.format(), W));
76
- const X = "https://aod4idm.idmwx.com/api/ocean/factor", q = await Q.get(X, W).json(), T = L().valueOf();
77
- if (s == null || s.info("[%s] get factors(cost: %d ms) from %s with options: %j", o.requestId, T - n, X, W), (q == null ? void 0 : q.code) === 0)
75
+ O.isBefore(Y.subtract(1, "month")) && (s == null || s.warn("[%s] get history factors on %s: %j", W.requestId, O.format(), o));
76
+ const X = "https://aod4idm.idmwx.com/api/ocean/factor", q = await Q.get(X, o).json(), T = L().valueOf();
77
+ if (s == null || s.info("[%s] get factors(cost: %d ms) from %s with options: %j", W.requestId, T - n, X, o), (q == null ? void 0 : q.code) === 0)
78
78
  return {
79
79
  ...q.data,
80
80
  source: c
81
81
  };
82
- s == null || s.warn("[%s] get factors failed: %j", o.requestId, q);
82
+ s == null || s.warn("[%s] get factors failed: %j", W.requestId, q);
83
83
  }
84
84
  /**
85
85
  * @see https://api.windy.com/point-forecast/docs
86
86
  * @param key
87
87
  */
88
88
  static async queryWindyPointForecast(M, z, b, A = {}) {
89
- const c = "https://api.windy.com/api/point-forecast/v2", o = [];
89
+ const c = "https://api.windy.com/api/point-forecast/v2", W = [];
90
90
  try {
91
91
  let O = L().valueOf();
92
- const W = await Q.post(c, {
92
+ const o = await Q.post(c, {
93
93
  headers: {
94
94
  "Content-Type": "application/json"
95
95
  },
@@ -134,28 +134,28 @@ class Q0 {
134
134
  }
135
135
  }).json();
136
136
  Y = L().valueOf(), s == null || s.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", A.requestId, Y - O, c);
137
- for (let q = 0; q < W.ts.length; q++) {
138
- const T = this.populateUVFactor(W["wind_u-surface"][q], W["wind_v-surface"][q], !1, A);
139
- T.scale = this.calculateBeaufortWindForceScale(T.speed), o.push({
140
- utc: L(W.ts[q]).utc().format(),
141
- temp: W["temp-surface"][q] ? Math.round((W["temp-surface"][q] - 273.15) * 100) / 100 : void 0,
142
- dp_temp: W["dewpoint-surface"][q] ? Math.round((W["dewpoint-surface"][q] - 273.15) * 100) / 100 : void 0,
137
+ for (let q = 0; q < o.ts.length; q++) {
138
+ const T = this.populateUVFactor(o["wind_u-surface"][q], o["wind_v-surface"][q], !1, A);
139
+ T.scale = this.calculateBeaufortWindForceScale(T.speed), W.push({
140
+ utc: L(o.ts[q]).utc().format(),
141
+ temp: o["temp-surface"][q] ? Math.round((o["temp-surface"][q] - 273.15) * 100) / 100 : void 0,
142
+ dp_temp: o["dewpoint-surface"][q] ? Math.round((o["dewpoint-surface"][q] - 273.15) * 100) / 100 : void 0,
143
143
  precip: {
144
- inter3h: W["past3hprecip-surface"][q] ? Math.round(W["past3hprecip-surface"][q] * 1e3 * 1e3) / 1e3 : 0,
145
- inter3hSnow: W["past3hsnowprecip-surface"][q] ? Math.round(W["past3hsnowprecip-surface"][q] * 1e3 * 1e3) / 1e3 : 0,
146
- inter3hConv: W["past3hconvprecip-surface"][q] ? Math.round(W["past3hconvprecip-surface"][q] * 1e3 * 1e3) / 1e3 : 0
144
+ inter3h: o["past3hprecip-surface"][q] ? Math.round(o["past3hprecip-surface"][q] * 1e3 * 1e3) / 1e3 : 0,
145
+ inter3hSnow: o["past3hsnowprecip-surface"][q] ? Math.round(o["past3hsnowprecip-surface"][q] * 1e3 * 1e3) / 1e3 : 0,
146
+ inter3hConv: o["past3hconvprecip-surface"][q] ? Math.round(o["past3hconvprecip-surface"][q] * 1e3 * 1e3) / 1e3 : 0
147
147
  },
148
148
  wind: T,
149
149
  gusts: {
150
- speed: Math.round((W["gust-surface"][q] || 0) * 100) / 100,
151
- kts: this.convertMs2Kts(W["gust-surface"][q])
150
+ speed: Math.round((o["gust-surface"][q] || 0) * 100) / 100,
151
+ kts: this.convertMs2Kts(o["gust-surface"][q])
152
152
  },
153
- lclouds: W["lclouds-surface"][q] ? Math.round(W["lclouds-surface"][q] * 100) / 100 : 0,
154
- mclouds: W["mclouds-surface"][q] ? Math.round(W["mclouds-surface"][q] * 100) / 100 : 0,
155
- hclouds: W["hclouds-surface"][q] ? Math.round(W["hclouds-surface"][q] * 100) / 100 : 0,
156
- rh: W["rh-surface"][q] ? Math.round(W["rh-surface"][q] * 100) / 100 : 0,
157
- gh: W["gh-surface"][q] ? Math.round(W["gh-surface"][q] * 100) / 100 : 0,
158
- pressure: Math.round(W["pressure-surface"][q] / 100 * 100) / 100
153
+ lclouds: o["lclouds-surface"][q] ? Math.round(o["lclouds-surface"][q] * 100) / 100 : 0,
154
+ mclouds: o["mclouds-surface"][q] ? Math.round(o["mclouds-surface"][q] * 100) / 100 : 0,
155
+ hclouds: o["hclouds-surface"][q] ? Math.round(o["hclouds-surface"][q] * 100) / 100 : 0,
156
+ rh: o["rh-surface"][q] ? Math.round(o["rh-surface"][q] * 100) / 100 : 0,
157
+ gh: o["gh-surface"][q] ? Math.round(o["gh-surface"][q] * 100) / 100 : 0,
158
+ pressure: Math.round(o["pressure-surface"][q] / 100 * 100) / 100
159
159
  });
160
160
  }
161
161
  const X = [];
@@ -171,14 +171,14 @@ class Q0 {
171
171
  }
172
172
  });
173
173
  }
174
- for (const q of o) {
174
+ for (const q of W) {
175
175
  const T = X.find((i) => i.utc === q.utc);
176
176
  q.wave = T == null ? void 0 : T.wave;
177
177
  }
178
178
  } catch (O) {
179
179
  s.warn("[%s] get-gfs-factor failed: %s", A.requestId, O);
180
180
  }
181
- return o;
181
+ return W;
182
182
  }
183
183
  /**
184
184
  * 填充UV向量
@@ -188,11 +188,11 @@ class Q0 {
188
188
  * @param options
189
189
  */
190
190
  static populateUVFactor(M, z, b = !1, A = {}) {
191
- const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(z, 2)) * 1e4) / 1e4, { degree: o, direction: O } = this.calculateUVDirection(M, z, b, A), W = this.convertMs2Kts(c);
191
+ const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(z, 2)) * 1e4) / 1e4, { degree: W, direction: O } = this.calculateUVDirection(M, z, b, A), o = this.convertMs2Kts(c);
192
192
  return {
193
193
  speed: c,
194
- kts: W,
195
- degree: o,
194
+ kts: o,
195
+ degree: W,
196
196
  direction: O,
197
197
  eastward: Math.round(M * 1e4) / 1e4,
198
198
  northward: Math.round(z * 1e4) / 1e4
@@ -211,11 +211,11 @@ class Q0 {
211
211
  static calculateUVDirection(M, z, b = !1, A = {}) {
212
212
  let c = Math.atan2(M, z) + Math.PI;
213
213
  b && (c = Math.atan2(M, z));
214
- const o = this.convert2Direction(c);
214
+ const W = this.convert2Direction(c);
215
215
  return c = Math.round(c / (2 * Math.PI) * 360 * 1e4) / 1e4, {
216
216
  angle: c,
217
217
  degree: c,
218
- direction: o
218
+ direction: W
219
219
  };
220
220
  }
221
221
  /**
@@ -271,9 +271,9 @@ var a0 = { exports: {} };
271
271
  throw new RangeError("invalid coordinates");
272
272
  if (90 <= z)
273
273
  return "Etc/GMT";
274
- var o = -1, O = 48 * (180 + b) / 360.00000000000006, W = 24 * (90 - z) / 180.00000000000003, Y = 0 | O, n = 0 | W, X = 96 * n + 2 * Y;
274
+ var W = -1, O = 48 * (180 + b) / 360.00000000000006, o = 24 * (90 - z) / 180.00000000000003, Y = 0 | O, n = 0 | o, X = 96 * n + 2 * Y;
275
275
  for (X = 56 * A.charCodeAt(X) + A.charCodeAt(X + 1) - 1995; X + c.length < 3136; )
276
- X = 56 * A.charCodeAt(X = 8 * (o = o + X + 1) + 4 * (n = 0 | (W = 2 * (W - n) % 2)) + 2 * (Y = 0 | (O = 2 * (O - Y) % 2)) + 2304) + A.charCodeAt(X + 1) - 1995;
276
+ X = 56 * A.charCodeAt(X = 8 * (W = W + X + 1) + 4 * (n = 0 | (o = 2 * (o - n) % 2)) + 2 * (Y = 0 | (O = 2 * (O - Y) % 2)) + 2304) + A.charCodeAt(X + 1) - 1995;
277
277
  return c[X + c.length - 3136];
278
278
  }
279
279
  r.exports = M;
@@ -291,7 +291,7 @@ var n0 = { exports: {} };
291
291
  r.exports ? r.exports = z(L) : z(M.moment);
292
292
  })(B0, function(M) {
293
293
  M.version === void 0 && M.default && (M = M.default);
294
- var z = "0.5.48", b = {}, A = {}, c = {}, o = {}, O = {}, W;
294
+ var z = "0.5.48", b = {}, A = {}, c = {}, W = {}, O = {}, o;
295
295
  (!M || typeof M.version != "string") && v("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
296
296
  var Y = M.version.split("."), n = +Y[0], X = +Y[1];
297
297
  (n < 2 || n === 2 && X < 6) && v("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
@@ -422,14 +422,14 @@ var n0 = { exports: {} };
422
422
  N[B] = !0;
423
423
  }
424
424
  for (u in a)
425
- a.hasOwnProperty(u) && R.push(o[u]);
425
+ a.hasOwnProperty(u) && R.push(W[u]);
426
426
  return R;
427
427
  }
428
428
  function Z() {
429
429
  try {
430
430
  var p = Intl.DateTimeFormat().resolvedOptions().timeZone;
431
431
  if (p && p.length > 3) {
432
- var d = o[_(p)];
432
+ var d = W[_(p)];
433
433
  if (d)
434
434
  return d;
435
435
  v("Moment Timezone found " + p + " from the Intl api, but did not have that data loaded.");
@@ -445,7 +445,7 @@ var n0 = { exports: {} };
445
445
  return u.sort(g), u.length > 0 ? u[0].zone.name : void 0;
446
446
  }
447
447
  function k(p) {
448
- return (!W || p) && (W = Z()), W;
448
+ return (!o || p) && (o = Z()), o;
449
449
  }
450
450
  function _(p) {
451
451
  return (p || "").toLowerCase().replace(/\//g, "_");
@@ -453,17 +453,17 @@ var n0 = { exports: {} };
453
453
  function W0(p) {
454
454
  var d, a, R, N;
455
455
  for (typeof p == "string" && (p = [p]), d = 0; d < p.length; d++)
456
- R = p[d].split("|"), a = R[0], N = _(a), b[N] = p[d], o[N] = a, D(N, R[2].split(" "));
456
+ R = p[d].split("|"), a = R[0], N = _(a), b[N] = p[d], W[N] = a, D(N, R[2].split(" "));
457
457
  }
458
458
  function y(p, d) {
459
459
  p = _(p);
460
460
  var a = b[p], R;
461
- return a instanceof V ? a : typeof a == "string" ? (a = new V(a), b[p] = a, a) : A[p] && d !== y && (R = y(A[p], y)) ? (a = b[p] = new V(), a._set(R), a.name = o[p], a) : null;
461
+ return a instanceof V ? a : typeof a == "string" ? (a = new V(a), b[p] = a, a) : A[p] && d !== y && (R = y(A[p], y)) ? (a = b[p] = new V(), a._set(R), a.name = W[p], a) : null;
462
462
  }
463
463
  function L0() {
464
464
  var p, d = [];
465
- for (p in o)
466
- o.hasOwnProperty(p) && (b[p] || b[A[p]]) && o[p] && d.push(o[p]);
465
+ for (p in W)
466
+ W.hasOwnProperty(p) && (b[p] || b[A[p]]) && W[p] && d.push(W[p]);
467
467
  return d.sort();
468
468
  }
469
469
  function e0() {
@@ -472,7 +472,7 @@ var n0 = { exports: {} };
472
472
  function o0(p) {
473
473
  var d, a, R, N;
474
474
  for (typeof p == "string" && (p = [p]), d = 0; d < p.length; d++)
475
- a = p[d].split("|"), R = _(a[0]), N = _(a[1]), A[R] = N, o[R] = a[0], A[N] = R, o[N] = a[1];
475
+ a = p[d].split("|"), R = _(a[0]), N = _(a[1]), A[R] = N, W[R] = a[0], A[N] = R, W[N] = a[1];
476
476
  }
477
477
  function T0(p) {
478
478
  var d, a, R, N;
@@ -515,7 +515,7 @@ var n0 = { exports: {} };
515
515
  var d = Array.prototype.slice.call(arguments, 0, -1), a = arguments[arguments.length - 1], R = M.utc.apply(null, d), N;
516
516
  return !M.isMoment(p) && A0(R) && (N = y(a)) && R.add(N.parse(R), "minutes"), R.tz(a), R;
517
517
  }
518
- l.version = z, l.dataVersion = "", l._zones = b, l._links = A, l._names = o, l._countries = c, l.add = W0, l.link = o0, l.load = f0, l.zone = y, l.zoneExists = O0, l.guess = k, l.names = L0, l.Zone = V, l.unpack = U, l.unpackBase60 = T, l.needsOffset = A0, l.moveInvalidForward = !0, l.moveAmbiguousForward = !1, l.countries = e0, l.zonesForCountry = r0;
518
+ l.version = z, l.dataVersion = "", l._zones = b, l._links = A, l._names = W, l._countries = c, l.add = W0, l.link = o0, l.load = f0, l.zone = y, l.zoneExists = O0, l.guess = k, l.names = L0, l.Zone = V, l.unpack = U, l.unpackBase60 = T, l.needsOffset = A0, l.moveInvalidForward = !0, l.moveAmbiguousForward = !1, l.countries = e0, l.zonesForCountry = r0;
519
519
  var w = M.fn;
520
520
  M.tz = l, M.defaultZone = null, M.updateOffset = function(p, d) {
521
521
  var a = M.defaultZone, R;
@@ -1489,21 +1489,21 @@ class J0 {
1489
1489
  const b = L();
1490
1490
  let A;
1491
1491
  if (M.start_dates instanceof Array)
1492
- for (let o = 0; o < M.start_dates.length; o++) {
1493
- M.start_date = M.start_dates[o], M.end_date = M.end_dates[o], M.fake = M.fakes[o];
1494
- const O = M.url[o];
1492
+ for (let W = 0; W < M.start_dates.length; W++) {
1493
+ M.start_date = M.start_dates[W], M.end_date = M.end_dates[W], M.fake = M.fakes[W];
1494
+ const O = M.url[W];
1495
1495
  this.debug && K.debug("[%s] fetch weather via %s with %j", z.requestId, O, {
1496
1496
  start_date: M.start_date,
1497
1497
  end_date: M.end_date,
1498
1498
  fake: M.fake,
1499
- step: o
1499
+ step: W
1500
1500
  });
1501
- const W = await z0(O, M), Y = await this.parseWeatherData(W, M, z);
1501
+ const o = await z0(O, M), Y = await this.parseWeatherData(o, M, z);
1502
1502
  A ? await this.mergeSegments(A, Y) : A = Y;
1503
1503
  }
1504
1504
  else {
1505
- const o = await z0(M.url, M);
1506
- A = await this.parseWeatherData(o, M, z);
1505
+ const W = await z0(M.url, M);
1506
+ A = await this.parseWeatherData(W, M, z);
1507
1507
  }
1508
1508
  delete M.apikey;
1509
1509
  const c = L();
@@ -1529,7 +1529,7 @@ class J0 {
1529
1529
  * @param options
1530
1530
  */
1531
1531
  async marineForecast(M, z = {}) {
1532
- var b, A, c, o, O, W, Y, n;
1532
+ var b, A, c, W, O, o, Y, n;
1533
1533
  try {
1534
1534
  const X = L();
1535
1535
  let q;
@@ -1554,7 +1554,7 @@ class J0 {
1554
1554
  const T = L();
1555
1555
  this.debug && K.info("[%s] fetch marine api (%j) cost: %d ms", z.requestId, M.url, T.diff(X, "ms"));
1556
1556
  const i = await this.mergeMarineData(q), S = i.find((f) => f.model === "ncep_gfswave016"), t = i.find((f) => f.model === "ncep_gfswave025"), U = i.find((f) => f.model === "meteofrance_wave"), V = i.find((f) => f.model === "best_match");
1557
- return (A = (b = V == null ? void 0 : V.hourly) == null ? void 0 : b.wave_height) != null && A.every((f) => f !== null) ? [V] : (o = (c = U == null ? void 0 : U.hourly) == null ? void 0 : c.wave_height) != null && o.every((f) => f !== null) ? [U] : (W = (O = S == null ? void 0 : S.hourly) == null ? void 0 : O.wave_height) != null && W.every((f) => f !== null) ? [S] : (n = (Y = t == null ? void 0 : t.hourly) == null ? void 0 : Y.wave_height) != null && n.every((f) => f !== null) ? [t] : i != null && i.length ? [i[0]] : [];
1557
+ return (A = (b = V == null ? void 0 : V.hourly) == null ? void 0 : b.wave_height) != null && A.every((f) => f !== null) ? [V] : (W = (c = U == null ? void 0 : U.hourly) == null ? void 0 : c.wave_height) != null && W.every((f) => f !== null) ? [U] : (o = (O = S == null ? void 0 : S.hourly) == null ? void 0 : O.wave_height) != null && o.every((f) => f !== null) ? [S] : (n = (Y = t == null ? void 0 : t.hourly) == null ? void 0 : Y.wave_height) != null && n.every((f) => f !== null) ? [t] : i != null && i.length ? [i[0]] : [];
1558
1558
  } catch (X) {
1559
1559
  return K.warn("[%s] marine forecast failed: %s, with %j", z.requestId, X, M), [];
1560
1560
  }
@@ -1567,11 +1567,11 @@ class J0 {
1567
1567
  * @private
1568
1568
  */
1569
1569
  async parseWeatherData(M, z, b = {}) {
1570
- var o, O, W, Y, n, X, q, T, i, S;
1570
+ var W, O, o, Y, n, X, q, T, i, S;
1571
1571
  const A = [], c = Math.pow(10, b.precision || 6);
1572
1572
  for (let t = 0; t < M.length; t++) {
1573
1573
  const U = M[t], V = U.utcOffsetSeconds(), f = U.timezone(), G = U.current(), E = U.hourly(), C = U.sixHourly(), H = U.daily(), h = {};
1574
- if (h.timezone = f || void 0, h.offset = this.prettyTimezoneOffset(V), h.model = z.models instanceof Array ? (o = z.models) == null ? void 0 : o[t] : z.models || "best_match", G) {
1574
+ if (h.timezone = f || void 0, h.offset = this.prettyTimezoneOffset(V), h.model = z.models instanceof Array ? (W = z.models) == null ? void 0 : W[t] : z.models || "best_match", G) {
1575
1575
  const g = L();
1576
1576
  h.current = {
1577
1577
  time: L.unix(Number(G.time())).utc().format()
@@ -1592,7 +1592,7 @@ class J0 {
1592
1592
  )
1593
1593
  };
1594
1594
  for (let Z = 0; Z < E.variablesLength(); Z++) {
1595
- const k = (Y = (W = (O = E.variables(Z).valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : W.split(",")) == null ? void 0 : Y.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
1595
+ const k = (Y = (o = (O = E.variables(Z).valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : o.split(",")) == null ? void 0 : Y.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
1596
1596
  h.hourly[z.hourly[Z]] = k;
1597
1597
  }
1598
1598
  const m = L();
@@ -1638,38 +1638,38 @@ class J0 {
1638
1638
  for (const c in z[b][A])
1639
1639
  if (M[b][A][c] instanceof Array)
1640
1640
  if (c === "time" && A === "hourly") {
1641
- const o = M[b][A][c].at(-1);
1642
- z[b][A][c] = z[b][A][c].map((O) => O + o + 1), M[b][A][c].push(...z[b][A][c]);
1641
+ const W = M[b][A][c].at(-1);
1642
+ z[b][A][c] = z[b][A][c].map((O) => O + W + 1), M[b][A][c].push(...z[b][A][c]);
1643
1643
  } else
1644
1644
  M[b][A][c].push(...z[b][A][c]);
1645
1645
  }
1646
1646
  return M;
1647
1647
  }
1648
1648
  async mergeMarineData(M) {
1649
- var c, o, O, W;
1649
+ var c, W, O, o;
1650
1650
  const z = [], b = M.find((Y) => Y.model === "best_match");
1651
1651
  b && z.push(b);
1652
1652
  const A = M.find((Y) => Y.model === "meteofrance_currents");
1653
1653
  for (const Y of M)
1654
- ["best_match", "meteofrance_currents"].includes(Y.model) || (Y.hourly.ocean_current_velocity = (c = A == null ? void 0 : A.hourly) == null ? void 0 : c.ocean_current_velocity, Y.hourly.ocean_current_direction = (o = A == null ? void 0 : A.hourly) == null ? void 0 : o.ocean_current_direction, Y.hourly.sea_level_height_msl = (O = A == null ? void 0 : A.hourly) == null ? void 0 : O.sea_level_height_msl, Y.hourly.sea_surface_temperature = (W = A == null ? void 0 : A.hourly) == null ? void 0 : W.sea_surface_temperature, z.push(Y));
1654
+ ["best_match", "meteofrance_currents"].includes(Y.model) || (Y.hourly.ocean_current_velocity = (c = A == null ? void 0 : A.hourly) == null ? void 0 : c.ocean_current_velocity, Y.hourly.ocean_current_direction = (W = A == null ? void 0 : A.hourly) == null ? void 0 : W.ocean_current_direction, Y.hourly.sea_level_height_msl = (O = A == null ? void 0 : A.hourly) == null ? void 0 : O.sea_level_height_msl, Y.hourly.sea_surface_temperature = (o = A == null ? void 0 : A.hourly) == null ? void 0 : o.sea_surface_temperature, z.push(Y));
1655
1655
  return z;
1656
1656
  }
1657
1657
  pickForecastUrl(M, z, b, A = {}) {
1658
1658
  return M ? b && !A.noFake ? A.selfHistory ? this.FORECAST.ORM_HISTORY_MARINE_URL : this.FORECAST.OM_MARINE_URL : z ? A.marineUrl || this.FORECAST.ORM_MARINE_URL : this.FORECAST.OM_MARINE_URL : b && !A.noFake ? A.selfHistory ? this.FORECAST.ORM_HISTORY_URL : this.FORECAST.OM_HISTORY_URL : z ? A.weatherUrl || this.FORECAST.ORM_URL : this.FORECAST.OM_URL;
1659
1659
  }
1660
1660
  pickMarineModels(M) {
1661
- var o;
1662
- const z = (o = M == null ? void 0 : M.trim()) == null ? void 0 : o.split(",");
1661
+ var W;
1662
+ const z = (W = M == null ? void 0 : M.trim()) == null ? void 0 : W.split(",");
1663
1663
  if (!(z != null && z.length))
1664
1664
  return ["best_match"];
1665
1665
  const b = [];
1666
1666
  for (let O = 0; O < z.length; O++) {
1667
- const W = z[O];
1668
- ["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(W) ? b.push("meteofrance_currents", W) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(W) ? b.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : b.push("best_match");
1667
+ const o = z[O];
1668
+ ["ecmwf_wam025", "meteofrance_wave", "ewam", "gwam", "era5_ocean"].includes(o) ? b.push("meteofrance_currents", o) : ["gfswave", "ncep_gfswave025", "ncep_gfswave016"].includes(o) ? b.push("meteofrance_currents", "ncep_gfswave025", "ncep_gfswave016") : b.push("best_match");
1669
1669
  }
1670
- const A = b.reduce((O, W) => (O.includes(W) || O.push(W), O), []), c = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
1671
- return A.sort((O, W) => {
1672
- const Y = c.indexOf(O), n = c.indexOf(W);
1670
+ const A = b.reduce((O, o) => (O.includes(o) || O.push(o), O), []), c = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
1671
+ return A.sort((O, o) => {
1672
+ const Y = c.indexOf(O), n = c.indexOf(o);
1673
1673
  return Y - n;
1674
1674
  }), A;
1675
1675
  }
@@ -1682,21 +1682,21 @@ class J0 {
1682
1682
  * @private
1683
1683
  */
1684
1684
  prepare(M, z, b, A = {}) {
1685
- var W;
1686
- const c = L().utc(), o = M ? L.utc(M) : void 0, O = c.clone().utc().add(z && ((W = b.models) != null && W.includes("meteofrance_wave")) ? 10 : 15, "day");
1685
+ var o;
1686
+ const c = L().utc(), W = M ? L.utc(M) : void 0, O = c.clone().utc().add(z && ((o = b.models) != null && o.includes("meteofrance_wave")) ? 10 : 15, "day");
1687
1687
  if (M) {
1688
- const Y = o.clone().utc().add(A.forecastDays ?? 1, "day");
1689
- Y.isAfter(O) ? (Y.subtract(1, "year"), o.isAfter(O) ? (o.subtract(1, "year"), b.start_dates = [
1690
- o.clone().subtract(A.pastDays || 0, "day").utc().format("YYYY-MM-DD")
1688
+ const Y = W.clone().utc().add(A.forecastDays ?? 1, "day");
1689
+ Y.isAfter(O) ? (Y.subtract(1, "year"), W.isAfter(O) ? (W.subtract(1, "year"), b.start_dates = [
1690
+ W.clone().subtract(A.pastDays || 0, "day").utc().format("YYYY-MM-DD")
1691
1691
  ], b.end_dates = [Y.utc().format("YYYY-MM-DD")], b.fakes = [!0], b.url = [this.pickForecastUrl(z, A.selfHosted ?? !0, !0, A)]) : (b.start_dates = [
1692
- o.clone().subtract(A.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
1692
+ W.clone().subtract(A.pastDays || 0, "day").utc().format("YYYY-MM-DD"),
1693
1693
  O.clone().subtract(1, "year").utc().format("YYYY-MM-DD")
1694
1694
  ], b.end_dates = [O.clone().subtract(1, "day").utc().format("YYYY-MM-DD"), Y.utc().format("YYYY-MM-DD")], b.fakes = [!1, !0], b.url = [
1695
1695
  this.pickForecastUrl(z, A.selfHosted ?? !0, !1, A),
1696
1696
  this.pickForecastUrl(z, A.selfHosted ?? !0, !0, A)
1697
1697
  ])) : (b.start_dates = [
1698
- o.clone().subtract(A.pastDays || 0, "day").utc().format("YYYY-MM-DD")
1699
- ], b.end_dates = [Y.utc().format("YYYY-MM-DD")], b.fakes = [!1], b.url = [this.pickForecastUrl(z, A.selfHosted ?? !0, o.isBefore(c.clone().subtract(30, "day")), A)]);
1698
+ W.clone().subtract(A.pastDays || 0, "day").utc().format("YYYY-MM-DD")
1699
+ ], b.end_dates = [Y.utc().format("YYYY-MM-DD")], b.fakes = [!1], b.url = [this.pickForecastUrl(z, A.selfHosted ?? !0, W.isBefore(c.clone().subtract(30, "day")), A)]);
1700
1700
  } else
1701
1701
  b.forecast_days = A.forecastDays, b.past_days = A.pastDays, b.fake = !1, b.url = this.pickForecastUrl(z, A.selfHosted ?? !0, !1, A);
1702
1702
  return b;
@@ -1746,15 +1746,15 @@ class J0 {
1746
1746
  * @param withHourly
1747
1747
  * @param options
1748
1748
  */
1749
- async spotForecast(M, z, b, A = !0, c = !0, o = !1, O = {
1749
+ async spotForecast(M, z, b, A = !0, c = !0, W = !1, O = {
1750
1750
  forecastDays: 1,
1751
1751
  pastDays: 0,
1752
1752
  precision: 6,
1753
1753
  selfHosted: !0
1754
1754
  }) {
1755
1755
  var T, i, S, t, U, V;
1756
- z = this.toStdLng(z), this.debug && K.info("[%s] spot forecast params: %j", O.requestId, { lat: M, lng: z, datetime: b, simplify: A, withDaily: c, withHourly: o, options: O });
1757
- const W = {
1756
+ z = this.toStdLng(z), this.debug && K.info("[%s] spot forecast params: %j", O.requestId, { lat: M, lng: z, datetime: b, simplify: A, withDaily: c, withHourly: W, options: O });
1757
+ const o = {
1758
1758
  apikey: this.apikey,
1759
1759
  latitude: M,
1760
1760
  longitude: z,
@@ -1768,8 +1768,8 @@ class J0 {
1768
1768
  const f = this.timezoneOffset(M, z);
1769
1769
  Y = L.utc(b).utcOffset(f), Y.subtract(f > 0 ? f : -f, "h"), O.selfHistory = !(Y != null && Y.isBefore(L.utc().subtract(120, "days")));
1770
1770
  }
1771
- c && (W.daily = ((i = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : i.split(",")) || []), Y || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, o = !0), o && (W.hourly = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : S.split(",")) || []), O.pastDays = O.pastDays || 0, O.pastDays = O.pastDays > 7 ? 7 : O.pastDays < 0 ? 0 : O.pastDays, O.forecastDays = O.forecastDays ?? 1, O.forecastDays = O.forecastDays > 14 ? 14 : O.forecastDays < 0 ? 1 : O.forecastDays, this.prepare(Y == null ? void 0 : Y.utc().format(), !1, W, O);
1772
- const n = await this.weatherForecast(W, O), X = {
1771
+ c && (o.daily = ((i = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : i.split(",")) || []), Y || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, W = !0), W && (o.hourly = ((S = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : S.split(",")) || []), O.pastDays = O.pastDays || 0, O.pastDays = O.pastDays > 7 ? 7 : O.pastDays < 0 ? 0 : O.pastDays, O.forecastDays = O.forecastDays ?? 1, O.forecastDays = O.forecastDays > 14 ? 14 : O.forecastDays < 0 ? 1 : O.forecastDays, this.prepare(Y == null ? void 0 : Y.utc().format(), !1, o, O);
1772
+ const n = await this.weatherForecast(o, O), X = {
1773
1773
  apikey: this.apikey,
1774
1774
  latitude: M,
1775
1775
  longitude: z,
@@ -1778,7 +1778,7 @@ class J0 {
1778
1778
  wind_speed_unit: "kn",
1779
1779
  models: this.pickMarineModels(O.marineModels)
1780
1780
  };
1781
- c && (X.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), Y || (O.forecastDays = O.forecastDays || 1, o = !0), o && (X.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), this.prepare(Y == null ? void 0 : Y.utc().format(), !0, X, O);
1781
+ c && (X.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), Y || (O.forecastDays = O.forecastDays || 1, W = !0), W && (X.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), this.prepare(Y == null ? void 0 : Y.utc().format(), !0, X, O);
1782
1782
  let q = await this.marineForecast(X, O);
1783
1783
  return (V = (U = (t = q[0]) == null ? void 0 : t.hourly) == null ? void 0 : U.wave_height) != null && V.every((f) => f === null) && (X.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), q = await this.marineForecast(X, O)), { weather: n, marine: q };
1784
1784
  }
@@ -1803,11 +1803,11 @@ class J0 {
1803
1803
  * @param withMarine
1804
1804
  * @param options
1805
1805
  */
1806
- async spotHistorical(M, z, b, A, c = !0, o = !0, O = !1, W = {
1806
+ async spotHistorical(M, z, b, A, c = !0, W = !0, O = !1, o = {
1807
1807
  precision: 6
1808
1808
  }) {
1809
1809
  var S, t;
1810
- z = this.toStdLng(z), this.debug && K.info("[%s] spot historical params: %j", W.requestId, { lat: M, lng: z, startDate: b, endDate: A, withMarine: O, options: W });
1810
+ z = this.toStdLng(z), this.debug && K.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: z, startDate: b, endDate: A, withMarine: O, options: o });
1811
1811
  const Y = this.timezoneOffset(M, z), n = L.utc(b).utcOffset(Y), X = L.utc(A).utcOffset(Y);
1812
1812
  n.subtract(Y > 0 ? Y : -Y, "h"), X.subtract(Y > 0 ? Y : -Y, "h");
1813
1813
  const q = {
@@ -1816,14 +1816,14 @@ class J0 {
1816
1816
  longitude: z,
1817
1817
  cell_selection: "sea",
1818
1818
  wind_speed_unit: "kn",
1819
- models: ((S = W.weatherModels) == null ? void 0 : S.split(",")) || ["best_match"],
1819
+ models: ((S = o.weatherModels) == null ? void 0 : S.split(",")) || ["best_match"],
1820
1820
  timezone: "auto",
1821
1821
  url: this.HISTORICAL.OM_URL,
1822
1822
  start_date: n.format("YYYY-MM-DD"),
1823
1823
  end_date: X.format("YYYY-MM-DD")
1824
1824
  };
1825
- c && (q.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), o && (q.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
1826
- const T = await this.weatherForecast(q, W);
1825
+ c && (q.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), W && (q.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
1826
+ const T = await this.weatherForecast(q, o);
1827
1827
  let i;
1828
1828
  if (O) {
1829
1829
  const U = {
@@ -1833,14 +1833,14 @@ class J0 {
1833
1833
  cell_selection: "sea",
1834
1834
  timezone: "auto",
1835
1835
  wind_speed_unit: "kn",
1836
- models: ((t = W.marineModels) == null ? void 0 : t.split(",")) || ["best_match"],
1836
+ models: ((t = o.marineModels) == null ? void 0 : t.split(",")) || ["best_match"],
1837
1837
  daily: this.FORECAST.MARINE_VARIABLES.DAILY.split(","),
1838
1838
  hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
1839
1839
  url: this.FORECAST.OM_MARINE_URL,
1840
1840
  start_date: n.format("YYYY-MM-DD"),
1841
1841
  end_date: X.format("YYYY-MM-DD")
1842
1842
  };
1843
- i = await this.marineForecast(U, W);
1843
+ i = await this.marineForecast(U, o);
1844
1844
  }
1845
1845
  return { weather: T, marine: i };
1846
1846
  }
@@ -1855,12 +1855,12 @@ class J0 {
1855
1855
  * @param endDate
1856
1856
  * @param options
1857
1857
  */
1858
- async spotSeasonal(M, z, b, A, c = !1, o = {
1858
+ async spotSeasonal(M, z, b, A, c = !1, W = {
1859
1859
  precision: 6
1860
1860
  }) {
1861
- z = this.toStdLng(z), this.debug && K.info("[%s] spot seasonal params: %j", o.requestId, { lat: M, lng: z, startDate: b, endDate: A, options: o });
1862
- const O = this.timezoneOffset(M, z), W = L.utc(b).utcOffset(O), Y = A ? L.utc(A).utcOffset(O) : W.clone().add(1, "month");
1863
- W.subtract(O > 0 ? O : -O, "h"), Y.subtract(O > 0 ? O : -O, "h");
1861
+ z = this.toStdLng(z), this.debug && K.info("[%s] spot seasonal params: %j", W.requestId, { lat: M, lng: z, startDate: b, endDate: A, options: W });
1862
+ const O = this.timezoneOffset(M, z), o = L.utc(b).utcOffset(O), Y = A ? L.utc(A).utcOffset(O) : o.clone().add(1, "month");
1863
+ o.subtract(O > 0 ? O : -O, "h"), Y.subtract(O > 0 ? O : -O, "h");
1864
1864
  const n = {
1865
1865
  apikey: this.apikey,
1866
1866
  latitude: M,
@@ -1869,11 +1869,11 @@ class J0 {
1869
1869
  wind_speed_unit: "kn",
1870
1870
  timezone: "auto",
1871
1871
  url: this.SEASONAL.OM_URL,
1872
- start_date: W.format("YYYY-MM-DD"),
1872
+ start_date: o.format("YYYY-MM-DD"),
1873
1873
  end_date: Y.format("YYYY-MM-DD"),
1874
1874
  daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
1875
1875
  };
1876
- return c && (n.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), o.memberLength = 4, { weather: await this.weatherForecast(n, o) };
1876
+ return c && (n.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), W.memberLength = 4, { weather: await this.weatherForecast(n, W) };
1877
1877
  }
1878
1878
  /**
1879
1879
  * 气候态数据
@@ -1900,8 +1900,8 @@ class J0 {
1900
1900
  }) {
1901
1901
  var X;
1902
1902
  z = this.toStdLng(z), this.debug && K.info("[%s] spot climate params: %j", c.requestId, { lat: M, lng: z, startDate: b, endDate: A, options: c });
1903
- const o = this.timezoneOffset(M, z), O = L.utc(b).utcOffset(o), W = A ? L.utc(A).utcOffset(o) : O.clone().add(1, "day");
1904
- W.subtract(o > 0 ? o : -o, "h"), O.subtract(o > 0 ? o : -o, "h");
1903
+ const W = this.timezoneOffset(M, z), O = L.utc(b).utcOffset(W), o = A ? L.utc(A).utcOffset(W) : O.clone().add(1, "day");
1904
+ o.subtract(W > 0 ? W : -W, "h"), O.subtract(W > 0 ? W : -W, "h");
1905
1905
  const Y = {
1906
1906
  apikey: this.apikey,
1907
1907
  latitude: M,
@@ -1912,7 +1912,7 @@ class J0 {
1912
1912
  timezone: "auto",
1913
1913
  url: this.CLIMATE.OM_URL,
1914
1914
  start_date: O.format("YYYY-MM-DD"),
1915
- end_date: W.format("YYYY-MM-DD"),
1915
+ end_date: o.format("YYYY-MM-DD"),
1916
1916
  daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
1917
1917
  };
1918
1918
  return { weather: await this.weatherForecast(Y, c) };
@@ -1927,9 +1927,9 @@ class J0 {
1927
1927
  }
1928
1928
  })).json();
1929
1929
  if (O.code === 0) {
1930
- const W = O.data, Y = M0.standardWeatherModels();
1930
+ const o = O.data, Y = M0.standardWeatherModels();
1931
1931
  for (const n of Y) {
1932
- const X = M0.autoPickSubCategories(n.alias), T = W.filter((i) => X.includes(i.category)).map((i) => {
1932
+ const X = M0.autoPickSubCategories(n.alias), T = o.filter((i) => X.includes(i.category)).map((i) => {
1933
1933
  var S, t, U, V, f, G;
1934
1934
  return {
1935
1935
  category: i.category,
@@ -1995,10 +1995,10 @@ class k0 {
1995
1995
  * @param datum
1996
1996
  * @param options
1997
1997
  */
1998
- async tidesForecast(M, z, b = 7, A = "today", c = !0, o = !1, O = !1, W = "CD", Y = {}) {
1999
- A = A || "today", b = b || 7, z = this.toStdLng(z), this.debug && R0.info("[%s] spot tides forecast params: %j", Y.requestId, { lat: M, lng: z, date: A, extremes: c, heights: o, datums: O, datum: W });
2000
- let n = `https://www.worldtides.info/api/v3?lat=${M}&lon=${z}&days=${b}&date=${A}&datum=${W}&key=${this.apikey}&localtime`;
2001
- c && (n = `${n}&extremes`), o && (n = `${n}&heights`), O && (n = `${n}&datums`);
1998
+ async tidesForecast(M, z, b = 7, A = "today", c = !0, W = !1, O = !1, o = "CD", Y = {}) {
1999
+ A = A || "today", b = b || 7, z = this.toStdLng(z), this.debug && R0.info("[%s] spot tides forecast params: %j", Y.requestId, { lat: M, lng: z, date: A, extremes: c, heights: W, datums: O, datum: o });
2000
+ let n = `https://www.worldtides.info/api/v3?lat=${M}&lon=${z}&days=${b}&date=${A}&datum=${o}&key=${this.apikey}&localtime`;
2001
+ c && (n = `${n}&extremes`), W && (n = `${n}&heights`), O && (n = `${n}&datums`);
2002
2002
  const q = await (await fetch(n)).json();
2003
2003
  return q.status === 200 ? {
2004
2004
  rqt: {
@@ -2027,14 +2027,14 @@ try {
2027
2027
  class $ {
2028
2028
  static async parseHistory(M) {
2029
2029
  return M == null ? void 0 : M.map((z) => {
2030
- const b = Number(z.pressure / 100), A = Number(z.lat), c = Number(z.lon), o = Number(z.windSpeed * 3600 / 1852);
2030
+ const b = Number(z.pressure / 100), A = Number(z.lat), c = Number(z.lon), W = Number(z.windSpeed * 3600 / 1852);
2031
2031
  return {
2032
2032
  updated: L.utc(z.time).format(),
2033
2033
  lat: isNaN(A) ? null : A,
2034
2034
  lng: isNaN(c) ? null : c,
2035
2035
  pressure: isNaN(b) ? null : Math.round(b) || null,
2036
- kts: isNaN(o) ? null : Math.round(o) || null,
2037
- type: e.parseTropicalType(o),
2036
+ kts: isNaN(W) ? null : Math.round(W) || null,
2037
+ type: e.parseTropicalType(W),
2038
2038
  wind: {
2039
2039
  r7: null,
2040
2040
  r7ne: null,
@@ -2059,9 +2059,9 @@ class $ {
2059
2059
  return M.map((z) => {
2060
2060
  var c;
2061
2061
  const b = L.utc(z.reftime).format(), A = {};
2062
- return (c = z.records) == null || c.forEach((o) => {
2063
- const O = L.utc(o.time), W = O.diff(b, "hour"), Y = Number(o.pressure / 100), n = Number(o.lat), X = Number(o.lon), q = Number(o.windSpeed * 3600 / 1852);
2064
- A[W] = {
2062
+ return (c = z.records) == null || c.forEach((W) => {
2063
+ const O = L.utc(W.time), o = O.diff(b, "hour"), Y = Number(W.pressure / 100), n = Number(W.lat), X = Number(W.lon), q = Number(W.windSpeed * 3600 / 1852);
2064
+ A[o] = {
2065
2065
  lat: isNaN(n) ? null : n,
2066
2066
  lng: isNaN(X) ? null : X,
2067
2067
  pressure: isNaN(Y) ? null : Math.round(Y) || null,
@@ -2093,7 +2093,7 @@ class $ {
2093
2093
  }), {
2094
2094
  date: b,
2095
2095
  //@ts-ignore
2096
- model: c0[((z == null ? void 0 : z.modelIdentifier) || "").toLowerCase()] || "OTHER".toLowerCase(),
2096
+ model: (c0[((z == null ? void 0 : z.modelIdentifier) || "").toUpperCase()] || "OTHER").toLowerCase(),
2097
2097
  hours: A
2098
2098
  };
2099
2099
  });
@@ -2111,7 +2111,7 @@ class $ {
2111
2111
  static async realtimeForecast() {
2112
2112
  const M = "https://node.windy.com/tc/v2/storms", z = await Q.get(M).json(), b = [];
2113
2113
  for (const A of z.storms) {
2114
- const c = `https://node.windy.com/tc/v2/storms/${A.id}`, o = await Q.get(c).json(), O = await $.parseTropical(o);
2114
+ const c = `https://node.windy.com/tc/v2/storms/${A.id}`, W = await Q.get(c).json(), O = await $.parseTropical(W);
2115
2115
  b.push(O);
2116
2116
  }
2117
2117
  return b;
@@ -2119,10 +2119,10 @@ class $ {
2119
2119
  }
2120
2120
  const J = class J {
2121
2121
  static async parseHistory(M) {
2122
- const z = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, b = await Q.post(z).text(), A = await J.parser.parseStringPromise(b), c = A.typhoon.position instanceof Array ? A.typhoon.position : [A.typhoon.position], o = [];
2122
+ const z = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, b = await Q.post(z).text(), A = await J.parser.parseStringPromise(b), c = A.typhoon.position instanceof Array ? A.typhoon.position : [A.typhoon.position], W = [];
2123
2123
  for (const O of c) {
2124
- const W = L(O.updatetime).utcOffset(8).utc().format(), Y = Number(O.lat), n = Number(O.lon), X = Number(O.pressure), q = Number(O.windspeed * 3600 / 1852), T = e.parseWindCircle(O.c7quad1 / 1.852), i = e.parseWindCircle(O.c7quad2 / 1.852), S = e.parseWindCircle(O.c7quad3 / 1.852), t = e.parseWindCircle(O.c7quad4 / 1.852), U = e.parseWindCircle(O.c10quad1 / 1.852), V = e.parseWindCircle(O.c10quad2 / 1.852), f = e.parseWindCircle(O.c10quad3 / 1.852), G = e.parseWindCircle(O.c10quad4 / 1.852), E = e.parseWindCircle(O.c12quad1 / 1.852), C = e.parseWindCircle(O.c12quad2 / 1.852), H = e.parseWindCircle(O.c12quad3 / 1.852), h = e.parseWindCircle(O.c12quad4 / 1.852), { r7: g, r10: D, r12: m } = e.estimateWindRadii(q, X, Y), Z = {
2125
- updated: W,
2124
+ const o = L(O.updatetime).utcOffset(8).utc().format(), Y = Number(O.lat), n = Number(O.lon), X = Number(O.pressure), q = Number(O.windspeed * 3600 / 1852), T = e.parseWindCircle(O.c7quad1 / 1.852), i = e.parseWindCircle(O.c7quad2 / 1.852), S = e.parseWindCircle(O.c7quad3 / 1.852), t = e.parseWindCircle(O.c7quad4 / 1.852), U = e.parseWindCircle(O.c10quad1 / 1.852), V = e.parseWindCircle(O.c10quad2 / 1.852), f = e.parseWindCircle(O.c10quad3 / 1.852), G = e.parseWindCircle(O.c10quad4 / 1.852), E = e.parseWindCircle(O.c12quad1 / 1.852), C = e.parseWindCircle(O.c12quad2 / 1.852), H = e.parseWindCircle(O.c12quad3 / 1.852), h = e.parseWindCircle(O.c12quad4 / 1.852), { r7: g, r10: D, r12: m } = e.estimateWindRadii(q, X, Y), Z = {
2125
+ updated: o,
2126
2126
  lat: isNaN(Y) ? null : Y,
2127
2127
  lng: isNaN(n) ? null : n,
2128
2128
  pressure: isNaN(X) ? null : Math.round(X),
@@ -2146,15 +2146,15 @@ const J = class J {
2146
2146
  r12se: h
2147
2147
  }
2148
2148
  };
2149
- o.push(Z);
2149
+ W.push(Z);
2150
2150
  }
2151
- return o.sort((O, W) => L(W.updated).unix() - L(O.updated).unix()), o;
2151
+ return W.sort((O, o) => L(o.updated).unix() - L(O.updated).unix()), W;
2152
2152
  }
2153
2153
  static async parseForecast(M, z) {
2154
- const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, A = await Q.post(b).text(), c = await J.parser.parseStringPromise(A), o = c.list.forecast instanceof Array ? c.list.forecast : [c.list.forecast], O = [];
2155
- for (const W of o)
2156
- if (W.xuhao === M) {
2157
- const Y = W.positions.forecastposition instanceof Array ? W.positions.forecastposition : [W.positions.forecastposition];
2154
+ const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, A = await Q.post(b).text(), c = await J.parser.parseStringPromise(A), W = c.list.forecast instanceof Array ? c.list.forecast : [c.list.forecast], O = [];
2155
+ for (const o of W)
2156
+ if (o.xuhao === M) {
2157
+ const Y = o.positions.forecastposition instanceof Array ? o.positions.forecastposition : [o.positions.forecastposition];
2158
2158
  if (Y.length) {
2159
2159
  z = z || L(Y.at(0).forecasttime).utcOffset(8).utc();
2160
2160
  const n = {};
@@ -2195,7 +2195,7 @@ const J = class J {
2195
2195
  }
2196
2196
  const X = {
2197
2197
  date: z.utc().format(),
2198
- model: e.parseTropicalModel(W.country).toLowerCase(),
2198
+ model: e.parseTropicalModel(o.country).toLowerCase(),
2199
2199
  hours: n
2200
2200
  };
2201
2201
  O.push(X);
@@ -2204,10 +2204,10 @@ const J = class J {
2204
2204
  return O;
2205
2205
  }
2206
2206
  static async parseTropical(M) {
2207
- var o, O, W;
2208
- const z = await J.parseHistory(M.xuhao), b = (o = z.at(0)) == null ? void 0 : o.updated, A = await J.parseForecast(M.xuhao, b ? L(b) : void 0), c = {
2207
+ var W, O, o;
2208
+ const z = await J.parseHistory(M.xuhao), b = (W = z.at(0)) == null ? void 0 : W.updated, A = await J.parseForecast(M.xuhao, b ? L(b) : void 0), c = {
2209
2209
  id: (O = M.enname) == null ? void 0 : O.toLowerCase(),
2210
- name: (W = M.enname) == null ? void 0 : W.toLowerCase(),
2210
+ name: (o = M.enname) == null ? void 0 : o.toLowerCase(),
2211
2211
  cnName: M.name,
2212
2212
  history: z,
2213
2213
  forecasts: A
@@ -2216,10 +2216,11 @@ const J = class J {
2216
2216
  }
2217
2217
  static async realtimeForecast() {
2218
2218
  const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", z = await Q.post(M).text(), b = await J.parser.parseStringPromise(z), A = [], c = b.typhoon.position instanceof Array ? b.typhoon.position : [b.typhoon.position];
2219
- for (const o of c) {
2220
- const O = await J.parseTropical(o);
2221
- A.push(O);
2222
- }
2219
+ for (const W of c)
2220
+ if (W) {
2221
+ const O = await J.parseTropical(W);
2222
+ A.push(O);
2223
+ }
2223
2224
  return A;
2224
2225
  }
2225
2226
  };
@@ -2228,7 +2229,7 @@ let b0 = J;
2228
2229
  class j {
2229
2230
  static async parseHistory(M) {
2230
2231
  return M.map((z) => {
2231
- const b = Number(z.lat), A = Number(z.lon), c = Number(z.maxSP * 3600 / 1852), o = Number(z.minP), O = e.parseWindCircle(z.r7Ne / 1.852), W = e.parseWindCircle(z.r7Nw / 1.852), Y = e.parseWindCircle(z.r7Se / 1.852), n = e.parseWindCircle(z.r7Sw / 1.852), X = e.parseWindCircle(z.r10Ne / 1.852), q = e.parseWindCircle(z.r10Nw / 1.852), T = e.parseWindCircle(z.r10Se / 1.852), i = e.parseWindCircle(z.r10Sw / 1.852), S = e.parseWindCircle(z.r12Ne / 1.852), t = e.parseWindCircle(z.r12Nw / 1.852), U = e.parseWindCircle(z.r12Se / 1.852), V = e.parseWindCircle(z.r12Sw / 1.852), { r7: f, r10: G, r12: E } = e.estimateWindRadii(c, o, b);
2232
+ const b = Number(z.lat), A = Number(z.lon), c = Number(z.maxSP * 3600 / 1852), W = Number(z.minP), O = e.parseWindCircle(z.r7Ne / 1.852), o = e.parseWindCircle(z.r7Nw / 1.852), Y = e.parseWindCircle(z.r7Se / 1.852), n = e.parseWindCircle(z.r7Sw / 1.852), X = e.parseWindCircle(z.r10Ne / 1.852), q = e.parseWindCircle(z.r10Nw / 1.852), T = e.parseWindCircle(z.r10Se / 1.852), i = e.parseWindCircle(z.r10Sw / 1.852), S = e.parseWindCircle(z.r12Ne / 1.852), t = e.parseWindCircle(z.r12Nw / 1.852), U = e.parseWindCircle(z.r12Se / 1.852), V = e.parseWindCircle(z.r12Sw / 1.852), { r7: f, r10: G, r12: E } = e.estimateWindRadii(c, W, b);
2232
2233
  return {
2233
2234
  updated: L.utc(z.realTime).format(),
2234
2235
  lat: isNaN(b) ? null : b || null,
@@ -2238,7 +2239,7 @@ class j {
2238
2239
  wind: {
2239
2240
  r7: f,
2240
2241
  r7ne: O,
2241
- r7nw: W,
2242
+ r7nw: o,
2242
2243
  r7se: Y,
2243
2244
  r7sw: n,
2244
2245
  r10: G,
@@ -2257,18 +2258,18 @@ class j {
2257
2258
  }
2258
2259
  static async parseForecast(M) {
2259
2260
  return M.map((z) => {
2260
- const b = z.currentPosition, A = z.forecastPoints, c = L.utc(b.realTime).format(), o = {};
2261
+ const b = z.currentPosition, A = z.forecastPoints, c = L.utc(b.realTime).format(), W = {};
2261
2262
  return A.forEach((O) => {
2262
- const W = L.utc(O.forecastTime), Y = W.diff(c, "hour"), n = Math.round(O.maxSP * 3600 / 1852), X = Math.round(O.maxSP * 3600 / 1852), q = O.pressure, T = e.parseWindCircle(O.r7Ne / 1.852), i = e.parseWindCircle(O.r7Nw / 1.852), S = e.parseWindCircle(O.r7Sw / 1.852), t = e.parseWindCircle(O.r7Se / 1.852), U = e.parseWindCircle(O.r10Ne / 1.852), V = e.parseWindCircle(O.r10Nw / 1.852), f = e.parseWindCircle(O.r10Sw / 1.852), G = e.parseWindCircle(O.r10Se / 1.852), E = e.parseWindCircle(O.r12Ne / 1.852), C = e.parseWindCircle(O.r12Nw / 1.852), H = e.parseWindCircle(O.r12Sw / 1.852), h = e.parseWindCircle(O.r12Se / 1.852), { r7: g, r10: D, r12: m } = e.estimateWindRadii(n, q, O.lat);
2263
- o[Y] = {
2263
+ const o = L.utc(O.forecastTime), Y = o.diff(c, "hour"), n = Math.round(O.maxSP * 3600 / 1852), X = Math.round(O.maxSP * 3600 / 1852), q = O.pressure, T = e.parseWindCircle(O.r7Ne / 1.852), i = e.parseWindCircle(O.r7Nw / 1.852), S = e.parseWindCircle(O.r7Sw / 1.852), t = e.parseWindCircle(O.r7Se / 1.852), U = e.parseWindCircle(O.r10Ne / 1.852), V = e.parseWindCircle(O.r10Nw / 1.852), f = e.parseWindCircle(O.r10Sw / 1.852), G = e.parseWindCircle(O.r10Se / 1.852), E = e.parseWindCircle(O.r12Ne / 1.852), C = e.parseWindCircle(O.r12Nw / 1.852), H = e.parseWindCircle(O.r12Sw / 1.852), h = e.parseWindCircle(O.r12Se / 1.852), { r7: g, r10: D, r12: m } = e.estimateWindRadii(n, q, O.lat);
2264
+ W[Y] = {
2264
2265
  lat: O.lat,
2265
2266
  lng: O.lon,
2266
2267
  pressure: O.pressure,
2267
- utc: W.format(),
2268
+ utc: o.format(),
2268
2269
  wind: {
2269
2270
  kts: isNaN(n) ? null : n || null,
2270
2271
  type: e.parseTropicalType(n),
2271
- datetime: W.format(),
2272
+ datetime: o.format(),
2272
2273
  r7: g,
2273
2274
  r7ne: T,
2274
2275
  r7nw: i,
@@ -2292,13 +2293,13 @@ class j {
2292
2293
  }), {
2293
2294
  date: c,
2294
2295
  model: e.parseTropicalModel(z.source).toLowerCase(),
2295
- hours: o
2296
+ hours: W
2296
2297
  };
2297
2298
  });
2298
2299
  }
2299
2300
  static async parseTropical(M) {
2300
- var o;
2301
- const z = M.baseInfo, b = M.currentPosition, A = (o = z == null ? void 0 : z.eName) == null ? void 0 : o.toLowerCase(), c = {
2301
+ var W;
2302
+ const z = M.baseInfo, b = M.currentPosition, A = (W = z == null ? void 0 : z.eName) == null ? void 0 : W.toLowerCase(), c = {
2302
2303
  id: z == null ? void 0 : z.stormID,
2303
2304
  name: A,
2304
2305
  cName: z == null ? void 0 : z.cName,
@@ -2330,19 +2331,19 @@ class e {
2330
2331
  var b;
2331
2332
  const z = Object.values(c0);
2332
2333
  return (b = M.forecasts) == null || b.sort((A, c) => {
2333
- var W, Y;
2334
- const o = z.indexOf((W = A.model) == null ? void 0 : W.toUpperCase()), O = z.indexOf((Y = c.model) == null ? void 0 : Y.toUpperCase());
2335
- return (o === -1 ? 999 : o) - (O === -1 ? 999 : O);
2334
+ var o, Y;
2335
+ const W = z.indexOf((o = A.model) == null ? void 0 : o.toUpperCase()), O = z.indexOf((Y = c.model) == null ? void 0 : Y.toUpperCase());
2336
+ return (W === -1 ? 999 : W) - (O === -1 ? 999 : O);
2336
2337
  }), M;
2337
2338
  }
2338
2339
  static async mergeTropicals(M = !0, z = !1, b = {}) {
2339
- var O, W;
2340
- const A = await $.realtimeForecast(), c = M ? await b0.realtimeForecast() : [], o = z ? await j.realtimeForecast() : [];
2340
+ var O, o;
2341
+ const A = await $.realtimeForecast(), c = M ? await b0.realtimeForecast() : [], W = z ? await j.realtimeForecast() : [];
2341
2342
  for (const Y of A) {
2342
2343
  const n = c.find((q) => {
2343
2344
  var T, i;
2344
2345
  return ((T = q.name) == null ? void 0 : T.toLowerCase()) === ((i = Y.name) == null ? void 0 : i.toLowerCase());
2345
- }), X = o.find((q) => {
2346
+ }), X = W.find((q) => {
2346
2347
  var T, i;
2347
2348
  return ((T = q.name) == null ? void 0 : T.toLowerCase()) === ((i = Y.name) == null ? void 0 : i.toLowerCase());
2348
2349
  });
@@ -2357,7 +2358,7 @@ class e {
2357
2358
  if (n) {
2358
2359
  Y.history.push(...n.history), Y.history.sort((q, T) => L(T.updated).valueOf() - L(q.updated).valueOf());
2359
2360
  for (const q of n.forecasts)
2360
- ["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((W = q.model) == null ? void 0 : W.toUpperCase()) && !Y.forecasts.find((T) => T.model.toLowerCase() === q.model.toLowerCase()) && Y.forecasts.push(q);
2361
+ ["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((o = q.model) == null ? void 0 : o.toUpperCase()) && !Y.forecasts.find((T) => T.model.toLowerCase() === q.model.toLowerCase()) && Y.forecasts.push(q);
2361
2362
  }
2362
2363
  Y.history = Y.history.reduce((q, T) => (q.find((i) => i.updated === T.updated) || q.push(T), q), []), await e.tropicalMovement(Y);
2363
2364
  }
@@ -2371,20 +2372,20 @@ class e {
2371
2372
  await e.sortTropical(M);
2372
2373
  let z = null;
2373
2374
  M.forecasts.forEach((A) => {
2374
- const c = A.hours, o = Object.keys(c);
2375
- for (let O = 0; O < o.length - 1; O++) {
2376
- const W = c[o[O]];
2377
- z = z || W;
2378
- const Y = c[o[O + 1]];
2379
- W.movement = e.calculateMovement(W, Y);
2380
- const n = e.supplementWindRadii(W);
2381
- W.wind = { ...W.wind || {}, ...n };
2375
+ const c = A.hours, W = Object.keys(c);
2376
+ for (let O = 0; O < W.length - 1; O++) {
2377
+ const o = c[W[O]];
2378
+ z = z || o;
2379
+ const Y = c[W[O + 1]];
2380
+ o.movement = e.calculateMovement(o, Y);
2381
+ const n = e.supplementWindRadii(o);
2382
+ o.wind = { ...o.wind || {}, ...n };
2382
2383
  }
2383
2384
  });
2384
2385
  let b = null;
2385
2386
  for (let A = 0; A < M.history.length - 1; A++) {
2386
- const c = M.history[A + 1], o = M.history[A];
2387
- b = b || o, c.movement = e.calculateMovement(c, o);
2387
+ const c = M.history[A + 1], W = M.history[A];
2388
+ b = b || W, c.movement = e.calculateMovement(c, W);
2388
2389
  const O = e.supplementWindRadii(c);
2389
2390
  c.wind = { ...c.wind || {}, ...O };
2390
2391
  }
@@ -2412,8 +2413,8 @@ class e {
2412
2413
  let A;
2413
2414
  const c = Math.abs(b || 25);
2414
2415
  if (z && z > 0) {
2415
- const o = 1013 - z;
2416
- A = 51.6 * Math.exp(-0.0223 * M + 0.0281 * c) * Math.pow(Math.max(o, 10) / 100, 0.155);
2416
+ const W = 1013 - z;
2417
+ A = 51.6 * Math.exp(-0.0223 * M + 0.0281 * c) * Math.pow(Math.max(W, 10) / 100, 0.155);
2417
2418
  } else
2418
2419
  A = 46.4 * Math.exp(-0.0155 * M + 0.0169 * c);
2419
2420
  return Math.max(10 / 1.852, Math.min(150 / 1.852, A));
@@ -2428,10 +2429,10 @@ class e {
2428
2429
  static estimateWindRadii(M, z, b) {
2429
2430
  if (!M || M < 17)
2430
2431
  return { r7: null, r10: null, r12: null };
2431
- const A = e.estimateRMW(M, z, b), c = A * 2.5, o = M >= 50 ? A * 1.8 : null, O = M >= 64 ? A * 1.3 : null;
2432
+ const A = e.estimateRMW(M, z, b), c = A * 2.5, W = M >= 50 ? A * 1.8 : null, O = M >= 64 ? A * 1.3 : null;
2432
2433
  return {
2433
2434
  r7: Math.round(c),
2434
- r10: o ? Math.round(o) : null,
2435
+ r10: W ? Math.round(W) : null,
2435
2436
  r12: O ? Math.round(O) : null
2436
2437
  };
2437
2438
  }
@@ -2448,20 +2449,20 @@ class e {
2448
2449
  return { ne: null, nw: null, se: null, sw: null };
2449
2450
  if (z < 9)
2450
2451
  return { ne: M, nw: M, se: M, sw: M };
2451
- const o = 0.15 * Math.min(z / (20 / 1.852), 1), O = {
2452
+ const W = 0.15 * Math.min(z / (20 / 1.852), 1), O = {
2452
2453
  ne: (45 - b + 360) % 360,
2453
2454
  nw: (315 - b + 360) % 360,
2454
2455
  se: (135 - b + 360) % 360,
2455
2456
  sw: (225 - b + 360) % 360
2456
- }, W = (Y) => {
2457
+ }, o = (Y) => {
2457
2458
  const n = Y > 180 ? Y - 360 : Y, X = Math.cos(n * Math.PI / 180);
2458
- return 1 - o * X;
2459
+ return 1 - W * X;
2459
2460
  };
2460
2461
  return {
2461
- ne: Math.round(M * W(O.ne)),
2462
- nw: Math.round(M * W(O.nw)),
2463
- se: Math.round(M * W(O.se)),
2464
- sw: Math.round(M * W(O.sw))
2462
+ ne: Math.round(M * o(O.ne)),
2463
+ nw: Math.round(M * o(O.nw)),
2464
+ se: Math.round(M * o(O.se)),
2465
+ sw: Math.round(M * o(O.sw))
2465
2466
  };
2466
2467
  }
2467
2468
  /**
@@ -2475,8 +2476,8 @@ class e {
2475
2476
  /^r[7,10,12]/.test(n) && (isNaN(Number(z[n])) || z[n] < 0) && (z[n] = null);
2476
2477
  return z;
2477
2478
  }
2478
- const o = z.kts;
2479
- if (!o || o < 17)
2479
+ const W = z.kts;
2480
+ if (!W || W < 17)
2480
2481
  return {
2481
2482
  r7: null,
2482
2483
  r7ne: null,
@@ -2494,16 +2495,16 @@ class e {
2494
2495
  r12se: null,
2495
2496
  r12sw: null
2496
2497
  };
2497
- const O = e.estimateWindRadii(o, b, A), W = {};
2498
+ const O = e.estimateWindRadii(W, b, A), o = {};
2498
2499
  return ["r7", "r10", "r12"].forEach((n) => {
2499
2500
  const X = O[n];
2500
2501
  if (X) {
2501
- W[n] = X;
2502
+ o[n] = X;
2502
2503
  const q = e.estimateAsymmetricRadii(X, (c == null ? void 0 : c.kts) || 0, (c == null ? void 0 : c.deg) || 0, A > 0 ? "N" : "S");
2503
- W[`${n}ne`] = q.ne, W[`${n}nw`] = q.nw, W[`${n}se`] = q.se, W[`${n}sw`] = q.sw;
2504
+ o[`${n}ne`] = q.ne, o[`${n}nw`] = q.nw, o[`${n}se`] = q.se, o[`${n}sw`] = q.sw;
2504
2505
  } else
2505
- W[n] = null, W[`${n}ne`] = null, W[`${n}nw`] = null, W[`${n}se`] = null, W[`${n}sw`] = null;
2506
- }), W;
2506
+ o[n] = null, o[`${n}ne`] = null, o[`${n}nw`] = null, o[`${n}se`] = null, o[`${n}sw`] = null;
2507
+ }), o;
2507
2508
  }
2508
2509
  /**
2509
2510
  * 台风类型