@chainrails/react 0.0.35 → 0.0.37

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,56 +1,56 @@
1
- import { useState as le, useRef as W, useEffect as F, useMemo as te, useSyncExternalStore as ke, useCallback as Ne, useLayoutEffect as qe, useDebugValue as _e } from "react";
2
- import { jsx as S, Fragment as Ue, jsxs as se } from "react/jsx-runtime";
3
- import './index.css';class D extends Error {
1
+ import { useState as Ne, useRef as se, useEffect as ne, useMemo as me, useSyncExternalStore as Tt, useCallback as At, useLayoutEffect as vt, useDebugValue as Pt } from "react";
2
+ import { jsx as U, Fragment as It, jsxs as ye } from "react/jsx-runtime";
3
+ import './index.css';class X extends Error {
4
4
  response;
5
5
  request;
6
6
  options;
7
- constructor(e, s, r) {
8
- const n = e.status || e.status === 0 ? e.status : "", i = e.statusText ?? "", o = `${n} ${i}`.trim(), a = o ? `status code ${o}` : "an unknown error";
9
- super(`Request failed with ${a}: ${s.method} ${s.url}`), this.name = "HTTPError", this.response = e, this.request = s, this.options = r;
7
+ constructor(t, s, n) {
8
+ const r = t.status || t.status === 0 ? t.status : "", i = t.statusText ?? "", o = `${r} ${i}`.trim(), a = o ? `status code ${o}` : "an unknown error";
9
+ super(`Request failed with ${a}: ${s.method} ${s.url}`), this.name = "HTTPError", this.response = t, this.request = s, this.options = n;
10
10
  }
11
11
  }
12
- class fe extends Error {
12
+ class Me extends Error {
13
13
  name = "NonError";
14
14
  value;
15
- constructor(e) {
15
+ constructor(t) {
16
16
  let s = "Non-error value was thrown";
17
17
  try {
18
- typeof e == "string" ? s = e : e && typeof e == "object" && "message" in e && typeof e.message == "string" && (s = e.message);
18
+ typeof t == "string" ? s = t : t && typeof t == "object" && "message" in t && typeof t.message == "string" && (s = t.message);
19
19
  } catch {
20
20
  }
21
- super(s), this.value = e;
21
+ super(s), this.value = t;
22
22
  }
23
23
  }
24
- class M extends Error {
24
+ class F extends Error {
25
25
  name = "ForceRetryError";
26
26
  customDelay;
27
27
  code;
28
28
  customRequest;
29
- constructor(e) {
30
- const s = e?.cause ? e.cause instanceof Error ? e.cause : new fe(e.cause) : void 0;
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;
29
+ constructor(t) {
30
+ const s = t?.cause ? t.cause instanceof Error ? t.cause : new Me(t.cause) : void 0;
31
+ super(t?.code ? `Forced retry: ${t.code}` : "Forced retry", s ? { cause: s } : void 0), this.customDelay = t?.delay, this.code = t?.code, this.customRequest = t?.request;
32
32
  }
33
33
  }
34
- const re = (() => {
35
- let t = !1, e = !1;
36
- const s = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
37
- if (s && r)
34
+ const we = (() => {
35
+ let e = !1, t = !1;
36
+ const s = typeof globalThis.ReadableStream == "function", n = typeof globalThis.Request == "function";
37
+ if (s && n)
38
38
  try {
39
- e = new globalThis.Request("https://empty.invalid", {
39
+ t = new globalThis.Request("https://empty.invalid", {
40
40
  body: new globalThis.ReadableStream(),
41
41
  method: "POST",
42
42
  // @ts-expect-error - Types are outdated.
43
43
  get duplex() {
44
- return t = !0, "half";
44
+ return e = !0, "half";
45
45
  }
46
46
  }).headers.has("Content-Type");
47
- } catch (n) {
48
- if (n instanceof Error && n.message === "unsupported BodyInit type")
47
+ } catch (r) {
48
+ if (r instanceof Error && r.message === "unsupported BodyInit type")
49
49
  return !1;
50
- throw n;
50
+ throw r;
51
51
  }
52
- return t && !e;
53
- })(), je = typeof globalThis.AbortController == "function", he = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", Me = typeof globalThis.ReadableStream == "function", xe = typeof globalThis.FormData == "function", de = ["get", "post", "put", "patch", "head", "delete"], Le = {
52
+ return e && !t;
53
+ })(), Ut = typeof globalThis.AbortController == "function", Be = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", Ct = typeof globalThis.ReadableStream == "function", xt = typeof globalThis.FormData == "function", _e = ["get", "post", "put", "patch", "head", "delete"], kt = {
54
54
  json: "application/json",
55
55
  text: "text/*",
56
56
  formData: "multipart/form-data",
@@ -59,14 +59,14 @@ const re = (() => {
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
- }, x = 2147483647, De = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, pe = Symbol("stop");
63
- class ye {
62
+ }, H = 2147483647, Ot = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, $e = Symbol("stop");
63
+ class Le {
64
64
  options;
65
- constructor(e) {
66
- this.options = e;
65
+ constructor(t) {
66
+ this.options = t;
67
67
  }
68
68
  }
69
- const Ie = (t) => new ye(t), Be = {
69
+ const Dt = (e) => new Le(e), Nt = {
70
70
  json: !0,
71
71
  parseJson: !0,
72
72
  stringifyJson: !0,
@@ -80,10 +80,10 @@ const Ie = (t) => new ye(t), Be = {
80
80
  onUploadProgress: !0,
81
81
  fetch: !0,
82
82
  context: !0
83
- }, He = {
83
+ }, Mt = {
84
84
  next: !0
85
85
  // Next.js cache revalidation (revalidate, tags)
86
- }, Ke = {
86
+ }, Bt = {
87
87
  method: !0,
88
88
  headers: !0,
89
89
  body: !0,
@@ -98,243 +98,243 @@ const Ie = (t) => new ye(t), Be = {
98
98
  signal: !0,
99
99
  window: !0,
100
100
  duplex: !0
101
- }, $e = (t) => {
102
- if (!t)
101
+ }, _t = (e) => {
102
+ if (!e)
103
103
  return 0;
104
- if (t instanceof FormData) {
105
- let e = 0;
106
- for (const [s, r] of t)
107
- e += De, e += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, e += typeof r == "string" ? new TextEncoder().encode(r).length : r.size;
108
- return e;
104
+ if (e instanceof FormData) {
105
+ let t = 0;
106
+ for (const [s, n] of e)
107
+ t += Ot, t += new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length, t += typeof n == "string" ? new TextEncoder().encode(n).length : n.size;
108
+ return t;
109
109
  }
110
- if (t instanceof Blob)
111
- return t.size;
112
- if (t instanceof ArrayBuffer)
113
- return t.byteLength;
114
- if (typeof t == "string")
115
- return new TextEncoder().encode(t).length;
116
- if (t instanceof URLSearchParams)
117
- return new TextEncoder().encode(t.toString()).length;
118
- if ("byteLength" in t)
119
- return t.byteLength;
120
- if (typeof t == "object" && t !== null)
110
+ if (e instanceof Blob)
111
+ return e.size;
112
+ if (e instanceof ArrayBuffer)
113
+ return e.byteLength;
114
+ if (typeof e == "string")
115
+ return new TextEncoder().encode(e).length;
116
+ if (e instanceof URLSearchParams)
117
+ return new TextEncoder().encode(e.toString()).length;
118
+ if ("byteLength" in e)
119
+ return e.byteLength;
120
+ if (typeof e == "object" && e !== null)
121
121
  try {
122
- const e = JSON.stringify(t);
123
- return new TextEncoder().encode(e).length;
122
+ const t = JSON.stringify(e);
123
+ return new TextEncoder().encode(t).length;
124
124
  } catch {
125
125
  return 0;
126
126
  }
127
127
  return 0;
128
- }, ge = (t, e, s) => {
129
- let r, n = 0;
130
- return t.pipeThrough(new TransformStream({
128
+ }, ze = (e, t, s) => {
129
+ let n, r = 0;
130
+ return e.pipeThrough(new TransformStream({
131
131
  transform(i, o) {
132
- if (o.enqueue(i), r) {
133
- n += r.byteLength;
134
- let a = e === 0 ? 0 : n / e;
135
- a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(e, n), transferredBytes: n }, r);
132
+ if (o.enqueue(i), n) {
133
+ r += n.byteLength;
134
+ let a = t === 0 ? 0 : r / t;
135
+ a >= 1 && (a = 1 - Number.EPSILON), s?.({ percent: a, totalBytes: Math.max(t, r), transferredBytes: r }, n);
136
136
  }
137
- r = i;
137
+ n = i;
138
138
  },
139
139
  flush() {
140
- r && (n += r.byteLength, s?.({ percent: 1, totalBytes: Math.max(e, n), transferredBytes: n }, r));
140
+ n && (r += n.byteLength, s?.({ percent: 1, totalBytes: Math.max(t, r), transferredBytes: r }, n));
141
141
  }
142
142
  }));
143
- }, We = (t, e) => {
144
- if (!t.body)
145
- return t;
146
- if (t.status === 204)
143
+ }, $t = (e, t) => {
144
+ if (!e.body)
145
+ return e;
146
+ if (e.status === 204)
147
147
  return new Response(null, {
148
- status: t.status,
149
- statusText: t.statusText,
150
- headers: t.headers
148
+ status: e.status,
149
+ statusText: e.statusText,
150
+ headers: e.headers
151
151
  });
152
- const s = Math.max(0, Number(t.headers.get("content-length")) || 0);
153
- return new Response(ge(t.body, s, e), {
154
- status: t.status,
155
- statusText: t.statusText,
156
- headers: t.headers
152
+ const s = Math.max(0, Number(e.headers.get("content-length")) || 0);
153
+ return new Response(ze(e.body, s, t), {
154
+ status: e.status,
155
+ statusText: e.statusText,
156
+ headers: e.headers
157
157
  });
158
- }, Fe = (t, e, s) => {
159
- if (!t.body)
160
- return t;
161
- const r = $e(s ?? t.body);
162
- return new Request(t, {
158
+ }, Lt = (e, t, s) => {
159
+ if (!e.body)
160
+ return e;
161
+ const n = _t(s ?? e.body);
162
+ return new Request(e, {
163
163
  // @ts-expect-error - Types are outdated.
164
164
  duplex: "half",
165
- body: ge(t.body, r, e)
165
+ body: ze(e.body, n, t)
166
166
  });
167
- }, E = (t) => t !== null && typeof t == "object", k = (...t) => {
168
- for (const e of t)
169
- if ((!E(e) || Array.isArray(e)) && e !== void 0)
167
+ }, P = (e) => e !== null && typeof e == "object", N = (...e) => {
168
+ for (const t of e)
169
+ if ((!P(t) || Array.isArray(t)) && t !== void 0)
170
170
  throw new TypeError("The `options` argument must be an object");
171
- return Y({}, ...t);
172
- }, me = (t = {}, e = {}) => {
173
- const s = new globalThis.Headers(t), r = e instanceof globalThis.Headers, n = new globalThis.Headers(e);
174
- for (const [i, o] of n.entries())
175
- r && o === "undefined" || o === void 0 ? s.delete(i) : s.set(i, o);
171
+ return re({}, ...e);
172
+ }, qe = (e = {}, t = {}) => {
173
+ const s = new globalThis.Headers(e), n = t instanceof globalThis.Headers, r = new globalThis.Headers(t);
174
+ for (const [i, o] of r.entries())
175
+ n && o === "undefined" || o === void 0 ? s.delete(i) : s.set(i, o);
176
176
  return s;
177
177
  };
178
- function N(t, e, s) {
179
- return Object.hasOwn(e, s) && e[s] === void 0 ? [] : Y(t[s] ?? [], e[s] ?? []);
180
- }
181
- const we = (t = {}, e = {}) => ({
182
- beforeRequest: N(t, e, "beforeRequest"),
183
- beforeRetry: N(t, e, "beforeRetry"),
184
- afterResponse: N(t, e, "afterResponse"),
185
- beforeError: N(t, e, "beforeError")
186
- }), Ye = (t, e) => {
178
+ function M(e, t, s) {
179
+ return Object.hasOwn(t, s) && t[s] === void 0 ? [] : re(e[s] ?? [], t[s] ?? []);
180
+ }
181
+ const je = (e = {}, t = {}) => ({
182
+ beforeRequest: M(e, t, "beforeRequest"),
183
+ beforeRetry: M(e, t, "beforeRetry"),
184
+ afterResponse: M(e, t, "afterResponse"),
185
+ beforeError: M(e, t, "beforeError")
186
+ }), zt = (e, t) => {
187
187
  const s = new URLSearchParams();
188
- for (const r of [t, e])
189
- if (r !== void 0)
190
- if (r instanceof URLSearchParams)
191
- for (const [n, i] of r.entries())
192
- s.append(n, i);
193
- else if (Array.isArray(r))
194
- for (const n of r) {
195
- if (!Array.isArray(n) || n.length !== 2)
188
+ for (const n of [e, t])
189
+ if (n !== void 0)
190
+ if (n instanceof URLSearchParams)
191
+ for (const [r, i] of n.entries())
192
+ s.append(r, i);
193
+ else if (Array.isArray(n))
194
+ for (const r of n) {
195
+ if (!Array.isArray(r) || r.length !== 2)
196
196
  throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
197
- s.append(String(n[0]), String(n[1]));
197
+ s.append(String(r[0]), String(r[1]));
198
198
  }
199
- else if (E(r))
200
- for (const [n, i] of Object.entries(r))
201
- i !== void 0 && s.append(n, String(i));
199
+ else if (P(n))
200
+ for (const [r, i] of Object.entries(n))
201
+ i !== void 0 && s.append(r, String(i));
202
202
  else {
203
- const n = new URLSearchParams(r);
204
- for (const [i, o] of n.entries())
203
+ const r = new URLSearchParams(n);
204
+ for (const [i, o] of r.entries())
205
205
  s.append(i, o);
206
206
  }
207
207
  return s;
208
- }, Y = (...t) => {
209
- let e = {}, s = {}, r = {}, n;
208
+ }, re = (...e) => {
209
+ let t = {}, s = {}, n = {}, r;
210
210
  const i = [];
211
- for (const o of t)
211
+ for (const o of e)
212
212
  if (Array.isArray(o))
213
- Array.isArray(e) || (e = []), e = [...e, ...o];
214
- else if (E(o)) {
213
+ Array.isArray(t) || (t = []), t = [...t, ...o];
214
+ else if (P(o)) {
215
215
  for (let [a, c] of Object.entries(o)) {
216
216
  if (a === "signal" && c instanceof globalThis.AbortSignal) {
217
217
  i.push(c);
218
218
  continue;
219
219
  }
220
220
  if (a === "context") {
221
- if (c != null && (!E(c) || Array.isArray(c)))
221
+ if (c != null && (!P(c) || Array.isArray(c)))
222
222
  throw new TypeError("The `context` option must be an object");
223
- e = {
224
- ...e,
225
- context: c == null ? {} : { ...e.context, ...c }
223
+ t = {
224
+ ...t,
225
+ context: c == null ? {} : { ...t.context, ...c }
226
226
  };
227
227
  continue;
228
228
  }
229
229
  if (a === "searchParams") {
230
- c == null ? n = void 0 : n = n === void 0 ? c : Ye(n, c);
230
+ c == null ? r = void 0 : r = r === void 0 ? c : zt(r, c);
231
231
  continue;
232
232
  }
233
- E(c) && a in e && (c = Y(e[a], c)), e = { ...e, [a]: c };
233
+ P(c) && a in t && (c = re(t[a], c)), t = { ...t, [a]: c };
234
234
  }
235
- E(o.hooks) && (r = we(r, o.hooks), e.hooks = r), E(o.headers) && (s = me(s, o.headers), e.headers = s);
235
+ P(o.hooks) && (n = je(n, o.hooks), t.hooks = n), P(o.headers) && (s = qe(s, o.headers), t.headers = s);
236
236
  }
237
- return n !== void 0 && (e.searchParams = n), i.length > 0 && (i.length === 1 ? e.signal = i[0] : he ? e.signal = AbortSignal.any(i) : e.signal = i.at(-1)), e.context === void 0 && (e.context = {}), e;
238
- }, ze = (t) => de.includes(t) ? t.toUpperCase() : t, Ve = ["get", "put", "head", "delete", "options", "trace"], Je = [408, 413, 429, 500, 502, 503, 504], Ge = [413, 429, 503], ne = {
237
+ return r !== void 0 && (t.searchParams = r), i.length > 0 && (i.length === 1 ? t.signal = i[0] : Be ? t.signal = AbortSignal.any(i) : t.signal = i.at(-1)), t.context === void 0 && (t.context = {}), t;
238
+ }, qt = (e) => _e.includes(e) ? e.toUpperCase() : e, jt = ["get", "put", "head", "delete", "options", "trace"], Ft = [408, 413, 429, 500, 502, 503, 504], Ht = [413, 429, 503], be = {
239
239
  limit: 2,
240
- methods: Ve,
241
- statusCodes: Je,
242
- afterStatusCodes: Ge,
240
+ methods: jt,
241
+ statusCodes: Ft,
242
+ afterStatusCodes: Ht,
243
243
  maxRetryAfter: Number.POSITIVE_INFINITY,
244
244
  backoffLimit: Number.POSITIVE_INFINITY,
245
- delay: (t) => 0.3 * 2 ** (t - 1) * 1e3,
245
+ delay: (e) => 0.3 * 2 ** (e - 1) * 1e3,
246
246
  jitter: void 0,
247
247
  retryOnTimeout: !1
248
- }, Xe = (t = {}) => {
249
- if (typeof t == "number")
248
+ }, Kt = (e = {}) => {
249
+ if (typeof e == "number")
250
250
  return {
251
- ...ne,
252
- limit: t
251
+ ...be,
252
+ limit: e
253
253
  };
254
- if (t.methods && !Array.isArray(t.methods))
254
+ if (e.methods && !Array.isArray(e.methods))
255
255
  throw new Error("retry.methods must be an array");
256
- if (t.statusCodes && !Array.isArray(t.statusCodes))
256
+ if (e.statusCodes && !Array.isArray(e.statusCodes))
257
257
  throw new Error("retry.statusCodes must be an array");
258
258
  return {
259
- ...ne,
260
- ...t
259
+ ...be,
260
+ ...e
261
261
  };
262
262
  };
263
- class I extends Error {
263
+ class J extends Error {
264
264
  request;
265
- constructor(e) {
266
- super(`Request timed out: ${e.method} ${e.url}`), this.name = "TimeoutError", this.request = e;
265
+ constructor(t) {
266
+ super(`Request timed out: ${t.method} ${t.url}`), this.name = "TimeoutError", this.request = t;
267
267
  }
268
268
  }
269
- async function Ze(t, e, s, r) {
270
- return new Promise((n, i) => {
269
+ async function Wt(e, t, s, n) {
270
+ return new Promise((r, i) => {
271
271
  const o = setTimeout(() => {
272
- s && s.abort(), i(new I(t));
273
- }, r.timeout);
274
- r.fetch(t, e).then(n).catch(i).then(() => {
272
+ s && s.abort(), i(new J(e));
273
+ }, n.timeout);
274
+ n.fetch(e, t).then(r).catch(i).then(() => {
275
275
  clearTimeout(o);
276
276
  });
277
277
  });
278
278
  }
279
- async function Qe(t, { signal: e }) {
280
- return new Promise((s, r) => {
281
- e && (e.throwIfAborted(), e.addEventListener("abort", n, { once: !0 }));
282
- function n() {
283
- clearTimeout(i), r(e.reason);
279
+ async function Vt(e, { signal: t }) {
280
+ return new Promise((s, n) => {
281
+ t && (t.throwIfAborted(), t.addEventListener("abort", r, { once: !0 }));
282
+ function r() {
283
+ clearTimeout(i), n(t.reason);
284
284
  }
285
285
  const i = setTimeout(() => {
286
- e?.removeEventListener("abort", n), s();
287
- }, t);
286
+ t?.removeEventListener("abort", r), s();
287
+ }, e);
288
288
  });
289
289
  }
290
- const et = (t, e) => {
290
+ const Yt = (e, t) => {
291
291
  const s = {};
292
- for (const r in e)
293
- Object.hasOwn(e, r) && !(r in Ke) && !(r in Be) && (!(r in t) || r in He) && (s[r] = e[r]);
292
+ for (const n in t)
293
+ Object.hasOwn(t, n) && !(n in Bt) && !(n in Nt) && (!(n in e) || n in Mt) && (s[n] = t[n]);
294
294
  return s;
295
- }, tt = (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 st(t) {
297
- return t instanceof D || t?.name === D.name;
295
+ }, Xt = (e) => e === void 0 ? !1 : Array.isArray(e) ? e.length > 0 : e instanceof URLSearchParams ? e.size > 0 : typeof e == "object" ? Object.keys(e).length > 0 : typeof e == "string" ? e.trim().length > 0 : !!e;
296
+ function Jt(e) {
297
+ return e instanceof X || e?.name === X.name;
298
298
  }
299
- function rt(t) {
300
- return t instanceof I || t?.name === I.name;
299
+ function Gt(e) {
300
+ return e instanceof J || e?.name === J.name;
301
301
  }
302
302
  class O {
303
- static create(e, s) {
304
- const r = new O(e, s), n = async () => {
305
- if (typeof r.#e.timeout == "number" && r.#e.timeout > x)
306
- throw new RangeError(`The \`timeout\` option cannot be greater than ${x}`);
303
+ static create(t, s) {
304
+ const n = new O(t, s), r = async () => {
305
+ if (typeof n.#e.timeout == "number" && n.#e.timeout > H)
306
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${H}`);
307
307
  await Promise.resolve();
308
- let o = await r.#y();
309
- for (const a of r.#e.hooks.afterResponse) {
310
- const c = r.#l(o.clone()), u = await a(r.request, r.#a(), c, { retryCount: r.#s });
311
- if (u instanceof globalThis.Response && (o = u), u instanceof ye)
308
+ let o = await n.#g();
309
+ for (const a of n.#e.hooks.afterResponse) {
310
+ const c = n.#l(o.clone()), u = await a(n.request, n.#a(), c, { retryCount: n.#s });
311
+ if (u instanceof globalThis.Response && (o = u), u instanceof Le)
312
312
  throw await Promise.all([
313
313
  c.body?.cancel(),
314
314
  o.body?.cancel()
315
- ]), new M(u.options);
315
+ ]), new F(u.options);
316
316
  }
317
- if (r.#l(o), !o.ok && (typeof r.#e.throwHttpErrors == "function" ? r.#e.throwHttpErrors(o.status) : r.#e.throwHttpErrors)) {
318
- let a = new D(o, r.request, r.#a());
319
- for (const c of r.#e.hooks.beforeError)
320
- a = await c(a, { retryCount: r.#s });
317
+ if (n.#l(o), !o.ok && (typeof n.#e.throwHttpErrors == "function" ? n.#e.throwHttpErrors(o.status) : n.#e.throwHttpErrors)) {
318
+ let a = new X(o, n.request, n.#a());
319
+ for (const c of n.#e.hooks.beforeError)
320
+ a = await c(a, { retryCount: n.#s });
321
321
  throw a;
322
322
  }
323
- if (r.#e.onDownloadProgress) {
324
- if (typeof r.#e.onDownloadProgress != "function")
323
+ if (n.#e.onDownloadProgress) {
324
+ if (typeof n.#e.onDownloadProgress != "function")
325
325
  throw new TypeError("The `onDownloadProgress` option must be a function");
326
- if (!Me)
326
+ if (!Ct)
327
327
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
328
- return We(o.clone(), r.#e.onDownloadProgress);
328
+ return $t(o.clone(), n.#e.onDownloadProgress);
329
329
  }
330
330
  return o;
331
- }, i = r.#f(n).finally(async () => {
332
- const o = r.#o, a = [];
333
- o && !o.bodyUsed && a.push(o.body?.cancel()), r.request.bodyUsed || a.push(r.request.body?.cancel()), await Promise.all(a);
331
+ }, i = n.#f(r).finally(async () => {
332
+ const o = n.#o, a = [];
333
+ o && !o.bodyUsed && a.push(o.body?.cancel()), n.request.bodyUsed || a.push(n.request.body?.cancel()), await Promise.all(a);
334
334
  });
335
- for (const [o, a] of Object.entries(Le))
335
+ for (const [o, a] of Object.entries(kt))
336
336
  o === "bytes" && typeof globalThis.Response?.prototype?.bytes != "function" || (i[o] = async () => {
337
- r.request.headers.set("accept", r.request.headers.get("accept") || a);
337
+ n.request.headers.set("accept", n.request.headers.get("accept") || a);
338
338
  const c = await i;
339
339
  if (o === "json") {
340
340
  if (c.status === 204)
@@ -347,33 +347,33 @@ class O {
347
347
  return i;
348
348
  }
349
349
  // eslint-disable-next-line unicorn/prevent-abbreviations
350
- static #d(e) {
351
- return e && typeof e == "object" && !Array.isArray(e) && !(e instanceof URLSearchParams) ? Object.fromEntries(Object.entries(e).filter(([, s]) => s !== void 0)) : e;
350
+ static #d(t) {
351
+ return t && typeof t == "object" && !Array.isArray(t) && !(t instanceof URLSearchParams) ? Object.fromEntries(Object.entries(t).filter(([, s]) => s !== void 0)) : t;
352
352
  }
353
353
  request;
354
- #r;
354
+ #n;
355
355
  #s = 0;
356
356
  // eslint-disable-next-line @typescript-eslint/prefer-readonly -- False positive: #input is reassigned on line 202
357
357
  #t;
358
358
  #e;
359
359
  #o;
360
- #n;
360
+ #r;
361
361
  #i;
362
362
  // eslint-disable-next-line complexity
363
- constructor(e, s = {}) {
364
- if (this.#t = e, this.#e = {
363
+ constructor(t, s = {}) {
364
+ if (this.#t = t, this.#e = {
365
365
  ...s,
366
- headers: me(this.#t.headers, s.headers),
367
- hooks: we({
366
+ headers: qe(this.#t.headers, s.headers),
367
+ hooks: je({
368
368
  beforeRequest: [],
369
369
  beforeRetry: [],
370
370
  beforeError: [],
371
371
  afterResponse: []
372
372
  }, s.hooks),
373
- method: ze(s.method ?? this.#t.method ?? "GET"),
373
+ method: qt(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: Xe(s.retry),
376
+ retry: Kt(s.retry),
377
377
  throwHttpErrors: s.throwHttpErrors ?? !0,
378
378
  timeout: s.timeout ?? 1e4,
379
379
  fetch: s.fetch ?? globalThis.fetch.bind(globalThis),
@@ -385,73 +385,73 @@ class O {
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
- je && he && (this.#n = this.#e.signal ?? this.#t.signal, this.#r = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#r.signal]) : this.#r.signal), re && (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
- const r = s.headers && new globalThis.Headers(s.headers).has("content-type");
390
- if (this.#t instanceof globalThis.Request && (xe && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !r && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), tt(this.#e.searchParams)) {
388
+ Ut && Be && (this.#r = this.#e.signal ?? this.#t.signal, this.#n = new globalThis.AbortController(), this.#e.signal = this.#r ? AbortSignal.any([this.#r, this.#n.signal]) : this.#n.signal), we && (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
+ const n = s.headers && new globalThis.Headers(s.headers).has("content-type");
390
+ if (this.#t instanceof globalThis.Request && (xt && 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), Xt(this.#e.searchParams)) {
391
391
  const i = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(O.#d(this.#e.searchParams)).toString()), o = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, i);
392
392
  this.request = new globalThis.Request(o, 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 (!re)
397
+ if (!we)
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.#h(this.request, this.#e.body ?? void 0);
400
400
  }
401
401
  }
402
402
  #c() {
403
- const e = this.#e.retry.delay(this.#s);
404
- let s = e;
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);
403
+ const t = this.#e.retry.delay(this.#s);
404
+ let s = t;
405
+ return this.#e.retry.jitter === !0 ? s = Math.random() * t : typeof this.#e.retry.jitter == "function" && (s = this.#e.retry.jitter(t), (!Number.isFinite(s) || s < 0) && (s = t)), Math.min(this.#e.retry.backoffLimit, s);
406
406
  }
407
- async #p(e) {
407
+ async #p(t) {
408
408
  if (this.#s++, this.#s > this.#e.retry.limit)
409
- throw e;
410
- const s = e instanceof Error ? e : new fe(e);
411
- if (s instanceof M)
409
+ throw t;
410
+ const s = t instanceof Error ? t : new Me(t);
411
+ if (s instanceof F)
412
412
  return s.customDelay ?? this.#c();
413
413
  if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
414
- throw e;
414
+ throw t;
415
415
  if (this.#e.retry.shouldRetry !== void 0) {
416
- const r = await this.#e.retry.shouldRetry({ error: s, retryCount: this.#s });
417
- if (r === !1)
418
- throw e;
419
- if (r === !0)
416
+ const n = await this.#e.retry.shouldRetry({ error: s, retryCount: this.#s });
417
+ if (n === !1)
418
+ throw t;
419
+ if (n === !0)
420
420
  return this.#c();
421
421
  }
422
- if (rt(e) && !this.#e.retry.retryOnTimeout)
423
- throw e;
424
- if (st(e)) {
425
- if (!this.#e.retry.statusCodes.includes(e.response.status))
426
- throw e;
427
- const r = 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");
428
- if (r && this.#e.retry.afterStatusCodes.includes(e.response.status)) {
429
- let n = Number(r) * 1e3;
430
- Number.isNaN(n) ? n = Date.parse(r) - Date.now() : n >= Date.parse("2024-01-01") && (n -= Date.now());
431
- const i = this.#e.retry.maxRetryAfter ?? n;
432
- return n < i ? n : i;
422
+ if (Gt(t) && !this.#e.retry.retryOnTimeout)
423
+ throw t;
424
+ if (Jt(t)) {
425
+ if (!this.#e.retry.statusCodes.includes(t.response.status))
426
+ throw t;
427
+ const n = t.response.headers.get("Retry-After") ?? t.response.headers.get("RateLimit-Reset") ?? t.response.headers.get("X-RateLimit-Retry-After") ?? t.response.headers.get("X-RateLimit-Reset") ?? t.response.headers.get("X-Rate-Limit-Reset");
428
+ if (n && this.#e.retry.afterStatusCodes.includes(t.response.status)) {
429
+ let r = Number(n) * 1e3;
430
+ Number.isNaN(r) ? r = Date.parse(n) - Date.now() : r >= Date.parse("2024-01-01") && (r -= Date.now());
431
+ const i = this.#e.retry.maxRetryAfter ?? r;
432
+ return r < i ? r : i;
433
433
  }
434
- if (e.response.status === 413)
435
- throw e;
434
+ if (t.response.status === 413)
435
+ throw t;
436
436
  }
437
437
  return this.#c();
438
438
  }
439
- #l(e) {
440
- return this.#e.parseJson && (e.json = async () => this.#e.parseJson(await e.text())), e;
439
+ #l(t) {
440
+ return this.#e.parseJson && (t.json = async () => this.#e.parseJson(await t.text())), t;
441
441
  }
442
- async #f(e) {
442
+ async #f(t) {
443
443
  try {
444
- return await e();
444
+ return await t();
445
445
  } catch (s) {
446
- const r = Math.min(await this.#p(s), x);
446
+ const n = Math.min(await this.#p(s), H);
447
447
  if (this.#s < 1)
448
448
  throw s;
449
- if (await Qe(r, this.#n ? { signal: this.#n } : {}), s instanceof M && s.customRequest) {
450
- const n = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
451
- this.#u(n);
449
+ if (await Vt(n, this.#r ? { signal: this.#r } : {}), s instanceof F && s.customRequest) {
450
+ const r = this.#e.signal ? new globalThis.Request(s.customRequest, { signal: this.#e.signal }) : new globalThis.Request(s.customRequest);
451
+ this.#u(r);
452
452
  }
453
- for (const n of this.#e.hooks.beforeRetry) {
454
- const i = await n({
453
+ for (const r of this.#e.hooks.beforeRetry) {
454
+ const i = await r({
455
455
  request: this.request,
456
456
  options: this.#a(),
457
457
  error: s,
@@ -463,92 +463,706 @@ class O {
463
463
  }
464
464
  if (i instanceof globalThis.Response)
465
465
  return i;
466
- if (i === pe)
466
+ if (i === $e)
467
467
  return;
468
468
  }
469
- return this.#f(e);
469
+ return this.#f(t);
470
470
  }
471
471
  }
472
- async #y() {
473
- this.#r?.signal.aborted && (this.#r = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#r.signal]) : this.#r.signal, this.request = new globalThis.Request(this.request, { signal: this.#e.signal }));
472
+ async #g() {
473
+ this.#n?.signal.aborted && (this.#n = new globalThis.AbortController(), this.#e.signal = this.#r ? AbortSignal.any([this.#r, 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
- const r = await s(this.request, this.#a(), { retryCount: this.#s });
476
- if (r instanceof Response)
477
- return r;
478
- if (r instanceof globalThis.Request) {
479
- this.#u(r);
475
+ const n = await s(this.request, this.#a(), { retryCount: this.#s });
476
+ if (n instanceof Response)
477
+ return n;
478
+ if (n instanceof globalThis.Request) {
479
+ this.#u(n);
480
480
  break;
481
481
  }
482
482
  }
483
- const e = et(this.request, this.#e);
484
- return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, e) : Ze(this.#o, e, this.#r, this.#e);
483
+ const t = Yt(this.request, this.#e);
484
+ return this.#o = this.request, this.request = this.#o.clone(), this.#e.timeout === !1 ? this.#e.fetch(this.#o, t) : Wt(this.#o, t, this.#n, this.#e);
485
485
  }
486
486
  #a() {
487
487
  if (!this.#i) {
488
- const { hooks: e, ...s } = this.#e;
488
+ const { hooks: t, ...s } = this.#e;
489
489
  this.#i = Object.freeze(s);
490
490
  }
491
491
  return this.#i;
492
492
  }
493
- #u(e) {
494
- this.#i = void 0, this.request = this.#h(e);
493
+ #u(t) {
494
+ this.#i = void 0, this.request = this.#h(t);
495
495
  }
496
- #h(e, s) {
497
- return !this.#e.onUploadProgress || !e.body ? e : Fe(e, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
496
+ #h(t, s) {
497
+ return !this.#e.onUploadProgress || !t.body ? t : Lt(t, this.#e.onUploadProgress, s ?? this.#e.body ?? void 0);
498
498
  }
499
499
  }
500
500
  /*! MIT License © Sindre Sorhus */
501
- const B = (t) => {
502
- const e = (s, r) => O.create(s, k(t, r));
503
- for (const s of de)
504
- e[s] = (r, n) => O.create(r, k(t, n, { method: s }));
505
- return e.create = (s) => B(k(s)), e.extend = (s) => (typeof s == "function" && (s = s(t ?? {})), B(k(t, s))), e.stop = pe, e.retry = Ie, e;
506
- }, nt = B();
507
- var ot = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(ot || {}), it = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(it || {}), z = /* @__PURE__ */ ((t) => (t.PRODUCTION = "production", t.STAGING = "staging", t))(z || {});
508
- class d {
509
- constructor({ api_key: e, env: s }) {
510
- this.api_key = e, this.jwt = "", this.env = s ?? z.PRODUCTION;
511
- }
512
- static async config(e) {
513
- if (!d.app) {
514
- if (!e)
515
- throw new Error("Please provide an api_key");
516
- d.app = new d(e);
501
+ const G = (e) => {
502
+ const t = (s, n) => O.create(s, N(e, n));
503
+ for (const s of _e)
504
+ t[s] = (n, r) => O.create(n, N(e, r, { method: s }));
505
+ return t.create = (s) => G(N(s)), t.extend = (s) => (typeof s == "function" && (s = s(e ?? {})), G(N(e, s))), t.stop = $e, t.retry = Dt, t;
506
+ }, Zt = G();
507
+ var E = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(E || {});
508
+ const Fe = {
509
+ type: "evm",
510
+ chainId: 42161,
511
+ name: "Arbitrum",
512
+ cctpDomain: 3,
513
+ logoURI: "/images/chains/arbitrum.svg"
514
+ }, He = {
515
+ type: "evm",
516
+ chainId: 421614,
517
+ name: "Arbitrum Sepolia",
518
+ cctpDomain: 3,
519
+ logoURI: "/images/chains/arbitrum.svg"
520
+ }, Ke = {
521
+ type: "evm",
522
+ chainId: 8453,
523
+ name: "Base",
524
+ cctpDomain: 6,
525
+ logoURI: "/images/chains/base.webp"
526
+ }, We = {
527
+ type: "evm",
528
+ chainId: 84532,
529
+ name: "Base Sepolia",
530
+ cctpDomain: 6,
531
+ logoURI: "/images/chains/base.webp"
532
+ }, Ve = {
533
+ type: "evm",
534
+ chainId: 56,
535
+ name: "BNB Chain",
536
+ cctpDomain: null,
537
+ logoURI: "/images/chains/bsc.webp"
538
+ }, Ye = {
539
+ type: "evm",
540
+ chainId: 1,
541
+ name: "Ethereum",
542
+ cctpDomain: 0,
543
+ logoURI: "/images/chains/ethereum.svg"
544
+ }, Xe = {
545
+ type: "evm",
546
+ chainId: 11155111,
547
+ name: "Ethereum Sepolia",
548
+ cctpDomain: 0,
549
+ logoURI: "/images/chains/ethereum.svg"
550
+ }, Je = {
551
+ type: "evm",
552
+ chainId: 43114,
553
+ name: "Avalanche",
554
+ cctpDomain: 1,
555
+ logoURI: "/images/chains/avalanche.svg"
556
+ }, Ge = {
557
+ type: "evm",
558
+ chainId: 43113,
559
+ name: "Avalanche Fuji",
560
+ cctpDomain: 1,
561
+ logoURI: "/images/chains/avalanche.svg"
562
+ }, Ze = {
563
+ type: "starknet",
564
+ chainId: "0x534e5f4d41494e",
565
+ // SN_MAIN
566
+ name: "Starknet",
567
+ cctpDomain: null,
568
+ logoURI: "/images/chains/starknet.svg"
569
+ };
570
+ function oe(e, { strict: t = !0 } = {}) {
571
+ return !e || typeof e != "string" ? !1 : t ? /^0x[0-9a-fA-F]*$/.test(e) : e.startsWith("0x");
572
+ }
573
+ function Ee(e) {
574
+ return oe(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
575
+ }
576
+ const Qe = "2.43.4";
577
+ let K = {
578
+ getDocsUrl: ({ docsBaseUrl: e, docsPath: t = "", docsSlug: s }) => t ? `${e ?? "https://viem.sh"}${t}${s ? `#${s}` : ""}` : void 0,
579
+ version: `viem@${Qe}`
580
+ };
581
+ class A extends Error {
582
+ constructor(t, s = {}) {
583
+ const n = s.cause instanceof A ? s.cause.details : s.cause?.message ? s.cause.message : s.details, r = s.cause instanceof A && s.cause.docsPath || s.docsPath, i = K.getDocsUrl?.({ ...s, docsPath: r }), o = [
584
+ t || "An error occurred.",
585
+ "",
586
+ ...s.metaMessages ? [...s.metaMessages, ""] : [],
587
+ ...i ? [`Docs: ${i}`] : [],
588
+ ...n ? [`Details: ${n}`] : [],
589
+ ...K.version ? [`Version: ${K.version}`] : []
590
+ ].join(`
591
+ `);
592
+ super(o, s.cause ? { cause: s.cause } : void 0), Object.defineProperty(this, "details", {
593
+ enumerable: !0,
594
+ configurable: !0,
595
+ writable: !0,
596
+ value: void 0
597
+ }), Object.defineProperty(this, "docsPath", {
598
+ enumerable: !0,
599
+ configurable: !0,
600
+ writable: !0,
601
+ value: void 0
602
+ }), Object.defineProperty(this, "metaMessages", {
603
+ enumerable: !0,
604
+ configurable: !0,
605
+ writable: !0,
606
+ value: void 0
607
+ }), Object.defineProperty(this, "shortMessage", {
608
+ enumerable: !0,
609
+ configurable: !0,
610
+ writable: !0,
611
+ value: void 0
612
+ }), Object.defineProperty(this, "version", {
613
+ enumerable: !0,
614
+ configurable: !0,
615
+ writable: !0,
616
+ value: void 0
617
+ }), Object.defineProperty(this, "name", {
618
+ enumerable: !0,
619
+ configurable: !0,
620
+ writable: !0,
621
+ value: "BaseError"
622
+ }), this.details = n, this.docsPath = r, this.metaMessages = s.metaMessages, this.name = s.name ?? this.name, this.shortMessage = t, this.version = Qe;
623
+ }
624
+ walk(t) {
625
+ return et(this, t);
626
+ }
627
+ }
628
+ function et(e, t) {
629
+ return t?.(e) ? e : e && typeof e == "object" && "cause" in e && e.cause !== void 0 ? et(e.cause, t) : t ? null : e;
630
+ }
631
+ class tt extends A {
632
+ constructor({ size: t, targetSize: s, type: n }) {
633
+ super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
634
+ }
635
+ }
636
+ function q(e, { dir: t, size: s = 32 } = {}) {
637
+ return typeof e == "string" ? Qt(e, { dir: t, size: s }) : es(e, { dir: t, size: s });
638
+ }
639
+ function Qt(e, { dir: t, size: s = 32 } = {}) {
640
+ if (s === null)
641
+ return e;
642
+ const n = e.replace("0x", "");
643
+ if (n.length > s * 2)
644
+ throw new tt({
645
+ size: Math.ceil(n.length / 2),
646
+ targetSize: s,
647
+ type: "hex"
648
+ });
649
+ return `0x${n[t === "right" ? "padEnd" : "padStart"](s * 2, "0")}`;
650
+ }
651
+ function es(e, { dir: t, size: s = 32 } = {}) {
652
+ if (s === null)
653
+ return e;
654
+ if (e.length > s)
655
+ throw new tt({
656
+ size: e.length,
657
+ targetSize: s,
658
+ type: "bytes"
659
+ });
660
+ const n = new Uint8Array(s);
661
+ for (let r = 0; r < s; r++) {
662
+ const i = t === "right";
663
+ n[i ? r : s - r - 1] = e[i ? r : e.length - r - 1];
664
+ }
665
+ return n;
666
+ }
667
+ class ts extends A {
668
+ constructor({ max: t, min: s, signed: n, size: r, value: i }) {
669
+ super(`Number "${i}" is not in safe ${r ? `${r * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${t ? `(${s} to ${t})` : `(above ${s})`}`, { name: "IntegerOutOfRangeError" });
670
+ }
671
+ }
672
+ class ss extends A {
673
+ constructor({ givenSize: t, maxSize: s }) {
674
+ super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`, { name: "SizeOverflowError" });
675
+ }
676
+ }
677
+ function ie(e, { size: t }) {
678
+ if (Ee(e) > t)
679
+ throw new ss({
680
+ givenSize: Ee(e),
681
+ maxSize: t
682
+ });
683
+ }
684
+ function ns(e, t = {}) {
685
+ const { signed: s, size: n } = t, r = BigInt(e);
686
+ let i;
687
+ n ? s ? i = (1n << BigInt(n) * 8n - 1n) - 1n : i = 2n ** (BigInt(n) * 8n) - 1n : typeof e == "number" && (i = BigInt(Number.MAX_SAFE_INTEGER));
688
+ const o = typeof i == "bigint" && s ? -i - 1n : 0;
689
+ if (i && r > i || r < o) {
690
+ const c = typeof e == "bigint" ? "n" : "";
691
+ throw new ts({
692
+ max: i ? `${i}${c}` : void 0,
693
+ min: `${o}${c}`,
694
+ signed: s,
695
+ size: n,
696
+ value: `${e}${c}`
697
+ });
698
+ }
699
+ const a = `0x${(s && r < 0 ? (1n << BigInt(n * 8)) + BigInt(r) : r).toString(16)}`;
700
+ return n ? q(a, { size: n }) : a;
701
+ }
702
+ const rs = /* @__PURE__ */ new TextEncoder();
703
+ function os(e, t = {}) {
704
+ return typeof e == "number" || typeof e == "bigint" ? as(e, t) : typeof e == "boolean" ? is(e, t) : oe(e) ? st(e, t) : nt(e, t);
705
+ }
706
+ function is(e, t = {}) {
707
+ const s = new Uint8Array(1);
708
+ return s[0] = Number(e), typeof t.size == "number" ? (ie(s, { size: t.size }), q(s, { size: t.size })) : s;
709
+ }
710
+ const S = {
711
+ zero: 48,
712
+ nine: 57,
713
+ A: 65,
714
+ F: 70,
715
+ a: 97,
716
+ f: 102
717
+ };
718
+ function Se(e) {
719
+ if (e >= S.zero && e <= S.nine)
720
+ return e - S.zero;
721
+ if (e >= S.A && e <= S.F)
722
+ return e - (S.A - 10);
723
+ if (e >= S.a && e <= S.f)
724
+ return e - (S.a - 10);
725
+ }
726
+ function st(e, t = {}) {
727
+ let s = e;
728
+ t.size && (ie(s, { size: t.size }), s = q(s, { dir: "right", size: t.size }));
729
+ let n = s.slice(2);
730
+ n.length % 2 && (n = `0${n}`);
731
+ const r = n.length / 2, i = new Uint8Array(r);
732
+ for (let o = 0, a = 0; o < r; o++) {
733
+ const c = Se(n.charCodeAt(a++)), u = Se(n.charCodeAt(a++));
734
+ if (c === void 0 || u === void 0)
735
+ throw new A(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`);
736
+ i[o] = c * 16 + u;
737
+ }
738
+ return i;
739
+ }
740
+ function as(e, t) {
741
+ const s = ns(e, t);
742
+ return st(s);
743
+ }
744
+ function nt(e, t = {}) {
745
+ const s = rs.encode(e);
746
+ return typeof t.size == "number" ? (ie(s, { size: t.size }), q(s, { dir: "right", size: t.size })) : s;
747
+ }
748
+ const B = /* @__PURE__ */ BigInt(2 ** 32 - 1), Re = /* @__PURE__ */ BigInt(32);
749
+ function cs(e, t = !1) {
750
+ return t ? { h: Number(e & B), l: Number(e >> Re & B) } : { h: Number(e >> Re & B) | 0, l: Number(e & B) | 0 };
751
+ }
752
+ function us(e, t = !1) {
753
+ const s = e.length;
754
+ let n = new Uint32Array(s), r = new Uint32Array(s);
755
+ for (let i = 0; i < s; i++) {
756
+ const { h: o, l: a } = cs(e[i], t);
757
+ [n[i], r[i]] = [o, a];
758
+ }
759
+ return [n, r];
760
+ }
761
+ const ls = (e, t, s) => e << s | t >>> 32 - s, fs = (e, t, s) => t << s | e >>> 32 - s, hs = (e, t, s) => t << s - 32 | e >>> 64 - s, ds = (e, t, s) => e << s - 32 | t >>> 64 - s;
762
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
763
+ function ps(e) {
764
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
765
+ }
766
+ function Te(e) {
767
+ if (!Number.isSafeInteger(e) || e < 0)
768
+ throw new Error("positive integer expected, got " + e);
769
+ }
770
+ function _(e, ...t) {
771
+ if (!ps(e))
772
+ throw new Error("Uint8Array expected");
773
+ if (t.length > 0 && !t.includes(e.length))
774
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
775
+ }
776
+ function Ae(e, t = !0) {
777
+ if (e.destroyed)
778
+ throw new Error("Hash instance has been destroyed");
779
+ if (t && e.finished)
780
+ throw new Error("Hash#digest() has already been called");
781
+ }
782
+ function gs(e, t) {
783
+ _(e);
784
+ const s = t.outputLen;
785
+ if (e.length < s)
786
+ throw new Error("digestInto() expects output buffer of length at least " + s);
787
+ }
788
+ function ms(e) {
789
+ return new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4));
790
+ }
791
+ function rt(...e) {
792
+ for (let t = 0; t < e.length; t++)
793
+ e[t].fill(0);
794
+ }
795
+ const ys = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
796
+ function ws(e) {
797
+ return e << 24 & 4278190080 | e << 8 & 16711680 | e >>> 8 & 65280 | e >>> 24 & 255;
798
+ }
799
+ function bs(e) {
800
+ for (let t = 0; t < e.length; t++)
801
+ e[t] = ws(e[t]);
802
+ return e;
803
+ }
804
+ const ve = ys ? (e) => e : bs;
805
+ function Es(e) {
806
+ if (typeof e != "string")
807
+ throw new Error("string expected");
808
+ return new Uint8Array(new TextEncoder().encode(e));
809
+ }
810
+ function ot(e) {
811
+ return typeof e == "string" && (e = Es(e)), _(e), e;
812
+ }
813
+ class Ss {
814
+ }
815
+ function Rs(e) {
816
+ const t = (n) => e().update(ot(n)).digest(), s = e();
817
+ return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
818
+ }
819
+ const Ts = BigInt(0), C = BigInt(1), As = BigInt(2), vs = BigInt(7), Ps = BigInt(256), Is = BigInt(113), it = [], at = [], ct = [];
820
+ for (let e = 0, t = C, s = 1, n = 0; e < 24; e++) {
821
+ [s, n] = [n, (2 * s + 3 * n) % 5], it.push(2 * (5 * n + s)), at.push((e + 1) * (e + 2) / 2 % 64);
822
+ let r = Ts;
823
+ for (let i = 0; i < 7; i++)
824
+ t = (t << C ^ (t >> vs) * Is) % Ps, t & As && (r ^= C << (C << /* @__PURE__ */ BigInt(i)) - C);
825
+ ct.push(r);
826
+ }
827
+ const ut = us(ct, !0), Us = ut[0], Cs = ut[1], Pe = (e, t, s) => s > 32 ? hs(e, t, s) : ls(e, t, s), Ie = (e, t, s) => s > 32 ? ds(e, t, s) : fs(e, t, s);
828
+ function xs(e, t = 24) {
829
+ const s = new Uint32Array(10);
830
+ for (let n = 24 - t; n < 24; n++) {
831
+ for (let o = 0; o < 10; o++)
832
+ s[o] = e[o] ^ e[o + 10] ^ e[o + 20] ^ e[o + 30] ^ e[o + 40];
833
+ for (let o = 0; o < 10; o += 2) {
834
+ const a = (o + 8) % 10, c = (o + 2) % 10, u = s[c], l = s[c + 1], w = Pe(u, l, 1) ^ s[a], d = Ie(u, l, 1) ^ s[a + 1];
835
+ for (let m = 0; m < 50; m += 10)
836
+ e[o + m] ^= w, e[o + m + 1] ^= d;
837
+ }
838
+ let r = e[2], i = e[3];
839
+ for (let o = 0; o < 24; o++) {
840
+ const a = at[o], c = Pe(r, i, a), u = Ie(r, i, a), l = it[o];
841
+ r = e[l], i = e[l + 1], e[l] = c, e[l + 1] = u;
517
842
  }
518
- return e && (d.app.api_key = e.api_key, e.env !== void 0 && (d.app.env = e.env), await this.updateJWT(), setInterval(this.updateJWT.bind(this), 1500 * 1e3)), d.app;
843
+ for (let o = 0; o < 50; o += 10) {
844
+ for (let a = 0; a < 10; a++)
845
+ s[a] = e[o + a];
846
+ for (let a = 0; a < 10; a++)
847
+ e[o + a] ^= ~s[(a + 2) % 10] & s[(a + 4) % 10];
848
+ }
849
+ e[0] ^= Us[n], e[1] ^= Cs[n];
519
850
  }
520
- static async updateJWT() {
521
- try {
522
- const e = await (await fetch(this.getBaseUrl() + "/client/api-keys/session-token", {
523
- method: "POST",
524
- headers: {
525
- "content-type": "application/json"
526
- },
527
- body: JSON.stringify({
528
- apiKey: d.app.api_key
529
- })
530
- })).json();
531
- this.app.jwt = e.token;
532
- } catch {
851
+ rt(s);
852
+ }
853
+ class ae extends Ss {
854
+ // NOTE: we accept arguments in bytes instead of bits here.
855
+ constructor(t, s, n, r = !1, i = 24) {
856
+ if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = t, this.suffix = s, this.outputLen = n, this.enableXOF = r, this.rounds = i, Te(n), !(0 < t && t < 200))
857
+ throw new Error("only keccak-f1600 function is supported");
858
+ this.state = new Uint8Array(200), this.state32 = ms(this.state);
859
+ }
860
+ clone() {
861
+ return this._cloneInto();
862
+ }
863
+ keccak() {
864
+ ve(this.state32), xs(this.state32, this.rounds), ve(this.state32), this.posOut = 0, this.pos = 0;
865
+ }
866
+ update(t) {
867
+ Ae(this), t = ot(t), _(t);
868
+ const { blockLen: s, state: n } = this, r = t.length;
869
+ for (let i = 0; i < r; ) {
870
+ const o = Math.min(s - this.pos, r - i);
871
+ for (let a = 0; a < o; a++)
872
+ n[this.pos++] ^= t[i++];
873
+ this.pos === s && this.keccak();
874
+ }
875
+ return this;
876
+ }
877
+ finish() {
878
+ if (this.finished)
879
+ return;
880
+ this.finished = !0;
881
+ const { state: t, suffix: s, pos: n, blockLen: r } = this;
882
+ t[n] ^= s, (s & 128) !== 0 && n === r - 1 && this.keccak(), t[r - 1] ^= 128, this.keccak();
883
+ }
884
+ writeInto(t) {
885
+ Ae(this, !1), _(t), this.finish();
886
+ const s = this.state, { blockLen: n } = this;
887
+ for (let r = 0, i = t.length; r < i; ) {
888
+ this.posOut >= n && this.keccak();
889
+ const o = Math.min(n - this.posOut, i - r);
890
+ t.set(s.subarray(this.posOut, this.posOut + o), r), this.posOut += o, r += o;
891
+ }
892
+ return t;
893
+ }
894
+ xofInto(t) {
895
+ if (!this.enableXOF)
896
+ throw new Error("XOF is not possible for this instance");
897
+ return this.writeInto(t);
898
+ }
899
+ xof(t) {
900
+ return Te(t), this.xofInto(new Uint8Array(t));
901
+ }
902
+ digestInto(t) {
903
+ if (gs(t, this), this.finished)
904
+ throw new Error("digest() was already called");
905
+ return this.writeInto(t), this.destroy(), t;
906
+ }
907
+ digest() {
908
+ return this.digestInto(new Uint8Array(this.outputLen));
909
+ }
910
+ destroy() {
911
+ this.destroyed = !0, rt(this.state);
912
+ }
913
+ _cloneInto(t) {
914
+ const { blockLen: s, suffix: n, outputLen: r, rounds: i, enableXOF: o } = this;
915
+ return t || (t = new ae(s, n, r, o, i)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = i, t.suffix = n, t.outputLen = r, t.enableXOF = o, t.destroyed = this.destroyed, t;
916
+ }
917
+ }
918
+ const ks = (e, t, s) => Rs(() => new ae(t, e, s)), Os = ks(1, 136, 256 / 8);
919
+ function Ds(e, t) {
920
+ return Os(oe(e, { strict: !1 }) ? os(e) : e);
921
+ }
922
+ class Ns extends A {
923
+ constructor({ address: t }) {
924
+ super(`Address "${t}" is invalid.`, {
925
+ metaMessages: [
926
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
927
+ "- Address must match its checksum counterpart."
928
+ ],
929
+ name: "InvalidAddressError"
930
+ });
931
+ }
932
+ }
933
+ class lt extends Map {
934
+ constructor(t) {
935
+ super(), Object.defineProperty(this, "maxSize", {
936
+ enumerable: !0,
937
+ configurable: !0,
938
+ writable: !0,
939
+ value: void 0
940
+ }), this.maxSize = t;
941
+ }
942
+ get(t) {
943
+ const s = super.get(t);
944
+ return super.has(t) && s !== void 0 && (this.delete(t), super.set(t, s)), s;
945
+ }
946
+ set(t, s) {
947
+ if (super.set(t, s), this.maxSize && this.size > this.maxSize) {
948
+ const n = this.keys().next().value;
949
+ n && this.delete(n);
950
+ }
951
+ return this;
952
+ }
953
+ }
954
+ const W = /* @__PURE__ */ new lt(8192);
955
+ function ft(e, t) {
956
+ if (W.has(`${e}.${t}`))
957
+ return W.get(`${e}.${t}`);
958
+ const s = e.substring(2).toLowerCase(), n = Ds(nt(s)), r = s.split("");
959
+ for (let o = 0; o < 40; o += 2)
960
+ n[o >> 1] >> 4 >= 8 && r[o] && (r[o] = r[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && r[o + 1] && (r[o + 1] = r[o + 1].toUpperCase());
961
+ const i = `0x${r.join("")}`;
962
+ return W.set(`${e}.${t}`, i), i;
963
+ }
964
+ function R(e, t) {
965
+ if (!Bs(e, { strict: !1 }))
966
+ throw new Ns({ address: e });
967
+ return ft(e, t);
968
+ }
969
+ const Ms = /^0x[a-fA-F0-9]{40}$/, V = /* @__PURE__ */ new lt(8192);
970
+ function Bs(e, t) {
971
+ const { strict: s = !0 } = t ?? {}, n = `${e}.${s}`;
972
+ if (V.has(n))
973
+ return V.get(n);
974
+ const r = Ms.test(e) ? e.toLowerCase() === e ? !0 : s ? ft(e) === e : !0 : !1;
975
+ return V.set(n, r), r;
976
+ }
977
+ const _s = {
978
+ chainId: He.chainId,
979
+ address: R("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),
980
+ symbol: "USDC",
981
+ fiatISO: "USD",
982
+ decimals: 6,
983
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
984
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
985
+ }, $s = {
986
+ chainId: Fe.chainId,
987
+ address: R("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
988
+ symbol: "USDC",
989
+ name: "USD Coin",
990
+ decimals: 6,
991
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png"
992
+ /* USDC */
993
+ }, Ls = {
994
+ chainId: Ge.chainId,
995
+ address: R("0x5425890298aed601595a70ab815c96711a31bc65"),
996
+ symbol: "USDC",
997
+ fiatISO: "USD",
998
+ decimals: 6,
999
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1000
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1001
+ }, zs = {
1002
+ chainId: Je.chainId,
1003
+ address: R("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),
1004
+ symbol: "USDC",
1005
+ fiatISO: "USD",
1006
+ decimals: 6,
1007
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1008
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1009
+ }, qs = {
1010
+ chainId: We.chainId,
1011
+ address: R("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),
1012
+ symbol: "USDC",
1013
+ fiatISO: "USD",
1014
+ decimals: 6,
1015
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1016
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1017
+ }, js = {
1018
+ chainId: Ke.chainId,
1019
+ address: R("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
1020
+ symbol: "USDC",
1021
+ fiatISO: "USD",
1022
+ decimals: 6,
1023
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1024
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1025
+ }, Fs = {
1026
+ chainId: Ve.chainId,
1027
+ address: R("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
1028
+ symbol: "USDC",
1029
+ decimals: 18,
1030
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1031
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1032
+ }, Hs = {
1033
+ chainId: Xe.chainId,
1034
+ address: R("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),
1035
+ symbol: "USDC",
1036
+ decimals: 6,
1037
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1038
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1039
+ }, Ks = {
1040
+ chainId: Ye.chainId,
1041
+ address: R("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
1042
+ symbol: "USDC",
1043
+ decimals: 6,
1044
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1045
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1046
+ }, Ws = {
1047
+ chainId: Ze.chainId,
1048
+ address: "0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",
1049
+ symbol: "USDC",
1050
+ decimals: 6,
1051
+ logoURI: "https://pay.daimo.com/coin-logos/usdc.png",
1052
+ logoSourceURI: "https://pay.daimo.com/coin-logos/usdc.png"
1053
+ }, Ue = {
1054
+ ARBITRUM_MAINNET: {
1055
+ ...Fe,
1056
+ tokens: {
1057
+ [E.USDC]: $s
1058
+ },
1059
+ explorer: "https://arbiscan.io"
1060
+ },
1061
+ ARBITRUM_TESTNET: {
1062
+ ...He,
1063
+ explorer: "https://sepolia.arbiscan.io",
1064
+ tokens: {
1065
+ [E.USDC]: _s
1066
+ }
1067
+ },
1068
+ AVALANCHE_MAINNET: {
1069
+ ...Je,
1070
+ tokens: {
1071
+ [E.USDC]: zs
1072
+ },
1073
+ explorer: "https://snowtrace.io"
1074
+ },
1075
+ AVALANCHE_TESTNET: {
1076
+ ...Ge,
1077
+ tokens: {
1078
+ [E.USDC]: Ls
1079
+ },
1080
+ explorer: "https://testnet.snowtrace.io"
1081
+ },
1082
+ BASE_MAINNET: {
1083
+ ...Ke,
1084
+ tokens: {
1085
+ [E.USDC]: js
1086
+ },
1087
+ explorer: "https://basescan.org"
1088
+ },
1089
+ BASE_TESTNET: {
1090
+ ...We,
1091
+ tokens: {
1092
+ [E.USDC]: qs
1093
+ },
1094
+ explorer: "https://sepolia.basescan.org"
1095
+ },
1096
+ BSC_MAINNET: {
1097
+ ...Ve,
1098
+ tokens: {
1099
+ [E.USDC]: Fs
1100
+ },
1101
+ explorer: "https://bscscan.com"
1102
+ },
1103
+ ETHEREUM_MAINNET: {
1104
+ ...Ye,
1105
+ tokens: {
1106
+ [E.USDC]: Ks
1107
+ },
1108
+ explorer: "https://etherscan.io"
1109
+ },
1110
+ ETHEREUM_TESTNET: {
1111
+ ...Xe,
1112
+ tokens: {
1113
+ [E.USDC]: Hs
1114
+ },
1115
+ explorer: "https://sepolia.etherscan.io"
1116
+ },
1117
+ STARKNET_MAINNET: {
1118
+ ...Ze,
1119
+ tokens: {
1120
+ [E.USDC]: Ws
1121
+ },
1122
+ explorer: ""
1123
+ }
1124
+ };
1125
+ var Z = /* @__PURE__ */ ((e) => (e.ARBITRUM = "ARBITRUM_MAINNET", e.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", e.AVALANCHE = "AVALANCHE_MAINNET", e.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", e.BASE = "BASE_MAINNET", e.BASE_TESTNET = "BASE_TESTNET", e.BSC = "BSC_MAINNET", e.ETHEREUM = "ETHEREUM_MAINNET", e.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", e.STARKNET = "STARKNET_MAINNET", e))(Z || {}), ht = /* @__PURE__ */ ((e) => (e.USDC = "USDC", e))(ht || {});
1126
+ const Vs = (e) => {
1127
+ const t = e?.trim().toUpperCase();
1128
+ if (Ue[t])
1129
+ return Ue[t];
1130
+ };
1131
+ function Ys(e, t) {
1132
+ return Vs(e)?.tokens[t]?.address;
1133
+ }
1134
+ var ce = /* @__PURE__ */ ((e) => (e.PRODUCTION = "production", e.STAGING = "staging", e))(ce || {});
1135
+ class h {
1136
+ constructor({ api_key: t, env: s, seesion_token: n }) {
1137
+ this.api_key = t || "", this.sessionToken = n || "", this.env = s ?? ce.PRODUCTION;
1138
+ }
1139
+ static async config(t) {
1140
+ if (!h.app) {
1141
+ if (!t)
1142
+ throw new Error("Please provide an api_key");
1143
+ h.app = new h(t);
533
1144
  }
1145
+ return t && (t.api_key !== void 0 && (h.app.api_key = t.api_key), t.seesion_token !== void 0 && (h.app.sessionToken = t.seesion_token), t.env !== void 0 && (h.app.env = t.env)), h.app;
534
1146
  }
535
1147
  static getApiKey() {
536
- if (!d.app)
1148
+ if (!h.app)
537
1149
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
538
- return d.app.api_key;
1150
+ return h.app.api_key;
539
1151
  }
540
- static getSessionKey() {
541
- return d.app.jwt;
1152
+ static getSessionToken() {
1153
+ if (!h.app)
1154
+ throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
1155
+ return h.app.sessionToken;
542
1156
  }
543
1157
  static getEnv() {
544
- if (!d.app)
1158
+ if (!h.app)
545
1159
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
546
- return d.app.env === "internal" ? "staging" : d.app.env;
1160
+ return h.app.env === "internal" ? "staging" : h.app.env;
547
1161
  }
548
1162
  static getBaseUrl() {
549
- if (!d.app)
1163
+ if (!h.app)
550
1164
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
551
- switch (d.app.env) {
1165
+ switch (h.app.env) {
552
1166
  case "production":
553
1167
  return "https://api.chainrails.io/api/v1";
554
1168
  case "staging":
@@ -559,313 +1173,328 @@ class d {
559
1173
  return "https://api.chainrails.io/api/v1";
560
1174
  }
561
1175
  }
562
- static getPayModalUrl(e, s, r, n) {
563
- if (!d.app)
1176
+ static getPayModalUrl(t, s, n, r) {
1177
+ if (!h.app)
564
1178
  throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");
565
- const i = d.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", o = n && n > 0 ? "/pay/" : "/deposit/", a = `_chain_/${e}/_token_/${s}/_to_/${r}${n ? "/_amount_/" + n * 100 : ""}`;
1179
+ const i = h.app.env === "internal" ? "https://chainrails-frontend-git-staging-horus-labs.vercel.app" : "https://app.chainrails.io", o = r && r > 0 ? "/pay/" : "/deposit/", a = `_chain_/${t}/_token_/${s}/_to_/${n}${r ? "/_amount_/" + r * 100 : ""}`;
566
1180
  return i + o + a;
567
1181
  }
568
1182
  }
569
- let H = null;
570
- function at() {
571
- H = nt.create({
572
- prefixUrl: d.getBaseUrl(),
1183
+ let Q = null;
1184
+ function Xs() {
1185
+ Q = Zt.create({
1186
+ prefixUrl: h.getBaseUrl(),
573
1187
  headers: {
574
1188
  "Content-Type": "application/json"
575
1189
  },
576
1190
  hooks: {
577
1191
  beforeRequest: [
578
- (t) => {
579
- const e = d.getSessionKey();
580
- t.headers.set("Authorization", `Bearer ${e}`);
1192
+ (e) => {
1193
+ const t = h.getSessionToken() || h.getApiKey();
1194
+ e.headers.set("Authorization", `Bearer ${t}`);
581
1195
  }
582
1196
  ],
583
- afterResponse: [(t, e, s) => s]
1197
+ afterResponse: [(e, t, s) => s]
584
1198
  },
585
1199
  retry: {
586
1200
  limit: 2
587
1201
  }
588
1202
  });
589
1203
  }
590
- function g() {
591
- return H || at(), H;
1204
+ function y() {
1205
+ return Q || Xs(), Q;
592
1206
  }
593
- class ct {
594
- async getById(e) {
595
- return await g().get("intents/" + e).json();
1207
+ class Js {
1208
+ async getById(t) {
1209
+ return await y().get("intents/" + t).json();
596
1210
  }
597
- async getForSender(e) {
598
- return await g().get("intents/user/" + e).json();
1211
+ async getForSender(t) {
1212
+ return await y().get("intents/user/" + t).json();
599
1213
  }
600
- async getForAddress(e) {
601
- return await g().get("intents/address/" + e).json();
1214
+ async getForAddress(t) {
1215
+ return await y().get("intents/address/" + t).json();
602
1216
  }
603
- async getAll(e) {
604
- return await g().get("intents", { searchParams: e }).json();
1217
+ async getAll(t) {
1218
+ return await y().get("intents", { searchParams: t }).json();
605
1219
  }
606
- async create(e) {
607
- return await g().post("intents", { json: e }).json();
1220
+ async create(t) {
1221
+ return await y().post("intents", { json: t }).json();
608
1222
  }
609
- async update(e, s) {
610
- return await g().post("intents", { json: s }).json();
1223
+ async update(t, s) {
1224
+ return await y().post("intents", { json: s }).json();
611
1225
  }
612
- async triggerProcessing(e) {
613
- return await g().post(`intents/${e}/trigger-processing`).json();
1226
+ async triggerProcessing(t) {
1227
+ return await y().post(`intents/${t}/trigger-processing`).json();
614
1228
  }
615
1229
  }
616
- class ut {
617
- async getFromSpecificBridge(e) {
618
- return await g().get("quotes/single", { searchParams: e }).json();
1230
+ class Gs {
1231
+ async getFromSpecificBridge(t) {
1232
+ return await y().get("quotes/single", { searchParams: t }).json();
619
1233
  }
620
- async getFromAllBridges(e) {
621
- return await g().get("quotes/multiple", { searchParams: e }).json();
1234
+ async getFromAllBridges(t) {
1235
+ return await y().get("quotes/multiple", { searchParams: t }).json();
622
1236
  }
623
- async getBestAcrossBridges(e) {
624
- return await g().get("quotes/best", { searchParams: e }).json();
1237
+ async getBestAcrossBridges(t) {
1238
+ return await y().get("quotes/best", { searchParams: t }).json();
625
1239
  }
626
- async getAll(e) {
627
- return await g().get("quotes/multi-source", { searchParams: e }).json();
1240
+ async getAll(t) {
1241
+ return await y().get("quotes/multi-source", { searchParams: t }).json();
628
1242
  }
629
1243
  }
630
- class lt {
631
- async getOptimalRoutes(e) {
632
- return await g().get("router/optimal-route", { searchParams: e }).json();
1244
+ class Zs {
1245
+ async getOptimalRoutes(t) {
1246
+ return await y().get("router/optimal-route", { searchParams: t }).json();
633
1247
  }
634
1248
  async getAllSupportedBridges() {
635
- return await g().get("router/supported-bridges/all").json();
1249
+ return await y().get("router/supported-bridges/all").json();
636
1250
  }
637
- async getSupportedBridges(e) {
638
- return await g().get("router/supported-bridges/route", { searchParams: e }).json();
1251
+ async getSupportedBridges(t) {
1252
+ return await y().get("router/supported-bridges/route", { searchParams: t }).json();
639
1253
  }
640
- async getSupportedRoutes(e, s) {
641
- return await g().get("router/supported-bridges/bridge/" + e, { searchParams: s }).json();
1254
+ async getSupportedRoutes(t, s) {
1255
+ return await y().get("router/supported-bridges/bridge/" + t, { searchParams: s }).json();
642
1256
  }
643
1257
  }
644
- class ft {
645
- async getSupported(e) {
646
- return await g().get("chains", { searchParams: e }).json();
1258
+ class Qs {
1259
+ async getSupported(t) {
1260
+ return await y().get("chains", { searchParams: t }).json();
647
1261
  }
648
1262
  }
649
- class ht {
1263
+ class en {
650
1264
  async getClientInfo() {
651
- return await g().get("client/auth/client-info").json();
1265
+ return await y().get("client/auth/client-info").json();
652
1266
  }
653
1267
  }
654
- const xt = {
655
- router: new lt(),
656
- quotes: new ut(),
657
- intents: new ct(),
658
- chains: new ft(),
659
- client: new ht()
1268
+ class tn {
1269
+ getSessionToken(t) {
1270
+ const s = {
1271
+ recipient: t.recipient,
1272
+ tokenOut: Ys(
1273
+ Z[t.destinationChain],
1274
+ ht[t.token]
1275
+ ),
1276
+ destinationChain: Z[t.destinationChain],
1277
+ amount: t.amount
1278
+ };
1279
+ return y().post("modal/sessions", { json: s }).json();
1280
+ }
1281
+ }
1282
+ const Pn = {
1283
+ router: new Zs(),
1284
+ quotes: new Gs(),
1285
+ intents: new Js(),
1286
+ chains: new Qs(),
1287
+ client: new en(),
1288
+ auth: new tn()
660
1289
  };
661
- function Te(t) {
662
- var e, s, r = "";
663
- if (typeof t == "string" || typeof t == "number") r += t;
664
- else if (typeof t == "object") if (Array.isArray(t)) {
665
- var n = t.length;
666
- for (e = 0; e < n; e++) t[e] && (s = Te(t[e])) && (r && (r += " "), r += s);
667
- } else for (s in t) t[s] && (r && (r += " "), r += s);
668
- return r;
669
- }
670
- function dt() {
671
- for (var t, e, s = 0, r = "", n = arguments.length; s < n; s++) (t = arguments[s]) && (e = Te(t)) && (r && (r += " "), r += e);
672
- return r;
673
- }
674
- function Lt(t) {
1290
+ function dt(e) {
1291
+ var t, s, n = "";
1292
+ if (typeof e == "string" || typeof e == "number") n += e;
1293
+ else if (typeof e == "object") if (Array.isArray(e)) {
1294
+ var r = e.length;
1295
+ for (t = 0; t < r; t++) e[t] && (s = dt(e[t])) && (n && (n += " "), n += s);
1296
+ } else for (s in e) e[s] && (n && (n += " "), n += s);
1297
+ return n;
1298
+ }
1299
+ function sn() {
1300
+ for (var e, t, s = 0, n = "", r = arguments.length; s < r; s++) (e = arguments[s]) && (t = dt(e)) && (n && (n += " "), n += t);
1301
+ return n;
1302
+ }
1303
+ function In(e) {
675
1304
  const {
676
- to: e,
1305
+ to: t,
677
1306
  token: s,
678
- chain: r,
679
- amount: n,
1307
+ chain: n,
1308
+ amount: r,
680
1309
  isOpen: i,
681
1310
  isPending: o,
682
1311
  open: a,
683
1312
  close: c,
684
1313
  onCancel: u,
685
- onSuccess: y,
1314
+ onSuccess: l,
686
1315
  data: w
687
- } = t, [p, m] = le(!0), R = W(null);
688
- F(() => {
689
- l();
690
- const f = document.body.style.overflow;
691
- i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = f || "";
692
- const h = (T) => {
693
- T.data === "closed" && (c(), u?.()), T.data === "completed" && (window.setTimeout(c, 2e3), y?.());
1316
+ } = e, [d, m] = Ne(!0), T = se(null);
1317
+ ne(() => {
1318
+ f();
1319
+ const p = document.body.style.overflow;
1320
+ i ? (document.body.style.overflow = "hidden", document.body.style.overflow = "hidden") : document.body.style.overflow = p || "";
1321
+ const g = (b) => {
1322
+ b.data === "closed" && (c(), u?.()), b.data === "completed" && (window.setTimeout(c, 2e3), l?.());
694
1323
  };
695
- return window.addEventListener("message", h), () => {
696
- document.body.style.overflow = f || "", window.removeEventListener("message", h);
1324
+ return window.addEventListener("message", g), () => {
1325
+ document.body.style.overflow = p || "", window.removeEventListener("message", g);
697
1326
  };
698
- }, [i, u, y]);
1327
+ }, [i, u, l]);
699
1328
  function j() {
700
- m(!1), l();
1329
+ m(!1), f();
701
1330
  }
702
- function l() {
1331
+ function f() {
703
1332
  if (!w?.sessionToken) return;
704
- const f = {
1333
+ const p = {
705
1334
  type: "session",
706
1335
  session_token: w.sessionToken,
707
- environment: d.getEnv() || z.PRODUCTION
1336
+ environment: h.getEnv() || ce.PRODUCTION
708
1337
  };
709
- R.current?.contentWindow?.postMessage(f, "https://app.chainrails.io"), R.current?.contentWindow?.postMessage(f, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
1338
+ T.current?.contentWindow?.postMessage(p, "https://app.chainrails.io"), T.current?.contentWindow?.postMessage(p, "https://chainrails-frontend-git-staging-horus-labs.vercel.app");
710
1339
  }
711
- return w?.sessionToken ? /* @__PURE__ */ se("div", {
712
- className: dt("payment-modal-wrapper", p || o ? "loading" : "not-loading", i ? "open" : "closed"),
713
- children: [(p || o) && /* @__PURE__ */ S("div", {
1340
+ return w?.sessionToken ? /* @__PURE__ */ ye("div", {
1341
+ className: sn("payment-modal-wrapper", d || o ? "loading" : "not-loading", i ? "open" : "closed"),
1342
+ children: [(d || o) && /* @__PURE__ */ U("div", {
714
1343
  role: "status",
715
1344
  className: "payment-modal-loader",
716
- children: /* @__PURE__ */ se("svg", {
1345
+ children: /* @__PURE__ */ ye("svg", {
717
1346
  "aria-hidden": "true",
718
1347
  className: "icon",
719
1348
  viewBox: "0 0 100 101",
720
1349
  fill: "none",
721
1350
  xmlns: "http://www.w3.org/2000/svg",
722
- children: [/* @__PURE__ */ S("path", {
1351
+ children: [/* @__PURE__ */ U("path", {
723
1352
  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",
724
1353
  fill: "currentColor"
725
- }), /* @__PURE__ */ S("path", {
1354
+ }), /* @__PURE__ */ U("path", {
726
1355
  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",
727
1356
  fill: "currentFill"
728
1357
  })]
729
1358
  })
730
- }), /* @__PURE__ */ S("iframe", {
1359
+ }), /* @__PURE__ */ U("iframe", {
731
1360
  allow: "clipboard-read *; clipboard-write *",
732
- src: d.getPayModalUrl(r, s, e, n),
1361
+ src: h.getPayModalUrl(n, s, t, r),
733
1362
  onLoad: j,
734
- className: `payment-modal ${p || o ? "invisible" : "visible"}`,
735
- "data-id": n,
736
- ref: R
1363
+ className: `payment-modal ${d || o ? "invisible" : "visible"}`,
1364
+ "data-id": r,
1365
+ ref: T
737
1366
  })]
738
- }) : /* @__PURE__ */ S(Ue, {});
739
- }
740
- const pt = Symbol(), V = Symbol(), A = "a", Re = "f", oe = "p", be = "c", Ee = "t", J = "h", v = "w", G = "o", X = "k";
741
- let yt = (t, e) => new Proxy(t, e);
742
- const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) => t && ($.has(t) ? $.get(t) : K(t) === Object.prototype || K(t) === Array.prototype), q = (t) => typeof t == "object" && t !== null, gt = (t) => Object.values(Object.getOwnPropertyDescriptors(t)).some((e) => !e.configurable && !e.writable), mt = (t) => {
743
- if (Array.isArray(t))
744
- return Array.from(t);
745
- const e = Object.getOwnPropertyDescriptors(t);
746
- return Object.values(e).forEach((s) => {
1367
+ }) : /* @__PURE__ */ U(It, {});
1368
+ }
1369
+ const nn = Symbol(), ue = Symbol(), x = "a", pt = "f", Ce = "p", gt = "c", mt = "t", le = "h", k = "w", fe = "o", he = "k";
1370
+ let rn = (e, t) => new Proxy(e, t);
1371
+ const ee = Object.getPrototypeOf, te = /* @__PURE__ */ new WeakMap(), yt = (e) => e && (te.has(e) ? te.get(e) : ee(e) === Object.prototype || ee(e) === Array.prototype), $ = (e) => typeof e == "object" && e !== null, on = (e) => Object.values(Object.getOwnPropertyDescriptors(e)).some((t) => !t.configurable && !t.writable), an = (e) => {
1372
+ if (Array.isArray(e))
1373
+ return Array.from(e);
1374
+ const t = Object.getOwnPropertyDescriptors(e);
1375
+ return Object.values(t).forEach((s) => {
747
1376
  s.configurable = !0;
748
- }), Object.create(K(t), e);
749
- }, wt = (t, e) => {
1377
+ }), Object.create(ee(e), t);
1378
+ }, cn = (e, t) => {
750
1379
  const s = {
751
- [Re]: e
1380
+ [pt]: t
752
1381
  };
753
- let r = !1;
754
- const n = (a, c) => {
755
- if (!r) {
756
- let u = s[A].get(t);
757
- if (u || (u = {}, s[A].set(t, u)), a === v)
758
- u[v] = !0;
1382
+ let n = !1;
1383
+ const r = (a, c) => {
1384
+ if (!n) {
1385
+ let u = s[x].get(e);
1386
+ if (u || (u = {}, s[x].set(e, u)), a === k)
1387
+ u[k] = !0;
759
1388
  else {
760
- let y = u[a];
761
- y || (y = /* @__PURE__ */ new Set(), u[a] = y), y.add(c);
1389
+ let l = u[a];
1390
+ l || (l = /* @__PURE__ */ new Set(), u[a] = l), l.add(c);
762
1391
  }
763
1392
  }
764
1393
  }, i = () => {
765
- r = !0, s[A].delete(t);
1394
+ n = !0, s[x].delete(e);
766
1395
  }, o = {
767
1396
  get(a, c) {
768
- return c === V ? t : (n(X, c), Se(Reflect.get(a, c), s[A], s[be], s[Ee]));
1397
+ return c === ue ? e : (r(he, c), wt(Reflect.get(a, c), s[x], s[gt], s[mt]));
769
1398
  },
770
1399
  has(a, c) {
771
- return c === pt ? (i(), !0) : (n(J, c), Reflect.has(a, c));
1400
+ return c === nn ? (i(), !0) : (r(le, c), Reflect.has(a, c));
772
1401
  },
773
1402
  getOwnPropertyDescriptor(a, c) {
774
- return n(G, c), Reflect.getOwnPropertyDescriptor(a, c);
1403
+ return r(fe, c), Reflect.getOwnPropertyDescriptor(a, c);
775
1404
  },
776
1405
  ownKeys(a) {
777
- return n(v), Reflect.ownKeys(a);
1406
+ return r(k), Reflect.ownKeys(a);
778
1407
  }
779
1408
  };
780
- return e && (o.set = o.deleteProperty = () => !1), [o, s];
781
- }, Z = (t) => (
1409
+ return t && (o.set = o.deleteProperty = () => !1), [o, s];
1410
+ }, de = (e) => (
782
1411
  // unwrap proxy
783
- t[V] || // otherwise
784
- t
785
- ), Se = (t, e, s, r) => {
786
- if (!Pe(t))
787
- return t;
788
- let n = r && r.get(t);
789
- if (!n) {
790
- const c = Z(t);
791
- gt(c) ? n = [c, mt(c)] : n = [c], r?.set(t, n);
1412
+ e[ue] || // otherwise
1413
+ e
1414
+ ), wt = (e, t, s, n) => {
1415
+ if (!yt(e))
1416
+ return e;
1417
+ let r = n && n.get(e);
1418
+ if (!r) {
1419
+ const c = de(e);
1420
+ on(c) ? r = [c, an(c)] : r = [c], n?.set(e, r);
792
1421
  }
793
- const [i, o] = n;
1422
+ const [i, o] = r;
794
1423
  let a = s && s.get(i);
795
- return (!a || a[1][Re] !== !!o) && (a = wt(i, !!o), a[1][oe] = yt(o || i, a[0]), s && s.set(i, a)), a[1][A] = e, a[1][be] = s, a[1][Ee] = r, a[1][oe];
796
- }, Tt = (t, e) => {
797
- const s = Reflect.ownKeys(t), r = Reflect.ownKeys(e);
798
- return s.length !== r.length || s.some((n, i) => n !== r[i]);
799
- }, Ae = (t, e, s, r, n = Object.is) => {
800
- if (n(t, e))
1424
+ return (!a || a[1][pt] !== !!o) && (a = cn(i, !!o), a[1][Ce] = rn(o || i, a[0]), s && s.set(i, a)), a[1][x] = t, a[1][gt] = s, a[1][mt] = n, a[1][Ce];
1425
+ }, un = (e, t) => {
1426
+ const s = Reflect.ownKeys(e), n = Reflect.ownKeys(t);
1427
+ return s.length !== n.length || s.some((r, i) => r !== n[i]);
1428
+ }, bt = (e, t, s, n, r = Object.is) => {
1429
+ if (r(e, t))
801
1430
  return !1;
802
- if (!q(t) || !q(e))
1431
+ if (!$(e) || !$(t))
803
1432
  return !0;
804
- const i = s.get(Z(t));
1433
+ const i = s.get(de(e));
805
1434
  if (!i)
806
1435
  return !0;
807
- if (r) {
808
- if (r.get(t) === e)
1436
+ if (n) {
1437
+ if (n.get(e) === t)
809
1438
  return !1;
810
- r.set(t, e);
1439
+ n.set(e, t);
811
1440
  }
812
1441
  let o = null;
813
- for (const a of i[J] || [])
814
- if (o = Reflect.has(t, a) !== Reflect.has(e, a), o)
1442
+ for (const a of i[le] || [])
1443
+ if (o = Reflect.has(e, a) !== Reflect.has(t, a), o)
815
1444
  return o;
816
- if (i[v] === !0) {
817
- if (o = Tt(t, e), o)
1445
+ if (i[k] === !0) {
1446
+ if (o = un(e, t), o)
818
1447
  return o;
819
1448
  } else
820
- for (const a of i[G] || []) {
821
- const c = !!Reflect.getOwnPropertyDescriptor(t, a), u = !!Reflect.getOwnPropertyDescriptor(e, a);
1449
+ for (const a of i[fe] || []) {
1450
+ const c = !!Reflect.getOwnPropertyDescriptor(e, a), u = !!Reflect.getOwnPropertyDescriptor(t, a);
822
1451
  if (o = c !== u, o)
823
1452
  return o;
824
1453
  }
825
- for (const a of i[X] || [])
826
- if (o = Ae(t[a], e[a], s, r, n), o)
1454
+ for (const a of i[he] || [])
1455
+ if (o = bt(e[a], t[a], s, n, r), o)
827
1456
  return o;
828
1457
  if (o === null)
829
1458
  throw new Error("invalid used");
830
1459
  return o;
831
- }, Rt = (t) => Pe(t) && t[V] || null, ie = (t, e = !0) => {
832
- $.set(t, e);
833
- }, bt = (t, e, s) => {
834
- const r = [], n = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
835
- var c, u, y;
836
- if (n.has(o))
1460
+ }, ln = (e) => yt(e) && e[ue] || null, xe = (e, t = !0) => {
1461
+ te.set(e, t);
1462
+ }, fn = (e, t, s) => {
1463
+ const n = [], r = /* @__PURE__ */ new WeakSet(), i = (o, a) => {
1464
+ var c, u, l;
1465
+ if (r.has(o))
837
1466
  return;
838
- q(o) && n.add(o);
839
- const w = q(o) && e.get(Z(o));
1467
+ $(o) && r.add(o);
1468
+ const w = $(o) && t.get(de(o));
840
1469
  if (w) {
841
- if ((c = w[J]) === null || c === void 0 || c.forEach((p) => {
842
- const m = `:has(${String(p)})`;
843
- r.push(a ? [...a, m] : [m]);
844
- }), w[v] === !0) {
845
- const p = ":ownKeys";
846
- r.push(a ? [...a, p] : [p]);
1470
+ if ((c = w[le]) === null || c === void 0 || c.forEach((d) => {
1471
+ const m = `:has(${String(d)})`;
1472
+ n.push(a ? [...a, m] : [m]);
1473
+ }), w[k] === !0) {
1474
+ const d = ":ownKeys";
1475
+ n.push(a ? [...a, d] : [d]);
847
1476
  } else
848
- (u = w[G]) === null || u === void 0 || u.forEach((p) => {
849
- const m = `:hasOwn(${String(p)})`;
850
- r.push(a ? [...a, m] : [m]);
1477
+ (u = w[fe]) === null || u === void 0 || u.forEach((d) => {
1478
+ const m = `:hasOwn(${String(d)})`;
1479
+ n.push(a ? [...a, m] : [m]);
851
1480
  });
852
- (y = w[X]) === null || y === void 0 || y.forEach((p) => {
853
- "value" in (Object.getOwnPropertyDescriptor(o, p) || {}) && i(o[p], a ? [...a, p] : [p]);
1481
+ (l = w[he]) === null || l === void 0 || l.forEach((d) => {
1482
+ "value" in (Object.getOwnPropertyDescriptor(o, d) || {}) && i(o[d], a ? [...a, d] : [d]);
854
1483
  });
855
- } else a && r.push(a);
1484
+ } else a && n.push(a);
856
1485
  };
857
- return i(t), r;
858
- }, _ = {}, Q = (t) => typeof t == "object" && t !== null, Et = (t) => Q(t) && !ee.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), ve = (t, e) => {
859
- const s = ae.get(t);
860
- if (s?.[0] === e)
1486
+ return i(e), n;
1487
+ }, L = {}, pe = (e) => typeof e == "object" && e !== null, hn = (e) => pe(e) && !ge.has(e) && (Array.isArray(e) || !(Symbol.iterator in e)) && !(e instanceof WeakMap) && !(e instanceof WeakSet) && !(e instanceof Error) && !(e instanceof Number) && !(e instanceof Date) && !(e instanceof String) && !(e instanceof RegExp) && !(e instanceof ArrayBuffer) && !(e instanceof Promise), Et = (e, t) => {
1488
+ const s = ke.get(e);
1489
+ if (s?.[0] === t)
861
1490
  return s[1];
862
- const r = Array.isArray(t) ? [] : Object.create(Object.getPrototypeOf(t));
863
- return ie(r, !0), ae.set(t, [e, r]), Reflect.ownKeys(t).forEach((n) => {
864
- if (Object.getOwnPropertyDescriptor(r, n))
1491
+ const n = Array.isArray(e) ? [] : Object.create(Object.getPrototypeOf(e));
1492
+ return xe(n, !0), ke.set(e, [t, n]), Reflect.ownKeys(e).forEach((r) => {
1493
+ if (Object.getOwnPropertyDescriptor(n, r))
865
1494
  return;
866
- const i = Reflect.get(t, n), { enumerable: o } = Reflect.getOwnPropertyDescriptor(
867
- t,
868
- n
1495
+ const i = Reflect.get(e, r), { enumerable: o } = Reflect.getOwnPropertyDescriptor(
1496
+ e,
1497
+ r
869
1498
  ), a = {
870
1499
  value: i,
871
1500
  enumerable: o,
@@ -873,214 +1502,216 @@ const K = Object.getPrototypeOf, $ = /* @__PURE__ */ new WeakMap(), Pe = (t) =>
873
1502
  // It's still non-writable, so it avoids assigning a value.
874
1503
  configurable: !0
875
1504
  };
876
- if (ee.has(i))
877
- ie(i, !1);
878
- else if (P.has(i)) {
879
- const [c, u] = P.get(
1505
+ if (ge.has(i))
1506
+ xe(i, !1);
1507
+ else if (I.has(i)) {
1508
+ const [c, u] = I.get(
880
1509
  i
881
1510
  );
882
- a.value = ve(c, u());
1511
+ a.value = Et(c, u());
883
1512
  }
884
- Object.defineProperty(r, n, a);
885
- }), Object.preventExtensions(r);
886
- }, Pt = (t, e, s, r) => ({
887
- deleteProperty(n, i) {
888
- const o = Reflect.get(n, i);
1513
+ Object.defineProperty(n, r, a);
1514
+ }), Object.preventExtensions(n);
1515
+ }, dn = (e, t, s, n) => ({
1516
+ deleteProperty(r, i) {
1517
+ const o = Reflect.get(r, i);
889
1518
  s(i);
890
- const a = Reflect.deleteProperty(n, i);
891
- return a && r(["delete", [i], o]), a;
1519
+ const a = Reflect.deleteProperty(r, i);
1520
+ return a && n(["delete", [i], o]), a;
892
1521
  },
893
- set(n, i, o, a) {
894
- const c = !t() && Reflect.has(n, i), u = Reflect.get(n, i, a);
895
- if (c && (ce(u, o) || U.has(o) && ce(u, U.get(o))))
1522
+ set(r, i, o, a) {
1523
+ const c = !e() && Reflect.has(r, i), u = Reflect.get(r, i, a);
1524
+ if (c && (Oe(u, o) || z.has(o) && Oe(u, z.get(o))))
896
1525
  return !0;
897
- s(i), Q(o) && (o = Rt(o) || o);
898
- const y = !P.has(o) && At(o) ? Oe(o) : o;
899
- return e(i, y), Reflect.set(n, i, y, a), r(["set", [i], o, u]), !0;
900
- }
901
- }), P = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), ae = /* @__PURE__ */ new WeakMap(), L = [1], U = /* @__PURE__ */ new WeakMap();
902
- let ce = Object.is, St = (t, e) => new Proxy(t, e), At = Et, vt = ve, Ot = Pt;
903
- function Oe(t = {}) {
904
- if (!Q(t))
1526
+ s(i), pe(o) && (o = ln(o) || o);
1527
+ const l = !I.has(o) && gn(o) ? St(o) : o;
1528
+ return t(i, l), Reflect.set(r, i, l, a), n(["set", [i], o, u]), !0;
1529
+ }
1530
+ }), I = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakSet(), ke = /* @__PURE__ */ new WeakMap(), Y = [1], z = /* @__PURE__ */ new WeakMap();
1531
+ let Oe = Object.is, pn = (e, t) => new Proxy(e, t), gn = hn, mn = Et, yn = dn;
1532
+ function St(e = {}) {
1533
+ if (!pe(e))
905
1534
  throw new Error("object required");
906
- const e = U.get(t);
907
- if (e)
908
- return e;
909
- let s = L[0];
910
- const r = /* @__PURE__ */ new Set(), n = (l, f = ++L[0]) => {
911
- s !== f && (i = s = f, r.forEach((h) => h(l, f)));
1535
+ const t = z.get(e);
1536
+ if (t)
1537
+ return t;
1538
+ let s = Y[0];
1539
+ const n = /* @__PURE__ */ new Set(), r = (f, p = ++Y[0]) => {
1540
+ s !== p && (i = s = p, n.forEach((g) => g(f, p)));
912
1541
  };
913
1542
  let i = s;
914
- const o = (l = L[0]) => (i !== l && (i = l, c.forEach(([f]) => {
915
- const h = f[1](l);
916
- h > s && (s = h);
917
- })), s), a = (l) => (f, h) => {
918
- const T = [...f];
919
- T[1] = [l, ...T[1]], n(T, h);
920
- }, c = /* @__PURE__ */ new Map(), u = (l, f) => {
921
- const h = !ee.has(f) && P.get(f);
922
- if (h) {
923
- if ((_ ? "production" : void 0) !== "production" && c.has(l))
1543
+ const o = (f = Y[0]) => (i !== f && (i = f, c.forEach(([p]) => {
1544
+ const g = p[1](f);
1545
+ g > s && (s = g);
1546
+ })), s), a = (f) => (p, g) => {
1547
+ const b = [...p];
1548
+ b[1] = [f, ...b[1]], r(b, g);
1549
+ }, c = /* @__PURE__ */ new Map(), u = (f, p) => {
1550
+ const g = !ge.has(p) && I.get(p);
1551
+ if (g) {
1552
+ if ((L ? "production" : void 0) !== "production" && c.has(f))
924
1553
  throw new Error("prop listener already exists");
925
- if (r.size) {
926
- const T = h[2](a(l));
927
- c.set(l, [h, T]);
1554
+ if (n.size) {
1555
+ const b = g[2](a(f));
1556
+ c.set(f, [g, b]);
928
1557
  } else
929
- c.set(l, [h]);
1558
+ c.set(f, [g]);
930
1559
  }
931
- }, y = (l) => {
932
- var f;
933
- const h = c.get(l);
934
- h && (c.delete(l), (f = h[1]) == null || f.call(h));
935
- }, w = (l) => (r.add(l), r.size === 1 && c.forEach(([h, T], C) => {
936
- if ((_ ? "production" : void 0) !== "production" && T)
1560
+ }, l = (f) => {
1561
+ var p;
1562
+ const g = c.get(f);
1563
+ g && (c.delete(f), (p = g[1]) == null || p.call(g));
1564
+ }, w = (f) => (n.add(f), n.size === 1 && c.forEach(([g, b], D) => {
1565
+ if ((L ? "production" : void 0) !== "production" && b)
937
1566
  throw new Error("remove already exists");
938
- const Ce = h[2](a(C));
939
- c.set(C, [h, Ce]);
1567
+ const Rt = g[2](a(D));
1568
+ c.set(D, [g, Rt]);
940
1569
  }), () => {
941
- r.delete(l), r.size === 0 && c.forEach(([h, T], C) => {
942
- T && (T(), c.set(C, [h]));
1570
+ n.delete(f), n.size === 0 && c.forEach(([g, b], D) => {
1571
+ b && (b(), c.set(D, [g]));
943
1572
  });
944
1573
  });
945
- let p = !0;
946
- const m = Ot(
947
- () => p,
1574
+ let d = !0;
1575
+ const m = yn(
1576
+ () => d,
948
1577
  u,
949
- y,
950
- n
951
- ), R = St(t, m);
952
- U.set(t, R);
953
- const j = [t, o, w];
954
- return P.set(R, j), Reflect.ownKeys(t).forEach((l) => {
955
- const f = Object.getOwnPropertyDescriptor(
956
- t,
957
- l
1578
+ l,
1579
+ r
1580
+ ), T = pn(e, m);
1581
+ z.set(e, T);
1582
+ const j = [e, o, w];
1583
+ return I.set(T, j), Reflect.ownKeys(e).forEach((f) => {
1584
+ const p = Object.getOwnPropertyDescriptor(
1585
+ e,
1586
+ f
958
1587
  );
959
- "value" in f && f.writable && (R[l] = t[l]);
960
- }), p = !1, R;
961
- }
962
- function Ct(t, e, s) {
963
- const r = P.get(t);
964
- (_ ? "production" : void 0) !== "production" && !r && console.warn("Please use proxy object");
965
- let n;
966
- const i = [], o = r[2];
1588
+ "value" in p && p.writable && (T[f] = e[f]);
1589
+ }), d = !1, T;
1590
+ }
1591
+ function wn(e, t, s) {
1592
+ const n = I.get(e);
1593
+ (L ? "production" : void 0) !== "production" && !n && console.warn("Please use proxy object");
1594
+ let r;
1595
+ const i = [], o = n[2];
967
1596
  let a = !1;
968
- const u = o((y) => {
969
- i.push(y), n || (n = Promise.resolve().then(() => {
970
- n = void 0, a && e(i.splice(0));
1597
+ const u = o((l) => {
1598
+ i.push(l), r || (r = Promise.resolve().then(() => {
1599
+ r = void 0, a && t(i.splice(0));
971
1600
  }));
972
1601
  });
973
1602
  return a = !0, () => {
974
1603
  a = !1, u();
975
1604
  };
976
1605
  }
977
- function ue(t) {
978
- const e = P.get(t);
979
- (_ ? "production" : void 0) !== "production" && !e && console.warn("Please use proxy object");
980
- const [s, r] = e;
981
- return vt(s, r());
982
- }
983
- const kt = {}, Nt = (t, e) => {
984
- const s = W(void 0);
985
- F(() => {
986
- s.current = bt(t, e);
987
- }), _e(s.current);
988
- }, qt = Nt, _t = /* @__PURE__ */ new WeakMap();
989
- function Ut(t, e) {
990
- const r = te(
991
- () => t && /* @__PURE__ */ new WeakMap(),
992
- [t]
993
- ), n = W(void 0);
1606
+ function De(e) {
1607
+ const t = I.get(e);
1608
+ (L ? "production" : void 0) !== "production" && !t && console.warn("Please use proxy object");
1609
+ const [s, n] = t;
1610
+ return mn(s, n());
1611
+ }
1612
+ const bn = {}, En = (e, t) => {
1613
+ const s = se(void 0);
1614
+ ne(() => {
1615
+ s.current = fn(e, t);
1616
+ }), Pt(s.current);
1617
+ }, Sn = En, Rn = /* @__PURE__ */ new WeakMap();
1618
+ function Tn(e, t) {
1619
+ const n = me(
1620
+ () => e && /* @__PURE__ */ new WeakMap(),
1621
+ [e]
1622
+ ), r = se(void 0);
994
1623
  let i = !0;
995
- const o = ke(
996
- Ne(
1624
+ const o = Tt(
1625
+ At(
997
1626
  (c) => {
998
- const u = Ct(t, c);
1627
+ const u = wn(e, c);
999
1628
  return c(), u;
1000
1629
  },
1001
- [t, void 0]
1630
+ [e, void 0]
1002
1631
  ),
1003
1632
  () => {
1004
- const c = ue(t);
1633
+ const c = De(e);
1005
1634
  try {
1006
- if (!i && n.current && !Ae(
1007
- n.current,
1635
+ if (!i && r.current && !bt(
1636
+ r.current,
1008
1637
  c,
1009
- r,
1638
+ n,
1010
1639
  /* @__PURE__ */ new WeakMap()
1011
1640
  ))
1012
- return n.current;
1641
+ return r.current;
1013
1642
  } catch {
1014
1643
  }
1015
1644
  return c;
1016
1645
  },
1017
- () => ue(t)
1646
+ () => De(e)
1018
1647
  );
1019
- i = !1, qe(() => {
1020
- n.current = o;
1021
- }), (kt ? "production" : void 0) !== "production" && qt(o, r);
1022
- const a = te(() => /* @__PURE__ */ new WeakMap(), []);
1023
- return Se(o, r, a, _t);
1648
+ i = !1, vt(() => {
1649
+ r.current = o;
1650
+ }), (bn ? "production" : void 0) !== "production" && Sn(o, n);
1651
+ const a = me(() => /* @__PURE__ */ new WeakMap(), []);
1652
+ return wt(o, n, a, Rn);
1024
1653
  }
1025
- const b = Oe({
1654
+ const v = St({
1026
1655
  data: null,
1027
1656
  isPending: !1,
1028
1657
  error: null
1029
1658
  });
1030
- function Dt({
1031
- auth_url: t,
1032
- chain: e,
1659
+ function Un({
1660
+ auth_url: e,
1661
+ chain: t,
1033
1662
  token: s,
1034
- amount: r,
1035
- to: n,
1663
+ amount: n,
1664
+ to: r,
1036
1665
  onCancel: i,
1037
1666
  onSuccess: o
1038
1667
  }) {
1039
- const a = Ut(b), [c, u] = le(!1);
1040
- function y() {
1668
+ const a = Tn(v), [c, u] = Ne(!1);
1669
+ function l() {
1041
1670
  u(!0);
1042
1671
  }
1043
1672
  function w() {
1044
1673
  u(!1);
1045
1674
  }
1046
- const p = () => {
1047
- b.isPending = !0, b.error = null, fetch(t, {
1675
+ const d = () => {
1676
+ v.isPending = !0, v.error = null, fetch(e, {
1048
1677
  method: "POST",
1049
1678
  headers: {
1050
1679
  "Content-Type": "application/json"
1051
1680
  },
1052
1681
  body: JSON.stringify({
1053
- chain: e,
1682
+ chain: t,
1054
1683
  token: s,
1055
- amount: r,
1056
- to: n
1684
+ amount: n,
1685
+ to: r
1057
1686
  })
1058
1687
  }).then((m) => m.json()).then((m) => {
1059
- b.data = m, b.isPending = !1;
1688
+ v.data = m, h.config({
1689
+ api_key: m.sessionToken
1690
+ }), v.isPending = !1;
1060
1691
  }).catch((m) => {
1061
- b.error = m?.toString(), b.isPending = !1;
1692
+ v.error = m?.toString(), v.isPending = !1;
1062
1693
  });
1063
1694
  };
1064
- return F(() => {
1065
- d.config(), p();
1066
- }, [e, s, r, n]), {
1695
+ return ne(() => {
1696
+ d();
1697
+ }, [t, s, n, r]), {
1067
1698
  ...a,
1068
- chain: e,
1699
+ chain: t,
1069
1700
  token: s,
1070
- to: n,
1701
+ to: r,
1071
1702
  isOpen: c,
1072
- open: y,
1703
+ open: l,
1073
1704
  close: w,
1074
- refetch: p,
1705
+ refetch: d,
1075
1706
  onSuccess: o,
1076
1707
  onCancel: i
1077
1708
  };
1078
1709
  }
1079
1710
  export {
1080
- d as Chainrails,
1081
- Lt as PaymentModal,
1082
- ot as chains,
1083
- xt as crapi,
1084
- it as tokens,
1085
- Dt as usePaymentSession
1711
+ h as Chainrails,
1712
+ In as PaymentModal,
1713
+ Z as chains,
1714
+ Pn as crapi,
1715
+ ht as tokens,
1716
+ Un as usePaymentSession
1086
1717
  };