@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.
- package/docTemplate/README.md +1 -1
- package/flashphoner-no-flash.js +768 -81
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +666 -9
- package/flashphoner-no-webrtc.min.js +2 -2
- package/flashphoner-no-wsplayer.js +767 -80
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-room-api-webrtc-only.js +768 -81
- package/flashphoner-room-api-webrtc-only.min.js +1 -1
- package/flashphoner-room-api.js +516 -60
- package/flashphoner-room-api.min.js +2 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +667 -10
- package/flashphoner-temasys-flash-websocket.js +667 -10
- package/flashphoner-temasys-flash-websocket.min.js +1 -1
- package/flashphoner-webrtc-only.js +767 -80
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +768 -81
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/constants.d.ts +6 -0
- package/src/constants.js +6 -0
- package/src/flashphoner-core.js +60 -5
- package/src/stats-collector.js +318 -0
- package/src/util.js +61 -1
- package/src/webrtc-media-provider.js +64 -48
package/flashphoner.js
CHANGED
|
@@ -8460,6 +8460,12 @@ var ERROR_INFO = Object.freeze({
|
|
|
8460
8460
|
* @memberOf Flashphoner.constants.ERROR_INFO
|
|
8461
8461
|
*/
|
|
8462
8462
|
CAN_NOT_SET_RESOLUTION: 'Cannot switch a published stream resolution',
|
|
8463
|
+
/**
|
|
8464
|
+
* Error if cannot get peer connection stats
|
|
8465
|
+
* @event CAN_NOT_GET_STATS
|
|
8466
|
+
* @memberOf Flashphoner.constants.ERROR_INFO
|
|
8467
|
+
*/
|
|
8468
|
+
CAN_NOT_GET_STATS: 'Cannot get PeerConnection stats',
|
|
8463
8469
|
/**
|
|
8464
8470
|
* Local browser error detected
|
|
8465
8471
|
* @event LOCAL_ERROR
|
|
@@ -8659,6 +8665,12 @@ module.exports = {
|
|
|
8659
8665
|
},{}],41:[function(require,module,exports){
|
|
8660
8666
|
'use strict';
|
|
8661
8667
|
|
|
8668
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8669
|
+
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."); }
|
|
8670
|
+
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; } }
|
|
8671
|
+
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; }
|
|
8672
|
+
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; } }
|
|
8673
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
8662
8674
|
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); }
|
|
8663
8675
|
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 }; })(); }
|
|
8664
8676
|
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); }
|
|
@@ -8670,6 +8682,7 @@ var constants = require("./constants");
|
|
|
8670
8682
|
var util = require('./util');
|
|
8671
8683
|
var LoggerObject = require('./util').logger;
|
|
8672
8684
|
var clientInfo = require('./client-info');
|
|
8685
|
+
var StatsCollector = require('./stats-collector');
|
|
8673
8686
|
var _Promise = require('promise-polyfill');
|
|
8674
8687
|
var KalmanFilter = require('kalmanjs');
|
|
8675
8688
|
var browserDetails = require('webrtc-adapter')["default"].browserDetails;
|
|
@@ -9213,6 +9226,9 @@ var createSession = function createSession(options) {
|
|
|
9213
9226
|
//callbacks added using session.on()
|
|
9214
9227
|
var callbacks = {};
|
|
9215
9228
|
var wsConnection;
|
|
9229
|
+
|
|
9230
|
+
// WebRTC metrics sending description
|
|
9231
|
+
var webRTCMetricsServerDescription;
|
|
9216
9232
|
if (lbUrl) {
|
|
9217
9233
|
requestURL(lbUrl);
|
|
9218
9234
|
} else {
|
|
@@ -9315,6 +9331,7 @@ var createSession = function createSession(options) {
|
|
|
9315
9331
|
case 'getUserData':
|
|
9316
9332
|
authToken = obj.authToken;
|
|
9317
9333
|
cConfig = obj;
|
|
9334
|
+
webRTCMetricsServerDescription = obj.webRTCMetricsServerDescription;
|
|
9318
9335
|
onSessionStatusChange(SESSION_STATUS.ESTABLISHED, obj);
|
|
9319
9336
|
break;
|
|
9320
9337
|
case 'setRemoteSDP':
|
|
@@ -9419,6 +9436,37 @@ var createSession = function createSession(options) {
|
|
|
9419
9436
|
streamRefreshHandlers[obj.mediaSessionId](obj);
|
|
9420
9437
|
}
|
|
9421
9438
|
break;
|
|
9439
|
+
case "webRTCMetricsDescriptionUpdate":
|
|
9440
|
+
if (obj.ids) {
|
|
9441
|
+
obj.ids.forEach(function (id) {
|
|
9442
|
+
if (streamRefreshHandlers[id]) {
|
|
9443
|
+
streamRefreshHandlers[id](obj);
|
|
9444
|
+
}
|
|
9445
|
+
});
|
|
9446
|
+
} else {
|
|
9447
|
+
if (obj.compression) {
|
|
9448
|
+
webRTCMetricsServerDescription.compression = obj.compression;
|
|
9449
|
+
}
|
|
9450
|
+
if (obj.batchSize) {
|
|
9451
|
+
webRTCMetricsServerDescription.batchSize = obj.batchSize;
|
|
9452
|
+
}
|
|
9453
|
+
if (obj.sampling) {
|
|
9454
|
+
webRTCMetricsServerDescription.sampling = obj.sampling;
|
|
9455
|
+
}
|
|
9456
|
+
if (obj.types) {
|
|
9457
|
+
webRTCMetricsServerDescription.types = obj.types;
|
|
9458
|
+
}
|
|
9459
|
+
if (obj.collect) {
|
|
9460
|
+
webRTCMetricsServerDescription.collect = obj.collect;
|
|
9461
|
+
}
|
|
9462
|
+
for (var _i = 0, _Object$entries = Object.entries(streamRefreshHandlers); _i < _Object$entries.length; _i++) {
|
|
9463
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
9464
|
+
_id = _Object$entries$_i[0],
|
|
9465
|
+
handler = _Object$entries$_i[1];
|
|
9466
|
+
handler(obj);
|
|
9467
|
+
}
|
|
9468
|
+
}
|
|
9469
|
+
break;
|
|
9422
9470
|
default:
|
|
9423
9471
|
logger.info(LOG_PREFIX, "Unknown server message " + data.message);
|
|
9424
9472
|
}
|
|
@@ -9430,10 +9478,12 @@ var createSession = function createSession(options) {
|
|
|
9430
9478
|
|
|
9431
9479
|
//WebSocket send helper
|
|
9432
9480
|
function send(message, data) {
|
|
9433
|
-
wsConnection.
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9481
|
+
if (wsConnection.readyState === WebSocket.OPEN) {
|
|
9482
|
+
wsConnection.send(JSON.stringify({
|
|
9483
|
+
message: message,
|
|
9484
|
+
data: [data]
|
|
9485
|
+
}));
|
|
9486
|
+
}
|
|
9437
9487
|
}
|
|
9438
9488
|
|
|
9439
9489
|
//Session status update helper
|
|
@@ -10464,6 +10514,7 @@ var createSession = function createSession(options) {
|
|
|
10464
10514
|
var videoState_;
|
|
10465
10515
|
var connectionQuality;
|
|
10466
10516
|
var videoBytes = 0;
|
|
10517
|
+
var statsCollector = null;
|
|
10467
10518
|
|
|
10468
10519
|
/**
|
|
10469
10520
|
* Represents media stream.
|
|
@@ -10496,7 +10547,7 @@ var createSession = function createSession(options) {
|
|
|
10496
10547
|
mediaConnection.setRemoteSdp(_sdp).then(function () {});
|
|
10497
10548
|
return;
|
|
10498
10549
|
}
|
|
10499
|
-
if (streamInfo.available
|
|
10550
|
+
if (streamInfo.available !== undefined) {
|
|
10500
10551
|
for (var i = 0; i < availableCallbacks.length; i++) {
|
|
10501
10552
|
info_ = streamInfo.reason;
|
|
10502
10553
|
if (streamInfo.available == "true") {
|
|
@@ -10542,10 +10593,28 @@ var createSession = function createSession(options) {
|
|
|
10542
10593
|
if (mediaConnection) {
|
|
10543
10594
|
mediaConnection.close(cacheLocalResources);
|
|
10544
10595
|
}
|
|
10596
|
+
if (statsCollector) {
|
|
10597
|
+
statsCollector.stop();
|
|
10598
|
+
statsCollector = null;
|
|
10599
|
+
}
|
|
10545
10600
|
}
|
|
10546
10601
|
if (record_ && typeof streamInfo.recordName !== 'undefined') {
|
|
10547
10602
|
recordFileName = streamInfo.recordName;
|
|
10548
10603
|
}
|
|
10604
|
+
|
|
10605
|
+
// Set up metrics collection
|
|
10606
|
+
if (event === STREAM_STATUS.PUBLISHING || event === STREAM_STATUS.PLAYING) {
|
|
10607
|
+
if (webRTCMetricsServerDescription && !statsCollector) {
|
|
10608
|
+
statsCollector = StatsCollector.StreamStatsCollector(webRTCMetricsServerDescription, id_, mediaConnection, wsConnection, logger);
|
|
10609
|
+
statsCollector.start();
|
|
10610
|
+
}
|
|
10611
|
+
}
|
|
10612
|
+
|
|
10613
|
+
// Pause or resume metrics collection
|
|
10614
|
+
if (!streamInfo.status && streamInfo.collect !== undefined && statsCollector) {
|
|
10615
|
+
statsCollector.update(streamInfo);
|
|
10616
|
+
}
|
|
10617
|
+
|
|
10549
10618
|
//fire stream event
|
|
10550
10619
|
if (callbacks[event]) {
|
|
10551
10620
|
callbacks[event](stream);
|
|
@@ -11779,7 +11848,7 @@ module.exports = {
|
|
|
11779
11848
|
Browser: util.Browser
|
|
11780
11849
|
};
|
|
11781
11850
|
|
|
11782
|
-
},{"./client-info":39,"./constants":40,"./media-source-media-provider":42,"./temasys-media-provider":1,"./util":
|
|
11851
|
+
},{"./client-info":39,"./constants":40,"./media-source-media-provider":42,"./stats-collector":43,"./temasys-media-provider":1,"./util":44,"./webrtc-media-provider":45,"./websocket-media-provider":46,"kalmanjs":2,"promise-polyfill":4,"uuid":8,"webrtc-adapter":23}],42:[function(require,module,exports){
|
|
11783
11852
|
(function (global){(function (){
|
|
11784
11853
|
!function(t){if("object"==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(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.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(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<,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.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(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<,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)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&&(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(){/*!
|
|
11785
11854
|
* The buffer module from node.js, for the browser.
|
|
@@ -11792,6 +11861,528 @@ module.exports = {
|
|
|
11792
11861
|
},{}],43:[function(require,module,exports){
|
|
11793
11862
|
'use strict';
|
|
11794
11863
|
|
|
11864
|
+
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); }
|
|
11865
|
+
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; } } }; }
|
|
11866
|
+
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; } }
|
|
11867
|
+
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; }
|
|
11868
|
+
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 }; })(); }
|
|
11869
|
+
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); }
|
|
11870
|
+
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); }
|
|
11871
|
+
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); }); }; }
|
|
11872
|
+
var util = require('./util');
|
|
11873
|
+
var LOG_PREFIX = "stats-collector";
|
|
11874
|
+
|
|
11875
|
+
// Collect and send WebRTC statistics periodically
|
|
11876
|
+
var StreamStatsCollector = function StreamStatsCollector(description, id, mediaConnection, wsConnection, logger) {
|
|
11877
|
+
var statCollector = {
|
|
11878
|
+
description: description,
|
|
11879
|
+
id: id,
|
|
11880
|
+
mediaConnection: mediaConnection,
|
|
11881
|
+
wsConnection: wsConnection,
|
|
11882
|
+
logger: getLogger(logger),
|
|
11883
|
+
headers: "",
|
|
11884
|
+
compression: "none",
|
|
11885
|
+
metricsBatch: null,
|
|
11886
|
+
timer: null,
|
|
11887
|
+
batchCount: 0,
|
|
11888
|
+
start: function () {
|
|
11889
|
+
var _start = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
11890
|
+
var error;
|
|
11891
|
+
return _regenerator().w(function (_context) {
|
|
11892
|
+
while (1) switch (_context.n) {
|
|
11893
|
+
case 0:
|
|
11894
|
+
error = "Can't collect WebRTC stats to send: ";
|
|
11895
|
+
if (statCollector.description.types) {
|
|
11896
|
+
_context.n = 1;
|
|
11897
|
+
break;
|
|
11898
|
+
}
|
|
11899
|
+
throw new Error(error + "no report types defined");
|
|
11900
|
+
case 1:
|
|
11901
|
+
if (statCollector.description.sampling) {
|
|
11902
|
+
_context.n = 2;
|
|
11903
|
+
break;
|
|
11904
|
+
}
|
|
11905
|
+
throw new Error(error + "no sampling interval defined");
|
|
11906
|
+
case 2:
|
|
11907
|
+
if (statCollector.description.batchSize) {
|
|
11908
|
+
_context.n = 3;
|
|
11909
|
+
break;
|
|
11910
|
+
}
|
|
11911
|
+
throw new Error(error + "no metrics batch size defined");
|
|
11912
|
+
case 3:
|
|
11913
|
+
if (statCollector.mediaConnection) {
|
|
11914
|
+
_context.n = 4;
|
|
11915
|
+
break;
|
|
11916
|
+
}
|
|
11917
|
+
throw new Error(error + "no media connection available");
|
|
11918
|
+
case 4:
|
|
11919
|
+
if (statCollector.wsConnection) {
|
|
11920
|
+
_context.n = 5;
|
|
11921
|
+
break;
|
|
11922
|
+
}
|
|
11923
|
+
throw new Error(error + "no websocket connection available");
|
|
11924
|
+
case 5:
|
|
11925
|
+
_context.n = 6;
|
|
11926
|
+
return statCollector.updateHeaders();
|
|
11927
|
+
case 6:
|
|
11928
|
+
_context.n = 7;
|
|
11929
|
+
return statCollector.updateCompression();
|
|
11930
|
+
case 7:
|
|
11931
|
+
statCollector.sendHeaders();
|
|
11932
|
+
if (statCollector.description.collect === "on") {
|
|
11933
|
+
statCollector.collect(true);
|
|
11934
|
+
}
|
|
11935
|
+
case 8:
|
|
11936
|
+
return _context.a(2);
|
|
11937
|
+
}
|
|
11938
|
+
}, _callee);
|
|
11939
|
+
}));
|
|
11940
|
+
function start() {
|
|
11941
|
+
return _start.apply(this, arguments);
|
|
11942
|
+
}
|
|
11943
|
+
return start;
|
|
11944
|
+
}(),
|
|
11945
|
+
collect: function collect(enable) {
|
|
11946
|
+
if (enable) {
|
|
11947
|
+
statCollector.startTimer();
|
|
11948
|
+
} else {
|
|
11949
|
+
statCollector.stopTimer();
|
|
11950
|
+
}
|
|
11951
|
+
},
|
|
11952
|
+
stop: function stop() {
|
|
11953
|
+
statCollector.stopTimer();
|
|
11954
|
+
statCollector.headers = "";
|
|
11955
|
+
},
|
|
11956
|
+
update: function () {
|
|
11957
|
+
var _update = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(description) {
|
|
11958
|
+
var _t;
|
|
11959
|
+
return _regenerator().w(function (_context2) {
|
|
11960
|
+
while (1) switch (_context2.n) {
|
|
11961
|
+
case 0:
|
|
11962
|
+
if (description) {
|
|
11963
|
+
_context2.n = 1;
|
|
11964
|
+
break;
|
|
11965
|
+
}
|
|
11966
|
+
if (!statCollector.logger) {
|
|
11967
|
+
_context2.n = 1;
|
|
11968
|
+
break;
|
|
11969
|
+
}
|
|
11970
|
+
statCollector.logger.error(LOG_PREFIX, "Can't update WebRTC metrics sending: no parameters passed");
|
|
11971
|
+
return _context2.a(2);
|
|
11972
|
+
case 1:
|
|
11973
|
+
if (!(description.types || description.compression)) {
|
|
11974
|
+
_context2.n = 4;
|
|
11975
|
+
break;
|
|
11976
|
+
}
|
|
11977
|
+
statCollector.stop();
|
|
11978
|
+
if (!description.types) {
|
|
11979
|
+
_context2.n = 2;
|
|
11980
|
+
break;
|
|
11981
|
+
}
|
|
11982
|
+
statCollector.description.types = description.types;
|
|
11983
|
+
_context2.n = 2;
|
|
11984
|
+
return statCollector.updateHeaders();
|
|
11985
|
+
case 2:
|
|
11986
|
+
if (!description.compression) {
|
|
11987
|
+
_context2.n = 3;
|
|
11988
|
+
break;
|
|
11989
|
+
}
|
|
11990
|
+
statCollector.description.compression = description.compression;
|
|
11991
|
+
_context2.n = 3;
|
|
11992
|
+
return statCollector.updateCompression();
|
|
11993
|
+
case 3:
|
|
11994
|
+
statCollector.sendHeaders();
|
|
11995
|
+
_context2.n = 5;
|
|
11996
|
+
break;
|
|
11997
|
+
case 4:
|
|
11998
|
+
statCollector.collect(false);
|
|
11999
|
+
case 5:
|
|
12000
|
+
if (description.batchSize) {
|
|
12001
|
+
statCollector.description.batchSize = description.batchSize;
|
|
12002
|
+
}
|
|
12003
|
+
if (description.sampling) {
|
|
12004
|
+
statCollector.description.sampling = description.sampling;
|
|
12005
|
+
}
|
|
12006
|
+
if (description.collect) {
|
|
12007
|
+
statCollector.description.collect = description.collect;
|
|
12008
|
+
}
|
|
12009
|
+
_t = statCollector.description.collect;
|
|
12010
|
+
_context2.n = _t === "on" ? 6 : _t === "off" ? 7 : 8;
|
|
12011
|
+
break;
|
|
12012
|
+
case 6:
|
|
12013
|
+
statCollector.collect(true);
|
|
12014
|
+
return _context2.a(3, 8);
|
|
12015
|
+
case 7:
|
|
12016
|
+
statCollector.collect(false);
|
|
12017
|
+
return _context2.a(3, 8);
|
|
12018
|
+
case 8:
|
|
12019
|
+
return _context2.a(2);
|
|
12020
|
+
}
|
|
12021
|
+
}, _callee2);
|
|
12022
|
+
}));
|
|
12023
|
+
function update(_x) {
|
|
12024
|
+
return _update.apply(this, arguments);
|
|
12025
|
+
}
|
|
12026
|
+
return update;
|
|
12027
|
+
}(),
|
|
12028
|
+
updateHeaders: function () {
|
|
12029
|
+
var _updateHeaders = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
12030
|
+
var stats;
|
|
12031
|
+
return _regenerator().w(function (_context3) {
|
|
12032
|
+
while (1) switch (_context3.n) {
|
|
12033
|
+
case 0:
|
|
12034
|
+
_context3.n = 1;
|
|
12035
|
+
return statCollector.mediaConnection.getWebRTCStats();
|
|
12036
|
+
case 1:
|
|
12037
|
+
stats = _context3.v;
|
|
12038
|
+
Object.keys(statCollector.description.types).forEach(function (type) {
|
|
12039
|
+
var typeDescriptor = statCollector.description.types[type];
|
|
12040
|
+
var metricsString = "";
|
|
12041
|
+
var contentFilters = null;
|
|
12042
|
+
if (typeDescriptor.metrics) {
|
|
12043
|
+
metricsString = typeDescriptor.metrics;
|
|
12044
|
+
}
|
|
12045
|
+
if (typeDescriptor.contains) {
|
|
12046
|
+
contentFilters = typeDescriptor.contains;
|
|
12047
|
+
}
|
|
12048
|
+
if (stats[type]) {
|
|
12049
|
+
stats[type].forEach(function (report) {
|
|
12050
|
+
statCollector.logger.debug(LOG_PREFIX, type + " report: " + JSON.stringify(report));
|
|
12051
|
+
if (contentFilters) {
|
|
12052
|
+
var filtersMatched = true;
|
|
12053
|
+
for (var filter in contentFilters) {
|
|
12054
|
+
statCollector.logger.debug(LOG_PREFIX, type + " filter by " + filter + ": " + JSON.stringify(contentFilters[filter]));
|
|
12055
|
+
var filterMatched = false;
|
|
12056
|
+
if (report[filter]) {
|
|
12057
|
+
var _iterator = _createForOfIteratorHelper(contentFilters[filter]),
|
|
12058
|
+
_step;
|
|
12059
|
+
try {
|
|
12060
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
12061
|
+
var value = _step.value;
|
|
12062
|
+
statCollector.logger.debug(LOG_PREFIX, filter + ": " + value + " <> " + report[filter]);
|
|
12063
|
+
if (report[filter] === value) {
|
|
12064
|
+
filterMatched = true;
|
|
12065
|
+
break;
|
|
12066
|
+
}
|
|
12067
|
+
}
|
|
12068
|
+
} catch (err) {
|
|
12069
|
+
_iterator.e(err);
|
|
12070
|
+
} finally {
|
|
12071
|
+
_iterator.f();
|
|
12072
|
+
}
|
|
12073
|
+
}
|
|
12074
|
+
filtersMatched = filtersMatched && filterMatched;
|
|
12075
|
+
if (!filterMatched) {
|
|
12076
|
+
break;
|
|
12077
|
+
}
|
|
12078
|
+
}
|
|
12079
|
+
if (filtersMatched) {
|
|
12080
|
+
statCollector.addHeaders(report, metricsString);
|
|
12081
|
+
}
|
|
12082
|
+
} else {
|
|
12083
|
+
statCollector.addHeaders(report, metricsString);
|
|
12084
|
+
}
|
|
12085
|
+
});
|
|
12086
|
+
} else {
|
|
12087
|
+
statCollector.logger.warn(LOG_PREFIX, "No report type found in RTC stats: '" + type + "'");
|
|
12088
|
+
}
|
|
12089
|
+
});
|
|
12090
|
+
case 2:
|
|
12091
|
+
return _context3.a(2);
|
|
12092
|
+
}
|
|
12093
|
+
}, _callee3);
|
|
12094
|
+
}));
|
|
12095
|
+
function updateHeaders() {
|
|
12096
|
+
return _updateHeaders.apply(this, arguments);
|
|
12097
|
+
}
|
|
12098
|
+
return updateHeaders;
|
|
12099
|
+
}(),
|
|
12100
|
+
addHeaders: function addHeaders(report, metricsString) {
|
|
12101
|
+
if (metricsString) {
|
|
12102
|
+
var metrics = metricsString.split(",");
|
|
12103
|
+
metrics.forEach(function (metric) {
|
|
12104
|
+
var metricFound = false;
|
|
12105
|
+
for (var _i = 0, _Object$keys = Object.keys(report); _i < _Object$keys.length; _i++) {
|
|
12106
|
+
var key = _Object$keys[_i];
|
|
12107
|
+
if (metric === key) {
|
|
12108
|
+
statCollector.headers = util.addFieldToCsvString(statCollector.headers, report.type + "." + report.id + "." + metric, ",");
|
|
12109
|
+
metricFound = true;
|
|
12110
|
+
break;
|
|
12111
|
+
}
|
|
12112
|
+
}
|
|
12113
|
+
if (!metricFound) {
|
|
12114
|
+
statCollector.logger.warn(LOG_PREFIX, "No metric found in RTC stats report '" + report.type + "': '" + metric + "'");
|
|
12115
|
+
}
|
|
12116
|
+
});
|
|
12117
|
+
}
|
|
12118
|
+
},
|
|
12119
|
+
updateCompression: function () {
|
|
12120
|
+
var _updateCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
12121
|
+
return _regenerator().w(function (_context4) {
|
|
12122
|
+
while (1) switch (_context4.n) {
|
|
12123
|
+
case 0:
|
|
12124
|
+
if (!statCollector.description.compression) {
|
|
12125
|
+
_context4.n = 3;
|
|
12126
|
+
break;
|
|
12127
|
+
}
|
|
12128
|
+
if (!(statCollector.description.compression.indexOf("gzip") >= 0)) {
|
|
12129
|
+
_context4.n = 2;
|
|
12130
|
+
break;
|
|
12131
|
+
}
|
|
12132
|
+
_context4.n = 1;
|
|
12133
|
+
return statCollector.checkForCompression("gzip");
|
|
12134
|
+
case 1:
|
|
12135
|
+
_context4.n = 3;
|
|
12136
|
+
break;
|
|
12137
|
+
case 2:
|
|
12138
|
+
if (!(statCollector.description.compression.indexOf("deflate") >= 0)) {
|
|
12139
|
+
_context4.n = 3;
|
|
12140
|
+
break;
|
|
12141
|
+
}
|
|
12142
|
+
_context4.n = 3;
|
|
12143
|
+
return statCollector.checkForCompression("deflate");
|
|
12144
|
+
case 3:
|
|
12145
|
+
return _context4.a(2);
|
|
12146
|
+
}
|
|
12147
|
+
}, _callee4);
|
|
12148
|
+
}));
|
|
12149
|
+
function updateCompression() {
|
|
12150
|
+
return _updateCompression.apply(this, arguments);
|
|
12151
|
+
}
|
|
12152
|
+
return updateCompression;
|
|
12153
|
+
}(),
|
|
12154
|
+
checkForCompression: function () {
|
|
12155
|
+
var _checkForCompression = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(compression) {
|
|
12156
|
+
var _t2;
|
|
12157
|
+
return _regenerator().w(function (_context5) {
|
|
12158
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
12159
|
+
case 0:
|
|
12160
|
+
_context5.p = 0;
|
|
12161
|
+
_context5.n = 1;
|
|
12162
|
+
return util.compress(compression, "test", false);
|
|
12163
|
+
case 1:
|
|
12164
|
+
statCollector.compression = compression;
|
|
12165
|
+
_context5.n = 3;
|
|
12166
|
+
break;
|
|
12167
|
+
case 2:
|
|
12168
|
+
_context5.p = 2;
|
|
12169
|
+
_t2 = _context5.v;
|
|
12170
|
+
statCollector.logger.warn(LOG_PREFIX, "Can't compress metrics data using " + compression + ": " + _t2);
|
|
12171
|
+
statCollector.compression = "none";
|
|
12172
|
+
case 3:
|
|
12173
|
+
return _context5.a(2);
|
|
12174
|
+
}
|
|
12175
|
+
}, _callee5, null, [[0, 2]]);
|
|
12176
|
+
}));
|
|
12177
|
+
function checkForCompression(_x2) {
|
|
12178
|
+
return _checkForCompression.apply(this, arguments);
|
|
12179
|
+
}
|
|
12180
|
+
return checkForCompression;
|
|
12181
|
+
}(),
|
|
12182
|
+
sendHeaders: function sendHeaders() {
|
|
12183
|
+
var data = {
|
|
12184
|
+
mediaSessionId: statCollector.id,
|
|
12185
|
+
compression: statCollector.compression,
|
|
12186
|
+
headers: statCollector.headers
|
|
12187
|
+
};
|
|
12188
|
+
statCollector.send("webRTCMetricsClientDescription", data);
|
|
12189
|
+
},
|
|
12190
|
+
send: function send(message, data) {
|
|
12191
|
+
statCollector.logger.debug(LOG_PREFIX, data);
|
|
12192
|
+
if (statCollector.wsConnection.readyState === WebSocket.OPEN) {
|
|
12193
|
+
statCollector.wsConnection.send(JSON.stringify({
|
|
12194
|
+
message: message,
|
|
12195
|
+
data: [data]
|
|
12196
|
+
}));
|
|
12197
|
+
}
|
|
12198
|
+
},
|
|
12199
|
+
startTimer: function startTimer() {
|
|
12200
|
+
if (!statCollector.timer && statCollector.headers) {
|
|
12201
|
+
statCollector.batchCount = statCollector.description.batchSize;
|
|
12202
|
+
statCollector.timer = setInterval(statCollector.collectMetrics, statCollector.description.sampling);
|
|
12203
|
+
}
|
|
12204
|
+
},
|
|
12205
|
+
stopTimer: function stopTimer() {
|
|
12206
|
+
if (statCollector.timer) {
|
|
12207
|
+
clearInterval(statCollector.timer);
|
|
12208
|
+
statCollector.timer = null;
|
|
12209
|
+
statCollector.metricsBatch = null;
|
|
12210
|
+
}
|
|
12211
|
+
},
|
|
12212
|
+
collectMetrics: function () {
|
|
12213
|
+
var _collectMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
12214
|
+
var stats, metrics;
|
|
12215
|
+
return _regenerator().w(function (_context6) {
|
|
12216
|
+
while (1) switch (_context6.n) {
|
|
12217
|
+
case 0:
|
|
12218
|
+
if (!statCollector.timer) {
|
|
12219
|
+
_context6.n = 2;
|
|
12220
|
+
break;
|
|
12221
|
+
}
|
|
12222
|
+
_context6.n = 1;
|
|
12223
|
+
return statCollector.mediaConnection.getWebRTCStats();
|
|
12224
|
+
case 1:
|
|
12225
|
+
stats = _context6.v;
|
|
12226
|
+
if (!statCollector.metricsBatch) {
|
|
12227
|
+
statCollector.metricsBatch = [];
|
|
12228
|
+
}
|
|
12229
|
+
metrics = [];
|
|
12230
|
+
statCollector.headers.split(",").forEach(function (header) {
|
|
12231
|
+
var components = header.split(".");
|
|
12232
|
+
var descriptor = {
|
|
12233
|
+
type: components[0],
|
|
12234
|
+
id: components[1],
|
|
12235
|
+
name: components[2]
|
|
12236
|
+
};
|
|
12237
|
+
var value = "undefined";
|
|
12238
|
+
if (stats[descriptor.type]) {
|
|
12239
|
+
var _iterator2 = _createForOfIteratorHelper(stats[descriptor.type]),
|
|
12240
|
+
_step2;
|
|
12241
|
+
try {
|
|
12242
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
12243
|
+
var report = _step2.value;
|
|
12244
|
+
if (report.id === descriptor.id) {
|
|
12245
|
+
value = report[descriptor.name];
|
|
12246
|
+
break;
|
|
12247
|
+
}
|
|
12248
|
+
}
|
|
12249
|
+
} catch (err) {
|
|
12250
|
+
_iterator2.e(err);
|
|
12251
|
+
} finally {
|
|
12252
|
+
_iterator2.f();
|
|
12253
|
+
}
|
|
12254
|
+
}
|
|
12255
|
+
metrics.push(value);
|
|
12256
|
+
});
|
|
12257
|
+
statCollector.metricsBatch.push(metrics);
|
|
12258
|
+
statCollector.batchCount--;
|
|
12259
|
+
if (!(statCollector.batchCount === 0)) {
|
|
12260
|
+
_context6.n = 2;
|
|
12261
|
+
break;
|
|
12262
|
+
}
|
|
12263
|
+
_context6.n = 2;
|
|
12264
|
+
return statCollector.sendMetrics();
|
|
12265
|
+
case 2:
|
|
12266
|
+
return _context6.a(2);
|
|
12267
|
+
}
|
|
12268
|
+
}, _callee6);
|
|
12269
|
+
}));
|
|
12270
|
+
function collectMetrics() {
|
|
12271
|
+
return _collectMetrics.apply(this, arguments);
|
|
12272
|
+
}
|
|
12273
|
+
return collectMetrics;
|
|
12274
|
+
}(),
|
|
12275
|
+
sendMetrics: function () {
|
|
12276
|
+
var _sendMetrics = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
12277
|
+
var previous, metricsToSend, metricsData, i, metricsString, j, valueString, previousString, separator, data, _t3;
|
|
12278
|
+
return _regenerator().w(function (_context7) {
|
|
12279
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
12280
|
+
case 0:
|
|
12281
|
+
metricsToSend = [];
|
|
12282
|
+
for (i = 0; i < statCollector.metricsBatch.length; i++) {
|
|
12283
|
+
metricsString = "";
|
|
12284
|
+
for (j = 0; j < statCollector.metricsBatch[i].length; j++) {
|
|
12285
|
+
valueString = valueToString(statCollector.metricsBatch[i][j]);
|
|
12286
|
+
previousString = "";
|
|
12287
|
+
separator = ";";
|
|
12288
|
+
if (previous) {
|
|
12289
|
+
previousString = valueToString(previous[j]);
|
|
12290
|
+
}
|
|
12291
|
+
if (valueString === previousString) {
|
|
12292
|
+
valueString = "";
|
|
12293
|
+
}
|
|
12294
|
+
metricsString = util.addFieldToCsvString(metricsString, valueString, separator);
|
|
12295
|
+
}
|
|
12296
|
+
previous = statCollector.metricsBatch[i];
|
|
12297
|
+
metricsToSend.push(metricsString);
|
|
12298
|
+
}
|
|
12299
|
+
if (!(statCollector.compression !== "none")) {
|
|
12300
|
+
_context7.n = 5;
|
|
12301
|
+
break;
|
|
12302
|
+
}
|
|
12303
|
+
_context7.p = 1;
|
|
12304
|
+
_context7.n = 2;
|
|
12305
|
+
return util.compress(statCollector.compression, JSON.stringify(metricsToSend), true);
|
|
12306
|
+
case 2:
|
|
12307
|
+
metricsData = _context7.v;
|
|
12308
|
+
_context7.n = 4;
|
|
12309
|
+
break;
|
|
12310
|
+
case 3:
|
|
12311
|
+
_context7.p = 3;
|
|
12312
|
+
_t3 = _context7.v;
|
|
12313
|
+
statCollector.logger.warn(LOG_PREFIX, "Can't send metrics data using" + statCollector.compression + ": " + _t3);
|
|
12314
|
+
metricsData = null;
|
|
12315
|
+
case 4:
|
|
12316
|
+
_context7.n = 6;
|
|
12317
|
+
break;
|
|
12318
|
+
case 5:
|
|
12319
|
+
metricsData = metricsToSend;
|
|
12320
|
+
case 6:
|
|
12321
|
+
if (metricsData) {
|
|
12322
|
+
data = {
|
|
12323
|
+
mediaSessionId: statCollector.id,
|
|
12324
|
+
metrics: metricsData
|
|
12325
|
+
};
|
|
12326
|
+
statCollector.send("webRTCMetricsBatch", data);
|
|
12327
|
+
}
|
|
12328
|
+
statCollector.metricsBatch = null;
|
|
12329
|
+
statCollector.batchCount = statCollector.description.batchSize;
|
|
12330
|
+
case 7:
|
|
12331
|
+
return _context7.a(2);
|
|
12332
|
+
}
|
|
12333
|
+
}, _callee7, null, [[1, 3]]);
|
|
12334
|
+
}));
|
|
12335
|
+
function sendMetrics() {
|
|
12336
|
+
return _sendMetrics.apply(this, arguments);
|
|
12337
|
+
}
|
|
12338
|
+
return sendMetrics;
|
|
12339
|
+
}()
|
|
12340
|
+
};
|
|
12341
|
+
return statCollector;
|
|
12342
|
+
};
|
|
12343
|
+
|
|
12344
|
+
// Helper function to stringify a value
|
|
12345
|
+
var valueToString = function valueToString(value) {
|
|
12346
|
+
var valueString = "undefined";
|
|
12347
|
+
if (_typeof(value) === "object") {
|
|
12348
|
+
valueString = JSON.stringify(value);
|
|
12349
|
+
} else {
|
|
12350
|
+
valueString = value.toString();
|
|
12351
|
+
}
|
|
12352
|
+
return valueString;
|
|
12353
|
+
};
|
|
12354
|
+
|
|
12355
|
+
// Helper function to get logger object
|
|
12356
|
+
var getLogger = function getLogger(logger) {
|
|
12357
|
+
if (logger) {
|
|
12358
|
+
if (logger.info !== undefined && logger.warn !== undefined && logger.error !== undefined && logger.debug !== undefined) {
|
|
12359
|
+
return logger;
|
|
12360
|
+
}
|
|
12361
|
+
}
|
|
12362
|
+
return {
|
|
12363
|
+
info: function info() {},
|
|
12364
|
+
warn: function warn() {},
|
|
12365
|
+
error: function error() {},
|
|
12366
|
+
debug: function debug() {}
|
|
12367
|
+
};
|
|
12368
|
+
};
|
|
12369
|
+
module.exports = {
|
|
12370
|
+
StreamStatsCollector: StreamStatsCollector
|
|
12371
|
+
};
|
|
12372
|
+
|
|
12373
|
+
},{"./util":44}],44:[function(require,module,exports){
|
|
12374
|
+
'use strict';
|
|
12375
|
+
|
|
12376
|
+
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 }; })(); }
|
|
12377
|
+
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); }
|
|
12378
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
12379
|
+
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."); }
|
|
12380
|
+
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; } }
|
|
12381
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
12382
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
12383
|
+
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; }
|
|
12384
|
+
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); }
|
|
12385
|
+
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); }); }; }
|
|
11795
12386
|
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); }
|
|
11796
12387
|
var isEmptyObject = function isEmptyObject(obj) {
|
|
11797
12388
|
for (var name in obj) {
|
|
@@ -12271,6 +12862,70 @@ var setPublishingBitrate = function setPublishingBitrate(sdp, mediaConnection, m
|
|
|
12271
12862
|
}
|
|
12272
12863
|
return sdp;
|
|
12273
12864
|
};
|
|
12865
|
+
var addFieldToCsvString = function addFieldToCsvString(csvString, field, separator) {
|
|
12866
|
+
if (field !== "" && field.indexOf(separator) >= 0) {
|
|
12867
|
+
field = '"' + field + '"';
|
|
12868
|
+
}
|
|
12869
|
+
if (csvString === "" && field !== "") {
|
|
12870
|
+
csvString = field;
|
|
12871
|
+
} else {
|
|
12872
|
+
csvString = csvString + separator + field;
|
|
12873
|
+
}
|
|
12874
|
+
return csvString;
|
|
12875
|
+
};
|
|
12876
|
+
var compress = /*#__PURE__*/function () {
|
|
12877
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(compression, data, base64) {
|
|
12878
|
+
var stream, compressedReadableStream, compressedResponse, blob, buffer, compressedBase64;
|
|
12879
|
+
return _regenerator().w(function (_context) {
|
|
12880
|
+
while (1) switch (_context.n) {
|
|
12881
|
+
case 0:
|
|
12882
|
+
if (!(typeof CompressionStream === "undefined")) {
|
|
12883
|
+
_context.n = 1;
|
|
12884
|
+
break;
|
|
12885
|
+
}
|
|
12886
|
+
throw new Error("Compression is not available");
|
|
12887
|
+
case 1:
|
|
12888
|
+
if (typeof data == "string") {
|
|
12889
|
+
stream = new Blob([data], {
|
|
12890
|
+
type: 'text/plain'
|
|
12891
|
+
}).stream();
|
|
12892
|
+
} else {
|
|
12893
|
+
// Assume blog
|
|
12894
|
+
stream = data.stream();
|
|
12895
|
+
}
|
|
12896
|
+
|
|
12897
|
+
// gzip stream
|
|
12898
|
+
compressedReadableStream = stream.pipeThrough(new CompressionStream(compression)); // create Response
|
|
12899
|
+
_context.n = 2;
|
|
12900
|
+
return new Response(compressedReadableStream);
|
|
12901
|
+
case 2:
|
|
12902
|
+
compressedResponse = _context.v;
|
|
12903
|
+
_context.n = 3;
|
|
12904
|
+
return compressedResponse.blob();
|
|
12905
|
+
case 3:
|
|
12906
|
+
blob = _context.v;
|
|
12907
|
+
if (!base64) {
|
|
12908
|
+
_context.n = 5;
|
|
12909
|
+
break;
|
|
12910
|
+
}
|
|
12911
|
+
_context.n = 4;
|
|
12912
|
+
return blob.arrayBuffer();
|
|
12913
|
+
case 4:
|
|
12914
|
+
buffer = _context.v;
|
|
12915
|
+
// convert ArrayBuffer to base64 encoded string
|
|
12916
|
+
compressedBase64 = btoa(String.fromCharCode.apply(String, _toConsumableArray(new Uint8Array(buffer))));
|
|
12917
|
+
return _context.a(2, compressedBase64);
|
|
12918
|
+
case 5:
|
|
12919
|
+
return _context.a(2, blob);
|
|
12920
|
+
case 6:
|
|
12921
|
+
return _context.a(2);
|
|
12922
|
+
}
|
|
12923
|
+
}, _callee);
|
|
12924
|
+
}));
|
|
12925
|
+
return function compress(_x, _x2, _x3) {
|
|
12926
|
+
return _ref.apply(this, arguments);
|
|
12927
|
+
};
|
|
12928
|
+
}();
|
|
12274
12929
|
module.exports = {
|
|
12275
12930
|
isEmptyObject: isEmptyObject,
|
|
12276
12931
|
copyObjectToArray: copyObjectToArray,
|
|
@@ -12282,22 +12937,24 @@ module.exports = {
|
|
|
12282
12937
|
stripCodecs: stripCodecs,
|
|
12283
12938
|
getCurrentCodecAndSampleRate: getCurrentCodecAndSampleRate,
|
|
12284
12939
|
isPromise: isPromise,
|
|
12285
|
-
setPublishingBitrate: setPublishingBitrate
|
|
12940
|
+
setPublishingBitrate: setPublishingBitrate,
|
|
12941
|
+
addFieldToCsvString: addFieldToCsvString,
|
|
12942
|
+
compress: compress
|
|
12286
12943
|
};
|
|
12287
12944
|
|
|
12288
|
-
},{}],
|
|
12945
|
+
},{}],45:[function(require,module,exports){
|
|
12289
12946
|
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); }
|
|
12290
12947
|
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; } } }; }
|
|
12291
|
-
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 }; })(); }
|
|
12292
|
-
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); }
|
|
12293
|
-
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); }
|
|
12294
|
-
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); }); }; }
|
|
12295
12948
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12296
12949
|
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."); }
|
|
12297
12950
|
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; } }
|
|
12298
12951
|
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; }
|
|
12299
12952
|
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; } }
|
|
12300
12953
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
12954
|
+
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 }; })(); }
|
|
12955
|
+
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); }
|
|
12956
|
+
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); }
|
|
12957
|
+
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); }); }; }
|
|
12301
12958
|
-'use strict';
|
|
12302
12959
|
var browserDetails = require('webrtc-adapter')["default"].browserDetails;
|
|
12303
12960
|
var _require = require('uuid'),
|
|
@@ -12742,67 +13399,70 @@ var createConnection = function createConnection(options) {
|
|
|
12742
13399
|
}
|
|
12743
13400
|
return true;
|
|
12744
13401
|
};
|
|
12745
|
-
var getStat = function
|
|
12746
|
-
var
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
13402
|
+
var getStat = /*#__PURE__*/function () {
|
|
13403
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(callbackFn, nativeStats) {
|
|
13404
|
+
var result, rawStat;
|
|
13405
|
+
return _regenerator().w(function (_context) {
|
|
13406
|
+
while (1) switch (_context.n) {
|
|
13407
|
+
case 0:
|
|
13408
|
+
result = {
|
|
13409
|
+
outboundStream: {},
|
|
13410
|
+
inboundStream: {},
|
|
13411
|
+
otherStats: []
|
|
13412
|
+
};
|
|
13413
|
+
_context.n = 1;
|
|
13414
|
+
return getWebRTCStats();
|
|
13415
|
+
case 1:
|
|
13416
|
+
rawStat = _context.v;
|
|
13417
|
+
if (nativeStats) {
|
|
13418
|
+
callbackFn(rawStat);
|
|
13419
|
+
} else {
|
|
13420
|
+
if (rawStat["candidate-pair"]) {
|
|
13421
|
+
rawStat["candidate-pair"].forEach(function (report) {
|
|
13422
|
+
if (report.state === 'succeeded' && report.nominated) {
|
|
13423
|
+
if (report.availableIncomingBitrate) {
|
|
13424
|
+
result.otherStats.availableIncomingBitrate = report.availableIncomingBitrate;
|
|
13425
|
+
} else if (localVideo && report.availableOutgoingBitrate) {
|
|
13426
|
+
// availableOutgoingBitrate is defined for incoming stream too #WCS-4175
|
|
13427
|
+
result.otherStats.availableOutgoingBitrate = report.availableOutgoingBitrate;
|
|
13428
|
+
}
|
|
12766
13429
|
}
|
|
12767
|
-
}
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
13430
|
+
});
|
|
13431
|
+
}
|
|
13432
|
+
if (rawStat["outbound-rtp"]) {
|
|
13433
|
+
rawStat["outbound-rtp"].forEach(function (report) {
|
|
13434
|
+
fillStatObject(result.outboundStream, report, report.kind);
|
|
13435
|
+
if (report.kind === "video") {
|
|
13436
|
+
getVideoSize(result.outboundStream[report.kind], report.type, report);
|
|
12772
13437
|
}
|
|
12773
|
-
}
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
13438
|
+
});
|
|
13439
|
+
}
|
|
13440
|
+
if (rawStat["inbound-rtp"]) {
|
|
13441
|
+
rawStat["inbound-rtp"].forEach(function (report) {
|
|
13442
|
+
fillStatObject(result.inboundStream, report, report.kind);
|
|
13443
|
+
if (report.kind === "video") {
|
|
13444
|
+
getVideoSize(result.inboundStream["video"], report.type, report);
|
|
12779
13445
|
}
|
|
12780
|
-
}
|
|
13446
|
+
});
|
|
12781
13447
|
}
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
return report.kind;
|
|
12795
|
-
}
|
|
12796
|
-
logger.warn(LOG_PREFIX, "No media type provided in WebRTC statistics");
|
|
12797
|
-
return "media";
|
|
12798
|
-
};
|
|
12799
|
-
var getVideoSize = function getVideoSize(obj, report) {
|
|
13448
|
+
callbackFn(result);
|
|
13449
|
+
}
|
|
13450
|
+
case 2:
|
|
13451
|
+
return _context.a(2);
|
|
13452
|
+
}
|
|
13453
|
+
}, _callee);
|
|
13454
|
+
}));
|
|
13455
|
+
return function getStat(_x, _x2) {
|
|
13456
|
+
return _ref.apply(this, arguments);
|
|
13457
|
+
};
|
|
13458
|
+
}();
|
|
13459
|
+
var getVideoSize = function getVideoSize(obj, type, report) {
|
|
12800
13460
|
var videoSize = {};
|
|
12801
|
-
if (
|
|
13461
|
+
if (type === 'outbound-rtp') {
|
|
12802
13462
|
if (localVideo !== undefined && localVideo != null) {
|
|
12803
13463
|
videoSize = localVideo.srcObject.getVideoTracks()[0].getSettings();
|
|
12804
13464
|
}
|
|
12805
|
-
} else if (
|
|
13465
|
+
} else if (type === 'inbound-rtp') {
|
|
12806
13466
|
if (remoteVideo !== undefined && remoteVideo != null) {
|
|
12807
13467
|
videoSize.width = remoteVideo.videoWidth;
|
|
12808
13468
|
videoSize.height = remoteVideo.videoHeight;
|
|
@@ -13205,25 +13865,25 @@ var createConnection = function createConnection(options) {
|
|
|
13205
13865
|
return zoom;
|
|
13206
13866
|
};
|
|
13207
13867
|
var setZoom = /*#__PURE__*/function () {
|
|
13208
|
-
var
|
|
13868
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(value) {
|
|
13209
13869
|
var _localVideo$srcObject3, _localVideo$srcObject4, track;
|
|
13210
|
-
return _regenerator().w(function (
|
|
13211
|
-
while (1) switch (
|
|
13870
|
+
return _regenerator().w(function (_context2) {
|
|
13871
|
+
while (1) switch (_context2.n) {
|
|
13212
13872
|
case 0:
|
|
13213
13873
|
if (!zoom) {
|
|
13214
|
-
|
|
13874
|
+
_context2.n = 6;
|
|
13215
13875
|
break;
|
|
13216
13876
|
}
|
|
13217
13877
|
if (!(value >= zoom.min && value <= zoom.max)) {
|
|
13218
|
-
|
|
13878
|
+
_context2.n = 4;
|
|
13219
13879
|
break;
|
|
13220
13880
|
}
|
|
13221
13881
|
if (!(localVideo && localVideo.srcObject)) {
|
|
13222
|
-
|
|
13882
|
+
_context2.n = 2;
|
|
13223
13883
|
break;
|
|
13224
13884
|
}
|
|
13225
13885
|
_localVideo$srcObject3 = localVideo.srcObject.getVideoTracks(), _localVideo$srcObject4 = _slicedToArray(_localVideo$srcObject3, 1), track = _localVideo$srcObject4[0];
|
|
13226
|
-
|
|
13886
|
+
_context2.n = 1;
|
|
13227
13887
|
return track.applyConstraints({
|
|
13228
13888
|
advanced: [{
|
|
13229
13889
|
zoom: value
|
|
@@ -13231,27 +13891,27 @@ var createConnection = function createConnection(options) {
|
|
|
13231
13891
|
});
|
|
13232
13892
|
case 1:
|
|
13233
13893
|
zoom.value = value;
|
|
13234
|
-
|
|
13894
|
+
_context2.n = 3;
|
|
13235
13895
|
break;
|
|
13236
13896
|
case 2:
|
|
13237
13897
|
logger.warn(LOG_PREFIX, "Can't set zoom value: no local video");
|
|
13238
13898
|
case 3:
|
|
13239
|
-
|
|
13899
|
+
_context2.n = 5;
|
|
13240
13900
|
break;
|
|
13241
13901
|
case 4:
|
|
13242
13902
|
logger.info(LOG_PREFIX, "Zoom value " + value + "is out of range: " + zoom.min + "-" + zoom.max);
|
|
13243
13903
|
case 5:
|
|
13244
|
-
|
|
13904
|
+
_context2.n = 7;
|
|
13245
13905
|
break;
|
|
13246
13906
|
case 6:
|
|
13247
13907
|
logger.info(LOG_PREFIX, "Zoom is not supported or zoom capabilities unknown yet");
|
|
13248
13908
|
case 7:
|
|
13249
|
-
return
|
|
13909
|
+
return _context2.a(2);
|
|
13250
13910
|
}
|
|
13251
|
-
},
|
|
13911
|
+
}, _callee2);
|
|
13252
13912
|
}));
|
|
13253
|
-
return function setZoom(
|
|
13254
|
-
return
|
|
13913
|
+
return function setZoom(_x3) {
|
|
13914
|
+
return _ref2.apply(this, arguments);
|
|
13255
13915
|
};
|
|
13256
13916
|
}();
|
|
13257
13917
|
var getZoom = function getZoom() {
|
|
@@ -13260,6 +13920,32 @@ var createConnection = function createConnection(options) {
|
|
|
13260
13920
|
}
|
|
13261
13921
|
return -1;
|
|
13262
13922
|
};
|
|
13923
|
+
var getWebRTCStats = function getWebRTCStats() {
|
|
13924
|
+
return new Promise(function (resolve, reject) {
|
|
13925
|
+
var browser = browserDetails.browser;
|
|
13926
|
+
if (connection && validBrowsers.includes(browser)) {
|
|
13927
|
+
connection.getStats(null).then(function (stats) {
|
|
13928
|
+
var statObject = {};
|
|
13929
|
+
if (stats) {
|
|
13930
|
+
stats.forEach(function (report) {
|
|
13931
|
+
if (report) {
|
|
13932
|
+
if (statObject[report.type] === undefined) {
|
|
13933
|
+
statObject[report.type] = [];
|
|
13934
|
+
}
|
|
13935
|
+
statObject[report.type].push(report);
|
|
13936
|
+
}
|
|
13937
|
+
});
|
|
13938
|
+
}
|
|
13939
|
+
resolve(statObject);
|
|
13940
|
+
})["catch"](function (reason) {
|
|
13941
|
+
logger.error(LOG_PREFIX, reason);
|
|
13942
|
+
reject(reason);
|
|
13943
|
+
});
|
|
13944
|
+
} else {
|
|
13945
|
+
reject(constants.ERROR_INFO.CAN_NOT_GET_STATS);
|
|
13946
|
+
}
|
|
13947
|
+
});
|
|
13948
|
+
};
|
|
13263
13949
|
var exports = {};
|
|
13264
13950
|
exports.state = state;
|
|
13265
13951
|
exports.createOffer = createOffer;
|
|
@@ -13292,6 +13978,7 @@ var createConnection = function createConnection(options) {
|
|
|
13292
13978
|
exports.getZoomCapabilities = getZoomCapabilities;
|
|
13293
13979
|
exports.setZoom = setZoom;
|
|
13294
13980
|
exports.getZoom = getZoom;
|
|
13981
|
+
exports.getWebRTCStats = getWebRTCStats;
|
|
13295
13982
|
connections[id] = exports;
|
|
13296
13983
|
resolve(exports);
|
|
13297
13984
|
});
|
|
@@ -14065,7 +14752,7 @@ module.exports = {
|
|
|
14065
14752
|
getVideoElement: getVideoElement
|
|
14066
14753
|
};
|
|
14067
14754
|
|
|
14068
|
-
},{"./constants":40,"./util":
|
|
14755
|
+
},{"./constants":40,"./util":44,"uuid":8,"webrtc-adapter":23}],46:[function(require,module,exports){
|
|
14069
14756
|
'use strict';
|
|
14070
14757
|
|
|
14071
14758
|
var WSPlayer = require('./WSPlayer').WSPlayer;
|
|
@@ -14255,5 +14942,5 @@ module.exports = {
|
|
|
14255
14942
|
}
|
|
14256
14943
|
};
|
|
14257
14944
|
|
|
14258
|
-
},{"./WSPlayer":38,"./util":
|
|
14945
|
+
},{"./WSPlayer":38,"./util":44}]},{},[41])(41)
|
|
14259
14946
|
});
|