@idm-plugin/meteo2 0.7.9 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import p0 from "@log4js-node/log4js-api";
5
5
  import L from "moment";
6
6
  import Q from "got";
7
7
  import { fetchWeatherApi as z0 } from "openmeteo";
8
- import { Meteo2Assist as M0 } from "@idm-plugin/meteo";
8
+ import { Meteo2Assist as $ } from "@idm-plugin/meteo";
9
9
  import u0 from "xml2js";
10
10
  import { LaneHelper as d0 } from "@idm-plugin/geo2";
11
11
  let s;
@@ -27,24 +27,24 @@ class Q0 {
27
27
  */
28
28
  static async queryPointMeteo(M, z, b, p = !1, c = "", W = {}) {
29
29
  typeof b == "number" && (b = b < 1e12 ? b * 1e3 : b);
30
- const A = L(b), o = {
30
+ const O = L(b), o = {
31
31
  searchParams: {
32
32
  lng: M,
33
33
  lat: z,
34
- ts: A.valueOf(),
34
+ ts: O.valueOf(),
35
35
  params: p ? "watertemp" : void 0,
36
36
  source: c == null ? void 0 : c.toLowerCase()
37
37
  },
38
38
  timeout: 3e4
39
- }, d = L(), Y = d.valueOf();
40
- A.isBefore(d.subtract(1, "month")) && (s == null || s.warn("[%s] get history meteo on %s: %j", W.requestId, A.format(), o));
41
- const X = "https://aod4idm.idmwx.com/api/ocean/point", q = await Q.get(X, o).json(), f = L().valueOf();
42
- if (s == null || s.info("[%s] get meteo(cost: %d ms) from %s with options: %j", W.requestId, f - Y, X, o), (q == null ? void 0 : q.code) === 0)
39
+ }, q = L(), d = q.valueOf();
40
+ O.isBefore(q.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", Y = await Q.get(X, o).json(), f = L().valueOf();
42
+ if (s == null || s.info("[%s] get meteo(cost: %d ms) from %s with options: %j", W.requestId, f - d, X, o), (Y == null ? void 0 : Y.code) === 0)
43
43
  return {
44
- ...q.data,
44
+ ...Y.data,
45
45
  source: c
46
46
  };
47
- s == null || s.warn("[%s] get meteo failed: %j", W.requestId, q);
47
+ s == null || s.warn("[%s] get meteo failed: %j", W.requestId, Y);
48
48
  }
49
49
  /**
50
50
  * 点查海洋气象要素(指定要素组合)
@@ -62,24 +62,24 @@ class Q0 {
62
62
  */
63
63
  static async queryPointFactor(M, z, b, p = "wind,wave,current,watertemp,visibility", c = "", W = {}) {
64
64
  typeof b == "number" && (b = b < 1e12 ? b * 1e3 : b);
65
- const A = L(b), o = {
65
+ const O = L(b), o = {
66
66
  searchParams: {
67
67
  lng: M,
68
68
  lat: z,
69
- ts: A.valueOf(),
69
+ ts: O.valueOf(),
70
70
  params: p,
71
71
  source: c == null ? void 0 : c.toLowerCase()
72
72
  },
73
73
  timeout: 3e4
74
- }, d = L(), Y = d.valueOf();
75
- A.isBefore(d.subtract(1, "month")) && (s == null || s.warn("[%s] get history factors on %s: %j", W.requestId, A.format(), o));
76
- const X = "https://aod4idm.idmwx.com/api/ocean/factor", q = await Q.get(X, o).json(), f = L().valueOf();
77
- if (s == null || s.info("[%s] get factors(cost: %d ms) from %s with options: %j", W.requestId, f - Y, X, o), (q == null ? void 0 : q.code) === 0)
74
+ }, q = L(), d = q.valueOf();
75
+ O.isBefore(q.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", Y = await Q.get(X, o).json(), f = L().valueOf();
77
+ if (s == null || s.info("[%s] get factors(cost: %d ms) from %s with options: %j", W.requestId, f - d, X, o), (Y == null ? void 0 : Y.code) === 0)
78
78
  return {
79
- ...q.data,
79
+ ...Y.data,
80
80
  source: c
81
81
  };
82
- s == null || s.warn("[%s] get factors failed: %j", W.requestId, q);
82
+ s == null || s.warn("[%s] get factors failed: %j", W.requestId, Y);
83
83
  }
84
84
  /**
85
85
  * @see https://api.windy.com/point-forecast/docs
@@ -88,7 +88,7 @@ class Q0 {
88
88
  static async queryWindyPointForecast(M, z, b, p = {}) {
89
89
  const c = "https://api.windy.com/api/point-forecast/v2", W = [];
90
90
  try {
91
- let A = L().valueOf();
91
+ let O = L().valueOf();
92
92
  const o = await Q.post(c, {
93
93
  headers: {
94
94
  "Content-Type": "application/json"
@@ -118,9 +118,9 @@ class Q0 {
118
118
  levels: ["surface"]
119
119
  }
120
120
  }).json();
121
- let d = L().valueOf();
122
- s == null || s.info("[%s] get gfs-factors(cost: %d ms) from %s", p.requestId, d - A, c), A = d;
123
- const Y = await Q.post(c, {
121
+ let q = L().valueOf();
122
+ s == null || s.info("[%s] get gfs-factors(cost: %d ms) from %s", p.requestId, q - O, c), O = q;
123
+ const d = await Q.post(c, {
124
124
  headers: {
125
125
  "Content-Type": "application/json"
126
126
  },
@@ -133,36 +133,36 @@ class Q0 {
133
133
  levels: ["surface"]
134
134
  }
135
135
  }).json();
136
- d = L().valueOf(), s == null || s.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", p.requestId, d - A, c);
137
- for (let q = 0; q < o.ts.length; q++) {
138
- const f = this.populateUVFactor(o["wind_u-surface"][q], o["wind_v-surface"][q], !1, p);
136
+ q = L().valueOf(), s == null || s.info("[%s] get gfs-wave-factors(cost: %d ms) from %s", p.requestId, q - O, c);
137
+ for (let Y = 0; Y < o.ts.length; Y++) {
138
+ const f = this.populateUVFactor(o["wind_u-surface"][Y], o["wind_v-surface"][Y], !1, p);
139
139
  f.scale = this.calculateBeaufortWindForceScale(f.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,
140
+ utc: L(o.ts[Y]).utc().format(),
141
+ temp: o["temp-surface"][Y] ? Math.round((o["temp-surface"][Y] - 273.15) * 100) / 100 : void 0,
142
+ dp_temp: o["dewpoint-surface"][Y] ? Math.round((o["dewpoint-surface"][Y] - 273.15) * 100) / 100 : void 0,
143
143
  precip: {
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
144
+ inter3h: o["past3hprecip-surface"][Y] ? Math.round(o["past3hprecip-surface"][Y] * 1e3 * 1e3) / 1e3 : 0,
145
+ inter3hSnow: o["past3hsnowprecip-surface"][Y] ? Math.round(o["past3hsnowprecip-surface"][Y] * 1e3 * 1e3) / 1e3 : 0,
146
+ inter3hConv: o["past3hconvprecip-surface"][Y] ? Math.round(o["past3hconvprecip-surface"][Y] * 1e3 * 1e3) / 1e3 : 0
147
147
  },
148
148
  wind: f,
149
149
  gusts: {
150
- speed: Math.round((o["gust-surface"][q] || 0) * 100) / 100,
151
- kts: this.convertMs2Kts(o["gust-surface"][q])
150
+ speed: Math.round((o["gust-surface"][Y] || 0) * 100) / 100,
151
+ kts: this.convertMs2Kts(o["gust-surface"][Y])
152
152
  },
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
153
+ lclouds: o["lclouds-surface"][Y] ? Math.round(o["lclouds-surface"][Y] * 100) / 100 : 0,
154
+ mclouds: o["mclouds-surface"][Y] ? Math.round(o["mclouds-surface"][Y] * 100) / 100 : 0,
155
+ hclouds: o["hclouds-surface"][Y] ? Math.round(o["hclouds-surface"][Y] * 100) / 100 : 0,
156
+ rh: o["rh-surface"][Y] ? Math.round(o["rh-surface"][Y] * 100) / 100 : 0,
157
+ gh: o["gh-surface"][Y] ? Math.round(o["gh-surface"][Y] * 100) / 100 : 0,
158
+ pressure: Math.round(o["pressure-surface"][Y] / 100 * 100) / 100
159
159
  });
160
160
  }
161
161
  const X = [];
162
- for (let q = 0; q < Y.ts.length; q++) {
163
- const f = this.calculateDouglasScale(Y["waves_height-surface"][q], Y["waves_direction-surface"][q], Y["waves_period-surface"][q]), e = this.calculateDouglasScale(Y["wwaves_height-surface"][q], Y["wwaves_direction-surface"][q], Y["wwaves_period-surface"][q]), r = this.calculateDouglasScale(Y["swell1_height-surface"][q], Y["swell1_direction-surface"][q], Y["swell1_period-surface"][q]), N = this.calculateDouglasScale(Y["swell2_height-surface"][q], Y["swell2_direction-surface"][q], Y["swell2_period-surface"][q]);
162
+ for (let Y = 0; Y < d.ts.length; Y++) {
163
+ const f = this.calculateDouglasScale(d["waves_height-surface"][Y], d["waves_direction-surface"][Y], d["waves_period-surface"][Y]), e = this.calculateDouglasScale(d["wwaves_height-surface"][Y], d["wwaves_direction-surface"][Y], d["wwaves_period-surface"][Y]), r = this.calculateDouglasScale(d["swell1_height-surface"][Y], d["swell1_direction-surface"][Y], d["swell1_period-surface"][Y]), N = this.calculateDouglasScale(d["swell2_height-surface"][Y], d["swell2_direction-surface"][Y], d["swell2_period-surface"][Y]);
164
164
  X.push({
165
- utc: L(Y.ts[q]).utc().format(),
165
+ utc: L(d.ts[Y]).utc().format(),
166
166
  wave: {
167
167
  sig: f,
168
168
  wd: e,
@@ -171,12 +171,12 @@ class Q0 {
171
171
  }
172
172
  });
173
173
  }
174
- for (const q of W) {
175
- const f = X.find((e) => e.utc === q.utc);
176
- q.wave = f == null ? void 0 : f.wave;
174
+ for (const Y of W) {
175
+ const f = X.find((e) => e.utc === Y.utc);
176
+ Y.wave = f == null ? void 0 : f.wave;
177
177
  }
178
- } catch (A) {
179
- s.warn("[%s] get-gfs-factor failed: %s", p.requestId, A);
178
+ } catch (O) {
179
+ s.warn("[%s] get-gfs-factor failed: %s", p.requestId, O);
180
180
  }
181
181
  return W;
182
182
  }
@@ -188,12 +188,12 @@ class Q0 {
188
188
  * @param options
189
189
  */
190
190
  static populateUVFactor(M, z, b = !1, p = {}) {
191
- const c = Math.round(Math.sqrt(Math.pow(M, 2) + Math.pow(z, 2)) * 1e4) / 1e4, { degree: W, direction: A } = this.calculateUVDirection(M, z, b, p), o = 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, p), o = this.convertMs2Kts(c);
192
192
  return {
193
193
  speed: c,
194
194
  kts: o,
195
195
  degree: W,
196
- direction: A,
196
+ direction: O,
197
197
  eastward: Math.round(M * 1e4) / 1e4,
198
198
  northward: Math.round(z * 1e4) / 1e4
199
199
  };
@@ -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 W = -1, A = 48 * (180 + b) / 360.00000000000006, o = 24 * (90 - z) / 180.00000000000003, d = 0 | A, Y = 0 | o, X = 96 * Y + 2 * d;
274
+ var W = -1, O = 48 * (180 + b) / 360.00000000000006, o = 24 * (90 - z) / 180.00000000000003, q = 0 | O, d = 0 | o, X = 96 * d + 2 * q;
275
275
  for (X = 56 * p.charCodeAt(X) + p.charCodeAt(X + 1) - 1995; X + c.length < 3136; )
276
- X = 56 * p.charCodeAt(X = 8 * (W = W + X + 1) + 4 * (Y = 0 | (o = 2 * (o - Y) % 2)) + 2 * (d = 0 | (A = 2 * (A - d) % 2)) + 2304) + p.charCodeAt(X + 1) - 1995;
276
+ X = 56 * p.charCodeAt(X = 8 * (W = W + X + 1) + 4 * (d = 0 | (o = 2 * (o - d) % 2)) + 2 * (q = 0 | (O = 2 * (O - q) % 2)) + 2304) + p.charCodeAt(X + 1) - 1995;
277
277
  return c[X + c.length - 3136];
278
278
  }
279
279
  i.exports = M;
@@ -291,38 +291,38 @@ var n0 = { exports: {} };
291
291
  i.exports ? i.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 = {}, p = {}, c = {}, W = {}, A = {}, o;
294
+ var z = "0.5.48", b = {}, p = {}, 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
- var d = M.version.split("."), Y = +d[0], X = +d[1];
297
- (Y < 2 || Y === 2 && X < 6) && v("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
298
- function q(O) {
299
- return O > 96 ? O - 87 : O > 64 ? O - 29 : O - 48;
296
+ var q = M.version.split("."), d = +q[0], X = +q[1];
297
+ (d < 2 || d === 2 && X < 6) && v("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
298
+ function Y(A) {
299
+ return A > 96 ? A - 87 : A > 64 ? A - 29 : A - 48;
300
300
  }
301
- function f(O) {
302
- var a = 0, n = O.split("."), R = n[0], t = n[1] || "", U = 1, C, V = 0, I = 1;
303
- for (O.charCodeAt(0) === 45 && (a = 1, I = -1), a; a < R.length; a++)
304
- C = q(R.charCodeAt(a)), V = 60 * V + C;
301
+ function f(A) {
302
+ var a = 0, n = A.split("."), R = n[0], t = n[1] || "", U = 1, G, V = 0, I = 1;
303
+ for (A.charCodeAt(0) === 45 && (a = 1, I = -1), a; a < R.length; a++)
304
+ G = Y(R.charCodeAt(a)), V = 60 * V + G;
305
305
  for (a = 0; a < t.length; a++)
306
- U = U / 60, C = q(t.charCodeAt(a)), V += C * U;
306
+ U = U / 60, G = Y(t.charCodeAt(a)), V += G * U;
307
307
  return V * I;
308
308
  }
309
- function e(O) {
310
- for (var a = 0; a < O.length; a++)
311
- O[a] = f(O[a]);
309
+ function e(A) {
310
+ for (var a = 0; a < A.length; a++)
311
+ A[a] = f(A[a]);
312
312
  }
313
- function r(O, a) {
313
+ function r(A, a) {
314
314
  for (var n = 0; n < a; n++)
315
- O[n] = Math.round((O[n - 1] || 0) + O[n] * 6e4);
316
- O[a - 1] = 1 / 0;
315
+ A[n] = Math.round((A[n - 1] || 0) + A[n] * 6e4);
316
+ A[a - 1] = 1 / 0;
317
317
  }
318
- function N(O, a) {
318
+ function N(A, a) {
319
319
  var n = [], R;
320
320
  for (R = 0; R < a.length; R++)
321
- n[R] = O[a[R]];
321
+ n[R] = A[a[R]];
322
322
  return n;
323
323
  }
324
- function u(O) {
325
- var a = O.split("|"), n = a[2].split(" "), R = a[3].split(""), t = a[4].split(" ");
324
+ function u(A) {
325
+ var a = A.split("|"), n = a[2].split(" "), R = a[3].split(""), t = a[4].split(" ");
326
326
  return e(n), e(R), e(t), r(t, R.length), {
327
327
  name: a[0],
328
328
  abbrs: N(a[1].split(" "), R),
@@ -331,94 +331,94 @@ var n0 = { exports: {} };
331
331
  population: a[5] | 0
332
332
  };
333
333
  }
334
- function B(O) {
335
- O && this._set(u(O));
334
+ function B(A) {
335
+ A && this._set(u(A));
336
336
  }
337
- function S(O, a) {
337
+ function S(A, a) {
338
338
  var n = a.length;
339
- if (O < a[0])
339
+ if (A < a[0])
340
340
  return 0;
341
- if (n > 1 && a[n - 1] === 1 / 0 && O >= a[n - 2])
341
+ if (n > 1 && a[n - 1] === 1 / 0 && A >= a[n - 2])
342
342
  return n - 1;
343
- if (O >= a[n - 1])
343
+ if (A >= a[n - 1])
344
344
  return -1;
345
345
  for (var R, t = 0, U = n - 1; U - t > 1; )
346
- R = Math.floor((t + U) / 2), a[R] <= O ? t = R : U = R;
346
+ R = Math.floor((t + U) / 2), a[R] <= A ? t = R : U = R;
347
347
  return U;
348
348
  }
349
349
  B.prototype = {
350
- _set: function(O) {
351
- this.name = O.name, this.abbrs = O.abbrs, this.untils = O.untils, this.offsets = O.offsets, this.population = O.population;
350
+ _set: function(A) {
351
+ this.name = A.name, this.abbrs = A.abbrs, this.untils = A.untils, this.offsets = A.offsets, this.population = A.population;
352
352
  },
353
- _index: function(O) {
354
- var a = +O, n = this.untils, R;
353
+ _index: function(A) {
354
+ var a = +A, n = this.untils, R;
355
355
  if (R = S(a, n), R >= 0)
356
356
  return R;
357
357
  },
358
358
  countries: function() {
359
- var O = this.name;
359
+ var A = this.name;
360
360
  return Object.keys(c).filter(function(a) {
361
- return c[a].zones.indexOf(O) !== -1;
361
+ return c[a].zones.indexOf(A) !== -1;
362
362
  });
363
363
  },
364
- parse: function(O) {
365
- var a = +O, n = this.offsets, R = this.untils, t = R.length - 1, U, C, V, I;
364
+ parse: function(A) {
365
+ var a = +A, n = this.offsets, R = this.untils, t = R.length - 1, U, G, V, I;
366
366
  for (I = 0; I < t; I++)
367
- if (U = n[I], C = n[I + 1], V = n[I && I - 1], U < C && Z.moveAmbiguousForward ? U = C : U > V && Z.moveInvalidForward && (U = V), a < R[I] - U * 6e4)
367
+ if (U = n[I], G = n[I + 1], V = n[I && I - 1], U < G && l.moveAmbiguousForward ? U = G : U > V && l.moveInvalidForward && (U = V), a < R[I] - U * 6e4)
368
368
  return n[I];
369
369
  return n[t];
370
370
  },
371
- abbr: function(O) {
372
- return this.abbrs[this._index(O)];
371
+ abbr: function(A) {
372
+ return this.abbrs[this._index(A)];
373
373
  },
374
- offset: function(O) {
375
- return v("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(O)];
374
+ offset: function(A) {
375
+ return v("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(A)];
376
376
  },
377
- utcOffset: function(O) {
378
- return this.offsets[this._index(O)];
377
+ utcOffset: function(A) {
378
+ return this.offsets[this._index(A)];
379
379
  }
380
380
  };
381
- function m(O, a) {
382
- this.name = O, this.zones = a;
381
+ function m(A, a) {
382
+ this.name = A, this.zones = a;
383
383
  }
384
- function l(O) {
385
- var a = O.toTimeString(), n = a.match(/\([a-z ]+\)/i);
386
- n && n[0] ? (n = n[0].match(/[A-Z]/g), n = n ? n.join("") : void 0) : (n = a.match(/[A-Z]{3,5}/g), n = n ? n[0] : void 0), n === "GMT" && (n = void 0), this.at = +O, this.abbr = n, this.offset = O.getTimezoneOffset();
384
+ function Z(A) {
385
+ var a = A.toTimeString(), n = a.match(/\([a-z ]+\)/i);
386
+ n && n[0] ? (n = n[0].match(/[A-Z]/g), n = n ? n.join("") : void 0) : (n = a.match(/[A-Z]{3,5}/g), n = n ? n[0] : void 0), n === "GMT" && (n = void 0), this.at = +A, this.abbr = n, this.offset = A.getTimezoneOffset();
387
387
  }
388
- function P(O) {
389
- this.zone = O, this.offsetScore = 0, this.abbrScore = 0;
388
+ function P(A) {
389
+ this.zone = A, this.offsetScore = 0, this.abbrScore = 0;
390
390
  }
391
- P.prototype.scoreOffsetAt = function(O) {
392
- this.offsetScore += Math.abs(this.zone.utcOffset(O.at) - O.offset), this.zone.abbr(O.at).replace(/[^A-Z]/g, "") !== O.abbr && this.abbrScore++;
391
+ P.prototype.scoreOffsetAt = function(A) {
392
+ this.offsetScore += Math.abs(this.zone.utcOffset(A.at) - A.offset), this.zone.abbr(A.at).replace(/[^A-Z]/g, "") !== A.abbr && this.abbrScore++;
393
393
  };
394
- function K(O, a) {
395
- for (var n, R; R = ((a.at - O.at) / 12e4 | 0) * 6e4; )
396
- n = new l(new Date(O.at + R)), n.offset === O.offset ? O = n : a = n;
397
- return O;
394
+ function K(A, a) {
395
+ for (var n, R; R = ((a.at - A.at) / 12e4 | 0) * 6e4; )
396
+ n = new Z(new Date(A.at + R)), n.offset === A.offset ? A = n : a = n;
397
+ return A;
398
398
  }
399
399
  function h() {
400
- var O = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new l(new Date(O, 0, 1)), n = a.offset, R = [a], t, U, C, V;
400
+ var A = (/* @__PURE__ */ new Date()).getFullYear() - 2, a = new Z(new Date(A, 0, 1)), n = a.offset, R = [a], t, U, G, V;
401
401
  for (V = 1; V < 48; V++)
402
- C = new Date(O, V, 1).getTimezoneOffset(), C !== n && (U = new l(new Date(O, V, 1)), t = K(a, U), R.push(t), R.push(new l(new Date(t.at + 6e4))), a = U, n = C);
402
+ G = new Date(A, V, 1).getTimezoneOffset(), G !== n && (U = new Z(new Date(A, V, 1)), t = K(a, U), R.push(t), R.push(new Z(new Date(t.at + 6e4))), a = U, n = G);
403
403
  for (V = 0; V < 4; V++)
404
- R.push(new l(new Date(O + V, 0, 1))), R.push(new l(new Date(O + V, 6, 1)));
404
+ R.push(new Z(new Date(A + V, 0, 1))), R.push(new Z(new Date(A + V, 6, 1)));
405
405
  return R;
406
406
  }
407
- function H(O, a) {
408
- return O.offsetScore !== a.offsetScore ? O.offsetScore - a.offsetScore : O.abbrScore !== a.abbrScore ? O.abbrScore - a.abbrScore : O.zone.population !== a.zone.population ? a.zone.population - O.zone.population : a.zone.name.localeCompare(O.zone.name);
407
+ function H(A, a) {
408
+ return A.offsetScore !== a.offsetScore ? A.offsetScore - a.offsetScore : A.abbrScore !== a.abbrScore ? A.abbrScore - a.abbrScore : A.zone.population !== a.zone.population ? a.zone.population - A.zone.population : a.zone.name.localeCompare(A.zone.name);
409
409
  }
410
- function g(O, a) {
410
+ function g(A, a) {
411
411
  var n, R;
412
412
  for (e(a), n = 0; n < a.length; n++)
413
- R = a[n], A[R] = A[R] || {}, A[R][O] = !0;
413
+ R = a[n], O[R] = O[R] || {}, O[R][A] = !0;
414
414
  }
415
- function G(O) {
416
- var a = O.length, n = {}, R = [], t = {}, U, C, V, I;
415
+ function C(A) {
416
+ var a = A.length, n = {}, R = [], t = {}, U, G, V, I;
417
417
  for (U = 0; U < a; U++)
418
- if (V = O[U].offset, !t.hasOwnProperty(V)) {
419
- I = A[V] || {};
420
- for (C in I)
421
- I.hasOwnProperty(C) && (n[C] = !0);
418
+ if (V = A[U].offset, !t.hasOwnProperty(V)) {
419
+ I = O[V] || {};
420
+ for (G in I)
421
+ I.hasOwnProperty(G) && (n[G] = !0);
422
422
  t[V] = !0;
423
423
  }
424
424
  for (U in n)
@@ -427,69 +427,69 @@ var n0 = { exports: {} };
427
427
  }
428
428
  function E() {
429
429
  try {
430
- var O = Intl.DateTimeFormat().resolvedOptions().timeZone;
431
- if (O && O.length > 3) {
432
- var a = W[_(O)];
430
+ var A = Intl.DateTimeFormat().resolvedOptions().timeZone;
431
+ if (A && A.length > 3) {
432
+ var a = W[_(A)];
433
433
  if (a)
434
434
  return a;
435
- v("Moment Timezone found " + O + " from the Intl api, but did not have that data loaded.");
435
+ v("Moment Timezone found " + A + " from the Intl api, but did not have that data loaded.");
436
436
  }
437
437
  } catch {
438
438
  }
439
- var n = h(), R = n.length, t = G(n), U = [], C, V, I;
439
+ var n = h(), R = n.length, t = C(n), U = [], G, V, I;
440
440
  for (V = 0; V < t.length; V++) {
441
- for (C = new P(y(t[V])), I = 0; I < R; I++)
442
- C.scoreOffsetAt(n[I]);
443
- U.push(C);
441
+ for (G = new P(y(t[V])), I = 0; I < R; I++)
442
+ G.scoreOffsetAt(n[I]);
443
+ U.push(G);
444
444
  }
445
445
  return U.sort(H), U.length > 0 ? U[0].zone.name : void 0;
446
446
  }
447
- function k(O) {
448
- return (!o || O) && (o = E()), o;
447
+ function J(A) {
448
+ return (!o || A) && (o = E()), o;
449
449
  }
450
- function _(O) {
451
- return (O || "").toLowerCase().replace(/\//g, "_");
450
+ function _(A) {
451
+ return (A || "").toLowerCase().replace(/\//g, "_");
452
452
  }
453
- function W0(O) {
453
+ function W0(A) {
454
454
  var a, n, R, t;
455
- for (typeof O == "string" && (O = [O]), a = 0; a < O.length; a++)
456
- R = O[a].split("|"), n = R[0], t = _(n), b[t] = O[a], W[t] = n, g(t, R[2].split(" "));
455
+ for (typeof A == "string" && (A = [A]), a = 0; a < A.length; a++)
456
+ R = A[a].split("|"), n = R[0], t = _(n), b[t] = A[a], W[t] = n, g(t, R[2].split(" "));
457
457
  }
458
- function y(O, a) {
459
- O = _(O);
460
- var n = b[O], R;
461
- return n instanceof B ? n : typeof n == "string" ? (n = new B(n), b[O] = n, n) : p[O] && a !== y && (R = y(p[O], y)) ? (n = b[O] = new B(), n._set(R), n.name = W[O], n) : null;
458
+ function y(A, a) {
459
+ A = _(A);
460
+ var n = b[A], R;
461
+ return n instanceof B ? n : typeof n == "string" ? (n = new B(n), b[A] = n, n) : p[A] && a !== y && (R = y(p[A], y)) ? (n = b[A] = new B(), n._set(R), n.name = W[A], n) : null;
462
462
  }
463
463
  function L0() {
464
- var O, a = [];
465
- for (O in W)
466
- W.hasOwnProperty(O) && (b[O] || b[p[O]]) && W[O] && a.push(W[O]);
464
+ var A, a = [];
465
+ for (A in W)
466
+ W.hasOwnProperty(A) && (b[A] || b[p[A]]) && W[A] && a.push(W[A]);
467
467
  return a.sort();
468
468
  }
469
469
  function e0() {
470
470
  return Object.keys(c);
471
471
  }
472
- function o0(O) {
472
+ function o0(A) {
473
473
  var a, n, R, t;
474
- for (typeof O == "string" && (O = [O]), a = 0; a < O.length; a++)
475
- n = O[a].split("|"), R = _(n[0]), t = _(n[1]), p[R] = t, W[R] = n[0], p[t] = R, W[t] = n[1];
474
+ for (typeof A == "string" && (A = [A]), a = 0; a < A.length; a++)
475
+ n = A[a].split("|"), R = _(n[0]), t = _(n[1]), p[R] = t, W[R] = n[0], p[t] = R, W[t] = n[1];
476
476
  }
477
- function T0(O) {
477
+ function T0(A) {
478
478
  var a, n, R, t;
479
- if (!(!O || !O.length))
480
- for (a = 0; a < O.length; a++)
481
- t = O[a].split("|"), n = t[0].toUpperCase(), R = t[1].split(" "), c[n] = new m(
479
+ if (!(!A || !A.length))
480
+ for (a = 0; a < A.length; a++)
481
+ t = A[a].split("|"), n = t[0].toUpperCase(), R = t[1].split(" "), c[n] = new m(
482
482
  n,
483
483
  R
484
484
  );
485
485
  }
486
- function i0(O) {
487
- return O = O.toUpperCase(), c[O] || null;
486
+ function i0(A) {
487
+ return A = A.toUpperCase(), c[A] || null;
488
488
  }
489
- function r0(O, a) {
490
- if (O = i0(O), !O)
489
+ function r0(A, a) {
490
+ if (A = i0(A), !A)
491
491
  return null;
492
- var n = O.zones.sort();
492
+ var n = A.zones.sort();
493
493
  return a ? n.map(function(R) {
494
494
  var t = y(R);
495
495
  return {
@@ -498,62 +498,62 @@ var n0 = { exports: {} };
498
498
  };
499
499
  }) : n;
500
500
  }
501
- function f0(O) {
502
- W0(O.zones), o0(O.links), T0(O.countries), Z.dataVersion = O.version;
501
+ function f0(A) {
502
+ W0(A.zones), o0(A.links), T0(A.countries), l.dataVersion = A.version;
503
503
  }
504
- function O0(O) {
505
- return O0.didShowError || (O0.didShowError = !0, v("moment.tz.zoneExists('" + O + "') has been deprecated in favor of !moment.tz.zone('" + O + "')")), !!y(O);
504
+ function O0(A) {
505
+ return O0.didShowError || (O0.didShowError = !0, v("moment.tz.zoneExists('" + A + "') has been deprecated in favor of !moment.tz.zone('" + A + "')")), !!y(A);
506
506
  }
507
- function A0(O) {
508
- var a = O._f === "X" || O._f === "x";
509
- return !!(O._a && O._tzm === void 0 && !a);
507
+ function A0(A) {
508
+ var a = A._f === "X" || A._f === "x";
509
+ return !!(A._a && A._tzm === void 0 && !a);
510
510
  }
511
- function v(O) {
512
- typeof console < "u" && typeof console.error == "function" && console.error(O);
511
+ function v(A) {
512
+ typeof console < "u" && typeof console.error == "function" && console.error(A);
513
513
  }
514
- function Z(O) {
514
+ function l(A) {
515
515
  var a = Array.prototype.slice.call(arguments, 0, -1), n = arguments[arguments.length - 1], R = M.utc.apply(null, a), t;
516
- return !M.isMoment(O) && A0(R) && (t = y(n)) && R.add(t.parse(R), "minutes"), R.tz(n), R;
516
+ return !M.isMoment(A) && A0(R) && (t = y(n)) && R.add(t.parse(R), "minutes"), R.tz(n), R;
517
517
  }
518
- Z.version = z, Z.dataVersion = "", Z._zones = b, Z._links = p, Z._names = W, Z._countries = c, Z.add = W0, Z.link = o0, Z.load = f0, Z.zone = y, Z.zoneExists = O0, Z.guess = k, Z.names = L0, Z.Zone = B, Z.unpack = u, Z.unpackBase60 = f, Z.needsOffset = A0, Z.moveInvalidForward = !0, Z.moveAmbiguousForward = !1, Z.countries = e0, Z.zonesForCountry = r0;
518
+ l.version = z, l.dataVersion = "", l._zones = b, l._links = p, l._names = W, l._countries = c, l.add = W0, l.link = o0, l.load = f0, l.zone = y, l.zoneExists = O0, l.guess = J, l.names = L0, l.Zone = B, l.unpack = u, l.unpackBase60 = f, l.needsOffset = A0, l.moveInvalidForward = !0, l.moveAmbiguousForward = !1, l.countries = e0, l.zonesForCountry = r0;
519
519
  var w = M.fn;
520
- M.tz = Z, M.defaultZone = null, M.updateOffset = function(O, a) {
520
+ M.tz = l, M.defaultZone = null, M.updateOffset = function(A, a) {
521
521
  var n = M.defaultZone, R;
522
- if (O._z === void 0 && (n && A0(O) && !O._isUTC && O.isValid() && (O._d = M.utc(O._a)._d, O.utc().add(n.parse(O), "minutes")), O._z = n), O._z)
523
- if (R = O._z.utcOffset(O), Math.abs(R) < 16 && (R = R / 60), O.utcOffset !== void 0) {
524
- var t = O._z;
525
- O.utcOffset(-R, a), O._z = t;
522
+ if (A._z === void 0 && (n && A0(A) && !A._isUTC && A.isValid() && (A._d = M.utc(A._a)._d, A.utc().add(n.parse(A), "minutes")), A._z = n), A._z)
523
+ if (R = A._z.utcOffset(A), Math.abs(R) < 16 && (R = R / 60), A.utcOffset !== void 0) {
524
+ var t = A._z;
525
+ A.utcOffset(-R, a), A._z = t;
526
526
  } else
527
- O.zone(R, a);
528
- }, w.tz = function(O, a) {
529
- if (O) {
530
- if (typeof O != "string")
531
- throw new Error("Time zone name must be a string, got " + O + " [" + typeof O + "]");
532
- return this._z = y(O), this._z ? M.updateOffset(this, a) : v("Moment Timezone has no data for " + O + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
527
+ A.zone(R, a);
528
+ }, w.tz = function(A, a) {
529
+ if (A) {
530
+ if (typeof A != "string")
531
+ throw new Error("Time zone name must be a string, got " + A + " [" + typeof A + "]");
532
+ return this._z = y(A), this._z ? M.updateOffset(this, a) : v("Moment Timezone has no data for " + A + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
533
533
  }
534
534
  if (this._z)
535
535
  return this._z.name;
536
536
  };
537
- function q0(O) {
537
+ function q0(A) {
538
538
  return function() {
539
- return this._z ? this._z.abbr(this) : O.call(this);
539
+ return this._z ? this._z.abbr(this) : A.call(this);
540
540
  };
541
541
  }
542
- function Y0(O) {
542
+ function Y0(A) {
543
543
  return function() {
544
- return this._z = null, O.apply(this, arguments);
544
+ return this._z = null, A.apply(this, arguments);
545
545
  };
546
546
  }
547
- function N0(O) {
547
+ function N0(A) {
548
548
  return function() {
549
- return arguments.length > 0 && (this._z = null), O.apply(this, arguments);
549
+ return arguments.length > 0 && (this._z = null), A.apply(this, arguments);
550
550
  };
551
551
  }
552
- w.zoneName = q0(w.zoneName), w.zoneAbbr = q0(w.zoneAbbr), w.utc = Y0(w.utc), w.local = Y0(w.local), w.utcOffset = N0(w.utcOffset), M.tz.setDefault = function(O) {
553
- return (Y < 2 || Y === 2 && X < 9) && v("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = O ? y(O) : null, M;
552
+ w.zoneName = q0(w.zoneName), w.zoneAbbr = q0(w.zoneAbbr), w.utc = Y0(w.utc), w.local = Y0(w.local), w.utcOffset = N0(w.utcOffset), M.tz.setDefault = function(A) {
553
+ return (d < 2 || d === 2 && X < 9) && v("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = A ? y(A) : null, M;
554
554
  };
555
- var x = M.momentProperties;
556
- return Object.prototype.toString.call(x) === "[object Array]" ? (x.push("_z"), x.push("_a")) : x && (x._z = null), M;
555
+ var M0 = M.momentProperties;
556
+ return Object.prototype.toString.call(M0) === "[object Array]" ? (M0.push("_z"), M0.push("_a")) : M0 && (M0._z = null), M;
557
557
  });
558
558
  })(n0);
559
559
  var Z0 = n0.exports;
@@ -1418,7 +1418,7 @@ try {
1418
1418
  } catch {
1419
1419
  } finally {
1420
1420
  }
1421
- class J0 {
1421
+ class k0 {
1422
1422
  constructor(M, z) {
1423
1423
  F(this, "apikey");
1424
1424
  F(this, "debug");
@@ -1468,13 +1468,13 @@ class J0 {
1468
1468
  this.apikey = M || "smE3JnDLHy3TizVv", this.debug = z;
1469
1469
  }
1470
1470
  async standardWeatherModels() {
1471
- return M0.standardWeatherModels();
1471
+ return $.standardWeatherModels();
1472
1472
  }
1473
1473
  async standardMarineModels() {
1474
- return M0.standardMarineModels();
1474
+ return $.standardMarineModels();
1475
1475
  }
1476
1476
  async autoPickMeteoModel(M = "best_match") {
1477
- return M0.autoPickMeteoModel(M);
1477
+ return $.autoPickMeteoModel(M);
1478
1478
  }
1479
1479
  range(M, z, b) {
1480
1480
  return Array.from({ length: (z - M) / b }, (p, c) => M + c * b);
@@ -1491,15 +1491,15 @@ class J0 {
1491
1491
  if (M.start_dates instanceof Array)
1492
1492
  for (let W = 0; W < M.start_dates.length; W++) {
1493
1493
  M.start_date = M.start_dates[W], M.end_date = M.end_dates[W], M.fake = M.fakes[W];
1494
- const A = M.url[W];
1495
- this.debug && D.debug("[%s] fetch weather via %s with %j", z.requestId, A, {
1494
+ const O = M.url[W];
1495
+ this.debug && D.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
1499
  step: W
1500
1500
  });
1501
- const o = await z0(A, M), d = await this.parseWeatherData(o, M, z);
1502
- p ? await this.mergeSegments(p, d) : p = d;
1501
+ const o = await z0(O, M), q = await this.parseWeatherData(o, M, z);
1502
+ p ? await this.mergeSegments(p, q) : p = q;
1503
1503
  }
1504
1504
  else {
1505
1505
  const W = await z0(M.url, M);
@@ -1529,10 +1529,10 @@ class J0 {
1529
1529
  * @param options
1530
1530
  */
1531
1531
  async marineForecast(M, z = {}) {
1532
- var b, p, c, W, A, o, d, Y;
1532
+ var b, p, c, W, O, o, q, d;
1533
1533
  try {
1534
1534
  const X = L();
1535
- let q;
1535
+ let Y;
1536
1536
  if (M.start_dates instanceof Array)
1537
1537
  for (let S = 0; S < M.start_dates.length; S++) {
1538
1538
  M.start_date = M.start_dates[S], M.end_date = M.end_dates[S], M.fake = M.fakes[S];
@@ -1543,18 +1543,18 @@ class J0 {
1543
1543
  fake: M.fake,
1544
1544
  step: S
1545
1545
  });
1546
- const l = await z0(m, M), P = await this.parseWeatherData(l, M, z);
1547
- q ? await this.mergeSegments(q, P) : q = P;
1546
+ const Z = await z0(m, M), P = await this.parseWeatherData(Z, M, z);
1547
+ Y ? await this.mergeSegments(Y, P) : Y = P;
1548
1548
  }
1549
1549
  else {
1550
1550
  const S = await z0(M.url, M);
1551
- q = await this.parseWeatherData(S, M, z);
1551
+ Y = await this.parseWeatherData(S, M, z);
1552
1552
  }
1553
1553
  delete M.apikey;
1554
1554
  const f = L();
1555
1555
  this.debug && D.info("[%s] fetch marine api (%j) cost: %d ms", z.requestId, M.url, f.diff(X, "ms"));
1556
- const e = await this.mergeMarineData(q), r = e.find((S) => S.model === "ncep_gfswave016"), N = e.find((S) => S.model === "ncep_gfswave025"), u = e.find((S) => S.model === "meteofrance_wave"), B = e.find((S) => S.model === "best_match");
1557
- return (p = (b = B == null ? void 0 : B.hourly) == null ? void 0 : b.wave_height) != null && p.every((S) => S !== null) ? [B] : (W = (c = u == null ? void 0 : u.hourly) == null ? void 0 : c.wave_height) != null && W.every((S) => S !== null) ? [u] : (o = (A = r == null ? void 0 : r.hourly) == null ? void 0 : A.wave_height) != null && o.every((S) => S !== null) ? [r] : (Y = (d = N == null ? void 0 : N.hourly) == null ? void 0 : d.wave_height) != null && Y.every((S) => S !== null) ? [N] : e != null && e.length ? [e[0]] : [];
1556
+ const e = await this.mergeMarineData(Y), r = e.find((S) => S.model === "ncep_gfswave016"), N = e.find((S) => S.model === "ncep_gfswave025"), u = e.find((S) => S.model === "meteofrance_wave"), B = e.find((S) => S.model === "best_match");
1557
+ return (p = (b = B == null ? void 0 : B.hourly) == null ? void 0 : b.wave_height) != null && p.every((S) => S !== null) ? [B] : (W = (c = u == null ? void 0 : u.hourly) == null ? void 0 : c.wave_height) != null && W.every((S) => S !== null) ? [u] : (o = (O = r == null ? void 0 : r.hourly) == null ? void 0 : O.wave_height) != null && o.every((S) => S !== null) ? [r] : (d = (q = N == null ? void 0 : N.hourly) == null ? void 0 : q.wave_height) != null && d.every((S) => S !== null) ? [N] : e != null && e.length ? [e[0]] : [];
1558
1558
  } catch (X) {
1559
1559
  return D.warn("[%s] marine forecast failed: %s, with %j", z.requestId, X, M), [];
1560
1560
  }
@@ -1567,36 +1567,36 @@ class J0 {
1567
1567
  * @private
1568
1568
  */
1569
1569
  async parseWeatherData(M, z, b = {}) {
1570
- var W, A, o, d, Y, X, q, f, e, r;
1570
+ var W, O, o, q, d, X, Y, f, e, r;
1571
1571
  const p = [], c = Math.pow(10, b.precision || 6);
1572
1572
  for (let N = 0; N < M.length; N++) {
1573
- const u = M[N], B = u.utcOffsetSeconds(), S = u.timezone(), m = u.current(), l = u.hourly(), P = u.sixHourly(), K = u.daily(), h = {};
1573
+ const u = M[N], B = u.utcOffsetSeconds(), S = u.timezone(), m = u.current(), Z = u.hourly(), P = u.sixHourly(), K = u.daily(), h = {};
1574
1574
  if (h.timezone = S || void 0, h.offset = this.prettyTimezoneOffset(B), h.model = z.models instanceof Array ? (W = z.models) == null ? void 0 : W[N] : z.models || "best_match", m) {
1575
1575
  const H = L();
1576
1576
  h.current = {
1577
1577
  time: L.unix(Number(m.time())).utc().format()
1578
1578
  };
1579
- for (let G = 0; G < m.variablesLength(); G++) {
1580
- const E = m.variables(G).value();
1581
- h.current[z.current[G]] = isNaN(E) ? null : Math.round(E * c) / c;
1579
+ for (let C = 0; C < m.variablesLength(); C++) {
1580
+ const E = m.variables(C).value();
1581
+ h.current[z.current[C]] = isNaN(E) ? null : Math.round(E * c) / c;
1582
1582
  }
1583
1583
  const g = L();
1584
1584
  this.debug && D.debug("[%s] fetch current variables cost: %d ms", b.requestId, g.diff(H, "ms"));
1585
1585
  }
1586
- if (l) {
1587
- const H = L(), g = L.unix(Number(l.time())).add(z.fake ? 1 : 0, "year");
1586
+ if (Z) {
1587
+ const H = L(), g = L.unix(Number(Z.time())).add(z.fake ? 1 : 0, "year");
1588
1588
  h.hourly = {
1589
1589
  date: g.utc().format(),
1590
- time: this.range(Number(l.time()), Number(l.timeEnd()), l.interval()).map(
1590
+ time: this.range(Number(Z.time()), Number(Z.timeEnd()), Z.interval()).map(
1591
1591
  (E) => L.unix(E).add(z.fake ? 1 : 0, "year").diff(g, "h")
1592
1592
  )
1593
1593
  };
1594
- for (let E = 0; E < l.variablesLength(); E++) {
1595
- const k = (d = (o = (A = l.variables(E).valuesArray()) == null ? void 0 : A.toString()) == null ? void 0 : o.split(",")) == null ? void 0 : d.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
1596
- h.hourly[z.hourly[E]] = k;
1594
+ for (let E = 0; E < Z.variablesLength(); E++) {
1595
+ const J = (q = (o = (O = Z.variables(E).valuesArray()) == null ? void 0 : O.toString()) == null ? void 0 : o.split(",")) == null ? void 0 : q.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
1596
+ h.hourly[z.hourly[E]] = J;
1597
1597
  }
1598
- const G = L();
1599
- this.debug && D.debug("[%s] fetch hourly variables cost: %d ms", b.requestId, G.diff(H, "ms"));
1598
+ const C = L();
1599
+ this.debug && D.debug("[%s] fetch hourly variables cost: %d ms", b.requestId, C.diff(H, "ms"));
1600
1600
  }
1601
1601
  if (P) {
1602
1602
  const H = L(), g = L.unix(Number(P.time())).add(z.fake ? 1 : 0, "year");
@@ -1607,22 +1607,22 @@ class J0 {
1607
1607
  )
1608
1608
  };
1609
1609
  for (let E = 0; E < P.variablesLength(); E += b.memberLength ?? 1) {
1610
- const k = (q = (X = (Y = P.variables(E).valuesArray()) == null ? void 0 : Y.toString()) == null ? void 0 : X.split(",")) == null ? void 0 : q.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
1611
- P.variables(E), h.sixHourly[z.six_hourly[E / (b.memberLength ?? 1)]] = k;
1610
+ const J = (Y = (X = (d = P.variables(E).valuesArray()) == null ? void 0 : d.toString()) == null ? void 0 : X.split(",")) == null ? void 0 : Y.map((_) => isNaN(_) ? null : Math.round(Number(_) * c) / c);
1611
+ P.variables(E), h.sixHourly[z.six_hourly[E / (b.memberLength ?? 1)]] = J;
1612
1612
  }
1613
- const G = L();
1614
- this.debug && D.debug("[%s] fetch 6-hourly variables cost: %d ms", b.requestId, G.diff(H, "ms"));
1613
+ const C = L();
1614
+ this.debug && D.debug("[%s] fetch 6-hourly variables cost: %d ms", b.requestId, C.diff(H, "ms"));
1615
1615
  }
1616
1616
  if (K) {
1617
1617
  const H = L();
1618
1618
  h.daily = {
1619
1619
  time: this.range(Number(K.time()), Number(K.timeEnd()), K.interval()).map(
1620
- (G) => L.unix(G).add(z.fake ? 1 : 0, "year").utc().format()
1620
+ (C) => L.unix(C).add(z.fake ? 1 : 0, "year").utc().format()
1621
1621
  )
1622
1622
  };
1623
- for (let G = 0; G < K.variablesLength(); G += b.memberLength ?? 1) {
1624
- const E = (r = (e = (f = K.variables(G).valuesArray()) == null ? void 0 : f.toString()) == null ? void 0 : e.split(",")) == null ? void 0 : r.map((k) => isNaN(k) ? null : Math.round(Number(k) * c) / c);
1625
- h.daily[z.daily[G / (b.memberLength ?? 1)]] = E;
1623
+ for (let C = 0; C < K.variablesLength(); C += b.memberLength ?? 1) {
1624
+ const E = (r = (e = (f = K.variables(C).valuesArray()) == null ? void 0 : f.toString()) == null ? void 0 : e.split(",")) == null ? void 0 : r.map((J) => isNaN(J) ? null : Math.round(Number(J) * c) / c);
1625
+ h.daily[z.daily[C / (b.memberLength ?? 1)]] = E;
1626
1626
  }
1627
1627
  const g = L();
1628
1628
  this.debug && D.debug("[%s] fetch daily variables cost: %d ms", b.requestId, g.diff(H, "ms"));
@@ -1643,10 +1643,10 @@ class J0 {
1643
1643
  for (let W = M[b][p][c].length; W < z[b][p][c].length; W++)
1644
1644
  M[b][p][c].push(z[b][p][c][W]);
1645
1645
  } else {
1646
- const W = L(z[b][p].date), A = L(M[b][p].date);
1646
+ const W = L(z[b][p].date), O = L(M[b][p].date);
1647
1647
  for (let o = 0; o < z[b][p][c].length; o++) {
1648
- const d = W.clone().add(o, "h").diff(A, "h");
1649
- d < M[b][p][c].length ? M[b][p][c][d] === null && (M[b][p][c][d] = z[b][p][c][o]) : c === "time" ? M[b][p][c].push(d) : M[b][p][c].push(z[b][p][c][o]);
1648
+ const q = W.clone().add(o, "h").diff(O, "h");
1649
+ q < M[b][p][c].length ? M[b][p][c][q] === null && (M[b][p][c][q] = z[b][p][c][o]) : c === "time" ? M[b][p][c].push(q) : M[b][p][c].push(z[b][p][c][o]);
1650
1650
  }
1651
1651
  }
1652
1652
  } else if (p === "daily") {
@@ -1660,12 +1660,12 @@ class J0 {
1660
1660
  return M;
1661
1661
  }
1662
1662
  async mergeMarineData(M) {
1663
- var c, W, A, o;
1664
- const z = [], b = M.find((d) => d.model === "best_match");
1663
+ var c, W, O, o;
1664
+ const z = [], b = M.find((q) => q.model === "best_match");
1665
1665
  b && z.push(b);
1666
- const p = M.find((d) => d.model === "meteofrance_currents");
1667
- for (const d of M)
1668
- ["best_match", "meteofrance_currents"].includes(d.model) || (d.hourly.ocean_current_velocity = (c = p == null ? void 0 : p.hourly) == null ? void 0 : c.ocean_current_velocity, d.hourly.ocean_current_direction = (W = p == null ? void 0 : p.hourly) == null ? void 0 : W.ocean_current_direction, d.hourly.sea_level_height_msl = (A = p == null ? void 0 : p.hourly) == null ? void 0 : A.sea_level_height_msl, d.hourly.sea_surface_temperature = (o = p == null ? void 0 : p.hourly) == null ? void 0 : o.sea_surface_temperature, z.push(d));
1666
+ const p = M.find((q) => q.model === "meteofrance_currents");
1667
+ for (const q of M)
1668
+ ["best_match", "meteofrance_currents"].includes(q.model) || (q.hourly.ocean_current_velocity = (c = p == null ? void 0 : p.hourly) == null ? void 0 : c.ocean_current_velocity, q.hourly.ocean_current_direction = (W = p == null ? void 0 : p.hourly) == null ? void 0 : W.ocean_current_direction, q.hourly.sea_level_height_msl = (O = p == null ? void 0 : p.hourly) == null ? void 0 : O.sea_level_height_msl, q.hourly.sea_surface_temperature = (o = p == null ? void 0 : p.hourly) == null ? void 0 : o.sea_surface_temperature, z.push(q));
1669
1669
  return z;
1670
1670
  }
1671
1671
  pickForecastUrl(M, z, b, p = {}) {
@@ -1677,14 +1677,14 @@ class J0 {
1677
1677
  if (!(z != null && z.length))
1678
1678
  return ["best_match"];
1679
1679
  const b = [];
1680
- for (let A = 0; A < z.length; A++) {
1681
- const o = z[A];
1680
+ for (let O = 0; O < z.length; O++) {
1681
+ const o = z[O];
1682
1682
  ["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");
1683
1683
  }
1684
- const p = b.reduce((A, o) => (A.includes(o) || A.push(o), A), []), c = ["best_match", "meteofrance_currents", "meteofrance_wave", "ecmwf_wam025", "ncep_gfswave025", "gwam", "era5_ocean", "ewam", "ncep_gfswave016"];
1685
- return p.sort((A, o) => {
1686
- const d = c.indexOf(A), Y = c.indexOf(o);
1687
- return d - Y;
1684
+ const p = 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"];
1685
+ return p.sort((O, o) => {
1686
+ const q = c.indexOf(O), d = c.indexOf(o);
1687
+ return q - d;
1688
1688
  }), p;
1689
1689
  }
1690
1690
  /**
@@ -1696,8 +1696,8 @@ class J0 {
1696
1696
  * @private
1697
1697
  */
1698
1698
  async prepare(M, z, b, p = {}) {
1699
- var d, Y;
1700
- const c = L.utc(), W = M ? L.utc(M) : void 0, A = z ? await this.pickUpdateMeta(b.models) : [], o = (Y = (d = A[0]) == null ? void 0 : d.meta) != null && Y.endTime ? L(A[0].meta.endTime) : c.clone().add(14, "day");
1699
+ var q, d;
1700
+ const c = L.utc(), W = M ? L.utc(M) : void 0, O = z ? await this.pickUpdateMeta(b.models) : [], o = (d = (q = O[0]) == null ? void 0 : q.meta) != null && d.endTime ? L(O[0].meta.endTime) : c.clone().add(14, "day");
1701
1701
  if (M) {
1702
1702
  const X = W.clone().utc().add(p.forecastDays ?? 1, "day");
1703
1703
  X.isAfter(o) ? (X.subtract(1, "year"), W.isAfter(o) ? (W.subtract(1, "year"), b.start_dates = [
@@ -1760,38 +1760,38 @@ class J0 {
1760
1760
  * @param withHourly
1761
1761
  * @param options
1762
1762
  */
1763
- async spotForecast(M, z, b, p = !0, c = !0, W = !1, A = {
1763
+ async spotForecast(M, z, b, p = !0, c = !0, W = !1, O = {
1764
1764
  forecastDays: 1,
1765
1765
  pastDays: 0,
1766
1766
  precision: 6,
1767
1767
  selfHosted: !0
1768
1768
  }) {
1769
1769
  var e, r, N, u, B, S;
1770
- z = this.toStdLng(z), this.debug && D.info("[%s] spot forecast params: %j", A.requestId, { lat: M, lng: z, datetime: b, simplify: p, withDaily: c, withHourly: W, options: A });
1770
+ z = this.toStdLng(z), this.debug && D.info("[%s] spot forecast params: %j", O.requestId, { lat: M, lng: z, datetime: b, simplify: p, withDaily: c, withHourly: W, options: O });
1771
1771
  const o = {
1772
1772
  apikey: this.apikey,
1773
1773
  latitude: M,
1774
1774
  longitude: z,
1775
1775
  cell_selection: "sea",
1776
1776
  wind_speed_unit: "kn",
1777
- models: ((e = A.weatherModels) == null ? void 0 : e.split(",")) || ["best_match"],
1777
+ models: ((e = O.weatherModels) == null ? void 0 : e.split(",")) || ["best_match"],
1778
1778
  timezone: "auto"
1779
1779
  };
1780
- let d;
1781
- const Y = this.timezoneOffset(M, z);
1782
- b && (d = L.utc(b).utcOffset(Y), d.subtract(Y > 0 ? Y : -Y, "h"), A.selfHistory = !(d != null && d.isBefore(L.utc().subtract(120, "days")))), c && (o.daily = ((r = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : r.split(",")) || []), d || (A.forecastDays = A.forecastDays || 1, A.pastDays = 0, W = !0), W && (o.hourly = ((N = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : N.split(",")) || []), A.pastDays = A.pastDays || 0, A.pastDays = A.pastDays > 7 ? 7 : A.pastDays < 0 ? 0 : A.pastDays, A.forecastDays = A.forecastDays ?? 1, A.forecastDays = A.forecastDays > 14 ? 14 : A.forecastDays < 0 ? 1 : A.forecastDays, await this.prepare(d == null ? void 0 : d.utc().format(), !1, o, A);
1783
- const X = await this.weatherForecast(o, A), q = {
1780
+ let q;
1781
+ const d = this.timezoneOffset(M, z);
1782
+ b && (q = L.utc(b).utcOffset(d), q.subtract(d > 0 ? d : -d, "h"), O.selfHistory = !(q != null && q.isBefore(L.utc().subtract(120, "days")))), c && (o.daily = ((r = this.FORECAST.WEATHER_VARIABLES.NORMAL.DAILY) == null ? void 0 : r.split(",")) || []), q || (O.forecastDays = O.forecastDays || 1, O.pastDays = 0, W = !0), W && (o.hourly = ((N = this.FORECAST.WEATHER_VARIABLES.NORMAL.HOURLY) == null ? void 0 : N.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, await this.prepare(q == null ? void 0 : q.utc().format(), !1, o, O);
1783
+ const X = await this.weatherForecast(o, O), Y = {
1784
1784
  apikey: this.apikey,
1785
1785
  latitude: M,
1786
1786
  longitude: z,
1787
1787
  cell_selection: "sea",
1788
1788
  timezone: "auto",
1789
1789
  wind_speed_unit: "kn",
1790
- models: this.pickMarineModels(A.marineModels)
1790
+ models: this.pickMarineModels(O.marineModels)
1791
1791
  };
1792
- c && (q.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), d || (A.forecastDays = A.forecastDays || 1, W = !0), W && (q.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare(d == null ? void 0 : d.utc().format(), !0, q, A);
1793
- let f = await this.marineForecast(q, A);
1794
- return (S = (B = (u = f[0]) == null ? void 0 : u.hourly) == null ? void 0 : B.wave_height) != null && S.every((m) => m === null || m === 0) && (q.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), f = await this.marineForecast(q, A)), { weather: X, marine: f };
1792
+ c && (Y.daily = this.FORECAST.MARINE_VARIABLES.DAILY.split(",")), q || (O.forecastDays = O.forecastDays || 1, W = !0), W && (Y.hourly = this.FORECAST.MARINE_VARIABLES.HOURLY.split(",")), await this.prepare(q == null ? void 0 : q.utc().format(), !0, Y, O);
1793
+ let f = await this.marineForecast(Y, O);
1794
+ return (S = (B = (u = f[0]) == null ? void 0 : u.hourly) == null ? void 0 : B.wave_height) != null && S.every((m) => m === null || m === 0) && (Y.models = this.pickMarineModels("best_match,ncep_gfswave025,meteofrance_wave"), f = await this.marineForecast(Y, O)), { weather: X, marine: f };
1795
1795
  }
1796
1796
  /**
1797
1797
  * 历史再分析数据
@@ -1814,14 +1814,14 @@ class J0 {
1814
1814
  * @param withMarine
1815
1815
  * @param options
1816
1816
  */
1817
- async spotHistorical(M, z, b, p, c = !0, W = !0, A = !1, o = {
1817
+ async spotHistorical(M, z, b, p, c = !0, W = !0, O = !1, o = {
1818
1818
  precision: 6
1819
1819
  }) {
1820
1820
  var r, N;
1821
- z = this.toStdLng(z), this.debug && D.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: z, startDate: b, endDate: p, withMarine: A, options: o });
1822
- const d = this.timezoneOffset(M, z), Y = L.utc(b).utcOffset(d), X = L.utc(p).utcOffset(d);
1823
- Y.subtract(d > 0 ? d : -d, "h"), X.subtract(d > 0 ? d : -d, "h");
1824
- const q = {
1821
+ z = this.toStdLng(z), this.debug && D.info("[%s] spot historical params: %j", o.requestId, { lat: M, lng: z, startDate: b, endDate: p, withMarine: O, options: o });
1822
+ const q = this.timezoneOffset(M, z), d = L.utc(b).utcOffset(q), X = L.utc(p).utcOffset(q);
1823
+ d.subtract(q > 0 ? q : -q, "h"), X.subtract(q > 0 ? q : -q, "h");
1824
+ const Y = {
1825
1825
  apikey: this.apikey,
1826
1826
  latitude: M,
1827
1827
  longitude: z,
@@ -1830,13 +1830,13 @@ class J0 {
1830
1830
  models: ((r = o.weatherModels) == null ? void 0 : r.split(",")) || ["best_match"],
1831
1831
  timezone: "auto",
1832
1832
  url: this.HISTORICAL.OM_URL,
1833
- start_date: Y.format("YYYY-MM-DD"),
1833
+ start_date: d.format("YYYY-MM-DD"),
1834
1834
  end_date: X.format("YYYY-MM-DD")
1835
1835
  };
1836
- c && (q.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), W && (q.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
1837
- const f = await this.weatherForecast(q, o);
1836
+ c && (Y.daily = this.HISTORICAL.WEATHER_VARIABLES.DAILY.split(",")), W && (Y.hourly = this.HISTORICAL.WEATHER_VARIABLES.HOURLY.split(","));
1837
+ const f = await this.weatherForecast(Y, o);
1838
1838
  let e;
1839
- if (A) {
1839
+ if (O) {
1840
1840
  const u = {
1841
1841
  apikey: this.apikey,
1842
1842
  latitude: M,
@@ -1848,7 +1848,7 @@ class J0 {
1848
1848
  daily: this.FORECAST.MARINE_VARIABLES.DAILY.split(","),
1849
1849
  hourly: this.FORECAST.MARINE_VARIABLES.HOURLY.split(","),
1850
1850
  url: this.FORECAST.OM_MARINE_URL,
1851
- start_date: Y.format("YYYY-MM-DD"),
1851
+ start_date: d.format("YYYY-MM-DD"),
1852
1852
  end_date: X.format("YYYY-MM-DD")
1853
1853
  };
1854
1854
  e = await this.marineForecast(u, o);
@@ -1870,9 +1870,9 @@ class J0 {
1870
1870
  precision: 6
1871
1871
  }) {
1872
1872
  z = this.toStdLng(z), this.debug && D.info("[%s] spot seasonal params: %j", W.requestId, { lat: M, lng: z, startDate: b, endDate: p, options: W });
1873
- const A = this.timezoneOffset(M, z), o = L.utc(b).utcOffset(A), d = p ? L.utc(p).utcOffset(A) : o.clone().add(1, "month");
1874
- o.subtract(A > 0 ? A : -A, "h"), d.subtract(A > 0 ? A : -A, "h");
1875
- const Y = {
1873
+ const O = this.timezoneOffset(M, z), o = L.utc(b).utcOffset(O), q = p ? L.utc(p).utcOffset(O) : o.clone().add(1, "month");
1874
+ o.subtract(O > 0 ? O : -O, "h"), q.subtract(O > 0 ? O : -O, "h");
1875
+ const d = {
1876
1876
  apikey: this.apikey,
1877
1877
  latitude: M,
1878
1878
  longitude: z,
@@ -1881,10 +1881,10 @@ class J0 {
1881
1881
  timezone: "auto",
1882
1882
  url: this.SEASONAL.OM_URL,
1883
1883
  start_date: o.format("YYYY-MM-DD"),
1884
- end_date: d.format("YYYY-MM-DD"),
1884
+ end_date: q.format("YYYY-MM-DD"),
1885
1885
  daily: this.SEASONAL.WEATHER_VARIABLES.DAILY.split(",")
1886
1886
  };
1887
- return c && (Y.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), W.memberLength = 4, { weather: await this.weatherForecast(Y, W) };
1887
+ return c && (d.six_hourly = this.SEASONAL.WEATHER_VARIABLES.SIX_HOURLY.split(",")), W.memberLength = 4, { weather: await this.weatherForecast(d, W) };
1888
1888
  }
1889
1889
  /**
1890
1890
  * 气候态数据
@@ -1911,9 +1911,9 @@ class J0 {
1911
1911
  }) {
1912
1912
  var X;
1913
1913
  z = this.toStdLng(z), this.debug && D.info("[%s] spot climate params: %j", c.requestId, { lat: M, lng: z, startDate: b, endDate: p, options: c });
1914
- const W = this.timezoneOffset(M, z), A = L.utc(b).utcOffset(W), o = p ? L.utc(p).utcOffset(W) : A.clone().add(1, "day");
1915
- o.subtract(W > 0 ? W : -W, "h"), A.subtract(W > 0 ? W : -W, "h");
1916
- const d = {
1914
+ const W = this.timezoneOffset(M, z), O = L.utc(b).utcOffset(W), o = p ? L.utc(p).utcOffset(W) : O.clone().add(1, "day");
1915
+ o.subtract(W > 0 ? W : -W, "h"), O.subtract(W > 0 ? W : -W, "h");
1916
+ const q = {
1917
1917
  apikey: this.apikey,
1918
1918
  latitude: M,
1919
1919
  longitude: z,
@@ -1922,11 +1922,11 @@ class J0 {
1922
1922
  models: ((X = c.weatherModels) == null ? void 0 : X.split(",")) || "EC_Earth3P_HR",
1923
1923
  timezone: "auto",
1924
1924
  url: this.CLIMATE.OM_URL,
1925
- start_date: A.format("YYYY-MM-DD"),
1925
+ start_date: O.format("YYYY-MM-DD"),
1926
1926
  end_date: o.format("YYYY-MM-DD"),
1927
1927
  daily: this.CLIMATE.WEATHER_VARIABLES.DAILY.split(",")
1928
1928
  };
1929
- return { weather: await this.weatherForecast(d, c) };
1929
+ return { weather: await this.weatherForecast(q, c) };
1930
1930
  }
1931
1931
  async update(M = {}) {
1932
1932
  const z = L.unix(this.METEO2_UPDATE.etime), b = this.METEO2_UPDATE.version, p = L();
@@ -1938,12 +1938,12 @@ class J0 {
1938
1938
  }
1939
1939
  });
1940
1940
  try {
1941
- const A = await W.json();
1942
- if (A.code === 0) {
1943
- const o = A.data, d = M0.standardWeatherModels();
1944
- for (const Y of d) {
1945
- const X = M0.autoPickSubCategories(Y.alias), f = o.filter((e) => X.includes(e.category)).map((e) => {
1946
- var B, S, m, l, P, K;
1941
+ const O = await W.json();
1942
+ if (O.code === 0) {
1943
+ const o = O.data, q = $.standardWeatherModels();
1944
+ for (const d of q) {
1945
+ const X = $.autoPickSubCategories(d.alias), f = o.filter((e) => X.includes(e.category)).map((e) => {
1946
+ var B, S, m, Z, P, K;
1947
1947
  const r = L.unix((B = e.meta) == null ? void 0 : B.data_end_time).utc(), N = L.unix((S = e.meta) == null ? void 0 : S.last_run_availability_time).utc(), u = r.diff(N, "days");
1948
1948
  return {
1949
1949
  category: e.category,
@@ -1952,18 +1952,18 @@ class J0 {
1952
1952
  availabilityTime: N.format(),
1953
1953
  days: u,
1954
1954
  initialisationTime: L.unix((m = e.meta) == null ? void 0 : m.last_run_initialisation_time).utc().format(),
1955
- modificationTime: L.unix((l = e.meta) == null ? void 0 : l.last_run_modification_time).utc().format(),
1955
+ modificationTime: L.unix((Z = e.meta) == null ? void 0 : Z.last_run_modification_time).utc().format(),
1956
1956
  temporalResolution: Math.round(((P = e.meta) == null ? void 0 : P.temporal_resolution_seconds) / 3600),
1957
1957
  frequency: Math.round(((K = e.meta) == null ? void 0 : K.update_interval_seconds) / 3600)
1958
1958
  }
1959
1959
  };
1960
1960
  });
1961
- f.length && (this.METEO2_UPDATE[Y.alias] = f);
1961
+ f.length && (this.METEO2_UPDATE[d.alias] = f);
1962
1962
  }
1963
1963
  this.METEO2_UPDATE.version = b + 1, this.METEO2_UPDATE.etime = p.unix();
1964
1964
  }
1965
- } catch (A) {
1966
- D.error("[%s] update meteo2 error: %s", M.requestId, A);
1965
+ } catch (O) {
1966
+ D.error("[%s] update meteo2 error: %s", M.requestId, O);
1967
1967
  }
1968
1968
  }
1969
1969
  return this.METEO2_UPDATE;
@@ -1985,7 +1985,7 @@ try {
1985
1985
  } catch {
1986
1986
  } finally {
1987
1987
  }
1988
- class k0 {
1988
+ class J0 {
1989
1989
  constructor(M, z) {
1990
1990
  F(this, "apikey");
1991
1991
  F(this, "debug");
@@ -2024,27 +2024,27 @@ class k0 {
2024
2024
  * @param datum
2025
2025
  * @param options
2026
2026
  */
2027
- async tidesForecast(M, z, b = 7, p = "today", c = !0, W = !1, A = !1, o = "CD", d = {}) {
2028
- p = p || "today", b = b || 7, z = this.toStdLng(z), this.debug && R0.info("[%s] spot tides forecast params: %j", d.requestId, { lat: M, lng: z, date: p, extremes: c, heights: W, datums: A, datum: o });
2029
- let Y = `https://www.worldtides.info/api/v3?lat=${M}&lon=${z}&days=${b}&date=${p}&datum=${o}&key=${this.apikey}&localtime`;
2030
- c && (Y = `${Y}&extremes`), W && (Y = `${Y}&heights`), A && (Y = `${Y}&datums`);
2031
- const q = await (await fetch(Y)).json();
2032
- return q.status === 200 ? {
2027
+ async tidesForecast(M, z, b = 7, p = "today", c = !0, W = !1, O = !1, o = "CD", q = {}) {
2028
+ p = p || "today", b = b || 7, z = this.toStdLng(z), this.debug && R0.info("[%s] spot tides forecast params: %j", q.requestId, { lat: M, lng: z, date: p, extremes: c, heights: W, datums: O, datum: o });
2029
+ let d = `https://www.worldtides.info/api/v3?lat=${M}&lon=${z}&days=${b}&date=${p}&datum=${o}&key=${this.apikey}&localtime`;
2030
+ c && (d = `${d}&extremes`), W && (d = `${d}&heights`), O && (d = `${d}&datums`);
2031
+ const Y = await (await fetch(d)).json();
2032
+ return Y.status === 200 ? {
2033
2033
  rqt: {
2034
2034
  lat: M,
2035
2035
  lng: z
2036
2036
  },
2037
2037
  rsp: {
2038
- lat: q.responseLat,
2039
- lng: q.responseLon
2038
+ lat: Y.responseLat,
2039
+ lng: Y.responseLon
2040
2040
  },
2041
- atlas: q.atlas,
2042
- datum: q.responseDatum,
2043
- extremes: q.extremes || [],
2044
- heights: q.heights || [],
2045
- stations: q.stations || [],
2046
- datums: q.datums || []
2047
- } : q;
2041
+ atlas: Y.atlas,
2042
+ datum: Y.responseDatum,
2043
+ extremes: Y.extremes || [],
2044
+ heights: Y.heights || [],
2045
+ stations: Y.stations || [],
2046
+ datums: Y.datums || []
2047
+ } : Y;
2048
2048
  }
2049
2049
  }
2050
2050
  let X0;
@@ -2053,7 +2053,7 @@ try {
2053
2053
  } catch {
2054
2054
  } finally {
2055
2055
  }
2056
- class $ {
2056
+ class j {
2057
2057
  static async parseHistory(M) {
2058
2058
  return M == null ? void 0 : M.map((z) => {
2059
2059
  const b = Number(z.pressure / 100), p = Number(z.lat), c = Number(z.lon), W = Number(z.windSpeed * 3600 / 1852);
@@ -2089,16 +2089,16 @@ class $ {
2089
2089
  var c;
2090
2090
  const b = L.utc(z.reftime).format(), p = {};
2091
2091
  return (c = z.records) == null || c.forEach((W) => {
2092
- const A = L.utc(W.time), o = A.diff(b, "hour"), d = Number(W.pressure / 100), Y = Number(W.lat), X = Number(W.lon), q = Number(W.windSpeed * 3600 / 1852);
2092
+ const O = L.utc(W.time), o = O.diff(b, "hour"), q = Number(W.pressure / 100), d = Number(W.lat), X = Number(W.lon), Y = Number(W.windSpeed * 3600 / 1852);
2093
2093
  p[o] = {
2094
- lat: isNaN(Y) ? null : Y,
2094
+ lat: isNaN(d) ? null : d,
2095
2095
  lng: isNaN(X) ? null : X,
2096
- pressure: isNaN(d) ? null : Math.round(d) || null,
2097
- utc: A.format(),
2096
+ pressure: isNaN(q) ? null : Math.round(q) || null,
2097
+ utc: O.format(),
2098
2098
  wind: {
2099
- datetime: A.format(),
2100
- kts: isNaN(q) ? null : Math.round(q) || null,
2101
- type: T.parseTropicalType(q),
2099
+ datetime: O.format(),
2100
+ kts: isNaN(Y) ? null : Math.round(Y) || null,
2101
+ type: T.parseTropicalType(Y),
2102
2102
  r7: null,
2103
2103
  r7ne: null,
2104
2104
  r7nw: null,
@@ -2133,31 +2133,31 @@ class $ {
2133
2133
  id: z == null ? void 0 : z.toLowerCase(),
2134
2134
  name: (W = b == null ? void 0 : b.toLowerCase()) == null ? void 0 : W.replaceAll(/\s/g, "-"),
2135
2135
  strength: p,
2136
- history: await $.parseHistory(M.history),
2137
- forecasts: await $.parseForecast(M.forecast)
2136
+ history: await j.parseHistory(M.history),
2137
+ forecasts: await j.parseForecast(M.forecast)
2138
2138
  };
2139
2139
  return await T.tropicalMovement(c), c;
2140
2140
  }
2141
2141
  static async realtimeForecast() {
2142
2142
  const M = "https://node.windy.com/tc/v2/storms", z = await Q.get(M).json(), b = [];
2143
2143
  for (const p of z.storms) {
2144
- const c = `https://node.windy.com/tc/v2/storms/${p.id}`, W = await Q.get(c).json(), A = await $.parseTropical(W);
2145
- b.push(A);
2144
+ const c = `https://node.windy.com/tc/v2/storms/${p.id}`, W = await Q.get(c).json(), O = await j.parseTropical(W);
2145
+ b.push(O);
2146
2146
  }
2147
2147
  return b;
2148
2148
  }
2149
2149
  }
2150
- const J = class J {
2150
+ const k = class k {
2151
2151
  static async parseHistory(M) {
2152
- const z = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, b = await Q.post(z).text(), p = await J.parser.parseStringPromise(b), c = p.typhoon.position instanceof Array ? p.typhoon.position : [p.typhoon.position], W = [];
2153
- for (const A of c) {
2154
- const o = L(A.updatetime).utcOffset(8).utc().format(), d = Number(A.lat), Y = Number(A.lon), X = Number(A.pressure), q = Number(A.windspeed * 3600 / 1852), f = T.parseWindCircle(A.c7quad1 / 1.852), e = T.parseWindCircle(A.c7quad2 / 1.852), r = T.parseWindCircle(A.c7quad3 / 1.852), N = T.parseWindCircle(A.c7quad4 / 1.852), u = T.parseWindCircle(A.c10quad1 / 1.852), B = T.parseWindCircle(A.c10quad2 / 1.852), S = T.parseWindCircle(A.c10quad3 / 1.852), m = T.parseWindCircle(A.c10quad4 / 1.852), l = T.parseWindCircle(A.c12quad1 / 1.852), P = T.parseWindCircle(A.c12quad2 / 1.852), K = T.parseWindCircle(A.c12quad3 / 1.852), h = T.parseWindCircle(A.c12quad4 / 1.852), { r7: H, r10: g, r12: G } = T.estimateWindRadii(q, X, d), E = {
2152
+ const z = `https://hifleet.com/hifleetapi/gettyphooninfo2.do?xuhao=${M}`, b = await Q.post(z).text(), p = await k.parser.parseStringPromise(b), c = p.typhoon.position instanceof Array ? p.typhoon.position : [p.typhoon.position], W = [];
2153
+ for (const O of c) {
2154
+ const o = L(O.updatetime).utcOffset(8).utc().format(), q = Number(O.lat), d = Number(O.lon), X = Number(O.pressure), Y = Number(O.windspeed * 3600 / 1852), f = T.parseWindCircle(O.c7quad1 / 1.852), e = T.parseWindCircle(O.c7quad2 / 1.852), r = T.parseWindCircle(O.c7quad3 / 1.852), N = T.parseWindCircle(O.c7quad4 / 1.852), u = T.parseWindCircle(O.c10quad1 / 1.852), B = T.parseWindCircle(O.c10quad2 / 1.852), S = T.parseWindCircle(O.c10quad3 / 1.852), m = T.parseWindCircle(O.c10quad4 / 1.852), Z = T.parseWindCircle(O.c12quad1 / 1.852), P = T.parseWindCircle(O.c12quad2 / 1.852), K = T.parseWindCircle(O.c12quad3 / 1.852), h = T.parseWindCircle(O.c12quad4 / 1.852), { r7: H, r10: g, r12: C } = T.estimateWindRadii(Y, q), E = {
2155
2155
  updated: o,
2156
- lat: isNaN(d) ? null : d,
2157
- lng: isNaN(Y) ? null : Y,
2156
+ lat: isNaN(q) ? null : q,
2157
+ lng: isNaN(d) ? null : d,
2158
2158
  pressure: isNaN(X) ? null : Math.round(X),
2159
- kts: isNaN(q) ? null : Math.round(q) || null,
2160
- type: T.parseTropicalType(q),
2159
+ kts: isNaN(Y) ? null : Math.round(Y) || null,
2160
+ type: T.parseTropicalType(Y),
2161
2161
  wind: {
2162
2162
  r7: H,
2163
2163
  r7ne: f,
@@ -2169,8 +2169,8 @@ const J = class J {
2169
2169
  r10nw: B,
2170
2170
  r10sw: S,
2171
2171
  r10se: m,
2172
- r12: G,
2173
- r12ne: l,
2172
+ r12: C,
2173
+ r12ne: Z,
2174
2174
  r12nw: P,
2175
2175
  r12sw: K,
2176
2176
  r12se: h
@@ -2178,21 +2178,21 @@ const J = class J {
2178
2178
  };
2179
2179
  W.push(E);
2180
2180
  }
2181
- return W.sort((A, o) => L(o.updated).unix() - L(A.updated).unix()), W;
2181
+ return W.sort((O, o) => L(o.updated).unix() - L(O.updated).unix()), W;
2182
2182
  }
2183
2183
  static async parseForecast(M, z) {
2184
- const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, p = await Q.post(b).text(), c = await J.parser.parseStringPromise(p), W = c.list.forecast instanceof Array ? c.list.forecast : [c.list.forecast], A = [];
2184
+ const b = `https://hifleet.com/hifleetapi/gettyphooforecast.do?xuhao=${M}`, p = await Q.post(b).text(), c = await k.parser.parseStringPromise(p), W = c.list.forecast instanceof Array ? c.list.forecast : [c.list.forecast], O = [];
2185
2185
  for (const o of W)
2186
2186
  if (o.xuhao === M) {
2187
- const d = o.positions.forecastposition instanceof Array ? o.positions.forecastposition : [o.positions.forecastposition];
2188
- if (d.length) {
2189
- z = z || L(d.at(0).forecasttime).utcOffset(8).utc();
2190
- const Y = {};
2191
- for (const q of d) {
2192
- const f = L(q.forecasttime).utcOffset(8).utc(), e = f.diff(z, "hours");
2187
+ const q = o.positions.forecastposition instanceof Array ? o.positions.forecastposition : [o.positions.forecastposition];
2188
+ if (q.length) {
2189
+ z = z || L(q.at(0).forecasttime).utcOffset(8).utc();
2190
+ const d = {};
2191
+ for (const Y of q) {
2192
+ const f = L(Y.forecasttime).utcOffset(8).utc(), e = f.diff(z, "hours");
2193
2193
  if (e) {
2194
- const r = Number(q.forelat), N = Number(q.forelon), u = Number(q.forepressure), B = Number(q.forespeed * 3600 / 1852);
2195
- Y[e] = {
2194
+ const r = Number(Y.forelat), N = Number(Y.forelon), u = Number(Y.forepressure), B = Number(Y.forespeed * 3600 / 1852);
2195
+ d[e] = {
2196
2196
  lat: isNaN(r) ? null : r,
2197
2197
  lng: isNaN(N) ? null : N,
2198
2198
  pressure: u ? Math.round(u) : null,
@@ -2226,17 +2226,17 @@ const J = class J {
2226
2226
  const X = {
2227
2227
  date: z.utc().format(),
2228
2228
  model: T.parseTropicalModel(o.country).toLowerCase(),
2229
- hours: Y
2229
+ hours: d
2230
2230
  };
2231
- A.push(X);
2231
+ O.push(X);
2232
2232
  }
2233
2233
  }
2234
- return A;
2234
+ return O;
2235
2235
  }
2236
2236
  static async parseTropical(M) {
2237
- var W, A, o;
2238
- const z = await J.parseHistory(M.xuhao), b = (W = z.at(0)) == null ? void 0 : W.updated, p = await J.parseForecast(M.xuhao, b ? L(b) : void 0), c = {
2239
- id: (A = M.enname) == null ? void 0 : A.toLowerCase(),
2237
+ var W, O, o;
2238
+ const z = await k.parseHistory(M.xuhao), b = (W = z.at(0)) == null ? void 0 : W.updated, p = await k.parseForecast(M.xuhao, b ? L(b) : void 0), c = {
2239
+ id: (O = M.enname) == null ? void 0 : O.toLowerCase(),
2240
2240
  name: (o = M.enname) == null ? void 0 : o.toLowerCase(),
2241
2241
  cnName: M.name,
2242
2242
  history: z,
@@ -2245,21 +2245,21 @@ const J = class J {
2245
2245
  return await T.tropicalMovement(c), c;
2246
2246
  }
2247
2247
  static async realtimeForecast() {
2248
- const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", z = await Q.post(M).text(), b = await J.parser.parseStringPromise(z), p = [], c = b.typhoon.position instanceof Array ? b.typhoon.position : [b.typhoon.position];
2248
+ const M = "https://hifleet.com/hifleetapi/getCurrentTyphoon2.do", z = await Q.post(M).text(), b = await k.parser.parseStringPromise(z), p = [], c = b.typhoon.position instanceof Array ? b.typhoon.position : [b.typhoon.position];
2249
2249
  for (const W of c)
2250
2250
  if (W) {
2251
- const A = await J.parseTropical(W);
2252
- p.push(A);
2251
+ const O = await k.parseTropical(W);
2252
+ p.push(O);
2253
2253
  }
2254
2254
  return p;
2255
2255
  }
2256
2256
  };
2257
- F(J, "parser", u0.Parser({ explicitArray: !1, mergeAttrs: !0, trim: !0 }));
2258
- let b0 = J;
2259
- class j {
2257
+ F(k, "parser", u0.Parser({ explicitArray: !1, mergeAttrs: !0, trim: !0 }));
2258
+ let b0 = k;
2259
+ class x {
2260
2260
  static async parseHistory(M) {
2261
2261
  return M.map((z) => {
2262
- const b = Number(z.lat), p = Number(z.lon), c = Number(z.maxSP * 3600 / 1852), W = Number(z.minP), A = T.parseWindCircle(z.r7Ne / 1.852), o = T.parseWindCircle(z.r7Nw / 1.852), d = T.parseWindCircle(z.r7Se / 1.852), Y = T.parseWindCircle(z.r7Sw / 1.852), X = T.parseWindCircle(z.r10Ne / 1.852), q = T.parseWindCircle(z.r10Nw / 1.852), f = T.parseWindCircle(z.r10Se / 1.852), e = T.parseWindCircle(z.r10Sw / 1.852), r = T.parseWindCircle(z.r12Ne / 1.852), N = T.parseWindCircle(z.r12Nw / 1.852), u = T.parseWindCircle(z.r12Se / 1.852), B = T.parseWindCircle(z.r12Sw / 1.852), { r7: S, r10: m, r12: l } = T.estimateWindRadii(c, W, b);
2262
+ const b = Number(z.lat), p = Number(z.lon), c = Number(z.maxSP * 3600 / 1852), W = T.parseWindCircle(z.r7Ne / 1.852), O = T.parseWindCircle(z.r7Nw / 1.852), o = T.parseWindCircle(z.r7Se / 1.852), q = T.parseWindCircle(z.r7Sw / 1.852), d = T.parseWindCircle(z.r10Ne / 1.852), X = T.parseWindCircle(z.r10Nw / 1.852), Y = T.parseWindCircle(z.r10Se / 1.852), f = T.parseWindCircle(z.r10Sw / 1.852), e = T.parseWindCircle(z.r12Ne / 1.852), r = T.parseWindCircle(z.r12Nw / 1.852), N = T.parseWindCircle(z.r12Se / 1.852), u = T.parseWindCircle(z.r12Sw / 1.852), { r7: B, r10: S, r12: m } = T.estimateWindRadii(c, b);
2263
2263
  return {
2264
2264
  updated: L.utc(z.realTime).format(),
2265
2265
  lat: isNaN(b) ? null : b || null,
@@ -2267,21 +2267,21 @@ class j {
2267
2267
  kts: isNaN(c) ? null : Math.round(c) || null,
2268
2268
  type: T.parseTropicalType(c),
2269
2269
  wind: {
2270
- r7: S,
2271
- r7ne: A,
2272
- r7nw: o,
2273
- r7se: d,
2274
- r7sw: Y,
2275
- r10: m,
2276
- r10ne: X,
2277
- r10nw: q,
2278
- r10se: f,
2279
- r10sw: e,
2280
- r12: l,
2281
- r12ne: r,
2282
- r12nw: N,
2283
- r12se: u,
2284
- r12sw: B
2270
+ r7: B,
2271
+ r7ne: W,
2272
+ r7nw: O,
2273
+ r7se: o,
2274
+ r7sw: q,
2275
+ r10: S,
2276
+ r10ne: d,
2277
+ r10nw: X,
2278
+ r10se: Y,
2279
+ r10sw: f,
2280
+ r12: m,
2281
+ r12ne: e,
2282
+ r12nw: r,
2283
+ r12se: N,
2284
+ r12sw: u
2285
2285
  }
2286
2286
  };
2287
2287
  });
@@ -2289,32 +2289,32 @@ class j {
2289
2289
  static async parseForecast(M) {
2290
2290
  return M.map((z) => {
2291
2291
  const b = z.currentPosition, p = z.forecastPoints, c = L.utc(b.realTime).format(), W = {};
2292
- return p.forEach((A) => {
2293
- const o = L.utc(A.forecastTime), d = o.diff(c, "hour"), Y = Math.round(A.maxSP * 3600 / 1852), X = Math.round(A.maxSP * 3600 / 1852), q = A.pressure, f = T.parseWindCircle(A.r7Ne / 1.852), e = T.parseWindCircle(A.r7Nw / 1.852), r = T.parseWindCircle(A.r7Sw / 1.852), N = T.parseWindCircle(A.r7Se / 1.852), u = T.parseWindCircle(A.r10Ne / 1.852), B = T.parseWindCircle(A.r10Nw / 1.852), S = T.parseWindCircle(A.r10Sw / 1.852), m = T.parseWindCircle(A.r10Se / 1.852), l = T.parseWindCircle(A.r12Ne / 1.852), P = T.parseWindCircle(A.r12Nw / 1.852), K = T.parseWindCircle(A.r12Sw / 1.852), h = T.parseWindCircle(A.r12Se / 1.852), { r7: H, r10: g, r12: G } = T.estimateWindRadii(Y, q, A.lat);
2294
- W[d] = {
2295
- lat: A.lat,
2296
- lng: A.lon,
2297
- pressure: A.pressure,
2292
+ return p.forEach((O) => {
2293
+ const o = L.utc(O.forecastTime), q = o.diff(c, "hour"), d = Math.round(O.maxSP * 3600 / 1852), X = Math.round(O.maxSP * 3600 / 1852), Y = T.parseWindCircle(O.r7Ne / 1.852), f = T.parseWindCircle(O.r7Nw / 1.852), e = T.parseWindCircle(O.r7Sw / 1.852), r = T.parseWindCircle(O.r7Se / 1.852), N = T.parseWindCircle(O.r10Ne / 1.852), u = T.parseWindCircle(O.r10Nw / 1.852), B = T.parseWindCircle(O.r10Sw / 1.852), S = T.parseWindCircle(O.r10Se / 1.852), m = T.parseWindCircle(O.r12Ne / 1.852), Z = T.parseWindCircle(O.r12Nw / 1.852), P = T.parseWindCircle(O.r12Sw / 1.852), K = T.parseWindCircle(O.r12Se / 1.852), { r7: h, r10: H, r12: g } = T.estimateWindRadii(d, O.lat);
2294
+ W[q] = {
2295
+ lat: O.lat,
2296
+ lng: O.lon,
2297
+ pressure: O.pressure,
2298
2298
  utc: o.format(),
2299
2299
  wind: {
2300
- kts: isNaN(Y) ? null : Y || null,
2301
- type: T.parseTropicalType(Y),
2300
+ kts: isNaN(d) ? null : d || null,
2301
+ type: T.parseTropicalType(d),
2302
2302
  datetime: o.format(),
2303
- r7: H,
2304
- r7ne: f,
2305
- r7nw: e,
2306
- r7sw: r,
2307
- r7se: N,
2308
- r10: g,
2309
- r10ne: u,
2310
- r10nw: B,
2311
- r10sw: S,
2312
- r10se: m,
2313
- r12: G,
2314
- r12ne: l,
2315
- r12nw: P,
2316
- r12sw: K,
2317
- r12se: h
2303
+ r7: h,
2304
+ r7ne: Y,
2305
+ r7nw: f,
2306
+ r7sw: e,
2307
+ r7se: r,
2308
+ r10: H,
2309
+ r10ne: N,
2310
+ r10nw: u,
2311
+ r10sw: B,
2312
+ r10se: S,
2313
+ r12: g,
2314
+ r12ne: m,
2315
+ r12nw: Z,
2316
+ r12sw: P,
2317
+ r12se: K
2318
2318
  },
2319
2319
  gusts: {
2320
2320
  kts: isNaN(X) ? null : X || null
@@ -2335,15 +2335,15 @@ class j {
2335
2335
  cName: z == null ? void 0 : z.cName,
2336
2336
  lat: b == null ? void 0 : b.lat,
2337
2337
  lng: b == null ? void 0 : b.lon,
2338
- history: await j.parseHistory(M.historyPoint),
2339
- forecasts: await j.parseForecast(M.forecastSets)
2338
+ history: await x.parseHistory(M.historyPoint),
2339
+ forecasts: await x.parseForecast(M.forecastSets)
2340
2340
  };
2341
2341
  return await T.tropicalMovement(c), c;
2342
2342
  }
2343
2343
  static async realtimeForecast() {
2344
2344
  const M = "http://weather.ninecosmos.cn/jiufang/meteo/typhoon", z = await Q.get(M).json(), b = [];
2345
2345
  for (const p in z.data)
2346
- b.push(await j.parseTropical(z.data[p]));
2346
+ b.push(await x.parseTropical(z.data[p]));
2347
2347
  return b;
2348
2348
  }
2349
2349
  }
@@ -2355,44 +2355,44 @@ class T {
2355
2355
  * @param options
2356
2356
  */
2357
2357
  static async realtimeForecast(M = "", z = {}) {
2358
- return X0.info("[%s] try to fetch realtime tropicals forecast from %s", z.requestId, M), M === "windy" ? $.realtimeForecast() : M === "hifleet" ? b0.realtimeForecast() : M === "nio" ? j.realtimeForecast() : T.mergeTropicals(!0, !1, z);
2358
+ return X0.info("[%s] try to fetch realtime tropicals forecast from %s", z.requestId, M), M === "windy" ? j.realtimeForecast() : M === "hifleet" ? b0.realtimeForecast() : M === "nio" ? x.realtimeForecast() : T.mergeTropicals(!0, !1, z);
2359
2359
  }
2360
2360
  static async sortTropical(M) {
2361
2361
  var b;
2362
2362
  const z = Object.values(c0);
2363
2363
  return (b = M.forecasts) == null || b.sort((p, c) => {
2364
- var o, d;
2365
- const W = z.indexOf((o = p.model) == null ? void 0 : o.toUpperCase()), A = z.indexOf((d = c.model) == null ? void 0 : d.toUpperCase());
2366
- return (W === -1 ? 999 : W) - (A === -1 ? 999 : A);
2364
+ var o, q;
2365
+ const W = z.indexOf((o = p.model) == null ? void 0 : o.toUpperCase()), O = z.indexOf((q = c.model) == null ? void 0 : q.toUpperCase());
2366
+ return (W === -1 ? 999 : W) - (O === -1 ? 999 : O);
2367
2367
  }), M;
2368
2368
  }
2369
2369
  static async mergeTropicals(M = !0, z = !1, b = {}) {
2370
- var A, o, d;
2371
- const p = await $.realtimeForecast(), c = M ? await b0.realtimeForecast() : [], W = z ? await j.realtimeForecast() : [];
2372
- for (const Y of p) {
2370
+ var O, o, q;
2371
+ const p = await j.realtimeForecast(), c = M ? await b0.realtimeForecast() : [], W = z ? await x.realtimeForecast() : [];
2372
+ for (const d of p) {
2373
2373
  const X = c.find((e) => {
2374
2374
  var r, N;
2375
- return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N = Y.name) == null ? void 0 : N.toLowerCase());
2376
- }), q = W.find((e) => {
2375
+ return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N = d.name) == null ? void 0 : N.toLowerCase());
2376
+ }), Y = W.find((e) => {
2377
2377
  var r, N;
2378
- return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N = Y.name) == null ? void 0 : N.toLowerCase());
2378
+ return ((r = e.name) == null ? void 0 : r.toLowerCase()) === ((N = d.name) == null ? void 0 : N.toLowerCase());
2379
2379
  });
2380
- if (q) {
2381
- Y.history.sort((e, r) => L(r.updated).valueOf() - L(e.updated).valueOf());
2382
- for (const e of q.forecasts)
2383
- ["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((A = e.model) == null ? void 0 : A.toUpperCase()) && !Y.forecasts.find((r) => {
2380
+ if (Y) {
2381
+ d.history.sort((e, r) => L(r.updated).valueOf() - L(e.updated).valueOf());
2382
+ for (const e of Y.forecasts)
2383
+ ["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((O = e.model) == null ? void 0 : O.toUpperCase()) && !d.forecasts.find((r) => {
2384
2384
  var N, u;
2385
2385
  return ((N = r.model) == null ? void 0 : N.toLowerCase()) === ((u = e.model) == null ? void 0 : u.toLowerCase());
2386
- }) && Y.forecasts.push(e);
2386
+ }) && d.forecasts.push(e);
2387
2387
  }
2388
2388
  if (X) {
2389
- (o = X.history) != null && o.length && (Y.history = X.history), Y.history.sort((e, r) => L(r.updated).valueOf() - L(e.updated).valueOf());
2389
+ (o = X.history) != null && o.length && (d.history = X.history), d.history.sort((e, r) => L(r.updated).valueOf() - L(e.updated).valueOf());
2390
2390
  for (const e of X.forecasts)
2391
- ["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((d = e.model) == null ? void 0 : d.toUpperCase()) && !Y.forecasts.find((r) => r.model.toLowerCase() === e.model.toLowerCase()) && Y.forecasts.push(e);
2391
+ ["CMA", "JMA", "CNTW", "CNHK", "KMA"].includes((q = e.model) == null ? void 0 : q.toUpperCase()) && !d.forecasts.find((r) => r.model.toLowerCase() === e.model.toLowerCase()) && d.forecasts.push(e);
2392
2392
  }
2393
- Y.history = Y.history.reduce((e, r) => (e.find((N) => N.updated === r.updated) || e.push(r), e), []);
2394
- const f = Y.history[0];
2395
- f && Y.forecasts.forEach((e) => {
2393
+ d.history = d.history.reduce((e, r) => (e.find((N) => N.updated === r.updated) || e.push(r), e), []);
2394
+ const f = d.history[0];
2395
+ f && d.forecasts.forEach((e) => {
2396
2396
  e.date = f.updated;
2397
2397
  const r = L(f.updated), N = {};
2398
2398
  for (const u in e.hours) {
@@ -2400,13 +2400,13 @@ class T {
2400
2400
  S > 0 && (N[S] = B);
2401
2401
  }
2402
2402
  e.hours = N;
2403
- }), await T.tropicalMovement(Y);
2403
+ }), await T.tropicalMovement(d);
2404
2404
  }
2405
- for (const Y of c)
2405
+ for (const d of c)
2406
2406
  p.every((X) => {
2407
- var q, f;
2408
- return ((q = X.name) == null ? void 0 : q.toLowerCase()) !== ((f = Y.name) == null ? void 0 : f.toLowerCase());
2409
- }) && p.push(Y);
2407
+ var Y, f;
2408
+ return ((Y = X.name) == null ? void 0 : Y.toLowerCase()) !== ((f = d.name) == null ? void 0 : f.toLowerCase());
2409
+ }) && p.push(d);
2410
2410
  return p;
2411
2411
  }
2412
2412
  /**
@@ -2418,21 +2418,21 @@ class T {
2418
2418
  let z = null;
2419
2419
  M.forecasts.forEach((p) => {
2420
2420
  const c = p.hours, W = Object.keys(c);
2421
- for (let A = 0; A < W.length - 1; A++) {
2422
- const o = c[W[A]];
2421
+ for (let O = 0; O < W.length - 1; O++) {
2422
+ const o = c[W[O]];
2423
2423
  z = z || o;
2424
- const d = c[W[A + 1]];
2425
- o.movement = T.calculateMovement(o, d);
2426
- const Y = T.supplementWindRadii(o);
2427
- o.wind = { ...o.wind || {}, ...Y };
2424
+ const q = c[W[O + 1]];
2425
+ o.movement = T.calculateMovement(o, q);
2426
+ const d = T.supplementWindRadii(o);
2427
+ o.wind = { ...o.wind || {}, ...d };
2428
2428
  }
2429
2429
  });
2430
2430
  let b = null;
2431
2431
  for (let p = 0; p < M.history.length - 1; p++) {
2432
2432
  const c = M.history[p + 1], W = M.history[p];
2433
2433
  b = b || W, c.movement = T.calculateMovement(c, W);
2434
- const A = T.supplementWindRadii(c);
2435
- c.wind = { ...c.wind || {}, ...A };
2434
+ const O = T.supplementWindRadii(c);
2435
+ c.wind = { ...c.wind || {}, ...O };
2436
2436
  }
2437
2437
  if (b && z) {
2438
2438
  b.movement = T.calculateMovement(b, z);
@@ -2450,35 +2450,51 @@ class T {
2450
2450
  }
2451
2451
  /**
2452
2452
  * 估算最大风速半径 (RMW - Radius of Maximum Wind)
2453
- * @param kts 最大风速(节)
2454
- * @param pressure 中心气压(hPa)
2453
+ * @param ms 最大风速(m/s)
2455
2454
  * @param lat 纬度
2456
2455
  */
2457
- static estimateRMW(M, z, b) {
2458
- let p;
2459
- const c = Math.abs(b || 25);
2460
- if (z && z > 0) {
2461
- const W = 1013 - z;
2462
- p = 51.6 * Math.exp(-0.0223 * M + 0.0281 * c) * Math.pow(Math.max(W, 10) / 100, 0.155);
2463
- } else
2464
- p = 46.4 * Math.exp(-0.0155 * M + 0.0169 * c);
2465
- return Math.max(90 / 1.852, Math.min(150 / 1.852, p));
2456
+ static estimateRMW(M, z) {
2457
+ const b = Math.abs(z || 25), p = 51.6 * Math.exp(-0.0223 * M + 0.0281 * b);
2458
+ return Math.max(10, Math.min(150, p));
2459
+ }
2460
+ /**
2461
+ * 反映风速衰减快慢,由台风特性决定
2462
+ * @param vMax 最大风速(m/s)
2463
+ * @param rmw 最大风速半径(km)
2464
+ * @param lat 中心纬度
2465
+ */
2466
+ static estimateHollandB(M, z, b) {
2467
+ return 1.0036 + 0.0173 * M - 0.0312 * Math.log(z) + 87e-4 * b;
2468
+ }
2469
+ /**
2470
+ * 推算风圈半径
2471
+ * @param vTarget 目标风速 m/s
2472
+ * @param vMax 最大风速 m/s
2473
+ * @param rmw 最大风速半径(km)
2474
+ * @param b Holland形状参数B
2475
+ */
2476
+ static findWindRadius(M, z, b, p) {
2477
+ if (M >= z)
2478
+ return 0;
2479
+ let c = b, W = b * 10;
2480
+ for (; W - c > 0.1; ) {
2481
+ const O = (c + W) / 2, o = b / O, q = Math.pow(o, p) * Math.exp(1 - Math.pow(o, p));
2482
+ z * Math.sqrt(q) > M ? c = O : W = O;
2483
+ }
2484
+ return $.kmh2kts(c + W);
2466
2485
  }
2467
2486
  /**
2468
2487
  * 基于台风强度推算风圈基础半径的经验公式
2469
2488
  * @param kts 最大风速(节)
2470
- * @param pressure 中心气压(hPa)
2471
2489
  * @param lat 纬度
2472
2490
  * @returns 风圈半径对象
2473
2491
  */
2474
- static estimateWindRadii(M, z, b) {
2475
- if (!M || M < 32)
2476
- return { r7: null, r10: null, r12: null };
2477
- const p = T.estimateRMW(M, z, b), c = p * 2.5, W = M >= 50 ? p * 1.8 : null, A = M >= 64 ? p * 1.3 : null;
2492
+ static estimateWindRadii(M, z) {
2493
+ const b = $.kts2ms(M), p = T.estimateRMW(b, z), c = T.estimateHollandB(b, p, z), W = T.findWindRadius(17.2, b, p, c), O = T.findWindRadius(28.5, b, p, c), o = T.findWindRadius(37, b, p, c);
2478
2494
  return {
2479
- r7: Math.round(c),
2480
- r10: W ? Math.round(W) : null,
2481
- r12: A ? Math.round(A) : null
2495
+ r7: W ? Math.round(W) : null,
2496
+ r10: O ? Math.round(O) : null,
2497
+ r12: o ? Math.round(o) : null
2482
2498
  };
2483
2499
  }
2484
2500
  /**
@@ -2494,20 +2510,20 @@ class T {
2494
2510
  return { ne: null, nw: null, se: null, sw: null };
2495
2511
  if (z < 9)
2496
2512
  return { ne: M, nw: M, se: M, sw: M };
2497
- const W = 0.15 * Math.min(z / (20 / 1.852), 1), A = {
2513
+ const W = 0.15 * Math.min(z / (20 / 1.852), 1), O = {
2498
2514
  ne: (45 - b + 360) % 360,
2499
2515
  nw: (315 - b + 360) % 360,
2500
2516
  se: (135 - b + 360) % 360,
2501
2517
  sw: (225 - b + 360) % 360
2502
- }, o = (d) => {
2503
- const Y = d > 180 ? d - 360 : d, X = Math.cos(Y * Math.PI / 180);
2518
+ }, o = (q) => {
2519
+ const d = q > 180 ? q - 360 : q, X = Math.cos(d * Math.PI / 180);
2504
2520
  return 1 - W * X;
2505
2521
  };
2506
2522
  return {
2507
- ne: Math.round(M * o(A.ne)),
2508
- nw: Math.round(M * o(A.nw)),
2509
- se: Math.round(M * o(A.se)),
2510
- sw: Math.round(M * o(A.sw))
2523
+ ne: Math.round(M * o(O.ne)),
2524
+ nw: Math.round(M * o(O.nw)),
2525
+ se: Math.round(M * o(O.se)),
2526
+ sw: Math.round(M * o(O.sw))
2511
2527
  };
2512
2528
  }
2513
2529
  /**
@@ -2515,14 +2531,14 @@ class T {
2515
2531
  * @param position 预报点数据
2516
2532
  */
2517
2533
  static supplementWindRadii(M) {
2518
- const { wind: z, pressure: b, lat: p, movement: c } = M;
2534
+ const { wind: z, lat: b, movement: p } = M;
2519
2535
  if (z.r7) {
2520
- for (const Y of Object.keys(z))
2521
- /^r[7,10,12]/.test(Y) && (isNaN(Number(z[Y])) || z[Y] < 0) && (z[Y] = null);
2536
+ for (const q of Object.keys(z))
2537
+ /^r[7,10,12]/.test(q) && (isNaN(Number(z[q])) || z[q] < 0) && (z[q] = null);
2522
2538
  return z;
2523
2539
  }
2524
- const W = z.kts;
2525
- if (!W || W < 17)
2540
+ const c = z.kts;
2541
+ if (!c || c < 17)
2526
2542
  return {
2527
2543
  r7: null,
2528
2544
  r7ne: null,
@@ -2540,16 +2556,16 @@ class T {
2540
2556
  r12se: null,
2541
2557
  r12sw: null
2542
2558
  };
2543
- const A = T.estimateWindRadii(W, b, p), o = {};
2544
- return ["r7", "r10", "r12"].forEach((Y) => {
2545
- const X = A[Y];
2546
- if (X) {
2547
- o[Y] = X;
2548
- const q = T.estimateAsymmetricRadii(X, (c == null ? void 0 : c.kts) || 0, (c == null ? void 0 : c.deg) || 0, p > 0 ? "N" : "S");
2549
- o[`${Y}ne`] = q.ne, o[`${Y}nw`] = q.nw, o[`${Y}se`] = q.se, o[`${Y}sw`] = q.sw;
2559
+ const W = T.estimateWindRadii(c, b), O = {};
2560
+ return ["r7", "r10", "r12"].forEach((q) => {
2561
+ const d = W[q];
2562
+ if (d) {
2563
+ O[q] = d;
2564
+ const X = T.estimateAsymmetricRadii(d, (p == null ? void 0 : p.kts) || 0, (p == null ? void 0 : p.deg) || 0, b > 0 ? "N" : "S");
2565
+ O[`${q}ne`] = X.ne, O[`${q}nw`] = X.nw, O[`${q}se`] = X.se, O[`${q}sw`] = X.sw;
2550
2566
  } else
2551
- o[Y] = null, o[`${Y}ne`] = null, o[`${Y}nw`] = null, o[`${Y}se`] = null, o[`${Y}sw`] = null;
2552
- }), o;
2567
+ O[q] = null, O[`${q}ne`] = null, O[`${q}nw`] = null, O[`${q}se`] = null, O[`${q}sw`] = null;
2568
+ }), O;
2553
2569
  }
2554
2570
  /**
2555
2571
  * 台风类型
@@ -2573,8 +2589,8 @@ class T {
2573
2589
  }
2574
2590
  export {
2575
2591
  Q0 as MeteoHelper,
2576
- J0 as MeteoHelper2,
2577
- k0 as TidesHelper,
2592
+ k0 as MeteoHelper2,
2593
+ J0 as TidesHelper,
2578
2594
  T as TropicalHelper,
2579
2595
  c0 as TropicalModel,
2580
2596
  U0 as WindyModel