@idm-plugin/geo 2.1.3 → 2.1.4

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
@@ -18,36 +18,36 @@ var _ = { exports: {} };
18
18
  M.version === void 0 && M.default && (M = M.default);
19
19
  var z = "0.5.48", p = {}, b = {}, c = {}, O = {}, A = {}, W;
20
20
  (!M || typeof M.version != "string") && D("Moment Timezone requires Moment.js. See https://momentjs.com/timezone/docs/#/use-it/browser/");
21
- var o = M.version.split("."), Y = +o[0], d = +o[1];
22
- (Y < 2 || Y === 2 && d < 6) && D("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
23
- function R(q) {
24
- return q > 96 ? q - 87 : q > 64 ? q - 29 : q - 48;
21
+ var q = M.version.split("."), d = +q[0], Y = +q[1];
22
+ (d < 2 || d === 2 && Y < 6) && D("Moment Timezone requires Moment.js >= 2.6.0. You are using Moment.js " + M.version + ". See momentjs.com");
23
+ function R(o) {
24
+ return o > 96 ? o - 87 : o > 64 ? o - 29 : o - 48;
25
25
  }
26
- function T(q) {
27
- var n = 0, X = q.split("."), L = X[0], N = X[1] || "", V = 1, E, s = 0, P = 1;
28
- for (q.charCodeAt(0) === 45 && (n = 1, P = -1), n; n < L.length; n++)
26
+ function T(o) {
27
+ var n = 0, X = o.split("."), L = X[0], N = X[1] || "", V = 1, E, s = 0, P = 1;
28
+ for (o.charCodeAt(0) === 45 && (n = 1, P = -1), n; n < L.length; n++)
29
29
  E = R(L.charCodeAt(n)), s = 60 * s + E;
30
30
  for (n = 0; n < N.length; n++)
31
31
  V = V / 60, E = R(N.charCodeAt(n)), s += E * V;
32
32
  return s * P;
33
33
  }
34
- function e(q) {
35
- for (var n = 0; n < q.length; n++)
36
- q[n] = T(q[n]);
34
+ function e(o) {
35
+ for (var n = 0; n < o.length; n++)
36
+ o[n] = T(o[n]);
37
37
  }
38
- function f(q, n) {
38
+ function f(o, n) {
39
39
  for (var X = 0; X < n; X++)
40
- q[X] = Math.round((q[X - 1] || 0) + q[X] * 6e4);
41
- q[n - 1] = 1 / 0;
40
+ o[X] = Math.round((o[X - 1] || 0) + o[X] * 6e4);
41
+ o[n - 1] = 1 / 0;
42
42
  }
43
- function i(q, n) {
43
+ function i(o, n) {
44
44
  var X = [], L;
45
45
  for (L = 0; L < n.length; L++)
46
- X[L] = q[n[L]];
46
+ X[L] = o[n[L]];
47
47
  return X;
48
48
  }
49
- function S(q) {
50
- var n = q.split("|"), X = n[2].split(" "), L = n[3].split(""), N = n[4].split(" ");
49
+ function S(o) {
50
+ var n = o.split("|"), X = n[2].split(" "), L = n[3].split(""), N = n[4].split(" ");
51
51
  return e(X), e(L), e(N), f(N, L.length), {
52
52
  name: n[0],
53
53
  abbrs: i(n[1].split(" "), L),
@@ -56,91 +56,91 @@ var _ = { exports: {} };
56
56
  population: n[5] | 0
57
57
  };
58
58
  }
59
- function u(q) {
60
- q && this._set(S(q));
59
+ function u(o) {
60
+ o && this._set(S(o));
61
61
  }
62
- function Z(q, n) {
62
+ function Z(o, n) {
63
63
  var X = n.length;
64
- if (q < n[0])
64
+ if (o < n[0])
65
65
  return 0;
66
- if (X > 1 && n[X - 1] === 1 / 0 && q >= n[X - 2])
66
+ if (X > 1 && n[X - 1] === 1 / 0 && o >= n[X - 2])
67
67
  return X - 1;
68
- if (q >= n[X - 1])
68
+ if (o >= n[X - 1])
69
69
  return -1;
70
70
  for (var L, N = 0, V = X - 1; V - N > 1; )
71
- L = Math.floor((N + V) / 2), n[L] <= q ? N = L : V = L;
71
+ L = Math.floor((N + V) / 2), n[L] <= o ? N = L : V = L;
72
72
  return V;
73
73
  }
74
74
  u.prototype = {
75
- _set: function(q) {
76
- this.name = q.name, this.abbrs = q.abbrs, this.untils = q.untils, this.offsets = q.offsets, this.population = q.population;
75
+ _set: function(o) {
76
+ this.name = o.name, this.abbrs = o.abbrs, this.untils = o.untils, this.offsets = o.offsets, this.population = o.population;
77
77
  },
78
- _index: function(q) {
79
- var n = +q, X = this.untils, L;
78
+ _index: function(o) {
79
+ var n = +o, X = this.untils, L;
80
80
  if (L = Z(n, X), L >= 0)
81
81
  return L;
82
82
  },
83
83
  countries: function() {
84
- var q = this.name;
84
+ var o = this.name;
85
85
  return Object.keys(c).filter(function(n) {
86
- return c[n].zones.indexOf(q) !== -1;
86
+ return c[n].zones.indexOf(o) !== -1;
87
87
  });
88
88
  },
89
- parse: function(q) {
90
- var n = +q, X = this.offsets, L = this.untils, N = L.length - 1, V, E, s, P;
89
+ parse: function(o) {
90
+ var n = +o, X = this.offsets, L = this.untils, N = L.length - 1, V, E, s, P;
91
91
  for (P = 0; P < N; P++)
92
92
  if (V = X[P], E = X[P + 1], s = X[P && P - 1], V < E && l.moveAmbiguousForward ? V = E : V > s && l.moveInvalidForward && (V = s), n < L[P] - V * 6e4)
93
93
  return X[P];
94
94
  return X[N];
95
95
  },
96
- abbr: function(q) {
97
- return this.abbrs[this._index(q)];
96
+ abbr: function(o) {
97
+ return this.abbrs[this._index(o)];
98
98
  },
99
- offset: function(q) {
100
- return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(q)];
99
+ offset: function(o) {
100
+ return D("zone.offset has been deprecated in favor of zone.utcOffset"), this.offsets[this._index(o)];
101
101
  },
102
- utcOffset: function(q) {
103
- return this.offsets[this._index(q)];
102
+ utcOffset: function(o) {
103
+ return this.offsets[this._index(o)];
104
104
  }
105
105
  };
106
- function B(q, n) {
107
- this.name = q, this.zones = n;
106
+ function B(o, n) {
107
+ this.name = o, this.zones = n;
108
108
  }
109
- function G(q) {
110
- var n = q.toTimeString(), X = n.match(/\([a-z ]+\)/i);
111
- X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = n.match(/[A-Z]{3,5}/g), X = X ? X[0] : void 0), X === "GMT" && (X = void 0), this.at = +q, this.abbr = X, this.offset = q.getTimezoneOffset();
109
+ function G(o) {
110
+ var n = o.toTimeString(), X = n.match(/\([a-z ]+\)/i);
111
+ X && X[0] ? (X = X[0].match(/[A-Z]/g), X = X ? X.join("") : void 0) : (X = n.match(/[A-Z]{3,5}/g), X = X ? X[0] : void 0), X === "GMT" && (X = void 0), this.at = +o, this.abbr = X, this.offset = o.getTimezoneOffset();
112
112
  }
113
- function Q(q) {
114
- this.zone = q, this.offsetScore = 0, this.abbrScore = 0;
113
+ function Q(o) {
114
+ this.zone = o, this.offsetScore = 0, this.abbrScore = 0;
115
115
  }
116
- Q.prototype.scoreOffsetAt = function(q) {
117
- this.offsetScore += Math.abs(this.zone.utcOffset(q.at) - q.offset), this.zone.abbr(q.at).replace(/[^A-Z]/g, "") !== q.abbr && this.abbrScore++;
116
+ Q.prototype.scoreOffsetAt = function(o) {
117
+ this.offsetScore += Math.abs(this.zone.utcOffset(o.at) - o.offset), this.zone.abbr(o.at).replace(/[^A-Z]/g, "") !== o.abbr && this.abbrScore++;
118
118
  };
119
- function F(q, n) {
120
- for (var X, L; L = ((n.at - q.at) / 12e4 | 0) * 6e4; )
121
- X = new G(new Date(q.at + L)), X.offset === q.offset ? q = X : n = X;
122
- return q;
119
+ function F(o, n) {
120
+ for (var X, L; L = ((n.at - o.at) / 12e4 | 0) * 6e4; )
121
+ X = new G(new Date(o.at + L)), X.offset === o.offset ? o = X : n = X;
122
+ return o;
123
123
  }
124
124
  function $() {
125
- var q = (/* @__PURE__ */ new Date()).getFullYear() - 2, n = new G(new Date(q, 0, 1)), X = n.offset, L = [n], N, V, E, s;
125
+ var o = (/* @__PURE__ */ new Date()).getFullYear() - 2, n = new G(new Date(o, 0, 1)), X = n.offset, L = [n], N, V, E, s;
126
126
  for (s = 1; s < 48; s++)
127
- E = new Date(q, s, 1).getTimezoneOffset(), E !== X && (V = new G(new Date(q, s, 1)), N = F(n, V), L.push(N), L.push(new G(new Date(N.at + 6e4))), n = V, X = E);
127
+ E = new Date(o, s, 1).getTimezoneOffset(), E !== X && (V = new G(new Date(o, s, 1)), N = F(n, V), L.push(N), L.push(new G(new Date(N.at + 6e4))), n = V, X = E);
128
128
  for (s = 0; s < 4; s++)
129
- L.push(new G(new Date(q + s, 0, 1))), L.push(new G(new Date(q + s, 6, 1)));
129
+ L.push(new G(new Date(o + s, 0, 1))), L.push(new G(new Date(o + s, 6, 1)));
130
130
  return L;
131
131
  }
132
- function z0(q, n) {
133
- return q.offsetScore !== n.offsetScore ? q.offsetScore - n.offsetScore : q.abbrScore !== n.abbrScore ? q.abbrScore - n.abbrScore : q.zone.population !== n.zone.population ? n.zone.population - q.zone.population : n.zone.name.localeCompare(q.zone.name);
132
+ function z0(o, n) {
133
+ return o.offsetScore !== n.offsetScore ? o.offsetScore - n.offsetScore : o.abbrScore !== n.abbrScore ? o.abbrScore - n.abbrScore : o.zone.population !== n.zone.population ? n.zone.population - o.zone.population : n.zone.name.localeCompare(o.zone.name);
134
134
  }
135
- function b0(q, n) {
135
+ function b0(o, n) {
136
136
  var X, L;
137
137
  for (e(n), X = 0; X < n.length; X++)
138
- L = n[X], A[L] = A[L] || {}, A[L][q] = !0;
138
+ L = n[X], A[L] = A[L] || {}, A[L][o] = !0;
139
139
  }
140
- function p0(q) {
141
- var n = q.length, X = {}, L = [], N = {}, V, E, s, P;
140
+ function p0(o) {
141
+ var n = o.length, X = {}, L = [], N = {}, V, E, s, P;
142
142
  for (V = 0; V < n; V++)
143
- if (s = q[V].offset, !N.hasOwnProperty(s)) {
143
+ if (s = o[V].offset, !N.hasOwnProperty(s)) {
144
144
  P = A[s] || {};
145
145
  for (E in P)
146
146
  P.hasOwnProperty(E) && (X[E] = !0);
@@ -152,12 +152,12 @@ var _ = { exports: {} };
152
152
  }
153
153
  function O0() {
154
154
  try {
155
- var q = Intl.DateTimeFormat().resolvedOptions().timeZone;
156
- if (q && q.length > 3) {
157
- var n = O[h(q)];
155
+ var o = Intl.DateTimeFormat().resolvedOptions().timeZone;
156
+ if (o && o.length > 3) {
157
+ var n = O[h(o)];
158
158
  if (n)
159
159
  return n;
160
- D("Moment Timezone found " + q + " from the Intl api, but did not have that data loaded.");
160
+ D("Moment Timezone found " + o + " from the Intl api, but did not have that data loaded.");
161
161
  }
162
162
  } catch {
163
163
  }
@@ -169,52 +169,52 @@ var _ = { exports: {} };
169
169
  }
170
170
  return V.sort(z0), V.length > 0 ? V[0].zone.name : void 0;
171
171
  }
172
- function A0(q) {
173
- return (!W || q) && (W = O0()), W;
172
+ function A0(o) {
173
+ return (!W || o) && (W = O0()), W;
174
174
  }
175
- function h(q) {
176
- return (q || "").toLowerCase().replace(/\//g, "_");
175
+ function h(o) {
176
+ return (o || "").toLowerCase().replace(/\//g, "_");
177
177
  }
178
- function k(q) {
178
+ function k(o) {
179
179
  var n, X, L, N;
180
- for (typeof q == "string" && (q = [q]), n = 0; n < q.length; n++)
181
- L = q[n].split("|"), X = L[0], N = h(X), p[N] = q[n], O[N] = X, b0(N, L[2].split(" "));
180
+ for (typeof o == "string" && (o = [o]), n = 0; n < o.length; n++)
181
+ L = o[n].split("|"), X = L[0], N = h(X), p[N] = o[n], O[N] = X, b0(N, L[2].split(" "));
182
182
  }
183
- function g(q, n) {
184
- q = h(q);
185
- var X = p[q], L;
186
- return X instanceof u ? X : typeof X == "string" ? (X = new u(X), p[q] = X, X) : b[q] && n !== g && (L = g(b[q], g)) ? (X = p[q] = new u(), X._set(L), X.name = O[q], X) : null;
183
+ function g(o, n) {
184
+ o = h(o);
185
+ var X = p[o], L;
186
+ return X instanceof u ? X : typeof X == "string" ? (X = new u(X), p[o] = X, X) : b[o] && n !== g && (L = g(b[o], g)) ? (X = p[o] = new u(), X._set(L), X.name = O[o], X) : null;
187
187
  }
188
188
  function c0() {
189
- var q, n = [];
190
- for (q in O)
191
- O.hasOwnProperty(q) && (p[q] || p[b[q]]) && O[q] && n.push(O[q]);
189
+ var o, n = [];
190
+ for (o in O)
191
+ O.hasOwnProperty(o) && (p[o] || p[b[o]]) && O[o] && n.push(O[o]);
192
192
  return n.sort();
193
193
  }
194
194
  function W0() {
195
195
  return Object.keys(c);
196
196
  }
197
- function y(q) {
197
+ function y(o) {
198
198
  var n, X, L, N;
199
- for (typeof q == "string" && (q = [q]), n = 0; n < q.length; n++)
200
- X = q[n].split("|"), L = h(X[0]), N = h(X[1]), b[L] = N, O[L] = X[0], b[N] = L, O[N] = X[1];
199
+ for (typeof o == "string" && (o = [o]), n = 0; n < o.length; n++)
200
+ X = o[n].split("|"), L = h(X[0]), N = h(X[1]), b[L] = N, O[L] = X[0], b[N] = L, O[N] = X[1];
201
201
  }
202
- function o0(q) {
202
+ function o0(o) {
203
203
  var n, X, L, N;
204
- if (!(!q || !q.length))
205
- for (n = 0; n < q.length; n++)
206
- N = q[n].split("|"), X = N[0].toUpperCase(), L = N[1].split(" "), c[X] = new B(
204
+ if (!(!o || !o.length))
205
+ for (n = 0; n < o.length; n++)
206
+ N = o[n].split("|"), X = N[0].toUpperCase(), L = N[1].split(" "), c[X] = new B(
207
207
  X,
208
208
  L
209
209
  );
210
210
  }
211
- function q0(q) {
212
- return q = q.toUpperCase(), c[q] || null;
211
+ function q0(o) {
212
+ return o = o.toUpperCase(), c[o] || null;
213
213
  }
214
- function Y0(q, n) {
215
- if (q = q0(q), !q)
214
+ function Y0(o, n) {
215
+ if (o = q0(o), !o)
216
216
  return null;
217
- var X = q.zones.sort();
217
+ var X = o.zones.sort();
218
218
  return n ? X.map(function(L) {
219
219
  var N = g(L);
220
220
  return {
@@ -223,59 +223,59 @@ var _ = { exports: {} };
223
223
  };
224
224
  }) : X;
225
225
  }
226
- function d0(q) {
227
- k(q.zones), y(q.links), o0(q.countries), l.dataVersion = q.version;
226
+ function d0(o) {
227
+ k(o.zones), y(o.links), o0(o.countries), l.dataVersion = o.version;
228
228
  }
229
- function J(q) {
230
- return J.didShowError || (J.didShowError = !0, D("moment.tz.zoneExists('" + q + "') has been deprecated in favor of !moment.tz.zone('" + q + "')")), !!g(q);
229
+ function J(o) {
230
+ return J.didShowError || (J.didShowError = !0, D("moment.tz.zoneExists('" + o + "') has been deprecated in favor of !moment.tz.zone('" + o + "')")), !!g(o);
231
231
  }
232
- function v(q) {
233
- var n = q._f === "X" || q._f === "x";
234
- return !!(q._a && q._tzm === void 0 && !n);
232
+ function v(o) {
233
+ var n = o._f === "X" || o._f === "x";
234
+ return !!(o._a && o._tzm === void 0 && !n);
235
235
  }
236
- function D(q) {
237
- typeof console < "u" && typeof console.error == "function" && console.error(q);
236
+ function D(o) {
237
+ typeof console < "u" && typeof console.error == "function" && console.error(o);
238
238
  }
239
- function l(q) {
239
+ function l(o) {
240
240
  var n = Array.prototype.slice.call(arguments, 0, -1), X = arguments[arguments.length - 1], L = M.utc.apply(null, n), N;
241
- return !M.isMoment(q) && v(L) && (N = g(X)) && L.add(N.parse(L), "minutes"), L.tz(X), L;
241
+ return !M.isMoment(o) && v(L) && (N = g(X)) && L.add(N.parse(L), "minutes"), L.tz(X), L;
242
242
  }
243
243
  l.version = z, l.dataVersion = "", l._zones = p, l._links = b, l._names = O, l._countries = c, l.add = k, l.link = y, l.load = d0, l.zone = g, l.zoneExists = J, l.guess = A0, l.names = c0, l.Zone = u, l.unpack = S, l.unpackBase60 = T, l.needsOffset = v, l.moveInvalidForward = !0, l.moveAmbiguousForward = !1, l.countries = W0, l.zonesForCountry = Y0;
244
244
  var C = M.fn;
245
- M.tz = l, M.defaultZone = null, M.updateOffset = function(q, n) {
245
+ M.tz = l, M.defaultZone = null, M.updateOffset = function(o, n) {
246
246
  var X = M.defaultZone, L;
247
- if (q._z === void 0 && (X && v(q) && !q._isUTC && q.isValid() && (q._d = M.utc(q._a)._d, q.utc().add(X.parse(q), "minutes")), q._z = X), q._z)
248
- if (L = q._z.utcOffset(q), Math.abs(L) < 16 && (L = L / 60), q.utcOffset !== void 0) {
249
- var N = q._z;
250
- q.utcOffset(-L, n), q._z = N;
247
+ if (o._z === void 0 && (X && v(o) && !o._isUTC && o.isValid() && (o._d = M.utc(o._a)._d, o.utc().add(X.parse(o), "minutes")), o._z = X), o._z)
248
+ if (L = o._z.utcOffset(o), Math.abs(L) < 16 && (L = L / 60), o.utcOffset !== void 0) {
249
+ var N = o._z;
250
+ o.utcOffset(-L, n), o._z = N;
251
251
  } else
252
- q.zone(L, n);
253
- }, C.tz = function(q, n) {
254
- if (q) {
255
- if (typeof q != "string")
256
- throw new Error("Time zone name must be a string, got " + q + " [" + typeof q + "]");
257
- return this._z = g(q), this._z ? M.updateOffset(this, n) : D("Moment Timezone has no data for " + q + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
252
+ o.zone(L, n);
253
+ }, C.tz = function(o, n) {
254
+ if (o) {
255
+ if (typeof o != "string")
256
+ throw new Error("Time zone name must be a string, got " + o + " [" + typeof o + "]");
257
+ return this._z = g(o), this._z ? M.updateOffset(this, n) : D("Moment Timezone has no data for " + o + ". See http://momentjs.com/timezone/docs/#/data-loading/."), this;
258
258
  }
259
259
  if (this._z)
260
260
  return this._z.name;
261
261
  };
262
- function w(q) {
262
+ function w(o) {
263
263
  return function() {
264
- return this._z ? this._z.abbr(this) : q.call(this);
264
+ return this._z ? this._z.abbr(this) : o.call(this);
265
265
  };
266
266
  }
267
- function x(q) {
267
+ function x(o) {
268
268
  return function() {
269
- return this._z = null, q.apply(this, arguments);
269
+ return this._z = null, o.apply(this, arguments);
270
270
  };
271
271
  }
272
- function a0(q) {
272
+ function a0(o) {
273
273
  return function() {
274
- return arguments.length > 0 && (this._z = null), q.apply(this, arguments);
274
+ return arguments.length > 0 && (this._z = null), o.apply(this, arguments);
275
275
  };
276
276
  }
277
- C.zoneName = w(C.zoneName), C.zoneAbbr = w(C.zoneAbbr), C.utc = x(C.utc), C.local = x(C.local), C.utcOffset = a0(C.utcOffset), M.tz.setDefault = function(q) {
278
- return (Y < 2 || Y === 2 && d < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = q ? g(q) : null, M;
277
+ C.zoneName = w(C.zoneName), C.zoneAbbr = w(C.zoneAbbr), C.utc = x(C.utc), C.local = x(C.local), C.utcOffset = a0(C.utcOffset), M.tz.setDefault = function(o) {
278
+ return (d < 2 || d === 2 && Y < 9) && D("Moment Timezone setDefault() requires Moment.js >= 2.9.0. You are using Moment.js " + M.version + "."), M.defaultZone = o ? g(o) : null, M;
279
279
  };
280
280
  var K = M.momentProperties;
281
281
  return Object.prototype.toString.call(K) === "[object Array]" ? (K.push("_z"), K.push("_a")) : K && (K._z = null), M;
@@ -1145,10 +1145,10 @@ var M0 = { exports: {} };
1145
1145
  throw new RangeError("invalid coordinates");
1146
1146
  if (90 <= z)
1147
1147
  return "Etc/GMT";
1148
- var O = -1, A = 48 * (180 + p) / 360.00000000000006, W = 24 * (90 - z) / 180.00000000000003, o = 0 | A, Y = 0 | W, d = 96 * Y + 2 * o;
1149
- for (d = 56 * b.charCodeAt(d) + b.charCodeAt(d + 1) - 1995; d + c.length < 3136; )
1150
- d = 56 * b.charCodeAt(d = 8 * (O = O + d + 1) + 4 * (Y = 0 | (W = 2 * (W - Y) % 2)) + 2 * (o = 0 | (A = 2 * (A - o) % 2)) + 2304) + b.charCodeAt(d + 1) - 1995;
1151
- return c[d + c.length - 3136];
1148
+ var O = -1, A = 48 * (180 + p) / 360.00000000000006, W = 24 * (90 - z) / 180.00000000000003, q = 0 | A, d = 0 | W, Y = 96 * d + 2 * q;
1149
+ for (Y = 56 * b.charCodeAt(Y) + b.charCodeAt(Y + 1) - 1995; Y + c.length < 3136; )
1150
+ Y = 56 * b.charCodeAt(Y = 8 * (O = O + Y + 1) + 4 * (d = 0 | (W = 2 * (W - d) % 2)) + 2 * (q = 0 | (A = 2 * (A - q) % 2)) + 2304) + b.charCodeAt(Y + 1) - 1995;
1151
+ return c[Y + c.length - 3136];
1152
1152
  }
1153
1153
  m.exports = M;
1154
1154
  })(M0);
@@ -1183,18 +1183,18 @@ class a {
1183
1183
  M = a.convertToStdLng(M, z);
1184
1184
  let b = "E";
1185
1185
  M < 0 && (b = "W"), M = Math.abs(M), p = p.toUpperCase();
1186
- let c = M * 3600, O, A, W, o, Y, d;
1187
- O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? o = a.roundPrecision(W, z).toString().padStart(2, "0") : o = a.padNumber(W, 2, 3), c = c - W * 60), Y = c / 3600, p.indexOf("M") !== -1 ? d = a.roundPrecision(Y, z).toString().padStart(3, "0") : d = a.padNumber(Y, 3, 6), Number(A) >= 60 && (o = Number(o) + 1, A = 0), Number(o) >= 60 && (d = Number(d) + 1, o = 0);
1188
- const R = `${p.replace(/S+/gi, A).replace(/M+/gi, o).replace(/H+/gi, d)}${b}`;
1186
+ let c = M * 3600, O, A, W, q, d, Y;
1187
+ O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? q = a.roundPrecision(W, z).toString().padStart(2, "0") : q = a.padNumber(W, 2, 3), c = c - W * 60), d = c / 3600, p.indexOf("M") !== -1 ? Y = a.roundPrecision(d, z).toString().padStart(3, "0") : Y = a.padNumber(d, 3, 6), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (Y = Number(Y) + 1, q = 0);
1188
+ const R = `${p.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, Y)}${b}`;
1189
1189
  return {
1190
1190
  direction: b,
1191
- degree: a.roundPrecision(Y, z),
1191
+ degree: a.roundPrecision(d, z),
1192
1192
  minute: a.roundPrecision(W, z),
1193
1193
  second: a.roundPrecision(O, z),
1194
1194
  pretty: R,
1195
1195
  S: A,
1196
- M: o,
1197
- H: d
1196
+ M: q,
1197
+ H: Y
1198
1198
  };
1199
1199
  }
1200
1200
  /**
@@ -1207,18 +1207,18 @@ class a {
1207
1207
  M = M % 180;
1208
1208
  let b = "N";
1209
1209
  M < 0 && (b = "S"), M = Math.abs(M), p = p.toUpperCase();
1210
- let c = M * 3600, O, A, W, o, Y, d;
1211
- O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? o = a.roundPrecision(W, z).toString().padStart(2, "0") : o = a.padNumber(W, 2, 3), c = c - W * 60), Y = c / 3600, p.indexOf("M") !== -1 ? d = a.roundPrecision(Y, z).toString().padStart(2, "0") : d = a.padNumber(Y, 2, 6), Number(A) >= 60 && (o = Number(o) + 1, A = 0), Number(o) >= 60 && (d = Number(d) + 1, o = 0);
1212
- const R = `${p.replace(/S+/gi, A).replace(/M+/gi, o).replace(/H+/gi, d)}${b}`;
1210
+ let c = M * 3600, O, A, W, q, d, Y;
1211
+ O = c % 3600 % 60, p.indexOf("S") !== -1 && (c = c - O, A = a.padNumber(O, 2, 2)), W = c / 60 % 60, p.indexOf("M") !== -1 && (p.indexOf("S") !== -1 ? q = a.roundPrecision(W, z).toString().padStart(2, "0") : q = a.padNumber(W, 2, 3), c = c - W * 60), d = c / 3600, p.indexOf("M") !== -1 ? Y = a.roundPrecision(d, z).toString().padStart(2, "0") : Y = a.padNumber(d, 2, 6), Number(A) >= 60 && (q = Number(q) + 1, A = 0), Number(q) >= 60 && (Y = Number(Y) + 1, q = 0);
1212
+ const R = `${p.replace(/S+/gi, A).replace(/M+/gi, q).replace(/H+/gi, Y)}${b}`;
1213
1213
  return {
1214
1214
  direction: b,
1215
- degree: a.roundPrecision(Y, z),
1215
+ degree: a.roundPrecision(d, z),
1216
1216
  minute: a.roundPrecision(W, z),
1217
1217
  second: a.roundPrecision(O, z),
1218
1218
  pretty: R,
1219
1219
  S: A,
1220
- M: o,
1221
- H: d
1220
+ M: q,
1221
+ H: Y
1222
1222
  };
1223
1223
  }
1224
1224
  static str2Lng(M, z = 6) {
@@ -1227,11 +1227,11 @@ class a {
1227
1227
  M = a.strReplace(M, "LNG");
1228
1228
  const b = M[M.length - 1].toUpperCase();
1229
1229
  M = M.substring(0, M.length - 1).trim();
1230
- const c = M.split(" ").filter((o) => o !== "").map((o) => Math.abs(Number(o)));
1230
+ const c = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
1231
1231
  let [O, A, W] = c;
1232
1232
  if (A = A || 0, A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, W = W || 0, W = W > 60 ? W / Math.pow(10, String(W).length - 2) : W, O > 360 && !A) {
1233
- const o = this.roundPrecision(O / 100, 0);
1234
- A = O - o * 100, O = o;
1233
+ const q = this.roundPrecision(O / 100, 0);
1234
+ A = O - q * 100, O = q;
1235
1235
  }
1236
1236
  p = O + A / 60 + W / 3600, b === "W" && (p = p * -1);
1237
1237
  } else
@@ -1244,11 +1244,11 @@ class a {
1244
1244
  M = a.strReplace(M, "LAT");
1245
1245
  const b = M[M.length - 1].toUpperCase();
1246
1246
  M = M.substring(0, M.length - 1).trim();
1247
- const c = M.split(" ").filter((o) => o !== "").map((o) => Math.abs(Number(o)));
1247
+ const c = M.split(" ").filter((q) => q !== "").map((q) => Math.abs(Number(q)));
1248
1248
  let [O, A, W] = c;
1249
1249
  if (W = W || 0, A = A || 0, A = A > 60 ? A / Math.pow(10, String(A).length - 2) : A, W = W > 60 ? W / Math.pow(10, String(W).length - 2) : W, O > 90 && !A) {
1250
- const o = this.roundPrecision(O / 100, 0);
1251
- A = O - o * 100, O = o;
1250
+ const q = this.roundPrecision(O / 100, 0);
1251
+ A = O - q * 100, O = q;
1252
1252
  }
1253
1253
  if (p = O + A / 60 + W / 3600, p > 90)
1254
1254
  throw new Error(`latitude out of range: ${M}${b}`);
@@ -1320,7 +1320,7 @@ class t0 {
1320
1320
  return `${M.lat}|${M.lng}|${M.positionTime}|${M.sog}|${M.cog}|${M.hdg}|${M.draught}|${z}|${JSON.stringify(M.meteo || {})}|${M.vendor}|${M.deleted}`;
1321
1321
  }
1322
1322
  static str2Json(M) {
1323
- const [z, p, b, c, O, A, W, o, Y, d, R] = M.split("|");
1323
+ const [z, p, b, c, O, A, W, q, d, Y, R] = M.split("|");
1324
1324
  return {
1325
1325
  lat: Number(z),
1326
1326
  lng: Number(p),
@@ -1330,35 +1330,35 @@ class t0 {
1330
1330
  hdg: Number(A),
1331
1331
  //@ts-ignore
1332
1332
  draught: isNaN(W) ? null : Number(W),
1333
- type: o,
1334
- important: o !== "A",
1335
- meteo: Y ? JSON.parse(Y) : void 0,
1336
- vendor: d,
1333
+ type: q,
1334
+ important: q !== "A",
1335
+ meteo: d ? JSON.parse(d) : void 0,
1336
+ vendor: Y,
1337
1337
  deleted: R === "true"
1338
1338
  };
1339
1339
  }
1340
1340
  static inspectStoppages(M, z = 1, p = !0) {
1341
1341
  const b = M.at(0).positionTime < M.at(-1).positionTime;
1342
- b || M.sort((W, o) => W.positionTime - o.positionTime);
1342
+ b || M.sort((W, q) => W.positionTime - q.positionTime);
1343
1343
  const c = [];
1344
1344
  let O, A;
1345
1345
  for (let W = 0; W < M.length - 1; W++) {
1346
- const o = M[W];
1347
- if (!(p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(o.type))) {
1348
- for (let Y = W + 1; Y < M.length; Y++) {
1349
- const d = M[Y - 1], R = M[Y];
1350
- if (p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(o.type))
1346
+ const q = M[W];
1347
+ if (!(p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))) {
1348
+ for (let d = W + 1; d < M.length; d++) {
1349
+ const Y = M[d - 1], R = M[d];
1350
+ if (p && ["N", "B", "E", "NOON", "BOSP", "EOSP"].includes(q.type))
1351
1351
  continue;
1352
- const T = R.positionTime - d.positionTime;
1353
- if (r.calculateDistance(R, d, !0, 4) / (T / 3600) < z)
1354
- O || (O = o), Y === M.length - 1 && (A = R, W = Y);
1352
+ const T = R.positionTime - Y.positionTime;
1353
+ if (r.calculateDistance(R, Y, !0, 4) / (T / 3600) < z)
1354
+ O || (O = q), d === M.length - 1 && (A = R, W = d);
1355
1355
  else {
1356
- O && (A = M[Y - 1], W = Y);
1356
+ O && (A = M[d - 1], W = d);
1357
1357
  break;
1358
1358
  }
1359
1359
  }
1360
1360
  if ((A == null ? void 0 : A.positionTime) > (O == null ? void 0 : O.positionTime) && O) {
1361
- const Y = {
1361
+ const d = {
1362
1362
  start: {
1363
1363
  lat: O.lat,
1364
1364
  lng: O.lng,
@@ -1374,13 +1374,13 @@ class t0 {
1374
1374
  utc: U.unix(A.positionTime).utc().format()
1375
1375
  },
1376
1376
  duration: A.positionTime - O.positionTime
1377
- }, d = M.filter((T) => T.positionTime >= Y.start.positionTime && T.positionTime <= Y.end.positionTime), R = r.divideAccordingToLng(d);
1378
- Y.distance = r.calculateRouteDistance(R), Y.hours = Math.round(Y.duration / 3600 * 10) / 10, Y.avgSog = Math.round(Y.distance / Y.hours * 10) / 10, c.push(Y);
1377
+ }, Y = M.filter((T) => T.positionTime >= d.start.positionTime && T.positionTime <= d.end.positionTime), R = r.divideAccordingToLng(Y);
1378
+ d.distance = r.calculateRouteDistance(R), d.hours = Math.round(d.duration / 3600 * 10) / 10, d.avgSog = Math.round(d.distance / d.hours * 10) / 10, c.push(d);
1379
1379
  }
1380
1380
  O = void 0, A = void 0;
1381
1381
  }
1382
1382
  }
1383
- return b || M.sort((W, o) => o.positionTime - W.positionTime), c;
1383
+ return b || M.sort((W, q) => q.positionTime - W.positionTime), c;
1384
1384
  }
1385
1385
  /**
1386
1386
  * 计算轨迹摘要
@@ -1389,16 +1389,16 @@ class t0 {
1389
1389
  * @param etm
1390
1390
  */
1391
1391
  static inspectSummary(M, z, p) {
1392
- const b = U(z), c = U(p), O = M.filter((Y) => Y.positionTime >= b.unix() && Y.positionTime <= c.unix());
1392
+ const b = U(z), c = U(p), O = M.filter((d) => d.positionTime >= b.unix() && d.positionTime <= c.unix());
1393
1393
  let A = 0, W = 0;
1394
1394
  if (O.length > 1)
1395
- for (let Y = 0; Y < O.length - 1; Y++) {
1396
- const d = O[Y], R = O[Y + 1];
1397
- A += r.calculateDistance(d, R, !0, 4), W += Math.abs(R.positionTime - d.positionTime);
1395
+ for (let d = 0; d < O.length - 1; d++) {
1396
+ const Y = O[d], R = O[d + 1];
1397
+ A += r.calculateDistance(Y, R, !0, 4), W += Math.abs(R.positionTime - Y.positionTime);
1398
1398
  }
1399
1399
  A = Math.round(A * 100) / 100, W = Math.round(W / 3600 * 100) / 100;
1400
- const o = W ? Math.round(A / W * 100) / 100 : 0;
1401
- return { distance: A, interval: W, avgSpd: o };
1400
+ const q = W ? Math.round(A / W * 100) / 100 : 0;
1401
+ return { distance: A, interval: W, avgSpd: q };
1402
1402
  }
1403
1403
  }
1404
1404
  let H;
@@ -1454,8 +1454,8 @@ class r {
1454
1454
  for (let A = 0; A < O.length - 1; A++) {
1455
1455
  const W = { lng: O[A][0], lat: O[A][1] };
1456
1456
  A === 0 && c && (b += this.calculateDistance(c, W, !0, z, p));
1457
- const o = { lng: O[A + 1][0], lat: O[A + 1][1] };
1458
- b += this.calculateDistance(W, o, !0, z, p), c = o;
1457
+ const q = { lng: O[A + 1][0], lat: O[A + 1][1] };
1458
+ b += this.calculateDistance(W, q, !0, z, p), c = q;
1459
1459
  }
1460
1460
  return a.roundPrecision(b, z);
1461
1461
  }
@@ -1484,11 +1484,11 @@ class r {
1484
1484
  * @param units 单位,默认 nm(海里)
1485
1485
  */
1486
1486
  static interpolateCoordinates(M, z, p, b = !0, c = !0, O = "nauticalmiles") {
1487
- const A = [], W = this.calculateBearing(M, z, !1), o = this.calculateDistance(M, z, !1, 8, O);
1487
+ const A = [], W = this.calculateBearing(M, z, !1), q = this.calculateDistance(M, z, !1, 8, O);
1488
1488
  b && A.push({ lng: M.lng, lat: M.lat });
1489
- let Y = 0;
1490
- for (; Y < o; )
1491
- Y += p, Y < o && A.push(this.calculateCoordinate(M, W, Y, O, !1));
1489
+ let d = 0;
1490
+ for (; d < q; )
1491
+ d += p, d < q && A.push(this.calculateCoordinate(M, W, d, O, !1));
1492
1492
  return c && A.push({ lng: z.lng, lat: z.lat }), A;
1493
1493
  }
1494
1494
  /**
@@ -1512,25 +1512,25 @@ class r {
1512
1512
  let O, A;
1513
1513
  for (let W = 0; W < M.length - 1; W++) {
1514
1514
  O = a.convertToStdLng(M[W].lng, 8), A = a.convertToStdLng(M[W + 1].lng, 8), M[W].lat = a.roundPrecision(M[W].lat, 8), M[W + 1].lat = a.roundPrecision(M[W + 1].lat, 8), b.push([O, M[W].lat]);
1515
- const o = O - A;
1516
- if (Math.abs(o) > 180) {
1517
- const Y = a.convertToMonotonicLng2([
1515
+ const q = O - A;
1516
+ if (Math.abs(q) > 180) {
1517
+ const d = a.convertToMonotonicLng2([
1518
1518
  [O, M[W].lat],
1519
1519
  [A, M[W + 1].lat]
1520
1520
  ]);
1521
- let d, R;
1522
- z ? (d = t.lineString(Y), R = t.lineString([
1523
- [o > 0 ? 180 : -180, 89],
1524
- [o > 0 ? 180 : -180, -89]
1525
- ])) : (d = t.greatCircle(Y[0], Y[1]), R = t.greatCircle([o > 0 ? 180 : -180, 89], [o > 0 ? 180 : -180, -89]));
1526
- const T = t.lineIntersect(d, R);
1521
+ let Y, R;
1522
+ z ? (Y = t.lineString(d), R = t.lineString([
1523
+ [q > 0 ? 180 : -180, 89],
1524
+ [q > 0 ? 180 : -180, -89]
1525
+ ])) : (Y = t.greatCircle(d[0], d[1]), R = t.greatCircle([q > 0 ? 180 : -180, 89], [q > 0 ? 180 : -180, -89]));
1526
+ const T = t.lineIntersect(Y, R);
1527
1527
  let e;
1528
1528
  if (T.features.length) {
1529
1529
  const f = t.getCoord(T.features[0]);
1530
1530
  e = a.roundPrecision(f[1], 8);
1531
1531
  } else
1532
1532
  e = M[W].lat;
1533
- o > 0 ? (b.push([180 - 1e-6, e]), c.push([...b]), b = [], b.push([-(180 - 1e-6), e])) : (b.push([-(180 - 1e-6), e]), c.push([...b]), b = [], b.push([180 - 1e-6, e]));
1533
+ q > 0 ? (b.push([180 - 1e-6, e]), c.push([...b]), b = [], b.push([-(180 - 1e-6), e])) : (b.push([-(180 - 1e-6), e]), c.push([...b]), b = [], b.push([180 - 1e-6, e]));
1534
1534
  }
1535
1535
  W === M.length - 2 && b.push([A, M[W + 1].lat]);
1536
1536
  }
@@ -1592,10 +1592,10 @@ class r {
1592
1592
  static mergeCoordinateToRoute(M, z) {
1593
1593
  M.lng = a.convertToStdLng(M.lng, 8);
1594
1594
  let p = Number.MAX_VALUE, b = 0, c = 0, O, A;
1595
- return z.forEach((W, o) => {
1596
- for (let Y = 0; Y < W.length - 1; Y++) {
1597
- const d = { lng: W[Y][0], lat: W[Y][1] }, R = { lng: W[Y + 1][0], lat: W[Y + 1][1] }, T = this.calculatePointToLineDistance(M, d, R);
1598
- p > T && (p = T, c = Y, b = o, O = this.calculateDistance(d, M), A = this.calculateDistance(R, M));
1595
+ return z.forEach((W, q) => {
1596
+ for (let d = 0; d < W.length - 1; d++) {
1597
+ const Y = { lng: W[d][0], lat: W[d][1] }, R = { lng: W[d + 1][0], lat: W[d + 1][1] }, T = this.calculatePointToLineDistance(M, Y, R);
1598
+ p > T && (p = T, c = d, b = q, O = this.calculateDistance(Y, M), A = this.calculateDistance(R, M));
1599
1599
  }
1600
1600
  }), O !== 0 && A !== 0 ? z[b].splice(c + 1, 0, [M.lng, M.lat]) : O === 0 ? z[b].splice(c, 1, [M.lng, M.lat]) : A === 0 && z[b].splice(c + 1, 1, [M.lng, M.lat]), z;
1601
1601
  }
@@ -1663,11 +1663,11 @@ class r {
1663
1663
  */
1664
1664
  static calculateRangeWaypoints(M, z, p, b = []) {
1665
1665
  const c = this.convertRouteToCoordinates(p, 0), O = this.mergeCoordinatesToWaypoints([M, z], c.length ? c : b), A = O.findIndex(
1666
- (Y) => a.roundPrecision(M.lng, 8) === a.roundPrecision(Y.lng, 8) && a.roundPrecision(M.lat, 8) === a.roundPrecision(Y.lat, 8)
1666
+ (d) => a.roundPrecision(M.lng, 8) === a.roundPrecision(d.lng, 8) && a.roundPrecision(M.lat, 8) === a.roundPrecision(d.lat, 8)
1667
1667
  ), W = O.findIndex(
1668
- (Y) => a.roundPrecision(z.lng, 8) === a.roundPrecision(Y.lng, 8) && a.roundPrecision(z.lat, 8) === a.roundPrecision(Y.lat, 8)
1668
+ (d) => a.roundPrecision(z.lng, 8) === a.roundPrecision(d.lng, 8) && a.roundPrecision(z.lat, 8) === a.roundPrecision(d.lat, 8)
1669
1669
  );
1670
- return O.filter((Y, d) => d >= A && d <= W);
1670
+ return O.filter((d, Y) => Y >= A && Y <= W);
1671
1671
  }
1672
1672
  /**
1673
1673
  * 计算坐标到航路上的最短距离
@@ -1678,8 +1678,8 @@ class r {
1678
1678
  let p = Number.MAX_VALUE, b = 0, c = 0;
1679
1679
  return z.forEach((O, A) => {
1680
1680
  for (let W = 0; W < O.length - 1; W++) {
1681
- const o = { lng: O[W][0], lat: O[W][1] }, Y = { lng: O[W + 1][0], lat: O[W + 1][1] }, d = this.calculatePointToLineDistance(M, o, Y);
1682
- p > d && (p = d, b = W, c = A);
1681
+ const q = { lng: O[W][0], lat: O[W][1] }, d = { lng: O[W + 1][0], lat: O[W + 1][1] }, Y = this.calculatePointToLineDistance(M, q, d);
1682
+ p > Y && (p = Y, b = W, c = A);
1683
1683
  }
1684
1684
  }), { minDist: p, segIndex: c, minIndex: b };
1685
1685
  }
@@ -1698,11 +1698,11 @@ class r {
1698
1698
  let A = !0;
1699
1699
  for (let W = b; W < z.length; W++)
1700
1700
  if (A) {
1701
- const o = [];
1702
- o.push([M.lng, M.lat]);
1703
- for (let Y = c + 1; Y < z[W].length; Y++)
1704
- M.lng === z[W][Y][0] && M.lat === z[W][Y][1] || o.push(z[W][Y]);
1705
- O.push(o), A = !1;
1701
+ const q = [];
1702
+ q.push([M.lng, M.lat]);
1703
+ for (let d = c + 1; d < z[W].length; d++)
1704
+ M.lng === z[W][d][0] && M.lat === z[W][d][1] || q.push(z[W][d]);
1705
+ O.push(q), A = !1;
1706
1706
  } else
1707
1707
  O.push([...z[W]]);
1708
1708
  return O;
@@ -1720,9 +1720,9 @@ class r {
1720
1720
  if (this.calculateDistance(M, A) === 0)
1721
1721
  return z;
1722
1722
  if (this.calculateDistance(M, W) === 0)
1723
- return z.filter((Y, d) => d > 0);
1724
- const o = this.calculatePointToLineDistance(M, A, W);
1725
- p > o && (p = o, b = O);
1723
+ return z.filter((d, Y) => Y > 0);
1724
+ const q = this.calculatePointToLineDistance(M, A, W);
1725
+ p > q && (p = q, b = O);
1726
1726
  }
1727
1727
  M.lng = a.convertToStdLng(M.lng);
1728
1728
  const c = [M];
@@ -1789,17 +1789,17 @@ class r {
1789
1789
  z.push(M);
1790
1790
  else {
1791
1791
  for (let W = 0; W < z.length - 1; W++) {
1792
- const o = { lng: z[W].lng, lat: z[W].lat }, Y = { lng: z[W + 1].lng, lat: z[W + 1].lat }, d = this.calculatePointToLineDistance(M, o, Y);
1793
- b >= d && (b = d, c = W, O = this.calculateDistance(o, M, !1, 6), A = this.calculateDistance(Y, M, !1, 6));
1792
+ const q = { lng: z[W].lng, lat: z[W].lat }, d = { lng: z[W + 1].lng, lat: z[W + 1].lat }, Y = this.calculatePointToLineDistance(M, q, d);
1793
+ b >= Y && (b = Y, c = W, O = this.calculateDistance(q, M, !1, 6), A = this.calculateDistance(d, M, !1, 6));
1794
1794
  }
1795
1795
  O !== 0 && A !== 0 ? O <= b && c === 0 ? z.unshift(M) : A <= b && c === z.length - 2 ? z.push(M) : z.splice(c + 1, 0, M) : O === 0 ? p ? z.splice(c, 1, M) : z.splice(c + 1, 0, M) : A === 0 && (p ? z.splice(c + 1, 1, M) : z.splice(c + 1, 0, M));
1796
1796
  }
1797
- return z.map((W, o) => {
1797
+ return z.map((W, q) => {
1798
1798
  W.lng = a.convertToStdLng(W.lng);
1799
- const Y = z[o + 1];
1800
- if (Y && ((W.bearing === null || W.bearing === void 0) && ((W.positionTime || 0) > (Y.positionTime || 0) ? W.bearing = this.calculateBearing(Y, W, !0) : W.bearing = this.calculateBearing(W, Y, !0)), W.cog = W.cog || W.bearing, !W.sog && W.positionTime && Y.positionTime)) {
1801
- const d = this.calculateDistance(W, Y, !0), R = Math.abs(Y.positionTime - W.positionTime) / 3600;
1802
- W.sog = a.roundPrecision(d / R, 2);
1799
+ const d = z[q + 1];
1800
+ if (d && ((W.bearing === null || W.bearing === void 0) && ((W.positionTime || 0) > (d.positionTime || 0) ? W.bearing = this.calculateBearing(d, W, !0) : W.bearing = this.calculateBearing(W, d, !0)), W.cog = W.cog || W.bearing, !W.sog && W.positionTime && d.positionTime)) {
1801
+ const Y = this.calculateDistance(W, d, !0), R = Math.abs(d.positionTime - W.positionTime) / 3600;
1802
+ W.sog = a.roundPrecision(Y / R, 2);
1803
1803
  }
1804
1804
  return W;
1805
1805
  });
@@ -1829,7 +1829,7 @@ class r {
1829
1829
  * @param route [[[lng, lat]]]
1830
1830
  */
1831
1831
  static nearestCoordinateInRoute(M, z) {
1832
- const p = t.point([M.lng, M.lat]), c = this.convertRouteToCoordinates(z).map((o) => [o.lng, o.lat]), O = t.lineString(c), A = t.nearestPointOnLine(O, p), W = t.getCoord(A);
1832
+ const p = t.point([M.lng, M.lat]), c = this.convertRouteToCoordinates(z).map((q) => [q.lng, q.lat]), O = t.lineString(c), A = t.nearestPointOnLine(O, p), W = t.getCoord(A);
1833
1833
  return { lng: a.roundPrecision(W[0], 8), lat: a.roundPrecision(W[1], 8) };
1834
1834
  }
1835
1835
  /**
@@ -1864,7 +1864,7 @@ class r {
1864
1864
  static calculateNextCoordinateAlongRoute(M, z, p, b = "nauticalmiles") {
1865
1865
  var R;
1866
1866
  const c = M.speed || 12, O = [];
1867
- let A = [], W = !1, o = 0, Y = 0, d;
1867
+ let A = [], W = !1, q = 0, d = 0, Y;
1868
1868
  if (z && p.length ? (O.push(M), p.forEach((T, e) => {
1869
1869
  if (W)
1870
1870
  A.push(T);
@@ -1872,32 +1872,32 @@ class r {
1872
1872
  const f = [];
1873
1873
  let i;
1874
1874
  for (let S = 0; S < T.length; S++)
1875
- if (d)
1875
+ if (Y)
1876
1876
  f.push(T[S]);
1877
1877
  else {
1878
1878
  i = { lng: T[S][0], lat: T[S][1] };
1879
1879
  const u = this.calculateDistance(M, i, !0, 8, b);
1880
- if (o += u, o < z)
1881
- Y += u, u && O.push(i), M = i;
1880
+ if (q += u, q < z)
1881
+ d += u, u && O.push(i), M = i;
1882
1882
  else {
1883
- if (Y = z, o === z)
1884
- d = i, f.push([d.lng, d.lat]);
1883
+ if (d = z, q === z)
1884
+ Y = i, f.push([Y.lng, Y.lat]);
1885
1885
  else {
1886
- const Z = o - z, B = this.calculateBearing(i, M);
1887
- d = this.calculateCoordinate(i, B, Z, b), f.push([d.lng, d.lat]), f.push([i.lng, i.lat]);
1886
+ const Z = q - z, B = this.calculateBearing(i, M);
1887
+ Y = this.calculateCoordinate(i, B, Z, b), f.push([Y.lng, Y.lat]), f.push([i.lng, i.lat]);
1888
1888
  }
1889
1889
  W = !0;
1890
1890
  }
1891
1891
  }
1892
- f.length && A.push(f), e === p.length - 1 && !d && (d = i);
1892
+ f.length && A.push(f), e === p.length - 1 && !Y && (Y = i);
1893
1893
  }
1894
- })) : (A = p, d = { ...M }), d)
1895
- if (O.push(d), d.distanceFromPrevious = Math.round(Y * 1e4) / 1e4, d.hourFromPrevious = Math.round(Y / c * 1e4) / 1e4, ((R = A[0]) == null ? void 0 : R.length) > 1) {
1894
+ })) : (A = p, Y = { ...M }), Y)
1895
+ if (O.push(Y), Y.distanceFromPrevious = Math.round(d * 1e4) / 1e4, Y.hourFromPrevious = Math.round(d / c * 1e4) / 1e4, ((R = A[0]) == null ? void 0 : R.length) > 1) {
1896
1896
  const T = { lng: A[0][1][0], lat: A[0][1][1] };
1897
- d.bearing = this.calculateBearing(d, T);
1897
+ Y.bearing = this.calculateBearing(Y, T);
1898
1898
  } else
1899
- d.bearing = 0;
1900
- return { coordinate: d, nextRoute: A, prevRoute: O };
1899
+ Y.bearing = 0;
1900
+ return { coordinate: Y, nextRoute: A, prevRoute: O };
1901
1901
  }
1902
1902
  /**
1903
1903
  * 返回最近点及其是否为垂足(最近点不是起点或终点)
@@ -1909,8 +1909,8 @@ class r {
1909
1909
  const b = a.convertToStdLng(M.lng, 6), c = t.point([b, M.lat]), O = a.convertToStdLng(z.lng, 6), A = a.convertToStdLng(p.lng, 6), W = t.lineString([
1910
1910
  [O, z.lat],
1911
1911
  [A, p.lat]
1912
- ]), o = t.nearestPointOnLine(W, c), Y = t.getCoord(o), d = a.roundPrecision(Y[0], 6), R = a.roundPrecision(Y[1], 6);
1913
- return { lng: d, lat: R, inline: !(d === O && R === z.lat) && !(d === A && R === p.lat) };
1912
+ ]), q = t.nearestPointOnLine(W, c), d = t.getCoord(q), Y = a.roundPrecision(d[0], 6), R = a.roundPrecision(d[1], 6);
1913
+ return { lng: Y, lat: R, inline: !(Y === O && R === z.lat) && !(Y === A && R === p.lat) };
1914
1914
  }
1915
1915
  /**
1916
1916
  * 将route转coordinate
@@ -1928,8 +1928,8 @@ class r {
1928
1928
  else if (c.bearing === void 0 || c.bearing === null)
1929
1929
  c.bearing = this.calculateBearing(c, W, !0);
1930
1930
  else {
1931
- const o = this.calculateDistance(b, W, !0);
1932
- o && o >= z && (b.bearing = this.calculateBearing(b, W, !0), p.push(b), c = b);
1931
+ const q = this.calculateDistance(b, W, !0);
1932
+ q && q >= z && (b.bearing = this.calculateBearing(b, W, !0), p.push(b), c = b);
1933
1933
  }
1934
1934
  b = W;
1935
1935
  });
@@ -1957,9 +1957,9 @@ class r {
1957
1957
  for (let b = 1; b < z.length; b++) {
1958
1958
  const c = z[b - 1], O = z[b];
1959
1959
  if (O.gcToPrevious) {
1960
- const A = M.findIndex((o) => o.lng === c.lng && o.lat === c.lat), W = M.findIndex((o) => o.lng === O.lng && o.lat === O.lat);
1961
- for (let o = W - 1; o > A; o--)
1962
- M.splice(o, 1);
1960
+ const A = M.findIndex((q) => q.lng === c.lng && q.lat === c.lat), W = M.findIndex((q) => q.lng === O.lng && q.lat === O.lat);
1961
+ for (let q = W - 1; q > A; q--)
1962
+ M.splice(q, 1);
1963
1963
  }
1964
1964
  }
1965
1965
  let p = 0;
@@ -2022,14 +2022,14 @@ class r {
2022
2022
  const b = [];
2023
2023
  for (let c = 1; c < M.length; c++) {
2024
2024
  const O = M[c - 1], A = M[c], W = M[c + 1];
2025
- let o = !1, Y = !1;
2026
- if ((O.velocity || O.suspend || O.important || O.pilot || c === 1) && (o = !0, b.push(O)), A.gcToPrevious && (o || (o = !0, b.push(O)), Y = !0, b.push(A), c++), W) {
2027
- const d = r.calculateDistance(O, A, !0), R = r.calculateDistance(A, W, !0), T = r.calculateDistance(O, W, !0), e = (Math.pow(d, 2) + Math.pow(R, 2) - Math.pow(T, 2)) / (2 * d * R);
2028
- Math.round(Math.acos(e) * 180 / Math.PI) < p && T > z && !Y && (b.push(A), c++);
2025
+ let q = !1, d = !1;
2026
+ if ((O.velocity || O.suspend || O.important || O.pilot || c === 1) && (q = !0, b.push(O)), A.gcToPrevious && (q || (q = !0, b.push(O)), d = !0, b.push(A), c++), W) {
2027
+ const Y = r.calculateDistance(O, A, !0), R = r.calculateDistance(A, W, !0), T = r.calculateDistance(O, W, !0), e = (Math.pow(Y, 2) + Math.pow(R, 2) - Math.pow(T, 2)) / (2 * Y * R);
2028
+ Math.round(Math.acos(e) * 180 / Math.PI) < p && T > z && !d && (b.push(A), c++);
2029
2029
  }
2030
2030
  if (c >= M.length - 1) {
2031
- const d = M.at(-1);
2032
- d && b.push(d);
2031
+ const Y = M.at(-1);
2032
+ Y && b.push(Y);
2033
2033
  }
2034
2034
  }
2035
2035
  return b;
@@ -2055,14 +2055,14 @@ class r {
2055
2055
  var c, O, A, W;
2056
2056
  M > 1e12 && (M = Math.round(M / 1e3));
2057
2057
  const p = U.unix(M);
2058
- let b = z.find((o) => o.positionTime === p.unix());
2058
+ let b = z.find((q) => q.positionTime === p.unix());
2059
2059
  if (!b) {
2060
- const o = (O = (c = z.filter((d) => (d == null ? void 0 : d.positionTime) < p.unix())) == null ? void 0 : c.sort((d, R) => (d.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : O.at(-1), Y = (W = (A = z.filter((d) => (d == null ? void 0 : d.positionTime) > p.unix())) == null ? void 0 : A.sort((d, R) => (d.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : W.at(0);
2061
- if (o && Y) {
2062
- const d = r.calculateBearing(o, Y, !0), R = r.calculateDistance(o, Y), T = (p.unix() - o.positionTime) / (Y.positionTime - o.positionTime);
2063
- b = r.calculateCoordinate(o, d, R * T), b.positionTime = p.unix(), b.utc = p.utc().format(), b.cog = d, b.sog = Math.round(R / ((Y.positionTime - o.positionTime) / 3600) * 100) / 100;
2060
+ const q = (O = (c = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) < p.unix())) == null ? void 0 : c.sort((Y, R) => (Y.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : O.at(-1), d = (W = (A = z.filter((Y) => (Y == null ? void 0 : Y.positionTime) > p.unix())) == null ? void 0 : A.sort((Y, R) => (Y.positionTime || 0) - (R.positionTime || 0))) == null ? void 0 : W.at(0);
2061
+ if (q && d) {
2062
+ const Y = r.calculateBearing(q, d, !0), R = r.calculateDistance(q, d), T = (p.unix() - q.positionTime) / (d.positionTime - q.positionTime);
2063
+ b = r.calculateCoordinate(q, Y, R * T), b.positionTime = p.unix(), b.utc = p.utc().format(), b.cog = Y, b.sog = Math.round(R / ((d.positionTime - q.positionTime) / 3600) * 100) / 100;
2064
2064
  } else
2065
- b = o || Y, b && (b.utc = U.unix(b == null ? void 0 : b.positionTime).utc().format());
2065
+ b = q || d, b && (b.utc = U.unix(b == null ? void 0 : b.positionTime).utc().format());
2066
2066
  }
2067
2067
  return b;
2068
2068
  }
@@ -2072,11 +2072,11 @@ class r {
2072
2072
  * @param positions
2073
2073
  */
2074
2074
  static deadReckoningTime(M, z) {
2075
- z = JSON.parse(JSON.stringify(z)), z.sort((o, Y) => (o.positionTime || 0) - (Y.positionTime || 0));
2075
+ z = JSON.parse(JSON.stringify(z)), z.sort((q, d) => (q.positionTime || 0) - (d.positionTime || 0));
2076
2076
  let p = Number.MAX_SAFE_INTEGER, b = Number.MAX_SAFE_INTEGER;
2077
- for (let o = 0; o < z.length - 1; o++) {
2078
- const Y = z[o], d = z[o + 1], R = r.calculatePointToLineDistance(M, Y, d);
2079
- R < p && (p = R, b = o);
2077
+ for (let q = 0; q < z.length - 1; q++) {
2078
+ const d = z[q], Y = z[q + 1], R = r.calculatePointToLineDistance(M, d, Y);
2079
+ R < p && (p = R, b = q);
2080
2080
  }
2081
2081
  const c = z[b], O = z[b + 1], A = r.calculateDistance(c, M), W = r.calculateDistance(O, M);
2082
2082
  if (A === 0)
@@ -2084,8 +2084,8 @@ class r {
2084
2084
  else if (W === 0)
2085
2085
  M = O;
2086
2086
  else {
2087
- const o = c.positionTime || 0, Y = O.positionTime || 0, d = r.calculateDistance(c, O);
2088
- M.positionTime = Math.round(o + (Y - o) * (A / d));
2087
+ const q = c.positionTime || 0, d = O.positionTime || 0, Y = r.calculateDistance(c, O);
2088
+ M.positionTime = Math.round(q + (d - q) * (A / Y));
2089
2089
  }
2090
2090
  return M.utc = M.positionTime ? U.unix(M.positionTime).utc().format() : void 0, M.positionTime ? M : void 0;
2091
2091
  }
@@ -2132,31 +2132,34 @@ class r {
2132
2132
  * @param waypoints 途径点
2133
2133
  * @see https://cirm.org/rtz-xml-schemas
2134
2134
  */
2135
- static waypoints2RTZ10(M, z) {
2136
- const b = [];
2137
- return b.push('<?xml version="1.0" encoding="UTF-8"?>'), b.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), b.push(` <routeInfo routeName="${r.xmlEscape(M)}"></routeInfo>`), b.push(...r.toRTZWaypoints(z, 6)), b.push("</route>"), b.join(`
2135
+ static waypoints2RTZ10(M, z, p = !0) {
2136
+ const c = [];
2137
+ return c.push('<?xml version="1.0" encoding="UTF-8"?>'), c.push('<route xmlns="http://www.cirm.org/RTZ/1/0" version="1.0">'), c.push(` <routeInfo routeName="${r.xmlEscape(M)}"></routeInfo>`), c.push(...r.toRTZWaypoints(z, 6, p)), c.push("</route>"), c.join(`
2138
2138
  `);
2139
2139
  }
2140
- static toRTZWaypoints(M, z = 6) {
2141
- const p = [];
2142
- p.push(" <waypoints>");
2143
- for (let b = 0; b < M.length; b++) {
2144
- const c = M[b], O = b + 1, A = (c.lat ?? "").toFixed ? c.lat.toFixed(z).padEnd(z + 2, "0") : c.lat, W = (c.lng ?? "").toFixed ? c.lng.toFixed(z).padEnd(z + 2, "0") : c.lng, o = [`id="${O}"`, 'revision="0"'];
2145
- if (c.name && o.push(`name="${r.xmlEscape(c.name)}"`), p.push(` <waypoint ${o.join(" ")}>`), p.push(` <position lat="${r.xmlEscape(A)}" lon="${r.xmlEscape(W)}" />`), b > 0) {
2146
- const d = c.gcToPrevious ? "Orthodrome" : "Loxodrome";
2147
- p.push(` <leg geometryType="${d}" />`);
2140
+ static toRTZWaypoints(M, z = 6, p = !0) {
2141
+ const b = [];
2142
+ b.push(" <waypoints>");
2143
+ for (let c = 0; c < M.length; c++) {
2144
+ const O = M[c], A = c + 1, W = (O.lat ?? "").toFixed ? O.lat.toFixed(z).padEnd(z + 2, "0") : O.lat, q = (O.lng ?? "").toFixed ? O.lng.toFixed(z).padEnd(z + 2, "0") : O.lng, d = [`id="${A}"`, 'revision="0"'];
2145
+ if (O.name && d.push(`name="${r.xmlEscape(O.name)}"`), b.push(` <waypoint ${d.join(" ")}>`), b.push(` <position lat="${r.xmlEscape(W)}" lon="${r.xmlEscape(q)}" />`), c > 0) {
2146
+ const Y = O.gcToPrevious ? "Orthodrome" : "Loxodrome";
2147
+ b.push(` <leg geometryType="${Y}" />`);
2148
2148
  }
2149
- const Y = [];
2150
- if (c.description && Y.push(` <description>${r.xmlEscape(c.description)}</description>`), c.utc)
2151
- Y.push(` <time>${r.xmlEscape(c.utc)}</time>`);
2152
- else if (c.positionTime)
2153
- try {
2154
- Y.push(` <time>${r.xmlEscape(U.unix(c.positionTime).utc().format())}</time>`);
2155
- } catch {
2156
- }
2157
- c.cog !== void 0 && Y.push(` <cog>${r.xmlEscape(c.cog)}</cog>`), c.sog !== void 0 && Y.push(` <sog>${r.xmlEscape(c.sog)}</sog>`), Y.length && (p.push(" <extensions>"), p.push(...Y), p.push(" </extensions>")), p.push(" </waypoint>");
2149
+ if (p) {
2150
+ const Y = [];
2151
+ if (O.description && Y.push(` <description>${r.xmlEscape(O.description)}</description>`), O.utc)
2152
+ Y.push(` <time>${r.xmlEscape(O.utc)}</time>`);
2153
+ else if (O.positionTime)
2154
+ try {
2155
+ Y.push(` <time>${r.xmlEscape(U.unix(O.positionTime).utc().format())}</time>`);
2156
+ } catch {
2157
+ }
2158
+ O.cog !== void 0 && Y.push(` <cog>${r.xmlEscape(O.cog)}</cog>`), O.sog !== void 0 && Y.push(` <sog>${r.xmlEscape(O.sog)}</sog>`), Y.length && (b.push(" <extensions>"), b.push(...Y), b.push(" </extensions>"));
2159
+ }
2160
+ b.push(" </waypoint>");
2158
2161
  }
2159
- return p.push(" </waypoints>"), p;
2162
+ return b.push(" </waypoints>"), b;
2160
2163
  }
2161
2164
  /**
2162
2165
  * 路径转通用CSV (纯十进制度数、无厂商头、RFC 4180标准)
@@ -2167,13 +2170,13 @@ class r {
2167
2170
  */
2168
2171
  static waypoints2CSV(M, z, p) {
2169
2172
  H.debug("keep name for waypoints2CSV for legacy compatibility only", M);
2170
- const b = (p == null ? void 0 : p.precision) ?? 6, c = z.some((i) => i.name), O = z.some((i) => i.description), A = z.some((i) => i.port != null), W = z.some((i) => i.stbd != null), o = z.some((i) => i.arrRad != null), Y = z.some((i) => i.speed != null), d = z.some((i, S) => S > 0 && i.gcToPrevious != null), R = z.some((i) => i.bearing != null), T = z.some((i) => i.distanceFromPrevious != null), e = ["WPT No.", "Latitude", "Longitude"];
2171
- c && e.push("Name"), O && e.push("Description"), d && e.push("Leg"), R && e.push("Bearing[deg]"), T && e.push("Distance[NM]"), Y && e.push("Speed[kn]"), A && e.push("PORT XTD[NM]"), W && e.push("STBD XTD[NM]"), o && e.push("Arr.Rad[NM]");
2173
+ const b = (p == null ? void 0 : p.precision) ?? 6, c = z.some((i) => i.name), O = z.some((i) => i.description), A = z.some((i) => i.port != null), W = z.some((i) => i.stbd != null), q = z.some((i) => i.arrRad != null), d = z.some((i) => i.speed != null), Y = z.some((i, S) => S > 0 && i.gcToPrevious != null), R = z.some((i) => i.bearing != null), T = z.some((i) => i.distanceFromPrevious != null), e = ["WPT No.", "Latitude", "Longitude"];
2174
+ c && e.push("Name"), O && e.push("Description"), Y && e.push("Leg"), R && e.push("Bearing[deg]"), T && e.push("Distance[NM]"), d && e.push("Speed[kn]"), A && e.push("PORT XTD[NM]"), W && e.push("STBD XTD[NM]"), q && e.push("Arr.Rad[NM]");
2172
2175
  const f = [];
2173
2176
  f.push(e.map((i) => r.csvEscapeField(i)).join(","));
2174
2177
  for (let i = 0; i < z.length; i++) {
2175
2178
  const S = z[i], u = [];
2176
- u.push((i + 1).toString()), u.push(S.lat.toFixed(b)), u.push(S.lng.toFixed(b)), c && u.push(S.name ?? ""), O && u.push(S.description ?? ""), d && u.push(i === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), R && u.push(S.bearing != null ? String(S.bearing) : ""), T && u.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), Y && u.push(S.speed != null ? String(S.speed) : ""), A && u.push(S.port != null ? String(S.port) : ""), W && u.push(S.stbd != null ? String(S.stbd) : ""), o && u.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(u.map((Z) => r.csvEscapeField(Z)).join(","));
2179
+ u.push((i + 1).toString()), u.push(S.lat.toFixed(b)), u.push(S.lng.toFixed(b)), c && u.push(S.name ?? ""), O && u.push(S.description ?? ""), Y && u.push(i === 0 ? "" : S.gcToPrevious ? "GC" : "RL"), R && u.push(S.bearing != null ? String(S.bearing) : ""), T && u.push(S.distanceFromPrevious != null ? String(S.distanceFromPrevious) : ""), d && u.push(S.speed != null ? String(S.speed) : ""), A && u.push(S.port != null ? String(S.port) : ""), W && u.push(S.stbd != null ? String(S.stbd) : ""), q && u.push(S.arrRad != null ? String(S.arrRad) : ""), f.push(u.map((Z) => r.csvEscapeField(Z)).join(","));
2177
2180
  }
2178
2181
  return f.join(`
2179
2182
  `);
@@ -2215,8 +2218,8 @@ class r {
2215
2218
  static waypoints2NMEA(M) {
2216
2219
  const z = [];
2217
2220
  for (let p = 0; p < M.length; p++) {
2218
- const b = M[p], c = r.decimalToNmeaDm(b.lat, !0), O = r.decimalToNmeaDm(b.lng, !1), A = b.name ? String(b.name).slice(0, 6) : `WPT${(p + 1).toString().padStart(3, "0")}`, W = `GPWPL,${c.dm},${c.dir},${O.dm},${O.dir},${A}`, o = r.nmeaChecksum(W);
2219
- z.push(`$${W}*${o}`);
2221
+ const b = M[p], c = r.decimalToNmeaDm(b.lat, !0), O = r.decimalToNmeaDm(b.lng, !1), A = b.name ? String(b.name).slice(0, 6) : `WPT${(p + 1).toString().padStart(3, "0")}`, W = `GPWPL,${c.dm},${c.dir},${O.dm},${O.dir},${A}`, q = r.nmeaChecksum(W);
2222
+ z.push(`$${W}*${q}`);
2220
2223
  }
2221
2224
  return z.join(`\r
2222
2225
  `);
@@ -2235,19 +2238,19 @@ class r {
2235
2238
  */
2236
2239
  static coordinatesSummary(M, z = 3) {
2237
2240
  if (M.length > 1) {
2238
- const p = M[0], b = M[M.length - 1], c = (p == null ? void 0 : p.positionTime) < (b == null ? void 0 : b.positionTime) ? U.unix(p == null ? void 0 : p.positionTime) : U.unix(b == null ? void 0 : b.positionTime), O = (p == null ? void 0 : p.positionTime) > (b == null ? void 0 : b.positionTime) ? U.unix(p == null ? void 0 : p.positionTime) : U.unix(b == null ? void 0 : b.positionTime), A = Math.round(O.diff(c, "hours", !0) * 100) / 100, W = this.generateRouteAccordingToWaypoints(M, !0, !0), o = this.calculateRouteDistance(W), d = t0.inspectStoppages(M, z).reduce(
2241
+ const p = M[0], b = M[M.length - 1], c = (p == null ? void 0 : p.positionTime) < (b == null ? void 0 : b.positionTime) ? U.unix(p == null ? void 0 : p.positionTime) : U.unix(b == null ? void 0 : b.positionTime), O = (p == null ? void 0 : p.positionTime) > (b == null ? void 0 : b.positionTime) ? U.unix(p == null ? void 0 : p.positionTime) : U.unix(b == null ? void 0 : b.positionTime), A = Math.round(O.diff(c, "hours", !0) * 100) / 100, W = this.generateRouteAccordingToWaypoints(M, !0, !0), q = this.calculateRouteDistance(W), Y = t0.inspectStoppages(M, z).reduce(
2239
2242
  (T, e) => (T.duration += e.duration, T.distance += e.distance, T),
2240
2243
  { hours: 0, distance: 0, spd: 0, duration: 0 }
2241
2244
  );
2242
- d.hours = Math.round(d.duration / 3600 * 100) / 100, d.distance = Math.round(d.distance * 100) / 100, d.spd = d.hours ? Math.round(d.distance / d.hours * 100) / 100 : 0;
2243
- const R = A ? Math.round((o - d.distance) / (A - d.hours) * 100) / 100 : 0;
2245
+ Y.hours = Math.round(Y.duration / 3600 * 100) / 100, Y.distance = Math.round(Y.distance * 100) / 100, Y.spd = Y.hours ? Math.round(Y.distance / Y.hours * 100) / 100 : 0;
2246
+ const R = A ? Math.round((q - Y.distance) / (A - Y.hours) * 100) / 100 : 0;
2244
2247
  return {
2245
2248
  begin: c.utc().format(),
2246
2249
  end: O.utc().format(),
2247
- distance: Math.round((o - d.distance) * 100) / 100,
2248
- hours: Math.round((A - d.hours) * 100) / 100,
2250
+ distance: Math.round((q - Y.distance) * 100) / 100,
2251
+ hours: Math.round((A - Y.hours) * 100) / 100,
2249
2252
  avgSpeed: R,
2250
- stoppage: d
2253
+ stoppage: Y
2251
2254
  };
2252
2255
  }
2253
2256
  return {
@@ -2268,8 +2271,8 @@ class r {
2268
2271
  * }
2269
2272
  */
2270
2273
  static pickUTCSampleFromSpeed(M, z) {
2271
- var Y, d, R;
2272
- if (!((d = (Y = z == null ? void 0 : z.sample) == null ? void 0 : Y.hours) != null && d.length))
2274
+ var d, Y, R;
2275
+ if (!((Y = (d = z == null ? void 0 : z.sample) == null ? void 0 : d.hours) != null && Y.length))
2273
2276
  return { routes: [], hour: void 0 };
2274
2277
  const p = z.sample.hours.at(0), b = U.utc(M), c = U.utc(z.eta), O = b.isAfter(c) ? c : b;
2275
2278
  let A = z.sample.all.find((T) => T.eta === O.format());
@@ -2309,14 +2312,14 @@ class r {
2309
2312
  */
2310
2313
  static pickUTCSampleFromRoute(M, z, p) {
2311
2314
  var T;
2312
- const b = this.calculateSubRoute(z, p), c = this.calculateRouteDistance(b), O = c / z.speed, A = U.utc(M), W = U(z.etd), o = (T = this.calculateNextCoordinateAlongRoute(z, z.speed * A.diff(U(z.etd), "hours", !0), b)) == null ? void 0 : T.coordinate;
2313
- o.speed = z.speed;
2314
- const Y = W.clone().add(o.hourFromPrevious, "hour");
2315
- o.eta = Math.abs(Y.diff(A, "second")) < 2 ? A.format() : Y.format(), o.etd = o.eta, o.distanceFromStart = Math.round(o.distanceFromPrevious * 100) / 100, o.distanceToGo = Math.round((c - o.distanceFromStart) * 100) / 100, o.timeToGo = Math.round(W.clone().add(O, "hour").diff(U(o.etd), "hour") * 100) / 100;
2316
- const d = this.calculateRangeWaypoints(z, o, p);
2315
+ const b = this.calculateSubRoute(z, p), c = this.calculateRouteDistance(b), O = c / z.speed, A = U.utc(M), W = U(z.etd), q = (T = this.calculateNextCoordinateAlongRoute(z, z.speed * A.diff(U(z.etd), "hours", !0), b)) == null ? void 0 : T.coordinate;
2316
+ q.speed = z.speed;
2317
+ const d = W.clone().add(q.hourFromPrevious, "hour");
2318
+ q.eta = Math.abs(d.diff(A, "second")) < 2 ? A.format() : d.format(), q.etd = q.eta, q.distanceFromStart = Math.round(q.distanceFromPrevious * 100) / 100, q.distanceToGo = Math.round((c - q.distanceFromStart) * 100) / 100, q.timeToGo = Math.round(W.clone().add(O, "hour").diff(U(q.etd), "hour") * 100) / 100;
2319
+ const Y = this.calculateRangeWaypoints(z, q, p);
2317
2320
  return {
2318
- routes: this.generateRouteAccordingToWaypoints(d),
2319
- hour: o
2321
+ routes: this.generateRouteAccordingToWaypoints(Y),
2322
+ hour: q
2320
2323
  };
2321
2324
  }
2322
2325
  /**
@@ -2349,11 +2352,11 @@ class V0 {
2349
2352
  if (O.forecasts) {
2350
2353
  A && A.wind && (A.wind.kts = A.kts);
2351
2354
  for (const W of O.forecasts) {
2352
- let o;
2353
- const Y = [], d = [], R = U(W.date).utc(), T = `${O.name}-${W.model}`;
2355
+ let q;
2356
+ const d = [], Y = [], R = U(W.date).utc(), T = `${O.name}-${W.model}`;
2354
2357
  for (const f in W == null ? void 0 : W.hours) {
2355
2358
  const i = W.hours[f];
2356
- o = o || i;
2359
+ q = q || i;
2357
2360
  const S = R.clone().add(Number(f), "hour"), u = t.point([i.lng, i.lat], {
2358
2361
  model: W.model,
2359
2362
  name: O.name,
@@ -2368,7 +2371,7 @@ class V0 {
2368
2371
  category: T,
2369
2372
  type: "forecast"
2370
2373
  });
2371
- d.push(u), Y.push(u.geometry.coordinates);
2374
+ Y.push(u), d.push(u.geometry.coordinates);
2372
2375
  }
2373
2376
  const e = {
2374
2377
  kts: void 0,
@@ -2376,9 +2379,9 @@ class V0 {
2376
2379
  };
2377
2380
  if (A) {
2378
2381
  const f = U(A.updated).utc();
2379
- if (o) {
2380
- const S = r.calculateDistance(A, o), u = U(o.utc || o.updated).diff(f, "h", !0);
2381
- e.kts = Math.round(S / u * 100) / 100, e.deg = r.calculateBearing(A, o, !0, 0);
2382
+ if (q) {
2383
+ const S = r.calculateDistance(A, q), u = U(q.utc || q.updated).diff(f, "h", !0);
2384
+ e.kts = Math.round(S / u * 100) / 100, e.deg = r.calculateBearing(A, q, !0, 0);
2382
2385
  }
2383
2386
  const i = t.point([A.lng, A.lat], {
2384
2387
  model: W.model,
@@ -2395,10 +2398,10 @@ class V0 {
2395
2398
  important: !0
2396
2399
  // 第一个预报点为重要点
2397
2400
  });
2398
- d.unshift(i), Y.unshift(i.geometry.coordinates);
2401
+ Y.unshift(i), d.unshift(i.geometry.coordinates);
2399
2402
  }
2400
- if (z.features.push(...d), (Y == null ? void 0 : Y.length) > 1) {
2401
- const f = t.lineString(a.convertToMonotonicLng2(Y), {
2403
+ if (z.features.push(...Y), (d == null ? void 0 : d.length) > 1) {
2404
+ const f = t.lineString(a.convertToMonotonicLng2(d), {
2402
2405
  date: (A == null ? void 0 : A.updated) || (R == null ? void 0 : R.format()),
2403
2406
  id: O.id || O.name,
2404
2407
  model: W.model,
@@ -2411,11 +2414,11 @@ class V0 {
2411
2414
  }
2412
2415
  }
2413
2416
  }
2414
- if (z.features.sort((W, o) => W.properties.type === "forecast" && o.properties.type === "forecast" && W.geometry.type === "Point" && o.geometry.type === "Point" ? U(W.properties.date).valueOf() - U(o.properties.date).valueOf() : 0), (b = O.history) != null && b.length) {
2415
- const W = [], o = U(A == null ? void 0 : A.updated).utc(), Y = U((c = O.history) == null ? void 0 : c.at(-1).updated).utc(), d = o.diff(Y, "h") % 24 > 2 ? 24 : 12;
2417
+ if (z.features.sort((W, q) => W.properties.type === "forecast" && q.properties.type === "forecast" && W.geometry.type === "Point" && q.geometry.type === "Point" ? U(W.properties.date).valueOf() - U(q.properties.date).valueOf() : 0), (b = O.history) != null && b.length) {
2418
+ const W = [], q = U(A == null ? void 0 : A.updated).utc(), d = U((c = O.history) == null ? void 0 : c.at(-1).updated).utc(), Y = q.diff(d, "h") % 24 > 2 ? 24 : 12;
2416
2419
  for (const R of O.history) {
2417
- const T = U(R.updated).utc(), e = T.isSameOrBefore(o) || T.isSame(Y);
2418
- e && o.add(-d, "h");
2420
+ const T = U(R.updated).utc(), e = T.isSameOrBefore(q) || T.isSame(d);
2421
+ e && q.add(-Y, "h");
2419
2422
  const f = t.point([R.lng, R.lat], {
2420
2423
  name: O.name,
2421
2424
  nameCn: O.nameCn,
@@ -2454,19 +2457,19 @@ class V0 {
2454
2457
  */
2455
2458
  static interpolate(M, z = 3) {
2456
2459
  var c, O, A, W;
2457
- const p = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((o) => o.geometry.type === "LineString" && o.properties.type === "forecast"), b = [];
2458
- for (const o of p) {
2459
- const Y = o.properties.name, d = o.properties.model, R = o.properties.showCircle, T = o.properties.disabled, e = U(o.properties.date).utc();
2460
+ const p = (c = M == null ? void 0 : M.data) == null ? void 0 : c.features.filter((q) => q.geometry.type === "LineString" && q.properties.type === "forecast"), b = [];
2461
+ for (const q of p) {
2462
+ const d = q.properties.name, Y = q.properties.model, R = q.properties.showCircle, T = q.properties.disabled, e = U(q.properties.date).utc();
2460
2463
  let f = z * 60;
2461
2464
  const i = (O = M == null ? void 0 : M.data) == null ? void 0 : O.features.filter(
2462
- (Z) => Z.geometry.type === "Point" && Z.properties.type === "forecast" && Z.properties.category === `${Y}-${d}`
2465
+ (Z) => Z.geometry.type === "Point" && Z.properties.type === "forecast" && Z.properties.category === `${d}-${Y}`
2463
2466
  );
2464
2467
  let S, u = e.clone().add(f, "minute").set({ minute: 0, second: 0, millisecond: 0 });
2465
2468
  for (; S = this.pickIndex(i, u), S <= i.length - 1; ) {
2466
2469
  if (S > 0) {
2467
2470
  const Z = i[S], B = S === 0 ? void 0 : i[S - 1], G = (f / 60 - ((A = B == null ? void 0 : B.properties) == null ? void 0 : A.hour)) / (Z.properties.hour - ((W = B == null ? void 0 : B.properties) == null ? void 0 : W.hour)), Q = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[0], Z.geometry.coordinates[0], G), F = this.computeNumber(B == null ? void 0 : B.geometry.coordinates[1], Z.geometry.coordinates[1], G), $ = t.point([Q, F], {
2468
- name: Y,
2469
- model: d,
2471
+ name: d,
2472
+ model: Y,
2470
2473
  category: Z == null ? void 0 : Z.properties.category,
2471
2474
  date: u.format(),
2472
2475
  format: u.format("MMM-DD/HHmm[Z]"),
@@ -2520,17 +2523,17 @@ class V0 {
2520
2523
  hr: A
2521
2524
  }), {};
2522
2525
  }
2523
- const o = r.calculateBearing(M, c), Y = r.calculateBearing(c, O), d = Math.abs(o - Y);
2526
+ const q = r.calculateBearing(M, c), d = r.calculateBearing(c, O), Y = Math.abs(q - d);
2524
2527
  let R = 0;
2525
- d < 180 ? R = d + 90 : d >= 180 && (R = d - 90);
2528
+ Y < 180 ? R = Y + 90 : Y >= 180 && (R = Y - 90);
2526
2529
  const T = r.calculateCoordinate(c, R, p);
2527
2530
  return I == null || I.info("[%s] the right tangent position: %j", b.requestId, {
2528
2531
  from: M,
2529
2532
  t1: c,
2530
2533
  t2: O,
2531
2534
  radius: p,
2532
- bearing1: o,
2533
- bearing2: Y,
2535
+ bearing1: q,
2536
+ bearing2: d,
2534
2537
  right: T
2535
2538
  }), { at: T, t1: c, t2: O, hr: Number(A), hours: W };
2536
2539
  }
@@ -2559,8 +2562,8 @@ class V0 {
2559
2562
  hr: A
2560
2563
  }), {};
2561
2564
  }
2562
- const o = r.calculateBearing(M, c), Y = r.calculateBearing(c, O), d = r.calculateDistance(M, c);
2563
- return { at: r.calculateCoordinate(c, o - Y + 180, p < d ? p : d), t1: c, t2: O, hr: Number(A), hours: W };
2565
+ const q = r.calculateBearing(M, c), d = r.calculateBearing(c, O), Y = r.calculateDistance(M, c);
2566
+ return { at: r.calculateCoordinate(c, q - d + 180, p < Y ? p : Y), t1: c, t2: O, hr: Number(A), hours: W };
2564
2567
  } else
2565
2568
  return I == null || I.info("[%s] no need drift: %j", b.requestId, { from: M, t1: c, t2: O, hr: A }), {};
2566
2569
  }
@@ -2573,21 +2576,21 @@ class V0 {
2573
2576
  * @private
2574
2577
  */
2575
2578
  static tropicalCenterTwin(M, z = 24, p = {}) {
2576
- var Y, d, R, T, e;
2579
+ var d, Y, R, T, e;
2577
2580
  let b = {};
2578
- (Y = M.forecasts) == null || Y.forEach((f) => {
2581
+ (d = M.forecasts) == null || d.forEach((f) => {
2579
2582
  b = { ...f.hours, ...b };
2580
2583
  });
2581
- const c = ((d = M == null ? void 0 : M.history) == null ? void 0 : d[0]) || (b == null ? void 0 : b[(R = Object.keys(b)) == null ? void 0 : R[0]]);
2584
+ const c = ((Y = M == null ? void 0 : M.history) == null ? void 0 : Y[0]) || (b == null ? void 0 : b[(R = Object.keys(b)) == null ? void 0 : R[0]]);
2582
2585
  I == null || I.info("[%s] the first tropical center: %j", p.requestId, c);
2583
2586
  let O = (T = Object.keys(b || {}).filter((f) => Number(f) <= (z < 0 ? 24 : z))) == null ? void 0 : T.at(-1);
2584
2587
  O || (O = (e = Object.keys(b || {}).filter((f) => Number(f) <= (z < 0 ? 24 : 2 * z))) == null ? void 0 : e.at(-1));
2585
2588
  const A = b == null ? void 0 : b[O || -1];
2586
2589
  I == null || I.info("[%s] the second tropical center: %j in %d hrs", p.requestId, A, O);
2587
- const W = Object.keys(b || {}).filter((f) => Number(f) <= Number(O)), o = { 0: c };
2590
+ const W = Object.keys(b || {}).filter((f) => Number(f) <= Number(O)), q = { 0: c };
2588
2591
  for (const f of W)
2589
- o[f] = b[f];
2590
- return { t1: c, t2: A, hr: Number(O), hours: o };
2592
+ q[f] = b[f];
2593
+ return { t1: c, t2: A, hr: Number(O), hours: q };
2591
2594
  }
2592
2595
  static pickIndex(M, z) {
2593
2596
  let p = 0;