@formant/data-sdk 0.0.96 → 0.0.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/data-sdk.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Oe,Me){typeof exports=="object"&&typeof module!="undefined"?Me(exports):typeof define=="function"&&define.amd?define(["exports"],Me):(Oe=typeof globalThis!="undefined"?globalThis:Oe||self,Me(Oe.FormantDataSDK={}))})(this,function(exports){"use strict";var lr=Object.defineProperty;var Zt=Object.getOwnPropertySymbols;var ur=Object.prototype.hasOwnProperty,cr=Object.prototype.propertyIsEnumerable;var Tt=(Oe,Me,e)=>Me in Oe?lr(Oe,Me,{enumerable:!0,configurable:!0,writable:!0,value:e}):Oe[Me]=e,st=(Oe,Me)=>{for(var e in Me||(Me={}))ur.call(Me,e)&&Tt(Oe,e,Me[e]);if(Zt)for(var e of Zt(Me))cr.call(Me,e)&&Tt(Oe,e,Me[e]);return Oe};var
|
|
1
|
+
(function(Oe,Me){typeof exports=="object"&&typeof module!="undefined"?Me(exports):typeof define=="function"&&define.amd?define(["exports"],Me):(Oe=typeof globalThis!="undefined"?globalThis:Oe||self,Me(Oe.FormantDataSDK={}))})(this,function(exports){"use strict";var lr=Object.defineProperty;var Zt=Object.getOwnPropertySymbols;var ur=Object.prototype.hasOwnProperty,cr=Object.prototype.propertyIsEnumerable;var Tt=(Oe,Me,e)=>Me in Oe?lr(Oe,Me,{enumerable:!0,configurable:!0,writable:!0,value:e}):Oe[Me]=e,st=(Oe,Me)=>{for(var e in Me||(Me={}))ur.call(Me,e)&&Tt(Oe,e,Me[e]);if(Zt)for(var e of Zt(Me))cr.call(Me,e)&&Tt(Oe,e,Me[e]);return Oe};var je=(Oe,Me,e)=>(Tt(Oe,typeof Me!="symbol"?Me+"":Me,e),e);var dist={exports:{}};/*! For license information please see index.js.LICENSE.txt */(function(module,exports){(function(e,t){module.exports=t()})(window,function(){return function(e){function t(u){for(var b,A,_=u[0],v=u[1],f=0,S=[];f<_.length;f++)A=_[f],Object.prototype.hasOwnProperty.call(n,A)&&n[A]&&S.push(n[A][0]),n[A]=0;for(b in v)Object.prototype.hasOwnProperty.call(v,b)&&(e[b]=v[b]);for(c&&c(u);S.length;)S.shift()()}var r={},n={0:0};function o(u){if(r[u])return r[u].exports;var b=r[u]={i:u,l:!1,exports:{}};return e[u].call(b.exports,b,b.exports,o),b.l=!0,b.exports}o.e=function(){return Promise.resolve()},o.m=e,o.c=r,o.d=function(u,b,A){o.o(u,b)||Object.defineProperty(u,b,{enumerable:!0,get:A})},o.r=function(u){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},o.t=function(u,b){if(1&b&&(u=o(u)),8&b||4&b&&typeof u=="object"&&u&&u.__esModule)return u;var A=Object.create(null);if(o.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:u}),2&b&&typeof u!="string")for(var _ in u)o.d(A,_,function(v){return u[v]}.bind(null,_));return A},o.n=function(u){var b=u&&u.__esModule?function(){return u.default}:function(){return u};return o.d(b,"a",b),b},o.o=function(u,b){return Object.prototype.hasOwnProperty.call(u,b)},o.p="",o.oe=function(u){throw console.error(u),u};var l=window.webpackJsonpFormantRealtimeSDK=window.webpackJsonpFormantRealtimeSDK||[],s=l.push.bind(l);l.push=t,l=l.slice();for(var i=0;i<l.length;i++)t(l[i]);var c=s;return o(o.s=226)}([function(e,t,r){r.d(t,"a",function(){return k});const n=Math.pow(2,20),o=n;var l=r(54),s=r.n(l),i=r(15),c=r(53),u=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),b=new Uint8Array(16);function A(){if(!u)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return u(b)}for(var _=[],v=0;v<256;++v)_[v]=(v+256).toString(16).substr(1);var f=function(g,U){var B=U||0,G=_;return[G[g[B++]],G[g[B++]],G[g[B++]],G[g[B++]],"-",G[g[B++]],G[g[B++]],"-",G[g[B++]],G[g[B++]],"-",G[g[B++]],G[g[B++]],"-",G[g[B++]],G[g[B++]],G[g[B++]],G[g[B++]],G[g[B++]],G[g[B++]]].join("")},S=function(g,U,B){var G=U&&B||0;typeof g=="string"&&(U=g==="binary"?new Array(16):null,g=null);var Y=(g=g||{}).random||(g.rng||A)();if(Y[6]=15&Y[6]|64,Y[8]=63&Y[8]|128,U)for(var K=0;K<16;++K)U[G+K]=Y[K];return U||f(Y)},w=r(16),P=r(6),N=r(29),T=r(35),R=r.n(T);function d(g){return R()(g,{cycles:!0})}var I=function(g,U){var B={};for(var G in g)Object.prototype.hasOwnProperty.call(g,G)&&U.indexOf(G)<0&&(B[G]=g[G]);if(g!=null&&typeof Object.getOwnPropertySymbols=="function"){var Y=0;for(G=Object.getOwnPropertySymbols(g);Y<G.length;Y++)U.indexOf(G[Y])<0&&Object.prototype.propertyIsEnumerable.call(g,G[Y])&&(B[G[Y]]=g[G[Y]])}return B};function Q(g,U={}){const B=V=>U.redacted!==!1?Object(N.a)(V):V;if(!g.stack)return{message:d(B(g))};const{name:G,message:Y,stack:K}=g,H=I(g,["name","message","stack"]);return{name:G,message:Y!==void 0?Y:d(B(g)),stack:K,meta:H&&Object.keys(H).length===0?void 0:B(H)}}function Z(g,U={}){const{message:B,stack:G,meta:Y}=Q(g,U);return`${G||B||""}${Y&&Object.keys(Y).length>0?` -- ${d(Y)}`:""}`}var h=r(99),p=r.n(h),C=function(g,U,B,G){return new(B||(B=Promise))(function(Y,K){function H(j){try{y(G.next(j))}catch(W){K(W)}}function V(j){try{y(G.throw(j))}catch(W){K(W)}}function y(j){var W;j.done?Y(j.value):(W=j.value,W instanceof B?W:new B(function(ee){ee(W)})).then(H,V)}y((G=G.apply(g,U||[])).next())})},m=function(g,U){var B={};for(var G in g)Object.prototype.hasOwnProperty.call(g,G)&&U.indexOf(G)<0&&(B[G]=g[G]);if(g!=null&&typeof Object.getOwnPropertySymbols=="function"){var Y=0;for(G=Object.getOwnPropertySymbols(g);Y<G.length;Y++)U.indexOf(G[Y])<0&&Object.prototype.propertyIsEnumerable.call(g,G[Y])&&(B[G[Y]]=g[G[Y]])}return B};class x extends p.a{constructor(U,B){super(),this.endpoint=U,this.meta=B,this.logClient=this.getLogClient()}getLogClient(){return C(this,void 0,void 0,function*(){const{LogClient:U}=yield Promise.resolve().then(r.bind(null,228));return new U(this.endpoint)})}log(U,B){return C(this,void 0,void 0,function*(){const{level:G,message:Y,error:K}=U,H=m(U,["level","message","error"]);this.emit("logged");try{yield(yield this.logClient).log([{timestamp:new Date().toISOString(),level:G,message:Y.substring(0,1e3),error:K!==void 0?Q(K):void 0,meta:Object.assign(Object.assign({},H),this.meta())}])}catch(V){console.error(`Failed to log to log-api: ${Z(V)}`)}B()})}}var F=function(g,U){var B={};for(var G in g)Object.prototype.hasOwnProperty.call(g,G)&&U.indexOf(G)<0&&(B[G]=g[G]);if(g!=null&&typeof Object.getOwnPropertySymbols=="function"){var Y=0;for(G=Object.getOwnPropertySymbols(g);Y<G.length;Y++)U.indexOf(G[Y])<0&&Object.prototype.propertyIsEnumerable.call(g,G[Y])&&(B[G[Y]]=g[G[Y]])}return B};const D={app:P.a,namespace:P.i,buildTag:P.b,instanceId:S()};let O={};const L=P.e?w.format.printf(g=>{var{timestamp:U,level:B,message:G,error:Y}=g,K=F(g,["timestamp","level","message","error"]);const H=Object.assign(Object.assign({timestamp:U?new Date(U).getTime():new Date().getTime(),level:B.toUpperCase(),message:G},Y?{error:Q(Y)}:{}),{meta:Object.assign(Object.assign(Object.assign({},D),O),K)});try{return JSON.stringify(H)}catch{return s()(H)}}):w.format.printf(g=>{var{timestamp:U,level:B,message:G,error:Y}=g,K=F(g,["timestamp","level","message","error"]);let H=`${U||new Date().toISOString()} ${B.toUpperCase()}: ${G} `;if(Object.keys(K).length>0)try{H+=JSON.stringify(K)}catch{H+=s()(K)}return Y&&(H+=`
|
|
2
2
|
${Z(Y)}`),H}),k=Object(w.createLogger)({level:P.f});if(P.g&&k.add(new w.transports.Console({format:L,level:"debug"})),P.d&&k.add(new x(P.d,()=>Object.assign(Object.assign(Object.assign({},D),O),{level:"debug"}))),P.h){const g=c.resolve(i.tmpdir(),`silly-${P.a}.log`);k.debug("Logging silly logs to file",{filename:g}),k.add(new w.transports.File({filename:g,maxsize:1*o,maxFiles:10,format:w.format.combine((E="silly",Object(w.format)(U=>U.level===E&&U)()),L),level:"silly"}))}var E},function(e,t,r){r.d(t,"a",function(){return n});const n={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}},function(e,t){var r,n,o=e.exports={};function l(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function i(w){if(r===setTimeout)return setTimeout(w,0);if((r===l||!r)&&setTimeout)return r=setTimeout,setTimeout(w,0);try{return r(w,0)}catch{try{return r.call(null,w,0)}catch{return r.call(this,w,0)}}}(function(){try{r=typeof setTimeout=="function"?setTimeout:l}catch{r=l}try{n=typeof clearTimeout=="function"?clearTimeout:s}catch{n=s}})();var c,u=[],b=!1,A=-1;function _(){b&&c&&(b=!1,c.length?u=c.concat(u):A=-1,u.length&&v())}function v(){if(!b){var w=i(_);b=!0;for(var P=u.length;P;){for(c=u,u=[];++A<P;)c&&c[A].run();A=-1,P=u.length}c=null,b=!1,function(N){if(n===clearTimeout)return clearTimeout(N);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(N);try{n(N)}catch{try{return n.call(null,N)}catch{return n.call(this,N)}}}(w)}}function f(w,P){this.fun=w,this.array=P}function S(){}o.nextTick=function(w){var P=new Array(arguments.length-1);if(arguments.length>1)for(var N=1;N<arguments.length;N++)P[N-1]=arguments[N];u.push(new f(w,P)),u.length!==1||b||i(v)},f.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=S,o.addListener=S,o.once=S,o.off=S,o.removeListener=S,o.removeAllListeners=S,o.emit=S,o.prependListener=S,o.prependOnceListener=S,o.listeners=function(w){return[]},o.binding=function(w){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(w){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,r){Object.defineProperty(t,"LEVEL",{value:Symbol.for("level")}),Object.defineProperty(t,"MESSAGE",{value:Symbol.for("message")}),Object.defineProperty(t,"SPLAT",{value:Symbol.for("splat")}),Object.defineProperty(t,"configs",{value:r(117)})},function(e,t,r){(function(n){var o=r(125),l=r(126),s=r(38);function i(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function c(y,j){if(i()<j)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(y=new Uint8Array(j)).__proto__=u.prototype:(y===null&&(y=new u(j)),y.length=j),y}function u(y,j,W){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(y,j,W);if(typeof y=="number"){if(typeof j=="string")throw new Error("If encoding is specified then the first argument must be a string");return _(this,y)}return b(this,y,j,W)}function b(y,j,W,ee){if(typeof j=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&j instanceof ArrayBuffer?function(X,ne,ie,he){if(ne.byteLength,ie<0||ne.byteLength<ie)throw new RangeError("'offset' is out of bounds");if(ne.byteLength<ie+(he||0))throw new RangeError("'length' is out of bounds");return ne=ie===void 0&&he===void 0?new Uint8Array(ne):he===void 0?new Uint8Array(ne,ie):new Uint8Array(ne,ie,he),u.TYPED_ARRAY_SUPPORT?(X=ne).__proto__=u.prototype:X=v(X,ne),X}(y,j,W,ee):typeof j=="string"?function(X,ne,ie){if(typeof ie=="string"&&ie!==""||(ie="utf8"),!u.isEncoding(ie))throw new TypeError('"encoding" must be a valid string encoding');var he=0|S(ne,ie),Se=(X=c(X,he)).write(ne,ie);return Se!==he&&(X=X.slice(0,Se)),X}(y,j,W):function(X,ne){if(u.isBuffer(ne)){var ie=0|f(ne.length);return(X=c(X,ie)).length===0||ne.copy(X,0,0,ie),X}if(ne){if(typeof ArrayBuffer!="undefined"&&ne.buffer instanceof ArrayBuffer||"length"in ne)return typeof ne.length!="number"||(he=ne.length)!=he?c(X,0):v(X,ne);if(ne.type==="Buffer"&&s(ne.data))return v(X,ne.data)}var he;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(y,j)}function A(y){if(typeof y!="number")throw new TypeError('"size" argument must be a number');if(y<0)throw new RangeError('"size" argument must not be negative')}function _(y,j){if(A(j),y=c(y,j<0?0:0|f(j)),!u.TYPED_ARRAY_SUPPORT)for(var W=0;W<j;++W)y[W]=0;return y}function v(y,j){var W=j.length<0?0:0|f(j.length);y=c(y,W);for(var ee=0;ee<W;ee+=1)y[ee]=255&j[ee];return y}function f(y){if(y>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|y}function S(y,j){if(u.isBuffer(y))return y.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(y)||y instanceof ArrayBuffer))return y.byteLength;typeof y!="string"&&(y=""+y);var W=y.length;if(W===0)return 0;for(var ee=!1;;)switch(j){case"ascii":case"latin1":case"binary":return W;case"utf8":case"utf-8":case void 0:return K(y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*W;case"hex":return W>>>1;case"base64":return H(y).length;default:if(ee)return K(y).length;j=(""+j).toLowerCase(),ee=!0}}function w(y,j,W){var ee=!1;if((j===void 0||j<0)&&(j=0),j>this.length||((W===void 0||W>this.length)&&(W=this.length),W<=0)||(W>>>=0)<=(j>>>=0))return"";for(y||(y="utf8");;)switch(y){case"hex":return F(this,j,W);case"utf8":case"utf-8":return C(this,j,W);case"ascii":return m(this,j,W);case"latin1":case"binary":return x(this,j,W);case"base64":return p(this,j,W);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,j,W);default:if(ee)throw new TypeError("Unknown encoding: "+y);y=(y+"").toLowerCase(),ee=!0}}function P(y,j,W){var ee=y[j];y[j]=y[W],y[W]=ee}function N(y,j,W,ee,X){if(y.length===0)return-1;if(typeof W=="string"?(ee=W,W=0):W>2147483647?W=2147483647:W<-2147483648&&(W=-2147483648),W=+W,isNaN(W)&&(W=X?0:y.length-1),W<0&&(W=y.length+W),W>=y.length){if(X)return-1;W=y.length-1}else if(W<0){if(!X)return-1;W=0}if(typeof j=="string"&&(j=u.from(j,ee)),u.isBuffer(j))return j.length===0?-1:T(y,j,W,ee,X);if(typeof j=="number")return j&=255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?X?Uint8Array.prototype.indexOf.call(y,j,W):Uint8Array.prototype.lastIndexOf.call(y,j,W):T(y,[j],W,ee,X);throw new TypeError("val must be string, number or Buffer")}function T(y,j,W,ee,X){var ne,ie=1,he=y.length,Se=j.length;if(ee!==void 0&&((ee=String(ee).toLowerCase())==="ucs2"||ee==="ucs-2"||ee==="utf16le"||ee==="utf-16le")){if(y.length<2||j.length<2)return-1;ie=2,he/=2,Se/=2,W/=2}function we($,te){return ie===1?$[te]:$.readUInt16BE(te*ie)}if(X){var Ee=-1;for(ne=W;ne<he;ne++)if(we(y,ne)===we(j,Ee===-1?0:ne-Ee)){if(Ee===-1&&(Ee=ne),ne-Ee+1===Se)return Ee*ie}else Ee!==-1&&(ne-=ne-Ee),Ee=-1}else for(W+Se>he&&(W=he-Se),ne=W;ne>=0;ne--){for(var ye=!0,q=0;q<Se;q++)if(we(y,ne+q)!==we(j,q)){ye=!1;break}if(ye)return ne}return-1}function R(y,j,W,ee){W=Number(W)||0;var X=y.length-W;ee?(ee=Number(ee))>X&&(ee=X):ee=X;var ne=j.length;if(ne%2!=0)throw new TypeError("Invalid hex string");ee>ne/2&&(ee=ne/2);for(var ie=0;ie<ee;++ie){var he=parseInt(j.substr(2*ie,2),16);if(isNaN(he))return ie;y[W+ie]=he}return ie}function d(y,j,W,ee){return V(K(j,y.length-W),y,W,ee)}function I(y,j,W,ee){return V(function(X){for(var ne=[],ie=0;ie<X.length;++ie)ne.push(255&X.charCodeAt(ie));return ne}(j),y,W,ee)}function Q(y,j,W,ee){return I(y,j,W,ee)}function Z(y,j,W,ee){return V(H(j),y,W,ee)}function h(y,j,W,ee){return V(function(X,ne){for(var ie,he,Se,we=[],Ee=0;Ee<X.length&&!((ne-=2)<0);++Ee)ie=X.charCodeAt(Ee),he=ie>>8,Se=ie%256,we.push(Se),we.push(he);return we}(j,y.length-W),y,W,ee)}function p(y,j,W){return j===0&&W===y.length?o.fromByteArray(y):o.fromByteArray(y.slice(j,W))}function C(y,j,W){W=Math.min(y.length,W);for(var ee=[],X=j;X<W;){var ne,ie,he,Se,we=y[X],Ee=null,ye=we>239?4:we>223?3:we>191?2:1;if(X+ye<=W)switch(ye){case 1:we<128&&(Ee=we);break;case 2:(192&(ne=y[X+1]))==128&&(Se=(31&we)<<6|63&ne)>127&&(Ee=Se);break;case 3:ne=y[X+1],ie=y[X+2],(192&ne)==128&&(192&ie)==128&&(Se=(15&we)<<12|(63&ne)<<6|63&ie)>2047&&(Se<55296||Se>57343)&&(Ee=Se);break;case 4:ne=y[X+1],ie=y[X+2],he=y[X+3],(192&ne)==128&&(192&ie)==128&&(192&he)==128&&(Se=(15&we)<<18|(63&ne)<<12|(63&ie)<<6|63&he)>65535&&Se<1114112&&(Ee=Se)}Ee===null?(Ee=65533,ye=1):Ee>65535&&(Ee-=65536,ee.push(Ee>>>10&1023|55296),Ee=56320|1023&Ee),ee.push(Ee),X+=ye}return function(q){var $=q.length;if($<=4096)return String.fromCharCode.apply(String,q);for(var te="",ue=0;ue<$;)te+=String.fromCharCode.apply(String,q.slice(ue,ue+=4096));return te}(ee)}t.Buffer=u,t.SlowBuffer=function(y){return+y!=y&&(y=0),u.alloc(+y)},t.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=n.TYPED_ARRAY_SUPPORT!==void 0?n.TYPED_ARRAY_SUPPORT:function(){try{var y=new Uint8Array(1);return y.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},y.foo()===42&&typeof y.subarray=="function"&&y.subarray(1,1).byteLength===0}catch{return!1}}(),t.kMaxLength=i(),u.poolSize=8192,u._augment=function(y){return y.__proto__=u.prototype,y},u.from=function(y,j,W){return b(null,y,j,W)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(y,j,W){return function(ee,X,ne,ie){return A(X),X<=0?c(ee,X):ne!==void 0?typeof ie=="string"?c(ee,X).fill(ne,ie):c(ee,X).fill(ne):c(ee,X)}(null,y,j,W)},u.allocUnsafe=function(y){return _(null,y)},u.allocUnsafeSlow=function(y){return _(null,y)},u.isBuffer=function(y){return!(y==null||!y._isBuffer)},u.compare=function(y,j){if(!u.isBuffer(y)||!u.isBuffer(j))throw new TypeError("Arguments must be Buffers");if(y===j)return 0;for(var W=y.length,ee=j.length,X=0,ne=Math.min(W,ee);X<ne;++X)if(y[X]!==j[X]){W=y[X],ee=j[X];break}return W<ee?-1:ee<W?1:0},u.isEncoding=function(y){switch(String(y).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(y,j){if(!s(y))throw new TypeError('"list" argument must be an Array of Buffers');if(y.length===0)return u.alloc(0);var W;if(j===void 0)for(j=0,W=0;W<y.length;++W)j+=y[W].length;var ee=u.allocUnsafe(j),X=0;for(W=0;W<y.length;++W){var ne=y[W];if(!u.isBuffer(ne))throw new TypeError('"list" argument must be an Array of Buffers');ne.copy(ee,X),X+=ne.length}return ee},u.byteLength=S,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var y=this.length;if(y%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var j=0;j<y;j+=2)P(this,j,j+1);return this},u.prototype.swap32=function(){var y=this.length;if(y%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var j=0;j<y;j+=4)P(this,j,j+3),P(this,j+1,j+2);return this},u.prototype.swap64=function(){var y=this.length;if(y%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var j=0;j<y;j+=8)P(this,j,j+7),P(this,j+1,j+6),P(this,j+2,j+5),P(this,j+3,j+4);return this},u.prototype.toString=function(){var y=0|this.length;return y===0?"":arguments.length===0?C(this,0,y):w.apply(this,arguments)},u.prototype.equals=function(y){if(!u.isBuffer(y))throw new TypeError("Argument must be a Buffer");return this===y||u.compare(this,y)===0},u.prototype.inspect=function(){var y="",j=t.INSPECT_MAX_BYTES;return this.length>0&&(y=this.toString("hex",0,j).match(/.{2}/g).join(" "),this.length>j&&(y+=" ... ")),"<Buffer "+y+">"},u.prototype.compare=function(y,j,W,ee,X){if(!u.isBuffer(y))throw new TypeError("Argument must be a Buffer");if(j===void 0&&(j=0),W===void 0&&(W=y?y.length:0),ee===void 0&&(ee=0),X===void 0&&(X=this.length),j<0||W>y.length||ee<0||X>this.length)throw new RangeError("out of range index");if(ee>=X&&j>=W)return 0;if(ee>=X)return-1;if(j>=W)return 1;if(this===y)return 0;for(var ne=(X>>>=0)-(ee>>>=0),ie=(W>>>=0)-(j>>>=0),he=Math.min(ne,ie),Se=this.slice(ee,X),we=y.slice(j,W),Ee=0;Ee<he;++Ee)if(Se[Ee]!==we[Ee]){ne=Se[Ee],ie=we[Ee];break}return ne<ie?-1:ie<ne?1:0},u.prototype.includes=function(y,j,W){return this.indexOf(y,j,W)!==-1},u.prototype.indexOf=function(y,j,W){return N(this,y,j,W,!0)},u.prototype.lastIndexOf=function(y,j,W){return N(this,y,j,W,!1)},u.prototype.write=function(y,j,W,ee){if(j===void 0)ee="utf8",W=this.length,j=0;else if(W===void 0&&typeof j=="string")ee=j,W=this.length,j=0;else{if(!isFinite(j))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");j|=0,isFinite(W)?(W|=0,ee===void 0&&(ee="utf8")):(ee=W,W=void 0)}var X=this.length-j;if((W===void 0||W>X)&&(W=X),y.length>0&&(W<0||j<0)||j>this.length)throw new RangeError("Attempt to write outside buffer bounds");ee||(ee="utf8");for(var ne=!1;;)switch(ee){case"hex":return R(this,y,j,W);case"utf8":case"utf-8":return d(this,y,j,W);case"ascii":return I(this,y,j,W);case"latin1":case"binary":return Q(this,y,j,W);case"base64":return Z(this,y,j,W);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h(this,y,j,W);default:if(ne)throw new TypeError("Unknown encoding: "+ee);ee=(""+ee).toLowerCase(),ne=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function m(y,j,W){var ee="";W=Math.min(y.length,W);for(var X=j;X<W;++X)ee+=String.fromCharCode(127&y[X]);return ee}function x(y,j,W){var ee="";W=Math.min(y.length,W);for(var X=j;X<W;++X)ee+=String.fromCharCode(y[X]);return ee}function F(y,j,W){var ee=y.length;(!j||j<0)&&(j=0),(!W||W<0||W>ee)&&(W=ee);for(var X="",ne=j;ne<W;++ne)X+=Y(y[ne]);return X}function D(y,j,W){for(var ee=y.slice(j,W),X="",ne=0;ne<ee.length;ne+=2)X+=String.fromCharCode(ee[ne]+256*ee[ne+1]);return X}function O(y,j,W){if(y%1!=0||y<0)throw new RangeError("offset is not uint");if(y+j>W)throw new RangeError("Trying to access beyond buffer length")}function L(y,j,W,ee,X,ne){if(!u.isBuffer(y))throw new TypeError('"buffer" argument must be a Buffer instance');if(j>X||j<ne)throw new RangeError('"value" argument is out of bounds');if(W+ee>y.length)throw new RangeError("Index out of range")}function k(y,j,W,ee){j<0&&(j=65535+j+1);for(var X=0,ne=Math.min(y.length-W,2);X<ne;++X)y[W+X]=(j&255<<8*(ee?X:1-X))>>>8*(ee?X:1-X)}function E(y,j,W,ee){j<0&&(j=4294967295+j+1);for(var X=0,ne=Math.min(y.length-W,4);X<ne;++X)y[W+X]=j>>>8*(ee?X:3-X)&255}function g(y,j,W,ee,X,ne){if(W+ee>y.length)throw new RangeError("Index out of range");if(W<0)throw new RangeError("Index out of range")}function U(y,j,W,ee,X){return X||g(y,0,W,4),l.write(y,j,W,ee,23,4),W+4}function B(y,j,W,ee,X){return X||g(y,0,W,8),l.write(y,j,W,ee,52,8),W+8}u.prototype.slice=function(y,j){var W,ee=this.length;if((y=~~y)<0?(y+=ee)<0&&(y=0):y>ee&&(y=ee),(j=j===void 0?ee:~~j)<0?(j+=ee)<0&&(j=0):j>ee&&(j=ee),j<y&&(j=y),u.TYPED_ARRAY_SUPPORT)(W=this.subarray(y,j)).__proto__=u.prototype;else{var X=j-y;W=new u(X,void 0);for(var ne=0;ne<X;++ne)W[ne]=this[ne+y]}return W},u.prototype.readUIntLE=function(y,j,W){y|=0,j|=0,W||O(y,j,this.length);for(var ee=this[y],X=1,ne=0;++ne<j&&(X*=256);)ee+=this[y+ne]*X;return ee},u.prototype.readUIntBE=function(y,j,W){y|=0,j|=0,W||O(y,j,this.length);for(var ee=this[y+--j],X=1;j>0&&(X*=256);)ee+=this[y+--j]*X;return ee},u.prototype.readUInt8=function(y,j){return j||O(y,1,this.length),this[y]},u.prototype.readUInt16LE=function(y,j){return j||O(y,2,this.length),this[y]|this[y+1]<<8},u.prototype.readUInt16BE=function(y,j){return j||O(y,2,this.length),this[y]<<8|this[y+1]},u.prototype.readUInt32LE=function(y,j){return j||O(y,4,this.length),(this[y]|this[y+1]<<8|this[y+2]<<16)+16777216*this[y+3]},u.prototype.readUInt32BE=function(y,j){return j||O(y,4,this.length),16777216*this[y]+(this[y+1]<<16|this[y+2]<<8|this[y+3])},u.prototype.readIntLE=function(y,j,W){y|=0,j|=0,W||O(y,j,this.length);for(var ee=this[y],X=1,ne=0;++ne<j&&(X*=256);)ee+=this[y+ne]*X;return ee>=(X*=128)&&(ee-=Math.pow(2,8*j)),ee},u.prototype.readIntBE=function(y,j,W){y|=0,j|=0,W||O(y,j,this.length);for(var ee=j,X=1,ne=this[y+--ee];ee>0&&(X*=256);)ne+=this[y+--ee]*X;return ne>=(X*=128)&&(ne-=Math.pow(2,8*j)),ne},u.prototype.readInt8=function(y,j){return j||O(y,1,this.length),128&this[y]?-1*(255-this[y]+1):this[y]},u.prototype.readInt16LE=function(y,j){j||O(y,2,this.length);var W=this[y]|this[y+1]<<8;return 32768&W?4294901760|W:W},u.prototype.readInt16BE=function(y,j){j||O(y,2,this.length);var W=this[y+1]|this[y]<<8;return 32768&W?4294901760|W:W},u.prototype.readInt32LE=function(y,j){return j||O(y,4,this.length),this[y]|this[y+1]<<8|this[y+2]<<16|this[y+3]<<24},u.prototype.readInt32BE=function(y,j){return j||O(y,4,this.length),this[y]<<24|this[y+1]<<16|this[y+2]<<8|this[y+3]},u.prototype.readFloatLE=function(y,j){return j||O(y,4,this.length),l.read(this,y,!0,23,4)},u.prototype.readFloatBE=function(y,j){return j||O(y,4,this.length),l.read(this,y,!1,23,4)},u.prototype.readDoubleLE=function(y,j){return j||O(y,8,this.length),l.read(this,y,!0,52,8)},u.prototype.readDoubleBE=function(y,j){return j||O(y,8,this.length),l.read(this,y,!1,52,8)},u.prototype.writeUIntLE=function(y,j,W,ee){y=+y,j|=0,W|=0,ee||L(this,y,j,W,Math.pow(2,8*W)-1,0);var X=1,ne=0;for(this[j]=255&y;++ne<W&&(X*=256);)this[j+ne]=y/X&255;return j+W},u.prototype.writeUIntBE=function(y,j,W,ee){y=+y,j|=0,W|=0,ee||L(this,y,j,W,Math.pow(2,8*W)-1,0);var X=W-1,ne=1;for(this[j+X]=255&y;--X>=0&&(ne*=256);)this[j+X]=y/ne&255;return j+W},u.prototype.writeUInt8=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,1,255,0),u.TYPED_ARRAY_SUPPORT||(y=Math.floor(y)),this[j]=255&y,j+1},u.prototype.writeUInt16LE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[j]=255&y,this[j+1]=y>>>8):k(this,y,j,!0),j+2},u.prototype.writeUInt16BE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[j]=y>>>8,this[j+1]=255&y):k(this,y,j,!1),j+2},u.prototype.writeUInt32LE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[j+3]=y>>>24,this[j+2]=y>>>16,this[j+1]=y>>>8,this[j]=255&y):E(this,y,j,!0),j+4},u.prototype.writeUInt32BE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[j]=y>>>24,this[j+1]=y>>>16,this[j+2]=y>>>8,this[j+3]=255&y):E(this,y,j,!1),j+4},u.prototype.writeIntLE=function(y,j,W,ee){if(y=+y,j|=0,!ee){var X=Math.pow(2,8*W-1);L(this,y,j,W,X-1,-X)}var ne=0,ie=1,he=0;for(this[j]=255&y;++ne<W&&(ie*=256);)y<0&&he===0&&this[j+ne-1]!==0&&(he=1),this[j+ne]=(y/ie>>0)-he&255;return j+W},u.prototype.writeIntBE=function(y,j,W,ee){if(y=+y,j|=0,!ee){var X=Math.pow(2,8*W-1);L(this,y,j,W,X-1,-X)}var ne=W-1,ie=1,he=0;for(this[j+ne]=255&y;--ne>=0&&(ie*=256);)y<0&&he===0&&this[j+ne+1]!==0&&(he=1),this[j+ne]=(y/ie>>0)-he&255;return j+W},u.prototype.writeInt8=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,1,127,-128),u.TYPED_ARRAY_SUPPORT||(y=Math.floor(y)),y<0&&(y=255+y+1),this[j]=255&y,j+1},u.prototype.writeInt16LE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[j]=255&y,this[j+1]=y>>>8):k(this,y,j,!0),j+2},u.prototype.writeInt16BE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[j]=y>>>8,this[j+1]=255&y):k(this,y,j,!1),j+2},u.prototype.writeInt32LE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[j]=255&y,this[j+1]=y>>>8,this[j+2]=y>>>16,this[j+3]=y>>>24):E(this,y,j,!0),j+4},u.prototype.writeInt32BE=function(y,j,W){return y=+y,j|=0,W||L(this,y,j,4,2147483647,-2147483648),y<0&&(y=4294967295+y+1),u.TYPED_ARRAY_SUPPORT?(this[j]=y>>>24,this[j+1]=y>>>16,this[j+2]=y>>>8,this[j+3]=255&y):E(this,y,j,!1),j+4},u.prototype.writeFloatLE=function(y,j,W){return U(this,y,j,!0,W)},u.prototype.writeFloatBE=function(y,j,W){return U(this,y,j,!1,W)},u.prototype.writeDoubleLE=function(y,j,W){return B(this,y,j,!0,W)},u.prototype.writeDoubleBE=function(y,j,W){return B(this,y,j,!1,W)},u.prototype.copy=function(y,j,W,ee){if(W||(W=0),ee||ee===0||(ee=this.length),j>=y.length&&(j=y.length),j||(j=0),ee>0&&ee<W&&(ee=W),ee===W||y.length===0||this.length===0)return 0;if(j<0)throw new RangeError("targetStart out of bounds");if(W<0||W>=this.length)throw new RangeError("sourceStart out of bounds");if(ee<0)throw new RangeError("sourceEnd out of bounds");ee>this.length&&(ee=this.length),y.length-j<ee-W&&(ee=y.length-j+W);var X,ne=ee-W;if(this===y&&W<j&&j<ee)for(X=ne-1;X>=0;--X)y[X+j]=this[X+W];else if(ne<1e3||!u.TYPED_ARRAY_SUPPORT)for(X=0;X<ne;++X)y[X+j]=this[X+W];else Uint8Array.prototype.set.call(y,this.subarray(W,W+ne),j);return ne},u.prototype.fill=function(y,j,W,ee){if(typeof y=="string"){if(typeof j=="string"?(ee=j,j=0,W=this.length):typeof W=="string"&&(ee=W,W=this.length),y.length===1){var X=y.charCodeAt(0);X<256&&(y=X)}if(ee!==void 0&&typeof ee!="string")throw new TypeError("encoding must be a string");if(typeof ee=="string"&&!u.isEncoding(ee))throw new TypeError("Unknown encoding: "+ee)}else typeof y=="number"&&(y&=255);if(j<0||this.length<j||this.length<W)throw new RangeError("Out of range index");if(W<=j)return this;var ne;if(j>>>=0,W=W===void 0?this.length:W>>>0,y||(y=0),typeof y=="number")for(ne=j;ne<W;++ne)this[ne]=y;else{var ie=u.isBuffer(y)?y:K(new u(y,ee).toString()),he=ie.length;for(ne=0;ne<W-j;++ne)this[ne+j]=ie[ne%he]}return this};var G=/[^+\/0-9A-Za-z-_]/g;function Y(y){return y<16?"0"+y.toString(16):y.toString(16)}function K(y,j){var W;j=j||1/0;for(var ee=y.length,X=null,ne=[],ie=0;ie<ee;++ie){if((W=y.charCodeAt(ie))>55295&&W<57344){if(!X){if(W>56319){(j-=3)>-1&&ne.push(239,191,189);continue}if(ie+1===ee){(j-=3)>-1&&ne.push(239,191,189);continue}X=W;continue}if(W<56320){(j-=3)>-1&&ne.push(239,191,189),X=W;continue}W=65536+(X-55296<<10|W-56320)}else X&&(j-=3)>-1&&ne.push(239,191,189);if(X=null,W<128){if((j-=1)<0)break;ne.push(W)}else if(W<2048){if((j-=2)<0)break;ne.push(W>>6|192,63&W|128)}else if(W<65536){if((j-=3)<0)break;ne.push(W>>12|224,W>>6&63|128,63&W|128)}else{if(!(W<1114112))throw new Error("Invalid code point");if((j-=4)<0)break;ne.push(W>>18|240,W>>12&63|128,W>>6&63|128,63&W|128)}}return ne}function H(y){return o.toByteArray(function(j){if((j=function(W){return W.trim?W.trim():W.replace(/^\s+|\s+$/g,"")}(j).replace(G,"")).length<2)return"";for(;j.length%4!=0;)j+="=";return j}(y))}function V(y,j,W,ee){for(var X=0;X<ee&&!(X+W>=j.length||X>=y.length);++X)j[X+W]=y[X];return X}}).call(this,r(5))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch{typeof window=="object"&&(r=window)}e.exports=r},function(e,t,r){(function(n){r.d(t,"a",function(){return s}),r.d(t,"i",function(){return i}),r.d(t,"j",function(){return c}),r.d(t,"b",function(){return u}),r.d(t,"f",function(){return b}),r.d(t,"e",function(){return A}),r.d(t,"g",function(){return _}),r.d(t,"d",function(){return v}),r.d(t,"c",function(){return f}),r.d(t,"h",function(){return S});var o=r(98);const l=o.from(Object.assign(Object.assign({},n.env),{ENVIRONMENT:n.env.ENV,APP:"realtime-sdk",NAMESPACE:"production",VERSION:n.env.VERSION,BUILD_TAG:n.env.BUILD_TAG,GIT_COMMIT:n.env.GIT_COMMIT,LOG_LEVEL:n.env.LOG_LEVEL,LOG_JSON:"false",LOG_API_ENDPOINT:n.env.LOG_API_ENDPOINT,JEST_WORKER_ID:n.env.JEST_WORKER_ID,ENABLE_SENTRY:n.env.ENABLE_SENTRY,SENTRY_DSN:n.env.SENTRY_DSN,STABLE_AGENT_VERSION:n.env.STABLE_AGENT_VERSION})),s=(l.get("ENVIRONMENT").default("").asString(),l.get("APP").default("").asString()),i=(l.get("APP_PATH").default("").asString(),l.get("API_ENDPOINT").default("").asString(),l.get("NAMESPACE").default("").asString()),c=l.get("VERSION").default("").asString(),u=l.get("BUILD_TAG").default("").asString(),b=(l.get("GIT_COMMIT").default("").asString(),l.get("ENABLE_SENTRY").default("false").asBool(),l.get("SENTRY_DSN").default("").asString(),l.get("LOG_LEVEL").default("debug").asString()),A=l.get("LOG_JSON").default("true").asBool(),_=l.get("LOG_TO_CONSOLE").default("true").asBool(),v=(l.get("STABLE_AGENT_VERSION").default("").asString(),l.get("LOG_API_ENDPOINT").asString()),f=l.get("JEST_WORKER_ID").asString(),S=(l.get("SHEET_EXPORT_MAX_ROW_COUNT").default("10000").asIntPositive(),l.get("LOG_TO_FILE").default("false").asBoolStrict())}).call(this,r(2))},function(e,t){typeof Object.create=="function"?e.exports=function(r,n){n&&(r.super_=n,r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(r,n){if(n){r.super_=n;var o=function(){};o.prototype=n.prototype,r.prototype=new o,r.prototype.constructor=r}}},function(e,t,r){var n=r(95),o=n,l=Function("return this")(),s=r(94);o.object.extend(proto,s),o.exportSymbol("proto.v1.signaling.api.CreatePeerRequest",null,l),o.exportSymbol("proto.v1.signaling.api.CreatePeerResponse",null,l),o.exportSymbol("proto.v1.signaling.api.DeletePeerRequest",null,l),o.exportSymbol("proto.v1.signaling.api.DeletePeerResponse",null,l),o.exportSymbol("proto.v1.signaling.api.GetIceServersRequest",null,l),o.exportSymbol("proto.v1.signaling.api.GetIceServersResponse",null,l),o.exportSymbol("proto.v1.signaling.api.GetPeersRequest",null,l),o.exportSymbol("proto.v1.signaling.api.GetPeersResponse",null,l),o.exportSymbol("proto.v1.signaling.api.Peer",null,l),o.exportSymbol("proto.v1.signaling.api.ReceiveSignalStreamRequest",null,l),o.exportSymbol("proto.v1.signaling.api.ReceiveSignalStreamResponse",null,l),o.exportSymbol("proto.v1.signaling.api.RefreshPeerRequest",null,l),o.exportSymbol("proto.v1.signaling.api.RefreshPeerResponse",null,l),o.exportSymbol("proto.v1.signaling.api.SendSignalRequest",null,l),o.exportSymbol("proto.v1.signaling.api.SendSignalResponse",null,l),o.exportSymbol("proto.v1.signaling.api.SessionType",null,l),o.exportSymbol("proto.v1.signaling.api.Signal",null,l),proto.v1.signaling.api.Peer=function(i){n.Message.initialize(this,i,0,-1,proto.v1.signaling.api.Peer.repeatedFields_,null)},o.inherits(proto.v1.signaling.api.Peer,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.Peer.displayName="proto.v1.signaling.api.Peer"),proto.v1.signaling.api.Signal=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.Signal,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.Signal.displayName="proto.v1.signaling.api.Signal"),proto.v1.signaling.api.CreatePeerRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.CreatePeerRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.CreatePeerRequest.displayName="proto.v1.signaling.api.CreatePeerRequest"),proto.v1.signaling.api.CreatePeerResponse=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.CreatePeerResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.CreatePeerResponse.displayName="proto.v1.signaling.api.CreatePeerResponse"),proto.v1.signaling.api.DeletePeerRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.DeletePeerRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.DeletePeerRequest.displayName="proto.v1.signaling.api.DeletePeerRequest"),proto.v1.signaling.api.DeletePeerResponse=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.DeletePeerResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.DeletePeerResponse.displayName="proto.v1.signaling.api.DeletePeerResponse"),proto.v1.signaling.api.RefreshPeerRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.RefreshPeerRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.RefreshPeerRequest.displayName="proto.v1.signaling.api.RefreshPeerRequest"),proto.v1.signaling.api.RefreshPeerResponse=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.RefreshPeerResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.RefreshPeerResponse.displayName="proto.v1.signaling.api.RefreshPeerResponse"),proto.v1.signaling.api.GetPeersRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.GetPeersRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetPeersRequest.displayName="proto.v1.signaling.api.GetPeersRequest"),proto.v1.signaling.api.GetPeersResponse=function(i){n.Message.initialize(this,i,0,-1,proto.v1.signaling.api.GetPeersResponse.repeatedFields_,null)},o.inherits(proto.v1.signaling.api.GetPeersResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetPeersResponse.displayName="proto.v1.signaling.api.GetPeersResponse"),proto.v1.signaling.api.GetIceServersRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.GetIceServersRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetIceServersRequest.displayName="proto.v1.signaling.api.GetIceServersRequest"),proto.v1.signaling.api.GetIceServersResponse=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.GetIceServersResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.GetIceServersResponse.displayName="proto.v1.signaling.api.GetIceServersResponse"),proto.v1.signaling.api.SendSignalRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.SendSignalRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.SendSignalRequest.displayName="proto.v1.signaling.api.SendSignalRequest"),proto.v1.signaling.api.SendSignalResponse=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.SendSignalResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.SendSignalResponse.displayName="proto.v1.signaling.api.SendSignalResponse"),proto.v1.signaling.api.ReceiveSignalStreamRequest=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.ReceiveSignalStreamRequest,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.ReceiveSignalStreamRequest.displayName="proto.v1.signaling.api.ReceiveSignalStreamRequest"),proto.v1.signaling.api.ReceiveSignalStreamResponse=function(i){n.Message.initialize(this,i,0,-1,null,null)},o.inherits(proto.v1.signaling.api.ReceiveSignalStreamResponse,n.Message),o.DEBUG&&!COMPILED&&(proto.v1.signaling.api.ReceiveSignalStreamResponse.displayName="proto.v1.signaling.api.ReceiveSignalStreamResponse"),proto.v1.signaling.api.Peer.repeatedFields_=[5],n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.Peer.prototype.toObject=function(i){return proto.v1.signaling.api.Peer.toObject(i,this)},proto.v1.signaling.api.Peer.toObject=function(i,c){var u,b={peerId:n.Message.getFieldWithDefault(c,1,""),organizationId:n.Message.getFieldWithDefault(c,2,""),userId:(u=c.getUserId())&&s.StringValue.toObject(i,u),deviceId:(u=c.getDeviceId())&&s.StringValue.toObject(i,u),sessionIdsList:(u=n.Message.getRepeatedField(c,5))==null?void 0:u,peerCreatedTimestamp:(u=c.getPeerCreatedTimestamp())&&s.Int64Value.toObject(i,u)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.Peer.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.Peer;return proto.v1.signaling.api.Peer.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.Peer.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();i.setPeerId(u);break;case 2:u=c.readString(),i.setOrganizationId(u);break;case 3:u=new s.StringValue,c.readMessage(u,s.StringValue.deserializeBinaryFromReader),i.setUserId(u);break;case 4:u=new s.StringValue,c.readMessage(u,s.StringValue.deserializeBinaryFromReader),i.setDeviceId(u);break;case 5:u=c.readString(),i.addSessionIds(u);break;case 6:u=new s.Int64Value,c.readMessage(u,s.Int64Value.deserializeBinaryFromReader),i.setPeerCreatedTimestamp(u);break;default:c.skipField()}return i},proto.v1.signaling.api.Peer.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.Peer.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.Peer.serializeBinaryToWriter=function(i,c){var u=void 0;(u=i.getPeerId()).length>0&&c.writeString(1,u),(u=i.getOrganizationId()).length>0&&c.writeString(2,u),(u=i.getUserId())!=null&&c.writeMessage(3,u,s.StringValue.serializeBinaryToWriter),(u=i.getDeviceId())!=null&&c.writeMessage(4,u,s.StringValue.serializeBinaryToWriter),(u=i.getSessionIdsList()).length>0&&c.writeRepeatedString(5,u),(u=i.getPeerCreatedTimestamp())!=null&&c.writeMessage(6,u,s.Int64Value.serializeBinaryToWriter)},proto.v1.signaling.api.Peer.prototype.getPeerId=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.Peer.prototype.setPeerId=function(i){return n.Message.setProto3StringField(this,1,i)},proto.v1.signaling.api.Peer.prototype.getOrganizationId=function(){return n.Message.getFieldWithDefault(this,2,"")},proto.v1.signaling.api.Peer.prototype.setOrganizationId=function(i){return n.Message.setProto3StringField(this,2,i)},proto.v1.signaling.api.Peer.prototype.getUserId=function(){return n.Message.getWrapperField(this,s.StringValue,3)},proto.v1.signaling.api.Peer.prototype.setUserId=function(i){return n.Message.setWrapperField(this,3,i)},proto.v1.signaling.api.Peer.prototype.clearUserId=function(){return this.setUserId(void 0)},proto.v1.signaling.api.Peer.prototype.hasUserId=function(){return n.Message.getField(this,3)!=null},proto.v1.signaling.api.Peer.prototype.getDeviceId=function(){return n.Message.getWrapperField(this,s.StringValue,4)},proto.v1.signaling.api.Peer.prototype.setDeviceId=function(i){return n.Message.setWrapperField(this,4,i)},proto.v1.signaling.api.Peer.prototype.clearDeviceId=function(){return this.setDeviceId(void 0)},proto.v1.signaling.api.Peer.prototype.hasDeviceId=function(){return n.Message.getField(this,4)!=null},proto.v1.signaling.api.Peer.prototype.getSessionIdsList=function(){return n.Message.getRepeatedField(this,5)},proto.v1.signaling.api.Peer.prototype.setSessionIdsList=function(i){return n.Message.setField(this,5,i||[])},proto.v1.signaling.api.Peer.prototype.addSessionIds=function(i,c){return n.Message.addToRepeatedField(this,5,i,c)},proto.v1.signaling.api.Peer.prototype.clearSessionIdsList=function(){return this.setSessionIdsList([])},proto.v1.signaling.api.Peer.prototype.getPeerCreatedTimestamp=function(){return n.Message.getWrapperField(this,s.Int64Value,6)},proto.v1.signaling.api.Peer.prototype.setPeerCreatedTimestamp=function(i){return n.Message.setWrapperField(this,6,i)},proto.v1.signaling.api.Peer.prototype.clearPeerCreatedTimestamp=function(){return this.setPeerCreatedTimestamp(void 0)},proto.v1.signaling.api.Peer.prototype.hasPeerCreatedTimestamp=function(){return n.Message.getField(this,6)!=null},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.Signal.prototype.toObject=function(i){return proto.v1.signaling.api.Signal.toObject(i,this)},proto.v1.signaling.api.Signal.toObject=function(i,c){var u,b={sessionId:(u=c.getSessionId())&&s.StringValue.toObject(i,u),sessionCreatedTimestamp:(u=c.getSessionCreatedTimestamp())&&s.Int64Value.toObject(i,u),senderId:n.Message.getFieldWithDefault(c,3,""),receiverId:n.Message.getFieldWithDefault(c,4,""),payload:n.Message.getFieldWithDefault(c,5,""),iceServers:n.Message.getFieldWithDefault(c,6,""),iceTransportPolicy:n.Message.getFieldWithDefault(c,7,""),sessionType:n.Message.getFieldWithDefault(c,8,0)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.Signal.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.Signal;return proto.v1.signaling.api.Signal.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.Signal.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new s.StringValue;c.readMessage(u,s.StringValue.deserializeBinaryFromReader),i.setSessionId(u);break;case 2:u=new s.Int64Value,c.readMessage(u,s.Int64Value.deserializeBinaryFromReader),i.setSessionCreatedTimestamp(u);break;case 3:u=c.readString(),i.setSenderId(u);break;case 4:u=c.readString(),i.setReceiverId(u);break;case 5:u=c.readString(),i.setPayload(u);break;case 6:u=c.readString(),i.setIceServers(u);break;case 7:u=c.readString(),i.setIceTransportPolicy(u);break;case 8:u=c.readEnum(),i.setSessionType(u);break;default:c.skipField()}return i},proto.v1.signaling.api.Signal.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.Signal.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.Signal.serializeBinaryToWriter=function(i,c){var u=void 0;(u=i.getSessionId())!=null&&c.writeMessage(1,u,s.StringValue.serializeBinaryToWriter),(u=i.getSessionCreatedTimestamp())!=null&&c.writeMessage(2,u,s.Int64Value.serializeBinaryToWriter),(u=i.getSenderId()).length>0&&c.writeString(3,u),(u=i.getReceiverId()).length>0&&c.writeString(4,u),(u=i.getPayload()).length>0&&c.writeString(5,u),(u=i.getIceServers()).length>0&&c.writeString(6,u),(u=i.getIceTransportPolicy()).length>0&&c.writeString(7,u),(u=i.getSessionType())!==0&&c.writeEnum(8,u)},proto.v1.signaling.api.Signal.prototype.getSessionId=function(){return n.Message.getWrapperField(this,s.StringValue,1)},proto.v1.signaling.api.Signal.prototype.setSessionId=function(i){return n.Message.setWrapperField(this,1,i)},proto.v1.signaling.api.Signal.prototype.clearSessionId=function(){return this.setSessionId(void 0)},proto.v1.signaling.api.Signal.prototype.hasSessionId=function(){return n.Message.getField(this,1)!=null},proto.v1.signaling.api.Signal.prototype.getSessionCreatedTimestamp=function(){return n.Message.getWrapperField(this,s.Int64Value,2)},proto.v1.signaling.api.Signal.prototype.setSessionCreatedTimestamp=function(i){return n.Message.setWrapperField(this,2,i)},proto.v1.signaling.api.Signal.prototype.clearSessionCreatedTimestamp=function(){return this.setSessionCreatedTimestamp(void 0)},proto.v1.signaling.api.Signal.prototype.hasSessionCreatedTimestamp=function(){return n.Message.getField(this,2)!=null},proto.v1.signaling.api.Signal.prototype.getSenderId=function(){return n.Message.getFieldWithDefault(this,3,"")},proto.v1.signaling.api.Signal.prototype.setSenderId=function(i){return n.Message.setProto3StringField(this,3,i)},proto.v1.signaling.api.Signal.prototype.getReceiverId=function(){return n.Message.getFieldWithDefault(this,4,"")},proto.v1.signaling.api.Signal.prototype.setReceiverId=function(i){return n.Message.setProto3StringField(this,4,i)},proto.v1.signaling.api.Signal.prototype.getPayload=function(){return n.Message.getFieldWithDefault(this,5,"")},proto.v1.signaling.api.Signal.prototype.setPayload=function(i){return n.Message.setProto3StringField(this,5,i)},proto.v1.signaling.api.Signal.prototype.getIceServers=function(){return n.Message.getFieldWithDefault(this,6,"")},proto.v1.signaling.api.Signal.prototype.setIceServers=function(i){return n.Message.setProto3StringField(this,6,i)},proto.v1.signaling.api.Signal.prototype.getIceTransportPolicy=function(){return n.Message.getFieldWithDefault(this,7,"")},proto.v1.signaling.api.Signal.prototype.setIceTransportPolicy=function(i){return n.Message.setProto3StringField(this,7,i)},proto.v1.signaling.api.Signal.prototype.getSessionType=function(){return n.Message.getFieldWithDefault(this,8,0)},proto.v1.signaling.api.Signal.prototype.setSessionType=function(i){return n.Message.setProto3EnumField(this,8,i)},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.CreatePeerRequest.prototype.toObject=function(i){return proto.v1.signaling.api.CreatePeerRequest.toObject(i,this)},proto.v1.signaling.api.CreatePeerRequest.toObject=function(i,c){var u={};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.CreatePeerRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.CreatePeerRequest;return proto.v1.signaling.api.CreatePeerRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.CreatePeerRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return i},proto.v1.signaling.api.CreatePeerRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.CreatePeerRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.CreatePeerRequest.serializeBinaryToWriter=function(i,c){},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.CreatePeerResponse.prototype.toObject=function(i){return proto.v1.signaling.api.CreatePeerResponse.toObject(i,this)},proto.v1.signaling.api.CreatePeerResponse.toObject=function(i,c){var u,b={peer:(u=c.getPeer())&&proto.v1.signaling.api.Peer.toObject(i,u)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.CreatePeerResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.CreatePeerResponse;return proto.v1.signaling.api.CreatePeerResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.CreatePeerResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Peer;c.readMessage(u,proto.v1.signaling.api.Peer.deserializeBinaryFromReader),i.setPeer(u);break;default:c.skipField()}return i},proto.v1.signaling.api.CreatePeerResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.CreatePeerResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.CreatePeerResponse.serializeBinaryToWriter=function(i,c){var u;(u=i.getPeer())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Peer.serializeBinaryToWriter)},proto.v1.signaling.api.CreatePeerResponse.prototype.getPeer=function(){return n.Message.getWrapperField(this,proto.v1.signaling.api.Peer,1)},proto.v1.signaling.api.CreatePeerResponse.prototype.setPeer=function(i){return n.Message.setWrapperField(this,1,i)},proto.v1.signaling.api.CreatePeerResponse.prototype.clearPeer=function(){return this.setPeer(void 0)},proto.v1.signaling.api.CreatePeerResponse.prototype.hasPeer=function(){return n.Message.getField(this,1)!=null},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.DeletePeerRequest.prototype.toObject=function(i){return proto.v1.signaling.api.DeletePeerRequest.toObject(i,this)},proto.v1.signaling.api.DeletePeerRequest.toObject=function(i,c){var u={peerId:n.Message.getFieldWithDefault(c,1,"")};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.DeletePeerRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.DeletePeerRequest;return proto.v1.signaling.api.DeletePeerRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.DeletePeerRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();i.setPeerId(u);break;default:c.skipField()}return i},proto.v1.signaling.api.DeletePeerRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.DeletePeerRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.DeletePeerRequest.serializeBinaryToWriter=function(i,c){var u;(u=i.getPeerId()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.DeletePeerRequest.prototype.getPeerId=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.DeletePeerRequest.prototype.setPeerId=function(i){return n.Message.setProto3StringField(this,1,i)},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.DeletePeerResponse.prototype.toObject=function(i){return proto.v1.signaling.api.DeletePeerResponse.toObject(i,this)},proto.v1.signaling.api.DeletePeerResponse.toObject=function(i,c){var u={};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.DeletePeerResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.DeletePeerResponse;return proto.v1.signaling.api.DeletePeerResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.DeletePeerResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return i},proto.v1.signaling.api.DeletePeerResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.DeletePeerResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.DeletePeerResponse.serializeBinaryToWriter=function(i,c){},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.RefreshPeerRequest.prototype.toObject=function(i){return proto.v1.signaling.api.RefreshPeerRequest.toObject(i,this)},proto.v1.signaling.api.RefreshPeerRequest.toObject=function(i,c){var u,b={peer:(u=c.getPeer())&&proto.v1.signaling.api.Peer.toObject(i,u)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.RefreshPeerRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.RefreshPeerRequest;return proto.v1.signaling.api.RefreshPeerRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.RefreshPeerRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Peer;c.readMessage(u,proto.v1.signaling.api.Peer.deserializeBinaryFromReader),i.setPeer(u);break;default:c.skipField()}return i},proto.v1.signaling.api.RefreshPeerRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.RefreshPeerRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.RefreshPeerRequest.serializeBinaryToWriter=function(i,c){var u;(u=i.getPeer())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Peer.serializeBinaryToWriter)},proto.v1.signaling.api.RefreshPeerRequest.prototype.getPeer=function(){return n.Message.getWrapperField(this,proto.v1.signaling.api.Peer,1)},proto.v1.signaling.api.RefreshPeerRequest.prototype.setPeer=function(i){return n.Message.setWrapperField(this,1,i)},proto.v1.signaling.api.RefreshPeerRequest.prototype.clearPeer=function(){return this.setPeer(void 0)},proto.v1.signaling.api.RefreshPeerRequest.prototype.hasPeer=function(){return n.Message.getField(this,1)!=null},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.RefreshPeerResponse.prototype.toObject=function(i){return proto.v1.signaling.api.RefreshPeerResponse.toObject(i,this)},proto.v1.signaling.api.RefreshPeerResponse.toObject=function(i,c){var u={};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.RefreshPeerResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.RefreshPeerResponse;return proto.v1.signaling.api.RefreshPeerResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.RefreshPeerResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return i},proto.v1.signaling.api.RefreshPeerResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.RefreshPeerResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.RefreshPeerResponse.serializeBinaryToWriter=function(i,c){},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetPeersRequest.prototype.toObject=function(i){return proto.v1.signaling.api.GetPeersRequest.toObject(i,this)},proto.v1.signaling.api.GetPeersRequest.toObject=function(i,c){var u={};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetPeersRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.GetPeersRequest;return proto.v1.signaling.api.GetPeersRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetPeersRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return i},proto.v1.signaling.api.GetPeersRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.GetPeersRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.GetPeersRequest.serializeBinaryToWriter=function(i,c){},proto.v1.signaling.api.GetPeersResponse.repeatedFields_=[1],n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetPeersResponse.prototype.toObject=function(i){return proto.v1.signaling.api.GetPeersResponse.toObject(i,this)},proto.v1.signaling.api.GetPeersResponse.toObject=function(i,c){var u={peersList:n.Message.toObjectList(c.getPeersList(),proto.v1.signaling.api.Peer.toObject,i)};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetPeersResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.GetPeersResponse;return proto.v1.signaling.api.GetPeersResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetPeersResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Peer;c.readMessage(u,proto.v1.signaling.api.Peer.deserializeBinaryFromReader),i.addPeers(u);break;default:c.skipField()}return i},proto.v1.signaling.api.GetPeersResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.GetPeersResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.GetPeersResponse.serializeBinaryToWriter=function(i,c){var u;(u=i.getPeersList()).length>0&&c.writeRepeatedMessage(1,u,proto.v1.signaling.api.Peer.serializeBinaryToWriter)},proto.v1.signaling.api.GetPeersResponse.prototype.getPeersList=function(){return n.Message.getRepeatedWrapperField(this,proto.v1.signaling.api.Peer,1)},proto.v1.signaling.api.GetPeersResponse.prototype.setPeersList=function(i){return n.Message.setRepeatedWrapperField(this,1,i)},proto.v1.signaling.api.GetPeersResponse.prototype.addPeers=function(i,c){return n.Message.addToRepeatedWrapperField(this,1,i,proto.v1.signaling.api.Peer,c)},proto.v1.signaling.api.GetPeersResponse.prototype.clearPeersList=function(){return this.setPeersList([])},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetIceServersRequest.prototype.toObject=function(i){return proto.v1.signaling.api.GetIceServersRequest.toObject(i,this)},proto.v1.signaling.api.GetIceServersRequest.toObject=function(i,c){var u={};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetIceServersRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.GetIceServersRequest;return proto.v1.signaling.api.GetIceServersRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetIceServersRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)c.getFieldNumber(),c.skipField();return i},proto.v1.signaling.api.GetIceServersRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.GetIceServersRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.GetIceServersRequest.serializeBinaryToWriter=function(i,c){},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.GetIceServersResponse.prototype.toObject=function(i){return proto.v1.signaling.api.GetIceServersResponse.toObject(i,this)},proto.v1.signaling.api.GetIceServersResponse.toObject=function(i,c){var u={iceServers:n.Message.getFieldWithDefault(c,1,"")};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.GetIceServersResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.GetIceServersResponse;return proto.v1.signaling.api.GetIceServersResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.GetIceServersResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();i.setIceServers(u);break;default:c.skipField()}return i},proto.v1.signaling.api.GetIceServersResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.GetIceServersResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.GetIceServersResponse.serializeBinaryToWriter=function(i,c){var u;(u=i.getIceServers()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.GetIceServersResponse.prototype.getIceServers=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.GetIceServersResponse.prototype.setIceServers=function(i){return n.Message.setProto3StringField(this,1,i)},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.SendSignalRequest.prototype.toObject=function(i){return proto.v1.signaling.api.SendSignalRequest.toObject(i,this)},proto.v1.signaling.api.SendSignalRequest.toObject=function(i,c){var u,b={signal:(u=c.getSignal())&&proto.v1.signaling.api.Signal.toObject(i,u)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.SendSignalRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.SendSignalRequest;return proto.v1.signaling.api.SendSignalRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.SendSignalRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Signal;c.readMessage(u,proto.v1.signaling.api.Signal.deserializeBinaryFromReader),i.setSignal(u);break;default:c.skipField()}return i},proto.v1.signaling.api.SendSignalRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.SendSignalRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.SendSignalRequest.serializeBinaryToWriter=function(i,c){var u;(u=i.getSignal())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Signal.serializeBinaryToWriter)},proto.v1.signaling.api.SendSignalRequest.prototype.getSignal=function(){return n.Message.getWrapperField(this,proto.v1.signaling.api.Signal,1)},proto.v1.signaling.api.SendSignalRequest.prototype.setSignal=function(i){return n.Message.setWrapperField(this,1,i)},proto.v1.signaling.api.SendSignalRequest.prototype.clearSignal=function(){return this.setSignal(void 0)},proto.v1.signaling.api.SendSignalRequest.prototype.hasSignal=function(){return n.Message.getField(this,1)!=null},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.SendSignalResponse.prototype.toObject=function(i){return proto.v1.signaling.api.SendSignalResponse.toObject(i,this)},proto.v1.signaling.api.SendSignalResponse.toObject=function(i,c){var u,b={sessionId:(u=c.getSessionId())&&s.StringValue.toObject(i,u),sessionCreatedTimestamp:(u=c.getSessionCreatedTimestamp())&&s.Int64Value.toObject(i,u)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.SendSignalResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.SendSignalResponse;return proto.v1.signaling.api.SendSignalResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.SendSignalResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new s.StringValue;c.readMessage(u,s.StringValue.deserializeBinaryFromReader),i.setSessionId(u);break;case 2:u=new s.Int64Value,c.readMessage(u,s.Int64Value.deserializeBinaryFromReader),i.setSessionCreatedTimestamp(u);break;default:c.skipField()}return i},proto.v1.signaling.api.SendSignalResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.SendSignalResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.SendSignalResponse.serializeBinaryToWriter=function(i,c){var u=void 0;(u=i.getSessionId())!=null&&c.writeMessage(1,u,s.StringValue.serializeBinaryToWriter),(u=i.getSessionCreatedTimestamp())!=null&&c.writeMessage(2,u,s.Int64Value.serializeBinaryToWriter)},proto.v1.signaling.api.SendSignalResponse.prototype.getSessionId=function(){return n.Message.getWrapperField(this,s.StringValue,1)},proto.v1.signaling.api.SendSignalResponse.prototype.setSessionId=function(i){return n.Message.setWrapperField(this,1,i)},proto.v1.signaling.api.SendSignalResponse.prototype.clearSessionId=function(){return this.setSessionId(void 0)},proto.v1.signaling.api.SendSignalResponse.prototype.hasSessionId=function(){return n.Message.getField(this,1)!=null},proto.v1.signaling.api.SendSignalResponse.prototype.getSessionCreatedTimestamp=function(){return n.Message.getWrapperField(this,s.Int64Value,2)},proto.v1.signaling.api.SendSignalResponse.prototype.setSessionCreatedTimestamp=function(i){return n.Message.setWrapperField(this,2,i)},proto.v1.signaling.api.SendSignalResponse.prototype.clearSessionCreatedTimestamp=function(){return this.setSessionCreatedTimestamp(void 0)},proto.v1.signaling.api.SendSignalResponse.prototype.hasSessionCreatedTimestamp=function(){return n.Message.getField(this,2)!=null},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.toObject=function(i){return proto.v1.signaling.api.ReceiveSignalStreamRequest.toObject(i,this)},proto.v1.signaling.api.ReceiveSignalStreamRequest.toObject=function(i,c){var u={peerId:n.Message.getFieldWithDefault(c,1,"")};return i&&(u.$jspbMessageInstance=c),u}),proto.v1.signaling.api.ReceiveSignalStreamRequest.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.ReceiveSignalStreamRequest;return proto.v1.signaling.api.ReceiveSignalStreamRequest.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.ReceiveSignalStreamRequest.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=c.readString();i.setPeerId(u);break;default:c.skipField()}return i},proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.ReceiveSignalStreamRequest.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.ReceiveSignalStreamRequest.serializeBinaryToWriter=function(i,c){var u;(u=i.getPeerId()).length>0&&c.writeString(1,u)},proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.getPeerId=function(){return n.Message.getFieldWithDefault(this,1,"")},proto.v1.signaling.api.ReceiveSignalStreamRequest.prototype.setPeerId=function(i){return n.Message.setProto3StringField(this,1,i)},n.Message.GENERATE_TO_OBJECT&&(proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.toObject=function(i){return proto.v1.signaling.api.ReceiveSignalStreamResponse.toObject(i,this)},proto.v1.signaling.api.ReceiveSignalStreamResponse.toObject=function(i,c){var u,b={signal:(u=c.getSignal())&&proto.v1.signaling.api.Signal.toObject(i,u)};return i&&(b.$jspbMessageInstance=c),b}),proto.v1.signaling.api.ReceiveSignalStreamResponse.deserializeBinary=function(i){var c=new n.BinaryReader(i),u=new proto.v1.signaling.api.ReceiveSignalStreamResponse;return proto.v1.signaling.api.ReceiveSignalStreamResponse.deserializeBinaryFromReader(u,c)},proto.v1.signaling.api.ReceiveSignalStreamResponse.deserializeBinaryFromReader=function(i,c){for(;c.nextField()&&!c.isEndGroup();)switch(c.getFieldNumber()){case 1:var u=new proto.v1.signaling.api.Signal;c.readMessage(u,proto.v1.signaling.api.Signal.deserializeBinaryFromReader),i.setSignal(u);break;default:c.skipField()}return i},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.serializeBinary=function(){var i=new n.BinaryWriter;return proto.v1.signaling.api.ReceiveSignalStreamResponse.serializeBinaryToWriter(this,i),i.getResultBuffer()},proto.v1.signaling.api.ReceiveSignalStreamResponse.serializeBinaryToWriter=function(i,c){var u;(u=i.getSignal())!=null&&c.writeMessage(1,u,proto.v1.signaling.api.Signal.serializeBinaryToWriter)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.getSignal=function(){return n.Message.getWrapperField(this,proto.v1.signaling.api.Signal,1)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.setSignal=function(i){return n.Message.setWrapperField(this,1,i)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.clearSignal=function(){return this.setSignal(void 0)},proto.v1.signaling.api.ReceiveSignalStreamResponse.prototype.hasSignal=function(){return n.Message.getField(this,1)!=null},proto.v1.signaling.api.SessionType={UNKNOWN:0,TELEOP:1,PORT_FORWARD:2,OBSERVE:3},o.object.extend(t,proto.v1.signaling.api)},function(e,t,r){function n(_){return(n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v})(_)}function o(_,v){return!v||n(v)!=="object"&&typeof v!="function"?l(_):v}function l(_){if(_===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _}function s(_){var v=typeof Map=="function"?new Map:void 0;return(s=function(f){if(f===null||(S=f,Function.toString.call(S).indexOf("[native code]")===-1))return f;var S;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(v!==void 0){if(v.has(f))return v.get(f);v.set(f,w)}function w(){return i(f,arguments,b(this).constructor)}return w.prototype=Object.create(f.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),u(w,f)})(_)}function i(_,v,f){return(i=c()?Reflect.construct:function(S,w,P){var N=[null];N.push.apply(N,w);var T=new(Function.bind.apply(S,N));return P&&u(T,P.prototype),T}).apply(null,arguments)}function c(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function u(_,v){return(u=Object.setPrototypeOf||function(f,S){return f.__proto__=S,f})(_,v)}function b(_){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)})(_)}var A=function(_){(function(P,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function");P.prototype=Object.create(N&&N.prototype,{constructor:{value:P,writable:!0,configurable:!0}}),N&&u(P,N)})(w,_);var v,f,S=(v=w,f=c(),function(){var P,N=b(v);if(f){var T=b(this).constructor;P=Reflect.construct(N,arguments,T)}else P=N.apply(this,arguments);return o(this,P)});function w(P){var N;return function(T,R){if(!(T instanceof R))throw new TypeError("Cannot call a class as a function")}(this,w),N=S.call(this,`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
3
3
|
Found: `.concat(P.toString().split(`
|
|
4
4
|
`)[0],`
|
|
@@ -12,11 +12,11 @@ Found: `.concat(P.toString().split(`
|
|
|
12
12
|
`+G.split(`
|
|
13
13
|
`).map(function(K){return" "+K}).join(`
|
|
14
14
|
`)):G=O.stylize("[Circular]","special")),T(B)){if(U&&g.match(/^\d+$/))return G;(B=JSON.stringify(""+g)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(B=B.substr(1,B.length-2),B=O.stylize(B,"name")):(B=B.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),B=O.stylize(B,"string"))}return B+": "+G}function f(O){return Array.isArray(O)}function S(O){return typeof O=="boolean"}function w(O){return O===null}function P(O){return typeof O=="number"}function N(O){return typeof O=="string"}function T(O){return O===void 0}function R(O){return d(O)&&h(O)==="[object RegExp]"}function d(O){return typeof O=="object"&&O!==null}function I(O){return d(O)&&h(O)==="[object Date]"}function Q(O){return d(O)&&(h(O)==="[object Error]"||O instanceof Error)}function Z(O){return typeof O=="function"}function h(O){return Object.prototype.toString.call(O)}function p(O){return O<10?"0"+O.toString(10):O.toString(10)}t.debuglog=function(O){if(T(s)&&(s=n.env.NODE_DEBUG||""),O=O.toUpperCase(),!i[O])if(new RegExp("\\b"+O+"\\b","i").test(s)){var L=n.pid;i[O]=function(){var k=t.format.apply(t,arguments);console.error("%s %d: %s",O,L,k)}}else i[O]=function(){};return i[O]},t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=f,t.isBoolean=S,t.isNull=w,t.isNullOrUndefined=function(O){return O==null},t.isNumber=P,t.isString=N,t.isSymbol=function(O){return typeof O=="symbol"},t.isUndefined=T,t.isRegExp=R,t.isObject=d,t.isDate=I,t.isError=Q,t.isFunction=Z,t.isPrimitive=function(O){return O===null||typeof O=="boolean"||typeof O=="number"||typeof O=="string"||typeof O=="symbol"||O===void 0},t.isBuffer=r(106);var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function m(){var O=new Date,L=[p(O.getHours()),p(O.getMinutes()),p(O.getSeconds())].join(":");return[O.getDate(),C[O.getMonth()],L].join(" ")}function x(O,L){return Object.prototype.hasOwnProperty.call(O,L)}t.log=function(){console.log("%s - %s",m(),t.format.apply(t,arguments))},t.inherits=r(107),t._extend=function(O,L){if(!L||!d(L))return O;for(var k=Object.keys(L),E=k.length;E--;)O[k[E]]=L[k[E]];return O};var F=typeof Symbol!="undefined"?Symbol("util.promisify.custom"):void 0;function D(O,L){if(!O){var k=new Error("Promise was rejected with a falsy value");k.reason=O,O=k}return L(O)}t.promisify=function(O){if(typeof O!="function")throw new TypeError('The "original" argument must be of type Function');if(F&&O[F]){var L;if(typeof(L=O[F])!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(L,F,{value:L,enumerable:!1,writable:!1,configurable:!0}),L}function L(){for(var k,E,g=new Promise(function(G,Y){k=G,E=Y}),U=[],B=0;B<arguments.length;B++)U.push(arguments[B]);U.push(function(G,Y){G?E(G):k(Y)});try{O.apply(this,U)}catch(G){E(G)}return g}return Object.setPrototypeOf(L,Object.getPrototypeOf(O)),F&&Object.defineProperty(L,F,{value:L,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(L,o(O))},t.promisify.custom=F,t.callbackify=function(O){if(typeof O!="function")throw new TypeError('The "original" argument must be of type Function');function L(){for(var k=[],E=0;E<arguments.length;E++)k.push(arguments[E]);var g=k.pop();if(typeof g!="function")throw new TypeError("The last argument must be of type Function");var U=this,B=function(){return g.apply(U,arguments)};O.apply(this,k).then(function(G){n.nextTick(B,null,G)},function(G){n.nextTick(D,G,B)})}return Object.setPrototypeOf(L,Object.getPrototypeOf(O)),Object.defineProperties(L,o(O)),L}}).call(this,r(2))},function(e,t,r){r.d(t,"a",function(){return n});const n=o=>new Promise(l=>setTimeout(l,o||0))},function(e,t,r){(function(n){var o=n!==void 0&&n||typeof self!="undefined"&&self||window,l=Function.prototype.apply;function s(i,c){this._id=i,this._clearFn=c}t.setTimeout=function(){return new s(l.call(setTimeout,o,arguments),clearTimeout)},t.setInterval=function(){return new s(l.call(setInterval,o,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(i){i&&i.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(o,this._id)},t.enroll=function(i,c){clearTimeout(i._idleTimeoutId),i._idleTimeout=c},t.unenroll=function(i){clearTimeout(i._idleTimeoutId),i._idleTimeout=-1},t._unrefActive=t.active=function(i){clearTimeout(i._idleTimeoutId);var c=i._idleTimeout;c>=0&&(i._idleTimeoutId=setTimeout(function(){i._onTimeout&&i._onTimeout()},c))},r(140),t.setImmediate=typeof self!="undefined"&&self.setImmediate||n!==void 0&&n.setImmediate||this&&this.setImmediate,t.clearImmediate=typeof self!="undefined"&&self.clearImmediate||n!==void 0&&n.clearImmediate||this&&this.clearImmediate}).call(this,r(5))},function(e,t,r){(function(n){n===void 0||!n.version||n.version.indexOf("v0.")===0||n.version.indexOf("v1.")===0&&n.version.indexOf("v1.8.")!==0?e.exports={nextTick:function(o,l,s,i){if(typeof o!="function")throw new TypeError('"callback" argument must be a function');var c,u,b=arguments.length;switch(b){case 0:case 1:return n.nextTick(o);case 2:return n.nextTick(function(){o.call(null,l)});case 3:return n.nextTick(function(){o.call(null,l,s)});case 4:return n.nextTick(function(){o.call(null,l,s,i)});default:for(c=new Array(b-1),u=0;u<c.length;)c[u++]=arguments[u];return n.nextTick(function(){o.apply(null,c)})}}}:e.exports=n}).call(this,r(2))},function(e,t,r){(function(n){function o(l){return Object.prototype.toString.call(l)}t.isArray=function(l){return Array.isArray?Array.isArray(l):o(l)==="[object Array]"},t.isBoolean=function(l){return typeof l=="boolean"},t.isNull=function(l){return l===null},t.isNullOrUndefined=function(l){return l==null},t.isNumber=function(l){return typeof l=="number"},t.isString=function(l){return typeof l=="string"},t.isSymbol=function(l){return typeof l=="symbol"},t.isUndefined=function(l){return l===void 0},t.isRegExp=function(l){return o(l)==="[object RegExp]"},t.isObject=function(l){return typeof l=="object"&&l!==null},t.isDate=function(l){return o(l)==="[object Date]"},t.isError=function(l){return o(l)==="[object Error]"||l instanceof Error},t.isFunction=function(l){return typeof l=="function"},t.isPrimitive=function(l){return l===null||typeof l=="boolean"||typeof l=="number"||typeof l=="string"||typeof l=="symbol"||l===void 0},t.isBuffer=n.isBuffer}).call(this,r(4).Buffer)},function(e,t){t.endianness=function(){return"LE"},t.hostname=function(){return typeof location!="undefined"?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return typeof navigator!="undefined"?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL=`
|
|
15
|
-
`,t.homedir=function(){return"/"}},function(e,t,r){var n=r(56),o=r(59).warn,l=t;l.version=r(137).version,l.transports=r(138),l.config=r(47),l.addColors=n.levels,l.format=n.format,l.createLogger=r(85),l.ExceptionHandler=r(86),l.RejectionHandler=r(90),l.Container=r(209),l.Transport=r(17),l.loggers=new l.Container;var s=l.createLogger();Object.keys(l.config.npm.levels).concat(["log","query","stream","add","remove","clear","profile","startTimer","handleExceptions","unhandleExceptions","handleRejections","unhandleRejections","configure","child"]).forEach(function(i){return l[i]=function(){return s[i].apply(s,arguments)}}),Object.defineProperty(l,"level",{get:function(){return s.level},set:function(i){s.level=i}}),Object.defineProperty(l,"exceptions",{get:function(){return s.exceptions}}),["exitOnError"].forEach(function(i){Object.defineProperty(l,i,{get:function(){return s[i]},set:function(c){s[i]=c}})}),Object.defineProperty(l,"default",{get:function(){return{exceptionHandlers:s.exceptionHandlers,rejectionHandlers:s.rejectionHandlers,transports:s.transports}}}),o.deprecated(l,"setLevels"),o.forFunctions(l,"useFormat",["cli"]),o.forProperties(l,"useFormat",["padLevels","stripColors"]),o.forFunctions(l,"deprecated",["addRewriter","addFilter","clone","extend"]),o.forProperties(l,"deprecated",["emitErrs","levelLength"]),o.moved(l,"createLogger","Logger")},function(e,t,r){var n=r(10),o=r(141),l=r(3).LEVEL,s=e.exports=function(){var i=this,c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};o.call(this,{objectMode:!0,highWaterMark:c.highWaterMark}),this.format=c.format,this.level=c.level,this.handleExceptions=c.handleExceptions,this.handleRejections=c.handleRejections,this.silent=c.silent,c.log&&(this.log=c.log),c.logv&&(this.logv=c.logv),c.close&&(this.close=c.close),this.once("pipe",function(u){i.levels=u.levels,i.parent=u}),this.once("unpipe",function(u){u===i.parent&&(i.parent=null,i.close&&i.close())})};n.inherits(s,o),s.prototype._write=function(i,c,u){if(this.silent||i.exception===!0&&!this.handleExceptions)return u(null);var b=this.level||this.parent&&this.parent.level;if(!b||this.levels[b]>=this.levels[i[l]]){if(i&&!this.format)return this.log(i,u);var A=void 0,_=void 0;try{_=this.format.transform(Object.assign({},i),this.format.options)}catch(v){A=v}if(A||!_){if(u(),A)throw A;return}return this.log(_,u)}return u(null)},s.prototype._writev=function(i,c){if(this.logv){var u=i.filter(this._accept,this);return u.length?this.logv(u,c):c(null)}for(var b=0;b<i.length;b++)if(this._accept(i[b]))if(!i[b].chunk||this.format){var A=void 0,_=void 0;try{_=this.format.transform(Object.assign({},i[b].chunk),this.format.options)}catch(v){A=v}if(A||!_){if(i[b].callback(),A)throw c(null),A}else this.log(_,i[b].callback)}else this.log(i[b].chunk,i[b].callback);return c(null)},s.prototype._accept=function(i){var c=i.chunk;if(this.silent)return!1;var u=this.level||this.parent&&this.parent.level;return!(c.exception!==!0&&u&&!(this.levels[u]>=this.levels[c[l]])||!this.handleExceptions&&c.exception===!0)},s.prototype._nop=function(){},e.exports.LegacyTransportStream=r(147)},function(e,t,r){var n,o=typeof Reflect=="object"?Reflect:null,l=o&&typeof o.apply=="function"?o.apply:function(w,P,N){return Function.prototype.apply.call(w,P,N)};n=o&&typeof o.ownKeys=="function"?o.ownKeys:Object.getOwnPropertySymbols?function(w){return Object.getOwnPropertyNames(w).concat(Object.getOwnPropertySymbols(w))}:function(w){return Object.getOwnPropertyNames(w)};var s=Number.isNaN||function(w){return w!=w};function i(){i.init.call(this)}e.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var c=10;function u(w){return w._maxListeners===void 0?i.defaultMaxListeners:w._maxListeners}function b(w,P,N,T){var R,d,I,Q;if(typeof N!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof N);if((d=w._events)===void 0?(d=w._events=Object.create(null),w._eventsCount=0):(d.newListener!==void 0&&(w.emit("newListener",P,N.listener?N.listener:N),d=w._events),I=d[P]),I===void 0)I=d[P]=N,++w._eventsCount;else if(typeof I=="function"?I=d[P]=T?[N,I]:[I,N]:T?I.unshift(N):I.push(N),(R=u(w))>0&&I.length>R&&!I.warned){I.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+I.length+" "+String(P)+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=w,Z.type=P,Z.count=I.length,Q=Z,console&&console.warn&&console.warn(Q)}return w}function A(){for(var w=[],P=0;P<arguments.length;P++)w.push(arguments[P]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,l(this.listener,this.target,w))}function _(w,P,N){var T={fired:!1,wrapFn:void 0,target:w,type:P,listener:N},R=A.bind(T);return R.listener=N,T.wrapFn=R,R}function v(w,P,N){var T=w._events;if(T===void 0)return[];var R=T[P];return R===void 0?[]:typeof R=="function"?N?[R.listener||R]:[R]:N?function(d){for(var I=new Array(d.length),Q=0;Q<I.length;++Q)I[Q]=d[Q].listener||d[Q];return I}(R):S(R,R.length)}function f(w){var P=this._events;if(P!==void 0){var N=P[w];if(typeof N=="function")return 1;if(N!==void 0)return N.length}return 0}function S(w,P){for(var N=new Array(P),T=0;T<P;++T)N[T]=w[T];return N}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(w){if(typeof w!="number"||w<0||s(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");c=w}}),i.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(w){if(typeof w!="number"||w<0||s(w))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+w+".");return this._maxListeners=w,this},i.prototype.getMaxListeners=function(){return u(this)},i.prototype.emit=function(w){for(var P=[],N=1;N<arguments.length;N++)P.push(arguments[N]);var T=w==="error",R=this._events;if(R!==void 0)T=T&&R.error===void 0;else if(!T)return!1;if(T){var d;if(P.length>0&&(d=P[0]),d instanceof Error)throw d;var I=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw I.context=d,I}var Q=R[w];if(Q===void 0)return!1;if(typeof Q=="function")l(Q,this,P);else{var Z=Q.length,h=S(Q,Z);for(N=0;N<Z;++N)l(h[N],this,P)}return!0},i.prototype.addListener=function(w,P){return b(this,w,P,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(w,P){return b(this,w,P,!0)},i.prototype.once=function(w,P){if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P);return this.on(w,_(this,w,P)),this},i.prototype.prependOnceListener=function(w,P){if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P);return this.prependListener(w,_(this,w,P)),this},i.prototype.removeListener=function(w,P){var N,T,R,d,I;if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P);if((T=this._events)===void 0)return this;if((N=T[w])===void 0)return this;if(N===P||N.listener===P)--this._eventsCount==0?this._events=Object.create(null):(delete T[w],T.removeListener&&this.emit("removeListener",w,N.listener||P));else if(typeof N!="function"){for(R=-1,d=N.length-1;d>=0;d--)if(N[d]===P||N[d].listener===P){I=N[d].listener,R=d;break}if(R<0)return this;R===0?N.shift():function(Q,Z){for(;Z+1<Q.length;Z++)Q[Z]=Q[Z+1];Q.pop()}(N,R),N.length===1&&(T[w]=N[0]),T.removeListener!==void 0&&this.emit("removeListener",w,I||P)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(w){var P,N,T;if((N=this._events)===void 0)return this;if(N.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):N[w]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete N[w]),this;if(arguments.length===0){var R,d=Object.keys(N);for(T=0;T<d.length;++T)(R=d[T])!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(P=N[w])=="function")this.removeListener(w,P);else if(P!==void 0)for(T=P.length-1;T>=0;T--)this.removeListener(w,P[T]);return this},i.prototype.listeners=function(w){return v(this,w,!0)},i.prototype.rawListeners=function(w){return v(this,w,!1)},i.listenerCount=function(w,P){return typeof w.listenerCount=="function"?w.listenerCount(P):f.call(w,P)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){var n=r(146).Buffer,o=n.isEncoding||function(f){switch((f=""+f)&&f.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function l(f){var S;switch(this.encoding=function(w){var P=function(N){if(!N)return"utf8";for(var T;;)switch(N){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return N;default:if(T)return;N=(""+N).toLowerCase(),T=!0}}(w);if(typeof P!="string"&&(n.isEncoding===o||!o(w)))throw new Error("Unknown encoding: "+w);return P||w}(f),this.encoding){case"utf16le":this.text=c,this.end=u,S=4;break;case"utf8":this.fillLast=i,S=4;break;case"base64":this.text=b,this.end=A,S=3;break;default:return this.write=_,void(this.end=v)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(S)}function s(f){return f<=127?0:f>>5==6?2:f>>4==14?3:f>>3==30?4:f>>6==2?-1:-2}function i(f){var S=this.lastTotal-this.lastNeed,w=function(P,N,T){if((192&N[0])!=128)return P.lastNeed=0,"\uFFFD";if(P.lastNeed>1&&N.length>1){if((192&N[1])!=128)return P.lastNeed=1,"\uFFFD";if(P.lastNeed>2&&N.length>2&&(192&N[2])!=128)return P.lastNeed=2,"\uFFFD"}}(this,f);return w!==void 0?w:this.lastNeed<=f.length?(f.copy(this.lastChar,S,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(f.copy(this.lastChar,S,0,f.length),void(this.lastNeed-=f.length))}function c(f,S){if((f.length-S)%2==0){var w=f.toString("utf16le",S);if(w){var P=w.charCodeAt(w.length-1);if(P>=55296&&P<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=f[f.length-2],this.lastChar[1]=f[f.length-1],w.slice(0,-1)}return w}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=f[f.length-1],f.toString("utf16le",S,f.length-1)}function u(f){var S=f&&f.length?this.write(f):"";if(this.lastNeed){var w=this.lastTotal-this.lastNeed;return S+this.lastChar.toString("utf16le",0,w)}return S}function b(f,S){var w=(f.length-S)%3;return w===0?f.toString("base64",S):(this.lastNeed=3-w,this.lastTotal=3,w===1?this.lastChar[0]=f[f.length-1]:(this.lastChar[0]=f[f.length-2],this.lastChar[1]=f[f.length-1]),f.toString("base64",S,f.length-w))}function A(f){var S=f&&f.length?this.write(f):"";return this.lastNeed?S+this.lastChar.toString("base64",0,3-this.lastNeed):S}function _(f){return f.toString(this.encoding)}function v(f){return f&&f.length?this.write(f):""}t.StringDecoder=l,l.prototype.write=function(f){if(f.length===0)return"";var S,w;if(this.lastNeed){if((S=this.fillLast(f))===void 0)return"";w=this.lastNeed,this.lastNeed=0}else w=0;return w<f.length?S?S+this.text(f,w):this.text(f,w):S||""},l.prototype.end=function(f){var S=f&&f.length?this.write(f):"";return this.lastNeed?S+"\uFFFD":S},l.prototype.text=function(f,S){var w=function(N,T,R){var d=T.length-1;if(d<R)return 0;var I=s(T[d]);return I>=0?(I>0&&(N.lastNeed=I-1),I):--d<R||I===-2?0:(I=s(T[d]))>=0?(I>0&&(N.lastNeed=I-2),I):--d<R||I===-2?0:(I=s(T[d]))>=0?(I>0&&(I===2?I=0:N.lastNeed=I-3),I):0}(this,f,S);if(!this.lastNeed)return f.toString("utf8",S);this.lastTotal=w;var P=f.length-(w-this.lastNeed);return f.copy(this.lastChar,0,P),f.toString("utf8",S,P)},l.prototype.fillLast=function(f){if(this.lastNeed<=f.length)return f.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);f.copy(this.lastChar,this.lastTotal-this.lastNeed,0,f.length),this.lastNeed-=f.length}},function(e,t,r){var n=r(13),o=Object.keys||function(f){var S=[];for(var w in f)S.push(w);return S};e.exports=A;var l=r(14);l.inherits=r(7);var s=r(67),i=r(44);l.inherits(A,s);for(var c=o(i.prototype),u=0;u<c.length;u++){var b=c[u];A.prototype[b]||(A.prototype[b]=i.prototype[b])}function A(f){if(!(this instanceof A))return new A(f);s.call(this,f),i.call(this,f),f&&f.readable===!1&&(this.readable=!1),f&&f.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,f&&f.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||n.nextTick(v,this)}function v(f){f.end()}Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(A.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(f){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=f,this._writableState.destroyed=f)}}),A.prototype._destroy=function(f,S){this.push(null),this.end(),n.nextTick(S,f)}},function(e,t,r){(function(n){function o(M){var z=0;return function(){return z<M.length?{done:!1,value:M[z++]}:{done:!0}}}var l=typeof Object.defineProperties=="function"?Object.defineProperty:function(M,z,J){M!=Array.prototype&&M!=Object.prototype&&(M[z]=J.value)},s=function(M){M=[typeof window=="object"&&window,typeof self=="object"&&self,typeof n=="object"&&n,M];for(var z=0;z<M.length;++z){var J=M[z];if(J&&J.Math==Math)return J}throw Error("Cannot find global object")}(this);function i(M,z){if(z){var J=s;M=M.split(".");for(var re=0;re<M.length-1;re++){var se=M[re];se in J||(J[se]={}),J=J[se]}(z=z(re=J[M=M[M.length-1]]))!=re&&z!=null&&l(J,M,{configurable:!0,writable:!0,value:z})}}function c(M){var z=typeof Symbol!="undefined"&&Symbol.iterator&&M[Symbol.iterator];return z?z.call(M):{next:o(M)}}i("Object.is",function(M){return M||function(z,J){return z===J?z!==0||1/z==1/J:z!=z&&J!=J}}),i("Array.prototype.includes",function(M){return M||function(z,J){var re=this;re instanceof String&&(re=String(re));var se=re.length;for(0>(J=J||0)&&(J=Math.max(J+se,0));J<se;J++){var fe=re[J];if(fe===z||Object.is(fe,z))return!0}return!1}}),i("Promise",function(M){function z(oe){this.b=0,this.c=void 0,this.a=[];var le=this.f();try{oe(le.resolve,le.reject)}catch(ve){le.reject(ve)}}function J(){this.a=null}function re(oe){return oe instanceof z?oe:new z(function(le){le(oe)})}if(M)return M;J.prototype.b=function(oe){if(this.a==null){this.a=[];var le=this;this.c(function(){le.g()})}this.a.push(oe)};var se=s.setTimeout;J.prototype.c=function(oe){se(oe,0)},J.prototype.g=function(){for(;this.a&&this.a.length;){var oe=this.a;this.a=[];for(var le=0;le<oe.length;++le){var ve=oe[le];oe[le]=null;try{ve()}catch(be){this.f(be)}}}this.a=null},J.prototype.f=function(oe){this.c(function(){throw oe})},z.prototype.f=function(){function oe(be){return function(_e){ve||(ve=!0,be.call(le,_e))}}var le=this,ve=!1;return{resolve:oe(this.m),reject:oe(this.g)}},z.prototype.m=function(oe){if(oe===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(oe instanceof z)this.o(oe);else{e:switch(typeof oe){case"object":var le=oe!=null;break e;case"function":le=!0;break e;default:le=!1}le?this.l(oe):this.h(oe)}},z.prototype.l=function(oe){var le=void 0;try{le=oe.then}catch(ve){return void this.g(ve)}typeof le=="function"?this.u(le,oe):this.h(oe)},z.prototype.g=function(oe){this.i(2,oe)},z.prototype.h=function(oe){this.i(1,oe)},z.prototype.i=function(oe,le){if(this.b!=0)throw Error("Cannot settle("+oe+", "+le+"): Promise already settled in state"+this.b);this.b=oe,this.c=le,this.j()},z.prototype.j=function(){if(this.a!=null){for(var oe=0;oe<this.a.length;++oe)fe.b(this.a[oe]);this.a=null}};var fe=new J;return z.prototype.o=function(oe){var le=this.f();oe.w(le.resolve,le.reject)},z.prototype.u=function(oe,le){var ve=this.f();try{oe.call(le,ve.resolve,ve.reject)}catch(be){ve.reject(be)}},z.prototype.then=function(oe,le){function ve(je,xe){return typeof je=="function"?function(Ne){try{be(je(Ne))}catch(Ue){_e(Ue)}}:xe}var be,_e,Ce=new z(function(je,xe){be=je,_e=xe});return this.w(ve(oe,be),ve(le,_e)),Ce},z.prototype.catch=function(oe){return this.then(void 0,oe)},z.prototype.w=function(oe,le){function ve(){switch(be.b){case 1:oe(be.c);break;case 2:le(be.c);break;default:throw Error("Unexpected state: "+be.b)}}var be=this;this.a==null?fe.b(ve):this.a.push(ve)},z.resolve=re,z.reject=function(oe){return new z(function(le,ve){ve(oe)})},z.race=function(oe){return new z(function(le,ve){for(var be=c(oe),_e=be.next();!_e.done;_e=be.next())re(_e.value).w(le,ve)})},z.all=function(oe){var le=c(oe),ve=le.next();return ve.done?re([]):new z(function(be,_e){function Ce(Ne){return function(Ue){je[Ne]=Ue,--xe==0&&be(je)}}var je=[],xe=0;do je.push(void 0),xe++,re(ve.value).w(Ce(je.length-1),_e),ve=le.next();while(!ve.done)})},z});var u=u||{},b=this||self;function A(M,z){M=M.split("."),z=z||b;for(var J=0;J<M.length;J++)if((z=z[M[J]])==null)return null;return z}function _(){}function v(M){var z=typeof M;if(z=="object"){if(!M)return"null";if(M instanceof Array)return"array";if(M instanceof Object)return z;var J=Object.prototype.toString.call(M);if(J=="[object Window]")return"object";if(J=="[object Array]"||typeof M.length=="number"&&M.splice!==void 0&&M.propertyIsEnumerable!==void 0&&!M.propertyIsEnumerable("splice"))return"array";if(J=="[object Function]"||M.call!==void 0&&M.propertyIsEnumerable!==void 0&&!M.propertyIsEnumerable("call"))return"function"}else if(z=="function"&&M.call===void 0)return"object";return z}function f(M){var z=typeof M;return z=="object"&&M!=null||z=="function"}function S(M,z,J){return M.call.apply(M.bind,arguments)}function w(M,z,J){if(!M)throw Error();if(2<arguments.length){var re=Array.prototype.slice.call(arguments,2);return function(){var se=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(se,re),M.apply(z,se)}}return function(){return M.apply(z,arguments)}}function P(M,z,J){return(P=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?S:w).apply(null,arguments)}function N(M,z){function J(){}J.prototype=z.prototype,M.S=z.prototype,M.prototype=new J,M.prototype.constructor=M}function T(){this.a={}}function R(M,z,J,re){this.f=M,this.c=z,this.b=J,this.a=re}function d(M,z,J,re){J=J===void 0?{}:J,this.c=M,this.a=J,this.b=z,this.f=re===void 0?null:re}function I(M,z,J,re,se,fe){this.name=M,this.a=se,this.b=fe}function Q(M,z,J){J=J===void 0?{}:J;var re=re===void 0?new T:re;return new R(z,M,J,re)}function Z(M,z,J,re){return re instanceof I?re:new I(M,J,re.b||z.constructor,re.f,re.a,re.c)}function h(M){this.a=M}function p(M){switch(M){case 0:return"No Error";case 1:return"Access denied to content document";case 2:return"File not found";case 3:return"Firefox silently errored";case 4:return"Application custom error";case 5:return"An exception occurred";case 6:return"Http response at 400 or 500 level";case 7:return"Request was aborted";case 8:return"Request timed out";case 9:return"The resource is not available offline";default:return"Unrecognized error code"}}function C(M){if(Error.captureStackTrace)Error.captureStackTrace(this,C);else{var z=Error().stack;z&&(this.stack=z)}M&&(this.message=String(M))}function m(M,z){for(var J="",re=(M=M.split("%s")).length-1,se=0;se<re;se++)J+=M[se]+(se<z.length?z[se]:"%s");C.call(this,J+M[re])}function x(){this.j=null,this.i=[],this.l=0,this.b=F,this.f=this.a=this.h=0,this.c=null,this.g=0}T.prototype.get=function(M){return this.a[M]},T.prototype.f=function(){return Object.keys(this.a)},R.prototype.getRequestMessage=function(){return this.f},R.prototype.getMethodDescriptor=function(){return this.c},R.prototype.getMetadata=function(){return this.b},R.prototype.getCallOptions=function(){return this.a},d.prototype.getResponseMessage=function(){return this.c},d.prototype.getMetadata=function(){return this.a},d.prototype.getMethodDescriptor=function(){return this.b},d.prototype.getStatus=function(){return this.f},h.prototype.on=function(M,z){return M=="data"||M=="error"?this:this.a.on(M,z)},h.prototype.removeListener=function(M,z){return this.a.removeListener(M,z)},h.prototype.cancel=function(){this.a.cancel()},N(C,Error),C.prototype.name="CustomError",N(m,C),m.prototype.name="AssertionError";var F=0,D=1,O=2,L=3,k=0,E=128;function g(M,z,J,re){throw M.b=L,M.j="The stream is broken @"+M.l+"/"+J+". Error: "+re+`. With input:
|
|
16
|
-
`+z,Error(M.j)}var U=Array.prototype.indexOf?function(M,z){return Array.prototype.indexOf.call(M,z,void 0)}:function(M,z){if(typeof M=="string")return typeof z!="string"||z.length!=1?-1:M.indexOf(z,0);for(var J=0;J<M.length;J++)if(J in M&&M[J]===z)return J;return-1},B,G=String.prototype.trim?function(M){return M.trim()}:function(M){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(M)[1]};function Y(M,z){return M.indexOf(z)!=-1}function K(M,z){return M<z?-1:M>z?1:0}e:{var H=b.navigator;if(H){var V=H.userAgent;if(V){B=V;break e}}B=""}var y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function j(M){var z=1;M=M.split(":");for(var J=[];0<z&&M.length;)J.push(M.shift()),z--;return M.length&&J.push(M.join(":")),J}function W(M){return W[" "](M),M}W[" "]=_;var ee,X,ne=Y(B,"Opera"),ie=Y(B,"Trident")||Y(B,"MSIE"),he=Y(B,"Edge"),Se=Y(B,"Gecko")&&!(Y(B.toLowerCase(),"webkit")&&!Y(B,"Edge"))&&!(Y(B,"Trident")||Y(B,"MSIE"))&&!Y(B,"Edge"),we=Y(B.toLowerCase(),"webkit")&&!Y(B,"Edge");function Ee(){var M=b.document;return M?M.documentMode:void 0}e:{var ye="",q=(X=B,Se?/rv:([^\);]+)(\)|;)/.exec(X):he?/Edge\/([\d\.]+)/.exec(X):ie?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(X):we?/WebKit\/(\S+)/.exec(X):ne?/(?:Version)[ \/]?(\S+)/.exec(X):void 0);if(q&&(ye=q?q[1]:""),ie){var $=Ee();if($!=null&&$>parseFloat(ye)){ee=String($);break e}}ee=ye}var te,ue={};function ae(M){return function(z,J){var re=ue;return Object.prototype.hasOwnProperty.call(re,z)?re[z]:re[z]=J(z)}(M,function(){for(var z=0,J=G(String(ee)).split("."),re=G(String(M)).split("."),se=Math.max(J.length,re.length),fe=0;z==0&&fe<se;fe++){var oe=J[fe]||"",le=re[fe]||"";do{if(oe=/(\d*)(\D*)(.*)/.exec(oe)||["","","",""],le=/(\d*)(\D*)(.*)/.exec(le)||["","","",""],oe[0].length==0&&le[0].length==0)break;z=K(oe[1].length==0?0:parseInt(oe[1],10),le[1].length==0?0:parseInt(le[1],10))||K(oe[2].length==0,le[2].length==0)||K(oe[2],le[2]),oe=oe[3],le=le[3]}while(z==0)}return 0<=z})}if(b.document&&ie){var de=Ee();te=de||parseInt(ee,10)||void 0}else te=void 0;var me=te;function pe(){this.F=this.F}pe.prototype.F=!1;var ge,ce=Object.freeze||function(M){return M};(ge=!ie)||(ge=9<=Number(me));var Te=ge,Re=ie&&!ae("9"),Pe=function(){if(!b.addEventListener||!Object.defineProperty)return!1;var M=!1,z=Object.defineProperty({},"passive",{get:function(){M=!0}});try{b.addEventListener("test",_,z),b.removeEventListener("test",_,z)}catch{}return M}();function Le(M,z){this.type=M,this.a=this.target=z,this.defaultPrevented=!1}function Fe(M,z){if(Le.call(this,M?M.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,M){var J=this.type=M.type,re=M.changedTouches&&M.changedTouches.length?M.changedTouches[0]:null;if(this.target=M.target||M.srcElement,this.a=z,z=M.relatedTarget){if(Se){e:{try{W(z.nodeName);var se=!0;break e}catch{}se=!1}se||(z=null)}}else J=="mouseover"?z=M.fromElement:J=="mouseout"&&(z=M.toElement);this.relatedTarget=z,re?(this.clientX=re.clientX!==void 0?re.clientX:re.pageX,this.clientY=re.clientY!==void 0?re.clientY:re.pageY,this.screenX=re.screenX||0,this.screenY=re.screenY||0):(this.clientX=M.clientX!==void 0?M.clientX:M.pageX,this.clientY=M.clientY!==void 0?M.clientY:M.pageY,this.screenX=M.screenX||0,this.screenY=M.screenY||0),this.button=M.button,this.key=M.key||"",this.ctrlKey=M.ctrlKey,this.altKey=M.altKey,this.shiftKey=M.shiftKey,this.metaKey=M.metaKey,this.pointerId=M.pointerId||0,this.pointerType=typeof M.pointerType=="string"?M.pointerType:ze[M.pointerType]||"",this.c=M,M.defaultPrevented&&this.b()}}Le.prototype.b=function(){this.defaultPrevented=!0},N(Fe,Le);var ze=ce({2:"touch",3:"pen",4:"mouse"});Fe.prototype.b=function(){Fe.S.b.call(this);var M=this.c;if(M.preventDefault)M.preventDefault();else if(M.returnValue=!1,Re)try{(M.ctrlKey||112<=M.keyCode&&123>=M.keyCode)&&(M.keyCode=-1)}catch{}};var De="closure_listenable_"+(1e6*Math.random()|0),We=0;function Be(M,z,J,re,se){this.listener=M,this.proxy=null,this.src=z,this.type=J,this.capture=!!re,this.A=se,this.key=++We,this.s=this.v=!1}function ke(M){M.s=!0,M.listener=null,M.proxy=null,M.src=null,M.A=null}function qe(M){this.src=M,this.a={},this.b=0}function Ge(M,z){var J=z.type;if(J in M.a){var re,se=M.a[J],fe=U(se,z);(re=0<=fe)&&Array.prototype.splice.call(se,fe,1),re&&(ke(z),M.a[J].length==0&&(delete M.a[J],M.b--))}}function gt(M,z,J,re){for(var se=0;se<M.length;++se){var fe=M[se];if(!fe.s&&fe.listener==z&&fe.capture==!!J&&fe.A==re)return se}return-1}qe.prototype.add=function(M,z,J,re,se){var fe=M.toString();(M=this.a[fe])||(M=this.a[fe]=[],this.b++);var oe=gt(M,z,re,se);return-1<oe?(z=M[oe],J||(z.v=!1)):((z=new Be(z,this.src,fe,!!re,se)).v=J,M.push(z)),z};var ft="closure_lm_"+(1e6*Math.random()|0),ht={};function at(M,z,J,re,se){if(re&&re.once)(function oe(le,ve,be,_e,Ce){if(Array.isArray(ve))for(var je=0;je<ve.length;je++)oe(le,ve[je],be,_e,Ce);else be=dt(be),le&&le[De]?le.f.add(String(ve),be,!0,f(_e)?!!_e.capture:!!_e,Ce):Rt(le,ve,be,!0,_e,Ce)})(M,z,J,re,se);else if(Array.isArray(z))for(var fe=0;fe<z.length;fe++)at(M,z[fe],J,re,se);else J=dt(J),M&&M[De]?M.f.add(String(z),J,!1,f(re)?!!re.capture:!!re,se):Rt(M,z,J,!1,re,se)}function Rt(M,z,J,re,se,fe){if(!z)throw Error("Invalid event type");var oe=f(se)?!!se.capture:!!se,le=lt(M);if(le||(M[ft]=le=new qe(M)),!(J=le.add(z,J,re,oe,fe)).proxy)if(re=function(){var ve=Kt,be=Te?function(_e){return ve.call(be.src,be.listener,_e)}:function(_e){if(!(_e=ve.call(be.src,be.listener,_e)))return _e};return be}(),J.proxy=re,re.src=M,re.listener=J,M.addEventListener)Pe||(se=oe),se===void 0&&(se=!1),M.addEventListener(z.toString(),re,se);else if(M.attachEvent)M.attachEvent(Ot(z.toString()),re);else{if(!M.addListener||!M.removeListener)throw Error("addEventListener and attachEvent are unavailable.");M.addListener(re)}}function At(M){if(typeof M!="number"&&M&&!M.s){var z=M.src;if(z&&z[De])Ge(z.f,M);else{var J=M.type,re=M.proxy;z.removeEventListener?z.removeEventListener(J,re,M.capture):z.detachEvent?z.detachEvent(Ot(J),re):z.addListener&&z.removeListener&&z.removeListener(re),(J=lt(z))?(Ge(J,M),J.b==0&&(J.src=null,z[ft]=null)):ke(M)}}}function Ot(M){return M in ht?ht[M]:ht[M]="on"+M}function jt(M,z,J,re){var se=!0;if((M=lt(M))&&(z=M.a[z.toString()]))for(z=z.concat(),M=0;M<z.length;M++){var fe=z[M];fe&&fe.capture==J&&!fe.s&&(fe=It(fe,re),se=se&&fe!==!1)}return se}function It(M,z){var J=M.listener,re=M.A||M.src;return M.v&&At(M),J.call(re,z)}function Kt(M,z){if(M.s)return!0;if(!Te){var J=z||A("window.event");z=new Fe(J,this);var re=!0;if(!(0>J.keyCode||J.returnValue!=null)){e:{var se=!1;if(J.keyCode==0)try{J.keyCode=-1;break e}catch{se=!0}(se||J.returnValue==null)&&(J.returnValue=!0)}for(J=[],se=z.a;se;se=se.parentNode)J.push(se);for(M=M.type,se=J.length-1;0<=se;se--){z.a=J[se];var fe=jt(J[se],M,!0,z);re=re&&fe}for(se=0;se<J.length;se++)z.a=J[se],fe=jt(J[se],M,!1,z),re=re&&fe}return re}return It(M,new Fe(z,this))}function lt(M){return(M=M[ft])instanceof qe?M:null}var pt="__closure_events_fn_"+(1e9*Math.random()>>>0);function dt(M){return v(M)=="function"?M:(M[pt]||(M[pt]=function(z){return M.handleEvent(z)}),M[pt])}function et(){pe.call(this),this.f=new qe(this),this.N=this}function Ze(M,z){M=M.N;var J=z.type||z;if(typeof z=="string")z=new Le(z,M);else if(z instanceof Le)z.target=z.target||M;else{var re=z;(function(se,fe){for(var oe,le,ve=1;ve<arguments.length;ve++){for(oe in le=arguments[ve])se[oe]=le[oe];for(var be=0;be<y.length;be++)oe=y[be],Object.prototype.hasOwnProperty.call(le,oe)&&(se[oe]=le[oe])}})(z=new Le(J,M),re)}Ct(M=z.a=M,J,!0,z),Ct(M,J,!1,z)}function Ct(M,z,J,re){if(z=M.f.a[String(z)]){z=z.concat();for(var se=!0,fe=0;fe<z.length;++fe){var oe=z[fe];if(oe&&!oe.s&&oe.capture==J){var le=oe.listener,ve=oe.A||oe.src;oe.v&&Ge(M.f,oe),se=le.call(ve,re)!==!1&&se}}}}function Mt(M,z,J){if(v(M)=="function")J&&(M=P(M,J));else{if(!M||typeof M.handleEvent!="function")throw Error("Invalid listener argument");M=P(M.handleEvent,M)}return 2147483647<Number(z)?-1:b.setTimeout(M,z||0)}function mt(M,z,J){this.reset(M,z,J,void 0,void 0)}N(et,pe),et.prototype[De]=!0,et.prototype.addEventListener=function(M,z,J,re){at(this,M,z,J,re)},et.prototype.removeEventListener=function(M,z,J,re){(function se(fe,oe,le,ve,be){if(Array.isArray(oe))for(var _e=0;_e<oe.length;_e++)se(fe,oe[_e],le,ve,be);else ve=f(ve)?!!ve.capture:!!ve,le=dt(le),fe&&fe[De]?(fe=fe.f,(oe=String(oe).toString())in fe.a&&-1<(le=gt(_e=fe.a[oe],le,ve,be))&&(ke(_e[le]),Array.prototype.splice.call(_e,le,1),_e.length==0&&(delete fe.a[oe],fe.b--))):fe&&(fe=lt(fe))&&(oe=fe.a[oe.toString()],fe=-1,oe&&(fe=gt(oe,le,ve,be)),(le=-1<fe?oe[fe]:null)&&At(le))})(this,M,z,J,re)},mt.prototype.a=null;function yt(M){this.f=M,this.b=this.c=this.a=null}function ut(M,z){this.name=M,this.value=z}mt.prototype.reset=function(M,z,J,re,se){delete this.a},ut.prototype.toString=function(){return this.name};var Pt=new ut("SEVERE",1e3),Jt=new ut("CONFIG",700),Xt=new ut("FINE",500);function Nt(M){return M.c?M.c:M.a?Nt(M.a):(function(z,J){throw new m("Failure"+(z?": "+z:""),Array.prototype.slice.call(arguments,1))}("Root logger has no level set."),null)}yt.prototype.log=function(M,z,J){if(M.value>=Nt(this).value)for(v(z)=="function"&&(z=z()),M=new mt(M,String(z),this.f),J&&(M.a=J),J=this;J;)J=J.a};var bt,vt={},ct=null;function He(M,z){M&&M.log(Xt,z,void 0)}function Lt(){}function xt(M){var z;return(z=M.a)||(z={},Bt(M)&&(z[0]=!0,z[1]=!0),z=M.a=z),z}function Ut(){}function Dt(M){return(M=Bt(M))?new ActiveXObject(M):new XMLHttpRequest}function Bt(M){if(!M.b&&typeof XMLHttpRequest=="undefined"&&typeof ActiveXObject!="undefined"){for(var z=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],J=0;J<z.length;J++){var re=z[J];try{return new ActiveXObject(re),M.b=re}catch{}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return M.b}function Xe(M,z){this.b={},this.a=[],this.c=0;var J=arguments.length;if(1<J){if(J%2)throw Error("Uneven number of arguments");for(var re=0;re<J;re+=2)this.set(arguments[re],arguments[re+1])}else M&&kt(this,M)}function _t(M){if(M.c!=M.a.length){for(var z=0,J=0;z<M.a.length;){var re=M.a[z];tt(M.b,re)&&(M.a[J++]=re),z++}M.a.length=J}if(M.c!=M.a.length){var se={};for(J=z=0;z<M.a.length;)tt(se,re=M.a[z])||(M.a[J++]=re,se[re]=1),z++;M.a.length=J}}function kt(M,z){if(z instanceof Xe)for(var J=z.f(),re=0;re<J.length;re++)M.set(J[re],z.get(J[re]));else for(J in z)M.set(J,z[J])}function tt(M,z){return Object.prototype.hasOwnProperty.call(M,z)}Lt.prototype.a=null,N(Ut,Lt),bt=new Ut,Xe.prototype.f=function(){return _t(this),this.a.concat()},Xe.prototype.get=function(M,z){return tt(this.b,M)?this.b[M]:z},Xe.prototype.set=function(M,z){tt(this.b,M)||(this.c++,this.a.push(M)),this.b[M]=z},Xe.prototype.forEach=function(M,z){for(var J=this.f(),re=0;re<J.length;re++){var se=J[re],fe=this.get(se);M.call(z,fe,se,this)}};var Qt=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Je(M){et.call(this),this.headers=new Xe,this.D=M||null,this.c=!1,this.C=this.a=null,this.J=this.o="",this.g=0,this.i="",this.h=this.I=this.m=this.G=!1,this.l=0,this.u=null,this.j=Ft,this.B=this.H=!1}N(Je,et);var Ft="",er=Je.prototype,tr=function M(z){var J;if(ct||(ct=new yt(""),vt[""]=ct,ct.c=Jt),!(J=vt[z])){J=new yt(z);var re=z.lastIndexOf("."),se=z.substr(re+1);(re=M(z.substr(0,re))).b||(re.b={}),re.b[se]=J,J.a=re,vt[z]=J}return J}("goog.net.XhrIo");er.b=tr;var rr=/^https?$/i,nr=["POST","PUT"];function or(M,z,J){if(M.a)throw Error("[goog.net.XhrIo] Object is active with another request="+M.o+"; newUri="+z);M.o=z,M.i="",M.g=0,M.J="POST",M.G=!1,M.c=!0,M.a=M.D?Dt(M.D):Dt(bt),M.C=M.D?xt(M.D):xt(bt),M.a.onreadystatechange=P(M.K,M);try{He(M.b,Ke(M,"Opening Xhr")),M.I=!0,M.a.open("POST",String(z),!0),M.I=!1}catch(fe){return He(M.b,Ke(M,"Error opening Xhr: "+fe.message)),void Wt(M,fe)}z=J||"";var re=function(fe){e:{for(var oe=ir,le=fe.length,ve=typeof fe=="string"?fe.split(""):fe,be=0;be<le;be++)if(be in ve&&oe.call(void 0,ve[be],be,fe)){oe=be;break e}oe=-1}return 0>oe?null:typeof fe=="string"?fe.charAt(oe):fe[oe]}((J=new Xe(M.headers)).f()),se=b.FormData&&z instanceof b.FormData;!(0<=U(nr,"POST"))||re||se||J.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),J.forEach(function(fe,oe){this.a.setRequestHeader(oe,fe)},M),M.j&&(M.a.responseType=M.j),"withCredentials"in M.a&&M.a.withCredentials!==M.H&&(M.a.withCredentials=M.H);try{Ht(M),0<M.l&&(M.B=function(fe){return ie&&ae(9)&&typeof fe.timeout=="number"&&fe.ontimeout!==void 0}(M.a),He(M.b,Ke(M,"Will abort after "+M.l+"ms if incomplete, xhr2 "+M.B)),M.B?(M.a.timeout=M.l,M.a.ontimeout=P(M.L,M)):M.u=Mt(M.L,M.l,M)),He(M.b,Ke(M,"Sending request")),M.m=!0,M.a.send(z),M.m=!1}catch(fe){He(M.b,Ke(M,"Send error: "+fe.message)),Wt(M,fe)}}function ir(M){return M.toLowerCase()=="content-type"}function Wt(M,z){M.c=!1,M.a&&(M.h=!0,M.a.abort(),M.h=!1),M.i=z,M.g=5,Vt(M),St(M)}function Vt(M){M.G||(M.G=!0,Ze(M,"complete"),Ze(M,"error"))}function zt(M){if(M.c&&u!==void 0){if(M.C[1]&&Qe(M)==4&&M.getStatus()==2)He(M.b,Ke(M,"Local request error detected and ignored"));else if(M.m&&Qe(M)==4)Mt(M.K,0,M);else if(Ze(M,"readystatechange"),Qe(M)==4){He(M.b,Ke(M,"Request complete")),M.c=!1;try{var z,J=M.getStatus();e:switch(J){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var re=!0;break e;default:re=!1}if(!(z=re)){var se;if(se=J===0){var fe=String(M.o).match(Qt)[1]||null;if(!fe&&b.self&&b.self.location){var oe=b.self.location.protocol;fe=oe.substr(0,oe.length-1)}se=!rr.test(fe?fe.toLowerCase():"")}z=se}if(z)Ze(M,"complete"),Ze(M,"success");else{M.g=6;try{var le=2<Qe(M)?M.a.statusText:""}catch(ve){He(M.b,"Can not get status: "+ve.message),le=""}M.i=le+" ["+M.getStatus()+"]",Vt(M)}}finally{St(M)}}}}function St(M){if(M.a){Ht(M);var z=M.a,J=M.C[0]?_:null;M.a=null,M.C=null,Ze(M,"ready");try{z.onreadystatechange=J}catch(re){(M=M.b)&&M.log(Pt,"Problem encountered resetting onreadystatechange: "+re.message,void 0)}}}function Ht(M){M.a&&M.B&&(M.a.ontimeout=null),M.u&&(b.clearTimeout(M.u),M.u=null)}function Qe(M){return M.a?M.a.readyState:0}function Gt(M,z){if(M.a&&Qe(M)==4)return(M=M.a.getResponseHeader(z))===null?void 0:M}function Ke(M,z){return z+" ["+M.J+" "+M.o+" "+M.getStatus()+"]"}Je.prototype.L=function(){u!==void 0&&this.a&&(this.i="Timed out after "+this.l+"ms, aborting",this.g=8,He(this.b,Ke(this,this.i)),Ze(this,"timeout"),this.abort(8))},Je.prototype.abort=function(M){this.a&&this.c&&(He(this.b,Ke(this,"Aborting")),this.c=!1,this.h=!0,this.a.abort(),this.h=!1,this.g=M||7,Ze(this,"complete"),Ze(this,"abort"),St(this))},Je.prototype.K=function(){this.F||(this.I||this.m||this.h?zt(this):this.O())},Je.prototype.O=function(){zt(this)},Je.prototype.getStatus=function(){try{return 2<Qe(this)?this.a.status:-1}catch{return-1}};var qt={},ot=null;function sr(M){var z=M.length,J=3*z/4;J%3?J=Math.floor(J):Y("=.",M[z-1])&&(J=Y("=.",M[z-2])?J-2:J-1);var re=new Uint8Array(J),se=0;return function(fe,oe){function le(xe){for(;ve<fe.length;){var Ne=fe.charAt(ve++),Ue=ot[Ne];if(Ue!=null)return Ue;if(!/^[\s\xa0]*$/.test(Ne))throw Error("Unknown base64 encoding at char: "+Ne)}return xe}Yt();for(var ve=0;;){var be=le(-1),_e=le(0),Ce=le(64),je=le(64);if(je===64&&be===-1)break;oe(be<<2|_e>>4),Ce!=64&&(oe(_e<<4&240|Ce>>2),je!=64&&oe(Ce<<6&192|je))}}(M,function(fe){re[se++]=fe}),re.subarray(0,se)}function Yt(){if(!ot){ot={};for(var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),z=["+/=","+/","-_=","-_.","-_"],J=0;5>J;J++){var re=M.concat(z[J].split(""));qt[J]=re;for(var se=0;se<re.length;se++){var fe=re[se];ot[fe]===void 0&&(ot[fe]=se)}}}}var ar=["content-type","grpc-status","grpc-message"];function Ye(M){this.a=M.T,this.l=null,this.b=[],this.h=[],this.g=[],this.f=[],this.c=[],this.j=!1,this.i=0,this.m=new x;var z=this;at(this.a,"readystatechange",function(){var J=z.a;if(J=J.a?J.a.getResponseHeader("Content-Type"):null){if((J=J.toLowerCase()).lastIndexOf("application/grpc-web-text",0)==0){J=z.a;try{var re=J.a?J.a.responseText:""}catch(be){He(J.b,"Can not get responseText: "+be.message),re=""}if(re=(J=re||"").length-J.length%4,(J=J.substr(z.i,re-z.i)).length==0)return;z.i=re,J=sr(J)}else{if(J.lastIndexOf("application/grpc",0)!=0)return void rt(z,{code:2,message:"Unknown Content-type received.",metadata:{}});J=new Uint8Array(function(be){try{if(!be.a)return null;if("response"in be.a)return be.a.response;switch(be.j){case Ft:case"text":return be.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in be.a)return be.a.mozResponseArrayBuffer}var _e=be.b;return _e&&_e.log(Pt,"Response type "+be.j+" is not supported on this browser",void 0),null}catch(Ce){return He(be.b,"Can not get response: "+Ce.message),null}}(z.a))}re=null;try{re=function(be,_e){function Ce(nt){Ae.f++,Ae.a=(Ae.a<<8)+nt,Ae.f==4&&(Ae.b=O,Ae.g=0,typeof Uint8Array!="undefined"?Ae.c=new Uint8Array(Ae.a):Ae.c=Array(Ae.a),Ae.a==0&&xe())}function je(nt){Ae.c[Ae.g++]=nt,Ae.g==Ae.a&&xe()}function xe(){var nt={};nt[Ae.h]=Ae.c,Ae.i.push(nt),Ae.b=F}var Ne,Ue,Ae=be,$e=0;for(Ne=_e instanceof Uint8Array||_e instanceof Array?_e:new Uint8Array(_e);$e<Ne.length;){switch(Ae.b){case L:g(Ae,Ne,$e,"stream already broken");break;case F:(Ue=Ne[$e])==k||Ue==E?Ae.h=Ue:g(Ae,Ne,$e,"invalid frame byte"),Ae.b=D,Ae.a=0,Ae.f=0;break;case D:Ce(Ne[$e]);break;case O:je(Ne[$e]);break;default:throw Error("unexpected parser state: "+Ae.b)}Ae.l++,$e++}return be=Ae.i,Ae.i=[],0<be.length?be:null}(z.m,J)}catch{rt(z,{code:2,message:"Error in parsing response body",metadata:{}})}if(re)for(J=0;J<re.length;J++){if(k in re[J]){var se=re[J][k];if(se)try{var fe=z.l(se);if(fe){se=z;for(var oe=fe,le=0;le<se.b.length;le++)se.b[le](oe)}}catch{rt(z,{code:2,message:"Error in response deserializer function.",metadata:{}})}}if(E in re[J]&&0<re[J][E].length){for(se="",oe=0;oe<re[J][E].length;oe++)se+=String.fromCharCode(re[J][E][oe]);for(se=se.trim().split(`\r
|
|
15
|
+
`,t.homedir=function(){return"/"}},function(e,t,r){var n=r(56),o=r(59).warn,l=t;l.version=r(137).version,l.transports=r(138),l.config=r(47),l.addColors=n.levels,l.format=n.format,l.createLogger=r(85),l.ExceptionHandler=r(86),l.RejectionHandler=r(90),l.Container=r(209),l.Transport=r(17),l.loggers=new l.Container;var s=l.createLogger();Object.keys(l.config.npm.levels).concat(["log","query","stream","add","remove","clear","profile","startTimer","handleExceptions","unhandleExceptions","handleRejections","unhandleRejections","configure","child"]).forEach(function(i){return l[i]=function(){return s[i].apply(s,arguments)}}),Object.defineProperty(l,"level",{get:function(){return s.level},set:function(i){s.level=i}}),Object.defineProperty(l,"exceptions",{get:function(){return s.exceptions}}),["exitOnError"].forEach(function(i){Object.defineProperty(l,i,{get:function(){return s[i]},set:function(c){s[i]=c}})}),Object.defineProperty(l,"default",{get:function(){return{exceptionHandlers:s.exceptionHandlers,rejectionHandlers:s.rejectionHandlers,transports:s.transports}}}),o.deprecated(l,"setLevels"),o.forFunctions(l,"useFormat",["cli"]),o.forProperties(l,"useFormat",["padLevels","stripColors"]),o.forFunctions(l,"deprecated",["addRewriter","addFilter","clone","extend"]),o.forProperties(l,"deprecated",["emitErrs","levelLength"]),o.moved(l,"createLogger","Logger")},function(e,t,r){var n=r(10),o=r(141),l=r(3).LEVEL,s=e.exports=function(){var i=this,c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};o.call(this,{objectMode:!0,highWaterMark:c.highWaterMark}),this.format=c.format,this.level=c.level,this.handleExceptions=c.handleExceptions,this.handleRejections=c.handleRejections,this.silent=c.silent,c.log&&(this.log=c.log),c.logv&&(this.logv=c.logv),c.close&&(this.close=c.close),this.once("pipe",function(u){i.levels=u.levels,i.parent=u}),this.once("unpipe",function(u){u===i.parent&&(i.parent=null,i.close&&i.close())})};n.inherits(s,o),s.prototype._write=function(i,c,u){if(this.silent||i.exception===!0&&!this.handleExceptions)return u(null);var b=this.level||this.parent&&this.parent.level;if(!b||this.levels[b]>=this.levels[i[l]]){if(i&&!this.format)return this.log(i,u);var A=void 0,_=void 0;try{_=this.format.transform(Object.assign({},i),this.format.options)}catch(v){A=v}if(A||!_){if(u(),A)throw A;return}return this.log(_,u)}return u(null)},s.prototype._writev=function(i,c){if(this.logv){var u=i.filter(this._accept,this);return u.length?this.logv(u,c):c(null)}for(var b=0;b<i.length;b++)if(this._accept(i[b]))if(!i[b].chunk||this.format){var A=void 0,_=void 0;try{_=this.format.transform(Object.assign({},i[b].chunk),this.format.options)}catch(v){A=v}if(A||!_){if(i[b].callback(),A)throw c(null),A}else this.log(_,i[b].callback)}else this.log(i[b].chunk,i[b].callback);return c(null)},s.prototype._accept=function(i){var c=i.chunk;if(this.silent)return!1;var u=this.level||this.parent&&this.parent.level;return!(c.exception!==!0&&u&&!(this.levels[u]>=this.levels[c[l]])||!this.handleExceptions&&c.exception===!0)},s.prototype._nop=function(){},e.exports.LegacyTransportStream=r(147)},function(e,t,r){var n,o=typeof Reflect=="object"?Reflect:null,l=o&&typeof o.apply=="function"?o.apply:function(w,P,N){return Function.prototype.apply.call(w,P,N)};n=o&&typeof o.ownKeys=="function"?o.ownKeys:Object.getOwnPropertySymbols?function(w){return Object.getOwnPropertyNames(w).concat(Object.getOwnPropertySymbols(w))}:function(w){return Object.getOwnPropertyNames(w)};var s=Number.isNaN||function(w){return w!=w};function i(){i.init.call(this)}e.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var c=10;function u(w){return w._maxListeners===void 0?i.defaultMaxListeners:w._maxListeners}function b(w,P,N,T){var R,d,I,Q;if(typeof N!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof N);if((d=w._events)===void 0?(d=w._events=Object.create(null),w._eventsCount=0):(d.newListener!==void 0&&(w.emit("newListener",P,N.listener?N.listener:N),d=w._events),I=d[P]),I===void 0)I=d[P]=N,++w._eventsCount;else if(typeof I=="function"?I=d[P]=T?[N,I]:[I,N]:T?I.unshift(N):I.push(N),(R=u(w))>0&&I.length>R&&!I.warned){I.warned=!0;var Z=new Error("Possible EventEmitter memory leak detected. "+I.length+" "+String(P)+" listeners added. Use emitter.setMaxListeners() to increase limit");Z.name="MaxListenersExceededWarning",Z.emitter=w,Z.type=P,Z.count=I.length,Q=Z,console&&console.warn&&console.warn(Q)}return w}function A(){for(var w=[],P=0;P<arguments.length;P++)w.push(arguments[P]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,l(this.listener,this.target,w))}function _(w,P,N){var T={fired:!1,wrapFn:void 0,target:w,type:P,listener:N},R=A.bind(T);return R.listener=N,T.wrapFn=R,R}function v(w,P,N){var T=w._events;if(T===void 0)return[];var R=T[P];return R===void 0?[]:typeof R=="function"?N?[R.listener||R]:[R]:N?function(d){for(var I=new Array(d.length),Q=0;Q<I.length;++Q)I[Q]=d[Q].listener||d[Q];return I}(R):S(R,R.length)}function f(w){var P=this._events;if(P!==void 0){var N=P[w];if(typeof N=="function")return 1;if(N!==void 0)return N.length}return 0}function S(w,P){for(var N=new Array(P),T=0;T<P;++T)N[T]=w[T];return N}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(w){if(typeof w!="number"||w<0||s(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");c=w}}),i.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(w){if(typeof w!="number"||w<0||s(w))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+w+".");return this._maxListeners=w,this},i.prototype.getMaxListeners=function(){return u(this)},i.prototype.emit=function(w){for(var P=[],N=1;N<arguments.length;N++)P.push(arguments[N]);var T=w==="error",R=this._events;if(R!==void 0)T=T&&R.error===void 0;else if(!T)return!1;if(T){var d;if(P.length>0&&(d=P[0]),d instanceof Error)throw d;var I=new Error("Unhandled error."+(d?" ("+d.message+")":""));throw I.context=d,I}var Q=R[w];if(Q===void 0)return!1;if(typeof Q=="function")l(Q,this,P);else{var Z=Q.length,h=S(Q,Z);for(N=0;N<Z;++N)l(h[N],this,P)}return!0},i.prototype.addListener=function(w,P){return b(this,w,P,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(w,P){return b(this,w,P,!0)},i.prototype.once=function(w,P){if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P);return this.on(w,_(this,w,P)),this},i.prototype.prependOnceListener=function(w,P){if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P);return this.prependListener(w,_(this,w,P)),this},i.prototype.removeListener=function(w,P){var N,T,R,d,I;if(typeof P!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof P);if((T=this._events)===void 0)return this;if((N=T[w])===void 0)return this;if(N===P||N.listener===P)--this._eventsCount==0?this._events=Object.create(null):(delete T[w],T.removeListener&&this.emit("removeListener",w,N.listener||P));else if(typeof N!="function"){for(R=-1,d=N.length-1;d>=0;d--)if(N[d]===P||N[d].listener===P){I=N[d].listener,R=d;break}if(R<0)return this;R===0?N.shift():function(Q,Z){for(;Z+1<Q.length;Z++)Q[Z]=Q[Z+1];Q.pop()}(N,R),N.length===1&&(T[w]=N[0]),T.removeListener!==void 0&&this.emit("removeListener",w,I||P)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(w){var P,N,T;if((N=this._events)===void 0)return this;if(N.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):N[w]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete N[w]),this;if(arguments.length===0){var R,d=Object.keys(N);for(T=0;T<d.length;++T)(R=d[T])!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(P=N[w])=="function")this.removeListener(w,P);else if(P!==void 0)for(T=P.length-1;T>=0;T--)this.removeListener(w,P[T]);return this},i.prototype.listeners=function(w){return v(this,w,!0)},i.prototype.rawListeners=function(w){return v(this,w,!1)},i.listenerCount=function(w,P){return typeof w.listenerCount=="function"?w.listenerCount(P):f.call(w,P)},i.prototype.listenerCount=f,i.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){var n=r(146).Buffer,o=n.isEncoding||function(f){switch((f=""+f)&&f.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function l(f){var S;switch(this.encoding=function(w){var P=function(N){if(!N)return"utf8";for(var T;;)switch(N){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return N;default:if(T)return;N=(""+N).toLowerCase(),T=!0}}(w);if(typeof P!="string"&&(n.isEncoding===o||!o(w)))throw new Error("Unknown encoding: "+w);return P||w}(f),this.encoding){case"utf16le":this.text=c,this.end=u,S=4;break;case"utf8":this.fillLast=i,S=4;break;case"base64":this.text=b,this.end=A,S=3;break;default:return this.write=_,void(this.end=v)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(S)}function s(f){return f<=127?0:f>>5==6?2:f>>4==14?3:f>>3==30?4:f>>6==2?-1:-2}function i(f){var S=this.lastTotal-this.lastNeed,w=function(P,N,T){if((192&N[0])!=128)return P.lastNeed=0,"\uFFFD";if(P.lastNeed>1&&N.length>1){if((192&N[1])!=128)return P.lastNeed=1,"\uFFFD";if(P.lastNeed>2&&N.length>2&&(192&N[2])!=128)return P.lastNeed=2,"\uFFFD"}}(this,f);return w!==void 0?w:this.lastNeed<=f.length?(f.copy(this.lastChar,S,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(f.copy(this.lastChar,S,0,f.length),void(this.lastNeed-=f.length))}function c(f,S){if((f.length-S)%2==0){var w=f.toString("utf16le",S);if(w){var P=w.charCodeAt(w.length-1);if(P>=55296&&P<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=f[f.length-2],this.lastChar[1]=f[f.length-1],w.slice(0,-1)}return w}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=f[f.length-1],f.toString("utf16le",S,f.length-1)}function u(f){var S=f&&f.length?this.write(f):"";if(this.lastNeed){var w=this.lastTotal-this.lastNeed;return S+this.lastChar.toString("utf16le",0,w)}return S}function b(f,S){var w=(f.length-S)%3;return w===0?f.toString("base64",S):(this.lastNeed=3-w,this.lastTotal=3,w===1?this.lastChar[0]=f[f.length-1]:(this.lastChar[0]=f[f.length-2],this.lastChar[1]=f[f.length-1]),f.toString("base64",S,f.length-w))}function A(f){var S=f&&f.length?this.write(f):"";return this.lastNeed?S+this.lastChar.toString("base64",0,3-this.lastNeed):S}function _(f){return f.toString(this.encoding)}function v(f){return f&&f.length?this.write(f):""}t.StringDecoder=l,l.prototype.write=function(f){if(f.length===0)return"";var S,w;if(this.lastNeed){if((S=this.fillLast(f))===void 0)return"";w=this.lastNeed,this.lastNeed=0}else w=0;return w<f.length?S?S+this.text(f,w):this.text(f,w):S||""},l.prototype.end=function(f){var S=f&&f.length?this.write(f):"";return this.lastNeed?S+"\uFFFD":S},l.prototype.text=function(f,S){var w=function(N,T,R){var d=T.length-1;if(d<R)return 0;var I=s(T[d]);return I>=0?(I>0&&(N.lastNeed=I-1),I):--d<R||I===-2?0:(I=s(T[d]))>=0?(I>0&&(N.lastNeed=I-2),I):--d<R||I===-2?0:(I=s(T[d]))>=0?(I>0&&(I===2?I=0:N.lastNeed=I-3),I):0}(this,f,S);if(!this.lastNeed)return f.toString("utf8",S);this.lastTotal=w;var P=f.length-(w-this.lastNeed);return f.copy(this.lastChar,0,P),f.toString("utf8",S,P)},l.prototype.fillLast=function(f){if(this.lastNeed<=f.length)return f.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);f.copy(this.lastChar,this.lastTotal-this.lastNeed,0,f.length),this.lastNeed-=f.length}},function(e,t,r){var n=r(13),o=Object.keys||function(f){var S=[];for(var w in f)S.push(w);return S};e.exports=A;var l=r(14);l.inherits=r(7);var s=r(67),i=r(44);l.inherits(A,s);for(var c=o(i.prototype),u=0;u<c.length;u++){var b=c[u];A.prototype[b]||(A.prototype[b]=i.prototype[b])}function A(f){if(!(this instanceof A))return new A(f);s.call(this,f),i.call(this,f),f&&f.readable===!1&&(this.readable=!1),f&&f.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,f&&f.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||n.nextTick(v,this)}function v(f){f.end()}Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(A.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(f){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=f,this._writableState.destroyed=f)}}),A.prototype._destroy=function(f,S){this.push(null),this.end(),n.nextTick(S,f)}},function(e,t,r){(function(n){function o(M){var z=0;return function(){return z<M.length?{done:!1,value:M[z++]}:{done:!0}}}var l=typeof Object.defineProperties=="function"?Object.defineProperty:function(M,z,J){M!=Array.prototype&&M!=Object.prototype&&(M[z]=J.value)},s=function(M){M=[typeof window=="object"&&window,typeof self=="object"&&self,typeof n=="object"&&n,M];for(var z=0;z<M.length;++z){var J=M[z];if(J&&J.Math==Math)return J}throw Error("Cannot find global object")}(this);function i(M,z){if(z){var J=s;M=M.split(".");for(var re=0;re<M.length-1;re++){var se=M[re];se in J||(J[se]={}),J=J[se]}(z=z(re=J[M=M[M.length-1]]))!=re&&z!=null&&l(J,M,{configurable:!0,writable:!0,value:z})}}function c(M){var z=typeof Symbol!="undefined"&&Symbol.iterator&&M[Symbol.iterator];return z?z.call(M):{next:o(M)}}i("Object.is",function(M){return M||function(z,J){return z===J?z!==0||1/z==1/J:z!=z&&J!=J}}),i("Array.prototype.includes",function(M){return M||function(z,J){var re=this;re instanceof String&&(re=String(re));var se=re.length;for(0>(J=J||0)&&(J=Math.max(J+se,0));J<se;J++){var fe=re[J];if(fe===z||Object.is(fe,z))return!0}return!1}}),i("Promise",function(M){function z(oe){this.b=0,this.c=void 0,this.a=[];var le=this.f();try{oe(le.resolve,le.reject)}catch(ve){le.reject(ve)}}function J(){this.a=null}function re(oe){return oe instanceof z?oe:new z(function(le){le(oe)})}if(M)return M;J.prototype.b=function(oe){if(this.a==null){this.a=[];var le=this;this.c(function(){le.g()})}this.a.push(oe)};var se=s.setTimeout;J.prototype.c=function(oe){se(oe,0)},J.prototype.g=function(){for(;this.a&&this.a.length;){var oe=this.a;this.a=[];for(var le=0;le<oe.length;++le){var ve=oe[le];oe[le]=null;try{ve()}catch(be){this.f(be)}}}this.a=null},J.prototype.f=function(oe){this.c(function(){throw oe})},z.prototype.f=function(){function oe(be){return function(_e){ve||(ve=!0,be.call(le,_e))}}var le=this,ve=!1;return{resolve:oe(this.m),reject:oe(this.g)}},z.prototype.m=function(oe){if(oe===this)this.g(new TypeError("A Promise cannot resolve to itself"));else if(oe instanceof z)this.o(oe);else{e:switch(typeof oe){case"object":var le=oe!=null;break e;case"function":le=!0;break e;default:le=!1}le?this.l(oe):this.h(oe)}},z.prototype.l=function(oe){var le=void 0;try{le=oe.then}catch(ve){return void this.g(ve)}typeof le=="function"?this.u(le,oe):this.h(oe)},z.prototype.g=function(oe){this.i(2,oe)},z.prototype.h=function(oe){this.i(1,oe)},z.prototype.i=function(oe,le){if(this.b!=0)throw Error("Cannot settle("+oe+", "+le+"): Promise already settled in state"+this.b);this.b=oe,this.c=le,this.j()},z.prototype.j=function(){if(this.a!=null){for(var oe=0;oe<this.a.length;++oe)fe.b(this.a[oe]);this.a=null}};var fe=new J;return z.prototype.o=function(oe){var le=this.f();oe.w(le.resolve,le.reject)},z.prototype.u=function(oe,le){var ve=this.f();try{oe.call(le,ve.resolve,ve.reject)}catch(be){ve.reject(be)}},z.prototype.then=function(oe,le){function ve(Ie,xe){return typeof Ie=="function"?function(Ne){try{be(Ie(Ne))}catch(Ue){_e(Ue)}}:xe}var be,_e,Ce=new z(function(Ie,xe){be=Ie,_e=xe});return this.w(ve(oe,be),ve(le,_e)),Ce},z.prototype.catch=function(oe){return this.then(void 0,oe)},z.prototype.w=function(oe,le){function ve(){switch(be.b){case 1:oe(be.c);break;case 2:le(be.c);break;default:throw Error("Unexpected state: "+be.b)}}var be=this;this.a==null?fe.b(ve):this.a.push(ve)},z.resolve=re,z.reject=function(oe){return new z(function(le,ve){ve(oe)})},z.race=function(oe){return new z(function(le,ve){for(var be=c(oe),_e=be.next();!_e.done;_e=be.next())re(_e.value).w(le,ve)})},z.all=function(oe){var le=c(oe),ve=le.next();return ve.done?re([]):new z(function(be,_e){function Ce(Ne){return function(Ue){Ie[Ne]=Ue,--xe==0&&be(Ie)}}var Ie=[],xe=0;do Ie.push(void 0),xe++,re(ve.value).w(Ce(Ie.length-1),_e),ve=le.next();while(!ve.done)})},z});var u=u||{},b=this||self;function A(M,z){M=M.split("."),z=z||b;for(var J=0;J<M.length;J++)if((z=z[M[J]])==null)return null;return z}function _(){}function v(M){var z=typeof M;if(z=="object"){if(!M)return"null";if(M instanceof Array)return"array";if(M instanceof Object)return z;var J=Object.prototype.toString.call(M);if(J=="[object Window]")return"object";if(J=="[object Array]"||typeof M.length=="number"&&M.splice!==void 0&&M.propertyIsEnumerable!==void 0&&!M.propertyIsEnumerable("splice"))return"array";if(J=="[object Function]"||M.call!==void 0&&M.propertyIsEnumerable!==void 0&&!M.propertyIsEnumerable("call"))return"function"}else if(z=="function"&&M.call===void 0)return"object";return z}function f(M){var z=typeof M;return z=="object"&&M!=null||z=="function"}function S(M,z,J){return M.call.apply(M.bind,arguments)}function w(M,z,J){if(!M)throw Error();if(2<arguments.length){var re=Array.prototype.slice.call(arguments,2);return function(){var se=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(se,re),M.apply(z,se)}}return function(){return M.apply(z,arguments)}}function P(M,z,J){return(P=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?S:w).apply(null,arguments)}function N(M,z){function J(){}J.prototype=z.prototype,M.S=z.prototype,M.prototype=new J,M.prototype.constructor=M}function T(){this.a={}}function R(M,z,J,re){this.f=M,this.c=z,this.b=J,this.a=re}function d(M,z,J,re){J=J===void 0?{}:J,this.c=M,this.a=J,this.b=z,this.f=re===void 0?null:re}function I(M,z,J,re,se,fe){this.name=M,this.a=se,this.b=fe}function Q(M,z,J){J=J===void 0?{}:J;var re=re===void 0?new T:re;return new R(z,M,J,re)}function Z(M,z,J,re){return re instanceof I?re:new I(M,J,re.b||z.constructor,re.f,re.a,re.c)}function h(M){this.a=M}function p(M){switch(M){case 0:return"No Error";case 1:return"Access denied to content document";case 2:return"File not found";case 3:return"Firefox silently errored";case 4:return"Application custom error";case 5:return"An exception occurred";case 6:return"Http response at 400 or 500 level";case 7:return"Request was aborted";case 8:return"Request timed out";case 9:return"The resource is not available offline";default:return"Unrecognized error code"}}function C(M){if(Error.captureStackTrace)Error.captureStackTrace(this,C);else{var z=Error().stack;z&&(this.stack=z)}M&&(this.message=String(M))}function m(M,z){for(var J="",re=(M=M.split("%s")).length-1,se=0;se<re;se++)J+=M[se]+(se<z.length?z[se]:"%s");C.call(this,J+M[re])}function x(){this.j=null,this.i=[],this.l=0,this.b=F,this.f=this.a=this.h=0,this.c=null,this.g=0}T.prototype.get=function(M){return this.a[M]},T.prototype.f=function(){return Object.keys(this.a)},R.prototype.getRequestMessage=function(){return this.f},R.prototype.getMethodDescriptor=function(){return this.c},R.prototype.getMetadata=function(){return this.b},R.prototype.getCallOptions=function(){return this.a},d.prototype.getResponseMessage=function(){return this.c},d.prototype.getMetadata=function(){return this.a},d.prototype.getMethodDescriptor=function(){return this.b},d.prototype.getStatus=function(){return this.f},h.prototype.on=function(M,z){return M=="data"||M=="error"?this:this.a.on(M,z)},h.prototype.removeListener=function(M,z){return this.a.removeListener(M,z)},h.prototype.cancel=function(){this.a.cancel()},N(C,Error),C.prototype.name="CustomError",N(m,C),m.prototype.name="AssertionError";var F=0,D=1,O=2,L=3,k=0,E=128;function g(M,z,J,re){throw M.b=L,M.j="The stream is broken @"+M.l+"/"+J+". Error: "+re+`. With input:
|
|
16
|
+
`+z,Error(M.j)}var U=Array.prototype.indexOf?function(M,z){return Array.prototype.indexOf.call(M,z,void 0)}:function(M,z){if(typeof M=="string")return typeof z!="string"||z.length!=1?-1:M.indexOf(z,0);for(var J=0;J<M.length;J++)if(J in M&&M[J]===z)return J;return-1},B,G=String.prototype.trim?function(M){return M.trim()}:function(M){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(M)[1]};function Y(M,z){return M.indexOf(z)!=-1}function K(M,z){return M<z?-1:M>z?1:0}e:{var H=b.navigator;if(H){var V=H.userAgent;if(V){B=V;break e}}B=""}var y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function j(M){var z=1;M=M.split(":");for(var J=[];0<z&&M.length;)J.push(M.shift()),z--;return M.length&&J.push(M.join(":")),J}function W(M){return W[" "](M),M}W[" "]=_;var ee,X,ne=Y(B,"Opera"),ie=Y(B,"Trident")||Y(B,"MSIE"),he=Y(B,"Edge"),Se=Y(B,"Gecko")&&!(Y(B.toLowerCase(),"webkit")&&!Y(B,"Edge"))&&!(Y(B,"Trident")||Y(B,"MSIE"))&&!Y(B,"Edge"),we=Y(B.toLowerCase(),"webkit")&&!Y(B,"Edge");function Ee(){var M=b.document;return M?M.documentMode:void 0}e:{var ye="",q=(X=B,Se?/rv:([^\);]+)(\)|;)/.exec(X):he?/Edge\/([\d\.]+)/.exec(X):ie?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(X):we?/WebKit\/(\S+)/.exec(X):ne?/(?:Version)[ \/]?(\S+)/.exec(X):void 0);if(q&&(ye=q?q[1]:""),ie){var $=Ee();if($!=null&&$>parseFloat(ye)){ee=String($);break e}}ee=ye}var te,ue={};function ae(M){return function(z,J){var re=ue;return Object.prototype.hasOwnProperty.call(re,z)?re[z]:re[z]=J(z)}(M,function(){for(var z=0,J=G(String(ee)).split("."),re=G(String(M)).split("."),se=Math.max(J.length,re.length),fe=0;z==0&&fe<se;fe++){var oe=J[fe]||"",le=re[fe]||"";do{if(oe=/(\d*)(\D*)(.*)/.exec(oe)||["","","",""],le=/(\d*)(\D*)(.*)/.exec(le)||["","","",""],oe[0].length==0&&le[0].length==0)break;z=K(oe[1].length==0?0:parseInt(oe[1],10),le[1].length==0?0:parseInt(le[1],10))||K(oe[2].length==0,le[2].length==0)||K(oe[2],le[2]),oe=oe[3],le=le[3]}while(z==0)}return 0<=z})}if(b.document&&ie){var de=Ee();te=de||parseInt(ee,10)||void 0}else te=void 0;var me=te;function pe(){this.F=this.F}pe.prototype.F=!1;var ge,ce=Object.freeze||function(M){return M};(ge=!ie)||(ge=9<=Number(me));var Te=ge,Re=ie&&!ae("9"),Pe=function(){if(!b.addEventListener||!Object.defineProperty)return!1;var M=!1,z=Object.defineProperty({},"passive",{get:function(){M=!0}});try{b.addEventListener("test",_,z),b.removeEventListener("test",_,z)}catch{}return M}();function Le(M,z){this.type=M,this.a=this.target=z,this.defaultPrevented=!1}function Fe(M,z){if(Le.call(this,M?M.type:""),this.relatedTarget=this.a=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.pointerId=0,this.pointerType="",this.c=null,M){var J=this.type=M.type,re=M.changedTouches&&M.changedTouches.length?M.changedTouches[0]:null;if(this.target=M.target||M.srcElement,this.a=z,z=M.relatedTarget){if(Se){e:{try{W(z.nodeName);var se=!0;break e}catch{}se=!1}se||(z=null)}}else J=="mouseover"?z=M.fromElement:J=="mouseout"&&(z=M.toElement);this.relatedTarget=z,re?(this.clientX=re.clientX!==void 0?re.clientX:re.pageX,this.clientY=re.clientY!==void 0?re.clientY:re.pageY,this.screenX=re.screenX||0,this.screenY=re.screenY||0):(this.clientX=M.clientX!==void 0?M.clientX:M.pageX,this.clientY=M.clientY!==void 0?M.clientY:M.pageY,this.screenX=M.screenX||0,this.screenY=M.screenY||0),this.button=M.button,this.key=M.key||"",this.ctrlKey=M.ctrlKey,this.altKey=M.altKey,this.shiftKey=M.shiftKey,this.metaKey=M.metaKey,this.pointerId=M.pointerId||0,this.pointerType=typeof M.pointerType=="string"?M.pointerType:ze[M.pointerType]||"",this.c=M,M.defaultPrevented&&this.b()}}Le.prototype.b=function(){this.defaultPrevented=!0},N(Fe,Le);var ze=ce({2:"touch",3:"pen",4:"mouse"});Fe.prototype.b=function(){Fe.S.b.call(this);var M=this.c;if(M.preventDefault)M.preventDefault();else if(M.returnValue=!1,Re)try{(M.ctrlKey||112<=M.keyCode&&123>=M.keyCode)&&(M.keyCode=-1)}catch{}};var De="closure_listenable_"+(1e6*Math.random()|0),We=0;function Be(M,z,J,re,se){this.listener=M,this.proxy=null,this.src=z,this.type=J,this.capture=!!re,this.A=se,this.key=++We,this.s=this.v=!1}function ke(M){M.s=!0,M.listener=null,M.proxy=null,M.src=null,M.A=null}function qe(M){this.src=M,this.a={},this.b=0}function Ge(M,z){var J=z.type;if(J in M.a){var re,se=M.a[J],fe=U(se,z);(re=0<=fe)&&Array.prototype.splice.call(se,fe,1),re&&(ke(z),M.a[J].length==0&&(delete M.a[J],M.b--))}}function gt(M,z,J,re){for(var se=0;se<M.length;++se){var fe=M[se];if(!fe.s&&fe.listener==z&&fe.capture==!!J&&fe.A==re)return se}return-1}qe.prototype.add=function(M,z,J,re,se){var fe=M.toString();(M=this.a[fe])||(M=this.a[fe]=[],this.b++);var oe=gt(M,z,re,se);return-1<oe?(z=M[oe],J||(z.v=!1)):((z=new Be(z,this.src,fe,!!re,se)).v=J,M.push(z)),z};var ft="closure_lm_"+(1e6*Math.random()|0),ht={};function at(M,z,J,re,se){if(re&&re.once)(function oe(le,ve,be,_e,Ce){if(Array.isArray(ve))for(var Ie=0;Ie<ve.length;Ie++)oe(le,ve[Ie],be,_e,Ce);else be=dt(be),le&&le[De]?le.f.add(String(ve),be,!0,f(_e)?!!_e.capture:!!_e,Ce):Rt(le,ve,be,!0,_e,Ce)})(M,z,J,re,se);else if(Array.isArray(z))for(var fe=0;fe<z.length;fe++)at(M,z[fe],J,re,se);else J=dt(J),M&&M[De]?M.f.add(String(z),J,!1,f(re)?!!re.capture:!!re,se):Rt(M,z,J,!1,re,se)}function Rt(M,z,J,re,se,fe){if(!z)throw Error("Invalid event type");var oe=f(se)?!!se.capture:!!se,le=lt(M);if(le||(M[ft]=le=new qe(M)),!(J=le.add(z,J,re,oe,fe)).proxy)if(re=function(){var ve=Kt,be=Te?function(_e){return ve.call(be.src,be.listener,_e)}:function(_e){if(!(_e=ve.call(be.src,be.listener,_e)))return _e};return be}(),J.proxy=re,re.src=M,re.listener=J,M.addEventListener)Pe||(se=oe),se===void 0&&(se=!1),M.addEventListener(z.toString(),re,se);else if(M.attachEvent)M.attachEvent(Ot(z.toString()),re);else{if(!M.addListener||!M.removeListener)throw Error("addEventListener and attachEvent are unavailable.");M.addListener(re)}}function At(M){if(typeof M!="number"&&M&&!M.s){var z=M.src;if(z&&z[De])Ge(z.f,M);else{var J=M.type,re=M.proxy;z.removeEventListener?z.removeEventListener(J,re,M.capture):z.detachEvent?z.detachEvent(Ot(J),re):z.addListener&&z.removeListener&&z.removeListener(re),(J=lt(z))?(Ge(J,M),J.b==0&&(J.src=null,z[ft]=null)):ke(M)}}}function Ot(M){return M in ht?ht[M]:ht[M]="on"+M}function jt(M,z,J,re){var se=!0;if((M=lt(M))&&(z=M.a[z.toString()]))for(z=z.concat(),M=0;M<z.length;M++){var fe=z[M];fe&&fe.capture==J&&!fe.s&&(fe=It(fe,re),se=se&&fe!==!1)}return se}function It(M,z){var J=M.listener,re=M.A||M.src;return M.v&&At(M),J.call(re,z)}function Kt(M,z){if(M.s)return!0;if(!Te){var J=z||A("window.event");z=new Fe(J,this);var re=!0;if(!(0>J.keyCode||J.returnValue!=null)){e:{var se=!1;if(J.keyCode==0)try{J.keyCode=-1;break e}catch{se=!0}(se||J.returnValue==null)&&(J.returnValue=!0)}for(J=[],se=z.a;se;se=se.parentNode)J.push(se);for(M=M.type,se=J.length-1;0<=se;se--){z.a=J[se];var fe=jt(J[se],M,!0,z);re=re&&fe}for(se=0;se<J.length;se++)z.a=J[se],fe=jt(J[se],M,!1,z),re=re&&fe}return re}return It(M,new Fe(z,this))}function lt(M){return(M=M[ft])instanceof qe?M:null}var pt="__closure_events_fn_"+(1e9*Math.random()>>>0);function dt(M){return v(M)=="function"?M:(M[pt]||(M[pt]=function(z){return M.handleEvent(z)}),M[pt])}function et(){pe.call(this),this.f=new qe(this),this.N=this}function Ze(M,z){M=M.N;var J=z.type||z;if(typeof z=="string")z=new Le(z,M);else if(z instanceof Le)z.target=z.target||M;else{var re=z;(function(se,fe){for(var oe,le,ve=1;ve<arguments.length;ve++){for(oe in le=arguments[ve])se[oe]=le[oe];for(var be=0;be<y.length;be++)oe=y[be],Object.prototype.hasOwnProperty.call(le,oe)&&(se[oe]=le[oe])}})(z=new Le(J,M),re)}Ct(M=z.a=M,J,!0,z),Ct(M,J,!1,z)}function Ct(M,z,J,re){if(z=M.f.a[String(z)]){z=z.concat();for(var se=!0,fe=0;fe<z.length;++fe){var oe=z[fe];if(oe&&!oe.s&&oe.capture==J){var le=oe.listener,ve=oe.A||oe.src;oe.v&&Ge(M.f,oe),se=le.call(ve,re)!==!1&&se}}}}function Mt(M,z,J){if(v(M)=="function")J&&(M=P(M,J));else{if(!M||typeof M.handleEvent!="function")throw Error("Invalid listener argument");M=P(M.handleEvent,M)}return 2147483647<Number(z)?-1:b.setTimeout(M,z||0)}function mt(M,z,J){this.reset(M,z,J,void 0,void 0)}N(et,pe),et.prototype[De]=!0,et.prototype.addEventListener=function(M,z,J,re){at(this,M,z,J,re)},et.prototype.removeEventListener=function(M,z,J,re){(function se(fe,oe,le,ve,be){if(Array.isArray(oe))for(var _e=0;_e<oe.length;_e++)se(fe,oe[_e],le,ve,be);else ve=f(ve)?!!ve.capture:!!ve,le=dt(le),fe&&fe[De]?(fe=fe.f,(oe=String(oe).toString())in fe.a&&-1<(le=gt(_e=fe.a[oe],le,ve,be))&&(ke(_e[le]),Array.prototype.splice.call(_e,le,1),_e.length==0&&(delete fe.a[oe],fe.b--))):fe&&(fe=lt(fe))&&(oe=fe.a[oe.toString()],fe=-1,oe&&(fe=gt(oe,le,ve,be)),(le=-1<fe?oe[fe]:null)&&At(le))})(this,M,z,J,re)},mt.prototype.a=null;function yt(M){this.f=M,this.b=this.c=this.a=null}function ut(M,z){this.name=M,this.value=z}mt.prototype.reset=function(M,z,J,re,se){delete this.a},ut.prototype.toString=function(){return this.name};var Pt=new ut("SEVERE",1e3),Jt=new ut("CONFIG",700),Xt=new ut("FINE",500);function Nt(M){return M.c?M.c:M.a?Nt(M.a):(function(z,J){throw new m("Failure"+(z?": "+z:""),Array.prototype.slice.call(arguments,1))}("Root logger has no level set."),null)}yt.prototype.log=function(M,z,J){if(M.value>=Nt(this).value)for(v(z)=="function"&&(z=z()),M=new mt(M,String(z),this.f),J&&(M.a=J),J=this;J;)J=J.a};var bt,vt={},ct=null;function He(M,z){M&&M.log(Xt,z,void 0)}function Lt(){}function xt(M){var z;return(z=M.a)||(z={},Bt(M)&&(z[0]=!0,z[1]=!0),z=M.a=z),z}function Ut(){}function Dt(M){return(M=Bt(M))?new ActiveXObject(M):new XMLHttpRequest}function Bt(M){if(!M.b&&typeof XMLHttpRequest=="undefined"&&typeof ActiveXObject!="undefined"){for(var z=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],J=0;J<z.length;J++){var re=z[J];try{return new ActiveXObject(re),M.b=re}catch{}}throw Error("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed")}return M.b}function Xe(M,z){this.b={},this.a=[],this.c=0;var J=arguments.length;if(1<J){if(J%2)throw Error("Uneven number of arguments");for(var re=0;re<J;re+=2)this.set(arguments[re],arguments[re+1])}else M&&kt(this,M)}function _t(M){if(M.c!=M.a.length){for(var z=0,J=0;z<M.a.length;){var re=M.a[z];tt(M.b,re)&&(M.a[J++]=re),z++}M.a.length=J}if(M.c!=M.a.length){var se={};for(J=z=0;z<M.a.length;)tt(se,re=M.a[z])||(M.a[J++]=re,se[re]=1),z++;M.a.length=J}}function kt(M,z){if(z instanceof Xe)for(var J=z.f(),re=0;re<J.length;re++)M.set(J[re],z.get(J[re]));else for(J in z)M.set(J,z[J])}function tt(M,z){return Object.prototype.hasOwnProperty.call(M,z)}Lt.prototype.a=null,N(Ut,Lt),bt=new Ut,Xe.prototype.f=function(){return _t(this),this.a.concat()},Xe.prototype.get=function(M,z){return tt(this.b,M)?this.b[M]:z},Xe.prototype.set=function(M,z){tt(this.b,M)||(this.c++,this.a.push(M)),this.b[M]=z},Xe.prototype.forEach=function(M,z){for(var J=this.f(),re=0;re<J.length;re++){var se=J[re],fe=this.get(se);M.call(z,fe,se,this)}};var Qt=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^\\/?#]*)@)?([^\\/?#]*?)(?::([0-9]+))?(?=[\\/?#]|$))?([^?#]+)?(?:\?([^#]*))?(?:#([\s\S]*))?$/;function Je(M){et.call(this),this.headers=new Xe,this.D=M||null,this.c=!1,this.C=this.a=null,this.J=this.o="",this.g=0,this.i="",this.h=this.I=this.m=this.G=!1,this.l=0,this.u=null,this.j=Ft,this.B=this.H=!1}N(Je,et);var Ft="",er=Je.prototype,tr=function M(z){var J;if(ct||(ct=new yt(""),vt[""]=ct,ct.c=Jt),!(J=vt[z])){J=new yt(z);var re=z.lastIndexOf("."),se=z.substr(re+1);(re=M(z.substr(0,re))).b||(re.b={}),re.b[se]=J,J.a=re,vt[z]=J}return J}("goog.net.XhrIo");er.b=tr;var rr=/^https?$/i,nr=["POST","PUT"];function or(M,z,J){if(M.a)throw Error("[goog.net.XhrIo] Object is active with another request="+M.o+"; newUri="+z);M.o=z,M.i="",M.g=0,M.J="POST",M.G=!1,M.c=!0,M.a=M.D?Dt(M.D):Dt(bt),M.C=M.D?xt(M.D):xt(bt),M.a.onreadystatechange=P(M.K,M);try{He(M.b,Ke(M,"Opening Xhr")),M.I=!0,M.a.open("POST",String(z),!0),M.I=!1}catch(fe){return He(M.b,Ke(M,"Error opening Xhr: "+fe.message)),void Wt(M,fe)}z=J||"";var re=function(fe){e:{for(var oe=ir,le=fe.length,ve=typeof fe=="string"?fe.split(""):fe,be=0;be<le;be++)if(be in ve&&oe.call(void 0,ve[be],be,fe)){oe=be;break e}oe=-1}return 0>oe?null:typeof fe=="string"?fe.charAt(oe):fe[oe]}((J=new Xe(M.headers)).f()),se=b.FormData&&z instanceof b.FormData;!(0<=U(nr,"POST"))||re||se||J.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),J.forEach(function(fe,oe){this.a.setRequestHeader(oe,fe)},M),M.j&&(M.a.responseType=M.j),"withCredentials"in M.a&&M.a.withCredentials!==M.H&&(M.a.withCredentials=M.H);try{Ht(M),0<M.l&&(M.B=function(fe){return ie&&ae(9)&&typeof fe.timeout=="number"&&fe.ontimeout!==void 0}(M.a),He(M.b,Ke(M,"Will abort after "+M.l+"ms if incomplete, xhr2 "+M.B)),M.B?(M.a.timeout=M.l,M.a.ontimeout=P(M.L,M)):M.u=Mt(M.L,M.l,M)),He(M.b,Ke(M,"Sending request")),M.m=!0,M.a.send(z),M.m=!1}catch(fe){He(M.b,Ke(M,"Send error: "+fe.message)),Wt(M,fe)}}function ir(M){return M.toLowerCase()=="content-type"}function Wt(M,z){M.c=!1,M.a&&(M.h=!0,M.a.abort(),M.h=!1),M.i=z,M.g=5,Vt(M),St(M)}function Vt(M){M.G||(M.G=!0,Ze(M,"complete"),Ze(M,"error"))}function zt(M){if(M.c&&u!==void 0){if(M.C[1]&&Qe(M)==4&&M.getStatus()==2)He(M.b,Ke(M,"Local request error detected and ignored"));else if(M.m&&Qe(M)==4)Mt(M.K,0,M);else if(Ze(M,"readystatechange"),Qe(M)==4){He(M.b,Ke(M,"Request complete")),M.c=!1;try{var z,J=M.getStatus();e:switch(J){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var re=!0;break e;default:re=!1}if(!(z=re)){var se;if(se=J===0){var fe=String(M.o).match(Qt)[1]||null;if(!fe&&b.self&&b.self.location){var oe=b.self.location.protocol;fe=oe.substr(0,oe.length-1)}se=!rr.test(fe?fe.toLowerCase():"")}z=se}if(z)Ze(M,"complete"),Ze(M,"success");else{M.g=6;try{var le=2<Qe(M)?M.a.statusText:""}catch(ve){He(M.b,"Can not get status: "+ve.message),le=""}M.i=le+" ["+M.getStatus()+"]",Vt(M)}}finally{St(M)}}}}function St(M){if(M.a){Ht(M);var z=M.a,J=M.C[0]?_:null;M.a=null,M.C=null,Ze(M,"ready");try{z.onreadystatechange=J}catch(re){(M=M.b)&&M.log(Pt,"Problem encountered resetting onreadystatechange: "+re.message,void 0)}}}function Ht(M){M.a&&M.B&&(M.a.ontimeout=null),M.u&&(b.clearTimeout(M.u),M.u=null)}function Qe(M){return M.a?M.a.readyState:0}function Gt(M,z){if(M.a&&Qe(M)==4)return(M=M.a.getResponseHeader(z))===null?void 0:M}function Ke(M,z){return z+" ["+M.J+" "+M.o+" "+M.getStatus()+"]"}Je.prototype.L=function(){u!==void 0&&this.a&&(this.i="Timed out after "+this.l+"ms, aborting",this.g=8,He(this.b,Ke(this,this.i)),Ze(this,"timeout"),this.abort(8))},Je.prototype.abort=function(M){this.a&&this.c&&(He(this.b,Ke(this,"Aborting")),this.c=!1,this.h=!0,this.a.abort(),this.h=!1,this.g=M||7,Ze(this,"complete"),Ze(this,"abort"),St(this))},Je.prototype.K=function(){this.F||(this.I||this.m||this.h?zt(this):this.O())},Je.prototype.O=function(){zt(this)},Je.prototype.getStatus=function(){try{return 2<Qe(this)?this.a.status:-1}catch{return-1}};var qt={},ot=null;function sr(M){var z=M.length,J=3*z/4;J%3?J=Math.floor(J):Y("=.",M[z-1])&&(J=Y("=.",M[z-2])?J-2:J-1);var re=new Uint8Array(J),se=0;return function(fe,oe){function le(xe){for(;ve<fe.length;){var Ne=fe.charAt(ve++),Ue=ot[Ne];if(Ue!=null)return Ue;if(!/^[\s\xa0]*$/.test(Ne))throw Error("Unknown base64 encoding at char: "+Ne)}return xe}Yt();for(var ve=0;;){var be=le(-1),_e=le(0),Ce=le(64),Ie=le(64);if(Ie===64&&be===-1)break;oe(be<<2|_e>>4),Ce!=64&&(oe(_e<<4&240|Ce>>2),Ie!=64&&oe(Ce<<6&192|Ie))}}(M,function(fe){re[se++]=fe}),re.subarray(0,se)}function Yt(){if(!ot){ot={};for(var M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),z=["+/=","+/","-_=","-_.","-_"],J=0;5>J;J++){var re=M.concat(z[J].split(""));qt[J]=re;for(var se=0;se<re.length;se++){var fe=re[se];ot[fe]===void 0&&(ot[fe]=se)}}}}var ar=["content-type","grpc-status","grpc-message"];function Ye(M){this.a=M.T,this.l=null,this.b=[],this.h=[],this.g=[],this.f=[],this.c=[],this.j=!1,this.i=0,this.m=new x;var z=this;at(this.a,"readystatechange",function(){var J=z.a;if(J=J.a?J.a.getResponseHeader("Content-Type"):null){if((J=J.toLowerCase()).lastIndexOf("application/grpc-web-text",0)==0){J=z.a;try{var re=J.a?J.a.responseText:""}catch(be){He(J.b,"Can not get responseText: "+be.message),re=""}if(re=(J=re||"").length-J.length%4,(J=J.substr(z.i,re-z.i)).length==0)return;z.i=re,J=sr(J)}else{if(J.lastIndexOf("application/grpc",0)!=0)return void rt(z,{code:2,message:"Unknown Content-type received.",metadata:{}});J=new Uint8Array(function(be){try{if(!be.a)return null;if("response"in be.a)return be.a.response;switch(be.j){case Ft:case"text":return be.a.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in be.a)return be.a.mozResponseArrayBuffer}var _e=be.b;return _e&&_e.log(Pt,"Response type "+be.j+" is not supported on this browser",void 0),null}catch(Ce){return He(be.b,"Can not get response: "+Ce.message),null}}(z.a))}re=null;try{re=function(be,_e){function Ce(nt){Ae.f++,Ae.a=(Ae.a<<8)+nt,Ae.f==4&&(Ae.b=O,Ae.g=0,typeof Uint8Array!="undefined"?Ae.c=new Uint8Array(Ae.a):Ae.c=Array(Ae.a),Ae.a==0&&xe())}function Ie(nt){Ae.c[Ae.g++]=nt,Ae.g==Ae.a&&xe()}function xe(){var nt={};nt[Ae.h]=Ae.c,Ae.i.push(nt),Ae.b=F}var Ne,Ue,Ae=be,$e=0;for(Ne=_e instanceof Uint8Array||_e instanceof Array?_e:new Uint8Array(_e);$e<Ne.length;){switch(Ae.b){case L:g(Ae,Ne,$e,"stream already broken");break;case F:(Ue=Ne[$e])==k||Ue==E?Ae.h=Ue:g(Ae,Ne,$e,"invalid frame byte"),Ae.b=D,Ae.a=0,Ae.f=0;break;case D:Ce(Ne[$e]);break;case O:Ie(Ne[$e]);break;default:throw Error("unexpected parser state: "+Ae.b)}Ae.l++,$e++}return be=Ae.i,Ae.i=[],0<be.length?be:null}(z.m,J)}catch{rt(z,{code:2,message:"Error in parsing response body",metadata:{}})}if(re)for(J=0;J<re.length;J++){if(k in re[J]){var se=re[J][k];if(se)try{var fe=z.l(se);if(fe){se=z;for(var oe=fe,le=0;le<se.b.length;le++)se.b[le](oe)}}catch{rt(z,{code:2,message:"Error in response deserializer function.",metadata:{}})}}if(E in re[J]&&0<re[J][E].length){for(se="",oe=0;oe<re[J][E].length;oe++)se+=String.fromCharCode(re[J][E][oe]);for(se=se.trim().split(`\r
|
|
17
17
|
`),oe={},le=0;le<se.length;le++){var ve=se[le].indexOf(":");oe[se[le].substring(0,ve).trim()]=se[le].substring(ve+1).trim()}se=oe,oe=0,le="","grpc-status"in se&&(oe=se["grpc-status"],delete se["grpc-status"]),"grpc-message"in se&&(le=se["grpc-message"],delete se["grpc-message"]),rt(z,{code:Number(oe),message:le,metadata:se})}}}}),at(this.a,"complete",function(){var J=z.a.g,re="",se={},fe=function(le){var ve={};le=(le.a&&Qe(le)==4&&le.a.getAllResponseHeaders()||"").split(`\r
|
|
18
|
-
`);for(var be=0;be<le.length;be++)if(!/^[\s\xa0]*$/.test(le[be])){var _e=j(le[be]),Ce=_e[0];if(typeof(_e=_e[1])=="string"){_e=_e.trim();var
|
|
19
|
-
`}),Ne}(oe),typeof se=="string"?(_e=encodeURIComponent("$httpHeaders"),(_e+=oe=oe!=null?"="+encodeURIComponent(String(oe)):"")&&(0>(oe=se.indexOf("#"))&&(oe=se.length),0>(le=se.indexOf("?"))||le>oe?(le=oe,ve=""):ve=se.substring(le+1,oe),oe=(se=[se.substr(0,le),ve,se.substr(oe)])[1],se[1]=_e?oe?oe+"&"+_e:_e:oe,se=se[0]+(se[1]?"?"+se[1]:"")+se[2])):se.a("$httpHeaders",oe))}for(re=(z=(0,re.a)(z.getRequestMessage())).length,_e=[0,0,0,0],oe=new Uint8Array(5+re),le=3;0<=le;le--)_e[le]=re%256,re>>>=8;if(oe.set(new Uint8Array(_e),1),oe.set(z,5),z=oe,M.a=="text"){var Ce;for(M=z,Ce===void 0&&(Ce=0),Yt(),Ce=qt[Ce],z=[],re=0;re<M.length;re+=3){be=M[re];var je=(_e=re+1<M.length)?M[re+1]:0;le=be>>2,be=(3&be)<<4|je>>4,je=(15&je)<<2|(ve=(oe=re+2<M.length)?M[re+2]:0)>>6,ve&=63,oe||(ve=64,_e||(je=64)),z.push(Ce[le],Ce[be],Ce[je]||"",Ce[ve]||"")}z=z.join("")}else M.a=="binary"&&(J.j="arraybuffer");return or(J,se,z),fe}function $t(M,z,J){var re=null,se=!1;M.on("data",function(fe){re=fe}),M.on("error",function(fe){fe.code==0||se||(se=!0,z(fe,null))}),M.on("status",function(fe){fe.code==0||se?J&&z(null,null,fe):(se=!0,z({code:fe.code,message:fe.details,metadata:fe.metadata},null))}),J&&M.on("metadata",function(fe){z(null,null,null,fe)}),M.on("end",function(){se||(re==null?z({code:2,message:"Incomplete response"}):z(null,re)),J&&z(null,null)})}function Et(M,z){var J=M;return z.forEach(function(re){var se=J;J=function(fe){return re.intercept(fe,se)}}),J}Ye.prototype.on=function(M,z){return M=="data"?this.b.push(z):M=="status"?this.h.push(z):M=="metadata"?this.g.push(z):M=="end"?this.c.push(z):M=="error"&&this.f.push(z),this},Ye.prototype.removeListener=function(M,z){return M=="data"?it(this.b,z):M=="status"?it(this.h,z):M=="metadata"?it(this.g,z):M=="end"?it(this.c,z):M=="error"&&it(this.f,z),this},Ye.prototype.cancel=function(){this.j=!0,this.a.abort()},Ye.prototype.cancel=Ye.prototype.cancel,Ye.prototype.removeListener=Ye.prototype.removeListener,Ye.prototype.on=Ye.prototype.on,Ve.prototype.P=function(M,z,J,re,se){var fe=this;re=Z(M,z,"unary",re);var oe=M.substr(0,M.length-re.name.length);return $t(M=Et(function(le){return wt(fe,le,oe)},this.b).call(this,Q(re,z,J)),se,!1),new h(M)},Ve.prototype.M=function(M,z,J,re){var se=this;re=Z(M,z,"unary",re);var fe=M.substr(0,M.length-re.name.length);return Et(function(oe){return new Promise(function(le,ve){var be,_e,Ce;$t(wt(se,oe,fe),function(je,xe,Ne,Ue){je?ve(je):xe?Ce=xe:Ne?_e=Ne:Ue?be=Ue:(je=oe.getMethodDescriptor(),le(new d(Ce,je,xe=(xe=be)===void 0?{}:xe,_e===void 0?null:_e)))},!0)})},this.g).call(this,Q(re,z,J)).then(function(oe){return oe.getResponseMessage()})},Ve.prototype.unaryCall=function(M,z,J,re){return this.M(M,z,J,re)},Ve.prototype.R=function(M,z,J,re){var se=this;re=Z(M,z,"server_streaming",re);var fe=M.substr(0,M.length-re.name.length);return Et(function(oe){return wt(se,oe,fe)},this.b).call(this,Q(re,z,J))},Ve.prototype.serverStreaming=Ve.prototype.R,Ve.prototype.unaryCall=Ve.prototype.unaryCall,Ve.prototype.thenableCall=Ve.prototype.M,Ve.prototype.rpcCall=Ve.prototype.P,e.exports.AbstractClientBase={MethodInfo:function(M,z,J,re,se){this.name=re,this.b=se,this.f=M,this.a=z,this.c=J}},e.exports.GrpcWebClientBase=Ve,e.exports.StatusCode={OK:0,CANCELLED:1,UNKNOWN:2,INVALID_ARGUMENT:3,DEADLINE_EXCEEDED:4,NOT_FOUND:5,ALREADY_EXISTS:6,PERMISSION_DENIED:7,UNAUTHENTICATED:16,RESOURCE_EXHAUSTED:8,FAILED_PRECONDITION:9,ABORTED:10,OUT_OF_RANGE:11,UNIMPLEMENTED:12,INTERNAL:13,UNAVAILABLE:14,DATA_LOSS:15},e.exports.MethodDescriptor=I,e.exports.MethodType={UNARY:"unary",SERVER_STREAMING:"server_streaming"}}).call(this,r(5))},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=t.isAsyncGenerator=t.isAsync=void 0;var n,o=r(151),l=(n=o)&&n.__esModule?n:{default:n};function s(i){return i[Symbol.toStringTag]==="AsyncFunction"}t.default=function(i){if(typeof i!="function")throw new Error("expected a function");return s(i)?(0,l.default)(i):i},t.isAsync=s,t.isAsyncGenerator=function(i){return i[Symbol.toStringTag]==="AsyncGenerator"},t.isAsyncIterable=function(i){return typeof i[Symbol.asyncIterator]=="function"}},function(e,t,r){var n={};function o(s,i,c){c||(c=Error);var u=function(b){var A,_;function v(f,S,w){return b.call(this,function(P,N,T){return typeof i=="string"?i:i(P,N,T)}(f,S,w))||this}return _=b,(A=v).prototype=Object.create(_.prototype),A.prototype.constructor=A,A.__proto__=_,v}(c);u.prototype.name=c.name,u.prototype.code=s,n[s]=u}function l(s,i){if(Array.isArray(s)){var c=s.length;return s=s.map(function(u){return String(u)}),c>2?"one of ".concat(i," ").concat(s.slice(0,c-1).join(", "),", or ")+s[c-1]:c===2?"one of ".concat(i," ").concat(s[0]," or ").concat(s[1]):"of ".concat(i," ").concat(s[0])}return"of ".concat(i," ").concat(String(s))}o("ERR_INVALID_OPT_VALUE",function(s,i){return'The value "'+i+'" is invalid for option "'+s+'"'},TypeError),o("ERR_INVALID_ARG_TYPE",function(s,i,c){var u,b,A;if(typeof i=="string"&&(b="not ",i.substr(0,b.length)===b)?(u="must not be",i=i.replace(/^not /,"")):u="must be",function(v,f,S){return(S===void 0||S>v.length)&&(S=v.length),v.substring(S-f.length,S)===f}(s," argument"))A="The ".concat(s," ").concat(u," ").concat(l(i,"type"));else{var _=function(v,f,S){return typeof S!="number"&&(S=0),!(S+f.length>v.length)&&v.indexOf(f,S)!==-1}(s,".")?"property":"argument";A='The "'.concat(s,'" ').concat(_," ").concat(u," ").concat(l(i,"type"))}return A+=". Received type ".concat(typeof c)},TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",function(s){return"The "+s+" method is not implemented"}),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",function(s){return"Cannot call "+s+" after a stream was destroyed"}),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",function(s){return"Unknown encoding: "+s},TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){(function(n){var o=Object.keys||function(v){var f=[];for(var S in v)f.push(S);return f};e.exports=b;var l=r(75),s=r(79);r(7)(b,l);for(var i=o(s.prototype),c=0;c<i.length;c++){var u=i[c];b.prototype[u]||(b.prototype[u]=s.prototype[u])}function b(v){if(!(this instanceof b))return new b(v);l.call(this,v),s.call(this,v),this.allowHalfOpen=!0,v&&(v.readable===!1&&(this.readable=!1),v.writable===!1&&(this.writable=!1),v.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",A)))}function A(){this._writableState.ended||n.nextTick(_,this)}function _(v){v.end()}Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(b.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(b.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(b.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(v){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=v,this._writableState.destroyed=v)}})}).call(this,r(2))},function(e,t,r){r.d(t,"a",function(){return s});var n=r(36),o=r(6);const l={"app-id":["app-id must match formant/*"]};class s extends n.a{constructor(c,u={}){super(c,Object.assign({validateHeaders:b=>`${b.get("app-id")}`.startsWith("formant/")?{}:l,headers:Object.assign(Object.assign({},s.headers),{"App-ID":`formant/${o.a}`,"App-Version":o.j})},u)),this.endpoint=c}}s.headers={}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(n,o=n.length){if(!o)throw new Error("arity is undefined");return function(...l){return typeof l[o-1]=="function"?n.apply(this,l):new Promise((s,i)=>{l[o-1]=(c,...u)=>{if(c)return i(c);s(u.length>1?u:u[0])},n.apply(this,l)})}},e.exports=t.default},function(e,t,r){(t=e.exports=r(67)).Stream=t,t.Readable=t,t.Writable=r(44),t.Duplex=r(20),t.Transform=r(70),t.PassThrough=r(164)},function(e,t,r){(t=e.exports=r(75)).Stream=t,t.Readable=t,t.Writable=r(79),t.Duplex=r(24),t.Transform=r(80),t.PassThrough=r(183),t.finished=r(45),t.pipeline=r(184)},function(e,t,r){r.d(t,"a",function(){return o});const n=["password","secret","token","key","buffer"];function o(l,s=new Set){return s.has(l)?"[ RECURSIVE ]":!(i=l)||typeof i!="object"&&typeof i!="function"?l:(s.add(l),Object.keys(l).reduce((c,u)=>(c[u]=n.some(b=>u.toLowerCase().includes(b.toLowerCase()))?"[ REDACTED ]":o(l[u],s),c),{}));var i}},function(e,t){e.exports=n,n.default=n,n.stable=l,n.stableStringify=l;var r=[];function n(s,i,c){(function A(_,v,f,S){var w;if(typeof _=="object"&&_!==null){for(w=0;w<f.length;w++)if(f[w]===_)return S[v]="[Circular]",void r.push([S,v,_]);if(f.push(_),Array.isArray(_))for(w=0;w<_.length;w++)A(_[w],w,f,_);else{var P=Object.keys(_);for(w=0;w<P.length;w++){var N=P[w];A(_[N],N,f,_)}}f.pop()}})(s,"",[],void 0);for(var u=JSON.stringify(s,i,c);r.length!==0;){var b=r.pop();b[0][b[1]]=b[2]}return u}function o(s,i){return s<i?-1:s>i?1:0}function l(s,i,c){for(var u=function _(v,f,S,w){var P;if(typeof v=="object"&&v!==null){for(P=0;P<S.length;P++)if(S[P]===v)return w[f]="[Circular]",void r.push([w,f,v]);if(typeof v.toJSON=="function")return;if(S.push(v),Array.isArray(v))for(P=0;P<v.length;P++)_(v[P],P,S,v);else{var N={},T=Object.keys(v).sort(o);for(P=0;P<T.length;P++){var R=T[P];_(v[R],R,S,v),N[R]=v[R]}if(w===void 0)return N;r.push([w,f,v]),w[f]=N}S.pop()}}(s,"",[],void 0)||s,b=JSON.stringify(u,i,c);r.length!==0;){var A=r.pop();A[0][A[1]]=A[2]}return b}},function(e,t,r){var n=r(13),o=Object.keys||function(f){var S=[];for(var w in f)S.push(w);return S};e.exports=A;var l=Object.create(r(14));l.inherits=r(7);var s=r(142),i=r(60);l.inherits(A,s);for(var c=o(i.prototype),u=0;u<c.length;u++){var b=c[u];A.prototype[b]||(A.prototype[b]=i.prototype[b])}function A(f){if(!(this instanceof A))return new A(f);s.call(this,f),i.call(this,f),f&&f.readable===!1&&(this.readable=!1),f&&f.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,f&&f.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||n.nextTick(v,this)}function v(f){f.end()}Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(A.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(f){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=f,this._writableState.destroyed=f)}}),A.prototype._destroy=function(f,S){this.push(null),this.end(),n.nextTick(S,f)}},function(e,t,r){var n=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function o(i,c){return Object.prototype.hasOwnProperty.call(i,c)}t.assign=function(i){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var b in u)o(u,b)&&(i[b]=u[b])}}return i},t.shrinkBuf=function(i,c){return i.length===c?i:i.subarray?i.subarray(0,c):(i.length=c,i)};var l={arraySet:function(i,c,u,b,A){if(c.subarray&&i.subarray)i.set(c.subarray(u,u+b),A);else for(var _=0;_<b;_++)i[A+_]=c[u+_]},flattenChunks:function(i){var c,u,b,A,_,v;for(b=0,c=0,u=i.length;c<u;c++)b+=i[c].length;for(v=new Uint8Array(b),A=0,c=0,u=i.length;c<u;c++)_=i[c],v.set(_,A),A+=_.length;return v}},s={arraySet:function(i,c,u,b,A){for(var _=0;_<b;_++)i[A+_]=c[u+_]},flattenChunks:function(i){return[].concat.apply([],i)}};t.setTyped=function(i){i?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,l)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,s))},t.setTyped(n)},function(e,t,r){e.exports=r(185)},function(e,t,r){e.exports=function(n){return n}},function(e,t,r){e.exports=function(n,o){o||(o={}),typeof o=="function"&&(o={cmp:o});var l,s=typeof o.cycles=="boolean"&&o.cycles,i=o.cmp&&(l=o.cmp,function(u){return function(b,A){var _={key:b,value:u[b]},v={key:A,value:u[A]};return l(_,v)}}),c=[];return function u(b){if(b&&b.toJSON&&typeof b.toJSON=="function"&&(b=b.toJSON()),b!==void 0){if(typeof b=="number")return isFinite(b)?""+b:"null";if(typeof b!="object")return JSON.stringify(b);var A,_;if(Array.isArray(b)){for(_="[",A=0;A<b.length;A++)A&&(_+=","),_+=u(b[A])||"null";return _+"]"}if(b===null)return"null";if(c.indexOf(b)!==-1){if(s)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var v=c.push(b)-1,f=Object.keys(b).sort(i&&i(b));for(_="",A=0;A<f.length;A++){var S=f[A],w=u(b[S]);w&&(_&&(_+=","),_+=JSON.stringify(S)+":"+w)}return c.splice(v,1),"{"+_+"}"}}(n)}},function(e,t,r){r.d(t,"a",function(){return N});var n=r(11),o=r(0);function l(T,R,d=()=>!0){if(T instanceof R&&d(T))return T;throw T}var s=r(1),i=r(100),c=r.n(i),u=r(101),b=r.n(u);class A extends Error{constructor(R,d,I){super(`Connection failure: ${R.message}`),this.cause=R,this.url=d,this.retryable=I}}var _=r(29);class v extends Error{constructor(R,d,I,Q,Z={},h){super(`Unexpected response (${I}) for ${R} ${d}: ${JSON.stringify(h?Object(_.a)([...h.entries()].reduce((p,[C,m])=>(p[C]=m,p),{})):{})} -- ${JSON.stringify(Object(_.a)(Q))}`),this.method=R,this.url=d,this.statusCode=I,this.body=Q,this.validationErrors=Z,this.headers=h}}class f extends Error{constructor(R,d){super(`Invalid headers (${JSON.stringify(R)}) for response: ${d.message}`),this.validationErrors=R,this.responseError=d}}var S=function(T,R,d,I){return new(d||(d=Promise))(function(Q,Z){function h(m){try{C(I.next(m))}catch(x){Z(x)}}function p(m){try{C(I.throw(m))}catch(x){Z(x)}}function C(m){var x;m.done?Q(m.value):(x=m.value,x instanceof d?x:new d(function(F){F(x)})).then(h,p)}C((I=I.apply(T,R||[])).next())})},w=function(T,R){var d={};for(var I in T)Object.prototype.hasOwnProperty.call(T,I)&&R.indexOf(I)<0&&(d[I]=T[I]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var Q=0;for(I=Object.getOwnPropertySymbols(T);Q<I.length;Q++)R.indexOf(I[Q])<0&&Object.prototype.propertyIsEnumerable.call(T,I[Q])&&(d[I[Q]]=T[I[Q]])}return d};const P=new Set(["GET","HEAD","PUT","QUERY","DELETE","OPTIONS","TRACE"]);class N{constructor(R,d={}){if(this.endpoint=R,this.validateHeaders=I=>d.validateHeaders?d.validateHeaders(I):{},this.verbose=d.verbose!==!1,this.headers=d.headers||{},d.retries!==void 0&&!(d.retries>=0))throw new Error("retries must be positive or zero");if(this.configuredRetries=d.retries,d.timeoutMs!==void 0&&!(d.timeoutMs>0))throw new Error("timeoutMs must be positive");if(this.timeoutMs=d.timeoutMs,d.maxBackoffDelayMs!==void 0&&!(d.maxBackoffDelayMs>0))throw new Error("maxBackoffDelayMs must be positive");this.maxBackoffDelayMs=d.maxBackoffDelayMs||30*s.a.second}getRetries(){return this.configuredRetries!==void 0?this.configuredRetries:this.constructor.retries}fetch(R,d={}){return S(this,void 0,void 0,function*(){return(yield this.fetchVerbose(R,d)).body})}fetchVerbose(R,d={}){return S(this,void 0,void 0,function*(){let I=100*s.a.millisecond,Q=0;const Z=this.timeoutMs!==void 0?new Date().getTime()+this.timeoutMs:void 0,h=Z?()=>Math.max(Z-new Date().getTime(),0):void 0;for(;;)try{return yield this.doFetch(R,d,h)}catch(p){const C=l(p,A);if((h==null?void 0:h())===0||Q===this.getRetries()||!C.retryable)throw C;Q++,I=Math.min(...h?[h()]:[],I*(2+.1*(Math.random()-.5)),this.maxBackoffDelayMs),yield Object(n.a)(I),this.verbose&&o.a.warn(`Connection failure, retrying. Error: ${p.cause.message}`,{url:p.url,error:p.cause,attempt:Q})}})}doFetch(R,d,I){return S(this,void 0,void 0,function*(){const{token:Q,json:Z,allowUnsafeRetries:h}=d,p=w(d,["token","json","allowUnsafeRetries"]),C=(p.method||"GET").toUpperCase(),m=this.endpoint!==void 0?`${this.endpoint}${R?`/${R}`:""}`:R,x=new c.a;let F;if(I){const D=I();D>0?F=setTimeout(()=>{x.abort()},D):x.abort()}try{let D;yield Promise.race([this.constructor.waitForConnectivity(),new Promise(B=>{D=setTimeout(B,I?Math.min(s.a.minute,I()):s.a.minute)})]),D&&clearTimeout(D);const O=yield b()(m,Object.assign(Object.assign({},p),{headers:Object.assign(Object.assign(Object.assign(Object.assign({},Z!==!1?{"Content-Type":"application/json"}:{}),this.headers),p.headers||{}),Q!==void 0?{Authorization:`Bearer ${Q}`}:{}),signal:x.signal})),L=O.headers.get("content-type")||"",k=L&&L.startsWith("application/json"),E=k?yield O.json():yield O.text(),g=()=>new v(C,m,O.status,E,E&&E.validationErrors||{},O.headers);if(!O.ok)throw this.verbose&&o.a[O.status>=500?"warn":"info"]("Response error",{method:C,url:m,statusCode:O.status}),g();const U=this.validateHeaders(O.headers);if(Object.keys(U).length!==0)throw new f(U,g());if(O.status===204)return{body:void 0,headers:O.headers};if(Z&&!k)throw new Error(`Response is not JSON: ${JSON.stringify(E)}`);return{body:E,headers:O.headers}}catch(D){const O=h||P.has(C);if(D.message==="Network request failed")throw new A(D,m,O);if(D.type==="system"&&["EAI_AGAIN","ECONNREFUSED","EHOSTUNREACH","ENOTFOUND"].find(g=>g===D.code))throw new A(D,m,!0);if(D.type==="system"&&["ETIMEDOUT","ECONNRESET","ESOCKETTIMEDOUT","EPIPE"].find(g=>g===D.code))throw new A(D,m,O);if(D.name==="AbortError")throw new A(D,m,O);const L=l(D,v),{statusCode:k}=L;if(k===408||k===429||k===502||k===503||k===504)throw this.verbose&&!O&&o.a.warn("Potentially unsafe retry"),new A(D,m,!0);const E=this.validateHeaders(L.headers);throw Object.keys(E).length!==0?new f(E,L):(yield this.constructor.onResponseError(L),D)}finally{F&&clearTimeout(F)}})}}N.retries=8,N.waitForConnectivity=()=>S(void 0,void 0,void 0,function*(){}),N.onResponseError=()=>S(void 0,void 0,void 0,function*(){})},function(e,t,r){function n(A,_){if(!(A instanceof _))throw new TypeError("Cannot call a class as a function")}function o(A,_){for(var v=0;v<_.length;v++){var f=_[v];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(A,f.key,f)}}var l=r(57),s=r(3),i=s.LEVEL,c=s.MESSAGE;l.enabled=!0;var u=/\s+/,b=function(){function A(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};n(this,A),S.colors&&this.addColors(S.colors),this.options=S}var _,v,f;return _=A,f=[{key:"addColors",value:function(S){var w=Object.keys(S).reduce(function(P,N){return P[N]=u.test(S[N])?S[N].split(u):S[N],P},{});return A.allColors=Object.assign({},A.allColors||{},w),A.allColors}}],(v=[{key:"addColors",value:function(S){return A.addColors(S)}},{key:"colorize",value:function(S,w,P){if(P===void 0&&(P=w),!Array.isArray(A.allColors[S]))return l[A.allColors[S]](P);for(var N=0,T=A.allColors[S].length;N<T;N++)P=l[A.allColors[S][N]](P);return P}},{key:"transform",value:function(S,w){return w.all&&typeof S[c]=="string"&&(S[c]=this.colorize(S[i],S.level,S[c])),(w.level||w.all||!w.message)&&(S.level=this.colorize(S[i],S.level)),(w.all||w.message)&&(S.message=this.colorize(S[i],S.level,S.message)),S}}])&&o(_.prototype,v),f&&o(_,f),A}();e.exports=function(A){return new b(A)},e.exports.Colorizer=e.exports.Format=b},function(e,t){var r={}.toString;e.exports=Array.isArray||function(n){return r.call(n)=="[object Array]"}},function(e,t,r){(function(n){function o(l){try{if(!n.localStorage)return!1}catch{return!1}var s=n.localStorage[l];return s!=null&&String(s).toLowerCase()==="true"}e.exports=function(l,s){if(o("noDeprecation"))return l;var i=!1;return function(){if(!i){if(o("throwDeprecation"))throw new Error(s);o("traceDeprecation")?console.trace(s):console.warn(s),i=!0}return l.apply(this,arguments)}}}).call(this,r(5))},function(e,t,r){var n=r(4),o=n.Buffer;function l(i,c){for(var u in i)c[u]=i[u]}function s(i,c,u){return o(i,c,u)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(l(n,t),t.Buffer=s),l(o,s),s.from=function(i,c,u){if(typeof i=="number")throw new TypeError("Argument must not be a number");return o(i,c,u)},s.alloc=function(i,c,u){if(typeof i!="number")throw new TypeError("Argument must be a number");var b=o(i);return c!==void 0?typeof u=="string"?b.fill(c,u):b.fill(c):b.fill(0),b},s.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return o(i)},s.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(i)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(n){return n&&typeof n.length=="number"&&n.length>=0&&n.length%1==0},e.exports=t.default},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default={},e.exports=t.default},function(e,t,r){var n=r(4),o=n.Buffer;function l(i,c){for(var u in i)c[u]=i[u]}function s(i,c,u){return o(i,c,u)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(l(n,t),t.Buffer=s),l(o,s),s.from=function(i,c,u){if(typeof i=="number")throw new TypeError("Argument must not be a number");return o(i,c,u)},s.alloc=function(i,c,u){if(typeof i!="number")throw new TypeError("Argument must be a number");var b=o(i);return c!==void 0?typeof u=="string"?b.fill(c,u):b.fill(c):b.fill(0),b},s.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return o(i)},s.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(i)}},function(e,t,r){(function(n,o,l){var s=r(13);function i(p){var C=this;this.next=null,this.entry=null,this.finish=function(){(function(m,x,F){var D=m.entry;for(m.entry=null;D;){var O=D.callback;x.pendingcb--,O(F),D=D.next}x.corkedRequestsFree?x.corkedRequestsFree.next=m:x.corkedRequestsFree=m})(C,p)}}e.exports=T;var c,u=!n.browser&&["v0.10","v0.9."].indexOf(n.version.slice(0,5))>-1?o:s.nextTick;T.WritableState=N;var b=r(14);b.inherits=r(7);var A={deprecate:r(39)},_=r(68),v=r(43).Buffer,f=l.Uint8Array||function(){},S,w=r(69);function P(){}function N(p,C){c=c||r(20),p=p||{};var m=C instanceof c;this.objectMode=!!p.objectMode,m&&(this.objectMode=this.objectMode||!!p.writableObjectMode);var x=p.highWaterMark,F=p.writableHighWaterMark,D=this.objectMode?16:16384;this.highWaterMark=x||x===0?x:m&&(F||F===0)?F:D,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var O=p.decodeStrings===!1;this.decodeStrings=!O,this.defaultEncoding=p.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(L){(function(k,E){var g=k._writableState,U=g.sync,B=g.writecb;if(function(Y){Y.writing=!1,Y.writecb=null,Y.length-=Y.writelen,Y.writelen=0}(g),E)(function(Y,K,H,V,y){--K.pendingcb,H?(s.nextTick(y,V),s.nextTick(h,Y,K),Y._writableState.errorEmitted=!0,Y.emit("error",V)):(y(V),Y._writableState.errorEmitted=!0,Y.emit("error",V),h(Y,K))})(k,g,U,E,B);else{var G=Q(g);G||g.corked||g.bufferProcessing||!g.bufferedRequest||I(k,g),U?u(d,k,g,G,B):d(k,g,G,B)}})(C,L)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function T(p){if(c=c||r(20),!(S.call(T,this)||this instanceof c))return new T(p);this._writableState=new N(p,this),this.writable=!0,p&&(typeof p.write=="function"&&(this._write=p.write),typeof p.writev=="function"&&(this._writev=p.writev),typeof p.destroy=="function"&&(this._destroy=p.destroy),typeof p.final=="function"&&(this._final=p.final)),_.call(this)}function R(p,C,m,x,F,D,O){C.writelen=x,C.writecb=O,C.writing=!0,C.sync=!0,m?p._writev(F,C.onwrite):p._write(F,D,C.onwrite),C.sync=!1}function d(p,C,m,x){m||function(F,D){D.length===0&&D.needDrain&&(D.needDrain=!1,F.emit("drain"))}(p,C),C.pendingcb--,x(),h(p,C)}function I(p,C){C.bufferProcessing=!0;var m=C.bufferedRequest;if(p._writev&&m&&m.next){var x=C.bufferedRequestCount,F=new Array(x),D=C.corkedRequestsFree;D.entry=m;for(var O=0,L=!0;m;)F[O]=m,m.isBuf||(L=!1),m=m.next,O+=1;F.allBuffers=L,R(p,C,!0,C.length,F,"",D.finish),C.pendingcb++,C.lastBufferedRequest=null,D.next?(C.corkedRequestsFree=D.next,D.next=null):C.corkedRequestsFree=new i(C),C.bufferedRequestCount=0}else{for(;m;){var k=m.chunk,E=m.encoding,g=m.callback;if(R(p,C,!1,C.objectMode?1:k.length,k,E,g),m=m.next,C.bufferedRequestCount--,C.writing)break}m===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=m,C.bufferProcessing=!1}function Q(p){return p.ending&&p.length===0&&p.bufferedRequest===null&&!p.finished&&!p.writing}function Z(p,C){p._final(function(m){C.pendingcb--,m&&p.emit("error",m),C.prefinished=!0,p.emit("prefinish"),h(p,C)})}function h(p,C){var m=Q(C);return m&&(function(x,F){F.prefinished||F.finalCalled||(typeof x._final=="function"?(F.pendingcb++,F.finalCalled=!0,s.nextTick(Z,x,F)):(F.prefinished=!0,x.emit("prefinish")))}(p,C),C.pendingcb===0&&(C.finished=!0,p.emit("finish"))),m}b.inherits(T,_),N.prototype.getBuffer=function(){for(var p=this.bufferedRequest,C=[];p;)C.push(p),p=p.next;return C},function(){try{Object.defineProperty(N.prototype,"buffer",{get:A.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(S=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(p){return!!S.call(this,p)||this===T&&p&&p._writableState instanceof N}})):S=function(p){return p instanceof this},T.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},T.prototype.write=function(p,C,m){var x,F=this._writableState,D=!1,O=!F.objectMode&&(x=p,v.isBuffer(x)||x instanceof f);return O&&!v.isBuffer(p)&&(p=function(L){return v.from(L)}(p)),typeof C=="function"&&(m=C,C=null),O?C="buffer":C||(C=F.defaultEncoding),typeof m!="function"&&(m=P),F.ended?function(L,k){var E=new Error("write after end");L.emit("error",E),s.nextTick(k,E)}(this,m):(O||function(L,k,E,g){var U=!0,B=!1;return E===null?B=new TypeError("May not write null values to stream"):typeof E=="string"||E===void 0||k.objectMode||(B=new TypeError("Invalid non-string/buffer chunk")),B&&(L.emit("error",B),s.nextTick(g,B),U=!1),U}(this,F,p,m))&&(F.pendingcb++,D=function(L,k,E,g,U,B){if(!E){var G=function(V,y,j){return V.objectMode||V.decodeStrings===!1||typeof y!="string"||(y=v.from(y,j)),y}(k,g,U);g!==G&&(E=!0,U="buffer",g=G)}var Y=k.objectMode?1:g.length;k.length+=Y;var K=k.length<k.highWaterMark;if(K||(k.needDrain=!0),k.writing||k.corked){var H=k.lastBufferedRequest;k.lastBufferedRequest={chunk:g,encoding:U,isBuf:E,callback:B,next:null},H?H.next=k.lastBufferedRequest:k.bufferedRequest=k.lastBufferedRequest,k.bufferedRequestCount+=1}else R(L,k,!1,Y,g,U,B);return K}(this,F,O,p,C,m)),D},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var p=this._writableState;p.corked&&(p.corked--,p.writing||p.corked||p.finished||p.bufferProcessing||!p.bufferedRequest||I(this,p))},T.prototype.setDefaultEncoding=function(p){if(typeof p=="string"&&(p=p.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((p+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+p);return this._writableState.defaultEncoding=p,this},Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(p,C,m){m(new Error("_write() is not implemented"))},T.prototype._writev=null,T.prototype.end=function(p,C,m){var x=this._writableState;typeof p=="function"?(m=p,p=null,C=null):typeof C=="function"&&(m=C,C=null),p!=null&&this.write(p,C),x.corked&&(x.corked=1,this.uncork()),x.ending||x.finished||function(F,D,O){D.ending=!0,h(F,D),O&&(D.finished?s.nextTick(O):F.once("finish",O)),D.ended=!0,F.writable=!1}(this,x,m)},Object.defineProperty(T.prototype,"destroyed",{get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(p){this._writableState&&(this._writableState.destroyed=p)}}),T.prototype.destroy=w.destroy,T.prototype._undestroy=w.undestroy,T.prototype._destroy=function(p,C){this.end(),C(p)}}).call(this,r(2),r(12).setImmediate,r(5))},function(e,t,r){var n=r(23).codes.ERR_STREAM_PREMATURE_CLOSE;function o(){}e.exports=function l(s,i,c){if(typeof i=="function")return l(s,null,i);i||(i={}),c=function(T){var R=!1;return function(){if(!R){R=!0;for(var d=arguments.length,I=new Array(d),Q=0;Q<d;Q++)I[Q]=arguments[Q];T.apply(this,I)}}}(c||o);var u=i.readable||i.readable!==!1&&s.readable,b=i.writable||i.writable!==!1&&s.writable,A=function(){s.writable||v()},_=s._writableState&&s._writableState.finished,v=function(){b=!1,_=!0,u||c.call(s)},f=s._readableState&&s._readableState.endEmitted,S=function(){u=!1,f=!0,b||c.call(s)},w=function(T){c.call(s,T)},P=function(){var T;return u&&!f?(s._readableState&&s._readableState.ended||(T=new n),c.call(s,T)):b&&!_?(s._writableState&&s._writableState.ended||(T=new n),c.call(s,T)):void 0},N=function(){s.req.on("finish",v)};return function(T){return T.setHeader&&typeof T.abort=="function"}(s)?(s.on("complete",v),s.on("abort",P),s.req?N():s.on("request",N)):b&&!s._writableState&&(s.on("end",A),s.on("close",A)),s.on("end",S),s.on("finish",v),i.error!==!1&&s.on("error",w),s.on("close",P),function(){s.removeListener("complete",v),s.removeListener("abort",P),s.removeListener("request",N),s.req&&s.req.removeListener("finish",v),s.removeListener("end",A),s.removeListener("close",A),s.removeListener("finish",v),s.removeListener("end",S),s.removeListener("error",w),s.removeListener("close",P)}}},function(e,t,r){var n=r(193),o=r(195);function l(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=T,t.resolve=function(R,d){return T(R,!1,!0).resolve(d)},t.resolveObject=function(R,d){return R?T(R,!1,!0).resolveObject(d):d},t.format=function(R){return o.isString(R)&&(R=T(R)),R instanceof l?R.format():l.prototype.format.call(R)},t.Url=l;var s=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",`
|
|
18
|
+
`);for(var be=0;be<le.length;be++)if(!/^[\s\xa0]*$/.test(le[be])){var _e=j(le[be]),Ce=_e[0];if(typeof(_e=_e[1])=="string"){_e=_e.trim();var Ie=ve[Ce]||[];ve[Ce]=Ie,Ie.push(_e)}}return function(xe,Ne){var Ue,Ae={};for(Ue in xe)Ae[Ue]=Ne.call(void 0,xe[Ue],Ue,xe);return Ae}(ve,function(xe){return xe.join(", ")})}(z.a);if(Object.keys(fe).forEach(function(le){ar.includes(le)||(se[le]=fe[le])}),function(le,ve){for(var be=0;be<le.g.length;be++)le.g[be](ve)}(z,se),J!=0){switch(J){case 7:var oe=10;break;case 8:oe=4;break;case 6:oe=function(le){switch(le){case 200:return 0;case 400:return 3;case 401:return 16;case 403:return 7;case 404:return 5;case 409:return 10;case 412:return 9;case 429:return 8;case 499:return 1;case 500:return 2;case 501:return 12;case 503:return 14;case 504:return 4;default:return 2}}(z.a.getStatus());break;default:oe=14}oe==10&&z.j||rt(z,{code:oe,message:p(J),metadata:{}})}else J=!1,"grpc-status"in fe&&(oe=Gt(z.a,"grpc-status"),"grpc-message"in fe&&(re=Gt(z.a,"grpc-message")),Number(oe)!=0&&(rt(z,{code:Number(oe),message:re,metadata:fe}),J=!0)),J||function(le){for(var ve=0;ve<le.c.length;ve++)le.c[ve]()}(z)})}function it(M,z){-1<(z=M.indexOf(z))&&M.splice(z,1)}function rt(M,z){if(z.code!=0)for(var J={code:z.code,message:decodeURIComponent(z.message||""),metadata:z.metadata},re=0;re<M.f.length;re++)M.f[re](J);for(z={code:z.code,details:decodeURIComponent(z.message||""),metadata:z.metadata},J=0;J<M.h.length;J++)M.h[J](z)}function Ve(M){this.a=A("format",M)||"text",this.f=A("suppressCorsPreflight",M)||!1,this.c=A("withCredentials",M)||!1,this.b=A("streamInterceptors",M)||[],this.g=A("unaryInterceptors",M)||[]}function wt(M,z,J){var re=z.getMethodDescriptor(),se=J+re.name;(J=new Je).H=M.c;var fe=new Ye({T:J});if(fe.l=re.b,kt(J.headers,z.getMetadata()),M.a=="text"?(J.headers.set("Content-Type","application/grpc-web-text"),J.headers.set("Accept","application/grpc-web-text")):J.headers.set("Content-Type","application/grpc-web+proto"),J.headers.set("X-User-Agent","grpc-web-javascript/0.1"),J.headers.set("X-Grpc-Web","1"),tt(J.headers.b,"deadline")){var oe=J.headers.get("deadline");oe=Math.round(oe-new Date().getTime());var le=J.headers;tt(le.b,"deadline")&&(delete le.b.deadline,le.c--,le.a.length>2*le.c&&_t(le)),1/0===oe&&(oe=0),0<oe&&J.headers.set("grpc-timeout",oe+"m")}if(M.f){_t(le=J.headers),oe={};for(var ve=0;ve<le.a.length;ve++){var be=le.a[ve];oe[be]=le.b[be]}(le=J.headers).b={},le.a.length=0,le.c=0;e:{for(_e in oe){var _e=!1;break e}_e=!0}_e||(oe=function(xe){var Ne="";return function(Ue,Ae){for(var $e in Ue)Ae.call(void 0,Ue[$e],$e,Ue)}(xe,function(Ue,Ae){Ne+=Ae,Ne+=":",Ne+=Ue,Ne+=`\r
|
|
19
|
+
`}),Ne}(oe),typeof se=="string"?(_e=encodeURIComponent("$httpHeaders"),(_e+=oe=oe!=null?"="+encodeURIComponent(String(oe)):"")&&(0>(oe=se.indexOf("#"))&&(oe=se.length),0>(le=se.indexOf("?"))||le>oe?(le=oe,ve=""):ve=se.substring(le+1,oe),oe=(se=[se.substr(0,le),ve,se.substr(oe)])[1],se[1]=_e?oe?oe+"&"+_e:_e:oe,se=se[0]+(se[1]?"?"+se[1]:"")+se[2])):se.a("$httpHeaders",oe))}for(re=(z=(0,re.a)(z.getRequestMessage())).length,_e=[0,0,0,0],oe=new Uint8Array(5+re),le=3;0<=le;le--)_e[le]=re%256,re>>>=8;if(oe.set(new Uint8Array(_e),1),oe.set(z,5),z=oe,M.a=="text"){var Ce;for(M=z,Ce===void 0&&(Ce=0),Yt(),Ce=qt[Ce],z=[],re=0;re<M.length;re+=3){be=M[re];var Ie=(_e=re+1<M.length)?M[re+1]:0;le=be>>2,be=(3&be)<<4|Ie>>4,Ie=(15&Ie)<<2|(ve=(oe=re+2<M.length)?M[re+2]:0)>>6,ve&=63,oe||(ve=64,_e||(Ie=64)),z.push(Ce[le],Ce[be],Ce[Ie]||"",Ce[ve]||"")}z=z.join("")}else M.a=="binary"&&(J.j="arraybuffer");return or(J,se,z),fe}function $t(M,z,J){var re=null,se=!1;M.on("data",function(fe){re=fe}),M.on("error",function(fe){fe.code==0||se||(se=!0,z(fe,null))}),M.on("status",function(fe){fe.code==0||se?J&&z(null,null,fe):(se=!0,z({code:fe.code,message:fe.details,metadata:fe.metadata},null))}),J&&M.on("metadata",function(fe){z(null,null,null,fe)}),M.on("end",function(){se||(re==null?z({code:2,message:"Incomplete response"}):z(null,re)),J&&z(null,null)})}function Et(M,z){var J=M;return z.forEach(function(re){var se=J;J=function(fe){return re.intercept(fe,se)}}),J}Ye.prototype.on=function(M,z){return M=="data"?this.b.push(z):M=="status"?this.h.push(z):M=="metadata"?this.g.push(z):M=="end"?this.c.push(z):M=="error"&&this.f.push(z),this},Ye.prototype.removeListener=function(M,z){return M=="data"?it(this.b,z):M=="status"?it(this.h,z):M=="metadata"?it(this.g,z):M=="end"?it(this.c,z):M=="error"&&it(this.f,z),this},Ye.prototype.cancel=function(){this.j=!0,this.a.abort()},Ye.prototype.cancel=Ye.prototype.cancel,Ye.prototype.removeListener=Ye.prototype.removeListener,Ye.prototype.on=Ye.prototype.on,Ve.prototype.P=function(M,z,J,re,se){var fe=this;re=Z(M,z,"unary",re);var oe=M.substr(0,M.length-re.name.length);return $t(M=Et(function(le){return wt(fe,le,oe)},this.b).call(this,Q(re,z,J)),se,!1),new h(M)},Ve.prototype.M=function(M,z,J,re){var se=this;re=Z(M,z,"unary",re);var fe=M.substr(0,M.length-re.name.length);return Et(function(oe){return new Promise(function(le,ve){var be,_e,Ce;$t(wt(se,oe,fe),function(Ie,xe,Ne,Ue){Ie?ve(Ie):xe?Ce=xe:Ne?_e=Ne:Ue?be=Ue:(Ie=oe.getMethodDescriptor(),le(new d(Ce,Ie,xe=(xe=be)===void 0?{}:xe,_e===void 0?null:_e)))},!0)})},this.g).call(this,Q(re,z,J)).then(function(oe){return oe.getResponseMessage()})},Ve.prototype.unaryCall=function(M,z,J,re){return this.M(M,z,J,re)},Ve.prototype.R=function(M,z,J,re){var se=this;re=Z(M,z,"server_streaming",re);var fe=M.substr(0,M.length-re.name.length);return Et(function(oe){return wt(se,oe,fe)},this.b).call(this,Q(re,z,J))},Ve.prototype.serverStreaming=Ve.prototype.R,Ve.prototype.unaryCall=Ve.prototype.unaryCall,Ve.prototype.thenableCall=Ve.prototype.M,Ve.prototype.rpcCall=Ve.prototype.P,e.exports.AbstractClientBase={MethodInfo:function(M,z,J,re,se){this.name=re,this.b=se,this.f=M,this.a=z,this.c=J}},e.exports.GrpcWebClientBase=Ve,e.exports.StatusCode={OK:0,CANCELLED:1,UNKNOWN:2,INVALID_ARGUMENT:3,DEADLINE_EXCEEDED:4,NOT_FOUND:5,ALREADY_EXISTS:6,PERMISSION_DENIED:7,UNAUTHENTICATED:16,RESOURCE_EXHAUSTED:8,FAILED_PRECONDITION:9,ABORTED:10,OUT_OF_RANGE:11,UNIMPLEMENTED:12,INTERNAL:13,UNAVAILABLE:14,DATA_LOSS:15},e.exports.MethodDescriptor=I,e.exports.MethodType={UNARY:"unary",SERVER_STREAMING:"server_streaming"}}).call(this,r(5))},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=t.isAsyncGenerator=t.isAsync=void 0;var n,o=r(151),l=(n=o)&&n.__esModule?n:{default:n};function s(i){return i[Symbol.toStringTag]==="AsyncFunction"}t.default=function(i){if(typeof i!="function")throw new Error("expected a function");return s(i)?(0,l.default)(i):i},t.isAsync=s,t.isAsyncGenerator=function(i){return i[Symbol.toStringTag]==="AsyncGenerator"},t.isAsyncIterable=function(i){return typeof i[Symbol.asyncIterator]=="function"}},function(e,t,r){var n={};function o(s,i,c){c||(c=Error);var u=function(b){var A,_;function v(f,S,w){return b.call(this,function(P,N,T){return typeof i=="string"?i:i(P,N,T)}(f,S,w))||this}return _=b,(A=v).prototype=Object.create(_.prototype),A.prototype.constructor=A,A.__proto__=_,v}(c);u.prototype.name=c.name,u.prototype.code=s,n[s]=u}function l(s,i){if(Array.isArray(s)){var c=s.length;return s=s.map(function(u){return String(u)}),c>2?"one of ".concat(i," ").concat(s.slice(0,c-1).join(", "),", or ")+s[c-1]:c===2?"one of ".concat(i," ").concat(s[0]," or ").concat(s[1]):"of ".concat(i," ").concat(s[0])}return"of ".concat(i," ").concat(String(s))}o("ERR_INVALID_OPT_VALUE",function(s,i){return'The value "'+i+'" is invalid for option "'+s+'"'},TypeError),o("ERR_INVALID_ARG_TYPE",function(s,i,c){var u,b,A;if(typeof i=="string"&&(b="not ",i.substr(0,b.length)===b)?(u="must not be",i=i.replace(/^not /,"")):u="must be",function(v,f,S){return(S===void 0||S>v.length)&&(S=v.length),v.substring(S-f.length,S)===f}(s," argument"))A="The ".concat(s," ").concat(u," ").concat(l(i,"type"));else{var _=function(v,f,S){return typeof S!="number"&&(S=0),!(S+f.length>v.length)&&v.indexOf(f,S)!==-1}(s,".")?"property":"argument";A='The "'.concat(s,'" ').concat(_," ").concat(u," ").concat(l(i,"type"))}return A+=". Received type ".concat(typeof c)},TypeError),o("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),o("ERR_METHOD_NOT_IMPLEMENTED",function(s){return"The "+s+" method is not implemented"}),o("ERR_STREAM_PREMATURE_CLOSE","Premature close"),o("ERR_STREAM_DESTROYED",function(s){return"Cannot call "+s+" after a stream was destroyed"}),o("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),o("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),o("ERR_STREAM_WRITE_AFTER_END","write after end"),o("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),o("ERR_UNKNOWN_ENCODING",function(s){return"Unknown encoding: "+s},TypeError),o("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){(function(n){var o=Object.keys||function(v){var f=[];for(var S in v)f.push(S);return f};e.exports=b;var l=r(75),s=r(79);r(7)(b,l);for(var i=o(s.prototype),c=0;c<i.length;c++){var u=i[c];b.prototype[u]||(b.prototype[u]=s.prototype[u])}function b(v){if(!(this instanceof b))return new b(v);l.call(this,v),s.call(this,v),this.allowHalfOpen=!0,v&&(v.readable===!1&&(this.readable=!1),v.writable===!1&&(this.writable=!1),v.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",A)))}function A(){this._writableState.ended||n.nextTick(_,this)}function _(v){v.end()}Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(b.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(b.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(b.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(v){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=v,this._writableState.destroyed=v)}})}).call(this,r(2))},function(e,t,r){r.d(t,"a",function(){return s});var n=r(36),o=r(6);const l={"app-id":["app-id must match formant/*"]};class s extends n.a{constructor(c,u={}){super(c,Object.assign({validateHeaders:b=>`${b.get("app-id")}`.startsWith("formant/")?{}:l,headers:Object.assign(Object.assign({},s.headers),{"App-ID":`formant/${o.a}`,"App-Version":o.j})},u)),this.endpoint=c}}s.headers={}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(n,o=n.length){if(!o)throw new Error("arity is undefined");return function(...l){return typeof l[o-1]=="function"?n.apply(this,l):new Promise((s,i)=>{l[o-1]=(c,...u)=>{if(c)return i(c);s(u.length>1?u:u[0])},n.apply(this,l)})}},e.exports=t.default},function(e,t,r){(t=e.exports=r(67)).Stream=t,t.Readable=t,t.Writable=r(44),t.Duplex=r(20),t.Transform=r(70),t.PassThrough=r(164)},function(e,t,r){(t=e.exports=r(75)).Stream=t,t.Readable=t,t.Writable=r(79),t.Duplex=r(24),t.Transform=r(80),t.PassThrough=r(183),t.finished=r(45),t.pipeline=r(184)},function(e,t,r){r.d(t,"a",function(){return o});const n=["password","secret","token","key","buffer"];function o(l,s=new Set){return s.has(l)?"[ RECURSIVE ]":!(i=l)||typeof i!="object"&&typeof i!="function"?l:(s.add(l),Object.keys(l).reduce((c,u)=>(c[u]=n.some(b=>u.toLowerCase().includes(b.toLowerCase()))?"[ REDACTED ]":o(l[u],s),c),{}));var i}},function(e,t){e.exports=n,n.default=n,n.stable=l,n.stableStringify=l;var r=[];function n(s,i,c){(function A(_,v,f,S){var w;if(typeof _=="object"&&_!==null){for(w=0;w<f.length;w++)if(f[w]===_)return S[v]="[Circular]",void r.push([S,v,_]);if(f.push(_),Array.isArray(_))for(w=0;w<_.length;w++)A(_[w],w,f,_);else{var P=Object.keys(_);for(w=0;w<P.length;w++){var N=P[w];A(_[N],N,f,_)}}f.pop()}})(s,"",[],void 0);for(var u=JSON.stringify(s,i,c);r.length!==0;){var b=r.pop();b[0][b[1]]=b[2]}return u}function o(s,i){return s<i?-1:s>i?1:0}function l(s,i,c){for(var u=function _(v,f,S,w){var P;if(typeof v=="object"&&v!==null){for(P=0;P<S.length;P++)if(S[P]===v)return w[f]="[Circular]",void r.push([w,f,v]);if(typeof v.toJSON=="function")return;if(S.push(v),Array.isArray(v))for(P=0;P<v.length;P++)_(v[P],P,S,v);else{var N={},T=Object.keys(v).sort(o);for(P=0;P<T.length;P++){var R=T[P];_(v[R],R,S,v),N[R]=v[R]}if(w===void 0)return N;r.push([w,f,v]),w[f]=N}S.pop()}}(s,"",[],void 0)||s,b=JSON.stringify(u,i,c);r.length!==0;){var A=r.pop();A[0][A[1]]=A[2]}return b}},function(e,t,r){var n=r(13),o=Object.keys||function(f){var S=[];for(var w in f)S.push(w);return S};e.exports=A;var l=Object.create(r(14));l.inherits=r(7);var s=r(142),i=r(60);l.inherits(A,s);for(var c=o(i.prototype),u=0;u<c.length;u++){var b=c[u];A.prototype[b]||(A.prototype[b]=i.prototype[b])}function A(f){if(!(this instanceof A))return new A(f);s.call(this,f),i.call(this,f),f&&f.readable===!1&&(this.readable=!1),f&&f.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,f&&f.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",_)}function _(){this.allowHalfOpen||this._writableState.ended||n.nextTick(v,this)}function v(f){f.end()}Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(A.prototype,"destroyed",{get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(f){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=f,this._writableState.destroyed=f)}}),A.prototype._destroy=function(f,S){this.push(null),this.end(),n.nextTick(S,f)}},function(e,t,r){var n=typeof Uint8Array!="undefined"&&typeof Uint16Array!="undefined"&&typeof Int32Array!="undefined";function o(i,c){return Object.prototype.hasOwnProperty.call(i,c)}t.assign=function(i){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var u=c.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var b in u)o(u,b)&&(i[b]=u[b])}}return i},t.shrinkBuf=function(i,c){return i.length===c?i:i.subarray?i.subarray(0,c):(i.length=c,i)};var l={arraySet:function(i,c,u,b,A){if(c.subarray&&i.subarray)i.set(c.subarray(u,u+b),A);else for(var _=0;_<b;_++)i[A+_]=c[u+_]},flattenChunks:function(i){var c,u,b,A,_,v;for(b=0,c=0,u=i.length;c<u;c++)b+=i[c].length;for(v=new Uint8Array(b),A=0,c=0,u=i.length;c<u;c++)_=i[c],v.set(_,A),A+=_.length;return v}},s={arraySet:function(i,c,u,b,A){for(var _=0;_<b;_++)i[A+_]=c[u+_]},flattenChunks:function(i){return[].concat.apply([],i)}};t.setTyped=function(i){i?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,l)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,s))},t.setTyped(n)},function(e,t,r){e.exports=r(185)},function(e,t,r){e.exports=function(n){return n}},function(e,t,r){e.exports=function(n,o){o||(o={}),typeof o=="function"&&(o={cmp:o});var l,s=typeof o.cycles=="boolean"&&o.cycles,i=o.cmp&&(l=o.cmp,function(u){return function(b,A){var _={key:b,value:u[b]},v={key:A,value:u[A]};return l(_,v)}}),c=[];return function u(b){if(b&&b.toJSON&&typeof b.toJSON=="function"&&(b=b.toJSON()),b!==void 0){if(typeof b=="number")return isFinite(b)?""+b:"null";if(typeof b!="object")return JSON.stringify(b);var A,_;if(Array.isArray(b)){for(_="[",A=0;A<b.length;A++)A&&(_+=","),_+=u(b[A])||"null";return _+"]"}if(b===null)return"null";if(c.indexOf(b)!==-1){if(s)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var v=c.push(b)-1,f=Object.keys(b).sort(i&&i(b));for(_="",A=0;A<f.length;A++){var S=f[A],w=u(b[S]);w&&(_&&(_+=","),_+=JSON.stringify(S)+":"+w)}return c.splice(v,1),"{"+_+"}"}}(n)}},function(e,t,r){r.d(t,"a",function(){return N});var n=r(11),o=r(0);function l(T,R,d=()=>!0){if(T instanceof R&&d(T))return T;throw T}var s=r(1),i=r(100),c=r.n(i),u=r(101),b=r.n(u);class A extends Error{constructor(R,d,I){super(`Connection failure: ${R.message}`),this.cause=R,this.url=d,this.retryable=I}}var _=r(29);class v extends Error{constructor(R,d,I,Q,Z={},h){super(`Unexpected response (${I}) for ${R} ${d}: ${JSON.stringify(h?Object(_.a)([...h.entries()].reduce((p,[C,m])=>(p[C]=m,p),{})):{})} -- ${JSON.stringify(Object(_.a)(Q))}`),this.method=R,this.url=d,this.statusCode=I,this.body=Q,this.validationErrors=Z,this.headers=h}}class f extends Error{constructor(R,d){super(`Invalid headers (${JSON.stringify(R)}) for response: ${d.message}`),this.validationErrors=R,this.responseError=d}}var S=function(T,R,d,I){return new(d||(d=Promise))(function(Q,Z){function h(m){try{C(I.next(m))}catch(x){Z(x)}}function p(m){try{C(I.throw(m))}catch(x){Z(x)}}function C(m){var x;m.done?Q(m.value):(x=m.value,x instanceof d?x:new d(function(F){F(x)})).then(h,p)}C((I=I.apply(T,R||[])).next())})},w=function(T,R){var d={};for(var I in T)Object.prototype.hasOwnProperty.call(T,I)&&R.indexOf(I)<0&&(d[I]=T[I]);if(T!=null&&typeof Object.getOwnPropertySymbols=="function"){var Q=0;for(I=Object.getOwnPropertySymbols(T);Q<I.length;Q++)R.indexOf(I[Q])<0&&Object.prototype.propertyIsEnumerable.call(T,I[Q])&&(d[I[Q]]=T[I[Q]])}return d};const P=new Set(["GET","HEAD","PUT","QUERY","DELETE","OPTIONS","TRACE"]);class N{constructor(R,d={}){if(this.endpoint=R,this.validateHeaders=I=>d.validateHeaders?d.validateHeaders(I):{},this.verbose=d.verbose!==!1,this.headers=d.headers||{},d.retries!==void 0&&!(d.retries>=0))throw new Error("retries must be positive or zero");if(this.configuredRetries=d.retries,d.timeoutMs!==void 0&&!(d.timeoutMs>0))throw new Error("timeoutMs must be positive");if(this.timeoutMs=d.timeoutMs,d.maxBackoffDelayMs!==void 0&&!(d.maxBackoffDelayMs>0))throw new Error("maxBackoffDelayMs must be positive");this.maxBackoffDelayMs=d.maxBackoffDelayMs||30*s.a.second}getRetries(){return this.configuredRetries!==void 0?this.configuredRetries:this.constructor.retries}fetch(R,d={}){return S(this,void 0,void 0,function*(){return(yield this.fetchVerbose(R,d)).body})}fetchVerbose(R,d={}){return S(this,void 0,void 0,function*(){let I=100*s.a.millisecond,Q=0;const Z=this.timeoutMs!==void 0?new Date().getTime()+this.timeoutMs:void 0,h=Z?()=>Math.max(Z-new Date().getTime(),0):void 0;for(;;)try{return yield this.doFetch(R,d,h)}catch(p){const C=l(p,A);if((h==null?void 0:h())===0||Q===this.getRetries()||!C.retryable)throw C;Q++,I=Math.min(...h?[h()]:[],I*(2+.1*(Math.random()-.5)),this.maxBackoffDelayMs),yield Object(n.a)(I),this.verbose&&o.a.warn(`Connection failure, retrying. Error: ${p.cause.message}`,{url:p.url,error:p.cause,attempt:Q})}})}doFetch(R,d,I){return S(this,void 0,void 0,function*(){const{token:Q,json:Z,allowUnsafeRetries:h}=d,p=w(d,["token","json","allowUnsafeRetries"]),C=(p.method||"GET").toUpperCase(),m=this.endpoint!==void 0?`${this.endpoint}${R?`/${R}`:""}`:R,x=new c.a;let F;if(I){const D=I();D>0?F=setTimeout(()=>{x.abort()},D):x.abort()}try{let D;yield Promise.race([this.constructor.waitForConnectivity(),new Promise(B=>{D=setTimeout(B,I?Math.min(s.a.minute,I()):s.a.minute)})]),D&&clearTimeout(D);const O=yield b()(m,Object.assign(Object.assign({},p),{headers:Object.assign(Object.assign(Object.assign(Object.assign({},Z!==!1?{"Content-Type":"application/json"}:{}),this.headers),p.headers||{}),Q!==void 0?{Authorization:`Bearer ${Q}`}:{}),signal:x.signal})),L=O.headers.get("content-type")||"",k=L&&L.startsWith("application/json"),E=k?yield O.json():yield O.text(),g=()=>new v(C,m,O.status,E,E&&E.validationErrors||{},O.headers);if(!O.ok)throw this.verbose&&o.a[O.status>=500?"warn":"info"]("Response error",{method:C,url:m,statusCode:O.status}),g();const U=this.validateHeaders(O.headers);if(Object.keys(U).length!==0)throw new f(U,g());if(O.status===204)return{body:void 0,headers:O.headers};if(Z&&!k)throw new Error(`Response is not JSON: ${JSON.stringify(E)}`);return{body:E,headers:O.headers}}catch(D){const O=h||P.has(C);if(D.message==="Network request failed")throw new A(D,m,O);if(D.type==="system"&&["EAI_AGAIN","ECONNREFUSED","EHOSTUNREACH","ENOTFOUND"].find(g=>g===D.code))throw new A(D,m,!0);if(D.type==="system"&&["ETIMEDOUT","ECONNRESET","ESOCKETTIMEDOUT","EPIPE"].find(g=>g===D.code))throw new A(D,m,O);if(D.name==="AbortError")throw new A(D,m,O);const L=l(D,v),{statusCode:k}=L;if(k===408||k===429||k===502||k===503||k===504)throw this.verbose&&!O&&o.a.warn("Potentially unsafe retry"),new A(D,m,!0);const E=this.validateHeaders(L.headers);throw Object.keys(E).length!==0?new f(E,L):(yield this.constructor.onResponseError(L),D)}finally{F&&clearTimeout(F)}})}}N.retries=8,N.waitForConnectivity=()=>S(void 0,void 0,void 0,function*(){}),N.onResponseError=()=>S(void 0,void 0,void 0,function*(){})},function(e,t,r){function n(A,_){if(!(A instanceof _))throw new TypeError("Cannot call a class as a function")}function o(A,_){for(var v=0;v<_.length;v++){var f=_[v];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(A,f.key,f)}}var l=r(57),s=r(3),i=s.LEVEL,c=s.MESSAGE;l.enabled=!0;var u=/\s+/,b=function(){function A(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};n(this,A),S.colors&&this.addColors(S.colors),this.options=S}var _,v,f;return _=A,f=[{key:"addColors",value:function(S){var w=Object.keys(S).reduce(function(P,N){return P[N]=u.test(S[N])?S[N].split(u):S[N],P},{});return A.allColors=Object.assign({},A.allColors||{},w),A.allColors}}],(v=[{key:"addColors",value:function(S){return A.addColors(S)}},{key:"colorize",value:function(S,w,P){if(P===void 0&&(P=w),!Array.isArray(A.allColors[S]))return l[A.allColors[S]](P);for(var N=0,T=A.allColors[S].length;N<T;N++)P=l[A.allColors[S][N]](P);return P}},{key:"transform",value:function(S,w){return w.all&&typeof S[c]=="string"&&(S[c]=this.colorize(S[i],S.level,S[c])),(w.level||w.all||!w.message)&&(S.level=this.colorize(S[i],S.level)),(w.all||w.message)&&(S.message=this.colorize(S[i],S.level,S.message)),S}}])&&o(_.prototype,v),f&&o(_,f),A}();e.exports=function(A){return new b(A)},e.exports.Colorizer=e.exports.Format=b},function(e,t){var r={}.toString;e.exports=Array.isArray||function(n){return r.call(n)=="[object Array]"}},function(e,t,r){(function(n){function o(l){try{if(!n.localStorage)return!1}catch{return!1}var s=n.localStorage[l];return s!=null&&String(s).toLowerCase()==="true"}e.exports=function(l,s){if(o("noDeprecation"))return l;var i=!1;return function(){if(!i){if(o("throwDeprecation"))throw new Error(s);o("traceDeprecation")?console.trace(s):console.warn(s),i=!0}return l.apply(this,arguments)}}}).call(this,r(5))},function(e,t,r){var n=r(4),o=n.Buffer;function l(i,c){for(var u in i)c[u]=i[u]}function s(i,c,u){return o(i,c,u)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(l(n,t),t.Buffer=s),l(o,s),s.from=function(i,c,u){if(typeof i=="number")throw new TypeError("Argument must not be a number");return o(i,c,u)},s.alloc=function(i,c,u){if(typeof i!="number")throw new TypeError("Argument must be a number");var b=o(i);return c!==void 0?typeof u=="string"?b.fill(c,u):b.fill(c):b.fill(0),b},s.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return o(i)},s.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(i)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(n){return n&&typeof n.length=="number"&&n.length>=0&&n.length%1==0},e.exports=t.default},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default={},e.exports=t.default},function(e,t,r){var n=r(4),o=n.Buffer;function l(i,c){for(var u in i)c[u]=i[u]}function s(i,c,u){return o(i,c,u)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=n:(l(n,t),t.Buffer=s),l(o,s),s.from=function(i,c,u){if(typeof i=="number")throw new TypeError("Argument must not be a number");return o(i,c,u)},s.alloc=function(i,c,u){if(typeof i!="number")throw new TypeError("Argument must be a number");var b=o(i);return c!==void 0?typeof u=="string"?b.fill(c,u):b.fill(c):b.fill(0),b},s.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return o(i)},s.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(i)}},function(e,t,r){(function(n,o,l){var s=r(13);function i(p){var C=this;this.next=null,this.entry=null,this.finish=function(){(function(m,x,F){var D=m.entry;for(m.entry=null;D;){var O=D.callback;x.pendingcb--,O(F),D=D.next}x.corkedRequestsFree?x.corkedRequestsFree.next=m:x.corkedRequestsFree=m})(C,p)}}e.exports=T;var c,u=!n.browser&&["v0.10","v0.9."].indexOf(n.version.slice(0,5))>-1?o:s.nextTick;T.WritableState=N;var b=r(14);b.inherits=r(7);var A={deprecate:r(39)},_=r(68),v=r(43).Buffer,f=l.Uint8Array||function(){},S,w=r(69);function P(){}function N(p,C){c=c||r(20),p=p||{};var m=C instanceof c;this.objectMode=!!p.objectMode,m&&(this.objectMode=this.objectMode||!!p.writableObjectMode);var x=p.highWaterMark,F=p.writableHighWaterMark,D=this.objectMode?16:16384;this.highWaterMark=x||x===0?x:m&&(F||F===0)?F:D,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var O=p.decodeStrings===!1;this.decodeStrings=!O,this.defaultEncoding=p.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(L){(function(k,E){var g=k._writableState,U=g.sync,B=g.writecb;if(function(Y){Y.writing=!1,Y.writecb=null,Y.length-=Y.writelen,Y.writelen=0}(g),E)(function(Y,K,H,V,y){--K.pendingcb,H?(s.nextTick(y,V),s.nextTick(h,Y,K),Y._writableState.errorEmitted=!0,Y.emit("error",V)):(y(V),Y._writableState.errorEmitted=!0,Y.emit("error",V),h(Y,K))})(k,g,U,E,B);else{var G=Q(g);G||g.corked||g.bufferProcessing||!g.bufferedRequest||I(k,g),U?u(d,k,g,G,B):d(k,g,G,B)}})(C,L)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new i(this)}function T(p){if(c=c||r(20),!(S.call(T,this)||this instanceof c))return new T(p);this._writableState=new N(p,this),this.writable=!0,p&&(typeof p.write=="function"&&(this._write=p.write),typeof p.writev=="function"&&(this._writev=p.writev),typeof p.destroy=="function"&&(this._destroy=p.destroy),typeof p.final=="function"&&(this._final=p.final)),_.call(this)}function R(p,C,m,x,F,D,O){C.writelen=x,C.writecb=O,C.writing=!0,C.sync=!0,m?p._writev(F,C.onwrite):p._write(F,D,C.onwrite),C.sync=!1}function d(p,C,m,x){m||function(F,D){D.length===0&&D.needDrain&&(D.needDrain=!1,F.emit("drain"))}(p,C),C.pendingcb--,x(),h(p,C)}function I(p,C){C.bufferProcessing=!0;var m=C.bufferedRequest;if(p._writev&&m&&m.next){var x=C.bufferedRequestCount,F=new Array(x),D=C.corkedRequestsFree;D.entry=m;for(var O=0,L=!0;m;)F[O]=m,m.isBuf||(L=!1),m=m.next,O+=1;F.allBuffers=L,R(p,C,!0,C.length,F,"",D.finish),C.pendingcb++,C.lastBufferedRequest=null,D.next?(C.corkedRequestsFree=D.next,D.next=null):C.corkedRequestsFree=new i(C),C.bufferedRequestCount=0}else{for(;m;){var k=m.chunk,E=m.encoding,g=m.callback;if(R(p,C,!1,C.objectMode?1:k.length,k,E,g),m=m.next,C.bufferedRequestCount--,C.writing)break}m===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=m,C.bufferProcessing=!1}function Q(p){return p.ending&&p.length===0&&p.bufferedRequest===null&&!p.finished&&!p.writing}function Z(p,C){p._final(function(m){C.pendingcb--,m&&p.emit("error",m),C.prefinished=!0,p.emit("prefinish"),h(p,C)})}function h(p,C){var m=Q(C);return m&&(function(x,F){F.prefinished||F.finalCalled||(typeof x._final=="function"?(F.pendingcb++,F.finalCalled=!0,s.nextTick(Z,x,F)):(F.prefinished=!0,x.emit("prefinish")))}(p,C),C.pendingcb===0&&(C.finished=!0,p.emit("finish"))),m}b.inherits(T,_),N.prototype.getBuffer=function(){for(var p=this.bufferedRequest,C=[];p;)C.push(p),p=p.next;return C},function(){try{Object.defineProperty(N.prototype,"buffer",{get:A.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}(),typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(S=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(p){return!!S.call(this,p)||this===T&&p&&p._writableState instanceof N}})):S=function(p){return p instanceof this},T.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},T.prototype.write=function(p,C,m){var x,F=this._writableState,D=!1,O=!F.objectMode&&(x=p,v.isBuffer(x)||x instanceof f);return O&&!v.isBuffer(p)&&(p=function(L){return v.from(L)}(p)),typeof C=="function"&&(m=C,C=null),O?C="buffer":C||(C=F.defaultEncoding),typeof m!="function"&&(m=P),F.ended?function(L,k){var E=new Error("write after end");L.emit("error",E),s.nextTick(k,E)}(this,m):(O||function(L,k,E,g){var U=!0,B=!1;return E===null?B=new TypeError("May not write null values to stream"):typeof E=="string"||E===void 0||k.objectMode||(B=new TypeError("Invalid non-string/buffer chunk")),B&&(L.emit("error",B),s.nextTick(g,B),U=!1),U}(this,F,p,m))&&(F.pendingcb++,D=function(L,k,E,g,U,B){if(!E){var G=function(V,y,j){return V.objectMode||V.decodeStrings===!1||typeof y!="string"||(y=v.from(y,j)),y}(k,g,U);g!==G&&(E=!0,U="buffer",g=G)}var Y=k.objectMode?1:g.length;k.length+=Y;var K=k.length<k.highWaterMark;if(K||(k.needDrain=!0),k.writing||k.corked){var H=k.lastBufferedRequest;k.lastBufferedRequest={chunk:g,encoding:U,isBuf:E,callback:B,next:null},H?H.next=k.lastBufferedRequest:k.bufferedRequest=k.lastBufferedRequest,k.bufferedRequestCount+=1}else R(L,k,!1,Y,g,U,B);return K}(this,F,O,p,C,m)),D},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var p=this._writableState;p.corked&&(p.corked--,p.writing||p.corked||p.finished||p.bufferProcessing||!p.bufferedRequest||I(this,p))},T.prototype.setDefaultEncoding=function(p){if(typeof p=="string"&&(p=p.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((p+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+p);return this._writableState.defaultEncoding=p,this},Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(p,C,m){m(new Error("_write() is not implemented"))},T.prototype._writev=null,T.prototype.end=function(p,C,m){var x=this._writableState;typeof p=="function"?(m=p,p=null,C=null):typeof C=="function"&&(m=C,C=null),p!=null&&this.write(p,C),x.corked&&(x.corked=1,this.uncork()),x.ending||x.finished||function(F,D,O){D.ending=!0,h(F,D),O&&(D.finished?s.nextTick(O):F.once("finish",O)),D.ended=!0,F.writable=!1}(this,x,m)},Object.defineProperty(T.prototype,"destroyed",{get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(p){this._writableState&&(this._writableState.destroyed=p)}}),T.prototype.destroy=w.destroy,T.prototype._undestroy=w.undestroy,T.prototype._destroy=function(p,C){this.end(),C(p)}}).call(this,r(2),r(12).setImmediate,r(5))},function(e,t,r){var n=r(23).codes.ERR_STREAM_PREMATURE_CLOSE;function o(){}e.exports=function l(s,i,c){if(typeof i=="function")return l(s,null,i);i||(i={}),c=function(T){var R=!1;return function(){if(!R){R=!0;for(var d=arguments.length,I=new Array(d),Q=0;Q<d;Q++)I[Q]=arguments[Q];T.apply(this,I)}}}(c||o);var u=i.readable||i.readable!==!1&&s.readable,b=i.writable||i.writable!==!1&&s.writable,A=function(){s.writable||v()},_=s._writableState&&s._writableState.finished,v=function(){b=!1,_=!0,u||c.call(s)},f=s._readableState&&s._readableState.endEmitted,S=function(){u=!1,f=!0,b||c.call(s)},w=function(T){c.call(s,T)},P=function(){var T;return u&&!f?(s._readableState&&s._readableState.ended||(T=new n),c.call(s,T)):b&&!_?(s._writableState&&s._writableState.ended||(T=new n),c.call(s,T)):void 0},N=function(){s.req.on("finish",v)};return function(T){return T.setHeader&&typeof T.abort=="function"}(s)?(s.on("complete",v),s.on("abort",P),s.req?N():s.on("request",N)):b&&!s._writableState&&(s.on("end",A),s.on("close",A)),s.on("end",S),s.on("finish",v),i.error!==!1&&s.on("error",w),s.on("close",P),function(){s.removeListener("complete",v),s.removeListener("abort",P),s.removeListener("request",N),s.req&&s.req.removeListener("finish",v),s.removeListener("end",A),s.removeListener("close",A),s.removeListener("finish",v),s.removeListener("end",S),s.removeListener("error",w),s.removeListener("close",P)}}},function(e,t,r){var n=r(193),o=r(195);function l(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}t.parse=T,t.resolve=function(R,d){return T(R,!1,!0).resolve(d)},t.resolveObject=function(R,d){return R?T(R,!1,!0).resolveObject(d):d},t.format=function(R){return o.isString(R)&&(R=T(R)),R instanceof l?R.format():l.prototype.format.call(R)},t.Url=l;var s=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",`
|
|
20
20
|
`," "]),b=["'"].concat(u),A=["%","/","?",";","#"].concat(b),_=["/","?","#"],v=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,S={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},P={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},N=r(196);function T(R,d,I){if(R&&o.isObject(R)&&R instanceof l)return R;var Q=new l;return Q.parse(R,d,I),Q}l.prototype.parse=function(R,d,I){if(!o.isString(R))throw new TypeError("Parameter 'url' must be a string, not "+typeof R);var Q=R.indexOf("?"),Z=Q!==-1&&Q<R.indexOf("#")?"?":"#",h=R.split(Z);h[0]=h[0].replace(/\\/g,"/");var p=R=h.join(Z);if(p=p.trim(),!I&&R.split("#").length===1){var C=c.exec(p);if(C)return this.path=p,this.href=p,this.pathname=C[1],C[2]?(this.search=C[2],this.query=d?N.parse(this.search.substr(1)):this.search.substr(1)):d&&(this.search="",this.query={}),this}var m=s.exec(p);if(m){var x=(m=m[0]).toLowerCase();this.protocol=x,p=p.substr(m.length)}if(I||m||p.match(/^\/\/[^@\/]+@[^@\/]+/)){var F=p.substr(0,2)==="//";!F||m&&w[m]||(p=p.substr(2),this.slashes=!0)}if(!w[m]&&(F||m&&!P[m])){for(var D,O,L=-1,k=0;k<_.length;k++)(E=p.indexOf(_[k]))!==-1&&(L===-1||E<L)&&(L=E);for((O=L===-1?p.lastIndexOf("@"):p.lastIndexOf("@",L))!==-1&&(D=p.slice(0,O),p=p.slice(O+1),this.auth=decodeURIComponent(D)),L=-1,k=0;k<A.length;k++){var E;(E=p.indexOf(A[k]))!==-1&&(L===-1||E<L)&&(L=E)}L===-1&&(L=p.length),this.host=p.slice(0,L),p=p.slice(L),this.parseHost(),this.hostname=this.hostname||"";var g=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!g)for(var U=this.hostname.split(/\./),B=(k=0,U.length);k<B;k++){var G=U[k];if(G&&!G.match(v)){for(var Y="",K=0,H=G.length;K<H;K++)G.charCodeAt(K)>127?Y+="x":Y+=G[K];if(!Y.match(v)){var V=U.slice(0,k),y=U.slice(k+1),j=G.match(f);j&&(V.push(j[1]),y.unshift(j[2])),y.length&&(p="/"+y.join(".")+p),this.hostname=V.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),g||(this.hostname=n.toASCII(this.hostname));var W=this.port?":"+this.port:"",ee=this.hostname||"";this.host=ee+W,this.href+=this.host,g&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),p[0]!=="/"&&(p="/"+p))}if(!S[x])for(k=0,B=b.length;k<B;k++){var X=b[k];if(p.indexOf(X)!==-1){var ne=encodeURIComponent(X);ne===X&&(ne=escape(X)),p=p.split(X).join(ne)}}var ie=p.indexOf("#");ie!==-1&&(this.hash=p.substr(ie),p=p.slice(0,ie));var he=p.indexOf("?");if(he!==-1?(this.search=p.substr(he),this.query=p.substr(he+1),d&&(this.query=N.parse(this.query)),p=p.slice(0,he)):d&&(this.search="",this.query={}),p&&(this.pathname=p),P[x]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){W=this.pathname||"";var Se=this.search||"";this.path=W+Se}return this.href=this.format(),this},l.prototype.format=function(){var R=this.auth||"";R&&(R=(R=encodeURIComponent(R)).replace(/%3A/i,":"),R+="@");var d=this.protocol||"",I=this.pathname||"",Q=this.hash||"",Z=!1,h="";this.host?Z=R+this.host:this.hostname&&(Z=R+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(Z+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(h=N.stringify(this.query));var p=this.search||h&&"?"+h||"";return d&&d.substr(-1)!==":"&&(d+=":"),this.slashes||(!d||P[d])&&Z!==!1?(Z="//"+(Z||""),I&&I.charAt(0)!=="/"&&(I="/"+I)):Z||(Z=""),Q&&Q.charAt(0)!=="#"&&(Q="#"+Q),p&&p.charAt(0)!=="?"&&(p="?"+p),d+Z+(I=I.replace(/[?#]/g,function(C){return encodeURIComponent(C)}))+(p=p.replace("#","%23"))+Q},l.prototype.resolve=function(R){return this.resolveObject(T(R,!1,!0)).format()},l.prototype.resolveObject=function(R){if(o.isString(R)){var d=new l;d.parse(R,!1,!0),R=d}for(var I=new l,Q=Object.keys(this),Z=0;Z<Q.length;Z++){var h=Q[Z];I[h]=this[h]}if(I.hash=R.hash,R.href==="")return I.href=I.format(),I;if(R.slashes&&!R.protocol){for(var p=Object.keys(R),C=0;C<p.length;C++){var m=p[C];m!=="protocol"&&(I[m]=R[m])}return P[I.protocol]&&I.hostname&&!I.pathname&&(I.path=I.pathname="/"),I.href=I.format(),I}if(R.protocol&&R.protocol!==I.protocol){if(!P[R.protocol]){for(var x=Object.keys(R),F=0;F<x.length;F++){var D=x[F];I[D]=R[D]}return I.href=I.format(),I}if(I.protocol=R.protocol,R.host||w[R.protocol])I.pathname=R.pathname;else{for(var O=(R.pathname||"").split("/");O.length&&!(R.host=O.shift()););R.host||(R.host=""),R.hostname||(R.hostname=""),O[0]!==""&&O.unshift(""),O.length<2&&O.unshift(""),I.pathname=O.join("/")}if(I.search=R.search,I.query=R.query,I.host=R.host||"",I.auth=R.auth,I.hostname=R.hostname||R.host,I.port=R.port,I.pathname||I.search){var L=I.pathname||"",k=I.search||"";I.path=L+k}return I.slashes=I.slashes||R.slashes,I.href=I.format(),I}var E=I.pathname&&I.pathname.charAt(0)==="/",g=R.host||R.pathname&&R.pathname.charAt(0)==="/",U=g||E||I.host&&R.pathname,B=U,G=I.pathname&&I.pathname.split("/")||[],Y=(O=R.pathname&&R.pathname.split("/")||[],I.protocol&&!P[I.protocol]);if(Y&&(I.hostname="",I.port=null,I.host&&(G[0]===""?G[0]=I.host:G.unshift(I.host)),I.host="",R.protocol&&(R.hostname=null,R.port=null,R.host&&(O[0]===""?O[0]=R.host:O.unshift(R.host)),R.host=null),U=U&&(O[0]===""||G[0]==="")),g)I.host=R.host||R.host===""?R.host:I.host,I.hostname=R.hostname||R.hostname===""?R.hostname:I.hostname,I.search=R.search,I.query=R.query,G=O;else if(O.length)G||(G=[]),G.pop(),G=G.concat(O),I.search=R.search,I.query=R.query;else if(!o.isNullOrUndefined(R.search))return Y&&(I.hostname=I.host=G.shift(),(j=!!(I.host&&I.host.indexOf("@")>0)&&I.host.split("@"))&&(I.auth=j.shift(),I.host=I.hostname=j.shift())),I.search=R.search,I.query=R.query,o.isNull(I.pathname)&&o.isNull(I.search)||(I.path=(I.pathname?I.pathname:"")+(I.search?I.search:"")),I.href=I.format(),I;if(!G.length)return I.pathname=null,I.search?I.path="/"+I.search:I.path=null,I.href=I.format(),I;for(var K=G.slice(-1)[0],H=(I.host||R.host||G.length>1)&&(K==="."||K==="..")||K==="",V=0,y=G.length;y>=0;y--)(K=G[y])==="."?G.splice(y,1):K===".."?(G.splice(y,1),V++):V&&(G.splice(y,1),V--);if(!U&&!B)for(;V--;V)G.unshift("..");!U||G[0]===""||G[0]&&G[0].charAt(0)==="/"||G.unshift(""),H&&G.join("/").substr(-1)!=="/"&&G.push("");var j,W=G[0]===""||G[0]&&G[0].charAt(0)==="/";return Y&&(I.hostname=I.host=W?"":G.length?G.shift():"",(j=!!(I.host&&I.host.indexOf("@")>0)&&I.host.split("@"))&&(I.auth=j.shift(),I.host=I.hostname=j.shift())),(U=U||I.host&&G.length)&&!W&&G.unshift(""),G.length?I.pathname=G.join("/"):(I.pathname=null,I.path=null),o.isNull(I.pathname)&&o.isNull(I.search)||(I.path=(I.pathname?I.pathname:"")+(I.search?I.search:"")),I.auth=R.auth||I.auth,I.slashes=I.slashes||R.slashes,I.href=I.format(),I},l.prototype.parseHost=function(){var R=this.host,d=i.exec(R);d&&((d=d[0])!==":"&&(this.port=d.substr(1)),R=R.substr(0,R.length-d.length)),R&&(this.hostname=R)}},function(e,t,r){var n=r(56),o=r(3).configs;t.cli=n.levels(o.cli),t.npm=n.levels(o.npm),t.syslog=n.levels(o.syslog),t.addColors=n.levels},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=i(r(202)),o=i(r(203)),l=i(r(22)),s=i(r(26));function i(c){return c&&c.__esModule?c:{default:c}}t.default=(0,s.default)(function(c,u,b){return(0,n.default)(c,(0,o.default)((0,l.default)(u)),b)},3),e.exports=t.default},function(e,t,r){function n(o){Error.captureStackTrace(this,this.constructor),this.name="EnvVarError",this.message=`env-var: ${o}`}(0,r(10).inherits)(n,Error),e.exports=n},function(e,t,r){e.exports=function(n){const o=parseInt(n,10);if(isNaN(o)||n.toString().indexOf(".")!==-1)throw new Error("should be a valid integer");return o}},function(e,t,r){e.exports=function(n){const o=parseFloat(n);if(isNaN(o))throw new Error("should be a valid float");return o}},function(e,t,r){e.exports=function(n){try{return JSON.parse(n)}catch{throw new Error("should be valid (parseable) JSON")}}},function(e,t,r){(function(n){function o(i,c){for(var u=0,b=i.length-1;b>=0;b--){var A=i[b];A==="."?i.splice(b,1):A===".."?(i.splice(b,1),u++):u&&(i.splice(b,1),u--)}if(c)for(;u--;u)i.unshift("..");return i}function l(i,c){if(i.filter)return i.filter(c);for(var u=[],b=0;b<i.length;b++)c(i[b],b,i)&&u.push(i[b]);return u}t.resolve=function(){for(var i="",c=!1,u=arguments.length-1;u>=-1&&!c;u--){var b=u>=0?arguments[u]:n.cwd();if(typeof b!="string")throw new TypeError("Arguments to path.resolve must be strings");b&&(i=b+"/"+i,c=b.charAt(0)==="/")}return(c?"/":"")+(i=o(l(i.split("/"),function(A){return!!A}),!c).join("/"))||"."},t.normalize=function(i){var c=t.isAbsolute(i),u=s(i,-1)==="/";return(i=o(l(i.split("/"),function(b){return!!b}),!c).join("/"))||c||(i="."),i&&u&&(i+="/"),(c?"/":"")+i},t.isAbsolute=function(i){return i.charAt(0)==="/"},t.join=function(){var i=Array.prototype.slice.call(arguments,0);return t.normalize(l(i,function(c,u){if(typeof c!="string")throw new TypeError("Arguments to path.join must be strings");return c}).join("/"))},t.relative=function(i,c){function u(w){for(var P=0;P<w.length&&w[P]==="";P++);for(var N=w.length-1;N>=0&&w[N]==="";N--);return P>N?[]:w.slice(P,N-P+1)}i=t.resolve(i).substr(1),c=t.resolve(c).substr(1);for(var b=u(i.split("/")),A=u(c.split("/")),_=Math.min(b.length,A.length),v=_,f=0;f<_;f++)if(b[f]!==A[f]){v=f;break}var S=[];for(f=v;f<b.length;f++)S.push("..");return(S=S.concat(A.slice(v))).join("/")},t.sep="/",t.delimiter=":",t.dirname=function(i){if(typeof i!="string"&&(i+=""),i.length===0)return".";for(var c=i.charCodeAt(0),u=c===47,b=-1,A=!0,_=i.length-1;_>=1;--_)if((c=i.charCodeAt(_))===47){if(!A){b=_;break}}else A=!1;return b===-1?u?"/":".":u&&b===1?"/":i.slice(0,b)},t.basename=function(i,c){var u=function(b){typeof b!="string"&&(b+="");var A,_=0,v=-1,f=!0;for(A=b.length-1;A>=0;--A)if(b.charCodeAt(A)===47){if(!f){_=A+1;break}}else v===-1&&(f=!1,v=A+1);return v===-1?"":b.slice(_,v)}(i);return c&&u.substr(-1*c.length)===c&&(u=u.substr(0,u.length-c.length)),u},t.extname=function(i){typeof i!="string"&&(i+="");for(var c=-1,u=0,b=-1,A=!0,_=0,v=i.length-1;v>=0;--v){var f=i.charCodeAt(v);if(f!==47)b===-1&&(A=!1,b=v+1),f===46?c===-1?c=v:_!==1&&(_=1):c!==-1&&(_=-1);else if(!A){u=v+1;break}}return c===-1||b===-1||_===0||_===1&&c===b-1&&c===u+1?"":i.slice(c,b)};var s="ab".substr(-1)==="b"?function(i,c,u){return i.substr(c,u)}:function(i,c,u){return c<0&&(c=i.length+c),i.substr(c,u)}}).call(this,r(2))},function(e,t){function r(n,o){var l=[],s=[];return o==null&&(o=function(i,c){return l[0]===c?"[Circular ~]":"[Circular ~."+s.slice(0,l.indexOf(c)).join(".")+"]"}),function(i,c){if(l.length>0){var u=l.indexOf(this);~u?l.splice(u+1):l.push(this),~u?s.splice(u,1/0,i):s.push(i),~l.indexOf(c)&&(c=o.call(this,i,c))}else l.push(c);return n==null?c:n.call(this,i,c)}}(e.exports=function(n,o,l,s){return JSON.stringify(n,r(o,s),l)}).getSerialize=r},function(e,t,r){r(225),e.exports={encode:n=>new TextEncoder().encode(n),decode:n=>new TextDecoder().decode(n)}},function(e,t,r){var n=t.format=r(9);t.levels=r(104),Object.defineProperty(n,"align",{value:r(121)}),Object.defineProperty(n,"cli",{value:r(122)}),Object.defineProperty(n,"combine",{value:r(123)}),Object.defineProperty(n,"colorize",{value:r(37)}),Object.defineProperty(n,"json",{value:r(124)}),Object.defineProperty(n,"label",{value:r(127)}),Object.defineProperty(n,"logstash",{value:r(128)}),Object.defineProperty(n,"metadata",{value:r(129)}),Object.defineProperty(n,"padLevels",{value:r(58)}),Object.defineProperty(n,"prettyPrint",{value:r(130)}),Object.defineProperty(n,"printf",{value:r(131)}),Object.defineProperty(n,"simple",{value:r(132)}),Object.defineProperty(n,"splat",{value:r(133)}),Object.defineProperty(n,"timestamp",{value:r(134)}),Object.defineProperty(n,"uncolorize",{value:r(136)})},function(e,t,r){var n=r(105);e.exports=n},function(e,t,r){function n(_){return function(v){if(Array.isArray(v))return o(v)}(_)||function(v){if(typeof Symbol!="undefined"&&Symbol.iterator in Object(v))return Array.from(v)}(_)||function(v,f){if(!!v){if(typeof v=="string")return o(v,f);var S=Object.prototype.toString.call(v).slice(8,-1);if(S==="Object"&&v.constructor&&(S=v.constructor.name),S==="Map"||S==="Set")return Array.from(v);if(S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S))return o(v,f)}}(_)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
21
21
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function o(_,v){(v==null||v>_.length)&&(v=_.length);for(var f=0,S=new Array(v);f<v;f++)S[f]=_[f];return S}function l(_,v){if(!(_ instanceof v))throw new TypeError("Cannot call a class as a function")}function s(_,v){for(var f=0;f<v.length;f++){var S=v[f];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(_,S.key,S)}}var i=r(3),c=i.configs,u=i.LEVEL,b=i.MESSAGE,A=function(){function _(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{levels:c.npm.levels};l(this,_),this.paddings=_.paddingForLevels(w.levels,w.filler),this.options=w}var v,f,S;return v=_,S=[{key:"getLongestLevel",value:function(w){var P=Object.keys(w).map(function(N){return N.length});return Math.max.apply(Math,n(P))}},{key:"paddingForLevel",value:function(w,P,N){var T=N+1-w.length,R=Math.floor(T/P.length);return"".concat(P).concat(P.repeat(R)).slice(0,T)}},{key:"paddingForLevels",value:function(w){var P=arguments.length>1&&arguments[1]!==void 0?arguments[1]:" ",N=_.getLongestLevel(w);return Object.keys(w).reduce(function(T,R){return T[R]=_.paddingForLevel(R,P,N),T},{})}}],(f=[{key:"transform",value:function(w,P){return w.message="".concat(this.paddings[w[u]]).concat(w.message),w[b]&&(w[b]="".concat(this.paddings[w[u]]).concat(w[b])),w}}])&&s(v.prototype,f),S&&s(v,S),_}();e.exports=function(_){return new A(_)},e.exports.Padder=e.exports.Format=A},function(e,t,r){var n=r(10).format;t.warn={deprecated:function(o){return function(){throw new Error(n("{ %s } was removed in winston@3.0.0.",o))}},useFormat:function(o){return function(){throw new Error([n("{ %s } was removed in winston@3.0.0.",o),"Use a custom winston.format = winston.format(function) instead."].join(`
|
|
22
22
|
`))}},forFunctions:function(o,l,s){s.forEach(function(i){o[i]=t.warn[l](i)})},moved:function(o,l,s){function i(){return function(){throw new Error([n("winston.%s was moved in winston@3.0.0.",s),n("Use a winston.%s instead.",l)].join(`
|
|
@@ -41,4 +41,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
41
41
|
`))},s.prototype.close=function(){this.transport.close&&this.transport.close(),this.transport.__winstonError&&(this.transport.removeListener("error",this.transport.__winstonError),this.transport.__winstonError=null)}},function(e,t,r){function n(l){return(n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s})(l)}function o(l,s){for(var i=0;i<s.length;i++){var c=s[i];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(l,c.key,c)}}e.exports=function(){function l(c){if(function(u,b){if(!(u instanceof b))throw new TypeError("Cannot call a class as a function")}(this,l),!c)throw new Error("Logger is required for profiling.");this.logger=c,this.start=Date.now()}var s,i;return s=l,(i=[{key:"done",value:function(){for(var c=arguments.length,u=new Array(c),b=0;b<c;b++)u[b]=arguments[b];typeof u[u.length-1]=="function"&&(console.warn("Callback function no longer supported as of winston@3.0.0"),u.pop());var A=n(u[u.length-1])==="object"?u.pop():{};return A.level=A.level||"info",A.durationMs=Date.now()-this.start,this.logger.write(A)}}])&&o(s.prototype,i),l}()},function(e,t,r){(function(n){const o=r(208),{MESSAGE:l}=r(3),s=r(30);function i(c,u){return u instanceof n?u.toString("base64"):typeof u=="bigint"?u.toString():u}e.exports=o((c,u={})=>(c[l]=(u.stable?s.stableStringify:s)(c,u.replacer||i,u.space),c))}).call(this,r(4).Buffer)},function(e,t,r){class n extends Error{constructor(l){super(`Format functions must be synchronous taking a two arguments: (info, opts)
|
|
42
42
|
Found: ${l.toString().split(`
|
|
43
43
|
`)[0]}
|
|
44
|
-
`),Error.captureStackTrace(this,n)}}e.exports=o=>{if(o.length>2)throw new n(o);function l(i={}){this.options=i}function s(i){return new l(i)}return l.prototype.transform=o,s.Format=l,s}},function(e,t,r){function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}function o(s,i){for(var c=0;c<i.length;c++){var u=i[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}var l=r(85);e.exports=function(){function s(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};n(this,s),this.loggers=new Map,this.options=u}var i,c;return i=s,(c=[{key:"add",value:function(u,b){var A=this;if(!this.loggers.has(u)){var _=(b=Object.assign({},b||this.options)).transports||this.options.transports;b.transports=_?_.slice():[];var v=l(b);v.on("close",function(){return A._delete(u)}),this.loggers.set(u,v)}return this.loggers.get(u)}},{key:"get",value:function(u,b){return this.add(u,b)}},{key:"has",value:function(u){return!!this.loggers.has(u)}},{key:"close",value:function(u){var b=this;if(u)return this._removeLogger(u);this.loggers.forEach(function(A,_){return b._removeLogger(_)})}},{key:"_removeLogger",value:function(u){this.loggers.has(u)&&(this.loggers.get(u).close(),this._delete(u))}},{key:"_delete",value:function(u){this.loggers.delete(u)}}])&&o(i.prototype,c),s}()},function(e,t,r){(function(n){const o=r(49),l=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/;e.exports=function(s,i,c){let u,b,A=!1,_=!1;function v(w,P){let N=`"${i}" ${P}`;throw w&&(N=`${N}, but is set to "${w}"`),b&&(N=`${N}. An example of a valid value would be: ${b}`),new o(N)}function f(w){return function(){let P=s[i];if(P===void 0)if(u===void 0&&_)v(void 0,"is a required variable, but it was not set");else{if(u===void 0)return;P=u}_&&P.trim().length===0&&v(void 0,"is a required variable, but its value was empty"),A&&(P.match(l)||v(P,"should be a valid base64 string if using convertFromBase64"),P=n.from(P,"base64").toString());const N=[P].concat(Array.prototype.slice.call(arguments));try{return w.apply(w,N)}catch(T){v(P,T.message)}}}const S={asArray:f(r(211)),asBoolStrict:f(r(212)),asBool:f(r(213)),asPortNumber:f(r(214)),asEnum:f(r(215)),asFloatNegative:f(r(216)),asFloatPositive:f(r(217)),asFloat:f(r(51)),asIntNegative:f(r(218)),asIntPositive:f(r(91)),asInt:f(r(50)),asJsonArray:f(r(219)),asJsonObject:f(r(220)),asJson:f(r(52)),asString:f(r(34)),asUrlObject:f(r(92)),asUrlString:f(r(221)),convertFromBase64:function(){return A=!0,S},default:function(w){if(typeof w=="number")u=w.toString();else if(Array.isArray(w)||typeof w=="object"&&w!==null)u=JSON.stringify(w);else{if(typeof w!="string")throw new o("values passed to default() must be of Number, String, Array, or Object type");u=w}return S},required:function(w){return _=w===void 0||w,S},example:function(w){return b=w,S}};return Object.entries(c).forEach(([w,P])=>{S[w]=f(P)}),S}}).call(this,r(4).Buffer)},function(e,t,r){const n=r(34);e.exports=function(o,l){return l=l||",",o.length?n(o).split(l).filter(Boolean):[]}},function(e,t,r){e.exports=function(n){const o=n.toLowerCase();if(o!=="false"&&o!=="true")throw new Error('should be either "true", "false", "TRUE", or "FALSE"');return o!=="false"}},function(e,t,r){e.exports=function(n){const o=n.toLowerCase();if(["false","0","true","1"].indexOf(o)===-1)throw new Error('should be either "true", "false", "TRUE", "FALSE", 1, or 0');return!(o==="0"||o==="false")}},function(e,t,r){const n=r(91);e.exports=function(o){var l=n(o);if(l>65535)throw new Error("cannot assign a port number greater than 65535");return l}},function(e,t,r){const n=r(34);e.exports=function(o,l){const s=n(o);if(l.indexOf(s)<0)throw new Error(`should be one of [${l.join(", ")}]`);return s}},function(e,t,r){const n=r(51);e.exports=function(o){const l=n(o);if(l>0)throw new Error("should be a negative float");return l}},function(e,t,r){const n=r(51);e.exports=function(o){const l=n(o);if(l<0)throw new Error("should be a positive float");return l}},function(e,t,r){const n=r(50);e.exports=function(o){const l=n(o);if(l>0)throw new Error("should be a negative integer");return l}},function(e,t,r){const n=r(52);e.exports=function(o){var l=n(o);if(!Array.isArray(l))throw new Error("should be a parseable JSON Array");return l}},function(e,t,r){const n=r(52);e.exports=function(o){var l=n(o);if(Array.isArray(l))throw new Error("should be a parseable JSON Object");return l}},function(e,t,r){const n=r(92);e.exports=function(o){return n(o).toString()}},function(e,t,r){(function(n){(function(){var o,l,s,i,c,u;typeof performance!="undefined"&&performance!==null&&performance.now?e.exports=function(){return performance.now()}:n!=null&&n.hrtime?(e.exports=function(){return(o()-c)/1e6},l=n.hrtime,i=(o=function(){var b;return 1e9*(b=l())[0]+b[1]})(),u=1e9*n.uptime(),c=i-u):Date.now?(e.exports=function(){return Date.now()-s},s=Date.now()):(e.exports=function(){return new Date().getTime()-s},s=new Date().getTime())}).call(this)}).call(this,r(2))},function(e,t,r){var n,o,l=r(96),s=r(97),i=0,c=0;e.exports=function(u,b,A){var _=b&&A||0,v=b||[],f=(u=u||{}).node||n,S=u.clockseq!==void 0?u.clockseq:o;if(f==null||S==null){var w=l();f==null&&(f=n=[1|w[0],w[1],w[2],w[3],w[4],w[5]]),S==null&&(S=o=16383&(w[6]<<8|w[7]))}var P=u.msecs!==void 0?u.msecs:new Date().getTime(),N=u.nsecs!==void 0?u.nsecs:c+1,T=P-i+(N-c)/1e4;if(T<0&&u.clockseq===void 0&&(S=S+1&16383),(T<0||P>i)&&u.nsecs===void 0&&(N=0),N>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");i=P,c=N,o=S;var R=(1e4*(268435455&(P+=122192928e5))+N)%4294967296;v[_++]=R>>>24&255,v[_++]=R>>>16&255,v[_++]=R>>>8&255,v[_++]=255&R;var d=P/4294967296*1e4&268435455;v[_++]=d>>>8&255,v[_++]=255&d,v[_++]=d>>>24&15|16,v[_++]=d>>>16&255,v[_++]=S>>>8|128,v[_++]=255&S;for(var I=0;I<6;++I)v[_+I]=f[I];return b||s(v)}},function(e,t,r){var n=r(96),o=r(97);e.exports=function(l,s,i){var c=s&&i||0;typeof l=="string"&&(s=l==="binary"?new Array(16):null,l=null);var u=(l=l||{}).random||(l.rng||n)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,s)for(var b=0;b<16;++b)s[c+b]=u[b];return s||o(u)}},function(e,t,r){(function(n){(function(o){function l(i){if((i=i===void 0?"utf-8":i)!=="utf-8")throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+i+"') is invalid.")}function s(i,c){if(c=c===void 0?{fatal:!1}:c,(i=i===void 0?"utf-8":i)!=="utf-8")throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+i+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(o.TextEncoder&&o.TextDecoder)return!1;Object.defineProperty(l.prototype,"encoding",{value:"utf-8"}),l.prototype.encode=function(i,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var u=i.length,b=0,A=Math.max(32,u+(u>>1)+7),_=new Uint8Array(A>>3<<3);c<u;){var v=i.charCodeAt(c++);if(55296<=v&&56319>=v){if(c<u){var f=i.charCodeAt(c);(64512&f)==56320&&(++c,v=((1023&v)<<10)+(1023&f)+65536)}if(55296<=v&&56319>=v)continue}if(b+4>_.length&&(A+=8,A=(A*=1+c/i.length*2)>>3<<3,(f=new Uint8Array(A)).set(_),_=f),(4294967168&v)==0)_[b++]=v;else{if((4294965248&v)==0)_[b++]=v>>6&31|192;else if((4294901760&v)==0)_[b++]=v>>12&15|224,_[b++]=v>>6&63|128;else{if((4292870144&v)!=0)continue;_[b++]=v>>18&7|240,_[b++]=v>>12&63|128,_[b++]=v>>6&63|128}_[b++]=63&v|128}}return _.slice(0,b)},Object.defineProperty(s.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(s.prototype,"fatal",{value:!1}),Object.defineProperty(s.prototype,"ignoreBOM",{value:!1}),s.prototype.decode=function(i,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");c=0;for(var u=(i=new Uint8Array(i)).length,b=[];c<u;){var A=i[c++];if(A===0)break;if((128&A)==0)b.push(A);else if((224&A)==192){var _=63&i[c++];b.push((31&A)<<6|_)}else if((240&A)==224){_=63&i[c++];var v=63&i[c++];b.push((31&A)<<12|_<<6|v)}else(248&A)==240&&(65535<(A=(7&A)<<18|(_=63&i[c++])<<12|(v=63&i[c++])<<6|63&i[c++])&&(A-=65536,b.push(A>>>10&1023|55296),A=56320|1023&A),b.push(A))}return String.fromCharCode.apply(null,b)},o.TextEncoder=l,o.TextDecoder=s})(typeof window!="undefined"?window:n!==void 0?n:this)}).call(this,r(5))},function(e,t,r){r.r(t),r.d(t,"AuthClient",function(){return l}),r.d(t,"RtcSignalingClient",function(){return i}),r.d(t,"Credentials",function(){return P}),r.d(t,"SignalingPromiseClient",function(){return N.SignalingPromiseClient}),r.d(t,"IRtcClientConfiguration",function(){}),r.d(t,"IRtcConnectConfiguration",function(){}),r.d(t,"IRtcConnectionStatsInfo",function(){}),r.d(t,"IRtcSendConfiguration",function(){}),r.d(t,"IRtcSessionMetricsMessageCounts",function(){}),r.d(t,"IRtcStreamMessage",function(){}),r.d(t,"IStreamControl",function(){}),r.d(t,"RtcClient",function(){return Ee}),r.d(t,"createRtcStreamMessage",function(){return X}),r.d(t,"IRtcStream",function(){}),r.d(t,"IRtcStreamPayload",function(){});var n=r(25),o=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class l extends n.a{adminSignup(q,$){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/admin-signup",{token:$,method:"POST",body:JSON.stringify(q)})})}login(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/login",{method:"POST",body:JSON.stringify(q),allowUnsafeRetries:!0})})}loginWithGoogleToken(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/login-google",{method:"POST",body:JSON.stringify(q),allowUnsafeRetries:!0})})}refresh(q,$){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/refresh",{method:"POST",body:JSON.stringify({refreshToken:q,tokenExpirationSeconds:$}),allowUnsafeRetries:!0})})}respondToNewPasswordRequiredChallenge(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/respond-to-new-password-required-challenge",{method:"POST",body:JSON.stringify(q)})})}forgotPassword(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/forgot-password",{method:"POST",body:JSON.stringify({email:q})})})}confirmForgotPassword(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/confirm-forgot-password",{method:"POST",body:JSON.stringify(q)})})}resendInvitation(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/resend-invitation",{method:"POST",body:JSON.stringify({email:q})})})}changePassword({token:q,refreshToken:$,currentPassword:te,newPassword:ue}){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/change-password",{token:q,method:"POST",body:JSON.stringify({refreshToken:$,currentPassword:te,newPassword:ue})})})}getDeviceCredentials(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/device-credentials",{token:q,method:"POST",allowUnsafeRetries:!0})})}impersonate(q,$){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/impersonate",{token:q,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({userId:$})})})}createServiceAccount(q,$,te,ue){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/service-account",{token:q,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({name:$,roleId:te,tags:ue})})})}getFeatures(q){return o(this,void 0,void 0,function*(){return(yield this.fetch("auth/features",{token:q})).features})}}var s=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class i extends n.a{createPeer(q,$){return s(this,void 0,void 0,function*(){return yield this.fetch("peers",{token:q,method:"POST",body:JSON.stringify($)})})}getPeers(q){return s(this,void 0,void 0,function*(){return(yield this.fetch("peers",{token:q})).items})}refreshPeer(q,$){return s(this,void 0,void 0,function*(){yield this.fetch(`peers/${$}/refresh`,{token:q,method:"POST",allowUnsafeRetries:!0})})}createSession(q,$){return s(this,void 0,void 0,function*(){return yield this.fetch("sessions",{token:q,method:"POST",body:JSON.stringify($)})})}refreshSession(q,$){return s(this,void 0,void 0,function*(){yield this.fetch(`sessions/${$}/refresh`,{token:q,method:"POST",allowUnsafeRetries:!0})})}deleteSession(q,$){return s(this,void 0,void 0,function*(){yield this.fetch(`sessions/${$}`,{token:q,method:"DELETE",allowUnsafeRetries:!0})})}getSessions(q){return s(this,void 0,void 0,function*(){return(yield this.fetch("sessions",{token:q})).items})}getIceServers(q){return s(this,void 0,void 0,function*(){return(yield this.fetch("ice-servers",{token:q})).items})}addSignals(q,$,te){return s(this,void 0,void 0,function*(){yield this.fetch(`sessions/${$}/add-signals`,{token:q,method:"POST",body:JSON.stringify(te)})})}takeSignals(q,$){return s(this,void 0,void 0,function*(){return(yield this.fetch(`sessions/${$}/take-signals`,{token:q,method:"POST"})).items})}}var c=r(1),u=r(11),b=r(35),A=r.n(b),_=r(102),v=r.n(_),f=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class S extends class{constructor(q){this.cache=new v.a(Object.assign(Object.assign({},q.dispose||q.disposeAfter?{ttlAutopurge:!0}:{}),q)),this.stringify=q.fastStringify?JSON.stringify:A.a}set(q,$,te){const ue=this.stringify(q);if(!this.cache.set(ue,$,{ttl:te})){const ae=this.cache.sizeCalculation?this.cache.sizeCalculation($,ue):"unknown";throw Error(`Value too large (${ae} > ${this.cache.max})`)}}get(q){return this.cache.get(this.stringify(q))}delete(q){this.cache.delete(this.stringify(q))}size(){return this.cache.size}clear(){this.cache.clear()}forEach(q){return this.cache.forEach(q)}}{constructor(q){if(super(q),this.expireRejectedPromiseValues=q.expireRejectedPromiseValues===void 0||q.expireRejectedPromiseValues,this.rejectedPromiseValueTtl=q.rejectedPromiseValueTtl!==void 0?q.rejectedPromiseValueTtl:c.a.second,this.rejectedPromiseValueTtl<0)throw new Error("rejectedPromiseValueTtl must not be negative")}set(q,$,te){const ue=this.stringify(q);this.cache.set(ue,$,{ttl:te}),this.expireRejectedPromiseValues&&Promise.resolve($).catch(()=>f(this,void 0,void 0,function*(){yield Object(u.a)(this.rejectedPromiseValueTtl),this.cache.peek(ue)===$&&this.cache.delete(ue)}))}}var w=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class P{constructor(q,$,te){this.authClient=q,this.email=$,this.password=te,this.tokenTtlMs=1*c.a.hour,this.tokenCache=new S({max:100,ttl:this.tokenTtlMs-5*c.a.minute,fastStringify:!0})}getToken(){return w(this,void 0,void 0,function*(){let q=this.tokenCache.get(this.email);return q||(q=(()=>w(this,void 0,void 0,function*(){const{authentication:$}=yield this.authClient.login({email:this.email,password:this.password,tokenExpirationSeconds:this.tokenTtlMs/c.a.second});if(!$)throw new Error("User account not verified.");return $.accessToken}))(),this.tokenCache.set(this.email,q)),q})}}var N=r(93),T=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};function R(ye){return T(this,void 0,void 0,function*(){return(yield Promise.all(ye.map(q=>q.catch($=>$)))).filter(q=>q instanceof Error)})}function d(ye){if(ye!==void 0)return ye;throw new Error("Value is undefined")}var I=r(0),Q=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};function Z({func:ye,delay:q,immediate:$}){let te=!1,ue=setTimeout(function de(){return Q(this,void 0,void 0,function*(){if(te)return;const me=new Date().getTime();try{ae=ye(),yield ae}finally{if(!te){const pe=new Date().getTime();ue=setTimeout(de,Math.max(q-(pe-me),0))}}})},$?0:q),ae=Promise.resolve();return{stop(){return Q(this,void 0,void 0,function*(){te=!0,clearTimeout(ue),yield ae})}}}function h(ye,q){return Object.keys(ye).reduce(($,te)=>Object.assign(Object.assign({},$),{[te]:q(ye[te])}),{})}var p=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class C{constructor(q){this.message=q}send(q){return p(this,void 0,void 0,function*(){I.a.info(this.message,h(q,$=>{const{sum:te,count:ue}=$,ae=te/ue;return Object.assign(Object.assign({},$),{average:ae})}))})}}var m=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};const x=r(222);var F=r(6);const D=!!F.c,O=new class{constructor(ye=60){this.buffer={},this.metrics={},this.reporters=[],this.flushInterval=Z({func:()=>this.flushStats(),delay:ye*c.a.second})}shutdown(){return m(this,void 0,void 0,function*(){yield this.flushInterval.stop(),yield this.flushStats(),yield Object(u.a)(2*c.a.second)})}aggregate(ye,q){if(this.buffer[ye]){const{min:$,max:te,sum:ue,count:ae}=this.buffer[ye];this.buffer[ye]={min:Math.min($,q),max:Math.max(te,q),sum:ue+q,count:ae+1}}else this.buffer[ye]={min:q,max:q,sum:q,count:1}}increment(ye){this.aggregate(ye,1)}timer(ye,q){return m(this,void 0,void 0,function*(){const $=x(),te=yield q(),ue=x();return this.aggregate(ye,ue-$),te})}metric(ye,q){this.metrics[ye]=q}registerStatsReporter(ye){this.reporters.push(ye)}write(ye){return m(this,void 0,void 0,function*(){if(Object.values(ye).length===0)return;const q=yield R(this.reporters.map($=>$.send(ye)));for(const $ of q)I.a.warn("Failed to write stats",{error:$})})}flushStats(){return m(this,void 0,void 0,function*(){const ye=Object.assign(Object.assign({},this.buffer),h(this.metrics,q=>{const $=q();return{min:$,max:$,sum:$,count:1}}));Object.keys(ye).length>0&&(yield this.write(ye),this.buffer={})})}};D||["local","on-prem"].includes(F.i)||O.registerStatsReporter(new C("stats"));var L=r(8),k=r(21),E=r(103),g=r(36),U=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class B extends g.a{constructor(q){super(q)}postLanRtcOffer(q){return U(this,void 0,void 0,function*(){return yield this.fetch("v1/lan-rtc-offer",{method:"POST",body:JSON.stringify(q)})})}}var G=r(55);const Y={ordered:!1,maxPacketLifeTime:300*c.a.millisecond},K={ordered:!0},H={ordered:!0},V={ordered:!1,maxRetransmits:0},y={ordered:!1,maxRetransmits:0};function j({entityId:ye,streamName:q,streamType:$}){return`${ye}.${q}.${$}`}var W=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class ee{constructor(q,$){this.sessionId=q,this.connection=$,this.counts={localSent:new Map,localReceived:new Map,remoteSent:new Map,remoteReceived:new Map},this.sessionId=q,this.connection=$}updateRemoteMessagesCounts(q){if(q.payload.streamsInfo){this.counts.remoteSent=new Map,this.counts.remoteReceived=new Map;for(const $ of q.payload.streamsInfo.items)this.counts.remoteSent.set($.streamId,$.sentCount),this.counts.remoteReceived.set($.streamId,$.receivedCount)}}getLocalStreamsInfo(q){const{localSent:$,localReceived:te}=this.counts;return{items:[...new Set([...$.keys(),...te.keys()])].map(ue=>{var ae,de;return{streamId:ue,sentCount:(ae=$.get(ue))!==null&&ae!==void 0?ae:0,receivedCount:(de=te.get(ue))!==null&&de!==void 0?de:0}}),timestamp:q}}incrementLocalSent(q){const{localSent:$}=this.counts,te=j(q.header.stream);$.set(te,($.get(te)||0)+1)}incrementLocalReceived(q){const{localReceived:$}=this.counts,te=j(q.header.stream),ue=$.get(te)||0;if(ue===0){const{streamName:ae,streamType:de}=q.header.stream;I.a.debug("RTC client received first message for stream",{streamName:ae,streamType:de})}$.set(te,ue+1)}uploadMetrics(){return W(this,void 0,void 0,function*(){const{sessionId:q}=this,$=yield this.connection.peerConnection.getStats(),te={};$.forEach(ge=>te[ge.id]=ge),I.a.debug("rtc-stats",Object.assign(Object.assign({},te),{sessionId:q}));const{localSent:ue,localReceived:ae,remoteSent:de,remoteReceived:me}=this.counts,pe=[...new Set([...ue.keys(),...ae.keys()])].reduce((ge,ce)=>{const Te=ue.get(ce),Re=ae.get(ce),Pe=de.get(ce),Le=me.get(ce);return Object.assign(Object.assign({},ge),{[`local-${ce}-sent`]:Te,[`local-${ce}-received`]:Re,[`remote-${ce}-sent`]:Pe,[`remote-${ce}-received`]:Le})},{sessionId:q});I.a.debug("rtc-message-report",Object.assign({deviceId:this.connection.getRemoteDeviceId()},pe))})}}function X(ye,q){return{header:{stream:ye,created:Date.now(),frameId:""},payload:q}}function ne(ye){return new Set(["disconnected","failed","closed"]).has(ye.iceConnectionState)}var ie=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class he{constructor(q,$,te){this.peerConnection=q,this.config=$,this.dataChannelNotifier=te,this.connectTimeoutMs=20*c.a.second,this.iceGatheringTimeoutMs=15*c.a.second,this.pingUpdateTimeoutMs=1*c.a.second,this.streamsInfoUpdateTimeoutMs=2*c.a.second,this.reassemblyTimeoutMs=500*c.a.millisecond,this.reassemblyTableCleanupMs=1*c.a.second,this.heartbeatTimeoutMs=20*c.a.millisecond,this.streamLatestTimestamp=new Map,this.reassemblyTable=new Map,this.reassemblyTableLastTimestamp=new Map,this.closeCalled=!1,this.gotOffer=!1,this.hasIceCandidate=!1;const{isOffer:ue}=$.baseConfig;ue?this.initializeChannels(q):q.ondatachannel=ae=>{switch(ae.channel.label){case"stream.latest-ttl":this.latestTtlStreamChannel=ae.channel;break;case"stream.reliable":this.reliableStreamChannel=ae.channel;break;case"stream.latest-reliable":this.latestReliableStreamChannel=ae.channel;break;case"stream.latest-try-once":this.latestTryOnceStreamChannel=ae.channel;break;case"heartbeat":return void(this.heartbeatChannel=ae.channel);default:return void this.dataChannelNotifier(ae.channel)}this.setupChannel(ae.channel)},this.pingUpdateTimeout=setInterval(()=>{const{reliableStreamChannel:ae}=this;ae&&this.sendSystemMessage(ae,{type:"ping"})},this.pingUpdateTimeoutMs),this.streamsInfoUpdateTimeout=setInterval(()=>{const{latestTtlStreamChannel:ae}=this;ae&&this.sendSystemMessage(ae,{type:"streams-info"})},this.streamsInfoUpdateTimeoutMs),this.reassemblyTableCleanupTimeout=setInterval(()=>{const ae=new Date().getTime();this.reassemblyTableLastTimestamp.forEach((de,me,pe)=>{ae>me+this.reassemblyTimeoutMs&&this.reassemblyTable.delete(de)})},this.reassemblyTableCleanupMs),this.heartbeatTimeout=setInterval(()=>{const{heartbeatChannel:ae}=this;ae&&ae.readyState==="open"&&ae.send(new Uint8Array([1]))},this.heartbeatTimeoutMs)}handleSignal(q){return ie(this,void 0,void 0,function*(){const{peerConnection:$}=this,{track:te}=this.config.baseConfig,ue=(()=>{try{return JSON.parse(q.getPayload())}catch{return}})();if(!ue)return void I.a.error("Received unparseable signal.");I.a.debug("Handling signal",{description:ue});const{sdp:ae,type:de}=ue;if(!ae||!de)return void I.a.warn("Received non-SDP signal");const{signalingState:me,connectionState:pe}=$;if(me!=="stable"||pe!=="connected")if($.remoteDescription)I.a.warn(`Received SDP after remote description was set: ${ae}`);else{if(de==="offer"){if(me!=="stable")return void I.a.warn("Received offer SDP when signaling is ongoing.");yield $.setRemoteDescription(ue);const ge=yield $.createAnswer();yield $.setLocalDescription(ge);const ce=q.clone();return te==null||te("Answer Received",ce),ce.setPayload(JSON.stringify(ge)),ce.setReceiverId(q.getSenderId()),ce.setSenderId(q.getReceiverId()),ce}if(de==="answer"){if(me==="stable")return void I.a.warn("Received answer SDP when signaling hasn't started.");yield $.setRemoteDescription(ue)}}else I.a.warn(`Received SDP when already connected: ${ae}`)})}send(q,$){const te=this.getChannelFromLabel($.channelLabel);te?this.sendOnChannel(te,q):I.a.warn("Send called with unexpected channel label",{channelLabel:$.channelLabel})}controlRemoteStream(q){this.sendSystemMessage(d(this.reliableStreamChannel),{type:"stream-control",streamControl:q})}isActive(){return new Set(["new","checking","connected","completed"]).has(this.peerConnection.iceConnectionState)||this.isReady()}isReady(){const{reliableStreamChannel:q,latestTtlStreamChannel:$,latestTryOnceStreamChannel:te,latestReliableStreamChannel:ue}=this;return(q==null?void 0:q.readyState)==="open"&&($==null?void 0:$.readyState)==="open"&&(te==null?void 0:te.readyState)==="open"&&(ue==null?void 0:ue.readyState)==="open"}close(){return ie(this,void 0,void 0,function*(){if(this.closeCalled)return;this.closeCalled=!0,this.sessionMetrics&&(yield this.sessionMetrics.uploadMetrics()),this.pingUpdateTimeout&&clearInterval(this.pingUpdateTimeout),this.reassemblyTableCleanupTimeout&&clearInterval(this.reassemblyTableCleanupTimeout),this.streamsInfoUpdateTimeout&&clearInterval(this.streamsInfoUpdateTimeout),this.heartbeatTimeout&&clearInterval(this.heartbeatTimeout);const{peerConnection:q,reliableStreamChannel:$,latestTtlStreamChannel:te,latestTryOnceStreamChannel:ue,latestReliableStreamChannel:ae}=this;q.close(),$==null||$.close(),te==null||te.close(),ue==null||ue.close(),ae==null||ae.close()})}getPing(){return this.pingTimeMs}getLastMessageTimestamp(){return this.lastMessageTimestamp}getSessionCreatedTimestamp(){var q;return(q=this.config.remoteConfig)===null||q===void 0?void 0:q.sessionCreatedTimestamp}setSessionCreatedTimestamp(q){this.config.remoteConfig&&(this.config.remoteConfig.sessionCreatedTimestamp=q)}getSessionId(){var q;return(q=this.config.remoteConfig)===null||q===void 0?void 0:q.sessionId}setSessionId(q){this.config.remoteConfig&&(this.config.remoteConfig.sessionId=q,this.sessionMetrics=new ee(q,this))}getRemotePeerId(){return this.config.baseConfig.remotePeerId}getRemoteDeviceId(){var q;return(q=this.config.baseConfig)===null||q===void 0?void 0:q.remoteDeviceId}setRemoteDeviceId(q){this.config.baseConfig.remoteDeviceId=q}getSessionMetricsMessageCounts(){var q;return(q=this.sessionMetrics)===null||q===void 0?void 0:q.counts}getConnectionStatsInfo(){return ie(this,void 0,void 0,function*(){const{peerConnection:q}=this;if(!q)return;const $=yield q.getStats(null),te=[];$.forEach(pe=>{te.push(pe)});const ue=te.find(pe=>pe.type==="transport");if(!ue)return;const ae=te.find(pe=>(pe.type==="candidate-pair"||pe.type==="candidatepair")&&pe.id===ue.selectedCandidatePairId);if(!ae)return;const de=te.find(pe=>pe.id===ae.localCandidateId),me=te.find(pe=>pe.id===ae.remoteCandidateId);return de&&me&&(de.address=de.address||de.ip,me.address=me.address||me.ip,de.address!==void 0&&me.address!==void 0)?{transport:ue,localCandidate:de,remoteCandidate:me}:void 0})}initializeChannels(q){this.heartbeatChannel=q.createDataChannel("heartbeat",y),this.heartbeatChannel.binaryType="arraybuffer",this.latestTtlStreamChannel=q.createDataChannel("stream.latest-ttl",Y),this.latestTtlStreamChannel.binaryType="arraybuffer",this.reliableStreamChannel=q.createDataChannel("stream.reliable",K),this.reliableStreamChannel.binaryType="arraybuffer",this.latestReliableStreamChannel=q.createDataChannel("stream.latest-reliable",H),this.latestReliableStreamChannel.binaryType="arraybuffer",this.latestTryOnceStreamChannel=q.createDataChannel("stream.latest-try-once",V),this.latestTryOnceStreamChannel.binaryType="arraybuffer",this.setupChannel(this.latestTtlStreamChannel),this.setupChannel(this.reliableStreamChannel),this.setupChannel(this.latestReliableStreamChannel),this.setupChannel(this.latestTryOnceStreamChannel)}getOffer(){var q,$,te;return ie(this,void 0,void 0,function*(){const{gotOffer:ue}=this,{peerConnection:ae,config:de}=this;if(this.config.baseConfig.isLan)throw new Error('"getOffer" method can only be called with internet connections. LAN connections should call the "getLanOffer" method.');const me=(q=this.config.remoteConfig)===null||q===void 0?void 0:q.sessionId;if(ue)return void I.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,ne(this.peerConnection))return void I.a.debug("Failed to generate offer because the peer connection was inactive.");const pe=de.baseConfig.track;ae.onicecandidate=()=>{this.hasIceCandidate=!0},ae.oniceconnectionstatechange=()=>ie(this,void 0,void 0,function*(){const Pe=ae.iceConnectionState;if(Pe==="connected"||Pe==="completed"){const Le=yield this.getConnectionStatsInfo(),Fe=Le?function(ze){const De=ze.localCandidate.candidateType,We=ze.remoteCandidate.candidateType;return De==="host"&&We==="host"?"local":De==="relay"||We==="relay"?"TURN":"STUN"}(Le):void 0;I.a.info(`ICE connection state changed to ${Pe}`,{sessionId:me,connectionStatsInfo:Le,iceMode:Fe}),pe==null||pe("ICE connection state change",{iceConnectionState:Pe,sessionId:me,connectionStatsInfo:Le,iceMode:Fe})}}),yield ae.setLocalDescription(yield ae.createOffer());const ge=new Date().getTime();for(;;){const Pe=new Date().getTime()-ge;if(Pe>this.connectTimeoutMs)return void I.a.debug("Failed to generate offer because ICE gathering timed out.");if(Pe>this.iceGatheringTimeoutMs&&this.hasIceCandidate){I.a.debug("ICE gathering partially completed; proceeding",{iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe}),pe==null||pe("ICE gathering partially completed",{sessionId:me,iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe});break}if(ae.iceGatheringState==="complete"){I.a.debug("ICE gathering complete",{iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe}),pe==null||pe("ICE gathering completed",{sessionId:me,iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe});break}yield Object(u.a)(.1*c.a.second)}const ce=($=this.peerConnection.getConfiguration().iceServers)!==null&&$!==void 0?$:[];for(const Pe of ce)Pe.credentialType=void 0;const Te=JSON.stringify(ce),Re=new L.Signal;return Re.setPayload(JSON.stringify(ae.localDescription)),Re.setSenderId(this.config.baseConfig.localPeerId),Re.setReceiverId(this.config.baseConfig.remotePeerId),Re.setIceServers(Te),Re.setIceTransportPolicy((te=this.peerConnection.getConfiguration().iceTransportPolicy)!==null&&te!==void 0?te:"all"),this.config.baseConfig.sessionType!==void 0?Re.setSessionType(this.config.baseConfig.sessionType):Re.setSessionType(L.SessionType.TELEOP),I.a.debug("Sending offer signal with description",{description:Re.getPayload()}),Re})}getLanOffer(){return ie(this,void 0,void 0,function*(){const{peerConnection:q,gotOffer:$}=this;if(!this.config.baseConfig.isLan)throw new Error('"getLanOffer" method can only be used with LAN connections. Internet connections should call the "getOffer" method.');if($)return void I.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,ne(this.peerConnection))return void I.a.debug("Failed to generate offer because the peer connection was inactive.");yield q.setLocalDescription(yield q.createOffer());const te=new Date().getTime();for(;;){if(new Date().getTime()-te>this.iceGatheringTimeoutMs)return void I.a.debug("Failed to generate offer because ICE gathering timed out.");if(q.iceGatheringState==="complete")break;yield Object(u.a)(.1*c.a.second)}const ue=q.localDescription;if(ue)return I.a.debug("Sending LAN offer signal with description",{description:ue}),ue;I.a.error("Failed to generate LAN offer description")})}handleLanAnswer(q){return ie(this,void 0,void 0,function*(){const{peerConnection:$}=this;if(!this.config.baseConfig.isLan)throw new Error('"handleLanAnswer" method can only be used with LAN connections. Internet connections should call the "handleSignal" method.');yield $.setRemoteDescription(q)})}getChannelFromLabel(q){switch(q){case"stream.latest-ttl":return this.latestTtlStreamChannel;case"stream.reliable":return this.reliableStreamChannel;case"stream.latest-reliable":return this.latestReliableStreamChannel;case"stream.latest-try-once":return this.latestTryOnceStreamChannel}}sendOnChannel(q,$){let te;try{te=Object(G.encode)(JSON.stringify($))}catch(ue){return void I.a.warn("Failed to encode RTC message",{error:ue})}try{q.send(te),this.sessionMetrics&&this.sessionMetrics.incrementLocalSent($)}catch(ue){I.a.warn("Failed to send message to channel",{error:ue,channel:q.label})}}channelNotRecognized(q){return q!==this.latestTtlStreamChannel&&q!==this.latestReliableStreamChannel&&q!==this.latestTryOnceStreamChannel&&q!==this.reliableStreamChannel}setupChannel(q){q.onmessage=$=>{if(this.channelNotRecognized(q))return void I.a.warn("Received message on unrecognized data channel.");let te;try{te=JSON.parse(Object(G.decode)($.data))}catch(ue){return void I.a.warn("Received unparseable message on RTC stream data channel",{error:ue,channel:q.label})}te.communicationType==="message-chunk"?this.receiveChannelMessageChunk(q,te):this.receiveChannelMessage(q,te)},q.onerror=$=>{I.a.warn(`Channel error: ${$.error}`,{error:$.error,sessionId:this.getSessionId(),channelLabel:q.label})},q.onopen=()=>{I.a.debug("Channel opened",{sessionId:this.getSessionId(),channelLabel:q.label})},q.onclose=()=>{const $={bufferedAmount:q.bufferedAmount,sessionId:this.getSessionId(),channelLabel:q.label};this.closeCalled===!1?I.a.debug("Unexpected channel closed",$):I.a.debug("Channel closed",$)}}receiveChannelMessage(q,$){const{config:te}=this,{remotePeerId:ue}=this.config.baseConfig;this.lastMessageTimestamp=new Date().getTime(),$=function(ae){switch(ae.header.stream.streamType){case"twist":{const{twist:de}=ae.payload;if(!de)throw Error("twist not in payload of RTC message with type twist");return{header:ae.header,payload:{twist:{linear:Object.assign({x:0,y:0,z:0},de.linear),angular:Object.assign({x:0,y:0,z:0},de.angular)}}}}case"pose":{const{pose:de}=ae.payload;if(!de)throw Error("pose not in payload of RTC message with type pose");return{header:ae.header,payload:{pose:{translation:Object.assign({x:0,y:0,z:0},de.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},de.rotation)}}}}case"pose-with-covariance":{const{poseWithCovariance:de}=ae.payload;if(!de)throw Error("poseWithCovariance not in payload of RTC message with type pose-with-covariance");const me=new Array(36).fill(0);return de.covariance.forEach((pe,ge)=>{if(ge>=36)throw Error("covariance contains more than 36 elements");me[ge]=pe}),{header:ae.header,payload:{poseWithCovariance:{pose:{translation:Object.assign({x:0,y:0,z:0},de.pose.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},de.pose.rotation)},covariance:me}}}}case"point":{const{point:de}=ae.payload;if(!de)throw Error("point not in payload of RTC message with type point");return{header:ae.header,payload:{point:Object.assign({x:0,y:0,z:0},de)}}}default:return ae}}($),this.sessionMetrics&&this.sessionMetrics.incrementLocalReceived($),this.handleSystemMessage(q,$)||(q===this.latestTryOnceStreamChannel||q===this.latestTtlStreamChannel||q===this.latestReliableStreamChannel)&&!this.isLatestMessage($)||te.baseConfig.receive(ue,$)}receiveChannelMessageChunk(q,$){const te=this.reassemblyTable.get($.id)||[];if(te.push($),te.length===$.total){const ue=function(ae){const de=ae.sort((me,pe)=>me.seq<pe.seq?-1:1).map(me=>me.part).reduce((me,pe)=>me+pe);try{return JSON.parse(de)}catch{return void I.a.warn("Could not reassemble RTC message chunks")}}(te);return ue&&this.receiveChannelMessage(q,ue),void this.reassemblyTable.delete($.id)}this.reassemblyTable.set($.id,te),this.reassemblyTableLastTimestamp.set($.id,new Date().getTime())}handleSystemMessage(q,$){var te,ue;const{config:ae}=this,{baseConfig:de}=ae,{remotePeerId:me}=de;switch($.header.stream.streamType){case"ping":return this.sendSystemMessage(q,{type:"pong",timestamp:d($.payload.ping)}),!0;case"pong":{const pe=new Date().getTime()-d($.payload.pong);return this.pingTimeMs=pe,O.aggregate("rtc-ping-time",pe),!0}case"streams-info":{const{sessionMetrics:pe}=this,ge=(te=$.payload.streamsInfo)===null||te===void 0?void 0:te.timestamp;return!!ge&&(pe==null||pe.updateRemoteMessagesCounts($),(ue=de.onStreamsInfoUpdate)===null||ue===void 0||ue.call(de,me,ge),!0)}case"stream-control":return!0;default:return!1}}sendSystemMessage(q,$){var te;const{localUserId:ue,localPeerId:ae}=this.config.baseConfig;if(q.readyState!=="open")return;const de={entityId:ue!=null?ue:ae,streamName:`$.${$.type}`,streamType:$.type};let me;switch($.type){case"ping":me={ping:new Date().getTime()};break;case"pong":me={pong:$.timestamp};break;case"stream-control":me={streamControl:$.streamControl};break;case"streams-info":me={streamsInfo:(te=this.sessionMetrics)===null||te===void 0?void 0:te.getLocalStreamsInfo(new Date().getTime())}}this.sendOnChannel(q,X(de,me))}isLatestMessage(q){const $=j(q.header.stream),te=(this.streamLatestTimestamp.get($)||0)<=q.header.created;return te&&this.streamLatestTimestamp.set($,q.header.created),te}}function Se(ye){var q,$;return{userId:(q=ye.getUserId())===null||q===void 0?void 0:q.getValue(),deviceId:($=ye.getDeviceId())===null||$===void 0?void 0:$.getValue(),organizationId:ye.getOrganizationId(),id:ye.getPeerId(),capabilities:[],capabilitySet:{}}}var we=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class Ee{constructor(q){this.config=q,this.grpcCallDeadline=5*c.a.second,this.refreshIntervalDelayMs=2*c.a.second,this.iceServersTtl=30*c.a.minute,this.connections=[],this.localConnections=[],this.isConnectionInitiator=new Map,this.isOutgoingConnection=new Map,this.peerDataChannelListeners=[];const{refreshIntervalDelayMs:$}=this;this.refreshInterval=Z({func:()=>we(this,void 0,void 0,function*(){try{yield this.update()}catch(te){I.a.warn("RTC refresh failed",{error:te})}}),delay:$,immediate:!0})}send(q,$,te){const ue=this.getActiveConnection(q);ue?ue.isReady()?ue.send($,te):I.a.warn("Send called with unready connection."):I.a.warn("Send called with no connection.")}controlRemoteStream(q,$){const te=this.getActiveConnection(q);te?te.isReady()?te.controlRemoteStream($):I.a.warn("controlRemoteStream called with unready connection."):I.a.warn("controlRemoteStream called with no connection.")}getLocalPeer(){return we(this,void 0,void 0,function*(){for(;!this.localPeer;)yield Object(u.a)(.1*c.a.second);return Se(this.localPeer)})}connect(q,$){var te,ue,ae;return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode===!0)throw new Error("connect method called in local only mode.");const{track:de,signalingClient:me}=this.config,{localPeer:pe,receiveSignalStream:ge,iceServers:ce}=this;if(!pe||!ge||!ce)return void I.a.warn("Connect called prior to local peer, receiveSignalStream, and ICE servers ready");if(this.getActiveConnection(q))return void I.a.warn("Connect called for peer with existing connection.");if(this.isOutgoingConnection.get(q))return void I.a.warn("Connect called for peer with an existing outgoing connection offer.");this.isOutgoingConnection.set(q,!0);const Te=new he(yield this.createRTCPeerConnection(ce,$),{baseConfig:{isOffer:!0,isLan:!1,receive:(De,We)=>this.config.receive(De,We),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(De,We)=>{var Be,ke;return(ke=(Be=this.config).onStreamsInfoUpdate)===null||ke===void 0?void 0:ke.call(Be,De,We)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(te=pe.getUserId())===null||te===void 0?void 0:te.getValue(),localPeerId:pe.getPeerId(),remotePeerId:q,sessionType:$==null?void 0:$.sessionType},remoteConfig:{}},De=>this.onCustomDataChannel(q,De)),Re=yield Te.getOffer();if(!Re)return I.a.error("Failed to generate offer."),void this.isOutgoingConnection.delete(q);I.a.debug("Sending offer."),de==null||de("Sending offer",Re);const Pe=new L.SendSignalRequest;Pe.setSignal(Re);const Le=yield(()=>we(this,void 0,void 0,function*(){try{return yield me.sendSignal(Pe,yield this.getMetadata({}))}catch(De){I.a.warn("Error when sending signal",{error:De})}}))();if(!this.isOutgoingConnection.get(q))return void I.a.debug("No offer set after receiving offer signal response.");I.a.debug("Offer sent.");const Fe=(ue=Le==null?void 0:Le.getSessionId())===null||ue===void 0?void 0:ue.getValue(),ze=(ae=Le==null?void 0:Le.getSessionCreatedTimestamp())===null||ae===void 0?void 0:ae.getValue();return Fe&&ze?(Te.setSessionId(Fe),Te.setSessionCreatedTimestamp(ze),this.isOutgoingConnection.delete(q),this.connections.push(Te),this.isConnectionInitiator.set(Te,!0),this.setupHandlers(Te),Fe):(I.a.warn("No session ID or no session created timestamp on send signal response."),void this.isOutgoingConnection.delete(q))})}connectLan(q){var $,te;return we(this,void 0,void 0,function*(){const ue=new B(q),ae=new he(yield this.createRTCPeerConnection([]),{baseConfig:{isOffer:!0,isLan:!0,receive:(ge,ce)=>this.config.receive(ge,ce),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ge,ce)=>{var Te,Re;return(Re=(Te=this.config).onStreamsInfoUpdate)===null||Re===void 0?void 0:Re.call(Te,ge,ce)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(te=($=this.localPeer)===null||$===void 0?void 0:$.getUserId())===null||te===void 0?void 0:te.getValue(),localPeerId:"lan_client",remotePeerId:q}},ge=>this.onCustomDataChannel(q,ge)),de=yield ae.getLanOffer();if(!de)return I.a.warn("Could not generate LAN offer"),!1;const me=yield ue.postLanRtcOffer({offer:JSON.stringify(de)}),pe=new RTCSessionDescription(JSON.parse(me.answer));return yield ae.handleLanAnswer(pe),this.localConnections.push(ae),this.isConnectionInitiator.set(ae,!0),Object(E.v4)()})}getConnections(){return[...this.connections,...this.localConnections]}createCustomDataChannel(q,$,te,ue,ae){const de=this.getActiveConnection(q);if(de&&this.isConnectionInitiator.has(de)){const pe=de.peerConnection.createDataChannel("custom."+$,te);return ue&&(pe.binaryType="arraybuffer"),ae(q,pe),()=>{}}const me=(pe,ge)=>{q===pe&&ge.label==="custom."+$&&ae(q,ge)};return this.peerDataChannelListeners.push(me),()=>{this.peerDataChannelListeners=this.peerDataChannelListeners.filter(pe=>pe!==me)}}onCustomDataChannel(q,$){this.peerDataChannelListeners.forEach(te=>te(q,$))}getConnectionStatus(q){if(this.isOutgoingConnection.get(q))return"connecting";const $=this.getActiveConnection(q);return $?$.isReady()?"connected":"connecting":"disconnected"}getConnectionStatsInfo(q){return we(this,void 0,void 0,function*(){const $=this.getActiveConnection(q);if($)return yield $.getConnectionStatsInfo()})}disconnect(q){return we(this,void 0,void 0,function*(){const $=this.getActiveConnection(q);$&&(yield $.close())})}getPeers(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:q}=this.config,$=yield(()=>we(this,void 0,void 0,function*(){try{return yield q.getPeers(new L.GetPeersRequest,yield this.getMetadata({}))}catch(ae){I.a.warn("Error when getting peers",{error:ae})}}))();if(!$)return[];const te=$.getPeersList();if(!te)return[];const ue=ae=>{var de,me;return(me=(de=ae.getPeerCreatedTimestamp())===null||de===void 0?void 0:de.getValue())!==null&&me!==void 0?me:0};return te.sort((ae,de)=>ue(de)-ue(ae)).map(ae=>Se(ae))})}getSessions(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:q}=this.config,$=yield(()=>we(this,void 0,void 0,function*(){try{return yield q.getPeers(new L.GetPeersRequest,yield this.getMetadata({}))}catch(ae){I.a.warn("Error when getting peers",{error:ae})}}))();if(!$)return{};const te=$.getPeersList(),ue={};for(const ae of te)ue[ae.getPeerId()]=ae.getSessionIdsList();return ue})}getPing(q){const $=this.getActiveConnection(q);if($)return $.getPing();I.a.warn("Attempted to get ping time from inactive peer.")}getLastMessageTimestamp(q){const $=this.getActiveConnection(q);if($)return $.getLastMessageTimestamp();I.a.warn("Attempted to get last message time from inactive peer.")}getSessionMetricsMessageCounts(q){const $=this.getActiveConnection(q);if($)return $.getSessionMetricsMessageCounts();I.a.warn("Attempted to get session metrics counts from inactive peer.")}isReady(){if(this.config.lanOnlyMode)return!0;const{localPeer:q,receiveSignalStream:$,iceServers:te}=this;return!!(q&&$&&te)}shutdown(){return we(this,void 0,void 0,function*(){I.a.info("Shutdown called on RTC client"),yield this.refreshInterval.stop(),this.receiveSignalStream&&this.receiveSignalStream.cancel();const q=this.connections;this.connections=[],yield this.closeConnections(q);const{localPeer:$}=this;if(!$||this.config.lanOnlyMode)return;const{signalingClient:te}=this.config;yield(()=>we(this,void 0,void 0,function*(){try{const ue=new L.DeletePeerRequest;ue.setPeerId($.getPeerId()),yield te.deletePeer(ue,yield this.getMetadata({}))}catch(ue){return void I.a.warn("Error deleting local peer",{error:ue})}}))()})}createPeer(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createPeer method cannot be used in local-only mode.");const{signalingClient:q}=this.config,$=yield(()=>we(this,void 0,void 0,function*(){try{return yield q.createPeer(new L.CreatePeerRequest,yield this.getMetadata({}))}catch(ue){throw new Error(`Was not able to create peer: ${JSON.stringify(ue)}`)}}))(),te=$==null?void 0:$.getPeer();if(!te)throw new Error("Response did not provide peer.");return this.localPeer=te})}createReceiveSignalStream(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createReceiveSignalStream method cannot be used in local-only mode.");const{signalingClient:q}=this.config,{localPeer:$,iceServers:te}=this;if(!$||!te)return;const{receiveSignalStream:ue}=this;ue&&ue.cancel();const ae=new L.ReceiveSignalStreamRequest;ae.setPeerId($.getPeerId());const de=yield(()=>we(this,void 0,void 0,function*(){try{return q.receiveSignalStream(ae,yield this.getMetadata({hasDeadline:!1}))}catch(me){throw new Error(`Unable to create receive signal stream: ${JSON.stringify(me)}`)}}))();if(!de)throw new Error("Response did not provide stream.");return de.on("data",me=>we(this,void 0,void 0,function*(){var pe,ge,ce,Te;const Re=me.getSignal(),Pe=(pe=Re==null?void 0:Re.getSessionId())===null||pe===void 0?void 0:pe.getValue(),Le=Re==null?void 0:Re.getSenderId(),Fe=Re==null?void 0:Re.getReceiverId(),ze=(ge=Re==null?void 0:Re.getSessionCreatedTimestamp())===null||ge===void 0?void 0:ge.getValue();if(!(Re&&Pe&&Le&&Fe&&ze))return void I.a.warn("Received signal with missing information.");const De=this.getActiveConnection(Le);if(De)if(De.getSessionId()!==Pe){if(I.a.debug("Received signal: different session for a peer we're already connected to."),(De.getSessionCreatedTimestamp()||0)>ze)return;const We=new he(yield this.createRTCPeerConnection(te),{baseConfig:{isOffer:!1,isLan:!1,receive:(Be,ke)=>this.config.receive(Be,ke),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(Be,ke)=>{var qe,Ge;return(Ge=(qe=this.config).onStreamsInfoUpdate)===null||Ge===void 0?void 0:Ge.call(qe,Be,ke)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:$.getPeerId(),localUserId:(Te=$.getUserId())===null||Te===void 0?void 0:Te.getValue(),remotePeerId:Le},remoteConfig:{sessionId:Pe,sessionCreatedTimestamp:ze}},Be=>this.onCustomDataChannel(Le,Be));yield We.handleSignal(Re),this.connections.push(We)}else I.a.debug("Received signal: for an existing connection."),yield De.handleSignal(Re);else{I.a.debug("Received signal: new connection.");const We=new he(yield this.createRTCPeerConnection(te),{baseConfig:{isOffer:!1,isLan:!1,receive:(Be,ke)=>this.config.receive(Be,ke),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(Be,ke)=>{var qe,Ge;return(Ge=(qe=this.config).onStreamsInfoUpdate)===null||Ge===void 0?void 0:Ge.call(qe,Be,ke)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:$.getPeerId(),localUserId:(ce=$.getUserId())===null||ce===void 0?void 0:ce.getValue(),remotePeerId:Le},remoteConfig:{sessionId:Pe,sessionCreatedTimestamp:ze}},Be=>this.onCustomDataChannel(Le,Be));yield We.handleSignal(Re),this.connections.push(We)}})),de.on("end",()=>{de.cancel(),this.receiveSignalStream=void 0}),de.on("error",me=>{switch(me.code){case k.StatusCode.CANCELLED:case k.StatusCode.UNAVAILABLE:case k.StatusCode.UNKNOWN:I.a.debug("Receive signal stream error",{error:me});break;case k.StatusCode.UNAUTHENTICATED:I.a.warn("Receive signal stream error",{error:me});break;default:I.a.error("Receive signal stream error",{error:me})}de.cancel(),this.receiveSignalStream=void 0}),this.receiveSignalStream=de})}createRTCPeerConnection(q,$){var te;return we(this,void 0,void 0,function*(){const ue=$==null?void 0:$.rtcIceTransportPolicies,ae=$!=null&&$.rtcIceServerProtocol?[$==null?void 0:$.rtcIceServerProtocol]:void 0,de=q.map(pe=>Object.assign(Object.assign({},pe),{urls:typeof pe.urls=="string"?[pe.urls]:pe.urls})).map(pe=>Object.assign(Object.assign({},pe),{urls:pe.urls.filter(ge=>{const ce=(ue===void 0||ue.some(Te=>((Re,Pe)=>{switch(Pe){case"stun":return/^stuns?:/.test(Re);case"turn":return/^turns?:/.test(Re)}})(ge,Te)))&&(ae===void 0||ae.some(Te=>((Re,Pe)=>Re.endsWith(`transport=${Pe}`))(ge,Te)));return ce||I.a.debug(`Ignoring ICE server: ${ge}`),ce})})).filter(({urls:pe})=>pe.filter(ge=>ge).length>0),me=(te=this.config.alternateRTCPeerConnection)!==null&&te!==void 0?te:window.RTCPeerConnection;if(!me)throw new Error("RTCPeerConnection class not found. WebRTC must be enabled.");return new me(Object.assign({iceServers:de,iceTransportPolicy:(ue==null?void 0:ue.length)===1&&ue[0]==="turn"?"relay":"all"},$))})}closeConnections(q){return we(this,void 0,void 0,function*(){const $=yield R(q.map(te=>we(this,void 0,void 0,function*(){yield te.close()})));for(const te of $)I.a.warn("Request to close session failed",{error:te})})}getActiveConnection(q){return this.getConnections().find($=>$.getRemotePeerId()===q&&$.isActive())}update(){var q;return we(this,void 0,void 0,function*(){if(this.localConnections=this.localConnections.filter(me=>me.isActive()),this.config.lanOnlyMode)return;const{signalingClient:$}=this.config;if(!this.localPeer||!this.receiveSignalStream||!this.iceServers)return this.localPeer||(yield this.createPeer()),this.iceServers||(yield this.updateIceServers()),void(this.receiveSignalStream||(yield this.createReceiveSignalStream()));yield this.closeConnections(this.connections.filter(me=>!me.isActive())),this.connections=this.connections.filter(me=>me.isActive());const{localPeer:te}=this,ue=this.connections.filter(me=>me.getSessionId).map(me=>d(me.getSessionId()));te.setSessionIdsList(ue);const ae=new L.RefreshPeerRequest;ae.setPeer(te);try{yield $.refreshPeer(ae,yield this.getMetadata({}))}catch(me){me.code===k.StatusCode.NOT_FOUND?(I.a.warn("Peer expired, creating new peer",{peerId:te.getPeerId()}),yield this.reset()):I.a.warn("Error calling RefreshPeer",{error:me})}const de=yield this.getPeers();for(const me of this.connections)me.setRemoteDeviceId((q=de.find(pe=>pe.id===me.getRemotePeerId()))===null||q===void 0?void 0:q.deviceId)})}reset(){return we(this,void 0,void 0,function*(){yield this.closeConnections(this.connections),this.connections=[],this.isOutgoingConnection=new Map,yield this.createPeer(),yield this.createReceiveSignalStream()})}updateIceServers(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)return;const{iceServersLastUpdate:q,iceServersTtl:$}=this,te=new Date().getTime();if(!q||te-q>$)try{const ue=(yield this.config.signalingClient.getIceServers(new L.GetIceServersRequest,yield this.getMetadata({}))).getIceServers();this.iceServers=JSON.parse(ue),this.iceServersLastUpdate=te}catch(ue){I.a.warn("Error in updateIceServers",{error:ue})}})}setupHandlers(q){const{peerConnection:$}=q,te=q.getSessionCreatedTimestamp();$.onconnectionstatechange=()=>we(this,void 0,void 0,function*(){const ue=$.connectionState;if(te)switch(ue){case"connected":O.aggregate("rtc-connect-time",new Date().getTime()-te);break;case"failed":O.increment("rtc-connect-failed")}})}getMetadata(q){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getMetadata method cannot be called in local-only mode");const{getToken:$}=this.config,{grpcCallDeadline:te}=this,{hasDeadline:ue}=q,ae=ue===!1?void 0:new Date().getTime()+te;return{authorization:yield $(),deadline:ae}})}}},,function(e,t,r){r.r(t),r.d(t,"LogClient",function(){return l});var n=r(25),o=function(s,i,c,u){return new(c||(c=Promise))(function(b,A){function _(S){try{f(u.next(S))}catch(w){A(w)}}function v(S){try{f(u.throw(S))}catch(w){A(w)}}function f(S){var w;S.done?b(S.value):(w=S.value,w instanceof c?w:new c(function(P){P(w)})).then(_,v)}f((u=u.apply(s,i||[])).next())})};class l extends n.a{log(i){return o(this,void 0,void 0,function*(){yield this.fetch("logs",{method:"POST",body:JSON.stringify({logs:i}),allowUnsafeRetries:!0})})}}}])})})(dist);let FORMANT_API_URL="https://api.formant.io";typeof window!="undefined"&&(FORMANT_API_URL=window.FORMANT_API_URL||FORMANT_API_URL);let urlParams$1=new URLSearchParams("");typeof window!="undefined"&&(urlParams$1=new URLSearchParams(window.location.search));const envDev=urlParams$1.get("formant_dev");envDev&&(FORMANT_API_URL="https://api-dev.formant.io");const envStage=urlParams$1.get("formant_stage");envStage&&(FORMANT_API_URL="https://api-stage.formant.io");function delay(e){return new Promise(t=>setTimeout(t,e))}function defined(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}class App{static sendAppMessage(t){window.parent.postMessage(t,"*")}static getCurrentModuleContext(){let t=new URLSearchParams("");return typeof window!="undefined"&&(t=new URLSearchParams(window.location.search)),t.get("module")}static isModule(){return this.getCurrentModuleContext()!==null}static goToTime(t){this.sendAppMessage({type:"go_to_time",time:t.getTime()})}static goToDevice(t){this.sendAppMessage({type:"go_to_device",deviceId:t})}static showMessage(t){this.sendAppMessage({type:"show_message",message:t})}static requestModuleData(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"request_module_data",module:t})}static setModuleDateTimeRange(t,r){const n=this.getCurrentModuleContext();if(!n)throw new Error("No module context");this.sendAppMessage({type:"set_module_data_time_range",module:n,before:t,after:r||0})}static refreshAuthToken(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"refresh_auth_token",module:t})}static sendChannelData(t,r){const n=this.getCurrentModuleContext();if(!n)throw new Error("No module context");this.sendAppMessage({type:"send_channel_data",source:n,channel:t,data:r})}static setupModuleMenus(t){const r=this.getCurrentModuleContext();if(!r)throw new Error("No module context");this.sendAppMessage({type:"setup_module_menus",module:r,menus:t})}static addMenuListener(t){window.addEventListener("message",r=>{const n=r.data;n.type==="module_menu_item_clicked"&&t(n.menu)})}static addAccessTokenRefreshListener(t){window.addEventListener("message",r=>{const n=r.data;n.type==="auth_token"&&t(n.token)})}static addModuleDataListener(t){window.addEventListener("message",r=>{const n=r.data;n.type==="module_data"&&t({streams:n.streams,time:n.time,queryRange:n.queryRange})})}static addChannelDataListener(t,r){window.addEventListener("message",n=>{const o=n.data;o.type==="channel_data"&&o.channel===t&&r({source:o.source,data:o.data})})}}const Oe=class{static async login(t,r){try{const n=await fetch(`${FORMANT_API_URL}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:r}),headers:{"Content-Type":"application/json"}}),o=await n.json();if(n.status!==200)throw new Error(o.message);return await Oe.loginWithToken(o.authentication.accessToken,o.authentication.refreshToken),o.authentication}catch(n){return Oe.waitingForAuth.forEach(o=>o(!1)),Oe.waitingForAuth=[],Promise.reject(n)}}static async loginWithToken(t,r){const n=JSON.parse(atob(t.split(".")[1]));try{let o;if(Oe.isShareToken=n["formant:claims"]&&n["formant:claims"].type=="share",n["formant:claims"]&&(Oe.currentOrganization=n["formant:claims"].organizationId),n["custom:organization_id"]&&(Oe.currentOrganization=n["custom:organization_id"]),Oe.isShareToken||(o=n.sub),n["formant:claims"]&&n["formant:claims"].userId&&(o=n["formant:claims"].userId),o){const l=await fetch(`${FORMANT_API_URL}/v1/admin/users/${o}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),s=await l.json();if(l.status!==200)throw new Error(s.message);Oe.currentUser=s}Oe.token=t,Oe.waitingForAuth.forEach(l=>l(!0))}catch(o){console.error(o),Oe.waitingForAuth.forEach(l=>l(!1))}Oe.waitingForAuth=[],r&&(Oe.refreshToken=r,setInterval(async()=>{if(Oe.refreshToken){const l=await(await fetch(`${FORMANT_API_URL}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:Oe.refreshToken})})).json();Oe.token=l.authentication.accessToken}},1e3*60*60))}static isAuthenticated(){return Oe.token!==void 0}static getCurrentUser(){return Oe.currentUser}static async waitTilAuthenticated(){return Oe.token!==void 0?!0:new Promise(t=>{Oe.waitingForAuth.push(function(r){t(r)})})}static async listenForRefresh(){App.addAccessTokenRefreshListener(t=>{this.loginWithToken(t)}),setInterval(async()=>{App.refreshAuthToken()},1e3*60*60)}};let Authentication=Oe;Ie(Authentication,"token"),Ie(Authentication,"refreshToken"),Ie(Authentication,"currentUser"),Ie(Authentication,"currentOrganization"),Ie(Authentication,"isShareToken",!1),Ie(Authentication,"defaultDeviceId"),Ie(Authentication,"waitingForAuth",[]);class DataChannel{constructor(t){Ie(this,"ready",!1);Ie(this,"listeners",[]);Ie(this,"binaryListeners",[]);Ie(this,"error");Ie(this,"decoder",new TextDecoder);this.dataChannel=t,this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=()=>{this.ready=!0},this.dataChannel.onclose=()=>{this.ready=!1},this.dataChannel.onerror=r=>{console.error(r),this.error="An error occurred in DataChannel"},this.dataChannel.onmessage=r=>{this.listeners.forEach(n=>{const o=new Uint8Array(r.data),l=this.decoder.decode(o);n(l)}),this.binaryListeners.forEach(n=>{n(new Uint8Array(r.data))})}}async waitTilReady(){return this.ready?!0:new Promise((r,n)=>{let o=window.setInterval(()=>{this.ready&&(window.clearInterval(o),r(!0)),this.error&&n(this.error)},10)})}send(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}sendBinary(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}addListener(t){this.listeners.push(t)}removeListener(t){const r=this.listeners.indexOf(t);if(r===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.listeners.splice(r,1)}addBinaryListener(t){this.binaryListeners.push(t)}removeBinaryListener(t){const r=this.binaryListeners.indexOf(t);if(r===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.binaryListeners.splice(r,1)}}class CaptureStream{constructor(t){Ie(this,"token");this.captureSession=t}async ingestJSON(t){if(!this.token){const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions/${this.captureSession.code}/authenticate`,{method:"POST"})).json();this.token=n.token}await fetch(`${FORMANT_API_URL}/v1/ingest`,{method:"POST",body:JSON.stringify({deviceId:this.captureSession.deviceId,name:this.captureSession.streamName,type:"json",points:[[Date.now(),JSON.stringify(t)]]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.token}})}}class Manipulator{constructor(t,r){Ie(this,"currentListeners",[]);Ie(this,"onRealtimeMessage",(t,r)=>{r.payload.jointState&&this.currentListeners.forEach(n=>{r.payload.jointState&&n(r.payload.jointState)})});this.device=t,this.config=r}async synchronize(){this.device.addRealtimeListener(this.onRealtimeMessage),this.device.startListeningToRealtimeDataStream(this.config.currentJointStateStream)}async desynchronize(){this.device.removeRealtimeListener(this.onRealtimeMessage),this.device.stopListeningToRealtimeDataStream(this.config.currentJointStateStream)}async addCurrentJointStateListener(t){this.currentListeners.push(t)}}class RequestDataChannel{constructor(t,r,n){Ie(this,"channel");Ie(this,"requestIdToResponseMap",new Map);this.device=t,this.channel_name=r,this.timeout=n}}class BinaryRequestDataChannel extends RequestDataChannel{constructor(){super(...arguments);Ie(this,"RESPONSE_SUCCESS_BYTE",0);Ie(this,"decoder",new TextDecoder)}generateBinaryId(){const r=new Uint8Array(16);for(let n=0;n<r.length;n++)r[n]=Math.floor(Math.random()*256);return r}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addBinaryListener(r=>{const o=r.slice(0,16).toString();if(o.length===0)throw new Error("Invalid response");const l=r.slice(16);if(l.length===0)throw new Error("Invalid response");this.requestIdToResponseMap.has(o)&&this.requestIdToResponseMap.set(o,l)})}async request(r){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:n,requestIdToResponseMap:o,timeout:l}=this;await n.waitTilReady();const s=this.generateBinaryId(),i=s.toString();o.set(i,!0),n.sendBinary(new Uint8Array([...s,...r]));const c=new Date().getTime();for(;new Date().getTime()<c+l;)if(await delay(50),o.has(i)){const u=o.get(i);if(u!==!0){o.delete(i);const b=u[0]===this.RESPONSE_SUCCESS_BYTE,A=u.slice(1);if(b)return A;throw{name:"AdapterError",message:this.decoder.decode(A)}}}throw o.delete(i),{name:"TimeoutError",message:`Request timed out after ${l/1e3} seconds`}}}class TextRequestDataChannel extends RequestDataChannel{generateTextId(){return Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2)}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addListener(t=>{const r=JSON.parse(t),{id:n,data:o,error:l}=r;if(!n)throw new Error("Invalid response");if(!o&&!l)throw new Error("Invalid response");this.requestIdToResponseMap.has(n)&&this.requestIdToResponseMap.set(n,r)})}async request(t){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:r,requestIdToResponseMap:n,timeout:o}=this;await r.waitTilReady();const l=this.generateTextId();n.set(l,!0),r.send(JSON.stringify({id:l,data:t}));const s=new Date().getTime();for(;new Date().getTime()<s+o;)if(await delay(50),n.has(l)){const i=n.get(l);if(i!==!0){n.delete(l);const{data:c,error:u}=i;if(c)return c;if(u)throw{name:"AdapterError",message:u}}}throw n.delete(l),{name:"TimeoutError",message:`Request timed out after ${o/1e3} seconds`}}}const SessionType={Teleop:1,Observe:3};class Device{constructor(t,r,n){Ie(this,"rtcClient");Ie(this,"remoteDevicePeerId");Ie(this,"realtimeListeners",[]);Ie(this,"handleMessage",(t,r)=>{this.realtimeListeners.forEach(n=>n(t,r))});this.id=t,this.name=r,this.organizationId=n}async getLatestTelemetry(){return(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}async getConfiguration(){let t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}});const r=await t.json();if(!r.state.reportedConfiguration)throw new Error("Device has no configuration, has it ever been turned on?");const n=r.state.reportedConfiguration.version;return t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}/configurations/${n}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),(await t.json()).document}async getFileUrl(t){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileId:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).fileUrls}getRealtimeStatus(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getConnectionStatus(this.remoteDevicePeerId);throw new Error(`Realtime connection hasn't been started for ${this.id}`)}getRealtimePing(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getPing(this.remoteDevicePeerId);throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async startRealtimeConnection(t){if(this.rtcClient)throw new Error(`Already created realtime connection to device ${this.id}`);{const r=new dist.exports.RtcClient({signalingClient:new dist.exports.SignalingPromiseClient(FORMANT_API_URL,null,null),getToken:async()=>defined(Authentication.token,"Realtime when user isn't authorized"),receive:this.handleMessage});for(;!r.isReady();)await delay(100);const o=(await r.getPeers()).find(l=>l.deviceId===this.id);if(!o)throw new Error("Cannot find peer, is the robot offline?");for(this.remoteDevicePeerId=o.id,await r.connect(this.remoteDevicePeerId,t||{sessionType:SessionType.Teleop});r.getConnectionStatus(this.remoteDevicePeerId)!=="connected";)await delay(100);this.rtcClient=r}}addRealtimeListener(t){this.realtimeListeners.push(t)}removeRealtimeListener(t){const r=this.realtimeListeners.indexOf(t);if(r===-1)throw new Error("Could not find realtime listener to remove");this.realtimeListeners.splice(r,1)}async getRealtimeVideoStreams(){var n,o,l;const t=await this.getConfiguration(),r=[];for(const s of(n=t.teleop.hardwareStreams)!=null?n:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});for(const s of(o=t.teleop.rosStreams)!=null?o:[])s.topicType=="formant/H264VideoFrame"&&r.push({name:s.topicName});for(const s of(l=t.teleop.customStreams)!=null?l:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});return r}async getRealtimeManipulators(){var n;const t=await this.getConfiguration(),r=[];for(const o of(n=t.teleop.rosStreams)!=null?n:[])o.topicType=="sensor_msgs/JointState"&&r.push(new Manipulator(this,{currentJointStateStream:{name:o.topicName},plannedJointStateStream:o.plannedTopic?{name:o.plannedTopic}:void 0,planValidStream:o.planValidTopic?{name:o.planValidTopic}:void 0,endEffectorStream:o.endEffectorTopic?{name:o.endEffectorTopic}:void 0,endEffectorLinkName:o.endEffectorLinkName,baseReferenceFrame:o.baseReferenceFrame,localFrame:o.localFrame}));return r}async startListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async startListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async enableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!0,pipeline:"telemetry"})}async disableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!1,pipeline:"telemetry"})}async getRemotePeer(){const r=(await defined(this.rtcClient,"Realtime connection has not been started").getPeers()).find(n=>n.deviceId===this.id);return defined(r,"Could not find remote peer for device "+this.id)}async stopRealtimeConnection(){if(this.rtcClient)await this.rtcClient.disconnect(this.id);else throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async isInRealtimeSession(){let t=await Fleet.getPeers(),r=await Fleet.getRealtimeSessions(),n=t.find(o=>o.deviceId===this.id);return n?r[n.id].length>0:!1}async getAvailableCommands(){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/command-templates/`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(n=>({name:n.name,id:n.id,command:n.command,description:n.description,parameterEnabled:n.parameterEnabled,parameterValue:n.parameterValue,parameterMeta:n.parameterMeta,enabled:n.enabled}))}async sendCommand(t,r,n,o){var u;const s=(await this.getAvailableCommands()).find(b=>b.name===t);if(!s)throw new Error(`Could not find command with name "${t}"`);let i;if(r===void 0)if(s.parameterEnabled&&s.parameterValue)i=s.parameterValue;else throw new Error("Command has no default parameter value, you must provide one");else i=r;let c={value:i,scrubberTime:(n||new Date).toISOString(),meta:st(st({},s.parameterMeta),o)};await fetch(`${FORMANT_API_URL}/v1/admin/commands`,{method:"POST",body:JSON.stringify({commandTemplateId:s.id,organizationId:this.organizationId,deviceId:this.id,command:s.command,parameter:c,userId:(u=Authentication.currentUser)==null?void 0:u.id}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}async createCustomDataChannel(t,r){const n=defined(this.rtcClient,"Realtime connection has not been started"),o=await this.getRemotePeer(),l=await new Promise(s=>{n.createCustomDataChannel(defined(o).id,t,st({ordered:!0},r),!1,(i,c)=>{const u=new DataChannel(c);s(u)})});return await l.waitTilReady(),l}createCustomRequestDataChannel(t,r=3e3){return new TextRequestDataChannel(this,t,r)}createCustomBinaryRequestDataChannel(t,r=3e3){return new BinaryRequestDataChannel(this,t,r)}async createCaptureStream(t){const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions`,{method:"POST",body:JSON.stringify({deviceId:this.id,streamName:t,tags:{}}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return new CaptureStream(n)}async getTelemetry(t,r,n,o){return await Fleet.getTelemetry(this.id,t,r,n,o)}async getTelemetryStreams(){var i,c;const t=await this.getConfiguration(),r=await fetch(`${FORMANT_API_URL}/v1/queries/metadata/stream-names`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),n=[],o=[];return(c=(i=t.telemetry)==null?void 0:i.streams)==null||c.forEach(u=>{u.disabled!==!0&&n.push(u.name),u.onDemand===!0&&o.push(u.name)}),console.log(o),(await r.json()).items.filter(u=>!n.includes(u)).map(u=>({name:u,onDemand:o.includes(u)}))}async createInterventionRequest(t,r,n,o){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"POST",body:JSON.stringify({message:t,interventionType:r,time:new Date().toISOString(),deviceId:this.id,tags:o,data:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async addInterventionResponse(t,r,n){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-responses`,{method:"POST",body:JSON.stringify({interventionId:t,interventionType:r,data:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}class PeerDevice{constructor(t){Ie(this,"rtcClient");Ie(this,"remoteDevicePeerId");Ie(this,"realtimeListeners",[]);Ie(this,"id");Ie(this,"handleMessage",(t,r)=>{this.realtimeListeners.forEach(n=>n(t,r))});this.peerUrl=t}async getLatestTelemetry(){const r=await(await fetch(`${this.peerUrl}/telemetry`)).json();return Object.entries(r).map(([o,l])=>({deviceId:this.id,streamName:o,streamType:"json",currentValue:l,currentValueTime:l.timestamp,tags:{}}))}async getDeviceId(){return(await(await fetch(`${this.peerUrl}/configuration`)).json()).agent_config.id}async getConfiguration(){return(await(await fetch(`${this.peerUrl}/configuration`)).json()).agent_config.document}getRealtimeStatus(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getConnectionStatus(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}getRealtimePing(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getPing(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}async startRealtimeConnection(t){if(this.rtcClient)throw new Error(`Already created realtime connection to device ${this.id}`);{const r=new dist.exports.RtcClient({lanOnlyMode:!0,receive:this.handleMessage});for(await r.connectLan(this.peerUrl);r.getConnectionStatus(this.peerUrl)!=="connected";)await delay(100);this.rtcClient=r}}addRealtimeListener(t){this.realtimeListeners.push(t)}removeRealtimeListener(t){const r=this.realtimeListeners.indexOf(t);if(r===-1)throw new Error("Could not find realtime listener to remove");this.realtimeListeners.splice(r,1)}async getRealtimeVideoStreams(){var n,o,l;const t=await this.getConfiguration(),r=[];for(const s of(n=t.teleop.hardwareStreams)!=null?n:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});for(const s of(o=t.teleop.rosStreams)!=null?o:[])s.topicType=="formant/H264VideoFrame"&&r.push({name:s.topicName});for(const s of(l=t.teleop.customStreams)!=null?l:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});return r}async getRealtimeManipulators(){var n;const t=await this.getConfiguration(),r=[];for(const o of(n=t.teleop.rosStreams)!=null?n:[])o.topicType=="sensor_msgs/JointState"&&r.push(new Manipulator(this,{currentJointStateStream:{name:o.topicName},plannedJointStateStream:o.plannedTopic?{name:o.plannedTopic}:void 0,planValidStream:o.planValidTopic?{name:o.planValidTopic}:void 0,endEffectorStream:o.endEffectorTopic?{name:o.endEffectorTopic}:void 0,endEffectorLinkName:o.endEffectorLinkName,baseReferenceFrame:o.baseReferenceFrame,localFrame:o.localFrame}));return r}async startListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async startListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async enableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!0,pipeline:"telemetry"})}async disableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!1,pipeline:"telemetry"})}async getRemotePeer(){return{id:this.peerUrl,organizationId:"",deviceId:this.id,capabilities:[],capabilitySet:{}}}async stopRealtimeConnection(){if(this.rtcClient)await this.rtcClient.disconnect(this.id);else throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async createCustomDataChannel(t,r){const n=defined(this.rtcClient,"Realtime connection has not been started"),o=await this.getRemotePeer(),l=await new Promise(s=>{n.createCustomDataChannel(defined(o).id,t,st({ordered:!0},r),!1,(i,c)=>{const u=new DataChannel(c);s(u)})});return await l.waitTilReady(),l}createCustomRequestDataChannel(t,r=3e3){return new TextRequestDataChannel(this,t,r)}createCustomBinaryRequestDataChannel(t,r=3e3){return new BinaryRequestDataChannel(this,t,r)}}const Me=class{static async setDefaultDevice(t){Me.defaultDeviceId=t}static async getCurrentDevice(){if(!Authentication.token)throw new Error("Not authenticated");if(!Me.defaultDeviceId)throw new Error("No known default device");const o=(await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.find(s=>s.id===Me.defaultDeviceId).name,l=new Device(Me.defaultDeviceId,o,defined(Authentication.currentOrganization));return Me.knownContext.push(new WeakRef(l)),l}static async getPeerDevice(t){const r=new PeerDevice(t);return r.id=await r.getDeviceId(),r}static async getDevice(t){if(!Authentication.token)throw new Error("Not authenticated");const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json(),o=n.name,l=new Device(t,o,n.organizationId);return Me.knownContext.push(new WeakRef(l)),l}static async getDevices(){if(!Authentication.token)throw new Error("Not authenticated");const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",body:JSON.stringify({enabled:!0,type:"default"}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return r.items,r.items.map(n=>new Device(n.id,n.name,n.organizationId))}static async getOnlineDevices(){if(!Authentication.token)throw new Error("Not authenticated");const n=(await(await fetch(`${FORMANT_API_URL}/v1/queries/online-devices`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items;return(await Me.getDevices()).filter(l=>n.includes(l.id))}static async getPeers(){if(!Authentication.token)throw new Error("Not authenticated");return await new dist.exports.RtcClient({signalingClient:new dist.exports.SignalingPromiseClient(FORMANT_API_URL,null,null),getToken:async()=>defined(Authentication.token,"Realtime when user isn't authorized"),receive:()=>{}}).getPeers()}static async getRealtimeSessions(){if(!Authentication.token)throw new Error("Not authenticated");return await new dist.exports.RtcClient({signalingClient:new dist.exports.SignalingPromiseClient(FORMANT_API_URL,null,null),getToken:async()=>defined(Authentication.token,"Realtime when user isn't authorized"),receive:()=>{}}).getSessions()}static async getRealtimeDevices(){if(!Authentication.token)throw new Error("Not authenticated");const n=(await(await fetch(`${FORMANT_API_URL}/v1/signaling/peers`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(l=>l.deviceId);return(await Me.getDevices()).filter(l=>n.includes(l.id))}static async getLatestTelemetry(t){let r=t;return t&&!Array.isArray(t)&&(t=[t]),(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getTelemetry(t,r,n,o,l){let s=t;Array.isArray(t)||(s=[t]);let i=r;return Array.isArray(r)||(i=[r]),(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify({deviceIds:s,end:o.toISOString(),names:i,start:n.toISOString(),tags:l}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getFileUrl(t){const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileIds:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();if(n.fileUrls.length===0)throw new Error("File not found");return n.fileUrls[0]}static async queryTelemetry(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async queryEvents(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getEvent(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query/id=${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getInterventions(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}};let Fleet=Me;Ie(Fleet,"defaultDeviceId"),Ie(Fleet,"knownContext",[]);class KeyValue{static async set(t,r){try{const n=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"POST",body:JSON.stringify({organizationId:defined(Authentication.currentUser).organizationId,key:t,value:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),o=await n.json();if(n.status!==200)throw new Error(o.message)}catch(n){throw n}}static async get(t){try{const r=await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),n=await r.json();if(r.status!==200)throw new Error(n.message);return n.value}catch(r){throw r}}static async list(){try{const t=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),r=await t.json();if(t.status!==200)throw new Error(r.message);return r.items}catch(t){throw t}}static async delete(t){try{if(!(await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).ok)throw new Error("Unable to handle request");return}catch(r){throw r}}}const accessLevels=["viewer","operator","administrator"],viewer="viewer",operator="operator",administrator="administrator",aggregateLevels=["year","month","week","day","hour","minute"],annotationTypes=["tag","sheet","user"],eventTypes=["triggered-event","intervention-request","teleop-session-record","port-forwarding-session-record","command-request","command-response","command-delivery","custom","comment","system","annotation"],healthStatuses=["unknown","operational","offline","error"],interventionTypes=["selection","labeling","teleop"],severities=["info","warning","error","critical"],videoMimeTypes=["video/mp4"];let urlParams=new URLSearchParams("");typeof window!="undefined"&&(urlParams=new URLSearchParams(window.location.search));const urlDevice=urlParams.get("device");urlDevice&&Fleet.setDefaultDevice(urlDevice);const urlAuth=urlParams.get("auth");urlAuth&&Authentication.loginWithToken(urlAuth);const moduleName=urlParams.get("module");moduleName&&Authentication.listenForRefresh(),exports.App=App,exports.Authentication=Authentication,exports.BinaryRequestDataChannel=BinaryRequestDataChannel,exports.CaptureStream=CaptureStream,exports.DataChannel=DataChannel,exports.Device=Device,exports.Fleet=Fleet,exports.KeyValue=KeyValue,exports.Manipulator=Manipulator,exports.PeerDevice=PeerDevice,exports.SessionType=SessionType,exports.TextRequestDataChannel=TextRequestDataChannel,exports.accessLevels=accessLevels,exports.administrator=administrator,exports.aggregateLevels=aggregateLevels,exports.annotationTypes=annotationTypes,exports.eventTypes=eventTypes,exports.healthStatuses=healthStatuses,exports.interventionTypes=interventionTypes,exports.operator=operator,exports.severities=severities,exports.videoMimeTypes=videoMimeTypes,exports.viewer=viewer,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
44
|
+
`),Error.captureStackTrace(this,n)}}e.exports=o=>{if(o.length>2)throw new n(o);function l(i={}){this.options=i}function s(i){return new l(i)}return l.prototype.transform=o,s.Format=l,s}},function(e,t,r){function n(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}function o(s,i){for(var c=0;c<i.length;c++){var u=i[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}var l=r(85);e.exports=function(){function s(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};n(this,s),this.loggers=new Map,this.options=u}var i,c;return i=s,(c=[{key:"add",value:function(u,b){var A=this;if(!this.loggers.has(u)){var _=(b=Object.assign({},b||this.options)).transports||this.options.transports;b.transports=_?_.slice():[];var v=l(b);v.on("close",function(){return A._delete(u)}),this.loggers.set(u,v)}return this.loggers.get(u)}},{key:"get",value:function(u,b){return this.add(u,b)}},{key:"has",value:function(u){return!!this.loggers.has(u)}},{key:"close",value:function(u){var b=this;if(u)return this._removeLogger(u);this.loggers.forEach(function(A,_){return b._removeLogger(_)})}},{key:"_removeLogger",value:function(u){this.loggers.has(u)&&(this.loggers.get(u).close(),this._delete(u))}},{key:"_delete",value:function(u){this.loggers.delete(u)}}])&&o(i.prototype,c),s}()},function(e,t,r){(function(n){const o=r(49),l=/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/;e.exports=function(s,i,c){let u,b,A=!1,_=!1;function v(w,P){let N=`"${i}" ${P}`;throw w&&(N=`${N}, but is set to "${w}"`),b&&(N=`${N}. An example of a valid value would be: ${b}`),new o(N)}function f(w){return function(){let P=s[i];if(P===void 0)if(u===void 0&&_)v(void 0,"is a required variable, but it was not set");else{if(u===void 0)return;P=u}_&&P.trim().length===0&&v(void 0,"is a required variable, but its value was empty"),A&&(P.match(l)||v(P,"should be a valid base64 string if using convertFromBase64"),P=n.from(P,"base64").toString());const N=[P].concat(Array.prototype.slice.call(arguments));try{return w.apply(w,N)}catch(T){v(P,T.message)}}}const S={asArray:f(r(211)),asBoolStrict:f(r(212)),asBool:f(r(213)),asPortNumber:f(r(214)),asEnum:f(r(215)),asFloatNegative:f(r(216)),asFloatPositive:f(r(217)),asFloat:f(r(51)),asIntNegative:f(r(218)),asIntPositive:f(r(91)),asInt:f(r(50)),asJsonArray:f(r(219)),asJsonObject:f(r(220)),asJson:f(r(52)),asString:f(r(34)),asUrlObject:f(r(92)),asUrlString:f(r(221)),convertFromBase64:function(){return A=!0,S},default:function(w){if(typeof w=="number")u=w.toString();else if(Array.isArray(w)||typeof w=="object"&&w!==null)u=JSON.stringify(w);else{if(typeof w!="string")throw new o("values passed to default() must be of Number, String, Array, or Object type");u=w}return S},required:function(w){return _=w===void 0||w,S},example:function(w){return b=w,S}};return Object.entries(c).forEach(([w,P])=>{S[w]=f(P)}),S}}).call(this,r(4).Buffer)},function(e,t,r){const n=r(34);e.exports=function(o,l){return l=l||",",o.length?n(o).split(l).filter(Boolean):[]}},function(e,t,r){e.exports=function(n){const o=n.toLowerCase();if(o!=="false"&&o!=="true")throw new Error('should be either "true", "false", "TRUE", or "FALSE"');return o!=="false"}},function(e,t,r){e.exports=function(n){const o=n.toLowerCase();if(["false","0","true","1"].indexOf(o)===-1)throw new Error('should be either "true", "false", "TRUE", "FALSE", 1, or 0');return!(o==="0"||o==="false")}},function(e,t,r){const n=r(91);e.exports=function(o){var l=n(o);if(l>65535)throw new Error("cannot assign a port number greater than 65535");return l}},function(e,t,r){const n=r(34);e.exports=function(o,l){const s=n(o);if(l.indexOf(s)<0)throw new Error(`should be one of [${l.join(", ")}]`);return s}},function(e,t,r){const n=r(51);e.exports=function(o){const l=n(o);if(l>0)throw new Error("should be a negative float");return l}},function(e,t,r){const n=r(51);e.exports=function(o){const l=n(o);if(l<0)throw new Error("should be a positive float");return l}},function(e,t,r){const n=r(50);e.exports=function(o){const l=n(o);if(l>0)throw new Error("should be a negative integer");return l}},function(e,t,r){const n=r(52);e.exports=function(o){var l=n(o);if(!Array.isArray(l))throw new Error("should be a parseable JSON Array");return l}},function(e,t,r){const n=r(52);e.exports=function(o){var l=n(o);if(Array.isArray(l))throw new Error("should be a parseable JSON Object");return l}},function(e,t,r){const n=r(92);e.exports=function(o){return n(o).toString()}},function(e,t,r){(function(n){(function(){var o,l,s,i,c,u;typeof performance!="undefined"&&performance!==null&&performance.now?e.exports=function(){return performance.now()}:n!=null&&n.hrtime?(e.exports=function(){return(o()-c)/1e6},l=n.hrtime,i=(o=function(){var b;return 1e9*(b=l())[0]+b[1]})(),u=1e9*n.uptime(),c=i-u):Date.now?(e.exports=function(){return Date.now()-s},s=Date.now()):(e.exports=function(){return new Date().getTime()-s},s=new Date().getTime())}).call(this)}).call(this,r(2))},function(e,t,r){var n,o,l=r(96),s=r(97),i=0,c=0;e.exports=function(u,b,A){var _=b&&A||0,v=b||[],f=(u=u||{}).node||n,S=u.clockseq!==void 0?u.clockseq:o;if(f==null||S==null){var w=l();f==null&&(f=n=[1|w[0],w[1],w[2],w[3],w[4],w[5]]),S==null&&(S=o=16383&(w[6]<<8|w[7]))}var P=u.msecs!==void 0?u.msecs:new Date().getTime(),N=u.nsecs!==void 0?u.nsecs:c+1,T=P-i+(N-c)/1e4;if(T<0&&u.clockseq===void 0&&(S=S+1&16383),(T<0||P>i)&&u.nsecs===void 0&&(N=0),N>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");i=P,c=N,o=S;var R=(1e4*(268435455&(P+=122192928e5))+N)%4294967296;v[_++]=R>>>24&255,v[_++]=R>>>16&255,v[_++]=R>>>8&255,v[_++]=255&R;var d=P/4294967296*1e4&268435455;v[_++]=d>>>8&255,v[_++]=255&d,v[_++]=d>>>24&15|16,v[_++]=d>>>16&255,v[_++]=S>>>8|128,v[_++]=255&S;for(var I=0;I<6;++I)v[_+I]=f[I];return b||s(v)}},function(e,t,r){var n=r(96),o=r(97);e.exports=function(l,s,i){var c=s&&i||0;typeof l=="string"&&(s=l==="binary"?new Array(16):null,l=null);var u=(l=l||{}).random||(l.rng||n)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,s)for(var b=0;b<16;++b)s[c+b]=u[b];return s||o(u)}},function(e,t,r){(function(n){(function(o){function l(i){if((i=i===void 0?"utf-8":i)!=="utf-8")throw new RangeError("Failed to construct 'TextEncoder': The encoding label provided ('"+i+"') is invalid.")}function s(i,c){if(c=c===void 0?{fatal:!1}:c,(i=i===void 0?"utf-8":i)!=="utf-8")throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+i+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}if(o.TextEncoder&&o.TextDecoder)return!1;Object.defineProperty(l.prototype,"encoding",{value:"utf-8"}),l.prototype.encode=function(i,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var u=i.length,b=0,A=Math.max(32,u+(u>>1)+7),_=new Uint8Array(A>>3<<3);c<u;){var v=i.charCodeAt(c++);if(55296<=v&&56319>=v){if(c<u){var f=i.charCodeAt(c);(64512&f)==56320&&(++c,v=((1023&v)<<10)+(1023&f)+65536)}if(55296<=v&&56319>=v)continue}if(b+4>_.length&&(A+=8,A=(A*=1+c/i.length*2)>>3<<3,(f=new Uint8Array(A)).set(_),_=f),(4294967168&v)==0)_[b++]=v;else{if((4294965248&v)==0)_[b++]=v>>6&31|192;else if((4294901760&v)==0)_[b++]=v>>12&15|224,_[b++]=v>>6&63|128;else{if((4292870144&v)!=0)continue;_[b++]=v>>18&7|240,_[b++]=v>>12&63|128,_[b++]=v>>6&63|128}_[b++]=63&v|128}}return _.slice(0,b)},Object.defineProperty(s.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(s.prototype,"fatal",{value:!1}),Object.defineProperty(s.prototype,"ignoreBOM",{value:!1}),s.prototype.decode=function(i,c){if((c=c===void 0?{stream:!1}:c).stream)throw Error("Failed to decode: the 'stream' option is unsupported.");c=0;for(var u=(i=new Uint8Array(i)).length,b=[];c<u;){var A=i[c++];if(A===0)break;if((128&A)==0)b.push(A);else if((224&A)==192){var _=63&i[c++];b.push((31&A)<<6|_)}else if((240&A)==224){_=63&i[c++];var v=63&i[c++];b.push((31&A)<<12|_<<6|v)}else(248&A)==240&&(65535<(A=(7&A)<<18|(_=63&i[c++])<<12|(v=63&i[c++])<<6|63&i[c++])&&(A-=65536,b.push(A>>>10&1023|55296),A=56320|1023&A),b.push(A))}return String.fromCharCode.apply(null,b)},o.TextEncoder=l,o.TextDecoder=s})(typeof window!="undefined"?window:n!==void 0?n:this)}).call(this,r(5))},function(e,t,r){r.r(t),r.d(t,"AuthClient",function(){return l}),r.d(t,"RtcSignalingClient",function(){return i}),r.d(t,"Credentials",function(){return P}),r.d(t,"SignalingPromiseClient",function(){return N.SignalingPromiseClient}),r.d(t,"IRtcClientConfiguration",function(){}),r.d(t,"IRtcConnectConfiguration",function(){}),r.d(t,"IRtcConnectionStatsInfo",function(){}),r.d(t,"IRtcSendConfiguration",function(){}),r.d(t,"IRtcSessionMetricsMessageCounts",function(){}),r.d(t,"IRtcStreamMessage",function(){}),r.d(t,"IStreamControl",function(){}),r.d(t,"RtcClient",function(){return Ee}),r.d(t,"createRtcStreamMessage",function(){return X}),r.d(t,"IRtcStream",function(){}),r.d(t,"IRtcStreamPayload",function(){});var n=r(25),o=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class l extends n.a{adminSignup(q,$){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/admin-signup",{token:$,method:"POST",body:JSON.stringify(q)})})}login(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/login",{method:"POST",body:JSON.stringify(q),allowUnsafeRetries:!0})})}loginWithGoogleToken(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/login-google",{method:"POST",body:JSON.stringify(q),allowUnsafeRetries:!0})})}refresh(q,$){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/refresh",{method:"POST",body:JSON.stringify({refreshToken:q,tokenExpirationSeconds:$}),allowUnsafeRetries:!0})})}respondToNewPasswordRequiredChallenge(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/respond-to-new-password-required-challenge",{method:"POST",body:JSON.stringify(q)})})}forgotPassword(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/forgot-password",{method:"POST",body:JSON.stringify({email:q})})})}confirmForgotPassword(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/confirm-forgot-password",{method:"POST",body:JSON.stringify(q)})})}resendInvitation(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/resend-invitation",{method:"POST",body:JSON.stringify({email:q})})})}changePassword({token:q,refreshToken:$,currentPassword:te,newPassword:ue}){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/change-password",{token:q,method:"POST",body:JSON.stringify({refreshToken:$,currentPassword:te,newPassword:ue})})})}getDeviceCredentials(q){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/device-credentials",{token:q,method:"POST",allowUnsafeRetries:!0})})}impersonate(q,$){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/impersonate",{token:q,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({userId:$})})})}createServiceAccount(q,$,te,ue){return o(this,void 0,void 0,function*(){return yield this.fetch("auth/service-account",{token:q,method:"POST",allowUnsafeRetries:!0,body:JSON.stringify({name:$,roleId:te,tags:ue})})})}getFeatures(q){return o(this,void 0,void 0,function*(){return(yield this.fetch("auth/features",{token:q})).features})}}var s=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class i extends n.a{createPeer(q,$){return s(this,void 0,void 0,function*(){return yield this.fetch("peers",{token:q,method:"POST",body:JSON.stringify($)})})}getPeers(q){return s(this,void 0,void 0,function*(){return(yield this.fetch("peers",{token:q})).items})}refreshPeer(q,$){return s(this,void 0,void 0,function*(){yield this.fetch(`peers/${$}/refresh`,{token:q,method:"POST",allowUnsafeRetries:!0})})}createSession(q,$){return s(this,void 0,void 0,function*(){return yield this.fetch("sessions",{token:q,method:"POST",body:JSON.stringify($)})})}refreshSession(q,$){return s(this,void 0,void 0,function*(){yield this.fetch(`sessions/${$}/refresh`,{token:q,method:"POST",allowUnsafeRetries:!0})})}deleteSession(q,$){return s(this,void 0,void 0,function*(){yield this.fetch(`sessions/${$}`,{token:q,method:"DELETE",allowUnsafeRetries:!0})})}getSessions(q){return s(this,void 0,void 0,function*(){return(yield this.fetch("sessions",{token:q})).items})}getIceServers(q){return s(this,void 0,void 0,function*(){return(yield this.fetch("ice-servers",{token:q})).items})}addSignals(q,$,te){return s(this,void 0,void 0,function*(){yield this.fetch(`sessions/${$}/add-signals`,{token:q,method:"POST",body:JSON.stringify(te)})})}takeSignals(q,$){return s(this,void 0,void 0,function*(){return(yield this.fetch(`sessions/${$}/take-signals`,{token:q,method:"POST"})).items})}}var c=r(1),u=r(11),b=r(35),A=r.n(b),_=r(102),v=r.n(_),f=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class S extends class{constructor(q){this.cache=new v.a(Object.assign(Object.assign({},q.dispose||q.disposeAfter?{ttlAutopurge:!0}:{}),q)),this.stringify=q.fastStringify?JSON.stringify:A.a}set(q,$,te){const ue=this.stringify(q);if(!this.cache.set(ue,$,{ttl:te})){const ae=this.cache.sizeCalculation?this.cache.sizeCalculation($,ue):"unknown";throw Error(`Value too large (${ae} > ${this.cache.max})`)}}get(q){return this.cache.get(this.stringify(q))}delete(q){this.cache.delete(this.stringify(q))}size(){return this.cache.size}clear(){this.cache.clear()}forEach(q){return this.cache.forEach(q)}}{constructor(q){if(super(q),this.expireRejectedPromiseValues=q.expireRejectedPromiseValues===void 0||q.expireRejectedPromiseValues,this.rejectedPromiseValueTtl=q.rejectedPromiseValueTtl!==void 0?q.rejectedPromiseValueTtl:c.a.second,this.rejectedPromiseValueTtl<0)throw new Error("rejectedPromiseValueTtl must not be negative")}set(q,$,te){const ue=this.stringify(q);this.cache.set(ue,$,{ttl:te}),this.expireRejectedPromiseValues&&Promise.resolve($).catch(()=>f(this,void 0,void 0,function*(){yield Object(u.a)(this.rejectedPromiseValueTtl),this.cache.peek(ue)===$&&this.cache.delete(ue)}))}}var w=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class P{constructor(q,$,te){this.authClient=q,this.email=$,this.password=te,this.tokenTtlMs=1*c.a.hour,this.tokenCache=new S({max:100,ttl:this.tokenTtlMs-5*c.a.minute,fastStringify:!0})}getToken(){return w(this,void 0,void 0,function*(){let q=this.tokenCache.get(this.email);return q||(q=(()=>w(this,void 0,void 0,function*(){const{authentication:$}=yield this.authClient.login({email:this.email,password:this.password,tokenExpirationSeconds:this.tokenTtlMs/c.a.second});if(!$)throw new Error("User account not verified.");return $.accessToken}))(),this.tokenCache.set(this.email,q)),q})}}var N=r(93),T=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};function R(ye){return T(this,void 0,void 0,function*(){return(yield Promise.all(ye.map(q=>q.catch($=>$)))).filter(q=>q instanceof Error)})}function d(ye){if(ye!==void 0)return ye;throw new Error("Value is undefined")}var I=r(0),Q=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};function Z({func:ye,delay:q,immediate:$}){let te=!1,ue=setTimeout(function de(){return Q(this,void 0,void 0,function*(){if(te)return;const me=new Date().getTime();try{ae=ye(),yield ae}finally{if(!te){const pe=new Date().getTime();ue=setTimeout(de,Math.max(q-(pe-me),0))}}})},$?0:q),ae=Promise.resolve();return{stop(){return Q(this,void 0,void 0,function*(){te=!0,clearTimeout(ue),yield ae})}}}function h(ye,q){return Object.keys(ye).reduce(($,te)=>Object.assign(Object.assign({},$),{[te]:q(ye[te])}),{})}var p=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class C{constructor(q){this.message=q}send(q){return p(this,void 0,void 0,function*(){I.a.info(this.message,h(q,$=>{const{sum:te,count:ue}=$,ae=te/ue;return Object.assign(Object.assign({},$),{average:ae})}))})}}var m=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};const x=r(222);var F=r(6);const D=!!F.c,O=new class{constructor(ye=60){this.buffer={},this.metrics={},this.reporters=[],this.flushInterval=Z({func:()=>this.flushStats(),delay:ye*c.a.second})}shutdown(){return m(this,void 0,void 0,function*(){yield this.flushInterval.stop(),yield this.flushStats(),yield Object(u.a)(2*c.a.second)})}aggregate(ye,q){if(this.buffer[ye]){const{min:$,max:te,sum:ue,count:ae}=this.buffer[ye];this.buffer[ye]={min:Math.min($,q),max:Math.max(te,q),sum:ue+q,count:ae+1}}else this.buffer[ye]={min:q,max:q,sum:q,count:1}}increment(ye){this.aggregate(ye,1)}timer(ye,q){return m(this,void 0,void 0,function*(){const $=x(),te=yield q(),ue=x();return this.aggregate(ye,ue-$),te})}metric(ye,q){this.metrics[ye]=q}registerStatsReporter(ye){this.reporters.push(ye)}write(ye){return m(this,void 0,void 0,function*(){if(Object.values(ye).length===0)return;const q=yield R(this.reporters.map($=>$.send(ye)));for(const $ of q)I.a.warn("Failed to write stats",{error:$})})}flushStats(){return m(this,void 0,void 0,function*(){const ye=Object.assign(Object.assign({},this.buffer),h(this.metrics,q=>{const $=q();return{min:$,max:$,sum:$,count:1}}));Object.keys(ye).length>0&&(yield this.write(ye),this.buffer={})})}};D||["local","on-prem"].includes(F.i)||O.registerStatsReporter(new C("stats"));var L=r(8),k=r(21),E=r(103),g=r(36),U=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class B extends g.a{constructor(q){super(q)}postLanRtcOffer(q){return U(this,void 0,void 0,function*(){return yield this.fetch("v1/lan-rtc-offer",{method:"POST",body:JSON.stringify(q)})})}}var G=r(55);const Y={ordered:!1,maxPacketLifeTime:300*c.a.millisecond},K={ordered:!0},H={ordered:!0},V={ordered:!1,maxRetransmits:0},y={ordered:!1,maxRetransmits:0};function j({entityId:ye,streamName:q,streamType:$}){return`${ye}.${q}.${$}`}var W=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class ee{constructor(q,$){this.sessionId=q,this.connection=$,this.counts={localSent:new Map,localReceived:new Map,remoteSent:new Map,remoteReceived:new Map},this.sessionId=q,this.connection=$}updateRemoteMessagesCounts(q){if(q.payload.streamsInfo){this.counts.remoteSent=new Map,this.counts.remoteReceived=new Map;for(const $ of q.payload.streamsInfo.items)this.counts.remoteSent.set($.streamId,$.sentCount),this.counts.remoteReceived.set($.streamId,$.receivedCount)}}getLocalStreamsInfo(q){const{localSent:$,localReceived:te}=this.counts;return{items:[...new Set([...$.keys(),...te.keys()])].map(ue=>{var ae,de;return{streamId:ue,sentCount:(ae=$.get(ue))!==null&&ae!==void 0?ae:0,receivedCount:(de=te.get(ue))!==null&&de!==void 0?de:0}}),timestamp:q}}incrementLocalSent(q){const{localSent:$}=this.counts,te=j(q.header.stream);$.set(te,($.get(te)||0)+1)}incrementLocalReceived(q){const{localReceived:$}=this.counts,te=j(q.header.stream),ue=$.get(te)||0;if(ue===0){const{streamName:ae,streamType:de}=q.header.stream;I.a.debug("RTC client received first message for stream",{streamName:ae,streamType:de})}$.set(te,ue+1)}uploadMetrics(){return W(this,void 0,void 0,function*(){const{sessionId:q}=this,$=yield this.connection.peerConnection.getStats(),te={};$.forEach(ge=>te[ge.id]=ge),I.a.debug("rtc-stats",Object.assign(Object.assign({},te),{sessionId:q}));const{localSent:ue,localReceived:ae,remoteSent:de,remoteReceived:me}=this.counts,pe=[...new Set([...ue.keys(),...ae.keys()])].reduce((ge,ce)=>{const Te=ue.get(ce),Re=ae.get(ce),Pe=de.get(ce),Le=me.get(ce);return Object.assign(Object.assign({},ge),{[`local-${ce}-sent`]:Te,[`local-${ce}-received`]:Re,[`remote-${ce}-sent`]:Pe,[`remote-${ce}-received`]:Le})},{sessionId:q});I.a.debug("rtc-message-report",Object.assign({deviceId:this.connection.getRemoteDeviceId()},pe))})}}function X(ye,q){return{header:{stream:ye,created:Date.now(),frameId:""},payload:q}}function ne(ye){return new Set(["disconnected","failed","closed"]).has(ye.iceConnectionState)}var ie=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class he{constructor(q,$,te){this.peerConnection=q,this.config=$,this.dataChannelNotifier=te,this.connectTimeoutMs=20*c.a.second,this.iceGatheringTimeoutMs=15*c.a.second,this.pingUpdateTimeoutMs=1*c.a.second,this.streamsInfoUpdateTimeoutMs=2*c.a.second,this.reassemblyTimeoutMs=500*c.a.millisecond,this.reassemblyTableCleanupMs=1*c.a.second,this.heartbeatTimeoutMs=20*c.a.millisecond,this.streamLatestTimestamp=new Map,this.reassemblyTable=new Map,this.reassemblyTableLastTimestamp=new Map,this.closeCalled=!1,this.gotOffer=!1,this.hasIceCandidate=!1;const{isOffer:ue}=$.baseConfig;ue?this.initializeChannels(q):q.ondatachannel=ae=>{switch(ae.channel.label){case"stream.latest-ttl":this.latestTtlStreamChannel=ae.channel;break;case"stream.reliable":this.reliableStreamChannel=ae.channel;break;case"stream.latest-reliable":this.latestReliableStreamChannel=ae.channel;break;case"stream.latest-try-once":this.latestTryOnceStreamChannel=ae.channel;break;case"heartbeat":return void(this.heartbeatChannel=ae.channel);default:return void this.dataChannelNotifier(ae.channel)}this.setupChannel(ae.channel)},this.pingUpdateTimeout=setInterval(()=>{const{reliableStreamChannel:ae}=this;ae&&this.sendSystemMessage(ae,{type:"ping"})},this.pingUpdateTimeoutMs),this.streamsInfoUpdateTimeout=setInterval(()=>{const{latestTtlStreamChannel:ae}=this;ae&&this.sendSystemMessage(ae,{type:"streams-info"})},this.streamsInfoUpdateTimeoutMs),this.reassemblyTableCleanupTimeout=setInterval(()=>{const ae=new Date().getTime();this.reassemblyTableLastTimestamp.forEach((de,me,pe)=>{ae>me+this.reassemblyTimeoutMs&&this.reassemblyTable.delete(de)})},this.reassemblyTableCleanupMs),this.heartbeatTimeout=setInterval(()=>{const{heartbeatChannel:ae}=this;ae&&ae.readyState==="open"&&ae.send(new Uint8Array([1]))},this.heartbeatTimeoutMs)}handleSignal(q){return ie(this,void 0,void 0,function*(){const{peerConnection:$}=this,{track:te}=this.config.baseConfig,ue=(()=>{try{return JSON.parse(q.getPayload())}catch{return}})();if(!ue)return void I.a.error("Received unparseable signal.");I.a.debug("Handling signal",{description:ue});const{sdp:ae,type:de}=ue;if(!ae||!de)return void I.a.warn("Received non-SDP signal");const{signalingState:me,connectionState:pe}=$;if(me!=="stable"||pe!=="connected")if($.remoteDescription)I.a.warn(`Received SDP after remote description was set: ${ae}`);else{if(de==="offer"){if(me!=="stable")return void I.a.warn("Received offer SDP when signaling is ongoing.");yield $.setRemoteDescription(ue);const ge=yield $.createAnswer();yield $.setLocalDescription(ge);const ce=q.clone();return te==null||te("Answer Received",ce),ce.setPayload(JSON.stringify(ge)),ce.setReceiverId(q.getSenderId()),ce.setSenderId(q.getReceiverId()),ce}if(de==="answer"){if(me==="stable")return void I.a.warn("Received answer SDP when signaling hasn't started.");yield $.setRemoteDescription(ue)}}else I.a.warn(`Received SDP when already connected: ${ae}`)})}send(q,$){const te=this.getChannelFromLabel($.channelLabel);te?this.sendOnChannel(te,q):I.a.warn("Send called with unexpected channel label",{channelLabel:$.channelLabel})}controlRemoteStream(q){this.sendSystemMessage(d(this.reliableStreamChannel),{type:"stream-control",streamControl:q})}isActive(){return new Set(["new","checking","connected","completed"]).has(this.peerConnection.iceConnectionState)||this.isReady()}isReady(){const{reliableStreamChannel:q,latestTtlStreamChannel:$,latestTryOnceStreamChannel:te,latestReliableStreamChannel:ue}=this;return(q==null?void 0:q.readyState)==="open"&&($==null?void 0:$.readyState)==="open"&&(te==null?void 0:te.readyState)==="open"&&(ue==null?void 0:ue.readyState)==="open"}close(){return ie(this,void 0,void 0,function*(){if(this.closeCalled)return;this.closeCalled=!0,this.sessionMetrics&&(yield this.sessionMetrics.uploadMetrics()),this.pingUpdateTimeout&&clearInterval(this.pingUpdateTimeout),this.reassemblyTableCleanupTimeout&&clearInterval(this.reassemblyTableCleanupTimeout),this.streamsInfoUpdateTimeout&&clearInterval(this.streamsInfoUpdateTimeout),this.heartbeatTimeout&&clearInterval(this.heartbeatTimeout);const{peerConnection:q,reliableStreamChannel:$,latestTtlStreamChannel:te,latestTryOnceStreamChannel:ue,latestReliableStreamChannel:ae}=this;q.close(),$==null||$.close(),te==null||te.close(),ue==null||ue.close(),ae==null||ae.close()})}getPing(){return this.pingTimeMs}getLastMessageTimestamp(){return this.lastMessageTimestamp}getSessionCreatedTimestamp(){var q;return(q=this.config.remoteConfig)===null||q===void 0?void 0:q.sessionCreatedTimestamp}setSessionCreatedTimestamp(q){this.config.remoteConfig&&(this.config.remoteConfig.sessionCreatedTimestamp=q)}getSessionId(){var q;return(q=this.config.remoteConfig)===null||q===void 0?void 0:q.sessionId}setSessionId(q){this.config.remoteConfig&&(this.config.remoteConfig.sessionId=q,this.sessionMetrics=new ee(q,this))}getRemotePeerId(){return this.config.baseConfig.remotePeerId}getRemoteDeviceId(){var q;return(q=this.config.baseConfig)===null||q===void 0?void 0:q.remoteDeviceId}setRemoteDeviceId(q){this.config.baseConfig.remoteDeviceId=q}getSessionMetricsMessageCounts(){var q;return(q=this.sessionMetrics)===null||q===void 0?void 0:q.counts}getConnectionStatsInfo(){return ie(this,void 0,void 0,function*(){const{peerConnection:q}=this;if(!q)return;const $=yield q.getStats(null),te=[];$.forEach(pe=>{te.push(pe)});const ue=te.find(pe=>pe.type==="transport");if(!ue)return;const ae=te.find(pe=>(pe.type==="candidate-pair"||pe.type==="candidatepair")&&pe.id===ue.selectedCandidatePairId);if(!ae)return;const de=te.find(pe=>pe.id===ae.localCandidateId),me=te.find(pe=>pe.id===ae.remoteCandidateId);return de&&me&&(de.address=de.address||de.ip,me.address=me.address||me.ip,de.address!==void 0&&me.address!==void 0)?{transport:ue,localCandidate:de,remoteCandidate:me}:void 0})}initializeChannels(q){this.heartbeatChannel=q.createDataChannel("heartbeat",y),this.heartbeatChannel.binaryType="arraybuffer",this.latestTtlStreamChannel=q.createDataChannel("stream.latest-ttl",Y),this.latestTtlStreamChannel.binaryType="arraybuffer",this.reliableStreamChannel=q.createDataChannel("stream.reliable",K),this.reliableStreamChannel.binaryType="arraybuffer",this.latestReliableStreamChannel=q.createDataChannel("stream.latest-reliable",H),this.latestReliableStreamChannel.binaryType="arraybuffer",this.latestTryOnceStreamChannel=q.createDataChannel("stream.latest-try-once",V),this.latestTryOnceStreamChannel.binaryType="arraybuffer",this.setupChannel(this.latestTtlStreamChannel),this.setupChannel(this.reliableStreamChannel),this.setupChannel(this.latestReliableStreamChannel),this.setupChannel(this.latestTryOnceStreamChannel)}getOffer(){var q,$,te;return ie(this,void 0,void 0,function*(){const{gotOffer:ue}=this,{peerConnection:ae,config:de}=this;if(this.config.baseConfig.isLan)throw new Error('"getOffer" method can only be called with internet connections. LAN connections should call the "getLanOffer" method.');const me=(q=this.config.remoteConfig)===null||q===void 0?void 0:q.sessionId;if(ue)return void I.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,ne(this.peerConnection))return void I.a.debug("Failed to generate offer because the peer connection was inactive.");const pe=de.baseConfig.track;ae.onicecandidate=()=>{this.hasIceCandidate=!0},ae.oniceconnectionstatechange=()=>ie(this,void 0,void 0,function*(){const Pe=ae.iceConnectionState;if(Pe==="connected"||Pe==="completed"){const Le=yield this.getConnectionStatsInfo(),Fe=Le?function(ze){const De=ze.localCandidate.candidateType,We=ze.remoteCandidate.candidateType;return De==="host"&&We==="host"?"local":De==="relay"||We==="relay"?"TURN":"STUN"}(Le):void 0;I.a.info(`ICE connection state changed to ${Pe}`,{sessionId:me,connectionStatsInfo:Le,iceMode:Fe}),pe==null||pe("ICE connection state change",{iceConnectionState:Pe,sessionId:me,connectionStatsInfo:Le,iceMode:Fe})}}),yield ae.setLocalDescription(yield ae.createOffer());const ge=new Date().getTime();for(;;){const Pe=new Date().getTime()-ge;if(Pe>this.connectTimeoutMs)return void I.a.debug("Failed to generate offer because ICE gathering timed out.");if(Pe>this.iceGatheringTimeoutMs&&this.hasIceCandidate){I.a.debug("ICE gathering partially completed; proceeding",{iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe}),pe==null||pe("ICE gathering partially completed",{sessionId:me,iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe});break}if(ae.iceGatheringState==="complete"){I.a.debug("ICE gathering complete",{iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe}),pe==null||pe("ICE gathering completed",{sessionId:me,iceTransportPolicy:ae.getConfiguration().iceTransportPolicy,waitTime:Pe});break}yield Object(u.a)(.1*c.a.second)}const ce=($=this.peerConnection.getConfiguration().iceServers)!==null&&$!==void 0?$:[];for(const Pe of ce)Pe.credentialType=void 0;const Te=JSON.stringify(ce),Re=new L.Signal;return Re.setPayload(JSON.stringify(ae.localDescription)),Re.setSenderId(this.config.baseConfig.localPeerId),Re.setReceiverId(this.config.baseConfig.remotePeerId),Re.setIceServers(Te),Re.setIceTransportPolicy((te=this.peerConnection.getConfiguration().iceTransportPolicy)!==null&&te!==void 0?te:"all"),this.config.baseConfig.sessionType!==void 0?Re.setSessionType(this.config.baseConfig.sessionType):Re.setSessionType(L.SessionType.TELEOP),I.a.debug("Sending offer signal with description",{description:Re.getPayload()}),Re})}getLanOffer(){return ie(this,void 0,void 0,function*(){const{peerConnection:q,gotOffer:$}=this;if(!this.config.baseConfig.isLan)throw new Error('"getLanOffer" method can only be used with LAN connections. Internet connections should call the "getOffer" method.');if($)return void I.a.debug("Failed to generate offer because gotOffer was already called.");if(this.gotOffer=!0,ne(this.peerConnection))return void I.a.debug("Failed to generate offer because the peer connection was inactive.");yield q.setLocalDescription(yield q.createOffer());const te=new Date().getTime();for(;;){if(new Date().getTime()-te>this.iceGatheringTimeoutMs)return void I.a.debug("Failed to generate offer because ICE gathering timed out.");if(q.iceGatheringState==="complete")break;yield Object(u.a)(.1*c.a.second)}const ue=q.localDescription;if(ue)return I.a.debug("Sending LAN offer signal with description",{description:ue}),ue;I.a.error("Failed to generate LAN offer description")})}handleLanAnswer(q){return ie(this,void 0,void 0,function*(){const{peerConnection:$}=this;if(!this.config.baseConfig.isLan)throw new Error('"handleLanAnswer" method can only be used with LAN connections. Internet connections should call the "handleSignal" method.');yield $.setRemoteDescription(q)})}getChannelFromLabel(q){switch(q){case"stream.latest-ttl":return this.latestTtlStreamChannel;case"stream.reliable":return this.reliableStreamChannel;case"stream.latest-reliable":return this.latestReliableStreamChannel;case"stream.latest-try-once":return this.latestTryOnceStreamChannel}}sendOnChannel(q,$){let te;try{te=Object(G.encode)(JSON.stringify($))}catch(ue){return void I.a.warn("Failed to encode RTC message",{error:ue})}try{q.send(te),this.sessionMetrics&&this.sessionMetrics.incrementLocalSent($)}catch(ue){I.a.warn("Failed to send message to channel",{error:ue,channel:q.label})}}channelNotRecognized(q){return q!==this.latestTtlStreamChannel&&q!==this.latestReliableStreamChannel&&q!==this.latestTryOnceStreamChannel&&q!==this.reliableStreamChannel}setupChannel(q){q.onmessage=$=>{if(this.channelNotRecognized(q))return void I.a.warn("Received message on unrecognized data channel.");let te;try{te=JSON.parse(Object(G.decode)($.data))}catch(ue){return void I.a.warn("Received unparseable message on RTC stream data channel",{error:ue,channel:q.label})}te.communicationType==="message-chunk"?this.receiveChannelMessageChunk(q,te):this.receiveChannelMessage(q,te)},q.onerror=$=>{I.a.warn(`Channel error: ${$.error}`,{error:$.error,sessionId:this.getSessionId(),channelLabel:q.label})},q.onopen=()=>{I.a.debug("Channel opened",{sessionId:this.getSessionId(),channelLabel:q.label})},q.onclose=()=>{const $={bufferedAmount:q.bufferedAmount,sessionId:this.getSessionId(),channelLabel:q.label};this.closeCalled===!1?I.a.debug("Unexpected channel closed",$):I.a.debug("Channel closed",$)}}receiveChannelMessage(q,$){const{config:te}=this,{remotePeerId:ue}=this.config.baseConfig;this.lastMessageTimestamp=new Date().getTime(),$=function(ae){switch(ae.header.stream.streamType){case"twist":{const{twist:de}=ae.payload;if(!de)throw Error("twist not in payload of RTC message with type twist");return{header:ae.header,payload:{twist:{linear:Object.assign({x:0,y:0,z:0},de.linear),angular:Object.assign({x:0,y:0,z:0},de.angular)}}}}case"pose":{const{pose:de}=ae.payload;if(!de)throw Error("pose not in payload of RTC message with type pose");return{header:ae.header,payload:{pose:{translation:Object.assign({x:0,y:0,z:0},de.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},de.rotation)}}}}case"pose-with-covariance":{const{poseWithCovariance:de}=ae.payload;if(!de)throw Error("poseWithCovariance not in payload of RTC message with type pose-with-covariance");const me=new Array(36).fill(0);return de.covariance.forEach((pe,ge)=>{if(ge>=36)throw Error("covariance contains more than 36 elements");me[ge]=pe}),{header:ae.header,payload:{poseWithCovariance:{pose:{translation:Object.assign({x:0,y:0,z:0},de.pose.translation),rotation:Object.assign({x:0,y:0,z:0,w:0},de.pose.rotation)},covariance:me}}}}case"point":{const{point:de}=ae.payload;if(!de)throw Error("point not in payload of RTC message with type point");return{header:ae.header,payload:{point:Object.assign({x:0,y:0,z:0},de)}}}default:return ae}}($),this.sessionMetrics&&this.sessionMetrics.incrementLocalReceived($),this.handleSystemMessage(q,$)||(q===this.latestTryOnceStreamChannel||q===this.latestTtlStreamChannel||q===this.latestReliableStreamChannel)&&!this.isLatestMessage($)||te.baseConfig.receive(ue,$)}receiveChannelMessageChunk(q,$){const te=this.reassemblyTable.get($.id)||[];if(te.push($),te.length===$.total){const ue=function(ae){const de=ae.sort((me,pe)=>me.seq<pe.seq?-1:1).map(me=>me.part).reduce((me,pe)=>me+pe);try{return JSON.parse(de)}catch{return void I.a.warn("Could not reassemble RTC message chunks")}}(te);return ue&&this.receiveChannelMessage(q,ue),void this.reassemblyTable.delete($.id)}this.reassemblyTable.set($.id,te),this.reassemblyTableLastTimestamp.set($.id,new Date().getTime())}handleSystemMessage(q,$){var te,ue;const{config:ae}=this,{baseConfig:de}=ae,{remotePeerId:me}=de;switch($.header.stream.streamType){case"ping":return this.sendSystemMessage(q,{type:"pong",timestamp:d($.payload.ping)}),!0;case"pong":{const pe=new Date().getTime()-d($.payload.pong);return this.pingTimeMs=pe,O.aggregate("rtc-ping-time",pe),!0}case"streams-info":{const{sessionMetrics:pe}=this,ge=(te=$.payload.streamsInfo)===null||te===void 0?void 0:te.timestamp;return!!ge&&(pe==null||pe.updateRemoteMessagesCounts($),(ue=de.onStreamsInfoUpdate)===null||ue===void 0||ue.call(de,me,ge),!0)}case"stream-control":return!0;default:return!1}}sendSystemMessage(q,$){var te;const{localUserId:ue,localPeerId:ae}=this.config.baseConfig;if(q.readyState!=="open")return;const de={entityId:ue!=null?ue:ae,streamName:`$.${$.type}`,streamType:$.type};let me;switch($.type){case"ping":me={ping:new Date().getTime()};break;case"pong":me={pong:$.timestamp};break;case"stream-control":me={streamControl:$.streamControl};break;case"streams-info":me={streamsInfo:(te=this.sessionMetrics)===null||te===void 0?void 0:te.getLocalStreamsInfo(new Date().getTime())}}this.sendOnChannel(q,X(de,me))}isLatestMessage(q){const $=j(q.header.stream),te=(this.streamLatestTimestamp.get($)||0)<=q.header.created;return te&&this.streamLatestTimestamp.set($,q.header.created),te}}function Se(ye){var q,$;return{userId:(q=ye.getUserId())===null||q===void 0?void 0:q.getValue(),deviceId:($=ye.getDeviceId())===null||$===void 0?void 0:$.getValue(),organizationId:ye.getOrganizationId(),id:ye.getPeerId(),capabilities:[],capabilitySet:{}}}var we=function(ye,q,$,te){return new($||($=Promise))(function(ue,ae){function de(ge){try{pe(te.next(ge))}catch(ce){ae(ce)}}function me(ge){try{pe(te.throw(ge))}catch(ce){ae(ce)}}function pe(ge){var ce;ge.done?ue(ge.value):(ce=ge.value,ce instanceof $?ce:new $(function(Te){Te(ce)})).then(de,me)}pe((te=te.apply(ye,q||[])).next())})};class Ee{constructor(q){this.config=q,this.grpcCallDeadline=5*c.a.second,this.refreshIntervalDelayMs=2*c.a.second,this.iceServersTtl=30*c.a.minute,this.connections=[],this.localConnections=[],this.isConnectionInitiator=new Map,this.isOutgoingConnection=new Map,this.peerDataChannelListeners=[];const{refreshIntervalDelayMs:$}=this;this.refreshInterval=Z({func:()=>we(this,void 0,void 0,function*(){try{yield this.update()}catch(te){I.a.warn("RTC refresh failed",{error:te})}}),delay:$,immediate:!0})}send(q,$,te){const ue=this.getActiveConnection(q);ue?ue.isReady()?ue.send($,te):I.a.warn("Send called with unready connection."):I.a.warn("Send called with no connection.")}controlRemoteStream(q,$){const te=this.getActiveConnection(q);te?te.isReady()?te.controlRemoteStream($):I.a.warn("controlRemoteStream called with unready connection."):I.a.warn("controlRemoteStream called with no connection.")}getLocalPeer(){return we(this,void 0,void 0,function*(){for(;!this.localPeer;)yield Object(u.a)(.1*c.a.second);return Se(this.localPeer)})}connect(q,$){var te,ue,ae;return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode===!0)throw new Error("connect method called in local only mode.");const{track:de,signalingClient:me}=this.config,{localPeer:pe,receiveSignalStream:ge,iceServers:ce}=this;if(!pe||!ge||!ce)return void I.a.warn("Connect called prior to local peer, receiveSignalStream, and ICE servers ready");if(this.getActiveConnection(q))return void I.a.warn("Connect called for peer with existing connection.");if(this.isOutgoingConnection.get(q))return void I.a.warn("Connect called for peer with an existing outgoing connection offer.");this.isOutgoingConnection.set(q,!0);const Te=new he(yield this.createRTCPeerConnection(ce,$),{baseConfig:{isOffer:!0,isLan:!1,receive:(De,We)=>this.config.receive(De,We),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(De,We)=>{var Be,ke;return(ke=(Be=this.config).onStreamsInfoUpdate)===null||ke===void 0?void 0:ke.call(Be,De,We)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(te=pe.getUserId())===null||te===void 0?void 0:te.getValue(),localPeerId:pe.getPeerId(),remotePeerId:q,sessionType:$==null?void 0:$.sessionType},remoteConfig:{}},De=>this.onCustomDataChannel(q,De)),Re=yield Te.getOffer();if(!Re)return I.a.error("Failed to generate offer."),void this.isOutgoingConnection.delete(q);I.a.debug("Sending offer."),de==null||de("Sending offer",Re);const Pe=new L.SendSignalRequest;Pe.setSignal(Re);const Le=yield(()=>we(this,void 0,void 0,function*(){try{return yield me.sendSignal(Pe,yield this.getMetadata({}))}catch(De){I.a.warn("Error when sending signal",{error:De})}}))();if(!this.isOutgoingConnection.get(q))return void I.a.debug("No offer set after receiving offer signal response.");I.a.debug("Offer sent.");const Fe=(ue=Le==null?void 0:Le.getSessionId())===null||ue===void 0?void 0:ue.getValue(),ze=(ae=Le==null?void 0:Le.getSessionCreatedTimestamp())===null||ae===void 0?void 0:ae.getValue();return Fe&&ze?(Te.setSessionId(Fe),Te.setSessionCreatedTimestamp(ze),this.isOutgoingConnection.delete(q),this.connections.push(Te),this.isConnectionInitiator.set(Te,!0),this.setupHandlers(Te),Fe):(I.a.warn("No session ID or no session created timestamp on send signal response."),void this.isOutgoingConnection.delete(q))})}connectLan(q){var $,te;return we(this,void 0,void 0,function*(){const ue=new B(q),ae=new he(yield this.createRTCPeerConnection([]),{baseConfig:{isOffer:!0,isLan:!0,receive:(ge,ce)=>this.config.receive(ge,ce),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(ge,ce)=>{var Te,Re;return(Re=(Te=this.config).onStreamsInfoUpdate)===null||Re===void 0?void 0:Re.call(Te,ge,ce)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localUserId:(te=($=this.localPeer)===null||$===void 0?void 0:$.getUserId())===null||te===void 0?void 0:te.getValue(),localPeerId:"lan_client",remotePeerId:q}},ge=>this.onCustomDataChannel(q,ge)),de=yield ae.getLanOffer();if(!de)return I.a.warn("Could not generate LAN offer"),!1;const me=yield ue.postLanRtcOffer({offer:JSON.stringify(de)}),pe=new RTCSessionDescription(JSON.parse(me.answer));return yield ae.handleLanAnswer(pe),this.localConnections.push(ae),this.isConnectionInitiator.set(ae,!0),Object(E.v4)()})}getConnections(){return[...this.connections,...this.localConnections]}createCustomDataChannel(q,$,te,ue,ae){const de=this.getActiveConnection(q);if(de&&this.isConnectionInitiator.has(de)){const pe=de.peerConnection.createDataChannel("custom."+$,te);return ue&&(pe.binaryType="arraybuffer"),ae(q,pe),()=>{}}const me=(pe,ge)=>{q===pe&&ge.label==="custom."+$&&ae(q,ge)};return this.peerDataChannelListeners.push(me),()=>{this.peerDataChannelListeners=this.peerDataChannelListeners.filter(pe=>pe!==me)}}onCustomDataChannel(q,$){this.peerDataChannelListeners.forEach(te=>te(q,$))}getConnectionStatus(q){if(this.isOutgoingConnection.get(q))return"connecting";const $=this.getActiveConnection(q);return $?$.isReady()?"connected":"connecting":"disconnected"}getConnectionStatsInfo(q){return we(this,void 0,void 0,function*(){const $=this.getActiveConnection(q);if($)return yield $.getConnectionStatsInfo()})}disconnect(q){return we(this,void 0,void 0,function*(){const $=this.getActiveConnection(q);$&&(yield $.close())})}getPeers(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:q}=this.config,$=yield(()=>we(this,void 0,void 0,function*(){try{return yield q.getPeers(new L.GetPeersRequest,yield this.getMetadata({}))}catch(ae){I.a.warn("Error when getting peers",{error:ae})}}))();if(!$)return[];const te=$.getPeersList();if(!te)return[];const ue=ae=>{var de,me;return(me=(de=ae.getPeerCreatedTimestamp())===null||de===void 0?void 0:de.getValue())!==null&&me!==void 0?me:0};return te.sort((ae,de)=>ue(de)-ue(ae)).map(ae=>Se(ae))})}getSessions(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getPeers method cannot be used in local-only mode.");const{signalingClient:q}=this.config,$=yield(()=>we(this,void 0,void 0,function*(){try{return yield q.getPeers(new L.GetPeersRequest,yield this.getMetadata({}))}catch(ae){I.a.warn("Error when getting peers",{error:ae})}}))();if(!$)return{};const te=$.getPeersList(),ue={};for(const ae of te)ue[ae.getPeerId()]=ae.getSessionIdsList();return ue})}getPing(q){const $=this.getActiveConnection(q);if($)return $.getPing();I.a.warn("Attempted to get ping time from inactive peer.")}getLastMessageTimestamp(q){const $=this.getActiveConnection(q);if($)return $.getLastMessageTimestamp();I.a.warn("Attempted to get last message time from inactive peer.")}getSessionMetricsMessageCounts(q){const $=this.getActiveConnection(q);if($)return $.getSessionMetricsMessageCounts();I.a.warn("Attempted to get session metrics counts from inactive peer.")}isReady(){if(this.config.lanOnlyMode)return!0;const{localPeer:q,receiveSignalStream:$,iceServers:te}=this;return!!(q&&$&&te)}shutdown(){return we(this,void 0,void 0,function*(){I.a.info("Shutdown called on RTC client"),yield this.refreshInterval.stop(),this.receiveSignalStream&&this.receiveSignalStream.cancel();const q=this.connections;this.connections=[],yield this.closeConnections(q);const{localPeer:$}=this;if(!$||this.config.lanOnlyMode)return;const{signalingClient:te}=this.config;yield(()=>we(this,void 0,void 0,function*(){try{const ue=new L.DeletePeerRequest;ue.setPeerId($.getPeerId()),yield te.deletePeer(ue,yield this.getMetadata({}))}catch(ue){return void I.a.warn("Error deleting local peer",{error:ue})}}))()})}createPeer(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createPeer method cannot be used in local-only mode.");const{signalingClient:q}=this.config,$=yield(()=>we(this,void 0,void 0,function*(){try{return yield q.createPeer(new L.CreatePeerRequest,yield this.getMetadata({}))}catch(ue){throw new Error(`Was not able to create peer: ${JSON.stringify(ue)}`)}}))(),te=$==null?void 0:$.getPeer();if(!te)throw new Error("Response did not provide peer.");return this.localPeer=te})}createReceiveSignalStream(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("createReceiveSignalStream method cannot be used in local-only mode.");const{signalingClient:q}=this.config,{localPeer:$,iceServers:te}=this;if(!$||!te)return;const{receiveSignalStream:ue}=this;ue&&ue.cancel();const ae=new L.ReceiveSignalStreamRequest;ae.setPeerId($.getPeerId());const de=yield(()=>we(this,void 0,void 0,function*(){try{return q.receiveSignalStream(ae,yield this.getMetadata({hasDeadline:!1}))}catch(me){throw new Error(`Unable to create receive signal stream: ${JSON.stringify(me)}`)}}))();if(!de)throw new Error("Response did not provide stream.");return de.on("data",me=>we(this,void 0,void 0,function*(){var pe,ge,ce,Te;const Re=me.getSignal(),Pe=(pe=Re==null?void 0:Re.getSessionId())===null||pe===void 0?void 0:pe.getValue(),Le=Re==null?void 0:Re.getSenderId(),Fe=Re==null?void 0:Re.getReceiverId(),ze=(ge=Re==null?void 0:Re.getSessionCreatedTimestamp())===null||ge===void 0?void 0:ge.getValue();if(!(Re&&Pe&&Le&&Fe&&ze))return void I.a.warn("Received signal with missing information.");const De=this.getActiveConnection(Le);if(De)if(De.getSessionId()!==Pe){if(I.a.debug("Received signal: different session for a peer we're already connected to."),(De.getSessionCreatedTimestamp()||0)>ze)return;const We=new he(yield this.createRTCPeerConnection(te),{baseConfig:{isOffer:!1,isLan:!1,receive:(Be,ke)=>this.config.receive(Be,ke),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(Be,ke)=>{var qe,Ge;return(Ge=(qe=this.config).onStreamsInfoUpdate)===null||Ge===void 0?void 0:Ge.call(qe,Be,ke)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:$.getPeerId(),localUserId:(Te=$.getUserId())===null||Te===void 0?void 0:Te.getValue(),remotePeerId:Le},remoteConfig:{sessionId:Pe,sessionCreatedTimestamp:ze}},Be=>this.onCustomDataChannel(Le,Be));yield We.handleSignal(Re),this.connections.push(We)}else I.a.debug("Received signal: for an existing connection."),yield De.handleSignal(Re);else{I.a.debug("Received signal: new connection.");const We=new he(yield this.createRTCPeerConnection(te),{baseConfig:{isOffer:!1,isLan:!1,receive:(Be,ke)=>this.config.receive(Be,ke),onStreamsInfoUpdate:this.config.onStreamsInfoUpdate?(Be,ke)=>{var qe,Ge;return(Ge=(qe=this.config).onStreamsInfoUpdate)===null||Ge===void 0?void 0:Ge.call(qe,Be,ke)}:void 0,track:this.config.lanOnlyMode?void 0:this.config.track,localPeerId:$.getPeerId(),localUserId:(ce=$.getUserId())===null||ce===void 0?void 0:ce.getValue(),remotePeerId:Le},remoteConfig:{sessionId:Pe,sessionCreatedTimestamp:ze}},Be=>this.onCustomDataChannel(Le,Be));yield We.handleSignal(Re),this.connections.push(We)}})),de.on("end",()=>{de.cancel(),this.receiveSignalStream=void 0}),de.on("error",me=>{switch(me.code){case k.StatusCode.CANCELLED:case k.StatusCode.UNAVAILABLE:case k.StatusCode.UNKNOWN:I.a.debug("Receive signal stream error",{error:me});break;case k.StatusCode.UNAUTHENTICATED:I.a.warn("Receive signal stream error",{error:me});break;default:I.a.error("Receive signal stream error",{error:me})}de.cancel(),this.receiveSignalStream=void 0}),this.receiveSignalStream=de})}createRTCPeerConnection(q,$){var te;return we(this,void 0,void 0,function*(){const ue=$==null?void 0:$.rtcIceTransportPolicies,ae=$!=null&&$.rtcIceServerProtocol?[$==null?void 0:$.rtcIceServerProtocol]:void 0,de=q.map(pe=>Object.assign(Object.assign({},pe),{urls:typeof pe.urls=="string"?[pe.urls]:pe.urls})).map(pe=>Object.assign(Object.assign({},pe),{urls:pe.urls.filter(ge=>{const ce=(ue===void 0||ue.some(Te=>((Re,Pe)=>{switch(Pe){case"stun":return/^stuns?:/.test(Re);case"turn":return/^turns?:/.test(Re)}})(ge,Te)))&&(ae===void 0||ae.some(Te=>((Re,Pe)=>Re.endsWith(`transport=${Pe}`))(ge,Te)));return ce||I.a.debug(`Ignoring ICE server: ${ge}`),ce})})).filter(({urls:pe})=>pe.filter(ge=>ge).length>0),me=(te=this.config.alternateRTCPeerConnection)!==null&&te!==void 0?te:window.RTCPeerConnection;if(!me)throw new Error("RTCPeerConnection class not found. WebRTC must be enabled.");return new me(Object.assign({iceServers:de,iceTransportPolicy:(ue==null?void 0:ue.length)===1&&ue[0]==="turn"?"relay":"all"},$))})}closeConnections(q){return we(this,void 0,void 0,function*(){const $=yield R(q.map(te=>we(this,void 0,void 0,function*(){yield te.close()})));for(const te of $)I.a.warn("Request to close session failed",{error:te})})}getActiveConnection(q){return this.getConnections().find($=>$.getRemotePeerId()===q&&$.isActive())}update(){var q;return we(this,void 0,void 0,function*(){if(this.localConnections=this.localConnections.filter(me=>me.isActive()),this.config.lanOnlyMode)return;const{signalingClient:$}=this.config;if(!this.localPeer||!this.receiveSignalStream||!this.iceServers)return this.localPeer||(yield this.createPeer()),this.iceServers||(yield this.updateIceServers()),void(this.receiveSignalStream||(yield this.createReceiveSignalStream()));yield this.closeConnections(this.connections.filter(me=>!me.isActive())),this.connections=this.connections.filter(me=>me.isActive());const{localPeer:te}=this,ue=this.connections.filter(me=>me.getSessionId).map(me=>d(me.getSessionId()));te.setSessionIdsList(ue);const ae=new L.RefreshPeerRequest;ae.setPeer(te);try{yield $.refreshPeer(ae,yield this.getMetadata({}))}catch(me){me.code===k.StatusCode.NOT_FOUND?(I.a.warn("Peer expired, creating new peer",{peerId:te.getPeerId()}),yield this.reset()):I.a.warn("Error calling RefreshPeer",{error:me})}const de=yield this.getPeers();for(const me of this.connections)me.setRemoteDeviceId((q=de.find(pe=>pe.id===me.getRemotePeerId()))===null||q===void 0?void 0:q.deviceId)})}reset(){return we(this,void 0,void 0,function*(){yield this.closeConnections(this.connections),this.connections=[],this.isOutgoingConnection=new Map,yield this.createPeer(),yield this.createReceiveSignalStream()})}updateIceServers(){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)return;const{iceServersLastUpdate:q,iceServersTtl:$}=this,te=new Date().getTime();if(!q||te-q>$)try{const ue=(yield this.config.signalingClient.getIceServers(new L.GetIceServersRequest,yield this.getMetadata({}))).getIceServers();this.iceServers=JSON.parse(ue),this.iceServersLastUpdate=te}catch(ue){I.a.warn("Error in updateIceServers",{error:ue})}})}setupHandlers(q){const{peerConnection:$}=q,te=q.getSessionCreatedTimestamp();$.onconnectionstatechange=()=>we(this,void 0,void 0,function*(){const ue=$.connectionState;if(te)switch(ue){case"connected":O.aggregate("rtc-connect-time",new Date().getTime()-te);break;case"failed":O.increment("rtc-connect-failed")}})}getMetadata(q){return we(this,void 0,void 0,function*(){if(this.config.lanOnlyMode)throw new Error("getMetadata method cannot be called in local-only mode");const{getToken:$}=this.config,{grpcCallDeadline:te}=this,{hasDeadline:ue}=q,ae=ue===!1?void 0:new Date().getTime()+te;return{authorization:yield $(),deadline:ae}})}}},,function(e,t,r){r.r(t),r.d(t,"LogClient",function(){return l});var n=r(25),o=function(s,i,c,u){return new(c||(c=Promise))(function(b,A){function _(S){try{f(u.next(S))}catch(w){A(w)}}function v(S){try{f(u.throw(S))}catch(w){A(w)}}function f(S){var w;S.done?b(S.value):(w=S.value,w instanceof c?w:new c(function(P){P(w)})).then(_,v)}f((u=u.apply(s,i||[])).next())})};class l extends n.a{log(i){return o(this,void 0,void 0,function*(){yield this.fetch("logs",{method:"POST",body:JSON.stringify({logs:i}),allowUnsafeRetries:!0})})}}}])})})(dist);let FORMANT_API_URL="https://api.formant.io";typeof window!="undefined"&&(FORMANT_API_URL=window.FORMANT_API_URL||FORMANT_API_URL);let urlParams$1=new URLSearchParams("");typeof window!="undefined"&&(urlParams$1=new URLSearchParams(window.location.search));const envDev=urlParams$1.get("formant_dev");envDev&&(FORMANT_API_URL="https://api-dev.formant.io");const envStage=urlParams$1.get("formant_stage");envStage&&(FORMANT_API_URL="https://api-stage.formant.io");function delay(e){return new Promise(t=>setTimeout(t,e))}function defined(e,t){if(e!==void 0)return e;throw new Error(t||"Value is undefined")}class App{static sendAppMessage(t){window.parent.postMessage(t,"*")}static getCurrentModuleContext(){let t=new URLSearchParams("");return typeof window!="undefined"&&(t=new URLSearchParams(window.location.search)),t.get("module")}static isModule(){return this.getCurrentModuleContext()!==null}static goToTime(t){this.sendAppMessage({type:"go_to_time",time:t.getTime()})}static goToDevice(t){this.sendAppMessage({type:"go_to_device",deviceId:t})}static showMessage(t){this.sendAppMessage({type:"show_message",message:t})}static requestModuleData(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"request_module_data",module:t})}static setModuleDateTimeRange(t,r){const n=this.getCurrentModuleContext();if(!n)throw new Error("No module context");this.sendAppMessage({type:"set_module_data_time_range",module:n,before:t,after:r||0})}static refreshAuthToken(){const t=this.getCurrentModuleContext();if(!t)throw new Error("No module context");this.sendAppMessage({type:"refresh_auth_token",module:t})}static sendChannelData(t,r){const n=this.getCurrentModuleContext();if(!n)throw new Error("No module context");this.sendAppMessage({type:"send_channel_data",source:n,channel:t,data:r})}static setupModuleMenus(t){const r=this.getCurrentModuleContext();if(!r)throw new Error("No module context");this.sendAppMessage({type:"setup_module_menus",module:r,menus:t})}static addMenuListener(t){window.addEventListener("message",r=>{const n=r.data;n.type==="module_menu_item_clicked"&&t(n.menu)})}static addAccessTokenRefreshListener(t){window.addEventListener("message",r=>{const n=r.data;n.type==="auth_token"&&t(n.token)})}static addModuleDataListener(t){window.addEventListener("message",r=>{const n=r.data;n.type==="module_data"&&t({streams:n.streams,time:n.time,queryRange:n.queryRange})})}static addChannelDataListener(t,r){window.addEventListener("message",n=>{const o=n.data;o.type==="channel_data"&&o.channel===t&&r({source:o.source,data:o.data})})}}const Oe=class{static async login(t,r){try{const n=await fetch(`${FORMANT_API_URL}/v1/admin/auth/login`,{method:"POST",body:JSON.stringify({email:t,password:r}),headers:{"Content-Type":"application/json"}}),o=await n.json();if(n.status!==200)throw new Error(o.message);return await Oe.loginWithToken(o.authentication.accessToken,o.authentication.refreshToken),o.authentication}catch(n){return Oe.waitingForAuth.forEach(o=>o(!1)),Oe.waitingForAuth=[],Promise.reject(n)}}static async loginWithToken(t,r){const n=JSON.parse(atob(t.split(".")[1]));try{let o;if(Oe.isShareToken=n["formant:claims"]&&n["formant:claims"].type=="share",n["formant:claims"]&&(Oe.currentOrganization=n["formant:claims"].organizationId),n["custom:organization_id"]&&(Oe.currentOrganization=n["custom:organization_id"]),Oe.isShareToken||(o=n.sub),n["formant:claims"]&&n["formant:claims"].userId&&(o=n["formant:claims"].userId),o){const l=await fetch(`${FORMANT_API_URL}/v1/admin/users/${o}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+t}}),s=await l.json();if(l.status!==200)throw new Error(s.message);Oe.currentUser=s}Oe.token=t,Oe.waitingForAuth.forEach(l=>l(!0))}catch(o){console.error(o),Oe.waitingForAuth.forEach(l=>l(!1))}Oe.waitingForAuth=[],r&&(Oe.refreshToken=r,setInterval(async()=>{if(Oe.refreshToken){const l=await(await fetch(`${FORMANT_API_URL}/v1/admin/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:Oe.refreshToken})})).json();Oe.token=l.authentication.accessToken}},1e3*60*60))}static isAuthenticated(){return Oe.token!==void 0}static getCurrentUser(){return Oe.currentUser}static async waitTilAuthenticated(){return Oe.token!==void 0?!0:new Promise(t=>{Oe.waitingForAuth.push(function(r){t(r)})})}static async listenForRefresh(){App.addAccessTokenRefreshListener(t=>{this.loginWithToken(t)}),setInterval(async()=>{App.refreshAuthToken()},1e3*60*60)}};let Authentication=Oe;je(Authentication,"token"),je(Authentication,"refreshToken"),je(Authentication,"currentUser"),je(Authentication,"currentOrganization"),je(Authentication,"isShareToken",!1),je(Authentication,"defaultDeviceId"),je(Authentication,"waitingForAuth",[]);class DataChannel{constructor(t){je(this,"ready",!1);je(this,"listeners",[]);je(this,"openListeners",[]);je(this,"closeListeners",[]);je(this,"errorListeners",[]);je(this,"binaryListeners",[]);je(this,"error");je(this,"decoder",new TextDecoder);this.dataChannel=t,this.dataChannel.binaryType="arraybuffer",this.dataChannel.onopen=()=>{this.ready=!0,this.openListeners.forEach(r=>r())},this.dataChannel.onclose=()=>{this.ready=!1,this.closeListeners.forEach(r=>r())},this.dataChannel.onerror=r=>{console.error(r),this.error="An error occurred in DataChannel",this.errorListeners.forEach(n=>n(r))},this.dataChannel.onmessage=r=>{this.listeners.forEach(n=>{const o=new Uint8Array(r.data),l=this.decoder.decode(o);n(l)}),this.binaryListeners.forEach(n=>{n(new Uint8Array(r.data))})}}addOpenListener(t){this.openListeners.push(t)}removeOpenListener(t){this.openListeners=this.openListeners.filter(r=>r!==t)}addCloseListener(t){this.closeListeners.push(t)}removeCloseListener(t){this.closeListeners=this.closeListeners.filter(r=>r!==t)}addErrorListener(t){this.errorListeners.push(t)}removeErrorListener(t){this.errorListeners=this.errorListeners.filter(r=>r!==t)}async waitTilReady(){return this.ready?!0:new Promise((r,n)=>{let o=window.setInterval(()=>{this.ready&&(window.clearInterval(o),r(!0)),this.error&&n(this.error)},10)})}send(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}sendBinary(t){if(!this.ready)throw new Error("Connection has been closed");this.dataChannel.send(t)}addListener(t){this.listeners.push(t)}removeListener(t){const r=this.listeners.indexOf(t);if(r===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.listeners.splice(r,1)}addBinaryListener(t){this.binaryListeners.push(t)}removeBinaryListener(t){const r=this.binaryListeners.indexOf(t);if(r===-1)throw new Error("Could not find data channel listener to remove");if(this.error)throw new Error(this.error);this.binaryListeners.splice(r,1)}}class CaptureStream{constructor(t){je(this,"token");this.captureSession=t}async ingestJSON(t){if(!this.token){const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions/${this.captureSession.code}/authenticate`,{method:"POST"})).json();this.token=n.token}await fetch(`${FORMANT_API_URL}/v1/ingest`,{method:"POST",body:JSON.stringify({deviceId:this.captureSession.deviceId,name:this.captureSession.streamName,type:"json",points:[[Date.now(),JSON.stringify(t)]]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+this.token}})}}class Manipulator{constructor(t,r){je(this,"currentListeners",[]);je(this,"onRealtimeMessage",(t,r)=>{r.payload.jointState&&this.currentListeners.forEach(n=>{r.payload.jointState&&n(r.payload.jointState)})});this.device=t,this.config=r}async synchronize(){this.device.addRealtimeListener(this.onRealtimeMessage),this.device.startListeningToRealtimeDataStream(this.config.currentJointStateStream)}async desynchronize(){this.device.removeRealtimeListener(this.onRealtimeMessage),this.device.stopListeningToRealtimeDataStream(this.config.currentJointStateStream)}async addCurrentJointStateListener(t){this.currentListeners.push(t)}}class RequestDataChannel{constructor(t,r,n){je(this,"channel");je(this,"requestIdToResponseMap",new Map);this.device=t,this.channel_name=r,this.timeout=n}addOpenListener(t){defined(this.channel,"channel not initalized").addOpenListener(t)}removeOpenListener(t){defined(this.channel,"channel not initalized").removeOpenListener(t)}addCloseListener(t){defined(this.channel,"channel not initalized").addCloseListener(t)}removeCloseListener(t){defined(this.channel,"channel not initalized").removeCloseListener(t)}addErrorListener(t){defined(this.channel,"channel not initalized").addErrorListener(t)}removeErrorListener(t){defined(this.channel,"channel not initalized").removeErrorListener(t)}}class BinaryRequestDataChannel extends RequestDataChannel{constructor(){super(...arguments);je(this,"RESPONSE_SUCCESS_BYTE",0);je(this,"decoder",new TextDecoder)}generateBinaryId(){const r=new Uint8Array(16);for(let n=0;n<r.length;n++)r[n]=Math.floor(Math.random()*256);return r}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addBinaryListener(r=>{const o=r.slice(0,16).toString();if(o.length===0)throw new Error("Invalid response");const l=r.slice(16);if(l.length===0)throw new Error("Invalid response");this.requestIdToResponseMap.has(o)&&this.requestIdToResponseMap.set(o,l)})}async request(r){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:n,requestIdToResponseMap:o,timeout:l}=this;await n.waitTilReady();const s=this.generateBinaryId(),i=s.toString();o.set(i,!0),n.sendBinary(new Uint8Array([...s,...r]));const c=new Date().getTime();for(;new Date().getTime()<c+l;)if(await delay(50),o.has(i)){const u=o.get(i);if(u!==!0){o.delete(i);const b=u[0]===this.RESPONSE_SUCCESS_BYTE,A=u.slice(1);if(b)return A;throw{name:"AdapterError",message:this.decoder.decode(A)}}}throw o.delete(i),{name:"TimeoutError",message:`Request timed out after ${l/1e3} seconds`}}}class TextRequestDataChannel extends RequestDataChannel{generateTextId(){return Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2)}async initialize(){this.channel=await this.device.createCustomDataChannel(this.channel_name),this.channel.addListener(t=>{const r=JSON.parse(t),{id:n,data:o,error:l}=r;if(!n)throw new Error("Invalid response");if(!o&&!l)throw new Error("Invalid response");this.requestIdToResponseMap.has(n)&&this.requestIdToResponseMap.set(n,r)})}async request(t){if(this.channel||await this.initialize(),!this.channel)throw new Error("Failed to create channel");const{channel:r,requestIdToResponseMap:n,timeout:o}=this;await r.waitTilReady();const l=this.generateTextId();n.set(l,!0),r.send(JSON.stringify({id:l,data:t}));const s=new Date().getTime();for(;new Date().getTime()<s+o;)if(await delay(50),n.has(l)){const i=n.get(l);if(i!==!0){n.delete(l);const{data:c,error:u}=i;if(c)return c;if(u)throw{name:"AdapterError",message:u}}}throw n.delete(l),{name:"TimeoutError",message:`Request timed out after ${o/1e3} seconds`}}}const SessionType={Teleop:1,Observe:3};class Device{constructor(t,r,n){je(this,"rtcClient");je(this,"remoteDevicePeerId");je(this,"realtimeListeners",[]);je(this,"handleMessage",(t,r)=>{this.realtimeListeners.forEach(n=>n(t,r))});this.id=t,this.name=r,this.organizationId=n}async getLatestTelemetry(){return(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}async getConfiguration(){let t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}});const r=await t.json();if(!r.state.reportedConfiguration)throw new Error("Device has no configuration, has it ever been turned on?");const n=r.state.reportedConfiguration.version;return t=await fetch(`${FORMANT_API_URL}/v1/admin/devices/${this.id}/configurations/${n}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),(await t.json()).document}async getFileUrl(t){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileId:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).fileUrls}getRealtimeStatus(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getConnectionStatus(this.remoteDevicePeerId);throw new Error(`Realtime connection hasn't been started for ${this.id}`)}getRealtimePing(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getPing(this.remoteDevicePeerId);throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async startRealtimeConnection(t){if(this.rtcClient)throw new Error(`Already created realtime connection to device ${this.id}`);{const r=new dist.exports.RtcClient({signalingClient:new dist.exports.SignalingPromiseClient(FORMANT_API_URL,null,null),getToken:async()=>defined(Authentication.token,"Realtime when user isn't authorized"),receive:this.handleMessage});for(;!r.isReady();)await delay(100);const o=(await r.getPeers()).find(l=>l.deviceId===this.id);if(!o)throw new Error("Cannot find peer, is the robot offline?");for(this.remoteDevicePeerId=o.id,await r.connect(this.remoteDevicePeerId,t||{sessionType:SessionType.Teleop});r.getConnectionStatus(this.remoteDevicePeerId)!=="connected";)await delay(100);this.rtcClient=r}}addRealtimeListener(t){this.realtimeListeners.push(t)}removeRealtimeListener(t){const r=this.realtimeListeners.indexOf(t);if(r===-1)throw new Error("Could not find realtime listener to remove");this.realtimeListeners.splice(r,1)}async getRealtimeVideoStreams(){var n,o,l;const t=await this.getConfiguration(),r=[];for(const s of(n=t.teleop.hardwareStreams)!=null?n:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});for(const s of(o=t.teleop.rosStreams)!=null?o:[])s.topicType=="formant/H264VideoFrame"&&r.push({name:s.topicName});for(const s of(l=t.teleop.customStreams)!=null?l:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});return r}async getRealtimeManipulators(){var n;const t=await this.getConfiguration(),r=[];for(const o of(n=t.teleop.rosStreams)!=null?n:[])o.topicType=="sensor_msgs/JointState"&&r.push(new Manipulator(this,{currentJointStateStream:{name:o.topicName},plannedJointStateStream:o.plannedTopic?{name:o.plannedTopic}:void 0,planValidStream:o.planValidTopic?{name:o.planValidTopic}:void 0,endEffectorStream:o.endEffectorTopic?{name:o.endEffectorTopic}:void 0,endEffectorLinkName:o.endEffectorLinkName,baseReferenceFrame:o.baseReferenceFrame,localFrame:o.localFrame}));return r}async startListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async startListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async enableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!0,pipeline:"telemetry"})}async disableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!1,pipeline:"telemetry"})}async getRemotePeer(){const r=(await defined(this.rtcClient,"Realtime connection has not been started").getPeers()).find(n=>n.deviceId===this.id);return defined(r,"Could not find remote peer for device "+this.id)}async stopRealtimeConnection(){if(this.rtcClient)await this.rtcClient.disconnect(this.id);else throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async isInRealtimeSession(){let t=await Fleet.getPeers(),r=await Fleet.getRealtimeSessions(),n=t.find(o=>o.deviceId===this.id);return n?r[n.id].length>0:!1}async getAvailableCommands(){return(await(await fetch(`${FORMANT_API_URL}/v1/admin/command-templates/`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(n=>({name:n.name,id:n.id,command:n.command,description:n.description,parameterEnabled:n.parameterEnabled,parameterValue:n.parameterValue,parameterMeta:n.parameterMeta,enabled:n.enabled}))}async sendCommand(t,r,n,o){var u;const s=(await this.getAvailableCommands()).find(b=>b.name===t);if(!s)throw new Error(`Could not find command with name "${t}"`);let i;if(r===void 0)if(s.parameterEnabled&&s.parameterValue)i=s.parameterValue;else throw new Error("Command has no default parameter value, you must provide one");else i=r;let c={value:i,scrubberTime:(n||new Date).toISOString(),meta:st(st({},s.parameterMeta),o)};await fetch(`${FORMANT_API_URL}/v1/admin/commands`,{method:"POST",body:JSON.stringify({commandTemplateId:s.id,organizationId:this.organizationId,deviceId:this.id,command:s.command,parameter:c,userId:(u=Authentication.currentUser)==null?void 0:u.id}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})}async createCustomDataChannel(t,r){const n=defined(this.rtcClient,"Realtime connection has not been started"),o=await this.getRemotePeer(),l=await new Promise(s=>{n.createCustomDataChannel(defined(o).id,t,st({ordered:!0},r),!1,(i,c)=>{const u=new DataChannel(c);s(u)})});return await l.waitTilReady(),l}createCustomRequestDataChannel(t,r=3e3){return new TextRequestDataChannel(this,t,r)}createCustomBinaryRequestDataChannel(t,r=3e3){return new BinaryRequestDataChannel(this,t,r)}async createCaptureStream(t){const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/capture-sessions`,{method:"POST",body:JSON.stringify({deviceId:this.id,streamName:t,tags:{}}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return new CaptureStream(n)}async getTelemetry(t,r,n,o){return await Fleet.getTelemetry(this.id,t,r,n,o)}async getTelemetryStreams(){var i,c;const t=await this.getConfiguration(),r=await fetch(`${FORMANT_API_URL}/v1/queries/metadata/stream-names`,{method:"POST",body:JSON.stringify({deviceIds:[this.id]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),n=[],o=[];return(c=(i=t.telemetry)==null?void 0:i.streams)==null||c.forEach(u=>{u.disabled!==!0&&n.push(u.name),u.onDemand===!0&&o.push(u.name)}),console.log(o),(await r.json()).items.filter(u=>!n.includes(u)).map(u=>({name:u,onDemand:o.includes(u)}))}async createInterventionRequest(t,r,n,o){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"POST",body:JSON.stringify({message:t,interventionType:r,time:new Date().toISOString(),deviceId:this.id,tags:o,data:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}async addInterventionResponse(t,r,n){return await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-responses`,{method:"POST",body:JSON.stringify({interventionId:t,interventionType:r,data:n}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()}}class PeerDevice{constructor(t){je(this,"rtcClient");je(this,"remoteDevicePeerId");je(this,"realtimeListeners",[]);je(this,"id");je(this,"handleMessage",(t,r)=>{this.realtimeListeners.forEach(n=>n(t,r))});this.peerUrl=t}async getLatestTelemetry(){const r=await(await fetch(`${this.peerUrl}/telemetry`)).json();return Object.entries(r).map(([o,l])=>({deviceId:this.id,streamName:o,streamType:"json",currentValue:l,currentValueTime:l.timestamp,tags:{}}))}async getDeviceId(){return(await(await fetch(`${this.peerUrl}/configuration`)).json()).agent_config.id}async getConfiguration(){return(await(await fetch(`${this.peerUrl}/configuration`)).json()).agent_config.document}getRealtimeStatus(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getConnectionStatus(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}getRealtimePing(){if(this.rtcClient&&this.remoteDevicePeerId)return this.rtcClient.getPing(this.remoteDevicePeerId);throw new Error("Realtime connection hasn't been started")}async startRealtimeConnection(t){if(this.rtcClient)throw new Error(`Already created realtime connection to device ${this.id}`);{const r=new dist.exports.RtcClient({lanOnlyMode:!0,receive:this.handleMessage});for(await r.connectLan(this.peerUrl);r.getConnectionStatus(this.peerUrl)!=="connected";)await delay(100);this.rtcClient=r}}addRealtimeListener(t){this.realtimeListeners.push(t)}removeRealtimeListener(t){const r=this.realtimeListeners.indexOf(t);if(r===-1)throw new Error("Could not find realtime listener to remove");this.realtimeListeners.splice(r,1)}async getRealtimeVideoStreams(){var n,o,l;const t=await this.getConfiguration(),r=[];for(const s of(n=t.teleop.hardwareStreams)!=null?n:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});for(const s of(o=t.teleop.rosStreams)!=null?o:[])s.topicType=="formant/H264VideoFrame"&&r.push({name:s.topicName});for(const s of(l=t.teleop.customStreams)!=null?l:[])s.rtcStreamType==="h264-video-frame"&&r.push({name:s.name});return r}async getRealtimeManipulators(){var n;const t=await this.getConfiguration(),r=[];for(const o of(n=t.teleop.rosStreams)!=null?n:[])o.topicType=="sensor_msgs/JointState"&&r.push(new Manipulator(this,{currentJointStateStream:{name:o.topicName},plannedJointStateStream:o.plannedTopic?{name:o.plannedTopic}:void 0,planValidStream:o.planValidTopic?{name:o.planValidTopic}:void 0,endEffectorStream:o.endEffectorTopic?{name:o.endEffectorTopic}:void 0,endEffectorLinkName:o.endEffectorLinkName,baseReferenceFrame:o.baseReferenceFrame,localFrame:o.localFrame}));return r}async startListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeVideo(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async startListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!0,pipeline:"rtc"})}async stopListeningToRealtimeDataStream(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t.name,enable:!1,pipeline:"rtc"})}async enableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!0,pipeline:"telemetry"})}async disableRealtimeTelemetryPriorityIngestion(t){const r=defined(this.rtcClient,"Realtime connection has not been started"),n=await this.getRemotePeer();r.controlRemoteStream(defined(n).id,{streamName:t,enablePriorityUpload:!1,pipeline:"telemetry"})}async getRemotePeer(){return{id:this.peerUrl,organizationId:"",deviceId:this.id,capabilities:[],capabilitySet:{}}}async stopRealtimeConnection(){if(this.rtcClient)await this.rtcClient.disconnect(this.id);else throw new Error(`Realtime connection hasn't been started for ${this.id}`)}async createCustomDataChannel(t,r){const n=defined(this.rtcClient,"Realtime connection has not been started"),o=await this.getRemotePeer(),l=await new Promise(s=>{n.createCustomDataChannel(defined(o).id,t,st({ordered:!0},r),!1,(i,c)=>{const u=new DataChannel(c);s(u)})});return await l.waitTilReady(),l}createCustomRequestDataChannel(t,r=3e3){return new TextRequestDataChannel(this,t,r)}createCustomBinaryRequestDataChannel(t,r=3e3){return new BinaryRequestDataChannel(this,t,r)}}const Me=class{static async setDefaultDevice(t){Me.defaultDeviceId=t}static async getCurrentDevice(){if(!Authentication.token)throw new Error("Not authenticated");if(!Me.defaultDeviceId)throw new Error("No known default device");const o=(await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.find(s=>s.id===Me.defaultDeviceId).name,l=new Device(Me.defaultDeviceId,o,defined(Authentication.currentOrganization));return Me.knownContext.push(new WeakRef(l)),l}static async getPeerDevice(t){const r=new PeerDevice(t);return r.id=await r.getDeviceId(),r}static async getDevice(t){if(!Authentication.token)throw new Error("Not authenticated");const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/devices/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json(),o=n.name,l=new Device(t,o,n.organizationId);return Me.knownContext.push(new WeakRef(l)),l}static async getDevices(){if(!Authentication.token)throw new Error("Not authenticated");const r=await(await fetch(`${FORMANT_API_URL}/v1/admin/device-details/query`,{method:"POST",body:JSON.stringify({enabled:!0,type:"default"}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();return r.items,r.items.map(n=>new Device(n.id,n.name,n.organizationId))}static async getOnlineDevices(){if(!Authentication.token)throw new Error("Not authenticated");const n=(await(await fetch(`${FORMANT_API_URL}/v1/queries/online-devices`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items;return(await Me.getDevices()).filter(l=>n.includes(l.id))}static async getPeers(){if(!Authentication.token)throw new Error("Not authenticated");return await new dist.exports.RtcClient({signalingClient:new dist.exports.SignalingPromiseClient(FORMANT_API_URL,null,null),getToken:async()=>defined(Authentication.token,"Realtime when user isn't authorized"),receive:()=>{}}).getPeers()}static async getRealtimeSessions(){if(!Authentication.token)throw new Error("Not authenticated");return await new dist.exports.RtcClient({signalingClient:new dist.exports.SignalingPromiseClient(FORMANT_API_URL,null,null),getToken:async()=>defined(Authentication.token,"Realtime when user isn't authorized"),receive:()=>{}}).getSessions()}static async getRealtimeDevices(){if(!Authentication.token)throw new Error("Not authenticated");const n=(await(await fetch(`${FORMANT_API_URL}/v1/signaling/peers`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items.map(l=>l.deviceId);return(await Me.getDevices()).filter(l=>n.includes(l.id))}static async getLatestTelemetry(t){let r=t;return t&&!Array.isArray(t)&&(t=[t]),(await(await fetch(`${FORMANT_API_URL}/v1/queries/stream-current-value`,{method:"POST",body:JSON.stringify({deviceIds:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getTelemetry(t,r,n,o,l){let s=t;Array.isArray(t)||(s=[t]);let i=r;return Array.isArray(r)||(i=[r]),(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify({deviceIds:s,end:o.toISOString(),names:i,start:n.toISOString(),tags:l}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getFileUrl(t){const n=await(await fetch(`${FORMANT_API_URL}/v1/admin/files/query`,{method:"POST",body:JSON.stringify({fileIds:[t]}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json();if(n.fileUrls.length===0)throw new Error("File not found");return n.fileUrls[0]}static async queryTelemetry(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/queries/queries`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async queryEvents(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query`,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getEvent(t){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/events/query/id=${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}static async getInterventions(){if(!Authentication.token)throw new Error("Not authenticated");return(await(await fetch(`${FORMANT_API_URL}/v1/admin/intervention-requests`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).json()).items}};let Fleet=Me;je(Fleet,"defaultDeviceId"),je(Fleet,"knownContext",[]);class KeyValue{static async set(t,r){try{const n=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"POST",body:JSON.stringify({organizationId:defined(Authentication.currentUser).organizationId,key:t,value:r}),headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),o=await n.json();if(n.status!==200)throw new Error(o.message)}catch(n){throw n}}static async get(t){try{const r=await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),n=await r.json();if(r.status!==200)throw new Error(n.message);return n.value}catch(r){throw r}}static async list(){try{const t=await fetch(FORMANT_API_URL+"/v1/admin/key-value",{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}}),r=await t.json();if(t.status!==200)throw new Error(r.message);return r.items}catch(t){throw t}}static async delete(t){try{if(!(await fetch(FORMANT_API_URL+`/v1/admin/key-value/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:"Bearer "+Authentication.token}})).ok)throw new Error("Unable to handle request");return}catch(r){throw r}}}const accessLevels=["viewer","operator","administrator"],viewer="viewer",operator="operator",administrator="administrator",aggregateLevels=["year","month","week","day","hour","minute"],annotationTypes=["tag","sheet","user"],eventTypes=["triggered-event","intervention-request","teleop-session-record","port-forwarding-session-record","command-request","command-response","command-delivery","custom","comment","system","annotation"],healthStatuses=["unknown","operational","offline","error"],interventionTypes=["selection","labeling","teleop"],severities=["info","warning","error","critical"],videoMimeTypes=["video/mp4"];let urlParams=new URLSearchParams("");typeof window!="undefined"&&(urlParams=new URLSearchParams(window.location.search));const urlDevice=urlParams.get("device");urlDevice&&Fleet.setDefaultDevice(urlDevice);const urlAuth=urlParams.get("auth");urlAuth&&Authentication.loginWithToken(urlAuth);const moduleName=urlParams.get("module");moduleName&&Authentication.listenForRefresh(),exports.App=App,exports.Authentication=Authentication,exports.BinaryRequestDataChannel=BinaryRequestDataChannel,exports.CaptureStream=CaptureStream,exports.DataChannel=DataChannel,exports.Device=Device,exports.Fleet=Fleet,exports.KeyValue=KeyValue,exports.Manipulator=Manipulator,exports.PeerDevice=PeerDevice,exports.SessionType=SessionType,exports.TextRequestDataChannel=TextRequestDataChannel,exports.accessLevels=accessLevels,exports.administrator=administrator,exports.aggregateLevels=aggregateLevels,exports.annotationTypes=annotationTypes,exports.eventTypes=eventTypes,exports.healthStatuses=healthStatuses,exports.interventionTypes=interventionTypes,exports.operator=operator,exports.severities=severities,exports.videoMimeTypes=videoMimeTypes,exports.viewer=viewer,Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|