Node updated. Some todos.

This commit is contained in:
Norm Rasmussen
2024-09-23 20:52:09 -04:00
parent 8bfaca8375
commit f25622067f
2041 changed files with 124145 additions and 110445 deletions

View File

@ -0,0 +1,24 @@
/**
* Copyright 2024 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Encodes a string to base64.
*
* Uses the native Web API if available, otherwise falls back to a NodeJS Buffer.
* @param {string} base64Str
* @return {string}
*/
export declare function base64ToString(base64Str: string): string;

View File

@ -0,0 +1,35 @@
"use strict";
/**
* Copyright 2024 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.base64ToString = base64ToString;
/**
* Encodes a string to base64.
*
* Uses the native Web API if available, otherwise falls back to a NodeJS Buffer.
* @param {string} base64Str
* @return {string}
*/
function base64ToString(base64Str) {
// Available only if run in a browser context.
if ('atob' in globalThis) {
return globalThis.atob(base64Str);
}
// Available only if run in a NodeJS context.
return Buffer.from(base64Str, 'base64').toString('ascii');
}
//# sourceMappingURL=Base64.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"Base64.js","sourceRoot":"","sources":["../../../src/utils/Base64.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AASH,wCAOC;AAdD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,SAAiB;IAC9C,8CAA8C;IAC9C,IAAI,MAAM,IAAI,UAAU,EAAE,CAAC;QACzB,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IACD,6CAA6C;IAC7C,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC5D,CAAC"}

View File

