@hashgraphonline/standards-sdk 0.1.141-canary.8 → 0.1.141-canary.9
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/dist/cjs/services/registry-broker/schemas.d.ts +22 -22
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +22 -22
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/standards-sdk.es101.js +1 -1
- package/dist/es/standards-sdk.es103.js +1 -1
- package/dist/es/standards-sdk.es109.js +1 -1
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es124.js +1 -1
- package/dist/es/standards-sdk.es125.js +1 -1
- package/dist/es/standards-sdk.es127.js +1 -1
- package/dist/es/standards-sdk.es13.js +1 -1
- package/dist/es/standards-sdk.es135.js +138 -760
- package/dist/es/standards-sdk.es135.js.map +1 -1
- package/dist/es/standards-sdk.es136.js +34 -12266
- package/dist/es/standards-sdk.es136.js.map +1 -1
- package/dist/es/standards-sdk.es137.js +50 -132
- package/dist/es/standards-sdk.es137.js.map +1 -1
- package/dist/es/standards-sdk.es138.js +58 -36
- package/dist/es/standards-sdk.es138.js.map +1 -1
- package/dist/es/standards-sdk.es139.js +766 -56
- package/dist/es/standards-sdk.es139.js.map +1 -1
- package/dist/es/standards-sdk.es140.js +12254 -44
- package/dist/es/standards-sdk.es140.js.map +1 -1
- package/dist/es/standards-sdk.es17.js +1 -1
- package/dist/es/standards-sdk.es19.js +4 -4
- package/dist/es/standards-sdk.es20.js +2 -2
- package/dist/es/standards-sdk.es23.js +1 -1
- package/dist/es/standards-sdk.es28.js +3 -3
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es32.js +1 -1
- package/dist/es/standards-sdk.es36.js +2 -2
- package/dist/es/standards-sdk.es37.js +3 -3
- package/dist/es/standards-sdk.es38.js +1 -1
- package/dist/es/standards-sdk.es5.js +1 -1
- package/dist/es/standards-sdk.es54.js +1 -1
- package/dist/es/standards-sdk.es57.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es61.js +2 -2
- package/dist/es/standards-sdk.es63.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es69.js +2 -2
- package/dist/es/standards-sdk.es70.js +1 -1
- package/dist/es/standards-sdk.es72.js +1 -1
- package/dist/es/standards-sdk.es77.js +1 -1
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es79.js +1 -1
- package/dist/es/standards-sdk.es8.js +1 -1
- package/dist/es/standards-sdk.es82.js +1 -1
- package/dist/es/standards-sdk.es84.js +1 -1
- package/dist/es/standards-sdk.es87.js +1 -1
- package/dist/es/standards-sdk.es91.js +1 -1
- package/dist/es/standards-sdk.es92.js +1 -1
- package/dist/es/standards-sdk.es97.js +1 -1
- package/dist/es/standards-sdk.es99.js +1 -1
- package/package.json +1 -1
|
@@ -1,141 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const pk = explicitType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
|
|
20
|
-
return { keyType: explicitType, privateKey: pk };
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const detected = detectKeyTypeFromString(operatorKeyInput);
|
|
24
|
-
return {
|
|
25
|
-
keyType: detected.detectedType,
|
|
26
|
-
privateKey: detected.privateKey
|
|
27
|
-
};
|
|
28
|
-
} catch {
|
|
29
|
-
return {
|
|
30
|
-
keyType: "ecdsa",
|
|
31
|
-
privateKey: PrivateKey.fromStringECDSA(operatorKeyInput)
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Resolve an operator key using Mirror Node for key type when possible.
|
|
37
|
-
* - If PrivateKey: return immediately.
|
|
38
|
-
* - If explicitType: parse directly.
|
|
39
|
-
* - Else: query Mirror Node; fallback to local detection.
|
|
40
|
-
*/
|
|
41
|
-
async resolveOperatorKey(operatorId, operatorKeyInput, explicitType) {
|
|
42
|
-
if (typeof operatorKeyInput !== "string") {
|
|
43
|
-
return { keyType: explicitType || "ecdsa", privateKey: operatorKeyInput };
|
|
44
|
-
}
|
|
45
|
-
if (explicitType) {
|
|
46
|
-
const pk = explicitType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
|
|
47
|
-
return { keyType: explicitType, privateKey: pk };
|
|
48
|
-
}
|
|
49
|
-
const account = typeof operatorId === "string" ? operatorId : operatorId.toString();
|
|
50
|
-
try {
|
|
51
|
-
const info = await this.mirror.requestAccount(account);
|
|
52
|
-
const t = info?.key?._type || "";
|
|
53
|
-
const keyType = t.includes("ED25519") ? "ed25519" : "ecdsa";
|
|
54
|
-
const privateKey = keyType === "ed25519" ? PrivateKey.fromStringED25519(operatorKeyInput) : PrivateKey.fromStringECDSA(operatorKeyInput);
|
|
55
|
-
return { keyType, privateKey };
|
|
56
|
-
} catch {
|
|
57
|
-
this.logger.warn(
|
|
58
|
-
"Mirror node key detection failed; using local detection or default ECDSA"
|
|
59
|
-
);
|
|
60
|
-
return this.bestGuessOperatorKey(operatorKeyInput);
|
|
1
|
+
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
2
|
+
const BASE = 58;
|
|
3
|
+
function base58Encode(bytes) {
|
|
4
|
+
if (bytes.length === 0) return "";
|
|
5
|
+
let zeros = 0;
|
|
6
|
+
while (zeros < bytes.length && bytes[zeros] === 0) zeros++;
|
|
7
|
+
if (zeros === bytes.length) return "1".repeat(zeros);
|
|
8
|
+
const digits = [0];
|
|
9
|
+
for (let i = zeros; i < bytes.length; i++) {
|
|
10
|
+
let carry = bytes[i];
|
|
11
|
+
for (let j = 0; j < digits.length; j++) {
|
|
12
|
+
const val = (digits[j] << 8) + carry;
|
|
13
|
+
digits[j] = val % BASE;
|
|
14
|
+
carry = val / BASE | 0;
|
|
15
|
+
}
|
|
16
|
+
while (carry > 0) {
|
|
17
|
+
digits.push(carry % BASE);
|
|
18
|
+
carry = carry / BASE | 0;
|
|
61
19
|
}
|
|
62
20
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
if (explicitType) {
|
|
88
|
-
return explicitType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
|
|
89
|
-
}
|
|
90
|
-
return fallbackType === "ed25519" ? PrivateKey.fromStringED25519(keyInput) : PrivateKey.fromStringECDSA(keyInput);
|
|
21
|
+
let result = "";
|
|
22
|
+
for (let i = 0; i < zeros; i++) result += "1";
|
|
23
|
+
for (let i = digits.length - 1; i >= 0; i--) result += ALPHABET[digits[i]];
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
function base58Decode(text) {
|
|
27
|
+
if (text.length === 0) return new Uint8Array(0);
|
|
28
|
+
let zeros = 0;
|
|
29
|
+
while (zeros < text.length && text[zeros] === "1") zeros++;
|
|
30
|
+
const b256 = [];
|
|
31
|
+
for (let i = zeros; i < text.length; i++) {
|
|
32
|
+
const ch = text[i];
|
|
33
|
+
const val = ALPHABET.indexOf(ch);
|
|
34
|
+
if (val === -1) throw new Error("Invalid Base58 character");
|
|
35
|
+
let carry = val;
|
|
36
|
+
for (let j = 0; j < b256.length; j++) {
|
|
37
|
+
const x = b256[j] * BASE + carry;
|
|
38
|
+
b256[j] = x & 255;
|
|
39
|
+
carry = x >> 8;
|
|
40
|
+
}
|
|
41
|
+
while (carry > 0) {
|
|
42
|
+
b256.push(carry & 255);
|
|
43
|
+
carry >>= 8;
|
|
91
44
|
}
|
|
92
45
|
}
|
|
46
|
+
for (let i = 0; i < zeros; i++) b256.push(0);
|
|
47
|
+
b256.reverse();
|
|
48
|
+
return Uint8Array.from(b256);
|
|
93
49
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const resolver = new NodeOperatorResolver({
|
|
98
|
-
mirrorNode: params.mirrorNode,
|
|
99
|
-
logger: params.logger
|
|
100
|
-
});
|
|
101
|
-
let currentKeyType;
|
|
102
|
-
let currentPrivateKey;
|
|
103
|
-
const guess = resolver.bestGuessOperatorKey(
|
|
104
|
-
params.operatorKey,
|
|
105
|
-
params.keyType
|
|
106
|
-
);
|
|
107
|
-
currentKeyType = guess.keyType;
|
|
108
|
-
currentPrivateKey = guess.privateKey;
|
|
109
|
-
client.setOperator(operatorId.toString(), currentPrivateKey);
|
|
110
|
-
const initPromise = (async () => {
|
|
111
|
-
try {
|
|
112
|
-
const resolved = await resolver.resolveOperatorKey(
|
|
113
|
-
operatorId,
|
|
114
|
-
params.operatorKey,
|
|
115
|
-
params.keyType
|
|
116
|
-
);
|
|
117
|
-
currentKeyType = resolved.keyType;
|
|
118
|
-
currentPrivateKey = resolved.privateKey;
|
|
119
|
-
client.setOperator(operatorId.toString(), currentPrivateKey);
|
|
120
|
-
} catch {
|
|
121
|
-
}
|
|
122
|
-
})();
|
|
123
|
-
return {
|
|
124
|
-
client,
|
|
125
|
-
operatorId,
|
|
126
|
-
get operatorKey() {
|
|
127
|
-
return currentPrivateKey;
|
|
128
|
-
},
|
|
129
|
-
get keyType() {
|
|
130
|
-
return currentKeyType;
|
|
131
|
-
},
|
|
132
|
-
ensureInitialized: async () => {
|
|
133
|
-
await initPromise;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
50
|
+
function multibaseB58btcDecode(zText) {
|
|
51
|
+
if (!zText.startsWith("z")) throw new Error("Invalid multibase base58btc");
|
|
52
|
+
return base58Decode(zText.slice(1));
|
|
136
53
|
}
|
|
137
54
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
55
|
+
base58Decode,
|
|
56
|
+
base58Encode,
|
|
57
|
+
multibaseB58btcDecode
|
|
140
58
|
};
|
|
141
59
|
//# sourceMappingURL=standards-sdk.es137.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es137.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es137.js","sources":["../../src/hcs-14/base58.ts"],"sourcesContent":["/**\n * Minimal Base58 encoder/decoder (Bitcoin alphabet) with no external dependencies.\n */\n\nconst ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nconst BASE = 58;\n\nfunction countLeadingZeros(bytes: Uint8Array): number {\n let zeros = 0;\n for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {\n zeros++;\n }\n return zeros;\n}\n\nexport function base58Encode(bytes: Uint8Array): string {\n if (bytes.length === 0) return '';\n\n let zeros = 0;\n while (zeros < bytes.length && bytes[zeros] === 0) zeros++;\n\n if (zeros === bytes.length) return '1'.repeat(zeros);\n\n const digits: number[] = [0];\n for (let i = zeros; i < bytes.length; i++) {\n let carry = bytes[i];\n for (let j = 0; j < digits.length; j++) {\n const val = (digits[j] << 8) + carry;\n digits[j] = val % BASE;\n carry = (val / BASE) | 0;\n }\n while (carry > 0) {\n digits.push(carry % BASE);\n carry = (carry / BASE) | 0;\n }\n }\n\n let result = '';\n for (let i = 0; i < zeros; i++) result += '1';\n for (let i = digits.length - 1; i >= 0; i--) result += ALPHABET[digits[i]];\n return result;\n}\n\nexport function base58Decode(text: string): Uint8Array {\n if (text.length === 0) return new Uint8Array(0);\n\n let zeros = 0;\n while (zeros < text.length && text[zeros] === '1') zeros++;\n\n const b256: number[] = [];\n for (let i = zeros; i < text.length; i++) {\n const ch = text[i];\n const val = ALPHABET.indexOf(ch);\n if (val === -1) throw new Error('Invalid Base58 character');\n\n let carry = val;\n for (let j = 0; j < b256.length; j++) {\n const x = b256[j] * BASE + carry;\n b256[j] = x & 0xff;\n carry = x >> 8;\n }\n while (carry > 0) {\n b256.push(carry & 0xff);\n carry >>= 8;\n }\n }\n\n for (let i = 0; i < zeros; i++) b256.push(0);\n b256.reverse();\n return Uint8Array.from(b256);\n}\n\nexport function multibaseB58btcDecode(zText: string): Uint8Array {\n if (!zText.startsWith('z')) throw new Error('Invalid multibase base58btc');\n return base58Decode(zText.slice(1));\n}\n"],"names":[],"mappings":"AAIA,MAAM,WAAW;AACjB,MAAM,OAAO;AAUN,SAAS,aAAa,OAA2B;AACtD,MAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,MAAI,QAAQ;AACZ,SAAO,QAAQ,MAAM,UAAU,MAAM,KAAK,MAAM,EAAG;AAEnD,MAAI,UAAU,MAAM,OAAQ,QAAO,IAAI,OAAO,KAAK;AAEnD,QAAM,SAAmB,CAAC,CAAC;AAC3B,WAAS,IAAI,OAAO,IAAI,MAAM,QAAQ,KAAK;AACzC,QAAI,QAAQ,MAAM,CAAC;AACnB,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,YAAM,OAAO,OAAO,CAAC,KAAK,KAAK;AAC/B,aAAO,CAAC,IAAI,MAAM;AAClB,cAAS,MAAM,OAAQ;AAAA,IACzB;AACA,WAAO,QAAQ,GAAG;AAChB,aAAO,KAAK,QAAQ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-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} catch {
|
|
18
|
-
return void 0;
|
|
19
|
-
}
|
|
1
|
+
import { isBrowser } from "./standards-sdk.es118.js";
|
|
2
|
+
let nodeRequire;
|
|
3
|
+
function isModuleNotFound(specifier, error) {
|
|
4
|
+
if (!error || typeof error !== "object") {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const code = Reflect.get(error, "code");
|
|
8
|
+
const message = Reflect.get(error, "message");
|
|
9
|
+
const messageText = typeof message === "string" ? message : "";
|
|
10
|
+
if (typeof code === "string" && code.includes("MODULE_NOT_FOUND")) {
|
|
11
|
+
return messageText.includes(specifier);
|
|
12
|
+
}
|
|
13
|
+
if (messageText) {
|
|
14
|
+
const lowered = messageText.toLowerCase();
|
|
15
|
+
if (lowered.includes("cannot find module") || lowered.includes("module not found") || lowered.includes("cannot find package")) {
|
|
16
|
+
return lowered.includes(specifier.toLowerCase());
|
|
20
17
|
}
|
|
21
|
-
return void 0;
|
|
22
|
-
};
|
|
23
|
-
const admin = coerceKey(adminKey);
|
|
24
|
-
if (admin) {
|
|
25
|
-
tx.setAdminKey(admin);
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
async function resolveNodeRequire() {
|
|
22
|
+
if (nodeRequire !== void 0) {
|
|
23
|
+
return nodeRequire;
|
|
24
|
+
}
|
|
25
|
+
if (isBrowser) {
|
|
26
|
+
nodeRequire = null;
|
|
27
|
+
return nodeRequire;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const globalObject = typeof global !== "undefined" ? global : globalThis;
|
|
31
|
+
const req = globalObject.process?.mainModule?.require ?? globalObject.require;
|
|
32
|
+
nodeRequire = typeof req === "function" && typeof req.resolve === "function" ? req : null;
|
|
33
|
+
} catch {
|
|
34
|
+
nodeRequire = null;
|
|
35
|
+
}
|
|
36
|
+
return nodeRequire;
|
|
37
|
+
}
|
|
38
|
+
async function dynamicImport(specifier) {
|
|
39
|
+
try {
|
|
40
|
+
return await import(specifier);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (isModuleNotFound(specifier, error)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
30
46
|
}
|
|
31
|
-
return tx;
|
|
32
47
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
async function optionalImport(specifier) {
|
|
49
|
+
if (isBrowser) {
|
|
50
|
+
return dynamicImport(specifier);
|
|
51
|
+
}
|
|
52
|
+
const requireFn = await resolveNodeRequire();
|
|
53
|
+
if (requireFn) {
|
|
54
|
+
try {
|
|
55
|
+
return requireFn(specifier);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (!isModuleNotFound(specifier, error)) {
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
37
61
|
}
|
|
38
|
-
return
|
|
62
|
+
return dynamicImport(specifier);
|
|
39
63
|
}
|
|
40
64
|
export {
|
|
41
|
-
|
|
42
|
-
buildTopicCreateTx,
|
|
43
|
-
encodeHcs2RegistryMemo
|
|
65
|
+
optionalImport
|
|
44
66
|
};
|
|
45
67
|
//# sourceMappingURL=standards-sdk.es138.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es138.js","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es138.js","sources":["../../src/utils/dynamic-import.ts"],"sourcesContent":["import { isBrowser } from './is-browser';\n\nlet nodeRequire: NodeRequire | null | undefined;\n\nfunction isModuleNotFound(specifier: string, error: unknown): boolean {\n if (!error || typeof error !== 'object') {\n return false;\n }\n const code = Reflect.get(error, 'code');\n const message = Reflect.get(error, 'message');\n const messageText = typeof message === 'string' ? message : '';\n\n if (typeof code === 'string' && code.includes('MODULE_NOT_FOUND')) {\n return messageText.includes(specifier);\n }\n\n if (messageText) {\n const lowered = messageText.toLowerCase();\n if (\n lowered.includes('cannot find module') ||\n lowered.includes('module not found') ||\n lowered.includes('cannot find package')\n ) {\n return lowered.includes(specifier.toLowerCase());\n }\n }\n\n return false;\n}\n\nasync function resolveNodeRequire(): Promise<NodeRequire | null> {\n if (nodeRequire !== undefined) {\n return nodeRequire;\n }\n\n if (isBrowser) {\n nodeRequire = null;\n return nodeRequire;\n }\n\n try {\n const globalObject =\n typeof global !== 'undefined'\n ? (global as typeof globalThis)\n : globalThis;\n const req =\n globalObject.process?.mainModule?.require ??\n (globalObject as { require?: NodeRequire }).require;\n\n nodeRequire =\n typeof req === 'function' &&\n typeof (req as NodeRequire).resolve === 'function'\n ? (req as NodeRequire)\n : null;\n } catch {\n nodeRequire = null;\n }\n\n return nodeRequire;\n}\n\nasync function dynamicImport<T>(specifier: string): Promise<T | null> {\n try {\n return (await import(specifier)) as T;\n } catch (error) {\n if (isModuleNotFound(specifier, error)) {\n return null;\n }\n throw error as Error;\n }\n}\n\nexport async function optionalImport<T>(specifier: string): Promise<T | null> {\n if (isBrowser) {\n return dynamicImport<T>(specifier);\n }\n\n const requireFn = await resolveNodeRequire();\n if (requireFn) {\n try {\n return requireFn(specifier) as T;\n } catch (error) {\n if (!isModuleNotFound(specifier, error)) {\n throw error as Error;\n }\n }\n }\n\n return dynamicImport<T>(specifier);\n}\n"],"names":[],"mappings":";AAEA,IAAI;AAEJ,SAAS,iBAAiB,WAAmB,OAAyB;AACpE,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,WAAO;AAAA,EACT;AACA,QAAM,OAAO,QAAQ,IAAI,OAAO,MAAM;AACtC,QAAM,UAAU,QAAQ,IAAI,OAAO,SAAS;AAC5C,QAAM,cAAc,OAAO,YAAY,WAAW,UAAU;AAE5D,MAAI,OAAO,SAAS,YAAY,KAAK,SAAS,kBAAkB,GAAG;AACjE,WAAO,YAA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