🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

@therms/rpc-client

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@therms/rpc-client - npm Package Compare versions

Comparing version

to
3.3.11

@@ -36,8 +36,8 @@ import { Cache } from '../cache/Cache';

constructor(options: ClientManagerOptions);
addResponseInterceptor: (interceptor: CallResponseInterceptor) => UnsubscribeCallback;
addRequestInterceptor: (interceptor: CallRequestInterceptor) => UnsubscribeCallback;
addResponseInterceptor: (interceptor: CallResponseInterceptor) => () => void;
addRequestInterceptor: (interceptor: CallRequestInterceptor) => () => void;
clearCache: (request?: CallRequestDTO) => void;
getCachedResponse: (request: CallRequestDTO) => CallResponseDTO | undefined;
getCachedResponse: (request: CallRequestDTO) => CallResponseDTO<any> | undefined;
getInFlightCallCount: () => number;
manageClientRequest: (request: CallRequestDTO, opts?: CallOptions) => Promise<CallResponseDTO>;
manageClientRequest: (originalRequest: CallRequestDTO, opts?: CallOptions) => Promise<CallResponseDTO<any>>;
setIdentity: (identity?: RPCClientIdentity) => void;

@@ -44,0 +44,0 @@ private interceptRequestMutator;

@@ -84,6 +84,6 @@ import { CallRequestDTO } from './CallRequestDTO';

getWebSocketConnected: () => boolean;
makeProcedure: <Args = any, Data = any>(request: CallRequestDTO<Args> | string) => (args?: any) => Promise<CallResponseDTO<Data>>;
makeProcedure: <Args = any, Data = any>(request: CallRequestDTO<Args> | string) => ((args?: any) => Promise<CallResponseDTO<Data>>);
registerResponseInterceptor: (responseInterceptor: CallResponseInterceptor) => UnsubscribeCallback;
registerRequestInterceptor: (requestInterceptor: CallRequestInterceptor) => UnsubscribeCallback;
registerWebSocketConnectionStatusChangeListener: (cb: (connected: boolean) => void) => UnsubscribeCallback;
registerWebSocketConnectionStatusChangeListener: (cb: (connected: boolean) => void) => () => void;
sendClientMessageToServer: (msg: any) => void;

@@ -90,0 +90,0 @@ setIdentity: (identity?: RPCClientIdentity) => void;

