github.com/philippseith/signalr@v0.6.3/chatsample/public/js/signalr.js (about)

     1  (function webpackUniversalModuleDefinition(root, factory) {
     2  	if(typeof exports === 'object' && typeof module === 'object')
     3  		module.exports = factory();
     4  	else if(typeof define === 'function' && define.amd)
     5  		define([], factory);
     6  	else if(typeof exports === 'object')
     7  		exports["signalR"] = factory();
     8  	else
     9  		root["signalR"] = factory();
    10  })(window, function() {
    11  return /******/ (function(modules) { // webpackBootstrap
    12  /******/ 	// The module cache
    13  /******/ 	var installedModules = {};
    14  /******/
    15  /******/ 	// The require function
    16  /******/ 	function __webpack_require__(moduleId) {
    17  /******/
    18  /******/ 		// Check if module is in cache
    19  /******/ 		if(installedModules[moduleId]) {
    20  /******/ 			return installedModules[moduleId].exports;
    21  /******/ 		}
    22  /******/ 		// Create a new module (and put it into the cache)
    23  /******/ 		var module = installedModules[moduleId] = {
    24  /******/ 			i: moduleId,
    25  /******/ 			l: false,
    26  /******/ 			exports: {}
    27  /******/ 		};
    28  /******/
    29  /******/ 		// Execute the module function
    30  /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
    31  /******/
    32  /******/ 		// Flag the module as loaded
    33  /******/ 		module.l = true;
    34  /******/
    35  /******/ 		// Return the exports of the module
    36  /******/ 		return module.exports;
    37  /******/ 	}
    38  /******/
    39  /******/
    40  /******/ 	// expose the modules object (__webpack_modules__)
    41  /******/ 	__webpack_require__.m = modules;
    42  /******/
    43  /******/ 	// expose the module cache
    44  /******/ 	__webpack_require__.c = installedModules;
    45  /******/
    46  /******/ 	// define getter function for harmony exports
    47  /******/ 	__webpack_require__.d = function(exports, name, getter) {
    48  /******/ 		if(!__webpack_require__.o(exports, name)) {
    49  /******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
    50  /******/ 		}
    51  /******/ 	};
    52  /******/
    53  /******/ 	// define __esModule on exports
    54  /******/ 	__webpack_require__.r = function(exports) {
    55  /******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
    56  /******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
    57  /******/ 		}
    58  /******/ 		Object.defineProperty(exports, '__esModule', { value: true });
    59  /******/ 	};
    60  /******/
    61  /******/ 	// create a fake namespace object
    62  /******/ 	// mode & 1: value is a module id, require it
    63  /******/ 	// mode & 2: merge all properties of value into the ns
    64  /******/ 	// mode & 4: return value when already ns object
    65  /******/ 	// mode & 8|1: behave like require
    66  /******/ 	__webpack_require__.t = function(value, mode) {
    67  /******/ 		if(mode & 1) value = __webpack_require__(value);
    68  /******/ 		if(mode & 8) return value;
    69  /******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
    70  /******/ 		var ns = Object.create(null);
    71  /******/ 		__webpack_require__.r(ns);
    72  /******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
    73  /******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
    74  /******/ 		return ns;
    75  /******/ 	};
    76  /******/
    77  /******/ 	// getDefaultExport function for compatibility with non-harmony modules
    78  /******/ 	__webpack_require__.n = function(module) {
    79  /******/ 		var getter = module && module.__esModule ?
    80  /******/ 			function getDefault() { return module['default']; } :
    81  /******/ 			function getModuleExports() { return module; };
    82  /******/ 		__webpack_require__.d(getter, 'a', getter);
    83  /******/ 		return getter;
    84  /******/ 	};
    85  /******/
    86  /******/ 	// Object.prototype.hasOwnProperty.call
    87  /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
    88  /******/
    89  /******/ 	// __webpack_public_path__
    90  /******/ 	__webpack_require__.p = "";
    91  /******/
    92  /******/
    93  /******/ 	// Load entry module and return exports
    94  /******/ 	return __webpack_require__(__webpack_require__.s = 0);
    95  /******/ })
    96  /************************************************************************/
    97  /******/ ([
    98  /* 0 */
    99  /***/ (function(module, __webpack_exports__, __webpack_require__) {
   100  
   101  "use strict";
   102  __webpack_require__.r(__webpack_exports__);
   103  /* harmony import */ var es6_promise_dist_es6_promise_auto_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
   104  /* harmony import */ var es6_promise_dist_es6_promise_auto_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(es6_promise_dist_es6_promise_auto_js__WEBPACK_IMPORTED_MODULE_0__);
   105  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
   106  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbortError", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["AbortError"]; });
   107  
   108  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpError", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HttpError"]; });
   109  
   110  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TimeoutError", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["TimeoutError"]; });
   111  
   112  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpClient", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HttpClient"]; });
   113  
   114  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpResponse", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HttpResponse"]; });
   115  
   116  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultHttpClient", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["DefaultHttpClient"]; });
   117  
   118  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HubConnection", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HubConnection"]; });
   119  
   120  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HubConnectionState", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HubConnectionState"]; });
   121  
   122  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HubConnectionBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HubConnectionBuilder"]; });
   123  
   124  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MessageType", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["MessageType"]; });
   125  
   126  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LogLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["LogLevel"]; });
   127  
   128  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpTransportType", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["HttpTransportType"]; });
   129  
   130  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransferFormat", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["TransferFormat"]; });
   131  
   132  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullLogger", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["NullLogger"]; });
   133  
   134  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JsonHubProtocol", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["JsonHubProtocol"]; });
   135  
   136  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Subject", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["Subject"]; });
   137  
   138  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return _index__WEBPACK_IMPORTED_MODULE_1__["VERSION"]; });
   139  
   140  // Copyright (c) .NET Foundation. All rights reserved.
   141  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
   142  // This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
   143  
   144  // Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties
   145  // that exist on Uint8Array with the same name, and JavaScript is magic.
   146  // We make them 'writable' because the Buffer polyfill messes with it as well.
   147  if (!Uint8Array.prototype.indexOf) {
   148      Object.defineProperty(Uint8Array.prototype, "indexOf", {
   149          value: Array.prototype.indexOf,
   150          writable: true,
   151      });
   152  }
   153  if (!Uint8Array.prototype.slice) {
   154      Object.defineProperty(Uint8Array.prototype, "slice", {
   155          // wrap the slice in Uint8Array so it looks like a Uint8Array.slice call
   156          // tslint:disable-next-line:object-literal-shorthand
   157          value: function (start, end) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },
   158          writable: true,
   159      });
   160  }
   161  if (!Uint8Array.prototype.forEach) {
   162      Object.defineProperty(Uint8Array.prototype, "forEach", {
   163          value: Array.prototype.forEach,
   164          writable: true,
   165      });
   166  }
   167  
   168  
   169  
   170  /***/ }),
   171  /* 1 */
   172  /***/ (function(module, exports, __webpack_require__) {
   173  
   174  /* WEBPACK VAR INJECTION */(function(global) {var require;/*!
   175   * @overview es6-promise - a tiny implementation of Promises/A+.
   176   * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
   177   * @license   Licensed under MIT license
   178   *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
   179   * @version   v4.2.2+97478eb6
   180   */
   181  
   182  (function (global, factory) {
   183  	 true ? module.exports = factory() :
   184  	undefined;
   185  }(this, (function () { 'use strict';
   186  
   187  function objectOrFunction(x) {
   188    var type = typeof x;
   189    return x !== null && (type === 'object' || type === 'function');
   190  }
   191  
   192  function isFunction(x) {
   193    return typeof x === 'function';
   194  }
   195  
   196  
   197  
   198  var _isArray = void 0;
   199  if (Array.isArray) {
   200    _isArray = Array.isArray;
   201  } else {
   202    _isArray = function (x) {
   203      return Object.prototype.toString.call(x) === '[object Array]';
   204    };
   205  }
   206  
   207  var isArray = _isArray;
   208  
   209  var len = 0;
   210  var vertxNext = void 0;
   211  var customSchedulerFn = void 0;
   212  
   213  var asap = function asap(callback, arg) {
   214    queue[len] = callback;
   215    queue[len + 1] = arg;
   216    len += 2;
   217    if (len === 2) {
   218      // If len is 2, that means that we need to schedule an async flush.
   219      // If additional callbacks are queued before the queue is flushed, they
   220      // will be processed by this flush that we are scheduling.
   221      if (customSchedulerFn) {
   222        customSchedulerFn(flush);
   223      } else {
   224        scheduleFlush();
   225      }
   226    }
   227  };
   228  
   229  function setScheduler(scheduleFn) {
   230    customSchedulerFn = scheduleFn;
   231  }
   232  
   233  function setAsap(asapFn) {
   234    asap = asapFn;
   235  }
   236  
   237  var browserWindow = typeof window !== 'undefined' ? window : undefined;
   238  var browserGlobal = browserWindow || {};
   239  var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
   240  var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
   241  
   242  // test for web worker but not in IE10
   243  var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
   244  
   245  // node
   246  function useNextTick() {
   247    // node version 0.10.x displays a deprecation warning when nextTick is used recursively
   248    // see https://github.com/cujojs/when/issues/410 for details
   249    return function () {
   250      return process.nextTick(flush);
   251    };
   252  }
   253  
   254  // vertx
   255  function useVertxTimer() {
   256    if (typeof vertxNext !== 'undefined') {
   257      return function () {
   258        vertxNext(flush);
   259      };
   260    }
   261  
   262    return useSetTimeout();
   263  }
   264  
   265  function useMutationObserver() {
   266    var iterations = 0;
   267    var observer = new BrowserMutationObserver(flush);
   268    var node = document.createTextNode('');
   269    observer.observe(node, { characterData: true });
   270  
   271    return function () {
   272      node.data = iterations = ++iterations % 2;
   273    };
   274  }
   275  
   276  // web worker
   277  function useMessageChannel() {
   278    var channel = new MessageChannel();
   279    channel.port1.onmessage = flush;
   280    return function () {
   281      return channel.port2.postMessage(0);
   282    };
   283  }
   284  
   285  function useSetTimeout() {
   286    // Store setTimeout reference so es6-promise will be unaffected by
   287    // other code modifying setTimeout (like sinon.useFakeTimers())
   288    var globalSetTimeout = setTimeout;
   289    return function () {
   290      return globalSetTimeout(flush, 1);
   291    };
   292  }
   293  
   294  var queue = new Array(1000);
   295  function flush() {
   296    for (var i = 0; i < len; i += 2) {
   297      var callback = queue[i];
   298      var arg = queue[i + 1];
   299  
   300      callback(arg);
   301  
   302      queue[i] = undefined;
   303      queue[i + 1] = undefined;
   304    }
   305  
   306    len = 0;
   307  }
   308  
   309  function attemptVertx() {
   310    try {
   311      var r = require;
   312      var vertx = __webpack_require__(!(function webpackMissingModule() { var e = new Error("Cannot find module 'vertx'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
   313      vertxNext = vertx.runOnLoop || vertx.runOnContext;
   314      return useVertxTimer();
   315    } catch (e) {
   316      return useSetTimeout();
   317    }
   318  }
   319  
   320  var scheduleFlush = void 0;
   321  // Decide what async method to use to triggering processing of queued callbacks:
   322  if (isNode) {
   323    scheduleFlush = useNextTick();
   324  } else if (BrowserMutationObserver) {
   325    scheduleFlush = useMutationObserver();
   326  } else if (isWorker) {
   327    scheduleFlush = useMessageChannel();
   328  } else if (browserWindow === undefined && "function" === 'function') {
   329    scheduleFlush = attemptVertx();
   330  } else {
   331    scheduleFlush = useSetTimeout();
   332  }
   333  
   334  function then(onFulfillment, onRejection) {
   335    var parent = this;
   336  
   337    var child = new this.constructor(noop);
   338  
   339    if (child[PROMISE_ID] === undefined) {
   340      makePromise(child);
   341    }
   342  
   343    var _state = parent._state;
   344  
   345  
   346    if (_state) {
   347      var callback = arguments[_state - 1];
   348      asap(function () {
   349        return invokeCallback(_state, child, callback, parent._result);
   350      });
   351    } else {
   352      subscribe(parent, child, onFulfillment, onRejection);
   353    }
   354  
   355    return child;
   356  }
   357  
   358  /**
   359    `Promise.resolve` returns a promise that will become resolved with the
   360    passed `value`. It is shorthand for the following:
   361  
   362    ```javascript
   363    let promise = new Promise(function(resolve, reject){
   364      resolve(1);
   365    });
   366  
   367    promise.then(function(value){
   368      // value === 1
   369    });
   370    ```
   371  
   372    Instead of writing the above, your code now simply becomes the following:
   373  
   374    ```javascript
   375    let promise = Promise.resolve(1);
   376  
   377    promise.then(function(value){
   378      // value === 1
   379    });
   380    ```
   381  
   382    @method resolve
   383    @static
   384    @param {Any} value value that the returned promise will be resolved with
   385    Useful for tooling.
   386    @return {Promise} a promise that will become fulfilled with the given
   387    `value`
   388  */
   389  function resolve$1(object) {
   390    /*jshint validthis:true */
   391    var Constructor = this;
   392  
   393    if (object && typeof object === 'object' && object.constructor === Constructor) {
   394      return object;
   395    }
   396  
   397    var promise = new Constructor(noop);
   398    resolve(promise, object);
   399    return promise;
   400  }
   401  
   402  var PROMISE_ID = Math.random().toString(36).substring(16);
   403  
   404  function noop() {}
   405  
   406  var PENDING = void 0;
   407  var FULFILLED = 1;
   408  var REJECTED = 2;
   409  
   410  var GET_THEN_ERROR = new ErrorObject();
   411  
   412  function selfFulfillment() {
   413    return new TypeError("You cannot resolve a promise with itself");
   414  }
   415  
   416  function cannotReturnOwn() {
   417    return new TypeError('A promises callback cannot return that same promise.');
   418  }
   419  
   420  function getThen(promise) {
   421    try {
   422      return promise.then;
   423    } catch (error) {
   424      GET_THEN_ERROR.error = error;
   425      return GET_THEN_ERROR;
   426    }
   427  }
   428  
   429  function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
   430    try {
   431      then$$1.call(value, fulfillmentHandler, rejectionHandler);
   432    } catch (e) {
   433      return e;
   434    }
   435  }
   436  
   437  function handleForeignThenable(promise, thenable, then$$1) {
   438    asap(function (promise) {
   439      var sealed = false;
   440      var error = tryThen(then$$1, thenable, function (value) {
   441        if (sealed) {
   442          return;
   443        }
   444        sealed = true;
   445        if (thenable !== value) {
   446          resolve(promise, value);
   447        } else {
   448          fulfill(promise, value);
   449        }
   450      }, function (reason) {
   451        if (sealed) {
   452          return;
   453        }
   454        sealed = true;
   455  
   456        reject(promise, reason);
   457      }, 'Settle: ' + (promise._label || ' unknown promise'));
   458  
   459      if (!sealed && error) {
   460        sealed = true;
   461        reject(promise, error);
   462      }
   463    }, promise);
   464  }
   465  
   466  function handleOwnThenable(promise, thenable) {
   467    if (thenable._state === FULFILLED) {
   468      fulfill(promise, thenable._result);
   469    } else if (thenable._state === REJECTED) {
   470      reject(promise, thenable._result);
   471    } else {
   472      subscribe(thenable, undefined, function (value) {
   473        return resolve(promise, value);
   474      }, function (reason) {
   475        return reject(promise, reason);
   476      });
   477    }
   478  }
   479  
   480  function handleMaybeThenable(promise, maybeThenable, then$$1) {
   481    if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
   482      handleOwnThenable(promise, maybeThenable);
   483    } else {
   484      if (then$$1 === GET_THEN_ERROR) {
   485        reject(promise, GET_THEN_ERROR.error);
   486        GET_THEN_ERROR.error = null;
   487      } else if (then$$1 === undefined) {
   488        fulfill(promise, maybeThenable);
   489      } else if (isFunction(then$$1)) {
   490        handleForeignThenable(promise, maybeThenable, then$$1);
   491      } else {
   492        fulfill(promise, maybeThenable);
   493      }
   494    }
   495  }
   496  
   497  function resolve(promise, value) {
   498    if (promise === value) {
   499      reject(promise, selfFulfillment());
   500    } else if (objectOrFunction(value)) {
   501      handleMaybeThenable(promise, value, getThen(value));
   502    } else {
   503      fulfill(promise, value);
   504    }
   505  }
   506  
   507  function publishRejection(promise) {
   508    if (promise._onerror) {
   509      promise._onerror(promise._result);
   510    }
   511  
   512    publish(promise);
   513  }
   514  
   515  function fulfill(promise, value) {
   516    if (promise._state !== PENDING) {
   517      return;
   518    }
   519  
   520    promise._result = value;
   521    promise._state = FULFILLED;
   522  
   523    if (promise._subscribers.length !== 0) {
   524      asap(publish, promise);
   525    }
   526  }
   527  
   528  function reject(promise, reason) {
   529    if (promise._state !== PENDING) {
   530      return;
   531    }
   532    promise._state = REJECTED;
   533    promise._result = reason;
   534  
   535    asap(publishRejection, promise);
   536  }
   537  
   538  function subscribe(parent, child, onFulfillment, onRejection) {
   539    var _subscribers = parent._subscribers;
   540    var length = _subscribers.length;
   541  
   542  
   543    parent._onerror = null;
   544  
   545    _subscribers[length] = child;
   546    _subscribers[length + FULFILLED] = onFulfillment;
   547    _subscribers[length + REJECTED] = onRejection;
   548  
   549    if (length === 0 && parent._state) {
   550      asap(publish, parent);
   551    }
   552  }
   553  
   554  function publish(promise) {
   555    var subscribers = promise._subscribers;
   556    var settled = promise._state;
   557  
   558    if (subscribers.length === 0) {
   559      return;
   560    }
   561  
   562    var child = void 0,
   563        callback = void 0,
   564        detail = promise._result;
   565  
   566    for (var i = 0; i < subscribers.length; i += 3) {
   567      child = subscribers[i];
   568      callback = subscribers[i + settled];
   569  
   570      if (child) {
   571        invokeCallback(settled, child, callback, detail);
   572      } else {
   573        callback(detail);
   574      }
   575    }
   576  
   577    promise._subscribers.length = 0;
   578  }
   579  
   580  function ErrorObject() {
   581    this.error = null;
   582  }
   583  
   584  var TRY_CATCH_ERROR = new ErrorObject();
   585  
   586  function tryCatch(callback, detail) {
   587    try {
   588      return callback(detail);
   589    } catch (e) {
   590      TRY_CATCH_ERROR.error = e;
   591      return TRY_CATCH_ERROR;
   592    }
   593  }
   594  
   595  function invokeCallback(settled, promise, callback, detail) {
   596    var hasCallback = isFunction(callback),
   597        value = void 0,
   598        error = void 0,
   599        succeeded = void 0,
   600        failed = void 0;
   601  
   602    if (hasCallback) {
   603      value = tryCatch(callback, detail);
   604  
   605      if (value === TRY_CATCH_ERROR) {
   606        failed = true;
   607        error = value.error;
   608        value.error = null;
   609      } else {
   610        succeeded = true;
   611      }
   612  
   613      if (promise === value) {
   614        reject(promise, cannotReturnOwn());
   615        return;
   616      }
   617    } else {
   618      value = detail;
   619      succeeded = true;
   620    }
   621  
   622    if (promise._state !== PENDING) {
   623      // noop
   624    } else if (hasCallback && succeeded) {
   625      resolve(promise, value);
   626    } else if (failed) {
   627      reject(promise, error);
   628    } else if (settled === FULFILLED) {
   629      fulfill(promise, value);
   630    } else if (settled === REJECTED) {
   631      reject(promise, value);
   632    }
   633  }
   634  
   635  function initializePromise(promise, resolver) {
   636    try {
   637      resolver(function resolvePromise(value) {
   638        resolve(promise, value);
   639      }, function rejectPromise(reason) {
   640        reject(promise, reason);
   641      });
   642    } catch (e) {
   643      reject(promise, e);
   644    }
   645  }
   646  
   647  var id = 0;
   648  function nextId() {
   649    return id++;
   650  }
   651  
   652  function makePromise(promise) {
   653    promise[PROMISE_ID] = id++;
   654    promise._state = undefined;
   655    promise._result = undefined;
   656    promise._subscribers = [];
   657  }
   658  
   659  function validationError() {
   660    return new Error('Array Methods must be provided an Array');
   661  }
   662  
   663  function validationError() {
   664    return new Error('Array Methods must be provided an Array');
   665  }
   666  
   667  var Enumerator = function () {
   668    function Enumerator(Constructor, input) {
   669      this._instanceConstructor = Constructor;
   670      this.promise = new Constructor(noop);
   671  
   672      if (!this.promise[PROMISE_ID]) {
   673        makePromise(this.promise);
   674      }
   675  
   676      if (isArray(input)) {
   677        this.length = input.length;
   678        this._remaining = input.length;
   679  
   680        this._result = new Array(this.length);
   681  
   682        if (this.length === 0) {
   683          fulfill(this.promise, this._result);
   684        } else {
   685          this.length = this.length || 0;
   686          this._enumerate(input);
   687          if (this._remaining === 0) {
   688            fulfill(this.promise, this._result);
   689          }
   690        }
   691      } else {
   692        reject(this.promise, validationError());
   693      }
   694    }
   695  
   696    Enumerator.prototype._enumerate = function _enumerate(input) {
   697      for (var i = 0; this._state === PENDING && i < input.length; i++) {
   698        this._eachEntry(input[i], i);
   699      }
   700    };
   701  
   702    Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {
   703      var c = this._instanceConstructor;
   704      var resolve$$1 = c.resolve;
   705  
   706  
   707      if (resolve$$1 === resolve$1) {
   708        var _then = getThen(entry);
   709  
   710        if (_then === then && entry._state !== PENDING) {
   711          this._settledAt(entry._state, i, entry._result);
   712        } else if (typeof _then !== 'function') {
   713          this._remaining--;
   714          this._result[i] = entry;
   715        } else if (c === Promise$2) {
   716          var promise = new c(noop);
   717          handleMaybeThenable(promise, entry, _then);
   718          this._willSettleAt(promise, i);
   719        } else {
   720          this._willSettleAt(new c(function (resolve$$1) {
   721            return resolve$$1(entry);
   722          }), i);
   723        }
   724      } else {
   725        this._willSettleAt(resolve$$1(entry), i);
   726      }
   727    };
   728  
   729    Enumerator.prototype._settledAt = function _settledAt(state, i, value) {
   730      var promise = this.promise;
   731  
   732  
   733      if (promise._state === PENDING) {
   734        this._remaining--;
   735  
   736        if (state === REJECTED) {
   737          reject(promise, value);
   738        } else {
   739          this._result[i] = value;
   740        }
   741      }
   742  
   743      if (this._remaining === 0) {
   744        fulfill(promise, this._result);
   745      }
   746    };
   747  
   748    Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {
   749      var enumerator = this;
   750  
   751      subscribe(promise, undefined, function (value) {
   752        return enumerator._settledAt(FULFILLED, i, value);
   753      }, function (reason) {
   754        return enumerator._settledAt(REJECTED, i, reason);
   755      });
   756    };
   757  
   758    return Enumerator;
   759  }();
   760  
   761  /**
   762    `Promise.all` accepts an array of promises, and returns a new promise which
   763    is fulfilled with an array of fulfillment values for the passed promises, or
   764    rejected with the reason of the first passed promise to be rejected. It casts all
   765    elements of the passed iterable to promises as it runs this algorithm.
   766  
   767    Example:
   768  
   769    ```javascript
   770    let promise1 = resolve(1);
   771    let promise2 = resolve(2);
   772    let promise3 = resolve(3);
   773    let promises = [ promise1, promise2, promise3 ];
   774  
   775    Promise.all(promises).then(function(array){
   776      // The array here would be [ 1, 2, 3 ];
   777    });
   778    ```
   779  
   780    If any of the `promises` given to `all` are rejected, the first promise
   781    that is rejected will be given as an argument to the returned promises's
   782    rejection handler. For example:
   783  
   784    Example:
   785  
   786    ```javascript
   787    let promise1 = resolve(1);
   788    let promise2 = reject(new Error("2"));
   789    let promise3 = reject(new Error("3"));
   790    let promises = [ promise1, promise2, promise3 ];
   791  
   792    Promise.all(promises).then(function(array){
   793      // Code here never runs because there are rejected promises!
   794    }, function(error) {
   795      // error.message === "2"
   796    });
   797    ```
   798  
   799    @method all
   800    @static
   801    @param {Array} entries array of promises
   802    @param {String} label optional string for labeling the promise.
   803    Useful for tooling.
   804    @return {Promise} promise that is fulfilled when all `promises` have been
   805    fulfilled, or rejected if any of them become rejected.
   806    @static
   807  */
   808  function all(entries) {
   809    return new Enumerator(this, entries).promise;
   810  }
   811  
   812  /**
   813    `Promise.race` returns a new promise which is settled in the same way as the
   814    first passed promise to settle.
   815  
   816    Example:
   817  
   818    ```javascript
   819    let promise1 = new Promise(function(resolve, reject){
   820      setTimeout(function(){
   821        resolve('promise 1');
   822      }, 200);
   823    });
   824  
   825    let promise2 = new Promise(function(resolve, reject){
   826      setTimeout(function(){
   827        resolve('promise 2');
   828      }, 100);
   829    });
   830  
   831    Promise.race([promise1, promise2]).then(function(result){
   832      // result === 'promise 2' because it was resolved before promise1
   833      // was resolved.
   834    });
   835    ```
   836  
   837    `Promise.race` is deterministic in that only the state of the first
   838    settled promise matters. For example, even if other promises given to the
   839    `promises` array argument are resolved, but the first settled promise has
   840    become rejected before the other promises became fulfilled, the returned
   841    promise will become rejected:
   842  
   843    ```javascript
   844    let promise1 = new Promise(function(resolve, reject){
   845      setTimeout(function(){
   846        resolve('promise 1');
   847      }, 200);
   848    });
   849  
   850    let promise2 = new Promise(function(resolve, reject){
   851      setTimeout(function(){
   852        reject(new Error('promise 2'));
   853      }, 100);
   854    });
   855  
   856    Promise.race([promise1, promise2]).then(function(result){
   857      // Code here never runs
   858    }, function(reason){
   859      // reason.message === 'promise 2' because promise 2 became rejected before
   860      // promise 1 became fulfilled
   861    });
   862    ```
   863  
   864    An example real-world use case is implementing timeouts:
   865  
   866    ```javascript
   867    Promise.race([ajax('foo.json'), timeout(5000)])
   868    ```
   869  
   870    @method race
   871    @static
   872    @param {Array} promises array of promises to observe
   873    Useful for tooling.
   874    @return {Promise} a promise which settles in the same way as the first passed
   875    promise to settle.
   876  */
   877  function race(entries) {
   878    /*jshint validthis:true */
   879    var Constructor = this;
   880  
   881    if (!isArray(entries)) {
   882      return new Constructor(function (_, reject) {
   883        return reject(new TypeError('You must pass an array to race.'));
   884      });
   885    } else {
   886      return new Constructor(function (resolve, reject) {
   887        var length = entries.length;
   888        for (var i = 0; i < length; i++) {
   889          Constructor.resolve(entries[i]).then(resolve, reject);
   890        }
   891      });
   892    }
   893  }
   894  
   895  /**
   896    `Promise.reject` returns a promise rejected with the passed `reason`.
   897    It is shorthand for the following:
   898  
   899    ```javascript
   900    let promise = new Promise(function(resolve, reject){
   901      reject(new Error('WHOOPS'));
   902    });
   903  
   904    promise.then(function(value){
   905      // Code here doesn't run because the promise is rejected!
   906    }, function(reason){
   907      // reason.message === 'WHOOPS'
   908    });
   909    ```
   910  
   911    Instead of writing the above, your code now simply becomes the following:
   912  
   913    ```javascript
   914    let promise = Promise.reject(new Error('WHOOPS'));
   915  
   916    promise.then(function(value){
   917      // Code here doesn't run because the promise is rejected!
   918    }, function(reason){
   919      // reason.message === 'WHOOPS'
   920    });
   921    ```
   922  
   923    @method reject
   924    @static
   925    @param {Any} reason value that the returned promise will be rejected with.
   926    Useful for tooling.
   927    @return {Promise} a promise rejected with the given `reason`.
   928  */
   929  function reject$1(reason) {
   930    /*jshint validthis:true */
   931    var Constructor = this;
   932    var promise = new Constructor(noop);
   933    reject(promise, reason);
   934    return promise;
   935  }
   936  
   937  function needsResolver() {
   938    throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
   939  }
   940  
   941  function needsNew() {
   942    throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
   943  }
   944  
   945  /**
   946    Promise objects represent the eventual result of an asynchronous operation. The
   947    primary way of interacting with a promise is through its `then` method, which
   948    registers callbacks to receive either a promise's eventual value or the reason
   949    why the promise cannot be fulfilled.
   950  
   951    Terminology
   952    -----------
   953  
   954    - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
   955    - `thenable` is an object or function that defines a `then` method.
   956    - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
   957    - `exception` is a value that is thrown using the throw statement.
   958    - `reason` is a value that indicates why a promise was rejected.
   959    - `settled` the final resting state of a promise, fulfilled or rejected.
   960  
   961    A promise can be in one of three states: pending, fulfilled, or rejected.
   962  
   963    Promises that are fulfilled have a fulfillment value and are in the fulfilled
   964    state.  Promises that are rejected have a rejection reason and are in the
   965    rejected state.  A fulfillment value is never a thenable.
   966  
   967    Promises can also be said to *resolve* a value.  If this value is also a
   968    promise, then the original promise's settled state will match the value's
   969    settled state.  So a promise that *resolves* a promise that rejects will
   970    itself reject, and a promise that *resolves* a promise that fulfills will
   971    itself fulfill.
   972  
   973  
   974    Basic Usage:
   975    ------------
   976  
   977    ```js
   978    let promise = new Promise(function(resolve, reject) {
   979      // on success
   980      resolve(value);
   981  
   982      // on failure
   983      reject(reason);
   984    });
   985  
   986    promise.then(function(value) {
   987      // on fulfillment
   988    }, function(reason) {
   989      // on rejection
   990    });
   991    ```
   992  
   993    Advanced Usage:
   994    ---------------
   995  
   996    Promises shine when abstracting away asynchronous interactions such as
   997    `XMLHttpRequest`s.
   998  
   999    ```js
  1000    function getJSON(url) {
  1001      return new Promise(function(resolve, reject){
  1002        let xhr = new XMLHttpRequest();
  1003  
  1004        xhr.open('GET', url);
  1005        xhr.onreadystatechange = handler;
  1006        xhr.responseType = 'json';
  1007        xhr.setRequestHeader('Accept', 'application/json');
  1008        xhr.send();
  1009  
  1010        function handler() {
  1011          if (this.readyState === this.DONE) {
  1012            if (this.status === 200) {
  1013              resolve(this.response);
  1014            } else {
  1015              reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
  1016            }
  1017          }
  1018        };
  1019      });
  1020    }
  1021  
  1022    getJSON('/posts.json').then(function(json) {
  1023      // on fulfillment
  1024    }, function(reason) {
  1025      // on rejection
  1026    });
  1027    ```
  1028  
  1029    Unlike callbacks, promises are great composable primitives.
  1030  
  1031    ```js
  1032    Promise.all([
  1033      getJSON('/posts'),
  1034      getJSON('/comments')
  1035    ]).then(function(values){
  1036      values[0] // => postsJSON
  1037      values[1] // => commentsJSON
  1038  
  1039      return values;
  1040    });
  1041    ```
  1042  
  1043    @class Promise
  1044    @param {Function} resolver
  1045    Useful for tooling.
  1046    @constructor
  1047  */
  1048  
  1049  var Promise$2 = function () {
  1050    function Promise(resolver) {
  1051      this[PROMISE_ID] = nextId();
  1052      this._result = this._state = undefined;
  1053      this._subscribers = [];
  1054  
  1055      if (noop !== resolver) {
  1056        typeof resolver !== 'function' && needsResolver();
  1057        this instanceof Promise ? initializePromise(this, resolver) : needsNew();
  1058      }
  1059    }
  1060  
  1061    /**
  1062    The primary way of interacting with a promise is through its `then` method,
  1063    which registers callbacks to receive either a promise's eventual value or the
  1064    reason why the promise cannot be fulfilled.
  1065     ```js
  1066    findUser().then(function(user){
  1067      // user is available
  1068    }, function(reason){
  1069      // user is unavailable, and you are given the reason why
  1070    });
  1071    ```
  1072     Chaining
  1073    --------
  1074     The return value of `then` is itself a promise.  This second, 'downstream'
  1075    promise is resolved with the return value of the first promise's fulfillment
  1076    or rejection handler, or rejected if the handler throws an exception.
  1077     ```js
  1078    findUser().then(function (user) {
  1079      return user.name;
  1080    }, function (reason) {
  1081      return 'default name';
  1082    }).then(function (userName) {
  1083      // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
  1084      // will be `'default name'`
  1085    });
  1086     findUser().then(function (user) {
  1087      throw new Error('Found user, but still unhappy');
  1088    }, function (reason) {
  1089      throw new Error('`findUser` rejected and we're unhappy');
  1090    }).then(function (value) {
  1091      // never reached
  1092    }, function (reason) {
  1093      // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
  1094      // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
  1095    });
  1096    ```
  1097    If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
  1098     ```js
  1099    findUser().then(function (user) {
  1100      throw new PedagogicalException('Upstream error');
  1101    }).then(function (value) {
  1102      // never reached
  1103    }).then(function (value) {
  1104      // never reached
  1105    }, function (reason) {
  1106      // The `PedgagocialException` is propagated all the way down to here
  1107    });
  1108    ```
  1109     Assimilation
  1110    ------------
  1111     Sometimes the value you want to propagate to a downstream promise can only be
  1112    retrieved asynchronously. This can be achieved by returning a promise in the
  1113    fulfillment or rejection handler. The downstream promise will then be pending
  1114    until the returned promise is settled. This is called *assimilation*.
  1115     ```js
  1116    findUser().then(function (user) {
  1117      return findCommentsByAuthor(user);
  1118    }).then(function (comments) {
  1119      // The user's comments are now available
  1120    });
  1121    ```
  1122     If the assimliated promise rejects, then the downstream promise will also reject.
  1123     ```js
  1124    findUser().then(function (user) {
  1125      return findCommentsByAuthor(user);
  1126    }).then(function (comments) {
  1127      // If `findCommentsByAuthor` fulfills, we'll have the value here
  1128    }, function (reason) {
  1129      // If `findCommentsByAuthor` rejects, we'll have the reason here
  1130    });
  1131    ```
  1132     Simple Example
  1133    --------------
  1134     Synchronous Example
  1135     ```javascript
  1136    let result;
  1137     try {
  1138      result = findResult();
  1139      // success
  1140    } catch(reason) {
  1141      // failure
  1142    }
  1143    ```
  1144     Errback Example
  1145     ```js
  1146    findResult(function(result, err){
  1147      if (err) {
  1148        // failure
  1149      } else {
  1150        // success
  1151      }
  1152    });
  1153    ```
  1154     Promise Example;
  1155     ```javascript
  1156    findResult().then(function(result){
  1157      // success
  1158    }, function(reason){
  1159      // failure
  1160    });
  1161    ```
  1162     Advanced Example
  1163    --------------
  1164     Synchronous Example
  1165     ```javascript
  1166    let author, books;
  1167     try {
  1168      author = findAuthor();
  1169      books  = findBooksByAuthor(author);
  1170      // success
  1171    } catch(reason) {
  1172      // failure
  1173    }
  1174    ```
  1175     Errback Example
  1176     ```js
  1177     function foundBooks(books) {
  1178     }
  1179     function failure(reason) {
  1180     }
  1181     findAuthor(function(author, err){
  1182      if (err) {
  1183        failure(err);
  1184        // failure
  1185      } else {
  1186        try {
  1187          findBoooksByAuthor(author, function(books, err) {
  1188            if (err) {
  1189              failure(err);
  1190            } else {
  1191              try {
  1192                foundBooks(books);
  1193              } catch(reason) {
  1194                failure(reason);
  1195              }
  1196            }
  1197          });
  1198        } catch(error) {
  1199          failure(err);
  1200        }
  1201        // success
  1202      }
  1203    });
  1204    ```
  1205     Promise Example;
  1206     ```javascript
  1207    findAuthor().
  1208      then(findBooksByAuthor).
  1209      then(function(books){
  1210        // found books
  1211    }).catch(function(reason){
  1212      // something went wrong
  1213    });
  1214    ```
  1215     @method then
  1216    @param {Function} onFulfilled
  1217    @param {Function} onRejected
  1218    Useful for tooling.
  1219    @return {Promise}
  1220    */
  1221  
  1222    /**
  1223    `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
  1224    as the catch block of a try/catch statement.
  1225    ```js
  1226    function findAuthor(){
  1227    throw new Error('couldn't find that author');
  1228    }
  1229    // synchronous
  1230    try {
  1231    findAuthor();
  1232    } catch(reason) {
  1233    // something went wrong
  1234    }
  1235    // async with promises
  1236    findAuthor().catch(function(reason){
  1237    // something went wrong
  1238    });
  1239    ```
  1240    @method catch
  1241    @param {Function} onRejection
  1242    Useful for tooling.
  1243    @return {Promise}
  1244    */
  1245  
  1246  
  1247    Promise.prototype.catch = function _catch(onRejection) {
  1248      return this.then(null, onRejection);
  1249    };
  1250  
  1251    /**
  1252      `finally` will be invoked regardless of the promise's fate just as native
  1253      try/catch/finally behaves
  1254    
  1255      Synchronous example:
  1256    
  1257      ```js
  1258      findAuthor() {
  1259        if (Math.random() > 0.5) {
  1260          throw new Error();
  1261        }
  1262        return new Author();
  1263      }
  1264    
  1265      try {
  1266        return findAuthor(); // succeed or fail
  1267      } catch(error) {
  1268        return findOtherAuther();
  1269      } finally {
  1270        // always runs
  1271        // doesn't affect the return value
  1272      }
  1273      ```
  1274    
  1275      Asynchronous example:
  1276    
  1277      ```js
  1278      findAuthor().catch(function(reason){
  1279        return findOtherAuther();
  1280      }).finally(function(){
  1281        // author was either found, or not
  1282      });
  1283      ```
  1284    
  1285      @method finally
  1286      @param {Function} callback
  1287      @return {Promise}
  1288    */
  1289  
  1290  
  1291    Promise.prototype.finally = function _finally(callback) {
  1292      var promise = this;
  1293      var constructor = promise.constructor;
  1294  
  1295      return promise.then(function (value) {
  1296        return constructor.resolve(callback()).then(function () {
  1297          return value;
  1298        });
  1299      }, function (reason) {
  1300        return constructor.resolve(callback()).then(function () {
  1301          throw reason;
  1302        });
  1303      });
  1304    };
  1305  
  1306    return Promise;
  1307  }();
  1308  
  1309  Promise$2.prototype.then = then;
  1310  Promise$2.all = all;
  1311  Promise$2.race = race;
  1312  Promise$2.resolve = resolve$1;
  1313  Promise$2.reject = reject$1;
  1314  Promise$2._setScheduler = setScheduler;
  1315  Promise$2._setAsap = setAsap;
  1316  Promise$2._asap = asap;
  1317  
  1318  /*global self*/
  1319  function polyfill() {
  1320      var local = void 0;
  1321  
  1322      if (typeof global !== 'undefined') {
  1323          local = global;
  1324      } else if (typeof self !== 'undefined') {
  1325          local = self;
  1326      } else {
  1327          try {
  1328              local = Function('return this')();
  1329          } catch (e) {
  1330              throw new Error('polyfill failed because global object is unavailable in this environment');
  1331          }
  1332      }
  1333  
  1334      var P = local.Promise;
  1335  
  1336      if (P) {
  1337          var promiseToString = null;
  1338          try {
  1339              promiseToString = Object.prototype.toString.call(P.resolve());
  1340          } catch (e) {
  1341              // silently ignored
  1342          }
  1343  
  1344          if (promiseToString === '[object Promise]' && !P.cast) {
  1345              return;
  1346          }
  1347      }
  1348  
  1349      local.Promise = Promise$2;
  1350  }
  1351  
  1352  // Strange compat..
  1353  Promise$2.polyfill = polyfill;
  1354  Promise$2.Promise = Promise$2;
  1355  
  1356  Promise$2.polyfill();
  1357  
  1358  return Promise$2;
  1359  
  1360  })));
  1361  
  1362  
  1363  
  1364  //# sourceMappingURL=es6-promise.auto.map
  1365  
  1366  /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(2)))
  1367  
  1368  /***/ }),
  1369  /* 2 */
  1370  /***/ (function(module, exports) {
  1371  
  1372  var g;
  1373  
  1374  // This works in non-strict mode
  1375  g = (function() {
  1376  	return this;
  1377  })();
  1378  
  1379  try {
  1380  	// This works if eval is allowed (see CSP)
  1381  	g = g || new Function("return this")();
  1382  } catch (e) {
  1383  	// This works if the window reference is available
  1384  	if (typeof window === "object") g = window;
  1385  }
  1386  
  1387  // g can still be undefined, but nothing to do about it...
  1388  // We return undefined, instead of nothing here, so it's
  1389  // easier to handle this case. if(!global) { ...}
  1390  
  1391  module.exports = g;
  1392  
  1393  
  1394  /***/ }),
  1395  /* 3 */
  1396  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1397  
  1398  "use strict";
  1399  __webpack_require__.r(__webpack_exports__);
  1400  /* harmony import */ var _Errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
  1401  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbortError", function() { return _Errors__WEBPACK_IMPORTED_MODULE_0__["AbortError"]; });
  1402  
  1403  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpError", function() { return _Errors__WEBPACK_IMPORTED_MODULE_0__["HttpError"]; });
  1404  
  1405  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TimeoutError", function() { return _Errors__WEBPACK_IMPORTED_MODULE_0__["TimeoutError"]; });
  1406  
  1407  /* harmony import */ var _HttpClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
  1408  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpClient", function() { return _HttpClient__WEBPACK_IMPORTED_MODULE_1__["HttpClient"]; });
  1409  
  1410  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpResponse", function() { return _HttpClient__WEBPACK_IMPORTED_MODULE_1__["HttpResponse"]; });
  1411  
  1412  /* harmony import */ var _DefaultHttpClient__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
  1413  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultHttpClient", function() { return _DefaultHttpClient__WEBPACK_IMPORTED_MODULE_2__["DefaultHttpClient"]; });
  1414  
  1415  /* harmony import */ var _HubConnection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
  1416  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HubConnection", function() { return _HubConnection__WEBPACK_IMPORTED_MODULE_3__["HubConnection"]; });
  1417  
  1418  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HubConnectionState", function() { return _HubConnection__WEBPACK_IMPORTED_MODULE_3__["HubConnectionState"]; });
  1419  
  1420  /* harmony import */ var _HubConnectionBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17);
  1421  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HubConnectionBuilder", function() { return _HubConnectionBuilder__WEBPACK_IMPORTED_MODULE_4__["HubConnectionBuilder"]; });
  1422  
  1423  /* harmony import */ var _IHubProtocol__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(15);
  1424  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MessageType", function() { return _IHubProtocol__WEBPACK_IMPORTED_MODULE_5__["MessageType"]; });
  1425  
  1426  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8);
  1427  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LogLevel", function() { return _ILogger__WEBPACK_IMPORTED_MODULE_6__["LogLevel"]; });
  1428  
  1429  /* harmony import */ var _ITransport__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(20);
  1430  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HttpTransportType", function() { return _ITransport__WEBPACK_IMPORTED_MODULE_7__["HttpTransportType"]; });
  1431  
  1432  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransferFormat", function() { return _ITransport__WEBPACK_IMPORTED_MODULE_7__["TransferFormat"]; });
  1433  
  1434  /* harmony import */ var _Loggers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(10);
  1435  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullLogger", function() { return _Loggers__WEBPACK_IMPORTED_MODULE_8__["NullLogger"]; });
  1436  
  1437  /* harmony import */ var _JsonHubProtocol__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(25);
  1438  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JsonHubProtocol", function() { return _JsonHubProtocol__WEBPACK_IMPORTED_MODULE_9__["JsonHubProtocol"]; });
  1439  
  1440  /* harmony import */ var _Subject__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(16);
  1441  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Subject", function() { return _Subject__WEBPACK_IMPORTED_MODULE_10__["Subject"]; });
  1442  
  1443  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(9);
  1444  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return _Utils__WEBPACK_IMPORTED_MODULE_11__["VERSION"]; });
  1445  
  1446  // Copyright (c) .NET Foundation. All rights reserved.
  1447  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1448  
  1449  
  1450  
  1451  
  1452  
  1453  
  1454  
  1455  
  1456  
  1457  
  1458  
  1459  
  1460  
  1461  
  1462  /***/ }),
  1463  /* 4 */
  1464  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1465  
  1466  "use strict";
  1467  __webpack_require__.r(__webpack_exports__);
  1468  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HttpError", function() { return HttpError; });
  1469  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TimeoutError", function() { return TimeoutError; });
  1470  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbortError", function() { return AbortError; });
  1471  // Copyright (c) .NET Foundation. All rights reserved.
  1472  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1473  var __extends = (undefined && undefined.__extends) || (function () {
  1474      var extendStatics = Object.setPrototypeOf ||
  1475          ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1476          function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1477      return function (d, b) {
  1478          extendStatics(d, b);
  1479          function __() { this.constructor = d; }
  1480          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1481      };
  1482  })();
  1483  /** Error thrown when an HTTP request fails. */
  1484  var HttpError = /** @class */ (function (_super) {
  1485      __extends(HttpError, _super);
  1486      /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
  1487       *
  1488       * @param {string} errorMessage A descriptive error message.
  1489       * @param {number} statusCode The HTTP status code represented by this error.
  1490       */
  1491      function HttpError(errorMessage, statusCode) {
  1492          var _newTarget = this.constructor;
  1493          var _this = this;
  1494          var trueProto = _newTarget.prototype;
  1495          _this = _super.call(this, errorMessage) || this;
  1496          _this.statusCode = statusCode;
  1497          // Workaround issue in Typescript compiler
  1498          // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  1499          _this.__proto__ = trueProto;
  1500          return _this;
  1501      }
  1502      return HttpError;
  1503  }(Error));
  1504  
  1505  /** Error thrown when a timeout elapses. */
  1506  var TimeoutError = /** @class */ (function (_super) {
  1507      __extends(TimeoutError, _super);
  1508      /** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
  1509       *
  1510       * @param {string} errorMessage A descriptive error message.
  1511       */
  1512      function TimeoutError(errorMessage) {
  1513          var _newTarget = this.constructor;
  1514          if (errorMessage === void 0) { errorMessage = "A timeout occurred."; }
  1515          var _this = this;
  1516          var trueProto = _newTarget.prototype;
  1517          _this = _super.call(this, errorMessage) || this;
  1518          // Workaround issue in Typescript compiler
  1519          // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  1520          _this.__proto__ = trueProto;
  1521          return _this;
  1522      }
  1523      return TimeoutError;
  1524  }(Error));
  1525  
  1526  /** Error thrown when an action is aborted. */
  1527  var AbortError = /** @class */ (function (_super) {
  1528      __extends(AbortError, _super);
  1529      /** Constructs a new instance of {@link AbortError}.
  1530       *
  1531       * @param {string} errorMessage A descriptive error message.
  1532       */
  1533      function AbortError(errorMessage) {
  1534          var _newTarget = this.constructor;
  1535          if (errorMessage === void 0) { errorMessage = "An abort occurred."; }
  1536          var _this = this;
  1537          var trueProto = _newTarget.prototype;
  1538          _this = _super.call(this, errorMessage) || this;
  1539          // Workaround issue in Typescript compiler
  1540          // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
  1541          _this.__proto__ = trueProto;
  1542          return _this;
  1543      }
  1544      return AbortError;
  1545  }(Error));
  1546  
  1547  
  1548  
  1549  /***/ }),
  1550  /* 5 */
  1551  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1552  
  1553  "use strict";
  1554  __webpack_require__.r(__webpack_exports__);
  1555  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HttpResponse", function() { return HttpResponse; });
  1556  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HttpClient", function() { return HttpClient; });
  1557  // Copyright (c) .NET Foundation. All rights reserved.
  1558  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1559  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  1560      for (var s, i = 1, n = arguments.length; i < n; i++) {
  1561          s = arguments[i];
  1562          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1563              t[p] = s[p];
  1564      }
  1565      return t;
  1566  };
  1567  /** Represents an HTTP response. */
  1568  var HttpResponse = /** @class */ (function () {
  1569      function HttpResponse(statusCode, statusText, content) {
  1570          this.statusCode = statusCode;
  1571          this.statusText = statusText;
  1572          this.content = content;
  1573      }
  1574      return HttpResponse;
  1575  }());
  1576  
  1577  /** Abstraction over an HTTP client.
  1578   *
  1579   * This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
  1580   */
  1581  var HttpClient = /** @class */ (function () {
  1582      function HttpClient() {
  1583      }
  1584      HttpClient.prototype.get = function (url, options) {
  1585          return this.send(__assign({}, options, { method: "GET", url: url }));
  1586      };
  1587      HttpClient.prototype.post = function (url, options) {
  1588          return this.send(__assign({}, options, { method: "POST", url: url }));
  1589      };
  1590      HttpClient.prototype.delete = function (url, options) {
  1591          return this.send(__assign({}, options, { method: "DELETE", url: url }));
  1592      };
  1593      /** Gets all cookies that apply to the specified URL.
  1594       *
  1595       * @param url The URL that the cookies are valid for.
  1596       * @returns {string} A string containing all the key-value cookie pairs for the specified URL.
  1597       */
  1598      // @ts-ignore
  1599      HttpClient.prototype.getCookieString = function (url) {
  1600          return "";
  1601      };
  1602      return HttpClient;
  1603  }());
  1604  
  1605  
  1606  
  1607  /***/ }),
  1608  /* 6 */
  1609  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1610  
  1611  "use strict";
  1612  __webpack_require__.r(__webpack_exports__);
  1613  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultHttpClient", function() { return DefaultHttpClient; });
  1614  /* harmony import */ var _Errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
  1615  /* harmony import */ var _FetchHttpClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
  1616  /* harmony import */ var _HttpClient__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
  1617  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
  1618  /* harmony import */ var _XhrHttpClient__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(11);
  1619  // Copyright (c) .NET Foundation. All rights reserved.
  1620  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1621  var __extends = (undefined && undefined.__extends) || (function () {
  1622      var extendStatics = Object.setPrototypeOf ||
  1623          ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1624          function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1625      return function (d, b) {
  1626          extendStatics(d, b);
  1627          function __() { this.constructor = d; }
  1628          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1629      };
  1630  })();
  1631  
  1632  
  1633  
  1634  
  1635  
  1636  /** Default implementation of {@link @microsoft/signalr.HttpClient}. */
  1637  var DefaultHttpClient = /** @class */ (function (_super) {
  1638      __extends(DefaultHttpClient, _super);
  1639      /** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
  1640      function DefaultHttpClient(logger) {
  1641          var _this = _super.call(this) || this;
  1642          if (typeof fetch !== "undefined" || _Utils__WEBPACK_IMPORTED_MODULE_3__["Platform"].isNode) {
  1643              _this.httpClient = new _FetchHttpClient__WEBPACK_IMPORTED_MODULE_1__["FetchHttpClient"](logger);
  1644          }
  1645          else if (typeof XMLHttpRequest !== "undefined") {
  1646              _this.httpClient = new _XhrHttpClient__WEBPACK_IMPORTED_MODULE_4__["XhrHttpClient"](logger);
  1647          }
  1648          else {
  1649              throw new Error("No usable HttpClient found.");
  1650          }
  1651          return _this;
  1652      }
  1653      /** @inheritDoc */
  1654      DefaultHttpClient.prototype.send = function (request) {
  1655          // Check that abort was not signaled before calling send
  1656          if (request.abortSignal && request.abortSignal.aborted) {
  1657              return Promise.reject(new _Errors__WEBPACK_IMPORTED_MODULE_0__["AbortError"]());
  1658          }
  1659          if (!request.method) {
  1660              return Promise.reject(new Error("No method defined."));
  1661          }
  1662          if (!request.url) {
  1663              return Promise.reject(new Error("No url defined."));
  1664          }
  1665          return this.httpClient.send(request);
  1666      };
  1667      DefaultHttpClient.prototype.getCookieString = function (url) {
  1668          return this.httpClient.getCookieString(url);
  1669      };
  1670      return DefaultHttpClient;
  1671  }(_HttpClient__WEBPACK_IMPORTED_MODULE_2__["HttpClient"]));
  1672  
  1673  
  1674  
  1675  /***/ }),
  1676  /* 7 */
  1677  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1678  
  1679  "use strict";
  1680  __webpack_require__.r(__webpack_exports__);
  1681  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FetchHttpClient", function() { return FetchHttpClient; });
  1682  /* harmony import */ var _Errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
  1683  /* harmony import */ var _HttpClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
  1684  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
  1685  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
  1686  // Copyright (c) .NET Foundation. All rights reserved.
  1687  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1688  var __extends = (undefined && undefined.__extends) || (function () {
  1689      var extendStatics = Object.setPrototypeOf ||
  1690          ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1691          function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1692      return function (d, b) {
  1693          extendStatics(d, b);
  1694          function __() { this.constructor = d; }
  1695          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1696      };
  1697  })();
  1698  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  1699      for (var s, i = 1, n = arguments.length; i < n; i++) {
  1700          s = arguments[i];
  1701          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1702              t[p] = s[p];
  1703      }
  1704      return t;
  1705  };
  1706  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  1707      return new (P || (P = Promise))(function (resolve, reject) {
  1708          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1709          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1710          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  1711          step((generator = generator.apply(thisArg, _arguments || [])).next());
  1712      });
  1713  };
  1714  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  1715      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1716      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1717      function verb(n) { return function (v) { return step([n, v]); }; }
  1718      function step(op) {
  1719          if (f) throw new TypeError("Generator is already executing.");
  1720          while (_) try {
  1721              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1722              if (y = 0, t) op = [op[0] & 2, t.value];
  1723              switch (op[0]) {
  1724                  case 0: case 1: t = op; break;
  1725                  case 4: _.label++; return { value: op[1], done: false };
  1726                  case 5: _.label++; y = op[1]; op = [0]; continue;
  1727                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1728                  default:
  1729                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1730                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1731                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1732                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1733                      if (t[2]) _.ops.pop();
  1734                      _.trys.pop(); continue;
  1735              }
  1736              op = body.call(thisArg, _);
  1737          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1738          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1739      }
  1740  };
  1741  
  1742  
  1743  
  1744  
  1745  var FetchHttpClient = /** @class */ (function (_super) {
  1746      __extends(FetchHttpClient, _super);
  1747      function FetchHttpClient(logger) {
  1748          var _this = _super.call(this) || this;
  1749          _this.logger = logger;
  1750          if (typeof fetch === "undefined") {
  1751              // In order to ignore the dynamic require in webpack builds we need to do this magic
  1752              // @ts-ignore: TS doesn't know about these names
  1753              var requireFunc =  true ? require : undefined;
  1754              // Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests
  1755              _this.jar = new (requireFunc("tough-cookie")).CookieJar();
  1756              _this.fetchType = requireFunc("node-fetch");
  1757              // node-fetch doesn't have a nice API for getting and setting cookies
  1758              // fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one
  1759              _this.fetchType = requireFunc("fetch-cookie")(_this.fetchType, _this.jar);
  1760              // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
  1761              _this.abortControllerType = requireFunc("abort-controller");
  1762          }
  1763          else {
  1764              _this.fetchType = fetch.bind(self);
  1765              _this.abortControllerType = AbortController;
  1766          }
  1767          return _this;
  1768      }
  1769      /** @inheritDoc */
  1770      FetchHttpClient.prototype.send = function (request) {
  1771          return __awaiter(this, void 0, void 0, function () {
  1772              var abortController, error, timeoutId, msTimeout, response, e_1, content, payload;
  1773              var _this = this;
  1774              return __generator(this, function (_a) {
  1775                  switch (_a.label) {
  1776                      case 0:
  1777                          // Check that abort was not signaled before calling send
  1778                          if (request.abortSignal && request.abortSignal.aborted) {
  1779                              throw new _Errors__WEBPACK_IMPORTED_MODULE_0__["AbortError"]();
  1780                          }
  1781                          if (!request.method) {
  1782                              throw new Error("No method defined.");
  1783                          }
  1784                          if (!request.url) {
  1785                              throw new Error("No url defined.");
  1786                          }
  1787                          abortController = new this.abortControllerType();
  1788                          // Hook our abortSignal into the abort controller
  1789                          if (request.abortSignal) {
  1790                              request.abortSignal.onabort = function () {
  1791                                  abortController.abort();
  1792                                  error = new _Errors__WEBPACK_IMPORTED_MODULE_0__["AbortError"]();
  1793                              };
  1794                          }
  1795                          timeoutId = null;
  1796                          if (request.timeout) {
  1797                              msTimeout = request.timeout;
  1798                              timeoutId = setTimeout(function () {
  1799                                  abortController.abort();
  1800                                  _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Warning, "Timeout from HTTP request.");
  1801                                  error = new _Errors__WEBPACK_IMPORTED_MODULE_0__["TimeoutError"]();
  1802                              }, msTimeout);
  1803                          }
  1804                          _a.label = 1;
  1805                      case 1:
  1806                          _a.trys.push([1, 3, 4, 5]);
  1807                          return [4 /*yield*/, this.fetchType(request.url, {
  1808                                  body: request.content,
  1809                                  cache: "no-cache",
  1810                                  credentials: request.withCredentials === true ? "include" : "same-origin",
  1811                                  headers: __assign({ "Content-Type": "text/plain;charset=UTF-8", "X-Requested-With": "XMLHttpRequest" }, request.headers),
  1812                                  method: request.method,
  1813                                  mode: "cors",
  1814                                  redirect: "manual",
  1815                                  signal: abortController.signal,
  1816                              })];
  1817                      case 2:
  1818                          response = _a.sent();
  1819                          return [3 /*break*/, 5];
  1820                      case 3:
  1821                          e_1 = _a.sent();
  1822                          if (error) {
  1823                              throw error;
  1824                          }
  1825                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Warning, "Error from HTTP request. " + e_1 + ".");
  1826                          throw e_1;
  1827                      case 4:
  1828                          if (timeoutId) {
  1829                              clearTimeout(timeoutId);
  1830                          }
  1831                          if (request.abortSignal) {
  1832                              request.abortSignal.onabort = null;
  1833                          }
  1834                          return [7 /*endfinally*/];
  1835                      case 5:
  1836                          if (!response.ok) {
  1837                              throw new _Errors__WEBPACK_IMPORTED_MODULE_0__["HttpError"](response.statusText, response.status);
  1838                          }
  1839                          content = deserializeContent(response, request.responseType);
  1840                          return [4 /*yield*/, content];
  1841                      case 6:
  1842                          payload = _a.sent();
  1843                          return [2 /*return*/, new _HttpClient__WEBPACK_IMPORTED_MODULE_1__["HttpResponse"](response.status, response.statusText, payload)];
  1844                  }
  1845              });
  1846          });
  1847      };
  1848      FetchHttpClient.prototype.getCookieString = function (url) {
  1849          var cookies = "";
  1850          if (_Utils__WEBPACK_IMPORTED_MODULE_3__["Platform"].isNode && this.jar) {
  1851              // @ts-ignore: unused variable
  1852              this.jar.getCookies(url, function (e, c) { return cookies = c.join("; "); });
  1853          }
  1854          return cookies;
  1855      };
  1856      return FetchHttpClient;
  1857  }(_HttpClient__WEBPACK_IMPORTED_MODULE_1__["HttpClient"]));
  1858  
  1859  function deserializeContent(response, responseType) {
  1860      var content;
  1861      switch (responseType) {
  1862          case "arraybuffer":
  1863              content = response.arrayBuffer();
  1864              break;
  1865          case "text":
  1866              content = response.text();
  1867              break;
  1868          case "blob":
  1869          case "document":
  1870          case "json":
  1871              throw new Error(responseType + " is not supported.");
  1872          default:
  1873              content = response.text();
  1874              break;
  1875      }
  1876      return content;
  1877  }
  1878  
  1879  
  1880  /***/ }),
  1881  /* 8 */
  1882  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1883  
  1884  "use strict";
  1885  __webpack_require__.r(__webpack_exports__);
  1886  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LogLevel", function() { return LogLevel; });
  1887  // Copyright (c) .NET Foundation. All rights reserved.
  1888  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1889  // These values are designed to match the ASP.NET Log Levels since that's the pattern we're emulating here.
  1890  /** Indicates the severity of a log message.
  1891   *
  1892   * Log Levels are ordered in increasing severity. So `Debug` is more severe than `Trace`, etc.
  1893   */
  1894  var LogLevel;
  1895  (function (LogLevel) {
  1896      /** Log level for very low severity diagnostic messages. */
  1897      LogLevel[LogLevel["Trace"] = 0] = "Trace";
  1898      /** Log level for low severity diagnostic messages. */
  1899      LogLevel[LogLevel["Debug"] = 1] = "Debug";
  1900      /** Log level for informational diagnostic messages. */
  1901      LogLevel[LogLevel["Information"] = 2] = "Information";
  1902      /** Log level for diagnostic messages that indicate a non-fatal problem. */
  1903      LogLevel[LogLevel["Warning"] = 3] = "Warning";
  1904      /** Log level for diagnostic messages that indicate a failure in the current operation. */
  1905      LogLevel[LogLevel["Error"] = 4] = "Error";
  1906      /** Log level for diagnostic messages that indicate a failure that will terminate the entire application. */
  1907      LogLevel[LogLevel["Critical"] = 5] = "Critical";
  1908      /** The highest possible log level. Used when configuring logging to indicate that no log messages should be emitted. */
  1909      LogLevel[LogLevel["None"] = 6] = "None";
  1910  })(LogLevel || (LogLevel = {}));
  1911  
  1912  
  1913  /***/ }),
  1914  /* 9 */
  1915  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1916  
  1917  "use strict";
  1918  __webpack_require__.r(__webpack_exports__);
  1919  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VERSION", function() { return VERSION; });
  1920  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arg", function() { return Arg; });
  1921  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Platform", function() { return Platform; });
  1922  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDataDetail", function() { return getDataDetail; });
  1923  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatArrayBuffer", function() { return formatArrayBuffer; });
  1924  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isArrayBuffer", function() { return isArrayBuffer; });
  1925  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sendMessage", function() { return sendMessage; });
  1926  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createLogger", function() { return createLogger; });
  1927  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubjectSubscription", function() { return SubjectSubscription; });
  1928  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConsoleLogger", function() { return ConsoleLogger; });
  1929  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUserAgentHeader", function() { return getUserAgentHeader; });
  1930  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "constructUserAgent", function() { return constructUserAgent; });
  1931  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
  1932  /* harmony import */ var _Loggers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
  1933  // Copyright (c) .NET Foundation. All rights reserved.
  1934  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  1935  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  1936      for (var s, i = 1, n = arguments.length; i < n; i++) {
  1937          s = arguments[i];
  1938          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1939              t[p] = s[p];
  1940      }
  1941      return t;
  1942  };
  1943  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  1944      return new (P || (P = Promise))(function (resolve, reject) {
  1945          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1946          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1947          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  1948          step((generator = generator.apply(thisArg, _arguments || [])).next());
  1949      });
  1950  };
  1951  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  1952      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1953      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1954      function verb(n) { return function (v) { return step([n, v]); }; }
  1955      function step(op) {
  1956          if (f) throw new TypeError("Generator is already executing.");
  1957          while (_) try {
  1958              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1959              if (y = 0, t) op = [op[0] & 2, t.value];
  1960              switch (op[0]) {
  1961                  case 0: case 1: t = op; break;
  1962                  case 4: _.label++; return { value: op[1], done: false };
  1963                  case 5: _.label++; y = op[1]; op = [0]; continue;
  1964                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1965                  default:
  1966                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1967                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1968                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1969                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1970                      if (t[2]) _.ops.pop();
  1971                      _.trys.pop(); continue;
  1972              }
  1973              op = body.call(thisArg, _);
  1974          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1975          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1976      }
  1977  };
  1978  
  1979  
  1980  // Version token that will be replaced by the prepack command
  1981  /** The version of the SignalR client. */
  1982  var VERSION = "5.0.4";
  1983  /** @private */
  1984  var Arg = /** @class */ (function () {
  1985      function Arg() {
  1986      }
  1987      Arg.isRequired = function (val, name) {
  1988          if (val === null || val === undefined) {
  1989              throw new Error("The '" + name + "' argument is required.");
  1990          }
  1991      };
  1992      Arg.isNotEmpty = function (val, name) {
  1993          if (!val || val.match(/^\s*$/)) {
  1994              throw new Error("The '" + name + "' argument should not be empty.");
  1995          }
  1996      };
  1997      Arg.isIn = function (val, values, name) {
  1998          // TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.
  1999          if (!(val in values)) {
  2000              throw new Error("Unknown " + name + " value: " + val + ".");
  2001          }
  2002      };
  2003      return Arg;
  2004  }());
  2005  
  2006  /** @private */
  2007  var Platform = /** @class */ (function () {
  2008      function Platform() {
  2009      }
  2010      Object.defineProperty(Platform, "isBrowser", {
  2011          get: function () {
  2012              return typeof window === "object";
  2013          },
  2014          enumerable: true,
  2015          configurable: true
  2016      });
  2017      Object.defineProperty(Platform, "isWebWorker", {
  2018          get: function () {
  2019              return typeof self === "object" && "importScripts" in self;
  2020          },
  2021          enumerable: true,
  2022          configurable: true
  2023      });
  2024      Object.defineProperty(Platform, "isNode", {
  2025          get: function () {
  2026              return !this.isBrowser && !this.isWebWorker;
  2027          },
  2028          enumerable: true,
  2029          configurable: true
  2030      });
  2031      return Platform;
  2032  }());
  2033  
  2034  /** @private */
  2035  function getDataDetail(data, includeContent) {
  2036      var detail = "";
  2037      if (isArrayBuffer(data)) {
  2038          detail = "Binary data of length " + data.byteLength;
  2039          if (includeContent) {
  2040              detail += ". Content: '" + formatArrayBuffer(data) + "'";
  2041          }
  2042      }
  2043      else if (typeof data === "string") {
  2044          detail = "String data of length " + data.length;
  2045          if (includeContent) {
  2046              detail += ". Content: '" + data + "'";
  2047          }
  2048      }
  2049      return detail;
  2050  }
  2051  /** @private */
  2052  function formatArrayBuffer(data) {
  2053      var view = new Uint8Array(data);
  2054      // Uint8Array.map only supports returning another Uint8Array?
  2055      var str = "";
  2056      view.forEach(function (num) {
  2057          var pad = num < 16 ? "0" : "";
  2058          str += "0x" + pad + num.toString(16) + " ";
  2059      });
  2060      // Trim of trailing space.
  2061      return str.substr(0, str.length - 1);
  2062  }
  2063  // Also in signalr-protocol-msgpack/Utils.ts
  2064  /** @private */
  2065  function isArrayBuffer(val) {
  2066      return val && typeof ArrayBuffer !== "undefined" &&
  2067          (val instanceof ArrayBuffer ||
  2068              // Sometimes we get an ArrayBuffer that doesn't satisfy instanceof
  2069              (val.constructor && val.constructor.name === "ArrayBuffer"));
  2070  }
  2071  /** @private */
  2072  function sendMessage(logger, transportName, httpClient, url, accessTokenFactory, content, logMessageContent, withCredentials, defaultHeaders) {
  2073      return __awaiter(this, void 0, void 0, function () {
  2074          var _a, headers, token, _b, name, value, responseType, response;
  2075          return __generator(this, function (_c) {
  2076              switch (_c.label) {
  2077                  case 0:
  2078                      headers = {};
  2079                      if (!accessTokenFactory) return [3 /*break*/, 2];
  2080                      return [4 /*yield*/, accessTokenFactory()];
  2081                  case 1:
  2082                      token = _c.sent();
  2083                      if (token) {
  2084                          headers = (_a = {},
  2085                              _a["Authorization"] = "Bearer " + token,
  2086                              _a);
  2087                      }
  2088                      _c.label = 2;
  2089                  case 2:
  2090                      _b = getUserAgentHeader(), name = _b[0], value = _b[1];
  2091                      headers[name] = value;
  2092                      logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(" + transportName + " transport) sending data. " + getDataDetail(content, logMessageContent) + ".");
  2093                      responseType = isArrayBuffer(content) ? "arraybuffer" : "text";
  2094                      return [4 /*yield*/, httpClient.post(url, {
  2095                              content: content,
  2096                              headers: __assign({}, headers, defaultHeaders),
  2097                              responseType: responseType,
  2098                              withCredentials: withCredentials,
  2099                          })];
  2100                  case 3:
  2101                      response = _c.sent();
  2102                      logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(" + transportName + " transport) request complete. Response status: " + response.statusCode + ".");
  2103                      return [2 /*return*/];
  2104              }
  2105          });
  2106      });
  2107  }
  2108  /** @private */
  2109  function createLogger(logger) {
  2110      if (logger === undefined) {
  2111          return new ConsoleLogger(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Information);
  2112      }
  2113      if (logger === null) {
  2114          return _Loggers__WEBPACK_IMPORTED_MODULE_1__["NullLogger"].instance;
  2115      }
  2116      if (logger.log) {
  2117          return logger;
  2118      }
  2119      return new ConsoleLogger(logger);
  2120  }
  2121  /** @private */
  2122  var SubjectSubscription = /** @class */ (function () {
  2123      function SubjectSubscription(subject, observer) {
  2124          this.subject = subject;
  2125          this.observer = observer;
  2126      }
  2127      SubjectSubscription.prototype.dispose = function () {
  2128          var index = this.subject.observers.indexOf(this.observer);
  2129          if (index > -1) {
  2130              this.subject.observers.splice(index, 1);
  2131          }
  2132          if (this.subject.observers.length === 0 && this.subject.cancelCallback) {
  2133              this.subject.cancelCallback().catch(function (_) { });
  2134          }
  2135      };
  2136      return SubjectSubscription;
  2137  }());
  2138  
  2139  /** @private */
  2140  var ConsoleLogger = /** @class */ (function () {
  2141      function ConsoleLogger(minimumLogLevel) {
  2142          this.minimumLogLevel = minimumLogLevel;
  2143          this.outputConsole = console;
  2144      }
  2145      ConsoleLogger.prototype.log = function (logLevel, message) {
  2146          if (logLevel >= this.minimumLogLevel) {
  2147              switch (logLevel) {
  2148                  case _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Critical:
  2149                  case _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Error:
  2150                      this.outputConsole.error("[" + new Date().toISOString() + "] " + _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"][logLevel] + ": " + message);
  2151                      break;
  2152                  case _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Warning:
  2153                      this.outputConsole.warn("[" + new Date().toISOString() + "] " + _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"][logLevel] + ": " + message);
  2154                      break;
  2155                  case _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Information:
  2156                      this.outputConsole.info("[" + new Date().toISOString() + "] " + _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"][logLevel] + ": " + message);
  2157                      break;
  2158                  default:
  2159                      // console.debug only goes to attached debuggers in Node, so we use console.log for Trace and Debug
  2160                      this.outputConsole.log("[" + new Date().toISOString() + "] " + _ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"][logLevel] + ": " + message);
  2161                      break;
  2162              }
  2163          }
  2164      };
  2165      return ConsoleLogger;
  2166  }());
  2167  
  2168  /** @private */
  2169  function getUserAgentHeader() {
  2170      var userAgentHeaderName = "X-SignalR-User-Agent";
  2171      if (Platform.isNode) {
  2172          userAgentHeaderName = "User-Agent";
  2173      }
  2174      return [userAgentHeaderName, constructUserAgent(VERSION, getOsName(), getRuntime(), getRuntimeVersion())];
  2175  }
  2176  /** @private */
  2177  function constructUserAgent(version, os, runtime, runtimeVersion) {
  2178      // Microsoft SignalR/[Version] ([Detailed Version]; [Operating System]; [Runtime]; [Runtime Version])
  2179      var userAgent = "Microsoft SignalR/";
  2180      var majorAndMinor = version.split(".");
  2181      userAgent += majorAndMinor[0] + "." + majorAndMinor[1];
  2182      userAgent += " (" + version + "; ";
  2183      if (os && os !== "") {
  2184          userAgent += os + "; ";
  2185      }
  2186      else {
  2187          userAgent += "Unknown OS; ";
  2188      }
  2189      userAgent += "" + runtime;
  2190      if (runtimeVersion) {
  2191          userAgent += "; " + runtimeVersion;
  2192      }
  2193      else {
  2194          userAgent += "; Unknown Runtime Version";
  2195      }
  2196      userAgent += ")";
  2197      return userAgent;
  2198  }
  2199  function getOsName() {
  2200      if (Platform.isNode) {
  2201          switch (process.platform) {
  2202              case "win32":
  2203                  return "Windows NT";
  2204              case "darwin":
  2205                  return "macOS";
  2206              case "linux":
  2207                  return "Linux";
  2208              default:
  2209                  return process.platform;
  2210          }
  2211      }
  2212      else {
  2213          return "";
  2214      }
  2215  }
  2216  function getRuntimeVersion() {
  2217      if (Platform.isNode) {
  2218          return process.versions.node;
  2219      }
  2220      return undefined;
  2221  }
  2222  function getRuntime() {
  2223      if (Platform.isNode) {
  2224          return "NodeJS";
  2225      }
  2226      else {
  2227          return "Browser";
  2228      }
  2229  }
  2230  
  2231  
  2232  /***/ }),
  2233  /* 10 */
  2234  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2235  
  2236  "use strict";
  2237  __webpack_require__.r(__webpack_exports__);
  2238  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullLogger", function() { return NullLogger; });
  2239  // Copyright (c) .NET Foundation. All rights reserved.
  2240  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  2241  /** A logger that does nothing when log messages are sent to it. */
  2242  var NullLogger = /** @class */ (function () {
  2243      function NullLogger() {
  2244      }
  2245      /** @inheritDoc */
  2246      // tslint:disable-next-line
  2247      NullLogger.prototype.log = function (_logLevel, _message) {
  2248      };
  2249      /** The singleton instance of the {@link @microsoft/signalr.NullLogger}. */
  2250      NullLogger.instance = new NullLogger();
  2251      return NullLogger;
  2252  }());
  2253  
  2254  
  2255  
  2256  /***/ }),
  2257  /* 11 */
  2258  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2259  
  2260  "use strict";
  2261  __webpack_require__.r(__webpack_exports__);
  2262  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XhrHttpClient", function() { return XhrHttpClient; });
  2263  /* harmony import */ var _Errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
  2264  /* harmony import */ var _HttpClient__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
  2265  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
  2266  // Copyright (c) .NET Foundation. All rights reserved.
  2267  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  2268  var __extends = (undefined && undefined.__extends) || (function () {
  2269      var extendStatics = Object.setPrototypeOf ||
  2270          ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2271          function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2272      return function (d, b) {
  2273          extendStatics(d, b);
  2274          function __() { this.constructor = d; }
  2275          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2276      };
  2277  })();
  2278  
  2279  
  2280  
  2281  var XhrHttpClient = /** @class */ (function (_super) {
  2282      __extends(XhrHttpClient, _super);
  2283      function XhrHttpClient(logger) {
  2284          var _this = _super.call(this) || this;
  2285          _this.logger = logger;
  2286          return _this;
  2287      }
  2288      /** @inheritDoc */
  2289      XhrHttpClient.prototype.send = function (request) {
  2290          var _this = this;
  2291          // Check that abort was not signaled before calling send
  2292          if (request.abortSignal && request.abortSignal.aborted) {
  2293              return Promise.reject(new _Errors__WEBPACK_IMPORTED_MODULE_0__["AbortError"]());
  2294          }
  2295          if (!request.method) {
  2296              return Promise.reject(new Error("No method defined."));
  2297          }
  2298          if (!request.url) {
  2299              return Promise.reject(new Error("No url defined."));
  2300          }
  2301          return new Promise(function (resolve, reject) {
  2302              var xhr = new XMLHttpRequest();
  2303              xhr.open(request.method, request.url, true);
  2304              xhr.withCredentials = request.withCredentials === undefined ? true : request.withCredentials;
  2305              xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  2306              // Explicitly setting the Content-Type header for React Native on Android platform.
  2307              xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
  2308              var headers = request.headers;
  2309              if (headers) {
  2310                  Object.keys(headers)
  2311                      .forEach(function (header) {
  2312                      xhr.setRequestHeader(header, headers[header]);
  2313                  });
  2314              }
  2315              if (request.responseType) {
  2316                  xhr.responseType = request.responseType;
  2317              }
  2318              if (request.abortSignal) {
  2319                  request.abortSignal.onabort = function () {
  2320                      xhr.abort();
  2321                      reject(new _Errors__WEBPACK_IMPORTED_MODULE_0__["AbortError"]());
  2322                  };
  2323              }
  2324              if (request.timeout) {
  2325                  xhr.timeout = request.timeout;
  2326              }
  2327              xhr.onload = function () {
  2328                  if (request.abortSignal) {
  2329                      request.abortSignal.onabort = null;
  2330                  }
  2331                  if (xhr.status >= 200 && xhr.status < 300) {
  2332                      resolve(new _HttpClient__WEBPACK_IMPORTED_MODULE_1__["HttpResponse"](xhr.status, xhr.statusText, xhr.response || xhr.responseText));
  2333                  }
  2334                  else {
  2335                      reject(new _Errors__WEBPACK_IMPORTED_MODULE_0__["HttpError"](xhr.statusText, xhr.status));
  2336                  }
  2337              };
  2338              xhr.onerror = function () {
  2339                  _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Warning, "Error from HTTP request. " + xhr.status + ": " + xhr.statusText + ".");
  2340                  reject(new _Errors__WEBPACK_IMPORTED_MODULE_0__["HttpError"](xhr.statusText, xhr.status));
  2341              };
  2342              xhr.ontimeout = function () {
  2343                  _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Warning, "Timeout from HTTP request.");
  2344                  reject(new _Errors__WEBPACK_IMPORTED_MODULE_0__["TimeoutError"]());
  2345              };
  2346              xhr.send(request.content || "");
  2347          });
  2348      };
  2349      return XhrHttpClient;
  2350  }(_HttpClient__WEBPACK_IMPORTED_MODULE_1__["HttpClient"]));
  2351  
  2352  
  2353  
  2354  /***/ }),
  2355  /* 12 */
  2356  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2357  
  2358  "use strict";
  2359  __webpack_require__.r(__webpack_exports__);
  2360  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HubConnectionState", function() { return HubConnectionState; });
  2361  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HubConnection", function() { return HubConnection; });
  2362  /* harmony import */ var _HandshakeProtocol__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
  2363  /* harmony import */ var _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
  2364  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
  2365  /* harmony import */ var _Subject__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
  2366  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
  2367  // Copyright (c) .NET Foundation. All rights reserved.
  2368  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  2369  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2370      return new (P || (P = Promise))(function (resolve, reject) {
  2371          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2372          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2373          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  2374          step((generator = generator.apply(thisArg, _arguments || [])).next());
  2375      });
  2376  };
  2377  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  2378      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2379      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2380      function verb(n) { return function (v) { return step([n, v]); }; }
  2381      function step(op) {
  2382          if (f) throw new TypeError("Generator is already executing.");
  2383          while (_) try {
  2384              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  2385              if (y = 0, t) op = [op[0] & 2, t.value];
  2386              switch (op[0]) {
  2387                  case 0: case 1: t = op; break;
  2388                  case 4: _.label++; return { value: op[1], done: false };
  2389                  case 5: _.label++; y = op[1]; op = [0]; continue;
  2390                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2391                  default:
  2392                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  2393                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  2394                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  2395                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  2396                      if (t[2]) _.ops.pop();
  2397                      _.trys.pop(); continue;
  2398              }
  2399              op = body.call(thisArg, _);
  2400          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  2401          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  2402      }
  2403  };
  2404  
  2405  
  2406  
  2407  
  2408  
  2409  var DEFAULT_TIMEOUT_IN_MS = 30 * 1000;
  2410  var DEFAULT_PING_INTERVAL_IN_MS = 15 * 1000;
  2411  /** Describes the current state of the {@link HubConnection} to the server. */
  2412  var HubConnectionState;
  2413  (function (HubConnectionState) {
  2414      /** The hub connection is disconnected. */
  2415      HubConnectionState["Disconnected"] = "Disconnected";
  2416      /** The hub connection is connecting. */
  2417      HubConnectionState["Connecting"] = "Connecting";
  2418      /** The hub connection is connected. */
  2419      HubConnectionState["Connected"] = "Connected";
  2420      /** The hub connection is disconnecting. */
  2421      HubConnectionState["Disconnecting"] = "Disconnecting";
  2422      /** The hub connection is reconnecting. */
  2423      HubConnectionState["Reconnecting"] = "Reconnecting";
  2424  })(HubConnectionState || (HubConnectionState = {}));
  2425  /** Represents a connection to a SignalR Hub. */
  2426  var HubConnection = /** @class */ (function () {
  2427      function HubConnection(connection, logger, protocol, reconnectPolicy) {
  2428          var _this = this;
  2429          _Utils__WEBPACK_IMPORTED_MODULE_4__["Arg"].isRequired(connection, "connection");
  2430          _Utils__WEBPACK_IMPORTED_MODULE_4__["Arg"].isRequired(logger, "logger");
  2431          _Utils__WEBPACK_IMPORTED_MODULE_4__["Arg"].isRequired(protocol, "protocol");
  2432          this.serverTimeoutInMilliseconds = DEFAULT_TIMEOUT_IN_MS;
  2433          this.keepAliveIntervalInMilliseconds = DEFAULT_PING_INTERVAL_IN_MS;
  2434          this.logger = logger;
  2435          this.protocol = protocol;
  2436          this.connection = connection;
  2437          this.reconnectPolicy = reconnectPolicy;
  2438          this.handshakeProtocol = new _HandshakeProtocol__WEBPACK_IMPORTED_MODULE_0__["HandshakeProtocol"]();
  2439          this.connection.onreceive = function (data) { return _this.processIncomingData(data); };
  2440          this.connection.onclose = function (error) { return _this.connectionClosed(error); };
  2441          this.callbacks = {};
  2442          this.methods = {};
  2443          this.closedCallbacks = [];
  2444          this.reconnectingCallbacks = [];
  2445          this.reconnectedCallbacks = [];
  2446          this.invocationId = 0;
  2447          this.receivedHandshakeResponse = false;
  2448          this.connectionState = HubConnectionState.Disconnected;
  2449          this.connectionStarted = false;
  2450          this.cachedPingMessage = this.protocol.writeMessage({ type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Ping });
  2451      }
  2452      /** @internal */
  2453      // Using a public static factory method means we can have a private constructor and an _internal_
  2454      // create method that can be used by HubConnectionBuilder. An "internal" constructor would just
  2455      // be stripped away and the '.d.ts' file would have no constructor, which is interpreted as a
  2456      // public parameter-less constructor.
  2457      HubConnection.create = function (connection, logger, protocol, reconnectPolicy) {
  2458          return new HubConnection(connection, logger, protocol, reconnectPolicy);
  2459      };
  2460      Object.defineProperty(HubConnection.prototype, "state", {
  2461          /** Indicates the state of the {@link HubConnection} to the server. */
  2462          get: function () {
  2463              return this.connectionState;
  2464          },
  2465          enumerable: true,
  2466          configurable: true
  2467      });
  2468      Object.defineProperty(HubConnection.prototype, "connectionId", {
  2469          /** Represents the connection id of the {@link HubConnection} on the server. The connection id will be null when the connection is either
  2470           *  in the disconnected state or if the negotiation step was skipped.
  2471           */
  2472          get: function () {
  2473              return this.connection ? (this.connection.connectionId || null) : null;
  2474          },
  2475          enumerable: true,
  2476          configurable: true
  2477      });
  2478      Object.defineProperty(HubConnection.prototype, "baseUrl", {
  2479          /** Indicates the url of the {@link HubConnection} to the server. */
  2480          get: function () {
  2481              return this.connection.baseUrl || "";
  2482          },
  2483          /**
  2484           * Sets a new url for the HubConnection. Note that the url can only be changed when the connection is in either the Disconnected or
  2485           * Reconnecting states.
  2486           * @param {string} url The url to connect to.
  2487           */
  2488          set: function (url) {
  2489              if (this.connectionState !== HubConnectionState.Disconnected && this.connectionState !== HubConnectionState.Reconnecting) {
  2490                  throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");
  2491              }
  2492              if (!url) {
  2493                  throw new Error("The HubConnection url must be a valid url.");
  2494              }
  2495              this.connection.baseUrl = url;
  2496          },
  2497          enumerable: true,
  2498          configurable: true
  2499      });
  2500      /** Starts the connection.
  2501       *
  2502       * @returns {Promise<void>} A Promise that resolves when the connection has been successfully established, or rejects with an error.
  2503       */
  2504      HubConnection.prototype.start = function () {
  2505          this.startPromise = this.startWithStateTransitions();
  2506          return this.startPromise;
  2507      };
  2508      HubConnection.prototype.startWithStateTransitions = function () {
  2509          return __awaiter(this, void 0, void 0, function () {
  2510              var e_1;
  2511              return __generator(this, function (_a) {
  2512                  switch (_a.label) {
  2513                      case 0:
  2514                          if (this.connectionState !== HubConnectionState.Disconnected) {
  2515                              return [2 /*return*/, Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."))];
  2516                          }
  2517                          this.connectionState = HubConnectionState.Connecting;
  2518                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Starting HubConnection.");
  2519                          _a.label = 1;
  2520                      case 1:
  2521                          _a.trys.push([1, 3, , 4]);
  2522                          return [4 /*yield*/, this.startInternal()];
  2523                      case 2:
  2524                          _a.sent();
  2525                          this.connectionState = HubConnectionState.Connected;
  2526                          this.connectionStarted = true;
  2527                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "HubConnection connected successfully.");
  2528                          return [3 /*break*/, 4];
  2529                      case 3:
  2530                          e_1 = _a.sent();
  2531                          this.connectionState = HubConnectionState.Disconnected;
  2532                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "HubConnection failed to start successfully because of error '" + e_1 + "'.");
  2533                          return [2 /*return*/, Promise.reject(e_1)];
  2534                      case 4: return [2 /*return*/];
  2535                  }
  2536              });
  2537          });
  2538      };
  2539      HubConnection.prototype.startInternal = function () {
  2540          return __awaiter(this, void 0, void 0, function () {
  2541              var handshakePromise, handshakeRequest, e_2;
  2542              var _this = this;
  2543              return __generator(this, function (_a) {
  2544                  switch (_a.label) {
  2545                      case 0:
  2546                          this.stopDuringStartError = undefined;
  2547                          this.receivedHandshakeResponse = false;
  2548                          handshakePromise = new Promise(function (resolve, reject) {
  2549                              _this.handshakeResolver = resolve;
  2550                              _this.handshakeRejecter = reject;
  2551                          });
  2552                          return [4 /*yield*/, this.connection.start(this.protocol.transferFormat)];
  2553                      case 1:
  2554                          _a.sent();
  2555                          _a.label = 2;
  2556                      case 2:
  2557                          _a.trys.push([2, 5, , 7]);
  2558                          handshakeRequest = {
  2559                              protocol: this.protocol.name,
  2560                              version: this.protocol.version,
  2561                          };
  2562                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Sending handshake request.");
  2563                          return [4 /*yield*/, this.sendMessage(this.handshakeProtocol.writeHandshakeRequest(handshakeRequest))];
  2564                      case 3:
  2565                          _a.sent();
  2566                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Using HubProtocol '" + this.protocol.name + "'.");
  2567                          // defensively cleanup timeout in case we receive a message from the server before we finish start
  2568                          this.cleanupTimeout();
  2569                          this.resetTimeoutPeriod();
  2570                          this.resetKeepAliveInterval();
  2571                          return [4 /*yield*/, handshakePromise];
  2572                      case 4:
  2573                          _a.sent();
  2574                          // It's important to check the stopDuringStartError instead of just relying on the handshakePromise
  2575                          // being rejected on close, because this continuation can run after both the handshake completed successfully
  2576                          // and the connection was closed.
  2577                          if (this.stopDuringStartError) {
  2578                              // It's important to throw instead of returning a rejected promise, because we don't want to allow any state
  2579                              // transitions to occur between now and the calling code observing the exceptions. Returning a rejected promise
  2580                              // will cause the calling continuation to get scheduled to run later.
  2581                              throw this.stopDuringStartError;
  2582                          }
  2583                          return [3 /*break*/, 7];
  2584                      case 5:
  2585                          e_2 = _a.sent();
  2586                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Hub handshake failed with error '" + e_2 + "' during start(). Stopping HubConnection.");
  2587                          this.cleanupTimeout();
  2588                          this.cleanupPingTimer();
  2589                          // HttpConnection.stop() should not complete until after the onclose callback is invoked.
  2590                          // This will transition the HubConnection to the disconnected state before HttpConnection.stop() completes.
  2591                          return [4 /*yield*/, this.connection.stop(e_2)];
  2592                      case 6:
  2593                          // HttpConnection.stop() should not complete until after the onclose callback is invoked.
  2594                          // This will transition the HubConnection to the disconnected state before HttpConnection.stop() completes.
  2595                          _a.sent();
  2596                          throw e_2;
  2597                      case 7: return [2 /*return*/];
  2598                  }
  2599              });
  2600          });
  2601      };
  2602      /** Stops the connection.
  2603       *
  2604       * @returns {Promise<void>} A Promise that resolves when the connection has been successfully terminated, or rejects with an error.
  2605       */
  2606      HubConnection.prototype.stop = function () {
  2607          return __awaiter(this, void 0, void 0, function () {
  2608              var startPromise, e_3;
  2609              return __generator(this, function (_a) {
  2610                  switch (_a.label) {
  2611                      case 0:
  2612                          startPromise = this.startPromise;
  2613                          this.stopPromise = this.stopInternal();
  2614                          return [4 /*yield*/, this.stopPromise];
  2615                      case 1:
  2616                          _a.sent();
  2617                          _a.label = 2;
  2618                      case 2:
  2619                          _a.trys.push([2, 4, , 5]);
  2620                          // Awaiting undefined continues immediately
  2621                          return [4 /*yield*/, startPromise];
  2622                      case 3:
  2623                          // Awaiting undefined continues immediately
  2624                          _a.sent();
  2625                          return [3 /*break*/, 5];
  2626                      case 4:
  2627                          e_3 = _a.sent();
  2628                          return [3 /*break*/, 5];
  2629                      case 5: return [2 /*return*/];
  2630                  }
  2631              });
  2632          });
  2633      };
  2634      HubConnection.prototype.stopInternal = function (error) {
  2635          if (this.connectionState === HubConnectionState.Disconnected) {
  2636              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Call to HubConnection.stop(" + error + ") ignored because it is already in the disconnected state.");
  2637              return Promise.resolve();
  2638          }
  2639          if (this.connectionState === HubConnectionState.Disconnecting) {
  2640              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Call to HttpConnection.stop(" + error + ") ignored because the connection is already in the disconnecting state.");
  2641              return this.stopPromise;
  2642          }
  2643          this.connectionState = HubConnectionState.Disconnecting;
  2644          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Stopping HubConnection.");
  2645          if (this.reconnectDelayHandle) {
  2646              // We're in a reconnect delay which means the underlying connection is currently already stopped.
  2647              // Just clear the handle to stop the reconnect loop (which no one is waiting on thankfully) and
  2648              // fire the onclose callbacks.
  2649              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Connection stopped during reconnect delay. Done reconnecting.");
  2650              clearTimeout(this.reconnectDelayHandle);
  2651              this.reconnectDelayHandle = undefined;
  2652              this.completeClose();
  2653              return Promise.resolve();
  2654          }
  2655          this.cleanupTimeout();
  2656          this.cleanupPingTimer();
  2657          this.stopDuringStartError = error || new Error("The connection was stopped before the hub handshake could complete.");
  2658          // HttpConnection.stop() should not complete until after either HttpConnection.start() fails
  2659          // or the onclose callback is invoked. The onclose callback will transition the HubConnection
  2660          // to the disconnected state if need be before HttpConnection.stop() completes.
  2661          return this.connection.stop(error);
  2662      };
  2663      /** Invokes a streaming hub method on the server using the specified name and arguments.
  2664       *
  2665       * @typeparam T The type of the items returned by the server.
  2666       * @param {string} methodName The name of the server method to invoke.
  2667       * @param {any[]} args The arguments used to invoke the server method.
  2668       * @returns {IStreamResult<T>} An object that yields results from the server as they are received.
  2669       */
  2670      HubConnection.prototype.stream = function (methodName) {
  2671          var _this = this;
  2672          var args = [];
  2673          for (var _i = 1; _i < arguments.length; _i++) {
  2674              args[_i - 1] = arguments[_i];
  2675          }
  2676          var _a = this.replaceStreamingParams(args), streams = _a[0], streamIds = _a[1];
  2677          var invocationDescriptor = this.createStreamInvocation(methodName, args, streamIds);
  2678          var promiseQueue;
  2679          var subject = new _Subject__WEBPACK_IMPORTED_MODULE_3__["Subject"]();
  2680          subject.cancelCallback = function () {
  2681              var cancelInvocation = _this.createCancelInvocation(invocationDescriptor.invocationId);
  2682              delete _this.callbacks[invocationDescriptor.invocationId];
  2683              return promiseQueue.then(function () {
  2684                  return _this.sendWithProtocol(cancelInvocation);
  2685              });
  2686          };
  2687          this.callbacks[invocationDescriptor.invocationId] = function (invocationEvent, error) {
  2688              if (error) {
  2689                  subject.error(error);
  2690                  return;
  2691              }
  2692              else if (invocationEvent) {
  2693                  // invocationEvent will not be null when an error is not passed to the callback
  2694                  if (invocationEvent.type === _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Completion) {
  2695                      if (invocationEvent.error) {
  2696                          subject.error(new Error(invocationEvent.error));
  2697                      }
  2698                      else {
  2699                          subject.complete();
  2700                      }
  2701                  }
  2702                  else {
  2703                      subject.next((invocationEvent.item));
  2704                  }
  2705              }
  2706          };
  2707          promiseQueue = this.sendWithProtocol(invocationDescriptor)
  2708              .catch(function (e) {
  2709              subject.error(e);
  2710              delete _this.callbacks[invocationDescriptor.invocationId];
  2711          });
  2712          this.launchStreams(streams, promiseQueue);
  2713          return subject;
  2714      };
  2715      HubConnection.prototype.sendMessage = function (message) {
  2716          this.resetKeepAliveInterval();
  2717          return this.connection.send(message);
  2718      };
  2719      /**
  2720       * Sends a js object to the server.
  2721       * @param message The js object to serialize and send.
  2722       */
  2723      HubConnection.prototype.sendWithProtocol = function (message) {
  2724          return this.sendMessage(this.protocol.writeMessage(message));
  2725      };
  2726      /** Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver.
  2727       *
  2728       * The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still
  2729       * be processing the invocation.
  2730       *
  2731       * @param {string} methodName The name of the server method to invoke.
  2732       * @param {any[]} args The arguments used to invoke the server method.
  2733       * @returns {Promise<void>} A Promise that resolves when the invocation has been successfully sent, or rejects with an error.
  2734       */
  2735      HubConnection.prototype.send = function (methodName) {
  2736          var args = [];
  2737          for (var _i = 1; _i < arguments.length; _i++) {
  2738              args[_i - 1] = arguments[_i];
  2739          }
  2740          var _a = this.replaceStreamingParams(args), streams = _a[0], streamIds = _a[1];
  2741          var sendPromise = this.sendWithProtocol(this.createInvocation(methodName, args, true, streamIds));
  2742          this.launchStreams(streams, sendPromise);
  2743          return sendPromise;
  2744      };
  2745      /** Invokes a hub method on the server using the specified name and arguments.
  2746       *
  2747       * The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise
  2748       * resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of
  2749       * resolving the Promise.
  2750       *
  2751       * @typeparam T The expected return type.
  2752       * @param {string} methodName The name of the server method to invoke.
  2753       * @param {any[]} args The arguments used to invoke the server method.
  2754       * @returns {Promise<T>} A Promise that resolves with the result of the server method (if any), or rejects with an error.
  2755       */
  2756      HubConnection.prototype.invoke = function (methodName) {
  2757          var _this = this;
  2758          var args = [];
  2759          for (var _i = 1; _i < arguments.length; _i++) {
  2760              args[_i - 1] = arguments[_i];
  2761          }
  2762          var _a = this.replaceStreamingParams(args), streams = _a[0], streamIds = _a[1];
  2763          var invocationDescriptor = this.createInvocation(methodName, args, false, streamIds);
  2764          var p = new Promise(function (resolve, reject) {
  2765              // invocationId will always have a value for a non-blocking invocation
  2766              _this.callbacks[invocationDescriptor.invocationId] = function (invocationEvent, error) {
  2767                  if (error) {
  2768                      reject(error);
  2769                      return;
  2770                  }
  2771                  else if (invocationEvent) {
  2772                      // invocationEvent will not be null when an error is not passed to the callback
  2773                      if (invocationEvent.type === _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Completion) {
  2774                          if (invocationEvent.error) {
  2775                              reject(new Error(invocationEvent.error));
  2776                          }
  2777                          else {
  2778                              resolve(invocationEvent.result);
  2779                          }
  2780                      }
  2781                      else {
  2782                          reject(new Error("Unexpected message type: " + invocationEvent.type));
  2783                      }
  2784                  }
  2785              };
  2786              var promiseQueue = _this.sendWithProtocol(invocationDescriptor)
  2787                  .catch(function (e) {
  2788                  reject(e);
  2789                  // invocationId will always have a value for a non-blocking invocation
  2790                  delete _this.callbacks[invocationDescriptor.invocationId];
  2791              });
  2792              _this.launchStreams(streams, promiseQueue);
  2793          });
  2794          return p;
  2795      };
  2796      /** Registers a handler that will be invoked when the hub method with the specified method name is invoked.
  2797       *
  2798       * @param {string} methodName The name of the hub method to define.
  2799       * @param {Function} newMethod The handler that will be raised when the hub method is invoked.
  2800       */
  2801      HubConnection.prototype.on = function (methodName, newMethod) {
  2802          if (!methodName || !newMethod) {
  2803              return;
  2804          }
  2805          methodName = methodName.toLowerCase();
  2806          if (!this.methods[methodName]) {
  2807              this.methods[methodName] = [];
  2808          }
  2809          // Preventing adding the same handler multiple times.
  2810          if (this.methods[methodName].indexOf(newMethod) !== -1) {
  2811              return;
  2812          }
  2813          this.methods[methodName].push(newMethod);
  2814      };
  2815      HubConnection.prototype.off = function (methodName, method) {
  2816          if (!methodName) {
  2817              return;
  2818          }
  2819          methodName = methodName.toLowerCase();
  2820          var handlers = this.methods[methodName];
  2821          if (!handlers) {
  2822              return;
  2823          }
  2824          if (method) {
  2825              var removeIdx = handlers.indexOf(method);
  2826              if (removeIdx !== -1) {
  2827                  handlers.splice(removeIdx, 1);
  2828                  if (handlers.length === 0) {
  2829                      delete this.methods[methodName];
  2830                  }
  2831              }
  2832          }
  2833          else {
  2834              delete this.methods[methodName];
  2835          }
  2836      };
  2837      /** Registers a handler that will be invoked when the connection is closed.
  2838       *
  2839       * @param {Function} callback The handler that will be invoked when the connection is closed. Optionally receives a single argument containing the error that caused the connection to close (if any).
  2840       */
  2841      HubConnection.prototype.onclose = function (callback) {
  2842          if (callback) {
  2843              this.closedCallbacks.push(callback);
  2844          }
  2845      };
  2846      /** Registers a handler that will be invoked when the connection starts reconnecting.
  2847       *
  2848       * @param {Function} callback The handler that will be invoked when the connection starts reconnecting. Optionally receives a single argument containing the error that caused the connection to start reconnecting (if any).
  2849       */
  2850      HubConnection.prototype.onreconnecting = function (callback) {
  2851          if (callback) {
  2852              this.reconnectingCallbacks.push(callback);
  2853          }
  2854      };
  2855      /** Registers a handler that will be invoked when the connection successfully reconnects.
  2856       *
  2857       * @param {Function} callback The handler that will be invoked when the connection successfully reconnects.
  2858       */
  2859      HubConnection.prototype.onreconnected = function (callback) {
  2860          if (callback) {
  2861              this.reconnectedCallbacks.push(callback);
  2862          }
  2863      };
  2864      HubConnection.prototype.processIncomingData = function (data) {
  2865          this.cleanupTimeout();
  2866          if (!this.receivedHandshakeResponse) {
  2867              data = this.processHandshakeResponse(data);
  2868              this.receivedHandshakeResponse = true;
  2869          }
  2870          // Data may have all been read when processing handshake response
  2871          if (data) {
  2872              // Parse the messages
  2873              var messages = this.protocol.parseMessages(data, this.logger);
  2874              for (var _i = 0, messages_1 = messages; _i < messages_1.length; _i++) {
  2875                  var message = messages_1[_i];
  2876                  switch (message.type) {
  2877                      case _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Invocation:
  2878                          this.invokeClientMethod(message);
  2879                          break;
  2880                      case _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].StreamItem:
  2881                      case _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Completion:
  2882                          var callback = this.callbacks[message.invocationId];
  2883                          if (callback) {
  2884                              if (message.type === _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Completion) {
  2885                                  delete this.callbacks[message.invocationId];
  2886                              }
  2887                              callback(message);
  2888                          }
  2889                          break;
  2890                      case _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Ping:
  2891                          // Don't care about pings
  2892                          break;
  2893                      case _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Close:
  2894                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Close message received from server.");
  2895                          var error = message.error ? new Error("Server returned an error on close: " + message.error) : undefined;
  2896                          if (message.allowReconnect === true) {
  2897                              // It feels wrong not to await connection.stop() here, but processIncomingData is called as part of an onreceive callback which is not async,
  2898                              // this is already the behavior for serverTimeout(), and HttpConnection.Stop() should catch and log all possible exceptions.
  2899                              // tslint:disable-next-line:no-floating-promises
  2900                              this.connection.stop(error);
  2901                          }
  2902                          else {
  2903                              // We cannot await stopInternal() here, but subsequent calls to stop() will await this if stopInternal() is still ongoing.
  2904                              this.stopPromise = this.stopInternal(error);
  2905                          }
  2906                          break;
  2907                      default:
  2908                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Warning, "Invalid message type: " + message.type + ".");
  2909                          break;
  2910                  }
  2911              }
  2912          }
  2913          this.resetTimeoutPeriod();
  2914      };
  2915      HubConnection.prototype.processHandshakeResponse = function (data) {
  2916          var _a;
  2917          var responseMessage;
  2918          var remainingData;
  2919          try {
  2920              _a = this.handshakeProtocol.parseHandshakeResponse(data), remainingData = _a[0], responseMessage = _a[1];
  2921          }
  2922          catch (e) {
  2923              var message = "Error parsing handshake response: " + e;
  2924              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, message);
  2925              var error = new Error(message);
  2926              this.handshakeRejecter(error);
  2927              throw error;
  2928          }
  2929          if (responseMessage.error) {
  2930              var message = "Server returned handshake error: " + responseMessage.error;
  2931              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, message);
  2932              var error = new Error(message);
  2933              this.handshakeRejecter(error);
  2934              throw error;
  2935          }
  2936          else {
  2937              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Server handshake complete.");
  2938          }
  2939          this.handshakeResolver();
  2940          return remainingData;
  2941      };
  2942      HubConnection.prototype.resetKeepAliveInterval = function () {
  2943          var _this = this;
  2944          if (this.connection.features.inherentKeepAlive) {
  2945              return;
  2946          }
  2947          this.cleanupPingTimer();
  2948          this.pingServerHandle = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
  2949              var _a;
  2950              return __generator(this, function (_b) {
  2951                  switch (_b.label) {
  2952                      case 0:
  2953                          if (!(this.connectionState === HubConnectionState.Connected)) return [3 /*break*/, 4];
  2954                          _b.label = 1;
  2955                      case 1:
  2956                          _b.trys.push([1, 3, , 4]);
  2957                          return [4 /*yield*/, this.sendMessage(this.cachedPingMessage)];
  2958                      case 2:
  2959                          _b.sent();
  2960                          return [3 /*break*/, 4];
  2961                      case 3:
  2962                          _a = _b.sent();
  2963                          // We don't care about the error. It should be seen elsewhere in the client.
  2964                          // The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering
  2965                          this.cleanupPingTimer();
  2966                          return [3 /*break*/, 4];
  2967                      case 4: return [2 /*return*/];
  2968                  }
  2969              });
  2970          }); }, this.keepAliveIntervalInMilliseconds);
  2971      };
  2972      HubConnection.prototype.resetTimeoutPeriod = function () {
  2973          var _this = this;
  2974          if (!this.connection.features || !this.connection.features.inherentKeepAlive) {
  2975              // Set the timeout timer
  2976              this.timeoutHandle = setTimeout(function () { return _this.serverTimeout(); }, this.serverTimeoutInMilliseconds);
  2977          }
  2978      };
  2979      HubConnection.prototype.serverTimeout = function () {
  2980          // The server hasn't talked to us in a while. It doesn't like us anymore ... :(
  2981          // Terminate the connection, but we don't need to wait on the promise. This could trigger reconnecting.
  2982          // tslint:disable-next-line:no-floating-promises
  2983          this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."));
  2984      };
  2985      HubConnection.prototype.invokeClientMethod = function (invocationMessage) {
  2986          var _this = this;
  2987          var methods = this.methods[invocationMessage.target.toLowerCase()];
  2988          if (methods) {
  2989              try {
  2990                  methods.forEach(function (m) { return m.apply(_this, invocationMessage.arguments); });
  2991              }
  2992              catch (e) {
  2993                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "A callback for the method " + invocationMessage.target.toLowerCase() + " threw error '" + e + "'.");
  2994              }
  2995              if (invocationMessage.invocationId) {
  2996                  // This is not supported in v1. So we return an error to avoid blocking the server waiting for the response.
  2997                  var message = "Server requested a response, which is not supported in this version of the client.";
  2998                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, message);
  2999                  // We don't want to wait on the stop itself.
  3000                  this.stopPromise = this.stopInternal(new Error(message));
  3001              }
  3002          }
  3003          else {
  3004              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Warning, "No client method with the name '" + invocationMessage.target + "' found.");
  3005          }
  3006      };
  3007      HubConnection.prototype.connectionClosed = function (error) {
  3008          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "HubConnection.connectionClosed(" + error + ") called while in state " + this.connectionState + ".");
  3009          // Triggering this.handshakeRejecter is insufficient because it could already be resolved without the continuation having run yet.
  3010          this.stopDuringStartError = this.stopDuringStartError || error || new Error("The underlying connection was closed before the hub handshake could complete.");
  3011          // If the handshake is in progress, start will be waiting for the handshake promise, so we complete it.
  3012          // If it has already completed, this should just noop.
  3013          if (this.handshakeResolver) {
  3014              this.handshakeResolver();
  3015          }
  3016          this.cancelCallbacksWithError(error || new Error("Invocation canceled due to the underlying connection being closed."));
  3017          this.cleanupTimeout();
  3018          this.cleanupPingTimer();
  3019          if (this.connectionState === HubConnectionState.Disconnecting) {
  3020              this.completeClose(error);
  3021          }
  3022          else if (this.connectionState === HubConnectionState.Connected && this.reconnectPolicy) {
  3023              // tslint:disable-next-line:no-floating-promises
  3024              this.reconnect(error);
  3025          }
  3026          else if (this.connectionState === HubConnectionState.Connected) {
  3027              this.completeClose(error);
  3028          }
  3029          // If none of the above if conditions were true were called the HubConnection must be in either:
  3030          // 1. The Connecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail it.
  3031          // 2. The Reconnecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail the current reconnect attempt
  3032          //    and potentially continue the reconnect() loop.
  3033          // 3. The Disconnected state in which case we're already done.
  3034      };
  3035      HubConnection.prototype.completeClose = function (error) {
  3036          var _this = this;
  3037          if (this.connectionStarted) {
  3038              this.connectionState = HubConnectionState.Disconnected;
  3039              this.connectionStarted = false;
  3040              try {
  3041                  this.closedCallbacks.forEach(function (c) { return c.apply(_this, [error]); });
  3042              }
  3043              catch (e) {
  3044                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "An onclose callback called with error '" + error + "' threw error '" + e + "'.");
  3045              }
  3046          }
  3047      };
  3048      HubConnection.prototype.reconnect = function (error) {
  3049          return __awaiter(this, void 0, void 0, function () {
  3050              var reconnectStartTime, previousReconnectAttempts, retryError, nextRetryDelay, e_4;
  3051              var _this = this;
  3052              return __generator(this, function (_a) {
  3053                  switch (_a.label) {
  3054                      case 0:
  3055                          reconnectStartTime = Date.now();
  3056                          previousReconnectAttempts = 0;
  3057                          retryError = error !== undefined ? error : new Error("Attempting to reconnect due to a unknown error.");
  3058                          nextRetryDelay = this.getNextRetryDelay(previousReconnectAttempts++, 0, retryError);
  3059                          if (nextRetryDelay === null) {
  3060                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt.");
  3061                              this.completeClose(error);
  3062                              return [2 /*return*/];
  3063                          }
  3064                          this.connectionState = HubConnectionState.Reconnecting;
  3065                          if (error) {
  3066                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Connection reconnecting because of error '" + error + "'.");
  3067                          }
  3068                          else {
  3069                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Connection reconnecting.");
  3070                          }
  3071                          if (this.onreconnecting) {
  3072                              try {
  3073                                  this.reconnectingCallbacks.forEach(function (c) { return c.apply(_this, [error]); });
  3074                              }
  3075                              catch (e) {
  3076                                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "An onreconnecting callback called with error '" + error + "' threw error '" + e + "'.");
  3077                              }
  3078                              // Exit early if an onreconnecting callback called connection.stop().
  3079                              if (this.connectionState !== HubConnectionState.Reconnecting) {
  3080                                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");
  3081                                  return [2 /*return*/];
  3082                              }
  3083                          }
  3084                          _a.label = 1;
  3085                      case 1:
  3086                          if (!(nextRetryDelay !== null)) return [3 /*break*/, 7];
  3087                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Reconnect attempt number " + previousReconnectAttempts + " will start in " + nextRetryDelay + " ms.");
  3088                          return [4 /*yield*/, new Promise(function (resolve) {
  3089                                  _this.reconnectDelayHandle = setTimeout(resolve, nextRetryDelay);
  3090                              })];
  3091                      case 2:
  3092                          _a.sent();
  3093                          this.reconnectDelayHandle = undefined;
  3094                          if (this.connectionState !== HubConnectionState.Reconnecting) {
  3095                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Connection left the reconnecting state during reconnect delay. Done reconnecting.");
  3096                              return [2 /*return*/];
  3097                          }
  3098                          _a.label = 3;
  3099                      case 3:
  3100                          _a.trys.push([3, 5, , 6]);
  3101                          return [4 /*yield*/, this.startInternal()];
  3102                      case 4:
  3103                          _a.sent();
  3104                          this.connectionState = HubConnectionState.Connected;
  3105                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "HubConnection reconnected successfully.");
  3106                          if (this.onreconnected) {
  3107                              try {
  3108                                  this.reconnectedCallbacks.forEach(function (c) { return c.apply(_this, [_this.connection.connectionId]); });
  3109                              }
  3110                              catch (e) {
  3111                                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "An onreconnected callback called with connectionId '" + this.connection.connectionId + "; threw error '" + e + "'.");
  3112                              }
  3113                          }
  3114                          return [2 /*return*/];
  3115                      case 5:
  3116                          e_4 = _a.sent();
  3117                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Reconnect attempt failed because of error '" + e_4 + "'.");
  3118                          if (this.connectionState !== HubConnectionState.Reconnecting) {
  3119                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Debug, "Connection left the reconnecting state during reconnect attempt. Done reconnecting.");
  3120                              return [2 /*return*/];
  3121                          }
  3122                          retryError = e_4 instanceof Error ? e_4 : new Error(e_4.toString());
  3123                          nextRetryDelay = this.getNextRetryDelay(previousReconnectAttempts++, Date.now() - reconnectStartTime, retryError);
  3124                          return [3 /*break*/, 6];
  3125                      case 6: return [3 /*break*/, 1];
  3126                      case 7:
  3127                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "Reconnect retries have been exhausted after " + (Date.now() - reconnectStartTime) + " ms and " + previousReconnectAttempts + " failed attempts. Connection disconnecting.");
  3128                          this.completeClose();
  3129                          return [2 /*return*/];
  3130                  }
  3131              });
  3132          });
  3133      };
  3134      HubConnection.prototype.getNextRetryDelay = function (previousRetryCount, elapsedMilliseconds, retryReason) {
  3135          try {
  3136              return this.reconnectPolicy.nextRetryDelayInMilliseconds({
  3137                  elapsedMilliseconds: elapsedMilliseconds,
  3138                  previousRetryCount: previousRetryCount,
  3139                  retryReason: retryReason,
  3140              });
  3141          }
  3142          catch (e) {
  3143              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "IRetryPolicy.nextRetryDelayInMilliseconds(" + previousRetryCount + ", " + elapsedMilliseconds + ") threw error '" + e + "'.");
  3144              return null;
  3145          }
  3146      };
  3147      HubConnection.prototype.cancelCallbacksWithError = function (error) {
  3148          var callbacks = this.callbacks;
  3149          this.callbacks = {};
  3150          Object.keys(callbacks)
  3151              .forEach(function (key) {
  3152              var callback = callbacks[key];
  3153              callback(null, error);
  3154          });
  3155      };
  3156      HubConnection.prototype.cleanupPingTimer = function () {
  3157          if (this.pingServerHandle) {
  3158              clearTimeout(this.pingServerHandle);
  3159          }
  3160      };
  3161      HubConnection.prototype.cleanupTimeout = function () {
  3162          if (this.timeoutHandle) {
  3163              clearTimeout(this.timeoutHandle);
  3164          }
  3165      };
  3166      HubConnection.prototype.createInvocation = function (methodName, args, nonblocking, streamIds) {
  3167          if (nonblocking) {
  3168              if (streamIds.length !== 0) {
  3169                  return {
  3170                      arguments: args,
  3171                      streamIds: streamIds,
  3172                      target: methodName,
  3173                      type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Invocation,
  3174                  };
  3175              }
  3176              else {
  3177                  return {
  3178                      arguments: args,
  3179                      target: methodName,
  3180                      type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Invocation,
  3181                  };
  3182              }
  3183          }
  3184          else {
  3185              var invocationId = this.invocationId;
  3186              this.invocationId++;
  3187              if (streamIds.length !== 0) {
  3188                  return {
  3189                      arguments: args,
  3190                      invocationId: invocationId.toString(),
  3191                      streamIds: streamIds,
  3192                      target: methodName,
  3193                      type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Invocation,
  3194                  };
  3195              }
  3196              else {
  3197                  return {
  3198                      arguments: args,
  3199                      invocationId: invocationId.toString(),
  3200                      target: methodName,
  3201                      type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Invocation,
  3202                  };
  3203              }
  3204          }
  3205      };
  3206      HubConnection.prototype.launchStreams = function (streams, promiseQueue) {
  3207          var _this = this;
  3208          if (streams.length === 0) {
  3209              return;
  3210          }
  3211          // Synchronize stream data so they arrive in-order on the server
  3212          if (!promiseQueue) {
  3213              promiseQueue = Promise.resolve();
  3214          }
  3215          var _loop_1 = function (streamId) {
  3216              streams[streamId].subscribe({
  3217                  complete: function () {
  3218                      promiseQueue = promiseQueue.then(function () { return _this.sendWithProtocol(_this.createCompletionMessage(streamId)); });
  3219                  },
  3220                  error: function (err) {
  3221                      var message;
  3222                      if (err instanceof Error) {
  3223                          message = err.message;
  3224                      }
  3225                      else if (err && err.toString) {
  3226                          message = err.toString();
  3227                      }
  3228                      else {
  3229                          message = "Unknown error";
  3230                      }
  3231                      promiseQueue = promiseQueue.then(function () { return _this.sendWithProtocol(_this.createCompletionMessage(streamId, message)); });
  3232                  },
  3233                  next: function (item) {
  3234                      promiseQueue = promiseQueue.then(function () { return _this.sendWithProtocol(_this.createStreamItemMessage(streamId, item)); });
  3235                  },
  3236              });
  3237          };
  3238          // We want to iterate over the keys, since the keys are the stream ids
  3239          // tslint:disable-next-line:forin
  3240          for (var streamId in streams) {
  3241              _loop_1(streamId);
  3242          }
  3243      };
  3244      HubConnection.prototype.replaceStreamingParams = function (args) {
  3245          var streams = [];
  3246          var streamIds = [];
  3247          for (var i = 0; i < args.length; i++) {
  3248              var argument = args[i];
  3249              if (this.isObservable(argument)) {
  3250                  var streamId = this.invocationId;
  3251                  this.invocationId++;
  3252                  // Store the stream for later use
  3253                  streams[streamId] = argument;
  3254                  streamIds.push(streamId.toString());
  3255                  // remove stream from args
  3256                  args.splice(i, 1);
  3257              }
  3258          }
  3259          return [streams, streamIds];
  3260      };
  3261      HubConnection.prototype.isObservable = function (arg) {
  3262          // This allows other stream implementations to just work (like rxjs)
  3263          return arg && arg.subscribe && typeof arg.subscribe === "function";
  3264      };
  3265      HubConnection.prototype.createStreamInvocation = function (methodName, args, streamIds) {
  3266          var invocationId = this.invocationId;
  3267          this.invocationId++;
  3268          if (streamIds.length !== 0) {
  3269              return {
  3270                  arguments: args,
  3271                  invocationId: invocationId.toString(),
  3272                  streamIds: streamIds,
  3273                  target: methodName,
  3274                  type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].StreamInvocation,
  3275              };
  3276          }
  3277          else {
  3278              return {
  3279                  arguments: args,
  3280                  invocationId: invocationId.toString(),
  3281                  target: methodName,
  3282                  type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].StreamInvocation,
  3283              };
  3284          }
  3285      };
  3286      HubConnection.prototype.createCancelInvocation = function (id) {
  3287          return {
  3288              invocationId: id,
  3289              type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].CancelInvocation,
  3290          };
  3291      };
  3292      HubConnection.prototype.createStreamItemMessage = function (id, item) {
  3293          return {
  3294              invocationId: id,
  3295              item: item,
  3296              type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].StreamItem,
  3297          };
  3298      };
  3299      HubConnection.prototype.createCompletionMessage = function (id, error, result) {
  3300          if (error) {
  3301              return {
  3302                  error: error,
  3303                  invocationId: id,
  3304                  type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Completion,
  3305              };
  3306          }
  3307          return {
  3308              invocationId: id,
  3309              result: result,
  3310              type: _IHubProtocol__WEBPACK_IMPORTED_MODULE_1__["MessageType"].Completion,
  3311          };
  3312      };
  3313      return HubConnection;
  3314  }());
  3315  
  3316  
  3317  
  3318  /***/ }),
  3319  /* 13 */
  3320  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3321  
  3322  "use strict";
  3323  __webpack_require__.r(__webpack_exports__);
  3324  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HandshakeProtocol", function() { return HandshakeProtocol; });
  3325  /* harmony import */ var _TextMessageFormat__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
  3326  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
  3327  // Copyright (c) .NET Foundation. All rights reserved.
  3328  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3329  
  3330  
  3331  /** @private */
  3332  var HandshakeProtocol = /** @class */ (function () {
  3333      function HandshakeProtocol() {
  3334      }
  3335      // Handshake request is always JSON
  3336      HandshakeProtocol.prototype.writeHandshakeRequest = function (handshakeRequest) {
  3337          return _TextMessageFormat__WEBPACK_IMPORTED_MODULE_0__["TextMessageFormat"].write(JSON.stringify(handshakeRequest));
  3338      };
  3339      HandshakeProtocol.prototype.parseHandshakeResponse = function (data) {
  3340          var responseMessage;
  3341          var messageData;
  3342          var remainingData;
  3343          if (Object(_Utils__WEBPACK_IMPORTED_MODULE_1__["isArrayBuffer"])(data) || (typeof Buffer !== "undefined" && data instanceof Buffer)) {
  3344              // Format is binary but still need to read JSON text from handshake response
  3345              var binaryData = new Uint8Array(data);
  3346              var separatorIndex = binaryData.indexOf(_TextMessageFormat__WEBPACK_IMPORTED_MODULE_0__["TextMessageFormat"].RecordSeparatorCode);
  3347              if (separatorIndex === -1) {
  3348                  throw new Error("Message is incomplete.");
  3349              }
  3350              // content before separator is handshake response
  3351              // optional content after is additional messages
  3352              var responseLength = separatorIndex + 1;
  3353              messageData = String.fromCharCode.apply(null, binaryData.slice(0, responseLength));
  3354              remainingData = (binaryData.byteLength > responseLength) ? binaryData.slice(responseLength).buffer : null;
  3355          }
  3356          else {
  3357              var textData = data;
  3358              var separatorIndex = textData.indexOf(_TextMessageFormat__WEBPACK_IMPORTED_MODULE_0__["TextMessageFormat"].RecordSeparator);
  3359              if (separatorIndex === -1) {
  3360                  throw new Error("Message is incomplete.");
  3361              }
  3362              // content before separator is handshake response
  3363              // optional content after is additional messages
  3364              var responseLength = separatorIndex + 1;
  3365              messageData = textData.substring(0, responseLength);
  3366              remainingData = (textData.length > responseLength) ? textData.substring(responseLength) : null;
  3367          }
  3368          // At this point we should have just the single handshake message
  3369          var messages = _TextMessageFormat__WEBPACK_IMPORTED_MODULE_0__["TextMessageFormat"].parse(messageData);
  3370          var response = JSON.parse(messages[0]);
  3371          if (response.type) {
  3372              throw new Error("Expected a handshake response from the server.");
  3373          }
  3374          responseMessage = response;
  3375          // multiple messages could have arrived with handshake
  3376          // return additional data to be parsed as usual, or null if all parsed
  3377          return [remainingData, responseMessage];
  3378      };
  3379      return HandshakeProtocol;
  3380  }());
  3381  
  3382  
  3383  
  3384  /***/ }),
  3385  /* 14 */
  3386  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3387  
  3388  "use strict";
  3389  __webpack_require__.r(__webpack_exports__);
  3390  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextMessageFormat", function() { return TextMessageFormat; });
  3391  // Copyright (c) .NET Foundation. All rights reserved.
  3392  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3393  // Not exported from index
  3394  /** @private */
  3395  var TextMessageFormat = /** @class */ (function () {
  3396      function TextMessageFormat() {
  3397      }
  3398      TextMessageFormat.write = function (output) {
  3399          return "" + output + TextMessageFormat.RecordSeparator;
  3400      };
  3401      TextMessageFormat.parse = function (input) {
  3402          if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
  3403              throw new Error("Message is incomplete.");
  3404          }
  3405          var messages = input.split(TextMessageFormat.RecordSeparator);
  3406          messages.pop();
  3407          return messages;
  3408      };
  3409      TextMessageFormat.RecordSeparatorCode = 0x1e;
  3410      TextMessageFormat.RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);
  3411      return TextMessageFormat;
  3412  }());
  3413  
  3414  
  3415  
  3416  /***/ }),
  3417  /* 15 */
  3418  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3419  
  3420  "use strict";
  3421  __webpack_require__.r(__webpack_exports__);
  3422  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MessageType", function() { return MessageType; });
  3423  // Copyright (c) .NET Foundation. All rights reserved.
  3424  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3425  /** Defines the type of a Hub Message. */
  3426  var MessageType;
  3427  (function (MessageType) {
  3428      /** Indicates the message is an Invocation message and implements the {@link @microsoft/signalr.InvocationMessage} interface. */
  3429      MessageType[MessageType["Invocation"] = 1] = "Invocation";
  3430      /** Indicates the message is a StreamItem message and implements the {@link @microsoft/signalr.StreamItemMessage} interface. */
  3431      MessageType[MessageType["StreamItem"] = 2] = "StreamItem";
  3432      /** Indicates the message is a Completion message and implements the {@link @microsoft/signalr.CompletionMessage} interface. */
  3433      MessageType[MessageType["Completion"] = 3] = "Completion";
  3434      /** Indicates the message is a Stream Invocation message and implements the {@link @microsoft/signalr.StreamInvocationMessage} interface. */
  3435      MessageType[MessageType["StreamInvocation"] = 4] = "StreamInvocation";
  3436      /** Indicates the message is a Cancel Invocation message and implements the {@link @microsoft/signalr.CancelInvocationMessage} interface. */
  3437      MessageType[MessageType["CancelInvocation"] = 5] = "CancelInvocation";
  3438      /** Indicates the message is a Ping message and implements the {@link @microsoft/signalr.PingMessage} interface. */
  3439      MessageType[MessageType["Ping"] = 6] = "Ping";
  3440      /** Indicates the message is a Close message and implements the {@link @microsoft/signalr.CloseMessage} interface. */
  3441      MessageType[MessageType["Close"] = 7] = "Close";
  3442  })(MessageType || (MessageType = {}));
  3443  
  3444  
  3445  /***/ }),
  3446  /* 16 */
  3447  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3448  
  3449  "use strict";
  3450  __webpack_require__.r(__webpack_exports__);
  3451  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Subject", function() { return Subject; });
  3452  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
  3453  // Copyright (c) .NET Foundation. All rights reserved.
  3454  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3455  
  3456  /** Stream implementation to stream items to the server. */
  3457  var Subject = /** @class */ (function () {
  3458      function Subject() {
  3459          this.observers = [];
  3460      }
  3461      Subject.prototype.next = function (item) {
  3462          for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
  3463              var observer = _a[_i];
  3464              observer.next(item);
  3465          }
  3466      };
  3467      Subject.prototype.error = function (err) {
  3468          for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
  3469              var observer = _a[_i];
  3470              if (observer.error) {
  3471                  observer.error(err);
  3472              }
  3473          }
  3474      };
  3475      Subject.prototype.complete = function () {
  3476          for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
  3477              var observer = _a[_i];
  3478              if (observer.complete) {
  3479                  observer.complete();
  3480              }
  3481          }
  3482      };
  3483      Subject.prototype.subscribe = function (observer) {
  3484          this.observers.push(observer);
  3485          return new _Utils__WEBPACK_IMPORTED_MODULE_0__["SubjectSubscription"](this, observer);
  3486      };
  3487      return Subject;
  3488  }());
  3489  
  3490  
  3491  
  3492  /***/ }),
  3493  /* 17 */
  3494  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3495  
  3496  "use strict";
  3497  __webpack_require__.r(__webpack_exports__);
  3498  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HubConnectionBuilder", function() { return HubConnectionBuilder; });
  3499  /* harmony import */ var _DefaultReconnectPolicy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
  3500  /* harmony import */ var _HttpConnection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19);
  3501  /* harmony import */ var _HubConnection__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12);
  3502  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
  3503  /* harmony import */ var _JsonHubProtocol__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(25);
  3504  /* harmony import */ var _Loggers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(10);
  3505  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9);
  3506  // Copyright (c) .NET Foundation. All rights reserved.
  3507  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3508  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  3509      for (var s, i = 1, n = arguments.length; i < n; i++) {
  3510          s = arguments[i];
  3511          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3512              t[p] = s[p];
  3513      }
  3514      return t;
  3515  };
  3516  
  3517  
  3518  
  3519  
  3520  
  3521  
  3522  
  3523  // tslint:disable:object-literal-sort-keys
  3524  var LogLevelNameMapping = {
  3525      trace: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Trace,
  3526      debug: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Debug,
  3527      info: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Information,
  3528      information: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Information,
  3529      warn: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Warning,
  3530      warning: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Warning,
  3531      error: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Error,
  3532      critical: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].Critical,
  3533      none: _ILogger__WEBPACK_IMPORTED_MODULE_3__["LogLevel"].None,
  3534  };
  3535  function parseLogLevel(name) {
  3536      // Case-insensitive matching via lower-casing
  3537      // Yes, I know case-folding is a complicated problem in Unicode, but we only support
  3538      // the ASCII strings defined in LogLevelNameMapping anyway, so it's fine -anurse.
  3539      var mapping = LogLevelNameMapping[name.toLowerCase()];
  3540      if (typeof mapping !== "undefined") {
  3541          return mapping;
  3542      }
  3543      else {
  3544          throw new Error("Unknown log level: " + name);
  3545      }
  3546  }
  3547  /** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */
  3548  var HubConnectionBuilder = /** @class */ (function () {
  3549      function HubConnectionBuilder() {
  3550      }
  3551      HubConnectionBuilder.prototype.configureLogging = function (logging) {
  3552          _Utils__WEBPACK_IMPORTED_MODULE_6__["Arg"].isRequired(logging, "logging");
  3553          if (isLogger(logging)) {
  3554              this.logger = logging;
  3555          }
  3556          else if (typeof logging === "string") {
  3557              var logLevel = parseLogLevel(logging);
  3558              this.logger = new _Utils__WEBPACK_IMPORTED_MODULE_6__["ConsoleLogger"](logLevel);
  3559          }
  3560          else {
  3561              this.logger = new _Utils__WEBPACK_IMPORTED_MODULE_6__["ConsoleLogger"](logging);
  3562          }
  3563          return this;
  3564      };
  3565      HubConnectionBuilder.prototype.withUrl = function (url, transportTypeOrOptions) {
  3566          _Utils__WEBPACK_IMPORTED_MODULE_6__["Arg"].isRequired(url, "url");
  3567          _Utils__WEBPACK_IMPORTED_MODULE_6__["Arg"].isNotEmpty(url, "url");
  3568          this.url = url;
  3569          // Flow-typing knows where it's at. Since HttpTransportType is a number and IHttpConnectionOptions is guaranteed
  3570          // to be an object, we know (as does TypeScript) this comparison is all we need to figure out which overload was called.
  3571          if (typeof transportTypeOrOptions === "object") {
  3572              this.httpConnectionOptions = __assign({}, this.httpConnectionOptions, transportTypeOrOptions);
  3573          }
  3574          else {
  3575              this.httpConnectionOptions = __assign({}, this.httpConnectionOptions, { transport: transportTypeOrOptions });
  3576          }
  3577          return this;
  3578      };
  3579      /** Configures the {@link @microsoft/signalr.HubConnection} to use the specified Hub Protocol.
  3580       *
  3581       * @param {IHubProtocol} protocol The {@link @microsoft/signalr.IHubProtocol} implementation to use.
  3582       */
  3583      HubConnectionBuilder.prototype.withHubProtocol = function (protocol) {
  3584          _Utils__WEBPACK_IMPORTED_MODULE_6__["Arg"].isRequired(protocol, "protocol");
  3585          this.protocol = protocol;
  3586          return this;
  3587      };
  3588      HubConnectionBuilder.prototype.withAutomaticReconnect = function (retryDelaysOrReconnectPolicy) {
  3589          if (this.reconnectPolicy) {
  3590              throw new Error("A reconnectPolicy has already been set.");
  3591          }
  3592          if (!retryDelaysOrReconnectPolicy) {
  3593              this.reconnectPolicy = new _DefaultReconnectPolicy__WEBPACK_IMPORTED_MODULE_0__["DefaultReconnectPolicy"]();
  3594          }
  3595          else if (Array.isArray(retryDelaysOrReconnectPolicy)) {
  3596              this.reconnectPolicy = new _DefaultReconnectPolicy__WEBPACK_IMPORTED_MODULE_0__["DefaultReconnectPolicy"](retryDelaysOrReconnectPolicy);
  3597          }
  3598          else {
  3599              this.reconnectPolicy = retryDelaysOrReconnectPolicy;
  3600          }
  3601          return this;
  3602      };
  3603      /** Creates a {@link @microsoft/signalr.HubConnection} from the configuration options specified in this builder.
  3604       *
  3605       * @returns {HubConnection} The configured {@link @microsoft/signalr.HubConnection}.
  3606       */
  3607      HubConnectionBuilder.prototype.build = function () {
  3608          // If httpConnectionOptions has a logger, use it. Otherwise, override it with the one
  3609          // provided to configureLogger
  3610          var httpConnectionOptions = this.httpConnectionOptions || {};
  3611          // If it's 'null', the user **explicitly** asked for null, don't mess with it.
  3612          if (httpConnectionOptions.logger === undefined) {
  3613              // If our logger is undefined or null, that's OK, the HttpConnection constructor will handle it.
  3614              httpConnectionOptions.logger = this.logger;
  3615          }
  3616          // Now create the connection
  3617          if (!this.url) {
  3618              throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");
  3619          }
  3620          var connection = new _HttpConnection__WEBPACK_IMPORTED_MODULE_1__["HttpConnection"](this.url, httpConnectionOptions);
  3621          return _HubConnection__WEBPACK_IMPORTED_MODULE_2__["HubConnection"].create(connection, this.logger || _Loggers__WEBPACK_IMPORTED_MODULE_5__["NullLogger"].instance, this.protocol || new _JsonHubProtocol__WEBPACK_IMPORTED_MODULE_4__["JsonHubProtocol"](), this.reconnectPolicy);
  3622      };
  3623      return HubConnectionBuilder;
  3624  }());
  3625  
  3626  function isLogger(logger) {
  3627      return logger.log !== undefined;
  3628  }
  3629  
  3630  
  3631  /***/ }),
  3632  /* 18 */
  3633  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3634  
  3635  "use strict";
  3636  __webpack_require__.r(__webpack_exports__);
  3637  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultReconnectPolicy", function() { return DefaultReconnectPolicy; });
  3638  // Copyright (c) .NET Foundation. All rights reserved.
  3639  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3640  // 0, 2, 10, 30 second delays before reconnect attempts.
  3641  var DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];
  3642  /** @private */
  3643  var DefaultReconnectPolicy = /** @class */ (function () {
  3644      function DefaultReconnectPolicy(retryDelays) {
  3645          this.retryDelays = retryDelays !== undefined ? retryDelays.concat([null]) : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;
  3646      }
  3647      DefaultReconnectPolicy.prototype.nextRetryDelayInMilliseconds = function (retryContext) {
  3648          return this.retryDelays[retryContext.previousRetryCount];
  3649      };
  3650      return DefaultReconnectPolicy;
  3651  }());
  3652  
  3653  
  3654  
  3655  /***/ }),
  3656  /* 19 */
  3657  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3658  
  3659  "use strict";
  3660  __webpack_require__.r(__webpack_exports__);
  3661  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HttpConnection", function() { return HttpConnection; });
  3662  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransportSendQueue", function() { return TransportSendQueue; });
  3663  /* harmony import */ var _DefaultHttpClient__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6);
  3664  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
  3665  /* harmony import */ var _ITransport__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
  3666  /* harmony import */ var _LongPollingTransport__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21);
  3667  /* harmony import */ var _ServerSentEventsTransport__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(23);
  3668  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9);
  3669  /* harmony import */ var _WebSocketTransport__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(24);
  3670  // Copyright (c) .NET Foundation. All rights reserved.
  3671  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3672  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  3673      for (var s, i = 1, n = arguments.length; i < n; i++) {
  3674          s = arguments[i];
  3675          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  3676              t[p] = s[p];
  3677      }
  3678      return t;
  3679  };
  3680  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3681      return new (P || (P = Promise))(function (resolve, reject) {
  3682          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3683          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3684          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  3685          step((generator = generator.apply(thisArg, _arguments || [])).next());
  3686      });
  3687  };
  3688  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  3689      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  3690      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  3691      function verb(n) { return function (v) { return step([n, v]); }; }
  3692      function step(op) {
  3693          if (f) throw new TypeError("Generator is already executing.");
  3694          while (_) try {
  3695              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  3696              if (y = 0, t) op = [op[0] & 2, t.value];
  3697              switch (op[0]) {
  3698                  case 0: case 1: t = op; break;
  3699                  case 4: _.label++; return { value: op[1], done: false };
  3700                  case 5: _.label++; y = op[1]; op = [0]; continue;
  3701                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  3702                  default:
  3703                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  3704                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  3705                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  3706                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  3707                      if (t[2]) _.ops.pop();
  3708                      _.trys.pop(); continue;
  3709              }
  3710              op = body.call(thisArg, _);
  3711          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  3712          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  3713      }
  3714  };
  3715  
  3716  
  3717  
  3718  
  3719  
  3720  
  3721  
  3722  var MAX_REDIRECTS = 100;
  3723  /** @private */
  3724  var HttpConnection = /** @class */ (function () {
  3725      function HttpConnection(url, options) {
  3726          if (options === void 0) { options = {}; }
  3727          this.features = {};
  3728          this.negotiateVersion = 1;
  3729          _Utils__WEBPACK_IMPORTED_MODULE_5__["Arg"].isRequired(url, "url");
  3730          this.logger = Object(_Utils__WEBPACK_IMPORTED_MODULE_5__["createLogger"])(options.logger);
  3731          this.baseUrl = this.resolveUrl(url);
  3732          options = options || {};
  3733          options.logMessageContent = options.logMessageContent === undefined ? false : options.logMessageContent;
  3734          if (typeof options.withCredentials === "boolean" || options.withCredentials === undefined) {
  3735              options.withCredentials = options.withCredentials === undefined ? true : options.withCredentials;
  3736          }
  3737          else {
  3738              throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");
  3739          }
  3740          var webSocketModule = null;
  3741          var eventSourceModule = null;
  3742          if (_Utils__WEBPACK_IMPORTED_MODULE_5__["Platform"].isNode && "function" !== "undefined") {
  3743              // In order to ignore the dynamic require in webpack builds we need to do this magic
  3744              // @ts-ignore: TS doesn't know about these names
  3745              var requireFunc =  true ? require : undefined;
  3746              webSocketModule = requireFunc("ws");
  3747              eventSourceModule = requireFunc("eventsource");
  3748          }
  3749          if (!_Utils__WEBPACK_IMPORTED_MODULE_5__["Platform"].isNode && typeof WebSocket !== "undefined" && !options.WebSocket) {
  3750              options.WebSocket = WebSocket;
  3751          }
  3752          else if (_Utils__WEBPACK_IMPORTED_MODULE_5__["Platform"].isNode && !options.WebSocket) {
  3753              if (webSocketModule) {
  3754                  options.WebSocket = webSocketModule;
  3755              }
  3756          }
  3757          if (!_Utils__WEBPACK_IMPORTED_MODULE_5__["Platform"].isNode && typeof EventSource !== "undefined" && !options.EventSource) {
  3758              options.EventSource = EventSource;
  3759          }
  3760          else if (_Utils__WEBPACK_IMPORTED_MODULE_5__["Platform"].isNode && !options.EventSource) {
  3761              if (typeof eventSourceModule !== "undefined") {
  3762                  options.EventSource = eventSourceModule;
  3763              }
  3764          }
  3765          this.httpClient = options.httpClient || new _DefaultHttpClient__WEBPACK_IMPORTED_MODULE_0__["DefaultHttpClient"](this.logger);
  3766          this.connectionState = "Disconnected" /* Disconnected */;
  3767          this.connectionStarted = false;
  3768          this.options = options;
  3769          this.onreceive = null;
  3770          this.onclose = null;
  3771      }
  3772      HttpConnection.prototype.start = function (transferFormat) {
  3773          return __awaiter(this, void 0, void 0, function () {
  3774              var message, message;
  3775              return __generator(this, function (_a) {
  3776                  switch (_a.label) {
  3777                      case 0:
  3778                          transferFormat = transferFormat || _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"].Binary;
  3779                          _Utils__WEBPACK_IMPORTED_MODULE_5__["Arg"].isIn(transferFormat, _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"], "transferFormat");
  3780                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Starting connection with transfer format '" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"][transferFormat] + "'.");
  3781                          if (this.connectionState !== "Disconnected" /* Disconnected */) {
  3782                              return [2 /*return*/, Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."))];
  3783                          }
  3784                          this.connectionState = "Connecting" /* Connecting */;
  3785                          this.startInternalPromise = this.startInternal(transferFormat);
  3786                          return [4 /*yield*/, this.startInternalPromise];
  3787                      case 1:
  3788                          _a.sent();
  3789                          if (!(this.connectionState === "Disconnecting" /* Disconnecting */)) return [3 /*break*/, 3];
  3790                          message = "Failed to start the HttpConnection before stop() was called.";
  3791                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, message);
  3792                          // We cannot await stopPromise inside startInternal since stopInternal awaits the startInternalPromise.
  3793                          return [4 /*yield*/, this.stopPromise];
  3794                      case 2:
  3795                          // We cannot await stopPromise inside startInternal since stopInternal awaits the startInternalPromise.
  3796                          _a.sent();
  3797                          return [2 /*return*/, Promise.reject(new Error(message))];
  3798                      case 3:
  3799                          if (this.connectionState !== "Connected" /* Connected */) {
  3800                              message = "HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";
  3801                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, message);
  3802                              return [2 /*return*/, Promise.reject(new Error(message))];
  3803                          }
  3804                          _a.label = 4;
  3805                      case 4:
  3806                          this.connectionStarted = true;
  3807                          return [2 /*return*/];
  3808                  }
  3809              });
  3810          });
  3811      };
  3812      HttpConnection.prototype.send = function (data) {
  3813          if (this.connectionState !== "Connected" /* Connected */) {
  3814              return Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State."));
  3815          }
  3816          if (!this.sendQueue) {
  3817              this.sendQueue = new TransportSendQueue(this.transport);
  3818          }
  3819          // Transport will not be null if state is connected
  3820          return this.sendQueue.send(data);
  3821      };
  3822      HttpConnection.prototype.stop = function (error) {
  3823          return __awaiter(this, void 0, void 0, function () {
  3824              var _this = this;
  3825              return __generator(this, function (_a) {
  3826                  switch (_a.label) {
  3827                      case 0:
  3828                          if (this.connectionState === "Disconnected" /* Disconnected */) {
  3829                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Call to HttpConnection.stop(" + error + ") ignored because the connection is already in the disconnected state.");
  3830                              return [2 /*return*/, Promise.resolve()];
  3831                          }
  3832                          if (this.connectionState === "Disconnecting" /* Disconnecting */) {
  3833                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Call to HttpConnection.stop(" + error + ") ignored because the connection is already in the disconnecting state.");
  3834                              return [2 /*return*/, this.stopPromise];
  3835                          }
  3836                          this.connectionState = "Disconnecting" /* Disconnecting */;
  3837                          this.stopPromise = new Promise(function (resolve) {
  3838                              // Don't complete stop() until stopConnection() completes.
  3839                              _this.stopPromiseResolver = resolve;
  3840                          });
  3841                          // stopInternal should never throw so just observe it.
  3842                          return [4 /*yield*/, this.stopInternal(error)];
  3843                      case 1:
  3844                          // stopInternal should never throw so just observe it.
  3845                          _a.sent();
  3846                          return [4 /*yield*/, this.stopPromise];
  3847                      case 2:
  3848                          _a.sent();
  3849                          return [2 /*return*/];
  3850                  }
  3851              });
  3852          });
  3853      };
  3854      HttpConnection.prototype.stopInternal = function (error) {
  3855          return __awaiter(this, void 0, void 0, function () {
  3856              var e_1, e_2;
  3857              return __generator(this, function (_a) {
  3858                  switch (_a.label) {
  3859                      case 0:
  3860                          // Set error as soon as possible otherwise there is a race between
  3861                          // the transport closing and providing an error and the error from a close message
  3862                          // We would prefer the close message error.
  3863                          this.stopError = error;
  3864                          _a.label = 1;
  3865                      case 1:
  3866                          _a.trys.push([1, 3, , 4]);
  3867                          return [4 /*yield*/, this.startInternalPromise];
  3868                      case 2:
  3869                          _a.sent();
  3870                          return [3 /*break*/, 4];
  3871                      case 3:
  3872                          e_1 = _a.sent();
  3873                          return [3 /*break*/, 4];
  3874                      case 4:
  3875                          if (!this.transport) return [3 /*break*/, 9];
  3876                          _a.label = 5;
  3877                      case 5:
  3878                          _a.trys.push([5, 7, , 8]);
  3879                          return [4 /*yield*/, this.transport.stop()];
  3880                      case 6:
  3881                          _a.sent();
  3882                          return [3 /*break*/, 8];
  3883                      case 7:
  3884                          e_2 = _a.sent();
  3885                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "HttpConnection.transport.stop() threw error '" + e_2 + "'.");
  3886                          this.stopConnection();
  3887                          return [3 /*break*/, 8];
  3888                      case 8:
  3889                          this.transport = undefined;
  3890                          return [3 /*break*/, 10];
  3891                      case 9:
  3892                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.");
  3893                          this.stopConnection();
  3894                          _a.label = 10;
  3895                      case 10: return [2 /*return*/];
  3896                  }
  3897              });
  3898          });
  3899      };
  3900      HttpConnection.prototype.startInternal = function (transferFormat) {
  3901          return __awaiter(this, void 0, void 0, function () {
  3902              var url, negotiateResponse, redirects, _loop_1, this_1, e_3;
  3903              return __generator(this, function (_a) {
  3904                  switch (_a.label) {
  3905                      case 0:
  3906                          url = this.baseUrl;
  3907                          this.accessTokenFactory = this.options.accessTokenFactory;
  3908                          _a.label = 1;
  3909                      case 1:
  3910                          _a.trys.push([1, 12, , 13]);
  3911                          if (!this.options.skipNegotiation) return [3 /*break*/, 5];
  3912                          if (!(this.options.transport === _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].WebSockets)) return [3 /*break*/, 3];
  3913                          // No need to add a connection ID in this case
  3914                          this.transport = this.constructTransport(_ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].WebSockets);
  3915                          // We should just call connect directly in this case.
  3916                          // No fallback or negotiate in this case.
  3917                          return [4 /*yield*/, this.startTransport(url, transferFormat)];
  3918                      case 2:
  3919                          // We should just call connect directly in this case.
  3920                          // No fallback or negotiate in this case.
  3921                          _a.sent();
  3922                          return [3 /*break*/, 4];
  3923                      case 3: throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");
  3924                      case 4: return [3 /*break*/, 11];
  3925                      case 5:
  3926                          negotiateResponse = null;
  3927                          redirects = 0;
  3928                          _loop_1 = function () {
  3929                              var accessToken_1;
  3930                              return __generator(this, function (_a) {
  3931                                  switch (_a.label) {
  3932                                      case 0: return [4 /*yield*/, this_1.getNegotiationResponse(url)];
  3933                                      case 1:
  3934                                          negotiateResponse = _a.sent();
  3935                                          // the user tries to stop the connection when it is being started
  3936                                          if (this_1.connectionState === "Disconnecting" /* Disconnecting */ || this_1.connectionState === "Disconnected" /* Disconnected */) {
  3937                                              throw new Error("The connection was stopped during negotiation.");
  3938                                          }
  3939                                          if (negotiateResponse.error) {
  3940                                              throw new Error(negotiateResponse.error);
  3941                                          }
  3942                                          if (negotiateResponse.ProtocolVersion) {
  3943                                              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.");
  3944                                          }
  3945                                          if (negotiateResponse.url) {
  3946                                              url = negotiateResponse.url;
  3947                                          }
  3948                                          if (negotiateResponse.accessToken) {
  3949                                              accessToken_1 = negotiateResponse.accessToken;
  3950                                              this_1.accessTokenFactory = function () { return accessToken_1; };
  3951                                          }
  3952                                          redirects++;
  3953                                          return [2 /*return*/];
  3954                                  }
  3955                              });
  3956                          };
  3957                          this_1 = this;
  3958                          _a.label = 6;
  3959                      case 6: return [5 /*yield**/, _loop_1()];
  3960                      case 7:
  3961                          _a.sent();
  3962                          _a.label = 8;
  3963                      case 8:
  3964                          if (negotiateResponse.url && redirects < MAX_REDIRECTS) return [3 /*break*/, 6];
  3965                          _a.label = 9;
  3966                      case 9:
  3967                          if (redirects === MAX_REDIRECTS && negotiateResponse.url) {
  3968                              throw new Error("Negotiate redirection limit exceeded.");
  3969                          }
  3970                          return [4 /*yield*/, this.createTransport(url, this.options.transport, negotiateResponse, transferFormat)];
  3971                      case 10:
  3972                          _a.sent();
  3973                          _a.label = 11;
  3974                      case 11:
  3975                          if (this.transport instanceof _LongPollingTransport__WEBPACK_IMPORTED_MODULE_3__["LongPollingTransport"]) {
  3976                              this.features.inherentKeepAlive = true;
  3977                          }
  3978                          if (this.connectionState === "Connecting" /* Connecting */) {
  3979                              // Ensure the connection transitions to the connected state prior to completing this.startInternalPromise.
  3980                              // start() will handle the case when stop was called and startInternal exits still in the disconnecting state.
  3981                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "The HttpConnection connected successfully.");
  3982                              this.connectionState = "Connected" /* Connected */;
  3983                          }
  3984                          return [3 /*break*/, 13];
  3985                      case 12:
  3986                          e_3 = _a.sent();
  3987                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "Failed to start the connection: " + e_3);
  3988                          this.connectionState = "Disconnected" /* Disconnected */;
  3989                          this.transport = undefined;
  3990                          return [2 /*return*/, Promise.reject(e_3)];
  3991                      case 13: return [2 /*return*/];
  3992                  }
  3993              });
  3994          });
  3995      };
  3996      HttpConnection.prototype.getNegotiationResponse = function (url) {
  3997          return __awaiter(this, void 0, void 0, function () {
  3998              var headers, token, _a, name, value, negotiateUrl, response, negotiateResponse, e_4;
  3999              return __generator(this, function (_b) {
  4000                  switch (_b.label) {
  4001                      case 0:
  4002                          headers = {};
  4003                          if (!this.accessTokenFactory) return [3 /*break*/, 2];
  4004                          return [4 /*yield*/, this.accessTokenFactory()];
  4005                      case 1:
  4006                          token = _b.sent();
  4007                          if (token) {
  4008                              headers["Authorization"] = "Bearer " + token;
  4009                          }
  4010                          _b.label = 2;
  4011                      case 2:
  4012                          _a = Object(_Utils__WEBPACK_IMPORTED_MODULE_5__["getUserAgentHeader"])(), name = _a[0], value = _a[1];
  4013                          headers[name] = value;
  4014                          negotiateUrl = this.resolveNegotiateUrl(url);
  4015                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Sending negotiation request: " + negotiateUrl + ".");
  4016                          _b.label = 3;
  4017                      case 3:
  4018                          _b.trys.push([3, 5, , 6]);
  4019                          return [4 /*yield*/, this.httpClient.post(negotiateUrl, {
  4020                                  content: "",
  4021                                  headers: __assign({}, headers, this.options.headers),
  4022                                  withCredentials: this.options.withCredentials,
  4023                              })];
  4024                      case 4:
  4025                          response = _b.sent();
  4026                          if (response.statusCode !== 200) {
  4027                              return [2 /*return*/, Promise.reject(new Error("Unexpected status code returned from negotiate '" + response.statusCode + "'"))];
  4028                          }
  4029                          negotiateResponse = JSON.parse(response.content);
  4030                          if (!negotiateResponse.negotiateVersion || negotiateResponse.negotiateVersion < 1) {
  4031                              // Negotiate version 0 doesn't use connectionToken
  4032                              // So we set it equal to connectionId so all our logic can use connectionToken without being aware of the negotiate version
  4033                              negotiateResponse.connectionToken = negotiateResponse.connectionId;
  4034                          }
  4035                          return [2 /*return*/, negotiateResponse];
  4036                      case 5:
  4037                          e_4 = _b.sent();
  4038                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "Failed to complete negotiation with the server: " + e_4);
  4039                          return [2 /*return*/, Promise.reject(e_4)];
  4040                      case 6: return [2 /*return*/];
  4041                  }
  4042              });
  4043          });
  4044      };
  4045      HttpConnection.prototype.createConnectUrl = function (url, connectionToken) {
  4046          if (!connectionToken) {
  4047              return url;
  4048          }
  4049          return url + (url.indexOf("?") === -1 ? "?" : "&") + ("id=" + connectionToken);
  4050      };
  4051      HttpConnection.prototype.createTransport = function (url, requestedTransport, negotiateResponse, requestedTransferFormat) {
  4052          return __awaiter(this, void 0, void 0, function () {
  4053              var connectUrl, transportExceptions, transports, negotiate, _i, transports_1, endpoint, transportOrError, ex_1, ex_2, message;
  4054              return __generator(this, function (_a) {
  4055                  switch (_a.label) {
  4056                      case 0:
  4057                          connectUrl = this.createConnectUrl(url, negotiateResponse.connectionToken);
  4058                          if (!this.isITransport(requestedTransport)) return [3 /*break*/, 2];
  4059                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Connection was provided an instance of ITransport, using that directly.");
  4060                          this.transport = requestedTransport;
  4061                          return [4 /*yield*/, this.startTransport(connectUrl, requestedTransferFormat)];
  4062                      case 1:
  4063                          _a.sent();
  4064                          this.connectionId = negotiateResponse.connectionId;
  4065                          return [2 /*return*/];
  4066                      case 2:
  4067                          transportExceptions = [];
  4068                          transports = negotiateResponse.availableTransports || [];
  4069                          negotiate = negotiateResponse;
  4070                          _i = 0, transports_1 = transports;
  4071                          _a.label = 3;
  4072                      case 3:
  4073                          if (!(_i < transports_1.length)) return [3 /*break*/, 13];
  4074                          endpoint = transports_1[_i];
  4075                          transportOrError = this.resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat);
  4076                          if (!(transportOrError instanceof Error)) return [3 /*break*/, 4];
  4077                          // Store the error and continue, we don't want to cause a re-negotiate in these cases
  4078                          transportExceptions.push(endpoint.transport + " failed: " + transportOrError);
  4079                          return [3 /*break*/, 12];
  4080                      case 4:
  4081                          if (!this.isITransport(transportOrError)) return [3 /*break*/, 12];
  4082                          this.transport = transportOrError;
  4083                          if (!!negotiate) return [3 /*break*/, 9];
  4084                          _a.label = 5;
  4085                      case 5:
  4086                          _a.trys.push([5, 7, , 8]);
  4087                          return [4 /*yield*/, this.getNegotiationResponse(url)];
  4088                      case 6:
  4089                          negotiate = _a.sent();
  4090                          return [3 /*break*/, 8];
  4091                      case 7:
  4092                          ex_1 = _a.sent();
  4093                          return [2 /*return*/, Promise.reject(ex_1)];
  4094                      case 8:
  4095                          connectUrl = this.createConnectUrl(url, negotiate.connectionToken);
  4096                          _a.label = 9;
  4097                      case 9:
  4098                          _a.trys.push([9, 11, , 12]);
  4099                          return [4 /*yield*/, this.startTransport(connectUrl, requestedTransferFormat)];
  4100                      case 10:
  4101                          _a.sent();
  4102                          this.connectionId = negotiate.connectionId;
  4103                          return [2 /*return*/];
  4104                      case 11:
  4105                          ex_2 = _a.sent();
  4106                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "Failed to start the transport '" + endpoint.transport + "': " + ex_2);
  4107                          negotiate = undefined;
  4108                          transportExceptions.push(endpoint.transport + " failed: " + ex_2);
  4109                          if (this.connectionState !== "Connecting" /* Connecting */) {
  4110                              message = "Failed to select transport before stop() was called.";
  4111                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, message);
  4112                              return [2 /*return*/, Promise.reject(new Error(message))];
  4113                          }
  4114                          return [3 /*break*/, 12];
  4115                      case 12:
  4116                          _i++;
  4117                          return [3 /*break*/, 3];
  4118                      case 13:
  4119                          if (transportExceptions.length > 0) {
  4120                              return [2 /*return*/, Promise.reject(new Error("Unable to connect to the server with any of the available transports. " + transportExceptions.join(" ")))];
  4121                          }
  4122                          return [2 /*return*/, Promise.reject(new Error("None of the transports supported by the client are supported by the server."))];
  4123                  }
  4124              });
  4125          });
  4126      };
  4127      HttpConnection.prototype.constructTransport = function (transport) {
  4128          switch (transport) {
  4129              case _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].WebSockets:
  4130                  if (!this.options.WebSocket) {
  4131                      throw new Error("'WebSocket' is not supported in your environment.");
  4132                  }
  4133                  return new _WebSocketTransport__WEBPACK_IMPORTED_MODULE_6__["WebSocketTransport"](this.httpClient, this.accessTokenFactory, this.logger, this.options.logMessageContent || false, this.options.WebSocket, this.options.headers || {});
  4134              case _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].ServerSentEvents:
  4135                  if (!this.options.EventSource) {
  4136                      throw new Error("'EventSource' is not supported in your environment.");
  4137                  }
  4138                  return new _ServerSentEventsTransport__WEBPACK_IMPORTED_MODULE_4__["ServerSentEventsTransport"](this.httpClient, this.accessTokenFactory, this.logger, this.options.logMessageContent || false, this.options.EventSource, this.options.withCredentials, this.options.headers || {});
  4139              case _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].LongPolling:
  4140                  return new _LongPollingTransport__WEBPACK_IMPORTED_MODULE_3__["LongPollingTransport"](this.httpClient, this.accessTokenFactory, this.logger, this.options.logMessageContent || false, this.options.withCredentials, this.options.headers || {});
  4141              default:
  4142                  throw new Error("Unknown transport: " + transport + ".");
  4143          }
  4144      };
  4145      HttpConnection.prototype.startTransport = function (url, transferFormat) {
  4146          var _this = this;
  4147          this.transport.onreceive = this.onreceive;
  4148          this.transport.onclose = function (e) { return _this.stopConnection(e); };
  4149          return this.transport.connect(url, transferFormat);
  4150      };
  4151      HttpConnection.prototype.resolveTransportOrError = function (endpoint, requestedTransport, requestedTransferFormat) {
  4152          var transport = _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][endpoint.transport];
  4153          if (transport === null || transport === undefined) {
  4154              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Skipping transport '" + endpoint.transport + "' because it is not supported by this client.");
  4155              return new Error("Skipping transport '" + endpoint.transport + "' because it is not supported by this client.");
  4156          }
  4157          else {
  4158              if (transportMatches(requestedTransport, transport)) {
  4159                  var transferFormats = endpoint.transferFormats.map(function (s) { return _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"][s]; });
  4160                  if (transferFormats.indexOf(requestedTransferFormat) >= 0) {
  4161                      if ((transport === _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].WebSockets && !this.options.WebSocket) ||
  4162                          (transport === _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"].ServerSentEvents && !this.options.EventSource)) {
  4163                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Skipping transport '" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "' because it is not supported in your environment.'");
  4164                          return new Error("'" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "' is not supported in your environment.");
  4165                      }
  4166                      else {
  4167                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Selecting transport '" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "'.");
  4168                          try {
  4169                              return this.constructTransport(transport);
  4170                          }
  4171                          catch (ex) {
  4172                              return ex;
  4173                          }
  4174                      }
  4175                  }
  4176                  else {
  4177                      this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Skipping transport '" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "' because it does not support the requested transfer format '" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"][requestedTransferFormat] + "'.");
  4178                      return new Error("'" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "' does not support " + _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"][requestedTransferFormat] + ".");
  4179                  }
  4180              }
  4181              else {
  4182                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Skipping transport '" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "' because it was disabled by the client.");
  4183                  return new Error("'" + _ITransport__WEBPACK_IMPORTED_MODULE_2__["HttpTransportType"][transport] + "' is disabled by the client.");
  4184              }
  4185          }
  4186      };
  4187      HttpConnection.prototype.isITransport = function (transport) {
  4188          return transport && typeof (transport) === "object" && "connect" in transport;
  4189      };
  4190      HttpConnection.prototype.stopConnection = function (error) {
  4191          var _this = this;
  4192          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "HttpConnection.stopConnection(" + error + ") called while in state " + this.connectionState + ".");
  4193          this.transport = undefined;
  4194          // If we have a stopError, it takes precedence over the error from the transport
  4195          error = this.stopError || error;
  4196          this.stopError = undefined;
  4197          if (this.connectionState === "Disconnected" /* Disconnected */) {
  4198              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Debug, "Call to HttpConnection.stopConnection(" + error + ") was ignored because the connection is already in the disconnected state.");
  4199              return;
  4200          }
  4201          if (this.connectionState === "Connecting" /* Connecting */) {
  4202              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Warning, "Call to HttpConnection.stopConnection(" + error + ") was ignored because the connection is still in the connecting state.");
  4203              throw new Error("HttpConnection.stopConnection(" + error + ") was called while the connection is still in the connecting state.");
  4204          }
  4205          if (this.connectionState === "Disconnecting" /* Disconnecting */) {
  4206              // A call to stop() induced this call to stopConnection and needs to be completed.
  4207              // Any stop() awaiters will be scheduled to continue after the onclose callback fires.
  4208              this.stopPromiseResolver();
  4209          }
  4210          if (error) {
  4211              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "Connection disconnected with error '" + error + "'.");
  4212          }
  4213          else {
  4214              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Information, "Connection disconnected.");
  4215          }
  4216          if (this.sendQueue) {
  4217              this.sendQueue.stop().catch(function (e) {
  4218                  _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "TransportSendQueue.stop() threw error '" + e + "'.");
  4219              });
  4220              this.sendQueue = undefined;
  4221          }
  4222          this.connectionId = undefined;
  4223          this.connectionState = "Disconnected" /* Disconnected */;
  4224          if (this.connectionStarted) {
  4225              this.connectionStarted = false;
  4226              try {
  4227                  if (this.onclose) {
  4228                      this.onclose(error);
  4229                  }
  4230              }
  4231              catch (e) {
  4232                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Error, "HttpConnection.onclose(" + error + ") threw error '" + e + "'.");
  4233              }
  4234          }
  4235      };
  4236      HttpConnection.prototype.resolveUrl = function (url) {
  4237          // startsWith is not supported in IE
  4238          if (url.lastIndexOf("https://", 0) === 0 || url.lastIndexOf("http://", 0) === 0) {
  4239              return url;
  4240          }
  4241          if (!_Utils__WEBPACK_IMPORTED_MODULE_5__["Platform"].isBrowser || !window.document) {
  4242              throw new Error("Cannot resolve '" + url + "'.");
  4243          }
  4244          // Setting the url to the href propery of an anchor tag handles normalization
  4245          // for us. There are 3 main cases.
  4246          // 1. Relative path normalization e.g "b" -> "http://localhost:5000/a/b"
  4247          // 2. Absolute path normalization e.g "/a/b" -> "http://localhost:5000/a/b"
  4248          // 3. Networkpath reference normalization e.g "//localhost:5000/a/b" -> "http://localhost:5000/a/b"
  4249          var aTag = window.document.createElement("a");
  4250          aTag.href = url;
  4251          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Information, "Normalizing '" + url + "' to '" + aTag.href + "'.");
  4252          return aTag.href;
  4253      };
  4254      HttpConnection.prototype.resolveNegotiateUrl = function (url) {
  4255          var index = url.indexOf("?");
  4256          var negotiateUrl = url.substring(0, index === -1 ? url.length : index);
  4257          if (negotiateUrl[negotiateUrl.length - 1] !== "/") {
  4258              negotiateUrl += "/";
  4259          }
  4260          negotiateUrl += "negotiate";
  4261          negotiateUrl += index === -1 ? "" : url.substring(index);
  4262          if (negotiateUrl.indexOf("negotiateVersion") === -1) {
  4263              negotiateUrl += index === -1 ? "?" : "&";
  4264              negotiateUrl += "negotiateVersion=" + this.negotiateVersion;
  4265          }
  4266          return negotiateUrl;
  4267      };
  4268      return HttpConnection;
  4269  }());
  4270  
  4271  function transportMatches(requestedTransport, actualTransport) {
  4272      return !requestedTransport || ((actualTransport & requestedTransport) !== 0);
  4273  }
  4274  /** @private */
  4275  var TransportSendQueue = /** @class */ (function () {
  4276      function TransportSendQueue(transport) {
  4277          this.transport = transport;
  4278          this.buffer = [];
  4279          this.executing = true;
  4280          this.sendBufferedData = new PromiseSource();
  4281          this.transportResult = new PromiseSource();
  4282          this.sendLoopPromise = this.sendLoop();
  4283      }
  4284      TransportSendQueue.prototype.send = function (data) {
  4285          this.bufferData(data);
  4286          if (!this.transportResult) {
  4287              this.transportResult = new PromiseSource();
  4288          }
  4289          return this.transportResult.promise;
  4290      };
  4291      TransportSendQueue.prototype.stop = function () {
  4292          this.executing = false;
  4293          this.sendBufferedData.resolve();
  4294          return this.sendLoopPromise;
  4295      };
  4296      TransportSendQueue.prototype.bufferData = function (data) {
  4297          if (this.buffer.length && typeof (this.buffer[0]) !== typeof (data)) {
  4298              throw new Error("Expected data to be of type " + typeof (this.buffer) + " but was of type " + typeof (data));
  4299          }
  4300          this.buffer.push(data);
  4301          this.sendBufferedData.resolve();
  4302      };
  4303      TransportSendQueue.prototype.sendLoop = function () {
  4304          return __awaiter(this, void 0, void 0, function () {
  4305              var transportResult, data, error_1;
  4306              return __generator(this, function (_a) {
  4307                  switch (_a.label) {
  4308                      case 0:
  4309                          if (false) {}
  4310                          return [4 /*yield*/, this.sendBufferedData.promise];
  4311                      case 1:
  4312                          _a.sent();
  4313                          if (!this.executing) {
  4314                              if (this.transportResult) {
  4315                                  this.transportResult.reject("Connection stopped.");
  4316                              }
  4317                              return [3 /*break*/, 6];
  4318                          }
  4319                          this.sendBufferedData = new PromiseSource();
  4320                          transportResult = this.transportResult;
  4321                          this.transportResult = undefined;
  4322                          data = typeof (this.buffer[0]) === "string" ?
  4323                              this.buffer.join("") :
  4324                              TransportSendQueue.concatBuffers(this.buffer);
  4325                          this.buffer.length = 0;
  4326                          _a.label = 2;
  4327                      case 2:
  4328                          _a.trys.push([2, 4, , 5]);
  4329                          return [4 /*yield*/, this.transport.send(data)];
  4330                      case 3:
  4331                          _a.sent();
  4332                          transportResult.resolve();
  4333                          return [3 /*break*/, 5];
  4334                      case 4:
  4335                          error_1 = _a.sent();
  4336                          transportResult.reject(error_1);
  4337                          return [3 /*break*/, 5];
  4338                      case 5: return [3 /*break*/, 0];
  4339                      case 6: return [2 /*return*/];
  4340                  }
  4341              });
  4342          });
  4343      };
  4344      TransportSendQueue.concatBuffers = function (arrayBuffers) {
  4345          var totalLength = arrayBuffers.map(function (b) { return b.byteLength; }).reduce(function (a, b) { return a + b; });
  4346          var result = new Uint8Array(totalLength);
  4347          var offset = 0;
  4348          for (var _i = 0, arrayBuffers_1 = arrayBuffers; _i < arrayBuffers_1.length; _i++) {
  4349              var item = arrayBuffers_1[_i];
  4350              result.set(new Uint8Array(item), offset);
  4351              offset += item.byteLength;
  4352          }
  4353          return result.buffer;
  4354      };
  4355      return TransportSendQueue;
  4356  }());
  4357  
  4358  var PromiseSource = /** @class */ (function () {
  4359      function PromiseSource() {
  4360          var _this = this;
  4361          this.promise = new Promise(function (resolve, reject) {
  4362              var _a;
  4363              return _a = [resolve, reject], _this.resolver = _a[0], _this.rejecter = _a[1], _a;
  4364          });
  4365      }
  4366      PromiseSource.prototype.resolve = function () {
  4367          this.resolver();
  4368      };
  4369      PromiseSource.prototype.reject = function (reason) {
  4370          this.rejecter(reason);
  4371      };
  4372      return PromiseSource;
  4373  }());
  4374  
  4375  
  4376  /***/ }),
  4377  /* 20 */
  4378  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4379  
  4380  "use strict";
  4381  __webpack_require__.r(__webpack_exports__);
  4382  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HttpTransportType", function() { return HttpTransportType; });
  4383  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransferFormat", function() { return TransferFormat; });
  4384  // Copyright (c) .NET Foundation. All rights reserved.
  4385  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  4386  // This will be treated as a bit flag in the future, so we keep it using power-of-two values.
  4387  /** Specifies a specific HTTP transport type. */
  4388  var HttpTransportType;
  4389  (function (HttpTransportType) {
  4390      /** Specifies no transport preference. */
  4391      HttpTransportType[HttpTransportType["None"] = 0] = "None";
  4392      /** Specifies the WebSockets transport. */
  4393      HttpTransportType[HttpTransportType["WebSockets"] = 1] = "WebSockets";
  4394      /** Specifies the Server-Sent Events transport. */
  4395      HttpTransportType[HttpTransportType["ServerSentEvents"] = 2] = "ServerSentEvents";
  4396      /** Specifies the Long Polling transport. */
  4397      HttpTransportType[HttpTransportType["LongPolling"] = 4] = "LongPolling";
  4398  })(HttpTransportType || (HttpTransportType = {}));
  4399  /** Specifies the transfer format for a connection. */
  4400  var TransferFormat;
  4401  (function (TransferFormat) {
  4402      /** Specifies that only text data will be transmitted over the connection. */
  4403      TransferFormat[TransferFormat["Text"] = 1] = "Text";
  4404      /** Specifies that binary data will be transmitted over the connection. */
  4405      TransferFormat[TransferFormat["Binary"] = 2] = "Binary";
  4406  })(TransferFormat || (TransferFormat = {}));
  4407  
  4408  
  4409  /***/ }),
  4410  /* 21 */
  4411  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4412  
  4413  "use strict";
  4414  __webpack_require__.r(__webpack_exports__);
  4415  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LongPollingTransport", function() { return LongPollingTransport; });
  4416  /* harmony import */ var _AbortController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
  4417  /* harmony import */ var _Errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
  4418  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
  4419  /* harmony import */ var _ITransport__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
  4420  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
  4421  // Copyright (c) .NET Foundation. All rights reserved.
  4422  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  4423  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  4424      for (var s, i = 1, n = arguments.length; i < n; i++) {
  4425          s = arguments[i];
  4426          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4427              t[p] = s[p];
  4428      }
  4429      return t;
  4430  };
  4431  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  4432      return new (P || (P = Promise))(function (resolve, reject) {
  4433          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4434          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4435          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  4436          step((generator = generator.apply(thisArg, _arguments || [])).next());
  4437      });
  4438  };
  4439  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  4440      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  4441      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  4442      function verb(n) { return function (v) { return step([n, v]); }; }
  4443      function step(op) {
  4444          if (f) throw new TypeError("Generator is already executing.");
  4445          while (_) try {
  4446              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4447              if (y = 0, t) op = [op[0] & 2, t.value];
  4448              switch (op[0]) {
  4449                  case 0: case 1: t = op; break;
  4450                  case 4: _.label++; return { value: op[1], done: false };
  4451                  case 5: _.label++; y = op[1]; op = [0]; continue;
  4452                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  4453                  default:
  4454                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  4455                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  4456                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  4457                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  4458                      if (t[2]) _.ops.pop();
  4459                      _.trys.pop(); continue;
  4460              }
  4461              op = body.call(thisArg, _);
  4462          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  4463          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  4464      }
  4465  };
  4466  
  4467  
  4468  
  4469  
  4470  
  4471  // Not exported from 'index', this type is internal.
  4472  /** @private */
  4473  var LongPollingTransport = /** @class */ (function () {
  4474      function LongPollingTransport(httpClient, accessTokenFactory, logger, logMessageContent, withCredentials, headers) {
  4475          this.httpClient = httpClient;
  4476          this.accessTokenFactory = accessTokenFactory;
  4477          this.logger = logger;
  4478          this.pollAbort = new _AbortController__WEBPACK_IMPORTED_MODULE_0__["AbortController"]();
  4479          this.logMessageContent = logMessageContent;
  4480          this.withCredentials = withCredentials;
  4481          this.headers = headers;
  4482          this.running = false;
  4483          this.onreceive = null;
  4484          this.onclose = null;
  4485      }
  4486      Object.defineProperty(LongPollingTransport.prototype, "pollAborted", {
  4487          // This is an internal type, not exported from 'index' so this is really just internal.
  4488          get: function () {
  4489              return this.pollAbort.aborted;
  4490          },
  4491          enumerable: true,
  4492          configurable: true
  4493      });
  4494      LongPollingTransport.prototype.connect = function (url, transferFormat) {
  4495          return __awaiter(this, void 0, void 0, function () {
  4496              var _a, _b, name, value, headers, pollOptions, token, pollUrl, response;
  4497              return __generator(this, function (_c) {
  4498                  switch (_c.label) {
  4499                      case 0:
  4500                          _Utils__WEBPACK_IMPORTED_MODULE_4__["Arg"].isRequired(url, "url");
  4501                          _Utils__WEBPACK_IMPORTED_MODULE_4__["Arg"].isRequired(transferFormat, "transferFormat");
  4502                          _Utils__WEBPACK_IMPORTED_MODULE_4__["Arg"].isIn(transferFormat, _ITransport__WEBPACK_IMPORTED_MODULE_3__["TransferFormat"], "transferFormat");
  4503                          this.url = url;
  4504                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Connecting.");
  4505                          // Allow binary format on Node and Browsers that support binary content (indicated by the presence of responseType property)
  4506                          if (transferFormat === _ITransport__WEBPACK_IMPORTED_MODULE_3__["TransferFormat"].Binary &&
  4507                              (typeof XMLHttpRequest !== "undefined" && typeof new XMLHttpRequest().responseType !== "string")) {
  4508                              throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");
  4509                          }
  4510                          _b = Object(_Utils__WEBPACK_IMPORTED_MODULE_4__["getUserAgentHeader"])(), name = _b[0], value = _b[1];
  4511                          headers = __assign((_a = {}, _a[name] = value, _a), this.headers);
  4512                          pollOptions = {
  4513                              abortSignal: this.pollAbort.signal,
  4514                              headers: headers,
  4515                              timeout: 100000,
  4516                              withCredentials: this.withCredentials,
  4517                          };
  4518                          if (transferFormat === _ITransport__WEBPACK_IMPORTED_MODULE_3__["TransferFormat"].Binary) {
  4519                              pollOptions.responseType = "arraybuffer";
  4520                          }
  4521                          return [4 /*yield*/, this.getAccessToken()];
  4522                      case 1:
  4523                          token = _c.sent();
  4524                          this.updateHeaderToken(pollOptions, token);
  4525                          pollUrl = url + "&_=" + Date.now();
  4526                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) polling: " + pollUrl + ".");
  4527                          return [4 /*yield*/, this.httpClient.get(pollUrl, pollOptions)];
  4528                      case 2:
  4529                          response = _c.sent();
  4530                          if (response.statusCode !== 200) {
  4531                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "(LongPolling transport) Unexpected response code: " + response.statusCode + ".");
  4532                              // Mark running as false so that the poll immediately ends and runs the close logic
  4533                              this.closeError = new _Errors__WEBPACK_IMPORTED_MODULE_1__["HttpError"](response.statusText || "", response.statusCode);
  4534                              this.running = false;
  4535                          }
  4536                          else {
  4537                              this.running = true;
  4538                          }
  4539                          this.receiving = this.poll(this.url, pollOptions);
  4540                          return [2 /*return*/];
  4541                  }
  4542              });
  4543          });
  4544      };
  4545      LongPollingTransport.prototype.getAccessToken = function () {
  4546          return __awaiter(this, void 0, void 0, function () {
  4547              return __generator(this, function (_a) {
  4548                  switch (_a.label) {
  4549                      case 0:
  4550                          if (!this.accessTokenFactory) return [3 /*break*/, 2];
  4551                          return [4 /*yield*/, this.accessTokenFactory()];
  4552                      case 1: return [2 /*return*/, _a.sent()];
  4553                      case 2: return [2 /*return*/, null];
  4554                  }
  4555              });
  4556          });
  4557      };
  4558      LongPollingTransport.prototype.updateHeaderToken = function (request, token) {
  4559          if (!request.headers) {
  4560              request.headers = {};
  4561          }
  4562          if (token) {
  4563              // tslint:disable-next-line:no-string-literal
  4564              request.headers["Authorization"] = "Bearer " + token;
  4565              return;
  4566          }
  4567          // tslint:disable-next-line:no-string-literal
  4568          if (request.headers["Authorization"]) {
  4569              // tslint:disable-next-line:no-string-literal
  4570              delete request.headers["Authorization"];
  4571          }
  4572      };
  4573      LongPollingTransport.prototype.poll = function (url, pollOptions) {
  4574          return __awaiter(this, void 0, void 0, function () {
  4575              var token, pollUrl, response, e_1;
  4576              return __generator(this, function (_a) {
  4577                  switch (_a.label) {
  4578                      case 0:
  4579                          _a.trys.push([0, , 8, 9]);
  4580                          _a.label = 1;
  4581                      case 1:
  4582                          if (!this.running) return [3 /*break*/, 7];
  4583                          return [4 /*yield*/, this.getAccessToken()];
  4584                      case 2:
  4585                          token = _a.sent();
  4586                          this.updateHeaderToken(pollOptions, token);
  4587                          _a.label = 3;
  4588                      case 3:
  4589                          _a.trys.push([3, 5, , 6]);
  4590                          pollUrl = url + "&_=" + Date.now();
  4591                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) polling: " + pollUrl + ".");
  4592                          return [4 /*yield*/, this.httpClient.get(pollUrl, pollOptions)];
  4593                      case 4:
  4594                          response = _a.sent();
  4595                          if (response.statusCode === 204) {
  4596                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Information, "(LongPolling transport) Poll terminated by server.");
  4597                              this.running = false;
  4598                          }
  4599                          else if (response.statusCode !== 200) {
  4600                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Error, "(LongPolling transport) Unexpected response code: " + response.statusCode + ".");
  4601                              // Unexpected status code
  4602                              this.closeError = new _Errors__WEBPACK_IMPORTED_MODULE_1__["HttpError"](response.statusText || "", response.statusCode);
  4603                              this.running = false;
  4604                          }
  4605                          else {
  4606                              // Process the response
  4607                              if (response.content) {
  4608                                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) data received. " + Object(_Utils__WEBPACK_IMPORTED_MODULE_4__["getDataDetail"])(response.content, this.logMessageContent) + ".");
  4609                                  if (this.onreceive) {
  4610                                      this.onreceive(response.content);
  4611                                  }
  4612                              }
  4613                              else {
  4614                                  // This is another way timeout manifest.
  4615                                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Poll timed out, reissuing.");
  4616                              }
  4617                          }
  4618                          return [3 /*break*/, 6];
  4619                      case 5:
  4620                          e_1 = _a.sent();
  4621                          if (!this.running) {
  4622                              // Log but disregard errors that occur after stopping
  4623                              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Poll errored after shutdown: " + e_1.message);
  4624                          }
  4625                          else {
  4626                              if (e_1 instanceof _Errors__WEBPACK_IMPORTED_MODULE_1__["TimeoutError"]) {
  4627                                  // Ignore timeouts and reissue the poll.
  4628                                  this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Poll timed out, reissuing.");
  4629                              }
  4630                              else {
  4631                                  // Close the connection with the error as the result.
  4632                                  this.closeError = e_1;
  4633                                  this.running = false;
  4634                              }
  4635                          }
  4636                          return [3 /*break*/, 6];
  4637                      case 6: return [3 /*break*/, 1];
  4638                      case 7: return [3 /*break*/, 9];
  4639                      case 8:
  4640                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Polling complete.");
  4641                          // We will reach here with pollAborted==false when the server returned a response causing the transport to stop.
  4642                          // If pollAborted==true then client initiated the stop and the stop method will raise the close event after DELETE is sent.
  4643                          if (!this.pollAborted) {
  4644                              this.raiseOnClose();
  4645                          }
  4646                          return [7 /*endfinally*/];
  4647                      case 9: return [2 /*return*/];
  4648                  }
  4649              });
  4650          });
  4651      };
  4652      LongPollingTransport.prototype.send = function (data) {
  4653          return __awaiter(this, void 0, void 0, function () {
  4654              return __generator(this, function (_a) {
  4655                  if (!this.running) {
  4656                      return [2 /*return*/, Promise.reject(new Error("Cannot send until the transport is connected"))];
  4657                  }
  4658                  return [2 /*return*/, Object(_Utils__WEBPACK_IMPORTED_MODULE_4__["sendMessage"])(this.logger, "LongPolling", this.httpClient, this.url, this.accessTokenFactory, data, this.logMessageContent, this.withCredentials, this.headers)];
  4659              });
  4660          });
  4661      };
  4662      LongPollingTransport.prototype.stop = function () {
  4663          return __awaiter(this, void 0, void 0, function () {
  4664              var headers, _a, name_1, value, deleteOptions, token;
  4665              return __generator(this, function (_b) {
  4666                  switch (_b.label) {
  4667                      case 0:
  4668                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Stopping polling.");
  4669                          // Tell receiving loop to stop, abort any current request, and then wait for it to finish
  4670                          this.running = false;
  4671                          this.pollAbort.abort();
  4672                          _b.label = 1;
  4673                      case 1:
  4674                          _b.trys.push([1, , 5, 6]);
  4675                          return [4 /*yield*/, this.receiving];
  4676                      case 2:
  4677                          _b.sent();
  4678                          // Send DELETE to clean up long polling on the server
  4679                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) sending DELETE request to " + this.url + ".");
  4680                          headers = {};
  4681                          _a = Object(_Utils__WEBPACK_IMPORTED_MODULE_4__["getUserAgentHeader"])(), name_1 = _a[0], value = _a[1];
  4682                          headers[name_1] = value;
  4683                          deleteOptions = {
  4684                              headers: __assign({}, headers, this.headers),
  4685                              withCredentials: this.withCredentials,
  4686                          };
  4687                          return [4 /*yield*/, this.getAccessToken()];
  4688                      case 3:
  4689                          token = _b.sent();
  4690                          this.updateHeaderToken(deleteOptions, token);
  4691                          return [4 /*yield*/, this.httpClient.delete(this.url, deleteOptions)];
  4692                      case 4:
  4693                          _b.sent();
  4694                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) DELETE request sent.");
  4695                          return [3 /*break*/, 6];
  4696                      case 5:
  4697                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, "(LongPolling transport) Stop finished.");
  4698                          // Raise close event here instead of in polling
  4699                          // It needs to happen after the DELETE request is sent
  4700                          this.raiseOnClose();
  4701                          return [7 /*endfinally*/];
  4702                      case 6: return [2 /*return*/];
  4703                  }
  4704              });
  4705          });
  4706      };
  4707      LongPollingTransport.prototype.raiseOnClose = function () {
  4708          if (this.onclose) {
  4709              var logMessage = "(LongPolling transport) Firing onclose event.";
  4710              if (this.closeError) {
  4711                  logMessage += " Error: " + this.closeError;
  4712              }
  4713              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_2__["LogLevel"].Trace, logMessage);
  4714              this.onclose(this.closeError);
  4715          }
  4716      };
  4717      return LongPollingTransport;
  4718  }());
  4719  
  4720  
  4721  
  4722  /***/ }),
  4723  /* 22 */
  4724  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4725  
  4726  "use strict";
  4727  __webpack_require__.r(__webpack_exports__);
  4728  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbortController", function() { return AbortController; });
  4729  // Copyright (c) .NET Foundation. All rights reserved.
  4730  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  4731  // Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController
  4732  // We don't actually ever use the API being polyfilled, we always use the polyfill because
  4733  // it's a very new API right now.
  4734  // Not exported from index.
  4735  /** @private */
  4736  var AbortController = /** @class */ (function () {
  4737      function AbortController() {
  4738          this.isAborted = false;
  4739          this.onabort = null;
  4740      }
  4741      AbortController.prototype.abort = function () {
  4742          if (!this.isAborted) {
  4743              this.isAborted = true;
  4744              if (this.onabort) {
  4745                  this.onabort();
  4746              }
  4747          }
  4748      };
  4749      Object.defineProperty(AbortController.prototype, "signal", {
  4750          get: function () {
  4751              return this;
  4752          },
  4753          enumerable: true,
  4754          configurable: true
  4755      });
  4756      Object.defineProperty(AbortController.prototype, "aborted", {
  4757          get: function () {
  4758              return this.isAborted;
  4759          },
  4760          enumerable: true,
  4761          configurable: true
  4762      });
  4763      return AbortController;
  4764  }());
  4765  
  4766  
  4767  
  4768  /***/ }),
  4769  /* 23 */
  4770  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4771  
  4772  "use strict";
  4773  __webpack_require__.r(__webpack_exports__);
  4774  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ServerSentEventsTransport", function() { return ServerSentEventsTransport; });
  4775  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
  4776  /* harmony import */ var _ITransport__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20);
  4777  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
  4778  // Copyright (c) .NET Foundation. All rights reserved.
  4779  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  4780  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  4781      for (var s, i = 1, n = arguments.length; i < n; i++) {
  4782          s = arguments[i];
  4783          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4784              t[p] = s[p];
  4785      }
  4786      return t;
  4787  };
  4788  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  4789      return new (P || (P = Promise))(function (resolve, reject) {
  4790          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4791          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4792          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  4793          step((generator = generator.apply(thisArg, _arguments || [])).next());
  4794      });
  4795  };
  4796  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  4797      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  4798      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  4799      function verb(n) { return function (v) { return step([n, v]); }; }
  4800      function step(op) {
  4801          if (f) throw new TypeError("Generator is already executing.");
  4802          while (_) try {
  4803              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4804              if (y = 0, t) op = [op[0] & 2, t.value];
  4805              switch (op[0]) {
  4806                  case 0: case 1: t = op; break;
  4807                  case 4: _.label++; return { value: op[1], done: false };
  4808                  case 5: _.label++; y = op[1]; op = [0]; continue;
  4809                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  4810                  default:
  4811                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  4812                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  4813                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  4814                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  4815                      if (t[2]) _.ops.pop();
  4816                      _.trys.pop(); continue;
  4817              }
  4818              op = body.call(thisArg, _);
  4819          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  4820          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  4821      }
  4822  };
  4823  
  4824  
  4825  
  4826  /** @private */
  4827  var ServerSentEventsTransport = /** @class */ (function () {
  4828      function ServerSentEventsTransport(httpClient, accessTokenFactory, logger, logMessageContent, eventSourceConstructor, withCredentials, headers) {
  4829          this.httpClient = httpClient;
  4830          this.accessTokenFactory = accessTokenFactory;
  4831          this.logger = logger;
  4832          this.logMessageContent = logMessageContent;
  4833          this.withCredentials = withCredentials;
  4834          this.eventSourceConstructor = eventSourceConstructor;
  4835          this.headers = headers;
  4836          this.onreceive = null;
  4837          this.onclose = null;
  4838      }
  4839      ServerSentEventsTransport.prototype.connect = function (url, transferFormat) {
  4840          return __awaiter(this, void 0, void 0, function () {
  4841              var token;
  4842              var _this = this;
  4843              return __generator(this, function (_a) {
  4844                  switch (_a.label) {
  4845                      case 0:
  4846                          _Utils__WEBPACK_IMPORTED_MODULE_2__["Arg"].isRequired(url, "url");
  4847                          _Utils__WEBPACK_IMPORTED_MODULE_2__["Arg"].isRequired(transferFormat, "transferFormat");
  4848                          _Utils__WEBPACK_IMPORTED_MODULE_2__["Arg"].isIn(transferFormat, _ITransport__WEBPACK_IMPORTED_MODULE_1__["TransferFormat"], "transferFormat");
  4849                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(SSE transport) Connecting.");
  4850                          // set url before accessTokenFactory because this.url is only for send and we set the auth header instead of the query string for send
  4851                          this.url = url;
  4852                          if (!this.accessTokenFactory) return [3 /*break*/, 2];
  4853                          return [4 /*yield*/, this.accessTokenFactory()];
  4854                      case 1:
  4855                          token = _a.sent();
  4856                          if (token) {
  4857                              url += (url.indexOf("?") < 0 ? "?" : "&") + ("access_token=" + encodeURIComponent(token));
  4858                          }
  4859                          _a.label = 2;
  4860                      case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
  4861                              var opened = false;
  4862                              if (transferFormat !== _ITransport__WEBPACK_IMPORTED_MODULE_1__["TransferFormat"].Text) {
  4863                                  reject(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));
  4864                                  return;
  4865                              }
  4866                              var eventSource;
  4867                              if (_Utils__WEBPACK_IMPORTED_MODULE_2__["Platform"].isBrowser || _Utils__WEBPACK_IMPORTED_MODULE_2__["Platform"].isWebWorker) {
  4868                                  eventSource = new _this.eventSourceConstructor(url, { withCredentials: _this.withCredentials });
  4869                              }
  4870                              else {
  4871                                  // Non-browser passes cookies via the dictionary
  4872                                  var cookies = _this.httpClient.getCookieString(url);
  4873                                  var headers = {};
  4874                                  headers.Cookie = cookies;
  4875                                  var _a = Object(_Utils__WEBPACK_IMPORTED_MODULE_2__["getUserAgentHeader"])(), name_1 = _a[0], value = _a[1];
  4876                                  headers[name_1] = value;
  4877                                  eventSource = new _this.eventSourceConstructor(url, { withCredentials: _this.withCredentials, headers: __assign({}, headers, _this.headers) });
  4878                              }
  4879                              try {
  4880                                  eventSource.onmessage = function (e) {
  4881                                      if (_this.onreceive) {
  4882                                          try {
  4883                                              _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(SSE transport) data received. " + Object(_Utils__WEBPACK_IMPORTED_MODULE_2__["getDataDetail"])(e.data, _this.logMessageContent) + ".");
  4884                                              _this.onreceive(e.data);
  4885                                          }
  4886                                          catch (error) {
  4887                                              _this.close(error);
  4888                                              return;
  4889                                          }
  4890                                      }
  4891                                  };
  4892                                  eventSource.onerror = function (e) {
  4893                                      var error = new Error(e.data || "Error occurred");
  4894                                      if (opened) {
  4895                                          _this.close(error);
  4896                                      }
  4897                                      else {
  4898                                          reject(error);
  4899                                      }
  4900                                  };
  4901                                  eventSource.onopen = function () {
  4902                                      _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Information, "SSE connected to " + _this.url);
  4903                                      _this.eventSource = eventSource;
  4904                                      opened = true;
  4905                                      resolve();
  4906                                  };
  4907                              }
  4908                              catch (e) {
  4909                                  reject(e);
  4910                                  return;
  4911                              }
  4912                          })];
  4913                  }
  4914              });
  4915          });
  4916      };
  4917      ServerSentEventsTransport.prototype.send = function (data) {
  4918          return __awaiter(this, void 0, void 0, function () {
  4919              return __generator(this, function (_a) {
  4920                  if (!this.eventSource) {
  4921                      return [2 /*return*/, Promise.reject(new Error("Cannot send until the transport is connected"))];
  4922                  }
  4923                  return [2 /*return*/, Object(_Utils__WEBPACK_IMPORTED_MODULE_2__["sendMessage"])(this.logger, "SSE", this.httpClient, this.url, this.accessTokenFactory, data, this.logMessageContent, this.withCredentials, this.headers)];
  4924              });
  4925          });
  4926      };
  4927      ServerSentEventsTransport.prototype.stop = function () {
  4928          this.close();
  4929          return Promise.resolve();
  4930      };
  4931      ServerSentEventsTransport.prototype.close = function (e) {
  4932          if (this.eventSource) {
  4933              this.eventSource.close();
  4934              this.eventSource = undefined;
  4935              if (this.onclose) {
  4936                  this.onclose(e);
  4937              }
  4938          }
  4939      };
  4940      return ServerSentEventsTransport;
  4941  }());
  4942  
  4943  
  4944  
  4945  /***/ }),
  4946  /* 24 */
  4947  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4948  
  4949  "use strict";
  4950  __webpack_require__.r(__webpack_exports__);
  4951  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebSocketTransport", function() { return WebSocketTransport; });
  4952  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
  4953  /* harmony import */ var _ITransport__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20);
  4954  /* harmony import */ var _Utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
  4955  // Copyright (c) .NET Foundation. All rights reserved.
  4956  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  4957  var __assign = (undefined && undefined.__assign) || Object.assign || function(t) {
  4958      for (var s, i = 1, n = arguments.length; i < n; i++) {
  4959          s = arguments[i];
  4960          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  4961              t[p] = s[p];
  4962      }
  4963      return t;
  4964  };
  4965  var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  4966      return new (P || (P = Promise))(function (resolve, reject) {
  4967          function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4968          function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4969          function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  4970          step((generator = generator.apply(thisArg, _arguments || [])).next());
  4971      });
  4972  };
  4973  var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
  4974      var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  4975      return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  4976      function verb(n) { return function (v) { return step([n, v]); }; }
  4977      function step(op) {
  4978          if (f) throw new TypeError("Generator is already executing.");
  4979          while (_) try {
  4980              if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4981              if (y = 0, t) op = [op[0] & 2, t.value];
  4982              switch (op[0]) {
  4983                  case 0: case 1: t = op; break;
  4984                  case 4: _.label++; return { value: op[1], done: false };
  4985                  case 5: _.label++; y = op[1]; op = [0]; continue;
  4986                  case 7: op = _.ops.pop(); _.trys.pop(); continue;
  4987                  default:
  4988                      if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  4989                      if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  4990                      if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  4991                      if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  4992                      if (t[2]) _.ops.pop();
  4993                      _.trys.pop(); continue;
  4994              }
  4995              op = body.call(thisArg, _);
  4996          } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  4997          if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  4998      }
  4999  };
  5000  
  5001  
  5002  
  5003  /** @private */
  5004  var WebSocketTransport = /** @class */ (function () {
  5005      function WebSocketTransport(httpClient, accessTokenFactory, logger, logMessageContent, webSocketConstructor, headers) {
  5006          this.logger = logger;
  5007          this.accessTokenFactory = accessTokenFactory;
  5008          this.logMessageContent = logMessageContent;
  5009          this.webSocketConstructor = webSocketConstructor;
  5010          this.httpClient = httpClient;
  5011          this.onreceive = null;
  5012          this.onclose = null;
  5013          this.headers = headers;
  5014      }
  5015      WebSocketTransport.prototype.connect = function (url, transferFormat) {
  5016          return __awaiter(this, void 0, void 0, function () {
  5017              var token;
  5018              var _this = this;
  5019              return __generator(this, function (_a) {
  5020                  switch (_a.label) {
  5021                      case 0:
  5022                          _Utils__WEBPACK_IMPORTED_MODULE_2__["Arg"].isRequired(url, "url");
  5023                          _Utils__WEBPACK_IMPORTED_MODULE_2__["Arg"].isRequired(transferFormat, "transferFormat");
  5024                          _Utils__WEBPACK_IMPORTED_MODULE_2__["Arg"].isIn(transferFormat, _ITransport__WEBPACK_IMPORTED_MODULE_1__["TransferFormat"], "transferFormat");
  5025                          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(WebSockets transport) Connecting.");
  5026                          if (!this.accessTokenFactory) return [3 /*break*/, 2];
  5027                          return [4 /*yield*/, this.accessTokenFactory()];
  5028                      case 1:
  5029                          token = _a.sent();
  5030                          if (token) {
  5031                              url += (url.indexOf("?") < 0 ? "?" : "&") + ("access_token=" + encodeURIComponent(token));
  5032                          }
  5033                          _a.label = 2;
  5034                      case 2: return [2 /*return*/, new Promise(function (resolve, reject) {
  5035                              url = url.replace(/^http/, "ws");
  5036                              var webSocket;
  5037                              var cookies = _this.httpClient.getCookieString(url);
  5038                              var opened = false;
  5039                              if (_Utils__WEBPACK_IMPORTED_MODULE_2__["Platform"].isNode) {
  5040                                  var headers = {};
  5041                                  var _a = Object(_Utils__WEBPACK_IMPORTED_MODULE_2__["getUserAgentHeader"])(), name_1 = _a[0], value = _a[1];
  5042                                  headers[name_1] = value;
  5043                                  if (cookies) {
  5044                                      headers["Cookie"] = "" + cookies;
  5045                                  }
  5046                                  // Only pass headers when in non-browser environments
  5047                                  webSocket = new _this.webSocketConstructor(url, undefined, {
  5048                                      headers: __assign({}, headers, _this.headers),
  5049                                  });
  5050                              }
  5051                              if (!webSocket) {
  5052                                  // Chrome is not happy with passing 'undefined' as protocol
  5053                                  webSocket = new _this.webSocketConstructor(url);
  5054                              }
  5055                              if (transferFormat === _ITransport__WEBPACK_IMPORTED_MODULE_1__["TransferFormat"].Binary) {
  5056                                  webSocket.binaryType = "arraybuffer";
  5057                              }
  5058                              // tslint:disable-next-line:variable-name
  5059                              webSocket.onopen = function (_event) {
  5060                                  _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Information, "WebSocket connected to " + url + ".");
  5061                                  _this.webSocket = webSocket;
  5062                                  opened = true;
  5063                                  resolve();
  5064                              };
  5065                              webSocket.onerror = function (event) {
  5066                                  var error = null;
  5067                                  // ErrorEvent is a browser only type we need to check if the type exists before using it
  5068                                  if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
  5069                                      error = event.error;
  5070                                  }
  5071                                  else {
  5072                                      error = new Error("There was an error with the transport.");
  5073                                  }
  5074                                  reject(error);
  5075                              };
  5076                              webSocket.onmessage = function (message) {
  5077                                  _this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(WebSockets transport) data received. " + Object(_Utils__WEBPACK_IMPORTED_MODULE_2__["getDataDetail"])(message.data, _this.logMessageContent) + ".");
  5078                                  if (_this.onreceive) {
  5079                                      try {
  5080                                          _this.onreceive(message.data);
  5081                                      }
  5082                                      catch (error) {
  5083                                          _this.close(error);
  5084                                          return;
  5085                                      }
  5086                                  }
  5087                              };
  5088                              webSocket.onclose = function (event) {
  5089                                  // Don't call close handler if connection was never established
  5090                                  // We'll reject the connect call instead
  5091                                  if (opened) {
  5092                                      _this.close(event);
  5093                                  }
  5094                                  else {
  5095                                      var error = null;
  5096                                      // ErrorEvent is a browser only type we need to check if the type exists before using it
  5097                                      if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
  5098                                          error = event.error;
  5099                                      }
  5100                                      else {
  5101                                          error = new Error("There was an error with the transport.");
  5102                                      }
  5103                                      reject(error);
  5104                                  }
  5105                              };
  5106                          })];
  5107                  }
  5108              });
  5109          });
  5110      };
  5111      WebSocketTransport.prototype.send = function (data) {
  5112          if (this.webSocket && this.webSocket.readyState === this.webSocketConstructor.OPEN) {
  5113              this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(WebSockets transport) sending data. " + Object(_Utils__WEBPACK_IMPORTED_MODULE_2__["getDataDetail"])(data, this.logMessageContent) + ".");
  5114              this.webSocket.send(data);
  5115              return Promise.resolve();
  5116          }
  5117          return Promise.reject("WebSocket is not in the OPEN state");
  5118      };
  5119      WebSocketTransport.prototype.stop = function () {
  5120          if (this.webSocket) {
  5121              // Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning
  5122              // This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects
  5123              this.close(undefined);
  5124          }
  5125          return Promise.resolve();
  5126      };
  5127      WebSocketTransport.prototype.close = function (event) {
  5128          // webSocket will be null if the transport did not start successfully
  5129          if (this.webSocket) {
  5130              // Clear websocket handlers because we are considering the socket closed now
  5131              this.webSocket.onclose = function () { };
  5132              this.webSocket.onmessage = function () { };
  5133              this.webSocket.onerror = function () { };
  5134              this.webSocket.close();
  5135              this.webSocket = undefined;
  5136          }
  5137          this.logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_0__["LogLevel"].Trace, "(WebSockets transport) socket closed.");
  5138          if (this.onclose) {
  5139              if (this.isCloseEvent(event) && (event.wasClean === false || event.code !== 1000)) {
  5140                  this.onclose(new Error("WebSocket closed with status code: " + event.code + " (" + event.reason + ")."));
  5141              }
  5142              else if (event instanceof Error) {
  5143                  this.onclose(event);
  5144              }
  5145              else {
  5146                  this.onclose();
  5147              }
  5148          }
  5149      };
  5150      WebSocketTransport.prototype.isCloseEvent = function (event) {
  5151          return event && typeof event.wasClean === "boolean" && typeof event.code === "number";
  5152      };
  5153      return WebSocketTransport;
  5154  }());
  5155  
  5156  
  5157  
  5158  /***/ }),
  5159  /* 25 */
  5160  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5161  
  5162  "use strict";
  5163  __webpack_require__.r(__webpack_exports__);
  5164  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JsonHubProtocol", function() { return JsonHubProtocol; });
  5165  /* harmony import */ var _IHubProtocol__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
  5166  /* harmony import */ var _ILogger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
  5167  /* harmony import */ var _ITransport__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
  5168  /* harmony import */ var _Loggers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
  5169  /* harmony import */ var _TextMessageFormat__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(14);
  5170  // Copyright (c) .NET Foundation. All rights reserved.
  5171  // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  5172  
  5173  
  5174  
  5175  
  5176  
  5177  var JSON_HUB_PROTOCOL_NAME = "json";
  5178  /** Implements the JSON Hub Protocol. */
  5179  var JsonHubProtocol = /** @class */ (function () {
  5180      function JsonHubProtocol() {
  5181          /** @inheritDoc */
  5182          this.name = JSON_HUB_PROTOCOL_NAME;
  5183          /** @inheritDoc */
  5184          this.version = 1;
  5185          /** @inheritDoc */
  5186          this.transferFormat = _ITransport__WEBPACK_IMPORTED_MODULE_2__["TransferFormat"].Text;
  5187      }
  5188      /** Creates an array of {@link @microsoft/signalr.HubMessage} objects from the specified serialized representation.
  5189       *
  5190       * @param {string} input A string containing the serialized representation.
  5191       * @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
  5192       */
  5193      JsonHubProtocol.prototype.parseMessages = function (input, logger) {
  5194          // The interface does allow "ArrayBuffer" to be passed in, but this implementation does not. So let's throw a useful error.
  5195          if (typeof input !== "string") {
  5196              throw new Error("Invalid input for JSON hub protocol. Expected a string.");
  5197          }
  5198          if (!input) {
  5199              return [];
  5200          }
  5201          if (logger === null) {
  5202              logger = _Loggers__WEBPACK_IMPORTED_MODULE_3__["NullLogger"].instance;
  5203          }
  5204          // Parse the messages
  5205          var messages = _TextMessageFormat__WEBPACK_IMPORTED_MODULE_4__["TextMessageFormat"].parse(input);
  5206          var hubMessages = [];
  5207          for (var _i = 0, messages_1 = messages; _i < messages_1.length; _i++) {
  5208              var message = messages_1[_i];
  5209              var parsedMessage = JSON.parse(message);
  5210              if (typeof parsedMessage.type !== "number") {
  5211                  throw new Error("Invalid payload.");
  5212              }
  5213              switch (parsedMessage.type) {
  5214                  case _IHubProtocol__WEBPACK_IMPORTED_MODULE_0__["MessageType"].Invocation:
  5215                      this.isInvocationMessage(parsedMessage);
  5216                      break;
  5217                  case _IHubProtocol__WEBPACK_IMPORTED_MODULE_0__["MessageType"].StreamItem:
  5218                      this.isStreamItemMessage(parsedMessage);
  5219                      break;
  5220                  case _IHubProtocol__WEBPACK_IMPORTED_MODULE_0__["MessageType"].Completion:
  5221                      this.isCompletionMessage(parsedMessage);
  5222                      break;
  5223                  case _IHubProtocol__WEBPACK_IMPORTED_MODULE_0__["MessageType"].Ping:
  5224                      // Single value, no need to validate
  5225                      break;
  5226                  case _IHubProtocol__WEBPACK_IMPORTED_MODULE_0__["MessageType"].Close:
  5227                      // All optional values, no need to validate
  5228                      break;
  5229                  default:
  5230                      // Future protocol changes can add message types, old clients can ignore them
  5231                      logger.log(_ILogger__WEBPACK_IMPORTED_MODULE_1__["LogLevel"].Information, "Unknown message type '" + parsedMessage.type + "' ignored.");
  5232                      continue;
  5233              }
  5234              hubMessages.push(parsedMessage);
  5235          }
  5236          return hubMessages;
  5237      };
  5238      /** Writes the specified {@link @microsoft/signalr.HubMessage} to a string and returns it.
  5239       *
  5240       * @param {HubMessage} message The message to write.
  5241       * @returns {string} A string containing the serialized representation of the message.
  5242       */
  5243      JsonHubProtocol.prototype.writeMessage = function (message) {
  5244          return _TextMessageFormat__WEBPACK_IMPORTED_MODULE_4__["TextMessageFormat"].write(JSON.stringify(message));
  5245      };
  5246      JsonHubProtocol.prototype.isInvocationMessage = function (message) {
  5247          this.assertNotEmptyString(message.target, "Invalid payload for Invocation message.");
  5248          if (message.invocationId !== undefined) {
  5249              this.assertNotEmptyString(message.invocationId, "Invalid payload for Invocation message.");
  5250          }
  5251      };
  5252      JsonHubProtocol.prototype.isStreamItemMessage = function (message) {
  5253          this.assertNotEmptyString(message.invocationId, "Invalid payload for StreamItem message.");
  5254          if (message.item === undefined) {
  5255              throw new Error("Invalid payload for StreamItem message.");
  5256          }
  5257      };
  5258      JsonHubProtocol.prototype.isCompletionMessage = function (message) {
  5259          if (message.result && message.error) {
  5260              throw new Error("Invalid payload for Completion message.");
  5261          }
  5262          if (!message.result && message.error) {
  5263              this.assertNotEmptyString(message.error, "Invalid payload for Completion message.");
  5264          }
  5265          this.assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
  5266      };
  5267      JsonHubProtocol.prototype.assertNotEmptyString = function (value, errorMessage) {
  5268          if (typeof value !== "string" || value === "") {
  5269              throw new Error(errorMessage);
  5270          }
  5271      };
  5272      return JsonHubProtocol;
  5273  }());
  5274  
  5275  
  5276  
  5277  /***/ })
  5278  /******/ ]);
  5279  });
  5280  //# sourceMappingURL=signalr.js.map