near-kit 0.0.0 → 0.1.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.
Files changed (128) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +371 -2
  3. package/dist/contracts/contract.d.ts +63 -0
  4. package/dist/contracts/contract.d.ts.map +1 -0
  5. package/dist/contracts/contract.js +42 -0
  6. package/dist/contracts/contract.js.map +1 -0
  7. package/dist/contracts/index.d.ts +5 -0
  8. package/dist/contracts/index.d.ts.map +1 -0
  9. package/dist/contracts/index.js +5 -0
  10. package/dist/contracts/index.js.map +1 -0
  11. package/dist/core/actions.d.ts +193 -0
  12. package/dist/core/actions.d.ts.map +1 -0
  13. package/dist/core/actions.js +195 -0
  14. package/dist/core/actions.js.map +1 -0
  15. package/dist/core/config-schemas.d.ts +179 -0
  16. package/dist/core/config-schemas.d.ts.map +1 -0
  17. package/dist/core/config-schemas.js +169 -0
  18. package/dist/core/config-schemas.js.map +1 -0
  19. package/dist/core/constants.d.ts +43 -0
  20. package/dist/core/constants.d.ts.map +1 -0
  21. package/dist/core/constants.js +49 -0
  22. package/dist/core/constants.js.map +1 -0
  23. package/dist/core/near.d.ts +301 -0
  24. package/dist/core/near.d.ts.map +1 -0
  25. package/dist/core/near.js +504 -0
  26. package/dist/core/near.js.map +1 -0
  27. package/dist/core/nonce-manager.d.ts +39 -0
  28. package/dist/core/nonce-manager.d.ts.map +1 -0
  29. package/dist/core/nonce-manager.js +73 -0
  30. package/dist/core/nonce-manager.js.map +1 -0
  31. package/dist/core/rpc/rpc-error-handler.d.ts +60 -0
  32. package/dist/core/rpc/rpc-error-handler.d.ts.map +1 -0
  33. package/dist/core/rpc/rpc-error-handler.js +324 -0
  34. package/dist/core/rpc/rpc-error-handler.js.map +1 -0
  35. package/dist/core/rpc/rpc-schemas.d.ts +1812 -0
  36. package/dist/core/rpc/rpc-schemas.d.ts.map +1 -0
  37. package/dist/core/rpc/rpc-schemas.js +424 -0
  38. package/dist/core/rpc/rpc-schemas.js.map +1 -0
  39. package/dist/core/rpc/rpc.d.ts +117 -0
  40. package/dist/core/rpc/rpc.d.ts.map +1 -0
  41. package/dist/core/rpc/rpc.js +325 -0
  42. package/dist/core/rpc/rpc.js.map +1 -0
  43. package/dist/core/schema.d.ts +1188 -0
  44. package/dist/core/schema.d.ts.map +1 -0
  45. package/dist/core/schema.js +396 -0
  46. package/dist/core/schema.js.map +1 -0
  47. package/dist/core/transaction.d.ts +390 -0
  48. package/dist/core/transaction.d.ts.map +1 -0
  49. package/dist/core/transaction.js +649 -0
  50. package/dist/core/transaction.js.map +1 -0
  51. package/dist/core/types.d.ts +271 -0
  52. package/dist/core/types.d.ts.map +1 -0
  53. package/dist/core/types.js +9 -0
  54. package/dist/core/types.js.map +1 -0
  55. package/dist/errors/index.d.ts +226 -0
  56. package/dist/errors/index.d.ts.map +1 -0
  57. package/dist/errors/index.js +366 -0
  58. package/dist/errors/index.js.map +1 -0
  59. package/dist/index.d.ts +16 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +23 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/keys/credential-schemas.d.ts +98 -0
  64. package/dist/keys/credential-schemas.d.ts.map +1 -0
  65. package/dist/keys/credential-schemas.js +128 -0
  66. package/dist/keys/credential-schemas.js.map +1 -0
  67. package/dist/keys/file-keystore.d.ts +130 -0
  68. package/dist/keys/file-keystore.d.ts.map +1 -0
  69. package/dist/keys/file-keystore.js +266 -0
  70. package/dist/keys/file-keystore.js.map +1 -0
  71. package/dist/keys/in-memory-keystore.d.ts +71 -0
  72. package/dist/keys/in-memory-keystore.d.ts.map +1 -0
  73. package/dist/keys/in-memory-keystore.js +85 -0
  74. package/dist/keys/in-memory-keystore.js.map +1 -0
  75. package/dist/keys/index.d.ts +12 -0
  76. package/dist/keys/index.d.ts.map +1 -0
  77. package/dist/keys/index.js +18 -0
  78. package/dist/keys/index.js.map +1 -0
  79. package/dist/keys/native-keystore.d.ts +111 -0
  80. package/dist/keys/native-keystore.d.ts.map +1 -0
  81. package/dist/keys/native-keystore.js +167 -0
  82. package/dist/keys/native-keystore.js.map +1 -0
  83. package/dist/sandbox/index.d.ts +6 -0
  84. package/dist/sandbox/index.d.ts.map +1 -0
  85. package/dist/sandbox/index.js +5 -0
  86. package/dist/sandbox/index.js.map +1 -0
  87. package/dist/sandbox/sandbox.d.ts +55 -0
  88. package/dist/sandbox/sandbox.d.ts.map +1 -0
  89. package/dist/sandbox/sandbox.js +341 -0
  90. package/dist/sandbox/sandbox.js.map +1 -0
  91. package/dist/utils/amount.d.ts +76 -0
  92. package/dist/utils/amount.d.ts.map +1 -0
  93. package/dist/utils/amount.js +137 -0
  94. package/dist/utils/amount.js.map +1 -0
  95. package/dist/utils/gas.d.ts +69 -0
  96. package/dist/utils/gas.d.ts.map +1 -0
  97. package/dist/utils/gas.js +92 -0
  98. package/dist/utils/gas.js.map +1 -0
  99. package/dist/utils/index.d.ts +14 -0
  100. package/dist/utils/index.d.ts.map +1 -0
  101. package/dist/utils/index.js +14 -0
  102. package/dist/utils/index.js.map +1 -0
  103. package/dist/utils/key.d.ts +117 -0
  104. package/dist/utils/key.d.ts.map +1 -0
  105. package/dist/utils/key.js +270 -0
  106. package/dist/utils/key.js.map +1 -0
  107. package/dist/utils/nep413.d.ts +97 -0
  108. package/dist/utils/nep413.d.ts.map +1 -0
  109. package/dist/utils/nep413.js +154 -0
  110. package/dist/utils/nep413.js.map +1 -0
  111. package/dist/utils/validation.d.ts +114 -0
  112. package/dist/utils/validation.d.ts.map +1 -0
  113. package/dist/utils/validation.js +150 -0
  114. package/dist/utils/validation.js.map +1 -0
  115. package/dist/wallets/adapters.d.ts +119 -0
  116. package/dist/wallets/adapters.d.ts.map +1 -0
  117. package/dist/wallets/adapters.js +267 -0
  118. package/dist/wallets/adapters.js.map +1 -0
  119. package/dist/wallets/index.d.ts +11 -0
  120. package/dist/wallets/index.d.ts.map +1 -0
  121. package/dist/wallets/index.js +2 -0
  122. package/dist/wallets/index.js.map +1 -0
  123. package/dist/wallets/types.d.ts +99 -0
  124. package/dist/wallets/types.d.ts.map +1 -0
  125. package/dist/wallets/types.js +10 -0
  126. package/dist/wallets/types.js.map +1 -0
  127. package/package.json +78 -7
  128. package/index.js +0 -1
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Native OS keystore implementation using system credential storage
3
+ */
4
+ import type { KeyPair, KeyStore } from "../core/types.js";
5
+ /**
6
+ * Native OS keystore using system credential storage
7
+ *
8
+ * This keystore uses the operating system's native secure credential storage:
9
+ * - **macOS**: Keychain Access
10
+ * - **Windows**: Credential Manager (DPAPI)
11
+ * - **Linux**: libsecret/Secret Service API
12
+ *
13
+ * ## Security Benefits
14
+ * - Keys stored in OS-level secure storage (not plain files)
15
+ * - Encrypted by OS using hardware-backed keys when available
16
+ * - Protected by user's system password/biometrics
17
+ * - Isolated from other applications
18
+ *
19
+ * ## Requirements
20
+ * - Requires `@napi-rs/keyring` native dependency
21
+ * - Linux requires `libsecret` (`apt install libsecret-1-dev` on Debian/Ubuntu)
22
+ *
23
+ * ## Limitations
24
+ * - Not available in browser environments (use InMemoryKeyStore instead)
25
+ * - Requires user to be logged in to the system
26
+ * - Keys are machine-specific (not synced across devices)
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Use OS keyring for maximum security
31
+ * const keyStore = new NativeKeyStore()
32
+ * const near = new Near({ keyStore })
33
+ *
34
+ * // Keys stored in:
35
+ * // - macOS: Keychain Access > "NEAR Credentials"
36
+ * // - Windows: Credential Manager > Generic Credentials
37
+ * // - Linux: GNOME Keyring / KDE Wallet
38
+ * ```
39
+ */
40
+ export declare class NativeKeyStore implements KeyStore {
41
+ private readonly service;
42
+ /**
43
+ * Create a new native OS keystore
44
+ *
45
+ * @param service - Service name for credential storage (default: "NEAR Credentials")
46
+ * This appears in Keychain Access (macOS) or Credential Manager (Windows)
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Default service name
51
+ * const keyStore = new NativeKeyStore()
52
+ *
53
+ * // Custom service name for your app
54
+ * const keyStore = new NativeKeyStore("MyApp NEAR Keys")
55
+ * ```
56
+ */
57
+ constructor(service?: string);
58
+ /**
59
+ * Create an Entry instance for keyring operations
60
+ */
61
+ private getEntry;
62
+ /**
63
+ * Add a key to the OS keystore
64
+ *
65
+ * Stores the key securely in the operating system's credential storage.
66
+ * The key is encrypted by the OS and protected by the user's system password.
67
+ *
68
+ * @param accountId - NEAR account ID (used as credential name)
69
+ * @param key - Key pair to store
70
+ * @param options - Optional metadata (stored alongside the key in OS keyring)
71
+ *
72
+ * @throws {Error} If keyring access fails (e.g., user denies permission)
73
+ */
74
+ add(accountId: string, key: KeyPair, options?: {
75
+ seedPhrase?: string;
76
+ derivationPath?: string;
77
+ implicitAccountId?: string;
78
+ }): Promise<void>;
79
+ /**
80
+ * Get a key from the OS keystore
81
+ *
82
+ * Retrieves and decrypts the key from the operating system's credential storage.
83
+ *
84
+ * @param accountId - NEAR account ID
85
+ * @returns Key pair if found, null otherwise
86
+ *
87
+ * @throws {Error} If keyring access fails or key is corrupted
88
+ */
89
+ get(accountId: string): Promise<KeyPair | null>;
90
+ /**
91
+ * Remove a key from the OS keystore
92
+ *
93
+ * Permanently deletes the credential from the operating system's storage.
94
+ *
95
+ * @param accountId - NEAR account ID
96
+ */
97
+ remove(accountId: string): Promise<void>;
98
+ /**
99
+ * List all account IDs in the OS keystore
100
+ *
101
+ * ⚠️ **Note**: The underlying keyring library doesn't support listing all
102
+ * credentials for a service. This method returns an empty array.
103
+ *
104
+ * If you need to track multiple accounts, maintain a list separately
105
+ * (e.g., in a config file) and use this keystore only for secure key storage.
106
+ *
107
+ * @returns Empty array (OS keyrings don't support enumeration for security)
108
+ */
109
+ list(): Promise<string[]>;
110
+ }
111
+ //# sourceMappingURL=native-keystore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-keystore.d.ts","sourceRoot":"","sources":["../../src/keys/native-keystore.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAOzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,cAAe,YAAW,QAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAEhC;;;;;;;;;;;;;;OAcG;gBACS,OAAO,SAAqB;IAIxC;;OAEG;YACW,QAAQ;IAMtB;;;;;;;;;;;OAWG;IACG,GAAG,CACP,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,OAAO,EACZ,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAC3B,GACA,OAAO,CAAC,IAAI,CAAC;IAyBhB;;;;;;;;;OASG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAqBrD;;;;;;OAMG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAa9C;;;;;;;;;;OAUG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAKhC"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Native OS keystore implementation using system credential storage
3
+ */
4
+ import { parseKey } from "../utils/key.js";
5
+ import { parseCredentialFile, } from "./credential-schemas.js";
6
+ /**
7
+ * Native OS keystore using system credential storage
8
+ *
9
+ * This keystore uses the operating system's native secure credential storage:
10
+ * - **macOS**: Keychain Access
11
+ * - **Windows**: Credential Manager (DPAPI)
12
+ * - **Linux**: libsecret/Secret Service API
13
+ *
14
+ * ## Security Benefits
15
+ * - Keys stored in OS-level secure storage (not plain files)
16
+ * - Encrypted by OS using hardware-backed keys when available
17
+ * - Protected by user's system password/biometrics
18
+ * - Isolated from other applications
19
+ *
20
+ * ## Requirements
21
+ * - Requires `@napi-rs/keyring` native dependency
22
+ * - Linux requires `libsecret` (`apt install libsecret-1-dev` on Debian/Ubuntu)
23
+ *
24
+ * ## Limitations
25
+ * - Not available in browser environments (use InMemoryKeyStore instead)
26
+ * - Requires user to be logged in to the system
27
+ * - Keys are machine-specific (not synced across devices)
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // Use OS keyring for maximum security
32
+ * const keyStore = new NativeKeyStore()
33
+ * const near = new Near({ keyStore })
34
+ *
35
+ * // Keys stored in:
36
+ * // - macOS: Keychain Access > "NEAR Credentials"
37
+ * // - Windows: Credential Manager > Generic Credentials
38
+ * // - Linux: GNOME Keyring / KDE Wallet
39
+ * ```
40
+ */
41
+ export class NativeKeyStore {
42
+ /**
43
+ * Create a new native OS keystore
44
+ *
45
+ * @param service - Service name for credential storage (default: "NEAR Credentials")
46
+ * This appears in Keychain Access (macOS) or Credential Manager (Windows)
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // Default service name
51
+ * const keyStore = new NativeKeyStore()
52
+ *
53
+ * // Custom service name for your app
54
+ * const keyStore = new NativeKeyStore("MyApp NEAR Keys")
55
+ * ```
56
+ */
57
+ constructor(service = "NEAR Credentials") {
58
+ this.service = service;
59
+ }
60
+ /**
61
+ * Create an Entry instance for keyring operations
62
+ */
63
+ async getEntry(accountId) {
64
+ // Dynamic import to allow graceful fallback if not installed
65
+ const { Entry } = await import("@napi-rs/keyring");
66
+ return new Entry(this.service, accountId);
67
+ }
68
+ /**
69
+ * Add a key to the OS keystore
70
+ *
71
+ * Stores the key securely in the operating system's credential storage.
72
+ * The key is encrypted by the OS and protected by the user's system password.
73
+ *
74
+ * @param accountId - NEAR account ID (used as credential name)
75
+ * @param key - Key pair to store
76
+ * @param options - Optional metadata (stored alongside the key in OS keyring)
77
+ *
78
+ * @throws {Error} If keyring access fails (e.g., user denies permission)
79
+ */
80
+ async add(accountId, key, options) {
81
+ const entry = await this.getEntry(accountId);
82
+ // Store full key data as JSON
83
+ const keyData = {
84
+ account_id: accountId,
85
+ public_key: key.publicKey.toString(),
86
+ private_key: key.secretKey,
87
+ };
88
+ // Add optional fields if provided
89
+ if (options?.seedPhrase) {
90
+ keyData.master_seed_phrase = options.seedPhrase;
91
+ }
92
+ if (options?.derivationPath) {
93
+ keyData.seed_phrase_hd_path = options.derivationPath;
94
+ }
95
+ if (options?.implicitAccountId) {
96
+ keyData.implicit_account_id = options.implicitAccountId;
97
+ }
98
+ // Store as JSON string in keyring
99
+ entry.setPassword(JSON.stringify(keyData));
100
+ }
101
+ /**
102
+ * Get a key from the OS keystore
103
+ *
104
+ * Retrieves and decrypts the key from the operating system's credential storage.
105
+ *
106
+ * @param accountId - NEAR account ID
107
+ * @returns Key pair if found, null otherwise
108
+ *
109
+ * @throws {Error} If keyring access fails or key is corrupted
110
+ */
111
+ async get(accountId) {
112
+ try {
113
+ const entry = await this.getEntry(accountId);
114
+ const stored = entry.getPassword();
115
+ if (!stored) {
116
+ return null;
117
+ }
118
+ // Parse stored JSON data
119
+ const keyData = parseCredentialFile(JSON.parse(stored));
120
+ return parseKey(keyData.private_key);
121
+ }
122
+ catch (error) {
123
+ // Key not found or access denied
124
+ if (error instanceof Error && error.message.includes("not found")) {
125
+ return null;
126
+ }
127
+ throw error;
128
+ }
129
+ }
130
+ /**
131
+ * Remove a key from the OS keystore
132
+ *
133
+ * Permanently deletes the credential from the operating system's storage.
134
+ *
135
+ * @param accountId - NEAR account ID
136
+ */
137
+ async remove(accountId) {
138
+ try {
139
+ const entry = await this.getEntry(accountId);
140
+ entry.deletePassword();
141
+ }
142
+ catch (error) {
143
+ // Ignore if credential doesn't exist
144
+ if (error instanceof Error && error.message.includes("not found")) {
145
+ return;
146
+ }
147
+ throw error;
148
+ }
149
+ }
150
+ /**
151
+ * List all account IDs in the OS keystore
152
+ *
153
+ * ⚠️ **Note**: The underlying keyring library doesn't support listing all
154
+ * credentials for a service. This method returns an empty array.
155
+ *
156
+ * If you need to track multiple accounts, maintain a list separately
157
+ * (e.g., in a config file) and use this keystore only for secure key storage.
158
+ *
159
+ * @returns Empty array (OS keyrings don't support enumeration for security)
160
+ */
161
+ async list() {
162
+ // Native keyrings don't support listing credentials for security reasons
163
+ // Applications should track account IDs separately if needed
164
+ return [];
165
+ }
166
+ }
167
+ //# sourceMappingURL=native-keystore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-keystore.js","sourceRoot":"","sources":["../../src/keys/native-keystore.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Sandbox exports
3
+ */
4
+ export type { SandboxOptions } from "./sandbox.js";
5
+ export { Sandbox } from "./sandbox.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Sandbox exports
3
+ */
4
+ export { Sandbox } from "./sandbox.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * NEAR Sandbox - Local testing environment
3
+ *
4
+ * Simple, explicit API for running a local NEAR node for testing.
5
+ */
6
+ export interface SandboxOptions {
7
+ version?: string;
8
+ /**
9
+ * Whether to spawn the sandbox process as detached.
10
+ * Default: true
11
+ * Set to false in test environments to prevent the process from being killed by test runners.
12
+ */
13
+ detached?: boolean;
14
+ }
15
+ /**
16
+ * NEAR Sandbox instance
17
+ *
18
+ * Manages a local NEAR node for testing. Automatically cleans up on stop().
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const sandbox = await Sandbox.start();
23
+ * const near = new Near({ network: sandbox });
24
+ * // ... run tests
25
+ * await sandbox.stop();
26
+ * ```
27
+ */
28
+ export declare class Sandbox {
29
+ readonly rpcUrl: string;
30
+ readonly networkId: string;
31
+ readonly rootAccount: {
32
+ id: string;
33
+ secretKey: string;
34
+ };
35
+ private process;
36
+ private homeDir;
37
+ private constructor();
38
+ /**
39
+ * Start a new sandbox instance
40
+ *
41
+ * Downloads the sandbox binary if needed, initializes a temporary directory,
42
+ * and starts the sandbox process.
43
+ *
44
+ * @param options - Optional configuration
45
+ * @returns Promise resolving to a running Sandbox instance
46
+ */
47
+ static start(options?: SandboxOptions): Promise<Sandbox>;
48
+ /**
49
+ * Stop the sandbox and clean up
50
+ *
51
+ * Kills the sandbox process and removes temporary files.
52
+ */
53
+ stop(): Promise<void>;
54
+ }
55
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,OAAO;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IAEvD,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,OAAO,CAAQ;IAEvB,OAAO;IAcP;;;;;;;;OAQG;WACU,KAAK,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAuDlE;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAiC5B"}