New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@therms/rpc-client

Package Overview
Dependencies
Maintainers
7
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@therms/rpc-client - npm Package Compare versions

Comparing version 2.3.1 to 2.4.0

dist/utils/cache-utils.d.ts

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# [2.4.0](http://bitbucket.org/thermsio/rpc-client-ts/compare/v2.3.1...v2.4.0) (2022-03-25)
### Features
* subscribe to RPC responses events ([20f4bee](http://bitbucket.org/thermsio/rpc-client-ts/commits/20f4beec499f39f212b5a842eb582b4367b827f3))
## [2.3.1](http://bitbucket.org/thermsio/rpc-client-ts/compare/v2.3.0...v2.3.1) (2022-03-14)

@@ -2,0 +9,0 @@

2

dist/cache/InMemoryCache.js
import LRU from 'lru-cache';
import { makeCallRequestKey } from './utils/cache-utils.js';
import { makeCallRequestKey } from '../utils/cache-utils.js';
import { GetDebugLogger } from '../utils/debug-logger.js';

@@ -4,0 +4,0 @@

@@ -142,18 +142,5 @@ 'use strict';

const makeCallRequestKey = (request) => {
const strippedCallRequest = {
args: request.args,
procedure: request.procedure,
scope: request.scope,
version: request.version,
};
let key;
if (Array.isArray(strippedCallRequest) ||
typeof strippedCallRequest === 'object') {
key = stringify__default["default"](sortKeys(strippedCallRequest, { deep: true }));
}
else {
console.warn('makeCallRequestKey() was not passed a CallRequestDTO', request);
throw new Error('makeCallRequestKey() was not passed a CallRequestDTO');
}
return key;
if (!request.args)
return `${request.scope}${request.procedure}${request.version}`;
return `${request.scope}${request.procedure}${request.version}${stringify__default["default"](sortKeys(request.args || {}, { deep: true }))}`;
};

@@ -647,2 +634,28 @@

class Vent {
constructor() {
this.events = {};
this.publish = (topic, data) => __awaiter(this, void 0, void 0, function* () {
const handlers = this.events[topic];
if (!handlers)
return;
handlers.forEach(function (handler) {
handler.call(handler, data);
});
});
this.subscribe = (topic, handler) => {
if (!this.events[topic]) {
this.events[topic] = [];
}
this.events[topic].push(handler);
};
this.unsubscribe = (topic, handler) => {
if (!this.events[topic])
return;
let handlerIdx = this.events[topic].indexOf(handler);
this.events[topic].splice(handlerIdx);
};
}
}
const ERRORS = {

@@ -656,2 +669,3 @@ HTTP_HOST_OR_TRANSPORT_REQUIRED: `http host or tansport is required`,

this.options = options;
this.vent = new Vent();
this.call = (request, args) => __awaiter(this, void 0, void 0, function* () {

@@ -679,2 +693,4 @@ if (!request)

}
const callRequestKey = makeCallRequestKey(req);
this.vent.publish(callRequestKey, callResponse === null || callResponse === void 0 ? void 0 : callResponse.data);
return callResponse;

@@ -773,2 +789,16 @@ });

}
subscribe(filter, handler) {
const request = typeof filter.request === 'string'
? parseRequestShorthand(filter.request)
: filter.request;
const callRequestKey = makeCallRequestKey(Object.assign(Object.assign({}, request), { args: filter.args }));
this.vent.subscribe(callRequestKey, handler);
}
unsubscribe(filter, handler) {
const request = typeof filter.request === 'string'
? parseRequestShorthand(filter.request)
: filter.request;
const callRequestKey = makeCallRequestKey(Object.assign(Object.assign({}, request), { args: filter.args }));
this.vent.unsubscribe(callRequestKey, handler);
}
}

@@ -775,0 +805,0 @@ RPCClient.DEFAULT_DEADLINE_MS = 10000;

@@ -5,3 +5,3 @@ import { __awaiter } from '../node_modules/tslib/tslib.es6.js';

import { ManagerCallRequestTimeoutError } from './errors/ManagerCallRequestTimeoutError.js';
import { makeCallRequestKey } from '../cache/utils/cache-utils.js';
import { makeCallRequestKey } from '../utils/cache-utils.js';
import { cloneDeep } from 'lodash-es';

@@ -8,0 +8,0 @@ import { GetDebugLogger } from '../utils/debug-logger.js';

@@ -18,2 +18,10 @@ import { CallRequestDTO } from './CallRequestDTO';

setIdentity(identity?: RPCClientIdentity): void;
subscribe(filter: {
request: CallRequestDTO | string;
args?: any;
}, handler: (response: CallResponseDTO) => void): void;
unsubscribe(filter: {
request: CallRequestDTO | string;
args?: any;
}, handler: (response: CallResponseDTO) => void): void;
}

@@ -43,2 +51,3 @@ export interface RPCClientOptions {

private readonly webSocketTransport?;
private vent;
constructor(options: RPCClientOptions);

@@ -45,0 +54,0 @@ call: <Args = any, Data = any>(request: string | CallRequestDTO<Args>, args?: Args | undefined) => Promise<CallResponseDTO<Data>>;

@@ -10,2 +10,4 @@ import { __awaiter } from './node_modules/tslib/tslib.es6.js';

import { parseRequestShorthand } from './utils/request.js';
import { Vent } from './utils/vent.js';
import { makeCallRequestKey } from './utils/cache-utils.js';

@@ -20,2 +22,3 @@ const ERRORS = {

this.options = options;
this.vent = new Vent();
this.call = (request, args) => __awaiter(this, void 0, void 0, function* () {

@@ -43,2 +46,4 @@ if (!request)

}
const callRequestKey = makeCallRequestKey(req);
this.vent.publish(callRequestKey, callResponse === null || callResponse === void 0 ? void 0 : callResponse.data);
return callResponse;

@@ -137,2 +142,16 @@ });

}
subscribe(filter, handler) {
const request = typeof filter.request === 'string'
? parseRequestShorthand(filter.request)
: filter.request;
const callRequestKey = makeCallRequestKey(Object.assign(Object.assign({}, request), { args: filter.args }));
this.vent.subscribe(callRequestKey, handler);
}
unsubscribe(filter, handler) {
const request = typeof filter.request === 'string'
? parseRequestShorthand(filter.request)
: filter.request;
const callRequestKey = makeCallRequestKey(Object.assign(Object.assign({}, request), { args: filter.args }));
this.vent.unsubscribe(callRequestKey, handler);
}
}

