@flashphoner/websdk 2.0.260 → 2.0.261

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7632,6 +7632,12 @@ var ERROR_INFO = Object.freeze({
7632
7632
  * @memberOf Flashphoner.constants.ERROR_INFO
7633
7633
  */
7634
7634
  CAN_NOT_SET_RESOLUTION: 'Cannot switch a published stream resolution',
7635
+ /**
7636
+ * Error if cannot get peer connection stats
7637
+ * @event CAN_NOT_GET_STATS
7638
+ * @memberOf Flashphoner.constants.ERROR_INFO
7639
+ */
7640
+ CAN_NOT_GET_STATS: 'Cannot get PeerConnection stats',
7635
7641
  /**
7636
7642
  * Local browser error detected
7637
7643
  * @event LOCAL_ERROR
@@ -7831,6 +7837,12 @@ module.exports = {
7831
7837
  },{}],40:[function(require,module,exports){
7832
7838
  'use strict';
7833
7839
 
7840
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
7841
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7842
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7843
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7844
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7845
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7834
7846
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7835
7847
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
7836
7848
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
@@ -7842,6 +7854,7 @@ var constants = require("./constants");
7842
7854
  var util = require('./util');
7843
7855
  var LoggerObject = require('./util').logger;
7844
7856
  var clientInfo = require('./client-info');
7857
+ var StatsCollector = require('./stats-collector');
7845
7858
  var _Promise = require('promise-polyfill');
7846
7859
  var KalmanFilter = require('kalmanjs');
7847
7860
  var browserDetails = require('webrtc-adapter')["default"].browserDetails;
@@ -8385,6 +8398,9 @@ var createSession = function createSession(options) {
8385
8398
  //callbacks added using session.on()
8386
8399
  var callbacks = {};
8387
8400
  var wsConnection;
8401
+
8402
+ // WebRTC metrics sending description
8403
+ var webRTCMetricsServerDescription;
8388
8404
  if (lbUrl) {
8389
8405
  requestURL(lbUrl);
8390
8406
  } else {
@@ -8487,6 +8503,7 @@ var createSession = function createSession(options) {
8487
8503
  case 'getUserData':
8488
8504
  authToken = obj.authToken;
8489
8505
  cConfig = obj;
8506
+ webRTCMetricsServerDescription = obj.webRTCMetricsServerDescription;
8490
8507
  onSessionStatusChange(SESSION_STATUS.ESTABLISHED, obj);
8491
8508
  break;
8492
8509
  case 'setRemoteSDP':
@@ -8591,6 +8608,37 @@ var createSession = function createSession(options) {
8591
8608
  streamRefreshHandlers[obj.mediaSessionId](obj);
8592
8609
  }
8593
8610
  break;
8611
+ case "webRTCMetricsDescriptionUpdate":
8612
+ if (obj.ids) {
8613
+ obj.ids.forEach(function (id) {
8614
+ if (streamRefreshHandlers[id]) {
8615
+ streamRefreshHandlers[id](obj);
8616
+ }
8617
+ });
8618
+ } else {
8619
+ if (obj.compression) {
8620
+ webRTCMetricsServerDescription.compression = obj.compression;
8621
+ }
8622
+ if (obj.batchSize) {
8623
+ webRTCMetricsServerDescription.batchSize = obj.batchSize;
8624
+ }
8625
+ if (obj.sampling) {
8626
+ webRTCMetricsServerDescription.sampling = obj.sampling;
8627
+ }
8628
+ if (obj.types) {
8629
+ webRTCMetricsServerDescription.types = obj.types;
8630
+ }
8631
+ if (obj.collect) {
8632
+ webRTCMetricsServerDescription.collect = obj.collect;
8633
+ }
8634
+ for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
8635
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
8636
+ _id = _Object$entries$_i[0],
8637
+ handler = _Object$entries$_i[1];
8638
+ handler(obj);
8639
+ }
8640
+ }
8641
+ break;
8594
8642
  default:
8595
8643
  logger.info(LOG_PREFIX, "Unknown server message " + data.message);
8596
8644
  }
@@ -8602,10 +8650,12 @@ var createSession = function createSession(options) {
8602
8650
 
8603
8651
  //WebSocket send helper
8604
8652
  function send(message, data) {
8605
- wsConnection.send(JSON.stringify({
8606
- message: message,
8607
- data: [data]
8608
- }));
8653
+ if (wsConnection.readyState === WebSocket.OPEN) {
8654
+ wsConnection.send(JSON.stringify({
8655
+ message: message,
8656
+ data: [data]
8657
+ }));
8658
+ }
8609
8659
  }
8610
8660
 
8611
8661
  //Session status update helper
@@ -9636,6 +9686,7 @@ var createSession = function createSession(options) {
9636
9686
  var videoState_;
9637
9687
  var connectionQuality;
9638
9688
  var videoBytes = 0;
9689
+ var statsCollector = null;
9639
9690
 
9640
9691
  /**
9641
9692
  * Represents media stream.
@@ -9668,7 +9719,7 @@ var createSession = function createSession(options) {
9668
9719
  mediaConnection.setRemoteSdp(_sdp).then(function () {});
9669
9720
  return;
9670
9721
  }
9671
- if (streamInfo.available != undefined) {
9722
+ if (streamInfo.available !== undefined) {
9672
9723
  for (var i = 0; i < availableCallbacks.length; i++) {
9673
9724
  info_ = streamInfo.reason;
9674
9725
  if (streamInfo.available == "true") {
@@ -9714,10 +9765,28 @@ var createSession = function createSession(options) {
9714
9765
  if (mediaConnection) {
9715
9766
  mediaConnection.close(cacheLocalResources);
9716
9767
  }
9768
+ if (statsCollector) {
9769
+ statsCollector.stop();
9770
+ statsCollector = null;
9771
+ }
9717
9772
  }
9718
9773
  if (record_ && typeof streamInfo.recordName !== 'undefined') {
9719
9774
  recordFileName = streamInfo.recordName;
9720
9775
  }
9776
+
9777
+ // Set up metrics collection
9778
+ if (event === STREAM_STATUS.PUBLISHING || event === STREAM_STATUS.PLAYING) {
9779
+ if (webRTCMetricsServerDescription && !statsCollector) {
9780
+ statsCollector = StatsCollector.StreamStatsCollector(webRTCMetricsServerDescription, id_, mediaConnection, wsConnection, logger);
9781
+ statsCollector.start();
9782
+ }
9783
+ }
9784
+
9785
+ // Pause or resume metrics collection
9786
+ if (!streamInfo.status && streamInfo.collect !== undefined && statsCollector) {
9787
+ statsCollector.update(streamInfo);
9788
+ }
9789
+
9721
9790
  //fire stream event
9722
9791
  if (callbacks[event]) {
9723
9792
  callbacks[event](stream);
@@ -10951,7 +11020,7 @@ module.exports = {
10951
11020
  Browser: util.Browser
10952
11021
  };
10953
11022
 
10954
- },{"./client-info":38,"./constants":39,"./media-source-media-provider":41,"./temasys-media-provider":1,"./util":42,"./webrtc-media-provider":43,"./websocket-media-provider":1,"kalmanjs":2,"promise-polyfill":4,"uuid":8,"webrtc-adapter":23}],41:[function(require,module,exports){
11023
+ },{"./client-info":38,"./constants":39,"./media-source-media-provider":41,"./stats-collector":42,"./temasys-media-provider":1,"./util":43,"./webrtc-media-provider":44,"./websocket-media-provider":1,"kalmanjs":2,"promise-polyfill":4,"uuid":8,"webrtc-adapter":23}],41:[function(require,module,exports){
10955
11024
  (function (global){(function (){
10956
11025
  function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}!function(t){if("object"==(typeof exports==="undefined"?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).MediaSourceMediaProvider=t();}}(function(){var define,module,exports;return function t(e,r,n){function i(a,s){if(!r[a]){if(!e[a]){var f="function"==typeof require&&require;if(!s&&f)return f(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u;}var c=r[a]={exports:{}};e[a][0].call(c.exports,function(t){return i(e[a][1][t]||t);},c,c.exports,t,e,r,n);}return r[a].exports;}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i;}({1:[function(t,e,r){e.exports=function(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(var r=new DataView(t),n=new DataView(e),i=t.byteLength;i--;)if(r.getUint8(i)!==n.getUint8(i))return!1;return!0;};},{}],2:[function(t,e,r){var n=r;n.bignum=t(16),n.define=t(3).define,n.base=t(5),n.constants=t(9),n.decoders=t(11),n.encoders=t(14);},{11:11,14:14,16:16,3:3,5:5,9:9}],3:[function(t,e,r){var n=t(2),i=t(474);function o(t,e){this.name=t,this.body=e,this.decoders={},this.encoders={};}r.define=function(t,e){return new o(t,e);},o.prototype._createNamed=function(e){var r;try{r=t(557).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})");}catch(t){r=function r(t){this._initNamed(t);};}return i(r,e),r.prototype._initNamed=function(t){e.call(this,t);},new r(this);},o.prototype._getDecoder=function(t){return t=t||"der",this.decoders.hasOwnProperty(t)||(this.decoders[t]=this._createNamed(n.decoders[t])),this.decoders[t];},o.prototype.decode=function(t,e,r){return this._getDecoder(e).decode(t,r);},o.prototype._getEncoder=function(t){return t=t||"der",this.encoders.hasOwnProperty(t)||(this.encoders[t]=this._createNamed(n.encoders[t])),this.encoders[t];},o.prototype.encode=function(t,e,r){return this._getEncoder(e).encode(t,r);};},{2:2,474:474,557:557}],4:[function(t,e,r){var n=t(474),i=t(5).Reporter,o=t(54).Buffer;function a(t,e){i.call(this,e),o.isBuffer(t)?(this.base=t,this.offset=0,this.length=t.length):this.error("Input not Buffer");}function s(t,e){if(Array.isArray(t))this.length=0,this.value=t.map(function(t){return t instanceof s||(t=new s(t,e)),this.length+=t.length,t;},this);else if("number"==typeof t){if(!(0<=t&&t<=255))return e.error("non-byte EncoderBuffer value");this.value=t,this.length=1;}else if("string"==typeof t)this.value=t,this.length=o.byteLength(t);else{if(!o.isBuffer(t))return e.error("Unsupported type: "+_typeof(t));this.value=t,this.length=t.length;}}n(a,i),r.DecoderBuffer=a,a.prototype.save=function(){return{offset:this.offset,reporter:i.prototype.save.call(this)};},a.prototype.restore=function(t){var e=new a(this.base);return e.offset=t.offset,e.length=this.offset,this.offset=t.offset,i.prototype.restore.call(this,t.reporter),e;},a.prototype.isEmpty=function(){return this.offset===this.length;},a.prototype.readUInt8=function(t){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(t||"DecoderBuffer overrun");},a.prototype.skip=function(t,e){if(!(this.offset+t<=this.length))return this.error(e||"DecoderBuffer overrun");var r=new a(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+t,this.offset+=t,r;},a.prototype.raw=function(t){return this.base.slice(t?t.offset:this.offset,this.length);},r.EncoderBuffer=s,s.prototype.join=function(t,e){return t||(t=new o(this.length)),e||(e=0),0===this.length||(Array.isArray(this.value)?this.value.forEach(function(r){r.join(t,e),e+=r.length;}):("number"==typeof this.value?t[e]=this.value:"string"==typeof this.value?t.write(this.value,e):o.isBuffer(this.value)&&this.value.copy(t,e),e+=this.length)),t;};},{474:474,5:5,54:54}],5:[function(t,e,r){var n=r;n.Reporter=t(7).Reporter,n.DecoderBuffer=t(4).DecoderBuffer,n.EncoderBuffer=t(4).EncoderBuffer,n.Node=t(6);},{4:4,6:6,7:7}],6:[function(t,e,r){var n=t(5).Reporter,i=t(5).EncoderBuffer,o=t(5).DecoderBuffer,a=t(489),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],f=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function u(t,e){var r={};this._baseState=r,r.enc=t,r.parent=e||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r["default"]=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap());}e.exports=u;var c=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];u.prototype.clone=function(){var t=this._baseState,e={};c.forEach(function(r){e[r]=t[r];});var r=new this.constructor(e.parent);return r._baseState=e,r;},u.prototype._wrap=function(){var t=this._baseState;f.forEach(function(e){this[e]=function(){var r=new this.constructor(this);return t.children.push(r),r[e].apply(r,arguments);};},this);},u.prototype._init=function(t){var e=this._baseState;a(null===e.parent),t.call(this),e.children=e.children.filter(function(t){return t._baseState.parent===this;},this),a.equal(e.children.length,1,"Root node can have only one child");},u.prototype._useArgs=function(t){var e=this._baseState,r=t.filter(function(t){return t instanceof this.constructor;},this);t=t.filter(function(t){return!(t instanceof this.constructor);},this),0!==r.length&&(a(null===e.children),e.children=r,r.forEach(function(t){t._baseState.parent=this;},this)),0!==t.length&&(a(null===e.args),e.args=t,e.reverseArgs=t.map(function(t){if("object"!=_typeof(t)||t.constructor!==Object)return t;var e={};return Object.keys(t).forEach(function(r){r==(0|r)&&(r|=0);var n=t[r];e[n]=r;}),e;}));},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach(function(t){u.prototype[t]=function(){var e=this._baseState;throw new Error(t+" not implemented for encoding: "+e.enc);};}),s.forEach(function(t){u.prototype[t]=function(){var e=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===e.tag),e.tag=t,this._useArgs(r),this;};}),u.prototype.use=function(t){a(t);var e=this._baseState;return a(null===e.use),e.use=t,this;},u.prototype.optional=function(){return this._baseState.optional=!0,this;},u.prototype.def=function(t){var e=this._baseState;return a(null===e["default"]),e["default"]=t,e.optional=!0,this;},u.prototype.explicit=function(t){var e=this._baseState;return a(null===e.explicit&&null===e.implicit),e.explicit=t,this;},u.prototype.implicit=function(t){var e=this._baseState;return a(null===e.explicit&&null===e.implicit),e.implicit=t,this;},u.prototype.obj=function(){var t=this._baseState,e=Array.prototype.slice.call(arguments);return t.obj=!0,0!==e.length&&this._useArgs(e),this;},u.prototype.key=function(t){var e=this._baseState;return a(null===e.key),e.key=t,this;},u.prototype.any=function(){return this._baseState.any=!0,this;},u.prototype.choice=function(t){var e=this._baseState;return a(null===e.choice),e.choice=t,this._useArgs(Object.keys(t).map(function(e){return t[e];})),this;},u.prototype.contains=function(t){var e=this._baseState;return a(null===e.use),e.contains=t,this;},u.prototype._decode=function(t,e){var r=this._baseState;if(null===r.parent)return t.wrapResult(r.children[0]._decode(t,e));var n,i=r["default"],a=!0,s=null;if(null!==r.key&&(s=t.enterKey(r.key)),r.optional){var f=null;if(null!==r.explicit?f=r.explicit:null!==r.implicit?f=r.implicit:null!==r.tag&&(f=r.tag),null!==f||r.any){if(a=this._peekTag(t,f,r.any),t.isError(a))return a;}else{var u=t.save();try{null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),a=!0;}catch(t){a=!1;}t.restore(u);}}if(r.obj&&a&&(n=t.enterObject()),a){if(null!==r.explicit){var c=this._decodeTag(t,r.explicit);if(t.isError(c))return c;t=c;}var h=t.offset;if(null===r.use&&null===r.choice){if(r.any)u=t.save();var d=this._decodeTag(t,null!==r.implicit?r.implicit:r.tag,r.any);if(t.isError(d))return d;r.any?i=t.raw(u):t=d;}if(e&&e.track&&null!==r.tag&&e.track(t.path(),h,t.length,"tagged"),e&&e.track&&null!==r.tag&&e.track(t.path(),t.offset,t.length,"content"),i=r.any?i:null===r.choice?this._decodeGeneric(r.tag,t,e):this._decodeChoice(t,e),t.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach(function(r){r._decode(t,e);}),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){var l=new o(i);i=this._getUse(r.contains,t._reporterState.obj)._decode(l,e);}}return r.obj&&a&&(i=t.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&t.exitKey(s):t.leaveKey(s,r.key,i),i;},u.prototype._decodeGeneric=function(t,e,r){var n=this._baseState;return"seq"===t||"set"===t?null:"seqof"===t||"setof"===t?this._decodeList(e,t,n.args[0],r):/str$/.test(t)?this._decodeStr(e,t,r):"objid"===t&&n.args?this._decodeObjid(e,n.args[0],n.args[1],r):"objid"===t?this._decodeObjid(e,null,null,r):"gentime"===t||"utctime"===t?this._decodeTime(e,t,r):"null_"===t?this._decodeNull(e,r):"bool"===t?this._decodeBool(e,r):"objDesc"===t?this._decodeStr(e,t,r):"int"===t||"enum"===t?this._decodeInt(e,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,e._reporterState.obj)._decode(e,r):e.error("unknown tag: "+t);},u.prototype._getUse=function(t,e){var r=this._baseState;return r.useDecoder=this._use(t,e),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder;},u.prototype._decodeChoice=function(t,e){var r=this._baseState,n=null,i=!1;return Object.keys(r.choice).some(function(o){var a=t.save(),s=r.choice[o];try{var f=s._decode(t,e);if(t.isError(f))return!1;n={type:o,value:f},i=!0;}catch(e){return t.restore(a),!1;}return!0;},this),i?n:t.error("Choice not matched");},u.prototype._createEncoderBuffer=function(t){return new i(t,this.reporter);},u.prototype._encode=function(t,e,r){var n=this._baseState;if(null===n["default"]||n["default"]!==t){var i=this._encodeValue(t,e,r);if(void 0!==i&&!this._skipDefault(i,e,r))return i;}},u.prototype._encodeValue=function(t,e,r){var i=this._baseState;if(null===i.parent)return i.children[0]._encode(t,e||new n());var o=null;if(this.reporter=e,i.optional&&void 0===t){if(null===i["default"])return;t=i["default"];}var a=null,s=!1;if(i.any)o=this._createEncoderBuffer(t);else if(i.choice)o=this._encodeChoice(t,e);else if(i.contains)a=this._getUse(i.contains,r)._encode(t,e),s=!0;else if(i.children)a=i.children.map(function(r){if("null_"===r._baseState.tag)return r._encode(null,e,t);if(null===r._baseState.key)return e.error("Child should have a key");var n=e.enterKey(r._baseState.key);if("object"!=_typeof(t))return e.error("Child expected, but input is not object");var i=r._encode(t[r._baseState.key],e,t);return e.leaveKey(n),i;},this).filter(function(t){return t;}),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return e.error("Too many args for : "+i.tag);if(!Array.isArray(t))return e.error("seqof/setof, but data is not Array");var f=this.clone();f._baseState.implicit=null,a=this._createEncoderBuffer(t.map(function(r){var n=this._baseState;return this._getUse(n.args[0],t)._encode(r,e);},f));}else null!==i.use?o=this._getUse(i.use,r)._encode(t,e):(a=this._encodePrimitive(i.tag,t),s=!0);if(!i.any&&null===i.choice){var u=null!==i.implicit?i.implicit:i.tag,c=null===i.implicit?"universal":"context";null===u?null===i.use&&e.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(u,s,c,a));}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o;},u.prototype._encodeChoice=function(t,e){var r=this._baseState,n=r.choice[t.type];return n||a(!1,t.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(t.value,e);},u.prototype._encodePrimitive=function(t,e){var r=this._baseState;if(/str$/.test(t))return this._encodeStr(e,t);if("objid"===t&&r.args)return this._encodeObjid(e,r.reverseArgs[0],r.args[1]);if("objid"===t)return this._encodeObjid(e,null,null);if("gentime"===t||"utctime"===t)return this._encodeTime(e,t);if("null_"===t)return this._encodeNull();if("int"===t||"enum"===t)return this._encodeInt(e,r.args&&r.reverseArgs[0]);if("bool"===t)return this._encodeBool(e);if("objDesc"===t)return this._encodeStr(e,t);throw new Error("Unsupported tag: "+t);},u.prototype._isNumstr=function(t){return /^[0-9 ]*$/.test(t);},u.prototype._isPrintstr=function(t){return /^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(t);};},{489:489,5:5}],7:[function(t,e,r){var n=t(474);function i(t){this._reporterState={obj:null,path:[],options:t||{},errors:[]};}function o(t,e){this.path=t,this.rethrow(e);}r.Reporter=i,i.prototype.isError=function(t){return t instanceof o;},i.prototype.save=function(){var t=this._reporterState;return{obj:t.obj,pathLen:t.path.length};},i.prototype.restore=function(t){var e=this._reporterState;e.obj=t.obj,e.path=e.path.slice(0,t.pathLen);},i.prototype.enterKey=function(t){return this._reporterState.path.push(t);},i.prototype.exitKey=function(t){var e=this._reporterState;e.path=e.path.slice(0,t-1);},i.prototype.leaveKey=function(t,e,r){var n=this._reporterState;this.exitKey(t),null!==n.obj&&(n.obj[e]=r);},i.prototype.path=function(){return this._reporterState.path.join("/");},i.prototype.enterObject=function(){var t=this._reporterState,e=t.obj;return t.obj={},e;},i.prototype.leaveObject=function(t){var e=this._reporterState,r=e.obj;return e.obj=t,r;},i.prototype.error=function(t){var e,r=this._reporterState,n=t instanceof o;if(e=n?t:new o(r.path.map(function(t){return"["+JSON.stringify(t)+"]";}).join(""),t.message||t,t.stack),!r.options.partial)throw e;return n||r.errors.push(e),e;},i.prototype.wrapResult=function(t){var e=this._reporterState;return e.options.partial?{result:this.isError(t)?null:t,errors:e.errors}:t;},n(o,Error),o.prototype.rethrow=function(t){if(this.message=t+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message);}catch(t){this.stack=t.stack;}return this;};},{474:474}],8:[function(t,e,r){var n=t(9);r.tagClass={0:"universal",1:"application",2:"context",3:"private"},r.tagClassByName=n._reverse(r.tagClass),r.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},r.tagByName=n._reverse(r.tag);},{9:9}],9:[function(t,e,r){var n=r;n._reverse=function(t){var e={};return Object.keys(t).forEach(function(r){(0|r)==r&&(r|=0);var n=t[r];e[n]=r;}),e;},n.der=t(8);},{8:8}],10:[function(t,e,r){var n=t(474),i=t(2),o=i.base,a=i.bignum,s=i.constants.der;function f(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u(),this.tree._init(t.body);}function u(t){o.Node.call(this,"der",t);}function c(t,e){var r=t.readUInt8(e);if(t.isError(r))return r;var n=s.tagClass[r>>6],i=0==(32&r);if(31==(31&r)){var o=r;for(r=0;128==(128&o);){if(o=t.readUInt8(e),t.isError(o))return o;r<<=7,r|=127&o;}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]};}function h(t,e,r){var n=t.readUInt8(r);if(t.isError(n))return n;if(!e&&128===n)return null;if(0==(128&n))return n;var i=127&n;if(i>4)return t.error("length octect is too long");n=0;for(var o=0;o<i;o++){n<<=8;var a=t.readUInt8(r);if(t.isError(a))return a;n|=a;}return n;}e.exports=f,f.prototype.decode=function(t,e){return t instanceof o.DecoderBuffer||(t=new o.DecoderBuffer(t,e)),this.tree._decode(t,e);},n(u,o.Node),u.prototype._peekTag=function(t,e,r){if(t.isEmpty())return!1;var n=t.save(),i=c(t,'Failed to peek tag: "'+e+'"');return t.isError(i)?i:(t.restore(n),i.tag===e||i.tagStr===e||i.tagStr+"of"===e||r);},u.prototype._decodeTag=function(t,e,r){var n=c(t,'Failed to decode tag of "'+e+'"');if(t.isError(n))return n;var i=h(t,n.primitive,'Failed to get length of "'+e+'"');if(t.isError(i))return i;if(!r&&n.tag!==e&&n.tagStr!==e&&n.tagStr+"of"!==e)return t.error('Failed to match tag: "'+e+'"');if(n.primitive||null!==i)return t.skip(i,'Failed to match body of: "'+e+'"');var o=t.save(),a=this._skipUntilEnd(t,'Failed to skip indefinite length body: "'+this.tag+'"');return t.isError(a)?a:(i=t.offset-o.offset,t.restore(o),t.skip(i,'Failed to match body of: "'+e+'"'));},u.prototype._skipUntilEnd=function(t,e){for(;;){var r=c(t,e);if(t.isError(r))return r;var n,i=h(t,r.primitive,e);if(t.isError(i))return i;if(n=r.primitive||null!==i?t.skip(i):this._skipUntilEnd(t,e),t.isError(n))return n;if("end"===r.tagStr)break;}},u.prototype._decodeList=function(t,e,r,n){for(var i=[];!t.isEmpty();){var o=this._peekTag(t,"end");if(t.isError(o))return o;var a=r.decode(t,"der",n);if(t.isError(a)&&o)break;i.push(a);}return i;},u.prototype._decodeStr=function(t,e){if("bitstr"===e){var r=t.readUInt8();return t.isError(r)?r:{unused:r,data:t.raw()};}if("bmpstr"===e){var n=t.raw();if(n.length%2==1)return t.error("Decoding of string type: bmpstr length mismatch");for(var i="",o=0;o<n.length/2;o++)i+=String.fromCharCode(n.readUInt16BE(2*o));return i;}if("numstr"===e){var a=t.raw().toString("ascii");return this._isNumstr(a)?a:t.error("Decoding of string type: numstr unsupported characters");}if("octstr"===e)return t.raw();if("objDesc"===e)return t.raw();if("printstr"===e){var s=t.raw().toString("ascii");return this._isPrintstr(s)?s:t.error("Decoding of string type: printstr unsupported characters");}return /str$/.test(e)?t.raw().toString():t.error("Decoding of string type: "+e+" unsupported");},u.prototype._decodeObjid=function(t,e,r){for(var n,i=[],o=0;!t.isEmpty();){var a=t.readUInt8();o<<=7,o|=127&a,0==(128&a)&&(i.push(o),o=0);}128&a&&i.push(o);var s=i[0]/40|0,f=i[0]%40;if(n=r?i:[s,f].concat(i.slice(1)),e){var u=e[n.join(" ")];void 0===u&&(u=e[n.join(".")]),void 0!==u&&(n=u);}return n;},u.prototype._decodeTime=function(t,e){var r=t.raw().toString();if("gentime"===e)var n=0|r.slice(0,4),i=0|r.slice(4,6),o=0|r.slice(6,8),a=0|r.slice(8,10),s=0|r.slice(10,12),f=0|r.slice(12,14);else{if("utctime"!==e)return t.error("Decoding "+e+" time is not supported yet");n=0|r.slice(0,2),i=0|r.slice(2,4),o=0|r.slice(4,6),a=0|r.slice(6,8),s=0|r.slice(8,10),f=0|r.slice(10,12);n=n<70?2e3+n:1900+n;}return Date.UTC(n,i-1,o,a,s,f,0);},u.prototype._decodeNull=function(t){return null;},u.prototype._decodeBool=function(t){var e=t.readUInt8();return t.isError(e)?e:0!==e;},u.prototype._decodeInt=function(t,e){var r=t.raw(),n=new a(r);return e&&(n=e[n.toString(10)]||n),n;},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getDecoder("der").tree;};},{2:2,474:474}],11:[function(t,e,r){var n=r;n.der=t(10),n.pem=t(12);},{10:10,12:12}],12:[function(t,e,r){var n=t(474),i=t(54).Buffer,o=t(10);function a(t){o.call(this,t),this.enc="pem";}n(a,o),e.exports=a,a.prototype.decode=function(t,e){for(var r=t.toString().split(/[\r\n]+/g),n=e.label.toUpperCase(),a=/^-----(BEGIN|END) ([^-]+)-----$/,s=-1,f=-1,u=0;u<r.length;u++){var c=r[u].match(a);if(null!==c&&c[2]===n){if(-1!==s){if("END"!==c[1])break;f=u;break;}if("BEGIN"!==c[1])break;s=u;}}if(-1===s||-1===f)throw new Error("PEM section not found for: "+n);var h=r.slice(s+1,f).join("");h.replace(/[^a-z0-9\+\/=]+/gi,"");var d=new i(h,"base64");return o.prototype.decode.call(this,d,e);};},{10:10,474:474,54:54}],13:[function(t,e,r){var n=t(474),i=t(54).Buffer,o=t(2),a=o.base,s=o.constants.der;function f(t){this.enc="der",this.name=t.name,this.entity=t,this.tree=new u(),this.tree._init(t.body);}function u(t){a.Node.call(this,"der",t);}function c(t){return t<10?"0"+t:t;}e.exports=f,f.prototype.encode=function(t,e){return this.tree._encode(t,e).join();},n(u,a.Node),u.prototype._encodeComposite=function(t,e,r,n){var o,a=function(t,e,r,n){var i;"seqof"===t?t="seq":"setof"===t&&(t="set");if(s.tagByName.hasOwnProperty(t))i=s.tagByName[t];else{if("number"!=typeof t||(0|t)!==t)return n.error("Unknown tag: "+t);i=t;}if(i>=31)return n.error("Multi-octet tag encoding unsupported");e||(i|=32);return i|=s.tagClassByName[r||"universal"]<<6;}(t,e,r,this.reporter);if(n.length<128)return(o=new i(2))[0]=a,o[1]=n.length,this._createEncoderBuffer([o,n]);for(var f=1,u=n.length;u>=256;u>>=8)f++;(o=new i(2+f))[0]=a,o[1]=128|f;u=1+f;for(var c=n.length;c>0;u--,c>>=8)o[u]=255&c;return this._createEncoderBuffer([o,n]);},u.prototype._encodeStr=function(t,e){if("bitstr"===e)return this._createEncoderBuffer([0|t.unused,t.data]);if("bmpstr"===e){for(var r=new i(2*t.length),n=0;n<t.length;n++)r.writeUInt16BE(t.charCodeAt(n),2*n);return this._createEncoderBuffer(r);}return"numstr"===e?this._isNumstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===e?this._isPrintstr(t)?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(e)||"objDesc"===e?this._createEncoderBuffer(t):this.reporter.error("Encoding of string type: "+e+" unsupported");},u.prototype._encodeObjid=function(t,e,r){if("string"==typeof t){if(!e)return this.reporter.error("string objid given, but no values map found");if(!e.hasOwnProperty(t))return this.reporter.error("objid not found in values map");t=e[t].split(/[\s\.]+/g);for(var n=0;n<t.length;n++)t[n]|=0;}else if(Array.isArray(t)){t=t.slice();for(n=0;n<t.length;n++)t[n]|=0;}if(!Array.isArray(t))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(t));if(!r){if(t[1]>=40)return this.reporter.error("Second objid identifier OOB");t.splice(0,2,40*t[0]+t[1]);}var o=0;for(n=0;n<t.length;n++){var a=t[n];for(o++;a>=128;a>>=7)o++;}var s=new i(o),f=s.length-1;for(n=t.length-1;n>=0;n--){a=t[n];for(s[f--]=127&a;(a>>=7)>0;)s[f--]=128|127&a;}return this._createEncoderBuffer(s);},u.prototype._encodeTime=function(t,e){var r,n=new Date(t);return"gentime"===e?r=[c(n.getFullYear()),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):"utctime"===e?r=[c(n.getFullYear()%100),c(n.getUTCMonth()+1),c(n.getUTCDate()),c(n.getUTCHours()),c(n.getUTCMinutes()),c(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+e+" time is not supported yet"),this._encodeStr(r,"octstr");},u.prototype._encodeNull=function(){return this._createEncoderBuffer("");},u.prototype._encodeInt=function(t,e){if("string"==typeof t){if(!e)return this.reporter.error("String int or enum given, but no values map");if(!e.hasOwnProperty(t))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(t));t=e[t];}if("number"!=typeof t&&!i.isBuffer(t)){var r=t.toArray();!t.sign&&128&r[0]&&r.unshift(0),t=new i(r);}if(i.isBuffer(t)){var n=t.length;0===t.length&&n++;var o=new i(n);return t.copy(o),0===t.length&&(o[0]=0),this._createEncoderBuffer(o);}if(t<128)return this._createEncoderBuffer(t);if(t<256)return this._createEncoderBuffer([0,t]);n=1;for(var a=t;a>=256;a>>=8)n++;for(a=(o=new Array(n)).length-1;a>=0;a--)o[a]=255&t,t>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(new i(o));},u.prototype._encodeBool=function(t){return this._createEncoderBuffer(t?255:0);},u.prototype._use=function(t,e){return"function"==typeof t&&(t=t(e)),t._getEncoder("der").tree;},u.prototype._skipDefault=function(t,e,r){var n,i=this._baseState;if(null===i["default"])return!1;var o=t.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i["default"],e,r).join()),o.length!==i.defaultBuffer.length)return!1;for(n=0;n<o.length;n++)if(o[n]!==i.defaultBuffer[n])return!1;return!0;};},{2:2,474:474,54:54}],14:[function(t,e,r){var n=r;n.der=t(13),n.pem=t(15);},{13:13,15:15}],15:[function(t,e,r){var n=t(474),i=t(13);function o(t){i.call(this,t),this.enc="pem";}n(o,i),e.exports=o,o.prototype.encode=function(t,e){for(var r=i.prototype.encode.call(this,t).toString("base64"),n=["-----BEGIN "+e.label+"-----"],o=0;o<r.length;o+=64)n.push(r.slice(o,o+64));return n.push("-----END "+e.label+"-----"),n.join("\n");};},{13:13,474:474}],16:[function(t,e,r){!function(e,r){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed");}function i(t,e){t.super_=e;var r=function r(){};r.prototype=e.prototype,t.prototype=new r(),t.prototype.constructor=t;}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"));}var a;"object"==_typeof(e)?e.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:t(22).Buffer;}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15;}function f(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n;}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),a=e;a<o;a++){var s=t.charCodeAt(a)-48;i*=n,i+=s>=49?s-49+10:s>=17?s-17+10:s;}return i;}o.isBN=function(t){return t instanceof o||null!==t&&"object"==_typeof(t)&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words);},o.max=function(t,e){return t.cmp(e)>0?t:e;},o.min=function(t,e){return t.cmp(e)<0?t:e;},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==_typeof(t))return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,r):(this._parseBase(t,e,i),"le"===r&&this._initArray(this.toArray(),e,r)));},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r);},o.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,a,s=0;if("be"===r)for(i=t.length-1,o=0;i>=0;i-=3)a=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i<t.length;i+=3)a=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip();},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,a=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=f(t,e,n)<<o,this.words[a]|=67108863&i,o>=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=f(t,e,n)<<o,this.words[a]|=67108863&i,o>=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this.strip();},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c<s;c+=n)f=u(t,c,c+n,e),this.imuln(i),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!==a){var h=1;for(f=u(t,c,t.length,e),c=0;c<a;c++)h*=e;this.imuln(h),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);}this.strip();},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red;},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t;},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this;},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign();},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this;},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">";};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],a=i*o,s=67108863&a,f=a/67108864|0;r.words[0]=s;for(var u=1;u<n;u++){for(var c=f>>>26,h=67108863&f,d=Math.min(u,e.length-1),l=Math.max(0,u-t.length+1);l<=d;l++){var p=u-l|0;c+=(a=(i=0|t.words[p])*(o=0|e.words[l])+h)/67108864|0,h=67108863&a;}r.words[u]=0|h,f=0|c;}return 0!==f?r.words[u]=0|f:r.length--,r.strip();}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,o=0,a=0;a<this.length;a++){var s=this.words[a],f=(16777215&(s<<i|o)).toString(16);o=s>>>24-i&16777215,(i+=2)>=26&&(i-=26,a--),r=0!==o||a!==this.length-1?c[6-f.length]+f+r:f+r;}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r;}if(t===(0|t)&&t>=2&&t<=36){var u=h[t],l=d[t];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(l).toString(t);r=(p=p.idivn(l)).isZero()?b+r:c[u-b.length]+b+r;}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r;}n(!1,"Base should be between 2 and 36");},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t;},o.prototype.toJSON=function(){return this.toString(16);},o.prototype.toBuffer=function(t,e){return n(void 0!==a),this.toArrayLike(a,t,e);},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e);},o.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,f="le"===e,u=new t(o),c=this.clone();if(f){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),u[s]=a;for(;s<o;s++)u[s]=0;}else{for(s=0;s<o-i;s++)u[s]=0;for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),u[o-s-1]=a;}return u;},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t);}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e;},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r;},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e;},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break;}return t;},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8);},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone();},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone();},o.prototype.isNeg=function(){return 0!==this.negative;},o.prototype.neg=function(){return this.clone().ineg();},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this;},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip();},o.prototype.ior=function(t){return n(0==(this.negative|t.negative)),this.iuor(t);},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this);},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this);},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip();},o.prototype.iand=function(t){return n(0==(this.negative|t.negative)),this.iuand(t);},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this);},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this);},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip();},o.prototype.ixor=function(t){return n(0==(this.negative|t.negative)),this.iuxor(t);},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this);},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this);},o.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip();},o.prototype.notn=function(t){return this.clone().inotn(t);},o.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip();},o.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this;},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this);},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign();}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,a=0;a<n.length;a++)o=(e=(0|r.words[a])-(0|n.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this.strip();},o.prototype.sub=function(t){return this.clone().isub(t);};var p=function p(t,e,r){var n,i,o,a=t.words,s=e.words,f=r.words,u=0,c=0|a[0],h=8191&c,d=c>>>13,l=0|a[1],p=8191&l,b=l>>>13,v=0|a[2],y=8191&v,g=v>>>13,m=0|a[3],w=8191&m,_=m>>>13,S=0|a[4],M=8191&S,A=S>>>13,x=0|a[5],E=8191&x,k=x>>>13,I=0|a[6],R=8191&I,B=I>>>13,P=0|a[7],T=8191&P,O=P>>>13,C=0|a[8],j=8191&C,L=C>>>13,N=0|a[9],U=8191&N,F=N>>>13,D=0|s[0],q=8191&D,z=D>>>13,V=0|s[1],G=8191&V,K=V>>>13,W=0|s[2],H=8191&W,X=W>>>13,Z=0|s[3],J=8191&Z,Y=Z>>>13,$=0|s[4],Q=8191&$,tt=$>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],ot=8191&it,at=it>>>13,st=0|s[7],ft=8191&st,ut=st>>>13,ct=0|s[8],ht=8191&ct,dt=ct>>>13,lt=0|s[9],pt=8191&lt,bt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(d,q)|0))<<13)|0;u=((o=Math.imul(d,z))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,z))+Math.imul(b,q)|0,o=Math.imul(b,z);var yt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(d,G)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,q),i=(i=Math.imul(y,z))+Math.imul(g,q)|0,o=Math.imul(g,z),n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,K)|0;var gt=(u+(n=n+Math.imul(h,H)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(d,H)|0))<<13)|0;u=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,z))+Math.imul(_,q)|0,o=Math.imul(_,z),n=n+Math.imul(y,G)|0,i=(i=i+Math.imul(y,K)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,K)|0,n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,X)|0;var mt=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(d,J)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(M,q),i=(i=Math.imul(M,z))+Math.imul(A,q)|0,o=Math.imul(A,z),n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,K)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,K)|0,n=n+Math.imul(y,H)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(g,H)|0,o=o+Math.imul(g,X)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Y)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,z))+Math.imul(k,q)|0,o=Math.imul(k,z),n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(A,G)|0,o=o+Math.imul(A,K)|0,n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(y,J)|0,i=(i=i+Math.imul(y,Y)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,q),i=(i=Math.imul(R,z))+Math.imul(B,q)|0,o=Math.imul(B,z),n=n+Math.imul(E,G)|0,i=(i=i+Math.imul(E,K)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,K)|0,n=n+Math.imul(M,H)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(A,H)|0,o=o+Math.imul(A,X)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var St=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,z))+Math.imul(O,q)|0,o=Math.imul(O,z),n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,K)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,K)|0,n=n+Math.imul(E,H)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,Y)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,at)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,at)|0;var Mt=(u+(n=n+Math.imul(h,ft)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(d,ft)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,z))+Math.imul(L,q)|0,o=Math.imul(L,z),n=n+Math.imul(T,G)|0,i=(i=i+Math.imul(T,K)|0)+Math.imul(O,G)|0,o=o+Math.imul(O,K)|0,n=n+Math.imul(R,H)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(B,H)|0,o=o+Math.imul(B,X)|0,n=n+Math.imul(E,J)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,at)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,at)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ft)|0,o=o+Math.imul(b,ut)|0;var At=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,dt)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(U,q),i=(i=Math.imul(U,z))+Math.imul(F,q)|0,o=Math.imul(F,z),n=n+Math.imul(j,G)|0,i=(i=i+Math.imul(j,K)|0)+Math.imul(L,G)|0,o=o+Math.imul(L,K)|0,n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,at)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,at)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(g,ft)|0,o=o+Math.imul(g,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,dt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,dt)|0;var xt=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((o=o+Math.imul(d,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(U,G),i=(i=Math.imul(U,K))+Math.imul(F,G)|0,o=Math.imul(F,K),n=n+Math.imul(j,H)|0,i=(i=i+Math.imul(j,X)|0)+Math.imul(L,H)|0,o=o+Math.imul(L,X)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,Y)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,at)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,at)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ft)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,dt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,dt)|0;var Et=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,H),i=(i=Math.imul(U,X))+Math.imul(F,H)|0,o=Math.imul(F,X),n=n+Math.imul(j,J)|0,i=(i=i+Math.imul(j,Y)|0)+Math.imul(L,J)|0,o=o+Math.imul(L,Y)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,n=n+Math.imul(M,ft)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,dt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,dt)|0;var kt=(u+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,bt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(U,J),i=(i=Math.imul(U,Y))+Math.imul(F,J)|0,o=Math.imul(F,Y),n=n+Math.imul(j,Q)|0,i=(i=i+Math.imul(j,tt)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,at)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,at)|0,n=n+Math.imul(E,ft)|0,i=(i=i+Math.imul(E,ut)|0)+Math.imul(k,ft)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,dt)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,dt)|0;var It=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(U,Q),i=(i=Math.imul(U,tt))+Math.imul(F,Q)|0,o=Math.imul(F,tt),n=n+Math.imul(j,rt)|0,i=(i=i+Math.imul(j,nt)|0)+Math.imul(L,rt)|0,o=o+Math.imul(L,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,at)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,at)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(B,ft)|0,o=o+Math.imul(B,ut)|0,n=n+Math.imul(E,ht)|0,i=(i=i+Math.imul(E,dt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,dt)|0;var Rt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((o=o+Math.imul(A,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(U,rt),i=(i=Math.imul(U,nt))+Math.imul(F,rt)|0,o=Math.imul(F,nt),n=n+Math.imul(j,ot)|0,i=(i=i+Math.imul(j,at)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,at)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ut)|0)+Math.imul(O,ft)|0,o=o+Math.imul(O,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,dt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,dt)|0;var Bt=(u+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(U,ot),i=(i=Math.imul(U,at))+Math.imul(F,ot)|0,o=Math.imul(F,at),n=n+Math.imul(j,ft)|0,i=(i=i+Math.imul(j,ut)|0)+Math.imul(L,ft)|0,o=o+Math.imul(L,ut)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,dt)|0)+Math.imul(O,ht)|0,o=o+Math.imul(O,dt)|0;var Pt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(B,pt)|0))<<13)|0;u=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(U,ft),i=(i=Math.imul(U,ut))+Math.imul(F,ft)|0,o=Math.imul(F,ut),n=n+Math.imul(j,ht)|0,i=(i=i+Math.imul(j,dt)|0)+Math.imul(L,ht)|0,o=o+Math.imul(L,dt)|0;var Tt=(u+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,bt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((o=o+Math.imul(O,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(U,ht),i=(i=Math.imul(U,dt))+Math.imul(F,ht)|0,o=Math.imul(F,dt);var Ot=(u+(n=n+Math.imul(j,pt)|0)|0)+((8191&(i=(i=i+Math.imul(j,bt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((o=o+Math.imul(L,bt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Ct=(u+(n=Math.imul(U,pt))|0)+((8191&(i=(i=Math.imul(U,bt))+Math.imul(F,pt)|0))<<13)|0;return u=((o=Math.imul(F,bt))+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,f[0]=vt,f[1]=yt,f[2]=gt,f[3]=mt,f[4]=wt,f[5]=_t,f[6]=St,f[7]=Mt,f[8]=At,f[9]=xt,f[10]=Et,f[11]=kt,f[12]=It,f[13]=Rt,f[14]=Bt,f[15]=Pt,f[16]=Tt,f[17]=Ot,f[18]=Ct,0!==u&&(f[19]=u,r.length++),r;};function b(t,e,r){return new v().mulp(t,e,r);}function v(t,e){this.x=t,this.y=e;}Math.imul||(p=l),o.prototype.mulTo=function(t,e){var r,n=this.length+t.length;return r=10===this.length&&10===t.length?p(this,t,e):n<63?l(this,t,e):n<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var a=i;i=0;for(var s=67108863&n,f=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=f;u++){var c=o-u,h=(0|t.words[c])*(0|e.words[u]),d=67108863&h;s=67108863&(d=d+s|0),i+=(a=(a=a+(h/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863;}r.words[o]=s,n=a,a=i;}return 0!==n?r.words[o]=n:r.length--,r.strip();}(this,t,e):b(this,t,e),r;},v.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e;},v.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n;},v.prototype.permute=function(t,e,r,n,i,o){for(var a=0;a<o;a++)n[a]=e[t[a]],i[a]=r[t[a]];},v.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var a=1;a<i;a<<=1)for(var s=a<<1,f=Math.cos(2*Math.PI/s),u=Math.sin(2*Math.PI/s),c=0;c<i;c+=s)for(var h=f,d=u,l=0;l<a;l++){var p=r[c+l],b=n[c+l],v=r[c+l+a],y=n[c+l+a],g=h*v-d*y;y=h*y+d*v,v=g,r[c+l]=p+v,n[c+l]=b+y,r[c+l+a]=p-v,n[c+l+a]=b-y,l!==s&&(g=f*h-u*d,d=f*d+u*h,h=g);}},v.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n;},v.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i;}},v.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0;}return t;},v.prototype.convert13b=function(t,e,r,i){for(var o=0,a=0;a<e;a++)o+=0|t[a],r[2*a]=8191&o,o>>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*e;a<i;++a)r[a]=0;n(0===o),n(0==(-8192&o));},v.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e;},v.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),a=new Array(n),s=new Array(n),f=new Array(n),u=new Array(n),c=new Array(n),h=new Array(n),d=r.words;d.length=n,this.convert13b(t.words,t.length,a,n),this.convert13b(e.words,e.length,u,n),this.transform(a,o,s,f,n,i),this.transform(u,o,c,h,n,i);for(var l=0;l<n;l++){var p=s[l]*c[l]-f[l]*h[l];f[l]=s[l]*h[l]+f[l]*c[l],s[l]=p;}return this.conjugate(s,f,n),this.transform(s,f,d,o,n,i),this.conjugate(d,o,n),this.normalize13b(d,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip();},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e);},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),b(this,t,e);},o.prototype.imul=function(t){return this.clone().mulTo(t,this);},o.prototype.imuln=function(t){n("number"==typeof t),n(t<67108864);for(var e=0,r=0;r<this.length;r++){var i=(0|this.words[r])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[r]=67108863&o;}return 0!==e&&(this.words[r]=e,this.length++),this.length=0===t?1:this.length,this;},o.prototype.muln=function(t){return this.clone().imuln(t);},o.prototype.sqr=function(){return this.mul(this);},o.prototype.isqr=function(){return this.imul(this.clone());},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i;}return e;}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r;},o.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,f=(0|this.words[e])-s<<r;this.words[e]=f|a,a=s>>>26-r;}a&&(this.words[e]=a,this.length++);}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i;}return this.strip();},o.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t);},o.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,f=r;if(i-=a,i=Math.max(0,i),f){for(var u=0;u<a;u++)f.words[u]=this.words[u];f.length=a;}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var c=0;for(u=this.length-1;u>=0&&(0!==c||u>=i);u--){var h=0|this.words[u];this.words[u]=c<<26-o|h>>>o,c=h&s;}return f&&0!==c&&(f.words[f.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip();},o.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r);},o.prototype.shln=function(t){return this.clone().ishln(t);},o.prototype.ushln=function(t){return this.clone().iushln(t);},o.prototype.shrn=function(t){return this.clone().ishrn(t);},o.prototype.ushrn=function(t){return this.clone().iushrn(t);},o.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i);},o.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i;}return this.strip();},o.prototype.maskn=function(t){return this.clone().imaskn(t);},o.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t);},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this;},o.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip();},o.prototype.addn=function(t){return this.clone().iaddn(t);},o.prototype.subn=function(t){return this.clone().isubn(t);},o.prototype.iabs=function(){return this.negative=0,this;},o.prototype.abs=function(){return this.clone().iabs();},o.prototype._ishlnsubmul=function(t,e,r){var i,o,a=t.length+r;this._expand(a);var s=0;for(i=0;i<t.length;i++){o=(0|this.words[i+r])+s;var f=(0|t.words[i])*e;s=((o-=67108863&f)>>26)-(f/67108864|0),this.words[i+r]=67108863&o;}for(;i<this.length-r;i++)s=(o=(0|this.words[i+r])+s)>>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i<this.length;i++)s=(o=-(0|this.words[i])+s)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip();},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,f=n.length-i.length;if("mod"!==e){(s=new o(null)).length=f+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0;}var c=n.clone()._ishlnsubmul(i,1,f);0===c.negative&&(n=c,s&&(s.words[f]=1));for(var h=f-1;h>=0;h--){var d=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(d=Math.min(d/a|0,67108863),n._ishlnsubmul(i,d,h);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=d);}return s&&s.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n};},o.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(t)),{div:i,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,a,s;},o.prototype.div=function(t){return this.divmod(t,"div",!1).div;},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod;},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod;},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1);},o.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r;},o.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t;}return this.strip();},o.prototype.divn=function(t){return this.clone().idivn(t);},o.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),a=new o(0),s=new o(0),f=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),h=e.clone();!e.isZero();){for(var d=0,l=1;0==(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-->0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-->0;)(s.isOdd()||f.isOdd())&&(s.iadd(c),f.isub(h)),s.iushrn(1),f.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),a.isub(f)):(r.isub(e),s.isub(i),f.isub(a));}return{a:s,b:f,gcd:r.iushln(u)};},o.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,a=new o(1),s=new o(0),f=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-->0;)a.isOdd()&&a.iadd(f),a.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-->0;)s.isOdd()&&s.iadd(f),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),a.isub(s)):(r.isub(e),s.isub(a));}return(i=0===e.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(t),i;},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o;}else if(0===i||0===r.cmpn(1))break;e.isub(r);}return r.iushln(n);},o.prototype.invm=function(t){return this.egcd(t).a.umod(t);},o.prototype.isEven=function(){return 0==(1&this.words[0]);},o.prototype.isOdd=function(){return 1==(1&this.words[0]);},o.prototype.andln=function(t){return this.words[0]&t;},o.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var o=i,a=r;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s;}return 0!==o&&(this.words[a]=o,this.length++),this;},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0];},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1;}return 0!==this.negative?0|-e:e;},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e;},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break;}}return e;},o.prototype.gtn=function(t){return 1===this.cmpn(t);},o.prototype.gt=function(t){return 1===this.cmp(t);},o.prototype.gten=function(t){return this.cmpn(t)>=0;},o.prototype.gte=function(t){return this.cmp(t)>=0;},o.prototype.ltn=function(t){return-1===this.cmpn(t);},o.prototype.lt=function(t){return-1===this.cmp(t);},o.prototype.lten=function(t){return this.cmpn(t)<=0;},o.prototype.lte=function(t){return this.cmp(t)<=0;},o.prototype.eqn=function(t){return 0===this.cmpn(t);},o.prototype.eq=function(t){return 0===this.cmp(t);},o.red=function(t){return new M(t);},o.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t);},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this);},o.prototype._forceRed=function(t){return this.red=t,this;},o.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t);},o.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t);},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t);},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t);},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t);},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t);},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t);},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t);},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this);},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this);},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this);},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this);},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this);},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t);};var y={k256:null,p224:null,p192:null,p25519:null};function g(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp();}function m(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f");}function w(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001");}function _(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff");}function S(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed");}function M(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e;}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null;}function A(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv);}g.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t;},g.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength();}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r;},g.prototype.split=function(t,e){t.iushrn(this.n,0,e);},g.prototype.imulK=function(t){return t.imul(this.k);},i(m,g),m.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var a=0|t.words[i];t.words[i-10]=(a&r)<<4|o>>>22,o=a;}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9;},m.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0);}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t;},i(w,g),i(_,g),i(S,g),S.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n;}return 0!==e&&(t.words[t.length++]=e),t;},o._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new m();else if("p224"===t)e=new w();else if("p192"===t)e=new _();else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new S();}return y[t]=e,e;},M.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers");},M.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers");},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this);},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this);},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this);},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r;},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this);},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r;},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e));},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e));},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e));},M.prototype.isqr=function(t){return this.imul(t,t.clone());},M.prototype.sqr=function(t){return this.mul(t,t);},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r);}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),f=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,u).cmp(f);)c.redIAdd(f);for(var h=this.pow(c,i),d=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),p=a;0!==l.cmp(s);){for(var b=l,v=0;0!==b.cmp(s);v++)b=b.redSqr();n(v<p);var y=this.pow(h,new o(1).iushln(p-v-1));d=d.redMul(y),h=y.redSqr(),l=l.redMul(h),p=v;}return d;},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e);},M.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var i=r[0],a=0,s=0,f=e.bitLength()%26;for(0===f&&(f=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],c=f-1;c>=0;c--){var h=u>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0;}f=26;}return i;},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e;},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e;},o.mont=function(t){return new A(t);},i(A,M),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift));},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e;},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this);},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this);},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this);};}(void 0===e||e,this);},{22:22}],17:[function(t,e,r){(function(r){(function(){"use strict";var n=t(509),i="undefined"==typeof globalThis?r:globalThis;e.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t;};}).call(this);}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});},{509:509}],18:[function(t,e,r){(function(e){(function(){"use strict";if(t(393),t(535),t(65),e._babelPolyfill)throw new Error("only one instance of babel-polyfill is allowed");e._babelPolyfill=!0;function r(t,e,r){t[e]||Object.defineProperty(t,e,{writable:!0,configurable:!0,value:r});}r(String.prototype,"padLeft","".padStart),r(String.prototype,"padRight","".padEnd),"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function(t){[][t]&&r(Array,t,Function.call.bind([][t]));});}).call(this);}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});},{393:393,535:535,65:65}],19:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n;},r.toByteArray=function(t){var e,r,n=u(t),a=n[0],s=n[1],f=new o(function(t,e,r){return 3*(e+r)/4-r;}(0,a,s)),c=0,h=s>0?a-4:a;for(r=0;r<h;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],f[c++]=e>>16&255,f[c++]=e>>8&255,f[c++]=255&e;2===s&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,f[c++]=255&e);1===s&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,f[c++]=e>>8&255,f[c++]=255&e);return f;},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=16383,s=0,f=r-i;s<f;s+=a)o.push(c(t,s,s+a>f?f:s+a));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("");};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,f=a.length;s<f;++s)n[s]=a[s],i[a.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4];}function c(t,e,r){for(var i,o,a=[],s=e;s<r;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("");}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63;},{}],20:[function(t,e,r){!function(e,r){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed");}function i(t,e){t.super_=e;var r=function r(){};r.prototype=e.prototype,t.prototype=new r(),t.prototype.constructor=t;}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"));}var a;"object"==_typeof(e)?e.exports=o:r.BN=o,o.BN=o,o.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:t(22).Buffer;}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t);}function f(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n;}function u(t,e,r,i){for(var o=0,a=0,s=Math.min(t.length,r),f=e;f<s;f++){var u=t.charCodeAt(f)-48;o*=i,a=u>=49?u-49+10:u>=17?u-17+10:u,n(u>=0&&a<i,"Invalid character"),o+=a;}return o;}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red;}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==_typeof(t)&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words);},o.max=function(t,e){return t.cmp(e)>0?t:e;},o.min=function(t,e){return t.cmp(e)<0?t:e;},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==_typeof(t))return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,r):(this._parseBase(t,e,i),"le"===r&&this._initArray(this.toArray(),e,r)));},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r);},o.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,a,s=0;if("be"===r)for(i=t.length-1,o=0;i>=0;i-=3)a=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i<t.length;i+=3)a=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip();},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,a=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=f(t,e,n)<<o,this.words[a]|=67108863&i,o>=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=f(t,e,n)<<o,this.words[a]|=67108863&i,o>=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip();},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c<s;c+=n)f=u(t,c,c+n,e),this.imuln(i),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!==a){var h=1;for(f=u(t,c,t.length,e),c=0;c<a;c++)h*=e;this.imuln(h),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);}this._strip();},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red;},o.prototype._move=function(t){c(t,this);},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t;},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this;},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign();},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this;},"undefined"!=typeof Symbol&&"function"==typeof Symbol["for"])try{o.prototype[Symbol["for"]("nodejs.util.inspect.custom")]=h;}catch(t){o.prototype.inspect=h;}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">";}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,o=0,a=0;a<this.length;a++){var s=this.words[a],f=(16777215&(s<<i|o)).toString(16);o=s>>>24-i&16777215,(i+=2)>=26&&(i-=26,a--),r=0!==o||a!==this.length-1?d[6-f.length]+f+r:f+r;}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r;}if(t===(0|t)&&t>=2&&t<=36){var u=l[t],c=p[t];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var b=h.modrn(c).toString(t);r=(h=h.idivn(c)).isZero()?b+r:d[u-b.length]+b+r;}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r;}n(!1,"Base should be between 2 and 36");},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t;},o.prototype.toJSON=function(){return this.toString(16,2);},a&&(o.prototype.toBuffer=function(t,e){return this.toArrayLike(a,t,e);}),o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e);};function b(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],a=i*o,s=67108863&a,f=a/67108864|0;r.words[0]=s;for(var u=1;u<n;u++){for(var c=f>>>26,h=67108863&f,d=Math.min(u,e.length-1),l=Math.max(0,u-t.length+1);l<=d;l++){var p=u-l|0;c+=(a=(i=0|t.words[p])*(o=0|e.words[l])+h)/67108864|0,h=67108863&a;}r.words[u]=0|h,f=0|c;}return 0!==f?r.words[u]=0|f:r.length--,r._strip();}o.prototype.toArrayLike=function(t,e,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e);}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,i),a;},o.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var a=this.words[i]<<o|n;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2);}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0;},o.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var a=this.words[i]<<o|n;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2);}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0;},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t);}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e;},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r;},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e;},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break;}return t;},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8);},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone();},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone();},o.prototype.isNeg=function(){return 0!==this.negative;},o.prototype.neg=function(){return this.clone().ineg();},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this;},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip();},o.prototype.ior=function(t){return n(0==(this.negative|t.negative)),this.iuor(t);},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this);},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this);},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip();},o.prototype.iand=function(t){return n(0==(this.negative|t.negative)),this.iuand(t);},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this);},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this);},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip();},o.prototype.ixor=function(t){return n(0==(this.negative|t.negative)),this.iuxor(t);},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this);},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this);},o.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip();},o.prototype.notn=function(t){return this.clone().inotn(t);},o.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this._strip();},o.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this;},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this);},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign();}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,a=0;a<n.length;a++)o=(e=(0|r.words[a])-(0|n.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip();},o.prototype.sub=function(t){return this.clone().isub(t);};var v=function v(t,e,r){var n,i,o,a=t.words,s=e.words,f=r.words,u=0,c=0|a[0],h=8191&c,d=c>>>13,l=0|a[1],p=8191&l,b=l>>>13,v=0|a[2],y=8191&v,g=v>>>13,m=0|a[3],w=8191&m,_=m>>>13,S=0|a[4],M=8191&S,A=S>>>13,x=0|a[5],E=8191&x,k=x>>>13,I=0|a[6],R=8191&I,B=I>>>13,P=0|a[7],T=8191&P,O=P>>>13,C=0|a[8],j=8191&C,L=C>>>13,N=0|a[9],U=8191&N,F=N>>>13,D=0|s[0],q=8191&D,z=D>>>13,V=0|s[1],G=8191&V,K=V>>>13,W=0|s[2],H=8191&W,X=W>>>13,Z=0|s[3],J=8191&Z,Y=Z>>>13,$=0|s[4],Q=8191&$,tt=$>>>13,et=0|s[5],rt=8191&et,nt=et>>>13,it=0|s[6],ot=8191&it,at=it>>>13,st=0|s[7],ft=8191&st,ut=st>>>13,ct=0|s[8],ht=8191&ct,dt=ct>>>13,lt=0|s[9],pt=8191&lt,bt=lt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(u+(n=Math.imul(h,q))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(d,q)|0))<<13)|0;u=((o=Math.imul(d,z))+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,z))+Math.imul(b,q)|0,o=Math.imul(b,z);var yt=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(d,G)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,q),i=(i=Math.imul(y,z))+Math.imul(g,q)|0,o=Math.imul(g,z),n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,K)|0;var gt=(u+(n=n+Math.imul(h,H)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(d,H)|0))<<13)|0;u=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,z))+Math.imul(_,q)|0,o=Math.imul(_,z),n=n+Math.imul(y,G)|0,i=(i=i+Math.imul(y,K)|0)+Math.imul(g,G)|0,o=o+Math.imul(g,K)|0,n=n+Math.imul(p,H)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(b,H)|0,o=o+Math.imul(b,X)|0;var mt=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(d,J)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(M,q),i=(i=Math.imul(M,z))+Math.imul(A,q)|0,o=Math.imul(A,z),n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,K)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,K)|0,n=n+Math.imul(y,H)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(g,H)|0,o=o+Math.imul(g,X)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,Y)|0;var wt=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(d,Q)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(E,q),i=(i=Math.imul(E,z))+Math.imul(k,q)|0,o=Math.imul(k,z),n=n+Math.imul(M,G)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(A,G)|0,o=o+Math.imul(A,K)|0,n=n+Math.imul(w,H)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(_,H)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(y,J)|0,i=(i=i+Math.imul(y,Y)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,q),i=(i=Math.imul(R,z))+Math.imul(B,q)|0,o=Math.imul(B,z),n=n+Math.imul(E,G)|0,i=(i=i+Math.imul(E,K)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,K)|0,n=n+Math.imul(M,H)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(A,H)|0,o=o+Math.imul(A,X)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0;var St=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,z))+Math.imul(O,q)|0,o=Math.imul(O,z),n=n+Math.imul(R,G)|0,i=(i=i+Math.imul(R,K)|0)+Math.imul(B,G)|0,o=o+Math.imul(B,K)|0,n=n+Math.imul(E,H)|0,i=(i=i+Math.imul(E,X)|0)+Math.imul(k,H)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,Y)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,at)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,at)|0;var Mt=(u+(n=n+Math.imul(h,ft)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(d,ft)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,z))+Math.imul(L,q)|0,o=Math.imul(L,z),n=n+Math.imul(T,G)|0,i=(i=i+Math.imul(T,K)|0)+Math.imul(O,G)|0,o=o+Math.imul(O,K)|0,n=n+Math.imul(R,H)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(B,H)|0,o=o+Math.imul(B,X)|0,n=n+Math.imul(E,J)|0,i=(i=i+Math.imul(E,Y)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,at)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,at)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ut)|0)+Math.imul(b,ft)|0,o=o+Math.imul(b,ut)|0;var At=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,dt)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(U,q),i=(i=Math.imul(U,z))+Math.imul(F,q)|0,o=Math.imul(F,z),n=n+Math.imul(j,G)|0,i=(i=i+Math.imul(j,K)|0)+Math.imul(L,G)|0,o=o+Math.imul(L,K)|0,n=n+Math.imul(T,H)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(O,H)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,Y)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,at)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,at)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(g,ft)|0,o=o+Math.imul(g,ut)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,dt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,dt)|0;var xt=(u+(n=n+Math.imul(h,pt)|0)|0)+((8191&(i=(i=i+Math.imul(h,bt)|0)+Math.imul(d,pt)|0))<<13)|0;u=((o=o+Math.imul(d,bt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(U,G),i=(i=Math.imul(U,K))+Math.imul(F,G)|0,o=Math.imul(F,K),n=n+Math.imul(j,H)|0,i=(i=i+Math.imul(j,X)|0)+Math.imul(L,H)|0,o=o+Math.imul(L,X)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,Y)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,at)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,at)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ut)|0)+Math.imul(_,ft)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,dt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,dt)|0;var Et=(u+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,bt)|0)+Math.imul(b,pt)|0))<<13)|0;u=((o=o+Math.imul(b,bt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,H),i=(i=Math.imul(U,X))+Math.imul(F,H)|0,o=Math.imul(F,X),n=n+Math.imul(j,J)|0,i=(i=i+Math.imul(j,Y)|0)+Math.imul(L,J)|0,o=o+Math.imul(L,Y)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,n=n+Math.imul(M,ft)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,dt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,dt)|0;var kt=(u+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,bt)|0)+Math.imul(g,pt)|0))<<13)|0;u=((o=o+Math.imul(g,bt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(U,J),i=(i=Math.imul(U,Y))+Math.imul(F,J)|0,o=Math.imul(F,Y),n=n+Math.imul(j,Q)|0,i=(i=i+Math.imul(j,tt)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,at)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,at)|0,n=n+Math.imul(E,ft)|0,i=(i=i+Math.imul(E,ut)|0)+Math.imul(k,ft)|0,o=o+Math.imul(k,ut)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,dt)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,dt)|0;var It=(u+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,bt)|0)+Math.imul(_,pt)|0))<<13)|0;u=((o=o+Math.imul(_,bt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(U,Q),i=(i=Math.imul(U,tt))+Math.imul(F,Q)|0,o=Math.imul(F,tt),n=n+Math.imul(j,rt)|0,i=(i=i+Math.imul(j,nt)|0)+Math.imul(L,rt)|0,o=o+Math.imul(L,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,at)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,at)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ut)|0)+Math.imul(B,ft)|0,o=o+Math.imul(B,ut)|0,n=n+Math.imul(E,ht)|0,i=(i=i+Math.imul(E,dt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,dt)|0;var Rt=(u+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,bt)|0)+Math.imul(A,pt)|0))<<13)|0;u=((o=o+Math.imul(A,bt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(U,rt),i=(i=Math.imul(U,nt))+Math.imul(F,rt)|0,o=Math.imul(F,nt),n=n+Math.imul(j,ot)|0,i=(i=i+Math.imul(j,at)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,at)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ut)|0)+Math.imul(O,ft)|0,o=o+Math.imul(O,ut)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,dt)|0)+Math.imul(B,ht)|0,o=o+Math.imul(B,dt)|0;var Bt=(u+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,bt)|0)+Math.imul(k,pt)|0))<<13)|0;u=((o=o+Math.imul(k,bt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(U,ot),i=(i=Math.imul(U,at))+Math.imul(F,ot)|0,o=Math.imul(F,at),n=n+Math.imul(j,ft)|0,i=(i=i+Math.imul(j,ut)|0)+Math.imul(L,ft)|0,o=o+Math.imul(L,ut)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,dt)|0)+Math.imul(O,ht)|0,o=o+Math.imul(O,dt)|0;var Pt=(u+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,bt)|0)+Math.imul(B,pt)|0))<<13)|0;u=((o=o+Math.imul(B,bt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(U,ft),i=(i=Math.imul(U,ut))+Math.imul(F,ft)|0,o=Math.imul(F,ut),n=n+Math.imul(j,ht)|0,i=(i=i+Math.imul(j,dt)|0)+Math.imul(L,ht)|0,o=o+Math.imul(L,dt)|0;var Tt=(u+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,bt)|0)+Math.imul(O,pt)|0))<<13)|0;u=((o=o+Math.imul(O,bt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(U,ht),i=(i=Math.imul(U,dt))+Math.imul(F,ht)|0,o=Math.imul(F,dt);var Ot=(u+(n=n+Math.imul(j,pt)|0)|0)+((8191&(i=(i=i+Math.imul(j,bt)|0)+Math.imul(L,pt)|0))<<13)|0;u=((o=o+Math.imul(L,bt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Ct=(u+(n=Math.imul(U,pt))|0)+((8191&(i=(i=Math.imul(U,bt))+Math.imul(F,pt)|0))<<13)|0;return u=((o=Math.imul(F,bt))+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,f[0]=vt,f[1]=yt,f[2]=gt,f[3]=mt,f[4]=wt,f[5]=_t,f[6]=St,f[7]=Mt,f[8]=At,f[9]=xt,f[10]=Et,f[11]=kt,f[12]=It,f[13]=Rt,f[14]=Bt,f[15]=Pt,f[16]=Tt,f[17]=Ot,f[18]=Ct,0!==u&&(f[19]=u,r.length++),r;};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var a=i;i=0;for(var s=67108863&n,f=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=f;u++){var c=o-u,h=(0|t.words[c])*(0|e.words[u]),d=67108863&h;s=67108863&(d=d+s|0),i+=(a=(a=a+(h/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863;}r.words[o]=s,n=a,a=i;}return 0!==n?r.words[o]=n:r.length--,r._strip();}function g(t,e,r){return y(t,e,r);}function m(t,e){this.x=t,this.y=e;}Math.imul||(v=b),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?v(this,t,e):r<63?b(this,t,e):r<1024?y(this,t,e):g(this,t,e);},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e;},m.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n;},m.prototype.permute=function(t,e,r,n,i,o){for(var a=0;a<o;a++)n[a]=e[t[a]],i[a]=r[t[a]];},m.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var a=1;a<i;a<<=1)for(var s=a<<1,f=Math.cos(2*Math.PI/s),u=Math.sin(2*Math.PI/s),c=0;c<i;c+=s)for(var h=f,d=u,l=0;l<a;l++){var p=r[c+l],b=n[c+l],v=r[c+l+a],y=n[c+l+a],g=h*v-d*y;y=h*y+d*v,v=g,r[c+l]=p+v,n[c+l]=b+y,r[c+l+a]=p-v,n[c+l+a]=b-y,l!==s&&(g=f*h-u*d,d=f*d+u*h,h=g);}},m.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n;},m.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i;}},m.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0;}return t;},m.prototype.convert13b=function(t,e,r,i){for(var o=0,a=0;a<e;a++)o+=0|t[a],r[2*a]=8191&o,o>>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*e;a<i;++a)r[a]=0;n(0===o),n(0==(-8192&o));},m.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e;},m.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),a=new Array(n),s=new Array(n),f=new Array(n),u=new Array(n),c=new Array(n),h=new Array(n),d=r.words;d.length=n,this.convert13b(t.words,t.length,a,n),this.convert13b(e.words,e.length,u,n),this.transform(a,o,s,f,n,i),this.transform(u,o,c,h,n,i);for(var l=0;l<n;l++){var p=s[l]*c[l]-f[l]*h[l];f[l]=s[l]*h[l]+f[l]*c[l],s[l]=p;}return this.conjugate(s,f,n),this.transform(s,f,d,o,n,i),this.conjugate(d,o,n),this.normalize13b(d,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r._strip();},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e);},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),g(this,t,e);},o.prototype.imul=function(t){return this.clone().mulTo(t,this);},o.prototype.imuln=function(t){var e=t<0;e&&(t=-t),n("number"==typeof t),n(t<67108864);for(var r=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,a=(67108863&o)+(67108863&r);r>>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a;}return 0!==r&&(this.words[i]=r,this.length++),this.length=0===t?1:this.length,e?this.ineg():this;},o.prototype.muln=function(t){return this.clone().imuln(t);},o.prototype.sqr=function(){return this.mul(this);},o.prototype.isqr=function(){return this.imul(this.clone());},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1;}return e;}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r;},o.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,f=(0|this.words[e])-s<<r;this.words[e]=f|a,a=s>>>26-r;}a&&(this.words[e]=a,this.length++);}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i;}return this._strip();},o.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t);},o.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,f=r;if(i-=a,i=Math.max(0,i),f){for(var u=0;u<a;u++)f.words[u]=this.words[u];f.length=a;}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var c=0;for(u=this.length-1;u>=0&&(0!==c||u>=i);u--){var h=0|this.words[u];this.words[u]=c<<26-o|h>>>o,c=h&s;}return f&&0!==c&&(f.words[f.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip();},o.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r);},o.prototype.shln=function(t){return this.clone().ishln(t);},o.prototype.ushln=function(t){return this.clone().iushln(t);},o.prototype.shrn=function(t){return this.clone().ishrn(t);},o.prototype.ushrn=function(t){return this.clone().iushrn(t);},o.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i);},o.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i;}return this._strip();},o.prototype.maskn=function(t){return this.clone().imaskn(t);},o.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t);},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this;},o.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip();},o.prototype.addn=function(t){return this.clone().iaddn(t);},o.prototype.subn=function(t){return this.clone().isubn(t);},o.prototype.iabs=function(){return this.negative=0,this;},o.prototype.abs=function(){return this.clone().iabs();},o.prototype._ishlnsubmul=function(t,e,r){var i,o,a=t.length+r;this._expand(a);var s=0;for(i=0;i<t.length;i++){o=(0|this.words[i+r])+s;var f=(0|t.words[i])*e;s=((o-=67108863&f)>>26)-(f/67108864|0),this.words[i+r]=67108863&o;}for(;i<this.length-r;i++)s=(o=(0|this.words[i+r])+s)>>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i<this.length;i++)s=(o=-(0|this.words[i])+s)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip();},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,f=n.length-i.length;if("mod"!==e){(s=new o(null)).length=f+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0;}var c=n.clone()._ishlnsubmul(i,1,f);0===c.negative&&(n=c,s&&(s.words[f]=1));for(var h=f-1;h>=0;h--){var d=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(d=Math.min(d/a|0,67108863),n._ishlnsubmul(i,d,h);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);s&&(s.words[h]=d);}return s&&s._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:s||null,mod:n};},o.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(i=s.div.neg()),"div"!==e&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(t)),{div:i,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,e);var i,a,s;},o.prototype.div=function(t){return this.divmod(t,"div",!1).div;},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod;},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod;},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1);},o.prototype.modrn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%t;return e?-i:i;},o.prototype.modn=function(t){return this.modrn(t);},o.prototype.idivn=function(t){var e=t<0;e&&(t=-t),n(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/t|0,r=o%t;}return this._strip(),e?this.ineg():this;},o.prototype.divn=function(t){return this.clone().idivn(t);},o.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),a=new o(0),s=new o(0),f=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),h=e.clone();!e.isZero();){for(var d=0,l=1;0==(e.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(e.iushrn(d);d-->0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(h)),i.iushrn(1),a.iushrn(1);for(var p=0,b=1;0==(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-->0;)(s.isOdd()||f.isOdd())&&(s.iadd(c),f.isub(h)),s.iushrn(1),f.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(s),a.isub(f)):(r.isub(e),s.isub(i),f.isub(a));}return{a:s,b:f,gcd:r.iushln(u)};},o.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,a=new o(1),s=new o(0),f=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(e.iushrn(u);u-->0;)a.isOdd()&&a.iadd(f),a.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-->0;)s.isOdd()&&s.iadd(f),s.iushrn(1);e.cmp(r)>=0?(e.isub(r),a.isub(s)):(r.isub(e),s.isub(a));}return(i=0===e.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(t),i;},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o;}else if(0===i||0===r.cmpn(1))break;e.isub(r);}return r.iushln(n);},o.prototype.invm=function(t){return this.egcd(t).a.umod(t);},o.prototype.isEven=function(){return 0==(1&this.words[0]);},o.prototype.isOdd=function(){return 1==(1&this.words[0]);},o.prototype.andln=function(t){return this.words[0]&t;},o.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var o=i,a=r;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s;}return 0!==o&&(this.words[a]=o,this.length++),this;},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0];},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1;}return 0!==this.negative?0|-e:e;},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e;},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break;}}return e;},o.prototype.gtn=function(t){return 1===this.cmpn(t);},o.prototype.gt=function(t){return 1===this.cmp(t);},o.prototype.gten=function(t){return this.cmpn(t)>=0;},o.prototype.gte=function(t){return this.cmp(t)>=0;},o.prototype.ltn=function(t){return-1===this.cmpn(t);},o.prototype.lt=function(t){return-1===this.cmp(t);},o.prototype.lten=function(t){return this.cmpn(t)<=0;},o.prototype.lte=function(t){return this.cmp(t)<=0;},o.prototype.eqn=function(t){return 0===this.cmpn(t);},o.prototype.eq=function(t){return 0===this.cmp(t);},o.red=function(t){return new E(t);},o.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t);},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this);},o.prototype._forceRed=function(t){return this.red=t,this;},o.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t);},o.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t);},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t);},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t);},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t);},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t);},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t);},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t);},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this);},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this);},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this);},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this);},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this);},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t);};var w={k256:null,p224:null,p192:null,p25519:null};function _(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp();}function S(){_.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f");}function M(){_.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001");}function A(){_.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff");}function x(){_.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed");}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e;}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null;}function k(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv);}_.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t;},_.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength();}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r;},_.prototype.split=function(t,e){t.iushrn(this.n,0,e);},_.prototype.imulK=function(t){return t.imul(this.k);},i(S,_),S.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var a=0|t.words[i];t.words[i-10]=(a&r)<<4|o>>>22,o=a;}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9;},S.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0);}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t;},i(M,_),i(A,_),i(x,_),x.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n;}return 0!==e&&(t.words[t.length++]=e),t;},o._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new S();else if("p224"===t)e=new M();else if("p192"===t)e=new A();else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new x();}return w[t]=e,e;},E.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers");},E.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers");},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t);},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this);},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this);},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r;},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this);},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r;},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e));},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e));},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e));},E.prototype.isqr=function(t){return this.imul(t,t.clone());},E.prototype.sqr=function(t){return this.mul(t,t);},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r);}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),f=s.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,u).cmp(f);)c.redIAdd(f);for(var h=this.pow(c,i),d=this.pow(t,i.addn(1).iushrn(1)),l=this.pow(t,i),p=a;0!==l.cmp(s);){for(var b=l,v=0;0!==b.cmp(s);v++)b=b.redSqr();n(v<p);var y=this.pow(h,new o(1).iushln(p-v-1));d=d.redMul(y),h=y.redSqr(),l=l.redMul(h),p=v;}return d;},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e);},E.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var i=r[0],a=0,s=0,f=e.bitLength()%26;for(0===f&&(f=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],c=f-1;c>=0;c--){var h=u>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==a?(a<<=1,a|=h,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0;}f=26;}return i;},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e;},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e;},o.mont=function(t){return new k(t);},i(k,E),k.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift));},k.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e;},k.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this);},k.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this);},k.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this);};}(void 0===e||e,this);},{22:22}],21:[function(t,e,r){var n;function i(t){this.rand=t;}if(e.exports=function(t){return n||(n=new i(null)),n.generate(t);},e.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t);},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e;},"object"==(typeof self==="undefined"?"undefined":_typeof(self)))self.crypto&&self.crypto.getRandomValues?i.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e;}:self.msCrypto&&self.msCrypto.getRandomValues?i.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e;}:"object"==(typeof window==="undefined"?"undefined":_typeof(window))&&(i.prototype._rand=function(){throw new Error("Not implemented yet");});else try{var o=t(22);if("function"!=typeof o.randomBytes)throw new Error("Not supported");i.prototype._rand=function(t){return o.randomBytes(t);};}catch(t){}},{22:22}],22:[function(t,e,r){},{}],23:[function(t,e,r){var n=t(537).Buffer;function i(t){n.isBuffer(t)||(t=n.from(t));for(var e=t.length/4|0,r=new Array(e),i=0;i<e;i++)r[i]=t.readUInt32BE(4*i);return r;}function o(t){for(;0<t.length;t++)t[0]=0;}function a(t,e,r,n,i){for(var o,a,s,f,u=r[0],c=r[1],h=r[2],d=r[3],l=t[0]^e[0],p=t[1]^e[1],b=t[2]^e[2],v=t[3]^e[3],y=4,g=1;g<i;g++)o=u[l>>>24]^c[p>>>16&255]^h[b>>>8&255]^d[255&v]^e[y++],a=u[p>>>24]^c[b>>>16&255]^h[v>>>8&255]^d[255&l]^e[y++],s=u[b>>>24]^c[v>>>16&255]^h[l>>>8&255]^d[255&p]^e[y++],f=u[v>>>24]^c[l>>>16&255]^h[p>>>8&255]^d[255&b]^e[y++],l=o,p=a,b=s,v=f;return o=(n[l>>>24]<<24|n[p>>>16&255]<<16|n[b>>>8&255]<<8|n[255&v])^e[y++],a=(n[p>>>24]<<24|n[b>>>16&255]<<16|n[v>>>8&255]<<8|n[255&l])^e[y++],s=(n[b>>>24]<<24|n[v>>>16&255]<<16|n[l>>>8&255]<<8|n[255&p])^e[y++],f=(n[v>>>24]<<24|n[l>>>16&255]<<16|n[p>>>8&255]<<8|n[255&b])^e[y++],[o>>>=0,a>>>=0,s>>>=0,f>>>=0];}var s=[0,1,2,4,8,16,32,64,128,27,54],f=function(){for(var t=new Array(256),e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,f=0;f<256;++f){var u=s^s<<1^s<<2^s<<3^s<<4;u=u>>>8^255&u^99,r[a]=u,n[u]=a;var c=t[a],h=t[c],d=t[h],l=257*t[u]^16843008*u;i[0][a]=l<<24|l>>>8,i[1][a]=l<<16|l>>>16,i[2][a]=l<<8|l>>>24,i[3][a]=l,l=16843009*d^65537*h^257*c^16843008*a,o[0][u]=l<<24|l>>>8,o[1][u]=l<<16|l>>>16,o[2][u]=l<<8|l>>>24,o[3][u]=l,0===a?a=s=1:(a=c^t[t[t[d^c]]],s^=t[t[s]]);}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o};}();function u(t){this._key=i(t),this._reset();}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var t=this._key,e=t.length,r=e+6,n=4*(r+1),i=[],o=0;o<e;o++)i[o]=t[o];for(o=e;o<n;o++){var a=i[o-1];o%e==0?(a=a<<8|a>>>24,a=f.SBOX[a>>>24]<<24|f.SBOX[a>>>16&255]<<16|f.SBOX[a>>>8&255]<<8|f.SBOX[255&a],a^=s[o/e|0]<<24):e>6&&o%e==4&&(a=f.SBOX[a>>>24]<<24|f.SBOX[a>>>16&255]<<16|f.SBOX[a>>>8&255]<<8|f.SBOX[255&a]),i[o]=i[o-e]^a;}for(var u=[],c=0;c<n;c++){var h=n-c,d=i[h-(c%4?0:4)];u[c]=c<4||h<=4?d:f.INV_SUB_MIX[0][f.SBOX[d>>>24]]^f.INV_SUB_MIX[1][f.SBOX[d>>>16&255]]^f.INV_SUB_MIX[2][f.SBOX[d>>>8&255]]^f.INV_SUB_MIX[3][f.SBOX[255&d]];}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=u;},u.prototype.encryptBlockRaw=function(t){return a(t=i(t),this._keySchedule,f.SUB_MIX,f.SBOX,this._nRounds);},u.prototype.encryptBlock=function(t){var e=this.encryptBlockRaw(t),r=n.allocUnsafe(16);return r.writeUInt32BE(e[0],0),r.writeUInt32BE(e[1],4),r.writeUInt32BE(e[2],8),r.writeUInt32BE(e[3],12),r;},u.prototype.decryptBlock=function(t){var e=(t=i(t))[1];t[1]=t[3],t[3]=e;var r=a(t,this._invKeySchedule,f.INV_SUB_MIX,f.INV_SBOX,this._nRounds),o=n.allocUnsafe(16);return o.writeUInt32BE(r[0],0),o.writeUInt32BE(r[3],4),o.writeUInt32BE(r[2],8),o.writeUInt32BE(r[1],12),o;},u.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key);},e.exports.AES=u;},{537:537}],24:[function(t,e,r){var n=t(23),i=t(537).Buffer,o=t(63),a=t(474),s=t(28),f=t(53),u=t(29);function c(t,e,r,a){o.call(this);var f=i.alloc(4,0);this._cipher=new n.AES(e);var c=this._cipher.encryptBlock(f);this._ghash=new s(c),r=function(t,e,r){if(12===e.length)return t._finID=i.concat([e,i.from([0,0,0,1])]),i.concat([e,i.from([0,0,0,2])]);var n=new s(r),o=e.length,a=o%16;n.update(e),a&&(a=16-a,n.update(i.alloc(a,0))),n.update(i.alloc(8,0));var f=8*o,c=i.alloc(8);c.writeUIntBE(f,0,8),n.update(c),t._finID=n.state;var h=i.from(t._finID);return u(h),h;}(this,r,c),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._alen=0,this._len=0,this._mode=t,this._authTag=null,this._called=!1;}a(c,o),c.prototype._update=function(t){if(!this._called&&this._alen){var e=16-this._alen%16;e<16&&(e=i.alloc(e,0),this._ghash.update(e));}this._called=!0;var r=this._mode.encrypt(this,t);return this._decrypt?this._ghash.update(t):this._ghash.update(r),this._len+=t.length,r;},c.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var t=f(this._ghash["final"](8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt&&function(t,e){var r=0;t.length!==e.length&&r++;for(var n=Math.min(t.length,e.length),i=0;i<n;++i)r+=t[i]^e[i];return r;}(t,this._authTag))throw new Error("Unsupported state or unable to authenticate data");this._authTag=t,this._cipher.scrub();},c.prototype.getAuthTag=function(){if(this._decrypt||!i.isBuffer(this._authTag))throw new Error("Attempting to get auth tag in unsupported state");return this._authTag;},c.prototype.setAuthTag=function(t){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=t;},c.prototype.setAAD=function(t){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(t),this._alen+=t.length;},e.exports=c;},{23:23,28:28,29:29,474:474,53:53,537:537,63:63}],25:[function(t,e,r){var n=t(27),i=t(26),o=t(37);r.createCipher=r.Cipher=n.createCipher,r.createCipheriv=r.Cipheriv=n.createCipheriv,r.createDecipher=r.Decipher=i.createDecipher,r.createDecipheriv=r.Decipheriv=i.createDecipheriv,r.listCiphers=r.getCiphers=function(){return Object.keys(o);};},{26:26,27:27,37:37}],26:[function(t,e,r){var n=t(24),i=t(537).Buffer,o=t(36),a=t(39),s=t(63),f=t(23),u=t(442);function c(t,e,r){s.call(this),this._cache=new h(),this._last=void 0,this._cipher=new f.AES(e),this._prev=i.from(r),this._mode=t,this._autopadding=!0;}function h(){this.cache=i.allocUnsafe(0);}function d(t,e,r){var s=o[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=i.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof e&&(e=i.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);return"stream"===s.type?new a(s.module,e,r,!0):"auth"===s.type?new n(s.module,e,r,!0):new c(s.module,e,r);}t(474)(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,e),n.push(r);return i.concat(n);},c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return function(t){var e=t[15];if(e<1||e>16)throw new Error("unable to decrypt data");var r=-1;for(;++r<e;)if(t[r+(16-e)]!==e)throw new Error("unable to decrypt data");if(16===e)return;return t.slice(0,16-e);}(this._mode.decrypt(this,t));if(t)throw new Error("data not multiple of block length");},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this;},h.prototype.add=function(t){this.cache=i.concat([this.cache,t]);},h.prototype.get=function(t){var e;if(t){if(this.cache.length>16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;}else if(this.cache.length>=16)return e=this.cache.slice(0,16),this.cache=this.cache.slice(16),e;return null;},h.prototype.flush=function(){if(this.cache.length)return this.cache;},r.createDecipher=function(t,e){var r=o[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(e,!1,r.key,r.iv);return d(t,n.key,n.iv);},r.createDecipheriv=d;},{23:23,24:24,36:36,39:39,442:442,474:474,537:537,63:63}],27:[function(t,e,r){var n=t(36),i=t(24),o=t(537).Buffer,a=t(39),s=t(63),f=t(23),u=t(442);function c(t,e,r){s.call(this),this._cache=new d(),this._cipher=new f.AES(e),this._prev=o.from(r),this._mode=t,this._autopadding=!0;}t(474)(c,s),c.prototype._update=function(t){var e,r;this._cache.add(t);for(var n=[];e=this._cache.get();)r=this._mode.encrypt(this,e),n.push(r);return o.concat(n);};var h=o.alloc(16,16);function d(){this.cache=o.allocUnsafe(0);}function l(t,e,r){var s=n[t.toLowerCase()];if(!s)throw new TypeError("invalid suite type");if("string"==typeof e&&(e=o.from(e)),e.length!==s.key/8)throw new TypeError("invalid key length "+e.length);if("string"==typeof r&&(r=o.from(r)),"GCM"!==s.mode&&r.length!==s.iv)throw new TypeError("invalid iv length "+r.length);return"stream"===s.type?new a(s.module,e,r):"auth"===s.type?new i(s.module,e,r):new c(s.module,e,r);}c.prototype._final=function(){var t=this._cache.flush();if(this._autopadding)return t=this._mode.encrypt(this,t),this._cipher.scrub(),t;if(!t.equals(h))throw this._cipher.scrub(),new Error("data not multiple of block length");},c.prototype.setAutoPadding=function(t){return this._autopadding=!!t,this;},d.prototype.add=function(t){this.cache=o.concat([this.cache,t]);},d.prototype.get=function(){if(this.cache.length>15){var t=this.cache.slice(0,16);return this.cache=this.cache.slice(16),t;}return null;},d.prototype.flush=function(){for(var t=16-this.cache.length,e=o.allocUnsafe(t),r=-1;++r<t;)e.writeUInt8(t,r);return o.concat([this.cache,e]);},r.createCipheriv=l,r.createCipher=function(t,e){var r=n[t.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var i=u(e,!1,r.key,r.iv);return l(t,i.key,i.iv);};},{23:23,24:24,36:36,39:39,442:442,474:474,537:537,63:63}],28:[function(t,e,r){var n=t(537).Buffer,i=n.alloc(16,0);function o(t){var e=n.allocUnsafe(16);return e.writeUInt32BE(t[0]>>>0,0),e.writeUInt32BE(t[1]>>>0,4),e.writeUInt32BE(t[2]>>>0,8),e.writeUInt32BE(t[3]>>>0,12),e;}function a(t){this.h=t,this.state=n.alloc(16,0),this.cache=n.allocUnsafe(0);}a.prototype.ghash=function(t){for(var e=-1;++e<t.length;)this.state[e]^=t[e];this._multiply();},a.prototype._multiply=function(){for(var t,e,r,n=[(t=this.h).readUInt32BE(0),t.readUInt32BE(4),t.readUInt32BE(8),t.readUInt32BE(12)],i=[0,0,0,0],a=-1;++a<128;){for(0!=(this.state[~~(a/8)]&1<<7-a%8)&&(i[0]^=n[0],i[1]^=n[1],i[2]^=n[2],i[3]^=n[3]),r=0!=(1&n[3]),e=3;e>0;e--)n[e]=n[e]>>>1|(1&n[e-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24);}this.state=o(i);},a.prototype.update=function(t){var e;for(this.cache=n.concat([this.cache,t]);this.cache.length>=16;)e=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(e);},a.prototype["final"]=function(t,e){return this.cache.length&&this.ghash(n.concat([this.cache,i],16)),this.ghash(o([0,t,0,e])),this.state;},e.exports=a;},{537:537}],29:[function(t,e,r){e.exports=function(t){for(var e,r=t.length;r--;){if(255!==(e=t.readUInt8(r))){e++,t.writeUInt8(e,r);break;}t.writeUInt8(0,r);}};},{}],30:[function(t,e,r){var n=t(53);r.encrypt=function(t,e){var r=n(e,t._prev);return t._prev=t._cipher.encryptBlock(r),t._prev;},r.decrypt=function(t,e){var r=t._prev;t._prev=e;var i=t._cipher.decryptBlock(e);return n(i,r);};},{53:53}],31:[function(t,e,r){var n=t(537).Buffer,i=t(53);function o(t,e,r){var o=e.length,a=i(e,t._cache);return t._cache=t._cache.slice(o),t._prev=n.concat([t._prev,r?e:a]),a;}r.encrypt=function(t,e,r){for(var i,a=n.allocUnsafe(0);e.length;){if(0===t._cache.length&&(t._cache=t._cipher.encryptBlock(t._prev),t._prev=n.allocUnsafe(0)),!(t._cache.length<=e.length)){a=n.concat([a,o(t,e,r)]);break;}i=t._cache.length,a=n.concat([a,o(t,e.slice(0,i),r)]),e=e.slice(i);}return a;};},{53:53,537:537}],32:[function(t,e,r){var n=t(537).Buffer;function i(t,e,r){for(var n,i,a=-1,s=0;++a<8;)n=e&1<<7-a?128:0,s+=(128&(i=t._cipher.encryptBlock(t._prev)[0]^n))>>a%8,t._prev=o(t._prev,r?n:i);return s;}function o(t,e){var r=t.length,i=-1,o=n.allocUnsafe(t.length);for(t=n.concat([t,n.from([e])]);++i<r;)o[i]=t[i]<<1|t[i+1]>>7;return o;}r.encrypt=function(t,e,r){for(var o=e.length,a=n.allocUnsafe(o),s=-1;++s<o;)a[s]=i(t,e[s],r);return a;};},{537:537}],33:[function(t,e,r){var n=t(537).Buffer;function i(t,e,r){var i=t._cipher.encryptBlock(t._prev)[0]^e;return t._prev=n.concat([t._prev.slice(1),n.from([r?e:i])]),i;}r.encrypt=function(t,e,r){for(var o=e.length,a=n.allocUnsafe(o),s=-1;++s<o;)a[s]=i(t,e[s],r);return a;};},{537:537}],34:[function(t,e,r){var n=t(53),i=t(537).Buffer,o=t(29);function a(t){var e=t._cipher.encryptBlockRaw(t._prev);return o(t._prev),e;}r.encrypt=function(t,e){var r=Math.ceil(e.length/16),o=t._cache.length;t._cache=i.concat([t._cache,i.allocUnsafe(16*r)]);for(var s=0;s<r;s++){var f=a(t),u=o+16*s;t._cache.writeUInt32BE(f[0],u+0),t._cache.writeUInt32BE(f[1],u+4),t._cache.writeUInt32BE(f[2],u+8),t._cache.writeUInt32BE(f[3],u+12);}var c=t._cache.slice(0,e.length);return t._cache=t._cache.slice(e.length),n(e,c);};},{29:29,53:53,537:537}],35:[function(t,e,r){r.encrypt=function(t,e){return t._cipher.encryptBlock(e);},r.decrypt=function(t,e){return t._cipher.decryptBlock(e);};},{}],36:[function(t,e,r){var n={ECB:t(35),CBC:t(30),CFB:t(31),CFB8:t(33),CFB1:t(32),OFB:t(38),CTR:t(34),GCM:t(34)},i=t(37);for(var o in i)i[o].module=n[i[o].mode];e.exports=i;},{30:30,31:31,32:32,33:33,34:34,35:35,37:37,38:38}],37:[function(t,e,r){e.exports={"aes-128-ecb":{cipher:"AES",key:128,iv:0,mode:"ECB",type:"block"},"aes-192-ecb":{cipher:"AES",key:192,iv:0,mode:"ECB",type:"block"},"aes-256-ecb":{cipher:"AES",key:256,iv:0,mode:"ECB",type:"block"},"aes-128-cbc":{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},"aes-192-cbc":{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},"aes-256-cbc":{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},aes128:{cipher:"AES",key:128,iv:16,mode:"CBC",type:"block"},aes192:{cipher:"AES",key:192,iv:16,mode:"CBC",type:"block"},aes256:{cipher:"AES",key:256,iv:16,mode:"CBC",type:"block"},"aes-128-cfb":{cipher:"AES",key:128,iv:16,mode:"CFB",type:"stream"},"aes-192-cfb":{cipher:"AES",key:192,iv:16,mode:"CFB",type:"stream"},"aes-256-cfb":{cipher:"AES",key:256,iv:16,mode:"CFB",type:"stream"},"aes-128-cfb8":{cipher:"AES",key:128,iv:16,mode:"CFB8",type:"stream"},"aes-192-cfb8":{cipher:"AES",key:192,iv:16,mode:"CFB8",type:"stream"},"aes-256-cfb8":{cipher:"AES",key:256,iv:16,mode:"CFB8",type:"stream"},"aes-128-cfb1":{cipher:"AES",key:128,iv:16,mode:"CFB1",type:"stream"},"aes-192-cfb1":{cipher:"AES",key:192,iv:16,mode:"CFB1",type:"stream"},"aes-256-cfb1":{cipher:"AES",key:256,iv:16,mode:"CFB1",type:"stream"},"aes-128-ofb":{cipher:"AES",key:128,iv:16,mode:"OFB",type:"stream"},"aes-192-ofb":{cipher:"AES",key:192,iv:16,mode:"OFB",type:"stream"},"aes-256-ofb":{cipher:"AES",key:256,iv:16,mode:"OFB",type:"stream"},"aes-128-ctr":{cipher:"AES",key:128,iv:16,mode:"CTR",type:"stream"},"aes-192-ctr":{cipher:"AES",key:192,iv:16,mode:"CTR",type:"stream"},"aes-256-ctr":{cipher:"AES",key:256,iv:16,mode:"CTR",type:"stream"},"aes-128-gcm":{cipher:"AES",key:128,iv:12,mode:"GCM",type:"auth"},"aes-192-gcm":{cipher:"AES",key:192,iv:12,mode:"GCM",type:"auth"},"aes-256-gcm":{cipher:"AES",key:256,iv:12,mode:"GCM",type:"auth"}};},{}],38:[function(t,e,r){(function(e){(function(){var n=t(53);function i(t){return t._prev=t._cipher.encryptBlock(t._prev),t._prev;}r.encrypt=function(t,r){for(;t._cache.length<r.length;)t._cache=e.concat([t._cache,i(t)]);var o=t._cache.slice(0,r.length);return t._cache=t._cache.slice(r.length),n(r,o);};}).call(this);}).call(this,t(54).Buffer);},{53:53,54:54}],39:[function(t,e,r){var n=t(23),i=t(537).Buffer,o=t(63);function a(t,e,r,a){o.call(this),this._cipher=new n.AES(e),this._prev=i.from(r),this._cache=i.allocUnsafe(0),this._secCache=i.allocUnsafe(0),this._decrypt=a,this._mode=t;}t(474)(a,o),a.prototype._update=function(t){return this._mode.encrypt(this,t,this._decrypt);},a.prototype._final=function(){this._cipher.scrub();},e.exports=a;},{23:23,474:474,537:537,63:63}],40:[function(t,e,r){var n=t(41),i=t(25),o=t(36),a=t(42),s=t(442);function f(t,e,r){if(t=t.toLowerCase(),o[t])return i.createCipheriv(t,e,r);if(a[t])return new n({key:e,iv:r,mode:t});throw new TypeError("invalid suite type");}function u(t,e,r){if(t=t.toLowerCase(),o[t])return i.createDecipheriv(t,e,r);if(a[t])return new n({key:e,iv:r,mode:t,decrypt:!0});throw new TypeError("invalid suite type");}r.createCipher=r.Cipher=function(t,e){var r,n;if(t=t.toLowerCase(),o[t])r=o[t].key,n=o[t].iv;else{if(!a[t])throw new TypeError("invalid suite type");r=8*a[t].key,n=a[t].iv;}var i=s(e,!1,r,n);return f(t,i.key,i.iv);},r.createCipheriv=r.Cipheriv=f,r.createDecipher=r.Decipher=function(t,e){var r,n;if(t=t.toLowerCase(),o[t])r=o[t].key,n=o[t].iv;else{if(!a[t])throw new TypeError("invalid suite type");r=8*a[t].key,n=a[t].iv;}var i=s(e,!1,r,n);return u(t,i.key,i.iv);},r.createDecipheriv=r.Decipheriv=u,r.listCiphers=r.getCiphers=function(){return Object.keys(a).concat(i.getCiphers());};},{25:25,36:36,41:41,42:42,442:442}],41:[function(t,e,r){var n=t(63),i=t(403),o=t(474),a=t(537).Buffer,s={"des-ede3-cbc":i.CBC.instantiate(i.EDE),"des-ede3":i.EDE,"des-ede-cbc":i.CBC.instantiate(i.EDE),"des-ede":i.EDE,"des-cbc":i.CBC.instantiate(i.DES),"des-ecb":i.DES};function f(t){n.call(this);var e,r=t.mode.toLowerCase(),i=s[r];e=t.decrypt?"decrypt":"encrypt";var o=t.key;a.isBuffer(o)||(o=a.from(o)),"des-ede"!==r&&"des-ede-cbc"!==r||(o=a.concat([o,o.slice(0,8)]));var f=t.iv;a.isBuffer(f)||(f=a.from(f)),this._des=i.create({key:o,iv:f,type:e});}s.des=s["des-cbc"],s.des3=s["des-ede3-cbc"],e.exports=f,o(f,n),f.prototype._update=function(t){return a.from(this._des.update(t));},f.prototype._final=function(){return a.from(this._des["final"]());};},{403:403,474:474,537:537,63:63}],42:[function(t,e,r){r["des-ecb"]={key:8,iv:0},r["des-cbc"]=r.des={key:8,iv:8},r["des-ede3-cbc"]=r.des3={key:24,iv:8},r["des-ede3"]={key:24,iv:0},r["des-ede-cbc"]={key:16,iv:8},r["des-ede"]={key:16,iv:0};},{}],43:[function(t,e,r){"use strict";var n=t(20),i=t(520),o=t(44).Buffer;function a(t){var e,r=t.modulus.byteLength();do{e=new n(i(r));}while(e.cmp(t.modulus)>=0||!e.umod(t.prime1)||!e.umod(t.prime2));return e;}function s(t,e){var r=function(t){var e=a(t);return{blinder:e.toRed(n.mont(t.modulus)).redPow(new n(t.publicExponent)).fromRed(),unblinder:e.invm(t.modulus)};}(e),i=e.modulus.byteLength(),s=new n(t).mul(r.blinder).umod(e.modulus),f=s.toRed(n.mont(e.prime1)),u=s.toRed(n.mont(e.prime2)),c=e.coefficient,h=e.prime1,d=e.prime2,l=f.redPow(e.exponent1).fromRed(),p=u.redPow(e.exponent2).fromRed(),b=l.isub(p).imul(c).umod(h).imul(d);return p.iadd(b).imul(r.unblinder).umod(e.modulus).toArrayLike(o,"be",i);}s.getr=a,e.exports=s;},{20:20,44:44,520:520}],44:[function(t,e,r){/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var n=t(54),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r];}function a(t,e,r){return i(t,e,r);}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,r),r.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r);},a.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n;},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t);},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t);};},{54:54}],45:[function(t,e,r){"use strict";e.exports=t(46);},{46:46}],46:[function(t,e,r){e.exports={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}};},{}],47:[function(t,e,r){e.exports={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};},{}],48:[function(t,e,r){"use strict";var n=t(51).Buffer,i=t(397),o=t(532),a=t(474),s=t(49),f=t(50),u=t(46);function c(t){o.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hashType=e.hash,this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign;}function h(t){o.Writable.call(this);var e=u[t];if(!e)throw new Error("Unknown message digest");this._hash=i(e.hash),this._tag=e.id,this._signType=e.sign;}function d(t){return new c(t);}function l(t){return new h(t);}Object.keys(u).forEach(function(t){u[t].id=n.from(u[t].id,"hex"),u[t.toLowerCase()]=u[t];}),a(c,o.Writable),c.prototype._write=function(t,e,r){this._hash.update(t),r();},c.prototype.update=function(t,e){return this._hash.update("string"==typeof t?n.from(t,e):t),this;},c.prototype.sign=function(t,e){this.end();var r=this._hash.digest(),n=s(r,t,this._hashType,this._signType,this._tag);return e?n.toString(e):n;},a(h,o.Writable),h.prototype._write=function(t,e,r){this._hash.update(t),r();},h.prototype.update=function(t,e){return this._hash.update("string"==typeof t?n.from(t,e):t),this;},h.prototype.verify=function(t,e,r){var i="string"==typeof e?n.from(e,r):e;this.end();var o=this._hash.digest();return f(i,o,t,this._signType,this._tag);},e.exports={Sign:d,Verify:l,createSign:d,createVerify:l};},{397:397,46:46,474:474,49:49,50:50,51:51,532:532}],49:[function(t,e,r){"use strict";var n=t(51).Buffer,i=t(399),o=t(43),a=t(415).ec,s=t(20),f=t(496),u=t(47);function c(t,e,r,o){if((t=n.from(t.toArray())).length<e.byteLength()){var a=n.alloc(e.byteLength()-t.length);t=n.concat([a,t]);}var s=r.length,f=function(t,e){t=(t=h(t,e)).mod(e);var r=n.from(t.toArray());if(r.length<e.byteLength()){var i=n.alloc(e.byteLength()-r.length);r=n.concat([i,r]);}return r;}(r,e),u=n.alloc(s);u.fill(1);var c=n.alloc(s);return c=i(o,c).update(u).update(n.from([0])).update(t).update(f).digest(),u=i(o,c).update(u).digest(),{k:c=i(o,c).update(u).update(n.from([1])).update(t).update(f).digest(),v:u=i(o,c).update(u).digest()};}function h(t,e){var r=new s(t),n=(t.length<<3)-e.bitLength();return n>0&&r.ishrn(n),r;}function d(t,e,r){var o,a;do{for(o=n.alloc(0);8*o.length<t.bitLength();)e.v=i(r,e.k).update(e.v).digest(),o=n.concat([o,e.v]);a=h(o,t),e.k=i(r,e.k).update(e.v).update(n.from([0])).digest(),e.v=i(r,e.k).update(e.v).digest();}while(-1!==a.cmp(t));return a;}function l(t,e,r,n){return t.toRed(s.mont(r)).redPow(e).fromRed().mod(n);}e.exports=function(t,e,r,i,p){var b=f(e);if(b.curve){if("ecdsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong private key type");return function(t,e){var r=u[e.curve.join(".")];if(!r)throw new Error("unknown curve "+e.curve.join("."));var i=new a(r).keyFromPrivate(e.privateKey).sign(t);return n.from(i.toDER());}(t,b);}if("dsa"===b.type){if("dsa"!==i)throw new Error("wrong private key type");return function(t,e,r){var i,o=e.params.priv_key,a=e.params.p,f=e.params.q,u=e.params.g,p=new s(0),b=h(t,f).mod(f),v=!1,y=c(o,f,t,r);for(;!1===v;)p=l(u,i=d(f,y,r),a,f),0===(v=i.invm(f).imul(b.add(o.mul(p))).mod(f)).cmpn(0)&&(v=!1,p=new s(0));return function(t,e){t=t.toArray(),e=e.toArray(),128&t[0]&&(t=[0].concat(t));128&e[0]&&(e=[0].concat(e));var r=[48,t.length+e.length+4,2,t.length];return r=r.concat(t,[2,e.length],e),n.from(r);}(p,v);}(t,b,r);}if("rsa"!==i&&"ecdsa/rsa"!==i)throw new Error("wrong private key type");if(void 0!==e.padding&&1!==e.padding)throw new Error("illegal or unsupported padding mode");t=n.concat([p,t]);for(var v=b.modulus.byteLength(),y=[0,1];t.length+y.length+1<v;)y.push(255);y.push(0);for(var g=-1;++g<t.length;)y.push(t[g]);return o(y,b);},e.exports.getKey=c,e.exports.makeKey=d;},{20:20,399:399,415:415,43:43,47:47,496:496,51:51}],50:[function(t,e,r){"use strict";var n=t(51).Buffer,i=t(20),o=t(415).ec,a=t(496),s=t(47);function f(t,e){if(t.cmpn(0)<=0)throw new Error("invalid sig");if(t.cmp(e)>=0)throw new Error("invalid sig");}e.exports=function(t,e,r,u,c){var h=a(r);if("ec"===h.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=s[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var i=new o(n),a=r.data.subjectPrivateKey.data;return i.verify(e,t,a);}(t,e,h);}if("dsa"===h.type){if("dsa"!==u)throw new Error("wrong public key type");return function(t,e,r){var n=r.data.p,o=r.data.q,s=r.data.g,u=r.data.pub_key,c=a.signature.decode(t,"der"),h=c.s,d=c.r;f(h,o),f(d,o);var l=i.mont(n),p=h.invm(o);return 0===s.toRed(l).redPow(new i(e).mul(p).mod(o)).fromRed().mul(u.toRed(l).redPow(d.mul(p).mod(o)).fromRed()).mod(n).mod(o).cmp(d);}(t,e,h);}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");e=n.concat([c,e]);for(var d=h.modulus.byteLength(),l=[1],p=0;e.length+l.length+2<d;)l.push(255),p+=1;l.push(0);for(var b=-1;++b<e.length;)l.push(e[b]);l=n.from(l);var v=i.mont(h.modulus);t=(t=new i(t).toRed(v)).redPow(new i(h.publicExponent)),t=n.from(t.fromRed().toArray());var y=p<8?1:0;for(d=Math.min(t.length,l.length),t.length!==l.length&&(y=1),b=-1;++b<d;)y|=t[b]^l[b];return 0===y;};},{20:20,415:415,47:47,496:496,51:51}],51:[function(t,e,r){arguments[4][44][0].apply(r,arguments);},{44:44,54:54}],52:[function(t,e,r){"use strict";var n=t(537).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1;}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0;}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t;}(t),this.encoding){case"utf16le":this.text=f,this.end=u,e=4;break;case"utf8":this.fillLast=s,e=4;break;case"base64":this.text=c,this.end=h,e=3;break;default:return this.write=d,void(this.end=l);}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e);}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:-1;}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�".repeat(r);if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�".repeat(r+1);if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�".repeat(r+2);}}(this,t,e);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length));}function f(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1);}return r;}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1);}function u(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r);}return e;}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r));}function h(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e;}function d(t){return t.toString(this.encoding);}function l(t){return t&&t.length?this.write(t):"";}r.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0;}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||"";},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�".repeat(this.lastTotal-this.lastNeed):e;},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=a(e[n]);if(i>=0)return i>0&&(t.lastNeed=i-1),i;if(--n<r)return 0;if((i=a(e[n]))>=0)return i>0&&(t.lastNeed=i-2),i;if(--n<r)return 0;if((i=a(e[n]))>=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0;}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n);},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length;};},{537:537}],53:[function(t,e,r){(function(t){(function(){e.exports=function(e,r){for(var n=Math.min(e.length,r.length),i=new t(n),o=0;o<n;++o)i[o]=e[o]^r[o];return i;};}).call(this);}).call(this,t(54).Buffer);},{54:54}],54:[function(t,e,r){(function(e){(function(){/*!
10957
11026
  * The buffer module from node.js, for the browser.
@@ -10964,6 +11033,528 @@ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof
10964
11033
  },{}],42:[function(require,module,exports){
10965
11034
  'use strict';
10966
11035
 
11036
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11037
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
11038
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
11039
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11040
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
11041
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
11042
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11043
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11044
+ var util = require('./util');
11045
+ var LOG_PREFIX = "stats-collector";
11046
+
11047
+ // Collect and send WebRTC statistics periodically
11048
+ var StreamStatsCollector = function StreamStatsCollector(description, id, mediaConnection, wsConnection, logger) {
11049
+ var statCollector = {
11050
+ description: description,
11051
+ id: id,
11052
+ mediaConnection: mediaConnection,
11053
+ wsConnection: wsConnection,
11054
+ logger: getLogger(logger),
11055
+ headers: "",
11056
+ compression: "none",
11057
+ metricsBatch: null,
11058
+ timer: null,
11059
+ batchCount: 0,
11060
+ start: function () {
11061
+ var _start = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
11062
+ var error;
11063
+ return _regenerator().w(function (_context) {
11064
+ while (1) switch (_context.n) {
11065
+ case 0:
11066
+ error = "Can't collect WebRTC stats to send: ";
11067
+ if (statCollector.description.types) {
11068
+ _context.n = 1;
11069
+ break;
11070
+ }
11071
+ throw new Error(error + "no report types defined");
11072
+ case 1:
11073
+ if (statCollector.description.sampling) {
11074
+ _context.n = 2;
11075
+ break;
11076
+ }
11077
+ throw new Error(error + "no sampling interval defined");
11078
+ case 2:
11079
+ if (statCollector.description.batchSize) {
11080
+ _context.n = 3;
11081
+ break;
11082
+ }
11083
+ throw new Error(error + "no metrics batch size defined");
11084
+ case 3:
11085
+ if (statCollector.mediaConnection) {
11086
+ _context.n = 4;
11087
+ break;
11088
+ }
11089
+ throw new Error(error + "no media connection available");
11090
+ case 4:
11091
+ if (statCollector.wsConnection) {
11092
+ _context.n = 5;
11093
+ break;
11094
+ }
11095
+ throw new Error(error + "no websocket connection available");
11096
+ case 5:
11097
+ _context.n = 6;
11098
+ return statCollector.updateHeaders();
11099
+ case 6:
11100
+ _context.n = 7;
11101
+ return statCollector.updateCompression();
11102
+ case 7:
11103
+ statCollector.sendHeaders();
11104
+ if (statCollector.description.collect === "on") {
11105
+ statCollector.collect(true);
11106
+ }
11107
+ case 8:
11108
+ return _context.a(2);
11109
+ }
11110
+ }, _callee);
11111
+ }));
11112
+ function start() {
11113
+ return _start.apply(this, arguments);
11114
+ }
11115
+ return start;
11116
+ }(),
11117
+ collect: function collect(enable) {
11118
+ if (enable) {
11119
+ statCollector.startTimer();
11120
+ } else {
11121
+ statCollector.stopTimer();
11122
+ }
11123
+ },
11124
+ stop: function stop() {
11125
+ statCollector.stopTimer();
11126
+ statCollector.headers = "";
11127
+ },
11128
+ update: function () {
11129
+ var _update = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(description) {
11130
+ var _t;
11131
+ return _regenerator().w(function (_context2) {
11132
+ while (1) switch (_context2.n) {
11133
+ case 0:
11134
+ if (description) {
11135
+ _context2.n = 1;
11136
+ break;
11137
+ }
11138
+ if (!statCollector.logger) {
11139
+ _context2.n = 1;
11140
+ break;
11141
+ }
11142
+ statCollector.logger.error(LOG_PREFIX, "Can't update WebRTC metrics sending: no parameters passed");
11143
+ return _context2.a(2);
11144
+ case 1:
11145
+ if (!(description.types || description.compression)) {
11146
+ _context2.n = 4;
11147
+ break;
11148
+ }
11149
+ statCollector.stop();
11150
+ if (!description.types) {
11151
+ _context2.n = 2;
11152
+ break;
11153
+ }
11154
+ statCollector.description.types = description.types;
11155
+ _context2.n = 2;
11156
+ return statCollector.updateHeaders();
11157
+ case 2:
11158
+ if (!description.compression) {
11159
+ _context2.n = 3;
11160
+ break;
11161
+ }
11162
+ statCollector.description.compression = description.compression;
11163
+ _context2.n = 3;
11164
+ return statCollector.updateCompression();
11165
+ case 3:
11166
+ statCollector.sendHeaders();
11167
+ _context2.n = 5;
11168
+ break;
11169
+ case 4:
11170
+ statCollector.collect(false);
11171
+ case 5:
11172
+ if (description.batchSize) {
11173
+ statCollector.description.batchSize = description.batchSize;
11174
+ }
11175
+ if (description.sampling) {
11176
+ statCollector.description.sampling = description.sampling;
11177
+ }
11178
+ if (description.collect) {
11179
+ statCollector.description.collect = description.collect;
11180
+ }
11181
+ _t = statCollector.description.collect;
11182
+ _context2.n = _t === "on" ? 6 : _t === "off" ? 7 : 8;
11183
+ break;
11184
+ case 6:
11185
+ statCollector.collect(true);
11186
+ return _context2.a(3, 8);
11187
+ case 7:
11188
+ statCollector.collect(false);
11189
+ return _context2.a(3, 8);
11190
+ case 8:
11191
+ return _context2.a(2);
11192
+ }
11193
+ }, _callee2);
11194
+ }));
11195
+ function update(_x) {
11196
+ return _update.apply(this, arguments);
11197
+ }
11198
+ return update;
11199
+ }(),
11200
+ updateHeaders: function () {
11201
+ var _updateHeaders = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
11202
+ var stats;
11203
+ return _regenerator().w(function (_context3) {
11204
+ while (1) switch (_context3.n) {
11205
+ case 0:
11206
+ _context3.n = 1;
11207
+ return statCollector.mediaConnection.getWebRTCStats();
11208
+ case 1:
11209
+ stats = _context3.v;
11210
+ Object.keys(statCollector.description.types).forEach(function (type) {
11211
+ var typeDescriptor = statCollector.description.types[type];
11212
+ var metricsString = "";
11213
+ var contentFilters = null;
11214
+ if (typeDescriptor.metrics) {
11215
+ metricsString = typeDescriptor.metrics;
11216
+ }
11217
+ if (typeDescriptor.contains) {
11218
+ contentFilters = typeDescriptor.contains;
11219
+ }
11220
+ if (stats[type]) {
11221
+ stats[type].forEach(function (report) {
11222
+ statCollector.logger.debug(LOG_PREFIX, type + " report: " + JSON.stringify(report));
11223
+ if (contentFilters) {
11224
+ var filtersMatched = true;
11225
+ for (var filter in contentFilters) {
11226
+ statCollector.logger.debug(LOG_PREFIX, type + " filter by " + filter + ": " + JSON.stringify(contentFilters[filter]));
11227
+ var filterMatched = false;
11228
+ if (report[filter]) {
11229
+ var _iterator = _createForOfIteratorHelper(contentFilters[filter]),
11230
+ _step;
11231
+ try {
11232
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
11233
+ var value = _step.value;
11234
+ statCollector.logger.debug(LOG_PREFIX, filter + ": " + value + " <> " + report[filter]);
11235
+ if (report[filter] === value) {
11236
+ filterMatched = true;
11237
+ break;
11238
+ }
11239
+ }
11240
+ } catch (err) {
11241
+ _iterator.e(err);
11242
+ } finally {
11243
+ _iterator.f();
11244
+ }
11245
+ }
11246
+ filtersMatched = filtersMatched && filterMatched;
11247
+ if (!filterMatched) {
11248
+ break;
11249
+ }
11250
+ }
11251
+ if (filtersMatched) {
11252
+ statCollector.addHeaders(report, metricsString);
11253
+ }
11254
+ } else {
11255
+ statCollector.addHeaders(report, metricsString);
11256
+ }
11257
+ });
11258
+ } else {
11259
+ statCollector.logger.warn(LOG_PREFIX, "No report type found in RTC stats: '" + type + "'");
11260
+ }
11261
+ });
11262
+ case 2:
11263
+ return _context3.a(2);
11264
+ }
11265
+ }, _callee3);
11266
+ }));
11267
+ function updateHeaders() {
11268
+ return _updateHeaders.apply(this, arguments);
11269
+ }
11270
+ return updateHeaders;
11271
+ }(),
11272
+ addHeaders: function addHeaders(report, metricsString) {
11273
+ if (metricsString) {
11274
+ var metrics = metricsString.split(",");
11275
+ metrics.forEach(function (metric) {
11276
+ var metricFound = false;
11277
+ for (var _i = 0, _Object$keys = Object.keys(report); _i < _Object$keys.length; _i++) {
11278
+ var key = _Object$keys[_i];
11279
+ if (metric === key) {
11280
+ statCollector.headers = util.addFieldToCsvString(statCollector.headers, report.type + "." + report.id + "." + metric, ",");
11281
+ metricFound = true;
11282
+ break;
11283
+ }
11284
+ }
11285
+ if (!metricFound) {
11286
+ statCollector.logger.warn(LOG_PREFIX, "No metric found in RTC stats report '" + report.type + "': '" + metric + "'");
11287
+ }
11288
+ });
11289
+ }
11290
+ },
11291
+ updateCompression: function () {
11292
+ var _updateCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
11293
+ return _regenerator().w(function (_context4) {
11294
+ while (1) switch (_context4.n) {
11295
+ case 0:
11296
+ if (!statCollector.description.compression) {
11297
+ _context4.n = 3;
11298
+ break;
11299
+ }
11300
+ if (!(statCollector.description.compression.indexOf("gzip") >= 0)) {
11301
+ _context4.n = 2;
11302
+ break;
11303
+ }
11304
+ _context4.n = 1;
11305
+ return statCollector.checkForCompression("gzip");
11306
+ case 1:
11307
+ _context4.n = 3;
11308
+ break;
11309
+ case 2:
11310
+ if (!(statCollector.description.compression.indexOf("deflate") >= 0)) {
11311
+ _context4.n = 3;
11312
+ break;
11313
+ }
11314
+ _context4.n = 3;
11315
+ return statCollector.checkForCompression("deflate");
11316
+ case 3:
11317
+ return _context4.a(2);
11318
+ }
11319
+ }, _callee4);
11320
+ }));
11321
+ function updateCompression() {
11322
+ return _updateCompression.apply(this, arguments);
11323
+ }
11324
+ return updateCompression;
11325
+ }(),
11326
+ checkForCompression: function () {
11327
+ var _checkForCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(compression) {
11328
+ var _t2;
11329
+ return _regenerator().w(function (_context5) {
11330
+ while (1) switch (_context5.p = _context5.n) {
11331
+ case 0:
11332
+ _context5.p = 0;
11333
+ _context5.n = 1;
11334
+ return util.compress(compression, "test", false);
11335
+ case 1:
11336
+ statCollector.compression = compression;
11337
+ _context5.n = 3;
11338
+ break;
11339
+ case 2:
11340
+ _context5.p = 2;
11341
+ _t2 = _context5.v;
11342
+ statCollector.logger.warn(LOG_PREFIX, "Can't compress metrics data using " + compression + ": " + _t2);
11343
+ statCollector.compression = "none";
11344
+ case 3:
11345
+ return _context5.a(2);
11346
+ }
11347
+ }, _callee5, null, [[0, 2]]);
11348
+ }));
11349
+ function checkForCompression(_x2) {
11350
+ return _checkForCompression.apply(this, arguments);
11351
+ }
11352
+ return checkForCompression;
11353
+ }(),
11354
+ sendHeaders: function sendHeaders() {
11355
+ var data = {
11356
+ mediaSessionId: statCollector.id,
11357
+ compression: statCollector.compression,
11358
+ headers: statCollector.headers
11359
+ };
11360
+ statCollector.send("webRTCMetricsClientDescription", data);
11361
+ },
11362
+ send: function send(message, data) {
11363
+ statCollector.logger.debug(LOG_PREFIX, data);
11364
+ if (statCollector.wsConnection.readyState === WebSocket.OPEN) {
11365
+ statCollector.wsConnection.send(JSON.stringify({
11366
+ message: message,
11367
+ data: [data]
11368
+ }));
11369
+ }
11370
+ },
11371
+ startTimer: function startTimer() {
11372
+ if (!statCollector.timer && statCollector.headers) {
11373
+ statCollector.batchCount = statCollector.description.batchSize;
11374
+ statCollector.timer = setInterval(statCollector.collectMetrics, statCollector.description.sampling);
11375
+ }
11376
+ },
11377
+ stopTimer: function stopTimer() {
11378
+ if (statCollector.timer) {
11379
+ clearInterval(statCollector.timer);
11380
+ statCollector.timer = null;
11381
+ statCollector.metricsBatch = null;
11382
+ }
11383
+ },
11384
+ collectMetrics: function () {
11385
+ var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
11386
+ var stats, metrics;
11387
+ return _regenerator().w(function (_context6) {
11388
+ while (1) switch (_context6.n) {
11389
+ case 0:
11390
+ if (!statCollector.timer) {
11391
+ _context6.n = 2;
11392
+ break;
11393
+ }
11394
+ _context6.n = 1;
11395
+ return statCollector.mediaConnection.getWebRTCStats();
11396
+ case 1:
11397
+ stats = _context6.v;
11398
+ if (!statCollector.metricsBatch) {
11399
+ statCollector.metricsBatch = [];
11400
+ }
11401
+ metrics = [];
11402
+ statCollector.headers.split(",").forEach(function (header) {
11403
+ var components = header.split(".");
11404
+ var descriptor = {
11405
+ type: components[0],
11406
+ id: components[1],
11407
+ name: components[2]
11408
+ };
11409
+ var value = "undefined";
11410
+ if (stats[descriptor.type]) {
11411
+ var _iterator2 = _createForOfIteratorHelper(stats[descriptor.type]),
11412
+ _step2;
11413
+ try {
11414
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
11415
+ var report = _step2.value;
11416
+ if (report.id === descriptor.id) {
11417
+ value = report[descriptor.name];
11418
+ break;
11419
+ }
11420
+ }
11421
+ } catch (err) {
11422
+ _iterator2.e(err);
11423
+ } finally {
11424
+ _iterator2.f();
11425
+ }
11426
+ }
11427
+ metrics.push(value);
11428
+ });
11429
+ statCollector.metricsBatch.push(metrics);
11430
+ statCollector.batchCount--;
11431
+ if (!(statCollector.batchCount === 0)) {
11432
+ _context6.n = 2;
11433
+ break;
11434
+ }
11435
+ _context6.n = 2;
11436
+ return statCollector.sendMetrics();
11437
+ case 2:
11438
+ return _context6.a(2);
11439
+ }
11440
+ }, _callee6);
11441
+ }));
11442
+ function collectMetrics() {
11443
+ return _collectMetrics.apply(this, arguments);
11444
+ }
11445
+ return collectMetrics;
11446
+ }(),
11447
+ sendMetrics: function () {
11448
+ var _sendMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
11449
+ var previous, metricsToSend, metricsData, i, metricsString, j, valueString, previousString, separator, data, _t3;
11450
+ return _regenerator().w(function (_context7) {
11451
+ while (1) switch (_context7.p = _context7.n) {
11452
+ case 0:
11453
+ metricsToSend = [];
11454
+ for (i = 0; i < statCollector.metricsBatch.length; i++) {
11455
+ metricsString = "";
11456
+ for (j = 0; j < statCollector.metricsBatch[i].length; j++) {
11457
+ valueString = valueToString(statCollector.metricsBatch[i][j]);
11458
+ previousString = "";
11459
+ separator = ";";
11460
+ if (previous) {
11461
+ previousString = valueToString(previous[j]);
11462
+ }
11463
+ if (valueString === previousString) {
11464
+ valueString = "";
11465
+ }
11466
+ metricsString = util.addFieldToCsvString(metricsString, valueString, separator);
11467
+ }
11468
+ previous = statCollector.metricsBatch[i];
11469
+ metricsToSend.push(metricsString);
11470
+ }
11471
+ if (!(statCollector.compression !== "none")) {
11472
+ _context7.n = 5;
11473
+ break;
11474
+ }
11475
+ _context7.p = 1;
11476
+ _context7.n = 2;
11477
+ return util.compress(statCollector.compression, JSON.stringify(metricsToSend), true);
11478
+ case 2:
11479
+ metricsData = _context7.v;
11480
+ _context7.n = 4;
11481
+ break;
11482
+ case 3:
11483
+ _context7.p = 3;
11484
+ _t3 = _context7.v;
11485
+ statCollector.logger.warn(LOG_PREFIX, "Can't send metrics data using" + statCollector.compression + ": " + _t3);
11486
+ metricsData = null;
11487
+ case 4:
11488
+ _context7.n = 6;
11489
+ break;
11490
+ case 5:
11491
+ metricsData = metricsToSend;
11492
+ case 6:
11493
+ if (metricsData) {
11494
+ data = {
11495
+ mediaSessionId: statCollector.id,
11496
+ metrics: metricsData
11497
+ };
11498
+ statCollector.send("webRTCMetricsBatch", data);
11499
+ }
11500
+ statCollector.metricsBatch = null;
11501
+ statCollector.batchCount = statCollector.description.batchSize;
11502
+ case 7:
11503
+ return _context7.a(2);
11504
+ }
11505
+ }, _callee7, null, [[1, 3]]);
11506
+ }));
11507
+ function sendMetrics() {
11508
+ return _sendMetrics.apply(this, arguments);
11509
+ }
11510
+ return sendMetrics;
11511
+ }()
11512
+ };
11513
+ return statCollector;
11514
+ };
11515
+
11516
+ // Helper function to stringify a value
11517
+ var valueToString = function valueToString(value) {
11518
+ var valueString = "undefined";
11519
+ if (_typeof(value) === "object") {
11520
+ valueString = JSON.stringify(value);
11521
+ } else {
11522
+ valueString = value.toString();
11523
+ }
11524
+ return valueString;
11525
+ };
11526
+
11527
+ // Helper function to get logger object
11528
+ var getLogger = function getLogger(logger) {
11529
+ if (logger) {
11530
+ if (logger.info !== undefined && logger.warn !== undefined && logger.error !== undefined && logger.debug !== undefined) {
11531
+ return logger;
11532
+ }
11533
+ }
11534
+ return {
11535
+ info: function info() {},
11536
+ warn: function warn() {},
11537
+ error: function error() {},
11538
+ debug: function debug() {}
11539
+ };
11540
+ };
11541
+ module.exports = {
11542
+ StreamStatsCollector: StreamStatsCollector
11543
+ };
11544
+
11545
+ },{"./util":43}],43:[function(require,module,exports){
11546
+ 'use strict';
11547
+
11548
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
11549
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
11550
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
11551
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11552
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
11553
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
11554
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
11555
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11556
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11557
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
10967
11558
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10968
11559
  var isEmptyObject = function isEmptyObject(obj) {
10969
11560
  for (var name in obj) {
@@ -11443,6 +12034,70 @@ var setPublishingBitrate = function setPublishingBitrate(sdp, mediaConnection, m
11443
12034
  }
11444
12035
  return sdp;
11445
12036
  };
12037
+ var addFieldToCsvString = function addFieldToCsvString(csvString, field, separator) {
12038
+ if (field !== "" && field.indexOf(separator) >= 0) {
12039
+ field = '"' + field + '"';
12040
+ }
12041
+ if (csvString === "" && field !== "") {
12042
+ csvString = field;
12043
+ } else {
12044
+ csvString = csvString + separator + field;
12045
+ }
12046
+ return csvString;
12047
+ };
12048
+ var compress = /*#__PURE__*/function () {
12049
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(compression, data, base64) {
12050
+ var stream, compressedReadableStream, compressedResponse, blob, buffer, compressedBase64;
12051
+ return _regenerator().w(function (_context) {
12052
+ while (1) switch (_context.n) {
12053
+ case 0:
12054
+ if (!(typeof CompressionStream === "undefined")) {
12055
+ _context.n = 1;
12056
+ break;
12057
+ }
12058
+ throw new Error("Compression is not available");
12059
+ case 1:
12060
+ if (typeof data == "string") {
12061
+ stream = new Blob([data], {
12062
+ type: 'text/plain'
12063
+ }).stream();
12064
+ } else {
12065
+ // Assume blog
12066
+ stream = data.stream();
12067
+ }
12068
+
12069
+ // gzip stream
12070
+ compressedReadableStream = stream.pipeThrough(new CompressionStream(compression)); // create Response
12071
+ _context.n = 2;
12072
+ return new Response(compressedReadableStream);
12073
+ case 2:
12074
+ compressedResponse = _context.v;
12075
+ _context.n = 3;
12076
+ return compressedResponse.blob();
12077
+ case 3:
12078
+ blob = _context.v;
12079
+ if (!base64) {
12080
+ _context.n = 5;
12081
+ break;
12082
+ }
12083
+ _context.n = 4;
12084
+ return blob.arrayBuffer();
12085
+ case 4:
12086
+ buffer = _context.v;
12087
+ // convert ArrayBuffer to base64 encoded string
12088
+ compressedBase64 = btoa(String.fromCharCode.apply(String, _toConsumableArray(new Uint8Array(buffer))));
12089
+ return _context.a(2, compressedBase64);
12090
+ case 5:
12091
+ return _context.a(2, blob);
12092
+ case 6:
12093
+ return _context.a(2);
12094
+ }
12095
+ }, _callee);
12096
+ }));
12097
+ return function compress(_x, _x2, _x3) {
12098
+ return _ref.apply(this, arguments);
12099
+ };
12100
+ }();
11446
12101
  module.exports = {
11447
12102
  isEmptyObject: isEmptyObject,
11448
12103
  copyObjectToArray: copyObjectToArray,
@@ -11454,22 +12109,24 @@ module.exports = {
11454
12109
  stripCodecs: stripCodecs,
11455
12110
  getCurrentCodecAndSampleRate: getCurrentCodecAndSampleRate,
11456
12111
  isPromise: isPromise,
11457
- setPublishingBitrate: setPublishingBitrate
12112
+ setPublishingBitrate: setPublishingBitrate,
12113
+ addFieldToCsvString: addFieldToCsvString,
12114
+ compress: compress
11458
12115
  };
11459
12116
 
11460
- },{}],43:[function(require,module,exports){
12117
+ },{}],44:[function(require,module,exports){
11461
12118
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11462
12119
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
11463
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
11464
- function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
11465
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11466
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11467
12120
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
11468
12121
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11469
12122
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
11470
12123
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11471
12124
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11472
12125
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
12126
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
12127
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
12128
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
12129
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11473
12130
  -'use strict';
11474
12131
  var browserDetails = require('webrtc-adapter')["default"].browserDetails;
11475
12132
  var _require = require('uuid'),
@@ -11914,67 +12571,70 @@ var createConnection = function createConnection(options) {
11914
12571
  }
11915
12572
  return true;
11916
12573
  };
11917
- var getStat = function getStat(callbackFn, nativeStats) {
11918
- var browser = browserDetails.browser;
11919
- var result = {
11920
- outboundStream: {},
11921
- inboundStream: {},
11922
- otherStats: []
11923
- };
11924
- if (connection && validBrowsers.includes(browser)) {
11925
- if (nativeStats) {
11926
- return connection.getStats(null);
11927
- } else {
11928
- connection.getStats(null).then(function (stat) {
11929
- if (stat) {
11930
- stat.forEach(function (report) {
11931
- if (!report.isRemote) {
11932
- var mediaType = "";
11933
- if (report.type === 'outbound-rtp') {
11934
- mediaType = getReportMediaType(report);
11935
- fillStatObject(result.outboundStream, report, mediaType);
11936
- if (mediaType === 'video') {
11937
- getVideoSize(result.outboundStream[mediaType], report);
12574
+ var getStat = /*#__PURE__*/function () {
12575
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(callbackFn, nativeStats) {
12576
+ var result, rawStat;
12577
+ return _regenerator().w(function (_context) {
12578
+ while (1) switch (_context.n) {
12579
+ case 0:
12580
+ result = {
12581
+ outboundStream: {},
12582
+ inboundStream: {},
12583
+ otherStats: []
12584
+ };
12585
+ _context.n = 1;
12586
+ return getWebRTCStats();
12587
+ case 1:
12588
+ rawStat = _context.v;
12589
+ if (nativeStats) {
12590
+ callbackFn(rawStat);
12591
+ } else {
12592
+ if (rawStat["candidate-pair"]) {
12593
+ rawStat["candidate-pair"].forEach(function (report) {
12594
+ if (report.state === 'succeeded' && report.nominated) {
12595
+ if (report.availableIncomingBitrate) {
12596
+ result.otherStats.availableIncomingBitrate = report.availableIncomingBitrate;
12597
+ } else if (localVideo && report.availableOutgoingBitrate) {
12598
+ // availableOutgoingBitrate is defined for incoming stream too #WCS-4175
12599
+ result.otherStats.availableOutgoingBitrate = report.availableOutgoingBitrate;
12600
+ }
11938
12601
  }
11939
- } else if (report.type === 'inbound-rtp') {
11940
- mediaType = getReportMediaType(report);
11941
- fillStatObject(result.inboundStream, report, mediaType);
11942
- if (mediaType === 'video') {
11943
- getVideoSize(result.inboundStream[mediaType], report);
12602
+ });
12603
+ }
12604
+ if (rawStat["outbound-rtp"]) {
12605
+ rawStat["outbound-rtp"].forEach(function (report) {
12606
+ fillStatObject(result.outboundStream, report, report.kind);
12607
+ if (report.kind === "video") {
12608
+ getVideoSize(result.outboundStream[report.kind], report.type, report);
11944
12609
  }
11945
- } else if (report.type === 'candidate-pair' && report.state === 'succeeded' && report.nominated) {
11946
- if (report.availableIncomingBitrate) {
11947
- result.otherStats.availableIncomingBitrate = report.availableIncomingBitrate;
11948
- } else if (localVideo && report.availableOutgoingBitrate) {
11949
- // availableOutgoingBitrate is defined for incoming stream too #WCS-4175
11950
- result.otherStats.availableOutgoingBitrate = report.availableOutgoingBitrate;
12610
+ });
12611
+ }
12612
+ if (rawStat["inbound-rtp"]) {
12613
+ rawStat["inbound-rtp"].forEach(function (report) {
12614
+ fillStatObject(result.inboundStream, report, report.kind);
12615
+ if (report.kind === "video") {
12616
+ getVideoSize(result.inboundStream["video"], report.type, report);
11951
12617
  }
11952
- }
12618
+ });
11953
12619
  }
11954
- });
11955
- }
11956
- callbackFn(result);
11957
- });
11958
- }
11959
- }
11960
- };
11961
- var getReportMediaType = function getReportMediaType(report) {
11962
- // Since Safari 17 report.mediaType is undefined #WCS-3922
11963
- if (report.mediaType !== undefined) {
11964
- return report.mediaType;
11965
- } else if (report.kind !== undefined) {
11966
- return report.kind;
11967
- }
11968
- logger.warn(LOG_PREFIX, "No media type provided in WebRTC statistics");
11969
- return "media";
11970
- };
11971
- var getVideoSize = function getVideoSize(obj, report) {
12620
+ callbackFn(result);
12621
+ }
12622
+ case 2:
12623
+ return _context.a(2);
12624
+ }
12625
+ }, _callee);
12626
+ }));
12627
+ return function getStat(_x, _x2) {
12628
+ return _ref.apply(this, arguments);
12629
+ };
12630
+ }();
12631
+ var getVideoSize = function getVideoSize(obj, type, report) {
11972
12632
  var videoSize = {};
11973
- if (report.type == 'outbound-rtp') {
12633
+ if (type === 'outbound-rtp') {
11974
12634
  if (localVideo !== undefined && localVideo != null) {
11975
12635
  videoSize = localVideo.srcObject.getVideoTracks()[0].getSettings();
11976
12636
  }
11977
- } else if (report.type == 'inbound-rtp') {
12637
+ } else if (type === 'inbound-rtp') {
11978
12638
  if (remoteVideo !== undefined && remoteVideo != null) {
11979
12639
  videoSize.width = remoteVideo.videoWidth;
11980
12640
  videoSize.height = remoteVideo.videoHeight;
@@ -12377,25 +13037,25 @@ var createConnection = function createConnection(options) {
12377
13037
  return zoom;
12378
13038
  };
12379
13039
  var setZoom = /*#__PURE__*/function () {
12380
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(value) {
13040
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
12381
13041
  var _localVideo$srcObject3, _localVideo$srcObject4, track;
12382
- return _regenerator().w(function (_context) {
12383
- while (1) switch (_context.n) {
13042
+ return _regenerator().w(function (_context2) {
13043
+ while (1) switch (_context2.n) {
12384
13044
  case 0:
12385
13045
  if (!zoom) {
12386
- _context.n = 6;
13046
+ _context2.n = 6;
12387
13047
  break;
12388
13048
  }
12389
13049
  if (!(value >= zoom.min && value <= zoom.max)) {
12390
- _context.n = 4;
13050
+ _context2.n = 4;
12391
13051
  break;
12392
13052
  }
12393
13053
  if (!(localVideo && localVideo.srcObject)) {
12394
- _context.n = 2;
13054
+ _context2.n = 2;
12395
13055
  break;
12396
13056
  }
12397
13057
  _localVideo$srcObject3 = localVideo.srcObject.getVideoTracks(), _localVideo$srcObject4 = _slicedToArray(_localVideo$srcObject3, 1), track = _localVideo$srcObject4[0];
12398
- _context.n = 1;
13058
+ _context2.n = 1;
12399
13059
  return track.applyConstraints({
12400
13060
  advanced: [{
12401
13061
  zoom: value
@@ -12403,27 +13063,27 @@ var createConnection = function createConnection(options) {
12403
13063
  });
12404
13064
  case 1:
12405
13065
  zoom.value = value;
12406
- _context.n = 3;
13066
+ _context2.n = 3;
12407
13067
  break;
12408
13068
  case 2:
12409
13069
  logger.warn(LOG_PREFIX, "Can't set zoom value: no local video");
12410
13070
  case 3:
12411
- _context.n = 5;
13071
+ _context2.n = 5;
12412
13072
  break;
12413
13073
  case 4:
12414
13074
  logger.info(LOG_PREFIX, "Zoom value " + value + "is out of range: " + zoom.min + "-" + zoom.max);
12415
13075
  case 5:
12416
- _context.n = 7;
13076
+ _context2.n = 7;
12417
13077
  break;
12418
13078
  case 6:
12419
13079
  logger.info(LOG_PREFIX, "Zoom is not supported or zoom capabilities unknown yet");
12420
13080
  case 7:
12421
- return _context.a(2);
13081
+ return _context2.a(2);
12422
13082
  }
12423
- }, _callee);
13083
+ }, _callee2);
12424
13084
  }));
12425
- return function setZoom(_x) {
12426
- return _ref.apply(this, arguments);
13085
+ return function setZoom(_x3) {
13086
+ return _ref2.apply(this, arguments);
12427
13087
  };
12428
13088
  }();
12429
13089
  var getZoom = function getZoom() {
@@ -12432,6 +13092,32 @@ var createConnection = function createConnection(options) {
12432
13092
  }
12433
13093
  return -1;
12434
13094
  };
13095
+ var getWebRTCStats = function getWebRTCStats() {
13096
+ return new Promise(function (resolve, reject) {
13097
+ var browser = browserDetails.browser;
13098
+ if (connection && validBrowsers.includes(browser)) {
13099
+ connection.getStats(null).then(function (stats) {
13100
+ var statObject = {};
13101
+ if (stats) {
13102
+ stats.forEach(function (report) {
13103
+ if (report) {
13104
+ if (statObject[report.type] === undefined) {
13105
+ statObject[report.type] = [];
13106
+ }
13107
+ statObject[report.type].push(report);
13108
+ }
13109
+ });
13110
+ }
13111
+ resolve(statObject);
13112
+ })["catch"](function (reason) {
13113
+ logger.error(LOG_PREFIX, reason);
13114
+ reject(reason);
13115
+ });
13116
+ } else {
13117
+ reject(constants.ERROR_INFO.CAN_NOT_GET_STATS);
13118
+ }
13119
+ });
13120
+ };
12435
13121
  var exports = {};
12436
13122
  exports.state = state;
12437
13123
  exports.createOffer = createOffer;
@@ -12464,6 +13150,7 @@ var createConnection = function createConnection(options) {
12464
13150
  exports.getZoomCapabilities = getZoomCapabilities;
12465
13151
  exports.setZoom = setZoom;
12466
13152
  exports.getZoom = getZoom;
13153
+ exports.getWebRTCStats = getWebRTCStats;
12467
13154
  connections[id] = exports;
12468
13155
  resolve(exports);
12469
13156
  });
@@ -13237,5 +13924,5 @@ module.exports = {
13237
13924
  getVideoElement: getVideoElement
13238
13925
  };
13239
13926
 
13240
- },{"./constants":39,"./util":42,"uuid":8,"webrtc-adapter":23}]},{},[40])(40)
13927
+ },{"./constants":39,"./util":43,"uuid":8,"webrtc-adapter":23}]},{},[40])(40)
13241
13928
  });