@idm-plugin/vessel 1.7.1 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (function(E,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("got"),require("@log4js-node/log4js-api"),require("moment"),require("@idm-plugin/geo2"),require("@idm-plugin/meteo2"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","got","@log4js-node/log4js-api","moment","@idm-plugin/geo2","@idm-plugin/meteo2","@idm-plugin/meteo"],F):(E=typeof globalThis<"u"?globalThis:E||self,F(E["idm-plugin-rabbitmq"]={},E.got,E["@log4js-node/log4js-api"],E.moment,E["@idm-plugin/geo2"],E["@idm-plugin/meteo2"],E["@idm-plugin/meteo"]))})(this,function(E,F,K,b,N,nt,ot){"use strict";var bt=Object.defineProperty;var gt=(E,F,K)=>F in E?bt(E,F,{enumerable:!0,configurable:!0,writable:!0,value:K}):E[F]=K;var z=(E,F,K)=>(gt(E,typeof F!="symbol"?F+"":F,K),K);let M;try{M=K.getLogger("vessel")}catch{}finally{}class U{parseStatus(e){let t,o;switch(e){case 0:t="在航(主机推动)",o="The engine is in use";break;case 1:t="锚泊",o="Anchored";break;case 2:t="失控",o="Not operated";break;case 3:t="操纵受限",o="Limited airworthiness";break;case 4:t="吃水受限",o="Limited by ship's draft";break;case 5:t="靠泊",o="Mooring";break;case 6:t="搁浅",o="Stranded";break;case 7:t="捕捞作业",o="Engaged in fishing";break;case 8:t="靠帆船提供动力",o="Sailing";break;default:t="未定义",o="Undefined"}return{labelCn:t,labelEn:o}}}class ht extends U{constructor(t,o){super();z(this,"clientId");z(this,"clientSecret");z(this,"token");this.clientId=t,this.clientSecret=o}async authToken(t={}){const o="https://svc.data.myvessel.cn/ada/oauth/token",r={searchParams:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}},n=await F.post(o,r).json();M==null||M.info("[%s] fetch access token from: %s - %j",t.requestId,o,n),n.error||(this.token={accessToken:n.access_token,tokenType:n.token_type,expiresIn:n.expires_in,scope:n.scope,jti:n.jti,issuedAt:b().utc().format()})}async realTimePosition(t,o={}){var u,m,h;(!this.token||b().diff(b(this.token.issuedAt),"seconds")>((u=this.token)==null?void 0:u.expiresIn)-300)&&await this.authToken(o);const r="https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit",n={headers:{Authorization:`${(m=this.token)==null?void 0:m.tokenType} ${(h=this.token)==null?void 0:h.accessToken}`},searchParams:{mmsi:t}};M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,r,n);const a=await F.get(r,n).json();if(a.code)return M==null||M.warn("[%s] fetch realtime position failed: %j",o.requestId,r,{message:a.message,status:a.status,code:a.code}),a;const s=a.data;for(const y in s)!isNaN(s[y])&&Number(s[y])!==1/0&&(s[y]=Number(s[y]));const d=b(`${s.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:s.mmsi,name:s.vesselName,imo:s.imo,callSign:s.callsign,lat:s.lat,lng:s.lon,length:s.length,width:s.width,draught:s.currDraught,sog:s.sog,cog:s.cog,hdg:s.hdg,rot:s.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta)?b.utc(s.eta).format():void 0,destination:s.dest,positionTime:d.unix(),status:s.status,labelCn:s.statusNameCn,labelEn:s.statusNameEn,method:"position",vendor:"myVessel",utc:d.utc().format()}}async trajectory(t,o,r,n,a=!0,s={}){(!this.token||b().diff(b(this.token.issuedAt),"seconds")>this.token.expiresIn-300)&&await this.authToken(s);const d=await this.realTimePosition(t,s),c=b(o),u=b(r),m=[];for(;u.diff(c,"day",!0)>30;)await this.trajectoryIn30Day(t,c,c.clone().add(30,"day"),d,n,m,s),c.add(30,"day");return await this.trajectoryIn30Day(t,c,u,d,n,m,s),m}async trajectoryIn30Day(t,o,r,n,a,s,d={}){var f,S,I,g,v;const c="https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",u={headers:{Authorization:`${(f=this.token)==null?void 0:f.tokenType} ${(S=this.token)==null?void 0:S.accessToken}`},json:{mmsi:t,startTime:o.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),endTime:r.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")}};M==null||M.info("[%s] fetch trajectory from: %s - %j",d.requestId,c,u);const m=await F.post(c,u).json();if(m.code)return M==null||M.warn("[%s] fetch trajectory failed: %j",d.requestId,c,{message:m.message,status:m.status,code:m.code}),m;let h=-1;const y=b(`${(g=(I=m.data)==null?void 0:I[0])==null?void 0:g.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return(v=m.data)==null||v.forEach(i=>{for(const x in i)!isNaN(i[x])&&Number(i[x])!==1/0&&(i[x]=Number(i[x]));const l=b(`${i.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"),j=i.status,{labelCn:p,labelEn:Y}=this.parseStatus(j),k={mmsi:i.mmsi,imo:n==null?void 0:n.imo,lat:i.lat,lng:i.lon,sog:i.sog,cog:i.cog,hdg:i.hdg,draught:i.draught,status:j,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(i.eta)?b(`${i.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00").utc().format():void 0,destination:i.dest,positionTime:l.unix(),labelCn:p,labelEn:Y,method:"trajectory",vendor:"myVessel",utc:l.utc().format()},O=Math.floor(l.diff(y,"minute",!0)/(a||1));O!==h&&(h=O,s.push(k))}),s}}class ft extends U{constructor(t){super();z(this,"token");this.token=t}async realTimePosition(t,o={}){const r="https://api.hifleet.com/position/position/get/token",n={searchParams:{mmsi:t,usertoken:this.token}},a=await F.post(r,n).json();M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,r,n);const s=a==null?void 0:a.list;if(!s)return M==null||M.warn("[%s] fetch realtime position failed: %j",o.requestId,r,a),a;for(const y in s)!isNaN(s[y])&&Number(s[y])!==1/0&&(s[y]=Number(s[y]));s.status=s.sp>3?0:1;const d=s.status,{labelCn:c,labelEn:u}=this.parseStatus(d),m=b(`${s.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:s.m,name:s.n,imo:s.imonumber,callSign:s.callsign,lat:Math.round(s.la/60*1e5)/1e5,lng:Math.round(s.lo/60*1e5)/1e5,length:s.l,width:s.w,draught:s.draught,sog:s.sp,cog:s.co,hdg:s.h,rot:isNaN(s.rot)?0:s.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta)?b.utc(s.eta).format():void 0,destination:s.destination,positionTime:m.unix(),utc:m.utc().format(),status:d,labelCn:c,labelEn:u,method:"position",vendor:"hifleet"}}async search(t,o={}){let r="https://www.hifleet.com/hifleetapi/searchVesselOL.do";const n={searchParams:{keyword:t},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}};let a=await F.post(r,n).json();M==null||M.info("[%s] fetch vessel props from: %s - %j",o.requestId,r,n),a instanceof Array&&(a=a[0]);for(const d in a)!isNaN(a[d])&&Number(a[d])!==1/0&&(a[d]=Number(a[d]));const s={mmsi:a.m,name:a.n,imo:a.i,callSign:a.c,length:a.l,breadth:a.b,draught:a.dr,type:a.t};return r="https://www.hifleet.com/hifleetapi/sameShipSearch.do",a=await F.post(r,n).json(),M==null||M.info("[%s] search vessel dead weight from: %s - %j",o.requestId,r,n),a instanceof Array&&(a=a[0]),a&&(s.deadweight=Number(a.dwt)),s}async suggest(t,o={}){const r="https://www.hifleet.com/hifleetapi/getShipSuggest.do",n={searchParams:{q:t},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}},a=await F.post(r,n).json();M==null||M.info("[%s] suggest vessel props from: %s - %j",o.requestId,r,n);const s=[];for(const d of a)s.push({mmsi:!d.mmsi||isNaN(d.mmsi)?null:Number(d.mmsi),name:d.name,callSign:d.callsign,imo:!d.imo||isNaN(d.imo)?null:Number(d.imo),score:d._score});return s.sort((d,c)=>c.score-d.score),s}async trajectory(t,o,r,n,a=!0,s={}){var i,l,j;const d=await this.realTimePosition(t,s);let c=b(o);const u=b(r),m=b();if(a){let p=u.diff(c,"d",!0);p<0?c=u.clone().subtract(40,"d"):p<30?c.subtract(10,"d"):p<60?c.subtract(5,"d"):c=u.clone().subtract(80,"d"),p=m.diff(u,"d",!0),u.add(p>10?240:p*24,"h")}const h={searchParams:{endtime:u.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),starttime:c.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),mmsi:t,usertoken:this.token}},y="https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",f=await F.get(y,h).json();M==null||M.info("[%s] fetch trajectory from: %s - %j",s.requestId,y,h);let S;f&&(S=((l=(i=f.ships)==null?void 0:i.offors)==null?void 0:l.ship)||[],S.length||M==null||M.warn("[%s] fetch trajectory failed: %j",s.requestId,f));const I=[];let g=-1;const v=b(`${(j=S==null?void 0:S[0])==null?void 0:j.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");for(const p of S){for(const C in p)!isNaN(p[C])&&Number(p[C])!==1/0&&(p[C]=Number(p[C]));const Y=b(`${p.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");p.status=p.sp>4?0:1;const{labelEn:k,labelCn:O}=this.parseStatus(p.status),x={mmsi:p.m,name:p.n,imo:d==null?void 0:d.imo,lat:p.la,lng:p.lo,draught:p.draught,sog:p.sp,cog:p.co,hdg:p.hdg,positionTime:Y.unix(),utc:Y.utc().format(),status:p.status,labelCn:O,labelEn:k,method:"trajectory",vendor:"hifleet"},H=Math.floor(Y.diff(v,"minute",!0)/(n||1));H!==g&&(g=H,I.push(x))}return I}}class mt extends U{constructor(t){super();z(this,"token");this.token=t}async realTimePosition(t,o={}){const r={searchParams:{id:t,k:this.token,enc:1}},n="https://api.shipxy.com/apicall/GetSingleShip",a=await F.get(n,r).json();if(M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,n,r),(a==null?void 0:a.status)!==0)return a;const s=a.data[0];for(const h in s)!isNaN(s[h])&&Number(s[h])!==1/0&&(s[h]=Number(s[h]));const{labelCn:d,labelEn:c}=await this.parseStatus(s.navistat),u=b.unix(s.lasttime);return{mmsi:s.ShipID,name:s.name,imo:s.imo,callSign:s.callsign,lat:Math.round(s.lat/1e6*1e5)/1e5,lng:Math.round(s.lon/1e6*1e5)/1e5,length:Math.round(s.length/10*100)/100,width:Math.round(s.width/10*100)/100,draught:Math.round(s.draught/1e3*100)/100,sog:Math.round(s.sog*3600/1e3/1852*100)/100,cog:Math.round(s.cog/100*100)/100,hdg:Math.round(s.hdg/100*100)/100,rot:Math.round(s.rot/100*100)/100,positionTime:s.lasttime,utc:u.utc().format(),status:s.navistat,labelEn:c,labelCn:d,method:"position",vendor:"shipxy"}}async trajectory(t,o,r,n,a=!0,s={}){var v;const d=await this.realTimePosition(t,s),c=b(o),u=b(r),m="https://api.shipxy.com/apicall/GetShipTrack",h={searchParams:{id:t,k:this.token,enc:1,cut:0,btm:c.unix(),etm:u.unix()}},y=await F.get(m,h).json();if(M==null||M.info("[%s] fetch trajectory from: %s - %j",s.requestId,m,h),(y==null?void 0:y.status)!==0)return y;const f=y==null?void 0:y.points,S=[],I=b.unix((v=f[0])==null?void 0:v.utc);let g=-1;for(const i of f){const l=b.unix(i.utc),j={imo:d==null?void 0:d.imo,mmsi:t,sog:Math.round(i.sog*3600/1e3/1852*100)/100,cog:Math.round(i.cog/100*100)/100,lat:Math.round(i.lat/1e6*1e5)/1e5,lng:Math.round(i.lon/1e6*1e5)/1e5,positionTime:l.unix(),utc:l.utc().format(),method:"trajectory",vendor:"shipxy"},p=Math.floor(l.diff(I,"minute",!0)/(n||1));p!==g&&(g=p,S.push(j))}return S}}class yt extends U{constructor(t){super();z(this,"token");this.token=t}async getShipId(t,o={}){const r={headers:{appKey:this.token},json:{mmsiList:t}},n="https://api3.myships.com/sp/ships/getShipIdByMMSI",a=await F.post(n,r).json();return M==null||M.info("[%s] fetch ship id from: %s - %j",o.requestId,n,r),a.code!=="0"?a:a.data[0].shipId}async getShipInfo(t,o={}){const r={headers:{appKey:this.token},json:{shipId:t}},n="https://api3.myships.com/sp/ships/aissta",a=await F.post(n,r).json();if(M==null||M.info("[%s] fetch ship info from: %s - %j",o.requestId,n,r),a.code!=="0")return a;const s=a.data;let d=s.imo;return t==="407170"&&(d="9198379",M==null||M.warn("[%s] ship(%s) imo error: %s, should be %s",o.requestId,t,s.imo,d)),{mmsi:s.mmsi,name:s.shipnameEn,imo:d,callSign:s.callSign,length:s.length,width:s.breadth,draught:(s.draught||100)/10}}async realTimePosition(t,o={}){const r=await this.getShipId(t,o),n=await this.getShipInfo(r,o),a={headers:{appKey:this.token},json:{shipId:r}},s="https://api3.myships.com/sp/ships/position/latest",d=await F.post(s,a).json();M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,s,a);const c=d.data[0];for(const f in c)!isNaN(c[f])&&Number(c[f])!==1/0&&(c[f]=Number(c[f]));const{labelCn:u,labelEn:m}=await this.parseStatus(c.aisNavStatus),h=b.unix(c.posTime);return{...n,mmsi:t,lat:Math.round(c.lat/1e4/60*1e5)/1e5,lng:Math.round(c.lon/1e4/60*1e5)/1e5,sog:Math.round(c.sog/10*100)/100,cog:Math.round(c.cog/10*100)/100,hdg:Math.round(c.heading*100)/100,rot:Math.round(c.rot*100)/100,positionTime:c.posTime,utc:h.utc().format(),status:c.aisNavStatus,labelEn:m,labelCn:u,method:"position",vendor:"myship"}}async trajectory(t,o,r,n,a=!0,s={}){const d=b(o),c=b(r),u=await this.getShipId(t),m=await this.getShipInfo(u),h=[];for(;c.diff(d,"day",!0)>30;)await this.trajectoryIn30Day(u,d.unix(),d.add(30,"day").unix(),m,t,n,h);return await this.trajectoryIn30Day(u,d.unix(),c.unix(),m,t,n,h),h}async trajectoryIn30Day(t,o,r,n,a,s,d,c={}){var I;const u={headers:{appKey:this.token},json:{shipId:t,startTime:o,endTime:r}},m="https://api3.myships.com/sp/ships/position/history",h=await F.post(m,u).json();if(M==null||M.info("[%s] fetch trajectory from: %s - %j",c.requestId,m,u),h.code!=="0")return M==null||M.warn("[%s] invoke myship trajectory failed: %j",c.requestId,h),h;const y=h.data;for(const g in y)!isNaN(y[g])&&Number(y[g])!==1/0&&(y[g]=Number(y[g]));const f=b.unix((I=y[0])==null?void 0:I.posTime);let S=-1;for(const g of y){const v=b.unix(g.posTime),i={imo:n==null?void 0:n.imo,mmsi:a,lat:Math.round(g.lat/1e4/60*1e5)/1e5,lng:Math.round(g.lon/1e4/60*1e5)/1e5,sog:Math.round(g.sog/10*100)/100,cog:Math.round(g.cog/10*100)/100,hdg:Math.round(g.heading*100)/100,rot:Math.round(g.rot*100)/100,positionTime:v.unix(),utc:v.utc().format(),method:"trajectory",vendor:"myship"},l=Math.floor(v.diff(f,"minute",!0)/(s||1));l!==S&&(S=l,d.push(i))}return d}}let J;try{J=K.getLogger("vessel")}catch{}finally{}var it=(D=>(D.NOTICE="NOTICE",D.WARN="WARN",D.HEAVY="HEAVY",D.SEVERE="SEVERE",D.ERROR="ERROR",D.FATAL="FATAL",D))(it||{});class rt{parsePrinciple(e,t={}){var s,d,c;J==null||J.info("[%s] parse rule: %s",t.requestId,e);const o=new RegExp("(?<=\\[)(.+)(?=])","g"),r=e.match(o)?(s=e.match(o))==null?void 0:s[0]:void 0,n=r==null?void 0:r.split(";");if(!n)return;const a={};for(let u=0;u<(n==null?void 0:n.length);u++){const m=(c=(d=n[u].match(o))==null?void 0:d[0])==null?void 0:c.split("],");if(u===0&&!m)a.scope=n[0];else if(m)for(let h=0,y=m.length;h<y;h++){const f=this.parseRule(m[h]);f&&(a[f.level]?f.key?a[f.level][f==null?void 0:f.key]=f:a[f.level]=f:f.key?a[f.level]={[f==null?void 0:f.key]:f}:a[f.level]=f)}}return a}parseRule(e,t={}){var a;J==null||J.info("[%s] parse rule: %s",t.requestId,e),e=e.startsWith("[")?e:`[${e}`,e=e.endsWith("]")?e:`${e}]`;const o=new RegExp("(?<=\\[)(.+?)(?=])","g"),r=(a=e==null?void 0:e.match(o))==null?void 0:a[0],n=r==null?void 0:r.split(",");if(n)return{operator:n[0],number:Number.isNaN(Number(n[1]))?n[1]:Number(n[1]),level:n[2],time:Number(n[3]),key:n[4]}}checkWeather(e,t,o={}){var f,S,I,g,v,i,l,j,p,Y,k,O,x,H,C;let r=0,n=0,a=0,s=0;const d=Math.round(((S=(f=t==null?void 0:t.SEVERE)==null?void 0:f.sigWave)==null?void 0:S.number)*1.6*100)/100,c=(g=(I=t==null?void 0:t.SEVERE)==null?void 0:I.sigWave)==null?void 0:g.number,u=(i=(v=t==null?void 0:t.HEAVY)==null?void 0:v.sigWave)==null?void 0:i.number,m=Math.round((((j=(l=t==null?void 0:t.SEVERE)==null?void 0:l.wind)==null?void 0:j.number)+2)*100)/100,h=(Y=(p=t==null?void 0:t.SEVERE)==null?void 0:p.wind)==null?void 0:Y.number,y=(O=(k=t==null?void 0:t.HEAVY)==null?void 0:k.wind)==null?void 0:O.number;for(let R=0;R<(e==null?void 0:e.length);R++){const T=e[R],A=(H=(x=T==null?void 0:T.meteo)==null?void 0:x.wave)==null?void 0:H.sig,V=(C=T==null?void 0:T.meteo)==null?void 0:C.wind,Z=R?b(T.eta).diff(b(e[R-1].eta),"hour",!0):0;s=Z>s?Z:s,J==null||J.info("[%s] check sig.wave: %j",o.requestId,{...A,dgThd4Wv:d,svThd4Wv:c,hvThd4Wv:u}),(A==null?void 0:A.height)>=d?T.isDangerous=!0:(A==null?void 0:A.height)>=c?T.isSevere=!0:(A==null?void 0:A.height)>=u&&(T.isHeavy=!0),J==null||J.info("[%s] check wind: %j",o.requestId,{...V,dgThd4Wd:m,svThd4Wd:h,hvThd4Wd:y}),(V==null?void 0:V.scale)>=m?(T.isDangerous=!0,delete T.isSevere,delete T.isHeavy):(V==null?void 0:V.scale)>h?(T.isDangerous||(T.isSevere=!0),delete T.isHeavy):(V==null?void 0:V.scale)===y&&!T.isDangerous&&!T.isSevere&&(T.isHeavy=!0),r+=T.isDangerous?Z:0,n+=T.isSevere?Z:0,a+=T.isHeavy?Z:0}return r=Math.round(r*100)/100,n=Math.round(n*100)/100,a=Math.round(a*100)/100,s=Math.round(s),{sample:e,dangerous:r,severe:n,heavy:a,step:s<3?3:s,wind:{dgThd4Wd:m,svThd4Wd:h,hvThd4Wd:y},sig:{dgThd4Wv:d,svThd4Wv:c,hvThd4Wv:u}}}}const Mt=new rt;let w;try{w=K.getLogger("vessel")}catch{}finally{}const pt=new nt.MeteoHelper2("",!0);var ct=(D=>(D.common="common",D.container="container",D.tugs="tugs",D))(ct||{}),dt=(D=>(D.Ballast="Ballast",D.Laden="Laden",D))(dt||{}),ut=(D=>(D.Cp="CP",D.Perf="Basis",D.Instruct="Other",D))(ut||{});class q{static blockCoefficient(e,t,o,r){let n=Math.round(e/(t*o*r)*100)/100;n=n<.55?.55:n>.85?.85:n;const a=[.55,.6,.65,.7,.75,.8,.85],s=a.map(d=>Math.abs(d-n));return a[s.indexOf(Math.min(...s))]}static froudeNumber(e,t,o=9.8){let r=Math.round(Math.sqrt(e*e/(o*t))*100)/100;return r=r<.05?.05:r>.3?.3:r,r}static amendFactor(e,t,o){const r={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.4,-10.6,-9.5],.8:[2.6,-13.1,-15.1],.85:[3.1,-18.7,28]};let a={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.6,-12.5,-13.5],.8:[3,-16.3,-21.6],.85:[3.4,-20.9,31.8]}[e];return o==="Laden"&&(a=r[e]),a[0]+a[1]*t+a[2]*Math.pow(t,2)}static directionFactor(e,t=0){let o;return e>30&&e<=60?o=(1.7-.03*Math.pow(t-4,2))/2:e>60&&e<=150?o=(.9-.06*Math.pow(t-6,2))/2:e>150&&e<=180?o=(.4-.03*Math.pow(t-8,2))/2:o=1,Math.round(o*1e5)/1e5}static vesselTagFactor(e,t,o,r=0){r=r>6?r-.9*(r-6):r;let n;return o==="container"?n=.7*r+Math.pow(r,6.5)/(22*Math.pow(e,2/3)):t==="Ballast"?n=.7*r+Math.pow(r,6.5)/(2.7*Math.pow(e,2/3)):n=.5*r+Math.pow(r,6.5)/(2.7*Math.pow(e,2/3)),n}static waveHeightFactor(e,t){e=e<0?.2:e,e=e>6?e-.9*(e-6):e,e=e>9?9:e;let o;return t>30&&t<=60?o=-.6:t>60&&t<=90?o=-.4:t>90&&t<=120?o=e<3?.4:-.3:t>120&&t<=150?o=e<3?.6:-.5:t>150&&t<=180?o=e<3?.7:-.6:o=-.7,Math.round(o*(.144*Math.pow(e,2)+.178*e)*1e4)/1e4}static assembleProperties(e,t,o,r){var h;const n=e.lbp??e.length??e.lengthOverall??198.9642,a=e.draught??8,s=e.breadthMoulded??e.breadth??e.breadthExtreme??32.4572,d=e.deadweight??67035.7773,c=((h=e==null?void 0:e.type)==null?void 0:h.toLowerCase())||"common";return{tag:c.indexOf("container")>-1?"container":c.indexOf("tugs")>-1?"tugs":"common",lbp:n,loadCondition:t,draught:a,breadthMoulded:s,displacement:Math.round((d/1.025+a*s*n*.7)*1e4)/1e4,speed:Math.round((o??14.1382)*1852/3600*1e4)/1e4,bearing:r||90}}static async speedLoseAt(e,t,o,r="",n=2,a=!0,s=!1,d={}){let c;if(t.velocity&&s&&(e.speed=N.LngLatHelper.roundPrecision(t.velocity*1852/3600,6)),a){let u;if(d.meteo2)try{const f=await pt.spotForecast(t.lat,t.lng,o.utc().format(),!1,!1,!0,d),[S]=ot.Meteo2Assist.pickHourly(f,o);u=ot.Meteo2Assist.toLegacy(S)}catch(f){w.warn("[%s] meteo2 spot(%j) forecast failed: %s",d.requestId,{...t,eta:o.utc().format()},f)}else u=await nt.MeteoHelper.queryPointFactor(t.lng,t.lat,o.valueOf(),"wind,wave,current,watertemp",r,d);const m=q.weatherFactor(e,u),h=q.currentFactor(e.bearing,u==null?void 0:u.current,n),y=Math.round((e.speed*1.943844+m+h)*100)/100;c={meteo:{...u},wxFactor:m,cFactor:h,speed:t.velocity&&s?t.velocity:y<0?1:y,eta:o.utc().format("YYYY-MM-DDTHH:mm[Z]"),etd:o.utc().format("YYYY-MM-DDTHH:mm[Z]")}}else c={wxFactor:0,cFactor:0,speed:t.velocity&&s?t.velocity:Math.round((e.speed*1.943844+0+0)*100)/100,eta:o.utc().format("YYYY-MM-DDTHH:mm[Z]"),etd:o.utc().format("YYYY-MM-DDTHH:mm[Z]")};return delete t.meteo,delete t.wxFactor,delete t.cFactor,delete t.speed,delete t.etd,{...c,...t}}static async speedLoseInHoursStep(e,t,o,r,n,a,s="",d=!0,c=!1,u={}){t.utc();const m=t.clone().add(14,"days"),h=[],y=[];let f=0,S=0,I,g;for(let v=0;v<a.length-1;v++){let i=a[v];i.distanceFromStart=Math.round((n+S)*1e4)/1e4;const l=a[v+1];if(e.bearing=N.LaneHelper.calculateBearing(i,l,!l.gcToPrevious),i.bearing=e.bearing,i.suspend&&c){i.eta=i.eta||t.format("YYYY-MM-DDTHH:mm[Z]"),i.elapsed=i.elapsed??0;const Y=i.suspend-i.elapsed;if(r-f>Y)r=r-f-Y,t.add(Y,"hour"),i.elapsed=i.suspend;else{const k=r-f;i.elapsed+=k,t.add(k,"hour"),r=0}if(w==null||w.info(`[%s] suspend ${i.elapsed} hours at %j, and remain ${r} hours need to go...`,u.requestId,i),r===0)return i.distanceFromPrevious=S,{etd:t,from:g||i,to:i,next:a.filter(k=>k),wps:h,days:y}}else i.suspend=0;d=t.isAfter(m)?!1:d,i=await q.speedLoseAt(e,i,t,s,0,d,c,u),g=g||i,i.important&&h.push(i),t.isSameOrAfter(o)&&(y.push(i),o.add(24,"hour"));const j=N.LaneHelper.calculateDistance(i,l,!l.gcToPrevious);let p=Math.ceil(j/g.speed*1e4)/1e4;if(f+p<r){if(f+=p,t.add(p,"hour"),delete a[v],w==null||w.debug(`[%s] go to %j from %j with ${j}nm, and cost ${p} hours`,u.requestId,{lat:l.lat,lng:l.lng},{lat:g.lat,lng:g.lng,etd:g.etd}),S+=j,a.filter(Y=>Y).length<=1){I=l,I.eta=t.format("YYYY-MM-DDTHH:mm[Z]"),I.distanceFromPrevious=j,I.distanceFromStart=Math.round((n+S)*1e4)/1e4,h.push(I),delete a[v+1];break}}else{p=r-f,t.add(p,"hour");const Y=N.LngLatHelper.roundPrecision(g.speed*p,4);I=N.LaneHelper.calculateCoordinate(i,e.bearing,Y,"nauticalmiles",!l.gcToPrevious),I.eta=t.format("YYYY-MM-DDTHH:mm[Z]"),a[v]=I,w==null||w.debug(`[%s] go to %j from %j with ${Y}nm, and cost ${p} hours`,u.requestId,{lat:I.lat,lng:I.lng},{lat:i.lat,lng:i.lng,etd:i.etd}),S+=Y,I.distanceFromPrevious=Math.round(S*1e4)/1e4,I.distanceFromStart=Math.round((n+S)*1e4)/1e4;break}}return{etd:t,from:g,to:I,next:a.filter(v=>v),wps:h,days:y}}static currentFactor(e,t,o=0){const r=(e-(t==null?void 0:t.degree)||0)/180*Math.PI;if(Math.abs(r)===Math.PI/2)return 0;let n=((t==null?void 0:t.kts)||0)*Math.cos(r);return o&2?n=Math.ceil(n*100)/100:o&1?n=Math.floor(n*100)/100:n=Math.round(n*100)/100,Math.abs(n)>5?0:n}static weatherFactor(e,t){var m,h,y,f,S,I,g;w==null||w.debug("calculate weather factor via: %j",{...e,...t});const o=q.blockCoefficient(e.displacement,e.lbp,e.breadthMoulded,e.draught),r=q.froudeNumber(e.speed,e.lbp),n=q.amendFactor(o,r,e.loadCondition);let a=Math.abs(e.bearing%360-(((m=t==null?void 0:t.wind)==null?void 0:m.degree)%360||0));a=a>180?360-a:a;const s=q.directionFactor(a,(h=t==null?void 0:t.wind)==null?void 0:h.scale),d=q.vesselTagFactor(e.displacement,e.loadCondition,e.tag,(y=t==null?void 0:t.wind)==null?void 0:y.scale);let c=s*n*d/100*e.speed;c=Math.round(c*1.943844*1e4)/1e4*-1,e.tag==="tugs"&&Math.abs(c)>1&&(c=c/(Math.abs(Math.round(c))+1)),w==null||w.debug("wind wx factor = %d",c),a=Math.abs(e.bearing%360-(((S=(f=t==null?void 0:t.wave)==null?void 0:f.sig)==null?void 0:S.degree)%360||0));const u=q.waveHeightFactor(((g=(I=t==null?void 0:t.wave)==null?void 0:I.sig)==null?void 0:g.height)??1,a);return w==null||w.debug("wave wx factor = %d",u),c=c*.4+u,w==null||w.debug("weather factor = %d",c),c=Math.abs(c)>4?4*(Math.abs(c)/c)+Math.abs(c)/c*(Math.abs(c)-4)*.1:c,Math.round((c||0)*100)/100}static async analyseInstant(e,t,o,r,n,a="",s=0,d=!0,c=!1,u={}){var Z,$,tt,et,st;const m=b().valueOf();e.lng=N.LngLatHelper.convertToStdLng(e.lng);const{route:h,waypoints:y}=n.points,f=N.LaneHelper.calculateSubRoute(e,h);if(((Z=f[0])==null?void 0:Z.length)<=1)return;const{v0:S,label:I}=e.sog?{v0:e.sog,label:"Other"}:{v0:r.speed,label:"CP"},g=q.assembleProperties(o,r.loadCondition,S,0),v=y.length?N.LaneHelper.calculateSubWaypoints(e,y):[];v.forEach(L=>L.important=!0);const i={from:{...e},route:f,waypoints:v,v0:S,label:I},l={hours:[],days:[],wps:[]};s||(N.LaneHelper.calculateRouteDistance(f)/r.speed<=72?s=3:s=6);let j=N.LaneHelper.simplifyRouteToCoordinates(f,v,0),p=0,Y=0,k=0,O=0;t=b(t).utc();const x=t.clone();for(;j.length>0;){const L=s-t.hour()%s,B=Math.ceil(t.clone().add(L,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4,P=await q.speedLoseInHoursStep(g,t,x,B,p,j,a,d,c,u);($=P.from)!=null&&$.speed&&(l.hours.push(P.from),l.wps.push(...P.wps),l.days.push(...P.days)),j=P==null?void 0:P.next,j.length||l.hours.push(P==null?void 0:P.to),p+=Math.round((((tt=P==null?void 0:P.to)==null?void 0:tt.distanceFromPrevious)??0)*1e4)/1e4}const H=l.hours;for(let L=0;L<H.length-1;L++){const B=b(H[L+1].eta).diff(H[L].etd,"hour",!0)||1;Y+=(H[L].wxFactor||0)*B,k+=(H[L].cFactor||0)*B,O+=B}(et=l.wps)==null||et.forEach((L,B)=>{if(L.positionTime=b.utc(L.etd||L.eta).unix(),B){const P=l.wps[B-1],at=L.distanceFromStart-P.distanceFromStart,Q=b(L.eta).diff(b(P.etd),"h",!0);if(Q<1)L.avgSpd=P.speed;else{L.avgSpd=Math.round(at/Q*100)/100;const X=Math.round((P.speed+L.speed)/2*100)/100;L.avgSpd=L.avgSpd>X?X:L.avgSpd}}}),i.sample=l;const C=l.hours.at(0),R=l.hours.at(-1);i.distance=Math.round(R.distanceFromStart*1e4)/1e4,i.etd=b(C.eta).utc().format(),i.eta=b(R.eta).utc().format(),i.wxFactor=Math.round(Y/O*1e4)/1e4,i.cFactor=Math.round(k/O*1e4)/1e4,i.avgSpeed=Math.round(R.distanceFromStart/O*1e4)/1e4,i.totalHrs=Math.round(O*1e4)/1e4,i.totalFoCons=Math.round((r==null?void 0:r.fo)/24*i.totalHrs*1e3)/1e3,i.totalDgoCons=Math.round((r==null?void 0:r.dgo)/24*i.totalHrs*1e3)/1e3;const A=b().valueOf()-m,V=((st=l==null?void 0:l.hours)==null?void 0:st.length)||1;return w==null||w.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms",u==null?void 0:u.requestId,A,V,Math.round(A/V*1e3)/1e3),i}static async analyseInstantWithThreshed(e,t,o,r,n,a,s,d="",c=3,u=!0,m=!1,h={}){var at,Q,X,lt;const y=b().valueOf();e.lng=N.LngLatHelper.convertToStdLng(e.lng);const{v0:f,label:S}=e.sog?{v0:e.sog,label:"Other"}:{v0:n.speed,label:"CP"},I=q.assembleProperties(r,n.loadCondition,f,0),g=N.LaneHelper.calculateSubRoute(e,a);if(((at=g[0])==null?void 0:at.length)<=1)return;const v=s.length?N.LaneHelper.calculateSubWaypoints(e,s):[];v.forEach(_=>_.important=!0);let i=N.LaneHelper.simplifyRouteToCoordinates(g,v,0),l=0,j=0,p=0,Y=0;const k={hours:[],wps:[],days:[]};t=b(t).utc();const O=t.clone();for(;i.length>0;){const _=c-t.hour()%c;let G=Math.ceil(t.clone().add(_,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4;G=t.clone().add(G,"h").isSameOrAfter(o)?o.diff(t,"h",!0)*1e4/1e4:G;const W=await q.speedLoseInHoursStep(I,t,O,G,l,i,d,u,m,h);if((Q=W.from)!=null&&Q.speed&&(k.hours.push(W.from),W!=null&&W.wps&&k.wps.push(...W.wps),k.days.push(...W.days)),i=W==null?void 0:W.next,i.length||k.hours.push(W==null?void 0:W.to),l+=Math.round((((X=W==null?void 0:W.to)==null?void 0:X.distanceFromPrevious)??0)*1e4)/1e4,!G)break}const x=k.hours;for(let _=0;_<x.length-1;_++){const G=b(x[_+1].eta).diff(x[_].etd,"hour",!0);j+=x[_].wxFactor*G,p+=x[_].cFactor*G,Y+=G}const H=k.hours.at(0),C=k.hours.at(-1),R=await N.LaneHelper.calculateRangeRoute(H,C,g),T=await N.LaneHelper.calculateRangeWaypoints(H,C,g,v),A={sample:k,distance:Math.round(((C==null?void 0:C.distanceFromStart)||0)*1e4)/1e4,etd:b(H.eta).utc().format(),eta:b(C==null?void 0:C.eta).utc().format(),wxFactor:Math.round(j/Y*1e4)/1e4,cFactor:Math.round(p/Y*1e4)/1e4,avgSpeed:Math.round(((C==null?void 0:C.distanceFromStart)||0)/Y*1e4)/1e4,totalHrs:Math.round(Y*1e4)/1e4,from:H,to:C,route:R,waypoints:T,v0:f,label:S},{distanceInECA:V,hoursInECA:Z,totalDgoConsInECA:$,eca:tt}=await this.calculateECA(A,n,h),et=N.LngLatHelper.roundPrecision(n.fo/24*(Y-Z),3),st=N.LngLatHelper.roundPrecision(n.dgo/24*Y,3);A.eca=tt,A.distanceInECA=V,A.hoursInECA=Z,A.totalDgoConsInECA=$,A.totalDgoCons=st,A.totalFoCons=et;const B=b().valueOf()-y,P=((lt=k==null?void 0:k.hours)==null?void 0:lt.length)||1;return w==null||w.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms",h==null?void 0:h.requestId,B,P,Math.round(B/P*1e3)/1e3),A}static async analyseCost(e,t,o,r,n={}){var g,v;const a=b().valueOf(),s=[];n.meteo2=n.meteo2||!0,e.speedStep=e.speedStep||3,e.alterStep=e.alterStep??1;const d=N.LaneHelper.calculateRouteDistance(r.route);let c=0;o.forEach(i=>{const l=Math.ceil(d/i.speed/24);c=c<l?l:c}),c=c*1.3;const u=b.utc(e.etd).add(c??14,"day");let m=1;for(const i of o){const l=JSON.parse(JSON.stringify(r.route)),j=JSON.parse(JSON.stringify(r.waypoints)),p=await q.analyseInstantWithThreshed({lat:e.lat,lng:e.lng},e.etd,u,t,i,l,j,e.meteoVendor,e.speedStep,e.useMeteo,e.useRouteParam,n);p&&(await q.calculateCost(p,i,e,n),s.push(p),w==null||w.info("[%s][L%d-%d] analyse from %s to %s cost: %j",n.requestId,1,m,e.etd,u.format(),{cost:p.cost.total,distance:p.distance,hours:p.totalHrs,cp:`${i.speed}/${i.fo}/${i.dgo}`})),m++}s.sort((i,l)=>i.cost.total-l.cost.total);const h=s.at(0),y=s.at(1),f=[];if(f.push({combined:!1,speeds:[h],cost:(g=h.cost)==null?void 0:g.total}),y){const i=h.cost.cp,l=y.cost.cp,j=b(h.eta),p=b(h.etd),Y=j.diff(p,"days",!0);let k=Math.ceil(Y/2);k=k>7?7:k<e.alterStep?e.alterStep:k;let O=2,x={combined:!1,speeds:[y],cost:(v=y.cost)==null?void 0:v.total},H;for(;k>=e.alterStep;){const C=await q.combinedAnalyse(e,t,u,[i,l],r,k,{...n,level:O});if(x.cost>C.cost?H?(H==null?void 0:H.cost)>C.cost&&(H=C):(H=x,x=C):(!H||(H==null?void 0:H.cost)>C.cost)&&(H=C),k<=e.alterStep)break;k=Math.ceil(k/2),O+=1}f.push(x),H&&f.push(H)}const I=b().valueOf()-a;return w==null||w.info("[%s] analyse elapsed: %d ms",n==null?void 0:n.requestId,I),f.sort((i,l)=>i.cost-l.cost)}static async combinedAnalyse(e,t,o,r,n,a,s={}){s.counter=1,w==null||w.info("[%s][L%d] analyse with alternate cp in every %d days",s.requestId,s.level,a);const d=await q.alternateAnalyse(e,t,o,r,0,n,a,s),c=d.reduce((h,y)=>h+y.cost.total,0);w==null||w.info("[%s][L%d] cost with cpa/cpb turn: %d",s.requestId,s.level,c);const u=await q.alternateAnalyse(e,t,o,r,1,n,a,s),m=u.reduce((h,y)=>h+y.cost.total,0);return w==null||w.info("[%s][L%d] cost with cpb/cpa turn: %d",s.requestId,s.level,m),c<m?{combined:!0,cost:Math.round(c*1e3)/1e3,speeds:d,step:a}:{combined:!0,cost:Math.round(m*1e3)/1e3,speeds:u,step:a}}static async alternateAnalyse(e,t,o,r,n,a,s,d={}){var h,y;let c=b.utc(e.etd);const u={lat:e.lat,lng:e.lng},m=[];for(;c.isBefore(o);){const f=c.clone().utc().add(s,"day"),S=JSON.parse(JSON.stringify(a.route)),I=JSON.parse(JSON.stringify(a.waypoints)),g=r[n],v=await q.analyseInstantWithThreshed(u,c.format(),f,t,g,S,I,e.meteoVendor,e.speedStep,e.useMeteo,e.useRouteParam,d);v&&(await q.calculateCost(v,g,e,d),w==null||w.info("[%s][L%d-%d] analyse from %s to %s cost: %j",d.requestId,d.level,d.counter,c.utc().format(),f.utc().format(),{cost:v.cost.total,distance:v.distance,hours:v.totalHrs,cp:`${g.speed}/${g.fo}/${g.dgo}`})),d.counter=d.counter+1;const i=(y=(h=v==null?void 0:v.sample)==null?void 0:h.hours)==null?void 0:y.at(-1);if(i)u.lat=i.lat,u.lng=i.lng,c=b(i.eta),m.push(v),n=n?0:1;else break}return m}static async calculateCost(e,t,o,r={}){if(e){const n=Math.round(e.totalHrs/24*(o.dailyHire||0)*(1-(o.addComm||0))*1e3)/1e3,a=Math.round(e.totalFoCons*(o.priceFO||0)*1e3)/1e3,s=Math.round((e.totalDgoCons+e.totalDgoConsInECA)*(o.priceDGO||0)*1e3)/1e3;e.cost={total:Math.round((n+a+s)*1e3)/1e3,hire:n,bunker:Math.round((a+s)*1e3)/1e3,cp:t}}return e}static async calculateECA(e,t,o={}){var d,c;const r=await N.LaneHelper.intersectInECA(e.route);let n=0,a=0,s=0;e.sample.wps.forEach(u=>{u.positionTime=b.utc(u.etd||u.eta).unix()});for(const u of r){n+=u.distance;const m=await N.LaneHelper.deadReckoningTime((d=u.waypoints)==null?void 0:d.at(0),e.sample.wps),h=await N.LaneHelper.deadReckoningTime((c=u.waypoints)==null?void 0:c.at(-1),e.sample.wps);u.in=m,u.out=h,u.totalHrs=N.LngLatHelper.roundPrecision((h.positionTime-m.positionTime)/3600,2),u.totalDgoCons=N.LngLatHelper.roundPrecision(t.fo/24*u.totalHrs,3),a+=u.totalHrs}return n=N.LngLatHelper.roundPrecision(n,3),a=N.LngLatHelper.roundPrecision(a,3),s=N.LngLatHelper.roundPrecision(s,3),{distanceInECA:n,hoursInECA:a,totalDgoConsInECA:s,eca:r}}static async mergeSpeeds(e,t={}){var v;const o={hours:[],wps:[],days:[]},r=e.reduce((i,l)=>i+l.distance,0),n=e.reduce((i,l)=>i+l.distanceInECA,0),a=e.reduce((i,l)=>i+l.totalHrs,0),s=e.reduce((i,l)=>i+l.hoursInECA,0),d=e.reduce((i,l)=>i+l.totalDgoConsInECA,0),c=e.reduce((i,l)=>i+l.wxFactor*l.totalHrs/a,0),u=e.reduce((i,l)=>i+l.cFactor*l.totalHrs/a,0),m=e.reduce((i,l)=>i+l.totalFoCons,0),h=e.reduce((i,l)=>i+l.totalDgoCons,0),y=e.reduce((i,l)=>i+l.cost.total,0),f=e.reduce((i,l)=>i+l.cost.hire,0),S=e.reduce((i,l)=>i+l.cost.bunker,0),I=[],g=[];for(const i of e){g.push(...i.eca);const l=i.sample.hours,j=l.at(0);j.cp=i.cost.cp;const p=[i.etd,i.eta],Y=I.findIndex(H=>H.id===j.cp.id);Y===-1?(j.cp.segment=[p],I.push(j.cp)):I[Y].segment.push(p);const k=i.sample.wps,O=i.sample.days;l.forEach(H=>{var R;((R=o.hours)==null?void 0:R.findIndex(T=>T.eta===H.eta))===-1&&o.hours.push(H)}),k.forEach(H=>{var R;((R=o.wps)==null?void 0:R.findIndex(T=>T.eta===H.eta))===-1&&o.wps.push(H)}),O.forEach(H=>{var R;((R=o==null?void 0:o.days)==null?void 0:R.findIndex(T=>T.eta===H.eta))===-1&&o.days.push(H)});const x=(v=o.wps)==null?void 0:v.findIndex(H=>H.eta===j.eta);x===-1?o.wps.push(j):o.wps[x]=j}return o.wps.sort((i,l)=>{b(i.etd).unix()-b(l.etd).unix()}),{sample:o,etd:e.at(0).etd,eta:e.at(-1).eta,from:e.at(0).from,to:e.at(-1).to,v0:e.at(0).v0,label:"Combined",distance:Math.round(r*1e4)/1e4,distanceInECA:Math.round(n*1e4)/1e4,totalHrs:Math.round(a*1e3)/1e3,hoursInECA:Math.round(s*1e3)/1e3,avgSpeed:Math.round(r/a*1e3)/1e3,wxFactor:Math.round(c/a*1e3)/1e3,cFactor:Math.round(u/a*1e3)/1e3,totalFoCons:Math.round(m*1e3)/1e3,totalDgoCons:Math.round(h*1e3)/1e3,totalDgoConsInECA:Math.round(d*1e3)/1e3,cost:{total:Math.round(y*1e3)/1e3,hire:Math.round(f*1e3)/1e3,bunker:Math.round(S*1e3)/1e3},cps:I,eca:g}}}E.AISImpl=U,E.AlertHelper=rt,E.AlertLevel=it,E.HifleetImpl=ft,E.LoadCondition=dt,E.MyShipImpl=yt,E.MyVesselImpl=ht,E.ShipxyImpl=mt,E.SpeedHelper=q,E.SpeedLabel=ut,E.VesselTag=ct,E.alertHelper=Mt,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
1
+ (function(D,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("got"),require("@log4js-node/log4js-api"),require("moment"),require("@idm-plugin/geo2"),require("@idm-plugin/meteo2"),require("@idm-plugin/meteo")):typeof define=="function"&&define.amd?define(["exports","got","@log4js-node/log4js-api","moment","@idm-plugin/geo2","@idm-plugin/meteo2","@idm-plugin/meteo"],P):(D=typeof globalThis<"u"?globalThis:D||self,P(D["idm-plugin-rabbitmq"]={},D.got,D["@log4js-node/log4js-api"],D.moment,D["@idm-plugin/geo2"],D["@idm-plugin/meteo2"],D["@idm-plugin/meteo"]))})(this,function(D,P,G,b,q,ot,it){"use strict";var wt=Object.defineProperty;var It=(D,P,G)=>P in D?wt(D,P,{enumerable:!0,configurable:!0,writable:!0,value:G}):D[P]=G;var z=(D,P,G)=>(It(D,typeof P!="symbol"?P+"":P,G),G);let M;try{M=G.getLogger("vessel")}catch{}finally{}class U{parseStatus(e){let t,o;switch(e){case 0:t="在航(主机推动)",o="The engine is in use";break;case 1:t="锚泊",o="Anchored";break;case 2:t="失控",o="Not operated";break;case 3:t="操纵受限",o="Limited airworthiness";break;case 4:t="吃水受限",o="Limited by ship's draft";break;case 5:t="靠泊",o="Mooring";break;case 6:t="搁浅",o="Stranded";break;case 7:t="捕捞作业",o="Engaged in fishing";break;case 8:t="靠帆船提供动力",o="Sailing";break;default:t="未定义",o="Undefined"}return{labelCn:t,labelEn:o}}}class mt extends U{constructor(t,o){super();z(this,"clientId");z(this,"clientSecret");z(this,"token");this.clientId=t,this.clientSecret=o}async authToken(t={}){const o="https://svc.data.myvessel.cn/ada/oauth/token",i={searchParams:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"client_credentials"}},n=await P.post(o,i).json();M==null||M.info("[%s] fetch access token from: %s - %j",t.requestId,o,n),n.error||(this.token={accessToken:n.access_token,tokenType:n.token_type,expiresIn:n.expires_in,scope:n.scope,jti:n.jti,issuedAt:b().utc().format()})}async realTimePosition(t,o={}){var u,m,h;(!this.token||b().diff(b(this.token.issuedAt),"seconds")>((u=this.token)==null?void 0:u.expiresIn)-300)&&await this.authToken(o);const i="https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit",n={headers:{Authorization:`${(m=this.token)==null?void 0:m.tokenType} ${(h=this.token)==null?void 0:h.accessToken}`},searchParams:{mmsi:t}};M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,i,n);const a=await P.get(i,n).json();if(a.code)return M==null||M.warn("[%s] fetch realtime position failed: %j",o.requestId,i,{message:a.message,status:a.status,code:a.code}),a;const s=a.data;for(const y in s)!isNaN(s[y])&&Number(s[y])!==1/0&&(s[y]=Number(s[y]));const d=b(`${s.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:s.mmsi,name:s.vesselName,imo:s.imo,callSign:s.callsign,lat:s.lat,lng:s.lon,length:s.length,width:s.width,draught:s.currDraught,sog:s.sog,cog:s.cog,hdg:s.hdg,rot:s.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta)?b.utc(s.eta).format():void 0,destination:s.dest,positionTime:d.unix(),status:s.status,labelCn:s.statusNameCn,labelEn:s.statusNameEn,method:"position",vendor:"myVessel",utc:d.utc().format()}}async trajectory(t,o,i,n,a=!0,s={}){(!this.token||b().diff(b(this.token.issuedAt),"seconds")>this.token.expiresIn-300)&&await this.authToken(s);const d=await this.realTimePosition(t,s),r=b(o),u=b(i),m=[];for(;u.diff(r,"day",!0)>30;)await this.trajectoryIn30Day(t,r,r.clone().add(30,"day"),d,n,m,s),r.add(30,"day");return await this.trajectoryIn30Day(t,r,u,d,n,m,s),m}async trajectoryIn30Day(t,o,i,n,a,s,d={}){var f,j,F,g,v;const r="https://svc.data.myvessel.cn/sdc/v1/vessels/status/track",u={headers:{Authorization:`${(f=this.token)==null?void 0:f.tokenType} ${(j=this.token)==null?void 0:j.accessToken}`},json:{mmsi:t,startTime:o.utcOffset(8).format("YYYY-MM-DD HH:mm:ss"),endTime:i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")}};M==null||M.info("[%s] fetch trajectory from: %s - %j",d.requestId,r,u);const m=await P.post(r,u).json();if(m.code)return M==null||M.warn("[%s] fetch trajectory failed: %j",d.requestId,r,{message:m.message,status:m.status,code:m.code}),m;let h=-1;const y=b(`${(g=(F=m.data)==null?void 0:F[0])==null?void 0:g.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return(v=m.data)==null||v.forEach(c=>{for(const Y in c)!isNaN(c[Y])&&Number(c[Y])!==1/0&&(c[Y]=Number(c[Y]));const w=b(`${c.postime} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00"),p=c.status,{labelCn:l,labelEn:S}=this.parseStatus(p),k={mmsi:c.mmsi,imo:n==null?void 0:n.imo,lat:c.lat,lng:c.lon,sog:c.sog,cog:c.cog,hdg:c.hdg,draught:c.draught,status:p,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(c.eta)?b(`${c.eta} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00").utc().format():void 0,destination:c.dest,positionTime:w.unix(),labelCn:l,labelEn:S,method:"trajectory",vendor:"myVessel",utc:w.utc().format()},L=Math.floor(w.diff(y,"minute",!0)/(a||1));L!==h&&(h=L,s.push(k))}),s}}class yt extends U{constructor(t){super();z(this,"token");this.token=t}async realTimePosition(t,o={}){const i="https://api.hifleet.com/position/position/get/token",n={searchParams:{mmsi:t,usertoken:this.token}},a=await P.post(i,n).json();M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,i,n);const s=a==null?void 0:a.list;if(!s)return M==null||M.warn("[%s] fetch realtime position failed: %j",o.requestId,i,a),a;for(const y in s)!isNaN(s[y])&&Number(s[y])!==1/0&&(s[y]=Number(s[y]));s.status=s.sp>3?0:1;const d=s.status,{labelCn:r,labelEn:u}=this.parseStatus(d),m=b(`${s.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");return{mmsi:s.m,name:s.n,imo:s.imonumber,callSign:s.callsign,lat:Math.round(s.la/60*1e5)/1e5,lng:Math.round(s.lo/60*1e5)/1e5,length:s.l,width:s.w,draught:s.draught,sog:s.sp,cog:s.co,hdg:s.h,rot:isNaN(s.rot)?0:s.rot,eta:/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta)?b.utc(s.eta).format():void 0,destination:s.destination,positionTime:m.unix(),utc:m.utc().format(),status:d,labelCn:r,labelEn:u,method:"position",vendor:"hifleet"}}async search(t,o={}){let i="https://www.hifleet.com/hifleetapi/searchVesselOL.do";const n={searchParams:{keyword:t},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}};let a=await P.post(i,n).json();M==null||M.info("[%s] fetch vessel props from: %s - %j",o.requestId,i,n),a instanceof Array&&(a=a[0]);for(const d in a)!isNaN(a[d])&&Number(a[d])!==1/0&&(a[d]=Number(a[d]));const s={mmsi:a.m,name:a.n,imo:a.i,callSign:a.c,length:a.l,breadth:a.b,draught:a.dr,type:a.t};return i="https://www.hifleet.com/hifleetapi/sameShipSearch.do",a=await P.post(i,n).json(),M==null||M.info("[%s] search vessel dead weight from: %s - %j",o.requestId,i,n),a instanceof Array&&(a=a[0]),a&&(s.deadweight=Number(a.dwt)),s}async suggest(t,o={}){const i="https://www.hifleet.com/hifleetapi/getShipSuggest.do",n={searchParams:{q:t},headers:{Referer:"https://www.hifleet.com",Origin:"https://www.hifleet.com",Host:"www.hifleet.com"}},a=await P.post(i,n).json();M==null||M.info("[%s] suggest vessel props from: %s - %j",o.requestId,i,n);const s=[];for(const d of a)s.push({mmsi:!d.mmsi||isNaN(d.mmsi)?null:Number(d.mmsi),name:d.name,callSign:d.callsign,imo:!d.imo||isNaN(d.imo)?null:Number(d.imo),score:d._score});return s.sort((d,r)=>r.score-d.score),s}async trajectory(t,o,i,n,a=!0,s={}){var c,w,p;const d=await this.realTimePosition(t,s);let r=b(o);const u=b(i),m=b();if(a){let l=u.diff(r,"d",!0);l<0?r=u.clone().subtract(40,"d"):l<30?r.subtract(10,"d"):l<60?r.subtract(5,"d"):r=u.clone().subtract(80,"d"),l=m.diff(u,"d",!0),u.add(l>10?240:l*24,"h")}const h={searchParams:{endtime:u.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),starttime:r.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),mmsi:t,usertoken:this.token}},y="https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token",f=await P.get(y,h).json();M==null||M.info("[%s] fetch trajectory from: %s - %j",s.requestId,y,h);let j;f&&(j=((w=(c=f.ships)==null?void 0:c.offors)==null?void 0:w.ship)||[],j.length||M==null||M.warn("[%s] fetch trajectory failed: %j",s.requestId,f));const F=[];let g=-1;const v=b(`${(p=j==null?void 0:j[0])==null?void 0:p.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");for(const l of j){for(const N in l)!isNaN(l[N])&&Number(l[N])!==1/0&&(l[N]=Number(l[N]));const S=b(`${l.ti} +08:00`,"YYYY-MM-DD HH:mm:ss +08:00");l.status=l.sp>4?0:1;const{labelEn:k,labelCn:L}=this.parseStatus(l.status),Y={mmsi:l.m,name:l.n,imo:d==null?void 0:d.imo,lat:l.la,lng:l.lo,draught:l.draught,sog:l.sp,cog:l.co,hdg:l.hdg,positionTime:S.unix(),utc:S.utc().format(),status:l.status,labelCn:L,labelEn:k,method:"trajectory",vendor:"hifleet"},H=Math.floor(S.diff(v,"minute",!0)/(n||1));H!==g&&(g=H,F.push(Y))}return F}}class Mt extends U{constructor(t){super();z(this,"token");this.token=t}async realTimePosition(t,o={}){const i={searchParams:{id:t,k:this.token,enc:1}},n="https://api.shipxy.com/apicall/GetSingleShip",a=await P.get(n,i).json();if(M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,n,i),(a==null?void 0:a.status)!==0)return a;const s=a.data[0];for(const h in s)!isNaN(s[h])&&Number(s[h])!==1/0&&(s[h]=Number(s[h]));const{labelCn:d,labelEn:r}=await this.parseStatus(s.navistat),u=b.unix(s.lasttime);return{mmsi:s.ShipID,name:s.name,imo:s.imo,callSign:s.callsign,lat:Math.round(s.lat/1e6*1e5)/1e5,lng:Math.round(s.lon/1e6*1e5)/1e5,length:Math.round(s.length/10*100)/100,width:Math.round(s.width/10*100)/100,draught:Math.round(s.draught/1e3*100)/100,sog:Math.round(s.sog*3600/1e3/1852*100)/100,cog:Math.round(s.cog/100*100)/100,hdg:Math.round(s.hdg/100*100)/100,rot:Math.round(s.rot/100*100)/100,positionTime:s.lasttime,utc:u.utc().format(),status:s.navistat,labelEn:r,labelCn:d,method:"position",vendor:"shipxy"}}async trajectory(t,o,i,n,a=!0,s={}){var v;const d=await this.realTimePosition(t,s),r=b(o),u=b(i),m="https://api.shipxy.com/apicall/GetShipTrack",h={searchParams:{id:t,k:this.token,enc:1,cut:0,btm:r.unix(),etm:u.unix()}},y=await P.get(m,h).json();if(M==null||M.info("[%s] fetch trajectory from: %s - %j",s.requestId,m,h),(y==null?void 0:y.status)!==0)return y;const f=y==null?void 0:y.points,j=[],F=b.unix((v=f[0])==null?void 0:v.utc);let g=-1;for(const c of f){const w=b.unix(c.utc),p={imo:d==null?void 0:d.imo,mmsi:t,sog:Math.round(c.sog*3600/1e3/1852*100)/100,cog:Math.round(c.cog/100*100)/100,lat:Math.round(c.lat/1e6*1e5)/1e5,lng:Math.round(c.lon/1e6*1e5)/1e5,positionTime:w.unix(),utc:w.utc().format(),method:"trajectory",vendor:"shipxy"},l=Math.floor(w.diff(F,"minute",!0)/(n||1));l!==g&&(g=l,j.push(p))}return j}}class pt extends U{constructor(t){super();z(this,"token");this.token=t}async getShipId(t,o={}){const i={headers:{appKey:this.token},json:{mmsiList:t}},n="https://api3.myships.com/sp/ships/getShipIdByMMSI",a=await P.post(n,i).json();return M==null||M.info("[%s] fetch ship id from: %s - %j",o.requestId,n,i),a.code!=="0"?a:a.data[0].shipId}async getShipInfo(t,o={}){const i={headers:{appKey:this.token},json:{shipId:t}},n="https://api3.myships.com/sp/ships/aissta",a=await P.post(n,i).json();if(M==null||M.info("[%s] fetch ship info from: %s - %j",o.requestId,n,i),a.code!=="0")return a;const s=a.data;let d=s.imo;return t==="407170"&&(d="9198379",M==null||M.warn("[%s] ship(%s) imo error: %s, should be %s",o.requestId,t,s.imo,d)),{mmsi:s.mmsi,name:s.shipnameEn,imo:d,callSign:s.callSign,length:s.length,width:s.breadth,draught:(s.draught||100)/10}}async realTimePosition(t,o={}){const i=await this.getShipId(t,o),n=await this.getShipInfo(i,o),a={headers:{appKey:this.token},json:{shipId:i}},s="https://api3.myships.com/sp/ships/position/latest",d=await P.post(s,a).json();M==null||M.info("[%s] fetch realtime position from: %s - %j",o.requestId,s,a);const r=d.data[0];for(const f in r)!isNaN(r[f])&&Number(r[f])!==1/0&&(r[f]=Number(r[f]));const{labelCn:u,labelEn:m}=await this.parseStatus(r.aisNavStatus),h=b.unix(r.posTime);return{...n,mmsi:t,lat:Math.round(r.lat/1e4/60*1e5)/1e5,lng:Math.round(r.lon/1e4/60*1e5)/1e5,sog:Math.round(r.sog/10*100)/100,cog:Math.round(r.cog/10*100)/100,hdg:Math.round(r.heading*100)/100,rot:Math.round(r.rot*100)/100,positionTime:r.posTime,utc:h.utc().format(),status:r.aisNavStatus,labelEn:m,labelCn:u,method:"position",vendor:"myship"}}async trajectory(t,o,i,n,a=!0,s={}){const d=b(o),r=b(i),u=await this.getShipId(t),m=await this.getShipInfo(u),h=[];for(;r.diff(d,"day",!0)>30;)await this.trajectoryIn30Day(u,d.unix(),d.add(30,"day").unix(),m,t,n,h);return await this.trajectoryIn30Day(u,d.unix(),r.unix(),m,t,n,h),h}async trajectoryIn30Day(t,o,i,n,a,s,d,r={}){var F;const u={headers:{appKey:this.token},json:{shipId:t,startTime:o,endTime:i}},m="https://api3.myships.com/sp/ships/position/history",h=await P.post(m,u).json();if(M==null||M.info("[%s] fetch trajectory from: %s - %j",r.requestId,m,u),h.code!=="0")return M==null||M.warn("[%s] invoke myship trajectory failed: %j",r.requestId,h),h;const y=h.data;for(const g in y)!isNaN(y[g])&&Number(y[g])!==1/0&&(y[g]=Number(y[g]));const f=b.unix((F=y[0])==null?void 0:F.posTime);let j=-1;for(const g of y){const v=b.unix(g.posTime),c={imo:n==null?void 0:n.imo,mmsi:a,lat:Math.round(g.lat/1e4/60*1e5)/1e5,lng:Math.round(g.lon/1e4/60*1e5)/1e5,sog:Math.round(g.sog/10*100)/100,cog:Math.round(g.cog/10*100)/100,hdg:Math.round(g.heading*100)/100,rot:Math.round(g.rot*100)/100,positionTime:v.unix(),utc:v.utc().format(),method:"trajectory",vendor:"myship"},w=Math.floor(v.diff(f,"minute",!0)/(s||1));w!==j&&(j=w,d.push(c))}return d}}let B;try{B=G.getLogger("vessel")}catch{}finally{}var rt=(T=>(T.NOTICE="NOTICE",T.WARN="WARN",T.HEAVY="HEAVY",T.SEVERE="SEVERE",T.ERROR="ERROR",T.FATAL="FATAL",T))(rt||{});class ct{parsePrinciple(e,t={}){var s,d,r;B==null||B.info("[%s] parse rule: %s",t.requestId,e);const o=new RegExp("(?<=\\[)(.+)(?=])","g"),i=e.match(o)?(s=e.match(o))==null?void 0:s[0]:void 0,n=i==null?void 0:i.split(";");if(!n)return;const a={};for(let u=0;u<(n==null?void 0:n.length);u++){const m=(r=(d=n[u].match(o))==null?void 0:d[0])==null?void 0:r.split("],");if(u===0&&!m)a.scope=n[0];else if(m)for(let h=0,y=m.length;h<y;h++){const f=this.parseRule(m[h]);f&&(a[f.level]?f.key?a[f.level][f==null?void 0:f.key]=f:a[f.level]=f:f.key?a[f.level]={[f==null?void 0:f.key]:f}:a[f.level]=f)}}return a}parseRule(e,t={}){var a;B==null||B.info("[%s] parse rule: %s",t.requestId,e),e=e.startsWith("[")?e:`[${e}`,e=e.endsWith("]")?e:`${e}]`;const o=new RegExp("(?<=\\[)(.+?)(?=])","g"),i=(a=e==null?void 0:e.match(o))==null?void 0:a[0],n=i==null?void 0:i.split(",");if(n)return{operator:n[0],number:Number.isNaN(Number(n[1]))?n[1]:Number(n[1]),level:n[2],time:Number(n[3]),key:n[4]}}checkWeather(e,t,o={}){var f,j,F,g,v,c,w,p,l,S,k,L,Y,H,N;let i=0,n=0,a=0,s=0;const d=Math.round(((j=(f=t==null?void 0:t.SEVERE)==null?void 0:f.sigWave)==null?void 0:j.number)*1.6*100)/100,r=(g=(F=t==null?void 0:t.SEVERE)==null?void 0:F.sigWave)==null?void 0:g.number,u=(c=(v=t==null?void 0:t.HEAVY)==null?void 0:v.sigWave)==null?void 0:c.number,m=Math.round((((p=(w=t==null?void 0:t.SEVERE)==null?void 0:w.wind)==null?void 0:p.number)+2)*100)/100,h=(S=(l=t==null?void 0:t.SEVERE)==null?void 0:l.wind)==null?void 0:S.number,y=(L=(k=t==null?void 0:t.HEAVY)==null?void 0:k.wind)==null?void 0:L.number;for(let E=0;E<(e==null?void 0:e.length);E++){const C=e[E],A=(H=(Y=C==null?void 0:C.meteo)==null?void 0:Y.wave)==null?void 0:H.sig,V=(N=C==null?void 0:C.meteo)==null?void 0:N.wind,K=E?b(C.eta).diff(b(e[E-1].eta),"hour",!0):0;s=K>s?K:s,B==null||B.info("[%s] check sig.wave: %j",o.requestId,{...A,dgThd4Wv:d,svThd4Wv:r,hvThd4Wv:u}),(A==null?void 0:A.height)>=d?C.isDangerous=!0:(A==null?void 0:A.height)>=r?C.isSevere=!0:(A==null?void 0:A.height)>=u&&(C.isHeavy=!0),B==null||B.info("[%s] check wind: %j",o.requestId,{...V,dgThd4Wd:m,svThd4Wd:h,hvThd4Wd:y}),(V==null?void 0:V.scale)>=m?(C.isDangerous=!0,delete C.isSevere,delete C.isHeavy):(V==null?void 0:V.scale)>h?(C.isDangerous||(C.isSevere=!0),delete C.isHeavy):(V==null?void 0:V.scale)===y&&!C.isDangerous&&!C.isSevere&&(C.isHeavy=!0),i+=C.isDangerous?K:0,n+=C.isSevere?K:0,a+=C.isHeavy?K:0}return i=Math.round(i*100)/100,n=Math.round(n*100)/100,a=Math.round(a*100)/100,s=Math.round(s),{sample:e,dangerous:i,severe:n,heavy:a,step:s<3?3:s,wind:{dgThd4Wd:m,svThd4Wd:h,hvThd4Wd:y},sig:{dgThd4Wv:d,svThd4Wv:r,hvThd4Wv:u}}}}const bt=new ct;let I;try{I=G.getLogger("vessel")}catch{}finally{}const vt=new ot.MeteoHelper2("",!0);var dt=(T=>(T.common="common",T.container="container",T.tugs="tugs",T))(dt||{}),ut=(T=>(T.Ballast="Ballast",T.Laden="Laden",T))(ut||{}),lt=(T=>(T.Cp="CP",T.Perf="Basis",T.Instruct="Other",T))(lt||{});class R{static blockCoefficient(e,t,o,i){let n=Math.round(e/(t*o*i)*100)/100;n=n<.55?.55:n>.85?.85:n;const a=[.55,.6,.65,.7,.75,.8,.85],s=a.map(d=>Math.abs(d-n));return a[s.indexOf(Math.min(...s))]}static froudeNumber(e,t,o=9.8){let i=Math.round(Math.sqrt(e*e/(o*t))*100)/100;return i=i<.05?.05:i>.3?.3:i,i}static amendFactor(e,t,o){const i={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.4,-10.6,-9.5],.8:[2.6,-13.1,-15.1],.85:[3.1,-18.7,28]};let a={.55:[1.7,-1.4,-7.4],.6:[2.2,-2.5,-9.7],.65:[2.6,-3.7,-11.6],.7:[3.1,-5.3,-12.4],.75:[2.6,-12.5,-13.5],.8:[3,-16.3,-21.6],.85:[3.4,-20.9,31.8]}[e];return o==="Laden"&&(a=i[e]),a[0]+a[1]*t+a[2]*Math.pow(t,2)}static directionFactor(e,t=0){let o;return e>30&&e<=60?o=(1.7-.03*Math.pow(t-4,2))/2:e>60&&e<=150?o=(.9-.06*Math.pow(t-6,2))/2:e>150&&e<=180?o=(.4-.03*Math.pow(t-8,2))/2:o=1,Math.round(o*1e5)/1e5}static vesselTagFactor(e,t,o,i=0){i=i>6?i-.9*(i-6):i;let n;return o==="container"?n=.7*i+Math.pow(i,6.5)/(22*Math.pow(e,2/3)):t==="Ballast"?n=.7*i+Math.pow(i,6.5)/(2.7*Math.pow(e,2/3)):n=.5*i+Math.pow(i,6.5)/(2.7*Math.pow(e,2/3)),n}static waveHeightFactor(e,t){e=e<0?.2:e,e=e>6?e-.9*(e-6):e,e=e>9?9:e;let o;return t>30&&t<=60?o=-.6:t>60&&t<=90?o=-.4:t>90&&t<=120?o=e<3?.4:-.3:t>120&&t<=150?o=e<3?.6:-.5:t>150&&t<=180?o=e<3?.7:-.6:o=-.7,Math.round(o*(.144*Math.pow(e,2)+.178*e)*1e4)/1e4}static assembleProperties(e,t,o,i){var h;const n=e.lbp??e.length??e.lengthOverall??198.9642,a=e.draught??8,s=e.breadthMoulded??e.breadth??e.breadthExtreme??32.4572,d=e.deadweight??67035.7773,r=((h=e==null?void 0:e.type)==null?void 0:h.toLowerCase())||"common";return{tag:r.indexOf("container")>-1?"container":r.indexOf("tugs")>-1?"tugs":"common",lbp:n,loadCondition:t,draught:a,breadthMoulded:s,displacement:Math.round((d/1.025+a*s*n*.7)*1e4)/1e4,speed:Math.round((o??14.1382)*1852/3600*1e4)/1e4,bearing:i||90}}static async speedLoseAt(e,t,o,i="",n=2,a=!0,s=!1,d={}){let r;if(t.velocity&&s&&(e.speed=q.LngLatHelper.roundPrecision(t.velocity*1852/3600,6)),a){let u;if(d.meteo2)try{const f=await vt.spotForecast(t.lat,t.lng,o.utc().format(),!1,!1,!0,d),[j]=it.Meteo2Assist.pickHourly(f,o);u=it.Meteo2Assist.toLegacy(j)}catch(f){I.warn("[%s] meteo2 spot(%j) forecast failed: %s",d.requestId,{...t,eta:o.utc().format()},f)}else u=await ot.MeteoHelper.queryPointFactor(t.lng,t.lat,o.valueOf(),"wind,wave,current,watertemp",i,d);const m=R.weatherFactor(e,u),h=R.currentFactor(e.bearing,u==null?void 0:u.current,n),y=Math.round((e.speed*1.943844+m+h)*100)/100;r={meteo:{...u},wxFactor:m,cFactor:h,speed:t.velocity&&s?t.velocity:y<0?1:y,eta:o.utc().format(),etd:o.utc().format()}}else r={wxFactor:0,cFactor:0,speed:t.velocity&&s?t.velocity:Math.round((e.speed*1.943844+0+0)*100)/100,eta:o.utc().format(),etd:o.utc().format()};return delete t.meteo,delete t.wxFactor,delete t.cFactor,delete t.speed,delete t.etd,{...r,...t}}static async speedLoseInHoursStep(e,t,o,i,n,a,s="",d=!0,r=!1,u={}){t.utc();const m=t.clone().add(14,"days"),h=[],y=[];let f=0,j=0,F,g;for(let v=0;v<a.length-1;v++){let c=a[v];c.distanceFromStart=Math.round((n+j)*1e4)/1e4;const w=a[v+1];if(e.bearing=q.LaneHelper.calculateBearing(c,w,!w.gcToPrevious),c.bearing=e.bearing,c.suspend&&r){c.eta=c.eta||t.utc().format(),c.elapsed=c.elapsed??0;const S=c.suspend-c.elapsed;if(i-f>S)i=i-f-S,t.add(S,"hour"),c.elapsed=c.suspend;else{const k=i-f;c.elapsed+=k,t.add(k,"hour"),i=0}if(I==null||I.info(`[%s] suspend ${c.elapsed} hours at %j, and remain ${i} hours need to go...`,u.requestId,c),i===0)return c.distanceFromPrevious=j,{etd:t,from:g||c,to:c,next:a.filter(k=>k),wps:h,days:y}}else c.suspend=0;d=t.isAfter(m)?!1:d,c=await R.speedLoseAt(e,c,t,s,0,d,r,u),g=g||c,c.important&&h.push(c),t.isSameOrAfter(o)&&(y.push(c),o.add(24,"hour"));const p=q.LaneHelper.calculateDistance(c,w,!w.gcToPrevious);let l=Math.round(p/g.speed*1e5)/1e5;if(f+l<i){if(f+=l,t.add(l,"hour"),delete a[v],I==null||I.debug(`[%s] go to %j from %j with ${p}nm, and cost ${l} hours`,u.requestId,{lat:w.lat,lng:w.lng},{lat:g.lat,lng:g.lng,etd:g.etd}),j+=p,a.filter(S=>S).length<=1){F=w,F.eta=t.utc().format(),F.distanceFromPrevious=p,F.distanceFromStart=Math.round((n+j)*1e4)/1e4,h.push(F),delete a[v+1];break}}else{l=i-f,t.add(l,"hour");const S=q.LngLatHelper.roundPrecision(g.speed*l,5);F=q.LaneHelper.calculateCoordinate(c,e.bearing,S,"nauticalmiles",!w.gcToPrevious),F.eta=t.utc().format(),a[v]=F,I==null||I.debug(`[%s] go to %j from %j with ${S}nm, and cost ${l} hours`,u.requestId,{lat:F.lat,lng:F.lng},{lat:c.lat,lng:c.lng,etd:c.etd}),j+=S,F.distanceFromPrevious=Math.round(j*1e4)/1e4,F.distanceFromStart=Math.round((n+j)*1e4)/1e4;break}}return{etd:t,from:g,to:F,next:a.filter(v=>v),wps:h,days:y}}static currentFactor(e,t,o=0){const i=(e-(t==null?void 0:t.degree)||0)/180*Math.PI;if(Math.abs(i)===Math.PI/2)return 0;let n=((t==null?void 0:t.kts)||0)*Math.cos(i);return o&2?n=Math.ceil(n*100)/100:o&1?n=Math.floor(n*100)/100:n=Math.round(n*100)/100,Math.abs(n)>5?0:n}static weatherFactor(e,t){var m,h,y,f,j,F,g;I==null||I.debug("calculate weather factor via: %j",{...e,...t});const o=R.blockCoefficient(e.displacement,e.lbp,e.breadthMoulded,e.draught),i=R.froudeNumber(e.speed,e.lbp),n=R.amendFactor(o,i,e.loadCondition);let a=Math.abs(e.bearing%360-(((m=t==null?void 0:t.wind)==null?void 0:m.degree)%360||0));a=a>180?360-a:a;const s=R.directionFactor(a,(h=t==null?void 0:t.wind)==null?void 0:h.scale),d=R.vesselTagFactor(e.displacement,e.loadCondition,e.tag,(y=t==null?void 0:t.wind)==null?void 0:y.scale);let r=s*n*d/100*e.speed;r=Math.round(r*1.943844*1e4)/1e4*-1,e.tag==="tugs"&&Math.abs(r)>1&&(r=r/(Math.abs(Math.round(r))+1)),I==null||I.debug("wind wx factor = %d",r),a=Math.abs(e.bearing%360-(((j=(f=t==null?void 0:t.wave)==null?void 0:f.sig)==null?void 0:j.degree)%360||0));const u=R.waveHeightFactor(((g=(F=t==null?void 0:t.wave)==null?void 0:F.sig)==null?void 0:g.height)??1,a);return I==null||I.debug("wave wx factor = %d",u),r=r*.4+u,I==null||I.debug("weather factor = %d",r),r=Math.abs(r)>4?4*(Math.abs(r)/r)+Math.abs(r)/r*(Math.abs(r)-4)*.1:r,Math.round((r||0)*100)/100}static async analyseInstant(e,t,o,i,n,a="",s=0,d=!0,r=!1,u={}){var Q,X,Z,$,tt;const m=b().valueOf();e.lng=q.LngLatHelper.convertToStdLng(e.lng);const{route:h,waypoints:y}=n.points,f=q.LaneHelper.calculateSubRoute(e,h);if(((Q=f[0])==null?void 0:Q.length)<=1)return;const{v0:j,label:F}=e.sog?{v0:e.sog,label:"Other"}:{v0:i.speed,label:"CP"},g=R.assembleProperties(o,i.loadCondition,j,0),v=y.length?q.LaneHelper.calculateSubWaypoints(e,y):[];v.forEach(W=>W.important=!0);const c={from:{...e},route:f,waypoints:v,v0:j,label:F},w={hours:[],days:[],wps:[]};s||(q.LaneHelper.calculateRouteDistance(f)/i.speed<=72?s=3:s=6);let p=q.LaneHelper.simplifyRouteToCoordinates(f,v,0),l=0,S=0,k=0,L=0;t=b(t).utc();const Y=t.clone();for(;p.length>0;){const W=s-t.hour()%s,_=Math.ceil(t.clone().add(W,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4,x=await R.speedLoseInHoursStep(g,t,Y,_,l,p,a,d,r,u);(X=x.from)!=null&&X.speed&&(w.hours.push(x.from),w.wps.push(...x.wps),w.days.push(...x.days)),p=x==null?void 0:x.next,p.length||w.hours.push(x==null?void 0:x.to),l+=Math.round((((Z=x==null?void 0:x.to)==null?void 0:Z.distanceFromPrevious)??0)*1e4)/1e4}const H=w.hours;for(let W=0;W<H.length-1;W++){const _=b(H[W+1].eta).diff(H[W].etd,"hour",!0)||1;S+=(H[W].wxFactor||0)*_,k+=(H[W].cFactor||0)*_,L+=_}($=w.wps)==null||$.forEach((W,_)=>{if(W.positionTime=b.utc(W.etd||W.eta).unix(),_){const x=w.wps[_-1],J=W.distanceFromStart-x.distanceFromStart,O=b(W.eta).diff(b(x.etd),"h",!0);O<.5?W.avgSpd=x.speed:W.avgSpd=Math.round(J/O*100)/100}}),c.sample=w;const N=w.hours.at(0),E=w.hours.at(-1);c.distance=Math.round(E.distanceFromStart*1e4)/1e4,c.etd=b(N.eta).utc().format(),c.eta=b(E.eta).utc().format(),c.wxFactor=Math.round(S/L*1e4)/1e4,c.cFactor=Math.round(k/L*1e4)/1e4,c.avgSpeed=Math.round(E.distanceFromStart/L*1e4)/1e4,c.totalHrs=Math.round(L*1e4)/1e4;const{distanceInECA:C,hoursInECA:A,totalDgoConsInECA:V,eca:K}=await this.calculateECA(c,i,u),st=q.LngLatHelper.roundPrecision(i.fo/24*(L-A),3),at=q.LngLatHelper.roundPrecision(i.dgo/24*L,3);c.extend={eca:K,distanceInECA:C,hoursInECA:A,totalDgoConsInECA:V},c.totalFoCons=st,c.totalDgoCons=at;const et=b().valueOf()-m,nt=((tt=w==null?void 0:w.hours)==null?void 0:tt.length)||1;return I==null||I.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms",u==null?void 0:u.requestId,et,nt,Math.round(et/nt*1e3)/1e3),c}static async analyseInstantWithThreshed(e,t,o,i,n,a,s,d="",r=3,u=!0,m=!1,h={}){var Z,$,tt,W,_;const y=b().valueOf();e.lng=q.LngLatHelper.convertToStdLng(e.lng);const{v0:f,label:j}=e.sog?{v0:e.sog,label:"Other"}:{v0:n.speed,label:"CP"},F=R.assembleProperties(i,n.loadCondition,f,0),g=q.LaneHelper.calculateSubRoute(e,a);if(((Z=g[0])==null?void 0:Z.length)<=1)return;const v=s.length?q.LaneHelper.calculateSubWaypoints(e,s):[];v.forEach(x=>x.important=!0);let c=q.LaneHelper.simplifyRouteToCoordinates(g,v,0),w=0,p=0,l=0,S=0;const k={hours:[],wps:[],days:[]};t=b(t).utc();const L=t.clone();for(;c.length>0;){const x=r-t.hour()%r;let J=Math.ceil(t.clone().add(x,"h").set({minute:0,second:0,millisecond:0}).diff(t,"h",!0)*1e4)/1e4;J=t.clone().add(J,"h").isSameOrAfter(o)?o.diff(t,"h",!0)*1e4/1e4:J;const O=await R.speedLoseInHoursStep(F,t,L,J,w,c,d,u,m,h);if(($=O.from)!=null&&$.speed&&(k.hours.push(O.from),O!=null&&O.wps&&k.wps.push(...O.wps),k.days.push(...O.days)),c=O==null?void 0:O.next,c.length||k.hours.push(O==null?void 0:O.to),w+=Math.round((((tt=O==null?void 0:O.to)==null?void 0:tt.distanceFromPrevious)??0)*1e4)/1e4,!J)break}(W=k.wps)==null||W.forEach((x,J)=>{if(J){const O=k.wps[J-1],gt=x.distanceFromStart-O.distanceFromStart,ft=b(x.eta).diff(b(O.etd),"h",!0);ft<.5?x.avgSpd=O.speed:x.avgSpd=Math.round(gt/ft*100)/100}});const Y=k.hours;for(let x=0;x<Y.length-1;x++){const J=b(Y[x+1].eta).diff(Y[x].etd,"hour",!0);p+=Y[x].wxFactor*J,l+=Y[x].cFactor*J,S+=J}const H=k.hours.at(0),N=k.hours.at(-1),E=await q.LaneHelper.calculateRangeRoute(H,N,g),C=await q.LaneHelper.calculateRangeWaypoints(H,N,g,v),A={sample:k,distance:Math.round(((N==null?void 0:N.distanceFromStart)||0)*1e4)/1e4,etd:b(H.eta).utc().format(),eta:b(N==null?void 0:N.eta).utc().format(),wxFactor:Math.round(p/S*1e4)/1e4,cFactor:Math.round(l/S*1e4)/1e4,avgSpeed:Math.round(((N==null?void 0:N.distanceFromStart)||0)/S*1e4)/1e4,totalHrs:Math.round(S*1e4)/1e4,from:H,to:N,route:E,waypoints:C,v0:f,label:j},{distanceInECA:V,hoursInECA:K,totalDgoConsInECA:st,eca:at}=await this.calculateECA(A,n,h),ht=q.LngLatHelper.roundPrecision(n.fo/24*(S-K),3),et=q.LngLatHelper.roundPrecision(n.dgo/24*S,3);A.extend={eca:at,distanceInECA:V,hoursInECA:K,totalDgoConsInECA:st},A.totalDgoCons=et,A.totalFoCons=ht;const Q=b().valueOf()-y,X=((_=k==null?void 0:k.hours)==null?void 0:_.length)||1;return I==null||I.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms",h==null?void 0:h.requestId,Q,X,Math.round(Q/X*1e3)/1e3),A}static async analyseCost(e,t,o,i,n={}){var g,v;const a=b().valueOf(),s=[];n.meteo2=n.meteo2||!0,e.speedStep=e.speedStep||3,e.alterStep=e.alterStep??1;const d=q.LaneHelper.calculateRouteDistance(i.route);let r=0;o.forEach(c=>{const w=Math.ceil(d/c.speed/24);r=r<w?w:r}),r=r*1.3;const u=b.utc(e.etd).add(r??14,"day");let m=1;for(const c of o){const w=JSON.parse(JSON.stringify(i.route)),p=JSON.parse(JSON.stringify(i.waypoints)),l=await R.analyseInstantWithThreshed({lat:e.lat,lng:e.lng},e.etd,u,t,c,w,p,e.meteoVendor,e.speedStep,e.useMeteo,e.useRouteParam,n);l&&(await R.calculateCost(l,c,e,n),s.push(l),I==null||I.info("[%s][L%d-%d] analyse from %s to %s cost: %j",n.requestId,1,m,e.etd,u.format(),{cost:l.cost.total,distance:l.distance,hours:l.totalHrs,cp:`${c.speed}/${c.fo}/${c.dgo}`})),m++}s.sort((c,w)=>c.cost.total-w.cost.total);const h=s.at(0),y=s.at(1),f=[];if(f.push({combined:!1,speeds:[h],cost:(g=h.cost)==null?void 0:g.total}),y){const c=h.cost.cp,w=y.cost.cp,p=b(h.eta),l=b(h.etd),S=p.diff(l,"days",!0);let k=Math.ceil(S/2);k=k>7?7:k<e.alterStep?e.alterStep:k;let L=2,Y={combined:!1,speeds:[y],cost:(v=y.cost)==null?void 0:v.total},H;for(;k>=e.alterStep;){const N=await R.combinedAnalyse(e,t,u,[c,w],i,k,{...n,level:L});if(Y.cost>N.cost?H?(H==null?void 0:H.cost)>N.cost&&(H=N):(H=Y,Y=N):(!H||(H==null?void 0:H.cost)>N.cost)&&(H=N),k<=e.alterStep)break;k=Math.ceil(k/2),L+=1}f.push(Y),H&&f.push(H)}const F=b().valueOf()-a;return I==null||I.info("[%s] analyse elapsed: %d ms",n==null?void 0:n.requestId,F),f.sort((c,w)=>c.cost-w.cost)}static async combinedAnalyse(e,t,o,i,n,a,s={}){s.counter=1,I==null||I.info("[%s][L%d] analyse with alternate cp in every %d days",s.requestId,s.level,a);const d=await R.alternateAnalyse(e,t,o,i,0,n,a,s),r=d.reduce((h,y)=>h+y.cost.total,0);I==null||I.info("[%s][L%d] cost with cpa/cpb turn: %d",s.requestId,s.level,r);const u=await R.alternateAnalyse(e,t,o,i,1,n,a,s),m=u.reduce((h,y)=>h+y.cost.total,0);return I==null||I.info("[%s][L%d] cost with cpb/cpa turn: %d",s.requestId,s.level,m),r<m?{combined:!0,cost:Math.round(r*1e3)/1e3,speeds:d,step:a}:{combined:!0,cost:Math.round(m*1e3)/1e3,speeds:u,step:a}}static async alternateAnalyse(e,t,o,i,n,a,s,d={}){var h,y;let r=b.utc(e.etd);const u={lat:e.lat,lng:e.lng},m=[];for(;r.isBefore(o);){const f=r.clone().utc().add(s,"day"),j=JSON.parse(JSON.stringify(a.route)),F=JSON.parse(JSON.stringify(a.waypoints)),g=i[n],v=await R.analyseInstantWithThreshed(u,r.utc().format(),f,t,g,j,F,e.meteoVendor,e.speedStep,e.useMeteo,e.useRouteParam,d);v&&(await R.calculateCost(v,g,e,d),I==null||I.info("[%s][L%d-%d] analyse from %s to %s cost: %j",d.requestId,d.level,d.counter,r.utc().format(),f.utc().format(),{cost:v.cost.total,distance:v.distance,hours:v.totalHrs,cp:`${g.speed}/${g.fo}/${g.dgo}`})),d.counter=d.counter+1;const c=(y=(h=v==null?void 0:v.sample)==null?void 0:h.hours)==null?void 0:y.at(-1);if(c)u.lat=c.lat,u.lng=c.lng,r=b(c.eta),m.push(v),n=n?0:1;else break}return m}static async calculateCost(e,t,o,i={}){var n;if(e){const a=Math.round(e.totalHrs/24*(o.dailyHire||0)*(1-(o.addComm||0))*1e3)/1e3,s=Math.round(e.totalFoCons*(o.priceFO||0)*1e3)/1e3,d=Math.round((e.totalDgoCons+(((n=e.extend)==null?void 0:n.totalDgoConsInECA)||0))*(o.priceDGO||0)*1e3)/1e3;e.cost={total:Math.round((a+s+d)*1e3)/1e3,hire:a,bunker:Math.round((s+d)*1e3)/1e3,cp:t}}return e}static async calculateECA(e,t,o={}){var d,r;const i=await q.LaneHelper.intersectInECA(e.route);let n=0,a=0,s=0;e.sample.wps.forEach(u=>{u.positionTime=b.utc(u.etd||u.eta).unix()});for(const u of i){n+=u.distance;const m=await q.LaneHelper.deadReckoningTime((d=u.waypoints)==null?void 0:d.at(0),e.sample.wps),h=await q.LaneHelper.deadReckoningTime((r=u.waypoints)==null?void 0:r.at(-1),e.sample.wps);u.in=m,u.out=h,u.totalHrs=q.LngLatHelper.roundPrecision((h.positionTime-m.positionTime)/3600,2),u.totalDgoCons=q.LngLatHelper.roundPrecision(t.fo/24*u.totalHrs,3),a+=u.totalHrs,s+=u.totalDgoCons}return n=q.LngLatHelper.roundPrecision(n,3),a=q.LngLatHelper.roundPrecision(a,3),s=q.LngLatHelper.roundPrecision(s,3),{distanceInECA:n,hoursInECA:a,totalDgoConsInECA:s,eca:i}}static async mergeSpeeds(e,t={}){var c,w;const o={hours:[],wps:[],days:[]},i=e.reduce((p,l)=>p+l.distance,0),n=e.reduce((p,l)=>{var S;return p+(((S=l.extend)==null?void 0:S.distanceInECA)||0)},0),a=e.reduce((p,l)=>p+l.totalHrs,0),s=e.reduce((p,l)=>{var S;return p+(((S=l.extend)==null?void 0:S.hoursInECA)||0)},0),d=e.reduce((p,l)=>{var S;return p+(((S=l.extend)==null?void 0:S.totalDgoConsInECA)||0)},0),r=e.reduce((p,l)=>p+l.wxFactor*l.totalHrs/a,0),u=e.reduce((p,l)=>p+l.cFactor*l.totalHrs/a,0),m=e.reduce((p,l)=>p+l.totalFoCons,0),h=e.reduce((p,l)=>p+l.totalDgoCons,0),y=e.reduce((p,l)=>p+l.cost.total,0),f=e.reduce((p,l)=>p+l.cost.hire,0),j=e.reduce((p,l)=>p+l.cost.bunker,0),F=[],g=[];let v;for(const p of e){g.push(...((c=p.extend)==null?void 0:c.eca)||[]);const l=p.sample.hours,S=p.sample.wps,k=p.sample.days,L=l.at(0);v&&(L.distanceFromPrevious=v.distanceFromPrevious,L.distanceFromStart=v.distanceFromStart,l.forEach((E,C)=>{C&&(E.distanceFromStart=E.distanceFromStart+v.distanceFromStart)}),S.at(0).distanceFromPrevious=v.distanceFromPrevious,S.at(0).distanceFromStart=v.distanceFromStart,S.forEach((E,C)=>{C&&(E.distanceFromStart=E.distanceFromStart+v.distanceFromStart)}),k.at(0).distanceFromPrevious=v.distanceFromPrevious,k.at(0).distanceFromStart=v.distanceFromStart,k.forEach((E,C)=>{C&&(E.distanceFromStart=E.distanceFromStart+v.distanceFromStart)})),L.cp=p.cost.cp;const Y=[p.etd,p.eta],H=F.findIndex(E=>E.id===L.cp.id);H===-1?(L.cp.segment=[Y],F.push(L.cp)):F[H].segment.push(Y),l.forEach(E=>{var A;((A=o.hours)==null?void 0:A.findIndex(V=>V.eta===E.eta))===-1&&o.hours.push(E)}),S.forEach(E=>{var A;((A=o.wps)==null?void 0:A.findIndex(V=>V.eta===E.eta))===-1&&o.wps.push(E)}),k.forEach(E=>{var A;((A=o==null?void 0:o.days)==null?void 0:A.findIndex(V=>V.eta===E.eta))===-1&&o.days.push(E)});const N=(w=o.wps)==null?void 0:w.findIndex(E=>E.eta===L.eta);N===-1?o.wps.push(L):o.wps[N]=L,v=l.at(-1)}return o.wps.sort((p,l)=>{b(p.etd).unix()-b(l.etd).unix()}),{sample:o,etd:e.at(0).etd,eta:e.at(-1).eta,from:e.at(0).from,to:e.at(-1).to,v0:e.at(0).v0,label:"Combined",distance:Math.round(i*1e4)/1e4,totalHrs:Math.round(a*1e3)/1e3,avgSpeed:Math.round(i/a*1e3)/1e3,wxFactor:Math.round(r/a*1e3)/1e3,cFactor:Math.round(u/a*1e3)/1e3,totalFoCons:Math.round(m*1e3)/1e3,totalDgoCons:Math.round(h*1e3)/1e3,cost:{total:Math.round(y*1e3)/1e3,hire:Math.round(f*1e3)/1e3,bunker:Math.round(j*1e3)/1e3},extend:{cps:F,eca:g,distanceInECA:Math.round(n*1e4)/1e4,hoursInECA:Math.round(s*1e3)/1e3,totalDgoConsInECA:Math.round(d*1e3)/1e3,speeds:e}}}}D.AISImpl=U,D.AlertHelper=ct,D.AlertLevel=rt,D.HifleetImpl=yt,D.LoadCondition=ut,D.MyShipImpl=pt,D.MyVesselImpl=mt,D.ShipxyImpl=Mt,D.SpeedHelper=R,D.SpeedLabel=lt,D.VesselTag=dt,D.alertHelper=bt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
@@ -339,21 +339,24 @@ export declare class SpeedHelper {
339
339
  v0: any;
340
340
  label: string;
341
341
  distance: number;
342
- distanceInECA: number;
343
342
  totalHrs: number;
344
- hoursInECA: number;
345
343
  avgSpeed: number;
346
344
  wxFactor: number;
347
345
  cFactor: number;
348
346
  totalFoCons: number;
349
347
  totalDgoCons: number;
350
- totalDgoConsInECA: number;
351
348
  cost: {
352
349
  total: number;
353
350
  hire: number;
354
351
  bunker: number;
355
352
  };
356
- cps: any[];
357
- eca: any;
353
+ extend: {
354
+ cps: any[];
355
+ eca: any;
356
+ distanceInECA: number;
357
+ hoursInECA: number;
358
+ totalDgoConsInECA: number;
359
+ speeds: any[];
360
+ };
358
361
  }>;
359
362
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idm-plugin/vessel",
3
3
  "private": false,
4
- "version": "1.7.1",
4
+ "version": "1.7.3",
5
5
  "description": "idm plugin for vessel",
6
6
  "type": "module",
7
7
  "keywords": [