@@ -139,0 +158,0 @@ RPCClient.DEFAULT_DEADLINE_MS = 10000;

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RPCClient={})}(this,(function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function e(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))}class r{constructor(t){const{args:e,correlationId:r,identity:n,procedure:o,scope:i,version:s}=t;if(this.args=e,r&&"string"!=typeof r)throw new Error("correlationId must be a string");if(this.correlationId=r||Math.random().toString(),n){if("object"!=typeof n)throw new Error("identity must be an object");if(n.authorization&&"string"!=typeof n.authorization)throw new Error("identity.authorization must be a string");if(n.deviceName&&"string"!=typeof n.deviceName)throw new Error("identity.deviceName must be a string");if(n.metadata&&"object"!=typeof n.metadata)throw new Error("identity.metadata must be a object");this.identity=n}if(o&&"string"!=typeof o)throw new Error("procedure must be string");if(this.procedure=o,i&&"string"!=typeof i)throw new Error("scope must be string");if(this.scope=i,s&&"string"!=typeof s)throw new Error("version must be string");this.version=s}}class n extends Error{}class o extends Error{}class i extends Error{}function s(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const a=t=>{const e={args:t.args,procedure:t.procedure,scope:t.scope,version:t.version};let r;if(!Array.isArray(e)&&"object"!=typeof e)throw console.warn("makeCallRequestKey() was not passed a CallRequestDTO",t),new Error("makeCallRequestKey() was not passed a CallRequestDTO");return r=function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var r,n="boolean"==typeof e.cycles&&e.cycles,o=e.cmp&&(r=e.cmp,function(t){return function(e,n){var o={key:e,value:t[e]},i={key:n,value:t[n]};return r(o,i)}}),i=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return JSON.stringify(e);var r,s;if(Array.isArray(e)){for(s="[",r=0;r<e.length;r++)r&&(s+=","),s+=t(e[r])||"null";return s+"]"}if(null===e)return"null";if(-1!==i.indexOf(e)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=i.push(e)-1,c=Object.keys(e).sort(o&&o(e));for(s="",r=0;r<c.length;r++){var h=c[r],u=t(e[h]);u&&(s&&(s+=","),s+=JSON.stringify(h)+":"+u)}return i.splice(a,1),"{"+s+"}"}}(t)}(function(t,e={}){if(!s(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:r,compare:n}=e,o=[],i=[],a=t=>{const e=o.indexOf(t);if(-1!==e)return i[e];const r=[];return o.push(t),i.push(r),r.push(...t.map((t=>Array.isArray(t)?a(t):s(t)?c(t):t))),r},c=t=>{const e=o.indexOf(t);if(-1!==e)return i[e];const h={},u=Object.keys(t).sort(n);o.push(t),i.push(h);for(const e of u){const n=t[e];let o;o=r&&Array.isArray(n)?a(n):r&&s(n)?c(n):n,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:o}))}return h};return Array.isArray(t)?r?a(t):t.slice():c(t)}(e,{deep:!0})),r};var c="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,u=c||h||Function("return this")(),l=u.Symbol,p=Object.prototype,f=p.hasOwnProperty,d=p.toString,y=l?l.toStringTag:void 0;var v=Object.prototype.toString;var g=l?l.toStringTag:void 0;function b(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=f.call(t,y),r=t[y];try{t[y]=void 0;var n=!0}catch(t){}var o=d.call(t);return n&&(e?t[y]=r:delete t[y]),o}(t):function(t){return v.call(t)}(t)}function m(t){return null!=t&&"object"==typeof t}var w=Array.isArray;function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function _(t){return t}function C(t){if(!j(t))return!1;var e=b(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var O,A=u["__core-js_shared__"],S=(O=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"";var E=Function.prototype.toString;function R(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var T=/^\[object .+?Constructor\]$/,I=Function.prototype,x=Object.prototype,k=I.toString,P=x.hasOwnProperty,M=RegExp("^"+k.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function F(t){return!(!j(t)||(e=t,S&&S in e))&&(C(t)?M:T).test(R(t));var e}function q(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return F(r)?r:void 0}var N=q(u,"WeakMap"),U=Object.create,D=function(){function t(){}return function(e){if(!j(e))return{};if(U)return U(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function W(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function B(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var z=Date.now;var L,J,$,H=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),K=H,G=K?function(t,e){return K(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:_,X=(L=G,J=0,$=0,function(){var t=z(),e=16-(t-$);if($=t,e>0){if(++J>=800)return arguments[0]}else J=0;return L.apply(void 0,arguments)}),V=X;var Z=/^(?:0|[1-9]\d*)$/;function Q(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Z.test(t))&&t>-1&&t%1==0&&t<e}function Y(t,e,r){"__proto__"==e&&K?K(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function tt(t,e){return t===e||t!=t&&e!=e}var et=Object.prototype.hasOwnProperty;function rt(t,e,r){var n=t[e];et.call(t,e)&&tt(n,r)&&(void 0!==r||e in t)||Y(t,e,r)}function nt(t,e,r,n){var o=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?Y(r,a,c):rt(r,a,c)}return r}var ot=Math.max;function it(t,e){return V(function(t,e,r){return e=ot(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ot(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),W(t,this,a)}}(t,e,_),t+"")}function st(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function at(t){return null!=t&&st(t.length)&&!C(t)}var ct=Object.prototype;function ht(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ct)}function ut(t){return m(t)&&"[object Arguments]"==b(t)}var lt=Object.prototype,pt=lt.hasOwnProperty,ft=lt.propertyIsEnumerable,dt=ut(function(){return arguments}())?ut:function(t){return m(t)&&pt.call(t,"callee")&&!ft.call(t,"callee")},yt=dt;var vt="object"==typeof t&&t&&!t.nodeType&&t,gt=vt&&"object"==typeof module&&module&&!module.nodeType&&module,bt=gt&&gt.exports===vt?u.Buffer:void 0,mt=(bt?bt.isBuffer:void 0)||function(){return!1},wt={};function jt(t){return function(e){return t(e)}}wt["[object Float32Array]"]=wt["[object Float64Array]"]=wt["[object Int8Array]"]=wt["[object Int16Array]"]=wt["[object Int32Array]"]=wt["[object Uint8Array]"]=wt["[object Uint8ClampedArray]"]=wt["[object Uint16Array]"]=wt["[object Uint32Array]"]=!0,wt["[object Arguments]"]=wt["[object Array]"]=wt["[object ArrayBuffer]"]=wt["[object Boolean]"]=wt["[object DataView]"]=wt["[object Date]"]=wt["[object Error]"]=wt["[object Function]"]=wt["[object Map]"]=wt["[object Number]"]=wt["[object Object]"]=wt["[object RegExp]"]=wt["[object Set]"]=wt["[object String]"]=wt["[object WeakMap]"]=!1;var _t="object"==typeof t&&t&&!t.nodeType&&t,Ct=_t&&"object"==typeof module&&module&&!module.nodeType&&module,Ot=Ct&&Ct.exports===_t&&c.process,At=function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||Ot&&Ot.binding&&Ot.binding("util")}catch(t){}}(),St=At&&At.isTypedArray,Et=St?jt(St):function(t){return m(t)&&st(t.length)&&!!wt[b(t)]},Rt=Object.prototype.hasOwnProperty;function Tt(t,e){var r=w(t),n=!r&&yt(t),o=!r&&!n&&mt(t),i=!r&&!n&&!o&&Et(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var h in t)!e&&!Rt.call(t,h)||s&&("length"==h||o&&("offset"==h||"parent"==h)||i&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Q(h,c))||a.push(h);return a}function It(t,e){return function(r){return t(e(r))}}var xt=It(Object.keys,Object),kt=Object.prototype.hasOwnProperty;function Pt(t){return at(t)?Tt(t):function(t){if(!ht(t))return xt(t);var e=[];for(var r in Object(t))kt.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var Mt=Object.prototype.hasOwnProperty;function Ft(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ht(t),r=[];for(var n in t)("constructor"!=n||!e&&Mt.call(t,n))&&r.push(n);return r}function qt(t){return at(t)?Tt(t,!0):Ft(t)}var Nt=q(Object,"create");var Ut=Object.prototype.hasOwnProperty;var Dt=Object.prototype.hasOwnProperty;function Wt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Bt(t,e){for(var r=t.length;r--;)if(tt(t[r][0],e))return r;return-1}Wt.prototype.clear=function(){this.__data__=Nt?Nt(null):{},this.size=0},Wt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Wt.prototype.get=function(t){var e=this.__data__;if(Nt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Ut.call(e,t)?e[t]:void 0},Wt.prototype.has=function(t){var e=this.__data__;return Nt?void 0!==e[t]:Dt.call(e,t)},Wt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Nt&&void 0===e?"__lodash_hash_undefined__":e,this};var zt=Array.prototype.splice;function Lt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Lt.prototype.clear=function(){this.__data__=[],this.size=0},Lt.prototype.delete=function(t){var e=this.__data__,r=Bt(e,t);return!(r<0)&&(r==e.length-1?e.pop():zt.call(e,r,1),--this.size,!0)},Lt.prototype.get=function(t){var e=this.__data__,r=Bt(e,t);return r<0?void 0:e[r][1]},Lt.prototype.has=function(t){return Bt(this.__data__,t)>-1},Lt.prototype.set=function(t,e){var r=this.__data__,n=Bt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Jt=q(u,"Map");function $t(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Ht(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Kt(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}Ht.prototype.clear=function(){this.size=0,this.__data__={hash:new Wt,map:new(Jt||Lt),string:new Wt}},Ht.prototype.delete=function(t){var e=$t(this,t).delete(t);return this.size-=e?1:0,e},Ht.prototype.get=function(t){return $t(this,t).get(t)},Ht.prototype.has=function(t){return $t(this,t).has(t)},Ht.prototype.set=function(t,e){var r=$t(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var Gt=It(Object.getPrototypeOf,Object),Xt=Function.prototype,Vt=Object.prototype,Zt=Xt.toString,Qt=Vt.hasOwnProperty,Yt=Zt.call(Object);function te(t){var e=this.__data__=new Lt(t);this.size=e.size}te.prototype.clear=function(){this.__data__=new Lt,this.size=0},te.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},te.prototype.get=function(t){return this.__data__.get(t)},te.prototype.has=function(t){return this.__data__.has(t)},te.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Lt){var n=r.__data__;if(!Jt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ht(n)}return r.set(t,e),this.size=r.size,this};var ee="object"==typeof t&&t&&!t.nodeType&&t,re=ee&&"object"==typeof module&&module&&!module.nodeType&&module,ne=re&&re.exports===ee?u.Buffer:void 0,oe=ne?ne.allocUnsafe:void 0;function ie(t,e){if(e)return t.slice();var r=t.length,n=oe?oe(r):new t.constructor(r);return t.copy(n),n}function se(){return[]}var ae=Object.prototype.propertyIsEnumerable,ce=Object.getOwnPropertySymbols,he=ce?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}(ce(t),(function(e){return ae.call(t,e)})))}:se;var ue=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Kt(e,he(t)),t=Gt(t);return e}:se;function le(t,e,r){var n=e(t);return w(t)?n:Kt(n,r(t))}function pe(t){return le(t,Pt,he)}function fe(t){return le(t,qt,ue)}var de=q(u,"DataView"),ye=q(u,"Promise"),ve=q(u,"Set"),ge="[object Map]",be="[object Promise]",me="[object Set]",we="[object WeakMap]",je="[object DataView]",_e=R(de),Ce=R(Jt),Oe=R(ye),Ae=R(ve),Se=R(N),Ee=b;(de&&Ee(new de(new ArrayBuffer(1)))!=je||Jt&&Ee(new Jt)!=ge||ye&&Ee(ye.resolve())!=be||ve&&Ee(new ve)!=me||N&&Ee(new N)!=we)&&(Ee=function(t){var e=b(t),r="[object Object]"==e?t.constructor:void 0,n=r?R(r):"";if(n)switch(n){case _e:return je;case Ce:return ge;case Oe:return be;case Ae:return me;case Se:return we}return e});var Re=Ee,Te=Object.prototype.hasOwnProperty;var Ie=u.Uint8Array;function xe(t){var e=new t.constructor(t.byteLength);return new Ie(e).set(new Ie(t)),e}var ke=/\w*$/;var Pe=l?l.prototype:void 0,Me=Pe?Pe.valueOf:void 0;function Fe(t,e){var r=e?xe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function qe(t,e,r){var n,o,i,s=t.constructor;switch(e){case"[object ArrayBuffer]":return xe(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return function(t,e){var r=e?xe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Fe(t,r);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return(i=new(o=t).constructor(o.source,ke.exec(o))).lastIndex=o.lastIndex,i;case"[object Symbol]":return n=t,Me?Object(Me.call(n)):{}}}function Ne(t){return"function"!=typeof t.constructor||ht(t)?{}:D(Gt(t))}var Ue=At&&At.isMap,De=Ue?jt(Ue):function(t){return m(t)&&"[object Map]"==Re(t)};var We=At&&At.isSet,Be=We?jt(We):function(t){return m(t)&&"[object Set]"==Re(t)},ze="[object Arguments]",Le="[object Function]",Je="[object Object]",$e={};function He(t,e,r,n,o,i){var s,a=1&e,c=2&e,h=4&e;if(r&&(s=o?r(t,n,o,i):r(t)),void 0!==s)return s;if(!j(t))return t;var u=w(t);if(u){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Te.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return B(t,s)}else{var l=Re(t),p=l==Le||"[object GeneratorFunction]"==l;if(mt(t))return ie(t,a);if(l==Je||l==ze||p&&!o){if(s=c||p?{}:Ne(t),!a)return c?function(t,e){return nt(t,ue(t),e)}(t,function(t,e){return t&&nt(e,qt(e),t)}(s,t)):function(t,e){return nt(t,he(t),e)}(t,function(t,e){return t&&nt(e,Pt(e),t)}(s,t))}else{if(!$e[l])return o?t:{};s=qe(t,l,a)}}i||(i=new te);var f=i.get(t);if(f)return f;i.set(t,s),Be(t)?t.forEach((function(n){s.add(He(n,e,r,n,t,i))})):De(t)&&t.forEach((function(n,o){s.set(o,He(n,e,r,o,t,i))}));var d=u?void 0:(h?c?fe:pe:c?qt:Pt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(d||t,(function(n,o){d&&(n=t[o=n]),rt(s,o,He(n,e,r,o,t,i))})),s}$e[ze]=$e["[object Array]"]=$e["[object ArrayBuffer]"]=$e["[object DataView]"]=$e["[object Boolean]"]=$e["[object Date]"]=$e["[object Float32Array]"]=$e["[object Float64Array]"]=$e["[object Int8Array]"]=$e["[object Int16Array]"]=$e["[object Int32Array]"]=$e["[object Map]"]=$e["[object Number]"]=$e[Je]=$e["[object RegExp]"]=$e["[object Set]"]=$e["[object String]"]=$e["[object Symbol]"]=$e["[object Uint8Array]"]=$e["[object Uint8ClampedArray]"]=$e["[object Uint16Array]"]=$e["[object Uint32Array]"]=!0,$e["[object Error]"]=$e[Le]=$e["[object WeakMap]"]=!1;function Ke(t){return He(t,5)}var Ge,Xe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),s=i.length;s--;){var a=i[Ge?s:++n];if(!1===e(o[a],a,o))break}return t};function Ve(t,e,r){(void 0!==r&&!tt(t[e],r)||void 0===r&&!(e in t))&&Y(t,e,r)}function Ze(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Qe(t,e,r,n,o,i,s){var a=Ze(t,r),c=Ze(e,r),h=s.get(c);if(h)Ve(t,r,h);else{var u,l=i?i(a,c,r+"",t,e,s):void 0,p=void 0===l;if(p){var f=w(c),d=!f&&mt(c),y=!f&&!d&&Et(c);l=c,f||d||y?w(a)?l=a:m(u=a)&&at(u)?l=B(a):d?(p=!1,l=ie(c,!0)):y?(p=!1,l=Fe(c,!0)):l=[]:function(t){if(!m(t)||"[object Object]"!=b(t))return!1;var e=Gt(t);if(null===e)return!0;var r=Qt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Zt.call(r)==Yt}(c)||yt(c)?(l=a,yt(a)?l=function(t){return nt(t,qt(t))}(a):j(a)&&!C(a)||(l=Ne(c))):p=!1}p&&(s.set(c,l),o(l,c,n,i,s),s.delete(c)),Ve(t,r,l)}}function Ye(t,e,r,n,o){t!==e&&Xe(e,(function(i,s){if(o||(o=new te),j(i))Qe(t,e,s,r,Ye,n,o);else{var a=n?n(Ze(t,s),i,s+"",t,e,o):void 0;void 0===a&&(a=i),Ve(t,s,a)}}),qt)}var tr,er=(tr=function(t,e,r){Ye(t,e,r)},it((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=tr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!j(r))return!1;var n=typeof e;return!!("number"==n?at(r)&&Q(e,r.length):"string"==n&&e in r)&&tt(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var s=e[r];s&&tr(t,s,r,o)}return t})));let rr=null;try{rr=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const nr=t=>rr&&new RegExp(rr).test(t)?(...e)=>console.log(t,...e):()=>{},or=nr("rpc:ClientManager");class ir{constructor(t){this.options=t,this.inflightCallsByKey={},this.interceptors={request:[],response:[]},this.addResponseInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");this.interceptors.response.push(t)},this.addRequestInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");this.interceptors.request.push(t)},this.clearCache=t=>{or("clearCache"),this.cache&&(t?this.cache.setCachedResponse(t,void 0):this.cache.clearCache())},this.getCachedResponse=t=>{var e;return or("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(or("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=t=>e(this,void 0,void 0,(function*(){or("manageClientRequest",t);const r=yield this.interceptRequestMutator(t),n=a(r);if(this.inflightCallsByKey.hasOwnProperty(n))return or("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const r=Ke(e);return t.correlationId&&(r.correlationId=t.correlationId),r}));const o=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(r),e=yield this.interceptResponseMutator(t,r);return this.cache&&e&&this.cache.setCachedResponse(r,e),e})))().then((t=>(delete this.inflightCallsByKey[n],t))).catch((t=>{throw delete this.inflightCallsByKey[n],t}));return this.inflightCallsByKey[n]=o,yield o})),this.setIdentity=t=>{or("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.request.length){or("interceptRequestMutator(), original request:",t);for(const t of this.interceptors.request)e=yield t(e)}return e})),this.interceptResponseMutator=(t,r)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){or("interceptResponseMutator",r,t);for(const n of this.interceptors.response)try{e=yield n(e,r)}catch(n){throw or("caught response interceptor, request:",r,"original response:",t,"mutated response:",e),n}}return e})),this.sendRequestWithTransport=t=>e(this,void 0,void 0,(function*(){let e;or("sendRequestWithTransport",t);let r=0;for(;!e&&this.transports[r];){const n=this.transports[r];if(n.isConnected()){or(`sendRequestWithTransport trying ${this.transports[r].name}`,t);try{let r;const o=new Promise(((e,n)=>{r=setTimeout((()=>{n(new i(`Procedure ${t.procedure}`))}),this.options.deadlineMs)}));e=yield Promise.race([o,n.sendRequest(t)]).then((t=>(clearTimeout(r),t)))}catch(t){if(!(t instanceof i||t instanceof o))throw t;or(`sending request with ${this.transports[r].name} failed, trying next transport`),r++}}else r++}if(!e&&!this.transports[r])throw new n(`Procedure ${t.procedure} did not get a response from any transports`);if(!e)throw new n(`Procedure ${t.procedure} did not get a response from the remote`);return e})),this.cache=t.cache,t.requestInterceptor&&this.interceptors.request.push(t.requestInterceptor),t.responseInterceptor&&this.interceptors.response.push(t.responseInterceptor),this.transports=t.transports}}class sr{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}sr.DEFAULT_CACHE_MAX_AGE_MS=3e5,sr.DEFAULT_CACHE_MAX_SIZE=100;var ar=cr;function cr(t){var e=this;if(e instanceof cr||(e=new cr),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)e.push(arguments[r]);return e}function hr(t,e,r){var n=e===t.head?new pr(r,null,e,t):new pr(r,e,e.next,t);return null===n.next&&(t.tail=n),null===n.prev&&(t.head=n),t.length++,n}function ur(t,e){t.tail=new pr(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function lr(t,e){t.head=new pr(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function pr(t,e,r,n){if(!(this instanceof pr))return new pr(t,e,r,n);this.list=n,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}cr.Node=pr,cr.create=cr,cr.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e},cr.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},cr.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},cr.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)ur(this,arguments[t]);return this.length},cr.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)lr(this,arguments[t]);return this.length},cr.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},cr.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},cr.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,n=0;null!==r;n++)t.call(e,r.value,n,this),r=r.next},cr.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,n=this.length-1;null!==r;n--)t.call(e,r.value,n,this),r=r.prev},cr.prototype.get=function(t){for(var e=0,r=this.head;null!==r&&e<t;e++)r=r.next;if(e===t&&null!==r)return r.value},cr.prototype.getReverse=function(t){for(var e=0,r=this.tail;null!==r&&e<t;e++)r=r.prev;if(e===t&&null!==r)return r.value},cr.prototype.map=function(t,e){e=e||this;for(var r=new cr,n=this.head;null!==n;)r.push(t.call(e,n.value,this)),n=n.next;return r},cr.prototype.mapReverse=function(t,e){e=e||this;for(var r=new cr,n=this.tail;null!==n;)r.push(t.call(e,n.value,this)),n=n.prev;return r},cr.prototype.reduce=function(t,e){var r,n=this.head;if(arguments.length>1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var o=0;null!==n;o++)r=t(r,n.value,o),n=n.next;return r},cr.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var o=this.length-1;null!==n;o--)r=t(r,n.value,o),n=n.prev;return r},cr.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},cr.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},cr.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new cr;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=0,o=this.head;null!==o&&n<t;n++)o=o.next;for(;null!==o&&n<e;n++,o=o.next)r.push(o.value);return r},cr.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new cr;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=this.length,o=this.tail;null!==o&&n>e;n--)o=o.prev;for(;null!==o&&n>t;n--,o=o.prev)r.push(o.value);return r},cr.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,o=this.head;null!==o&&n<t;n++)o=o.next;var i=[];for(n=0;o&&n<e;n++)i.push(o.value),o=this.removeNode(o);null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev);for(n=0;n<r.length;n++)o=hr(this,o,r[n]);return i},cr.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=e,this.tail=t,this};try{!function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}(cr)}catch(t){}const fr=Symbol("max"),dr=Symbol("length"),yr=Symbol("lengthCalculator"),vr=Symbol("allowStale"),gr=Symbol("maxAge"),br=Symbol("dispose"),mr=Symbol("noDisposeOnSet"),wr=Symbol("lruList"),jr=Symbol("cache"),_r=Symbol("updateAgeOnGet"),Cr=()=>1;const Or=(t,e,r)=>{const n=t[jr].get(e);if(n){const e=n.value;if(Ar(t,e)){if(Er(t,n),!t[vr])return}else r&&(t[_r]&&(n.value.now=Date.now()),t[wr].unshiftNode(n));return e.value}},Ar=(t,e)=>{if(!e||!e.maxAge&&!t[gr])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[gr]&&r>t[gr]},Sr=t=>{if(t[dr]>t[fr])for(let e=t[wr].tail;t[dr]>t[fr]&&null!==e;){const r=e.prev;Er(t,e),e=r}},Er=(t,e)=>{if(e){const r=e.value;t[br]&&t[br](r.key,r.value),t[dr]-=r.length,t[jr].delete(r.key),t[wr].removeNode(e)}};class Rr{constructor(t,e,r,n,o){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=o||0}}const Tr=(t,e,r,n)=>{let o=r.value;Ar(t,o)&&(Er(t,r),t[vr]||(o=void 0)),o&&e.call(n,o.value,o.key,t)};var Ir=class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[fr]=t.max||1/0;const e=t.length||Cr;if(this[yr]="function"!=typeof e?Cr:e,this[vr]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[gr]=t.maxAge||0,this[br]=t.dispose,this[mr]=t.noDisposeOnSet||!1,this[_r]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[fr]=t||1/0,Sr(this)}get max(){return this[fr]}set allowStale(t){this[vr]=!!t}get allowStale(){return this[vr]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[gr]=t,Sr(this)}get maxAge(){return this[gr]}set lengthCalculator(t){"function"!=typeof t&&(t=Cr),t!==this[yr]&&(this[yr]=t,this[dr]=0,this[wr].forEach((t=>{t.length=this[yr](t.value,t.key),this[dr]+=t.length}))),Sr(this)}get lengthCalculator(){return this[yr]}get length(){return this[dr]}get itemCount(){return this[wr].length}rforEach(t,e){e=e||this;for(let r=this[wr].tail;null!==r;){const n=r.prev;Tr(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[wr].head;null!==r;){const n=r.next;Tr(this,t,r,e),r=n}}keys(){return this[wr].toArray().map((t=>t.key))}values(){return this[wr].toArray().map((t=>t.value))}reset(){this[br]&&this[wr]&&this[wr].length&&this[wr].forEach((t=>this[br](t.key,t.value))),this[jr]=new Map,this[wr]=new ar,this[dr]=0}dump(){return this[wr].map((t=>!Ar(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[wr]}set(t,e,r){if((r=r||this[gr])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,o=this[yr](e,t);if(this[jr].has(t)){if(o>this[fr])return Er(this,this[jr].get(t)),!1;const i=this[jr].get(t).value;return this[br]&&(this[mr]||this[br](t,i.value)),i.now=n,i.maxAge=r,i.value=e,this[dr]+=o-i.length,i.length=o,this.get(t),Sr(this),!0}const i=new Rr(t,e,o,n,r);return i.length>this[fr]?(this[br]&&this[br](t,e),!1):(this[dr]+=i.length,this[wr].unshift(i),this[jr].set(t,this[wr].head),Sr(this),!0)}has(t){if(!this[jr].has(t))return!1;const e=this[jr].get(t).value;return!Ar(this,e)}get(t){return Or(this,t,!0)}peek(t){return Or(this,t,!1)}pop(){const t=this[wr].tail;return t?(Er(this,t),t.value):null}del(t){Er(this,this[jr].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],o=n.e||0;if(0===o)this.set(n.k,n.v);else{const t=o-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[jr].forEach(((t,e)=>Or(this,e,!1)))}};const xr=nr("rpc:InMemoryCache");class kr{constructor(t){this.clearCache=()=>{var t;xr("clearCache"),null===(t=this.cachedResponseByParams)||void 0===t||t.reset()},this.getCachedResponse=t=>{var e;xr("getCachedResponse, key: ",t);let r=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(a(t));return"string"==typeof r&&(r=JSON.parse(r)),r},this.setCachedResponse=(t,e)=>{var r,n;xr("setCachedResponse",t,e);const o=a(t);if(!e)return null===(r=this.cachedResponseByParams)||void 0===r?void 0:r.del(o);const i=Object.assign({},e);delete i.correlationId,null===(n=this.cachedResponseByParams)||void 0===n||n.set(o,i?JSON.stringify(i):void 0)},this.cachedResponseByParams=new Ir({max:(null==t?void 0:t.cacheMaxSize)||kr.DEFAULT_CACHE_MAX_SIZE,maxAge:(null==t?void 0:t.cacheMaxAgeMs)||kr.DEFAULT_CACHE_MAX_AGE_MS})}}kr.DEFAULT_CACHE_MAX_AGE_MS=3e5,kr.DEFAULT_CACHE_MAX_SIZE=100;class Pr{constructor(t){const{code:e,correlationId:r,data:n,message:o,success:i}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,r&&"string"!=typeof r)throw new Error("correlationId must be a string");if(this.correlationId=r,this.data=n,o&&"string"!=typeof o)throw new Error("message must be a string");if(this.message=o,"boolean"!=typeof i)throw new Error("success must be a boolean");this.success=i}}const Mr=nr("rpc:HTTPTransport");class Fr{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.isConnected=()=>{var t;return"undefined"!=typeof window?!!(null===(t=null===window||void 0===window?void 0:window.navigator)||void 0===t?void 0:t.onLine):this.networkIsConnected},this.sendRequest=t=>e(this,void 0,void 0,(function*(){Mr("sendRequest",t);const e=JSON.stringify(Object.assign({identity:this.identity},t)),r=yield null===window||void 0===window?void 0:window.fetch(this.host,{body:e,cache:"default",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"follow",referrerPolicy:"origin"}),n=yield r.text();if(!n)throw new Error("No response received from remote");const o=JSON.parse(n);return new Pr(o)})),this.setIdentity=t=>{Mr("setIdentity",t),this.identity=t},this.host=t.host}}class qr{constructor(t){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((r,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error("PromiseWraper timeout"))}),t||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),r(t)}}))))}}const Nr=t=>new Promise((e=>setTimeout(e,t))),Ur=nr("rpc:WebSocketTransport");class Dr{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.websocketId=void 0,this.name="WebSocketTransport",this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.sendRequest=t=>e(this,void 0,void 0,(function*(){for(Ur("sendRequest",t);this.isWaitingForIdentityConfirmation;)Ur("waiting for identity confirmation"),yield Nr(100);return this.send(t)})),this.setIdentity=t=>{if(Ur("setIdentity",t),!t)return this.identity=void 0,void this.resetConnection();this.identity=t,this.connectedToRemote?(this.isWaitingForIdentityConfirmation=!0,this.send({identity:t}).then((()=>{Ur("setIdentity with remote complete")})).catch((t=>{Ur("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):Ur("setIdentity is not connected to remote")},this.connect=()=>{if(Ur("connect",this.host),this.websocket)return void Ur("connect() returning early, websocket already exists");this.websocketId=Math.random(),this.websocket=new WebSocket(this.host);const t=this.websocket;t.onopen=()=>{console.log("WebSocket connected:"),this.setConnectedToRemote(!0),this.identity&&this.setIdentity(this.identity)},t.onmessage=t=>{this.handleWebSocketMsg(t)},t.onclose=t=>{this.connectedToRemote?console.log("WebSocket closed",t.reason):Ur("WebSocket closed, it was not connected to the remote"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,this.websocket=void 0,this.websocketId=void 0,Object.entries(this.pendingPromisesForResponse).forEach((([t,e])=>{e.reject(new o("Websocket disconnected"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("Socket encountered error: ",e):Ur("WebSocket errored, it was not connected to the remote"),t.close()}},this.disconnect=()=>{var t;Ur("disconnect"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,null===(t=this.websocket)||void 0===t||t.close(),this.websocket=void 0,this.websocketId=void 0},this.handleWebSocketMsg=t=>{let e;Ur("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){console.error("error parsing WS msg",t)}const r=new Pr(e);if(!r.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const n=this.pendingPromisesForResponse[r.correlationId];n?n.resolve(r):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>{Ur("resetConnection"),this.disconnect(),this.connect()},this.send=t=>e(this,void 0,void 0,(function*(){var e;Ur("send",t);const r=Math.random().toString();t.correlationId=t.correlationId||r;let n=new qr(Dr.DEFAULT_TIMEOUT_MS);return null===(e=this.websocket)||void 0===e||e.send(JSON.stringify(t)),this.pendingPromisesForResponse[t.correlationId]=n,yield n.promise.finally((()=>{delete this.pendingPromisesForResponse[t.correlationId]}))})),this.setConnectedToRemote=t=>{this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t)},Ur("new WebSocketTransport()"),this.host=t.host,this.connect()}}Dr.DEFAULT_TIMEOUT_MS=1e4;const Wr=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},Br={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class zr{constructor(t){var n,o,i,s,a,c;if(this.options=t,this.call=(t,n)=>e(this,void 0,void 0,(function*(){if(!t)throw new Error('RPCClient.call(request) requires a "request" param');let e;e="string"==typeof t?Wr(t):t,n&&(e.args=n);const o=new r(e);if(!o.procedure&&!o.identity)throw new TypeError('RPCClient#call requires a "identity" or "procedure" prop and received neither');o.identity||(o.identity={}),o.identity=er(Object.assign({},this.identity),o.identity);const i=yield this.callManager.manageClientRequest(o);if(!i.success)throw i;return i})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let r;r="string"==typeof t?Wr(t):t,e&&(r.args=e);const n=this.callManager.getCachedResponse(r);if(n)return n},this.getIdentity=()=>this.identity?Ke(this.identity):this.identity,this.getInFlightCallCount=()=>this.callManager.getInFlightCallCount(),this.getWebSocketConnected=()=>{var t;return!!(null===(t=null==this?void 0:this.webSocketTransport)||void 0===t?void 0:t.isConnected())},this.makeProcedure=t=>{const e=this;let r;return r="string"==typeof t?Wr(t):t,function(t){return e.call(Object.assign(Object.assign({},r),{args:t}))}},this.registerResponseInterceptor=t=>{this.callManager.addResponseInterceptor(t)},this.registerRequestInterceptor=t=>{this.callManager.addRequestInterceptor(t)},this.setIdentity=t=>{this.identity=t,this.callManager.setIdentity(t)},!(null===(n=null==t?void 0:t.hosts)||void 0===n?void 0:n.http)&&!(null===(o=null==t?void 0:t.transports)||void 0===o?void 0:o.http))throw new Error(Br.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(Br.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(Br.INTERCEPTOR_MUSTBE_FUNC);let h;const u={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};h="browser"==t.cacheType?new sr(u):new kr(u);const l=[];(null===(i=t.transports)||void 0===i?void 0:i.websocket)?l.push(t.transports.websocket):(null===(s=null==t?void 0:t.hosts)||void 0===s?void 0:s.websocket)&&(this.webSocketTransport=new Dr({host:t.hosts.websocket,onConnectionStatusChange:t.onWebSocketConnectionStatusChange}),l.push(this.webSocketTransport)),(null===(a=t.transports)||void 0===a?void 0:a.http)?l.push(t.transports.http):(null===(c=null==t?void 0:t.hosts)||void 0===c?void 0:c.http)&&(this.httpTransport=new Fr({host:t.hosts.http}),l.push(this.httpTransport)),this.callManager=new ir({cache:h,deadlineMs:t.deadlineMs||zr.DEFAULT_DEADLINE_MS,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:l})}}zr.DEFAULT_DEADLINE_MS=1e4,t.RPCClient=zr,t.RPCResponse=Pr,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */function e(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))}class r{constructor(t){const{args:e,correlationId:r,identity:n,procedure:o,scope:i,version:s}=t;if(this.args=e,r&&"string"!=typeof r)throw new Error("correlationId must be a string");if(this.correlationId=r||Math.random().toString(),n){if("object"!=typeof n)throw new Error("identity must be an object");if(n.authorization&&"string"!=typeof n.authorization)throw new Error("identity.authorization must be a string");if(n.deviceName&&"string"!=typeof n.deviceName)throw new Error("identity.deviceName must be a string");if(n.metadata&&"object"!=typeof n.metadata)throw new Error("identity.metadata must be a object");this.identity=n}if(o&&"string"!=typeof o)throw new Error("procedure must be string");if(this.procedure=o,i&&"string"!=typeof i)throw new Error("scope must be string");if(this.scope=i,s&&"string"!=typeof s)throw new Error("version must be string");this.version=s}}class n extends Error{}class o extends Error{}class i extends Error{}function s(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const a=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var r,n="boolean"==typeof e.cycles&&e.cycles,o=e.cmp&&(r=e.cmp,function(t){return function(e,n){var o={key:e,value:t[e]},i={key:n,value:t[n]};return r(o,i)}}),i=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=typeof e)return JSON.stringify(e);var r,s;if(Array.isArray(e)){for(s="[",r=0;r<e.length;r++)r&&(s+=","),s+=t(e[r])||"null";return s+"]"}if(null===e)return"null";if(-1!==i.indexOf(e)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=i.push(e)-1,c=Object.keys(e).sort(o&&o(e));for(s="",r=0;r<c.length;r++){var h=c[r],u=t(e[h]);u&&(s&&(s+=","),s+=JSON.stringify(h)+":"+u)}return i.splice(a,1),"{"+s+"}"}}(t)}(function(t,e={}){if(!s(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:r,compare:n}=e,o=[],i=[],a=t=>{const e=o.indexOf(t);if(-1!==e)return i[e];const r=[];return o.push(t),i.push(r),r.push(...t.map((t=>Array.isArray(t)?a(t):s(t)?c(t):t))),r},c=t=>{const e=o.indexOf(t);if(-1!==e)return i[e];const h={},u=Object.keys(t).sort(n);o.push(t),i.push(h);for(const e of u){const n=t[e];let o;o=r&&Array.isArray(n)?a(n):r&&s(n)?c(n):n,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:o}))}return h};return Array.isArray(t)?r?a(t):t.slice():c(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;var c="object"==typeof global&&global&&global.Object===Object&&global,h="object"==typeof self&&self&&self.Object===Object&&self,u=c||h||Function("return this")(),l=u.Symbol,p=Object.prototype,f=p.hasOwnProperty,d=p.toString,v=l?l.toStringTag:void 0;var y=Object.prototype.toString;var g=l?l.toStringTag:void 0;function b(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=f.call(t,v),r=t[v];try{t[v]=void 0;var n=!0}catch(t){}var o=d.call(t);return n&&(e?t[v]=r:delete t[v]),o}(t):function(t){return y.call(t)}(t)}function m(t){return null!=t&&"object"==typeof t}var w=Array.isArray;function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function _(t){return t}function O(t){if(!j(t))return!1;var e=b(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var A,C=u["__core-js_shared__"],S=(A=/[^.]+$/.exec(C&&C.keys&&C.keys.IE_PROTO||""))?"Symbol(src)_1."+A:"";var E=Function.prototype.toString;function R(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var I=/^\[object .+?Constructor\]$/,T=Function.prototype,x=Object.prototype,P=T.toString,k=x.hasOwnProperty,M=RegExp("^"+P.call(k).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function q(t){return!(!j(t)||(e=t,S&&S in e))&&(O(t)?M:I).test(R(t));var e}function F(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return q(r)?r:void 0}var N=F(u,"WeakMap"),U=Object.create,D=function(){function t(){}return function(e){if(!j(e))return{};if(U)return U(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function W(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function B(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}var z=Date.now;var $,L,J,H=function(){try{var t=F(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),G=H,K=G?function(t,e){return G(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:_,X=($=K,L=0,J=0,function(){var t=z(),e=16-(t-J);if(J=t,e>0){if(++L>=800)return arguments[0]}else L=0;return $.apply(void 0,arguments)}),V=X;var Z=/^(?:0|[1-9]\d*)$/;function Q(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Z.test(t))&&t>-1&&t%1==0&&t<e}function Y(t,e,r){"__proto__"==e&&G?G(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function tt(t,e){return t===e||t!=t&&e!=e}var et=Object.prototype.hasOwnProperty;function rt(t,e,r){var n=t[e];et.call(t,e)&&tt(n,r)&&(void 0!==r||e in t)||Y(t,e,r)}function nt(t,e,r,n){var o=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),o?Y(r,a,c):rt(r,a,c)}return r}var ot=Math.max;function it(t,e){return V(function(t,e,r){return e=ot(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ot(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),W(t,this,a)}}(t,e,_),t+"")}function st(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function at(t){return null!=t&&st(t.length)&&!O(t)}var ct=Object.prototype;function ht(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ct)}function ut(t){return m(t)&&"[object Arguments]"==b(t)}var lt=Object.prototype,pt=lt.hasOwnProperty,ft=lt.propertyIsEnumerable,dt=ut(function(){return arguments}())?ut:function(t){return m(t)&&pt.call(t,"callee")&&!ft.call(t,"callee")},vt=dt;var yt="object"==typeof t&&t&&!t.nodeType&&t,gt=yt&&"object"==typeof module&&module&&!module.nodeType&&module,bt=gt&&gt.exports===yt?u.Buffer:void 0,mt=(bt?bt.isBuffer:void 0)||function(){return!1},wt={};function jt(t){return function(e){return t(e)}}wt["[object Float32Array]"]=wt["[object Float64Array]"]=wt["[object Int8Array]"]=wt["[object Int16Array]"]=wt["[object Int32Array]"]=wt["[object Uint8Array]"]=wt["[object Uint8ClampedArray]"]=wt["[object Uint16Array]"]=wt["[object Uint32Array]"]=!0,wt["[object Arguments]"]=wt["[object Array]"]=wt["[object ArrayBuffer]"]=wt["[object Boolean]"]=wt["[object DataView]"]=wt["[object Date]"]=wt["[object Error]"]=wt["[object Function]"]=wt["[object Map]"]=wt["[object Number]"]=wt["[object Object]"]=wt["[object RegExp]"]=wt["[object Set]"]=wt["[object String]"]=wt["[object WeakMap]"]=!1;var _t="object"==typeof t&&t&&!t.nodeType&&t,Ot=_t&&"object"==typeof module&&module&&!module.nodeType&&module,At=Ot&&Ot.exports===_t&&c.process,Ct=function(){try{var t=Ot&&Ot.require&&Ot.require("util").types;return t||At&&At.binding&&At.binding("util")}catch(t){}}(),St=Ct&&Ct.isTypedArray,Et=St?jt(St):function(t){return m(t)&&st(t.length)&&!!wt[b(t)]},Rt=Object.prototype.hasOwnProperty;function It(t,e){var r=w(t),n=!r&&vt(t),o=!r&&!n&&mt(t),i=!r&&!n&&!o&&Et(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],c=a.length;for(var h in t)!e&&!Rt.call(t,h)||s&&("length"==h||o&&("offset"==h||"parent"==h)||i&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Q(h,c))||a.push(h);return a}function Tt(t,e){return function(r){return t(e(r))}}var xt=Tt(Object.keys,Object),Pt=Object.prototype.hasOwnProperty;function kt(t){return at(t)?It(t):function(t){if(!ht(t))return xt(t);var e=[];for(var r in Object(t))Pt.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var Mt=Object.prototype.hasOwnProperty;function qt(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ht(t),r=[];for(var n in t)("constructor"!=n||!e&&Mt.call(t,n))&&r.push(n);return r}function Ft(t){return at(t)?It(t,!0):qt(t)}var Nt=F(Object,"create");var Ut=Object.prototype.hasOwnProperty;var Dt=Object.prototype.hasOwnProperty;function Wt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Bt(t,e){for(var r=t.length;r--;)if(tt(t[r][0],e))return r;return-1}Wt.prototype.clear=function(){this.__data__=Nt?Nt(null):{},this.size=0},Wt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Wt.prototype.get=function(t){var e=this.__data__;if(Nt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Ut.call(e,t)?e[t]:void 0},Wt.prototype.has=function(t){var e=this.__data__;return Nt?void 0!==e[t]:Dt.call(e,t)},Wt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Nt&&void 0===e?"__lodash_hash_undefined__":e,this};var zt=Array.prototype.splice;function $t(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}$t.prototype.clear=function(){this.__data__=[],this.size=0},$t.prototype.delete=function(t){var e=this.__data__,r=Bt(e,t);return!(r<0)&&(r==e.length-1?e.pop():zt.call(e,r,1),--this.size,!0)},$t.prototype.get=function(t){var e=this.__data__,r=Bt(e,t);return r<0?void 0:e[r][1]},$t.prototype.has=function(t){return Bt(this.__data__,t)>-1},$t.prototype.set=function(t,e){var r=this.__data__,n=Bt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Lt=F(u,"Map");function Jt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Ht(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Gt(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}Ht.prototype.clear=function(){this.size=0,this.__data__={hash:new Wt,map:new(Lt||$t),string:new Wt}},Ht.prototype.delete=function(t){var e=Jt(this,t).delete(t);return this.size-=e?1:0,e},Ht.prototype.get=function(t){return Jt(this,t).get(t)},Ht.prototype.has=function(t){return Jt(this,t).has(t)},Ht.prototype.set=function(t,e){var r=Jt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};var Kt=Tt(Object.getPrototypeOf,Object),Xt=Function.prototype,Vt=Object.prototype,Zt=Xt.toString,Qt=Vt.hasOwnProperty,Yt=Zt.call(Object);function te(t){var e=this.__data__=new $t(t);this.size=e.size}te.prototype.clear=function(){this.__data__=new $t,this.size=0},te.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},te.prototype.get=function(t){return this.__data__.get(t)},te.prototype.has=function(t){return this.__data__.has(t)},te.prototype.set=function(t,e){var r=this.__data__;if(r instanceof $t){var n=r.__data__;if(!Lt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ht(n)}return r.set(t,e),this.size=r.size,this};var ee="object"==typeof t&&t&&!t.nodeType&&t,re=ee&&"object"==typeof module&&module&&!module.nodeType&&module,ne=re&&re.exports===ee?u.Buffer:void 0,oe=ne?ne.allocUnsafe:void 0;function ie(t,e){if(e)return t.slice();var r=t.length,n=oe?oe(r):new t.constructor(r);return t.copy(n),n}function se(){return[]}var ae=Object.prototype.propertyIsEnumerable,ce=Object.getOwnPropertySymbols,he=ce?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,o=0,i=[];++r<n;){var s=t[r];e(s,r,t)&&(i[o++]=s)}return i}(ce(t),(function(e){return ae.call(t,e)})))}:se;var ue=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Gt(e,he(t)),t=Kt(t);return e}:se;function le(t,e,r){var n=e(t);return w(t)?n:Gt(n,r(t))}function pe(t){return le(t,kt,he)}function fe(t){return le(t,Ft,ue)}var de=F(u,"DataView"),ve=F(u,"Promise"),ye=F(u,"Set"),ge="[object Map]",be="[object Promise]",me="[object Set]",we="[object WeakMap]",je="[object DataView]",_e=R(de),Oe=R(Lt),Ae=R(ve),Ce=R(ye),Se=R(N),Ee=b;(de&&Ee(new de(new ArrayBuffer(1)))!=je||Lt&&Ee(new Lt)!=ge||ve&&Ee(ve.resolve())!=be||ye&&Ee(new ye)!=me||N&&Ee(new N)!=we)&&(Ee=function(t){var e=b(t),r="[object Object]"==e?t.constructor:void 0,n=r?R(r):"";if(n)switch(n){case _e:return je;case Oe:return ge;case Ae:return be;case Ce:return me;case Se:return we}return e});var Re=Ee,Ie=Object.prototype.hasOwnProperty;var Te=u.Uint8Array;function xe(t){var e=new t.constructor(t.byteLength);return new Te(e).set(new Te(t)),e}var Pe=/\w*$/;var ke=l?l.prototype:void 0,Me=ke?ke.valueOf:void 0;function qe(t,e){var r=e?xe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Fe(t,e,r){var n,o,i,s=t.constructor;switch(e){case"[object ArrayBuffer]":return xe(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return function(t,e){var r=e?xe(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return qe(t,r);case"[object Map]":case"[object Set]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return(i=new(o=t).constructor(o.source,Pe.exec(o))).lastIndex=o.lastIndex,i;case"[object Symbol]":return n=t,Me?Object(Me.call(n)):{}}}function Ne(t){return"function"!=typeof t.constructor||ht(t)?{}:D(Kt(t))}var Ue=Ct&&Ct.isMap,De=Ue?jt(Ue):function(t){return m(t)&&"[object Map]"==Re(t)};var We=Ct&&Ct.isSet,Be=We?jt(We):function(t){return m(t)&&"[object Set]"==Re(t)},ze="[object Arguments]",$e="[object Function]",Le="[object Object]",Je={};function He(t,e,r,n,o,i){var s,a=1&e,c=2&e,h=4&e;if(r&&(s=o?r(t,n,o,i):r(t)),void 0!==s)return s;if(!j(t))return t;var u=w(t);if(u){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Ie.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return B(t,s)}else{var l=Re(t),p=l==$e||"[object GeneratorFunction]"==l;if(mt(t))return ie(t,a);if(l==Le||l==ze||p&&!o){if(s=c||p?{}:Ne(t),!a)return c?function(t,e){return nt(t,ue(t),e)}(t,function(t,e){return t&&nt(e,Ft(e),t)}(s,t)):function(t,e){return nt(t,he(t),e)}(t,function(t,e){return t&&nt(e,kt(e),t)}(s,t))}else{if(!Je[l])return o?t:{};s=Fe(t,l,a)}}i||(i=new te);var f=i.get(t);if(f)return f;i.set(t,s),Be(t)?t.forEach((function(n){s.add(He(n,e,r,n,t,i))})):De(t)&&t.forEach((function(n,o){s.set(o,He(n,e,r,o,t,i))}));var d=u?void 0:(h?c?fe:pe:c?Ft:kt)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););}(d||t,(function(n,o){d&&(n=t[o=n]),rt(s,o,He(n,e,r,o,t,i))})),s}Je[ze]=Je["[object Array]"]=Je["[object ArrayBuffer]"]=Je["[object DataView]"]=Je["[object Boolean]"]=Je["[object Date]"]=Je["[object Float32Array]"]=Je["[object Float64Array]"]=Je["[object Int8Array]"]=Je["[object Int16Array]"]=Je["[object Int32Array]"]=Je["[object Map]"]=Je["[object Number]"]=Je[Le]=Je["[object RegExp]"]=Je["[object Set]"]=Je["[object String]"]=Je["[object Symbol]"]=Je["[object Uint8Array]"]=Je["[object Uint8ClampedArray]"]=Je["[object Uint16Array]"]=Je["[object Uint32Array]"]=!0,Je["[object Error]"]=Je[$e]=Je["[object WeakMap]"]=!1;function Ge(t){return He(t,5)}var Ke,Xe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),s=i.length;s--;){var a=i[Ke?s:++n];if(!1===e(o[a],a,o))break}return t};function Ve(t,e,r){(void 0!==r&&!tt(t[e],r)||void 0===r&&!(e in t))&&Y(t,e,r)}function Ze(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Qe(t,e,r,n,o,i,s){var a=Ze(t,r),c=Ze(e,r),h=s.get(c);if(h)Ve(t,r,h);else{var u,l=i?i(a,c,r+"",t,e,s):void 0,p=void 0===l;if(p){var f=w(c),d=!f&&mt(c),v=!f&&!d&&Et(c);l=c,f||d||v?w(a)?l=a:m(u=a)&&at(u)?l=B(a):d?(p=!1,l=ie(c,!0)):v?(p=!1,l=qe(c,!0)):l=[]:function(t){if(!m(t)||"[object Object]"!=b(t))return!1;var e=Kt(t);if(null===e)return!0;var r=Qt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Zt.call(r)==Yt}(c)||vt(c)?(l=a,vt(a)?l=function(t){return nt(t,Ft(t))}(a):j(a)&&!O(a)||(l=Ne(c))):p=!1}p&&(s.set(c,l),o(l,c,n,i,s),s.delete(c)),Ve(t,r,l)}}function Ye(t,e,r,n,o){t!==e&&Xe(e,(function(i,s){if(o||(o=new te),j(i))Qe(t,e,s,r,Ye,n,o);else{var a=n?n(Ze(t,s),i,s+"",t,e,o):void 0;void 0===a&&(a=i),Ve(t,s,a)}}),Ft)}var tr,er=(tr=function(t,e,r){Ye(t,e,r)},it((function(t,e){var r=-1,n=e.length,o=n>1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=tr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!j(r))return!1;var n=typeof e;return!!("number"==n?at(r)&&Q(e,r.length):"string"==n&&e in r)&&tt(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var s=e[r];s&&tr(t,s,r,o)}return t})));let rr=null;try{rr=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const nr=t=>rr&&new RegExp(rr).test(t)?(...e)=>console.log(t,...e):()=>{},or=nr("rpc:ClientManager");class ir{constructor(t){this.options=t,this.inflightCallsByKey={},this.interceptors={request:[],response:[]},this.addResponseInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");this.interceptors.response.push(t)},this.addRequestInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");this.interceptors.request.push(t)},this.clearCache=t=>{or("clearCache"),this.cache&&(t?this.cache.setCachedResponse(t,void 0):this.cache.clearCache())},this.getCachedResponse=t=>{var e;return or("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(or("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=t=>e(this,void 0,void 0,(function*(){or("manageClientRequest",t);const r=yield this.interceptRequestMutator(t),n=a(r);if(this.inflightCallsByKey.hasOwnProperty(n))return or("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const r=Ge(e);return t.correlationId&&(r.correlationId=t.correlationId),r}));const o=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(r),e=yield this.interceptResponseMutator(t,r);return this.cache&&e&&this.cache.setCachedResponse(r,e),e})))().then((t=>(delete this.inflightCallsByKey[n],t))).catch((t=>{throw delete this.inflightCallsByKey[n],t}));return this.inflightCallsByKey[n]=o,yield o})),this.setIdentity=t=>{or("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.request.length){or("interceptRequestMutator(), original request:",t);for(const t of this.interceptors.request)e=yield t(e)}return e})),this.interceptResponseMutator=(t,r)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){or("interceptResponseMutator",r,t);for(const n of this.interceptors.response)try{e=yield n(e,r)}catch(n){throw or("caught response interceptor, request:",r,"original response:",t,"mutated response:",e),n}}return e})),this.sendRequestWithTransport=t=>e(this,void 0,void 0,(function*(){let e;or("sendRequestWithTransport",t);let r=0;for(;!e&&this.transports[r];){const n=this.transports[r];if(n.isConnected()){or(`sendRequestWithTransport trying ${this.transports[r].name}`,t);try{let r;const o=new Promise(((e,n)=>{r=setTimeout((()=>{n(new i(`Procedure ${t.procedure}`))}),this.options.deadlineMs)}));e=yield Promise.race([o,n.sendRequest(t)]).then((t=>(clearTimeout(r),t)))}catch(t){if(!(t instanceof i||t instanceof o))throw t;or(`sending request with ${this.transports[r].name} failed, trying next transport`),r++}}else r++}if(!e&&!this.transports[r])throw new n(`Procedure ${t.procedure} did not get a response from any transports`);if(!e)throw new n(`Procedure ${t.procedure} did not get a response from the remote`);return e})),this.cache=t.cache,t.requestInterceptor&&this.interceptors.request.push(t.requestInterceptor),t.responseInterceptor&&this.interceptors.response.push(t.responseInterceptor),this.transports=t.transports}}class sr{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}sr.DEFAULT_CACHE_MAX_AGE_MS=3e5,sr.DEFAULT_CACHE_MAX_SIZE=100;var ar=cr;function cr(t){var e=this;if(e instanceof cr||(e=new cr),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach((function(t){e.push(t)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)e.push(arguments[r]);return e}function hr(t,e,r){var n=e===t.head?new pr(r,null,e,t):new pr(r,e,e.next,t);return null===n.next&&(t.tail=n),null===n.prev&&(t.head=n),t.length++,n}function ur(t,e){t.tail=new pr(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++}function lr(t,e){t.head=new pr(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++}function pr(t,e,r,n){if(!(this instanceof pr))return new pr(t,e,r,n);this.list=n,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}cr.Node=pr,cr.create=cr,cr.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,r=t.prev;return e&&(e.prev=r),r&&(r.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=r),t.list.length--,t.next=null,t.prev=null,t.list=null,e},cr.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++}},cr.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++}},cr.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++)ur(this,arguments[t]);return this.length},cr.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++)lr(this,arguments[t]);return this.length},cr.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}},cr.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}},cr.prototype.forEach=function(t,e){e=e||this;for(var r=this.head,n=0;null!==r;n++)t.call(e,r.value,n,this),r=r.next},cr.prototype.forEachReverse=function(t,e){e=e||this;for(var r=this.tail,n=this.length-1;null!==r;n--)t.call(e,r.value,n,this),r=r.prev},cr.prototype.get=function(t){for(var e=0,r=this.head;null!==r&&e<t;e++)r=r.next;if(e===t&&null!==r)return r.value},cr.prototype.getReverse=function(t){for(var e=0,r=this.tail;null!==r&&e<t;e++)r=r.prev;if(e===t&&null!==r)return r.value},cr.prototype.map=function(t,e){e=e||this;for(var r=new cr,n=this.head;null!==n;)r.push(t.call(e,n.value,this)),n=n.next;return r},cr.prototype.mapReverse=function(t,e){e=e||this;for(var r=new cr,n=this.tail;null!==n;)r.push(t.call(e,n.value,this)),n=n.prev;return r},cr.prototype.reduce=function(t,e){var r,n=this.head;if(arguments.length>1)r=e;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");n=this.head.next,r=this.head.value}for(var o=0;null!==n;o++)r=t(r,n.value,o),n=n.next;return r},cr.prototype.reduceReverse=function(t,e){var r,n=this.tail;if(arguments.length>1)r=e;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");n=this.tail.prev,r=this.tail.value}for(var o=this.length-1;null!==n;o--)r=t(r,n.value,o),n=n.prev;return r},cr.prototype.toArray=function(){for(var t=new Array(this.length),e=0,r=this.head;null!==r;e++)t[e]=r.value,r=r.next;return t},cr.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,r=this.tail;null!==r;e++)t[e]=r.value,r=r.prev;return t},cr.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new cr;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=0,o=this.head;null!==o&&n<t;n++)o=o.next;for(;null!==o&&n<e;n++,o=o.next)r.push(o.value);return r},cr.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var r=new cr;if(e<t||e<0)return r;t<0&&(t=0),e>this.length&&(e=this.length);for(var n=this.length,o=this.tail;null!==o&&n>e;n--)o=o.prev;for(;null!==o&&n>t;n--,o=o.prev)r.push(o.value);return r},cr.prototype.splice=function(t,e,...r){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var n=0,o=this.head;null!==o&&n<t;n++)o=o.next;var i=[];for(n=0;o&&n<e;n++)i.push(o.value),o=this.removeNode(o);null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev);for(n=0;n<r.length;n++)o=hr(this,o,r[n]);return i},cr.prototype.reverse=function(){for(var t=this.head,e=this.tail,r=t;null!==r;r=r.prev){var n=r.prev;r.prev=r.next,r.next=n}return this.head=e,this.tail=t,this};try{!function(t){t.prototype[Symbol.iterator]=function*(){for(let t=this.head;t;t=t.next)yield t.value}}(cr)}catch(t){}const fr=Symbol("max"),dr=Symbol("length"),vr=Symbol("lengthCalculator"),yr=Symbol("allowStale"),gr=Symbol("maxAge"),br=Symbol("dispose"),mr=Symbol("noDisposeOnSet"),wr=Symbol("lruList"),jr=Symbol("cache"),_r=Symbol("updateAgeOnGet"),Or=()=>1;const Ar=(t,e,r)=>{const n=t[jr].get(e);if(n){const e=n.value;if(Cr(t,e)){if(Er(t,n),!t[yr])return}else r&&(t[_r]&&(n.value.now=Date.now()),t[wr].unshiftNode(n));return e.value}},Cr=(t,e)=>{if(!e||!e.maxAge&&!t[gr])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:t[gr]&&r>t[gr]},Sr=t=>{if(t[dr]>t[fr])for(let e=t[wr].tail;t[dr]>t[fr]&&null!==e;){const r=e.prev;Er(t,e),e=r}},Er=(t,e)=>{if(e){const r=e.value;t[br]&&t[br](r.key,r.value),t[dr]-=r.length,t[jr].delete(r.key),t[wr].removeNode(e)}};class Rr{constructor(t,e,r,n,o){this.key=t,this.value=e,this.length=r,this.now=n,this.maxAge=o||0}}const Ir=(t,e,r,n)=>{let o=r.value;Cr(t,o)&&(Er(t,r),t[yr]||(o=void 0)),o&&e.call(n,o.value,o.key,t)};var Tr=class{constructor(t){if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[fr]=t.max||1/0;const e=t.length||Or;if(this[vr]="function"!=typeof e?Or:e,this[yr]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[gr]=t.maxAge||0,this[br]=t.dispose,this[mr]=t.noDisposeOnSet||!1,this[_r]=t.updateAgeOnGet||!1,this.reset()}set max(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[fr]=t||1/0,Sr(this)}get max(){return this[fr]}set allowStale(t){this[yr]=!!t}get allowStale(){return this[yr]}set maxAge(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[gr]=t,Sr(this)}get maxAge(){return this[gr]}set lengthCalculator(t){"function"!=typeof t&&(t=Or),t!==this[vr]&&(this[vr]=t,this[dr]=0,this[wr].forEach((t=>{t.length=this[vr](t.value,t.key),this[dr]+=t.length}))),Sr(this)}get lengthCalculator(){return this[vr]}get length(){return this[dr]}get itemCount(){return this[wr].length}rforEach(t,e){e=e||this;for(let r=this[wr].tail;null!==r;){const n=r.prev;Ir(this,t,r,e),r=n}}forEach(t,e){e=e||this;for(let r=this[wr].head;null!==r;){const n=r.next;Ir(this,t,r,e),r=n}}keys(){return this[wr].toArray().map((t=>t.key))}values(){return this[wr].toArray().map((t=>t.value))}reset(){this[br]&&this[wr]&&this[wr].length&&this[wr].forEach((t=>this[br](t.key,t.value))),this[jr]=new Map,this[wr]=new ar,this[dr]=0}dump(){return this[wr].map((t=>!Cr(this,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)})).toArray().filter((t=>t))}dumpLru(){return this[wr]}set(t,e,r){if((r=r||this[gr])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const n=r?Date.now():0,o=this[vr](e,t);if(this[jr].has(t)){if(o>this[fr])return Er(this,this[jr].get(t)),!1;const i=this[jr].get(t).value;return this[br]&&(this[mr]||this[br](t,i.value)),i.now=n,i.maxAge=r,i.value=e,this[dr]+=o-i.length,i.length=o,this.get(t),Sr(this),!0}const i=new Rr(t,e,o,n,r);return i.length>this[fr]?(this[br]&&this[br](t,e),!1):(this[dr]+=i.length,this[wr].unshift(i),this[jr].set(t,this[wr].head),Sr(this),!0)}has(t){if(!this[jr].has(t))return!1;const e=this[jr].get(t).value;return!Cr(this,e)}get(t){return Ar(this,t,!0)}peek(t){return Ar(this,t,!1)}pop(){const t=this[wr].tail;return t?(Er(this,t),t.value):null}del(t){Er(this,this[jr].get(t))}load(t){this.reset();const e=Date.now();for(let r=t.length-1;r>=0;r--){const n=t[r],o=n.e||0;if(0===o)this.set(n.k,n.v);else{const t=o-e;t>0&&this.set(n.k,n.v,t)}}}prune(){this[jr].forEach(((t,e)=>Ar(this,e,!1)))}};const xr=nr("rpc:InMemoryCache");class Pr{constructor(t){this.clearCache=()=>{var t;xr("clearCache"),null===(t=this.cachedResponseByParams)||void 0===t||t.reset()},this.getCachedResponse=t=>{var e;xr("getCachedResponse, key: ",t);let r=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(a(t));return"string"==typeof r&&(r=JSON.parse(r)),r},this.setCachedResponse=(t,e)=>{var r,n;xr("setCachedResponse",t,e);const o=a(t);if(!e)return null===(r=this.cachedResponseByParams)||void 0===r?void 0:r.del(o);const i=Object.assign({},e);delete i.correlationId,null===(n=this.cachedResponseByParams)||void 0===n||n.set(o,i?JSON.stringify(i):void 0)},this.cachedResponseByParams=new Tr({max:(null==t?void 0:t.cacheMaxSize)||Pr.DEFAULT_CACHE_MAX_SIZE,maxAge:(null==t?void 0:t.cacheMaxAgeMs)||Pr.DEFAULT_CACHE_MAX_AGE_MS})}}Pr.DEFAULT_CACHE_MAX_AGE_MS=3e5,Pr.DEFAULT_CACHE_MAX_SIZE=100;class kr{constructor(t){const{code:e,correlationId:r,data:n,message:o,success:i}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,r&&"string"!=typeof r)throw new Error("correlationId must be a string");if(this.correlationId=r,this.data=n,o&&"string"!=typeof o)throw new Error("message must be a string");if(this.message=o,"boolean"!=typeof i)throw new Error("success must be a boolean");this.success=i}}const Mr=nr("rpc:HTTPTransport");class qr{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.isConnected=()=>{var t;return"undefined"!=typeof window?!!(null===(t=null===window||void 0===window?void 0:window.navigator)||void 0===t?void 0:t.onLine):this.networkIsConnected},this.sendRequest=t=>e(this,void 0,void 0,(function*(){Mr("sendRequest",t);const e=JSON.stringify(Object.assign({identity:this.identity},t)),r=yield null===window||void 0===window?void 0:window.fetch(this.host,{body:e,cache:"default",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"follow",referrerPolicy:"origin"}),n=yield r.text();if(!n)throw new Error("No response received from remote");const o=JSON.parse(n);return new kr(o)})),this.setIdentity=t=>{Mr("setIdentity",t),this.identity=t},this.host=t.host}}class Fr{constructor(t){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((r,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error("PromiseWraper timeout"))}),t||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),r(t)}}))))}}const Nr=t=>new Promise((e=>setTimeout(e,t))),Ur=nr("rpc:WebSocketTransport");class Dr{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.websocketId=void 0,this.name="WebSocketTransport",this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.sendRequest=t=>e(this,void 0,void 0,(function*(){for(Ur("sendRequest",t);this.isWaitingForIdentityConfirmation;)Ur("waiting for identity confirmation"),yield Nr(100);return this.send(t)})),this.setIdentity=t=>{if(Ur("setIdentity",t),!t)return this.identity=void 0,void this.resetConnection();this.identity=t,this.connectedToRemote?(this.isWaitingForIdentityConfirmation=!0,this.send({identity:t}).then((()=>{Ur("setIdentity with remote complete")})).catch((t=>{Ur("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):Ur("setIdentity is not connected to remote")},this.connect=()=>{if(Ur("connect",this.host),this.websocket)return void Ur("connect() returning early, websocket already exists");this.websocketId=Math.random(),this.websocket=new WebSocket(this.host);const t=this.websocket;t.onopen=()=>{console.log("WebSocket connected:"),this.setConnectedToRemote(!0),this.identity&&this.setIdentity(this.identity)},t.onmessage=t=>{this.handleWebSocketMsg(t)},t.onclose=t=>{this.connectedToRemote?console.log("WebSocket closed",t.reason):Ur("WebSocket closed, it was not connected to the remote"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,this.websocket=void 0,this.websocketId=void 0,Object.entries(this.pendingPromisesForResponse).forEach((([t,e])=>{e.reject(new o("Websocket disconnected"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("Socket encountered error: ",e):Ur("WebSocket errored, it was not connected to the remote"),t.close()}},this.disconnect=()=>{var t;Ur("disconnect"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,null===(t=this.websocket)||void 0===t||t.close(),this.websocket=void 0,this.websocketId=void 0},this.handleWebSocketMsg=t=>{let e;Ur("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){console.error("error parsing WS msg",t)}const r=new kr(e);if(!r.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const n=this.pendingPromisesForResponse[r.correlationId];n?n.resolve(r):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>{Ur("resetConnection"),this.disconnect(),this.connect()},this.send=t=>e(this,void 0,void 0,(function*(){var e;Ur("send",t);const r=Math.random().toString();t.correlationId=t.correlationId||r;let n=new Fr(Dr.DEFAULT_TIMEOUT_MS);return null===(e=this.websocket)||void 0===e||e.send(JSON.stringify(t)),this.pendingPromisesForResponse[t.correlationId]=n,yield n.promise.finally((()=>{delete this.pendingPromisesForResponse[t.correlationId]}))})),this.setConnectedToRemote=t=>{this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t)},Ur("new WebSocketTransport()"),this.host=t.host,this.connect()}}Dr.DEFAULT_TIMEOUT_MS=1e4;const Wr=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}};class Br{constructor(){this.events={},this.publish=(t,r)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,r)}))})),this.subscribe=(t,e)=>{this.events[t]||(this.events[t]=[]),this.events[t].push(e)},this.unsubscribe=(t,e)=>{if(!this.events[t])return;let r=this.events[t].indexOf(e);this.events[t].splice(r)}}}const zr={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class $r{constructor(t){var n,o,i,s,c,h;if(this.options=t,this.vent=new Br,this.call=(t,n)=>e(this,void 0,void 0,(function*(){if(!t)throw new Error('RPCClient.call(request) requires a "request" param');let e;e="string"==typeof t?Wr(t):t,n&&(e.args=n);const o=new r(e);if(!o.procedure&&!o.identity)throw new TypeError('RPCClient#call requires a "identity" or "procedure" prop and received neither');o.identity||(o.identity={}),o.identity=er(Object.assign({},this.identity),o.identity);const i=yield this.callManager.manageClientRequest(o);if(!i.success)throw i;const s=a(e);return this.vent.publish(s,null==i?void 0:i.data),i})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let r;r="string"==typeof t?Wr(t):t,e&&(r.args=e);const n=this.callManager.getCachedResponse(r);if(n)return n},this.getIdentity=()=>this.identity?Ge(this.identity):this.identity,this.getInFlightCallCount=()=>this.callManager.getInFlightCallCount(),this.getWebSocketConnected=()=>{var t;return!!(null===(t=null==this?void 0:this.webSocketTransport)||void 0===t?void 0:t.isConnected())},this.makeProcedure=t=>{const e=this;let r;return r="string"==typeof t?Wr(t):t,function(t){return e.call(Object.assign(Object.assign({},r),{args:t}))}},this.registerResponseInterceptor=t=>{this.callManager.addResponseInterceptor(t)},this.registerRequestInterceptor=t=>{this.callManager.addRequestInterceptor(t)},this.setIdentity=t=>{this.identity=t,this.callManager.setIdentity(t)},!(null===(n=null==t?void 0:t.hosts)||void 0===n?void 0:n.http)&&!(null===(o=null==t?void 0:t.transports)||void 0===o?void 0:o.http))throw new Error(zr.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(zr.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(zr.INTERCEPTOR_MUSTBE_FUNC);let u;const l={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};u="browser"==t.cacheType?new sr(l):new Pr(l);const p=[];(null===(i=t.transports)||void 0===i?void 0:i.websocket)?p.push(t.transports.websocket):(null===(s=null==t?void 0:t.hosts)||void 0===s?void 0:s.websocket)&&(this.webSocketTransport=new Dr({host:t.hosts.websocket,onConnectionStatusChange:t.onWebSocketConnectionStatusChange}),p.push(this.webSocketTransport)),(null===(c=t.transports)||void 0===c?void 0:c.http)?p.push(t.transports.http):(null===(h=null==t?void 0:t.hosts)||void 0===h?void 0:h.http)&&(this.httpTransport=new qr({host:t.hosts.http}),p.push(this.httpTransport)),this.callManager=new ir({cache:u,deadlineMs:t.deadlineMs||$r.DEFAULT_DEADLINE_MS,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:p})}subscribe(t,e){const r="string"==typeof t.request?Wr(t.request):t.request,n=a(Object.assign(Object.assign({},r),{args:t.args}));this.vent.subscribe(n,e)}unsubscribe(t,e){const r="string"==typeof t.request?Wr(t.request):t.request,n=a(Object.assign(Object.assign({},r),{args:t.args}));this.vent.unsubscribe(n,e)}}$r.DEFAULT_DEADLINE_MS=1e4,t.RPCClient=$r,t.RPCResponse=kr,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=umd.js.map
{
"name": "@therms/rpc-client",
"version": "2.3.1",
"version": "2.4.0",
"description": "RPC framework, browser client lib",

@@ -5,0 +5,0 @@ "private": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc