gaussian-id 2.34.1 → 2.34.3

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.
@@ -1,129 +1,129 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- /* global Reflect, Promise */
16
-
17
- var extendStatics = function(d, b) {
18
- extendStatics = Object.setPrototypeOf ||
19
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
- return extendStatics(d, b);
22
- };
23
-
24
- function __extends(d, b) {
25
- if (typeof b !== "function" && b !== null)
26
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
27
- extendStatics(d, b);
28
- function __() { this.constructor = d; }
29
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
- }
31
-
32
- function __awaiter(thisArg, _arguments, P, generator) {
33
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
- return new (P || (P = Promise))(function (resolve, reject) {
35
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
37
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
38
- step((generator = generator.apply(thisArg, _arguments || [])).next());
39
- });
40
- }
41
-
42
- function __generator(thisArg, body) {
43
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
44
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
45
- function verb(n) { return function (v) { return step([n, v]); }; }
46
- function step(op) {
47
- if (f) throw new TypeError("Generator is already executing.");
48
- while (_) try {
49
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
50
- if (y = 0, t) op = [op[0] & 2, t.value];
51
- switch (op[0]) {
52
- case 0: case 1: t = op; break;
53
- case 4: _.label++; return { value: op[1], done: false };
54
- case 5: _.label++; y = op[1]; op = [0]; continue;
55
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
56
- default:
57
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
58
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
59
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
60
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
61
- if (t[2]) _.ops.pop();
62
- _.trys.pop(); continue;
63
- }
64
- op = body.call(thisArg, _);
65
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
66
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
67
- }
68
- }
69
-
70
- function __values(o) {
71
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
72
- if (m) return m.call(o);
73
- if (o && typeof o.length === "number") return {
74
- next: function () {
75
- if (o && i >= o.length) o = void 0;
76
- return { value: o && o[i++], done: !o };
77
- }
78
- };
79
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
80
- }
81
-
82
- function __read(o, n) {
83
- var m = typeof Symbol === "function" && o[Symbol.iterator];
84
- if (!m) return o;
85
- var i = m.call(o), r, ar = [], e;
86
- try {
87
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
88
- }
89
- catch (error) { e = { error: error }; }
90
- finally {
91
- try {
92
- if (r && !r.done && (m = i["return"])) m.call(i);
93
- }
94
- finally { if (e) throw e.error; }
95
- }
96
- return ar;
97
- }
98
-
99
- function __spreadArray(to, from) {
100
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
101
- to[j] = from[i];
102
- return to;
103
- }
104
-
105
- function __await(v) {
106
- return this instanceof __await ? (this.v = v, this) : new __await(v);
107
- }
108
-
109
- function __asyncGenerator(thisArg, _arguments, generator) {
110
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
111
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
112
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
113
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
114
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
115
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
116
- function fulfill(value) { resume("next", value); }
117
- function reject(value) { resume("throw", value); }
118
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
119
- }
120
-
121
- function __asyncValues(o) {
122
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
123
- var m = o[Symbol.asyncIterator], i;
124
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
125
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
126
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
1
+ /*! *****************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise */
16
+
17
+ var extendStatics = function(d, b) {
18
+ extendStatics = Object.setPrototypeOf ||
19
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21
+ return extendStatics(d, b);
22
+ };
23
+
24
+ function __extends(d, b) {
25
+ if (typeof b !== "function" && b !== null)
26
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
27
+ extendStatics(d, b);
28
+ function __() { this.constructor = d; }
29
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
30
+ }
31
+
32
+ function __awaiter(thisArg, _arguments, P, generator) {
33
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
+ return new (P || (P = Promise))(function (resolve, reject) {
35
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
37
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
38
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
39
+ });
40
+ }
41
+
42
+ function __generator(thisArg, body) {
43
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
44
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
45
+ function verb(n) { return function (v) { return step([n, v]); }; }
46
+ function step(op) {
47
+ if (f) throw new TypeError("Generator is already executing.");
48
+ while (_) try {
49
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
50
+ if (y = 0, t) op = [op[0] & 2, t.value];
51
+ switch (op[0]) {
52
+ case 0: case 1: t = op; break;
53
+ case 4: _.label++; return { value: op[1], done: false };
54
+ case 5: _.label++; y = op[1]; op = [0]; continue;
55
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
56
+ default:
57
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
58
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
59
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
60
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
61
+ if (t[2]) _.ops.pop();
62
+ _.trys.pop(); continue;
63
+ }
64
+ op = body.call(thisArg, _);
65
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
66
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
67
+ }
68
+ }
69
+
70
+ function __values(o) {
71
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
72
+ if (m) return m.call(o);
73
+ if (o && typeof o.length === "number") return {
74
+ next: function () {
75
+ if (o && i >= o.length) o = void 0;
76
+ return { value: o && o[i++], done: !o };
77
+ }
78
+ };
79
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
80
+ }
81
+
82
+ function __read(o, n) {
83
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
84
+ if (!m) return o;
85
+ var i = m.call(o), r, ar = [], e;
86
+ try {
87
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
88
+ }
89
+ catch (error) { e = { error: error }; }
90
+ finally {
91
+ try {
92
+ if (r && !r.done && (m = i["return"])) m.call(i);
93
+ }
94
+ finally { if (e) throw e.error; }
95
+ }
96
+ return ar;
97
+ }
98
+
99
+ function __spreadArray(to, from) {
100
+ for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
101
+ to[j] = from[i];
102
+ return to;
103
+ }
104
+
105
+ function __await(v) {
106
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
107
+ }
108
+
109
+ function __asyncGenerator(thisArg, _arguments, generator) {
110
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
111
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
112
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
113
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
114
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
115
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
116
+ function fulfill(value) { resume("next", value); }
117
+ function reject(value) { resume("throw", value); }
118
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
119
+ }
120
+
121
+ function __asyncValues(o) {
122
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
123
+ var m = o[Symbol.asyncIterator], i;
124
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
125
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
126
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
127
127
  }
128
128
 
129
129
  function isFunction(value) {
@@ -49742,10 +49742,10 @@ function isWidget$7(w) {
49742
49742
  return w && w.type === "Widget"
49743
49743
  }
49744
49744
 
49745
- var isThunk_1 = isThunk$3;
49746
-
49747
- function isThunk$3(t) {
49748
- return t && t.type === "Thunk"
49745
+ var isThunk_1 = isThunk$3;
49746
+
49747
+ function isThunk$3(t) {
49748
+ return t && t.type === "Thunk"
49749
49749
  }
49750
49750
 
49751
49751
  var isVNode$4 = isVnode;
@@ -51893,20 +51893,20 @@ var createElement = createElement_1$1;
51893
51893
 
51894
51894
  var createElement_1 = createElement;
51895
51895
 
51896
- var diff = diff_1;
51897
- var patch = patch_1;
51898
- var h = h_1;
51899
- var create = createElement_1;
51900
- var VNode = vnode;
51901
- var VText = vtext;
51902
-
51903
- var virtualDom = {
51904
- diff: diff,
51905
- patch: patch,
51906
- h: h,
51907
- create: create,
51908
- VNode: VNode,
51909
- VText: VText
51896
+ var diff = diff_1;
51897
+ var patch = patch_1;
51898
+ var h = h_1;
51899
+ var create = createElement_1;
51900
+ var VNode = vnode;
51901
+ var VText = vtext;
51902
+
51903
+ var virtualDom = {
51904
+ diff: diff,
51905
+ patch: patch,
51906
+ h: h,
51907
+ create: create,
51908
+ VNode: VNode,
51909
+ VText: VText
51910
51910
  };
51911
51911
 
51912
51912
  class EventEmitter {
@@ -77352,1212 +77352,1212 @@ var s2geometry = {exports: {}};
77352
77352
 
77353
77353
  var long = {exports: {}};
77354
77354
 
77355
- /*
77356
- Copyright 2013 Daniel Wirtz <dcode@dcode.io>
77357
- Copyright 2009 The Closure Library Authors. All Rights Reserved.
77358
-
77359
- Licensed under the Apache License, Version 2.0 (the "License");
77360
- you may not use this file except in compliance with the License.
77361
- You may obtain a copy of the License at
77362
-
77363
- http://www.apache.org/licenses/LICENSE-2.0
77364
-
77365
- Unless required by applicable law or agreed to in writing, software
77366
- distributed under the License is distributed on an "AS-IS" BASIS,
77367
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77368
- See the License for the specific language governing permissions and
77369
- limitations under the License.
77355
+ /*
77356
+ Copyright 2013 Daniel Wirtz <dcode@dcode.io>
77357
+ Copyright 2009 The Closure Library Authors. All Rights Reserved.
77358
+
77359
+ Licensed under the Apache License, Version 2.0 (the "License");
77360
+ you may not use this file except in compliance with the License.
77361
+ You may obtain a copy of the License at
77362
+
77363
+ http://www.apache.org/licenses/LICENSE-2.0
77364
+
77365
+ Unless required by applicable law or agreed to in writing, software
77366
+ distributed under the License is distributed on an "AS-IS" BASIS,
77367
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
77368
+ See the License for the specific language governing permissions and
77369
+ limitations under the License.
77370
77370
  */
77371
77371
 
77372
77372
  (function (module) {
77373
- /**
77374
- * @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
77375
- * Released under the Apache License, Version 2.0
77376
- * see: https://github.com/dcodeIO/long.js for details
77377
- */
77378
- (function(global, factory) {
77379
-
77380
- /* AMD */ if (typeof commonjsRequire === 'function' && 'object' === "object" && module && module["exports"])
77381
- module["exports"] = factory();
77382
- /* Global */ else
77383
- (global["dcodeIO"] = global["dcodeIO"] || {})["Long"] = factory();
77384
-
77385
- })(commonjsGlobal, function() {
77386
-
77387
- /**
77388
- * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
77389
- * See the from* functions below for more convenient ways of constructing Longs.
77390
- * @exports Long
77391
- * @class A Long class for representing a 64 bit two's-complement integer value.
77392
- * @param {number} low The low (signed) 32 bits of the long
77393
- * @param {number} high The high (signed) 32 bits of the long
77394
- * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77395
- * @constructor
77396
- */
77397
- function Long(low, high, unsigned) {
77398
-
77399
- /**
77400
- * The low 32 bits as a signed value.
77401
- * @type {number}
77402
- */
77403
- this.low = low | 0;
77404
-
77405
- /**
77406
- * The high 32 bits as a signed value.
77407
- * @type {number}
77408
- */
77409
- this.high = high | 0;
77410
-
77411
- /**
77412
- * Whether unsigned or not.
77413
- * @type {boolean}
77414
- */
77415
- this.unsigned = !!unsigned;
77416
- }
77417
-
77418
- // The internal representation of a long is the two given signed, 32-bit values.
77419
- // We use 32-bit pieces because these are the size of integers on which
77420
- // Javascript performs bit-operations. For operations like addition and
77421
- // multiplication, we split each number into 16 bit pieces, which can easily be
77422
- // multiplied within Javascript's floating-point representation without overflow
77423
- // or change in sign.
77424
- //
77425
- // In the algorithms below, we frequently reduce the negative case to the
77426
- // positive case by negating the input(s) and then post-processing the result.
77427
- // Note that we must ALWAYS check specially whether those values are MIN_VALUE
77428
- // (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
77429
- // a positive number, it overflows back into a negative). Not handling this
77430
- // case would often result in infinite recursion.
77431
- //
77432
- // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
77433
- // methods on which they depend.
77434
-
77435
- /**
77436
- * An indicator used to reliably determine if an object is a Long or not.
77437
- * @type {boolean}
77438
- * @const
77439
- * @private
77440
- */
77441
- Long.prototype.__isLong__;
77442
-
77443
- Object.defineProperty(Long.prototype, "__isLong__", {
77444
- value: true,
77445
- enumerable: false,
77446
- configurable: false
77447
- });
77448
-
77449
- /**
77450
- * @function
77451
- * @param {*} obj Object
77452
- * @returns {boolean}
77453
- * @inner
77454
- */
77455
- function isLong(obj) {
77456
- return (obj && obj["__isLong__"]) === true;
77457
- }
77458
-
77459
- /**
77460
- * Tests if the specified object is a Long.
77461
- * @function
77462
- * @param {*} obj Object
77463
- * @returns {boolean}
77464
- */
77465
- Long.isLong = isLong;
77466
-
77467
- /**
77468
- * A cache of the Long representations of small integer values.
77469
- * @type {!Object}
77470
- * @inner
77471
- */
77472
- var INT_CACHE = {};
77473
-
77474
- /**
77475
- * A cache of the Long representations of small unsigned integer values.
77476
- * @type {!Object}
77477
- * @inner
77478
- */
77479
- var UINT_CACHE = {};
77480
-
77481
- /**
77482
- * @param {number} value
77483
- * @param {boolean=} unsigned
77484
- * @returns {!Long}
77485
- * @inner
77486
- */
77487
- function fromInt(value, unsigned) {
77488
- var obj, cachedObj, cache;
77489
- if (unsigned) {
77490
- value >>>= 0;
77491
- if (cache = (0 <= value && value < 256)) {
77492
- cachedObj = UINT_CACHE[value];
77493
- if (cachedObj)
77494
- return cachedObj;
77495
- }
77496
- obj = fromBits(value, (value | 0) < 0 ? -1 : 0, true);
77497
- if (cache)
77498
- UINT_CACHE[value] = obj;
77499
- return obj;
77500
- } else {
77501
- value |= 0;
77502
- if (cache = (-128 <= value && value < 128)) {
77503
- cachedObj = INT_CACHE[value];
77504
- if (cachedObj)
77505
- return cachedObj;
77506
- }
77507
- obj = fromBits(value, value < 0 ? -1 : 0, false);
77508
- if (cache)
77509
- INT_CACHE[value] = obj;
77510
- return obj;
77511
- }
77512
- }
77513
-
77514
- /**
77515
- * Returns a Long representing the given 32 bit integer value.
77516
- * @function
77517
- * @param {number} value The 32 bit integer in question
77518
- * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77519
- * @returns {!Long} The corresponding Long value
77520
- */
77521
- Long.fromInt = fromInt;
77522
-
77523
- /**
77524
- * @param {number} value
77525
- * @param {boolean=} unsigned
77526
- * @returns {!Long}
77527
- * @inner
77528
- */
77529
- function fromNumber(value, unsigned) {
77530
- if (isNaN(value) || !isFinite(value))
77531
- return unsigned ? UZERO : ZERO;
77532
- if (unsigned) {
77533
- if (value < 0)
77534
- return UZERO;
77535
- if (value >= TWO_PWR_64_DBL)
77536
- return MAX_UNSIGNED_VALUE;
77537
- } else {
77538
- if (value <= -TWO_PWR_63_DBL)
77539
- return MIN_VALUE;
77540
- if (value + 1 >= TWO_PWR_63_DBL)
77541
- return MAX_VALUE;
77542
- }
77543
- if (value < 0)
77544
- return fromNumber(-value, unsigned).neg();
77545
- return fromBits((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
77546
- }
77547
-
77548
- /**
77549
- * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
77550
- * @function
77551
- * @param {number} value The number in question
77552
- * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77553
- * @returns {!Long} The corresponding Long value
77554
- */
77555
- Long.fromNumber = fromNumber;
77556
-
77557
- /**
77558
- * @param {number} lowBits
77559
- * @param {number} highBits
77560
- * @param {boolean=} unsigned
77561
- * @returns {!Long}
77562
- * @inner
77563
- */
77564
- function fromBits(lowBits, highBits, unsigned) {
77565
- return new Long(lowBits, highBits, unsigned);
77566
- }
77567
-
77568
- /**
77569
- * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
77570
- * assumed to use 32 bits.
77571
- * @function
77572
- * @param {number} lowBits The low 32 bits
77573
- * @param {number} highBits The high 32 bits
77574
- * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77575
- * @returns {!Long} The corresponding Long value
77576
- */
77577
- Long.fromBits = fromBits;
77578
-
77579
- /**
77580
- * @function
77581
- * @param {number} base
77582
- * @param {number} exponent
77583
- * @returns {number}
77584
- * @inner
77585
- */
77586
- var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
77587
-
77588
- /**
77589
- * @param {string} str
77590
- * @param {(boolean|number)=} unsigned
77591
- * @param {number=} radix
77592
- * @returns {!Long}
77593
- * @inner
77594
- */
77595
- function fromString(str, unsigned, radix) {
77596
- if (str.length === 0)
77597
- throw Error('empty string');
77598
- if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
77599
- return ZERO;
77600
- if (typeof unsigned === 'number') {
77601
- // For goog.math.long compatibility
77602
- radix = unsigned,
77603
- unsigned = false;
77604
- } else {
77605
- unsigned = !! unsigned;
77606
- }
77607
- radix = radix || 10;
77608
- if (radix < 2 || 36 < radix)
77609
- throw RangeError('radix');
77610
-
77611
- var p;
77612
- if ((p = str.indexOf('-')) > 0)
77613
- throw Error('interior hyphen');
77614
- else if (p === 0) {
77615
- return fromString(str.substring(1), unsigned, radix).neg();
77616
- }
77617
-
77618
- // Do several (8) digits each time through the loop, so as to
77619
- // minimize the calls to the very expensive emulated div.
77620
- var radixToPower = fromNumber(pow_dbl(radix, 8));
77621
-
77622
- var result = ZERO;
77623
- for (var i = 0; i < str.length; i += 8) {
77624
- var size = Math.min(8, str.length - i),
77625
- value = parseInt(str.substring(i, i + size), radix);
77626
- if (size < 8) {
77627
- var power = fromNumber(pow_dbl(radix, size));
77628
- result = result.mul(power).add(fromNumber(value));
77629
- } else {
77630
- result = result.mul(radixToPower);
77631
- result = result.add(fromNumber(value));
77632
- }
77633
- }
77634
- result.unsigned = unsigned;
77635
- return result;
77636
- }
77637
-
77638
- /**
77639
- * Returns a Long representation of the given string, written using the specified radix.
77640
- * @function
77641
- * @param {string} str The textual representation of the Long
77642
- * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to `false` for signed
77643
- * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
77644
- * @returns {!Long} The corresponding Long value
77645
- */
77646
- Long.fromString = fromString;
77647
-
77648
- /**
77649
- * @function
77650
- * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
77651
- * @returns {!Long}
77652
- * @inner
77653
- */
77654
- function fromValue(val) {
77655
- if (val /* is compatible */ instanceof Long)
77656
- return val;
77657
- if (typeof val === 'number')
77658
- return fromNumber(val);
77659
- if (typeof val === 'string')
77660
- return fromString(val);
77661
- // Throws for non-objects, converts non-instanceof Long:
77662
- return fromBits(val.low, val.high, val.unsigned);
77663
- }
77664
-
77665
- /**
77666
- * Converts the specified value to a Long.
77667
- * @function
77668
- * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
77669
- * @returns {!Long}
77670
- */
77671
- Long.fromValue = fromValue;
77672
-
77673
- // NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
77674
- // no runtime penalty for these.
77675
-
77676
- /**
77677
- * @type {number}
77678
- * @const
77679
- * @inner
77680
- */
77681
- var TWO_PWR_16_DBL = 1 << 16;
77682
-
77683
- /**
77684
- * @type {number}
77685
- * @const
77686
- * @inner
77687
- */
77688
- var TWO_PWR_24_DBL = 1 << 24;
77689
-
77690
- /**
77691
- * @type {number}
77692
- * @const
77693
- * @inner
77694
- */
77695
- var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
77696
-
77697
- /**
77698
- * @type {number}
77699
- * @const
77700
- * @inner
77701
- */
77702
- var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
77703
-
77704
- /**
77705
- * @type {number}
77706
- * @const
77707
- * @inner
77708
- */
77709
- var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
77710
-
77711
- /**
77712
- * @type {!Long}
77713
- * @const
77714
- * @inner
77715
- */
77716
- var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
77717
-
77718
- /**
77719
- * @type {!Long}
77720
- * @inner
77721
- */
77722
- var ZERO = fromInt(0);
77723
-
77724
- /**
77725
- * Signed zero.
77726
- * @type {!Long}
77727
- */
77728
- Long.ZERO = ZERO;
77729
-
77730
- /**
77731
- * @type {!Long}
77732
- * @inner
77733
- */
77734
- var UZERO = fromInt(0, true);
77735
-
77736
- /**
77737
- * Unsigned zero.
77738
- * @type {!Long}
77739
- */
77740
- Long.UZERO = UZERO;
77741
-
77742
- /**
77743
- * @type {!Long}
77744
- * @inner
77745
- */
77746
- var ONE = fromInt(1);
77747
-
77748
- /**
77749
- * Signed one.
77750
- * @type {!Long}
77751
- */
77752
- Long.ONE = ONE;
77753
-
77754
- /**
77755
- * @type {!Long}
77756
- * @inner
77757
- */
77758
- var UONE = fromInt(1, true);
77759
-
77760
- /**
77761
- * Unsigned one.
77762
- * @type {!Long}
77763
- */
77764
- Long.UONE = UONE;
77765
-
77766
- /**
77767
- * @type {!Long}
77768
- * @inner
77769
- */
77770
- var NEG_ONE = fromInt(-1);
77771
-
77772
- /**
77773
- * Signed negative one.
77774
- * @type {!Long}
77775
- */
77776
- Long.NEG_ONE = NEG_ONE;
77777
-
77778
- /**
77779
- * @type {!Long}
77780
- * @inner
77781
- */
77782
- var MAX_VALUE = fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false);
77783
-
77784
- /**
77785
- * Maximum signed value.
77786
- * @type {!Long}
77787
- */
77788
- Long.MAX_VALUE = MAX_VALUE;
77789
-
77790
- /**
77791
- * @type {!Long}
77792
- * @inner
77793
- */
77794
- var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true);
77795
-
77796
- /**
77797
- * Maximum unsigned value.
77798
- * @type {!Long}
77799
- */
77800
- Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
77801
-
77802
- /**
77803
- * @type {!Long}
77804
- * @inner
77805
- */
77806
- var MIN_VALUE = fromBits(0, 0x80000000|0, false);
77807
-
77808
- /**
77809
- * Minimum signed value.
77810
- * @type {!Long}
77811
- */
77812
- Long.MIN_VALUE = MIN_VALUE;
77813
-
77814
- /**
77815
- * @alias Long.prototype
77816
- * @inner
77817
- */
77818
- var LongPrototype = Long.prototype;
77819
-
77820
- /**
77821
- * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
77822
- * @returns {number}
77823
- */
77824
- LongPrototype.toInt = function toInt() {
77825
- return this.unsigned ? this.low >>> 0 : this.low;
77826
- };
77827
-
77828
- /**
77829
- * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
77830
- * @returns {number}
77831
- */
77832
- LongPrototype.toNumber = function toNumber() {
77833
- if (this.unsigned)
77834
- return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);
77835
- return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
77836
- };
77837
-
77838
- /**
77839
- * Converts the Long to a string written in the specified radix.
77840
- * @param {number=} radix Radix (2-36), defaults to 10
77841
- * @returns {string}
77842
- * @override
77843
- * @throws {RangeError} If `radix` is out of range
77844
- */
77845
- LongPrototype.toString = function toString(radix) {
77846
- radix = radix || 10;
77847
- if (radix < 2 || 36 < radix)
77848
- throw RangeError('radix');
77849
- if (this.isZero())
77850
- return '0';
77851
- if (this.isNegative()) { // Unsigned Longs are never negative
77852
- if (this.eq(MIN_VALUE)) {
77853
- // We need to change the Long value before it can be negated, so we remove
77854
- // the bottom-most digit in this base and then recurse to do the rest.
77855
- var radixLong = fromNumber(radix),
77856
- div = this.div(radixLong),
77857
- rem1 = div.mul(radixLong).sub(this);
77858
- return div.toString(radix) + rem1.toInt().toString(radix);
77859
- } else
77860
- return '-' + this.neg().toString(radix);
77861
- }
77862
-
77863
- // Do several (6) digits each time through the loop, so as to
77864
- // minimize the calls to the very expensive emulated div.
77865
- var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned),
77866
- rem = this;
77867
- var result = '';
77868
- while (true) {
77869
- var remDiv = rem.div(radixToPower),
77870
- intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0,
77871
- digits = intval.toString(radix);
77872
- rem = remDiv;
77873
- if (rem.isZero())
77874
- return digits + result;
77875
- else {
77876
- while (digits.length < 6)
77877
- digits = '0' + digits;
77878
- result = '' + digits + result;
77879
- }
77880
- }
77881
- };
77882
-
77883
- /**
77884
- * Gets the high 32 bits as a signed integer.
77885
- * @returns {number} Signed high bits
77886
- */
77887
- LongPrototype.getHighBits = function getHighBits() {
77888
- return this.high;
77889
- };
77890
-
77891
- /**
77892
- * Gets the high 32 bits as an unsigned integer.
77893
- * @returns {number} Unsigned high bits
77894
- */
77895
- LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
77896
- return this.high >>> 0;
77897
- };
77898
-
77899
- /**
77900
- * Gets the low 32 bits as a signed integer.
77901
- * @returns {number} Signed low bits
77902
- */
77903
- LongPrototype.getLowBits = function getLowBits() {
77904
- return this.low;
77905
- };
77906
-
77907
- /**
77908
- * Gets the low 32 bits as an unsigned integer.
77909
- * @returns {number} Unsigned low bits
77910
- */
77911
- LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
77912
- return this.low >>> 0;
77913
- };
77914
-
77915
- /**
77916
- * Gets the number of bits needed to represent the absolute value of this Long.
77917
- * @returns {number}
77918
- */
77919
- LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
77920
- if (this.isNegative()) // Unsigned Longs are never negative
77921
- return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
77922
- var val = this.high != 0 ? this.high : this.low;
77923
- for (var bit = 31; bit > 0; bit--)
77924
- if ((val & (1 << bit)) != 0)
77925
- break;
77926
- return this.high != 0 ? bit + 33 : bit + 1;
77927
- };
77928
-
77929
- /**
77930
- * Tests if this Long's value equals zero.
77931
- * @returns {boolean}
77932
- */
77933
- LongPrototype.isZero = function isZero() {
77934
- return this.high === 0 && this.low === 0;
77935
- };
77936
-
77937
- /**
77938
- * Tests if this Long's value is negative.
77939
- * @returns {boolean}
77940
- */
77941
- LongPrototype.isNegative = function isNegative() {
77942
- return !this.unsigned && this.high < 0;
77943
- };
77944
-
77945
- /**
77946
- * Tests if this Long's value is positive.
77947
- * @returns {boolean}
77948
- */
77949
- LongPrototype.isPositive = function isPositive() {
77950
- return this.unsigned || this.high >= 0;
77951
- };
77952
-
77953
- /**
77954
- * Tests if this Long's value is odd.
77955
- * @returns {boolean}
77956
- */
77957
- LongPrototype.isOdd = function isOdd() {
77958
- return (this.low & 1) === 1;
77959
- };
77960
-
77961
- /**
77962
- * Tests if this Long's value is even.
77963
- * @returns {boolean}
77964
- */
77965
- LongPrototype.isEven = function isEven() {
77966
- return (this.low & 1) === 0;
77967
- };
77968
-
77969
- /**
77970
- * Tests if this Long's value equals the specified's.
77971
- * @param {!Long|number|string} other Other value
77972
- * @returns {boolean}
77973
- */
77974
- LongPrototype.equals = function equals(other) {
77975
- if (!isLong(other))
77976
- other = fromValue(other);
77977
- if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1)
77978
- return false;
77979
- return this.high === other.high && this.low === other.low;
77980
- };
77981
-
77982
- /**
77983
- * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
77984
- * @function
77985
- * @param {!Long|number|string} other Other value
77986
- * @returns {boolean}
77987
- */
77988
- LongPrototype.eq = LongPrototype.equals;
77989
-
77990
- /**
77991
- * Tests if this Long's value differs from the specified's.
77992
- * @param {!Long|number|string} other Other value
77993
- * @returns {boolean}
77994
- */
77995
- LongPrototype.notEquals = function notEquals(other) {
77996
- return !this.eq(/* validates */ other);
77997
- };
77998
-
77999
- /**
78000
- * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
78001
- * @function
78002
- * @param {!Long|number|string} other Other value
78003
- * @returns {boolean}
78004
- */
78005
- LongPrototype.neq = LongPrototype.notEquals;
78006
-
78007
- /**
78008
- * Tests if this Long's value is less than the specified's.
78009
- * @param {!Long|number|string} other Other value
78010
- * @returns {boolean}
78011
- */
78012
- LongPrototype.lessThan = function lessThan(other) {
78013
- return this.comp(/* validates */ other) < 0;
78014
- };
78015
-
78016
- /**
78017
- * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
78018
- * @function
78019
- * @param {!Long|number|string} other Other value
78020
- * @returns {boolean}
78021
- */
78022
- LongPrototype.lt = LongPrototype.lessThan;
78023
-
78024
- /**
78025
- * Tests if this Long's value is less than or equal the specified's.
78026
- * @param {!Long|number|string} other Other value
78027
- * @returns {boolean}
78028
- */
78029
- LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
78030
- return this.comp(/* validates */ other) <= 0;
78031
- };
78032
-
78033
- /**
78034
- * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
78035
- * @function
78036
- * @param {!Long|number|string} other Other value
78037
- * @returns {boolean}
78038
- */
78039
- LongPrototype.lte = LongPrototype.lessThanOrEqual;
78040
-
78041
- /**
78042
- * Tests if this Long's value is greater than the specified's.
78043
- * @param {!Long|number|string} other Other value
78044
- * @returns {boolean}
78045
- */
78046
- LongPrototype.greaterThan = function greaterThan(other) {
78047
- return this.comp(/* validates */ other) > 0;
78048
- };
78049
-
78050
- /**
78051
- * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
78052
- * @function
78053
- * @param {!Long|number|string} other Other value
78054
- * @returns {boolean}
78055
- */
78056
- LongPrototype.gt = LongPrototype.greaterThan;
78057
-
78058
- /**
78059
- * Tests if this Long's value is greater than or equal the specified's.
78060
- * @param {!Long|number|string} other Other value
78061
- * @returns {boolean}
78062
- */
78063
- LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
78064
- return this.comp(/* validates */ other) >= 0;
78065
- };
78066
-
78067
- /**
78068
- * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
78069
- * @function
78070
- * @param {!Long|number|string} other Other value
78071
- * @returns {boolean}
78072
- */
78073
- LongPrototype.gte = LongPrototype.greaterThanOrEqual;
78074
-
78075
- /**
78076
- * Compares this Long's value with the specified's.
78077
- * @param {!Long|number|string} other Other value
78078
- * @returns {number} 0 if they are the same, 1 if the this is greater and -1
78079
- * if the given one is greater
78080
- */
78081
- LongPrototype.compare = function compare(other) {
78082
- if (!isLong(other))
78083
- other = fromValue(other);
78084
- if (this.eq(other))
78085
- return 0;
78086
- var thisNeg = this.isNegative(),
78087
- otherNeg = other.isNegative();
78088
- if (thisNeg && !otherNeg)
78089
- return -1;
78090
- if (!thisNeg && otherNeg)
78091
- return 1;
78092
- // At this point the sign bits are the same
78093
- if (!this.unsigned)
78094
- return this.sub(other).isNegative() ? -1 : 1;
78095
- // Both are positive if at least one is unsigned
78096
- return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
78097
- };
78098
-
78099
- /**
78100
- * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
78101
- * @function
78102
- * @param {!Long|number|string} other Other value
78103
- * @returns {number} 0 if they are the same, 1 if the this is greater and -1
78104
- * if the given one is greater
78105
- */
78106
- LongPrototype.comp = LongPrototype.compare;
78107
-
78108
- /**
78109
- * Negates this Long's value.
78110
- * @returns {!Long} Negated Long
78111
- */
78112
- LongPrototype.negate = function negate() {
78113
- if (!this.unsigned && this.eq(MIN_VALUE))
78114
- return MIN_VALUE;
78115
- return this.not().add(ONE);
78116
- };
78117
-
78118
- /**
78119
- * Negates this Long's value. This is an alias of {@link Long#negate}.
78120
- * @function
78121
- * @returns {!Long} Negated Long
78122
- */
78123
- LongPrototype.neg = LongPrototype.negate;
78124
-
78125
- /**
78126
- * Returns the sum of this and the specified Long.
78127
- * @param {!Long|number|string} addend Addend
78128
- * @returns {!Long} Sum
78129
- */
78130
- LongPrototype.add = function add(addend) {
78131
- if (!isLong(addend))
78132
- addend = fromValue(addend);
78133
-
78134
- // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
78135
-
78136
- var a48 = this.high >>> 16;
78137
- var a32 = this.high & 0xFFFF;
78138
- var a16 = this.low >>> 16;
78139
- var a00 = this.low & 0xFFFF;
78140
-
78141
- var b48 = addend.high >>> 16;
78142
- var b32 = addend.high & 0xFFFF;
78143
- var b16 = addend.low >>> 16;
78144
- var b00 = addend.low & 0xFFFF;
78145
-
78146
- var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
78147
- c00 += a00 + b00;
78148
- c16 += c00 >>> 16;
78149
- c00 &= 0xFFFF;
78150
- c16 += a16 + b16;
78151
- c32 += c16 >>> 16;
78152
- c16 &= 0xFFFF;
78153
- c32 += a32 + b32;
78154
- c48 += c32 >>> 16;
78155
- c32 &= 0xFFFF;
78156
- c48 += a48 + b48;
78157
- c48 &= 0xFFFF;
78158
- return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
78159
- };
78160
-
78161
- /**
78162
- * Returns the difference of this and the specified Long.
78163
- * @param {!Long|number|string} subtrahend Subtrahend
78164
- * @returns {!Long} Difference
78165
- */
78166
- LongPrototype.subtract = function subtract(subtrahend) {
78167
- if (!isLong(subtrahend))
78168
- subtrahend = fromValue(subtrahend);
78169
- return this.add(subtrahend.neg());
78170
- };
78171
-
78172
- /**
78173
- * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
78174
- * @function
78175
- * @param {!Long|number|string} subtrahend Subtrahend
78176
- * @returns {!Long} Difference
78177
- */
78178
- LongPrototype.sub = LongPrototype.subtract;
78179
-
78180
- /**
78181
- * Returns the product of this and the specified Long.
78182
- * @param {!Long|number|string} multiplier Multiplier
78183
- * @returns {!Long} Product
78184
- */
78185
- LongPrototype.multiply = function multiply(multiplier) {
78186
- if (this.isZero())
78187
- return ZERO;
78188
- if (!isLong(multiplier))
78189
- multiplier = fromValue(multiplier);
78190
- if (multiplier.isZero())
78191
- return ZERO;
78192
- if (this.eq(MIN_VALUE))
78193
- return multiplier.isOdd() ? MIN_VALUE : ZERO;
78194
- if (multiplier.eq(MIN_VALUE))
78195
- return this.isOdd() ? MIN_VALUE : ZERO;
78196
-
78197
- if (this.isNegative()) {
78198
- if (multiplier.isNegative())
78199
- return this.neg().mul(multiplier.neg());
78200
- else
78201
- return this.neg().mul(multiplier).neg();
78202
- } else if (multiplier.isNegative())
78203
- return this.mul(multiplier.neg()).neg();
78204
-
78205
- // If both longs are small, use float multiplication
78206
- if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))
78207
- return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
78208
-
78209
- // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
78210
- // We can skip products that would overflow.
78211
-
78212
- var a48 = this.high >>> 16;
78213
- var a32 = this.high & 0xFFFF;
78214
- var a16 = this.low >>> 16;
78215
- var a00 = this.low & 0xFFFF;
78216
-
78217
- var b48 = multiplier.high >>> 16;
78218
- var b32 = multiplier.high & 0xFFFF;
78219
- var b16 = multiplier.low >>> 16;
78220
- var b00 = multiplier.low & 0xFFFF;
78221
-
78222
- var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
78223
- c00 += a00 * b00;
78224
- c16 += c00 >>> 16;
78225
- c00 &= 0xFFFF;
78226
- c16 += a16 * b00;
78227
- c32 += c16 >>> 16;
78228
- c16 &= 0xFFFF;
78229
- c16 += a00 * b16;
78230
- c32 += c16 >>> 16;
78231
- c16 &= 0xFFFF;
78232
- c32 += a32 * b00;
78233
- c48 += c32 >>> 16;
78234
- c32 &= 0xFFFF;
78235
- c32 += a16 * b16;
78236
- c48 += c32 >>> 16;
78237
- c32 &= 0xFFFF;
78238
- c32 += a00 * b32;
78239
- c48 += c32 >>> 16;
78240
- c32 &= 0xFFFF;
78241
- c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
78242
- c48 &= 0xFFFF;
78243
- return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
78244
- };
78245
-
78246
- /**
78247
- * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
78248
- * @function
78249
- * @param {!Long|number|string} multiplier Multiplier
78250
- * @returns {!Long} Product
78251
- */
78252
- LongPrototype.mul = LongPrototype.multiply;
78253
-
78254
- /**
78255
- * Returns this Long divided by the specified. The result is signed if this Long is signed or
78256
- * unsigned if this Long is unsigned.
78257
- * @param {!Long|number|string} divisor Divisor
78258
- * @returns {!Long} Quotient
78259
- */
78260
- LongPrototype.divide = function divide(divisor) {
78261
- if (!isLong(divisor))
78262
- divisor = fromValue(divisor);
78263
- if (divisor.isZero())
78264
- throw Error('division by zero');
78265
- if (this.isZero())
78266
- return this.unsigned ? UZERO : ZERO;
78267
- var approx, rem, res;
78268
- if (!this.unsigned) {
78269
- // This section is only relevant for signed longs and is derived from the
78270
- // closure library as a whole.
78271
- if (this.eq(MIN_VALUE)) {
78272
- if (divisor.eq(ONE) || divisor.eq(NEG_ONE))
78273
- return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
78274
- else if (divisor.eq(MIN_VALUE))
78275
- return ONE;
78276
- else {
78277
- // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
78278
- var halfThis = this.shr(1);
78279
- approx = halfThis.div(divisor).shl(1);
78280
- if (approx.eq(ZERO)) {
78281
- return divisor.isNegative() ? ONE : NEG_ONE;
78282
- } else {
78283
- rem = this.sub(divisor.mul(approx));
78284
- res = approx.add(rem.div(divisor));
78285
- return res;
78286
- }
78287
- }
78288
- } else if (divisor.eq(MIN_VALUE))
78289
- return this.unsigned ? UZERO : ZERO;
78290
- if (this.isNegative()) {
78291
- if (divisor.isNegative())
78292
- return this.neg().div(divisor.neg());
78293
- return this.neg().div(divisor).neg();
78294
- } else if (divisor.isNegative())
78295
- return this.div(divisor.neg()).neg();
78296
- res = ZERO;
78297
- } else {
78298
- // The algorithm below has not been made for unsigned longs. It's therefore
78299
- // required to take special care of the MSB prior to running it.
78300
- if (!divisor.unsigned)
78301
- divisor = divisor.toUnsigned();
78302
- if (divisor.gt(this))
78303
- return UZERO;
78304
- if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true
78305
- return UONE;
78306
- res = UZERO;
78307
- }
78308
-
78309
- // Repeat the following until the remainder is less than other: find a
78310
- // floating-point that approximates remainder / other *from below*, add this
78311
- // into the result, and subtract it from the remainder. It is critical that
78312
- // the approximate value is less than or equal to the real value so that the
78313
- // remainder never becomes negative.
78314
- rem = this;
78315
- while (rem.gte(divisor)) {
78316
- // Approximate the result of division. This may be a little greater or
78317
- // smaller than the actual value.
78318
- approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
78319
-
78320
- // We will tweak the approximate result by changing it in the 48-th digit or
78321
- // the smallest non-fractional digit, whichever is larger.
78322
- var log2 = Math.ceil(Math.log(approx) / Math.LN2),
78323
- delta = (log2 <= 48) ? 1 : pow_dbl(2, log2 - 48),
78324
-
78325
- // Decrease the approximation until it is smaller than the remainder. Note
78326
- // that if it is too large, the product overflows and is negative.
78327
- approxRes = fromNumber(approx),
78328
- approxRem = approxRes.mul(divisor);
78329
- while (approxRem.isNegative() || approxRem.gt(rem)) {
78330
- approx -= delta;
78331
- approxRes = fromNumber(approx, this.unsigned);
78332
- approxRem = approxRes.mul(divisor);
78333
- }
78334
-
78335
- // We know the answer can't be zero... and actually, zero would cause
78336
- // infinite recursion since we would make no progress.
78337
- if (approxRes.isZero())
78338
- approxRes = ONE;
78339
-
78340
- res = res.add(approxRes);
78341
- rem = rem.sub(approxRem);
78342
- }
78343
- return res;
78344
- };
78345
-
78346
- /**
78347
- * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
78348
- * @function
78349
- * @param {!Long|number|string} divisor Divisor
78350
- * @returns {!Long} Quotient
78351
- */
78352
- LongPrototype.div = LongPrototype.divide;
78353
-
78354
- /**
78355
- * Returns this Long modulo the specified.
78356
- * @param {!Long|number|string} divisor Divisor
78357
- * @returns {!Long} Remainder
78358
- */
78359
- LongPrototype.modulo = function modulo(divisor) {
78360
- if (!isLong(divisor))
78361
- divisor = fromValue(divisor);
78362
- return this.sub(this.div(divisor).mul(divisor));
78363
- };
78364
-
78365
- /**
78366
- * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
78367
- * @function
78368
- * @param {!Long|number|string} divisor Divisor
78369
- * @returns {!Long} Remainder
78370
- */
78371
- LongPrototype.mod = LongPrototype.modulo;
78372
-
78373
- /**
78374
- * Returns the bitwise NOT of this Long.
78375
- * @returns {!Long}
78376
- */
78377
- LongPrototype.not = function not() {
78378
- return fromBits(~this.low, ~this.high, this.unsigned);
78379
- };
78380
-
78381
- /**
78382
- * Returns the bitwise AND of this Long and the specified.
78383
- * @param {!Long|number|string} other Other Long
78384
- * @returns {!Long}
78385
- */
78386
- LongPrototype.and = function and(other) {
78387
- if (!isLong(other))
78388
- other = fromValue(other);
78389
- return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
78390
- };
78391
-
78392
- /**
78393
- * Returns the bitwise OR of this Long and the specified.
78394
- * @param {!Long|number|string} other Other Long
78395
- * @returns {!Long}
78396
- */
78397
- LongPrototype.or = function or(other) {
78398
- if (!isLong(other))
78399
- other = fromValue(other);
78400
- return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
78401
- };
78402
-
78403
- /**
78404
- * Returns the bitwise XOR of this Long and the given one.
78405
- * @param {!Long|number|string} other Other Long
78406
- * @returns {!Long}
78407
- */
78408
- LongPrototype.xor = function xor(other) {
78409
- if (!isLong(other))
78410
- other = fromValue(other);
78411
- return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
78412
- };
78413
-
78414
- /**
78415
- * Returns this Long with bits shifted to the left by the given amount.
78416
- * @param {number|!Long} numBits Number of bits
78417
- * @returns {!Long} Shifted Long
78418
- */
78419
- LongPrototype.shiftLeft = function shiftLeft(numBits) {
78420
- if (isLong(numBits))
78421
- numBits = numBits.toInt();
78422
- if ((numBits &= 63) === 0)
78423
- return this;
78424
- else if (numBits < 32)
78425
- return fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
78426
- else
78427
- return fromBits(0, this.low << (numBits - 32), this.unsigned);
78428
- };
78429
-
78430
- /**
78431
- * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
78432
- * @function
78433
- * @param {number|!Long} numBits Number of bits
78434
- * @returns {!Long} Shifted Long
78435
- */
78436
- LongPrototype.shl = LongPrototype.shiftLeft;
78437
-
78438
- /**
78439
- * Returns this Long with bits arithmetically shifted to the right by the given amount.
78440
- * @param {number|!Long} numBits Number of bits
78441
- * @returns {!Long} Shifted Long
78442
- */
78443
- LongPrototype.shiftRight = function shiftRight(numBits) {
78444
- if (isLong(numBits))
78445
- numBits = numBits.toInt();
78446
- if ((numBits &= 63) === 0)
78447
- return this;
78448
- else if (numBits < 32)
78449
- return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
78450
- else
78451
- return fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
78452
- };
78453
-
78454
- /**
78455
- * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
78456
- * @function
78457
- * @param {number|!Long} numBits Number of bits
78458
- * @returns {!Long} Shifted Long
78459
- */
78460
- LongPrototype.shr = LongPrototype.shiftRight;
78461
-
78462
- /**
78463
- * Returns this Long with bits logically shifted to the right by the given amount.
78464
- * @param {number|!Long} numBits Number of bits
78465
- * @returns {!Long} Shifted Long
78466
- */
78467
- LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
78468
- if (isLong(numBits))
78469
- numBits = numBits.toInt();
78470
- numBits &= 63;
78471
- if (numBits === 0)
78472
- return this;
78473
- else {
78474
- var high = this.high;
78475
- if (numBits < 32) {
78476
- var low = this.low;
78477
- return fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
78478
- } else if (numBits === 32)
78479
- return fromBits(high, 0, this.unsigned);
78480
- else
78481
- return fromBits(high >>> (numBits - 32), 0, this.unsigned);
78482
- }
78483
- };
78484
-
78485
- /**
78486
- * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
78487
- * @function
78488
- * @param {number|!Long} numBits Number of bits
78489
- * @returns {!Long} Shifted Long
78490
- */
78491
- LongPrototype.shru = LongPrototype.shiftRightUnsigned;
78492
-
78493
- /**
78494
- * Converts this Long to signed.
78495
- * @returns {!Long} Signed long
78496
- */
78497
- LongPrototype.toSigned = function toSigned() {
78498
- if (!this.unsigned)
78499
- return this;
78500
- return fromBits(this.low, this.high, false);
78501
- };
78502
-
78503
- /**
78504
- * Converts this Long to unsigned.
78505
- * @returns {!Long} Unsigned long
78506
- */
78507
- LongPrototype.toUnsigned = function toUnsigned() {
78508
- if (this.unsigned)
78509
- return this;
78510
- return fromBits(this.low, this.high, true);
78511
- };
78512
-
78513
- /**
78514
- * Converts this Long to its byte representation.
78515
- * @param {boolean=} le Whether little or big endian, defaults to big endian
78516
- * @returns {!Array.<number>} Byte representation
78517
- */
78518
- LongPrototype.toBytes = function(le) {
78519
- return le ? this.toBytesLE() : this.toBytesBE();
78520
- };
78521
-
78522
- /**
78523
- * Converts this Long to its little endian byte representation.
78524
- * @returns {!Array.<number>} Little endian byte representation
78525
- */
78526
- LongPrototype.toBytesLE = function() {
78527
- var hi = this.high,
78528
- lo = this.low;
78529
- return [
78530
- lo & 0xff,
78531
- (lo >>> 8) & 0xff,
78532
- (lo >>> 16) & 0xff,
78533
- (lo >>> 24) & 0xff,
78534
- hi & 0xff,
78535
- (hi >>> 8) & 0xff,
78536
- (hi >>> 16) & 0xff,
78537
- (hi >>> 24) & 0xff
78538
- ];
78539
- };
78540
-
78541
- /**
78542
- * Converts this Long to its big endian byte representation.
78543
- * @returns {!Array.<number>} Big endian byte representation
78544
- */
78545
- LongPrototype.toBytesBE = function() {
78546
- var hi = this.high,
78547
- lo = this.low;
78548
- return [
78549
- (hi >>> 24) & 0xff,
78550
- (hi >>> 16) & 0xff,
78551
- (hi >>> 8) & 0xff,
78552
- hi & 0xff,
78553
- (lo >>> 24) & 0xff,
78554
- (lo >>> 16) & 0xff,
78555
- (lo >>> 8) & 0xff,
78556
- lo & 0xff
78557
- ];
78558
- };
78559
-
78560
- return Long;
77373
+ /**
77374
+ * @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
77375
+ * Released under the Apache License, Version 2.0
77376
+ * see: https://github.com/dcodeIO/long.js for details
77377
+ */
77378
+ (function(global, factory) {
77379
+
77380
+ /* AMD */ if (typeof commonjsRequire === 'function' && 'object' === "object" && module && module["exports"])
77381
+ module["exports"] = factory();
77382
+ /* Global */ else
77383
+ (global["dcodeIO"] = global["dcodeIO"] || {})["Long"] = factory();
77384
+
77385
+ })(commonjsGlobal, function() {
77386
+
77387
+ /**
77388
+ * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.
77389
+ * See the from* functions below for more convenient ways of constructing Longs.
77390
+ * @exports Long
77391
+ * @class A Long class for representing a 64 bit two's-complement integer value.
77392
+ * @param {number} low The low (signed) 32 bits of the long
77393
+ * @param {number} high The high (signed) 32 bits of the long
77394
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77395
+ * @constructor
77396
+ */
77397
+ function Long(low, high, unsigned) {
77398
+
77399
+ /**
77400
+ * The low 32 bits as a signed value.
77401
+ * @type {number}
77402
+ */
77403
+ this.low = low | 0;
77404
+
77405
+ /**
77406
+ * The high 32 bits as a signed value.
77407
+ * @type {number}
77408
+ */
77409
+ this.high = high | 0;
77410
+
77411
+ /**
77412
+ * Whether unsigned or not.
77413
+ * @type {boolean}
77414
+ */
77415
+ this.unsigned = !!unsigned;
77416
+ }
77417
+
77418
+ // The internal representation of a long is the two given signed, 32-bit values.
77419
+ // We use 32-bit pieces because these are the size of integers on which
77420
+ // Javascript performs bit-operations. For operations like addition and
77421
+ // multiplication, we split each number into 16 bit pieces, which can easily be
77422
+ // multiplied within Javascript's floating-point representation without overflow
77423
+ // or change in sign.
77424
+ //
77425
+ // In the algorithms below, we frequently reduce the negative case to the
77426
+ // positive case by negating the input(s) and then post-processing the result.
77427
+ // Note that we must ALWAYS check specially whether those values are MIN_VALUE
77428
+ // (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as
77429
+ // a positive number, it overflows back into a negative). Not handling this
77430
+ // case would often result in infinite recursion.
77431
+ //
77432
+ // Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
77433
+ // methods on which they depend.
77434
+
77435
+ /**
77436
+ * An indicator used to reliably determine if an object is a Long or not.
77437
+ * @type {boolean}
77438
+ * @const
77439
+ * @private
77440
+ */
77441
+ Long.prototype.__isLong__;
77442
+
77443
+ Object.defineProperty(Long.prototype, "__isLong__", {
77444
+ value: true,
77445
+ enumerable: false,
77446
+ configurable: false
77447
+ });
77448
+
77449
+ /**
77450
+ * @function
77451
+ * @param {*} obj Object
77452
+ * @returns {boolean}
77453
+ * @inner
77454
+ */
77455
+ function isLong(obj) {
77456
+ return (obj && obj["__isLong__"]) === true;
77457
+ }
77458
+
77459
+ /**
77460
+ * Tests if the specified object is a Long.
77461
+ * @function
77462
+ * @param {*} obj Object
77463
+ * @returns {boolean}
77464
+ */
77465
+ Long.isLong = isLong;
77466
+
77467
+ /**
77468
+ * A cache of the Long representations of small integer values.
77469
+ * @type {!Object}
77470
+ * @inner
77471
+ */
77472
+ var INT_CACHE = {};
77473
+
77474
+ /**
77475
+ * A cache of the Long representations of small unsigned integer values.
77476
+ * @type {!Object}
77477
+ * @inner
77478
+ */
77479
+ var UINT_CACHE = {};
77480
+
77481
+ /**
77482
+ * @param {number} value
77483
+ * @param {boolean=} unsigned
77484
+ * @returns {!Long}
77485
+ * @inner
77486
+ */
77487
+ function fromInt(value, unsigned) {
77488
+ var obj, cachedObj, cache;
77489
+ if (unsigned) {
77490
+ value >>>= 0;
77491
+ if (cache = (0 <= value && value < 256)) {
77492
+ cachedObj = UINT_CACHE[value];
77493
+ if (cachedObj)
77494
+ return cachedObj;
77495
+ }
77496
+ obj = fromBits(value, (value | 0) < 0 ? -1 : 0, true);
77497
+ if (cache)
77498
+ UINT_CACHE[value] = obj;
77499
+ return obj;
77500
+ } else {
77501
+ value |= 0;
77502
+ if (cache = (-128 <= value && value < 128)) {
77503
+ cachedObj = INT_CACHE[value];
77504
+ if (cachedObj)
77505
+ return cachedObj;
77506
+ }
77507
+ obj = fromBits(value, value < 0 ? -1 : 0, false);
77508
+ if (cache)
77509
+ INT_CACHE[value] = obj;
77510
+ return obj;
77511
+ }
77512
+ }
77513
+
77514
+ /**
77515
+ * Returns a Long representing the given 32 bit integer value.
77516
+ * @function
77517
+ * @param {number} value The 32 bit integer in question
77518
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77519
+ * @returns {!Long} The corresponding Long value
77520
+ */
77521
+ Long.fromInt = fromInt;
77522
+
77523
+ /**
77524
+ * @param {number} value
77525
+ * @param {boolean=} unsigned
77526
+ * @returns {!Long}
77527
+ * @inner
77528
+ */
77529
+ function fromNumber(value, unsigned) {
77530
+ if (isNaN(value) || !isFinite(value))
77531
+ return unsigned ? UZERO : ZERO;
77532
+ if (unsigned) {
77533
+ if (value < 0)
77534
+ return UZERO;
77535
+ if (value >= TWO_PWR_64_DBL)
77536
+ return MAX_UNSIGNED_VALUE;
77537
+ } else {
77538
+ if (value <= -TWO_PWR_63_DBL)
77539
+ return MIN_VALUE;
77540
+ if (value + 1 >= TWO_PWR_63_DBL)
77541
+ return MAX_VALUE;
77542
+ }
77543
+ if (value < 0)
77544
+ return fromNumber(-value, unsigned).neg();
77545
+ return fromBits((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
77546
+ }
77547
+
77548
+ /**
77549
+ * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.
77550
+ * @function
77551
+ * @param {number} value The number in question
77552
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77553
+ * @returns {!Long} The corresponding Long value
77554
+ */
77555
+ Long.fromNumber = fromNumber;
77556
+
77557
+ /**
77558
+ * @param {number} lowBits
77559
+ * @param {number} highBits
77560
+ * @param {boolean=} unsigned
77561
+ * @returns {!Long}
77562
+ * @inner
77563
+ */
77564
+ function fromBits(lowBits, highBits, unsigned) {
77565
+ return new Long(lowBits, highBits, unsigned);
77566
+ }
77567
+
77568
+ /**
77569
+ * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is
77570
+ * assumed to use 32 bits.
77571
+ * @function
77572
+ * @param {number} lowBits The low 32 bits
77573
+ * @param {number} highBits The high 32 bits
77574
+ * @param {boolean=} unsigned Whether unsigned or not, defaults to `false` for signed
77575
+ * @returns {!Long} The corresponding Long value
77576
+ */
77577
+ Long.fromBits = fromBits;
77578
+
77579
+ /**
77580
+ * @function
77581
+ * @param {number} base
77582
+ * @param {number} exponent
77583
+ * @returns {number}
77584
+ * @inner
77585
+ */
77586
+ var pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)
77587
+
77588
+ /**
77589
+ * @param {string} str
77590
+ * @param {(boolean|number)=} unsigned
77591
+ * @param {number=} radix
77592
+ * @returns {!Long}
77593
+ * @inner
77594
+ */
77595
+ function fromString(str, unsigned, radix) {
77596
+ if (str.length === 0)
77597
+ throw Error('empty string');
77598
+ if (str === "NaN" || str === "Infinity" || str === "+Infinity" || str === "-Infinity")
77599
+ return ZERO;
77600
+ if (typeof unsigned === 'number') {
77601
+ // For goog.math.long compatibility
77602
+ radix = unsigned,
77603
+ unsigned = false;
77604
+ } else {
77605
+ unsigned = !! unsigned;
77606
+ }
77607
+ radix = radix || 10;
77608
+ if (radix < 2 || 36 < radix)
77609
+ throw RangeError('radix');
77610
+
77611
+ var p;
77612
+ if ((p = str.indexOf('-')) > 0)
77613
+ throw Error('interior hyphen');
77614
+ else if (p === 0) {
77615
+ return fromString(str.substring(1), unsigned, radix).neg();
77616
+ }
77617
+
77618
+ // Do several (8) digits each time through the loop, so as to
77619
+ // minimize the calls to the very expensive emulated div.
77620
+ var radixToPower = fromNumber(pow_dbl(radix, 8));
77621
+
77622
+ var result = ZERO;
77623
+ for (var i = 0; i < str.length; i += 8) {
77624
+ var size = Math.min(8, str.length - i),
77625
+ value = parseInt(str.substring(i, i + size), radix);
77626
+ if (size < 8) {
77627
+ var power = fromNumber(pow_dbl(radix, size));
77628
+ result = result.mul(power).add(fromNumber(value));
77629
+ } else {
77630
+ result = result.mul(radixToPower);
77631
+ result = result.add(fromNumber(value));
77632
+ }
77633
+ }
77634
+ result.unsigned = unsigned;
77635
+ return result;
77636
+ }
77637
+
77638
+ /**
77639
+ * Returns a Long representation of the given string, written using the specified radix.
77640
+ * @function
77641
+ * @param {string} str The textual representation of the Long
77642
+ * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to `false` for signed
77643
+ * @param {number=} radix The radix in which the text is written (2-36), defaults to 10
77644
+ * @returns {!Long} The corresponding Long value
77645
+ */
77646
+ Long.fromString = fromString;
77647
+
77648
+ /**
77649
+ * @function
77650
+ * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val
77651
+ * @returns {!Long}
77652
+ * @inner
77653
+ */
77654
+ function fromValue(val) {
77655
+ if (val /* is compatible */ instanceof Long)
77656
+ return val;
77657
+ if (typeof val === 'number')
77658
+ return fromNumber(val);
77659
+ if (typeof val === 'string')
77660
+ return fromString(val);
77661
+ // Throws for non-objects, converts non-instanceof Long:
77662
+ return fromBits(val.low, val.high, val.unsigned);
77663
+ }
77664
+
77665
+ /**
77666
+ * Converts the specified value to a Long.
77667
+ * @function
77668
+ * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value
77669
+ * @returns {!Long}
77670
+ */
77671
+ Long.fromValue = fromValue;
77672
+
77673
+ // NOTE: the compiler should inline these constant values below and then remove these variables, so there should be
77674
+ // no runtime penalty for these.
77675
+
77676
+ /**
77677
+ * @type {number}
77678
+ * @const
77679
+ * @inner
77680
+ */
77681
+ var TWO_PWR_16_DBL = 1 << 16;
77682
+
77683
+ /**
77684
+ * @type {number}
77685
+ * @const
77686
+ * @inner
77687
+ */
77688
+ var TWO_PWR_24_DBL = 1 << 24;
77689
+
77690
+ /**
77691
+ * @type {number}
77692
+ * @const
77693
+ * @inner
77694
+ */
77695
+ var TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
77696
+
77697
+ /**
77698
+ * @type {number}
77699
+ * @const
77700
+ * @inner
77701
+ */
77702
+ var TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
77703
+
77704
+ /**
77705
+ * @type {number}
77706
+ * @const
77707
+ * @inner
77708
+ */
77709
+ var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
77710
+
77711
+ /**
77712
+ * @type {!Long}
77713
+ * @const
77714
+ * @inner
77715
+ */
77716
+ var TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);
77717
+
77718
+ /**
77719
+ * @type {!Long}
77720
+ * @inner
77721
+ */
77722
+ var ZERO = fromInt(0);
77723
+
77724
+ /**
77725
+ * Signed zero.
77726
+ * @type {!Long}
77727
+ */
77728
+ Long.ZERO = ZERO;
77729
+
77730
+ /**
77731
+ * @type {!Long}
77732
+ * @inner
77733
+ */
77734
+ var UZERO = fromInt(0, true);
77735
+
77736
+ /**
77737
+ * Unsigned zero.
77738
+ * @type {!Long}
77739
+ */
77740
+ Long.UZERO = UZERO;
77741
+
77742
+ /**
77743
+ * @type {!Long}
77744
+ * @inner
77745
+ */
77746
+ var ONE = fromInt(1);
77747
+
77748
+ /**
77749
+ * Signed one.
77750
+ * @type {!Long}
77751
+ */
77752
+ Long.ONE = ONE;
77753
+
77754
+ /**
77755
+ * @type {!Long}
77756
+ * @inner
77757
+ */
77758
+ var UONE = fromInt(1, true);
77759
+
77760
+ /**
77761
+ * Unsigned one.
77762
+ * @type {!Long}
77763
+ */
77764
+ Long.UONE = UONE;
77765
+
77766
+ /**
77767
+ * @type {!Long}
77768
+ * @inner
77769
+ */
77770
+ var NEG_ONE = fromInt(-1);
77771
+
77772
+ /**
77773
+ * Signed negative one.
77774
+ * @type {!Long}
77775
+ */
77776
+ Long.NEG_ONE = NEG_ONE;
77777
+
77778
+ /**
77779
+ * @type {!Long}
77780
+ * @inner
77781
+ */
77782
+ var MAX_VALUE = fromBits(0xFFFFFFFF|0, 0x7FFFFFFF|0, false);
77783
+
77784
+ /**
77785
+ * Maximum signed value.
77786
+ * @type {!Long}
77787
+ */
77788
+ Long.MAX_VALUE = MAX_VALUE;
77789
+
77790
+ /**
77791
+ * @type {!Long}
77792
+ * @inner
77793
+ */
77794
+ var MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF|0, 0xFFFFFFFF|0, true);
77795
+
77796
+ /**
77797
+ * Maximum unsigned value.
77798
+ * @type {!Long}
77799
+ */
77800
+ Long.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;
77801
+
77802
+ /**
77803
+ * @type {!Long}
77804
+ * @inner
77805
+ */
77806
+ var MIN_VALUE = fromBits(0, 0x80000000|0, false);
77807
+
77808
+ /**
77809
+ * Minimum signed value.
77810
+ * @type {!Long}
77811
+ */
77812
+ Long.MIN_VALUE = MIN_VALUE;
77813
+
77814
+ /**
77815
+ * @alias Long.prototype
77816
+ * @inner
77817
+ */
77818
+ var LongPrototype = Long.prototype;
77819
+
77820
+ /**
77821
+ * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.
77822
+ * @returns {number}
77823
+ */
77824
+ LongPrototype.toInt = function toInt() {
77825
+ return this.unsigned ? this.low >>> 0 : this.low;
77826
+ };
77827
+
77828
+ /**
77829
+ * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).
77830
+ * @returns {number}
77831
+ */
77832
+ LongPrototype.toNumber = function toNumber() {
77833
+ if (this.unsigned)
77834
+ return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);
77835
+ return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
77836
+ };
77837
+
77838
+ /**
77839
+ * Converts the Long to a string written in the specified radix.
77840
+ * @param {number=} radix Radix (2-36), defaults to 10
77841
+ * @returns {string}
77842
+ * @override
77843
+ * @throws {RangeError} If `radix` is out of range
77844
+ */
77845
+ LongPrototype.toString = function toString(radix) {
77846
+ radix = radix || 10;
77847
+ if (radix < 2 || 36 < radix)
77848
+ throw RangeError('radix');
77849
+ if (this.isZero())
77850
+ return '0';
77851
+ if (this.isNegative()) { // Unsigned Longs are never negative
77852
+ if (this.eq(MIN_VALUE)) {
77853
+ // We need to change the Long value before it can be negated, so we remove
77854
+ // the bottom-most digit in this base and then recurse to do the rest.
77855
+ var radixLong = fromNumber(radix),
77856
+ div = this.div(radixLong),
77857
+ rem1 = div.mul(radixLong).sub(this);
77858
+ return div.toString(radix) + rem1.toInt().toString(radix);
77859
+ } else
77860
+ return '-' + this.neg().toString(radix);
77861
+ }
77862
+
77863
+ // Do several (6) digits each time through the loop, so as to
77864
+ // minimize the calls to the very expensive emulated div.
77865
+ var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned),
77866
+ rem = this;
77867
+ var result = '';
77868
+ while (true) {
77869
+ var remDiv = rem.div(radixToPower),
77870
+ intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0,
77871
+ digits = intval.toString(radix);
77872
+ rem = remDiv;
77873
+ if (rem.isZero())
77874
+ return digits + result;
77875
+ else {
77876
+ while (digits.length < 6)
77877
+ digits = '0' + digits;
77878
+ result = '' + digits + result;
77879
+ }
77880
+ }
77881
+ };
77882
+
77883
+ /**
77884
+ * Gets the high 32 bits as a signed integer.
77885
+ * @returns {number} Signed high bits
77886
+ */
77887
+ LongPrototype.getHighBits = function getHighBits() {
77888
+ return this.high;
77889
+ };
77890
+
77891
+ /**
77892
+ * Gets the high 32 bits as an unsigned integer.
77893
+ * @returns {number} Unsigned high bits
77894
+ */
77895
+ LongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {
77896
+ return this.high >>> 0;
77897
+ };
77898
+
77899
+ /**
77900
+ * Gets the low 32 bits as a signed integer.
77901
+ * @returns {number} Signed low bits
77902
+ */
77903
+ LongPrototype.getLowBits = function getLowBits() {
77904
+ return this.low;
77905
+ };
77906
+
77907
+ /**
77908
+ * Gets the low 32 bits as an unsigned integer.
77909
+ * @returns {number} Unsigned low bits
77910
+ */
77911
+ LongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {
77912
+ return this.low >>> 0;
77913
+ };
77914
+
77915
+ /**
77916
+ * Gets the number of bits needed to represent the absolute value of this Long.
77917
+ * @returns {number}
77918
+ */
77919
+ LongPrototype.getNumBitsAbs = function getNumBitsAbs() {
77920
+ if (this.isNegative()) // Unsigned Longs are never negative
77921
+ return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
77922
+ var val = this.high != 0 ? this.high : this.low;
77923
+ for (var bit = 31; bit > 0; bit--)
77924
+ if ((val & (1 << bit)) != 0)
77925
+ break;
77926
+ return this.high != 0 ? bit + 33 : bit + 1;
77927
+ };
77928
+
77929
+ /**
77930
+ * Tests if this Long's value equals zero.
77931
+ * @returns {boolean}
77932
+ */
77933
+ LongPrototype.isZero = function isZero() {
77934
+ return this.high === 0 && this.low === 0;
77935
+ };
77936
+
77937
+ /**
77938
+ * Tests if this Long's value is negative.
77939
+ * @returns {boolean}
77940
+ */
77941
+ LongPrototype.isNegative = function isNegative() {
77942
+ return !this.unsigned && this.high < 0;
77943
+ };
77944
+
77945
+ /**
77946
+ * Tests if this Long's value is positive.
77947
+ * @returns {boolean}
77948
+ */
77949
+ LongPrototype.isPositive = function isPositive() {
77950
+ return this.unsigned || this.high >= 0;
77951
+ };
77952
+
77953
+ /**
77954
+ * Tests if this Long's value is odd.
77955
+ * @returns {boolean}
77956
+ */
77957
+ LongPrototype.isOdd = function isOdd() {
77958
+ return (this.low & 1) === 1;
77959
+ };
77960
+
77961
+ /**
77962
+ * Tests if this Long's value is even.
77963
+ * @returns {boolean}
77964
+ */
77965
+ LongPrototype.isEven = function isEven() {
77966
+ return (this.low & 1) === 0;
77967
+ };
77968
+
77969
+ /**
77970
+ * Tests if this Long's value equals the specified's.
77971
+ * @param {!Long|number|string} other Other value
77972
+ * @returns {boolean}
77973
+ */
77974
+ LongPrototype.equals = function equals(other) {
77975
+ if (!isLong(other))
77976
+ other = fromValue(other);
77977
+ if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1)
77978
+ return false;
77979
+ return this.high === other.high && this.low === other.low;
77980
+ };
77981
+
77982
+ /**
77983
+ * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.
77984
+ * @function
77985
+ * @param {!Long|number|string} other Other value
77986
+ * @returns {boolean}
77987
+ */
77988
+ LongPrototype.eq = LongPrototype.equals;
77989
+
77990
+ /**
77991
+ * Tests if this Long's value differs from the specified's.
77992
+ * @param {!Long|number|string} other Other value
77993
+ * @returns {boolean}
77994
+ */
77995
+ LongPrototype.notEquals = function notEquals(other) {
77996
+ return !this.eq(/* validates */ other);
77997
+ };
77998
+
77999
+ /**
78000
+ * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.
78001
+ * @function
78002
+ * @param {!Long|number|string} other Other value
78003
+ * @returns {boolean}
78004
+ */
78005
+ LongPrototype.neq = LongPrototype.notEquals;
78006
+
78007
+ /**
78008
+ * Tests if this Long's value is less than the specified's.
78009
+ * @param {!Long|number|string} other Other value
78010
+ * @returns {boolean}
78011
+ */
78012
+ LongPrototype.lessThan = function lessThan(other) {
78013
+ return this.comp(/* validates */ other) < 0;
78014
+ };
78015
+
78016
+ /**
78017
+ * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.
78018
+ * @function
78019
+ * @param {!Long|number|string} other Other value
78020
+ * @returns {boolean}
78021
+ */
78022
+ LongPrototype.lt = LongPrototype.lessThan;
78023
+
78024
+ /**
78025
+ * Tests if this Long's value is less than or equal the specified's.
78026
+ * @param {!Long|number|string} other Other value
78027
+ * @returns {boolean}
78028
+ */
78029
+ LongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {
78030
+ return this.comp(/* validates */ other) <= 0;
78031
+ };
78032
+
78033
+ /**
78034
+ * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.
78035
+ * @function
78036
+ * @param {!Long|number|string} other Other value
78037
+ * @returns {boolean}
78038
+ */
78039
+ LongPrototype.lte = LongPrototype.lessThanOrEqual;
78040
+
78041
+ /**
78042
+ * Tests if this Long's value is greater than the specified's.
78043
+ * @param {!Long|number|string} other Other value
78044
+ * @returns {boolean}
78045
+ */
78046
+ LongPrototype.greaterThan = function greaterThan(other) {
78047
+ return this.comp(/* validates */ other) > 0;
78048
+ };
78049
+
78050
+ /**
78051
+ * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.
78052
+ * @function
78053
+ * @param {!Long|number|string} other Other value
78054
+ * @returns {boolean}
78055
+ */
78056
+ LongPrototype.gt = LongPrototype.greaterThan;
78057
+
78058
+ /**
78059
+ * Tests if this Long's value is greater than or equal the specified's.
78060
+ * @param {!Long|number|string} other Other value
78061
+ * @returns {boolean}
78062
+ */
78063
+ LongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {
78064
+ return this.comp(/* validates */ other) >= 0;
78065
+ };
78066
+
78067
+ /**
78068
+ * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.
78069
+ * @function
78070
+ * @param {!Long|number|string} other Other value
78071
+ * @returns {boolean}
78072
+ */
78073
+ LongPrototype.gte = LongPrototype.greaterThanOrEqual;
78074
+
78075
+ /**
78076
+ * Compares this Long's value with the specified's.
78077
+ * @param {!Long|number|string} other Other value
78078
+ * @returns {number} 0 if they are the same, 1 if the this is greater and -1
78079
+ * if the given one is greater
78080
+ */
78081
+ LongPrototype.compare = function compare(other) {
78082
+ if (!isLong(other))
78083
+ other = fromValue(other);
78084
+ if (this.eq(other))
78085
+ return 0;
78086
+ var thisNeg = this.isNegative(),
78087
+ otherNeg = other.isNegative();
78088
+ if (thisNeg && !otherNeg)
78089
+ return -1;
78090
+ if (!thisNeg && otherNeg)
78091
+ return 1;
78092
+ // At this point the sign bits are the same
78093
+ if (!this.unsigned)
78094
+ return this.sub(other).isNegative() ? -1 : 1;
78095
+ // Both are positive if at least one is unsigned
78096
+ return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;
78097
+ };
78098
+
78099
+ /**
78100
+ * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.
78101
+ * @function
78102
+ * @param {!Long|number|string} other Other value
78103
+ * @returns {number} 0 if they are the same, 1 if the this is greater and -1
78104
+ * if the given one is greater
78105
+ */
78106
+ LongPrototype.comp = LongPrototype.compare;
78107
+
78108
+ /**
78109
+ * Negates this Long's value.
78110
+ * @returns {!Long} Negated Long
78111
+ */
78112
+ LongPrototype.negate = function negate() {
78113
+ if (!this.unsigned && this.eq(MIN_VALUE))
78114
+ return MIN_VALUE;
78115
+ return this.not().add(ONE);
78116
+ };
78117
+
78118
+ /**
78119
+ * Negates this Long's value. This is an alias of {@link Long#negate}.
78120
+ * @function
78121
+ * @returns {!Long} Negated Long
78122
+ */
78123
+ LongPrototype.neg = LongPrototype.negate;
78124
+
78125
+ /**
78126
+ * Returns the sum of this and the specified Long.
78127
+ * @param {!Long|number|string} addend Addend
78128
+ * @returns {!Long} Sum
78129
+ */
78130
+ LongPrototype.add = function add(addend) {
78131
+ if (!isLong(addend))
78132
+ addend = fromValue(addend);
78133
+
78134
+ // Divide each number into 4 chunks of 16 bits, and then sum the chunks.
78135
+
78136
+ var a48 = this.high >>> 16;
78137
+ var a32 = this.high & 0xFFFF;
78138
+ var a16 = this.low >>> 16;
78139
+ var a00 = this.low & 0xFFFF;
78140
+
78141
+ var b48 = addend.high >>> 16;
78142
+ var b32 = addend.high & 0xFFFF;
78143
+ var b16 = addend.low >>> 16;
78144
+ var b00 = addend.low & 0xFFFF;
78145
+
78146
+ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
78147
+ c00 += a00 + b00;
78148
+ c16 += c00 >>> 16;
78149
+ c00 &= 0xFFFF;
78150
+ c16 += a16 + b16;
78151
+ c32 += c16 >>> 16;
78152
+ c16 &= 0xFFFF;
78153
+ c32 += a32 + b32;
78154
+ c48 += c32 >>> 16;
78155
+ c32 &= 0xFFFF;
78156
+ c48 += a48 + b48;
78157
+ c48 &= 0xFFFF;
78158
+ return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
78159
+ };
78160
+
78161
+ /**
78162
+ * Returns the difference of this and the specified Long.
78163
+ * @param {!Long|number|string} subtrahend Subtrahend
78164
+ * @returns {!Long} Difference
78165
+ */
78166
+ LongPrototype.subtract = function subtract(subtrahend) {
78167
+ if (!isLong(subtrahend))
78168
+ subtrahend = fromValue(subtrahend);
78169
+ return this.add(subtrahend.neg());
78170
+ };
78171
+
78172
+ /**
78173
+ * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.
78174
+ * @function
78175
+ * @param {!Long|number|string} subtrahend Subtrahend
78176
+ * @returns {!Long} Difference
78177
+ */
78178
+ LongPrototype.sub = LongPrototype.subtract;
78179
+
78180
+ /**
78181
+ * Returns the product of this and the specified Long.
78182
+ * @param {!Long|number|string} multiplier Multiplier
78183
+ * @returns {!Long} Product
78184
+ */
78185
+ LongPrototype.multiply = function multiply(multiplier) {
78186
+ if (this.isZero())
78187
+ return ZERO;
78188
+ if (!isLong(multiplier))
78189
+ multiplier = fromValue(multiplier);
78190
+ if (multiplier.isZero())
78191
+ return ZERO;
78192
+ if (this.eq(MIN_VALUE))
78193
+ return multiplier.isOdd() ? MIN_VALUE : ZERO;
78194
+ if (multiplier.eq(MIN_VALUE))
78195
+ return this.isOdd() ? MIN_VALUE : ZERO;
78196
+
78197
+ if (this.isNegative()) {
78198
+ if (multiplier.isNegative())
78199
+ return this.neg().mul(multiplier.neg());
78200
+ else
78201
+ return this.neg().mul(multiplier).neg();
78202
+ } else if (multiplier.isNegative())
78203
+ return this.mul(multiplier.neg()).neg();
78204
+
78205
+ // If both longs are small, use float multiplication
78206
+ if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))
78207
+ return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
78208
+
78209
+ // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.
78210
+ // We can skip products that would overflow.
78211
+
78212
+ var a48 = this.high >>> 16;
78213
+ var a32 = this.high & 0xFFFF;
78214
+ var a16 = this.low >>> 16;
78215
+ var a00 = this.low & 0xFFFF;
78216
+
78217
+ var b48 = multiplier.high >>> 16;
78218
+ var b32 = multiplier.high & 0xFFFF;
78219
+ var b16 = multiplier.low >>> 16;
78220
+ var b00 = multiplier.low & 0xFFFF;
78221
+
78222
+ var c48 = 0, c32 = 0, c16 = 0, c00 = 0;
78223
+ c00 += a00 * b00;
78224
+ c16 += c00 >>> 16;
78225
+ c00 &= 0xFFFF;
78226
+ c16 += a16 * b00;
78227
+ c32 += c16 >>> 16;
78228
+ c16 &= 0xFFFF;
78229
+ c16 += a00 * b16;
78230
+ c32 += c16 >>> 16;
78231
+ c16 &= 0xFFFF;
78232
+ c32 += a32 * b00;
78233
+ c48 += c32 >>> 16;
78234
+ c32 &= 0xFFFF;
78235
+ c32 += a16 * b16;
78236
+ c48 += c32 >>> 16;
78237
+ c32 &= 0xFFFF;
78238
+ c32 += a00 * b32;
78239
+ c48 += c32 >>> 16;
78240
+ c32 &= 0xFFFF;
78241
+ c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
78242
+ c48 &= 0xFFFF;
78243
+ return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
78244
+ };
78245
+
78246
+ /**
78247
+ * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.
78248
+ * @function
78249
+ * @param {!Long|number|string} multiplier Multiplier
78250
+ * @returns {!Long} Product
78251
+ */
78252
+ LongPrototype.mul = LongPrototype.multiply;
78253
+
78254
+ /**
78255
+ * Returns this Long divided by the specified. The result is signed if this Long is signed or
78256
+ * unsigned if this Long is unsigned.
78257
+ * @param {!Long|number|string} divisor Divisor
78258
+ * @returns {!Long} Quotient
78259
+ */
78260
+ LongPrototype.divide = function divide(divisor) {
78261
+ if (!isLong(divisor))
78262
+ divisor = fromValue(divisor);
78263
+ if (divisor.isZero())
78264
+ throw Error('division by zero');
78265
+ if (this.isZero())
78266
+ return this.unsigned ? UZERO : ZERO;
78267
+ var approx, rem, res;
78268
+ if (!this.unsigned) {
78269
+ // This section is only relevant for signed longs and is derived from the
78270
+ // closure library as a whole.
78271
+ if (this.eq(MIN_VALUE)) {
78272
+ if (divisor.eq(ONE) || divisor.eq(NEG_ONE))
78273
+ return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE
78274
+ else if (divisor.eq(MIN_VALUE))
78275
+ return ONE;
78276
+ else {
78277
+ // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.
78278
+ var halfThis = this.shr(1);
78279
+ approx = halfThis.div(divisor).shl(1);
78280
+ if (approx.eq(ZERO)) {
78281
+ return divisor.isNegative() ? ONE : NEG_ONE;
78282
+ } else {
78283
+ rem = this.sub(divisor.mul(approx));
78284
+ res = approx.add(rem.div(divisor));
78285
+ return res;
78286
+ }
78287
+ }
78288
+ } else if (divisor.eq(MIN_VALUE))
78289
+ return this.unsigned ? UZERO : ZERO;
78290
+ if (this.isNegative()) {
78291
+ if (divisor.isNegative())
78292
+ return this.neg().div(divisor.neg());
78293
+ return this.neg().div(divisor).neg();
78294
+ } else if (divisor.isNegative())
78295
+ return this.div(divisor.neg()).neg();
78296
+ res = ZERO;
78297
+ } else {
78298
+ // The algorithm below has not been made for unsigned longs. It's therefore
78299
+ // required to take special care of the MSB prior to running it.
78300
+ if (!divisor.unsigned)
78301
+ divisor = divisor.toUnsigned();
78302
+ if (divisor.gt(this))
78303
+ return UZERO;
78304
+ if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true
78305
+ return UONE;
78306
+ res = UZERO;
78307
+ }
78308
+
78309
+ // Repeat the following until the remainder is less than other: find a
78310
+ // floating-point that approximates remainder / other *from below*, add this
78311
+ // into the result, and subtract it from the remainder. It is critical that
78312
+ // the approximate value is less than or equal to the real value so that the
78313
+ // remainder never becomes negative.
78314
+ rem = this;
78315
+ while (rem.gte(divisor)) {
78316
+ // Approximate the result of division. This may be a little greater or
78317
+ // smaller than the actual value.
78318
+ approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
78319
+
78320
+ // We will tweak the approximate result by changing it in the 48-th digit or
78321
+ // the smallest non-fractional digit, whichever is larger.
78322
+ var log2 = Math.ceil(Math.log(approx) / Math.LN2),
78323
+ delta = (log2 <= 48) ? 1 : pow_dbl(2, log2 - 48),
78324
+
78325
+ // Decrease the approximation until it is smaller than the remainder. Note
78326
+ // that if it is too large, the product overflows and is negative.
78327
+ approxRes = fromNumber(approx),
78328
+ approxRem = approxRes.mul(divisor);
78329
+ while (approxRem.isNegative() || approxRem.gt(rem)) {
78330
+ approx -= delta;
78331
+ approxRes = fromNumber(approx, this.unsigned);
78332
+ approxRem = approxRes.mul(divisor);
78333
+ }
78334
+
78335
+ // We know the answer can't be zero... and actually, zero would cause
78336
+ // infinite recursion since we would make no progress.
78337
+ if (approxRes.isZero())
78338
+ approxRes = ONE;
78339
+
78340
+ res = res.add(approxRes);
78341
+ rem = rem.sub(approxRem);
78342
+ }
78343
+ return res;
78344
+ };
78345
+
78346
+ /**
78347
+ * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.
78348
+ * @function
78349
+ * @param {!Long|number|string} divisor Divisor
78350
+ * @returns {!Long} Quotient
78351
+ */
78352
+ LongPrototype.div = LongPrototype.divide;
78353
+
78354
+ /**
78355
+ * Returns this Long modulo the specified.
78356
+ * @param {!Long|number|string} divisor Divisor
78357
+ * @returns {!Long} Remainder
78358
+ */
78359
+ LongPrototype.modulo = function modulo(divisor) {
78360
+ if (!isLong(divisor))
78361
+ divisor = fromValue(divisor);
78362
+ return this.sub(this.div(divisor).mul(divisor));
78363
+ };
78364
+
78365
+ /**
78366
+ * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.
78367
+ * @function
78368
+ * @param {!Long|number|string} divisor Divisor
78369
+ * @returns {!Long} Remainder
78370
+ */
78371
+ LongPrototype.mod = LongPrototype.modulo;
78372
+
78373
+ /**
78374
+ * Returns the bitwise NOT of this Long.
78375
+ * @returns {!Long}
78376
+ */
78377
+ LongPrototype.not = function not() {
78378
+ return fromBits(~this.low, ~this.high, this.unsigned);
78379
+ };
78380
+
78381
+ /**
78382
+ * Returns the bitwise AND of this Long and the specified.
78383
+ * @param {!Long|number|string} other Other Long
78384
+ * @returns {!Long}
78385
+ */
78386
+ LongPrototype.and = function and(other) {
78387
+ if (!isLong(other))
78388
+ other = fromValue(other);
78389
+ return fromBits(this.low & other.low, this.high & other.high, this.unsigned);
78390
+ };
78391
+
78392
+ /**
78393
+ * Returns the bitwise OR of this Long and the specified.
78394
+ * @param {!Long|number|string} other Other Long
78395
+ * @returns {!Long}
78396
+ */
78397
+ LongPrototype.or = function or(other) {
78398
+ if (!isLong(other))
78399
+ other = fromValue(other);
78400
+ return fromBits(this.low | other.low, this.high | other.high, this.unsigned);
78401
+ };
78402
+
78403
+ /**
78404
+ * Returns the bitwise XOR of this Long and the given one.
78405
+ * @param {!Long|number|string} other Other Long
78406
+ * @returns {!Long}
78407
+ */
78408
+ LongPrototype.xor = function xor(other) {
78409
+ if (!isLong(other))
78410
+ other = fromValue(other);
78411
+ return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
78412
+ };
78413
+
78414
+ /**
78415
+ * Returns this Long with bits shifted to the left by the given amount.
78416
+ * @param {number|!Long} numBits Number of bits
78417
+ * @returns {!Long} Shifted Long
78418
+ */
78419
+ LongPrototype.shiftLeft = function shiftLeft(numBits) {
78420
+ if (isLong(numBits))
78421
+ numBits = numBits.toInt();
78422
+ if ((numBits &= 63) === 0)
78423
+ return this;
78424
+ else if (numBits < 32)
78425
+ return fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
78426
+ else
78427
+ return fromBits(0, this.low << (numBits - 32), this.unsigned);
78428
+ };
78429
+
78430
+ /**
78431
+ * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.
78432
+ * @function
78433
+ * @param {number|!Long} numBits Number of bits
78434
+ * @returns {!Long} Shifted Long
78435
+ */
78436
+ LongPrototype.shl = LongPrototype.shiftLeft;
78437
+
78438
+ /**
78439
+ * Returns this Long with bits arithmetically shifted to the right by the given amount.
78440
+ * @param {number|!Long} numBits Number of bits
78441
+ * @returns {!Long} Shifted Long
78442
+ */
78443
+ LongPrototype.shiftRight = function shiftRight(numBits) {
78444
+ if (isLong(numBits))
78445
+ numBits = numBits.toInt();
78446
+ if ((numBits &= 63) === 0)
78447
+ return this;
78448
+ else if (numBits < 32)
78449
+ return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
78450
+ else
78451
+ return fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
78452
+ };
78453
+
78454
+ /**
78455
+ * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.
78456
+ * @function
78457
+ * @param {number|!Long} numBits Number of bits
78458
+ * @returns {!Long} Shifted Long
78459
+ */
78460
+ LongPrototype.shr = LongPrototype.shiftRight;
78461
+
78462
+ /**
78463
+ * Returns this Long with bits logically shifted to the right by the given amount.
78464
+ * @param {number|!Long} numBits Number of bits
78465
+ * @returns {!Long} Shifted Long
78466
+ */
78467
+ LongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {
78468
+ if (isLong(numBits))
78469
+ numBits = numBits.toInt();
78470
+ numBits &= 63;
78471
+ if (numBits === 0)
78472
+ return this;
78473
+ else {
78474
+ var high = this.high;
78475
+ if (numBits < 32) {
78476
+ var low = this.low;
78477
+ return fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
78478
+ } else if (numBits === 32)
78479
+ return fromBits(high, 0, this.unsigned);
78480
+ else
78481
+ return fromBits(high >>> (numBits - 32), 0, this.unsigned);
78482
+ }
78483
+ };
78484
+
78485
+ /**
78486
+ * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.
78487
+ * @function
78488
+ * @param {number|!Long} numBits Number of bits
78489
+ * @returns {!Long} Shifted Long
78490
+ */
78491
+ LongPrototype.shru = LongPrototype.shiftRightUnsigned;
78492
+
78493
+ /**
78494
+ * Converts this Long to signed.
78495
+ * @returns {!Long} Signed long
78496
+ */
78497
+ LongPrototype.toSigned = function toSigned() {
78498
+ if (!this.unsigned)
78499
+ return this;
78500
+ return fromBits(this.low, this.high, false);
78501
+ };
78502
+
78503
+ /**
78504
+ * Converts this Long to unsigned.
78505
+ * @returns {!Long} Unsigned long
78506
+ */
78507
+ LongPrototype.toUnsigned = function toUnsigned() {
78508
+ if (this.unsigned)
78509
+ return this;
78510
+ return fromBits(this.low, this.high, true);
78511
+ };
78512
+
78513
+ /**
78514
+ * Converts this Long to its byte representation.
78515
+ * @param {boolean=} le Whether little or big endian, defaults to big endian
78516
+ * @returns {!Array.<number>} Byte representation
78517
+ */
78518
+ LongPrototype.toBytes = function(le) {
78519
+ return le ? this.toBytesLE() : this.toBytesBE();
78520
+ };
78521
+
78522
+ /**
78523
+ * Converts this Long to its little endian byte representation.
78524
+ * @returns {!Array.<number>} Little endian byte representation
78525
+ */
78526
+ LongPrototype.toBytesLE = function() {
78527
+ var hi = this.high,
78528
+ lo = this.low;
78529
+ return [
78530
+ lo & 0xff,
78531
+ (lo >>> 8) & 0xff,
78532
+ (lo >>> 16) & 0xff,
78533
+ (lo >>> 24) & 0xff,
78534
+ hi & 0xff,
78535
+ (hi >>> 8) & 0xff,
78536
+ (hi >>> 16) & 0xff,
78537
+ (hi >>> 24) & 0xff
78538
+ ];
78539
+ };
78540
+
78541
+ /**
78542
+ * Converts this Long to its big endian byte representation.
78543
+ * @returns {!Array.<number>} Big endian byte representation
78544
+ */
78545
+ LongPrototype.toBytesBE = function() {
78546
+ var hi = this.high,
78547
+ lo = this.low;
78548
+ return [
78549
+ (hi >>> 24) & 0xff,
78550
+ (hi >>> 16) & 0xff,
78551
+ (hi >>> 8) & 0xff,
78552
+ hi & 0xff,
78553
+ (lo >>> 24) & 0xff,
78554
+ (lo >>> 16) & 0xff,
78555
+ (lo >>> 8) & 0xff,
78556
+ lo & 0xff
78557
+ ];
78558
+ };
78559
+
78560
+ return Long;
78561
78561
  });
78562
78562
  }(long));
78563
78563