@animaapp/anima-sdk-react 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,415 +1,136 @@
1
- var dn = Object.defineProperty, hn = Object.defineProperties;
2
- var pn = Object.getOwnPropertyDescriptors;
3
- var Ct = Object.getOwnPropertySymbols;
4
- var En = Object.prototype.hasOwnProperty, mn = Object.prototype.propertyIsEnumerable;
5
- var At = (e, n, t) => n in e ? dn(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, k = (e, n) => {
1
+ var on = Object.defineProperty, an = Object.defineProperties;
2
+ var cn = Object.getOwnPropertyDescriptors;
3
+ var _t = Object.getOwnPropertySymbols;
4
+ var un = Object.prototype.hasOwnProperty, ln = Object.prototype.propertyIsEnumerable;
5
+ var yt = (e, n, t) => n in e ? on(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, L = (e, n) => {
6
6
  for (var t in n || (n = {}))
7
- En.call(n, t) && At(e, t, n[t]);
8
- if (Ct)
9
- for (var t of Ct(n))
10
- mn.call(n, t) && At(e, t, n[t]);
7
+ un.call(n, t) && yt(e, t, n[t]);
8
+ if (_t)
9
+ for (var t of _t(n))
10
+ ln.call(n, t) && yt(e, t, n[t]);
11
11
  return e;
12
- }, Ye = (e, n) => hn(e, pn(n));
13
- var H = (e, n, t) => new Promise((r, o) => {
14
- var u = (s) => {
12
+ }, Me = (e, n) => an(e, cn(n));
13
+ var V = (e, n, t) => new Promise((s, i) => {
14
+ var c = (r) => {
15
15
  try {
16
- l(t.next(s));
17
- } catch (i) {
18
- o(i);
16
+ l(t.next(r));
17
+ } catch (o) {
18
+ i(o);
19
19
  }
20
- }, a = (s) => {
20
+ }, a = (r) => {
21
21
  try {
22
- l(t.throw(s));
23
- } catch (i) {
24
- o(i);
22
+ l(t.throw(r));
23
+ } catch (o) {
24
+ i(o);
25
25
  }
26
- }, l = (s) => s.done ? r(s.value) : Promise.resolve(s.value).then(u, a);
26
+ }, l = (r) => r.done ? s(r.value) : Promise.resolve(r.value).then(c, a);
27
27
  l((t = t.apply(e, n)).next());
28
28
  });
29
- import be, { createContext as Yt, useState as rt, useRef as ue, useEffect as Bt, useContext as Ht, useCallback as $e, useLayoutEffect as gn, useMemo as zt, useDebugValue as vn } from "react";
30
- import { CodegenError as Be } from "@animaapp/anima-sdk";
31
- var Pe = { exports: {} }, Ce = {};
32
- /**
33
- * @license React
34
- * react-jsx-runtime.production.js
35
- *
36
- * Copyright (c) Meta Platforms, Inc. and affiliates.
37
- *
38
- * This source code is licensed under the MIT license found in the
39
- * LICENSE file in the root directory of this source tree.
40
- */
41
- var Lt;
42
- function _n() {
43
- if (Lt) return Ce;
44
- Lt = 1;
45
- var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
46
- function t(r, o, u) {
47
- var a = null;
48
- if (u !== void 0 && (a = "" + u), o.key !== void 0 && (a = "" + o.key), "key" in o) {
49
- u = {};
50
- for (var l in o)
51
- l !== "key" && (u[l] = o[l]);
52
- } else u = o;
53
- return o = u.ref, {
54
- $$typeof: e,
55
- type: r,
56
- key: a,
57
- ref: o !== void 0 ? o : null,
58
- props: u
59
- };
60
- }
61
- return Ce.Fragment = n, Ce.jsx = t, Ce.jsxs = t, Ce;
62
- }
63
- var Ae = {};
64
- /**
65
- * @license React
66
- * react-jsx-runtime.development.js
67
- *
68
- * Copyright (c) Meta Platforms, Inc. and affiliates.
69
- *
70
- * This source code is licensed under the MIT license found in the
71
- * LICENSE file in the root directory of this source tree.
72
- */
73
- var Nt;
74
- function Sn() {
75
- return Nt || (Nt = 1, process.env.NODE_ENV !== "production" && (function() {
76
- function e(c) {
77
- if (c == null) return null;
78
- if (typeof c == "function")
79
- return c.$$typeof === G ? null : c.displayName || c.name || null;
80
- if (typeof c == "string") return c;
81
- switch (c) {
82
- case d:
83
- return "Fragment";
84
- case f:
85
- return "Profiler";
86
- case g:
87
- return "StrictMode";
88
- case T:
89
- return "Suspense";
90
- case I:
91
- return "SuspenseList";
92
- case ae:
93
- return "Activity";
94
- }
95
- if (typeof c == "object")
96
- switch (typeof c.tag == "number" && console.error(
97
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
98
- ), c.$$typeof) {
99
- case E:
100
- return "Portal";
101
- case O:
102
- return (c.displayName || "Context") + ".Provider";
103
- case w:
104
- return (c._context.displayName || "Context") + ".Consumer";
105
- case M:
106
- var _ = c.render;
107
- return c = c.displayName, c || (c = _.displayName || _.name || "", c = c !== "" ? "ForwardRef(" + c + ")" : "ForwardRef"), c;
108
- case q:
109
- return _ = c.displayName || null, _ !== null ? _ : e(c.type) || "Memo";
110
- case C:
111
- _ = c._payload, c = c._init;
112
- try {
113
- return e(c(_));
114
- } catch (b) {
115
- }
116
- }
117
- return null;
118
- }
119
- function n(c) {
120
- return "" + c;
121
- }
122
- function t(c) {
123
- try {
124
- n(c);
125
- var _ = !1;
126
- } catch (Y) {
127
- _ = !0;
128
- }
129
- if (_) {
130
- _ = console;
131
- var b = _.error, x = typeof Symbol == "function" && Symbol.toStringTag && c[Symbol.toStringTag] || c.constructor.name || "Object";
132
- return b.call(
133
- _,
134
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
135
- x
136
- ), n(c);
137
- }
138
- }
139
- function r(c) {
140
- if (c === d) return "<>";
141
- if (typeof c == "object" && c !== null && c.$$typeof === C)
142
- return "<...>";
143
- try {
144
- var _ = e(c);
145
- return _ ? "<" + _ + ">" : "<...>";
146
- } catch (b) {
147
- return "<...>";
148
- }
149
- }
150
- function o() {
151
- var c = X.A;
152
- return c === null ? null : c.getOwner();
153
- }
154
- function u() {
155
- return Error("react-stack-top-frame");
156
- }
157
- function a(c) {
158
- if (he.call(c, "key")) {
159
- var _ = Object.getOwnPropertyDescriptor(c, "key").get;
160
- if (_ && _.isReactWarning) return !1;
161
- }
162
- return c.key !== void 0;
163
- }
164
- function l(c, _) {
165
- function b() {
166
- ie || (ie = !0, console.error(
167
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
168
- _
169
- ));
170
- }
171
- b.isReactWarning = !0, Object.defineProperty(c, "key", {
172
- get: b,
173
- configurable: !0
174
- });
175
- }
176
- function s() {
177
- var c = e(this.type);
178
- return Re[c] || (Re[c] = !0, console.error(
179
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
180
- )), c = this.props.ref, c !== void 0 ? c : null;
181
- }
182
- function i(c, _, b, x, Y, $, Ee, me) {
183
- return b = $.ref, c = {
184
- $$typeof: p,
185
- type: c,
186
- key: _,
187
- props: $,
188
- _owner: Y
189
- }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(c, "ref", {
190
- enumerable: !1,
191
- get: s
192
- }) : Object.defineProperty(c, "ref", { enumerable: !1, value: null }), c._store = {}, Object.defineProperty(c._store, "validated", {
193
- configurable: !1,
194
- enumerable: !1,
195
- writable: !0,
196
- value: 0
197
- }), Object.defineProperty(c, "_debugInfo", {
198
- configurable: !1,
199
- enumerable: !1,
200
- writable: !0,
201
- value: null
202
- }), Object.defineProperty(c, "_debugStack", {
203
- configurable: !1,
204
- enumerable: !1,
205
- writable: !0,
206
- value: Ee
207
- }), Object.defineProperty(c, "_debugTask", {
208
- configurable: !1,
209
- enumerable: !1,
210
- writable: !0,
211
- value: me
212
- }), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c;
213
- }
214
- function h(c, _, b, x, Y, $, Ee, me) {
215
- var P = _.children;
216
- if (P !== void 0)
217
- if (x)
218
- if (Q(P)) {
219
- for (x = 0; x < P.length; x++)
220
- m(P[x]);
221
- Object.freeze && Object.freeze(P);
222
- } else
223
- console.error(
224
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
225
- );
226
- else m(P);
227
- if (he.call(_, "key")) {
228
- P = e(c);
229
- var ce = Object.keys(_).filter(function(Me) {
230
- return Me !== "key";
231
- });
232
- x = 0 < ce.length ? "{key: someKey, " + ce.join(": ..., ") + ": ...}" : "{key: someKey}", Te[P + x] || (ce = 0 < ce.length ? "{" + ce.join(": ..., ") + ": ...}" : "{}", console.error(
233
- `A props object containing a "key" prop is being spread into JSX:
234
- let props = %s;
235
- <%s {...props} />
236
- React keys must be passed directly to JSX without using spread:
237
- let props = %s;
238
- <%s key={someKey} {...props} />`,
239
- x,
240
- P,
241
- ce,
242
- P
243
- ), Te[P + x] = !0);
244
- }
245
- if (P = null, b !== void 0 && (t(b), P = "" + b), a(_) && (t(_.key), P = "" + _.key), "key" in _) {
246
- b = {};
247
- for (var te in _)
248
- te !== "key" && (b[te] = _[te]);
249
- } else b = _;
250
- return P && l(
251
- b,
252
- typeof c == "function" ? c.displayName || c.name || "Unknown" : c
253
- ), i(
254
- c,
255
- P,
256
- $,
257
- Y,
258
- o(),
259
- b,
260
- Ee,
261
- me
262
- );
263
- }
264
- function m(c) {
265
- typeof c == "object" && c !== null && c.$$typeof === p && c._store && (c._store.validated = 1);
266
- }
267
- var v = be, p = Symbol.for("react.transitional.element"), E = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), g = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), w = Symbol.for("react.consumer"), O = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), I = Symbol.for("react.suspense_list"), q = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), ae = Symbol.for("react.activity"), G = Symbol.for("react.client.reference"), X = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, he = Object.prototype.hasOwnProperty, Q = Array.isArray, D = console.createTask ? console.createTask : function() {
268
- return null;
269
- };
270
- v = {
271
- react_stack_bottom_frame: function(c) {
272
- return c();
273
- }
274
- };
275
- var ie, Re = {}, Oe = v.react_stack_bottom_frame.bind(
276
- v,
277
- u
278
- )(), ee = D(r(u)), Te = {};
279
- Ae.Fragment = d, Ae.jsx = function(c, _, b, x, Y) {
280
- var $ = 1e4 > X.recentlyCreatedOwnerStacks++;
281
- return h(
282
- c,
283
- _,
284
- b,
285
- !1,
286
- x,
287
- Y,
288
- $ ? Error("react-stack-top-frame") : Oe,
289
- $ ? D(r(c)) : ee
290
- );
291
- }, Ae.jsxs = function(c, _, b, x, Y) {
292
- var $ = 1e4 > X.recentlyCreatedOwnerStacks++;
293
- return h(
294
- c,
295
- _,
296
- b,
297
- !0,
298
- x,
299
- Y,
300
- $ ? Error("react-stack-top-frame") : Oe,
301
- $ ? D(r(c)) : ee
302
- );
303
- };
304
- })()), Ae;
305
- }
306
- var xt;
307
- function wn() {
308
- return xt || (xt = 1, process.env.NODE_ENV === "production" ? Pe.exports = _n() : Pe.exports = Sn()), Pe.exports;
309
- }
310
- var yn = wn();
311
- class kt extends Error {
29
+ import { jsx as dn } from "react/jsx-runtime";
30
+ import we, { createContext as Wt, useState as Ge, useRef as z, useEffect as Ft, useContext as Vt, useCallback as Le, useLayoutEffect as fn, useMemo as Pt, useDebugValue as hn } from "react";
31
+ import { CodegenError as ke } from "@animaapp/anima-sdk";
32
+ class Ot extends Error {
312
33
  constructor(n, t) {
313
34
  super(n), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
314
35
  }
315
36
  }
316
- function He(e) {
37
+ function je(e) {
317
38
  }
318
- function bn(e) {
39
+ function pn(e) {
319
40
  if (typeof e == "function")
320
41
  throw new TypeError(
321
42
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
322
43
  );
323
- const { onEvent: n = He, onError: t = He, onRetry: r = He, onComment: o } = e;
324
- let u = "", a = !0, l, s = "", i = "";
325
- function h(d) {
326
- const g = a ? d.replace(/^\xEF\xBB\xBF/, "") : d, [f, w] = Rn(`${u}${g}`);
327
- for (const O of f)
328
- m(O);
329
- u = w, a = !1;
44
+ const { onEvent: n = je, onError: t = je, onRetry: s = je, onComment: i } = e;
45
+ let c = "", a = !0, l, r = "", o = "";
46
+ function f(d) {
47
+ const g = a ? d.replace(/^\xEF\xBB\xBF/, "") : d, [u, w] = gn(`${c}${g}`);
48
+ for (const O of u)
49
+ E(O);
50
+ c = w, a = !1;
330
51
  }
331
- function m(d) {
52
+ function E(d) {
332
53
  if (d === "") {
333
- p();
54
+ h();
334
55
  return;
335
56
  }
336
57
  if (d.startsWith(":")) {
337
- o && o(d.slice(d.startsWith(": ") ? 2 : 1));
58
+ i && i(d.slice(d.startsWith(": ") ? 2 : 1));
338
59
  return;
339
60
  }
340
61
  const g = d.indexOf(":");
341
62
  if (g !== -1) {
342
- const f = d.slice(0, g), w = d[g + 1] === " " ? 2 : 1, O = d.slice(g + w);
343
- v(f, O, d);
63
+ const u = d.slice(0, g), w = d[g + 1] === " " ? 2 : 1, O = d.slice(g + w);
64
+ m(u, O, d);
344
65
  return;
345
66
  }
346
- v(d, "", d);
67
+ m(d, "", d);
347
68
  }
348
- function v(d, g, f) {
69
+ function m(d, g, u) {
349
70
  switch (d) {
350
71
  case "event":
351
- i = g;
72
+ o = g;
352
73
  break;
353
74
  case "data":
354
- s = `${s}${g}
75
+ r = `${r}${g}
355
76
  `;
356
77
  break;
357
78
  case "id":
358
79
  l = g.includes("\0") ? void 0 : g;
359
80
  break;
360
81
  case "retry":
361
- /^\d+$/.test(g) ? r(parseInt(g, 10)) : t(
362
- new kt(`Invalid \`retry\` value: "${g}"`, {
82
+ /^\d+$/.test(g) ? s(parseInt(g, 10)) : t(
83
+ new Ot(`Invalid \`retry\` value: "${g}"`, {
363
84
  type: "invalid-retry",
364
85
  value: g,
365
- line: f
86
+ line: u
366
87
  })
367
88
  );
368
89
  break;
369
90
  default:
370
91
  t(
371
- new kt(
92
+ new Ot(
372
93
  `Unknown field "${d.length > 20 ? `${d.slice(0, 20)}…` : d}"`,
373
- { type: "unknown-field", field: d, value: g, line: f }
94
+ { type: "unknown-field", field: d, value: g, line: u }
374
95
  )
375
96
  );
376
97
  break;
377
98
  }
378
99
  }
379
- function p() {
380
- s.length > 0 && n({
100
+ function h() {
101
+ r.length > 0 && n({
381
102
  id: l,
382
- event: i || void 0,
103
+ event: o || void 0,
383
104
  // If the data buffer's last character is a U+000A LINE FEED (LF) character,
384
105
  // then remove the last character from the data buffer.
385
- data: s.endsWith(`
386
- `) ? s.slice(0, -1) : s
387
- }), l = void 0, s = "", i = "";
106
+ data: r.endsWith(`
107
+ `) ? r.slice(0, -1) : r
108
+ }), l = void 0, r = "", o = "";
388
109
  }
389
- function E(d = {}) {
390
- u && d.consume && m(u), a = !0, l = void 0, s = "", i = "", u = "";
110
+ function p(d = {}) {
111
+ c && d.consume && E(c), a = !0, l = void 0, r = "", o = "", c = "";
391
112
  }
392
- return { feed: h, reset: E };
113
+ return { feed: f, reset: p };
393
114
  }
394
- function Rn(e) {
115
+ function gn(e) {
395
116
  const n = [];
396
- let t = "", r = 0;
397
- for (; r < e.length; ) {
398
- const o = e.indexOf("\r", r), u = e.indexOf(`
399
- `, r);
117
+ let t = "", s = 0;
118
+ for (; s < e.length; ) {
119
+ const i = e.indexOf("\r", s), c = e.indexOf(`
120
+ `, s);
400
121
  let a = -1;
401
- if (o !== -1 && u !== -1 ? a = Math.min(o, u) : o !== -1 ? o === e.length - 1 ? a = -1 : a = o : u !== -1 && (a = u), a === -1) {
402
- t = e.slice(r);
122
+ if (i !== -1 && c !== -1 ? a = Math.min(i, c) : i !== -1 ? i === e.length - 1 ? a = -1 : a = i : c !== -1 && (a = c), a === -1) {
123
+ t = e.slice(s);
403
124
  break;
404
125
  } else {
405
- const l = e.slice(r, a);
406
- n.push(l), r = a + 1, e[r - 1] === "\r" && e[r] === `
407
- ` && r++;
126
+ const l = e.slice(s, a);
127
+ n.push(l), s = a + 1, e[s - 1] === "\r" && e[s] === `
128
+ ` && s++;
408
129
  }
409
130
  }
410
131
  return [n, t];
411
132
  }
412
- class It extends Event {
133
+ class bt extends Event {
413
134
  /**
414
135
  * Constructs a new `ErrorEvent` instance. This is typically not called directly,
415
136
  * but rather emitted by the `EventSource` object when an error occurs.
@@ -418,8 +139,8 @@ class It extends Event {
418
139
  * @param errorEventInitDict - Optional properties to include in the error event
419
140
  */
420
141
  constructor(n, t) {
421
- var r, o;
422
- super(n), this.code = (r = t == null ? void 0 : t.code) != null ? r : void 0, this.message = (o = t == null ? void 0 : t.message) != null ? o : void 0;
142
+ var s, i;
143
+ super(n), this.code = (s = t == null ? void 0 : t.code) != null ? s : void 0, this.message = (i = t == null ? void 0 : t.message) != null ? i : void 0;
423
144
  }
424
145
  /**
425
146
  * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
@@ -433,8 +154,8 @@ class It extends Event {
433
154
  * @param inspect - The inspect function to use (prevents having to import it from `util`)
434
155
  * @returns A string representation of the error
435
156
  */
436
- [Symbol.for("nodejs.util.inspect.custom")](n, t, r) {
437
- return r(Dt(this), t);
157
+ [Symbol.for("nodejs.util.inspect.custom")](n, t, s) {
158
+ return s(Rt(this), t);
438
159
  }
439
160
  /**
440
161
  * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
@@ -448,17 +169,17 @@ class It extends Event {
448
169
  * @returns A string representation of the error
449
170
  */
450
171
  [Symbol.for("Deno.customInspect")](n, t) {
451
- return n(Dt(this), t);
172
+ return n(Rt(this), t);
452
173
  }
453
174
  }
454
- function On(e) {
175
+ function En(e) {
455
176
  const n = globalThis.DOMException;
456
177
  return typeof n == "function" ? new n(e, "SyntaxError") : new SyntaxError(e);
457
178
  }
458
- function st(e) {
459
- return e instanceof Error ? "errors" in e && Array.isArray(e.errors) ? e.errors.map(st).join(", ") : "cause" in e && e.cause instanceof Error ? `${e}: ${st(e.cause)}` : e.message : `${e}`;
179
+ function Be(e) {
180
+ return e instanceof Error ? "errors" in e && Array.isArray(e.errors) ? e.errors.map(Be).join(", ") : "cause" in e && e.cause instanceof Error ? `${e}: ${Be(e.cause)}` : e.message : `${e}`;
460
181
  }
461
- function Dt(e) {
182
+ function Rt(e) {
462
183
  return {
463
184
  type: e.type,
464
185
  message: e.message,
@@ -468,71 +189,71 @@ function Dt(e) {
468
189
  timeStamp: e.timeStamp
469
190
  };
470
191
  }
471
- var Kt = (e) => {
192
+ var $t = (e) => {
472
193
  throw TypeError(e);
473
- }, St = (e, n, t) => n.has(e) || Kt("Cannot " + t), S = (e, n, t) => (St(e, n, "read from private field"), t ? t.call(e) : n.get(e)), j = (e, n, t) => n.has(e) ? Kt("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), L = (e, n, t, r) => (St(e, n, "write to private field"), n.set(e, t), t), se = (e, n, t) => (St(e, n, "access private method"), t), J, pe, ve, Ue, Je, xe, we, ke, le, _e, ye, Se, Le, K, ot, at, it, jt, ct, ut, Ne, lt, ft;
474
- class Ie extends EventTarget {
194
+ }, ct = (e, n, t) => n.has(e) || $t("Cannot " + t), S = (e, n, t) => (ct(e, n, "read from private field"), t ? t.call(e) : n.get(e)), I = (e, n, t) => n.has(e) ? $t("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), R = (e, n, t, s) => (ct(e, n, "write to private field"), n.set(e, t), t), H = (e, n, t) => (ct(e, n, "access private method"), t), W, te, ie, Ie, De, Ee, le, me, Y, ce, de, ue, pe, $, He, Ke, ze, Tt, Ye, Xe, ge, Qe, Ze;
195
+ class Se extends EventTarget {
475
196
  constructor(n, t) {
476
- var r, o;
477
- super(), j(this, K), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, j(this, J), j(this, pe), j(this, ve), j(this, Ue), j(this, Je), j(this, xe), j(this, we), j(this, ke, null), j(this, le), j(this, _e), j(this, ye, null), j(this, Se, null), j(this, Le, null), j(this, at, (u) => H(this, null, function* () {
197
+ var s, i;
198
+ super(), I(this, $), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, I(this, W), I(this, te), I(this, ie), I(this, Ie), I(this, De), I(this, Ee), I(this, le), I(this, me, null), I(this, Y), I(this, ce), I(this, de, null), I(this, ue, null), I(this, pe, null), I(this, Ke, (c) => V(this, null, function* () {
478
199
  var a;
479
- S(this, _e).reset();
480
- const { body: l, redirected: s, status: i, headers: h } = u;
481
- if (i === 204) {
482
- se(this, K, Ne).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
200
+ S(this, ce).reset();
201
+ const { body: l, redirected: r, status: o, headers: f } = c;
202
+ if (o === 204) {
203
+ H(this, $, ge).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
483
204
  return;
484
205
  }
485
- if (s ? L(this, ve, new URL(u.url)) : L(this, ve, void 0), i !== 200) {
486
- se(this, K, Ne).call(this, `Non-200 status code (${i})`, i);
206
+ if (r ? R(this, ie, new URL(c.url)) : R(this, ie, void 0), o !== 200) {
207
+ H(this, $, ge).call(this, `Non-200 status code (${o})`, o);
487
208
  return;
488
209
  }
489
- if (!(h.get("content-type") || "").startsWith("text/event-stream")) {
490
- se(this, K, Ne).call(this, 'Invalid content type, expected "text/event-stream"', i);
210
+ if (!(f.get("content-type") || "").startsWith("text/event-stream")) {
211
+ H(this, $, ge).call(this, 'Invalid content type, expected "text/event-stream"', o);
491
212
  return;
492
213
  }
493
- if (S(this, J) === this.CLOSED)
214
+ if (S(this, W) === this.CLOSED)
494
215
  return;
495
- L(this, J, this.OPEN);
496
- const m = new Event("open");
497
- if ((a = S(this, Le)) == null || a.call(this, m), this.dispatchEvent(m), typeof l != "object" || !l || !("getReader" in l)) {
498
- se(this, K, Ne).call(this, "Invalid response body, expected a web ReadableStream", i), this.close();
216
+ R(this, W, this.OPEN);
217
+ const E = new Event("open");
218
+ if ((a = S(this, pe)) == null || a.call(this, E), this.dispatchEvent(E), typeof l != "object" || !l || !("getReader" in l)) {
219
+ H(this, $, ge).call(this, "Invalid response body, expected a web ReadableStream", o), this.close();
499
220
  return;
500
221
  }
501
- const v = new TextDecoder(), p = l.getReader();
502
- let E = !0;
222
+ const m = new TextDecoder(), h = l.getReader();
223
+ let p = !0;
503
224
  do {
504
- const { done: d, value: g } = yield p.read();
505
- g && S(this, _e).feed(v.decode(g, { stream: !d })), d && (E = !1, S(this, _e).reset(), se(this, K, lt).call(this));
506
- } while (E);
507
- })), j(this, it, (u) => {
508
- L(this, le, void 0), !(u.name === "AbortError" || u.type === "aborted") && se(this, K, lt).call(this, st(u));
509
- }), j(this, ct, (u) => {
510
- typeof u.id == "string" && L(this, ke, u.id);
511
- const a = new MessageEvent(u.event || "message", {
512
- data: u.data,
513
- origin: S(this, ve) ? S(this, ve).origin : S(this, pe).origin,
514
- lastEventId: u.id || ""
225
+ const { done: d, value: g } = yield h.read();
226
+ g && S(this, ce).feed(m.decode(g, { stream: !d })), d && (p = !1, S(this, ce).reset(), H(this, $, Qe).call(this));
227
+ } while (p);
228
+ })), I(this, ze, (c) => {
229
+ R(this, Y, void 0), !(c.name === "AbortError" || c.type === "aborted") && H(this, $, Qe).call(this, Be(c));
230
+ }), I(this, Ye, (c) => {
231
+ typeof c.id == "string" && R(this, me, c.id);
232
+ const a = new MessageEvent(c.event || "message", {
233
+ data: c.data,
234
+ origin: S(this, ie) ? S(this, ie).origin : S(this, te).origin,
235
+ lastEventId: c.id || ""
515
236
  });
516
- S(this, Se) && (!u.event || u.event === "message") && S(this, Se).call(this, a), this.dispatchEvent(a);
517
- }), j(this, ut, (u) => {
518
- L(this, xe, u);
519
- }), j(this, ft, () => {
520
- L(this, we, void 0), S(this, J) === this.CONNECTING && se(this, K, ot).call(this);
237
+ S(this, ue) && (!c.event || c.event === "message") && S(this, ue).call(this, a), this.dispatchEvent(a);
238
+ }), I(this, Xe, (c) => {
239
+ R(this, Ee, c);
240
+ }), I(this, Ze, () => {
241
+ R(this, le, void 0), S(this, W) === this.CONNECTING && H(this, $, He).call(this);
521
242
  });
522
243
  try {
523
244
  if (n instanceof URL)
524
- L(this, pe, n);
245
+ R(this, te, n);
525
246
  else if (typeof n == "string")
526
- L(this, pe, new URL(n, Tn()));
247
+ R(this, te, new URL(n, mn()));
527
248
  else
528
249
  throw new Error("Invalid URL");
529
- } catch (u) {
530
- throw On("An invalid or illegal string was specified");
250
+ } catch (c) {
251
+ throw En("An invalid or illegal string was specified");
531
252
  }
532
- L(this, _e, bn({
533
- onEvent: S(this, ct),
534
- onRetry: S(this, ut)
535
- })), L(this, J, this.CONNECTING), L(this, xe, 3e3), L(this, Je, (r = t == null ? void 0 : t.fetch) != null ? r : globalThis.fetch), L(this, Ue, (o = t == null ? void 0 : t.withCredentials) != null ? o : !1), se(this, K, ot).call(this);
253
+ R(this, ce, pn({
254
+ onEvent: S(this, Ye),
255
+ onRetry: S(this, Xe)
256
+ })), R(this, W, this.CONNECTING), R(this, Ee, 3e3), R(this, De, (s = t == null ? void 0 : t.fetch) != null ? s : globalThis.fetch), R(this, Ie, (i = t == null ? void 0 : t.withCredentials) != null ? i : !1), H(this, $, He).call(this);
536
257
  }
537
258
  /**
538
259
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -545,7 +266,7 @@ class Ie extends EventTarget {
545
266
  * @public
546
267
  */
547
268
  get readyState() {
548
- return S(this, J);
269
+ return S(this, W);
549
270
  }
550
271
  /**
551
272
  * Returns the URL providing the event stream.
@@ -555,7 +276,7 @@ class Ie extends EventTarget {
555
276
  * @public
556
277
  */
557
278
  get url() {
558
- return S(this, pe).href;
279
+ return S(this, te).href;
559
280
  }
560
281
  /**
561
282
  * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
@@ -563,36 +284,36 @@ class Ie extends EventTarget {
563
284
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
564
285
  */
565
286
  get withCredentials() {
566
- return S(this, Ue);
287
+ return S(this, Ie);
567
288
  }
568
289
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
569
290
  get onerror() {
570
- return S(this, ye);
291
+ return S(this, de);
571
292
  }
572
293
  set onerror(n) {
573
- L(this, ye, n);
294
+ R(this, de, n);
574
295
  }
575
296
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
576
297
  get onmessage() {
577
- return S(this, Se);
298
+ return S(this, ue);
578
299
  }
579
300
  set onmessage(n) {
580
- L(this, Se, n);
301
+ R(this, ue, n);
581
302
  }
582
303
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
583
304
  get onopen() {
584
- return S(this, Le);
305
+ return S(this, pe);
585
306
  }
586
307
  set onopen(n) {
587
- L(this, Le, n);
308
+ R(this, pe, n);
588
309
  }
589
- addEventListener(n, t, r) {
590
- const o = t;
591
- super.addEventListener(n, o, r);
310
+ addEventListener(n, t, s) {
311
+ const i = t;
312
+ super.addEventListener(n, i, s);
592
313
  }
593
- removeEventListener(n, t, r) {
594
- const o = t;
595
- super.removeEventListener(n, o, r);
314
+ removeEventListener(n, t, s) {
315
+ const i = t;
316
+ super.removeEventListener(n, i, s);
596
317
  }
597
318
  /**
598
319
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -602,46 +323,46 @@ class Ie extends EventTarget {
602
323
  * @public
603
324
  */
604
325
  close() {
605
- S(this, we) && clearTimeout(S(this, we)), S(this, J) !== this.CLOSED && (S(this, le) && S(this, le).abort(), L(this, J, this.CLOSED), L(this, le, void 0));
326
+ S(this, le) && clearTimeout(S(this, le)), S(this, W) !== this.CLOSED && (S(this, Y) && S(this, Y).abort(), R(this, W, this.CLOSED), R(this, Y, void 0));
606
327
  }
607
328
  }
608
- J = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), ve = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), we = /* @__PURE__ */ new WeakMap(), ke = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), _e = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakSet(), /**
329
+ W = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), ie = /* @__PURE__ */ new WeakMap(), Ie = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), ce = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), pe = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakSet(), /**
609
330
  * Connect to the given URL and start receiving events
610
331
  *
611
332
  * @internal
612
333
  */
613
- ot = function() {
614
- L(this, J, this.CONNECTING), L(this, le, new AbortController()), S(this, Je)(S(this, pe), se(this, K, jt).call(this)).then(S(this, at)).catch(S(this, it));
615
- }, at = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new WeakMap(), /**
334
+ He = function() {
335
+ R(this, W, this.CONNECTING), R(this, Y, new AbortController()), S(this, De)(S(this, te), H(this, $, Tt).call(this)).then(S(this, Ke)).catch(S(this, ze));
336
+ }, Ke = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), /**
616
337
  * Get request options for the `fetch()` request
617
338
  *
618
339
  * @returns The request options
619
340
  * @internal
620
341
  */
621
- jt = function() {
342
+ Tt = function() {
622
343
  var e;
623
344
  const n = {
624
345
  // [spec] Let `corsAttributeState` be `Anonymous`…
625
346
  // [spec] …will have their mode set to "cors"…
626
347
  mode: "cors",
627
348
  redirect: "follow",
628
- headers: k({ Accept: "text/event-stream" }, S(this, ke) ? { "Last-Event-ID": S(this, ke) } : void 0),
349
+ headers: L({ Accept: "text/event-stream" }, S(this, me) ? { "Last-Event-ID": S(this, me) } : void 0),
629
350
  cache: "no-store",
630
- signal: (e = S(this, le)) == null ? void 0 : e.signal
351
+ signal: (e = S(this, Y)) == null ? void 0 : e.signal
631
352
  };
632
353
  return "window" in globalThis && (n.credentials = this.withCredentials ? "include" : "same-origin"), n;
633
- }, ct = /* @__PURE__ */ new WeakMap(), ut = /* @__PURE__ */ new WeakMap(), /**
354
+ }, Ye = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), /**
634
355
  * Handles the process referred to in the EventSource specification as "failing a connection".
635
356
  *
636
357
  * @param error - The error causing the connection to fail
637
358
  * @param code - The HTTP status code, if available
638
359
  * @internal
639
360
  */
640
- Ne = function(e, n) {
361
+ ge = function(e, n) {
641
362
  var t;
642
- S(this, J) !== this.CLOSED && L(this, J, this.CLOSED);
643
- const r = new It("error", { code: n, message: e });
644
- (t = S(this, ye)) == null || t.call(this, r), this.dispatchEvent(r);
363
+ S(this, W) !== this.CLOSED && R(this, W, this.CLOSED);
364
+ const s = new bt("error", { code: n, message: e });
365
+ (t = S(this, de)) == null || t.call(this, s), this.dispatchEvent(s);
645
366
  }, /**
646
367
  * Schedules a reconnection attempt against the EventSource endpoint.
647
368
  *
@@ -649,40 +370,40 @@ Ne = function(e, n) {
649
370
  * @param code - The HTTP status code, if available
650
371
  * @internal
651
372
  */
652
- lt = function(e, n) {
373
+ Qe = function(e, n) {
653
374
  var t;
654
- if (S(this, J) === this.CLOSED)
375
+ if (S(this, W) === this.CLOSED)
655
376
  return;
656
- L(this, J, this.CONNECTING);
657
- const r = new It("error", { code: n, message: e });
658
- (t = S(this, ye)) == null || t.call(this, r), this.dispatchEvent(r), L(this, we, setTimeout(S(this, ft), S(this, xe)));
659
- }, ft = /* @__PURE__ */ new WeakMap(), /**
377
+ R(this, W, this.CONNECTING);
378
+ const s = new bt("error", { code: n, message: e });
379
+ (t = S(this, de)) == null || t.call(this, s), this.dispatchEvent(s), R(this, le, setTimeout(S(this, Ze), S(this, Ee)));
380
+ }, Ze = /* @__PURE__ */ new WeakMap(), /**
660
381
  * ReadyState representing an EventSource currently trying to connect
661
382
  *
662
383
  * @public
663
384
  */
664
- Ie.CONNECTING = 0, /**
385
+ Se.CONNECTING = 0, /**
665
386
  * ReadyState representing an EventSource connection that is open (eg connected)
666
387
  *
667
388
  * @public
668
389
  */
669
- Ie.OPEN = 1, /**
390
+ Se.OPEN = 1, /**
670
391
  * ReadyState representing an EventSource connection that is closed (eg disconnected)
671
392
  *
672
393
  * @public
673
394
  */
674
- Ie.CLOSED = 2;
675
- function Tn() {
395
+ Se.CLOSED = 2;
396
+ function mn() {
676
397
  const e = "document" in globalThis ? globalThis.document : void 0;
677
398
  return e && typeof e == "object" && "baseURI" in e && typeof e.baseURI == "string" ? e.baseURI : void 0;
678
399
  }
679
- const Cn = (e) => {
400
+ const Sn = (e) => {
680
401
  let n = "";
681
- const t = new Uint8Array(e), r = t.byteLength;
682
- for (let o = 0; o < r; o++)
683
- n += String.fromCharCode(t[o]);
402
+ const t = new Uint8Array(e), s = t.byteLength;
403
+ for (let i = 0; i < s; i++)
404
+ n += String.fromCharCode(t[i]);
684
405
  return btoa(n);
685
- }, wt = {
406
+ }, ut = {
686
407
  status: "idle",
687
408
  error: null,
688
409
  result: null,
@@ -695,348 +416,348 @@ const Cn = (e) => {
695
416
  jobSessionId: null,
696
417
  jobStatus: {},
697
418
  jobType: null
698
- }, Mt = 10, Xt = (e) => "path" in e ? {
419
+ }, Ct = 10, Ut = (e) => "path" in e ? {
699
420
  filePath: e.path.replace(/^\//, ""),
700
421
  referencePath: e.path === "/" ? "" : e.path
701
422
  // Workaround to avoid duplicated slashes in the URL. Ideally, the fix should be done in Codegen.
702
423
  } : {
703
424
  filePath: e.filePath.replace(/^\//, ""),
704
425
  referencePath: e.referencePath === "/" ? "" : e.referencePath
705
- }, Zt = ({
426
+ }, Jt = ({
706
427
  es: e,
707
428
  lastFetchResponse: n,
708
429
  stateUpdated: t
709
430
  }) => {
710
- const r = structuredClone(wt);
711
- return r.status = "pending", t(k({}, r)), new Promise((o, u) => {
431
+ const s = structuredClone(ut);
432
+ return s.status = "pending", t(L({}, s)), new Promise((i, c) => {
712
433
  const a = {};
713
- e.addEventListener("set_job_type", (s) => {
714
- const i = JSON.parse(
715
- s.data
434
+ e.addEventListener("set_job_type", (r) => {
435
+ const o = JSON.parse(
436
+ r.data
716
437
  );
717
- r.jobType = i.payload.jobType, t(k({}, r));
718
- }), e.addEventListener("start", (s) => {
719
- const i = JSON.parse(s.data);
720
- a.sessionId = i.sessionId, r.tasks.fetchDesign.status = "running", r.jobSessionId = i.sessionId, t(k({}, r));
721
- }), e.addEventListener("queueing", (s) => {
722
- const i = JSON.parse(s.data);
723
- r.jobSessionId = i.payload.sessionId, t(k({}, r));
724
- }), e.addEventListener("pre_codegen", (s) => {
438
+ s.jobType = o.payload.jobType, t(L({}, s));
439
+ }), e.addEventListener("start", (r) => {
440
+ const o = JSON.parse(r.data);
441
+ a.sessionId = o.sessionId, s.tasks.fetchDesign.status = "running", s.jobSessionId = o.sessionId, t(L({}, s));
442
+ }), e.addEventListener("queueing", (r) => {
443
+ const o = JSON.parse(r.data);
444
+ s.jobSessionId = o.payload.sessionId, t(L({}, s));
445
+ }), e.addEventListener("pre_codegen", (r) => {
725
446
  JSON.parse(
726
- s.data
727
- ).message === "Anima model built" && (r.tasks.fetchDesign.status = "finished", r.tasks.codeGeneration.status = "running", r.tasks.uploadAssets.status = "running", t(k({}, r)));
728
- }), e.addEventListener("figma_metadata", (s) => {
729
- const i = JSON.parse(
730
- s.data
447
+ r.data
448
+ ).message === "Anima model built" && (s.tasks.fetchDesign.status = "finished", s.tasks.codeGeneration.status = "running", s.tasks.uploadAssets.status = "running", t(L({}, s)));
449
+ }), e.addEventListener("figma_metadata", (r) => {
450
+ const o = JSON.parse(
451
+ r.data
731
452
  );
732
- a.figmaFileName = i.figmaFileName, a.figmaSelectedFrameName = i.figmaSelectedFrameName;
453
+ a.figmaFileName = o.figmaFileName, a.figmaSelectedFrameName = o.figmaSelectedFrameName;
733
454
  }), e.addEventListener("aborted", () => {
734
- const s = new Be({ name: "Aborted", reason: "Unknown" });
735
- r.status = "aborted", r.result = null, r.error = s, t(k({}, r)), o({
455
+ const r = new ke({ name: "Aborted", reason: "Unknown" });
456
+ s.status = "aborted", s.result = null, s.error = r, t(L({}, s)), i({
736
457
  result: null,
737
- error: s
458
+ error: r
738
459
  });
739
- }), e.addEventListener("generating_code", (s) => {
740
- const i = JSON.parse(
741
- s.data
460
+ }), e.addEventListener("generating_code", (r) => {
461
+ const o = JSON.parse(
462
+ r.data
742
463
  );
743
- i.payload.status === "success" && (a.files = i.payload.files), r.tasks.codeGeneration.progress = i.payload.progress, r.tasks.codeGeneration.status = "running", t(k({}, r));
744
- }), e.addEventListener("progress_messages_updated", (s) => {
745
- const i = JSON.parse(
746
- s.data
464
+ o.payload.status === "success" && (a.files = o.payload.files), s.tasks.codeGeneration.progress = o.payload.progress, s.tasks.codeGeneration.status = "running", t(L({}, s));
465
+ }), e.addEventListener("progress_messages_updated", (r) => {
466
+ const o = JSON.parse(
467
+ r.data
747
468
  );
748
- r.progressMessages = i.payload.progressMessages, t(k({}, r));
749
- }), e.addEventListener("job_status_updated", (s) => {
750
- const i = JSON.parse(
751
- s.data
469
+ s.progressMessages = o.payload.progressMessages, t(L({}, s));
470
+ }), e.addEventListener("job_status_updated", (r) => {
471
+ const o = JSON.parse(
472
+ r.data
752
473
  );
753
- r.jobStatus = i.payload.jobStatus, t(k({}, r));
474
+ s.jobStatus = o.payload.jobStatus, t(L({}, s));
754
475
  }), e.addEventListener("codegen_completed", () => {
755
- r.tasks.codeGeneration.status = "finished", t(k({}, r));
476
+ s.tasks.codeGeneration.status = "finished", t(L({}, s));
756
477
  }), e.addEventListener("generation_completed", () => {
757
- r.tasks.codeGeneration.status = "finished", t(k({}, r));
478
+ s.tasks.codeGeneration.status = "finished", t(L({}, s));
758
479
  }), e.addEventListener("assets_uploaded", () => {
759
- r.tasks.uploadAssets.status = "finished", t(k({}, r));
760
- }), e.addEventListener("assets_list", (s) => {
761
- const i = JSON.parse(
762
- s.data
480
+ s.tasks.uploadAssets.status = "finished", t(L({}, s));
481
+ }), e.addEventListener("assets_list", (r) => {
482
+ const o = JSON.parse(
483
+ r.data
763
484
  );
764
- a.assets = i.payload.assets;
485
+ a.assets = o.payload.assets;
765
486
  });
766
487
  let l = 0;
767
- e.addEventListener("error", (s) => H(null, null, function* () {
768
- var E, d, g, f, w, O, M;
488
+ e.addEventListener("error", (r) => V(null, null, function* () {
489
+ var p, d, g, u, w, O, x;
769
490
  if (!n)
770
491
  return;
771
- const i = yield n;
772
- if (!i.ok) {
773
- let T = "";
492
+ const o = yield n;
493
+ if (!o.ok) {
494
+ let b = "";
774
495
  try {
775
- T = yield i.text();
776
- const I = JSON.parse(T);
777
- (E = I == null ? void 0 : I.payload) != null && E.message && (T = I.payload.message);
778
- } catch (I) {
496
+ b = yield o.text();
497
+ const D = JSON.parse(b);
498
+ (p = D == null ? void 0 : D.payload) != null && p.message && (b = D.payload.message);
499
+ } catch (D) {
779
500
  }
780
- u(
781
- new Be({
501
+ c(
502
+ new ke({
782
503
  name: "Request failed",
783
504
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
784
- reason: T,
785
- status: i.status
505
+ reason: b,
506
+ status: o.status
786
507
  })
787
508
  ), e.close();
788
509
  return;
789
510
  }
790
511
  console.warn(
791
- `Experienced error during code generation (attempt ${l + 1} / ${Mt})`,
792
- s
512
+ `Experienced error during code generation (attempt ${l + 1} / ${Ct})`,
513
+ r
793
514
  );
794
- let h, m = !1;
795
- if (s instanceof MessageEvent)
515
+ let f, E = !1;
516
+ if (r instanceof MessageEvent)
796
517
  try {
797
- h = JSON.parse(s.data);
798
- } catch (T) {
518
+ f = JSON.parse(r.data);
519
+ } catch (b) {
799
520
  }
800
- (((d = h == null ? void 0 : h.payload) == null ? void 0 : d.name) === "Task Crashed" || ((g = h == null ? void 0 : h.payload) == null ? void 0 : g.name) === "TimeoutError" || ((f = h == null ? void 0 : h.payload) == null ? void 0 : f.name) === "Error" || ((w = h == null ? void 0 : h.payload) == null ? void 0 : w.name) === "Unknown error") && (m = !0);
801
- const v = new Be({
802
- name: (O = h == null ? void 0 : h.payload.name) != null ? O : "Unknown error",
803
- reason: (M = h == null ? void 0 : h.payload.message) != null ? M : "Unknown",
804
- status: h == null ? void 0 : h.payload.status,
805
- detail: h == null ? void 0 : h.payload.detail
521
+ (((d = f == null ? void 0 : f.payload) == null ? void 0 : d.name) === "Task Crashed" || ((g = f == null ? void 0 : f.payload) == null ? void 0 : g.name) === "TimeoutError" || ((u = f == null ? void 0 : f.payload) == null ? void 0 : u.name) === "Error" || ((w = f == null ? void 0 : f.payload) == null ? void 0 : w.name) === "Unknown error") && (E = !0);
522
+ const m = new ke({
523
+ name: (O = f == null ? void 0 : f.payload.name) != null ? O : "Unknown error",
524
+ reason: (x = f == null ? void 0 : f.payload.message) != null ? x : "Unknown",
525
+ status: f == null ? void 0 : f.payload.status,
526
+ detail: f == null ? void 0 : f.payload.detail
806
527
  });
807
528
  l++;
808
- let p = !1;
809
- l > Mt ? (console.error("Experienced too many errors, terminating request"), p = !0) : m && (console.error("Experienced unrecoverable error, terminating request"), p = !0), p && (r.status = "error", r.error = v, t(k({}, r)), o({
529
+ let h = !1;
530
+ l > Ct ? (console.error("Experienced too many errors, terminating request"), h = !0) : E && (console.error("Experienced unrecoverable error, terminating request"), h = !0), h && (s.status = "error", s.error = m, t(L({}, s)), i({
810
531
  result: null,
811
- error: v
532
+ error: m
812
533
  }));
813
- })), e.addEventListener("done", (s) => {
814
- const i = JSON.parse(s.data);
815
- a.tokenUsage = i.payload.tokenUsage, a.sessionId = i.payload.sessionId, r.status = "success", r.result = a, t(k({}, r)), o({ result: a, error: null });
534
+ })), e.addEventListener("done", (r) => {
535
+ const o = JSON.parse(r.data);
536
+ a.tokenUsage = o.payload.tokenUsage, a.sessionId = o.payload.sessionId, s.status = "success", s.result = a, t(L({}, s)), i({ result: a, error: null });
816
537
  });
817
538
  });
818
- }, Qt = (e, n, t, r) => H(null, null, function* () {
539
+ }, qt = (e, n, t, s) => V(null, null, function* () {
819
540
  var l;
820
- const o = structuredClone(t);
541
+ const i = structuredClone(t);
821
542
  if (((l = t.assetsStorage) == null ? void 0 : l.strategy) === "local") {
822
- const { referencePath: s } = Xt(
543
+ const { referencePath: r } = Ut(
823
544
  t.assetsStorage
824
545
  );
825
- t.assetsStorage = { strategy: "external", url: s };
546
+ t.assetsStorage = { strategy: "external", url: r };
826
547
  }
827
- let u;
828
- const a = new Ie(e, {
829
- fetch: (s, i) => (u = fetch(s, Ye(k({}, i), {
548
+ let c;
549
+ const a = new Se(e, {
550
+ fetch: (r, o) => (c = fetch(r, Me(L({}, o), {
830
551
  method: n,
831
552
  body: JSON.stringify(t)
832
- })), u)
553
+ })), c)
833
554
  });
834
555
  try {
835
- const { result: s, error: i } = yield Zt({
556
+ const { result: r, error: o } = yield Jt({
836
557
  es: a,
837
- lastFetchResponse: u,
838
- stateUpdated: r
558
+ lastFetchResponse: c,
559
+ stateUpdated: s
839
560
  });
840
- if (i || !s)
841
- return { result: null, error: i };
842
- const h = structuredClone(s);
843
- return en(h, o), { result: h, error: null };
561
+ if (o || !r)
562
+ return { result: null, error: o };
563
+ const f = structuredClone(r);
564
+ return Gt(f, i), { result: f, error: null };
844
565
  } finally {
845
566
  a.close();
846
567
  }
847
- }), An = (e, n, t) => H(null, null, function* () {
848
- const r = structuredClone(n);
849
- let o;
850
- const u = new Ie(e, {
851
- fetch: (a, l) => (o = fetch(a, Ye(k({}, l), {
568
+ }), vn = (e, n, t) => V(null, null, function* () {
569
+ const s = structuredClone(n);
570
+ let i;
571
+ const c = new Se(e, {
572
+ fetch: (a, l) => (i = fetch(a, Me(L({}, l), {
852
573
  method: "POST",
853
574
  body: JSON.stringify(n)
854
- })), o)
575
+ })), i)
855
576
  });
856
577
  try {
857
- const { result: a, error: l } = yield Zt({
858
- es: u,
859
- lastFetchResponse: o,
578
+ const { result: a, error: l } = yield Jt({
579
+ es: c,
580
+ lastFetchResponse: i,
860
581
  stateUpdated: t
861
582
  });
862
583
  if (l || !a)
863
584
  return { result: null, error: l };
864
- const s = structuredClone(a);
865
- return en(s, r), { result: s, error: null };
585
+ const r = structuredClone(a);
586
+ return Gt(r, s), { result: r, error: null };
866
587
  } finally {
867
- u.close();
588
+ c.close();
868
589
  }
869
- }), en = (e, n) => H(null, null, function* () {
870
- var t, r;
871
- if (((t = n.assetsStorage) == null ? void 0 : t.strategy) === "local" && ((r = e.assets) != null && r.length)) {
872
- const { filePath: o } = Xt(n.assetsStorage), u = e.assets.map(
873
- (l) => H(null, null, function* () {
874
- const i = yield (yield fetch(l.url)).arrayBuffer();
590
+ }), Gt = (e, n) => V(null, null, function* () {
591
+ var t, s;
592
+ if (((t = n.assetsStorage) == null ? void 0 : t.strategy) === "local" && ((s = e.assets) != null && s.length)) {
593
+ const { filePath: i } = Ut(n.assetsStorage), c = e.assets.map(
594
+ (l) => V(null, null, function* () {
595
+ const o = yield (yield fetch(l.url)).arrayBuffer();
875
596
  return {
876
597
  assetName: l.name,
877
- base64: Cn(i)
598
+ base64: Sn(o)
878
599
  };
879
600
  })
880
- ), a = yield Promise.allSettled(u);
601
+ ), a = yield Promise.allSettled(c);
881
602
  for (const l of a)
882
603
  if (l.status === "fulfilled") {
883
- const { assetName: s, base64: i } = l.value, h = o ? `${o}/${s}` : s;
884
- e.files[h] = {
885
- content: i,
604
+ const { assetName: r, base64: o } = l.value, f = i ? `${i}/${r}` : r;
605
+ e.files[f] = {
606
+ content: o,
886
607
  isBinary: !0
887
608
  };
888
609
  }
889
610
  }
890
611
  });
891
- class Ln extends Error {
612
+ class wn extends Error {
892
613
  constructor(n, t) {
893
614
  super(n), this.name = "CreateJobError", this.cause = t;
894
615
  }
895
616
  }
896
- class Nn extends Error {
617
+ class _n extends Error {
897
618
  constructor(n, t) {
898
619
  super(n), this.name = "AttachJobError", this.cause = t;
899
620
  }
900
621
  }
901
- class xn extends Error {
622
+ class yn extends Error {
902
623
  constructor() {
903
624
  super(""), this.name = "UnknownCodegenError";
904
625
  }
905
626
  }
906
- const tn = Yt(null);
907
- function gr({ figmaRestApi: e, f2cUrl: n, l2cUrl: t, p2cUrl: r, jobsUrl: o, children: u }) {
908
- const [a, l] = rt({ status: "idle" }), s = ue(null), [i, h] = rt(wt), m = {
627
+ const Bt = Wt(null);
628
+ function us({ figmaRestApi: e, f2cUrl: n, l2cUrl: t, p2cUrl: s, jobsUrl: i, children: c }) {
629
+ const [a, l] = Ge({ status: "idle" }), r = z(null), [o, f] = Ge(ut), E = {
909
630
  f2c: n,
910
631
  l2c: t,
911
- p2c: r
912
- }, v = (E, d) => H(null, null, function* () {
632
+ p2c: s
633
+ }, m = (p, d) => V(null, null, function* () {
913
634
  var g;
914
635
  if (a.status === "pending")
915
636
  throw new Error("A job is already in progress");
916
- s.current = E;
637
+ r.current = p;
917
638
  try {
918
- const f = m[E], { result: w } = yield Qt(f, "POST", d, (O) => h(O));
639
+ const u = E[p], { result: w } = yield qt(u, "POST", d, (O) => f(O));
919
640
  if (w) {
920
- const O = w.sessionId, M = w.files, T = w.assets;
921
- l((I) => ({
641
+ const O = w.sessionId, x = w.files, b = w.assets;
642
+ l((D) => ({
922
643
  status: "success",
923
- type: E,
924
- params: "params" in I ? I.params : {},
644
+ type: p,
645
+ params: "params" in D ? D.params : {},
925
646
  sessionId: O,
926
- payload: i.jobStatus,
927
- assets: T,
928
- files: M,
929
- progressMessages: i.progressMessages
647
+ payload: o.jobStatus,
648
+ assets: b,
649
+ files: x,
650
+ progressMessages: o.progressMessages
930
651
  }));
931
652
  return;
932
653
  }
933
- } catch (f) {
934
- s.current = null;
935
- const w = f instanceof Error ? f.message : "Unknown error", O = new Ln(w, f);
654
+ } catch (u) {
655
+ r.current = null;
656
+ const w = u instanceof Error ? u.message : "Unknown error", O = new wn(w, u);
936
657
  throw l({
937
658
  status: "error",
938
- type: E,
659
+ type: p,
939
660
  params: d,
940
661
  error: O,
941
- sessionId: (g = i.jobSessionId) != null ? g : null,
942
- payload: i.jobStatus,
943
- progressMessages: i.progressMessages
662
+ sessionId: (g = o.jobSessionId) != null ? g : null,
663
+ payload: o.jobStatus,
664
+ progressMessages: o.progressMessages
944
665
  }), O;
945
666
  }
946
- }), p = (E, d) => H(null, null, function* () {
947
- if (!o)
667
+ }), h = (p, d) => V(null, null, function* () {
668
+ if (!i)
948
669
  throw new Error("jobsUrl is required in order to attach to a job");
949
670
  try {
950
- const g = `${o}/${E}`, { result: f } = yield An(
671
+ const g = `${i}/${p}`, { result: u } = yield vn(
951
672
  g,
952
673
  d,
953
- (w) => h(w)
674
+ (w) => f(w)
954
675
  );
955
- if (f) {
956
- const w = f.files, O = f.assets;
957
- l((M) => ({
676
+ if (u) {
677
+ const w = u.files, O = u.assets;
678
+ l((x) => ({
958
679
  status: "success",
959
- type: i.jobType,
960
- params: "params" in M ? M.params : {},
961
- sessionId: E,
962
- payload: i.jobStatus,
680
+ type: o.jobType,
681
+ params: "params" in x ? x.params : {},
682
+ sessionId: p,
683
+ payload: o.jobStatus,
963
684
  assets: O,
964
685
  files: w,
965
- progressMessages: i.progressMessages
686
+ progressMessages: o.progressMessages
966
687
  }));
967
688
  }
968
689
  } catch (g) {
969
- const f = g instanceof Error ? g.message : "Unknown error", w = new Nn(f, g);
690
+ const u = g instanceof Error ? g.message : "Unknown error", w = new _n(u, g);
970
691
  throw l({
971
692
  status: "error",
972
- type: s.current,
693
+ type: r.current,
973
694
  params: {},
974
695
  error: w,
975
- sessionId: E,
976
- payload: i.jobStatus,
977
- progressMessages: i.progressMessages
696
+ sessionId: p,
697
+ payload: o.jobStatus,
698
+ progressMessages: o.progressMessages
978
699
  }), w;
979
700
  }
980
701
  });
981
- return Bt(() => {
702
+ return Ft(() => {
982
703
  var d, g;
983
- const E = (d = s.current) != null ? d : i.jobType;
984
- if (E) {
985
- if (i.status === "error") {
986
- const f = (g = i.error) != null ? g : new xn();
704
+ const p = (d = r.current) != null ? d : o.jobType;
705
+ if (p) {
706
+ if (o.status === "error") {
707
+ const u = (g = o.error) != null ? g : new yn();
987
708
  l((w) => {
988
709
  var O;
989
710
  return {
990
711
  status: "error",
991
- type: E,
712
+ type: p,
992
713
  params: "params" in w ? w.params : {},
993
- error: f,
994
- sessionId: (O = i.jobSessionId) != null ? O : null,
995
- payload: i.jobStatus,
996
- progressMessages: i.progressMessages
714
+ error: u,
715
+ sessionId: (O = o.jobSessionId) != null ? O : null,
716
+ payload: o.jobStatus,
717
+ progressMessages: o.progressMessages
997
718
  };
998
719
  });
999
720
  return;
1000
721
  }
1001
- if (i.status === "pending") {
1002
- l((f) => ({
722
+ if (o.status === "pending") {
723
+ l((u) => ({
1003
724
  status: "pending",
1004
- type: E,
1005
- params: "params" in f ? f.params : {},
1006
- sessionId: i.jobSessionId,
1007
- payload: i.jobStatus,
1008
- progressMessages: i.progressMessages
725
+ type: p,
726
+ params: "params" in u ? u.params : {},
727
+ sessionId: o.jobSessionId,
728
+ payload: o.jobStatus,
729
+ progressMessages: o.progressMessages
1009
730
  }));
1010
731
  return;
1011
732
  }
1012
733
  }
1013
- }, [i]), /* @__PURE__ */ yn.jsx(
1014
- tn.Provider,
734
+ }, [o]), /* @__PURE__ */ dn(
735
+ Bt.Provider,
1015
736
  {
1016
737
  value: {
1017
- createJob: v,
1018
- attachJob: p,
738
+ createJob: m,
739
+ attachJob: h,
1019
740
  job: a,
1020
741
  figmaRestApi: e
1021
742
  },
1022
- children: u
743
+ children: c
1023
744
  }
1024
745
  );
1025
746
  }
1026
- function kn() {
1027
- const e = Ht(tn);
747
+ function On() {
748
+ const e = Vt(Bt);
1028
749
  if (!e)
1029
750
  throw new Error("useAnimaSDK must be used within AnimaSDKProvider");
1030
751
  return e;
1031
752
  }
1032
- const vr = ({
753
+ const ls = ({
1033
754
  url: e,
1034
755
  method: n = "POST"
1035
756
  }) => {
1036
- const [t, r] = rt(wt);
757
+ const [t, s] = Ge(ut);
1037
758
  return {
1038
- getCode: $e(
1039
- (u) => Qt(e, n, u, r),
759
+ getCode: Le(
760
+ (c) => qt(e, n, c, s),
1040
761
  [e, n]
1041
762
  ),
1042
763
  status: t.status,
@@ -1048,7 +769,7 @@ const vr = ({
1048
769
  result: t.result
1049
770
  };
1050
771
  };
1051
- var We = { exports: {} }, ze = {};
772
+ var Re = { exports: {} }, We = {};
1052
773
  /**
1053
774
  * @license React
1054
775
  * use-sync-external-store-shim.production.js
@@ -1058,48 +779,48 @@ var We = { exports: {} }, ze = {};
1058
779
  * This source code is licensed under the MIT license found in the
1059
780
  * LICENSE file in the root directory of this source tree.
1060
781
  */
1061
- var Pt;
1062
- function In() {
1063
- if (Pt) return ze;
1064
- Pt = 1;
1065
- var e = be;
1066
- function n(m, v) {
1067
- return m === v && (m !== 0 || 1 / m === 1 / v) || m !== m && v !== v;
782
+ var Lt;
783
+ function bn() {
784
+ if (Lt) return We;
785
+ Lt = 1;
786
+ var e = we;
787
+ function n(E, m) {
788
+ return E === m && (E !== 0 || 1 / E === 1 / m) || E !== E && m !== m;
1068
789
  }
1069
- var t = typeof Object.is == "function" ? Object.is : n, r = e.useState, o = e.useEffect, u = e.useLayoutEffect, a = e.useDebugValue;
1070
- function l(m, v) {
1071
- var p = v(), E = r({ inst: { value: p, getSnapshot: v } }), d = E[0].inst, g = E[1];
1072
- return u(
790
+ var t = typeof Object.is == "function" ? Object.is : n, s = e.useState, i = e.useEffect, c = e.useLayoutEffect, a = e.useDebugValue;
791
+ function l(E, m) {
792
+ var h = m(), p = s({ inst: { value: h, getSnapshot: m } }), d = p[0].inst, g = p[1];
793
+ return c(
1073
794
  function() {
1074
- d.value = p, d.getSnapshot = v, s(d) && g({ inst: d });
795
+ d.value = h, d.getSnapshot = m, r(d) && g({ inst: d });
1075
796
  },
1076
- [m, p, v]
1077
- ), o(
797
+ [E, h, m]
798
+ ), i(
1078
799
  function() {
1079
- return s(d) && g({ inst: d }), m(function() {
1080
- s(d) && g({ inst: d });
800
+ return r(d) && g({ inst: d }), E(function() {
801
+ r(d) && g({ inst: d });
1081
802
  });
1082
803
  },
1083
- [m]
1084
- ), a(p), p;
804
+ [E]
805
+ ), a(h), h;
1085
806
  }
1086
- function s(m) {
1087
- var v = m.getSnapshot;
1088
- m = m.value;
807
+ function r(E) {
808
+ var m = E.getSnapshot;
809
+ E = E.value;
1089
810
  try {
1090
- var p = v();
1091
- return !t(m, p);
1092
- } catch (E) {
811
+ var h = m();
812
+ return !t(E, h);
813
+ } catch (p) {
1093
814
  return !0;
1094
815
  }
1095
816
  }
1096
- function i(m, v) {
1097
- return v();
817
+ function o(E, m) {
818
+ return m();
1098
819
  }
1099
- var h = typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined" ? i : l;
1100
- return ze.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : h, ze;
820
+ var f = typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined" ? o : l;
821
+ return We.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : f, We;
1101
822
  }
1102
- var Ke = {};
823
+ var Fe = {};
1103
824
  /**
1104
825
  * @license React
1105
826
  * use-sync-external-store-shim.development.js
@@ -1109,341 +830,341 @@ var Ke = {};
1109
830
  * This source code is licensed under the MIT license found in the
1110
831
  * LICENSE file in the root directory of this source tree.
1111
832
  */
1112
- var Wt;
1113
- function Dn() {
1114
- return Wt || (Wt = 1, process.env.NODE_ENV !== "production" && (function() {
1115
- function e(p, E) {
1116
- return p === E && (p !== 0 || 1 / p === 1 / E) || p !== p && E !== E;
833
+ var It;
834
+ function Rn() {
835
+ return It || (It = 1, process.env.NODE_ENV !== "production" && (function() {
836
+ function e(h, p) {
837
+ return h === p && (h !== 0 || 1 / h === 1 / p) || h !== h && p !== p;
1117
838
  }
1118
- function n(p, E) {
1119
- h || o.startTransition === void 0 || (h = !0, console.error(
839
+ function n(h, p) {
840
+ f || i.startTransition === void 0 || (f = !0, console.error(
1120
841
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
1121
842
  ));
1122
- var d = E();
1123
- if (!m) {
1124
- var g = E();
1125
- u(d, g) || (console.error(
843
+ var d = p();
844
+ if (!E) {
845
+ var g = p();
846
+ c(d, g) || (console.error(
1126
847
  "The result of getSnapshot should be cached to avoid an infinite loop"
1127
- ), m = !0);
848
+ ), E = !0);
1128
849
  }
1129
850
  g = a({
1130
- inst: { value: d, getSnapshot: E }
851
+ inst: { value: d, getSnapshot: p }
1131
852
  });
1132
- var f = g[0].inst, w = g[1];
1133
- return s(
853
+ var u = g[0].inst, w = g[1];
854
+ return r(
1134
855
  function() {
1135
- f.value = d, f.getSnapshot = E, t(f) && w({ inst: f });
856
+ u.value = d, u.getSnapshot = p, t(u) && w({ inst: u });
1136
857
  },
1137
- [p, d, E]
858
+ [h, d, p]
1138
859
  ), l(
1139
860
  function() {
1140
- return t(f) && w({ inst: f }), p(function() {
1141
- t(f) && w({ inst: f });
861
+ return t(u) && w({ inst: u }), h(function() {
862
+ t(u) && w({ inst: u });
1142
863
  });
1143
864
  },
1144
- [p]
1145
- ), i(d), d;
865
+ [h]
866
+ ), o(d), d;
1146
867
  }
1147
- function t(p) {
1148
- var E = p.getSnapshot;
1149
- p = p.value;
868
+ function t(h) {
869
+ var p = h.getSnapshot;
870
+ h = h.value;
1150
871
  try {
1151
- var d = E();
1152
- return !u(p, d);
872
+ var d = p();
873
+ return !c(h, d);
1153
874
  } catch (g) {
1154
875
  return !0;
1155
876
  }
1156
877
  }
1157
- function r(p, E) {
1158
- return E();
878
+ function s(h, p) {
879
+ return p();
1159
880
  }
1160
881
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1161
- var o = be, u = typeof Object.is == "function" ? Object.is : e, a = o.useState, l = o.useEffect, s = o.useLayoutEffect, i = o.useDebugValue, h = !1, m = !1, v = typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined" ? r : n;
1162
- Ke.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1163
- })()), Ke;
882
+ var i = we, c = typeof Object.is == "function" ? Object.is : e, a = i.useState, l = i.useEffect, r = i.useLayoutEffect, o = i.useDebugValue, f = !1, E = !1, m = typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined" ? s : n;
883
+ Fe.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : m, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
884
+ })()), Fe;
1164
885
  }
1165
- var Ft;
1166
- function jn() {
1167
- return Ft || (Ft = 1, process.env.NODE_ENV === "production" ? We.exports = In() : We.exports = Dn()), We.exports;
886
+ var Dt;
887
+ function Tn() {
888
+ return Dt || (Dt = 1, process.env.NODE_ENV === "production" ? Re.exports = bn() : Re.exports = Rn()), Re.exports;
1168
889
  }
1169
- var Mn = jn();
1170
- const nn = 0, rn = 1, sn = 2, Vt = 3;
1171
- var $t = Object.prototype.hasOwnProperty;
1172
- function dt(e, n) {
1173
- var t, r;
890
+ var Cn = Tn();
891
+ const Ht = 0, Kt = 1, zt = 2, Nt = 3;
892
+ var At = Object.prototype.hasOwnProperty;
893
+ function et(e, n) {
894
+ var t, s;
1174
895
  if (e === n) return !0;
1175
896
  if (e && n && (t = e.constructor) === n.constructor) {
1176
897
  if (t === Date) return e.getTime() === n.getTime();
1177
898
  if (t === RegExp) return e.toString() === n.toString();
1178
899
  if (t === Array) {
1179
- if ((r = e.length) === n.length)
1180
- for (; r-- && dt(e[r], n[r]); ) ;
1181
- return r === -1;
900
+ if ((s = e.length) === n.length)
901
+ for (; s-- && et(e[s], n[s]); ) ;
902
+ return s === -1;
1182
903
  }
1183
904
  if (!t || typeof e == "object") {
1184
- r = 0;
905
+ s = 0;
1185
906
  for (t in e)
1186
- if ($t.call(e, t) && ++r && !$t.call(n, t) || !(t in n) || !dt(e[t], n[t])) return !1;
1187
- return Object.keys(n).length === r;
907
+ if (At.call(e, t) && ++s && !At.call(n, t) || !(t in n) || !et(e[t], n[t])) return !1;
908
+ return Object.keys(n).length === s;
1188
909
  }
1189
910
  }
1190
911
  return e !== e && n !== n;
1191
912
  }
1192
- const oe = /* @__PURE__ */ new WeakMap(), fe = () => {
1193
- }, V = (
913
+ const K = /* @__PURE__ */ new WeakMap(), X = () => {
914
+ }, M = (
1194
915
  /*#__NOINLINE__*/
1195
- fe()
1196
- ), ht = Object, y = (e) => e === V, Z = (e) => typeof e == "function", de = (e, n) => k(k({}, e), n), on = (e) => Z(e.then), Xe = {}, Fe = {}, yt = "undefined", je = typeof window != yt, pt = typeof document != yt, Pn = je && "Deno" in window, Wn = () => je && typeof window.requestAnimationFrame != yt, an = (e, n) => {
1197
- const t = oe.get(e);
916
+ X()
917
+ ), tt = Object, v = (e) => e === M, q = (e) => typeof e == "function", Q = (e, n) => L(L({}, e), n), Yt = (e) => q(e.then), Ve = {}, Te = {}, lt = "undefined", _e = typeof window != lt, nt = typeof document != lt, Ln = _e && "Deno" in window, In = () => _e && typeof window.requestAnimationFrame != lt, Xt = (e, n) => {
918
+ const t = K.get(e);
1198
919
  return [
1199
920
  // Getter
1200
- () => !y(n) && e.get(n) || Xe,
921
+ () => !v(n) && e.get(n) || Ve,
1201
922
  // Setter
1202
- (r) => {
1203
- if (!y(n)) {
1204
- const o = e.get(n);
1205
- n in Fe || (Fe[n] = o), t[5](n, de(o, r), o || Xe);
923
+ (s) => {
924
+ if (!v(n)) {
925
+ const i = e.get(n);
926
+ n in Te || (Te[n] = i), t[5](n, Q(i, s), i || Ve);
1206
927
  }
1207
928
  },
1208
929
  // Subscriber
1209
930
  t[6],
1210
931
  // Get server cache snapshot
1211
- () => !y(n) && n in Fe ? Fe[n] : !y(n) && e.get(n) || Xe
932
+ () => !v(n) && n in Te ? Te[n] : !v(n) && e.get(n) || Ve
1212
933
  ];
1213
934
  };
1214
- let Et = !0;
1215
- const Fn = () => Et, [mt, gt] = je && window.addEventListener ? [
935
+ let st = !0;
936
+ const Dn = () => st, [rt, ot] = _e && window.addEventListener ? [
1216
937
  window.addEventListener.bind(window),
1217
938
  window.removeEventListener.bind(window)
1218
939
  ] : [
1219
- fe,
1220
- fe
1221
- ], Vn = () => {
1222
- const e = pt && document.visibilityState;
1223
- return y(e) || e !== "hidden";
1224
- }, $n = (e) => (pt && document.addEventListener("visibilitychange", e), mt("focus", e), () => {
1225
- pt && document.removeEventListener("visibilitychange", e), gt("focus", e);
1226
- }), Un = (e) => {
940
+ X,
941
+ X
942
+ ], Nn = () => {
943
+ const e = nt && document.visibilityState;
944
+ return v(e) || e !== "hidden";
945
+ }, An = (e) => (nt && document.addEventListener("visibilitychange", e), rt("focus", e), () => {
946
+ nt && document.removeEventListener("visibilitychange", e), ot("focus", e);
947
+ }), xn = (e) => {
1227
948
  const n = () => {
1228
- Et = !0, e();
949
+ st = !0, e();
1229
950
  }, t = () => {
1230
- Et = !1;
951
+ st = !1;
1231
952
  };
1232
- return mt("online", n), mt("offline", t), () => {
1233
- gt("online", n), gt("offline", t);
953
+ return rt("online", n), rt("offline", t), () => {
954
+ ot("online", n), ot("offline", t);
1234
955
  };
1235
- }, Jn = {
1236
- isOnline: Fn,
1237
- isVisible: Vn
1238
- }, qn = {
1239
- initFocus: $n,
1240
- initReconnect: Un
1241
- }, Ut = !be.useId, De = !je || Pn, Gn = (e) => Wn() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Ze = De ? Bt : gn, Qe = typeof navigator != "undefined" && navigator.connection, Jt = !De && Qe && ([
956
+ }, Mn = {
957
+ isOnline: Dn,
958
+ isVisible: Nn
959
+ }, kn = {
960
+ initFocus: An,
961
+ initReconnect: xn
962
+ }, xt = !we.useId, ve = !_e || Ln, jn = (e) => In() ? window.requestAnimationFrame(e) : setTimeout(e, 1), Pe = ve ? Ft : fn, $e = typeof navigator != "undefined" && navigator.connection, Mt = !ve && $e && ([
1242
963
  "slow-2g",
1243
964
  "2g"
1244
- ].includes(Qe.effectiveType) || Qe.saveData), Ve = /* @__PURE__ */ new WeakMap(), Yn = (e) => ht.prototype.toString.call(e), et = (e, n) => e === `[object ${n}]`;
1245
- let Bn = 0;
1246
- const vt = (e) => {
1247
- const n = typeof e, t = Yn(e), r = et(t, "Date"), o = et(t, "RegExp"), u = et(t, "Object");
965
+ ].includes($e.effectiveType) || $e.saveData), Ce = /* @__PURE__ */ new WeakMap(), Wn = (e) => tt.prototype.toString.call(e), Ue = (e, n) => e === `[object ${n}]`;
966
+ let Fn = 0;
967
+ const at = (e) => {
968
+ const n = typeof e, t = Wn(e), s = Ue(t, "Date"), i = Ue(t, "RegExp"), c = Ue(t, "Object");
1248
969
  let a, l;
1249
- if (ht(e) === e && !r && !o) {
1250
- if (a = Ve.get(e), a) return a;
1251
- if (a = ++Bn + "~", Ve.set(e, a), Array.isArray(e)) {
970
+ if (tt(e) === e && !s && !i) {
971
+ if (a = Ce.get(e), a) return a;
972
+ if (a = ++Fn + "~", Ce.set(e, a), Array.isArray(e)) {
1252
973
  for (a = "@", l = 0; l < e.length; l++)
1253
- a += vt(e[l]) + ",";
1254
- Ve.set(e, a);
974
+ a += at(e[l]) + ",";
975
+ Ce.set(e, a);
1255
976
  }
1256
- if (u) {
977
+ if (c) {
1257
978
  a = "#";
1258
- const s = ht.keys(e).sort();
1259
- for (; !y(l = s.pop()); )
1260
- y(e[l]) || (a += l + ":" + vt(e[l]) + ",");
1261
- Ve.set(e, a);
979
+ const r = tt.keys(e).sort();
980
+ for (; !v(l = r.pop()); )
981
+ v(e[l]) || (a += l + ":" + at(e[l]) + ",");
982
+ Ce.set(e, a);
1262
983
  }
1263
984
  } else
1264
- a = r ? e.toJSON() : n == "symbol" ? e.toString() : n == "string" ? JSON.stringify(e) : "" + e;
985
+ a = s ? e.toJSON() : n == "symbol" ? e.toString() : n == "string" ? JSON.stringify(e) : "" + e;
1265
986
  return a;
1266
- }, bt = (e) => {
1267
- if (Z(e))
987
+ }, dt = (e) => {
988
+ if (q(e))
1268
989
  try {
1269
990
  e = e();
1270
991
  } catch (t) {
1271
992
  e = "";
1272
993
  }
1273
994
  const n = e;
1274
- return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? vt(e) : "", [
995
+ return e = typeof e == "string" ? e : (Array.isArray(e) ? e.length : e) ? at(e) : "", [
1275
996
  e,
1276
997
  n
1277
998
  ];
1278
999
  };
1279
- let Hn = 0;
1280
- const _t = () => ++Hn;
1281
- function cn(...e) {
1282
- return H(this, null, function* () {
1283
- const [n, t, r, o] = e, u = de({
1000
+ let Vn = 0;
1001
+ const it = () => ++Vn;
1002
+ function Qt(...e) {
1003
+ return V(this, null, function* () {
1004
+ const [n, t, s, i] = e, c = Q({
1284
1005
  populateCache: !0,
1285
1006
  throwOnError: !0
1286
- }, typeof o == "boolean" ? {
1287
- revalidate: o
1288
- } : o || {});
1289
- let a = u.populateCache;
1290
- const l = u.rollbackOnError;
1291
- let s = u.optimisticData;
1292
- const i = (v) => typeof l == "function" ? l(v) : l !== !1, h = u.throwOnError;
1293
- if (Z(t)) {
1294
- const v = t, p = [], E = n.keys();
1295
- for (const d of E)
1007
+ }, typeof i == "boolean" ? {
1008
+ revalidate: i
1009
+ } : i || {});
1010
+ let a = c.populateCache;
1011
+ const l = c.rollbackOnError;
1012
+ let r = c.optimisticData;
1013
+ const o = (m) => typeof l == "function" ? l(m) : l !== !1, f = c.throwOnError;
1014
+ if (q(t)) {
1015
+ const m = t, h = [], p = n.keys();
1016
+ for (const d of p)
1296
1017
  // Skip the special useSWRInfinite and useSWRSubscription keys.
1297
- !/^\$(inf|sub)\$/.test(d) && v(n.get(d)._k) && p.push(d);
1298
- return Promise.all(p.map(m));
1018
+ !/^\$(inf|sub)\$/.test(d) && m(n.get(d)._k) && h.push(d);
1019
+ return Promise.all(h.map(E));
1299
1020
  }
1300
- return m(t);
1301
- function m(v) {
1302
- return H(this, null, function* () {
1303
- const [p] = bt(v);
1304
- if (!p) return;
1305
- const [E, d] = an(n, p), [g, f, w, O] = oe.get(n), M = () => {
1306
- const D = g[p];
1307
- return (Z(u.revalidate) ? u.revalidate(E().data, v) : u.revalidate !== !1) && (delete w[p], delete O[p], D && D[0]) ? D[0](sn).then(() => E().data) : E().data;
1021
+ return E(t);
1022
+ function E(m) {
1023
+ return V(this, null, function* () {
1024
+ const [h] = dt(m);
1025
+ if (!h) return;
1026
+ const [p, d] = Xt(n, h), [g, u, w, O] = K.get(n), x = () => {
1027
+ const k = g[h];
1028
+ return (q(c.revalidate) ? c.revalidate(p().data, m) : c.revalidate !== !1) && (delete w[h], delete O[h], k && k[0]) ? k[0](zt).then(() => p().data) : p().data;
1308
1029
  };
1309
1030
  if (e.length < 3)
1310
- return M();
1311
- let T = r, I, q = !1;
1312
- const C = _t();
1313
- f[p] = [
1031
+ return x();
1032
+ let b = s, D, U = !1;
1033
+ const C = it();
1034
+ u[h] = [
1314
1035
  C,
1315
1036
  0
1316
1037
  ];
1317
- const ae = !y(s), G = E(), X = G.data, he = G._c, Q = y(he) ? X : he;
1318
- if (ae && (s = Z(s) ? s(Q, X) : s, d({
1319
- data: s,
1320
- _c: Q
1321
- })), Z(T))
1038
+ const ne = !v(r), J = p(), se = J.data, ye = J._c, Z = v(ye) ? se : ye;
1039
+ if (ne && (r = q(r) ? r(Z, se) : r, d({
1040
+ data: r,
1041
+ _c: Z
1042
+ })), q(b))
1322
1043
  try {
1323
- T = T(Q);
1324
- } catch (D) {
1325
- I = D, q = !0;
1044
+ b = b(Z);
1045
+ } catch (k) {
1046
+ D = k, U = !0;
1326
1047
  }
1327
- if (T && on(T))
1328
- if (T = yield T.catch((D) => {
1329
- I = D, q = !0;
1330
- }), C !== f[p][0]) {
1331
- if (q) throw I;
1332
- return T;
1333
- } else q && ae && i(I) && (a = !0, d({
1334
- data: Q,
1335
- _c: V
1048
+ if (b && Yt(b))
1049
+ if (b = yield b.catch((k) => {
1050
+ D = k, U = !0;
1051
+ }), C !== u[h][0]) {
1052
+ if (U) throw D;
1053
+ return b;
1054
+ } else U && ne && o(D) && (a = !0, d({
1055
+ data: Z,
1056
+ _c: M
1336
1057
  }));
1337
- if (a && !q)
1338
- if (Z(a)) {
1339
- const D = a(T, Q);
1058
+ if (a && !U)
1059
+ if (q(a)) {
1060
+ const k = a(b, Z);
1340
1061
  d({
1341
- data: D,
1342
- error: V,
1343
- _c: V
1062
+ data: k,
1063
+ error: M,
1064
+ _c: M
1344
1065
  });
1345
1066
  } else
1346
1067
  d({
1347
- data: T,
1348
- error: V,
1349
- _c: V
1068
+ data: b,
1069
+ error: M,
1070
+ _c: M
1350
1071
  });
1351
- if (f[p][1] = _t(), Promise.resolve(M()).then(() => {
1072
+ if (u[h][1] = it(), Promise.resolve(x()).then(() => {
1352
1073
  d({
1353
- _c: V
1074
+ _c: M
1354
1075
  });
1355
- }), q) {
1356
- if (h) throw I;
1076
+ }), U) {
1077
+ if (f) throw D;
1357
1078
  return;
1358
1079
  }
1359
- return T;
1080
+ return b;
1360
1081
  });
1361
1082
  }
1362
1083
  });
1363
1084
  }
1364
- const qt = (e, n) => {
1085
+ const kt = (e, n) => {
1365
1086
  for (const t in e)
1366
1087
  e[t][0] && e[t][0](n);
1367
- }, zn = (e, n) => {
1368
- if (!oe.has(e)) {
1369
- const t = de(qn, n), r = /* @__PURE__ */ Object.create(null), o = cn.bind(V, e);
1370
- let u = fe;
1371
- const a = /* @__PURE__ */ Object.create(null), l = (h, m) => {
1372
- const v = a[h] || [];
1373
- return a[h] = v, v.push(m), () => v.splice(v.indexOf(m), 1);
1374
- }, s = (h, m, v) => {
1375
- e.set(h, m);
1376
- const p = a[h];
1377
- if (p)
1378
- for (const E of p)
1379
- E(m, v);
1380
- }, i = () => {
1381
- if (!oe.has(e) && (oe.set(e, [
1382
- r,
1088
+ }, Pn = (e, n) => {
1089
+ if (!K.has(e)) {
1090
+ const t = Q(kn, n), s = /* @__PURE__ */ Object.create(null), i = Qt.bind(M, e);
1091
+ let c = X;
1092
+ const a = /* @__PURE__ */ Object.create(null), l = (f, E) => {
1093
+ const m = a[f] || [];
1094
+ return a[f] = m, m.push(E), () => m.splice(m.indexOf(E), 1);
1095
+ }, r = (f, E, m) => {
1096
+ e.set(f, E);
1097
+ const h = a[f];
1098
+ if (h)
1099
+ for (const p of h)
1100
+ p(E, m);
1101
+ }, o = () => {
1102
+ if (!K.has(e) && (K.set(e, [
1103
+ s,
1383
1104
  /* @__PURE__ */ Object.create(null),
1384
1105
  /* @__PURE__ */ Object.create(null),
1385
1106
  /* @__PURE__ */ Object.create(null),
1386
- o,
1387
- s,
1107
+ i,
1108
+ r,
1388
1109
  l
1389
- ]), !De)) {
1390
- const h = t.initFocus(setTimeout.bind(V, qt.bind(V, r, nn))), m = t.initReconnect(setTimeout.bind(V, qt.bind(V, r, rn)));
1391
- u = () => {
1392
- h && h(), m && m(), oe.delete(e);
1110
+ ]), !ve)) {
1111
+ const f = t.initFocus(setTimeout.bind(M, kt.bind(M, s, Ht))), E = t.initReconnect(setTimeout.bind(M, kt.bind(M, s, Kt)));
1112
+ c = () => {
1113
+ f && f(), E && E(), K.delete(e);
1393
1114
  };
1394
1115
  }
1395
1116
  };
1396
- return i(), [
1117
+ return o(), [
1397
1118
  e,
1398
- o,
1399
1119
  i,
1400
- u
1120
+ o,
1121
+ c
1401
1122
  ];
1402
1123
  }
1403
1124
  return [
1404
1125
  e,
1405
- oe.get(e)[4]
1126
+ K.get(e)[4]
1406
1127
  ];
1407
- }, Kn = (e, n, t, r, o) => {
1408
- const u = t.errorRetryCount, a = o.retryCount, l = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * t.errorRetryInterval;
1409
- !y(u) && a > u || setTimeout(r, l, o);
1410
- }, Xn = dt, [un, Zn] = zn(/* @__PURE__ */ new Map()), Qn = de(
1128
+ }, $n = (e, n, t, s, i) => {
1129
+ const c = t.errorRetryCount, a = i.retryCount, l = ~~((Math.random() + 0.5) * (1 << (a < 8 ? a : 8))) * t.errorRetryInterval;
1130
+ !v(c) && a > c || setTimeout(s, l, i);
1131
+ }, Un = et, [Zt, Jn] = Pn(/* @__PURE__ */ new Map()), qn = Q(
1411
1132
  {
1412
1133
  // events
1413
- onLoadingSlow: fe,
1414
- onSuccess: fe,
1415
- onError: fe,
1416
- onErrorRetry: Kn,
1417
- onDiscarded: fe,
1134
+ onLoadingSlow: X,
1135
+ onSuccess: X,
1136
+ onError: X,
1137
+ onErrorRetry: $n,
1138
+ onDiscarded: X,
1418
1139
  // switches
1419
1140
  revalidateOnFocus: !0,
1420
1141
  revalidateOnReconnect: !0,
1421
1142
  revalidateIfStale: !0,
1422
1143
  shouldRetryOnError: !0,
1423
1144
  // timeouts
1424
- errorRetryInterval: Jt ? 1e4 : 5e3,
1145
+ errorRetryInterval: Mt ? 1e4 : 5e3,
1425
1146
  focusThrottleInterval: 5 * 1e3,
1426
1147
  dedupingInterval: 2 * 1e3,
1427
- loadingTimeout: Jt ? 5e3 : 3e3,
1148
+ loadingTimeout: Mt ? 5e3 : 3e3,
1428
1149
  // providers
1429
- compare: Xn,
1150
+ compare: Un,
1430
1151
  isPaused: () => !1,
1431
- cache: un,
1432
- mutate: Zn,
1152
+ cache: Zt,
1153
+ mutate: Jn,
1433
1154
  fallback: {}
1434
1155
  },
1435
1156
  // use web preset by default
1436
- Jn
1437
- ), er = (e, n) => {
1438
- const t = de(e, n);
1157
+ Mn
1158
+ ), Gn = (e, n) => {
1159
+ const t = Q(e, n);
1439
1160
  if (n) {
1440
- const { use: r, fallback: o } = e, { use: u, fallback: a } = n;
1441
- r && u && (t.use = r.concat(u)), o && a && (t.fallback = de(o, a));
1161
+ const { use: s, fallback: i } = e, { use: c, fallback: a } = n;
1162
+ s && c && (t.use = s.concat(c)), i && a && (t.fallback = Q(i, a));
1442
1163
  }
1443
1164
  return t;
1444
- }, tr = Yt({}), nr = "$inf$", ln = je && window.__SWR_DEVTOOLS_USE__, rr = ln ? window.__SWR_DEVTOOLS_USE__ : [], sr = () => {
1445
- ln && (window.__SWR_DEVTOOLS_REACT__ = be);
1446
- }, or = (e) => Z(e[1]) ? [
1165
+ }, Bn = Wt({}), Hn = "$inf$", en = _e && window.__SWR_DEVTOOLS_USE__, Kn = en ? window.__SWR_DEVTOOLS_USE__ : [], zn = () => {
1166
+ en && (window.__SWR_DEVTOOLS_REACT__ = we);
1167
+ }, Yn = (e) => q(e[1]) ? [
1447
1168
  e[0],
1448
1169
  e[1],
1449
1170
  e[2] || {}
@@ -1451,33 +1172,33 @@ const qt = (e, n) => {
1451
1172
  e[0],
1452
1173
  null,
1453
1174
  (e[1] === null ? e[2] : e[1]) || {}
1454
- ], ar = () => {
1455
- const e = Ht(tr);
1456
- return zt(() => de(Qn, e), [
1175
+ ], Xn = () => {
1176
+ const e = Vt(Bn);
1177
+ return Pt(() => Q(qn, e), [
1457
1178
  e
1458
1179
  ]);
1459
- }, ir = (e) => (n, t, r) => e(n, t && ((...u) => {
1460
- const [a] = bt(n), [, , , l] = oe.get(un);
1461
- if (a.startsWith(nr))
1462
- return t(...u);
1463
- const s = l[a];
1464
- return y(s) ? t(...u) : (delete l[a], s);
1465
- }), r), cr = rr.concat(ir), ur = (e) => function(...t) {
1466
- const r = ar(), [o, u, a] = or(t), l = er(r, a);
1467
- let s = e;
1468
- const { use: i } = l, h = (i || []).concat(cr);
1469
- for (let m = h.length; m--; )
1470
- s = h[m](s);
1471
- return s(o, u || l.fetcher || null, l);
1472
- }, lr = (e, n, t) => {
1473
- const r = n[e] || (n[e] = []);
1474
- return r.push(t), () => {
1475
- const o = r.indexOf(t);
1476
- o >= 0 && (r[o] = r[r.length - 1], r.pop());
1180
+ }, Qn = (e) => (n, t, s) => e(n, t && ((...c) => {
1181
+ const [a] = dt(n), [, , , l] = K.get(Zt);
1182
+ if (a.startsWith(Hn))
1183
+ return t(...c);
1184
+ const r = l[a];
1185
+ return v(r) ? t(...c) : (delete l[a], r);
1186
+ }), s), Zn = Kn.concat(Qn), es = (e) => function(...t) {
1187
+ const s = Xn(), [i, c, a] = Yn(t), l = Gn(s, a);
1188
+ let r = e;
1189
+ const { use: o } = l, f = (o || []).concat(Zn);
1190
+ for (let E = f.length; E--; )
1191
+ r = f[E](r);
1192
+ return r(i, c || l.fetcher || null, l);
1193
+ }, ts = (e, n, t) => {
1194
+ const s = n[e] || (n[e] = []);
1195
+ return s.push(t), () => {
1196
+ const i = s.indexOf(t);
1197
+ i >= 0 && (s[i] = s[s.length - 1], s.pop());
1477
1198
  };
1478
1199
  };
1479
- sr();
1480
- const tt = be.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
1200
+ zn();
1201
+ const Je = we.use || // This extra generic is to avoid TypeScript mixing up the generic and JSX sytax
1481
1202
  // and emitting an error.
1482
1203
  // We assume that this is only for the `use(thenable)` case, not `use(context)`.
1483
1204
  // https://github.com/facebook/react/blob/aed00dacfb79d17c53218404c52b1c7aa59c4a89/packages/react-server/src/ReactFizzThenable.js#L45
@@ -1496,94 +1217,94 @@ const tt = be.use || // This extra generic is to avoid TypeScript mixing up the
1496
1217
  e.status = "rejected", e.reason = n;
1497
1218
  }), e;
1498
1219
  }
1499
- }), nt = {
1220
+ }), qe = {
1500
1221
  dedupe: !0
1501
- }, Gt = Promise.resolve(V), fr = (e, n, t) => {
1502
- const { cache: r, compare: o, suspense: u, fallbackData: a, revalidateOnMount: l, revalidateIfStale: s, refreshInterval: i, refreshWhenHidden: h, refreshWhenOffline: m, keepPreviousData: v } = t, [p, E, d, g] = oe.get(r), [f, w] = bt(e), O = ue(!1), M = ue(!1), T = ue(f), I = ue(n), q = ue(t), C = () => q.current, ae = () => C().isVisible() && C().isOnline(), [G, X, he, Q] = an(r, f), D = ue({}).current, ie = y(a) ? y(t.fallback) ? V : t.fallback[f] : a, Re = (R, N) => {
1503
- for (const W in D) {
1504
- const A = W;
1505
- if (A === "data") {
1506
- if (!o(R[A], N[A]) && (!y(R[A]) || !o($, N[A])))
1222
+ }, jt = Promise.resolve(M), ns = (e, n, t) => {
1223
+ const { cache: s, compare: i, suspense: c, fallbackData: a, revalidateOnMount: l, revalidateIfStale: r, refreshInterval: o, refreshWhenHidden: f, refreshWhenOffline: E, keepPreviousData: m } = t, [h, p, d, g] = K.get(s), [u, w] = dt(e), O = z(!1), x = z(!1), b = z(u), D = z(n), U = z(t), C = () => U.current, ne = () => C().isVisible() && C().isOnline(), [J, se, ye, Z] = Xt(s, u), k = z({}).current, fe = v(a) ? v(t.fallback) ? M : t.fallback[u] : a, ft = (_, T) => {
1224
+ for (const N in k) {
1225
+ const y = N;
1226
+ if (y === "data") {
1227
+ if (!i(_[y], T[y]) && (!v(_[y]) || !i(be, T[y])))
1507
1228
  return !1;
1508
- } else if (N[A] !== R[A])
1229
+ } else if (T[y] !== _[y])
1509
1230
  return !1;
1510
1231
  }
1511
1232
  return !0;
1512
- }, Oe = zt(() => {
1513
- const R = !f || !n ? !1 : y(l) ? C().isPaused() || u ? !1 : s !== !1 : l, N = (U) => {
1514
- const ne = de(U);
1515
- return delete ne._k, R ? k({
1233
+ }, ht = Pt(() => {
1234
+ const _ = !u || !n ? !1 : v(l) ? C().isPaused() || c ? !1 : r !== !1 : l, T = (j) => {
1235
+ const G = Q(j);
1236
+ return delete G._k, _ ? L({
1516
1237
  isValidating: !0,
1517
1238
  isLoading: !0
1518
- }, ne) : ne;
1519
- }, W = G(), A = Q(), z = N(W), ge = W === A ? z : N(A);
1520
- let F = z;
1239
+ }, G) : G;
1240
+ }, N = J(), y = Z(), P = T(N), ae = N === y ? P : T(y);
1241
+ let A = P;
1521
1242
  return [
1522
1243
  () => {
1523
- const U = N(G());
1524
- return Re(U, F) ? (F.data = U.data, F.isLoading = U.isLoading, F.isValidating = U.isValidating, F.error = U.error, F) : (F = U, U);
1244
+ const j = T(J());
1245
+ return ft(j, A) ? (A.data = j.data, A.isLoading = j.isLoading, A.isValidating = j.isValidating, A.error = j.error, A) : (A = j, j);
1525
1246
  },
1526
- () => ge
1247
+ () => ae
1527
1248
  ];
1528
1249
  }, [
1529
- r,
1530
- f
1531
- ]), ee = Mn.useSyncExternalStore($e(
1532
- (R) => he(f, (N, W) => {
1533
- Re(W, N) || R();
1250
+ s,
1251
+ u
1252
+ ]), re = Cn.useSyncExternalStore(Le(
1253
+ (_) => ye(u, (T, N) => {
1254
+ ft(N, T) || _();
1534
1255
  }),
1535
1256
  // eslint-disable-next-line react-hooks/exhaustive-deps
1536
1257
  [
1537
- r,
1538
- f
1258
+ s,
1259
+ u
1539
1260
  ]
1540
- ), Oe[0], Oe[1]), Te = !O.current, c = p[f] && p[f].length > 0, _ = ee.data, b = y(_) ? ie && on(ie) ? tt(ie) : ie : _, x = ee.error, Y = ue(b), $ = v ? y(_) ? y(Y.current) ? b : Y.current : _ : b, Ee = c && !y(x) ? !1 : Te && !y(l) ? l : C().isPaused() ? !1 : u ? y(b) ? !1 : s : y(b) || s, me = !!(f && n && Te && Ee), P = y(ee.isValidating) ? me : ee.isValidating, ce = y(ee.isLoading) ? me : ee.isLoading, te = $e(
1541
- (R) => H(null, null, function* () {
1542
- const N = I.current;
1543
- if (!f || !N || M.current || C().isPaused())
1261
+ ), ht[0], ht[1]), pt = !O.current, tn = h[u] && h[u].length > 0, oe = re.data, ee = v(oe) ? fe && Yt(fe) ? Je(fe) : fe : oe, Oe = re.error, Ne = z(ee), be = m ? v(oe) ? v(Ne.current) ? ee : Ne.current : oe : ee, gt = tn && !v(Oe) ? !1 : pt && !v(l) ? l : C().isPaused() ? !1 : c ? v(ee) ? !1 : r : v(ee) || r, Et = !!(u && n && pt && gt), nn = v(re.isValidating) ? Et : re.isValidating, sn = v(re.isLoading) ? Et : re.isLoading, he = Le(
1262
+ (_) => V(null, null, function* () {
1263
+ const T = D.current;
1264
+ if (!u || !T || x.current || C().isPaused())
1544
1265
  return !1;
1545
- let W, A, z = !0;
1546
- const ge = R || {}, F = !d[f] || !ge.dedupe, U = () => Ut ? !M.current && f === T.current && O.current : f === T.current, ne = {
1266
+ let N, y, P = !0;
1267
+ const ae = _ || {}, A = !d[u] || !ae.dedupe, j = () => xt ? !x.current && u === b.current && O.current : u === b.current, G = {
1547
1268
  isValidating: !1,
1548
1269
  isLoading: !1
1549
- }, Rt = () => {
1550
- X(ne);
1551
- }, Ot = () => {
1552
- const B = d[f];
1553
- B && B[1] === A && delete d[f];
1554
- }, Tt = {
1270
+ }, St = () => {
1271
+ se(G);
1272
+ }, vt = () => {
1273
+ const F = d[u];
1274
+ F && F[1] === y && delete d[u];
1275
+ }, wt = {
1555
1276
  isValidating: !0
1556
1277
  };
1557
- y(G().data) && (Tt.isLoading = !0);
1278
+ v(J().data) && (wt.isLoading = !0);
1558
1279
  try {
1559
- if (F && (X(Tt), t.loadingTimeout && y(G().data) && setTimeout(() => {
1560
- z && U() && C().onLoadingSlow(f, t);
1561
- }, t.loadingTimeout), d[f] = [
1562
- N(w),
1563
- _t()
1564
- ]), [W, A] = d[f], W = yield W, F && setTimeout(Ot, t.dedupingInterval), !d[f] || d[f][1] !== A)
1565
- return F && U() && C().onDiscarded(f), !1;
1566
- ne.error = V;
1567
- const B = E[f];
1568
- if (!y(B) && // case 1
1569
- (A <= B[0] || // case 2
1570
- A <= B[1] || // case 3
1571
- B[1] === 0))
1572
- return Rt(), F && U() && C().onDiscarded(f), !1;
1573
- const re = G().data;
1574
- ne.data = o(re, W) ? re : W, F && U() && C().onSuccess(W, f, t);
1575
- } catch (B) {
1576
- Ot();
1577
- const re = C(), { shouldRetryOnError: qe } = re;
1578
- re.isPaused() || (ne.error = B, F && U() && (re.onError(B, f, re), (qe === !0 || Z(qe) && qe(B)) && (!C().revalidateOnFocus || !C().revalidateOnReconnect || ae()) && re.onErrorRetry(B, f, re, (fn) => {
1579
- const Ge = p[f];
1580
- Ge && Ge[0] && Ge[0](Vt, fn);
1280
+ if (A && (se(wt), t.loadingTimeout && v(J().data) && setTimeout(() => {
1281
+ P && j() && C().onLoadingSlow(u, t);
1282
+ }, t.loadingTimeout), d[u] = [
1283
+ T(w),
1284
+ it()
1285
+ ]), [N, y] = d[u], N = yield N, A && setTimeout(vt, t.dedupingInterval), !d[u] || d[u][1] !== y)
1286
+ return A && j() && C().onDiscarded(u), !1;
1287
+ G.error = M;
1288
+ const F = p[u];
1289
+ if (!v(F) && // case 1
1290
+ (y <= F[0] || // case 2
1291
+ y <= F[1] || // case 3
1292
+ F[1] === 0))
1293
+ return St(), A && j() && C().onDiscarded(u), !1;
1294
+ const B = J().data;
1295
+ G.data = i(B, N) ? B : N, A && j() && C().onSuccess(N, u, t);
1296
+ } catch (F) {
1297
+ vt();
1298
+ const B = C(), { shouldRetryOnError: Ae } = B;
1299
+ B.isPaused() || (G.error = F, A && j() && (B.onError(F, u, B), (Ae === !0 || q(Ae) && Ae(F)) && (!C().revalidateOnFocus || !C().revalidateOnReconnect || ne()) && B.onErrorRetry(F, u, B, (rn) => {
1300
+ const xe = h[u];
1301
+ xe && xe[0] && xe[0](Nt, rn);
1581
1302
  }, {
1582
- retryCount: (ge.retryCount || 0) + 1,
1303
+ retryCount: (ae.retryCount || 0) + 1,
1583
1304
  dedupe: !0
1584
1305
  })));
1585
1306
  }
1586
- return z = !1, Rt(), !0;
1307
+ return P = !1, St(), !0;
1587
1308
  }),
1588
1309
  // `setState` is immutable, and `eventsCallback`, `fnArg`, and
1589
1310
  // `keyValidating` are depending on `key`, so we can exclude them from
@@ -1597,96 +1318,96 @@ const tt = be.use || // This extra generic is to avoid TypeScript mixing up the
1597
1318
  // even though it might cause unexpected behaviors.
1598
1319
  // eslint-disable-next-line react-hooks/exhaustive-deps
1599
1320
  [
1600
- f,
1601
- r
1321
+ u,
1322
+ s
1602
1323
  ]
1603
- ), Me = $e(
1324
+ ), mt = Le(
1604
1325
  // Use callback to make sure `keyRef.current` returns latest result every time
1605
- (...R) => cn(r, T.current, ...R),
1326
+ (..._) => Qt(s, b.current, ..._),
1606
1327
  // eslint-disable-next-line react-hooks/exhaustive-deps
1607
1328
  []
1608
1329
  );
1609
- if (Ze(() => {
1610
- I.current = n, q.current = t, y(_) || (Y.current = _);
1611
- }), Ze(() => {
1612
- if (!f) return;
1613
- const R = te.bind(V, nt);
1614
- let N = 0;
1615
- C().revalidateOnFocus && (N = Date.now() + C().focusThrottleInterval);
1616
- const A = lr(f, p, (z, ge = {}) => {
1617
- if (z == nn) {
1618
- const F = Date.now();
1619
- C().revalidateOnFocus && F > N && ae() && (N = F + C().focusThrottleInterval, R());
1620
- } else if (z == rn)
1621
- C().revalidateOnReconnect && ae() && R();
1330
+ if (Pe(() => {
1331
+ D.current = n, U.current = t, v(oe) || (Ne.current = oe);
1332
+ }), Pe(() => {
1333
+ if (!u) return;
1334
+ const _ = he.bind(M, qe);
1335
+ let T = 0;
1336
+ C().revalidateOnFocus && (T = Date.now() + C().focusThrottleInterval);
1337
+ const y = ts(u, h, (P, ae = {}) => {
1338
+ if (P == Ht) {
1339
+ const A = Date.now();
1340
+ C().revalidateOnFocus && A > T && ne() && (T = A + C().focusThrottleInterval, _());
1341
+ } else if (P == Kt)
1342
+ C().revalidateOnReconnect && ne() && _();
1622
1343
  else {
1623
- if (z == sn)
1624
- return te();
1625
- if (z == Vt)
1626
- return te(ge);
1344
+ if (P == zt)
1345
+ return he();
1346
+ if (P == Nt)
1347
+ return he(ae);
1627
1348
  }
1628
1349
  });
1629
- return M.current = !1, T.current = f, O.current = !0, X({
1350
+ return x.current = !1, b.current = u, O.current = !0, se({
1630
1351
  _k: w
1631
- }), Ee && (d[f] || (y(b) || De ? R() : Gn(R))), () => {
1632
- M.current = !0, A();
1352
+ }), gt && (d[u] || (v(ee) || ve ? _() : jn(_))), () => {
1353
+ x.current = !0, y();
1633
1354
  };
1634
1355
  }, [
1635
- f
1636
- ]), Ze(() => {
1637
- let R;
1638
- function N() {
1639
- const A = Z(i) ? i(G().data) : i;
1640
- A && R !== -1 && (R = setTimeout(W, A));
1356
+ u
1357
+ ]), Pe(() => {
1358
+ let _;
1359
+ function T() {
1360
+ const y = q(o) ? o(J().data) : o;
1361
+ y && _ !== -1 && (_ = setTimeout(N, y));
1641
1362
  }
1642
- function W() {
1643
- !G().error && (h || C().isVisible()) && (m || C().isOnline()) ? te(nt).then(N) : N();
1363
+ function N() {
1364
+ !J().error && (f || C().isVisible()) && (E || C().isOnline()) ? he(qe).then(T) : T();
1644
1365
  }
1645
- return N(), () => {
1646
- R && (clearTimeout(R), R = -1);
1366
+ return T(), () => {
1367
+ _ && (clearTimeout(_), _ = -1);
1647
1368
  };
1648
1369
  }, [
1649
- i,
1650
- h,
1651
- m,
1652
- f
1653
- ]), vn($), u) {
1654
- const R = f && y(b);
1655
- if (!Ut && De && R)
1370
+ o,
1371
+ f,
1372
+ E,
1373
+ u
1374
+ ]), hn(be), c) {
1375
+ const _ = u && v(ee);
1376
+ if (!xt && ve && _)
1656
1377
  throw new Error("Fallback data is required when using Suspense in SSR.");
1657
- R && (I.current = n, q.current = t, M.current = !1);
1658
- const N = g[f], W = !y(N) && R ? Me(N) : Gt;
1659
- if (tt(W), !y(x) && R)
1660
- throw x;
1661
- const A = R ? te(nt) : Gt;
1662
- !y($) && R && (A.status = "fulfilled", A.value = !0), tt(A);
1378
+ _ && (D.current = n, U.current = t, x.current = !1);
1379
+ const T = g[u], N = !v(T) && _ ? mt(T) : jt;
1380
+ if (Je(N), !v(Oe) && _)
1381
+ throw Oe;
1382
+ const y = _ ? he(qe) : jt;
1383
+ !v(be) && _ && (y.status = "fulfilled", y.value = !0), Je(y);
1663
1384
  }
1664
1385
  return {
1665
- mutate: Me,
1386
+ mutate: mt,
1666
1387
  get data() {
1667
- return D.data = !0, $;
1388
+ return k.data = !0, be;
1668
1389
  },
1669
1390
  get error() {
1670
- return D.error = !0, x;
1391
+ return k.error = !0, Oe;
1671
1392
  },
1672
1393
  get isValidating() {
1673
- return D.isValidating = !0, P;
1394
+ return k.isValidating = !0, nn;
1674
1395
  },
1675
1396
  get isLoading() {
1676
- return D.isLoading = !0, ce;
1397
+ return k.isLoading = !0, sn;
1677
1398
  }
1678
1399
  };
1679
- }, dr = ur(fr), _r = ({
1400
+ }, ss = es(ns), ds = ({
1680
1401
  fileKey: e,
1681
1402
  authToken: n,
1682
1403
  enabled: t = !0,
1683
- params: r = {}
1404
+ params: s = {}
1684
1405
  }) => {
1685
- const { figmaRestApi: o } = kn(), u = !!(t && e && n), { data: a, isLoading: l, error: s } = dr(
1686
- ["useFigmaFile", e, n, r],
1687
- () => u ? o.withOptions(n ? { token: n } : {}).getFile({
1406
+ const { figmaRestApi: i } = On(), c = !!(t && e && n), { data: a, isLoading: l, error: r } = ss(
1407
+ ["useFigmaFile", e, n, s],
1408
+ () => c ? i.withOptions(n ? { token: n } : {}).getFile({
1688
1409
  fileKey: e,
1689
- depth: r.depth
1410
+ depth: s.depth
1690
1411
  }) : null,
1691
1412
  {
1692
1413
  revalidateIfStale: !1,
@@ -1697,17 +1418,17 @@ const tt = be.use || // This extra generic is to avoid TypeScript mixing up the
1697
1418
  return {
1698
1419
  data: a != null ? a : null,
1699
1420
  isLoading: l,
1700
- error: s
1421
+ error: r
1701
1422
  };
1702
1423
  };
1703
1424
  export {
1704
- tn as AnimaSdkContext,
1705
- gr as AnimaSdkProvider,
1706
- Nn as AttachJobError,
1707
- Ln as CreateJobError,
1708
- xn as UnknownCodegenError,
1709
- vr as useAnimaCodegen,
1710
- kn as useAnimaSDK,
1711
- _r as useFigmaFile
1425
+ Bt as AnimaSdkContext,
1426
+ us as AnimaSdkProvider,
1427
+ _n as AttachJobError,
1428
+ wn as CreateJobError,
1429
+ yn as UnknownCodegenError,
1430
+ ls as useAnimaCodegen,
1431
+ On as useAnimaSDK,
1432
+ ds as useFigmaFile
1712
1433
  };
1713
1434
  //# sourceMappingURL=index.js.map