@nexus-cross/crossx-sdk-core 1.0.0 → 1.0.2-beta.1

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 (29) hide show
  1. package/README.md +2 -2
  2. package/dist/__tests__/mocks/MockWalletProviderPort.d.ts +4 -0
  3. package/dist/__tests__/mocks/MockWalletProviderPort.d.ts.map +1 -1
  4. package/dist/adapters/chain/RemoteChainRegistryAdapter.d.ts +2 -1
  5. package/dist/adapters/chain/RemoteChainRegistryAdapter.d.ts.map +1 -1
  6. package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts +15 -0
  7. package/dist/adapters/confirmation/BrowserConfirmationAdapter.d.ts.map +1 -1
  8. package/dist/adapters/wallet/MockWalletProviderAdapter.d.ts +4 -0
  9. package/dist/adapters/wallet/MockWalletProviderAdapter.d.ts.map +1 -1
  10. package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts +6 -1
  11. package/dist/adapters/wallet/RemoteWalletProviderAdapter.d.ts.map +1 -1
  12. package/dist/core/config/environments.d.ts +28 -0
  13. package/dist/core/config/environments.d.ts.map +1 -0
  14. package/dist/core/ports/ConfirmationPort.d.ts +19 -0
  15. package/dist/core/ports/ConfirmationPort.d.ts.map +1 -1
  16. package/dist/core/ports/WalletProviderPort.d.ts +7 -0
  17. package/dist/core/ports/WalletProviderPort.d.ts.map +1 -1
  18. package/dist/core/types/index.d.ts +0 -6
  19. package/dist/core/types/index.d.ts.map +1 -1
  20. package/dist/core/types/internal.d.ts +2 -0
  21. package/dist/core/types/internal.d.ts.map +1 -1
  22. package/dist/core/usecases/SignOutUseCase.d.ts +2 -2
  23. package/dist/core/usecases/SignOutUseCase.d.ts.map +1 -1
  24. package/dist/index.cjs +238 -78
  25. package/dist/index.js +1223 -933
  26. package/dist/sdk/CROSSxSDK.d.ts +31 -2
  27. package/dist/sdk/CROSSxSDK.d.ts.map +1 -1
  28. package/dist/sdk/factory.d.ts.map +1 -1
  29. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var Ss = Object.defineProperty;
