@arcadeai/design-system 1.5.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/{arcade-DSu1Vp41.js → arcade-DzMbb7xi.js} +512 -586
  2. package/dist/components/index.js +302 -300
  3. package/dist/components/ui/atoms/alert-dialog.d.ts +14 -0
  4. package/dist/components/ui/atoms/alert-dialog.js +248 -0
  5. package/dist/components/ui/atoms/command.js +1 -1
  6. package/dist/components/ui/atoms/dialog.js +1 -1
  7. package/dist/components/ui/atoms/icons/codesandbox.d.ts +3 -0
  8. package/dist/components/ui/atoms/icons/codesandbox.js +26 -0
  9. package/dist/components/ui/atoms/icons/index.d.ts +1 -0
  10. package/dist/components/ui/atoms/icons/index.js +182 -180
  11. package/dist/components/ui/atoms/index.js +285 -283
  12. package/dist/components/ui/atoms/sheet.js +1 -1
  13. package/dist/components/ui/index.js +302 -300
  14. package/dist/components/ui/molecules/toolkit-picker-trigger.js +29 -32
  15. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-filter.test.js +2 -2
  16. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-search.test.js +2 -2
  17. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker-selection.test.js +2 -2
  18. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.d.ts +11 -3
  19. package/dist/components/ui/organisms/toolkit-picker/hooks/use-toolkit-picker.js +141 -99
  20. package/dist/components/ui/organisms/toolkit-picker/index.d.ts +2 -0
  21. package/dist/components/ui/organisms/toolkit-picker/index.js +3 -2
  22. package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.d.ts +2 -0
  23. package/dist/components/ui/organisms/toolkit-picker/mocks/toolkit-collection.js +247 -55
  24. package/dist/components/ui/organisms/toolkit-picker/toolkit-picker.test.js +2 -2
  25. package/dist/components/ui/utils/memo.test.js +1 -1
  26. package/dist/{index-BzU0xzeS.js → index-Dkey23PG.js} +3 -1
  27. package/dist/lib/arcade/arcade.js +3 -2
  28. package/dist/lib/arcade/arcade.test.js +2 -2
  29. package/dist/lib/utils.test.js +1 -1
  30. package/dist/main.js +313 -311
  31. package/dist/metadata/oauth-providers.js +9 -9
  32. package/dist/metadata/toolkits.js +383 -227
  33. package/dist/metadata/types.d.ts +2 -1
  34. package/dist/{react.esm-CFMQn0EI.js → react.esm-CAxz4dXo.js} +1 -1
  35. package/dist/{vi.bdSIJ99Y-CQ1FdEM8.js → vi.bdSIJ99Y-hyudrc3R.js} +3880 -3436
  36. package/dist/web-sgv-FK6q.js +84 -0
  37. package/package.json +2 -1
