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