@ -17,6 +17,7 @@
export declare class Deferred<T> implements Promise<T> {
#private;
get isFinished(): boolean;
get result(): T;
constructor();
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
catch<TResult = never>(onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;

View File

@ -20,11 +20,18 @@ exports.Deferred = void 0;
class Deferred {
#isFinished = false;
#promise;
#result;
#resolve;
#reject;
get isFinished() {
return this.#isFinished;
}
get result() {
if (!this.#isFinished) {
throw new Error('Deferred is not finished yet');
}
return this.#result;
}
constructor() {
this.#promise = new Promise((resolve, reject) => {
this.#resolve = resolve;
@ -43,6 +50,7 @@ class Deferred {
return this.#promise.catch(onRejected);
}
resolve(value) {
this.#result = value;
if (!this.#isFinished) {
this.#isFinished = true;
this.#resolve(value);

View File

@ -1 +1 @@
{"version":3,"file":"Deferred.js","sourceRoot":"","sources":["../../../src/utils/Deferred.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,MAAa,QAAQ;IACnB,WAAW,GAAG,KAAK,CAAC;IACpB,QAAQ,CAAa;IACrB,QAAQ,CAAsB;IAC9B,OAAO,CAA6B;IAEpC,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;QACE,IAAI,CAAC,Q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AAI,CAAC,WAAW,GAAG,IAAI,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,SAA+B;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;IAED,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;CAClC;AA/DD,4BA+DC"}

View File

@ -0,0 +1,14 @@
/**
* Returns an array of distinct values. Order is not guaranteed.
* @param values - The values to filter. Should be JSON-serializable.
* @return - An array of distinct values.
*/
export declare function distinctValues<T>(values: T[]): T[];
/**
* Returns a stringified version of the object with keys sorted. This is required to
* ensure that the stringified version of an object is deterministic independent of the
* order of keys.
* @param obj
* @return {string}
*/
export declare function deterministicJSONStringify(obj: unknown): string;

View File

@ -0,0 +1,58 @@
"use strict";
/*
* Copyright 2024 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.distinctValues = distinctValues;
exports.deterministicJSONStringify = deterministicJSONStringify;
/**
* Returns an array of distinct values. Order is not guaranteed.
* @param values - The values to filter. Should be JSON-serializable.
* @return - An array of distinct values.
*/
function distinctValues(values) {
const map = new Map();
for (const value of values) {
map.set(deterministicJSONStringify(value), value);
}
return Array.from(map.values());
}
/**
* Returns a stringified version of the object with keys sorted. This is required to
* ensure that the stringified version of an object is deterministic independent of the
* order of keys.
* @param obj
* @return {string}
*/
function deterministicJSONStringify(obj) {
return JSON.stringify(normalizeObject(obj));
}
function normalizeObject(obj) {
if (obj === undefined ||
obj === null ||
Array.isArray(obj) ||
typeof obj !== 'object') {
return obj;
}
// Copy the original object key and values to a new object in sorted order.
const newObj = {};
for (const key of Object.keys(obj).sort()) {
const value = obj[key];
newObj[key] = normalizeObject(value); // Recursively sort nested objects
}
return newObj;
}
//# sourceMappingURL=DistinctValues.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"DistinctValues.js","sourceRoot":"","sources":["../../../src/utils/DistinctValues.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAOH,wCAMC;AASD,gEAEC;AAtBD;;;;GAIG;AACH,SAAgB,cAAc,CAAI,MAAW;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;IACjC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,GAAG,CAAC,GAAG,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,GAAY;IACrD,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,eAAe,CAAC,GAAQ;IAC/B,IACE,GAAG,KAAK,SAAS;QACjB,GAAG,KAAK,IAAI;QACZ,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAClB,OAAO,GAAG,KAAK,QAAQ,EACvB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,2EAA2E;IAC3E,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,kCAAkC;IAC1E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}

View File

@ -0,0 +1,9 @@
/**
* Check if the given string is a single complex grapheme. A complex grapheme is one that
* is made up of multiple characters.
*/
export declare function isSingleComplexGrapheme(value: string): boolean;
/**
* Check if the given string is a single grapheme.
*/
export declare function isSingleGrapheme(value: string): boolean;

View File

@ -0,0 +1,38 @@
"use strict";
/*
* Copyright 2024 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSingleComplexGrapheme = isSingleComplexGrapheme;
exports.isSingleGrapheme = isSingleGrapheme;
/**
* Check if the given string is a single complex grapheme. A complex grapheme is one that
* is made up of multiple characters.
*/
function isSingleComplexGrapheme(value) {
return isSingleGrapheme(value) && value.length > 1;
}
/**
* Check if the given string is a single grapheme.
*/
function isSingleGrapheme(value) {
// Theoretically there can be some strings considered a grapheme in some locales, like
// slovak "ch" digraph. Use english locale for consistency.
// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
return [...segmenter.segment(value)].length === 1;
}
//# sourceMappingURL=GraphemeTools.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"GraphemeTools.js","sourceRoot":"","sources":["../../../src/utils/GraphemeTools.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAMH,0DAEC;AAKD,4CAMC;AAjBD;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,KAAa;IACnD,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,sFAAsF;IACtF,2DAA2D;IAC3D,oEAAoE;IACpE,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAC,WAAW,EAAE,UAAU,EAAC,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACpD,CAAC"}

View File

@ -0,0 +1,24 @@
/**
* Copyright 2024 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Used as an alias to `UrlPattern.ts` to reduce the
* size of Chromium-BiDi when used the tab.
* See rollup.config.mjs
*/
import type UrlPatternTypes from 'urlpattern-polyfill/dist/types.js';
declare const URLPattern: typeof UrlPatternTypes.URLPattern;
export { URLPattern };

View File

@ -0,0 +1,26 @@
"use strict";
/**
* Copyright 2024 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.URLPattern = void 0;
const URLPattern = globalThis
.URLPattern;
exports.URLPattern = URLPattern;
if (!URLPattern) {
throw new Error('Unable to find URLPattern');
}
//# sourceMappingURL=UrlPattern-browser.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"UrlPattern-browser.js","sourceRoot":"","sources":["../../../src/utils/UrlPattern-browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AASH,MAAM,UAAU,GAAI,UAAkB;KACnC,UAA+C,CAAC;AAM3C,gCAAU;AAJlB,IAAI,CAAC,UAAU,EAAE,CAAC;IAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC"}

View File

@ -14,5 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { URLPattern } from 'urlpattern-polyfill';
import { URLPattern as URLPatternPolyfill } from 'urlpattern-polyfill';
declare let URLPattern: typeof URLPatternPolyfill;
export { URLPattern };

View File

@ -18,10 +18,12 @@ exports.URLPattern = void 0;
* limitations under the License.
*/
const urlpattern_polyfill_1 = require("urlpattern-polyfill");
Object.defineProperty(exports, "URLPattern", { enumerable: true, get: function () { return urlpattern_polyfill_1.URLPattern; } });
// XXX: Switch to native URLPattern when available.
// https://github.com/nodejs/node/issues/40844
let URLPattern = urlpattern_polyfill_1.URLPattern;
exports.URLPattern = URLPattern;
if ('URLPattern' in globalThis) {
urlpattern_polyfill_1.URLPattern = globalThis.URLPattern;
// eslint-disable-next-line no-global-assign
exports.URLPattern = URLPattern = globalThis.URLPattern;
}
//# sourceMappingURL=UrlPattern.js.map

View File

@ -1 +1 @@
{"version":3,"file":"UrlPattern.js","sourceRoot":"","sources":["../../../src/utils/UrlPattern.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,6DAA+C;AAQvC,2FARA,gCAAU,OAQA;AANlB,mDAAmD;AACnD,8CAA8C;AAC9C,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;IAC9B,gCAAkB,GAAI,UAAkB,CAAC,UAAU,CAAC;AACvD,CAAC"}
{"version":3,"file":"UrlPattern.js","sourceRoot":"","sources":["../../../src/utils/UrlPattern.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,6DAAqE;AACrE,mDAAmD;AACnD,8CAA8C;AAC9C,IAAI,UAAU,GAAG,gCAAkB,CAAC;AAO5B,gCAAU;AALlB,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;IAC/B,4CAA4C;IAC5C,qBAAA,UAAU,GAAI,UAAkB,CAAC,UAAU,CAAC;AAC9C,CAAC"}

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
exports.assert = assert;
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
@ -22,5 +22,4 @@ function assert(predicate, message) {
throw new Error(message ?? 'Internal assertion failed.');
}
}
exports.assert = assert;
//# sourceMappingURL=assert.js.map

View File

@ -1 +1 @@
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/utils/assert.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,MAAM,CAAI,SAAY,EAAE,OAAgB;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAJD,wBAIC"}
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../../src/utils/assert.ts"],"names":[],"mappings":";;AAgBA,wBAIC;AApBD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,MAAM,CAAI,SAAY,EAAE,OAAgB;IACtD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}

View File

@ -16,10 +16,9 @@
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.inchesFromCm = void 0;
exports.inchesFromCm = inchesFromCm;
/** @return Given an input in cm, convert it to inches. */
function inchesFromCm(cm) {
return cm / 2.54;
}
exports.inchesFromCm = inchesFromCm;
//# sourceMappingURL=unitConversions.js.map

View File

@ -1 +1 @@
{"version":3,"file":"unitConversions.js","sourceRoot":"","sources":["../../../src/utils/unitConversions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,0DAA0D;AAC1D,SAAgB,YAAY,CAAC,EAAU;IACrC,OAAO,EAAE,GAAG,IAAI,CAAC;AACnB,CAAC;AAFD,oCAEC"}
{"version":3,"file":"unitConversions.js","sourceRoot":"","sources":["../../../src/utils/unitConversions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;AAGH,oCAEC;AAHD,0DAA0D;AAC1D,SAAgB,YAAY,CAAC,EAAU;IACrC,OAAO,EAAE,GAAG,IAAI,CAAC;AACnB,CAAC"}

View File

@ -16,7 +16,10 @@
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidv4 = void 0;
exports.uuidv4 = uuidv4;
function bytesToHex(bytes) {
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
}
/**
* Generates a random v4 UUID, as specified in RFC4122.
*
@ -36,21 +39,20 @@ function uuidv4() {
}
const randomValues = new Uint8Array(16);
if ('crypto' in globalThis && 'getRandomValues' in globalThis.crypto) {
// Node with
// Node (>=18) with
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1 or
// browser.
globalThis.crypto.getRandomValues(randomValues);
}
else {
// Node without
// Node (<=16) without
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1.
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports
require('crypto').webcrypto.getRandomValues(randomValues);
}
// Set version (4) and variant (RFC4122) bits.
randomValues[6] = (randomValues[6] & 0x0f) | 0x40;
randomValues[8] = (randomValues[8] & 0x3f) | 0x80;
const bytesToHex = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');
return [
bytesToHex(randomValues.subarray(0, 4)),
bytesToHex(randomValues.subarray(4, 6)),
@ -59,5 +61,4 @@ function uuidv4() {
bytesToHex(randomValues.subarray(10, 16)),
].join('-');
}
exports.uuidv4 = uuidv4;
//# sourceMappingURL=uuid.js.map

View File

@ -1 +1 @@
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../src/utils/uuid.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;;;;;GAOG;AACH,SAAgB,MAAM;IACpB,oCAAoC;IACpC,kEAAkE;IAClE,IAAI,QAAQ,IAAI,UAAU,IAAI,YAAY,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QAChE,YAAY;QACZ,yEAAyE;QACzE,0BAA0B;QAC1B,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAExC,IAAI,QAAQ,IAAI,UAAU,IAAI,iBAAiB,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACrE,YAAY;QACZ,yEAAyE;QACzE,WAAW;QACX,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,eAAe;QACf,uEAAuE;QACvE,8DAA8D;QAC9D,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;IAC5D,CAAC;IAED,8CAA8C;IAC9C,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACnD,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAE,GAAG,IAAI,CAAC,GAAG,I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