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
4
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 3.0.1 to 3.0.2

3

dist/cjs.js

@@ -480,3 +480,2 @@ 'use strict';

this.options = options;
this.networkIsConnected = false;
this.name = 'HttpTransport';

@@ -489,3 +488,3 @@ this.type = TransportType.http;

}
return this.networkIsConnected;
return true;
};

@@ -492,0 +491,0 @@ this.sendRequest = (call, opts) => __awaiter(this, void 0, void 0, function* () {

@@ -478,3 +478,2 @@ import stringify from 'fast-json-stable-stringify';

this.options = options;
this.networkIsConnected = false;
this.name = 'HttpTransport';

@@ -487,3 +486,3 @@ this.type = TransportType.http;

}
return this.networkIsConnected;
return true;
};

@@ -490,0 +489,0 @@ this.sendRequest = (call, opts) => __awaiter(this, void 0, void 0, function* () {

@@ -14,3 +14,2 @@ import { Transport, TransportType } from './Transport';

private identity?;
private networkIsConnected;
readonly name = "HttpTransport";

@@ -17,0 +16,0 @@ readonly type = TransportType['http'];

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

!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";function e(t,e,s,i){return new(s||(s=Promise))((function(n,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,s=e&&t[e],i=0;if(s)return s.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=t[s]&&function(e){return new Promise((function(i,n){(function(t,e,s,i){Promise.resolve(i).then((function(e){t({value:e,done:s})}),e)})(i,n,(e=t[s](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){const{args:e,correlationId:s,identity:i,procedure:n,scope:r,version:o}=t;if(this.args=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s||Math.random().toString(),i){if("object"!=typeof i)throw new Error("identity must be an object");if(i.authorization&&"string"!=typeof i.authorization)throw new Error("identity.authorization must be a string");if(i.deviceName&&"string"!=typeof i.deviceName)throw new Error("identity.deviceName must be a string");if(i.metadata&&"object"!=typeof i.metadata)throw new Error("identity.metadata must be a object");this.identity=i}if(n&&"string"!=typeof n)throw new Error("procedure must be string");if(this.procedure=n,r&&"string"!=typeof r)throw new Error("scope must be string");if(this.scope=r,o&&"string"!=typeof o)throw new Error("version must be string");this.version=o}}function r(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const o=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var s,i="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(s=e.cmp,function(t){return function(e,i){var n={key:e,value:t[e]},r={key:i,value:t[i]};return s(n,r)}}),r=[];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 s,o;if(Array.isArray(e)){for(o="[",s=0;s<e.length;s++)s&&(o+=","),o+=t(e[s])||"null";return o+"]"}if(null===e)return"null";if(-1!==r.indexOf(e)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=r.push(e)-1,c=Object.keys(e).sort(n&&n(e));for(o="",s=0;s<c.length;s++){var h=c[s],l=t(e[h]);l&&(o&&(o+=","),o+=JSON.stringify(h)+":"+l)}return r.splice(a,1),"{"+o+"}"}}(t)}(function(t,e={}){if(!r(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:s,compare:i}=e,n=[],o=[],a=t=>{const e=n.indexOf(t);if(-1!==e)return o[e];const s=[];return n.push(t),o.push(s),s.push(...t.map((t=>Array.isArray(t)?a(t):r(t)?c(t):t))),s},c=t=>{const e=n.indexOf(t);if(-1!==e)return o[e];const h={},l=Object.keys(t).sort(i);n.push(t),o.push(h);for(const e of l){const i=t[e];let n;n=s&&Array.isArray(i)?a(i):s&&r(i)?c(i):i,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:n}))}return h};return Array.isArray(t)?s?a(t):t.slice():c(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;class a{constructor(t){const{code:e,correlationId:s,data:i,message:n,success:r}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s,this.data=i,n&&"string"!=typeof n)throw new Error("message must be a string");if(this.message=n,"boolean"!=typeof r)throw new Error("success must be a boolean");this.success=r}}class c extends Error{constructor(t,e,s){super(t.message),this.response={code:0,success:!1},this.name="CallResponseError";const{code:i,correlationId:n,message:r}=t;this.response.code=i,this.response.correlationId=n,this.response.data=t.data,this.response.message=`${o(e)} response error: `+(r||"RPC call failed with no message"),this.request=e,this.callOptions=s}}class h extends Error{}var l="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,d=l||u||Function("return this")(),p=d.Symbol,f=Object.prototype,v=f.hasOwnProperty,y=f.toString,g=p?p.toStringTag:void 0;var b=Object.prototype.toString;var w="[object Null]",m="[object Undefined]",S=p?p.toStringTag:void 0;function _(t){return null==t?void 0===t?m:w:S&&S in Object(t)?function(t){var e=v.call(t,g),s=t[g];try{t[g]=void 0;var i=!0}catch(t){}var n=y.call(t);return i&&(e?t[g]=s:delete t[g]),n}(t):function(t){return b.call(t)}(t)}function T(t){return null!=t&&"object"==typeof t}var C=Array.isArray;function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function O(t){return t}var A="[object AsyncFunction]",k="[object Function]",R="[object GeneratorFunction]",E="[object Proxy]";function F(t){if(!j(t))return!1;var e=_(t);return e==k||e==R||e==A||e==E}var z,x=d["__core-js_shared__"],I=(z=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"";var M=Function.prototype.toString;function L(t){if(null!=t){try{return M.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var P=/^\[object .+?Constructor\]$/,D=Function.prototype,W=Object.prototype,q=D.toString,U=W.hasOwnProperty,B=RegExp("^"+q.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function N(t){return!(!j(t)||(e=t,I&&I in e))&&(F(t)?B:P).test(L(t));var e}function $(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return N(s)?s:void 0}var H=$(d,"WeakMap"),G=Object.create,J=function(){function t(){}return function(e){if(!j(e))return{};if(G)return G(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();function V(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}var X=Date.now;var K,Z,Q,Y=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),tt=Y?function(t,e){return Y(t,"toString",{configurable:!0,enumerable:!1,value:(s=e,function(){return s}),writable:!0});var s}:O,et=(K=tt,Z=0,Q=0,function(){var t=X(),e=16-(t-Q);if(Q=t,e>0){if(++Z>=800)return arguments[0]}else Z=0;return K.apply(void 0,arguments)});var st=9007199254740991,it=/^(?:0|[1-9]\d*)$/;function nt(t,e){var s=typeof t;return!!(e=null==e?st:e)&&("number"==s||"symbol"!=s&&it.test(t))&&t>-1&&t%1==0&&t<e}function rt(t,e,s){"__proto__"==e&&Y?Y(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function ot(t,e){return t===e||t!=t&&e!=e}var at=Object.prototype.hasOwnProperty;function ct(t,e,s){var i=t[e];at.call(t,e)&&ot(i,s)&&(void 0!==s||e in t)||rt(t,e,s)}function ht(t,e,s,i){var n=!s;s||(s={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=i?i(s[a],t[a],a,s,t):void 0;void 0===c&&(c=t[a]),n?rt(s,a,c):ct(s,a,c)}return s}var lt=Math.max;function ut(t,e){return et(function(t,e,s){return e=lt(void 0===e?t.length-1:e,0),function(){for(var i=arguments,n=-1,r=lt(i.length-e,0),o=Array(r);++n<r;)o[n]=i[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=i[n];return a[e]=s(o),function(t,e,s){switch(s.length){case 0:return t.call(e);case 1:return t.call(e,s[0]);case 2:return t.call(e,s[0],s[1]);case 3:return t.call(e,s[0],s[1],s[2])}return t.apply(e,s)}(t,this,a)}}(t,e,O),t+"")}var dt=9007199254740991;function pt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=dt}function ft(t){return null!=t&&pt(t.length)&&!F(t)}var vt=Object.prototype;function yt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||vt)}function gt(t){return T(t)&&"[object Arguments]"==_(t)}var bt=Object.prototype,wt=bt.hasOwnProperty,mt=bt.propertyIsEnumerable,St=gt(function(){return arguments}())?gt:function(t){return T(t)&&wt.call(t,"callee")&&!mt.call(t,"callee")};var _t="object"==typeof t&&t&&!t.nodeType&&t,Tt=_t&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=Tt&&Tt.exports===_t?d.Buffer:void 0,jt=(Ct?Ct.isBuffer:void 0)||function(){return!1},Ot={};function At(t){return function(e){return t(e)}}Ot["[object Float32Array]"]=Ot["[object Float64Array]"]=Ot["[object Int8Array]"]=Ot["[object Int16Array]"]=Ot["[object Int32Array]"]=Ot["[object Uint8Array]"]=Ot["[object Uint8ClampedArray]"]=Ot["[object Uint16Array]"]=Ot["[object Uint32Array]"]=!0,Ot["[object Arguments]"]=Ot["[object Array]"]=Ot["[object ArrayBuffer]"]=Ot["[object Boolean]"]=Ot["[object DataView]"]=Ot["[object Date]"]=Ot["[object Error]"]=Ot["[object Function]"]=Ot["[object Map]"]=Ot["[object Number]"]=Ot["[object Object]"]=Ot["[object RegExp]"]=Ot["[object Set]"]=Ot["[object String]"]=Ot["[object WeakMap]"]=!1;var kt="object"==typeof t&&t&&!t.nodeType&&t,Rt=kt&&"object"==typeof module&&module&&!module.nodeType&&module,Et=Rt&&Rt.exports===kt&&l.process,Ft=function(){try{var t=Rt&&Rt.require&&Rt.require("util").types;return t||Et&&Et.binding&&Et.binding("util")}catch(t){}}(),zt=Ft&&Ft.isTypedArray,xt=zt?At(zt):function(t){return T(t)&&pt(t.length)&&!!Ot[_(t)]},It=Object.prototype.hasOwnProperty;function Mt(t,e){var s=C(t),i=!s&&St(t),n=!s&&!i&&jt(t),r=!s&&!i&&!n&&xt(t),o=s||i||n||r,a=o?function(t,e){for(var s=-1,i=Array(t);++s<t;)i[s]=e(s);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!It.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||nt(h,c))||a.push(h);return a}function Lt(t,e){return function(s){return t(e(s))}}var Pt=Lt(Object.keys,Object),Dt=Object.prototype.hasOwnProperty;function Wt(t){return ft(t)?Mt(t):function(t){if(!yt(t))return Pt(t);var e=[];for(var s in Object(t))Dt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}var qt=Object.prototype.hasOwnProperty;function Ut(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}(t);var e=yt(t),s=[];for(var i in t)("constructor"!=i||!e&&qt.call(t,i))&&s.push(i);return s}function Bt(t){return ft(t)?Mt(t,!0):Ut(t)}var Nt=$(Object,"create");var $t=Object.prototype.hasOwnProperty;var Ht=Object.prototype.hasOwnProperty;function Gt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Jt(t,e){for(var s=t.length;s--;)if(ot(t[s][0],e))return s;return-1}Gt.prototype.clear=function(){this.__data__=Nt?Nt(null):{},this.size=0},Gt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Gt.prototype.get=function(t){var e=this.__data__;if(Nt){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return $t.call(e,t)?e[t]:void 0},Gt.prototype.has=function(t){var e=this.__data__;return Nt?void 0!==e[t]:Ht.call(e,t)},Gt.prototype.set=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Nt&&void 0===e?"__lodash_hash_undefined__":e,this};var Vt=Array.prototype.splice;function Xt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}Xt.prototype.clear=function(){this.__data__=[],this.size=0},Xt.prototype.delete=function(t){var e=this.__data__,s=Jt(e,t);return!(s<0)&&(s==e.length-1?e.pop():Vt.call(e,s,1),--this.size,!0)},Xt.prototype.get=function(t){var e=this.__data__,s=Jt(e,t);return s<0?void 0:e[s][1]},Xt.prototype.has=function(t){return Jt(this.__data__,t)>-1},Xt.prototype.set=function(t,e){var s=this.__data__,i=Jt(s,t);return i<0?(++this.size,s.push([t,e])):s[i][1]=e,this};var Kt=$(d,"Map");function Zt(t,e){var s,i,n=t.__data__;return("string"==(i=typeof(s=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?n["string"==typeof e?"string":"hash"]:n.map}function Qt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Yt(t,e){for(var s=-1,i=e.length,n=t.length;++s<i;)t[n+s]=e[s];return t}Qt.prototype.clear=function(){this.size=0,this.__data__={hash:new Gt,map:new(Kt||Xt),string:new Gt}},Qt.prototype.delete=function(t){var e=Zt(this,t).delete(t);return this.size-=e?1:0,e},Qt.prototype.get=function(t){return Zt(this,t).get(t)},Qt.prototype.has=function(t){return Zt(this,t).has(t)},Qt.prototype.set=function(t,e){var s=Zt(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this};var te=Lt(Object.getPrototypeOf,Object),ee="[object Object]",se=Function.prototype,ie=Object.prototype,ne=se.toString,re=ie.hasOwnProperty,oe=ne.call(Object);function ae(t){var e=this.__data__=new Xt(t);this.size=e.size}ae.prototype.clear=function(){this.__data__=new Xt,this.size=0},ae.prototype.delete=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s},ae.prototype.get=function(t){return this.__data__.get(t)},ae.prototype.has=function(t){return this.__data__.has(t)},ae.prototype.set=function(t,e){var s=this.__data__;if(s instanceof Xt){var i=s.__data__;if(!Kt||i.length<199)return i.push([t,e]),this.size=++s.size,this;s=this.__data__=new Qt(i)}return s.set(t,e),this.size=s.size,this};var ce="object"==typeof t&&t&&!t.nodeType&&t,he=ce&&"object"==typeof module&&module&&!module.nodeType&&module,le=he&&he.exports===ce?d.Buffer:void 0,ue=le?le.allocUnsafe:void 0;function de(t,e){if(e)return t.slice();var s=t.length,i=ue?ue(s):new t.constructor(s);return t.copy(i),i}function pe(){return[]}var fe=Object.prototype.propertyIsEnumerable,ve=Object.getOwnPropertySymbols,ye=ve?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var s=-1,i=null==t?0:t.length,n=0,r=[];++s<i;){var o=t[s];e(o,s,t)&&(r[n++]=o)}return r}(ve(t),(function(e){return fe.call(t,e)})))}:pe;var ge=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Yt(e,ye(t)),t=te(t);return e}:pe;function be(t,e,s){var i=e(t);return C(t)?i:Yt(i,s(t))}function we(t){return be(t,Wt,ye)}function me(t){return be(t,Bt,ge)}var Se=$(d,"DataView"),_e=$(d,"Promise"),Te=$(d,"Set"),Ce="[object Map]",je="[object Promise]",Oe="[object Set]",Ae="[object WeakMap]",ke="[object DataView]",Re=L(Se),Ee=L(Kt),Fe=L(_e),ze=L(Te),xe=L(H),Ie=_;(Se&&Ie(new Se(new ArrayBuffer(1)))!=ke||Kt&&Ie(new Kt)!=Ce||_e&&Ie(_e.resolve())!=je||Te&&Ie(new Te)!=Oe||H&&Ie(new H)!=Ae)&&(Ie=function(t){var e=_(t),s="[object Object]"==e?t.constructor:void 0,i=s?L(s):"";if(i)switch(i){case Re:return ke;case Ee:return Ce;case Fe:return je;case ze:return Oe;case xe:return Ae}return e});var Me=Ie,Le=Object.prototype.hasOwnProperty;var Pe=d.Uint8Array;function De(t){var e=new t.constructor(t.byteLength);return new Pe(e).set(new Pe(t)),e}var We=/\w*$/;var qe=p?p.prototype:void 0,Ue=qe?qe.valueOf:void 0;function Be(t,e){var s=e?De(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}var Ne="[object Boolean]",$e="[object Date]",He="[object Map]",Ge="[object Number]",Je="[object RegExp]",Ve="[object Set]",Xe="[object String]",Ke="[object Symbol]",Ze="[object ArrayBuffer]",Qe="[object DataView]",Ye="[object Float32Array]",ts="[object Float64Array]",es="[object Int8Array]",ss="[object Int16Array]",is="[object Int32Array]",ns="[object Uint8Array]",rs="[object Uint8ClampedArray]",os="[object Uint16Array]",as="[object Uint32Array]";function cs(t,e,s){var i,n,r,o=t.constructor;switch(e){case Ze:return De(t);case Ne:case $e:return new o(+t);case Qe:return function(t,e){var s=e?De(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}(t,s);case Ye:case ts:case es:case ss:case is:case ns:case rs:case os:case as:return Be(t,s);case He:return new o;case Ge:case Xe:return new o(t);case Je:return(r=new(n=t).constructor(n.source,We.exec(n))).lastIndex=n.lastIndex,r;case Ve:return new o;case Ke:return i=t,Ue?Object(Ue.call(i)):{}}}function hs(t){return"function"!=typeof t.constructor||yt(t)?{}:J(te(t))}var ls=Ft&&Ft.isMap,us=ls?At(ls):function(t){return T(t)&&"[object Map]"==Me(t)};var ds=Ft&&Ft.isSet,ps=ds?At(ds):function(t){return T(t)&&"[object Set]"==Me(t)},fs=1,vs=2,ys=4,gs="[object Arguments]",bs="[object Function]",ws="[object GeneratorFunction]",ms="[object Object]",Ss={};function _s(t,e,s,i,n,r){var o,a=e&fs,c=e&vs,h=e&ys;if(s&&(o=n?s(t,i,n,r):s(t)),void 0!==o)return o;if(!j(t))return t;var l=C(t);if(l){if(o=function(t){var e=t.length,s=new t.constructor(e);return e&&"string"==typeof t[0]&&Le.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t),!a)return V(t,o)}else{var u=Me(t),d=u==bs||u==ws;if(jt(t))return de(t,a);if(u==ms||u==gs||d&&!n){if(o=c||d?{}:hs(t),!a)return c?function(t,e){return ht(t,ge(t),e)}(t,function(t,e){return t&&ht(e,Bt(e),t)}(o,t)):function(t,e){return ht(t,ye(t),e)}(t,function(t,e){return t&&ht(e,Wt(e),t)}(o,t))}else{if(!Ss[u])return n?t:{};o=cs(t,u,a)}}r||(r=new ae);var p=r.get(t);if(p)return p;r.set(t,o),ps(t)?t.forEach((function(i){o.add(_s(i,e,s,i,t,r))})):us(t)&&t.forEach((function(i,n){o.set(n,_s(i,e,s,n,t,r))}));var f=l?void 0:(h?c?me:we:c?Bt:Wt)(t);return function(t,e){for(var s=-1,i=null==t?0:t.length;++s<i&&!1!==e(t[s],s,t););}(f||t,(function(i,n){f&&(i=t[n=i]),ct(o,n,_s(i,e,s,n,t,r))})),o}Ss[gs]=Ss["[object Array]"]=Ss["[object ArrayBuffer]"]=Ss["[object DataView]"]=Ss["[object Boolean]"]=Ss["[object Date]"]=Ss["[object Float32Array]"]=Ss["[object Float64Array]"]=Ss["[object Int8Array]"]=Ss["[object Int16Array]"]=Ss["[object Int32Array]"]=Ss["[object Map]"]=Ss["[object Number]"]=Ss[ms]=Ss["[object RegExp]"]=Ss["[object Set]"]=Ss["[object String]"]=Ss["[object Symbol]"]=Ss["[object Uint8Array]"]=Ss["[object Uint8ClampedArray]"]=Ss["[object Uint16Array]"]=Ss["[object Uint32Array]"]=!0,Ss["[object Error]"]=Ss[bs]=Ss["[object WeakMap]"]=!1;function Ts(t){return _s(t,5)}var Cs,js=function(t,e,s){for(var i=-1,n=Object(t),r=s(t),o=r.length;o--;){var a=r[Cs?o:++i];if(!1===e(n[a],a,n))break}return t};function Os(t,e,s){(void 0!==s&&!ot(t[e],s)||void 0===s&&!(e in t))&&rt(t,e,s)}function As(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function ks(t,e,s,i,n,r,o){var a=As(t,s),c=As(e,s),h=o.get(c);if(h)Os(t,s,h);else{var l,u=r?r(a,c,s+"",t,e,o):void 0,d=void 0===u;if(d){var p=C(c),f=!p&&jt(c),v=!p&&!f&&xt(c);u=c,p||f||v?C(a)?u=a:T(l=a)&&ft(l)?u=V(a):f?(d=!1,u=de(c,!0)):v?(d=!1,u=Be(c,!0)):u=[]:function(t){if(!T(t)||_(t)!=ee)return!1;var e=te(t);if(null===e)return!0;var s=re.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&ne.call(s)==oe}(c)||St(c)?(u=a,St(a)?u=function(t){return ht(t,Bt(t))}(a):j(a)&&!F(a)||(u=hs(c))):d=!1}d&&(o.set(c,u),n(u,c,i,r,o),o.delete(c)),Os(t,s,u)}}function Rs(t,e,s,i,n){t!==e&&js(e,(function(r,o){if(n||(n=new ae),j(r))ks(t,e,o,s,Rs,i,n);else{var a=i?i(As(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Os(t,o,a)}}),Bt)}var Es,Fs=(Es=function(t,e,s){Rs(t,e,s)},ut((function(t,e){var s=-1,i=e.length,n=i>1?e[i-1]:void 0,r=i>2?e[2]:void 0;for(n=Es.length>3&&"function"==typeof n?(i--,n):void 0,r&&function(t,e,s){if(!j(s))return!1;var i=typeof e;return!!("number"==i?ft(s)&&nt(e,s.length):"string"==i&&e in s)&&ot(s[e],t)}(e[0],e[1],r)&&(n=i<3?void 0:n,i=1),t=Object(t);++s<i;){var o=e[s];o&&Es(t,o,s,n)}return t})));let zs=null;try{zs=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const xs=t=>zs&&new RegExp(zs).test(t)?(...e)=>console.log(t,...e):()=>{};class Is extends Error{}class Ms extends Error{}const Ls=xs("rpc:ClientManager");class Ps{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");return this.interceptors.response.push(t),()=>{this.interceptors.response=this.interceptors.response.filter((e=>e!==t))}},this.addRequestInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");return this.interceptors.request.push(t),()=>{this.interceptors.request=this.interceptors.request.filter((e=>e!==t))}},this.clearCache=t=>{Ls("clearCache"),this.cache&&this.cache.clearCache(t)},this.getCachedResponse=t=>{var e;return Ls("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Ls("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,s)=>e(this,void 0,void 0,(function*(){Ls("manageClientRequest",t);const i=yield this.interceptRequestMutator(t),n=o(i);if(this.inflightCallsByKey.hasOwnProperty(n))return Ls("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const s=Ts(e);return t.correlationId&&(s.correlationId=t.correlationId),s}));const r=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(i,s),e=yield this.interceptResponseMutator(t,i);return this.cache&&e&&this.cache.setCachedResponse(i,e),e})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Ls("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){var e,s,n,r;let o=t;if(this.interceptors.request.length){Ls("interceptRequestMutator(), original request:",t);try{for(var a,c=!0,h=i(this.interceptors.request);!(e=(a=yield h.next()).done);c=!0){r=a.value,c=!1;const t=r;o=yield t(o)}}catch(t){s={error:t}}finally{try{c||e||!(n=h.return)||(yield n.call(h))}finally{if(s)throw s.error}}}return o})),this.interceptResponseMutator=(t,s)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){Ls("interceptResponseMutator",s,t);for(const i of this.interceptors.response)try{e=yield i(e,s)}catch(i){throw Ls("caught response interceptor, request:",s,"original response:",t,"mutated response:",e),i}}return e})),this.sendRequestWithTransport=(t,s)=>e(this,void 0,void 0,(function*(){var e,i;let n;Ls("sendRequestWithTransport",t);let r=0,o=this.transports;if(null==s?void 0:s.transport){const t=this.transports.find((t=>t.type===s.transport));if(!t)throw new h(`Specified Transport "${s.transport}" not available`);o=[t]}for(;!n&&o[r];){const a=o[r];if(a.isConnected()){Ls(`sendRequestWithTransport trying ${this.transports[r].name}`,t);try{let e;const i=a.sendRequest(t,s||{}),r=new Promise(((i,n)=>{e=setTimeout((()=>{n(new Is(`Procedure ${t.procedure}`))}),(null==s?void 0:s.timeout)||this.options.deadlineMs)}));n=yield Promise.race([r,i]).finally((()=>{clearTimeout(e)}))}catch(s){if(null===(i=(e=this.options).onTransportRequestError)||void 0===i||i.call(e,s,o[r].type,t),!(s instanceof Is||s instanceof Ms))throw s;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${o[r].name} failed ${o[r+1]?`trying next transport "${o[r+1].name}"`:"no more transports to try"}`),r++}}else r++}if(!n&&!this.transports[r])throw console.error(`RPCClient ClientManager#sendRequestWithTransport() ${t.scope}::${t.procedure}::${t.version} did not get a response from any transports`),new h(`Procedure ${t.procedure} did not get a response from any transports`);if(!n)throw new h(`Procedure ${t.procedure} did not get a response from the remote`);return n})),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 Ds{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Ds.DEFAULT_CACHE_MAX_AGE_MS=3e5,Ds.DEFAULT_CACHE_MAX_SIZE=100;var Ws,qs=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const s="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,i=new Set,n="object"==typeof process&&process?process:{},r=(t,e,s,i)=>{"function"==typeof n.emitWarning?n.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let o=globalThis.AbortController,a=globalThis.AbortSignal;if(void 0===o){a=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},o=class{constructor(){e()}signal=new a;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==n.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,r("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const c=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),h=t=>c(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?l:null:null;class l extends Array{constructor(t){super(t),this.fill(0)}}class u{heap;length;static#t=!1;static create(t){const e=h(t);if(!e)return[];u.#t=!0;const s=new u(t,e);return u.#t=!1,s}constructor(t,e){if(!u.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class d{#e;#s;#i;#n;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#w;#m;#S;#_;static unsafeExposeInternals(t){return{starts:t.#b,ttls:t.#w,sizes:t.#g,keyMap:t.#c,keyList:t.#h,valList:t.#l,next:t.#u,prev:t.#d,get head(){return t.#p},get tail(){return t.#f},free:t.#v,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,s,i,n)=>t.#C(e,s,i,n),moveToTail:e=>t.#j(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#r}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:p,dispose:f,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:g,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:m,fetchMethod:S,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:j,ignoreFetchAbort:O}=t;if(0!==e&&!c(e))throw new TypeError("max option must be a nonnegative integer");const A=e?h(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=b,this.maxEntrySize=w||this.#s,this.sizeCalculation=m,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=S,this.#S=!!S,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new A(e),this.#d=new A(e),this.#p=0,this.#f=0,this.#v=u.create(e),this.#o=0,this.#a=0,"function"==typeof f&&(this.#i=f),"function"==typeof v?(this.#n=v,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#m=!!this.#i,this.#_=!!this.#n,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!j,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#s&&!c(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=c(n)||0===n?n:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#E()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";if((t=>!i.has(t))(t)){i.add(t);r("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,d)}}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#E(){const t=new l(this.#e),e=new l(this.#e);this.#w=t,this.#b=e,this.#F=(i,n,r=s.now())=>{if(e[i]=0!==n?r:0,t[i]=n,0!==n&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(i)&&this.delete(this.#h[i])}),n+1);t.unref&&t.unref()}},this.#z=i=>{e[i]=0!==t[i]?s.now():0},this.#x=(s,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;s.ttl=o,s.start=a,s.now=i||n();const c=s.now-a;s.remainingTTL=o-c}};let i=0;const n=()=>{const t=s.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=s=>{const r=this.#c.get(s);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((i||n())-a)},this.#k=s=>{const r=e[s],o=t[s];return!!o&&!!r&&(i||n())-r>o}}#z=()=>{};#x=()=>{};#F=()=>{};#k=()=>!1;#R(){const t=new l(this.#e);this.#a=0,this.#g=t,this.#I=e=>{this.#a-=t[e],t[e]=0},this.#M=(t,e,s,i)=>{if(this.#T(e))return 0;if(!c(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!c(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#L=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#a>s;)this.#P(!0)}this.#a+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#a)}}#I=t=>{};#L=(t,e,s)=>{};#M=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#f;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#d[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#f);)e=this.#u[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}*rvalues(){for(const t of this.#A()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#h[s],this))return this.get(this.#h[s],e)}}forEach(t,e=this){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const i=this.#l[e],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0===n)return;const r={value:n};if(this.#w&&this.#b){const t=this.#w[e],i=this.#b[e];if(t&&i){const e=t-(s.now()-i);r.ttl=e,r.start=Date.now()}}return this.#g&&(r.size=this.#g[e]),r}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const i=this.#h[e],n=this.#l[e],r=this.#T(n)?n.__staleWhileFetching:n;if(void 0===r||void 0===i)continue;const o={value:r};if(this.#w&&this.#b){o.ttl=this.#w[e];const t=s.now()-this.#b[e];o.start=Math.floor(Date.now()-t)}this.#g&&(o.size=this.#g[e]),t.unshift([i,o])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=s.now()-t}this.set(e,i.value,i)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#M(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#o?void 0:this.#c.get(t);if(void 0===l)l=0===this.#o?this.#f:0!==this.#v.length?this.#v.pop():this.#o===this.#e?this.#P(!1):this.#o,this.#h[l]=t,this.#l[l]=e,this.#c.set(t,l),this.#u[this.#f]=l,this.#d[l]=this.#f,this.#f=l,this.#o++,this.#L(l,h,a),a&&(a.set="add"),c=!1;else{this.#j(l);const s=this.#l[l];if(e!==s){if(this.#S&&this.#T(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#m&&this.#i?.(e,t,"set"),this.#_&&this.#y?.push([e,t,"set"]))}else r||(this.#m&&this.#i?.(s,t,"set"),this.#_&&this.#y?.push([s,t,"set"]));if(this.#I(l),this.#L(l,h,a),this.#l[l]=e,a){a.set="replace";const t=s&&this.#T(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#E(),this.#w&&(c||this.#F(l,i,n),a&&this.#x(a,l)),!r&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#l[this.#p];if(this.#P(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#P(t){const e=this.#p,s=this.#h[e],i=this.#l[e];return this.#S&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(i,s,"evict"),this.#_&&this.#y?.push([i,s,"evict"])),this.#I(e),t&&(this.#h[e]=void 0,this.#l[e]=void 0,this.#v.push(e)),1===this.#o?(this.#p=this.#f=0,this.#v.length=0):this.#p=this.#u[e],this.#c.delete(s),this.#o--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#c.get(t);if(void 0!==n){const t=this.#l[n];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(n))return s&&this.#z(n),i&&(i.has="hit",this.#x(i,n)),!0;i&&(i.has="stale",this.#x(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#c.get(t);if(void 0===i||!s&&this.#k(i))return;const n=this.#l[i];return this.#T(n)?n.__staleWhileFetching:n}#C(t,e,s,i){const n=void 0===e?void 0:this.#l[e];if(this.#T(n))return n;const r=new o,{signal:a}=s;a?.addEventListener("abort",(()=>r.abort(a.reason)),{signal:r.signal});const c={signal:r.signal,options:s,context:i},h=(i,n=!1)=>{const{aborted:o}=r.signal,a=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,a&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!a&&!n)return l(r.signal.reason);const h=u;return this.#l[e]===u&&(void 0===i?h.__staleWhileFetching?this.#l[e]=h.__staleWhileFetching:this.delete(t):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,c.options))),i},l=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u){!c||void 0===h.__staleWhileFetching?this.delete(t):o||(this.#l[e]=h.__staleWhileFetching)}if(a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#r?.(t,n,c);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),l(t)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,d,{...c.options,status:void 0}),e=this.#c.get(t)):this.#l[e]=d,d}#T(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof o}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:v=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:y});const b={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:y,signal:g};let w=this.#c.get(t);if(void 0===w){y&&(y.fetch="miss");const e=this.#C(t,w,b,f);return e.__returned=e}{const e=this.#l[w];if(this.#T(e)){const t=s&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#k(w);if(!v&&!n)return y&&(y.fetch="hit"),this.#j(w),i&&this.#z(w),y&&this.#x(y,w),e;const r=this.#C(t,w,b,f),o=void 0!==r.__staleWhileFetching&&s;return y&&(y.fetch=n?"stale":"refresh",o&&n&&(y.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#l[o],a=this.#T(e);return r&&this.#x(r,o),this.#k(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.delete(t),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#j(o),i&&this.#z(o),e))}r&&(r.get="miss")}#W(t,e){this.#d[e]=t,this.#u[t]=e}#j(t){t!==this.#f&&(t===this.#p?this.#p=this.#u[t]:this.#W(this.#d[t],this.#u[t]),this.#W(this.#f,t),this.#f=t)}delete(t){let e=!1;if(0!==this.#o){const s=this.#c.get(t);if(void 0!==s)if(e=!0,1===this.#o)this.clear();else{this.#I(s);const e=this.#l[s];if(this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#h[s]=void 0,this.#l[s]=void 0,s===this.#f)this.#f=this.#d[s];else if(s===this.#p)this.#p=this.#u[s];else{const t=this.#d[s];this.#u[t]=this.#u[s];const e=this.#u[s];this.#d[e]=this.#d[s]}this.#o--,this.#v.push(s)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const s=this.#h[t];this.#m&&this.#i?.(e,s,"delete"),this.#_&&this.#y?.push([e,s,"delete"])}}if(this.#c.clear(),this.#l.fill(void 0),this.#h.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#g&&this.#g.fill(0),this.#p=0,this.#f=0,this.#v.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}e.LRUCache=d}));(Ws=qs)&&Ws.__esModule&&Object.prototype.hasOwnProperty.call(Ws,"default")&&Ws.default;var Us=qs.LRUCache;const Bs=xs("rpc:InMemoryCache");class Ns{constructor(t){this.clearCache=t=>{var e,s;Bs("clearCache"),t?null===(e=this.cachedResponseByParams)||void 0===e||e.delete(o(t)):null===(s=this.cachedResponseByParams)||void 0===s||s.clear()},this.getCachedResponse=t=>{var e;Bs("getCachedResponse, key: ",t);let s=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(o(t));return"string"==typeof s&&(s=JSON.parse(s)),s},this.setCachedResponse=(t,e)=>{var s,i;Bs("setCachedResponse",t,e);const n=o(t);if(!e)return null===(s=this.cachedResponseByParams)||void 0===s?void 0:s.delete(n);const r=Object.assign({},e);delete r.correlationId,null===(i=this.cachedResponseByParams)||void 0===i||i.set(n,r?JSON.stringify(r):void 0)},this.cachedResponseByParams=new Us({max:(null==t?void 0:t.cacheMaxSize)||Ns.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||Ns.DEFAULT_CACHE_MAX_AGE_MS})}}var $s;Ns.DEFAULT_CACHE_MAX_AGE_MS=9e5,Ns.DEFAULT_CACHE_MAX_SIZE=200,function(t){t.http="http",t.websocket="websocket"}($s||($s={}));const Hs=t=>`${t.scope}::${t.procedure}::${t.version}`,Gs=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},Js=xs("rpc:HTTPTransport");class Vs{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.type=$s.http,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,s)=>e(this,void 0,void 0,(function*(){Js("sendRequest",t);try{const e=JSON.stringify(Object.assign({identity:this.identity},t)),s=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"}),i=yield s.text();if(!i)throw new Error("No response received from remote");const n=JSON.parse(i);return new a(n)}catch(e){throw Js("sendRequest() error",e),new Ms(`HTTPTransport request error ${Hs(t)} (${null==e?void 0:e.message})`)}})),this.setIdentity=t=>{Js("setIdentity",t),this.identity=t},this.host=t.host}}class Xs{constructor(t,s){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((i,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error(`PromiseWraper timeout: ${t}`))}),s||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),i(t)}}))))}}const Ks=t=>new Promise((e=>setTimeout(e,t))),Zs=xs("rpc:WebSocketTransport");class Qs{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.type=$s.http,this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e;let s=t;try{s=JSON.stringify({clientMessage:t})}catch(e){console.warn('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}null===(e=this.websocket)||void 0===e||e.send(s)},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){for(Zs("sendRequest",t);this.isWaitingForIdentityConfirmation;)Zs("waiting for identity confirmation"),yield Ks(100);return this.sendCall(t,s)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(Zs("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?Zs('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{Zs("setIdentity with remote complete")})).catch((t=>{Zs("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):Zs("setIdentity is not connected to remote")})),this.subscribeToServerMessages=t=>(this.serverMessageHandlers.push(t),()=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))}),this.unsubscribeFromServerMessages=t=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))},this._connect=()=>{if(Zs("connect",this.host),this.websocket)return void Zs("connect() returning early, websocket already exists");this.websocketId=Math.random(),this.websocket=new WebSocket(this.host);const t=this.websocket;t.onopen=()=>{console.info(`[${(new Date).toLocaleTimeString()}] WebSocket connected`),this.setConnectedToRemote(!0)},t.onmessage=t=>{this.handleWebSocketMsg(t)},t.onclose=t=>{this.connectedToRemote?console.info(`[${(new Date).toLocaleTimeString()}] WebSocket closed`,t.reason||t.code):Zs("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 Ms("Websocket closed"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):Zs("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>{var e;Zs("_disconnect"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,null===(e=this.websocket)||void 0===e||e.close(1e3,t),this.websocket=void 0,this.websocketId=void 0},this.handleServerMessage=t=>{this.serverMessageHandlers.forEach((e=>{try{e(t.serverMessage)}catch(s){console.warn("WebSocketTransport.handleServerMessage() a serverMessageHandler errored when calling",t,"handler func:",e),console.error(s)}}))},this.handleWebSocketMsg=t=>{let e;Zs("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){console.error("error parsing WS msg",t)}if("serverMessage"in e)return void this.handleServerMessage(e);const s=new a(e);if(!s.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const i=this.pendingPromisesForResponse[s.correlationId];i?i.resolve(s):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>e(this,void 0,void 0,(function*(){Zs("resetConnection"),this._disconnect("WebSocketTransport#resetConnection"),yield Ks(100),this._connect()})),this.sendCall=(t,s)=>e(this,void 0,void 0,(function*(){var e;Zs("sendCall",t);const i=Math.random().toString();t.correlationId=t.correlationId||i;let n=new Xs(Hs(t),s.timeout||this.options.rpcOptions.deadlineMs);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=>{Zs(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},Zs("new WebSocketTransport()"),this.host=t.host,this.connect()}}class Ys{constructor(){this.events={},this.publish=(t,s)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,s)}))})),this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>this.unsubscribe(t,e)),this.unsubscribe=(t,e)=>{if(!this.events[t])return;let s=this.events[t].indexOf(e);this.events[t].splice(s)}}}const ti={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class ei{constructor(t){var s,i,r,a,h,l;if(this.options=t,this.webSocketConnectionChangeListeners=[],this.vent=new Ys,this.onWebSocketConnectionStatusChange=t=>{this.options.onWebSocketConnectionStatusChange&&this.options.onWebSocketConnectionStatusChange(t),this.webSocketConnectionChangeListeners.forEach((e=>e(t)))},this.call=(t,s,i)=>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?Gs(t):t,s&&(e.args=s);const r=new n(e);if(!r.procedure&&!r.identity)throw new TypeError('RPCClient#call requires a "identity" or "procedure" prop and received neither');r.identity||(r.identity={}),r.identity=Fs(Object.assign({},this.identity),r.identity);const a=yield this.callManager.manageClientRequest(r,i);if(!a.success)throw new c(a,r,i);const h=o(e);return this.vent.publish(h,null==a?void 0:a.data),a})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let s;s="string"==typeof t?Gs(t):t,e&&(s.args=e);const i=this.callManager.getCachedResponse(s);if(i)return i},this.getIdentity=()=>this.identity?Ts(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 s;return s="string"==typeof t?Gs(t):t,function(t){return e.call(Object.assign(Object.assign({},s),{args:t}))}},this.registerResponseInterceptor=t=>this.callManager.addResponseInterceptor(t),this.registerRequestInterceptor=t=>this.callManager.addRequestInterceptor(t),this.registerWebSocketConnectionStatusChangeListener=t=>(this.webSocketConnectionChangeListeners.push(t),()=>{this.webSocketConnectionChangeListeners=this.webSocketConnectionChangeListeners.filter((e=>e!==t))}),this.sendClientMessageToServer=t=>{this.webSocketTransport?this.webSocketTransport.isConnected()?this.webSocketTransport.sendClientMessageToServer(t):console.info("RPCClient.sendClientMessageToServer() cannot send because the websocket is not connected"):console.warn("RPCClient.sendClientMessageToServer() unable to send because RPCClient has no websocket configuration")},this.setIdentity=t=>{let e=Ts(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const s=Ts(this.identity);s.metadata=t,this.identity.metadata=t,this.callManager.setIdentity(s)},this.transports=()=>({http:this.httpTransport,websocket:this.webSocketTransport}),!(null===(s=null==t?void 0:t.hosts)||void 0===s?void 0:s.http)&&!(null===(i=null==t?void 0:t.transports)||void 0===i?void 0:i.http))throw new Error(ti.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(ti.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(ti.INTERCEPTOR_MUSTBE_FUNC);let u;const d={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};u="browser"==t.cacheType?new Ds(d):new Ns(d);const p=[];(null===(r=t.transports)||void 0===r?void 0:r.websocket)?p.push(t.transports.websocket):(null===(a=null==t?void 0:t.hosts)||void 0===a?void 0:a.websocket)&&(this.webSocketTransport=new Qs({host:t.hosts.websocket,onConnectionStatusChange:this.onWebSocketConnectionStatusChange,rpcOptions:t}),p.push(this.webSocketTransport)),(null===(h=t.transports)||void 0===h?void 0:h.http)?p.push(t.transports.http):(null===(l=null==t?void 0:t.hosts)||void 0===l?void 0:l.http)&&(this.httpTransport=new Vs({host:t.hosts.http,rpcOptions:t}),p.push(this.httpTransport)),this.callManager=new Ps({cache:u,deadlineMs:t.deadlineMs||ei.DEFAULT_DEADLINE_MS,onTransportRequestError:t.onTransportRequestError,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:p})}subscribe(t,e){const s="string"==typeof t.request?Gs(t.request):t.request,i=o(Object.assign(Object.assign({},s),{args:t.args}));return this.vent.subscribe(i,e)}unsubscribe(t,e){const s="string"==typeof t.request?Gs(t.request):t.request,i=o(Object.assign(Object.assign({},s),{args:t.args}));this.vent.unsubscribe(i,e)}subscribeToServerMessages(t){return this.webSocketTransport?this.webSocketTransport.subscribeToServerMessages(t):(console.warn("RPCClient.subscribeToServerMessages() cannot subscribe because RPCClient has no websocket configuration"),()=>{})}unsubscribeFromServerMessages(t){var e;null===(e=this.webSocketTransport)||void 0===e||e.unsubscribeFromServerMessages(t)}}ei.DEFAULT_DEADLINE_MS=1e4,t.CallRequestTransportError=Ms,t.CallRequestTransportTimeoutError=Is,t.CallResponseError=c,t.RPCClient=ei,t.RPCResponse=a}));
!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";function e(t,e,s,i){return new(s||(s=Promise))((function(n,r){function o(t){try{c(i.next(t))}catch(t){r(t)}}function a(t){try{c(i.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((i=i.apply(t,e||[])).next())}))}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,s=e&&t[e],i=0;if(s)return s.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=t[Symbol.asyncIterator];return i?i.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=t[s]&&function(e){return new Promise((function(i,n){(function(t,e,s,i){Promise.resolve(i).then((function(e){t({value:e,done:s})}),e)})(i,n,(e=t[s](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){const{args:e,correlationId:s,identity:i,procedure:n,scope:r,version:o}=t;if(this.args=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s||Math.random().toString(),i){if("object"!=typeof i)throw new Error("identity must be an object");if(i.authorization&&"string"!=typeof i.authorization)throw new Error("identity.authorization must be a string");if(i.deviceName&&"string"!=typeof i.deviceName)throw new Error("identity.deviceName must be a string");if(i.metadata&&"object"!=typeof i.metadata)throw new Error("identity.metadata must be a object");this.identity=i}if(n&&"string"!=typeof n)throw new Error("procedure must be string");if(this.procedure=n,r&&"string"!=typeof r)throw new Error("scope must be string");if(this.scope=r,o&&"string"!=typeof o)throw new Error("version must be string");this.version=o}}function r(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const o=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var s,i="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(s=e.cmp,function(t){return function(e,i){var n={key:e,value:t[e]},r={key:i,value:t[i]};return s(n,r)}}),r=[];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 s,o;if(Array.isArray(e)){for(o="[",s=0;s<e.length;s++)s&&(o+=","),o+=t(e[s])||"null";return o+"]"}if(null===e)return"null";if(-1!==r.indexOf(e)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=r.push(e)-1,c=Object.keys(e).sort(n&&n(e));for(o="",s=0;s<c.length;s++){var h=c[s],l=t(e[h]);l&&(o&&(o+=","),o+=JSON.stringify(h)+":"+l)}return r.splice(a,1),"{"+o+"}"}}(t)}(function(t,e={}){if(!r(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:s,compare:i}=e,n=[],o=[],a=t=>{const e=n.indexOf(t);if(-1!==e)return o[e];const s=[];return n.push(t),o.push(s),s.push(...t.map((t=>Array.isArray(t)?a(t):r(t)?c(t):t))),s},c=t=>{const e=n.indexOf(t);if(-1!==e)return o[e];const h={},l=Object.keys(t).sort(i);n.push(t),o.push(h);for(const e of l){const i=t[e];let n;n=s&&Array.isArray(i)?a(i):s&&r(i)?c(i):i,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:n}))}return h};return Array.isArray(t)?s?a(t):t.slice():c(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;class a{constructor(t){const{code:e,correlationId:s,data:i,message:n,success:r}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,s&&"string"!=typeof s)throw new Error("correlationId must be a string");if(this.correlationId=s,this.data=i,n&&"string"!=typeof n)throw new Error("message must be a string");if(this.message=n,"boolean"!=typeof r)throw new Error("success must be a boolean");this.success=r}}class c extends Error{constructor(t,e,s){super(t.message),this.response={code:0,success:!1},this.name="CallResponseError";const{code:i,correlationId:n,message:r}=t;this.response.code=i,this.response.correlationId=n,this.response.data=t.data,this.response.message=`${o(e)} response error: `+(r||"RPC call failed with no message"),this.request=e,this.callOptions=s}}class h extends Error{}var l="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,d=l||u||Function("return this")(),p=d.Symbol,f=Object.prototype,v=f.hasOwnProperty,y=f.toString,g=p?p.toStringTag:void 0;var b=Object.prototype.toString;var w="[object Null]",m="[object Undefined]",S=p?p.toStringTag:void 0;function _(t){return null==t?void 0===t?m:w:S&&S in Object(t)?function(t){var e=v.call(t,g),s=t[g];try{t[g]=void 0;var i=!0}catch(t){}var n=y.call(t);return i&&(e?t[g]=s:delete t[g]),n}(t):function(t){return b.call(t)}(t)}function T(t){return null!=t&&"object"==typeof t}var C=Array.isArray;function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function O(t){return t}var A="[object AsyncFunction]",k="[object Function]",R="[object GeneratorFunction]",E="[object Proxy]";function F(t){if(!j(t))return!1;var e=_(t);return e==k||e==R||e==A||e==E}var z,x=d["__core-js_shared__"],M=(z=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"";var I=Function.prototype.toString;function L(t){if(null!=t){try{return I.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var P=/^\[object .+?Constructor\]$/,D=Function.prototype,W=Object.prototype,q=D.toString,U=W.hasOwnProperty,B=RegExp("^"+q.call(U).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function N(t){return!(!j(t)||(e=t,M&&M in e))&&(F(t)?B:P).test(L(t));var e}function $(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return N(s)?s:void 0}var H=$(d,"WeakMap"),G=Object.create,J=function(){function t(){}return function(e){if(!j(e))return{};if(G)return G(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();function V(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}var X=Date.now;var K,Z,Q,Y=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),tt=Y?function(t,e){return Y(t,"toString",{configurable:!0,enumerable:!1,value:(s=e,function(){return s}),writable:!0});var s}:O,et=(K=tt,Z=0,Q=0,function(){var t=X(),e=16-(t-Q);if(Q=t,e>0){if(++Z>=800)return arguments[0]}else Z=0;return K.apply(void 0,arguments)});var st=9007199254740991,it=/^(?:0|[1-9]\d*)$/;function nt(t,e){var s=typeof t;return!!(e=null==e?st:e)&&("number"==s||"symbol"!=s&&it.test(t))&&t>-1&&t%1==0&&t<e}function rt(t,e,s){"__proto__"==e&&Y?Y(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function ot(t,e){return t===e||t!=t&&e!=e}var at=Object.prototype.hasOwnProperty;function ct(t,e,s){var i=t[e];at.call(t,e)&&ot(i,s)&&(void 0!==s||e in t)||rt(t,e,s)}function ht(t,e,s,i){var n=!s;s||(s={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=i?i(s[a],t[a],a,s,t):void 0;void 0===c&&(c=t[a]),n?rt(s,a,c):ct(s,a,c)}return s}var lt=Math.max;function ut(t,e){return et(function(t,e,s){return e=lt(void 0===e?t.length-1:e,0),function(){for(var i=arguments,n=-1,r=lt(i.length-e,0),o=Array(r);++n<r;)o[n]=i[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=i[n];return a[e]=s(o),function(t,e,s){switch(s.length){case 0:return t.call(e);case 1:return t.call(e,s[0]);case 2:return t.call(e,s[0],s[1]);case 3:return t.call(e,s[0],s[1],s[2])}return t.apply(e,s)}(t,this,a)}}(t,e,O),t+"")}var dt=9007199254740991;function pt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=dt}function ft(t){return null!=t&&pt(t.length)&&!F(t)}var vt=Object.prototype;function yt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||vt)}function gt(t){return T(t)&&"[object Arguments]"==_(t)}var bt=Object.prototype,wt=bt.hasOwnProperty,mt=bt.propertyIsEnumerable,St=gt(function(){return arguments}())?gt:function(t){return T(t)&&wt.call(t,"callee")&&!mt.call(t,"callee")};var _t="object"==typeof t&&t&&!t.nodeType&&t,Tt=_t&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=Tt&&Tt.exports===_t?d.Buffer:void 0,jt=(Ct?Ct.isBuffer:void 0)||function(){return!1},Ot={};function At(t){return function(e){return t(e)}}Ot["[object Float32Array]"]=Ot["[object Float64Array]"]=Ot["[object Int8Array]"]=Ot["[object Int16Array]"]=Ot["[object Int32Array]"]=Ot["[object Uint8Array]"]=Ot["[object Uint8ClampedArray]"]=Ot["[object Uint16Array]"]=Ot["[object Uint32Array]"]=!0,Ot["[object Arguments]"]=Ot["[object Array]"]=Ot["[object ArrayBuffer]"]=Ot["[object Boolean]"]=Ot["[object DataView]"]=Ot["[object Date]"]=Ot["[object Error]"]=Ot["[object Function]"]=Ot["[object Map]"]=Ot["[object Number]"]=Ot["[object Object]"]=Ot["[object RegExp]"]=Ot["[object Set]"]=Ot["[object String]"]=Ot["[object WeakMap]"]=!1;var kt="object"==typeof t&&t&&!t.nodeType&&t,Rt=kt&&"object"==typeof module&&module&&!module.nodeType&&module,Et=Rt&&Rt.exports===kt&&l.process,Ft=function(){try{var t=Rt&&Rt.require&&Rt.require("util").types;return t||Et&&Et.binding&&Et.binding("util")}catch(t){}}(),zt=Ft&&Ft.isTypedArray,xt=zt?At(zt):function(t){return T(t)&&pt(t.length)&&!!Ot[_(t)]},Mt=Object.prototype.hasOwnProperty;function It(t,e){var s=C(t),i=!s&&St(t),n=!s&&!i&&jt(t),r=!s&&!i&&!n&&xt(t),o=s||i||n||r,a=o?function(t,e){for(var s=-1,i=Array(t);++s<t;)i[s]=e(s);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!Mt.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||nt(h,c))||a.push(h);return a}function Lt(t,e){return function(s){return t(e(s))}}var Pt=Lt(Object.keys,Object),Dt=Object.prototype.hasOwnProperty;function Wt(t){return ft(t)?It(t):function(t){if(!yt(t))return Pt(t);var e=[];for(var s in Object(t))Dt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}var qt=Object.prototype.hasOwnProperty;function Ut(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}(t);var e=yt(t),s=[];for(var i in t)("constructor"!=i||!e&&qt.call(t,i))&&s.push(i);return s}function Bt(t){return ft(t)?It(t,!0):Ut(t)}var Nt=$(Object,"create");var $t=Object.prototype.hasOwnProperty;var Ht=Object.prototype.hasOwnProperty;function Gt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Jt(t,e){for(var s=t.length;s--;)if(ot(t[s][0],e))return s;return-1}Gt.prototype.clear=function(){this.__data__=Nt?Nt(null):{},this.size=0},Gt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Gt.prototype.get=function(t){var e=this.__data__;if(Nt){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return $t.call(e,t)?e[t]:void 0},Gt.prototype.has=function(t){var e=this.__data__;return Nt?void 0!==e[t]:Ht.call(e,t)},Gt.prototype.set=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Nt&&void 0===e?"__lodash_hash_undefined__":e,this};var Vt=Array.prototype.splice;function Xt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}Xt.prototype.clear=function(){this.__data__=[],this.size=0},Xt.prototype.delete=function(t){var e=this.__data__,s=Jt(e,t);return!(s<0)&&(s==e.length-1?e.pop():Vt.call(e,s,1),--this.size,!0)},Xt.prototype.get=function(t){var e=this.__data__,s=Jt(e,t);return s<0?void 0:e[s][1]},Xt.prototype.has=function(t){return Jt(this.__data__,t)>-1},Xt.prototype.set=function(t,e){var s=this.__data__,i=Jt(s,t);return i<0?(++this.size,s.push([t,e])):s[i][1]=e,this};var Kt=$(d,"Map");function Zt(t,e){var s,i,n=t.__data__;return("string"==(i=typeof(s=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?n["string"==typeof e?"string":"hash"]:n.map}function Qt(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Yt(t,e){for(var s=-1,i=e.length,n=t.length;++s<i;)t[n+s]=e[s];return t}Qt.prototype.clear=function(){this.size=0,this.__data__={hash:new Gt,map:new(Kt||Xt),string:new Gt}},Qt.prototype.delete=function(t){var e=Zt(this,t).delete(t);return this.size-=e?1:0,e},Qt.prototype.get=function(t){return Zt(this,t).get(t)},Qt.prototype.has=function(t){return Zt(this,t).has(t)},Qt.prototype.set=function(t,e){var s=Zt(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this};var te=Lt(Object.getPrototypeOf,Object),ee="[object Object]",se=Function.prototype,ie=Object.prototype,ne=se.toString,re=ie.hasOwnProperty,oe=ne.call(Object);function ae(t){var e=this.__data__=new Xt(t);this.size=e.size}ae.prototype.clear=function(){this.__data__=new Xt,this.size=0},ae.prototype.delete=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s},ae.prototype.get=function(t){return this.__data__.get(t)},ae.prototype.has=function(t){return this.__data__.has(t)},ae.prototype.set=function(t,e){var s=this.__data__;if(s instanceof Xt){var i=s.__data__;if(!Kt||i.length<199)return i.push([t,e]),this.size=++s.size,this;s=this.__data__=new Qt(i)}return s.set(t,e),this.size=s.size,this};var ce="object"==typeof t&&t&&!t.nodeType&&t,he=ce&&"object"==typeof module&&module&&!module.nodeType&&module,le=he&&he.exports===ce?d.Buffer:void 0,ue=le?le.allocUnsafe:void 0;function de(t,e){if(e)return t.slice();var s=t.length,i=ue?ue(s):new t.constructor(s);return t.copy(i),i}function pe(){return[]}var fe=Object.prototype.propertyIsEnumerable,ve=Object.getOwnPropertySymbols,ye=ve?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var s=-1,i=null==t?0:t.length,n=0,r=[];++s<i;){var o=t[s];e(o,s,t)&&(r[n++]=o)}return r}(ve(t),(function(e){return fe.call(t,e)})))}:pe;var ge=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Yt(e,ye(t)),t=te(t);return e}:pe;function be(t,e,s){var i=e(t);return C(t)?i:Yt(i,s(t))}function we(t){return be(t,Wt,ye)}function me(t){return be(t,Bt,ge)}var Se=$(d,"DataView"),_e=$(d,"Promise"),Te=$(d,"Set"),Ce="[object Map]",je="[object Promise]",Oe="[object Set]",Ae="[object WeakMap]",ke="[object DataView]",Re=L(Se),Ee=L(Kt),Fe=L(_e),ze=L(Te),xe=L(H),Me=_;(Se&&Me(new Se(new ArrayBuffer(1)))!=ke||Kt&&Me(new Kt)!=Ce||_e&&Me(_e.resolve())!=je||Te&&Me(new Te)!=Oe||H&&Me(new H)!=Ae)&&(Me=function(t){var e=_(t),s="[object Object]"==e?t.constructor:void 0,i=s?L(s):"";if(i)switch(i){case Re:return ke;case Ee:return Ce;case Fe:return je;case ze:return Oe;case xe:return Ae}return e});var Ie=Me,Le=Object.prototype.hasOwnProperty;var Pe=d.Uint8Array;function De(t){var e=new t.constructor(t.byteLength);return new Pe(e).set(new Pe(t)),e}var We=/\w*$/;var qe=p?p.prototype:void 0,Ue=qe?qe.valueOf:void 0;function Be(t,e){var s=e?De(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}var Ne="[object Boolean]",$e="[object Date]",He="[object Map]",Ge="[object Number]",Je="[object RegExp]",Ve="[object Set]",Xe="[object String]",Ke="[object Symbol]",Ze="[object ArrayBuffer]",Qe="[object DataView]",Ye="[object Float32Array]",ts="[object Float64Array]",es="[object Int8Array]",ss="[object Int16Array]",is="[object Int32Array]",ns="[object Uint8Array]",rs="[object Uint8ClampedArray]",os="[object Uint16Array]",as="[object Uint32Array]";function cs(t,e,s){var i,n,r,o=t.constructor;switch(e){case Ze:return De(t);case Ne:case $e:return new o(+t);case Qe:return function(t,e){var s=e?De(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}(t,s);case Ye:case ts:case es:case ss:case is:case ns:case rs:case os:case as:return Be(t,s);case He:return new o;case Ge:case Xe:return new o(t);case Je:return(r=new(n=t).constructor(n.source,We.exec(n))).lastIndex=n.lastIndex,r;case Ve:return new o;case Ke:return i=t,Ue?Object(Ue.call(i)):{}}}function hs(t){return"function"!=typeof t.constructor||yt(t)?{}:J(te(t))}var ls=Ft&&Ft.isMap,us=ls?At(ls):function(t){return T(t)&&"[object Map]"==Ie(t)};var ds=Ft&&Ft.isSet,ps=ds?At(ds):function(t){return T(t)&&"[object Set]"==Ie(t)},fs=1,vs=2,ys=4,gs="[object Arguments]",bs="[object Function]",ws="[object GeneratorFunction]",ms="[object Object]",Ss={};function _s(t,e,s,i,n,r){var o,a=e&fs,c=e&vs,h=e&ys;if(s&&(o=n?s(t,i,n,r):s(t)),void 0!==o)return o;if(!j(t))return t;var l=C(t);if(l){if(o=function(t){var e=t.length,s=new t.constructor(e);return e&&"string"==typeof t[0]&&Le.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t),!a)return V(t,o)}else{var u=Ie(t),d=u==bs||u==ws;if(jt(t))return de(t,a);if(u==ms||u==gs||d&&!n){if(o=c||d?{}:hs(t),!a)return c?function(t,e){return ht(t,ge(t),e)}(t,function(t,e){return t&&ht(e,Bt(e),t)}(o,t)):function(t,e){return ht(t,ye(t),e)}(t,function(t,e){return t&&ht(e,Wt(e),t)}(o,t))}else{if(!Ss[u])return n?t:{};o=cs(t,u,a)}}r||(r=new ae);var p=r.get(t);if(p)return p;r.set(t,o),ps(t)?t.forEach((function(i){o.add(_s(i,e,s,i,t,r))})):us(t)&&t.forEach((function(i,n){o.set(n,_s(i,e,s,n,t,r))}));var f=l?void 0:(h?c?me:we:c?Bt:Wt)(t);return function(t,e){for(var s=-1,i=null==t?0:t.length;++s<i&&!1!==e(t[s],s,t););}(f||t,(function(i,n){f&&(i=t[n=i]),ct(o,n,_s(i,e,s,n,t,r))})),o}Ss[gs]=Ss["[object Array]"]=Ss["[object ArrayBuffer]"]=Ss["[object DataView]"]=Ss["[object Boolean]"]=Ss["[object Date]"]=Ss["[object Float32Array]"]=Ss["[object Float64Array]"]=Ss["[object Int8Array]"]=Ss["[object Int16Array]"]=Ss["[object Int32Array]"]=Ss["[object Map]"]=Ss["[object Number]"]=Ss[ms]=Ss["[object RegExp]"]=Ss["[object Set]"]=Ss["[object String]"]=Ss["[object Symbol]"]=Ss["[object Uint8Array]"]=Ss["[object Uint8ClampedArray]"]=Ss["[object Uint16Array]"]=Ss["[object Uint32Array]"]=!0,Ss["[object Error]"]=Ss[bs]=Ss["[object WeakMap]"]=!1;function Ts(t){return _s(t,5)}var Cs,js=function(t,e,s){for(var i=-1,n=Object(t),r=s(t),o=r.length;o--;){var a=r[Cs?o:++i];if(!1===e(n[a],a,n))break}return t};function Os(t,e,s){(void 0!==s&&!ot(t[e],s)||void 0===s&&!(e in t))&&rt(t,e,s)}function As(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function ks(t,e,s,i,n,r,o){var a=As(t,s),c=As(e,s),h=o.get(c);if(h)Os(t,s,h);else{var l,u=r?r(a,c,s+"",t,e,o):void 0,d=void 0===u;if(d){var p=C(c),f=!p&&jt(c),v=!p&&!f&&xt(c);u=c,p||f||v?C(a)?u=a:T(l=a)&&ft(l)?u=V(a):f?(d=!1,u=de(c,!0)):v?(d=!1,u=Be(c,!0)):u=[]:function(t){if(!T(t)||_(t)!=ee)return!1;var e=te(t);if(null===e)return!0;var s=re.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&ne.call(s)==oe}(c)||St(c)?(u=a,St(a)?u=function(t){return ht(t,Bt(t))}(a):j(a)&&!F(a)||(u=hs(c))):d=!1}d&&(o.set(c,u),n(u,c,i,r,o),o.delete(c)),Os(t,s,u)}}function Rs(t,e,s,i,n){t!==e&&js(e,(function(r,o){if(n||(n=new ae),j(r))ks(t,e,o,s,Rs,i,n);else{var a=i?i(As(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Os(t,o,a)}}),Bt)}var Es,Fs=(Es=function(t,e,s){Rs(t,e,s)},ut((function(t,e){var s=-1,i=e.length,n=i>1?e[i-1]:void 0,r=i>2?e[2]:void 0;for(n=Es.length>3&&"function"==typeof n?(i--,n):void 0,r&&function(t,e,s){if(!j(s))return!1;var i=typeof e;return!!("number"==i?ft(s)&&nt(e,s.length):"string"==i&&e in s)&&ot(s[e],t)}(e[0],e[1],r)&&(n=i<3?void 0:n,i=1),t=Object(t);++s<i;){var o=e[s];o&&Es(t,o,s,n)}return t})));let zs=null;try{zs=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const xs=t=>zs&&new RegExp(zs).test(t)?(...e)=>console.log(t,...e):()=>{};class Ms extends Error{}class Is extends Error{}const Ls=xs("rpc:ClientManager");class Ps{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");return this.interceptors.response.push(t),()=>{this.interceptors.response=this.interceptors.response.filter((e=>e!==t))}},this.addRequestInterceptor=t=>{if("function"!=typeof t)throw new Error("cannot add interceptor that is not a function");return this.interceptors.request.push(t),()=>{this.interceptors.request=this.interceptors.request.filter((e=>e!==t))}},this.clearCache=t=>{Ls("clearCache"),this.cache&&this.cache.clearCache(t)},this.getCachedResponse=t=>{var e;return Ls("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Ls("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,s)=>e(this,void 0,void 0,(function*(){Ls("manageClientRequest",t);const i=yield this.interceptRequestMutator(t),n=o(i);if(this.inflightCallsByKey.hasOwnProperty(n))return Ls("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const s=Ts(e);return t.correlationId&&(s.correlationId=t.correlationId),s}));const r=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(i,s),e=yield this.interceptResponseMutator(t,i);return this.cache&&e&&this.cache.setCachedResponse(i,e),e})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Ls("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){var e,s,n,r;let o=t;if(this.interceptors.request.length){Ls("interceptRequestMutator(), original request:",t);try{for(var a,c=!0,h=i(this.interceptors.request);!(e=(a=yield h.next()).done);c=!0){r=a.value,c=!1;const t=r;o=yield t(o)}}catch(t){s={error:t}}finally{try{c||e||!(n=h.return)||(yield n.call(h))}finally{if(s)throw s.error}}}return o})),this.interceptResponseMutator=(t,s)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){Ls("interceptResponseMutator",s,t);for(const i of this.interceptors.response)try{e=yield i(e,s)}catch(i){throw Ls("caught response interceptor, request:",s,"original response:",t,"mutated response:",e),i}}return e})),this.sendRequestWithTransport=(t,s)=>e(this,void 0,void 0,(function*(){var e,i;let n;Ls("sendRequestWithTransport",t);let r=0,o=this.transports;if(null==s?void 0:s.transport){const t=this.transports.find((t=>t.type===s.transport));if(!t)throw new h(`Specified Transport "${s.transport}" not available`);o=[t]}for(;!n&&o[r];){const a=o[r];if(a.isConnected()){Ls(`sendRequestWithTransport trying ${this.transports[r].name}`,t);try{let e;const i=a.sendRequest(t,s||{}),r=new Promise(((i,n)=>{e=setTimeout((()=>{n(new Ms(`Procedure ${t.procedure}`))}),(null==s?void 0:s.timeout)||this.options.deadlineMs)}));n=yield Promise.race([r,i]).finally((()=>{clearTimeout(e)}))}catch(s){if(null===(i=(e=this.options).onTransportRequestError)||void 0===i||i.call(e,s,o[r].type,t),!(s instanceof Ms||s instanceof Is))throw s;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${o[r].name} failed ${o[r+1]?`trying next transport "${o[r+1].name}"`:"no more transports to try"}`),r++}}else r++}if(!n&&!this.transports[r])throw console.error(`RPCClient ClientManager#sendRequestWithTransport() ${t.scope}::${t.procedure}::${t.version} did not get a response from any transports`),new h(`Procedure ${t.procedure} did not get a response from any transports`);if(!n)throw new h(`Procedure ${t.procedure} did not get a response from the remote`);return n})),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 Ds{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Ds.DEFAULT_CACHE_MAX_AGE_MS=3e5,Ds.DEFAULT_CACHE_MAX_SIZE=100;var Ws,qs=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const s="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,i=new Set,n="object"==typeof process&&process?process:{},r=(t,e,s,i)=>{"function"==typeof n.emitWarning?n.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let o=globalThis.AbortController,a=globalThis.AbortSignal;if(void 0===o){a=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},o=class{constructor(){e()}signal=new a;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==n.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,r("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}const c=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),h=t=>c(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?l:null:null;class l extends Array{constructor(t){super(t),this.fill(0)}}class u{heap;length;static#t=!1;static create(t){const e=h(t);if(!e)return[];u.#t=!0;const s=new u(t,e);return u.#t=!1,s}constructor(t,e){if(!u.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class d{#e;#s;#i;#n;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#w;#m;#S;#_;static unsafeExposeInternals(t){return{starts:t.#b,ttls:t.#w,sizes:t.#g,keyMap:t.#c,keyList:t.#h,valList:t.#l,next:t.#u,prev:t.#d,get head(){return t.#p},get tail(){return t.#f},free:t.#v,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,s,i,n)=>t.#C(e,s,i,n),moveToTail:e=>t.#j(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#r}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:p,dispose:f,disposeAfter:v,noDisposeOnSet:y,noUpdateTTL:g,maxSize:b=0,maxEntrySize:w=0,sizeCalculation:m,fetchMethod:S,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:j,ignoreFetchAbort:O}=t;if(0!==e&&!c(e))throw new TypeError("max option must be a nonnegative integer");const A=e?h(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=b,this.maxEntrySize=w||this.#s,this.sizeCalculation=m,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==S&&"function"!=typeof S)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=S,this.#S=!!S,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new A(e),this.#d=new A(e),this.#p=0,this.#f=0,this.#v=u.create(e),this.#o=0,this.#a=0,"function"==typeof f&&(this.#i=f),"function"==typeof v?(this.#n=v,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#m=!!this.#i,this.#_=!!this.#n,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!j,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#s&&!c(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!c(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=c(n)||0===n?n:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!c(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#E()}if(0===this.#e&&0===this.ttl&&0===this.#s)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#s){const t="LRU_CACHE_UNBOUNDED";if((t=>!i.has(t))(t)){i.add(t);r("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,d)}}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#E(){const t=new l(this.#e),e=new l(this.#e);this.#w=t,this.#b=e,this.#F=(i,n,r=s.now())=>{if(e[i]=0!==n?r:0,t[i]=n,0!==n&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(i)&&this.delete(this.#h[i])}),n+1);t.unref&&t.unref()}},this.#z=i=>{e[i]=0!==t[i]?s.now():0},this.#x=(s,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;s.ttl=o,s.start=a,s.now=i||n();const c=s.now-a;s.remainingTTL=o-c}};let i=0;const n=()=>{const t=s.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=s=>{const r=this.#c.get(s);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((i||n())-a)},this.#k=s=>{const r=e[s],o=t[s];return!!o&&!!r&&(i||n())-r>o}}#z=()=>{};#x=()=>{};#F=()=>{};#k=()=>!1;#R(){const t=new l(this.#e);this.#a=0,this.#g=t,this.#M=e=>{this.#a-=t[e],t[e]=0},this.#I=(t,e,s,i)=>{if(this.#T(e))return 0;if(!c(s)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(s=i(e,t),!c(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#L=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#a>s;)this.#P(!0)}this.#a+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#a)}}#M=t=>{};#L=(t,e,s)=>{};#I=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#f;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#d[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#f);)e=this.#u[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}*rvalues(){for(const t of this.#A()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#h[s],this))return this.get(this.#h[s],e)}}forEach(t,e=this){for(const s of this.#O()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}rforEach(t,e=this){for(const s of this.#A()){const i=this.#l[s],n=this.#T(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#h[s],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}info(t){const e=this.#c.get(t);if(void 0===e)return;const i=this.#l[e],n=this.#T(i)?i.__staleWhileFetching:i;if(void 0===n)return;const r={value:n};if(this.#w&&this.#b){const t=this.#w[e],i=this.#b[e];if(t&&i){const e=t-(s.now()-i);r.ttl=e,r.start=Date.now()}}return this.#g&&(r.size=this.#g[e]),r}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const i=this.#h[e],n=this.#l[e],r=this.#T(n)?n.__staleWhileFetching:n;if(void 0===r||void 0===i)continue;const o={value:r};if(this.#w&&this.#b){o.ttl=this.#w[e];const t=s.now()-this.#b[e];o.start=Math.floor(Date.now()-t)}this.#g&&(o.size=this.#g[e]),t.unshift([i,o])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=s.now()-t}this.set(e,i.value,i)}}set(t,e,s={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=s;let{noUpdateTTL:c=this.noUpdateTTL}=s;const h=this.#I(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#o?void 0:this.#c.get(t);if(void 0===l)l=0===this.#o?this.#f:0!==this.#v.length?this.#v.pop():this.#o===this.#e?this.#P(!1):this.#o,this.#h[l]=t,this.#l[l]=e,this.#c.set(t,l),this.#u[this.#f]=l,this.#d[l]=this.#f,this.#f=l,this.#o++,this.#L(l,h,a),a&&(a.set="add"),c=!1;else{this.#j(l);const s=this.#l[l];if(e!==s){if(this.#S&&this.#T(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#m&&this.#i?.(e,t,"set"),this.#_&&this.#y?.push([e,t,"set"]))}else r||(this.#m&&this.#i?.(s,t,"set"),this.#_&&this.#y?.push([s,t,"set"]));if(this.#M(l),this.#L(l,h,a),this.#l[l]=e,a){a.set="replace";const t=s&&this.#T(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#E(),this.#w&&(c||this.#F(l,i,n),a&&this.#x(a,l)),!r&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#l[this.#p];if(this.#P(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#P(t){const e=this.#p,s=this.#h[e],i=this.#l[e];return this.#S&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(i,s,"evict"),this.#_&&this.#y?.push([i,s,"evict"])),this.#M(e),t&&(this.#h[e]=void 0,this.#l[e]=void 0,this.#v.push(e)),1===this.#o?(this.#p=this.#f=0,this.#v.length=0):this.#p=this.#u[e],this.#c.delete(s),this.#o--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#c.get(t);if(void 0!==n){const t=this.#l[n];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(n))return s&&this.#z(n),i&&(i.has="hit",this.#x(i,n)),!0;i&&(i.has="stale",this.#x(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#c.get(t);if(void 0===i||!s&&this.#k(i))return;const n=this.#l[i];return this.#T(n)?n.__staleWhileFetching:n}#C(t,e,s,i){const n=void 0===e?void 0:this.#l[e];if(this.#T(n))return n;const r=new o,{signal:a}=s;a?.addEventListener("abort",(()=>r.abort(a.reason)),{signal:r.signal});const c={signal:r.signal,options:s,context:i},h=(i,n=!1)=>{const{aborted:o}=r.signal,a=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,a&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!a&&!n)return l(r.signal.reason);const h=u;return this.#l[e]===u&&(void 0===i?h.__staleWhileFetching?this.#l[e]=h.__staleWhileFetching:this.delete(t):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,c.options))),i},l=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=u;if(this.#l[e]===u){!c||void 0===h.__staleWhileFetching?this.delete(t):o||(this.#l[e]=h.__staleWhileFetching)}if(a)return s.status&&void 0!==h.__staleWhileFetching&&(s.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i};s.status&&(s.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#r?.(t,n,c);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),r.signal.addEventListener("abort",(()=>{s.ignoreFetchAbort&&!s.allowStaleOnFetchAbort||(e(void 0),s.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),l(t)))),d=Object.assign(u,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,d,{...c.options,status:void 0}),e=this.#c.get(t)):this.#l[e]=d,d}#T(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof o}async fetch(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:v=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,status:y});const b={allowStale:s,updateAgeOnGet:i,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:y,signal:g};let w=this.#c.get(t);if(void 0===w){y&&(y.fetch="miss");const e=this.#C(t,w,b,f);return e.__returned=e}{const e=this.#l[w];if(this.#T(e)){const t=s&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#k(w);if(!v&&!n)return y&&(y.fetch="hit"),this.#j(w),i&&this.#z(w),y&&this.#x(y,w),e;const r=this.#C(t,w,b,f),o=void 0!==r.__staleWhileFetching&&s;return y&&(y.fetch=n?"stale":"refresh",o&&n&&(y.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#l[o],a=this.#T(e);return r&&this.#x(r,o),this.#k(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.delete(t),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#j(o),i&&this.#z(o),e))}r&&(r.get="miss")}#W(t,e){this.#d[e]=t,this.#u[t]=e}#j(t){t!==this.#f&&(t===this.#p?this.#p=this.#u[t]:this.#W(this.#d[t],this.#u[t]),this.#W(this.#f,t),this.#f=t)}delete(t){let e=!1;if(0!==this.#o){const s=this.#c.get(t);if(void 0!==s)if(e=!0,1===this.#o)this.clear();else{this.#M(s);const e=this.#l[s];if(this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#m||this.#_)&&(this.#m&&this.#i?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#h[s]=void 0,this.#l[s]=void 0,s===this.#f)this.#f=this.#d[s];else if(s===this.#p)this.#p=this.#u[s];else{const t=this.#d[s];this.#u[t]=this.#u[s];const e=this.#u[s];this.#d[e]=this.#d[s]}this.#o--,this.#v.push(s)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const s=this.#h[t];this.#m&&this.#i?.(e,s,"delete"),this.#_&&this.#y?.push([e,s,"delete"])}}if(this.#c.clear(),this.#l.fill(void 0),this.#h.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#g&&this.#g.fill(0),this.#p=0,this.#f=0,this.#v.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}e.LRUCache=d}));(Ws=qs)&&Ws.__esModule&&Object.prototype.hasOwnProperty.call(Ws,"default")&&Ws.default;var Us=qs.LRUCache;const Bs=xs("rpc:InMemoryCache");class Ns{constructor(t){this.clearCache=t=>{var e,s;Bs("clearCache"),t?null===(e=this.cachedResponseByParams)||void 0===e||e.delete(o(t)):null===(s=this.cachedResponseByParams)||void 0===s||s.clear()},this.getCachedResponse=t=>{var e;Bs("getCachedResponse, key: ",t);let s=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(o(t));return"string"==typeof s&&(s=JSON.parse(s)),s},this.setCachedResponse=(t,e)=>{var s,i;Bs("setCachedResponse",t,e);const n=o(t);if(!e)return null===(s=this.cachedResponseByParams)||void 0===s?void 0:s.delete(n);const r=Object.assign({},e);delete r.correlationId,null===(i=this.cachedResponseByParams)||void 0===i||i.set(n,r?JSON.stringify(r):void 0)},this.cachedResponseByParams=new Us({max:(null==t?void 0:t.cacheMaxSize)||Ns.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||Ns.DEFAULT_CACHE_MAX_AGE_MS})}}var $s;Ns.DEFAULT_CACHE_MAX_AGE_MS=9e5,Ns.DEFAULT_CACHE_MAX_SIZE=200,function(t){t.http="http",t.websocket="websocket"}($s||($s={}));const Hs=t=>`${t.scope}::${t.procedure}::${t.version}`,Gs=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},Js=xs("rpc:HTTPTransport");class Vs{constructor(t){this.options=t,this.name="HttpTransport",this.type=$s.http,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.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){Js("sendRequest",t);try{const e=JSON.stringify(Object.assign({identity:this.identity},t)),s=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"}),i=yield s.text();if(!i)throw new Error("No response received from remote");const n=JSON.parse(i);return new a(n)}catch(e){throw Js("sendRequest() error",e),new Is(`HTTPTransport request error ${Hs(t)} (${null==e?void 0:e.message})`)}})),this.setIdentity=t=>{Js("setIdentity",t),this.identity=t},this.host=t.host}}class Xs{constructor(t,s){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((i,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error(`PromiseWraper timeout: ${t}`))}),s||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),i(t)}}))))}}const Ks=t=>new Promise((e=>setTimeout(e,t))),Zs=xs("rpc:WebSocketTransport");class Qs{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.type=$s.http,this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e;let s=t;try{s=JSON.stringify({clientMessage:t})}catch(e){console.warn('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}null===(e=this.websocket)||void 0===e||e.send(s)},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){for(Zs("sendRequest",t);this.isWaitingForIdentityConfirmation;)Zs("waiting for identity confirmation"),yield Ks(100);return this.sendCall(t,s)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(Zs("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?Zs('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{Zs("setIdentity with remote complete")})).catch((t=>{Zs("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):Zs("setIdentity is not connected to remote")})),this.subscribeToServerMessages=t=>(this.serverMessageHandlers.push(t),()=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))}),this.unsubscribeFromServerMessages=t=>{this.serverMessageHandlers=this.serverMessageHandlers.filter((e=>e!==t))},this._connect=()=>{if(Zs("connect",this.host),this.websocket)return void Zs("connect() returning early, websocket already exists");this.websocketId=Math.random(),this.websocket=new WebSocket(this.host);const t=this.websocket;t.onopen=()=>{console.info(`[${(new Date).toLocaleTimeString()}] WebSocket connected`),this.setConnectedToRemote(!0)},t.onmessage=t=>{this.handleWebSocketMsg(t)},t.onclose=t=>{this.connectedToRemote?console.info(`[${(new Date).toLocaleTimeString()}] WebSocket closed`,t.reason||t.code):Zs("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 Is("Websocket closed"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):Zs("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>{var e;Zs("_disconnect"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,null===(e=this.websocket)||void 0===e||e.close(1e3,t),this.websocket=void 0,this.websocketId=void 0},this.handleServerMessage=t=>{this.serverMessageHandlers.forEach((e=>{try{e(t.serverMessage)}catch(s){console.warn("WebSocketTransport.handleServerMessage() a serverMessageHandler errored when calling",t,"handler func:",e),console.error(s)}}))},this.handleWebSocketMsg=t=>{let e;Zs("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){console.error("error parsing WS msg",t)}if("serverMessage"in e)return void this.handleServerMessage(e);const s=new a(e);if(!s.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const i=this.pendingPromisesForResponse[s.correlationId];i?i.resolve(s):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>e(this,void 0,void 0,(function*(){Zs("resetConnection"),this._disconnect("WebSocketTransport#resetConnection"),yield Ks(100),this._connect()})),this.sendCall=(t,s)=>e(this,void 0,void 0,(function*(){var e;Zs("sendCall",t);const i=Math.random().toString();t.correlationId=t.correlationId||i;let n=new Xs(Hs(t),s.timeout||this.options.rpcOptions.deadlineMs);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=>{Zs(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},Zs("new WebSocketTransport()"),this.host=t.host,this.connect()}}class Ys{constructor(){this.events={},this.publish=(t,s)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,s)}))})),this.subscribe=(t,e)=>(this.events[t]||(this.events[t]=[]),this.events[t].push(e),()=>this.unsubscribe(t,e)),this.unsubscribe=(t,e)=>{if(!this.events[t])return;let s=this.events[t].indexOf(e);this.events[t].splice(s)}}}const ti={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class ei{constructor(t){var s,i,r,a,h,l;if(this.options=t,this.webSocketConnectionChangeListeners=[],this.vent=new Ys,this.onWebSocketConnectionStatusChange=t=>{this.options.onWebSocketConnectionStatusChange&&this.options.onWebSocketConnectionStatusChange(t),this.webSocketConnectionChangeListeners.forEach((e=>e(t)))},this.call=(t,s,i)=>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?Gs(t):t,s&&(e.args=s);const r=new n(e);if(!r.procedure&&!r.identity)throw new TypeError('RPCClient#call requires a "identity" or "procedure" prop and received neither');r.identity||(r.identity={}),r.identity=Fs(Object.assign({},this.identity),r.identity);const a=yield this.callManager.manageClientRequest(r,i);if(!a.success)throw new c(a,r,i);const h=o(e);return this.vent.publish(h,null==a?void 0:a.data),a})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let s;s="string"==typeof t?Gs(t):t,e&&(s.args=e);const i=this.callManager.getCachedResponse(s);if(i)return i},this.getIdentity=()=>this.identity?Ts(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 s;return s="string"==typeof t?Gs(t):t,function(t){return e.call(Object.assign(Object.assign({},s),{args:t}))}},this.registerResponseInterceptor=t=>this.callManager.addResponseInterceptor(t),this.registerRequestInterceptor=t=>this.callManager.addRequestInterceptor(t),this.registerWebSocketConnectionStatusChangeListener=t=>(this.webSocketConnectionChangeListeners.push(t),()=>{this.webSocketConnectionChangeListeners=this.webSocketConnectionChangeListeners.filter((e=>e!==t))}),this.sendClientMessageToServer=t=>{this.webSocketTransport?this.webSocketTransport.isConnected()?this.webSocketTransport.sendClientMessageToServer(t):console.info("RPCClient.sendClientMessageToServer() cannot send because the websocket is not connected"):console.warn("RPCClient.sendClientMessageToServer() unable to send because RPCClient has no websocket configuration")},this.setIdentity=t=>{let e=Ts(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const s=Ts(this.identity);s.metadata=t,this.identity.metadata=t,this.callManager.setIdentity(s)},this.transports=()=>({http:this.httpTransport,websocket:this.webSocketTransport}),!(null===(s=null==t?void 0:t.hosts)||void 0===s?void 0:s.http)&&!(null===(i=null==t?void 0:t.transports)||void 0===i?void 0:i.http))throw new Error(ti.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(ti.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(ti.INTERCEPTOR_MUSTBE_FUNC);let u;const d={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};u="browser"==t.cacheType?new Ds(d):new Ns(d);const p=[];(null===(r=t.transports)||void 0===r?void 0:r.websocket)?p.push(t.transports.websocket):(null===(a=null==t?void 0:t.hosts)||void 0===a?void 0:a.websocket)&&(this.webSocketTransport=new Qs({host:t.hosts.websocket,onConnectionStatusChange:this.onWebSocketConnectionStatusChange,rpcOptions:t}),p.push(this.webSocketTransport)),(null===(h=t.transports)||void 0===h?void 0:h.http)?p.push(t.transports.http):(null===(l=null==t?void 0:t.hosts)||void 0===l?void 0:l.http)&&(this.httpTransport=new Vs({host:t.hosts.http,rpcOptions:t}),p.push(this.httpTransport)),this.callManager=new Ps({cache:u,deadlineMs:t.deadlineMs||ei.DEFAULT_DEADLINE_MS,onTransportRequestError:t.onTransportRequestError,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:p})}subscribe(t,e){const s="string"==typeof t.request?Gs(t.request):t.request,i=o(Object.assign(Object.assign({},s),{args:t.args}));return this.vent.subscribe(i,e)}unsubscribe(t,e){const s="string"==typeof t.request?Gs(t.request):t.request,i=o(Object.assign(Object.assign({},s),{args:t.args}));this.vent.unsubscribe(i,e)}subscribeToServerMessages(t){return this.webSocketTransport?this.webSocketTransport.subscribeToServerMessages(t):(console.warn("RPCClient.subscribeToServerMessages() cannot subscribe because RPCClient has no websocket configuration"),()=>{})}unsubscribeFromServerMessages(t){var e;null===(e=this.webSocketTransport)||void 0===e||e.unsubscribeFromServerMessages(t)}}ei.DEFAULT_DEADLINE_MS=1e4,t.CallRequestTransportError=Is,t.CallRequestTransportTimeoutError=Ms,t.CallResponseError=c,t.RPCClient=ei,t.RPCResponse=a}));
{
"name": "@therms/rpc-client",
"version": "3.0.1",
"version": "3.0.2",
"description": "RPC framework, browser client lib",

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

@@ -21,3 +21,2 @@ import { Transport, TransportType } from './Transport'

// private inFlightCallCount: number = 0;
private networkIsConnected: boolean = false

@@ -37,3 +36,3 @@ readonly name = 'HttpTransport'

return this.networkIsConnected
return true
}

@@ -40,0 +39,0 @@

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