@@ -1,24 +1,25 @@
1
- import { TOOLKIT_CATALOGUE as tt } from "./metadata/toolkits.js";
2
- import { r as pe } from "./utils-Db4QWi-E.js";
3
- const Y = "RFC3986", Z = {
1
+ import { k as _e, s as Qe, g as Ge, F as de, f as Je, a as Ye, b as Ze } from "./web-sgv-FK6q.js";
2
+ import { TOOLKIT_CATALOGUE as et } from "./metadata/toolkits.js";
3
+ import { r as he } from "./utils-Db4QWi-E.js";
4
+ const J = "RFC3986", Y = {
4
5
  RFC1738: (t) => String(t).replace(/%20/g, "+"),
5
6
  RFC3986: (t) => String(t)
6
- }, rt = "RFC1738", nt = Array.isArray, _ = (() => {
7
+ }, tt = "RFC1738", nt = Array.isArray, _ = (() => {
7
8
  const t = [];
8
9
  for (let e = 0; e < 256; ++e)
9
10
  t.push("%" + ((e < 16 ? "0" : "") + e.toString(16)).toUpperCase());
10
11
  return t;
11
- })(), V = 1024, st = (t, e, r, n, s) => {
12
+ })(), W = 1024, rt = (t, e, n, r, s) => {
12
13
  if (t.length === 0)
13
14
  return t;
14
15
  let o = t;
15
- if (typeof t == "symbol" ? o = Symbol.prototype.toString.call(t) : typeof t != "string" && (o = String(t)), r === "iso-8859-1")
16
+ if (typeof t == "symbol" ? o = Symbol.prototype.toString.call(t) : typeof t != "string" && (o = String(t)), n === "iso-8859-1")
16
17
  return escape(o).replace(/%u[0-9a-f]{4}/gi, function(l) {
17
18
  return "%26%23" + parseInt(l.slice(2), 16) + "%3B";
18
19
  });
19
20
  let i = "";
20
- for (let l = 0; l < o.length; l += V) {
21
- const c = o.length >= V ? o.slice(l, l + V) : o, u = [];
21
+ for (let l = 0; l < o.length; l += W) {
22
+ const c = o.length >= W ? o.slice(l, l + W) : o, u = [];
22
23
  for (let p = 0; p < c.length; ++p) {
23
24
  let a = c.charCodeAt(p);
24
25
  if (a === 45 || // -
@@ -28,7 +29,7 @@ const Y = "RFC3986", Z = {
28
29
  a >= 48 && a <= 57 || // 0-9
29
30
  a >= 65 && a <= 90 || // a-z
30
31
  a >= 97 && a <= 122 || // A-Z
31
- s === rt && (a === 40 || a === 41)) {
32
+ s === tt && (a === 40 || a === 41)) {
32
33
  u[u.length] = c.charAt(p);
33
34
  continue;
34
35
  }
@@ -50,19 +51,19 @@ const Y = "RFC3986", Z = {
50
51
  }
51
52
  return i;
52
53
  };
53
- function ot(t) {
54
+ function st(t) {
54
55
  return !t || typeof t != "object" ? !1 : !!(t.constructor && t.constructor.isBuffer && t.constructor.isBuffer(t));
55
56
  }
56
- function ye(t, e) {
57
+ function pe(t, e) {
57
58
  if (nt(t)) {
58
- const r = [];
59
- for (let n = 0; n < t.length; n += 1)
60
- r.push(e(t[n]));
61
- return r;
59
+ const n = [];
60
+ for (let r = 0; r < t.length; r += 1)
61
+ n.push(e(t[r]));
62
+ return n;
62
63
  }
63
64
  return e(t);
64
65
  }
65
- const it = Object.prototype.hasOwnProperty, Re = {
66
+ const ot = Object.prototype.hasOwnProperty, Ae = {
66
67
  brackets(t) {
67
68
  return String(t) + "[]";
68
69
  },
@@ -73,9 +74,9 @@ const it = Object.prototype.hasOwnProperty, Re = {
73
74
  repeat(t) {
74
75
  return String(t);
75
76
  }
76
- }, A = Array.isArray, at = Array.prototype.push, Se = function(t, e) {
77
- at.apply(t, A(e) ? e : [e]);
78
- }, ct = Date.prototype.toISOString, y = {
77
+ }, A = Array.isArray, it = Array.prototype.push, Se = function(t, e) {
78
+ it.apply(t, A(e) ? e : [e]);
79
+ }, at = Date.prototype.toISOString, y = {
79
80
  addQueryPrefix: !1,
80
81
  allowDots: !1,
81
82
  allowEmptyArrays: !1,
@@ -85,103 +86,103 @@ const it = Object.prototype.hasOwnProperty, Re = {
85
86
  delimiter: "&",
86
87
  encode: !0,
87
88
  encodeDotInKeys: !1,
88
- encoder: st,
89
+ encoder: rt,
89
90
  encodeValuesOnly: !1,
90
- format: Y,
91
- formatter: Z[Y],
91
+ format: J,
92
+ formatter: Y[J],
92
93
  /** @deprecated */
93
94
  indices: !1,
94
95
  serializeDate(t) {
95
- return ct.call(t);
96
+ return at.call(t);
96
97
  },
97
98
  skipNulls: !1,
98
99
  strictNullHandling: !1
99
100
  };
100
- function ut(t) {
101
+ function ct(t) {
101
102
  return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || typeof t == "symbol" || typeof t == "bigint";
102
103
  }
103
- const Q = {};
104
- function Ee(t, e, r, n, s, o, i, l, c, u, p, a, h, m, x, E, R, X) {
105
- let f = t, F = X, $ = 0, le = !1;
106
- for (; (F = F.get(Q)) !== void 0 && !le; ) {
107
- const g = F.get(t);
108
- if ($ += 1, typeof g < "u") {
109
- if (g === $)
104
+ const V = {};
105
+ function Re(t, e, n, r, s, o, i, l, c, u, p, a, h, m, b, E, S, z) {
106
+ let f = t, D = z, U = 0, ce = !1;
107
+ for (; (D = D.get(V)) !== void 0 && !ce; ) {
108
+ const g = D.get(t);
109
+ if (U += 1, typeof g < "u") {
110
+ if (g === U)
110
111
  throw new RangeError("Cyclic object value");
111
- le = !0;
112
+ ce = !0;
112
113
  }
113
- typeof F.get(Q) > "u" && ($ = 0);
114
+ typeof D.get(V) > "u" && (U = 0);
114
115
  }
115
- if (typeof u == "function" ? f = u(e, f) : f instanceof Date ? f = h?.(f) : r === "comma" && A(f) && (f = ye(f, function(g) {
116
+ if (typeof u == "function" ? f = u(e, f) : f instanceof Date ? f = h?.(f) : n === "comma" && A(f) && (f = pe(f, function(g) {
116
117
  return g instanceof Date ? h?.(g) : g;
117
118
  })), f === null) {
118
119
  if (o)
119
120
  return c && !E ? (
120
121
  // @ts-expect-error
121
- c(e, y.encoder, R, "key", m)
122
+ c(e, y.encoder, S, "key", m)
122
123
  ) : e;
123
124
  f = "";
124
125
  }
125
- if (ut(f) || ot(f)) {
126
+ if (ct(f) || st(f)) {
126
127
  if (c) {
127
- const g = E ? e : c(e, y.encoder, R, "key", m);
128
+ const g = E ? e : c(e, y.encoder, S, "key", m);
128
129
  return [
129
- x?.(g) + "=" + // @ts-expect-error
130
- x?.(c(f, y.encoder, R, "value", m))
130
+ b?.(g) + "=" + // @ts-expect-error
131
+ b?.(c(f, y.encoder, S, "value", m))
131
132
  ];
132
133
  }
133
- return [x?.(e) + "=" + x?.(String(f))];
134
+ return [b?.(e) + "=" + b?.(String(f))];
134
135
  }
135
- const K = [];
136
+ const X = [];
136
137
  if (typeof f > "u")
137
- return K;
138
+ return X;
138
139
  let I;
139
- if (r === "comma" && A(f))
140
- E && c && (f = ye(f, c)), I = [{ value: f.length > 0 ? f.join(",") || null : void 0 }];
140
+ if (n === "comma" && A(f))
141
+ E && c && (f = pe(f, c)), I = [{ value: f.length > 0 ? f.join(",") || null : void 0 }];
141
142
  else if (A(u))
142
143
  I = u;
143
144
  else {
144
145
  const g = Object.keys(f);
145
146
  I = p ? g.sort(p) : g;
146
147
  }
147
- const fe = l ? String(e).replace(/\./g, "%2E") : String(e), j = n && A(f) && f.length === 1 ? fe + "[]" : fe;
148
+ const ue = l ? String(e).replace(/\./g, "%2E") : String(e), $ = r && A(f) && f.length === 1 ? ue + "[]" : ue;
148
149
  if (s && A(f) && f.length === 0)
149
- return j + "[]";
150
+ return $ + "[]";
150
151
  for (let g = 0; g < I.length; ++g) {
151
- const k = I[g], de = (
152
+ const k = I[g], le = (
152
153
  // @ts-ignore
153
154
  typeof k == "object" && typeof k.value < "u" ? k.value : f[k]
154
155
  );
155
- if (i && de === null)
156
+ if (i && le === null)
156
157
  continue;
157
- const W = a && l ? k.replace(/\./g, "%2E") : k, et = A(f) ? typeof r == "function" ? r(j, W) : j : j + (a ? "." + W : "[" + W + "]");
158
- X.set(t, $);
159
- const he = /* @__PURE__ */ new WeakMap();
160
- he.set(Q, X), Se(K, Ee(
161
- de,
162
- et,
163
- r,
158
+ const K = a && l ? k.replace(/\./g, "%2E") : k, Ve = A(f) ? typeof n == "function" ? n($, K) : $ : $ + (a ? "." + K : "[" + K + "]");
159
+ z.set(t, U);
160
+ const fe = /* @__PURE__ */ new WeakMap();
161
+ fe.set(V, z), Se(X, Re(
162
+ le,
163
+ Ve,
164
164
  n,
165
+ r,
165
166
  s,
166
167
  o,
167
168
  i,
168
169
  l,
169
170
  // @ts-ignore
170
- r === "comma" && E && A(f) ? null : c,
171
+ n === "comma" && E && A(f) ? null : c,
171
172
  u,
172
173
  p,
173
174
  a,
174
175
  h,
175
176
  m,
176
- x,
177
+ b,
177
178
  E,
178
- R,
179
- he
179
+ S,
180
+ fe
180
181
  ));
181
182
  }
182
- return K;
183
+ return X;
183
184
  }
184
- function lt(t = y) {
185
+ function ut(t = y) {
185
186
  if (typeof t.allowEmptyArrays < "u" && typeof t.allowEmptyArrays != "boolean")
186
187
  throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");
187
188
  if (typeof t.encodeDotInKeys < "u" && typeof t.encodeDotInKeys != "boolean")
@@ -191,17 +192,17 @@ function lt(t = y) {
191
192
  const e = t.charset || y.charset;
192
193
  if (typeof t.charset < "u" && t.charset !== "utf-8" && t.charset !== "iso-8859-1")
193
194
  throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
194
- let r = Y;
195
+ let n = J;
195
196
  if (typeof t.format < "u") {
196
- if (!it.call(Z, t.format))
197
+ if (!ot.call(Y, t.format))
197
198
  throw new TypeError("Unknown format option provided.");
198
- r = t.format;
199
+ n = t.format;
199
200
  }
200
- const n = Z[r];
201
+ const r = Y[n];
201
202
  let s = y.filter;
202
203
  (typeof t.filter == "function" || A(t.filter)) && (s = t.filter);
203
204
  let o;
204
- if (t.arrayFormat && t.arrayFormat in Re ? o = t.arrayFormat : "indices" in t ? o = t.indices ? "indices" : "repeat" : o = y.arrayFormat, "commaRoundTrip" in t && typeof t.commaRoundTrip != "boolean")
205
+ if (t.arrayFormat && t.arrayFormat in Ae ? o = t.arrayFormat : "indices" in t ? o = t.indices ? "indices" : "repeat" : o = y.arrayFormat, "commaRoundTrip" in t && typeof t.commaRoundTrip != "boolean")
205
206
  throw new TypeError("`commaRoundTrip` must be a boolean, or absent");
206
207
  const i = typeof t.allowDots > "u" ? t.encodeDotInKeys ? !0 : y.allowDots : !!t.allowDots;
207
208
  return {
@@ -219,8 +220,8 @@ function lt(t = y) {
219
220
  encoder: typeof t.encoder == "function" ? t.encoder : y.encoder,
220
221
  encodeValuesOnly: typeof t.encodeValuesOnly == "boolean" ? t.encodeValuesOnly : y.encodeValuesOnly,
221
222
  filter: s,
222
- format: r,
223
- formatter: n,
223
+ format: n,
224
+ formatter: r,
224
225
  serializeDate: typeof t.serializeDate == "function" ? t.serializeDate : y.serializeDate,
225
226
  skipNulls: typeof t.skipNulls == "boolean" ? t.skipNulls : y.skipNulls,
226
227
  // @ts-ignore
@@ -228,249 +229,175 @@ function lt(t = y) {
228
229
  strictNullHandling: typeof t.strictNullHandling == "boolean" ? t.strictNullHandling : y.strictNullHandling
229
230
  };
230
231
  }
231
- function ft(t, e = {}) {
232
- let r = t;
233
- const n = lt(e);
232
+ function lt(t, e = {}) {
233
+ let n = t;
234
+ const r = ut(e);
234
235
  let s, o;
235
- typeof n.filter == "function" ? (o = n.filter, r = o("", r)) : A(n.filter) && (o = n.filter, s = o);
236
+ typeof r.filter == "function" ? (o = r.filter, n = o("", n)) : A(r.filter) && (o = r.filter, s = o);
236
237
  const i = [];
237
- if (typeof r != "object" || r === null)
238
+ if (typeof n != "object" || n === null)
238
239
  return "";
239
- const l = Re[n.arrayFormat], c = l === "comma" && n.commaRoundTrip;
240
- s || (s = Object.keys(r)), n.sort && s.sort(n.sort);
240
+ const l = Ae[r.arrayFormat], c = l === "comma" && r.commaRoundTrip;
241
+ s || (s = Object.keys(n)), r.sort && s.sort(r.sort);
241
242
  const u = /* @__PURE__ */ new WeakMap();
242
243
  for (let h = 0; h < s.length; ++h) {
243
244
  const m = s[h];
244
- n.skipNulls && r[m] === null || Se(i, Ee(
245
- r[m],
245
+ r.skipNulls && n[m] === null || Se(i, Re(
246
+ n[m],
246
247
  m,
247
248
  // @ts-expect-error
248
249
  l,
249
250
  c,
250
- n.allowEmptyArrays,
251
- n.strictNullHandling,
252
- n.skipNulls,
253
- n.encodeDotInKeys,
254
- n.encode ? n.encoder : null,
255
- n.filter,
256
- n.sort,
257
- n.allowDots,
258
- n.serializeDate,
259
- n.format,
260
- n.formatter,
261
- n.encodeValuesOnly,
262
- n.charset,
251
+ r.allowEmptyArrays,
252
+ r.strictNullHandling,
253
+ r.skipNulls,
254
+ r.encodeDotInKeys,
255
+ r.encode ? r.encoder : null,
256
+ r.filter,
257
+ r.sort,
258
+ r.allowDots,
259
+ r.serializeDate,
260
+ r.format,
261
+ r.formatter,
262
+ r.encodeValuesOnly,
263
+ r.charset,
263
264
  u
264
265
  ));
265
266
  }
266
- const p = i.join(n.delimiter);
267
- let a = n.addQueryPrefix === !0 ? "?" : "";
268
- return n.charsetSentinel && (n.charset === "iso-8859-1" ? a += "utf8=%26%2310003%3B&" : a += "utf8=%E2%9C%93&"), p.length > 0 ? a + p : "";
267
+ const p = i.join(r.delimiter);
268
+ let a = r.addQueryPrefix === !0 ? "?" : "";
269
+ return r.charsetSentinel && (r.charset === "iso-8859-1" ? a += "utf8=%26%2310003%3B&" : a += "utf8=%E2%9C%93&"), p.length > 0 ? a + p : "";
269
270
  }
270
271
  const T = "1.9.1";
271
272
  class P extends Error {
272
273
  }
273
274
  class w extends P {
274
- constructor(e, r, n, s) {
275
- super(`${w.makeMessage(e, r, n)}`), this.status = e, this.headers = s, this.error = r;
275
+ constructor(e, n, r, s) {
276
+ super(`${w.makeMessage(e, n, r)}`), this.status = e, this.headers = s, this.error = n;
276
277
  }
277
- static makeMessage(e, r, n) {
278
- const s = r?.message ? typeof r.message == "string" ? r.message : JSON.stringify(r.message) : r ? JSON.stringify(r) : n;
278
+ static makeMessage(e, n, r) {
279
+ const s = n?.message ? typeof n.message == "string" ? n.message : JSON.stringify(n.message) : n ? JSON.stringify(n) : r;
279
280
  return e && s ? `${e} ${s}` : e ? `${e} status code (no body)` : s || "(no status code or body)";
280
281
  }
281
- static generate(e, r, n, s) {
282
+ static generate(e, n, r, s) {
282
283
  if (!e || !s)
283
- return new q({ message: n, cause: re(r) });
284
- const o = r;
285
- return e === 400 ? new ke(e, o, n, s) : e === 401 ? new Te(e, o, n, s) : e === 403 ? new ve(e, o, n, s) : e === 404 ? new Ce(e, o, n, s) : e === 409 ? new Ie(e, o, n, s) : e === 422 ? new De(e, o, n, s) : e === 429 ? new Le(e, o, n, s) : e >= 500 ? new Oe(e, o, n, s) : new w(e, o, n, s);
284
+ return new F({ message: r, cause: ee(n) });
285
+ const o = n;
286
+ return e === 400 ? new Pe(e, o, r, s) : e === 401 ? new ke(e, o, r, s) : e === 403 ? new Te(e, o, r, s) : e === 404 ? new Ce(e, o, r, s) : e === 409 ? new ve(e, o, r, s) : e === 422 ? new Ie(e, o, r, s) : e === 429 ? new Le(e, o, r, s) : e >= 500 ? new Oe(e, o, r, s) : new w(e, o, r, s);
286
287
  }
287
288
  }
288
- class ee extends w {
289
+ class Z extends w {
289
290
  constructor({ message: e } = {}) {
290
291
  super(void 0, void 0, e || "Request was aborted.", void 0);
291
292
  }
292
293
  }
293
- class q extends w {
294
- constructor({ message: e, cause: r }) {
295
- super(void 0, void 0, e || "Connection error.", void 0), r && (this.cause = r);
294
+ class F extends w {
295
+ constructor({ message: e, cause: n }) {
296
+ super(void 0, void 0, e || "Connection error.", void 0), n && (this.cause = n);
296
297
  }
297
298
  }
298
- class Pe extends q {
299
+ class Ee extends F {
299
300
  constructor({ message: e } = {}) {
300
301
  super({ message: e ?? "Request timed out." });
301
302
  }
302
303
  }
304
+ class Pe extends w {
305
+ }
303
306
  class ke extends w {
304
307
  }
305
308
  class Te extends w {
306
309
  }
307
- class ve extends w {
308
- }
309
310
  class Ce extends w {
310
311
  }
311
- class Ie extends w {
312
+ class ve extends w {
312
313
  }
313
- class De extends w {
314
+ class Ie extends w {
314
315
  }
315
316
  class Le extends w {
316
317
  }
317
318
  class Oe extends w {
318
319
  }
319
- let me = !1, D, Fe, te, $e, je;
320
- function Ue(t, e = { auto: !1 }) {
321
- if (me)
322
- throw new Error(`you must \`import '@arcadeai/arcadejs/shims/${t.kind}'\` before importing anything else from @arcadeai/arcadejs`);
323
- if (D)
324
- throw new Error(`can't \`import '@arcadeai/arcadejs/shims/${t.kind}'\` after \`import '@arcadeai/arcadejs/shims/${D}'\``);
325
- me = e.auto, D = t.kind, Fe = t.fetch, t.Request, t.Response, t.Headers, t.FormData, t.Blob, te = t.File, t.ReadableStream, t.getMultipartRequestOptions, $e = t.getDefaultAgent, je = t.fileFromPath, t.isFsReadStream;
326
- }
327
- class dt {
328
- constructor(e) {
329
- this.body = e;
330
- }
331
- get [Symbol.toStringTag]() {
332
- return "MultipartBody";
333
- }
334
- }
335
- function Be({ manuallyImported: t } = {}) {
336
- const e = t ? "You may need to use polyfills" : "Add one of these imports before your first `import … from '@arcadeai/arcadejs'`:\n- `import '@arcadeai/arcadejs/shims/node'` (if you're running on Node)\n- `import '@arcadeai/arcadejs/shims/web'` (otherwise)\n";
337
- let r, n, s, o;
338
- try {
339
- r = fetch, n = Request, s = Response, o = Headers;
340
- } catch (i) {
341
- throw new Error(`this environment is missing the following Web Fetch API type: ${i.message}. ${e}`);
342
- }
343
- return {
344
- kind: "web",
345
- fetch: r,
346
- Request: n,
347
- Response: s,
348
- Headers: o,
349
- FormData: (
350
- // @ts-ignore
351
- typeof FormData < "u" ? FormData : class {
352
- // @ts-ignore
353
- constructor() {
354
- throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${e}`);
355
- }
356
- }
357
- ),
358
- Blob: typeof Blob < "u" ? Blob : class {
359
- constructor() {
360
- throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${e}`);
361
- }
362
- },
363
- File: (
364
- // @ts-ignore
365
- typeof File < "u" ? File : class {
366
- // @ts-ignore
367
- constructor() {
368
- throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${e}`);
369
- }
370
- }
371
- ),
372
- ReadableStream: (
373
- // @ts-ignore
374
- typeof ReadableStream < "u" ? ReadableStream : class {
375
- // @ts-ignore
376
- constructor() {
377
- throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${e}`);
378
- }
379
- }
380
- ),
381
- getMultipartRequestOptions: async (i, l) => ({
382
- ...l,
383
- body: new dt(i)
384
- }),
385
- getDefaultAgent: (i) => {
386
- },
387
- fileFromPath: () => {
388
- throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/ArcadeAI/arcade-js#file-uploads");
389
- },
390
- isFsReadStream: (i) => !1
391
- };
392
- }
393
- const Me = () => {
394
- D || Ue(Be(), { auto: !0 });
320
+ const De = () => {
321
+ _e || Qe(Ge(), { auto: !0 });
395
322
  };
396
- Me();
397
- const ht = (t) => t != null && typeof t == "object" && typeof t.url == "string" && typeof t.blob == "function", pt = (t) => t != null && typeof t == "object" && typeof t.name == "string" && typeof t.lastModified == "number" && N(t), N = (t) => t != null && typeof t == "object" && typeof t.size == "number" && typeof t.type == "string" && typeof t.text == "function" && typeof t.slice == "function" && typeof t.arrayBuffer == "function";
398
- async function yt(t, e, r) {
399
- if (t = await t, pt(t))
323
+ De();
324
+ const ft = (t) => t != null && typeof t == "object" && typeof t.url == "string" && typeof t.blob == "function", dt = (t) => t != null && typeof t == "object" && typeof t.name == "string" && typeof t.lastModified == "number" && q(t), q = (t) => t != null && typeof t == "object" && typeof t.size == "number" && typeof t.type == "string" && typeof t.text == "function" && typeof t.slice == "function" && typeof t.arrayBuffer == "function";
325
+ async function ht(t, e, n) {
326
+ if (t = await t, dt(t))
400
327
  return t;
401
- if (ht(t)) {
328
+ if (ft(t)) {
402
329
  const s = await t.blob();
403
330
  e || (e = new URL(t.url).pathname.split(/[\\/]/).pop() ?? "unknown_file");
404
- const o = N(s) ? [await s.arrayBuffer()] : [s];
405
- return new te(o, e, r);
331
+ const o = q(s) ? [await s.arrayBuffer()] : [s];
332
+ return new de(o, e, n);
406
333
  }
407
- const n = await mt(t);
408
- if (e || (e = wt(t) ?? "unknown_file"), !r?.type) {
409
- const s = n[0]?.type;
410
- typeof s == "string" && (r = { ...r, type: s });
334
+ const r = await pt(t);
335
+ if (e || (e = mt(t) ?? "unknown_file"), !n?.type) {
336
+ const s = r[0]?.type;
337
+ typeof s == "string" && (n = { ...n, type: s });
411
338
  }
412
- return new te(n, e, r);
339
+ return new de(r, e, n);
413
340
  }
414
- async function mt(t) {
341
+ async function pt(t) {
415
342
  let e = [];
416
343
  if (typeof t == "string" || ArrayBuffer.isView(t) || // includes Uint8Array, Buffer, etc.
417
344
  t instanceof ArrayBuffer)
418
345
  e.push(t);
419
- else if (N(t))
346
+ else if (q(t))
420
347
  e.push(await t.arrayBuffer());
421
- else if (bt(t))
422
- for await (const r of t)
423
- e.push(r);
348
+ else if (gt(t))
349
+ for await (const n of t)
350
+ e.push(n);
424
351
  else
425
- throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${gt(t)}`);
352
+ throw new Error(`Unexpected data type: ${typeof t}; constructor: ${t?.constructor?.name}; props: ${yt(t)}`);
426
353
  return e;
427
354
  }
428
- function gt(t) {
429
- return `[${Object.getOwnPropertyNames(t).map((r) => `"${r}"`).join(", ")}]`;
355
+ function yt(t) {
356
+ return `[${Object.getOwnPropertyNames(t).map((n) => `"${n}"`).join(", ")}]`;
430
357
  }
431
- function wt(t) {
432
- return G(t.name) || G(t.filename) || // For fs.ReadStream
433
- G(t.path)?.split(/[\\/]/).pop();
358
+ function mt(t) {
359
+ return Q(t.name) || Q(t.filename) || // For fs.ReadStream
360
+ Q(t.path)?.split(/[\\/]/).pop();
434
361
  }
435
- const G = (t) => {
362
+ const Q = (t) => {
436
363
  if (typeof t == "string")
437
364
  return t;
438
365
  if (typeof Buffer < "u" && t instanceof Buffer)
439
366
  return String(t);
440
- }, bt = (t) => t != null && typeof t == "object" && typeof t[Symbol.asyncIterator] == "function", ge = (t) => t && typeof t == "object" && t.body && t[Symbol.toStringTag] === "MultipartBody";
441
- var qe = function(t, e, r, n, s) {
442
- if (n === "m") throw new TypeError("Private method is not writable");
443
- if (n === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
367
+ }, gt = (t) => t != null && typeof t == "object" && typeof t[Symbol.asyncIterator] == "function", ye = (t) => t && typeof t == "object" && t.body && t[Symbol.toStringTag] === "MultipartBody";
368
+ var Ue = function(t, e, n, r, s) {
369
+ if (r === "m") throw new TypeError("Private method is not writable");
370
+ if (r === "a" && !s) throw new TypeError("Private accessor was defined without a setter");
444
371
  if (typeof e == "function" ? t !== e || !s : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
445
- return n === "a" ? s.call(t, r) : s ? s.value = r : e.set(t, r), r;
446
- }, Ne = function(t, e, r, n) {
447
- if (r === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
448
- if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
449
- return r === "m" ? n : r === "a" ? n.call(t) : n ? n.value : e.get(t);
450
- }, M, U;
451
- Me();
452
- async function He(t) {
372
+ return r === "a" ? s.call(t, n) : s ? s.value = n : e.set(t, n), n;
373
+ }, $e = function(t, e, n, r) {
374
+ if (n === "a" && !r) throw new TypeError("Private accessor was defined without a getter");
375
+ if (typeof e == "function" ? t !== e || !r : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
376
+ return n === "m" ? r : n === "a" ? r.call(t) : r ? r.value : e.get(t);
377
+ }, M, j;
378
+ De();
379
+ async function je(t) {
453
380
  const { response: e } = t;
454
381
  if (e.status === 204)
455
382
  return null;
456
383
  if (t.options.__binaryResponse)
457
384
  return e;
458
- const n = e.headers.get("content-type")?.split(";")[0]?.trim();
459
- if (n?.includes("application/json") || n?.endsWith("+json")) {
385
+ const r = e.headers.get("content-type")?.split(";")[0]?.trim();
386
+ if (r?.includes("application/json") || r?.endsWith("+json")) {
460
387
  const i = await e.json();
461
388
  return L("response", e.status, e.url, e.headers, i), i;
462
389
  }
463
390
  const o = await e.text();
464
391
  return L("response", e.status, e.url, e.headers, o), o;
465
392
  }
466
- class H extends Promise {
467
- constructor(e, r = He) {
468
- super((n) => {
469
- n(null);
470
- }), this.responsePromise = e, this.parseResponse = r;
393
+ class B extends Promise {
394
+ constructor(e, n = je) {
395
+ super((r) => {
396
+ r(null);
397
+ }), this.responsePromise = e, this.parseResponse = n;
471
398
  }
472
399
  _thenUnwrap(e) {
473
- return new H(this.responsePromise, async (r) => e(await this.parseResponse(r), r));
400
+ return new B(this.responsePromise, async (n) => e(await this.parseResponse(n), n));
474
401
  }
475
402
  /**
476
403
  * Gets the raw `Response` instance instead of parsing the response
@@ -502,14 +429,14 @@ class H extends Promise {
502
429
  * - `import '@arcadeai/arcadejs/shims/web'` (otherwise)
503
430
  */
504
431
  async withResponse() {
505
- const [e, r] = await Promise.all([this.parse(), this.asResponse()]);
506
- return { data: e, response: r };
432
+ const [e, n] = await Promise.all([this.parse(), this.asResponse()]);
433
+ return { data: e, response: n };
507
434
  }
508
435
  parse() {
509
436
  return this.parsedPromise || (this.parsedPromise = this.responsePromise.then(this.parseResponse)), this.parsedPromise;
510
437
  }
511
- then(e, r) {
512
- return this.parse().then(e, r);
438
+ then(e, n) {
439
+ return this.parse().then(e, n);
513
440
  }
514
441
  catch(e) {
515
442
  return this.parse().catch(e);
@@ -518,17 +445,17 @@ class H extends Promise {
518
445
  return this.parse().finally(e);
519
446
  }
520
447
  }
521
- class xt {
448
+ class wt {
522
449
  constructor({
523
450
  baseURL: e,
524
- baseURLOverridden: r,
525
- maxRetries: n = 2,
451
+ baseURLOverridden: n,
452
+ maxRetries: r = 2,
526
453
  timeout: s = 6e4,
527
454
  // 1 minute
528
455
  httpAgent: o,
529
456
  fetch: i
530
457
  }) {
531
- M.set(this, void 0), this.baseURL = e, qe(this, M, r, "f"), this.maxRetries = J("maxRetries", n), this.timeout = J("timeout", s), this.httpAgent = o, this.fetch = i ?? Fe;
458
+ M.set(this, void 0), this.baseURL = e, Ue(this, M, n, "f"), this.maxRetries = G("maxRetries", r), this.timeout = G("timeout", s), this.httpAgent = o, this.fetch = i ?? Je;
532
459
  }
533
460
  authHeaders(e) {
534
461
  return {};
@@ -546,41 +473,41 @@ class xt {
546
473
  Accept: "application/json",
547
474
  ...["head", "get"].includes(e.method) ? {} : { "Content-Type": "application/json" },
548
475
  "User-Agent": this.getUserAgent(),
549
- ...kt(),
476
+ ...Et(),
550
477
  ...this.authHeaders(e)
551
478
  };
552
479
  }
553
480
  /**
554
481
  * Override this to add your own headers validation:
555
482
  */
556
- validateHeaders(e, r) {
483
+ validateHeaders(e, n) {
557
484
  }
558
485
  defaultIdempotencyKey() {
559
- return `stainless-node-retry-${Dt()}`;
486
+ return `stainless-node-retry-${vt()}`;
560
487
  }
561
- get(e, r) {
562
- return this.methodRequest("get", e, r);
488
+ get(e, n) {
489
+ return this.methodRequest("get", e, n);
563
490
  }
564
- post(e, r) {
565
- return this.methodRequest("post", e, r);
491
+ post(e, n) {
492
+ return this.methodRequest("post", e, n);
566
493
  }
567
- patch(e, r) {
568
- return this.methodRequest("patch", e, r);
494
+ patch(e, n) {
495
+ return this.methodRequest("patch", e, n);
569
496
  }
570
- put(e, r) {
571
- return this.methodRequest("put", e, r);
497
+ put(e, n) {
498
+ return this.methodRequest("put", e, n);
572
499
  }
573
- delete(e, r) {
574
- return this.methodRequest("delete", e, r);
500
+ delete(e, n) {
501
+ return this.methodRequest("delete", e, n);
575
502
  }
576
- methodRequest(e, r, n) {
577
- return this.request(Promise.resolve(n).then(async (s) => {
578
- const o = s && N(s?.body) ? new DataView(await s.body.arrayBuffer()) : s?.body instanceof DataView ? s.body : s?.body instanceof ArrayBuffer ? new DataView(s.body) : s && ArrayBuffer.isView(s?.body) ? new DataView(s.body.buffer) : s?.body;
579
- return { method: e, path: r, ...s, body: o };
503
+ methodRequest(e, n, r) {
504
+ return this.request(Promise.resolve(r).then(async (s) => {
505
+ const o = s && q(s?.body) ? new DataView(await s.body.arrayBuffer()) : s?.body instanceof DataView ? s.body : s?.body instanceof ArrayBuffer ? new DataView(s.body) : s && ArrayBuffer.isView(s?.body) ? new DataView(s.body.buffer) : s?.body;
506
+ return { method: e, path: n, ...s, body: o };
580
507
  }));
581
508
  }
582
- getAPIList(e, r, n) {
583
- return this.requestAPIList(r, { method: "get", path: e, ...n });
509
+ getAPIList(e, n, r) {
510
+ return this.requestAPIList(n, { method: "get", path: e, ...r });
584
511
  }
585
512
  calculateContentLength(e) {
586
513
  if (typeof e == "string") {
@@ -592,27 +519,27 @@ class xt {
592
519
  return e.byteLength.toString();
593
520
  return null;
594
521
  }
595
- async buildRequest(e, { retryCount: r = 0 } = {}) {
596
- const n = { ...e }, { method: s, path: o, query: i, defaultBaseURL: l, headers: c = {} } = n, u = ArrayBuffer.isView(n.body) || n.__binaryRequest && typeof n.body == "string" ? n.body : ge(n.body) ? n.body.body : n.body ? JSON.stringify(n.body, null, 2) : null, p = this.calculateContentLength(u), a = this.buildURL(o, i, l);
597
- "timeout" in n && J("timeout", n.timeout), n.timeout = n.timeout ?? this.timeout;
598
- const h = n.httpAgent ?? this.httpAgent ?? $e(a), m = n.timeout + 1e3;
522
+ async buildRequest(e, { retryCount: n = 0 } = {}) {
523
+ const r = { ...e }, { method: s, path: o, query: i, defaultBaseURL: l, headers: c = {} } = r, u = ArrayBuffer.isView(r.body) || r.__binaryRequest && typeof r.body == "string" ? r.body : ye(r.body) ? r.body.body : r.body ? JSON.stringify(r.body, null, 2) : null, p = this.calculateContentLength(u), a = this.buildURL(o, i, l);
524
+ "timeout" in r && G("timeout", r.timeout), r.timeout = r.timeout ?? this.timeout;
525
+ const h = r.httpAgent ?? this.httpAgent ?? Ye(a), m = r.timeout + 1e3;
599
526
  typeof h?.options?.timeout == "number" && m > (h.options.timeout ?? 0) && (h.options.timeout = m), this.idempotencyHeader && s !== "get" && (e.idempotencyKey || (e.idempotencyKey = this.defaultIdempotencyKey()), c[this.idempotencyHeader] = e.idempotencyKey);
600
- const x = this.buildHeaders({ options: n, headers: c, contentLength: p, retryCount: r });
527
+ const b = this.buildHeaders({ options: r, headers: c, contentLength: p, retryCount: n });
601
528
  return { req: {
602
529
  method: s,
603
530
  ...u && { body: u },
604
- headers: x,
531
+ headers: b,
605
532
  ...h && { agent: h },
606
533
  // @ts-ignore node-fetch uses a custom AbortSignal type that is
607
534
  // not compatible with standard web types
608
- signal: n.signal ?? null
609
- }, url: a, timeout: n.timeout };
535
+ signal: r.signal ?? null
536
+ }, url: a, timeout: r.timeout };
610
537
  }
611
- buildHeaders({ options: e, headers: r, contentLength: n, retryCount: s }) {
538
+ buildHeaders({ options: e, headers: n, contentLength: r, retryCount: s }) {
612
539
  const o = {};
613
- n && (o["content-length"] = n);
540
+ r && (o["content-length"] = r);
614
541
  const i = this.defaultHeaders(e);
615
- return Ae(o, i), Ae(o, r), ge(e.body) && D !== "node" && delete o["content-type"], B(i, "x-stainless-retry-count") === void 0 && B(r, "x-stainless-retry-count") === void 0 && (o["x-stainless-retry-count"] = String(s)), B(i, "x-stainless-timeout") === void 0 && B(r, "x-stainless-timeout") === void 0 && e.timeout && (o["x-stainless-timeout"] = String(Math.trunc(e.timeout / 1e3))), this.validateHeaders(o, r), o;
542
+ return be(o, i), be(o, n), ye(e.body) && _e !== "node" && delete o["content-type"], N(i, "x-stainless-retry-count") === void 0 && N(n, "x-stainless-retry-count") === void 0 && (o["x-stainless-retry-count"] = String(s)), N(i, "x-stainless-timeout") === void 0 && N(n, "x-stainless-timeout") === void 0 && e.timeout && (o["x-stainless-timeout"] = String(Math.trunc(e.timeout / 1e3))), this.validateHeaders(o, n), o;
616
543
  }
617
544
  /**
618
545
  * Used as a callback for mutating the given `FinalRequestOptions` object.
@@ -625,65 +552,65 @@ class xt {
625
552
  * This is useful for cases where you want to add certain headers based off of
626
553
  * the request properties, e.g. `method` or `url`.
627
554
  */
628
- async prepareRequest(e, { url: r, options: n }) {
555
+ async prepareRequest(e, { url: n, options: r }) {
629
556
  }
630
557
  parseHeaders(e) {
631
- return e ? Symbol.iterator in e ? Object.fromEntries(Array.from(e).map((r) => [...r])) : { ...e } : {};
558
+ return e ? Symbol.iterator in e ? Object.fromEntries(Array.from(e).map((n) => [...n])) : { ...e } : {};
632
559
  }
633
- makeStatusError(e, r, n, s) {
634
- return w.generate(e, r, n, s);
560
+ makeStatusError(e, n, r, s) {
561
+ return w.generate(e, n, r, s);
635
562
  }
636
- request(e, r = null) {
637
- return new H(this.makeRequest(e, r));
563
+ request(e, n = null) {
564
+ return new B(this.makeRequest(e, n));
638
565
  }
639
- async makeRequest(e, r) {
640
- const n = await e, s = n.maxRetries ?? this.maxRetries;
641
- r == null && (r = s), await this.prepareOptions(n);
642
- const { req: o, url: i, timeout: l } = await this.buildRequest(n, {
643
- retryCount: s - r
566
+ async makeRequest(e, n) {
567
+ const r = await e, s = r.maxRetries ?? this.maxRetries;
568
+ n == null && (n = s), await this.prepareOptions(r);
569
+ const { req: o, url: i, timeout: l } = await this.buildRequest(r, {
570
+ retryCount: s - n
644
571
  });
645
- if (await this.prepareRequest(o, { url: i, options: n }), L("request", i, n, o.headers), n.signal?.aborted)
646
- throw new ee();
647
- const c = new AbortController(), u = await this.fetchWithTimeout(i, o, l, c).catch(re);
572
+ if (await this.prepareRequest(o, { url: i, options: r }), L("request", i, r, o.headers), r.signal?.aborted)
573
+ throw new Z();
574
+ const c = new AbortController(), u = await this.fetchWithTimeout(i, o, l, c).catch(ee);
648
575
  if (u instanceof Error) {
649
- if (n.signal?.aborted)
650
- throw new ee();
651
- if (r)
652
- return this.retryRequest(n, r);
653
- throw u.name === "AbortError" ? new Pe() : new q({ cause: u });
576
+ if (r.signal?.aborted)
577
+ throw new Z();
578
+ if (n)
579
+ return this.retryRequest(r, n);
580
+ throw u.name === "AbortError" ? new Ee() : new F({ cause: u });
654
581
  }
655
- const p = Rt(u.headers);
582
+ const p = _t(u.headers);
656
583
  if (!u.ok) {
657
- if (r && this.shouldRetry(u)) {
658
- const R = `retrying, ${r} attempts remaining`;
659
- return L(`response (error; ${R})`, u.status, i, p), this.retryRequest(n, r, p);
584
+ if (n && this.shouldRetry(u)) {
585
+ const S = `retrying, ${n} attempts remaining`;
586
+ return L(`response (error; ${S})`, u.status, i, p), this.retryRequest(r, n, p);
660
587
  }
661
- const a = await u.text().catch((R) => re(R).message), h = Tt(a), m = h ? void 0 : a;
662
- throw L(`response (error; ${r ? "(error; no more retries left)" : "(error; not retryable)"})`, u.status, i, p, m), this.makeStatusError(u.status, h, m, p);
588
+ const a = await u.text().catch((S) => ee(S).message), h = Pt(a), m = h ? void 0 : a;
589
+ throw L(`response (error; ${n ? "(error; no more retries left)" : "(error; not retryable)"})`, u.status, i, p, m), this.makeStatusError(u.status, h, m, p);
663
590
  }
664
- return { response: u, options: n, controller: c };
591
+ return { response: u, options: r, controller: c };
665
592
  }
666
- requestAPIList(e, r) {
667
- const n = this.makeRequest(r, null);
668
- return new At(this, n, e);
593
+ requestAPIList(e, n) {
594
+ const r = this.makeRequest(n, null);
595
+ return new bt(this, r, e);
669
596
  }
670
- buildURL(e, r, n) {
671
- const s = !Ne(this, M, "f") && n || this.baseURL, o = Ct(e) ? new URL(e) : new URL(s + (s.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), i = this.defaultQuery();
672
- return ze(i) || (r = { ...i, ...r }), typeof r == "object" && r && !Array.isArray(r) && (o.search = this.stringifyQuery(r)), o.toString();
597
+ buildURL(e, n, r) {
598
+ const s = !$e(this, M, "f") && r || this.baseURL, o = Tt(e) ? new URL(e) : new URL(s + (s.endsWith("/") && e.startsWith("/") ? e.slice(1) : e)), i = this.defaultQuery();
599
+ return Ne(i) || (n = { ...i, ...n }), typeof n == "object" && n && !Array.isArray(n) && (o.search = this.stringifyQuery(n)), o.toString();
673
600
  }
674
601
  stringifyQuery(e) {
675
- return Object.entries(e).filter(([r, n]) => typeof n < "u").map(([r, n]) => {
676
- if (typeof n == "string" || typeof n == "number" || typeof n == "boolean")
677
- return `${encodeURIComponent(r)}=${encodeURIComponent(n)}`;
678
- if (n === null)
679
- return `${encodeURIComponent(r)}=`;
680
- throw new P(`Cannot stringify type ${typeof n}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
602
+ return Object.entries(e).filter(([n, r]) => typeof r < "u").map(([n, r]) => {
603
+ if (typeof r == "string" || typeof r == "number" || typeof r == "boolean")
604
+ return `${encodeURIComponent(n)}=${encodeURIComponent(r)}`;
605
+ if (r === null)
606
+ return `${encodeURIComponent(n)}=`;
607
+ throw new P(`Cannot stringify type ${typeof r}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
681
608
  }).join("&");
682
609
  }
683
- async fetchWithTimeout(e, r, n, s) {
684
- const { signal: o, ...i } = r || {};
610
+ async fetchWithTimeout(e, n, r, s) {
611
+ const { signal: o, ...i } = n || {};
685
612
  o && o.addEventListener("abort", () => s.abort());
686
- const l = setTimeout(() => s.abort(), n), c = {
613
+ const l = setTimeout(() => s.abort(), r), c = {
687
614
  signal: s.signal,
688
615
  ...i
689
616
  };
@@ -693,29 +620,29 @@ class xt {
693
620
  });
694
621
  }
695
622
  shouldRetry(e) {
696
- const r = e.headers.get("x-should-retry");
697
- return r === "true" ? !0 : r === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
623
+ const n = e.headers.get("x-should-retry");
624
+ return n === "true" ? !0 : n === "false" ? !1 : e.status === 408 || e.status === 409 || e.status === 429 || e.status >= 500;
698
625
  }
699
- async retryRequest(e, r, n) {
626
+ async retryRequest(e, n, r) {
700
627
  let s;
701
- const o = n?.["retry-after-ms"];
628
+ const o = r?.["retry-after-ms"];
702
629
  if (o) {
703
630
  const l = parseFloat(o);
704
631
  Number.isNaN(l) || (s = l);
705
632
  }
706
- const i = n?.["retry-after"];
633
+ const i = r?.["retry-after"];
707
634
  if (i && !s) {
708
635
  const l = parseFloat(i);
709
636
  Number.isNaN(l) ? s = Date.parse(i) - Date.now() : s = l * 1e3;
710
637
  }
711
638
  if (!(s && 0 <= s && s < 60 * 1e3)) {
712
639
  const l = e.maxRetries ?? this.maxRetries;
713
- s = this.calculateDefaultRetryTimeoutMillis(r, l);
640
+ s = this.calculateDefaultRetryTimeoutMillis(n, l);
714
641
  }
715
- return await It(s), this.makeRequest(e, r - 1);
642
+ return await Ct(s), this.makeRequest(e, n - 1);
716
643
  }
717
- calculateDefaultRetryTimeoutMillis(e, r) {
718
- const o = r - e, i = Math.min(0.5 * Math.pow(2, o), 8), l = 1 - Math.random() * 0.25;
644
+ calculateDefaultRetryTimeoutMillis(e, n) {
645
+ const o = n - e, i = Math.min(0.5 * Math.pow(2, o), 8), l = 1 - Math.random() * 0.25;
719
646
  return i * l * 1e3;
720
647
  }
721
648
  getUserAgent() {
@@ -723,9 +650,9 @@ class xt {
723
650
  }
724
651
  }
725
652
  M = /* @__PURE__ */ new WeakMap();
726
- class _t {
727
- constructor(e, r, n, s) {
728
- U.set(this, void 0), qe(this, U, e, "f"), this.options = s, this.response = r, this.body = n;
653
+ class xt {
654
+ constructor(e, n, r, s) {
655
+ j.set(this, void 0), Ue(this, j, e, "f"), this.options = s, this.response = n, this.body = r;
729
656
  }
730
657
  hasNextPage() {
731
658
  return this.getPaginatedItems().length ? this.nextPageInfo() != null : !1;
@@ -734,31 +661,31 @@ class _t {
734
661
  const e = this.nextPageInfo();
735
662
  if (!e)
736
663
  throw new P("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
737
- const r = { ...this.options };
738
- if ("params" in e && typeof r.query == "object")
739
- r.query = { ...r.query, ...e.params };
664
+ const n = { ...this.options };
665
+ if ("params" in e && typeof n.query == "object")
666
+ n.query = { ...n.query, ...e.params };
740
667
  else if ("url" in e) {
741
- const n = [...Object.entries(r.query || {}), ...e.url.searchParams.entries()];
742
- for (const [s, o] of n)
668
+ const r = [...Object.entries(n.query || {}), ...e.url.searchParams.entries()];
669
+ for (const [s, o] of r)
743
670
  e.url.searchParams.set(s, o);
744
- r.query = void 0, r.path = e.url.toString();
671
+ n.query = void 0, n.path = e.url.toString();
745
672
  }
746
- return await Ne(this, U, "f").requestAPIList(this.constructor, r);
673
+ return await $e(this, j, "f").requestAPIList(this.constructor, n);
747
674
  }
748
675
  async *iterPages() {
749
676
  let e = this;
750
677
  for (yield e; e.hasNextPage(); )
751
678
  e = await e.getNextPage(), yield e;
752
679
  }
753
- async *[(U = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
680
+ async *[(j = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
754
681
  for await (const e of this.iterPages())
755
- for (const r of e.getPaginatedItems())
756
- yield r;
682
+ for (const n of e.getPaginatedItems())
683
+ yield n;
757
684
  }
758
685
  }
759
- class At extends H {
760
- constructor(e, r, n) {
761
- super(r, async (s) => new n(e, s.response, await He(s), s.options));
686
+ class bt extends B {
687
+ constructor(e, n, r) {
688
+ super(n, async (s) => new r(e, s.response, await je(s), s.options));
762
689
  }
763
690
  /**
764
691
  * Allow auto-paginating iteration on an unawaited list call, eg:
@@ -769,19 +696,19 @@ class At extends H {
769
696
  */
770
697
  async *[Symbol.asyncIterator]() {
771
698
  const e = await this;
772
- for await (const r of e)
773
- yield r;
699
+ for await (const n of e)
700
+ yield n;
774
701
  }
775
702
  }
776
- const Rt = (t) => new Proxy(Object.fromEntries(
703
+ const _t = (t) => new Proxy(Object.fromEntries(
777
704
  // @ts-ignore
778
705
  t.entries()
779
706
  ), {
780
- get(e, r) {
781
- const n = r.toString();
782
- return e[n.toLowerCase()] || e[n];
707
+ get(e, n) {
708
+ const r = n.toString();
709
+ return e[r.toLowerCase()] || e[r];
783
710
  }
784
- }), St = {
711
+ }), At = {
785
712
  method: !0,
786
713
  path: !0,
787
714
  query: !0,
@@ -796,13 +723,13 @@ const Rt = (t) => new Proxy(Object.fromEntries(
796
723
  idempotencyKey: !0,
797
724
  __binaryRequest: !0,
798
725
  __binaryResponse: !0
799
- }, S = (t) => typeof t == "object" && t !== null && !ze(t) && Object.keys(t).every((e) => Xe(St, e)), Et = () => {
726
+ }, R = (t) => typeof t == "object" && t !== null && !Ne(t) && Object.keys(t).every((e) => Me(At, e)), St = () => {
800
727
  if (typeof Deno < "u" && Deno.build != null)
801
728
  return {
802
729
  "X-Stainless-Lang": "js",
803
730
  "X-Stainless-Package-Version": T,
804
- "X-Stainless-OS": be(Deno.build.os),
805
- "X-Stainless-Arch": we(Deno.build.arch),
731
+ "X-Stainless-OS": ge(Deno.build.os),
732
+ "X-Stainless-Arch": me(Deno.build.arch),
806
733
  "X-Stainless-Runtime": "deno",
807
734
  "X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : Deno.version?.deno ?? "unknown"
808
735
  };
@@ -819,12 +746,12 @@ const Rt = (t) => new Proxy(Object.fromEntries(
819
746
  return {
820
747
  "X-Stainless-Lang": "js",
821
748
  "X-Stainless-Package-Version": T,
822
- "X-Stainless-OS": be(process.platform),
823
- "X-Stainless-Arch": we(process.arch),
749
+ "X-Stainless-OS": ge(process.platform),
750
+ "X-Stainless-Arch": me(process.arch),
824
751
  "X-Stainless-Runtime": "node",
825
752
  "X-Stainless-Runtime-Version": process.version
826
753
  };
827
- const t = Pt();
754
+ const t = Rt();
828
755
  return t ? {
829
756
  "X-Stainless-Lang": "js",
830
757
  "X-Stainless-Package-Version": T,
@@ -841,7 +768,7 @@ const Rt = (t) => new Proxy(Object.fromEntries(
841
768
  "X-Stainless-Runtime-Version": "unknown"
842
769
  };
843
770
  };
844
- function Pt() {
771
+ function Rt() {
845
772
  if (typeof navigator > "u" || !navigator)
846
773
  return null;
847
774
  const t = [
@@ -852,30 +779,30 @@ function Pt() {
852
779
  { key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
853
780
  { key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
854
781
  ];
855
- for (const { key: e, pattern: r } of t) {
856
- const n = r.exec(navigator.userAgent);
857
- if (n) {
858
- const s = n[1] || 0, o = n[2] || 0, i = n[3] || 0;
782
+ for (const { key: e, pattern: n } of t) {
783
+ const r = n.exec(navigator.userAgent);
784
+ if (r) {
785
+ const s = r[1] || 0, o = r[2] || 0, i = r[3] || 0;
859
786
  return { browser: e, version: `${s}.${o}.${i}` };
860
787
  }
861
788
  }
862
789
  return null;
863
790
  }
864
- const we = (t) => t === "x32" ? "x32" : t === "x86_64" || t === "x64" ? "x64" : t === "arm" ? "arm" : t === "aarch64" || t === "arm64" ? "arm64" : t ? `other:${t}` : "unknown", be = (t) => (t = t.toLowerCase(), t.includes("ios") ? "iOS" : t === "android" ? "Android" : t === "darwin" ? "MacOS" : t === "win32" ? "Windows" : t === "freebsd" ? "FreeBSD" : t === "openbsd" ? "OpenBSD" : t === "linux" ? "Linux" : t ? `Other:${t}` : "Unknown");
865
- let xe;
866
- const kt = () => xe ?? (xe = Et()), Tt = (t) => {
791
+ const me = (t) => t === "x32" ? "x32" : t === "x86_64" || t === "x64" ? "x64" : t === "arm" ? "arm" : t === "aarch64" || t === "arm64" ? "arm64" : t ? `other:${t}` : "unknown", ge = (t) => (t = t.toLowerCase(), t.includes("ios") ? "iOS" : t === "android" ? "Android" : t === "darwin" ? "MacOS" : t === "win32" ? "Windows" : t === "freebsd" ? "FreeBSD" : t === "openbsd" ? "OpenBSD" : t === "linux" ? "Linux" : t ? `Other:${t}` : "Unknown");
792
+ let we;
793
+ const Et = () => we ?? (we = St()), Pt = (t) => {
867
794
  try {
868
795
  return JSON.parse(t);
869
796
  } catch {
870
797
  return;
871
798
  }
872
- }, vt = /^[a-z][a-z0-9+.-]*:/i, Ct = (t) => vt.test(t), It = (t) => new Promise((e) => setTimeout(e, t)), J = (t, e) => {
799
+ }, kt = /^[a-z][a-z0-9+.-]*:/i, Tt = (t) => kt.test(t), Ct = (t) => new Promise((e) => setTimeout(e, t)), G = (t, e) => {
873
800
  if (typeof e != "number" || !Number.isInteger(e))
874
801
  throw new P(`${t} must be an integer`);
875
802
  if (e < 0)
876
803
  throw new P(`${t} must be a positive integer`);
877
804
  return e;
878
- }, re = (t) => {
805
+ }, ee = (t) => {
879
806
  if (t instanceof Error)
880
807
  return t;
881
808
  if (typeof t == "object" && t !== null)
@@ -884,56 +811,56 @@ const kt = () => xe ?? (xe = Et()), Tt = (t) => {
884
811
  } catch {
885
812
  }
886
813
  return new Error(t);
887
- }, _e = (t) => {
814
+ }, xe = (t) => {
888
815
  if (typeof process < "u")
889
816
  return process.env?.[t]?.trim() ?? void 0;
890
817
  if (typeof Deno < "u")
891
818
  return Deno.env?.get?.(t)?.trim();
892
819
  };
893
- function ze(t) {
820
+ function Ne(t) {
894
821
  if (!t)
895
822
  return !0;
896
823
  for (const e in t)
897
824
  return !1;
898
825
  return !0;
899
826
  }
900
- function Xe(t, e) {
827
+ function Me(t, e) {
901
828
  return Object.prototype.hasOwnProperty.call(t, e);
902
829
  }
903
- function Ae(t, e) {
904
- for (const r in e) {
905
- if (!Xe(e, r))
830
+ function be(t, e) {
831
+ for (const n in e) {
832
+ if (!Me(e, n))
906
833
  continue;
907
- const n = r.toLowerCase();
908
- if (!n)
834
+ const r = n.toLowerCase();
835
+ if (!r)
909
836
  continue;
910
- const s = e[r];
911
- s === null ? delete t[n] : s !== void 0 && (t[n] = s);
837
+ const s = e[n];
838
+ s === null ? delete t[r] : s !== void 0 && (t[r] = s);
912
839
  }
913
840
  }
914
841
  function L(t, ...e) {
915
842
  typeof process < "u" && process?.env?.DEBUG === "true" && console.log(`Arcade:DEBUG:${t}`, ...e);
916
843
  }
917
- const Dt = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
844
+ const vt = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
918
845
  const e = Math.random() * 16 | 0;
919
846
  return (t === "x" ? e : e & 3 | 8).toString(16);
920
- }), Lt = (t) => typeof t?.get == "function", B = (t, e) => {
921
- const r = e.toLowerCase();
922
- if (Lt(t)) {
923
- const n = e[0]?.toUpperCase() + e.substring(1).replace(/([^\w])(\w)/g, (s, o, i) => o + i.toUpperCase());
924
- for (const s of [e, r, e.toUpperCase(), n]) {
847
+ }), It = (t) => typeof t?.get == "function", N = (t, e) => {
848
+ const n = e.toLowerCase();
849
+ if (It(t)) {
850
+ const r = e[0]?.toUpperCase() + e.substring(1).replace(/([^\w])(\w)/g, (s, o, i) => o + i.toUpperCase());
851
+ for (const s of [e, n, e.toUpperCase(), r]) {
925
852
  const o = t.get(s);
926
853
  if (o)
927
854
  return o;
928
855
  }
929
856
  }
930
- for (const [n, s] of Object.entries(t))
931
- if (n.toLowerCase() === r)
857
+ for (const [r, s] of Object.entries(t))
858
+ if (r.toLowerCase() === n)
932
859
  return Array.isArray(s) ? (s.length <= 1 || console.warn(`Received ${s.length} entries for the ${e} header, using the first entry.`), s[0]) : s;
933
860
  };
934
- class O extends _t {
935
- constructor(e, r, n, s) {
936
- super(e, r, n, s), this.items = n.items || [], this.total_count = n.total_count || 0, this.offset = n.offset || 0;
861
+ class O extends xt {
862
+ constructor(e, n, r, s) {
863
+ super(e, n, r, s), this.items = r.items || [], this.total_count = r.total_count || 0, this.offset = r.offset || 0;
937
864
  }
938
865
  getPaginatedItems() {
939
866
  return this.items ?? [];
@@ -945,28 +872,28 @@ class O extends _t {
945
872
  return null;
946
873
  if ("params" in e)
947
874
  return e.params;
948
- const r = Object.fromEntries(e.url.searchParams);
949
- return Object.keys(r).length ? r : null;
875
+ const n = Object.fromEntries(e.url.searchParams);
876
+ return Object.keys(n).length ? n : null;
950
877
  }
951
878
  nextPageInfo() {
952
879
  const e = this.offset;
953
880
  if (!e)
954
881
  return null;
955
- const r = this.getPaginatedItems().length, n = e + r, s = this.total_count;
956
- return s && n < s ? { params: { offset: n } } : null;
882
+ const n = this.getPaginatedItems().length, r = e + n, s = this.total_count;
883
+ return s && r < s ? { params: { offset: r } } : null;
957
884
  }
958
885
  }
959
- class b {
886
+ class x {
960
887
  constructor(e) {
961
888
  this._client = e;
962
889
  }
963
890
  }
964
- class Ke extends b {
891
+ class Fe extends x {
965
892
  /**
966
893
  * Create a new auth provider
967
894
  */
968
- create(e, r) {
969
- return this._client.post("/v1/admin/auth_providers", { body: e, ...r });
895
+ create(e, n) {
896
+ return this._client.post("/v1/admin/auth_providers", { body: e, ...n });
970
897
  }
971
898
  /**
972
899
  * List a page of auth providers that are available to the caller
@@ -977,23 +904,23 @@ class Ke extends b {
977
904
  /**
978
905
  * Delete a specific auth provider
979
906
  */
980
- delete(e, r) {
981
- return this._client.delete(`/v1/admin/auth_providers/${e}`, r);
907
+ delete(e, n) {
908
+ return this._client.delete(`/v1/admin/auth_providers/${e}`, n);
982
909
  }
983
910
  /**
984
911
  * Get the details of a specific auth provider
985
912
  */
986
- get(e, r) {
987
- return this._client.get(`/v1/admin/auth_providers/${e}`, r);
913
+ get(e, n) {
914
+ return this._client.get(`/v1/admin/auth_providers/${e}`, n);
988
915
  }
989
916
  /**
990
917
  * Patch an existing auth provider
991
918
  */
992
- patch(e, r, n) {
993
- return this._client.patch(`/v1/admin/auth_providers/${e}`, { body: r, ...n });
919
+ patch(e, n, r) {
920
+ return this._client.patch(`/v1/admin/auth_providers/${e}`, { body: n, ...r });
994
921
  }
995
922
  }
996
- class We extends b {
923
+ class qe extends x {
997
924
  /**
998
925
  * List all secrets that are visible to the caller
999
926
  */
@@ -1003,49 +930,49 @@ class We extends b {
1003
930
  /**
1004
931
  * Delete a secret by its ID
1005
932
  */
1006
- delete(e, r) {
933
+ delete(e, n) {
1007
934
  return this._client.delete(`/v1/admin/secrets/${e}`, {
1008
- ...r,
1009
- headers: { Accept: "*/*", ...r?.headers }
935
+ ...n,
936
+ headers: { Accept: "*/*", ...n?.headers }
1010
937
  });
1011
938
  }
1012
939
  }
1013
- class ne extends b {
1014
- list(e = {}, r) {
1015
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/admin/user_connections", se, {
940
+ class te extends x {
941
+ list(e = {}, n) {
942
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/admin/user_connections", ne, {
1016
943
  query: e,
1017
- ...r
944
+ ...n
1018
945
  });
1019
946
  }
1020
947
  /**
1021
948
  * Delete a user/auth provider connection
1022
949
  */
1023
- delete(e, r) {
950
+ delete(e, n) {
1024
951
  return this._client.delete(`/v1/admin/user_connections/${e}`, {
1025
- ...r,
1026
- headers: { Accept: "*/*", ...r?.headers }
952
+ ...n,
953
+ headers: { Accept: "*/*", ...n?.headers }
1027
954
  });
1028
955
  }
1029
956
  }
1030
- class se extends O {
957
+ class ne extends O {
1031
958
  }
1032
- ne.UserConnectionResponsesOffsetPage = se;
1033
- class v extends b {
959
+ te.UserConnectionResponsesOffsetPage = ne;
960
+ class C extends x {
1034
961
  constructor() {
1035
- super(...arguments), this.userConnections = new ne(this._client), this.authProviders = new Ke(this._client), this.secrets = new We(this._client);
962
+ super(...arguments), this.userConnections = new te(this._client), this.authProviders = new Fe(this._client), this.secrets = new qe(this._client);
1036
963
  }
1037
964
  }
1038
- v.UserConnections = ne;
1039
- v.UserConnectionResponsesOffsetPage = se;
1040
- v.AuthProviders = Ke;
1041
- v.Secrets = We;
1042
- const Ot = 45;
1043
- class Ft extends Error {
965
+ C.UserConnections = te;
966
+ C.UserConnectionResponsesOffsetPage = ne;
967
+ C.AuthProviders = Fe;
968
+ C.Secrets = qe;
969
+ const Lt = 45;
970
+ class Ot extends Error {
1044
971
  constructor(e) {
1045
972
  super(e), this.name = "AuthorizationError";
1046
973
  }
1047
974
  }
1048
- class Ve extends b {
975
+ class Be extends x {
1049
976
  /**
1050
977
  * Starts the authorization process for a given provider and scopes.
1051
978
  * @param userId - The user ID for which authorization is being requested
@@ -1060,9 +987,9 @@ class Ve extends b {
1060
987
  * const authResponse = await client.auth.start("user@example.com", "github");
1061
988
  * ```
1062
989
  */
1063
- start(e, r, n = {}) {
1064
- const { providerType: s = "oauth2", scopes: o = [] } = n, i = {
1065
- provider_id: r,
990
+ start(e, n, r = {}) {
991
+ const { providerType: s = "oauth2", scopes: o = [] } = r, i = {
992
+ provider_id: n,
1066
993
  provider_type: s,
1067
994
  oauth2: {
1068
995
  scopes: o
@@ -1076,22 +1003,22 @@ class Ve extends b {
1076
1003
  /**
1077
1004
  * Starts the authorization process for given authorization requirements
1078
1005
  */
1079
- authorize(e, r) {
1080
- return this._client.post("/v1/auth/authorize", { body: e, ...r });
1006
+ authorize(e, n) {
1007
+ return this._client.post("/v1/auth/authorize", { body: e, ...n });
1081
1008
  }
1082
1009
  /**
1083
1010
  * Confirms a user's details during an authorization flow
1084
1011
  */
1085
- confirmUser(e, r) {
1086
- return this._client.post("/v1/auth/confirm_user", { body: e, ...r });
1012
+ confirmUser(e, n) {
1013
+ return this._client.post("/v1/auth/confirm_user", { body: e, ...n });
1087
1014
  }
1088
1015
  /**
1089
1016
  * Checks the status of an ongoing authorization process for a specific tool. If
1090
1017
  * 'wait' param is present, does not respond until either the auth status becomes
1091
1018
  * completed or the timeout is reached.
1092
1019
  */
1093
- status(e, r) {
1094
- return this._client.get("/v1/auth/status", { query: e, ...r });
1020
+ status(e, n) {
1021
+ return this._client.get("/v1/auth/status", { query: e, ...n });
1095
1022
  }
1096
1023
  /**
1097
1024
  * Waits for the authorization process to complete.
@@ -1113,37 +1040,37 @@ class Ve extends b {
1113
1040
  * ```
1114
1041
  */
1115
1042
  async waitForCompletion(e) {
1116
- let r, n;
1043
+ let n, r;
1117
1044
  if (typeof e == "string")
1118
- r = e, n = { status: "pending" };
1045
+ n = e, r = { status: "pending" };
1119
1046
  else {
1120
1047
  if (!e.id)
1121
- throw new Ft("Authorization ID is required");
1122
- r = e.id, n = e;
1048
+ throw new Ot("Authorization ID is required");
1049
+ n = e.id, r = e;
1123
1050
  }
1124
- for (; n.status !== "completed"; )
1125
- n = await this.status({
1126
- id: r,
1127
- wait: Ot
1051
+ for (; r.status !== "completed"; )
1052
+ r = await this.status({
1053
+ id: n,
1054
+ wait: Lt
1128
1055
  });
1129
- return n;
1056
+ return r;
1130
1057
  }
1131
1058
  }
1132
- class Qe extends b {
1059
+ class He extends x {
1133
1060
  /**
1134
1061
  * Talk to different LLM Chat APIs via OpenAI's API
1135
1062
  */
1136
- create(e, r) {
1137
- return this._client.post("/v1/chat/completions", { body: e, ...r });
1063
+ create(e, n) {
1064
+ return this._client.post("/v1/chat/completions", { body: e, ...n });
1138
1065
  }
1139
1066
  }
1140
- class oe extends b {
1067
+ class re extends x {
1141
1068
  constructor() {
1142
- super(...arguments), this.completions = new Qe(this._client);
1069
+ super(...arguments), this.completions = new He(this._client);
1143
1070
  }
1144
1071
  }
1145
- oe.Completions = Qe;
1146
- class Ge extends b {
1072
+ re.Completions = He;
1073
+ class ze extends x {
1147
1074
  /**
1148
1075
  * Engine Health
1149
1076
  */
@@ -1151,111 +1078,111 @@ class Ge extends b {
1151
1078
  return this._client.get("/v1/health", e);
1152
1079
  }
1153
1080
  }
1154
- class ie extends b {
1155
- list(e = {}, r) {
1156
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/formatted_tools", ae, {
1081
+ class se extends x {
1082
+ list(e = {}, n) {
1083
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/formatted_tools", oe, {
1157
1084
  query: e,
1158
- ...r
1085
+ ...n
1159
1086
  });
1160
1087
  }
1161
- get(e, r = {}, n) {
1162
- return S(r) ? this.get(e, {}, r) : this._client.get(`/v1/formatted_tools/${e}`, { query: r, ...n });
1088
+ get(e, n = {}, r) {
1089
+ return R(n) ? this.get(e, {}, n) : this._client.get(`/v1/formatted_tools/${e}`, { query: n, ...r });
1163
1090
  }
1164
1091
  }
1165
- class ae extends O {
1092
+ class oe extends O {
1166
1093
  }
1167
- ie.FormattedListResponsesOffsetPage = ae;
1168
- class Je extends b {
1169
- list(e = {}, r) {
1170
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/scheduled_tools", $t, { query: e, ...r });
1094
+ se.FormattedListResponsesOffsetPage = oe;
1095
+ class Xe extends x {
1096
+ list(e = {}, n) {
1097
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/scheduled_tools", Dt, { query: e, ...n });
1171
1098
  }
1172
1099
  /**
1173
1100
  * Returns the details for a specific scheduled tool execution
1174
1101
  */
1175
- get(e, r) {
1176
- return this._client.get(`/v1/scheduled_tools/${e}`, r);
1102
+ get(e, n) {
1103
+ return this._client.get(`/v1/scheduled_tools/${e}`, n);
1177
1104
  }
1178
1105
  }
1179
- class C extends b {
1106
+ class v extends x {
1180
1107
  constructor() {
1181
- super(...arguments), this.scheduled = new Je(this._client), this.formatted = new ie(this._client);
1108
+ super(...arguments), this.scheduled = new Xe(this._client), this.formatted = new se(this._client);
1182
1109
  }
1183
- list(e = {}, r) {
1184
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/tools", z, { query: e, ...r });
1110
+ list(e = {}, n) {
1111
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/tools", H, { query: e, ...n });
1185
1112
  }
1186
1113
  /**
1187
1114
  * Authorizes a user for a specific tool by name
1188
1115
  */
1189
- authorize(e, r) {
1190
- return this._client.post("/v1/tools/authorize", { body: e, ...r });
1116
+ authorize(e, n) {
1117
+ return this._client.post("/v1/tools/authorize", { body: e, ...n });
1191
1118
  }
1192
1119
  /**
1193
1120
  * Executes a tool by name and arguments
1194
1121
  */
1195
- execute(e, r) {
1196
- return this._client.post("/v1/tools/execute", { body: e, ...r });
1122
+ execute(e, n) {
1123
+ return this._client.post("/v1/tools/execute", { body: e, ...n });
1197
1124
  }
1198
- get(e, r = {}, n) {
1199
- return S(r) ? this.get(e, {}, r) : this._client.get(`/v1/tools/${e}`, { query: r, ...n });
1125
+ get(e, n = {}, r) {
1126
+ return R(n) ? this.get(e, {}, n) : this._client.get(`/v1/tools/${e}`, { query: n, ...r });
1200
1127
  }
1201
1128
  }
1202
- class z extends O {
1129
+ class H extends O {
1203
1130
  }
1204
- class $t extends O {
1131
+ class Dt extends O {
1205
1132
  }
1206
- C.ToolDefinitionsOffsetPage = z;
1207
- C.Scheduled = Je;
1208
- C.Formatted = ie;
1209
- C.FormattedListResponsesOffsetPage = ae;
1210
- class ce extends b {
1133
+ v.ToolDefinitionsOffsetPage = H;
1134
+ v.Scheduled = Xe;
1135
+ v.Formatted = se;
1136
+ v.FormattedListResponsesOffsetPage = oe;
1137
+ class ie extends x {
1211
1138
  /**
1212
1139
  * Create a worker
1213
1140
  */
1214
- create(e, r) {
1215
- return this._client.post("/v1/workers", { body: e, ...r });
1141
+ create(e, n) {
1142
+ return this._client.post("/v1/workers", { body: e, ...n });
1216
1143
  }
1217
1144
  /**
1218
1145
  * Update a worker
1219
1146
  */
1220
- update(e, r, n) {
1221
- return this._client.patch(`/v1/workers/${e}`, { body: r, ...n });
1147
+ update(e, n, r) {
1148
+ return this._client.patch(`/v1/workers/${e}`, { body: n, ...r });
1222
1149
  }
1223
- list(e = {}, r) {
1224
- return S(e) ? this.list({}, e) : this._client.getAPIList("/v1/workers", ue, { query: e, ...r });
1150
+ list(e = {}, n) {
1151
+ return R(e) ? this.list({}, e) : this._client.getAPIList("/v1/workers", ae, { query: e, ...n });
1225
1152
  }
1226
1153
  /**
1227
1154
  * Delete a worker
1228
1155
  */
1229
- delete(e, r) {
1156
+ delete(e, n) {
1230
1157
  return this._client.delete(`/v1/workers/${e}`, {
1231
- ...r,
1232
- headers: { Accept: "*/*", ...r?.headers }
1158
+ ...n,
1159
+ headers: { Accept: "*/*", ...n?.headers }
1233
1160
  });
1234
1161
  }
1235
1162
  /**
1236
1163
  * Get a worker by ID
1237
1164
  */
1238
- get(e, r) {
1239
- return this._client.get(`/v1/workers/${e}`, r);
1165
+ get(e, n) {
1166
+ return this._client.get(`/v1/workers/${e}`, n);
1240
1167
  }
1241
1168
  /**
1242
1169
  * Get the health of a worker
1243
1170
  */
1244
- health(e, r) {
1245
- return this._client.get(`/v1/workers/${e}/health`, r);
1171
+ health(e, n) {
1172
+ return this._client.get(`/v1/workers/${e}/health`, n);
1246
1173
  }
1247
- tools(e, r = {}, n) {
1248
- return S(r) ? this.tools(e, {}, r) : this._client.getAPIList(`/v1/workers/${e}/tools`, z, {
1249
- query: r,
1250
- ...n
1174
+ tools(e, n = {}, r) {
1175
+ return R(n) ? this.tools(e, {}, n) : this._client.getAPIList(`/v1/workers/${e}/tools`, H, {
1176
+ query: n,
1177
+ ...r
1251
1178
  });
1252
1179
  }
1253
1180
  }
1254
- class ue extends O {
1181
+ class ae extends O {
1255
1182
  }
1256
- ce.WorkerResponsesOffsetPage = ue;
1257
- var Ye, Ze;
1258
- class d extends xt {
1183
+ ie.WorkerResponsesOffsetPage = ae;
1184
+ var Ke, We;
1185
+ class d extends wt {
1259
1186
  /**
1260
1187
  * API Client for interfacing with the Arcade API.
1261
1188
  *
@@ -1268,12 +1195,12 @@ class d extends xt {
1268
1195
  * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
1269
1196
  * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
1270
1197
  */
1271
- constructor({ baseURL: e = _e("ARCADE_BASE_URL"), apiKey: r = _e("ARCADE_API_KEY"), ...n } = {}) {
1272
- if (r === void 0)
1198
+ constructor({ baseURL: e = xe("ARCADE_BASE_URL"), apiKey: n = xe("ARCADE_API_KEY"), ...r } = {}) {
1199
+ if (n === void 0)
1273
1200
  throw new P("The ARCADE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Arcade client with an apiKey option, like new Arcade({ apiKey: 'My API Key' }).");
1274
1201
  const s = {
1275
- apiKey: r,
1276
- ...n,
1202
+ apiKey: n,
1203
+ ...r,
1277
1204
  baseURL: e || "https://api.arcade.dev"
1278
1205
  };
1279
1206
  super({
@@ -1283,7 +1210,7 @@ class d extends xt {
1283
1210
  httpAgent: s.httpAgent,
1284
1211
  maxRetries: s.maxRetries,
1285
1212
  fetch: s.fetch
1286
- }), Ye.add(this), this.admin = new v(this), this.auth = new Ve(this), this.health = new Ge(this), this.chat = new oe(this), this.tools = new C(this), this.workers = new ce(this), this._options = s, this.idempotencyHeader = "Idempotency-Key", this.apiKey = r;
1213
+ }), Ke.add(this), this.admin = new C(this), this.auth = new Be(this), this.health = new ze(this), this.chat = new re(this), this.tools = new v(this), this.workers = new ie(this), this._options = s, this.idempotencyHeader = "Idempotency-Key", this.apiKey = n;
1287
1214
  }
1288
1215
  defaultQuery() {
1289
1216
  return this._options.defaultQuery;
@@ -1298,44 +1225,43 @@ class d extends xt {
1298
1225
  return { Authorization: this.apiKey };
1299
1226
  }
1300
1227
  stringifyQuery(e) {
1301
- return ft(e, { arrayFormat: "comma" });
1228
+ return lt(e, { arrayFormat: "comma" });
1302
1229
  }
1303
1230
  }
1304
- Ze = d, Ye = /* @__PURE__ */ new WeakSet();
1305
- d.Arcade = Ze;
1231
+ We = d, Ke = /* @__PURE__ */ new WeakSet();
1232
+ d.Arcade = We;
1306
1233
  d.DEFAULT_TIMEOUT = 6e4;
1307
1234
  d.ArcadeError = P;
1308
1235
  d.APIError = w;
1309
- d.APIConnectionError = q;
1310
- d.APIConnectionTimeoutError = Pe;
1311
- d.APIUserAbortError = ee;
1236
+ d.APIConnectionError = F;
1237
+ d.APIConnectionTimeoutError = Ee;
1238
+ d.APIUserAbortError = Z;
1312
1239
  d.NotFoundError = Ce;
1313
- d.ConflictError = Ie;
1240
+ d.ConflictError = ve;
1314
1241
  d.RateLimitError = Le;
1315
- d.BadRequestError = ke;
1316
- d.AuthenticationError = Te;
1242
+ d.BadRequestError = Pe;
1243
+ d.AuthenticationError = ke;
1317
1244
  d.InternalServerError = Oe;
1318
- d.PermissionDeniedError = ve;
1319
- d.UnprocessableEntityError = De;
1320
- d.toFile = yt;
1321
- d.fileFromPath = je;
1322
- d.Admin = v;
1323
- d.Auth = Ve;
1324
- d.Health = Ge;
1325
- d.Chat = oe;
1326
- d.Tools = C;
1327
- d.ToolDefinitionsOffsetPage = z;
1328
- d.Workers = ce;
1329
- d.WorkerResponsesOffsetPage = ue;
1330
- Ue(Be({ manuallyImported: !0 }));
1331
- const jt = /[._\-\s]+/, Ut = /([a-z])([A-Z])/g, Bt = /\s+/;
1332
- class Kt {
1245
+ d.PermissionDeniedError = Te;
1246
+ d.UnprocessableEntityError = Ie;
1247
+ d.toFile = ht;
1248
+ d.fileFromPath = Ze;
1249
+ d.Admin = C;
1250
+ d.Auth = Be;
1251
+ d.Health = ze;
1252
+ d.Chat = re;
1253
+ d.Tools = v;
1254
+ d.ToolDefinitionsOffsetPage = H;
1255
+ d.Workers = ie;
1256
+ d.WorkerResponsesOffsetPage = ae;
1257
+ const Ut = /[._\-\s]+/, $t = /([a-z])([A-Z])/g, jt = /\s+/;
1258
+ class qt {
1333
1259
  #e;
1334
1260
  constructor(e) {
1335
- const { accessToken: r, apiKey: n, arcadeClientId: s, baseURL: o } = e, i = n ?? pe("ARCADE_API_KEY"), l = !!i, c = {};
1336
- s && (c["Arcade-Client-Id"] = s), !l && r && (c.Authorization = `Bearer ${r}`);
1261
+ const { accessToken: n, apiKey: r, arcadeClientId: s, baseURL: o } = e, i = r ?? he("ARCADE_API_KEY"), l = !!i, c = {};
1262
+ s && (c["Arcade-Client-Id"] = s), !l && n && (c.Authorization = `Bearer ${n}`);
1337
1263
  const u = {
1338
- baseURL: o ?? pe("ARCADE_BASE_URL"),
1264
+ baseURL: o ?? he("ARCADE_BASE_URL"),
1339
1265
  defaultHeaders: c,
1340
1266
  apiKey: i ?? ""
1341
1267
  };
@@ -1345,28 +1271,28 @@ class Kt {
1345
1271
  return new d(e);
1346
1272
  }
1347
1273
  async getAllTools(e = {}) {
1348
- const { limit: r = 1e3, offset: n = 0, toolkit: s } = e;
1274
+ const { limit: n = 1e3, offset: r = 0, toolkit: s } = e;
1349
1275
  return (await this.#e.tools.list({
1350
- limit: r,
1351
- offset: n,
1276
+ limit: n,
1277
+ offset: r,
1352
1278
  toolkit: s
1353
1279
  })).items;
1354
1280
  }
1355
1281
  async groupToolsBy(e) {
1356
- const r = await this.getAllTools(), n = /* @__PURE__ */ new Map();
1357
- for (const s of r) {
1282
+ const n = await this.getAllTools(), r = /* @__PURE__ */ new Map();
1283
+ for (const s of n) {
1358
1284
  const o = s[e];
1359
- typeof o == "string" && n.set(o, s);
1285
+ typeof o == "string" && r.set(o, s);
1360
1286
  }
1361
- return n;
1287
+ return r;
1362
1288
  }
1363
1289
  async getToolkits() {
1364
- const e = await this.getAllTools(), r = /* @__PURE__ */ new Map();
1365
- for (const n of e) {
1366
- const s = n.toolkit.name;
1367
- let o = r.get(s);
1290
+ const e = await this.getAllTools(), n = /* @__PURE__ */ new Map();
1291
+ for (const r of e) {
1292
+ const s = r.toolkit.name;
1293
+ let o = n.get(s);
1368
1294
  o || (o = {
1369
- ...n.toolkit,
1295
+ ...r.toolkit,
1370
1296
  tools: [],
1371
1297
  requirements: {
1372
1298
  met: !0,
@@ -1374,9 +1300,9 @@ class Kt {
1374
1300
  authorization: [],
1375
1301
  scopes: {}
1376
1302
  }
1377
- }, r.set(s, o)), o.tools.push(n), n.requirements && this.applyToolRequirements(o, n.requirements);
1303
+ }, n.set(s, o)), o.tools.push(r), r.requirements && this.applyToolRequirements(o, r.requirements);
1378
1304
  }
1379
- return r;
1305
+ return n;
1380
1306
  }
1381
1307
  async getToolsForToolkit(e) {
1382
1308
  return (await this.#e.tools.list({
@@ -1384,81 +1310,81 @@ class Kt {
1384
1310
  limit: 1e3
1385
1311
  })).items;
1386
1312
  }
1387
- applyToolRequirements(e, r) {
1388
- if (!r)
1313
+ applyToolRequirements(e, n) {
1314
+ if (!n)
1389
1315
  return;
1390
1316
  e.requirements.secrets = this.mergeSecrets(
1391
- r.secrets ?? [],
1317
+ n.secrets ?? [],
1392
1318
  e.requirements.secrets ?? []
1393
1319
  ), e.requirements.authorization = this.mergeAuthorizations(
1394
- r.authorization,
1320
+ n.authorization,
1395
1321
  e.requirements.authorization ?? []
1396
1322
  );
1397
- const n = r.authorization?.provider_id, s = r.authorization?.oauth2?.scopes ?? [];
1398
- n && s.length && (e.requirements.scopes = this.mergeScopes(
1399
- n,
1323
+ const r = n.authorization?.provider_id, s = n.authorization?.oauth2?.scopes ?? [];
1324
+ r && s.length && (e.requirements.scopes = this.mergeScopes(
1325
+ r,
1400
1326
  s,
1401
1327
  e.requirements.scopes ?? {}
1402
- )), e.requirements.met = !!(e.requirements.met && (r.met ?? !0));
1328
+ )), e.requirements.met = !!(e.requirements.met && (n.met ?? !0));
1403
1329
  }
1404
- mergeSecrets(e = [], r = []) {
1330
+ mergeSecrets(e = [], n = []) {
1405
1331
  if (e.length === 0)
1406
- return r;
1407
- const n = /* @__PURE__ */ new Map();
1408
- for (const s of r)
1409
- n.set(s.key, { ...s });
1332
+ return n;
1333
+ const r = /* @__PURE__ */ new Map();
1334
+ for (const s of n)
1335
+ r.set(s.key, { ...s });
1410
1336
  for (const s of e) {
1411
- const o = n.get(s.key);
1337
+ const o = r.get(s.key);
1412
1338
  if (!o) {
1413
- n.set(s.key, { ...s });
1339
+ r.set(s.key, { ...s });
1414
1340
  continue;
1415
1341
  }
1416
1342
  const i = !!(o.met || s.met), l = s.status_reason ?? o.status_reason;
1417
- n.set(s.key, { key: s.key, met: i, status_reason: l });
1343
+ r.set(s.key, { key: s.key, met: i, status_reason: l });
1418
1344
  }
1419
- return Array.from(n.values());
1345
+ return Array.from(r.values());
1420
1346
  }
1421
- mergeAuthorizations(e, r = []) {
1347
+ mergeAuthorizations(e, n = []) {
1422
1348
  if (!e?.provider_id)
1423
- return r;
1424
- const n = new Map(r.map((i) => [i.provider_id, { ...i }])), s = n.get(e.provider_id);
1349
+ return n;
1350
+ const r = new Map(n.map((i) => [i.provider_id, { ...i }])), s = r.get(e.provider_id);
1425
1351
  if (!s)
1426
- return n.set(e.provider_id, { ...e }), Array.from(n.values());
1352
+ return r.set(e.provider_id, { ...e }), Array.from(r.values());
1427
1353
  const o = new Set(s.oauth2?.scopes ?? []);
1428
1354
  for (const i of e.oauth2?.scopes ?? [])
1429
1355
  o.add(i);
1430
- return n.set(e.provider_id, {
1356
+ return r.set(e.provider_id, {
1431
1357
  ...s,
1432
1358
  oauth2: {
1433
1359
  ...s.oauth2 ?? {},
1434
1360
  scopes: Array.from(o)
1435
1361
  }
1436
- }), Array.from(n.values());
1362
+ }), Array.from(r.values());
1437
1363
  }
1438
- mergeScopes(e, r = [], n = {}) {
1439
- if (!e || r.length === 0)
1440
- return n;
1441
- const s = new Set(n[e] ?? []);
1442
- for (const o of r)
1364
+ mergeScopes(e, n = [], r = {}) {
1365
+ if (!e || n.length === 0)
1366
+ return r;
1367
+ const s = new Set(r[e] ?? []);
1368
+ for (const o of n)
1443
1369
  s.add(o);
1444
- return { ...n, [e]: Array.from(s) };
1370
+ return { ...r, [e]: Array.from(s) };
1445
1371
  }
1446
1372
  /**
1447
1373
  * Pre-compute requirements summary for optimal UI performance.
1448
1374
  * This eliminates the need for runtime transformation in UI components.
1449
1375
  */
1450
1376
  computeRequirementsSummary(e) {
1451
- const r = e?.secrets?.length ? {
1377
+ const n = e?.secrets?.length ? {
1452
1378
  configured: e.secrets.filter((s) => s.met === !0).map((s) => s.key),
1453
1379
  pending: e.secrets.filter((s) => s.met === !1).map((s) => s.key)
1454
- } : void 0, n = e?.authorization?.length ? {
1380
+ } : void 0, r = e?.authorization?.length ? {
1455
1381
  providers: e.authorization.filter((s) => s.provider_id || s.id).map((s) => ({
1456
1382
  id: s.provider_id || s.id || "",
1457
1383
  status: s.status,
1458
1384
  scopes: s.oauth2?.scopes || []
1459
1385
  }))
1460
1386
  } : void 0;
1461
- return { secrets: r, oauth: n };
1387
+ return { secrets: n, oauth: r };
1462
1388
  }
1463
1389
  /**
1464
1390
  * Process raw toolkit data into an optimized collection with pre-computed search indices.
@@ -1470,7 +1396,7 @@ class Kt {
1470
1396
  * - Toolkit/tool mapping for quick relationships
1471
1397
  */
1472
1398
  async getProcessedToolkitCollection() {
1473
- const e = await this.getToolkits(), r = [], n = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = {
1399
+ const e = await this.getToolkits(), n = [], r = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = {
1474
1400
  toolkitsByName: /* @__PURE__ */ new Map(),
1475
1401
  toolsByName: /* @__PURE__ */ new Map()
1476
1402
  };
@@ -1485,9 +1411,9 @@ class Kt {
1485
1411
  ...c,
1486
1412
  searchableText: u,
1487
1413
  requirementsSummary: p,
1488
- metadata: tt[c.name]
1414
+ metadata: et[c.name]
1489
1415
  };
1490
- r.push(a), s.set(l, a), i.toolkitsByName.set(l.toLowerCase(), a);
1416
+ n.push(a), s.set(l, a), i.toolkitsByName.set(l.toLowerCase(), a);
1491
1417
  for (const h of c.tools) {
1492
1418
  const m = this.normalizeText([
1493
1419
  h.name,
@@ -1495,19 +1421,19 @@ class Kt {
1495
1421
  h.description ?? "",
1496
1422
  c.name,
1497
1423
  c.description ?? ""
1498
- ]), x = {
1424
+ ]), b = {
1499
1425
  ...h,
1500
1426
  searchableText: m
1501
1427
  };
1502
- n.push(x), o.set(h.fully_qualified_name, l), i.toolsByName.set(
1428
+ r.push(b), o.set(h.fully_qualified_name, l), i.toolsByName.set(
1503
1429
  h.fully_qualified_name.toLowerCase(),
1504
- x
1430
+ b
1505
1431
  );
1506
1432
  }
1507
1433
  }
1508
1434
  return {
1509
- toolkits: r,
1510
- tools: n,
1435
+ toolkits: n,
1436
+ tools: r,
1511
1437
  toolkitMap: s,
1512
1438
  toolToToolkitMap: o,
1513
1439
  searchIndex: i
@@ -1519,25 +1445,25 @@ class Kt {
1519
1445
  * Handles camelCase, snake_case, kebab-case, and dot.notation.
1520
1446
  */
1521
1447
  normalizeText(e) {
1522
- const r = /* @__PURE__ */ new Set();
1523
- for (const n of e) {
1524
- if (!n)
1448
+ const n = /* @__PURE__ */ new Set();
1449
+ for (const r of e) {
1450
+ if (!r)
1525
1451
  continue;
1526
- const s = n.toLowerCase();
1527
- r.add(s);
1528
- const o = n.split(jt);
1452
+ const s = r.toLowerCase();
1453
+ n.add(s);
1454
+ const o = r.split(Ut);
1529
1455
  for (const i of o) {
1530
1456
  if (i.length <= 1)
1531
1457
  continue;
1532
- const c = i.replace(Ut, "$1 $2").split(Bt);
1458
+ const c = i.replace($t, "$1 $2").split(jt);
1533
1459
  for (const u of c)
1534
- u.length > 1 && r.add(u.toLowerCase());
1460
+ u.length > 1 && n.add(u.toLowerCase());
1535
1461
  }
1536
1462
  }
1537
- return Array.from(r).join(" ");
1463
+ return Array.from(n).join(" ");
1538
1464
  }
1539
1465
  }
1540
1466
  export {
1541
- Kt as A,
1467
+ qt as A,
1542
1468
  d as a
1543
1469
  };