Copy as Markdown

Other Tools

function new_Record() {
return std_Object_create(null);
}
function ToBoolean(v) {
return !!v;
}
function ToNumber(v) {
return +v;
}
function SameValueZero(x, y) {
return x === y || (x !== x && y !== y);
}
function GetMethod(V, P) {
do { if (!(IsPropertyKey(P))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 61 + ": " + "Invalid property key") } } while (false);
var func = V[P];
if (IsNullOrUndefined(func)) {
return undefined;
}
if (!IsCallable(func)) {
ThrowTypeError(11, typeof func);
}
return func;
}
function IsPropertyKey(argument) {
var type = typeof argument;
return type === "string" || type === "symbol";
}
function SpeciesConstructor(obj, defaultConstructor) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 92 + ": " + "not passed an object") } } while (false);
var ctor = obj.constructor;
if (ctor === undefined) {
return defaultConstructor;
}
if (!IsObject(ctor)) {
ThrowTypeError(55, "object's 'constructor' property");
}
var s = ctor[GetBuiltinSymbol("species")];
if (IsNullOrUndefined(s)) {
return defaultConstructor;
}
if (IsConstructor(s)) {
return s;
}
ThrowTypeError(
13,
"@@species property of object's constructor"
);
}
function GetTypeError(...args) {
try {
callFunction(std_Function_apply, ThrowTypeError, undefined, args);
} catch (e) {
return e;
}
do { if (!(false)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 133 + ": " + "the catch block should've returned from this function.") } } while (false);
}
function GetAggregateError(...args) {
try {
callFunction(std_Function_apply, ThrowAggregateError, undefined, args);
} catch (e) {
return e;
}
do { if (!(false)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 142 + ": " + "the catch block should've returned from this function.") } } while (false);
}
function GetInternalError(...args) {
try {
callFunction(std_Function_apply, ThrowInternalError, undefined, args);
} catch (e) {
return e;
}
do { if (!(false)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 151 + ": " + "the catch block should've returned from this function.") } } while (false);
}
function NullFunction() {}
function CopyDataProperties(target, source, excludedItems) {
do { if (!(IsObject(target))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 161 + ": " + "target is an object") } } while (false);
do { if (!(IsObject(excludedItems))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 164 + ": " + "excludedItems is an object") } } while (false);
if (IsNullOrUndefined(source)) {
return;
}
var from = ToObject(source);
var keys = CopyDataPropertiesOrGetOwnKeys(target, from, excludedItems);
if (keys === null) {
return;
}
for (var index = 0; index < keys.length; index++) {
var key = keys[index];
if (
!hasOwn(key, excludedItems) &&
callFunction(std_Object_propertyIsEnumerable, from, key)
) {
DefineDataProperty(target, key, from[key]);
}
}
}
function CopyDataPropertiesUnfiltered(target, source) {
do { if (!(IsObject(target))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Utilities.js" + ":" + 203 + ": " + "target is an object") } } while (false);
if (IsNullOrUndefined(source)) {
return;
}
var from = ToObject(source);
var keys = CopyDataPropertiesOrGetOwnKeys(target, from, null);
if (keys === null) {
return;
}
for (var index = 0; index < keys.length; index++) {
var key = keys[index];
if (callFunction(std_Object_propertyIsEnumerable, from, key)) {
DefineDataProperty(target, key, from[key]);
}
}
}
function outer() {
return function inner() {
return "foo";
};
}
function ArrayEvery(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.every");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
if (k in O) {
if (!callContentFunction(callbackfn, T, O[k], k, O)) {
return false;
}
}
}
return true;
}
SetIsInlinableLargeFunction(ArrayEvery);
function ArraySome(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.some");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
if (k in O) {
if (callContentFunction(callbackfn, T, O[k], k, O)) {
return true;
}
}
}
return false;
}
SetIsInlinableLargeFunction(ArraySome);
function ArrayForEach(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.forEach");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
if (k in O) {
callContentFunction(callbackfn, T, O[k], k, O);
}
}
return undefined;
}
SetIsInlinableLargeFunction(ArrayForEach);
function ArrayMap(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.map");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var A = ArraySpeciesCreate(O, len);
for (var k = 0; k < len; k++) {
if (k in O) {
var mappedValue = callContentFunction(callbackfn, T, O[k], k, O);
DefineDataProperty(A, k, mappedValue);
}
}
return A;
}
SetIsInlinableLargeFunction(ArrayMap);
function ArrayFilter(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.filter");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var A = ArraySpeciesCreate(O, 0);
for (var k = 0, to = 0; k < len; k++) {
if (k in O) {
var kValue = O[k];
if (callContentFunction(callbackfn, T, kValue, k, O)) {
DefineDataProperty(A, to++, kValue);
}
}
}
return A;
}
SetIsInlinableLargeFunction(ArrayFilter);
function ArrayReduce(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.reduce");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var k = 0;
var accumulator;
if (ArgumentsLength() > 1) {
accumulator = GetArgument(1);
} else {
if (len === 0) {
throw ThrowTypeError(51);
}
var kPresent = false;
do {
if (k in O) {
kPresent = true;
break;
}
} while (++k < len);
if (!kPresent) {
throw ThrowTypeError(51);
}
accumulator = O[k++];
}
for (; k < len; k++) {
if (k in O) {
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
}
return accumulator;
}
function ArrayReduceRight(callbackfn ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.reduce");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var k = len - 1;
var accumulator;
if (ArgumentsLength() > 1) {
accumulator = GetArgument(1);
} else {
if (len === 0) {
throw ThrowTypeError(51);
}
var kPresent = false;
do {
if (k in O) {
kPresent = true;
break;
}
} while (--k >= 0);
if (!kPresent) {
throw ThrowTypeError(51);
}
accumulator = O[k--];
}
for (; k >= 0; k--) {
if (k in O) {
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
}
return accumulator;
}
function ArrayFind(predicate ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.find");
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
var kValue = O[k];
if (callContentFunction(predicate, T, kValue, k, O)) {
return kValue;
}
}
return undefined;
}
SetIsInlinableLargeFunction(ArrayFind);
function ArrayFindIndex(predicate ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.find");
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
if (callContentFunction(predicate, T, O[k], k, O)) {
return k;
}
}
return -1;
}
SetIsInlinableLargeFunction(ArrayFindIndex);
function ArrayCopyWithin(target, start, end = undefined) {
var O = ToObject(this);
var len = ToLength(O.length);
var relativeTarget = ToInteger(target);
var to =
relativeTarget < 0
? std_Math_max(len + relativeTarget, 0)
: std_Math_min(relativeTarget, len);
var relativeStart = ToInteger(start);
var from =
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
var relativeEnd = end === undefined ? len : ToInteger(end);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
var count = std_Math_min(final - from, len - to);
if (from < to && to < from + count) {
from = from + count - 1;
to = to + count - 1;
while (count > 0) {
if (from in O) {
O[to] = O[from];
} else {
delete O[to];
}
from--;
to--;
count--;
}
} else {
while (count > 0) {
if (from in O) {
O[to] = O[from];
} else {
delete O[to];
}
from++;
to++;
count--;
}
}
return O;
}
function ArrayFill(value, start = 0, end = undefined) {
var O = ToObject(this);
var len = ToLength(O.length);
var relativeStart = ToInteger(start);
var k =
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
var relativeEnd = end === undefined ? len : ToInteger(end);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
for (; k < final; k++) {
O[k] = value;
}
return O;
}
function CreateArrayIterator(obj, kind) {
var iteratedObject = ToObject(obj);
var iterator = NewArrayIterator();
UnsafeSetReservedSlot(iterator, 0, iteratedObject);
UnsafeSetReservedSlot(iterator, 1, 0);
UnsafeSetReservedSlot(iterator, 2, kind);
return iterator;
}
function ArrayIteratorNext() {
var obj = this;
if (!IsObject(obj) || (obj = GuardToArrayIterator(obj)) === null) {
return callFunction(
CallArrayIteratorMethodIfWrapped,
this,
"ArrayIteratorNext"
);
}
var a = UnsafeGetReservedSlot(obj, 0);
var result = { value: undefined, done: false };
if (a === null) {
result.done = true;
return result;
}
var index = UnsafeGetReservedSlot(obj, 1);
var itemKind = UnsafeGetInt32FromReservedSlot(obj, 2);
var len;
if (IsPossiblyWrappedTypedArray(a)) {
len = PossiblyWrappedTypedArrayLength(a);
if (len === 0) {
if (PossiblyWrappedTypedArrayHasDetachedBuffer(a)) {
ThrowTypeError(564);
}
}
} else {
len = ToLength(a.length);
}
if (index >= len) {
UnsafeSetReservedSlot(obj, 0, null);
result.done = true;
return result;
}
UnsafeSetReservedSlot(obj, 1, index + 1);
if (itemKind === 1) {
result.value = a[index];
return result;
}
if (itemKind === 2) {
var pair = [index, a[index]];
result.value = pair;
return result;
}
do { if (!(itemKind === 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Array.js" + ":" + 596 + ": " + itemKind) } } while (false);
result.value = index;
return result;
}
SetIsInlinableLargeFunction(ArrayIteratorNext);
function $ArrayValues() {
return CreateArrayIterator(this, 1);
}
SetCanonicalName($ArrayValues, "values");
function ArrayEntries() {
return CreateArrayIterator(this, 2);
}
function ArrayKeys() {
return CreateArrayIterator(this, 0);
}
function ArrayFromAsync(asyncItems, mapfn = undefined, thisArg = undefined) {
var C = this;
var fromAsyncClosure = async () => {
var mapping = mapfn !== undefined;
if (mapping && !IsCallable(mapfn)) {
ThrowTypeError(11, ToSource(mapfn));
}
var usingAsyncIterator = asyncItems[GetBuiltinSymbol("asyncIterator")];
if (usingAsyncIterator === null) {
usingAsyncIterator = undefined;
}
var usingSyncIterator = undefined;
if (usingAsyncIterator !== undefined) {
if (!IsCallable(usingAsyncIterator)) {
ThrowTypeError(70, ToSource(asyncItems));
}
} else {
usingSyncIterator = asyncItems[GetBuiltinSymbol("iterator")];
if (usingSyncIterator === null) {
usingSyncIterator = undefined;
}
if (usingSyncIterator !== undefined) {
if (!IsCallable(usingSyncIterator)) {
ThrowTypeError(70, ToSource(asyncItems));
}
}
}
if (usingAsyncIterator !== undefined || usingSyncIterator !== undefined) {
var A = IsConstructor(C) ? constructContentFunction(C, C) : [];
var k = 0;
for await (var nextValue of allowContentIterWith(
asyncItems,
usingAsyncIterator,
usingSyncIterator
)) {
var mappedValue = nextValue;
if (mapping) {
mappedValue = callContentFunction(mapfn, thisArg, nextValue, k);
mappedValue = await mappedValue;
}
DefineDataProperty(A, k, mappedValue);
k = k + 1;
}
A.length = k;
return A;
}
var arrayLike = ToObject(asyncItems);
var len = ToLength(arrayLike.length);
var A = IsConstructor(C) ? constructContentFunction(C, C, len) : std_Array(len);
var k = 0;
while (k < len) {
var kValue = await arrayLike[k];
var mappedValue = mapping
? await callContentFunction(mapfn, thisArg, kValue, k)
: kValue;
DefineDataProperty(A, k, mappedValue);
k = k + 1;
}
A.length = len;
return A;
};
return fromAsyncClosure();
}
function ArrayFrom(items, mapfn = undefined, thisArg = undefined) {
var C = this;
var mapping = mapfn !== undefined;
if (mapping && !IsCallable(mapfn)) {
ThrowTypeError(11, DecompileArg(1, mapfn));
}
var T = thisArg;
var usingIterator = items[GetBuiltinSymbol("iterator")];
if (!IsNullOrUndefined(usingIterator)) {
if (!IsCallable(usingIterator)) {
ThrowTypeError(70, DecompileArg(0, items));
}
var A = IsConstructor(C) ? constructContentFunction(C, C) : [];
var k = 0;
for (var nextValue of allowContentIterWith(items, usingIterator)) {
var mappedValue = mapping
? callContentFunction(mapfn, T, nextValue, k)
: nextValue;
DefineDataProperty(A, k++, mappedValue);
}
A.length = k;
return A;
}
var arrayLike = ToObject(items);
var len = ToLength(arrayLike.length);
var A = IsConstructor(C)
? constructContentFunction(C, C, len)
: std_Array(len);
for (var k = 0; k < len; k++) {
var kValue = items[k];
var mappedValue = mapping
? callContentFunction(mapfn, T, kValue, k)
: kValue;
DefineDataProperty(A, k, mappedValue);
}
A.length = len;
return A;
}
function ArrayToString() {
var array = ToObject(this);
var func = array.join;
if (!IsCallable(func)) {
return callFunction(std_Object_toString, array);
}
return callContentFunction(func, array);
}
function ArrayToLocaleString(locales, options) {
do { if (!(IsObject(this))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Array.js" + ":" + 905 + ": " + "|this| should be an object") } } while (false);
var array = this;
var len = ToLength(array.length);
if (len === 0) {
return "";
}
var firstElement = array[0];
var R;
if (IsNullOrUndefined(firstElement)) {
R = "";
} else {
R = ToString(
callContentFunction(
firstElement.toLocaleString,
firstElement,
locales,
options
)
);
}
var separator = ",";
for (var k = 1; k < len; k++) {
var nextElement = array[k];
R += separator;
if (!IsNullOrUndefined(nextElement)) {
R += ToString(
callContentFunction(
nextElement.toLocaleString,
nextElement,
locales,
options
)
);
}
}
return R;
}
function $ArraySpecies() {
return this;
}
SetCanonicalName($ArraySpecies, "get [Symbol.species]");
function ArraySpeciesCreate(originalArray, length) {
do { if (!(typeof length === "number")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Array.js" + ":" + 983 + ": " + "length should be a number") } } while (false);
do { if (!(length >= 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Array.js" + ":" + 984 + ": " + "length should be a non-negative number") } } while (false);
if (length === -0) {
length = 0;
}
if (!IsArray(originalArray)) {
return std_Array(length);
}
var C = originalArray.constructor;
if (IsConstructor(C) && IsCrossRealmArrayConstructor(C)) {
return std_Array(length);
}
if (IsObject(C)) {
C = C[GetBuiltinSymbol("species")];
if (C === GetBuiltinConstructor("Array")) {
return std_Array(length);
}
if (C === null) {
return std_Array(length);
}
}
if (C === undefined) {
return std_Array(length);
}
if (!IsConstructor(C)) {
ThrowTypeError(13, "constructor property");
}
return constructContentFunction(C, C, length);
}
function ArrayFlatMap(mapperFunction ) {
var O = ToObject(this);
var sourceLen = ToLength(O.length);
if (!IsCallable(mapperFunction)) {
ThrowTypeError(11, DecompileArg(0, mapperFunction));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var A = ArraySpeciesCreate(O, 0);
FlattenIntoArray(A, O, sourceLen, 0, 1, mapperFunction, T);
return A;
}
function ArrayFlat( ) {
var O = ToObject(this);
var sourceLen = ToLength(O.length);
var depthNum = 1;
if (ArgumentsLength() && GetArgument(0) !== undefined) {
depthNum = ToInteger(GetArgument(0));
}
var A = ArraySpeciesCreate(O, 0);
FlattenIntoArray(A, O, sourceLen, 0, depthNum);
return A;
}
function FlattenIntoArray(
target,
source,
sourceLen,
start,
depth,
mapperFunction,
thisArg
) {
var targetIndex = start;
for (var sourceIndex = 0; sourceIndex < sourceLen; sourceIndex++) {
if (sourceIndex in source) {
var element = source[sourceIndex];
if (mapperFunction) {
do { if (!(ArgumentsLength() === 7)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Array.js" + ":" + 1112 + ": " + "thisArg is present") } } while (false);
element = callContentFunction(
mapperFunction,
thisArg,
element,
sourceIndex,
source
);
}
var shouldFlatten = false;
if (depth > 0) {
shouldFlatten = IsArray(element);
}
if (shouldFlatten) {
var elementLen = ToLength(element.length);
targetIndex = FlattenIntoArray(
target,
element,
elementLen,
targetIndex,
depth - 1
);
} else {
if (targetIndex >= 0x1fffffffffffff) {
ThrowTypeError(557);
}
DefineDataProperty(target, targetIndex, element);
targetIndex++;
}
}
}
return targetIndex;
}
function ArrayAt(index) {
var O = ToObject(this);
var len = ToLength(O.length);
var relativeIndex = ToInteger(index);
var k;
if (relativeIndex >= 0) {
k = relativeIndex;
} else {
k = len + relativeIndex;
}
if (k < 0 || k >= len) {
return undefined;
}
return O[k];
}
SetIsInlinableLargeFunction(ArrayAt);
function ArrayToReversed() {
var O = ToObject(this);
var len = ToLength(O.length);
var A = std_Array(len);
for (var k = 0; k < len; k++) {
var from = len - k - 1;
var fromValue = O[from];
DefineDataProperty(A, k, fromValue);
}
return A;
}
function ArrayToSorted(comparefn) {
if (comparefn !== undefined && !IsCallable(comparefn)) {
ThrowTypeError(7);
}
var O = ToObject(this);
var len = ToLength(O.length);
var items = std_Array(len);
for (var k = 0; k < len; k++) {
DefineDataProperty(items, k, O[k]);
}
if (len <= 1) {
return items;
}
return callFunction(std_Array_sort, items, comparefn);
}
function ArrayFindLast(predicate ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.findLast");
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = len - 1; k >= 0; k--) {
var kValue = O[k];
if (callContentFunction(predicate, thisArg, kValue, k, O)) {
return kValue;
}
}
return undefined;
}
SetIsInlinableLargeFunction(ArrayFindLast);
function ArrayFindLastIndex(predicate ) {
var O = ToObject(this);
var len = ToLength(O.length);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "Array.prototype.findLastIndex");
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = len - 1; k >= 0; k--) {
if (callContentFunction(predicate, thisArg, O[k], k, O)) {
return k;
}
}
return -1;
}
SetIsInlinableLargeFunction(ArrayFindLastIndex);
function AsyncFunctionNext(val) {
do { if (!(IsAsyncFunctionGeneratorObject(this))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/AsyncFunction.js" + ":" + 9 + ": " + "ThisArgument must be a generator object for async functions") } } while (false);
return resumeGenerator(this, val, "next");
}
function AsyncFunctionThrow(val) {
do { if (!(IsAsyncFunctionGeneratorObject(this))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/AsyncFunction.js" + ":" + 17 + ": " + "ThisArgument must be a generator object for async functions") } } while (false);
return resumeGenerator(this, val, "throw");
}
function AsyncIteratorIdentity() {
return this;
}
function AsyncGeneratorNext(val) {
do { if (!(IsAsyncGeneratorObject(this))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/AsyncIteration.js" + ":" + 13 + ": " + "ThisArgument must be a generator object for async generators") } } while (false);
return resumeGenerator(this, val, "next");
}
function AsyncGeneratorThrow(val) {
do { if (!(IsAsyncGeneratorObject(this))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/AsyncIteration.js" + ":" + 21 + ": " + "ThisArgument must be a generator object for async generators") } } while (false);
return resumeGenerator(this, val, "throw");
}
function AsyncGeneratorReturn(val) {
do { if (!(IsAsyncGeneratorObject(this))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/AsyncIteration.js" + ":" + 29 + ": " + "ThisArgument must be a generator object for async generators") } } while (false);
return resumeGenerator(this, val, "return");
}
async function AsyncIteratorClose(iteratorRecord, value) {
var iterator = iteratorRecord.iterator;
var returnMethod = iterator.return;
if (!IsNullOrUndefined(returnMethod)) {
var result = await callContentFunction(returnMethod, iterator);
if (!IsObject(result)) {
ThrowTypeError(55, DecompileArg(0, result));
}
}
return value;
}
function GetIteratorDirect(obj) {
if (!IsObject(obj)) {
ThrowTypeError(55, DecompileArg(0, obj));
}
var nextMethod = obj.next;
if (!IsCallable(nextMethod)) {
ThrowTypeError(11, DecompileArg(0, nextMethod));
}
return {
iterator: obj,
nextMethod,
done: false,
};
}
function GetAsyncIteratorDirectWrapper(obj) {
if (!IsObject(obj)) {
ThrowTypeError(55, obj);
}
var nextMethod = obj.next;
if (!IsCallable(nextMethod)) {
ThrowTypeError(11, nextMethod);
}
return {
[GetBuiltinSymbol("asyncIterator")]: function AsyncIteratorMethod() {
return this;
},
next(value) {
return callContentFunction(nextMethod, obj, value);
},
async return(value) {
var returnMethod = obj.return;
if (!IsNullOrUndefined(returnMethod)) {
return callContentFunction(returnMethod, obj, value);
}
return { done: true, value };
},
};
}
function AsyncIteratorHelperNext(value) {
var O = this;
if (!IsObject(O) || (O = GuardToAsyncIteratorHelper(O)) === null) {
return callFunction(
CallAsyncIteratorHelperMethodIfWrapped,
this,
value,
"AsyncIteratorHelperNext"
);
}
var generator = UnsafeGetReservedSlot(
O,
0
);
return callFunction(IntrinsicAsyncGeneratorNext, generator, value);
}
function AsyncIteratorHelperReturn(value) {
var O = this;
if (!IsObject(O) || (O = GuardToAsyncIteratorHelper(O)) === null) {
return callFunction(
CallAsyncIteratorHelperMethodIfWrapped,
this,
value,
"AsyncIteratorHelperReturn"
);
}
var generator = UnsafeGetReservedSlot(
O,
0
);
return callFunction(IntrinsicAsyncGeneratorReturn, generator, value);
}
function AsyncIteratorHelperThrow(value) {
var O = this;
if (!IsObject(O) || (O = GuardToAsyncIteratorHelper(O)) === null) {
return callFunction(
CallAsyncIteratorHelperMethodIfWrapped,
this,
value,
"AsyncIteratorHelperThrow"
);
}
var generator = UnsafeGetReservedSlot(
O,
0
);
return callFunction(IntrinsicAsyncGeneratorThrow, generator, value);
}
function AsyncIteratorMap(mapper) {
var iterated = GetIteratorDirect(this);
if (!IsCallable(mapper)) {
ThrowTypeError(11, DecompileArg(0, mapper));
}
var iteratorHelper = NewAsyncIteratorHelper();
var generator = AsyncIteratorMapGenerator(iterated, mapper);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(
iteratorHelper,
0,
generator
);
return iteratorHelper;
}
async function* AsyncIteratorMapGenerator(iterated, mapper) {
var lastValue;
var needClose = true;
try {
yield;
needClose = false;
for (
var next = await IteratorNext(iterated, lastValue);
!next.done;
next = await IteratorNext(iterated, lastValue)
) {
var value = next.value;
needClose = true;
lastValue = yield callContentFunction(mapper, undefined, value);
needClose = false;
}
} finally {
if (needClose) {
AsyncIteratorClose(iterated);
}
}
}
function AsyncIteratorFilter(filterer) {
var iterated = GetIteratorDirect(this);
if (!IsCallable(filterer)) {
ThrowTypeError(11, DecompileArg(0, filterer));
}
var iteratorHelper = NewAsyncIteratorHelper();
var generator = AsyncIteratorFilterGenerator(iterated, filterer);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(
iteratorHelper,
0,
generator
);
return iteratorHelper;
}
async function* AsyncIteratorFilterGenerator(iterated, filterer) {
var lastValue;
var needClose = true;
try {
yield;
needClose = false;
for (
var next = await IteratorNext(iterated, lastValue);
!next.done;
next = await IteratorNext(iterated, lastValue)
) {
var value = next.value;
needClose = true;
if (await callContentFunction(filterer, undefined, value)) {
lastValue = yield value;
}
needClose = false;
}
} finally {
if (needClose) {
AsyncIteratorClose(iterated);
}
}
}
function AsyncIteratorTake(limit) {
var iterated = GetIteratorDirect(this);
var remaining = ToInteger(limit);
if (remaining < 0) {
ThrowRangeError(675);
}
var iteratorHelper = NewAsyncIteratorHelper();
var generator = AsyncIteratorTakeGenerator(iterated, remaining);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(
iteratorHelper,
0,
generator
);
return iteratorHelper;
}
async function* AsyncIteratorTakeGenerator(iterated, remaining) {
var lastValue;
var needClose = true;
try {
yield;
needClose = false;
for (; remaining > 0; remaining--) {
var next = await IteratorNext(iterated, lastValue);
if (next.done) {
return undefined;
}
var value = next.value;
needClose = true;
lastValue = yield value;
needClose = false;
}
} finally {
if (needClose) {
AsyncIteratorClose(iterated, undefined);
}
}
return AsyncIteratorClose(iterated, undefined);
}
function AsyncIteratorDrop(limit) {
var iterated = GetIteratorDirect(this);
var remaining = ToInteger(limit);
if (remaining < 0) {
ThrowRangeError(675);
}
var iteratorHelper = NewAsyncIteratorHelper();
var generator = AsyncIteratorDropGenerator(iterated, remaining);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(
iteratorHelper,
0,
generator
);
return iteratorHelper;
}
async function* AsyncIteratorDropGenerator(iterated, remaining) {
var needClose = true;
try {
yield;
needClose = false;
for (; remaining > 0; remaining--) {
var next = await IteratorNext(iterated);
if (next.done) {
return;
}
}
var lastValue;
for (
var next = await IteratorNext(iterated, lastValue);
!next.done;
next = await IteratorNext(iterated, lastValue)
) {
var value = next.value;
needClose = true;
lastValue = yield value;
needClose = false;
}
} finally {
if (needClose) {
AsyncIteratorClose(iterated);
}
}
}
function AsyncIteratorAsIndexedPairs() {
var iterated = GetIteratorDirect(this);
var iteratorHelper = NewAsyncIteratorHelper();
var generator = AsyncIteratorAsIndexedPairsGenerator(iterated);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(
iteratorHelper,
0,
generator
);
return iteratorHelper;
}
async function* AsyncIteratorAsIndexedPairsGenerator(iterated) {
var needClose = true;
try {
yield;
needClose = false;
var lastValue;
for (
var next = await IteratorNext(iterated, lastValue), index = 0;
!next.done;
next = await IteratorNext(iterated, lastValue), index++
) {
var value = next.value;
needClose = true;
lastValue = yield [index, value];
needClose = false;
}
} finally {
if (needClose) {
AsyncIteratorClose(iterated);
}
}
}
function AsyncIteratorFlatMap(mapper) {
var iterated = GetIteratorDirect(this);
if (!IsCallable(mapper)) {
ThrowTypeError(11, DecompileArg(0, mapper));
}
var iteratorHelper = NewAsyncIteratorHelper();
var generator = AsyncIteratorFlatMapGenerator(iterated, mapper);
callFunction(IntrinsicAsyncGeneratorNext, generator);
UnsafeSetReservedSlot(
iteratorHelper,
0,
generator
);
return iteratorHelper;
}
async function* AsyncIteratorFlatMapGenerator(iterated, mapper) {
var needClose = true;
try {
yield;
needClose = false;
for (
var next = await IteratorNext(iterated);
!next.done;
next = await IteratorNext(iterated)
) {
var value = next.value;
needClose = true;
var mapped = await callContentFunction(mapper, undefined, value);
for await (var innerValue of allowContentIter(mapped)) {
yield innerValue;
}
needClose = false;
}
} finally {
if (needClose) {
AsyncIteratorClose(iterated);
}
}
}
async function AsyncIteratorReduce(reducer ) {
var iterated = GetAsyncIteratorDirectWrapper(this);
if (!IsCallable(reducer)) {
ThrowTypeError(11, DecompileArg(0, reducer));
}
var accumulator;
if (ArgumentsLength() === 1) {
var next = await callContentFunction(iterated.next, iterated);
if (!IsObject(next)) {
ThrowTypeError(55, DecompileArg(0, next));
}
if (next.done) {
ThrowTypeError(52);
}
accumulator = next.value;
} else {
accumulator = GetArgument(1);
}
for await (var value of allowContentIter(iterated)) {
accumulator = await callContentFunction(
reducer,
undefined,
accumulator,
value
);
}
return accumulator;
}
async function AsyncIteratorToArray() {
var iterated = { [GetBuiltinSymbol("asyncIterator")]: () => this };
var items = [];
var index = 0;
for await (var value of allowContentIter(iterated)) {
DefineDataProperty(items, index++, value);
}
return items;
}
async function AsyncIteratorForEach(fn) {
var iterated = GetAsyncIteratorDirectWrapper(this);
if (!IsCallable(fn)) {
ThrowTypeError(11, DecompileArg(0, fn));
}
for await (var value of allowContentIter(iterated)) {
await callContentFunction(fn, undefined, value);
}
}
async function AsyncIteratorSome(fn) {
var iterated = GetAsyncIteratorDirectWrapper(this);
if (!IsCallable(fn)) {
ThrowTypeError(11, DecompileArg(0, fn));
}
for await (var value of allowContentIter(iterated)) {
if (await callContentFunction(fn, undefined, value)) {
return true;
}
}
return false;
}
async function AsyncIteratorEvery(fn) {
var iterated = GetAsyncIteratorDirectWrapper(this);
if (!IsCallable(fn)) {
ThrowTypeError(11, DecompileArg(0, fn));
}
for await (var value of allowContentIter(iterated)) {
if (!(await callContentFunction(fn, undefined, value))) {
return false;
}
}
return true;
}
async function AsyncIteratorFind(fn) {
var iterated = GetAsyncIteratorDirectWrapper(this);
if (!IsCallable(fn)) {
ThrowTypeError(11, DecompileArg(0, fn));
}
for await (var value of allowContentIter(iterated)) {
if (await callContentFunction(fn, undefined, value)) {
return value;
}
}
}
function BigInt_toLocaleString() {
var x = callFunction(std_BigInt_valueOf, this);
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var numberFormat;
if (locales === undefined && options === undefined) {
if (!intl_IsRuntimeDefaultLocale(numberFormatCache.runtimeDefaultLocale)) {
numberFormatCache.numberFormat = intl_NumberFormat(locales, options);
numberFormatCache.runtimeDefaultLocale = intl_RuntimeDefaultLocale();
}
numberFormat = numberFormatCache.numberFormat;
} else {
numberFormat = intl_NumberFormat(locales, options);
}
return intl_FormatNumber(numberFormat, x, false);
}
var dateTimeFormatCache = new_Record();
function GetCachedFormat(format, required, defaults) {
do { if (!(format === "dateTimeFormat" || format === "dateFormat" || format === "timeFormat")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Date.js" + ":" + 50 + ": " + "unexpected format key: please update the comment by dateTimeFormatCache") } } while (false);
var formatters;
if (
!intl_IsRuntimeDefaultLocale(dateTimeFormatCache.runtimeDefaultLocale) ||
!intl_isDefaultTimeZone(dateTimeFormatCache.icuDefaultTimeZone)
) {
formatters = dateTimeFormatCache.formatters = new_Record();
dateTimeFormatCache.runtimeDefaultLocale = intl_RuntimeDefaultLocale();
dateTimeFormatCache.icuDefaultTimeZone = intl_defaultTimeZone();
} else {
formatters = dateTimeFormatCache.formatters;
}
var fmt = formatters[format];
if (fmt === undefined) {
fmt = formatters[format] = intl_CreateDateTimeFormat(undefined, undefined, required, defaults);
}
return fmt;
}
function Date_toLocaleString() {
var x = callFunction(ThisTimeValue, this, 2);
if (Number_isNaN(x)) {
return "Invalid Date";
}
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var dateTimeFormat;
if (locales === undefined && options === undefined) {
dateTimeFormat = GetCachedFormat("dateTimeFormat", "any", "all");
} else {
dateTimeFormat = intl_CreateDateTimeFormat(locales, options, "any", "all");
}
return intl_FormatDateTime(dateTimeFormat, x, false);
}
function Date_toLocaleDateString() {
var x = callFunction(ThisTimeValue, this, 1);
if (Number_isNaN(x)) {
return "Invalid Date";
}
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var dateTimeFormat;
if (locales === undefined && options === undefined) {
dateTimeFormat = GetCachedFormat("dateFormat", "date", "date");
} else {
dateTimeFormat = intl_CreateDateTimeFormat(locales, options, "date", "date");
}
return intl_FormatDateTime(dateTimeFormat, x, false);
}
function Date_toLocaleTimeString() {
var x = callFunction(ThisTimeValue, this, 0);
if (Number_isNaN(x)) {
return "Invalid Date";
}
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var dateTimeFormat;
if (locales === undefined && options === undefined) {
dateTimeFormat = GetCachedFormat("timeFormat", "time", "time");
} else {
dateTimeFormat = intl_CreateDateTimeFormat(locales, options, "time", "time");
}
return intl_FormatDateTime(dateTimeFormat, x, false);
}
function ErrorToString() {
var obj = this;
if (!IsObject(obj)) {
ThrowTypeError(3, "Error", "toString", "value");
}
var name = obj.name;
name = name === undefined ? "Error" : ToString(name);
var msg = obj.message;
msg = msg === undefined ? "" : ToString(msg);
if (name === "") {
return msg;
}
if (msg === "") {
return name;
}
return name + ": " + msg;
}
function ErrorToStringWithTrailingNewline() {
return callFunction(std_Function_apply, ErrorToString, this, []) + "\n";
}
function GeneratorNext(val) {
if (!IsSuspendedGenerator(this)) {
if (!IsObject(this) || !IsGeneratorObject(this)) {
return callFunction(
CallGeneratorMethodIfWrapped,
this,
val,
"GeneratorNext"
);
}
if (GeneratorObjectIsClosed(this)) {
return { value: undefined, done: true };
}
if (GeneratorIsRunning(this)) {
ThrowTypeError(45);
}
}
try {
return resumeGenerator(this, val, "next");
} catch (e) {
if (!GeneratorObjectIsClosed(this)) {
GeneratorSetClosed(this);
}
throw e;
}
}
function GeneratorThrow(val) {
if (!IsSuspendedGenerator(this)) {
if (!IsObject(this) || !IsGeneratorObject(this)) {
return callFunction(
CallGeneratorMethodIfWrapped,
this,
val,
"GeneratorThrow"
);
}
if (GeneratorObjectIsClosed(this)) {
throw val;
}
if (GeneratorIsRunning(this)) {
ThrowTypeError(45);
}
}
try {
return resumeGenerator(this, val, "throw");
} catch (e) {
if (!GeneratorObjectIsClosed(this)) {
GeneratorSetClosed(this);
}
throw e;
}
}
function GeneratorReturn(val) {
if (!IsSuspendedGenerator(this)) {
if (!IsObject(this) || !IsGeneratorObject(this)) {
return callFunction(
CallGeneratorMethodIfWrapped,
this,
val,
"GeneratorReturn"
);
}
if (GeneratorObjectIsClosed(this)) {
return { value: val, done: true };
}
if (GeneratorIsRunning(this)) {
ThrowTypeError(45);
}
}
try {
var rval = { value: val, done: true };
return resumeGenerator(this, rval, "return");
} catch (e) {
if (!GeneratorObjectIsClosed(this)) {
GeneratorSetClosed(this);
}
throw e;
}
}
function InterpretGeneratorResume(gen, val, kind) {
forceInterpreter();
if (kind === "next") {
return resumeGenerator(gen, val, "next");
}
if (kind === "throw") {
return resumeGenerator(gen, val, "throw");
}
do { if (!(kind === "return")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Generator.js" + ":" + 112 + ": " + "Invalid resume kind") } } while (false);
return resumeGenerator(gen, val, "return");
}
function IteratorIdentity() {
return this;
}
function IteratorNext(iteratorRecord, value) {
var result =
ArgumentsLength() < 2
? callContentFunction(iteratorRecord.nextMethod, iteratorRecord.iterator)
: callContentFunction(
iteratorRecord.nextMethod,
iteratorRecord.iterator,
value
);
if (!IsObject(result)) {
ThrowTypeError(55, result);
}
return result;
}
function GetIterator(obj, isAsync, method) {
if (!method) {
if (isAsync) {
method = GetMethod(obj, GetBuiltinSymbol("asyncIterator"));
if (!method) {
var syncMethod = GetMethod(obj, GetBuiltinSymbol("iterator"));
var syncIteratorRecord = GetIterator(obj, false, syncMethod);
return CreateAsyncFromSyncIterator(syncIteratorRecord.iterator, syncIteratorRecord.nextMethod);
}
} else {
method = GetMethod(obj, GetBuiltinSymbol("iterator"));
}
}
var iterator = callContentFunction(method, obj);
if (!IsObject(iterator)) {
ThrowTypeError(70, obj === null ? "null" : typeof obj);
}
var nextMethod = iterator.next;
var iteratorRecord = {
__proto__: null,
iterator,
nextMethod,
done: false,
};
return iteratorRecord;
}
function GetIteratorFlattenable(obj, rejectStrings) {
do { if (!(typeof rejectStrings === "boolean")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Iterator.js" + ":" + 84 + ": " + "rejectStrings is a boolean") } } while (false);
if (!IsObject(obj)) {
if (rejectStrings || typeof obj !== "string") {
ThrowTypeError(55, obj === null ? "null" : typeof obj);
}
}
var method = obj[GetBuiltinSymbol("iterator")];
var iterator;
if (IsNullOrUndefined(method)) {
iterator = obj;
} else {
iterator = callContentFunction(method, obj);
}
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
return iterator;
}
function IteratorFrom(O) {
var iterator = GetIteratorFlattenable(O, false);
var nextMethod = iterator.next;
var hasInstance = callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("Iterator"),
iterator
);
if (hasInstance) {
return iterator;
}
var wrapper = NewWrapForValidIterator();
UnsafeSetReservedSlot(
wrapper,
0,
iterator
);
UnsafeSetReservedSlot(
wrapper,
1,
nextMethod
);
return wrapper;
}
function WrapForValidIteratorNext() {
var O = this;
if (!IsObject(O) || (O = GuardToWrapForValidIterator(O)) === null) {
return callFunction(
CallWrapForValidIteratorMethodIfWrapped,
this,
"WrapForValidIteratorNext"
);
}
var iterator = UnsafeGetReservedSlot(O, 0);
var nextMethod = UnsafeGetReservedSlot(O, 1);
return callContentFunction(nextMethod, iterator);
}
function WrapForValidIteratorReturn() {
var O = this;
if (!IsObject(O) || (O = GuardToWrapForValidIterator(O)) === null) {
return callFunction(
CallWrapForValidIteratorMethodIfWrapped,
this,
"WrapForValidIteratorReturn"
);
}
var iterator = UnsafeGetReservedSlot(O, 0);
do { if (!(IsObject(iterator))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Iterator.js" + ":" + 202 + ": " + "iterator is an object") } } while (false);
var returnMethod = iterator.return;
if (IsNullOrUndefined(returnMethod)) {
return {
value: undefined,
done: true,
};
}
return callContentFunction(returnMethod, iterator);
}
function IteratorHelperNext() {
var O = this;
if (!IsObject(O) || (O = GuardToIteratorHelper(O)) === null) {
return callFunction(
CallIteratorHelperMethodIfWrapped,
this,
"IteratorHelperNext"
);
}
var generator = UnsafeGetReservedSlot(O, 0);
return callFunction(GeneratorNext, generator, undefined);
}
function IteratorHelperReturn() {
var O = this;
if (!IsObject(O) || (O = GuardToIteratorHelper(O)) === null) {
return callFunction(
CallIteratorHelperMethodIfWrapped,
this,
"IteratorHelperReturn"
);
}
var generator = UnsafeGetReservedSlot(O, 0);
return callFunction(GeneratorReturn, generator, undefined);
}
function IteratorMap(mapper) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(mapper)) {
ThrowTypeError(11, DecompileArg(0, mapper));
}
var nextMethod = iterator.next;
var result = NewIteratorHelper();
var generator = IteratorMapGenerator(iterator, nextMethod, mapper);
UnsafeSetReservedSlot(
result,
0,
generator
);
callFunction(GeneratorNext, generator);
return result;
}
function* IteratorMapGenerator(iterator, nextMethod, mapper) {
var isReturnCompletion = true;
try {
yield;
isReturnCompletion = false;
} finally {
if (isReturnCompletion) {
IteratorClose(iterator);
}
}
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
var mapped = callContentFunction(mapper, undefined, value, counter);
yield mapped;
counter += 1;
}
}
function IteratorFilter(predicate) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var nextMethod = iterator.next;
var result = NewIteratorHelper();
var generator = IteratorFilterGenerator(iterator, nextMethod, predicate);
UnsafeSetReservedSlot(
result,
0,
generator
);
callFunction(GeneratorNext, generator);
return result;
}
function* IteratorFilterGenerator(iterator, nextMethod, predicate) {
var isReturnCompletion = true;
try {
yield;
isReturnCompletion = false;
} finally {
if (isReturnCompletion) {
IteratorClose(iterator);
}
}
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
var selected = callContentFunction(predicate, undefined, value, counter);
if (selected) {
yield value;
}
counter += 1;
}
}
function IteratorTake(limit) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
var integerLimit = std_Math_trunc(limit);
if (!(integerLimit >= 0)) {
ThrowRangeError(675);
}
var nextMethod = iterator.next;
var result = NewIteratorHelper();
var generator = IteratorTakeGenerator(iterator, nextMethod, integerLimit);
UnsafeSetReservedSlot(
result,
0,
generator
);
callFunction(GeneratorNext, generator);
return result;
}
function* IteratorTakeGenerator(iterator, nextMethod, remaining) {
var isReturnCompletion = true;
try {
yield;
isReturnCompletion = false;
} finally {
if (isReturnCompletion) {
IteratorClose(iterator);
}
}
if (remaining === 0) {
IteratorClose(iterator);
return;
}
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
yield value;
if (--remaining === 0) {
break;
}
}
}
function IteratorDrop(limit) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
var integerLimit = std_Math_trunc(limit);
if (!(integerLimit >= 0)) {
ThrowRangeError(675);
}
var nextMethod = iterator.next;
var result = NewIteratorHelper();
var generator = IteratorDropGenerator(iterator, nextMethod, integerLimit);
UnsafeSetReservedSlot(
result,
0,
generator
);
callFunction(GeneratorNext, generator);
return result;
}
function* IteratorDropGenerator(iterator, nextMethod, remaining) {
var isReturnCompletion = true;
try {
yield;
isReturnCompletion = false;
} finally {
if (isReturnCompletion) {
IteratorClose(iterator);
}
}
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
if (remaining-- <= 0) {
yield value;
}
}
}
function IteratorFlatMap(mapper) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(mapper)) {
ThrowTypeError(11, DecompileArg(0, mapper));
}
var nextMethod = iterator.next;
var result = NewIteratorHelper();
var generator = IteratorFlatMapGenerator(iterator, nextMethod, mapper);
UnsafeSetReservedSlot(
result,
0,
generator
);
callFunction(GeneratorNext, generator);
return result;
}
function* IteratorFlatMapGenerator(iterator, nextMethod, mapper) {
var isReturnCompletion = true;
try {
yield;
isReturnCompletion = false;
} finally {
if (isReturnCompletion) {
IteratorClose(iterator);
}
}
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
var mapped = callContentFunction(mapper, undefined, value, counter);
var innerIterator = GetIteratorFlattenable(mapped, true);
var innerIteratorNextMethod = innerIterator.next;
for (var innerValue of allowContentIterWithNext(innerIterator, innerIteratorNextMethod)) {
yield innerValue;
}
counter += 1;
}
}
function IteratorReduce(reducer ) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(reducer)) {
ThrowTypeError(11, DecompileArg(0, reducer));
}
var nextMethod = iterator.next;
var accumulator;
var counter;
if (ArgumentsLength() === 1) {
counter = -1;
} else {
accumulator = GetArgument(1);
counter = 0;
}
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
if (counter < 0) {
accumulator = value;
counter = 1;
} else {
accumulator = callContentFunction(reducer, undefined, accumulator, value, counter++);
}
}
if (counter < 0) {
ThrowTypeError(52);
}
return accumulator;
}
function IteratorToArray() {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
var nextMethod = iterator.next;
return [...allowContentIterWithNext(iterator, nextMethod)];
}
function IteratorForEach(fn) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(fn)) {
ThrowTypeError(11, DecompileArg(0, fn));
}
var nextMethod = iterator.next;
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
callContentFunction(fn, undefined, value, counter++);
}
}
function IteratorSome(predicate) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var nextMethod = iterator.next;
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
if (callContentFunction(predicate, undefined, value, counter++)) {
return true;
}
}
return false;
}
function IteratorEvery(predicate) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var nextMethod = iterator.next;
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
if (!callContentFunction(predicate, undefined, value, counter++)) {
return false;
}
}
return true;
}
function IteratorFind(predicate) {
var iterator = this;
if (!IsObject(iterator)) {
ThrowTypeError(55, iterator === null ? "null" : typeof iterator);
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var nextMethod = iterator.next;
var counter = 0;
for (var value of allowContentIterWithNext(iterator, nextMethod)) {
if (callContentFunction(predicate, undefined, value, counter++)) {
return value;
}
}
}
function MapConstructorInit(iterable) {
var map = this;
var adder = map.set;
if (!IsCallable(adder)) {
ThrowTypeError(11, typeof adder);
}
for (var nextItem of allowContentIter(iterable)) {
if (!IsObject(nextItem)) {
ThrowTypeError(44, "Map");
}
callContentFunction(adder, map, nextItem[0], nextItem[1]);
}
}
function MapForEach(callbackfn, thisArg = undefined) {
var M = this;
if (!IsObject(M) || (M = GuardToMapObject(M)) === null) {
return callFunction(
CallMapMethodIfWrapped,
this,
callbackfn,
thisArg,
"MapForEach"
);
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var entries = callFunction(std_Map_entries, M);
var mapIterationResultPair = globalMapIterationResultPair;
while (true) {
var done = GetNextMapEntryForIterator(entries, mapIterationResultPair);
if (done) {
break;
}
var key = mapIterationResultPair[0];
var value = mapIterationResultPair[1];
mapIterationResultPair[0] = null;
mapIterationResultPair[1] = null;
callContentFunction(callbackfn, thisArg, value, key, M);
}
}
var globalMapIterationResultPair = CreateMapIterationResultPair();
function MapIteratorNext() {
var O = this;
if (!IsObject(O) || (O = GuardToMapIterator(O)) === null) {
return callFunction(
CallMapIteratorMethodIfWrapped,
this,
"MapIteratorNext"
);
}
var mapIterationResultPair = globalMapIterationResultPair;
var retVal = { value: undefined, done: true };
var done = GetNextMapEntryForIterator(O, mapIterationResultPair);
if (!done) {
var itemKind = UnsafeGetInt32FromReservedSlot(O, 2);
var result;
if (itemKind === 0) {
result = mapIterationResultPair[0];
} else if (itemKind === 1) {
result = mapIterationResultPair[1];
} else {
do { if (!(itemKind === 2)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Map.js" + ":" + 112 + ": " + itemKind) } } while (false);
result = [mapIterationResultPair[0], mapIterationResultPair[1]];
}
mapIterationResultPair[0] = null;
mapIterationResultPair[1] = null;
retVal.value = result;
retVal.done = false;
}
return retVal;
}
function $MapSpecies() {
return this;
}
SetCanonicalName($MapSpecies, "get [Symbol.species]");
function MapGroupBy(items, callbackfn) {
if (IsNullOrUndefined(items)) {
ThrowTypeError(
53,
DecompileArg(0, items),
items === null ? "null" : "undefined"
);
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(1, callbackfn));
}
var C = GetBuiltinConstructor("Map");
var map = new C();
var k = 0;
for (var value of allowContentIter(items)) {
do { if (!(k < 2 ** 53 - 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Map.js" + ":" + 169 + ": " + "out-of-memory happens before k exceeds 2^53 - 1") } } while (false);
var key = callContentFunction(callbackfn, undefined, value, k);
var elements = callFunction(std_Map_get, map, key);
if (elements === undefined) {
callFunction(std_Map_set, map, key, [value]);
} else {
DefineDataProperty(elements, elements.length, value);
}
k += 1;
}
return map;
}
var numberFormatCache = new_Record();
function Number_toLocaleString() {
var x = callFunction(ThisNumberValueForToLocaleString, this);
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var numberFormat;
if (locales === undefined && options === undefined) {
if (!intl_IsRuntimeDefaultLocale(numberFormatCache.runtimeDefaultLocale)) {
numberFormatCache.numberFormat = intl_NumberFormat(locales, options);
numberFormatCache.runtimeDefaultLocale = intl_RuntimeDefaultLocale();
}
numberFormat = numberFormatCache.numberFormat;
} else {
numberFormat = intl_NumberFormat(locales, options);
}
return intl_FormatNumber(numberFormat, x, false);
}
function Number_isFinite(num) {
if (typeof num !== "number") {
return false;
}
return num - num === 0;
}
function Number_isNaN(num) {
if (typeof num !== "number") {
return false;
}
return num !== num;
}
function Number_isInteger(number) {
if (typeof number !== "number") {
return false;
}
var integer = std_Math_trunc(number);
return number - integer === 0;
}
function Number_isSafeInteger(number) {
if (typeof number !== "number") {
return false;
}
var integer = std_Math_trunc(number);
if (number - integer !== 0) {
return false;
}
return -((2 ** 53) - 1) <= integer && integer <= (2 ** 53) - 1;
}
function Global_isNaN(number) {
return Number_isNaN(ToNumber(number));
}
function Global_isFinite(number) {
return Number_isFinite(ToNumber(number));
}
function ObjectGetOwnPropertyDescriptors(O) {
var obj = ToObject(O);
var keys = std_Reflect_ownKeys(obj);
var descriptors = {};
for (var index = 0, len = keys.length; index < len; index++) {
var key = keys[index];
var desc = ObjectGetOwnPropertyDescriptor(obj, key);
if (typeof desc !== "undefined") {
DefineDataProperty(descriptors, key, desc);
}
}
return descriptors;
}
function ObjectGetPrototypeOf(obj) {
return std_Reflect_getPrototypeOf(ToObject(obj));
}
function ObjectIsExtensible(obj) {
return IsObject(obj) && std_Reflect_isExtensible(obj);
}
function Object_toLocaleString() {
var O = this;
return callContentFunction(O.toString, O);
}
function Object_valueOf() {
return ToObject(this);
}
function Object_hasOwnProperty(V) {
return hasOwn(V, this);
}
function $ObjectProtoGetter() {
return std_Reflect_getPrototypeOf(ToObject(this));
}
SetCanonicalName($ObjectProtoGetter, "get __proto__");
function $ObjectProtoSetter(proto) {
return callFunction(std_Object_setProto, this, proto);
}
SetCanonicalName($ObjectProtoSetter, "set __proto__");
function ObjectDefineSetter(name, setter) {
var object = ToObject(this);
if (!IsCallable(setter)) {
ThrowTypeError(32, "setter");
}
var key = (typeof name !== "string" && typeof name !== "number" && typeof name !== "symbol" ? ToPropertyKey(name) : name);
DefineProperty(
object,
key,
0x200 | 0x01 | 0x02,
null,
setter,
true
);
}
function ObjectDefineGetter(name, getter) {
var object = ToObject(this);
if (!IsCallable(getter)) {
ThrowTypeError(32, "getter");
}
var key = (typeof name !== "string" && typeof name !== "number" && typeof name !== "symbol" ? ToPropertyKey(name) : name);
DefineProperty(
object,
key,
0x200 | 0x01 | 0x02,
getter,
null,
true
);
}
function ObjectLookupSetter(name) {
var object = ToObject(this);
var key = (typeof name !== "string" && typeof name !== "number" && typeof name !== "symbol" ? ToPropertyKey(name) : name);
do {
var desc = GetOwnPropertyDescriptorToArray(object, key);
if (desc) {
if (desc[0] & 0x200) {
return desc[2];
}
return undefined;
}
object = std_Reflect_getPrototypeOf(object);
} while (object !== null);
}
function ObjectLookupGetter(name) {
var object = ToObject(this);
var key = (typeof name !== "string" && typeof name !== "number" && typeof name !== "symbol" ? ToPropertyKey(name) : name);
do {
var desc = GetOwnPropertyDescriptorToArray(object, key);
if (desc) {
if (desc[0] & 0x200) {
return desc[1];
}
return undefined;
}
object = std_Reflect_getPrototypeOf(object);
} while (object !== null);
}
function ObjectGetOwnPropertyDescriptor(obj, propertyKey) {
var desc = GetOwnPropertyDescriptorToArray(obj, propertyKey);
if (!desc) {
return undefined;
}
var attrsAndKind = desc[0];
if (attrsAndKind & 0x100) {
return {
value: desc[1],
writable: !!(attrsAndKind & 0x04),
enumerable: !!(attrsAndKind & 0x01),
configurable: !!(attrsAndKind & 0x02),
};
}
do { if (!(attrsAndKind & 0x200)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Object.js" + ":" + 219 + ": " + "expected accessor property descriptor") } } while (false);
return {
get: desc[1],
set: desc[2],
enumerable: !!(attrsAndKind & 0x01),
configurable: !!(attrsAndKind & 0x02),
};
}
function ObjectOrReflectDefineProperty(obj, propertyKey, attributes, strict) {
if (!IsObject(obj)) {
ThrowTypeError(55, DecompileArg(0, obj));
}
propertyKey = (typeof propertyKey !== "string" && typeof propertyKey !== "number" && typeof propertyKey !== "symbol" ? ToPropertyKey(propertyKey) : propertyKey);
if (!IsObject(attributes)) {
ThrowTypeError(
57,
DecompileArg(2, attributes)
);
}
var attrs = 0;
var hasValue = false;
var value;
var getter = null;
var setter = null;
if ("enumerable" in attributes) {
attrs |= attributes.enumerable ? 0x01 : 0x08;
}
if ("configurable" in attributes) {
attrs |= attributes.configurable ? 0x02 : 0x10;
}
if ("value" in attributes) {
attrs |= 0x100;
value = attributes.value;
hasValue = true;
}
if ("writable" in attributes) {
attrs |= 0x100;
attrs |= attributes.writable ? 0x04 : 0x20;
}
if ("get" in attributes) {
attrs |= 0x200;
getter = attributes.get;
if (!IsCallable(getter) && getter !== undefined) {
ThrowTypeError(67, "get");
}
}
if ("set" in attributes) {
attrs |= 0x200;
setter = attributes.set;
if (!IsCallable(setter) && setter !== undefined) {
ThrowTypeError(67, "set");
}
}
if (attrs & 0x200) {
if (attrs & 0x100) {
ThrowTypeError(61);
}
return DefineProperty(obj, propertyKey, attrs, getter, setter, strict);
}
if (hasValue) {
if (strict) {
if (
(attrs & (0x01 | 0x02 | 0x04)) ===
(0x01 | 0x02 | 0x04)
) {
DefineDataProperty(obj, propertyKey, value);
return true;
}
}
return DefineProperty(obj, propertyKey, attrs, value, null, strict);
}
return DefineProperty(obj, propertyKey, attrs, undefined, undefined, strict);
}
function ObjectDefineProperty(obj, propertyKey, attributes) {
if (!ObjectOrReflectDefineProperty(obj, propertyKey, attributes, true)) {
return null;
}
return obj;
}
function ObjectFromEntries(iter) {
var obj = {};
for (var pair of allowContentIter(iter)) {
if (!IsObject(pair)) {
ThrowTypeError(44, "Object.fromEntries");
}
DefineDataProperty(obj, pair[0], pair[1]);
}
return obj;
}
function ObjectHasOwn(O, P) {
var obj = ToObject(O);
return hasOwn(P, obj);
}
function ObjectGroupBy(items, callbackfn) {
if (IsNullOrUndefined(items)) {
ThrowTypeError(
53,
DecompileArg(0, items),
items === null ? "null" : "undefined"
);
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(1, callbackfn));
}
var obj = std_Object_create(null);
var k = 0;
for (var value of allowContentIter(items)) {
do { if (!(k < 2 ** 53 - 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Object.js" + ":" + 404 + ": " + "out-of-memory happens before k exceeds 2^53 - 1") } } while (false);
var key = callContentFunction(callbackfn, undefined, value, k);
key = (typeof key !== "string" && typeof key !== "number" && typeof key !== "symbol" ? ToPropertyKey(key) : key);
var elements = obj[key];
if (elements === undefined) {
DefineDataProperty(obj, key, [value]);
} else {
DefineDataProperty(elements, elements.length, value);
}
k += 1;
}
return obj;
}
function Promise_finally(onFinally) {
var promise = this;
if (!IsObject(promise)) {
ThrowTypeError(3, "Promise", "finally", "value");
}
var C = SpeciesConstructor(promise, GetBuiltinConstructor("Promise"));
do { if (!(IsConstructor(C))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Promise.js" + ":" + 20 + ": " + "SpeciesConstructor returns a constructor function") } } while (false);
var thenFinally, catchFinally;
if (!IsCallable(onFinally)) {
thenFinally = onFinally;
catchFinally = onFinally;
} else {
(thenFinally) = function(value) {
var result = callContentFunction(onFinally, undefined);
var promise = PromiseResolve(C, result);
return callContentFunction(promise.then, promise, function() {
return value;
});
};
(catchFinally) = function(reason) {
var result = callContentFunction(onFinally, undefined);
var promise = PromiseResolve(C, result);
return callContentFunction(promise.then, promise, function() {
throw reason;
});
};
}
return callContentFunction(promise.then, promise, thenFinally, catchFinally);
}
function CreateListFromArrayLikeForArgs(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Reflect.js" + ":" + 14 + ": " + "object must be passed to CreateListFromArrayLikeForArgs") } } while (false);
var len = ToLength(obj.length);
if (len > (500 * 1000)) {
ThrowRangeError(116);
}
var list = std_Array(len);
for (var i = 0; i < len; i++) {
DefineDataProperty(list, i, obj[i]);
}
return list;
}
function Reflect_apply(target, thisArgument, argumentsList) {
if (!IsCallable(target)) {
ThrowTypeError(11, DecompileArg(0, target));
}
if (!IsObject(argumentsList)) {
ThrowTypeError(
56,
"`argumentsList`",
"Reflect.apply",
ToSource(argumentsList)
);
}
return callFunction(std_Function_apply, target, thisArgument, argumentsList);
}
SetIsInlinableLargeFunction(Reflect_apply);
function Reflect_construct(target, argumentsList ) {
if (!IsConstructor(target)) {
ThrowTypeError(13, DecompileArg(0, target));
}
var newTarget;
if (ArgumentsLength() > 2) {
newTarget = GetArgument(2);
if (!IsConstructor(newTarget)) {
ThrowTypeError(13, DecompileArg(2, newTarget));
}
} else {
newTarget = target;
}
if (!IsObject(argumentsList)) {
ThrowTypeError(
56,
"`argumentsList`",
"Reflect.construct",
ToSource(argumentsList)
);
}
var args =
IsPackedArray(argumentsList) && argumentsList.length <= (500 * 1000)
? argumentsList
: CreateListFromArrayLikeForArgs(argumentsList);
switch (args.length) {
case 0:
return constructContentFunction(target, newTarget);
case 1:
return constructContentFunction(target, newTarget, args[0]);
case 2:
return constructContentFunction(target, newTarget, args[0], args[1]);
case 3:
return constructContentFunction(target, newTarget, args[0], args[1], args[2]);
case 4:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3]);
case 5:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4]);
case 6:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5]);
case 7:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
case 8:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
case 9:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
case 10:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
case 11:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10]);
case 12:
return constructContentFunction(target, newTarget, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11]);
default:
return ConstructFunction(target, newTarget, args);
}
}
function Reflect_defineProperty(obj, propertyKey, attributes) {
return ObjectOrReflectDefineProperty(obj, propertyKey, attributes, false);
}
function Reflect_getOwnPropertyDescriptor(target, propertyKey) {
if (!IsObject(target)) {
ThrowTypeError(55, DecompileArg(0, target));
}
return ObjectGetOwnPropertyDescriptor(target, propertyKey);
}
function Reflect_has(target, propertyKey) {
if (!IsObject(target)) {
ThrowTypeError(
56,
"`target`",
"Reflect.has",
ToSource(target)
);
}
return propertyKey in target;
}
function Reflect_get(target, propertyKey ) {
if (!IsObject(target)) {
ThrowTypeError(
56,
"`target`",
"Reflect.get",
ToSource(target)
);
}
if (ArgumentsLength() > 2) {
return getPropertySuper(target, propertyKey, GetArgument(2));
}
return target[propertyKey];
}
function $RegExpFlagsGetter() {
var R = this;
if (!IsObject(R)) {
ThrowTypeError(55, R === null ? "null" : typeof R);
}
var result = "";
if (R.hasIndices) {
result += "d";
}
if (R.global) {
result += "g";
}
if (R.ignoreCase) {
result += "i";
}
if (R.multiline) {
result += "m";
}
if (R.dotAll) {
result += "s";
}
if (R.unicode) {
result += "u";
}
if (R.unicodeSets) {
result += "v";
}
if (R.sticky) {
result += "y";
}
return result;
}
SetCanonicalName($RegExpFlagsGetter, "get flags");
function $RegExpToString() {
var R = this;
if (!IsObject(R)) {
ThrowTypeError(55, R === null ? "null" : typeof R);
}
var pattern = ToString(R.source);
var flags = ToString(R.flags);
return "/" + pattern + "/" + flags;
}
SetCanonicalName($RegExpToString, "toString");
function AdvanceStringIndex(S, index) {
do { if (!(typeof S === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 88 + ": " + "Expected string as 1st argument") } } while (false);
do { if (!(index >= 0 && index <= 0x1fffffffffffff)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 94 + ": " + "Expected integer as 2nd argument") } } while (false);
var supplementary = (
index < S.length &&
callFunction(std_String_codePointAt, S, index) > 0xffff
);
return index + 1 + supplementary;
}
function RegExpMatch(string) {
var rx = this;
if (!IsObject(rx)) {
ThrowTypeError(55, rx === null ? "null" : typeof rx);
}
var S = ToString(string);
if (IsRegExpMethodOptimizable(rx)) {
var flags = UnsafeGetInt32FromReservedSlot(rx, 2);
var global = !!(flags & 0x02);
if (global) {
var fullUnicode = !!(flags & 0x10);
return RegExpGlobalMatchOpt(rx, S, fullUnicode);
}
return RegExpBuiltinExec(rx, S);
}
return RegExpMatchSlowPath(rx, S);
}
function RegExpMatchSlowPath(rx, S) {
var flags = ToString(rx.flags);
if (!callFunction(std_String_includes, flags, "g")) {
return RegExpExec(rx, S);
}
var fullUnicode = callFunction(std_String_includes, flags, "u");
rx.lastIndex = 0;
var A = [];
var n = 0;
while (true) {
var result = RegExpExec(rx, S);
if (result === null) {
return n === 0 ? null : A;
}
var matchStr = ToString(result[0]);
DefineDataProperty(A, n, matchStr);
if (matchStr === "") {
var lastIndex = ToLength(rx.lastIndex);
rx.lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
}
n++;
}
}
function RegExpGlobalMatchOpt(rx, S, fullUnicode) {
var lastIndex = 0;
rx.lastIndex = 0;
var A = [];
var n = 0;
var lengthS = S.length;
while (true) {
var position = RegExpSearcher(rx, S, lastIndex);
if (position === -1) {
return n === 0 ? null : A;
}
lastIndex = RegExpSearcherLastLimit(S);
var matchStr = Substring(S, position, lastIndex - position);
DefineDataProperty(A, n, matchStr);
if (matchStr === "") {
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
return A;
}
}
n++;
}
}
function IsRegExpMethodOptimizable(rx) {
if (!IsRegExpObject(rx)) {
return false;
}
var RegExpProto = GetBuiltinPrototype("RegExp");
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpInstanceOptimizable(rx, RegExpProto) &&
RegExpProto.exec === RegExp_prototype_Exec
);
}
function RegExpReplace(string, replaceValue) {
var rx = this;
if (!IsObject(rx)) {
ThrowTypeError(55, rx === null ? "null" : typeof rx);
}
var S = ToString(string);
var lengthS = S.length;
var functionalReplace = IsCallable(replaceValue);
var firstDollarIndex = -1;
if (!functionalReplace) {
replaceValue = ToString(replaceValue);
if (replaceValue.length > 1) {
firstDollarIndex = GetFirstDollarIndex(replaceValue);
}
}
if (IsRegExpMethodOptimizable(rx)) {
var flags = UnsafeGetInt32FromReservedSlot(rx, 2);
var global = !!(flags & 0x02);
if (global) {
if (functionalReplace) {
if (lengthS > 5000) {
var elemBase = GetElemBaseForLambda(replaceValue);
if (IsObject(elemBase)) {
return RegExpGlobalReplaceOptElemBase(
rx,
S,
lengthS,
replaceValue,
flags,
elemBase
);
}
}
return RegExpGlobalReplaceOptFunc(rx, S, lengthS, replaceValue, flags);
}
if (firstDollarIndex !== -1) {
return RegExpGlobalReplaceOptSubst(
rx,
S,
lengthS,
replaceValue,
flags,
firstDollarIndex
);
}
return RegExpGlobalReplaceOptSimple(rx, S, lengthS, replaceValue, flags);
}
if (functionalReplace) {
return RegExpLocalReplaceOptFunc(rx, S, lengthS, replaceValue);
}
if (firstDollarIndex !== -1) {
return RegExpLocalReplaceOptSubst(
rx,
S,
lengthS,
replaceValue,
firstDollarIndex
);
}
return RegExpLocalReplaceOptSimple(rx, S, lengthS, replaceValue);
}
return RegExpReplaceSlowPath(
rx,
S,
lengthS,
replaceValue,
functionalReplace,
firstDollarIndex
);
}
function RegExpReplaceSlowPath(
rx,
S,
lengthS,
replaceValue,
functionalReplace,
firstDollarIndex
) {
var flags = ToString(rx.flags);
var global = callFunction(std_String_includes, flags, "g");
var fullUnicode = false;
if (global) {
fullUnicode = callFunction(std_String_includes, flags, "u");
rx.lastIndex = 0;
}
var results = new_List();
var nResults = 0;
while (true) {
var result = RegExpExec(rx, S);
if (result === null) {
break;
}
DefineDataProperty(results, nResults++, result);
if (!global) {
break;
}
var matchStr = ToString(result[0]);
if (matchStr === "") {
var lastIndex = ToLength(rx.lastIndex);
rx.lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
}
}
var accumulatedResult = "";
var nextSourcePosition = 0;
for (var i = 0; i < nResults; i++) {
result = results[i];
var nCaptures = std_Math_max(ToLength(result.length) - 1, 0);
var matched = ToString(result[0]);
var matchLength = matched.length;
var position = std_Math_max(
std_Math_min(ToInteger(result.index), lengthS),
0
);
var replacement;
if (functionalReplace || firstDollarIndex !== -1) {
replacement = RegExpGetComplexReplacement(
result,
matched,
S,
position,
nCaptures,
replaceValue,
functionalReplace,
firstDollarIndex
);
} else {
for (var n = 1; n <= nCaptures; n++) {
var capN = result[n];
if (capN !== undefined) {
ToString(capN);
}
}
var namedCaptures = result.groups;
if (namedCaptures !== undefined) {
ToObject(namedCaptures);
}
replacement = replaceValue;
}
if (position >= nextSourcePosition) {
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replacement;
nextSourcePosition = position + matchLength;
}
}
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpGetComplexReplacement(
result,
matched,
S,
position,
nCaptures,
replaceValue,
functionalReplace,
firstDollarIndex
) {
var captures = new_List();
var capturesLength = 0;
DefineDataProperty(captures, capturesLength++, matched);
for (var n = 1; n <= nCaptures; n++) {
var capN = result[n];
if (capN !== undefined) {
capN = ToString(capN);
}
DefineDataProperty(captures, capturesLength++, capN);
}
var namedCaptures = result.groups;
if (functionalReplace) {
if (namedCaptures === undefined) {
switch (nCaptures) {
case 0:
return ToString(
callContentFunction(
replaceValue,
undefined,
captures[0],
position,
S
)
);
case 1:
return ToString(
callContentFunction(
replaceValue,
undefined,
captures[0], captures[1],
position,
S
)
);
case 2:
return ToString(
callContentFunction(
replaceValue,
undefined,
captures[0], captures[1], captures[2],
position,
S
)
);
case 3:
return ToString(
callContentFunction(
replaceValue,
undefined,
captures[0], captures[1], captures[2], captures[3],
position,
S
)
);
case 4:
return ToString(
callContentFunction(
replaceValue,
undefined,
captures[0], captures[1], captures[2], captures[3], captures[4],
position,
S
)
);
}
}
DefineDataProperty(captures, capturesLength++, position);
DefineDataProperty(captures, capturesLength++, S);
if (namedCaptures !== undefined) {
DefineDataProperty(captures, capturesLength++, namedCaptures);
}
return ToString(
callFunction(std_Function_apply, replaceValue, undefined, captures)
);
}
if (namedCaptures !== undefined) {
namedCaptures = ToObject(namedCaptures);
}
return RegExpGetSubstitution(
captures,
S,
position,
replaceValue,
firstDollarIndex,
namedCaptures
);
}
function RegExpGetFunctionalReplacement(result, S, position, replaceValue) {
do { if (!(result.length >= 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 660 + ": " + "RegExpMatcher doesn't return an empty array") } } while (false);
var nCaptures = result.length - 1;
var namedCaptures = result.groups;
if (namedCaptures === undefined) {
switch (nCaptures) {
case 0:
return ToString(
callContentFunction(
replaceValue,
undefined,
result[0],
position,
S
)
);
case 1:
return ToString(
callContentFunction(
replaceValue,
undefined,
result[0], result[1],
position,
S
)
);
case 2:
return ToString(
callContentFunction(
replaceValue,
undefined,
result[0], result[1], result[2],
position,
S
)
);
case 3:
return ToString(
callContentFunction(
replaceValue,
undefined,
result[0], result[1], result[2], result[3],
position,
S
)
);
case 4:
return ToString(
callContentFunction(
replaceValue,
undefined,
result[0], result[1], result[2], result[3], result[4],
position,
S
)
);
}
}
var captures = new_List();
for (var n = 0; n <= nCaptures; n++) {
do { if (!(typeof result[n] === "string" || result[n] === undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 727 + ": " + "RegExpMatcher returns only strings and undefined") } } while (false);
DefineDataProperty(captures, n, result[n]);
}
DefineDataProperty(captures, nCaptures + 1, position);
DefineDataProperty(captures, nCaptures + 2, S);
if (namedCaptures !== undefined) {
DefineDataProperty(captures, nCaptures + 3, namedCaptures);
}
return ToString(
callFunction(std_Function_apply, replaceValue, undefined, captures)
);
}
function RegExpGlobalReplaceOptSimple(rx, S, lengthS, replaceValue, flags) {
var fullUnicode = !!(flags & 0x10);
var lastIndex = 0;
rx.lastIndex = 0;
var accumulatedResult = "";
var nextSourcePosition = 0;
while (true) {
var position = RegExpSearcher(rx, S, lastIndex);
if (position === -1) {
break;
}
lastIndex = RegExpSearcherLastLimit(S);
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replaceValue;
nextSourcePosition = lastIndex;
if (lastIndex === position) {
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
break;
}
}
}
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpGlobalReplaceOptFunc(
rx,
S,
lengthS,
replaceValue,
flags,
) {
var fullUnicode = !!(flags & 0x10);
var lastIndex = 0;
rx.lastIndex = 0;
var originalSource = UnsafeGetStringFromReservedSlot(rx, 1);
var originalFlags = flags;
var hasCaptureGroups = RegExpHasCaptureGroups(rx, S);
var accumulatedResult = "";
var nextSourcePosition = 0;
while (true) {
var replacement;
var matchLength;
if (!hasCaptureGroups) {
var position = RegExpSearcher(rx, S, lastIndex);
if (position === -1) {
break;
}
lastIndex = RegExpSearcherLastLimit(S);
var matched = Substring(S, position, lastIndex - position);
matchLength = matched.length;
replacement = ToString(
callContentFunction(
replaceValue,
undefined,
matched,
position,
S
)
);
} else
{
var result = RegExpMatcher(rx, S, lastIndex);
if (result === null) {
break;
}
do { if (!(result.length >= 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExpGlobalReplaceOpt.h.js" + ":" + 105 + ": " + "RegExpMatcher doesn't return an empty array") } } while (false);
var matched = result[0];
matchLength = matched.length | 0;
var position = result.index | 0;
lastIndex = position + matchLength;
replacement = RegExpGetFunctionalReplacement(
result,
S,
position,
replaceValue
);
}
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replacement;
nextSourcePosition = lastIndex;
if (matchLength === 0) {
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
break;
}
lastIndex |= 0;
}
if (
UnsafeGetStringFromReservedSlot(rx, 1) !==
originalSource ||
UnsafeGetInt32FromReservedSlot(rx, 2) !== originalFlags
) {
rx = RegExpConstructRaw(originalSource, originalFlags);
}
}
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpGlobalReplaceOptElemBase(
rx,
S,
lengthS,
replaceValue,
flags,
elemBase
) {
var fullUnicode = !!(flags & 0x10);
var lastIndex = 0;
rx.lastIndex = 0;
var originalSource = UnsafeGetStringFromReservedSlot(rx, 1);
var originalFlags = flags;
var accumulatedResult = "";
var nextSourcePosition = 0;
while (true) {
var replacement;
var matchLength;
{
var result = RegExpMatcher(rx, S, lastIndex);
if (result === null) {
break;
}
do { if (!(result.length >= 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExpGlobalReplaceOpt.h.js" + ":" + 105 + ": " + "RegExpMatcher doesn't return an empty array") } } while (false);
var matched = result[0];
matchLength = matched.length | 0;
var position = result.index | 0;
lastIndex = position + matchLength;
if (IsObject(elemBase)) {
var prop = GetStringDataProperty(elemBase, matched);
if (prop !== undefined) {
do { if (!(typeof prop === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExpGlobalReplaceOpt.h.js" + ":" + 147 + ": " + "GetStringDataProperty should return either string or undefined") } } while (false);
replacement = prop;
} else {
elemBase = undefined;
}
}
if (!IsObject(elemBase)) {
replacement = RegExpGetFunctionalReplacement(
result,
S,
position,
replaceValue
);
}
}
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replacement;
nextSourcePosition = lastIndex;
if (matchLength === 0) {
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
break;
}
lastIndex |= 0;
}
if (
UnsafeGetStringFromReservedSlot(rx, 1) !==
originalSource ||
UnsafeGetInt32FromReservedSlot(rx, 2) !== originalFlags
) {
rx = RegExpConstructRaw(originalSource, originalFlags);
}
}
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpGlobalReplaceOptSubst(
rx,
S,
lengthS,
replaceValue,
flags,
firstDollarIndex,
) {
var fullUnicode = !!(flags & 0x10);
var lastIndex = 0;
rx.lastIndex = 0;
var accumulatedResult = "";
var nextSourcePosition = 0;
while (true) {
var replacement;
var matchLength;
{
var result = RegExpMatcher(rx, S, lastIndex);
if (result === null) {
break;
}
do { if (!(result.length >= 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExpGlobalReplaceOpt.h.js" + ":" + 105 + ": " + "RegExpMatcher doesn't return an empty array") } } while (false);
var matched = result[0];
matchLength = matched.length | 0;
var position = result.index | 0;
lastIndex = position + matchLength;
var namedCaptures = result.groups;
if (namedCaptures !== undefined) {
namedCaptures = ToObject(namedCaptures);
}
replacement = RegExpGetSubstitution(
result,
S,
position,
replaceValue,
firstDollarIndex,
namedCaptures
);
}
accumulatedResult +=
Substring(S, nextSourcePosition, position - nextSourcePosition) +
replacement;
nextSourcePosition = lastIndex;
if (matchLength === 0) {
lastIndex = fullUnicode
? AdvanceStringIndex(S, lastIndex)
: lastIndex + 1;
if (lastIndex > lengthS) {
break;
}
lastIndex |= 0;
}
}
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpLocalReplaceOptSimple(
rx,
S,
lengthS,
replaceValue,
) {
var lastIndex = ToLength(rx.lastIndex);
var flags = UnsafeGetInt32FromReservedSlot(rx, 2);
var globalOrSticky = !!(flags & (0x02 | 0x08));
if (globalOrSticky) {
if (lastIndex > lengthS) {
if (globalOrSticky) {
rx.lastIndex = 0;
}
return S;
}
} else {
lastIndex = 0;
}
var position = RegExpSearcher(rx, S, lastIndex);
if (position === -1) {
if (globalOrSticky) {
rx.lastIndex = 0;
}
return S;
}
var nextSourcePosition = RegExpSearcherLastLimit(S);
if (globalOrSticky) {
rx.lastIndex = nextSourcePosition;
}
var replacement;
replacement = replaceValue;
var accumulatedResult = Substring(S, 0, position) + replacement;
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpLocalReplaceOptFunc(
rx,
S,
lengthS,
replaceValue,
) {
var lastIndex = ToLength(rx.lastIndex);
var flags = UnsafeGetInt32FromReservedSlot(rx, 2);
var globalOrSticky = !!(flags & (0x02 | 0x08));
if (globalOrSticky) {
if (lastIndex > lengthS) {
if (globalOrSticky) {
rx.lastIndex = 0;
}
return S;
}
} else {
lastIndex = 0;
}
var result = RegExpMatcher(rx, S, lastIndex);
if (result === null) {
if (globalOrSticky) {
rx.lastIndex = 0;
}
return S;
}
do { if (!(result.length >= 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExpLocalReplaceOpt.h.js" + ":" + 93 + ": " + "RegExpMatcher doesn't return an empty array") } } while (false);
var matched = result[0];
var matchLength = matched.length;
var position = result.index;
var nextSourcePosition = position + matchLength;
if (globalOrSticky) {
rx.lastIndex = nextSourcePosition;
}
var replacement;
replacement = RegExpGetFunctionalReplacement(
result,
S,
position,
replaceValue
);
var accumulatedResult = Substring(S, 0, position) + replacement;
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpLocalReplaceOptSubst(
rx,
S,
lengthS,
replaceValue,
firstDollarIndex
) {
var lastIndex = ToLength(rx.lastIndex);
var flags = UnsafeGetInt32FromReservedSlot(rx, 2);
var globalOrSticky = !!(flags & (0x02 | 0x08));
if (globalOrSticky) {
if (lastIndex > lengthS) {
if (globalOrSticky) {
rx.lastIndex = 0;
}
return S;
}
} else {
lastIndex = 0;
}
var result = RegExpMatcher(rx, S, lastIndex);
if (result === null) {
if (globalOrSticky) {
rx.lastIndex = 0;
}
return S;
}
do { if (!(result.length >= 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExpLocalReplaceOpt.h.js" + ":" + 93 + ": " + "RegExpMatcher doesn't return an empty array") } } while (false);
var matched = result[0];
var matchLength = matched.length;
var position = result.index;
var nextSourcePosition = position + matchLength;
if (globalOrSticky) {
rx.lastIndex = nextSourcePosition;
}
var replacement;
var namedCaptures = result.groups;
if (namedCaptures !== undefined) {
namedCaptures = ToObject(namedCaptures);
}
replacement = RegExpGetSubstitution(
result,
S,
position,
replaceValue,
firstDollarIndex,
namedCaptures
);
var accumulatedResult = Substring(S, 0, position) + replacement;
if (nextSourcePosition >= lengthS) {
return accumulatedResult;
}
return (
accumulatedResult +
Substring(S, nextSourcePosition, lengthS - nextSourcePosition)
);
}
function RegExpSearch(string) {
var rx = this;
if (!IsObject(rx)) {
ThrowTypeError(55, rx === null ? "null" : typeof rx);
}
var S = ToString(string);
var previousLastIndex = rx.lastIndex;
var lastIndexIsZero = SameValue(previousLastIndex, 0);
if (!lastIndexIsZero) {
rx.lastIndex = 0;
}
if (IsRegExpMethodOptimizable(rx) && S.length < 0x7fff) {
var result = RegExpSearcher(rx, S, 0);
if (!lastIndexIsZero) {
rx.lastIndex = previousLastIndex;
} else {
var flags = UnsafeGetInt32FromReservedSlot(rx, 2);
if (flags & (0x02 | 0x08)) {
rx.lastIndex = previousLastIndex;
}
}
return result;
}
return RegExpSearchSlowPath(rx, S, previousLastIndex);
}
function RegExpSearchSlowPath(rx, S, previousLastIndex) {
var result = RegExpExec(rx, S);
var currentLastIndex = rx.lastIndex;
if (!SameValue(currentLastIndex, previousLastIndex)) {
rx.lastIndex = previousLastIndex;
}
if (result === null) {
return -1;
}
return result.index;
}
function IsRegExpSplitOptimizable(rx, C) {
if (!IsRegExpObject(rx)) {
return false;
}
var RegExpCtor = GetBuiltinConstructor("RegExp");
if (C !== RegExpCtor) {
return false;
}
var RegExpProto = RegExpCtor.prototype;
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpInstanceOptimizable(rx, RegExpProto) &&
RegExpProto.exec === RegExp_prototype_Exec
);
}
function RegExpSplit(string, limit) {
var rx = this;
if (!IsObject(rx)) {
ThrowTypeError(55, rx === null ? "null" : typeof rx);
}
var S = ToString(string);
var C = SpeciesConstructor(rx, GetBuiltinConstructor("RegExp"));
var optimizable =
IsRegExpSplitOptimizable(rx, C) &&
(limit === undefined || typeof limit === "number");
var flags, unicodeMatching, splitter;
if (optimizable) {
flags = UnsafeGetInt32FromReservedSlot(rx, 2);
unicodeMatching = !!(flags & 0x10);
if (flags & 0x08) {
var source = UnsafeGetStringFromReservedSlot(rx, 1);
splitter = RegExpConstructRaw(source, flags & ~0x08);
} else {
splitter = rx;
}
} else {
flags = ToString(rx.flags);
unicodeMatching = callFunction(std_String_includes, flags, "u");
var newFlags;
if (callFunction(std_String_includes, flags, "y")) {
newFlags = flags;
} else {
newFlags = flags + "y";
}
splitter = constructContentFunction(C, C, rx, newFlags);
}
var A = [];
var lengthA = 0;
var lim;
if (limit === undefined) {
lim = 0xffffffff;
} else {
lim = limit >>> 0;
}
var p = 0;
if (lim === 0) {
return A;
}
var size = S.length;
if (size === 0) {
if (optimizable) {
if (RegExpSearcher(splitter, S, 0) !== -1) {
return A;
}
} else {
if (RegExpExec(splitter, S) !== null) {
return A;
}
}
DefineDataProperty(A, 0, S);
return A;
}
var q = p;
var optimizableNoCaptures = optimizable && !RegExpHasCaptureGroups(splitter, S);
while (q < size) {
var e, z;
if (optimizableNoCaptures) {
q = RegExpSearcher(splitter, S, q);
if (q === -1 || q >= size) {
break;
}
e = RegExpSearcherLastLimit(S);
z = null;
} else if (optimizable) {
z = RegExpMatcher(splitter, S, q);
if (z === null) {
break;
}
q = z.index;
if (q >= size) {
break;
}
e = q + z[0].length;
} else {
splitter.lastIndex = q;
z = RegExpExec(splitter, S);
if (z === null) {
q = unicodeMatching ? AdvanceStringIndex(S, q) : q + 1;
continue;
}
e = ToLength(splitter.lastIndex);
}
if (e === p) {
q = unicodeMatching ? AdvanceStringIndex(S, q) : q + 1;
continue;
}
DefineDataProperty(A, lengthA, Substring(S, p, q - p));
lengthA++;
if (lengthA === lim) {
return A;
}
p = e;
if (z !== null) {
var numberOfCaptures = std_Math_max(ToLength(z.length) - 1, 0);
var i = 1;
while (i <= numberOfCaptures) {
DefineDataProperty(A, lengthA, z[i]);
i++;
lengthA++;
if (lengthA === lim) {
return A;
}
}
}
q = p;
}
if (p >= size) {
DefineDataProperty(A, lengthA, "");
} else {
DefineDataProperty(A, lengthA, Substring(S, p, size - p));
}
return A;
}
function RegExp_prototype_Exec(string) {
var R = this;
if (!IsObject(R) || !IsRegExpObject(R)) {
return callFunction(
CallRegExpMethodIfWrapped,
R,
string,
"RegExp_prototype_Exec"
);
}
var S = ToString(string);
return RegExpBuiltinExec(R, S);
}
function RegExpTest(string) {
var R = this;
if (!IsObject(R)) {
ThrowTypeError(55, R === null ? "null" : typeof R);
}
var S = ToString(string);
return RegExpExecForTest(R, S);
}
function $RegExpSpecies() {
return this;
}
SetCanonicalName($RegExpSpecies, "get [Symbol.species]");
function IsRegExpMatchAllOptimizable(rx, C) {
if (!IsRegExpObject(rx)) {
return false;
}
var RegExpCtor = GetBuiltinConstructor("RegExp");
if (C !== RegExpCtor) {
return false;
}
var RegExpProto = RegExpCtor.prototype;
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpInstanceOptimizable(rx, RegExpProto)
);
}
function RegExpMatchAll(string) {
var rx = this;
if (!IsObject(rx)) {
ThrowTypeError(55, rx === null ? "null" : typeof rx);
}
var str = ToString(string);
var C = SpeciesConstructor(rx, GetBuiltinConstructor("RegExp"));
var source, flags, matcher, lastIndex;
if (IsRegExpMatchAllOptimizable(rx, C)) {
source = UnsafeGetStringFromReservedSlot(rx, 1);
flags = UnsafeGetInt32FromReservedSlot(rx, 2);
matcher = rx;
lastIndex = ToLength(rx.lastIndex);
} else {
source = "";
flags = ToString(rx.flags);
matcher = constructContentFunction(C, C, rx, flags);
matcher.lastIndex = ToLength(rx.lastIndex);
flags =
(callFunction(std_String_includes, flags, "g") ? 0x02 : 0) |
(callFunction(std_String_includes, flags, "u") ? 0x10 : 0);
lastIndex = -2;
}
return CreateRegExpStringIterator(matcher, str, source, flags, lastIndex);
}
function CreateRegExpStringIterator(regexp, string, source, flags, lastIndex) {
do { if (!(typeof string === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 1316 + ": " + "|string| is a string value") } } while (false);
do { if (!(typeof flags === "number")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 1319 + ": " + "|flags| is a number value") } } while (false);
do { if (!(typeof source === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 1321 + ": " + "|source| is a string value") } } while (false);
do { if (!(typeof lastIndex === "number")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 1322 + ": " + "|lastIndex| is a number value") } } while (false);
var iterator = NewRegExpStringIterator();
UnsafeSetReservedSlot(iterator, 0, regexp);
UnsafeSetReservedSlot(iterator, 1, string);
UnsafeSetReservedSlot(iterator, 2, source);
UnsafeSetReservedSlot(iterator, 3, flags | 0);
UnsafeSetReservedSlot(
iterator,
4,
lastIndex
);
return iterator;
}
function IsRegExpStringIteratorNextOptimizable() {
var RegExpProto = GetBuiltinPrototype("RegExp");
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpProto.exec === RegExp_prototype_Exec
);
}
function RegExpStringIteratorNext() {
var obj = this;
if (!IsObject(obj) || (obj = GuardToRegExpStringIterator(obj)) === null) {
return callFunction(
CallRegExpStringIteratorMethodIfWrapped,
this,
"RegExpStringIteratorNext"
);
}
var result = { value: undefined, done: false };
var lastIndex = UnsafeGetReservedSlot(
obj,
4
);
if (lastIndex === -1) {
result.done = true;
return result;
}
var regexp = UnsafeGetObjectFromReservedSlot(
obj,
0
);
var string = UnsafeGetStringFromReservedSlot(
obj,
1
);
var flags = UnsafeGetInt32FromReservedSlot(
obj,
3
);
var global = !!(flags & 0x02);
var fullUnicode = !!(flags & 0x10);
if (lastIndex >= 0) {
do { if (!(IsRegExpObject(regexp))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/RegExp.js" + ":" + 1397 + ": " + "|regexp| is a RegExp object") } } while (false);
var source = UnsafeGetStringFromReservedSlot(
obj,
2
);
if (
IsRegExpStringIteratorNextOptimizable() &&
UnsafeGetStringFromReservedSlot(regexp, 1) === source &&
UnsafeGetInt32FromReservedSlot(regexp, 2) === flags
) {
var globalOrSticky = !!(
flags &
(0x02 | 0x08)
);
if (!globalOrSticky) {
lastIndex = 0;
}
var match =
lastIndex <= string.length
? RegExpMatcher(regexp, string, lastIndex)
: null;
if (match === null) {
UnsafeSetReservedSlot(
obj,
4,
-1
);
result.done = true;
return result;
}
if (global) {
var matchLength = match[0].length;
lastIndex = match.index + matchLength;
if (matchLength === 0) {
lastIndex = fullUnicode
? AdvanceStringIndex(string, lastIndex)
: lastIndex + 1;
}
UnsafeSetReservedSlot(
obj,
4,
lastIndex
);
} else {
UnsafeSetReservedSlot(
obj,
4,
-1
);
}
result.value = match;
return result;
}
regexp = RegExpConstructRaw(source, flags);
regexp.lastIndex = lastIndex;
UnsafeSetReservedSlot(obj, 0, regexp);
UnsafeSetReservedSlot(
obj,
4,
-2
);
}
var match = RegExpExec(regexp, string);
if (match === null) {
UnsafeSetReservedSlot(
obj,
4,
-1
);
result.done = true;
return result;
}
if (global) {
var matchStr = ToString(match[0]);
if (matchStr.length === 0) {
var thisIndex = ToLength(regexp.lastIndex);
var nextIndex = fullUnicode
? AdvanceStringIndex(string, thisIndex)
: thisIndex + 1;
regexp.lastIndex = nextIndex;
}
} else {
UnsafeSetReservedSlot(
obj,
4,
-1
);
}
result.value = match;
return result;
}
function IsRegExp(argument) {
if (!IsObject(argument)) {
return false;
}
var matcher = argument[GetBuiltinSymbol("match")];
if (matcher !== undefined) {
return !!matcher;
}
return IsPossiblyWrappedRegExpObject(argument);
}
function StringProtoHasNoMatch() {
var ObjectProto = GetBuiltinPrototype("Object");
var StringProto = GetBuiltinPrototype("String");
if (!ObjectHasPrototype(StringProto, ObjectProto)) {
return false;
}
return !(GetBuiltinSymbol("match") in StringProto);
}
function IsStringMatchOptimizable() {
var RegExpProto = GetBuiltinPrototype("RegExp");
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpProto.exec === RegExp_prototype_Exec &&
RegExpProto[GetBuiltinSymbol("match")] === RegExpMatch
);
}
function ThrowIncompatibleMethod(name, thisv) {
ThrowTypeError(3, "String", name, ToString(thisv));
}
function String_match(regexp) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("match", this);
}
var isPatternString = typeof regexp === "string";
if (
!(isPatternString && StringProtoHasNoMatch()) &&
!IsNullOrUndefined(regexp)
) {
var matcher = GetMethod(regexp, GetBuiltinSymbol("match"));
if (matcher !== undefined) {
return callContentFunction(matcher, regexp, this);
}
}
var S = ToString(this);
if (isPatternString && IsStringMatchOptimizable()) {
var flatResult = FlatStringMatch(S, regexp);
if (flatResult !== undefined) {
return flatResult;
}
}
var rx = RegExpCreate(regexp);
if (IsStringMatchOptimizable()) {
return RegExpMatcher(rx, S, 0);
}
return callContentFunction(GetMethod(rx, GetBuiltinSymbol("match")), rx, S);
}
function String_matchAll(regexp) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("matchAll", this);
}
if (!IsNullOrUndefined(regexp)) {
if (IsRegExp(regexp)) {
var flags = regexp.flags;
if (IsNullOrUndefined(flags)) {
ThrowTypeError(108);
}
if (!callFunction(std_String_includes, ToString(flags), "g")) {
ThrowTypeError(109, "matchAll");
}
}
var matcher = GetMethod(regexp, GetBuiltinSymbol("matchAll"));
if (matcher !== undefined) {
return callContentFunction(matcher, regexp, this);
}
}
var string = ToString(this);
var rx = RegExpCreate(regexp, "g");
return callContentFunction(
GetMethod(rx, GetBuiltinSymbol("matchAll")),
rx,
string
);
}
function String_pad(maxLength, fillString, padEnd) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod(padEnd ? "padEnd" : "padStart", this);
}
var str = ToString(this);
var intMaxLength = ToLength(maxLength);
var strLen = str.length;
if (intMaxLength <= strLen) {
return str;
}
do { if (!(fillString !== undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 146 + ": " + "never called when fillString is undefined") } } while (false);
var filler = ToString(fillString);
if (filler === "") {
return str;
}
if (intMaxLength > ((1 << 30) - 2)) {
ThrowRangeError(107);
}
var fillLen = intMaxLength - strLen;
var truncatedStringFiller = callFunction(
String_repeat,
filler,
(fillLen / filler.length) | 0
);
truncatedStringFiller += Substring(filler, 0, fillLen % filler.length);
if (padEnd === true) {
return str + truncatedStringFiller;
}
return truncatedStringFiller + str;
}
function String_pad_start(maxLength, fillString = " ") {
return callFunction(String_pad, this, maxLength, fillString, false);
}
function String_pad_end(maxLength, fillString = " ") {
return callFunction(String_pad, this, maxLength, fillString, true);
}
function StringProtoHasNoReplace() {
var ObjectProto = GetBuiltinPrototype("Object");
var StringProto = GetBuiltinPrototype("String");
if (!ObjectHasPrototype(StringProto, ObjectProto)) {
return false;
}
return !(GetBuiltinSymbol("replace") in StringProto);
}
function Substring(str, from, length) {
do { if (!(typeof str === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 201 + ": " + "|str| should be a string") } } while (false);
do { if (!((from | 0) === from)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 205 + ": " + "coercing |from| into int32 should not change the value") } } while (false);
do { if (!((length | 0) === length)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 209 + ": " + "coercing |length| into int32 should not change the value") } } while (false);
return SubstringKernel(
str,
std_Math_max(from, 0) | 0,
std_Math_max(length, 0) | 0
);
}
function String_replace(searchValue, replaceValue) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("replace", this);
}
if (
!(typeof searchValue === "string" && StringProtoHasNoReplace()) &&
!IsNullOrUndefined(searchValue)
) {
var replacer = GetMethod(searchValue, GetBuiltinSymbol("replace"));
if (replacer !== undefined) {
return callContentFunction(replacer, searchValue, this, replaceValue);
}
}
var string = ToString(this);
var searchString = ToString(searchValue);
if (typeof replaceValue === "string") {
return StringReplaceString(string, searchString, replaceValue);
}
if (!IsCallable(replaceValue)) {
return StringReplaceString(string, searchString, ToString(replaceValue));
}
var pos = callFunction(std_String_indexOf, string, searchString);
if (pos === -1) {
return string;
}
var replStr = ToString(
callContentFunction(replaceValue, undefined, searchString, pos, string)
);
var tailPos = pos + searchString.length;
var newString;
if (pos === 0) {
newString = "";
} else {
newString = Substring(string, 0, pos);
}
newString += replStr;
var stringLength = string.length;
if (tailPos < stringLength) {
newString += Substring(string, tailPos, stringLength - tailPos);
}
return newString;
}
function String_replaceAll(searchValue, replaceValue) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("replaceAll", this);
}
if (!IsNullOrUndefined(searchValue)) {
if (IsRegExp(searchValue)) {
var flags = searchValue.flags;
if (IsNullOrUndefined(flags)) {
ThrowTypeError(108);
}
if (!callFunction(std_String_includes, ToString(flags), "g")) {
ThrowTypeError(109, "replaceAll");
}
}
var replacer = GetMethod(searchValue, GetBuiltinSymbol("replace"));
if (replacer !== undefined) {
return callContentFunction(replacer, searchValue, this, replaceValue);
}
}
var string = ToString(this);
var searchString = ToString(searchValue);
if (!IsCallable(replaceValue)) {
return StringReplaceAllString(string, searchString, ToString(replaceValue));
}
var searchLength = searchString.length;
var advanceBy = std_Math_max(1, searchLength);
var endOfLastMatch = 0;
var result = "";
var position = 0;
while (true) {
var nextPosition = callFunction(
std_String_indexOf,
string,
searchString,
position
);
if (nextPosition < position) {
break;
}
position = nextPosition;
var replacement = ToString(
callContentFunction(
replaceValue,
undefined,
searchString,
position,
string
)
);
var stringSlice = Substring(
string,
endOfLastMatch,
position - endOfLastMatch
);
result += stringSlice + replacement;
endOfLastMatch = position + searchLength;
position += advanceBy;
}
if (endOfLastMatch < string.length) {
result += Substring(string, endOfLastMatch, string.length - endOfLastMatch);
}
return result;
}
function StringProtoHasNoSearch() {
var ObjectProto = GetBuiltinPrototype("Object");
var StringProto = GetBuiltinPrototype("String");
if (!ObjectHasPrototype(StringProto, ObjectProto)) {
return false;
}
return !(GetBuiltinSymbol("search") in StringProto);
}
function IsStringSearchOptimizable() {
var RegExpProto = GetBuiltinPrototype("RegExp");
return (
RegExpPrototypeOptimizable(RegExpProto) &&
RegExpProto.exec === RegExp_prototype_Exec &&
RegExpProto[GetBuiltinSymbol("search")] === RegExpSearch
);
}
function String_search(regexp) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("search", this);
}
var isPatternString = typeof regexp === "string";
if (
!(isPatternString && StringProtoHasNoSearch()) &&
!IsNullOrUndefined(regexp)
) {
var searcher = GetMethod(regexp, GetBuiltinSymbol("search"));
if (searcher !== undefined) {
return callContentFunction(searcher, regexp, this);
}
}
var string = ToString(this);
if (isPatternString && IsStringSearchOptimizable()) {
var flatResult = FlatStringSearch(string, regexp);
if (flatResult !== -2) {
return flatResult;
}
}
var rx = RegExpCreate(regexp);
return callContentFunction(
GetMethod(rx, GetBuiltinSymbol("search")),
rx,
string
);
}
function StringProtoHasNoSplit() {
var ObjectProto = GetBuiltinPrototype("Object");
var StringProto = GetBuiltinPrototype("String");
if (!ObjectHasPrototype(StringProto, ObjectProto)) {
return false;
}
return !(GetBuiltinSymbol("split") in StringProto);
}
function String_split(separator, limit) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("split", this);
}
if (typeof this === "string") {
if (StringProtoHasNoSplit()) {
if (typeof separator === "string") {
if (limit === undefined) {
return StringSplitString(this, separator);
}
}
}
}
if (
!(typeof separator === "string" && StringProtoHasNoSplit()) &&
!IsNullOrUndefined(separator)
) {
var splitter = GetMethod(separator, GetBuiltinSymbol("split"));
if (splitter !== undefined) {
return callContentFunction(splitter, separator, this, limit);
}
}
var S = ToString(this);
var R;
if (limit !== undefined) {
var lim = limit >>> 0;
R = ToString(separator);
if (lim === 0) {
return [];
}
if (separator === undefined) {
return [S];
}
return StringSplitStringLimit(S, R, lim);
}
R = ToString(separator);
if (separator === undefined) {
return [S];
}
return StringSplitString(S, R);
}
function String_substring(start, end) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("substring", this);
}
var str = ToString(this);
var len = str.length;
var intStart = ToInteger(start);
var intEnd = end === undefined ? len : ToInteger(end);
var finalStart = std_Math_min(std_Math_max(intStart, 0), len);
var finalEnd = std_Math_min(std_Math_max(intEnd, 0), len);
var from = std_Math_min(finalStart, finalEnd);
var to = std_Math_max(finalStart, finalEnd);
return SubstringKernel(str, from | 0, (to - from) | 0);
}
SetIsInlinableLargeFunction(String_substring);
function String_substr(start, length) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("substr", this);
}
var str = ToString(this);
var intStart = ToInteger(start);
var size = str.length;
var end = length === undefined ? size : ToInteger(length);
if (intStart < 0) {
intStart = std_Math_max(intStart + size, 0);
} else {
intStart = std_Math_min(intStart, size);
}
var resultLength = std_Math_min(std_Math_max(end, 0), size - intStart);
do { if (!(0 <= resultLength && resultLength <= size - intStart)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 633 + ": " + "resultLength is a valid substring length value") } } while (false);
return SubstringKernel(str, intStart | 0, resultLength | 0);
}
SetIsInlinableLargeFunction(String_substr);
function String_concat(arg1) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("concat", this);
}
var str = ToString(this);
if (ArgumentsLength() === 0) {
return str;
}
if (ArgumentsLength() === 1) {
return str + ToString(GetArgument(0));
}
if (ArgumentsLength() === 2) {
return str + ToString(GetArgument(0)) + ToString(GetArgument(1));
}
var result = str;
for (var i = 0; i < ArgumentsLength(); i++) {
var nextString = ToString(GetArgument(i));
result += nextString;
}
return result;
}
function String_slice(start, end) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("slice", this);
}
var str = ToString(this);
var len = str.length;
var intStart = ToInteger(start);
var intEnd = end === undefined ? len : ToInteger(end);
var from =
intStart < 0
? std_Math_max(len + intStart, 0)
: std_Math_min(intStart, len);
var to =
intEnd < 0 ? std_Math_max(len + intEnd, 0) : std_Math_min(intEnd, len);
var span = std_Math_max(to - from, 0);
return SubstringKernel(str, from | 0, span | 0);
}
SetIsInlinableLargeFunction(String_slice);
function String_repeat(count) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("repeat", this);
}
var S = ToString(this);
var n = ToInteger(count);
if (n < 0) {
ThrowRangeError(105);
}
if (!(n * S.length <= ((1 << 30) - 2))) {
ThrowRangeError(107);
}
do { if (!(((((1 << 30) - 2) + 1) | 0) === ((1 << 30) - 2) + 1)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 754 + ": " + "MAX_STRING_LENGTH + 1 must fit in int32") } } while (false);
do { if (!(((((1 << 30) - 2) + 1) & (((1 << 30) - 2) + 2)) === 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/String.js" + ":" + 758 + ": " + "MAX_STRING_LENGTH + 1 can be used as a bitmask") } } while (false);
n = n & (((1 << 30) - 2) + 1);
var T = "";
for (;;) {
if (n & 1) {
T += S;
}
n >>= 1;
if (n) {
S += S;
} else {
break;
}
}
return T;
}
function String_iterator() {
if (IsNullOrUndefined(this)) {
ThrowTypeError(
4,
"String",
"Symbol.iterator",
ToString(this)
);
}
var S = ToString(this);
var iterator = NewStringIterator();
UnsafeSetReservedSlot(iterator, 0, S);
UnsafeSetReservedSlot(iterator, 1, 0);
return iterator;
}
function StringIteratorNext() {
var obj = this;
if (!IsObject(obj) || (obj = GuardToStringIterator(obj)) === null) {
return callFunction(
CallStringIteratorMethodIfWrapped,
this,
"StringIteratorNext"
);
}
var S = UnsafeGetStringFromReservedSlot(obj, 0);
var index = UnsafeGetInt32FromReservedSlot(obj, 1);
var size = S.length;
var result = { value: undefined, done: false };
if (index >= size) {
result.done = true;
return result;
}
var codePoint = callFunction(std_String_codePointAt, S, index);
var charCount = 1 + (codePoint > 0xffff);
UnsafeSetReservedSlot(obj, 1, index + charCount);
result.value = callFunction(std_String_fromCodePoint, null, codePoint);
return result;
}
SetIsInlinableLargeFunction(StringIteratorNext);
var collatorCache = new_Record();
function String_localeCompare(that) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("localeCompare", this);
}
var S = ToString(this);
var That = ToString(that);
var locales = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var options = ArgumentsLength() > 2 ? GetArgument(2) : undefined;
var collator;
if (locales === undefined && options === undefined) {
if (!intl_IsRuntimeDefaultLocale(collatorCache.runtimeDefaultLocale)) {
collatorCache.collator = intl_Collator(locales, options);
collatorCache.runtimeDefaultLocale = intl_RuntimeDefaultLocale();
}
collator = collatorCache.collator;
} else {
collator = intl_Collator(locales, options);
}
return intl_CompareStrings(collator, S, That);
}
function String_toLocaleLowerCase() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("toLocaleLowerCase", this);
}
var string = ToString(this);
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var requestedLocale;
if (locales === undefined) {
requestedLocale = undefined;
} else if (typeof locales === "string") {
requestedLocale = intl_ValidateAndCanonicalizeLanguageTag(locales, false);
} else {
var requestedLocales = CanonicalizeLocaleList(locales);
requestedLocale = requestedLocales.length ? requestedLocales[0] : undefined;
}
if (string.length === 0) {
return "";
}
if (requestedLocale === undefined) {
requestedLocale = DefaultLocale();
}
return intl_toLocaleLowerCase(string, requestedLocale);
}
function String_toLocaleUpperCase() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("toLocaleUpperCase", this);
}
var string = ToString(this);
var locales = ArgumentsLength() ? GetArgument(0) : undefined;
var requestedLocale;
if (locales === undefined) {
requestedLocale = undefined;
} else if (typeof locales === "string") {
requestedLocale = intl_ValidateAndCanonicalizeLanguageTag(locales, false);
} else {
var requestedLocales = CanonicalizeLocaleList(locales);
requestedLocale = requestedLocales.length ? requestedLocales[0] : undefined;
}
if (string.length === 0) {
return "";
}
if (requestedLocale === undefined) {
requestedLocale = DefaultLocale();
}
return intl_toLocaleUpperCase(string, requestedLocale);
}
function String_static_raw(callSite ) {
var cooked = ToObject(callSite);
var raw = ToObject(cooked.raw);
var literalSegments = ToLength(raw.length);
if (literalSegments === 0) {
return "";
}
if (literalSegments === 1) {
return ToString(raw[0]);
}
var resultString = ToString(raw[0]);
for (var nextIndex = 1; nextIndex < literalSegments; nextIndex++) {
if (nextIndex < ArgumentsLength()) {
resultString += ToString(GetArgument(nextIndex));
}
resultString += ToString(raw[nextIndex]);
}
return resultString;
}
function String_big() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("big", this);
}
return "<big>" + ToString(this) + "</big>";
}
function String_blink() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("blink", this);
}
return "<blink>" + ToString(this) + "</blink>";
}
function String_bold() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("bold", this);
}
return "<b>" + ToString(this) + "</b>";
}
function String_fixed() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("fixed", this);
}
return "<tt>" + ToString(this) + "</tt>";
}
function String_italics() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("italics", this);
}
return "<i>" + ToString(this) + "</i>";
}
function String_small() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("small", this);
}
return "<small>" + ToString(this) + "</small>";
}
function String_strike() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("strike", this);
}
return "<strike>" + ToString(this) + "</strike>";
}
function String_sub() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("sub", this);
}
return "<sub>" + ToString(this) + "</sub>";
}
function String_sup() {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("sup", this);
}
return "<sup>" + ToString(this) + "</sup>";
}
function EscapeAttributeValue(v) {
var inputStr = ToString(v);
return StringReplaceAllString(inputStr, '"', "&quot;");
}
function String_anchor(name) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("anchor", this);
}
var S = ToString(this);
return '<a name="' + EscapeAttributeValue(name) + '">' + S + "</a>";
}
function String_fontcolor(color) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("fontcolor", this);
}
var S = ToString(this);
return '<font color="' + EscapeAttributeValue(color) + '">' + S + "</font>";
}
function String_fontsize(size) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("fontsize", this);
}
var S = ToString(this);
return '<font size="' + EscapeAttributeValue(size) + '">' + S + "</font>";
}
function String_link(url) {
if (IsNullOrUndefined(this)) {
ThrowIncompatibleMethod("link", this);
}
var S = ToString(this);
return '<a href="' + EscapeAttributeValue(url) + '">' + S + "</a>";
}
function SetConstructorInit(iterable) {
var set = this;
var adder = set.add;
if (!IsCallable(adder)) {
ThrowTypeError(11, typeof adder);
}
for (var nextValue of allowContentIter(iterable)) {
callContentFunction(adder, set, nextValue);
}
}
function SetForEach(callbackfn, thisArg = undefined) {
var S = this;
if (!IsObject(S) || (S = GuardToSetObject(S)) === null) {
return callFunction(
CallSetMethodIfWrapped,
this,
callbackfn,
thisArg,
"SetForEach"
);
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var values = callFunction(std_Set_values, S);
var setIterationResult = globalSetIterationResult;
while (true) {
var done = GetNextSetEntryForIterator(values, setIterationResult);
if (done) {
break;
}
var value = setIterationResult[0];
setIterationResult[0] = null;
callContentFunction(callbackfn, thisArg, value, value, S);
}
}
function $SetSpecies() {
return this;
}
SetCanonicalName($SetSpecies, "get [Symbol.species]");
var globalSetIterationResult = CreateSetIterationResult();
function SetIteratorNext() {
var O = this;
if (!IsObject(O) || (O = GuardToSetIterator(O)) === null) {
return callFunction(
CallSetIteratorMethodIfWrapped,
this,
"SetIteratorNext"
);
}
var setIterationResult = globalSetIterationResult;
var retVal = { value: undefined, done: true };
var done = GetNextSetEntryForIterator(O, setIterationResult);
if (!done) {
var itemKind = UnsafeGetInt32FromReservedSlot(O, 2);
var result;
if (itemKind === 1) {
result = setIterationResult[0];
} else {
do { if (!(itemKind === 2)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Set.js" + ":" + 110 + ": " + itemKind) } } while (false);
result = [setIterationResult[0], setIterationResult[0]];
}
setIterationResult[0] = null;
retVal.value = result;
retVal.done = false;
}
return retVal;
}
function GetSetRecord(obj) {
if (!IsObject(obj)) {
ThrowTypeError(55, obj === null ? "null" : typeof obj);
}
var rawSize = obj.size;
var numSize = +rawSize;
if (numSize !== numSize) {
if (rawSize === undefined) {
ThrowTypeError(53, "size", "undefined");
} else {
ThrowTypeError(53, "size", "NaN");
}
}
var intSize = ToInteger(numSize);
if (intSize < 0) {
ThrowRangeError(676);
}
var has = obj.has;
if (!IsCallable(has)) {
ThrowTypeError(12, "has");
}
var keys = obj.keys;
if (!IsCallable(keys)) {
ThrowTypeError(12, "keys");
}
return { set: obj, size: intSize, has, keys };
}
function GetIteratorFromMethod(setRec) {
var keysIter = callContentFunction(setRec.keys, setRec.set);
if (!IsObject(keysIter)) {
ThrowTypeError(
55,
keysIter === null ? "null" : typeof keysIter
);
}
return keysIter;
}
function SetUnion(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(CallSetMethodIfWrapped, this, other, "SetUnion");
}
var otherRec = GetSetRecord(other);
var keysIter = GetIteratorFromMethod(otherRec);
var keysIterNext = keysIter.next;
var result = SetCopy(O);
for (var nextValue of allowContentIterWithNext(keysIter, keysIterNext)) {
callFunction(std_Set_add, result, nextValue);
}
return result;
}
function SetIntersection(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(CallSetMethodIfWrapped, this, other, "SetIntersection");
}
var otherRec = GetSetRecord(other);
var Set = GetBuiltinConstructor("Set");
var result = new Set();
var thisSize = callFunction(std_Set_size, O);
if (thisSize <= otherRec.size) {
var values = callFunction(std_Set_values, O);
var setIterationResult = globalSetIterationResult;
while (true) {
var done = GetNextSetEntryForIterator(values, setIterationResult);
if (done) {
break;
}
var value = setIterationResult[0];
setIterationResult[0] = null;
if (callContentFunction(otherRec.has, otherRec.set, value)) {
callFunction(std_Set_add, result, value);
}
}
} else {
var keysIter = GetIteratorFromMethod(otherRec);
for (var nextValue of allowContentIterWithNext(keysIter, keysIter.next)) {
if (callFunction(std_Set_has, O, nextValue)) {
callFunction(std_Set_add, result, nextValue);
}
}
}
return result;
}
function SetDifference(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(CallSetMethodIfWrapped, this, other, "SetDifference");
}
var otherRec = GetSetRecord(other);
var result = SetCopy(O);
var thisSize = callFunction(std_Set_size, O);
if (thisSize <= otherRec.size) {
var values = callFunction(std_Set_values, result);
var setIterationResult = globalSetIterationResult;
while (true) {
var done = GetNextSetEntryForIterator(values, setIterationResult);
if (done) {
break;
}
var value = setIterationResult[0];
setIterationResult[0] = null;
if (callContentFunction(otherRec.has, otherRec.set, value)) {
callFunction(std_Set_delete, result, value);
}
}
} else {
var keysIter = GetIteratorFromMethod(otherRec);
for (var nextValue of allowContentIterWithNext(keysIter, keysIter.next)) {
callFunction(std_Set_delete, result, nextValue);
}
}
return result;
}
function SetSymmetricDifference(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(
CallSetMethodIfWrapped,
this,
other,
"SetSymmetricDifference"
);
}
var otherRec = GetSetRecord(other);
var keysIter = GetIteratorFromMethod(otherRec);
var keysIterNext = keysIter.next;
var result = SetCopy(O);
for (var nextValue of allowContentIterWithNext(keysIter, keysIterNext)) {
if (callFunction(std_Set_has, O, nextValue)) {
callFunction(std_Set_delete, result, nextValue);
} else {
callFunction(std_Set_add, result, nextValue);
}
}
return result;
}
function SetIsSubsetOf(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(CallSetMethodIfWrapped, this, other, "SetIsSubsetOf");
}
var otherRec = GetSetRecord(other);
var thisSize = callFunction(std_Set_size, O);
if (thisSize > otherRec.size) {
return false;
}
var values = callFunction(std_Set_values, O);
var setIterationResult = globalSetIterationResult;
while (true) {
var done = GetNextSetEntryForIterator(values, setIterationResult);
if (done) {
break;
}
var value = setIterationResult[0];
setIterationResult[0] = null;
if (!callContentFunction(otherRec.has, otherRec.set, value)) {
return false;
}
}
return true;
}
function SetIsSupersetOf(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(CallSetMethodIfWrapped, this, other, "SetIsSupersetOf");
}
var otherRec = GetSetRecord(other);
var thisSize = callFunction(std_Set_size, O);
if (thisSize < otherRec.size) {
return false;
}
var keysIter = GetIteratorFromMethod(otherRec);
for (var nextValue of allowContentIterWithNext(keysIter, keysIter.next)) {
if (!callFunction(std_Set_has, O, nextValue)) {
return false;
}
}
return true;
}
function SetIsDisjointFrom(other) {
var O = this;
if (!IsObject(O) || (O = GuardToSetObject(O)) === null) {
return callFunction(
CallSetMethodIfWrapped,
this,
other,
"SetIsDisjointFrom"
);
}
var otherRec = GetSetRecord(other);
var thisSize = callFunction(std_Set_size, O);
if (thisSize <= otherRec.size) {
var values = callFunction(std_Set_values, O);
var setIterationResult = globalSetIterationResult;
while (true) {
var done = GetNextSetEntryForIterator(values, setIterationResult);
if (done) {
break;
}
var value = setIterationResult[0];
setIterationResult[0] = null;
if (callContentFunction(otherRec.has, otherRec.set, value)) {
return false;
}
}
} else {
var keysIter = GetIteratorFromMethod(otherRec);
for (var nextValue of allowContentIterWithNext(keysIter, keysIter.next)) {
if (callFunction(std_Set_has, O, nextValue)) {
return false;
}
}
}
return true;
}
function InsertionSort(array, from, to, comparefn) {
var item, swap, i, j;
for (i = from + 1; i <= to; i++) {
item = array[i];
for (j = i - 1; j >= from; j--) {
swap = array[j];
if (callContentFunction(comparefn, undefined, swap, item) <= 0) {
break;
}
array[j + 1] = swap;
}
array[j + 1] = item;
}
}
function MergeTypedArray(list, out, start, mid, end, comparefn) {
if (
mid >= end ||
callContentFunction(comparefn, undefined, list[mid], list[mid + 1]) <= 0
) {
for (var i = start; i <= end; i++) {
out[i] = list[i];
}
return;
}
var i = start;
var j = mid + 1;
var k = start;
while (i <= mid && j <= end) {
var lvalue = list[i];
var rvalue = list[j];
if (callContentFunction(comparefn, undefined, lvalue, rvalue) <= 0) {
out[k++] = lvalue;
i++;
} else {
out[k++] = rvalue;
j++;
}
}
while (i <= mid) {
out[k++] = list[i++];
}
while (j <= end) {
out[k++] = list[j++];
}
}
function MergeSortTypedArray(array, len, comparefn) {
do { if (!(IsPossiblyWrappedTypedArray(array))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/Sorting.js" + ":" + 71 + ": " + "MergeSortTypedArray works only with typed arrays.") } } while (false);
var C = ConstructorForTypedArray(array);
var lBuffer = new C(len);
for (var i = 0; i < len; i++) {
lBuffer[i] = array[i];
}
if (len < 8) {
InsertionSort(lBuffer, 0, len - 1, comparefn);
return lBuffer;
}
var rBuffer = new C(len);
var windowSize = 4;
for (var start = 0; start < len - 1; start += windowSize) {
var end = std_Math_min(start + windowSize - 1, len - 1);
InsertionSort(lBuffer, start, end, comparefn);
}
for (; windowSize < len; windowSize = 2 * windowSize) {
for (var start = 0; start < len; start += 2 * windowSize) {
var mid = start + windowSize - 1;
var end = std_Math_min(start + 2 * windowSize - 1, len - 1);
MergeTypedArray(lBuffer, rBuffer, start, mid, end, comparefn);
}
var swap = lBuffer;
lBuffer = rBuffer;
rBuffer = swap;
}
return lBuffer;
}
function ViewedArrayBufferIfReified(tarray) {
do { if (!(IsTypedArray(tarray))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 8 + ": " + "non-typed array asked for its buffer") } } while (false);
var buf = UnsafeGetReservedSlot(tarray, 0);
do { if (!(buf === false || buf === true || (IsObject(buf) && (GuardToArrayBuffer(buf) !== null || GuardToSharedArrayBuffer(buf) !== null)))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 18 + ": " + "unexpected value in buffer slot") } } while (false);
return IsObject(buf) ? buf : null;
}
function IsDetachedBuffer(buffer) {
if (buffer === null) {
return false;
}
do { if (!(GuardToArrayBuffer(buffer) !== null || GuardToSharedArrayBuffer(buffer) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 33 + ": " + "non-ArrayBuffer passed to IsDetachedBuffer") } } while (false);
if ((buffer = GuardToArrayBuffer(buffer)) === null) {
return false;
}
var flags = UnsafeGetInt32FromReservedSlot(buffer, 3);
return (flags & 0x8) !== 0;
}
function GetAttachedArrayBuffer(tarray) {
var buffer = ViewedArrayBufferIfReified(tarray);
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(564);
}
return buffer;
}
function GetAttachedArrayBufferMethod() {
return GetAttachedArrayBuffer(this);
}
function EnsureTypedArrayWithArrayBuffer(arg) {
if (IsObject(arg) && IsTypedArray(arg)) {
GetAttachedArrayBuffer(arg);
return;
}
callFunction(
CallTypedArrayMethodIfWrapped,
arg,
"GetAttachedArrayBufferMethod"
);
}
function TypedArraySpeciesConstructor(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 81 + ": " + "not passed an object") } } while (false);
var ctor = obj.constructor;
if (ctor === undefined) {
return ConstructorForTypedArray(obj);
}
if (!IsObject(ctor)) {
ThrowTypeError(55, "object's 'constructor' property");
}
var s = ctor[GetBuiltinSymbol("species")];
if (IsNullOrUndefined(s)) {
return ConstructorForTypedArray(obj);
}
if (IsConstructor(s)) {
return s;
}
ThrowTypeError(
13,
"@@species property of object's constructor"
);
}
function ValidateTypedArray(obj) {
if (IsObject(obj)) {
if (IsTypedArray(obj)) {
GetAttachedArrayBuffer(obj);
return;
}
if (IsPossiblyWrappedTypedArray(obj)) {
if (PossiblyWrappedTypedArrayHasDetachedBuffer(obj)) {
ThrowTypeError(564);
}
return;
}
}
ThrowTypeError(582);
}
function TypedArrayCreateWithLength(constructor, length) {
var newTypedArray = constructContentFunction(
constructor,
constructor,
length
);
ValidateTypedArray(newTypedArray);
var len = PossiblyWrappedTypedArrayLength(newTypedArray);
if (len < length) {
ThrowTypeError(583, length, len);
}
return newTypedArray;
}
function TypedArrayCreateWithBuffer(constructor, buffer, byteOffset, length) {
var newTypedArray = constructContentFunction(
constructor,
constructor,
buffer,
byteOffset,
length
);
ValidateTypedArray(newTypedArray);
PossiblyWrappedTypedArrayLength(newTypedArray);
return newTypedArray;
}
function TypedArrayCreateWithResizableBuffer(constructor, buffer, byteOffset) {
var newTypedArray = constructContentFunction(
constructor,
constructor,
buffer,
byteOffset
);
ValidateTypedArray(newTypedArray);
PossiblyWrappedTypedArrayLength(newTypedArray);
return newTypedArray;
}
function TypedArraySpeciesCreateWithLength(exemplar, length) {
var C = TypedArraySpeciesConstructor(exemplar);
return TypedArrayCreateWithLength(C, length);
}
function TypedArraySpeciesCreateWithBuffer(
exemplar,
buffer,
byteOffset,
length
) {
var C = TypedArraySpeciesConstructor(exemplar);
return TypedArrayCreateWithBuffer(C, buffer, byteOffset, length);
}
function TypedArraySpeciesCreateWithResizableBuffer(
exemplar,
buffer,
byteOffset
) {
var C = TypedArraySpeciesConstructor(exemplar);
return TypedArrayCreateWithResizableBuffer(C, buffer, byteOffset);
}
function TypedArrayEntries() {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
PossiblyWrappedTypedArrayLength(O);
return CreateArrayIterator(O, 2);
}
function TypedArrayEvery(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.every");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
var kValue = O[k];
var testResult = callContentFunction(callbackfn, thisArg, kValue, k, O);
if (!testResult) {
return false;
}
}
return true;
}
SetIsInlinableLargeFunction(TypedArrayEvery);
function TypedArrayFill(value, start = 0, end = undefined) {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
value,
start,
end,
"TypedArrayFill"
);
}
var O = this;
var buffer = GetAttachedArrayBuffer(this);
var len = TypedArrayLength(O);
var kind = GetTypedArrayKind(O);
if (kind === 9 || kind === 10) {
value = ToBigInt(value);
} else {
value = ToNumber(value);
}
var relativeStart = ToInteger(start);
var k =
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
var relativeEnd = end === undefined ? len : ToInteger(end);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
if (buffer === null) {
buffer = ViewedArrayBufferIfReified(O);
}
if (IsDetachedBuffer(buffer)) {
ThrowTypeError(564);
}
len = TypedArrayLength(O);
final = std_Math_min(final, len);
for (; k < final; k++) {
O[k] = value;
}
return O;
}
function TypedArrayFilter(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.filter");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var kept = new_List();
var captured = 0;
for (var k = 0; k < len; k++) {
var kValue = O[k];
if (callContentFunction(callbackfn, T, kValue, k, O)) {
kept[captured++] = kValue;
}
}
var A = TypedArraySpeciesCreateWithLength(O, captured);
for (var n = 0; n < captured; n++) {
A[n] = kept[n];
}
return A;
}
SetIsInlinableLargeFunction(TypedArrayFilter);
function TypedArrayFind(predicate ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.find");
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
var kValue = O[k];
if (callContentFunction(predicate, thisArg, kValue, k, O)) {
return kValue;
}
}
return undefined;
}
SetIsInlinableLargeFunction(TypedArrayFind);
function TypedArrayFindIndex(predicate ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(
54,
0,
"%TypedArray%.prototype.findIndex"
);
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
if (callContentFunction(predicate, thisArg, O[k], k, O)) {
return k;
}
}
return -1;
}
SetIsInlinableLargeFunction(TypedArrayFindIndex);
function TypedArrayForEach(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "TypedArray.prototype.forEach");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
callContentFunction(callbackfn, thisArg, O[k], k, O);
}
return undefined;
}
SetIsInlinableLargeFunction(TypedArrayForEach);
function TypedArrayIndexOf(searchElement, fromIndex = 0) {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
searchElement,
fromIndex,
"TypedArrayIndexOf"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
if (len === 0) {
return -1;
}
var n = ToInteger(fromIndex);
do { if (!(fromIndex !== undefined || n === 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 622 + ": " + "ToInteger(undefined) is zero") } } while (false);
len = std_Math_min(len, TypedArrayLengthZeroOnOutOfBounds(O));
do { if (!(len === 0 || !IsDetachedBuffer(ViewedArrayBufferIfReified(O)))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 631 + ": " + "TypedArrays with detached buffers have a length of zero") } } while (false);
if (n >= len) {
return -1;
}
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
}
}
for (; k < len; k++) {
do { if (!(k in O)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 657 + ": " + "unexpected missing element") } } while (false);
if (O[k] === searchElement) {
return k;
}
}
return -1;
}
function TypedArrayJoin(separator) {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
separator,
"TypedArrayJoin"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
var sep = separator === undefined ? "," : ToString(separator);
if (len === 0) {
return "";
}
var limit = std_Math_min(len, TypedArrayLengthZeroOnOutOfBounds(O));
if (limit === 0) {
return callFunction(String_repeat, sep, len - 1);
}
do { if (!(!IsDetachedBuffer(ViewedArrayBufferIfReified(O)))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 710 + ": " + "TypedArrays with detached buffers have a length of zero") } } while (false);
var element0 = O[0];
do { if (!(element0 !== undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 715 + ": " + "unexpected undefined element") } } while (false);
var R = ToString(element0);
for (var k = 1; k < limit; k++) {
var element = O[k];
do { if (!(element !== undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 726 + ": " + "unexpected undefined element") } } while (false);
R += sep + ToString(element);
}
if (limit < len) {
R += callFunction(String_repeat, sep, len - limit);
}
return R;
}
function TypedArrayKeys() {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
PossiblyWrappedTypedArrayLength(O);
return CreateArrayIterator(O, 0);
}
function TypedArrayLastIndexOf(searchElement ) {
if (!IsObject(this) || !IsTypedArray(this)) {
if (ArgumentsLength() > 1) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
searchElement,
GetArgument(1),
"TypedArrayLastIndexOf"
);
}
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
searchElement,
"TypedArrayLastIndexOf"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
if (len === 0) {
return -1;
}
var n = ArgumentsLength() > 1 ? ToInteger(GetArgument(1)) : len - 1;
len = std_Math_min(len, TypedArrayLengthZeroOnOutOfBounds(O));
do { if (!(len === 0 || !IsDetachedBuffer(ViewedArrayBufferIfReified(O)))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 801 + ": " + "TypedArrays with detached buffers have a length of zero") } } while (false);
var k = n >= 0 ? std_Math_min(n, len - 1) : len + n;
for (; k >= 0; k--) {
do { if (!(k in O)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 809 + ": " + "unexpected missing element") } } while (false);
if (O[k] === searchElement) {
return k;
}
}
return -1;
}
function TypedArrayMap(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.map");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var T = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var A = TypedArraySpeciesCreateWithLength(O, len);
for (var k = 0; k < len; k++) {
var mappedValue = callContentFunction(callbackfn, T, O[k], k, O);
A[k] = mappedValue;
}
return A;
}
SetIsInlinableLargeFunction(TypedArrayMap);
function TypedArrayReduce(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.reduce");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
if (len === 0 && ArgumentsLength() === 1) {
ThrowTypeError(51);
}
var k = 0;
var accumulator = ArgumentsLength() > 1 ? GetArgument(1) : O[k++];
for (; k < len; k++) {
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
return accumulator;
}
function TypedArrayReduceRight(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(
54,
0,
"%TypedArray%.prototype.reduceRight"
);
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
if (len === 0 && ArgumentsLength() === 1) {
ThrowTypeError(51);
}
var k = len - 1;
var accumulator = ArgumentsLength() > 1 ? GetArgument(1) : O[k--];
for (; k >= 0; k--) {
accumulator = callContentFunction(
callbackfn,
undefined,
accumulator,
O[k],
k,
O
);
}
return accumulator;
}
function TypedArrayReverse() {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
"TypedArrayReverse"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
var middle = std_Math_floor(len / 2);
for (var lower = 0; lower !== middle; lower++) {
var upper = len - lower - 1;
var lowerValue = O[lower];
var upperValue = O[upper];
O[lower] = upperValue;
O[upper] = lowerValue;
}
return O;
}
function TypedArraySlice(start, end) {
var O = this;
if (!IsObject(O) || !IsTypedArray(O)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
O,
start,
end,
"TypedArraySlice"
);
}
GetAttachedArrayBuffer(O);
var len = TypedArrayLength(O);
var relativeStart = ToInteger(start);
var k =
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
var relativeEnd = end === undefined ? len : ToInteger(end);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
var count = std_Math_max(final - k, 0);
var A = TypedArraySpeciesCreateWithLength(O, count);
if (count > 0) {
var sliced = TypedArrayBitwiseSlice(O, A, k, count);
if (!sliced) {
final = std_Math_min(final, TypedArrayLength(O));
var n = 0;
while (k < final) {
A[n++] = O[k++];
}
}
}
return A;
}
function TypedArraySome(callbackfn ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.some");
}
if (!IsCallable(callbackfn)) {
ThrowTypeError(11, DecompileArg(0, callbackfn));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = 0; k < len; k++) {
var kValue = O[k];
var testResult = callContentFunction(callbackfn, thisArg, kValue, k, O);
if (testResult) {
return true;
}
}
return false;
}
SetIsInlinableLargeFunction(TypedArraySome);
function TypedArraySortCompare(comparefn) {
return function(x, y) {
var v = +callContentFunction(comparefn, undefined, x, y);
if (v !== v) {
return 0;
}
return v;
};
}
function TypedArraySort(comparefn) {
if (comparefn !== undefined) {
if (!IsCallable(comparefn)) {
ThrowTypeError(11, DecompileArg(0, comparefn));
}
}
var obj = this;
EnsureTypedArrayWithArrayBuffer(obj);
var len = PossiblyWrappedTypedArrayLength(obj);
if (len <= 1) {
return obj;
}
if (comparefn === undefined) {
return TypedArrayNativeSort(obj);
}
var wrappedCompareFn = TypedArraySortCompare(comparefn);
var sorted = MergeSortTypedArray(obj, len, wrappedCompareFn);
for (var i = 0; i < len; i++) {
obj[i] = sorted[i];
}
return obj;
}
function TypedArrayToLocaleString(locales = undefined, options = undefined) {
var array = this;
EnsureTypedArrayWithArrayBuffer(array);
var len = PossiblyWrappedTypedArrayLength(array);
if (len === 0) {
return "";
}
var firstElement = array[0];
do { if (!(typeof firstElement === "number" || typeof firstElement === "bigint")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 1220 + ": " + "TypedArray elements are either Numbers or BigInts") } } while (false);
var R = ToString(
callContentFunction(
firstElement.toLocaleString,
firstElement,
locales,
options
)
);
var separator = ",";
for (var k = 1; k < len; k++) {
R += separator;
var nextElement = array[k];
if (nextElement === undefined) {
continue;
}
do { if (!(typeof nextElement === "number" || typeof nextElement === "bigint")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 1259 + ": " + "TypedArray elements are either Numbers or BigInts") } } while (false);
R += ToString(
callContentFunction(
nextElement.toLocaleString,
nextElement,
locales,
options
)
);
}
return R;
}
function TypedArraySubarray(begin, end) {
var obj = this;
if (!IsObject(obj) || !IsTypedArray(obj)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
begin,
end,
"TypedArraySubarray"
);
}
var buffer = ViewedArrayBufferIfReified(obj);
if (buffer === null) {
buffer = TypedArrayBuffer(obj);
}
var srcLength = TypedArrayLengthZeroOnOutOfBounds(obj);
var srcByteOffset = TypedArrayByteOffset(obj);
var relativeBegin = ToInteger(begin);
var beginIndex =
relativeBegin < 0
? std_Math_max(srcLength + relativeBegin, 0)
: std_Math_min(relativeBegin, srcLength);
var elementSize = TypedArrayElementSize(obj);
var beginByteOffset = srcByteOffset + beginIndex * elementSize;
if (end === undefined && TypedArrayIsAutoLength(obj)) {
return TypedArraySpeciesCreateWithResizableBuffer(
obj,
buffer,
beginByteOffset
);
}
var relativeEnd = end === undefined ? srcLength : ToInteger(end);
var endIndex =
relativeEnd < 0
? std_Math_max(srcLength + relativeEnd, 0)
: std_Math_min(relativeEnd, srcLength);
var newLength = std_Math_max(endIndex - beginIndex, 0);
return TypedArraySpeciesCreateWithBuffer(
obj,
buffer,
beginByteOffset,
newLength
);
}
function TypedArrayAt(index) {
var obj = this;
if (!IsObject(obj) || !IsTypedArray(obj)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
obj,
index,
"TypedArrayAt"
);
}
GetAttachedArrayBuffer(obj);
var len = TypedArrayLength(obj);
var relativeIndex = ToInteger(index);
var k;
if (relativeIndex >= 0) {
k = relativeIndex;
} else {
k = len + relativeIndex;
}
if (k < 0 || k >= len) {
return undefined;
}
return obj[k];
}
SetIsInlinableLargeFunction(TypedArrayAt);
function TypedArrayFindLast(predicate ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(54, 0, "%TypedArray%.prototype.findLast");
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = len - 1; k >= 0; k--) {
var kValue = O[k];
if (callContentFunction(predicate, thisArg, kValue, k, O)) {
return kValue;
}
}
return undefined;
}
SetIsInlinableLargeFunction(TypedArrayFindLast);
function TypedArrayFindLastIndex(predicate ) {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (ArgumentsLength() === 0) {
ThrowTypeError(
54,
0,
"%TypedArray%.prototype.findLastIndex"
);
}
if (!IsCallable(predicate)) {
ThrowTypeError(11, DecompileArg(0, predicate));
}
var thisArg = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
for (var k = len - 1; k >= 0; k--) {
if (callContentFunction(predicate, thisArg, O[k], k, O)) {
return k;
}
}
return -1;
}
SetIsInlinableLargeFunction(TypedArrayFindLastIndex);
function $TypedArrayValues() {
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
PossiblyWrappedTypedArrayLength(O);
return CreateArrayIterator(O, 1);
}
SetCanonicalName($TypedArrayValues, "values");
function TypedArrayIncludes(searchElement, fromIndex = 0) {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
searchElement,
fromIndex,
"TypedArrayIncludes"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
if (len === 0) {
return false;
}
var n = ToInteger(fromIndex);
do { if (!(fromIndex !== undefined || n === 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 1530 + ": " + "ToInteger(undefined) is zero") } } while (false);
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
}
}
while (k < len) {
if (SameValueZero(searchElement, O[k])) {
return true;
}
k++;
}
return false;
}
function TypedArrayStaticFrom(source, mapfn = undefined, thisArg = undefined) {
var C = this;
if (!IsConstructor(C)) {
ThrowTypeError(13, typeof C);
}
var mapping;
if (mapfn !== undefined) {
if (!IsCallable(mapfn)) {
ThrowTypeError(11, DecompileArg(1, mapfn));
}
mapping = true;
} else {
mapping = false;
}
var T = thisArg;
var usingIterator = source[GetBuiltinSymbol("iterator")];
if (usingIterator !== undefined && usingIterator !== null) {
if (!IsCallable(usingIterator)) {
ThrowTypeError(70, DecompileArg(0, source));
}
if (!mapping && IsTypedArrayConstructor(C) && IsObject(source)) {
if (
usingIterator === $TypedArrayValues &&
IsTypedArray(source) &&
ArrayIteratorPrototypeOptimizable()
) {
GetAttachedArrayBuffer(source);
var len = TypedArrayLength(source);
var targetObj = constructContentFunction(C, C, len);
for (var k = 0; k < len; k++) {
targetObj[k] = source[k];
}
return targetObj;
}
if (
usingIterator === $ArrayValues &&
IsPackedArray(source) &&
ArrayIteratorPrototypeOptimizable()
) {
var targetObj = constructContentFunction(C, C, source.length);
TypedArrayInitFromPackedArray(targetObj, source);
return targetObj;
}
}
var values = IterableToList(source, usingIterator);
var len = values.length;
var targetObj = TypedArrayCreateWithLength(C, len);
for (var k = 0; k < len; k++) {
var kValue = values[k];
var mappedValue = mapping
? callContentFunction(mapfn, T, kValue, k)
: kValue;
targetObj[k] = mappedValue;
}
return targetObj;
}
var arrayLike = ToObject(source);
var len = ToLength(arrayLike.length);
var targetObj = TypedArrayCreateWithLength(C, len);
for (var k = 0; k < len; k++) {
var kValue = arrayLike[k];
var mappedValue = mapping
? callContentFunction(mapfn, T, kValue, k)
: kValue;
targetObj[k] = mappedValue;
}
return targetObj;
}
function TypedArrayStaticOf( ) {
var len = ArgumentsLength();
var C = this;
if (!IsConstructor(C)) {
ThrowTypeError(13, typeof C);
}
var newObj = TypedArrayCreateWithLength(C, len);
for (var k = 0; k < len; k++) {
newObj[k] = GetArgument(k);
}
return newObj;
}
function $TypedArraySpecies() {
return this;
}
SetCanonicalName($TypedArraySpecies, "get [Symbol.species]");
function IterableToList(items, method) {
do { if (!(IsCallable(method))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 1752 + ": " + "method argument is a function") } } while (false);
var iterator = callContentFunction(method, items);
if (!IsObject(iterator)) {
ThrowTypeError(72);
}
var nextMethod = iterator.next;
var values = [];
var i = 0;
while (true) {
var next = callContentFunction(nextMethod, iterator);
if (!IsObject(next)) {
ThrowTypeError(73, "next");
}
if (next.done) {
break;
}
DefineDataProperty(values, i++, next.value);
}
return values;
}
function ArrayBufferSlice(start, end) {
var O = this;
if (!IsObject(O) || (O = GuardToArrayBuffer(O)) === null) {
return callFunction(
CallArrayBufferMethodIfWrapped,
this,
start,
end,
"ArrayBufferSlice"
);
}
if (IsDetachedBuffer(O)) {
ThrowTypeError(564);
}
var len = ArrayBufferByteLength(O);
var relativeStart = ToInteger(start);
var first =
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
var relativeEnd = end === undefined ? len : ToInteger(end);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
var newLen = std_Math_max(final - first, 0);
var ctor = SpeciesConstructor(O, GetBuiltinConstructor("ArrayBuffer"));
var new_ = constructContentFunction(ctor, ctor, newLen);
var isWrapped = false;
var newBuffer;
if ((newBuffer = GuardToArrayBuffer(new_)) !== null) {
if (IsDetachedBuffer(newBuffer)) {
ThrowTypeError(564);
}
} else {
newBuffer = new_;
if (!IsWrappedArrayBuffer(newBuffer)) {
ThrowTypeError(560);
}
isWrapped = true;
if (
callFunction(
CallArrayBufferMethodIfWrapped,
newBuffer,
"IsDetachedBufferThis"
)
) {
ThrowTypeError(564);
}
}
if (newBuffer === O) {
ThrowTypeError(561);
}
var actualLen = PossiblyWrappedArrayBufferByteLength(newBuffer);
if (actualLen < newLen) {
ThrowTypeError(562, newLen, actualLen);
}
if (IsDetachedBuffer(O)) {
ThrowTypeError(564);
}
var currentLen = ArrayBufferByteLength(O);
if (first < currentLen) {
var count = std_Math_min(newLen, currentLen - first);
ArrayBufferCopyData(newBuffer, 0, O, first, count, isWrapped);
}
return newBuffer;
}
function IsDetachedBufferThis() {
return IsDetachedBuffer(this);
}
function $ArrayBufferSpecies() {
return this;
}
SetCanonicalName($ArrayBufferSpecies, "get [Symbol.species]");
function $SharedArrayBufferSpecies() {
return this;
}
SetCanonicalName($SharedArrayBufferSpecies, "get [Symbol.species]");
function SharedArrayBufferSlice(start, end) {
var O = this;
if (!IsObject(O) || (O = GuardToSharedArrayBuffer(O)) === null) {
return callFunction(
CallSharedArrayBufferMethodIfWrapped,
this,
start,
end,
"SharedArrayBufferSlice"
);
}
var len = SharedArrayBufferByteLength(O);
var relativeStart = ToInteger(start);
var first =
relativeStart < 0
? std_Math_max(len + relativeStart, 0)
: std_Math_min(relativeStart, len);
var relativeEnd = end === undefined ? len : ToInteger(end);
var final =
relativeEnd < 0
? std_Math_max(len + relativeEnd, 0)
: std_Math_min(relativeEnd, len);
var newLen = std_Math_max(final - first, 0);
var ctor = SpeciesConstructor(O, GetBuiltinConstructor("SharedArrayBuffer"));
var new_ = constructContentFunction(ctor, ctor, newLen);
var isWrapped = false;
var newObj;
if ((newObj = GuardToSharedArrayBuffer(new_)) === null) {
if (!IsWrappedSharedArrayBuffer(new_)) {
ThrowTypeError(590);
}
isWrapped = true;
newObj = new_;
}
if (newObj === O || SharedArrayBuffersMemorySame(newObj, O)) {
ThrowTypeError(591);
}
var actualLen = PossiblyWrappedSharedArrayBufferByteLength(newObj);
if (actualLen < newLen) {
ThrowTypeError(592, newLen, actualLen);
}
SharedArrayBufferCopyData(newObj, 0, O, first, newLen, isWrapped);
return newObj;
}
function TypedArrayCreateSameType(exemplar, length) {
do { if (!(IsPossiblyWrappedTypedArray(exemplar))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 2002 + ": " + "in TypedArrayCreateSameType, exemplar does not have a [[ContentType]] internal slot") } } while (false);
var constructor = ConstructorForTypedArray(exemplar);
return TypedArrayCreateWithLength(constructor, length);
}
function TypedArrayToReversed() {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
"TypedArrayToReversed"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
var A = TypedArrayCreateSameType(O, len);
for (var k = 0; k < len; k++) {
var from = len - k - 1;
var fromValue = O[from];
A[k] = fromValue;
}
return A;
}
function TypedArrayWith(index, value) {
if (!IsObject(this) || !IsTypedArray(this)) {
return callFunction(
CallTypedArrayMethodIfWrapped,
this,
index,
value,
"TypedArrayWith"
);
}
GetAttachedArrayBuffer(this);
var O = this;
var len = TypedArrayLength(O);
var relativeIndex = ToInteger(index);
var actualIndex;
if (relativeIndex >= 0) {
actualIndex = relativeIndex;
} else {
actualIndex = len + relativeIndex;
}
var kind = GetTypedArrayKind(O);
if (kind === 9 || kind === 10) {
value = ToBigInt(value);
} else {
value = ToNumber(value);
}
var currentLen = TypedArrayLengthZeroOnOutOfBounds(O);
do { if (!(!IsDetachedBuffer(ViewedArrayBufferIfReified(O)) || currentLen === 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/TypedArray.js" + ":" + 2103 + ": " + "length is set to zero when the buffer has been detached") } } while (false);
if (actualIndex < 0 || actualIndex >= currentLen) {
ThrowRangeError(558);
}
var A = TypedArrayCreateSameType(O, len);
for (var k = 0; k < len; k++) {
var fromValue = k === actualIndex ? value : O[k];
A[k] = fromValue;
}
return A;
}
function TypedArrayToSorted(comparefn) {
if (comparefn !== undefined) {
if (!IsCallable(comparefn)) {
ThrowTypeError(11, DecompileArg(0, comparefn));
}
}
var O = this;
EnsureTypedArrayWithArrayBuffer(O);
var len = PossiblyWrappedTypedArrayLength(O);
if (len <= 1) {
var A = TypedArrayCreateSameType(O, len);
if (len > 0) {
A[0] = O[0];
}
return A;
}
if (comparefn === undefined) {
var A = TypedArrayCreateSameType(O, len);
for (var k = 0; k < len; k++) {
A[k] = O[k];
}
return TypedArrayNativeSort(A);
}
var wrappedCompareFn = TypedArraySortCompare(comparefn);
return MergeSortTypedArray(O, len, wrappedCompareFn);
}
function WeakMapConstructorInit(iterable) {
var map = this;
var adder = map.set;
if (!IsCallable(adder)) {
ThrowTypeError(11, typeof adder);
}
for (var nextItem of allowContentIter(iterable)) {
if (!IsObject(nextItem)) {
ThrowTypeError(44, "WeakMap");
}
callContentFunction(adder, map, nextItem[0], nextItem[1]);
}
}
function WeakSetConstructorInit(iterable) {
var set = this;
var adder = set.add;
if (!IsCallable(adder)) {
ThrowTypeError(11, typeof adder);
}
for (var nextValue of allowContentIter(iterable)) {
callContentFunction(adder, set, nextValue);
}
}
function resolveCollatorInternals(lazyCollatorData) {
do { if (!(IsObject(lazyCollatorData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 11 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var Collator = collatorInternalProperties;
internalProps.usage = lazyCollatorData.usage;
var collatorIsSorting = lazyCollatorData.usage === "sort";
var localeData = collatorIsSorting
? Collator.sortLocaleData
: Collator.searchLocaleData;
var relevantExtensionKeys = Collator.relevantExtensionKeys;
var r = ResolveLocale(
"Collator",
lazyCollatorData.requestedLocales,
lazyCollatorData.opt,
relevantExtensionKeys,
localeData
);
internalProps.locale = r.locale;
var collation = r.co;
if (collation === null) {
collation = "default";
}
internalProps.collation = collation;
internalProps.numeric = r.kn === "true";
internalProps.caseFirst = r.kf;
var s = lazyCollatorData.rawSensitivity;
if (s === undefined) {
s = "variant";
}
internalProps.sensitivity = s;
var ignorePunctuation = lazyCollatorData.ignorePunctuation;
if (ignorePunctuation === undefined) {
var actualLocale = collatorActualLocale(r.dataLocale);
ignorePunctuation = intl_isIgnorePunctuation(actualLocale);
}
internalProps.ignorePunctuation = ignorePunctuation;
return internalProps;
}
function getCollatorInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 90 + ": " + "getCollatorInternals called with non-object") } } while (false);
do { if (!(intl_GuardToCollator(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 94 + ": " + "getCollatorInternals called with non-Collator") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "Collator")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 100 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveCollatorInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function InitializeCollator(collator, locales, options) {
do { if (!(IsObject(collator))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 126 + ": " + "InitializeCollator called with non-object") } } while (false);
do { if (!(intl_GuardToCollator(collator) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 130 + ": " + "InitializeCollator called with non-Collator") } } while (false);
var lazyCollatorData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyCollatorData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else {
options = ToObject(options);
}
var u = GetOption(options, "usage", "string", ["sort", "search"], "sort");
lazyCollatorData.usage = u;
var opt = new_Record();
lazyCollatorData.opt = opt;
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var collation = GetOption(
options,
"collation",
"string",
undefined,
undefined
);
if (collation !== undefined) {
collation = intl_ValidateAndCanonicalizeUnicodeExtensionType(
collation,
"collation",
"co"
);
}
opt.co = collation;
var numericValue = GetOption(
options,
"numeric",
"boolean",
undefined,
undefined
);
if (numericValue !== undefined) {
numericValue = numericValue ? "true" : "false";
}
opt.kn = numericValue;
var caseFirstValue = GetOption(
options,
"caseFirst",
"string",
["upper", "lower", "false"],
undefined
);
opt.kf = caseFirstValue;
var s = GetOption(
options,
"sensitivity",
"string",
["base", "accent", "case", "variant"],
undefined
);
lazyCollatorData.rawSensitivity = s;
var ip = GetOption(options, "ignorePunctuation", "boolean", undefined, undefined);
lazyCollatorData.ignorePunctuation = ip;
initializeIntlObject(collator, "Collator", lazyCollatorData);
}
function Intl_Collator_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "Collator";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
var collatorInternalProperties = {
sortLocaleData: collatorSortLocaleData,
searchLocaleData: collatorSearchLocaleData,
relevantExtensionKeys: ["co", "kf", "kn"],
};
function collatorActualLocale(locale) {
do { if (!(typeof locale === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 284 + ": " + "locale should be string") } } while (false);
return BestAvailableLocaleIgnoringDefault("Collator", locale);
}
function collatorSortCaseFirst(locale) {
var actualLocale = collatorActualLocale(locale);
if (intl_isUpperCaseFirst(actualLocale)) {
return ["upper", "false", "lower"];
}
return ["false", "lower", "upper"];
}
function collatorSortCaseFirstDefault(locale) {
var actualLocale = collatorActualLocale(locale);
if (intl_isUpperCaseFirst(actualLocale)) {
return "upper";
}
return "false";
}
function collatorSortLocaleData() {
return {
co: intl_availableCollations,
kn: function() {
return ["false", "true"];
},
kf: collatorSortCaseFirst,
default: {
co: function() {
return null;
},
kn: function() {
return "false";
},
kf: collatorSortCaseFirstDefault,
},
};
}
function collatorSearchLocaleData() {
return {
co: function() {
return [null];
},
kn: function() {
return ["false", "true"];
},
kf: function() {
return ["false", "lower", "upper"];
},
default: {
co: function() {
return null;
},
kn: function() {
return "false";
},
kf: function() {
return "false";
},
},
};
}
function createCollatorCompare(collator) {
return function(x, y) {
do { if (!(IsObject(collator))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 382 + ": " + "collatorCompareToBind called with non-object") } } while (false);
do { if (!(intl_GuardToCollator(collator) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Collator.js" + ":" + 386 + ": " + "collatorCompareToBind called with non-Collator") } } while (false);
var X = ToString(x);
var Y = ToString(y);
return intl_CompareStrings(collator, X, Y);
};
}
function $Intl_Collator_compare_get() {
var collator = this;
if (
!IsObject(collator) ||
(collator = intl_GuardToCollator(collator)) === null
) {
return callFunction(
intl_CallCollatorMethodIfWrapped,
this,
"$Intl_Collator_compare_get"
);
}
var internals = getCollatorInternals(collator);
if (internals.boundCompare === undefined) {
internals.boundCompare = createCollatorCompare(collator);
}
return internals.boundCompare;
}
SetCanonicalName($Intl_Collator_compare_get, "get compare");
function Intl_Collator_resolvedOptions() {
var collator = this;
if (
!IsObject(collator) ||
(collator = intl_GuardToCollator(collator)) === null
) {
return callFunction(
intl_CallCollatorMethodIfWrapped,
this,
"Intl_Collator_resolvedOptions"
);
}
var internals = getCollatorInternals(collator);
var result = {
locale: internals.locale,
usage: internals.usage,
sensitivity: internals.sensitivity,
ignorePunctuation: internals.ignorePunctuation,
collation: internals.collation,
numeric: internals.numeric,
caseFirst: internals.caseFirst,
};
return result;
}
function startOfUnicodeExtensions(locale) {
do { if (!(typeof locale === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 34 + ": " + "locale is a string") } } while (false);
var start = callFunction(std_String_indexOf, locale, "-u-");
if (start < 0) {
return -1;
}
var privateExt = callFunction(std_String_indexOf, locale, "-x-");
if (privateExt >= 0 && privateExt < start) {
return -1;
}
return start;
}
function endOfUnicodeExtensions(locale, start) {
do { if (!(typeof locale === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 56 + ": " + "locale is a string") } } while (false);
do { if (!(0 <= start && start < locale.length)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 57 + ": " + "start is an index into locale") } } while (false);
do { if (!(Substring(locale, start, 3) === "-u-")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 61 + ": " + "start points to Unicode extension sequence") } } while (false);
for (var i = start + 5, end = locale.length - 4; i <= end; i++) {
if (locale[i] !== "-") {
continue;
}
if (locale[i + 2] === "-") {
return i;
}
i += 2;
}
return locale.length;
}
function removeUnicodeExtensions(locale) {
do { var canonical95 = intl_TryValidateAndCanonicalizeLanguageTag(locale); do { if (!(canonical95 !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 95 + ": " + `${"locale with possible Unicode extension"} is a structurally valid language tag`) } } while (false); do { if (!(canonical95 === locale)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 95 + ": " + `${"locale with possible Unicode extension"} is a canonicalized language tag`) } } while (false); } while (false);
var start = startOfUnicodeExtensions(locale);
if (start < 0) {
return locale;
}
var end = endOfUnicodeExtensions(locale, start);
var left = Substring(locale, 0, start);
var right = Substring(locale, end, locale.length - end);
var combined = left + right;
do { var canonical108 = intl_TryValidateAndCanonicalizeLanguageTag(combined); do { if (!(canonical108 !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 108 + ": " + `${"the recombined locale"} is a structurally valid language tag`) } } while (false); do { if (!(canonical108 === combined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 108 + ": " + `${"the recombined locale"} is a canonicalized language tag`) } } while (false); } while (false);
do { if (!(startOfUnicodeExtensions(combined) < 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 112 + ": " + "recombination failed to remove all Unicode locale extension sequences") } } while (false);
return combined;
}
function getUnicodeExtensions(locale) {
do { var canonical121 = intl_TryValidateAndCanonicalizeLanguageTag(locale); do { if (!(canonical121 !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 121 + ": " + `${"locale with Unicode extension"} is a structurally valid language tag`) } } while (false); do { if (!(canonical121 === locale)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 121 + ": " + `${"locale with Unicode extension"} is a canonicalized language tag`) } } while (false); } while (false);
var start = startOfUnicodeExtensions(locale);
do { if (!(start >= 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 124 + ": " + "start of Unicode extension sequence not found") } } while (false);
var end = endOfUnicodeExtensions(locale, start);
return Substring(locale, start, end - start);
}
function IsASCIIAlphaString(s) {
do { if (!(typeof s === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 134 + ": " + "IsASCIIAlphaString") } } while (false);
for (var i = 0; i < s.length; i++) {
var c = callFunction(std_String_charCodeAt, s, i);
if (!((0x41 <= c && c <= 0x5a) || (0x61 <= c && c <= 0x7a))) {
return false;
}
}
return true;
}
var localeCache = {
runtimeDefaultLocale: undefined,
defaultLocale: undefined,
};
function DefaultLocale() {
if (intl_IsRuntimeDefaultLocale(localeCache.runtimeDefaultLocale)) {
return localeCache.defaultLocale;
}
var runtimeDefaultLocale = intl_RuntimeDefaultLocale();
var locale = intl_supportedLocaleOrFallback(runtimeDefaultLocale);
do { var canonical164 = intl_TryValidateAndCanonicalizeLanguageTag(locale); do { if (!(canonical164 !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 164 + ": " + `${"the computed default locale"} is a structurally valid language tag`) } } while (false); do { if (!(canonical164 === locale)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 164 + ": " + `${"the computed default locale"} is a canonicalized language tag`) } } while (false); } while (false);
do { if (!(startOfUnicodeExtensions(locale) < 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 168 + ": " + "the computed default locale must not contain a Unicode extension sequence") } } while (false);
localeCache.defaultLocale = locale;
localeCache.runtimeDefaultLocale = runtimeDefaultLocale;
return locale;
}
function CanonicalizeLocaleList(locales) {
if (locales === undefined) {
return [];
}
var tag = intl_ValidateAndCanonicalizeLanguageTag(locales, false);
if (tag !== null) {
do { if (!(typeof tag === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 194 + ": " + "intl_ValidateAndCanonicalizeLanguageTag returns a string value") } } while (false);
return [tag];
}
var seen = [];
var O = ToObject(locales);
var len = ToLength(O.length);
var k = 0;
while (k < len) {
if (k in O) {
var kValue = O[k];
if (!(typeof kValue === "string" || IsObject(kValue))) {
ThrowTypeError(513);
}
var tag = intl_ValidateAndCanonicalizeLanguageTag(kValue, true);
do { if (!(typeof tag === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 227 + ": " + "ValidateAndCanonicalizeLanguageTag returns a string value") } } while (false);
if (callFunction(std_Array_indexOf, seen, tag) === -1) {
DefineDataProperty(seen, seen.length, tag);
}
}
k++;
}
return seen;
}
function BestAvailableLocale(availableLocales, locale) {
return intl_BestAvailableLocale(availableLocales, locale, DefaultLocale());
}
function BestAvailableLocaleIgnoringDefault(availableLocales, locale) {
return intl_BestAvailableLocale(availableLocales, locale, null);
}
function LookupMatcher(availableLocales, requestedLocales) {
var result = new_Record();
for (var i = 0; i < requestedLocales.length; i++) {
var locale = requestedLocales[i];
var noExtensionsLocale = removeUnicodeExtensions(locale);
var availableLocale = BestAvailableLocale(
availableLocales,
noExtensionsLocale
);
if (availableLocale !== undefined) {
result.locale = availableLocale;
if (locale !== noExtensionsLocale) {
result.extension = getUnicodeExtensions(locale);
}
return result;
}
}
result.locale = DefaultLocale();
return result;
}
function BestFitMatcher(availableLocales, requestedLocales) {
return LookupMatcher(availableLocales, requestedLocales);
}
function UnicodeExtensionValue(extension, key) {
do { if (!(typeof extension === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 334 + ": " + "extension is a string value") } } while (false);
do { if (!(callFunction(std_String_startsWith, extension, "-u-") && getUnicodeExtensions("und" + extension) === extension)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 339 + ": " + "extension is a Unicode extension subtag") } } while (false);
do { if (!(typeof key === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 340 + ": " + "key is a string value") } } while (false);
do { if (!(key.length === 2)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 343 + ": " + "key is a Unicode extension key subtag") } } while (false);
var size = extension.length;
var searchValue = "-" + key + "-";
var pos = callFunction(std_String_indexOf, extension, searchValue);
if (pos !== -1) {
var start = pos + 4;
var end = start;
var k = start;
while (true) {
var e = callFunction(std_String_indexOf, extension, "-", k);
var len = e === -1 ? size - k : e - k;
if (len === 2) {
break;
}
if (e === -1) {
end = size;
break;
}
end = e;
k = e + 1;
}
return callFunction(String_substring, extension, start, end);
}
searchValue = "-" + key;
if (callFunction(std_String_endsWith, extension, searchValue)) {
return "";
}
}
function ResolveLocale(
availableLocales,
requestedLocales,
options,
relevantExtensionKeys,
localeData
) {
var matcher = options.localeMatcher;
var r =
matcher === "lookup"
? LookupMatcher(availableLocales, requestedLocales)
: BestFitMatcher(availableLocales, requestedLocales);
var foundLocale = r.locale;
var extension = r.extension;
var result = new_Record();
result.dataLocale = foundLocale;
var supportedExtension = "-u";
var localeDataProvider = localeData();
for (var i = 0; i < relevantExtensionKeys.length; i++) {
var key = relevantExtensionKeys[i];
var keyLocaleData = undefined;
var value = undefined;
var supportedExtensionAddition = "";
if (extension !== undefined) {
var requestedValue = UnicodeExtensionValue(extension, key);
if (requestedValue !== undefined) {
keyLocaleData = callFunction(
localeDataProvider[key],
null,
foundLocale
);
if (requestedValue !== "") {
if (
callFunction(std_Array_indexOf, keyLocaleData, requestedValue) !==
-1
) {
value = requestedValue;
supportedExtensionAddition = "-" + key + "-" + value;
}
} else {
if (callFunction(std_Array_indexOf, keyLocaleData, "true") !== -1) {
value = "true";
supportedExtensionAddition = "-" + key;
}
}
}
}
var optionsValue = options[key];
do { if (!(typeof optionsValue === "string" || optionsValue === undefined || optionsValue === null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 504 + ": " + "unexpected type for options value") } } while (false);
if (optionsValue !== undefined && optionsValue !== value) {
if (keyLocaleData === undefined) {
keyLocaleData = callFunction(
localeDataProvider[key],
null,
foundLocale
);
}
if (callFunction(std_Array_indexOf, keyLocaleData, optionsValue) !== -1) {
value = optionsValue;
supportedExtensionAddition = "";
}
}
if (value === undefined) {
value =
keyLocaleData === undefined
? callFunction(localeDataProvider.default[key], null, foundLocale)
: keyLocaleData[0];
}
do { if (!(typeof value === "string" || value === null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 537 + ": " + "unexpected locale data value") } } while (false);
result[key] = value;
supportedExtension += supportedExtensionAddition;
}
if (supportedExtension.length > 2) {
foundLocale = addUnicodeExtension(foundLocale, supportedExtension);
}
result.locale = foundLocale;
return result;
}
function addUnicodeExtension(locale, extension) {
do { if (!(typeof locale === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 562 + ": " + "locale is a string value") } } while (false);
do { if (!(!callFunction(std_String_startsWith, locale, "x-"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 566 + ": " + "unexpected privateuse-only locale") } } while (false);
do { if (!(startOfUnicodeExtensions(locale) < 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 570 + ": " + "Unicode extension subtag already present in locale") } } while (false);
do { if (!(typeof extension === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 572 + ": " + "extension is a string value") } } while (false);
do { if (!(callFunction(std_String_startsWith, extension, "-u-") && getUnicodeExtensions("und" + extension) === extension)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 577 + ": " + "extension is a Unicode extension subtag") } } while (false);
var privateIndex = callFunction(std_String_indexOf, locale, "-x-");
if (privateIndex === -1) {
locale += extension;
} else {
var preExtension = callFunction(String_substring, locale, 0, privateIndex);
var postExtension = callFunction(String_substring, locale, privateIndex);
locale = preExtension + extension + postExtension;
}
do { var canonical593 = intl_TryValidateAndCanonicalizeLanguageTag(locale); do { if (!(canonical593 !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 593 + ": " + `${"locale after concatenation"} is a structurally valid language tag`) } } while (false); do { if (!(canonical593 === locale)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 593 + ": " + `${"locale after concatenation"} is a canonicalized language tag`) } } while (false); } while (false);
return locale;
}
function LookupSupportedLocales(availableLocales, requestedLocales) {
var subset = [];
for (var i = 0; i < requestedLocales.length; i++) {
var locale = requestedLocales[i];
var noExtensionsLocale = removeUnicodeExtensions(locale);
var availableLocale = BestAvailableLocale(
availableLocales,
noExtensionsLocale
);
if (availableLocale !== undefined) {
DefineDataProperty(subset, subset.length, locale);
}
}
return subset;
}
function BestFitSupportedLocales(availableLocales, requestedLocales) {
return LookupSupportedLocales(availableLocales, requestedLocales);
}
function SupportedLocales(availableLocales, requestedLocales, options) {
var matcher;
if (options !== undefined) {
options = ToObject(options);
matcher = options.localeMatcher;
if (matcher !== undefined) {
matcher = ToString(matcher);
if (matcher !== "lookup" && matcher !== "best fit") {
ThrowRangeError(514, matcher);
}
}
}
return matcher === undefined || matcher === "best fit"
? BestFitSupportedLocales(availableLocales, requestedLocales)
: LookupSupportedLocales(availableLocales, requestedLocales);
}
function GetOption(options, property, type, values, fallback) {
var value = options[property];
if (value !== undefined) {
if (type === "boolean") {
value = ToBoolean(value);
} else if (type === "string") {
value = ToString(value);
} else {
do { if (!(false)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 693 + ": " + "GetOption") } } while (false);
}
if (
values !== undefined &&
callFunction(std_Array_indexOf, values, value) === -1
) {
ThrowRangeError(515, property, `"${value}"`);
}
return value;
}
return fallback;
}
function GetStringOrBooleanOption(
options,
property,
stringValues,
fallback
) {
do { if (!(IsObject(stringValues))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 723 + ": " + "GetStringOrBooleanOption") } } while (false);
var value = options[property];
if (value === undefined) {
return fallback;
}
if (value === true) {
return true;
}
if (!value) {
return false;
}
value = ToString(value);
if (callFunction(std_Array_indexOf, stringValues, value) === -1) {
ThrowRangeError(515, property, `"${value}"`);
}
return value;
}
function DefaultNumberOption(value, minimum, maximum, fallback) {
do { if (!(typeof minimum === "number" && (minimum | 0) === minimum)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 766 + ": " + "DefaultNumberOption") } } while (false);
do { if (!(typeof maximum === "number" && (maximum | 0) === maximum)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 770 + ": " + "DefaultNumberOption") } } while (false);
do { if (!(fallback === undefined || (typeof fallback === "number" && (fallback | 0) === fallback))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 775 + ": " + "DefaultNumberOption") } } while (false);
do { if (!(fallback === undefined || (minimum <= fallback && fallback <= maximum))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 779 + ": " + "DefaultNumberOption") } } while (false);
if (value === undefined) {
return fallback;
}
value = ToNumber(value);
if (Number_isNaN(value) || value < minimum || value > maximum) {
ThrowRangeError(510, value);
}
return std_Math_floor(value) | 0;
}
function GetNumberOption(options, property, minimum, maximum, fallback) {
return DefaultNumberOption(options[property], minimum, maximum, fallback);
}
var intlFallbackSymbolHolder = { value: undefined };
function intlFallbackSymbol() {
var fallbackSymbol = intlFallbackSymbolHolder.value;
if (!fallbackSymbol) {
var Symbol = GetBuiltinConstructor("Symbol");
fallbackSymbol = Symbol("IntlLegacyConstructedSymbol");
intlFallbackSymbolHolder.value = fallbackSymbol;
}
return fallbackSymbol;
}
function initializeIntlObject(obj, type, lazyData) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 837 + ": " + "Non-object passed to initializeIntlObject") } } while (false);
do { if (!((type === "Collator" && intl_GuardToCollator(obj) !== null) || (type === "DateTimeFormat" && intl_GuardToDateTimeFormat(obj) !== null) || (type === "DisplayNames" && intl_GuardToDisplayNames(obj) !== null) || (type === "ListFormat" && intl_GuardToListFormat(obj) !== null) || (type === "NumberFormat" && intl_GuardToNumberFormat(obj) !== null) || (type === "PluralRules" && intl_GuardToPluralRules(obj) !== null) || (type === "RelativeTimeFormat" && intl_GuardToRelativeTimeFormat(obj) !== null) || (type === "Segmenter" && intl_GuardToSegmenter(obj) !== null))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 849 + ": " + "type must match the object's class") } } while (false);
do { if (!(IsObject(lazyData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 850 + ": " + "non-object lazy data") } } while (false);
var internals = std_Object_create(null);
internals.type = type;
internals.lazyData = lazyData;
internals.internalProps = null;
do { if (!(UnsafeGetReservedSlot(obj, 0) === undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 881 + ": " + "Internal slot already initialized?") } } while (false);
UnsafeSetReservedSlot(obj, 0, internals);
}
function setInternalProperties(internals, internalProps) {
do { if (!(IsObject(internals.lazyData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 890 + ": " + "lazy data must exist already") } } while (false);
do { if (!(IsObject(internalProps))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 891 + ": " + "internalProps argument should be an object") } } while (false);
internals.internalProps = internalProps;
internals.lazyData = null;
}
function maybeInternalProperties(internals) {
do { if (!(IsObject(internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 903 + ": " + "non-object passed to maybeInternalProperties") } } while (false);
var lazyData = internals.lazyData;
if (lazyData) {
return null;
}
do { if (!(IsObject(internals.internalProps))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 911 + ": " + "missing lazy data and computed internals") } } while (false);
return internals.internalProps;
}
function getIntlObjectInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 924 + ": " + "getIntlObjectInternals called with non-Object") } } while (false);
do { if (!(intl_GuardToCollator(obj) !== null || intl_GuardToDateTimeFormat(obj) !== null || intl_GuardToDisplayNames(obj) !== null || intl_GuardToListFormat(obj) !== null || intl_GuardToNumberFormat(obj) !== null || intl_GuardToPluralRules(obj) !== null || intl_GuardToRelativeTimeFormat(obj) !== null || intl_GuardToSegmenter(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 935 + ": " + "getIntlObjectInternals called with non-Intl object") } } while (false);
var internals = UnsafeGetReservedSlot(obj, 0);
do { if (!(IsObject(internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 939 + ": " + "internals not an object") } } while (false);
do { if (!(hasOwn("type", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 940 + ": " + "missing type") } } while (false);
do { if (!((internals.type === "Collator" && intl_GuardToCollator(obj) !== null) || (internals.type === "DateTimeFormat" && intl_GuardToDateTimeFormat(obj) !== null) || (internals.type === "DisplayNames" && intl_GuardToDisplayNames(obj) !== null) || (internals.type === "ListFormat" && intl_GuardToListFormat(obj) !== null) || (internals.type === "NumberFormat" && intl_GuardToNumberFormat(obj) !== null) || (internals.type === "PluralRules" && intl_GuardToPluralRules(obj) !== null) || (internals.type === "RelativeTimeFormat" && intl_GuardToRelativeTimeFormat(obj) !== null) || (internals.type === "Segmenter" && intl_GuardToSegmenter(obj) !== null))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 958 + ": " + "type must match the object's class") } } while (false);
do { if (!(hasOwn("lazyData", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 959 + ": " + "missing lazyData") } } while (false);
do { if (!(hasOwn("internalProps", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 960 + ": " + "missing internalProps") } } while (false);
return internals;
}
function getInternals(obj) {
var internals = getIntlObjectInternals(obj);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
var type = internals.type;
if (type === "Collator") {
internalProps = resolveCollatorInternals(internals.lazyData);
} else if (type === "DateTimeFormat") {
internalProps = resolveDateTimeFormatInternals(internals.lazyData);
} else if (type === "DisplayNames") {
internalProps = resolveDisplayNamesInternals(internals.lazyData);
} else if (type === "ListFormat") {
internalProps = resolveListFormatInternals(internals.lazyData);
} else if (type === "NumberFormat") {
internalProps = resolveNumberFormatInternals(internals.lazyData);
} else if (type === "PluralRules") {
internalProps = resolvePluralRulesInternals(internals.lazyData);
} else if (type === "RelativeTimeFormat") {
internalProps = resolveRelativeTimeFormatInternals(internals.lazyData);
} else {
do { if (!(type === "Segmenter")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/CommonFunctions.js" + ":" + 995 + ": " + "unexpected Intl type") } } while (false);
internalProps = resolveSegmenterInternals(internals.lazyData);
}
setInternalProperties(internals, internalProps);
return internalProps;
}
var currencyDigits = {
BHD: 3,
BIF: 0,
CLF: 4,
CLP: 0,
DJF: 0,
GNF: 0,
IQD: 3,
ISK: 0,
JOD: 3,
JPY: 0,
KMF: 0,
KRW: 0,
KWD: 3,
LYD: 3,
OMR: 3,
PYG: 0,
RWF: 0,
TND: 3,
UGX: 0,
UYI: 0,
UYW: 4,
VND: 0,
VUV: 0,
XAF: 0,
XOF: 0,
XPF: 0,
};
function resolveDateTimeFormatInternals(lazyDateTimeFormatData) {
do { if (!(IsObject(lazyDateTimeFormatData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 13 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var DateTimeFormat = dateTimeFormatInternalProperties;
var localeData = DateTimeFormat.localeData;
var r = ResolveLocale(
"DateTimeFormat",
lazyDateTimeFormatData.requestedLocales,
lazyDateTimeFormatData.localeOpt,
DateTimeFormat.relevantExtensionKeys,
localeData
);
internalProps.locale = r.locale;
internalProps.calendar = r.ca;
internalProps.numberingSystem = r.nu;
var formatOptions = lazyDateTimeFormatData.formatOptions;
if (r.hc !== null && formatOptions.hour12 === undefined) {
formatOptions.hourCycle = r.hc;
}
internalProps.timeZone = lazyDateTimeFormatData.timeZone;
if (lazyDateTimeFormatData.patternOption !== undefined) {
internalProps.pattern = lazyDateTimeFormatData.patternOption;
} else if (
lazyDateTimeFormatData.dateStyle !== undefined ||
lazyDateTimeFormatData.timeStyle !== undefined
) {
internalProps.hourCycle = formatOptions.hourCycle;
internalProps.hour12 = formatOptions.hour12;
internalProps.dateStyle = lazyDateTimeFormatData.dateStyle;
internalProps.timeStyle = lazyDateTimeFormatData.timeStyle;
} else {
internalProps.hourCycle = formatOptions.hourCycle;
internalProps.hour12 = formatOptions.hour12;
internalProps.weekday = formatOptions.weekday;
internalProps.era = formatOptions.era;
internalProps.year = formatOptions.year;
internalProps.month = formatOptions.month;
internalProps.day = formatOptions.day;
internalProps.dayPeriod = formatOptions.dayPeriod;
internalProps.hour = formatOptions.hour;
internalProps.minute = formatOptions.minute;
internalProps.second = formatOptions.second;
internalProps.fractionalSecondDigits = formatOptions.fractionalSecondDigits;
internalProps.timeZoneName = formatOptions.timeZoneName;
}
return internalProps;
}
function getDateTimeFormatInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 129 + ": " + "getDateTimeFormatInternals called with non-object") } } while (false);
do { if (!(intl_GuardToDateTimeFormat(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 133 + ": " + "getDateTimeFormatInternals called with non-DateTimeFormat") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "DateTimeFormat")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 139 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveDateTimeFormatInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function UnwrapDateTimeFormat(dtf) {
if (
IsObject(dtf) &&
intl_GuardToDateTimeFormat(dtf) === null &&
!intl_IsWrappedDateTimeFormat(dtf) &&
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("DateTimeFormat"),
dtf
)
) {
dtf = dtf[intlFallbackSymbol()];
}
return dtf;
}
function CanonicalizeTimeZoneName(timeZone) {
do { if (!(typeof timeZone === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 181 + ": " + "CanonicalizeTimeZoneName") } } while (false);
do { if (!(timeZone !== "Etc/Unknown")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 184 + ": " + "Invalid time zone") } } while (false);
do { if (!(timeZone === intl_IsValidTimeZoneName(timeZone))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 188 + ": " + "Time zone name not normalized") } } while (false);
var ianaTimeZone = intl_canonicalizeTimeZone(timeZone);
do { if (!(ianaTimeZone !== "Etc/Unknown")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 192 + ": " + "Invalid canonical time zone") } } while (false);
do { if (!(ianaTimeZone === intl_IsValidTimeZoneName(ianaTimeZone))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 196 + ": " + "Unsupported canonical time zone") } } while (false);
if (ianaTimeZone === "Etc/UTC" || ianaTimeZone === "Etc/GMT") {
ianaTimeZone = "UTC";
}
return ianaTimeZone;
}
var timeZoneCache = {
icuDefaultTimeZone: undefined,
defaultTimeZone: undefined,
};
function DefaultTimeZone() {
if (intl_isDefaultTimeZone(timeZoneCache.icuDefaultTimeZone)) {
return timeZoneCache.defaultTimeZone;
}
var icuDefaultTimeZone = intl_defaultTimeZone();
var timeZone = intl_IsValidTimeZoneName(icuDefaultTimeZone);
if (timeZone === null) {
var msPerHour = 60 * 60 * 1000;
var offset = intl_defaultTimeZoneOffset();
do { if (!(offset === (offset | 0))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 236 + ": " + "milliseconds offset shouldn't be able to exceed int32_t range") } } while (false);
var offsetHours = offset / msPerHour;
var offsetHoursFraction = offset % msPerHour;
if (offsetHoursFraction === 0) {
timeZone =
"Etc/GMT" + (offsetHours < 0 ? "+" : "-") + std_Math_abs(offsetHours);
timeZone = intl_IsValidTimeZoneName(timeZone);
}
if (timeZone === null) {
timeZone = "UTC";
}
}
var defaultTimeZone = CanonicalizeTimeZoneName(timeZone);
timeZoneCache.defaultTimeZone = defaultTimeZone;
timeZoneCache.icuDefaultTimeZone = icuDefaultTimeZone;
return defaultTimeZone;
}
function TimeZoneOffsetString(offsetString) {
do { if (!(typeof(offsetString) === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 275 + ": " + "offsetString is a string") } } while (false);
if (offsetString.length < 3 || offsetString.length > 6) {
return null;
}
var sign = callFunction(std_String_charCodeAt, offsetString, 0);
if (sign !== 0x2b && sign !== 0x2d && sign !== 0x2212) {
return null;
}
var hourTens = callFunction(std_String_charCodeAt, offsetString, 1);
var hourOnes = callFunction(std_String_charCodeAt, offsetString, 2);
var minutesTens = 0x30;
var minutesOnes = 0x30;
if (offsetString.length > 3) {
var separatorLength = offsetString[3] === ":" ? 1 : 0;
if (offsetString.length !== (5 + separatorLength)) {
return null;
}
minutesTens = callFunction(
std_String_charCodeAt,
offsetString,
3 + separatorLength,
);
minutesOnes = callFunction(
std_String_charCodeAt,
offsetString,
4 + separatorLength,
);
}
if (
hourTens < 0x30 ||
hourOnes < 0x30 ||
minutesTens < 0x30 ||
minutesOnes < 0x30 ||
hourTens > 0x32 ||
hourOnes > 0x39 ||
minutesTens > 0x35 ||
minutesOnes > 0x39 ||
(hourTens === 0x32 && hourOnes > 0x33)
) {
return null;
}
if (
hourTens === 0x30 &&
hourOnes === 0x30 &&
minutesTens === 0x30 &&
minutesOnes === 0x30
) {
sign = 0x2b;
} else if (sign === 0x2212) {
sign = 0x2d;
}
return std_String_fromCharCode(
sign,
hourTens,
hourOnes,
0x3a,
minutesTens,
minutesOnes,
);
}
function InitializeDateTimeFormat(
dateTimeFormat,
thisValue,
locales,
options,
required,
defaults,
mozExtensions
) {
do { if (!(IsObject(dateTimeFormat))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 447 + ": " + "InitializeDateTimeFormat called with non-Object") } } while (false);
do { if (!(intl_GuardToDateTimeFormat(dateTimeFormat) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 451 + ": " + "InitializeDateTimeFormat called with non-DateTimeFormat") } } while (false);
do { if (!(required === "date" || required === "time" || required === "any")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 455 + ": " + `InitializeDateTimeFormat called with invalid required value: ${required}`) } } while (false);
do { if (!(defaults === "date" || defaults === "time" || defaults === "all")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 459 + ": " + `InitializeDateTimeFormat called with invalid defaults value: ${defaults}`) } } while (false);
var lazyDateTimeFormatData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyDateTimeFormatData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else {
options = ToObject(options);
}
var localeOpt = new_Record();
lazyDateTimeFormatData.localeOpt = localeOpt;
var localeMatcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
localeOpt.localeMatcher = localeMatcher;
var calendar = GetOption(options, "calendar", "string", undefined, undefined);
if (calendar !== undefined) {
calendar = intl_ValidateAndCanonicalizeUnicodeExtensionType(
calendar,
"calendar",
"ca"
);
}
localeOpt.ca = calendar;
var numberingSystem = GetOption(
options,
"numberingSystem",
"string",
undefined,
undefined
);
if (numberingSystem !== undefined) {
numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(
numberingSystem,
"numberingSystem",
"nu"
);
}
localeOpt.nu = numberingSystem;
var hour12 = GetOption(options, "hour12", "boolean", undefined, undefined);
var hourCycle = GetOption(
options,
"hourCycle",
"string",
["h11", "h12", "h23", "h24"],
undefined
);
if (hour12 !== undefined) {
hourCycle = null;
}
localeOpt.hc = hourCycle;
var timeZone = options.timeZone;
if (timeZone === undefined) {
timeZone = DefaultTimeZone();
} else {
timeZone = ToString(timeZone);
var offsetString = TimeZoneOffsetString(timeZone);
if (offsetString !== null) {
timeZone = offsetString;
} else {
var validTimeZone = intl_IsValidTimeZoneName(timeZone);
if (validTimeZone !== null) {
timeZone = CanonicalizeTimeZoneName(validTimeZone);
} else {
ThrowRangeError(516, timeZone);
}
}
}
lazyDateTimeFormatData.timeZone = timeZone;
var formatOptions = new_Record();
lazyDateTimeFormatData.formatOptions = formatOptions;
if (mozExtensions) {
var pattern = GetOption(options, "pattern", "string", undefined, undefined);
lazyDateTimeFormatData.patternOption = pattern;
}
if (hour12 !== undefined) {
formatOptions.hour12 = hour12;
}
formatOptions.weekday = GetOption(
options,
"weekday",
"string",
["narrow", "short", "long"],
undefined
);
formatOptions.era = GetOption(
options,
"era",
"string",
["narrow", "short", "long"],
undefined
);
formatOptions.year = GetOption(
options,
"year",
"string",
["2-digit", "numeric"],
undefined
);
formatOptions.month = GetOption(
options,
"month",
"string",
["2-digit", "numeric", "narrow", "short", "long"],
undefined
);
formatOptions.day = GetOption(
options,
"day",
"string",
["2-digit", "numeric"],
undefined
);
formatOptions.dayPeriod = GetOption(
options,
"dayPeriod",
"string",
["narrow", "short", "long"],
undefined
);
formatOptions.hour = GetOption(
options,
"hour",
"string",
["2-digit", "numeric"],
undefined
);
formatOptions.minute = GetOption(
options,
"minute",
"string",
["2-digit", "numeric"],
undefined
);
formatOptions.second = GetOption(
options,
"second",
"string",
["2-digit", "numeric"],
undefined
);
formatOptions.fractionalSecondDigits = GetNumberOption(
options,
"fractionalSecondDigits",
1,
3,
undefined
);
formatOptions.timeZoneName = GetOption(
options,
"timeZoneName",
"string",
[
"short",
"long",
"shortOffset",
"longOffset",
"shortGeneric",
"longGeneric",
],
undefined
);
var formatMatcher = GetOption(
options,
"formatMatcher",
"string",
["basic", "best fit"],
"best fit"
);
void formatMatcher;
var dateStyle = GetOption(
options,
"dateStyle",
"string",
["full", "long", "medium", "short"],
undefined
);
lazyDateTimeFormatData.dateStyle = dateStyle;
var timeStyle = GetOption(
options,
"timeStyle",
"string",
["full", "long", "medium", "short"],
undefined
);
lazyDateTimeFormatData.timeStyle = timeStyle;
if (dateStyle !== undefined || timeStyle !== undefined) {
var explicitFormatComponent =
formatOptions.weekday !== undefined
? "weekday"
: formatOptions.era !== undefined
? "era"
: formatOptions.year !== undefined
? "year"
: formatOptions.month !== undefined
? "month"
: formatOptions.day !== undefined
? "day"
: formatOptions.dayPeriod !== undefined
? "dayPeriod"
: formatOptions.hour !== undefined
? "hour"
: formatOptions.minute !== undefined
? "minute"
: formatOptions.second !== undefined
? "second"
: formatOptions.fractionalSecondDigits !== undefined
? "fractionalSecondDigits"
: formatOptions.timeZoneName !== undefined
? "timeZoneName"
: undefined;
if (explicitFormatComponent !== undefined) {
ThrowTypeError(
517,
explicitFormatComponent,
dateStyle !== undefined ? "dateStyle" : "timeStyle"
);
}
if (required === "date" && timeStyle !== undefined) {
ThrowTypeError(
518,
"timeStyle",
"toLocaleDateString"
);
}
if (required === "time" && dateStyle !== undefined) {
ThrowTypeError(
518,
"dateStyle",
"toLocaleTimeString"
);
}
} else {
var needDefaults = true;
if (required === "date" || required === "any") {
needDefaults =
formatOptions.weekday === undefined &&
formatOptions.year === undefined &&
formatOptions.month === undefined &&
formatOptions.day === undefined;
}
if (required === "time" || required === "any") {
needDefaults =
needDefaults &&
formatOptions.dayPeriod === undefined &&
formatOptions.hour === undefined &&
formatOptions.minute === undefined &&
formatOptions.second === undefined &&
formatOptions.fractionalSecondDigits === undefined;
}
if (needDefaults && (defaults === "date" || defaults === "all")) {
formatOptions.year = "numeric";
formatOptions.month = "numeric";
formatOptions.day = "numeric";
}
if (needDefaults && (defaults === "time" || defaults === "all")) {
formatOptions.hour = "numeric";
formatOptions.minute = "numeric";
formatOptions.second = "numeric";
}
}
initializeIntlObject(
dateTimeFormat,
"DateTimeFormat",
lazyDateTimeFormatData
);
if (
dateTimeFormat !== thisValue &&
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("DateTimeFormat"),
thisValue
)
) {
DefineDataProperty(
thisValue,
intlFallbackSymbol(),
dateTimeFormat,
0x08 | 0x10 | 0x20
);
return thisValue;
}
return dateTimeFormat;
}
function Intl_DateTimeFormat_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "DateTimeFormat";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
var dateTimeFormatInternalProperties = {
localeData: dateTimeFormatLocaleData,
relevantExtensionKeys: ["ca", "hc", "nu"],
};
function dateTimeFormatLocaleData() {
return {
ca: intl_availableCalendars,
nu: getNumberingSystems,
hc: () => {
return [null, "h11", "h12", "h23", "h24"];
},
default: {
ca: intl_defaultCalendar,
nu: intl_numberingSystem,
hc: () => {
return null;
},
},
};
}
function createDateTimeFormatFormat(dtf) {
return function(date) {
do { if (!(IsObject(dtf))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 945 + ": " + "dateTimeFormatFormatToBind called with non-Object") } } while (false);
do { if (!(intl_GuardToDateTimeFormat(dtf) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DateTimeFormat.js" + ":" + 949 + ": " + "dateTimeFormatFormatToBind called with non-DateTimeFormat") } } while (false);
var x = date === undefined ? std_Date_now() : ToNumber(date);
return intl_FormatDateTime(dtf, x, false);
};
}
function $Intl_DateTimeFormat_format_get() {
var thisArg = UnwrapDateTimeFormat(this);
var dtf = thisArg;
if (!IsObject(dtf) || (dtf = intl_GuardToDateTimeFormat(dtf)) === null) {
return callFunction(
intl_CallDateTimeFormatMethodIfWrapped,
thisArg,
"$Intl_DateTimeFormat_format_get"
);
}
var internals = getDateTimeFormatInternals(dtf);
if (internals.boundFormat === undefined) {
internals.boundFormat = createDateTimeFormatFormat(dtf);
}
return internals.boundFormat;
}
SetCanonicalName($Intl_DateTimeFormat_format_get, "get format");
function Intl_DateTimeFormat_formatToParts(date) {
var dtf = this;
if (!IsObject(dtf) || (dtf = intl_GuardToDateTimeFormat(dtf)) === null) {
return callFunction(
intl_CallDateTimeFormatMethodIfWrapped,
this,
date,
"Intl_DateTimeFormat_formatToParts"
);
}
var x = date === undefined ? std_Date_now() : ToNumber(date);
getDateTimeFormatInternals(dtf);
return intl_FormatDateTime(dtf, x, true);
}
function Intl_DateTimeFormat_formatRange(startDate, endDate) {
var dtf = this;
if (!IsObject(dtf) || (dtf = intl_GuardToDateTimeFormat(dtf)) === null) {
return callFunction(
intl_CallDateTimeFormatMethodIfWrapped,
this,
startDate,
endDate,
"Intl_DateTimeFormat_formatRange"
);
}
if (startDate === undefined || endDate === undefined) {
ThrowTypeError(
521,
startDate === undefined ? "start" : "end",
"formatRange"
);
}
var x = ToNumber(startDate);
var y = ToNumber(endDate);
getDateTimeFormatInternals(dtf);
return intl_FormatDateTimeRange(dtf, x, y, false);
}
function Intl_DateTimeFormat_formatRangeToParts(startDate, endDate) {
var dtf = this;
if (!IsObject(dtf) || (dtf = intl_GuardToDateTimeFormat(dtf)) === null) {
return callFunction(
intl_CallDateTimeFormatMethodIfWrapped,
this,
startDate,
endDate,
"Intl_DateTimeFormat_formatRangeToParts"
);
}
if (startDate === undefined || endDate === undefined) {
ThrowTypeError(
521,
startDate === undefined ? "start" : "end",
"formatRangeToParts"
);
}
var x = ToNumber(startDate);
var y = ToNumber(endDate);
getDateTimeFormatInternals(dtf);
return intl_FormatDateTimeRange(dtf, x, y, true);
}
function Intl_DateTimeFormat_resolvedOptions() {
var thisArg = UnwrapDateTimeFormat(this);
var dtf = thisArg;
if (!IsObject(dtf) || (dtf = intl_GuardToDateTimeFormat(dtf)) === null) {
return callFunction(
intl_CallDateTimeFormatMethodIfWrapped,
thisArg,
"Intl_DateTimeFormat_resolvedOptions"
);
}
var internals = getDateTimeFormatInternals(dtf);
var result = {
locale: internals.locale,
calendar: internals.calendar,
numberingSystem: internals.numberingSystem,
timeZone: internals.timeZone,
};
if (internals.pattern !== undefined) {
DefineDataProperty(result, "pattern", internals.pattern);
}
var hasDateStyle = internals.dateStyle !== undefined;
var hasTimeStyle = internals.timeStyle !== undefined;
if (hasDateStyle || hasTimeStyle) {
if (hasTimeStyle) {
intl_resolveDateTimeFormatComponents(
dtf,
result,
false
);
}
if (hasDateStyle) {
DefineDataProperty(result, "dateStyle", internals.dateStyle);
}
if (hasTimeStyle) {
DefineDataProperty(result, "timeStyle", internals.timeStyle);
}
} else {
intl_resolveDateTimeFormatComponents(
dtf,
result,
true
);
}
return result;
}
function displayNamesLocaleData() {
return {};
}
var displayNamesInternalProperties = {
localeData: displayNamesLocaleData,
relevantExtensionKeys: [],
};
function mozDisplayNamesLocaleData() {
return {
ca: intl_availableCalendars,
default: {
ca: intl_defaultCalendar,
},
};
}
var mozDisplayNamesInternalProperties = {
localeData: mozDisplayNamesLocaleData,
relevantExtensionKeys: ["ca"],
};
function resolveDisplayNamesInternals(lazyDisplayNamesData) {
do { if (!(IsObject(lazyDisplayNamesData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 36 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var mozExtensions = lazyDisplayNamesData.mozExtensions;
var DisplayNames = mozExtensions
? mozDisplayNamesInternalProperties
: displayNamesInternalProperties;
var localeData = DisplayNames.localeData;
var r = ResolveLocale(
"DisplayNames",
lazyDisplayNamesData.requestedLocales,
lazyDisplayNamesData.opt,
DisplayNames.relevantExtensionKeys,
localeData
);
internalProps.style = lazyDisplayNamesData.style;
var type = lazyDisplayNamesData.type;
internalProps.type = type;
internalProps.fallback = lazyDisplayNamesData.fallback;
internalProps.locale = r.locale;
if (type === "language") {
internalProps.languageDisplay = lazyDisplayNamesData.languageDisplay;
}
if (mozExtensions) {
internalProps.calendar = r.ca;
}
return internalProps;
}
function getDisplayNamesInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 91 + ": " + "getDisplayNamesInternals called with non-object") } } while (false);
do { if (!(intl_GuardToDisplayNames(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 95 + ": " + "getDisplayNamesInternals called with non-DisplayNames") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "DisplayNames")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 101 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveDisplayNamesInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function InitializeDisplayNames(displayNames, locales, options, mozExtensions) {
do { if (!(IsObject(displayNames))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 130 + ": " + "InitializeDisplayNames called with non-object") } } while (false);
do { if (!(intl_GuardToDisplayNames(displayNames) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 134 + ": " + "InitializeDisplayNames called with non-DisplayNames") } } while (false);
var lazyDisplayNamesData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyDisplayNamesData.requestedLocales = requestedLocales;
if (!IsObject(options)) {
ThrowTypeError(
55,
options === null ? "null" : typeof options
);
}
var opt = new_Record();
lazyDisplayNamesData.opt = opt;
lazyDisplayNamesData.mozExtensions = mozExtensions;
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
if (mozExtensions) {
var calendar = GetOption(
options,
"calendar",
"string",
undefined,
undefined
);
if (calendar !== undefined) {
calendar = intl_ValidateAndCanonicalizeUnicodeExtensionType(
calendar,
"calendar",
"ca"
);
}
opt.ca = calendar;
}
var style;
if (mozExtensions) {
style = GetOption(
options,
"style",
"string",
["narrow", "short", "abbreviated", "long"],
"long"
);
} else {
style = GetOption(
options,
"style",
"string",
["narrow", "short", "long"],
"long"
);
}
lazyDisplayNamesData.style = style;
var type;
if (mozExtensions) {
type = GetOption(
options,
"type",
"string",
[
"language",
"region",
"script",
"currency",
"calendar",
"dateTimeField",
"weekday",
"month",
"quarter",
"dayPeriod",
],
undefined
);
} else {
type = GetOption(
options,
"type",
"string",
["language", "region", "script", "currency", "calendar", "dateTimeField"],
undefined
);
}
if (type === undefined) {
ThrowTypeError(523);
}
lazyDisplayNamesData.type = type;
var fallback = GetOption(
options,
"fallback",
"string",
["code", "none"],
"code"
);
lazyDisplayNamesData.fallback = fallback;
var languageDisplay = GetOption(
options,
"languageDisplay",
"string",
["dialect", "standard"],
"dialect"
);
if (type === "language") {
lazyDisplayNamesData.languageDisplay = languageDisplay;
}
initializeIntlObject(displayNames, "DisplayNames", lazyDisplayNamesData);
}
function Intl_DisplayNames_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "DisplayNames";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
function Intl_DisplayNames_of(code) {
var displayNames = this;
if (
!IsObject(displayNames) ||
(displayNames = intl_GuardToDisplayNames(displayNames)) === null
) {
return callFunction(
intl_CallDisplayNamesMethodIfWrapped,
this,
"Intl_DisplayNames_of"
);
}
code = ToString(code);
var internals = getDisplayNamesInternals(displayNames);
var {
locale,
calendar = "",
style,
type,
languageDisplay = "",
fallback,
} = internals;
return intl_ComputeDisplayName(
displayNames,
locale,
calendar,
style,
languageDisplay,
fallback,
type,
code
);
}
function Intl_DisplayNames_resolvedOptions() {
var displayNames = this;
if (
!IsObject(displayNames) ||
(displayNames = intl_GuardToDisplayNames(displayNames)) === null
) {
return callFunction(
intl_CallDisplayNamesMethodIfWrapped,
this,
"Intl_DisplayNames_resolvedOptions"
);
}
var internals = getDisplayNamesInternals(displayNames);
var options = {
locale: internals.locale,
style: internals.style,
type: internals.type,
fallback: internals.fallback,
};
do { if (!(hasOwn("languageDisplay", internals) === (internals.type === "language"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/DisplayNames.js" + ":" + 406 + ": " + "languageDisplay is present iff type is 'language'") } } while (false);
if (hasOwn("languageDisplay", internals)) {
DefineDataProperty(options, "languageDisplay", internals.languageDisplay);
}
if (hasOwn("calendar", internals)) {
DefineDataProperty(options, "calendar", internals.calendar);
}
return options;
}
function Intl_getCanonicalLocales(locales) {
return CanonicalizeLocaleList(locales);
}
function Intl_supportedValuesOf(key) {
key = ToString(key);
return intl_SupportedValuesOf(key);
}
function Intl_getCalendarInfo(locales) {
var requestedLocales = CanonicalizeLocaleList(locales);
var DateTimeFormat = dateTimeFormatInternalProperties;
var localeData = DateTimeFormat.localeData;
var localeOpt = new_Record();
localeOpt.localeMatcher = "best fit";
var r = ResolveLocale(
"DateTimeFormat",
requestedLocales,
localeOpt,
DateTimeFormat.relevantExtensionKeys,
localeData
);
var result = intl_GetCalendarInfo(r.locale);
DefineDataProperty(result, "calendar", r.ca);
DefineDataProperty(result, "locale", r.locale);
return result;
}
function listFormatLocaleData() {
return {};
}
var listFormatInternalProperties = {
localeData: listFormatLocaleData,
relevantExtensionKeys: [],
};
function resolveListFormatInternals(lazyListFormatData) {
do { if (!(IsObject(lazyListFormatData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/ListFormat.js" + ":" + 23 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var ListFormat = listFormatInternalProperties;
var localeData = ListFormat.localeData;
var r = ResolveLocale(
"ListFormat",
lazyListFormatData.requestedLocales,
lazyListFormatData.opt,
ListFormat.relevantExtensionKeys,
localeData
);
internalProps.locale = r.locale;
internalProps.type = lazyListFormatData.type;
internalProps.style = lazyListFormatData.style;
return internalProps;
}
function getListFormatInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/ListFormat.js" + ":" + 63 + ": " + "getListFormatInternals called with non-object") } } while (false);
do { if (!(intl_GuardToListFormat(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/ListFormat.js" + ":" + 67 + ": " + "getListFormatInternals called with non-ListFormat") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "ListFormat")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/ListFormat.js" + ":" + 73 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveListFormatInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function InitializeListFormat(listFormat, locales, options) {
do { if (!(IsObject(listFormat))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/ListFormat.js" + ":" + 99 + ": " + "InitializeListFormat called with non-object") } } while (false);
do { if (!(intl_GuardToListFormat(listFormat) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/ListFormat.js" + ":" + 103 + ": " + "InitializeListFormat called with non-ListFormat") } } while (false);
var lazyListFormatData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyListFormatData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else if (!IsObject(options)) {
ThrowTypeError(
55,
options === null ? "null" : typeof options
);
}
var opt = new_Record();
lazyListFormatData.opt = opt;
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var type = GetOption(
options,
"type",
"string",
["conjunction", "disjunction", "unit"],
"conjunction"
);
lazyListFormatData.type = type;
var style = GetOption(
options,
"style",
"string",
["long", "short", "narrow"],
"long"
);
lazyListFormatData.style = style;
initializeIntlObject(listFormat, "ListFormat", lazyListFormatData);
}
function Intl_ListFormat_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "ListFormat";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
function StringListFromIterable(iterable, methodName) {
if (iterable === undefined) {
return [];
}
var list = [];
for (var element of allowContentIter(iterable)) {
if (typeof element !== "string") {
ThrowTypeError(
69,
methodName,
"string",
typeof element
);
}
DefineDataProperty(list, list.length, element);
}
return list;
}
function Intl_ListFormat_format(list) {
var listFormat = this;
if (
!IsObject(listFormat) ||
(listFormat = intl_GuardToListFormat(listFormat)) === null
) {
return callFunction(
intl_CallListFormatMethodIfWrapped,
this,
list,
"Intl_ListFormat_format"
);
}
var stringList = StringListFromIterable(list, "format");
if (stringList.length < 2) {
return stringList.length === 0 ? "" : stringList[0];
}
getListFormatInternals(listFormat);
return intl_FormatList(listFormat, stringList, false);
}
function Intl_ListFormat_formatToParts(list) {
var listFormat = this;
if (
!IsObject(listFormat) ||
(listFormat = intl_GuardToListFormat(listFormat)) === null
) {
return callFunction(
intl_CallListFormatMethodIfWrapped,
this,
list,
"Intl_ListFormat_formatToParts"
);
}
var stringList = StringListFromIterable(list, "formatToParts");
if (stringList.length < 2) {
return stringList.length === 0
? []
: [{ type: "element", value: stringList[0] }];
}
getListFormatInternals(listFormat);
return intl_FormatList(listFormat, stringList, true);
}
function Intl_ListFormat_resolvedOptions() {
var listFormat = this;
if (
!IsObject(listFormat) ||
(listFormat = intl_GuardToListFormat(listFormat)) === null
) {
return callFunction(
intl_CallListFormatMethodIfWrapped,
this,
"Intl_ListFormat_resolvedOptions"
);
}
var internals = getListFormatInternals(listFormat);
var result = {
locale: internals.locale,
type: internals.type,
style: internals.style,
};
return result;
}
var numberFormatInternalProperties = {
localeData: numberFormatLocaleData,
relevantExtensionKeys: ["nu"],
};
function resolveNumberFormatInternals(lazyNumberFormatData) {
do { if (!(IsObject(lazyNumberFormatData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 30 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var NumberFormat = numberFormatInternalProperties;
var localeData = NumberFormat.localeData;
var r = ResolveLocale(
"NumberFormat",
lazyNumberFormatData.requestedLocales,
lazyNumberFormatData.opt,
NumberFormat.relevantExtensionKeys,
localeData
);
internalProps.locale = r.locale;
internalProps.numberingSystem = r.nu;
var style = lazyNumberFormatData.style;
internalProps.style = style;
if (style === "currency") {
internalProps.currency = lazyNumberFormatData.currency;
internalProps.currencyDisplay = lazyNumberFormatData.currencyDisplay;
internalProps.currencySign = lazyNumberFormatData.currencySign;
}
if (style === "unit") {
internalProps.unit = lazyNumberFormatData.unit;
internalProps.unitDisplay = lazyNumberFormatData.unitDisplay;
}
var notation = lazyNumberFormatData.notation;
internalProps.notation = notation;
internalProps.minimumIntegerDigits =
lazyNumberFormatData.minimumIntegerDigits;
internalProps.roundingIncrement = lazyNumberFormatData.roundingIncrement;
internalProps.roundingMode = lazyNumberFormatData.roundingMode;
internalProps.trailingZeroDisplay = lazyNumberFormatData.trailingZeroDisplay;
if ("minimumFractionDigits" in lazyNumberFormatData) {
do { if (!("maximumFractionDigits" in lazyNumberFormatData)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 97 + ": " + "min/max frac digits mismatch") } } while (false);
internalProps.minimumFractionDigits =
lazyNumberFormatData.minimumFractionDigits;
internalProps.maximumFractionDigits =
lazyNumberFormatData.maximumFractionDigits;
}
if ("minimumSignificantDigits" in lazyNumberFormatData) {
do { if (!("maximumSignificantDigits" in lazyNumberFormatData)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 111 + ": " + "min/max sig digits mismatch") } } while (false);
internalProps.minimumSignificantDigits =
lazyNumberFormatData.minimumSignificantDigits;
internalProps.maximumSignificantDigits =
lazyNumberFormatData.maximumSignificantDigits;
}
internalProps.roundingPriority = lazyNumberFormatData.roundingPriority;
if (notation === "compact") {
internalProps.compactDisplay = lazyNumberFormatData.compactDisplay;
}
internalProps.useGrouping = lazyNumberFormatData.useGrouping;
internalProps.signDisplay = lazyNumberFormatData.signDisplay;
return internalProps;
}
function getNumberFormatInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 141 + ": " + "getNumberFormatInternals called with non-object") } } while (false);
do { if (!(intl_GuardToNumberFormat(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 145 + ": " + "getNumberFormatInternals called with non-NumberFormat") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "NumberFormat")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 151 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveNumberFormatInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function UnwrapNumberFormat(nf) {
if (
IsObject(nf) &&
intl_GuardToNumberFormat(nf) === null &&
!intl_IsWrappedNumberFormat(nf) &&
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("NumberFormat"),
nf
)
) {
return nf[intlFallbackSymbol()];
}
return nf;
}
function SetNumberFormatDigitOptions(
lazyData,
options,
mnfdDefault,
mxfdDefault,
notation
) {
do { if (!(IsObject(options))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 202 + ": " + "SetNumberFormatDigitOptions") } } while (false);
do { if (!(typeof mnfdDefault === "number")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 203 + ": " + "SetNumberFormatDigitOptions") } } while (false);
do { if (!(typeof mxfdDefault === "number")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 204 + ": " + "SetNumberFormatDigitOptions") } } while (false);
do { if (!(mnfdDefault <= mxfdDefault)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 205 + ": " + "SetNumberFormatDigitOptions") } } while (false);
do { if (!(typeof notation === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 206 + ": " + "SetNumberFormatDigitOptions") } } while (false);
var mnid = GetNumberOption(options, "minimumIntegerDigits", 1, 21, 1);
var mnfd = options.minimumFractionDigits;
var mxfd = options.maximumFractionDigits;
var mnsd = options.minimumSignificantDigits;
var mxsd = options.maximumSignificantDigits;
lazyData.minimumIntegerDigits = mnid;
var roundingIncrement = GetNumberOption(
options,
"roundingIncrement",
1,
5000,
1
);
switch (roundingIncrement) {
case 1:
case 2:
case 5:
case 10:
case 20:
case 25:
case 50:
case 100:
case 200:
case 250:
case 500:
case 1000:
case 2000:
case 2500:
case 5000:
break;
default:
ThrowRangeError(
515,
"roundingIncrement",
roundingIncrement
);
}
var roundingMode = GetOption(
options,
"roundingMode",
"string",
[
"ceil",
"floor",
"expand",
"trunc",
"halfCeil",
"halfFloor",
"halfExpand",
"halfTrunc",
"halfEven",
],
"halfExpand"
);
var roundingPriority = GetOption(
options,
"roundingPriority",
"string",
["auto", "morePrecision", "lessPrecision"],
"auto"
);
var trailingZeroDisplay = GetOption(
options,
"trailingZeroDisplay",
"string",
["auto", "stripIfInteger"],
"auto"
);
if (roundingIncrement !== 1) {
mxfdDefault = mnfdDefault;
}
lazyData.roundingIncrement = roundingIncrement;
lazyData.roundingMode = roundingMode;
lazyData.trailingZeroDisplay = trailingZeroDisplay;
var hasSignificantDigits = mnsd !== undefined || mxsd !== undefined;
var hasFractionDigits = mnfd !== undefined || mxfd !== undefined;
var needSignificantDigits =
roundingPriority !== "auto" || hasSignificantDigits;
var needFractionalDigits =
roundingPriority !== "auto" ||
!(hasSignificantDigits || (!hasFractionDigits && notation === "compact"));
if (needSignificantDigits) {
if (hasSignificantDigits) {
mnsd = DefaultNumberOption(mnsd, 1, 21, 1);
lazyData.minimumSignificantDigits = mnsd;
mxsd = DefaultNumberOption(mxsd, mnsd, 21, 21);
lazyData.maximumSignificantDigits = mxsd;
} else {
lazyData.minimumSignificantDigits = 1;
lazyData.maximumSignificantDigits = 21;
}
}
if (needFractionalDigits) {
if (hasFractionDigits) {
mnfd = DefaultNumberOption(mnfd, 0, 100, undefined);
mxfd = DefaultNumberOption(mxfd, 0, 100, undefined);
if (mnfd === undefined) {
do { if (!(mxfd !== undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 356 + ": " + "mxfd isn't undefined when mnfd is undefined") } } while (false);
mnfd = std_Math_min(mnfdDefault, mxfd);
}
else if (mxfd === undefined) {
mxfd = std_Math_max(mxfdDefault, mnfd);
}
else if (mnfd > mxfd) {
ThrowRangeError(510, mxfd);
}
lazyData.minimumFractionDigits = mnfd;
lazyData.maximumFractionDigits = mxfd;
} else {
lazyData.minimumFractionDigits = mnfdDefault;
lazyData.maximumFractionDigits = mxfdDefault;
}
}
if (!needSignificantDigits && !needFractionalDigits) {
do { if (!(!hasSignificantDigits)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 386 + ": " + "bad significant digits in fallback case") } } while (false);
do { if (!(roundingPriority === "auto")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 390 + ": " + `bad rounding in fallback case: ${roundingPriority}`) } } while (false);
do { if (!(notation === "compact")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 394 + ": " + `bad notation in fallback case: ${notation}`) } } while (false);
lazyData.minimumFractionDigits = 0;
lazyData.maximumFractionDigits = 0;
lazyData.minimumSignificantDigits = 1;
lazyData.maximumSignificantDigits = 2;
lazyData.roundingPriority = "morePrecision";
} else {
lazyData.roundingPriority = roundingPriority;
}
if (roundingIncrement !== 1) {
if (roundingPriority !== "auto") {
ThrowTypeError(
525,
"roundingIncrement",
"roundingPriority"
);
}
if (hasSignificantDigits) {
ThrowTypeError(
525,
"roundingIncrement",
"minimumSignificantDigits"
);
}
if (
lazyData.minimumFractionDigits !==
lazyData.maximumFractionDigits
) {
ThrowRangeError(526);
}
}
}
function toASCIIUpperCase(s) {
do { if (!(typeof s === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 450 + ": " + "toASCIIUpperCase") } } while (false);
var result = "";
for (var i = 0; i < s.length; i++) {
var c = callFunction(std_String_charCodeAt, s, i);
result +=
0x61 <= c && c <= 0x7a
? callFunction(std_String_fromCharCode, null, c & ~0x20)
: s[i];
}
return result;
}
function IsWellFormedCurrencyCode(currency) {
do { if (!(typeof currency === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 474 + ": " + "currency is a string value") } } while (false);
return currency.length === 3 && IsASCIIAlphaString(currency);
}
function IsWellFormedUnitIdentifier(unitIdentifier) {
do { if (!(typeof unitIdentifier === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 494 + ": " + "unitIdentifier is a string value") } } while (false);
if (IsSanctionedSimpleUnitIdentifier(unitIdentifier)) {
return true;
}
var pos = callFunction(std_String_indexOf, unitIdentifier, "-per-");
if (pos < 0) {
return false;
}
var next = pos + "-per-".length;
var numerator = Substring(unitIdentifier, 0, pos);
var denominator = Substring(
unitIdentifier,
next,
unitIdentifier.length - next
);
return (
IsSanctionedSimpleUnitIdentifier(numerator) &&
IsSanctionedSimpleUnitIdentifier(denominator)
);
}
var availableMeasurementUnits = {
value: null,
};
function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
do { if (!(typeof unitIdentifier === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 548 + ": " + "unitIdentifier is a string value") } } while (false);
var isSanctioned = hasOwn(unitIdentifier, sanctionedSimpleUnitIdentifiers);
if (isSanctioned) {
if (availableMeasurementUnits.value === null) {
availableMeasurementUnits.value = intl_availableMeasurementUnits();
}
var isSupported = hasOwn(unitIdentifier, availableMeasurementUnits.value);
do { if (!(isSupported)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 572 + ": " + `"${unitIdentifier}" is sanctioned but not supported. Did you forget to update intl/icu/data_filter.json to include the unit (and any implicit compound units)? For example "speed/kilometer-per-hour" is implied by "length/kilometer" and "duration/hour" and must therefore also be present.`) } } while (false);
}
return isSanctioned;
}
function InitializeNumberFormat(numberFormat, thisValue, locales, options) {
do { if (!(IsObject(numberFormat))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 598 + ": " + "InitializeNumberFormat called with non-object") } } while (false);
do { if (!(intl_GuardToNumberFormat(numberFormat) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 602 + ": " + "InitializeNumberFormat called with non-NumberFormat") } } while (false);
var lazyNumberFormatData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyNumberFormatData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else {
options = ToObject(options);
}
var opt = new_Record();
lazyNumberFormatData.opt = opt;
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var numberingSystem = GetOption(
options,
"numberingSystem",
"string",
undefined,
undefined
);
if (numberingSystem !== undefined) {
numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(
numberingSystem,
"numberingSystem",
"nu"
);
}
opt.nu = numberingSystem;
var style = GetOption(
options,
"style",
"string",
["decimal", "percent", "currency", "unit"],
"decimal"
);
lazyNumberFormatData.style = style;
var currency = GetOption(options, "currency", "string", undefined, undefined);
if (currency === undefined) {
if (style === "currency") {
ThrowTypeError(519);
}
} else {
if (!IsWellFormedCurrencyCode(currency)) {
ThrowRangeError(508, currency);
}
}
var currencyDisplay = GetOption(
options,
"currencyDisplay",
"string",
["code", "symbol", "narrowSymbol", "name"],
"symbol"
);
var currencySign = GetOption(
options,
"currencySign",
"string",
["standard", "accounting"],
"standard"
);
if (style === "currency") {
currency = toASCIIUpperCase(currency);
lazyNumberFormatData.currency = currency;
lazyNumberFormatData.currencyDisplay = currencyDisplay;
lazyNumberFormatData.currencySign = currencySign;
}
var unit = GetOption(options, "unit", "string", undefined, undefined);
if (unit === undefined) {
if (style === "unit") {
ThrowTypeError(520);
}
} else {
if (!IsWellFormedUnitIdentifier(unit)) {
ThrowRangeError(509, unit);
}
}
var unitDisplay = GetOption(
options,
"unitDisplay",
"string",
["short", "narrow", "long"],
"short"
);
if (style === "unit") {
lazyNumberFormatData.unit = unit;
lazyNumberFormatData.unitDisplay = unitDisplay;
}
var mnfdDefault, mxfdDefault;
if (style === "currency") {
var cDigits = CurrencyDigits(currency);
mnfdDefault = cDigits;
mxfdDefault = cDigits;
} else {
mnfdDefault = 0;
mxfdDefault = style === "percent" ? 0 : 3;
}
var notation = GetOption(
options,
"notation",
"string",
["standard", "scientific", "engineering", "compact"],
"standard"
);
lazyNumberFormatData.notation = notation;
SetNumberFormatDigitOptions(
lazyNumberFormatData,
options,
mnfdDefault,
mxfdDefault,
notation
);
var compactDisplay = GetOption(
options,
"compactDisplay",
"string",
["short", "long"],
"short"
);
if (notation === "compact") {
lazyNumberFormatData.compactDisplay = compactDisplay;
}
var defaultUseGrouping = notation !== "compact" ? "auto" : "min2";
var useGrouping = GetStringOrBooleanOption(
options,
"useGrouping",
["min2", "auto", "always", "true", "false"],
defaultUseGrouping
);
if (useGrouping === "true" || useGrouping === "false") {
useGrouping = defaultUseGrouping;
} else if (useGrouping === true) {
useGrouping = "always";
}
do { if (!(useGrouping === "min2" || useGrouping === "auto" || useGrouping === "always" || useGrouping === false)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 868 + ": " + `invalid 'useGrouping' value: ${useGrouping}`) } } while (false);
lazyNumberFormatData.useGrouping = useGrouping;
var signDisplay = GetOption(
options,
"signDisplay",
"string",
["auto", "never", "always", "exceptZero", "negative"],
"auto"
);
lazyNumberFormatData.signDisplay = signDisplay;
initializeIntlObject(numberFormat, "NumberFormat", lazyNumberFormatData);
if (
numberFormat !== thisValue &&
callFunction(
std_Object_isPrototypeOf,
GetBuiltinPrototype("NumberFormat"),
thisValue
)
) {
DefineDataProperty(
thisValue,
intlFallbackSymbol(),
numberFormat,
0x08 | 0x10 | 0x20
);
return thisValue;
}
return numberFormat;
}
function CurrencyDigits(currency) {
do { if (!(typeof currency === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 919 + ": " + "currency is a string value") } } while (false);
do { if (!(IsWellFormedCurrencyCode(currency))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 920 + ": " + "currency is well-formed") } } while (false);
do { if (!(currency === toASCIIUpperCase(currency))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 921 + ": " + "currency is all upper-case") } } while (false);
if (hasOwn(currency, currencyDigits)) {
return currencyDigits[currency];
}
return 2;
}
function Intl_NumberFormat_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "NumberFormat";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
function getNumberingSystems(locale) {
var defaultNumberingSystem = intl_numberingSystem(locale);
return [defaultNumberingSystem, "adlm", "ahom", "arab", "arabext", "bali", "beng", "bhks", "brah", "cakm", "cham", "deva", "diak", "fullwide", "gong", "gonm", "gujr", "guru", "hanidec", "hmng", "hmnp", "java", "kali", "kawi", "khmr", "knda", "lana", "lanatham", "laoo", "latn", "lepc", "limb", "mathbold", "mathdbl", "mathmono", "mathsanb", "mathsans", "mlym", "modi", "mong", "mroo", "mtei", "mymr", "mymrshan", "mymrtlng", "nagm", "newa", "nkoo", "olck", "orya", "osma", "rohg", "saur", "segment", "shrd", "sind", "sinh", "sora", "sund", "takr", "talu", "tamldec", "telu", "thai", "tibt", "tirh", "tnsa", "vaii", "wara", "wcho"];
}
function numberFormatLocaleData() {
return {
nu: getNumberingSystems,
default: {
nu: intl_numberingSystem,
},
};
}
function createNumberFormatFormat(nf) {
return function(value) {
do { if (!(IsObject(nf))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 988 + ": " + "InitializeNumberFormat called with non-object") } } while (false);
do { if (!(intl_GuardToNumberFormat(nf) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 992 + ": " + "InitializeNumberFormat called with non-NumberFormat") } } while (false);
return intl_FormatNumber(nf, value, false);
};
}
function $Intl_NumberFormat_format_get() {
var thisArg = UnwrapNumberFormat(this);
var nf = thisArg;
if (!IsObject(nf) || (nf = intl_GuardToNumberFormat(nf)) === null) {
return callFunction(
intl_CallNumberFormatMethodIfWrapped,
thisArg,
"$Intl_NumberFormat_format_get"
);
}
var internals = getNumberFormatInternals(nf);
if (internals.boundFormat === undefined) {
internals.boundFormat = createNumberFormatFormat(nf);
}
return internals.boundFormat;
}
SetCanonicalName($Intl_NumberFormat_format_get, "get format");
function Intl_NumberFormat_formatToParts(value) {
var nf = this;
if (!IsObject(nf) || (nf = intl_GuardToNumberFormat(nf)) === null) {
return callFunction(
intl_CallNumberFormatMethodIfWrapped,
this,
value,
"Intl_NumberFormat_formatToParts"
);
}
return intl_FormatNumber(nf, value, true);
}
function Intl_NumberFormat_formatRange(start, end) {
var nf = this;
if (!IsObject(nf) || (nf = intl_GuardToNumberFormat(nf)) === null) {
return callFunction(
intl_CallNumberFormatMethodIfWrapped,
this,
start,
end,
"Intl_NumberFormat_formatRange"
);
}
if (start === undefined || end === undefined) {
ThrowTypeError(
522,
start === undefined ? "start" : "end",
"NumberFormat",
"formatRange"
);
}
return intl_FormatNumberRange(nf, start, end, false);
}
function Intl_NumberFormat_formatRangeToParts(start, end) {
var nf = this;
if (!IsObject(nf) || (nf = intl_GuardToNumberFormat(nf)) === null) {
return callFunction(
intl_CallNumberFormatMethodIfWrapped,
this,
start,
end,
"Intl_NumberFormat_formatRangeToParts"
);
}
if (start === undefined || end === undefined) {
ThrowTypeError(
522,
start === undefined ? "start" : "end",
"NumberFormat",
"formatRangeToParts"
);
}
return intl_FormatNumberRange(nf, start, end, true);
}
function Intl_NumberFormat_resolvedOptions() {
var thisArg = UnwrapNumberFormat(this);
var nf = thisArg;
if (!IsObject(nf) || (nf = intl_GuardToNumberFormat(nf)) === null) {
return callFunction(
intl_CallNumberFormatMethodIfWrapped,
thisArg,
"Intl_NumberFormat_resolvedOptions"
);
}
var internals = getNumberFormatInternals(nf);
var result = {
locale: internals.locale,
numberingSystem: internals.numberingSystem,
style: internals.style,
};
do { if (!(hasOwn("currency", internals) === (internals.style === "currency"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1159 + ": " + "currency is present iff style is 'currency'") } } while (false);
do { if (!(hasOwn("currencyDisplay", internals) === (internals.style === "currency"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1163 + ": " + "currencyDisplay is present iff style is 'currency'") } } while (false);
do { if (!(hasOwn("currencySign", internals) === (internals.style === "currency"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1167 + ": " + "currencySign is present iff style is 'currency'") } } while (false);
if (hasOwn("currency", internals)) {
DefineDataProperty(result, "currency", internals.currency);
DefineDataProperty(result, "currencyDisplay", internals.currencyDisplay);
DefineDataProperty(result, "currencySign", internals.currencySign);
}
do { if (!(hasOwn("unit", internals) === (internals.style === "unit"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1179 + ": " + "unit is present iff style is 'unit'") } } while (false);
do { if (!(hasOwn("unitDisplay", internals) === (internals.style === "unit"))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1183 + ": " + "unitDisplay is present iff style is 'unit'") } } while (false);
if (hasOwn("unit", internals)) {
DefineDataProperty(result, "unit", internals.unit);
DefineDataProperty(result, "unitDisplay", internals.unitDisplay);
}
DefineDataProperty(
result,
"minimumIntegerDigits",
internals.minimumIntegerDigits
);
do { if (!(hasOwn("minimumFractionDigits", internals) === hasOwn("maximumFractionDigits", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1201 + ": " + "minimumFractionDigits is present iff maximumFractionDigits is present") } } while (false);
if (hasOwn("minimumFractionDigits", internals)) {
DefineDataProperty(
result,
"minimumFractionDigits",
internals.minimumFractionDigits
);
DefineDataProperty(
result,
"maximumFractionDigits",
internals.maximumFractionDigits
);
}
do { if (!(hasOwn("minimumSignificantDigits", internals) === hasOwn("maximumSignificantDigits", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/NumberFormat.js" + ":" + 1221 + ": " + "minimumSignificantDigits is present iff maximumSignificantDigits is present") } } while (false);
if (hasOwn("minimumSignificantDigits", internals)) {
DefineDataProperty(
result,
"minimumSignificantDigits",
internals.minimumSignificantDigits
);
DefineDataProperty(
result,
"maximumSignificantDigits",
internals.maximumSignificantDigits
);
}
DefineDataProperty(result, "useGrouping", internals.useGrouping);
var notation = internals.notation;
DefineDataProperty(result, "notation", notation);
if (notation === "compact") {
DefineDataProperty(result, "compactDisplay", internals.compactDisplay);
}
DefineDataProperty(result, "signDisplay", internals.signDisplay);
DefineDataProperty(result, "roundingIncrement", internals.roundingIncrement);
DefineDataProperty(result, "roundingMode", internals.roundingMode);
DefineDataProperty(result, "roundingPriority", internals.roundingPriority);
DefineDataProperty(
result,
"trailingZeroDisplay",
internals.trailingZeroDisplay
);
return result;
}
var pluralRulesInternalProperties = {
localeData: pluralRulesLocaleData,
relevantExtensionKeys: [],
};
function pluralRulesLocaleData() {
return {};
}
function resolvePluralRulesInternals(lazyPluralRulesData) {
do { if (!(IsObject(lazyPluralRulesData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 31 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var PluralRules = pluralRulesInternalProperties;
var localeData = PluralRules.localeData;
var r = ResolveLocale(
"PluralRules",
lazyPluralRulesData.requestedLocales,
lazyPluralRulesData.opt,
PluralRules.relevantExtensionKeys,
localeData
);
internalProps.locale = r.locale;
internalProps.type = lazyPluralRulesData.type;
internalProps.minimumIntegerDigits = lazyPluralRulesData.minimumIntegerDigits;
internalProps.roundingIncrement = lazyPluralRulesData.roundingIncrement;
internalProps.roundingMode = lazyPluralRulesData.roundingMode;
internalProps.trailingZeroDisplay = lazyPluralRulesData.trailingZeroDisplay;
if ("minimumFractionDigits" in lazyPluralRulesData) {
do { if (!("maximumFractionDigits" in lazyPluralRulesData)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 74 + ": " + "min/max frac digits mismatch") } } while (false);
internalProps.minimumFractionDigits =
lazyPluralRulesData.minimumFractionDigits;
internalProps.maximumFractionDigits =
lazyPluralRulesData.maximumFractionDigits;
}
if ("minimumSignificantDigits" in lazyPluralRulesData) {
do { if (!("maximumSignificantDigits" in lazyPluralRulesData)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 86 + ": " + "min/max sig digits mismatch") } } while (false);
internalProps.minimumSignificantDigits =
lazyPluralRulesData.minimumSignificantDigits;
internalProps.maximumSignificantDigits =
lazyPluralRulesData.maximumSignificantDigits;
}
internalProps.roundingPriority = lazyPluralRulesData.roundingPriority;
internalProps.pluralCategories = null;
return internalProps;
}
function getPluralRulesInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 106 + ": " + "getPluralRulesInternals called with non-object") } } while (false);
do { if (!(intl_GuardToPluralRules(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 110 + ": " + "getPluralRulesInternals called with non-PluralRules") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "PluralRules")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 116 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolvePluralRulesInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function InitializePluralRules(pluralRules, locales, options) {
do { if (!(IsObject(pluralRules))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 142 + ": " + "InitializePluralRules called with non-object") } } while (false);
do { if (!(intl_GuardToPluralRules(pluralRules) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 146 + ": " + "InitializePluralRules called with non-PluralRules") } } while (false);
var lazyPluralRulesData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyPluralRulesData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else {
options = ToObject(options);
}
var opt = new_Record();
lazyPluralRulesData.opt = opt;
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var type = GetOption(
options,
"type",
"string",
["cardinal", "ordinal"],
"cardinal"
);
lazyPluralRulesData.type = type;
SetNumberFormatDigitOptions(lazyPluralRulesData, options, 0, 3, "standard");
initializeIntlObject(pluralRules, "PluralRules", lazyPluralRulesData);
}
function Intl_PluralRules_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "PluralRules";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
function Intl_PluralRules_select(value) {
var pluralRules = this;
if (
!IsObject(pluralRules) ||
(pluralRules = intl_GuardToPluralRules(pluralRules)) === null
) {
return callFunction(
intl_CallPluralRulesMethodIfWrapped,
this,
value,
"Intl_PluralRules_select"
);
}
var n = ToNumber(value);
getPluralRulesInternals(pluralRules);
return intl_SelectPluralRule(pluralRules, n);
}
function Intl_PluralRules_selectRange(start, end) {
var pluralRules = this;
if (
!IsObject(pluralRules) ||
(pluralRules = intl_GuardToPluralRules(pluralRules)) === null
) {
return callFunction(
intl_CallPluralRulesMethodIfWrapped,
this,
start,
end,
"Intl_PluralRules_selectRange"
);
}
if (start === undefined || end === undefined) {
ThrowTypeError(
522,
start === undefined ? "start" : "end",
"PluralRules",
"selectRange"
);
}
var x = ToNumber(start);
var y = ToNumber(end);
return intl_SelectPluralRuleRange(pluralRules, x, y);
}
function Intl_PluralRules_resolvedOptions() {
var pluralRules = this;
if (
!IsObject(pluralRules) ||
(pluralRules = intl_GuardToPluralRules(pluralRules)) === null
) {
return callFunction(
intl_CallPluralRulesMethodIfWrapped,
this,
"Intl_PluralRules_resolvedOptions"
);
}
var internals = getPluralRulesInternals(pluralRules);
var internalsPluralCategories = internals.pluralCategories;
if (internalsPluralCategories === null) {
internalsPluralCategories = intl_GetPluralCategories(pluralRules);
internals.pluralCategories = internalsPluralCategories;
}
var pluralCategories = [];
for (var i = 0; i < internalsPluralCategories.length; i++) {
DefineDataProperty(pluralCategories, i, internalsPluralCategories[i]);
}
var result = {
locale: internals.locale,
type: internals.type,
minimumIntegerDigits: internals.minimumIntegerDigits,
};
do { if (!(hasOwn("minimumFractionDigits", internals) === hasOwn("maximumFractionDigits", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 387 + ": " + "minimumFractionDigits is present iff maximumFractionDigits is present") } } while (false);
if (hasOwn("minimumFractionDigits", internals)) {
DefineDataProperty(
result,
"minimumFractionDigits",
internals.minimumFractionDigits
);
DefineDataProperty(
result,
"maximumFractionDigits",
internals.maximumFractionDigits
);
}
do { if (!(hasOwn("minimumSignificantDigits", internals) === hasOwn("maximumSignificantDigits", internals))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/PluralRules.js" + ":" + 407 + ": " + "minimumSignificantDigits is present iff maximumSignificantDigits is present") } } while (false);
if (hasOwn("minimumSignificantDigits", internals)) {
DefineDataProperty(
result,
"minimumSignificantDigits",
internals.minimumSignificantDigits
);
DefineDataProperty(
result,
"maximumSignificantDigits",
internals.maximumSignificantDigits
);
}
DefineDataProperty(result, "pluralCategories", pluralCategories);
DefineDataProperty(result, "roundingIncrement", internals.roundingIncrement);
DefineDataProperty(result, "roundingMode", internals.roundingMode);
DefineDataProperty(result, "roundingPriority", internals.roundingPriority);
DefineDataProperty(
result,
"trailingZeroDisplay",
internals.trailingZeroDisplay
);
return result;
}
var relativeTimeFormatInternalProperties = {
localeData: relativeTimeFormatLocaleData,
relevantExtensionKeys: ["nu"],
};
function relativeTimeFormatLocaleData() {
return {
nu: getNumberingSystems,
default: {
nu: intl_numberingSystem,
},
};
}
function resolveRelativeTimeFormatInternals(lazyRelativeTimeFormatData) {
do { if (!(IsObject(lazyRelativeTimeFormatData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/RelativeTimeFormat.js" + ":" + 28 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var RelativeTimeFormat = relativeTimeFormatInternalProperties;
var r = ResolveLocale(
"RelativeTimeFormat",
lazyRelativeTimeFormatData.requestedLocales,
lazyRelativeTimeFormatData.opt,
RelativeTimeFormat.relevantExtensionKeys,
RelativeTimeFormat.localeData
);
internalProps.locale = r.locale;
internalProps.numberingSystem = r.nu;
internalProps.style = lazyRelativeTimeFormatData.style;
internalProps.numeric = lazyRelativeTimeFormatData.numeric;
return internalProps;
}
function getRelativeTimeFormatInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/RelativeTimeFormat.js" + ":" + 69 + ": " + "getRelativeTimeFormatInternals called with non-object") } } while (false);
do { if (!(intl_GuardToRelativeTimeFormat(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/RelativeTimeFormat.js" + ":" + 73 + ": " + "getRelativeTimeFormatInternals called with non-RelativeTimeFormat") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "RelativeTimeFormat")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/RelativeTimeFormat.js" + ":" + 79 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveRelativeTimeFormatInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function InitializeRelativeTimeFormat(relativeTimeFormat, locales, options) {
do { if (!(IsObject(relativeTimeFormat))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/RelativeTimeFormat.js" + ":" + 106 + ": " + "InitializeRelativeimeFormat called with non-object") } } while (false);
do { if (!(intl_GuardToRelativeTimeFormat(relativeTimeFormat) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/RelativeTimeFormat.js" + ":" + 110 + ": " + "InitializeRelativeTimeFormat called with non-RelativeTimeFormat") } } while (false);
var lazyRelativeTimeFormatData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazyRelativeTimeFormatData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else {
options = ToObject(options);
}
var opt = new_Record();
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var numberingSystem = GetOption(
options,
"numberingSystem",
"string",
undefined,
undefined
);
if (numberingSystem !== undefined) {
numberingSystem = intl_ValidateAndCanonicalizeUnicodeExtensionType(
numberingSystem,
"numberingSystem",
"nu"
);
}
opt.nu = numberingSystem;
lazyRelativeTimeFormatData.opt = opt;
var style = GetOption(
options,
"style",
"string",
["long", "short", "narrow"],
"long"
);
lazyRelativeTimeFormatData.style = style;
var numeric = GetOption(
options,
"numeric",
"string",
["always", "auto"],
"always"
);
lazyRelativeTimeFormatData.numeric = numeric;
initializeIntlObject(
relativeTimeFormat,
"RelativeTimeFormat",
lazyRelativeTimeFormatData
);
}
function Intl_RelativeTimeFormat_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "RelativeTimeFormat";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
function Intl_RelativeTimeFormat_format(value, unit) {
var relativeTimeFormat = this;
if (
!IsObject(relativeTimeFormat) ||
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(
relativeTimeFormat
)) === null
) {
return callFunction(
intl_CallRelativeTimeFormatMethodIfWrapped,
this,
value,
unit,
"Intl_RelativeTimeFormat_format"
);
}
var t = ToNumber(value);
var u = ToString(unit);
return intl_FormatRelativeTime(relativeTimeFormat, t, u, false);
}
function Intl_RelativeTimeFormat_formatToParts(value, unit) {
var relativeTimeFormat = this;
if (
!IsObject(relativeTimeFormat) ||
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(
relativeTimeFormat
)) === null
) {
return callFunction(
intl_CallRelativeTimeFormatMethodIfWrapped,
this,
value,
unit,
"Intl_RelativeTimeFormat_formatToParts"
);
}
var t = ToNumber(value);
var u = ToString(unit);
return intl_FormatRelativeTime(relativeTimeFormat, t, u, true);
}
function Intl_RelativeTimeFormat_resolvedOptions() {
var relativeTimeFormat = this;
if (
!IsObject(relativeTimeFormat) ||
(relativeTimeFormat = intl_GuardToRelativeTimeFormat(
relativeTimeFormat
)) === null
) {
return callFunction(
intl_CallRelativeTimeFormatMethodIfWrapped,
this,
"Intl_RelativeTimeFormat_resolvedOptions"
);
}
var internals = getRelativeTimeFormatInternals(relativeTimeFormat);
var result = {
locale: internals.locale,
style: internals.style,
numeric: internals.numeric,
numberingSystem: internals.numberingSystem,
};
return result;
}
var sanctionedSimpleUnitIdentifiers = {
"acre": true,
"bit": true,
"byte": true,
"celsius": true,
"centimeter": true,
"day": true,
"degree": true,
"fahrenheit": true,
"fluid-ounce": true,
"foot": true,
"gallon": true,
"gigabit": true,
"gigabyte": true,
"gram": true,
"hectare": true,
"hour": true,
"inch": true,
"kilobit": true,
"kilobyte": true,
"kilogram": true,
"kilometer": true,
"liter": true,
"megabit": true,
"megabyte": true,
"meter": true,
"microsecond": true,
"mile": true,
"mile-scandinavian": true,
"milliliter": true,
"millimeter": true,
"millisecond": true,
"minute": true,
"month": true,
"nanosecond": true,
"ounce": true,
"percent": true,
"petabyte": true,
"pound": true,
"second": true,
"stone": true,
"terabit": true,
"terabyte": true,
"week": true,
"yard": true,
"year": true
};
function segmenterLocaleData() {
return {};
}
var segmenterInternalProperties = {
localeData: segmenterLocaleData,
relevantExtensionKeys: [],
};
function resolveSegmenterInternals(lazySegmenterData) {
do { if (!(IsObject(lazySegmenterData))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 23 + ": " + "lazy data not an object?") } } while (false);
var internalProps = std_Object_create(null);
var Segmenter = segmenterInternalProperties;
var localeData = Segmenter.localeData;
var r = ResolveLocale(
"Segmenter",
lazySegmenterData.requestedLocales,
lazySegmenterData.opt,
Segmenter.relevantExtensionKeys,
localeData
);
internalProps.locale = r.locale;
internalProps.granularity = lazySegmenterData.granularity;
return internalProps;
}
function getSegmenterInternals(obj) {
do { if (!(IsObject(obj))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 58 + ": " + "getSegmenterInternals called with non-object") } } while (false);
do { if (!(intl_GuardToSegmenter(obj) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 62 + ": " + "getSegmenterInternals called with non-Segmenter") } } while (false);
var internals = getIntlObjectInternals(obj);
do { if (!(internals.type === "Segmenter")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 68 + ": " + "bad type escaped getIntlObjectInternals") } } while (false);
var internalProps = maybeInternalProperties(internals);
if (internalProps) {
return internalProps;
}
internalProps = resolveSegmenterInternals(internals.lazyData);
setInternalProperties(internals, internalProps);
return internalProps;
}
function InitializeSegmenter(segmenter, locales, options) {
do { if (!(IsObject(segmenter))) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 94 + ": " + "InitializeSegmenter called with non-object") } } while (false);
do { if (!(intl_GuardToSegmenter(segmenter) !== null)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 98 + ": " + "InitializeSegmenter called with non-Segmenter") } } while (false);
var lazySegmenterData = std_Object_create(null);
var requestedLocales = CanonicalizeLocaleList(locales);
lazySegmenterData.requestedLocales = requestedLocales;
if (options === undefined) {
options = std_Object_create(null);
} else if (!IsObject(options)) {
ThrowTypeError(
55,
options === null ? "null" : typeof options
);
}
var opt = new_Record();
lazySegmenterData.opt = opt;
var matcher = GetOption(
options,
"localeMatcher",
"string",
["lookup", "best fit"],
"best fit"
);
opt.localeMatcher = matcher;
var granularity = GetOption(
options,
"granularity",
"string",
["grapheme", "word", "sentence"],
"grapheme"
);
lazySegmenterData.granularity = granularity;
initializeIntlObject(segmenter, "Segmenter", lazySegmenterData);
}
function Intl_Segmenter_supportedLocalesOf(locales ) {
var options = ArgumentsLength() > 1 ? GetArgument(1) : undefined;
var availableLocales = "Segmenter";
var requestedLocales = CanonicalizeLocaleList(locales);
return SupportedLocales(availableLocales, requestedLocales, options);
}
function Intl_Segmenter_segment(value) {
var segmenter = this;
if (
!IsObject(segmenter) ||
(segmenter = intl_GuardToSegmenter(segmenter)) === null
) {
return callFunction(
intl_CallSegmenterMethodIfWrapped,
this,
value,
"Intl_Segmenter_segment"
);
}
getSegmenterInternals(segmenter);
var string = ToString(value);
return intl_CreateSegmentsObject(segmenter, string);
}
function Intl_Segmenter_resolvedOptions() {
var segmenter = this;
if (
!IsObject(segmenter) ||
(segmenter = intl_GuardToSegmenter(segmenter)) === null
) {
return callFunction(
intl_CallSegmenterMethodIfWrapped,
this,
"Intl_Segmenter_resolvedOptions"
);
}
var internals = getSegmenterInternals(segmenter);
var options = {
locale: internals.locale,
granularity: internals.granularity,
};
return options;
}
function CreateSegmentDataObject(string, boundaries) {
do { if (!(typeof string === "string")) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 250 + ": " + "CreateSegmentDataObject") } } while (false);
do { if (!(IsPackedArray(boundaries) && boundaries.length === 3)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 254 + ": " + "CreateSegmentDataObject") } } while (false);
var startIndex = boundaries[0];
do { if (!(typeof startIndex === "number" && (startIndex | 0) === startIndex)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 260 + ": " + "startIndex is an int32-value") } } while (false);
var endIndex = boundaries[1];
do { if (!(typeof endIndex === "number" && (endIndex | 0) === endIndex)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 266 + ": " + "endIndex is an int32-value") } } while (false);
var isWordLike = boundaries[2];
do { if (!(typeof isWordLike === "boolean" || isWordLike === undefined)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 273 + ": " + "isWordLike is either a boolean or undefined") } } while (false);
do { if (!(startIndex >= 0)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 278 + ": " + "startIndex is a positive number") } } while (false);
do { if (!(endIndex <= string.length)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 284 + ": " + "endIndex is less-than-equals the string length") } } while (false);
do { if (!(startIndex < endIndex)) { AssertionFailed("./../../checkouts/gecko/js/src/builtin/intl/Segmenter.js" + ":" + 287 + ": " + "startIndex is strictly less than endIndex") } } while (false);
var segment = Substring(string, startIndex, endIndex - startIndex);
if (isWordLike === undefined) {
return {
segment,
index: startIndex,
input: string,
};
}
return {
segment,
index: startIndex,
input: string,
isWordLike,
};
}
function Intl_Segments_containing(index) {
var segments = this;
if (
!IsObject(segments) ||
(segments = intl_GuardToSegments(segments)) === null
) {
return callFunction(
intl_CallSegmentsMethodIfWrapped,
this,
index,
"Intl_Segments_containing"
);
}
var string = UnsafeGetStringFromReservedSlot(
segments,
1
);
var len = string.length;
var n = ToInteger(index);
if (n < 0 || n >= len) {
return undefined;
}
var boundaries = intl_FindSegmentBoundaries(segments, n | 0);
return CreateSegmentDataObject(string, boundaries);
}
function Intl_Segments_iterator() {
var segments = this;
if (
!IsObject(segments) ||
(segments = intl_GuardToSegments(segments)) === null
) {
return callFunction(
intl_CallSegmentsMethodIfWrapped,
this,
"Intl_Segments_iterator"
);
}
return intl_CreateSegmentIterator(segments);
}
function Intl_SegmentIterator_next() {
var iterator = this;
if (
!IsObject(iterator) ||
(iterator = intl_GuardToSegmentIterator(iterator)) === null)
{
return callFunction(
intl_CallSegmentIteratorMethodIfWrapped,
this,
"Intl_SegmentIterator_next"
);
}
var string = UnsafeGetStringFromReservedSlot(
iterator,
1
);
var index = UnsafeGetInt32FromReservedSlot(
iterator,
3
);
var result = { value: undefined, done: false };
if (index === string.length) {
result.done = true;
return result;
}
var boundaries = intl_FindNextSegmentBoundaries(iterator);
result.value = CreateSegmentDataObject(string, boundaries);
return result;
}