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

@therms/rpc-client

Package Overview
Dependencies
Maintainers
0
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@therms/rpc-client - npm Package Compare versions

Comparing version 3.2.1 to 3.2.2

2

dist/cjs.js

@@ -21,3 +21,3 @@ 'use strict';

***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */

@@ -24,0 +24,0 @@

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

***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */

@@ -22,0 +22,0 @@

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc