@therms/rpc-client
Advanced tools
Comparing version 2.16.1 to 2.16.2
@@ -58,2 +58,7 @@ 'use strict'; | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
const DEFAULT_REQUEST_SCOPE = 'global'; | ||
@@ -268,12 +273,7 @@ const DEFAULT_REQUEST_VERSION = '1'; | ||
try { | ||
for (var _d = true, _e = __asyncValues(this.interceptors.request), _f; _f = yield _e.next(), _a = _f.done, !_a;) { | ||
for (var _d = true, _e = __asyncValues(this.interceptors.request), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { | ||
_c = _f.value; | ||
_d = false; | ||
try { | ||
const interceptor = _c; | ||
request = yield interceptor(request); | ||
} | ||
finally { | ||
_d = true; | ||
} | ||
const interceptor = _c; | ||
request = yield interceptor(request); | ||
} | ||
@@ -280,0 +280,0 @@ } |
@@ -50,2 +50,7 @@ import stringify from 'fast-json-stable-stringify'; | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
const DEFAULT_REQUEST_SCOPE = 'global'; | ||
@@ -260,12 +265,7 @@ const DEFAULT_REQUEST_VERSION = '1'; | ||
try { | ||
for (var _d = true, _e = __asyncValues(this.interceptors.request), _f; _f = yield _e.next(), _a = _f.done, !_a;) { | ||
for (var _d = true, _e = __asyncValues(this.interceptors.request), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { | ||
_c = _f.value; | ||
_d = false; | ||
try { | ||
const interceptor = _c; | ||
request = yield interceptor(request); | ||
} | ||
finally { | ||
_d = true; | ||
} | ||
const interceptor = _c; | ||
request = yield interceptor(request); | ||
} | ||
@@ -272,0 +272,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,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{c(s.next(t))}catch(t){r(t)}}function a(t){try{c(s.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}c((s=s.apply(t,e||[])).next())}))}function i(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,s=t[Symbol.asyncIterator];return s?s.call(t):(t=i(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(e){return new Promise((function(s,n){(function(t,e,i,s){Promise.resolve(s).then((function(e){t({value:e,done:i})}),e)})(s,n,(e=t[i](e)).done,e.value)}))}}}class n{constructor(t){const{args:e,correlationId:i,identity:s,procedure:n,scope:r,version:o}=t;if(this.args=e,i&&"string"!=typeof i)throw new Error("correlationId must be a string");if(this.correlationId=i||Math.random().toString(),s){if("object"!=typeof s)throw new Error("identity must be an object");if(s.authorization&&"string"!=typeof s.authorization)throw new Error("identity.authorization must be a string");if(s.deviceName&&"string"!=typeof s.deviceName)throw new Error("identity.deviceName must be a string");if(s.metadata&&"object"!=typeof s.metadata)throw new Error("identity.metadata must be a object");this.identity=s}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}}class r extends Error{}class o extends Error{}class a extends Error{}function c(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const h=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var i,s="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(i=e.cmp,function(t){return function(e,s){var n={key:e,value:t[e]},r={key:s,value:t[s]};return i(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 i,o;if(Array.isArray(e)){for(o="[",i=0;i<e.length;i++)i&&(o+=","),o+=t(e[i])||"null";return o+"]"}if(null===e)return"null";if(-1!==r.indexOf(e)){if(s)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="",i=0;i<c.length;i++){var h=c[i],l=t(e[h]);l&&(o&&(o+=","),o+=JSON.stringify(h)+":"+l)}return r.splice(a,1),"{"+o+"}"}}(t)}(function(t,e={}){if(!c(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:i,compare:s}=e,n=[],r=[],o=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const i=[];return n.push(t),r.push(i),i.push(...t.map((t=>Array.isArray(t)?o(t):c(t)?a(t):t))),i},a=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const h={},l=Object.keys(t).sort(s);n.push(t),r.push(h);for(const e of l){const s=t[e];let n;n=i&&Array.isArray(s)?o(s):i&&c(s)?a(s):s,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:n}))}return h};return Array.isArray(t)?i?o(t):t.slice():a(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;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")(),f=d.Symbol,p=Object.prototype,v=p.hasOwnProperty,y=p.toString,g=f?f.toStringTag:void 0;var b=Object.prototype.toString;var w="[object Null]",m="[object Undefined]",S=f?f.toStringTag:void 0;function _(t){return null==t?void 0===t?m:w:S&&S in Object(t)?function(t){var e=v.call(t,g),i=t[g];try{t[g]=void 0;var s=!0}catch(t){}var n=y.call(t);return s&&(e?t[g]=i:delete t[g]),n}(t):function(t){return b.call(t)}(t)}function T(t){return null!=t&&"object"==typeof t}var C=Array.isArray;function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function O(t){return t}var A="[object AsyncFunction]",k="[object Function]",F="[object GeneratorFunction]",z="[object Proxy]";function E(t){if(!j(t))return!1;var e=_(t);return e==k||e==F||e==A||e==z}var R,x=d["__core-js_shared__"],I=(R=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var M=Function.prototype.toString;function L(t){if(null!=t){try{return M.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var P=/^\[object .+?Constructor\]$/,D=Function.prototype,W=Object.prototype,q=D.toString,B=W.hasOwnProperty,U=RegExp("^"+q.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function N(t){return!(!j(t)||(e=t,I&&I in e))&&(E(t)?U:P).test(L(t));var e}function $(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return N(i)?i:void 0}var G=$(d,"WeakMap"),H=Object.create,J=function(){function t(){}return function(e){if(!j(e))return{};if(H)return H(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function V(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e}var X=Date.now;var K,Z,Q,Y=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),tt=Y,et=tt?function(t,e){return tt(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:O,it=(K=et,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)}),st=it;var nt=9007199254740991,rt=/^(?:0|[1-9]\d*)$/;function ot(t,e){var i=typeof t;return!!(e=null==e?nt:e)&&("number"==i||"symbol"!=i&&rt.test(t))&&t>-1&&t%1==0&&t<e}function at(t,e,i){"__proto__"==e&&tt?tt(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function ct(t,e){return t===e||t!=t&&e!=e}var ht=Object.prototype.hasOwnProperty;function lt(t,e,i){var s=t[e];ht.call(t,e)&&ct(s,i)&&(void 0!==i||e in t)||at(t,e,i)}function ut(t,e,i,s){var n=!i;i||(i={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=s?s(i[a],t[a],a,i,t):void 0;void 0===c&&(c=t[a]),n?at(i,a,c):lt(i,a,c)}return i}var dt=Math.max;function ft(t,e){return st(function(t,e,i){return e=dt(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=dt(s.length-e,0),o=Array(r);++n<r;)o[n]=s[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=s[n];return a[e]=i(o),function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}(t,this,a)}}(t,e,O),t+"")}var pt=9007199254740991;function vt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=pt}function yt(t){return null!=t&&vt(t.length)&&!E(t)}var gt=Object.prototype;function bt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||gt)}function wt(t){return T(t)&&"[object Arguments]"==_(t)}var mt=Object.prototype,St=mt.hasOwnProperty,_t=mt.propertyIsEnumerable,Tt=wt(function(){return arguments}())?wt:function(t){return T(t)&&St.call(t,"callee")&&!_t.call(t,"callee")},Ct=Tt;var jt="object"==typeof t&&t&&!t.nodeType&&t,Ot=jt&&"object"==typeof module&&module&&!module.nodeType&&module,At=Ot&&Ot.exports===jt?d.Buffer:void 0,kt=(At?At.isBuffer:void 0)||function(){return!1},Ft={};function zt(t){return function(e){return t(e)}}Ft["[object Float32Array]"]=Ft["[object Float64Array]"]=Ft["[object Int8Array]"]=Ft["[object Int16Array]"]=Ft["[object Int32Array]"]=Ft["[object Uint8Array]"]=Ft["[object Uint8ClampedArray]"]=Ft["[object Uint16Array]"]=Ft["[object Uint32Array]"]=!0,Ft["[object Arguments]"]=Ft["[object Array]"]=Ft["[object ArrayBuffer]"]=Ft["[object Boolean]"]=Ft["[object DataView]"]=Ft["[object Date]"]=Ft["[object Error]"]=Ft["[object Function]"]=Ft["[object Map]"]=Ft["[object Number]"]=Ft["[object Object]"]=Ft["[object RegExp]"]=Ft["[object Set]"]=Ft["[object String]"]=Ft["[object WeakMap]"]=!1;var Et="object"==typeof t&&t&&!t.nodeType&&t,Rt=Et&&"object"==typeof module&&module&&!module.nodeType&&module,xt=Rt&&Rt.exports===Et&&l.process,It=function(){try{var t=Rt&&Rt.require&&Rt.require("util").types;return t||xt&&xt.binding&&xt.binding("util")}catch(t){}}(),Mt=It&&It.isTypedArray,Lt=Mt?zt(Mt):function(t){return T(t)&&vt(t.length)&&!!Ft[_(t)]},Pt=Object.prototype.hasOwnProperty;function Dt(t,e){var i=C(t),s=!i&&Ct(t),n=!i&&!s&&kt(t),r=!i&&!s&&!n&&Lt(t),o=i||s||n||r,a=o?function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s}(t.length,String):[],c=a.length;for(var h in t)!e&&!Pt.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ot(h,c))||a.push(h);return a}function Wt(t,e){return function(i){return t(e(i))}}var qt=Wt(Object.keys,Object),Bt=Object.prototype.hasOwnProperty;function Ut(t){return yt(t)?Dt(t):function(t){if(!bt(t))return qt(t);var e=[];for(var i in Object(t))Bt.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var Nt=Object.prototype.hasOwnProperty;function $t(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=bt(t),i=[];for(var s in t)("constructor"!=s||!e&&Nt.call(t,s))&&i.push(s);return i}function Gt(t){return yt(t)?Dt(t,!0):$t(t)}var Ht=$(Object,"create");var Jt=Object.prototype.hasOwnProperty;var Vt=Object.prototype.hasOwnProperty;function Xt(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function Kt(t,e){for(var i=t.length;i--;)if(ct(t[i][0],e))return i;return-1}Xt.prototype.clear=function(){this.__data__=Ht?Ht(null):{},this.size=0},Xt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Xt.prototype.get=function(t){var e=this.__data__;if(Ht){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Jt.call(e,t)?e[t]:void 0},Xt.prototype.has=function(t){var e=this.__data__;return Ht?void 0!==e[t]:Vt.call(e,t)},Xt.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Ht&&void 0===e?"__lodash_hash_undefined__":e,this};var Zt=Array.prototype.splice;function Qt(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}Qt.prototype.clear=function(){this.__data__=[],this.size=0},Qt.prototype.delete=function(t){var e=this.__data__,i=Kt(e,t);return!(i<0)&&(i==e.length-1?e.pop():Zt.call(e,i,1),--this.size,!0)},Qt.prototype.get=function(t){var e=this.__data__,i=Kt(e,t);return i<0?void 0:e[i][1]},Qt.prototype.has=function(t){return Kt(this.__data__,t)>-1},Qt.prototype.set=function(t,e){var i=this.__data__,s=Kt(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};var Yt=$(d,"Map");function te(t,e){var i,s,n=t.__data__;return("string"==(s=typeof(i=e))||"number"==s||"symbol"==s||"boolean"==s?"__proto__"!==i:null===i)?n["string"==typeof e?"string":"hash"]:n.map}function ee(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function ie(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t}ee.prototype.clear=function(){this.size=0,this.__data__={hash:new Xt,map:new(Yt||Qt),string:new Xt}},ee.prototype.delete=function(t){var e=te(this,t).delete(t);return this.size-=e?1:0,e},ee.prototype.get=function(t){return te(this,t).get(t)},ee.prototype.has=function(t){return te(this,t).has(t)},ee.prototype.set=function(t,e){var i=te(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};var se=Wt(Object.getPrototypeOf,Object),ne="[object Object]",re=Function.prototype,oe=Object.prototype,ae=re.toString,ce=oe.hasOwnProperty,he=ae.call(Object);function le(t){var e=this.__data__=new Qt(t);this.size=e.size}le.prototype.clear=function(){this.__data__=new Qt,this.size=0},le.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},le.prototype.get=function(t){return this.__data__.get(t)},le.prototype.has=function(t){return this.__data__.has(t)},le.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Qt){var s=i.__data__;if(!Yt||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new ee(s)}return i.set(t,e),this.size=i.size,this};var ue="object"==typeof t&&t&&!t.nodeType&&t,de=ue&&"object"==typeof module&&module&&!module.nodeType&&module,fe=de&&de.exports===ue?d.Buffer:void 0,pe=fe?fe.allocUnsafe:void 0;function ve(t,e){if(e)return t.slice();var i=t.length,s=pe?pe(i):new t.constructor(i);return t.copy(s),s}function ye(){return[]}var ge=Object.prototype.propertyIsEnumerable,be=Object.getOwnPropertySymbols,we=be?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var o=t[i];e(o,i,t)&&(r[n++]=o)}return r}(be(t),(function(e){return ge.call(t,e)})))}:ye;var me=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ie(e,we(t)),t=se(t);return e}:ye;function Se(t,e,i){var s=e(t);return C(t)?s:ie(s,i(t))}function _e(t){return Se(t,Ut,we)}function Te(t){return Se(t,Gt,me)}var Ce=$(d,"DataView"),je=$(d,"Promise"),Oe=$(d,"Set"),Ae="[object Map]",ke="[object Promise]",Fe="[object Set]",ze="[object WeakMap]",Ee="[object DataView]",Re=L(Ce),xe=L(Yt),Ie=L(je),Me=L(Oe),Le=L(G),Pe=_;(Ce&&Pe(new Ce(new ArrayBuffer(1)))!=Ee||Yt&&Pe(new Yt)!=Ae||je&&Pe(je.resolve())!=ke||Oe&&Pe(new Oe)!=Fe||G&&Pe(new G)!=ze)&&(Pe=function(t){var e=_(t),i="[object Object]"==e?t.constructor:void 0,s=i?L(i):"";if(s)switch(s){case Re:return Ee;case xe:return Ae;case Ie:return ke;case Me:return Fe;case Le:return ze}return e});var De=Pe,We=Object.prototype.hasOwnProperty;var qe=d.Uint8Array;function Be(t){var e=new t.constructor(t.byteLength);return new qe(e).set(new qe(t)),e}var Ue=/\w*$/;var Ne=f?f.prototype:void 0,$e=Ne?Ne.valueOf:void 0;function Ge(t,e){var i=e?Be(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}var He="[object Boolean]",Je="[object Date]",Ve="[object Map]",Xe="[object Number]",Ke="[object RegExp]",Ze="[object Set]",Qe="[object String]",Ye="[object Symbol]",ti="[object ArrayBuffer]",ei="[object DataView]",ii="[object Float32Array]",si="[object Float64Array]",ni="[object Int8Array]",ri="[object Int16Array]",oi="[object Int32Array]",ai="[object Uint8Array]",ci="[object Uint8ClampedArray]",hi="[object Uint16Array]",li="[object Uint32Array]";function ui(t,e,i){var s,n,r,o=t.constructor;switch(e){case ti:return Be(t);case He:case Je:return new o(+t);case ei:return function(t,e){var i=e?Be(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case ii:case si:case ni:case ri:case oi:case ai:case ci:case hi:case li:return Ge(t,i);case Ve:return new o;case Xe:case Qe:return new o(t);case Ke:return(r=new(n=t).constructor(n.source,Ue.exec(n))).lastIndex=n.lastIndex,r;case Ze:return new o;case Ye:return s=t,$e?Object($e.call(s)):{}}}function di(t){return"function"!=typeof t.constructor||bt(t)?{}:J(se(t))}var fi=It&&It.isMap,pi=fi?zt(fi):function(t){return T(t)&&"[object Map]"==De(t)};var vi=It&&It.isSet,yi=vi?zt(vi):function(t){return T(t)&&"[object Set]"==De(t)},gi=1,bi=2,wi=4,mi="[object Arguments]",Si="[object Function]",_i="[object GeneratorFunction]",Ti="[object Object]",Ci={};function ji(t,e,i,s,n,r){var o,a=e&gi,c=e&bi,h=e&wi;if(i&&(o=n?i(t,s,n,r):i(t)),void 0!==o)return o;if(!j(t))return t;var l=C(t);if(l){if(o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&We.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!a)return V(t,o)}else{var u=De(t),d=u==Si||u==_i;if(kt(t))return ve(t,a);if(u==Ti||u==mi||d&&!n){if(o=c||d?{}:di(t),!a)return c?function(t,e){return ut(t,me(t),e)}(t,function(t,e){return t&&ut(e,Gt(e),t)}(o,t)):function(t,e){return ut(t,we(t),e)}(t,function(t,e){return t&&ut(e,Ut(e),t)}(o,t))}else{if(!Ci[u])return n?t:{};o=ui(t,u,a)}}r||(r=new le);var f=r.get(t);if(f)return f;r.set(t,o),yi(t)?t.forEach((function(s){o.add(ji(s,e,i,s,t,r))})):pi(t)&&t.forEach((function(s,n){o.set(n,ji(s,e,i,n,t,r))}));var p=l?void 0:(h?c?Te:_e:c?Gt:Ut)(t);return function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i,t););}(p||t,(function(s,n){p&&(s=t[n=s]),lt(o,n,ji(s,e,i,n,t,r))})),o}Ci[mi]=Ci["[object Array]"]=Ci["[object ArrayBuffer]"]=Ci["[object DataView]"]=Ci["[object Boolean]"]=Ci["[object Date]"]=Ci["[object Float32Array]"]=Ci["[object Float64Array]"]=Ci["[object Int8Array]"]=Ci["[object Int16Array]"]=Ci["[object Int32Array]"]=Ci["[object Map]"]=Ci["[object Number]"]=Ci[Ti]=Ci["[object RegExp]"]=Ci["[object Set]"]=Ci["[object String]"]=Ci["[object Symbol]"]=Ci["[object Uint8Array]"]=Ci["[object Uint8ClampedArray]"]=Ci["[object Uint16Array]"]=Ci["[object Uint32Array]"]=!0,Ci["[object Error]"]=Ci[Si]=Ci["[object WeakMap]"]=!1;function Oi(t){return ji(t,5)}var Ai,ki=function(t,e,i){for(var s=-1,n=Object(t),r=i(t),o=r.length;o--;){var a=r[Ai?o:++s];if(!1===e(n[a],a,n))break}return t};function Fi(t,e,i){(void 0!==i&&!ct(t[e],i)||void 0===i&&!(e in t))&&at(t,e,i)}function zi(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Ei(t,e,i,s,n,r,o){var a=zi(t,i),c=zi(e,i),h=o.get(c);if(h)Fi(t,i,h);else{var l,u=r?r(a,c,i+"",t,e,o):void 0,d=void 0===u;if(d){var f=C(c),p=!f&&kt(c),v=!f&&!p&&Lt(c);u=c,f||p||v?C(a)?u=a:T(l=a)&&yt(l)?u=V(a):p?(d=!1,u=ve(c,!0)):v?(d=!1,u=Ge(c,!0)):u=[]:function(t){if(!T(t)||_(t)!=ne)return!1;var e=se(t);if(null===e)return!0;var i=ce.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&ae.call(i)==he}(c)||Ct(c)?(u=a,Ct(a)?u=function(t){return ut(t,Gt(t))}(a):j(a)&&!E(a)||(u=di(c))):d=!1}d&&(o.set(c,u),n(u,c,s,r,o),o.delete(c)),Fi(t,i,u)}}function Ri(t,e,i,s,n){t!==e&&ki(e,(function(r,o){if(n||(n=new le),j(r))Ei(t,e,o,i,Ri,s,n);else{var a=s?s(zi(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Fi(t,o,a)}}),Gt)}var xi,Ii=(xi=function(t,e,i){Ri(t,e,i)},ft((function(t,e){var i=-1,s=e.length,n=s>1?e[s-1]:void 0,r=s>2?e[2]:void 0;for(n=xi.length>3&&"function"==typeof n?(s--,n):void 0,r&&function(t,e,i){if(!j(i))return!1;var s=typeof e;return!!("number"==s?yt(i)&&ot(e,i.length):"string"==s&&e in i)&&ct(i[e],t)}(e[0],e[1],r)&&(n=s<3?void 0:n,s=1),t=Object(t);++i<s;){var o=e[i];o&&xi(t,o,i,n)}return t})));let Mi=null;try{Mi=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const Li=t=>Mi&&new RegExp(Mi).test(t)?(...e)=>console.log(t,...e):()=>{},Pi=Li("rpc:ClientManager");class Di{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=>{Pi("clearCache"),this.cache&&(t?this.cache.setCachedResponse(t,void 0):this.cache.clearCache())},this.getCachedResponse=t=>{var e;return Pi("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Pi("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,i)=>e(this,void 0,void 0,(function*(){Pi("manageClientRequest",t);const s=yield this.interceptRequestMutator(t),n=h(s);if(this.inflightCallsByKey.hasOwnProperty(n))return Pi("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const i=Oi(e);return t.correlationId&&(i.correlationId=t.correlationId),i}));const r=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(s,i),e=yield this.interceptResponseMutator(t,s);return this.cache&&e&&this.cache.setCachedResponse(s,e),e})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Pi("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){var e,i,n,r;let o=t;if(this.interceptors.request.length){Pi("interceptRequestMutator(), original request:",t);try{for(var a,c=!0,h=s(this.interceptors.request);!(e=(a=yield h.next()).done);){r=a.value,c=!1;try{const t=r;o=yield t(o)}finally{c=!0}}}catch(t){i={error:t}}finally{try{c||e||!(n=h.return)||(yield n.call(h))}finally{if(i)throw i.error}}}return o})),this.interceptResponseMutator=(t,i)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){Pi("interceptResponseMutator",i,t);for(const s of this.interceptors.response)try{e=yield s(e,i)}catch(s){throw Pi("caught response interceptor, request:",i,"original response:",t,"mutated response:",e),s}}return e})),this.sendRequestWithTransport=(t,i)=>e(this,void 0,void 0,(function*(){let e;Pi("sendRequestWithTransport",t);let s=0;for(;!e&&this.transports[s];){const n=this.transports[s];if(n.isConnected()){Pi(`sendRequestWithTransport trying ${this.transports[s].name}`,t);try{let s;const r=n.sendRequest(t,i||{}),o=new Promise(((e,n)=>{s=setTimeout((()=>{n(new a(`Procedure ${t.procedure}`))}),(null==i?void 0:i.timeout)||this.options.deadlineMs)}));e=yield Promise.race([o,r]).finally((()=>{clearTimeout(s)}))}catch(t){if(!(t instanceof a||t instanceof o))throw t;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${this.transports[s].name} failed, trying next transport`),s++}}else s++}if(!e&&!this.transports[s])throw console.error(`RPCClient ClientManager#sendRequestWithTransport() ${t.scope}::${t.procedure}::${t.version} did not get a response from any transports`),new r(`Procedure ${t.procedure} did not get a response from any transports`);if(!e)throw new r(`Procedure ${t.procedure} did not get a response from the remote`);return e})),this.cache=t.cache,t.requestInterceptor&&this.interceptors.request.push(t.requestInterceptor),t.responseInterceptor&&this.interceptors.response.push(t.responseInterceptor),this.transports=t.transports}}class Wi{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Wi.DEFAULT_CACHE_MAX_AGE_MS=3e5,Wi.DEFAULT_CACHE_MAX_SIZE=100;const qi="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Bi=new Set,Ui="object"==typeof process&&process?process:{},Ni=(t,e,i,s)=>{"function"==typeof Ui.emitWarning?Ui.emitWarning(t,e,i,s):console.error(`[${i}] ${e}: ${t}`)};let $i=globalThis.AbortController,Gi=globalThis.AbortSignal;if(void 0===$i){Gi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},$i=class{constructor(){e()}signal=new Gi;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"!==Ui.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,Ni("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 Hi=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Ji=t=>Hi(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Vi:null:null;class Vi extends Array{constructor(t){super(t),this.fill(0)}}class Xi{heap;length;static#t=!1;static create(t){const e=Ji(t);if(!e)return[];Xi.#t=!0;const i=new Xi(t,e);return Xi.#t=!1,i}constructor(t,e){if(!Xi.#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 Ki{#e;#i;#s;#n;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#l;#u;#d;#f;#p;#v;#y;#g;#b;#w;#m;#S;#_;static unsafeExposeInternals(t){return{starts:t.#b,ttls:t.#w,sizes:t.#g,keyMap:t.#c,keyList:t.#h,valList:t.#l,next:t.#u,prev:t.#d,get head(){return t.#f},get tail(){return t.#p},free:t.#v,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,i,s,n)=>t.#C(e,i,s,n),moveToTail:e=>t.#j(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#i}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#r}get dispose(){return this.#s}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:o,allowStale:a,dispose:c,disposeAfter:h,noDisposeOnSet:l,noUpdateTTL:u,maxSize:d=0,maxEntrySize:f=0,sizeCalculation:p,fetchMethod:v,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:g,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:w,ignoreFetchAbort:m}=t;if(0!==e&&!Hi(e))throw new TypeError("max option must be a nonnegative integer");const S=e?Ji(e):Array;if(!S)throw new Error("invalid max value: "+e);if(this.#e=e,this.#i=d,this.maxEntrySize=f||this.#i,this.sizeCalculation=p,this.sizeCalculation){if(!this.#i&&!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!==v&&"function"!=typeof v)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=v,this.#S=!!v,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new S(e),this.#d=new S(e),this.#f=0,this.#p=0,this.#v=Xi.create(e),this.#o=0,this.#a=0,"function"==typeof c&&(this.#s=c),"function"==typeof h?(this.#n=h,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#m=!!this.#s,this.#_=!!this.#n,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!m,0!==this.maxEntrySize){if(0!==this.#i&&!Hi(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!Hi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#F()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!g,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=Hi(s)||0===s?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!Hi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#z()}if(0===this.#e&&0===this.ttl&&0===this.#i)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#i){const t="LRU_CACHE_UNBOUNDED";if((t=>!Bi.has(t))(t)){Bi.add(t);Ni("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,Ki)}}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#z(){const t=new Vi(this.#e),e=new Vi(this.#e);this.#w=t,this.#b=e,this.#E=(i,s,n=qi.now())=>{if(e[i]=0!==s?n:0,t[i]=s,0!==s&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(i)&&this.delete(this.#h[i])}),s+1);t.unref&&t.unref()}},this.#R=i=>{e[i]=0!==t[i]?qi.now():0},this.#x=(n,r)=>{if(t[r]){const o=t[r],a=e[r];n.ttl=o,n.start=a,n.now=i||s();const c=n.now-a;n.remainingTTL=o-c}};let i=0;const s=()=>{const t=qi.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#c.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];if(0===o||0===a)return 1/0;return o-((i||s())-a)},this.#k=n=>0!==t[n]&&0!==e[n]&&(i||s())-e[n]>t[n]}#R=()=>{};#x=()=>{};#E=()=>{};#k=()=>!1;#F(){const t=new Vi(this.#e);this.#a=0,this.#g=t,this.#I=e=>{this.#a-=t[e],t[e]=0},this.#M=(t,e,i,s)=>{if(this.#T(e))return 0;if(!Hi(i)){if(!s)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 s)throw new TypeError("sizeCalculation must be a function");if(i=s(e,t),!Hi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return i},this.#L=(e,i,s)=>{if(t[e]=i,this.#i){const i=this.#i-t[e];for(;this.#a>i;)this.#P(!0)}this.#a+=t[e],s&&(s.entrySize=i,s.totalCalculatedSize=this.#a)}}#I=t=>{};#L=(t,e,i)=>{};#M=(t,e,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#f);)e=this.#d[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#f;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#u[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}*rvalues(){for(const t of this.#A()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const i of this.#O()){const s=this.#l[i],n=this.#T(s)?s.__staleWhileFetching:s;if(void 0!==n&&t(n,this.#h[i],this))return this.get(this.#h[i],e)}}forEach(t,e=this){for(const i of this.#O()){const s=this.#l[i],n=this.#T(s)?s.__staleWhileFetching:s;void 0!==n&&t.call(e,n,this.#h[i],this)}}rforEach(t,e=this){for(const i of this.#A()){const s=this.#l[i],n=this.#T(s)?s.__staleWhileFetching:s;void 0!==n&&t.call(e,n,this.#h[i],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const i=this.#h[e],s=this.#l[e],n=this.#T(s)?s.__staleWhileFetching:s;if(void 0===n||void 0===i)continue;const r={value:n};if(this.#w&&this.#b){r.ttl=this.#w[e];const t=qi.now()-this.#b[e];r.start=Math.floor(Date.now()-t)}this.#g&&(r.size=this.#g[e]),t.unshift([i,r])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=qi.now()-t}this.set(e,i.value,i)}}set(t,e,i={}){if(void 0===e)return this.delete(t),this;const{ttl:s=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=i;let{noUpdateTTL:c=this.noUpdateTTL}=i;const h=this.#M(t,e,i.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#o?void 0:this.#c.get(t);if(void 0===l)l=0===this.#o?this.#p:0!==this.#v.length?this.#v.pop():this.#o===this.#e?this.#P(!1):this.#o,this.#h[l]=t,this.#l[l]=e,this.#c.set(t,l),this.#u[this.#p]=l,this.#d[l]=this.#p,this.#p=l,this.#o++,this.#L(l,h,a),a&&(a.set="add"),c=!1;else{this.#j(l);const i=this.#l[l];if(e!==i){if(this.#S&&this.#T(i)?i.__abortController.abort(new Error("replaced")):r||(this.#m&&this.#s?.(i,t,"set"),this.#_&&this.#y?.push([i,t,"set"])),this.#I(l),this.#L(l,h,a),this.#l[l]=e,a){a.set="replace";const t=i&&this.#T(i)?i.__staleWhileFetching:i;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===s||this.#w||this.#z(),this.#w&&(c||this.#E(l,s,n),a&&this.#x(a,l)),!r&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#l[this.#f];if(this.#P(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#P(t){const e=this.#f,i=this.#h[e],s=this.#l[e];return this.#S&&this.#T(s)?s.__abortController.abort(new Error("evicted")):(this.#m||this.#_)&&(this.#m&&this.#s?.(s,i,"evict"),this.#_&&this.#y?.push([s,i,"evict"])),this.#I(e),t&&(this.#h[e]=void 0,this.#l[e]=void 0,this.#v.push(e)),1===this.#o?(this.#f=this.#p=0,this.#v.length=0):this.#f=this.#u[e],this.#c.delete(i),this.#o--,e}has(t,e={}){const{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=e,n=this.#c.get(t);if(void 0!==n){const t=this.#l[n];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(n))return i&&this.#R(n),s&&(s.has="hit",this.#x(s,n)),!0;s&&(s.has="stale",this.#x(s,n))}else s&&(s.has="miss");return!1}peek(t,e={}){const{allowStale:i=this.allowStale}=e,s=this.#c.get(t);if(void 0!==s&&(i||!this.#k(s))){const t=this.#l[s];return this.#T(t)?t.__staleWhileFetching:t}}#C(t,e,i,s){const n=void 0===e?void 0:this.#l[e];if(this.#T(n))return n;const r=new $i,{signal:o}=i;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:i,context:s},c=(s,n=!1)=>{const{aborted:o}=r.signal,c=i.ignoreFetchAbort&&void 0!==s;if(i.status&&(o&&!n?(i.status.fetchAborted=!0,i.status.fetchError=r.signal.reason,c&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),o&&!c&&!n)return h(r.signal.reason);const u=l;return this.#l[e]===l&&(void 0===s?u.__staleWhileFetching?this.#l[e]=u.__staleWhileFetching:this.delete(t):(i.status&&(i.status.fetchUpdated=!0),this.set(t,s,a.options))),s},h=s=>{const{aborted:n}=r.signal,o=n&&i.allowStaleOnFetchAbort,a=o||i.allowStaleOnFetchRejection,c=a||i.noDeleteOnFetchRejection,h=l;if(this.#l[e]===l){!c||void 0===h.__staleWhileFetching?this.delete(t):o||(this.#l[e]=h.__staleWhileFetching)}if(a)return i.status&&void 0!==h.__staleWhileFetching&&(i.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw s};i.status&&(i.status.fetchDispatched=!0);const l=new Promise(((e,s)=>{const o=this.#r?.(t,n,a);o&&o instanceof Promise&&o.then((t=>e(t)),s),r.signal.addEventListener("abort",(()=>{i.ignoreFetchAbort&&!i.allowStaleOnFetchAbort||(e(),i.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(i.status&&(i.status.fetchRejected=!0,i.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.#c.get(t)):this.#l[e]=u,u}#T(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof $i}async fetch(t,e={}){const{allowStale:i=this.allowStale,updateAgeOnGet:s=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:f=this.allowStaleOnFetchAbort,context:p,forceRefresh:v=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:y});const b={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:y,signal:g};let w=this.#c.get(t);if(void 0===w){y&&(y.fetch="miss");const e=this.#C(t,w,b,p);return e.__returned=e}{const e=this.#l[w];if(this.#T(e)){const t=i&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#k(w);if(!v&&!n)return y&&(y.fetch="hit"),this.#j(w),s&&this.#R(w),y&&this.#x(y,w),e;const r=this.#C(t,w,b,p),o=void 0!==r.__staleWhileFetching&&i;return y&&(y.fetch=n?"stale":"refresh",o&&n&&(y.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}get(t,e={}){const{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#l[o],a=this.#T(e);return r&&this.#x(r,o),this.#k(o)?(r&&(r.get="stale"),a?(r&&i&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),i?e.__staleWhileFetching:void 0):(n||this.delete(t),r&&i&&(r.returnedStale=!0),i?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#j(o),s&&this.#R(o),e))}r&&(r.get="miss")}#W(t,e){this.#d[e]=t,this.#u[t]=e}#j(t){t!==this.#p&&(t===this.#f?this.#f=this.#u[t]:this.#W(this.#d[t],this.#u[t]),this.#W(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#o){const i=this.#c.get(t);if(void 0!==i)if(e=!0,1===this.#o)this.clear();else{this.#I(i);const e=this.#l[i];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#m||this.#_)&&(this.#m&&this.#s?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#h[i]=void 0,this.#l[i]=void 0,i===this.#p?this.#p=this.#d[i]:i===this.#f?this.#f=this.#u[i]:(this.#u[this.#d[i]]=this.#u[i],this.#d[this.#u[i]]=this.#d[i]),this.#o--,this.#v.push(i)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const i=this.#h[t];this.#m&&this.#s?.(e,i,"delete"),this.#_&&this.#y?.push([e,i,"delete"])}}if(this.#c.clear(),this.#l.fill(void 0),this.#h.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#g&&this.#g.fill(0),this.#f=0,this.#p=0,this.#v.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}const Zi=Li("rpc:InMemoryCache");class Qi{constructor(t){this.clearCache=()=>{var t;Zi("clearCache"),null===(t=this.cachedResponseByParams)||void 0===t||t.clear()},this.getCachedResponse=t=>{var e;Zi("getCachedResponse, key: ",t);let i=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(h(t));return"string"==typeof i&&(i=JSON.parse(i)),i},this.setCachedResponse=(t,e)=>{var i,s;Zi("setCachedResponse",t,e);const n=h(t);if(!e)return null===(i=this.cachedResponseByParams)||void 0===i?void 0:i.delete(n);const r=Object.assign({},e);delete r.correlationId,null===(s=this.cachedResponseByParams)||void 0===s||s.set(n,r?JSON.stringify(r):void 0)},this.cachedResponseByParams=new Ki({max:(null==t?void 0:t.cacheMaxSize)||Qi.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||Qi.DEFAULT_CACHE_MAX_AGE_MS})}}Qi.DEFAULT_CACHE_MAX_AGE_MS=9e5,Qi.DEFAULT_CACHE_MAX_SIZE=200;class Yi{constructor(t){const{code:e,correlationId:i,data:s,message:n,success:r}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,i&&"string"!=typeof i)throw new Error("correlationId must be a string");if(this.correlationId=i,this.data=s,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}}const ts=Li("rpc:HTTPTransport");class es{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.isConnected=()=>{var t;return"undefined"!=typeof window?!!(null===(t=null===window||void 0===window?void 0:window.navigator)||void 0===t?void 0:t.onLine):this.networkIsConnected},this.sendRequest=(t,i)=>e(this,void 0,void 0,(function*(){ts("sendRequest",t);const e=JSON.stringify(Object.assign({identity:this.identity},t)),i=yield null===window||void 0===window?void 0:window.fetch(this.host,{body:e,cache:"default",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"follow",referrerPolicy:"origin"}),s=yield i.text();if(!s)throw new Error("No response received from remote");const n=JSON.parse(s);return new Yi(n)})),this.setIdentity=t=>{ts("setIdentity",t),this.identity=t},this.host=t.host}}class is{constructor(t,i){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((s,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error(`PromiseWraper timeout: ${t}`))}),i||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),s(t)}}))))}}const ss=t=>new Promise((e=>setTimeout(e,t))),ns=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},rs=Li("rpc:WebSocketTransport");class os{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e;let i=t;try{i=JSON.stringify({clientMessage:t})}catch(e){console.warn('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}null===(e=this.websocket)||void 0===e||e.send(i)},this.sendRequest=(t,i)=>e(this,void 0,void 0,(function*(){for(rs("sendRequest",t);this.isWaitingForIdentityConfirmation;)rs("waiting for identity confirmation"),yield ss(100);return this.sendCall(t,i)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(rs("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?rs('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{rs("setIdentity with remote complete")})).catch((t=>{rs("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):rs("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(rs("connect",this.host),this.websocket)return void rs("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):rs("WebSocket closed, it was not connected to the remote"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,this.websocket=void 0,this.websocketId=void 0,Object.entries(this.pendingPromisesForResponse).forEach((([t,e])=>{e.reject(new o("Websocket disconnected"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):rs("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>{var e;rs("_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(i){console.warn("WebSocketTransport.handleServerMessage() a serverMessageHandler errored when calling",t,"handler func:",e),console.error(i)}}))},this.handleWebSocketMsg=t=>{let e;rs("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 i=new Yi(e);if(!i.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const s=this.pendingPromisesForResponse[i.correlationId];s?s.resolve(i):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>e(this,void 0,void 0,(function*(){rs("resetConnection"),this._disconnect("WebSocketTransport#resetConnection"),yield ss(100),this._connect()})),this.sendCall=(t,i)=>e(this,void 0,void 0,(function*(){var e;rs("sendCall",t);const s=Math.random().toString();t.correlationId=t.correlationId||s;let n=new is(`${(r=t).scope}::${r.procedure}::${r.version}`,i.timeout||this.options.rpcOptions.deadlineMs);var r;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=>{rs(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},rs("new WebSocketTransport()"),this.host=t.host,this.connect()}}class as{constructor(){this.events={},this.publish=(t,i)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,i)}))})),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 i=this.events[t].indexOf(e);this.events[t].splice(i)}}}const cs={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class hs{constructor(t){var i,s,r,o,a,c;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,i,s)=>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?ns(t):t,i&&(e.args=i);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=Ii(Object.assign({},this.identity),r.identity);const o=yield this.callManager.manageClientRequest(r,s);if(!o.success)throw o;const a=h(e);return this.vent.publish(a,null==o?void 0:o.data),o})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let i;i="string"==typeof t?ns(t):t,e&&(i.args=e);const s=this.callManager.getCachedResponse(i);if(s)return s},this.getIdentity=()=>this.identity?Oi(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 i;return i="string"==typeof t?ns(t):t,function(t){return e.call(Object.assign(Object.assign({},i),{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=Oi(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const i=Oi(this.identity);i.metadata=t,this.identity.metadata=t,this.callManager.setIdentity(i)},this.transports=()=>({http:this.httpTransport,websocket:this.webSocketTransport}),!(null===(i=null==t?void 0:t.hosts)||void 0===i?void 0:i.http)&&!(null===(s=null==t?void 0:t.transports)||void 0===s?void 0:s.http))throw new Error(cs.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(cs.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(cs.INTERCEPTOR_MUSTBE_FUNC);let l;const u={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};l="browser"==t.cacheType?new Wi(u):new Qi(u);const d=[];(null===(r=t.transports)||void 0===r?void 0:r.websocket)?d.push(t.transports.websocket):(null===(o=null==t?void 0:t.hosts)||void 0===o?void 0:o.websocket)&&(this.webSocketTransport=new os({host:t.hosts.websocket,onConnectionStatusChange:this.onWebSocketConnectionStatusChange,rpcOptions:t}),d.push(this.webSocketTransport)),(null===(a=t.transports)||void 0===a?void 0:a.http)?d.push(t.transports.http):(null===(c=null==t?void 0:t.hosts)||void 0===c?void 0:c.http)&&(this.httpTransport=new es({host:t.hosts.http,rpcOptions:t}),d.push(this.httpTransport)),this.callManager=new Di({cache:l,deadlineMs:t.deadlineMs||hs.DEFAULT_DEADLINE_MS,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:d})}subscribe(t,e){const i="string"==typeof t.request?ns(t.request):t.request,s=h(Object.assign(Object.assign({},i),{args:t.args}));return this.vent.subscribe(s,e)}unsubscribe(t,e){const i="string"==typeof t.request?ns(t.request):t.request,s=h(Object.assign(Object.assign({},i),{args:t.args}));this.vent.unsubscribe(s,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)}}hs.DEFAULT_DEADLINE_MS=1e4,t.RPCClient=hs,t.RPCResponse=Yi,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!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,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{c(s.next(t))}catch(t){r(t)}}function a(t){try{c(s.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}c((s=s.apply(t,e||[])).next())}))}function i(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],s=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,s=t[Symbol.asyncIterator];return s?s.call(t):(t=i(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(e){return new Promise((function(s,n){(function(t,e,i,s){Promise.resolve(s).then((function(e){t({value:e,done:i})}),e)})(s,n,(e=t[i](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){const{args:e,correlationId:i,identity:s,procedure:n,scope:r,version:o}=t;if(this.args=e,i&&"string"!=typeof i)throw new Error("correlationId must be a string");if(this.correlationId=i||Math.random().toString(),s){if("object"!=typeof s)throw new Error("identity must be an object");if(s.authorization&&"string"!=typeof s.authorization)throw new Error("identity.authorization must be a string");if(s.deviceName&&"string"!=typeof s.deviceName)throw new Error("identity.deviceName must be a string");if(s.metadata&&"object"!=typeof s.metadata)throw new Error("identity.metadata must be a object");this.identity=s}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}}class r extends Error{}class o extends Error{}class a extends Error{}function c(t){if("[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}const h=t=>t.args?`${t.scope}${t.procedure}${t.version}${function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var i,s="boolean"==typeof e.cycles&&e.cycles,n=e.cmp&&(i=e.cmp,function(t){return function(e,s){var n={key:e,value:t[e]},r={key:s,value:t[s]};return i(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 i,o;if(Array.isArray(e)){for(o="[",i=0;i<e.length;i++)i&&(o+=","),o+=t(e[i])||"null";return o+"]"}if(null===e)return"null";if(-1!==r.indexOf(e)){if(s)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="",i=0;i<c.length;i++){var h=c[i],l=t(e[h]);l&&(o&&(o+=","),o+=JSON.stringify(h)+":"+l)}return r.splice(a,1),"{"+o+"}"}}(t)}(function(t,e={}){if(!c(t)&&!Array.isArray(t))throw new TypeError("Expected a plain object or array");const{deep:i,compare:s}=e,n=[],r=[],o=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const i=[];return n.push(t),r.push(i),i.push(...t.map((t=>Array.isArray(t)?o(t):c(t)?a(t):t))),i},a=t=>{const e=n.indexOf(t);if(-1!==e)return r[e];const h={},l=Object.keys(t).sort(s);n.push(t),r.push(h);for(const e of l){const s=t[e];let n;n=i&&Array.isArray(s)?o(s):i&&c(s)?a(s):s,Object.defineProperty(h,e,Object.assign(Object.assign({},Object.getOwnPropertyDescriptor(t,e)),{value:n}))}return h};return Array.isArray(t)?i?o(t):t.slice():a(t)}(t.args||{},{deep:!0}))}`:`${t.scope}${t.procedure}${t.version}`;var l="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,d=l||u||Function("return this")(),p=d.Symbol,f=Object.prototype,v=f.hasOwnProperty,y=f.toString,g=p?p.toStringTag:void 0;var b=Object.prototype.toString;var w="[object Null]",m="[object Undefined]",S=p?p.toStringTag:void 0;function _(t){return null==t?void 0===t?m:w:S&&S in Object(t)?function(t){var e=v.call(t,g),i=t[g];try{t[g]=void 0;var s=!0}catch(t){}var n=y.call(t);return s&&(e?t[g]=i:delete t[g]),n}(t):function(t){return b.call(t)}(t)}function T(t){return null!=t&&"object"==typeof t}var C=Array.isArray;function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function O(t){return t}var A="[object AsyncFunction]",k="[object Function]",F="[object GeneratorFunction]",E="[object Proxy]";function z(t){if(!j(t))return!1;var e=_(t);return e==k||e==F||e==A||e==E}var R,x=d["__core-js_shared__"],I=(R=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+R:"";var M=Function.prototype.toString;function L(t){if(null!=t){try{return M.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var P=/^\[object .+?Constructor\]$/,D=Function.prototype,W=Object.prototype,q=D.toString,B=W.hasOwnProperty,U=RegExp("^"+q.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function N(t){return!(!j(t)||(e=t,I&&I in e))&&(z(t)?U:P).test(L(t));var e}function $(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return N(i)?i:void 0}var G=$(d,"WeakMap"),H=Object.create,J=function(){function t(){}return function(e){if(!j(e))return{};if(H)return H(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();function V(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e}var X=Date.now;var K,Z,Q,Y=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),tt=Y,et=tt?function(t,e){return tt(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:O,it=(K=et,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)}),st=it;var nt=9007199254740991,rt=/^(?:0|[1-9]\d*)$/;function ot(t,e){var i=typeof t;return!!(e=null==e?nt:e)&&("number"==i||"symbol"!=i&&rt.test(t))&&t>-1&&t%1==0&&t<e}function at(t,e,i){"__proto__"==e&&tt?tt(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function ct(t,e){return t===e||t!=t&&e!=e}var ht=Object.prototype.hasOwnProperty;function lt(t,e,i){var s=t[e];ht.call(t,e)&&ct(s,i)&&(void 0!==i||e in t)||at(t,e,i)}function ut(t,e,i,s){var n=!i;i||(i={});for(var r=-1,o=e.length;++r<o;){var a=e[r],c=s?s(i[a],t[a],a,i,t):void 0;void 0===c&&(c=t[a]),n?at(i,a,c):lt(i,a,c)}return i}var dt=Math.max;function pt(t,e){return st(function(t,e,i){return e=dt(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=dt(s.length-e,0),o=Array(r);++n<r;)o[n]=s[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=s[n];return a[e]=i(o),function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}(t,this,a)}}(t,e,O),t+"")}var ft=9007199254740991;function vt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=ft}function yt(t){return null!=t&&vt(t.length)&&!z(t)}var gt=Object.prototype;function bt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||gt)}function wt(t){return T(t)&&"[object Arguments]"==_(t)}var mt=Object.prototype,St=mt.hasOwnProperty,_t=mt.propertyIsEnumerable,Tt=wt(function(){return arguments}())?wt:function(t){return T(t)&&St.call(t,"callee")&&!_t.call(t,"callee")},Ct=Tt;var jt="object"==typeof t&&t&&!t.nodeType&&t,Ot=jt&&"object"==typeof module&&module&&!module.nodeType&&module,At=Ot&&Ot.exports===jt?d.Buffer:void 0,kt=(At?At.isBuffer:void 0)||function(){return!1},Ft={};function Et(t){return function(e){return t(e)}}Ft["[object Float32Array]"]=Ft["[object Float64Array]"]=Ft["[object Int8Array]"]=Ft["[object Int16Array]"]=Ft["[object Int32Array]"]=Ft["[object Uint8Array]"]=Ft["[object Uint8ClampedArray]"]=Ft["[object Uint16Array]"]=Ft["[object Uint32Array]"]=!0,Ft["[object Arguments]"]=Ft["[object Array]"]=Ft["[object ArrayBuffer]"]=Ft["[object Boolean]"]=Ft["[object DataView]"]=Ft["[object Date]"]=Ft["[object Error]"]=Ft["[object Function]"]=Ft["[object Map]"]=Ft["[object Number]"]=Ft["[object Object]"]=Ft["[object RegExp]"]=Ft["[object Set]"]=Ft["[object String]"]=Ft["[object WeakMap]"]=!1;var zt="object"==typeof t&&t&&!t.nodeType&&t,Rt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,xt=Rt&&Rt.exports===zt&&l.process,It=function(){try{var t=Rt&&Rt.require&&Rt.require("util").types;return t||xt&&xt.binding&&xt.binding("util")}catch(t){}}(),Mt=It&&It.isTypedArray,Lt=Mt?Et(Mt):function(t){return T(t)&&vt(t.length)&&!!Ft[_(t)]},Pt=Object.prototype.hasOwnProperty;function Dt(t,e){var i=C(t),s=!i&&Ct(t),n=!i&&!s&&kt(t),r=!i&&!s&&!n&&Lt(t),o=i||s||n||r,a=o?function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s}(t.length,String):[],c=a.length;for(var h in t)!e&&!Pt.call(t,h)||o&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ot(h,c))||a.push(h);return a}function Wt(t,e){return function(i){return t(e(i))}}var qt=Wt(Object.keys,Object),Bt=Object.prototype.hasOwnProperty;function Ut(t){return yt(t)?Dt(t):function(t){if(!bt(t))return qt(t);var e=[];for(var i in Object(t))Bt.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}var Nt=Object.prototype.hasOwnProperty;function $t(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=bt(t),i=[];for(var s in t)("constructor"!=s||!e&&Nt.call(t,s))&&i.push(s);return i}function Gt(t){return yt(t)?Dt(t,!0):$t(t)}var Ht=$(Object,"create");var Jt=Object.prototype.hasOwnProperty;var Vt=Object.prototype.hasOwnProperty;function Xt(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function Kt(t,e){for(var i=t.length;i--;)if(ct(t[i][0],e))return i;return-1}Xt.prototype.clear=function(){this.__data__=Ht?Ht(null):{},this.size=0},Xt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Xt.prototype.get=function(t){var e=this.__data__;if(Ht){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Jt.call(e,t)?e[t]:void 0},Xt.prototype.has=function(t){var e=this.__data__;return Ht?void 0!==e[t]:Vt.call(e,t)},Xt.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Ht&&void 0===e?"__lodash_hash_undefined__":e,this};var Zt=Array.prototype.splice;function Qt(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}Qt.prototype.clear=function(){this.__data__=[],this.size=0},Qt.prototype.delete=function(t){var e=this.__data__,i=Kt(e,t);return!(i<0)&&(i==e.length-1?e.pop():Zt.call(e,i,1),--this.size,!0)},Qt.prototype.get=function(t){var e=this.__data__,i=Kt(e,t);return i<0?void 0:e[i][1]},Qt.prototype.has=function(t){return Kt(this.__data__,t)>-1},Qt.prototype.set=function(t,e){var i=this.__data__,s=Kt(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};var Yt=$(d,"Map");function te(t,e){var i,s,n=t.__data__;return("string"==(s=typeof(i=e))||"number"==s||"symbol"==s||"boolean"==s?"__proto__"!==i:null===i)?n["string"==typeof e?"string":"hash"]:n.map}function ee(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function ie(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t}ee.prototype.clear=function(){this.size=0,this.__data__={hash:new Xt,map:new(Yt||Qt),string:new Xt}},ee.prototype.delete=function(t){var e=te(this,t).delete(t);return this.size-=e?1:0,e},ee.prototype.get=function(t){return te(this,t).get(t)},ee.prototype.has=function(t){return te(this,t).has(t)},ee.prototype.set=function(t,e){var i=te(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};var se=Wt(Object.getPrototypeOf,Object),ne="[object Object]",re=Function.prototype,oe=Object.prototype,ae=re.toString,ce=oe.hasOwnProperty,he=ae.call(Object);function le(t){var e=this.__data__=new Qt(t);this.size=e.size}le.prototype.clear=function(){this.__data__=new Qt,this.size=0},le.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},le.prototype.get=function(t){return this.__data__.get(t)},le.prototype.has=function(t){return this.__data__.has(t)},le.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Qt){var s=i.__data__;if(!Yt||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new ee(s)}return i.set(t,e),this.size=i.size,this};var ue="object"==typeof t&&t&&!t.nodeType&&t,de=ue&&"object"==typeof module&&module&&!module.nodeType&&module,pe=de&&de.exports===ue?d.Buffer:void 0,fe=pe?pe.allocUnsafe:void 0;function ve(t,e){if(e)return t.slice();var i=t.length,s=fe?fe(i):new t.constructor(i);return t.copy(s),s}function ye(){return[]}var ge=Object.prototype.propertyIsEnumerable,be=Object.getOwnPropertySymbols,we=be?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var o=t[i];e(o,i,t)&&(r[n++]=o)}return r}(be(t),(function(e){return ge.call(t,e)})))}:ye;var me=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ie(e,we(t)),t=se(t);return e}:ye;function Se(t,e,i){var s=e(t);return C(t)?s:ie(s,i(t))}function _e(t){return Se(t,Ut,we)}function Te(t){return Se(t,Gt,me)}var Ce=$(d,"DataView"),je=$(d,"Promise"),Oe=$(d,"Set"),Ae="[object Map]",ke="[object Promise]",Fe="[object Set]",Ee="[object WeakMap]",ze="[object DataView]",Re=L(Ce),xe=L(Yt),Ie=L(je),Me=L(Oe),Le=L(G),Pe=_;(Ce&&Pe(new Ce(new ArrayBuffer(1)))!=ze||Yt&&Pe(new Yt)!=Ae||je&&Pe(je.resolve())!=ke||Oe&&Pe(new Oe)!=Fe||G&&Pe(new G)!=Ee)&&(Pe=function(t){var e=_(t),i="[object Object]"==e?t.constructor:void 0,s=i?L(i):"";if(s)switch(s){case Re:return ze;case xe:return Ae;case Ie:return ke;case Me:return Fe;case Le:return Ee}return e});var De=Pe,We=Object.prototype.hasOwnProperty;var qe=d.Uint8Array;function Be(t){var e=new t.constructor(t.byteLength);return new qe(e).set(new qe(t)),e}var Ue=/\w*$/;var Ne=p?p.prototype:void 0,$e=Ne?Ne.valueOf:void 0;function Ge(t,e){var i=e?Be(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)}var He="[object Boolean]",Je="[object Date]",Ve="[object Map]",Xe="[object Number]",Ke="[object RegExp]",Ze="[object Set]",Qe="[object String]",Ye="[object Symbol]",ti="[object ArrayBuffer]",ei="[object DataView]",ii="[object Float32Array]",si="[object Float64Array]",ni="[object Int8Array]",ri="[object Int16Array]",oi="[object Int32Array]",ai="[object Uint8Array]",ci="[object Uint8ClampedArray]",hi="[object Uint16Array]",li="[object Uint32Array]";function ui(t,e,i){var s,n,r,o=t.constructor;switch(e){case ti:return Be(t);case He:case Je:return new o(+t);case ei:return function(t,e){var i=e?Be(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)}(t,i);case ii:case si:case ni:case ri:case oi:case ai:case ci:case hi:case li:return Ge(t,i);case Ve:return new o;case Xe:case Qe:return new o(t);case Ke:return(r=new(n=t).constructor(n.source,Ue.exec(n))).lastIndex=n.lastIndex,r;case Ze:return new o;case Ye:return s=t,$e?Object($e.call(s)):{}}}function di(t){return"function"!=typeof t.constructor||bt(t)?{}:J(se(t))}var pi=It&&It.isMap,fi=pi?Et(pi):function(t){return T(t)&&"[object Map]"==De(t)};var vi=It&&It.isSet,yi=vi?Et(vi):function(t){return T(t)&&"[object Set]"==De(t)},gi=1,bi=2,wi=4,mi="[object Arguments]",Si="[object Function]",_i="[object GeneratorFunction]",Ti="[object Object]",Ci={};function ji(t,e,i,s,n,r){var o,a=e&gi,c=e&bi,h=e&wi;if(i&&(o=n?i(t,s,n,r):i(t)),void 0!==o)return o;if(!j(t))return t;var l=C(t);if(l){if(o=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&We.call(t,"index")&&(i.index=t.index,i.input=t.input),i}(t),!a)return V(t,o)}else{var u=De(t),d=u==Si||u==_i;if(kt(t))return ve(t,a);if(u==Ti||u==mi||d&&!n){if(o=c||d?{}:di(t),!a)return c?function(t,e){return ut(t,me(t),e)}(t,function(t,e){return t&&ut(e,Gt(e),t)}(o,t)):function(t,e){return ut(t,we(t),e)}(t,function(t,e){return t&&ut(e,Ut(e),t)}(o,t))}else{if(!Ci[u])return n?t:{};o=ui(t,u,a)}}r||(r=new le);var p=r.get(t);if(p)return p;r.set(t,o),yi(t)?t.forEach((function(s){o.add(ji(s,e,i,s,t,r))})):fi(t)&&t.forEach((function(s,n){o.set(n,ji(s,e,i,n,t,r))}));var f=l?void 0:(h?c?Te:_e:c?Gt:Ut)(t);return function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i,t););}(f||t,(function(s,n){f&&(s=t[n=s]),lt(o,n,ji(s,e,i,n,t,r))})),o}Ci[mi]=Ci["[object Array]"]=Ci["[object ArrayBuffer]"]=Ci["[object DataView]"]=Ci["[object Boolean]"]=Ci["[object Date]"]=Ci["[object Float32Array]"]=Ci["[object Float64Array]"]=Ci["[object Int8Array]"]=Ci["[object Int16Array]"]=Ci["[object Int32Array]"]=Ci["[object Map]"]=Ci["[object Number]"]=Ci[Ti]=Ci["[object RegExp]"]=Ci["[object Set]"]=Ci["[object String]"]=Ci["[object Symbol]"]=Ci["[object Uint8Array]"]=Ci["[object Uint8ClampedArray]"]=Ci["[object Uint16Array]"]=Ci["[object Uint32Array]"]=!0,Ci["[object Error]"]=Ci[Si]=Ci["[object WeakMap]"]=!1;function Oi(t){return ji(t,5)}var Ai,ki=function(t,e,i){for(var s=-1,n=Object(t),r=i(t),o=r.length;o--;){var a=r[Ai?o:++s];if(!1===e(n[a],a,n))break}return t};function Fi(t,e,i){(void 0!==i&&!ct(t[e],i)||void 0===i&&!(e in t))&&at(t,e,i)}function Ei(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function zi(t,e,i,s,n,r,o){var a=Ei(t,i),c=Ei(e,i),h=o.get(c);if(h)Fi(t,i,h);else{var l,u=r?r(a,c,i+"",t,e,o):void 0,d=void 0===u;if(d){var p=C(c),f=!p&&kt(c),v=!p&&!f&&Lt(c);u=c,p||f||v?C(a)?u=a:T(l=a)&&yt(l)?u=V(a):f?(d=!1,u=ve(c,!0)):v?(d=!1,u=Ge(c,!0)):u=[]:function(t){if(!T(t)||_(t)!=ne)return!1;var e=se(t);if(null===e)return!0;var i=ce.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&ae.call(i)==he}(c)||Ct(c)?(u=a,Ct(a)?u=function(t){return ut(t,Gt(t))}(a):j(a)&&!z(a)||(u=di(c))):d=!1}d&&(o.set(c,u),n(u,c,s,r,o),o.delete(c)),Fi(t,i,u)}}function Ri(t,e,i,s,n){t!==e&&ki(e,(function(r,o){if(n||(n=new le),j(r))zi(t,e,o,i,Ri,s,n);else{var a=s?s(Ei(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Fi(t,o,a)}}),Gt)}var xi,Ii=(xi=function(t,e,i){Ri(t,e,i)},pt((function(t,e){var i=-1,s=e.length,n=s>1?e[s-1]:void 0,r=s>2?e[2]:void 0;for(n=xi.length>3&&"function"==typeof n?(s--,n):void 0,r&&function(t,e,i){if(!j(i))return!1;var s=typeof e;return!!("number"==s?yt(i)&&ot(e,i.length):"string"==s&&e in i)&&ct(i[e],t)}(e[0],e[1],r)&&(n=s<3?void 0:n,s=1),t=Object(t);++i<s;){var o=e[i];o&&xi(t,o,i,n)}return t})));let Mi=null;try{Mi=localStorage.getItem("debug")||""}catch(t){"undefined"!=typeof window&&"undefined"!=typeof localStorage&&console.warn("Error checking window.debug")}const Li=t=>Mi&&new RegExp(Mi).test(t)?(...e)=>console.log(t,...e):()=>{},Pi=Li("rpc:ClientManager");class Di{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=>{Pi("clearCache"),this.cache&&(t?this.cache.setCachedResponse(t,void 0):this.cache.clearCache())},this.getCachedResponse=t=>{var e;return Pi("getCachedResponse",t),null===(e=null==this?void 0:this.cache)||void 0===e?void 0:e.getCachedResponse(t)},this.getInFlightCallCount=()=>(Pi("getInFlightCallCount"),Object.keys(this.inflightCallsByKey).length),this.manageClientRequest=(t,i)=>e(this,void 0,void 0,(function*(){Pi("manageClientRequest",t);const s=yield this.interceptRequestMutator(t),n=h(s);if(this.inflightCallsByKey.hasOwnProperty(n))return Pi("manageClientRequest using an existing in-flight call",n),this.inflightCallsByKey[n].then((e=>{const i=Oi(e);return t.correlationId&&(i.correlationId=t.correlationId),i}));const r=(()=>e(this,void 0,void 0,(function*(){const t=yield this.sendRequestWithTransport(s,i),e=yield this.interceptResponseMutator(t,s);return this.cache&&e&&this.cache.setCachedResponse(s,e),e})))().finally((()=>{delete this.inflightCallsByKey[n]}));return this.inflightCallsByKey[n]=r,yield r})),this.setIdentity=t=>{Pi("setIdentity",t),this.transports.forEach((e=>e.setIdentity(t)))},this.interceptRequestMutator=t=>e(this,void 0,void 0,(function*(){var e,i,n,r;let o=t;if(this.interceptors.request.length){Pi("interceptRequestMutator(), original request:",t);try{for(var a,c=!0,h=s(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){i={error:t}}finally{try{c||e||!(n=h.return)||(yield n.call(h))}finally{if(i)throw i.error}}}return o})),this.interceptResponseMutator=(t,i)=>e(this,void 0,void 0,(function*(){let e=t;if(this.interceptors.response.length){Pi("interceptResponseMutator",i,t);for(const s of this.interceptors.response)try{e=yield s(e,i)}catch(s){throw Pi("caught response interceptor, request:",i,"original response:",t,"mutated response:",e),s}}return e})),this.sendRequestWithTransport=(t,i)=>e(this,void 0,void 0,(function*(){let e;Pi("sendRequestWithTransport",t);let s=0;for(;!e&&this.transports[s];){const n=this.transports[s];if(n.isConnected()){Pi(`sendRequestWithTransport trying ${this.transports[s].name}`,t);try{let s;const r=n.sendRequest(t,i||{}),o=new Promise(((e,n)=>{s=setTimeout((()=>{n(new a(`Procedure ${t.procedure}`))}),(null==i?void 0:i.timeout)||this.options.deadlineMs)}));e=yield Promise.race([o,r]).finally((()=>{clearTimeout(s)}))}catch(t){if(!(t instanceof a||t instanceof o))throw t;console.warn(`RPCClient ClientManager#sendRequestWithTransport() sending request with ${this.transports[s].name} failed, trying next transport`),s++}}else s++}if(!e&&!this.transports[s])throw console.error(`RPCClient ClientManager#sendRequestWithTransport() ${t.scope}::${t.procedure}::${t.version} did not get a response from any transports`),new r(`Procedure ${t.procedure} did not get a response from any transports`);if(!e)throw new r(`Procedure ${t.procedure} did not get a response from the remote`);return e})),this.cache=t.cache,t.requestInterceptor&&this.interceptors.request.push(t.requestInterceptor),t.responseInterceptor&&this.interceptors.response.push(t.responseInterceptor),this.transports=t.transports}}class Wi{constructor(t){this.cacheOptions=t}clearCache(){}getCachedResponse(t){}setCachedResponse(t,e){}}Wi.DEFAULT_CACHE_MAX_AGE_MS=3e5,Wi.DEFAULT_CACHE_MAX_SIZE=100;const qi="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Bi=new Set,Ui="object"==typeof process&&process?process:{},Ni=(t,e,i,s)=>{"function"==typeof Ui.emitWarning?Ui.emitWarning(t,e,i,s):console.error(`[${i}] ${e}: ${t}`)};let $i=globalThis.AbortController,Gi=globalThis.AbortSignal;if(void 0===$i){Gi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},$i=class{constructor(){e()}signal=new Gi;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"!==Ui.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,Ni("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 Hi=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Ji=t=>Hi(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Vi:null:null;class Vi extends Array{constructor(t){super(t),this.fill(0)}}class Xi{heap;length;static#t=!1;static create(t){const e=Ji(t);if(!e)return[];Xi.#t=!0;const i=new Xi(t,e);return Xi.#t=!1,i}constructor(t,e){if(!Xi.#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 Ki{#e;#i;#s;#n;#r;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#l;#u;#d;#p;#f;#v;#y;#g;#b;#w;#m;#S;#_;static unsafeExposeInternals(t){return{starts:t.#b,ttls:t.#w,sizes:t.#g,keyMap:t.#c,keyList:t.#h,valList:t.#l,next:t.#u,prev:t.#d,get head(){return t.#p},get tail(){return t.#f},free:t.#v,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,i,s,n)=>t.#C(e,i,s,n),moveToTail:e=>t.#j(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#i}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#r}get dispose(){return this.#s}get disposeAfter(){return this.#n}constructor(t){const{max:e=0,ttl:i,ttlResolution:s=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,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:g,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:w,ignoreFetchAbort:m}=t;if(0!==e&&!Hi(e))throw new TypeError("max option must be a nonnegative integer");const S=e?Ji(e):Array;if(!S)throw new Error("invalid max value: "+e);if(this.#e=e,this.#i=d,this.maxEntrySize=p||this.#i,this.sizeCalculation=f,this.sizeCalculation){if(!this.#i&&!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!==v&&"function"!=typeof v)throw new TypeError("fetchMethod must be a function if specified");if(this.#r=v,this.#S=!!v,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new S(e),this.#d=new S(e),this.#p=0,this.#f=0,this.#v=Xi.create(e),this.#o=0,this.#a=0,"function"==typeof c&&(this.#s=c),"function"==typeof h?(this.#n=h,this.#y=[]):(this.#n=void 0,this.#y=void 0),this.#m=!!this.#s,this.#_=!!this.#n,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!w,this.ignoreFetchAbort=!!m,0!==this.maxEntrySize){if(0!==this.#i&&!Hi(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!Hi(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#F()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!g,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!o,this.ttlResolution=Hi(s)||0===s?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!Hi(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#E()}if(0===this.#e&&0===this.ttl&&0===this.#i)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#i){const t="LRU_CACHE_UNBOUNDED";if((t=>!Bi.has(t))(t)){Bi.add(t);Ni("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,Ki)}}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#E(){const t=new Vi(this.#e),e=new Vi(this.#e);this.#w=t,this.#b=e,this.#z=(i,s,n=qi.now())=>{if(e[i]=0!==s?n:0,t[i]=s,0!==s&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(i)&&this.delete(this.#h[i])}),s+1);t.unref&&t.unref()}},this.#R=i=>{e[i]=0!==t[i]?qi.now():0},this.#x=(n,r)=>{if(t[r]){const o=t[r],a=e[r];n.ttl=o,n.start=a,n.now=i||s();const c=n.now-a;n.remainingTTL=o-c}};let i=0;const s=()=>{const t=qi.now();if(this.ttlResolution>0){i=t;const e=setTimeout((()=>i=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=n=>{const r=this.#c.get(n);if(void 0===r)return 0;const o=t[r],a=e[r];if(0===o||0===a)return 1/0;return o-((i||s())-a)},this.#k=n=>0!==t[n]&&0!==e[n]&&(i||s())-e[n]>t[n]}#R=()=>{};#x=()=>{};#z=()=>{};#k=()=>!1;#F(){const t=new Vi(this.#e);this.#a=0,this.#g=t,this.#I=e=>{this.#a-=t[e],t[e]=0},this.#M=(t,e,i,s)=>{if(this.#T(e))return 0;if(!Hi(i)){if(!s)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 s)throw new TypeError("sizeCalculation must be a function");if(i=s(e,t),!Hi(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return i},this.#L=(e,i,s)=>{if(t[e]=i,this.#i){const i=this.#i-t[e];for(;this.#a>i;)this.#P(!0)}this.#a+=t[e],s&&(s.entrySize=i,s.totalCalculatedSize=this.#a)}}#I=t=>{};#L=(t,e,i)=>{};#M=(t,e,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#f;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#d[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#D(e)&&(!t&&this.#k(e)||(yield e),e!==this.#f);)e=this.#u[e]}#D(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#h[t]||this.#T(this.#l[t])||(yield[this.#h[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}*rvalues(){for(const t of this.#A()){void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const i of this.#O()){const s=this.#l[i],n=this.#T(s)?s.__staleWhileFetching:s;if(void 0!==n&&t(n,this.#h[i],this))return this.get(this.#h[i],e)}}forEach(t,e=this){for(const i of this.#O()){const s=this.#l[i],n=this.#T(s)?s.__staleWhileFetching:s;void 0!==n&&t.call(e,n,this.#h[i],this)}}rforEach(t,e=this){for(const i of this.#A()){const s=this.#l[i],n=this.#T(s)?s.__staleWhileFetching:s;void 0!==n&&t.call(e,n,this.#h[i],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const i=this.#h[e],s=this.#l[e],n=this.#T(s)?s.__staleWhileFetching:s;if(void 0===n||void 0===i)continue;const r={value:n};if(this.#w&&this.#b){r.ttl=this.#w[e];const t=qi.now()-this.#b[e];r.start=Math.floor(Date.now()-t)}this.#g&&(r.size=this.#g[e]),t.unshift([i,r])}return t}load(t){this.clear();for(const[e,i]of t){if(i.start){const t=Date.now()-i.start;i.start=qi.now()-t}this.set(e,i.value,i)}}set(t,e,i={}){if(void 0===e)return this.delete(t),this;const{ttl:s=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=i;let{noUpdateTTL:c=this.noUpdateTTL}=i;const h=this.#M(t,e,i.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#o?void 0:this.#c.get(t);if(void 0===l)l=0===this.#o?this.#f:0!==this.#v.length?this.#v.pop():this.#o===this.#e?this.#P(!1):this.#o,this.#h[l]=t,this.#l[l]=e,this.#c.set(t,l),this.#u[this.#f]=l,this.#d[l]=this.#f,this.#f=l,this.#o++,this.#L(l,h,a),a&&(a.set="add"),c=!1;else{this.#j(l);const i=this.#l[l];if(e!==i){if(this.#S&&this.#T(i)?i.__abortController.abort(new Error("replaced")):r||(this.#m&&this.#s?.(i,t,"set"),this.#_&&this.#y?.push([i,t,"set"])),this.#I(l),this.#L(l,h,a),this.#l[l]=e,a){a.set="replace";const t=i&&this.#T(i)?i.__staleWhileFetching:i;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===s||this.#w||this.#E(),this.#w&&(c||this.#z(l,s,n),a&&this.#x(a,l)),!r&&this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#l[this.#p];if(this.#P(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}#P(t){const e=this.#p,i=this.#h[e],s=this.#l[e];return this.#S&&this.#T(s)?s.__abortController.abort(new Error("evicted")):(this.#m||this.#_)&&(this.#m&&this.#s?.(s,i,"evict"),this.#_&&this.#y?.push([s,i,"evict"])),this.#I(e),t&&(this.#h[e]=void 0,this.#l[e]=void 0,this.#v.push(e)),1===this.#o?(this.#p=this.#f=0,this.#v.length=0):this.#p=this.#u[e],this.#c.delete(i),this.#o--,e}has(t,e={}){const{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=e,n=this.#c.get(t);if(void 0!==n){const t=this.#l[n];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(n))return i&&this.#R(n),s&&(s.has="hit",this.#x(s,n)),!0;s&&(s.has="stale",this.#x(s,n))}else s&&(s.has="miss");return!1}peek(t,e={}){const{allowStale:i=this.allowStale}=e,s=this.#c.get(t);if(void 0!==s&&(i||!this.#k(s))){const t=this.#l[s];return this.#T(t)?t.__staleWhileFetching:t}}#C(t,e,i,s){const n=void 0===e?void 0:this.#l[e];if(this.#T(n))return n;const r=new $i,{signal:o}=i;o?.addEventListener("abort",(()=>r.abort(o.reason)),{signal:r.signal});const a={signal:r.signal,options:i,context:s},c=(s,n=!1)=>{const{aborted:o}=r.signal,c=i.ignoreFetchAbort&&void 0!==s;if(i.status&&(o&&!n?(i.status.fetchAborted=!0,i.status.fetchError=r.signal.reason,c&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),o&&!c&&!n)return h(r.signal.reason);const u=l;return this.#l[e]===l&&(void 0===s?u.__staleWhileFetching?this.#l[e]=u.__staleWhileFetching:this.delete(t):(i.status&&(i.status.fetchUpdated=!0),this.set(t,s,a.options))),s},h=s=>{const{aborted:n}=r.signal,o=n&&i.allowStaleOnFetchAbort,a=o||i.allowStaleOnFetchRejection,c=a||i.noDeleteOnFetchRejection,h=l;if(this.#l[e]===l){!c||void 0===h.__staleWhileFetching?this.delete(t):o||(this.#l[e]=h.__staleWhileFetching)}if(a)return i.status&&void 0!==h.__staleWhileFetching&&(i.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw s};i.status&&(i.status.fetchDispatched=!0);const l=new Promise(((e,s)=>{const o=this.#r?.(t,n,a);o&&o instanceof Promise&&o.then((t=>e(t)),s),r.signal.addEventListener("abort",(()=>{i.ignoreFetchAbort&&!i.allowStaleOnFetchAbort||(e(),i.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(i.status&&(i.status.fetchRejected=!0,i.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.#c.get(t)):this.#l[e]=u,u}#T(t){if(!this.#S)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof $i}async fetch(t,e={}){const{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:v=!1,status:y,signal:g}=e;if(!this.#S)return y&&(y.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:y});const b={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:p,ignoreFetchAbort:d,status:y,signal:g};let w=this.#c.get(t);if(void 0===w){y&&(y.fetch="miss");const e=this.#C(t,w,b,f);return e.__returned=e}{const e=this.#l[w];if(this.#T(e)){const t=i&&void 0!==e.__staleWhileFetching;return y&&(y.fetch="inflight",t&&(y.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const n=this.#k(w);if(!v&&!n)return y&&(y.fetch="hit"),this.#j(w),s&&this.#R(w),y&&this.#x(y,w),e;const r=this.#C(t,w,b,f),o=void 0!==r.__staleWhileFetching&&i;return y&&(y.fetch=n?"stale":"refresh",o&&n&&(y.returnedStale=!0)),o?r.__staleWhileFetching:r.__returned=r}}get(t,e={}){const{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#l[o],a=this.#T(e);return r&&this.#x(r,o),this.#k(o)?(r&&(r.get="stale"),a?(r&&i&&void 0!==e.__staleWhileFetching&&(r.returnedStale=!0),i?e.__staleWhileFetching:void 0):(n||this.delete(t),r&&i&&(r.returnedStale=!0),i?e:void 0)):(r&&(r.get="hit"),a?e.__staleWhileFetching:(this.#j(o),s&&this.#R(o),e))}r&&(r.get="miss")}#W(t,e){this.#d[e]=t,this.#u[t]=e}#j(t){t!==this.#f&&(t===this.#p?this.#p=this.#u[t]:this.#W(this.#d[t],this.#u[t]),this.#W(this.#f,t),this.#f=t)}delete(t){let e=!1;if(0!==this.#o){const i=this.#c.get(t);if(void 0!==i)if(e=!0,1===this.#o)this.clear();else{this.#I(i);const e=this.#l[i];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#m||this.#_)&&(this.#m&&this.#s?.(e,t,"delete"),this.#_&&this.#y?.push([e,t,"delete"])),this.#c.delete(t),this.#h[i]=void 0,this.#l[i]=void 0,i===this.#f?this.#f=this.#d[i]:i===this.#p?this.#p=this.#u[i]:(this.#u[this.#d[i]]=this.#u[i],this.#d[this.#u[i]]=this.#d[i]),this.#o--,this.#v.push(i)}}if(this.#_&&this.#y?.length){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const i=this.#h[t];this.#m&&this.#s?.(e,i,"delete"),this.#_&&this.#y?.push([e,i,"delete"])}}if(this.#c.clear(),this.#l.fill(void 0),this.#h.fill(void 0),this.#w&&this.#b&&(this.#w.fill(0),this.#b.fill(0)),this.#g&&this.#g.fill(0),this.#p=0,this.#f=0,this.#v.length=0,this.#a=0,this.#o=0,this.#_&&this.#y){const t=this.#y;let e;for(;e=t?.shift();)this.#n?.(...e)}}}const Zi=Li("rpc:InMemoryCache");class Qi{constructor(t){this.clearCache=()=>{var t;Zi("clearCache"),null===(t=this.cachedResponseByParams)||void 0===t||t.clear()},this.getCachedResponse=t=>{var e;Zi("getCachedResponse, key: ",t);let i=null===(e=this.cachedResponseByParams)||void 0===e?void 0:e.get(h(t));return"string"==typeof i&&(i=JSON.parse(i)),i},this.setCachedResponse=(t,e)=>{var i,s;Zi("setCachedResponse",t,e);const n=h(t);if(!e)return null===(i=this.cachedResponseByParams)||void 0===i?void 0:i.delete(n);const r=Object.assign({},e);delete r.correlationId,null===(s=this.cachedResponseByParams)||void 0===s||s.set(n,r?JSON.stringify(r):void 0)},this.cachedResponseByParams=new Ki({max:(null==t?void 0:t.cacheMaxSize)||Qi.DEFAULT_CACHE_MAX_SIZE,ttl:(null==t?void 0:t.cacheMaxAgeMs)||Qi.DEFAULT_CACHE_MAX_AGE_MS})}}Qi.DEFAULT_CACHE_MAX_AGE_MS=9e5,Qi.DEFAULT_CACHE_MAX_SIZE=200;class Yi{constructor(t){const{code:e,correlationId:i,data:s,message:n,success:r}=t;if("number"!=typeof e)throw new Error("code must be a number");if(this.code=e,i&&"string"!=typeof i)throw new Error("correlationId must be a string");if(this.correlationId=i,this.data=s,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}}const ts=Li("rpc:HTTPTransport");class es{constructor(t){this.options=t,this.networkIsConnected=!1,this.name="HttpTransport",this.isConnected=()=>{var t;return"undefined"!=typeof window?!!(null===(t=null===window||void 0===window?void 0:window.navigator)||void 0===t?void 0:t.onLine):this.networkIsConnected},this.sendRequest=(t,i)=>e(this,void 0,void 0,(function*(){ts("sendRequest",t);const e=JSON.stringify(Object.assign({identity:this.identity},t)),i=yield null===window||void 0===window?void 0:window.fetch(this.host,{body:e,cache:"default",credentials:"omit",headers:{"Content-Type":"application/json"},method:"POST",mode:"cors",redirect:"follow",referrerPolicy:"origin"}),s=yield i.text();if(!s)throw new Error("No response received from remote");const n=JSON.parse(s);return new Yi(n)})),this.setIdentity=t=>{ts("setIdentity",t),this.identity=t},this.host=t.host}}class is{constructor(t,i){this.reject=t=>{this.rejectPromise&&this.rejectPromise(t)},this.resolve=t=>{this.resolvePromise&&this.resolvePromise(t)},this.promise=new Promise(((s,n)=>e(this,void 0,void 0,(function*(){const e=setTimeout((()=>{n(new Error(`PromiseWraper timeout: ${t}`))}),i||3e4);this.rejectPromise=t=>{clearTimeout(e),n(t)},this.resolvePromise=t=>{clearTimeout(e),s(t)}}))))}}const ss=t=>new Promise((e=>setTimeout(e,t))),ns=t=>{const e=t.split("::");return{procedure:e[1],scope:e[0]||"global",version:e[2]||"1"}},rs=Li("rpc:WebSocketTransport");class os{constructor(t){this.options=t,this.connectedToRemote=!1,this.isWaitingForIdentityConfirmation=!1,this.pendingPromisesForResponse={},this.serverMessageHandlers=[],this.websocketId=void 0,this.name="WebSocketTransport",this.isConnected=()=>this.connectedToRemote&&!!this.websocket,this.connect=()=>{this._connect()},this.disconnect=()=>{this._disconnect("public disconnect() called")},this.sendClientMessageToServer=t=>{var e;let i=t;try{i=JSON.stringify({clientMessage:t})}catch(e){console.warn('WebSocketTransport.sendClientMessage() unable to stringify "msg"',t)}null===(e=this.websocket)||void 0===e||e.send(i)},this.sendRequest=(t,i)=>e(this,void 0,void 0,(function*(){for(rs("sendRequest",t);this.isWaitingForIdentityConfirmation;)rs("waiting for identity confirmation"),yield ss(100);return this.sendCall(t,i)})),this.setIdentity=t=>e(this,void 0,void 0,(function*(){if(rs("setIdentity",t),!t)return this.identity=void 0,void(yield this.resetConnection());this.identity=t,this.connectedToRemote?this.isWaitingForIdentityConfirmation?rs('setIdentity returning early because "this.isWaitingForIdentityConfirmation=true"'):(this.isWaitingForIdentityConfirmation=!0,this.sendCall({identity:t},{}).then((()=>{rs("setIdentity with remote complete")})).catch((t=>{rs("setIdentity with remote error",t)})).finally((()=>{this.isWaitingForIdentityConfirmation=!1}))):rs("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(rs("connect",this.host),this.websocket)return void rs("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):rs("WebSocket closed, it was not connected to the remote"),this.setConnectedToRemote(!1),this.isWaitingForIdentityConfirmation=!1,this.websocket=void 0,this.websocketId=void 0,Object.entries(this.pendingPromisesForResponse).forEach((([t,e])=>{e.reject(new o("Websocket disconnected"))})),t.wasClean||setTimeout((()=>{this.connect()}),1e3)},t.onerror=e=>{this.connectedToRemote?console.error("WebSocket encountered error: ",e):rs("WebSocket errored, it was not connected to the remote"),t.close()}},this._disconnect=t=>{var e;rs("_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(i){console.warn("WebSocketTransport.handleServerMessage() a serverMessageHandler errored when calling",t,"handler func:",e),console.error(i)}}))},this.handleWebSocketMsg=t=>{let e;rs("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 i=new Yi(e);if(!i.correlationId)return void console.error("RPCClient WebSocketTransport received unexpected msg from the server, not correlationId found in response.",e);const s=this.pendingPromisesForResponse[i.correlationId];s?s.resolve(i):console.warn("rcvd WS msg/response that doesn't match any pending RPC's",e)},this.resetConnection=()=>e(this,void 0,void 0,(function*(){rs("resetConnection"),this._disconnect("WebSocketTransport#resetConnection"),yield ss(100),this._connect()})),this.sendCall=(t,i)=>e(this,void 0,void 0,(function*(){var e;rs("sendCall",t);const s=Math.random().toString();t.correlationId=t.correlationId||s;let n=new is(`${(r=t).scope}::${r.procedure}::${r.version}`,i.timeout||this.options.rpcOptions.deadlineMs);var r;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=>{rs(`setConnectedToRemote: ${t}`),this.connectedToRemote=t,this.options.onConnectionStatusChange&&this.options.onConnectionStatusChange(t),t&&this.identity&&this.setIdentity(this.identity)},rs("new WebSocketTransport()"),this.host=t.host,this.connect()}}class as{constructor(){this.events={},this.publish=(t,i)=>e(this,void 0,void 0,(function*(){const e=this.events[t];e&&e.forEach((function(t){t.call(t,i)}))})),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 i=this.events[t].indexOf(e);this.events[t].splice(i)}}}const cs={HTTP_HOST_OR_TRANSPORT_REQUIRED:"http host or tansport is required",INTERCEPTOR_MUSTBE_FUNC:"interceptors must be a function"};class hs{constructor(t){var i,s,r,o,a,c;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,i,s)=>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?ns(t):t,i&&(e.args=i);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=Ii(Object.assign({},this.identity),r.identity);const o=yield this.callManager.manageClientRequest(r,s);if(!o.success)throw o;const a=h(e);return this.vent.publish(a,null==o?void 0:o.data),o})),this.clearCache=t=>{this.callManager.clearCache(t)},this.getCallCache=(t,e)=>{let i;i="string"==typeof t?ns(t):t,e&&(i.args=e);const s=this.callManager.getCachedResponse(i);if(s)return s},this.getIdentity=()=>this.identity?Oi(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 i;return i="string"==typeof t?ns(t):t,function(t){return e.call(Object.assign(Object.assign({},i),{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=Oi(t);this.identity=t,this.callManager.setIdentity(e)},this.setIdentityMetadata=t=>{var e;null!==(e=this.identity)&&void 0!==e||(this.identity={});const i=Oi(this.identity);i.metadata=t,this.identity.metadata=t,this.callManager.setIdentity(i)},this.transports=()=>({http:this.httpTransport,websocket:this.webSocketTransport}),!(null===(i=null==t?void 0:t.hosts)||void 0===i?void 0:i.http)&&!(null===(s=null==t?void 0:t.transports)||void 0===s?void 0:s.http))throw new Error(cs.HTTP_HOST_OR_TRANSPORT_REQUIRED);if(t.requestInterceptor&&"function"!=typeof t.requestInterceptor)throw new Error(cs.INTERCEPTOR_MUSTBE_FUNC);if(t.responseInterceptor&&"function"!=typeof t.responseInterceptor)throw new Error(cs.INTERCEPTOR_MUSTBE_FUNC);let l;const u={cacheMaxAgeMs:null==t?void 0:t.cacheMaxAgeMs};l="browser"==t.cacheType?new Wi(u):new Qi(u);const d=[];(null===(r=t.transports)||void 0===r?void 0:r.websocket)?d.push(t.transports.websocket):(null===(o=null==t?void 0:t.hosts)||void 0===o?void 0:o.websocket)&&(this.webSocketTransport=new os({host:t.hosts.websocket,onConnectionStatusChange:this.onWebSocketConnectionStatusChange,rpcOptions:t}),d.push(this.webSocketTransport)),(null===(a=t.transports)||void 0===a?void 0:a.http)?d.push(t.transports.http):(null===(c=null==t?void 0:t.hosts)||void 0===c?void 0:c.http)&&(this.httpTransport=new es({host:t.hosts.http,rpcOptions:t}),d.push(this.httpTransport)),this.callManager=new Di({cache:l,deadlineMs:t.deadlineMs||hs.DEFAULT_DEADLINE_MS,requestInterceptor:t.requestInterceptor,responseInterceptor:t.responseInterceptor,transports:d})}subscribe(t,e){const i="string"==typeof t.request?ns(t.request):t.request,s=h(Object.assign(Object.assign({},i),{args:t.args}));return this.vent.subscribe(s,e)}unsubscribe(t,e){const i="string"==typeof t.request?ns(t.request):t.request,s=h(Object.assign(Object.assign({},i),{args:t.args}));this.vent.unsubscribe(s,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)}}hs.DEFAULT_DEADLINE_MS=1e4,t.RPCClient=hs,t.RPCResponse=Yi,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@therms/rpc-client", | ||
"version": "2.16.1", | ||
"version": "2.16.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
327159
3645