@deeptrekker/api-channels 0.8.1-testingconnectionfix.11 → 0.8.1-testingconnectionfix.12
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/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((o=o.apply(e,t||[])).next())}))}var t,n,o=(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}),r=function(e){function t(t,n){var o=this,r=this.constructor.prototype;return(o=e.call(this,t)||this).statusCode=n,o.__proto__=r,o}return o(t,e),t}(Error),i=function(e){function t(t){void 0===t&&(t="A timeout occurred.");var n=this,o=this.constructor.prototype;return(n=e.call(this,t)||this).__proto__=o,n}return o(t,e),t}(Error),s=function(e){function t(t){void 0===t&&(t="An abort occurred.");var n=this,o=this.constructor.prototype;return(n=e.call(this,t)||this).__proto__=o,n}return o(t,e),t}(Error),c=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},a=function(e,t,n){this.statusCode=e,this.statusText=t,this.content=n},l=function(){function e(){}return e.prototype.get=function(e,t){return this.send(c({},t,{method:"GET",url:e}))},e.prototype.post=function(e,t){return this.send(c({},t,{method:"POST",url:e}))},e.prototype.delete=function(e,t){return this.send(c({},t,{method:"DELETE",url:e}))},e.prototype.getCookieString=function(e){return""},e}();!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(n||(n={}));var u=function(){function e(){}return e.prototype.log=function(e,t){},e.instance=new e,e}(),h=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},p=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},d=function(){function e(){}return e.isRequired=function(e,t){if(null==e)throw new Error("The '"+t+"' argument is required.")},e.isIn=function(e,t,n){if(!(e in t))throw new Error("Unknown "+n+" value: "+e+".")},e}(),f=function(){function e(){}return Object.defineProperty(e,"isBrowser",{get:function(){return"object"==typeof window},enumerable:!0,configurable:!0}),Object.defineProperty(e,"isWebWorker",{get:function(){return"object"==typeof self&&"importScripts"in self},enumerable:!0,configurable:!0}),Object.defineProperty(e,"isNode",{get:function(){return!this.isBrowser&&!this.isWebWorker},enumerable:!0,configurable:!0}),e}();function g(e,t){var n="";return m(e)?(n="Binary data of length "+e.byteLength,t&&(n+=". Content: '"+function(e){var t=new Uint8Array(e),n="";return t.forEach((function(e){n+="0x"+(e<16?"0":"")+e.toString(16)+" "})),n.substr(0,n.length-1)}(e)+"'")):"string"==typeof e&&(n="String data of length "+e.length,t&&(n+=". Content: '"+e+"'")),n}function m(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function v(e,t,o,r,i,s,c){return h(this,void 0,void 0,(function(){var a,l,u,h,d;return p(this,(function(p){switch(p.label){case 0:return i?[4,i()]:[3,2];case 1:(u=p.sent())&&((a={}).Authorization="Bearer "+u,l=a),p.label=2;case 2:return e.log(n.Trace,"("+t+" transport) sending data. "+g(s,c)+"."),h=m(s)?"arraybuffer":"text",[4,o.post(r,{content:s,headers:l,responseType:h})];case 3:return d=p.sent(),e.log(n.Trace,"("+t+" transport) request complete. Response status: "+d.statusCode+"."),[2]}}))}))}var y,b=function(){function e(e,t){this.subject=e,this.observer=t}return e.prototype.dispose=function(){var e=this.subject.observers.indexOf(this.observer);e>-1&&this.subject.observers.splice(e,1),0===this.subject.observers.length&&this.subject.cancelCallback&&this.subject.cancelCallback().catch((function(e){}))},e}(),w=function(){function e(e){this.minimumLogLevel=e,this.outputConsole=console}return e.prototype.log=function(e,t){if(e>=this.minimumLogLevel)switch(e){case n.Critical:case n.Error:this.outputConsole.error("["+(new Date).toISOString()+"] "+n[e]+": "+t);break;case n.Warning:this.outputConsole.warn("["+(new Date).toISOString()+"] "+n[e]+": "+t);break;case n.Information:this.outputConsole.info("["+(new Date).toISOString()+"] "+n[e]+": "+t);break;default:this.outputConsole.log("["+(new Date).toISOString()+"] "+n[e]+": "+t)}},e}(),S=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),C=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e};if("undefined"==typeof XMLHttpRequest){var k="function"==typeof __webpack_require__?__non_webpack_require__:require;y=k("request")}var E,I=function(e){function t(t){var n=e.call(this)||this;if(void 0===y)throw new Error("The 'request' module could not be loaded.");return n.logger=t,n.cookieJar=y.jar(),n.request=y.defaults({jar:n.cookieJar}),n}return S(t,e),t.prototype.send=function(e){var t=this;return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new s):new Promise((function(o,c){var l;l=m(e.content)?Buffer.from(e.content):e.content||"";var u=t.request(e.url,{body:l,encoding:"arraybuffer"===e.responseType?null:"utf8",headers:C({"X-Requested-With":"XMLHttpRequest"},e.headers),method:e.method,timeout:e.timeout},(function(s,l,u){if(e.abortSignal&&(e.abortSignal.onabort=null),s)return"ETIMEDOUT"===s.code&&(t.logger.log(n.Warning,"Timeout from HTTP request."),c(new i)),t.logger.log(n.Warning,"Error from HTTP request. "+s),void c(s);l.statusCode>=200&&l.statusCode<300?o(new a(l.statusCode,l.statusMessage||"",u)):c(new r(l.statusMessage||"",l.statusCode||0))}));e.abortSignal&&(e.abortSignal.onabort=function(){u.abort(),c(new s)})}))},t.prototype.getCookieString=function(e){return this.cookieJar.getCookieString(e)},t}(l),T=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),P=function(e){function t(t){var n=e.call(this)||this;return n.logger=t,n}return T(t,e),t.prototype.send=function(e){var t=this;return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new s):e.method?e.url?new Promise((function(o,c){var l=new XMLHttpRequest;l.open(e.method,e.url,!0),l.withCredentials=!0,l.setRequestHeader("X-Requested-With","XMLHttpRequest"),l.setRequestHeader("Content-Type","text/plain;charset=UTF-8");var u=e.headers;u&&Object.keys(u).forEach((function(e){l.setRequestHeader(e,u[e])})),e.responseType&&(l.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=function(){l.abort(),c(new s)}),e.timeout&&(l.timeout=e.timeout),l.onload=function(){e.abortSignal&&(e.abortSignal.onabort=null),l.status>=200&&l.status<300?o(new a(l.status,l.statusText,l.response||l.responseText)):c(new r(l.statusText,l.status))},l.onerror=function(){t.logger.log(n.Warning,"Error from HTTP request. "+l.status+": "+l.statusText+"."),c(new r(l.statusText,l.status))},l.ontimeout=function(){t.logger.log(n.Warning,"Timeout from HTTP request."),c(new i)},l.send(e.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))},t}(l),x=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),D=function(e){function t(t){var n=e.call(this)||this;return"undefined"!=typeof XMLHttpRequest?n.httpClient=new P(t):n.httpClient=new I(t),n}return x(t,e),t.prototype.send=function(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new s):e.method?e.url?this.httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))},t.prototype.getCookieString=function(e){return this.httpClient.getCookieString(e)},t}(l),R=function(){function e(){}return e.write=function(t){return""+t+e.RecordSeparator},e.parse=function(t){if(t[t.length-1]!==e.RecordSeparator)throw new Error("Message is incomplete.");var n=t.split(e.RecordSeparator);return n.pop(),n},e.RecordSeparatorCode=30,e.RecordSeparator=String.fromCharCode(e.RecordSeparatorCode),e}(),_=function(){function e(){}return e.prototype.writeHandshakeRequest=function(e){return R.write(JSON.stringify(e))},e.prototype.parseHandshakeResponse=function(e){var t,n;if(m(e)||"undefined"!=typeof Buffer&&e instanceof Buffer){var o=new Uint8Array(e);if(-1===(i=o.indexOf(R.RecordSeparatorCode)))throw new Error("Message is incomplete.");var r=i+1;t=String.fromCharCode.apply(null,o.slice(0,r)),n=o.byteLength>r?o.slice(r).buffer:null}else{var i,s=e;if(-1===(i=s.indexOf(R.RecordSeparator)))throw new Error("Message is incomplete.");r=i+1;t=s.substring(0,r),n=s.length>r?s.substring(r):null}var c=R.parse(t),a=JSON.parse(c[0]);if(a.type)throw new Error("Expected a handshake response from the server.");return[n,a]},e}();!function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close"}(E||(E={}));var O,j=function(){function e(){this.observers=[]}return e.prototype.next=function(e){for(var t=0,n=this.observers;t<n.length;t++){n[t].next(e)}},e.prototype.error=function(e){for(var t=0,n=this.observers;t<n.length;t++){var o=n[t];o.error&&o.error(e)}},e.prototype.complete=function(){for(var e=0,t=this.observers;e<t.length;e++){var n=t[e];n.complete&&n.complete()}},e.prototype.subscribe=function(e){return this.observers.push(e),new b(this,e)},e}(),M=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},H=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},N=3e4,A=15e3;!function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"}(O||(O={}));var L,W,q=function(){function e(e,t,n,o){var r=this;this.nextKeepAlive=0,d.isRequired(e,"connection"),d.isRequired(t,"logger"),d.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=N,this.keepAliveIntervalInMilliseconds=A,this.logger=t,this.protocol=n,this.connection=e,this.reconnectPolicy=o,this.handshakeProtocol=new _,this.connection.onreceive=function(e){return r.processIncomingData(e)},this.connection.onclose=function(e){return r.connectionClosed(e)},this.callbacks={},this.methods={},this.closedCallbacks=[],this.reconnectingCallbacks=[],this.reconnectedCallbacks=[],this.invocationId=0,this.receivedHandshakeResponse=!1,this.connectionState=O.Disconnected,this.connectionStarted=!1,this.cachedPingMessage=this.protocol.writeMessage({type:E.Ping})}return e.create=function(t,n,o,r){return new e(t,n,o,r)},Object.defineProperty(e.prototype,"state",{get:function(){return this.connectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"connectionId",{get:function(){return this.connection&&this.connection.connectionId||null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baseUrl",{get:function(){return this.connection.baseUrl||""},set:function(e){if(this.connectionState!==O.Disconnected&&this.connectionState!==O.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e},enumerable:!0,configurable:!0}),e.prototype.start=function(){return this.startPromise=this.startWithStateTransitions(),this.startPromise},e.prototype.startWithStateTransitions=function(){return M(this,void 0,void 0,(function(){var e;return H(this,(function(t){switch(t.label){case 0:if(this.connectionState!==O.Disconnected)return[2,Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."))];this.connectionState=O.Connecting,this.logger.log(n.Debug,"Starting HubConnection."),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.startInternal()];case 2:return t.sent(),this.connectionState=O.Connected,this.connectionStarted=!0,this.logger.log(n.Debug,"HubConnection connected successfully."),[3,4];case 3:return e=t.sent(),this.connectionState=O.Disconnected,this.logger.log(n.Debug,"HubConnection failed to start successfully because of error '"+e+"'."),[2,Promise.reject(e)];case 4:return[2]}}))}))},e.prototype.startInternal=function(){return M(this,void 0,void 0,(function(){var e,t,o,r=this;return H(this,(function(i){switch(i.label){case 0:return this.stopDuringStartError=void 0,this.receivedHandshakeResponse=!1,e=new Promise((function(e,t){r.handshakeResolver=e,r.handshakeRejecter=t})),[4,this.connection.start(this.protocol.transferFormat)];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,7]),t={protocol:this.protocol.name,version:this.protocol.version},this.logger.log(n.Debug,"Sending handshake request."),[4,this.sendMessage(this.handshakeProtocol.writeHandshakeRequest(t))];case 3:return i.sent(),this.logger.log(n.Information,"Using HubProtocol '"+this.protocol.name+"'."),this.cleanupTimeout(),this.resetTimeoutPeriod(),this.resetKeepAliveInterval(),[4,e];case 4:if(i.sent(),this.stopDuringStartError)throw this.stopDuringStartError;return[3,7];case 5:return o=i.sent(),this.logger.log(n.Debug,"Hub handshake failed with error '"+o+"' during start(). Stopping HubConnection."),this.cleanupTimeout(),this.cleanupPingTimer(),[4,this.connection.stop(o)];case 6:throw i.sent(),o;case 7:return[2]}}))}))},e.prototype.stop=function(){return M(this,void 0,void 0,(function(){var e;return H(this,(function(t){switch(t.label){case 0:return e=this.startPromise,this.stopPromise=this.stopInternal(),[4,this.stopPromise];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,e];case 3:case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},e.prototype.stopInternal=function(e){return this.connectionState===O.Disconnected?(this.logger.log(n.Debug,"Call to HubConnection.stop("+e+") ignored because it is already in the disconnected state."),Promise.resolve()):this.connectionState===O.Disconnecting?(this.logger.log(n.Debug,"Call to HttpConnection.stop("+e+") ignored because the connection is already in the disconnecting state."),this.stopPromise):(this.connectionState=O.Disconnecting,this.logger.log(n.Debug,"Stopping HubConnection."),this.reconnectDelayHandle?(this.logger.log(n.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.reconnectDelayHandle),this.reconnectDelayHandle=void 0,this.completeClose(),Promise.resolve()):(this.cleanupTimeout(),this.cleanupPingTimer(),this.stopDuringStartError=e||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))},e.prototype.stream=function(e){for(var t=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r,i=this.replaceStreamingParams(n),s=i[0],c=i[1],a=this.createStreamInvocation(e,n,c),l=new j;return l.cancelCallback=function(){var e=t.createCancelInvocation(a.invocationId);return delete t.callbacks[a.invocationId],r.then((function(){return t.sendWithProtocol(e)}))},this.callbacks[a.invocationId]=function(e,t){t?l.error(t):e&&(e.type===E.Completion?e.error?l.error(new Error(e.error)):l.complete():l.next(e.item))},r=this.sendWithProtocol(a).catch((function(e){l.error(e),delete t.callbacks[a.invocationId]})),this.launchStreams(s,r),l},e.prototype.sendMessage=function(e){return this.resetKeepAliveInterval(),this.connection.send(e)},e.prototype.sendWithProtocol=function(e){return this.sendMessage(this.protocol.writeMessage(e))},e.prototype.send=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.replaceStreamingParams(t),r=o[0],i=o[1],s=this.sendWithProtocol(this.createInvocation(e,t,!0,i));return this.launchStreams(r,s),s},e.prototype.invoke=function(e){for(var t=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r=this.replaceStreamingParams(n),i=r[0],s=r[1],c=this.createInvocation(e,n,!1,s);return new Promise((function(e,n){t.callbacks[c.invocationId]=function(t,o){o?n(o):t&&(t.type===E.Completion?t.error?n(new Error(t.error)):e(t.result):n(new Error("Unexpected message type: "+t.type)))};var o=t.sendWithProtocol(c).catch((function(e){n(e),delete t.callbacks[c.invocationId]}));t.launchStreams(i,o)}))},e.prototype.on=function(e,t){e&&t&&(e=e.toLowerCase(),this.methods[e]||(this.methods[e]=[]),-1===this.methods[e].indexOf(t)&&this.methods[e].push(t))},e.prototype.off=function(e,t){if(e){e=e.toLowerCase();var n=this.methods[e];if(n)if(t){var o=n.indexOf(t);-1!==o&&(n.splice(o,1),0===n.length&&delete this.methods[e])}else delete this.methods[e]}},e.prototype.onclose=function(e){e&&this.closedCallbacks.push(e)},e.prototype.onreconnecting=function(e){e&&this.reconnectingCallbacks.push(e)},e.prototype.onreconnected=function(e){e&&this.reconnectedCallbacks.push(e)},e.prototype.processIncomingData=function(e){if(this.cleanupTimeout(),this.receivedHandshakeResponse||(e=this.processHandshakeResponse(e),this.receivedHandshakeResponse=!0),e)for(var t=0,o=this.protocol.parseMessages(e,this.logger);t<o.length;t++){var r=o[t];switch(r.type){case E.Invocation:this.invokeClientMethod(r);break;case E.StreamItem:case E.Completion:var i=this.callbacks[r.invocationId];i&&(r.type===E.Completion&&delete this.callbacks[r.invocationId],i(r));break;case E.Ping:break;case E.Close:this.logger.log(n.Information,"Close message received from server.");var s=r.error?new Error("Server returned an error on close: "+r.error):void 0;!0===r.allowReconnect?this.connection.stop(s):this.stopPromise=this.stopInternal(s);break;default:this.logger.log(n.Warning,"Invalid message type: "+r.type+".")}}this.resetTimeoutPeriod()},e.prototype.processHandshakeResponse=function(e){var t,o,r;try{r=(t=this.handshakeProtocol.parseHandshakeResponse(e))[0],o=t[1]}catch(e){var i="Error parsing handshake response: "+e;this.logger.log(n.Error,i);var s=new Error(i);throw this.handshakeRejecter(s),s}if(o.error){i="Server returned handshake error: "+o.error;this.logger.log(n.Error,i);s=new Error(i);throw this.handshakeRejecter(s),s}return this.logger.log(n.Debug,"Server handshake complete."),this.handshakeResolver(),r},e.prototype.resetKeepAliveInterval=function(){this.connection.features.inherentKeepAlive||(this.nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.cleanupPingTimer())},e.prototype.resetTimeoutPeriod=function(){var e=this;if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.timeoutHandle=setTimeout((function(){return e.serverTimeout()}),this.serverTimeoutInMilliseconds),void 0!==this.pingServerHandle))){var t=this.nextKeepAlive-(new Date).getTime();t<0&&(t=0),this.pingServerHandle=setTimeout((function(){return M(e,void 0,void 0,(function(){return H(this,(function(e){switch(e.label){case 0:if(this.connectionState!==O.Connected)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sendMessage(this.cachedPingMessage)];case 2:return e.sent(),[3,4];case 3:return e.sent(),this.cleanupPingTimer(),[3,4];case 4:return[2]}}))}))}),t)}},e.prototype.serverTimeout=function(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))},e.prototype.invokeClientMethod=function(e){var t=this,o=this.methods[e.target.toLowerCase()];if(o){try{o.forEach((function(n){return n.apply(t,e.arguments)}))}catch(t){this.logger.log(n.Error,"A callback for the method "+e.target.toLowerCase()+" threw error '"+t+"'.")}if(e.invocationId){var r="Server requested a response, which is not supported in this version of the client.";this.logger.log(n.Error,r),this.stopPromise=this.stopInternal(new Error(r))}}else this.logger.log(n.Warning,"No client method with the name '"+e.target+"' found.")},e.prototype.connectionClosed=function(e){this.logger.log(n.Debug,"HubConnection.connectionClosed("+e+") called while in state "+this.connectionState+"."),this.stopDuringStartError=this.stopDuringStartError||e||new Error("The underlying connection was closed before the hub handshake could complete."),this.handshakeResolver&&this.handshakeResolver(),this.cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this.cleanupTimeout(),this.cleanupPingTimer(),this.connectionState===O.Disconnecting?this.completeClose(e):this.connectionState===O.Connected&&this.reconnectPolicy?this.reconnect(e):this.connectionState===O.Connected&&this.completeClose(e)},e.prototype.completeClose=function(e){var t=this;if(this.connectionStarted){this.connectionState=O.Disconnected,this.connectionStarted=!1;try{this.closedCallbacks.forEach((function(n){return n.apply(t,[e])}))}catch(t){this.logger.log(n.Error,"An onclose callback called with error '"+e+"' threw error '"+t+"'.")}}},e.prototype.reconnect=function(e){return M(this,void 0,void 0,(function(){var t,o,r,i,s,c=this;return H(this,(function(a){switch(a.label){case 0:if(t=Date.now(),o=0,r=void 0!==e?e:new Error("Attempting to reconnect due to a unknown error."),null===(i=this.getNextRetryDelay(o++,0,r)))return this.logger.log(n.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),this.completeClose(e),[2];if(this.connectionState=O.Reconnecting,e?this.logger.log(n.Information,"Connection reconnecting because of error '"+e+"'."):this.logger.log(n.Information,"Connection reconnecting."),this.onreconnecting){try{this.reconnectingCallbacks.forEach((function(t){return t.apply(c,[e])}))}catch(t){this.logger.log(n.Error,"An onreconnecting callback called with error '"+e+"' threw error '"+t+"'.")}if(this.connectionState!==O.Reconnecting)return this.logger.log(n.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting."),[2]}a.label=1;case 1:return null===i?[3,7]:(this.logger.log(n.Information,"Reconnect attempt number "+o+" will start in "+i+" ms."),[4,new Promise((function(e){c.reconnectDelayHandle=setTimeout(e,i)}))]);case 2:if(a.sent(),this.reconnectDelayHandle=void 0,this.connectionState!==O.Reconnecting)return this.logger.log(n.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting."),[2];a.label=3;case 3:return a.trys.push([3,5,,6]),[4,this.startInternal()];case 4:if(a.sent(),this.connectionState=O.Connected,this.logger.log(n.Information,"HubConnection reconnected successfully."),this.onreconnected)try{this.reconnectedCallbacks.forEach((function(e){return e.apply(c,[c.connection.connectionId])}))}catch(e){this.logger.log(n.Error,"An onreconnected callback called with connectionId '"+this.connection.connectionId+"; threw error '"+e+"'.")}return[2];case 5:return s=a.sent(),this.logger.log(n.Information,"Reconnect attempt failed because of error '"+s+"'."),this.connectionState!==O.Reconnecting?(this.logger.log(n.Debug,"Connection moved to the '"+this.connectionState+"' from the reconnecting state during reconnect attempt. Done reconnecting."),this.connectionState===O.Disconnecting&&this.completeClose(),[2]):(r=s instanceof Error?s:new Error(s.toString()),i=this.getNextRetryDelay(o++,Date.now()-t,r),[3,6]);case 6:return[3,1];case 7:return this.logger.log(n.Information,"Reconnect retries have been exhausted after "+(Date.now()-t)+" ms and "+o+" failed attempts. Connection disconnecting."),this.completeClose(),[2]}}))}))},e.prototype.getNextRetryDelay=function(e,t,o){try{return this.reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:o})}catch(o){return this.logger.log(n.Error,"IRetryPolicy.nextRetryDelayInMilliseconds("+e+", "+t+") threw error '"+o+"'."),null}},e.prototype.cancelCallbacksWithError=function(e){var t=this.callbacks;this.callbacks={},Object.keys(t).forEach((function(n){(0,t[n])(null,e)}))},e.prototype.cleanupPingTimer=function(){this.pingServerHandle&&(clearTimeout(this.pingServerHandle),this.pingServerHandle=void 0)},e.prototype.cleanupTimeout=function(){this.timeoutHandle&&clearTimeout(this.timeoutHandle)},e.prototype.createInvocation=function(e,t,n,o){if(n)return{arguments:t,streamIds:o,target:e,type:E.Invocation};var r=this.invocationId;return this.invocationId++,{arguments:t,invocationId:r.toString(),streamIds:o,target:e,type:E.Invocation}},e.prototype.launchStreams=function(e,t){var n=this;if(0!==e.length){t||(t=Promise.resolve());var o=function(o){e[o].subscribe({complete:function(){t=t.then((function(){return n.sendWithProtocol(n.createCompletionMessage(o))}))},error:function(e){var r;r=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",t=t.then((function(){return n.sendWithProtocol(n.createCompletionMessage(o,r))}))},next:function(e){t=t.then((function(){return n.sendWithProtocol(n.createStreamItemMessage(o,e))}))}})};for(var r in e)o(r)}},e.prototype.replaceStreamingParams=function(e){for(var t=[],n=[],o=0;o<e.length;o++){var r=e[o];if(this.isObservable(r)){var i=this.invocationId;this.invocationId++,t[i]=r,n.push(i.toString()),e.splice(o,1)}}return[t,n]},e.prototype.isObservable=function(e){return e&&e.subscribe&&"function"==typeof e.subscribe},e.prototype.createStreamInvocation=function(e,t,n){var o=this.invocationId;return this.invocationId++,{arguments:t,invocationId:o.toString(),streamIds:n,target:e,type:E.StreamInvocation}},e.prototype.createCancelInvocation=function(e){return{invocationId:e,type:E.CancelInvocation}},e.prototype.createStreamItemMessage=function(e,t){return{invocationId:e,item:t,type:E.StreamItem}},e.prototype.createCompletionMessage=function(e,t,n){return t?{error:t,invocationId:e,type:E.Completion}:{invocationId:e,result:n,type:E.Completion}},e}(),F=[0,2e3,1e4,3e4,null],U=function(){function e(e){this.retryDelays=void 0!==e?e.concat([null]):F}return e.prototype.nextRetryDelayInMilliseconds=function(e){return this.retryDelays[e.previousRetryCount]},e}();!function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"}(L||(L={})),function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"}(W||(W={}));var B=function(){function e(){this.isAborted=!1,this.onabort=null}return e.prototype.abort=function(){this.isAborted||(this.isAborted=!0,this.onabort&&this.onabort())},Object.defineProperty(e.prototype,"signal",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aborted",{get:function(){return this.isAborted},enumerable:!0,configurable:!0}),e}(),z=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},J=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},$=function(){function e(e,t,n,o){this.httpClient=e,this.accessTokenFactory=t,this.logger=n,this.pollAbort=new B,this.logMessageContent=o,this.running=!1,this.onreceive=null,this.onclose=null}return Object.defineProperty(e.prototype,"pollAborted",{get:function(){return this.pollAbort.aborted},enumerable:!0,configurable:!0}),e.prototype.connect=function(e,t){return z(this,void 0,void 0,(function(){var o,i,s,c;return J(this,(function(a){switch(a.label){case 0:if(d.isRequired(e,"url"),d.isRequired(t,"transferFormat"),d.isIn(t,W,"transferFormat"),this.url=e,this.logger.log(n.Trace,"(LongPolling transport) Connecting."),t===W.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");return o={abortSignal:this.pollAbort.signal,headers:{},timeout:1e5},t===W.Binary&&(o.responseType="arraybuffer"),[4,this.getAccessToken()];case 1:return i=a.sent(),this.updateHeaderToken(o,i),s=e+"&_="+Date.now(),this.logger.log(n.Trace,"(LongPolling transport) polling: "+s+"."),[4,this.httpClient.get(s,o)];case 2:return 200!==(c=a.sent()).statusCode?(this.logger.log(n.Error,"(LongPolling transport) Unexpected response code: "+c.statusCode+"."),this.closeError=new r(c.statusText||"",c.statusCode),this.running=!1):this.running=!0,this.receiving=this.poll(this.url,o),[2]}}))}))},e.prototype.getAccessToken=function(){return z(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:return[2,e.sent()];case 2:return[2,null]}}))}))},e.prototype.updateHeaderToken=function(e,t){e.headers||(e.headers={}),t?e.headers.Authorization="Bearer "+t:e.headers.Authorization&&delete e.headers.Authorization},e.prototype.poll=function(e,t){return z(this,void 0,void 0,(function(){var o,s,c,a;return J(this,(function(l){switch(l.label){case 0:l.trys.push([0,,8,9]),l.label=1;case 1:return this.running?[4,this.getAccessToken()]:[3,7];case 2:o=l.sent(),this.updateHeaderToken(t,o),l.label=3;case 3:return l.trys.push([3,5,,6]),s=e+"&_="+Date.now(),this.logger.log(n.Trace,"(LongPolling transport) polling: "+s+"."),[4,this.httpClient.get(s,t)];case 4:return 204===(c=l.sent()).statusCode?(this.logger.log(n.Information,"(LongPolling transport) Poll terminated by server."),this.running=!1):200!==c.statusCode?(this.logger.log(n.Error,"(LongPolling transport) Unexpected response code: "+c.statusCode+"."),this.closeError=new r(c.statusText||"",c.statusCode),this.running=!1):c.content?(this.logger.log(n.Trace,"(LongPolling transport) data received. "+g(c.content,this.logMessageContent)+"."),this.onreceive&&this.onreceive(c.content)):this.logger.log(n.Trace,"(LongPolling transport) Poll timed out, reissuing."),[3,6];case 5:return a=l.sent(),this.running?a instanceof i?this.logger.log(n.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.closeError=a,this.running=!1):this.logger.log(n.Trace,"(LongPolling transport) Poll errored after shutdown: "+a.message),[3,6];case 6:return[3,1];case 7:return[3,9];case 8:return this.logger.log(n.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.raiseOnClose(),[7];case 9:return[2]}}))}))},e.prototype.send=function(e){return z(this,void 0,void 0,(function(){return J(this,(function(t){return this.running?[2,v(this.logger,"LongPolling",this.httpClient,this.url,this.accessTokenFactory,e,this.logMessageContent)]:[2,Promise.reject(new Error("Cannot send until the transport is connected"))]}))}))},e.prototype.stop=function(){return z(this,void 0,void 0,(function(){var e,t;return J(this,(function(o){switch(o.label){case 0:this.logger.log(n.Trace,"(LongPolling transport) Stopping polling."),this.running=!1,this.pollAbort.abort(),o.label=1;case 1:return o.trys.push([1,,5,6]),[4,this.receiving];case 2:return o.sent(),this.logger.log(n.Trace,"(LongPolling transport) sending DELETE request to "+this.url+"."),e={headers:{}},[4,this.getAccessToken()];case 3:return t=o.sent(),this.updateHeaderToken(e,t),[4,this.httpClient.delete(this.url,e)];case 4:return o.sent(),this.logger.log(n.Trace,"(LongPolling transport) DELETE request sent."),[3,6];case 5:return this.logger.log(n.Trace,"(LongPolling transport) Stop finished."),this.raiseOnClose(),[7];case 6:return[2]}}))}))},e.prototype.raiseOnClose=function(){if(this.onclose){var e="(LongPolling transport) Firing onclose event.";this.closeError&&(e+=" Error: "+this.closeError),this.logger.log(n.Trace,e),this.onclose(this.closeError)}},e}(),G=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},V=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},X=function(){function e(e,t,n,o,r){this.httpClient=e,this.accessTokenFactory=t,this.logger=n,this.logMessageContent=o,this.eventSourceConstructor=r,this.onreceive=null,this.onclose=null}return e.prototype.connect=function(e,t){return G(this,void 0,void 0,(function(){var o,r=this;return V(this,(function(i){switch(i.label){case 0:return d.isRequired(e,"url"),d.isRequired(t,"transferFormat"),d.isIn(t,W,"transferFormat"),this.logger.log(n.Trace,"(SSE transport) Connecting."),this.url=e,this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(o=i.sent())&&(e+=(e.indexOf("?")<0?"?":"&")+"access_token="+encodeURIComponent(o)),i.label=2;case 2:return[2,new Promise((function(o,i){var s=!1;if(t===W.Text){var c;if(f.isBrowser||f.isWebWorker)c=new r.eventSourceConstructor(e,{withCredentials:!0});else{var a=r.httpClient.getCookieString(e);c=new r.eventSourceConstructor(e,{withCredentials:!0,headers:{Cookie:a}})}try{c.onmessage=function(e){if(r.onreceive)try{r.logger.log(n.Trace,"(SSE transport) data received. "+g(e.data,r.logMessageContent)+"."),r.onreceive(e.data)}catch(e){return void r.close(e)}},c.onerror=function(e){var t=new Error(e.data||"Error occurred");s?r.close(t):i(t)},c.onopen=function(){r.logger.log(n.Information,"SSE connected to "+r.url),r.eventSource=c,s=!0,o()}}catch(e){return void i(e)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))]}}))}))},e.prototype.send=function(e){return G(this,void 0,void 0,(function(){return V(this,(function(t){return this.eventSource?[2,v(this.logger,"SSE",this.httpClient,this.url,this.accessTokenFactory,e,this.logMessageContent)]:[2,Promise.reject(new Error("Cannot send until the transport is connected"))]}))}))},e.prototype.stop=function(){return this.close(),Promise.resolve()},e.prototype.close=function(e){this.eventSource&&(this.eventSource.close(),this.eventSource=void 0,this.onclose&&this.onclose(e))},e}(),K=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},Q=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},Z=function(){function e(e,t,n,o,r){this.logger=n,this.accessTokenFactory=t,this.logMessageContent=o,this.webSocketConstructor=r,this.httpClient=e,this.onreceive=null,this.onclose=null}return e.prototype.connect=function(e,t){return K(this,void 0,void 0,(function(){var o,r=this;return Q(this,(function(i){switch(i.label){case 0:return d.isRequired(e,"url"),d.isRequired(t,"transferFormat"),d.isIn(t,W,"transferFormat"),this.logger.log(n.Trace,"(WebSockets transport) Connecting."),this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(o=i.sent())&&(e+=(e.indexOf("?")<0?"?":"&")+"access_token="+encodeURIComponent(o)),i.label=2;case 2:return[2,new Promise((function(o,i){var s;e=e.replace(/^http/,"ws");var c=r.httpClient.getCookieString(e),a=!1;f.isNode&&c&&(s=new r.webSocketConstructor(e,void 0,{headers:{Cookie:""+c}})),s||(s=new r.webSocketConstructor(e)),t===W.Binary&&(s.binaryType="arraybuffer"),s.onopen=function(t){r.logger.log(n.Information,"WebSocket connected to "+e+"."),r.webSocket=s,a=!0,o()},s.onerror=function(e){var t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:new Error("There was an error with the transport."),i(t)},s.onmessage=function(e){r.logger.log(n.Trace,"(WebSockets transport) data received. "+g(e.data,r.logMessageContent)+"."),r.onreceive&&r.onreceive(e.data)},s.onclose=function(e){if(a)r.close(e);else{var t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:new Error("There was an error with the transport."),i(t)}}}))]}}))}))},e.prototype.send=function(e){return this.webSocket&&this.webSocket.readyState===this.webSocketConstructor.OPEN?(this.logger.log(n.Trace,"(WebSockets transport) sending data. "+g(e,this.logMessageContent)+"."),this.webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")},e.prototype.stop=function(){return this.webSocket&&this.close(void 0),Promise.resolve()},e.prototype.close=function(e){this.webSocket&&(this.webSocket.onclose=function(){},this.webSocket.onmessage=function(){},this.webSocket.onerror=function(){},this.webSocket.close(),this.webSocket=void 0),this.logger.log(n.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!e||!1!==e.wasClean&&1e3===e.code?this.onclose():this.onclose(new Error("WebSocket closed with status code: "+e.code+" ("+e.reason+").")))},e}(),Y=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},ee=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},te=null,ne=null;if(f.isNode&&"undefined"!=typeof require){var oe="function"==typeof __webpack_require__?__non_webpack_require__:require;te=oe("ws"),ne=oe("eventsource")}var re=function(){function e(e,t){var o;void 0===t&&(t={}),this.stopPromiseResolver=function(){},this.features={},this.negotiateVersion=1,d.isRequired(e,"url"),this.logger=void 0===(o=t.logger)?new w(n.Information):null===o?u.instance:o.log?o:new w(o),this.baseUrl=this.resolveUrl(e),(t=t||{}).logMessageContent=t.logMessageContent||!1,f.isNode||"undefined"==typeof WebSocket||t.WebSocket?f.isNode&&!t.WebSocket&&te&&(t.WebSocket=te):t.WebSocket=WebSocket,f.isNode||"undefined"==typeof EventSource||t.EventSource?f.isNode&&!t.EventSource&&void 0!==ne&&(t.EventSource=ne):t.EventSource=EventSource,this.httpClient=t.httpClient||new D(this.logger),this.connectionState="Disconnected",this.connectionStarted=!1,this.options=t,this.onreceive=null,this.onclose=null}return e.prototype.start=function(e){return Y(this,void 0,void 0,(function(){var t;return ee(this,(function(o){switch(o.label){case 0:return e=e||W.Binary,d.isIn(e,W,"transferFormat"),this.logger.log(n.Debug,"Starting connection with transfer format '"+W[e]+"'."),"Disconnected"!==this.connectionState?[2,Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."))]:(this.connectionState="Connecting ",this.startInternalPromise=this.startInternal(e),[4,this.startInternalPromise]);case 1:return o.sent(),"Disconnecting"!==this.connectionState?[3,3]:(t="Failed to start the HttpConnection before stop() was called.",this.logger.log(n.Error,t),[4,this.stopPromise]);case 2:return o.sent(),[2,Promise.reject(new Error(t))];case 3:if("Connected"!==this.connectionState)return t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!",this.logger.log(n.Error,t),[2,Promise.reject(new Error(t))];o.label=4;case 4:return this.connectionStarted=!0,[2]}}))}))},e.prototype.send=function(e){return"Connected"!==this.connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.sendQueue||(this.sendQueue=new ie(this.transport)),this.sendQueue.send(e))},e.prototype.stop=function(e){return Y(this,void 0,void 0,(function(){var t=this;return ee(this,(function(o){switch(o.label){case 0:return"Disconnected"===this.connectionState?(this.logger.log(n.Debug,"Call to HttpConnection.stop("+e+") ignored because the connection is already in the disconnected state."),[2,Promise.resolve()]):"Disconnecting"===this.connectionState?(this.logger.log(n.Debug,"Call to HttpConnection.stop("+e+") ignored because the connection is already in the disconnecting state."),[2,this.stopPromise]):(this.connectionState="Disconnecting",this.stopPromise=new Promise((function(e){t.stopPromiseResolver=e})),[4,this.stopInternal(e)]);case 1:return o.sent(),[4,this.stopPromise];case 2:return o.sent(),[2]}}))}))},e.prototype.stopInternal=function(e){return Y(this,void 0,void 0,(function(){var t;return ee(this,(function(o){switch(o.label){case 0:this.stopError=e,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.startInternalPromise];case 2:case 3:return o.sent(),[3,4];case 4:if(!this.transport)return[3,9];o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.transport.stop()];case 6:return o.sent(),[3,8];case 7:return t=o.sent(),this.logger.log(n.Error,"HttpConnection.transport.stop() threw error '"+t+"'."),this.stopConnection(),[3,8];case 8:return this.transport=void 0,[3,10];case 9:this.logger.log(n.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed."),o.label=10;case 10:return[2]}}))}))},e.prototype.startInternal=function(e){return Y(this,void 0,void 0,(function(){var t,o,r,i,s,c;return ee(this,(function(a){switch(a.label){case 0:t=this.baseUrl,this.accessTokenFactory=this.options.accessTokenFactory,a.label=1;case 1:return a.trys.push([1,12,,13]),this.options.skipNegotiation?this.options.transport!==L.WebSockets?[3,3]:(this.transport=this.constructTransport(L.WebSockets),[4,this.startTransport(t,e)]):[3,5];case 2:return a.sent(),[3,4];case 3:throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");case 4:return[3,11];case 5:o=null,r=0,i=function(){var e;return ee(this,(function(n){switch(n.label){case 0:return[4,s.getNegotiationResponse(t)];case 1:if(o=n.sent(),"Disconnecting"===s.connectionState||"Disconnected"===s.connectionState)throw new Error("The connection was stopped during negotiation.");if(o.error)throw new Error(o.error);if(o.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");return o.url&&(t=o.url),o.accessToken&&(e=o.accessToken,s.accessTokenFactory=function(){return e}),r++,[2]}}))},s=this,a.label=6;case 6:return[5,i()];case 7:a.sent(),a.label=8;case 8:if(o.url&&r<100)return[3,6];a.label=9;case 9:if(100===r&&o.url)throw new Error("Negotiate redirection limit exceeded.");return[4,this.createTransport(t,this.options.transport,o,e)];case 10:a.sent(),a.label=11;case 11:return this.transport instanceof $&&(this.features.inherentKeepAlive=!0),"Connecting "===this.connectionState&&(this.logger.log(n.Debug,"The HttpConnection connected successfully."),this.connectionState="Connected"),[3,13];case 12:return c=a.sent(),this.logger.log(n.Error,"Failed to start the connection: "+c),this.connectionState="Disconnected",this.transport=void 0,this.stopPromiseResolver(),[2,Promise.reject(c)];case 13:return[2]}}))}))},e.prototype.getNegotiationResponse=function(e){return Y(this,void 0,void 0,(function(){var t,o,r,i,s,c,a;return ee(this,(function(l){switch(l.label){case 0:return this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(r=l.sent())&&((t={}).Authorization="Bearer "+r,o=t),l.label=2;case 2:i=this.resolveNegotiateUrl(e),this.logger.log(n.Debug,"Sending negotiation request: "+i+"."),l.label=3;case 3:return l.trys.push([3,5,,6]),[4,this.httpClient.post(i,{content:"",headers:o})];case 4:return 200!==(s=l.sent()).statusCode?[2,Promise.reject(new Error("Unexpected status code returned from negotiate "+s.statusCode))]:((!(c=JSON.parse(s.content)).negotiateVersion||c.negotiateVersion<1)&&(c.connectionToken=c.connectionId),[2,c]);case 5:return a=l.sent(),this.logger.log(n.Error,"Failed to complete negotiation with the server: "+a),[2,Promise.reject(a)];case 6:return[2]}}))}))},e.prototype.createConnectUrl=function(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+"id="+t:e},e.prototype.createTransport=function(e,t,o,r){return Y(this,void 0,void 0,(function(){var i,s,c,a,l,u,h,p,d,f,g;return ee(this,(function(m){switch(m.label){case 0:return i=this.createConnectUrl(e,o.connectionToken),this.isITransport(t)?(this.logger.log(n.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,[4,this.startTransport(i,r)]):[3,2];case 1:return m.sent(),this.connectionId=o.connectionId,[2];case 2:s=[],c=o.availableTransports||[],a=o,l=0,u=c,m.label=3;case 3:return l<u.length?(h=u[l],(p=this.resolveTransportOrError(h,t,r))instanceof Error?(s.push(h.transport+" failed: "+p),[3,12]):[3,4]):[3,13];case 4:if(!this.isITransport(p))return[3,12];if(this.transport=p,a)return[3,9];m.label=5;case 5:return m.trys.push([5,7,,8]),[4,this.getNegotiationResponse(e)];case 6:return a=m.sent(),[3,8];case 7:return d=m.sent(),[2,Promise.reject(d)];case 8:i=this.createConnectUrl(e,a.connectionToken),m.label=9;case 9:return m.trys.push([9,11,,12]),[4,this.startTransport(i,r)];case 10:return m.sent(),this.connectionId=a.connectionId,[2];case 11:return f=m.sent(),this.logger.log(n.Error,"Failed to start the transport '"+h.transport+"': "+f),a=void 0,s.push(h.transport+" failed: "+f),"Connecting "!==this.connectionState?(g="Failed to select transport before stop() was called.",this.logger.log(n.Debug,g),[2,Promise.reject(new Error(g))]):[3,12];case 12:return l++,[3,3];case 13:return s.length>0?[2,Promise.reject(new Error("Unable to connect to the server with any of the available transports. "+s.join(" ")))]:[2,Promise.reject(new Error("None of the transports supported by the client are supported by the server."))]}}))}))},e.prototype.constructTransport=function(e){switch(e){case L.WebSockets:if(!this.options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new Z(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.WebSocket);case L.ServerSentEvents:if(!this.options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.EventSource);case L.LongPolling:return new $(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1);default:throw new Error("Unknown transport: "+e+".")}},e.prototype.startTransport=function(e,t){var n=this;return this.transport.onreceive=this.onreceive,this.transport.onclose=function(e){return n.stopConnection(e)},this.transport.connect(e,t)},e.prototype.resolveTransportOrError=function(e,t,o){var r=L[e.transport];if(null==r)return this.logger.log(n.Debug,"Skipping transport '"+e.transport+"' because it is not supported by this client."),new Error("Skipping transport '"+e.transport+"' because it is not supported by this client.");if(!function(e,t){return!e||0!=(t&e)}(t,r))return this.logger.log(n.Debug,"Skipping transport '"+L[r]+"' because it was disabled by the client."),new Error("'"+L[r]+"' is disabled by the client.");if(!(e.transferFormats.map((function(e){return W[e]})).indexOf(o)>=0))return this.logger.log(n.Debug,"Skipping transport '"+L[r]+"' because it does not support the requested transfer format '"+W[o]+"'."),new Error("'"+L[r]+"' does not support "+W[o]+".");if(r===L.WebSockets&&!this.options.WebSocket||r===L.ServerSentEvents&&!this.options.EventSource)return this.logger.log(n.Debug,"Skipping transport '"+L[r]+"' because it is not supported in your environment.'"),new Error("'"+L[r]+"' is not supported in your environment.");this.logger.log(n.Debug,"Selecting transport '"+L[r]+"'.");try{return this.constructTransport(r)}catch(e){return e}},e.prototype.isITransport=function(e){return e&&"object"==typeof e&&"connect"in e},e.prototype.stopConnection=function(e){var t=this;if(this.logger.log(n.Debug,"HttpConnection.stopConnection("+e+") called while in state "+this.connectionState+"."),this.transport=void 0,e=this.stopError||e,this.stopError=void 0,"Disconnected"!==this.connectionState)if("Connecting "!==this.connectionState){if("Disconnecting"===this.connectionState&&this.stopPromiseResolver(),e?this.logger.log(n.Error,"Connection disconnected with error '"+e+"'."):this.logger.log(n.Information,"Connection disconnected."),this.sendQueue&&(this.sendQueue.stop().catch((function(e){t.logger.log(n.Error,"TransportSendQueue.stop() threw error '"+e+"'.")})),this.sendQueue=void 0),this.connectionId=void 0,this.connectionState="Disconnected",this.connectionStarted){this.connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this.logger.log(n.Error,"HttpConnection.onclose("+e+") threw error '"+t+"'.")}}}else this.logger.log(n.Warning,"Call to HttpConnection.stopConnection("+e+") was ignored because the connection hasn't yet left the in the connecting state.");else this.logger.log(n.Debug,"Call to HttpConnection.stopConnection("+e+") was ignored because the connection is already in the disconnected state.")},e.prototype.resolveUrl=function(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!f.isBrowser||!window.document)throw new Error("Cannot resolve '"+e+"'.");var t=window.document.createElement("a");return t.href=e,this.logger.log(n.Information,"Normalizing '"+e+"' to '"+t.href+"'."),t.href},e.prototype.resolveNegotiateUrl=function(e){var t=e.indexOf("?"),n=e.substring(0,-1===t?e.length:t);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",-1===(n+=-1===t?"":e.substring(t)).indexOf("negotiateVersion")&&(n+=-1===t?"?":"&",n+="negotiateVersion="+this.negotiateVersion),n},e}();var ie=function(){function e(e){this.transport=e,this.buffer=[],this.executing=!0,this.sendBufferedData=new se,this.transportResult=new se,this.sendLoopPromise=this.sendLoop()}return e.prototype.send=function(e){return this.bufferData(e),this.transportResult||(this.transportResult=new se),this.transportResult.promise},e.prototype.stop=function(){return this.executing=!1,this.sendBufferedData.resolve(),this.sendLoopPromise},e.prototype.bufferData=function(e){if(this.buffer.length&&typeof this.buffer[0]!=typeof e)throw new Error("Expected data to be of type "+typeof this.buffer+" but was of type "+typeof e);this.buffer.push(e),this.sendBufferedData.resolve()},e.prototype.sendLoop=function(){return Y(this,void 0,void 0,(function(){var t,n,o;return ee(this,(function(r){switch(r.label){case 0:return[4,this.sendBufferedData.promise];case 1:if(r.sent(),!this.executing)return this.transportResult&&this.transportResult.reject("Connection stopped."),[3,6];this.sendBufferedData=new se,t=this.transportResult,this.transportResult=void 0,n="string"==typeof this.buffer[0]?this.buffer.join(""):e.concatBuffers(this.buffer),this.buffer.length=0,r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this.transport.send(n)];case 3:return r.sent(),t.resolve(),[3,5];case 4:return o=r.sent(),t.reject(o),[3,5];case 5:return[3,0];case 6:return[2]}}))}))},e.concatBuffers=function(e){for(var t=e.map((function(e){return e.byteLength})).reduce((function(e,t){return e+t})),n=new Uint8Array(t),o=0,r=0,i=e;r<i.length;r++){var s=i[r];n.set(new Uint8Array(s),o),o+=s.byteLength}return n},e}(),se=function(){function e(){var e=this;this.promise=new Promise((function(t,n){var o;return o=[t,n],e.resolver=o[0],e.rejecter=o[1],o}))}return e.prototype.resolve=function(){this.resolver()},e.prototype.reject=function(e){this.rejecter(e)},e}(),ce="json",ae=function(){function e(){this.name=ce,this.version=1,this.transferFormat=W.Text}return e.prototype.parseMessages=function(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=u.instance);for(var o=[],r=0,i=R.parse(e);r<i.length;r++){var s=i[r],c=JSON.parse(s);if("number"!=typeof c.type)throw new Error("Invalid payload.");switch(c.type){case E.Invocation:this.isInvocationMessage(c);break;case E.StreamItem:this.isStreamItemMessage(c);break;case E.Completion:this.isCompletionMessage(c);break;case E.Ping:case E.Close:break;default:t.log(n.Information,"Unknown message type '"+c.type+"' ignored.");continue}o.push(c)}return o},e.prototype.writeMessage=function(e){return R.write(JSON.stringify(e))},e.prototype.isInvocationMessage=function(e){this.assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this.assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")},e.prototype.isStreamItemMessage=function(e){if(this.assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")},e.prototype.isCompletionMessage=function(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this.assertNotEmptyString(e.error,"Invalid payload for Completion message."),this.assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")},e.prototype.assertNotEmptyString=function(e,t){if("string"!=typeof e||""===e)throw new Error(t)},e}(),le=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ue={trace:n.Trace,debug:n.Debug,info:n.Information,information:n.Information,warn:n.Warning,warning:n.Warning,error:n.Error,critical:n.Critical,none:n.None};var he=function(){function e(){}return e.prototype.configureLogging=function(e){if(d.isRequired(e,"logging"),void 0!==e.log)this.logger=e;else if("string"==typeof e){var t=function(e){var t=ue[e.toLowerCase()];if(void 0!==t)return t;throw new Error("Unknown log level: "+e)}(e);this.logger=new w(t)}else this.logger=new w(e);return this},e.prototype.withUrl=function(e,t){return d.isRequired(e,"url"),this.url=e,this.httpConnectionOptions=le({},this.httpConnectionOptions,"object"==typeof t?t:{transport:t}),this},e.prototype.withHubProtocol=function(e){return d.isRequired(e,"protocol"),this.protocol=e,this},e.prototype.withAutomaticReconnect=function(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new U(e):this.reconnectPolicy=e:this.reconnectPolicy=new U,this},e.prototype.build=function(){var e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");var t=new re(this.url,e);return q.create(t,this.logger||u.instance,this.protocol||new ae,this.reconnectPolicy)},e}();const pe=36e5,de=5001,fe="10.77.100.1",ge=`https://${fe}:5001`,me=6e4,ve=/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|^((http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])+(\:([1-9][0-9]?[0-9]?[0-9]?[0-9]?))?|^((http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?(localhost)+(\:([1-9][0-9]?[0-9]?[0-9]?[0-9]?)))$/,ye="ControlApp",be="apichannels",we=n.None;var Se={},Ce={exports:{}},ke=Ce.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(ke).forEach((function(e){ke[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,o){var r=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:r&&!n[e.name]&&(n[e.name]={});var i=e.push?{}:r?n[e.name]:n;!function(e,n,o,r){if(r&&!o)n[r]=t(e[1]);else for(var i=0;i<o.length;i+=1)null!=e[i+1]&&(n[o[i]]=t(e[i+1]))}(o.match(e.reg),i,e.names,e.name),e.push&&n[e.push].push(i)},o=Ce.exports,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},i=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(r).forEach((function(e){var t=e[0],r=e.slice(2);"m"===t&&(i.push({rtp:[],fmtp:[]}),s=i[i.length-1]);for(var c=0;c<(o[t]||[]).length;c+=1){var a=o[t][c];if(a.reg.test(r))return n(a,s,r)}})),t.media=i,t};var i=function(e,n){var o=n.split(/=(.+)/,2);return 2===o.length?e[o[0]]=t(o[1]):1===o.length&&n.length>1&&(e[o[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(i,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],o=e.split(" ").map(t),r=0;r<o.length;r+=3)n.push({component:o[r],ip:o[r+1],port:o[r+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(i,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,o=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),o=!0),{scid:n,paused:o}}))}))}}(Se);var Ee=Ce.exports,Ie=/%[sdv%]/g,Te=function(e){var t=1,n=arguments,o=n.length;return e.replace(Ie,(function(e){if(t>=o)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},Pe=function(e,t,n){var o=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var i=t.names[r];t.name?o.push(n[t.name][i]):o.push(n[t.names[r]])}else o.push(n[t.name]);return Te.apply(null,o)},xe=["v","o","s","i","u","e","p","c","b","t","r","z","a"],De=["i","c","b","a"],Re=Se,_e=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var n=t.outerOrder||xe,o=t.innerOrder||De,r=[];return n.forEach((function(t){Ee[t].forEach((function(n){n.name in e&&null!=e[n.name]?r.push(Pe(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){r.push(Pe(t,n,e))}))}))})),e.media.forEach((function(e){r.push(Pe("m",Ee.m[0],e)),o.forEach((function(t){Ee[t].forEach((function(n){n.name in e&&null!=e[n.name]?r.push(Pe(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){r.push(Pe(t,n,e))}))}))}))})),r.join("\r\n")+"\r\n"},Oe=Re.parse;function je(e){const t=Oe(e);return t.media=t.media.map((e=>(e.fmtp=e.fmtp.map((e=>({payload:e.payload,config:e.config+";x-google-max-bitrate=8000;x-google-min-bitrate=0;x-google-start-bitrate=3000"}))),e))),_e(t)}const Me={},He=()=>{Object.keys(Me).forEach((e=>{var t;null===(t=Me[e])||void 0===t||t.close(),delete Me[e]}))},Ne=(t,n,o)=>{let r,i;const{clientId:s=ye}=o,{onDataChannel:c,onTrackEvent:a,onSessionList:l,onError:u,onSessionClose:h,onConnectionStateChange:p,onJoinSession:d,onSessionInfo:f}=n,g={},m=e=>{var t;return e===i.connection_id?i.session_id:null===(t=i.clients.find((t=>t.connection_id===e)))||void 0===t?void 0:t.client_id},v=t=>e(void 0,void 0,void 0,(function*(){const e=Me[t];if(e&&g[t]){for(const n of g[t])try{yield e.addIceCandidate(new RTCIceCandidate(n))}catch(e){console.warn("Failed to add pending candidate",e)}delete g[t]}})),y=e=>{!!i||(i=e,d(e)),r||t.state!==O.Connected||(r=setTimeout((()=>{t.invoke("join_session",JSON.stringify({client_id:s,session_id:e.session_id})),clearTimeout(r),r=void 0}),1e3))},b=()=>{if(t.state===O.Connected)try{t.invoke("session_check",JSON.stringify({client_id:s}))}catch(e){console.warn("Failed session_check:",e)}else console.log("SignalR not connected, will retry next tick")};setInterval(b,5e3);const w=(e,n)=>{const o=new RTCPeerConnection({iceTransportPolicy:"all"});return o.onicecandidate=n=>{if(n.candidate&&t.state===O.Connected){const o={target:e,sessionId:(null==i?void 0:i.session_id)||"",candidate:{content:n.candidate.candidate,sdpMid:n.candidate.sdpMid,sdpMlineIndex:n.candidate.sdpMLineIndex}};try{t.invoke("ice_candidate",JSON.stringify(o))}catch(e){console.log(e)}}},o.onconnectionstatechange=e=>{p(e),"failed"!==o.connectionState&&"disconnected"!==o.connectionState||o.close()},o.oniceconnectionstatechange=()=>{var e;console.log(`%cICE State [${n}]: ${o.iceConnectionState}`,"color: yellow; font-weight: bold;"),"failed"!==o.iceConnectionState&&"disconnected"!==o.iceConnectionState||(console.warn("ICE failed, attempting restart"),null===(e=o.restartIce)||void 0===e||e.call(o))},o.onicegatheringstatechange=()=>{console.log(`%cICE Gathering State [${n}]: ${o.iceGatheringState}`,"color: orange; font-weight: bold;")},o.ontrack=e=>a({trackEvent:e,label:n||e.streams[0].id}),o},S=(e,t)=>{var n;const o=m(t);if(!o||Me[o])return;const r=w(t,null===(n=e.clients.find((e=>e.connection_id===t)))||void 0===n?void 0:n.client_id);return C(r,t),Me[o]=r,r},C=(n,o,r=!1)=>e(void 0,void 0,void 0,(function*(){var e,s;console.log("%cWebRTC: Making an Offer: ","color: cyan; font-weight: bold;",n,"Target:",o),yield n.setLocalDescription(yield n.createOffer({iceRestart:r}));const c={target:o,sessionId:(null==i?void 0:i.session_id)||"",caller:null==t?void 0:t.connectionId,sdp:n.localDescription&&{type:null===(e=n.localDescription)||void 0===e?void 0:e.type,sdp:null===(s=n.localDescription)||void 0===s?void 0:s.sdp}};try{(null==t?void 0:t.state)===O.Connected&&(console.log("%c[WebRTC: Sending offer]:","font-weight: bold; color: cyan;",c),null==t||t.invoke("offer",JSON.stringify(c)))}catch(e){console.log(e)}}));setInterval((()=>{Object.keys(Me).forEach((e=>{var t;"closed"==(null===(t=Me[e])||void 0===t?void 0:t.connectionState)&&delete Me[e]}))}),1e4),t.on("session_list",(e=>{console.log("Current session",i),console.log("%cWebRTC: SessionList: ","color: cyan; font-weight: bold;",e),0!==e.length||t.state!==O.Connected?e.filter((e=>{var t;return 0===(null===(t=e.clients)||void 0===t?void 0:t.length)})).length>1?l(e,y):void 0!==i&&i.session_id===e[0].session_id||y(e[0]):setTimeout((()=>{b()}),1e3)})),t.on("ice_candidate",(t=>e(void 0,void 0,void 0,(function*(){console.log("%cWebRTC: Received Remote Ice Candidate: ","color: cyan; font-weight: bold;",JSON.parse(t));const{candidate:e,caller:n}=JSON.parse(t),o=m(n);if(!e||!n||!o)return;const r={candidate:e.content,sdpMid:e.sdpMid,sdpMLineIndex:e.sdpMlineIndex},i=Me[o];if(!i)return g[o]=g[o]||[],void g[o].push(r);try{yield i.addIceCandidate(new RTCIceCandidate(r))}catch(e){console.warn("addIceCandidate failed, buffering",e),g[o]=g[o]||[],g[o].push(r)}})))),t.on("answer",(n=>e(void 0,void 0,void 0,(function*(){const{sdp:e,caller:o}=JSON.parse(n),r=m(o);if(!e||!o||!r)return;const i=Me[r];i&&t.state===O.Connected&&(yield i.setRemoteDescription(e),yield v(r))})))),t.on("offer",(n=>e(void 0,void 0,void 0,(function*(){console.log("%cWebRTC: Received Offer from the Signalling Server: ","color: cyan; font-weight: bold;",JSON.parse(n));const{sdp:e,caller:o}=JSON.parse(n),r=m(o);if(!r)return;if(!Me[r]&&t.state===O.Connected){const e=w(o,r);Me[r]=e,e.ondatachannel=c}const s=Me[r];if(!s)return;e&&(yield s.setRemoteDescription(e)),yield v(r);const a=yield s.createAnswer();yield s.setLocalDescription({type:"answer",sdp:je(a.sdp||"")});const l={target:o,caller:t.connectionId,sessionId:(null==i?void 0:i.session_id)||"",sdp:s.localDescription&&{type:s.localDescription.type,sdp:s.localDescription.sdp}};if(t.state===O.Connected)try{t.invoke("answer",JSON.stringify(l))}catch(e){u(e)}})))),t.on("session_closed",(()=>{h()})),t.on("session_info",(e=>{i=e,f(e,S)}));try{t.state===O.Connected&&t.invoke("session_check",JSON.stringify({client_id:s}))}catch(e){u(e)}};var Ae;let Le,We,qe;!function(e){e[e.Searching=0]="Searching",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Error=3]="Error",e[e.SSL=4]="SSL",e[e.Ready=5]="Ready"}(Ae||(Ae={}));const Fe=()=>{const e=new Date;return"dt_bweb_api_channels_lib "+e.toLocaleTimeString("en-GB",{hour12:!1})+":"+e.getMilliseconds().toString().padStart(3,"0")},Ue=(t,n,o)=>e(void 0,void 0,void 0,(function*(){const{reconnection:e,onConnectionStateChange:r=(()=>{}),onSocketConnected:i=(()=>{}),ip:s,connectionState:c,isElectron:a}=n,{abortConnectionTimeout:l=pe,connectionTimeout:u=me,defaultConnectionString:h=ge,socketLogging:p=we}=o;if(s&&!ve.test(s))return qe=Ae.Error,void r(qe);c===Ae.Searching&&(qe=Ae.Connecting,r(qe));const d=(e=>{let t="";return e?(t=e,e.endsWith("/")&&(t=t.substring(0,t.length-1)),e.includes("http")||e.includes("https")||(t=`https://${t}`)):t=h,t})(s),f=(new he).withUrl(`${d}/sessionHub`).configureLogging(p).withAutomaticReconnect([0,2e3,1e4,3e4]).build();try{!a&&!e&&void 0===Le&&c===Ae.Searching&&((e,t)=>{Le=setTimeout((()=>{qe=Ae.SSL,t(qe)}),e)})(u,r),a&&((e,t)=>{null!=We&&null!=We||(We=setTimeout((()=>{qe=Ae.Error,t(qe),clearTimeout(We),We=void 0}),e))})(u,r),f.onreconnecting((e=>console.log(e))),f.keepAliveIntervalInMilliseconds=5e3,f.serverTimeoutInMilliseconds=12e4,f.onreconnected((e=>{console.log("SignalR reconnected with ID:",e)})),f.onclose((e=>{console.warn("SignalR connection closed",e)})),yield f.start(),qe=Ae.Connected,r(qe),Le&&clearTimeout(Le),We&&clearTimeout(We),Le=void 0,We=void 0,i(f),t(f)}catch(e){return void(qe!=Ae.Error&&setTimeout((()=>Ue(t,Object.assign(Object.assign({},n),{reconnection:!0}),o)),3e3))}})),Be=(e,t,n={})=>Ue((e=>Ne(e,t,n)),e,n);export{be as APPLICATION_NAME,me as CONNECTION_TIMEOUT_IN_MILLISECONDS,ve as CONNECTION_VALIDATION,Ae as ConnectionState,ye as DEFAULT_CLIENT_NAME,we as DEFAULT_LOGGING_LEVEL,pe as ONE_HOUR_IN_MILLISECONDS,fe as SIGNAL_SERVER_CONNECTION_IP,de as SIGNAL_SERVER_CONNECTION_PORT,ge as SIGNAL_SERVER_CONNECTION_STRING,He as closeAllPeerConnections,Ue as connectToServer,Be as establishFullConnection,Fe as getTime,Ne as initializeWebRTC,Me as peerConnections};
|
|
1
|
+
function e(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((o=o.apply(e,t||[])).next())}))}var t,n,o=(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}),r=function(e){function t(t,n){var o=this,r=this.constructor.prototype;return(o=e.call(this,t)||this).statusCode=n,o.__proto__=r,o}return o(t,e),t}(Error),i=function(e){function t(t){void 0===t&&(t="A timeout occurred.");var n=this,o=this.constructor.prototype;return(n=e.call(this,t)||this).__proto__=o,n}return o(t,e),t}(Error),s=function(e){function t(t){void 0===t&&(t="An abort occurred.");var n=this,o=this.constructor.prototype;return(n=e.call(this,t)||this).__proto__=o,n}return o(t,e),t}(Error),c=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},a=function(e,t,n){this.statusCode=e,this.statusText=t,this.content=n},l=function(){function e(){}return e.prototype.get=function(e,t){return this.send(c({},t,{method:"GET",url:e}))},e.prototype.post=function(e,t){return this.send(c({},t,{method:"POST",url:e}))},e.prototype.delete=function(e,t){return this.send(c({},t,{method:"DELETE",url:e}))},e.prototype.getCookieString=function(e){return""},e}();!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(n||(n={}));var u=function(){function e(){}return e.prototype.log=function(e,t){},e.instance=new e,e}(),h=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},p=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},d=function(){function e(){}return e.isRequired=function(e,t){if(null==e)throw new Error("The '"+t+"' argument is required.")},e.isIn=function(e,t,n){if(!(e in t))throw new Error("Unknown "+n+" value: "+e+".")},e}(),f=function(){function e(){}return Object.defineProperty(e,"isBrowser",{get:function(){return"object"==typeof window},enumerable:!0,configurable:!0}),Object.defineProperty(e,"isWebWorker",{get:function(){return"object"==typeof self&&"importScripts"in self},enumerable:!0,configurable:!0}),Object.defineProperty(e,"isNode",{get:function(){return!this.isBrowser&&!this.isWebWorker},enumerable:!0,configurable:!0}),e}();function g(e,t){var n="";return m(e)?(n="Binary data of length "+e.byteLength,t&&(n+=". Content: '"+function(e){var t=new Uint8Array(e),n="";return t.forEach((function(e){n+="0x"+(e<16?"0":"")+e.toString(16)+" "})),n.substr(0,n.length-1)}(e)+"'")):"string"==typeof e&&(n="String data of length "+e.length,t&&(n+=". Content: '"+e+"'")),n}function m(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function v(e,t,o,r,i,s,c){return h(this,void 0,void 0,(function(){var a,l,u,h,d;return p(this,(function(p){switch(p.label){case 0:return i?[4,i()]:[3,2];case 1:(u=p.sent())&&((a={}).Authorization="Bearer "+u,l=a),p.label=2;case 2:return e.log(n.Trace,"("+t+" transport) sending data. "+g(s,c)+"."),h=m(s)?"arraybuffer":"text",[4,o.post(r,{content:s,headers:l,responseType:h})];case 3:return d=p.sent(),e.log(n.Trace,"("+t+" transport) request complete. Response status: "+d.statusCode+"."),[2]}}))}))}var y,b=function(){function e(e,t){this.subject=e,this.observer=t}return e.prototype.dispose=function(){var e=this.subject.observers.indexOf(this.observer);e>-1&&this.subject.observers.splice(e,1),0===this.subject.observers.length&&this.subject.cancelCallback&&this.subject.cancelCallback().catch((function(e){}))},e}(),w=function(){function e(e){this.minimumLogLevel=e,this.outputConsole=console}return e.prototype.log=function(e,t){if(e>=this.minimumLogLevel)switch(e){case n.Critical:case n.Error:this.outputConsole.error("["+(new Date).toISOString()+"] "+n[e]+": "+t);break;case n.Warning:this.outputConsole.warn("["+(new Date).toISOString()+"] "+n[e]+": "+t);break;case n.Information:this.outputConsole.info("["+(new Date).toISOString()+"] "+n[e]+": "+t);break;default:this.outputConsole.log("["+(new Date).toISOString()+"] "+n[e]+": "+t)}},e}(),S=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),C=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e};if("undefined"==typeof XMLHttpRequest){var k="function"==typeof __webpack_require__?__non_webpack_require__:require;y=k("request")}var E,I=function(e){function t(t){var n=e.call(this)||this;if(void 0===y)throw new Error("The 'request' module could not be loaded.");return n.logger=t,n.cookieJar=y.jar(),n.request=y.defaults({jar:n.cookieJar}),n}return S(t,e),t.prototype.send=function(e){var t=this;return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new s):new Promise((function(o,c){var l;l=m(e.content)?Buffer.from(e.content):e.content||"";var u=t.request(e.url,{body:l,encoding:"arraybuffer"===e.responseType?null:"utf8",headers:C({"X-Requested-With":"XMLHttpRequest"},e.headers),method:e.method,timeout:e.timeout},(function(s,l,u){if(e.abortSignal&&(e.abortSignal.onabort=null),s)return"ETIMEDOUT"===s.code&&(t.logger.log(n.Warning,"Timeout from HTTP request."),c(new i)),t.logger.log(n.Warning,"Error from HTTP request. "+s),void c(s);l.statusCode>=200&&l.statusCode<300?o(new a(l.statusCode,l.statusMessage||"",u)):c(new r(l.statusMessage||"",l.statusCode||0))}));e.abortSignal&&(e.abortSignal.onabort=function(){u.abort(),c(new s)})}))},t.prototype.getCookieString=function(e){return this.cookieJar.getCookieString(e)},t}(l),T=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),P=function(e){function t(t){var n=e.call(this)||this;return n.logger=t,n}return T(t,e),t.prototype.send=function(e){var t=this;return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new s):e.method?e.url?new Promise((function(o,c){var l=new XMLHttpRequest;l.open(e.method,e.url,!0),l.withCredentials=!0,l.setRequestHeader("X-Requested-With","XMLHttpRequest"),l.setRequestHeader("Content-Type","text/plain;charset=UTF-8");var u=e.headers;u&&Object.keys(u).forEach((function(e){l.setRequestHeader(e,u[e])})),e.responseType&&(l.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=function(){l.abort(),c(new s)}),e.timeout&&(l.timeout=e.timeout),l.onload=function(){e.abortSignal&&(e.abortSignal.onabort=null),l.status>=200&&l.status<300?o(new a(l.status,l.statusText,l.response||l.responseText)):c(new r(l.statusText,l.status))},l.onerror=function(){t.logger.log(n.Warning,"Error from HTTP request. "+l.status+": "+l.statusText+"."),c(new r(l.statusText,l.status))},l.ontimeout=function(){t.logger.log(n.Warning,"Timeout from HTTP request."),c(new i)},l.send(e.content||"")})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))},t}(l),x=function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),D=function(e){function t(t){var n=e.call(this)||this;return"undefined"!=typeof XMLHttpRequest?n.httpClient=new P(t):n.httpClient=new I(t),n}return x(t,e),t.prototype.send=function(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new s):e.method?e.url?this.httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))},t.prototype.getCookieString=function(e){return this.httpClient.getCookieString(e)},t}(l),R=function(){function e(){}return e.write=function(t){return""+t+e.RecordSeparator},e.parse=function(t){if(t[t.length-1]!==e.RecordSeparator)throw new Error("Message is incomplete.");var n=t.split(e.RecordSeparator);return n.pop(),n},e.RecordSeparatorCode=30,e.RecordSeparator=String.fromCharCode(e.RecordSeparatorCode),e}(),_=function(){function e(){}return e.prototype.writeHandshakeRequest=function(e){return R.write(JSON.stringify(e))},e.prototype.parseHandshakeResponse=function(e){var t,n;if(m(e)||"undefined"!=typeof Buffer&&e instanceof Buffer){var o=new Uint8Array(e);if(-1===(i=o.indexOf(R.RecordSeparatorCode)))throw new Error("Message is incomplete.");var r=i+1;t=String.fromCharCode.apply(null,o.slice(0,r)),n=o.byteLength>r?o.slice(r).buffer:null}else{var i,s=e;if(-1===(i=s.indexOf(R.RecordSeparator)))throw new Error("Message is incomplete.");r=i+1;t=s.substring(0,r),n=s.length>r?s.substring(r):null}var c=R.parse(t),a=JSON.parse(c[0]);if(a.type)throw new Error("Expected a handshake response from the server.");return[n,a]},e}();!function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close"}(E||(E={}));var O,j=function(){function e(){this.observers=[]}return e.prototype.next=function(e){for(var t=0,n=this.observers;t<n.length;t++){n[t].next(e)}},e.prototype.error=function(e){for(var t=0,n=this.observers;t<n.length;t++){var o=n[t];o.error&&o.error(e)}},e.prototype.complete=function(){for(var e=0,t=this.observers;e<t.length;e++){var n=t[e];n.complete&&n.complete()}},e.prototype.subscribe=function(e){return this.observers.push(e),new b(this,e)},e}(),M=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},H=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},N=3e4,A=15e3;!function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"}(O||(O={}));var W,L,q=function(){function e(e,t,n,o){var r=this;this.nextKeepAlive=0,d.isRequired(e,"connection"),d.isRequired(t,"logger"),d.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=N,this.keepAliveIntervalInMilliseconds=A,this.logger=t,this.protocol=n,this.connection=e,this.reconnectPolicy=o,this.handshakeProtocol=new _,this.connection.onreceive=function(e){return r.processIncomingData(e)},this.connection.onclose=function(e){return r.connectionClosed(e)},this.callbacks={},this.methods={},this.closedCallbacks=[],this.reconnectingCallbacks=[],this.reconnectedCallbacks=[],this.invocationId=0,this.receivedHandshakeResponse=!1,this.connectionState=O.Disconnected,this.connectionStarted=!1,this.cachedPingMessage=this.protocol.writeMessage({type:E.Ping})}return e.create=function(t,n,o,r){return new e(t,n,o,r)},Object.defineProperty(e.prototype,"state",{get:function(){return this.connectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"connectionId",{get:function(){return this.connection&&this.connection.connectionId||null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"baseUrl",{get:function(){return this.connection.baseUrl||""},set:function(e){if(this.connectionState!==O.Disconnected&&this.connectionState!==O.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e},enumerable:!0,configurable:!0}),e.prototype.start=function(){return this.startPromise=this.startWithStateTransitions(),this.startPromise},e.prototype.startWithStateTransitions=function(){return M(this,void 0,void 0,(function(){var e;return H(this,(function(t){switch(t.label){case 0:if(this.connectionState!==O.Disconnected)return[2,Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."))];this.connectionState=O.Connecting,this.logger.log(n.Debug,"Starting HubConnection."),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.startInternal()];case 2:return t.sent(),this.connectionState=O.Connected,this.connectionStarted=!0,this.logger.log(n.Debug,"HubConnection connected successfully."),[3,4];case 3:return e=t.sent(),this.connectionState=O.Disconnected,this.logger.log(n.Debug,"HubConnection failed to start successfully because of error '"+e+"'."),[2,Promise.reject(e)];case 4:return[2]}}))}))},e.prototype.startInternal=function(){return M(this,void 0,void 0,(function(){var e,t,o,r=this;return H(this,(function(i){switch(i.label){case 0:return this.stopDuringStartError=void 0,this.receivedHandshakeResponse=!1,e=new Promise((function(e,t){r.handshakeResolver=e,r.handshakeRejecter=t})),[4,this.connection.start(this.protocol.transferFormat)];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,5,,7]),t={protocol:this.protocol.name,version:this.protocol.version},this.logger.log(n.Debug,"Sending handshake request."),[4,this.sendMessage(this.handshakeProtocol.writeHandshakeRequest(t))];case 3:return i.sent(),this.logger.log(n.Information,"Using HubProtocol '"+this.protocol.name+"'."),this.cleanupTimeout(),this.resetTimeoutPeriod(),this.resetKeepAliveInterval(),[4,e];case 4:if(i.sent(),this.stopDuringStartError)throw this.stopDuringStartError;return[3,7];case 5:return o=i.sent(),this.logger.log(n.Debug,"Hub handshake failed with error '"+o+"' during start(). Stopping HubConnection."),this.cleanupTimeout(),this.cleanupPingTimer(),[4,this.connection.stop(o)];case 6:throw i.sent(),o;case 7:return[2]}}))}))},e.prototype.stop=function(){return M(this,void 0,void 0,(function(){var e;return H(this,(function(t){switch(t.label){case 0:return e=this.startPromise,this.stopPromise=this.stopInternal(),[4,this.stopPromise];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,e];case 3:case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},e.prototype.stopInternal=function(e){return this.connectionState===O.Disconnected?(this.logger.log(n.Debug,"Call to HubConnection.stop("+e+") ignored because it is already in the disconnected state."),Promise.resolve()):this.connectionState===O.Disconnecting?(this.logger.log(n.Debug,"Call to HttpConnection.stop("+e+") ignored because the connection is already in the disconnecting state."),this.stopPromise):(this.connectionState=O.Disconnecting,this.logger.log(n.Debug,"Stopping HubConnection."),this.reconnectDelayHandle?(this.logger.log(n.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.reconnectDelayHandle),this.reconnectDelayHandle=void 0,this.completeClose(),Promise.resolve()):(this.cleanupTimeout(),this.cleanupPingTimer(),this.stopDuringStartError=e||new Error("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))},e.prototype.stream=function(e){for(var t=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r,i=this.replaceStreamingParams(n),s=i[0],c=i[1],a=this.createStreamInvocation(e,n,c),l=new j;return l.cancelCallback=function(){var e=t.createCancelInvocation(a.invocationId);return delete t.callbacks[a.invocationId],r.then((function(){return t.sendWithProtocol(e)}))},this.callbacks[a.invocationId]=function(e,t){t?l.error(t):e&&(e.type===E.Completion?e.error?l.error(new Error(e.error)):l.complete():l.next(e.item))},r=this.sendWithProtocol(a).catch((function(e){l.error(e),delete t.callbacks[a.invocationId]})),this.launchStreams(s,r),l},e.prototype.sendMessage=function(e){return this.resetKeepAliveInterval(),this.connection.send(e)},e.prototype.sendWithProtocol=function(e){return this.sendMessage(this.protocol.writeMessage(e))},e.prototype.send=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var o=this.replaceStreamingParams(t),r=o[0],i=o[1],s=this.sendWithProtocol(this.createInvocation(e,t,!0,i));return this.launchStreams(r,s),s},e.prototype.invoke=function(e){for(var t=this,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r=this.replaceStreamingParams(n),i=r[0],s=r[1],c=this.createInvocation(e,n,!1,s);return new Promise((function(e,n){t.callbacks[c.invocationId]=function(t,o){o?n(o):t&&(t.type===E.Completion?t.error?n(new Error(t.error)):e(t.result):n(new Error("Unexpected message type: "+t.type)))};var o=t.sendWithProtocol(c).catch((function(e){n(e),delete t.callbacks[c.invocationId]}));t.launchStreams(i,o)}))},e.prototype.on=function(e,t){e&&t&&(e=e.toLowerCase(),this.methods[e]||(this.methods[e]=[]),-1===this.methods[e].indexOf(t)&&this.methods[e].push(t))},e.prototype.off=function(e,t){if(e){e=e.toLowerCase();var n=this.methods[e];if(n)if(t){var o=n.indexOf(t);-1!==o&&(n.splice(o,1),0===n.length&&delete this.methods[e])}else delete this.methods[e]}},e.prototype.onclose=function(e){e&&this.closedCallbacks.push(e)},e.prototype.onreconnecting=function(e){e&&this.reconnectingCallbacks.push(e)},e.prototype.onreconnected=function(e){e&&this.reconnectedCallbacks.push(e)},e.prototype.processIncomingData=function(e){if(this.cleanupTimeout(),this.receivedHandshakeResponse||(e=this.processHandshakeResponse(e),this.receivedHandshakeResponse=!0),e)for(var t=0,o=this.protocol.parseMessages(e,this.logger);t<o.length;t++){var r=o[t];switch(r.type){case E.Invocation:this.invokeClientMethod(r);break;case E.StreamItem:case E.Completion:var i=this.callbacks[r.invocationId];i&&(r.type===E.Completion&&delete this.callbacks[r.invocationId],i(r));break;case E.Ping:break;case E.Close:this.logger.log(n.Information,"Close message received from server.");var s=r.error?new Error("Server returned an error on close: "+r.error):void 0;!0===r.allowReconnect?this.connection.stop(s):this.stopPromise=this.stopInternal(s);break;default:this.logger.log(n.Warning,"Invalid message type: "+r.type+".")}}this.resetTimeoutPeriod()},e.prototype.processHandshakeResponse=function(e){var t,o,r;try{r=(t=this.handshakeProtocol.parseHandshakeResponse(e))[0],o=t[1]}catch(e){var i="Error parsing handshake response: "+e;this.logger.log(n.Error,i);var s=new Error(i);throw this.handshakeRejecter(s),s}if(o.error){i="Server returned handshake error: "+o.error;this.logger.log(n.Error,i);s=new Error(i);throw this.handshakeRejecter(s),s}return this.logger.log(n.Debug,"Server handshake complete."),this.handshakeResolver(),r},e.prototype.resetKeepAliveInterval=function(){this.connection.features.inherentKeepAlive||(this.nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.cleanupPingTimer())},e.prototype.resetTimeoutPeriod=function(){var e=this;if(!(this.connection.features&&this.connection.features.inherentKeepAlive||(this.timeoutHandle=setTimeout((function(){return e.serverTimeout()}),this.serverTimeoutInMilliseconds),void 0!==this.pingServerHandle))){var t=this.nextKeepAlive-(new Date).getTime();t<0&&(t=0),this.pingServerHandle=setTimeout((function(){return M(e,void 0,void 0,(function(){return H(this,(function(e){switch(e.label){case 0:if(this.connectionState!==O.Connected)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sendMessage(this.cachedPingMessage)];case 2:return e.sent(),[3,4];case 3:return e.sent(),this.cleanupPingTimer(),[3,4];case 4:return[2]}}))}))}),t)}},e.prototype.serverTimeout=function(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))},e.prototype.invokeClientMethod=function(e){var t=this,o=this.methods[e.target.toLowerCase()];if(o){try{o.forEach((function(n){return n.apply(t,e.arguments)}))}catch(t){this.logger.log(n.Error,"A callback for the method "+e.target.toLowerCase()+" threw error '"+t+"'.")}if(e.invocationId){var r="Server requested a response, which is not supported in this version of the client.";this.logger.log(n.Error,r),this.stopPromise=this.stopInternal(new Error(r))}}else this.logger.log(n.Warning,"No client method with the name '"+e.target+"' found.")},e.prototype.connectionClosed=function(e){this.logger.log(n.Debug,"HubConnection.connectionClosed("+e+") called while in state "+this.connectionState+"."),this.stopDuringStartError=this.stopDuringStartError||e||new Error("The underlying connection was closed before the hub handshake could complete."),this.handshakeResolver&&this.handshakeResolver(),this.cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this.cleanupTimeout(),this.cleanupPingTimer(),this.connectionState===O.Disconnecting?this.completeClose(e):this.connectionState===O.Connected&&this.reconnectPolicy?this.reconnect(e):this.connectionState===O.Connected&&this.completeClose(e)},e.prototype.completeClose=function(e){var t=this;if(this.connectionStarted){this.connectionState=O.Disconnected,this.connectionStarted=!1;try{this.closedCallbacks.forEach((function(n){return n.apply(t,[e])}))}catch(t){this.logger.log(n.Error,"An onclose callback called with error '"+e+"' threw error '"+t+"'.")}}},e.prototype.reconnect=function(e){return M(this,void 0,void 0,(function(){var t,o,r,i,s,c=this;return H(this,(function(a){switch(a.label){case 0:if(t=Date.now(),o=0,r=void 0!==e?e:new Error("Attempting to reconnect due to a unknown error."),null===(i=this.getNextRetryDelay(o++,0,r)))return this.logger.log(n.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),this.completeClose(e),[2];if(this.connectionState=O.Reconnecting,e?this.logger.log(n.Information,"Connection reconnecting because of error '"+e+"'."):this.logger.log(n.Information,"Connection reconnecting."),this.onreconnecting){try{this.reconnectingCallbacks.forEach((function(t){return t.apply(c,[e])}))}catch(t){this.logger.log(n.Error,"An onreconnecting callback called with error '"+e+"' threw error '"+t+"'.")}if(this.connectionState!==O.Reconnecting)return this.logger.log(n.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting."),[2]}a.label=1;case 1:return null===i?[3,7]:(this.logger.log(n.Information,"Reconnect attempt number "+o+" will start in "+i+" ms."),[4,new Promise((function(e){c.reconnectDelayHandle=setTimeout(e,i)}))]);case 2:if(a.sent(),this.reconnectDelayHandle=void 0,this.connectionState!==O.Reconnecting)return this.logger.log(n.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting."),[2];a.label=3;case 3:return a.trys.push([3,5,,6]),[4,this.startInternal()];case 4:if(a.sent(),this.connectionState=O.Connected,this.logger.log(n.Information,"HubConnection reconnected successfully."),this.onreconnected)try{this.reconnectedCallbacks.forEach((function(e){return e.apply(c,[c.connection.connectionId])}))}catch(e){this.logger.log(n.Error,"An onreconnected callback called with connectionId '"+this.connection.connectionId+"; threw error '"+e+"'.")}return[2];case 5:return s=a.sent(),this.logger.log(n.Information,"Reconnect attempt failed because of error '"+s+"'."),this.connectionState!==O.Reconnecting?(this.logger.log(n.Debug,"Connection moved to the '"+this.connectionState+"' from the reconnecting state during reconnect attempt. Done reconnecting."),this.connectionState===O.Disconnecting&&this.completeClose(),[2]):(r=s instanceof Error?s:new Error(s.toString()),i=this.getNextRetryDelay(o++,Date.now()-t,r),[3,6]);case 6:return[3,1];case 7:return this.logger.log(n.Information,"Reconnect retries have been exhausted after "+(Date.now()-t)+" ms and "+o+" failed attempts. Connection disconnecting."),this.completeClose(),[2]}}))}))},e.prototype.getNextRetryDelay=function(e,t,o){try{return this.reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:o})}catch(o){return this.logger.log(n.Error,"IRetryPolicy.nextRetryDelayInMilliseconds("+e+", "+t+") threw error '"+o+"'."),null}},e.prototype.cancelCallbacksWithError=function(e){var t=this.callbacks;this.callbacks={},Object.keys(t).forEach((function(n){(0,t[n])(null,e)}))},e.prototype.cleanupPingTimer=function(){this.pingServerHandle&&(clearTimeout(this.pingServerHandle),this.pingServerHandle=void 0)},e.prototype.cleanupTimeout=function(){this.timeoutHandle&&clearTimeout(this.timeoutHandle)},e.prototype.createInvocation=function(e,t,n,o){if(n)return{arguments:t,streamIds:o,target:e,type:E.Invocation};var r=this.invocationId;return this.invocationId++,{arguments:t,invocationId:r.toString(),streamIds:o,target:e,type:E.Invocation}},e.prototype.launchStreams=function(e,t){var n=this;if(0!==e.length){t||(t=Promise.resolve());var o=function(o){e[o].subscribe({complete:function(){t=t.then((function(){return n.sendWithProtocol(n.createCompletionMessage(o))}))},error:function(e){var r;r=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",t=t.then((function(){return n.sendWithProtocol(n.createCompletionMessage(o,r))}))},next:function(e){t=t.then((function(){return n.sendWithProtocol(n.createStreamItemMessage(o,e))}))}})};for(var r in e)o(r)}},e.prototype.replaceStreamingParams=function(e){for(var t=[],n=[],o=0;o<e.length;o++){var r=e[o];if(this.isObservable(r)){var i=this.invocationId;this.invocationId++,t[i]=r,n.push(i.toString()),e.splice(o,1)}}return[t,n]},e.prototype.isObservable=function(e){return e&&e.subscribe&&"function"==typeof e.subscribe},e.prototype.createStreamInvocation=function(e,t,n){var o=this.invocationId;return this.invocationId++,{arguments:t,invocationId:o.toString(),streamIds:n,target:e,type:E.StreamInvocation}},e.prototype.createCancelInvocation=function(e){return{invocationId:e,type:E.CancelInvocation}},e.prototype.createStreamItemMessage=function(e,t){return{invocationId:e,item:t,type:E.StreamItem}},e.prototype.createCompletionMessage=function(e,t,n){return t?{error:t,invocationId:e,type:E.Completion}:{invocationId:e,result:n,type:E.Completion}},e}(),F=[0,2e3,1e4,3e4,null],U=function(){function e(e){this.retryDelays=void 0!==e?e.concat([null]):F}return e.prototype.nextRetryDelayInMilliseconds=function(e){return this.retryDelays[e.previousRetryCount]},e}();!function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"}(W||(W={})),function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"}(L||(L={}));var B=function(){function e(){this.isAborted=!1,this.onabort=null}return e.prototype.abort=function(){this.isAborted||(this.isAborted=!0,this.onabort&&this.onabort())},Object.defineProperty(e.prototype,"signal",{get:function(){return this},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aborted",{get:function(){return this.isAborted},enumerable:!0,configurable:!0}),e}(),z=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},J=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},$=function(){function e(e,t,n,o){this.httpClient=e,this.accessTokenFactory=t,this.logger=n,this.pollAbort=new B,this.logMessageContent=o,this.running=!1,this.onreceive=null,this.onclose=null}return Object.defineProperty(e.prototype,"pollAborted",{get:function(){return this.pollAbort.aborted},enumerable:!0,configurable:!0}),e.prototype.connect=function(e,t){return z(this,void 0,void 0,(function(){var o,i,s,c;return J(this,(function(a){switch(a.label){case 0:if(d.isRequired(e,"url"),d.isRequired(t,"transferFormat"),d.isIn(t,L,"transferFormat"),this.url=e,this.logger.log(n.Trace,"(LongPolling transport) Connecting."),t===L.Binary&&"undefined"!=typeof XMLHttpRequest&&"string"!=typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");return o={abortSignal:this.pollAbort.signal,headers:{},timeout:1e5},t===L.Binary&&(o.responseType="arraybuffer"),[4,this.getAccessToken()];case 1:return i=a.sent(),this.updateHeaderToken(o,i),s=e+"&_="+Date.now(),this.logger.log(n.Trace,"(LongPolling transport) polling: "+s+"."),[4,this.httpClient.get(s,o)];case 2:return 200!==(c=a.sent()).statusCode?(this.logger.log(n.Error,"(LongPolling transport) Unexpected response code: "+c.statusCode+"."),this.closeError=new r(c.statusText||"",c.statusCode),this.running=!1):this.running=!0,this.receiving=this.poll(this.url,o),[2]}}))}))},e.prototype.getAccessToken=function(){return z(this,void 0,void 0,(function(){return J(this,(function(e){switch(e.label){case 0:return this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:return[2,e.sent()];case 2:return[2,null]}}))}))},e.prototype.updateHeaderToken=function(e,t){e.headers||(e.headers={}),t?e.headers.Authorization="Bearer "+t:e.headers.Authorization&&delete e.headers.Authorization},e.prototype.poll=function(e,t){return z(this,void 0,void 0,(function(){var o,s,c,a;return J(this,(function(l){switch(l.label){case 0:l.trys.push([0,,8,9]),l.label=1;case 1:return this.running?[4,this.getAccessToken()]:[3,7];case 2:o=l.sent(),this.updateHeaderToken(t,o),l.label=3;case 3:return l.trys.push([3,5,,6]),s=e+"&_="+Date.now(),this.logger.log(n.Trace,"(LongPolling transport) polling: "+s+"."),[4,this.httpClient.get(s,t)];case 4:return 204===(c=l.sent()).statusCode?(this.logger.log(n.Information,"(LongPolling transport) Poll terminated by server."),this.running=!1):200!==c.statusCode?(this.logger.log(n.Error,"(LongPolling transport) Unexpected response code: "+c.statusCode+"."),this.closeError=new r(c.statusText||"",c.statusCode),this.running=!1):c.content?(this.logger.log(n.Trace,"(LongPolling transport) data received. "+g(c.content,this.logMessageContent)+"."),this.onreceive&&this.onreceive(c.content)):this.logger.log(n.Trace,"(LongPolling transport) Poll timed out, reissuing."),[3,6];case 5:return a=l.sent(),this.running?a instanceof i?this.logger.log(n.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.closeError=a,this.running=!1):this.logger.log(n.Trace,"(LongPolling transport) Poll errored after shutdown: "+a.message),[3,6];case 6:return[3,1];case 7:return[3,9];case 8:return this.logger.log(n.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this.raiseOnClose(),[7];case 9:return[2]}}))}))},e.prototype.send=function(e){return z(this,void 0,void 0,(function(){return J(this,(function(t){return this.running?[2,v(this.logger,"LongPolling",this.httpClient,this.url,this.accessTokenFactory,e,this.logMessageContent)]:[2,Promise.reject(new Error("Cannot send until the transport is connected"))]}))}))},e.prototype.stop=function(){return z(this,void 0,void 0,(function(){var e,t;return J(this,(function(o){switch(o.label){case 0:this.logger.log(n.Trace,"(LongPolling transport) Stopping polling."),this.running=!1,this.pollAbort.abort(),o.label=1;case 1:return o.trys.push([1,,5,6]),[4,this.receiving];case 2:return o.sent(),this.logger.log(n.Trace,"(LongPolling transport) sending DELETE request to "+this.url+"."),e={headers:{}},[4,this.getAccessToken()];case 3:return t=o.sent(),this.updateHeaderToken(e,t),[4,this.httpClient.delete(this.url,e)];case 4:return o.sent(),this.logger.log(n.Trace,"(LongPolling transport) DELETE request sent."),[3,6];case 5:return this.logger.log(n.Trace,"(LongPolling transport) Stop finished."),this.raiseOnClose(),[7];case 6:return[2]}}))}))},e.prototype.raiseOnClose=function(){if(this.onclose){var e="(LongPolling transport) Firing onclose event.";this.closeError&&(e+=" Error: "+this.closeError),this.logger.log(n.Trace,e),this.onclose(this.closeError)}},e}(),G=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},V=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},X=function(){function e(e,t,n,o,r){this.httpClient=e,this.accessTokenFactory=t,this.logger=n,this.logMessageContent=o,this.eventSourceConstructor=r,this.onreceive=null,this.onclose=null}return e.prototype.connect=function(e,t){return G(this,void 0,void 0,(function(){var o,r=this;return V(this,(function(i){switch(i.label){case 0:return d.isRequired(e,"url"),d.isRequired(t,"transferFormat"),d.isIn(t,L,"transferFormat"),this.logger.log(n.Trace,"(SSE transport) Connecting."),this.url=e,this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(o=i.sent())&&(e+=(e.indexOf("?")<0?"?":"&")+"access_token="+encodeURIComponent(o)),i.label=2;case 2:return[2,new Promise((function(o,i){var s=!1;if(t===L.Text){var c;if(f.isBrowser||f.isWebWorker)c=new r.eventSourceConstructor(e,{withCredentials:!0});else{var a=r.httpClient.getCookieString(e);c=new r.eventSourceConstructor(e,{withCredentials:!0,headers:{Cookie:a}})}try{c.onmessage=function(e){if(r.onreceive)try{r.logger.log(n.Trace,"(SSE transport) data received. "+g(e.data,r.logMessageContent)+"."),r.onreceive(e.data)}catch(e){return void r.close(e)}},c.onerror=function(e){var t=new Error(e.data||"Error occurred");s?r.close(t):i(t)},c.onopen=function(){r.logger.log(n.Information,"SSE connected to "+r.url),r.eventSource=c,s=!0,o()}}catch(e){return void i(e)}}else i(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))]}}))}))},e.prototype.send=function(e){return G(this,void 0,void 0,(function(){return V(this,(function(t){return this.eventSource?[2,v(this.logger,"SSE",this.httpClient,this.url,this.accessTokenFactory,e,this.logMessageContent)]:[2,Promise.reject(new Error("Cannot send until the transport is connected"))]}))}))},e.prototype.stop=function(){return this.close(),Promise.resolve()},e.prototype.close=function(e){this.eventSource&&(this.eventSource.close(),this.eventSource=void 0,this.onclose&&this.onclose(e))},e}(),K=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},Q=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},Z=function(){function e(e,t,n,o,r){this.logger=n,this.accessTokenFactory=t,this.logMessageContent=o,this.webSocketConstructor=r,this.httpClient=e,this.onreceive=null,this.onclose=null}return e.prototype.connect=function(e,t){return K(this,void 0,void 0,(function(){var o,r=this;return Q(this,(function(i){switch(i.label){case 0:return d.isRequired(e,"url"),d.isRequired(t,"transferFormat"),d.isIn(t,L,"transferFormat"),this.logger.log(n.Trace,"(WebSockets transport) Connecting."),this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(o=i.sent())&&(e+=(e.indexOf("?")<0?"?":"&")+"access_token="+encodeURIComponent(o)),i.label=2;case 2:return[2,new Promise((function(o,i){var s;e=e.replace(/^http/,"ws");var c=r.httpClient.getCookieString(e),a=!1;f.isNode&&c&&(s=new r.webSocketConstructor(e,void 0,{headers:{Cookie:""+c}})),s||(s=new r.webSocketConstructor(e)),t===L.Binary&&(s.binaryType="arraybuffer"),s.onopen=function(t){r.logger.log(n.Information,"WebSocket connected to "+e+"."),r.webSocket=s,a=!0,o()},s.onerror=function(e){var t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:new Error("There was an error with the transport."),i(t)},s.onmessage=function(e){r.logger.log(n.Trace,"(WebSockets transport) data received. "+g(e.data,r.logMessageContent)+"."),r.onreceive&&r.onreceive(e.data)},s.onclose=function(e){if(a)r.close(e);else{var t=null;t="undefined"!=typeof ErrorEvent&&e instanceof ErrorEvent?e.error:new Error("There was an error with the transport."),i(t)}}}))]}}))}))},e.prototype.send=function(e){return this.webSocket&&this.webSocket.readyState===this.webSocketConstructor.OPEN?(this.logger.log(n.Trace,"(WebSockets transport) sending data. "+g(e,this.logMessageContent)+"."),this.webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")},e.prototype.stop=function(){return this.webSocket&&this.close(void 0),Promise.resolve()},e.prototype.close=function(e){this.webSocket&&(this.webSocket.onclose=function(){},this.webSocket.onmessage=function(){},this.webSocket.onerror=function(){},this.webSocket.close(),this.webSocket=void 0),this.logger.log(n.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!e||!1!==e.wasClean&&1e3===e.code?this.onclose():this.onclose(new Error("WebSocket closed with status code: "+e.code+" ("+e.reason+").")))},e}(),Y=function(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){e.done?r(e.value):new n((function(t){t(e.value)})).then(s,c)}a((o=o.apply(e,t||[])).next())}))},ee=function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},te=null,ne=null;if(f.isNode&&"undefined"!=typeof require){var oe="function"==typeof __webpack_require__?__non_webpack_require__:require;te=oe("ws"),ne=oe("eventsource")}var re=function(){function e(e,t){var o;void 0===t&&(t={}),this.stopPromiseResolver=function(){},this.features={},this.negotiateVersion=1,d.isRequired(e,"url"),this.logger=void 0===(o=t.logger)?new w(n.Information):null===o?u.instance:o.log?o:new w(o),this.baseUrl=this.resolveUrl(e),(t=t||{}).logMessageContent=t.logMessageContent||!1,f.isNode||"undefined"==typeof WebSocket||t.WebSocket?f.isNode&&!t.WebSocket&&te&&(t.WebSocket=te):t.WebSocket=WebSocket,f.isNode||"undefined"==typeof EventSource||t.EventSource?f.isNode&&!t.EventSource&&void 0!==ne&&(t.EventSource=ne):t.EventSource=EventSource,this.httpClient=t.httpClient||new D(this.logger),this.connectionState="Disconnected",this.connectionStarted=!1,this.options=t,this.onreceive=null,this.onclose=null}return e.prototype.start=function(e){return Y(this,void 0,void 0,(function(){var t;return ee(this,(function(o){switch(o.label){case 0:return e=e||L.Binary,d.isIn(e,L,"transferFormat"),this.logger.log(n.Debug,"Starting connection with transfer format '"+L[e]+"'."),"Disconnected"!==this.connectionState?[2,Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."))]:(this.connectionState="Connecting ",this.startInternalPromise=this.startInternal(e),[4,this.startInternalPromise]);case 1:return o.sent(),"Disconnecting"!==this.connectionState?[3,3]:(t="Failed to start the HttpConnection before stop() was called.",this.logger.log(n.Error,t),[4,this.stopPromise]);case 2:return o.sent(),[2,Promise.reject(new Error(t))];case 3:if("Connected"!==this.connectionState)return t="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!",this.logger.log(n.Error,t),[2,Promise.reject(new Error(t))];o.label=4;case 4:return this.connectionStarted=!0,[2]}}))}))},e.prototype.send=function(e){return"Connected"!==this.connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this.sendQueue||(this.sendQueue=new ie(this.transport)),this.sendQueue.send(e))},e.prototype.stop=function(e){return Y(this,void 0,void 0,(function(){var t=this;return ee(this,(function(o){switch(o.label){case 0:return"Disconnected"===this.connectionState?(this.logger.log(n.Debug,"Call to HttpConnection.stop("+e+") ignored because the connection is already in the disconnected state."),[2,Promise.resolve()]):"Disconnecting"===this.connectionState?(this.logger.log(n.Debug,"Call to HttpConnection.stop("+e+") ignored because the connection is already in the disconnecting state."),[2,this.stopPromise]):(this.connectionState="Disconnecting",this.stopPromise=new Promise((function(e){t.stopPromiseResolver=e})),[4,this.stopInternal(e)]);case 1:return o.sent(),[4,this.stopPromise];case 2:return o.sent(),[2]}}))}))},e.prototype.stopInternal=function(e){return Y(this,void 0,void 0,(function(){var t;return ee(this,(function(o){switch(o.label){case 0:this.stopError=e,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.startInternalPromise];case 2:case 3:return o.sent(),[3,4];case 4:if(!this.transport)return[3,9];o.label=5;case 5:return o.trys.push([5,7,,8]),[4,this.transport.stop()];case 6:return o.sent(),[3,8];case 7:return t=o.sent(),this.logger.log(n.Error,"HttpConnection.transport.stop() threw error '"+t+"'."),this.stopConnection(),[3,8];case 8:return this.transport=void 0,[3,10];case 9:this.logger.log(n.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed."),o.label=10;case 10:return[2]}}))}))},e.prototype.startInternal=function(e){return Y(this,void 0,void 0,(function(){var t,o,r,i,s,c;return ee(this,(function(a){switch(a.label){case 0:t=this.baseUrl,this.accessTokenFactory=this.options.accessTokenFactory,a.label=1;case 1:return a.trys.push([1,12,,13]),this.options.skipNegotiation?this.options.transport!==W.WebSockets?[3,3]:(this.transport=this.constructTransport(W.WebSockets),[4,this.startTransport(t,e)]):[3,5];case 2:return a.sent(),[3,4];case 3:throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");case 4:return[3,11];case 5:o=null,r=0,i=function(){var e;return ee(this,(function(n){switch(n.label){case 0:return[4,s.getNegotiationResponse(t)];case 1:if(o=n.sent(),"Disconnecting"===s.connectionState||"Disconnected"===s.connectionState)throw new Error("The connection was stopped during negotiation.");if(o.error)throw new Error(o.error);if(o.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");return o.url&&(t=o.url),o.accessToken&&(e=o.accessToken,s.accessTokenFactory=function(){return e}),r++,[2]}}))},s=this,a.label=6;case 6:return[5,i()];case 7:a.sent(),a.label=8;case 8:if(o.url&&r<100)return[3,6];a.label=9;case 9:if(100===r&&o.url)throw new Error("Negotiate redirection limit exceeded.");return[4,this.createTransport(t,this.options.transport,o,e)];case 10:a.sent(),a.label=11;case 11:return this.transport instanceof $&&(this.features.inherentKeepAlive=!0),"Connecting "===this.connectionState&&(this.logger.log(n.Debug,"The HttpConnection connected successfully."),this.connectionState="Connected"),[3,13];case 12:return c=a.sent(),this.logger.log(n.Error,"Failed to start the connection: "+c),this.connectionState="Disconnected",this.transport=void 0,this.stopPromiseResolver(),[2,Promise.reject(c)];case 13:return[2]}}))}))},e.prototype.getNegotiationResponse=function(e){return Y(this,void 0,void 0,(function(){var t,o,r,i,s,c,a;return ee(this,(function(l){switch(l.label){case 0:return this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(r=l.sent())&&((t={}).Authorization="Bearer "+r,o=t),l.label=2;case 2:i=this.resolveNegotiateUrl(e),this.logger.log(n.Debug,"Sending negotiation request: "+i+"."),l.label=3;case 3:return l.trys.push([3,5,,6]),[4,this.httpClient.post(i,{content:"",headers:o})];case 4:return 200!==(s=l.sent()).statusCode?[2,Promise.reject(new Error("Unexpected status code returned from negotiate "+s.statusCode))]:((!(c=JSON.parse(s.content)).negotiateVersion||c.negotiateVersion<1)&&(c.connectionToken=c.connectionId),[2,c]);case 5:return a=l.sent(),this.logger.log(n.Error,"Failed to complete negotiation with the server: "+a),[2,Promise.reject(a)];case 6:return[2]}}))}))},e.prototype.createConnectUrl=function(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+"id="+t:e},e.prototype.createTransport=function(e,t,o,r){return Y(this,void 0,void 0,(function(){var i,s,c,a,l,u,h,p,d,f,g;return ee(this,(function(m){switch(m.label){case 0:return i=this.createConnectUrl(e,o.connectionToken),this.isITransport(t)?(this.logger.log(n.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,[4,this.startTransport(i,r)]):[3,2];case 1:return m.sent(),this.connectionId=o.connectionId,[2];case 2:s=[],c=o.availableTransports||[],a=o,l=0,u=c,m.label=3;case 3:return l<u.length?(h=u[l],(p=this.resolveTransportOrError(h,t,r))instanceof Error?(s.push(h.transport+" failed: "+p),[3,12]):[3,4]):[3,13];case 4:if(!this.isITransport(p))return[3,12];if(this.transport=p,a)return[3,9];m.label=5;case 5:return m.trys.push([5,7,,8]),[4,this.getNegotiationResponse(e)];case 6:return a=m.sent(),[3,8];case 7:return d=m.sent(),[2,Promise.reject(d)];case 8:i=this.createConnectUrl(e,a.connectionToken),m.label=9;case 9:return m.trys.push([9,11,,12]),[4,this.startTransport(i,r)];case 10:return m.sent(),this.connectionId=a.connectionId,[2];case 11:return f=m.sent(),this.logger.log(n.Error,"Failed to start the transport '"+h.transport+"': "+f),a=void 0,s.push(h.transport+" failed: "+f),"Connecting "!==this.connectionState?(g="Failed to select transport before stop() was called.",this.logger.log(n.Debug,g),[2,Promise.reject(new Error(g))]):[3,12];case 12:return l++,[3,3];case 13:return s.length>0?[2,Promise.reject(new Error("Unable to connect to the server with any of the available transports. "+s.join(" ")))]:[2,Promise.reject(new Error("None of the transports supported by the client are supported by the server."))]}}))}))},e.prototype.constructTransport=function(e){switch(e){case W.WebSockets:if(!this.options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new Z(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.WebSocket);case W.ServerSentEvents:if(!this.options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.EventSource);case W.LongPolling:return new $(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1);default:throw new Error("Unknown transport: "+e+".")}},e.prototype.startTransport=function(e,t){var n=this;return this.transport.onreceive=this.onreceive,this.transport.onclose=function(e){return n.stopConnection(e)},this.transport.connect(e,t)},e.prototype.resolveTransportOrError=function(e,t,o){var r=W[e.transport];if(null==r)return this.logger.log(n.Debug,"Skipping transport '"+e.transport+"' because it is not supported by this client."),new Error("Skipping transport '"+e.transport+"' because it is not supported by this client.");if(!function(e,t){return!e||0!=(t&e)}(t,r))return this.logger.log(n.Debug,"Skipping transport '"+W[r]+"' because it was disabled by the client."),new Error("'"+W[r]+"' is disabled by the client.");if(!(e.transferFormats.map((function(e){return L[e]})).indexOf(o)>=0))return this.logger.log(n.Debug,"Skipping transport '"+W[r]+"' because it does not support the requested transfer format '"+L[o]+"'."),new Error("'"+W[r]+"' does not support "+L[o]+".");if(r===W.WebSockets&&!this.options.WebSocket||r===W.ServerSentEvents&&!this.options.EventSource)return this.logger.log(n.Debug,"Skipping transport '"+W[r]+"' because it is not supported in your environment.'"),new Error("'"+W[r]+"' is not supported in your environment.");this.logger.log(n.Debug,"Selecting transport '"+W[r]+"'.");try{return this.constructTransport(r)}catch(e){return e}},e.prototype.isITransport=function(e){return e&&"object"==typeof e&&"connect"in e},e.prototype.stopConnection=function(e){var t=this;if(this.logger.log(n.Debug,"HttpConnection.stopConnection("+e+") called while in state "+this.connectionState+"."),this.transport=void 0,e=this.stopError||e,this.stopError=void 0,"Disconnected"!==this.connectionState)if("Connecting "!==this.connectionState){if("Disconnecting"===this.connectionState&&this.stopPromiseResolver(),e?this.logger.log(n.Error,"Connection disconnected with error '"+e+"'."):this.logger.log(n.Information,"Connection disconnected."),this.sendQueue&&(this.sendQueue.stop().catch((function(e){t.logger.log(n.Error,"TransportSendQueue.stop() threw error '"+e+"'.")})),this.sendQueue=void 0),this.connectionId=void 0,this.connectionState="Disconnected",this.connectionStarted){this.connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this.logger.log(n.Error,"HttpConnection.onclose("+e+") threw error '"+t+"'.")}}}else this.logger.log(n.Warning,"Call to HttpConnection.stopConnection("+e+") was ignored because the connection hasn't yet left the in the connecting state.");else this.logger.log(n.Debug,"Call to HttpConnection.stopConnection("+e+") was ignored because the connection is already in the disconnected state.")},e.prototype.resolveUrl=function(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!f.isBrowser||!window.document)throw new Error("Cannot resolve '"+e+"'.");var t=window.document.createElement("a");return t.href=e,this.logger.log(n.Information,"Normalizing '"+e+"' to '"+t.href+"'."),t.href},e.prototype.resolveNegotiateUrl=function(e){var t=e.indexOf("?"),n=e.substring(0,-1===t?e.length:t);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",-1===(n+=-1===t?"":e.substring(t)).indexOf("negotiateVersion")&&(n+=-1===t?"?":"&",n+="negotiateVersion="+this.negotiateVersion),n},e}();var ie=function(){function e(e){this.transport=e,this.buffer=[],this.executing=!0,this.sendBufferedData=new se,this.transportResult=new se,this.sendLoopPromise=this.sendLoop()}return e.prototype.send=function(e){return this.bufferData(e),this.transportResult||(this.transportResult=new se),this.transportResult.promise},e.prototype.stop=function(){return this.executing=!1,this.sendBufferedData.resolve(),this.sendLoopPromise},e.prototype.bufferData=function(e){if(this.buffer.length&&typeof this.buffer[0]!=typeof e)throw new Error("Expected data to be of type "+typeof this.buffer+" but was of type "+typeof e);this.buffer.push(e),this.sendBufferedData.resolve()},e.prototype.sendLoop=function(){return Y(this,void 0,void 0,(function(){var t,n,o;return ee(this,(function(r){switch(r.label){case 0:return[4,this.sendBufferedData.promise];case 1:if(r.sent(),!this.executing)return this.transportResult&&this.transportResult.reject("Connection stopped."),[3,6];this.sendBufferedData=new se,t=this.transportResult,this.transportResult=void 0,n="string"==typeof this.buffer[0]?this.buffer.join(""):e.concatBuffers(this.buffer),this.buffer.length=0,r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this.transport.send(n)];case 3:return r.sent(),t.resolve(),[3,5];case 4:return o=r.sent(),t.reject(o),[3,5];case 5:return[3,0];case 6:return[2]}}))}))},e.concatBuffers=function(e){for(var t=e.map((function(e){return e.byteLength})).reduce((function(e,t){return e+t})),n=new Uint8Array(t),o=0,r=0,i=e;r<i.length;r++){var s=i[r];n.set(new Uint8Array(s),o),o+=s.byteLength}return n},e}(),se=function(){function e(){var e=this;this.promise=new Promise((function(t,n){var o;return o=[t,n],e.resolver=o[0],e.rejecter=o[1],o}))}return e.prototype.resolve=function(){this.resolver()},e.prototype.reject=function(e){this.rejecter(e)},e}(),ce="json",ae=function(){function e(){this.name=ce,this.version=1,this.transferFormat=L.Text}return e.prototype.parseMessages=function(e,t){if("string"!=typeof e)throw new Error("Invalid input for JSON hub protocol. Expected a string.");if(!e)return[];null===t&&(t=u.instance);for(var o=[],r=0,i=R.parse(e);r<i.length;r++){var s=i[r],c=JSON.parse(s);if("number"!=typeof c.type)throw new Error("Invalid payload.");switch(c.type){case E.Invocation:this.isInvocationMessage(c);break;case E.StreamItem:this.isStreamItemMessage(c);break;case E.Completion:this.isCompletionMessage(c);break;case E.Ping:case E.Close:break;default:t.log(n.Information,"Unknown message type '"+c.type+"' ignored.");continue}o.push(c)}return o},e.prototype.writeMessage=function(e){return R.write(JSON.stringify(e))},e.prototype.isInvocationMessage=function(e){this.assertNotEmptyString(e.target,"Invalid payload for Invocation message."),void 0!==e.invocationId&&this.assertNotEmptyString(e.invocationId,"Invalid payload for Invocation message.")},e.prototype.isStreamItemMessage=function(e){if(this.assertNotEmptyString(e.invocationId,"Invalid payload for StreamItem message."),void 0===e.item)throw new Error("Invalid payload for StreamItem message.")},e.prototype.isCompletionMessage=function(e){if(e.result&&e.error)throw new Error("Invalid payload for Completion message.");!e.result&&e.error&&this.assertNotEmptyString(e.error,"Invalid payload for Completion message."),this.assertNotEmptyString(e.invocationId,"Invalid payload for Completion message.")},e.prototype.assertNotEmptyString=function(e,t){if("string"!=typeof e||""===e)throw new Error(t)},e}(),le=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},ue={trace:n.Trace,debug:n.Debug,info:n.Information,information:n.Information,warn:n.Warning,warning:n.Warning,error:n.Error,critical:n.Critical,none:n.None};var he=function(){function e(){}return e.prototype.configureLogging=function(e){if(d.isRequired(e,"logging"),void 0!==e.log)this.logger=e;else if("string"==typeof e){var t=function(e){var t=ue[e.toLowerCase()];if(void 0!==t)return t;throw new Error("Unknown log level: "+e)}(e);this.logger=new w(t)}else this.logger=new w(e);return this},e.prototype.withUrl=function(e,t){return d.isRequired(e,"url"),this.url=e,this.httpConnectionOptions=le({},this.httpConnectionOptions,"object"==typeof t?t:{transport:t}),this},e.prototype.withHubProtocol=function(e){return d.isRequired(e,"protocol"),this.protocol=e,this},e.prototype.withAutomaticReconnect=function(e){if(this.reconnectPolicy)throw new Error("A reconnectPolicy has already been set.");return e?Array.isArray(e)?this.reconnectPolicy=new U(e):this.reconnectPolicy=e:this.reconnectPolicy=new U,this},e.prototype.build=function(){var e=this.httpConnectionOptions||{};if(void 0===e.logger&&(e.logger=this.logger),!this.url)throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");var t=new re(this.url,e);return q.create(t,this.logger||u.instance,this.protocol||new ae,this.reconnectPolicy)},e}();const pe=36e5,de=5001,fe="10.77.100.1",ge=`https://${fe}:5001`,me=6e4,ve=/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|^((http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])+(\:([1-9][0-9]?[0-9]?[0-9]?[0-9]?))?|^((http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?(localhost)+(\:([1-9][0-9]?[0-9]?[0-9]?[0-9]?)))$/,ye="ControlApp",be="apichannels",we=n.None;var Se={},Ce={exports:{}},ke=Ce.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(ke).forEach((function(e){ke[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,o){var r=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:r&&!n[e.name]&&(n[e.name]={});var i=e.push?{}:r?n[e.name]:n;!function(e,n,o,r){if(r&&!o)n[r]=t(e[1]);else for(var i=0;i<o.length;i+=1)null!=e[i+1]&&(n[o[i]]=t(e[i+1]))}(o.match(e.reg),i,e.names,e.name),e.push&&n[e.push].push(i)},o=Ce.exports,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},i=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(r).forEach((function(e){var t=e[0],r=e.slice(2);"m"===t&&(i.push({rtp:[],fmtp:[]}),s=i[i.length-1]);for(var c=0;c<(o[t]||[]).length;c+=1){var a=o[t][c];if(a.reg.test(r))return n(a,s,r)}})),t.media=i,t};var i=function(e,n){var o=n.split(/=(.+)/,2);return 2===o.length?e[o[0]]=t(o[1]):1===o.length&&n.length>1&&(e[o[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(i,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],o=e.split(" ").map(t),r=0;r<o.length;r+=3)n.push({component:o[r],ip:o[r+1],port:o[r+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(i,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,o=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),o=!0),{scid:n,paused:o}}))}))}}(Se);var Ee=Ce.exports,Ie=/%[sdv%]/g,Te=function(e){var t=1,n=arguments,o=n.length;return e.replace(Ie,(function(e){if(t>=o)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},Pe=function(e,t,n){var o=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var i=t.names[r];t.name?o.push(n[t.name][i]):o.push(n[t.names[r]])}else o.push(n[t.name]);return Te.apply(null,o)},xe=["v","o","s","i","u","e","p","c","b","t","r","z","a"],De=["i","c","b","a"],Re=Se,_e=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var n=t.outerOrder||xe,o=t.innerOrder||De,r=[];return n.forEach((function(t){Ee[t].forEach((function(n){n.name in e&&null!=e[n.name]?r.push(Pe(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){r.push(Pe(t,n,e))}))}))})),e.media.forEach((function(e){r.push(Pe("m",Ee.m[0],e)),o.forEach((function(t){Ee[t].forEach((function(n){n.name in e&&null!=e[n.name]?r.push(Pe(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){r.push(Pe(t,n,e))}))}))}))})),r.join("\r\n")+"\r\n"},Oe=Re.parse;function je(e){const t=Oe(e);return t.media=t.media.map((e=>(e.fmtp=e.fmtp.map((e=>({payload:e.payload,config:e.config+";x-google-max-bitrate=8000;x-google-min-bitrate=0;x-google-start-bitrate=3000"}))),e))),_e(t)}const Me={},He=()=>{Object.keys(Me).forEach((e=>{var t;null===(t=Me[e])||void 0===t||t.close(),delete Me[e]}))},Ne=(t,n,o)=>{let r,i;const{clientId:s=ye}=o,{onDataChannel:c,onTrackEvent:a,onSessionList:l,onError:u,onSessionClose:h,onConnectionStateChange:p,onJoinSession:d,onSessionInfo:f}=n,g={},m=e=>{var t;return e===i.connection_id?i.session_id:null===(t=i.clients.find((t=>t.connection_id===e)))||void 0===t?void 0:t.client_id},v=t=>e(void 0,void 0,void 0,(function*(){const e=Me[t];if(e&&g[t]){for(const n of g[t])try{yield e.addIceCandidate(new RTCIceCandidate(n))}catch(e){console.warn("Failed to add pending candidate",e)}delete g[t]}})),y=e=>{!!i||(i=e,d(e)),r||t.state!==O.Connected||(r=setTimeout((()=>{t.invoke("join_session",JSON.stringify({client_id:s,session_id:e.session_id})),clearTimeout(r),r=void 0}),1e3))},b=()=>{if(t.state===O.Connected)try{t.invoke("session_check",JSON.stringify({client_id:s}))}catch(e){console.warn("Failed session_check:",e)}else console.log("SignalR not connected, will retry next tick")};setInterval(b,5e3);const w=(e,n)=>{const o=new RTCPeerConnection({iceTransportPolicy:"all"});return o.onicecandidate=n=>{if(n.candidate&&t.state===O.Connected){const o={target:e,sessionId:(null==i?void 0:i.session_id)||"",candidate:{content:n.candidate.candidate,sdpMid:n.candidate.sdpMid,sdpMlineIndex:n.candidate.sdpMLineIndex}};try{t.invoke("ice_candidate",JSON.stringify(o))}catch(e){console.log(e)}}},o.onconnectionstatechange=e=>{p(e),"failed"!==o.connectionState&&"disconnected"!==o.connectionState||o.close()},o.oniceconnectionstatechange=()=>{var e;console.log(`%cICE State [${n}]: ${o.iceConnectionState}`,"color: yellow; font-weight: bold;"),"failed"!==o.iceConnectionState&&"disconnected"!==o.iceConnectionState||(console.warn("ICE failed, attempting restart"),null===(e=o.restartIce)||void 0===e||e.call(o))},o.onicegatheringstatechange=()=>{console.log(`%cICE Gathering State [${n}]: ${o.iceGatheringState}`,"color: orange; font-weight: bold;")},o.ontrack=e=>a({trackEvent:e,label:n||e.streams[0].id}),o},S=(e,t)=>{var n;const o=m(t);if(!o||Me[o])return;const r=w(t,null===(n=e.clients.find((e=>e.connection_id===t)))||void 0===n?void 0:n.client_id);return C(r,t),Me[o]=r,r},C=(n,o,r=!1)=>e(void 0,void 0,void 0,(function*(){var e,s;console.log("%cWebRTC: Making an Offer: ","color: cyan; font-weight: bold;",n,"Target:",o),yield n.setLocalDescription(yield n.createOffer({iceRestart:r}));const c={target:o,sessionId:(null==i?void 0:i.session_id)||"",caller:null==t?void 0:t.connectionId,sdp:n.localDescription&&{type:null===(e=n.localDescription)||void 0===e?void 0:e.type,sdp:null===(s=n.localDescription)||void 0===s?void 0:s.sdp}};try{(null==t?void 0:t.state)===O.Connected&&(console.log("%c[WebRTC: Sending offer]:","font-weight: bold; color: cyan;",c),null==t||t.invoke("offer",JSON.stringify(c)))}catch(e){console.log(e)}}));setInterval((()=>{Object.keys(Me).forEach((e=>{var t;"closed"==(null===(t=Me[e])||void 0===t?void 0:t.connectionState)&&delete Me[e]}))}),1e4),t.on("session_list",(e=>{console.log("Current session",i),console.log("%cWebRTC: SessionList: ","color: cyan; font-weight: bold;",e),0!==e.length||t.state!==O.Connected?e.filter((e=>{var t;return 0===(null===(t=e.clients)||void 0===t?void 0:t.length)})).length>1?l(e,y):void 0!==i&&i.session_id===e[0].session_id||y(e[0]):setTimeout((()=>{b()}),1e3)})),t.on("ice_candidate",(t=>e(void 0,void 0,void 0,(function*(){console.log("%cWebRTC: Received Remote Ice Candidate: ","color: cyan; font-weight: bold;",JSON.parse(t));const{candidate:e,caller:n}=JSON.parse(t),o=m(n);if(!e||!n||!o)return;const r={candidate:e.content,sdpMid:e.sdpMid,sdpMLineIndex:e.sdpMlineIndex},i=Me[o];if(!i)return g[o]=g[o]||[],void g[o].push(r);try{yield i.addIceCandidate(new RTCIceCandidate(r))}catch(e){console.warn("addIceCandidate failed, buffering",e),g[o]=g[o]||[],g[o].push(r)}})))),t.on("answer",(n=>e(void 0,void 0,void 0,(function*(){const{sdp:e,caller:o}=JSON.parse(n),r=m(o);if(!e||!o||!r)return;const i=Me[r];i&&t.state===O.Connected&&(yield i.setRemoteDescription(e),yield v(r))})))),t.on("offer",(n=>e(void 0,void 0,void 0,(function*(){console.log("%cWebRTC: Received Offer from the Signalling Server: ","color: cyan; font-weight: bold;",JSON.parse(n));const{sdp:e,caller:o}=JSON.parse(n),r=m(o);if(!r)return;if(!Me[r]&&t.state===O.Connected){const e=w(o,r);Me[r]=e,e.ondatachannel=c}const s=Me[r];if(!s)return;e&&(yield s.setRemoteDescription(e)),yield v(r);const a=yield s.createAnswer();yield s.setLocalDescription({type:"answer",sdp:je(a.sdp||"")});const l={target:o,caller:t.connectionId,sessionId:(null==i?void 0:i.session_id)||"",sdp:s.localDescription&&{type:s.localDescription.type,sdp:s.localDescription.sdp}};if(t.state===O.Connected)try{t.invoke("answer",JSON.stringify(l))}catch(e){u(e)}})))),t.on("session_closed",(()=>{h()})),t.on("session_info",(e=>{i=e,f(e,S)}));try{t.state===O.Connected&&t.invoke("session_check",JSON.stringify({client_id:s}))}catch(e){u(e)}};var Ae;let We,Le,qe;!function(e){e[e.Searching=0]="Searching",e[e.Connecting=1]="Connecting",e[e.Connected=2]="Connected",e[e.Error=3]="Error",e[e.SSL=4]="SSL",e[e.Ready=5]="Ready"}(Ae||(Ae={}));const Fe=()=>{const e=new Date;return"dt_bweb_api_channels_lib "+e.toLocaleTimeString("en-GB",{hour12:!1})+":"+e.getMilliseconds().toString().padStart(3,"0")},Ue=(t,n,o)=>e(void 0,void 0,void 0,(function*(){const{reconnection:e,onConnectionStateChange:r=(()=>{}),onSocketConnected:i=(()=>{}),ip:s,connectionState:c,isElectron:a}=n,{abortConnectionTimeout:l=pe,connectionTimeout:u=me,defaultConnectionString:h=ge,socketLogging:p=we}=o;if(s&&!ve.test(s))return qe=Ae.Error,void r(qe);c===Ae.Searching&&(qe=Ae.Connecting,r(qe));const d=(e=>{let t="";return e?(t=e,e.endsWith("/")&&(t=t.substring(0,t.length-1)),e.includes("http")||e.includes("https")||(t=`https://${t}`)):t=h,t})(s),f=(new he).withUrl(`${d}/sessionHub`,{transport:W.WebSockets}).configureLogging(p).withAutomaticReconnect([0,2e3,1e4,3e4]).build();try{!a&&!e&&void 0===We&&c===Ae.Searching&&((e,t)=>{We=setTimeout((()=>{qe=Ae.SSL,t(qe)}),e)})(u,r),a&&((e,t)=>{null!=Le&&null!=Le||(Le=setTimeout((()=>{qe=Ae.Error,t(qe),clearTimeout(Le),Le=void 0}),e))})(u,r),f.onreconnecting((e=>console.log(e))),f.keepAliveIntervalInMilliseconds=5e3,f.serverTimeoutInMilliseconds=12e4,f.onreconnected((e=>{console.log("SignalR reconnected with ID:",e)})),f.onclose((e=>{console.warn("SignalR connection closed",e)})),yield f.start(),qe=Ae.Connected,r(qe),We&&clearTimeout(We),Le&&clearTimeout(Le),We=void 0,Le=void 0,i(f),t(f)}catch(e){return void(qe!=Ae.Error&&setTimeout((()=>Ue(t,Object.assign(Object.assign({},n),{reconnection:!0}),o)),3e3))}})),Be=(e,t,n={})=>Ue((e=>Ne(e,t,n)),e,n);export{be as APPLICATION_NAME,me as CONNECTION_TIMEOUT_IN_MILLISECONDS,ve as CONNECTION_VALIDATION,Ae as ConnectionState,ye as DEFAULT_CLIENT_NAME,we as DEFAULT_LOGGING_LEVEL,pe as ONE_HOUR_IN_MILLISECONDS,fe as SIGNAL_SERVER_CONNECTION_IP,de as SIGNAL_SERVER_CONNECTION_PORT,ge as SIGNAL_SERVER_CONNECTION_STRING,He as closeAllPeerConnections,Ue as connectToServer,Be as establishFullConnection,Fe as getTime,Ne as initializeWebRTC,Me as peerConnections};
|