@signalk/freeboard-sk 1.21.2 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,39 @@
1
1
  # CHANGELOG: Freeboard
2
2
 
3
+ ### v1.22.0
4
+
5
+ - **Add**: Additional settings to control the way vessel trail is retrieved from the server.
6
+
7
+ - **Update**: Improved rendering of vessel trail when retrieved from the server.
8
+
9
+ - **Fix**: Trail to Route not honoring `Include Trail from Server` on tolerance change.
10
+
11
+
12
+ ### v1.21.2
13
+
14
+ - **Update**: Allow seconds to be specified when setting targetArrivalTime.
15
+ - **Fix**: Error handling when targetArrivalTime.
16
+
17
+
18
+ ### v1.21.1
19
+
20
+ - **Fix**: VMG display value is incorrect.
21
+
22
+
23
+ ### v1.21.0
24
+
25
+ - **Add**: Ability to apply targetArrivalTime when a destination is active at the path navigation.course.targetArrivalTime
26
+
27
+ - **Add**: Support to display Icon in WebApps list.
28
+
29
+
3
30
  ### v1.20.0
4
31
 
5
32
  - **Add**: Ability to supply url parameters to set the following configuration: `northup`, `zoom` and `movemap`. See Help for details. (closes #110)
6
33
 
7
34
  - **Experiment**: View weather forecast information provided by `openweather-signalk` plugin.
8
35
 
36
+
9
37
  ### v1.19.4
10
38
 
11
39
  - **Update**: Change select all/none on resource lists to only operate on the visible (filtered) list items. (closes #107)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/freeboard-sk",
3
- "version": "1.21.2",
3
+ "version": "1.22.0",
4
4
  "description": "Openlayers chartplotter implementation for Signal K",
5
5
  "keywords": [
6
6
  "signalk-webapp",
@@ -0,0 +1 @@
1
+ !function(){var t={8255:function(t){function e(t){return Promise.resolve().then(function(){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e})}e.keys=function(){return[]},e.resolve=e,e.id=8255,t.exports=e},5686:function(t,e){"use strict";function s(t,e){return t*t+e*e}function i(t,e){return s(t[0]-e[0],t[1]-e[1])}function n(t,e,i){var n=e[0],r=e[1],o=i[0]-n,a=i[1]-r;if(0!==o||0!==a){var l=((t[0]-n)*o+(t[1]-r)*a)/s(o,a);l>1?(n=i[0],r=i[1]):l>0&&(n+=o*l,r+=a*l)}return s(t[0]-n,t[1]-r)}function r(t,e,s,i,o){for(var a,l=i,c=e+1;c<s;c++){var u=n(t[c],t[e],t[s]);u>l&&(a=c,l=u)}l>i&&(a-e>1&&r(t,e,a,i,o),o.push(t[a]),s-a>1&&r(t,a,s,i,o))}function o(t,e){var s=t.length-1,i=[t[0]];return r(t,0,s,e,i),i.push(t[s]),i}e.__esModule=!0,e.SimplifyAP=function(t,e,s){if(void 0===e&&(e=1),void 0===s&&(s=!1),t.length<=2)return t;var n=e*e;return o(t=s?t:function(t,e){for(var s,n=t[0],r=[n],o=1,a=t.length;o<a;o++)i(s=t[o],n)>e&&(r.push(s),n=s);return n!==s&&r.push(s),r}(t,n),n)}},8332:function(t,e,s){"use strict";var i=s(5686);e.EK=i.SimplifyAP,s(3981),s(2165)},3981:function(t,e){"use strict";function s(t,e){return t*t+e*e}function i(t,e){return s(t.longitude-e.longitude,t.latitude-e.latitude)}function n(t,e,i){var n=e.longitude,r=e.latitude,o=i.longitude-n,a=i.latitude-r;if(0!==o||0!==a){var l=((t.longitude-n)*o+(t.latitude-r)*a)/s(o,a);l>1?(n=i.longitude,r=i.latitude):l>0&&(n+=o*l,r+=a*l)}return s(t.longitude-n,t.latitude-r)}function r(t,e,s,i,o){for(var a,l=i,c=e+1;c<s;c++){var u=n(t[c],t[e],t[s]);u>l&&(a=c,l=u)}l>i&&(a-e>1&&r(t,e,a,i,o),o.push(t[a]),s-a>1&&r(t,a,s,i,o))}function o(t,e){var s=t.length-1,i=[t[0]];return r(t,0,s,e,i),i.push(t[s]),i}e.__esModule=!0,e.SimplifyLL=function(t,e,s){if(void 0===e&&(e=1),void 0===s&&(s=!1),t.length<=2)return t;var n=e*e;return o(t=s?t:function(t,e){for(var s,n=t[0],r=[n],o=1,a=t.length;o<a;o++)i(s=t[o],n)>e&&(r.push(s),n=s);return n!==s&&r.push(s),r}(t,n),n)}},2165:function(t,e){"use strict";function s(t,e){return t*t+e*e}function i(t,e){return s(t.x-e.x,t.y-e.y)}function n(t,e,i){var n=e.x,r=e.y,o=i.x-n,a=i.y-r;if(0!==o||0!==a){var l=((t.x-n)*o+(t.y-r)*a)/s(o,a);l>1?(n=i.x,r=i.y):l>0&&(n+=o*l,r+=a*l)}return s(t.x-n,t.y-r)}function r(t,e,s,i,o){for(var a,l=i,c=e+1;c<s;c++){var u=n(t[c],t[e],t[s]);u>l&&(a=c,l=u)}l>i&&(a-e>1&&r(t,e,a,i,o),o.push(t[a]),s-a>1&&r(t,a,s,i,o))}function o(t,e){var s=t.length-1,i=[t[0]];return r(t,0,s,e,i),i.push(t[s]),i}e.__esModule=!0,e.Simplify=function(t,e,s){if(void 0===e&&(e=1),void 0===s&&(s=!1),t.length<=2)return t;var n=e*e;return o(t=s?t:function(t,e){for(var s,n=t[0],r=[n],o=1,a=t.length;o<a;o++)i(s=t[o],n)>e&&(r.push(s),n=s);return n!==s&&r.push(s),r}(t,n),n)}}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var r=e[i]={exports:{}};return t[i](r,r.exports,s),r.exports}s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},function(){"use strict";function t(t){return"function"==typeof t}let e=!1;const i={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){if(t){const t=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+t.stack)}else e&&console.log("RxJS: Back to a better error behavior. Thank you. <3");e=t},get useDeprecatedSynchronousErrorHandling(){return e}};function n(t){setTimeout(()=>{throw t},0)}const r={closed:!0,next(t){},error(t){if(i.useDeprecatedSynchronousErrorHandling)throw t;n(t)},complete(){}},o=Array.isArray||(t=>t&&"number"==typeof t.length);function a(t){return null!==t&&"object"==typeof t}const l=(()=>{function t(t){return Error.call(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((t,e)=>`${e+1}) ${t.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t,this}return t.prototype=Object.create(Error.prototype),t})();class c{constructor(t){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}unsubscribe(){let e;if(this.closed)return;let{_parentOrParents:s,_ctorUnsubscribe:i,_unsubscribe:n,_subscriptions:r}=this;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,s instanceof c)s.remove(this);else if(null!==s)for(let t=0;t<s.length;++t)s[t].remove(this);if(t(n)){i&&(this._unsubscribe=void 0);try{n.call(this)}catch(u){e=u instanceof l?h(u.errors):[u]}}if(o(r)){let t=-1,s=r.length;for(;++t<s;){const s=r[t];if(a(s))try{s.unsubscribe()}catch(d){e=e||[],d instanceof l?e=e.concat(h(d.errors)):e.push(d)}}}if(e)throw new l(e)}add(t){let e=t;if(!t)return c.EMPTY;switch(typeof t){case"function":e=new c(t);case"object":if(e===this||e.closed||"function"!=typeof e.unsubscribe)return e;if(this.closed)return e.unsubscribe(),e;if(!(e instanceof c)){const t=e;e=new c,e._subscriptions=[t]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}let{_parentOrParents:s}=e;if(null===s)e._parentOrParents=this;else if(s instanceof c){if(s===this)return e;e._parentOrParents=[s,this]}else{if(-1!==s.indexOf(this))return e;s.push(this)}const i=this._subscriptions;return null===i?this._subscriptions=[e]:i.push(e),e}remove(t){const e=this._subscriptions;if(e){const s=e.indexOf(t);-1!==s&&e.splice(s,1)}}}var u;function h(t){return t.reduce((t,e)=>t.concat(e instanceof l?e.errors:e),[])}c.EMPTY=((u=new c).closed=!0,u);const d="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random();class p extends c{constructor(t,e,s){switch(super(),this.syncErrorValue=null,this.syncErrorThrown=!1,this.syncErrorThrowable=!1,this.isStopped=!1,arguments.length){case 0:this.destination=r;break;case 1:if(!t){this.destination=r;break}if("object"==typeof t){t instanceof p?(this.syncErrorThrowable=t.syncErrorThrowable,this.destination=t,t.add(this)):(this.syncErrorThrowable=!0,this.destination=new f(this,t));break}default:this.syncErrorThrowable=!0,this.destination=new f(this,t,e,s)}}[d](){return this}static create(t,e,s){const i=new p(t,e,s);return i.syncErrorThrowable=!1,i}next(t){this.isStopped||this._next(t)}error(t){this.isStopped||(this.isStopped=!0,this._error(t))}complete(){this.isStopped||(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe())}_next(t){this.destination.next(t)}_error(t){this.destination.error(t),this.unsubscribe()}_complete(){this.destination.complete(),this.unsubscribe()}_unsubscribeAndRecycle(){const{_parentOrParents:t}=this;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=t,this}}class f extends p{constructor(e,s,i,n){super(),this._parentSubscriber=e;let o,a=this;t(s)?o=s:s&&(o=s.next,i=s.error,n=s.complete,s!==r&&(a=Object.create(s),t(a.unsubscribe)&&this.add(a.unsubscribe.bind(a)),a.unsubscribe=this.unsubscribe.bind(this))),this._context=a,this._next=o,this._error=i,this._complete=n}next(t){if(!this.isStopped&&this._next){const{_parentSubscriber:e}=this;i.useDeprecatedSynchronousErrorHandling&&e.syncErrorThrowable?this.__tryOrSetError(e,this._next,t)&&this.unsubscribe():this.__tryOrUnsub(this._next,t)}}error(t){if(!this.isStopped){const{_parentSubscriber:e}=this,{useDeprecatedSynchronousErrorHandling:s}=i;if(this._error)s&&e.syncErrorThrowable?(this.__tryOrSetError(e,this._error,t),this.unsubscribe()):(this.__tryOrUnsub(this._error,t),this.unsubscribe());else if(e.syncErrorThrowable)s?(e.syncErrorValue=t,e.syncErrorThrown=!0):n(t),this.unsubscribe();else{if(this.unsubscribe(),s)throw t;n(t)}}}complete(){if(!this.isStopped){const{_parentSubscriber:t}=this;if(this._complete){const e=()=>this._complete.call(this._context);i.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,e),this.unsubscribe()):(this.__tryOrUnsub(e),this.unsubscribe())}else this.unsubscribe()}}__tryOrUnsub(t,e){try{t.call(this._context,e)}catch(s){if(this.unsubscribe(),i.useDeprecatedSynchronousErrorHandling)throw s;n(s)}}__tryOrSetError(t,e,s){if(!i.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{e.call(this._context,s)}catch(r){return i.useDeprecatedSynchronousErrorHandling?(t.syncErrorValue=r,t.syncErrorThrown=!0,!0):(n(r),!0)}return!1}_unsubscribe(){const{_parentSubscriber:t}=this;this._context=null,this._parentSubscriber=null,t.unsubscribe()}}const b="function"==typeof Symbol&&Symbol.observable||"@@observable";function m(t){return t}let g=(()=>{class t{constructor(t){this._isScalar=!1,t&&(this._subscribe=t)}lift(e){const s=new t;return s.source=this,s.operator=e,s}subscribe(t,e,s){const{operator:n}=this,o=function(t,e,s){if(t){if(t instanceof p)return t;if(t[d])return t[d]()}return t||e||s?new p(t,e,s):new p(r)}(t,e,s);if(o.add(n?n.call(o,this.source):this.source||i.useDeprecatedSynchronousErrorHandling&&!o.syncErrorThrowable?this._subscribe(o):this._trySubscribe(o)),i.useDeprecatedSynchronousErrorHandling&&o.syncErrorThrowable&&(o.syncErrorThrowable=!1,o.syncErrorThrown))throw o.syncErrorValue;return o}_trySubscribe(t){try{return this._subscribe(t)}catch(e){i.useDeprecatedSynchronousErrorHandling&&(t.syncErrorThrown=!0,t.syncErrorValue=e),function(t){for(;t;){const{closed:e,destination:s,isStopped:i}=t;if(e||i)return!1;t=s&&s instanceof p?s:null}return!0}(t)?t.error(e):console.warn(e)}}forEach(t,e){return new(e=v(e))((e,s)=>{let i;i=this.subscribe(e=>{try{t(e)}catch(n){s(n),i&&i.unsubscribe()}},s,e)})}_subscribe(t){const{source:e}=this;return e&&e.subscribe(t)}[b](){return this}pipe(...t){return 0===t.length?this:function(t){return 0===t.length?m:1===t.length?t[0]:function(e){return t.reduce((t,e)=>e(t),e)}}(t)(this)}toPromise(t){return new(t=v(t))((t,e)=>{let s;this.subscribe(t=>s=t,t=>e(t),()=>t(s))})}}return t.create=e=>new t(e),t})();function v(t){if(t||(t=i.Promise||Promise),!t)throw new Error("no Promise impl found");return t}const y=(()=>{function t(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return t.prototype=Object.create(Error.prototype),t})();class w extends c{constructor(t,e){super(),this.subject=t,this.subscriber=e,this.closed=!1}unsubscribe(){if(this.closed)return;this.closed=!0;const t=this.subject,e=t.observers;if(this.subject=null,!e||0===e.length||t.isStopped||t.closed)return;const s=e.indexOf(this.subscriber);-1!==s&&e.splice(s,1)}}class _ extends p{constructor(t){super(t),this.destination=t}}let x=(()=>{class t extends g{constructor(){super(),this.observers=[],this.closed=!1,this.isStopped=!1,this.hasError=!1,this.thrownError=null}[d](){return new _(this)}lift(t){const e=new k(this,this);return e.operator=t,e}next(t){if(this.closed)throw new y;if(!this.isStopped){const{observers:e}=this,s=e.length,i=e.slice();for(let n=0;n<s;n++)i[n].next(t)}}error(t){if(this.closed)throw new y;this.hasError=!0,this.thrownError=t,this.isStopped=!0;const{observers:e}=this,s=e.length,i=e.slice();for(let n=0;n<s;n++)i[n].error(t);this.observers.length=0}complete(){if(this.closed)throw new y;this.isStopped=!0;const{observers:t}=this,e=t.length,s=t.slice();for(let i=0;i<e;i++)s[i].complete();this.observers.length=0}unsubscribe(){this.isStopped=!0,this.closed=!0,this.observers=null}_trySubscribe(t){if(this.closed)throw new y;return super._trySubscribe(t)}_subscribe(t){if(this.closed)throw new y;return this.hasError?(t.error(this.thrownError),c.EMPTY):this.isStopped?(t.complete(),c.EMPTY):(this.observers.push(t),new w(this,t))}asObservable(){const t=new g;return t.source=this,t}}return t.create=(t,e)=>new k(t,e),t})();class k extends x{constructor(t,e){super(),this.destination=t,this.source=e}next(t){const{destination:e}=this;e&&e.next&&e.next(t)}error(t){const{destination:e}=this;e&&e.error&&this.destination.error(t)}complete(){const{destination:t}=this;t&&t.complete&&this.destination.complete()}_subscribe(t){const{source:e}=this;return e?this.source.subscribe(t):c.EMPTY}}"function"==typeof Symbol&&Symbol.iterator&&Symbol;function T(t){return{token:t.token,providedIn:t.providedIn||null,factory:t.factory,value:void 0}}Error;const S="undefined"!=typeof globalThis&&globalThis;"undefined"!=typeof window&&window,"undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self;S||"undefined"!=typeof global&&global;Symbol;class M{constructor(){this.version=4,this.hex="",this.limitUI04=this.maxFromBits(4),this.limitUI06=this.maxFromBits(6),this.limitUI08=this.maxFromBits(8),this.limitUI12=this.maxFromBits(12),this.limitUI14=this.maxFromBits(14),this.limitUI16=this.maxFromBits(16),this.limitUI32=this.maxFromBits(32),this.limitUI40=this.maxFromBits(40),this.limitUI48=this.maxFromBits(48),this.create()}toString(){return this.hex}toURN(){return"urn:uuid:"+this.hex}toSignalK(){return`urn:mrn:signalk:uuid:${this.hex}`}toBytes(){let t=this.hex.split("-"),e=[],s=0;for(let i=0;i<t.length;i++)for(let n=0;n<t[i].length;n+=2)e[s++]=parseInt(t[i].substr(n,2),16);return e}maxFromBits(t){return Math.pow(2,t)}getRandomInt(t,e){return Math.floor(Math.random()*(e-t+1))+t}randomUI04(){return this.getRandomInt(0,this.limitUI04-1)}randomUI06(){return this.getRandomInt(0,this.limitUI06-1)}randomUI08(){return this.getRandomInt(0,this.limitUI08-1)}randomUI12(){return this.getRandomInt(0,this.limitUI12-1)}randomUI14(){return this.getRandomInt(0,this.limitUI14-1)}randomUI16(){return this.getRandomInt(0,this.limitUI16-1)}randomUI32(){return this.getRandomInt(0,this.limitUI32-1)}randomUI40(){return(0|Math.random()*(1<<30))+(0|1024*Math.random())*(1<<30)}randomUI48(){return(0|Math.random()*(1<<30))+(0|Math.random()*(1<<18))*(1<<30)}create(){this.fromParts(this.randomUI32(),this.randomUI16(),16384|this.randomUI12(),128|this.randomUI06(),this.randomUI08(),this.randomUI48())}paddedString(t,e,s=null){s=s||"0";let i=e-(t=String(t)).length;for(;i>0;i>>>=1,s+=s)1&i&&(t=s+t);return t}fromParts(t,e,s,i,n,r){return this.version=s>>12&15,this.hex=this.paddedString(t.toString(16),8)+"-"+this.paddedString(e.toString(16),4)+"-"+this.paddedString(s.toString(16),4)+"-"+this.paddedString(i.toString(16),2)+this.paddedString(n.toString(16),2)+"-"+this.paddedString(r.toString(16),12),this}}class E{static updates(){return{context:null,updates:[]}}static subscribe(){return{context:null,subscribe:[]}}static unsubscribe(){return{context:null,unsubscribe:[]}}static request(){return{requestId:(new M).toString()}}}let O=(()=>{class t{constructor(){this._filter="",this._wsTimeout=2e4,this._token="",this._playbackMode=!1,this.endpoint="",this.selfId="",this._source=null,this._connect=new x,this.onConnect=this._connect.asObservable(),this._close=new x,this.onClose=this._close.asObservable(),this._error=new x,this.onError=this._error.asObservable(),this._message=new x,this.onMessage=this._message.asObservable()}set source(t){this._source||(this._source={}),this._source.label=t}set authToken(t){this._token=t}get connectionTimeout(){return this._wsTimeout}set connectionTimeout(t){this._wsTimeout=t<3e3?3e3:t>6e4?6e4:t}get isOpen(){return!(!this.ws||1==this.ws.readyState||3==this.ws.readyState)}get filter(){return this._filter}set filter(t){this._filter=t&&-1!=t.indexOf("self")?this.selfId?this.selfId:"":t}get playbackMode(){return this._playbackMode}close(){this.ws&&(this.ws.close(),this.ws=null)}open(t,e,s){if(!(t=t||this.endpoint))return;let i=-1==t.indexOf("?")?"?":"&";e&&(t+=`${i}subscribe=${e}`),(this._token||s)&&(t+=`${e?"&":"?"}token=${this._token||s}`),this.close(),this.ws=new WebSocket(t),setTimeout(()=>{this.ws&&1!=this.ws.readyState&&3!=this.ws.readyState&&(console.warn(`Connection watchdog expired (${this._wsTimeout/1e3} sec): ${this.ws.readyState}... aborting connection...`),this.close())},this._wsTimeout),this.ws.onopen=t=>{this._connect.next(t)},this.ws.onclose=t=>{this._close.next(t)},this.ws.onerror=t=>{this._error.next(t)},this.ws.onmessage=t=>{this.parseOnMessage(t)}}parseOnMessage(t){let e;if("string"==typeof t.data)try{e=JSON.parse(t.data)}catch(s){return}this.isHello(e)?(this.selfId=e.self,this._playbackMode=void 0!==e.startTime,this._message.next(e)):this.isResponse(e)?(void 0!==e.login&&void 0!==e.login.token&&(this._token=e.login.token),this._message.next(e)):this._filter&&this.isDelta(e)?e.context==this._filter&&this._message.next(e):this._message.next(e)}sendRequest(t){if("object"!=typeof t)return"";let e=E.request();return void 0===t.login&&this._token&&(e.token=this._token),Object.keys(t).forEach(s=>{e[s]=t[s]}),this.send(e),e.requestId}put(t,e,s){return this.sendRequest({context:"self"==t?"vessels.self":t,put:{path:e,value:s}})}login(t,e){return this.sendRequest({login:{username:t,password:e}})}send(t){this.ws&&("object"==typeof t&&(t=JSON.stringify(t)),this.ws.send(t))}sendUpdate(t="self",e,s){let i=E.updates();this._token&&(i.token=this._token),i.context="self"==t?"vessels.self":t,this._token&&(i.token=this._token);let n=[];"string"==typeof e&&n.push({path:e,value:s}),"object"==typeof e&&Array.isArray(e)&&(n=e);let r={timestamp:(new Date).toISOString(),values:n};this._source&&(r.source=this._source),i.updates.push(r),this.send(i)}subscribe(t="*",e="*",s){let i=E.subscribe();if(this._token&&(i.token=this._token),i.context="self"==t?"vessels.self":t,this._token&&(i.token=this._token),"object"==typeof e&&Array.isArray(e)&&(i.subscribe=e),"string"==typeof e){let t={};t.path=e,s&&"object"==typeof s&&(s.period&&(t.period=s.period),s.minPeriod&&(t.minPeriod=s.period),s.format&&("delta"==s.format||"full"==s.format)&&(t.format=s.format),s.policy&&("instant"==s.policy||"ideal"==s.policy||"fixed"==s.policy)&&(t.policy=s.policy)),i.subscribe.push(t)}this.send(i)}unsubscribe(t="*",e="*"){let s=E.unsubscribe();this._token&&(s.token=this._token),s.context="self"==t?"vessels.self":t,this._token&&(s.token=this._token),"object"==typeof e&&Array.isArray(e)&&(s.unsubscribe=e),"string"==typeof e&&s.unsubscribe.push({path:e}),this.send(s)}raiseAlarm(t="*",e,s){let i;i="string"==typeof e&&-1==e.indexOf("notifications.")?`notifications.${e}`:e,this.put(t,i,s.value)}clearAlarm(t="*",e){let s=-1==e.indexOf("notifications.")?`notifications.${e}`:e;this.put(t,s,null)}isSelf(t){return t.context==this.selfId}isDelta(t){return void 0!==t.context}isHello(t){return void 0!==t.version&&void 0!==t.self}isResponse(t){return void 0!==t.requestId}}return t.\u0275fac=function(e){return new(e||t)},t.\u0275prov=T({token:t,factory:t.\u0275fac,providedIn:"root"}),t})();class I{constructor(t,e,s,i){this._method=[],this._message="",this._message=void 0!==t?t:"",this._state=void 0!==e?e:R.alarm,s&&this._method.push(U.visual),i&&this._method.push(U.sound)}get value(){return{message:this._message,state:this._state,method:this._method}}}var R=(()=>(function(t){t.normal="normal",t.alert="alert",t.warn="warn",t.alarm="alarm",t.emergency="emergency"}(R||(R={})),R))(),U=(()=>(function(t){t.visual="visual",t.sound="sound"}(U||(U={})),U))();class A{constructor(){this.obsList=[],this.stream=new O,this._connect=new x,this.onConnect=this._connect.asObservable(),this._close=new x,this.onClose=this._close.asObservable(),this._error=new x,this.onError=this._error.asObservable(),this._message=new x,this.onMessage=this._message.asObservable()}get endpoint(){return this.stream.endpoint}set endpoint(t){this.stream.endpoint=t}get selfId(){return this.stream.selfId}set selfId(t){this.stream.selfId=t}get _source(){return this.stream._source}set _source(t){this.stream._source=t}set source(t){this.stream.source=t}set authToken(t){this.stream.authToken=t}get connectionTimeout(){return this.stream.connectionTimeout}set connectionTimeout(t){this.stream.connectionTimeout=t}get isOpen(){return this.stream.isOpen}get filter(){return this.stream.filter}set filter(t){this.stream.filter=t}get playbackMode(){return this.stream.playbackMode}open(t,e="none",s){this.obsList.push(this.stream.onConnect.subscribe(t=>this._connect.next(t))),this.obsList.push(this.stream.onClose.subscribe(t=>this._close.next(t))),this.obsList.push(this.stream.onError.subscribe(t=>this._error.next(t))),this.obsList.push(this.stream.onMessage.subscribe(t=>this._message.next(t))),this.stream.open(t,e,s)}close(){this.stream.close(),this.obsList.forEach(t=>t.unsubscribe()),this.obsList=[]}sendRequest(t){return this.stream.sendRequest(t)}put(t,e,s){return this.stream.put(t,e,s)}login(t,e){return this.stream.login(t,e)}send(t){this.stream.send(t)}sendUpdate(t="self",e,s){this.stream.sendUpdate(t,e,s)}subscribe(t="*",e="*",s){this.stream.subscribe(t,e,s)}unsubscribe(t="*",e="*"){this.stream.unsubscribe(t,e)}raiseAlarm(t="*",e,s){this.stream.raiseAlarm(t,e,s)}clearAlarm(t="*",e){this.stream.clearAlarm(t,e)}isSelf(t){return this.stream.isSelf(t)}isDelta(t){return this.stream.isDelta(t)}isHello(t){return this.stream.isHello(t)}isResponse(t){return this.stream.isResponse(t)}}class D{constructor(){this.position=[0,0],this.headingTrue=null,this.headingMagnetic=null,this.cogTrue=null,this.cogMagnetic=null,this.wind={direction:null,mwd:null,twd:null,tws:null,speedTrue:null,sog:null,awa:null,aws:null},this.lastUpdated=new Date,this.orientation=0,this.buddy=!1,this.closestApproach=null,this.mode="day",this.anchor={maxRadius:null,radius:null,position:null},this.resourceUpdates=[],this.autopilot={},this.track=[],this.properties={}}}class P{constructor(){this.lastUpdated=new Date,this.position=[0,0],this.properties={}}}class $ extends P{constructor(){super(),this.type={id:-1,name:""}}}class j extends P{constructor(){super(),this.orientation=0,this.sog=0,this.track=[]}}class C{constructor(){}static celciusToKelvin(t=0){return t+273.15}static kelvinToCelcius(t=0){return t-273.15}static kelvinToFarenheit(t=0){return 1.8*t-459.67}static degreesToRadians(t=0){return t*Math.PI/180}static radiansToDegrees(t=0){return 180*t/Math.PI}static angleToDirection(t,e){let s=2*Math.PI;if(e||(e=0),t||(t=0),isNaN(e)||isNaN(t))return null;let i=e+t;return i>s?i-s:i<0?s+i:i}static directionToAngle(t,e){let s=2*Math.PI;if(e||(e=0),t||(t=0),isNaN(e)||isNaN(t))return null;let i,n=e-t;if(n>0)i=n>Math.PI?s-n:0-n;else if(n<0){let t=Math.abs(n);i=t>Math.PI?t-s:t}else i=n;return i}static knotsToKm(t){return 1.852*t}static nauticalMilesToKm(t){return 1.852*t}static knotsToMSec(t){return.51444325460445*t}static kmToKnots(t){return.539957*t}static kmToNauticalMiles(t){return.539957*t}static kmToMiles(t){return.621371*t}static msecToKnots(t){return 1.94384*t}static msecToKmh(t){return 3.6*t}static msecToMph(t){return 2.23694*t}static nauticalMilesToMiles(t){return 1.15078*t}static milesToKm(t){return 1.60934*t}static milesToNauticalMiles(t){return.868976*t}static rpmToHertz(t){return t/60}}class H{constructor(){}static destCoordinate(t,e,s,i){let n=6378137,r=6356752.3142,o=1/298.257223563,a=i,l=s,c=Math.sin(l),u=Math.cos(l),h=(1-o)*Math.tan(C.degreesToRadians(t)),d=1/Math.sqrt(1+h*h),p=h*d,f=Math.atan2(h,u),b=d*c,m=1-b*b,g=m*(n*n-r*r)/(r*r),v=1+g/16384*(4096+g*(g*(320-175*g)-768)),y=g/1024*(256+g*(g*(74-47*g)-128)),w=a/(r*v),_=2*Math.PI;for(;Math.abs(w-_)>1e-12;){var x=Math.cos(2*f+w),k=Math.sin(w),T=Math.cos(w);_=w,w=a/(r*v)+y*k*(x+y/4*(T*(2*x*x-1)-y/6*x*(4*k*k-3)*(4*x*x-3)))}let S=p*k-d*T*u,M=Math.atan2(p*T+d*k*u,(1-o)*Math.sqrt(b*b+S*S)),E=o/16*m*(4+o*(4-3*m)),O=Math.atan2(k*c,d*T-p*k*u)-(1-E)*o*b*(w+E*k*(x+E*T*(2*x*x-1))),I=(Math.atan2(b,-S),C.radiansToDegrees(M));return[e+C.radiansToDegrees(O),I]}static toGo(t,e){return{bearing:H.bearingTo(t,e),distance:H.distanceTo(t,e)}}static distanceTo(t,e){let s=C.degreesToRadians(t[1]),i=C.degreesToRadians(t[0]),n=C.degreesToRadians(e[1]),r=C.degreesToRadians(e[0])-i,o=Math.pow(Math.sin((n-s)/2),2)+Math.cos(s)*Math.cos(n)*Math.pow(Math.sin(r/2),2);return 2*Math.atan2(Math.sqrt(o),Math.sqrt(1-o))*6373*1e3}static bearingTo(t,e){let s=C.degreesToRadians(t[1]),i=C.degreesToRadians(e[1]),n=C.degreesToRadians(e[0]-t[0]),r=Math.sin(n)*Math.cos(i),o=Math.cos(s)*Math.sin(i)-Math.sin(s)*Math.cos(i)*Math.cos(n);return Math.atan2(r,o)}static centreOfPolygon(t){let e=[-180,-90],s=[180,90];if(t.forEach(t=>{s[0]=t[0]<s[0]?t[0]:s[0],s[1]=t[1]<s[1]?t[1]:s[1],e[0]=t[0]>e[0]?t[0]:e[0],e[1]=t[1]>e[1]?t[1]:e[1]}),H.inDLCrossingZone(s)||H.inDLCrossingZone(e)){let t=s[0]>0&&e[0]<0?1:s[0]<0&&e[0]>0?-1:0;1==t&&(e[0]=e[0]+360),-1==t&&(e[0]=Math.abs(e[0])-360)}return[s[0]+(e[0]-s[0])/2,s[1]+(e[1]-s[1])/2]}static calulateExtent(t){let e=[180,90,-180,-90];return t.forEach(t=>{e[0]=t[0]<e[0]?t[0]:e[0],e[1]=t[1]<e[1]?t[1]:e[1],e[2]=t[0]>e[2]?t[0]:e[2],e[3]=t[1]>e[3]?t[1]:e[3]}),e}static inDLCrossingZone(t,e=170){return Math.abs(t[0])>=e}static inBounds(t,e){let s=JSON.parse(JSON.stringify(e)),i=[t[0],t[1]];return s[0]>0&&s[2]<0&&(s[2]=360+s[2],i[0]<0&&(i[0]=360+i[0])),i[0]>s[0]&&i[0]<s[2]&&i[1]>s[1]&&i[1]<s[3]}static calcMapifiedExtent(t,e){const s=111111;let i=s*Math.cos(C.degreesToRadians(t[1])),n=[0,0,0,0];return n[1]=t[1]+(0-Math.abs(e))/s,n[3]=t[1]+Math.abs(e)/s,n[0]=t[0]+(0-Math.abs(e))/i,n[2]=t[0]+Math.abs(e)/i,n}static normaliseCoords(t){if(!Array.isArray(t))return[0,0];if("number"==typeof t[0]){if(t[0]>180)for(;t[0]>180;)t[0]=t[0]-360;else if(t[0]<-180)for(;t[0]<-180;)t[0]=360+t[0];return t}return Array.isArray(t[0])?(t.forEach(t=>this.normaliseCoords(t)),t):void 0}}var N=s(8332);class B{constructor(){this.action=null,this.playback=!1,this.result=null}}class F extends B{constructor(t){super(),this.action="notification",this.type=t}}class G extends B{constructor(){super(),this.action="update"}}class L extends B{constructor(){super(),this.action="trail"}}const q=["environment.wind.speedTrue","environment.wind.speedOverGround","environment.wind.angleTrueGround","environment.wind.angleTrueWater","environment.wind.directionTrue","environment.wind.directionMagnetic","navigation.courseOverGroundTrue","navigation.courseOverGroundMagnetic","navigation.headingTrue","navigation.headingMagnetic"];let W,K,V,J,Y,z=[],Z=[],Q=!1,X=!1,tt={signalk:{},aisState:[]},et=[0,0,0,0],st=60,it=0,nt={},rt=500,ot=!1,at={maxAge:54e4,staleAge:36e4,lastTick:(new Date).valueOf(),maxTrack:20};const lt={trailDuration:24,trailResolution:{lastHour:"5s",next23:"10s",beyond24:"1m"}};function ct(){J={updated:{},stale:{},expired:{}}}function ut({action:t,msg:e}){switch(t){case"onConnect":postMessage({action:"open",playback:ot,result:e.target.readyState});break;case"onClose":console.warn("streamEvent: ",e),dt(!1);break;case"onError":console.warn("streamEvent: ",e),postMessage({action:"error",playback:ot,result:"Connection error!"});break;case"onMessage":!function(t){K.isHello(t)?(postMessage({action:"hello",result:t,self:t.self,playback:ot}),rt&&gt()):K.isDelta(t)?(Q=!0,t.updates.forEach(e=>{!e.values||e.values.forEach(s=>{if(Y=e.timestamp,t.context)switch(t.context.split(".")[0]){case"shore":case"atons":(null==tt?void 0:tt.signalk.atons)&&function(t,e){let s=!1;if(-1!=t.indexOf("shore.basestations")&&(s=!0),!W.atons.has(t)){let e=new $;e.id=t,e.position=null,s&&(e.type.id=-1,e.type.name="Basestation"),W.atons.set(t,e)}let i=W.atons.get(t);""==e.path?(void 0!==e.value.name&&(i.name=e.value.name),void 0!==e.value.mmsi&&(i.mmsi=e.value.mmsi),void 0!==e.value.atonType&&(i.type=e.value.atonType)):"atonType"==e.path?i.type=e.value:"navigation.position"==e.path?(i.position=[e.value.longitude,e.value.latitude],i.positionReceived=!0):i.properties[e.path]=e.value}(t.context,s),bt(t.context,W.atons,null==tt?void 0:tt.signalk.atons);break;case"sar":(null==tt?void 0:tt.signalk.sar)&&function(t,e){if(!W.sar.has(t)){let e=new $;e.id=t,e.position=null,e.type.id=-1,e.type.name="SaR Beacon",W.sar.set(t,e)}let s=W.sar.get(t);""==e.path?(void 0!==e.value.name&&(s.name=e.value.name),void 0!==e.value.mmsi&&(s.mmsi=e.value.mmsi)):"communication.callsignVhf"==e.path?s.callsign=e.value:"navigation.position"==e.path&&e.value?(s.position=H.normaliseCoords([e.value.longitude,e.value.latitude]),s.positionReceived=!0):s.properties[e.path]=e.value}(t.context,s),bt(t.context,W.sar,null==tt?void 0:tt.signalk.sar);break;case"aircraft":(null==tt?void 0:tt.signalk.aircraft)&&function(t,e){if(!W.aircraft.has(t)){let e=new j;e.id=t,e.position=null,W.aircraft.set(t,e)}let s=W.aircraft.get(t);""==e.path?(void 0!==e.value.name&&(s.name=e.value.name),void 0!==e.value.mmsi&&(s.mmsi=e.value.mmsi)):"communication.callsignVhf"==e.path?s.callsign=e.value:"navigation.position"==e.path&&e.value?(s.position=H.normaliseCoords([e.value.longitude,e.value.latitude]),s.positionReceived=!0,wt(s)):"navigation.courseOverGroundTrue"==e.path?s.orientation=e.value:"navigation.speedOverGround"==e.path?s.sog=e.value:s.properties[e.path]=e.value}(t.context,s),bt(t.context,W.aircraft,null==tt?void 0:tt.signalk.aircraft);break;case"vessels":K.isSelf(t)?(yt(W.self,s,!0),function(t,e){let s,i={path:t.path,value:t.value,context:null},n=t.path.split(".");if(("notifications.environment.depth.belowTransducer"==t.path||"notifications.environment.depth.belowSurface"==t.path||"notifications.environment.depth.belowKeel"==t.path)&&(s=n[2]),"notifications.navigation.anchor"==t.path&&(s=n[2]),-1!=["mob","sinking","fire","piracy","flooding","collision","grounding","listing","adrift","abandon"].indexOf(n[n.length-1])&&(s=n[n.length-1]),-1!=t.path.indexOf("notifications.navigation.closestApproach")&&(s=n[2],i.context=n[3]),-1!=t.path.indexOf("notifications.buddy")&&(s=n[1],i.context=n[2]),(-1!=t.path.indexOf("notifications.arrivalCircleEntered")||-1!=t.path.indexOf("notifications.navigation.course.arrivalCircleEntered"))&&(s=n[1],i.context=n[2]),s){let t=new F(s);t.playback=ot,t.result=i,postMessage(t)}}(s)):((null==tt?void 0:tt.signalk.vessels)&&yt(function(t){if(!W.aisTargets.has(t)){let e=new D;e.position=null,W.aisTargets.set(t,e)}return W.aisTargets.get(t)}(t.context),s),bt(t.context,W.aisTargets,null==tt?void 0:tt.signalk.vessels,null==tt?void 0:tt.aisState))}})}),mt()):K.isResponse(t)&&postMessage({action:"response",result:t})}(e)}}function ht(t={}){t.interval&&"number"==typeof t.interval&&(rt=t.interval,vt(),gt(),st=1/(rt/1e3)*60),ot=!!t.playback,t.selections&&(void 0!==t.selections.preferredPaths&&(nt=t.selections.preferredPaths),t.selections.aisMaxAge&&"number"==typeof t.selections.aisMaxAge&&(at.maxAge=t.selections.aisMaxAge),t.selections.aisStaleAge&&"number"==typeof t.selections.aisStaleAge&&(at.staleAge=t.selections.aisStaleAge),"number"==typeof t.selections.signalk.maxRadius&&(tt.signalk=t.selections.signalk),void 0!==t.selections.aisState&&Array.isArray(t.selections.aisState)&&(tt.aisState=t.selections.aisState),console.log("Worker: AIS Filter...",tt))}function dt(t=!1,e){vt(),z.forEach(t=>t.unsubscribe()),K&&t&&K.close(),K=null,postMessage({action:"close",result:t,playback:ot})}function pt(t){return new Promise((e,s)=>{fetch(`${t}`).then(t=>{t.json().then(t=>e(t)).catch(t=>s(t))}).catch(t=>{s(t)})})}function ft(){pt(V+"/tracks"+(tt&&tt.signalk&&tt.signalk.maxRadius?`?radius=${tt.signalk.maxRadius}`:"?radius=10000")).then(t=>{X=!0,Object.entries(t).forEach(t=>{if(W.aisTargets.has(t[0])){let e=W.aisTargets.get(t[0]);e.track=t[1].coordinates,wt(e)}})}).catch(t=>{X=!1,console.warn("Unable to fetch AIS tracks!")})}function bt(t,e,s=!0,i=[]){if(s){let s=e.get(t);s&&i.includes(null==s?void 0:s.state)&&(console.log(`state match => ${i}, ${t}`),J.expired[t]=!0,s=null),s&&tt.signalk.maxRadius?s.positionReceived&&H.inBounds(s.position,et)?J.updated[t]=!0:(e.delete(t),J.expired[t]=!0):J.updated[t]=!0}else 0!=e.size&&(e.forEach((t,e)=>{J.expired[e]=!0}),e.clear())}function mt(t=!1){if(!rt||t){let t=new G;t.playback=ot,W.aisStatus.updated=Object.keys(J.updated),W.aisStatus.stale=Object.keys(J.stale),W.aisStatus.expired=Object.keys(J.expired),t.result=W,t.timestamp=ot?Y:W.self.lastUpdated.toISOString(),postMessage(t),ct(),W.self.resourceUpdates=[],0==it&&(function(){let t=(new Date).valueOf();W.aisTargets.forEach((e,s)=>{e.lastUpdated<t-at.maxAge?(J.expired[s]=!0,W.aisTargets.delete(s)):e.lastUpdated<t-at.staleAge&&(J.stale[s]=!0)}),W.aircraft.forEach((e,s)=>{e.lastUpdated<t-at.maxAge?(J.expired[s]=!0,W.aircraft.delete(s)):e.lastUpdated<t-at.staleAge&&(J.stale[s]=!0)}),W.sar.forEach((e,s)=>{e.lastUpdated<t-at.maxAge?(J.expired[s]=!0,W.sar.delete(s)):e.lastUpdated<t-at.staleAge&&(J.stale[s]=!0)})}(),W.self.positionReceived&&(null==tt?void 0:tt.signalk.maxRadius)&&(et=H.calcMapifiedExtent(W.self.position,tt.signalk.maxRadius),it++)),it=it>=st?0:it+1}}function gt(){rt&&"number"==typeof rt&&Z.push(setInterval(()=>{Q&&(mt(!0),Q=!1)},rt)),Z.push(setInterval(()=>{console.warn("hasTrackPlugin",X),X&&ft()},6e4))}function vt(){Z.forEach(t=>clearInterval(t)),Z=[]}function yt(t,e,s=!1){if(t.lastUpdated=new Date,s&&-1!=q.indexOf(e.path)&&(W.paths[e.path]=e.value),""==e.path)void 0!==e.value.name&&(t.name=e.value.name),void 0!==e.value.mmsi&&(t.mmsi=e.value.mmsi),void 0!==e.value.buddy&&(t.buddy=e.value.buddy);else if("communication.callsignVhf"==e.path)t.callsign=e.value;else if("navigation.position"==e.path&&e.value){if(void 0===e.value.longitude)return;t.position=H.normaliseCoords([e.value.longitude,e.value.latitude]),t.positionReceived=!0,s||wt(t)}else"navigation.state"==e.path?t.state=e.value:"navigation.speedOverGround"==e.path?t.sog=e.value:"navigation.courseOverGroundTrue"==e.path?t.cogTrue=e.value:"navigation.courseOverGroundMagnetic"==e.path?t.cogMagnetic=e.value:"navigation.headingTrue"==e.path?t.headingTrue=e.value:"navigation.headingMagnetic"==e.path?t.headingMagnetic=e.value:"environment.wind.angleApparent"==e.path?t.wind.awa=e.value:"environment.wind.speedApparent"==e.path?t.wind.aws=e.value:"environment.wind.speedTrue"==e.path?t.wind.speedTrue=e.value:"environment.wind.speedOverGround"==e.path?t.wind.sog=e.value:"environment.wind.directionTrue"==e.path?t.wind.twd=e.value:"environment.wind.directionMagnetic"==e.path?t.wind.mwd=e.value:"environment.mode"==e.path?t.mode=e.value:-1!=e.path.indexOf("navigation.courseRhumbline")&&void 0!==nt.course&&e.path.split(".").slice(0,2).join(".")==nt.course||-1!=e.path.indexOf("navigation.courseGreatCircle")&&void 0!==nt.course&&e.path.split(".").slice(0,2).join(".")==nt.course?t["course."+e.path.split(".").slice(2).join(".")]=e.value:-1!=e.path.indexOf("navigation.closestApproach")?t.closestApproach=e.value:"navigation.anchor.position"==e.path?t.anchor.position=e.value:"navigation.anchor.maxRadius"==e.path?t.anchor.maxRadius=e.value:"navigation.anchor.currentRadius"==e.path?t.anchor.radius=e.value:-1!=e.path.indexOf("resources.")?t.resourceUpdates.push(e):"steering.autopilot.state"==e.path?t.autopilot.state=e.value:"steering.autopilot.mode"==e.path?t.autopilot.mode=e.value:t.properties[e.path]=e.value;t.heading=null==t.heading&&null!=t.cog?t.cog:t.heading,void 0!==nt.heading&&e.path==nt.heading&&(t.orientation=e.value),void 0!==nt.tws&&e.path==nt.tws&&(t.wind.tws=e.value),void 0!==nt.twd&&e.path==nt.twd&&(t.wind.direction="environment.wind.angleTrueGround"==e.path||"environment.wind.angleTrueWater"==e.path?C.angleToDirection(e.value,t.heading):e.value)}function wt(t){if(t.track&&0==t.track.length)t.track.push([t.position]);else{let e=t.track[t.track.length-1][t.track[t.track.length-1].length-1];e[0]!=t.position[0]&&e[1]!=t.position[1]&&t.track[t.track.length-1].push(t.position)}t.track[t.track.length-1]=t.track[t.track.length-1].slice(0-at.maxTrack)}addEventListener("message",({data:t})=>{!function(t){var e,s,i,n;if(t.cmd)switch(t.cmd){case"open":console.log("Worker control: opening stream..."),ht(t.options),function(t){if(K)return;if(!t.url)return void postMessage({action:"error",result:"Valid options not provided!"});let e=t.url.split("/");if(e.pop(),e.push("api"),e[0]="wss:"==e[0]?"https:":"http:",V=e.join("/"),W={self:new D,aisTargets:new Map,aisStatus:{updated:[],stale:[],expired:[]},paths:{},atons:new Map,aircraft:new Map,sar:new Map},W.self.positionReceived=!1,ct(),K=new A,z.push(K.onConnect.subscribe(t=>ut({action:"onConnect",msg:t}))),z.push(K.onClose.subscribe(t=>ut({action:"onClose",msg:t}))),z.push(K.onError.subscribe(t=>ut({action:"onError",msg:t}))),z.push(K.onMessage.subscribe(t=>ut({action:"onMessage",msg:t}))),t.playback){let e=t.playbackOptions.startTime?`?startTime=${t.playbackOptions.startTime}`:null,s=t.playbackOptions.playbackRate?`playbackRate=${t.playbackOptions.playbackRate}`:null;s=s?e?"&"+s:"?"+s:null,K.open(`${t.url}${e||""}${s||""}`,t.playbackOptions.subscribe,t.token)}else K.open(t.url,t.subscribe,t.token),ft()}(t.options);break;case"close":console.log("Worker control: closing stream..."),dt(!0);break;case"subscribe":console.log("Worker control: subscribing to paths..."),K.subscribe(t.options.context,t.options.path);break;case"settings":console.log("Worker control: settings..."),ht(t.options);break;case"alarm":console.log("Worker control: alarm action..."),function(t){let e=-1==t.type.indexOf("notifications.")?`notifications.${t.type}`:t.type;t.raise?K.raiseAlarm("self",e,new I(t.message,t.state,!0,!0)):K.clearAlarm("self",e)}(t.options);break;case"vessel":if(console.log("Worker control: vessel setting..."),t.options){let e;e="self"==t.options.context?W.self:W.aisTargets.get(t.options.context),e&&t.options.name&&(e.name=t.options.name)}break;case"auth":console.log("Worker control: auth token..."),t.options&&(K.authToken=t.options.token);break;case"trail":console.log("Worker control: Fetch vessel trail from server..."),t.options&&(lt.trailDuration=null!==(e=t.options.trailDuration)&&void 0!==e?e:24,t.options.trailResolution&&(lt.trailResolution.lastHour=null!==(s=t.options.trailResolution.lastHour)&&void 0!==s?s:"5s",lt.trailResolution.next23=null!==(i=t.options.trailResolution.next23)&&void 0!==i?i:"1m",lt.trailResolution.beyond24=null!==(n=t.options.trailResolution.beyond24)&&void 0!==n?n:"5m")),function(t){console.info("Fetching vessel trail from server!",t);const e=V+"/self/track?",s=[];t.trailDuration>24&&(s.push(pt(`${e}timespan=${t.trailDuration-24}h&resolution=${t.trailResolution.beyond24}&timespanOffset=24`)),s.push(pt(`${e}timespan=23h&resolution=${t.trailResolution.next23}&timespanOffset=1`))),t.trailDuration>1&&t.trailDuration<25&&s.push(pt(`${e}timespan=${t.trailDuration-1}h&resolution=${t.trailResolution.next23}&timespanOffset=1`)),s.push(pt(`${e}timespan=1h&resolution=${t.trailResolution.lastHour}`));let i=[];const n=new L;n.playback=ot,Promise.all(s).then(t=>{let e=0,r=s.length-1;console.log("res",...t),t.forEach(t=>{if(t.type&&"MultiLineString"===t.type&&t.coordinates&&Array.isArray(t.coordinates))if(e!=r){let e=[];for(t.coordinates.forEach(t=>{e=e.concat(t)}),e=(0,N.EK)(e,5e-4,true);e.length>60;){const t=e.slice(0,60);i.push(t),e=e.slice(59),e[0]=[e[0][0]+5e-9,e[0][1]+5e-9]}0!==e.length&&i.push(e)}else i=i.concat(t.coordinates);e++}),console.log("trail",i),n.result=i,postMessage(n)}).catch(t=>{n.result=null,postMessage(n)})}(lt)}}(t)})}()}();
@@ -0,0 +1 @@
1
+ !function(){function e(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"==typeof e)return t(e,n);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return t(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function n(){return(n="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=i(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}}).apply(this,arguments)}function i(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=c(e)););return e}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var n,i=c(e);if(t){var r=c(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return a(this,n)}}function a(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return u(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function f(e,t,n){return t&&h(e.prototype,t),n&&h(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}!function(){var t={8255:function(e){function t(e){return Promise.resolve().then(function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t})}t.keys=function(){return[]},t.resolve=t,t.id=8255,e.exports=t},5686:function(e,t){"use strict";function n(e,t){return e*e+t*t}function i(e,t){return n(e[0]-t[0],e[1]-t[1])}function r(e,t,i){var r=t[0],o=t[1],s=i[0]-r,a=i[1]-o;if(0!==s||0!==a){var u=((e[0]-r)*s+(e[1]-o)*a)/n(s,a);u>1?(r=i[0],o=i[1]):u>0&&(r+=s*u,o+=a*u)}return n(e[0]-r,e[1]-o)}function o(e,t,n,i,s){for(var a,u=i,c=t+1;c<n;c++){var l=r(e[c],e[t],e[n]);l>u&&(a=c,u=l)}u>i&&(a-t>1&&o(e,t,a,i,s),s.push(e[a]),n-a>1&&o(e,a,n,i,s))}function s(e,t){var n=e.length-1,i=[e[0]];return o(e,0,n,t,i),i.push(e[n]),i}t.__esModule=!0,t.SimplifyAP=function(e,t,n){if(void 0===t&&(t=1),void 0===n&&(n=!1),e.length<=2)return e;var r=t*t;return s(e=n?e:function(e,t){for(var n,r=e[0],o=[r],s=1,a=e.length;s<a;s++)i(n=e[s],r)>t&&(o.push(n),r=n);return r!==n&&o.push(n),o}(e,r),r)}},8332:function(e,t,n){"use strict";var i=n(5686);t.EK=i.SimplifyAP,n(3981),n(2165)},3981:function(e,t){"use strict";function n(e,t){return e*e+t*t}function i(e,t){return n(e.longitude-t.longitude,e.latitude-t.latitude)}function r(e,t,i){var r=t.longitude,o=t.latitude,s=i.longitude-r,a=i.latitude-o;if(0!==s||0!==a){var u=((e.longitude-r)*s+(e.latitude-o)*a)/n(s,a);u>1?(r=i.longitude,o=i.latitude):u>0&&(r+=s*u,o+=a*u)}return n(e.longitude-r,e.latitude-o)}function o(e,t,n,i,s){for(var a,u=i,c=t+1;c<n;c++){var l=r(e[c],e[t],e[n]);l>u&&(a=c,u=l)}u>i&&(a-t>1&&o(e,t,a,i,s),s.push(e[a]),n-a>1&&o(e,a,n,i,s))}function s(e,t){var n=e.length-1,i=[e[0]];return o(e,0,n,t,i),i.push(e[n]),i}t.__esModule=!0,t.SimplifyLL=function(e,t,n){if(void 0===t&&(t=1),void 0===n&&(n=!1),e.length<=2)return e;var r=t*t;return s(e=n?e:function(e,t){for(var n,r=e[0],o=[r],s=1,a=e.length;s<a;s++)i(n=e[s],r)>t&&(o.push(n),r=n);return r!==n&&o.push(n),o}(e,r),r)}},2165:function(e,t){"use strict";function n(e,t){return e*e+t*t}function i(e,t){return n(e.x-t.x,e.y-t.y)}function r(e,t,i){var r=t.x,o=t.y,s=i.x-r,a=i.y-o;if(0!==s||0!==a){var u=((e.x-r)*s+(e.y-o)*a)/n(s,a);u>1?(r=i.x,o=i.y):u>0&&(r+=s*u,o+=a*u)}return n(e.x-r,e.y-o)}function o(e,t,n,i,s){for(var a,u=i,c=t+1;c<n;c++){var l=r(e[c],e[t],e[n]);l>u&&(a=c,u=l)}u>i&&(a-t>1&&o(e,t,a,i,s),s.push(e[a]),n-a>1&&o(e,a,n,i,s))}function s(e,t){var n=e.length-1,i=[e[0]];return o(e,0,n,t,i),i.push(e[n]),i}t.__esModule=!0,t.Simplify=function(e,t,n){if(void 0===t&&(t=1),void 0===n&&(n=!1),e.length<=2)return e;var r=t*t;return s(e=n?e:function(e,t){for(var n,r=e[0],o=[r],s=1,a=e.length;s<a;s++)i(n=e[s],r)>t&&(o.push(n),r=n);return r!==n&&o.push(n),o}(e,r),r)}}},i={};function o(e){var n=i[e];if(void 0!==n)return n.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";function t(e){return"function"==typeof e}var i=!1,a={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){if(e){var t=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+t.stack)}else i&&console.log("RxJS: Back to a better error behavior. Thank you. <3");i=e},get useDeprecatedSynchronousErrorHandling(){return i}};function h(e){setTimeout(function(){throw e},0)}var d={closed:!0,next:function(e){},error:function(e){if(a.useDeprecatedSynchronousErrorHandling)throw e;h(e)},complete:function(){}},v=Array.isArray||function(e){return e&&"number"==typeof e.length};function p(e){return null!==e&&"object"==typeof e}var b,g=function(){function e(e){return Error.call(this),this.message=e?"".concat(e.length," errors occurred during unsubscription:\n").concat(e.map(function(e,t){return"".concat(t+1,") ").concat(e.toString())}).join("\n ")):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),y=function(){function e(t){l(this,e),this.closed=!1,this._parentOrParents=null,this._subscriptions=null,t&&(this._ctorUnsubscribe=!0,this._unsubscribe=t)}return f(e,[{key:"unsubscribe",value:function(){var n;if(!this.closed){var i=this._parentOrParents,r=this._ctorUnsubscribe,o=this._unsubscribe,s=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,i instanceof e)i.remove(this);else if(null!==i)for(var a=0;a<i.length;++a)i[a].remove(this);if(t(o)){r&&(this._unsubscribe=void 0);try{o.call(this)}catch(a){n=a instanceof g?m(a.errors):[a]}}if(v(s))for(var u=-1,c=s.length;++u<c;){var l=s[u];if(p(l))try{l.unsubscribe()}catch(h){n=n||[],h instanceof g?n=n.concat(m(h.errors)):n.push(h)}}if(n)throw new g(n)}}},{key:"add",value:function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var i=n;(n=new e)._subscriptions=[i]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var r=n._parentOrParents;if(null===r)n._parentOrParents=this;else if(r instanceof e){if(r===this)return n;n._parentOrParents=[r,this]}else{if(-1!==r.indexOf(this))return n;r.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[n]:o.push(n),n}},{key:"remove",value:function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}}}]),e}();function m(e){return e.reduce(function(e,t){return e.concat(t instanceof g?t.errors:t)},[])}y.EMPTY=((b=new y).closed=!0,b);var k="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),w=function(e){r(i,e);var t=s(i);function i(e,n,r){var o;switch(l(this,i),(o=t.call(this)).syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=d;break;case 1:if(!e){o.destination=d;break}if("object"==typeof e){e instanceof i?(o.syncErrorThrowable=e.syncErrorThrowable,o.destination=e,e.add(u(o))):(o.syncErrorThrowable=!0,o.destination=new _(u(o),e));break}default:o.syncErrorThrowable=!0,o.destination=new _(u(o),e,n,r)}return o}return f(i,[{key:k,value:function(){return this}},{key:"next",value:function(e){this.isStopped||this._next(e)}},{key:"error",value:function(e){this.isStopped||(this.isStopped=!0,this._error(e))}},{key:"complete",value:function(){this.isStopped||(this.isStopped=!0,this._complete())}},{key:"unsubscribe",value:function(){this.closed||(this.isStopped=!0,n(c(i.prototype),"unsubscribe",this).call(this))}},{key:"_next",value:function(e){this.destination.next(e)}},{key:"_error",value:function(e){this.destination.error(e),this.unsubscribe()}},{key:"_complete",value:function(){this.destination.complete(),this.unsubscribe()}},{key:"_unsubscribeAndRecycle",value:function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this}}],[{key:"create",value:function(e,t,n){var r=new i(e,t,n);return r.syncErrorThrowable=!1,r}}]),i}(y),_=function(e){r(i,e);var n=s(i);function i(e,r,o,s){var a;l(this,i),(a=n.call(this))._parentSubscriber=e;var c,h=u(a);return t(r)?c=r:r&&(c=r.next,o=r.error,s=r.complete,r!==d&&(t((h=Object.create(r)).unsubscribe)&&a.add(h.unsubscribe.bind(h)),h.unsubscribe=a.unsubscribe.bind(u(a)))),a._context=h,a._next=c,a._error=o,a._complete=s,a}return f(i,[{key:"next",value:function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;a.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}}},{key:"error",value:function(e){if(!this.isStopped){var t=this._parentSubscriber,n=a.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):h(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;h(e)}}}},{key:"complete",value:function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};a.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}}},{key:"__tryOrUnsub",value:function(e,t){try{e.call(this._context,t)}catch(n){if(this.unsubscribe(),a.useDeprecatedSynchronousErrorHandling)throw n;h(n)}}},{key:"__tryOrSetError",value:function(e,t,n){if(!a.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(i){return a.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=i,e.syncErrorThrown=!0,!0):(h(i),!0)}return!1}},{key:"_unsubscribe",value:function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()}}]),i}(w),x="function"==typeof Symbol&&Symbol.observable||"@@observable";function S(e){return e}var T=function(){var e=function(){function e(t){l(this,e),this._isScalar=!1,t&&(this._subscribe=t)}return f(e,[{key:"lift",value:function(t){var n=new e;return n.source=this,n.operator=t,n}},{key:"subscribe",value:function(e,t,n){var i=this.operator,r=function(e,t,n){if(e){if(e instanceof w)return e;if(e[k])return e[k]()}return e||t||n?new w(e,t,n):new w(d)}(e,t,n);if(r.add(i?i.call(r,this.source):this.source||a.useDeprecatedSynchronousErrorHandling&&!r.syncErrorThrowable?this._subscribe(r):this._trySubscribe(r)),a.useDeprecatedSynchronousErrorHandling&&r.syncErrorThrowable&&(r.syncErrorThrowable=!1,r.syncErrorThrown))throw r.syncErrorValue;return r}},{key:"_trySubscribe",value:function(e){try{return this._subscribe(e)}catch(t){a.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),function(e){for(;e;){var t=e,n=t.closed,i=t.destination,r=t.isStopped;if(n||r)return!1;e=i&&i instanceof w?i:null}return!0}(e)?e.error(t):console.warn(t)}}},{key:"forEach",value:function(e,t){var n=this;return new(t=M(t))(function(t,i){var r;r=n.subscribe(function(t){try{e(t)}catch(n){i(n),r&&r.unsubscribe()}},i,t)})}},{key:"_subscribe",value:function(e){var t=this.source;return t&&t.subscribe(e)}},{key:x,value:function(){return this}},{key:"pipe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?this:function(e){return 0===e.length?S:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}(t)(this)}},{key:"toPromise",value:function(e){var t=this;return new(e=M(e))(function(e,n){var i;t.subscribe(function(e){return i=e},function(e){return n(e)},function(){return e(i)})})}}]),e}();return e.create=function(t){return new e(t)},e}();function M(e){if(e||(e=a.Promise||Promise),!e)throw new Error("no Promise impl found");return e}var O=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),E=function(e){r(n,e);var t=s(n);function n(e,i){var r;return l(this,n),(r=t.call(this)).subject=e,r.subscriber=i,r.closed=!1,r}return f(n,[{key:"unsubscribe",value:function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}}}]),n}(y),R=function(e){r(n,e);var t=s(n);function n(e){var i;return l(this,n),(i=t.call(this,e)).destination=e,i}return f(n)}(w),I=function(){var e=function(e){r(i,e);var t=s(i);function i(){var e;return l(this,i),(e=t.call(this)).observers=[],e.closed=!1,e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return f(i,[{key:k,value:function(){return new R(this)}},{key:"lift",value:function(e){var t=new A(this,this);return t.operator=e,t}},{key:"next",value:function(e){if(this.closed)throw new O;if(!this.isStopped)for(var t=this.observers,n=t.length,i=t.slice(),r=0;r<n;r++)i[r].next(e)}},{key:"error",value:function(e){if(this.closed)throw new O;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,i=t.slice(),r=0;r<n;r++)i[r].error(e);this.observers.length=0}},{key:"complete",value:function(){if(this.closed)throw new O;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),i=0;i<t;i++)n[i].complete();this.observers.length=0}},{key:"unsubscribe",value:function(){this.isStopped=!0,this.closed=!0,this.observers=null}},{key:"_trySubscribe",value:function(e){if(this.closed)throw new O;return n(c(i.prototype),"_trySubscribe",this).call(this,e)}},{key:"_subscribe",value:function(e){if(this.closed)throw new O;return this.hasError?(e.error(this.thrownError),y.EMPTY):this.isStopped?(e.complete(),y.EMPTY):(this.observers.push(e),new E(this,e))}},{key:"asObservable",value:function(){var e=new T;return e.source=this,e}}]),i}(T);return e.create=function(e,t){return new A(e,t)},e}(),A=function(e){r(n,e);var t=s(n);function n(e,i){var r;return l(this,n),(r=t.call(this)).destination=e,r.source=i,r}return f(n,[{key:"next",value:function(e){var t=this.destination;t&&t.next&&t.next(e)}},{key:"error",value:function(e){var t=this.destination;t&&t.error&&this.destination.error(e)}},{key:"complete",value:function(){var e=this.destination;e&&e.complete&&this.destination.complete()}},{key:"_subscribe",value:function(e){return this.source?this.source.subscribe(e):y.EMPTY}}]),n}(I);"function"==typeof Symbol&&Symbol.iterator&&Symbol,Error;var U="undefined"!=typeof globalThis&&globalThis;"undefined"!=typeof window&&window,"undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,U||"undefined"!=typeof global&&global,Symbol;var P,D,j,C,H,B=function(){function e(){l(this,e),this.version=4,this.hex="",this.limitUI04=this.maxFromBits(4),this.limitUI06=this.maxFromBits(6),this.limitUI08=this.maxFromBits(8),this.limitUI12=this.maxFromBits(12),this.limitUI14=this.maxFromBits(14),this.limitUI16=this.maxFromBits(16),this.limitUI32=this.maxFromBits(32),this.limitUI40=this.maxFromBits(40),this.limitUI48=this.maxFromBits(48),this.create()}return f(e,[{key:"toString",value:function(){return this.hex}},{key:"toURN",value:function(){return"urn:uuid:"+this.hex}},{key:"toSignalK",value:function(){return"urn:mrn:signalk:uuid:".concat(this.hex)}},{key:"toBytes",value:function(){for(var e=this.hex.split("-"),t=[],n=0,i=0;i<e.length;i++)for(var r=0;r<e[i].length;r+=2)t[n++]=parseInt(e[i].substr(r,2),16);return t}},{key:"maxFromBits",value:function(e){return Math.pow(2,e)}},{key:"getRandomInt",value:function(e,t){return Math.floor(Math.random()*(t-e+1))+e}},{key:"randomUI04",value:function(){return this.getRandomInt(0,this.limitUI04-1)}},{key:"randomUI06",value:function(){return this.getRandomInt(0,this.limitUI06-1)}},{key:"randomUI08",value:function(){return this.getRandomInt(0,this.limitUI08-1)}},{key:"randomUI12",value:function(){return this.getRandomInt(0,this.limitUI12-1)}},{key:"randomUI14",value:function(){return this.getRandomInt(0,this.limitUI14-1)}},{key:"randomUI16",value:function(){return this.getRandomInt(0,this.limitUI16-1)}},{key:"randomUI32",value:function(){return this.getRandomInt(0,this.limitUI32-1)}},{key:"randomUI40",value:function(){return(0|Math.random()*(1<<30))+(0|1024*Math.random())*(1<<30)}},{key:"randomUI48",value:function(){return(0|Math.random()*(1<<30))+(0|Math.random()*(1<<18))*(1<<30)}},{key:"create",value:function(){this.fromParts(this.randomUI32(),this.randomUI16(),16384|this.randomUI12(),128|this.randomUI06(),this.randomUI08(),this.randomUI48())}},{key:"paddedString",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;n=n||"0";for(var i=t-(e=String(e)).length;i>0;i>>>=1,n+=n)1&i&&(e=n+e);return e}},{key:"fromParts",value:function(e,t,n,i,r,o){return this.version=n>>12&15,this.hex=this.paddedString(e.toString(16),8)+"-"+this.paddedString(t.toString(16),4)+"-"+this.paddedString(n.toString(16),4)+"-"+this.paddedString(i.toString(16),2)+this.paddedString(r.toString(16),2)+"-"+this.paddedString(o.toString(16),12),this}}]),e}(),N=function(){function e(){l(this,e)}return f(e,null,[{key:"updates",value:function(){return{context:null,updates:[]}}},{key:"subscribe",value:function(){return{context:null,subscribe:[]}}},{key:"unsubscribe",value:function(){return{context:null,unsubscribe:[]}}},{key:"request",value:function(){return{requestId:(new B).toString()}}}]),e}(),F=function(){var e=function(){function e(){l(this,e),this._filter="",this._wsTimeout=2e4,this._token="",this._playbackMode=!1,this.endpoint="",this.selfId="",this._source=null,this._connect=new I,this.onConnect=this._connect.asObservable(),this._close=new I,this.onClose=this._close.asObservable(),this._error=new I,this.onError=this._error.asObservable(),this._message=new I,this.onMessage=this._message.asObservable()}return f(e,[{key:"source",set:function(e){this._source||(this._source={}),this._source.label=e}},{key:"authToken",set:function(e){this._token=e}},{key:"connectionTimeout",get:function(){return this._wsTimeout},set:function(e){this._wsTimeout=e<3e3?3e3:e>6e4?6e4:e}},{key:"isOpen",get:function(){return!(!this.ws||1==this.ws.readyState||3==this.ws.readyState)}},{key:"filter",get:function(){return this._filter},set:function(e){this._filter=e&&-1!=e.indexOf("self")?this.selfId?this.selfId:"":e}},{key:"playbackMode",get:function(){return this._playbackMode}},{key:"close",value:function(){this.ws&&(this.ws.close(),this.ws=null)}},{key:"open",value:function(e,t,n){var i=this;if(e=e||this.endpoint){var r=-1==e.indexOf("?")?"?":"&";t&&(e+="".concat(r,"subscribe=").concat(t)),(this._token||n)&&(e+="".concat(t?"&":"?","token=").concat(this._token||n)),this.close(),this.ws=new WebSocket(e),setTimeout(function(){i.ws&&1!=i.ws.readyState&&3!=i.ws.readyState&&(console.warn("Connection watchdog expired (".concat(i._wsTimeout/1e3," sec): ").concat(i.ws.readyState,"... aborting connection...")),i.close())},this._wsTimeout),this.ws.onopen=function(e){i._connect.next(e)},this.ws.onclose=function(e){i._close.next(e)},this.ws.onerror=function(e){i._error.next(e)},this.ws.onmessage=function(e){i.parseOnMessage(e)}}}},{key:"parseOnMessage",value:function(e){var t;if("string"==typeof e.data)try{t=JSON.parse(e.data)}catch(n){return}this.isHello(t)?(this.selfId=t.self,this._playbackMode=void 0!==t.startTime,this._message.next(t)):this.isResponse(t)?(void 0!==t.login&&void 0!==t.login.token&&(this._token=t.login.token),this._message.next(t)):this._filter&&this.isDelta(t)?t.context==this._filter&&this._message.next(t):this._message.next(t)}},{key:"sendRequest",value:function(e){if("object"!=typeof e)return"";var t=N.request();return void 0===e.login&&this._token&&(t.token=this._token),Object.keys(e).forEach(function(n){t[n]=e[n]}),this.send(t),t.requestId}},{key:"put",value:function(e,t,n){return this.sendRequest({context:"self"==e?"vessels.self":e,put:{path:t,value:n}})}},{key:"login",value:function(e,t){return this.sendRequest({login:{username:e,password:t}})}},{key:"send",value:function(e){this.ws&&("object"==typeof e&&(e=JSON.stringify(e)),this.ws.send(e))}},{key:"sendUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"self",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,i=N.updates();this._token&&(i.token=this._token),i.context="self"==e?"vessels.self":e,this._token&&(i.token=this._token);var r=[];"string"==typeof t&&r.push({path:t,value:n}),"object"==typeof t&&Array.isArray(t)&&(r=t);var o={timestamp:(new Date).toISOString(),values:r};this._source&&(o.source=this._source),i.updates.push(o),this.send(i)}},{key:"subscribe",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=arguments.length>2?arguments[2]:void 0,i=N.subscribe();if(this._token&&(i.token=this._token),i.context="self"==e?"vessels.self":e,this._token&&(i.token=this._token),"object"==typeof t&&Array.isArray(t)&&(i.subscribe=t),"string"==typeof t){var r={};r.path=t,n&&"object"==typeof n&&(n.period&&(r.period=n.period),n.minPeriod&&(r.minPeriod=n.period),n.format&&("delta"==n.format||"full"==n.format)&&(r.format=n.format),n.policy&&("instant"==n.policy||"ideal"==n.policy||"fixed"==n.policy)&&(r.policy=n.policy)),i.subscribe.push(r)}this.send(i)}},{key:"unsubscribe",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=N.unsubscribe();this._token&&(n.token=this._token),n.context="self"==e?"vessels.self":e,this._token&&(n.token=this._token),"object"==typeof t&&Array.isArray(t)&&(n.unsubscribe=t),"string"==typeof t&&n.unsubscribe.push({path:t}),this.send(n)}},{key:"raiseAlarm",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;e="string"==typeof n&&-1==n.indexOf("notifications.")?"notifications.".concat(n):n,this.put(t,e,i.value)}},{key:"clearAlarm",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1?arguments[1]:void 0,n=-1==t.indexOf("notifications.")?"notifications.".concat(t):t;this.put(e,n,null)}},{key:"isSelf",value:function(e){return e.context==this.selfId}},{key:"isDelta",value:function(e){return void 0!==e.context}},{key:"isHello",value:function(e){return void 0!==e.version&&void 0!==e.self}},{key:"isResponse",value:function(e){return void 0!==e.requestId}}]),e}();return e.\u0275fac=function(t){return new(t||e)},e.\u0275prov=function(e){return{token:e.token,providedIn:e.providedIn||null,factory:e.factory,value:void 0}}({token:e,factory:e.\u0275fac,providedIn:"root"}),e}(),G=function(){function e(t,n,i,r){l(this,e),this._method=[],this._message="",this._message=void 0!==t?t:"",this._state=void 0!==n?n:L.alarm,i&&this._method.push(q.visual),r&&this._method.push(q.sound)}return f(e,[{key:"value",get:function(){return{message:this._message,state:this._state,method:this._method}}}]),e}(),L=(function(e){e.normal="normal",e.alert="alert",e.warn="warn",e.alarm="alarm",e.emergency="emergency"}(L||(L={})),L),q=(function(e){e.visual="visual",e.sound="sound"}(q||(q={})),q),W=function(){function e(){l(this,e),this.obsList=[],this.stream=new F,this._connect=new I,this.onConnect=this._connect.asObservable(),this._close=new I,this.onClose=this._close.asObservable(),this._error=new I,this.onError=this._error.asObservable(),this._message=new I,this.onMessage=this._message.asObservable()}return f(e,[{key:"endpoint",get:function(){return this.stream.endpoint},set:function(e){this.stream.endpoint=e}},{key:"selfId",get:function(){return this.stream.selfId},set:function(e){this.stream.selfId=e}},{key:"_source",get:function(){return this.stream._source},set:function(e){this.stream._source=e}},{key:"source",set:function(e){this.stream.source=e}},{key:"authToken",set:function(e){this.stream.authToken=e}},{key:"connectionTimeout",get:function(){return this.stream.connectionTimeout},set:function(e){this.stream.connectionTimeout=e}},{key:"isOpen",get:function(){return this.stream.isOpen}},{key:"filter",get:function(){return this.stream.filter},set:function(e){this.stream.filter=e}},{key:"playbackMode",get:function(){return this.stream.playbackMode}},{key:"open",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none",i=arguments.length>2?arguments[2]:void 0;this.obsList.push(this.stream.onConnect.subscribe(function(e){return t._connect.next(e)})),this.obsList.push(this.stream.onClose.subscribe(function(e){return t._close.next(e)})),this.obsList.push(this.stream.onError.subscribe(function(e){return t._error.next(e)})),this.obsList.push(this.stream.onMessage.subscribe(function(e){return t._message.next(e)})),this.stream.open(e,n,i)}},{key:"close",value:function(){this.stream.close(),this.obsList.forEach(function(e){return e.unsubscribe()}),this.obsList=[]}},{key:"sendRequest",value:function(e){return this.stream.sendRequest(e)}},{key:"put",value:function(e,t,n){return this.stream.put(e,t,n)}},{key:"login",value:function(e,t){return this.stream.login(e,t)}},{key:"send",value:function(e){this.stream.send(e)}},{key:"sendUpdate",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"self",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;this.stream.sendUpdate(e,t,n)}},{key:"subscribe",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*",n=arguments.length>2?arguments[2]:void 0;this.stream.subscribe(e,t,n)}},{key:"unsubscribe",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"*";this.stream.unsubscribe(e,t)}},{key:"raiseAlarm",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;this.stream.raiseAlarm(e,t,n)}},{key:"clearAlarm",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"*",t=arguments.length>1?arguments[1]:void 0;this.stream.clearAlarm(e,t)}},{key:"isSelf",value:function(e){return this.stream.isSelf(e)}},{key:"isDelta",value:function(e){return this.stream.isDelta(e)}},{key:"isHello",value:function(e){return this.stream.isHello(e)}},{key:"isResponse",value:function(e){return this.stream.isResponse(e)}}]),e}(),K=f(function e(){l(this,e),this.position=[0,0],this.headingTrue=null,this.headingMagnetic=null,this.cogTrue=null,this.cogMagnetic=null,this.wind={direction:null,mwd:null,twd:null,tws:null,speedTrue:null,sog:null,awa:null,aws:null},this.lastUpdated=new Date,this.orientation=0,this.buddy=!1,this.closestApproach=null,this.mode="day",this.anchor={maxRadius:null,radius:null,position:null},this.resourceUpdates=[],this.autopilot={},this.track=[],this.properties={}}),V=f(function e(){l(this,e),this.lastUpdated=new Date,this.position=[0,0],this.properties={}}),J=function(e){r(n,e);var t=s(n);function n(){var e;return l(this,n),(e=t.call(this)).type={id:-1,name:""},e}return f(n)}(V),Y=function(e){r(n,e);var t=s(n);function n(){var e;return l(this,n),(e=t.call(this)).orientation=0,e.sog=0,e.track=[],e}return f(n)}(V),z=function(){function e(){l(this,e)}return f(e,null,[{key:"celciusToKelvin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e+273.15}},{key:"kelvinToCelcius",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e-273.15}},{key:"kelvinToFarenheit",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return 1.8*e-459.67}},{key:"degreesToRadians",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e*Math.PI/180}},{key:"radiansToDegrees",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return 180*e/Math.PI}},{key:"angleToDirection",value:function(e,t){var n=2*Math.PI;if(t||(t=0),e||(e=0),isNaN(t)||isNaN(e))return null;var i=t+e;return i>n?i-n:i<0?n+i:i}},{key:"directionToAngle",value:function(e,t){var n=2*Math.PI;if(t||(t=0),e||(e=0),isNaN(t)||isNaN(e))return null;var i,r=t-e;if(r>0)i=r>Math.PI?n-r:0-r;else if(r<0){var o=Math.abs(r);i=o>Math.PI?o-n:o}else i=r;return i}},{key:"knotsToKm",value:function(e){return 1.852*e}},{key:"nauticalMilesToKm",value:function(e){return 1.852*e}},{key:"knotsToMSec",value:function(e){return.51444325460445*e}},{key:"kmToKnots",value:function(e){return.539957*e}},{key:"kmToNauticalMiles",value:function(e){return.539957*e}},{key:"kmToMiles",value:function(e){return.621371*e}},{key:"msecToKnots",value:function(e){return 1.94384*e}},{key:"msecToKmh",value:function(e){return 3.6*e}},{key:"msecToMph",value:function(e){return 2.23694*e}},{key:"nauticalMilesToMiles",value:function(e){return 1.15078*e}},{key:"milesToKm",value:function(e){return 1.60934*e}},{key:"milesToNauticalMiles",value:function(e){return.868976*e}},{key:"rpmToHertz",value:function(e){return e/60}}]),e}(),Z=function(){function e(){l(this,e)}return f(e,null,[{key:"destCoordinate",value:function(e,t,n,i){for(var r=6378137,o=6356752.3142,s=1/298.257223563,a=i,u=n,c=Math.sin(u),l=Math.cos(u),h=(1-s)*Math.tan(z.degreesToRadians(e)),f=1/Math.sqrt(1+h*h),d=h*f,v=Math.atan2(h,l),p=f*c,b=1-p*p,g=b*(r*r-o*o)/(o*o),y=1+g/16384*(4096+g*(g*(320-175*g)-768)),m=g/1024*(256+g*(g*(74-47*g)-128)),k=a/(o*y),w=2*Math.PI;Math.abs(k-w)>1e-12;){var _=Math.cos(2*v+k),x=Math.sin(k),S=Math.cos(k);w=k,k=a/(o*y)+m*x*(_+m/4*(S*(2*_*_-1)-m/6*_*(4*x*x-3)*(4*_*_-3)))}var T=d*x-f*S*l,M=Math.atan2(d*S+f*x*l,(1-s)*Math.sqrt(p*p+T*T)),O=s/16*b*(4+s*(4-3*b)),E=Math.atan2(x*c,f*S-d*x*l)-(1-O)*s*p*(k+O*x*(_+O*S*(2*_*_-1))),R=(Math.atan2(p,-T),z.radiansToDegrees(M));return[t+z.radiansToDegrees(E),R]}},{key:"toGo",value:function(t,n){return{bearing:e.bearingTo(t,n),distance:e.distanceTo(t,n)}}},{key:"distanceTo",value:function(e,t){var n=z.degreesToRadians(e[1]),i=z.degreesToRadians(e[0]),r=z.degreesToRadians(t[1]),o=z.degreesToRadians(t[0])-i,s=Math.pow(Math.sin((r-n)/2),2)+Math.cos(n)*Math.cos(r)*Math.pow(Math.sin(o/2),2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6373*1e3}},{key:"bearingTo",value:function(e,t){var n=z.degreesToRadians(e[1]),i=z.degreesToRadians(t[1]),r=z.degreesToRadians(t[0]-e[0]),o=Math.sin(r)*Math.cos(i),s=Math.cos(n)*Math.sin(i)-Math.sin(n)*Math.cos(i)*Math.cos(r);return Math.atan2(o,s)}},{key:"centreOfPolygon",value:function(t){var n=[-180,-90],i=[180,90];if(t.forEach(function(e){i[0]=e[0]<i[0]?e[0]:i[0],i[1]=e[1]<i[1]?e[1]:i[1],n[0]=e[0]>n[0]?e[0]:n[0],n[1]=e[1]>n[1]?e[1]:n[1]}),e.inDLCrossingZone(i)||e.inDLCrossingZone(n)){var r=i[0]>0&&n[0]<0?1:i[0]<0&&n[0]>0?-1:0;1==r&&(n[0]=n[0]+360),-1==r&&(n[0]=Math.abs(n[0])-360)}return[i[0]+(n[0]-i[0])/2,i[1]+(n[1]-i[1])/2]}},{key:"calulateExtent",value:function(e){var t=[180,90,-180,-90];return e.forEach(function(e){t[0]=e[0]<t[0]?e[0]:t[0],t[1]=e[1]<t[1]?e[1]:t[1],t[2]=e[0]>t[2]?e[0]:t[2],t[3]=e[1]>t[3]?e[1]:t[3]}),t}},{key:"inDLCrossingZone",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:170;return Math.abs(e[0])>=t}},{key:"inBounds",value:function(e,t){var n=JSON.parse(JSON.stringify(t)),i=[e[0],e[1]];return n[0]>0&&n[2]<0&&(n[2]=360+n[2],i[0]<0&&(i[0]=360+i[0])),i[0]>n[0]&&i[0]<n[2]&&i[1]>n[1]&&i[1]<n[3]}},{key:"calcMapifiedExtent",value:function(e,t){var n=111111,i=n*Math.cos(z.degreesToRadians(e[1])),r=[0,0,0,0];return r[1]=e[1]+(0-Math.abs(t))/n,r[3]=e[1]+Math.abs(t)/n,r[0]=e[0]+(0-Math.abs(t))/i,r[2]=e[0]+Math.abs(t)/i,r}},{key:"normaliseCoords",value:function(e){var t=this;if(!Array.isArray(e))return[0,0];if("number"==typeof e[0]){if(e[0]>180)for(;e[0]>180;)e[0]=e[0]-360;else if(e[0]<-180)for(;e[0]<-180;)e[0]=360+e[0];return e}return Array.isArray(e[0])?(e.forEach(function(e){return t.normaliseCoords(e)}),e):void 0}}]),e}(),$=o(8332),Q=f(function e(){l(this,e),this.action=null,this.playback=!1,this.result=null}),X=function(e){r(n,e);var t=s(n);function n(e){var i;return l(this,n),(i=t.call(this)).action="notification",i.type=e,i}return f(n)}(Q),ee=function(e){r(n,e);var t=s(n);function n(){var e;return l(this,n),(e=t.call(this)).action="update",e}return f(n)}(Q),te=function(e){r(n,e);var t=s(n);function n(){var e;return l(this,n),(e=t.call(this)).action="trail",e}return f(n)}(Q),ne=["environment.wind.speedTrue","environment.wind.speedOverGround","environment.wind.angleTrueGround","environment.wind.angleTrueWater","environment.wind.directionTrue","environment.wind.directionMagnetic","navigation.courseOverGroundTrue","navigation.courseOverGroundMagnetic","navigation.headingTrue","navigation.headingMagnetic"],ie=[],re=[],oe=!1,se=!1,ae={signalk:{},aisState:[]},ue=[0,0,0,0],ce=60,le=0,he={},fe=500,de=!1,ve={maxAge:54e4,staleAge:36e4,lastTick:(new Date).valueOf(),maxTrack:20},pe={trailDuration:24,trailResolution:{lastHour:"5s",next23:"10s",beyond24:"1m"}};function be(){C={updated:{},stale:{},expired:{}}}function ge(e){var t=e.action,n=e.msg;switch(t){case"onConnect":postMessage({action:"open",playback:de,result:n.target.readyState});break;case"onClose":console.warn("streamEvent: ",n),me(!1);break;case"onError":console.warn("streamEvent: ",n),postMessage({action:"error",playback:de,result:"Connection error!"});break;case"onMessage":!function(e){D.isHello(e)?(postMessage({action:"hello",result:e,self:e.self,playback:de}),fe&&Se()):D.isDelta(e)?(oe=!0,e.updates.forEach(function(t){!t.values||t.values.forEach(function(n){if(H=t.timestamp,e.context)switch(e.context.split(".")[0]){case"shore":case"atons":(null==ae?void 0:ae.signalk.atons)&&function(e,t){var n=!1;if(-1!=e.indexOf("shore.basestations")&&(n=!0),!P.atons.has(e)){var i=new J;i.id=e,i.position=null,n&&(i.type.id=-1,i.type.name="Basestation"),P.atons.set(e,i)}var r=P.atons.get(e);""==t.path?(void 0!==t.value.name&&(r.name=t.value.name),void 0!==t.value.mmsi&&(r.mmsi=t.value.mmsi),void 0!==t.value.atonType&&(r.type=t.value.atonType)):"atonType"==t.path?r.type=t.value:"navigation.position"==t.path?(r.position=[t.value.longitude,t.value.latitude],r.positionReceived=!0):r.properties[t.path]=t.value}(e.context,n),_e(e.context,P.atons,null==ae?void 0:ae.signalk.atons);break;case"sar":(null==ae?void 0:ae.signalk.sar)&&function(e,t){if(!P.sar.has(e)){var n=new J;n.id=e,n.position=null,n.type.id=-1,n.type.name="SaR Beacon",P.sar.set(e,n)}var i=P.sar.get(e);""==t.path?(void 0!==t.value.name&&(i.name=t.value.name),void 0!==t.value.mmsi&&(i.mmsi=t.value.mmsi)):"communication.callsignVhf"==t.path?i.callsign=t.value:"navigation.position"==t.path&&t.value?(i.position=Z.normaliseCoords([t.value.longitude,t.value.latitude]),i.positionReceived=!0):i.properties[t.path]=t.value}(e.context,n),_e(e.context,P.sar,null==ae?void 0:ae.signalk.sar);break;case"aircraft":(null==ae?void 0:ae.signalk.aircraft)&&function(e,t){if(!P.aircraft.has(e)){var n=new Y;n.id=e,n.position=null,P.aircraft.set(e,n)}var i=P.aircraft.get(e);""==t.path?(void 0!==t.value.name&&(i.name=t.value.name),void 0!==t.value.mmsi&&(i.mmsi=t.value.mmsi)):"communication.callsignVhf"==t.path?i.callsign=t.value:"navigation.position"==t.path&&t.value?(i.position=Z.normaliseCoords([t.value.longitude,t.value.latitude]),i.positionReceived=!0,Oe(i)):"navigation.courseOverGroundTrue"==t.path?i.orientation=t.value:"navigation.speedOverGround"==t.path?i.sog=t.value:i.properties[t.path]=t.value}(e.context,n),_e(e.context,P.aircraft,null==ae?void 0:ae.signalk.aircraft);break;case"vessels":D.isSelf(e)?(Me(P.self,n,!0),function(e,t){var n,i={path:e.path,value:e.value,context:null},r=e.path.split(".");if(("notifications.environment.depth.belowTransducer"==e.path||"notifications.environment.depth.belowSurface"==e.path||"notifications.environment.depth.belowKeel"==e.path)&&(n=r[2]),"notifications.navigation.anchor"==e.path&&(n=r[2]),-1!=["mob","sinking","fire","piracy","flooding","collision","grounding","listing","adrift","abandon"].indexOf(r[r.length-1])&&(n=r[r.length-1]),-1!=e.path.indexOf("notifications.navigation.closestApproach")&&(n=r[2],i.context=r[3]),-1!=e.path.indexOf("notifications.buddy")&&(n=r[1],i.context=r[2]),(-1!=e.path.indexOf("notifications.arrivalCircleEntered")||-1!=e.path.indexOf("notifications.navigation.course.arrivalCircleEntered"))&&(n=r[1],i.context=r[2]),n){var o=new X(n);o.playback=de,o.result=i,postMessage(o)}}(n)):((null==ae?void 0:ae.signalk.vessels)&&Me(function(e){if(!P.aisTargets.has(e)){var t=new K;t.position=null,P.aisTargets.set(e,t)}return P.aisTargets.get(e)}(e.context),n),_e(e.context,P.aisTargets,null==ae?void 0:ae.signalk.vessels,null==ae?void 0:ae.aisState))}})}),xe()):D.isResponse(e)&&postMessage({action:"response",result:e})}(n)}}function ye(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interval&&"number"==typeof e.interval&&(fe=e.interval,Te(),Se(),ce=1/(fe/1e3)*60),de=!!e.playback,e.selections&&(void 0!==e.selections.preferredPaths&&(he=e.selections.preferredPaths),e.selections.aisMaxAge&&"number"==typeof e.selections.aisMaxAge&&(ve.maxAge=e.selections.aisMaxAge),e.selections.aisStaleAge&&"number"==typeof e.selections.aisStaleAge&&(ve.staleAge=e.selections.aisStaleAge),"number"==typeof e.selections.signalk.maxRadius&&(ae.signalk=e.selections.signalk),void 0!==e.selections.aisState&&Array.isArray(e.selections.aisState)&&(ae.aisState=e.selections.aisState),console.log("Worker: AIS Filter...",ae))}function me(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Te(),ie.forEach(function(e){return e.unsubscribe()}),D&&e&&D.close(),D=null,postMessage({action:"close",result:e,playback:de})}function ke(e){return new Promise(function(t,n){fetch("".concat(e)).then(function(e){e.json().then(function(e){return t(e)}).catch(function(e){return n(e)})}).catch(function(e){n(e)})})}function we(){ke(j+"/tracks"+(ae&&ae.signalk&&ae.signalk.maxRadius?"?radius=".concat(ae.signalk.maxRadius):"?radius=10000")).then(function(e){se=!0,Object.entries(e).forEach(function(e){if(P.aisTargets.has(e[0])){var t=P.aisTargets.get(e[0]);t.track=e[1].coordinates,Oe(t)}})}).catch(function(e){se=!1,console.warn("Unable to fetch AIS tracks!")})}function _e(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];if(n){var r=t.get(e);r&&i.includes(null==r?void 0:r.state)&&(console.log("state match => ".concat(i,", ").concat(e)),C.expired[e]=!0,r=null),r&&ae.signalk.maxRadius?r.positionReceived&&Z.inBounds(r.position,ue)?C.updated[e]=!0:(t.delete(e),C.expired[e]=!0):C.updated[e]=!0}else 0!=t.size&&(t.forEach(function(e,t){C.expired[t]=!0}),t.clear())}function xe(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!fe||e){var t=new ee;t.playback=de,P.aisStatus.updated=Object.keys(C.updated),P.aisStatus.stale=Object.keys(C.stale),P.aisStatus.expired=Object.keys(C.expired),t.result=P,t.timestamp=de?H:P.self.lastUpdated.toISOString(),postMessage(t),be(),P.self.resourceUpdates=[],0==le&&(function(){var e=(new Date).valueOf();P.aisTargets.forEach(function(t,n){t.lastUpdated<e-ve.maxAge?(C.expired[n]=!0,P.aisTargets.delete(n)):t.lastUpdated<e-ve.staleAge&&(C.stale[n]=!0)}),P.aircraft.forEach(function(t,n){t.lastUpdated<e-ve.maxAge?(C.expired[n]=!0,P.aircraft.delete(n)):t.lastUpdated<e-ve.staleAge&&(C.stale[n]=!0)}),P.sar.forEach(function(t,n){t.lastUpdated<e-ve.maxAge?(C.expired[n]=!0,P.sar.delete(n)):t.lastUpdated<e-ve.staleAge&&(C.stale[n]=!0)})}(),P.self.positionReceived&&(null==ae?void 0:ae.signalk.maxRadius)&&(ue=Z.calcMapifiedExtent(P.self.position,ae.signalk.maxRadius),le++)),le=le>=ce?0:le+1}}function Se(){fe&&"number"==typeof fe&&re.push(setInterval(function(){oe&&(xe(!0),oe=!1)},fe)),re.push(setInterval(function(){console.warn("hasTrackPlugin",se),se&&we()},6e4))}function Te(){re.forEach(function(e){return clearInterval(e)}),re=[]}function Me(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e.lastUpdated=new Date,n&&-1!=ne.indexOf(t.path)&&(P.paths[t.path]=t.value),""==t.path)void 0!==t.value.name&&(e.name=t.value.name),void 0!==t.value.mmsi&&(e.mmsi=t.value.mmsi),void 0!==t.value.buddy&&(e.buddy=t.value.buddy);else if("communication.callsignVhf"==t.path)e.callsign=t.value;else if("navigation.position"==t.path&&t.value){if(void 0===t.value.longitude)return;e.position=Z.normaliseCoords([t.value.longitude,t.value.latitude]),e.positionReceived=!0,n||Oe(e)}else"navigation.state"==t.path?e.state=t.value:"navigation.speedOverGround"==t.path?e.sog=t.value:"navigation.courseOverGroundTrue"==t.path?e.cogTrue=t.value:"navigation.courseOverGroundMagnetic"==t.path?e.cogMagnetic=t.value:"navigation.headingTrue"==t.path?e.headingTrue=t.value:"navigation.headingMagnetic"==t.path?e.headingMagnetic=t.value:"environment.wind.angleApparent"==t.path?e.wind.awa=t.value:"environment.wind.speedApparent"==t.path?e.wind.aws=t.value:"environment.wind.speedTrue"==t.path?e.wind.speedTrue=t.value:"environment.wind.speedOverGround"==t.path?e.wind.sog=t.value:"environment.wind.directionTrue"==t.path?e.wind.twd=t.value:"environment.wind.directionMagnetic"==t.path?e.wind.mwd=t.value:"environment.mode"==t.path?e.mode=t.value:-1!=t.path.indexOf("navigation.courseRhumbline")&&void 0!==he.course&&t.path.split(".").slice(0,2).join(".")==he.course||-1!=t.path.indexOf("navigation.courseGreatCircle")&&void 0!==he.course&&t.path.split(".").slice(0,2).join(".")==he.course?e["course."+t.path.split(".").slice(2).join(".")]=t.value:-1!=t.path.indexOf("navigation.closestApproach")?e.closestApproach=t.value:"navigation.anchor.position"==t.path?e.anchor.position=t.value:"navigation.anchor.maxRadius"==t.path?e.anchor.maxRadius=t.value:"navigation.anchor.currentRadius"==t.path?e.anchor.radius=t.value:-1!=t.path.indexOf("resources.")?e.resourceUpdates.push(t):"steering.autopilot.state"==t.path?e.autopilot.state=t.value:"steering.autopilot.mode"==t.path?e.autopilot.mode=t.value:e.properties[t.path]=t.value;e.heading=null==e.heading&&null!=e.cog?e.cog:e.heading,void 0!==he.heading&&t.path==he.heading&&(e.orientation=t.value),void 0!==he.tws&&t.path==he.tws&&(e.wind.tws=t.value),void 0!==he.twd&&t.path==he.twd&&(e.wind.direction="environment.wind.angleTrueGround"==t.path||"environment.wind.angleTrueWater"==t.path?z.angleToDirection(t.value,e.heading):t.value)}function Oe(e){if(e.track&&0==e.track.length)e.track.push([e.position]);else{var t=e.track[e.track.length-1][e.track[e.track.length-1].length-1];t[0]!=e.position[0]&&t[1]!=e.position[1]&&e.track[e.track.length-1].push(e.position)}e.track[e.track.length-1]=e.track[e.track.length-1].slice(0-ve.maxTrack)}addEventListener("message",function(t){!function(t){var n,i,r,o;if(t.cmd)switch(t.cmd){case"open":console.log("Worker control: opening stream..."),ye(t.options),function(e){if(!D)if(e.url){var t=e.url.split("/");if(t.pop(),t.push("api"),t[0]="wss:"==t[0]?"https:":"http:",j=t.join("/"),(P={self:new K,aisTargets:new Map,aisStatus:{updated:[],stale:[],expired:[]},paths:{},atons:new Map,aircraft:new Map,sar:new Map}).self.positionReceived=!1,be(),D=new W,ie.push(D.onConnect.subscribe(function(e){return ge({action:"onConnect",msg:e})})),ie.push(D.onClose.subscribe(function(e){return ge({action:"onClose",msg:e})})),ie.push(D.onError.subscribe(function(e){return ge({action:"onError",msg:e})})),ie.push(D.onMessage.subscribe(function(e){return ge({action:"onMessage",msg:e})})),e.playback){var n=e.playbackOptions.startTime?"?startTime=".concat(e.playbackOptions.startTime):null,i=e.playbackOptions.playbackRate?"playbackRate=".concat(e.playbackOptions.playbackRate):null;i=i?n?"&"+i:"?"+i:null,D.open("".concat(e.url).concat(n||"").concat(i||""),e.playbackOptions.subscribe,e.token)}else D.open(e.url,e.subscribe,e.token),we()}else postMessage({action:"error",result:"Valid options not provided!"})}(t.options);break;case"close":console.log("Worker control: closing stream..."),me(!0);break;case"subscribe":console.log("Worker control: subscribing to paths..."),D.subscribe(t.options.context,t.options.path);break;case"settings":console.log("Worker control: settings..."),ye(t.options);break;case"alarm":console.log("Worker control: alarm action..."),function(e){var t=-1==e.type.indexOf("notifications.")?"notifications.".concat(e.type):e.type;e.raise?D.raiseAlarm("self",t,new G(e.message,e.state,!0,!0)):D.clearAlarm("self",t)}(t.options);break;case"vessel":var s;if(console.log("Worker control: vessel setting..."),t.options)(s="self"==t.options.context?P.self:P.aisTargets.get(t.options.context))&&t.options.name&&(s.name=t.options.name);break;case"auth":console.log("Worker control: auth token..."),t.options&&(D.authToken=t.options.token);break;case"trail":console.log("Worker control: Fetch vessel trail from server..."),t.options&&(pe.trailDuration=null!==(n=t.options.trailDuration)&&void 0!==n?n:24,t.options.trailResolution&&(pe.trailResolution.lastHour=null!==(i=t.options.trailResolution.lastHour)&&void 0!==i?i:"5s",pe.trailResolution.next23=null!==(r=t.options.trailResolution.next23)&&void 0!==r?r:"1m",pe.trailResolution.beyond24=null!==(o=t.options.trailResolution.beyond24)&&void 0!==o?o:"5m")),function(t){console.info("Fetching vessel trail from server!",t);var n=j+"/self/track?",i=[];t.trailDuration>24&&(i.push(ke("".concat(n,"timespan=").concat(t.trailDuration-24,"h&resolution=").concat(t.trailResolution.beyond24,"&timespanOffset=24"))),i.push(ke("".concat(n,"timespan=23h&resolution=").concat(t.trailResolution.next23,"&timespanOffset=1")))),t.trailDuration>1&&t.trailDuration<25&&i.push(ke("".concat(n,"timespan=").concat(t.trailDuration-1,"h&resolution=").concat(t.trailResolution.next23,"&timespanOffset=1"))),i.push(ke("".concat(n,"timespan=1h&resolution=").concat(t.trailResolution.lastHour)));var r=[],o=new te;o.playback=de,Promise.all(i).then(function(t){var n,s=0,a=i.length-1;(n=console).log.apply(n,["res"].concat(e(t))),t.forEach(function(e){e.type&&"MultiLineString"===e.type&&e.coordinates&&Array.isArray(e.coordinates)&&(s!=a?function(){var t=[];for(e.coordinates.forEach(function(e){t=t.concat(e)}),t=(0,$.EK)(t,5e-4,!0);t.length>60;){var n=t.slice(0,60);r.push(n),(t=t.slice(59))[0]=[t[0][0]+5e-9,t[0][1]+5e-9]}0!==t.length&&r.push(t)}():r=r.concat(e.coordinates)),s++}),console.log("trail",r),o.result=r,postMessage(o)}).catch(function(e){o.result=null,postMessage(o)})}(pe)}}(t.data)})}()}()}();
@@ -1248,15 +1248,23 @@
1248
1248
  <i>signalk/v1/api/self/track</i>.<br>
1249
1249
  </li>
1250
1250
  <li>
1251
- Use the slider to set the length of track to retrieve from the server
1251
+ Use the slider to set the <b>length</b> of track to retrieve from the server
1252
1252
  in hours. Time is relative to the current time.<br>
1253
1253
 
1254
- Freeboard will attempt to retrieve track from the server in the following way:
1254
+ The <b>Resolution</b> settings define the number of track points returned by the
1255
+ server for the following time windows:
1255
1256
  <ul>
1256
- <li>time < (now - 24hrs) => 5 minute intervals.</li>
1257
- <li>(now - 1hr) < time > (now - 24hrs) => 1 minute intervals.</li>
1258
- <li>time > (now - 1hr) => 5 second intervals.</li>
1257
+ <li>Last hour (default = 5 secs)</li>
1258
+ <li>1 hour -> 24 hours (default = 1 min)</li>
1259
+ <li>> 24 hours (default = 5 min)</li>
1259
1260
  </ul>
1261
+ <span style="color:red"><b>Note:</b> Selections will determine the volume of data transferred from the
1262
+ server which may impact performance.
1263
+ </span>
1264
+ Trail data received from the server undergoes
1265
+ temporal simplification to minimise the data used to display the trail whilst
1266
+ maintianing integrity.
1267
+
1260
1268
  </li>
1261
1269
  </ul>
1262
1270
  </li>
package/public/index.html CHANGED
@@ -72,6 +72,6 @@
72
72
  </div>
73
73
  </div>
74
74
  </app-root>
75
- <script src="runtime-es2015.590ce0576882394cd0a4.js" type="module"></script><script src="runtime-es5.590ce0576882394cd0a4.js" nomodule defer></script><script src="polyfills-es5.db83d87fca4fca7bb07a.js" nomodule defer></script><script src="polyfills-es2015.c13136a48056748116fd.js" type="module"></script><script src="main-es2015.f4a91b99f17fed6aa4cc.js" type="module"></script><script src="main-es5.f4a91b99f17fed6aa4cc.js" nomodule defer></script>
75
+ <script src="runtime-es2015.f799139aff466a1573e8.js" type="module"></script><script src="runtime-es5.f799139aff466a1573e8.js" nomodule defer></script><script src="polyfills-es5.db83d87fca4fca7bb07a.js" nomodule defer></script><script src="polyfills-es2015.c13136a48056748116fd.js" type="module"></script><script src="main-es2015.17183406194d3d974967.js" type="module"></script><script src="main-es5.17183406194d3d974967.js" nomodule defer></script>
76
76
 
77
77
  </body></html>