@@ -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||`${Date.now()}-${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 m=p?p.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":m&&m 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 S(t){return null!=t&&"object"==typeof t}var _=Array.isArray;function T(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function C(t){return t}function j(t){if(!T(t))return!1;var e=w(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var O,A=d["__core-js_shared__"],k=(O=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"";var E=Function.prototype.toString;function R(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var F=/^\[object .+?Constructor\]$/,x=Function.prototype,M=Object.prototype,z=x.toString,I=M.hasOwnProperty,L=RegExp("^"+z.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function P(t){return!(!T(t)||(e=t,k&&k in e))&&(j(t)?L:F).test(R(t));var e}function W(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return P(s)?s:void 0}var D=W(d,"WeakMap"),q=Object.create,B=function(){function t(){}return function(e){if(!T(e))return{};if(q)return q(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();function U(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}var N=Date.now;var $,H,G,J=function(){try{var t=W(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),V=J?function(t,e){return J(t,"toString",{configurable:!0,enumerable:!1,value:(s=e,function(){return s}),writable:!0});var s}:C,X=($=V,H=0,G=0,function(){var t=N(),e=16-(t-G);if(G=t,e>0){if(++H>=800)return arguments[0]}else H=0;return $.apply(void 0,arguments)});var K=/^(?:0|[1-9]\d*)$/;function Z(t,e){var s=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==s||"symbol"!=s&&K.test(t))&&t>-1&&t%1==0&&t<e}function Q(t,e,s){"__proto__"==e&&J?J(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function Y(t,e){return t===e||t!=t&&e!=e}var tt=Object.prototype.hasOwnProperty;function et(t,e,s){var i=t[e];tt.call(t,e)&&Y(i,s)&&(void 0!==s||e in t)||Q(t,e,s)}function st(t,e,s,i){var n=!s;s||(s={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=void 0;void 0===c&&(c=t[a]),n?Q(s,a,c):et(s,a,c)}return s}var it=Math.max;function nt(t,e){return X(function(t,e,s){return e=it(void 0===e?t.length-1:e,0),function(){for(var i=arguments,n=-1,r=it(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,C),t+"")}function rt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function ot(t){return null!=t&&rt(t.length)&&!j(t)}var at=Object.prototype;function ct(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||at)}function ht(t){return S(t)&&"[object Arguments]"==w(t)}var lt=Object.prototype,ut=lt.hasOwnProperty,dt=lt.propertyIsEnumerable,pt=ht(function(){return arguments}())?ht:function(t){return S(t)&&ut.call(t,"callee")&&!dt.call(t,"callee")};var ft="object"==typeof t&&t&&!t.nodeType&&t,vt=ft&&"object"==typeof module&&module&&!module.nodeType&&module,yt=vt&&vt.exports===ft?d.Buffer:void 0,gt=(yt?yt.isBuffer:void 0)||function(){return!1},bt={};function mt(t){return function(e){return t(e)}}bt["[object Float32Array]"]=bt["[object Float64Array]"]=bt["[object Int8Array]"]=bt["[object Int16Array]"]=bt["[object Int32Array]"]=bt["[object Uint8Array]"]=bt["[object Uint8ClampedArray]"]=bt["[object Uint16Array]"]=bt["[object Uint32Array]"]=!0,bt["[object Arguments]"]=bt["[object Array]"]=bt["[object ArrayBuffer]"]=bt["[object Boolean]"]=bt["[object DataView]"]=bt["[object Date]"]=bt["[object Error]"]=bt["[object Function]"]=bt["[object Map]"]=bt["[object Number]"]=bt["[object Object]"]=bt["[object RegExp]"]=bt["[object Set]"]=bt["[object String]"]=bt["[object WeakMap]"]=!1;var wt="object"==typeof t&&t&&!t.nodeType&&t,St=wt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=St&&St.exports===wt&&l.process,Tt=function(){try{var t=St&&St.require&&St.require("util").types;return t||_t&&_t.binding&&_t.binding("util")}catch(t){}}(),Ct=Tt&&Tt.isTypedArray,jt=Ct?mt(Ct):function(t){return S(t)&&rt(t.length)&&!!bt[w(t)]},Ot=Object.prototype.hasOwnProperty;function At(t,e){var s=_(t),i=!s&&pt(t),n=!s&&!i&&gt(t),r=!s&&!i&&!n&&jt(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&&!Ot.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Z(h,c))||a.push(h);return a}function kt(t,e){return function(s){return t(e(s))}}var Et=kt(Object.keys,Object),Rt=Object.prototype.hasOwnProperty;function Ft(t){return ot(t)?At(t):function(t){if(!ct(t))return Et(t);var e=[];for(var s in Object(t))Rt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}var xt=Object.prototype.hasOwnProperty;function Mt(t){if(!T(t))return function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}(t);var e=ct(t),s=[];for(var i in t)("constructor"!=i||!e&&xt.call(t,i))&&s.push(i);return s}function zt(t){return ot(t)?At(t,!0):Mt(t)}var It=W(Object,"create");var Lt=Object.prototype.hasOwnProperty;var Pt=Object.prototype.hasOwnProperty;function Wt(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 Dt(t,e){for(var s=t.length;s--;)if(Y(t[s][0],e))return s;return-1}Wt.prototype.clear=function(){this.__data__=It?It(null):{},this.size=0},Wt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Wt.prototype.get=function(t){var e=this.__data__;if(It){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return Lt.call(e,t)?e[t]:void 0},Wt.prototype.has=function(t){var e=this.__data__;return It?void 0!==e[t]:Pt.call(e,t)},Wt.prototype.set=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=It&&void 0===e?"__lodash_hash_undefined__":e,this};var qt=Array.prototype.splice;function Bt(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])}}Bt.prototype.clear=function(){this.__data__=[],this.size=0},Bt.prototype.delete=function(t){var e=this.__data__,s=Dt(e,t);return!(s<0)&&(s==e.length-1?e.pop():qt.call(e,s,1),--this.size,!0)},Bt.prototype.get=function(t){var e=this.__data__,s=Dt(e,t);return s<0?void 0:e[s][1]},Bt.prototype.has=function(t){return Dt(this.__data__,t)>-1},Bt.prototype.set=function(t,e){var s=this.__data__,i=Dt(s,t);return i<0?(++this.size,s.push([t,e])):s[i][1]=e,this};var Ut=W(d,"Map");function Nt(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 $t(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 Ht(t,e){for(var s=-1,i=e.length,n=t.length;++s<i;)t[n+s]=e[s];return t}$t.prototype.clear=function(){this.size=0,this.__data__={hash:new Wt,map:new(Ut||Bt),string:new Wt}},$t.prototype.delete=function(t){var e=Nt(this,t).delete(t);return this.size-=e?1:0,e},$t.prototype.get=function(t){return Nt(this,t).get(t)},$t.prototype.has=function(t){return Nt(this,t).has(t)},$t.prototype.set=function(t,e){var s=Nt(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this};var Gt=kt(Object.getPrototypeOf,Object),Jt=Function.prototype,Vt=Object.prototype,Xt=Jt.toString,Kt=Vt.hasOwnProperty,Zt=Xt.call(Object);function Qt(t){var e=this.__data__=new Bt(t);this.size=e.size}Qt.prototype.clear=function(){this.__data__=new Bt,this.size=0},Qt.prototype.delete=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s},Qt.prototype.get=function(t){return this.__data__.get(t)},Qt.prototype.has=function(t){return this.__data__.has(t)},Qt.prototype.set=function(t,e){var s=this.__data__;if(s instanceof Bt){var i=s.__data__;if(!Ut||i.length<199)return i.push([t,e]),this.size=++s.size,this;s=this.__data__=new $t(i)}return s.set(t,e),this.size=s.size,this};var Yt="object"==typeof t&&t&&!t.nodeType&&t,te=Yt&&"object"==typeof module&&module&&!module.nodeType&&module,ee=te&&te.exports===Yt?d.Buffer:void 0,se=ee?ee.allocUnsafe:void 0;function ie(t,e){if(e)return t.slice();var s=t.length,i=se?se(s):new t.constructor(s);return t.copy(i),i}function ne(){return[]}var re=Object.prototype.propertyIsEnumerable,oe=Object.getOwnPropertySymbols,ae=oe?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}(oe(t),(function(e){return re.call(t,e)})))}:ne;var ce=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Ht(e,ae(t)),t=Gt(t);return e}:ne;function he(t,e,s){var i=e(t);return _(t)?i:Ht(i,s(t))}function le(t){return he(t,Ft,ae)}function ue(t){return he(t,zt,ce)}var de=W(d,"DataView"),pe=W(d,"Promise"),fe=W(d,"Set"),ve="[object Map]",ye="[object Promise]",ge="[object Set]",be="[object WeakMap]",me="[object DataView]",we=R(de),Se=R(Ut),_e=R(pe),Te=R(fe),Ce=R(D),je=w;(de&&je(new de(new ArrayBuffer(1)))!=me||Ut&&je(new Ut)!=ve||pe&&je(pe.resolve())!=ye||fe&&je(new fe)!=ge||D&&je(new D)!=be)&&(je=function(t){var e=w(t),s="[object Object]"==e?t.constructor:void 0,i=s?R(s):"";if(i)switch(i){case we:return me;case Se:return ve;case _e:return ye;case Te:return ge;case Ce:return be}return e});var Oe=Object.prototype.hasOwnProperty;var Ae=d.Uint8Array;function ke(t){var e=new t.constructor(t.byteLength);return new Ae(e).set(new Ae(t)),e}var Ee=/\w*$/;var Re=p?p.prototype:void 0,Fe=Re?Re.valueOf:void 0;function xe(t,e){var s=e?ke(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}function Me(t,e,s){var i,n,r,o=t.constructor;switch(e){case"[object ArrayBuffer]":return ke(t);case"[object Boolean]":case"[object Date]":return new o(+t);case"[object DataView]":return function(t,e){var s=e?ke(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}(t,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return xe(t,s);case"[object Map]":case"[object Set]":return new o;case"[object Number]":case"[object String]":return new o(t);case"[object RegExp]":return(r=new(n=t).constructor(n.source,Ee.exec(n))).lastIndex=n.lastIndex,r;case"[object Symbol]":return i=t,Fe?Object(Fe.call(i)):{}}}function ze(t){return"function"!=typeof t.constructor||ct(t)?{}:B(Gt(t))}var Ie=Tt&&Tt.isMap,Le=Ie?mt(Ie):function(t){return S(t)&&"[object Map]"==je(t)};var Pe=Tt&&Tt.isSet,We=Pe?mt(Pe):function(t){return S(t)&&"[object Set]"==je(t)},De="[object Arguments]",qe="[object Function]",Be="[object Object]",Ue={};function Ne(t,e,s,i,n,r){var o,a=1&e,c=2&e,h=4&e;if(void 0!==o)return o;if(!T(t))return t;var l=_(t);if(l){if(o=function(t){var e=t.length,s=new t.constructor(e);return e&&"string"==typeof t[0]&&Oe.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t),!a)return U(t,o)}else{var u=je(t),d=u==qe||"[object GeneratorFunction]"==u;if(gt(t))return ie(t,a);if(u==Be||u==De||d&&!n){if(o=c||d?{}:ze(t),!a)return c?function(t,e){return st(t,ce(t),e)}(t,function(t,e){return t&&st(e,zt(e),t)}(o,t)):function(t,e){return st(t,ae(t),e)}(t,function(t,e){return t&&st(e,Ft(e),t)}(o,t))}else{if(!Ue[u])return n?t:{};o=Me(t,u,a)}}r||(r=new Qt);var p=r.get(t);if(p)return p;r.set(t,o),We(t)?t.forEach((function(i){o.add(Ne(i,e,s,i,t,r))})):Le(t)&&t.forEach((function(i,n){o.set(n,Ne(i,e,s,n,t,r))}));var f=l?void 0:(h?c?ue:le:c?zt:Ft)(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]),et(o,n,Ne(i,e,s,n,t,r))})),o}Ue[De]=Ue["[object Array]"]=Ue["[object ArrayBuffer]"]=Ue["[object DataView]"]=Ue["[object Boolean]"]=Ue["[object Date]"]=Ue["[object Float32Array]"]=Ue["[object Float64Array]"]=Ue["[object Int8Array]"]=Ue["[object Int16Array]"]=Ue["[object Int32Array]"]=Ue["[object Map]"]=Ue["[object Number]"]=Ue[Be]=Ue["[object RegExp]"]=Ue["[object Set]"]=Ue["[object String]"]=Ue["[object Symbol]"]=Ue["[object Uint8Array]"]=Ue["[object Uint8ClampedArray]"]=Ue["[object Uint16Array]"]=Ue["[object Uint32Array]"]=!0,Ue["[object Error]"]=Ue[qe]=Ue["[object WeakMap]"]=!1;function $e(t){return Ne(t,5)}var He=function(t,e,s){for(var i=-1,n=Object(t),r=s(t),o=r.length;o--;){var a=r[++i];if(!1===e(n[a],a,n))break}return t};function Ge(t,e,s){(void 0!==s&&!Y(t[e],s)||void 0===s&&!(e in t))&&Q(t,e,s)}function Je(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Ve(t,e,s,i,n,r,o){var a=Je(t,s),c=Je(e,s),h=o.get(c);if(h)Ge(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),f=!p&&gt(c),v=!p&&!f&&jt(c);u=c,p||f||v?_(a)?u=a:S(l=a)&&ot(l)?u=U(a):f?(d=!1,u=ie(c,!0)):v?(d=!1,u=xe(c,!0)):u=[]:function(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=Gt(t);if(null===e)return!0;var s=Kt.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&Xt.call(s)==Zt}(c)||pt(c)?(u=a,pt(a)?u=function(t){return st(t,zt(t))}(a):T(a)&&!j(a)||(u=ze(c))):d=!1}d&&(o.set(c,u),n(u,c,i,r,o),o.delete(c)),Ge(t,s,u)}}function Xe(t,e,s,i,n){t!==e&&He(e,(function(r,o){if(n||(n=new Qt),T(r))Ve(t,e,o,s,Xe,i,n);else{var a=i?i(Je(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Ge(t,o,a)}}),zt)}var Ke,Ze=(Ke=function(t,e,s){Xe(t,e,s)},nt((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=Ke.length>3&&"function"==typeof n?(i--,n):void 0,r&&function(t,e,s){if(!T(s))return!1;var i=typeof e;return!!("number"==i?ot(s)&&Z(e,s.length):"string"==i&&e in s)&&Y(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&&Ke(t,o,s,n)}return t})));let Qe=null;try{Qe=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const Ye=t=>Qe&&new RegExp(Qe).test(t)?(...e)=>console.log(t,...e):()=>{};class ts extends Error{}class es extends Error{}const ss=Ye("rpc:ClientManager");class is{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=>{ss("clearCache"),this.cache&&this.cache.clearCache(t)},this.getCachedResponse=t=>{var e;return ss("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(ss("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,s)=>e(this,void 0,void 0,(function*(){ss("manageClientRequest",t);const i=yield this.interceptRequestMutator(t),n=o(i);if(this.inflightCallsByKey.hasOwnProperty(n))return ss("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const s=$e(e);return t.correlationId&&(s.correlationId=t.correlationId),s}));const r=(()=>e(this,void 0,void 0,(function*(){var t,e;const n=null===(t=this.options.transportOptions)||void 0===t?void 0:t.preferredTransport,r=null!==(e=null==s?void 0:s.transport)&&void 0!==e?e:n,o=yield this.sendRequestWithTransport(i,Object.assign(Object.assign({},s),{transport:r})),a=yield this.interceptResponseMutator(o,i);return this.cache&&a&&this.cache.setCachedResponse(i,a),a})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{ss("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){ss("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){ss("interceptResponseMutator",s,t);for(const i of this.interceptors.response)try{e=yield i(e,s)}catch(i){throw ss("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,n,r;let o;ss("sendRequestWithTransport",t);let a=0,c=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`);c=[t]}for(;!o&&c[a];){const h=c[a];if(h.isConnected()){ss(`sendRequestWithTransport trying ${h.name}`,t);try{let e;const i=h.sendRequest(t,s||{}),n=new Promise(((i,n)=>{e=setTimeout((()=>{n(new ts(`Procedure ${t.procedure}`))}),(null==s?void 0:s.timeout)||this.options.deadlineMs)}));o=yield Promise.race([n,i]).finally((()=>{clearTimeout(e)}))}catch(e){if(null===(r=(n=this.options).onTransportRequestError)||void 0===r||r.call(n,e,c[a].type,t),!(e instanceof ts||e instanceof es))throw e;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${c[a].name} failed ${c[a+1]?`trying next transport "${c[a+1].name}"`:"no more transports to try"}`),a++}}else a++,ss(`sendRequestWithTransport transport ${h.name} not connected, trying next transport "${null!==(i=null===(e=c[a])||void 0===e?void 0:e.name)&&void 0!==i?i:"no next transport"}"`)}if(!o&&!this.transports[a])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(!o)throw new h(`Procedure ${t.procedure} did not get a response from the remote`);return o})),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 ns{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}ns.DEFAULT_CACHE_MAX_AGE_MS=3e5,ns.DEFAULT_CACHE_MAX_SIZE=100;const rs="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,os=new Set,as="object"==typeof process&&process?process:{},cs=(t,e,s,i)=>{"function"==typeof as.emitWarning?as.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let hs=globalThis.AbortController,ls=globalThis.AbortSignal;if(void 0===hs){ls=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},hs=class{constructor(){e()}signal=new ls;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"!==as.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,cs("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 us=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),ds=t=>us(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ps:null:null;class ps extends Array{constructor(t){super(t),this.fill(0)}}class fs{heap;length;static#t=!1;static create(t){const e=ds(t);if(!e)return[];fs.#t=!0;const s=new fs(t,e);return fs.#t=!1,s}constructor(t,e){if(!fs.#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 vs{#e;#s;#i;#n;#r;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#m;#w;#S;#_;#T;static unsafeExposeInternals(t){return{starts:t.#m,ttls:t.#w,sizes:t.#b,keyMap:t.#h,keyList:t.#l,valList:t.#u,next:t.#d,prev:t.#p,get head(){return t.#f},get tail(){return t.#v},free:t.#y,isBackgroundFetch:e=>t.#C(e),backgroundFetch:(e,s,i,n)=>t.#j(e,s,i,n),moveToTail:e=>t.#O(e),indexes:e=>t.#A(e),rindexes:e=>t.#k(e),isStale:e=>t.#E(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#o}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:h,noDisposeOnSet:l,noUpdateTTL:u,maxSize:d=0,maxEntrySize:p=0,sizeCalculation:f,fetchMethod:v,memoMethod:y,noDeleteOnFetchRejection:g,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:w,ignoreFetchAbort:S}=t;if(0!==e&&!us(e))throw new TypeError("max option must be a nonnegative integer");const _=e?ds(e):Array;if(!_)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=d,this.maxEntrySize=p||this.#s,this.sizeCalculation=f,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!==y&&"function"!=typeof y)throw new TypeError("memoMethod must be a function if defined");if(this.#o=y,void 0!==v&&"function"!=typeof v)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=v,this.#_=!!v,this.#h=new Map,this.#l=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#d=new _(e),this.#p=new _(e),this.#f=0,this.#v=0,this.#y=fs.create(e),this.#a=0,this.#c=0,"function"==typeof c&&(this.#i=c),"function"==typeof h?(this.#n=h,this.#g=[]):(this.#n=void 0,this.#g=void 0),this.#S=!!this.#i,this.#T=!!this.#n,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!g,this.allowStaleOnFetchRejection=!!m,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#s&&!us(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!us(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=us(i)||0===i?i:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!us(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#F()}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=>!os.has(t))(t)){os.add(t);cs("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,vs)}}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#F(){const t=new ps(this.#e),e=new ps(this.#e);this.#w=t,this.#m=e,this.#x=(s,i,n=rs.now())=>{if(e[s]=0!==i?n:0,t[s]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#E(s)&&this.#M(this.#l[s],"expire")}),i+1);t.unref&&t.unref()}},this.#z=s=>{e[s]=0!==t[s]?rs.now():0},this.#I=(n,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;n.ttl=o,n.start=a,n.now=s||i();const c=n.now-a;n.remainingTTL=o-c}};let s=0;const i=()=>{const t=rs.now();if(this.ttlResolution>0){s=t;const e=setTimeout((()=>s=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#h.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((s||i())-a)},this.#E=n=>{const r=e[n],o=t[n];return!!o&&!!r&&(s||i())-r>o}}#z=()=>{};#I=()=>{};#x=()=>{};#E=()=>!1;#R(){const t=new ps(this.#e);this.#c=0,this.#b=t,this.#L=e=>{this.#c-=t[e],t[e]=0},this.#P=(t,e,s,i)=>{if(this.#C(e))return 0;if(!us(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),!us(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#W=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#c>s;)this.#D(!0)}this.#c+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#c)}}#L=t=>{};#W=(t,e,s)=>{};#P=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#v;this.#q(e)&&(!t&&this.#E(e)||(yield e),e!==this.#f);)e=this.#p[e]}*#k({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#f;this.#q(e)&&(!t&&this.#E(e)||(yield e),e!==this.#v);)e=this.#d[e]}#q(t){return void 0!==t&&this.#h.get(this.#l[t])===t}*entries(){for(const t of this.#A())void 0===this.#u[t]||void 0===this.#l[t]||this.#C(this.#u[t])||(yield[this.#l[t],this.#u[t]])}*rentries(){for(const t of this.#k())void 0===this.#u[t]||void 0===this.#l[t]||this.#C(this.#u[t])||(yield[this.#l[t],this.#u[t]])}*keys(){for(const t of this.#A()){const e=this.#l[t];void 0===e||this.#C(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#k()){const e=this.#l[t];void 0===e||this.#C(this.#u[t])||(yield e)}}*values(){for(const t of this.#A()){void 0===this.#u[t]||this.#C(this.#u[t])||(yield this.#u[t])}}*rvalues(){for(const t of this.#k()){void 0===this.#u[t]||this.#C(this.#u[t])||(yield this.#u[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#A()){const i=this.#u[s],n=this.#C(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#l[s],this))return this.get(this.#l[s],e)}}forEach(t,e=this){for(const s of this.#A()){const i=this.#u[s],n=this.#C(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#l[s],this)}}rforEach(t,e=this){for(const s of this.#k()){const i=this.#u[s],n=this.#C(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#l[s],this)}}purgeStale(){let t=!1;for(const e of this.#k({allowStale:!0}))this.#E(e)&&(this.#M(this.#l[e],"expire"),t=!0);return t}info(t){const e=this.#h.get(t);if(void 0===e)return;const s=this.#u[e],i=this.#C(s)?s.__staleWhileFetching:s;if(void 0===i)return;const n={value:i};if(this.#w&&this.#m){const t=this.#w[e],s=this.#m[e];if(t&&s){const e=t-(rs.now()-s);n.ttl=e,n.start=Date.now()}}return this.#b&&(n.size=this.#b[e]),n}dump(){const t=[];for(const e of this.#A({allowStale:!0})){const s=this.#l[e],i=this.#u[e],n=this.#C(i)?i.__staleWhileFetching:i;if(void 0===n||void 0===s)continue;const r={value:n};if(this.#w&&this.#m){r.ttl=this.#w[e];const t=rs.now()-this.#m[e];r.start=Math.floor(Date.now()-t)}this.#b&&(r.size=this.#b[e]),t.unshift([s,r])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=rs.now()-t}this.set(e,s.value,s)}}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.#P(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#M(t,"set"),this;let l=0===this.#a?void 0:this.#h.get(t);if(void 0===l)l=0===this.#a?this.#v:0!==this.#y.length?this.#y.pop():this.#a===this.#e?this.#D(!1):this.#a,this.#l[l]=t,this.#u[l]=e,this.#h.set(t,l),this.#d[this.#v]=l,this.#p[l]=this.#v,this.#v=l,this.#a++,this.#W(l,h,a),a&&(a.set="add"),c=!1;else{this.#O(l);const s=this.#u[l];if(e!==s){if(this.#_&&this.#C(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#S&&this.#i?.(e,t,"set"),this.#T&&this.#g?.push([e,t,"set"]))}else r||(this.#S&&this.#i?.(s,t,"set"),this.#T&&this.#g?.push([s,t,"set"]));if(this.#L(l),this.#W(l,h,a),this.#u[l]=e,a){a.set="replace";const t=s&&this.#C(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#F(),this.#w&&(c||this.#x(l,i,n),a&&this.#I(a,l)),!r&&this.#T&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#u[this.#f];if(this.#D(!0),this.#C(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#T&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#D(t){const e=this.#f,s=this.#l[e],i=this.#u[e];return this.#_&&this.#C(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#T)&&(this.#S&&this.#i?.(i,s,"evict"),this.#T&&this.#g?.push([i,s,"evict"])),this.#L(e),t&&(this.#l[e]=void 0,this.#u[e]=void 0,this.#y.push(e)),1===this.#a?(this.#f=this.#v=0,this.#y.length=0):this.#f=this.#d[e],this.#h.delete(s),this.#a--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#h.get(t);if(void 0!==n){const t=this.#u[n];if(this.#C(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#E(n))return s&&this.#z(n),i&&(i.has="hit",this.#I(i,n)),!0;i&&(i.has="stale",this.#I(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#h.get(t);if(void 0===i||!s&&this.#E(i))return;const n=this.#u[i];return this.#C(n)?n.__staleWhileFetching:n}#j(t,e,s,i){const n=void 0===e?void 0:this.#u[e];if(this.#C(n))return n;const r=new hs,{signal:o}=s;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:s,context:i},c=(i,n=!1)=>{const{aborted:o}=r.signal,c=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,c&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!c&&!n)return h(r.signal.reason);const u=l;return this.#u[e]===l&&(void 0===i?u.__staleWhileFetching?this.#u[e]=u.__staleWhileFetching:this.#M(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,a.options))),i},h=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=l;if(this.#u[e]===l){!c||void 0===h.__staleWhileFetching?this.#M(t,"fetch"):o||(this.#u[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 l=new Promise(((e,i)=>{const o=this.#r?.(t,n,a);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=>c(t,!0)))}))})).then(c,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),h(t)))),u=Object.assign(l,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,u,{...a.options,status:void 0}),e=this.#h.get(t)):this.#u[e]=u,u}#C(t){if(!this.#_)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof hs}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.#_)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 m=this.#h.get(t);if(void 0===m){y&&(y.fetch="miss");const e=this.#j(t,m,b,f);return e.__returned=e}{const e=this.#u[m];if(this.#C(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.#E(m);if(!v&&!n)return y&&(y.fetch="hit"),this.#O(m),i&&this.#z(m),y&&this.#I(y,m),e;const r=this.#j(t,m,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}}async forceFetch(t,e={}){const s=await this.fetch(t,e);if(void 0===s)throw new Error("fetch() returned undefined");return s}memo(t,e={}){const s=this.#o;if(!s)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:n,...r}=e,o=this.get(t,r);if(!n&&void 0!==o)return o;const a=s(t,o,{options:r,context:i});return this.set(t,a,r),a}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#u[o],a=this.#C(e);return r&&this.#I(r,o),this.#E(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.#M(t,"expire"),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#O(o),i&&this.#z(o),e))}r&&(r.get="miss")}#B(t,e){this.#p[e]=t,this.#d[t]=e}#O(t){t!==this.#v&&(t===this.#f?this.#f=this.#d[t]:this.#B(this.#p[t],this.#d[t]),this.#B(this.#v,t),this.#v=t)}delete(t){return this.#M(t,"delete")}#M(t,e){let s=!1;if(0!==this.#a){const i=this.#h.get(t);if(void 0!==i)if(s=!0,1===this.#a)this.#U(e);else{this.#L(i);const s=this.#u[i];if(this.#C(s)?s.__abortController.abort(new Error("deleted")):(this.#S||this.#T)&&(this.#S&&this.#i?.(s,t,e),this.#T&&this.#g?.push([s,t,e])),this.#h.delete(t),this.#l[i]=void 0,this.#u[i]=void 0,i===this.#v)this.#v=this.#p[i];else if(i===this.#f)this.#f=this.#d[i];else{const t=this.#p[i];this.#d[t]=this.#d[i];const e=this.#d[i];this.#p[e]=this.#p[i]}this.#a--,this.#y.push(i)}}if(this.#T&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}return s}clear(){return this.#U("delete")}#U(t){for(const e of this.#k({allowStale:!0})){const s=this.#u[e];if(this.#C(s))s.__abortController.abort(new Error("deleted"));else{const i=this.#l[e];this.#S&&this.#i?.(s,i,t),this.#T&&this.#g?.push([s,i,t])}}if(this.#h.clear(),this.#u.fill(void 0),this.#l.fill(void 0),this.#w&&this.#m&&(this.#w.fill(0),this.#m.fill(0)),this.#b&&this.#b.fill(0),this.#f=0,this.#v=0,this.#y.length=0,this.#c=0,this.#a=0,this.#T&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}}}const ys=Ye("rpc:InMemoryCache");class gs{constructor(t){this.clearCache=t=>{var e,s;ys("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;ys("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;ys("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 vs({max:(null==t?void 0:t.cacheMaxSize)||gs.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||gs.DEFAULT_CACHE_MAX_AGE_MS})}}var bs;gs.DEFAULT_CACHE_MAX_AGE_MS=9e5,gs.DEFAULT_CACHE_MAX_SIZE=200,t.TransportType=void 0,(bs=t.TransportType||(t.TransportType={})).http="http",bs.websocket="websocket";const ms=t=>`${t.scope}::${t.procedure}::${t.version}`,ws=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},Ss=Ye("rpc:HTTPTransport");class _s{constructor(s){this.options=s,this.name="HttpTransport",this.type=t.TransportType.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):"function"==typeof fetch},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){Ss("sendRequest",t);try{const e=JSON.stringify(Object.assign({identity:this.identity},t)),s=yield 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 Ss("sendRequest() error",e),new es(`HTTPTransport request error ${ms(t)} (${null==e?void 0:e.message})`)}})),this.setIdentity=t=>{Ss("setIdentity",t),this.identity=t},this.host=s.host}}class Ts{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 Cs=t=>new Promise((e=>setTimeout(e,t))),js=Ye("rpc:WebSocketTransport");class Os{constructor(s){var i,n;this.options=s,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.type=t.TransportType.websocket,this.isConnected=()=>{var t;return(null===(t=this.websocket)||void 0===t?void 0:t.readyState)===WebSocket.OPEN},this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e,s;let i=t;try{i=JSON.stringify({clientMessage:t})}catch(e){return void console.error('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}js("sendClientMessageToServer",i),(null===(e=this.websocket)||void 0===e?void 0:e.readyState)===WebSocket.OPEN?null===(s=this.websocket)||void 0===s||s.send(i):js("WebSocket is not connected. Message not sent:",i)},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){var e;if(js("sendRequest",t),(null===(e=this.websocket)||void 0===e?void 0:e.readyState)!==WebSocket.OPEN)throw js("sendRequest WebSocket is not connected"),new es("WebSocket is not connected");let i=0;for(;this.isWaitingForIdentityConfirmation;){if(js("waiting for identity confirmation"),i++,i>=20)throw new es("Timed out waiting for identity confirmation");yield Cs(100)}return this.sendCall(t,s)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(js("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?js('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{js("setIdentity with remote complete")})).catch((t=>{js("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):js("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(js("connect",this.host),this.websocket)return void js("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):js("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 es("Websocket closed"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):js("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>e(this,void 0,void 0,(function*(){var e;js("_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;js("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){return void js("error parsing WS msg",t)}if(e&&"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*(){js("resetConnection");const t=this.isConnected();return yield this._disconnect("WebSocketTransport#resetConnection"),t&&(yield Cs(300),yield this._connect()),this.isConnected()})),this.sendCall=(t,s)=>e(this,void 0,void 0,(function*(){var e;js("sendCall",t);const i=`${Date.now()}-${Math.random().toString()}`;t.correlationId=t.correlationId||i;const n=new Ts(ms(t),s.timeout||this.options.rpcOptions.deadlineMs);if(!this.isConnected()){const t=new es("Cannot send message: WebSocket is not connected");return js("sendCall failed - websocket not connected",t),n.reject(t),n.promise}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=>{js(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},js("new WebSocketTransport()"),this.host=s.host,!1!==(null===(n=null===(i=s.rpcOptions.transportOptions)||void 0===i?void 0:i.websocket)||void 0===n?void 0:n.autoConnect)&&this.connect()}}class As{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 ks=Ye("rpc:RPCClient"),Es={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class Rs{constructor(t){var s,i,r,a,h,l;if(this.options=t,this.webSocketConnectionChangeListeners=[],this.vent=new As,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?ws(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=Ze(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?ws(t):t,e&&(s.args=e);const i=this.callManager.getCachedResponse(s);if(i)return i},this.getIdentity=()=>this.identity?$e(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?ws(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):ks("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=$e(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const s=$e(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(Es.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(Es.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(Es.INTERCEPTOR_MUSTBE_FUNC);let u;const d={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};u="browser"==t.cacheType?new ns(d):new gs(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 Os({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 _s({host:t.hosts.http,rpcOptions:t}),p.push(this.httpTransport)),this.callManager=new is({cache:u,deadlineMs:t.deadlineMs||Rs.DEFAULT_DEADLINE_MS,onTransportRequestError:t.onTransportRequestError,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:p,transportOptions:t.transportOptions})}subscribe(t,e){const s="string"==typeof t.request?ws(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?ws(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)}}Rs.DEFAULT_DEADLINE_MS=1e4,t.CallRequestTransportError=es,t.CallRequestTransportTimeoutError=ts,t.CallResponseError=c,t.RPCClient=Rs,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||`${Date.now()}-${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 m=p?p.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":m&&m 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 S(t){return null!=t&&"object"==typeof t}var _=Array.isArray;function T(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function C(t){return t}function j(t){if(!T(t))return!1;var e=w(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var O,A=d["__core-js_shared__"],k=(O=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+O:"";var E=Function.prototype.toString;function R(t){if(null!=t){try{return E.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var F=/^\[object .+?Constructor\]$/,x=Function.prototype,M=Object.prototype,z=x.toString,I=M.hasOwnProperty,L=RegExp("^"+z.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function P(t){return!(!T(t)||(e=t,k&&k in e))&&(j(t)?L:F).test(R(t));var e}function W(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return P(s)?s:void 0}var D=W(d,"WeakMap"),q=Object.create,B=function(){function t(){}return function(e){if(!T(e))return{};if(q)return q(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();var U=Date.now;var N,$,H,G=function(){try{var t=W(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),J=G?function(t,e){return G(t,"toString",{configurable:!0,enumerable:!1,value:(s=e,function(){return s}),writable:!0});var s}:C,V=(N=J,$=0,H=0,function(){var t=U(),e=16-(t-H);if(H=t,e>0){if(++$>=800)return arguments[0]}else $=0;return N.apply(void 0,arguments)});var X=/^(?:0|[1-9]\d*)$/;function K(t,e){var s=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==s||"symbol"!=s&&X.test(t))&&t>-1&&t%1==0&&t<e}function Z(t,e,s){"__proto__"==e&&G?G(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function Q(t,e){return t===e||t!=t&&e!=e}var Y=Object.prototype.hasOwnProperty;function tt(t,e,s){var i=t[e];Y.call(t,e)&&Q(i,s)&&(void 0!==s||e in t)||Z(t,e,s)}var et=Math.max;function st(t,e){return V(function(t,e,s){return e=et(void 0===e?t.length-1:e,0),function(){for(var i=arguments,n=-1,r=et(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,C),t+"")}function it(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function nt(t){return null!=t&&it(t.length)&&!j(t)}var rt=Object.prototype;function ot(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||rt)}function at(t){return S(t)&&"[object Arguments]"==w(t)}var ct=Object.prototype,ht=ct.hasOwnProperty,lt=ct.propertyIsEnumerable,ut=at(function(){return arguments}())?at:function(t){return S(t)&&ht.call(t,"callee")&&!lt.call(t,"callee")};var dt="object"==typeof t&&t&&!t.nodeType&&t,pt=dt&&"object"==typeof module&&module&&!module.nodeType&&module,ft=pt&&pt.exports===dt?d.Buffer:void 0,vt=(ft?ft.isBuffer:void 0)||function(){return!1},yt={};function gt(t){return function(e){return t(e)}}yt["[object Float32Array]"]=yt["[object Float64Array]"]=yt["[object Int8Array]"]=yt["[object Int16Array]"]=yt["[object Int32Array]"]=yt["[object Uint8Array]"]=yt["[object Uint8ClampedArray]"]=yt["[object Uint16Array]"]=yt["[object Uint32Array]"]=!0,yt["[object Arguments]"]=yt["[object Array]"]=yt["[object ArrayBuffer]"]=yt["[object Boolean]"]=yt["[object DataView]"]=yt["[object Date]"]=yt["[object Error]"]=yt["[object Function]"]=yt["[object Map]"]=yt["[object Number]"]=yt["[object Object]"]=yt["[object RegExp]"]=yt["[object Set]"]=yt["[object String]"]=yt["[object WeakMap]"]=!1;var bt="object"==typeof t&&t&&!t.nodeType&&t,mt=bt&&"object"==typeof module&&module&&!module.nodeType&&module,wt=mt&&mt.exports===bt&&l.process,St=function(){try{var t=mt&&mt.require&&mt.require("util").types;return t||wt&&wt.binding&&wt.binding("util")}catch(t){}}(),_t=St&&St.isTypedArray,Tt=_t?gt(_t):function(t){return S(t)&&it(t.length)&&!!yt[w(t)]},Ct=Object.prototype.hasOwnProperty;function jt(t,e){var s=_(t),i=!s&&ut(t),n=!s&&!i&&vt(t),r=!s&&!i&&!n&&Tt(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&&!Ct.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||K(h,c))||a.push(h);return a}function Ot(t,e){return function(s){return t(e(s))}}var At=Ot(Object.keys,Object),kt=Object.prototype.hasOwnProperty;function Et(t){return nt(t)?jt(t):function(t){if(!ot(t))return At(t);var e=[];for(var s in Object(t))kt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}var Rt=Object.prototype.hasOwnProperty;function Ft(t){if(!T(t))return function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}(t);var e=ot(t),s=[];for(var i in t)("constructor"!=i||!e&&Rt.call(t,i))&&s.push(i);return s}function xt(t){return nt(t)?jt(t,!0):Ft(t)}var Mt=W(Object,"create");var zt=Object.prototype.hasOwnProperty;var It=Object.prototype.hasOwnProperty;function Lt(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 Pt(t,e){for(var s=t.length;s--;)if(Q(t[s][0],e))return s;return-1}Lt.prototype.clear=function(){this.__data__=Mt?Mt(null):{},this.size=0},Lt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Lt.prototype.get=function(t){var e=this.__data__;if(Mt){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return zt.call(e,t)?e[t]:void 0},Lt.prototype.has=function(t){var e=this.__data__;return Mt?void 0!==e[t]:It.call(e,t)},Lt.prototype.set=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Mt&&void 0===e?"__lodash_hash_undefined__":e,this};var Wt=Array.prototype.splice;function Dt(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])}}Dt.prototype.clear=function(){this.__data__=[],this.size=0},Dt.prototype.delete=function(t){var e=this.__data__,s=Pt(e,t);return!(s<0)&&(s==e.length-1?e.pop():Wt.call(e,s,1),--this.size,!0)},Dt.prototype.get=function(t){var e=this.__data__,s=Pt(e,t);return s<0?void 0:e[s][1]},Dt.prototype.has=function(t){return Pt(this.__data__,t)>-1},Dt.prototype.set=function(t,e){var s=this.__data__,i=Pt(s,t);return i<0?(++this.size,s.push([t,e])):s[i][1]=e,this};var qt=W(d,"Map");function Bt(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 Ut(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])}}Ut.prototype.clear=function(){this.size=0,this.__data__={hash:new Lt,map:new(qt||Dt),string:new Lt}},Ut.prototype.delete=function(t){var e=Bt(this,t).delete(t);return this.size-=e?1:0,e},Ut.prototype.get=function(t){return Bt(this,t).get(t)},Ut.prototype.has=function(t){return Bt(this,t).has(t)},Ut.prototype.set=function(t,e){var s=Bt(this,t),i=s.size;return s.set(t,e),this.size+=s.size==i?0:1,this};var Nt=Ot(Object.getPrototypeOf,Object),$t=Function.prototype,Ht=Object.prototype,Gt=$t.toString,Jt=Ht.hasOwnProperty,Vt=Gt.call(Object);function Xt(t){var e=this.__data__=new Dt(t);this.size=e.size}Xt.prototype.clear=function(){this.__data__=new Dt,this.size=0},Xt.prototype.delete=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s},Xt.prototype.get=function(t){return this.__data__.get(t)},Xt.prototype.has=function(t){return this.__data__.has(t)},Xt.prototype.set=function(t,e){var s=this.__data__;if(s instanceof Dt){var i=s.__data__;if(!qt||i.length<199)return i.push([t,e]),this.size=++s.size,this;s=this.__data__=new Ut(i)}return s.set(t,e),this.size=s.size,this};var Kt="object"==typeof t&&t&&!t.nodeType&&t,Zt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Qt=Zt&&Zt.exports===Kt?d.Buffer:void 0,Yt=Qt?Qt.allocUnsafe:void 0;function te(t,e){if(e)return t.slice();var s=t.length,i=Yt?Yt(s):new t.constructor(s);return t.copy(i),i}var ee=Object.prototype.propertyIsEnumerable,se=Object.getOwnPropertySymbols,ie=se?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}(se(t),(function(e){return ee.call(t,e)})))}:function(){return[]};function ne(t){return function(t,e,s){var i=e(t);return _(t)?i:function(t,e){for(var s=-1,i=e.length,n=t.length;++s<i;)t[n+s]=e[s];return t}(i,s(t))}(t,Et,ie)}var re=W(d,"DataView"),oe=W(d,"Promise"),ae=W(d,"Set"),ce="[object Map]",he="[object Promise]",le="[object Set]",ue="[object WeakMap]",de="[object DataView]",pe=R(re),fe=R(qt),ve=R(oe),ye=R(ae),ge=R(D),be=w;(re&&be(new re(new ArrayBuffer(1)))!=de||qt&&be(new qt)!=ce||oe&&be(oe.resolve())!=he||ae&&be(new ae)!=le||D&&be(new D)!=ue)&&(be=function(t){var e=w(t),s="[object Object]"==e?t.constructor:void 0,i=s?R(s):"";if(i)switch(i){case pe:return de;case fe:return ce;case ve:return he;case ye:return le;case ge:return ue}return e});var me=Object.prototype.hasOwnProperty;var we=d.Uint8Array;function Se(t){var e=new t.constructor(t.byteLength);return new we(e).set(new we(t)),e}var _e=/\w*$/;var Te=p?p.prototype:void 0,Ce=Te?Te.valueOf:void 0;function je(t,e){var s=e?Se(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}function Oe(t,e,s){var i,n,r,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return Se(t);case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return a=Se((o=t).buffer),new o.constructor(a,o.byteOffset,o.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return je(t,s);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return(r=new(n=t).constructor(n.source,_e.exec(n))).lastIndex=n.lastIndex,r;case"[object Symbol]":return i=t,Ce?Object(Ce.call(i)):{}}}function Ae(t){return"function"!=typeof t.constructor||ot(t)?{}:B(Nt(t))}var ke=St&&St.isMap,Ee=ke?gt(ke):function(t){return S(t)&&"[object Map]"==be(t)};var Re=St&&St.isSet,Fe=Re?gt(Re):function(t){return S(t)&&"[object Set]"==be(t)},xe="[object Arguments]",Me="[object Function]",ze="[object Object]",Ie={};function Le(t,e,s,i,n,r){var o,a=1&e;if(void 0!==o)return o;if(!T(t))return t;var c=_(t);if(c)o=function(t){var e=t.length,s=new t.constructor(e);return e&&"string"==typeof t[0]&&me.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t);else{var h=be(t),l=h==Me||"[object GeneratorFunction]"==h;if(vt(t))return te(t,a);if(h==ze||h==xe||l&&!n)o=l?{}:Ae(t);else{if(!Ie[h])return n?t:{};o=Oe(t,h,a)}}r||(r=new Xt);var u=r.get(t);if(u)return u;r.set(t,o),Fe(t)?t.forEach((function(i){o.add(Le(i,e,s,i,t,r))})):Ee(t)&&t.forEach((function(i,n){o.set(n,Le(i,e,s,n,t,r))}));var d=c?void 0:ne(t);return function(t,e){for(var s=-1,i=null==t?0:t.length;++s<i&&!1!==e(t[s],s,t););}(d||t,(function(i,n){d&&(i=t[n=i]),tt(o,n,Le(i,e,s,n,t,r))})),o}Ie[xe]=Ie["[object Array]"]=Ie["[object ArrayBuffer]"]=Ie["[object DataView]"]=Ie["[object Boolean]"]=Ie["[object Date]"]=Ie["[object Float32Array]"]=Ie["[object Float64Array]"]=Ie["[object Int8Array]"]=Ie["[object Int16Array]"]=Ie["[object Int32Array]"]=Ie["[object Map]"]=Ie["[object Number]"]=Ie[ze]=Ie["[object RegExp]"]=Ie["[object Set]"]=Ie["[object String]"]=Ie["[object Symbol]"]=Ie["[object Uint8Array]"]=Ie["[object Uint8ClampedArray]"]=Ie["[object Uint16Array]"]=Ie["[object Uint32Array]"]=!0,Ie["[object Error]"]=Ie[Me]=Ie["[object WeakMap]"]=!1;function Pe(t){return Le(t,5)}var We=function(t,e,s){for(var i=-1,n=Object(t),r=s(t),o=r.length;o--;){var a=r[++i];if(!1===e(n[a],a,n))break}return t};function De(t,e,s){(void 0!==s&&!Q(t[e],s)||void 0===s&&!(e in t))&&Z(t,e,s)}function qe(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Be(t){return function(t,e,s){var i=!s;s||(s={});for(var n=-1,r=e.length;++n<r;){var o=e[n],a=void 0;void 0===a&&(a=t[o]),i?Z(s,o,a):tt(s,o,a)}return s}(t,xt(t))}function Ue(t,e,s,i,n,r,o){var a=qe(t,s),c=qe(e,s),h=o.get(c);if(h)De(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),f=!p&&vt(c),v=!p&&!f&&Tt(c);u=c,p||f||v?_(a)?u=a:S(l=a)&&nt(l)?u=function(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}(a):f?(d=!1,u=te(c,!0)):v?(d=!1,u=je(c,!0)):u=[]:function(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=Nt(t);if(null===e)return!0;var s=Jt.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&Gt.call(s)==Vt}(c)||ut(c)?(u=a,ut(a)?u=Be(a):T(a)&&!j(a)||(u=Ae(c))):d=!1}d&&(o.set(c,u),n(u,c,i,r,o),o.delete(c)),De(t,s,u)}}function Ne(t,e,s,i,n){t!==e&&We(e,(function(r,o){if(n||(n=new Xt),T(r))Ue(t,e,o,s,Ne,i,n);else{var a=i?i(qe(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),De(t,o,a)}}),xt)}var $e,He=($e=function(t,e,s){Ne(t,e,s)},st((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=$e.length>3&&"function"==typeof n?(i--,n):void 0,r&&function(t,e,s){if(!T(s))return!1;var i=typeof e;return!!("number"==i?nt(s)&&K(e,s.length):"string"==i&&e in s)&&Q(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&&$e(t,o,s,n)}return t})));let Ge=null;try{Ge=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const Je=t=>Ge&&new RegExp(Ge).test(t)?(...e)=>console.log(t,...e):()=>{};class Ve extends Error{}class Xe extends Error{}const Ke=Je("rpc:ClientManager");class Ze{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=>{Ke("clearCache"),this.cache&&this.cache.clearCache(t)},this.getCachedResponse=t=>{var e;return Ke("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Ke("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,s)=>e(this,void 0,void 0,(function*(){Ke("manageClientRequest",t);const i=yield this.interceptRequestMutator(t),n=o(i);if(this.inflightCallsByKey.hasOwnProperty(n))return Ke("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const s=Pe(e);return t.correlationId&&(s.correlationId=t.correlationId),s}));const r=(()=>e(this,void 0,void 0,(function*(){var t,e;const n=null===(t=this.options.transportOptions)||void 0===t?void 0:t.preferredTransport,r=null!==(e=null==s?void 0:s.transport)&&void 0!==e?e:n,o=yield this.sendRequestWithTransport(i,Object.assign(Object.assign({},s),{transport:r})),a=yield this.interceptResponseMutator(o,i);return this.cache&&a&&this.cache.setCachedResponse(i,a),a})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Ke("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){Ke("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){Ke("interceptResponseMutator",s,t);for(const i of this.interceptors.response)try{e=yield i(e,s)}catch(i){throw Ke("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,n,r;let o;Ke("sendRequestWithTransport",t);let a=0,c=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`);c=[t]}for(;!o&&c[a];){const h=c[a];if(h.isConnected()){Ke(`sendRequestWithTransport trying ${h.name}`,t);try{let e;const i=h.sendRequest(t,s||{}),n=new Promise(((i,n)=>{e=setTimeout((()=>{n(new Ve(`Procedure ${t.procedure}`))}),(null==s?void 0:s.timeout)||this.options.deadlineMs)}));o=yield Promise.race([n,i]).finally((()=>{clearTimeout(e)}))}catch(e){if(null===(r=(n=this.options).onTransportRequestError)||void 0===r||r.call(n,e,c[a].type,t),!(e instanceof Ve||e instanceof Xe))throw e;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${c[a].name} failed ${c[a+1]?`trying next transport "${c[a+1].name}"`:"no more transports to try"}`),a++}}else a++,Ke(`sendRequestWithTransport transport ${h.name} not connected, trying next transport "${null!==(i=null===(e=c[a])||void 0===e?void 0:e.name)&&void 0!==i?i:"no next transport"}"`)}if(!o&&!this.transports[a])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(!o)throw new h(`Procedure ${t.procedure} did not get a response from the remote`);return o})),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 Qe{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Qe.DEFAULT_CACHE_MAX_AGE_MS=3e5,Qe.DEFAULT_CACHE_MAX_SIZE=100;const Ye="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,ts=new Set,es="object"==typeof process&&process?process:{},ss=(t,e,s,i)=>{"function"==typeof es.emitWarning?es.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)};let is=globalThis.AbortController,ns=globalThis.AbortSignal;if(void 0===is){ns=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},is=class{constructor(){e()}signal=new ns;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"!==es.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,ss("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 rs=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),os=t=>rs(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?as:null:null;class as extends Array{constructor(t){super(t),this.fill(0)}}class cs{heap;length;static#t=!1;static create(t){const e=os(t);if(!e)return[];cs.#t=!0;const s=new cs(t,e);return cs.#t=!1,s}constructor(t,e){if(!cs.#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 hs{#e;#s;#i;#n;#r;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#m;#w;#S;#_;#T;static unsafeExposeInternals(t){return{starts:t.#m,ttls:t.#w,sizes:t.#b,keyMap:t.#h,keyList:t.#l,valList:t.#u,next:t.#d,prev:t.#p,get head(){return t.#f},get tail(){return t.#v},free:t.#y,isBackgroundFetch:e=>t.#C(e),backgroundFetch:(e,s,i,n)=>t.#j(e,s,i,n),moveToTail:e=>t.#O(e),indexes:e=>t.#A(e),rindexes:e=>t.#k(e),isStale:e=>t.#E(e)}}get max(){return this.#e}get maxSize(){return this.#s}get calculatedSize(){return this.#c}get size(){return this.#a}get fetchMethod(){return this.#r}get memoMethod(){return this.#o}get dispose(){return this.#i}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:s,ttlResolution:i=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:h,noDisposeOnSet:l,noUpdateTTL:u,maxSize:d=0,maxEntrySize:p=0,sizeCalculation:f,fetchMethod:v,memoMethod:y,noDeleteOnFetchRejection:g,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:w,ignoreFetchAbort:S}=t;if(0!==e&&!rs(e))throw new TypeError("max option must be a nonnegative integer");const _=e?os(e):Array;if(!_)throw new Error("invalid max value: "+e);if(this.#e=e,this.#s=d,this.maxEntrySize=p||this.#s,this.sizeCalculation=f,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!==y&&"function"!=typeof y)throw new TypeError("memoMethod must be a function if defined");if(this.#o=y,void 0!==v&&"function"!=typeof v)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=v,this.#_=!!v,this.#h=new Map,this.#l=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#d=new _(e),this.#p=new _(e),this.#f=0,this.#v=0,this.#y=cs.create(e),this.#a=0,this.#c=0,"function"==typeof c&&(this.#i=c),"function"==typeof h?(this.#n=h,this.#g=[]):(this.#n=void 0,this.#g=void 0),this.#S=!!this.#i,this.#T=!!this.#n,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!g,this.allowStaleOnFetchRejection=!!m,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!S,0!==this.maxEntrySize){if(0!==this.#s&&!rs(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!rs(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#R()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=rs(i)||0===i?i:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!rs(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#F()}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=>!ts.has(t))(t)){ts.add(t);ss("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,hs)}}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#F(){const t=new as(this.#e),e=new as(this.#e);this.#w=t,this.#m=e,this.#x=(s,i,n=Ye.now())=>{if(e[s]=0!==i?n:0,t[s]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#E(s)&&this.#M(this.#l[s],"expire")}),i+1);t.unref&&t.unref()}},this.#z=s=>{e[s]=0!==t[s]?Ye.now():0},this.#I=(n,r)=>{if(t[r]){const o=t[r],a=e[r];if(!o||!a)return;n.ttl=o,n.start=a,n.now=s||i();const c=n.now-a;n.remainingTTL=o-c}};let s=0;const i=()=>{const t=Ye.now();if(this.ttlResolution>0){s=t;const e=setTimeout((()=>s=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#h.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];if(!o||!a)return 1/0;return o-((s||i())-a)},this.#E=n=>{const r=e[n],o=t[n];return!!o&&!!r&&(s||i())-r>o}}#z=()=>{};#I=()=>{};#x=()=>{};#E=()=>!1;#R(){const t=new as(this.#e);this.#c=0,this.#b=t,this.#L=e=>{this.#c-=t[e],t[e]=0},this.#P=(t,e,s,i)=>{if(this.#C(e))return 0;if(!rs(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),!rs(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return s},this.#W=(e,s,i)=>{if(t[e]=s,this.#s){const s=this.#s-t[e];for(;this.#c>s;)this.#D(!0)}this.#c+=t[e],i&&(i.entrySize=s,i.totalCalculatedSize=this.#c)}}#L=t=>{};#W=(t,e,s)=>{};#P=(t,e,s,i)=>{if(s||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#v;this.#q(e)&&(!t&&this.#E(e)||(yield e),e!==this.#f);)e=this.#p[e]}*#k({allowStale:t=this.allowStale}={}){if(this.#a)for(let e=this.#f;this.#q(e)&&(!t&&this.#E(e)||(yield e),e!==this.#v);)e=this.#d[e]}#q(t){return void 0!==t&&this.#h.get(this.#l[t])===t}*entries(){for(const t of this.#A())void 0===this.#u[t]||void 0===this.#l[t]||this.#C(this.#u[t])||(yield[this.#l[t],this.#u[t]])}*rentries(){for(const t of this.#k())void 0===this.#u[t]||void 0===this.#l[t]||this.#C(this.#u[t])||(yield[this.#l[t],this.#u[t]])}*keys(){for(const t of this.#A()){const e=this.#l[t];void 0===e||this.#C(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#k()){const e=this.#l[t];void 0===e||this.#C(this.#u[t])||(yield e)}}*values(){for(const t of this.#A()){void 0===this.#u[t]||this.#C(this.#u[t])||(yield this.#u[t])}}*rvalues(){for(const t of this.#k()){void 0===this.#u[t]||this.#C(this.#u[t])||(yield this.#u[t])}}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(const s of this.#A()){const i=this.#u[s],n=this.#C(i)?i.__staleWhileFetching:i;if(void 0!==n&&t(n,this.#l[s],this))return this.get(this.#l[s],e)}}forEach(t,e=this){for(const s of this.#A()){const i=this.#u[s],n=this.#C(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#l[s],this)}}rforEach(t,e=this){for(const s of this.#k()){const i=this.#u[s],n=this.#C(i)?i.__staleWhileFetching:i;void 0!==n&&t.call(e,n,this.#l[s],this)}}purgeStale(){let t=!1;for(const e of this.#k({allowStale:!0}))this.#E(e)&&(this.#M(this.#l[e],"expire"),t=!0);return t}info(t){const e=this.#h.get(t);if(void 0===e)return;const s=this.#u[e],i=this.#C(s)?s.__staleWhileFetching:s;if(void 0===i)return;const n={value:i};if(this.#w&&this.#m){const t=this.#w[e],s=this.#m[e];if(t&&s){const e=t-(Ye.now()-s);n.ttl=e,n.start=Date.now()}}return this.#b&&(n.size=this.#b[e]),n}dump(){const t=[];for(const e of this.#A({allowStale:!0})){const s=this.#l[e],i=this.#u[e],n=this.#C(i)?i.__staleWhileFetching:i;if(void 0===n||void 0===s)continue;const r={value:n};if(this.#w&&this.#m){r.ttl=this.#w[e];const t=Ye.now()-this.#m[e];r.start=Math.floor(Date.now()-t)}this.#b&&(r.size=this.#b[e]),t.unshift([s,r])}return t}load(t){this.clear();for(const[e,s]of t){if(s.start){const t=Date.now()-s.start;s.start=Ye.now()-t}this.set(e,s.value,s)}}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.#P(t,e,s.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#M(t,"set"),this;let l=0===this.#a?void 0:this.#h.get(t);if(void 0===l)l=0===this.#a?this.#v:0!==this.#y.length?this.#y.pop():this.#a===this.#e?this.#D(!1):this.#a,this.#l[l]=t,this.#u[l]=e,this.#h.set(t,l),this.#d[this.#v]=l,this.#p[l]=this.#v,this.#v=l,this.#a++,this.#W(l,h,a),a&&(a.set="add"),c=!1;else{this.#O(l);const s=this.#u[l];if(e!==s){if(this.#_&&this.#C(s)){s.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=s;void 0===e||r||(this.#S&&this.#i?.(e,t,"set"),this.#T&&this.#g?.push([e,t,"set"]))}else r||(this.#S&&this.#i?.(s,t,"set"),this.#T&&this.#g?.push([s,t,"set"]));if(this.#L(l),this.#W(l,h,a),this.#u[l]=e,a){a.set="replace";const t=s&&this.#C(s)?s.__staleWhileFetching:s;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#w||this.#F(),this.#w&&(c||this.#x(l,i,n),a&&this.#I(a,l)),!r&&this.#T&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#a;){const t=this.#u[this.#f];if(this.#D(!0),this.#C(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#T&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#D(t){const e=this.#f,s=this.#l[e],i=this.#u[e];return this.#_&&this.#C(i)?i.__abortController.abort(new Error("evicted")):(this.#S||this.#T)&&(this.#S&&this.#i?.(i,s,"evict"),this.#T&&this.#g?.push([i,s,"evict"])),this.#L(e),t&&(this.#l[e]=void 0,this.#u[e]=void 0,this.#y.push(e)),1===this.#a?(this.#f=this.#v=0,this.#y.length=0):this.#f=this.#d[e],this.#h.delete(s),this.#a--,e}has(t,e={}){const{updateAgeOnHas:s=this.updateAgeOnHas,status:i}=e,n=this.#h.get(t);if(void 0!==n){const t=this.#u[n];if(this.#C(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#E(n))return s&&this.#z(n),i&&(i.has="hit",this.#I(i,n)),!0;i&&(i.has="stale",this.#I(i,n))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:s=this.allowStale}=e,i=this.#h.get(t);if(void 0===i||!s&&this.#E(i))return;const n=this.#u[i];return this.#C(n)?n.__staleWhileFetching:n}#j(t,e,s,i){const n=void 0===e?void 0:this.#u[e];if(this.#C(n))return n;const r=new is,{signal:o}=s;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:s,context:i},c=(i,n=!1)=>{const{aborted:o}=r.signal,c=s.ignoreFetchAbort&&void 0!==i;if(s.status&&(o&&!n?(s.status.fetchAborted=!0,s.status.fetchError=r.signal.reason,c&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),o&&!c&&!n)return h(r.signal.reason);const u=l;return this.#u[e]===l&&(void 0===i?u.__staleWhileFetching?this.#u[e]=u.__staleWhileFetching:this.#M(t,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(t,i,a.options))),i},h=i=>{const{aborted:n}=r.signal,o=n&&s.allowStaleOnFetchAbort,a=o||s.allowStaleOnFetchRejection,c=a||s.noDeleteOnFetchRejection,h=l;if(this.#u[e]===l){!c||void 0===h.__staleWhileFetching?this.#M(t,"fetch"):o||(this.#u[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 l=new Promise(((e,i)=>{const o=this.#r?.(t,n,a);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=>c(t,!0)))}))})).then(c,(t=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=t),h(t)))),u=Object.assign(l,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return void 0===e?(this.set(t,u,{...a.options,status:void 0}),e=this.#h.get(t)):this.#u[e]=u,u}#C(t){if(!this.#_)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof is}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.#_)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 m=this.#h.get(t);if(void 0===m){y&&(y.fetch="miss");const e=this.#j(t,m,b,f);return e.__returned=e}{const e=this.#u[m];if(this.#C(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.#E(m);if(!v&&!n)return y&&(y.fetch="hit"),this.#O(m),i&&this.#z(m),y&&this.#I(y,m),e;const r=this.#j(t,m,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}}async forceFetch(t,e={}){const s=await this.fetch(t,e);if(void 0===s)throw new Error("fetch() returned undefined");return s}memo(t,e={}){const s=this.#o;if(!s)throw new Error("no memoMethod provided to constructor");const{context:i,forceRefresh:n,...r}=e,o=this.get(t,r);if(!n&&void 0!==o)return o;const a=s(t,o,{options:r,context:i});return this.set(t,a,r),a}get(t,e={}){const{allowStale:s=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#u[o],a=this.#C(e);return r&&this.#I(r,o),this.#E(o)?(r&&(r.get="stale"),a?(r&&s&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),s?e.__staleWhileFetching:void 0):(n||this.#M(t,"expire"),r&&s&&(r.returnedStale=!0),s?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#O(o),i&&this.#z(o),e))}r&&(r.get="miss")}#B(t,e){this.#p[e]=t,this.#d[t]=e}#O(t){t!==this.#v&&(t===this.#f?this.#f=this.#d[t]:this.#B(this.#p[t],this.#d[t]),this.#B(this.#v,t),this.#v=t)}delete(t){return this.#M(t,"delete")}#M(t,e){let s=!1;if(0!==this.#a){const i=this.#h.get(t);if(void 0!==i)if(s=!0,1===this.#a)this.#U(e);else{this.#L(i);const s=this.#u[i];if(this.#C(s)?s.__abortController.abort(new Error("deleted")):(this.#S||this.#T)&&(this.#S&&this.#i?.(s,t,e),this.#T&&this.#g?.push([s,t,e])),this.#h.delete(t),this.#l[i]=void 0,this.#u[i]=void 0,i===this.#v)this.#v=this.#p[i];else if(i===this.#f)this.#f=this.#d[i];else{const t=this.#p[i];this.#d[t]=this.#d[i];const e=this.#d[i];this.#p[e]=this.#p[i]}this.#a--,this.#y.push(i)}}if(this.#T&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}return s}clear(){return this.#U("delete")}#U(t){for(const e of this.#k({allowStale:!0})){const s=this.#u[e];if(this.#C(s))s.__abortController.abort(new Error("deleted"));else{const i=this.#l[e];this.#S&&this.#i?.(s,i,t),this.#T&&this.#g?.push([s,i,t])}}if(this.#h.clear(),this.#u.fill(void 0),this.#l.fill(void 0),this.#w&&this.#m&&(this.#w.fill(0),this.#m.fill(0)),this.#b&&this.#b.fill(0),this.#f=0,this.#v=0,this.#y.length=0,this.#c=0,this.#a=0,this.#T&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#n?.(...e)}}}const ls=Je("rpc:InMemoryCache");class us{constructor(t){this.clearCache=t=>{var e,s;ls("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;ls("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;ls("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 hs({max:(null==t?void 0:t.cacheMaxSize)||us.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||us.DEFAULT_CACHE_MAX_AGE_MS})}}var ds;us.DEFAULT_CACHE_MAX_AGE_MS=9e5,us.DEFAULT_CACHE_MAX_SIZE=200,t.TransportType=void 0,(ds=t.TransportType||(t.TransportType={})).http="http",ds.websocket="websocket";const ps=t=>`${t.scope}::${t.procedure}::${t.version}`,fs=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},vs=Je("rpc:HTTPTransport");class ys{constructor(s){this.options=s,this.name="HttpTransport",this.type=t.TransportType.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):"function"==typeof fetch},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){vs("sendRequest",t);try{const e=JSON.stringify(Object.assign({identity:this.identity},t)),s=yield 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 vs("sendRequest() error",e),new Xe(`HTTPTransport request error ${ps(t)} (${null==e?void 0:e.message})`)}})),this.setIdentity=t=>{vs("setIdentity",t),this.identity=t},this.host=s.host}}class gs{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 bs=t=>new Promise((e=>setTimeout(e,t))),ms=Je("rpc:WebSocketTransport");class ws{constructor(s){var i,n;this.options=s,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.type=t.TransportType.websocket,this.isConnected=()=>{var t;return(null===(t=this.websocket)||void 0===t?void 0:t.readyState)===WebSocket.OPEN},this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e,s;let i=t;try{i=JSON.stringify({clientMessage:t})}catch(e){return void console.error('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}ms("sendClientMessageToServer",i),(null===(e=this.websocket)||void 0===e?void 0:e.readyState)===WebSocket.OPEN?null===(s=this.websocket)||void 0===s||s.send(i):ms("WebSocket is not connected. Message not sent:",i)},this.sendRequest=(t,s)=>e(this,void 0,void 0,(function*(){var e;if(ms("sendRequest",t),(null===(e=this.websocket)||void 0===e?void 0:e.readyState)!==WebSocket.OPEN)throw ms("sendRequest WebSocket is not connected"),new Xe("WebSocket is not connected");let i=0;for(;this.isWaitingForIdentityConfirmation;){if(ms("waiting for identity confirmation"),i++,i>=20)throw new Xe("Timed out waiting for identity confirmation");yield bs(100)}return this.sendCall(t,s)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(ms("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?ms('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{ms("setIdentity with remote complete")})).catch((t=>{ms("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):ms("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(ms("connect",this.host),this.websocket)return void ms("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):ms("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 Xe("Websocket closed"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):ms("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>e(this,void 0,void 0,(function*(){var e;ms("_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;ms("handleWebSocketMsg",t);try{e=JSON.parse(t.data)}catch(t){return void ms("error parsing WS msg",t)}if(e&&"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*(){ms("resetConnection");const t=this.isConnected();return yield this._disconnect("WebSocketTransport#resetConnection"),t&&(yield bs(300),yield this._connect()),this.isConnected()})),this.sendCall=(t,s)=>e(this,void 0,void 0,(function*(){var e;ms("sendCall",t);const i=`${Date.now()}-${Math.random().toString()}`;t.correlationId=t.correlationId||i;const n=new gs(ps(t),s.timeout||this.options.rpcOptions.deadlineMs);if(!this.isConnected()){const t=new Xe("Cannot send message: WebSocket is not connected");return ms("sendCall failed - websocket not connected",t),n.reject(t),n.promise}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=>{ms(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},ms("new WebSocketTransport()"),this.host=s.host,!1!==(null===(n=null===(i=s.rpcOptions.transportOptions)||void 0===i?void 0:i.websocket)||void 0===n?void 0:n.autoConnect)&&this.connect()}}class Ss{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 _s=Je("rpc:RPCClient"),Ts={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class Cs{constructor(t){var s,i,r,a,h,l;if(this.options=t,this.webSocketConnectionChangeListeners=[],this.vent=new Ss,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?fs(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=He(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?fs(t):t,e&&(s.args=e);const i=this.callManager.getCachedResponse(s);if(i)return i},this.getIdentity=()=>this.identity?Pe(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?fs(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):_s("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=Pe(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const s=Pe(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(Ts.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(Ts.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(Ts.INTERCEPTOR_MUSTBE_FUNC);let u;const d={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};u="browser"==t.cacheType?new Qe(d):new us(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 ws({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 ys({host:t.hosts.http,rpcOptions:t}),p.push(this.httpTransport)),this.callManager=new Ze({cache:u,deadlineMs:t.deadlineMs||Cs.DEFAULT_DEADLINE_MS,onTransportRequestError:t.onTransportRequestError,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:p,transportOptions:t.transportOptions})}subscribe(t,e){const s="string"==typeof t.request?fs(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?fs(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)}}Cs.DEFAULT_DEADLINE_MS=1e4,t.CallRequestTransportError=Xe,t.CallRequestTransportTimeoutError=Ve,t.CallResponseError=c,t.RPCClient=Cs,t.RPCResponse=a}));
{
"name": "@therms/rpc-client",
"version": "3.3.10",
"version": "3.3.11",
"description": "RPC framework, browser client lib",

@@ -9,2 +9,3 @@ "private": false,

"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",

@@ -11,0 +12,0 @@ "default": "./dist/umd.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet