@mxtommy/kip
Version:
An advanced and versatile marine instrumentation package to display Signal K data.
1 lines • 143 kB
JavaScript
import{$a as wr,Aa as hi,Bc as ie,Cc as $,Da as de,Dd as Ie,Ea as mi,Eb as F,F as ci,Fb as R,Fe as Vi,Ga as J,Gb as bi,Ia as Ee,Ja as Z,Je as Ei,La as rt,Lc as Et,Le as Ii,M as De,N as ui,Nb as ot,Nc as kr,Nd as wi,Pb as L,Pd as Ai,Qe as lt,Rb as X,Rc as Mr,Re as Oi,Te as Pi,U as di,Ue as Fi,Vb as _i,Wa as P,Wb as Ar,Xb as Tr,Xd as Ti,Ya as Vt,Za as gi,Zd as Vr,a as C,ab as p,b as j,bc as at,dc as Ci,ea as fi,ec as Q,ee as Di,f as I,fa as pi,fc as st,gb as it,gc as Dr,hb as nt,ia as Mt,ib as m,ie as It,k as G,ka as O,la as x,lb as _,le as Er,m as v,ma as tt,mb as vi,me as Ir,nd as Si,ne as ki,oa as z,oe as Mi,qa as f,qb as yi,r as si,re as Or,s as li,sc as N,t as xr,va as ke,vb as re,w as B,wa as Me,xb as Ce,xd as xi,y as Dt,yb as Se,z as kt,za as Ve}from"./chunk-LEY6MANN.js";var d=(function(t){return t.Disconnected="Disconnected",t.HTTPDiscovering="HTTPDiscovering",t.HTTPConnected="HTTPConnected",t.HTTPError="HTTPError",t.HTTPRetrying="HTTPRetrying",t.WebSocketConnecting="WebSocketConnecting",t.Connected="Connected",t.WebSocketError="WebSocketError",t.WebSocketRetrying="WebSocketRetrying",t.PermanentFailure="PermanentFailure",t})(d||{}),Ri=(()=>{class t{config={httpRetryCount:3,webSocketRetryCount:5,retryIntervals:[2e3,3e3,5e3],notificationDebounceMs:0};_currentState$=new v(d.Disconnected);_status$=new v(this.createStatus(d.Disconnected,"Not connected"));_httpRetryCount=0;_webSocketRetryCount=0;_retryTimeout=null;_notificationTimeout=null;_httpRetryCallback=null;_webSocketRetryCallback=null;_isInitializationMode=!0;constructor(){console.log("[ConnectionStateMachine] Service initialized")}get state$(){return this._currentState$.asObservable()}get status$(){return this._status$.asObservable()}get currentState(){return this._currentState$.getValue()}enableWebSocketMode(){this._isInitializationMode=!1,console.log("[ConnectionStateMachine] WebSocket mode enabled");let e=this._status$.getValue();this._status$.next(e)}setHTTPRetryCallback(e){this._httpRetryCallback=e}setWebSocketRetryCallback(e){this._webSocketRetryCallback=e}startHTTPDiscovery(e="Connection request"){console.log(`[ConnectionStateMachine] Starting HTTP discovery: ${e}`),this._httpRetryCount=0,this.setState(d.HTTPDiscovering,"Discovering Signal K server...")}onHTTPDiscoverySuccess(){console.log("[ConnectionStateMachine] HTTP discovery successful"),this._httpRetryCount=0,this.setState(d.HTTPConnected,"Signal K server discovered"),this._isInitializationMode||this.startWebSocketConnection()}onHTTPDiscoveryError(e){console.log(`[ConnectionStateMachine] HTTP discovery failed: ${e}`),this._httpRetryCount<this.config.httpRetryCount?(this._httpRetryCount++,this.setState(d.HTTPRetrying,`HTTP connection failed. Retrying (${this._httpRetryCount}/${this.config.httpRetryCount})...`,this._httpRetryCount,this.config.httpRetryCount),this.scheduleHTTPRetry()):this.setState(d.PermanentFailure,`HTTP connection failed after ${this.config.httpRetryCount} attempts. Check server URL.`,this.config.httpRetryCount,this.config.httpRetryCount)}startWebSocketConnection(){if(!(this.currentState===d.HTTPConnected||this.currentState===d.WebSocketRetrying||this.currentState===d.WebSocketConnecting||this.currentState===d.Connected))return this.currentState===d.HTTPDiscovering,void 0;console.log("[ConnectionStateMachine] Starting WebSocket connection"),this._webSocketRetryCount=0,this.setState(d.WebSocketConnecting,"Connecting to Signal K Websocket...")}onWebSocketConnected(){console.log("[ConnectionStateMachine] WebSocket connected"),this._webSocketRetryCount=0,this.setState(d.Connected,"Connected to Signal K server")}onWebSocketError(e){if(console.log(`[ConnectionStateMachine] WebSocket error: ${e}`),this.currentState!==d.HTTPConnected&&this.currentState!==d.WebSocketConnecting&&this.currentState!==d.Connected&&this.currentState!==d.WebSocketRetrying){console.log("[ConnectionStateMachine] HTTP connection lost, restarting HTTP discovery"),this.startHTTPDiscovery("HTTP connection lost during WebSocket operation");return}this._webSocketRetryCount++,this.setState(d.WebSocketRetrying,`WebSocket connection failed. Retry attempt ${this._webSocketRetryCount}...`,this._webSocketRetryCount,this.config.webSocketRetryCount),this.scheduleWebSocketRetry()}shutdown(e="App shutdown"){console.log(`[ConnectionStateMachine] Shutting down all connections: ${e}`),this.clearRetryTimer(),this.clearNotificationTimeout(),this._httpRetryCount=0,this._webSocketRetryCount=0,this.setState(d.Disconnected,"Application restarting...")}isHTTPConnected(){return this.currentState===d.HTTPConnected||this.currentState===d.WebSocketConnecting||this.currentState===d.Connected||this.currentState===d.WebSocketRetrying}isFullyConnected(){return this.currentState===d.Connected}getHttpRetryWindowMs(e=0){return Array.from({length:this.config.httpRetryCount},(n,o)=>{let a=Math.min(o,this.config.retryIntervals.length-1);return this.config.retryIntervals[a]}).reduce((n,o)=>n+o,0)+e}setState(e,i,n,o){this._currentState$.next(e);let a=this.createStatus(e,i,n,o);e===d.HTTPDiscovering||e===d.WebSocketConnecting?this._status$.next(a):e===d.Connected?(this.clearNotificationTimeout(),this._notificationTimeout=setTimeout(()=>{this._status$.next(a)},this.config.notificationDebounceMs)):(this.clearNotificationTimeout(),this._status$.next(a))}createStatus(e,i,n,o){return{state:e,operation:this.stateToOperationCode(e),message:i,retryCount:n||0,maxRetries:o||0,timestamp:new Date}}stateToOperationCode(e){switch(e){case d.Disconnected:return 0;case d.HTTPDiscovering:case d.WebSocketConnecting:return 1;case d.Connected:return 2;case d.HTTPError:case d.WebSocketError:case d.HTTPRetrying:case d.WebSocketRetrying:return 3;case d.HTTPConnected:return 2;case d.PermanentFailure:return 5;default:return 0}}scheduleHTTPRetry(){this.clearRetryTimer();let e=Math.min(this._httpRetryCount-1,this.config.retryIntervals.length-1),i=this.config.retryIntervals[e];console.log(`[ConnectionStateMachine] Scheduling HTTP retry in ${i}ms`),this._retryTimeout=setTimeout(()=>{this._httpRetryCallback?(console.log(`[ConnectionStateMachine] Executing HTTP retry ${this._httpRetryCount}/${this.config.httpRetryCount}`),this._httpRetryCallback()):(console.error("[ConnectionStateMachine] No HTTP retry callback set!"),this.setState(d.Disconnected,"HTTP retry callback not configured"))},i)}scheduleWebSocketRetry(){this.clearRetryTimer(),console.log(`[ConnectionStateMachine] Scheduling WebSocket retry in ${this.config.retryIntervals[1]}ms`),this._retryTimeout=setTimeout(()=>{this._webSocketRetryCallback?(console.log(`[ConnectionStateMachine] Executing WebSocket retry ${this._webSocketRetryCount}/${this.config.webSocketRetryCount}`),this._webSocketRetryCallback()):(console.log("[ConnectionStateMachine] No WebSocket retry callback - using state change method"),this.setState(d.WebSocketConnecting,`Retrying WebSocket connection (${this._webSocketRetryCount}/${this.config.webSocketRetryCount})...`,this._webSocketRetryCount,this.config.webSocketRetryCount))},this.config.retryIntervals[1])}clearRetryTimer(){this._retryTimeout&&(clearTimeout(this._retryTimeout),this._retryTimeout=null)}clearNotificationTimeout(){this._notificationTimeout&&(clearTimeout(this._notificationTimeout),this._notificationTimeout=null)}ngOnDestroy(){this.clearRetryTimer(),this.clearNotificationTimeout(),this._httpRetryCallback=null,this._webSocketRetryCallback=null,this._currentState$?.complete(),this._status$?.complete()}static \u0275fac=function(i){return new(i||t)};static \u0275prov=x({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var Oe=(()=>{class t{TIMEOUT_DURATION=1e4;connectionStateMachine=f(Ri);constructor(){this.connectionStateMachine.setHTTPRetryCallback(()=>{console.log("[SignalKConnectionService] Executing HTTP retry via callback"),this.retryCurrentConnection()})}serverServiceEndpoint$=new v({operation:0,message:"Not connected",serverDescription:null,httpServiceUrl:null,WsServiceUrl:null});signalKURL;serverName;serverVersion$=new v(null);serverRoles=[];http=f(Ie);currentProxyEnabled;currentSubscribeAll;validateSignalKUrl(e){return I(this,null,function*(){if(!e)throw new Error("Please enter a server URL");try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol))throw new Error("URL must start with http:// or https://")}catch(n){throw new Error("Invalid URL format - please check for typos and ensure it starts with http:// or https://")}let i=e;i.endsWith("signalk/")||(i+="/signalk/"),console.log(`[Connection Service] Validating Signal K server at: ${e}`);try{if(!(yield B(this.http.get(i,{observe:"response"}).pipe(Dt(5e3),De(o=>{throw console.error("[Connection Service] HTTP Error details:",o),o.name==="TimeoutError"?(console.error("[Connection Service] Validation timed out after 5000ms"),new Error("Server is not responding - check if the URL is correct and the server is running")):o.status===0||o.status===void 0?new Error("Cannot connect to server - check the URL format and ensure the server is accessible"):o.status===404?new Error("Server found but no Signal K service detected - verify this is a Signal K server"):o.status===403?new Error("Server refused connection - check if the server allows connections from this browser"):o.status>=500?new Error(`Server error (${o.status}) - the Signal K server may be having issues`):new Error(`Connection failed (${o.status}) - ${o.statusText||"please check the server URL"}`)})))).body?.endpoints?.v1)throw new Error("Server responded but doesn't appear to be a Signal K server - missing required endpoints");console.log(`[Connection Service] Validation successful for: ${e}`)}catch(n){throw console.error(`[Connection Service] Validation failed for ${e}:`,n.message),n}})}initializeConnection(e,i,n){return I(this,null,function*(){if(!e.url){console.log("[Connection Service] Connection initialization called with null or empty URL value");return}this.currentProxyEnabled=i,this.currentSubscribeAll=n;let o={operation:1,message:"Connecting...",serverDescription:null,httpServiceUrl:null,WsServiceUrl:null};this.signalKURL=e,this.serverServiceEndpoint$.next(o),this.connectionStateMachine.startHTTPDiscovery(`Connecting to ${e.url}`);let a=this.signalKURL.url;a.endsWith("signalk/")||(a+="/signalk/");try{console.log("[Connection Service] Connecting to: "+this.signalKURL.url);let s=yield B(this.http.get(a,{observe:"response"}).pipe(Dt(this.TIMEOUT_DURATION),De(l=>(l.name==="TimeoutError"&&console.error("[Connection Service] Connection request timed out after "+this.TIMEOUT_DURATION+"ms"),xr(l)))));Object.assign(o,this.processEndpointResponse(s,i,n)),this.connectionStateMachine.onHTTPDiscoverySuccess()}catch(s){o.operation=3,o.message=s.message,this.connectionStateMachine.onHTTPDiscoveryError(s.message),this.handleError(s)}finally{o.subscribeAll=!!n,this.serverServiceEndpoint$.next(o)}})}retryCurrentConnection(){if(!this.signalKURL?.url){console.error("[SignalKConnectionService] Cannot retry - no current URL stored");return}console.log(`[SignalKConnectionService] Retrying connection to ${this.signalKURL.url}`),this.performHTTPDiscovery()}performHTTPDiscovery(){return I(this,null,function*(){if(!this.signalKURL?.url){console.error("[SignalKConnectionService] No URL available for HTTP discovery");return}let e=this.signalKURL.url;e.endsWith("signalk/")||(e+="/signalk/");try{console.log("[Connection Service] Connecting to: "+this.signalKURL.url);let i=yield B(this.http.get(e,{observe:"response"}).pipe(Dt(this.TIMEOUT_DURATION),De(o=>(o.name==="TimeoutError"&&console.error("[Connection Service] Connection request timed out after "+this.TIMEOUT_DURATION+"ms"),xr(o))))),n=this.processEndpointResponse(i,this.currentProxyEnabled,this.currentSubscribeAll);this.connectionStateMachine.onHTTPDiscoverySuccess(),this.serverServiceEndpoint$.next(n)}catch(i){let n={operation:3,message:i.message,serverDescription:null,httpServiceUrl:null,WsServiceUrl:null};this.connectionStateMachine.onHTTPDiscoveryError(i.message),this.serverServiceEndpoint$.next(n),this.handleError(i)}})}processEndpointResponse(e,i,n){console.debug("[Connection Service] Signal K HTTP Endpoints retrieved"),this.serverVersion$.next(e.body.server.version);let o=e.body.endpoints.v1["signalk-http"],a=e.body.endpoints.v1["signalk-ws"],s=e.body.endpoints.v2?.["signalk-http"],l=e.body.endpoints.v2?.["signalk-ws"],c={operation:2,message:e.status?.toString()||"Connected",serverDescription:`${e.body.server.id} ${e.body.server.version}`,httpServiceUrl:null,WsServiceUrl:null};if(i)console.debug("[Connection Service] Proxy Mode Enabled"),c.httpServiceUrl=window.location.origin+new URL(o).pathname,c.WsServiceUrl=window.location.protocol.replace("http","ws")+"//"+window.location.host+new URL(a).pathname,s&&(c.httpServiceUrlV2=window.location.origin+new URL(s).pathname),l&&(c.WsServiceUrlV2=window.location.protocol.replace("http","ws")+"//"+window.location.host+new URL(l).pathname);else{c.httpServiceUrl=o;let u=window.location.protocol==="https:";c.WsServiceUrl=u?a.replace("ws://","wss://"):a,s&&(c.httpServiceUrlV2=s),l&&(c.WsServiceUrlV2=u?l.replace("ws://","wss://"):l)}return console.debug("[Connection Service] HTTP URI: "+c.httpServiceUrl),c.httpServiceUrlV2&&console.debug("[Connection Service] HTTP V2 URI: "+c.httpServiceUrlV2),console.debug("[Connection Service] WebSocket URI: "+c.WsServiceUrl),c.WsServiceUrlV2&&console.debug("[Connection Service] WebSocket V2 URI: "+c.WsServiceUrlV2),c.subscribeAll=!!n,c}handleError(e){let i=e.status===0?`[Connection Service] ${e.name}: ${e.message}`:`[Connection Service] Backend returned code ${e.status}, body was: ${e.error}`;throw console.error(i),e}getServiceEndpointStatusAsO(){return this.serverServiceEndpoint$.asObservable()}setServerInfo(e,i,n){this.serverName=e,this.serverRoles=n,console.log(`[Connection Service] Server Name: ${e}, Version: ${i}, Roles: ${JSON.stringify(n)}`)}get skServerName(){return this.serverName}get skServerVersion(){return this.serverVersion$.getValue()}get skServerRoles(){return this.serverRoles}static \u0275fac=function(i){return new(i||t)};static \u0275prov=x({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var Ua="/signalk/v1/",Ni="auth/login",ja="auth/logout",Ba="auth/validate",Pr=60,La=2147483647,Ui=(()=>{class t{http=f(Ie);conn=f(Oe);_IsLoggedIn$=new v(!1);isLoggedIn$=this._IsLoggedIn$.asObservable();_authToken$=new v(null);authToken$=this._authToken$.asObservable();connectionEndpointSubscription=null;authTokenSubscription=null;renewalTimerId=null;isRenewingToken=!1;loginUrl=null;logoutUrl=null;validateTokenUrl=null;constructor(){let e=JSON.parse(localStorage.getItem("authorization_token"));e&&(e.isDeviceAccessToken?e.expiry===null?(console.log("[Authentication Service] Device Access Token found with expiry: NEVER"),this._authToken$.next(e)):this.isTokenExpired(e.expiry)?(console.log("[Authentication Service] Device Access Token expired. Deleting token"),localStorage.removeItem("authorization_token")):(console.log("[Authentication Service] Device Access Token found in Local Storage"),this._authToken$.next(e)):(console.log("[Authentication Service] User session token found in Local Storage"),console.log("[Authentication Service] Deleting user session token"),localStorage.removeItem("authorization_token"))),this.authTokenSubscription=this._authToken$.pipe(di((i,n)=>i?.expiry===n?.expiry)).subscribe(i=>{this.renewalTimerId&&(clearTimeout(this.renewalTimerId),this.renewalTimerId=null),!(!i||i.expiry==null)&&this.scheduleRenewalChunk(i)}),this.connectionEndpointSubscription=this.conn.serverServiceEndpoint$.subscribe(i=>{if(i.operation===2){let n=i.httpServiceUrl.substring(0,i.httpServiceUrl.length-4);this.loginUrl=n+Ni,this.logoutUrl=n+ja,this.validateTokenUrl=n+Ba}})}scheduleRenewalChunk(e){let i=Date.now(),n=(e.expiry-Pr)*1e3,o=n-i;if(o<=0){this.handleTokenRenewal();return}let a=Math.min(o,La);console.log(a!==o?`[Authentication Service] Large renewal delay (${o} ms). Scheduling first chunk of ${a} ms.`:`[Authentication Service] Scheduling token renewal in ${a} ms (buffered target: ${new Date(n).toISOString()})`),this.renewalTimerId=setTimeout(()=>{this.renewalTimerId=null;let s=this._authToken$.getValue();!s||s.expiry!==e.expiry||this.scheduleRenewalChunk(e)},a)}handleTokenRenewal(){if(this.isRenewingToken){console.warn("[Authentication Service] Token renewal already in progress.");return}this.isRenewingToken=!0;let e=JSON.parse(localStorage.getItem("authorization_token"));if(!e){console.warn("[Authentication Service] No token found in local storage. Cannot renew."),this.isRenewingToken=!1;return}if(e.isDeviceAccessToken)console.warn("[Authentication Service] Device Access Token expired. Manual renewal required."),this.isRenewingToken=!1;else{let i=Math.floor(Date.now()/1e3),n=e.expiry-i;if(this.isTokenExpired(e.expiry))console.log("[Authentication Service] User session Token expired. Cannot renew."),this.isRenewingToken=!1;else if(n>Pr)console.log(`[Authentication Service] Renewal trigger fired early; ${n}s remaining (> buffer ${Pr}s). Rescheduling.`),this.isRenewingToken=!1,this.scheduleRenewalChunk(e);else{console.log(`[Authentication Service] User session Token within renewal window (${n}s remaining). Renewing token...`);let o=JSON.parse(localStorage.getItem("connectionConfig"));this.login({usr:o.loginName,pwd:o.loginPassword}).then(()=>{console.log("[Authentication Service] Token successfully renewed.")}).catch(a=>{console.error("[Authentication Service] Token renewal failed. Server returned:",a.error)}).finally(()=>{this.isRenewingToken=!1})}}}login(o){return I(this,arguments,function*({usr:e,pwd:i,newUrl:n}){let a;if(n?a=n.replace(/\/+$/,"")+Ua+Ni:a=this.loginUrl,this._IsLoggedIn$.getValue()&&(yield this.logout(!0)),!a)throw console.error("[Authentication Service] Login URL is not set. Cannot perform login."),this.deleteToken(),new Error("Login URL is not set.");yield B(this.http.post(a,{username:e,password:i},{observe:"response"})).then(s=>{console.log("[Authentication Service] User "+e+" login successful"),this.setSession(s.body.token)}).catch(s=>{this.deleteToken(),this.handleError(s)})})}handleError(e){throw e.status===0&&this.deleteToken(),e}setSession(e){if(e){let i=JSON.parse(atob(e.split(".")[1])).exp,n={token:null,expiry:null,isDeviceAccessToken:!1};i===void 0?(n.token=e,console.log("[Authentication Service] User Session Token received. Token Expiration: NEVER"),this._IsLoggedIn$.next(!0),this._authToken$.next(n),localStorage.setItem("authorization_token",JSON.stringify(n))):this.isTokenExpired(i)?console.log("[Authentication Service] Received expired Session Token from server"):(n.token=e,n.expiry=i,console.log("[Authentication Service] Session Authorization Token received. Token Expiration: "+this.getTokenExpirationDate(n.expiry)),this._IsLoggedIn$.next(!0),this._authToken$.next(n),localStorage.setItem("authorization_token",JSON.stringify(n)))}}isTokenExpired(e){return Math.floor(new Date().getTime()/1e3)>=e}getTokenExpirationDate(e,i){let n=new Date(0);if(i){let o=new Date(0);o.setUTCSeconds(e-i),n=o}else n.setUTCSeconds(e);return n}renewToken(){return this.http.post(this.validateTokenUrl,null,{observe:"response"})}logout(e){return I(this,null,function*(){localStorage.removeItem("authorization_token"),yield B(this.http.put(this.logoutUrl,null)).then(()=>{this._IsLoggedIn$.next(!1),e||this._authToken$.next(null),console.log("[Authentication Service] User logged out")}).catch(i=>{console.error(i)})})}deleteToken(){this._authToken$&&(console.log("[Authentication Service] Deleting Authorization token"),localStorage.removeItem("authorization_token"),this._IsLoggedIn$.next(!1),this._authToken$.next(null))}setDeviceAccessToken(e){if(e){let i=JSON.parse(atob(e.split(".")[1])).exp,n={token:null,expiry:null,isDeviceAccessToken:!0};i===void 0?(n.token=e,console.log("[Authentication Service] Device Access Token received. Token Expiration: NEVER"),this._IsLoggedIn$.next(!1),this._authToken$.next(n),localStorage.setItem("authorization_token",JSON.stringify(n))):this.isTokenExpired(i)?console.log("[Authentication Service] Received expired Device Access Token from server"):(n.token=e,n.expiry=i,console.log("[Authentication Service] Device Access Token received. Token Expiration: "+this.getTokenExpirationDate(n.expiry)),this._IsLoggedIn$.next(!1),this._authToken$.next(n),localStorage.setItem("authorization_token",JSON.stringify(n)))}}ngOnDestroy(){this.connectionEndpointSubscription?.unsubscribe(),this.authTokenSubscription?.unsubscribe(),this.renewalTimerId&&(clearTimeout(this.renewalTimerId),this.renewalTimerId=null)}static \u0275fac=function(i){return new(i||t)};static \u0275prov=x({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var $a=typeof global=="object"&&global&&global.Object===Object&&global,Ot=$a;var Ha=typeof self=="object"&&self&&self.Object===Object&&self,Wa=Ot||Ha||Function("return this")(),S=Wa;var Ga=S.Symbol,H=Ga;var ji=Object.prototype,qa=ji.hasOwnProperty,Ka=ji.toString,ct=H?H.toStringTag:void 0;function za(t){var r=qa.call(t,ct),e=t[ct];try{t[ct]=void 0;var i=!0}catch(o){}var n=Ka.call(t);return i&&(r?t[ct]=e:delete t[ct]),n}var Bi=za;var Ja=Object.prototype,Za=Ja.toString;function Xa(t){return Za.call(t)}var Li=Xa;var Qa="[object Null]",Ya="[object Undefined]",$i=H?H.toStringTag:void 0;function es(t){return t==null?t===void 0?Ya:Qa:$i&&$i in Object(t)?Bi(t):Li(t)}var q=es;function ts(t){return t!=null&&typeof t=="object"}var T=ts;var rs=Array.isArray,W=rs;function is(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}var k=is;function ns(t){return t}var Pt=ns;var os="[object AsyncFunction]",as="[object Function]",ss="[object GeneratorFunction]",ls="[object Proxy]";function cs(t){if(!k(t))return!1;var r=q(t);return r==as||r==ss||r==os||r==ls}var Pe=cs;var us=S["__core-js_shared__"],Ft=us;var Hi=(function(){var t=/[^.]+$/.exec(Ft&&Ft.keys&&Ft.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function ds(t){return!!Hi&&Hi in t}var Wi=ds;var fs=Function.prototype,ps=fs.toString;function hs(t){if(t!=null){try{return ps.call(t)}catch(r){}try{return t+""}catch(r){}}return""}var oe=hs;var ms=/[\\^$.*+?()[\]{}|]/g,gs=/^\[object .+?Constructor\]$/,vs=Function.prototype,ys=Object.prototype,bs=vs.toString,_s=ys.hasOwnProperty,Cs=RegExp("^"+bs.call(_s).replace(ms,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ss(t){if(!k(t)||Wi(t))return!1;var r=Pe(t)?Cs:gs;return r.test(oe(t))}var Gi=Ss;function xs(t,r){return t?.[r]}var qi=xs;function ws(t,r){var e=qi(t,r);return Gi(e)?e:void 0}var U=ws;var As=U(S,"WeakMap"),Rt=As;var Ki=Object.create,Ts=(function(){function t(){}return function(r){if(!k(r))return{};if(Ki)return Ki(r);t.prototype=r;var e=new t;return t.prototype=void 0,e}})(),zi=Ts;function Ds(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}var Ji=Ds;function ks(t,r){var e=-1,i=t.length;for(r||(r=Array(i));++e<i;)r[e]=t[e];return r}var Nt=ks;var Ms=800,Vs=16,Es=Date.now;function Is(t){var r=0,e=0;return function(){var i=Es(),n=Vs-(i-e);if(e=i,n>0){if(++r>=Ms)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}var Zi=Is;function Os(t){return function(){return t}}var Xi=Os;var Ps=(function(){try{var t=U(Object,"defineProperty");return t({},"",{}),t}catch(r){}})(),Fe=Ps;var Fs=Fe?function(t,r){return Fe(t,"toString",{configurable:!0,enumerable:!1,value:Xi(r),writable:!0})}:Pt,Qi=Fs;var Rs=Zi(Qi),Yi=Rs;function Ns(t,r){for(var e=-1,i=t==null?0:t.length;++e<i&&r(t[e],e,t)!==!1;);return t}var en=Ns;var Us=9007199254740991,js=/^(?:0|[1-9]\d*)$/;function Bs(t,r){var e=typeof t;return r=r??Us,!!r&&(e=="number"||e!="symbol"&&js.test(t))&&t>-1&&t%1==0&&t<r}var Ut=Bs;function Ls(t,r,e){r=="__proto__"&&Fe?Fe(t,r,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[r]=e}var Re=Ls;function $s(t,r){return t===r||t!==t&&r!==r}var Y=$s;var Hs=Object.prototype,Ws=Hs.hasOwnProperty;function Gs(t,r,e){var i=t[r];(!(Ws.call(t,r)&&Y(i,e))||e===void 0&&!(r in t))&&Re(t,r,e)}var jt=Gs;function qs(t,r,e,i){var n=!e;e||(e={});for(var o=-1,a=r.length;++o<a;){var s=r[o],l=i?i(e[s],t[s],s,e,t):void 0;l===void 0&&(l=t[s]),n?Re(e,s,l):jt(e,s,l)}return e}var ee=qs;var tn=Math.max;function Ks(t,r,e){return r=tn(r===void 0?t.length-1:r,0),function(){for(var i=arguments,n=-1,o=tn(i.length-r,0),a=Array(o);++n<o;)a[n]=i[r+n];n=-1;for(var s=Array(r+1);++n<r;)s[n]=i[n];return s[r]=e(a),Ji(t,this,s)}}var rn=Ks;function zs(t,r){return Yi(rn(t,r,Pt),t+"")}var nn=zs;var Js=9007199254740991;function Zs(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Js}var Bt=Zs;function Xs(t){return t!=null&&Bt(t.length)&&!Pe(t)}var fe=Xs;function Qs(t,r,e){if(!k(e))return!1;var i=typeof r;return(i=="number"?fe(e)&&Ut(r,e.length):i=="string"&&r in e)?Y(e[r],t):!1}var on=Qs;function Ys(t){return nn(function(r,e){var i=-1,n=e.length,o=n>1?e[n-1]:void 0,a=n>2?e[2]:void 0;for(o=t.length>3&&typeof o=="function"?(n--,o):void 0,a&&on(e[0],e[1],a)&&(o=n<3?void 0:o,n=1),r=Object(r);++i<n;){var s=e[i];s&&t(r,s,i,o)}return r})}var an=Ys;var el=Object.prototype;function tl(t){var r=t&&t.constructor,e=typeof r=="function"&&r.prototype||el;return t===e}var Ne=tl;function rl(t,r){for(var e=-1,i=Array(t);++e<t;)i[e]=r(e);return i}var sn=rl;var il="[object Arguments]";function nl(t){return T(t)&&q(t)==il}var Fr=nl;var ln=Object.prototype,ol=ln.hasOwnProperty,al=ln.propertyIsEnumerable,sl=Fr((function(){return arguments})())?Fr:function(t){return T(t)&&ol.call(t,"callee")&&!al.call(t,"callee")},ut=sl;function ll(){return!1}var cn=ll;var fn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,un=fn&&typeof module=="object"&&module&&!module.nodeType&&module,cl=un&&un.exports===fn,dn=cl?S.Buffer:void 0,ul=dn?dn.isBuffer:void 0,dl=ul||cn,ae=dl;var fl="[object Arguments]",pl="[object Array]",hl="[object Boolean]",ml="[object Date]",gl="[object Error]",vl="[object Function]",yl="[object Map]",bl="[object Number]",_l="[object Object]",Cl="[object RegExp]",Sl="[object Set]",xl="[object String]",wl="[object WeakMap]",Al="[object ArrayBuffer]",Tl="[object DataView]",Dl="[object Float32Array]",kl="[object Float64Array]",Ml="[object Int8Array]",Vl="[object Int16Array]",El="[object Int32Array]",Il="[object Uint8Array]",Ol="[object Uint8ClampedArray]",Pl="[object Uint16Array]",Fl="[object Uint32Array]",y={};y[Dl]=y[kl]=y[Ml]=y[Vl]=y[El]=y[Il]=y[Ol]=y[Pl]=y[Fl]=!0;y[fl]=y[pl]=y[Al]=y[hl]=y[Tl]=y[ml]=y[gl]=y[vl]=y[yl]=y[bl]=y[_l]=y[Cl]=y[Sl]=y[xl]=y[wl]=!1;function Rl(t){return T(t)&&Bt(t.length)&&!!y[q(t)]}var pn=Rl;function Nl(t){return function(r){return t(r)}}var Ue=Nl;var hn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,dt=hn&&typeof module=="object"&&module&&!module.nodeType&&module,Ul=dt&&dt.exports===hn,Rr=Ul&&Ot.process,jl=(function(){try{var t=dt&&dt.require&&dt.require("util").types;return t||Rr&&Rr.binding&&Rr.binding("util")}catch(r){}})(),se=jl;var mn=se&&se.isTypedArray,Bl=mn?Ue(mn):pn,je=Bl;var Ll=Object.prototype,$l=Ll.hasOwnProperty;function Hl(t,r){var e=W(t),i=!e&&ut(t),n=!e&&!i&&ae(t),o=!e&&!i&&!n&&je(t),a=e||i||n||o,s=a?sn(t.length,String):[],l=s.length;for(var c in t)(r||$l.call(t,c))&&!(a&&(c=="length"||n&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Ut(c,l)))&&s.push(c);return s}var Lt=Hl;function Wl(t,r){return function(e){return t(r(e))}}var $t=Wl;var Gl=$t(Object.keys,Object),gn=Gl;var ql=Object.prototype,Kl=ql.hasOwnProperty;function zl(t){if(!Ne(t))return gn(t);var r=[];for(var e in Object(t))Kl.call(t,e)&&e!="constructor"&&r.push(e);return r}var vn=zl;function Jl(t){return fe(t)?Lt(t):vn(t)}var Be=Jl;function Zl(t){var r=[];if(t!=null)for(var e in Object(t))r.push(e);return r}var yn=Zl;var Xl=Object.prototype,Ql=Xl.hasOwnProperty;function Yl(t){if(!k(t))return yn(t);var r=Ne(t),e=[];for(var i in t)i=="constructor"&&(r||!Ql.call(t,i))||e.push(i);return e}var bn=Yl;function ec(t){return fe(t)?Lt(t,!0):bn(t)}var te=ec;var tc=U(Object,"create"),le=tc;function rc(){this.__data__=le?le(null):{},this.size=0}var _n=rc;function ic(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}var Cn=ic;var nc="__lodash_hash_undefined__",oc=Object.prototype,ac=oc.hasOwnProperty;function sc(t){var r=this.__data__;if(le){var e=r[t];return e===nc?void 0:e}return ac.call(r,t)?r[t]:void 0}var Sn=sc;var lc=Object.prototype,cc=lc.hasOwnProperty;function uc(t){var r=this.__data__;return le?r[t]!==void 0:cc.call(r,t)}var xn=uc;var dc="__lodash_hash_undefined__";function fc(t,r){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=le&&r===void 0?dc:r,this}var wn=fc;function Le(t){var r=-1,e=t==null?0:t.length;for(this.clear();++r<e;){var i=t[r];this.set(i[0],i[1])}}Le.prototype.clear=_n;Le.prototype.delete=Cn;Le.prototype.get=Sn;Le.prototype.has=xn;Le.prototype.set=wn;var Nr=Le;function pc(){this.__data__=[],this.size=0}var An=pc;function hc(t,r){for(var e=t.length;e--;)if(Y(t[e][0],r))return e;return-1}var pe=hc;var mc=Array.prototype,gc=mc.splice;function vc(t){var r=this.__data__,e=pe(r,t);if(e<0)return!1;var i=r.length-1;return e==i?r.pop():gc.call(r,e,1),--this.size,!0}var Tn=vc;function yc(t){var r=this.__data__,e=pe(r,t);return e<0?void 0:r[e][1]}var Dn=yc;function bc(t){return pe(this.__data__,t)>-1}var kn=bc;function _c(t,r){var e=this.__data__,i=pe(e,t);return i<0?(++this.size,e.push([t,r])):e[i][1]=r,this}var Mn=_c;function $e(t){var r=-1,e=t==null?0:t.length;for(this.clear();++r<e;){var i=t[r];this.set(i[0],i[1])}}$e.prototype.clear=An;$e.prototype.delete=Tn;$e.prototype.get=Dn;$e.prototype.has=kn;$e.prototype.set=Mn;var he=$e;var Cc=U(S,"Map"),me=Cc;function Sc(){this.size=0,this.__data__={hash:new Nr,map:new(me||he),string:new Nr}}var Vn=Sc;function xc(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}var En=xc;function wc(t,r){var e=t.__data__;return En(r)?e[typeof r=="string"?"string":"hash"]:e.map}var ge=wc;function Ac(t){var r=ge(this,t).delete(t);return this.size-=r?1:0,r}var In=Ac;function Tc(t){return ge(this,t).get(t)}var On=Tc;function Dc(t){return ge(this,t).has(t)}var Pn=Dc;function kc(t,r){var e=ge(this,t),i=e.size;return e.set(t,r),this.size+=e.size==i?0:1,this}var Fn=kc;function He(t){var r=-1,e=t==null?0:t.length;for(this.clear();++r<e;){var i=t[r];this.set(i[0],i[1])}}He.prototype.clear=Vn;He.prototype.delete=In;He.prototype.get=On;He.prototype.has=Pn;He.prototype.set=Fn;var Ht=He;function Mc(t,r){for(var e=-1,i=r.length,n=t.length;++e<i;)t[n+e]=r[e];return t}var Wt=Mc;var Vc=$t(Object.getPrototypeOf,Object),We=Vc;var Ec="[object Object]",Ic=Function.prototype,Oc=Object.prototype,Rn=Ic.toString,Pc=Oc.hasOwnProperty,Fc=Rn.call(Object);function Rc(t){if(!T(t)||q(t)!=Ec)return!1;var r=We(t);if(r===null)return!0;var e=Pc.call(r,"constructor")&&r.constructor;return typeof e=="function"&&e instanceof e&&Rn.call(e)==Fc}var Nn=Rc;function Nc(){this.__data__=new he,this.size=0}var Un=Nc;function Uc(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e}var jn=Uc;function jc(t){return this.__data__.get(t)}var Bn=jc;function Bc(t){return this.__data__.has(t)}var Ln=Bc;var Lc=200;function $c(t,r){var e=this.__data__;if(e instanceof he){var i=e.__data__;if(!me||i.length<Lc-1)return i.push([t,r]),this.size=++e.size,this;e=this.__data__=new Ht(i)}return e.set(t,r),this.size=e.size,this}var $n=$c;function Ge(t){var r=this.__data__=new he(t);this.size=r.size}Ge.prototype.clear=Un;Ge.prototype.delete=jn;Ge.prototype.get=Bn;Ge.prototype.has=Ln;Ge.prototype.set=$n;var ve=Ge;function Hc(t,r){return t&&ee(r,Be(r),t)}var Hn=Hc;function Wc(t,r){return t&&ee(r,te(r),t)}var Wn=Wc;var zn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gn=zn&&typeof module=="object"&&module&&!module.nodeType&&module,Gc=Gn&&Gn.exports===zn,qn=Gc?S.Buffer:void 0,Kn=qn?qn.allocUnsafe:void 0;function qc(t,r){if(r)return t.slice();var e=t.length,i=Kn?Kn(e):new t.constructor(e);return t.copy(i),i}var Gt=qc;function Kc(t,r){for(var e=-1,i=t==null?0:t.length,n=0,o=[];++e<i;){var a=t[e];r(a,e,t)&&(o[n++]=a)}return o}var Jn=Kc;function zc(){return[]}var qt=zc;var Jc=Object.prototype,Zc=Jc.propertyIsEnumerable,Zn=Object.getOwnPropertySymbols,Xc=Zn?function(t){return t==null?[]:(t=Object(t),Jn(Zn(t),function(r){return Zc.call(t,r)}))}:qt,qe=Xc;function Qc(t,r){return ee(t,qe(t),r)}var Xn=Qc;var Yc=Object.getOwnPropertySymbols,eu=Yc?function(t){for(var r=[];t;)Wt(r,qe(t)),t=We(t);return r}:qt,Kt=eu;function tu(t,r){return ee(t,Kt(t),r)}var Qn=tu;function ru(t,r,e){var i=r(t);return W(t)?i:Wt(i,e(t))}var zt=ru;function iu(t){return zt(t,Be,qe)}var ft=iu;function nu(t){return zt(t,te,Kt)}var Yn=nu;var ou=U(S,"DataView"),Jt=ou;var au=U(S,"Promise"),Zt=au;var su=U(S,"Set"),Xt=su;var eo="[object Map]",lu="[object Object]",to="[object Promise]",ro="[object Set]",io="[object WeakMap]",no="[object DataView]",cu=oe(Jt),uu=oe(me),du=oe(Zt),fu=oe(Xt),pu=oe(Rt),xe=q;(Jt&&xe(new Jt(new ArrayBuffer(1)))!=no||me&&xe(new me)!=eo||Zt&&xe(Zt.resolve())!=to||Xt&&xe(new Xt)!=ro||Rt&&xe(new Rt)!=io)&&(xe=function(t){var r=q(t),e=r==lu?t.constructor:void 0,i=e?oe(e):"";if(i)switch(i){case cu:return no;case uu:return eo;case du:return to;case fu:return ro;case pu:return io}return r});var ce=xe;var hu=Object.prototype,mu=hu.hasOwnProperty;function gu(t){var r=t.length,e=new t.constructor(r);return r&&typeof t[0]=="string"&&mu.call(t,"index")&&(e.index=t.index,e.input=t.input),e}var oo=gu;var vu=S.Uint8Array,Ke=vu;function yu(t){var r=new t.constructor(t.byteLength);return new Ke(r).set(new Ke(t)),r}var ze=yu;function bu(t,r){var e=r?ze(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}var ao=bu;var _u=/\w*$/;function Cu(t){var r=new t.constructor(t.source,_u.exec(t));return r.lastIndex=t.lastIndex,r}var so=Cu;var lo=H?H.prototype:void 0,co=lo?lo.valueOf:void 0;function Su(t){return co?Object(co.call(t)):{}}var uo=Su;function xu(t,r){var e=r?ze(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}var Qt=xu;var wu="[object Boolean]",Au="[object Date]",Tu="[object Map]",Du="[object Number]",ku="[object RegExp]",Mu="[object Set]",Vu="[object String]",Eu="[object Symbol]",Iu="[object ArrayBuffer]",Ou="[object DataView]",Pu="[object Float32Array]",Fu="[object Float64Array]",Ru="[object Int8Array]",Nu="[object Int16Array]",Uu="[object Int32Array]",ju="[object Uint8Array]",Bu="[object Uint8ClampedArray]",Lu="[object Uint16Array]",$u="[object Uint32Array]";function Hu(t,r,e){var i=t.constructor;switch(r){case Iu:return ze(t);case wu:case Au:return new i(+t);case Ou:return ao(t,e);case Pu:case Fu:case Ru:case Nu:case Uu:case ju:case Bu:case Lu:case $u:return Qt(t,e);case Tu:return new i;case Du:case Vu:return new i(t);case ku:return so(t);case Mu:return new i;case Eu:return uo(t)}}var fo=Hu;function Wu(t){return typeof t.constructor=="function"&&!Ne(t)?zi(We(t)):{}}var Yt=Wu;var Gu="[object Map]";function qu(t){return T(t)&&ce(t)==Gu}var po=qu;var ho=se&&se.isMap,Ku=ho?Ue(ho):po,mo=Ku;var zu="[object Set]";function Ju(t){return T(t)&&ce(t)==zu}var go=Ju;var vo=se&&se.isSet,Zu=vo?Ue(vo):go,yo=Zu;var Xu=1,Qu=2,Yu=4,bo="[object Arguments]",ed="[object Array]",td="[object Boolean]",rd="[object Date]",id="[object Error]",_o="[object Function]",nd="[object GeneratorFunction]",od="[object Map]",ad="[object Number]",Co="[object Object]",sd="[object RegExp]",ld="[object Set]",cd="[object String]",ud="[object Symbol]",dd="[object WeakMap]",fd="[object ArrayBuffer]",pd="[object DataView]",hd="[object Float32Array]",md="[object Float64Array]",gd="[object Int8Array]",vd="[object Int16Array]",yd="[object Int32Array]",bd="[object Uint8Array]",_d="[object Uint8ClampedArray]",Cd="[object Uint16Array]",Sd="[object Uint32Array]",g={};g[bo]=g[ed]=g[fd]=g[pd]=g[td]=g[rd]=g[hd]=g[md]=g[gd]=g[vd]=g[yd]=g[od]=g[ad]=g[Co]=g[sd]=g[ld]=g[cd]=g[ud]=g[bd]=g[_d]=g[Cd]=g[Sd]=!0;g[id]=g[_o]=g[dd]=!1;function er(t,r,e,i,n,o){var a,s=r&Xu,l=r&Qu,c=r&Yu;if(e&&(a=n?e(t,i,n,o):e(t)),a!==void 0)return a;if(!k(t))return t;var u=W(t);if(u){if(a=oo(t),!s)return Nt(t,a)}else{var h=ce(t),b=h==_o||h==nd;if(ae(t))return Gt(t,s);if(h==Co||h==bo||b&&!n){if(a=l||b?{}:Yt(t),!s)return l?Qn(t,Wn(a,t)):Xn(t,Hn(a,t))}else{if(!g[h])return n?t:{};a=fo(t,h,s)}}o||(o=new ve);var D=o.get(t);if(D)return D;o.set(t,a),yo(t)?t.forEach(function(A){a.add(er(A,r,e,A,t,o))}):mo(t)&&t.forEach(function(A,M){a.set(M,er(A,r,e,M,t,o))});var w=c?l?Yn:ft:l?te:Be,E=u?void 0:w(t);return en(E||t,function(A,M){E&&(M=A,A=t[M]),jt(a,M,er(A,r,e,M,t,o))}),a}var So=er;var xd=1,wd=4;function Ad(t){return So(t,xd|wd)}var tr=Ad;var Td="__lodash_hash_undefined__";function Dd(t){return this.__data__.set(t,Td),this}var xo=Dd;function kd(t){return this.__data__.has(t)}var wo=kd;function rr(t){var r=-1,e=t==null?0:t.length;for(this.__data__=new Ht;++r<e;)this.add(t[r])}rr.prototype.add=rr.prototype.push=xo;rr.prototype.has=wo;var Ao=rr;function Md(t,r){for(var e=-1,i=t==null?0:t.length;++e<i;)if(r(t[e],e,t))return!0;return!1}var To=Md;function Vd(t,r){return t.has(r)}var Do=Vd;var Ed=1,Id=2;function Od(t,r,e,i,n,o){var a=e&Ed,s=t.length,l=r.length;if(s!=l&&!(a&&l>s))return!1;var c=o.get(t),u=o.get(r);if(c&&u)return c==r&&u==t;var h=-1,b=!0,D=e&Id?new Ao:void 0;for(o.set(t,r),o.set(r,t);++h<s;){var w=t[h],E=r[h];if(i)var A=a?i(E,w,h,r,t,o):i(w,E,h,t,r,o);if(A!==void 0){if(A)continue;b=!1;break}if(D){if(!To(r,function(M,_e){if(!Do(D,_e)&&(w===M||n(w,M,e,i,o)))return D.push(_e)})){b=!1;break}}else if(!(w===E||n(w,E,e,i,o))){b=!1;break}}return o.delete(t),o.delete(r),b}var ir=Od;function Pd(t){var r=-1,e=Array(t.size);return t.forEach(function(i,n){e[++r]=[n,i]}),e}var ko=Pd;function Fd(t){var r=-1,e=Array(t.size);return t.forEach(function(i){e[++r]=i}),e}var Mo=Fd;var Rd=1,Nd=2,Ud="[object Boolean]",jd="[object Date]",Bd="[object Error]",Ld="[object Map]",$d="[object Number]",Hd="[object RegExp]",Wd="[object Set]",Gd="[object String]",qd="[object Symbol]",Kd="[object ArrayBuffer]",zd="[object DataView]",Vo=H?H.prototype:void 0,Ur=Vo?Vo.valueOf:void 0;function Jd(t,r,e,i,n,o,a){switch(e){case zd:if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case Kd:return!(t.byteLength!=r.byteLength||!o(new Ke(t),new Ke(r)));case Ud:case jd:case $d:return Y(+t,+r);case Bd:return t.name==r.name&&t.message==r.message;case Hd:case Gd:return t==r+"";case Ld:var s=ko;case Wd:var l=i&Rd;if(s||(s=Mo),t.size!=r.size&&!l)return!1;var c=a.get(t);if(c)return c==r;i|=Nd,a.set(t,r);var u=ir(s(t),s(r),i,n,o,a);return a.delete(t),u;case qd:if(Ur)return Ur.call(t)==Ur.call(r)}return!1}var Eo=Jd;var Zd=1,Xd=Object.prototype,Qd=Xd.hasOwnProperty;function Yd(t,r,e,i,n,o){var a=e&Zd,s=ft(t),l=s.length,c=ft(r),u=c.length;if(l!=u&&!a)return!1;for(var h=l;h--;){var b=s[h];if(!(a?b in r:Qd.call(r,b)))return!1}var D=o.get(t),w=o.get(r);if(D&&w)return D==r&&w==t;var E=!0;o.set(t,r),o.set(r,t);for(var A=a;++h<l;){b=s[h];var M=t[b],_e=r[b];if(i)var ai=a?i(_e,M,b,r,t,o):i(M,_e,b,t,r,o);if(!(ai===void 0?M===_e||n(M,_e,e,i,o):ai)){E=!1;break}A||(A=b=="constructor")}if(E&&!A){var At=t.constructor,Tt=r.constructor;At!=Tt&&"constructor"in t&&"constructor"in r&&!(typeof At=="function"&&At instanceof At&&typeof Tt=="function"&&Tt instanceof Tt)&&(E=!1)}return o.delete(t),o.delete(r),E}var Io=Yd;var ef=1,Oo="[object Arguments]",Po="[object Array]",nr="[object Object]",tf=Object.prototype,Fo=tf.hasOwnProperty;function rf(t,r,e,i,n,o){var a=W(t),s=W(r),l=a?Po:ce(t),c=s?Po:ce(r);l=l==Oo?nr:l,c=c==Oo?nr:c;var u=l==nr,h=c==nr,b=l==c;if(b&&ae(t)){if(!ae(r))return!1;a=!0,u=!1}if(b&&!u)return o||(o=new ve),a||je(t)?ir(t,r,e,i,n,o):Eo(t,r,l,e,i,n,o);if(!(e&ef)){var D=u&&Fo.call(t,"__wrapped__"),w=h&&Fo.call(r,"__wrapped__");if(D||w){var E=D?t.value():t,A=w?r.value():r;return o||(o=new ve),n(E,A,e,i,o)}}return b?(o||(o=new ve),Io(t,r,e,i,n,o)):!1}var Ro=rf;function No(t,r,e,i,n){return t===r?!0:t==null||r==null||!T(t)&&!T(r)?t!==t&&r!==r:Ro(t,r,e,i,No,n)}var Uo=No;function nf(t){return function(r,e,i){for(var n=-1,o=Object(r),a=i(r),s=a.length;s--;){var l=a[t?s:++n];if(e(o[l],l,o)===!1)break}return r}}var jo=nf;var of=jo(),Bo=of;function af(t,r,e){(e!==void 0&&!Y(t[r],e)||e===void 0&&!(r in t))&&Re(t,r,e)}var pt=af;function sf(t){return T(t)&&fe(t)}var Lo=sf;function lf(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}var ht=lf;function cf(t){return ee(t,te(t))}var $o=cf;function uf(t,r,e,i,n,o,a){var s=ht(t,e),l=ht(r,e),c=a.get(l);if(c){pt(t,e,c);return}var u=o?o(s,l,e+"",t,r,a):void 0,h=u===void 0;if(h){var b=W(l),D=!b&&ae(l),w=!b&&!D&&je(l);u=l,b||D||w?W(s)?u=s:Lo(s)?u=Nt(s):D?(h=!1,u=Gt(l,!0)):w?(h=!1,u=Qt(l,!0)):u=[]:Nn(l)||ut(l)?(u=s,ut(s)?u=$o(s):(!k(s)||Pe(s))&&(u=Yt(l))):h=!1}h&&(a.set(l,u),n(u,l,i,o,a),a.delete(l)),pt(t,e,u)}var Ho=uf;function Wo(t,r,e,i,n){t!==r&&Bo(r,function(o,a){if(n||(n=new ve),k(o))Ho(t,r,a,e,Wo,i,n);else{var s=i?i(ht(t,a),o,a+"",t,r,n):void 0;s===void 0&&(s=o),pt(t,a,s)}},te)}var Go=Wo;function df(t,r){return Uo(t,r)}var ff=df;var pf=an(function(t,r,e){Go(t,r,e)}),hf=pf;var mf=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,jr=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let r=t.match(mf);if(!r)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return r.shift(),r},qo=t=>t==="*"||t==="x"||t==="X",Ko=t=>{let r=parseInt(t,10);return isNaN(r)?t:r},gf=(t,r)=>typeof t!=typeof r?[String(t),String(r)]:[t,r],vf=(t,r)=>{if(qo(t)||qo(r))return 0;let[e,i]=gf(Ko(t),Ko(r));return e>i?1:e<i?-1:0},Br=(t,r)=>{for(let e=0;e<Math.max(t.length,r.length);e++){let i=vf(t[e]||"0",r[e]||"0");if(i!==0)return i}return 0};var zo=(t,r)=>{let e=jr(t),i=jr(r),n=e.pop(),o=i.pop(),a=Br(e,i);return a!==0?a:n&&o?Br(n.split("."),o.split(".")):n||o?n?-1:1:0};var mt=(t,r,e)=>{yf(e);let i=zo(t,r);return Zo[e].includes(i)},Zo={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},Jo=Object.keys(Zo),yf=t=>{if(typeof t!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof t}`);if(Jo.indexOf(t)===-1)throw new Error(`Invalid operator, expected one of ${Jo.join("|")}`)};var Xo=(()=>{class t{server=f(Oe);http=f(Ie);_auth=f(Ui);serverEndpoint=null;isAppDataSupported=!1;configFileVersion=null;sharedConfigName;InitConfig=null;_isRemoteContextBootstrapped=!1;storageServiceReady$=new v(!1);_isLoggedIn=!1;_networkStatus=void 0;_logIO=!1;patchQueue$=new G;patch=function(e){return this.http.post(e.url,e.document).pipe(pi(()=>console.log("[Storage Service] Remote config patch request completed successfully")),De(i=>this.handleError(i)))};constructor(){let e=this.server;this._auth.isLoggedIn$.pipe(lt()).subscribe(i=>{this._isLoggedIn=i,this.isStorageServiceReady()}),e.serverServiceEndpoint$.pipe(lt()).subscribe(i=>{this._networkStatus=i,this.isStorageServiceReady()}),e.serverVersion$.pipe(lt()).subscribe(i=>{i&&(this.isAppDataSupported=mt(i,"1.27.0",">="))}),this.patchQueue$.pipe(ui(i=>this.patch(i)),lt()).subscribe(()=>{})}isStorageServiceReady(){this._networkStatus?.httpServiceUrl&&(this.serverEndpoint=this._networkStatus.httpServiceUrl.substring(0,this._networkStatus.httpServiceUrl.length-4)+"applicationData/"),this._networkStatus?.operation===2&&this._isLoggedIn&&this.serverEndpoint?(this.storageServiceReady$.next(!0),console.log(`[Remote Storage Service] Authenticated ${this._isLoggedIn}, AppData API: ${this.serverEndpoint}`)):this.storageServiceReady$.next(!1)}waitUntilReady(e=1e4){return I(this,null,function*(){return this.storageServiceReady$.getValue()?!0:new Promise(i=>{let n=!1,o=this.storageServiceReady$.subscribe(s=>{n||!s||(n=!0,clearTimeout(a),o.unsubscribe(),i(!0))}),a=window.setTimeout(()=>{n||(n=!0,o.unsubscribe(),i(!1))},e)})})}ensureReady(){if(!this.storageServiceReady$.getValue())throw new Error("[StorageService] Not ready: storageServiceReady is false")}listConfigs(e){return I(this,null,function*(){this.ensureReady();let i=[];if(!this.serverEndpoint)return console.warn("[Storage Service] No server endpoint set. Cannot retrieve config list"),null;let n=this.serverEndpoint,o=e??this.configFileVersion,a=`${n}global/kip/${o}/?keys=true`,s=`${n}user/kip/${o}/?keys=true`;try{let l=yield B(this.http.get(a));for(let c of l)i.push({scope:"global",name:c});console.log("[Storage Service] Retrieved Global config list")}catch(l){this.handleError(l)}try{let l=yield B(this.http.get(s));for(let c of l)i.push({scope:"user",name:c});console.log("[Storage Service] Retrieved User config list")}catch(l){this.handleError(l)}return i})}getConfig(e,i,n,o){return I(this,null,function*(){this.ensureReady();let a=this.serverEndpoint+e+"/kip/",s=n??this.configFileVersion,l=a+s+"/"+i;this._logIO&&console.debug("[StorageService.getConfig]",{scope:e,configName:i,ver:s,url:l,isInitLoad:!!o});try{let c=yield B(this.http.get(l));if(this._logIO){let u=c&&typeof c=="object"?c?.app?.configVersion:void 0;console.debug("[StorageService.getConfig Response]",{scope:e,configName:i,ver:s,appConfigVersion:u})}else console.log(`[Storage Service] Retrieved config [${i}] from [${e}] scope`);return o&&(this.InitConfig=c),tr(c)}catch(c){return this.handleError(c),null}})}setConfig(e,i,n,o){return I(this,null,function*(){this.ensureReady();let a=this.serverEndpoint+e+"/kip/",s=o??this.configFileVersion,l=a+s+"/"+i;if(this._logIO){let c=n?.app?.configVersion;console.debug("[StorageService.setConfig]",{scope:e,configName:i,ver:s,url:l,appConfigVersion:c})}try{return yield B(this.http.post(l,n)),this._logIO?console.debug("[StorageService.setConfig Response]",{scope:e,configName:i,ver:s,url:l,status:"ok"}):console.log(`[Storage Service] Saved config [${i}] to [${e}] scope`),null}catch(c){return this.handleError(c),null}})}patchConfig(e,i,n){this.ensureReady();let o=n??this.configFileVersion,a=this.serverEndpoint+"user/kip/"+o,s,l=i?.configVersion;switch(this._logIO&&console.warn("[StorageService.patchConfig] Suppressing app.configVersion write into v11 file",{targetFileVersion:o,incomingAppConfigVersion:l}),e){case"IAppConfig":s=[{op:"replace",path:`/${this.sharedConfigName}/app`,value:i}];break;case"IThemeConfig":s=[{op:"replace",path:`/${this.sharedConfigName}/theme/themeName`,value:i.themeName}];break;case"IWidgetConfig":s=[{op:"replace",path:`/${this.sharedConfigName}/widget`,value:i}];break;case"ILayoutConfig":s=[{op:"replace",path:`/${this.sharedConfigName}/layout`,value:i}];break;case"Dashboards":s=[{op:"replace",path:`/${this.sharedConfigName}/dashboards`,value:i}];break;case"Array<IUnitDefaults>":s=[{op:"replace",path:`/${this.sharedConfigName}/app/unitDefaults`,value:i}];break;case"Array<IDatasetDef>":s=[{op:"replace",path:`/${this.sharedConfigName}/app/dataSets`,value:i}];break;case"INotificationConfig":s=[{op:"replace",path:`/${this.sharedConfigName}/app/notificationConfig`,value:i}];break;default:console.warn("[Storage Service] JSON Patch request type unknown");break}let c={url:a,document:s};if(this._logIO){let u=e==="IAppConfig"?i?.configVersion:void 0;console.debug("[StorageService.patchConfig]",{ObjType:e,ver:o,url:a,appConfigVersionInValue:u,touchesConfigVersion:e==="IAppConfig"&&typeof u<"u"})}this.patchQueue$.next(c)}patchGlobal(e,i,n,o,a){this.ensureReady();let s=a??this.configFileVersion,l=this.serverEndpoint+i+"/kip/"+s,c;switch(o){case"add":c=[{op:"add",path:`/${e}`,value:n}];break;case"replace":c=[{op:"replace",path:`/${e}`,value:n}];break;case"remove":c=[{op:"remove",path:`/${e}`,value:n}];break;default:console.warn("[Storage Service] JSON Patch operation request type unknown");break}let u={url:l,document:c};if(this._logIO){let h=n?.app?.configVersion;console.debug("[StorageService.patchGlobal]",{scope:i,configName:e,operation:o,ver:s,url:l,appConfigVersionInValue:h})}this.patchQueue$.next(u)}removeItem(e,i,n){this.ensureReady();let o=this.serverEndpoint+e+"/kip/"+this.configFileVersion;n&&(o=this.serverEndpoint+e+"/kip/"+n);let a=[{op:"remove",path:`/${i}`}],s={url:o,document:a};this.patchQueue$.next(s)}clear(){this.ensureReady()}set activeConfigFileVersion(e){this.configFileVersion=e}bootstrapRemoteContext(e){if(!e?.sharedConfigName||e.configFileVersion==null||!e.initConfig)throw new Error("[StorageService] Invalid remote bootstrap context");this.sharedConfigName=e.sharedConfigName,this.configFileVersion=e.configFileVersion,this.InitConfig=tr(e.initConfig),this._isRemoteContextBootstrapped=!0,console.log(`[Storage Service] Bootstrap handoff applied (sharedConfig=${this.sharedConfigName}, fileVersion=${this.configFileVersion})`)}isRemoteContextBootstrapped(){return this._isRemoteContextBootstrapped}handleError(e){throw e.status===0?console.error("[Storage Service] An error occurred:",e.error):console.error("[Storage Service] Backend returned error: ",e.message),e}get initConfig(){return this.InitConfig}static \u0275fac=function(i){return new(i||t)};static \u0275prov=x({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var ye=class{static create(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let e=Math.random()*16|0;return(r=="x"?e:e&3|8).toString(16)})}};var gt={disableNotifications:!1,menuGrouping:!0,security:{disableSecurity:!0},devices:{disableDevices:!1,showNormalState:!1,showNominalState:!1},sound:{disableSound:!1,muteNormal:!0,muteNominal:!0,muteWarn:!0,muteAlert:!1,muteAlarm:!1,muteEmergency:!1}};var or={Unitless:"unitless",Speed:"knots",Flow:"l/h",Temperature:"celsius",Length:"m",Volume:"liter",Current:"A",Potential:"V",Charge:"C",Power:"W",Energy:"J",Pressure:"mmHg","Fuel Distance":"nm/l","Energy Distance":"nm/kWh",Density:"kg/m3",Time:"Hours","Angular Velocity":"deg/min",Angle:"deg",Frequency:"Hz",Ratio:"ratio",Resistance:"ohm"};var Qo={configVersion:12,autoNightMode:!0,redNightMode:!1,nightModeBrightness:.27,isRemoteControl:!1,instanceName:"",dataSets:[],unitDefault