@kheopskit/core 4.0.0 → 5.0.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 (54) hide show
  1. package/dist/{chunk-SIUWQBT4.js → chunk-4ENHC7G4.js} +11 -2
  2. package/dist/chunk-4ENHC7G4.js.map +1 -0
  3. package/dist/{chunk-KWFQDD7E.mjs → chunk-6XAZANB5.mjs} +58 -186
  4. package/dist/chunk-6XAZANB5.mjs.map +1 -0
  5. package/dist/{chunk-PNPPI5CH.mjs → chunk-7QSGAJ4A.mjs} +11 -2
  6. package/dist/chunk-7QSGAJ4A.mjs.map +1 -0
  7. package/dist/{chunk-TMAPQWW2.js → chunk-B4L6GAYD.js} +24 -9
  8. package/dist/chunk-B4L6GAYD.js.map +1 -0
  9. package/dist/chunk-XQWJM3KC.js +450 -0
  10. package/dist/chunk-XQWJM3KC.js.map +1 -0
  11. package/dist/{chunk-4RBYRNY3.mjs → chunk-YDLCHYHH.mjs} +22 -7
  12. package/dist/chunk-YDLCHYHH.mjs.map +1 -0
  13. package/dist/ethereum.d.mts +4 -3
  14. package/dist/ethereum.d.ts +4 -3
  15. package/dist/ethereum.js +61 -42
  16. package/dist/ethereum.js.map +1 -1
  17. package/dist/ethereum.mjs +53 -34
  18. package/dist/ethereum.mjs.map +1 -1
  19. package/dist/index.d.mts +20 -6
  20. package/dist/index.d.ts +20 -6
  21. package/dist/index.js +253 -47
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +271 -65
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/internal.d.mts +4 -4
  26. package/dist/internal.d.ts +4 -4
  27. package/dist/internal.js +3 -3
  28. package/dist/internal.mjs +2 -2
  29. package/dist/polkadot.d.mts +4 -3
  30. package/dist/polkadot.d.ts +4 -3
  31. package/dist/polkadot.js +26 -37
  32. package/dist/polkadot.js.map +1 -1
  33. package/dist/polkadot.mjs +13 -24
  34. package/dist/polkadot.mjs.map +1 -1
  35. package/dist/solana.d.mts +5 -4
  36. package/dist/solana.d.ts +5 -4
  37. package/dist/solana.js +37 -42
  38. package/dist/solana.js.map +1 -1
  39. package/dist/solana.mjs +26 -31
  40. package/dist/solana.mjs.map +1 -1
  41. package/dist/{types-BNzRUNw-.d.mts → types-C7V7DGlg.d.mts} +47 -17
  42. package/dist/{types-BNzRUNw-.d.ts → types-C7V7DGlg.d.ts} +47 -17
  43. package/package.json +42 -16
  44. package/dist/chunk-4RBYRNY3.mjs.map +0 -1
  45. package/dist/chunk-FIAL4HTE.js +0 -1
  46. package/dist/chunk-FIAL4HTE.js.map +0 -1
  47. package/dist/chunk-KWFQDD7E.mjs.map +0 -1
  48. package/dist/chunk-NU46D4MZ.js +0 -578
  49. package/dist/chunk-NU46D4MZ.js.map +0 -1
  50. package/dist/chunk-PNPPI5CH.mjs.map +0 -1
  51. package/dist/chunk-SIUWQBT4.js.map +0 -1
  52. package/dist/chunk-TMAPQWW2.js.map +0 -1
  53. package/dist/chunk-YFD3IKK5.mjs +0 -1
  54. package/dist/chunk-YFD3IKK5.mjs.map +0 -1
@@ -3,6 +3,10 @@ import { Observable } from 'rxjs';
3
3
 
4
4
  type WalletAccountId = string;
5
5
  declare const getWalletAccountId: (walletId: string, address: string) => WalletAccountId;
6
+ declare const parseWalletAccountId: (accountId: string) => {
7
+ walletId: string;
8
+ address: string;
9
+ };
6
10
 
7
11
  type WalletId = string;
8
12
  declare const getWalletId: (platform: WalletPlatform, identifier: string) => WalletId;
@@ -10,6 +14,11 @@ declare const parseWalletId: (walletId: string) => {
10
14
  platform: WalletPlatform;
11
15
  identifier: string;
12
16
  };
17
+ /**
18
+ * Non-throwing variant of {@link parseWalletId}. Use when validating untrusted
19
+ * input (e.g. cached state persisted by an older version) before parsing.
20
+ */
21
+ declare const isValidWalletId: (walletId: unknown) => walletId is WalletId;
13
22
 
14
23
  type KheopskitStoreData = {
15
24
  autoReconnect?: WalletId[];
@@ -103,7 +112,7 @@ type AppKitInstance = {
103
112
  caipNetworkId?: string;
104
113
  }[];
105
114
  };
106
- type WalletType = "injected" | "appKit";
115
+ type WalletType = "injected" | "walletconnect";
107
116
  type PolkadotAccountType = "sr25519" | "ed25519" | "ecdsa" | "ethereum";
108
117
  /**
109
118
  * SDK-free fields common to every wallet, regardless of platform. Platform
@@ -139,21 +148,27 @@ type BaseWalletAccount = {
139
148
  walletId: WalletId;
140
149
  };
141
150
  /**
142
- * AppKit (WalletConnect) wallet handle for a given platform. References only
143
- * `@reown/appkit` (a hard dependency) — no optional platform SDK — so it lives
144
- * in core and is shared by every platform's wallet union.
151
+ * The single WalletConnect connector, shared across every platform.
145
152
  *
146
- * The per-platform aliases below (`PolkadotAppKitWallet`, ) are kept so each
147
- * platform entry point can re-export a concrete name.
153
+ * Unlike injected wallets, it is **not tied to a platform**: one WalletConnect
154
+ * session spans whichever namespaces the remote wallet approves in a single
155
+ * pairing (a namespace can't be added to a live session afterwards). So there is
156
+ * exactly one of these in `wallets`, discriminated by `type: "walletconnect"`.
157
+ * Its accounts appear in `accounts`, each carrying its own `platform`.
148
158
  */
