@chainrails/react 0.3.1 → 0.3.2

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.
@@ -1,6 +1,6 @@
1
- import { useState as I, useRef as ie, useEffect as x, useMemo as be, useSyncExternalStore as mt, useCallback as pt, useLayoutEffect as yt, useDebugValue as Tt } from "react";
2
- import { jsxs as Ee, jsx as L } from "react/jsx-runtime";
3
- import './index.css';class ee extends Error {
1
+ import { useState as k, useRef as le, useEffect as x, useMemo as Ce, useSyncExternalStore as bt, useCallback as Et, useLayoutEffect as St, useDebugValue as wt } from "react";
2
+ import { jsxs as Ae, jsx as _ } from "react/jsx-runtime";
3
+ import './index.css';class oe extends Error {
4
4
  response;
5
5
  request;
6
6
  options;
@@ -9,7 +9,7 @@ import './index.css';class ee extends Error {
9
9
  super(`Request failed with ${a}: ${s.method} ${s.url}`), this.name = "HTTPError", this.response = e, this.request = s, this.options = n;
10
10
  }
11
11
  }
12
- class Le extends Error {
12
+ class je extends Error {
13
13
  name = "NonError";
14
14
  value;
15
15
  constructor(e) {
@@ -21,17 +21,17 @@ class Le extends Error {
21
21
  super(s), this.value = e;
22
22
  }
23
23
  }
24
- class V extends Error {
24
+ class J extends Error {
25
25
  name = "ForceRetryError";
26
26
  customDelay;
27
27
  code;
28
28
  customRequest;
29
29
  constructor(e) {
30
- const s = e?.cause ? e.cause instanceof Error ? e.cause : new Le(e.cause) : void 0;
30
+ const s = e?.cause ? e.cause instanceof Error ? e.cause : new je(e.cause) : void 0;
31
31
  super(e?.code ? `Forced retry: ${e.code}` : "Forced retry", s ? { cause: s } : void 0), this.customDelay = e?.delay, this.code = e?.code, this.customRequest = e?.request;
32
32
  }
33
33
  }
34
- const Se = (() => {
34
+ const De = (() => {
35
35
  let t = !1, e = !1;
36
36
  const s = typeof globalThis.ReadableStream == "function", n = typeof globalThis.Request == "function";
37
37
  if (s && n)
@@ -50,7 +50,7 @@ const Se = (() => {
50
50
  throw o;
51
51
  }
52
52
  return t && !e;
53
- })(), bt = typeof globalThis.AbortController == "function", Fe = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", Et = typeof globalThis.ReadableStream == "function", St = typeof globalThis.FormData == "function", _e = ["get", "post", "put", "patch", "head", "delete"], wt = {
53
+ })(), Rt = typeof globalThis.AbortController == "function", ze = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", Ct = typeof globalThis.ReadableStream == "function", At = typeof globalThis.FormData == "function", qe = ["get", "post", "put", "patch", "head", "delete"], Dt = {
54
54
  json: "application/json",
55
55
  text: "text/*",
56
56
  formData: "multipart/form-data",
@@ -59,14 +59,14 @@ const Se = (() => {
59
59
  // Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
60
60
  // We still feature-check at runtime before exposing the shortcut.
61
61
  bytes: "*/*"
62
- }, Y = 2147483647, Rt = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, He = Symbol("stop");
63
- class $e {
62
+ }, Z = 2147483647, Ut = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, Ke = Symbol("stop");
63
+ class We {
64
64
  options;
65
65
  constructor(e) {
66
66
  this.options = e;
67
67
  }
68
68
  }
69
- const Ct = (t) => new $e(t), At = {
69
+ const vt = (t) => new We(t), kt = {
70
70
  json: !0,
71
71
  parseJson: !0,
72
72
  stringifyJson: !0,
@@ -80,10 +80,10 @@ const Ct = (t) => new $e(t), At = {
80
80
  onUploadProgress: !0,
81
81
  fetch: !0,
82
82
  context: !0
83
- }, Dt = {
83
+ }, It = {
84
84
  next: !0
85
85
  // Next.js cache revalidation (revalidate, tags)
86
- }, Ut = {
86
+ }, Pt = {
87
87
  method: !0,
88
88
  headers: !0,
89
89
  body: !0,
@@ -98,13 +98,13 @@ const Ct = (t) => new $e(t), At = {
98
98
  signal: !0,
99
99
  window: !0,
100
100
  duplex: !0
101
- }, vt = (t) => {
101
+ }, xt = (t) => {
102
102
  if (!t)
103
103
  return 0;
104
104
  if (t instanceof FormData) {
105
105
  let e = 0;
106
106
  for (const [s, n] of t)
107
- e += Rt, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof n == "string" ? new TextEncoder().encode(n).length : n.size;
107
+ e += Ut, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof n == "string" ? new TextEncoder().encode(n).length : n.size;
108
108
  return e;
109
109
  }
110
110
  if (t instanceof Blob)
@@ -125,7 +125,7 @@ const Ct = (t) => new $e(t), At = {
125
125
  return 0;
126
126
  }
127
127
  return 0;
128
- }, ze = (t, e, s) => {
128
+ }, Ve = (t, e, s) => {
129
129
  let n, o = 0;
130
130
  return t.pipeThrough(new TransformStream({
131
131
  transform(i, r) {
@@ -140,7 +140,7 @@ const Ct = (t) => new $e(t), At = {
140
140
  n && (o += n.byteLength, s?.({ percent: 1, totalBytes: Math.max(e, o), transferredBytes: o }, n));
141
141
  }
142
142
  }));
143
- }, kt = (t, e) => {
143
+ }, Nt = (t, e) => {
144
144
  if (!t.body)
145
145
  return t;
146
146
  if (t.status === 204)
@@ -150,40 +150,40 @@ const Ct = (t) => new $e(t), At = {
150
150
  headers: t.headers
151
151
  });
152
152
  const s = Math.max(0, Number(t.headers.get("content-length")) || 0);
153
- return new Response(ze(t.body, s, e), {
153
+ return new Response(Ve(t.body, s, e), {
154
154
  status: t.status,
155
155
  statusText: t.statusText,
156
156
  headers: t.headers
157
157
  });
158
- }, It = (t, e, s) => {
158
+ }, Ot = (t, e, s) => {
159
159
  if (!t.body)
160
160
  return t;
161
- const n = vt(s ?? t.body);
161
+ const n = xt(s ?? t.body);
162
162
  return new Request(t, {
163
163
  // @ts-expect-error - Types are outdated.
164
164
  duplex: "half",
165
- body: ze(t.body, n, e)
165
+ body: Ve(t.body, n, e)
166
166
  });
167
- }, k = (t) => t !== null && typeof t == "object", F = (...t) => {
167
+ }, P = (t) => t !== null && typeof t == "object", F = (...t) => {
168
168
  for (const e of t)
169
- if ((!k(e) || Array.isArray(e)) && e !== void 0)
169
+ if ((!P(e) || Array.isArray(e)) && e !== void 0)
170
170
  throw new TypeError("The `options` argument must be an object");
171
- return ae({}, ...t);
172
- }, je = (t = {}, e = {}) => {
171
+ return de({}, ...t);
172
+ }, Ye = (t = {}, e = {}) => {
173
173
  const s = new globalThis.Headers(t), n = e instanceof globalThis.Headers, o = new globalThis.Headers(e);
174
174
  for (const [i, r] of o.entries())
175
175
  n && r === "undefined" || r === void 0 ? s.delete(i) : s.set(i, r);
176
176
  return s;
177
177
  };
178
- function _(t, e, s) {
179
- return Object.hasOwn(e, s) && e[s] === void 0 ? [] : ae(t[s] ?? [], e[s] ?? []);
180
- }
181
- const qe = (t = {}, e = {}) => ({
182
- beforeRequest: _(t, e, "beforeRequest"),
183
- beforeRetry: _(t, e, "beforeRetry"),
184
- afterResponse: _(t, e, "afterResponse"),
185
- beforeError: _(t, e, "beforeError")
186
- }), Pt = (t, e) => {
178
+ function H(t, e, s) {
179
+ return Object.hasOwn(e, s) && e[s] === void 0 ? [] : de(t[s] ?? [], e[s] ?? []);
180
+ }
181
+ const Ge = (t = {}, e = {}) => ({
182
+ beforeRequest: H(t, e, "beforeRequest"),
183
+ beforeRetry: H(t, e, "beforeRetry"),
184
+ afterResponse: H(t, e, "afterResponse"),
185
+ beforeError: H(t, e, "beforeError")
186
+ }), Bt = (t, e) => {
187
187
  const s = new URLSearchParams();
188
188
  for (const n of [t, e])
189
189
  if (n !== void 0)
@@ -196,7 +196,7 @@ const qe = (t = {}, e = {}) => ({
196
196
  throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
197
197
  s.append(String(o[0]), String(o[1]));
198
198
  }
199
- else if (k(n))
199
+ else if (P(n))
200
200
  for (const [o, i] of Object.entries(n))
201
201
  i !== void 0 && s.append(o, String(i));
202
202
  else {
@@ -205,20 +205,20 @@ const qe = (t = {}, e = {}) => ({
205
205
  s.append(i, r);
206
206
  }
207
207
  return s;
208
- }, ae = (...t) => {
208
+ }, de = (...t) => {
209
209
  let e = {}, s = {}, n = {}, o;
210
210
  const i = [];
211
211
  for (const r of t)
212
212
  if (Array.isArray(r))
213
213
  Array.isArray(e) || (e = []), e = [...e, ...r];
214
- else if (k(r)) {
214
+ else if (P(r)) {
215
215
  for (let [a, u] of Object.entries(r)) {
216
216
  if (a === "signal" && u instanceof globalThis.AbortSignal) {
217
217
  i.push(u);
218
218
  continue;
219
219
  }
220
220
  if (a === "context") {
221
- if (u != null && (!k(u) || Array.isArray(u)))
221
+ if (u != null && (!P(u) || Array.isArray(u)))
222
222
  throw new TypeError("The `context` option must be an object");
223
223
  e = {
224
224
  ...e,
@@ -227,28 +227,28 @@ const qe = (t = {}, e = {}) => ({
227
227
  continue;
228
228
  }
229
229
  if (a === "searchParams") {
230
- u == null ? o = void 0 : o = o === void 0 ? u : Pt(o, u);
230
+ u == null ? o = void 0 : o = o === void 0 ? u : Bt(o, u);
231
231
  continue;
232
232
  }
233
- k(u) && a in e && (u = ae(e[a], u)), e = { ...e, [a]: u };
233
+ P(u) && a in e && (u = de(e[a], u)), e = { ...e, [a]: u };
234
234
  }
235
- k(r.hooks) && (n = qe(n, r.hooks), e.hooks = n), k(r.headers) && (s = je(s, r.headers), e.headers = s);
235
+ P(r.hooks) && (n = Ge(n, r.hooks), e.hooks = n), P(r.headers) && (s = Ye(s, r.headers), e.headers = s);
236
236
  }
237
- return o !== void 0 && (e.searchParams = o), i.length > 0 && (i.length === 1 ? e.signal = i[0] : Fe ? e.signal = AbortSignal.any(i) : e.signal = i.at(-1)), e.context === void 0 && (e.context = {}), e;
238
- }, xt = (t) => _e.includes(t) ? t.toUpperCase() : t, Nt = ["get", "put", "head", "delete", "options", "trace"], Ot = [408, 413, 429, 500, 502, 503, 504], Bt = [413, 429, 503], we = {
237
+ return o !== void 0 && (e.searchParams = o), i.length > 0 && (i.length === 1 ? e.signal = i[0] : ze ? e.signal = AbortSignal.any(i) : e.signal = i.at(-1)), e.context === void 0 && (e.context = {}), e;
238
+ }, Mt = (t) => qe.includes(t) ? t.toUpperCase() : t, Lt = ["get", "put", "head", "delete", "options", "trace"], _t = [408, 413, 429, 500, 502, 503, 504], Ft = [413, 429, 503], Ue = {
239
239
  limit: 2,
240
- methods: Nt,
241
- statusCodes: Ot,
242
- afterStatusCodes: Bt,
240
+ methods: Lt,
241
+ statusCodes: _t,
242
+ afterStatusCodes: Ft,
243
243
  maxRetryAfter: Number.POSITIVE_INFINITY,
244
244
  backoffLimit: Number.POSITIVE_INFINITY,
245
245
  delay: (t) => 0.3 * 2 ** (t - 1) * 1e3,
246
246
  jitter: void 0,
247
247
  retryOnTimeout: !1
248
- }, Mt = (t = {}) => {
248
+ }, Ht = (t = {}) => {
249
249
  if (typeof t == "number")
250
250
  return {
251
- ...we,
251
+ ...Ue,
252
252
  limit: t
253
253
  };
254
254
  if (t.methods && !Array.isArray(t.methods))
@@ -256,27 +256,27 @@ const qe = (t = {}, e = {}) => ({
256
256
  if (t.statusCodes && !Array.isArray(t.statusCodes))
257
257
  throw new Error("retry.statusCodes must be an array");
258
258
  return {
259
- ...we,
259
+ ...Ue,
260
260
  ...t
261
261
  };
262
262
  };
263
- class te extends Error {
263
+ class re extends Error {
264
264
  request;
265
265
  constructor(e) {
266
266
  super(`Request timed out: ${e.method} ${e.url}`), this.name = "TimeoutError", this.request = e;
267
267
  }
268
268
  }
269
- async function Lt(t, e, s, n) {
269
+ async function $t(t, e, s, n) {
270
270
  return new Promise((o, i) => {
271
271
  const r = setTimeout(() => {
272
- s && s.abort(), i(new te(t));
272
+ s && s.abort(), i(new re(t));
273
273
  }, n.timeout);
274
274
  n.fetch(t, e).then(o).catch(i).then(() => {
275
275
  clearTimeout(r);
276
276
  });
277
277
  });
278
278
  }
279
- async function Ft(t, { signal: e }) {
279
+ async function jt(t, { signal: e }) {
280
280
  return new Promise((s, n) => {
281
281
  e && (e.throwIfAborted(), e.addEventListener("abort", o, { once: !0 }));
282
282
  function o() {
@@ -287,35 +287,35 @@ async function Ft(t, { signal: e }) {
287
287
  }, t);
288
288
  });
289
289
  }
290
- const _t = (t, e) => {
290
+ const zt = (t, e) => {
291
291
  const s = {};
292
292
  for (const n in e)
293
- Object.hasOwn(e, n) && !(n in Ut) && !(n in At) && (!(n in t) || n in Dt) && (s[n] = e[n]);
293
+ Object.hasOwn(e, n) && !(n in Pt) && !(n in kt) && (!(n in t) || n in It) && (s[n] = e[n]);
294
294
  return s;
295
- }, Ht = (t) => t === void 0 ? !1 : Array.isArray(t) ? t.length > 0 : t instanceof URLSearchParams ? t.size > 0 : typeof t == "object" ? Object.keys(t).length > 0 : typeof t == "string" ? t.trim().length > 0 : !!t;
296
- function $t(t) {
297
- return t instanceof ee || t?.name === ee.name;
295
+ }, qt = (t) => t === void 0 ? !1 : Array.isArray(t) ? t.length > 0 : t instanceof URLSearchParams ? t.size > 0 : typeof t == "object" ? Object.keys(t).length > 0 : typeof t == "string" ? t.trim().length > 0 : !!t;
296
+ function Kt(t) {
297
+ return t instanceof oe || t?.name === oe.name;
298
298
  }
299
- function zt(t) {
300
- return t instanceof te || t?.name === te.name;
299
+ function Wt(t) {
300
+ return t instanceof re || t?.name === re.name;
301
301
  }
302
- class M {
302
+ class L {
303
303
  static create(e, s) {
304
- const n = new M(e, s), o = async () => {
305
- if (typeof n.#e.timeout == "number" && n.#e.timeout > Y)
306
- throw new RangeError(`The \`timeout\` option cannot be greater than ${Y}`);
304
+ const n = new L(e, s), o = async () => {
305
+ if (typeof n.#e.timeout == "number" && n.#e.timeout > Z)
306
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${Z}`);
307
307
  await Promise.resolve();
308
- let r = await n.#m();
308
+ let r = await n.#g();
309
309
  for (const a of n.#e.hooks.afterResponse) {
310
310
  const u = n.#l(r.clone()), l = await a(n.request, n.#a(), u, { retryCount: n.#s });
311
- if (l instanceof globalThis.Response && (r = l), l instanceof $e)
311
+ if (l instanceof globalThis.Response && (r = l), l instanceof We)
312
312
  throw await Promise.all([
313
313
  u.body?.cancel(),
314
314
  r.body?.cancel()
315
- ]), new V(l.options);
315
+ ]), new J(l.options);
316
316
  }
317
317
  if (n.#l(r), !r.ok && (typeof n.#e.throwHttpErrors == "function" ? n.#e.throwHttpErrors(r.status) : n.#e.throwHttpErrors)) {
318
- let a = new ee(r, n.request, n.#a());
318
+ let a = new oe(r, n.request, n.#a());
319
319
  for (const u of n.#e.hooks.beforeError)
320
320
  a = await u(a, { retryCount: n.#s });
321
321
  throw a;
@@ -323,16 +323,16 @@ class M {
323
323
  if (n.#e.onDownloadProgress) {
324
324
  if (typeof n.#e.onDownloadProgress != "function")
325
325
  throw new TypeError("The `onDownloadProgress` option must be a function");
326
- if (!Et)
326
+ if (!Ct)
327
327
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
328
- return kt(r.clone(), n.#e.onDownloadProgress);
328
+ return Nt(r.clone(), n.#e.onDownloadProgress);
329
329
  }
330
330
  return r;
331
331
  }, i = n.#d(o).finally(async () => {
332
332
  const r = n.#r, a = [];
333
333
  r && !r.bodyUsed && a.push(r.body?.cancel()), n.request.bodyUsed || a.push(n.request.body?.cancel()), await Promise.all(a);
334
334
  });
335
- for (const [r, a] of Object.entries(wt))
335
+ for (const [r, a] of Object.entries(Dt))
336
336
  r === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (i[r] = async () => {
337
337
  n.request.headers.set("accept", n.request.headers.get("accept") || a);
338
338
  const u = await i;
@@ -363,17 +363,17 @@ class M {
363
363
  constructor(e, s = {}) {
364
364
  if (this.#t = e, this.#e = {
365
365
  ...s,
366
- headers: je(this.#t.headers, s.headers),
367
- hooks: qe({
366
+ headers: Ye(this.#t.headers, s.headers),
367
+ hooks: Ge({
368
368
  beforeRequest: [],
369
369
  beforeRetry: [],
370
370
  beforeError: [],
371
371
  afterResponse: []
372
372
  }, s.hooks),
373
- method: xt(s.method ?? this.#t.method ?? "GET"),
373
+ method: Mt(s.method ?? this.#t.method ?? "GET"),
374
374
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
375
375
  prefixUrl: String(s.prefixUrl || ""),
376
- retry: Mt(s.retry),
376
+ retry: Ht(s.retry),
377
377
  throwHttpErrors: s.throwHttpErrors ?? !0,
378
378
  timeout: s.timeout ?? 1e4,
379
379
  fetch: s.fetch ?? globalThis.fetch.bind(globalThis),
@@ -385,16 +385,16 @@ class M {
385
385
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
386
386
  this.#e.prefixUrl.endsWith("/") || (this.#e.prefixUrl += "/"), this.#t = this.#e.prefixUrl + this.#t;
387
387
  }
388
- bt && Fe && (this.#o = this.#e.signal ?? this.#t.signal, this.#n = new globalThis.AbortController(), this.#e.signal = this.#o ? AbortSignal.any([this.#o, this.#n.signal]) : this.#n.signal), Se && (this.#e.duplex = "half"), this.#e.json !== void 0 && (this.#e.body = this.#e.stringifyJson?.(this.#e.json) ?? JSON.stringify(this.#e.json), this.#e.headers.set("content-type", this.#e.headers.get("content-type") ?? "application/json"));
388
+ Rt && ze && (this.#o = this.#e.signal ?? this.#t.signal, this.#n = new globalThis.AbortController(), this.#e.signal = this.#o ? AbortSignal.any([this.#o, this.#n.signal]) : this.#n.signal), De && (this.#e.duplex = "half"), this.#e.json !== void 0 && (this.#e.body = this.#e.stringifyJson?.(this.#e.json) ?? JSON.stringify(this.#e.json), this.#e.headers.set("content-type", this.#e.headers.get("content-type") ?? "application/json"));
389
389
  const n = s.headers && new globalThis.Headers(s.headers).has("content-type");
390
- if (this.#t instanceof globalThis.Request && (St && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !n && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), Ht(this.#e.searchParams)) {
391
- const i = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(M.#h(this.#e.searchParams)).toString()), r = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
390
+ if (this.#t instanceof globalThis.Request && (At && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !n && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), qt(this.#e.searchParams)) {
391
+ const i = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(L.#h(this.#e.searchParams)).toString()), r = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
392
392
  this.request = new globalThis.Request(r, this.#e);
393
393
  }
394
394
  if (this.#e.onUploadProgress) {
395
395
  if (typeof this.#e.onUploadProgress != "function")
396
396
  throw new TypeError("The `onUploadProgress` option must be a function");
397
- if (!Se)
397
+ if (!De)
398
398
  throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
399
399
  this.request = this.#f(this.request, this.#e.body ?? void 0);
400
400
  }
@@ -404,11 +404,11 @@ class M {
404
404
  let s = e;
405
405
  return this.#e.retry.jitter === !0 ? s = Math.random() * e : typeof this.#e.retry.jitter == "function" && (s = this.#e.retry.jitter(e), (!Number.isFinite(s) || s < 0) && (s = e)), Math.min(this.#e.retry.backoffLimit, s);
406
406
  }
407
- async #g(e) {
407
+ async #m(e) {
408
408
  if (this.#s++, this.#s > this.#e.retry.limit)
409
409
  throw e;
410
- const s = e instanceof Error ? e : new Le(e);
411
- if (s instanceof V)
410
+ const s = e instanceof Error ? e : new je(e);
411
+ if (s instanceof J)
412
412
  return s.customDelay ?? this.#c();
413
413
  if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
414
414
  throw e;
@@ -419,9 +419,9 @@ class M {
419
419
  if (n === !0)
420
420
  return this.#c();
421
421
  }
422
- if (zt(e) && !this.#e.retry.retryOnTimeout)
422
+ if (Wt(e) && !this.#e.retry.retryOnTimeout)
423
423
  throw e;
424
- if ($t(e)) {
424
+ if (Kt(e)) {
425
425
  if (!this.#e.retry.statusCodes.includes(e.response.status))
426
426
  throw e;
427
427
  const n = e.response.headers.get("Retry-After") ?? e.response.headers.get("RateLimit-Reset") ?? e.response.headers.get("X-RateLimit-Retry-After") ?? e.response.headers.get("X-RateLimit-Reset") ?? e.response.headers.get("X-Rate-Limit-Reset");
@@ -443,10 +443,10 @@ class M {
443
443
  try {
444
444
  return await e();
445
445
  } catch (s) {
446
- const n = Math.min(await this.#g(s), Y);
446
+ const n = Math.min(await this.#m(s), Z);
447
447
  if (this.#s < 1)
448
448
  throw s;
449
- if (await Ft(n, this.#o ? { signal: this.#o } : {}), s instanceof V && s.customRequest) {
449
+ if (await jt(n, this.#o ? { signal: this.#o } : {}), s instanceof J && s.customRequest) {
450
450
  const o = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
451
451
  this.#u(o);
452
452
  }
@@ -463,13 +463,13 @@ class M {
463
463
  }
464
464
  if (i instanceof globalThis.Response)
465
465
  return i;
466
- if (i === He)
466
+ if (i === Ke)
467
467
  return;
468
468
  }
469
469
  return this.#d(e);
470
470
  }
471
471
  }
472
- async #m() {
472
+ async #g() {
473
473
  this.#n?.signal.aborted && (this.#n = new globalThis.AbortController(), this.#e.signal = this.#o ? AbortSignal.any([this.#o, this.#n.signal]) : this.#n.signal, this.request = new globalThis.Request(this.request, { signal: this.#e.signal }));
474
474
  for (const s of this.#e.hooks.beforeRequest) {
475
475
  const n = await s(this.request, this.#a(), { retryCount: this.#s });
@@ -480,8 +480,8 @@ class M {
480
480
  break;
481
481
  }
482
482
  }
483
- const e = _t(this.request, this.#e);
484
- return this.#r = this.request, this.request = this.#r.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#r, e) : Lt(this.#r, e, this.#n, this.#e);
483
+ const e = zt(this.request, this.#e);
484
+ return this.#r = this.request, this.request = this.#r.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#r, e) : $t(this.#r, e, this.#n, this.#e);
485
485
  }
486
486
  #a() {
487
487
  if (!this.#i) {
@@ -494,16 +494,16 @@ class M {
494
494
  this.#i = void 0, this.request = this.#f(e);
495
495
  }
496
496
  #f(e, s) {
497
- return !this.#e.onUploadProgress || !e.body ? e : It(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
497
+ return !this.#e.onUploadProgress || !e.body ? e : Ot(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
498
498
  }
499
499
  }
500
500
  /*! MIT License © Sindre Sorhus */
501
- const se = (t) => {
502
- const e = (s, n) => M.create(s, F(t, n));
503
- for (const s of _e)
504
- e[s] = (n, o) => M.create(n, F(t, o, { method: s }));
505
- return e.create = (s) => se(F(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), se(F(t, s))), e.stop = He, e.retry = Ct, e;
506
- }, jt = se(), T = {
501
+ const ie = (t) => {
502
+ const e = (s, n) => L.create(s, F(t, n));
503
+ for (const s of qe)
504
+ e[s] = (n, o) => L.create(n, F(t, o, { method: s }));
505
+ return e.create = (s) => ie(F(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), ie(F(t, s))), e.stop = Ke, e.retry = vt, e;
506
+ }, Vt = ie(), b = {
507
507
  ARBITRUM: "ARBITRUM_MAINNET",
508
508
  ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
509
509
  AVALANCHE: "AVALANCHE_MAINNET",
@@ -522,7 +522,7 @@ const se = (t) => {
522
522
  POLYGON: "POLYGON_MAINNET",
523
523
  STARKNET: "STARKNET_MAINNET",
524
524
  STARKNET_TESTNET: "STARKNET_TESTNET"
525
- }, un = {
525
+ }, mn = {
526
526
  ARBITRUM: "ARBITRUM",
527
527
  ARBITRUM_TESTNET: "ARBITRUM_TESTNET",
528
528
  AVALANCHE: "AVALANCHE",
@@ -542,26 +542,26 @@ const se = (t) => {
542
542
  STARKNET: "STARKNET",
543
543
  STARKNET_TESTNET: "STARKNET_TESTNET"
544
544
  };
545
- function ce(t, { strict: e = !0 } = {}) {
545
+ function fe(t, { strict: e = !0 } = {}) {
546
546
  return !t || typeof t != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
547
547
  }
548
- function Re(t) {
549
- return ce(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
548
+ function ve(t) {
549
+ return fe(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length;
550
550
  }
551
- const Ke = "2.43.4";
552
- let G = {
551
+ const Xe = "2.43.4";
552
+ let Q = {
553
553
  getDocsUrl: ({ docsBaseUrl: t, docsPath: e = "", docsSlug: s }) => e ? `${t ?? "https://viem.sh"}${e}${s ? `#${s}` : ""}` : void 0,
554
- version: `viem@${Ke}`
554
+ version: `viem@${Xe}`
555
555
  };
556
- class U extends Error {
556
+ class I extends Error {
557
557
  constructor(e, s = {}) {
558
- const n = s.cause instanceof U ? s.cause.details : s.cause?.message ? s.cause.message : s.details, o = s.cause instanceof U && s.cause.docsPath || s.docsPath, i = G.getDocsUrl?.({ ...s, docsPath: o }), r = [
558
+ const n = s.cause instanceof I ? s.cause.details : s.cause?.message ? s.cause.message : s.details, o = s.cause instanceof I && s.cause.docsPath || s.docsPath, i = Q.getDocsUrl?.({ ...s, docsPath: o }), r = [
559
559
  e || "An error occurred.",
560
560
  "",
561
561
  ...s.metaMessages ? [...s.metaMessages, ""] : [],
562
562
  ...i ? [`Docs: ${i}`] : [],
563
563
  ...n ? [`Details: ${n}`] : [],
564
- ...G.version ? [`Version: ${G.version}`] : []
564
+ ...Q.version ? [`Version: ${Q.version}`] : []
565
565
  ].join(`
566
566
  `);
567
567
  super(r, s.cause ? { cause: s.cause } : void 0), Object.defineProperty(this, "details", {
@@ -594,40 +594,40 @@ class U extends Error {
594
594
  configurable: !0,
595
595
  writable: !0,
596
596
  value: "BaseError"
597
- }), this.details = n, this.docsPath = o, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage = e, this.version = Ke;
597
+ }), this.details = n, this.docsPath = o, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage = e, this.version = Xe;
598
598
  }
599
599
  walk(e) {
600
- return We(this, e);
600
+ return Je(this, e);
601
601
  }
602
602
  }
603
- function We(t, e) {
604
- return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause !== void 0 ? We(t.cause, e) : e ? null : t;
603
+ function Je(t, e) {
604
+ return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause !== void 0 ? Je(t.cause, e) : e ? null : t;
605
605
  }
606
- class Ve extends U {
606
+ class Ze extends I {
607
607
  constructor({ size: e, targetSize: s, type: n }) {
608
608
  super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
609
609
  }
610
610
  }
611
- function K(t, { dir: e, size: s = 32 } = {}) {
612
- return typeof t == "string" ? qt(t, { dir: e, size: s }) : Kt(t, { dir: e, size: s });
611
+ function W(t, { dir: e, size: s = 32 } = {}) {
612
+ return typeof t == "string" ? Yt(t, { dir: e, size: s }) : Gt(t, { dir: e, size: s });
613
613
  }
614
- function qt(t, { dir: e, size: s = 32 } = {}) {
614
+ function Yt(t, { dir: e, size: s = 32 } = {}) {
615
615
  if (s === null)
616
616
  return t;
617
617
  const n = t.replace("0x", "");
618
618
  if (n.length > s * 2)
619
- throw new Ve({
619
+ throw new Ze({
620
620
  size: Math.ceil(n.length / 2),
621
621
  targetSize: s,
622
622
  type: "hex"
623
623
  });
624
624
  return `0x${n[e === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
625
625
  }
626
- function Kt(t, { dir: e, size: s = 32 } = {}) {
626
+ function Gt(t, { dir: e, size: s = 32 } = {}) {
627
627
  if (s === null)
628
628
  return t;
629
629
  if (t.length > s)
630
- throw new Ve({
630
+ throw new Ze({
631
631
  size: t.length,
632
632
  targetSize: s,
633
633
  type: "bytes"
@@ -639,31 +639,31 @@ function Kt(t, { dir: e, size: s = 32 } = {}) {
639
639
  }
640
640
  return n;
641
641
  }
642
- class Wt extends U {
642
+ class Xt extends I {
643
643
  constructor({ max: e, min: s, signed: n, size: o, value: i }) {
644
644
  super(`Number "${i}" is not in safe ${o ? `${o * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${s} to ${e})` : `(above ${s})`}`, { name: "IntegerOutOfRangeError" });
645
645
  }
646
646
  }
647
- class Vt extends U {
647
+ class Jt extends I {
648
648
  constructor({ givenSize: e, maxSize: s }) {
649
649
  super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" });
650
650
  }
651
651
  }
652
- function ue(t, { size: e }) {
653
- if (Re(t) > e)
654
- throw new Vt({
655
- givenSize: Re(t),
652
+ function he(t, { size: e }) {
653
+ if (ve(t) > e)
654
+ throw new Jt({
655
+ givenSize: ve(t),
656
656
  maxSize: e
657
657
  });
658
658
  }
659
- function Yt(t, e = {}) {
659
+ function Zt(t, e = {}) {
660
660
  const { signed: s, size: n } = e, o = BigInt(t);
661
661
  let i;
662
662
  n ? s ? i = (1n << BigInt(n) * 8n - 1n) - 1n : i = 2n ** (BigInt(n) * 8n) - 1n : typeof t == "number" && (i = BigInt(Number.MAX_SAFE_INTEGER));
663
663
  const r = typeof i == "bigint" && s ? -i - 1n : 0;
664
664
  if (i && o > i || o < r) {
665
665
  const u = typeof t == "bigint" ? "n" : "";
666
- throw new Wt({
666
+ throw new Xt({
667
667
  max: i ? `${i}${u}` : void 0,
668
668
  min: `${r}${u}`,
669
669
  signed: s,
@@ -672,17 +672,17 @@ function Yt(t, e = {}) {
672
672
  });
673
673
  }
674
674
  const a = `0x${(s && o < 0 ? (1n << BigInt(n * 8)) + BigInt(o) : o).toString(16)}`;
675
- return n ? K(a, { size: n }) : a;
675
+ return n ? W(a, { size: n }) : a;
676
676
  }
677
- const Gt = /* @__PURE__ */ new TextEncoder();
678
- function Xt(t, e = {}) {
679
- return typeof t == "number" || typeof t == "bigint" ? Zt(t, e) : typeof t == "boolean" ? Jt(t, e) : ce(t) ? Ye(t, e) : Ge(t, e);
677
+ const Qt = /* @__PURE__ */ new TextEncoder();
678
+ function es(t, e = {}) {
679
+ return typeof t == "number" || typeof t == "bigint" ? ss(t, e) : typeof t == "boolean" ? ts(t, e) : fe(t) ? Qe(t, e) : et(t, e);
680
680
  }
681
- function Jt(t, e = {}) {
681
+ function ts(t, e = {}) {
682
682
  const s = new Uint8Array(1);
683
- return s[0] = Number(t), typeof e.size == "number" ? (ue(s, { size: e.size }), K(s, { size: e.size })) : s;
683
+ return s[0] = Number(t), typeof e.size == "number" ? (he(s, { size: e.size }), W(s, { size: e.size })) : s;
684
684
  }
685
- const A = {
685
+ const U = {
686
686
  zero: 48,
687
687
  nine: 57,
688
688
  A: 65,
@@ -690,130 +690,130 @@ const A = {
690
690
  a: 97,
691
691
  f: 102
692
692
  };
693
- function Ce(t) {
694
- if (t >= A.zero && t <= A.nine)
695
- return t - A.zero;
696
- if (t >= A.A && t <= A.F)
697
- return t - (A.A - 10);
698
- if (t >= A.a && t <= A.f)
699
- return t - (A.a - 10);
700
- }
701
- function Ye(t, e = {}) {
693
+ function ke(t) {
694
+ if (t >= U.zero && t <= U.nine)
695
+ return t - U.zero;
696
+ if (t >= U.A && t <= U.F)
697
+ return t - (U.A - 10);
698
+ if (t >= U.a && t <= U.f)
699
+ return t - (U.a - 10);
700
+ }
701
+ function Qe(t, e = {}) {
702
702
  let s = t;
703
- e.size && (ue(s, { size: e.size }), s = K(s, { dir: "right", size: e.size }));
703
+ e.size && (he(s, { size: e.size }), s = W(s, { dir: "right", size: e.size }));
704
704
  let n = s.slice(2);
705
705
  n.length % 2 && (n = `0${n}`);
706
706
  const o = n.length / 2, i = new Uint8Array(o);
707
707
  for (let r = 0, a = 0; r < o; r++) {
708
- const u = Ce(n.charCodeAt(a++)), l = Ce(n.charCodeAt(a++));
708
+ const u = ke(n.charCodeAt(a++)), l = ke(n.charCodeAt(a++));
709
709
  if (u === void 0 || l === void 0)
710
- throw new U(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`);
710
+ throw new I(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`);
711
711
  i[r] = u * 16 + l;
712
712
  }
713
713
  return i;
714
714
  }
715
- function Zt(t, e) {
716
- const s = Yt(t, e);
717
- return Ye(s);
715
+ function ss(t, e) {
716
+ const s = Zt(t, e);
717
+ return Qe(s);
718
718
  }
719
- function Ge(t, e = {}) {
720
- const s = Gt.encode(t);
721
- return typeof e.size == "number" ? (ue(s, { size: e.size }), K(s, { dir: "right", size: e.size })) : s;
719
+ function et(t, e = {}) {
720
+ const s = Qt.encode(t);
721
+ return typeof e.size == "number" ? (he(s, { size: e.size }), W(s, { dir: "right", size: e.size })) : s;
722
722
  }
723
- const H = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ae = /* @__PURE__ */ BigInt(32);
724
- function Qt(t, e = !1) {
725
- return e ? { h: Number(t & H), l: Number(t >> Ae & H) } : { h: Number(t >> Ae & H) | 0, l: Number(t & H) | 0 };
723
+ const $ = /* @__PURE__ */ BigInt(2 ** 32 - 1), Ie = /* @__PURE__ */ BigInt(32);
724
+ function ns(t, e = !1) {
725
+ return e ? { h: Number(t & $), l: Number(t >> Ie & $) } : { h: Number(t >> Ie & $) | 0, l: Number(t & $) | 0 };
726
726
  }
727
- function es(t, e = !1) {
727
+ function os(t, e = !1) {
728
728
  const s = t.length;
729
729
  let n = new Uint32Array(s), o = new Uint32Array(s);
730
730
  for (let i = 0; i < s; i++) {
731
- const { h: r, l: a } = Qt(t[i], e);
731
+ const { h: r, l: a } = ns(t[i], e);
732
732
  [n[i], o[i]] = [r, a];
733
733
  }
734
734
  return [n, o];
735
735
  }
736
- const ts = (t, e, s) => t << s | e >>> 32 - s, ss = (t, e, s) => e << s | t >>> 32 - s, ns = (t, e, s) => e << s - 32 | t >>> 64 - s, os = (t, e, s) => t << s - 32 | e >>> 64 - s;
736
+ const rs = (t, e, s) => t << s | e >>> 32 - s, is = (t, e, s) => e << s | t >>> 32 - s, as = (t, e, s) => e << s - 32 | t >>> 64 - s, cs = (t, e, s) => t << s - 32 | e >>> 64 - s;
737
737
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
738
- function rs(t) {
738
+ function us(t) {
739
739
  return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
740
740
  }
741
- function De(t) {
741
+ function Pe(t) {
742
742
  if (!Number.isSafeInteger(t) || t < 0)
743
743
  throw new Error("positive integer expected, got " + t);
744
744
  }
745
- function $(t, ...e) {
746
- if (!rs(t))
745
+ function j(t, ...e) {
746
+ if (!us(t))
747
747
  throw new Error("Uint8Array expected");
748
748
  if (e.length > 0 && !e.includes(t.length))
749
749
  throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
750
750
  }
751
- function Ue(t, e = !0) {
751
+ function xe(t, e = !0) {
752
752
  if (t.destroyed)
753
753
  throw new Error("Hash instance has been destroyed");
754
754
  if (e && t.finished)
755
755
  throw new Error("Hash#digest() has already been called");
756
756
  }
757
- function is(t, e) {
758
- $(t);
757
+ function ls(t, e) {
758
+ j(t);
759
759
  const s = e.outputLen;
760
760
  if (t.length < s)
761
761
  throw new Error("digestInto() expects output buffer of length at least " + s);
762
762
  }
763
- function as(t) {
763
+ function ds(t) {
764
764
  return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
765
765
  }
766
- function Xe(...t) {
766
+ function tt(...t) {
767
767
  for (let e = 0; e < t.length; e++)
768
768
  t[e].fill(0);
769
769
  }
770
- const cs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
771
- function us(t) {
770
+ const fs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
771
+ function hs(t) {
772
772
  return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
773
773
  }
774
- function ls(t) {
774
+ function ms(t) {
775
775
  for (let e = 0; e < t.length; e++)
776
- t[e] = us(t[e]);
776
+ t[e] = hs(t[e]);
777
777
  return t;
778
778
  }
779
- const ve = cs ? (t) => t : ls;
780
- function ds(t) {
779
+ const Ne = fs ? (t) => t : ms;
780
+ function gs(t) {
781
781
  if (typeof t != "string")
782
782
  throw new Error("string expected");
783
783
  return new Uint8Array(new TextEncoder().encode(t));
784
784
  }
785
- function Je(t) {
786
- return typeof t == "string" && (t = ds(t)), $(t), t;
785
+ function st(t) {
786
+ return typeof t == "string" && (t = gs(t)), j(t), t;
787
787
  }
788
- class fs {
788
+ class ps {
789
789
  }
790
- function hs(t) {
791
- const e = (n) => t().update(Je(n)).digest(), s = t();
790
+ function ys(t) {
791
+ const e = (n) => t().update(st(n)).digest(), s = t();
792
792
  return e.outputLen = s.outputLen, e.blockLen = s.blockLen, e.create = () => t(), e;
793
793
  }
794
- const gs = BigInt(0), N = BigInt(1), ms = BigInt(2), ps = BigInt(7), ys = BigInt(256), Ts = BigInt(113), Ze = [], Qe = [], et = [];
795
- for (let t = 0, e = N, s = 1, n = 0; t < 24; t++) {
796
- [s, n] = [n, (2 * s + 3 * n) % 5], Ze.push(2 * (5 * n + s)), Qe.push((t + 1) * (t + 2) / 2 % 64);
797
- let o = gs;
794
+ const Ts = BigInt(0), O = BigInt(1), bs = BigInt(2), Es = BigInt(7), Ss = BigInt(256), ws = BigInt(113), nt = [], ot = [], rt = [];
795
+ for (let t = 0, e = O, s = 1, n = 0; t < 24; t++) {
796
+ [s, n] = [n, (2 * s + 3 * n) % 5], nt.push(2 * (5 * n + s)), ot.push((t + 1) * (t + 2) / 2 % 64);
797
+ let o = Ts;
798
798
  for (let i = 0; i < 7; i++)
799
- e = (e << N ^ (e >> ps) * Ts) % ys, e & ms && (o ^= N << (N << /* @__PURE__ */ BigInt(i)) - N);
800
- et.push(o);
799
+ e = (e << O ^ (e >> Es) * ws) % Ss, e & bs && (o ^= O << (O << /* @__PURE__ */ BigInt(i)) - O);
800
+ rt.push(o);
801
801
  }
802
- const tt = es(et, !0), bs = tt[0], Es = tt[1], ke = (t, e, s) => s > 32 ? ns(t, e, s) : ts(t, e, s), Ie = (t, e, s) => s > 32 ? os(t, e, s) : ss(t, e, s);
803
- function Ss(t, e = 24) {
802
+ const it = os(rt, !0), Rs = it[0], Cs = it[1], Oe = (t, e, s) => s > 32 ? as(t, e, s) : rs(t, e, s), Be = (t, e, s) => s > 32 ? cs(t, e, s) : is(t, e, s);
803
+ function As(t, e = 24) {
804
804
  const s = new Uint32Array(10);
805
805
  for (let n = 24 - e; n < 24; n++) {
806
806
  for (let r = 0; r < 10; r++)
807
807
  s[r] = t[r] ^ t[r + 10] ^ t[r + 20] ^ t[r + 30] ^ t[r + 40];
808
808
  for (let r = 0; r < 10; r += 2) {
809
- const a = (r + 8) % 10, u = (r + 2) % 10, l = s[u], d = s[u + 1], E = ke(l, d, 1) ^ s[a], m = Ie(l, d, 1) ^ s[a + 1];
809
+ const a = (r + 8) % 10, u = (r + 2) % 10, l = s[u], f = s[u + 1], E = Oe(l, f, 1) ^ s[a], h = Be(l, f, 1) ^ s[a + 1];
810
810
  for (let y = 0; y < 50; y += 10)
811
- t[r + y] ^= E, t[r + y + 1] ^= m;
811
+ t[r + y] ^= E, t[r + y + 1] ^= h;
812
812
  }
813
813
  let o = t[2], i = t[3];
814
814
  for (let r = 0; r < 24; r++) {
815
- const a = Qe[r], u = ke(o, i, a), l = Ie(o, i, a), d = Ze[r];
816
- o = t[d], i = t[d + 1], t[d] = u, t[d + 1] = l;
815
+ const a = ot[r], u = Oe(o, i, a), l = Be(o, i, a), f = nt[r];
816
+ o = t[f], i = t[f + 1], t[f] = u, t[f + 1] = l;
817
817
  }
818
818
  for (let r = 0; r < 50; r += 10) {
819
819
  for (let a = 0; a < 10; a++)
@@ -821,25 +821,25 @@ function Ss(t, e = 24) {
821
821
  for (let a = 0; a < 10; a++)
822
822
  t[r + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
823
823
  }
824
- t[0] ^= bs[n], t[1] ^= Es[n];
824
+ t[0] ^= Rs[n], t[1] ^= Cs[n];
825
825
  }
826
- Xe(s);
826
+ tt(s);
827
827
  }
828
- class le extends fs {
828
+ class me extends ps {
829
829
  // NOTE: we accept arguments in bytes instead of bits here.
830
830
  constructor(e, s, n, o = !1, i = 24) {
831
- if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = s, this.outputLen = n, this.enableXOF = o, this.rounds = i, De(n), !(0 < e && e < 200))
831
+ if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = s, this.outputLen = n, this.enableXOF = o, this.rounds = i, Pe(n), !(0 < e && e < 200))
832
832
  throw new Error("only keccak-f1600 function is supported");
833
- this.state = new Uint8Array(200), this.state32 = as(this.state);
833
+ this.state = new Uint8Array(200), this.state32 = ds(this.state);
834
834
  }
835
835
  clone() {
836
836
  return this._cloneInto();
837
837
  }
838
838
  keccak() {
839
- ve(this.state32), Ss(this.state32, this.rounds), ve(this.state32), this.posOut = 0, this.pos = 0;
839
+ Ne(this.state32), As(this.state32, this.rounds), Ne(this.state32), this.posOut = 0, this.pos = 0;
840
840
  }
841
841
  update(e) {
842
- Ue(this), e = Je(e), $(e);
842
+ xe(this), e = st(e), j(e);
843
843
  const { blockLen: s, state: n } = this, o = e.length;
844
844
  for (let i = 0; i < o; ) {
845
845
  const r = Math.min(s - this.pos, o - i);
@@ -857,7 +857,7 @@ class le extends fs {
857
857
  e[n] ^= s, (s & 128) !== 0 && n === o - 1 && this.keccak(), e[o - 1] ^= 128, this.keccak();
858
858
  }
859
859
  writeInto(e) {
860
- Ue(this, !1), $(e), this.finish();
860
+ xe(this, !1), j(e), this.finish();
861
861
  const s = this.state, { blockLen: n } = this;
862
862
  for (let o = 0, i = e.length; o < i; ) {
863
863
  this.posOut >= n && this.keccak();
@@ -872,10 +872,10 @@ class le extends fs {
872
872
  return this.writeInto(e);
873
873
  }
874
874
  xof(e) {
875
- return De(e), this.xofInto(new Uint8Array(e));
875
+ return Pe(e), this.xofInto(new Uint8Array(e));
876
876
  }
877
877
  digestInto(e) {
878
- if (is(e, this), this.finished)
878
+ if (ls(e, this), this.finished)
879
879
  throw new Error("digest() was already called");
880
880
  return this.writeInto(e), this.destroy(), e;
881
881
  }
@@ -883,18 +883,18 @@ class le extends fs {
883
883
  return this.digestInto(new Uint8Array(this.outputLen));
884
884
  }
885
885
  destroy() {
886
- this.destroyed = !0, Xe(this.state);
886
+ this.destroyed = !0, tt(this.state);
887
887
  }
888
888
  _cloneInto(e) {
889
889
  const { blockLen: s, suffix: n, outputLen: o, rounds: i, enableXOF: r } = this;
890
- return e || (e = new le(s, n, o, r, i)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = i, e.suffix = n, e.outputLen = o, e.enableXOF = r, e.destroyed = this.destroyed, e;
890
+ return e || (e = new me(s, n, o, r, i)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = i, e.suffix = n, e.outputLen = o, e.enableXOF = r, e.destroyed = this.destroyed, e;
891
891
  }
892
892
  }
893
- const ws = (t, e, s) => hs(() => new le(e, t, s)), Rs = ws(1, 136, 256 / 8);
894
- function Cs(t, e) {
895
- return Rs(ce(t, { strict: !1 }) ? Xt(t) : t);
893
+ const Ds = (t, e, s) => ys(() => new me(e, t, s)), Us = Ds(1, 136, 256 / 8);
894
+ function vs(t, e) {
895
+ return Us(fe(t, { strict: !1 }) ? es(t) : t);
896
896
  }
897
- class As extends U {
897
+ class ks extends I {
898
898
  constructor({ address: e }) {
899
899
  super(`Address "${e}" is invalid.`, {
900
900
  metaMessages: [
@@ -905,7 +905,7 @@ class As extends U {
905
905
  });
906
906
  }
907
907
  }
908
- class st extends Map {
908
+ class at extends Map {
909
909
  constructor(e) {
910
910
  super(), Object.defineProperty(this, "maxSize", {
911
911
  enumerable: !0,
@@ -926,28 +926,28 @@ class st extends Map {
926
926
  return this;
927
927
  }
928
928
  }
929
- const X = /* @__PURE__ */ new st(8192);
930
- function nt(t, e) {
931
- if (X.has(`${t}.${e}`))
932
- return X.get(`${t}.${e}`);
933
- const s = t.substring(2).toLowerCase(), n = Cs(Ge(s)), o = s.split("");
929
+ const ee = /* @__PURE__ */ new at(8192);
930
+ function ct(t, e) {
931
+ if (ee.has(`${t}.${e}`))
932
+ return ee.get(`${t}.${e}`);
933
+ const s = t.substring(2).toLowerCase(), n = vs(et(s)), o = s.split("");
934
934
  for (let r = 0; r < 40; r += 2)
935
935
  n[r >> 1] >> 4 >= 8 && o[r] && (o[r] = o[r].toUpperCase()), (n[r >> 1] & 15) >= 8 && o[r + 1] && (o[r + 1] = o[r + 1].toUpperCase());
936
936
  const i = `0x${o.join("")}`;
937
- return X.set(`${t}.${e}`, i), i;
937
+ return ee.set(`${t}.${e}`, i), i;
938
938
  }
939
939
  function S(t, e) {
940
- if (!Us(t, { strict: !1 }))
941
- throw new As({ address: t });
942
- return nt(t, e);
940
+ if (!Ps(t, { strict: !1 }))
941
+ throw new ks({ address: t });
942
+ return ct(t, e);
943
943
  }
944
- const Ds = /^0x[a-fA-F0-9]{40}$/, J = /* @__PURE__ */ new st(8192);
945
- function Us(t, e) {
944
+ const Is = /^0x[a-fA-F0-9]{40}$/, te = /* @__PURE__ */ new at(8192);
945
+ function Ps(t, e) {
946
946
  const { strict: s = !0 } = e ?? {}, n = `${t}.${s}`;
947
- if (J.has(n))
948
- return J.get(n);
949
- const o = Ds.test(t) ? t.toLowerCase() === t ? !0 : s ? nt(t) === t : !0 : !1;
950
- return J.set(n, o), o;
947
+ if (te.has(n))
948
+ return te.get(n);
949
+ const o = Is.test(t) ? t.toLowerCase() === t ? !0 : s ? ct(t) === t : !0 : !1;
950
+ return te.set(n, o), o;
951
951
  }
952
952
  const c = {
953
953
  USDC: "USDC",
@@ -962,8 +962,8 @@ const c = {
962
962
  LORDS: "LORDS"
963
963
  };
964
964
  c.USDC;
965
- const ot = {
966
- [T.ARBITRUM]: {
965
+ const ut = {
966
+ [b.ARBITRUM]: {
967
967
  [c.DAI]: {
968
968
  address: S("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
969
969
  symbol: c.DAI,
@@ -1005,7 +1005,7 @@ const ot = {
1005
1005
  nativeToken: !1
1006
1006
  }
1007
1007
  },
1008
- [T.ARBITRUM_TESTNET]: {
1008
+ [b.ARBITRUM_TESTNET]: {
1009
1009
  [c.USDC]: {
1010
1010
  address: S("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
1011
1011
  symbol: c.USDC,
@@ -1017,7 +1017,7 @@ const ot = {
1017
1017
  nativeToken: !1
1018
1018
  }
1019
1019
  },
1020
- [T.AVALANCHE]: {
1020
+ [b.AVALANCHE]: {
1021
1021
  [c.DAI]: {
1022
1022
  address: "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
1023
1023
  symbol: c.DAI,
@@ -1053,7 +1053,7 @@ const ot = {
1053
1053
  nativeToken: !1
1054
1054
  }
1055
1055
  },
1056
- [T.AVALANCHE_TESTNET]: {
1056
+ [b.AVALANCHE_TESTNET]: {
1057
1057
  [c.USDC]: {
1058
1058
  address: S("0x5425890298aed601595a70AB815c96711a31Bc65"),
1059
1059
  symbol: c.USDC,
@@ -1065,7 +1065,7 @@ const ot = {
1065
1065
  nativeToken: !1
1066
1066
  }
1067
1067
  },
1068
- [T.BASE]: {
1068
+ [b.BASE]: {
1069
1069
  [c.DAI]: {
1070
1070
  address: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
1071
1071
  symbol: c.DAI,
@@ -1109,7 +1109,7 @@ const ot = {
1109
1109
  nativeToken: !1
1110
1110
  }
1111
1111
  },
1112
- [T.BASE_TESTNET]: {
1112
+ [b.BASE_TESTNET]: {
1113
1113
  [c.USDC]: {
1114
1114
  address: S("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
1115
1115
  symbol: c.USDC,
@@ -1121,7 +1121,7 @@ const ot = {
1121
1121
  nativeToken: !1
1122
1122
  }
1123
1123
  },
1124
- [T.BSC]: {
1124
+ [b.BSC]: {
1125
1125
  [c.BNB]: {
1126
1126
  address: "0x0000000000000000000000000000000000000000",
1127
1127
  symbol: c.BNB,
@@ -1172,7 +1172,7 @@ const ot = {
1172
1172
  nativeToken: !1
1173
1173
  }
1174
1174
  },
1175
- [T.ETHEREUM]: {
1175
+ [b.ETHEREUM]: {
1176
1176
  [c.BUSD]: {
1177
1177
  address: "0x4Fabb145d64652a948d72533023f6E7A623C7C53",
1178
1178
  symbol: c.BUSD,
@@ -1239,7 +1239,7 @@ const ot = {
1239
1239
  nativeToken: !1
1240
1240
  }
1241
1241
  },
1242
- [T.ETHEREUM_TESTNET]: {
1242
+ [b.ETHEREUM_TESTNET]: {
1243
1243
  [c.USDC]: {
1244
1244
  address: S("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
1245
1245
  symbol: c.USDC,
@@ -1250,7 +1250,7 @@ const ot = {
1250
1250
  nativeToken: !1
1251
1251
  }
1252
1252
  },
1253
- [T.HYPEREVM]: {
1253
+ [b.HYPEREVM]: {
1254
1254
  [c.USDC]: {
1255
1255
  address: "0xb88339CB7199b77E23DB6E890353E22632Ba630f",
1256
1256
  symbol: c.USDC,
@@ -1260,7 +1260,7 @@ const ot = {
1260
1260
  nativeToken: !1
1261
1261
  }
1262
1262
  },
1263
- [T.LISK]: {
1263
+ [b.LISK]: {
1264
1264
  [c.USDC]: {
1265
1265
  address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
1266
1266
  symbol: c.USDC,
@@ -1270,7 +1270,7 @@ const ot = {
1270
1270
  nativeToken: !1
1271
1271
  }
1272
1272
  },
1273
- [T.MONAD]: {
1273
+ [b.MONAD]: {
1274
1274
  [c.USDC]: {
1275
1275
  address: "0x754704Bc059F8C67012fEd69BC8A327a5aafb603",
1276
1276
  symbol: c.USDC,
@@ -1280,7 +1280,7 @@ const ot = {
1280
1280
  nativeToken: !1
1281
1281
  }
1282
1282
  },
1283
- [T.MONAD_TESTNET]: {
1283
+ [b.MONAD_TESTNET]: {
1284
1284
  [c.USDC]: {
1285
1285
  address: "0x534b2f3A21130d7a60830c2Df862319e593943A3",
1286
1286
  symbol: c.USDC,
@@ -1290,7 +1290,7 @@ const ot = {
1290
1290
  nativeToken: !1
1291
1291
  }
1292
1292
  },
1293
- [T.OPTIMISM]: {
1293
+ [b.OPTIMISM]: {
1294
1294
  [c.DAI]: {
1295
1295
  address: "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",
1296
1296
  symbol: c.DAI,
@@ -1332,7 +1332,7 @@ const ot = {
1332
1332
  nativeToken: !1
1333
1333
  }
1334
1334
  },
1335
- [T.OPTIMISM_TESTNET]: {
1335
+ [b.OPTIMISM_TESTNET]: {
1336
1336
  [c.USDC]: {
1337
1337
  address: "0x5fd84259d66Cd46123540766Be93DFE6D43130D7",
1338
1338
  symbol: c.USDC,
@@ -1342,7 +1342,7 @@ const ot = {
1342
1342
  nativeToken: !1
1343
1343
  }
1344
1344
  },
1345
- [T.POLYGON]: {
1345
+ [b.POLYGON]: {
1346
1346
  [c.DAI]: {
1347
1347
  address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
1348
1348
  symbol: c.DAI,
@@ -1376,7 +1376,7 @@ const ot = {
1376
1376
  nativeToken: !1
1377
1377
  }
1378
1378
  },
1379
- [T.STARKNET]: {
1379
+ [b.STARKNET]: {
1380
1380
  [c.DAI]: {
1381
1381
  address: "0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",
1382
1382
  symbol: c.DAI,
@@ -1427,7 +1427,7 @@ const ot = {
1427
1427
  nativeToken: !1
1428
1428
  }
1429
1429
  },
1430
- [T.STARKNET_TESTNET]: {
1430
+ [b.STARKNET_TESTNET]: {
1431
1431
  [c.USDC]: {
1432
1432
  address: "0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",
1433
1433
  symbol: c.USDC,
@@ -1437,20 +1437,20 @@ const ot = {
1437
1437
  nativeToken: !1
1438
1438
  }
1439
1439
  }
1440
- }, vs = new Set(Object.values(T));
1440
+ }, xs = new Set(Object.values(b));
1441
1441
  function w(t) {
1442
- if (ks(t))
1442
+ if (Ns(t))
1443
1443
  return t;
1444
- const e = T[t];
1444
+ const e = b[t];
1445
1445
  if (!e)
1446
1446
  throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);
1447
1447
  return e;
1448
1448
  }
1449
- function ks(t) {
1450
- return vs.has(t);
1449
+ function Ns(t) {
1450
+ return xs.has(t);
1451
1451
  }
1452
- function Is(t, e) {
1453
- const s = e.toLowerCase().trim(), n = ot[t];
1452
+ function Os(t, e) {
1453
+ const s = e.toLowerCase().trim(), n = ut[t];
1454
1454
  if (!n)
1455
1455
  throw new Error(
1456
1456
  `Chain not found: ${t}. The chain key must be a valid chain identifier.`
@@ -1469,57 +1469,57 @@ function Is(t, e) {
1469
1469
  );
1470
1470
  return o;
1471
1471
  }
1472
- function Z(t, e, s) {
1473
- const n = Is(t, e);
1472
+ function se(t, e, s) {
1473
+ const n = Os(t, e);
1474
1474
  if (n.symbol !== s)
1475
1475
  throw new Error(
1476
1476
  `Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${n.symbol}", but expected "${s}". The token address must correspond to a token with the expected symbol on the specified chain.`
1477
1477
  );
1478
1478
  return n;
1479
1479
  }
1480
- function Ps(t, e) {
1481
- return ot[t]?.[e];
1480
+ function Bs(t, e) {
1481
+ return ut[t]?.[e];
1482
1482
  }
1483
- function Pe(t, e) {
1484
- return Ps(t, e)?.address;
1483
+ function Me(t, e) {
1484
+ return Bs(t, e)?.address;
1485
1485
  }
1486
- var de = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(de || {});
1487
- class g {
1486
+ var ge = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(ge || {});
1487
+ class d {
1488
1488
  constructor({ api_key: e, env: s, seesion_token: n, props: o }) {
1489
- this.api_key = e || "", this.sessionToken = n || "", this.env = s ?? de.PRODUCTION, this.props = o;
1489
+ this.api_key = e || "", this.sessionToken = n || "", this.env = s ?? ge.PRODUCTION, this.props = o;
1490
1490
  }
1491
1491
  static async config(e) {
1492
- if (!g.app) {
1492
+ if (!d.app) {
1493
1493
  if (!e)
1494
1494
  throw new Error("Please provide an api_key");
1495
- g.app = new g(e);
1495
+ d.app = new d(e);
1496
1496
  }
1497
- return e && (e.api_key !== void 0 && (g.app.api_key = e.api_key), e.seesion_token !== void 0 && (g.app.sessionToken = e.seesion_token), e.env !== void 0 && (g.app.env = e.env), e.props !== void 0 && (g.app.props = e.props)), g.app;
1497
+ return e && (e.api_key !== void 0 && (d.app.api_key = e.api_key), e.seesion_token !== void 0 && (d.app.sessionToken = e.seesion_token), e.env !== void 0 && (d.app.env = e.env), e.props !== void 0 && (d.app.props = e.props)), d.app;
1498
1498
  }
1499
1499
  static getApiKey() {
1500
- if (!g.app)
1500
+ if (!d.app)
1501
1501
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1502
- return g.app.api_key;
1502
+ return d.app.api_key;
1503
1503
  }
1504
1504
  static getSessionToken() {
1505
- if (!g.app)
1505
+ if (!d.app)
1506
1506
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1507
- return g.app.sessionToken;
1507
+ return d.app.sessionToken;
1508
1508
  }
1509
1509
  static getProps() {
1510
- if (!g.app)
1510
+ if (!d.app)
1511
1511
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1512
- return g.app.props;
1512
+ return d.app.props;
1513
1513
  }
1514
1514
  static getEnv() {
1515
- if (!g.app)
1515
+ if (!d.app)
1516
1516
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1517
- return g.app.env === "internal" ? "staging" : g.app.env;
1517
+ return d.app.env === "internal" ? "staging" : d.app.env;
1518
1518
  }
1519
1519
  static getBaseUrl() {
1520
- if (!g.app)
1520
+ if (!d.app)
1521
1521
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1522
- switch (g.app.env) {
1522
+ switch (d.app.env) {
1523
1523
  case "production":
1524
1524
  return "https://api.chainrails.io/api/v1";
1525
1525
  case "staging":
@@ -1531,23 +1531,23 @@ class g {
1531
1531
  }
1532
1532
  }
1533
1533
  static getPayModalUrl(e) {
1534
- if (!g.app)
1534
+ if (!d.app)
1535
1535
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1536
- const s = g.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(e), o = e && !isNaN(Number(e)) && n > 0 ? "/pay/" : "/deposit/", i = `${e && !isNaN(Number(e)) && n > 0 ? n * 100 : ""}`;
1536
+ const s = d.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", n = Number(e), o = e && !isNaN(Number(e)) && n > 0 ? "/pay/" : "/deposit/", i = `${e && !isNaN(Number(e)) && n > 0 ? n * 100 : ""}`;
1537
1537
  return s + o + i;
1538
1538
  }
1539
1539
  }
1540
- let ne = null;
1541
- function xs() {
1542
- ne = jt.create({
1543
- prefixUrl: g.getBaseUrl(),
1540
+ let ae = null;
1541
+ function Ms() {
1542
+ ae = Vt.create({
1543
+ prefixUrl: d.getBaseUrl(),
1544
1544
  headers: {
1545
1545
  "Content-Type": "application/json"
1546
1546
  },
1547
1547
  hooks: {
1548
1548
  beforeRequest: [
1549
1549
  (t) => {
1550
- const e = g.getSessionToken() || g.getApiKey();
1550
+ const e = d.getSessionToken() || d.getApiKey();
1551
1551
  t.headers.set("Authorization", `Bearer ${e}`);
1552
1552
  }
1553
1553
  ],
@@ -1559,9 +1559,9 @@ function xs() {
1559
1559
  });
1560
1560
  }
1561
1561
  function p() {
1562
- return ne || xs(), ne;
1562
+ return ae || Ms(), ae;
1563
1563
  }
1564
- class Ns {
1564
+ class Ls {
1565
1565
  async getById(e) {
1566
1566
  return await p().get("intents/" + e).json();
1567
1567
  }
@@ -1603,10 +1603,10 @@ class Ns {
1603
1603
  return await p().post(`modal/sessions/intents/${e}/process`).json();
1604
1604
  }
1605
1605
  }
1606
- class Os {
1606
+ class _s {
1607
1607
  async getFromSpecificBridge(e) {
1608
1608
  const s = w(e.sourceChain);
1609
- Z(s, e.tokenIn, e.amountSymbol);
1609
+ se(s, e.tokenIn, e.amountSymbol);
1610
1610
  const n = w(e.destinationChain);
1611
1611
  return await p().get("quotes/single", {
1612
1612
  searchParams: {
@@ -1618,7 +1618,7 @@ class Os {
1618
1618
  }
1619
1619
  async getFromAllBridges(e) {
1620
1620
  const s = w(e.sourceChain);
1621
- Z(s, e.tokenIn, e.amountSymbol);
1621
+ se(s, e.tokenIn, e.amountSymbol);
1622
1622
  const n = w(e.destinationChain);
1623
1623
  return await p().get("quotes/multiple", {
1624
1624
  searchParams: {
@@ -1630,7 +1630,7 @@ class Os {
1630
1630
  }
1631
1631
  async getBestAcrossBridges(e) {
1632
1632
  const s = w(e.sourceChain);
1633
- Z(s, e.tokenIn, e.amountSymbol);
1633
+ se(s, e.tokenIn, e.amountSymbol);
1634
1634
  const n = w(e.destinationChain);
1635
1635
  return await p().get("quotes/best", { searchParams: {
1636
1636
  ...e,
@@ -1649,7 +1649,7 @@ class Os {
1649
1649
  return await p().get("modal/sessions/quotes", { searchParams: e }).json();
1650
1650
  }
1651
1651
  }
1652
- class Bs {
1652
+ class Fs {
1653
1653
  async getOptimalRoutes(e) {
1654
1654
  const s = w(e.sourceChain), n = w(e.destinationChain);
1655
1655
  return await p().get("router/optimal-route", {
@@ -1675,7 +1675,7 @@ class Bs {
1675
1675
  return await p().get("router/supported-routes/bridge/" + e).json();
1676
1676
  }
1677
1677
  }
1678
- class Ms {
1678
+ class Hs {
1679
1679
  async getSupported(e) {
1680
1680
  return await p().get("chains", { searchParams: e }).json();
1681
1681
  }
@@ -1683,7 +1683,7 @@ class Ms {
1683
1683
  return await p().get(`chains/balances/${e.address}`, { searchParams: e }).json();
1684
1684
  }
1685
1685
  }
1686
- class Ls {
1686
+ class $s {
1687
1687
  async getClientInfo() {
1688
1688
  return await p().get("client/auth/client-info").json();
1689
1689
  }
@@ -1691,11 +1691,11 @@ class Ls {
1691
1691
  return await p().get("modal/sessions/client").json();
1692
1692
  }
1693
1693
  }
1694
- class Fs {
1694
+ class js {
1695
1695
  async getSessionToken(e) {
1696
1696
  const s = w(e.destinationChain);
1697
- let n = Pe(s, e.token);
1698
- n || (console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`), n = Pe(s, "USDC"));
1697
+ let n = Me(s, e.token);
1698
+ n || (console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`), n = Me(s, "USDC"));
1699
1699
  const o = {
1700
1700
  recipient: e.recipient,
1701
1701
  tokenOut: n,
@@ -1705,28 +1705,29 @@ class Fs {
1705
1705
  return p().post("modal/sessions", { json: o }).json().then((i) => ({ ...i, amount: o.amount }));
1706
1706
  }
1707
1707
  }
1708
- const ln = {
1709
- router: new Bs(),
1710
- quotes: new Os(),
1711
- intents: new Ns(),
1712
- chains: new Ms(),
1713
- client: new Ls(),
1714
- auth: new Fs()
1708
+ const gn = {
1709
+ router: new Fs(),
1710
+ quotes: new _s(),
1711
+ intents: new Ls(),
1712
+ chains: new Hs(),
1713
+ client: new $s(),
1714
+ auth: new js()
1715
1715
  };
1716
- function rt(t) {
1716
+ function lt(t) {
1717
1717
  var e, s, n = "";
1718
1718
  if (typeof t == "string" || typeof t == "number") n += t;
1719
1719
  else if (typeof t == "object") if (Array.isArray(t)) {
1720
1720
  var o = t.length;
1721
- for (e = 0; e < o; e++) t[e] && (s = rt(t[e])) && (n && (n += " "), n += s);
1721
+ for (e = 0; e < o; e++) t[e] && (s = lt(t[e])) && (n && (n += " "), n += s);
1722
1722
  } else for (s in t) t[s] && (n && (n += " "), n += s);
1723
1723
  return n;
1724
1724
  }
1725
- function _s() {
1726
- for (var t, e, s = 0, n = "", o = arguments.length; s < o; s++) (t = arguments[s]) && (e = rt(t)) && (n && (n += " "), n += e);
1725
+ function zs() {
1726
+ for (var t, e, s = 0, n = "", o = arguments.length; s < o; s++) (t = arguments[s]) && (e = lt(t)) && (n && (n += " "), n += e);
1727
1727
  return n;
1728
1728
  }
1729
- function dn(t) {
1729
+ const qs = ["light", "dark", "system"];
1730
+ function pn(t) {
1730
1731
  const {
1731
1732
  amount: e,
1732
1733
  styles: s,
@@ -1737,140 +1738,158 @@ function dn(t) {
1737
1738
  close: a,
1738
1739
  onCancel: u,
1739
1740
  onSuccess: l,
1740
- session_url: d,
1741
+ session_url: f,
1741
1742
  sessionToken: E
1742
- } = t, [m, y] = I(0), [R, W] = I(""), f = ie(null);
1743
- g.config({
1743
+ } = t, [h, y] = k(0), [R, V] = k(""), [g, T] = k(null), m = le(null);
1744
+ d.config({
1744
1745
  api_key: "",
1745
1746
  // @ts-expect-error
1746
1747
  env: t.env === "internal" ? "internal" : "production"
1747
1748
  }), x(() => {
1748
- W(g.getPayModalUrl(e));
1749
+ V(d.getPayModalUrl(e));
1749
1750
  }, [e]), x(() => {
1750
- const h = document.body.style.overflow;
1751
- o ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = h || "";
1752
- const C = (v) => {
1753
- v.data === "closed" && (a(), u?.()), v.data === "completed" && (window.setTimeout(a, 2e3), l?.());
1751
+ const C = s?.theme;
1752
+ if (!C || qs.includes(C)) {
1753
+ T(null);
1754
+ return;
1755
+ }
1756
+ let D = !1;
1757
+ return (async () => {
1758
+ try {
1759
+ const G = d.getBaseUrl(), Re = await fetch(`${G}/themes/${C}`);
1760
+ if (!Re.ok) return;
1761
+ const X = await Re.json();
1762
+ !D && X.status === "approved" && X.css_content && T(X.css_content);
1763
+ } catch (G) {
1764
+ console.error("Failed to fetch theme:", G);
1765
+ }
1766
+ })(), () => {
1767
+ D = !0;
1768
+ };
1769
+ }, [s?.theme]), x(() => {
1770
+ const C = document.body.style.overflow;
1771
+ o ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = C || "";
1772
+ const D = (Y) => {
1773
+ Y.data === "closed" && (a(), u?.()), Y.data === "completed" && (window.setTimeout(a, 2e3), l?.());
1754
1774
  };
1755
- return window.addEventListener("message", C), () => {
1756
- document.body.style.overflow = h || "", window.removeEventListener("message", C);
1775
+ return window.addEventListener("message", D), () => {
1776
+ document.body.style.overflow = C || "", window.removeEventListener("message", D);
1757
1777
  };
1758
1778
  }, [o, u, l]), x(() => {
1759
1779
  if (!E) return;
1760
- const h = {
1780
+ const C = t.css || g || void 0, D = {
1761
1781
  type: "session",
1762
1782
  session_token: E,
1763
- environment: g.getEnv() || de.PRODUCTION,
1783
+ environment: d.getEnv() || ge.PRODUCTION,
1764
1784
  styles: s,
1765
1785
  props: {
1766
1786
  excludeChains: n?.join(",")
1767
1787
  },
1768
- // @ts-expect-error - internal property, not exposed in public types
1769
- ...t.css ? {
1770
- css: t.css
1788
+ ...C ? {
1789
+ css: C
1771
1790
  } : {}
1772
1791
  };
1773
- f.current?.contentWindow?.postMessage(h, "https://app.chainrails.io"), f.current?.contentWindow?.postMessage(h, "https://chainrails-frontend-git-staging-horus-labs.vercel.app"), window.setTimeout(() => {
1774
- f.current?.contentWindow?.postMessage(h, "https://app.chainrails.io"), f.current?.contentWindow?.postMessage(h, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1792
+ m.current?.contentWindow?.postMessage(D, "https://app.chainrails.io"), m.current?.contentWindow?.postMessage(D, "https://chainrails-frontend-git-staging-horus-labs.vercel.app"), window.setTimeout(() => {
1793
+ m.current?.contentWindow?.postMessage(D, "https://app.chainrails.io"), m.current?.contentWindow?.postMessage(D, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1775
1794
  }, 1e3);
1776
- }, [E, m, o, s]);
1777
- function b() {
1795
+ }, [E, h, o, s, g]);
1796
+ function A() {
1778
1797
  y(Math.random());
1779
1798
  }
1780
- return /* @__PURE__ */ Ee("div", {
1781
- className: _s("payment-modal-wrapper", m === 0 || i ? "loading" : "not-loading", o ? "open" : "closed"),
1782
- children: [(m === 0 || i) && /* @__PURE__ */ L("div", {
1799
+ return /* @__PURE__ */ Ae("div", {
1800
+ className: zs("payment-modal-wrapper", h === 0 || i ? "loading" : "not-loading", o ? "open" : "closed"),
1801
+ children: [(h === 0 || i) && /* @__PURE__ */ _("div", {
1783
1802
  role: "status",
1784
1803
  className: "payment-modal-loader",
1785
- children: /* @__PURE__ */ Ee("svg", {
1804
+ children: /* @__PURE__ */ Ae("svg", {
1786
1805
  "aria-hidden": "true",
1787
1806
  className: "icon",
1788
1807
  viewBox: "0 0 100 101",
1789
1808
  fill: "none",
1790
1809
  xmlns: "http://www.w3.org/2000/svg",
1791
- children: [/* @__PURE__ */ L("path", {
1810
+ children: [/* @__PURE__ */ _("path", {
1792
1811
  d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",
1793
1812
  fill: "currentColor"
1794
- }), /* @__PURE__ */ L("path", {
1813
+ }), /* @__PURE__ */ _("path", {
1795
1814
  d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",
1796
1815
  fill: "currentFill"
1797
1816
  })]
1798
1817
  })
1799
- }), /* @__PURE__ */ L("iframe", {
1818
+ }), /* @__PURE__ */ _("iframe", {
1800
1819
  allow: "clipboard-read *; clipboard-write *",
1801
1820
  src: R || void 0,
1802
- onLoad: b,
1803
- className: `payment-modal ${m === 0 || i ? "invisible" : "visible"}`,
1821
+ onLoad: A,
1822
+ className: `payment-modal ${h === 0 || i ? "invisible" : "visible"}`,
1804
1823
  "data-id": e,
1805
- ref: f
1824
+ ref: m
1806
1825
  }, e)]
1807
1826
  });
1808
1827
  }
1809
- const Hs = Symbol(), fe = Symbol(), O = "a", it = "f", xe = "p", at = "c", ct = "t", he = "h", B = "w", ge = "o", me = "k";
1810
- let $s = (t, e) => new Proxy(t, e);
1811
- const oe = Object.getPrototypeOf, re = /* @__PURE__ */ new WeakMap(), ut = (t) => t && (re.has(t) ? re.get(t) : oe(t) === Object.prototype || oe(t) === Array.prototype), z = (t) => typeof t == "object" && t !== null, zs = (t) => Object.values(Object.getOwnPropertyDescriptors(t)).some((e) => !e.configurable && !e.writable), js = (t) => {
1828
+ const Ks = Symbol(), pe = Symbol(), B = "a", dt = "f", Le = "p", ft = "c", ht = "t", ye = "h", M = "w", Te = "o", be = "k";
1829
+ let Ws = (t, e) => new Proxy(t, e);
1830
+ const ce = Object.getPrototypeOf, ue = /* @__PURE__ */ new WeakMap(), mt = (t) => t && (ue.has(t) ? ue.get(t) : ce(t) === Object.prototype || ce(t) === Array.prototype), z = (t) => typeof t == "object" && t !== null, Vs = (t) => Object.values(Object.getOwnPropertyDescriptors(t)).some((e) => !e.configurable && !e.writable), Ys = (t) => {
1812
1831
  if (Array.isArray(t))
1813
1832
  return Array.from(t);
1814
1833
  const e = Object.getOwnPropertyDescriptors(t);
1815
1834
  return Object.values(e).forEach((s) => {
1816
1835
  s.configurable = !0;
1817
- }), Object.create(oe(t), e);
1818
- }, qs = (t, e) => {
1836
+ }), Object.create(ce(t), e);
1837
+ }, Gs = (t, e) => {
1819
1838
  const s = {
1820
- [it]: e
1839
+ [dt]: e
1821
1840
  };
1822
1841
  let n = !1;
1823
1842
  const o = (a, u) => {
1824
1843
  if (!n) {
1825
- let l = s[O].get(t);
1826
- if (l || (l = {}, s[O].set(t, l)), a === B)
1827
- l[B] = !0;
1844
+ let l = s[B].get(t);
1845
+ if (l || (l = {}, s[B].set(t, l)), a === M)
1846
+ l[M] = !0;
1828
1847
  else {
1829
- let d = l[a];
1830
- d || (d = /* @__PURE__ */ new Set(), l[a] = d), d.add(u);
1848
+ let f = l[a];
1849
+ f || (f = /* @__PURE__ */ new Set(), l[a] = f), f.add(u);
1831
1850
  }
1832
1851
  }
1833
1852
  }, i = () => {
1834
- n = !0, s[O].delete(t);
1853
+ n = !0, s[B].delete(t);
1835
1854
  }, r = {
1836
1855
  get(a, u) {
1837
- return u === fe ? t : (o(me, u), lt(Reflect.get(a, u), s[O], s[at], s[ct]));
1856
+ return u === pe ? t : (o(be, u), gt(Reflect.get(a, u), s[B], s[ft], s[ht]));
1838
1857
  },
1839
1858
  has(a, u) {
1840
- return u === Hs ? (i(), !0) : (o(he, u), Reflect.has(a, u));
1859
+ return u === Ks ? (i(), !0) : (o(ye, u), Reflect.has(a, u));
1841
1860
  },
1842
1861
  getOwnPropertyDescriptor(a, u) {
1843
- return o(ge, u), Reflect.getOwnPropertyDescriptor(a, u);
1862
+ return o(Te, u), Reflect.getOwnPropertyDescriptor(a, u);
1844
1863
  },
1845
1864
  ownKeys(a) {
1846
- return o(B), Reflect.ownKeys(a);
1865
+ return o(M), Reflect.ownKeys(a);
1847
1866
  }
1848
1867
  };
1849
1868
  return e && (r.set = r.deleteProperty = () => !1), [r, s];
1850
- }, pe = (t) => (
1869
+ }, Ee = (t) => (
1851
1870
  // unwrap proxy
1852
- t[fe] || // otherwise
1871
+ t[pe] || // otherwise
1853
1872
  t
1854
- ), lt = (t, e, s, n) => {
1855
- if (!ut(t))
1873
+ ), gt = (t, e, s, n) => {
1874
+ if (!mt(t))
1856
1875
  return t;
1857
1876
  let o = n && n.get(t);
1858
1877
  if (!o) {
1859
- const u = pe(t);
1860
- zs(u) ? o = [u, js(u)] : o = [u], n?.set(t, o);
1878
+ const u = Ee(t);
1879
+ Vs(u) ? o = [u, Ys(u)] : o = [u], n?.set(t, o);
1861
1880
  }
1862
1881
  const [i, r] = o;
1863
1882
  let a = s && s.get(i);
1864
- return (!a || a[1][it] !== !!r) && (a = qs(i, !!r), a[1][xe] = $s(r || i, a[0]), s && s.set(i, a)), a[1][O] = e, a[1][at] = s, a[1][ct] = n, a[1][xe];
1865
- }, Ks = (t, e) => {
1883
+ return (!a || a[1][dt] !== !!r) && (a = Gs(i, !!r), a[1][Le] = Ws(r || i, a[0]), s && s.set(i, a)), a[1][B] = e, a[1][ft] = s, a[1][ht] = n, a[1][Le];
1884
+ }, Xs = (t, e) => {
1866
1885
  const s = Reflect.ownKeys(t), n = Reflect.ownKeys(e);
1867
1886
  return s.length !== n.length || s.some((o, i) => o !== n[i]);
1868
- }, dt = (t, e, s, n, o = Object.is) => {
1887
+ }, pt = (t, e, s, n, o = Object.is) => {
1869
1888
  if (o(t, e))
1870
1889
  return !1;
1871
1890
  if (!z(t) || !z(e))
1872
1891
  return !0;
1873
- const i = s.get(pe(t));
1892
+ const i = s.get(Ee(t));
1874
1893
  if (!i)
1875
1894
  return !0;
1876
1895
  if (n) {
@@ -1879,57 +1898,57 @@ const oe = Object.getPrototypeOf, re = /* @__PURE__ */ new WeakMap(), ut = (t) =
1879
1898
  n.set(t, e);
1880
1899
  }
1881
1900
  let r = null;
1882
- for (const a of i[he] || [])
1901
+ for (const a of i[ye] || [])
1883
1902
  if (r = Reflect.has(t, a) !== Reflect.has(e, a), r)
1884
1903
  return r;
1885
- if (i[B] === !0) {
1886
- if (r = Ks(t, e), r)
1904
+ if (i[M] === !0) {
1905
+ if (r = Xs(t, e), r)
1887
1906
  return r;
1888
1907
  } else
1889
- for (const a of i[ge] || []) {
1908
+ for (const a of i[Te] || []) {
1890
1909
  const u = !!Reflect.getOwnPropertyDescriptor(t, a), l = !!Reflect.getOwnPropertyDescriptor(e, a);
1891
1910
  if (r = u !== l, r)
1892
1911
  return r;
1893
1912
  }
1894
- for (const a of i[me] || [])
1895
- if (r = dt(t[a], e[a], s, n, o), r)
1913
+ for (const a of i[be] || [])
1914
+ if (r = pt(t[a], e[a], s, n, o), r)
1896
1915
  return r;
1897
1916
  if (r === null)
1898
1917
  throw new Error("invalid used");
1899
1918
  return r;
1900
- }, Ws = (t) => ut(t) && t[fe] || null, Ne = (t, e = !0) => {
1901
- re.set(t, e);
1902
- }, Vs = (t, e, s) => {
1919
+ }, Js = (t) => mt(t) && t[pe] || null, _e = (t, e = !0) => {
1920
+ ue.set(t, e);
1921
+ }, Zs = (t, e, s) => {
1903
1922
  const n = [], o = /* @__PURE__ */ new WeakSet(), i = (r, a) => {
1904
- var u, l, d;
1923
+ var u, l, f;
1905
1924
  if (o.has(r))
1906
1925
  return;
1907
1926
  z(r) && o.add(r);
1908
- const E = z(r) && e.get(pe(r));
1927
+ const E = z(r) && e.get(Ee(r));
1909
1928
  if (E) {
1910
- if ((u = E[he]) === null || u === void 0 || u.forEach((m) => {
1911
- const y = `:has(${String(m)})`;
1929
+ if ((u = E[ye]) === null || u === void 0 || u.forEach((h) => {
1930
+ const y = `:has(${String(h)})`;
1912
1931
  n.push(a ? [...a, y] : [y]);
1913
- }), E[B] === !0) {
1914
- const m = ":ownKeys";
1915
- n.push(a ? [...a, m] : [m]);
1932
+ }), E[M] === !0) {
1933
+ const h = ":ownKeys";
1934
+ n.push(a ? [...a, h] : [h]);
1916
1935
  } else
1917
- (l = E[ge]) === null || l === void 0 || l.forEach((m) => {
1918
- const y = `:hasOwn(${String(m)})`;
1936
+ (l = E[Te]) === null || l === void 0 || l.forEach((h) => {
1937
+ const y = `:hasOwn(${String(h)})`;
1919
1938
  n.push(a ? [...a, y] : [y]);
1920
1939
  });
1921
- (d = E[me]) === null || d === void 0 || d.forEach((m) => {
1922
- "value" in (Object.getOwnPropertyDescriptor(r, m) || {}) && i(r[m], a ? [...a, m] : [m]);
1940
+ (f = E[be]) === null || f === void 0 || f.forEach((h) => {
1941
+ "value" in (Object.getOwnPropertyDescriptor(r, h) || {}) && i(r[h], a ? [...a, h] : [h]);
1923
1942
  });
1924
1943
  } else a && n.push(a);
1925
1944
  };
1926
1945
  return i(t), n;
1927
- }, j = {}, ye = (t) => typeof t == "object" && t !== null, Ys = (t) => ye(t) && !Te.has(t) && (Array.isArray(t) || !(Symbol.iterator in t)) && !(t instanceof WeakMap) && !(t instanceof WeakSet) && !(t instanceof Error) && !(t instanceof Number) && !(t instanceof Date) && !(t instanceof String) && !(t instanceof RegExp) && !(t instanceof ArrayBuffer) && !(t instanceof Promise), ft = (t, e) => {
1928
- const s = Oe.get(t);
1946
+ }, q = {}, Se = (t) => typeof t == "object" && t !== null, Qs = (t) => Se(t) && !we.has(t) && (Array.isArray(t) || !(Symbol.iterator in t)) && !(t instanceof WeakMap) && !(t instanceof WeakSet) && !(t instanceof Error) && !(t instanceof Number) && !(t instanceof Date) && !(t instanceof String) && !(t instanceof RegExp) && !(t instanceof ArrayBuffer) && !(t instanceof Promise), yt = (t, e) => {
1947
+ const s = Fe.get(t);
1929
1948
  if (s?.[0] === e)
1930
1949
  return s[1];
1931
1950
  const n = Array.isArray(t) ? [] : Object.create(Object.getPrototypeOf(t));
1932
- return Ne(n, !0), Oe.set(t, [e, n]), Reflect.ownKeys(t).forEach((o) => {
1951
+ return _e(n, !0), Fe.set(t, [e, n]), Reflect.ownKeys(t).forEach((o) => {
1933
1952
  if (Object.getOwnPropertyDescriptor(n, o))
1934
1953
  return;
1935
1954
  const i = Reflect.get(t, o), { enumerable: r } = Reflect.getOwnPropertyDescriptor(
@@ -1942,17 +1961,17 @@ const oe = Object.getPrototypeOf, re = /* @__PURE__ */ new WeakMap(), ut = (t) =
1942
1961
  // It's still non-writable, so it avoids assigning a value.
1943
1962
  configurable: !0
1944
1963
  };
1945
- if (Te.has(i))
1946
- Ne(i, !1);
1947
- else if (P.has(i)) {
1948
- const [u, l] = P.get(
1964
+ if (we.has(i))
1965
+ _e(i, !1);
1966
+ else if (N.has(i)) {
1967
+ const [u, l] = N.get(
1949
1968
  i
1950
1969
  );
1951
- a.value = ft(u, l());
1970
+ a.value = yt(u, l());
1952
1971
  }
1953
1972
  Object.defineProperty(n, o, a);
1954
1973
  }), Object.preventExtensions(n);
1955
- }, Gs = (t, e, s, n) => ({
1974
+ }, en = (t, e, s, n) => ({
1956
1975
  deleteProperty(o, i) {
1957
1976
  const r = Reflect.get(o, i);
1958
1977
  s(i);
@@ -1961,81 +1980,81 @@ const oe = Object.getPrototypeOf, re = /* @__PURE__ */ new WeakMap(), ut = (t) =
1961
1980
  },
1962
1981
  set(o, i, r, a) {
1963
1982
  const u = !t() && Reflect.has(o, i), l = Reflect.get(o, i, a);
1964
- if (u && (Be(l, r) || q.has(r) && Be(l, q.get(r))))
1983
+ if (u && (He(l, r) || K.has(r) && He(l, K.get(r))))
1965
1984
  return !0;
1966
- s(i), ye(r) && (r = Ws(r) || r);
1967
- const d = !P.has(r) && Js(r) ? ht(r) : r;
1968
- return e(i, d), Reflect.set(o, i, d, a), n(["set", [i], r, l]), !0;
1969
- }
1970
- }), P = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakSet(), Oe = /* @__PURE__ */ new WeakMap(), Q = [1], q = /* @__PURE__ */ new WeakMap();
1971
- let Be = Object.is, Xs = (t, e) => new Proxy(t, e), Js = Ys, Zs = ft, Qs = Gs;
1972
- function ht(t = {}) {
1973
- if (!ye(t))
1985
+ s(i), Se(r) && (r = Js(r) || r);
1986
+ const f = !N.has(r) && sn(r) ? Tt(r) : r;
1987
+ return e(i, f), Reflect.set(o, i, f, a), n(["set", [i], r, l]), !0;
1988
+ }
1989
+ }), N = /* @__PURE__ */ new WeakMap(), we = /* @__PURE__ */ new WeakSet(), Fe = /* @__PURE__ */ new WeakMap(), ne = [1], K = /* @__PURE__ */ new WeakMap();
1990
+ let He = Object.is, tn = (t, e) => new Proxy(t, e), sn = Qs, nn = yt, on = en;
1991
+ function Tt(t = {}) {
1992
+ if (!Se(t))
1974
1993
  throw new Error("object required");
1975
- const e = q.get(t);
1994
+ const e = K.get(t);
1976
1995
  if (e)
1977
1996
  return e;
1978
- let s = Q[0];
1979
- const n = /* @__PURE__ */ new Set(), o = (f, b = ++Q[0]) => {
1980
- s !== b && (i = s = b, n.forEach((h) => h(f, b)));
1997
+ let s = ne[0];
1998
+ const n = /* @__PURE__ */ new Set(), o = (g, T = ++ne[0]) => {
1999
+ s !== T && (i = s = T, n.forEach((m) => m(g, T)));
1981
2000
  };
1982
2001
  let i = s;
1983
- const r = (f = Q[0]) => (i !== f && (i = f, u.forEach(([b]) => {
1984
- const h = b[1](f);
1985
- h > s && (s = h);
1986
- })), s), a = (f) => (b, h) => {
1987
- const C = [...b];
1988
- C[1] = [f, ...C[1]], o(C, h);
1989
- }, u = /* @__PURE__ */ new Map(), l = (f, b) => {
1990
- const h = !Te.has(b) && P.get(b);
1991
- if (h) {
1992
- if ((j ? "production" : void 0) !== "production" && u.has(f))
2002
+ const r = (g = ne[0]) => (i !== g && (i = g, u.forEach(([T]) => {
2003
+ const m = T[1](g);
2004
+ m > s && (s = m);
2005
+ })), s), a = (g) => (T, m) => {
2006
+ const A = [...T];
2007
+ A[1] = [g, ...A[1]], o(A, m);
2008
+ }, u = /* @__PURE__ */ new Map(), l = (g, T) => {
2009
+ const m = !we.has(T) && N.get(T);
2010
+ if (m) {
2011
+ if ((q ? "production" : void 0) !== "production" && u.has(g))
1993
2012
  throw new Error("prop listener already exists");
1994
2013
  if (n.size) {
1995
- const C = h[2](a(f));
1996
- u.set(f, [h, C]);
2014
+ const A = m[2](a(g));
2015
+ u.set(g, [m, A]);
1997
2016
  } else
1998
- u.set(f, [h]);
2017
+ u.set(g, [m]);
1999
2018
  }
2000
- }, d = (f) => {
2001
- var b;
2002
- const h = u.get(f);
2003
- h && (u.delete(f), (b = h[1]) == null || b.call(h));
2004
- }, E = (f) => (n.add(f), n.size === 1 && u.forEach(([h, C], v) => {
2005
- if ((j ? "production" : void 0) !== "production" && C)
2019
+ }, f = (g) => {
2020
+ var T;
2021
+ const m = u.get(g);
2022
+ m && (u.delete(g), (T = m[1]) == null || T.call(m));
2023
+ }, E = (g) => (n.add(g), n.size === 1 && u.forEach(([m, A], C) => {
2024
+ if ((q ? "production" : void 0) !== "production" && A)
2006
2025
  throw new Error("remove already exists");
2007
- const gt = h[2](a(v));
2008
- u.set(v, [h, gt]);
2026
+ const D = m[2](a(C));
2027
+ u.set(C, [m, D]);
2009
2028
  }), () => {
2010
- n.delete(f), n.size === 0 && u.forEach(([h, C], v) => {
2011
- C && (C(), u.set(v, [h]));
2029
+ n.delete(g), n.size === 0 && u.forEach(([m, A], C) => {
2030
+ A && (A(), u.set(C, [m]));
2012
2031
  });
2013
2032
  });
2014
- let m = !0;
2015
- const y = Qs(
2016
- () => m,
2033
+ let h = !0;
2034
+ const y = on(
2035
+ () => h,
2017
2036
  l,
2018
- d,
2037
+ f,
2019
2038
  o
2020
- ), R = Xs(t, y);
2021
- q.set(t, R);
2022
- const W = [t, r, E];
2023
- return P.set(R, W), Reflect.ownKeys(t).forEach((f) => {
2024
- const b = Object.getOwnPropertyDescriptor(
2039
+ ), R = tn(t, y);
2040
+ K.set(t, R);
2041
+ const V = [t, r, E];
2042
+ return N.set(R, V), Reflect.ownKeys(t).forEach((g) => {
2043
+ const T = Object.getOwnPropertyDescriptor(
2025
2044
  t,
2026
- f
2045
+ g
2027
2046
  );
2028
- "value" in b && b.writable && (R[f] = t[f]);
2029
- }), m = !1, R;
2047
+ "value" in T && T.writable && (R[g] = t[g]);
2048
+ }), h = !1, R;
2030
2049
  }
2031
- function en(t, e, s) {
2032
- const n = P.get(t);
2033
- (j ? "production" : void 0) !== "production" && !n && console.warn("Please use proxy object");
2050
+ function rn(t, e, s) {
2051
+ const n = N.get(t);
2052
+ (q ? "production" : void 0) !== "production" && !n && console.warn("Please use proxy object");
2034
2053
  let o;
2035
2054
  const i = [], r = n[2];
2036
2055
  let a = !1;
2037
- const l = r((d) => {
2038
- i.push(d), o || (o = Promise.resolve().then(() => {
2056
+ const l = r((f) => {
2057
+ i.push(f), o || (o = Promise.resolve().then(() => {
2039
2058
  o = void 0, a && e(i.splice(0));
2040
2059
  }));
2041
2060
  });
@@ -2043,36 +2062,36 @@ function en(t, e, s) {
2043
2062
  a = !1, l();
2044
2063
  };
2045
2064
  }
2046
- function Me(t) {
2047
- const e = P.get(t);
2048
- (j ? "production" : void 0) !== "production" && !e && console.warn("Please use proxy object");
2065
+ function $e(t) {
2066
+ const e = N.get(t);
2067
+ (q ? "production" : void 0) !== "production" && !e && console.warn("Please use proxy object");
2049
2068
  const [s, n] = e;
2050
- return Zs(s, n());
2069
+ return nn(s, n());
2051
2070
  }
2052
- const tn = {}, sn = (t, e) => {
2053
- const s = ie(void 0);
2071
+ const an = {}, cn = (t, e) => {
2072
+ const s = le(void 0);
2054
2073
  x(() => {
2055
- s.current = Vs(t, e);
2056
- }), Tt(s.current);
2057
- }, nn = sn, on = /* @__PURE__ */ new WeakMap();
2058
- function rn(t, e) {
2059
- const n = be(
2074
+ s.current = Zs(t, e);
2075
+ }), wt(s.current);
2076
+ }, un = cn, ln = /* @__PURE__ */ new WeakMap();
2077
+ function dn(t, e) {
2078
+ const n = Ce(
2060
2079
  () => t && /* @__PURE__ */ new WeakMap(),
2061
2080
  [t]
2062
- ), o = ie(void 0);
2081
+ ), o = le(void 0);
2063
2082
  let i = !0;
2064
- const r = mt(
2065
- pt(
2083
+ const r = bt(
2084
+ Et(
2066
2085
  (u) => {
2067
- const l = en(t, u);
2086
+ const l = rn(t, u);
2068
2087
  return u(), l;
2069
2088
  },
2070
2089
  [t, void 0]
2071
2090
  ),
2072
2091
  () => {
2073
- const u = Me(t);
2092
+ const u = $e(t);
2074
2093
  try {
2075
- if (!i && o.current && !dt(
2094
+ if (!i && o.current && !pt(
2076
2095
  o.current,
2077
2096
  u,
2078
2097
  n,
@@ -2083,26 +2102,26 @@ function rn(t, e) {
2083
2102
  }
2084
2103
  return u;
2085
2104
  },
2086
- () => Me(t)
2105
+ () => $e(t)
2087
2106
  );
2088
- i = !1, yt(() => {
2107
+ i = !1, St(() => {
2089
2108
  o.current = r;
2090
- }), (tn ? "production" : void 0) !== "production" && nn(r, n);
2091
- const a = be(() => /* @__PURE__ */ new WeakMap(), []);
2092
- return lt(r, n, a, on);
2109
+ }), (an ? "production" : void 0) !== "production" && un(r, n);
2110
+ const a = Ce(() => /* @__PURE__ */ new WeakMap(), []);
2111
+ return gt(r, n, a, ln);
2093
2112
  }
2094
- const D = ht({
2113
+ const v = Tt({
2095
2114
  data: null,
2096
2115
  isPending: !1,
2097
2116
  error: null
2098
2117
  });
2099
- function fn({
2118
+ function yn({
2100
2119
  session_url: t,
2101
2120
  onCancel: e,
2102
2121
  onSuccess: s
2103
2122
  }) {
2104
- const n = rn(D), [o, i] = I(!1), [r, a] = I(Date.now()), u = n?.data?.sessionToken, l = n?.data?.amount;
2105
- function d() {
2123
+ const n = dn(v), [o, i] = k(!1), [r, a] = k(Date.now()), u = n?.data?.sessionToken, l = n?.data?.amount;
2124
+ function f() {
2106
2125
  u || window.setTimeout(() => {
2107
2126
  u && i(!0);
2108
2127
  }, 200), i(!0);
@@ -2110,42 +2129,42 @@ function fn({
2110
2129
  function E() {
2111
2130
  i(!1);
2112
2131
  }
2113
- const m = () => {
2132
+ const h = () => {
2114
2133
  const y = Date.now();
2115
- D.isPending = !0, D.error = null, D.data = null, fetch(t, {
2134
+ v.isPending = !0, v.error = null, v.data = null, fetch(t, {
2116
2135
  headers: {
2117
2136
  "Content-Type": "application/json"
2118
2137
  }
2119
2138
  }).then((R) => R.json()).then((R) => {
2120
- y < r || (D.data = R, D.isPending = !1, a(y));
2139
+ y < r || (v.data = R, v.isPending = !1, a(y));
2121
2140
  }).catch((R) => {
2122
- y < r || (D.error = R?.toString(), D.isPending = !1, a(y), setInterval(m, 5e3));
2141
+ y < r || (v.error = R?.toString(), v.isPending = !1, a(y), setInterval(h, 5e3));
2123
2142
  });
2124
2143
  };
2125
2144
  return x(() => {
2126
- m();
2145
+ h();
2127
2146
  }, [t]), {
2128
2147
  sessionToken: u,
2129
2148
  amount: l,
2130
2149
  isOpen: o,
2131
2150
  session_url: t,
2132
- open: d,
2151
+ open: f,
2133
2152
  close: E,
2134
2153
  isPending: n.isPending,
2135
2154
  error: n.error,
2136
- refetch: m,
2155
+ refetch: h,
2137
2156
  onSuccess: s,
2138
2157
  onCancel: e
2139
2158
  };
2140
2159
  }
2141
- function hn({
2160
+ function Tn({
2142
2161
  sessionToken: t,
2143
2162
  amount: e,
2144
2163
  onCancel: s,
2145
2164
  onSuccess: n
2146
2165
  }) {
2147
- const [o, i] = I(!1), [r, a] = I(t), [u, l] = I(e);
2148
- function d({
2166
+ const [o, i] = k(!1), [r, a] = k(t), [u, l] = k(e);
2167
+ function f({
2149
2168
  sessionToken: y,
2150
2169
  amount: R
2151
2170
  }) {
@@ -2159,26 +2178,26 @@ function hn({
2159
2178
  r && i(!0);
2160
2179
  }, 200), i(!0);
2161
2180
  }
2162
- function m() {
2181
+ function h() {
2163
2182
  i(!1);
2164
2183
  }
2165
2184
  return {
2166
2185
  sessionToken: r,
2167
- updateSession: d,
2186
+ updateSession: f,
2168
2187
  amount: u,
2169
2188
  isOpen: o,
2170
2189
  open: E,
2171
- close: m,
2190
+ close: h,
2172
2191
  onSuccess: n,
2173
2192
  onCancel: s
2174
2193
  };
2175
2194
  }
2176
2195
  export {
2177
2196
  c as AmountSymbols,
2178
- g as Chainrails,
2179
- un as Chains,
2180
- dn as PaymentModal,
2181
- ln as crapi,
2182
- hn as usePaymentModal,
2183
- fn as usePaymentSession
2197
+ d as Chainrails,
2198
+ mn as Chains,
2199
+ pn as PaymentModal,
2200
+ gn as crapi,
2201
+ Tn as usePaymentModal,
2202
+ yn as usePaymentSession
2184
2203
  };