@bboss/uuid32 1.0.0 โ 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +7 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +26 -12
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# @bboss/uuid32
|
|
2
2
|
|
|
3
|
-
A lightweight TypeScript library for encoding and decoding UUIDs to/from Crockford Base32 strings
|
|
3
|
+
A lightweight TypeScript library for encoding and decoding UUIDs to/from Crockford Base32 strings.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- ๐ **Fast & Lightweight**: Zero dependencies, optimized for performance
|
|
8
|
-
-
|
|
8
|
+
- ๐ **Universal**: Works in Node.js and modern browsers
|
|
9
9
|
- ๐ฆ **TypeScript Native**: Full TypeScript support with type definitions
|
|
10
10
|
- ๐งช **Well Tested**: Comprehensive test suite with high coverage
|
|
11
11
|
- ๐ง **Simple API**: Easy-to-use functions for encoding, decoding, and validation
|
|
12
|
-
- ๐ก๏ธ **User-Friendly**:
|
|
12
|
+
- ๐ก๏ธ **User-Friendly**: Case-insensitive with automatic correction of confusable characters
|
|
13
|
+
- โจ **Crockford Standard**: Full compliance with Crockford Base32 specification
|
|
13
14
|
|
|
14
15
|
## Use Cases
|
|
15
16
|
|
|
@@ -30,8 +31,7 @@ yarn add @bboss/uuid32
|
|
|
30
31
|
|
|
31
32
|
## Requirements
|
|
32
33
|
|
|
33
|
-
-
|
|
34
|
-
- **Node.js only** - not compatible with browser environments
|
|
34
|
+
- Requires an environment with `crypto.randomUUID()` support (e.g., Node.js 16+ or modern browsers).
|
|
35
35
|
|
|
36
36
|
## Usage
|
|
37
37
|
|
|
@@ -51,8 +51,17 @@ console.log(encoded); // โ "29STNWYQG28H4VWA59PD0XYJR8"
|
|
|
51
51
|
const decoded = uuid32.decode('29STNWYQG28H4VWA59PD0XYJR8');
|
|
52
52
|
console.log(decoded); // โ "49ceabcf-5e02-4449-be28-a9b341df4b08"
|
|
53
53
|
|
|
54
|
+
// Case-insensitive decoding (NEW in v1.2.0)
|
|
55
|
+
uuid32.decode('29stnwyqg28h4vwa59pd0xyjr8'); // โ
Works (lowercase)
|
|
56
|
+
uuid32.decode('29StNwYqG28h4VwA59Pd0XyJr8'); // โ
Works (mixed case)
|
|
57
|
+
|
|
58
|
+
// Auto-correction of confusable characters (NEW in v1.2.0)
|
|
59
|
+
uuid32.decode('29STNWYQG28H4VWA59PD0XYJRl'); // โ
'l' โ '1' auto-corrected
|
|
60
|
+
uuid32.decode('2OSTNWYQG28H4VWA59PD0XYJR8'); // โ
'O' โ '0' auto-corrected
|
|
61
|
+
|
|
54
62
|
// Validation
|
|
55
63
|
console.log(uuid32.isValidBase32('29STNWYQG28H4VWA59PD0XYJR8')); // โ true
|
|
64
|
+
console.log(uuid32.isValidBase32('abc123')); // โ true (accepts lowercase)
|
|
56
65
|
```
|
|
57
66
|
|
|
58
67
|
## API Reference
|
|
@@ -75,8 +84,14 @@ Encodes a standard UUID to Crockford Base32 format.
|
|
|
75
84
|
### `decode(base32: string): string`
|
|
76
85
|
Decodes a Crockford Base32 string back to standard UUID format.
|
|
77
86
|
|
|
87
|
+
Supports case-insensitive input and automatically corrects confusable characters according to the Crockford Base32 standard:
|
|
88
|
+
- Case-insensitive: `ABC` and `abc` are treated the same
|
|
89
|
+
- `I` or `i` โ `1`
|
|
90
|
+
- `L` or `l` โ `1`
|
|
91
|
+
- `O` or `o` โ `0`
|
|
92
|
+
|
|
78
93
|
**Parameters:**
|
|
79
|
-
- `base32` - Base32 encoded string
|
|
94
|
+
- `base32` - Base32 encoded string (case-insensitive)
|
|
80
95
|
|
|
81
96
|
**Returns:** Standard UUID string with hyphens
|
|
82
97
|
|
|
@@ -85,8 +100,10 @@ Decodes a Crockford Base32 string back to standard UUID format.
|
|
|
85
100
|
### `isValidBase32(str: string): boolean`
|
|
86
101
|
Validates if a string is a valid Crockford Base32 format.
|
|
87
102
|
|
|
103
|
+
Accepts both uppercase and lowercase characters, as well as confusable characters that can be auto-corrected.
|
|
104
|
+
|
|
88
105
|
**Parameters:**
|
|
89
|
-
- `str` - String to validate
|
|
106
|
+
- `str` - String to validate (case-insensitive)
|
|
90
107
|
|
|
91
108
|
**Returns:** `true` if valid Base32, `false` otherwise
|
|
92
109
|
|
|
@@ -112,13 +129,21 @@ try {
|
|
|
112
129
|
|
|
113
130
|
Uses the following 32 characters: `0123456789ABCDEFGHJKMNPQRSTVWXYZ`
|
|
114
131
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- `L` (
|
|
118
|
-
- `
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
### Encoding
|
|
133
|
+
Encoded strings will only contain valid Base32 characters, excluding confusable ones:
|
|
134
|
+
- **Excluded:** `I`, `L`, `O`, `U` (never appear in encoded output)
|
|
135
|
+
- **Used:** `0-9`, `A-H`, `J`, `K`, `M`, `N`, `P-Z`
|
|
136
|
+
|
|
137
|
+
### Decoding (Flexible Input)
|
|
138
|
+
Supports case-insensitive decoding and automatic correction of confusable characters:
|
|
139
|
+
- **Case-insensitive:** `ABC` = `abc` = `AbC`
|
|
140
|
+
- **Auto-correction:**
|
|
141
|
+
- `I` or `i` โ `1`
|
|
142
|
+
- `L` or `l` โ `1`
|
|
143
|
+
- `O` or `o` โ `0`
|
|
144
|
+
- `U` remains as `U` (not confusable in this context)
|
|
145
|
+
|
|
146
|
+
This flexible decoding makes the library more user-friendly for manual input scenarios like product keys and API keys, while maintaining full compliance with the Crockford Base32 specification.
|
|
122
147
|
|
|
123
148
|
## License
|
|
124
149
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { isValidBase32 } from './utils';
|
|
|
5
5
|
export declare function encode(uuid: string): string;
|
|
6
6
|
/**
|
|
7
7
|
* Decodes a Crockford Base32 string to UUID
|
|
8
|
+
* Supports case-insensitive input and automatic correction of confusable characters
|
|
8
9
|
*/
|
|
9
10
|
export declare function decode(base32: string): string;
|
|
10
11
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,aAAa,EAIhB,MAAM,SAAS,CAAC;AA2BjB;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB3C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA0B7C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAGvC;AAGD,OAAO,EAAE,aAAa,EAAE,CAAC;;;;;;;AAGzB,wBAKE"}
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,30 @@ exports.isValidBase32 = void 0;
|
|
|
4
4
|
exports.encode = encode;
|
|
5
5
|
exports.decode = decode;
|
|
6
6
|
exports.generateBase32 = generateBase32;
|
|
7
|
-
const crypto_1 = require("crypto");
|
|
8
7
|
const utils_1 = require("./utils");
|
|
9
8
|
Object.defineProperty(exports, "isValidBase32", { enumerable: true, get: function () { return utils_1.isValidBase32; } });
|
|
10
|
-
|
|
11
|
-
(
|
|
9
|
+
/**
|
|
10
|
+
* Gets randomUUID function based on environment (Node.js or browser)
|
|
11
|
+
*/
|
|
12
|
+
function getRandomUUID() {
|
|
13
|
+
// Modern browsers and Node.js 19+ support globalThis.crypto.randomUUID
|
|
14
|
+
if (typeof globalThis.crypto?.randomUUID === 'function') {
|
|
15
|
+
return globalThis.crypto.randomUUID();
|
|
16
|
+
}
|
|
17
|
+
// Node.js < 19 fallback - use require to avoid bundler issues
|
|
18
|
+
if (typeof require !== 'undefined') {
|
|
19
|
+
try {
|
|
20
|
+
const crypto = require('crypto');
|
|
21
|
+
if (typeof crypto.randomUUID === 'function') {
|
|
22
|
+
return crypto.randomUUID();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
// crypto module not available
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw new Error('crypto.randomUUID is not available in this environment');
|
|
30
|
+
}
|
|
12
31
|
/**
|
|
13
32
|
* Encodes a UUID to Crockford Base32 string
|
|
14
33
|
*/
|
|
@@ -30,14 +49,17 @@ function encode(uuid) {
|
|
|
30
49
|
}
|
|
31
50
|
/**
|
|
32
51
|
* Decodes a Crockford Base32 string to UUID
|
|
52
|
+
* Supports case-insensitive input and automatic correction of confusable characters
|
|
33
53
|
*/
|
|
34
54
|
function decode(base32) {
|
|
35
55
|
if (!(0, utils_1.isValidBase32)(base32)) {
|
|
36
56
|
throw new Error('Invalid Base32 format');
|
|
37
57
|
}
|
|
58
|
+
// Normalize input according to Crockford Base32 standard
|
|
59
|
+
const normalized = (0, utils_1.normalizeBase32)(base32);
|
|
38
60
|
let num = 0n;
|
|
39
|
-
for (let i = 0; i <
|
|
40
|
-
const char =
|
|
61
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
62
|
+
const char = normalized[i];
|
|
41
63
|
const index = utils_1.BASE32_CHARS.indexOf(char);
|
|
42
64
|
if (index === -1) {
|
|
43
65
|
throw new Error('Invalid Base32 character');
|
|
@@ -54,7 +76,7 @@ function decode(base32) {
|
|
|
54
76
|
* Generates a new UUID v4 and encodes it to Crockford Base32
|
|
55
77
|
*/
|
|
56
78
|
function generateBase32() {
|
|
57
|
-
const uuid = (
|
|
79
|
+
const uuid = getRandomUUID();
|
|
58
80
|
return encode(uuid);
|
|
59
81
|
}
|
|
60
82
|
// Default export for CommonJS compatibility
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAqCA,wBAmBC;AAMD,wBA0BC;AAKD,wCAGC;AAhGD,mCAOiB;AA4FR,8FAhGL,qBAAa,OAgGK;AA1FtB;;GAEG;AACH,SAAS,aAAa;IAClB,uEAAuE;IACvE,IAAI,OAAO,UAAU,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,EAAE,CAAC;QACtD,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1C,CAAC;IAED,8DAA8D;IAC9D,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QACjC,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAC1C,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;YAC/B,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,8BAA8B;QAClC,CAAC;IACL,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;AAC9E,CAAC;AAGD;;GAEG;AACH,SAAgB,MAAM,CAAC,IAAY;IAC/B,IAAI,CAAC,IAAA,mBAAW,EAAC,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC;IAEtC,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG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KAAK,CAAC,0CAA0C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAA,kBAAU,EAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc;IAC1B,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAKD,4CAA4C;AAC5C,kBAAe;IACX,cAAc;IACd,MAAM;IACN,MAAM;IACN,aAAa,EAAb,qBAAa;CAChB,CAAC"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -6,8 +6,15 @@ export declare const BASE32_CHARS = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
|
6
6
|
* Validates if a string is a valid UUID format
|
|
7
7
|
*/
|
|
8
8
|
export declare function isValidUuid(str: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes a Crockford Base32 string according to the standard:
|
|
11
|
+
* - Converts to uppercase
|
|
12
|
+
* - Replaces confusable characters: I/i/L/l โ 1, O/o โ 0
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeBase32(str: string): string;
|
|
9
15
|
/**
|
|
10
16
|
* Validates if a string is a valid Crockford Base32 format
|
|
17
|
+
* Accepts both strict format and inputs with confusable characters
|
|
11
18
|
*/
|
|
12
19
|
export declare function isValidBase32(str: string): boolean;
|
|
13
20
|
/**
|
|
@@ -18,8 +25,4 @@ export declare function normalizeUuid(uuid: string): string;
|
|
|
18
25
|
* Formats UUID by adding hyphens
|
|
19
26
|
*/
|
|
20
27
|
export declare function formatUuid(uuid: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Checks if running in browser environment
|
|
23
|
-
*/
|
|
24
|
-
export declare function checkNodeEnvironment(): void;
|
|
25
28
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY,qCAAqC,CAAC;AAkB/D;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGhD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CASlD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
package/dist/utils.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BASE32_CHARS = void 0;
|
|
4
4
|
exports.isValidUuid = isValidUuid;
|
|
5
|
+
exports.normalizeBase32 = normalizeBase32;
|
|
5
6
|
exports.isValidBase32 = isValidBase32;
|
|
6
7
|
exports.normalizeUuid = normalizeUuid;
|
|
7
8
|
exports.formatUuid = formatUuid;
|
|
8
|
-
exports.checkNodeEnvironment = checkNodeEnvironment;
|
|
9
9
|
/**
|
|
10
10
|
* Crockford Base32 character set (excludes I, L, O, U to avoid confusion)
|
|
11
11
|
*/
|
|
@@ -15,9 +15,14 @@ exports.BASE32_CHARS = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
|
15
15
|
*/
|
|
16
16
|
const UUID_REGEX = /^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$/i;
|
|
17
17
|
/**
|
|
18
|
-
* Crockford Base32 validation regex
|
|
18
|
+
* Crockford Base32 validation regex (after normalization)
|
|
19
19
|
*/
|
|
20
20
|
const BASE32_REGEX = /^[0-9ABCDEFGHJKMNPQRSTVWXYZ]+$/;
|
|
21
|
+
/**
|
|
22
|
+
* Crockford Base32 input validation regex (before normalization)
|
|
23
|
+
* Allows lowercase and confusable characters (I, L, O, i, l, o)
|
|
24
|
+
*/
|
|
25
|
+
const BASE32_INPUT_REGEX = /^[0-9A-Za-z]+$/;
|
|
21
26
|
/**
|
|
22
27
|
* Validates if a string is a valid UUID format
|
|
23
28
|
*/
|
|
@@ -26,13 +31,30 @@ function isValidUuid(str) {
|
|
|
26
31
|
return false;
|
|
27
32
|
return UUID_REGEX.test(str);
|
|
28
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes a Crockford Base32 string according to the standard:
|
|
36
|
+
* - Converts to uppercase
|
|
37
|
+
* - Replaces confusable characters: I/i/L/l โ 1, O/o โ 0
|
|
38
|
+
*/
|
|
39
|
+
function normalizeBase32(str) {
|
|
40
|
+
return str
|
|
41
|
+
.toUpperCase()
|
|
42
|
+
.replace(/[IL]/g, '1')
|
|
43
|
+
.replace(/O/g, '0');
|
|
44
|
+
}
|
|
29
45
|
/**
|
|
30
46
|
* Validates if a string is a valid Crockford Base32 format
|
|
47
|
+
* Accepts both strict format and inputs with confusable characters
|
|
31
48
|
*/
|
|
32
49
|
function isValidBase32(str) {
|
|
33
|
-
if (typeof str !== 'string')
|
|
50
|
+
if (typeof str !== 'string' || str.length === 0)
|
|
51
|
+
return false;
|
|
52
|
+
// Check if input contains only valid Base32 characters (including confusable ones)
|
|
53
|
+
if (!BASE32_INPUT_REGEX.test(str))
|
|
34
54
|
return false;
|
|
35
|
-
|
|
55
|
+
// Normalize and check if result is valid Base32
|
|
56
|
+
const normalized = normalizeBase32(str);
|
|
57
|
+
return BASE32_REGEX.test(normalized);
|
|
36
58
|
}
|
|
37
59
|
/**
|
|
38
60
|
* Normalizes UUID by removing hyphens
|
|
@@ -46,12 +68,4 @@ function normalizeUuid(uuid) {
|
|
|
46
68
|
function formatUuid(uuid) {
|
|
47
69
|
return `${uuid.slice(0, 8)}-${uuid.slice(8, 12)}-${uuid.slice(12, 16)}-${uuid.slice(16, 20)}-${uuid.slice(20, 32)}`;
|
|
48
70
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Checks if running in browser environment
|
|
51
|
-
*/
|
|
52
|
-
function checkNodeEnvironment() {
|
|
53
|
-
if (typeof globalThis.window !== 'undefined' || typeof globalThis.document !== 'undefined') {
|
|
54
|
-
throw new Error('@bboss/uuid32 is Node.js only and cannot run in browser environments');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
71
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAwBA,kCAGC;AAOD,0CAKC;AAMD,sCASC;AAKD,sCAEC;AAKD,gCAEC;AApED;;GAEG;AACU,QAAA,YAAY,GAAG,kCAAkC,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,GAAG,qEAAqE,CAAC;AAEzF;;GAEG;AACH,MAAM,YAAY,GAAG,gCAAgC,CAAC;AAEtD;;;GAGG;AACH,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAE5C;;GAEG;AACH,SAAgB,WAAW,CAAC,GAAW;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAW;IACvC,OAAO,GAAG;SACL,WAAW,EAAE;SACb,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,G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