2
- var Es = (r, e, s) => e in r ? Ss(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
- var b = (r, e, s) => Es(r, typeof e != "symbol" ? e + "" : e, s);
4
- import { decodeJwt as Ts } from "jose";
1
+ var Ts = Object.defineProperty;
2
+ var Is = (r, e, s) => e in r ? Ts(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var v = (r, e, s) => Is(r, typeof e != "symbol" ? e + "" : e, s);
4
+ import { decodeJwt as As } from "jose";
5
5
  var p = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(p || {});
6
6
  class _ extends Error {
7
7
  constructor(e, s, t) {
@@ -16,7 +16,7 @@ class _ extends Error {
16
16
  };
17
17
  }
18
18
  }
19
- const qe = {
19
+ const We = {
20
20
  // ─── CROSS ────────────────────────────────────────────
21
21
  CROSS_MAINNET: {
22
22
  caipId: "eip155:612055",
@@ -66,19 +66,19 @@ const qe = {
66
66
  testnet: !0
67
67
  }
68
68
  }, $n = Object.fromEntries(
69
- Object.entries(qe).map(([r, e]) => [r, e.caipId])
70
- ), As = new Map(
71
- Object.values(qe).map((r) => [r.caipId, r])
69
+ Object.entries(We).map(([r, e]) => [r, e.caipId])
70
+ ), Rs = new Map(
71
+ Object.values(We).map((r) => [r.caipId, r])
72
72
  );
73
73
  new Map(
74
- Object.values(qe).map((r) => [r.chainId, r])
74
+ Object.values(We).map((r) => [r.chainId, r])
75
75
  );
76
- const Is = { symbol: "", decimals: 18 };
77
- function Ke(r) {
76
+ const Os = { symbol: "", decimals: 18 };
77
+ function ze(r) {
78
78
  var e;
79
- return ((e = As.get(r)) == null ? void 0 : e.nativeCurrency) ?? Is;
79
+ return ((e = Rs.get(r)) == null ? void 0 : e.nativeCurrency) ?? Os;
80
80
  }
81
- class Rs {
81
+ class Cs {
82
82
  constructor(e, s) {
83
83
  this.sdk = e, this.chainId = s, this._listeners = /* @__PURE__ */ new Map();
84
84
  }
@@ -164,36 +164,36 @@ class Rs {
164
164
  };
165
165
  }
166
166
  }
167
- let me = null;
168
- function mt(r) {
169
- me = r;
167
+ let we = null;
168
+ function wt(r) {
169
+ we = r;
170
170
  }
171
171
  const f = {
172
172
  log(...r) {
173
- if (me) {
174
- me.log(...r);
173
+ if (we) {
174
+ we.log(...r);
175
175
  return;
176
176
  }
177
177
  },
178
178
  warn(...r) {
179
- if (me) {
180
- me.warn(...r);
179
+ if (we) {
180
+ we.warn(...r);
181
181
  return;
182
182
  }
183
183
  },
184
184
  error(...r) {
185
- if (me) {
186
- me.error(...r);
185
+ if (we) {
186
+ we.error(...r);
187
187
  return;
188
188
  }
189
189
  }
190
- }, ze = "crossx_access_token", Ne = "crossx_refresh_token", Pe = "crossx_user_info";
191
- class Os {
190
+ }, Ye = "crossx_access_token", Ne = "crossx_refresh_token", Pe = "crossx_user_info";
191
+ class ks {
192
192
  constructor(e, s, t, n, o, i, a) {
193
193
  this.config = e, this.storage = s, this.crypto = t, this.oauth = n, this.transport = o, this.walletProvider = i, this.tokenStore = a, this._refreshPromise = null;
194
194
  }
195
195
  get useCookieAuth() {
196
- return this.config.authMode !== "token";
196
+ return this.config.authMode === "cookie";
197
197
  }
198
198
  /**
199
199
  * 서버 응답의 에러 코드 확인.
@@ -223,43 +223,43 @@ class Os {
223
223
  const c = e == null ? void 0 : e.provider;
224
224
  let l = "/login";
225
225
  c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
226
- const { oauthServiceUrl: d, authApiUrl: g } = this.config, w = `${d}${l}`;
227
- f.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, w);
228
- const m = await this.oauth.openAuth({
229
- authUrl: w,
226
+ const { oauthServiceUrl: d, authApiUrl: g } = this.config, m = `${d}${l}`;
227
+ f.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, m);
228
+ const x = await this.oauth.openAuth({
229
+ authUrl: m,
230
230
  expectedOrigin: new URL(d).origin
231
231
  });
232
- f.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", m.length, ")");
233
- const { accessToken: x, refreshToken: A } = await this.exchangeFirebaseToken(m, g);
234
- let E, C;
232
+ f.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", x.length, ")");
233
+ const { accessToken: w, refreshToken: b } = await this.exchangeFirebaseToken(x, g);
234
+ let S, E;
235
235
  try {
236
- const $ = this.crypto.decodeJWT(m);
237
- C = (n = $.firebase) == null ? void 0 : n.sign_in_provider;
238
- const B = ((o = $.firebase) == null ? void 0 : o.identities) ?? {};
239
- C === "google.com" ? E = (i = B["google.com"]) == null ? void 0 : i[0] : C === "apple.com" && (E = (a = B["apple.com"]) == null ? void 0 : a[0]), f.log("[CROSSx] OAuth provider sub 추출 — provider:", C, "hasProviderSub:", !!E);
236
+ const M = this.crypto.decodeJWT(x);
237
+ E = (n = M.firebase) == null ? void 0 : n.sign_in_provider;
238
+ const D = ((o = M.firebase) == null ? void 0 : o.identities) ?? {};
239
+ E === "google.com" ? S = (i = D["google.com"]) == null ? void 0 : i[0] : E === "apple.com" && (S = (a = D["apple.com"]) == null ? void 0 : a[0]), f.log("[CROSSx] OAuth provider sub 추출 — provider:", E, "hasProviderSub:", !!S);
240
240
  } catch {
241
241
  f.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
242
242
  }
243
- if (x) {
244
- const $ = this.crypto.decodeJWT(x);
245
- f.log("[CROSSx] access_token 디코딩 — sub:", $.sub, "exp:", $.exp);
246
- const B = await this.crypto.verifyJWT(x);
247
- if (t = B.signatureVerified ?? !1, !B.valid)
243
+ if (w) {
244
+ const M = this.crypto.decodeJWT(w);
245
+ f.log("[CROSSx] access_token 디코딩 — sub:", M.sub, "exp:", M.exp);
246
+ const D = await this.crypto.verifyJWT(w);
247
+ if (t = D.signatureVerified ?? !1, !D.valid)
248
248
  throw f.error("[CROSSx] access_token 검증 실패"), new Error("Invalid access token");
249
- const F = B.payload;
249
+ const B = D.payload;
250
250
  s = {
251
- id: F.sub,
252
- email: F.email,
253
- signInProvider: C,
254
- providerSub: E
255
- }, this.tokenStore.set(x), this.useCookieAuth || (await this.storage.set(ze, x), A && await this.storage.set(Ne, A));
251
+ id: B.sub,
252
+ email: B.email,
253
+ signInProvider: E,
254
+ providerSub: S
255
+ }, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(Ye, w), b && await this.storage.set(Ne, b));
256
256
  } else {
257
- const $ = this.crypto.decodeJWT(m);
257
+ const M = this.crypto.decodeJWT(x);
258
258
  s = {
259
- id: $.sub,
260
- email: $.email,
261
- signInProvider: C,
262
- providerSub: E
259
+ id: M.sub,
260
+ email: M.email,
261
+ signInProvider: E,
262
+ providerSub: S
263
263
  }, f.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
264
264
  }
265
265
  f.log("[CROSSx] 사용자 정보 — id:", s.id);
@@ -370,7 +370,7 @@ class Os {
370
370
  const t = await this.silentRefresh();
371
371
  t && this.tokenStore.set(t);
372
372
  } else {
373
- const t = await this.storage.get(ze), n = await this.storage.get(Ne);
373
+ const t = await this.storage.get(Ye), n = await this.storage.get(Ne);
374
374
  if (f.log(
375
375
  "[CROSSx] restoreSession — access_token:",
376
376
  t ? "있음" : "없음",
@@ -429,7 +429,7 @@ class Os {
429
429
  if (!c)
430
430
  throw new _(p.AUTH_FAILED, "Silent refresh failed: no token in response");
431
431
  if (this.tokenStore.set(c), !t) {
432
- await this.storage.set(ze, c);
432
+ await this.storage.set(Ye, c);
433
433
  const l = this.extractRefreshToken(a);
434
434
  l && await this.storage.set(Ne, l);
435
435
  }
@@ -451,16 +451,16 @@ class Os {
451
451
  return f.log("[CROSSx][Migration Phase 2] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
452
452
  }
453
453
  }
454
- const Cs = "crossx_access_token", Ns = "crossx_refresh_token", Ps = "crossx_user_info";
455
- class ks {
454
+ const Ns = "crossx_access_token", Ps = "crossx_refresh_token", Ls = "crossx_user_info";
455
+ class Ds {
456
456
  constructor(e, s, t) {
457
457
  this.config = e, this.storage = s, this.tokenStore = t;
458
458
  }
459
459
  async execute() {
460
- this.tokenStore.clear(), this.config.authMode === "token" && (await this.storage.remove(Cs), await this.storage.remove(Ns)), await this.storage.remove(Ps);
460
+ this.tokenStore.clear(), this.config.authMode !== "cookie" && (await this.storage.remove(Ns), await this.storage.remove(Ps)), await this.storage.remove(Ls);
461
461
  }
462
462
  }
463
- class Ls {
463
+ class $s {
464
464
  constructor(e, s) {
465
465
  this.storage = e, this.walletProvider = s;
466
466
  }
@@ -477,7 +477,7 @@ class Ls {
477
477
  };
478
478
  }
479
479
  }
480
- class Ds {
480
+ class Bs {
481
481
  constructor(e, s) {
482
482
  this.chainRegistry = e, this.transport = s;
483
483
  }
@@ -509,7 +509,7 @@ class Ds {
509
509
  return a == null ? void 0 : a.result;
510
510
  }
511
511
  }
512
- class $s {
512
+ class Ms {
513
513
  constructor() {
514
514
  this.listeners = /* @__PURE__ */ new Map();
515
515
  }
@@ -532,17 +532,56 @@ class $s {
532
532
  this.listeners.clear();
533
533
  }
534
534
  }
535
- const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA00", bt = 130, vt = 6, St = 18, Hs = 0, Gs = 30 * 1e3, Z = class Z extends $s {
536
- constructor(e, s, t, n, o, i, a, c, l) {
537
- super(), this.storage = s, this.crypto = t, this.transport = n, this.oauth = o, this.walletProvider = i, this.tokenStore = a, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), e.logger && mt(e.logger), this.confirmation = c, this.chainRegistry = l, this.jsonRpc = new Ds(l, n), this.signInUseCase = new Os(
538
- e,
539
- s,
535
+ const Ue = {
536
+ production: {
537
+ oauthServiceUrl: "https://cross-wallet-oauth.crosstoken.io",
538
+ authApiUrl: "https://cross-auth.crosstoken.io",
539
+ walletGatewayUrl: "https://embedded-wallet-gateway.crosstoken.io/api/v1"
540
+ },
541
+ staging: {
542
+ oauthServiceUrl: "https://stg-cross-wallet-oauth.crosstoken.io",
543
+ authApiUrl: "https://stg-cross-auth.crosstoken.io",
544
+ walletGatewayUrl: "https://stg-embedded-wallet-gateway.crosstoken.io/api/v1"
545
+ },
546
+ development: {
547
+ oauthServiceUrl: "https://dev-cross-wallet-oauth.crosstoken.io",
548
+ authApiUrl: "https://dev-cross-auth.crosstoken.io",
549
+ walletGatewayUrl: "https://dev-embedded-wallet-gateway.crosstoken.io/api/v1"
550
+ }
551
+ }, Us = "/crossx.config.json";
552
+ function yt(r) {
553
+ const e = r.environment;
554
+ return e && e in Ue ? Ue[e] : null;
555
+ }
556
+ async function Fs() {
557
+ try {
558
+ if (typeof __CROSSX_CONFIG__ < "u") {
559
+ const r = typeof __CROSSX_CONFIG__ == "string" ? JSON.parse(__CROSSX_CONFIG__) : __CROSSX_CONFIG__, e = yt(r);
560
+ if (e) return e;
561
+ }
562
+ } catch {
563
+ }
564
+ try {
565
+ const r = await fetch(Us);
566
+ if (r.ok) {
567
+ const e = await r.json(), s = yt(e);
568
+ if (s) return s;
569
+ }
570
+ } catch {
571
+ }
572
+ return Ue.production;
573
+ }
574
+ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA00", St = 130, Et = 6, Tt = 18, js = 0, Vs = 30 * 1e3, X = class X extends Ms {
575
+ constructor(e, s, t, n, o, i, a, c, l, d) {
576
+ super(), this.storage = t, this.crypto = n, this.transport = o, this.oauth = i, this.walletProvider = a, this.tokenStore = c, this.initialized = !1, this.authenticated = !1, this.userId = null, this.address = null, this.userEmail = null, this.loginType = null, this.providerSub = null, this.tokenSignatureVerified = !1, this._config = Object.freeze({ ...e }), this.internalConfig = e, this.adapterConfig = s, e.logger && wt(e.logger), this.confirmation = l, this.chainRegistry = d, this.jsonRpc = new Bs(d, o), this.signInUseCase = new ks(
577
+ this.internalConfig,
540
578
  t,
541
- o,
542
579
  n,
543
580
  i,
544
- a
545
- ), this.signOutUseCase = new ks(e, s, a), this.migrateWalletUseCase = new Ls(s, i);
581
+ o,
582
+ a,
583
+ c
584
+ ), this.signOutUseCase = new Ds(this.internalConfig, t, c), this.migrateWalletUseCase = new $s(t, a);
546
585
  }
547
586
  get config() {
548
587
  return this._config;
@@ -563,10 +602,12 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
563
602
  */
564
603
  async initialize() {
565
604
  if (this.initialized) return this.authenticated ? { success: !0, address: this.address ?? void 0 } : null;
566
- console.log("[CROSSx SDK] v1.0.0 initializing...");
605
+ console.log("[CROSSx SDK] v1.0.1 initializing...");
567
606
  try {
568
- const e = await this.signInUseCase.restoreSession();
569
- return e != null && e.success && this.applyAuthResult(e), this.initialized = !0, this.emit("initialized", { restored: !!(e != null && e.success) }), e ?? null;
607
+ const e = await Fs();
608
+ this.internalConfig.oauthServiceUrl = e.oauthServiceUrl, this.internalConfig.authApiUrl = e.authApiUrl, this.internalConfig.walletGatewayUrl = e.walletGatewayUrl, this.adapterConfig.gatewayUrl = e.walletGatewayUrl;
609
+ const s = await this.signInUseCase.restoreSession();
610
+ return s != null && s.success && this.applyAuthResult(s), this.initialized = !0, this.emit("initialized", { restored: !!(s != null && s.success) }), s ?? null;
570
611
  } catch (e) {
571
612
  throw new _(p.AUTH_NOT_INITIALIZED, "SDK initialization failed", e);
572
613
  }
@@ -707,7 +748,37 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
707
748
  * @returns `[{ address, index }]` 형식의 배열
708
749
  */
709
750
  async getAddresses() {
710
- return this.ensureAuthenticated(), this.address ? [{ address: this.address, index: 0 }] : [];
751
+ return this.ensureAuthenticated(), this.userId ? this.walletProvider.getAddresses(this.userId) : [];
752
+ }
753
+ /**
754
+ * 연결된 지갑 선택 모달을 표시합니다.
755
+ *
756
+ * 사용자의 전체 지갑 목록을 조회하여 선택 UI를 표시합니다.
757
+ * "add a wallet" 클릭 시 새 지갑이 파생되어 목록에 추가되며,
758
+ * 모달은 사용자가 지갑을 선택하거나 닫을 때까지 유지됩니다.
759
+ *
760
+ * SDK 내부에 "활성 지갑" 상태를 저장하지 않습니다.
761
+ * 반환된 index를 서명/전송 시 opts.index로 전달하세요.
762
+ *
763
+ * @returns 선택된 지갑 `{ address, index }` 또는 닫기 시 `null`
764
+ *
765
+ * @example
766
+ * const wallet = await sdk.selectWallet();
767
+ * if (wallet) {
768
+ * await sdk.signMessage(chainId, message, { index: wallet.index });
769
+ * }
770
+ */
771
+ async selectWallet() {
772
+ if (this.ensureAuthenticated(), !this.userId)
773
+ throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
774
+ const e = await this.walletProvider.getAddresses(this.userId);
775
+ return this.confirmation.showWalletSelector(
776
+ e,
777
+ async () => {
778
+ const s = e.length, n = { address: (await this.walletProvider.getAddress(this.userId, s)).address, index: s };
779
+ return e.push(n), n;
780
+ }
781
+ );
711
782
  }
712
783
  // ============================================================================
713
784
  // 체인 조회
@@ -863,7 +934,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
863
934
  throw new _(p.AUTH_NOT_AUTHENTICATED, "User ID not found");
864
935
  if (!this.walletProvider.signTypedData)
865
936
  throw new _(p.NOT_IMPLEMENTED, "signTypedData is not implemented");
866
- Z.validateTypedDataChainId(e, s);
937
+ X.validateTypedDataChainId(e, s);
867
938
  const n = await this.walletProvider.getAddress(this.userId, (t == null ? void 0 : t.index) ?? 0);
868
939
  let o;
869
940
  if (this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign-typed-data", { typedData: s, from: n.address })).uuid), !await this.confirmation.requestConfirmation({
@@ -884,7 +955,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
884
955
  o,
885
956
  n.address
886
957
  );
887
- return Z.validateSignatureFormat(a.signature), {
958
+ return X.validateSignatureFormat(a.signature), {
888
959
  chainId: e,
889
960
  signature: a.signature,
890
961
  address: n.address
@@ -913,7 +984,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
913
984
  * });
914
985
  */
915
986
  async signTypedDataOffchain(e, s) {
916
- return this.signTypedData(Z.OFFCHAIN_CHAIN_ID, e, s);
987
+ return this.signTypedData(X.OFFCHAIN_CHAIN_ID, e, s);
917
988
  }
918
989
  // ============================================================================
919
990
  // 트랜잭션
@@ -930,7 +1001,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
930
1001
  const n = await this.withResolvedGasAndFee(s, e);
931
1002
  let o;
932
1003
  this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign", { tx: n })).uuid);
933
- const i = Ke(e);
1004
+ const i = ze(e);
934
1005
  if (!await this.confirmation.requestConfirmation({
935
1006
  type: "sign",
936
1007
  chainId: e,
@@ -956,7 +1027,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
956
1027
  t == null ? void 0 : t.index,
957
1028
  o
958
1029
  );
959
- return Z.validateSignedTxFormat(c.signature), {
1030
+ return X.validateSignedTxFormat(c.signature), {
960
1031
  chainId: e,
961
1032
  signedTx: c.signature,
962
1033
  txHash: c.txHash ?? ""
@@ -983,7 +1054,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
983
1054
  const n = await this.withResolvedGasAndFee(s, e);
984
1055
  let o;
985
1056
  this.walletProvider.prepare && (o = (await this.walletProvider.prepare("send", { tx: n })).uuid);
986
- const i = Ke(e);
1057
+ const i = ze(e);
987
1058
  if (!await this.confirmation.requestConfirmation({
988
1059
  type: "send",
989
1060
  chainId: e,
@@ -1049,7 +1120,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1049
1120
  * @param opts.timeoutMs 최대 대기 시간 (기본 60000ms)
1050
1121
  */
1051
1122
  async waitForTxAndGetReceipt(e, s, t = {}) {
1052
- const n = t.intervalMs ?? Ms, o = Fs, i = t.timeoutMs ?? wt, a = Date.now() + i;
1123
+ const n = t.intervalMs ?? Gs, o = qs, i = t.timeoutMs ?? bt, a = Date.now() + i;
1053
1124
  let c = n;
1054
1125
  for (; Date.now() < a; ) {
1055
1126
  const l = await this.getTransactionReceipt(e, s);
@@ -1077,37 +1148,37 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1077
1148
  * logger.log(receipt.status); // '0x1' | '0x0'
1078
1149
  */
1079
1150
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1080
- var w, m;
1081
- const { txHash: n } = await this.sendTransaction(e, s), o = t.intervalMs ?? ((w = this._config.receiptPolling) == null ? void 0 : w.intervalMs) ?? Bs, i = t.timeoutMs ?? ((m = this._config.receiptPolling) == null ? void 0 : m.timeoutMs) ?? wt, a = Ke(e), c = s.from ?? "";
1082
- let l, d;
1083
- const g = this.waitForTxAndGetReceipt(n, e, { intervalMs: o, timeoutMs: i }).then((x) => {
1084
- l = x;
1085
- const A = BigInt(x.gasUsed) * BigInt(x.effectiveGasPrice), E = s.value ? BigInt(s.value) : 0n, C = Z.formatTxAmount(s.value, a.symbol, a.decimals), q = Z.formatTxAmount("0x" + A.toString(16), a.symbol, a.decimals), $ = Z.formatTxAmount("0x" + (E + A).toString(16), a.symbol, a.decimals);
1151
+ var b, S;
1152
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Hs, l = o ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? bt, d = ze(e), g = s.from ?? "";
1153
+ let m, x;
1154
+ const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((E) => {
1155
+ m = E;
1156
+ const q = BigInt(E.gasUsed) * BigInt(E.effectiveGasPrice), M = s.value ? BigInt(s.value) : 0n, D = X.formatTxAmount(s.value, d.symbol, d.decimals), B = X.formatTxAmount("0x" + q.toString(16), d.symbol, d.decimals), Q = X.formatTxAmount("0x" + (M + q).toString(16), d.symbol, d.decimals);
1086
1157
  return {
1087
1158
  chainId: e,
1088
- txHash: n,
1089
- from: x.from,
1090
- to: x.to ?? s.to,
1091
- amount: C,
1092
- fees: q,
1093
- total: $,
1094
- nativeSymbol: a.symbol,
1095
- status: x.status === "0x1" ? "success" : "reverted"
1159
+ txHash: a,
1160
+ from: E.from,
1161
+ to: E.to ?? s.to,
1162
+ amount: D,
1163
+ fees: B,
1164
+ total: Q,
1165
+ nativeSymbol: d.symbol,
1166
+ status: E.status === "0x1" ? "success" : "reverted"
1096
1167
  };
1097
- }).catch((x) => (d = x instanceof Error ? x : new Error(String(x)), {
1168
+ }).catch((E) => (x = E instanceof Error ? E : new Error(String(E)), {
1098
1169
  chainId: e,
1099
- txHash: n,
1100
- from: c,
1170
+ txHash: a,
1171
+ from: g,
1101
1172
  to: s.to,
1102
- amount: Z.formatTxAmount(s.value, a.symbol, a.decimals),
1103
- nativeSymbol: a.symbol,
1173
+ amount: X.formatTxAmount(s.value, d.symbol, d.decimals),
1174
+ nativeSymbol: d.symbol,
1104
1175
  status: "timeout"
1105
1176
  }));
1106
1177
  if (await this.confirmation.showTransactionProgress(
1107
- { chainId: e, txHash: n, from: c, to: s.to },
1108
- g
1109
- ), d) throw d;
1110
- return { chainId: e, txHash: n, receipt: l };
1178
+ { chainId: e, txHash: a, from: g, to: s.to },
1179
+ w
1180
+ ), x) throw x;
1181
+ return { chainId: e, txHash: a, receipt: m };
1111
1182
  }
1112
1183
  // ============================================================================
1113
1184
  // Gas 조회
@@ -1223,7 +1294,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1223
1294
  return { wei: "0x0", formatted: "0", chainId: e };
1224
1295
  try {
1225
1296
  const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
1226
- return { wei: n, formatted: Z.formatWei(n), chainId: e };
1297
+ return { wei: n, formatted: X.formatWei(n), chainId: e };
1227
1298
  } catch (t) {
1228
1299
  if (t instanceof _) throw t;
1229
1300
  const n = t instanceof Error ? t.message : String(t);
@@ -1235,7 +1306,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1235
1306
  try {
1236
1307
  const s = BigInt(e);
1237
1308
  if (s === 0n) return "0";
1238
- const t = 10n ** BigInt(St), n = s / t, i = (s % t).toString().padStart(St, "0").replace(/0+$/, "").slice(0, vt);
1309
+ const t = 10n ** BigInt(Tt), n = s / t, i = (s % t).toString().padStart(Tt, "0").replace(/0+$/, "").slice(0, Et);
1239
1310
  return i ? `${n}.${i}` : `${n}`;
1240
1311
  } catch {
1241
1312
  return "?";
@@ -1260,7 +1331,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1260
1331
  * const client = createWalletClient({ transport: custom(provider) });
1261
1332
  */
1262
1333
  getProvider(e) {
1263
- return this.ensureAuthenticated(), new Rs(this, e);
1334
+ return this.ensureAuthenticated(), new Cs(this, e);
1264
1335
  }
1265
1336
  /**
1266
1337
  * 범용 JSON-RPC 요청 — 노드에 직접 연결.
@@ -1278,7 +1349,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1278
1349
  } catch (n) {
1279
1350
  if (n instanceof _) throw n;
1280
1351
  const o = n instanceof Error ? n.message : String(n);
1281
- throw new _(p.UNKNOWN_ERROR, `rpcRequest failed [${e}] (${t}): ${o}`, n);
1352
+ throw new _(p.UNKNOWN_ERROR, `walletRpc failed [${e}] (${t}): ${o}`, n);
1282
1353
  }
1283
1354
  }
1284
1355
  // ============================================================================
@@ -1293,7 +1364,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1293
1364
  try {
1294
1365
  const n = BigInt(e);
1295
1366
  if (n === 0n) return;
1296
- const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, vt).replace(/0+$/, "");
1367
+ const o = 10n ** BigInt(t), i = n / o, c = (n % o).toString().padStart(t, "0").slice(0, Et).replace(/0+$/, "");
1297
1368
  return `${c ? `${i}.${c}` : `${i}`} ${s}`;
1298
1369
  } catch {
1299
1370
  return;
@@ -1349,12 +1420,12 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1349
1420
  f.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
1350
1421
  const l = await this.getBaseFeePerGas(s);
1351
1422
  if (l) {
1352
- const d = yt;
1423
+ const d = vt;
1353
1424
  c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, f.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
1354
1425
  } else
1355
- c.gasPrice = Us, f.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1426
+ c.gasPrice = Ws, f.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1356
1427
  }
1357
- return !i && a && (c.maxPriorityFeePerGas = yt, f.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1428
+ return !i && a && (c.maxPriorityFeePerGas = vt, f.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1358
1429
  }
1359
1430
  /**
1360
1431
  * EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
@@ -1363,7 +1434,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1363
1434
  * - chainId가 '0' → domain.chainId가 없거나 0이어야 함
1364
1435
  */
1365
1436
  static validateTypedDataChainId(e, s) {
1366
- const t = Z.extractDomainChainId(s);
1437
+ const t = X.extractDomainChainId(s);
1367
1438
  if (e === "0") {
1368
1439
  if (t !== void 0 && t !== 0)
1369
1440
  throw new _(
@@ -1401,10 +1472,10 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1401
1472
  const s = e.startsWith("0x") ? e.slice(2) : e;
1402
1473
  if (!/^[0-9a-fA-F]+$/.test(s))
1403
1474
  throw new _(p.SIGNATURE_FAILED, "Invalid signature: not a valid hex string");
1404
- if (s.length !== bt)
1475
+ if (s.length !== St)
1405
1476
  throw new _(
1406
1477
  p.SIGNATURE_FAILED,
1407
- `Invalid signature length: expected ${bt} hex chars (65 bytes), got ${s.length}`
1478
+ `Invalid signature length: expected ${St} hex chars (65 bytes), got ${s.length}`
1408
1479
  );
1409
1480
  }
1410
1481
  /** RLP-encoded signed transaction 형식 검증 */
@@ -1442,7 +1513,7 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1442
1513
  /** AuthResult를 내부 상태에 반영합니다. */
1443
1514
  applyAuthResult(e) {
1444
1515
  var s, t, n, o;
1445
- this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = Z.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this.emit("authChanged", {
1516
+ this.authenticated = e.success, this.userId = ((s = e.user) == null ? void 0 : s.id) ?? null, this.address = e.address ?? null, this.userEmail = ((t = e.user) == null ? void 0 : t.email) ?? null, this.providerSub = ((n = e.user) == null ? void 0 : n.providerSub) ?? null, this.loginType = X.normalizeLoginType((o = e.user) == null ? void 0 : o.signInProvider), this.tokenSignatureVerified = e.tokenSignatureVerified ?? !1, this.emit("authChanged", {
1446
1517
  isAuthenticated: this.authenticated,
1447
1518
  address: this.address,
1448
1519
  userId: this.userId
@@ -1484,12 +1555,12 @@ const Bs = 2e3, wt = 6e4, Ms = 1e3, Fs = 1e4, Us = "0x77359400", yt = "0x3B9ACA0
1484
1555
  * dispose 후 SDK 인스턴스는 더 이상 사용할 수 없습니다.
1485
1556
  */
1486
1557
  dispose() {
1487
- this.clearAuthState(), this.tokenStore.clear(), this.initialized = !1, this.removeAllListeners(), mt(null);
1558
+ this.clearAuthState(), this.tokenStore.clear(), this.initialized = !1, this.removeAllListeners(), wt(null);
1488
1559
  }
1489
1560
  };
1490
- Z.OFFCHAIN_CHAIN_ID = "0";
1491
- let tt = Z;
1492
- class qs {
1561
+ X.OFFCHAIN_CHAIN_ID = "0";
1562
+ let st = X;
1563
+ class Ks {
1493
1564
  constructor() {
1494
1565
  this.prefix = "crossx_";
1495
1566
  }
@@ -1526,8 +1597,8 @@ class qs {
1526
1597
  }
1527
1598
  }
1528
1599
  }
1529
- const Ws = "crossx-sdk", js = 1, ve = "data", ke = "keys", Et = "aes-primary", Vs = 12;
1530
- class Tt {
1600
+ const zs = "crossx-sdk", Ys = 1, Se = "data", Le = "keys", It = "aes-primary", Zs = 12;
1601
+ class At {
1531
1602
  constructor() {
1532
1603
  this.db = null, this.cryptoKey = null, this.initPromise = null;
1533
1604
  }
@@ -1536,10 +1607,10 @@ class Tt {
1536
1607
  }
1537
1608
  openDB() {
1538
1609
  return new Promise((e, s) => {
1539
- const t = indexedDB.open(Ws, js);
1610
+ const t = indexedDB.open(zs, Ys);
1540
1611
  t.onupgradeneeded = () => {
1541
1612
  const n = t.result;
1542
- n.objectStoreNames.contains(ve) || n.createObjectStore(ve), n.objectStoreNames.contains(ke) || n.createObjectStore(ke);
1613
+ n.objectStoreNames.contains(Se) || n.createObjectStore(Se), n.objectStoreNames.contains(Le) || n.createObjectStore(Le);
1543
1614
  }, t.onsuccess = () => e(t.result), t.onerror = () => s(t.error);
1544
1615
  });
1545
1616
  }
@@ -1569,7 +1640,7 @@ class Tt {
1569
1640
  }
1570
1641
  async init() {
1571
1642
  this.db = await this.openDB();
1572
- const e = await this.idbGet(ke, Et);
1643
+ const e = await this.idbGet(Le, It);
1573
1644
  if (e) {
1574
1645
  this.cryptoKey = e;
1575
1646
  return;
@@ -1578,10 +1649,10 @@ class Tt {
1578
1649
  { name: "AES-GCM", length: 256 },
1579
1650
  !1,
1580
1651
  ["encrypt", "decrypt"]
1581
- ), await this.idbPut(ke, Et, this.cryptoKey);
1652
+ ), await this.idbPut(Le, It, this.cryptoKey);
1582
1653
  }
1583
1654
  async encrypt(e) {
1584
- const s = new Uint8Array(Vs);
1655
+ const s = new Uint8Array(Zs);
1585
1656
  crypto.getRandomValues(s);
1586
1657
  const t = new TextEncoder().encode(e), n = await crypto.subtle.encrypt(
1587
1658
  { name: "AES-GCM", iv: s },
@@ -1602,7 +1673,7 @@ class Tt {
1602
1673
  try {
1603
1674
  await this.ensureReady();
1604
1675
  const t = JSON.stringify(s), n = await this.encrypt(t);
1605
- await this.idbPut(ve, e, n);
1676
+ await this.idbPut(Se, e, n);
1606
1677
  } catch (t) {
1607
1678
  throw f.error("[CROSSx] IndexedDB set error:", t), t;
1608
1679
  }
@@ -1610,7 +1681,7 @@ class Tt {
1610
1681
  async get(e) {
1611
1682
  try {
1612
1683
  await this.ensureReady();
1613
- const s = await this.idbGet(ve, e);
1684
+ const s = await this.idbGet(Se, e);
1614
1685
  if (!s) return null;
1615
1686
  const t = await this.decrypt(s);
1616
1687
  return JSON.parse(t);
@@ -1620,14 +1691,14 @@ class Tt {
1620
1691
  }
1621
1692
  async remove(e) {
1622
1693
  try {
1623
- await this.ensureReady(), await this.idbDelete(ve, e);
1694
+ await this.ensureReady(), await this.idbDelete(Se, e);
1624
1695
  } catch (s) {
1625
1696
  throw f.error("[CROSSx] IndexedDB remove error:", s), s;
1626
1697
  }
1627
1698
  }
1628
1699
  async clear() {
1629
1700
  try {
1630
- await this.ensureReady(), await this.idbClear(ve);
1701
+ await this.ensureReady(), await this.idbClear(Se);
1631
1702
  } catch (e) {
1632
1703
  throw f.error("[CROSSx] IndexedDB clear error:", e), e;
1633
1704
  }
@@ -1640,27 +1711,27 @@ class Tt {
1640
1711
  }
1641
1712
  }
1642
1713
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1643
- function it(r) {
1714
+ function at(r) {
1644
1715
  return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
1645
1716
  }
1646
- function le(r, e = "") {
1717
+ function ue(r, e = "") {
1647
1718
  if (!Number.isSafeInteger(r) || r < 0) {
1648
1719
  const s = e && `"${e}" `;
1649
1720
  throw new Error(`${s}expected integer >= 0, got ${r}`);
1650
1721
  }
1651
1722
  }
1652
- function U(r, e, s = "") {
1653
- const t = it(r), n = r == null ? void 0 : r.length, o = e !== void 0;
1723
+ function F(r, e, s = "") {
1724
+ const t = at(r), n = r == null ? void 0 : r.length, o = e !== void 0;
1654
1725
  if (!t || o && n !== e) {
1655
1726
  const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
1656
1727
  throw new Error(i + "expected Uint8Array" + a + ", got " + c);
1657
1728
  }
1658
1729
  return r;
1659
1730
  }
1660
- function jt(r) {
1731
+ function Kt(r) {
1661
1732
  if (typeof r != "function" || typeof r.create != "function")
1662
1733
  throw new Error("Hash must wrapped by utils.createHasher");
1663
- le(r.outputLen), le(r.blockLen);
1734
+ ue(r.outputLen), ue(r.blockLen);
1664
1735
  }
1665
1736
  function Te(r, e = !0) {
1666
1737
  if (r.destroyed)
@@ -1668,63 +1739,63 @@ function Te(r, e = !0) {
1668
1739
  if (e && r.finished)
1669
1740
  throw new Error("Hash#digest() has already been called");
1670
1741
  }
1671
- function Vt(r, e) {
1672
- U(r, void 0, "digestInto() output");
1742
+ function zt(r, e) {
1743
+ F(r, void 0, "digestInto() output");
1673
1744
  const s = e.outputLen;
1674
1745
  if (r.length < s)
1675
1746
  throw new Error('"digestInto() output" expected to be of length >=' + s);
1676
1747
  }
1677
- function Ks(r) {
1748
+ function Xs(r) {
1678
1749
  return new Uint32Array(r.buffer, r.byteOffset, Math.floor(r.byteLength / 4));
1679
1750
  }
1680
- function Ae(...r) {
1751
+ function Ie(...r) {
1681
1752
  for (let e = 0; e < r.length; e++)
1682
1753
  r[e].fill(0);
1683
1754
  }
1684
- function Ye(r) {
1755
+ function Ze(r) {
1685
1756
  return new DataView(r.buffer, r.byteOffset, r.byteLength);
1686
1757
  }
1687
1758
  function oe(r, e) {
1688
1759
  return r << 32 - e | r >>> e;
1689
1760
  }
1690
- const zs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1691
- function Ys(r) {
1761
+ const Js = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1762
+ function Qs(r) {
1692
1763
  return r << 24 & 4278190080 | r << 8 & 16711680 | r >>> 8 & 65280 | r >>> 24 & 255;
1693
1764
  }
1694
- function Zs(r) {
1765
+ function er(r) {
1695
1766
  for (let e = 0; e < r.length; e++)
1696
- r[e] = Ys(r[e]);
1767
+ r[e] = Qs(r[e]);
1697
1768
  return r;
1698
1769
  }
1699
- const At = zs ? (r) => r : Zs, Kt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Xs = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
1700
- function Ce(r) {
1701
- if (U(r), Kt)
1770
+ const Rt = Js ? (r) => r : er, Yt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", tr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
1771
+ function ke(r) {
1772
+ if (F(r), Yt)
1702
1773
  return r.toHex();
1703
1774
  let e = "";
1704
1775
  for (let s = 0; s < r.length; s++)
1705
- e += Xs[r[s]];
1776
+ e += tr[r[s]];
1706
1777
  return e;
1707
1778
  }
1708
- const ie = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1709
- function It(r) {
1710
- if (r >= ie._0 && r <= ie._9)
1711
- return r - ie._0;
1712
- if (r >= ie.A && r <= ie.F)
1713
- return r - (ie.A - 10);
1714
- if (r >= ie.a && r <= ie.f)
1715
- return r - (ie.a - 10);
1779
+ const ce = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
1780
+ function Ot(r) {
1781
+ if (r >= ce._0 && r <= ce._9)
1782
+ return r - ce._0;
1783
+ if (r >= ce.A && r <= ce.F)
1784
+ return r - (ce.A - 10);
1785
+ if (r >= ce.a && r <= ce.f)
1786
+ return r - (ce.a - 10);
1716
1787
  }
1717
1788
  function Fe(r) {
1718
1789
  if (typeof r != "string")
1719
1790
  throw new Error("hex string expected, got " + typeof r);
1720
- if (Kt)
1791
+ if (Yt)
1721
1792
  return Uint8Array.fromHex(r);
1722
1793
  const e = r.length, s = e / 2;
1723
1794
  if (e % 2)
1724
1795
  throw new Error("hex string expected, got unpadded hex of length " + e);
1725
1796
  const t = new Uint8Array(s);
1726
1797
  for (let n = 0, o = 0; n < s; n++, o += 2) {
1727
- const i = It(r.charCodeAt(o)), a = It(r.charCodeAt(o + 1));
1798
+ const i = Ot(r.charCodeAt(o)), a = Ot(r.charCodeAt(o + 1));
1728
1799
  if (i === void 0 || a === void 0) {
1729
1800
  const c = r[o] + r[o + 1];
1730
1801
  throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + o);
@@ -1733,11 +1804,11 @@ function Fe(r) {
1733
1804
  }
1734
1805
  return t;
1735
1806
  }
1736
- function xe(...r) {
1807
+ function _e(...r) {
1737
1808
  let e = 0;
1738
1809
  for (let t = 0; t < r.length; t++) {
1739
1810
  const n = r[t];
1740
- U(n), e += n.length;
1811
+ F(n), e += n.length;
1741
1812
  }
1742
1813
  const s = new Uint8Array(e);
1743
1814
  for (let t = 0, n = 0; t < r.length; t++) {
@@ -1746,47 +1817,47 @@ function xe(...r) {
1746
1817
  }
1747
1818
  return s;
1748
1819
  }
1749
- function zt(r, e = {}) {
1820
+ function Zt(r, e = {}) {
1750
1821
  const s = (n, o) => r(o).update(n).digest(), t = r(void 0);
1751
1822
  return s.outputLen = t.outputLen, s.blockLen = t.blockLen, s.create = (n) => r(n), Object.assign(s, e), Object.freeze(s);
1752
1823
  }
1753
- function Yt(r = 32) {
1824
+ function Xt(r = 32) {
1754
1825
  const e = typeof globalThis == "object" ? globalThis.crypto : null;
1755
1826
  if (typeof (e == null ? void 0 : e.getRandomValues) != "function")
1756
1827
  throw new Error("crypto.getRandomValues must be defined");
1757
1828
  return e.getRandomValues(new Uint8Array(r));
1758
1829
  }
1759
- const Js = (r) => ({
1830
+ const sr = (r) => ({
1760
1831
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, r])
1761
1832
  });
1762
- function Qs(r, e, s) {
1833
+ function rr(r, e, s) {
1763
1834
  return r & e ^ ~r & s;
1764
1835
  }
1765
- function er(r, e, s) {
1836
+ function nr(r, e, s) {
1766
1837
  return r & e ^ r & s ^ e & s;
1767
1838
  }
1768
- class tr {
1839
+ class or {
1769
1840
  constructor(e, s, t, n) {
1770
- b(this, "blockLen");
1771
- b(this, "outputLen");
1772
- b(this, "padOffset");
1773
- b(this, "isLE");
1841
+ v(this, "blockLen");
1842
+ v(this, "outputLen");
1843
+ v(this, "padOffset");
1844
+ v(this, "isLE");
1774
1845
  // For partial updates less than block size
1775
- b(this, "buffer");
1776
- b(this, "view");
1777
- b(this, "finished", !1);
1778
- b(this, "length", 0);
1779
- b(this, "pos", 0);
1780
- b(this, "destroyed", !1);
1781
- this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ye(this.buffer);
1846
+ v(this, "buffer");
1847
+ v(this, "view");
1848
+ v(this, "finished", !1);
1849
+ v(this, "length", 0);
1850
+ v(this, "pos", 0);
1851
+ v(this, "destroyed", !1);
1852
+ this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
1782
1853
  }
1783
1854
  update(e) {
1784
- Te(this), U(e);
1855
+ Te(this), F(e);
1785
1856
  const { view: s, buffer: t, blockLen: n } = this, o = e.length;
1786
1857
  for (let i = 0; i < o; ) {
1787
1858
  const a = Math.min(n - this.pos, o - i);
1788
1859
  if (a === n) {
1789
- const c = Ye(e);
1860
+ const c = Ze(e);
1790
1861
  for (; n <= o - i; i += n)
1791
1862
  this.process(c, i);
1792
1863
  continue;
@@ -1796,14 +1867,14 @@ class tr {
1796
1867
  return this.length += e.length, this.roundClean(), this;
1797
1868
  }
1798
1869
  digestInto(e) {
1799
- Te(this), Vt(e, this), this.finished = !0;
1870
+ Te(this), zt(e, this), this.finished = !0;
1800
1871
  const { buffer: s, view: t, blockLen: n, isLE: o } = this;
1801
1872
  let { pos: i } = this;
1802
- s[i++] = 128, Ae(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
1873
+ s[i++] = 128, Ie(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
1803
1874
  for (let g = i; g < n; g++)
1804
1875
  s[g] = 0;
1805
1876
  t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
1806
- const a = Ye(e), c = this.outputLen;
1877
+ const a = Ze(e), c = this.outputLen;
1807
1878
  if (c % 4)
1808
1879
  throw new Error("_sha2: outputLen must be aligned to 32bit");
1809
1880
  const l = c / 4, d = this.get();
@@ -1836,20 +1907,20 @@ const fe = /* @__PURE__ */ Uint32Array.from([
1836
1907
  2600822924,
1837
1908
  528734635,
1838
1909
  1541459225
1839
- ]), Le = /* @__PURE__ */ BigInt(2 ** 32 - 1), Rt = /* @__PURE__ */ BigInt(32);
1840
- function sr(r, e = !1) {
1841
- return e ? { h: Number(r & Le), l: Number(r >> Rt & Le) } : { h: Number(r >> Rt & Le) | 0, l: Number(r & Le) | 0 };
1910
+ ]), De = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ct = /* @__PURE__ */ BigInt(32);
1911
+ function ir(r, e = !1) {
1912
+ return e ? { h: Number(r & De), l: Number(r >> Ct & De) } : { h: Number(r >> Ct & De) | 0, l: Number(r & De) | 0 };
1842
1913
  }
1843
- function rr(r, e = !1) {
1914
+ function ar(r, e = !1) {
1844
1915
  const s = r.length;
1845
1916
  let t = new Uint32Array(s), n = new Uint32Array(s);
1846
1917
  for (let o = 0; o < s; o++) {
1847
- const { h: i, l: a } = sr(r[o], e);
1918
+ const { h: i, l: a } = ir(r[o], e);
1848
1919
  [t[o], n[o]] = [i, a];
1849
1920
  }
1850
1921
  return [t, n];
1851
1922
  }
1852
- const nr = (r, e, s) => r << s | e >>> 32 - s, or = (r, e, s) => e << s | r >>> 32 - s, ir = (r, e, s) => e << s - 32 | r >>> 64 - s, ar = (r, e, s) => r << s - 32 | e >>> 64 - s, cr = /* @__PURE__ */ Uint32Array.from([
1923
+ const cr = (r, e, s) => r << s | e >>> 32 - s, lr = (r, e, s) => e << s | r >>> 32 - s, dr = (r, e, s) => e << s - 32 | r >>> 64 - s, ur = (r, e, s) => r << s - 32 | e >>> 64 - s, hr = /* @__PURE__ */ Uint32Array.from([
1853
1924
  1116352408,
1854
1925
  1899447441,
1855
1926
  3049323471,
@@ -1915,7 +1986,7 @@ const nr = (r, e, s) => r << s | e >>> 32 - s, or = (r, e, s) => e << s | r >>>
1915
1986
  3204031479,
1916
1987
  3329325298
1917
1988
  ]), ge = /* @__PURE__ */ new Uint32Array(64);
1918
- class lr extends tr {
1989
+ class fr extends or {
1919
1990
  constructor(e) {
1920
1991
  super(64, e, 8, !1);
1921
1992
  }
@@ -1931,132 +2002,132 @@ class lr extends tr {
1931
2002
  for (let g = 0; g < 16; g++, s += 4)
1932
2003
  ge[g] = e.getUint32(s, !1);
1933
2004
  for (let g = 16; g < 64; g++) {
1934
- const w = ge[g - 15], m = ge[g - 2], x = oe(w, 7) ^ oe(w, 18) ^ w >>> 3, A = oe(m, 17) ^ oe(m, 19) ^ m >>> 10;
1935
- ge[g] = A + ge[g - 7] + x + ge[g - 16] | 0;
2005
+ const m = ge[g - 15], x = ge[g - 2], w = oe(m, 7) ^ oe(m, 18) ^ m >>> 3, b = oe(x, 17) ^ oe(x, 19) ^ x >>> 10;
2006
+ ge[g] = b + ge[g - 7] + w + ge[g - 16] | 0;
1936
2007
  }
1937
2008
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
1938
2009
  for (let g = 0; g < 64; g++) {
1939
- const w = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), m = d + w + Qs(a, c, l) + cr[g] + ge[g] | 0, A = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + er(t, n, o) | 0;
1940
- d = l, l = c, c = a, a = i + m | 0, i = o, o = n, n = t, t = m + A | 0;
2010
+ const m = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), x = d + m + rr(a, c, l) + hr[g] + ge[g] | 0, b = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + nr(t, n, o) | 0;
2011
+ d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + b | 0;
1941
2012
  }
1942
2013
  t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
1943
2014
  }
1944
2015
  roundClean() {
1945
- Ae(ge);
2016
+ Ie(ge);
1946
2017
  }
1947
2018
  destroy() {
1948
- this.set(0, 0, 0, 0, 0, 0, 0, 0), Ae(this.buffer);
2019
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), Ie(this.buffer);
1949
2020
  }
1950
2021
  }
1951
- class dr extends lr {
2022
+ class gr extends fr {
1952
2023
  constructor() {
1953
2024
  super(32);
1954
2025
  // We cannot use array here since array allows indexing by variable
1955
2026
  // which means optimizer/compiler cannot use registers.
1956
- b(this, "A", fe[0] | 0);
1957
- b(this, "B", fe[1] | 0);
1958
- b(this, "C", fe[2] | 0);
1959
- b(this, "D", fe[3] | 0);
1960
- b(this, "E", fe[4] | 0);
1961
- b(this, "F", fe[5] | 0);
1962
- b(this, "G", fe[6] | 0);
1963
- b(this, "H", fe[7] | 0);
1964
- }
1965
- }
1966
- const ur = /* @__PURE__ */ zt(
1967
- () => new dr(),
1968
- /* @__PURE__ */ Js(1)
2027
+ v(this, "A", fe[0] | 0);
2028
+ v(this, "B", fe[1] | 0);
2029
+ v(this, "C", fe[2] | 0);
2030
+ v(this, "D", fe[3] | 0);
2031
+ v(this, "E", fe[4] | 0);
2032
+ v(this, "F", fe[5] | 0);
2033
+ v(this, "G", fe[6] | 0);
2034
+ v(this, "H", fe[7] | 0);
2035
+ }
2036
+ }
2037
+ const pr = /* @__PURE__ */ Zt(
2038
+ () => new gr(),
2039
+ /* @__PURE__ */ sr(1)
1969
2040
  );
1970
2041
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1971
- const at = /* @__PURE__ */ BigInt(0), st = /* @__PURE__ */ BigInt(1);
1972
- function Ue(r, e = "") {
2042
+ const ct = /* @__PURE__ */ BigInt(0), rt = /* @__PURE__ */ BigInt(1);
2043
+ function He(r, e = "") {
1973
2044
  if (typeof r != "boolean") {
1974
2045
  const s = e && `"${e}" `;
1975
2046
  throw new Error(s + "expected boolean, got type=" + typeof r);
1976
2047
  }
1977
2048
  return r;
1978
2049
  }
1979
- function Zt(r) {
2050
+ function Jt(r) {
1980
2051
  if (typeof r == "bigint") {
1981
2052
  if (!Me(r))
1982
2053
  throw new Error("positive bigint expected, got " + r);
1983
2054
  } else
1984
- le(r);
2055
+ ue(r);
1985
2056
  return r;
1986
2057
  }
1987
- function De(r) {
1988
- const e = Zt(r).toString(16);
2058
+ function $e(r) {
2059
+ const e = Jt(r).toString(16);
1989
2060
  return e.length & 1 ? "0" + e : e;
1990
2061
  }
1991
- function Xt(r) {
2062
+ function Qt(r) {
1992
2063
  if (typeof r != "string")
1993
2064
  throw new Error("hex string expected, got " + typeof r);
1994
- return r === "" ? at : BigInt("0x" + r);
2065
+ return r === "" ? ct : BigInt("0x" + r);
1995
2066
  }
1996
- function We(r) {
1997
- return Xt(Ce(r));
2067
+ function je(r) {
2068
+ return Qt(ke(r));
1998
2069
  }
1999
- function Jt(r) {
2000
- return Xt(Ce(hr(U(r)).reverse()));
2070
+ function es(r) {
2071
+ return Qt(ke(_r(F(r)).reverse()));
2001
2072
  }
2002
- function ct(r, e) {
2003
- le(e), r = Zt(r);
2073
+ function lt(r, e) {
2074
+ ue(e), r = Jt(r);
2004
2075
  const s = Fe(r.toString(16).padStart(e * 2, "0"));
2005
2076
  if (s.length !== e)
2006
2077
  throw new Error("number too large");
2007
2078
  return s;
2008
2079
  }
2009
- function Qt(r, e) {
2010
- return ct(r, e).reverse();
2080
+ function ts(r, e) {
2081
+ return lt(r, e).reverse();
2011
2082
  }
2012
- function hr(r) {
2083
+ function _r(r) {
2013
2084
  return Uint8Array.from(r);
2014
2085
  }
2015
- const Me = (r) => typeof r == "bigint" && at <= r;
2016
- function fr(r, e, s) {
2086
+ const Me = (r) => typeof r == "bigint" && ct <= r;
2087
+ function xr(r, e, s) {
2017
2088
  return Me(r) && Me(e) && Me(s) && e <= r && r < s;
2018
2089
  }
2019
- function gr(r, e, s, t) {
2020
- if (!fr(e, s, t))
2090
+ function mr(r, e, s, t) {
2091
+ if (!xr(e, s, t))
2021
2092
  throw new Error("expected valid " + r + ": " + s + " <= n < " + t + ", got " + e);
2022
2093
  }
2023
- function pr(r) {
2094
+ function wr(r) {
2024
2095
  let e;
2025
- for (e = 0; r > at; r >>= st, e += 1)
2096
+ for (e = 0; r > ct; r >>= rt, e += 1)
2026
2097
  ;
2027
2098
  return e;
2028
2099
  }
2029
- const lt = (r) => (st << BigInt(r)) - st;
2030
- function xr(r, e, s) {
2031
- if (le(r, "hashLen"), le(e, "qByteLen"), typeof s != "function")
2100
+ const dt = (r) => (rt << BigInt(r)) - rt;
2101
+ function yr(r, e, s) {
2102
+ if (ue(r, "hashLen"), ue(e, "qByteLen"), typeof s != "function")
2032
2103
  throw new Error("hmacFn must be a function");
2033
- const t = (E) => new Uint8Array(E), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2104
+ const t = (S) => new Uint8Array(S), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2034
2105
  let c = t(r), l = t(r), d = 0;
2035
2106
  const g = () => {
2036
2107
  c.fill(1), l.fill(0), d = 0;
2037
- }, w = (...E) => s(l, xe(c, ...E)), m = (E = n) => {
2038
- l = w(o, E), c = w(), E.length !== 0 && (l = w(i, E), c = w());
2039
- }, x = () => {
2108
+ }, m = (...S) => s(l, _e(c, ...S)), x = (S = n) => {
2109
+ l = m(o, S), c = m(), S.length !== 0 && (l = m(i, S), c = m());
2110
+ }, w = () => {
2040
2111
  if (d++ >= a)
2041
2112
  throw new Error("drbg: tried max amount of iterations");
2042
- let E = 0;
2043
- const C = [];
2044
- for (; E < e; ) {
2045
- c = w();
2113
+ let S = 0;
2114
+ const E = [];
2115
+ for (; S < e; ) {
2116
+ c = m();
2046
2117
  const q = c.slice();
2047
- C.push(q), E += c.length;
2118
+ E.push(q), S += c.length;
2048
2119
  }
2049
- return xe(...C);
2120
+ return _e(...E);
2050
2121
  };
2051
- return (E, C) => {
2052
- g(), m(E);
2122
+ return (S, E) => {
2123
+ g(), x(S);
2053
2124
  let q;
2054
- for (; !(q = C(x())); )
2055
- m();
2125
+ for (; !(q = E(w())); )
2126
+ x();
2056
2127
  return g(), q;
2057
2128
  };
2058
2129
  }
2059
- function dt(r, e = {}, s = {}) {
2130
+ function ut(r, e = {}, s = {}) {
2060
2131
  if (!r || typeof r != "object")
2061
2132
  throw new Error("expected valid options object");
2062
2133
  function t(o, i, a) {
@@ -2070,7 +2141,7 @@ function dt(r, e = {}, s = {}) {
2070
2141
  const n = (o, i) => Object.entries(o).forEach(([a, c]) => t(a, c, i));
2071
2142
  n(e, !1), n(s, !0);
2072
2143
  }
2073
- function Ot(r) {
2144
+ function kt(r) {
2074
2145
  const e = /* @__PURE__ */ new WeakMap();
2075
2146
  return (s, ...t) => {
2076
2147
  const n = e.get(s);
@@ -2081,24 +2152,24 @@ function Ot(r) {
2081
2152
  };
2082
2153
  }
2083
2154
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2084
- const X = /* @__PURE__ */ BigInt(0), z = /* @__PURE__ */ BigInt(1), we = /* @__PURE__ */ BigInt(2), es = /* @__PURE__ */ BigInt(3), ts = /* @__PURE__ */ BigInt(4), ss = /* @__PURE__ */ BigInt(5), _r = /* @__PURE__ */ BigInt(7), rs = /* @__PURE__ */ BigInt(8), mr = /* @__PURE__ */ BigInt(9), ns = /* @__PURE__ */ BigInt(16);
2155
+ const J = /* @__PURE__ */ BigInt(0), z = /* @__PURE__ */ BigInt(1), ye = /* @__PURE__ */ BigInt(2), ss = /* @__PURE__ */ BigInt(3), rs = /* @__PURE__ */ BigInt(4), ns = /* @__PURE__ */ BigInt(5), br = /* @__PURE__ */ BigInt(7), os = /* @__PURE__ */ BigInt(8), vr = /* @__PURE__ */ BigInt(9), is = /* @__PURE__ */ BigInt(16);
2085
2156
  function re(r, e) {
2086
2157
  const s = r % e;
2087
- return s >= X ? s : e + s;
2158
+ return s >= J ? s : e + s;
2088
2159
  }
2089
- function ee(r, e, s) {
2160
+ function se(r, e, s) {
2090
2161
  let t = r;
2091
- for (; e-- > X; )
2162
+ for (; e-- > J; )
2092
2163
  t *= t, t %= s;
2093
2164
  return t;
2094
2165
  }
2095
- function Ct(r, e) {
2096
- if (r === X)
2166
+ function Nt(r, e) {
2167
+ if (r === J)
2097
2168
  throw new Error("invert: expected non-zero number");
2098
- if (e <= X)
2169
+ if (e <= J)
2099
2170
  throw new Error("invert: expected positive modulus, got " + e);
2100
- let s = re(r, e), t = e, n = X, o = z;
2101
- for (; s !== X; ) {
2171
+ let s = re(r, e), t = e, n = J, o = z;
2172
+ for (; s !== J; ) {
2102
2173
  const a = t / s, c = t % s, l = n - o * a;
2103
2174
  t = s, s = c, n = o, o = l;
2104
2175
  }
@@ -2106,66 +2177,66 @@ function Ct(r, e) {
2106
2177
  throw new Error("invert: does not exist");
2107
2178
  return re(n, e);
2108
2179
  }
2109
- function ut(r, e, s) {
2180
+ function ht(r, e, s) {
2110
2181
  if (!r.eql(r.sqr(e), s))
2111
2182
  throw new Error("Cannot find square root");
2112
2183
  }
2113
- function os(r, e) {
2114
- const s = (r.ORDER + z) / ts, t = r.pow(e, s);
2115
- return ut(r, t, e), t;
2184
+ function as(r, e) {
2185
+ const s = (r.ORDER + z) / rs, t = r.pow(e, s);
2186
+ return ht(r, t, e), t;
2116
2187
  }
2117
- function wr(r, e) {
2118
- const s = (r.ORDER - ss) / rs, t = r.mul(e, we), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, we), n), a = r.mul(o, r.sub(i, r.ONE));
2119
- return ut(r, a, e), a;
2188
+ function Sr(r, e) {
2189
+ const s = (r.ORDER - ns) / os, t = r.mul(e, ye), n = r.pow(t, s), o = r.mul(e, n), i = r.mul(r.mul(o, ye), n), a = r.mul(o, r.sub(i, r.ONE));
2190
+ return ht(r, a, e), a;
2120
2191
  }
2121
- function yr(r) {
2122
- const e = je(r), s = is(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + _r) / ns;
2192
+ function Er(r) {
2193
+ const e = Ve(r), s = cs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + br) / is;
2123
2194
  return (a, c) => {
2124
2195
  let l = a.pow(c, i), d = a.mul(l, t);
2125
- const g = a.mul(l, n), w = a.mul(l, o), m = a.eql(a.sqr(d), c), x = a.eql(a.sqr(g), c);
2126
- l = a.cmov(l, d, m), d = a.cmov(w, g, x);
2127
- const A = a.eql(a.sqr(d), c), E = a.cmov(l, d, A);
2128
- return ut(a, E, c), E;
2196
+ const g = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(g), c);
2197
+ l = a.cmov(l, d, x), d = a.cmov(m, g, w);
2198
+ const b = a.eql(a.sqr(d), c), S = a.cmov(l, d, b);
2199
+ return ht(a, S, c), S;
2129
2200
  };
2130
2201
  }
2131
- function is(r) {
2132
- if (r < es)
2202
+ function cs(r) {
2203
+ if (r < ss)
2133
2204
  throw new Error("sqrt is not defined for small field");
2134
2205
  let e = r - z, s = 0;
2135
- for (; e % we === X; )
2136
- e /= we, s++;
2137
- let t = we;
2138
- const n = je(r);
2139
- for (; Nt(n, t) === 1; )
2206
+ for (; e % ye === J; )
2207
+ e /= ye, s++;
2208
+ let t = ye;
2209
+ const n = Ve(r);
2210
+ for (; Pt(n, t) === 1; )
2140
2211
  if (t++ > 1e3)
2141
2212
  throw new Error("Cannot find square root: probably non-prime P");
2142
2213
  if (s === 1)
2143
- return os;
2214
+ return as;
2144
2215
  let o = n.pow(t, e);
2145
- const i = (e + z) / we;
2216
+ const i = (e + z) / ye;
2146
2217
  return function(c, l) {
2147
2218
  if (c.is0(l))
2148
2219
  return l;
2149
- if (Nt(c, l) !== 1)
2220
+ if (Pt(c, l) !== 1)
2150
2221
  throw new Error("Cannot find square root");
2151
- let d = s, g = c.mul(c.ONE, o), w = c.pow(l, e), m = c.pow(l, i);
2152
- for (; !c.eql(w, c.ONE); ) {
2153
- if (c.is0(w))
2222
+ let d = s, g = c.mul(c.ONE, o), m = c.pow(l, e), x = c.pow(l, i);
2223
+ for (; !c.eql(m, c.ONE); ) {
2224
+ if (c.is0(m))
2154
2225
  return c.ZERO;
2155
- let x = 1, A = c.sqr(w);
2156
- for (; !c.eql(A, c.ONE); )
2157
- if (x++, A = c.sqr(A), x === d)
2226
+ let w = 1, b = c.sqr(m);
2227
+ for (; !c.eql(b, c.ONE); )
2228
+ if (w++, b = c.sqr(b), w === d)
2158
2229
  throw new Error("Cannot find square root");
2159
- const E = z << BigInt(d - x - 1), C = c.pow(g, E);
2160
- d = x, g = c.sqr(C), w = c.mul(w, g), m = c.mul(m, C);
2230
+ const S = z << BigInt(d - w - 1), E = c.pow(g, S);
2231
+ d = w, g = c.sqr(E), m = c.mul(m, g), x = c.mul(x, E);
2161
2232
  }
2162
- return m;
2233
+ return x;
2163
2234
  };
2164
2235
  }
2165
- function br(r) {
2166
- return r % ts === es ? os : r % rs === ss ? wr : r % ns === mr ? yr(r) : is(r);
2236
+ function Tr(r) {
2237
+ return r % rs === ss ? as : r % os === ns ? Sr : r % is === vr ? Er(r) : cs(r);
2167
2238
  }
2168
- const vr = [
2239
+ const Ir = [
2169
2240
  "create",
2170
2241
  "isValid",
2171
2242
  "is0",
@@ -2184,59 +2255,59 @@ const vr = [
2184
2255
  "mulN",
2185
2256
  "sqrN"
2186
2257
  ];
2187
- function Sr(r) {
2258
+ function Ar(r) {
2188
2259
  const e = {
2189
2260
  ORDER: "bigint",
2190
2261
  BYTES: "number",
2191
2262
  BITS: "number"
2192
- }, s = vr.reduce((t, n) => (t[n] = "function", t), e);
2193
- return dt(r, s), r;
2263
+ }, s = Ir.reduce((t, n) => (t[n] = "function", t), e);
2264
+ return ut(r, s), r;
2194
2265
  }
2195
- function Er(r, e, s) {
2196
- if (s < X)
2266
+ function Rr(r, e, s) {
2267
+ if (s < J)
2197
2268
  throw new Error("invalid exponent, negatives unsupported");
2198
- if (s === X)
2269
+ if (s === J)
2199
2270
  return r.ONE;
2200
2271
  if (s === z)
2201
2272
  return e;
2202
2273
  let t = r.ONE, n = e;
2203
- for (; s > X; )
2274
+ for (; s > J; )
2204
2275
  s & z && (t = r.mul(t, n)), n = r.sqr(n), s >>= z;
2205
2276
  return t;
2206
2277
  }
2207
- function as(r, e, s = !1) {
2278
+ function ls(r, e, s = !1) {
2208
2279
  const t = new Array(e.length).fill(s ? r.ZERO : void 0), n = e.reduce((i, a, c) => r.is0(a) ? i : (t[c] = i, r.mul(i, a)), r.ONE), o = r.inv(n);
2209
2280
  return e.reduceRight((i, a, c) => r.is0(a) ? i : (t[c] = r.mul(i, t[c]), r.mul(i, a)), o), t;
2210
2281
  }
2211
- function Nt(r, e) {
2212
- const s = (r.ORDER - z) / we, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
2282
+ function Pt(r, e) {
2283
+ const s = (r.ORDER - z) / ye, t = r.pow(e, s), n = r.eql(t, r.ONE), o = r.eql(t, r.ZERO), i = r.eql(t, r.neg(r.ONE));
2213
2284
  if (!n && !o && !i)
2214
2285
  throw new Error("invalid Legendre symbol result");
2215
2286
  return n ? 1 : o ? 0 : -1;
2216
2287
  }
2217
- function Tr(r, e) {
2218
- e !== void 0 && le(e);
2288
+ function Or(r, e) {
2289
+ e !== void 0 && ue(e);
2219
2290
  const s = e !== void 0 ? e : r.toString(2).length, t = Math.ceil(s / 8);
2220
2291
  return { nBitLength: s, nByteLength: t };
2221
2292
  }
2222
- class Ar {
2293
+ class Cr {
2223
2294
  constructor(e, s = {}) {
2224
- b(this, "ORDER");
2225
- b(this, "BITS");
2226
- b(this, "BYTES");
2227
- b(this, "isLE");
2228
- b(this, "ZERO", X);
2229
- b(this, "ONE", z);
2230
- b(this, "_lengths");
2231
- b(this, "_sqrt");
2295
+ v(this, "ORDER");
2296
+ v(this, "BITS");
2297
+ v(this, "BYTES");
2298
+ v(this, "isLE");
2299
+ v(this, "ZERO", J);
2300
+ v(this, "ONE", z);
2301
+ v(this, "_lengths");
2302
+ v(this, "_sqrt");
2232
2303
  // cached sqrt
2233
- b(this, "_mod");
2304
+ v(this, "_mod");
2234
2305
  var i;
2235
- if (e <= X)
2306
+ if (e <= J)
2236
2307
  throw new Error("invalid field: expected ORDER > 0, got " + e);
2237
2308
  let t;
2238
2309
  this.isLE = !1, s != null && typeof s == "object" && (typeof s.BITS == "number" && (t = s.BITS), typeof s.sqrt == "function" && (this.sqrt = s.sqrt), typeof s.isLE == "boolean" && (this.isLE = s.isLE), s.allowedLengths && (this._lengths = (i = s.allowedLengths) == null ? void 0 : i.slice()), typeof s.modFromBytes == "boolean" && (this._mod = s.modFromBytes));
2239
- const { nBitLength: n, nByteLength: o } = Tr(e, t);
2310
+ const { nBitLength: n, nByteLength: o } = Or(e, t);
2240
2311
  if (o > 2048)
2241
2312
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
2242
2313
  this.ORDER = e, this.BITS = n, this.BYTES = o, this._sqrt = void 0, Object.preventExtensions(this);
@@ -2247,10 +2318,10 @@ class Ar {
2247
2318
  isValid(e) {
2248
2319
  if (typeof e != "bigint")
2249
2320
  throw new Error("invalid field element: expected bigint, got " + typeof e);
2250
- return X <= e && e < this.ORDER;
2321
+ return J <= e && e < this.ORDER;
2251
2322
  }
2252
2323
  is0(e) {
2253
- return e === X;
2324
+ return e === J;
2254
2325
  }
2255
2326
  // is valid and invertible
2256
2327
  isValidNot0(e) {
@@ -2278,10 +2349,10 @@ class Ar {
2278
2349
  return re(e * s, this.ORDER);
2279
2350
  }
2280
2351
  pow(e, s) {
2281
- return Er(this, e, s);
2352
+ return Rr(this, e, s);
2282
2353
  }
2283
2354
  div(e, s) {
2284
- return re(e * Ct(s, this.ORDER), this.ORDER);
2355
+ return re(e * Nt(s, this.ORDER), this.ORDER);
2285
2356
  }
2286
2357
  // Same as above, but doesn't normalize
2287
2358
  sqrN(e) {
@@ -2297,16 +2368,16 @@ class Ar {
2297
2368
  return e * s;
2298
2369
  }
2299
2370
  inv(e) {
2300
- return Ct(e, this.ORDER);
2371
+ return Nt(e, this.ORDER);
2301
2372
  }
2302
2373
  sqrt(e) {
2303
- return this._sqrt || (this._sqrt = br(this.ORDER)), this._sqrt(this, e);
2374
+ return this._sqrt || (this._sqrt = Tr(this.ORDER)), this._sqrt(this, e);
2304
2375
  }
2305
2376
  toBytes(e) {
2306
- return this.isLE ? Qt(e, this.BYTES) : ct(e, this.BYTES);
2377
+ return this.isLE ? ts(e, this.BYTES) : lt(e, this.BYTES);
2307
2378
  }
2308
2379
  fromBytes(e, s = !1) {
2309
- U(e);
2380
+ F(e);
2310
2381
  const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
2311
2382
  if (t) {
2312
2383
  if (!t.includes(e.length) || e.length > n)
@@ -2316,14 +2387,14 @@ class Ar {
2316
2387
  }
2317
2388
  if (e.length !== n)
2318
2389
  throw new Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
2319
- let c = o ? Jt(e) : We(e);
2390
+ let c = o ? es(e) : je(e);
2320
2391
  if (a && (c = re(c, i)), !s && !this.isValid(c))
2321
2392
  throw new Error("invalid field element: outside of range 0..ORDER");
2322
2393
  return c;
2323
2394
  }
2324
2395
  // TODO: we don't need it here, move out to separate fn
2325
2396
  invertBatch(e) {
2326
- return as(this, e);
2397
+ return ls(this, e);
2327
2398
  }
2328
2399
  // We can't move this out because Fp6, Fp12 implement it
2329
2400
  // and it's unclear what to return in there.
@@ -2331,75 +2402,75 @@ class Ar {
2331
2402
  return t ? s : e;
2332
2403
  }
2333
2404
  }
2334
- function je(r, e = {}) {
2335
- return new Ar(r, e);
2405
+ function Ve(r, e = {}) {
2406
+ return new Cr(r, e);
2336
2407
  }
2337
- function cs(r) {
2408
+ function ds(r) {
2338
2409
  if (typeof r != "bigint")
2339
2410
  throw new Error("field order must be bigint");
2340
2411
  const e = r.toString(2).length;
2341
2412
  return Math.ceil(e / 8);
2342
2413
  }
2343
- function ls(r) {
2344
- const e = cs(r);
2414
+ function us(r) {
2415
+ const e = ds(r);
2345
2416
  return e + Math.ceil(e / 2);
2346
2417
  }
2347
- function Ir(r, e, s = !1) {
2348
- U(r);
2349
- const t = r.length, n = cs(e), o = ls(e);
2418
+ function kr(r, e, s = !1) {
2419
+ F(r);
2420
+ const t = r.length, n = ds(e), o = us(e);
2350
2421
  if (t < 16 || t < o || t > 1024)
2351
2422
  throw new Error("expected " + o + "-1024 bytes of input, got " + t);
2352
- const i = s ? Jt(r) : We(r), a = re(i, e - z) + z;
2353
- return s ? Qt(a, n) : ct(a, n);
2423
+ const i = s ? es(r) : je(r), a = re(i, e - z) + z;
2424
+ return s ? ts(a, n) : lt(a, n);
2354
2425
  }
2355
2426
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2356
- const Ie = /* @__PURE__ */ BigInt(0), ye = /* @__PURE__ */ BigInt(1);
2357
- function He(r, e) {
2427
+ const Ae = /* @__PURE__ */ BigInt(0), be = /* @__PURE__ */ BigInt(1);
2428
+ function Ge(r, e) {
2358
2429
  const s = e.negate();
2359
2430
  return r ? s : e;
2360
2431
  }
2361
- function Pt(r, e) {
2362
- const s = as(r.Fp, e.map((t) => t.Z));
2432
+ function Lt(r, e) {
2433
+ const s = ls(r.Fp, e.map((t) => t.Z));
2363
2434
  return e.map((t, n) => r.fromAffine(t.toAffine(s[n])));
2364
2435
  }
2365
- function ds(r, e) {
2436
+ function hs(r, e) {
2366
2437
  if (!Number.isSafeInteger(r) || r <= 0 || r > e)
2367
2438
  throw new Error("invalid window size, expected [1.." + e + "], got W=" + r);
2368
2439
  }
2369
- function Ze(r, e) {
2370
- ds(r, e);
2371
- const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = lt(r), i = BigInt(r);
2440
+ function Xe(r, e) {
2441
+ hs(r, e);
2442
+ const s = Math.ceil(e / r) + 1, t = 2 ** (r - 1), n = 2 ** r, o = dt(r), i = BigInt(r);
2372
2443
  return { windows: s, windowSize: t, mask: o, maxNumber: n, shiftBy: i };
2373
2444
  }
2374
- function kt(r, e, s) {
2445
+ function Dt(r, e, s) {
2375
2446
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
2376
2447
  let a = Number(r & n), c = r >> i;
2377
- a > t && (a -= o, c += ye);
2378
- const l = e * t, d = l + Math.abs(a) - 1, g = a === 0, w = a < 0, m = e % 2 !== 0;
2379
- return { nextN: c, offset: d, isZero: g, isNeg: w, isNegF: m, offsetF: l };
2448
+ a > t && (a -= o, c += be);
2449
+ const l = e * t, d = l + Math.abs(a) - 1, g = a === 0, m = a < 0, x = e % 2 !== 0;
2450
+ return { nextN: c, offset: d, isZero: g, isNeg: m, isNegF: x, offsetF: l };
2380
2451
  }
2381
- const Xe = /* @__PURE__ */ new WeakMap(), us = /* @__PURE__ */ new WeakMap();
2382
- function Je(r) {
2383
- return us.get(r) || 1;
2452
+ const Je = /* @__PURE__ */ new WeakMap(), fs = /* @__PURE__ */ new WeakMap();
2453
+ function Qe(r) {
2454
+ return fs.get(r) || 1;
2384
2455
  }
2385
- function Lt(r) {
2386
- if (r !== Ie)
2456
+ function $t(r) {
2457
+ if (r !== Ae)
2387
2458
  throw new Error("invalid wNAF");
2388
2459
  }
2389
- class Rr {
2460
+ class Nr {
2390
2461
  // Parametrized with a given Point class (not individual point)
2391
2462
  constructor(e, s) {
2392
- b(this, "BASE");
2393
- b(this, "ZERO");
2394
- b(this, "Fn");
2395
- b(this, "bits");
2463
+ v(this, "BASE");
2464
+ v(this, "ZERO");
2465
+ v(this, "Fn");
2466
+ v(this, "bits");
2396
2467
  this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = s;
2397
2468
  }
2398
2469
  // non-const time multiplication ladder
2399
2470
  _unsafeLadder(e, s, t = this.ZERO) {
2400
2471
  let n = e;
2401
- for (; s > Ie; )
2402
- s & ye && (t = t.add(n)), n = n.double(), s >>= ye;
2472
+ for (; s > Ae; )
2473
+ s & be && (t = t.add(n)), n = n.double(), s >>= be;
2403
2474
  return t;
2404
2475
  }
2405
2476
  /**
@@ -2415,7 +2486,7 @@ class Rr {
2415
2486
  * @returns precomputed point tables flattened to a single array
2416
2487
  */
2417
2488
  precomputeWindow(e, s) {
2418
- const { windows: t, windowSize: n } = Ze(s, this.bits), o = [];
2489
+ const { windows: t, windowSize: n } = Xe(s, this.bits), o = [];
2419
2490
  let i = e, a = i;
2420
2491
  for (let c = 0; c < t; c++) {
2421
2492
  a = i, o.push(a);
@@ -2435,12 +2506,12 @@ class Rr {
2435
2506
  if (!this.Fn.isValid(t))
2436
2507
  throw new Error("invalid scalar");
2437
2508
  let n = this.ZERO, o = this.BASE;
2438
- const i = Ze(e, this.bits);
2509
+ const i = Xe(e, this.bits);
2439
2510
  for (let a = 0; a < i.windows; a++) {
2440
- const { nextN: c, offset: l, isZero: d, isNeg: g, isNegF: w, offsetF: m } = kt(t, a, i);
2441
- t = c, d ? o = o.add(He(w, s[m])) : n = n.add(He(g, s[l]));
2511
+ const { nextN: c, offset: l, isZero: d, isNeg: g, isNegF: m, offsetF: x } = Dt(t, a, i);
2512
+ t = c, d ? o = o.add(Ge(m, s[x])) : n = n.add(Ge(g, s[l]));
2442
2513
  }
2443
- return Lt(t), { p: n, f: o };
2514
+ return $t(t), { p: n, f: o };
2444
2515
  }
2445
2516
  /**
2446
2517
  * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
@@ -2448,81 +2519,81 @@ class Rr {
2448
2519
  * @returns point
2449
2520
  */
2450
2521
  wNAFUnsafe(e, s, t, n = this.ZERO) {
2451
- const o = Ze(e, this.bits);
2452
- for (let i = 0; i < o.windows && t !== Ie; i++) {
2453
- const { nextN: a, offset: c, isZero: l, isNeg: d } = kt(t, i, o);
2522
+ const o = Xe(e, this.bits);
2523
+ for (let i = 0; i < o.windows && t !== Ae; i++) {
2524
+ const { nextN: a, offset: c, isZero: l, isNeg: d } = Dt(t, i, o);
2454
2525
  if (t = a, !l) {
2455
2526
  const g = s[c];
2456
2527
  n = n.add(d ? g.negate() : g);
2457
2528
  }
2458
2529
  }
2459
- return Lt(t), n;
2530
+ return $t(t), n;
2460
2531
  }
2461
2532
  getPrecomputes(e, s, t) {
2462
- let n = Xe.get(s);
2463
- return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), Xe.set(s, n))), n;
2533
+ let n = Je.get(s);
2534
+ return n || (n = this.precomputeWindow(s, e), e !== 1 && (typeof t == "function" && (n = t(n)), Je.set(s, n))), n;
2464
2535
  }
2465
2536
  cached(e, s, t) {
2466
- const n = Je(e);
2537
+ const n = Qe(e);
2467
2538
  return this.wNAF(n, this.getPrecomputes(n, e, t), s);
2468
2539
  }
2469
2540
  unsafe(e, s, t, n) {
2470
- const o = Je(e);
2541
+ const o = Qe(e);
2471
2542
  return o === 1 ? this._unsafeLadder(e, s, n) : this.wNAFUnsafe(o, this.getPrecomputes(o, e, t), s, n);
2472
2543
  }
2473
2544
  // We calculate precomputes for elliptic curve point multiplication
2474
2545
  // using windowed method. This specifies window size and
2475
2546
  // stores precomputed values. Usually only base point would be precomputed.
2476
2547
  createCache(e, s) {
2477
- ds(s, this.bits), us.set(e, s), Xe.delete(e);
2548
+ hs(s, this.bits), fs.set(e, s), Je.delete(e);
2478
2549
  }
2479
2550
  hasCache(e) {
2480
- return Je(e) !== 1;
2551
+ return Qe(e) !== 1;
2481
2552
  }
2482
2553
  }
2483
- function Or(r, e, s, t) {
2554
+ function Pr(r, e, s, t) {
2484
2555
  let n = e, o = r.ZERO, i = r.ZERO;
2485
- for (; s > Ie || t > Ie; )
2486
- s & ye && (o = o.add(n)), t & ye && (i = i.add(n)), n = n.double(), s >>= ye, t >>= ye;
2556
+ for (; s > Ae || t > Ae; )
2557
+ s & be && (o = o.add(n)), t & be && (i = i.add(n)), n = n.double(), s >>= be, t >>= be;
2487
2558
  return { p1: o, p2: i };
2488
2559
  }
2489
- function Dt(r, e, s) {
2560
+ function Bt(r, e, s) {
2490
2561
  if (e) {
2491
2562
  if (e.ORDER !== r)
2492
2563
  throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
2493
- return Sr(e), e;
2564
+ return Ar(e), e;
2494
2565
  } else
2495
- return je(r, { isLE: s });
2566
+ return Ve(r, { isLE: s });
2496
2567
  }
2497
- function Cr(r, e, s = {}, t) {
2568
+ function Lr(r, e, s = {}, t) {
2498
2569
  if (t === void 0 && (t = r === "edwards"), !e || typeof e != "object")
2499
2570
  throw new Error(`expected valid ${r} CURVE object`);
2500
2571
  for (const c of ["p", "n", "h"]) {
2501
2572
  const l = e[c];
2502
- if (!(typeof l == "bigint" && l > Ie))
2573
+ if (!(typeof l == "bigint" && l > Ae))
2503
2574
  throw new Error(`CURVE.${c} must be positive bigint`);
2504
2575
  }
2505
- const n = Dt(e.p, s.Fp, t), o = Dt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
2576
+ const n = Bt(e.p, s.Fp, t), o = Bt(e.n, s.Fn, t), a = ["Gx", "Gy", "a", "b"];
2506
2577
  for (const c of a)
2507
2578
  if (!n.isValid(e[c]))
2508
2579
  throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
2509
2580
  return e = Object.freeze(Object.assign({}, e)), { CURVE: e, Fp: n, Fn: o };
2510
2581
  }
2511
- function Nr(r, e) {
2582
+ function Dr(r, e) {
2512
2583
  return function(t) {
2513
2584
  const n = r(t);
2514
2585
  return { secretKey: n, publicKey: e(n) };
2515
2586
  };
2516
2587
  }
2517
- class hs {
2588
+ class gs {
2518
2589
  constructor(e, s) {
2519
- b(this, "oHash");
2520
- b(this, "iHash");
2521
- b(this, "blockLen");
2522
- b(this, "outputLen");
2523
- b(this, "finished", !1);
2524
- b(this, "destroyed", !1);
2525
- if (jt(e), U(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
2590
+ v(this, "oHash");
2591
+ v(this, "iHash");
2592
+ v(this, "blockLen");
2593
+ v(this, "outputLen");
2594
+ v(this, "finished", !1);
2595
+ v(this, "destroyed", !1);
2596
+ if (Kt(e), F(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
2526
2597
  throw new Error("Expected instance of class which extends utils.Hash");
2527
2598
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
2528
2599
  const t = this.blockLen, n = new Uint8Array(t);
@@ -2532,13 +2603,13 @@ class hs {
2532
2603
  this.iHash.update(n), this.oHash = e.create();
2533
2604
  for (let o = 0; o < n.length; o++)
2534
2605
  n[o] ^= 106;
2535
- this.oHash.update(n), Ae(n);
2606
+ this.oHash.update(n), Ie(n);
2536
2607
  }
2537
2608
  update(e) {
2538
2609
  return Te(this), this.iHash.update(e), this;
2539
2610
  }
2540
2611
  digestInto(e) {
2541
- Te(this), U(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2612
+ Te(this), F(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2542
2613
  }
2543
2614
  digest() {
2544
2615
  const e = new Uint8Array(this.oHash.outputLen);
@@ -2556,39 +2627,39 @@ class hs {
2556
2627
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
2557
2628
  }
2558
2629
  }
2559
- const fs = (r, e, s) => new hs(r, e).update(s).digest();
2560
- fs.create = (r, e) => new hs(r, e);
2630
+ const ps = (r, e, s) => new gs(r, e).update(s).digest();
2631
+ ps.create = (r, e) => new gs(r, e);
2561
2632
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2562
- const $t = (r, e) => (r + (r >= 0 ? e : -e) / gs) / e;
2563
- function Pr(r, e, s) {
2564
- const [[t, n], [o, i]] = e, a = $t(i * r, s), c = $t(-n * r, s);
2633
+ const Mt = (r, e) => (r + (r >= 0 ? e : -e) / _s) / e;
2634
+ function $r(r, e, s) {
2635
+ const [[t, n], [o, i]] = e, a = Mt(i * r, s), c = Mt(-n * r, s);
2565
2636
  let l = r - a * t - c * o, d = -a * n - c * i;
2566
- const g = l < ae, w = d < ae;
2567
- g && (l = -l), w && (d = -d);
2568
- const m = lt(Math.ceil(pr(s) / 2)) + Ee;
2569
- if (l < ae || l >= m || d < ae || d >= m)
2637
+ const g = l < le, m = d < le;
2638
+ g && (l = -l), m && (d = -d);
2639
+ const x = dt(Math.ceil(wr(s) / 2)) + Ee;
2640
+ if (l < le || l >= x || d < le || d >= x)
2570
2641
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
2571
- return { k1neg: g, k1: l, k2neg: w, k2: d };
2642
+ return { k1neg: g, k1: l, k2neg: m, k2: d };
2572
2643
  }
2573
- function rt(r) {
2644
+ function nt(r) {
2574
2645
  if (!["compact", "recovered", "der"].includes(r))
2575
2646
  throw new Error('Signature format must be "compact", "recovered", or "der"');
2576
2647
  return r;
2577
2648
  }
2578
- function Qe(r, e) {
2649
+ function et(r, e) {
2579
2650
  const s = {};
2580
2651
  for (let t of Object.keys(e))
2581
2652
  s[t] = r[t] === void 0 ? e[t] : r[t];
2582
- return Ue(s.lowS, "lowS"), Ue(s.prehash, "prehash"), s.format !== void 0 && rt(s.format), s;
2653
+ return He(s.lowS, "lowS"), He(s.prehash, "prehash"), s.format !== void 0 && nt(s.format), s;
2583
2654
  }
2584
- class kr extends Error {
2655
+ class Br extends Error {
2585
2656
  constructor(e = "") {
2586
2657
  super(e);
2587
2658
  }
2588
2659
  }
2589
2660
  const pe = {
2590
2661
  // asn.1 DER encoding utils
2591
- Err: kr,
2662
+ Err: Br,
2592
2663
  // Basic building block is TLV (Tag-Length-Value)
2593
2664
  _tlv: {
2594
2665
  encode: (r, e) => {
@@ -2597,11 +2668,11 @@ const pe = {
2597
2668
  throw new s("tlv.encode: wrong tag");
2598
2669
  if (e.length & 1)
2599
2670
  throw new s("tlv.encode: unpadded data");
2600
- const t = e.length / 2, n = De(t);
2671
+ const t = e.length / 2, n = $e(t);
2601
2672
  if (n.length / 2 & 128)
2602
2673
  throw new s("tlv.encode: long form length too big");
2603
- const o = t > 127 ? De(n.length / 2 | 128) : "";
2604
- return De(r) + o + n + e;
2674
+ const o = t > 127 ? $e(n.length / 2 | 128) : "";
2675
+ return $e(r) + o + n + e;
2605
2676
  },
2606
2677
  // v - value, l - left bytes (unparsed)
2607
2678
  decode(r, e) {
@@ -2644,9 +2715,9 @@ const pe = {
2644
2715
  _int: {
2645
2716
  encode(r) {
2646
2717
  const { Err: e } = pe;
2647
- if (r < ae)
2718
+ if (r < le)
2648
2719
  throw new e("integer: negative integers are not allowed");
2649
- let s = De(r);
2720
+ let s = $e(r);
2650
2721
  if (Number.parseInt(s[0], 16) & 8 && (s = "00" + s), s.length & 1)
2651
2722
  throw new e("unexpected DER parsing assertion: unpadded hex");
2652
2723
  return s;
@@ -2657,11 +2728,11 @@ const pe = {
2657
2728
  throw new e("invalid signature integer: negative");
2658
2729
  if (r[0] === 0 && !(r[1] & 128))
2659
2730
  throw new e("invalid signature integer: unnecessary leading zero");
2660
- return We(r);
2731
+ return je(r);
2661
2732
  }
2662
2733
  },
2663
2734
  toSig(r) {
2664
- const { Err: e, _int: s, _tlv: t } = pe, n = U(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
2735
+ const { Err: e, _int: s, _tlv: t } = pe, n = F(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
2665
2736
  if (i.length)
2666
2737
  throw new e("invalid signature: left bytes after parsing");
2667
2738
  const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
@@ -2673,12 +2744,12 @@ const pe = {
2673
2744
  const { _tlv: e, _int: s } = pe, t = e.encode(2, s.encode(r.r)), n = e.encode(2, s.encode(r.s)), o = t + n;
2674
2745
  return e.encode(48, o);
2675
2746
  }
2676
- }, ae = BigInt(0), Ee = BigInt(1), gs = BigInt(2), $e = BigInt(3), Lr = BigInt(4);
2677
- function Dr(r, e = {}) {
2678
- const s = Cr("weierstrass", r, e), { Fp: t, Fn: n } = s;
2747
+ }, le = BigInt(0), Ee = BigInt(1), _s = BigInt(2), Be = BigInt(3), Mr = BigInt(4);
2748
+ function Ur(r, e = {}) {
2749
+ const s = Lr("weierstrass", r, e), { Fp: t, Fn: n } = s;
2679
2750
  let o = s.CURVE;
2680
2751
  const { h: i, n: a } = o;
2681
- dt(e, {}, {
2752
+ ut(e, {}, {
2682
2753
  allowInfinityPoint: "boolean",
2683
2754
  clearCofactor: "function",
2684
2755
  isTorsionFree: "function",
@@ -2689,111 +2760,111 @@ function Dr(r, e = {}) {
2689
2760
  const { endo: c } = e;
2690
2761
  if (c && (!t.is0(o.a) || typeof c.beta != "bigint" || !Array.isArray(c.basises)))
2691
2762
  throw new Error('invalid endo: expected "beta": bigint and "basises": array');
2692
- const l = xs(t, n);
2763
+ const l = ms(t, n);
2693
2764
  function d() {
2694
2765
  if (!t.isOdd)
2695
2766
  throw new Error("compression is not supported: Field does not have .isOdd()");
2696
2767
  }
2697
- function g(k, u, h) {
2698
- const { x: y, y: S } = u.toAffine(), I = t.toBytes(y);
2699
- if (Ue(h, "isCompressed"), h) {
2768
+ function g(P, u, h) {
2769
+ const { x: y, y: I } = u.toAffine(), R = t.toBytes(y);
2770
+ if (He(h, "isCompressed"), h) {
2700
2771
  d();
2701
- const T = !t.isOdd(S);
2702
- return xe(ps(T), I);
2772
+ const A = !t.isOdd(I);
2773
+ return _e(xs(A), R);
2703
2774
  } else
2704
- return xe(Uint8Array.of(4), I, t.toBytes(S));
2705
- }
2706
- function w(k) {
2707
- U(k, void 0, "Point");
2708
- const { publicKey: u, publicKeyUncompressed: h } = l, y = k.length, S = k[0], I = k.subarray(1);
2709
- if (y === u && (S === 2 || S === 3)) {
2710
- const T = t.fromBytes(I);
2711
- if (!t.isValid(T))
2775
+ return _e(Uint8Array.of(4), R, t.toBytes(I));
2776
+ }
2777
+ function m(P) {
2778
+ F(P, void 0, "Point");
2779
+ const { publicKey: u, publicKeyUncompressed: h } = l, y = P.length, I = P[0], R = P.subarray(1);
2780
+ if (y === u && (I === 2 || I === 3)) {
2781
+ const A = t.fromBytes(R);
2782
+ if (!t.isValid(A))
2712
2783
  throw new Error("bad point: is not on curve, wrong x");
2713
- const R = A(T);
2714
- let v;
2784
+ const O = b(A);
2785
+ let T;
2715
2786
  try {
2716
- v = t.sqrt(R);
2787
+ T = t.sqrt(O);
2717
2788
  } catch (W) {
2718
- const M = W instanceof Error ? ": " + W.message : "";
2719
- throw new Error("bad point: is not on curve, sqrt error" + M);
2789
+ const U = W instanceof Error ? ": " + W.message : "";
2790
+ throw new Error("bad point: is not on curve, sqrt error" + U);
2720
2791
  }
2721
2792
  d();
2722
- const O = t.isOdd(v);
2723
- return (S & 1) === 1 !== O && (v = t.neg(v)), { x: T, y: v };
2724
- } else if (y === h && S === 4) {
2725
- const T = t.BYTES, R = t.fromBytes(I.subarray(0, T)), v = t.fromBytes(I.subarray(T, T * 2));
2726
- if (!E(R, v))
2793
+ const C = t.isOdd(T);
2794
+ return (I & 1) === 1 !== C && (T = t.neg(T)), { x: A, y: T };
2795
+ } else if (y === h && I === 4) {
2796
+ const A = t.BYTES, O = t.fromBytes(R.subarray(0, A)), T = t.fromBytes(R.subarray(A, A * 2));
2797
+ if (!S(O, T))
2727
2798
  throw new Error("bad point: is not on curve");
2728
- return { x: R, y: v };
2799
+ return { x: O, y: T };
2729
2800
  } else
2730
2801
  throw new Error(`bad point: got length ${y}, expected compressed=${u} or uncompressed=${h}`);
2731
2802
  }
2732
- const m = e.toBytes || g, x = e.fromBytes || w;
2733
- function A(k) {
2734
- const u = t.sqr(k), h = t.mul(u, k);
2735
- return t.add(t.add(h, t.mul(k, o.a)), o.b);
2803
+ const x = e.toBytes || g, w = e.fromBytes || m;
2804
+ function b(P) {
2805
+ const u = t.sqr(P), h = t.mul(u, P);
2806
+ return t.add(t.add(h, t.mul(P, o.a)), o.b);
2736
2807
  }
2737
- function E(k, u) {
2738
- const h = t.sqr(u), y = A(k);
2808
+ function S(P, u) {
2809
+ const h = t.sqr(u), y = b(P);
2739
2810
  return t.eql(h, y);
2740
2811
  }
2741
- if (!E(o.Gx, o.Gy))
2812
+ if (!S(o.Gx, o.Gy))
2742
2813
  throw new Error("bad curve params: generator point");
2743
- const C = t.mul(t.pow(o.a, $e), Lr), q = t.mul(t.sqr(o.b), BigInt(27));
2744
- if (t.is0(t.add(C, q)))
2814
+ const E = t.mul(t.pow(o.a, Be), Mr), q = t.mul(t.sqr(o.b), BigInt(27));
2815
+ if (t.is0(t.add(E, q)))
2745
2816
  throw new Error("bad curve params: a or b");
2746
- function $(k, u, h = !1) {
2817
+ function M(P, u, h = !1) {
2747
2818
  if (!t.isValid(u) || h && t.is0(u))
2748
- throw new Error(`bad point coordinate ${k}`);
2819
+ throw new Error(`bad point coordinate ${P}`);
2749
2820
  return u;
2750
2821
  }
2751
- function B(k) {
2752
- if (!(k instanceof Y))
2822
+ function D(P) {
2823
+ if (!(P instanceof Z))
2753
2824
  throw new Error("Weierstrass Point expected");
2754
2825
  }
2755
- function F(k) {
2826
+ function B(P) {
2756
2827
  if (!c || !c.basises)
2757
2828
  throw new Error("no endo");
2758
- return Pr(k, c.basises, n.ORDER);
2829
+ return $r(P, c.basises, n.ORDER);
2759
2830
  }
2760
- const se = Ot((k, u) => {
2761
- const { X: h, Y: y, Z: S } = k;
2762
- if (t.eql(S, t.ONE))
2831
+ const Q = kt((P, u) => {
2832
+ const { X: h, Y: y, Z: I } = P;
2833
+ if (t.eql(I, t.ONE))
2763
2834
  return { x: h, y };
2764
- const I = k.is0();
2765
- u == null && (u = I ? t.ONE : t.inv(S));
2766
- const T = t.mul(h, u), R = t.mul(y, u), v = t.mul(S, u);
2767
- if (I)
2835
+ const R = P.is0();
2836
+ u == null && (u = R ? t.ONE : t.inv(I));
2837
+ const A = t.mul(h, u), O = t.mul(y, u), T = t.mul(I, u);
2838
+ if (R)
2768
2839
  return { x: t.ZERO, y: t.ZERO };
2769
- if (!t.eql(v, t.ONE))
2840
+ if (!t.eql(T, t.ONE))
2770
2841
  throw new Error("invZ was invalid");
2771
- return { x: T, y: R };
2772
- }), be = Ot((k) => {
2773
- if (k.is0()) {
2774
- if (e.allowInfinityPoint && !t.is0(k.Y))
2842
+ return { x: A, y: O };
2843
+ }), ve = kt((P) => {
2844
+ if (P.is0()) {
2845
+ if (e.allowInfinityPoint && !t.is0(P.Y))
2775
2846
  return;
2776
2847
  throw new Error("bad point: ZERO");
2777
2848
  }
2778
- const { x: u, y: h } = k.toAffine();
2849
+ const { x: u, y: h } = P.toAffine();
2779
2850
  if (!t.isValid(u) || !t.isValid(h))
2780
2851
  throw new Error("bad point: x or y not field elements");
2781
- if (!E(u, h))
2852
+ if (!S(u, h))
2782
2853
  throw new Error("bad point: equation left != right");
2783
- if (!k.isTorsionFree())
2854
+ if (!P.isTorsionFree())
2784
2855
  throw new Error("bad point: not in prime-order subgroup");
2785
2856
  return !0;
2786
2857
  });
2787
- function he(k, u, h, y, S) {
2788
- return h = new Y(t.mul(h.X, k), h.Y, h.Z), u = He(y, u), h = He(S, h), u.add(h);
2858
+ function he(P, u, h, y, I) {
2859
+ return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(y, u), h = Ge(I, h), u.add(h);
2789
2860
  }
2790
2861
  const L = class L {
2791
2862
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2792
2863
  constructor(u, h, y) {
2793
- b(this, "X");
2794
- b(this, "Y");
2795
- b(this, "Z");
2796
- this.X = $("x", u), this.Y = $("y", h, !0), this.Z = $("z", y), Object.freeze(this);
2864
+ v(this, "X");
2865
+ v(this, "Y");
2866
+ v(this, "Z");
2867
+ this.X = M("x", u), this.Y = M("y", h, !0), this.Z = M("z", y), Object.freeze(this);
2797
2868
  }
2798
2869
  static CURVE() {
2799
2870
  return o;
@@ -2808,7 +2879,7 @@ function Dr(r, e = {}) {
2808
2879
  return t.is0(h) && t.is0(y) ? L.ZERO : new L(h, y, t.ONE);
2809
2880
  }
2810
2881
  static fromBytes(u) {
2811
- const h = L.fromAffine(x(U(u, void 0, "point")));
2882
+ const h = L.fromAffine(w(F(u, void 0, "point")));
2812
2883
  return h.assertValidity(), h;
2813
2884
  }
2814
2885
  static fromHex(u) {
@@ -2827,12 +2898,12 @@ function Dr(r, e = {}) {
2827
2898
  * @returns
2828
2899
  */
2829
2900
  precompute(u = 8, h = !0) {
2830
- return ne.createCache(this, u), h || this.multiply($e), this;
2901
+ return ne.createCache(this, u), h || this.multiply(Be), this;
2831
2902
  }
2832
2903
  // TODO: return `this`
2833
2904
  /** A point on curve is valid if it conforms to equation. */
2834
2905
  assertValidity() {
2835
- be(this);
2906
+ ve(this);
2836
2907
  }
2837
2908
  hasEvenY() {
2838
2909
  const { y: u } = this.toAffine();
@@ -2842,9 +2913,9 @@ function Dr(r, e = {}) {
2842
2913
  }
2843
2914
  /** Compare one point to another. */
2844
2915
  equals(u) {
2845
- B(u);
2846
- const { X: h, Y: y, Z: S } = this, { X: I, Y: T, Z: R } = u, v = t.eql(t.mul(h, R), t.mul(I, S)), O = t.eql(t.mul(y, R), t.mul(T, S));
2847
- return v && O;
2916
+ D(u);
2917
+ const { X: h, Y: y, Z: I } = this, { X: R, Y: A, Z: O } = u, T = t.eql(t.mul(h, O), t.mul(R, I)), C = t.eql(t.mul(y, O), t.mul(A, I));
2918
+ return T && C;
2848
2919
  }
2849
2920
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
2850
2921
  negate() {
@@ -2855,23 +2926,23 @@ function Dr(r, e = {}) {
2855
2926
  // https://eprint.iacr.org/2015/1060, algorithm 3
2856
2927
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
2857
2928
  double() {
2858
- const { a: u, b: h } = o, y = t.mul(h, $e), { X: S, Y: I, Z: T } = this;
2859
- let R = t.ZERO, v = t.ZERO, O = t.ZERO, P = t.mul(S, S), W = t.mul(I, I), M = t.mul(T, T), N = t.mul(S, I);
2860
- return N = t.add(N, N), O = t.mul(S, T), O = t.add(O, O), R = t.mul(u, O), v = t.mul(y, M), v = t.add(R, v), R = t.sub(W, v), v = t.add(W, v), v = t.mul(R, v), R = t.mul(N, R), O = t.mul(y, O), M = t.mul(u, M), N = t.sub(P, M), N = t.mul(u, N), N = t.add(N, O), O = t.add(P, P), P = t.add(O, P), P = t.add(P, M), P = t.mul(P, N), v = t.add(v, P), M = t.mul(I, T), M = t.add(M, M), P = t.mul(M, N), R = t.sub(R, P), O = t.mul(M, W), O = t.add(O, O), O = t.add(O, O), new L(R, v, O);
2929
+ const { a: u, b: h } = o, y = t.mul(h, Be), { X: I, Y: R, Z: A } = this;
2930
+ let O = t.ZERO, T = t.ZERO, C = t.ZERO, N = t.mul(I, I), W = t.mul(R, R), U = t.mul(A, A), k = t.mul(I, R);
2931
+ return k = t.add(k, k), C = t.mul(I, A), C = t.add(C, C), O = t.mul(u, C), T = t.mul(y, U), T = t.add(O, T), O = t.sub(W, T), T = t.add(W, T), T = t.mul(O, T), O = t.mul(k, O), C = t.mul(y, C), U = t.mul(u, U), k = t.sub(N, U), k = t.mul(u, k), k = t.add(k, C), C = t.add(N, N), N = t.add(C, N), N = t.add(N, U), N = t.mul(N, k), T = t.add(T, N), U = t.mul(R, A), U = t.add(U, U), N = t.mul(U, k), O = t.sub(O, N), C = t.mul(U, W), C = t.add(C, C), C = t.add(C, C), new L(O, T, C);
2861
2932
  }
2862
2933
  // Renes-Costello-Batina exception-free addition formula.
2863
2934
  // There is 30% faster Jacobian formula, but it is not complete.
2864
2935
  // https://eprint.iacr.org/2015/1060, algorithm 1
2865
2936
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
2866
2937
  add(u) {
2867
- B(u);
2868
- const { X: h, Y: y, Z: S } = this, { X: I, Y: T, Z: R } = u;
2869
- let v = t.ZERO, O = t.ZERO, P = t.ZERO;
2870
- const W = o.a, M = t.mul(o.b, $e);
2871
- let N = t.mul(h, I), j = t.mul(y, T), V = t.mul(S, R), J = t.add(h, y), H = t.add(I, T);
2872
- J = t.mul(J, H), H = t.add(N, j), J = t.sub(J, H), H = t.add(h, S);
2873
- let K = t.add(I, R);
2874
- return H = t.mul(H, K), K = t.add(N, V), H = t.sub(H, K), K = t.add(y, S), v = t.add(T, R), K = t.mul(K, v), v = t.add(j, V), K = t.sub(K, v), P = t.mul(W, H), v = t.mul(M, V), P = t.add(v, P), v = t.sub(j, P), P = t.add(j, P), O = t.mul(v, P), j = t.add(N, N), j = t.add(j, N), V = t.mul(W, V), H = t.mul(M, H), j = t.add(j, V), V = t.sub(N, V), V = t.mul(W, V), H = t.add(H, V), N = t.mul(j, H), O = t.add(O, N), N = t.mul(K, H), v = t.mul(J, v), v = t.sub(v, N), N = t.mul(J, j), P = t.mul(K, P), P = t.add(P, N), new L(v, O, P);
2938
+ D(u);
2939
+ const { X: h, Y: y, Z: I } = this, { X: R, Y: A, Z: O } = u;
2940
+ let T = t.ZERO, C = t.ZERO, N = t.ZERO;
2941
+ const W = o.a, U = t.mul(o.b, Be);
2942
+ let k = t.mul(h, R), j = t.mul(y, A), V = t.mul(I, O), ee = t.add(h, y), H = t.add(R, A);
2943
+ ee = t.mul(ee, H), H = t.add(k, j), ee = t.sub(ee, H), H = t.add(h, I);
2944
+ let K = t.add(R, O);
2945
+ return H = t.mul(H, K), K = t.add(k, V), H = t.sub(H, K), K = t.add(y, I), T = t.add(A, O), K = t.mul(K, T), T = t.add(j, V), K = t.sub(K, T), N = t.mul(W, H), T = t.mul(U, V), N = t.add(T, N), T = t.sub(j, N), N = t.add(j, N), C = t.mul(T, N), j = t.add(k, k), j = t.add(j, k), V = t.mul(W, V), H = t.mul(U, H), j = t.add(j, V), V = t.sub(k, V), V = t.mul(W, V), H = t.add(H, V), k = t.mul(j, H), C = t.add(C, k), k = t.mul(K, H), T = t.mul(ee, T), T = t.sub(T, k), k = t.mul(ee, j), N = t.mul(K, N), N = t.add(N, k), new L(T, C, N);
2875
2946
  }
2876
2947
  subtract(u) {
2877
2948
  return this.add(u.negate());
@@ -2892,16 +2963,16 @@ function Dr(r, e = {}) {
2892
2963
  const { endo: h } = e;
2893
2964
  if (!n.isValidNot0(u))
2894
2965
  throw new Error("invalid scalar: out of range");
2895
- let y, S;
2896
- const I = (T) => ne.cached(this, T, (R) => Pt(L, R));
2966
+ let y, I;
2967
+ const R = (A) => ne.cached(this, A, (O) => Lt(L, O));
2897
2968
  if (h) {
2898
- const { k1neg: T, k1: R, k2neg: v, k2: O } = F(u), { p: P, f: W } = I(R), { p: M, f: N } = I(O);
2899
- S = W.add(N), y = he(h.beta, P, M, T, v);
2969
+ const { k1neg: A, k1: O, k2neg: T, k2: C } = B(u), { p: N, f: W } = R(O), { p: U, f: k } = R(C);
2970
+ I = W.add(k), y = he(h.beta, N, U, A, T);
2900
2971
  } else {
2901
- const { p: T, f: R } = I(u);
2902
- y = T, S = R;
2972
+ const { p: A, f: O } = R(u);
2973
+ y = A, I = O;
2903
2974
  }
2904
- return Pt(L, [y, S])[0];
2975
+ return Lt(L, [y, I])[0];
2905
2976
  }
2906
2977
  /**
2907
2978
  * Non-constant-time multiplication. Uses double-and-add algorithm.
@@ -2912,15 +2983,15 @@ function Dr(r, e = {}) {
2912
2983
  const { endo: h } = e, y = this;
2913
2984
  if (!n.isValid(u))
2914
2985
  throw new Error("invalid scalar: out of range");
2915
- if (u === ae || y.is0())
2986
+ if (u === le || y.is0())
2916
2987
  return L.ZERO;
2917
2988
  if (u === Ee)
2918
2989
  return y;
2919
2990
  if (ne.hasCache(this))
2920
2991
  return this.multiply(u);
2921
2992
  if (h) {
2922
- const { k1neg: S, k1: I, k2neg: T, k2: R } = F(u), { p1: v, p2: O } = Or(L, y, I, R);
2923
- return he(h.beta, v, O, S, T);
2993
+ const { k1neg: I, k1: R, k2neg: A, k2: O } = B(u), { p1: T, p2: C } = Pr(L, y, R, O);
2994
+ return he(h.beta, T, C, I, A);
2924
2995
  } else
2925
2996
  return ne.unsafe(y, u);
2926
2997
  }
@@ -2929,7 +3000,7 @@ function Dr(r, e = {}) {
2929
3000
  * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
2930
3001
  */
2931
3002
  toAffine(u) {
2932
- return se(this, u);
3003
+ return Q(this, u);
2933
3004
  }
2934
3005
  /**
2935
3006
  * Checks whether Point is free of torsion elements (is in prime subgroup).
@@ -2947,29 +3018,29 @@ function Dr(r, e = {}) {
2947
3018
  return this.multiplyUnsafe(i).is0();
2948
3019
  }
2949
3020
  toBytes(u = !0) {
2950
- return Ue(u, "isCompressed"), this.assertValidity(), m(L, this, u);
3021
+ return He(u, "isCompressed"), this.assertValidity(), x(L, this, u);
2951
3022
  }
2952
3023
  toHex(u = !0) {
2953
- return Ce(this.toBytes(u));
3024
+ return ke(this.toBytes(u));
2954
3025
  }
2955
3026
  toString() {
2956
3027
  return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
2957
3028
  }
2958
3029
  };
2959
3030
  // base / generator point
2960
- b(L, "BASE", new L(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
2961
- b(L, "ZERO", new L(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3031
+ v(L, "BASE", new L(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3032
+ v(L, "ZERO", new L(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
2962
3033
  // math field
2963
- b(L, "Fp", t), // scalar field
2964
- b(L, "Fn", n);
2965
- let Y = L;
2966
- const _e = n.BITS, ne = new Rr(Y, e.endo ? Math.ceil(_e / 2) : _e);
2967
- return Y.BASE.precompute(8), Y;
3034
+ v(L, "Fp", t), // scalar field
3035
+ v(L, "Fn", n);
3036
+ let Z = L;
3037
+ const xe = n.BITS, ne = new Nr(Z, e.endo ? Math.ceil(xe / 2) : xe);
3038
+ return Z.BASE.precompute(8), Z;
2968
3039
  }
2969
- function ps(r) {
3040
+ function xs(r) {
2970
3041
  return Uint8Array.of(r ? 2 : 3);
2971
3042
  }
2972
- function xs(r, e) {
3043
+ function ms(r, e) {
2973
3044
  return {
2974
3045
  secretKey: e.BYTES,
2975
3046
  publicKey: 1 + r.BYTES,
@@ -2978,107 +3049,107 @@ function xs(r, e) {
2978
3049
  signature: 2 * e.BYTES
2979
3050
  };
2980
3051
  }
2981
- function $r(r, e = {}) {
2982
- const { Fn: s } = r, t = e.randomBytes || Yt, n = Object.assign(xs(r.Fp, s), { seed: ls(s.ORDER) });
2983
- function o(m) {
3052
+ function Fr(r, e = {}) {
3053
+ const { Fn: s } = r, t = e.randomBytes || Xt, n = Object.assign(ms(r.Fp, s), { seed: us(s.ORDER) });
3054
+ function o(x) {
2984
3055
  try {
2985
- const x = s.fromBytes(m);
2986
- return s.isValidNot0(x);
3056
+ const w = s.fromBytes(x);
3057
+ return s.isValidNot0(w);
2987
3058
  } catch {
2988
3059
  return !1;
2989
3060
  }
2990
3061
  }
2991
- function i(m, x) {
2992
- const { publicKey: A, publicKeyUncompressed: E } = n;
3062
+ function i(x, w) {
3063
+ const { publicKey: b, publicKeyUncompressed: S } = n;
2993
3064
  try {
2994
- const C = m.length;
2995
- return x === !0 && C !== A || x === !1 && C !== E ? !1 : !!r.fromBytes(m);
3065
+ const E = x.length;
3066
+ return w === !0 && E !== b || w === !1 && E !== S ? !1 : !!r.fromBytes(x);
2996
3067
  } catch {
2997
3068
  return !1;
2998
3069
  }
2999
3070
  }
3000
- function a(m = t(n.seed)) {
3001
- return Ir(U(m, n.seed, "seed"), s.ORDER);
3071
+ function a(x = t(n.seed)) {
3072
+ return kr(F(x, n.seed, "seed"), s.ORDER);
3002
3073
  }
3003
- function c(m, x = !0) {
3004
- return r.BASE.multiply(s.fromBytes(m)).toBytes(x);
3074
+ function c(x, w = !0) {
3075
+ return r.BASE.multiply(s.fromBytes(x)).toBytes(w);
3005
3076
  }
3006
- function l(m) {
3007
- const { secretKey: x, publicKey: A, publicKeyUncompressed: E } = n;
3008
- if (!it(m) || "_lengths" in s && s._lengths || x === A)
3077
+ function l(x) {
3078
+ const { secretKey: w, publicKey: b, publicKeyUncompressed: S } = n;
3079
+ if (!at(x) || "_lengths" in s && s._lengths || w === b)
3009
3080
  return;
3010
- const C = U(m, void 0, "key").length;
3011
- return C === A || C === E;
3081
+ const E = F(x, void 0, "key").length;
3082
+ return E === b || E === S;
3012
3083
  }
3013
- function d(m, x, A = !0) {
3014
- if (l(m) === !0)
3084
+ function d(x, w, b = !0) {
3085
+ if (l(x) === !0)
3015
3086
  throw new Error("first arg must be private key");
3016
- if (l(x) === !1)
3087
+ if (l(w) === !1)
3017
3088
  throw new Error("second arg must be public key");
3018
- const E = s.fromBytes(m);
3019
- return r.fromBytes(x).multiply(E).toBytes(A);
3089
+ const S = s.fromBytes(x);
3090
+ return r.fromBytes(w).multiply(S).toBytes(b);
3020
3091
  }
3021
3092
  const g = {
3022
3093
  isValidSecretKey: o,
3023
3094
  isValidPublicKey: i,
3024
3095
  randomSecretKey: a
3025
- }, w = Nr(a, c);
3026
- return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: w, Point: r, utils: g, lengths: n });
3096
+ }, m = Dr(a, c);
3097
+ return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils: g, lengths: n });
3027
3098
  }
3028
- function Br(r, e, s = {}) {
3029
- jt(e), dt(s, {}, {
3099
+ function Hr(r, e, s = {}) {
3100
+ Kt(e), ut(s, {}, {
3030
3101
  hmac: "function",
3031
3102
  lowS: "boolean",
3032
3103
  randomBytes: "function",
3033
3104
  bits2int: "function",
3034
3105
  bits2int_modN: "function"
3035
3106
  }), s = Object.assign({}, s);
3036
- const t = s.randomBytes || Yt, n = s.hmac || ((u, h) => fs(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: g, utils: w, lengths: m } = $r(r, s), x = {
3107
+ const t = s.randomBytes || Xt, n = s.hmac || ((u, h) => ps(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: g, utils: m, lengths: x } = Fr(r, s), w = {
3037
3108
  prehash: !0,
3038
3109
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
3039
3110
  format: "compact",
3040
3111
  extraEntropy: !1
3041
- }, A = a * gs < o.ORDER;
3042
- function E(u) {
3112
+ }, b = a * _s < o.ORDER;
3113
+ function S(u) {
3043
3114
  const h = a >> Ee;
3044
3115
  return u > h;
3045
3116
  }
3046
- function C(u, h) {
3117
+ function E(u, h) {
3047
3118
  if (!i.isValidNot0(h))
3048
3119
  throw new Error(`invalid signature ${u}: out of range 1..Point.Fn.ORDER`);
3049
3120
  return h;
3050
3121
  }
3051
3122
  function q() {
3052
- if (A)
3123
+ if (b)
3053
3124
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
3054
3125
  }
3055
- function $(u, h) {
3056
- rt(h);
3057
- const y = m.signature, S = h === "compact" ? y : h === "recovered" ? y + 1 : void 0;
3058
- return U(u, S);
3059
- }
3060
- class B {
3061
- constructor(h, y, S) {
3062
- b(this, "r");
3063
- b(this, "s");
3064
- b(this, "recovery");
3065
- if (this.r = C("r", h), this.s = C("s", y), S != null) {
3066
- if (q(), ![0, 1, 2, 3].includes(S))
3126
+ function M(u, h) {
3127
+ nt(h);
3128
+ const y = x.signature, I = h === "compact" ? y : h === "recovered" ? y + 1 : void 0;
3129
+ return F(u, I);
3130
+ }
3131
+ class D {
3132
+ constructor(h, y, I) {
3133
+ v(this, "r");
3134
+ v(this, "s");
3135
+ v(this, "recovery");
3136
+ if (this.r = E("r", h), this.s = E("s", y), I != null) {
3137
+ if (q(), ![0, 1, 2, 3].includes(I))
3067
3138
  throw new Error("invalid recovery id");
3068
- this.recovery = S;
3139
+ this.recovery = I;
3069
3140
  }
3070
3141
  Object.freeze(this);
3071
3142
  }
3072
- static fromBytes(h, y = x.format) {
3073
- $(h, y);
3074
- let S;
3143
+ static fromBytes(h, y = w.format) {
3144
+ M(h, y);
3145
+ let I;
3075
3146
  if (y === "der") {
3076
- const { r: v, s: O } = pe.toSig(U(h));
3077
- return new B(v, O);
3147
+ const { r: T, s: C } = pe.toSig(F(h));
3148
+ return new D(T, C);
3078
3149
  }
3079
- y === "recovered" && (S = h[0], y = "compact", h = h.subarray(1));
3080
- const I = m.signature / 2, T = h.subarray(0, I), R = h.subarray(I, I * 2);
3081
- return new B(i.fromBytes(T), i.fromBytes(R), S);
3150
+ y === "recovered" && (I = h[0], y = "compact", h = h.subarray(1));
3151
+ const R = x.signature / 2, A = h.subarray(0, R), O = h.subarray(R, R * 2);
3152
+ return new D(i.fromBytes(A), i.fromBytes(O), I);
3082
3153
  }
3083
3154
  static fromHex(h, y) {
3084
3155
  return this.fromBytes(Fe(h), y);
@@ -3090,113 +3161,113 @@ function Br(r, e, s = {}) {
3090
3161
  return h;
3091
3162
  }
3092
3163
  addRecoveryBit(h) {
3093
- return new B(this.r, this.s, h);
3164
+ return new D(this.r, this.s, h);
3094
3165
  }
3095
3166
  recoverPublicKey(h) {
3096
- const { r: y, s: S } = this, I = this.assertRecovery(), T = I === 2 || I === 3 ? y + a : y;
3097
- if (!o.isValid(T))
3167
+ const { r: y, s: I } = this, R = this.assertRecovery(), A = R === 2 || R === 3 ? y + a : y;
3168
+ if (!o.isValid(A))
3098
3169
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
3099
- const R = o.toBytes(T), v = r.fromBytes(xe(ps((I & 1) === 0), R)), O = i.inv(T), P = se(U(h, void 0, "msgHash")), W = i.create(-P * O), M = i.create(S * O), N = r.BASE.multiplyUnsafe(W).add(v.multiplyUnsafe(M));
3100
- if (N.is0())
3170
+ const O = o.toBytes(A), T = r.fromBytes(_e(xs((R & 1) === 0), O)), C = i.inv(A), N = Q(F(h, void 0, "msgHash")), W = i.create(-N * C), U = i.create(I * C), k = r.BASE.multiplyUnsafe(W).add(T.multiplyUnsafe(U));
3171
+ if (k.is0())
3101
3172
  throw new Error("invalid recovery: point at infinify");
3102
- return N.assertValidity(), N;
3173
+ return k.assertValidity(), k;
3103
3174
  }
3104
3175
  // Signatures should be low-s, to prevent malleability.
3105
3176
  hasHighS() {
3106
- return E(this.s);
3177
+ return S(this.s);
3107
3178
  }
3108
- toBytes(h = x.format) {
3109
- if (rt(h), h === "der")
3179
+ toBytes(h = w.format) {
3180
+ if (nt(h), h === "der")
3110
3181
  return Fe(pe.hexFromSig(this));
3111
- const { r: y, s: S } = this, I = i.toBytes(y), T = i.toBytes(S);
3112
- return h === "recovered" ? (q(), xe(Uint8Array.of(this.assertRecovery()), I, T)) : xe(I, T);
3182
+ const { r: y, s: I } = this, R = i.toBytes(y), A = i.toBytes(I);
3183
+ return h === "recovered" ? (q(), _e(Uint8Array.of(this.assertRecovery()), R, A)) : _e(R, A);
3113
3184
  }
3114
3185
  toHex(h) {
3115
- return Ce(this.toBytes(h));
3186
+ return ke(this.toBytes(h));
3116
3187
  }
3117
3188
  }
3118
- const F = s.bits2int || function(h) {
3189
+ const B = s.bits2int || function(h) {
3119
3190
  if (h.length > 8192)
3120
3191
  throw new Error("input is too large");
3121
- const y = We(h), S = h.length * 8 - c;
3122
- return S > 0 ? y >> BigInt(S) : y;
3123
- }, se = s.bits2int_modN || function(h) {
3124
- return i.create(F(h));
3125
- }, be = lt(c);
3192
+ const y = je(h), I = h.length * 8 - c;
3193
+ return I > 0 ? y >> BigInt(I) : y;
3194
+ }, Q = s.bits2int_modN || function(h) {
3195
+ return i.create(B(h));
3196
+ }, ve = dt(c);
3126
3197
  function he(u) {
3127
- return gr("num < 2^" + c, u, ae, be), i.toBytes(u);
3198
+ return mr("num < 2^" + c, u, le, ve), i.toBytes(u);
3128
3199
  }
3129
- function Y(u, h) {
3130
- return U(u, void 0, "message"), h ? U(e(u), void 0, "prehashed message") : u;
3200
+ function Z(u, h) {
3201
+ return F(u, void 0, "message"), h ? F(e(u), void 0, "prehashed message") : u;
3131
3202
  }
3132
- function _e(u, h, y) {
3133
- const { lowS: S, prehash: I, extraEntropy: T } = Qe(y, x);
3134
- u = Y(u, I);
3135
- const R = se(u), v = i.fromBytes(h);
3136
- if (!i.isValidNot0(v))
3203
+ function xe(u, h, y) {
3204
+ const { lowS: I, prehash: R, extraEntropy: A } = et(y, w);
3205
+ u = Z(u, R);
3206
+ const O = Q(u), T = i.fromBytes(h);
3207
+ if (!i.isValidNot0(T))
3137
3208
  throw new Error("invalid private key");
3138
- const O = [he(v), he(R)];
3139
- if (T != null && T !== !1) {
3140
- const N = T === !0 ? t(m.secretKey) : T;
3141
- O.push(U(N, void 0, "extraEntropy"));
3209
+ const C = [he(T), he(O)];
3210
+ if (A != null && A !== !1) {
3211
+ const k = A === !0 ? t(x.secretKey) : A;
3212
+ C.push(F(k, void 0, "extraEntropy"));
3142
3213
  }
3143
- const P = xe(...O), W = R;
3144
- function M(N) {
3145
- const j = F(N);
3214
+ const N = _e(...C), W = O;
3215
+ function U(k) {
3216
+ const j = B(k);
3146
3217
  if (!i.isValidNot0(j))
3147
3218
  return;
3148
- const V = i.inv(j), J = r.BASE.multiply(j).toAffine(), H = i.create(J.x);
3149
- if (H === ae)
3219
+ const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(), H = i.create(ee.x);
3220
+ if (H === le)
3150
3221
  return;
3151
- const K = i.create(V * i.create(W + H * v));
3152
- if (K === ae)
3222
+ const K = i.create(V * i.create(W + H * T));
3223
+ if (K === le)
3153
3224
  return;
3154
- let xt = (J.x === H ? 0 : 2) | Number(J.y & Ee), _t = K;
3155
- return S && E(K) && (_t = i.neg(K), xt ^= 1), new B(H, _t, A ? void 0 : xt);
3225
+ let xt = (ee.x === H ? 0 : 2) | Number(ee.y & Ee), mt = K;
3226
+ return I && S(K) && (mt = i.neg(K), xt ^= 1), new D(H, mt, b ? void 0 : xt);
3156
3227
  }
3157
- return { seed: P, k2sig: M };
3228
+ return { seed: N, k2sig: U };
3158
3229
  }
3159
3230
  function ne(u, h, y = {}) {
3160
- const { seed: S, k2sig: I } = _e(u, h, y);
3161
- return xr(e.outputLen, i.BYTES, n)(S, I).toBytes(y.format);
3162
- }
3163
- function L(u, h, y, S = {}) {
3164
- const { lowS: I, prehash: T, format: R } = Qe(S, x);
3165
- if (y = U(y, void 0, "publicKey"), h = Y(h, T), !it(u)) {
3166
- const v = u instanceof B ? ", use sig.toBytes()" : "";
3167
- throw new Error("verify expects Uint8Array signature" + v);
3231
+ const { seed: I, k2sig: R } = xe(u, h, y);
3232
+ return yr(e.outputLen, i.BYTES, n)(I, R).toBytes(y.format);
3233
+ }
3234
+ function L(u, h, y, I = {}) {
3235
+ const { lowS: R, prehash: A, format: O } = et(I, w);
3236
+ if (y = F(y, void 0, "publicKey"), h = Z(h, A), !at(u)) {
3237
+ const T = u instanceof D ? ", use sig.toBytes()" : "";
3238
+ throw new Error("verify expects Uint8Array signature" + T);
3168
3239
  }
3169
- $(u, R);
3240
+ M(u, O);
3170
3241
  try {
3171
- const v = B.fromBytes(u, R), O = r.fromBytes(y);
3172
- if (I && v.hasHighS())
3242
+ const T = D.fromBytes(u, O), C = r.fromBytes(y);
3243
+ if (R && T.hasHighS())
3173
3244
  return !1;
3174
- const { r: P, s: W } = v, M = se(h), N = i.inv(W), j = i.create(M * N), V = i.create(P * N), J = r.BASE.multiplyUnsafe(j).add(O.multiplyUnsafe(V));
3175
- return J.is0() ? !1 : i.create(J.x) === P;
3245
+ const { r: N, s: W } = T, U = Q(h), k = i.inv(W), j = i.create(U * k), V = i.create(N * k), ee = r.BASE.multiplyUnsafe(j).add(C.multiplyUnsafe(V));
3246
+ return ee.is0() ? !1 : i.create(ee.x) === N;
3176
3247
  } catch {
3177
3248
  return !1;
3178
3249
  }
3179
3250
  }
3180
- function k(u, h, y = {}) {
3181
- const { prehash: S } = Qe(y, x);
3182
- return h = Y(h, S), B.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
3251
+ function P(u, h, y = {}) {
3252
+ const { prehash: I } = et(y, w);
3253
+ return h = Z(h, I), D.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
3183
3254
  }
3184
3255
  return Object.freeze({
3185
3256
  keygen: l,
3186
3257
  getPublicKey: d,
3187
3258
  getSharedSecret: g,
3188
- utils: w,
3189
- lengths: m,
3259
+ utils: m,
3260
+ lengths: x,
3190
3261
  Point: r,
3191
3262
  sign: ne,
3192
3263
  verify: L,
3193
- recoverPublicKey: k,
3194
- Signature: B,
3264
+ recoverPublicKey: P,
3265
+ Signature: D,
3195
3266
  hash: e
3196
3267
  });
3197
3268
  }
3198
3269
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3199
- const ht = {
3270
+ const ft = {
3200
3271
  p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
3201
3272
  n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
3202
3273
  h: BigInt(1),
@@ -3204,44 +3275,44 @@ const ht = {
3204
3275
  b: BigInt(7),
3205
3276
  Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
3206
3277
  Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
3207
- }, Mr = {
3278
+ }, Gr = {
3208
3279
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
3209
3280
  basises: [
3210
3281
  [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
3211
3282
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
3212
3283
  ]
3213
- }, Bt = /* @__PURE__ */ BigInt(2);
3214
- function Fr(r) {
3215
- const e = ht.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, g = ee(d, s, e) * d % e, w = ee(g, s, e) * d % e, m = ee(w, Bt, e) * l % e, x = ee(m, n, e) * m % e, A = ee(x, o, e) * x % e, E = ee(A, a, e) * A % e, C = ee(E, c, e) * E % e, q = ee(C, a, e) * A % e, $ = ee(q, s, e) * d % e, B = ee($, i, e) * x % e, F = ee(B, t, e) * l % e, se = ee(F, Bt, e);
3216
- if (!nt.eql(nt.sqr(se), r))
3284
+ }, Ut = /* @__PURE__ */ BigInt(2);
3285
+ function qr(r) {
3286
+ const e = ft.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, g = se(d, s, e) * d % e, m = se(g, s, e) * d % e, x = se(m, Ut, e) * l % e, w = se(x, n, e) * x % e, b = se(w, o, e) * w % e, S = se(b, a, e) * b % e, E = se(S, c, e) * S % e, q = se(E, a, e) * b % e, M = se(q, s, e) * d % e, D = se(M, i, e) * w % e, B = se(D, t, e) * l % e, Q = se(B, Ut, e);
3287
+ if (!ot.eql(ot.sqr(Q), r))
3217
3288
  throw new Error("Cannot find square root");
3218
- return se;
3289
+ return Q;
3219
3290
  }
3220
- const nt = je(ht.p, { sqrt: Fr }), Ur = /* @__PURE__ */ Dr(ht, {
3221
- Fp: nt,
3222
- endo: Mr
3223
- }), Hr = /* @__PURE__ */ Br(Ur, ur), Gr = BigInt(0), Re = BigInt(1), qr = BigInt(2), Wr = BigInt(7), jr = BigInt(256), Vr = BigInt(113), _s = [], ms = [], ws = [];
3291
+ const ot = Ve(ft.p, { sqrt: qr }), Wr = /* @__PURE__ */ Ur(ft, {
3292
+ Fp: ot,
3293
+ endo: Gr
3294
+ }), jr = /* @__PURE__ */ Hr(Wr, pr), Vr = BigInt(0), Re = BigInt(1), Kr = BigInt(2), zr = BigInt(7), Yr = BigInt(256), Zr = BigInt(113), ws = [], ys = [], bs = [];
3224
3295
  for (let r = 0, e = Re, s = 1, t = 0; r < 24; r++) {
3225
- [s, t] = [t, (2 * s + 3 * t) % 5], _s.push(2 * (5 * t + s)), ms.push((r + 1) * (r + 2) / 2 % 64);
3226
- let n = Gr;
3296
+ [s, t] = [t, (2 * s + 3 * t) % 5], ws.push(2 * (5 * t + s)), ys.push((r + 1) * (r + 2) / 2 % 64);
3297
+ let n = Vr;
3227
3298
  for (let o = 0; o < 7; o++)
3228
- e = (e << Re ^ (e >> Wr) * Vr) % jr, e & qr && (n ^= Re << (Re << BigInt(o)) - Re);
3229
- ws.push(n);
3299
+ e = (e << Re ^ (e >> zr) * Zr) % Yr, e & Kr && (n ^= Re << (Re << BigInt(o)) - Re);
3300
+ bs.push(n);
3230
3301
  }
3231
- const ys = rr(ws, !0), Kr = ys[0], zr = ys[1], Mt = (r, e, s) => s > 32 ? ir(r, e, s) : nr(r, e, s), Ft = (r, e, s) => s > 32 ? ar(r, e, s) : or(r, e, s);
3232
- function Yr(r, e = 24) {
3302
+ const vs = ar(bs, !0), Xr = vs[0], Jr = vs[1], Ft = (r, e, s) => s > 32 ? dr(r, e, s) : cr(r, e, s), Ht = (r, e, s) => s > 32 ? ur(r, e, s) : lr(r, e, s);
3303
+ function Qr(r, e = 24) {
3233
3304
  const s = new Uint32Array(10);
3234
3305
  for (let t = 24 - e; t < 24; t++) {
3235
3306
  for (let i = 0; i < 10; i++)
3236
3307
  s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
3237
3308
  for (let i = 0; i < 10; i += 2) {
3238
- const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], g = Mt(l, d, 1) ^ s[a], w = Ft(l, d, 1) ^ s[a + 1];
3239
- for (let m = 0; m < 50; m += 10)
3240
- r[i + m] ^= g, r[i + m + 1] ^= w;
3309
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], g = Ft(l, d, 1) ^ s[a], m = Ht(l, d, 1) ^ s[a + 1];
3310
+ for (let x = 0; x < 50; x += 10)
3311
+ r[i + x] ^= g, r[i + x + 1] ^= m;
3241
3312
  }
3242
3313
  let n = r[2], o = r[3];
3243
3314
  for (let i = 0; i < 24; i++) {
3244
- const a = ms[i], c = Mt(n, o, a), l = Ft(n, o, a), d = _s[i];
3315
+ const a = ys[i], c = Ft(n, o, a), l = Ht(n, o, a), d = ws[i];
3245
3316
  n = r[d], o = r[d + 1], r[d] = c, r[d + 1] = l;
3246
3317
  }
3247
3318
  for (let i = 0; i < 50; i += 10) {
@@ -3250,36 +3321,36 @@ function Yr(r, e = 24) {
3250
3321
  for (let a = 0; a < 10; a++)
3251
3322
  r[i + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
3252
3323
  }
3253
- r[0] ^= Kr[t], r[1] ^= zr[t];
3324
+ r[0] ^= Xr[t], r[1] ^= Jr[t];
3254
3325
  }
3255
- Ae(s);
3326
+ Ie(s);
3256
3327
  }
3257
- class ft {
3328
+ class gt {
3258
3329
  // NOTE: we accept arguments in bytes instead of bits here.
3259
3330
  constructor(e, s, t, n = !1, o = 24) {
3260
- b(this, "state");
3261
- b(this, "pos", 0);
3262
- b(this, "posOut", 0);
3263
- b(this, "finished", !1);
3264
- b(this, "state32");
3265
- b(this, "destroyed", !1);
3266
- b(this, "blockLen");
3267
- b(this, "suffix");
3268
- b(this, "outputLen");
3269
- b(this, "enableXOF", !1);
3270
- b(this, "rounds");
3271
- if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, le(t, "outputLen"), !(0 < e && e < 200))
3331
+ v(this, "state");
3332
+ v(this, "pos", 0);
3333
+ v(this, "posOut", 0);
3334
+ v(this, "finished", !1);
3335
+ v(this, "state32");
3336
+ v(this, "destroyed", !1);
3337
+ v(this, "blockLen");
3338
+ v(this, "suffix");
3339
+ v(this, "outputLen");
3340
+ v(this, "enableXOF", !1);
3341
+ v(this, "rounds");
3342
+ if (this.blockLen = e, this.suffix = s, this.outputLen = t, this.enableXOF = n, this.rounds = o, ue(t, "outputLen"), !(0 < e && e < 200))
3272
3343
  throw new Error("only keccak-f1600 function is supported");
3273
- this.state = new Uint8Array(200), this.state32 = Ks(this.state);
3344
+ this.state = new Uint8Array(200), this.state32 = Xs(this.state);
3274
3345
  }
3275
3346
  clone() {
3276
3347
  return this._cloneInto();
3277
3348
  }
3278
3349
  keccak() {
3279
- At(this.state32), Yr(this.state32, this.rounds), At(this.state32), this.posOut = 0, this.pos = 0;
3350
+ Rt(this.state32), Qr(this.state32, this.rounds), Rt(this.state32), this.posOut = 0, this.pos = 0;
3280
3351
  }
3281
3352
  update(e) {
3282
- Te(this), U(e);
3353
+ Te(this), F(e);
3283
3354
  const { blockLen: s, state: t } = this, n = e.length;
3284
3355
  for (let o = 0; o < n; ) {
3285
3356
  const i = Math.min(s - this.pos, n - o);
@@ -3297,7 +3368,7 @@ class ft {
3297
3368
  e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
3298
3369
  }
3299
3370
  writeInto(e) {
3300
- Te(this, !1), U(e), this.finish();
3371
+ Te(this, !1), F(e), this.finish();
3301
3372
  const s = this.state, { blockLen: t } = this;
3302
3373
  for (let n = 0, o = e.length; n < o; ) {
3303
3374
  this.posOut >= t && this.keccak();
@@ -3312,10 +3383,10 @@ class ft {
3312
3383
  return this.writeInto(e);
3313
3384
  }
3314
3385
  xof(e) {
3315
- return le(e), this.xofInto(new Uint8Array(e));
3386
+ return ue(e), this.xofInto(new Uint8Array(e));
3316
3387
  }
3317
3388
  digestInto(e) {
3318
- if (Vt(e, this), this.finished)
3389
+ if (zt(e, this), this.finished)
3319
3390
  throw new Error("digest() was already called");
3320
3391
  return this.writeInto(e), this.destroy(), e;
3321
3392
  }
@@ -3323,15 +3394,15 @@ class ft {
3323
3394
  return this.digestInto(new Uint8Array(this.outputLen));
3324
3395
  }
3325
3396
  destroy() {
3326
- this.destroyed = !0, Ae(this.state);
3397
+ this.destroyed = !0, Ie(this.state);
3327
3398
  }
3328
3399
  _cloneInto(e) {
3329
3400
  const { blockLen: s, suffix: t, outputLen: n, rounds: o, enableXOF: i } = this;
3330
- return e || (e = new ft(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
3401
+ return e || (e = new gt(s, t, n, i, o)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = o, e.suffix = t, e.outputLen = n, e.enableXOF = i, e.destroyed = this.destroyed, e;
3331
3402
  }
3332
3403
  }
3333
- const Zr = (r, e, s, t = {}) => zt(() => new ft(e, r, s), t), Ut = /* @__PURE__ */ Zr(1, 136, 32);
3334
- class Xr {
3404
+ const en = (r, e, s, t = {}) => Zt(() => new gt(e, r, s), t), Gt = /* @__PURE__ */ en(1, 136, 32);
3405
+ class tn {
3335
3406
  async verifyJWT(e, s) {
3336
3407
  try {
3337
3408
  const t = this.decodeJWT(e);
@@ -3352,7 +3423,7 @@ class Xr {
3352
3423
  }
3353
3424
  }
3354
3425
  decodeJWT(e) {
3355
- return Ts(e);
3426
+ return As(e);
3356
3427
  }
3357
3428
  /**
3358
3429
  * EIP-191 personal_sign 서명에서 서명자 Ethereum 주소를 복원합니다.
@@ -3367,33 +3438,33 @@ class Xr {
3367
3438
  ${t.length}`
3368
3439
  ), o = new Uint8Array(n.length + t.length);
3369
3440
  o.set(n, 0), o.set(t, n.length);
3370
- const i = Ut(o), a = s.startsWith("0x") ? s.slice(2) : s;
3441
+ const i = Gt(o), a = s.startsWith("0x") ? s.slice(2) : s;
3371
3442
  if (a.length !== 130)
3372
3443
  throw new Error(`Invalid signature length: expected 130 hex chars, got ${a.length}`);
3373
- const c = Jr(a), l = c.slice(0, 32), d = c.slice(32, 64), g = c[64], w = g >= 27 ? g - 27 : g, A = new Hr.Signature(
3374
- Ht(l),
3375
- Ht(d)
3376
- ).addRecoveryBit(w).recoverPublicKey(i).toBytes(!1).slice(1), E = Ut(A);
3377
- return "0x" + Ce(E.slice(12));
3444
+ const c = sn(a), l = c.slice(0, 32), d = c.slice(32, 64), g = c[64], m = g >= 27 ? g - 27 : g, b = new jr.Signature(
3445
+ qt(l),
3446
+ qt(d)
3447
+ ).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), S = Gt(b);
3448
+ return "0x" + ke(S.slice(12));
3378
3449
  }
3379
3450
  }
3380
- function Jr(r) {
3451
+ function sn(r) {
3381
3452
  const e = new Uint8Array(r.length / 2);
3382
3453
  for (let s = 0; s < e.length; s++)
3383
3454
  e[s] = parseInt(r.substring(s * 2, s * 2 + 2), 16);
3384
3455
  return e;
3385
3456
  }
3386
- function Ht(r) {
3457
+ function qt(r) {
3387
3458
  let e = "0x";
3388
3459
  for (const s of r) e += s.toString(16).padStart(2, "0");
3389
3460
  return BigInt(e);
3390
3461
  }
3391
- const Qr = 3e4;
3392
- class en {
3462
+ const rn = 3e4;
3463
+ class nn {
3393
3464
  async request(e) {
3394
3465
  const s = new AbortController(), t = setTimeout(
3395
3466
  () => s.abort(),
3396
- e.timeoutMs ?? Qr
3467
+ e.timeoutMs ?? rn
3397
3468
  );
3398
3469
  try {
3399
3470
  const n = await fetch(e.url, {
@@ -3420,14 +3491,14 @@ class en {
3420
3491
  }
3421
3492
  }
3422
3493
  }
3423
- class gt {
3494
+ class pt {
3424
3495
  static generateState() {
3425
3496
  const e = new Uint8Array(16);
3426
3497
  return crypto.getRandomValues(e), Array.from(e, (s) => s.toString(16).padStart(2, "0")).join("");
3427
3498
  }
3428
3499
  openAuth(e) {
3429
3500
  return new Promise((s, t) => {
3430
- const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = gt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, g = window.open(
3501
+ const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = pt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, g = window.open(
3431
3502
  d,
3432
3503
  "CROSSx OAuth",
3433
3504
  `width=${n},height=${o},left=${i},top=${a}`
@@ -3436,55 +3507,55 @@ class gt {
3436
3507
  t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
3437
3508
  return;
3438
3509
  }
3439
- const w = setTimeout(() => {
3440
- f.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), $(), t(new Error("Authentication timeout"));
3441
- }, 5 * 60 * 1e3), m = 10, x = 30;
3442
- let A = 0, E = null;
3443
- const C = () => {
3444
- clearInterval(q), f.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + x + "초간 대기합니다"), E = setTimeout(() => {
3445
- $(), t(new Error(
3510
+ const m = setTimeout(() => {
3511
+ f.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), M(), t(new Error("Authentication timeout"));
3512
+ }, 5 * 60 * 1e3), x = 10, w = 30;
3513
+ let b = 0, S = null;
3514
+ const E = () => {
3515
+ clearInterval(q), f.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + w + "초간 대기합니다"), S = setTimeout(() => {
3516
+ M(), t(new Error(
3446
3517
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
3447
3518
  ));
3448
- }, x * 1e3);
3519
+ }, w * 1e3);
3449
3520
  }, q = setInterval(() => {
3450
- A++;
3521
+ b++;
3451
3522
  try {
3452
- g.closed && (A <= m ? C() : ($(), t(new Error("로그인이 취소되었습니다"))));
3523
+ g.closed && (b <= x ? E() : (M(), t(new Error("로그인이 취소되었습니다"))));
3453
3524
  } catch {
3454
- C();
3525
+ E();
3455
3526
  }
3456
- }, 1e3), $ = () => {
3457
- clearTimeout(w), clearInterval(q), E && clearTimeout(E), window.removeEventListener("message", B);
3458
- }, B = (F) => {
3459
- var be, he, Y, _e, ne, L, k;
3460
- if (F.origin !== e.expectedOrigin) return;
3461
- $(), f.log("[CROSSx] OAuth postMessage 수신 — status:", F.data.status);
3462
- const se = F.data.state ?? ((be = F.data.data) == null ? void 0 : be.state);
3463
- if (!se || se !== c) {
3527
+ }, 1e3), M = () => {
3528
+ clearTimeout(m), clearInterval(q), S && clearTimeout(S), window.removeEventListener("message", D);
3529
+ }, D = (B) => {
3530
+ var ve, he, Z, xe, ne, L, P;
3531
+ if (B.origin !== e.expectedOrigin) return;
3532
+ M(), f.log("[CROSSx] OAuth postMessage 수신 — status:", B.data.status);
3533
+ const Q = B.data.state ?? ((ve = B.data.data) == null ? void 0 : ve.state);
3534
+ if (!Q || Q !== c) {
3464
3535
  t(new Error("OAuth state mismatch — possible CSRF attack"));
3465
3536
  return;
3466
3537
  }
3467
- if (F.data.status === "success") {
3468
- const u = ((he = F.data.data) == null ? void 0 : he.accessToken) || ((Y = F.data.data) == null ? void 0 : Y.idToken);
3538
+ if (B.data.status === "success") {
3539
+ const u = ((he = B.data.data) == null ? void 0 : he.accessToken) || ((Z = B.data.data) == null ? void 0 : Z.idToken);
3469
3540
  f.log("[CROSSx] OAuth 토큰 수신:", {
3470
- hasAccessToken: !!((_e = F.data.data) != null && _e.accessToken),
3471
- hasIdToken: !!((ne = F.data.data) != null && ne.idToken)
3472
- }), u ? s(u) : (f.error("[CROSSx] 토큰을 찾을 수 없음:", F.data), t(new Error("Token not found in response")));
3541
+ hasAccessToken: !!((xe = B.data.data) != null && xe.accessToken),
3542
+ hasIdToken: !!((ne = B.data.data) != null && ne.idToken)
3543
+ }), u ? s(u) : (f.error("[CROSSx] 토큰을 찾을 수 없음:", B.data), t(new Error("Token not found in response")));
3473
3544
  } else
3474
- f.error("[CROSSx] OAuth 실패:", (L = F.data.data) == null ? void 0 : L.error), t(new Error(((k = F.data.data) == null ? void 0 : k.error) || "Authentication failed"));
3545
+ f.error("[CROSSx] OAuth 실패:", (L = B.data.data) == null ? void 0 : L.error), t(new Error(((P = B.data.data) == null ? void 0 : P.error) || "Authentication failed"));
3475
3546
  };
3476
- window.addEventListener("message", B);
3547
+ window.addEventListener("message", D);
3477
3548
  });
3478
3549
  }
3479
3550
  }
3480
- const Be = "crossx_wallet_data";
3481
- class tn {
3551
+ const Oe = "crossx_wallet_data";
3552
+ class on {
3482
3553
  constructor(e) {
3483
3554
  this.storage = e;
3484
3555
  }
3485
3556
  async getOrCreateWallet(e) {
3486
3557
  try {
3487
- const s = await this.storage.get(Be);
3558
+ const s = await this.storage.get(Oe);
3488
3559
  if (s) return s;
3489
3560
  const t = {
3490
3561
  id: e,
@@ -3492,11 +3563,15 @@ class tn {
3492
3563
  derivationPath: "m/44'/60'/0'/0/0",
3493
3564
  createdAt: Date.now()
3494
3565
  };
3495
- return await this.storage.set(Be, t), t;
3566
+ return await this.storage.set(Oe, t), t;
3496
3567
  } catch (s) {
3497
3568
  throw new _(p.WALLET_CREATION_FAILED, "Wallet creation failed", s);
3498
3569
  }
3499
3570
  }
3571
+ async getAddresses(e) {
3572
+ const s = await this.storage.get(Oe);
3573
+ return s ? [{ address: s.address, index: 0 }] : [];
3574
+ }
3500
3575
  async getAddress(e, s) {
3501
3576
  return {
3502
3577
  address: this.generateMockEvmAddress(),
@@ -3529,7 +3604,7 @@ class tn {
3529
3604
  derivationPath: "m/44'/60'/0'/0/0",
3530
3605
  createdAt: Date.now()
3531
3606
  };
3532
- return await this.storage.set(Be, t), t;
3607
+ return await this.storage.set(Oe, t), t;
3533
3608
  }
3534
3609
  async migrateWallet(e, s) {
3535
3610
  f.log(`[Mock] migrateWallet pin=${e} sub=${s}`);
@@ -3539,7 +3614,7 @@ class tn {
3539
3614
  derivationPath: "m/44'/60'/0'/0/0",
3540
3615
  createdAt: Date.now()
3541
3616
  };
3542
- return await this.storage.set(Be, t), t;
3617
+ return await this.storage.set(Oe, t), t;
3543
3618
  }
3544
3619
  generateMockEvmAddress() {
3545
3620
  return "0x" + Array(40).fill(0).map(
@@ -3552,9 +3627,12 @@ class tn {
3552
3627
  ).join("");
3553
3628
  }
3554
3629
  }
3555
- class Ge {
3630
+ class qe {
3556
3631
  constructor(e, s, t, n) {
3557
- this.baseUrl = e.gatewayUrl, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n;
3632
+ this.adapterConfig = e, this.projectId = e.projectId, this.storage = s, this.transport = t, this.tokenStore = n;
3633
+ }
3634
+ get baseUrl() {
3635
+ return this.adapterConfig.gatewayUrl;
3558
3636
  }
3559
3637
  getAuthToken() {
3560
3638
  const e = this.tokenStore.get();
@@ -3589,8 +3667,8 @@ class Ge {
3589
3667
  method: e,
3590
3668
  fullResponse: d
3591
3669
  });
3592
- const w = Ge.mapGatewayError(d.code), m = Ge.getGatewayErrorMessage(d.code, g), x = new _(w, m);
3593
- throw x.gatewayCode = d.code, x.gatewayMessage = g, x;
3670
+ const m = qe.mapGatewayError(d.code), x = qe.getGatewayErrorMessage(d.code, g), w = new _(m, x);
3671
+ throw w.gatewayCode = d.code, w.gatewayMessage = g, w;
3594
3672
  }
3595
3673
  return f.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
3596
3674
  }
@@ -3598,16 +3676,16 @@ class Ge {
3598
3676
  } catch (l) {
3599
3677
  if (l instanceof _) throw l;
3600
3678
  if ((a = l.response) != null && a.data) {
3601
- const d = l.response.data, g = d.message || d.data || "API request failed", w = d.code || "UNKNOWN";
3679
+ const d = l.response.data, g = d.message || d.data || "API request failed", m = d.code || "UNKNOWN";
3602
3680
  throw f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
3603
- code: w,
3681
+ code: m,
3604
3682
  message: g,
3605
3683
  url: o,
3606
3684
  method: e,
3607
3685
  status: (c = l.response) == null ? void 0 : c.status
3608
3686
  }), new _(
3609
3687
  p.UNKNOWN_ERROR,
3610
- `Wallet Gateway error (${w}): ${g}`
3688
+ `Wallet Gateway error (${m}): ${g}`
3611
3689
  );
3612
3690
  }
3613
3691
  throw l;
@@ -3654,6 +3732,9 @@ class Ge {
3654
3732
  throw (t == null ? void 0 : t.gatewayCode) === -10012 && f.log("[CROSSx][Migration Phase 2] Gateway -10012 수신 → MIGRATION_BACKUP_EXISTS throw"), t;
3655
3733
  }
3656
3734
  }
3735
+ async getAddresses(e) {
3736
+ return ((await this.request("GET", "/mnemonic/addresses")).addresses ?? []).map((t) => ({ address: t.address, index: t.index }));
3737
+ }
3657
3738
  async getAddress(e, s) {
3658
3739
  try {
3659
3740
  return { address: (await this.request(
@@ -3828,9 +3909,12 @@ class Ge {
3828
3909
  }
3829
3910
  }
3830
3911
  }
3831
- class Oe {
3912
+ class Ce {
3832
3913
  constructor(e, s) {
3833
- this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.baseUrl = e.gatewayUrl, this.projectId = e.projectId, this.transport = s;
3914
+ this.cache = /* @__PURE__ */ new Map(), this.loadedAt = 0, this.usingFallback = !1, this.adapterConfig = e, this.projectId = e.projectId, this.transport = s;
3915
+ }
3916
+ get baseUrl() {
3917
+ return this.adapterConfig.gatewayUrl;
3834
3918
  }
3835
3919
  async getChains() {
3836
3920
  if (this.isCacheValid())
@@ -3843,7 +3927,7 @@ class Oe {
3843
3927
  const s = e.data.chains;
3844
3928
  return this.populateCache(s, !1), s;
3845
3929
  } catch {
3846
- const e = Oe.fallbackChains();
3930
+ const e = Ce.fallbackChains();
3847
3931
  return this.populateCache(e, !0), e;
3848
3932
  }
3849
3933
  }
@@ -3857,7 +3941,7 @@ class Oe {
3857
3941
  }
3858
3942
  isCacheValid() {
3859
3943
  if (this.loadedAt === 0) return !1;
3860
- const e = this.usingFallback ? Gs : Hs;
3944
+ const e = this.usingFallback ? Vs : js;
3861
3945
  return e === 0 ? !0 : Date.now() - this.loadedAt < e;
3862
3946
  }
3863
3947
  populateCache(e, s) {
@@ -3879,13 +3963,13 @@ class Oe {
3879
3963
  if (e.code < 0) {
3880
3964
  const s = typeof e.data == "string" ? e.data : e.message ?? "Chain registry request failed";
3881
3965
  throw new _(
3882
- Oe.mapErrorCode(e.code),
3966
+ Ce.mapErrorCode(e.code),
3883
3967
  s
3884
3968
  );
3885
3969
  }
3886
3970
  }
3887
3971
  fallbackOrThrow(e) {
3888
- const s = Oe.fallbackChains().find(
3972
+ const s = Ce.fallbackChains().find(
3889
3973
  (t) => t.chainId === e
3890
3974
  );
3891
3975
  if (s) return s;
@@ -3895,7 +3979,7 @@ class Oe {
3895
3979
  );
3896
3980
  }
3897
3981
  static fallbackChains() {
3898
- return Object.values(qe).map((e) => ({
3982
+ return Object.values(We).map((e) => ({
3899
3983
  chainId: e.caipId,
3900
3984
  rpcUrl: e.rpcUrl
3901
3985
  }));
@@ -3919,7 +4003,7 @@ class Oe {
3919
4003
  }
3920
4004
  }
3921
4005
  }
3922
- const Gt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", sn = {
4006
+ const Wt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", an = {
3923
4007
  light: {
3924
4008
  bg: "#FFFFFF",
3925
4009
  border: "rgba(18,18,18,0.05)",
@@ -3965,8 +4049,8 @@ const Gt = "__crossx-confirm-style", te = "__crossx-confirm-overlay", sn = {
3965
4049
  onPrimary: "#FFFFFF"
3966
4050
  }
3967
4051
  };
3968
- function qt(r, e) {
3969
- const s = sn[r], t = e == null ? void 0 : e[r];
4052
+ function jt(r, e) {
4053
+ const s = an[r], t = e == null ? void 0 : e[r];
3970
4054
  return t ? {
3971
4055
  ...s,
3972
4056
  // ── Brand
@@ -3995,7 +4079,7 @@ function qt(r, e) {
3995
4079
  ...t.bg !== void 0 && { bg: t.bg, inputBg: t.bg }
3996
4080
  } : s;
3997
4081
  }
3998
- const rn = `
4082
+ const cn = `
3999
4083
  @import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600&display=swap');
4000
4084
 
4001
4085
  #${te} {
@@ -4630,6 +4714,85 @@ const rn = `
4630
4714
  filter: none;
4631
4715
  }
4632
4716
 
4717
+ /* ── Wallet Selector Modal ─────────────────────────────────── */
4718
+ .__crossx-wallet-list {
4719
+ display: flex;
4720
+ flex-direction: column;
4721
+ gap: 8px;
4722
+ max-height: 320px;
4723
+ overflow-y: auto;
4724
+ -webkit-overflow-scrolling: touch;
4725
+ scrollbar-width: thin;
4726
+ }
4727
+ .__crossx-wallet-list::-webkit-scrollbar {
4728
+ width: 4px;
4729
+ }
4730
+ .__crossx-wallet-list::-webkit-scrollbar-thumb {
4731
+ background: var(--cx-divider);
4732
+ border-radius: 2px;
4733
+ }
4734
+ .__crossx-wallet-item {
4735
+ display: flex;
4736
+ align-items: center;
4737
+ gap: 8px;
4738
+ padding: 16px;
4739
+ background: var(--cx-pill-bg);
4740
+ border: 1px solid var(--cx-border);
4741
+ border-radius: 8px;
4742
+ cursor: pointer;
4743
+ appearance: none;
4744
+ -webkit-appearance: none;
4745
+ -webkit-tap-highlight-color: transparent;
4746
+ box-shadow: none;
4747
+ outline: none;
4748
+ width: 100%;
4749
+ transition: opacity 0.12s;
4750
+ font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
4751
+ }
4752
+ .__crossx-wallet-item:hover { opacity: 0.8; }
4753
+ .__crossx-wallet-item:focus { outline: none; box-shadow: none; }
4754
+ .__crossx-wallet-addr {
4755
+ font-size: 16px;
4756
+ font-weight: 600;
4757
+ line-height: 1.3;
4758
+ color: var(--cx-value);
4759
+ white-space: nowrap;
4760
+ }
4761
+ .__crossx-wallet-add {
4762
+ display: flex;
4763
+ align-items: center;
4764
+ justify-content: center;
4765
+ gap: 8px;
4766
+ padding: 16px;
4767
+ border: 1px dashed var(--cx-divider);
4768
+ border-radius: 8px;
4769
+ cursor: pointer;
4770
+ appearance: none;
4771
+ -webkit-appearance: none;
4772
+ -webkit-tap-highlight-color: transparent;
4773
+ box-shadow: none;
4774
+ outline: none;
4775
+ background: none;
4776
+ width: 100%;
4777
+ transition: opacity 0.12s;
4778
+ flex-shrink: 0;
4779
+ font-family: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
4780
+ }
4781
+ .__crossx-wallet-add:hover { opacity: 0.8; }
4782
+ .__crossx-wallet-add:focus { outline: none; box-shadow: none; }
4783
+ .__crossx-wallet-add:disabled { opacity: 0.5; cursor: not-allowed; }
4784
+ .__crossx-wallet-add-icon {
4785
+ width: 24px;
4786
+ height: 24px;
4787
+ color: var(--cx-subtitle);
4788
+ }
4789
+ .__crossx-wallet-add-label {
4790
+ font-size: 16px;
4791
+ font-weight: 600;
4792
+ line-height: 1.3;
4793
+ color: var(--cx-subtitle);
4794
+ }
4795
+
4633
4796
  /* ── Mobile bottom sheet ───────────────────────────────────── */
4634
4797
  @media (max-width: 480px) {
4635
4798
  #${te} { align-items: flex-end; }
@@ -4642,6 +4805,10 @@ const rn = `
4642
4805
  overflow-y: auto;
4643
4806
  animation: __crossx-slide-up-mobile 0.25s ease;
4644
4807
  }
4808
+ .__crossx-card--wallet-selector {
4809
+ overflow: hidden !important;
4810
+ }
4811
+ .__crossx-card--wallet-selector .__crossx-wallet-list { max-height: 203px; }
4645
4812
  .__crossx-login-btn-row {
4646
4813
  flex-direction: column;
4647
4814
  }
@@ -4667,14 +4834,20 @@ const rn = `
4667
4834
  gap: 16px;
4668
4835
  }
4669
4836
  .__crossx-divider--cols { flex-shrink: 0; }
4837
+ .__crossx-col-right-ws {
4838
+ display: flex;
4839
+ flex-direction: column;
4840
+ gap: 8px;
4841
+ }
4670
4842
 
4671
4843
  /* ── Landscape for signing/transaction modals ──────────── */
4672
4844
  @media (orientation: landscape) and (max-height: 500px) {
4673
- #${te} { align-items: center !important; }
4845
+ #${te} { align-items: center !important; overflow: hidden; }
4674
4846
  .__crossx-card--send-tx,
4675
4847
  .__crossx-card--sign-tx,
4676
4848
  .__crossx-card--sign-msg,
4677
- .__crossx-card--sign-typed {
4849
+ .__crossx-card--sign-typed,
4850
+ .__crossx-card--wallet-selector {
4678
4851
  width: 600px;
4679
4852
  max-width: calc(100vw - 32px);
4680
4853
  border-radius: 24px;
@@ -4686,20 +4859,23 @@ const rn = `
4686
4859
  .__crossx-card--send-tx .__crossx-header,
4687
4860
  .__crossx-card--sign-tx .__crossx-header,
4688
4861
  .__crossx-card--sign-msg .__crossx-header,
4689
- .__crossx-card--sign-typed .__crossx-header {
4862
+ .__crossx-card--sign-typed .__crossx-header,
4863
+ .__crossx-card--wallet-selector .__crossx-header {
4690
4864
  padding: 16px 24px 12px;
4691
4865
  }
4692
4866
  .__crossx-card--send-tx .__crossx-body,
4693
4867
  .__crossx-card--sign-tx .__crossx-body,
4694
4868
  .__crossx-card--sign-msg .__crossx-body,
4695
- .__crossx-card--sign-typed .__crossx-body {
4869
+ .__crossx-card--sign-typed .__crossx-body,
4870
+ .__crossx-card--wallet-selector .__crossx-body {
4696
4871
  padding: 16px 24px 20px;
4697
4872
  gap: 12px;
4698
4873
  }
4699
4874
  .__crossx-card--send-tx .__crossx-body-cols,
4700
4875
  .__crossx-card--sign-tx .__crossx-body-cols,
4701
4876
  .__crossx-card--sign-msg .__crossx-body-cols,
4702
- .__crossx-card--sign-typed .__crossx-body-cols {
4877
+ .__crossx-card--sign-typed .__crossx-body-cols,
4878
+ .__crossx-card--wallet-selector .__crossx-body-cols {
4703
4879
  flex-direction: row;
4704
4880
  gap: 24px;
4705
4881
  align-items: flex-start;
@@ -4716,27 +4892,59 @@ const rn = `
4716
4892
  .__crossx-card--sign-msg .__crossx-msg-box { max-height: 130px; }
4717
4893
  .__crossx-card--sign-typed .__crossx-td-rows { max-height: 130px; overflow-y: auto; }
4718
4894
  .__crossx-col-left > .__crossx-divider { display: none; }
4895
+ .__crossx-card--wallet-selector {
4896
+ overflow: hidden !important;
4897
+ display: flex !important;
4898
+ flex-direction: column !important;
4899
+ }
4900
+ .__crossx-card--wallet-selector .__crossx-header { flex-shrink: 0; }
4901
+ .__crossx-card--wallet-selector > .__crossx-divider { flex-shrink: 0; }
4902
+ .__crossx-card--wallet-selector .__crossx-body {
4903
+ flex: 1;
4904
+ min-height: 0;
4905
+ overflow: hidden;
4906
+ display: flex;
4907
+ flex-direction: column;
4908
+ }
4909
+ .__crossx-card--wallet-selector .__crossx-body-cols {
4910
+ flex: 1;
4911
+ min-height: 0;
4912
+ align-items: stretch !important;
4913
+ }
4914
+ .__crossx-card--wallet-selector .__crossx-col-right-ws {
4915
+ display: flex;
4916
+ flex-direction: column;
4917
+ gap: 8px;
4918
+ min-height: 0;
4919
+ overflow: hidden;
4920
+ }
4921
+ .__crossx-card--wallet-selector .__crossx-wallet-list {
4922
+ max-height: none;
4923
+ flex: 1;
4924
+ min-height: 0;
4925
+ }
4926
+ .__crossx-card--wallet-selector .__crossx-wallet-add { flex-shrink: 0; }
4719
4927
  }
4720
4928
  `;
4721
- function Se() {
4722
- let r = document.getElementById(Gt);
4723
- r || (r = document.createElement("style"), r.id = Gt, document.head.appendChild(r)), r.textContent = rn;
4929
+ function me() {
4930
+ let r = document.getElementById(Wt);
4931
+ r || (r = document.createElement("style"), r.id = Wt, document.head.appendChild(r)), r.textContent = cn;
4724
4932
  }
4725
- function Q(r) {
4933
+ function Y(r) {
4726
4934
  return r ? r.length <= 13 ? r : `${r.slice(0, 6)}…${r.slice(-4)}` : "—";
4727
4935
  }
4728
- function nn(r, e = "CROSS", s = 18) {
4936
+ function ln(r, e = "CROSS", s = 18) {
4729
4937
  if (!r || r === "0x" || r === "0x0") return null;
4730
4938
  try {
4731
4939
  const t = BigInt(r);
4732
4940
  if (t === 0n) return null;
4733
- const n = ot(t, s);
4941
+ const n = it(t, s);
4734
4942
  return n === "0" ? null : `${n} ${e}`;
4735
4943
  } catch {
4736
4944
  return null;
4737
4945
  }
4738
4946
  }
4739
- const Wt = {
4947
+ const Vt = {
4740
4948
  1: "Ethereum Mainnet",
4741
4949
  5: "Goerli Testnet",
4742
4950
  11155111: "Ethereum Sepolia",
@@ -4759,16 +4967,16 @@ const Wt = {
4759
4967
  612044: "CROSS Testnet",
4760
4968
  612055: "CROSS Mainnet"
4761
4969
  };
4762
- function bs(r) {
4970
+ function Ss(r) {
4763
4971
  const e = parseInt(r.split(":")[1] ?? "", 10);
4764
- return !isNaN(e) && Wt[e] ? Wt[e] : r;
4972
+ return !isNaN(e) && Vt[e] ? Vt[e] : r;
4765
4973
  }
4766
- function ot(r, e) {
4974
+ function it(r, e) {
4767
4975
  if (r === 0n) return "0";
4768
4976
  const s = 10n ** BigInt(e), t = r / s, i = (r % s).toString().padStart(e, "0").slice(0, 6).replace(/0+$/, "");
4769
4977
  return i ? `${t}.${i}` : `${t}`;
4770
4978
  }
4771
- function et(r) {
4979
+ function tt(r) {
4772
4980
  try {
4773
4981
  const e = BigInt(r), s = e / 1000000000n, n = (e % 1000000000n).toString().padStart(9, "0").slice(0, 2).replace(/0+$/, "");
4774
4982
  return n ? `${s}.${n}` : `${s}`;
@@ -4776,25 +4984,25 @@ function et(r) {
4776
4984
  return r;
4777
4985
  }
4778
4986
  }
4779
- function on(r) {
4987
+ function dn(r) {
4780
4988
  try {
4781
4989
  return BigInt(r).toLocaleString();
4782
4990
  } catch {
4783
4991
  return r;
4784
4992
  }
4785
4993
  }
4786
- function an(r) {
4994
+ function un(r) {
4787
4995
  const { gasLimit: e, gasPrice: s, maxFeePerGas: t, maxPriorityFeePerGas: n, nativeSymbol: o = "ETH", nativeDecimals: i = 18 } = r;
4788
4996
  if (!e) return null;
4789
4997
  try {
4790
- const a = BigInt(e), c = on(e);
4998
+ const a = BigInt(e), c = dn(e);
4791
4999
  if (t) {
4792
5000
  const l = a * BigInt(t);
4793
5001
  return {
4794
5002
  isDynamic: !0,
4795
- estTxFee: `${ot(l, i)} ${o}`,
4796
- maxFeeGwei: et(t),
4797
- maxPriorityFeeGwei: n ? et(n) : void 0,
5003
+ estTxFee: `${it(l, i)} ${o}`,
5004
+ maxFeeGwei: tt(t),
5005
+ maxPriorityFeeGwei: n ? tt(n) : void 0,
4798
5006
  gasLimitFormatted: c
4799
5007
  };
4800
5008
  }
@@ -4802,8 +5010,8 @@ function an(r) {
4802
5010
  const l = a * BigInt(s);
4803
5011
  return {
4804
5012
  isDynamic: !1,
4805
- estTxFee: `${ot(l, i)} ${o}`,
4806
- gasPriceGwei: et(s),
5013
+ estTxFee: `${it(l, i)} ${o}`,
5014
+ gasPriceGwei: tt(s),
4807
5015
  gasLimitFormatted: c
4808
5016
  };
4809
5017
  }
@@ -4812,37 +5020,37 @@ function an(r) {
4812
5020
  return null;
4813
5021
  }
4814
5022
  }
4815
- function vs(r) {
4816
- const e = an(r);
5023
+ function Es(r) {
5024
+ const e = un(r);
4817
5025
  if (!e) return G("Estimated fee", "<span>—</span>");
4818
5026
  let s = G("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
4819
5027
  return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += G("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += G("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += G("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += G("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
4820
5028
  }
4821
- const ce = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5029
+ const de = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
4822
5030
  <rect x="9" y="9" width="13" height="13" rx="2"/>
4823
5031
  <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
4824
- </svg>`, de = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
5032
+ </svg>`, ie = `<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round">
4825
5033
  <line x1="18" y1="6" x2="6" y2="18"/>
4826
5034
  <line x1="6" y1="6" x2="18" y2="18"/>
4827
5035
  </svg>`;
4828
- function cn(r) {
5036
+ function hn(r) {
4829
5037
  return `<svg width="28" height="28" viewBox="0 0 28 28" fill="none">
4830
5038
  <circle cx="14" cy="14" r="14" fill="${r}"/>
4831
5039
  <path d="M14 7.5L19.2 10.5V16.5L14 19.5L8.8 16.5V10.5L14 7.5Z" fill="white" opacity="0.9"/>
4832
5040
  </svg>`;
4833
5041
  }
4834
- const pt = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
5042
+ const _t = `<svg width="20" height="20" viewBox="0 0 20 20" fill="none">
4835
5043
  <rect x="2" y="5" width="16" height="12" rx="2" stroke="currentColor" stroke-width="1.5"/>
4836
5044
  <path d="M2 9h16" stroke="currentColor" stroke-width="1.5"/>
4837
5045
  <rect x="12.5" y="11.5" width="3.5" height="2.5" rx="0.75" fill="currentColor"/>
4838
- </svg>`, ln = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
5046
+ </svg>`, fn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
4839
5047
  <path d="M12 0C18.6274 0 24 5.37258 24 12C23.9999 18.6273 18.6274 24 12 24C5.37264 24 9.89594e-05 18.6273 0 12C0 5.37258 5.37258 0 12 0ZM10.875 15.127V17.377H13.125V15.127H10.875ZM10.875 6.62207V13.627H13.125V6.62207H10.875Z" fill="var(--cx-secondary)"/>
4840
- </svg>`, dn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
5048
+ </svg>`, gn = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
4841
5049
  <circle cx="12" cy="12" r="12" fill="var(--cx-secondary)"/>
4842
5050
  <circle cx="12" cy="12" r="5.5" stroke="white" stroke-width="1.5"/>
4843
5051
  <path d="M12 9.5v3l2 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
4844
5052
  </svg>`;
4845
- function ue(r) {
5053
+ function ae(r) {
4846
5054
  return [
4847
5055
  `--cx-bg:${r.bg}`,
4848
5056
  `--cx-border:${r.border}`,
@@ -4873,35 +5081,35 @@ function G(r, e) {
4873
5081
  <div class="__crossx-row-value">${e}</div>
4874
5082
  </div>`;
4875
5083
  }
4876
- function un(r, e) {
4877
- const s = e, t = Ve(), n = r.to ? `<span class="__crossx-addr-text">${Q(r.to)}</span>
4878
- <button class="__crossx-copy-btn" data-copy="${D(r.to)}" title="Copy address">${ce}</button>` : "<span>—</span>", o = vs(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
5084
+ function pn(r, e) {
5085
+ const s = e, t = Ke(), n = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
5086
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o = Es(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
4879
5087
  return a.id = te, a.innerHTML = `
4880
- <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5088
+ <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
4881
5089
  <div class="__crossx-header">
4882
5090
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
4883
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5091
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
4884
5092
  </div>
4885
5093
  <hr class="__crossx-divider">
4886
5094
  <div class="__crossx-body">
4887
5095
  <div class="__crossx-body-cols">
4888
5096
  <div class="__crossx-col-left">
4889
5097
  <p class="__crossx-sig-subtitle">
4890
- <span class="__crossx-sig-origin">${D(t)} </span>is requesting a Signature
5098
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
4891
5099
  </p>
4892
5100
  <div class="__crossx-addr-pill">
4893
- ${pt}
4894
- <span class="__crossx-addr-pill-text">${Q(r.from)}</span>
5101
+ ${_t}
5102
+ <span class="__crossx-addr-pill-text">${Y(r.from)}</span>
4895
5103
  </div>
4896
5104
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
4897
5105
  <hr class="__crossx-divider">
4898
5106
  <div class="__crossx-rows">
4899
5107
  ${G("To", n)}
4900
- ${G("Network", `<span>${bs(r.chainId)}</span>`)}
5108
+ ${G("Network", `<span>${Ss(r.chainId)}</span>`)}
4901
5109
  ${o}
4902
5110
  </div>
4903
5111
  </div>
4904
- <pre class="__crossx-raw-tx">${D(i)}</pre>
5112
+ <pre class="__crossx-raw-tx">${$(i)}</pre>
4905
5113
  </div>
4906
5114
  <div class="__crossx-btn-row">
4907
5115
  <button class="__crossx-cancel-btn" id="__crossx-cancel-btn">Cancel</button>
@@ -4911,28 +5119,28 @@ function un(r, e) {
4911
5119
  </div>
4912
5120
  `, a;
4913
5121
  }
4914
- function hn(r, e) {
4915
- const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ve(), i = r.to ? `<span class="__crossx-addr-text">${Q(r.to)}</span>
4916
- <button class="__crossx-copy-btn" data-copy="${D(r.to)}" title="Copy address">${ce}</button>` : "<span>—</span>", a = vs(r), l = nn(r.value, t, n) ?? "—", d = document.createElement("div");
5122
+ function _n(r, e) {
5123
+ const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ke(), i = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
5124
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", a = Es(r), l = ln(r.value, t, n) ?? "—", d = document.createElement("div");
4917
5125
  return d.id = te, d.innerHTML = `
4918
- <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5126
+ <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
4919
5127
  <div class="__crossx-header">
4920
5128
  <p class="__crossx-title" id="__crossx-ttl">Approve transaction</p>
4921
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5129
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
4922
5130
  </div>
4923
5131
  <hr class="__crossx-divider">
4924
5132
  <div class="__crossx-body">
4925
5133
  <p class="__crossx-tx-subtitle">
4926
- <span class="__crossx-sig-origin">${D(o)}</span> wants your permission to approve the following transaction.
5134
+ <span class="__crossx-sig-origin">${$(o)}</span> wants your permission to approve the following transaction.
4927
5135
  </p>
4928
5136
  <div class="__crossx-body-cols">
4929
5137
  <div class="__crossx-rows">
4930
5138
  ${G("To", i)}
4931
- ${G("Network", `<span>${bs(r.chainId)}</span>`)}
5139
+ ${G("Network", `<span>${Ss(r.chainId)}</span>`)}
4932
5140
  ${a}
4933
5141
  </div>
4934
5142
  <div class="__crossx-pill">
4935
- <span class="__crossx-pill-from">${Q(r.from)}</span>
5143
+ <span class="__crossx-pill-from">${Y(r.from)}</span>
4936
5144
  <span class="__crossx-pill-amount">${l}</span>
4937
5145
  </div>
4938
5146
  </div>
@@ -4941,7 +5149,7 @@ function hn(r, e) {
4941
5149
  </div>
4942
5150
  `, d;
4943
5151
  }
4944
- function Ve() {
5152
+ function Ke() {
4945
5153
  var r;
4946
5154
  try {
4947
5155
  return ((r = window.location) == null ? void 0 : r.hostname) || "This site";
@@ -4949,37 +5157,37 @@ function Ve() {
4949
5157
  return "This site";
4950
5158
  }
4951
5159
  }
4952
- function D(r) {
5160
+ function $(r) {
4953
5161
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
4954
5162
  }
4955
- function fn(r) {
5163
+ function xn(r) {
4956
5164
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
4957
5165
  }
4958
- function gn(r) {
4959
- if (typeof r == "string") return D(r);
5166
+ function mn(r) {
5167
+ if (typeof r == "string") return $(r);
4960
5168
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
4961
5169
  try {
4962
- return D(JSON.stringify(r));
5170
+ return $(JSON.stringify(r));
4963
5171
  } catch {
4964
5172
  return String(r);
4965
5173
  }
4966
5174
  }
4967
- function pn(r, e) {
5175
+ function wn(r, e) {
4968
5176
  const s = G(
4969
5177
  "From",
4970
- `<span class="__crossx-addr-text">${Q(r.from)}</span>
4971
- <button class="__crossx-copy-btn" data-copy="${D(r.from)}" title="Copy address">${ce}</button>`
4972
- ), t = r.to ? G("To", `<span class="__crossx-addr-text">${Q(r.to)}</span>
4973
- <button class="__crossx-copy-btn" data-copy="${D(r.to)}" title="Copy address">${ce}</button>`) : "", n = r.amount ? G("Transfer", `<span>${D(r.amount)}</span>`) : "", o = r.fees ? G("Tx Fee", `<span>${D(r.fees)}</span>`) : "", i = r.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Q(r.txHash)}</span>
4974
- <button class="__crossx-copy-btn" data-copy="${D(r.txHash)}" title="Copy hash">${ce}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
5178
+ `<span class="__crossx-addr-text">${Y(r.from)}</span>
5179
+ <button class="__crossx-copy-btn" data-copy="${$(r.from)}" title="Copy address">${de}</button>`
5180
+ ), t = r.to ? G("To", `<span class="__crossx-addr-text">${Y(r.to)}</span>
5181
+ <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>`) : "", n = r.amount ? G("Transfer", `<span>${$(r.amount)}</span>`) : "", o = r.fees ? G("Tx Fee", `<span>${$(r.fees)}</span>`) : "", i = r.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(r.txHash)}</span>
5182
+ <button class="__crossx-copy-btn" data-copy="${$(r.txHash)}" title="Copy hash">${de}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
4975
5183
  <span class="__crossx-total-label">Total<br>(including fees)</span>
4976
- <span class="__crossx-total-amount">${D(r.total)}</span>
5184
+ <span class="__crossx-total-amount">${$(r.total)}</span>
4977
5185
  </div>` : "", c = document.createElement("div");
4978
5186
  return c.id = te, c.innerHTML = `
4979
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5187
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
4980
5188
  <div class="__crossx-header">
4981
5189
  <p class="__crossx-title" id="__crossx-ttl">Transaction complete</p>
4982
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5190
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
4983
5191
  </div>
4984
5192
  <hr class="__crossx-divider">
4985
5193
  <div class="__crossx-body">
@@ -4996,10 +5204,10 @@ function pn(r, e) {
4996
5204
  </div>
4997
5205
  `, c;
4998
5206
  }
4999
- function xn(r, e) {
5207
+ function yn(r, e) {
5000
5208
  const s = document.createElement("div");
5001
5209
  return s.id = te, s.innerHTML = `
5002
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5210
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5003
5211
  <div class="__crossx-header">
5004
5212
  <p class="__crossx-title" id="__crossx-ttl">Waiting for confirmation</p>
5005
5213
  </div>
@@ -5013,24 +5221,24 @@ function xn(r, e) {
5013
5221
  </div>
5014
5222
  `, s;
5015
5223
  }
5016
- function _n(r, e, s) {
5224
+ function bn(r, e, s) {
5017
5225
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
5018
5226
  if (o) {
5019
- const x = n ? dn : t ? "" : ln, A = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
5020
- x ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${x}<span>${A}</span>`) : o.textContent = A;
5227
+ const w = n ? gn : t ? "" : fn, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
5228
+ w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
5021
5229
  }
5022
5230
  if (i && !r.querySelector("#__crossx-close-btn")) {
5023
- const x = document.createElement("button");
5024
- x.className = "__crossx-close", x.id = "__crossx-close-btn", x.setAttribute("aria-label", "Close"), x.innerHTML = de, i.appendChild(x);
5231
+ const w = document.createElement("button");
5232
+ w.className = "__crossx-close", w.id = "__crossx-close-btn", w.setAttribute("aria-label", "Close"), w.innerHTML = ie, i.appendChild(w);
5025
5233
  }
5026
5234
  const a = r.querySelector("#__crossx-progress-body");
5027
5235
  if (!a) return;
5028
- const c = e.from ? G("From", `<span class="__crossx-addr-text">${Q(e.from)}</span>
5029
- <button class="__crossx-copy-btn" data-copy="${D(e.from)}" title="Copy address">${ce}</button>`) : "", l = e.to ? G("To", `<span class="__crossx-addr-text">${Q(e.to)}</span>
5030
- <button class="__crossx-copy-btn" data-copy="${D(e.to)}" title="Copy address">${ce}</button>`) : "", d = e.amount ? G("Transfer", `<span>${D(e.amount)}</span>`) : "", g = e.fees ? G("Tx Fee", `<span>${D(e.fees)}</span>`) : "", w = e.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Q(e.txHash)}</span>
5031
- <button class="__crossx-copy-btn" data-copy="${D(e.txHash)}" title="Copy hash">${ce}</button>`) : "", m = e.total ? `<div class="__crossx-total-pill">
5236
+ const c = e.from ? G("From", `<span class="__crossx-addr-text">${Y(e.from)}</span>
5237
+ <button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${de}</button>`) : "", l = e.to ? G("To", `<span class="__crossx-addr-text">${Y(e.to)}</span>
5238
+ <button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? G("Transfer", `<span>${$(e.amount)}</span>`) : "", g = e.fees ? G("Tx Fee", `<span>${$(e.fees)}</span>`) : "", m = e.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(e.txHash)}</span>
5239
+ <button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${de}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
5032
5240
  <span class="__crossx-total-label">Total<br>(including fees)</span>
5033
- <span class="__crossx-total-amount">${D(e.total)}</span>
5241
+ <span class="__crossx-total-amount">${$(e.total)}</span>
5034
5242
  </div>` : "";
5035
5243
  a.innerHTML = `
5036
5244
  <div class="__crossx-rows">
@@ -5038,38 +5246,38 @@ function _n(r, e, s) {
5038
5246
  ${l}
5039
5247
  ${d}
5040
5248
  ${g}
5041
- ${w}
5249
+ ${m}
5042
5250
  </div>
5043
- ${m}
5251
+ ${x}
5044
5252
  <button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
5045
- `, a.querySelectorAll(".__crossx-copy-btn").forEach((x) => {
5046
- x.addEventListener("click", (A) => {
5047
- var C;
5048
- A.stopPropagation();
5049
- const E = x.dataset.copy;
5050
- E && ((C = navigator.clipboard) == null || C.writeText(E).catch(() => {
5253
+ `, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
5254
+ w.addEventListener("click", (b) => {
5255
+ var E;
5256
+ b.stopPropagation();
5257
+ const S = w.dataset.copy;
5258
+ S && ((E = navigator.clipboard) == null || E.writeText(S).catch(() => {
5051
5259
  }));
5052
5260
  });
5053
5261
  });
5054
5262
  }
5055
- function mn(r, e) {
5056
- const s = e, t = Ve(), n = D(r.message), o = document.createElement("div");
5263
+ function vn(r, e) {
5264
+ const s = e, t = Ke(), n = $(r.message), o = document.createElement("div");
5057
5265
  return o.id = te, o.innerHTML = `
5058
- <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5266
+ <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5059
5267
  <div class="__crossx-header">
5060
5268
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
5061
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5269
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5062
5270
  </div>
5063
5271
  <hr class="__crossx-divider">
5064
5272
  <div class="__crossx-body">
5065
5273
  <div class="__crossx-body-cols">
5066
5274
  <div class="__crossx-col-left">
5067
5275
  <p class="__crossx-sig-subtitle">
5068
- <span class="__crossx-sig-origin">${D(t)} </span>is requesting a Signature
5276
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5069
5277
  </p>
5070
5278
  <div class="__crossx-addr-pill">
5071
- ${pt}
5072
- <span class="__crossx-addr-pill-text">${Q(r.from)}</span>
5279
+ ${_t}
5280
+ <span class="__crossx-addr-pill-text">${Y(r.from)}</span>
5073
5281
  </div>
5074
5282
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
5075
5283
  </div>
@@ -5084,8 +5292,8 @@ function mn(r, e) {
5084
5292
  </div>
5085
5293
  `, o;
5086
5294
  }
5087
- function wn(r, e) {
5088
- const s = e, t = Ve();
5295
+ function Sn(r, e) {
5296
+ const s = e, t = Ke();
5089
5297
  let n = {};
5090
5298
  if (typeof r.typedData == "string")
5091
5299
  try {
@@ -5097,34 +5305,34 @@ function wn(r, e) {
5097
5305
  let a = `
5098
5306
  <div class="__crossx-td-row">
5099
5307
  <span class="__crossx-td-label">Primary Type</span>
5100
- <span class="__crossx-td-value">${D(o)}</span>
5308
+ <span class="__crossx-td-value">${$(o)}</span>
5101
5309
  </div>`;
5102
5310
  for (const [l, d] of Object.entries(i)) {
5103
- const g = gn(d), m = fn(d) ? `<span class="__crossx-addr-text">${Q(d)}</span>
5104
- <button class="__crossx-copy-btn" data-copy="${D(String(d))}" title="Copy">${ce}</button>` : `<span>${g}</span>`;
5311
+ const g = mn(d), x = xn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
5312
+ <button class="__crossx-copy-btn" data-copy="${$(String(d))}" title="Copy">${de}</button>` : `<span>${g}</span>`;
5105
5313
  a += `
5106
5314
  <div class="__crossx-td-row">
5107
- <span class="__crossx-td-label">${D(l)}</span>
5108
- <div class="__crossx-td-value">${m}</div>
5315
+ <span class="__crossx-td-label">${$(l)}</span>
5316
+ <div class="__crossx-td-value">${x}</div>
5109
5317
  </div>`;
5110
5318
  }
5111
5319
  const c = document.createElement("div");
5112
5320
  return c.id = te, c.innerHTML = `
5113
- <div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5321
+ <div class="__crossx-card __crossx-card--migration __crossx-card--sign-typed" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5114
5322
  <div class="__crossx-header">
5115
5323
  <p class="__crossx-title" id="__crossx-ttl">Signature Request</p>
5116
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5324
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5117
5325
  </div>
5118
5326
  <hr class="__crossx-divider">
5119
5327
  <div class="__crossx-body">
5120
5328
  <div class="__crossx-body-cols">
5121
5329
  <div class="__crossx-col-left">
5122
5330
  <p class="__crossx-sig-subtitle">
5123
- <span class="__crossx-sig-origin">${D(t)} </span>is requesting a Signature
5331
+ <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5124
5332
  </p>
5125
5333
  <div class="__crossx-addr-pill">
5126
- ${pt}
5127
- <span class="__crossx-addr-pill-text">${Q(r.from)}</span>
5334
+ ${_t}
5335
+ <span class="__crossx-addr-pill-text">${Y(r.from)}</span>
5128
5336
  </div>
5129
5337
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
5130
5338
  </div>
@@ -5139,35 +5347,78 @@ function wn(r, e) {
5139
5347
  </div>
5140
5348
  `, c;
5141
5349
  }
5142
- const yn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5350
+ const En = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
5351
+ <line x1="12" y1="5" x2="12" y2="19"/>
5352
+ <line x1="5" y1="12" x2="19" y2="12"/>
5353
+ </svg>`;
5354
+ function Tn(r, e) {
5355
+ const s = r.map(
5356
+ (n) => `<button class="__crossx-wallet-item" data-wallet-index="${n.index}" data-wallet-address="${$(n.address)}">
5357
+ <span class="__crossx-wallet-addr">${Y(n.address)}</span>
5358
+ </button>`
5359
+ ).join(""), t = document.createElement("div");
5360
+ return t.id = te, t.innerHTML = `
5361
+ <div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5362
+ <div class="__crossx-header">
5363
+ <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
5364
+ <p class="__crossx-title" id="__crossx-ttl" style="padding-right:0;">Select Connected Wallet</p>
5365
+ <p class="__crossx-subtitle--body">Please select the wallet you previously used for this game to continue.</p>
5366
+ </div>
5367
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5368
+ </div>
5369
+ <hr class="__crossx-divider">
5370
+ <div class="__crossx-body">
5371
+ <div class="__crossx-body-cols">
5372
+ <div class="__crossx-col-left">
5373
+ <div class="__crossx-mig-info">
5374
+ <p class="__crossx-mig-info-title">Why do I need to select a wallet?</p>
5375
+ <p class="__crossx-mig-info-desc">Identifying your previously linked wallet ensures your game progress and assets are synced correctly.</p>
5376
+ </div>
5377
+ </div>
5378
+ <hr class="__crossx-divider __crossx-divider--cols">
5379
+ <div class="__crossx-col-right-ws">
5380
+ <div class="__crossx-wallet-list" id="__crossx-wallet-list">
5381
+ ${s}
5382
+ </div>
5383
+ <button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
5384
+ <span class="__crossx-wallet-add-icon">${En}</span>
5385
+ <span class="__crossx-wallet-add-label">add a wallet</span>
5386
+ </button>
5387
+ </div>
5388
+ </div>
5389
+ </div>
5390
+ </div>
5391
+ `, t;
5392
+ }
5393
+ const In = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5143
5394
  <path d="M26.693 21.193c-.028-3.168 2.587-4.712 2.706-4.786-1.477-2.16-3.77-2.454-4.58-2.484-1.944-.197-3.804 1.148-4.793 1.148-.992 0-2.52-1.12-4.147-1.09-2.13.032-4.1 1.239-5.198 3.133-2.222 3.855-.569 9.562 1.593 12.69 1.061 1.535 2.318 3.258 3.975 3.196 1.6-.064 2.2-1.03 4.133-1.03 1.928 0 2.48 1.03 4.172.997 1.72-.03 2.806-1.56 3.862-3.1 1.211-1.779 1.713-3.495 1.74-3.583-.037-.017-3.427-1.316-3.463-5.09z" fill="currentColor"/>
5144
5395
  <path d="M23.527 11.876c.877-1.065 1.471-2.545 1.31-4.024-1.266.053-2.807.845-3.718 1.907-.813.946-1.53 2.468-1.34 3.915 1.41.107 2.852-.716 3.748-1.798z" fill="currentColor"/>
5145
- </svg>`, bn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5396
+ </svg>`, An = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5146
5397
  <path d="M38.06 20.44c0-1.34-.12-2.63-.34-3.87H20.5v7.32h9.84c-.42 2.28-1.71 4.21-3.65 5.51v4.57h5.91c3.46-3.19 5.46-7.88 5.46-13.53z" fill="#4285F4"/>
5147
5398
  <path d="M20.5 38.5c4.94 0 9.09-1.64 12.12-4.44l-5.91-4.57c-1.64 1.1-3.73 1.75-6.21 1.75-4.77 0-8.82-3.22-10.26-7.55H4.16v4.72A18.49 18.49 0 0 0 20.5 38.5z" fill="#34A853"/>
5148
5399
  <path d="M10.24 23.69A11.16 11.16 0 0 1 9.66 20c0-1.28.22-2.52.58-3.69v-4.72H4.16A18.49 18.49 0 0 0 2 20c0 2.97.71 5.78 1.97 8.28l6.27-4.59z" fill="#FBBC05"/>
5149
5400
  <path d="M20.5 8.76c2.69 0 5.1.92 7 2.73l5.24-5.24C29.58 3.36 25.43 1.5 20.5 1.5A18.49 18.49 0 0 0 4.16 11.59l6.08 4.72C11.68 11.98 15.73 8.76 20.5 8.76z" fill="#EA4335"/>
5150
5401
  </svg>`;
5151
- function vn(r) {
5402
+ function Rn(r) {
5152
5403
  const e = r, s = document.createElement("div");
5153
5404
  return s.id = te, s.innerHTML = `
5154
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5405
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5155
5406
  <div class="__crossx-header">
5156
5407
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
5157
5408
  <p class="__crossx-title" id="__crossx-ttl" style="padding-right:0;">Welcome onboard</p>
5158
5409
  <p class="__crossx-subtitle">Creating CROSSx Embedded Wallet</p>
5159
5410
  </div>
5160
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5411
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5161
5412
  </div>
5162
5413
  <hr class="__crossx-divider">
5163
5414
  <div class="__crossx-body">
5164
5415
  <div class="__crossx-login-btn-row">
5165
5416
  <button class="__crossx-login-btn" id="__crossx-apple-btn" type="button">
5166
- <span class="__crossx-login-icon" style="color:var(--cx-value);">${yn}</span>
5417
+ <span class="__crossx-login-icon" style="color:var(--cx-value);">${In}</span>
5167
5418
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Apple</span>
5168
5419
  </button>
5169
5420
  <button class="__crossx-login-btn" id="__crossx-google-btn" type="button">
5170
- <span class="__crossx-login-icon">${bn}</span>
5421
+ <span class="__crossx-login-icon">${An}</span>
5171
5422
  <span class="__crossx-login-btn-label">Sign in with&nbsp;&nbsp;Google</span>
5172
5423
  </button>
5173
5424
  </div>
@@ -5179,14 +5430,14 @@ function vn(r) {
5179
5430
  </div>
5180
5431
  `, s;
5181
5432
  }
5182
- function Sn(r) {
5433
+ function On(r) {
5183
5434
  const e = r, s = document.createElement("div");
5184
5435
  return s.id = te, s.innerHTML = `
5185
- <div class="__crossx-card __crossx-card--migration" style="${ue(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5436
+ <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5186
5437
  <div class="__crossx-header">
5187
5438
  <p class="__crossx-title" id="__crossx-ttl">Wallet Found on Social Account 🎉</p>
5188
5439
  <p class="__crossx-subtitle--body">We found a wallet linked to your social account. Enter your 4-digit PIN to restore your assets.</p>
5189
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5440
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5190
5441
  </div>
5191
5442
  <hr class="__crossx-divider">
5192
5443
  <div class="__crossx-body">
@@ -5195,7 +5446,7 @@ function Sn(r) {
5195
5446
  <p class="__crossx-mig-info-desc">It safely restores and integrates all your previous assets. Simply verify your PIN to get started.</p>
5196
5447
  </div>
5197
5448
  <button class="__crossx-recover-btn" id="__crossx-recover-btn">
5198
- <span>${cn(e.primary)}</span>
5449
+ <span>${hn(e.primary)}</span>
5199
5450
  <span class="__crossx-recover-label">Recover My Wallet</span>
5200
5451
  </button>
5201
5452
  <button class="__crossx-skip-btn" id="__crossx-skip-btn">Skip for Now</button>
@@ -5203,13 +5454,13 @@ function Sn(r) {
5203
5454
  </div>
5204
5455
  `, s;
5205
5456
  }
5206
- function En(r, e) {
5457
+ function Cn(r, e) {
5207
5458
  const s = r, t = e ? `<p class="__crossx-pin-error-text">${e}</p>` : "", n = document.createElement("div");
5208
5459
  return n.id = te, n.innerHTML = `
5209
- <div class="__crossx-card __crossx-card--migration" style="${ue(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5460
+ <div class="__crossx-card __crossx-card--migration" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5210
5461
  <div class="__crossx-header">
5211
5462
  <p class="__crossx-title" id="__crossx-ttl">Recover My Wallet</p>
5212
- <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${de}</button>
5463
+ <button class="__crossx-close" id="__crossx-close-btn" aria-label="Close">${ie}</button>
5213
5464
  </div>
5214
5465
  <hr class="__crossx-divider">
5215
5466
  <div class="__crossx-pin-center">
@@ -5225,7 +5476,7 @@ function En(r, e) {
5225
5476
  </div>
5226
5477
  `, n;
5227
5478
  }
5228
- function Tn(r, e, s) {
5479
+ function kn(r, e, s) {
5229
5480
  var n;
5230
5481
  const t = r.querySelectorAll(".__crossx-pin-input");
5231
5482
  t.forEach((o, i) => {
@@ -5243,24 +5494,75 @@ function Tn(r, e, s) {
5243
5494
  a.preventDefault();
5244
5495
  const c = (((d = a.clipboardData) == null ? void 0 : d.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
5245
5496
  if (!c) return;
5246
- c.split("").forEach((g, w) => {
5247
- t[w] && (t[w].value = g);
5497
+ c.split("").forEach((g, m) => {
5498
+ t[m] && (t[m].value = g);
5248
5499
  });
5249
5500
  const l = Math.min(c.length, 3);
5250
5501
  t[l].focus(), c.length === 4 && setTimeout(() => e(c), 200);
5251
5502
  });
5252
5503
  }), (n = t[0]) == null || n.focus();
5253
5504
  }
5254
- class An {
5505
+ class Nn {
5255
5506
  constructor(e = "light", s) {
5256
- this.theme = e, this.overrides = s, this.tokens = qt(e, s);
5507
+ this.theme = e, this.overrides = s, this.tokens = jt(e, s);
5257
5508
  }
5258
5509
  setTheme(e, s) {
5259
- this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = qt(e, this.overrides);
5510
+ this.theme = e, s !== void 0 && (this.overrides = s), this.tokens = jt(e, this.overrides);
5260
5511
  }
5261
5512
  getTheme() {
5262
5513
  return this.theme;
5263
5514
  }
5515
+ /**
5516
+ * 지갑 선택 팝업: "Select Connected Wallet"
5517
+ * 지갑 목록을 표시하고, 사용자가 선택하거나 새 지갑을 추가할 수 있습니다.
5518
+ * 모달은 지갑을 선택하거나 X를 누를 때까지 유지됩니다.
5519
+ */
5520
+ showWalletSelector(e, s) {
5521
+ return new Promise((t) => {
5522
+ var w;
5523
+ me();
5524
+ const n = [...e], o = Tn(n, this.tokens), i = document.body.style.overflow;
5525
+ document.body.style.overflow = "hidden", document.body.appendChild(o);
5526
+ let a = !1;
5527
+ const c = () => {
5528
+ a || (a = !0, o.remove(), document.body.style.overflow = i);
5529
+ }, l = (b) => {
5530
+ c(), t(b);
5531
+ }, d = () => {
5532
+ c(), t(null);
5533
+ };
5534
+ (() => {
5535
+ o.querySelectorAll(".__crossx-wallet-item").forEach((b) => {
5536
+ b.addEventListener("click", () => {
5537
+ const S = b.dataset.walletAddress ?? "", E = parseInt(b.dataset.walletIndex ?? "0", 10);
5538
+ l({ address: S, index: E });
5539
+ });
5540
+ });
5541
+ })();
5542
+ const m = o.querySelector("#__crossx-add-wallet-btn");
5543
+ m && m.addEventListener("click", async () => {
5544
+ m.disabled = !0;
5545
+ try {
5546
+ const b = await s();
5547
+ n.push(b);
5548
+ const S = o.querySelector("#__crossx-wallet-list");
5549
+ if (S) {
5550
+ const E = document.createElement("button");
5551
+ E.className = "__crossx-wallet-item", E.dataset.walletIndex = String(b.index), E.dataset.walletAddress = b.address, E.innerHTML = `<span class="__crossx-wallet-addr">${Y(b.address)}</span>`, E.addEventListener("click", () => l(b)), S.appendChild(E), E.scrollIntoView({ behavior: "smooth", block: "nearest" });
5552
+ }
5553
+ } catch {
5554
+ } finally {
5555
+ m.disabled = !1;
5556
+ }
5557
+ }), (w = o.querySelector("#__crossx-close-btn")) == null || w.addEventListener("click", d), o.addEventListener("click", (b) => {
5558
+ b.target === o && d();
5559
+ });
5560
+ const x = (b) => {
5561
+ b.key === "Escape" && (document.removeEventListener("keydown", x), d());
5562
+ };
5563
+ document.addEventListener("keydown", x);
5564
+ });
5565
+ }
5264
5566
  /**
5265
5567
  * 로그인 프로바이더 선택 팝업: "Welcome onboard"
5266
5568
  * Apple / Google 버튼을 표시하고 선택된 프로바이더를 반환합니다.
@@ -5269,8 +5571,8 @@ class An {
5269
5571
  showLoginSelector() {
5270
5572
  return new Promise((e) => {
5271
5573
  var a, c, l;
5272
- Se();
5273
- const s = vn(this.tokens);
5574
+ me();
5575
+ const s = Rn(this.tokens);
5274
5576
  document.body.appendChild(s);
5275
5577
  const t = () => s.remove(), n = (d) => {
5276
5578
  t(), e(d);
@@ -5295,8 +5597,8 @@ class An {
5295
5597
  showMigrationFoundPrompt() {
5296
5598
  return new Promise((e) => {
5297
5599
  var a, c, l;
5298
- Se();
5299
- const s = Sn(this.tokens);
5600
+ me();
5601
+ const s = On(this.tokens);
5300
5602
  document.body.appendChild(s);
5301
5603
  const t = () => s.remove(), n = () => {
5302
5604
  t(), e("recover");
@@ -5320,15 +5622,15 @@ class An {
5320
5622
  showPinInputPrompt(e) {
5321
5623
  return new Promise((s) => {
5322
5624
  var a;
5323
- Se();
5324
- const t = En(this.tokens, e);
5625
+ me();
5626
+ const t = Cn(this.tokens, e);
5325
5627
  document.body.appendChild(t);
5326
5628
  const n = () => t.remove(), o = (c) => {
5327
5629
  n(), s(c);
5328
5630
  }, i = () => {
5329
5631
  n(), s(null);
5330
5632
  };
5331
- Tn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
5633
+ kn(t, o, i), (a = t.querySelector("#__crossx-close-btn")) == null || a.addEventListener("click", i), t.addEventListener("click", (c) => {
5332
5634
  c.target === t && i();
5333
5635
  });
5334
5636
  });
@@ -5340,18 +5642,18 @@ class An {
5340
5642
  showTransactionComplete(e) {
5341
5643
  return new Promise((s) => {
5342
5644
  var a, c;
5343
- Se();
5344
- const t = pn(e, this.tokens);
5645
+ me();
5646
+ const t = wn(e, this.tokens);
5345
5647
  document.body.appendChild(t);
5346
5648
  const n = () => t.remove(), o = () => {
5347
5649
  n(), s();
5348
5650
  };
5349
5651
  (a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
5350
5652
  l.addEventListener("click", (d) => {
5351
- var w;
5653
+ var m;
5352
5654
  d.stopPropagation();
5353
5655
  const g = l.dataset.copy;
5354
- g && ((w = navigator.clipboard) == null || w.writeText(g).catch(() => {
5656
+ g && ((m = navigator.clipboard) == null || m.writeText(g).catch(() => {
5355
5657
  }));
5356
5658
  });
5357
5659
  }), t.addEventListener("click", (l) => {
@@ -5369,8 +5671,8 @@ class An {
5369
5671
  */
5370
5672
  showTransactionProgress(e, s) {
5371
5673
  return new Promise((t) => {
5372
- Se();
5373
- const n = xn(e, this.tokens);
5674
+ me();
5675
+ const n = yn(e, this.tokens);
5374
5676
  document.body.appendChild(n);
5375
5677
  const o = () => n.remove();
5376
5678
  let i = !1;
@@ -5378,36 +5680,36 @@ class An {
5378
5680
  i || (i = !0, o(), t());
5379
5681
  }, c = () => {
5380
5682
  var d, g;
5381
- (d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (g = n.querySelector("#__crossx-close-btn")) == null || g.addEventListener("click", a), n.addEventListener("click", (w) => {
5382
- w.target === n && a();
5683
+ (d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (g = n.querySelector("#__crossx-close-btn")) == null || g.addEventListener("click", a), n.addEventListener("click", (m) => {
5684
+ m.target === n && a();
5383
5685
  });
5384
- const l = (w) => {
5385
- w.key === "Escape" && (document.removeEventListener("keydown", l), a());
5686
+ const l = (m) => {
5687
+ m.key === "Escape" && (document.removeEventListener("keydown", l), a());
5386
5688
  };
5387
5689
  document.addEventListener("keydown", l);
5388
5690
  };
5389
5691
  s.then((l) => {
5390
- i || (_n(n, l, this.tokens), c());
5692
+ i || (bn(n, l, this.tokens), c());
5391
5693
  });
5392
5694
  });
5393
5695
  }
5394
5696
  requestConfirmation(e) {
5395
5697
  return new Promise((s) => {
5396
5698
  var c, l, d;
5397
- Se();
5699
+ me();
5398
5700
  let t;
5399
- e.type === "sign-message" ? t = mn(e, this.tokens) : e.type === "sign-typed-data" ? t = wn(e, this.tokens) : e.type === "sign" ? t = un(e, this.tokens) : t = hn(e, this.tokens), document.body.appendChild(t);
5701
+ e.type === "sign-message" ? t = vn(e, this.tokens) : e.type === "sign-typed-data" ? t = Sn(e, this.tokens) : e.type === "sign" ? t = pn(e, this.tokens) : t = _n(e, this.tokens), document.body.appendChild(t);
5400
5702
  const n = () => t.remove(), o = () => {
5401
5703
  n(), s(!0);
5402
5704
  }, i = () => {
5403
5705
  n(), s(!1);
5404
5706
  };
5405
5707
  (c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((g) => {
5406
- g.addEventListener("click", (w) => {
5407
- var x;
5408
- w.stopPropagation();
5409
- const m = g.dataset.copy;
5410
- m && ((x = navigator.clipboard) == null || x.writeText(m).catch(() => {
5708
+ g.addEventListener("click", (m) => {
5709
+ var w;
5710
+ m.stopPropagation();
5711
+ const x = g.dataset.copy;
5712
+ x && ((w = navigator.clipboard) == null || w.writeText(x).catch(() => {
5411
5713
  }));
5412
5714
  });
5413
5715
  }), t.addEventListener("click", (g) => {
@@ -5420,7 +5722,7 @@ class An {
5420
5722
  });
5421
5723
  }
5422
5724
  }
5423
- class In {
5725
+ class Pn {
5424
5726
  constructor() {
5425
5727
  this._accessToken = null;
5426
5728
  }
@@ -5437,54 +5739,42 @@ class In {
5437
5739
  return this._accessToken !== null;
5438
5740
  }
5439
5741
  }
5440
- const Rn = "https://cross-wallet-oauth.crosstoken.io", On = "https://cross-auth.crosstoken.io", Cn = "https://embedded-wallet-gateway.crosstoken.io/api/v1";
5441
- function Nn() {
5442
- return Rn;
5443
- }
5444
- function Pn() {
5445
- return On;
5446
- }
5447
- function kn() {
5448
- return Cn;
5449
- }
5450
5742
  function Bn(r) {
5451
5743
  r.debug;
5452
- const e = Nn(), s = Pn(), t = kn(), n = {
5744
+ const e = Ue.production, s = {
5453
5745
  ...r,
5454
- oauthServiceUrl: e,
5455
- authApiUrl: s,
5456
- walletGatewayUrl: t
5457
- }, i = r.authMode === "token" && Tt.isAvailable() ? new Tt() : new qs(), a = new Xr(), c = new en(), l = new gt(), d = new In();
5458
- let g;
5459
- r.useMockWallet ? (f.log("[CROSSx] Mock Wallet Provider 사용"), g = new tn(i)) : (f.log("[CROSSx] Remote Wallet Provider 사용"), g = new Ge(
5460
- {
5461
- gatewayUrl: t,
5462
- projectId: r.projectId
5463
- },
5464
- i,
5465
- c,
5466
- d
5746
+ oauthServiceUrl: e.oauthServiceUrl,
5747
+ authApiUrl: e.authApiUrl,
5748
+ walletGatewayUrl: e.walletGatewayUrl
5749
+ }, t = {
5750
+ gatewayUrl: e.walletGatewayUrl,
5751
+ projectId: r.projectId
5752
+ }, o = s.authMode !== "cookie" && At.isAvailable() ? new At() : new Ks(), i = new tn(), a = new nn(), c = new pt(), l = new Pn();
5753
+ let d;
5754
+ r.useMockWallet ? (f.log("[CROSSx] Mock Wallet Provider 사용"), d = new on(o)) : (f.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
5755
+ t,
5756
+ o,
5757
+ a,
5758
+ l
5467
5759
  ));
5468
- const w = new Oe(
5469
- { gatewayUrl: t, projectId: r.projectId },
5470
- c
5471
- ), m = new An(r.theme ?? "light", r.themeTokens);
5472
- return new tt(
5473
- n,
5760
+ const g = new Ce(t, a), m = new Nn(r.theme ?? "light", r.themeTokens);
5761
+ return new st(
5762
+ s,
5763
+ t,
5764
+ o,
5474
5765
  i,
5475
5766
  a,
5476
5767
  c,
5477
- l,
5478
- g,
5479
5768
  d,
5769
+ l,
5480
5770
  m,
5481
- w
5771
+ g
5482
5772
  );
5483
5773
  }
5484
5774
  export {
5485
5775
  _ as CROSSxError,
5486
- Rs as CROSSxEthereumProvider,
5487
- tt as CROSSxSDK,
5776
+ Cs as CROSSxEthereumProvider,
5777
+ st as CROSSxSDK,
5488
5778
  $n as ChainId,
5489
5779
  p as ErrorCode,
5490
5780
  Bn as createCROSSxSDK