@chainrails/react 0.0.8 → 0.0.9

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
1
  import { useState as U, useEffect as z } from "react";
2
- import { jsxs as N, jsx as w } from "react/jsx-runtime";
3
- import './index.css';class x extends Error {
2
+ import { jsxs as j, jsx as w } from "react/jsx-runtime";
3
+ import './index.css';class C extends Error {
4
4
  response;
5
5
  request;
6
6
  options;
@@ -21,7 +21,7 @@ class L extends Error {
21
21
  super(r), this.value = e;
22
22
  }
23
23
  }
24
- class E extends Error {
24
+ class S extends Error {
25
25
  name = "ForceRetryError";
26
26
  customDelay;
27
27
  code;
@@ -50,7 +50,7 @@ const v = (() => {
50
50
  throw n;
51
51
  }
52
52
  return t && !e;
53
- })(), J = typeof globalThis.AbortController == "function", I = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", V = typeof globalThis.ReadableStream == "function", K = typeof globalThis.FormData == "function", _ = ["get", "post", "put", "patch", "head", "delete"], W = {
53
+ })(), J = typeof globalThis.AbortController == "function", M = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", V = typeof globalThis.ReadableStream == "function", K = typeof globalThis.FormData == "function", _ = ["get", "post", "put", "patch", "head", "delete"], W = {
54
54
  json: "application/json",
55
55
  text: "text/*",
56
56
  formData: "multipart/form-data",
