@idm-plugin/vessel 1.5.3 → 1.5.5

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
@@ -1,15 +1,15 @@
1
1
  var st = Object.defineProperty;
2
- var at = (I, s, t) => s in I ? st(I, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : I[s] = t;
3
- var Z = (I, s, t) => (at(I, typeof s != "symbol" ? s + "" : s, t), t);
4
- import A from "got";
2
+ var at = (k, s, t) => s in k ? st(k, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : k[s] = t;
3
+ var Z = (k, s, t) => (at(k, typeof s != "symbol" ? s + "" : s, t), t);
4
+ import O from "got";
5
5
  import z from "@log4js-node/log4js-api";
6
6
  import v from "moment";
7
7
  import { LngLatHelper as B, LaneHelper as V } from "@idm-plugin/geo";
8
8
  import { MeteoHelper2 as ot, MeteoHelper as nt } from "@idm-plugin/meteo2";
9
9
  import { Meteo2Assist as tt } from "@idm-plugin/meteo";
10
- let h;
10
+ let u;
11
11
  try {
12
- h = z.getLogger("vessel");
12
+ u = z.getLogger("vessel");
13
13
  } catch {
14
14
  } finally {
15
15
  }
@@ -19,79 +19,79 @@ class K {
19
19
  * @param status
20
20
  */
21
21
  parseStatus(s) {
22
- let t, o;
22
+ let t, i;
23
23
  switch (s) {
24
24
  case 0:
25
- t = "在航(主机推动)", o = "The engine is in use";
25
+ t = "在航(主机推动)", i = "The engine is in use";
26
26
  break;
27
27
  case 1:
28
- t = "锚泊", o = "Anchored";
28
+ t = "锚泊", i = "Anchored";
29
29
  break;
30
30
  case 2:
31
- t = "失控", o = "Not operated";
31
+ t = "失控", i = "Not operated";
32
32
  break;
33
33
  case 3:
34
- t = "操纵受限", o = "Limited airworthiness";
34
+ t = "操纵受限", i = "Limited airworthiness";
35
35
  break;
36
36
  case 4:
37
- t = "吃水受限", o = "Limited by ship's draft";
37
+ t = "吃水受限", i = "Limited by ship's draft";
38
38
  break;
39
39
  case 5:
40
- t = "靠泊", o = "Mooring";
40
+ t = "靠泊", i = "Mooring";
41
41
  break;
42
42
  case 6:
43
- t = "搁浅", o = "Stranded";
43
+ t = "搁浅", i = "Stranded";
44
44
  break;
45
45
  case 7:
46
- t = "捕捞作业", o = "Engaged in fishing";
46
+ t = "捕捞作业", i = "Engaged in fishing";
47
47
  break;
48
48
  case 8:
49
- t = "靠帆船提供动力", o = "Sailing";
49
+ t = "靠帆船提供动力", i = "Sailing";
50
50
  break;
51
51
  default:
52
- t = "未定义", o = "Undefined";
52
+ t = "未定义", i = "Undefined";
53
53
  }
54
- return { labelCn: t, labelEn: o };
54
+ return { labelCn: t, labelEn: i };
55
55
  }
56
56
  }
57
57
  class bt extends K {
58
- constructor(t, o) {
58
+ constructor(t, i) {
59
59
  super();
60
60
  Z(this, "clientId");
61
61
  Z(this, "clientSecret");
62
62
  Z(this, "token");
63
- this.clientId = t, this.clientSecret = o;
63
+ this.clientId = t, this.clientSecret = i;
64
64
  }
65
65
  async authToken(t = {}) {
66
- const o = "https://svc.data.myvessel.cn/ada/oauth/token", n = {
66
+ const i = "https://svc.data.myvessel.cn/ada/oauth/token", o = {
67
67
  searchParams: {
68
68
  client_id: this.clientId,
69
69
  client_secret: this.clientSecret,
70
70
  grant_type: "client_credentials"
71
71
  }
72
- }, i = await A.post(o, n).json();
73
- h == null || h.info("[%s] fetch access token from: %s - %j", t.requestId, o, i), i.error || (this.token = {
74
- accessToken: i.access_token,
75
- tokenType: i.token_type,
76
- expiresIn: i.expires_in,
77
- scope: i.scope,
78
- jti: i.jti,
72
+ }, n = await O.post(i, o).json();
73
+ u == null || u.info("[%s] fetch access token from: %s - %j", t.requestId, i, n), n.error || (this.token = {
74
+ accessToken: n.access_token,
75
+ tokenType: n.token_type,
76
+ expiresIn: n.expires_in,
77
+ scope: n.scope,
78
+ jti: n.jti,
79
79
  issuedAt: v().utc().format()
80
80
  });
81
81
  }
82
- async realTimePosition(t, o = {}) {
82
+ async realTimePosition(t, i = {}) {
83
83
  var d, f, M;
84
- (!this.token || v().diff(v(this.token.issuedAt), "seconds") > ((d = this.token) == null ? void 0 : d.expiresIn) - 300) && await this.authToken(o);
85
- const n = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", i = {
84
+ (!this.token || v().diff(v(this.token.issuedAt), "seconds") > ((d = this.token) == null ? void 0 : d.expiresIn) - 300) && await this.authToken(i);
85
+ const o = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", n = {
86
86
  headers: {
87
87
  Authorization: `${(f = this.token) == null ? void 0 : f.tokenType} ${(M = this.token) == null ? void 0 : M.accessToken}`
88
88
  },
89
89
  searchParams: { mmsi: t }
90
90
  };
91
- h == null || h.info("[%s] fetch realtime position from: %s - %j", o.requestId, n, i);
92
- const a = await A.get(n, i).json();
91
+ u == null || u.info("[%s] fetch realtime position from: %s - %j", i.requestId, o, n);
92
+ const a = await O.get(o, n).json();
93
93
  if (a.code)
94
- return h == null || h.warn("[%s] fetch realtime position failed: %j", o.requestId, n, { message: a.message, status: a.status, code: a.code }), a;
94
+ return u == null || u.warn("[%s] fetch realtime position failed: %j", i.requestId, o, { message: a.message, status: a.status, code: a.code }), a;
95
95
  const e = a.data;
96
96
  for (const m in e)
97
97
  !isNaN(e[m]) && Number(e[m]) !== 1 / 0 && (e[m] = Number(e[m]));
@@ -121,54 +121,54 @@ class bt extends K {
121
121
  utc: c.utc().format()
122
122
  };
123
123
  }
124
- async trajectory(t, o, n, i, a = !0, e = {}) {
124
+ async trajectory(t, i, o, n, a = !0, e = {}) {
125
125
  (!this.token || v().diff(v(this.token.issuedAt), "seconds") > this.token.expiresIn - 300) && await this.authToken(e);
126
- const c = await this.realTimePosition(t, e), r = v(o), d = v(n), f = [];
126
+ const c = await this.realTimePosition(t, e), r = v(i), d = v(o), f = [];
127
127
  for (; d.diff(r, "day", !0) > 30; )
128
- await this.trajectoryIn30Day(t, r, r.clone().add(30, "day"), c, i, f, e), r.add(30, "day");
129
- return await this.trajectoryIn30Day(t, r, d, c, i, f, e), f;
128
+ await this.trajectoryIn30Day(t, r, r.clone().add(30, "day"), c, n, f, e), r.add(30, "day");
129
+ return await this.trajectoryIn30Day(t, r, d, c, n, f, e), f;
130
130
  }
131
- async trajectoryIn30Day(t, o, n, i, a, e, c = {}) {
132
- var u, Y, j, b, p;
131
+ async trajectoryIn30Day(t, i, o, n, a, e, c = {}) {
132
+ var h, w, I, b, p;
133
133
  const r = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", d = {
134
134
  headers: {
135
- Authorization: `${(u = this.token) == null ? void 0 : u.tokenType} ${(Y = this.token) == null ? void 0 : Y.accessToken}`
135
+ Authorization: `${(h = this.token) == null ? void 0 : h.tokenType} ${(w = this.token) == null ? void 0 : w.accessToken}`
136
136
  },
137
137
  json: {
138
138
  mmsi: t,
139
- startTime: o.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),
140
- endTime: n.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")
139
+ startTime: i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),
140
+ endTime: o.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")
141
141
  }
142
142
  };
143
- h == null || h.info("[%s] fetch trajectory from: %s - %j", c.requestId, r, d);
144
- const f = await A.post(r, d).json();
143
+ u == null || u.info("[%s] fetch trajectory from: %s - %j", c.requestId, r, d);
144
+ const f = await O.post(r, d).json();
145
145
  if (f.code)
146
- return h == null || h.warn("[%s] fetch trajectory failed: %j", c.requestId, r, { message: f.message, status: f.status, code: f.code }), f;
146
+ return u == null || u.warn("[%s] fetch trajectory failed: %j", c.requestId, r, { message: f.message, status: f.status, code: f.code }), f;
147
147
  let M = -1;
148
- const m = v(`${(b = (j = f.data) == null ? void 0 : j[0]) == null ? void 0 : b.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
148
+ const m = v(`${(b = (I = f.data) == null ? void 0 : I[0]) == null ? void 0 : b.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
149
149
  return (p = f.data) == null || p.forEach((l) => {
150
- for (const O in l)
151
- !isNaN(l[O]) && Number(l[O]) !== 1 / 0 && (l[O] = Number(l[O]));
152
- const k = v(`${l.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), w = l.status, { labelCn: y, labelEn: g } = this.parseStatus(w), H = {
150
+ for (const R in l)
151
+ !isNaN(l[R]) && Number(l[R]) !== 1 / 0 && (l[R] = Number(l[R]));
152
+ const Y = v(`${l.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), j = l.status, { labelCn: y, labelEn: g } = this.parseStatus(j), D = {
153
153
  mmsi: l.mmsi,
154
- imo: i == null ? void 0 : i.imo,
154
+ imo: n == null ? void 0 : n.imo,
155
155
  lat: l.lat,
156
156
  lng: l.lon,
157
157
  sog: l.sog,
158
158
  cog: l.cog,
159
159
  hdg: l.hdg,
160
160
  draught: l.draught,
161
- status: w,
161
+ status: j,
162
162
  eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(l.eta) ? v(`${l.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").utc().format() : void 0,
163
163
  destination: l.dest,
164
- positionTime: k.unix(),
164
+ positionTime: Y.unix(),
165
165
  labelCn: y,
166
166
  labelEn: g,
167
167
  method: "trajectory",
168
168
  vendor: "myVessel",
169
- utc: k.utc().format()
170
- }, F = Math.floor(k.diff(m, "minute", !0) / (a || 1));
171
- F !== M && (M = F, e.push(H));
169
+ utc: Y.utc().format()
170
+ }, F = Math.floor(Y.diff(m, "minute", !0) / (a || 1));
171
+ F !== M && (M = F, e.push(D));
172
172
  }), e;
173
173
  }
174
174
  }
@@ -178,17 +178,17 @@ class vt extends K {
178
178
  Z(this, "token");
179
179
  this.token = t;
180
180
  }
181
- async realTimePosition(t, o = {}) {
182
- const n = "https://api.hifleet.com/position/position/get/token", i = {
181
+ async realTimePosition(t, i = {}) {
182
+ const o = "https://api.hifleet.com/position/position/get/token", n = {
183
183
  searchParams: {
184
184
  mmsi: t,
185
185
  usertoken: this.token
186
186
  }
187
- }, a = await A.post(n, i).json();
188
- h == null || h.info("[%s] fetch realtime position from: %s - %j", o.requestId, n, i);
187
+ }, a = await O.post(o, n).json();
188
+ u == null || u.info("[%s] fetch realtime position from: %s - %j", i.requestId, o, n);
189
189
  const e = a == null ? void 0 : a.list;
190
190
  if (!e)
191
- return h == null || h.warn("[%s] fetch realtime position failed: %j", o.requestId, n, a), a;
191
+ return u == null || u.warn("[%s] fetch realtime position failed: %j", i.requestId, o, a), a;
192
192
  for (const m in e)
193
193
  !isNaN(e[m]) && Number(e[m]) !== 1 / 0 && (e[m] = Number(e[m]));
194
194
  e.status = e.sp > 3 ? 0 : 1;
@@ -218,9 +218,9 @@ class vt extends K {
218
218
  vendor: "hifleet"
219
219
  };
220
220
  }
221
- async search(t, o = {}) {
222
- let n = "https://www.hifleet.com/hifleetapi/searchVesselOL.do";
223
- const i = {
221
+ async search(t, i = {}) {
222
+ let o = "https://www.hifleet.com/hifleetapi/searchVesselOL.do";
223
+ const n = {
224
224
  searchParams: {
225
225
  keyword: t
226
226
  },
@@ -230,8 +230,8 @@ class vt extends K {
230
230
  Host: "www.hifleet.com"
231
231
  }
232
232
  };
233
- let a = await A.post(n, i).json();
234
- h == null || h.info("[%s] fetch vessel props from: %s - %j", o.requestId, n, i), a instanceof Array && (a = a[0]);
233
+ let a = await O.post(o, n).json();
234
+ u == null || u.info("[%s] fetch vessel props from: %s - %j", i.requestId, o, n), a instanceof Array && (a = a[0]);
235
235
  for (const c in a)
236
236
  !isNaN(a[c]) && Number(a[c]) !== 1 / 0 && (a[c] = Number(a[c]));
237
237
  const e = {
@@ -243,13 +243,36 @@ class vt extends K {
243
243
  breadth: a.b,
244
244
  draught: a.dr
245
245
  };
246
- return n = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", a = await A.post(n, i).json(), h == null || h.info("[%s] fetch vessel dead weight from: %s - %j", o.requestId, n, i), a instanceof Array && (a = a[0]), a && (e.deadweight = Number(a.dwt)), e;
246
+ return o = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", a = await O.post(o, n).json(), u == null || u.info("[%s] search vessel dead weight from: %s - %j", i.requestId, o, n), a instanceof Array && (a = a[0]), a && (e.deadweight = Number(a.dwt)), e;
247
+ }
248
+ async suggest(t, i = {}) {
249
+ const o = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", n = {
250
+ searchParams: {
251
+ q: t
252
+ },
253
+ headers: {
254
+ Referer: "https://www.hifleet.com",
255
+ Origin: "https://www.hifleet.com",
256
+ Host: "www.hifleet.com"
257
+ }
258
+ }, a = await O.post(o, n).json();
259
+ u == null || u.info("[%s] suggest vessel props from: %s - %j", i.requestId, o, n);
260
+ const e = [];
261
+ for (const c of a)
262
+ e.push({
263
+ mmsi: !c.mmsi || isNaN(c.mmsi) ? null : Number(c.mmsi),
264
+ name: c.name,
265
+ callSign: c.callsign,
266
+ imo: !c.imo || isNaN(c.imo) ? null : Number(c.imo),
267
+ score: c._score
268
+ });
269
+ return e.sort((c, r) => r.score - c.score), e;
247
270
  }
248
- async trajectory(t, o, n, i, a = !0, e = {}) {
249
- var l, k, w;
271
+ async trajectory(t, i, o, n, a = !0, e = {}) {
272
+ var l, Y, j;
250
273
  const c = await this.realTimePosition(t, e);
251
- let r = v(o);
252
- const d = v(n), f = v();
274
+ let r = v(i);
275
+ const d = v(o), f = v();
253
276
  if (a) {
254
277
  let y = d.diff(r, "d", !0);
255
278
  y < 0 ? r = d.clone().subtract(40, "d") : y < 30 ? r.subtract(10, "d") : y < 60 ? r.subtract(5, "d") : r = d.clone().subtract(80, "d"), y = f.diff(d, "d", !0), d.add(y > 10 ? 240 : y * 24, "h");
@@ -261,19 +284,19 @@ class vt extends K {
261
284
  mmsi: t,
262
285
  usertoken: this.token
263
286
  }
264
- }, m = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", u = await A.get(m, M).json();
265
- h == null || h.info("[%s] fetch trajectory from: %s - %j", e.requestId, m, M);
266
- let Y;
267
- u && (Y = ((k = (l = u.ships) == null ? void 0 : l.offors) == null ? void 0 : k.ship) || [], Y.length || h == null || h.warn("[%s] fetch trajectory failed: %j", e.requestId, u));
268
- const j = [];
287
+ }, m = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", h = await O.get(m, M).json();
288
+ u == null || u.info("[%s] fetch trajectory from: %s - %j", e.requestId, m, M);
289
+ let w;
290
+ h && (w = ((Y = (l = h.ships) == null ? void 0 : l.offors) == null ? void 0 : Y.ship) || [], w.length || u == null || u.warn("[%s] fetch trajectory failed: %j", e.requestId, h));
291
+ const I = [];
269
292
  let b = -1;
270
- const p = v(`${(w = Y == null ? void 0 : Y[0]) == null ? void 0 : w.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
271
- for (const y of Y) {
293
+ const p = v(`${(j = w == null ? void 0 : w[0]) == null ? void 0 : j.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
294
+ for (const y of w) {
272
295
  for (const L in y)
273
296
  !isNaN(y[L]) && Number(y[L]) !== 1 / 0 && (y[L] = Number(y[L]));
274
297
  const g = v(`${y.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
275
298
  y.status = y.sp > 4 ? 0 : 1;
276
- const { labelEn: H, labelCn: F } = this.parseStatus(y.status), O = {
299
+ const { labelEn: D, labelCn: F } = this.parseStatus(y.status), R = {
277
300
  mmsi: y.m,
278
301
  name: y.n,
279
302
  imo: c == null ? void 0 : c.imo,
@@ -287,30 +310,30 @@ class vt extends K {
287
310
  utc: g.utc().format(),
288
311
  status: y.status,
289
312
  labelCn: F,
290
- labelEn: H,
313
+ labelEn: D,
291
314
  method: "trajectory",
292
315
  vendor: "hifleet"
293
- }, N = Math.floor(g.diff(p, "minute", !0) / (i || 1));
294
- N !== b && (b = N, j.push(O));
316
+ }, H = Math.floor(g.diff(p, "minute", !0) / (n || 1));
317
+ H !== b && (b = H, I.push(R));
295
318
  }
296
- return j;
319
+ return I;
297
320
  }
298
321
  }
299
- class Yt extends K {
322
+ class wt extends K {
300
323
  constructor(t) {
301
324
  super();
302
325
  Z(this, "token");
303
326
  this.token = t;
304
327
  }
305
- async realTimePosition(t, o = {}) {
306
- const n = {
328
+ async realTimePosition(t, i = {}) {
329
+ const o = {
307
330
  searchParams: {
308
331
  id: t,
309
332
  k: this.token,
310
333
  enc: 1
311
334
  }
312
- }, i = "https://api.shipxy.com/apicall/GetSingleShip", a = await A.get(i, n).json();
313
- if (h == null || h.info("[%s] fetch realtime position from: %s - %j", o.requestId, i, n), (a == null ? void 0 : a.status) !== 0)
335
+ }, n = "https://api.shipxy.com/apicall/GetSingleShip", a = await O.get(n, o).json();
336
+ if (u == null || u.info("[%s] fetch realtime position from: %s - %j", i.requestId, n, o), (a == null ? void 0 : a.status) !== 0)
314
337
  return a;
315
338
  const e = a.data[0];
316
339
  for (const M in e)
@@ -339,9 +362,9 @@ class Yt extends K {
339
362
  vendor: "shipxy"
340
363
  };
341
364
  }
342
- async trajectory(t, o, n, i, a = !0, e = {}) {
365
+ async trajectory(t, i, o, n, a = !0, e = {}) {
343
366
  var p;
344
- const c = await this.realTimePosition(t, e), r = v(o), d = v(n), f = "https://api.shipxy.com/apicall/GetShipTrack", M = {
367
+ const c = await this.realTimePosition(t, e), r = v(i), d = v(o), f = "https://api.shipxy.com/apicall/GetShipTrack", M = {
345
368
  searchParams: {
346
369
  id: t,
347
370
  k: this.token,
@@ -350,60 +373,60 @@ class Yt extends K {
350
373
  btm: r.unix(),
351
374
  etm: d.unix()
352
375
  }
353
- }, m = await A.get(f, M).json();
354
- if (h == null || h.info("[%s] fetch trajectory from: %s - %j", e.requestId, f, M), (m == null ? void 0 : m.status) !== 0)
376
+ }, m = await O.get(f, M).json();
377
+ if (u == null || u.info("[%s] fetch trajectory from: %s - %j", e.requestId, f, M), (m == null ? void 0 : m.status) !== 0)
355
378
  return m;
356
- const u = m == null ? void 0 : m.points, Y = [], j = v.unix((p = u[0]) == null ? void 0 : p.utc);
379
+ const h = m == null ? void 0 : m.points, w = [], I = v.unix((p = h[0]) == null ? void 0 : p.utc);
357
380
  let b = -1;
358
- for (const l of u) {
359
- const k = v.unix(l.utc), w = {
381
+ for (const l of h) {
382
+ const Y = v.unix(l.utc), j = {
360
383
  imo: c == null ? void 0 : c.imo,
361
384
  mmsi: t,
362
385
  sog: Math.round(l.sog * 3600 / 1e3 / 1852 * 100) / 100,
363
386
  cog: Math.round(l.cog / 100 * 100) / 100,
364
387
  lat: Math.round(l.lat / 1e6 * 1e5) / 1e5,
365
388
  lng: Math.round(l.lon / 1e6 * 1e5) / 1e5,
366
- positionTime: k.unix(),
367
- utc: k.utc().format(),
389
+ positionTime: Y.unix(),
390
+ utc: Y.utc().format(),
368
391
  method: "trajectory",
369
392
  vendor: "shipxy"
370
- }, y = Math.floor(k.diff(j, "minute", !0) / (i || 1));
371
- y !== b && (b = y, Y.push(w));
393
+ }, y = Math.floor(Y.diff(I, "minute", !0) / (n || 1));
394
+ y !== b && (b = y, w.push(j));
372
395
  }
373
- return Y;
396
+ return w;
374
397
  }
375
398
  }
376
- class kt extends K {
399
+ class Yt extends K {
377
400
  constructor(t) {
378
401
  super();
379
402
  Z(this, "token");
380
403
  this.token = t;
381
404
  }
382
- async getShipId(t, o = {}) {
383
- const n = {
405
+ async getShipId(t, i = {}) {
406
+ const o = {
384
407
  headers: {
385
408
  appKey: this.token
386
409
  },
387
410
  json: {
388
411
  mmsiList: t
389
412
  }
390
- }, i = "https://api3.myships.com/sp/ships/getShipIdByMMSI", a = await A.post(i, n).json();
391
- return h == null || h.info("[%s] fetch ship id from: %s - %j", o.requestId, i, n), a.code !== "0" ? a : a.data[0].shipId;
413
+ }, n = "https://api3.myships.com/sp/ships/getShipIdByMMSI", a = await O.post(n, o).json();
414
+ return u == null || u.info("[%s] fetch ship id from: %s - %j", i.requestId, n, o), a.code !== "0" ? a : a.data[0].shipId;
392
415
  }
393
- async getShipInfo(t, o = {}) {
394
- const n = {
416
+ async getShipInfo(t, i = {}) {
417
+ const o = {
395
418
  headers: {
396
419
  appKey: this.token
397
420
  },
398
421
  json: {
399
422
  shipId: t
400
423
  }
401
- }, i = "https://api3.myships.com/sp/ships/aissta", a = await A.post(i, n).json();
402
- if (h == null || h.info("[%s] fetch ship info from: %s - %j", o.requestId, i, n), a.code !== "0")
424
+ }, n = "https://api3.myships.com/sp/ships/aissta", a = await O.post(n, o).json();
425
+ if (u == null || u.info("[%s] fetch ship info from: %s - %j", i.requestId, n, o), a.code !== "0")
403
426
  return a;
404
427
  const e = a.data;
405
428
  let c = e.imo;
406
- return t === "407170" && (c = "9198379", h == null || h.warn("[%s] ship(%s) imo error: %s, should be %s", o.requestId, t, e.imo, c)), {
429
+ return t === "407170" && (c = "9198379", u == null || u.warn("[%s] ship(%s) imo error: %s, should be %s", i.requestId, t, e.imo, c)), {
407
430
  mmsi: e.mmsi,
408
431
  name: e.shipnameEn,
409
432
  imo: c,
@@ -413,22 +436,22 @@ class kt extends K {
413
436
  draught: (e.draught || 100) / 10
414
437
  };
415
438
  }
416
- async realTimePosition(t, o = {}) {
417
- const n = await this.getShipId(t, o), i = await this.getShipInfo(n, o), a = {
439
+ async realTimePosition(t, i = {}) {
440
+ const o = await this.getShipId(t, i), n = await this.getShipInfo(o, i), a = {
418
441
  headers: {
419
442
  appKey: this.token
420
443
  },
421
444
  json: {
422
- shipId: n
445
+ shipId: o
423
446
  }
424
- }, e = "https://api3.myships.com/sp/ships/position/latest", c = await A.post(e, a).json();
425
- h == null || h.info("[%s] fetch realtime position from: %s - %j", o.requestId, e, a);
447
+ }, e = "https://api3.myships.com/sp/ships/position/latest", c = await O.post(e, a).json();
448
+ u == null || u.info("[%s] fetch realtime position from: %s - %j", i.requestId, e, a);
426
449
  const r = c.data[0];
427
- for (const u in r)
428
- !isNaN(r[u]) && Number(r[u]) !== 1 / 0 && (r[u] = Number(r[u]));
450
+ for (const h in r)
451
+ !isNaN(r[h]) && Number(r[h]) !== 1 / 0 && (r[h] = Number(r[h]));
429
452
  const { labelCn: d, labelEn: f } = await this.parseStatus(r.aisNavStatus), M = v.unix(r.posTime);
430
453
  return {
431
- ...i,
454
+ ...n,
432
455
  mmsi: t,
433
456
  lat: Math.round(r.lat / 1e4 / 60 * 1e5) / 1e5,
434
457
  lng: Math.round(r.lon / 1e4 / 60 * 1e5) / 1e5,
@@ -445,34 +468,34 @@ class kt extends K {
445
468
  vendor: "myship"
446
469
  };
447
470
  }
448
- async trajectory(t, o, n, i, a = !0, e = {}) {
449
- const c = v(o), r = v(n), d = await this.getShipId(t), f = await this.getShipInfo(d), M = [];
471
+ async trajectory(t, i, o, n, a = !0, e = {}) {
472
+ const c = v(i), r = v(o), d = await this.getShipId(t), f = await this.getShipInfo(d), M = [];
450
473
  for (; r.diff(c, "day", !0) > 30; )
451
- await this.trajectoryIn30Day(d, c.unix(), c.add(30, "day").unix(), f, t, i, M);
452
- return await this.trajectoryIn30Day(d, c.unix(), r.unix(), f, t, i, M), M;
474
+ await this.trajectoryIn30Day(d, c.unix(), c.add(30, "day").unix(), f, t, n, M);
475
+ return await this.trajectoryIn30Day(d, c.unix(), r.unix(), f, t, n, M), M;
453
476
  }
454
- async trajectoryIn30Day(t, o, n, i, a, e, c, r = {}) {
455
- var j;
477
+ async trajectoryIn30Day(t, i, o, n, a, e, c, r = {}) {
478
+ var I;
456
479
  const d = {
457
480
  headers: {
458
481
  appKey: this.token
459
482
  },
460
483
  json: {
461
484
  shipId: t,
462
- startTime: o,
463
- endTime: n
485
+ startTime: i,
486
+ endTime: o
464
487
  }
465
- }, f = "https://api3.myships.com/sp/ships/position/history", M = await A.post(f, d).json();
466
- if (h == null || h.info("[%s] fetch trajectory from: %s - %j", r.requestId, f, d), M.code !== "0")
467
- return h == null || h.warn("[%s] invoke myship trajectory failed: %j", r.requestId, M), M;
488
+ }, f = "https://api3.myships.com/sp/ships/position/history", M = await O.post(f, d).json();
489
+ if (u == null || u.info("[%s] fetch trajectory from: %s - %j", r.requestId, f, d), M.code !== "0")
490
+ return u == null || u.warn("[%s] invoke myship trajectory failed: %j", r.requestId, M), M;
468
491
  const m = M.data;
469
492
  for (const b in m)
470
493
  !isNaN(m[b]) && Number(m[b]) !== 1 / 0 && (m[b] = Number(m[b]));
471
- const u = v.unix((j = m[0]) == null ? void 0 : j.posTime);
472
- let Y = -1;
494
+ const h = v.unix((I = m[0]) == null ? void 0 : I.posTime);
495
+ let w = -1;
473
496
  for (const b of m) {
474
497
  const p = v.unix(b.posTime), l = {
475
- imo: i == null ? void 0 : i.imo,
498
+ imo: n == null ? void 0 : n.imo,
476
499
  mmsi: a,
477
500
  lat: Math.round(b.lat / 1e4 / 60 * 1e5) / 1e5,
478
501
  lng: Math.round(b.lon / 1e4 / 60 * 1e5) / 1e5,
@@ -484,19 +507,19 @@ class kt extends K {
484
507
  utc: p.utc().format(),
485
508
  method: "trajectory",
486
509
  vendor: "myship"
487
- }, k = Math.floor(p.diff(u, "minute", !0) / (e || 1));
488
- k !== Y && (Y = k, c.push(l));
510
+ }, Y = Math.floor(p.diff(h, "minute", !0) / (e || 1));
511
+ Y !== w && (w = Y, c.push(l));
489
512
  }
490
513
  return c;
491
514
  }
492
515
  }
493
- let R;
516
+ let A;
494
517
  try {
495
- R = z.getLogger("vessel");
518
+ A = z.getLogger("vessel");
496
519
  } catch {
497
520
  } finally {
498
521
  }
499
- var it = /* @__PURE__ */ ((I) => (I.NOTICE = "NOTICE", I.WARN = "WARN", I.HEAVY = "HEAVY", I.SEVERE = "SEVERE", I.ERROR = "ERROR", I.FATAL = "FATAL", I))(it || {});
522
+ var it = /* @__PURE__ */ ((k) => (k.NOTICE = "NOTICE", k.WARN = "WARN", k.HEAVY = "HEAVY", k.SEVERE = "SEVERE", k.ERROR = "ERROR", k.FATAL = "FATAL", k))(it || {});
500
523
  class rt {
501
524
  /**
502
525
  * 解析告警规则, 多规则场景
@@ -508,19 +531,19 @@ class rt {
508
531
  */
509
532
  parsePrinciple(s, t = {}) {
510
533
  var e, c, r;
511
- R == null || R.info("[%s] parse rule: %s", t.requestId, s);
512
- const o = new RegExp("(?<=\\[)(.+)(?=])", "g"), n = s.match(o) ? (e = s.match(o)) == null ? void 0 : e[0] : void 0, i = n == null ? void 0 : n.split(";");
513
- if (!i)
534
+ A == null || A.info("[%s] parse rule: %s", t.requestId, s);
535
+ const i = new RegExp("(?<=\\[)(.+)(?=])", "g"), o = s.match(i) ? (e = s.match(i)) == null ? void 0 : e[0] : void 0, n = o == null ? void 0 : o.split(";");
536
+ if (!n)
514
537
  return;
515
538
  const a = {};
516
- for (let d = 0; d < (i == null ? void 0 : i.length); d++) {
517
- const f = (r = (c = i[d].match(o)) == null ? void 0 : c[0]) == null ? void 0 : r.split("],");
539
+ for (let d = 0; d < (n == null ? void 0 : n.length); d++) {
540
+ const f = (r = (c = n[d].match(i)) == null ? void 0 : c[0]) == null ? void 0 : r.split("],");
518
541
  if (d === 0 && !f)
519
- a.scope = i[0];
542
+ a.scope = n[0];
520
543
  else if (f)
521
544
  for (let M = 0, m = f.length; M < m; M++) {
522
- const u = this.parseRule(f[M]);
523
- u && (a[u.level] ? u.key ? a[u.level][u == null ? void 0 : u.key] = u : a[u.level] = u : u.key ? a[u.level] = { [u == null ? void 0 : u.key]: u } : a[u.level] = u);
545
+ const h = this.parseRule(f[M]);
546
+ h && (a[h.level] ? h.key ? a[h.level][h == null ? void 0 : h.key] = h : a[h.level] = h : h.key ? a[h.level] = { [h == null ? void 0 : h.key]: h } : a[h.level] = h);
524
547
  }
525
548
  }
526
549
  return a;
@@ -533,15 +556,15 @@ class rt {
533
556
  */
534
557
  parseRule(s, t = {}) {
535
558
  var a;
536
- R == null || R.info("[%s] parse rule: %s", t.requestId, s), s = s.startsWith("[") ? s : `[${s}`, s = s.endsWith("]") ? s : `${s}]`;
537
- const o = new RegExp("(?<=\\[)(.+?)(?=])", "g"), n = (a = s == null ? void 0 : s.match(o)) == null ? void 0 : a[0], i = n == null ? void 0 : n.split(",");
538
- if (i)
559
+ A == null || A.info("[%s] parse rule: %s", t.requestId, s), s = s.startsWith("[") ? s : `[${s}`, s = s.endsWith("]") ? s : `${s}]`;
560
+ const i = new RegExp("(?<=\\[)(.+?)(?=])", "g"), o = (a = s == null ? void 0 : s.match(i)) == null ? void 0 : a[0], n = o == null ? void 0 : o.split(",");
561
+ if (n)
539
562
  return {
540
- operator: i[0],
541
- number: Number.isNaN(Number(i[1])) ? i[1] : Number(i[1]),
542
- level: i[2],
543
- time: Number(i[3]),
544
- key: i[4]
563
+ operator: n[0],
564
+ number: Number.isNaN(Number(n[1])) ? n[1] : Number(n[1]),
565
+ level: n[2],
566
+ time: Number(n[3]),
567
+ key: n[4]
545
568
  };
546
569
  }
547
570
  /**
@@ -550,26 +573,26 @@ class rt {
550
573
  * @param principle 告警规则
551
574
  * @param options
552
575
  */
553
- checkWeather(s, t, o = {}) {
554
- var u, Y, j, b, p, l, k, w, y, g, H, F, O, N, L;
555
- let n = 0, i = 0, a = 0, e = 0;
556
- const c = Math.round(((Y = (u = t == null ? void 0 : t.SEVERE) == null ? void 0 : u.sigWave) == null ? void 0 : Y.number) * 1.6 * 100) / 100, r = (b = (j = t == null ? void 0 : t.SEVERE) == null ? void 0 : j.sigWave) == null ? void 0 : b.number, d = (l = (p = t == null ? void 0 : t.HEAVY) == null ? void 0 : p.sigWave) == null ? void 0 : l.number, f = Math.round((((w = (k = t == null ? void 0 : t.SEVERE) == null ? void 0 : k.wind) == null ? void 0 : w.number) + 2) * 100) / 100, M = (g = (y = t == null ? void 0 : t.SEVERE) == null ? void 0 : y.wind) == null ? void 0 : g.number, m = (F = (H = t == null ? void 0 : t.HEAVY) == null ? void 0 : H.wind) == null ? void 0 : F.number;
576
+ checkWeather(s, t, i = {}) {
577
+ var h, w, I, b, p, l, Y, j, y, g, D, F, R, H, L;
578
+ let o = 0, n = 0, a = 0, e = 0;
579
+ const c = Math.round(((w = (h = t == null ? void 0 : t.SEVERE) == null ? void 0 : h.sigWave) == null ? void 0 : w.number) * 1.6 * 100) / 100, r = (b = (I = t == null ? void 0 : t.SEVERE) == null ? void 0 : I.sigWave) == null ? void 0 : b.number, d = (l = (p = t == null ? void 0 : t.HEAVY) == null ? void 0 : p.sigWave) == null ? void 0 : l.number, f = Math.round((((j = (Y = t == null ? void 0 : t.SEVERE) == null ? void 0 : Y.wind) == null ? void 0 : j.number) + 2) * 100) / 100, M = (g = (y = t == null ? void 0 : t.SEVERE) == null ? void 0 : y.wind) == null ? void 0 : g.number, m = (F = (D = t == null ? void 0 : t.HEAVY) == null ? void 0 : D.wind) == null ? void 0 : F.number;
557
580
  for (let W = 0; W < (s == null ? void 0 : s.length); W++) {
558
- const T = s[W], P = (N = (O = T == null ? void 0 : T.meteo) == null ? void 0 : O.wave) == null ? void 0 : N.sig, D = (L = T == null ? void 0 : T.meteo) == null ? void 0 : L.wind, E = W ? v(T.eta).diff(v(s[W - 1].eta), "hour", !0) : 0;
559
- e = E > e ? E : e, R == null || R.info("[%s] check sig.wave: %j", o.requestId, { ...P, dgThd4Wv: c, svThd4Wv: r, hvThd4Wv: d }), (P == null ? void 0 : P.height) >= c ? T.isDangerous = !0 : (P == null ? void 0 : P.height) >= r ? T.isSevere = !0 : (P == null ? void 0 : P.height) >= d && (T.isHeavy = !0), R == null || R.info("[%s] check wind: %j", o.requestId, { ...D, dgThd4Wd: f, svThd4Wd: M, hvThd4Wd: m }), (D == null ? void 0 : D.scale) >= f ? (T.isDangerous = !0, delete T.isSevere, delete T.isHeavy) : (D == null ? void 0 : D.scale) > M ? (T.isDangerous || (T.isSevere = !0), delete T.isHeavy) : (D == null ? void 0 : D.scale) === m && !T.isDangerous && !T.isSevere && (T.isHeavy = !0), n += T.isDangerous ? E : 0, i += T.isSevere ? E : 0, a += T.isHeavy ? E : 0;
581
+ const S = s[W], P = (H = (R = S == null ? void 0 : S.meteo) == null ? void 0 : R.wave) == null ? void 0 : H.sig, N = (L = S == null ? void 0 : S.meteo) == null ? void 0 : L.wind, E = W ? v(S.eta).diff(v(s[W - 1].eta), "hour", !0) : 0;
582
+ e = E > e ? E : e, A == null || A.info("[%s] check sig.wave: %j", i.requestId, { ...P, dgThd4Wv: c, svThd4Wv: r, hvThd4Wv: d }), (P == null ? void 0 : P.height) >= c ? S.isDangerous = !0 : (P == null ? void 0 : P.height) >= r ? S.isSevere = !0 : (P == null ? void 0 : P.height) >= d && (S.isHeavy = !0), A == null || A.info("[%s] check wind: %j", i.requestId, { ...N, dgThd4Wd: f, svThd4Wd: M, hvThd4Wd: m }), (N == null ? void 0 : N.scale) >= f ? (S.isDangerous = !0, delete S.isSevere, delete S.isHeavy) : (N == null ? void 0 : N.scale) > M ? (S.isDangerous || (S.isSevere = !0), delete S.isHeavy) : (N == null ? void 0 : N.scale) === m && !S.isDangerous && !S.isSevere && (S.isHeavy = !0), o += S.isDangerous ? E : 0, n += S.isSevere ? E : 0, a += S.isHeavy ? E : 0;
560
583
  }
561
- return n = Math.round(n * 100) / 100, i = Math.round(i * 100) / 100, a = Math.round(a * 100) / 100, e = Math.round(e), { sample: s, dangerous: n, severe: i, heavy: a, step: e < 3 ? 3 : e, wind: { dgThd4Wd: f, svThd4Wd: M, hvThd4Wd: m }, sig: { dgThd4Wv: c, svThd4Wv: r, hvThd4Wv: d } };
584
+ return o = Math.round(o * 100) / 100, n = Math.round(n * 100) / 100, a = Math.round(a * 100) / 100, e = Math.round(e), { sample: s, dangerous: o, severe: n, heavy: a, step: e < 3 ? 3 : e, wind: { dgThd4Wd: f, svThd4Wd: M, hvThd4Wd: m }, sig: { dgThd4Wv: c, svThd4Wv: r, hvThd4Wv: d } };
562
585
  }
563
586
  }
564
- const It = new rt();
565
- let S;
587
+ const kt = new rt();
588
+ let T;
566
589
  try {
567
- S = z.getLogger("vessel");
590
+ T = z.getLogger("vessel");
568
591
  } catch {
569
592
  } finally {
570
593
  }
571
594
  const ct = new ot("", !0);
572
- var dt = /* @__PURE__ */ ((I) => (I.common = "common", I.container = "container", I.tugs = "tugs", I))(dt || {}), ut = /* @__PURE__ */ ((I) => (I.Ballast = "Ballast", I.Laden = "Laden", I))(ut || {}), ht = /* @__PURE__ */ ((I) => (I.Cp = "CP", I.Perf = "Basis", I.Instruct = "Other", I))(ht || {});
595
+ var dt = /* @__PURE__ */ ((k) => (k.common = "common", k.container = "container", k.tugs = "tugs", k))(dt || {}), ut = /* @__PURE__ */ ((k) => (k.Ballast = "Ballast", k.Laden = "Laden", k))(ut || {}), ht = /* @__PURE__ */ ((k) => (k.Cp = "CP", k.Perf = "Basis", k.Instruct = "Other", k))(ht || {});
573
596
  class C {
574
597
  /**
575
598
  * @see https://baike.baidu.com/item/%E6%96%B9%E5%BD%A2%E7%B3%BB%E6%95%B0/4965568?fr=aladdin
@@ -583,10 +606,10 @@ class C {
583
606
  * @param draught 吃水 m
584
607
  * @return [0.55, 0.85]
585
608
  */
586
- static blockCoefficient(s, t, o, n) {
587
- let i = Math.round(s / (t * o * n) * 100) / 100;
588
- i = i < 0.55 ? 0.55 : i > 0.85 ? 0.85 : i;
589
- const a = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85], e = a.map((c) => Math.abs(c - i));
609
+ static blockCoefficient(s, t, i, o) {
610
+ let n = Math.round(s / (t * i * o) * 100) / 100;
611
+ n = n < 0.55 ? 0.55 : n > 0.85 ? 0.85 : n;
612
+ const a = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85], e = a.map((c) => Math.abs(c - n));
590
613
  return a[e.indexOf(Math.min(...e))];
591
614
  }
592
615
  /**
@@ -600,9 +623,9 @@ class C {
600
623
  * @param g 重力加速度 9.80 m/s^2
601
624
  * @return [0.05, 0.30]
602
625
  */
603
- static froudeNumber(s, t, o = 9.8) {
604
- let n = Math.round(Math.sqrt(s * s / (o * t)) * 100) / 100;
605
- return n = n < 0.05 ? 0.05 : n > 0.3 ? 0.3 : n, n;
626
+ static froudeNumber(s, t, i = 9.8) {
627
+ let o = Math.round(Math.sqrt(s * s / (i * t)) * 100) / 100;
628
+ return o = o < 0.05 ? 0.05 : o > 0.3 ? 0.3 : o, o;
606
629
  }
607
630
  /**
608
631
  * 失速修正系數
@@ -611,8 +634,8 @@ class C {
611
634
  * @param loadCondition
612
635
  * @private
613
636
  */
614
- static amendFactor(s, t, o) {
615
- const n = {
637
+ static amendFactor(s, t, i) {
638
+ const o = {
616
639
  0.55: [1.7, -1.4, -7.4],
617
640
  0.6: [2.2, -2.5, -9.7],
618
641
  0.65: [2.6, -3.7, -11.6],
@@ -630,7 +653,7 @@ class C {
630
653
  0.8: [3, -16.3, -21.6],
631
654
  0.85: [3.4, -20.9, 31.8]
632
655
  }[s];
633
- return o === "Laden" && (a = n[s]), a[0] + a[1] * t + a[2] * Math.pow(t, 2);
656
+ return i === "Laden" && (a = o[s]), a[0] + a[1] * t + a[2] * Math.pow(t, 2);
634
657
  }
635
658
  /**
636
659
  * 失速方向因子
@@ -644,8 +667,8 @@ class C {
644
667
  * @private
645
668
  */
646
669
  static directionFactor(s, t = 0) {
647
- let o;
648
- return s > 30 && s <= 60 ? o = (1.7 - 0.03 * Math.pow(t - 4, 2)) / 2 : s > 60 && s <= 150 ? o = (0.9 - 0.06 * Math.pow(t - 6, 2)) / 2 : s > 150 && s <= 180 ? o = (0.4 - 0.03 * Math.pow(t - 8, 2)) / 2 : o = 1, Math.round(o * 1e5) / 1e5;
670
+ let i;
671
+ return s > 30 && s <= 60 ? i = (1.7 - 0.03 * Math.pow(t - 4, 2)) / 2 : s > 60 && s <= 150 ? i = (0.9 - 0.06 * Math.pow(t - 6, 2)) / 2 : s > 150 && s <= 180 ? i = (0.4 - 0.03 * Math.pow(t - 8, 2)) / 2 : i = 1, Math.round(i * 1e5) / 1e5;
649
672
  }
650
673
  /**
651
674
  * 失速船型因子
@@ -658,10 +681,10 @@ class C {
658
681
  * @param bn
659
682
  * @private
660
683
  */
661
- static vesselTagFactor(s, t, o, n = 0) {
662
- n = n > 6 ? n - 0.9 * (n - 6) : n;
663
- let i;
664
- return o === "container" ? i = 0.7 * n + Math.pow(n, 6.5) / (22 * Math.pow(s, 2 / 3)) : t === "Ballast" ? i = 0.7 * n + Math.pow(n, 6.5) / (2.7 * Math.pow(s, 2 / 3)) : i = 0.5 * n + Math.pow(n, 6.5) / (2.7 * Math.pow(s, 2 / 3)), i;
684
+ static vesselTagFactor(s, t, i, o = 0) {
685
+ o = o > 6 ? o - 0.9 * (o - 6) : o;
686
+ let n;
687
+ return i === "container" ? n = 0.7 * o + Math.pow(o, 6.5) / (22 * Math.pow(s, 2 / 3)) : t === "Ballast" ? n = 0.7 * o + Math.pow(o, 6.5) / (2.7 * Math.pow(s, 2 / 3)) : n = 0.5 * o + Math.pow(o, 6.5) / (2.7 * Math.pow(s, 2 / 3)), n;
665
688
  }
666
689
  /**
667
690
  * 浪高影响因子
@@ -670,8 +693,8 @@ class C {
670
693
  */
671
694
  static waveHeightFactor(s, t) {
672
695
  s = s < 0 ? 0.2 : s, s = s > 6 ? s - 0.9 * (s - 6) : s, s = s > 9 ? 9 : s;
673
- let o;
674
- return t > 30 && t <= 60 ? o = -0.6 : t > 60 && t <= 90 ? o = -0.4 : t > 90 && t <= 120 ? o = s < 3 ? 0.4 : -0.3 : t > 120 && t <= 150 ? o = s < 3 ? 0.6 : -0.5 : t > 150 && t <= 180 ? o = s < 3 ? 0.7 : -0.6 : o = -0.7, Math.round(o * (0.144 * Math.pow(s, 2) + 0.178 * s) * 1e4) / 1e4;
696
+ let i;
697
+ return t > 30 && t <= 60 ? i = -0.6 : t > 60 && t <= 90 ? i = -0.4 : t > 90 && t <= 120 ? i = s < 3 ? 0.4 : -0.3 : t > 120 && t <= 150 ? i = s < 3 ? 0.6 : -0.5 : t > 150 && t <= 180 ? i = s < 3 ? 0.7 : -0.6 : i = -0.7, Math.round(i * (0.144 * Math.pow(s, 2) + 0.178 * s) * 1e4) / 1e4;
675
698
  }
676
699
  /**
677
700
  * 组装船舶运行参数
@@ -681,21 +704,21 @@ class C {
681
704
  * @param bearing 方位角
682
705
  * @private
683
706
  */
684
- static assembleProperties(s, t, o, n) {
707
+ static assembleProperties(s, t, i, o) {
685
708
  var M;
686
- const i = s.lbp ?? s.length ?? s.lengthOverall ?? 198.9642, a = s.draught ?? 8, e = s.breadthMoulded ?? s.breadth ?? s.breadthExtreme ?? 32.4572, c = s.deadweight ?? 67035.7773, r = ((M = s == null ? void 0 : s.type) == null ? void 0 : M.toLowerCase()) || "common";
709
+ const n = s.lbp ?? s.length ?? s.lengthOverall ?? 198.9642, a = s.draught ?? 8, e = s.breadthMoulded ?? s.breadth ?? s.breadthExtreme ?? 32.4572, c = s.deadweight ?? 67035.7773, r = ((M = s == null ? void 0 : s.type) == null ? void 0 : M.toLowerCase()) || "common";
687
710
  return {
688
711
  tag: r.indexOf("container") > -1 ? "container" : r.indexOf("tugs") > -1 ? "tugs" : "common",
689
- lbp: i,
712
+ lbp: n,
690
713
  loadCondition: t,
691
714
  draught: a,
692
715
  breadthMoulded: e,
693
716
  // 排水量(吨)= 载重量(吨)/ 1.025 + 吃水(米)× 船舶型宽(米)× 船舶型长(米)× 0.7
694
717
  // 其中,1.025是指海水的密度,吨是指公吨,吃水是指船舶的最大吃水深度。船舶型宽是指船舶的最大型宽,船舶型长是指船舶的设计型长。上述公式是针对常规船舶适用的,不同类型的船舶可能会有一些差异。
695
- displacement: Math.round((c / 1.025 + a * e * i * 0.7) * 1e4) / 1e4,
718
+ displacement: Math.round((c / 1.025 + a * e * n * 0.7) * 1e4) / 1e4,
696
719
  // 换算为m/s
697
- speed: Math.round((o ?? 14.1382) * 1852 / 3600 * 1e4) / 1e4,
698
- bearing: n || 90
720
+ speed: Math.round((i ?? 14.1382) * 1852 / 3600 * 1e4) / 1e4,
721
+ bearing: o || 90
699
722
  };
700
723
  }
701
724
  /**
@@ -708,35 +731,35 @@ class C {
708
731
  * @param useMeteo true 启用气象分析
709
732
  * @param useRouteParam true 启用设置速度
710
733
  */
711
- static async speedLoseAt(s, t, o, n = "", i = 2, a = !0, e = !1, c = {}) {
734
+ static async speedLoseAt(s, t, i, o = "", n = 2, a = !0, e = !1, c = {}) {
712
735
  let r;
713
736
  if (t.velocity && e && (s.speed = B.roundPrecision(t.velocity * 1852 / 3600, 6)), a) {
714
737
  let d;
715
738
  if (c.meteo2)
716
739
  try {
717
- const u = await ct.spotForecast(t.lat, t.lng, o.utc().format(), !1, !1, !0, c), [Y] = tt.pickHourly(u, o);
718
- d = tt.toLegacy(Y);
719
- } catch (u) {
720
- S.warn("[%s] meteo2 spot(%j) forecast failed: %s", c.requestId, { ...t, eta: o.utc().format() }, u);
740
+ const h = await ct.spotForecast(t.lat, t.lng, i.utc().format(), !1, !1, !0, c), [w] = tt.pickHourly(h, i);
741
+ d = tt.toLegacy(w);
742
+ } catch (h) {
743
+ T.warn("[%s] meteo2 spot(%j) forecast failed: %s", c.requestId, { ...t, eta: i.utc().format() }, h);
721
744
  }
722
745
  else
723
- d = await nt.queryPointFactor(t.lng, t.lat, o.valueOf(), "wind,wave,current,watertemp", n, c);
724
- const f = C.weatherFactor(s, d), M = C.currentFactor(s.bearing, d == null ? void 0 : d.current, i), m = Math.round((s.speed * 1.943844 + f + M) * 100) / 100;
746
+ d = await nt.queryPointFactor(t.lng, t.lat, i.valueOf(), "wind,wave,current,watertemp", o, c);
747
+ const f = C.weatherFactor(s, d), M = C.currentFactor(s.bearing, d == null ? void 0 : d.current, n), m = Math.round((s.speed * 1.943844 + f + M) * 100) / 100;
725
748
  r = {
726
749
  meteo: { ...d },
727
750
  wxFactor: f,
728
751
  cFactor: M,
729
752
  speed: t.velocity && e ? t.velocity : m < 0 ? 1 : m,
730
- eta: o.utc().format("YYYY-MM-DDTHH:mm[Z]"),
731
- etd: o.utc().format("YYYY-MM-DDTHH:mm[Z]")
753
+ eta: i.utc().format("YYYY-MM-DDTHH:mm[Z]"),
754
+ etd: i.utc().format("YYYY-MM-DDTHH:mm[Z]")
732
755
  };
733
756
  } else
734
757
  r = {
735
758
  wxFactor: 0,
736
759
  cFactor: 0,
737
760
  speed: t.velocity && e ? t.velocity : Math.round((s.speed * 1.943844 + 0 + 0) * 100) / 100,
738
- eta: o.utc().format("YYYY-MM-DDTHH:mm[Z]"),
739
- etd: o.utc().format("YYYY-MM-DDTHH:mm[Z]")
761
+ eta: i.utc().format("YYYY-MM-DDTHH:mm[Z]"),
762
+ etd: i.utc().format("YYYY-MM-DDTHH:mm[Z]")
740
763
  };
741
764
  return delete t.meteo, delete t.wxFactor, delete t.cFactor, delete t.speed, delete t.etd, { ...r, ...t };
742
765
  }
@@ -753,53 +776,53 @@ class C {
753
776
  * @param useRouteParam true 启用航线上设置的参数 { suspend: 停留时长(小时), velocity: 速度(kts)}
754
777
  * @private
755
778
  */
756
- static async speedLoseInHoursStep(s, t, o, n, i, a, e = "", c = !0, r = !1, d = {}) {
779
+ static async speedLoseInHoursStep(s, t, i, o, n, a, e = "", c = !0, r = !1, d = {}) {
757
780
  t.utc();
758
781
  const f = [], M = [];
759
- let m = 0, u = 0, Y, j;
782
+ let m = 0, h = 0, w, I;
760
783
  for (let b = 0; b < a.length - 1; b++) {
761
784
  let p = a[b];
762
- p.distanceFromStart = i + u;
785
+ p.distanceFromStart = n + h;
763
786
  const l = a[b + 1];
764
787
  if (s.bearing = V.calculateBearing(p, l, !l.gcToPrevious), p.bearing = s.bearing, p.suspend && r) {
765
788
  p.eta = p.eta || t.format("YYYY-MM-DDTHH:mm[Z]"), p.elapsed = p.elapsed ?? 0;
766
789
  const y = p.suspend - p.elapsed;
767
- if (n - m > y)
768
- n = n - m - y, t.add(y, "hour"), p.elapsed = p.suspend;
790
+ if (o - m > y)
791
+ o = o - m - y, t.add(y, "hour"), p.elapsed = p.suspend;
769
792
  else {
770
- const g = n - m;
771
- p.elapsed += g, t.add(g, "hour"), n = 0;
793
+ const g = o - m;
794
+ p.elapsed += g, t.add(g, "hour"), o = 0;
772
795
  }
773
- if (S == null || S.info(`[%s] suspend ${p.elapsed} hours at %j, and remain ${n} hours need to go...`, d.requestId, p), n === 0)
774
- return p.distanceFromPrevious = u, { etd: t, from: j || p, to: p, next: a.filter((g) => g), wps: f, days: M };
796
+ if (T == null || T.info(`[%s] suspend ${p.elapsed} hours at %j, and remain ${o} hours need to go...`, d.requestId, p), o === 0)
797
+ return p.distanceFromPrevious = h, { etd: t, from: I || p, to: p, next: a.filter((g) => g), wps: f, days: M };
775
798
  } else
776
799
  p.suspend = 0;
777
- p = await C.speedLoseAt(s, p, t, e, 0, c, r, d), j = j || p, p.important && f.push(p), t.isSameOrAfter(o) && (M.push(p), o.add(24, "hour"));
778
- const k = V.calculateDistance(p, l, !l.gcToPrevious);
779
- let w = Math.ceil(k / j.speed * 1e4) / 1e4;
780
- if (m + w < n) {
781
- if (m += w, t.add(w, "hour"), delete a[b], S == null || S.info(
782
- `[%s] go to %j from %j with ${k}nm, and cost ${w} hours`,
800
+ p = await C.speedLoseAt(s, p, t, e, 0, c, r, d), I = I || p, p.important && f.push(p), t.isSameOrAfter(i) && (M.push(p), i.add(24, "hour"));
801
+ const Y = V.calculateDistance(p, l, !l.gcToPrevious);
802
+ let j = Math.ceil(Y / I.speed * 1e4) / 1e4;
803
+ if (m + j < o) {
804
+ if (m += j, t.add(j, "hour"), delete a[b], T == null || T.info(
805
+ `[%s] go to %j from %j with ${Y}nm, and cost ${j} hours`,
783
806
  d.requestId,
784
807
  { lat: l.lat, lng: l.lng },
785
- { lat: j.lat, lng: j.lng, etd: j.etd }
786
- ), u += k, a.filter((y) => y).length <= 1) {
787
- Y = l, Y.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), Y.distanceFromPrevious = k, Y.distanceFromStart = i + u, f.push(Y), delete a[b + 1];
808
+ { lat: I.lat, lng: I.lng, etd: I.etd }
809
+ ), h += Y, a.filter((y) => y).length <= 1) {
810
+ w = l, w.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), w.distanceFromPrevious = Y, w.distanceFromStart = n + h, f.push(w), delete a[b + 1];
788
811
  break;
789
812
  }
790
813
  } else {
791
- w = n - m, t.add(w, "hour");
792
- const y = B.roundPrecision(j.speed * w, 4);
793
- Y = V.calculateCoordinate(p, s.bearing, y, "nauticalmiles", !l.gcToPrevious), Y.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), a[b] = Y, S == null || S.info(
794
- `[%s] go to %j from %j with ${y}nm, and cost ${w} hours`,
814
+ j = o - m, t.add(j, "hour");
815
+ const y = B.roundPrecision(I.speed * j, 4);
816
+ w = V.calculateCoordinate(p, s.bearing, y, "nauticalmiles", !l.gcToPrevious), w.eta = t.format("YYYY-MM-DDTHH:mm[Z]"), a[b] = w, T == null || T.info(
817
+ `[%s] go to %j from %j with ${y}nm, and cost ${j} hours`,
795
818
  d.requestId,
796
- { lat: Y.lat, lng: Y.lng },
819
+ { lat: w.lat, lng: w.lng },
797
820
  { lat: p.lat, lng: p.lng, etd: p.etd }
798
- ), u += y, Y.distanceFromPrevious = u, Y.distanceFromStart = i + u;
821
+ ), h += y, w.distanceFromPrevious = h, w.distanceFromStart = n + h;
799
822
  break;
800
823
  }
801
824
  }
802
- return { etd: t, from: j, to: Y, next: a.filter((b) => b), wps: f, days: M };
825
+ return { etd: t, from: I, to: w, next: a.filter((b) => b), wps: f, days: M };
803
826
  }
804
827
  /**
805
828
  * 洋流影响因子
@@ -807,12 +830,12 @@ class C {
807
830
  * @param current 洋流要素
808
831
  * @param role 1: 船东, 2: 租家, 0: 未知
809
832
  */
810
- static currentFactor(s, t, o = 0) {
811
- const n = (s - (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
812
- if (Math.abs(n) === Math.PI / 2)
833
+ static currentFactor(s, t, i = 0) {
834
+ const o = (s - (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
835
+ if (Math.abs(o) === Math.PI / 2)
813
836
  return 0;
814
- let i = ((t == null ? void 0 : t.kts) || 0) * Math.cos(n);
815
- return o & 2 ? i = Math.ceil(i * 100) / 100 : o & 1 ? i = Math.floor(i * 100) / 100 : i = Math.round(i * 100) / 100, Math.abs(i) > 5 ? 0 : i;
837
+ let n = ((t == null ? void 0 : t.kts) || 0) * Math.cos(o);
838
+ return i & 2 ? n = Math.ceil(n * 100) / 100 : i & 1 ? n = Math.floor(n * 100) / 100 : n = Math.round(n * 100) / 100, Math.abs(n) > 5 ? 0 : n;
816
839
  }
817
840
  /**
818
841
  * 风浪影响因子
@@ -820,16 +843,16 @@ class C {
820
843
  * @param wwc 气象要素
821
844
  */
822
845
  static weatherFactor(s, t) {
823
- var f, M, m, u, Y, j, b;
824
- S == null || S.debug("calculate weather factor via: %j", { ...s, ...t });
825
- const o = C.blockCoefficient(s.displacement, s.lbp, s.breadthMoulded, s.draught), n = C.froudeNumber(s.speed, s.lbp), i = C.amendFactor(o, n, s.loadCondition);
846
+ var f, M, m, h, w, I, b;
847
+ T == null || T.debug("calculate weather factor via: %j", { ...s, ...t });
848
+ const i = C.blockCoefficient(s.displacement, s.lbp, s.breadthMoulded, s.draught), o = C.froudeNumber(s.speed, s.lbp), n = C.amendFactor(i, o, s.loadCondition);
826
849
  let a = Math.abs(s.bearing % 360 - (((f = t == null ? void 0 : t.wind) == null ? void 0 : f.degree) % 360 || 0));
827
850
  a = a > 180 ? 360 - a : a;
828
851
  const e = C.directionFactor(a, (M = t == null ? void 0 : t.wind) == null ? void 0 : M.scale), c = C.vesselTagFactor(s.displacement, s.loadCondition, s.tag, (m = t == null ? void 0 : t.wind) == null ? void 0 : m.scale);
829
- let r = e * i * c / 100 * s.speed;
830
- r = Math.round(r * 1.943844 * 1e4) / 1e4 * -1, s.tag === "tugs" && Math.abs(r) > 1 && (r = r / (Math.abs(Math.round(r)) + 1)), S == null || S.debug("wind wx factor = %d", r), a = Math.abs(s.bearing % 360 - (((Y = (u = t == null ? void 0 : t.wave) == null ? void 0 : u.sig) == null ? void 0 : Y.degree) % 360 || 0));
831
- const d = C.waveHeightFactor(((b = (j = t == null ? void 0 : t.wave) == null ? void 0 : j.sig) == null ? void 0 : b.height) ?? 1, a);
832
- return S == null || S.debug("wave wx factor = %d", d), r = r * 0.4 + d, S == null || S.debug("weather factor = %d", r), r = Math.abs(r) > 4 ? 4 * (Math.abs(r) / r) + Math.abs(r) / r * (Math.abs(r) - 4) * 0.1 : r, Math.round((r || 0) * 100) / 100;
852
+ let r = e * n * c / 100 * s.speed;
853
+ r = Math.round(r * 1.943844 * 1e4) / 1e4 * -1, s.tag === "tugs" && Math.abs(r) > 1 && (r = r / (Math.abs(Math.round(r)) + 1)), T == null || T.debug("wind wx factor = %d", r), a = Math.abs(s.bearing % 360 - (((w = (h = t == null ? void 0 : t.wave) == null ? void 0 : h.sig) == null ? void 0 : w.degree) % 360 || 0));
854
+ const d = C.waveHeightFactor(((b = (I = t == null ? void 0 : t.wave) == null ? void 0 : I.sig) == null ? void 0 : b.height) ?? 1, a);
855
+ return T == null || T.debug("wave wx factor = %d", d), r = r * 0.4 + d, T == null || T.debug("weather factor = %d", r), r = Math.abs(r) > 4 ? 4 * (Math.abs(r) / r) + Math.abs(r) / r * (Math.abs(r) - 4) * 0.1 : r, Math.round((r || 0) * 100) / 100;
833
856
  }
834
857
  /**
835
858
  * 全程失速分析(走完航程)
@@ -843,61 +866,61 @@ class C {
843
866
  * @param useMeteo true 启用气象分析
844
867
  * @param useRouteParam
845
868
  */
846
- static async analyseInstant(s, t, o, n, i, a = "", e = 0, c = !0, r = !1, d = {}) {
869
+ static async analyseInstant(s, t, i, o, n, a = "", e = 0, c = !0, r = !1, d = {}) {
847
870
  var E, G, U, J, Q;
848
871
  const f = v().valueOf();
849
872
  s.lng = B.convertToStdLng(s.lng);
850
- const { route: M, waypoints: m } = i.points, u = V.calculateSubRoute(s, M);
851
- if (((E = u[0]) == null ? void 0 : E.length) <= 1)
873
+ const { route: M, waypoints: m } = n.points, h = V.calculateSubRoute(s, M);
874
+ if (((E = h[0]) == null ? void 0 : E.length) <= 1)
852
875
  return;
853
- const { v0: Y, label: j } = s.sog ? {
876
+ const { v0: w, label: I } = s.sog ? {
854
877
  v0: s.sog,
855
878
  label: "Other"
856
879
  /* Instruct */
857
880
  } : {
858
- v0: n.speed,
881
+ v0: o.speed,
859
882
  label: "CP"
860
883
  /* Cp */
861
- }, b = C.assembleProperties(o, n.loadCondition, Y, 0), p = m.length ? V.calculateSubWaypoints(s, m) : [];
884
+ }, b = C.assembleProperties(i, o.loadCondition, w, 0), p = m.length ? V.calculateSubWaypoints(s, m) : [];
862
885
  p.forEach((x) => x.important = !0);
863
886
  const l = {
864
887
  from: { ...s },
865
- route: u,
888
+ route: h,
866
889
  waypoints: p,
867
- v0: Y,
868
- label: j
869
- }, k = {
890
+ v0: w,
891
+ label: I
892
+ }, Y = {
870
893
  hours: [],
871
894
  days: [],
872
895
  wps: []
873
896
  };
874
- e || (V.calculateRouteDistance(u) / n.speed <= 72 ? e = 3 : e = 6);
875
- let w = V.simplifyRouteToCoordinates(u, p, 0), y = 0, g = 0, H = 0, F = 0;
897
+ e || (V.calculateRouteDistance(h) / o.speed <= 72 ? e = 3 : e = 6);
898
+ let j = V.simplifyRouteToCoordinates(h, p, 0), y = 0, g = 0, D = 0, F = 0;
876
899
  t = v(t).utc();
877
- const O = t.clone();
878
- for (; w.length > 0; ) {
900
+ const R = t.clone();
901
+ for (; j.length > 0; ) {
879
902
  const x = e - t.hour() % e, _ = Math.ceil(t.clone().add(x, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, q = await C.speedLoseInHoursStep(
880
903
  b,
881
904
  t,
882
- O,
905
+ R,
883
906
  _,
884
907
  y,
885
- w,
908
+ j,
886
909
  a,
887
910
  c,
888
911
  r,
889
912
  d
890
913
  );
891
- (G = q.from) != null && G.speed && (k.hours.push(q.from), k.wps.push(...q.wps), k.days.push(...q.days)), w = q == null ? void 0 : q.next, w.length || k.hours.push(q == null ? void 0 : q.to), y += ((U = q == null ? void 0 : q.to) == null ? void 0 : U.distanceFromPrevious) ?? 0;
914
+ (G = q.from) != null && G.speed && (Y.hours.push(q.from), Y.wps.push(...q.wps), Y.days.push(...q.days)), j = q == null ? void 0 : q.next, j.length || Y.hours.push(q == null ? void 0 : q.to), y += ((U = q == null ? void 0 : q.to) == null ? void 0 : U.distanceFromPrevious) ?? 0;
892
915
  }
893
- const N = k.hours;
894
- for (let x = 0; x < N.length - 1; x++) {
895
- const _ = v(N[x + 1].eta).diff(N[x].etd, "hour", !0) || 1;
896
- g += (N[x].wxFactor || 0) * _, H += (N[x].cFactor || 0) * _, F += _;
916
+ const H = Y.hours;
917
+ for (let x = 0; x < H.length - 1; x++) {
918
+ const _ = v(H[x + 1].eta).diff(H[x].etd, "hour", !0) || 1;
919
+ g += (H[x].wxFactor || 0) * _, D += (H[x].cFactor || 0) * _, F += _;
897
920
  }
898
- (J = k.wps) == null || J.forEach((x, _) => {
921
+ (J = Y.wps) == null || J.forEach((x, _) => {
899
922
  if (_) {
900
- const q = k.wps[_ - 1], et = x.distanceFromStart - q.distanceFromStart, X = v(x.eta).diff(v(q.etd), "h", !0);
923
+ const q = Y.wps[_ - 1], et = x.distanceFromStart - q.distanceFromStart, X = v(x.eta).diff(v(q.etd), "h", !0);
901
924
  if (X < 1)
902
925
  x.avgSpd = q.speed;
903
926
  else {
@@ -906,11 +929,11 @@ class C {
906
929
  x.avgSpd = x.avgSpd > $ ? $ : x.avgSpd;
907
930
  }
908
931
  }
909
- }), l.sample = k;
910
- const L = k.hours.at(0), W = k.hours.at(-1);
911
- l.distance = Math.round(W.distanceFromStart * 1e4) / 1e4, l.etd = v(L.eta).utc().format(), l.eta = v(W.eta).utc().format(), l.wxFactor = Math.round(g / F * 1e4) / 1e4, l.cFactor = Math.round(H / F * 1e4) / 1e4, l.avgSpeed = Math.round(W.distanceFromStart / F * 1e4) / 1e4, l.totalHrs = Math.round(F * 1e4) / 1e4, l.totalFoCons = Math.round((n == null ? void 0 : n.fo) / 24 * l.totalHrs * 1e3) / 1e3, l.totalDgoCons = Math.round((n == null ? void 0 : n.dgo) / 24 * l.totalHrs * 1e3) / 1e3;
912
- const P = v().valueOf() - f, D = ((Q = k == null ? void 0 : k.hours) == null ? void 0 : Q.length) || 1;
913
- return S == null || S.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", d == null ? void 0 : d.requestId, P, D, Math.round(P / D * 1e3) / 1e3), l;
932
+ }), l.sample = Y;
933
+ const L = Y.hours.at(0), W = Y.hours.at(-1);
934
+ l.distance = Math.round(W.distanceFromStart * 1e4) / 1e4, l.etd = v(L.eta).utc().format(), l.eta = v(W.eta).utc().format(), l.wxFactor = Math.round(g / F * 1e4) / 1e4, l.cFactor = Math.round(D / F * 1e4) / 1e4, l.avgSpeed = Math.round(W.distanceFromStart / F * 1e4) / 1e4, l.totalHrs = Math.round(F * 1e4) / 1e4, l.totalFoCons = Math.round((o == null ? void 0 : o.fo) / 24 * l.totalHrs * 1e3) / 1e3, l.totalDgoCons = Math.round((o == null ? void 0 : o.dgo) / 24 * l.totalHrs * 1e3) / 1e3;
935
+ const P = v().valueOf() - f, N = ((Q = Y == null ? void 0 : Y.hours) == null ? void 0 : Q.length) || 1;
936
+ return T == null || T.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", d == null ? void 0 : d.requestId, P, N, Math.round(P / N * 1e3) / 1e3), l;
914
937
  }
915
938
  /**
916
939
  * 分段失速分析(最多走hours 小时)
@@ -925,36 +948,36 @@ class C {
925
948
  * @param useMeteo true 启用气象分析
926
949
  * @param useRouteParam
927
950
  */
928
- static async analyseInstantWithThreshed(s, t, o, n, i, a, e, c = "", r = 3, d = !0, f = !1, M = {}) {
929
- var W, T, P;
951
+ static async analyseInstantWithThreshed(s, t, i, o, n, a, e, c = "", r = 3, d = !0, f = !1, M = {}) {
952
+ var W, S, P;
930
953
  s.lng = B.convertToStdLng(s.lng);
931
- const { v0: m, label: u } = s.sog ? {
954
+ const { v0: m, label: h } = s.sog ? {
932
955
  v0: s.sog,
933
956
  label: "Other"
934
957
  /* Instruct */
935
958
  } : {
936
- v0: i.speed,
959
+ v0: n.speed,
937
960
  label: "CP"
938
961
  /* Cp */
939
- }, Y = C.assembleProperties(n, i.loadCondition, m, 0), j = V.calculateSubRoute(s, a);
940
- if (((W = j[0]) == null ? void 0 : W.length) <= 1)
962
+ }, w = C.assembleProperties(o, n.loadCondition, m, 0), I = V.calculateSubRoute(s, a);
963
+ if (((W = I[0]) == null ? void 0 : W.length) <= 1)
941
964
  return;
942
965
  const b = e.length ? V.calculateSubWaypoints(s, e) : [];
943
- b.forEach((D) => D.important = !0);
944
- let p = V.simplifyRouteToCoordinates(j, b, 0), l = 0, k = 0, w = 0, y = 0, g;
945
- const H = {
966
+ b.forEach((N) => N.important = !0);
967
+ let p = V.simplifyRouteToCoordinates(I, b, 0), l = 0, Y = 0, j = 0, y = 0, g;
968
+ const D = {
946
969
  hours: [],
947
970
  wps: [],
948
971
  days: []
949
972
  };
950
973
  for (t = v(t).utc(); p.length > 0; ) {
951
- const D = r - t.hour() % r;
952
- let E = Math.ceil(t.clone().add(D, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
953
- if (E = t.clone().add(E, "h").isAfter(o) ? o.diff(t, "h", !0) * 1e4 / 1e4 : E, E)
974
+ const N = r - t.hour() % r;
975
+ let E = Math.ceil(t.clone().add(N, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
976
+ if (E = t.clone().add(E, "h").isAfter(i) ? i.diff(t, "h", !0) * 1e4 / 1e4 : E, E)
954
977
  g = await C.speedLoseInHoursStep(
955
- Y,
978
+ w,
956
979
  t,
957
- o.clone(),
980
+ i.clone(),
958
981
  E,
959
982
  l,
960
983
  p,
@@ -962,34 +985,34 @@ class C {
962
985
  d,
963
986
  f,
964
987
  M
965
- ), (T = g.from) != null && T.speed && (H.hours.push(g.from), g != null && g.wps && H.wps.push(...g.wps), H.days.push(...g.days)), p = g == null ? void 0 : g.next, p.length || (H.hours.push(g == null ? void 0 : g.to), g != null && g.wps && H.wps.push(...g.wps), H.days.push(g == null ? void 0 : g.to)), l += ((P = g == null ? void 0 : g.to) == null ? void 0 : P.distanceFromPrevious) ?? 0;
988
+ ), (S = g.from) != null && S.speed && (D.hours.push(g.from), g != null && g.wps && D.wps.push(...g.wps), D.days.push(...g.days)), p = g == null ? void 0 : g.next, p.length || (D.hours.push(g == null ? void 0 : g.to), g != null && g.wps && D.wps.push(...g.wps), D.days.push(g == null ? void 0 : g.to)), l += ((P = g == null ? void 0 : g.to) == null ? void 0 : P.distanceFromPrevious) ?? 0;
966
989
  else {
967
- g && (H.hours.push(g.to), g != null && g.wps && H.wps.push(...g.wps), H.days.push(g.to));
990
+ g && (D.hours.push(g.to), g != null && g.wps && D.wps.push(...g.wps), D.days.push(g.to));
968
991
  break;
969
992
  }
970
993
  }
971
- const F = H.hours;
972
- for (let D = 0; D < F.length - 1; D++) {
973
- const E = v(F[D + 1].eta).diff(F[D].etd, "hour", !0);
974
- k += F[D].wxFactor * E, w += F[D].cFactor * E, y += E;
994
+ const F = D.hours;
995
+ for (let N = 0; N < F.length - 1; N++) {
996
+ const E = v(F[N + 1].eta).diff(F[N].etd, "hour", !0);
997
+ Y += F[N].wxFactor * E, j += F[N].cFactor * E, y += E;
975
998
  }
976
- const O = H.hours.at(0), N = H.hours.at(-1);
999
+ const R = D.hours.at(0), H = D.hours.at(-1);
977
1000
  return {
978
- sample: H,
979
- distance: Math.round(((N == null ? void 0 : N.distanceFromStart) || 0) * 1e4) / 1e4,
1001
+ sample: D,
1002
+ distance: Math.round(((H == null ? void 0 : H.distanceFromStart) || 0) * 1e4) / 1e4,
980
1003
  // 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
981
- etd: v(O.eta).utc().format(),
982
- eta: v(N == null ? void 0 : N.eta).utc().format(),
983
- wxFactor: Math.round(k / y * 1e4) / 1e4,
984
- cFactor: Math.round(w / y * 1e4) / 1e4,
985
- avgSpeed: Math.round(((N == null ? void 0 : N.distanceFromStart) || 0) / y * 1e4) / 1e4,
1004
+ etd: v(R.eta).utc().format(),
1005
+ eta: v(H == null ? void 0 : H.eta).utc().format(),
1006
+ wxFactor: Math.round(Y / y * 1e4) / 1e4,
1007
+ cFactor: Math.round(j / y * 1e4) / 1e4,
1008
+ avgSpeed: Math.round(((H == null ? void 0 : H.distanceFromStart) || 0) / y * 1e4) / 1e4,
986
1009
  totalHrs: Math.round(y * 1e4) / 1e4,
987
1010
  from: s,
988
- to: N,
989
- route: j,
1011
+ to: H,
1012
+ route: I,
990
1013
  waypoints: b,
991
1014
  v0: m,
992
- label: u
1015
+ label: h
993
1016
  };
994
1017
  }
995
1018
  }
@@ -999,11 +1022,11 @@ export {
999
1022
  it as AlertLevel,
1000
1023
  vt as HifleetImpl,
1001
1024
  ut as LoadCondition,
1002
- kt as MyShipImpl,
1025
+ Yt as MyShipImpl,
1003
1026
  bt as MyVesselImpl,
1004
- Yt as ShipxyImpl,
1027
+ wt as ShipxyImpl,
1005
1028
  C as SpeedHelper,
1006
1029
  ht as SpeedLabel,
1007
1030
  dt as VesselTag,
1008
- It as alertHelper
1031
+ kt as alertHelper
1009
1032
  };