(function(n,t){typeof exports=="object"&&typeof module=="object"?module.exports=t():typeof define=="function"&&define.amd?define([],t):typeof exports=="object"?exports.signalR=t():n.signalR=t()})(window,function(){return function(n){function t(r){if(i[r])return i[r].exports;var u=i[r]={i:r,l:!1,exports:{}};return n[r].call(u.exports,u,u.exports,t),u.l=!0,u.exports}var i={};return t.m=n,t.c=i,t.d=function(n,i,r){t.o(n,i)||Object.defineProperty(n,i,{enumerable:!0,get:r})},t.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"});Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,i){var r,u;if((i&1&&(n=t(n)),i&8)||i&4&&typeof n=="object"&&n&&n.__esModule)return n;if(r=Object.create(null),t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),i&2&&typeof n!="string")for(u in n)t.d(r,u,function(t){return n[t]}.bind(null,u));return r},t.n=function(n){var i=n&&n.__esModule?function(){return n["default"]}:function(){return n};return t.d(i,"a",i),i},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=0)}([function(n,t,i){"use strict";i.r(t);var u=i(1),f=i.n(u),r=i(3);i.d(t,"VERSION",function(){return r.VERSION});i.d(t,"AbortError",function(){return r.AbortError});i.d(t,"HttpError",function(){return r.HttpError});i.d(t,"TimeoutError",function(){return r.TimeoutError});i.d(t,"HttpClient",function(){return r.HttpClient});i.d(t,"HttpResponse",function(){return r.HttpResponse});i.d(t,"DefaultHttpClient",function(){return r.DefaultHttpClient});i.d(t,"HubConnection",function(){return r.HubConnection});i.d(t,"HubConnectionState",function(){return r.HubConnectionState});i.d(t,"HubConnectionBuilder",function(){return r.HubConnectionBuilder});i.d(t,"MessageType",function(){return r.MessageType});i.d(t,"LogLevel",function(){return r.LogLevel});i.d(t,"HttpTransportType",function(){return r.HttpTransportType});i.d(t,"TransferFormat",function(){return r.TransferFormat});i.d(t,"NullLogger",function(){return r.NullLogger});i.d(t,"JsonHubProtocol",function(){return r.JsonHubProtocol});i.d(t,"Subject",function(){return r.Subject});Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0});Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(n,t){return new Uint8Array(Array.prototype.slice.call(this,n,t))},writable:!0});Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,writable:!0})},function(n,t,i){(function(t){var r; /*! * @overview es6-promise - a tiny implementation of Promises/A+. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) * @license Licensed under MIT license * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE * @version v4.2.2+97478eb6 */ (function(t,i){n.exports=i()})(this,function(){"use strict";function kt(n){var t=typeof n;return n!==null&&(t==="object"||t==="function")}function et(n){return typeof n=="function"}function dt(n){d=n}function gt(n){e=n}function ii(){return function(){return process.nextTick(h)}}function ri(){return typeof k!="undefined"?function(){k(h)}:g()}function ui(){var n=0,i=new lt(h),t=document.createTextNode("");return i.observe(t,{characterData:!0}),function(){t.data=n=++n%2}}function fi(){var n=new MessageChannel;return n.port1.onmessage=h,function(){return n.port2.postMessage(0)}}function g(){var n=setTimeout;return function(){return n(h,1)}}function h(){for(var t,i,n=0;n=200&&o.status<300?i(new u.HttpResponse(o.status,o.statusText,o.response||o.responseText)):e(new r.HttpError(o.statusText,o.status))};o.onerror=function(){t.logger.log(f.LogLevel.Warning,"Error from HTTP request. "+o.status+": "+o.statusText+".");e(new r.HttpError(o.statusText,o.status))};o.ontimeout=function(){t.logger.log(f.LogLevel.Warning,"Timeout from HTTP request.");e(new r.TimeoutError)};o.send(n.content||"")}):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))},t}(u.HttpClient)},function(n,t,i){"use strict";i.r(t);i.d(t,"LogLevel",function(){return r});var r;(function(n){n[n.Trace=0]="Trace";n[n.Debug=1]="Debug";n[n.Information=2]="Information";n[n.Warning=3]="Warning";n[n.Error=4]="Error";n[n.Critical=5]="Critical";n[n.None=6]="None"})(r||(r={}))},function(n,t,i){"use strict";var h;i.r(t);i.d(t,"HubConnectionState",function(){return u});i.d(t,"HubConnection",function(){return h});var c=i(11),f=i(15),r=i(9),l=i(16),s=i(13),e=undefined&&undefined.__awaiter||function(n,t,i,r){return new(i||(i=Promise))(function(u,f){function o(n){try{e(r.next(n))}catch(t){f(t)}}function s(n){try{e(r["throw"](n))}catch(t){f(t)}}function e(n){n.done?u(n.value):new i(function(t){t(n.value)}).then(o,s)}e((r=r.apply(n,t||[])).next())})},o=undefined&&undefined.__generator||function(n,t){function o(n){return function(t){return s([n,t])}}function s(e){if(f)throw new TypeError("Generator is already executing.");while(r)try{if(f=1,u&&(i=e[0]&2?u["return"]:e[0]?u["throw"]||((i=u["return"])&&i.call(u),0):u.next)&&!(i=i.call(u,e[1])).done)return i;(u=0,i)&&(e=[e[0]&2,i.value]);switch(e[0]){case 0:case 1:i=e;break;case 4:return r.label++,{value:e[1],done:!1};case 5:r.label++;u=e[1];e=[0];continue;case 7:e=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]t?f.slice(t).buffer:null}else{if(e=n,i=e.indexOf(r.TextMessageFormat.RecordSeparator),i===-1)throw new Error("Message is incomplete.");t=i+1;o=e.substring(0,t);s=e.length>t?e.substring(t):null}if(l=r.TextMessageFormat.parse(o),h=JSON.parse(l[0]),h.type)throw new Error("Expected a handshake response from the server.");return c=h,[s,c]},n}()},function(n,t,i){"use strict";i.r(t);i.d(t,"TextMessageFormat",function(){return r});var r=function(){function n(){}return n.write=function(t){return""+t+n.RecordSeparator},n.parse=function(t){if(t[t.length-1]!==n.RecordSeparator)throw new Error("Message is incomplete.");var i=t.split(n.RecordSeparator);return i.pop(),i},n.RecordSeparatorCode=30,n.RecordSeparator=String.fromCharCode(n.RecordSeparatorCode),n}()},function(n,t,i){"use strict";function e(n,t){var i="";return f(n)?(i="Binary data of length "+n.byteLength,t&&(i+=". Content: '"+o(n)+"'")):typeof n=="string"&&(i="String data of length "+n.length,t&&(i+=". Content: '"+n+"'")),i}function o(n){var i=new Uint8Array(n),t="";return i.forEach(function(n){var i=n<16?"0":"";t+="0x"+i+n.toString(16)+" "}),t.substr(0,t.length-1)}function f(n){return n&&typeof ArrayBuffer!="undefined"&&(n instanceof ArrayBuffer||n.constructor&&n.constructor.name==="ArrayBuffer")}function y(n,t,i,u,o,s,h){return c(this,void 0,void 0,function(){var c,v,a,y,p;return l(this,function(l){switch(l.label){case 0:return o?[4,o()]:[3,2];case 1:a=l.sent();a&&(v=(c={},c.Authorization="Bearer "+a,c));l.label=2;case 2:return n.log(r.LogLevel.Trace,"("+t+" transport) sending data. "+e(s,h)+"."),y=f(s)?"arraybuffer":"text",[4,i.post(u,{content:s,headers:v,responseType:y})];case 3:return p=l.sent(),n.log(r.LogLevel.Trace,"("+t+" transport) request complete. Response status: "+p.statusCode+"."),[2]}})})}function p(n){return n===undefined?new u(r.LogLevel.Information):n===null?h.NullLogger.instance:n.log?n:new u(n)}var s,u;i.r(t);i.d(t,"Arg",function(){return a});i.d(t,"Platform",function(){return v});i.d(t,"getDataDetail",function(){return e});i.d(t,"formatArrayBuffer",function(){return o});i.d(t,"isArrayBuffer",function(){return f});i.d(t,"sendMessage",function(){return y});i.d(t,"createLogger",function(){return p});i.d(t,"SubjectSubscription",function(){return s});i.d(t,"ConsoleLogger",function(){return u});var r=i(9),h=i(14),c=undefined&&undefined.__awaiter||function(n,t,i,r){return new(i||(i=Promise))(function(u,f){function o(n){try{e(r.next(n))}catch(t){f(t)}}function s(n){try{e(r["throw"](n))}catch(t){f(t)}}function e(n){n.done?u(n.value):new i(function(t){t(n.value)}).then(o,s)}e((r=r.apply(n,t||[])).next())})},l=undefined&&undefined.__generator||function(n,t){function o(n){return function(t){return s([n,t])}}function s(e){if(f)throw new TypeError("Generator is already executing.");while(r)try{if(f=1,u&&(i=e[0]&2?u["return"]:e[0]?u["throw"]||((i=u["return"])&&i.call(u),0):u.next)&&!(i=i.call(u,e[1])).done)return i;(u=0,i)&&(e=[e[0]&2,i.value]);switch(e[0]){case 0:case 1:i=e;break;case 4:return r.label++,{value:e[1],done:!1};case 5:r.label++;u=e[1];e=[0];continue;case 7:e=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]-1&&this.subject.observers.splice(n,1);this.subject.observers.length===0&&this.subject.cancelCallback&&this.subject.cancelCallback().catch(function(){})},n}();u=function(){function n(n){this.minimumLogLevel=n;this.outputConsole=console}return n.prototype.log=function(n,t){if(n>=this.minimumLogLevel)switch(n){case r.LogLevel.Critical:case r.LogLevel.Error:this.outputConsole.error("["+(new Date).toISOString()+"] "+r.LogLevel[n]+": "+t);break;case r.LogLevel.Warning:this.outputConsole.warn("["+(new Date).toISOString()+"] "+r.LogLevel[n]+": "+t);break;case r.LogLevel.Information:this.outputConsole.info("["+(new Date).toISOString()+"] "+r.LogLevel[n]+": "+t);break;default:this.outputConsole.log("["+(new Date).toISOString()+"] "+r.LogLevel[n]+": "+t)}},n}()},function(n,t,i){"use strict";i.r(t);i.d(t,"NullLogger",function(){return r});var r=function(){function n(){}return n.prototype.log=function(){},n.instance=new n,n}()},function(n,t,i){"use strict";i.r(t);i.d(t,"MessageType",function(){return r});var r;(function(n){n[n.Invocation=1]="Invocation";n[n.StreamItem=2]="StreamItem";n[n.Completion=3]="Completion";n[n.StreamInvocation=4]="StreamInvocation";n[n.CancelInvocation=5]="CancelInvocation";n[n.Ping=6]="Ping";n[n.Close=7]="Close"})(r||(r={}))},function(n,t,i){"use strict";i.r(t);i.d(t,"Subject",function(){return u});var r=i(13),u=function(){function n(){this.observers=[]}return n.prototype.next=function(n){for(var r,t=0,i=this.observers;t0&&i[i.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]0?[2,Promise.reject(new Error("Unable to connect to the server with any of the available transports. "+o.join(" ")))]:[2,Promise.reject(new Error("None of the transports supported by the client are supported by the server."))]}})})},n.prototype.constructTransport=function(n){switch(n){case u.HttpTransportType.WebSockets:if(!this.options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new k.WebSocketTransport(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.WebSocket);case u.HttpTransportType.ServerSentEvents:if(!this.options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new b.ServerSentEventsTransport(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.EventSource);case u.HttpTransportType.LongPolling:return new v.LongPollingTransport(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1);default:throw new Error("Unknown transport: "+n+".");}},n.prototype.startTransport=function(n,t){var i=this;return this.transport.onreceive=this.onreceive,this.transport.onclose=function(n){return i.stopConnection(n)},this.transport.connect(n,t)},n.prototype.resolveTransportOrError=function(n,t,i){var f=u.HttpTransportType[n.transport],e;if(f===null||f===undefined)return this.logger.log(r.LogLevel.Debug,"Skipping transport '"+n.transport+"' because it is not supported by this client."),new Error("Skipping transport '"+n.transport+"' because it is not supported by this client.");if(d(t,f))if(e=n.transferFormats.map(function(n){return u.TransferFormat[n]}),e.indexOf(i)>=0)if((f!==u.HttpTransportType.WebSockets||this.options.WebSocket)&&(f!==u.HttpTransportType.ServerSentEvents||this.options.EventSource)){this.logger.log(r.LogLevel.Debug,"Selecting transport '"+u.HttpTransportType[f]+"'.");try{return this.constructTransport(f)}catch(o){return o}}else return this.logger.log(r.LogLevel.Debug,"Skipping transport '"+u.HttpTransportType[f]+"' because it is not supported in your environment.'"),new Error("'"+u.HttpTransportType[f]+"' is not supported in your environment.");else return this.logger.log(r.LogLevel.Debug,"Skipping transport '"+u.HttpTransportType[f]+"' because it does not support the requested transfer format '"+u.TransferFormat[i]+"'."),new Error("'"+u.HttpTransportType[f]+"' does not support "+u.TransferFormat[i]+".");else return this.logger.log(r.LogLevel.Debug,"Skipping transport '"+u.HttpTransportType[f]+"' because it was disabled by the client."),new Error("'"+u.HttpTransportType[f]+"' is disabled by the client.")},n.prototype.isITransport=function(n){return n&&typeof n=="object"&&"connect"in n},n.prototype.stopConnection=function(n){var t=this;if(this.logger.log(r.LogLevel.Debug,"HttpConnection.stopConnection("+n+") called while in state "+this.connectionState+"."),this.transport=undefined,n=this.stopError||n,this.stopError=undefined,this.connectionState==="Disconnected"){this.logger.log(r.LogLevel.Debug,"Call to HttpConnection.stopConnection("+n+") was ignored because the connection is already in the disconnected state.");return}if(this.connectionState==="Connecting "){this.logger.log(r.LogLevel.Warning,"Call to HttpConnection.stopConnection("+n+") was ignored because the connection hasn't yet left the in the connecting state.");return}if(this.connectionState==="Disconnecting"&&this.stopPromiseResolver(),n?this.logger.log(r.LogLevel.Error,"Connection disconnected with error '"+n+"'."):this.logger.log(r.LogLevel.Information,"Connection disconnected."),this.sendQueue&&(this.sendQueue.stop().catch(function(n){t.logger.log(r.LogLevel.Error,"TransportSendQueue.stop() threw error '"+n+"'.")}),this.sendQueue=undefined),this.connectionId=undefined,this.connectionState="Disconnected",this.connectionStarted){this.connectionStarted=!1;try{if(this.onclose)this.onclose(n)}catch(i){this.logger.log(r.LogLevel.Error,"HttpConnection.onclose("+n+") threw error '"+i+"'.")}}},n.prototype.resolveUrl=function(n){if(n.lastIndexOf("https://",0)===0||n.lastIndexOf("http://",0)===0)return n;if(!f.Platform.isBrowser||!window.document)throw new Error("Cannot resolve '"+n+"'.");var t=window.document.createElement("a");return t.href=n,this.logger.log(r.LogLevel.Information,"Normalizing '"+n+"' to '"+t.href+"'."),t.href},n.prototype.resolveNegotiateUrl=function(n){var i=n.indexOf("?"),t=n.substring(0,i===-1?n.length:i);return t[t.length-1]!=="/"&&(t+="/"),t+="negotiate",t+=i===-1?"":n.substring(i),t.indexOf("negotiateVersion")===-1&&(t+=i===-1?"?":"&",t+="negotiateVersion="+this.negotiateVersion),t},n}();a=function(){function n(n){this.transport=n;this.buffer=[];this.executing=!0;this.sendBufferedData=new s;this.transportResult=new s;this.sendLoopPromise=this.sendLoop()}return n.prototype.send=function(n){return this.bufferData(n),this.transportResult||(this.transportResult=new s),this.transportResult.promise},n.prototype.stop=function(){return this.executing=!1,this.sendBufferedData.resolve(),this.sendLoopPromise},n.prototype.bufferData=function(n){if(this.buffer.length&&typeof this.buffer[0]!=typeof n)throw new Error("Expected data to be of type "+typeof this.buffer+" but was of type "+typeof n);this.buffer.push(n);this.sendBufferedData.resolve()},n.prototype.sendLoop=function(){return o(this,void 0,void 0,function(){var t,i,r;return e(this,function(u){switch(u.label){case 0:return[4,this.sendBufferedData.promise];case 1:if(u.sent(),!this.executing)return this.transportResult&&this.transportResult.reject("Connection stopped."),[3,6];this.sendBufferedData=new s;t=this.transportResult;this.transportResult=undefined;i=typeof this.buffer[0]=="string"?this.buffer.join(""):n.concatBuffers(this.buffer);this.buffer.length=0;u.label=2;case 2:return u.trys.push([2,4,,5]),[4,this.transport.send(i)];case 3:return u.sent(),t.resolve(),[3,5];case 4:return r=u.sent(),t.reject(r),[3,5];case 5:return[3,0];case 6:return[2]}})})},n.concatBuffers=function(n){for(var i,e=n.map(function(n){return n.byteLength}).reduce(function(n,t){return n+t}),r=new Uint8Array(e),u=0,t=0,f=n;t0&&i[i.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]0&&i[i.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]0&&i[i.length-1])&&(e[0]===6||e[0]===2)){r=0;continue}if(e[0]===3&&(!i||e[1]>i[0]&&e[1]