@@ -59,14 +59,14 @@ const v = (() => {
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
- }, A = 2147483647, X = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, M = Symbol("stop");
63
- class B {
62
+ }, A = 2147483647, X = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, I = Symbol("stop");
63
+ class H {
64
64
  options;
65
65
  constructor(e) {
66
66
  this.options = e;
67
67
  }
68
68
  }
69
- const Z = (t) => new B(t), Y = {
69
+ const Z = (t) => new H(t), Y = {
70
70
  json: !0,
71
71
  parseJson: !0,
72
72
  stringifyJson: !0,
@@ -125,7 +125,7 @@ const Z = (t) => new B(t), Y = {
125
125
  return 0;
126
126
  }
127
127
  return 0;
128
- }, H = (t, e, r) => {
128
+ }, B = (t, e, r) => {
129
129
  let s, n = 0;
130
130
  return t.pipeThrough(new TransformStream({
131
131
  transform(o, i) {
@@ -150,7 +150,7 @@ const Z = (t) => new B(t), Y = {
150
150
  headers: t.headers
151
151
  });
152
152
  const r = Math.max(0, Number(t.headers.get("content-length")) || 0);
153
- return new Response(H(t.body, r, e), {
153
+ return new Response(B(t.body, r, e), {
154
154
  status: t.status,
155
155
  statusText: t.statusText,
156
156
  headers: t.headers
@@ -162,7 +162,7 @@ const Z = (t) => new B(t), Y = {
162
162
  return new Request(t, {
163
163
  // @ts-expect-error - Types are outdated.
164
164
  duplex: "half",
165
- body: H(t.body, s, e)
165
+ body: B(t.body, s, e)
166
166
  });
167
167
  }, l = (t) => t !== null && typeof t == "object", b = (...t) => {
168
168
  for (const e of t)
@@ -175,14 +175,14 @@ const Z = (t) => new B(t), Y = {
175
175
  s && i === "undefined" || i === void 0 ? r.delete(o) : r.set(o, i);
176
176
  return r;
177
177
  };
178
- function R(t, e, r) {
178
+ function T(t, e, r) {
179
179
  return Object.hasOwn(e, r) && e[r] === void 0 ? [] : k(t[r] ?? [], e[r] ?? []);
180
180
  }
181
181
  const $ = (t = {}, e = {}) => ({
182
- beforeRequest: R(t, e, "beforeRequest"),
183
- beforeRetry: R(t, e, "beforeRetry"),
184
- afterResponse: R(t, e, "afterResponse"),
185
- beforeError: R(t, e, "beforeError")
182
+ beforeRequest: T(t, e, "beforeRequest"),
183
+ beforeRetry: T(t, e, "beforeRetry"),
184
+ afterResponse: T(t, e, "afterResponse"),
185
+ beforeError: T(t, e, "beforeError")
186
186
  }), se = (t, e) => {
187
187
  const r = new URLSearchParams();
188
188
  for (const s of [t, e])
@@ -234,7 +234,7 @@ const $ = (t = {}, e = {}) => ({
234
234
  }
235
235
  l(i.hooks) && (s = $(s, i.hooks), e.hooks = s), l(i.headers) && (r = D(r, i.headers), e.headers = r);
236
236
  }
237
- return n !== void 0 && (e.searchParams = n), o.length > 0 && (o.length === 1 ? e.signal = o[0] : I ? e.signal = AbortSignal.any(o) : e.signal = o.at(-1)), e.context === void 0 && (e.context = {}), e;
237
+ return n !== void 0 && (e.searchParams = n), o.length > 0 && (o.length === 1 ? e.signal = o[0] : M ? e.signal = AbortSignal.any(o) : e.signal = o.at(-1)), e.context === void 0 && (e.context = {}), e;
238
238
  }, ne = (t) => _.includes(t) ? t.toUpperCase() : t, oe = ["get", "put", "head", "delete", "options", "trace"], ie = [408, 413, 429, 500, 502, 503, 504], ae = [413, 429, 503], O = {
239
239
  limit: 2,
240
240
  methods: oe,
@@ -260,7 +260,7 @@ const $ = (t = {}, e = {}) => ({
260
260
  ...t
261
261
  };
262
262
  };
263
- class C extends Error {
263
+ class x 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;
@@ -269,7 +269,7 @@ class C extends Error {
269
269
  async function ce(t, e, r, s) {
270
270
  return new Promise((n, o) => {
271
271
  const i = setTimeout(() => {
272
- r && r.abort(), o(new C(t));
272
+ r && r.abort(), o(new x(t));
273
273
  }, s.timeout);
274
274
  s.fetch(t, e).then(n).catch(o).then(() => {
275
275
  clearTimeout(i);
@@ -294,10 +294,10 @@ const le = (t, e) => {
294
294
  return r;
295
295
  }, fe = (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
296
  function de(t) {
297
- return t instanceof x || t?.name === x.name;
297
+ return t instanceof C || t?.name === C.name;
298
298
  }
299
299
  function pe(t) {
300
- return t instanceof C || t?.name === C.name;
300
+ return t instanceof x || t?.name === x.name;
301
301
  }
302
302
  class y {
303
303
  static create(e, r) {
@@ -308,14 +308,14 @@ class y {
308
308
  let i = await s.#y();
309
309
  for (const u of s.#e.hooks.afterResponse) {
310
310
  const a = s.#h(i.clone()), c = await u(s.request, s.#a(), a, { retryCount: s.#r });
311
- if (c instanceof globalThis.Response && (i = c), c instanceof B)
311
+ if (c instanceof globalThis.Response && (i = c), c instanceof H)
312
312
  throw await Promise.all([
313
313
  a.body?.cancel(),
314
314
  i.body?.cancel()
315
- ]), new E(c.options);
315
+ ]), new S(c.options);
316
316
  }
317
317
  if (s.#h(i), !i.ok && (typeof s.#e.throwHttpErrors == "function" ? s.#e.throwHttpErrors(i.status) : s.#e.throwHttpErrors)) {
318
- let u = new x(i, s.request, s.#a());
318
+ let u = new C(i, s.request, s.#a());
319
319
  for (const a of s.#e.hooks.beforeError)
320
320
  u = await a(u, { retryCount: s.#r });
321
321
  throw u;
@@ -385,7 +385,7 @@ class y {
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
- J && I && (this.#n = this.#e.signal ?? this.#t.signal, this.#s = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#s.signal]) : this.#s.signal), v && (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
+ J && M && (this.#n = this.#e.signal ?? this.#t.signal, this.#s = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#s.signal]) : this.#s.signal), v && (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 s = r.headers && new globalThis.Headers(r.headers).has("content-type");
390
390
  if (this.#t instanceof globalThis.Request && (K && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !s && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), fe(this.#e.searchParams)) {
391
391
  const o = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(y.#d(this.#e.searchParams)).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, o);
@@ -408,7 +408,7 @@ class y {
408
408
  if (this.#r++, this.#r > this.#e.retry.limit)
409
409
  throw e;
410
410
  const r = e instanceof Error ? e : new L(e);
411
- if (r instanceof E)
411
+ if (r instanceof S)
412
412
  return r.customDelay ?? this.#u();
413
413
  if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
414
414
  throw e;
@@ -446,7 +446,7 @@ class y {
446
446
  const s = Math.min(await this.#p(r), A);
447
447
  if (this.#r < 1)
448
448
  throw r;
449
- if (await he(s, this.#n ? { signal: this.#n } : {}), r instanceof E && r.customRequest) {
449
+ if (await he(s, this.#n ? { signal: this.#n } : {}), r instanceof S && r.customRequest) {
450
450
  const n = this.#e.signal ? new globalThis.Request(r.customRequest, { signal: this.#e.signal }) : new globalThis.Request(r.customRequest);
451
451
  this.#c(n);
452
452
  }
@@ -463,7 +463,7 @@ class y {
463
463
  }
464
464
  if (o instanceof globalThis.Response)
465
465
  return o;
466
- if (o === M)
466
+ if (o === I)
467
467
  return;
468
468
  }
469
469
  return this.#l(e);
@@ -502,7 +502,7 @@ const P = (t) => {
502
502
  const e = (r, s) => y.create(r, b(t, s));
503
503
  for (const r of _)
504
504
  e[r] = (s, n) => y.create(s, b(t, n, { method: r }));
505
- return e.create = (r) => P(b(r)), e.extend = (r) => (typeof r == "function" && (r = r(t ?? {})), P(b(t, r))), e.stop = M, e.retry = Z, e;
505
+ return e.create = (r) => P(b(r)), e.extend = (r) => (typeof r == "function" && (r = r(t ?? {})), P(b(t, r))), e.stop = I, e.retry = Z, e;
506
506
  }, ye = P();
507
507
  let me = class d {
508
508
  constructor({ api_key: e }) {
@@ -569,7 +569,7 @@ class be {
569
569
  return await h.get("quotes/multi-source", { searchParams: e }).json();
570
570
  }
571
571
  }
572
- class Re {
572
+ class Te {
573
573
  async getOptimalRoutes(e) {
574
574
  return await h.get("router/optimal-route", { searchParams: e }).json();
575
575
  }
@@ -583,14 +583,14 @@ class Re {
583
583
  return await h.get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
584
584
  }
585
585
  }
586
- const Te = {
587
- router: new Re(),
586
+ const Re = {
587
+ router: new Te(),
588
588
  quotes: new be(),
589
589
  intents: new we(),
590
590
  client: new ge()
591
591
  }, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
592
592
  __proto__: null,
593
- default: Te
593
+ default: Re
594
594
  }, Symbol.toStringTag, { value: "Module" }));
595
595
  function F(t) {
596
596
  var e, r, s = "";
@@ -601,11 +601,11 @@ function F(t) {
601
601
  } else for (r in t) t[r] && (s && (s += " "), s += r);
602
602
  return s;
603
603
  }
604
- function Se() {
604
+ function Ee() {
605
605
  for (var t, e, r = 0, s = "", n = arguments.length; r < n; r++) (t = arguments[r]) && (e = F(t)) && (s && (s += " "), s += e);
606
606
  return s;
607
607
  }
608
- var Ee = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t))(Ee || {}), Ae = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(Ae || {});
608
+ var Se = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(Se || {}), Ae = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(Ae || {});
609
609
  class f {
610
610
  constructor({ api_key: e }) {
611
611
  this.api_key = e;
@@ -634,24 +634,24 @@ function ke(t) {
634
634
  cancel: a,
635
635
  chainSelected: c,
636
636
  intentCreated: m,
637
- ...T
638
- } = t, [p, S] = U(!0);
637
+ ...R
638
+ } = t, [p, E] = U(!0);
639
639
  return z(() => {
640
640
  const q = document.body.style.overflow;
641
641
  o ? document.body.style.overflow = "hidden" : document.body.style.overflow = q || "";
642
- const j = (g) => {
642
+ const N = (g) => {
643
643
  g.data === "closed" && a(), g.data === "completed" && u(), g.data === "chainSelected" && c(), g.data === "intentCreated" && m();
644
644
  };
645
- return window.addEventListener("message", j), () => {
646
- document.body.style.overflow = q || "", window.removeEventListener("message", j);
645
+ return window.addEventListener("message", N), () => {
646
+ document.body.style.overflow = q || "", window.removeEventListener("message", N);
647
647
  };
648
- }, [o, a, u, c, m]), /* @__PURE__ */ N("div", {
649
- ...T,
650
- className: Se("payment-modal-wrapper", p ? "loading" : "not-loading", o ? "open" : "closed"),
648
+ }, [o, a, u, c, m]), /* @__PURE__ */ j("div", {
649
+ ...R,
650
+ className: Ee("payment-modal-wrapper", p ? "loading" : "not-loading", o ? "open" : "closed"),
651
651
  children: [p && /* @__PURE__ */ w("div", {
652
652
  role: "status",
653
653
  className: "payment-modal-loader",
654
- children: /* @__PURE__ */ N("svg", {
654
+ children: /* @__PURE__ */ j("svg", {
655
655
  "aria-hidden": "true",
656
656
  className: "icon",
657
657
  viewBox: "0 0 100 101",
@@ -669,7 +669,7 @@ function ke(t) {
669
669
  allow: "clipboard-read *; clipboard-write *",
670
670
  src: `https://chainrails-frontend.vercel.app/pay/_chain_/${s}/_token_/${r}/_to_/${e}/_amount_/${n * 100}?id=${f.getApiKey()}`,
671
671
  onLoad: () => {
672
- S(!1);
672
+ E(!1);
673
673
  },
674
674
  className: `payment-modal ${p ? "invisible" : "visible"}`
675
675
  })]
@@ -692,22 +692,22 @@ function qe(t) {
692
692
  function m() {
693
693
  c(), e?.();
694
694
  }
695
- function T() {
695
+ function R() {
696
696
  window.setTimeout(c, 2e3), r?.();
697
697
  }
698
698
  function p() {
699
699
  s?.();
700
700
  }
701
- function S() {
701
+ function E() {
702
702
  n?.();
703
703
  }
704
704
  return {
705
705
  open: a,
706
706
  close: c,
707
- complete: T,
707
+ complete: R,
708
708
  cancel: m,
709
709
  chainSelected: p,
710
- intentCreated: S,
710
+ intentCreated: E,
711
711
  isOpen: i,
712
712
  ...o
713
713
  };
@@ -716,7 +716,7 @@ export {
716
716
  Pe as CRAPI,
717
717
  f as Chainrails,
718
718
  ke as PaymentModal,
719
- Ee as chains,
719
+ Se as chains,
720
720
  Ae as tokens,
721
721
  qe as usePaymentModal
722
722
  };
@@ -1,6 +1,6 @@
1
1
  import { useState as U, useEffect as z } from "react";
2
- import { jsxs as N, jsx as w } from "react/jsx-runtime";
3
- import './index.css';class x extends Error {
2
+ import { jsxs as j, jsx as w } from "react/jsx-runtime";
3
+ import './index.css';class C extends Error {
4
4
  response;
5
5
  request;
6
6
  options;
@@ -21,7 +21,7 @@ class L extends Error {
21
21
  super(r), this.value = e;
22
22
  }
23
23
  }
24
- class E extends Error {
24
+ class S extends Error {
25
25
  name = "ForceRetryError";
26
26
  customDelay;
27
27
  code;
@@ -50,7 +50,7 @@ const v = (() => {
50
50
  throw n;
51
51
  }
52
52
  return t && !e;
53
- })(), J = typeof globalThis.AbortController == "function", I = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", V = typeof globalThis.ReadableStream == "function", K = typeof globalThis.FormData == "function", _ = ["get", "post", "put", "patch", "head", "delete"], W = {
53
+ })(), J = typeof globalThis.AbortController == "function", M = typeof globalThis.AbortSignal == "function" && typeof globalThis.AbortSignal.any == "function", V = typeof globalThis.ReadableStream == "function", K = typeof globalThis.FormData == "function", _ = ["get", "post", "put", "patch", "head", "delete"], W = {
54
54
  json: "application/json",
55
55
  text: "text/*",
56
56
  formData: "multipart/form-data",
@@ -59,14 +59,14 @@ const v = (() => {
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
- }, A = 2147483647, X = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, M = Symbol("stop");
63
- class B {
62
+ }, A = 2147483647, X = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length, I = Symbol("stop");
63
+ class H {
64
64
  options;
65
65
  constructor(e) {
66
66
  this.options = e;
67
67
  }
68
68
  }
69
- const Z = (t) => new B(t), Y = {
69
+ const Z = (t) => new H(t), Y = {
70
70
  json: !0,
71
71
  parseJson: !0,
72
72
  stringifyJson: !0,
@@ -125,7 +125,7 @@ const Z = (t) => new B(t), Y = {
125
125
  return 0;
126
126
  }
127
127
  return 0;
128
- }, H = (t, e, r) => {
128
+ }, B = (t, e, r) => {
129
129
  let s, n = 0;
130
130
  return t.pipeThrough(new TransformStream({
131
131
  transform(o, i) {
@@ -150,7 +150,7 @@ const Z = (t) => new B(t), Y = {
150
150
  headers: t.headers
151
151
  });
152
152
  const r = Math.max(0, Number(t.headers.get("content-length")) || 0);
153
- return new Response(H(t.body, r, e), {
153
+ return new Response(B(t.body, r, e), {
154
154
  status: t.status,
155
155
  statusText: t.statusText,
156
156
  headers: t.headers
@@ -162,7 +162,7 @@ const Z = (t) => new B(t), Y = {
162
162
  return new Request(t, {
163
163
  // @ts-expect-error - Types are outdated.
164
164
  duplex: "half",
165
- body: H(t.body, s, e)
165
+ body: B(t.body, s, e)
166
166
  });
167
167
  }, l = (t) => t !== null && typeof t == "object", b = (...t) => {
168
168
  for (const e of t)
@@ -175,14 +175,14 @@ const Z = (t) => new B(t), Y = {
175
175
  s && i === "undefined" || i === void 0 ? r.delete(o) : r.set(o, i);
176
176
  return r;
177
177
  };
178
- function R(t, e, r) {
178
+ function T(t, e, r) {
179
179
  return Object.hasOwn(e, r) && e[r] === void 0 ? [] : k(t[r] ?? [], e[r] ?? []);
180
180
  }
181
181
  const $ = (t = {}, e = {}) => ({
182
- beforeRequest: R(t, e, "beforeRequest"),
183
- beforeRetry: R(t, e, "beforeRetry"),
184
- afterResponse: R(t, e, "afterResponse"),
185
- beforeError: R(t, e, "beforeError")
182
+ beforeRequest: T(t, e, "beforeRequest"),
183
+ beforeRetry: T(t, e, "beforeRetry"),
184
+ afterResponse: T(t, e, "afterResponse"),
185
+ beforeError: T(t, e, "beforeError")
186
186
  }), se = (t, e) => {
187
187
  const r = new URLSearchParams();
188
188
  for (const s of [t, e])
@@ -234,7 +234,7 @@ const $ = (t = {}, e = {}) => ({
234
234
  }
235
235
  l(i.hooks) && (s = $(s, i.hooks), e.hooks = s), l(i.headers) && (r = D(r, i.headers), e.headers = r);
236
236
  }
237
- return n !== void 0 && (e.searchParams = n), o.length > 0 && (o.length === 1 ? e.signal = o[0] : I ? e.signal = AbortSignal.any(o) : e.signal = o.at(-1)), e.context === void 0 && (e.context = {}), e;
237
+ return n !== void 0 && (e.searchParams = n), o.length > 0 && (o.length === 1 ? e.signal = o[0] : M ? e.signal = AbortSignal.any(o) : e.signal = o.at(-1)), e.context === void 0 && (e.context = {}), e;
238
238
  }, ne = (t) => _.includes(t) ? t.toUpperCase() : t, oe = ["get", "put", "head", "delete", "options", "trace"], ie = [408, 413, 429, 500, 502, 503, 504], ae = [413, 429, 503], O = {
239
239
  limit: 2,
240
240
  methods: oe,
@@ -260,7 +260,7 @@ const $ = (t = {}, e = {}) => ({
260
260
  ...t
261
261
  };
262
262
  };
263
- class C extends Error {
263
+ class x 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;
@@ -269,7 +269,7 @@ class C extends Error {
269
269
  async function ce(t, e, r, s) {
270
270
  return new Promise((n, o) => {
271
271
  const i = setTimeout(() => {
272
- r && r.abort(), o(new C(t));
272
+ r && r.abort(), o(new x(t));
273
273
  }, s.timeout);
274
274
  s.fetch(t, e).then(n).catch(o).then(() => {
275
275
  clearTimeout(i);
@@ -294,10 +294,10 @@ const le = (t, e) => {
294
294
  return r;
295
295
  }, fe = (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
296
  function de(t) {
297
- return t instanceof x || t?.name === x.name;
297
+ return t instanceof C || t?.name === C.name;
298
298
  }
299
299
  function pe(t) {
300
- return t instanceof C || t?.name === C.name;
300
+ return t instanceof x || t?.name === x.name;
301
301
  }
302
302
  class y {
303
303
  static create(e, r) {
@@ -308,14 +308,14 @@ class y {
308
308
  let i = await s.#y();
309
309
  for (const u of s.#e.hooks.afterResponse) {
310
310
  const a = s.#h(i.clone()), c = await u(s.request, s.#a(), a, { retryCount: s.#r });
311
- if (c instanceof globalThis.Response && (i = c), c instanceof B)
311
+ if (c instanceof globalThis.Response && (i = c), c instanceof H)
312
312
  throw await Promise.all([
313
313
  a.body?.cancel(),
314
314
  i.body?.cancel()
315
- ]), new E(c.options);
315
+ ]), new S(c.options);
316
316
  }
317
317
  if (s.#h(i), !i.ok && (typeof s.#e.throwHttpErrors == "function" ? s.#e.throwHttpErrors(i.status) : s.#e.throwHttpErrors)) {
318
- let u = new x(i, s.request, s.#a());
318
+ let u = new C(i, s.request, s.#a());
319
319
  for (const a of s.#e.hooks.beforeError)
320
320
  u = await a(u, { retryCount: s.#r });
321
321
  throw u;
@@ -385,7 +385,7 @@ class y {
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
- J && I && (this.#n = this.#e.signal ?? this.#t.signal, this.#s = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#s.signal]) : this.#s.signal), v && (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
+ J && M && (this.#n = this.#e.signal ?? this.#t.signal, this.#s = new globalThis.AbortController(), this.#e.signal = this.#n ? AbortSignal.any([this.#n, this.#s.signal]) : this.#s.signal), v && (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 s = r.headers && new globalThis.Headers(r.headers).has("content-type");
390
390
  if (this.#t instanceof globalThis.Request && (K && this.#e.body instanceof globalThis.FormData || this.#e.body instanceof URLSearchParams) && !s && this.#e.headers.delete("content-type"), this.request = new globalThis.Request(this.#t, this.#e), fe(this.#e.searchParams)) {
391
391
  const o = "?" + (typeof this.#e.searchParams == "string" ? this.#e.searchParams.replace(/^\?/, "") : new URLSearchParams(y.#d(this.#e.searchParams)).toString()), i = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, o);
@@ -408,7 +408,7 @@ class y {
408
408
  if (this.#r++, this.#r > this.#e.retry.limit)
409
409
  throw e;
410
410
  const r = e instanceof Error ? e : new L(e);
411
- if (r instanceof E)
411
+ if (r instanceof S)
412
412
  return r.customDelay ?? this.#u();
413
413
  if (!this.#e.retry.methods.includes(this.request.method.toLowerCase()))
414
414
  throw e;
@@ -446,7 +446,7 @@ class y {
446
446
  const s = Math.min(await this.#p(r), A);
447
447
  if (this.#r < 1)
448
448
  throw r;
449
- if (await he(s, this.#n ? { signal: this.#n } : {}), r instanceof E && r.customRequest) {
449
+ if (await he(s, this.#n ? { signal: this.#n } : {}), r instanceof S && r.customRequest) {
450
450
  const n = this.#e.signal ? new globalThis.Request(r.customRequest, { signal: this.#e.signal }) : new globalThis.Request(r.customRequest);
451
451
  this.#c(n);
452
452
  }
@@ -463,7 +463,7 @@ class y {
463
463
  }
464
464
  if (o instanceof globalThis.Response)
465
465
  return o;
466
- if (o === M)
466
+ if (o === I)
467
467
  return;
468
468
  }
469
469
  return this.#l(e);
@@ -502,7 +502,7 @@ const P = (t) => {
502
502
  const e = (r, s) => y.create(r, b(t, s));
503
503
  for (const r of _)
504
504
  e[r] = (s, n) => y.create(s, b(t, n, { method: r }));
505
- return e.create = (r) => P(b(r)), e.extend = (r) => (typeof r == "function" && (r = r(t ?? {})), P(b(t, r))), e.stop = M, e.retry = Z, e;
505
+ return e.create = (r) => P(b(r)), e.extend = (r) => (typeof r == "function" && (r = r(t ?? {})), P(b(t, r))), e.stop = I, e.retry = Z, e;
506
506
  }, ye = P();
507
507
  let me = class d {
508
508
  constructor({ api_key: e }) {
@@ -569,7 +569,7 @@ class be {
569
569
  return await h.get("quotes/multi-source", { searchParams: e }).json();
570
570
  }
571
571
  }
572
- class Re {
572
+ class Te {
573
573
  async getOptimalRoutes(e) {
574
574
  return await h.get("router/optimal-route", { searchParams: e }).json();
575
575
  }
@@ -583,14 +583,14 @@ class Re {
583
583
  return await h.get("router/supported-bridges/bridge/" + e, { searchParams: r }).json();
584
584
  }
585
585
  }
586
- const Te = {
587
- router: new Re(),
586
+ const Re = {
587
+ router: new Te(),
588
588
  quotes: new be(),
589
589
  intents: new we(),
590
590
  client: new ge()
591
591
  }, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
592
592
  __proto__: null,
593
- default: Te
593
+ default: Re
594
594
  }, Symbol.toStringTag, { value: "Module" }));
595
595
  function F(t) {
596
596
  var e, r, s = "";
@@ -601,11 +601,11 @@ function F(t) {
601
601
  } else for (r in t) t[r] && (s && (s += " "), s += r);
602
602
  return s;
603
603
  }
604
- function Se() {
604
+ function Ee() {
605
605
  for (var t, e, r = 0, s = "", n = arguments.length; r < n; r++) (t = arguments[r]) && (e = F(t)) && (s && (s += " "), s += e);
606
606
  return s;
607
607
  }
608
- var Ee = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t))(Ee || {}), Ae = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(Ae || {});
608
+ var Se = /* @__PURE__ */ ((t) => (t.ARBITRUM = "ARBITRUM_MAINNET", t.ARBITRUM_TESTNET = "ARBITRUM_TESTNET", t.BASE = "BASE_MAINNET", t.BASE_TESTNET = "BASE_TESTNET", t.AVALANCHE = "AVALANCHE_MAINNET", t.AVALANCHE_TESTNET = "AVALANCHE_TESTNET", t.BSC = "BSC_MAINNET", t.ETHEREUM = "ETHEREUM_MAINNET", t.ETHEREUM_TESTNET = "ETHEREUM_TESTNET", t.STARKNET = "STARKNET_MAINNET", t))(Se || {}), Ae = /* @__PURE__ */ ((t) => (t.USDC = "USDC", t))(Ae || {});
609
609
  class f {
610
610
  constructor({ api_key: e }) {
611
611
  this.api_key = e;
@@ -634,24 +634,24 @@ function ke(t) {
634
634
  cancel: a,
635
635
  chainSelected: c,
636
636
  intentCreated: m,
637
- ...T
638
- } = t, [p, S] = U(!0);
637
+ ...R
638
+ } = t, [p, E] = U(!0);
639
639
  return z(() => {
640
640
  const q = document.body.style.overflow;
641
641
  o ? document.body.style.overflow = "hidden" : document.body.style.overflow = q || "";
642
- const j = (g) => {
642
+ const N = (g) => {
643
643
  g.data === "closed" && a(), g.data === "completed" && u(), g.data === "chainSelected" && c(), g.data === "intentCreated" && m();
644
644
  };
645
- return window.addEventListener("message", j), () => {
646
- document.body.style.overflow = q || "", window.removeEventListener("message", j);
645
+ return window.addEventListener("message", N), () => {
646
+ document.body.style.overflow = q || "", window.removeEventListener("message", N);
647
647
  };
648
- }, [o, a, u, c, m]), /* @__PURE__ */ N("div", {
649
- ...T,
650
- className: Se("payment-modal-wrapper", p ? "loading" : "not-loading", o ? "open" : "closed"),
648
+ }, [o, a, u, c, m]), /* @__PURE__ */ j("div", {
649
+ ...R,
650
+ className: Ee("payment-modal-wrapper", p ? "loading" : "not-loading", o ? "open" : "closed"),
651
651
  children: [p && /* @__PURE__ */ w("div", {
652
652
  role: "status",
653
653
  className: "payment-modal-loader",
654
- children: /* @__PURE__ */ N("svg", {
654
+ children: /* @__PURE__ */ j("svg", {
655
655
  "aria-hidden": "true",
656
656
  className: "icon",
657
657
  viewBox: "0 0 100 101",
@@ -669,7 +669,7 @@ function ke(t) {
669
669
  allow: "clipboard-read *; clipboard-write *",
670
670
  src: `https://chainrails-frontend.vercel.app/pay/_chain_/${s}/_token_/${r}/_to_/${e}/_amount_/${n * 100}?id=${f.getApiKey()}`,
671
671
  onLoad: () => {
672
- S(!1);
672
+ E(!1);
673
673
  },
674
674
  className: `payment-modal ${p ? "invisible" : "visible"}`
675
675
  })]
@@ -692,22 +692,22 @@ function qe(t) {
692
692
  function m() {
693
693
  c(), e?.();
694
694
  }
695
- function T() {
695
+ function R() {
696
696
  window.setTimeout(c, 2e3), r?.();
697
697
  }
698
698
  function p() {
699
699
  s?.();
700
700
  }
701
- function S() {
701
+ function E() {
702
702
  n?.();
703
703
  }
704
704
  return {
705
705
  open: a,
706
706
  close: c,
707
- complete: T,
707
+ complete: R,
708
708
  cancel: m,
709
709
  chainSelected: p,
710
- intentCreated: S,
710
+ intentCreated: E,
711
711
  isOpen: i,
712
712
  ...o
713
713
  };
@@ -716,7 +716,7 @@ export {
716
716
  Pe as CRAPI,
717
717
  f as Chainrails,
718
718
  ke as PaymentModal,
719
- Ee as chains,
719
+ Se as chains,
720
720
  Ae as tokens,
721
721
  qe as usePaymentModal
722
722
  };
@@ -1,2 +1,2 @@
1
1
  (function(d,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],f):(d=typeof globalThis<"u"?globalThis:d||self,f(d.Chainrails={},d.React,d.jsxRuntime))})(this,(function(d,f,y){"use strict";var q=document.createElement("style");q.textContent=`/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-duration:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-blue-600:oklch(54.6% .245 262.881);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-600:oklch(44.6% .03 256.802);--color-black:#000;--spacing:.25rem;--animate-spin:spin 1s linear infinite;--blur-xs:4px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.invisible{visibility:hidden}.visible{visibility:visible}.hidden{display:none}}.payment-modal-wrapper{inset:calc(var(--spacing)*0);z-index:10000;width:100vw;height:100dvh;transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));--tw-duration:.1s;transition-duration:.1s;position:fixed}.payment-modal-wrapper.loading{background-color:#00000026}@supports (color:color-mix(in lab,red,red)){.payment-modal-wrapper.loading{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.payment-modal-wrapper.loading{--tw-backdrop-blur:blur(2px);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.payment-modal-wrapper.not-loading{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.payment-modal-wrapper.not-loading{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.payment-modal-wrapper.not-loading{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0}.payment-modal-wrapper.open iframe{--tw-translate-y:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y);--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.payment-modal-wrapper.closed iframe{--tw-translate-y:50vh;translate:var(--tw-translate-x)var(--tw-translate-y);--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x)var(--tw-scale-y)}.payment-modal-loader{inset:calc(var(--spacing)*0);z-index:10000;place-content:center;width:100%;height:100%;display:grid;position:absolute}.payment-modal-loader .icon{height:calc(var(--spacing)*12);width:calc(var(--spacing)*12);animation:var(--animate-spin);fill:var(--color-blue-600);color:var(--color-gray-200)}@media (prefers-color-scheme:dark){.payment-modal-loader .icon{color:var(--color-gray-600)}}.payment-modal{inset:calc(var(--spacing)*0);z-index:10000;width:100%;height:100%;transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));--tw-duration:.3s;transition-duration:.3s;transition-timing-function:cubic-bezier(.25,1,.5,1);position:absolute}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@property --tw-duration{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}
2
- /*$vite$:1*/`,document.head.appendChild(q);class T extends Error{response;request;options;constructor(t,r,o){const n=t.status||t.status===0?t.status:"",i=t.statusText??"",a=`${n} ${i}`.trim(),l=a?`status code ${a}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=o}}class N extends Error{name="NonError";value;constructor(t){let r="Non-error value was thrown";try{typeof t=="string"?r=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(r=t.message)}catch{}super(r),this.value=t}}class R extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const r=t?.cause?t.cause instanceof Error?t.cause:new N(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",r?{cause:r}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const z=(()=>{let e=!1,t=!1;const r=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(r&&o)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),K=typeof globalThis.AbortController=="function",O=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",W=typeof globalThis.ReadableStream=="function",X=typeof globalThis.FormData=="function",U=["get","post","put","patch","head","delete"],Z={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},S=2147483647,Y=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,M=Symbol("stop");class L{options;constructor(t){this.options=t}}const G=e=>new L(e),Q={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},tt={next:!0},et={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},rt=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,o]of e)t+=Y,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{const t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},I=(e,t,r)=>{let o,n=0;return e.pipeThrough(new TransformStream({transform(i,a){if(a.enqueue(i),o){n+=o.byteLength;let l=t===0?0:n/t;l>=1&&(l=1-Number.EPSILON),r?.({percent:l,totalBytes:Math.max(t,n),transferredBytes:n},o)}o=i},flush(){o&&(n+=o.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},o))}}))},ot=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const r=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(I(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},nt=(e,t,r)=>{if(!e.body)return e;const o=rt(r??e.body);return new Request(e,{duplex:"half",body:I(e.body,o,t)})},h=e=>e!==null&&typeof e=="object",g=(...e)=>{for(const t of e)if((!h(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return E({},...e)},_=(e={},t={})=>{const r=new globalThis.Headers(e),o=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[i,a]of n.entries())o&&a==="undefined"||a===void 0?r.delete(i):r.set(i,a);return r};function k(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:E(e[r]??[],t[r]??[])}const B=(e={},t={})=>({beforeRequest:k(e,t,"beforeRequest"),beforeRetry:k(e,t,"beforeRetry"),afterResponse:k(e,t,"afterResponse"),beforeError:k(e,t,"beforeError")}),it=(e,t)=>{const r=new URLSearchParams;for(const o of[e,t])if(o!==void 0)if(o instanceof URLSearchParams)for(const[n,i]of o.entries())r.append(n,i);else if(Array.isArray(o))for(const n of o){if(!Array.isArray(n)||n.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(n[0]),String(n[1]))}else if(h(o))for(const[n,i]of Object.entries(o))i!==void 0&&r.append(n,String(i));else{const n=new URLSearchParams(o);for(const[i,a]of n.entries())r.append(i,a)}return r},E=(...e)=>{let t={},r={},o={},n;const i=[];for(const a of e)if(Array.isArray(a))Array.isArray(t)||(t=[]),t=[...t,...a];else if(h(a)){for(let[l,s]of Object.entries(a)){if(l==="signal"&&s instanceof globalThis.AbortSignal){i.push(s);continue}if(l==="context"){if(s!=null&&(!h(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");t={...t,context:s==null?{}:{...t.context,...s}};continue}if(l==="searchParams"){s==null?n=void 0:n=n===void 0?s:it(n,s);continue}h(s)&&l in t&&(s=E(t[l],s)),t={...t,[l]:s}}h(a.hooks)&&(o=B(o,a.hooks),t.hooks=o),h(a.headers)&&(r=_(r,a.headers),t.headers=r)}return n!==void 0&&(t.searchParams=n),i.length>0&&(i.length===1?t.signal=i[0]:O?t.signal=AbortSignal.any(i):t.signal=i.at(-1)),t.context===void 0&&(t.context={}),t},at=e=>U.includes(e)?e.toUpperCase():e,H={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},st=(e={})=>{if(typeof e=="number")return{...H,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...H,...e}};class A extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function lt(e,t,r,o){return new Promise((n,i)=>{const a=setTimeout(()=>{r&&r.abort(),i(new A(e))},o.timeout);o.fetch(e,t).then(n).catch(i).then(()=>{clearTimeout(a)})})}async function ct(e,{signal:t}){return new Promise((r,o)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(i),o(t.reason)}const i=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}const dt=(e,t)=>{const r={};for(const o in t)Object.hasOwn(t,o)&&!(o in et)&&!(o in Q)&&(!(o in e)||o in tt)&&(r[o]=t[o]);return r},ut=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;function pt(e){return e instanceof T||e?.name===T.name}function ft(e){return e instanceof A||e?.name===A.name}class m{static create(t,r){const o=new m(t,r),n=async()=>{if(typeof o.#t.timeout=="number"&&o.#t.timeout>S)throw new RangeError(`The \`timeout\` option cannot be greater than ${S}`);await Promise.resolve();let a=await o.#y();for(const l of o.#t.hooks.afterResponse){const s=o.#d(a.clone()),c=await l(o.request,o.#s(),s,{retryCount:o.#r});if(c instanceof globalThis.Response&&(a=c),c instanceof L)throw await Promise.all([s.body?.cancel(),a.body?.cancel()]),new R(c.options)}if(o.#d(a),!a.ok&&(typeof o.#t.throwHttpErrors=="function"?o.#t.throwHttpErrors(a.status):o.#t.throwHttpErrors)){let l=new T(a,o.request,o.#s());for(const s of o.#t.hooks.beforeError)l=await s(l,{retryCount:o.#r});throw l}if(o.#t.onDownloadProgress){if(typeof o.#t.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!W)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return ot(a.clone(),o.#t.onDownloadProgress)}return a},i=o.#u(n).finally(async()=>{const a=o.#i,l=[];a&&!a.bodyUsed&&l.push(a.body?.cancel()),o.request.bodyUsed||l.push(o.request.body?.cancel()),await Promise.all(l)});for(const[a,l]of Object.entries(Z))a==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[a]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||l);const s=await i;if(a==="json"){if(s.status===204)return"";const c=await s.text();return c===""?"":r.parseJson?r.parseJson(c):JSON.parse(c)}return s[a]()});return i}static#f(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;#o;#r=0;#e;#t;#i;#n;#a;constructor(t,r={}){if(this.#e=t,this.#t={...r,headers:_(this.#e.headers,r.headers),hooks:B({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:at(r.method??this.#e.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:st(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},typeof this.#e!="string"&&!(this.#e instanceof URL||this.#e instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#t.prefixUrl&&typeof this.#e=="string"){if(this.#e.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#t.prefixUrl.endsWith("/")||(this.#t.prefixUrl+="/"),this.#e=this.#t.prefixUrl+this.#e}K&&O&&(this.#n=this.#t.signal??this.#e.signal,this.#o=new globalThis.AbortController,this.#t.signal=this.#n?AbortSignal.any([this.#n,this.#o.signal]):this.#o.signal),z&&(this.#t.duplex="half"),this.#t.json!==void 0&&(this.#t.body=this.#t.stringifyJson?.(this.#t.json)??JSON.stringify(this.#t.json),this.#t.headers.set("content-type",this.#t.headers.get("content-type")??"application/json"));const o=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#e instanceof globalThis.Request&&(X&&this.#t.body instanceof globalThis.FormData||this.#t.body instanceof URLSearchParams)&&!o&&this.#t.headers.delete("content-type"),this.request=new globalThis.Request(this.#e,this.#t),ut(this.#t.searchParams)){const i="?"+(typeof this.#t.searchParams=="string"?this.#t.searchParams.replace(/^\?/,""):new URLSearchParams(m.#f(this.#t.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(a,this.#t)}if(this.#t.onUploadProgress){if(typeof this.#t.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!z)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#t.body??void 0)}}#l(){const t=this.#t.retry.delay(this.#r);let r=t;return this.#t.retry.jitter===!0?r=Math.random()*t:typeof this.#t.retry.jitter=="function"&&(r=this.#t.retry.jitter(t),(!Number.isFinite(r)||r<0)&&(r=t)),Math.min(this.#t.retry.backoffLimit,r)}async#h(t){if(this.#r++,this.#r>this.#t.retry.limit)throw t;const r=t instanceof Error?t:new N(t);if(r instanceof R)return r.customDelay??this.#l();if(!this.#t.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#t.retry.shouldRetry!==void 0){const o=await this.#t.retry.shouldRetry({error:r,retryCount:this.#r});if(o===!1)throw t;if(o===!0)return this.#l()}if(ft(t)&&!this.#t.retry.retryOnTimeout)throw t;if(pt(t)){if(!this.#t.retry.statusCodes.includes(t.response.status))throw t;const o=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");if(o&&this.#t.retry.afterStatusCodes.includes(t.response.status)){let n=Number(o)*1e3;Number.isNaN(n)?n=Date.parse(o)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const i=this.#t.retry.maxRetryAfter??n;return n<i?n:i}if(t.response.status===413)throw t}return this.#l()}#d(t){return this.#t.parseJson&&(t.json=async()=>this.#t.parseJson(await t.text())),t}async#u(t){try{return await t()}catch(r){const o=Math.min(await this.#h(r),S);if(this.#r<1)throw r;if(await ct(o,this.#n?{signal:this.#n}:{}),r instanceof R&&r.customRequest){const n=this.#t.signal?new globalThis.Request(r.customRequest,{signal:this.#t.signal}):new globalThis.Request(r.customRequest);this.#c(n)}for(const n of this.#t.hooks.beforeRetry){const i=await n({request:this.request,options:this.#s(),error:r,retryCount:this.#r});if(i instanceof globalThis.Request){this.#c(i);break}if(i instanceof globalThis.Response)return i;if(i===M)return}return this.#u(t)}}async#y(){this.#o?.signal.aborted&&(this.#o=new globalThis.AbortController,this.#t.signal=this.#n?AbortSignal.any([this.#n,this.#o.signal]):this.#o.signal,this.request=new globalThis.Request(this.request,{signal:this.#t.signal}));for(const r of this.#t.hooks.beforeRequest){const o=await r(this.request,this.#s(),{retryCount:this.#r});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#c(o);break}}const t=dt(this.request,this.#t);return this.#i=this.request,this.request=this.#i.clone(),this.#t.timeout===!1?this.#t.fetch(this.#i,t):lt(this.#i,t,this.#o,this.#t)}#s(){if(!this.#a){const{hooks:t,...r}=this.#t;this.#a=Object.freeze(r)}return this.#a}#c(t){this.#a=void 0,this.request=this.#p(t)}#p(t,r){return!this.#t.onUploadProgress||!t.body?t:nt(t,this.#t.onUploadProgress,r??this.#t.body??void 0)}}/*! MIT License © Sindre Sorhus */const C=e=>{const t=(r,o)=>m.create(r,g(e,o));for(const r of U)t[r]=(o,n)=>m.create(o,g(e,n,{method:r}));return t.create=r=>C(g(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),C(g(e,r))),t.stop=M,t.retry=G,t},ht=C();let yt=class b{constructor({api_key:t}){this.api_key=t}static config(t){if(!b.app){if(!t)throw new Error("Please provide an api_key");b.app=new b(t)}return t&&(this.app.api_key=t.api_key),b.app}static getApiKey(){return b.app.api_key}};const u=ht.create({prefixUrl:"https://dev.chainrails.io/api/v1",headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=yt.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,r)=>r]},retry:{limit:2}});class bt{async getClientInfo(){return await u.get("client/auth/client-info").json()}}class mt{async getById(t){return await u.get("intents/"+t).json()}async getForSender(t){return await u.get("intents/user/"+t).json()}async getForAddress(t){return await u.get("intents/address/"+t).json()}async getAll(t){return await u.get("intents",{searchParams:t}).json()}async create(t){return await u.post("intents",{json:t}).json()}async update(t,r){return await u.post("intents",{json:r}).json()}}class wt{async getAll(t){return await u.get("quotes/multi-source",{searchParams:t}).json()}}class gt{async getOptimalRoutes(t){return await u.get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await u.get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await u.get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,r){return await u.get("router/supported-bridges/bridge/"+t,{searchParams:r}).json()}}const kt={router:new gt,quotes:new wt,intents:new mt,client:new bt},vt=Object.freeze(Object.defineProperty({__proto__:null,default:kt},Symbol.toStringTag,{value:"Module"}));function $(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=$(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function xt(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=$(e))&&(o&&(o+=" "),o+=t);return o}var D=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e))(D||{}),F=(e=>(e.USDC="USDC",e))(F||{});class p{constructor({api_key:t}){this.api_key=t}static config(t){if(!p.app){if(!t)throw new Error("Please provide an api_key");p.app=new p(t)}return t&&(this.app.api_key=t.api_key),p.app}static getApiKey(){return p.app.api_key}}function Tt(e){const{to:t,token:r,chain:o,amount:n,isOpen:i,close:a,complete:l,cancel:s,chainSelected:c,intentCreated:v,...j}=e,[w,P]=f.useState(!0);return f.useEffect(()=>{const J=document.body.style.overflow;i?document.body.style.overflow="hidden":document.body.style.overflow=J||"";const V=x=>{x.data==="closed"&&s(),x.data==="completed"&&l(),x.data==="chainSelected"&&c(),x.data==="intentCreated"&&v()};return window.addEventListener("message",V),()=>{document.body.style.overflow=J||"",window.removeEventListener("message",V)}},[i,s,l,c,v]),y.jsxs("div",{...j,className:xt("payment-modal-wrapper",w?"loading":"not-loading",i?"open":"closed"),children:[w&&y.jsx("div",{role:"status",className:"payment-modal-loader",children:y.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{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",fill:"currentColor"}),y.jsx("path",{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",fill:"currentFill"})]})}),y.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:`https://chainrails-frontend.vercel.app/pay/_chain_/${o}/_token_/${r}/_to_/${t}/_amount_/${n*100}?id=${p.getApiKey()}`,onLoad:()=>{P(!1)},className:`payment-modal ${w?"invisible":"visible"}`})]})}function Rt(e){const{onCancel:t,onSuccess:r,onChainSelect:o,onIntentCreate:n,...i}=e,[a,l]=f.useState(!1);function s(){l(!0)}function c(){l(!1)}function v(){c(),t?.()}function j(){window.setTimeout(c,2e3),r?.()}function w(){o?.()}function P(){n?.()}return{open:s,close:c,complete:j,cancel:v,chainSelected:w,intentCreated:P,isOpen:a,...i}}d.CRAPI=vt,d.Chainrails=p,d.PaymentModal=Tt,d.chains=D,d.tokens=F,d.usePaymentModal=Rt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
2
+ /*$vite$:1*/`,document.head.appendChild(q);class x extends Error{response;request;options;constructor(t,r,o){const n=t.status||t.status===0?t.status:"",i=t.statusText??"",a=`${n} ${i}`.trim(),l=a?`status code ${a}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=o}}class N extends Error{name="NonError";value;constructor(t){let r="Non-error value was thrown";try{typeof t=="string"?r=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(r=t.message)}catch{}super(r),this.value=t}}class R extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const r=t?.cause?t.cause instanceof Error?t.cause:new N(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",r?{cause:r}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const M=(()=>{let e=!1,t=!1;const r=typeof globalThis.ReadableStream=="function",o=typeof globalThis.Request=="function";if(r&&o)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(n){if(n instanceof Error&&n.message==="unsupported BodyInit type")return!1;throw n}return e&&!t})(),K=typeof globalThis.AbortController=="function",U=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",W=typeof globalThis.ReadableStream=="function",X=typeof globalThis.FormData=="function",z=["get","post","put","patch","head","delete"],Z={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},S=2147483647,Y=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,O=Symbol("stop");class _{options;constructor(t){this.options=t}}const G=e=>new _(e),Q={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},tt={next:!0},et={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},rt=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[r,o]of e)t+=Y,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${r}"`).length,t+=typeof o=="string"?new TextEncoder().encode(o).length:o.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{const t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},L=(e,t,r)=>{let o,n=0;return e.pipeThrough(new TransformStream({transform(i,a){if(a.enqueue(i),o){n+=o.byteLength;let l=t===0?0:n/t;l>=1&&(l=1-Number.EPSILON),r?.({percent:l,totalBytes:Math.max(t,n),transferredBytes:n},o)}o=i},flush(){o&&(n+=o.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},o))}}))},ot=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const r=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(L(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},nt=(e,t,r)=>{if(!e.body)return e;const o=rt(r??e.body);return new Request(e,{duplex:"half",body:L(e.body,o,t)})},h=e=>e!==null&&typeof e=="object",g=(...e)=>{for(const t of e)if((!h(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return E({},...e)},I=(e={},t={})=>{const r=new globalThis.Headers(e),o=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[i,a]of n.entries())o&&a==="undefined"||a===void 0?r.delete(i):r.set(i,a);return r};function k(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:E(e[r]??[],t[r]??[])}const H=(e={},t={})=>({beforeRequest:k(e,t,"beforeRequest"),beforeRetry:k(e,t,"beforeRetry"),afterResponse:k(e,t,"afterResponse"),beforeError:k(e,t,"beforeError")}),it=(e,t)=>{const r=new URLSearchParams;for(const o of[e,t])if(o!==void 0)if(o instanceof URLSearchParams)for(const[n,i]of o.entries())r.append(n,i);else if(Array.isArray(o))for(const n of o){if(!Array.isArray(n)||n.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");r.append(String(n[0]),String(n[1]))}else if(h(o))for(const[n,i]of Object.entries(o))i!==void 0&&r.append(n,String(i));else{const n=new URLSearchParams(o);for(const[i,a]of n.entries())r.append(i,a)}return r},E=(...e)=>{let t={},r={},o={},n;const i=[];for(const a of e)if(Array.isArray(a))Array.isArray(t)||(t=[]),t=[...t,...a];else if(h(a)){for(let[l,s]of Object.entries(a)){if(l==="signal"&&s instanceof globalThis.AbortSignal){i.push(s);continue}if(l==="context"){if(s!=null&&(!h(s)||Array.isArray(s)))throw new TypeError("The `context` option must be an object");t={...t,context:s==null?{}:{...t.context,...s}};continue}if(l==="searchParams"){s==null?n=void 0:n=n===void 0?s:it(n,s);continue}h(s)&&l in t&&(s=E(t[l],s)),t={...t,[l]:s}}h(a.hooks)&&(o=H(o,a.hooks),t.hooks=o),h(a.headers)&&(r=I(r,a.headers),t.headers=r)}return n!==void 0&&(t.searchParams=n),i.length>0&&(i.length===1?t.signal=i[0]:U?t.signal=AbortSignal.any(i):t.signal=i.at(-1)),t.context===void 0&&(t.context={}),t},at=e=>z.includes(e)?e.toUpperCase():e,B={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},st=(e={})=>{if(typeof e=="number")return{...B,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...B,...e}};class A extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function lt(e,t,r,o){return new Promise((n,i)=>{const a=setTimeout(()=>{r&&r.abort(),i(new A(e))},o.timeout);o.fetch(e,t).then(n).catch(i).then(()=>{clearTimeout(a)})})}async function ct(e,{signal:t}){return new Promise((r,o)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",n,{once:!0}));function n(){clearTimeout(i),o(t.reason)}const i=setTimeout(()=>{t?.removeEventListener("abort",n),r()},e)})}const dt=(e,t)=>{const r={};for(const o in t)Object.hasOwn(t,o)&&!(o in et)&&!(o in Q)&&(!(o in e)||o in tt)&&(r[o]=t[o]);return r},ut=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;function pt(e){return e instanceof x||e?.name===x.name}function ft(e){return e instanceof A||e?.name===A.name}class m{static create(t,r){const o=new m(t,r),n=async()=>{if(typeof o.#t.timeout=="number"&&o.#t.timeout>S)throw new RangeError(`The \`timeout\` option cannot be greater than ${S}`);await Promise.resolve();let a=await o.#y();for(const l of o.#t.hooks.afterResponse){const s=o.#d(a.clone()),c=await l(o.request,o.#s(),s,{retryCount:o.#r});if(c instanceof globalThis.Response&&(a=c),c instanceof _)throw await Promise.all([s.body?.cancel(),a.body?.cancel()]),new R(c.options)}if(o.#d(a),!a.ok&&(typeof o.#t.throwHttpErrors=="function"?o.#t.throwHttpErrors(a.status):o.#t.throwHttpErrors)){let l=new x(a,o.request,o.#s());for(const s of o.#t.hooks.beforeError)l=await s(l,{retryCount:o.#r});throw l}if(o.#t.onDownloadProgress){if(typeof o.#t.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!W)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return ot(a.clone(),o.#t.onDownloadProgress)}return a},i=o.#u(n).finally(async()=>{const a=o.#i,l=[];a&&!a.bodyUsed&&l.push(a.body?.cancel()),o.request.bodyUsed||l.push(o.request.body?.cancel()),await Promise.all(l)});for(const[a,l]of Object.entries(Z))a==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[a]=async()=>{o.request.headers.set("accept",o.request.headers.get("accept")||l);const s=await i;if(a==="json"){if(s.status===204)return"";const c=await s.text();return c===""?"":r.parseJson?r.parseJson(c):JSON.parse(c)}return s[a]()});return i}static#f(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;#o;#r=0;#e;#t;#i;#n;#a;constructor(t,r={}){if(this.#e=t,this.#t={...r,headers:I(this.#e.headers,r.headers),hooks:H({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:at(r.method??this.#e.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:st(r.retry),throwHttpErrors:r.throwHttpErrors??!0,timeout:r.timeout??1e4,fetch:r.fetch??globalThis.fetch.bind(globalThis),context:r.context??{}},typeof this.#e!="string"&&!(this.#e instanceof URL||this.#e instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#t.prefixUrl&&typeof this.#e=="string"){if(this.#e.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#t.prefixUrl.endsWith("/")||(this.#t.prefixUrl+="/"),this.#e=this.#t.prefixUrl+this.#e}K&&U&&(this.#n=this.#t.signal??this.#e.signal,this.#o=new globalThis.AbortController,this.#t.signal=this.#n?AbortSignal.any([this.#n,this.#o.signal]):this.#o.signal),M&&(this.#t.duplex="half"),this.#t.json!==void 0&&(this.#t.body=this.#t.stringifyJson?.(this.#t.json)??JSON.stringify(this.#t.json),this.#t.headers.set("content-type",this.#t.headers.get("content-type")??"application/json"));const o=r.headers&&new globalThis.Headers(r.headers).has("content-type");if(this.#e instanceof globalThis.Request&&(X&&this.#t.body instanceof globalThis.FormData||this.#t.body instanceof URLSearchParams)&&!o&&this.#t.headers.delete("content-type"),this.request=new globalThis.Request(this.#e,this.#t),ut(this.#t.searchParams)){const i="?"+(typeof this.#t.searchParams=="string"?this.#t.searchParams.replace(/^\?/,""):new URLSearchParams(m.#f(this.#t.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(a,this.#t)}if(this.#t.onUploadProgress){if(typeof this.#t.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!M)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#t.body??void 0)}}#l(){const t=this.#t.retry.delay(this.#r);let r=t;return this.#t.retry.jitter===!0?r=Math.random()*t:typeof this.#t.retry.jitter=="function"&&(r=this.#t.retry.jitter(t),(!Number.isFinite(r)||r<0)&&(r=t)),Math.min(this.#t.retry.backoffLimit,r)}async#h(t){if(this.#r++,this.#r>this.#t.retry.limit)throw t;const r=t instanceof Error?t:new N(t);if(r instanceof R)return r.customDelay??this.#l();if(!this.#t.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#t.retry.shouldRetry!==void 0){const o=await this.#t.retry.shouldRetry({error:r,retryCount:this.#r});if(o===!1)throw t;if(o===!0)return this.#l()}if(ft(t)&&!this.#t.retry.retryOnTimeout)throw t;if(pt(t)){if(!this.#t.retry.statusCodes.includes(t.response.status))throw t;const o=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");if(o&&this.#t.retry.afterStatusCodes.includes(t.response.status)){let n=Number(o)*1e3;Number.isNaN(n)?n=Date.parse(o)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());const i=this.#t.retry.maxRetryAfter??n;return n<i?n:i}if(t.response.status===413)throw t}return this.#l()}#d(t){return this.#t.parseJson&&(t.json=async()=>this.#t.parseJson(await t.text())),t}async#u(t){try{return await t()}catch(r){const o=Math.min(await this.#h(r),S);if(this.#r<1)throw r;if(await ct(o,this.#n?{signal:this.#n}:{}),r instanceof R&&r.customRequest){const n=this.#t.signal?new globalThis.Request(r.customRequest,{signal:this.#t.signal}):new globalThis.Request(r.customRequest);this.#c(n)}for(const n of this.#t.hooks.beforeRetry){const i=await n({request:this.request,options:this.#s(),error:r,retryCount:this.#r});if(i instanceof globalThis.Request){this.#c(i);break}if(i instanceof globalThis.Response)return i;if(i===O)return}return this.#u(t)}}async#y(){this.#o?.signal.aborted&&(this.#o=new globalThis.AbortController,this.#t.signal=this.#n?AbortSignal.any([this.#n,this.#o.signal]):this.#o.signal,this.request=new globalThis.Request(this.request,{signal:this.#t.signal}));for(const r of this.#t.hooks.beforeRequest){const o=await r(this.request,this.#s(),{retryCount:this.#r});if(o instanceof Response)return o;if(o instanceof globalThis.Request){this.#c(o);break}}const t=dt(this.request,this.#t);return this.#i=this.request,this.request=this.#i.clone(),this.#t.timeout===!1?this.#t.fetch(this.#i,t):lt(this.#i,t,this.#o,this.#t)}#s(){if(!this.#a){const{hooks:t,...r}=this.#t;this.#a=Object.freeze(r)}return this.#a}#c(t){this.#a=void 0,this.request=this.#p(t)}#p(t,r){return!this.#t.onUploadProgress||!t.body?t:nt(t,this.#t.onUploadProgress,r??this.#t.body??void 0)}}/*! MIT License © Sindre Sorhus */const C=e=>{const t=(r,o)=>m.create(r,g(e,o));for(const r of z)t[r]=(o,n)=>m.create(o,g(e,n,{method:r}));return t.create=r=>C(g(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),C(g(e,r))),t.stop=O,t.retry=G,t},ht=C();let yt=class b{constructor({api_key:t}){this.api_key=t}static config(t){if(!b.app){if(!t)throw new Error("Please provide an api_key");b.app=new b(t)}return t&&(this.app.api_key=t.api_key),b.app}static getApiKey(){return b.app.api_key}};const u=ht.create({prefixUrl:"https://dev.chainrails.io/api/v1",headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=yt.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,r)=>r]},retry:{limit:2}});class bt{async getClientInfo(){return await u.get("client/auth/client-info").json()}}class mt{async getById(t){return await u.get("intents/"+t).json()}async getForSender(t){return await u.get("intents/user/"+t).json()}async getForAddress(t){return await u.get("intents/address/"+t).json()}async getAll(t){return await u.get("intents",{searchParams:t}).json()}async create(t){return await u.post("intents",{json:t}).json()}async update(t,r){return await u.post("intents",{json:r}).json()}}class wt{async getAll(t){return await u.get("quotes/multi-source",{searchParams:t}).json()}}class gt{async getOptimalRoutes(t){return await u.get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await u.get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await u.get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,r){return await u.get("router/supported-bridges/bridge/"+t,{searchParams:r}).json()}}const kt={router:new gt,quotes:new wt,intents:new mt,client:new bt},vt=Object.freeze(Object.defineProperty({__proto__:null,default:kt},Symbol.toStringTag,{value:"Module"}));function $(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var n=e.length;for(t=0;t<n;t++)e[t]&&(r=$(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function Tt(){for(var e,t,r=0,o="",n=arguments.length;r<n;r++)(e=arguments[r])&&(t=$(e))&&(o&&(o+=" "),o+=t);return o}var D=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e.BSC="BSC_MAINNET",e.ETHEREUM="ETHEREUM_MAINNET",e.ETHEREUM_TESTNET="ETHEREUM_TESTNET",e.STARKNET="STARKNET_MAINNET",e))(D||{}),F=(e=>(e.USDC="USDC",e))(F||{});class p{constructor({api_key:t}){this.api_key=t}static config(t){if(!p.app){if(!t)throw new Error("Please provide an api_key");p.app=new p(t)}return t&&(this.app.api_key=t.api_key),p.app}static getApiKey(){return p.app.api_key}}function xt(e){const{to:t,token:r,chain:o,amount:n,isOpen:i,close:a,complete:l,cancel:s,chainSelected:c,intentCreated:v,...j}=e,[w,P]=f.useState(!0);return f.useEffect(()=>{const J=document.body.style.overflow;i?document.body.style.overflow="hidden":document.body.style.overflow=J||"";const V=T=>{T.data==="closed"&&s(),T.data==="completed"&&l(),T.data==="chainSelected"&&c(),T.data==="intentCreated"&&v()};return window.addEventListener("message",V),()=>{document.body.style.overflow=J||"",window.removeEventListener("message",V)}},[i,s,l,c,v]),y.jsxs("div",{...j,className:Tt("payment-modal-wrapper",w?"loading":"not-loading",i?"open":"closed"),children:[w&&y.jsx("div",{role:"status",className:"payment-modal-loader",children:y.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[y.jsx("path",{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",fill:"currentColor"}),y.jsx("path",{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",fill:"currentFill"})]})}),y.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:`https://chainrails-frontend.vercel.app/pay/_chain_/${o}/_token_/${r}/_to_/${t}/_amount_/${n*100}?id=${p.getApiKey()}`,onLoad:()=>{P(!1)},className:`payment-modal ${w?"invisible":"visible"}`})]})}function Rt(e){const{onCancel:t,onSuccess:r,onChainSelect:o,onIntentCreate:n,...i}=e,[a,l]=f.useState(!1);function s(){l(!0)}function c(){l(!1)}function v(){c(),t?.()}function j(){window.setTimeout(c,2e3),r?.()}function w(){o?.()}function P(){n?.()}return{open:s,close:c,complete:j,cancel:v,chainSelected:w,intentCreated:P,isOpen:a,...i}}d.CRAPI=vt,d.Chainrails=p,d.PaymentModal=xt,d.chains=D,d.tokens=F,d.usePaymentModal=Rt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sideEffects": [
4
4
  "**/*.css"
5
5
  ],
6
- "version": "0.0.8",
6
+ "version": "0.0.9",
7
7
  "description": "",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -54,8 +54,8 @@
54
54
  "vite-plugin-lib-inject-css": "^2.2.2"
55
55
  },
56
56
  "dependencies": {
57
- "@chainrails/common": "^0.0.3",
58
- "@chainrails/sdk": "^0.0.3",
57
+ "@chainrails/common": "^0.0.4",
58
+ "@chainrails/sdk": "^0.0.4",
59
59
  "@tailwindcss/vite": "^4.1.14",
60
60
  "clsx": "^2.1.1",
61
61
  "dotenv": "^17.2.3",