149
- type AppKitWallet<P extends WalletPlatform = WalletPlatform> = {
159
+ type WalletConnectWallet = {
150
160
  id: WalletId;
151
- platform: P;
152
- type: "appKit";
161
+ type: "walletconnect";
162
+ /**
163
+ * Platforms (namespaces) the live session currently carries. Empty until
164
+ * connected; populated with whatever the wallet approved (e.g. just
165
+ * `["ethereum"]`, or `["polkadot", "ethereum"]`).
166
+ */
167
+ platforms: WalletPlatform[];
153
168
  /**
154
169
  * Raw Reown AppKit instance, exposed as an escape hatch for advanced use
155
170
  * (custom modal control, reading providers directly). Most consumers should
156
- * use the wallet's `connect`/`disconnect` and the derived accounts instead.
171
+ * use `connect`/`disconnect` and the derived accounts instead.
157
172
  */
158
173
  appKit: AppKitInstance;
159
174
  name: string;
@@ -162,9 +177,23 @@ type AppKitWallet<P extends WalletPlatform = WalletPlatform> = {
162
177
  connect: () => Promise<void>;
163
178
  disconnect: () => Promise<void>;
164
179
  };
165
- type PolkadotAppKitWallet = AppKitWallet<"polkadot">;
166
- type EthereumAppKitWallet = AppKitWallet<"ethereum">;
167
- type SolanaAppKitWallet = AppKitWallet<"solana">;
180
+ /** Narrows a wallet to the platform-less {@link WalletConnectWallet}. */
181
+ declare const isWalletConnectWallet: (wallet: BaseWallet | WalletConnectWallet) => wallet is WalletConnectWallet;
182
+ /**
183
+ * Narrows a wallet to an injected (browser-extension / Wallet Standard) wallet —
184
+ * the complement of {@link isWalletConnectWallet}. `state.wallets` is
185
+ * `(InjectedWallet | WalletConnectWallet)[]`, so use this to recover the
186
+ * injected-only fields when iterating: `platform`, `sourceId`, and the SDK
187
+ * handle (`provider` on Ethereum, `extension` on Polkadot, `wallet` on Solana).
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * for (const wallet of wallets.filter(isInjectedWallet)) {
192
+ * console.log(wallet.platform, wallet.sourceId); // typed, no WC widening
193
+ * }
194
+ * ```
195
+ */
196
+ declare const isInjectedWallet: <W extends BaseWallet | WalletConnectWallet>(wallet: W) => wallet is Exclude<W, WalletConnectWallet>;
168
197
  /**
169
198
  * Dapp metadata shown in the WalletConnect modal. Mirrors WalletConnect's
170
199
  * `Metadata`, declared locally so core doesn't depend on
@@ -212,7 +241,7 @@ type PlatformContext = {
212
241
  type KheopskitPlatform<TPlatform extends WalletPlatform = WalletPlatform, TWallet extends BaseWallet = BaseWallet, TAccount extends BaseWalletAccount = BaseWalletAccount> = {
213
242
  readonly platform: TPlatform;
214
243
  getWallets$(ctx: PlatformContext): Observable<TWallet[]>;
215
- getAccounts$(wallets$: Observable<TWallet[]>): Observable<TAccount[]>;
244
+ getAccounts$(wallets$: Observable<(TWallet | WalletConnectWallet)[]>): Observable<TAccount[]>;
216
245
  /**
217
246
  * Optional hydration filter. Cached accounts for which this returns false are
218
247
  * dropped during SSR hydration (Polkadot uses it to honour `accountTypes`).
@@ -274,7 +303,7 @@ type KheopskitConfig<P extends readonly KheopskitPlatform[] = readonly Kheopskit
274
303
  * so it remains absent until the live account loads.
275
304
  */
276
305
  type KheopskitState<P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[]> = {
277
- wallets: WalletOf<P[number]>[];
306
+ wallets: (WalletOf<P[number]> | WalletConnectWallet)[];
278
307
  accounts: AccountOf<P[number]>[];
279
308
  config: KheopskitConfig<P>;
280
309
  /**
@@ -294,7 +323,8 @@ type KheopskitState<P extends readonly KheopskitPlatform[] = readonly KheopskitP
294
323
  */
295
324
  type CachedWallet = {
296
325
  id: WalletId;
297
- platform: WalletPlatform;
326
+ /** Absent for the platform-less WalletConnect connector. */
327
+ platform?: WalletPlatform;
298
328
  type: WalletType;
299
329
  name: string;
300
330
  isConnected: boolean;
@@ -316,4 +346,4 @@ type CachedAccount = {
316
346
  walletName: string;
317
347
  };
318
348
 
319
- export { type AccountOf as A, type BaseWallet as B, type CachedAccount as C, type EthereumAppKitWallet as E, type KheopskitPlatform as K, type PlatformContext as P, type SolanaAppKitWallet as S, type WalletAccountId as W, type WalletId as a, type KheopskitConfig as b, createKheopskitStore as c, type KheopskitState as d, type AppKitInstance as e, type AppKitWallet as f, type BaseWalletAccount as g, type CachedWallet as h, type PolkadotAccountType as i, type PolkadotAppKitWallet as j, type WalletConnectConfig as k, type WalletConnectMetadata as l, type WalletConnectProvider as m, type WalletOf as n, type WalletPlatform as o, type WalletType as p, getDefaultStore as q, getWalletAccountId as r, getWalletId as s, parseWalletId as t };
349
+ export { type AccountOf as A, type BaseWallet as B, type CachedAccount as C, type KheopskitPlatform as K, type PlatformContext as P, type WalletAccountId as W, type WalletId as a, type WalletConnectWallet as b, isWalletConnectWallet as c, type KheopskitConfig as d, createKheopskitStore as e, type KheopskitState as f, type AppKitInstance as g, type BaseWalletAccount as h, isInjectedWallet as i, type CachedWallet as j, type PolkadotAccountType as k, type WalletConnectConfig as l, type WalletConnectMetadata as m, type WalletConnectProvider as n, type WalletOf as o, type WalletPlatform as p, type WalletType as q, getDefaultStore as r, getWalletAccountId as s, getWalletId as t, isValidWalletId as u, parseWalletAccountId as v, parseWalletId as w };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@kheopskit/core",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "",
5
5
  "private": false,
6
+ "sideEffects": false,
6
7
  "files": [
7
8
  "dist",
8
9
  "README.md",
@@ -13,29 +14,54 @@
13
14
  "types": "./dist/index.d.ts",
14
15
  "exports": {
15
16
  ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.mjs",
18
- "require": "./dist/index.js"
17
+ "import": {
18
+ "types": "./dist/index.d.mts",
19
+ "default": "./dist/index.mjs"
20
+ },
21
+ "require": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
19
25
  },
20
26
  "./polkadot": {
21
- "types": "./dist/polkadot.d.ts",
22
- "import": "./dist/polkadot.mjs",
23
- "require": "./dist/polkadot.js"
27
+ "import": {
28
+ "types": "./dist/polkadot.d.mts",
29
+ "default": "./dist/polkadot.mjs"
30
+ },
31
+ "require": {
32
+ "types": "./dist/polkadot.d.ts",
33
+ "default": "./dist/polkadot.js"
34
+ }
24
35
  },
25
36
  "./ethereum": {
26
- "types": "./dist/ethereum.d.ts",
27
- "import": "./dist/ethereum.mjs",
28
- "require": "./dist/ethereum.js"
37
+ "import": {
38
+ "types": "./dist/ethereum.d.mts",
39
+ "default": "./dist/ethereum.mjs"
40
+ },
41
+ "require": {
42
+ "types": "./dist/ethereum.d.ts",
43
+ "default": "./dist/ethereum.js"
44
+ }
29
45
  },
30
46
  "./solana": {
31
- "types": "./dist/solana.d.ts",
32
- "import": "./dist/solana.mjs",
33
- "require": "./dist/solana.js"
47
+ "import": {
48
+ "types": "./dist/solana.d.mts",
49
+ "default": "./dist/solana.mjs"
50
+ },
51
+ "require": {
52
+ "types": "./dist/solana.d.ts",
53
+ "default": "./dist/solana.js"
54
+ }
34
55
  },
35
56
  "./internal": {
36
- "types": "./dist/internal.d.ts",
37
- "import": "./dist/internal.mjs",
38
- "require": "./dist/internal.js"
57
+ "import": {
58
+ "types": "./dist/internal.d.mts",
59
+ "default": "./dist/internal.mjs"
60
+ },
61
+ "require": {
62
+ "types": "./dist/internal.d.ts",
63
+ "default": "./dist/internal.js"
64
+ }
39
65
  },
40
66
  "./package.json": "./package.json"
41
67
  },
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/hydrateState.ts","../src/utils/iconCache.ts","../src/utils/sortAccounts.ts","../src/utils/sortWallets.ts","../src/api/platform.ts"],"sourcesContent":["import type {\n\tBaseWallet,\n\tBaseWalletAccount,\n\tCachedAccount,\n\tCachedWallet,\n\tPolkadotAccountType,\n} from \"../api/types\";\nimport { POLKADOT_EXTENSIONS } from \"./polkadotExtensions\";\nimport type { WalletAccountId } from \"./WalletAccountId\";\nimport { parseWalletId, type WalletId } from \"./WalletId\";\n\n/**\n * Looks up the icon for a wallet from known Polkadot extensions only.\n * Ethereum icons will be populated from the localStorage icon cache via the merge function.\n *\n * Note: We DON'T use localStorage icon cache here because hydrateWallet is called\n * during SSR (server) and client hydration. localStorage isn't available on server,\n * so using it would cause a hydration mismatch. Icons for Ethereum wallets will be\n * populated when the hydration buffer merges cached wallets with live wallets.\n */\nconst lookupWalletIcon = (platform: string, identifier: string): string => {\n\t// Only Polkadot extensions have hardcoded icons that are safe for SSR\n\tif (platform === \"polkadot\") {\n\t\treturn POLKADOT_EXTENSIONS[identifier]?.icon ?? \"\";\n\t}\n\t// Ethereum icons come from localStorage or live wallets - not here\n\treturn \"\";\n};\n\n/**\n * Error thrown when trying to use a placeholder wallet that hasn't fully loaded yet.\n */\nclass PendingWalletError extends Error {\n\tconstructor(walletId: string) {\n\t\tsuper(\n\t\t\t`Wallet ${walletId} is still loading. Wait for isHydrating to be false before calling connect/disconnect.`,\n\t\t);\n\t\tthis.name = \"PendingWalletError\";\n\t}\n}\n\n/**\n * Converts a CachedWallet to a placeholder wallet for SSR hydration display.\n *\n * The placeholder carries only the SDK-free {@link BaseWallet} fields; the real\n * wallet (with its injected provider/extension/standard-wallet handle) replaces\n * it once it loads. connect/disconnect throw until then.\n */\nexport const hydrateWallet = (cached: CachedWallet): BaseWallet => {\n\tconst { platform, identifier } = parseWalletId(cached.id);\n\n\tconst throwPending = () => {\n\t\tthrow new PendingWalletError(cached.id);\n\t};\n\n\treturn {\n\t\tid: cached.id,\n\t\tplatform: cached.platform,\n\t\ttype: cached.type,\n\t\tname: cached.name,\n\t\ticon: lookupWalletIcon(platform, identifier),\n\t\tisConnected: cached.isConnected,\n\t\tconnect: throwPending,\n\t\tdisconnect: throwPending,\n\t};\n};\n\n/**\n * Converts a CachedAccount to a placeholder account for SSR hydration display.\n *\n * The placeholder carries the SDK-free {@link BaseWalletAccount} fields plus the\n * plain, serializable platform data that lives in the cache — Ethereum `chainId`\n * and the Polkadot key `type`. Those render immediately on reload (no blank →\n * value flicker) and match what the live account will report. Only the SDK\n * handles (`client`/`signer`/`polkadotSigner`) are absent until the real account\n * replaces this placeholder; signing stays gated on `isHydrating` until then.\n */\nexport const hydrateAccount = (cached: CachedAccount): BaseWalletAccount => ({\n\tid: cached.id as WalletAccountId,\n\tplatform: cached.platform,\n\taddress: cached.address,\n\tname: cached.name,\n\twalletId: cached.walletId,\n\twalletName: cached.walletName,\n\t// Spread (not direct keys) so the extra platform fields don't trip the\n\t// excess-property check against BaseWalletAccount; they're read back via the\n\t// platform-specific account types once narrowed by `platform`.\n\t...(cached.platform === \"ethereum\" && { chainId: cached.chainId }),\n\t...(cached.platform === \"polkadot\" && {\n\t\ttype: cached.polkadotAccountType,\n\t}),\n});\n\n/**\n * Converts a wallet to a CachedWallet for storage.\n * Only extracts the serializable properties needed for hydration.\n */\nexport const serializeWallet = (wallet: BaseWallet): CachedWallet => ({\n\tid: wallet.id,\n\tplatform: wallet.platform,\n\ttype: wallet.type,\n\tname: wallet.name,\n\t// Note: icon is NOT stored to save cookie space\n\tisConnected: wallet.isConnected,\n});\n\n/**\n * Converts an account to a CachedAccount for storage.\n * Only extracts the serializable properties needed for hydration. Platform-only\n * fields (Ethereum chainId, Polkadot key type) are read defensively so this\n * stays SDK-free.\n */\nexport const serializeAccount = (\n\taccount: BaseWalletAccount,\n): CachedAccount => ({\n\tid: account.id,\n\tplatform: account.platform,\n\taddress: account.address,\n\tname: account.name,\n\tchainId:\n\t\taccount.platform === \"ethereum\"\n\t\t\t? (account as { chainId?: number }).chainId\n\t\t\t: undefined,\n\tpolkadotAccountType:\n\t\taccount.platform === \"polkadot\"\n\t\t\t? (account as { type?: PolkadotAccountType }).type\n\t\t\t: undefined,\n\twalletId: account.walletId as WalletId,\n\twalletName: account.walletName,\n});\n","import { safeLocalStorage } from \"./storage\";\n\n/**\n * Storage key for the icon cache in localStorage.\n */\nconst ICON_CACHE_KEY = \"kheopskit-icons\";\n\n/**\n * Icon cache type: a map of wallet ID to icon data URI or URL.\n */\ntype IconCache = Record<string, string>;\n\n/**\n * In-memory cache to avoid repeated localStorage reads.\n */\nlet memoryCache: IconCache | null = null;\n\n/**\n * Loads the icon cache from localStorage.\n */\nconst loadCache = (): IconCache => {\n\tif (memoryCache !== null) return memoryCache;\n\n\ttry {\n\t\tconst stored = safeLocalStorage.getItem(ICON_CACHE_KEY);\n\t\tmemoryCache = stored ? (JSON.parse(stored) as IconCache) : {};\n\t} catch {\n\t\tmemoryCache = {};\n\t}\n\treturn memoryCache;\n};\n\n/**\n * Saves the icon cache to localStorage.\n */\nconst saveCache = (cache: IconCache): void => {\n\ttry {\n\t\tsafeLocalStorage.setItem(ICON_CACHE_KEY, JSON.stringify(cache));\n\t\tmemoryCache = cache;\n\t} catch {\n\t\t// localStorage may be full or unavailable\n\t}\n};\n\n/**\n * Gets a cached icon for a wallet.\n * @param walletId - The wallet ID (e.g., \"ethereum:io.talisman\")\n * @returns The cached icon data URI, or undefined if not cached\n */\nexport const getCachedIcon = (walletId: string): string | undefined => {\n\tconst cache = loadCache();\n\treturn cache[walletId] || undefined;\n};\n\n/**\n * Sets multiple cached icons at once.\n * More efficient than calling setCachedIcon multiple times.\n * @param icons - Map of wallet ID to icon\n */\nexport const setCachedIcons = (icons: Record<string, string>): void => {\n\tconst cache = loadCache();\n\tlet changed = false;\n\n\tfor (const [walletId, icon] of Object.entries(icons)) {\n\t\tif (icon && cache[walletId] !== icon) {\n\t\t\tcache[walletId] = icon;\n\t\t\tchanged = true;\n\t\t}\n\t}\n\n\tif (changed) {\n\t\tsaveCache(cache);\n\t}\n};\n","import type { BaseWalletAccount, WalletPlatform } from \"../api/types\";\n\nconst PLATFORM_ORDER: Record<WalletPlatform, number> = {\n\tpolkadot: 0,\n\tethereum: 1,\n\tsolana: 2,\n};\n\n// Group accounts by wallet, surfacing Talisman first (case-insensitive).\nconst byWalletName = (a1: BaseWalletAccount, a2: BaseWalletAccount) => {\n\tif (a1.walletName.toLowerCase() === \"talisman\") return -1;\n\tif (a2.walletName.toLowerCase() === \"talisman\") return 1;\n\treturn a1.walletName.localeCompare(a2.walletName);\n};\n\nexport const sortAccounts = (a1: BaseWalletAccount, a2: BaseWalletAccount) => {\n\t// Sort by platform first: polkadot, then ethereum, then solana\n\tif (a1.platform !== a2.platform)\n\t\treturn PLATFORM_ORDER[a1.platform] - PLATFORM_ORDER[a2.platform];\n\n\t// Then group by wallet name\n\tif (a1.walletName !== a2.walletName) return byWalletName(a1, a2);\n\n\t// Polkadot accounts expose a friendly name; fall back to address\n\tif (a1.platform === \"polkadot\" && a2.platform === \"polkadot\")\n\t\treturn a1.name !== a2.name\n\t\t\t? (a1.name ?? \"\").localeCompare(a2.name ?? \"\")\n\t\t\t: a1.address.localeCompare(a2.address);\n\n\t// Ethereum and Solana accounts disambiguate by id\n\treturn a1.id.localeCompare(a2.id);\n};\n","import type { BaseWallet, WalletPlatform } from \"../api/types\";\n\nconst PLATFORM_ORDER: Record<WalletPlatform, number> = {\n\tpolkadot: 0,\n\tethereum: 1,\n\tsolana: 2,\n};\n\nexport const sortWallets = (w1: BaseWallet, w2: BaseWallet) => {\n\t// Sort by platform first: polkadot, then ethereum, then solana\n\tif (w1.platform !== w2.platform) {\n\t\treturn PLATFORM_ORDER[w1.platform] - PLATFORM_ORDER[w2.platform];\n\t}\n\n\t// Sort by name, but Talisman first\n\tif (w1.name.toLowerCase() === \"talisman\") return -1;\n\tif (w2.name.toLowerCase() === \"talisman\") return 1;\n\n\treturn w1.name.localeCompare(w2.name);\n};\n","import type { CachedAccount, KheopskitPlatform } from \"./types\";\n\n/**\n * Whether a cached account should survive SSR hydration, per its platform\n * plugin's `acceptsCachedAccount` hook. Plugins without the hook (and platforms\n * with no enabled plugin) accept all — matching the pre-plugin behavior where\n * only Polkadot accounts were filtered (by key type).\n */\nexport const acceptsCachedAccount = (\n\tcached: CachedAccount,\n\tplatforms: readonly KheopskitPlatform[],\n): boolean => {\n\tconst plugin = platforms.find((p) => p.platform === cached.platform);\n\treturn plugin?.acceptsCachedAccount?.(cached) ?? true;\n};\n"],"mappings":";;;;;;;;;AAoBA,IAAM,mBAAmB,CAAC,UAAkB,eAA+B;AAE1E,MAAI,aAAa,YAAY;AAC5B,WAAO,oBAAoB,UAAU,GAAG,QAAQ;AAAA,EACjD;AAEA,SAAO;AACR;AAKA,IAAM,qBAAN,cAAiC,MAAM;AAAA,EACtC,YAAY,UAAkB;AAC7B;AAAA,MACC,UAAU,QAAQ;AAAA,IACnB;AACA,SAAK,OAAO;AAAA,EACb;AACD;AASO,IAAM,gBAAgB,CAAC,WAAqC;AAClE,QAAM,EAAE,UAAU,WAAW,IAAI,cAAc,OAAO,EAAE;AAExD,QAAM,eAAe,MAAM;AAC1B,UAAM,IAAI,mBAAmB,OAAO,EAAE;AAAA,EACvC;AAEA,SAAO;AAAA,IACN,IAAI,OAAO;AAAA,IACX,UAAU,OAAO;AAAA,IACjB,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,iBAAiB,UAAU,UAAU;AAAA,IAC3C,aAAa,OAAO;AAAA,IACpB,SAAS;AAAA,IACT,YAAY;AAA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,IAAIA,gBAAe,GAAG,QAAQ;AAAA,EAChE;AAGA,MAAI,GAAG,KAAK,YAAY,MAAM,WAAY,QAAO;AACjD,MAAI,GAAG,KAAK,YAAY,MAAM,WAAY,QAAO;AAEjD,SAAO,GAAG,KAAK,cAAc,GAAG,IAAI;AACrC;;;ACXO,IAAM,uBAAuB,CACnC,QACA,cACa;AACb,QAAM,SAAS,UAAU,KAAK,CAAC,MAAM,EAAE,aAAa,OAAO,QAAQ;AACnE,SAAO,QAAQ,uBAAuB,MAAM,KAAK;AAClD;","names":["PLATFORM_ORDER"]}
@@ -1 +0,0 @@
1
- "use strict";//# sourceMappingURL=chunk-FIAL4HTE.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/kheopskit/kheopskit/packages/core/dist/chunk-FIAL4HTE.js"],"names":[],"mappings":"AAAA","file":"/home/runner/work/kheopskit/kheopskit/packages/core/dist/chunk-FIAL4HTE.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/isEthereumAddress.ts","../src/utils/isSs58Address.ts","../src/utils/isSolanaAddress.ts","../src/utils/isValidAddress.ts","../src/utils/WalletAccountId.ts","../src/api/appKit.ts","../src/api/errors.ts","../src/api/config.ts","../src/api/store.ts","../src/utils/createStore.ts"],"sourcesContent":["import { keccak_256 } from \"@noble/hashes/sha3\";\n\nconst HEX_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst encoder = new TextEncoder();\n\n/**\n * Verifies the EIP-55 mixed-case checksum of an Ethereum address.\n * Dependency-free (keccak via @noble/hashes) so core stays decoupled from viem.\n */\nconst isChecksumValid = (address: string): boolean => {\n\tconst hex = address.slice(2);\n\tconst hash = keccak_256(encoder.encode(hex.toLowerCase()));\n\tfor (let i = 0; i < 40; i++) {\n\t\tconst char = hex.charAt(i);\n\t\tconst isLetter =\n\t\t\t(char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\");\n\t\tif (!isLetter) continue;\n\t\tconst byte = hash[i >> 1] ?? 0;\n\t\tconst nibble = i % 2 === 0 ? byte >> 4 : byte & 0x0f;\n\t\tconst isUpper = char <= \"F\";\n\t\tif (isUpper !== nibble >= 8) return false;\n\t}\n\treturn true;\n};\n\n/**\n * Returns true if `address` is a valid Ethereum address.\n *\n * Mirrors viem's `isAddress` (strict): the shape must be `0x` + 40 hex, and a\n * mixed-case address must pass the EIP-55 checksum. All-lowercase addresses are\n * accepted as non-checksummed.\n */\nexport const isEthereumAddress = (address: string): boolean => {\n\tif (!HEX_ADDRESS.test(address)) return false;\n\tif (address === address.toLowerCase()) return true;\n\treturn isChecksumValid(address);\n};\n","import { blake2b } from \"@noble/hashes/blake2b\";\nimport { base58 } from \"@scure/base\";\n\n// The \"SS58PRE\" prefix used in the SS58 checksum preimage.\nconst SS58PRE = new Uint8Array([0x53, 0x53, 0x35, 0x38, 0x50, 0x52, 0x45]);\n\n/**\n * Returns true if `address` is a valid SS58-encoded 32-byte account id (the\n * only form Substrate wallets inject), verifying the blake2b-512 checksum.\n *\n * Dependency-free (base58 via @scure/base, blake2b via @noble/hashes) so core\n * stays decoupled from polkadot-api.\n */\nexport const isSs58Address = (address: string): boolean => {\n\tif (!address) return false;\n\n\tlet decoded: Uint8Array;\n\ttry {\n\t\tdecoded = base58.decode(address);\n\t} catch {\n\t\treturn false;\n\t}\n\n\t// First byte encodes the network prefix; the high bit is reserved/invalid.\n\tconst firstByte = decoded[0];\n\tif (firstByte === undefined || firstByte & 0b1000_0000) return false;\n\t// The 0b0100_0000 bit marks a 2-byte prefix.\n\tconst prefixLength = firstByte & 0b0100_0000 ? 2 : 1;\n\n\t// AccountId32 layout: prefix + 32-byte pubkey + 2-byte checksum.\n\tif (decoded.length !== prefixLength + 32 + 2) return false;\n\n\tconst body = decoded.subarray(0, decoded.length - 2);\n\tconst preimage = new Uint8Array(SS58PRE.length + body.length);\n\tpreimage.set(SS58PRE);\n\tpreimage.set(body, SS58PRE.length);\n\tconst hash = blake2b(preimage, { dkLen: 64 });\n\n\treturn (\n\t\tdecoded[decoded.length - 2] === hash[0] &&\n\t\tdecoded[decoded.length - 1] === hash[1]\n\t);\n};\n","import { base58 } from \"@scure/base\";\n\n/**\n * Returns true if the value is a valid Solana address: a base58-encoded\n * 32-byte ed25519 public key.\n *\n * Solana addresses carry no checksum, so this is a pure base58 + length check.\n * Dependency-free (base58 via @scure/base) so core stays decoupled from\n * @solana/kit.\n */\nexport const isSolanaAddress = (address: string): boolean => {\n\tif (!address) return false;\n\ttry {\n\t\treturn base58.decode(address).length === 32;\n\t} catch {\n\t\treturn false;\n\t}\n};\n","import { isEthereumAddress } from \"./isEthereumAddress\";\nimport { isSolanaAddress } from \"./isSolanaAddress\";\nimport { isSs58Address } from \"./isSs58Address\";\n\nexport const isValidAddress = (address: string): boolean => {\n\tif (address.startsWith(\"0x\")) return isEthereumAddress(address);\n\t// SS58 (checksummed) and Solana (base58, no checksum) are disjoint: a\n\t// 32-byte Solana pubkey fails SS58 decoding, and an SS58 address decodes to\n\t// more than 32 bytes so it fails the Solana length check.\n\treturn isSs58Address(address) || isSolanaAddress(address);\n};\n","import { isValidAddress } from \"./isValidAddress\";\n\nexport type WalletAccountId = string;\n\nexport const getWalletAccountId = (\n\twalletId: string,\n\taddress: string,\n): WalletAccountId => {\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn `${walletId}::${address}`;\n};\n\nexport const parseWalletAccountId = (accountId: string) => {\n\tif (!accountId) throw new Error(\"Invalid walletAccountId\");\n\tconst [walletId, address] = accountId.split(\"::\");\n\tif (!walletId) throw new Error(\"Missing walletId\");\n\tif (!address || !isValidAddress(address)) throw new Error(\"Invalid address\");\n\treturn { walletId, address };\n};\n","import {\n\tBehaviorSubject,\n\tcombineLatest,\n\tdistinctUntilChanged,\n\tfrom,\n\tmap,\n\tObservable,\n\tof,\n\tshareReplay,\n\tswitchMap,\n\ttap,\n} from \"rxjs\";\nimport { clearCachedObservablesByPrefix } from \"../utils/getCachedObservable\";\nimport { getWalletId } from \"../utils/WalletId\";\nimport type {\n\tAppKitInstance,\n\tEthereumAppKitWallet,\n\tKheopskitConfig,\n\tPolkadotAppKitWallet,\n\tSolanaAppKitWallet,\n} from \"./types\";\n\n/**\n * Dynamically import @reown/appkit/core to avoid loading browser-only code\n * during SSR or in edge runtimes like Cloudflare Workers.\n * The AppKit library uses Lit for web components which requires document.\n */\nconst loadAppKit = async () => {\n\ttry {\n\t\tconst { createAppKit } = await import(\"@reown/appkit/core\");\n\t\treturn createAppKit;\n\t} catch (cause) {\n\t\tconsole.error(\n\t\t\t\"[kheopskit] WalletConnect is configured but @reown/appkit could not be loaded. \" +\n\t\t\t\t\"Install it with `pnpm add @reown/appkit` (or remove config.walletConnect). \" +\n\t\t\t\t\"WalletConnect wallets are disabled; injected wallets still work.\",\n\t\t\tcause,\n\t\t);\n\t\treturn null;\n\t}\n};\n\nconst WALLET_CONNECT_ICON =\n\t\"data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjQwMCIgdmlld0JveD0iMCAwIDQwMCA0MDAiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxjbGlwUGF0aCBpZD0iYSI+PHBhdGggZD0ibTAgMGg0MDB2NDAwaC00MDB6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjYSkiPjxjaXJjbGUgY3g9IjIwMCIgY3k9IjIwMCIgZmlsbD0iIzMzOTZmZiIgcj0iMTk5LjUiIHN0cm9rZT0iIzY2YjFmZiIvPjxwYXRoIGQ9Im0xMjIuNTE5IDE0OC45NjVjNDIuNzkxLTQxLjcyOSAxMTIuMTcxLTQxLjcyOSAxNTQuOTYyIDBsNS4xNSA1LjAyMmMyLjE0IDIuMDg2IDIuMTQgNS40NjkgMCA3LjU1NWwtMTcuNjE3IDE3LjE4Yy0xLjA3IDEuMDQzLTIuODA0IDEuMDQzLTMuODc0IDBsLTcuMDg3LTYuOTExYy0yOS44NTMtMjkuMTExLTc4LjI1My0yOS4xMTEtMTA4LjEwNiAwbC03LjU5IDcuNDAxYy0xLjA3IDEuMDQzLTIuODA0IDEuMDQzLTMuODc0IDBsLTE3LjYxNy0xNy4xOGMtMi4xNC0yLjA4Ni0yLjE0LTUuNDY5IDAtNy41NTV6bTE5MS4zOTcgMzUuNTI5IDE1LjY3OSAxNS4yOWMyLjE0IDIuMDg2IDIuMTQgNS40NjkgMCA3LjU1NWwtNzAuNyA2OC45NDRjLTIuMTM5IDIuMDg3LTUuNjA4IDIuMDg3LTcuNzQ4IDBsLTUwLjE3OC00OC45MzFjLS41MzUtLjUyMi0xLjQwMi0uNTIyLTEuOTM3IDBsLTUwLjE3OCA0OC45MzFjLTIuMTM5IDIuMDg3LTUuNjA4IDIuMDg3LTcuNzQ4IDBsLTcwLjcwMTUtNjguOTQ1Yy0yLjEzOTYtMi4wODYtMi4xMzk2LTUuNDY5IDAtNy41NTVsMTUuNjc5NS0xNS4yOWMyLjEzOTYtMi4wODYgNS42MDg1LTIuMDg2IDcuNzQ4MSAwbDUwLjE3ODkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3Ny00OC45MzJjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMGw1MC4xNzkgNDguOTMyYy41MzUuNTIyIDEuNDAyLjUyMiAxLjkzNyAwbDUwLjE3OS00OC45MzFjMi4xMzktMi4wODcgNS42MDgtMi4wODcgNy43NDggMHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+\";\n\ntype AppKitWallets = {\n\tpolkadot?: PolkadotAppKitWallet;\n\tethereum?: EthereumAppKitWallet;\n\tsolana?: SolanaAppKitWallet;\n};\n\n// Once it exists, the appKit object should never be recreated. Anchored on\n// globalThis so it stays a single instance even if this module is duplicated\n// across bundle chunks (e.g. CJS subpath entries).\nconst APPKIT_SYMBOL = Symbol.for(\"kheopskit.cachedAppKit\");\ntype AppKitGlobal = Record<symbol, Observable<AppKitWallets> | undefined>;\nconst getCachedAppKit = (): Observable<AppKitWallets> | undefined =>\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL];\nconst setCachedAppKit = (\n\tvalue: Observable<AppKitWallets> | undefined,\n): void => {\n\t(globalThis as unknown as AppKitGlobal)[APPKIT_SYMBOL] = value;\n};\n\n/**\n * Clears the cached AppKit observable.\n * Use when configuration changes or for testing purposes.\n * Note: This does NOT destroy the appKit instance created by Reown.\n */\nexport const resetAppKitCache = (): void => {\n\tsetCachedAppKit(undefined);\n};\n\n/**\n * Tap callback that drops a WalletConnect wallet's cached account observables\n * whenever it transitions to disconnected. Covers external disconnects (from\n * the wallet app), which flip `isConnected` via `subscribeProviders` without\n * ever calling `disconnect()`, so a later reconnect rebuilds the account\n * observables against the fresh session instead of a stale closure.\n *\n * Keys are `accounts:<walletId>:...`; the trailing colon scopes the prefix to\n * this wallet and avoids matching a sibling whose id is a string prefix.\n */\nconst clearAccountsCacheOnDisconnect =\n\t(platform: \"polkadot\" | \"ethereum\" | \"solana\") =>\n\t(isConnected: boolean): void => {\n\t\tif (!isConnected)\n\t\t\tclearCachedObservablesByPrefix(\n\t\t\t\t`accounts:${getWalletId(platform, \"walletconnect\")}:`,\n\t\t\t);\n\t};\n\n/**\n * Observable of AppKit (WalletConnect) wallets for the given config.\n *\n * @remarks\n * The AppKit instance is a process-wide singleton (Reown AppKit itself cannot\n * be instantiated twice). The **first** call with a `walletConnect` config wins;\n * later calls with a *different* `walletConnect` config reuse that first\n * instance. Call {@link resetAppKitCache} before re-initialising if the\n * WalletConnect config must change.\n */\nexport const getAppKitWallets$ = (\n\tconfig: KheopskitConfig,\n): Observable<AppKitWallets> => {\n\tif (!config.walletConnect) return of({});\n\n\t// SSR guard - don't try to load AppKit on the server\n\tif (typeof window === \"undefined\") return of({});\n\n\tconst walletConnect = config.walletConnect;\n\n\tlet cachedAppKit = getCachedAppKit();\n\tif (!cachedAppKit) {\n\t\t// Use dynamic import to avoid loading @reown/appkit at module evaluation time\n\t\t// This is critical for SSR and edge runtimes like Cloudflare Workers\n\t\tcachedAppKit = from(loadAppKit()).pipe(\n\t\t\tswitchMap((createAppKit) => {\n\t\t\t\t// @reown/appkit missing (optional peer dep) — degrade gracefully.\n\t\t\t\tif (!createAppKit) return of<AppKitWallets>({});\n\t\t\t\treturn new Observable<AppKitWallets>((subscriber) => {\n\t\t\t\t\tconst appKit = createAppKit({\n\t\t\t\t\t\tprojectId: walletConnect.projectId,\n\t\t\t\t\t\tmetadata: walletConnect.metadata,\n\t\t\t\t\t\t// Loosely typed in WalletConnectConfig to keep @reown/appkit's\n\t\t\t\t\t\t// types out of core; forwarded to AppKit verbatim.\n\t\t\t\t\t\tnetworks: walletConnect.networks as never,\n\t\t\t\t\t\tthemeMode: walletConnect.themeMode,\n\t\t\t\t\t\tthemeVariables: walletConnect.themeVariables as never,\n\t\t\t\t\t\tuniversalProviderConfigOverride: {\n\t\t\t\t\t\t\tmethods: {\n\t\t\t\t\t\t\t\tpolkadot: [\"polkadot_signTransaction\", \"polkadot_signMessage\"],\n\t\t\t\t\t\t\t\tsolana: [\n\t\t\t\t\t\t\t\t\t\"solana_signTransaction\",\n\t\t\t\t\t\t\t\t\t\"solana_signMessage\",\n\t\t\t\t\t\t\t\t\t\"solana_signAndSendTransaction\",\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tallWallets: \"HIDE\",\n\t\t\t\t\t\tdebug: config.debug,\n\t\t\t\t\t\tallowUnsupportedChain: true,\n\t\t\t\t\t});\n\n\t\t\t\t\t// Exposed on wallets as the (decoupled) AppKitInstance escape hatch.\n\t\t\t\t\tconst appKitInstance = appKit as unknown as AppKitInstance;\n\n\t\t\t\t\tconst status$ = new BehaviorSubject({\n\t\t\t\t\t\tisPolkadotConnected: false,\n\t\t\t\t\t\tisEthereumConnected: false,\n\t\t\t\t\t\tisSolanaConnected: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst unsubProviders = appKit.subscribeProviders((providers) => {\n\t\t\t\t\t\tstatus$.next({\n\t\t\t\t\t\t\tisPolkadotConnected: !!providers.polkadot,\n\t\t\t\t\t\t\tisEthereumConnected: !!providers.eip155,\n\t\t\t\t\t\t\tisSolanaConnected: !!providers.solana,\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\n\t\t\t\t\tconst polkadotWallet$ = appKit.chainNamespaces.includes(\"polkadot\")\n\t\t\t\t\t\t? status$.pipe(\n\t\t\t\t\t\t\t\tmap((s) => s.isPolkadotConnected),\n\t\t\t\t\t\t\t\tdistinctUntilChanged(),\n\t\t\t\t\t\t\t\ttap(clearAccountsCacheOnDisconnect(\"polkadot\")),\n\t\t\t\t\t\t\t\tmap((isConnected): PolkadotAppKitWallet => {\n\t\t\t\t\t\t\t\t\tconst walletInfo = appKit.getWalletInfo();\n\t\t\t\t\t\t\t\t\tconst walletId = getWalletId(\"polkadot\", \"walletconnect\");\n\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tid: walletId,\n\t\t\t\t\t\t\t\t\t\tplatform: \"polkadot\",\n\t\t\t\t\t\t\t\t\t\ttype: \"appKit\",\n\t\t\t\t\t\t\t\t\t\tappKit: appKitInstance,\n\t\t\t\t\t\t\t\t\t\tname: walletInfo?.name ?? \"WalletConnect\",\n\t\t\t\t\t\t\t\t\t\ticon: walletInfo?.icon ?? WALLET_CONNECT_ICON,\n\t\t\t\t\t\t\t\t\t\tconnect: async () => {\n\t\t\t\t\t\t\t\t\t\t\tif (!isConnected) await appKit.open();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdisconnect: async () => {\n\t\t\t\t\t\t\t\t\t\t\tif (isConnected) await appKit.disconnect();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tisConnected,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: of(undefined);\n\n\t\t\t\t\tconst ethereumWallet$ = appKit.chainNamespaces.includes(\"eip155\")\n\t\t\t\t\t\t? status$.pipe(\n\t\t\t\t\t\t\t\tmap((s) => s.isEthereumConnected),\n\t\t\t\t\t\t\t\tdistinctUntilChanged(),\n\t\t\t\t\t\t\t\ttap(clearAccountsCacheOnDisconnect(\"ethereum\")),\n\t\t\t\t\t\t\t\tmap((isConnected): EthereumAppKitWallet => {\n\t\t\t\t\t\t\t\t\tconst walletInfo = appKit.getWalletInfo();\n\t\t\t\t\t\t\t\t\tconst walletId = getWalletId(\"ethereum\", \"walletconnect\");\n\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tid: walletId,\n\t\t\t\t\t\t\t\t\t\tplatform: \"ethereum\",\n\t\t\t\t\t\t\t\t\t\ttype: \"appKit\",\n\t\t\t\t\t\t\t\t\t\tappKit: appKitInstance,\n\t\t\t\t\t\t\t\t\t\tname: walletInfo?.name ?? \"WalletConnect\",\n\t\t\t\t\t\t\t\t\t\ticon: walletInfo?.icon ?? WALLET_CONNECT_ICON,\n\t\t\t\t\t\t\t\t\t\tconnect: () => appKit.open(),\n\t\t\t\t\t\t\t\t\t\tdisconnect: async () => {\n\t\t\t\t\t\t\t\t\t\t\tawait appKit.disconnect();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tisConnected,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: of(undefined);\n\n\t\t\t\t\tconst solanaWallet$ = appKit.chainNamespaces.includes(\"solana\")\n\t\t\t\t\t\t? status$.pipe(\n\t\t\t\t\t\t\t\tmap((s) => s.isSolanaConnected),\n\t\t\t\t\t\t\t\tdistinctUntilChanged(),\n\t\t\t\t\t\t\t\ttap(clearAccountsCacheOnDisconnect(\"solana\")),\n\t\t\t\t\t\t\t\tmap((isConnected): SolanaAppKitWallet => {\n\t\t\t\t\t\t\t\t\tconst walletInfo = appKit.getWalletInfo();\n\t\t\t\t\t\t\t\t\tconst walletId = getWalletId(\"solana\", \"walletconnect\");\n\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\tid: walletId,\n\t\t\t\t\t\t\t\t\t\tplatform: \"solana\",\n\t\t\t\t\t\t\t\t\t\ttype: \"appKit\",\n\t\t\t\t\t\t\t\t\t\tappKit: appKitInstance,\n\t\t\t\t\t\t\t\t\t\tname: walletInfo?.name ?? \"WalletConnect\",\n\t\t\t\t\t\t\t\t\t\ticon: walletInfo?.icon ?? WALLET_CONNECT_ICON,\n\t\t\t\t\t\t\t\t\t\tconnect: () => appKit.open(),\n\t\t\t\t\t\t\t\t\t\tdisconnect: async () => {\n\t\t\t\t\t\t\t\t\t\t\tawait appKit.disconnect();\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tisConnected,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: of(undefined);\n\n\t\t\t\t\tconst sub = combineLatest({\n\t\t\t\t\t\tpolkadot: polkadotWallet$,\n\t\t\t\t\t\tethereum: ethereumWallet$,\n\t\t\t\t\t\tsolana: solanaWallet$,\n\t\t\t\t\t}).subscribe(subscriber);\n\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tsub.unsubscribe();\n\t\t\t\t\t\tunsubProviders();\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}),\n\t\t\tshareReplay({ refCount: true, bufferSize: 1 }),\n\t\t);\n\t\tsetCachedAppKit(cachedAppKit);\n\t}\n\n\treturn cachedAppKit;\n};\n","/**\n * Stable error codes thrown by kheopskit. Catch a {@link KheopskitError} and\n * branch on `error.code` instead of matching message strings.\n */\nexport type KheopskitErrorCode =\n\t/** `connect()` called on a wallet that is already connected. */\n\t| \"WALLET_ALREADY_CONNECTED\"\n\t/** `disconnect()` called on a wallet that is not connected. */\n\t| \"WALLET_NOT_CONNECTED\"\n\t/** The wallet does not advertise a capability kheopskit needs to proceed. */\n\t| \"FEATURE_NOT_SUPPORTED\"\n\t/** No active WalletConnect session for the requested operation. */\n\t| \"NO_SESSION\"\n\t/** No provider available for the requested namespace. */\n\t| \"NO_PROVIDER\"\n\t/** The requested chain cannot be used for this operation (e.g. a Solana cluster with no CAIP-2 id over WalletConnect). */\n\t| \"UNSUPPORTED_CHAIN\";\n\n/**\n * Error thrown by kheopskit wallet/account operations. Carries a stable\n * {@link KheopskitErrorCode} and, when relevant, the offending wallet id.\n *\n * @example\n * ```ts\n * try {\n * await wallet.connect();\n * } catch (error) {\n * if (error instanceof KheopskitError && error.code === \"WALLET_ALREADY_CONNECTED\") {\n * // ignore\n * } else throw error;\n * }\n * ```\n */\nexport class KheopskitError extends Error {\n\treadonly code: KheopskitErrorCode;\n\t/** The wallet id this error relates to, when applicable. */\n\treadonly walletId?: string;\n\n\tconstructor(\n\t\tcode: KheopskitErrorCode,\n\t\tmessage: string,\n\t\toptions?: { walletId?: string; cause?: unknown },\n\t) {\n\t\tsuper(`[kheopskit] ${message}`, { cause: options?.cause });\n\t\tthis.name = \"KheopskitError\";\n\t\tthis.code = code;\n\t\tthis.walletId = options?.walletId;\n\t}\n}\n","import type { KheopskitConfig, KheopskitPlatform } from \"./types\";\n\n/**\n * Default storage key for persisting wallet connection state.\n * Can be overridden via config.storageKey to avoid conflicts\n * when running multiple dapps on the same domain.\n */\nexport const DEFAULT_STORAGE_KEY = \"kheopskit\";\n\nconst DEFAULTS = {\n\tautoReconnect: true,\n\tdebug: false,\n\tstorageKey: DEFAULT_STORAGE_KEY,\n\thydrationGracePeriod: 500,\n} satisfies Omit<KheopskitConfig, \"platforms\" | \"walletConnect\">;\n\nexport const resolveConfig = <\n\tconst P extends readonly KheopskitPlatform[] = readonly KheopskitPlatform[],\n>(\n\tconfig?: Partial<KheopskitConfig<P>>,\n): KheopskitConfig<P> => {\n\tconst platforms = (config?.platforms ?? []) as P;\n\n\t// Guard the v4 breaking change: platforms are plugin instances, not strings.\n\t// Catches JS callers (no tsc) and gives agents a fix that names the doc.\n\tconst invalidPlatforms = (platforms as readonly unknown[]).filter(\n\t\t(p) =>\n\t\t\ttypeof p !== \"object\" ||\n\t\t\tp === null ||\n\t\t\ttypeof (p as { getWallets$?: unknown }).getWallets$ !== \"function\",\n\t);\n\tif (invalidPlatforms.length > 0) {\n\t\tthrow new Error(\n\t\t\t\"[kheopskit] config.platforms must contain plugin instances created by the \" +\n\t\t\t\t\"per-platform factories (e.g. platforms: [polkadot(), ethereum(), solana()] \" +\n\t\t\t\t'imported from \"@kheopskit/core/<platform>\"). ' +\n\t\t\t\t`Invalid entries: ${JSON.stringify(invalidPlatforms)}. ` +\n\t\t\t\t'String platform names like \"polkadot\" were removed in v4 — see MIGRATING_TO_V4.md.',\n\t\t);\n\t}\n\n\tif (platforms.length === 0) {\n\t\tconsole.warn(\n\t\t\t\"[kheopskit] No platforms configured; wallets and accounts will be empty. \" +\n\t\t\t\t'Pass e.g. platforms: [polkadot()] from \"@kheopskit/core/polkadot\".',\n\t\t);\n\t}\n\n\treturn Object.assign({}, DEFAULTS, config, { platforms });\n};\n","import { uniq } from \"lodash-es\";\nimport { createStore } from \"../utils/createStore\";\nimport { isWalletPlatform } from \"../utils/isWalletPlatform\";\nimport { cookieStorage, safeLocalStorage } from \"../utils/storage\";\nimport { getWalletAccountId } from \"../utils/WalletAccountId\";\nimport {\n\tisValidWalletId,\n\tparseWalletId,\n\ttype WalletId,\n} from \"../utils/WalletId\";\nimport { DEFAULT_STORAGE_KEY } from \"./config\";\nimport type { CachedAccount, CachedWallet } from \"./types\";\n\ntype KheopskitStoreData = {\n\tautoReconnect?: WalletId[];\n\t/** Cached wallet state for SSR hydration to prevent UI flash */\n\tcachedWallets?: CachedWallet[];\n\t/** Cached account state for SSR hydration to prevent UI flash */\n\tcachedAccounts?: CachedAccount[];\n};\n\ntype CompactWalletEntry = [WalletId, string, 0 | 1, 0 | 1];\ntype CompactPolkadotAccountType = 0 | 1 | 2 | 3;\ntype CompactAccountEntry = [\n\tWalletId,\n\tstring,\n\tstring | null,\n\tnumber | null,\n\t(CompactPolkadotAccountType | null)?,\n];\n\ntype CompactStoreV1 = {\n\tv: 1;\n\t// autoReconnect\n\tr?: WalletId[];\n\t// wallets: [id, name, isConnected(0|1), type(0=injected,1=appKit)?]\n\tw?: CompactWalletEntry[];\n\t// accounts: [walletId, address, name?]\n\ta?: CompactAccountEntry[];\n};\n\nconst DEFAULT_SETTINGS: KheopskitStoreData = {};\n\n/**\n * Validates a cached wallet read from persisted storage. Cached state may have\n * been written by an older (or corrupted) version with a different shape, so we\n * drop anything that wouldn't survive hydration/sort rather than letting it\n * throw at render time. Only the fields downstream code relies on are checked.\n */\nconst isValidCachedWallet = (value: unknown): value is CachedWallet => {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst w = value as Record<string, unknown>;\n\treturn (\n\t\tisValidWalletId(w.id) &&\n\t\tisWalletPlatform(w.platform) &&\n\t\ttypeof w.name === \"string\" &&\n\t\t(w.type === \"injected\" || w.type === \"appKit\") &&\n\t\ttypeof w.isConnected === \"boolean\"\n\t);\n};\n\n/** Validates a cached account read from persisted storage. See {@link isValidCachedWallet}. */\nconst isValidCachedAccount = (value: unknown): value is CachedAccount => {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst a = value as Record<string, unknown>;\n\treturn (\n\t\ttypeof a.id === \"string\" &&\n\t\t!!a.id &&\n\t\tisWalletPlatform(a.platform) &&\n\t\ttypeof a.address === \"string\" &&\n\t\t!!a.address &&\n\t\tisValidWalletId(a.walletId) &&\n\t\ttypeof a.walletName === \"string\"\n\t);\n};\n\nconst toCompactPolkadotAccountType = (\n\ttype: CachedAccount[\"polkadotAccountType\"],\n): CompactPolkadotAccountType | null => {\n\tswitch (type) {\n\t\tcase \"sr25519\":\n\t\t\treturn 0;\n\t\tcase \"ed25519\":\n\t\t\treturn 1;\n\t\tcase \"ecdsa\":\n\t\t\treturn 2;\n\t\tcase \"ethereum\":\n\t\t\treturn 3;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n};\n\nconst fromCompactPolkadotAccountType = (\n\ttype: CompactPolkadotAccountType | null | undefined,\n): CachedAccount[\"polkadotAccountType\"] => {\n\tswitch (type) {\n\t\tcase 0:\n\t\t\treturn \"sr25519\";\n\t\tcase 1:\n\t\t\treturn \"ed25519\";\n\t\tcase 2:\n\t\t\treturn \"ecdsa\";\n\t\tcase 3:\n\t\t\treturn \"ethereum\";\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n};\n\ntype CreateKheopskitStoreOptions = {\n\t/**\n\t * Cookie string for SSR hydration.\n\t * When provided, uses cookieStorage instead of localStorage.\n\t */\n\tssrCookies?: string;\n\t/**\n\t * Custom storage key to namespace the stored data.\n\t * @default \"kheopskit\"\n\t */\n\tstorageKey?: string;\n};\n\n/**\n * Creates a kheopskit store with the appropriate storage backend.\n * Uses cookieStorage when ssrCookies is provided (for SSR hydration),\n * otherwise falls back to safeLocalStorage.\n *\n * @param options - Configuration options for the store\n */\nexport const createKheopskitStore = (\n\toptions: CreateKheopskitStoreOptions = {},\n) => {\n\tconst { ssrCookies, storageKey = DEFAULT_STORAGE_KEY } = options;\n\tconst storage =\n\t\tssrCookies !== undefined\n\t\t\t? createCompactCookieStorage(ssrCookies)\n\t\t\t: safeLocalStorage;\n\tconst store = createStore(storageKey, DEFAULT_SETTINGS, storage);\n\n\tconst addEnabledWalletId = (walletId: WalletId) => {\n\t\tparseWalletId(walletId); // validate walletId\n\t\tstore.mutate((prev) => ({\n\t\t\t...prev,\n\t\t\tautoReconnect: uniq((prev.autoReconnect ?? []).concat(walletId)),\n\t\t}));\n\t};\n\n\tconst removeEnabledWalletId = (walletId: WalletId) => {\n\t\tstore.mutate((prev) => ({\n\t\t\t...prev,\n\t\t\tautoReconnect: uniq(\n\t\t\t\t(prev.autoReconnect ?? []).filter((id) => id !== walletId),\n\t\t\t),\n\t\t}));\n\t};\n\n\tconst getCachedState = () => {\n\t\t// `store.get()` returns whatever JSON was persisted — it may be from an\n\t\t// older version, a different shape, or outright corrupt. Read defensively:\n\t\t// coerce non-objects/arrays to empty and drop any entry that fails\n\t\t// validation, so stale cache degrades to \"start fresh\" instead of throwing\n\t\t// during hydration (which renders eagerly, so a throw blanks the dapp).\n\t\tconst data = store.get() as Partial<KheopskitStoreData> | null | undefined;\n\t\tconst cachedWallets = Array.isArray(data?.cachedWallets)\n\t\t\t? data.cachedWallets\n\t\t\t: [];\n\t\tconst cachedAccounts = Array.isArray(data?.cachedAccounts)\n\t\t\t? data.cachedAccounts\n\t\t\t: [];\n\t\treturn {\n\t\t\twallets: cachedWallets.filter(isValidCachedWallet),\n\t\t\taccounts: cachedAccounts.filter(isValidCachedAccount),\n\t\t};\n\t};\n\n\tconst setCachedState = (\n\t\twallets: CachedWallet[],\n\t\taccounts: CachedAccount[],\n\t) => {\n\t\tstore.mutate((prev) => ({\n\t\t\t...prev,\n\t\t\tcachedWallets: wallets,\n\t\t\tcachedAccounts: accounts,\n\t\t}));\n\t};\n\n\treturn {\n\t\tobservable: store.observable,\n\t\taddEnabledWalletId,\n\t\tremoveEnabledWalletId,\n\t\tgetCachedState,\n\t\tsetCachedState,\n\t};\n};\n\nexport type KheopskitStore = ReturnType<typeof createKheopskitStore>;\n\n/**\n * Cached default store instance, anchored on globalThis so it stays a single\n * instance even if this module is duplicated across bundle chunks (e.g. CJS\n * subpath entries). Lazily initialized on first access to be SSR-safe.\n */\nconst DEFAULT_STORE_SYMBOL = Symbol.for(\"kheopskit.defaultStore\");\n\n/**\n * Gets the default store, creating it on first access.\n * Uses localStorage on client, noop on server.\n * Lazily initialized to avoid SSR issues with module-level code.\n */\nexport const getDefaultStore = (): KheopskitStore => {\n\tconst g = globalThis as unknown as Record<symbol, KheopskitStore | undefined>;\n\tif (!g[DEFAULT_STORE_SYMBOL]) {\n\t\tg[DEFAULT_STORE_SYMBOL] = createKheopskitStore();\n\t}\n\treturn g[DEFAULT_STORE_SYMBOL];\n};\n\n/**\n * @deprecated Use createKheopskitStore() or getDefaultStore() instead.\n * This export is kept for backward compatibility but may cause SSR issues\n * if imported at module level in server environments.\n */\nexport const store = {\n\tget observable() {\n\t\treturn getDefaultStore().observable;\n\t},\n\taddEnabledWalletId: (walletId: WalletId) =>\n\t\tgetDefaultStore().addEnabledWalletId(walletId),\n\tremoveEnabledWalletId: (walletId: WalletId) =>\n\t\tgetDefaultStore().removeEnabledWalletId(walletId),\n\tgetCachedState: () => getDefaultStore().getCachedState(),\n\tsetCachedState: (wallets: CachedWallet[], accounts: CachedAccount[]) =>\n\t\tgetDefaultStore().setCachedState(wallets, accounts),\n};\n\nconst isCompactStore = (value: unknown): value is CompactStoreV1 => {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tif (\"cachedWallets\" in value || \"cachedAccounts\" in value) return false;\n\treturn \"v\" in value || \"w\" in value || \"a\" in value || \"r\" in value;\n};\n\nconst toCompactStore = (data: KheopskitStoreData): CompactStoreV1 => {\n\tconst wallets = data.cachedWallets?.map(\n\t\t(wallet): CompactWalletEntry => [\n\t\t\twallet.id,\n\t\t\twallet.name,\n\t\t\twallet.isConnected ? 1 : 0,\n\t\t\twallet.type === \"appKit\" ? 1 : 0,\n\t\t],\n\t);\n\n\tconst accounts = data.cachedAccounts?.map(\n\t\t(account): CompactAccountEntry => [\n\t\t\taccount.walletId,\n\t\t\taccount.address,\n\t\t\taccount.name ?? null,\n\t\t\taccount.chainId ?? null,\n\t\t\ttoCompactPolkadotAccountType(account.polkadotAccountType),\n\t\t],\n\t);\n\n\treturn {\n\t\tv: 1,\n\t\tr: data.autoReconnect,\n\t\tw: wallets?.length ? wallets : undefined,\n\t\ta: accounts?.length ? accounts : undefined,\n\t};\n};\n\nconst fromCompactStore = (data: CompactStoreV1): KheopskitStoreData => {\n\tconst walletNameMap = new Map<WalletId, string>();\n\n\t// Decode defensively: a compact payload may be malformed (older/corrupt\n\t// cookie, hand-edited). Skip entries with an unparseable wallet id rather\n\t// than throwing, which would crash store initialisation.\n\tconst wallets: CachedWallet[] = [];\n\tfor (const item of Array.isArray(data.w) ? data.w : []) {\n\t\tif (!Array.isArray(item)) continue;\n\t\tconst [id, name, isConnected, type] = item;\n\t\tif (!isValidWalletId(id)) continue;\n\t\tconst { platform } = parseWalletId(id);\n\t\twalletNameMap.set(id, name);\n\t\twallets.push({\n\t\t\tid,\n\t\t\tplatform,\n\t\t\ttype: type === 1 ? \"appKit\" : \"injected\",\n\t\t\tname,\n\t\t\tisConnected: isConnected === 1,\n\t\t});\n\t}\n\n\tconst accounts: CachedAccount[] = [];\n\tfor (const item of Array.isArray(data.a) ? data.a : []) {\n\t\tif (!Array.isArray(item)) continue;\n\t\tconst [walletId, address, name, chainId, polkadotAccountType] = item;\n\t\tif (!isValidWalletId(walletId) || typeof address !== \"string\" || !address)\n\t\t\tcontinue;\n\t\tconst { platform } = parseWalletId(walletId);\n\t\taccounts.push({\n\t\t\tid: getWalletAccountId(walletId, address),\n\t\t\tplatform,\n\t\t\taddress,\n\t\t\tname: name ?? undefined,\n\t\t\tchainId: chainId ?? undefined,\n\t\t\tpolkadotAccountType:\n\t\t\t\tplatform === \"polkadot\"\n\t\t\t\t\t? fromCompactPolkadotAccountType(polkadotAccountType)\n\t\t\t\t\t: undefined,\n\t\t\twalletId,\n\t\t\twalletName: walletNameMap.get(walletId) ?? walletId,\n\t\t});\n\t}\n\n\treturn {\n\t\tautoReconnect: data.r,\n\t\tcachedWallets: wallets,\n\t\tcachedAccounts: accounts,\n\t};\n};\n\nconst decodeStore = (raw: string, fallback: KheopskitStoreData) => {\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\tif (isCompactStore(parsed)) return fromCompactStore(parsed);\n\t\treturn parsed as KheopskitStoreData;\n\t} catch {\n\t\treturn fallback;\n\t}\n};\n\nconst encodeStore = (data: KheopskitStoreData): string =>\n\tJSON.stringify(toCompactStore(data));\n\nconst createCompactCookieStorage = (initialCookies?: string) => {\n\tconst base = cookieStorage(initialCookies);\n\n\treturn {\n\t\tgetItem: (key: string) => {\n\t\t\tconst raw = base.getItem(key);\n\t\t\tif (!raw) return null;\n\t\t\tconst expanded = decodeStore(raw, DEFAULT_SETTINGS);\n\t\t\tif (typeof document !== \"undefined\") {\n\t\t\t\ttry {\n\t\t\t\t\tconst parsed = JSON.parse(raw) as unknown;\n\t\t\t\t\tif (!isCompactStore(parsed)) {\n\t\t\t\t\t\tbase.setItem(key, encodeStore(expanded));\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore malformed cookie during migration\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn JSON.stringify(expanded);\n\t\t},\n\t\tsetItem: (key: string, value: string) => {\n\t\t\tconst expanded = decodeStore(value, DEFAULT_SETTINGS);\n\t\t\tbase.setItem(key, encodeStore(expanded));\n\t\t},\n\t\tremoveItem: base.removeItem,\n\t\tsubscribe: (key: string, callback: (value: string | null) => void) => {\n\t\t\tconst unsubscribe = base.subscribe?.(key, (value) => {\n\t\t\t\tif (!value) {\n\t\t\t\t\tcallback(null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst expanded = decodeStore(value, DEFAULT_SETTINGS);\n\t\t\t\tcallback(JSON.stringify(expanded));\n\t\t\t});\n\t\t\treturn () => {\n\t\t\t\tunsubscribe?.();\n\t\t\t};\n\t\t},\n\t};\n};\n","import { BehaviorSubject } from \"rxjs\";\nimport { type SyncableStorage, safeLocalStorage } from \"./storage\";\n\nexport const createStore = <T>(\n\tkey: string,\n\tdefaultValue: T,\n\tstorage: SyncableStorage = safeLocalStorage,\n) => {\n\tconst subject = new BehaviorSubject<T>(\n\t\tgetStoredData(key, defaultValue, storage),\n\t);\n\n\t// Cross-tab sync via storage.subscribe (uses storage event for localStorage, BroadcastChannel for cookies)\n\t// Only subscribe if window is available (client-side) and storage supports it\n\tlet unsubscribeStorage: (() => void) | undefined;\n\tif (typeof window !== \"undefined\" && storage.subscribe) {\n\t\tunsubscribeStorage = storage.subscribe(key, (newValue) => {\n\t\t\tsubject.next(parseData(newValue, defaultValue));\n\t\t});\n\t}\n\n\tconst update = (val: T) => {\n\t\tsetStoredData(key, val, storage);\n\t\tsubject.next(val);\n\t};\n\n\treturn {\n\t\tobservable: subject.asObservable(),\n\t\tset: (val: T) => update(val),\n\t\tmutate: (transform: (prev: T) => T) =>\n\t\t\tupdate(transform(subject.getValue())),\n\t\tget: () => structuredClone(subject.getValue()),\n\t\t/**\n\t\t * Cleanup subscriptions. Call this when the store is no longer needed.\n\t\t */\n\t\tdestroy: () => {\n\t\t\tunsubscribeStorage?.();\n\t\t\tsubject.complete();\n\t\t},\n\t};\n};\n\nconst parseData = <T>(str: string | null, defaultValue: T): T => {\n\ttry {\n\t\tif (str) return JSON.parse(str);\n\t} catch {\n\t\t// invalid data\n\t}\n\treturn defaultValue;\n};\n\nconst getStoredData = <T>(\n\tkey: string,\n\tdefaultValue: T,\n\tstorage: SyncableStorage,\n): T => {\n\tconst str = storage.getItem(key);\n\treturn parseData(str, defaultValue);\n};\n\nconst setStoredData = <T>(key: string, val: T, storage: SyncableStorage) => {\n\tconst str = JSON.stringify(val);\n\tstorage.setItem(key, str);\n};\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAE3B,IAAM,cAAc;AACpB,IAAM,UAAU,IAAI,YAAY;AAMhC,IAAM,kBAAkB,CAAC,YAA6B;AACrD,QAAM,MAAM,QAAQ,MAAM,CAAC;AAC3B,QAAM,OAAO,WAAW,QAAQ,OAAO,IAAI,YAAY,CAAC,CAAC;AACzD,WAAS,IAAI,GAAG,IAAI,IAAI,KAAK;AAC5B,UAAM,OAAO,IAAI,OAAO,CAAC;AACzB,UAAM,WACJ,QAAQ,OAAO,QAAQ,OAAS,QA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