@motiadev/plugin-bullmq 0.14.0-beta.165-285707 → 0.14.0-beta.165-602289

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 (42) hide show
  1. package/dist/index.css +1159 -0
  2. package/dist/index.css.map +1 -0
  3. package/dist/index.d.ts +62 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +0 -4533
  6. package/dist/index.js.map +1 -0
  7. package/dist/plugin.d.ts +6 -2
  8. package/dist/plugin.d.ts.map +1 -1
  9. package/dist/plugin.js +630 -384
  10. package/dist/plugin.js.map +1 -0
  11. package/package.json +17 -24
  12. package/dist/api.d.ts +0 -4
  13. package/dist/api.d.ts.map +0 -1
  14. package/dist/components/dlq-panel.d.ts +0 -2
  15. package/dist/components/dlq-panel.d.ts.map +0 -1
  16. package/dist/components/job-detail.d.ts +0 -2
  17. package/dist/components/job-detail.d.ts.map +0 -1
  18. package/dist/components/jobs-table.d.ts +0 -2
  19. package/dist/components/jobs-table.d.ts.map +0 -1
  20. package/dist/components/queue-detail.d.ts +0 -2
  21. package/dist/components/queue-detail.d.ts.map +0 -1
  22. package/dist/components/queue-list.d.ts +0 -2
  23. package/dist/components/queue-list.d.ts.map +0 -1
  24. package/dist/components/queues-page.d.ts +0 -2
  25. package/dist/components/queues-page.d.ts.map +0 -1
  26. package/dist/hooks/use-jobs-mutations.d.ts +0 -23
  27. package/dist/hooks/use-jobs-mutations.d.ts.map +0 -1
  28. package/dist/hooks/use-jobs-query.d.ts +0 -5
  29. package/dist/hooks/use-jobs-query.d.ts.map +0 -1
  30. package/dist/hooks/use-queues.d.ts +0 -11
  31. package/dist/hooks/use-queues.d.ts.map +0 -1
  32. package/dist/index.cjs +0 -98
  33. package/dist/plugin-bullmq.css +0 -1
  34. package/dist/plugin.cjs +0 -1
  35. package/dist/providers/query-provider.d.ts +0 -7
  36. package/dist/providers/query-provider.d.ts.map +0 -1
  37. package/dist/stores/use-bullmq-store.d.ts +0 -22
  38. package/dist/stores/use-bullmq-store.d.ts.map +0 -1
  39. package/dist/streams/queues-stream.d.ts +0 -33
  40. package/dist/streams/queues-stream.d.ts.map +0 -1
  41. package/dist/types/queue.d.ts +0 -54
  42. package/dist/types/queue.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,4533 +0,0 @@
1
- import * as C from "react";
2
- import ge, { useEffect as ke, useCallback as k, forwardRef as us, createElement as Ke, useState as Z, createContext as nn, useContext as pe, isValidElement as rn, useRef as ht, useMemo as Te, memo as z } from "react";
3
- import { useStreamGroup as an } from "@motiadev/stream-client-react";
4
- import { Button as X, TooltipProvider as ds, Tooltip as re, TooltipTrigger as ae, TooltipContent as ie, Table as hs, TableHeader as fs, TableRow as Fe, TableHead as ee, TableBody as ms, TableCell as te, Sidebar as ps, cn as ue, DropdownMenu as ys, DropdownMenuTrigger as gs, DropdownMenuContent as vs, DropdownMenuItem as ve, DropdownMenuSeparator as on, Tabs as ln, TabsList as cn, TabsTrigger as un, Input as dn } from "@motiadev/ui";
5
- var De = { exports: {} }, Ce = {};
6
- /**
7
- * @license React
8
- * react-jsx-runtime.production.js
9
- *
10
- * Copyright (c) Meta Platforms, Inc. and affiliates.
11
- *
12
- * This source code is licensed under the MIT license found in the
13
- * LICENSE file in the root directory of this source tree.
14
- */
15
- var St;
16
- function hn() {
17
- if (St) return Ce;
18
- St = 1;
19
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
20
- function s(r, a, o) {
21
- var l = null;
22
- if (o !== void 0 && (l = "" + o), a.key !== void 0 && (l = "" + a.key), "key" in a) {
23
- o = {};
24
- for (var i in a)
25
- i !== "key" && (o[i] = a[i]);
26
- } else o = a;
27
- return a = o.ref, {
28
- $$typeof: e,
29
- type: r,
30
- key: l,
31
- ref: a !== void 0 ? a : null,
32
- props: o
33
- };
34
- }
35
- return Ce.Fragment = t, Ce.jsx = s, Ce.jsxs = s, Ce;
36
- }
37
- var Se = {};
38
- /**
39
- * @license React
40
- * react-jsx-runtime.development.js
41
- *
42
- * Copyright (c) Meta Platforms, Inc. and affiliates.
43
- *
44
- * This source code is licensed under the MIT license found in the
45
- * LICENSE file in the root directory of this source tree.
46
- */
47
- var Nt;
48
- function fn() {
49
- return Nt || (Nt = 1, process.env.NODE_ENV !== "production" && function() {
50
- function e(u) {
51
- if (u == null) return null;
52
- if (typeof u == "function")
53
- return u.$$typeof === I ? null : u.displayName || u.name || null;
54
- if (typeof u == "string") return u;
55
- switch (u) {
56
- case g:
57
- return "Fragment";
58
- case b:
59
- return "Profiler";
60
- case N:
61
- return "StrictMode";
62
- case w:
63
- return "Suspense";
64
- case R:
65
- return "SuspenseList";
66
- case F:
67
- return "Activity";
68
- }
69
- if (typeof u == "object")
70
- switch (typeof u.tag == "number" && console.error(
71
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
72
- ), u.$$typeof) {
73
- case m:
74
- return "Portal";
75
- case T:
76
- return (u.displayName || "Context") + ".Provider";
77
- case P:
78
- return (u._context.displayName || "Context") + ".Consumer";
79
- case j:
80
- var x = u.render;
81
- return u = u.displayName, u || (u = x.displayName || x.name || "", u = u !== "" ? "ForwardRef(" + u + ")" : "ForwardRef"), u;
82
- case S:
83
- return x = u.displayName || null, x !== null ? x : e(u.type) || "Memo";
84
- case M:
85
- x = u._payload, u = u._init;
86
- try {
87
- return e(u(x));
88
- } catch {
89
- }
90
- }
91
- return null;
92
- }
93
- function t(u) {
94
- return "" + u;
95
- }
96
- function s(u) {
97
- try {
98
- t(u);
99
- var x = !1;
100
- } catch {
101
- x = !0;
102
- }
103
- if (x) {
104
- x = console;
105
- var O = x.error, v = typeof Symbol == "function" && Symbol.toStringTag && u[Symbol.toStringTag] || u.constructor.name || "Object";
106
- return O.call(
107
- x,
108
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
109
- v
110
- ), t(u);
111
- }
112
- }
113
- function r(u) {
114
- if (u === g) return "<>";
115
- if (typeof u == "object" && u !== null && u.$$typeof === M)
116
- return "<...>";
117
- try {
118
- var x = e(u);
119
- return x ? "<" + x + ">" : "<...>";
120
- } catch {
121
- return "<...>";
122
- }
123
- }
124
- function a() {
125
- var u = _.A;
126
- return u === null ? null : u.getOwner();
127
- }
128
- function o() {
129
- return Error("react-stack-top-frame");
130
- }
131
- function l(u) {
132
- if (L.call(u, "key")) {
133
- var x = Object.getOwnPropertyDescriptor(u, "key").get;
134
- if (x && x.isReactWarning) return !1;
135
- }
136
- return u.key !== void 0;
137
- }
138
- function i(u, x) {
139
- function O() {
140
- Q || (Q = !0, console.error(
141
- "%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)",
142
- x
143
- ));
144
- }
145
- O.isReactWarning = !0, Object.defineProperty(u, "key", {
146
- get: O,
147
- configurable: !0
148
- });
149
- }
150
- function c() {
151
- var u = e(this.type);
152
- return $[u] || ($[u] = !0, console.error(
153
- "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."
154
- )), u = this.props.ref, u !== void 0 ? u : null;
155
- }
156
- function h(u, x, O, v, E, Y, $e, He) {
157
- return O = Y.ref, u = {
158
- $$typeof: p,
159
- type: u,
160
- key: x,
161
- props: Y,
162
- _owner: E
163
- }, (O !== void 0 ? O : null) !== null ? Object.defineProperty(u, "ref", {
164
- enumerable: !1,
165
- get: c
166
- }) : Object.defineProperty(u, "ref", { enumerable: !1, value: null }), u._store = {}, Object.defineProperty(u._store, "validated", {
167
- configurable: !1,
168
- enumerable: !1,
169
- writable: !0,
170
- value: 0
171
- }), Object.defineProperty(u, "_debugInfo", {
172
- configurable: !1,
173
- enumerable: !1,
174
- writable: !0,
175
- value: null
176
- }), Object.defineProperty(u, "_debugStack", {
177
- configurable: !1,
178
- enumerable: !1,
179
- writable: !0,
180
- value: $e
181
- }), Object.defineProperty(u, "_debugTask", {
182
- configurable: !1,
183
- enumerable: !1,
184
- writable: !0,
185
- value: He
186
- }), Object.freeze && (Object.freeze(u.props), Object.freeze(u)), u;
187
- }
188
- function d(u, x, O, v, E, Y, $e, He) {
189
- var J = x.children;
190
- if (J !== void 0)
191
- if (v)
192
- if (K(J)) {
193
- for (v = 0; v < J.length; v++)
194
- y(J[v]);
195
- Object.freeze && Object.freeze(J);
196
- } else
197
- console.error(
198
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
199
- );
200
- else y(J);
201
- if (L.call(x, "key")) {
202
- J = e(u);
203
- var ye = Object.keys(x).filter(function(sn) {
204
- return sn !== "key";
205
- });
206
- v = 0 < ye.length ? "{key: someKey, " + ye.join(": ..., ") + ": ...}" : "{key: someKey}", H[J + v] || (ye = 0 < ye.length ? "{" + ye.join(": ..., ") + ": ...}" : "{}", console.error(
207
- `A props object containing a "key" prop is being spread into JSX:
208
- let props = %s;
209
- <%s {...props} />
210
- React keys must be passed directly to JSX without using spread:
211
- let props = %s;
212
- <%s key={someKey} {...props} />`,
213
- v,
214
- J,
215
- ye,
216
- J
217
- ), H[J + v] = !0);
218
- }
219
- if (J = null, O !== void 0 && (s(O), J = "" + O), l(x) && (s(x.key), J = "" + x.key), "key" in x) {
220
- O = {};
221
- for (var We in x)
222
- We !== "key" && (O[We] = x[We]);
223
- } else O = x;
224
- return J && i(
225
- O,
226
- typeof u == "function" ? u.displayName || u.name || "Unknown" : u
227
- ), h(
228
- u,
229
- J,
230
- Y,
231
- E,
232
- a(),
233
- O,
234
- $e,
235
- He
236
- );
237
- }
238
- function y(u) {
239
- typeof u == "object" && u !== null && u.$$typeof === p && u._store && (u._store.validated = 1);
240
- }
241
- var f = ge, p = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), N = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), P = Symbol.for("react.consumer"), T = Symbol.for("react.context"), j = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), R = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), M = Symbol.for("react.lazy"), F = Symbol.for("react.activity"), I = Symbol.for("react.client.reference"), _ = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, K = Array.isArray, V = console.createTask ? console.createTask : function() {
242
- return null;
243
- };
244
- f = {
245
- react_stack_bottom_frame: function(u) {
246
- return u();
247
- }
248
- };
249
- var Q, $ = {}, A = f.react_stack_bottom_frame.bind(
250
- f,
251
- o
252
- )(), B = V(r(o)), H = {};
253
- Se.Fragment = g, Se.jsx = function(u, x, O, v, E) {
254
- var Y = 1e4 > _.recentlyCreatedOwnerStacks++;
255
- return d(
256
- u,
257
- x,
258
- O,
259
- !1,
260
- v,
261
- E,
262
- Y ? Error("react-stack-top-frame") : A,
263
- Y ? V(r(u)) : B
264
- );
265
- }, Se.jsxs = function(u, x, O, v, E) {
266
- var Y = 1e4 > _.recentlyCreatedOwnerStacks++;
267
- return d(
268
- u,
269
- x,
270
- O,
271
- !0,
272
- v,
273
- E,
274
- Y ? Error("react-stack-top-frame") : A,
275
- Y ? V(r(u)) : B
276
- );
277
- };
278
- }()), Se;
279
- }
280
- var Et;
281
- function mn() {
282
- return Et || (Et = 1, process.env.NODE_ENV === "production" ? De.exports = hn() : De.exports = fn()), De.exports;
283
- }
284
- var n = mn();
285
- const Ot = (e) => {
286
- let t;
287
- const s = /* @__PURE__ */ new Set(), r = (h, d) => {
288
- const y = typeof h == "function" ? h(t) : h;
289
- if (!Object.is(y, t)) {
290
- const f = t;
291
- t = d ?? (typeof y != "object" || y === null) ? y : Object.assign({}, t, y), s.forEach((p) => p(t, f));
292
- }
293
- }, a = () => t, i = { setState: r, getState: a, getInitialState: () => c, subscribe: (h) => (s.add(h), () => s.delete(h)) }, c = t = e(r, a, i);
294
- return i;
295
- }, pn = (e) => e ? Ot(e) : Ot, yn = (e) => e;
296
- function gn(e, t = yn) {
297
- const s = ge.useSyncExternalStore(
298
- e.subscribe,
299
- ge.useCallback(() => t(e.getState()), [e, t]),
300
- ge.useCallback(() => t(e.getInitialState()), [e, t])
301
- );
302
- return ge.useDebugValue(s), s;
303
- }
304
- const Rt = (e) => {
305
- const t = pn(e), s = (r) => gn(t, r);
306
- return Object.assign(s, t), s;
307
- }, vn = (e) => e ? Rt(e) : Rt, kt = {
308
- queues: [],
309
- selectedQueue: null,
310
- selectedJob: null,
311
- selectedStatus: "waiting",
312
- error: null,
313
- searchQuery: "",
314
- jobDetailOpen: !1
315
- }, D = vn((e) => ({
316
- ...kt,
317
- setQueues: (t) => e({ queues: t }),
318
- setSelectedQueue: (t) => e({ selectedQueue: t, selectedJob: null }),
319
- updateSelectedQueueStats: (t) => e({ selectedQueue: t }),
320
- setSelectedJob: (t) => e({ selectedJob: t }),
321
- setSelectedStatus: (t) => e({ selectedStatus: t }),
322
- setError: (t) => e({ error: t }),
323
- setSearchQuery: (t) => e({ searchQuery: t }),
324
- setJobDetailOpen: (t) => e({ jobDetailOpen: t }),
325
- reset: () => e(kt)
326
- })), bn = "__motia.bullmq-queues", bs = () => {
327
- const { queues: e, setQueues: t, setError: s, error: r, selectedQueue: a, setSelectedQueue: o } = D(), { data: l } = an({
328
- streamName: bn,
329
- groupId: "default"
330
- });
331
- ke(() => {
332
- if (l.length > 0 && (t(l), a)) {
333
- const f = l.find((p) => p.name === a.name);
334
- if (f) {
335
- const p = JSON.stringify(a.stats), m = JSON.stringify(f.stats), g = a.isPaused !== f.isPaused;
336
- (p !== m || g) && o(f);
337
- }
338
- }
339
- }, [l, t, a, o]);
340
- const i = k(async (f) => {
341
- try {
342
- const p = await fetch(`/__motia/bullmq/queues/${encodeURIComponent(f)}`);
343
- if (!p.ok)
344
- throw new Error("Failed to fetch queue");
345
- return await p.json();
346
- } catch {
347
- return null;
348
- }
349
- }, []), c = k(
350
- async (f) => {
351
- try {
352
- await fetch(`/__motia/bullmq/queues/${encodeURIComponent(f)}/pause`, { method: "POST" });
353
- } catch (p) {
354
- s(p instanceof Error ? p.message : "Failed to pause queue");
355
- }
356
- },
357
- [s]
358
- ), h = k(
359
- async (f) => {
360
- try {
361
- await fetch(`/__motia/bullmq/queues/${encodeURIComponent(f)}/resume`, { method: "POST" });
362
- } catch (p) {
363
- s(p instanceof Error ? p.message : "Failed to resume queue");
364
- }
365
- },
366
- [s]
367
- ), d = k(
368
- async (f, p, m = 0, g = 1e3) => {
369
- try {
370
- await fetch(`/__motia/bullmq/queues/${encodeURIComponent(f)}/clean`, {
371
- method: "POST",
372
- headers: { "Content-Type": "application/json" },
373
- body: JSON.stringify({ status: p, grace: m, limit: g })
374
- });
375
- } catch (N) {
376
- s(N instanceof Error ? N.message : "Failed to clean queue");
377
- }
378
- },
379
- [s]
380
- ), y = k(
381
- async (f) => {
382
- try {
383
- await fetch(`/__motia/bullmq/queues/${encodeURIComponent(f)}/drain`, { method: "POST" });
384
- } catch (p) {
385
- s(p instanceof Error ? p.message : "Failed to drain queue");
386
- }
387
- },
388
- [s]
389
- );
390
- return {
391
- queues: e,
392
- error: r,
393
- refreshQueue: i,
394
- pauseQueue: c,
395
- resumeQueue: h,
396
- cleanQueue: d,
397
- drainQueue: y
398
- };
399
- };
400
- var je = class {
401
- constructor() {
402
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
403
- }
404
- subscribe(e) {
405
- return this.listeners.add(e), this.onSubscribe(), () => {
406
- this.listeners.delete(e), this.onUnsubscribe();
407
- };
408
- }
409
- hasListeners() {
410
- return this.listeners.size > 0;
411
- }
412
- onSubscribe() {
413
- }
414
- onUnsubscribe() {
415
- }
416
- }, xn = {
417
- // We need the wrapper function syntax below instead of direct references to
418
- // global setTimeout etc.
419
- //
420
- // BAD: `setTimeout: setTimeout`
421
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
422
- //
423
- // If we use direct references here, then anything that wants to spy on or
424
- // replace the global setTimeout (like tests) won't work since we'll already
425
- // have a hard reference to the original implementation at the time when this
426
- // file was imported.
427
- setTimeout: (e, t) => setTimeout(e, t),
428
- clearTimeout: (e) => clearTimeout(e),
429
- setInterval: (e, t) => setInterval(e, t),
430
- clearInterval: (e) => clearInterval(e)
431
- }, jn = class {
432
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
433
- // type at app boot; and if we leave that type, then any new timer provider
434
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
435
- //
436
- // We settle for type safety for the TimeoutProvider type, and accept that
437
- // this class is unsafe internally to allow for extension.
438
- #e = xn;
439
- #t = !1;
440
- setTimeoutProvider(e) {
441
- process.env.NODE_ENV !== "production" && this.#t && e !== this.#e && console.error(
442
- "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
443
- { previous: this.#e, provider: e }
444
- ), this.#e = e, process.env.NODE_ENV !== "production" && (this.#t = !1);
445
- }
446
- setTimeout(e, t) {
447
- return process.env.NODE_ENV !== "production" && (this.#t = !0), this.#e.setTimeout(e, t);
448
- }
449
- clearTimeout(e) {
450
- this.#e.clearTimeout(e);
451
- }
452
- setInterval(e, t) {
453
- return process.env.NODE_ENV !== "production" && (this.#t = !0), this.#e.setInterval(e, t);
454
- }
455
- clearInterval(e) {
456
- this.#e.clearInterval(e);
457
- }
458
- }, de = new jn();
459
- function wn(e) {
460
- setTimeout(e, 0);
461
- }
462
- var fe = typeof window > "u" || "Deno" in globalThis;
463
- function W() {
464
- }
465
- function Cn(e, t) {
466
- return typeof e == "function" ? e(t) : e;
467
- }
468
- function Ve(e) {
469
- return typeof e == "number" && e >= 0 && e !== 1 / 0;
470
- }
471
- function xs(e, t) {
472
- return Math.max(e + (t || 0) - Date.now(), 0);
473
- }
474
- function oe(e, t) {
475
- return typeof e == "function" ? e(t) : e;
476
- }
477
- function G(e, t) {
478
- return typeof e == "function" ? e(t) : e;
479
- }
480
- function Dt(e, t) {
481
- const {
482
- type: s = "all",
483
- exact: r,
484
- fetchStatus: a,
485
- predicate: o,
486
- queryKey: l,
487
- stale: i
488
- } = e;
489
- if (l) {
490
- if (r) {
491
- if (t.queryHash !== ft(l, t.options))
492
- return !1;
493
- } else if (!Re(t.queryKey, l))
494
- return !1;
495
- }
496
- if (s !== "all") {
497
- const c = t.isActive();
498
- if (s === "active" && !c || s === "inactive" && c)
499
- return !1;
500
- }
501
- return !(typeof i == "boolean" && t.isStale() !== i || a && a !== t.state.fetchStatus || o && !o(t));
502
- }
503
- function Pt(e, t) {
504
- const { exact: s, status: r, predicate: a, mutationKey: o } = e;
505
- if (o) {
506
- if (!t.options.mutationKey)
507
- return !1;
508
- if (s) {
509
- if (me(t.options.mutationKey) !== me(o))
510
- return !1;
511
- } else if (!Re(t.options.mutationKey, o))
512
- return !1;
513
- }
514
- return !(r && t.state.status !== r || a && !a(t));
515
- }
516
- function ft(e, t) {
517
- return (t?.queryKeyHashFn || me)(e);
518
- }
519
- function me(e) {
520
- return JSON.stringify(
521
- e,
522
- (t, s) => Ye(s) ? Object.keys(s).sort().reduce((r, a) => (r[a] = s[a], r), {}) : s
523
- );
524
- }
525
- function Re(e, t) {
526
- return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((s) => Re(e[s], t[s])) : !1;
527
- }
528
- var Sn = Object.prototype.hasOwnProperty;
529
- function Be(e, t) {
530
- if (e === t)
531
- return e;
532
- const s = Mt(e) && Mt(t);
533
- if (!s && !(Ye(e) && Ye(t))) return t;
534
- const a = (s ? e : Object.keys(e)).length, o = s ? t : Object.keys(t), l = o.length, i = s ? new Array(l) : {};
535
- let c = 0;
536
- for (let h = 0; h < l; h++) {
537
- const d = s ? h : o[h], y = e[d], f = t[d];
538
- if (y === f) {
539
- i[d] = y, (s ? h < a : Sn.call(e, d)) && c++;
540
- continue;
541
- }
542
- if (y === null || f === null || typeof y != "object" || typeof f != "object") {
543
- i[d] = f;
544
- continue;
545
- }
546
- const p = Be(y, f);
547
- i[d] = p, p === y && c++;
548
- }
549
- return a === l && c === a ? e : i;
550
- }
551
- function _e(e, t) {
552
- if (!t || Object.keys(e).length !== Object.keys(t).length)
553
- return !1;
554
- for (const s in e)
555
- if (e[s] !== t[s])
556
- return !1;
557
- return !0;
558
- }
559
- function Mt(e) {
560
- return Array.isArray(e) && e.length === Object.keys(e).length;
561
- }
562
- function Ye(e) {
563
- if (!Tt(e))
564
- return !1;
565
- const t = e.constructor;
566
- if (t === void 0)
567
- return !0;
568
- const s = t.prototype;
569
- return !(!Tt(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
570
- }
571
- function Tt(e) {
572
- return Object.prototype.toString.call(e) === "[object Object]";
573
- }
574
- function Nn(e) {
575
- return new Promise((t) => {
576
- de.setTimeout(t, e);
577
- });
578
- }
579
- function Ze(e, t, s) {
580
- if (typeof s.structuralSharing == "function")
581
- return s.structuralSharing(e, t);
582
- if (s.structuralSharing !== !1) {
583
- if (process.env.NODE_ENV !== "production")
584
- try {
585
- return Be(e, t);
586
- } catch (r) {
587
- throw console.error(
588
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${r}`
589
- ), r;
590
- }
591
- return Be(e, t);
592
- }
593
- return t;
594
- }
595
- function En(e, t, s = 0) {
596
- const r = [...e, t];
597
- return s && r.length > s ? r.slice(1) : r;
598
- }
599
- function On(e, t, s = 0) {
600
- const r = [t, ...e];
601
- return s && r.length > s ? r.slice(0, -1) : r;
602
- }
603
- var Qe = Symbol();
604
- function js(e, t) {
605
- return process.env.NODE_ENV !== "production" && e.queryFn === Qe && console.error(
606
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
607
- ), !e.queryFn && t?.initialPromise ? () => t.initialPromise : !e.queryFn || e.queryFn === Qe ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
608
- }
609
- function ws(e, t) {
610
- return typeof e == "function" ? e(...t) : !!e;
611
- }
612
- var Rn = class extends je {
613
- #e;
614
- #t;
615
- #s;
616
- constructor() {
617
- super(), this.#s = (e) => {
618
- if (!fe && window.addEventListener) {
619
- const t = () => e();
620
- return window.addEventListener("visibilitychange", t, !1), () => {
621
- window.removeEventListener("visibilitychange", t);
622
- };
623
- }
624
- };
625
- }
626
- onSubscribe() {
627
- this.#t || this.setEventListener(this.#s);
628
- }
629
- onUnsubscribe() {
630
- this.hasListeners() || (this.#t?.(), this.#t = void 0);
631
- }
632
- setEventListener(e) {
633
- this.#s = e, this.#t?.(), this.#t = e((t) => {
634
- typeof t == "boolean" ? this.setFocused(t) : this.onFocus();
635
- });
636
- }
637
- setFocused(e) {
638
- this.#e !== e && (this.#e = e, this.onFocus());
639
- }
640
- onFocus() {
641
- const e = this.isFocused();
642
- this.listeners.forEach((t) => {
643
- t(e);
644
- });
645
- }
646
- isFocused() {
647
- return typeof this.#e == "boolean" ? this.#e : globalThis.document?.visibilityState !== "hidden";
648
- }
649
- }, mt = new Rn();
650
- function Xe() {
651
- let e, t;
652
- const s = new Promise((a, o) => {
653
- e = a, t = o;
654
- });
655
- s.status = "pending", s.catch(() => {
656
- });
657
- function r(a) {
658
- Object.assign(s, a), delete s.resolve, delete s.reject;
659
- }
660
- return s.resolve = (a) => {
661
- r({
662
- status: "fulfilled",
663
- value: a
664
- }), e(a);
665
- }, s.reject = (a) => {
666
- r({
667
- status: "rejected",
668
- reason: a
669
- }), t(a);
670
- }, s;
671
- }
672
- var kn = wn;
673
- function Dn() {
674
- let e = [], t = 0, s = (i) => {
675
- i();
676
- }, r = (i) => {
677
- i();
678
- }, a = kn;
679
- const o = (i) => {
680
- t ? e.push(i) : a(() => {
681
- s(i);
682
- });
683
- }, l = () => {
684
- const i = e;
685
- e = [], i.length && a(() => {
686
- r(() => {
687
- i.forEach((c) => {
688
- s(c);
689
- });
690
- });
691
- });
692
- };
693
- return {
694
- batch: (i) => {
695
- let c;
696
- t++;
697
- try {
698
- c = i();
699
- } finally {
700
- t--, t || l();
701
- }
702
- return c;
703
- },
704
- /**
705
- * All calls to the wrapped function will be batched.
706
- */
707
- batchCalls: (i) => (...c) => {
708
- o(() => {
709
- i(...c);
710
- });
711
- },
712
- schedule: o,
713
- /**
714
- * Use this method to set a custom notify function.
715
- * This can be used to for example wrap notifications with `React.act` while running tests.
716
- */
717
- setNotifyFunction: (i) => {
718
- s = i;
719
- },
720
- /**
721
- * Use this method to set a custom function to batch notifications together into a single tick.
722
- * By default React Query will use the batch function provided by ReactDOM or React Native.
723
- */
724
- setBatchNotifyFunction: (i) => {
725
- r = i;
726
- },
727
- setScheduler: (i) => {
728
- a = i;
729
- }
730
- };
731
- }
732
- var q = Dn(), Pn = class extends je {
733
- #e = !0;
734
- #t;
735
- #s;
736
- constructor() {
737
- super(), this.#s = (e) => {
738
- if (!fe && window.addEventListener) {
739
- const t = () => e(!0), s = () => e(!1);
740
- return window.addEventListener("online", t, !1), window.addEventListener("offline", s, !1), () => {
741
- window.removeEventListener("online", t), window.removeEventListener("offline", s);
742
- };
743
- }
744
- };
745
- }
746
- onSubscribe() {
747
- this.#t || this.setEventListener(this.#s);
748
- }
749
- onUnsubscribe() {
750
- this.hasListeners() || (this.#t?.(), this.#t = void 0);
751
- }
752
- setEventListener(e) {
753
- this.#s = e, this.#t?.(), this.#t = e(this.setOnline.bind(this));
754
- }
755
- setOnline(e) {
756
- this.#e !== e && (this.#e = e, this.listeners.forEach((s) => {
757
- s(e);
758
- }));
759
- }
760
- isOnline() {
761
- return this.#e;
762
- }
763
- }, Ie = new Pn();
764
- function Mn(e) {
765
- return Math.min(1e3 * 2 ** e, 3e4);
766
- }
767
- function Cs(e) {
768
- return (e ?? "online") === "online" ? Ie.isOnline() : !0;
769
- }
770
- var Ge = class extends Error {
771
- constructor(e) {
772
- super("CancelledError"), this.revert = e?.revert, this.silent = e?.silent;
773
- }
774
- };
775
- function Ss(e) {
776
- let t = !1, s = 0, r;
777
- const a = Xe(), o = () => a.status !== "pending", l = (g) => {
778
- if (!o()) {
779
- const N = new Ge(g);
780
- f(N), e.onCancel?.(N);
781
- }
782
- }, i = () => {
783
- t = !0;
784
- }, c = () => {
785
- t = !1;
786
- }, h = () => mt.isFocused() && (e.networkMode === "always" || Ie.isOnline()) && e.canRun(), d = () => Cs(e.networkMode) && e.canRun(), y = (g) => {
787
- o() || (r?.(), a.resolve(g));
788
- }, f = (g) => {
789
- o() || (r?.(), a.reject(g));
790
- }, p = () => new Promise((g) => {
791
- r = (N) => {
792
- (o() || h()) && g(N);
793
- }, e.onPause?.();
794
- }).then(() => {
795
- r = void 0, o() || e.onContinue?.();
796
- }), m = () => {
797
- if (o())
798
- return;
799
- let g;
800
- const N = s === 0 ? e.initialPromise : void 0;
801
- try {
802
- g = N ?? e.fn();
803
- } catch (b) {
804
- g = Promise.reject(b);
805
- }
806
- Promise.resolve(g).then(y).catch((b) => {
807
- if (o())
808
- return;
809
- const P = e.retry ?? (fe ? 0 : 3), T = e.retryDelay ?? Mn, j = typeof T == "function" ? T(s, b) : T, w = P === !0 || typeof P == "number" && s < P || typeof P == "function" && P(s, b);
810
- if (t || !w) {
811
- f(b);
812
- return;
813
- }
814
- s++, e.onFail?.(s, b), Nn(j).then(() => h() ? void 0 : p()).then(() => {
815
- t ? f(b) : m();
816
- });
817
- });
818
- };
819
- return {
820
- promise: a,
821
- status: () => a.status,
822
- cancel: l,
823
- continue: () => (r?.(), a),
824
- cancelRetry: i,
825
- continueRetry: c,
826
- canStart: d,
827
- start: () => (d() ? m() : p().then(m), a)
828
- };
829
- }
830
- var Ns = class {
831
- #e;
832
- destroy() {
833
- this.clearGcTimeout();
834
- }
835
- scheduleGc() {
836
- this.clearGcTimeout(), Ve(this.gcTime) && (this.#e = de.setTimeout(() => {
837
- this.optionalRemove();
838
- }, this.gcTime));
839
- }
840
- updateGcTime(e) {
841
- this.gcTime = Math.max(
842
- this.gcTime || 0,
843
- e ?? (fe ? 1 / 0 : 5 * 60 * 1e3)
844
- );
845
- }
846
- clearGcTimeout() {
847
- this.#e && (de.clearTimeout(this.#e), this.#e = void 0);
848
- }
849
- }, Tn = class extends Ns {
850
- #e;
851
- #t;
852
- #s;
853
- #r;
854
- #n;
855
- #i;
856
- #o;
857
- constructor(e) {
858
- super(), this.#o = !1, this.#i = e.defaultOptions, this.setOptions(e.options), this.observers = [], this.#r = e.client, this.#s = this.#r.getQueryCache(), this.queryKey = e.queryKey, this.queryHash = e.queryHash, this.#e = Ft(this.options), this.state = e.state ?? this.#e, this.scheduleGc();
859
- }
860
- get meta() {
861
- return this.options.meta;
862
- }
863
- get promise() {
864
- return this.#n?.promise;
865
- }
866
- setOptions(e) {
867
- if (this.options = { ...this.#i, ...e }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
868
- const t = Ft(this.options);
869
- t.data !== void 0 && (this.setState(
870
- At(t.data, t.dataUpdatedAt)
871
- ), this.#e = t);
872
- }
873
- }
874
- optionalRemove() {
875
- !this.observers.length && this.state.fetchStatus === "idle" && this.#s.remove(this);
876
- }
877
- setData(e, t) {
878
- const s = Ze(this.state.data, e, this.options);
879
- return this.#a({
880
- data: s,
881
- type: "success",
882
- dataUpdatedAt: t?.updatedAt,
883
- manual: t?.manual
884
- }), s;
885
- }
886
- setState(e, t) {
887
- this.#a({ type: "setState", state: e, setStateOptions: t });
888
- }
889
- cancel(e) {
890
- const t = this.#n?.promise;
891
- return this.#n?.cancel(e), t ? t.then(W).catch(W) : Promise.resolve();
892
- }
893
- destroy() {
894
- super.destroy(), this.cancel({ silent: !0 });
895
- }
896
- reset() {
897
- this.destroy(), this.setState(this.#e);
898
- }
899
- isActive() {
900
- return this.observers.some(
901
- (e) => G(e.options.enabled, this) !== !1
902
- );
903
- }
904
- isDisabled() {
905
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Qe || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
906
- }
907
- isStatic() {
908
- return this.getObserversCount() > 0 ? this.observers.some(
909
- (e) => oe(e.options.staleTime, this) === "static"
910
- ) : !1;
911
- }
912
- isStale() {
913
- return this.getObserversCount() > 0 ? this.observers.some(
914
- (e) => e.getCurrentResult().isStale
915
- ) : this.state.data === void 0 || this.state.isInvalidated;
916
- }
917
- isStaleByTime(e = 0) {
918
- return this.state.data === void 0 ? !0 : e === "static" ? !1 : this.state.isInvalidated ? !0 : !xs(this.state.dataUpdatedAt, e);
919
- }
920
- onFocus() {
921
- this.observers.find((t) => t.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#n?.continue();
922
- }
923
- onOnline() {
924
- this.observers.find((t) => t.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#n?.continue();
925
- }
926
- addObserver(e) {
927
- this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), this.#s.notify({ type: "observerAdded", query: this, observer: e }));
928
- }
929
- removeObserver(e) {
930
- this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (this.#n && (this.#o ? this.#n.cancel({ revert: !0 }) : this.#n.cancelRetry()), this.scheduleGc()), this.#s.notify({ type: "observerRemoved", query: this, observer: e }));
931
- }
932
- getObserversCount() {
933
- return this.observers.length;
934
- }
935
- invalidate() {
936
- this.state.isInvalidated || this.#a({ type: "invalidate" });
937
- }
938
- async fetch(e, t) {
939
- if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
940
- // re-start the fetch; there is a chance that the query is still in a
941
- // pending state when that happens
942
- this.#n?.status() !== "rejected") {
943
- if (this.state.data !== void 0 && t?.cancelRefetch)
944
- this.cancel({ silent: !0 });
945
- else if (this.#n)
946
- return this.#n.continueRetry(), this.#n.promise;
947
- }
948
- if (e && this.setOptions(e), !this.options.queryFn) {
949
- const i = this.observers.find((c) => c.options.queryFn);
950
- i && this.setOptions(i.options);
951
- }
952
- process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
953
- "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
954
- ));
955
- const s = new AbortController(), r = (i) => {
956
- Object.defineProperty(i, "signal", {
957
- enumerable: !0,
958
- get: () => (this.#o = !0, s.signal)
959
- });
960
- }, a = () => {
961
- const i = js(this.options, t), h = (() => {
962
- const d = {
963
- client: this.#r,
964
- queryKey: this.queryKey,
965
- meta: this.meta
966
- };
967
- return r(d), d;
968
- })();
969
- return this.#o = !1, this.options.persister ? this.options.persister(
970
- i,
971
- h,
972
- this
973
- ) : i(h);
974
- }, l = (() => {
975
- const i = {
976
- fetchOptions: t,
977
- options: this.options,
978
- queryKey: this.queryKey,
979
- client: this.#r,
980
- state: this.state,
981
- fetchFn: a
982
- };
983
- return r(i), i;
984
- })();
985
- this.options.behavior?.onFetch(l, this), this.#t = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== l.fetchOptions?.meta) && this.#a({ type: "fetch", meta: l.fetchOptions?.meta }), this.#n = Ss({
986
- initialPromise: t?.initialPromise,
987
- fn: l.fetchFn,
988
- onCancel: (i) => {
989
- i instanceof Ge && i.revert && this.setState({
990
- ...this.#t,
991
- fetchStatus: "idle"
992
- }), s.abort();
993
- },
994
- onFail: (i, c) => {
995
- this.#a({ type: "failed", failureCount: i, error: c });
996
- },
997
- onPause: () => {
998
- this.#a({ type: "pause" });
999
- },
1000
- onContinue: () => {
1001
- this.#a({ type: "continue" });
1002
- },
1003
- retry: l.options.retry,
1004
- retryDelay: l.options.retryDelay,
1005
- networkMode: l.options.networkMode,
1006
- canRun: () => !0
1007
- });
1008
- try {
1009
- const i = await this.#n.start();
1010
- if (i === void 0)
1011
- throw process.env.NODE_ENV !== "production" && console.error(
1012
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
1013
- ), new Error(`${this.queryHash} data is undefined`);
1014
- return this.setData(i), this.#s.config.onSuccess?.(i, this), this.#s.config.onSettled?.(
1015
- i,
1016
- this.state.error,
1017
- this
1018
- ), i;
1019
- } catch (i) {
1020
- if (i instanceof Ge) {
1021
- if (i.silent)
1022
- return this.#n.promise;
1023
- if (i.revert) {
1024
- if (this.state.data === void 0)
1025
- throw i;
1026
- return this.state.data;
1027
- }
1028
- }
1029
- throw this.#a({
1030
- type: "error",
1031
- error: i
1032
- }), this.#s.config.onError?.(
1033
- i,
1034
- this
1035
- ), this.#s.config.onSettled?.(
1036
- this.state.data,
1037
- i,
1038
- this
1039
- ), i;
1040
- } finally {
1041
- this.scheduleGc();
1042
- }
1043
- }
1044
- #a(e) {
1045
- const t = (s) => {
1046
- switch (e.type) {
1047
- case "failed":
1048
- return {
1049
- ...s,
1050
- fetchFailureCount: e.failureCount,
1051
- fetchFailureReason: e.error
1052
- };
1053
- case "pause":
1054
- return {
1055
- ...s,
1056
- fetchStatus: "paused"
1057
- };
1058
- case "continue":
1059
- return {
1060
- ...s,
1061
- fetchStatus: "fetching"
1062
- };
1063
- case "fetch":
1064
- return {
1065
- ...s,
1066
- ...Es(s.data, this.options),
1067
- fetchMeta: e.meta ?? null
1068
- };
1069
- case "success":
1070
- const r = {
1071
- ...s,
1072
- ...At(e.data, e.dataUpdatedAt),
1073
- dataUpdateCount: s.dataUpdateCount + 1,
1074
- ...!e.manual && {
1075
- fetchStatus: "idle",
1076
- fetchFailureCount: 0,
1077
- fetchFailureReason: null
1078
- }
1079
- };
1080
- return this.#t = e.manual ? r : void 0, r;
1081
- case "error":
1082
- const a = e.error;
1083
- return {
1084
- ...s,
1085
- error: a,
1086
- errorUpdateCount: s.errorUpdateCount + 1,
1087
- errorUpdatedAt: Date.now(),
1088
- fetchFailureCount: s.fetchFailureCount + 1,
1089
- fetchFailureReason: a,
1090
- fetchStatus: "idle",
1091
- status: "error"
1092
- };
1093
- case "invalidate":
1094
- return {
1095
- ...s,
1096
- isInvalidated: !0
1097
- };
1098
- case "setState":
1099
- return {
1100
- ...s,
1101
- ...e.state
1102
- };
1103
- }
1104
- };
1105
- this.state = t(this.state), q.batch(() => {
1106
- this.observers.forEach((s) => {
1107
- s.onQueryUpdate();
1108
- }), this.#s.notify({ query: this, type: "updated", action: e });
1109
- });
1110
- }
1111
- };
1112
- function Es(e, t) {
1113
- return {
1114
- fetchFailureCount: 0,
1115
- fetchFailureReason: null,
1116
- fetchStatus: Cs(t.networkMode) ? "fetching" : "paused",
1117
- ...e === void 0 && {
1118
- error: null,
1119
- status: "pending"
1120
- }
1121
- };
1122
- }
1123
- function At(e, t) {
1124
- return {
1125
- data: e,
1126
- dataUpdatedAt: t ?? Date.now(),
1127
- error: null,
1128
- isInvalidated: !1,
1129
- status: "success"
1130
- };
1131
- }
1132
- function Ft(e) {
1133
- const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, s = t !== void 0, r = s ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
1134
- return {
1135
- data: t,
1136
- dataUpdateCount: 0,
1137
- dataUpdatedAt: s ? r ?? Date.now() : 0,
1138
- error: null,
1139
- errorUpdateCount: 0,
1140
- errorUpdatedAt: 0,
1141
- fetchFailureCount: 0,
1142
- fetchFailureReason: null,
1143
- fetchMeta: null,
1144
- isInvalidated: !1,
1145
- status: s ? "success" : "pending",
1146
- fetchStatus: "idle"
1147
- };
1148
- }
1149
- var An = class extends je {
1150
- constructor(e, t) {
1151
- super(), this.options = t, this.#e = e, this.#a = null, this.#o = Xe(), this.bindMethods(), this.setOptions(t);
1152
- }
1153
- #e;
1154
- #t = void 0;
1155
- #s = void 0;
1156
- #r = void 0;
1157
- #n;
1158
- #i;
1159
- #o;
1160
- #a;
1161
- #p;
1162
- #h;
1163
- // This property keeps track of the last query with defined data.
1164
- // It will be used to pass the previous data and query to the placeholder function between renders.
1165
- #f;
1166
- #c;
1167
- #u;
1168
- #l;
1169
- #m = /* @__PURE__ */ new Set();
1170
- bindMethods() {
1171
- this.refetch = this.refetch.bind(this);
1172
- }
1173
- onSubscribe() {
1174
- this.listeners.size === 1 && (this.#t.addObserver(this), _t(this.#t, this.options) ? this.#d() : this.updateResult(), this.#b());
1175
- }
1176
- onUnsubscribe() {
1177
- this.hasListeners() || this.destroy();
1178
- }
1179
- shouldFetchOnReconnect() {
1180
- return et(
1181
- this.#t,
1182
- this.options,
1183
- this.options.refetchOnReconnect
1184
- );
1185
- }
1186
- shouldFetchOnWindowFocus() {
1187
- return et(
1188
- this.#t,
1189
- this.options,
1190
- this.options.refetchOnWindowFocus
1191
- );
1192
- }
1193
- destroy() {
1194
- this.listeners = /* @__PURE__ */ new Set(), this.#x(), this.#j(), this.#t.removeObserver(this);
1195
- }
1196
- setOptions(e) {
1197
- const t = this.options, s = this.#t;
1198
- if (this.options = this.#e.defaultQueryOptions(e), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof G(this.options.enabled, this.#t) != "boolean")
1199
- throw new Error(
1200
- "Expected enabled to be a boolean or a callback that returns a boolean"
1201
- );
1202
- this.#w(), this.#t.setOptions(this.options), t._defaulted && !_e(this.options, t) && this.#e.getQueryCache().notify({
1203
- type: "observerOptionsUpdated",
1204
- query: this.#t,
1205
- observer: this
1206
- });
1207
- const r = this.hasListeners();
1208
- r && Qt(
1209
- this.#t,
1210
- s,
1211
- this.options,
1212
- t
1213
- ) && this.#d(), this.updateResult(), r && (this.#t !== s || G(this.options.enabled, this.#t) !== G(t.enabled, this.#t) || oe(this.options.staleTime, this.#t) !== oe(t.staleTime, this.#t)) && this.#y();
1214
- const a = this.#g();
1215
- r && (this.#t !== s || G(this.options.enabled, this.#t) !== G(t.enabled, this.#t) || a !== this.#l) && this.#v(a);
1216
- }
1217
- getOptimisticResult(e) {
1218
- const t = this.#e.getQueryCache().build(this.#e, e), s = this.createResult(t, e);
1219
- return _n(this, s) && (this.#r = s, this.#i = this.options, this.#n = this.#t.state), s;
1220
- }
1221
- getCurrentResult() {
1222
- return this.#r;
1223
- }
1224
- trackResult(e, t) {
1225
- return new Proxy(e, {
1226
- get: (s, r) => (this.trackProp(r), t?.(r), r === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && this.#o.status === "pending" && this.#o.reject(
1227
- new Error(
1228
- "experimental_prefetchInRender feature flag is not enabled"
1229
- )
1230
- )), Reflect.get(s, r))
1231
- });
1232
- }
1233
- trackProp(e) {
1234
- this.#m.add(e);
1235
- }
1236
- getCurrentQuery() {
1237
- return this.#t;
1238
- }
1239
- refetch({ ...e } = {}) {
1240
- return this.fetch({
1241
- ...e
1242
- });
1243
- }
1244
- fetchOptimistic(e) {
1245
- const t = this.#e.defaultQueryOptions(e), s = this.#e.getQueryCache().build(this.#e, t);
1246
- return s.fetch().then(() => this.createResult(s, t));
1247
- }
1248
- fetch(e) {
1249
- return this.#d({
1250
- ...e,
1251
- cancelRefetch: e.cancelRefetch ?? !0
1252
- }).then(() => (this.updateResult(), this.#r));
1253
- }
1254
- #d(e) {
1255
- this.#w();
1256
- let t = this.#t.fetch(
1257
- this.options,
1258
- e
1259
- );
1260
- return e?.throwOnError || (t = t.catch(W)), t;
1261
- }
1262
- #y() {
1263
- this.#x();
1264
- const e = oe(
1265
- this.options.staleTime,
1266
- this.#t
1267
- );
1268
- if (fe || this.#r.isStale || !Ve(e))
1269
- return;
1270
- const s = xs(this.#r.dataUpdatedAt, e) + 1;
1271
- this.#c = de.setTimeout(() => {
1272
- this.#r.isStale || this.updateResult();
1273
- }, s);
1274
- }
1275
- #g() {
1276
- return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#t) : this.options.refetchInterval) ?? !1;
1277
- }
1278
- #v(e) {
1279
- this.#j(), this.#l = e, !(fe || G(this.options.enabled, this.#t) === !1 || !Ve(this.#l) || this.#l === 0) && (this.#u = de.setInterval(() => {
1280
- (this.options.refetchIntervalInBackground || mt.isFocused()) && this.#d();
1281
- }, this.#l));
1282
- }
1283
- #b() {
1284
- this.#y(), this.#v(this.#g());
1285
- }
1286
- #x() {
1287
- this.#c && (de.clearTimeout(this.#c), this.#c = void 0);
1288
- }
1289
- #j() {
1290
- this.#u && (de.clearInterval(this.#u), this.#u = void 0);
1291
- }
1292
- createResult(e, t) {
1293
- const s = this.#t, r = this.options, a = this.#r, o = this.#n, l = this.#i, c = e !== s ? e.state : this.#s, { state: h } = e;
1294
- let d = { ...h }, y = !1, f;
1295
- if (t._optimisticResults) {
1296
- const M = this.hasListeners(), F = !M && _t(e, t), I = M && Qt(e, s, t, r);
1297
- (F || I) && (d = {
1298
- ...d,
1299
- ...Es(h.data, e.options)
1300
- }), t._optimisticResults === "isRestoring" && (d.fetchStatus = "idle");
1301
- }
1302
- let { error: p, errorUpdatedAt: m, status: g } = d;
1303
- f = d.data;
1304
- let N = !1;
1305
- if (t.placeholderData !== void 0 && f === void 0 && g === "pending") {
1306
- let M;
1307
- a?.isPlaceholderData && t.placeholderData === l?.placeholderData ? (M = a.data, N = !0) : M = typeof t.placeholderData == "function" ? t.placeholderData(
1308
- this.#f?.state.data,
1309
- this.#f
1310
- ) : t.placeholderData, M !== void 0 && (g = "success", f = Ze(
1311
- a?.data,
1312
- M,
1313
- t
1314
- ), y = !0);
1315
- }
1316
- if (t.select && f !== void 0 && !N)
1317
- if (a && f === o?.data && t.select === this.#p)
1318
- f = this.#h;
1319
- else
1320
- try {
1321
- this.#p = t.select, f = t.select(f), f = Ze(a?.data, f, t), this.#h = f, this.#a = null;
1322
- } catch (M) {
1323
- this.#a = M;
1324
- }
1325
- this.#a && (p = this.#a, f = this.#h, m = Date.now(), g = "error");
1326
- const b = d.fetchStatus === "fetching", P = g === "pending", T = g === "error", j = P && b, w = f !== void 0, S = {
1327
- status: g,
1328
- fetchStatus: d.fetchStatus,
1329
- isPending: P,
1330
- isSuccess: g === "success",
1331
- isError: T,
1332
- isInitialLoading: j,
1333
- isLoading: j,
1334
- data: f,
1335
- dataUpdatedAt: d.dataUpdatedAt,
1336
- error: p,
1337
- errorUpdatedAt: m,
1338
- failureCount: d.fetchFailureCount,
1339
- failureReason: d.fetchFailureReason,
1340
- errorUpdateCount: d.errorUpdateCount,
1341
- isFetched: d.dataUpdateCount > 0 || d.errorUpdateCount > 0,
1342
- isFetchedAfterMount: d.dataUpdateCount > c.dataUpdateCount || d.errorUpdateCount > c.errorUpdateCount,
1343
- isFetching: b,
1344
- isRefetching: b && !P,
1345
- isLoadingError: T && !w,
1346
- isPaused: d.fetchStatus === "paused",
1347
- isPlaceholderData: y,
1348
- isRefetchError: T && w,
1349
- isStale: pt(e, t),
1350
- refetch: this.refetch,
1351
- promise: this.#o,
1352
- isEnabled: G(t.enabled, e) !== !1
1353
- };
1354
- if (this.options.experimental_prefetchInRender) {
1355
- const M = (_) => {
1356
- S.status === "error" ? _.reject(S.error) : S.data !== void 0 && _.resolve(S.data);
1357
- }, F = () => {
1358
- const _ = this.#o = S.promise = Xe();
1359
- M(_);
1360
- }, I = this.#o;
1361
- switch (I.status) {
1362
- case "pending":
1363
- e.queryHash === s.queryHash && M(I);
1364
- break;
1365
- case "fulfilled":
1366
- (S.status === "error" || S.data !== I.value) && F();
1367
- break;
1368
- case "rejected":
1369
- (S.status !== "error" || S.error !== I.reason) && F();
1370
- break;
1371
- }
1372
- }
1373
- return S;
1374
- }
1375
- updateResult() {
1376
- const e = this.#r, t = this.createResult(this.#t, this.options);
1377
- if (this.#n = this.#t.state, this.#i = this.options, this.#n.data !== void 0 && (this.#f = this.#t), _e(t, e))
1378
- return;
1379
- this.#r = t;
1380
- const s = () => {
1381
- if (!e)
1382
- return !0;
1383
- const { notifyOnChangeProps: r } = this.options, a = typeof r == "function" ? r() : r;
1384
- if (a === "all" || !a && !this.#m.size)
1385
- return !0;
1386
- const o = new Set(
1387
- a ?? this.#m
1388
- );
1389
- return this.options.throwOnError && o.add("error"), Object.keys(this.#r).some((l) => {
1390
- const i = l;
1391
- return this.#r[i] !== e[i] && o.has(i);
1392
- });
1393
- };
1394
- this.#C({ listeners: s() });
1395
- }
1396
- #w() {
1397
- const e = this.#e.getQueryCache().build(this.#e, this.options);
1398
- if (e === this.#t)
1399
- return;
1400
- const t = this.#t;
1401
- this.#t = e, this.#s = e.state, this.hasListeners() && (t?.removeObserver(this), e.addObserver(this));
1402
- }
1403
- onQueryUpdate() {
1404
- this.updateResult(), this.hasListeners() && this.#b();
1405
- }
1406
- #C(e) {
1407
- q.batch(() => {
1408
- e.listeners && this.listeners.forEach((t) => {
1409
- t(this.#r);
1410
- }), this.#e.getQueryCache().notify({
1411
- query: this.#t,
1412
- type: "observerResultsUpdated"
1413
- });
1414
- });
1415
- }
1416
- };
1417
- function Fn(e, t) {
1418
- return G(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1);
1419
- }
1420
- function _t(e, t) {
1421
- return Fn(e, t) || e.state.data !== void 0 && et(e, t, t.refetchOnMount);
1422
- }
1423
- function et(e, t, s) {
1424
- if (G(t.enabled, e) !== !1 && oe(t.staleTime, e) !== "static") {
1425
- const r = typeof s == "function" ? s(e) : s;
1426
- return r === "always" || r !== !1 && pt(e, t);
1427
- }
1428
- return !1;
1429
- }
1430
- function Qt(e, t, s, r) {
1431
- return (e !== t || G(r.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && pt(e, s);
1432
- }
1433
- function pt(e, t) {
1434
- return G(t.enabled, e) !== !1 && e.isStaleByTime(oe(t.staleTime, e));
1435
- }
1436
- function _n(e, t) {
1437
- return !_e(e.getCurrentResult(), t);
1438
- }
1439
- function It(e) {
1440
- return {
1441
- onFetch: (t, s) => {
1442
- const r = t.options, a = t.fetchOptions?.meta?.fetchMore?.direction, o = t.state.data?.pages || [], l = t.state.data?.pageParams || [];
1443
- let i = { pages: [], pageParams: [] }, c = 0;
1444
- const h = async () => {
1445
- let d = !1;
1446
- const y = (m) => {
1447
- Object.defineProperty(m, "signal", {
1448
- enumerable: !0,
1449
- get: () => (t.signal.aborted ? d = !0 : t.signal.addEventListener("abort", () => {
1450
- d = !0;
1451
- }), t.signal)
1452
- });
1453
- }, f = js(t.options, t.fetchOptions), p = async (m, g, N) => {
1454
- if (d)
1455
- return Promise.reject();
1456
- if (g == null && m.pages.length)
1457
- return Promise.resolve(m);
1458
- const P = (() => {
1459
- const R = {
1460
- client: t.client,
1461
- queryKey: t.queryKey,
1462
- pageParam: g,
1463
- direction: N ? "backward" : "forward",
1464
- meta: t.options.meta
1465
- };
1466
- return y(R), R;
1467
- })(), T = await f(P), { maxPages: j } = t.options, w = N ? On : En;
1468
- return {
1469
- pages: w(m.pages, T, j),
1470
- pageParams: w(m.pageParams, g, j)
1471
- };
1472
- };
1473
- if (a && o.length) {
1474
- const m = a === "backward", g = m ? Qn : qt, N = {
1475
- pages: o,
1476
- pageParams: l
1477
- }, b = g(r, N);
1478
- i = await p(N, b, m);
1479
- } else {
1480
- const m = e ?? o.length;
1481
- do {
1482
- const g = c === 0 ? l[0] ?? r.initialPageParam : qt(r, i);
1483
- if (c > 0 && g == null)
1484
- break;
1485
- i = await p(i, g), c++;
1486
- } while (c < m);
1487
- }
1488
- return i;
1489
- };
1490
- t.options.persister ? t.fetchFn = () => t.options.persister?.(
1491
- h,
1492
- {
1493
- client: t.client,
1494
- queryKey: t.queryKey,
1495
- meta: t.options.meta,
1496
- signal: t.signal
1497
- },
1498
- s
1499
- ) : t.fetchFn = h;
1500
- }
1501
- };
1502
- }
1503
- function qt(e, { pages: t, pageParams: s }) {
1504
- const r = t.length - 1;
1505
- return t.length > 0 ? e.getNextPageParam(
1506
- t[r],
1507
- t,
1508
- s[r],
1509
- s
1510
- ) : void 0;
1511
- }
1512
- function Qn(e, { pages: t, pageParams: s }) {
1513
- return t.length > 0 ? e.getPreviousPageParam?.(t[0], t, s[0], s) : void 0;
1514
- }
1515
- var In = class extends Ns {
1516
- #e;
1517
- #t;
1518
- #s;
1519
- #r;
1520
- constructor(e) {
1521
- super(), this.#e = e.client, this.mutationId = e.mutationId, this.#s = e.mutationCache, this.#t = [], this.state = e.state || Os(), this.setOptions(e.options), this.scheduleGc();
1522
- }
1523
- setOptions(e) {
1524
- this.options = e, this.updateGcTime(this.options.gcTime);
1525
- }
1526
- get meta() {
1527
- return this.options.meta;
1528
- }
1529
- addObserver(e) {
1530
- this.#t.includes(e) || (this.#t.push(e), this.clearGcTimeout(), this.#s.notify({
1531
- type: "observerAdded",
1532
- mutation: this,
1533
- observer: e
1534
- }));
1535
- }
1536
- removeObserver(e) {
1537
- this.#t = this.#t.filter((t) => t !== e), this.scheduleGc(), this.#s.notify({
1538
- type: "observerRemoved",
1539
- mutation: this,
1540
- observer: e
1541
- });
1542
- }
1543
- optionalRemove() {
1544
- this.#t.length || (this.state.status === "pending" ? this.scheduleGc() : this.#s.remove(this));
1545
- }
1546
- continue() {
1547
- return this.#r?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
1548
- this.execute(this.state.variables);
1549
- }
1550
- async execute(e) {
1551
- const t = () => {
1552
- this.#n({ type: "continue" });
1553
- }, s = {
1554
- client: this.#e,
1555
- meta: this.options.meta,
1556
- mutationKey: this.options.mutationKey
1557
- };
1558
- this.#r = Ss({
1559
- fn: () => this.options.mutationFn ? this.options.mutationFn(e, s) : Promise.reject(new Error("No mutationFn found")),
1560
- onFail: (o, l) => {
1561
- this.#n({ type: "failed", failureCount: o, error: l });
1562
- },
1563
- onPause: () => {
1564
- this.#n({ type: "pause" });
1565
- },
1566
- onContinue: t,
1567
- retry: this.options.retry ?? 0,
1568
- retryDelay: this.options.retryDelay,
1569
- networkMode: this.options.networkMode,
1570
- canRun: () => this.#s.canRun(this)
1571
- });
1572
- const r = this.state.status === "pending", a = !this.#r.canStart();
1573
- try {
1574
- if (r)
1575
- t();
1576
- else {
1577
- this.#n({ type: "pending", variables: e, isPaused: a }), await this.#s.config.onMutate?.(
1578
- e,
1579
- this,
1580
- s
1581
- );
1582
- const l = await this.options.onMutate?.(
1583
- e,
1584
- s
1585
- );
1586
- l !== this.state.context && this.#n({
1587
- type: "pending",
1588
- context: l,
1589
- variables: e,
1590
- isPaused: a
1591
- });
1592
- }
1593
- const o = await this.#r.start();
1594
- return await this.#s.config.onSuccess?.(
1595
- o,
1596
- e,
1597
- this.state.context,
1598
- this,
1599
- s
1600
- ), await this.options.onSuccess?.(
1601
- o,
1602
- e,
1603
- this.state.context,
1604
- s
1605
- ), await this.#s.config.onSettled?.(
1606
- o,
1607
- null,
1608
- this.state.variables,
1609
- this.state.context,
1610
- this,
1611
- s
1612
- ), await this.options.onSettled?.(
1613
- o,
1614
- null,
1615
- e,
1616
- this.state.context,
1617
- s
1618
- ), this.#n({ type: "success", data: o }), o;
1619
- } catch (o) {
1620
- try {
1621
- throw await this.#s.config.onError?.(
1622
- o,
1623
- e,
1624
- this.state.context,
1625
- this,
1626
- s
1627
- ), await this.options.onError?.(
1628
- o,
1629
- e,
1630
- this.state.context,
1631
- s
1632
- ), await this.#s.config.onSettled?.(
1633
- void 0,
1634
- o,
1635
- this.state.variables,
1636
- this.state.context,
1637
- this,
1638
- s
1639
- ), await this.options.onSettled?.(
1640
- void 0,
1641
- o,
1642
- e,
1643
- this.state.context,
1644
- s
1645
- ), o;
1646
- } finally {
1647
- this.#n({ type: "error", error: o });
1648
- }
1649
- } finally {
1650
- this.#s.runNext(this);
1651
- }
1652
- }
1653
- #n(e) {
1654
- const t = (s) => {
1655
- switch (e.type) {
1656
- case "failed":
1657
- return {
1658
- ...s,
1659
- failureCount: e.failureCount,
1660
- failureReason: e.error
1661
- };
1662
- case "pause":
1663
- return {
1664
- ...s,
1665
- isPaused: !0
1666
- };
1667
- case "continue":
1668
- return {
1669
- ...s,
1670
- isPaused: !1
1671
- };
1672
- case "pending":
1673
- return {
1674
- ...s,
1675
- context: e.context,
1676
- data: void 0,
1677
- failureCount: 0,
1678
- failureReason: null,
1679
- error: null,
1680
- isPaused: e.isPaused,
1681
- status: "pending",
1682
- variables: e.variables,
1683
- submittedAt: Date.now()
1684
- };
1685
- case "success":
1686
- return {
1687
- ...s,
1688
- data: e.data,
1689
- failureCount: 0,
1690
- failureReason: null,
1691
- error: null,
1692
- status: "success",
1693
- isPaused: !1
1694
- };
1695
- case "error":
1696
- return {
1697
- ...s,
1698
- data: void 0,
1699
- error: e.error,
1700
- failureCount: s.failureCount + 1,
1701
- failureReason: e.error,
1702
- isPaused: !1,
1703
- status: "error"
1704
- };
1705
- }
1706
- };
1707
- this.state = t(this.state), q.batch(() => {
1708
- this.#t.forEach((s) => {
1709
- s.onMutationUpdate(e);
1710
- }), this.#s.notify({
1711
- mutation: this,
1712
- type: "updated",
1713
- action: e
1714
- });
1715
- });
1716
- }
1717
- };
1718
- function Os() {
1719
- return {
1720
- context: void 0,
1721
- data: void 0,
1722
- error: null,
1723
- failureCount: 0,
1724
- failureReason: null,
1725
- isPaused: !1,
1726
- status: "idle",
1727
- variables: void 0,
1728
- submittedAt: 0
1729
- };
1730
- }
1731
- var qn = class extends je {
1732
- constructor(e = {}) {
1733
- super(), this.config = e, this.#e = /* @__PURE__ */ new Set(), this.#t = /* @__PURE__ */ new Map(), this.#s = 0;
1734
- }
1735
- #e;
1736
- #t;
1737
- #s;
1738
- build(e, t, s) {
1739
- const r = new In({
1740
- client: e,
1741
- mutationCache: this,
1742
- mutationId: ++this.#s,
1743
- options: e.defaultMutationOptions(t),
1744
- state: s
1745
- });
1746
- return this.add(r), r;
1747
- }
1748
- add(e) {
1749
- this.#e.add(e);
1750
- const t = Pe(e);
1751
- if (typeof t == "string") {
1752
- const s = this.#t.get(t);
1753
- s ? s.push(e) : this.#t.set(t, [e]);
1754
- }
1755
- this.notify({ type: "added", mutation: e });
1756
- }
1757
- remove(e) {
1758
- if (this.#e.delete(e)) {
1759
- const t = Pe(e);
1760
- if (typeof t == "string") {
1761
- const s = this.#t.get(t);
1762
- if (s)
1763
- if (s.length > 1) {
1764
- const r = s.indexOf(e);
1765
- r !== -1 && s.splice(r, 1);
1766
- } else s[0] === e && this.#t.delete(t);
1767
- }
1768
- }
1769
- this.notify({ type: "removed", mutation: e });
1770
- }
1771
- canRun(e) {
1772
- const t = Pe(e);
1773
- if (typeof t == "string") {
1774
- const r = this.#t.get(t)?.find(
1775
- (a) => a.state.status === "pending"
1776
- );
1777
- return !r || r === e;
1778
- } else
1779
- return !0;
1780
- }
1781
- runNext(e) {
1782
- const t = Pe(e);
1783
- return typeof t == "string" ? this.#t.get(t)?.find((r) => r !== e && r.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
1784
- }
1785
- clear() {
1786
- q.batch(() => {
1787
- this.#e.forEach((e) => {
1788
- this.notify({ type: "removed", mutation: e });
1789
- }), this.#e.clear(), this.#t.clear();
1790
- });
1791
- }
1792
- getAll() {
1793
- return Array.from(this.#e);
1794
- }
1795
- find(e) {
1796
- const t = { exact: !0, ...e };
1797
- return this.getAll().find(
1798
- (s) => Pt(t, s)
1799
- );
1800
- }
1801
- findAll(e = {}) {
1802
- return this.getAll().filter((t) => Pt(e, t));
1803
- }
1804
- notify(e) {
1805
- q.batch(() => {
1806
- this.listeners.forEach((t) => {
1807
- t(e);
1808
- });
1809
- });
1810
- }
1811
- resumePausedMutations() {
1812
- const e = this.getAll().filter((t) => t.state.isPaused);
1813
- return q.batch(
1814
- () => Promise.all(
1815
- e.map((t) => t.continue().catch(W))
1816
- )
1817
- );
1818
- }
1819
- };
1820
- function Pe(e) {
1821
- return e.options.scope?.id;
1822
- }
1823
- var Ln = class extends je {
1824
- #e;
1825
- #t = void 0;
1826
- #s;
1827
- #r;
1828
- constructor(e, t) {
1829
- super(), this.#e = e, this.setOptions(t), this.bindMethods(), this.#n();
1830
- }
1831
- bindMethods() {
1832
- this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
1833
- }
1834
- setOptions(e) {
1835
- const t = this.options;
1836
- this.options = this.#e.defaultMutationOptions(e), _e(this.options, t) || this.#e.getMutationCache().notify({
1837
- type: "observerOptionsUpdated",
1838
- mutation: this.#s,
1839
- observer: this
1840
- }), t?.mutationKey && this.options.mutationKey && me(t.mutationKey) !== me(this.options.mutationKey) ? this.reset() : this.#s?.state.status === "pending" && this.#s.setOptions(this.options);
1841
- }
1842
- onUnsubscribe() {
1843
- this.hasListeners() || this.#s?.removeObserver(this);
1844
- }
1845
- onMutationUpdate(e) {
1846
- this.#n(), this.#i(e);
1847
- }
1848
- getCurrentResult() {
1849
- return this.#t;
1850
- }
1851
- reset() {
1852
- this.#s?.removeObserver(this), this.#s = void 0, this.#n(), this.#i();
1853
- }
1854
- mutate(e, t) {
1855
- return this.#r = t, this.#s?.removeObserver(this), this.#s = this.#e.getMutationCache().build(this.#e, this.options), this.#s.addObserver(this), this.#s.execute(e);
1856
- }
1857
- #n() {
1858
- const e = this.#s?.state ?? Os();
1859
- this.#t = {
1860
- ...e,
1861
- isPending: e.status === "pending",
1862
- isSuccess: e.status === "success",
1863
- isError: e.status === "error",
1864
- isIdle: e.status === "idle",
1865
- mutate: this.mutate,
1866
- reset: this.reset
1867
- };
1868
- }
1869
- #i(e) {
1870
- q.batch(() => {
1871
- if (this.#r && this.hasListeners()) {
1872
- const t = this.#t.variables, s = this.#t.context, r = {
1873
- client: this.#e,
1874
- meta: this.options.meta,
1875
- mutationKey: this.options.mutationKey
1876
- };
1877
- e?.type === "success" ? (this.#r.onSuccess?.(
1878
- e.data,
1879
- t,
1880
- s,
1881
- r
1882
- ), this.#r.onSettled?.(
1883
- e.data,
1884
- null,
1885
- t,
1886
- s,
1887
- r
1888
- )) : e?.type === "error" && (this.#r.onError?.(
1889
- e.error,
1890
- t,
1891
- s,
1892
- r
1893
- ), this.#r.onSettled?.(
1894
- void 0,
1895
- e.error,
1896
- t,
1897
- s,
1898
- r
1899
- ));
1900
- }
1901
- this.listeners.forEach((t) => {
1902
- t(this.#t);
1903
- });
1904
- });
1905
- }
1906
- }, Un = class extends je {
1907
- constructor(e = {}) {
1908
- super(), this.config = e, this.#e = /* @__PURE__ */ new Map();
1909
- }
1910
- #e;
1911
- build(e, t, s) {
1912
- const r = t.queryKey, a = t.queryHash ?? ft(r, t);
1913
- let o = this.get(a);
1914
- return o || (o = new Tn({
1915
- client: e,
1916
- queryKey: r,
1917
- queryHash: a,
1918
- options: e.defaultQueryOptions(t),
1919
- state: s,
1920
- defaultOptions: e.getQueryDefaults(r)
1921
- }), this.add(o)), o;
1922
- }
1923
- add(e) {
1924
- this.#e.has(e.queryHash) || (this.#e.set(e.queryHash, e), this.notify({
1925
- type: "added",
1926
- query: e
1927
- }));
1928
- }
1929
- remove(e) {
1930
- const t = this.#e.get(e.queryHash);
1931
- t && (e.destroy(), t === e && this.#e.delete(e.queryHash), this.notify({ type: "removed", query: e }));
1932
- }
1933
- clear() {
1934
- q.batch(() => {
1935
- this.getAll().forEach((e) => {
1936
- this.remove(e);
1937
- });
1938
- });
1939
- }
1940
- get(e) {
1941
- return this.#e.get(e);
1942
- }
1943
- getAll() {
1944
- return [...this.#e.values()];
1945
- }
1946
- find(e) {
1947
- const t = { exact: !0, ...e };
1948
- return this.getAll().find(
1949
- (s) => Dt(t, s)
1950
- );
1951
- }
1952
- findAll(e = {}) {
1953
- const t = this.getAll();
1954
- return Object.keys(e).length > 0 ? t.filter((s) => Dt(e, s)) : t;
1955
- }
1956
- notify(e) {
1957
- q.batch(() => {
1958
- this.listeners.forEach((t) => {
1959
- t(e);
1960
- });
1961
- });
1962
- }
1963
- onFocus() {
1964
- q.batch(() => {
1965
- this.getAll().forEach((e) => {
1966
- e.onFocus();
1967
- });
1968
- });
1969
- }
1970
- onOnline() {
1971
- q.batch(() => {
1972
- this.getAll().forEach((e) => {
1973
- e.onOnline();
1974
- });
1975
- });
1976
- }
1977
- }, Jn = class {
1978
- #e;
1979
- #t;
1980
- #s;
1981
- #r;
1982
- #n;
1983
- #i;
1984
- #o;
1985
- #a;
1986
- constructor(e = {}) {
1987
- this.#e = e.queryCache || new Un(), this.#t = e.mutationCache || new qn(), this.#s = e.defaultOptions || {}, this.#r = /* @__PURE__ */ new Map(), this.#n = /* @__PURE__ */ new Map(), this.#i = 0;
1988
- }
1989
- mount() {
1990
- this.#i++, this.#i === 1 && (this.#o = mt.subscribe(async (e) => {
1991
- e && (await this.resumePausedMutations(), this.#e.onFocus());
1992
- }), this.#a = Ie.subscribe(async (e) => {
1993
- e && (await this.resumePausedMutations(), this.#e.onOnline());
1994
- }));
1995
- }
1996
- unmount() {
1997
- this.#i--, this.#i === 0 && (this.#o?.(), this.#o = void 0, this.#a?.(), this.#a = void 0);
1998
- }
1999
- isFetching(e) {
2000
- return this.#e.findAll({ ...e, fetchStatus: "fetching" }).length;
2001
- }
2002
- isMutating(e) {
2003
- return this.#t.findAll({ ...e, status: "pending" }).length;
2004
- }
2005
- /**
2006
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
2007
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
2008
- *
2009
- * Hint: Do not use this function inside a component, because it won't receive updates.
2010
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
2011
- */
2012
- getQueryData(e) {
2013
- const t = this.defaultQueryOptions({ queryKey: e });
2014
- return this.#e.get(t.queryHash)?.state.data;
2015
- }
2016
- ensureQueryData(e) {
2017
- const t = this.defaultQueryOptions(e), s = this.#e.build(this, t), r = s.state.data;
2018
- return r === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && s.isStaleByTime(oe(t.staleTime, s)) && this.prefetchQuery(t), Promise.resolve(r));
2019
- }
2020
- getQueriesData(e) {
2021
- return this.#e.findAll(e).map(({ queryKey: t, state: s }) => {
2022
- const r = s.data;
2023
- return [t, r];
2024
- });
2025
- }
2026
- setQueryData(e, t, s) {
2027
- const r = this.defaultQueryOptions({ queryKey: e }), o = this.#e.get(
2028
- r.queryHash
2029
- )?.state.data, l = Cn(t, o);
2030
- if (l !== void 0)
2031
- return this.#e.build(this, r).setData(l, { ...s, manual: !0 });
2032
- }
2033
- setQueriesData(e, t, s) {
2034
- return q.batch(
2035
- () => this.#e.findAll(e).map(({ queryKey: r }) => [
2036
- r,
2037
- this.setQueryData(r, t, s)
2038
- ])
2039
- );
2040
- }
2041
- getQueryState(e) {
2042
- const t = this.defaultQueryOptions({ queryKey: e });
2043
- return this.#e.get(
2044
- t.queryHash
2045
- )?.state;
2046
- }
2047
- removeQueries(e) {
2048
- const t = this.#e;
2049
- q.batch(() => {
2050
- t.findAll(e).forEach((s) => {
2051
- t.remove(s);
2052
- });
2053
- });
2054
- }
2055
- resetQueries(e, t) {
2056
- const s = this.#e;
2057
- return q.batch(() => (s.findAll(e).forEach((r) => {
2058
- r.reset();
2059
- }), this.refetchQueries(
2060
- {
2061
- type: "active",
2062
- ...e
2063
- },
2064
- t
2065
- )));
2066
- }
2067
- cancelQueries(e, t = {}) {
2068
- const s = { revert: !0, ...t }, r = q.batch(
2069
- () => this.#e.findAll(e).map((a) => a.cancel(s))
2070
- );
2071
- return Promise.all(r).then(W).catch(W);
2072
- }
2073
- invalidateQueries(e, t = {}) {
2074
- return q.batch(() => (this.#e.findAll(e).forEach((s) => {
2075
- s.invalidate();
2076
- }), e?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
2077
- {
2078
- ...e,
2079
- type: e?.refetchType ?? e?.type ?? "active"
2080
- },
2081
- t
2082
- )));
2083
- }
2084
- refetchQueries(e, t = {}) {
2085
- const s = {
2086
- ...t,
2087
- cancelRefetch: t.cancelRefetch ?? !0
2088
- }, r = q.batch(
2089
- () => this.#e.findAll(e).filter((a) => !a.isDisabled() && !a.isStatic()).map((a) => {
2090
- let o = a.fetch(void 0, s);
2091
- return s.throwOnError || (o = o.catch(W)), a.state.fetchStatus === "paused" ? Promise.resolve() : o;
2092
- })
2093
- );
2094
- return Promise.all(r).then(W);
2095
- }
2096
- fetchQuery(e) {
2097
- const t = this.defaultQueryOptions(e);
2098
- t.retry === void 0 && (t.retry = !1);
2099
- const s = this.#e.build(this, t);
2100
- return s.isStaleByTime(
2101
- oe(t.staleTime, s)
2102
- ) ? s.fetch(t) : Promise.resolve(s.state.data);
2103
- }
2104
- prefetchQuery(e) {
2105
- return this.fetchQuery(e).then(W).catch(W);
2106
- }
2107
- fetchInfiniteQuery(e) {
2108
- return e.behavior = It(e.pages), this.fetchQuery(e);
2109
- }
2110
- prefetchInfiniteQuery(e) {
2111
- return this.fetchInfiniteQuery(e).then(W).catch(W);
2112
- }
2113
- ensureInfiniteQueryData(e) {
2114
- return e.behavior = It(e.pages), this.ensureQueryData(e);
2115
- }
2116
- resumePausedMutations() {
2117
- return Ie.isOnline() ? this.#t.resumePausedMutations() : Promise.resolve();
2118
- }
2119
- getQueryCache() {
2120
- return this.#e;
2121
- }
2122
- getMutationCache() {
2123
- return this.#t;
2124
- }
2125
- getDefaultOptions() {
2126
- return this.#s;
2127
- }
2128
- setDefaultOptions(e) {
2129
- this.#s = e;
2130
- }
2131
- setQueryDefaults(e, t) {
2132
- this.#r.set(me(e), {
2133
- queryKey: e,
2134
- defaultOptions: t
2135
- });
2136
- }
2137
- getQueryDefaults(e) {
2138
- const t = [...this.#r.values()], s = {};
2139
- return t.forEach((r) => {
2140
- Re(e, r.queryKey) && Object.assign(s, r.defaultOptions);
2141
- }), s;
2142
- }
2143
- setMutationDefaults(e, t) {
2144
- this.#n.set(me(e), {
2145
- mutationKey: e,
2146
- defaultOptions: t
2147
- });
2148
- }
2149
- getMutationDefaults(e) {
2150
- const t = [...this.#n.values()], s = {};
2151
- return t.forEach((r) => {
2152
- Re(e, r.mutationKey) && Object.assign(s, r.defaultOptions);
2153
- }), s;
2154
- }
2155
- defaultQueryOptions(e) {
2156
- if (e._defaulted)
2157
- return e;
2158
- const t = {
2159
- ...this.#s.queries,
2160
- ...this.getQueryDefaults(e.queryKey),
2161
- ...e,
2162
- _defaulted: !0
2163
- };
2164
- return t.queryHash || (t.queryHash = ft(
2165
- t.queryKey,
2166
- t
2167
- )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === Qe && (t.enabled = !1), t;
2168
- }
2169
- defaultMutationOptions(e) {
2170
- return e?._defaulted ? e : {
2171
- ...this.#s.mutations,
2172
- ...e?.mutationKey && this.getMutationDefaults(e.mutationKey),
2173
- ...e,
2174
- _defaulted: !0
2175
- };
2176
- }
2177
- clear() {
2178
- this.#e.clear(), this.#t.clear();
2179
- }
2180
- }, Rs = C.createContext(
2181
- void 0
2182
- ), ne = (e) => {
2183
- const t = C.useContext(Rs);
2184
- if (!t)
2185
- throw new Error("No QueryClient set, use QueryClientProvider to set one");
2186
- return t;
2187
- }, $n = ({
2188
- client: e,
2189
- children: t
2190
- }) => (C.useEffect(() => (e.mount(), () => {
2191
- e.unmount();
2192
- }), [e]), /* @__PURE__ */ n.jsx(Rs.Provider, { value: e, children: t })), ks = C.createContext(!1), Hn = () => C.useContext(ks);
2193
- ks.Provider;
2194
- function Wn() {
2195
- let e = !1;
2196
- return {
2197
- clearReset: () => {
2198
- e = !1;
2199
- },
2200
- reset: () => {
2201
- e = !0;
2202
- },
2203
- isReset: () => e
2204
- };
2205
- }
2206
- var zn = C.createContext(Wn()), Kn = () => C.useContext(zn), Vn = (e, t) => {
2207
- (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1));
2208
- }, Bn = (e) => {
2209
- C.useEffect(() => {
2210
- e.clearReset();
2211
- }, [e]);
2212
- }, Yn = ({
2213
- result: e,
2214
- errorResetBoundary: t,
2215
- throwOnError: s,
2216
- query: r,
2217
- suspense: a
2218
- }) => e.isError && !t.isReset() && !e.isFetching && r && (a && e.data === void 0 || ws(s, [e.error, r])), Zn = (e) => {
2219
- if (e.suspense) {
2220
- const s = (a) => a === "static" ? a : Math.max(a ?? 1e3, 1e3), r = e.staleTime;
2221
- e.staleTime = typeof r == "function" ? (...a) => s(r(...a)) : s(r), typeof e.gcTime == "number" && (e.gcTime = Math.max(
2222
- e.gcTime,
2223
- 1e3
2224
- ));
2225
- }
2226
- }, Xn = (e, t) => e.isLoading && e.isFetching && !t, Gn = (e, t) => e?.suspense && t.isPending, Lt = (e, t, s) => t.fetchOptimistic(e).catch(() => {
2227
- s.clearReset();
2228
- });
2229
- function er(e, t, s) {
2230
- if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
2231
- throw new Error(
2232
- 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
2233
- );
2234
- const r = Hn(), a = Kn(), o = ne(), l = o.defaultQueryOptions(e);
2235
- o.getDefaultOptions().queries?._experimental_beforeQuery?.(
2236
- l
2237
- ), process.env.NODE_ENV !== "production" && (l.queryFn || console.error(
2238
- `[${l.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
2239
- )), l._optimisticResults = r ? "isRestoring" : "optimistic", Zn(l), Vn(l, a), Bn(a);
2240
- const i = !o.getQueryCache().get(l.queryHash), [c] = C.useState(
2241
- () => new t(
2242
- o,
2243
- l
2244
- )
2245
- ), h = c.getOptimisticResult(l), d = !r && e.subscribed !== !1;
2246
- if (C.useSyncExternalStore(
2247
- C.useCallback(
2248
- (y) => {
2249
- const f = d ? c.subscribe(q.batchCalls(y)) : W;
2250
- return c.updateResult(), f;
2251
- },
2252
- [c, d]
2253
- ),
2254
- () => c.getCurrentResult(),
2255
- () => c.getCurrentResult()
2256
- ), C.useEffect(() => {
2257
- c.setOptions(l);
2258
- }, [l, c]), Gn(l, h))
2259
- throw Lt(l, c, a);
2260
- if (Yn({
2261
- result: h,
2262
- errorResetBoundary: a,
2263
- throwOnError: l.throwOnError,
2264
- query: o.getQueryCache().get(l.queryHash),
2265
- suspense: l.suspense
2266
- }))
2267
- throw h.error;
2268
- return o.getDefaultOptions().queries?._experimental_afterQuery?.(
2269
- l,
2270
- h
2271
- ), l.experimental_prefetchInRender && !fe && Xn(h, r) && (i ? (
2272
- // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
2273
- Lt(l, c, a)
2274
- ) : (
2275
- // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
2276
- o.getQueryCache().get(l.queryHash)?.promise
2277
- ))?.catch(W).finally(() => {
2278
- c.updateResult();
2279
- }), l.notifyOnChangeProps ? h : c.trackResult(h);
2280
- }
2281
- function Ds(e, t) {
2282
- return er(e, An);
2283
- }
2284
- function we(e, t) {
2285
- const s = ne(), [r] = C.useState(
2286
- () => new Ln(
2287
- s,
2288
- e
2289
- )
2290
- );
2291
- C.useEffect(() => {
2292
- r.setOptions(e);
2293
- }, [r, e]);
2294
- const a = C.useSyncExternalStore(
2295
- C.useCallback(
2296
- (l) => r.subscribe(q.batchCalls(l)),
2297
- [r]
2298
- ),
2299
- () => r.getCurrentResult(),
2300
- () => r.getCurrentResult()
2301
- ), o = C.useCallback(
2302
- (l, i) => {
2303
- r.mutate(l, i).catch(W);
2304
- },
2305
- [r]
2306
- );
2307
- if (a.error && ws(r.options.throwOnError, [a.error]))
2308
- throw a.error;
2309
- return { ...a, mutate: o, mutateAsync: a.mutate };
2310
- }
2311
- const tr = new Jn({
2312
- defaultOptions: {
2313
- queries: {
2314
- staleTime: 5e3,
2315
- refetchOnWindowFocus: !1,
2316
- retry: 1
2317
- }
2318
- }
2319
- }), sr = ({ children: e }) => /* @__PURE__ */ n.jsx($n, { client: tr, children: e });
2320
- function U(e) {
2321
- const t = Object.prototype.toString.call(e);
2322
- return e instanceof Date || typeof e == "object" && t === "[object Date]" ? new e.constructor(+e) : typeof e == "number" || t === "[object Number]" || typeof e == "string" || t === "[object String]" ? new Date(e) : /* @__PURE__ */ new Date(NaN);
2323
- }
2324
- function nr(e, t) {
2325
- return e instanceof Date ? new e.constructor(t) : new Date(t);
2326
- }
2327
- const Me = 43200, Ut = 1440;
2328
- let rr = {};
2329
- function ar() {
2330
- return rr;
2331
- }
2332
- function Jt(e) {
2333
- const t = U(e), s = new Date(
2334
- Date.UTC(
2335
- t.getFullYear(),
2336
- t.getMonth(),
2337
- t.getDate(),
2338
- t.getHours(),
2339
- t.getMinutes(),
2340
- t.getSeconds(),
2341
- t.getMilliseconds()
2342
- )
2343
- );
2344
- return s.setUTCFullYear(t.getFullYear()), +e - +s;
2345
- }
2346
- function Ae(e, t) {
2347
- const s = U(e), r = U(t), a = s.getTime() - r.getTime();
2348
- return a < 0 ? -1 : a > 0 ? 1 : a;
2349
- }
2350
- function ir(e) {
2351
- return nr(e, Date.now());
2352
- }
2353
- function or(e, t) {
2354
- const s = U(e), r = U(t), a = s.getFullYear() - r.getFullYear(), o = s.getMonth() - r.getMonth();
2355
- return a * 12 + o;
2356
- }
2357
- function lr(e) {
2358
- return (t) => {
2359
- const r = (e ? Math[e] : Math.trunc)(t);
2360
- return r === 0 ? 0 : r;
2361
- };
2362
- }
2363
- function cr(e, t) {
2364
- return +U(e) - +U(t);
2365
- }
2366
- function ur(e) {
2367
- const t = U(e);
2368
- return t.setHours(23, 59, 59, 999), t;
2369
- }
2370
- function dr(e) {
2371
- const t = U(e), s = t.getMonth();
2372
- return t.setFullYear(t.getFullYear(), s + 1, 0), t.setHours(23, 59, 59, 999), t;
2373
- }
2374
- function hr(e) {
2375
- const t = U(e);
2376
- return +ur(t) == +dr(t);
2377
- }
2378
- function fr(e, t) {
2379
- const s = U(e), r = U(t), a = Ae(s, r), o = Math.abs(
2380
- or(s, r)
2381
- );
2382
- let l;
2383
- if (o < 1)
2384
- l = 0;
2385
- else {
2386
- s.getMonth() === 1 && s.getDate() > 27 && s.setDate(30), s.setMonth(s.getMonth() - a * o);
2387
- let i = Ae(s, r) === -a;
2388
- hr(U(e)) && o === 1 && Ae(e, r) === 1 && (i = !1), l = a * (o - Number(i));
2389
- }
2390
- return l === 0 ? 0 : l;
2391
- }
2392
- function mr(e, t, s) {
2393
- const r = cr(e, t) / 1e3;
2394
- return lr(s?.roundingMethod)(r);
2395
- }
2396
- const pr = {
2397
- lessThanXSeconds: {
2398
- one: "less than a second",
2399
- other: "less than {{count}} seconds"
2400
- },
2401
- xSeconds: {
2402
- one: "1 second",
2403
- other: "{{count}} seconds"
2404
- },
2405
- halfAMinute: "half a minute",
2406
- lessThanXMinutes: {
2407
- one: "less than a minute",
2408
- other: "less than {{count}} minutes"
2409
- },
2410
- xMinutes: {
2411
- one: "1 minute",
2412
- other: "{{count}} minutes"
2413
- },
2414
- aboutXHours: {
2415
- one: "about 1 hour",
2416
- other: "about {{count}} hours"
2417
- },
2418
- xHours: {
2419
- one: "1 hour",
2420
- other: "{{count}} hours"
2421
- },
2422
- xDays: {
2423
- one: "1 day",
2424
- other: "{{count}} days"
2425
- },
2426
- aboutXWeeks: {
2427
- one: "about 1 week",
2428
- other: "about {{count}} weeks"
2429
- },
2430
- xWeeks: {
2431
- one: "1 week",
2432
- other: "{{count}} weeks"
2433
- },
2434
- aboutXMonths: {
2435
- one: "about 1 month",
2436
- other: "about {{count}} months"
2437
- },
2438
- xMonths: {
2439
- one: "1 month",
2440
- other: "{{count}} months"
2441
- },
2442
- aboutXYears: {
2443
- one: "about 1 year",
2444
- other: "about {{count}} years"
2445
- },
2446
- xYears: {
2447
- one: "1 year",
2448
- other: "{{count}} years"
2449
- },
2450
- overXYears: {
2451
- one: "over 1 year",
2452
- other: "over {{count}} years"
2453
- },
2454
- almostXYears: {
2455
- one: "almost 1 year",
2456
- other: "almost {{count}} years"
2457
- }
2458
- }, yr = (e, t, s) => {
2459
- let r;
2460
- const a = pr[e];
2461
- return typeof a == "string" ? r = a : t === 1 ? r = a.one : r = a.other.replace("{{count}}", t.toString()), s?.addSuffix ? s.comparison && s.comparison > 0 ? "in " + r : r + " ago" : r;
2462
- };
2463
- function ze(e) {
2464
- return (t = {}) => {
2465
- const s = t.width ? String(t.width) : e.defaultWidth;
2466
- return e.formats[s] || e.formats[e.defaultWidth];
2467
- };
2468
- }
2469
- const gr = {
2470
- full: "EEEE, MMMM do, y",
2471
- long: "MMMM do, y",
2472
- medium: "MMM d, y",
2473
- short: "MM/dd/yyyy"
2474
- }, vr = {
2475
- full: "h:mm:ss a zzzz",
2476
- long: "h:mm:ss a z",
2477
- medium: "h:mm:ss a",
2478
- short: "h:mm a"
2479
- }, br = {
2480
- full: "{{date}} 'at' {{time}}",
2481
- long: "{{date}} 'at' {{time}}",
2482
- medium: "{{date}}, {{time}}",
2483
- short: "{{date}}, {{time}}"
2484
- }, xr = {
2485
- date: ze({
2486
- formats: gr,
2487
- defaultWidth: "full"
2488
- }),
2489
- time: ze({
2490
- formats: vr,
2491
- defaultWidth: "full"
2492
- }),
2493
- dateTime: ze({
2494
- formats: br,
2495
- defaultWidth: "full"
2496
- })
2497
- }, jr = {
2498
- lastWeek: "'last' eeee 'at' p",
2499
- yesterday: "'yesterday at' p",
2500
- today: "'today at' p",
2501
- tomorrow: "'tomorrow at' p",
2502
- nextWeek: "eeee 'at' p",
2503
- other: "P"
2504
- }, wr = (e, t, s, r) => jr[e];
2505
- function Ne(e) {
2506
- return (t, s) => {
2507
- const r = s?.context ? String(s.context) : "standalone";
2508
- let a;
2509
- if (r === "formatting" && e.formattingValues) {
2510
- const l = e.defaultFormattingWidth || e.defaultWidth, i = s?.width ? String(s.width) : l;
2511
- a = e.formattingValues[i] || e.formattingValues[l];
2512
- } else {
2513
- const l = e.defaultWidth, i = s?.width ? String(s.width) : e.defaultWidth;
2514
- a = e.values[i] || e.values[l];
2515
- }
2516
- const o = e.argumentCallback ? e.argumentCallback(t) : t;
2517
- return a[o];
2518
- };
2519
- }
2520
- const Cr = {
2521
- narrow: ["B", "A"],
2522
- abbreviated: ["BC", "AD"],
2523
- wide: ["Before Christ", "Anno Domini"]
2524
- }, Sr = {
2525
- narrow: ["1", "2", "3", "4"],
2526
- abbreviated: ["Q1", "Q2", "Q3", "Q4"],
2527
- wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
2528
- }, Nr = {
2529
- narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
2530
- abbreviated: [
2531
- "Jan",
2532
- "Feb",
2533
- "Mar",
2534
- "Apr",
2535
- "May",
2536
- "Jun",
2537
- "Jul",
2538
- "Aug",
2539
- "Sep",
2540
- "Oct",
2541
- "Nov",
2542
- "Dec"
2543
- ],
2544
- wide: [
2545
- "January",
2546
- "February",
2547
- "March",
2548
- "April",
2549
- "May",
2550
- "June",
2551
- "July",
2552
- "August",
2553
- "September",
2554
- "October",
2555
- "November",
2556
- "December"
2557
- ]
2558
- }, Er = {
2559
- narrow: ["S", "M", "T", "W", "T", "F", "S"],
2560
- short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
2561
- abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
2562
- wide: [
2563
- "Sunday",
2564
- "Monday",
2565
- "Tuesday",
2566
- "Wednesday",
2567
- "Thursday",
2568
- "Friday",
2569
- "Saturday"
2570
- ]
2571
- }, Or = {
2572
- narrow: {
2573
- am: "a",
2574
- pm: "p",
2575
- midnight: "mi",
2576
- noon: "n",
2577
- morning: "morning",
2578
- afternoon: "afternoon",
2579
- evening: "evening",
2580
- night: "night"
2581
- },
2582
- abbreviated: {
2583
- am: "AM",
2584
- pm: "PM",
2585
- midnight: "midnight",
2586
- noon: "noon",
2587
- morning: "morning",
2588
- afternoon: "afternoon",
2589
- evening: "evening",
2590
- night: "night"
2591
- },
2592
- wide: {
2593
- am: "a.m.",
2594
- pm: "p.m.",
2595
- midnight: "midnight",
2596
- noon: "noon",
2597
- morning: "morning",
2598
- afternoon: "afternoon",
2599
- evening: "evening",
2600
- night: "night"
2601
- }
2602
- }, Rr = {
2603
- narrow: {
2604
- am: "a",
2605
- pm: "p",
2606
- midnight: "mi",
2607
- noon: "n",
2608
- morning: "in the morning",
2609
- afternoon: "in the afternoon",
2610
- evening: "in the evening",
2611
- night: "at night"
2612
- },
2613
- abbreviated: {
2614
- am: "AM",
2615
- pm: "PM",
2616
- midnight: "midnight",
2617
- noon: "noon",
2618
- morning: "in the morning",
2619
- afternoon: "in the afternoon",
2620
- evening: "in the evening",
2621
- night: "at night"
2622
- },
2623
- wide: {
2624
- am: "a.m.",
2625
- pm: "p.m.",
2626
- midnight: "midnight",
2627
- noon: "noon",
2628
- morning: "in the morning",
2629
- afternoon: "in the afternoon",
2630
- evening: "in the evening",
2631
- night: "at night"
2632
- }
2633
- }, kr = (e, t) => {
2634
- const s = Number(e), r = s % 100;
2635
- if (r > 20 || r < 10)
2636
- switch (r % 10) {
2637
- case 1:
2638
- return s + "st";
2639
- case 2:
2640
- return s + "nd";
2641
- case 3:
2642
- return s + "rd";
2643
- }
2644
- return s + "th";
2645
- }, Dr = {
2646
- ordinalNumber: kr,
2647
- era: Ne({
2648
- values: Cr,
2649
- defaultWidth: "wide"
2650
- }),
2651
- quarter: Ne({
2652
- values: Sr,
2653
- defaultWidth: "wide",
2654
- argumentCallback: (e) => e - 1
2655
- }),
2656
- month: Ne({
2657
- values: Nr,
2658
- defaultWidth: "wide"
2659
- }),
2660
- day: Ne({
2661
- values: Er,
2662
- defaultWidth: "wide"
2663
- }),
2664
- dayPeriod: Ne({
2665
- values: Or,
2666
- defaultWidth: "wide",
2667
- formattingValues: Rr,
2668
- defaultFormattingWidth: "wide"
2669
- })
2670
- };
2671
- function Ee(e) {
2672
- return (t, s = {}) => {
2673
- const r = s.width, a = r && e.matchPatterns[r] || e.matchPatterns[e.defaultMatchWidth], o = t.match(a);
2674
- if (!o)
2675
- return null;
2676
- const l = o[0], i = r && e.parsePatterns[r] || e.parsePatterns[e.defaultParseWidth], c = Array.isArray(i) ? Mr(i, (y) => y.test(l)) : (
2677
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
2678
- Pr(i, (y) => y.test(l))
2679
- );
2680
- let h;
2681
- h = e.valueCallback ? e.valueCallback(c) : c, h = s.valueCallback ? (
2682
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
2683
- s.valueCallback(h)
2684
- ) : h;
2685
- const d = t.slice(l.length);
2686
- return { value: h, rest: d };
2687
- };
2688
- }
2689
- function Pr(e, t) {
2690
- for (const s in e)
2691
- if (Object.prototype.hasOwnProperty.call(e, s) && t(e[s]))
2692
- return s;
2693
- }
2694
- function Mr(e, t) {
2695
- for (let s = 0; s < e.length; s++)
2696
- if (t(e[s]))
2697
- return s;
2698
- }
2699
- function Tr(e) {
2700
- return (t, s = {}) => {
2701
- const r = t.match(e.matchPattern);
2702
- if (!r) return null;
2703
- const a = r[0], o = t.match(e.parsePattern);
2704
- if (!o) return null;
2705
- let l = e.valueCallback ? e.valueCallback(o[0]) : o[0];
2706
- l = s.valueCallback ? s.valueCallback(l) : l;
2707
- const i = t.slice(a.length);
2708
- return { value: l, rest: i };
2709
- };
2710
- }
2711
- const Ar = /^(\d+)(th|st|nd|rd)?/i, Fr = /\d+/i, _r = {
2712
- narrow: /^(b|a)/i,
2713
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
2714
- wide: /^(before christ|before common era|anno domini|common era)/i
2715
- }, Qr = {
2716
- any: [/^b/i, /^(a|c)/i]
2717
- }, Ir = {
2718
- narrow: /^[1234]/i,
2719
- abbreviated: /^q[1234]/i,
2720
- wide: /^[1234](th|st|nd|rd)? quarter/i
2721
- }, qr = {
2722
- any: [/1/i, /2/i, /3/i, /4/i]
2723
- }, Lr = {
2724
- narrow: /^[jfmasond]/i,
2725
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
2726
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
2727
- }, Ur = {
2728
- narrow: [
2729
- /^j/i,
2730
- /^f/i,
2731
- /^m/i,
2732
- /^a/i,
2733
- /^m/i,
2734
- /^j/i,
2735
- /^j/i,
2736
- /^a/i,
2737
- /^s/i,
2738
- /^o/i,
2739
- /^n/i,
2740
- /^d/i
2741
- ],
2742
- any: [
2743
- /^ja/i,
2744
- /^f/i,
2745
- /^mar/i,
2746
- /^ap/i,
2747
- /^may/i,
2748
- /^jun/i,
2749
- /^jul/i,
2750
- /^au/i,
2751
- /^s/i,
2752
- /^o/i,
2753
- /^n/i,
2754
- /^d/i
2755
- ]
2756
- }, Jr = {
2757
- narrow: /^[smtwf]/i,
2758
- short: /^(su|mo|tu|we|th|fr|sa)/i,
2759
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2760
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2761
- }, $r = {
2762
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2763
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2764
- }, Hr = {
2765
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2766
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
2767
- }, Wr = {
2768
- any: {
2769
- am: /^a/i,
2770
- pm: /^p/i,
2771
- midnight: /^mi/i,
2772
- noon: /^no/i,
2773
- morning: /morning/i,
2774
- afternoon: /afternoon/i,
2775
- evening: /evening/i,
2776
- night: /night/i
2777
- }
2778
- }, zr = {
2779
- ordinalNumber: Tr({
2780
- matchPattern: Ar,
2781
- parsePattern: Fr,
2782
- valueCallback: (e) => parseInt(e, 10)
2783
- }),
2784
- era: Ee({
2785
- matchPatterns: _r,
2786
- defaultMatchWidth: "wide",
2787
- parsePatterns: Qr,
2788
- defaultParseWidth: "any"
2789
- }),
2790
- quarter: Ee({
2791
- matchPatterns: Ir,
2792
- defaultMatchWidth: "wide",
2793
- parsePatterns: qr,
2794
- defaultParseWidth: "any",
2795
- valueCallback: (e) => e + 1
2796
- }),
2797
- month: Ee({
2798
- matchPatterns: Lr,
2799
- defaultMatchWidth: "wide",
2800
- parsePatterns: Ur,
2801
- defaultParseWidth: "any"
2802
- }),
2803
- day: Ee({
2804
- matchPatterns: Jr,
2805
- defaultMatchWidth: "wide",
2806
- parsePatterns: $r,
2807
- defaultParseWidth: "any"
2808
- }),
2809
- dayPeriod: Ee({
2810
- matchPatterns: Hr,
2811
- defaultMatchWidth: "any",
2812
- parsePatterns: Wr,
2813
- defaultParseWidth: "any"
2814
- })
2815
- }, Kr = {
2816
- code: "en-US",
2817
- formatDistance: yr,
2818
- formatLong: xr,
2819
- formatRelative: wr,
2820
- localize: Dr,
2821
- match: zr,
2822
- options: {
2823
- weekStartsOn: 0,
2824
- firstWeekContainsDate: 1
2825
- }
2826
- };
2827
- function Vr(e, t, s) {
2828
- const r = ar(), a = s?.locale ?? r.locale ?? Kr, o = 2520, l = Ae(e, t);
2829
- if (isNaN(l))
2830
- throw new RangeError("Invalid time value");
2831
- const i = Object.assign({}, s, {
2832
- addSuffix: s?.addSuffix,
2833
- comparison: l
2834
- });
2835
- let c, h;
2836
- l > 0 ? (c = U(t), h = U(e)) : (c = U(e), h = U(t));
2837
- const d = mr(h, c), y = (Jt(h) - Jt(c)) / 1e3, f = Math.round((d - y) / 60);
2838
- let p;
2839
- if (f < 2)
2840
- return s?.includeSeconds ? d < 5 ? a.formatDistance("lessThanXSeconds", 5, i) : d < 10 ? a.formatDistance("lessThanXSeconds", 10, i) : d < 20 ? a.formatDistance("lessThanXSeconds", 20, i) : d < 40 ? a.formatDistance("halfAMinute", 0, i) : d < 60 ? a.formatDistance("lessThanXMinutes", 1, i) : a.formatDistance("xMinutes", 1, i) : f === 0 ? a.formatDistance("lessThanXMinutes", 1, i) : a.formatDistance("xMinutes", f, i);
2841
- if (f < 45)
2842
- return a.formatDistance("xMinutes", f, i);
2843
- if (f < 90)
2844
- return a.formatDistance("aboutXHours", 1, i);
2845
- if (f < Ut) {
2846
- const m = Math.round(f / 60);
2847
- return a.formatDistance("aboutXHours", m, i);
2848
- } else {
2849
- if (f < o)
2850
- return a.formatDistance("xDays", 1, i);
2851
- if (f < Me) {
2852
- const m = Math.round(f / Ut);
2853
- return a.formatDistance("xDays", m, i);
2854
- } else if (f < Me * 2)
2855
- return p = Math.round(f / Me), a.formatDistance("aboutXMonths", p, i);
2856
- }
2857
- if (p = fr(h, c), p < 12) {
2858
- const m = Math.round(f / Me);
2859
- return a.formatDistance("xMonths", m, i);
2860
- } else {
2861
- const m = p % 12, g = Math.trunc(p / 12);
2862
- return m < 3 ? a.formatDistance("aboutXYears", g, i) : m < 9 ? a.formatDistance("overXYears", g, i) : a.formatDistance("almostXYears", g + 1, i);
2863
- }
2864
- }
2865
- function qe(e, t) {
2866
- return Vr(e, ir(e), t);
2867
- }
2868
- /**
2869
- * @license lucide-react v0.545.0 - ISC
2870
- *
2871
- * This source code is licensed under the ISC license.
2872
- * See the LICENSE file in the root directory of this source tree.
2873
- */
2874
- const Br = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Yr = (e) => e.replace(
2875
- /^([A-Z])|[\s-_]+(\w)/g,
2876
- (t, s, r) => r ? r.toUpperCase() : s.toLowerCase()
2877
- ), $t = (e) => {
2878
- const t = Yr(e);
2879
- return t.charAt(0).toUpperCase() + t.slice(1);
2880
- }, Ps = (...e) => e.filter((t, s, r) => !!t && t.trim() !== "" && r.indexOf(t) === s).join(" ").trim(), Zr = (e) => {
2881
- for (const t in e)
2882
- if (t.startsWith("aria-") || t === "role" || t === "title")
2883
- return !0;
2884
- };
2885
- /**
2886
- * @license lucide-react v0.545.0 - ISC
2887
- *
2888
- * This source code is licensed under the ISC license.
2889
- * See the LICENSE file in the root directory of this source tree.
2890
- */
2891
- var Xr = {
2892
- xmlns: "http://www.w3.org/2000/svg",
2893
- width: 24,
2894
- height: 24,
2895
- viewBox: "0 0 24 24",
2896
- fill: "none",
2897
- stroke: "currentColor",
2898
- strokeWidth: 2,
2899
- strokeLinecap: "round",
2900
- strokeLinejoin: "round"
2901
- };
2902
- /**
2903
- * @license lucide-react v0.545.0 - ISC
2904
- *
2905
- * This source code is licensed under the ISC license.
2906
- * See the LICENSE file in the root directory of this source tree.
2907
- */
2908
- const Gr = us(
2909
- ({
2910
- color: e = "currentColor",
2911
- size: t = 24,
2912
- strokeWidth: s = 2,
2913
- absoluteStrokeWidth: r,
2914
- className: a = "",
2915
- children: o,
2916
- iconNode: l,
2917
- ...i
2918
- }, c) => Ke(
2919
- "svg",
2920
- {
2921
- ref: c,
2922
- ...Xr,
2923
- width: t,
2924
- height: t,
2925
- stroke: e,
2926
- strokeWidth: r ? Number(s) * 24 / Number(t) : s,
2927
- className: Ps("lucide", a),
2928
- ...!o && !Zr(i) && { "aria-hidden": "true" },
2929
- ...i
2930
- },
2931
- [
2932
- ...l.map(([h, d]) => Ke(h, d)),
2933
- ...Array.isArray(o) ? o : [o]
2934
- ]
2935
- )
2936
- );
2937
- /**
2938
- * @license lucide-react v0.545.0 - ISC
2939
- *
2940
- * This source code is licensed under the ISC license.
2941
- * See the LICENSE file in the root directory of this source tree.
2942
- */
2943
- const se = (e, t) => {
2944
- const s = us(
2945
- ({ className: r, ...a }, o) => Ke(Gr, {
2946
- ref: o,
2947
- iconNode: t,
2948
- className: Ps(
2949
- `lucide-${Br($t(e))}`,
2950
- `lucide-${e}`,
2951
- r
2952
- ),
2953
- ...a
2954
- })
2955
- );
2956
- return s.displayName = $t(e), s;
2957
- };
2958
- /**
2959
- * @license lucide-react v0.545.0 - ISC
2960
- *
2961
- * This source code is licensed under the ISC license.
2962
- * See the LICENSE file in the root directory of this source tree.
2963
- */
2964
- const ea = [
2965
- ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
2966
- ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
2967
- ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
2968
- ["path", { d: "M8 16H3v5", key: "1cv678" }]
2969
- ], he = se("refresh-cw", ea);
2970
- /**
2971
- * @license lucide-react v0.545.0 - ISC
2972
- *
2973
- * This source code is licensed under the ISC license.
2974
- * See the LICENSE file in the root directory of this source tree.
2975
- */
2976
- const ta = [
2977
- ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
2978
- ["path", { d: "M3 6h18", key: "d0wm0j" }],
2979
- ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
2980
- ], be = se("trash", ta);
2981
- /**
2982
- * @license lucide-react v0.545.0 - ISC
2983
- *
2984
- * This source code is licensed under the ISC license.
2985
- * See the LICENSE file in the root directory of this source tree.
2986
- */
2987
- const sa = [
2988
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
2989
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
2990
- ], yt = se("x", sa);
2991
- function na(e, t, s, r) {
2992
- function a(o) {
2993
- return o instanceof s ? o : new s(function(l) {
2994
- l(o);
2995
- });
2996
- }
2997
- return new (s || (s = Promise))(function(o, l) {
2998
- function i(d) {
2999
- try {
3000
- h(r.next(d));
3001
- } catch (y) {
3002
- l(y);
3003
- }
3004
- }
3005
- function c(d) {
3006
- try {
3007
- h(r.throw(d));
3008
- } catch (y) {
3009
- l(y);
3010
- }
3011
- }
3012
- function h(d) {
3013
- d.done ? o(d.value) : a(d.value).then(i, c);
3014
- }
3015
- h((r = r.apply(e, [])).next());
3016
- });
3017
- }
3018
- var ra = function() {
3019
- var e = document.getSelection();
3020
- if (!e.rangeCount)
3021
- return function() {
3022
- };
3023
- for (var t = document.activeElement, s = [], r = 0; r < e.rangeCount; r++)
3024
- s.push(e.getRangeAt(r));
3025
- switch (t.tagName.toUpperCase()) {
3026
- // .toUpperCase handles XHTML
3027
- case "INPUT":
3028
- case "TEXTAREA":
3029
- t.blur();
3030
- break;
3031
- default:
3032
- t = null;
3033
- break;
3034
- }
3035
- return e.removeAllRanges(), function() {
3036
- e.type === "Caret" && e.removeAllRanges(), e.rangeCount || s.forEach(function(a) {
3037
- e.addRange(a);
3038
- }), t && t.focus();
3039
- };
3040
- }, aa = ra, Ht = {
3041
- "text/plain": "Text",
3042
- "text/html": "Url",
3043
- default: "Text"
3044
- }, ia = "Copy to clipboard: #{key}, Enter";
3045
- function oa(e) {
3046
- var t = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
3047
- return e.replace(/#{\s*key\s*}/g, t);
3048
- }
3049
- function la(e, t) {
3050
- var s, r, a, o, l, i, c = !1;
3051
- t || (t = {}), s = t.debug || !1;
3052
- try {
3053
- a = aa(), o = document.createRange(), l = document.getSelection(), i = document.createElement("span"), i.textContent = e, i.ariaHidden = "true", i.style.all = "unset", i.style.position = "fixed", i.style.top = 0, i.style.clip = "rect(0, 0, 0, 0)", i.style.whiteSpace = "pre", i.style.webkitUserSelect = "text", i.style.MozUserSelect = "text", i.style.msUserSelect = "text", i.style.userSelect = "text", i.addEventListener("copy", function(d) {
3054
- if (d.stopPropagation(), t.format)
3055
- if (d.preventDefault(), typeof d.clipboardData > "u") {
3056
- s && console.warn("unable to use e.clipboardData"), s && console.warn("trying IE specific stuff"), window.clipboardData.clearData();
3057
- var y = Ht[t.format] || Ht.default;
3058
- window.clipboardData.setData(y, e);
3059
- } else
3060
- d.clipboardData.clearData(), d.clipboardData.setData(t.format, e);
3061
- t.onCopy && (d.preventDefault(), t.onCopy(d.clipboardData));
3062
- }), document.body.appendChild(i), o.selectNodeContents(i), l.addRange(o);
3063
- var h = document.execCommand("copy");
3064
- if (!h)
3065
- throw new Error("copy command was unsuccessful");
3066
- c = !0;
3067
- } catch (d) {
3068
- s && console.error("unable to copy using execCommand: ", d), s && console.warn("trying IE specific stuff");
3069
- try {
3070
- window.clipboardData.setData(t.format || "text", e), t.onCopy && t.onCopy(window.clipboardData), c = !0;
3071
- } catch (y) {
3072
- s && console.error("unable to copy using clipboardData: ", y), s && console.error("falling back to prompt"), r = oa("message" in t ? t.message : ia), window.prompt(r, e);
3073
- }
3074
- } finally {
3075
- l && (typeof l.removeRange == "function" ? l.removeRange(o) : l.removeAllRanges()), i && document.body.removeChild(i), a();
3076
- }
3077
- return c;
3078
- }
3079
- var ca = la;
3080
- function le(e) {
3081
- return Object.prototype.toString.call(e) === "[object Object]";
3082
- }
3083
- function Oe(e) {
3084
- return Array.isArray(e) ? e.length : le(e) ? Object.keys(e).length : 0;
3085
- }
3086
- function ua(e, t) {
3087
- if (typeof e == "string")
3088
- return e;
3089
- try {
3090
- return JSON.stringify(e, (s, r) => {
3091
- switch (typeof r) {
3092
- case "bigint":
3093
- return String(r) + "n";
3094
- case "number":
3095
- case "boolean":
3096
- case "object":
3097
- case "string":
3098
- return r;
3099
- default:
3100
- return String(r);
3101
- }
3102
- }, t);
3103
- } catch (s) {
3104
- return `${s.name}: ${s.message}` || "JSON.stringify failed";
3105
- }
3106
- }
3107
- function da(e) {
3108
- return na(this, void 0, void 0, function* () {
3109
- try {
3110
- yield navigator.clipboard.writeText(e);
3111
- } catch {
3112
- ca(e);
3113
- }
3114
- });
3115
- }
3116
- function Wt(e, t, s, r, a, o) {
3117
- if (o && o.collapsed !== void 0)
3118
- return !!o.collapsed;
3119
- if (typeof r == "boolean")
3120
- return r;
3121
- if (typeof r == "number" && t > r)
3122
- return !0;
3123
- const l = Oe(e);
3124
- if (typeof r == "function") {
3125
- const i = gt(r, [{ node: e, depth: t, indexOrName: s, size: l }]);
3126
- if (typeof i == "boolean")
3127
- return i;
3128
- }
3129
- return !!(Array.isArray(e) && l > a || le(e) && l > a);
3130
- }
3131
- function zt(e, t, s, r, a, o) {
3132
- if (o && o.collapsed !== void 0)
3133
- return !!o.collapsed;
3134
- if (typeof r == "boolean")
3135
- return r;
3136
- if (typeof r == "number" && t > r)
3137
- return !0;
3138
- const l = Math.ceil(e.length / 100);
3139
- if (typeof r == "function") {
3140
- const i = gt(r, [{ node: e, depth: t, indexOrName: s, size: l }]);
3141
- if (typeof i == "boolean")
3142
- return i;
3143
- }
3144
- return !!(Array.isArray(e) && l > a || le(e) && l > a);
3145
- }
3146
- function xe(e, t, s) {
3147
- return typeof e == "boolean" ? e : !!(typeof e == "number" && t > e || e === "collapsed" && s || e === "expanded" && !s);
3148
- }
3149
- function gt(e, t) {
3150
- try {
3151
- return e(...t);
3152
- } catch (s) {
3153
- reportError(s);
3154
- }
3155
- }
3156
- function Ms(e) {
3157
- if (e === !0 || le(e) && e.add === !0)
3158
- return !0;
3159
- }
3160
- function Kt(e) {
3161
- if (e === !0 || le(e) && e.edit === !0)
3162
- return !0;
3163
- }
3164
- function vt(e) {
3165
- if (e === !0 || le(e) && e.delete === !0)
3166
- return !0;
3167
- }
3168
- function ha(e) {
3169
- return typeof e == "function";
3170
- }
3171
- function Ts(e) {
3172
- return !e || e.add === void 0 || !!e.add;
3173
- }
3174
- function Vt(e) {
3175
- return !e || e.edit === void 0 || !!e.edit;
3176
- }
3177
- function bt(e) {
3178
- return !e || e.delete === void 0 || !!e.delete;
3179
- }
3180
- function Le(e) {
3181
- return !e || e.enableClipboard === void 0 || !!e.enableClipboard;
3182
- }
3183
- function fa(e) {
3184
- return !e || e.matchesURL === void 0 || !!e.matchesURL;
3185
- }
3186
- function ma(e, t) {
3187
- return e === "string" ? t.trim().replace(/^\"([\s\S]+?)\"$/, "$1") : t;
3188
- }
3189
- var Bt;
3190
- function tt() {
3191
- return tt = Object.assign ? Object.assign.bind() : function(e) {
3192
- for (var t = 1; t < arguments.length; t++) {
3193
- var s = arguments[t];
3194
- for (var r in s)
3195
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3196
- }
3197
- return e;
3198
- }, tt.apply(this, arguments);
3199
- }
3200
- var xt = function(t) {
3201
- return /* @__PURE__ */ C.createElement("svg", tt({
3202
- xmlns: "http://www.w3.org/2000/svg",
3203
- width: 16,
3204
- height: 16,
3205
- fill: "none",
3206
- viewBox: "0 0 16 16"
3207
- }, t), Bt || (Bt = /* @__PURE__ */ C.createElement("path", {
3208
- fill: "currentColor",
3209
- d: "M12.473 5.806a.666.666 0 0 0-.946 0L8.473 8.86a.667.667 0 0 1-.946 0L4.473 5.806a.667.667 0 1 0-.946.94l3.06 3.06a2 2 0 0 0 2.826 0l3.06-3.06a.667.667 0 0 0 0-.94Z"
3210
- })));
3211
- }, Yt;
3212
- function st() {
3213
- return st = Object.assign ? Object.assign.bind() : function(e) {
3214
- for (var t = 1; t < arguments.length; t++) {
3215
- var s = arguments[t];
3216
- for (var r in s)
3217
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3218
- }
3219
- return e;
3220
- }, st.apply(this, arguments);
3221
- }
3222
- var pa = function(t) {
3223
- return /* @__PURE__ */ C.createElement("svg", st({
3224
- xmlns: "http://www.w3.org/2000/svg",
3225
- width: 24,
3226
- height: 24,
3227
- fill: "none",
3228
- viewBox: "0 0 24 24"
3229
- }, t), Yt || (Yt = /* @__PURE__ */ C.createElement("path", {
3230
- fill: "currentColor",
3231
- d: "M17.542 2.5h-4.75a3.963 3.963 0 0 0-3.959 3.958v4.75a3.963 3.963 0 0 0 3.959 3.959h4.75a3.963 3.963 0 0 0 3.958-3.959v-4.75A3.963 3.963 0 0 0 17.542 2.5Zm2.375 8.708a2.378 2.378 0 0 1-2.375 2.375h-4.75a2.378 2.378 0 0 1-2.375-2.375v-4.75a2.378 2.378 0 0 1 2.375-2.375h4.75a2.378 2.378 0 0 1 2.375 2.375v4.75Zm-4.75 6.334a3.963 3.963 0 0 1-3.959 3.958h-4.75A3.963 3.963 0 0 1 2.5 17.542v-4.75a3.963 3.963 0 0 1 3.958-3.959.791.791 0 1 1 0 1.584 2.378 2.378 0 0 0-2.375 2.375v4.75a2.378 2.378 0 0 0 2.375 2.375h4.75a2.378 2.378 0 0 0 2.375-2.375.792.792 0 1 1 1.584 0Z"
3232
- })));
3233
- }, Zt, Xt;
3234
- function nt() {
3235
- return nt = Object.assign ? Object.assign.bind() : function(e) {
3236
- for (var t = 1; t < arguments.length; t++) {
3237
- var s = arguments[t];
3238
- for (var r in s)
3239
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3240
- }
3241
- return e;
3242
- }, nt.apply(this, arguments);
3243
- }
3244
- var ya = function(t) {
3245
- return /* @__PURE__ */ C.createElement("svg", nt({
3246
- xmlns: "http://www.w3.org/2000/svg",
3247
- width: 24,
3248
- height: 24,
3249
- fill: "none",
3250
- viewBox: "0 0 24 24"
3251
- }, t), Zt || (Zt = /* @__PURE__ */ C.createElement("path", {
3252
- fill: "currentColor",
3253
- d: "M17.25 3H6.75A3.755 3.755 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.755 3.755 0 0 0 17.25 3Zm2.25 14.25a2.25 2.25 0 0 1-2.25 2.25H6.75a2.25 2.25 0 0 1-2.25-2.25V6.75A2.25 2.25 0 0 1 6.75 4.5h10.5a2.25 2.25 0 0 1 2.25 2.25v10.5Z"
3254
- })), Xt || (Xt = /* @__PURE__ */ C.createElement("path", {
3255
- fill: "#14C786",
3256
- d: "M10.312 14.45 7.83 11.906a.625.625 0 0 0-.896 0 .659.659 0 0 0 0 .918l2.481 2.546a1.264 1.264 0 0 0 .896.381 1.237 1.237 0 0 0 .895-.38l5.858-6.011a.658.658 0 0 0 0-.919.625.625 0 0 0-.896 0l-5.857 6.01Z"
3257
- })));
3258
- };
3259
- function Ue({ node: e, nodeMeta: t }) {
3260
- const { customizeCopy: s, CopyComponent: r, CopiedComponent: a } = pe(ce), [o, l] = Z(!1), i = (c) => {
3261
- c.stopPropagation();
3262
- const h = s(e, t);
3263
- typeof h == "string" && h && da(h), l(!0), setTimeout(() => l(!1), 3e3);
3264
- };
3265
- return o ? typeof a == "function" ? n.jsx(a, { className: "json-view--copy", style: { display: "inline-block" } }) : n.jsx(ya, { className: "json-view--copy", style: { display: "inline-block" } }) : typeof r == "function" ? n.jsx(r, { onClick: i, className: "json-view--copy" }) : n.jsx(pa, { onClick: i, className: "json-view--copy" });
3266
- }
3267
- function rt({ indexOrName: e, value: t, depth: s, deleteHandle: r, editHandle: a, parent: o, parentPath: l }) {
3268
- const { displayArrayIndex: i } = pe(ce), c = Array.isArray(o);
3269
- return n.jsxs("div", Object.assign({ className: "json-view--pair" }, { children: [!c || c && i ? n.jsxs(n.Fragment, { children: [n.jsx("span", Object.assign({ className: typeof e == "number" ? "json-view--index" : "json-view--property" }, { children: e })), ":", " "] }) : n.jsx(n.Fragment, {}), n.jsx(Fs, { node: t, depth: s + 1, deleteHandle: (h, d) => r(h, d), editHandle: (h, d, y, f) => a(h, d, y, f), parent: o, indexOrName: e, parentPath: l })] }));
3270
- }
3271
- var Gt, es;
3272
- function at() {
3273
- return at = Object.assign ? Object.assign.bind() : function(e) {
3274
- for (var t = 1; t < arguments.length; t++) {
3275
- var s = arguments[t];
3276
- for (var r in s)
3277
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3278
- }
3279
- return e;
3280
- }, at.apply(this, arguments);
3281
- }
3282
- var jt = function(t) {
3283
- return /* @__PURE__ */ C.createElement("svg", at({
3284
- xmlns: "http://www.w3.org/2000/svg",
3285
- width: 24,
3286
- height: 24,
3287
- fill: "none",
3288
- viewBox: "0 0 24 24"
3289
- }, t), Gt || (Gt = /* @__PURE__ */ C.createElement("path", {
3290
- fill: "currentColor",
3291
- d: "M18.75 6h-2.325a3.757 3.757 0 0 0-3.675-3h-1.5a3.757 3.757 0 0 0-3.675 3H5.25a.75.75 0 0 0 0 1.5H6v9.75A3.754 3.754 0 0 0 9.75 21h4.5A3.754 3.754 0 0 0 18 17.25V7.5h.75a.75.75 0 1 0 0-1.5Zm-7.5-1.5h1.5A2.255 2.255 0 0 1 14.872 6H9.128a2.255 2.255 0 0 1 2.122-1.5Zm5.25 12.75a2.25 2.25 0 0 1-2.25 2.25h-4.5a2.25 2.25 0 0 1-2.25-2.25V7.5h9v9.75Z"
3292
- })), es || (es = /* @__PURE__ */ C.createElement("path", {
3293
- fill: "#DA0000",
3294
- d: "M10.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75ZM13.5 16.5a.75.75 0 0 0 .75-.75v-4.5a.75.75 0 1 0-1.5 0v4.5a.75.75 0 0 0 .75.75Z"
3295
- })));
3296
- }, ts, ss;
3297
- function it() {
3298
- return it = Object.assign ? Object.assign.bind() : function(e) {
3299
- for (var t = 1; t < arguments.length; t++) {
3300
- var s = arguments[t];
3301
- for (var r in s)
3302
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3303
- }
3304
- return e;
3305
- }, it.apply(this, arguments);
3306
- }
3307
- var As = function(t) {
3308
- return /* @__PURE__ */ C.createElement("svg", it({
3309
- xmlns: "http://www.w3.org/2000/svg",
3310
- width: 24,
3311
- height: 24,
3312
- fill: "none",
3313
- viewBox: "0 0 24 24"
3314
- }, t), ts || (ts = /* @__PURE__ */ C.createElement("path", {
3315
- fill: "currentColor",
3316
- d: "M21 6.75v10.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3h10.5A3.754 3.754 0 0 1 21 6.75Zm-1.5 0c0-1.24-1.01-2.25-2.25-2.25H6.75C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25V6.75Z"
3317
- })), ss || (ss = /* @__PURE__ */ C.createElement("path", {
3318
- fill: "#14C786",
3319
- d: "M15 12.75a.75.75 0 1 0 0-1.5h-2.25V9a.75.75 0 1 0-1.5 0v2.25H9a.75.75 0 1 0 0 1.5h2.25V15a.75.75 0 1 0 1.5 0v-2.25H15Z"
3320
- })));
3321
- }, ns, rs;
3322
- function ot() {
3323
- return ot = Object.assign ? Object.assign.bind() : function(e) {
3324
- for (var t = 1; t < arguments.length; t++) {
3325
- var s = arguments[t];
3326
- for (var r in s)
3327
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3328
- }
3329
- return e;
3330
- }, ot.apply(this, arguments);
3331
- }
3332
- var wt = function(t) {
3333
- return /* @__PURE__ */ C.createElement("svg", ot({
3334
- xmlns: "http://www.w3.org/2000/svg",
3335
- width: 24,
3336
- height: 24,
3337
- fill: "none",
3338
- viewBox: "0 0 24 24"
3339
- }, t), ns || (ns = /* @__PURE__ */ C.createElement("path", {
3340
- fill: "currentColor",
3341
- d: "M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"
3342
- })), rs || (rs = /* @__PURE__ */ C.createElement("path", {
3343
- fill: "#14C786",
3344
- d: "m10.85 13.96-1.986-2.036a.5.5 0 0 0-.716 0 .527.527 0 0 0 0 .735l1.985 2.036a1.01 1.01 0 0 0 .717.305.99.99 0 0 0 .716-.305l4.686-4.808a.526.526 0 0 0 0-.735.5.5 0 0 0-.716 0l-4.687 4.809Z"
3345
- })));
3346
- }, as, is;
3347
- function lt() {
3348
- return lt = Object.assign ? Object.assign.bind() : function(e) {
3349
- for (var t = 1; t < arguments.length; t++) {
3350
- var s = arguments[t];
3351
- for (var r in s)
3352
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3353
- }
3354
- return e;
3355
- }, lt.apply(this, arguments);
3356
- }
3357
- var Ct = function(t) {
3358
- return /* @__PURE__ */ C.createElement("svg", lt({
3359
- xmlns: "http://www.w3.org/2000/svg",
3360
- width: 24,
3361
- height: 24,
3362
- fill: "none",
3363
- viewBox: "0 0 24 24"
3364
- }, t), as || (as = /* @__PURE__ */ C.createElement("path", {
3365
- fill: "#DA0000",
3366
- d: "M15 9a.75.75 0 0 0-1.06 0L12 10.94 10.06 9A.75.75 0 0 0 9 10.06L10.94 12 9 13.94A.75.75 0 0 0 10.06 15L12 13.06 13.94 15A.75.75 0 0 0 15 13.94L13.06 12 15 10.06A.75.75 0 0 0 15 9Z"
3367
- })), is || (is = /* @__PURE__ */ C.createElement("path", {
3368
- fill: "currentColor",
3369
- d: "M12 3a9 9 0 1 0 9 9 9.01 9.01 0 0 0-9-9Zm0 16.5a7.5 7.5 0 1 1 7.5-7.5 7.509 7.509 0 0 1-7.5 7.5Z"
3370
- })));
3371
- };
3372
- function ga({ originNode: e, node: t, depth: s, index: r, deleteHandle: a, customOptions: o, startIndex: l, parent: i, parentPath: c }) {
3373
- const { enableClipboard: h, src: d, onEdit: y, onChange: f, forceUpdate: p, displaySize: m, CustomOperation: g } = pe(ce), N = [...c, String(r)], [b, P] = Z(!0), T = k((R, S, M) => {
3374
- e[R] = S, y && y({
3375
- newValue: S,
3376
- oldValue: M,
3377
- depth: s,
3378
- src: d,
3379
- indexOrName: R,
3380
- parentType: "array",
3381
- parentPath: c
3382
- }), f && f({ type: "edit", depth: s, src: d, indexOrName: R, parentType: "array", parentPath: c }), p();
3383
- }, [t, y, f, p]), j = (R) => {
3384
- e.splice(R, 1), a && a(R, c), p();
3385
- }, w = n.jsxs(n.Fragment, { children: [!b && n.jsxs("span", Object.assign({ onClick: () => P(!0), className: "jv-size-chevron" }, { children: [xe(m, s, b) && n.jsxs("span", Object.assign({ className: "jv-size" }, { children: [Oe(t), " Items"] })), n.jsx(xt, { className: "jv-chevron" })] })), !b && h && Le(o) && n.jsx(Ue, { node: t, nodeMeta: { depth: s, indexOrName: r, parent: i, parentPath: c, currentPath: N } }), typeof g == "function" ? n.jsx(g, { node: t }) : null] });
3386
- return n.jsxs("div", { children: [n.jsx("span", { children: "[" }), w, b ? n.jsxs("button", Object.assign({ onClick: () => P(!1), className: "jv-button" }, { children: [l, " ... ", l + t.length - 1] })) : n.jsx("div", Object.assign({ className: "jv-indent" }, { children: t.map((R, S) => n.jsx(rt, { indexOrName: S + l, value: R, depth: s, parent: t, deleteHandle: j, editHandle: T, parentPath: c }, String(r) + String(S))) })), n.jsx("span", { children: "]" })] });
3387
- }
3388
- function va({ node: e, depth: t, deleteHandle: s, indexOrName: r, customOptions: a, parent: o, parentPath: l }) {
3389
- const i = typeof r < "u" ? [...l, String(r)] : l, c = [];
3390
- for (let Q = 0; Q < e.length; Q += 100)
3391
- c.push(e.slice(Q, Q + 100));
3392
- const { collapsed: h, enableClipboard: d, collapseObjectsAfterLength: y, editable: f, onDelete: p, src: m, onAdd: g, CustomOperation: N, onChange: b, forceUpdate: P, displaySize: T } = pe(ce), [j, w] = Z(zt(e, t, r, h, y, a));
3393
- ke(() => {
3394
- w(zt(e, t, r, h, y, a));
3395
- }, [h, y]);
3396
- const [R, S] = Z(!1), M = () => {
3397
- S(!1), s && s(r, l), p && p({ value: e, depth: t, src: m, indexOrName: r, parentType: "array", parentPath: l }), b && b({
3398
- type: "delete",
3399
- depth: t,
3400
- src: m,
3401
- indexOrName: r,
3402
- parentType: "array",
3403
- parentPath: l
3404
- });
3405
- }, [F, I] = Z(!1), _ = () => {
3406
- const Q = e;
3407
- Q.push(null), g && g({ indexOrName: Q.length - 1, depth: t, src: m, parentType: "array", parentPath: l }), b && b({ type: "add", indexOrName: Q.length - 1, depth: t, src: m, parentType: "array", parentPath: l }), P();
3408
- }, L = R || F, K = () => {
3409
- S(!1), I(!1);
3410
- }, V = n.jsxs(n.Fragment, { children: [!j && !L && n.jsxs("span", Object.assign({ onClick: () => w(!0), className: "jv-size-chevron" }, { children: [xe(T, t, j) && n.jsxs("span", Object.assign({ className: "jv-size" }, { children: [e.length, " Items"] })), n.jsx(xt, { className: "jv-chevron" })] })), L && n.jsx(wt, { className: "json-view--edit", style: { display: "inline-block" }, onClick: F ? _ : M }), L && n.jsx(Ct, { className: "json-view--edit", style: { display: "inline-block" }, onClick: K }), !j && !L && d && Le(a) && n.jsx(Ue, { node: e, nodeMeta: { depth: t, indexOrName: r, parent: o, parentPath: l, currentPath: i } }), !j && !L && Ms(f) && Ts(a) && n.jsx(As, { className: "json-view--edit", onClick: () => {
3411
- _();
3412
- } }), !j && !L && vt(f) && bt(a) && s && n.jsx(jt, { className: "json-view--edit", onClick: () => S(!0) }), typeof N == "function" ? n.jsx(N, { node: e }) : null] });
3413
- return n.jsxs(n.Fragment, { children: [n.jsx("span", { children: "[" }), V, j ? n.jsx("button", Object.assign({ onClick: () => w(!1), className: "jv-button" }, { children: "..." })) : n.jsx("div", Object.assign({ className: "jv-indent" }, { children: c.map((Q, $) => n.jsx(ga, { originNode: e, node: Q, depth: t, index: $, startIndex: $ * 100, deleteHandle: s, customOptions: a, parentPath: l }, String(r) + String($))) })), n.jsx("span", { children: "]" }), j && xe(T, t, j) && n.jsxs("span", Object.assign({ onClick: () => w(!1), className: "jv-size" }, { children: [e.length, " Items"] }))] });
3414
- }
3415
- function ba({ node: e, depth: t, indexOrName: s, deleteHandle: r, customOptions: a, parent: o, parentPath: l }) {
3416
- const { collapsed: i, onCollapse: c, enableClipboard: h, ignoreLargeArray: d, collapseObjectsAfterLength: y, editable: f, onDelete: p, src: m, onAdd: g, onEdit: N, onChange: b, forceUpdate: P, displaySize: T, CustomOperation: j } = pe(ce), w = typeof s < "u" ? [...l, String(s)] : l;
3417
- if (!d && Array.isArray(e) && e.length > 100)
3418
- return n.jsx(va, { node: e, depth: t, indexOrName: s, deleteHandle: r, customOptions: a, parentPath: w });
3419
- const R = le(e), [S, M] = Z(Wt(e, t, s, i, y, a)), F = (v) => {
3420
- c?.({ isCollapsing: !v, node: e, depth: t, indexOrName: s }), M(v);
3421
- };
3422
- ke(() => {
3423
- F(Wt(e, t, s, i, y, a));
3424
- }, [i, y]);
3425
- const I = k((v, E, Y) => {
3426
- Array.isArray(e) ? e[+v] = E : e && (e[v] = E), N && N({
3427
- newValue: E,
3428
- oldValue: Y,
3429
- depth: t,
3430
- src: m,
3431
- indexOrName: v,
3432
- parentType: R ? "object" : "array",
3433
- parentPath: w
3434
- }), b && b({ type: "edit", depth: t, src: m, indexOrName: v, parentType: R ? "object" : "array", parentPath: w }), P();
3435
- }, [e, N, b, P]), _ = (v) => {
3436
- Array.isArray(e) ? e.splice(+v, 1) : e && delete e[v], P();
3437
- }, [L, K] = Z(!1), V = () => {
3438
- K(!1), r && r(s, w), p && p({ value: e, depth: t, src: m, indexOrName: s, parentType: R ? "object" : "array", parentPath: w }), b && b({
3439
- type: "delete",
3440
- depth: t,
3441
- src: m,
3442
- indexOrName: s,
3443
- parentType: R ? "object" : "array",
3444
- parentPath: w
3445
- });
3446
- }, [Q, $] = Z(!1), A = ht(null), B = () => {
3447
- var v;
3448
- if (R) {
3449
- const E = (v = A.current) === null || v === void 0 ? void 0 : v.value;
3450
- E && (e[E] = null, A.current && (A.current.value = ""), $(!1), g && g({ indexOrName: E, depth: t, src: m, parentType: "object", parentPath: w }), b && b({ type: "add", indexOrName: E, depth: t, src: m, parentType: "object", parentPath: w }));
3451
- } else if (Array.isArray(e)) {
3452
- const E = e;
3453
- E.push(null), g && g({ indexOrName: E.length - 1, depth: t, src: m, parentType: "array", parentPath: w }), b && b({ type: "add", indexOrName: E.length - 1, depth: t, src: m, parentType: "array", parentPath: w });
3454
- }
3455
- P();
3456
- }, H = (v) => {
3457
- v.key === "Enter" ? (v.preventDefault(), B()) : v.key === "Escape" && x();
3458
- }, u = L || Q, x = () => {
3459
- K(!1), $(!1);
3460
- }, O = n.jsxs(n.Fragment, { children: [!S && !u && n.jsxs("span", Object.assign({ onClick: () => F(!0), className: "jv-size-chevron" }, { children: [xe(T, t, S) && n.jsxs("span", Object.assign({ className: "jv-size" }, { children: [Oe(e), " Items"] })), n.jsx(xt, { className: "jv-chevron" })] })), Q && R && n.jsx("input", { className: "json-view--input", placeholder: "property", ref: A, onKeyDown: H }), u && n.jsx(wt, { className: "json-view--edit", style: { display: "inline-block" }, onClick: Q ? B : V }), u && n.jsx(Ct, { className: "json-view--edit", style: { display: "inline-block" }, onClick: x }), !S && !u && h && Le(a) && n.jsx(Ue, { node: e, nodeMeta: { depth: t, indexOrName: s, parent: o, parentPath: l, currentPath: w } }), !S && !u && Ms(f) && Ts(a) && n.jsx(As, { className: "json-view--edit", onClick: () => {
3461
- R ? ($(!0), setTimeout(() => {
3462
- var v;
3463
- return (v = A.current) === null || v === void 0 ? void 0 : v.focus();
3464
- })) : B();
3465
- } }), !S && !u && vt(f) && bt(a) && r && n.jsx(jt, { className: "json-view--edit", onClick: () => K(!0) }), typeof j == "function" ? n.jsx(j, { node: e }) : null] });
3466
- return Array.isArray(e) ? n.jsxs(n.Fragment, { children: [n.jsx("span", { children: "[" }), O, S ? n.jsx("button", Object.assign({ onClick: () => F(!1), className: "jv-button" }, { children: "..." })) : n.jsx("div", Object.assign({ className: "jv-indent" }, { children: e.map((v, E) => n.jsx(rt, { indexOrName: E, value: v, depth: t, parent: e, deleteHandle: _, editHandle: I, parentPath: w }, String(s) + String(E))) })), n.jsx("span", { children: "]" }), S && xe(T, t, S) && n.jsxs("span", Object.assign({ onClick: () => F(!1), className: "jv-size" }, { children: [Oe(e), " Items"] }))] }) : R ? n.jsxs(n.Fragment, { children: [n.jsx("span", { children: "{" }), O, S ? n.jsx("button", Object.assign({ onClick: () => F(!1), className: "jv-button" }, { children: "..." })) : n.jsx("div", Object.assign({ className: "jv-indent" }, { children: Object.entries(e).map(([v, E]) => n.jsx(rt, { indexOrName: v, value: E, depth: t, parent: e, deleteHandle: _, editHandle: I, parentPath: w }, String(s) + String(v))) })), n.jsx("span", { children: "}" }), S && xe(T, t, S) && n.jsxs("span", Object.assign({ onClick: () => F(!1), className: "jv-size" }, { children: [Oe(e), " Items"] }))] }) : n.jsx("span", { children: String(e) });
3467
- }
3468
- const xa = ge.forwardRef(({ str: e, className: t, ctrlClick: s }, r) => {
3469
- let { collapseStringMode: a, collapseStringsAfterLength: o, customizeCollapseStringUI: l } = pe(ce);
3470
- const [i, c] = Z(!0), h = ht(null);
3471
- o = o > 0 ? o : 0;
3472
- const d = e.replace(/\s+/g, " "), y = typeof l == "function" ? l(d, i) : typeof l == "string" ? l : "...", f = (p) => {
3473
- var m;
3474
- if ((p.ctrlKey || p.metaKey) && s)
3475
- s(p);
3476
- else {
3477
- const g = window.getSelection();
3478
- if (g && g.anchorOffset !== g.focusOffset && ((m = g.anchorNode) === null || m === void 0 ? void 0 : m.parentElement) === h.current)
3479
- return;
3480
- c(!i);
3481
- }
3482
- };
3483
- if (e.length <= o)
3484
- return n.jsxs("span", Object.assign({ ref: h, className: t, onClick: s }, { children: ['"', e, '"'] }));
3485
- if (a === "address")
3486
- return e.length <= 10 ? n.jsxs("span", Object.assign({ ref: h, className: t, onClick: s }, { children: ['"', e, '"'] })) : n.jsxs("span", Object.assign({ ref: h, onClick: f, className: t + " cursor-pointer" }, { children: ['"', i ? [d.slice(0, 6), y, d.slice(-4)] : e, '"'] }));
3487
- if (a === "directly")
3488
- return n.jsxs("span", Object.assign({ ref: h, onClick: f, className: t + " cursor-pointer" }, { children: ['"', i ? [d.slice(0, o), y] : e, '"'] }));
3489
- if (a === "word") {
3490
- let p = o, m = o + 1, g = d, N = 1;
3491
- for (; ; ) {
3492
- if (/\W/.test(e[p])) {
3493
- g = e.slice(0, p);
3494
- break;
3495
- }
3496
- if (/\W/.test(e[m])) {
3497
- g = e.slice(0, m);
3498
- break;
3499
- }
3500
- if (N === 6) {
3501
- g = e.slice(0, o);
3502
- break;
3503
- }
3504
- N++, p--, m++;
3505
- }
3506
- return n.jsxs("span", Object.assign({ ref: h, onClick: f, className: t + " cursor-pointer" }, { children: ['"', i ? [g, y] : e, '"'] }));
3507
- }
3508
- return n.jsxs("span", Object.assign({ ref: h, className: t }, { children: ['"', e, '"'] }));
3509
- });
3510
- var os;
3511
- function ct() {
3512
- return ct = Object.assign ? Object.assign.bind() : function(e) {
3513
- for (var t = 1; t < arguments.length; t++) {
3514
- var s = arguments[t];
3515
- for (var r in s)
3516
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3517
- }
3518
- return e;
3519
- }, ct.apply(this, arguments);
3520
- }
3521
- var ja = function(t) {
3522
- return /* @__PURE__ */ C.createElement("svg", ct({
3523
- xmlns: "http://www.w3.org/2000/svg",
3524
- width: 24,
3525
- height: 24,
3526
- fill: "none",
3527
- viewBox: "0 0 24 24"
3528
- }, t), os || (os = /* @__PURE__ */ C.createElement("path", {
3529
- fill: "currentColor",
3530
- d: "M17.25 3H6.75A3.754 3.754 0 0 0 3 6.75v10.5A3.754 3.754 0 0 0 6.75 21h10.5A3.754 3.754 0 0 0 21 17.25V6.75A3.754 3.754 0 0 0 17.25 3Zm2.25 14.25c0 1.24-1.01 2.25-2.25 2.25H6.75c-1.24 0-2.25-1.01-2.25-2.25V6.75c0-1.24 1.01-2.25 2.25-2.25h10.5c1.24 0 2.25 1.01 2.25 2.25v10.5Zm-6.09-9.466-5.031 5.03a2.981 2.981 0 0 0-.879 2.121v1.19c0 .415.336.75.75.75h1.19c.8 0 1.554-.312 2.12-.879l5.03-5.03a2.252 2.252 0 0 0 0-3.182c-.85-.85-2.331-.85-3.18 0Zm-2.91 7.151c-.28.28-.666.44-1.06.44H9v-.44c0-.4.156-.777.44-1.06l3.187-3.188 1.06 1.061-3.187 3.188Zm5.03-5.03-.782.783-1.06-1.061.782-.782a.766.766 0 0 1 1.06 0 .75.75 0 0 1 0 1.06Z"
3531
- })));
3532
- }, ls, cs;
3533
- function ut() {
3534
- return ut = Object.assign ? Object.assign.bind() : function(e) {
3535
- for (var t = 1; t < arguments.length; t++) {
3536
- var s = arguments[t];
3537
- for (var r in s)
3538
- Object.prototype.hasOwnProperty.call(s, r) && (e[r] = s[r]);
3539
- }
3540
- return e;
3541
- }, ut.apply(this, arguments);
3542
- }
3543
- var wa = function(t) {
3544
- return /* @__PURE__ */ C.createElement("svg", ut({
3545
- xmlns: "http://www.w3.org/2000/svg",
3546
- width: 24,
3547
- height: 24,
3548
- fill: "none",
3549
- viewBox: "0 0 24 24"
3550
- }, t), ls || (ls = /* @__PURE__ */ C.createElement("path", {
3551
- fill: "currentColor",
3552
- d: "M6.75 3h5.5v1.5h-5.5C5.51 4.5 4.5 5.51 4.5 6.75v10.5c0 1.24 1.01 2.25 2.25 2.25h10.5c1.24 0 2.25-1.01 2.25-2.25v-5.5H21v5.5A3.754 3.754 0 0 1 17.25 21H6.75A3.754 3.754 0 0 1 3 17.25V6.75A3.754 3.754 0 0 1 6.75 3Z"
3553
- })), cs || (cs = /* @__PURE__ */ C.createElement("path", {
3554
- fill: "currentColor",
3555
- d: "M20.013 3h-3.946a.987.987 0 0 0 0 1.973h1.564l-6.342 6.342a1.004 1.004 0 0 0 0 1.396 1.004 1.004 0 0 0 1.396 0l6.342-6.342v1.564a.987.987 0 0 0 1.973 0V3.987A.987.987 0 0 0 20.013 3Z"
3556
- })));
3557
- };
3558
- function Fs({ node: e, depth: t, deleteHandle: s, indexOrName: r, parent: a, editHandle: o, parentPath: l }) {
3559
- const { collapseStringsAfterLength: i, enableClipboard: c, editable: h, src: d, onDelete: y, onChange: f, customizeNode: p, matchesURL: m, urlRegExp: g, EditComponent: N, DoneComponent: b, CancelComponent: P, CustomOperation: T } = pe(ce);
3560
- let j;
3561
- if (typeof p == "function" && (j = gt(p, [{ node: e, depth: t, indexOrName: r }])), j) {
3562
- if (rn(j))
3563
- return j;
3564
- if (ha(j)) {
3565
- const w = j;
3566
- return n.jsx(w, { node: e, depth: t, indexOrName: r });
3567
- }
3568
- }
3569
- if (Array.isArray(e) || le(e))
3570
- return n.jsx(ba, { parent: a, node: e, depth: t, indexOrName: r, deleteHandle: s, parentPath: l, customOptions: typeof j == "object" ? j : void 0 });
3571
- {
3572
- const w = typeof e, R = typeof r < "u" ? [...l, String(r)] : l, [S, M] = Z(!1), [F, I] = Z(!1), _ = ht(null), L = () => {
3573
- M(!0), setTimeout(() => {
3574
- var v, E;
3575
- (v = window.getSelection()) === null || v === void 0 || v.selectAllChildren(_.current), (E = _.current) === null || E === void 0 || E.focus();
3576
- });
3577
- }, K = k(() => {
3578
- let v = _.current.innerText;
3579
- try {
3580
- const E = JSON.parse(v);
3581
- o && o(r, E, e, l);
3582
- } catch {
3583
- const Y = ma(w, v);
3584
- o && o(r, Y, e, l);
3585
- }
3586
- M(!1);
3587
- }, [o, r, e, l, w]), V = () => {
3588
- M(!1), I(!1);
3589
- }, Q = () => {
3590
- I(!1), s && s(r, l), y && y({
3591
- value: e,
3592
- depth: t,
3593
- src: d,
3594
- indexOrName: r,
3595
- parentType: Array.isArray(a) ? "array" : "object",
3596
- parentPath: l
3597
- }), f && f({
3598
- depth: t,
3599
- src: d,
3600
- indexOrName: r,
3601
- parentType: Array.isArray(a) ? "array" : "object",
3602
- type: "delete",
3603
- parentPath: l
3604
- });
3605
- }, $ = k((v) => {
3606
- v.key === "Enter" ? (v.preventDefault(), K()) : v.key === "Escape" && V();
3607
- }, [K]), A = S || F, B = !A && Kt(h) && Vt(j) && o ? (v) => {
3608
- (v.ctrlKey || v.metaKey) && L();
3609
- } : void 0, H = n.jsxs(n.Fragment, { children: [A && (typeof b == "function" ? n.jsx(b, { className: "json-view--edit", style: { display: "inline-block" }, onClick: F ? Q : K }) : n.jsx(wt, { className: "json-view--edit", style: { display: "inline-block" }, onClick: F ? Q : K })), A && (typeof P == "function" ? n.jsx(P, { className: "json-view--edit", style: { display: "inline-block" }, onClick: V }) : n.jsx(Ct, { className: "json-view--edit", style: { display: "inline-block" }, onClick: V })), !A && c && Le(j) && n.jsx(Ue, { node: e, nodeMeta: { depth: t, indexOrName: r, parent: a, parentPath: l, currentPath: R } }), !A && m && w === "string" && g.test(e) && fa(j) && n.jsx("a", Object.assign({ href: e, target: "_blank", className: "json-view--link" }, { children: n.jsx(wa, {}) })), !A && Kt(h) && Vt(j) && o && (typeof N == "function" ? n.jsx(N, { className: "json-view--edit", onClick: L }) : n.jsx(ja, { className: "json-view--edit", onClick: L })), !A && vt(h) && bt(j) && s && n.jsx(jt, { className: "json-view--edit", onClick: () => I(!0) }), typeof T == "function" ? n.jsx(T, { node: e }) : null] });
3610
- let u = "json-view--string";
3611
- switch (w) {
3612
- case "number":
3613
- case "bigint":
3614
- u = "json-view--number";
3615
- break;
3616
- case "boolean":
3617
- u = "json-view--boolean";
3618
- break;
3619
- case "object":
3620
- u = "json-view--null";
3621
- break;
3622
- }
3623
- typeof j?.className == "string" && (u += " " + j.className), F && (u += " json-view--deleting");
3624
- let x = String(e);
3625
- w === "bigint" && (x += "n");
3626
- const O = Te(() => n.jsx("span", { contentEditable: !0, className: u, dangerouslySetInnerHTML: { __html: w === "string" ? `"${x}"` : x }, ref: _, onKeyDown: $ }), [x, w, $]);
3627
- return w === "string" ? n.jsxs(n.Fragment, { children: [S ? O : e.length > i ? n.jsx(xa, { str: e, ref: _, className: u, ctrlClick: B }) : n.jsxs("span", Object.assign({ className: u, onClick: B }, { children: ['"', x, '"'] })), H] }) : n.jsxs(n.Fragment, { children: [S ? O : n.jsx("span", Object.assign({ className: u, onClick: B }, { children: x })), H] });
3628
- }
3629
- }
3630
- const _s = /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/, ce = nn({
3631
- src: void 0,
3632
- collapseStringsAfterLength: 99,
3633
- collapseStringMode: "directly",
3634
- customizeCollapseStringUI: void 0,
3635
- collapseObjectsAfterLength: 20,
3636
- collapsed: !1,
3637
- onCollapse: void 0,
3638
- enableClipboard: !0,
3639
- editable: !1,
3640
- onEdit: void 0,
3641
- onDelete: void 0,
3642
- onAdd: void 0,
3643
- onChange: void 0,
3644
- forceUpdate: () => {
3645
- },
3646
- customizeNode: void 0,
3647
- customizeCopy: () => {
3648
- },
3649
- displaySize: void 0,
3650
- displayArrayIndex: !0,
3651
- matchesURL: !1,
3652
- urlRegExp: _s,
3653
- ignoreLargeArray: !1,
3654
- CopyComponent: void 0,
3655
- CopiedComponent: void 0,
3656
- EditComponent: void 0,
3657
- CancelComponent: void 0,
3658
- DoneComponent: void 0,
3659
- CustomOperation: void 0
3660
- });
3661
- function Je({ src: e, collapseStringsAfterLength: t = 99, collapseStringMode: s = "directly", customizeCollapseStringUI: r, collapseObjectsAfterLength: a = 99, collapsed: o, onCollapse: l, enableClipboard: i = !0, editable: c = !1, onEdit: h, onDelete: d, onAdd: y, onChange: f, dark: p = !1, theme: m = "default", customizeNode: g, customizeCopy: N = (V) => ua(V), displaySize: b, displayArrayIndex: P = !0, style: T, className: j, matchesURL: w = !1, urlRegExp: R = _s, ignoreLargeArray: S = !1, CopyComponent: M, CopiedComponent: F, EditComponent: I, CancelComponent: _, DoneComponent: L, CustomOperation: K }) {
3662
- const [V, Q] = Z(0), $ = k(() => Q((H) => ++H), []), [A, B] = Z(e);
3663
- return ke(() => B(e), [e]), n.jsx(ce.Provider, Object.assign({ value: {
3664
- src: A,
3665
- collapseStringsAfterLength: t,
3666
- collapseStringMode: s,
3667
- customizeCollapseStringUI: r,
3668
- collapseObjectsAfterLength: a,
3669
- collapsed: o,
3670
- onCollapse: l,
3671
- enableClipboard: i,
3672
- editable: c,
3673
- onEdit: h,
3674
- onDelete: d,
3675
- onAdd: y,
3676
- onChange: f,
3677
- forceUpdate: $,
3678
- customizeNode: g,
3679
- customizeCopy: N,
3680
- displaySize: b,
3681
- displayArrayIndex: P,
3682
- matchesURL: w,
3683
- urlRegExp: R,
3684
- ignoreLargeArray: S,
3685
- CopyComponent: M,
3686
- CopiedComponent: F,
3687
- EditComponent: I,
3688
- CancelComponent: _,
3689
- DoneComponent: L,
3690
- CustomOperation: K
3691
- } }, { children: n.jsx("code", Object.assign({ className: "json-view" + (p ? " dark" : "") + (m && m !== "default" ? " json-view_" + m : "") + (j ? " " + j : ""), style: T }, { children: n.jsx(Fs, { node: A, depth: 1, editHandle: (H, u, x, O) => {
3692
- B(u), h && h({
3693
- newValue: u,
3694
- oldValue: x,
3695
- depth: 1,
3696
- src: A,
3697
- indexOrName: H,
3698
- parentType: null,
3699
- parentPath: O
3700
- }), f && f({ type: "edit", depth: 1, src: A, indexOrName: H, parentType: null, parentPath: O });
3701
- }, deleteHandle: (H, u) => {
3702
- B(void 0), d && d({
3703
- value: A,
3704
- depth: 1,
3705
- src: A,
3706
- indexOrName: H,
3707
- parentType: null,
3708
- parentPath: u
3709
- }), f && f({
3710
- depth: 1,
3711
- src: A,
3712
- indexOrName: H,
3713
- parentType: null,
3714
- type: "delete",
3715
- parentPath: u
3716
- });
3717
- }, parentPath: [] }) })) }));
3718
- }
3719
- const Ca = async ({ queueName: e, jobId: t }) => {
3720
- if (!(await fetch(
3721
- `/__motia/bullmq/queues/${encodeURIComponent(e)}/jobs/${encodeURIComponent(t)}/retry`,
3722
- { method: "POST" }
3723
- )).ok)
3724
- throw new Error("Failed to retry job");
3725
- }, Sa = async ({ queueName: e, jobId: t }) => {
3726
- if (!(await fetch(
3727
- `/__motia/bullmq/queues/${encodeURIComponent(e)}/jobs/${encodeURIComponent(t)}/remove`,
3728
- { method: "POST" }
3729
- )).ok)
3730
- throw new Error("Failed to remove job");
3731
- }, Na = async ({ queueName: e, jobId: t }) => {
3732
- if (!(await fetch(
3733
- `/__motia/bullmq/queues/${encodeURIComponent(e)}/jobs/${encodeURIComponent(t)}/promote`,
3734
- { method: "POST" }
3735
- )).ok)
3736
- throw new Error("Failed to promote job");
3737
- }, Ea = async ({ queueName: e, jobId: t }) => {
3738
- if (!(await fetch(
3739
- `/__motia/bullmq/dlq/${encodeURIComponent(e)}/retry/${encodeURIComponent(t)}`,
3740
- { method: "POST" }
3741
- )).ok)
3742
- throw new Error("Failed to retry from DLQ");
3743
- }, Oa = async ({ queueName: e }) => {
3744
- if (!(await fetch(`/__motia/bullmq/dlq/${encodeURIComponent(e)}/retry-all`, { method: "POST" })).ok)
3745
- throw new Error("Failed to retry all from DLQ");
3746
- }, Ra = async ({ queueName: e }) => {
3747
- if (!(await fetch(`/__motia/bullmq/dlq/${encodeURIComponent(e)}/clear`, { method: "POST" })).ok)
3748
- throw new Error("Failed to clear DLQ");
3749
- }, Qs = () => {
3750
- const e = ne(), t = D((s) => s.setError);
3751
- return we({
3752
- mutationFn: Ca,
3753
- onSuccess: (s, { queueName: r }) => {
3754
- e.invalidateQueries({ queryKey: ["jobs", r] });
3755
- },
3756
- onError: (s) => {
3757
- t(s instanceof Error ? s.message : "Failed to retry job");
3758
- }
3759
- });
3760
- }, Is = () => {
3761
- const e = ne(), t = D((s) => s.setError);
3762
- return we({
3763
- mutationFn: Sa,
3764
- onSuccess: (s, { queueName: r }) => {
3765
- e.invalidateQueries({ queryKey: ["jobs", r] });
3766
- },
3767
- onError: (s) => {
3768
- t(s instanceof Error ? s.message : "Failed to remove job");
3769
- }
3770
- });
3771
- }, qs = () => {
3772
- const e = ne(), t = D((s) => s.setError);
3773
- return we({
3774
- mutationFn: Na,
3775
- onSuccess: (s, { queueName: r }) => {
3776
- e.invalidateQueries({ queryKey: ["jobs", r] });
3777
- },
3778
- onError: (s) => {
3779
- t(s instanceof Error ? s.message : "Failed to promote job");
3780
- }
3781
- });
3782
- }, ka = () => {
3783
- const e = ne(), t = D((s) => s.setError);
3784
- return we({
3785
- mutationFn: Ea,
3786
- onSuccess: (s, { queueName: r }) => {
3787
- e.invalidateQueries({ queryKey: ["dlq-jobs", r] });
3788
- },
3789
- onError: (s) => {
3790
- t(s instanceof Error ? s.message : "Failed to retry from DLQ");
3791
- }
3792
- });
3793
- }, Da = () => {
3794
- const e = ne(), t = D((s) => s.setError);
3795
- return we({
3796
- mutationFn: Oa,
3797
- onSuccess: (s, { queueName: r }) => {
3798
- e.invalidateQueries({ queryKey: ["dlq-jobs", r] });
3799
- },
3800
- onError: (s) => {
3801
- t(s instanceof Error ? s.message : "Failed to retry all from DLQ");
3802
- }
3803
- });
3804
- }, Pa = () => {
3805
- const e = ne(), t = D((s) => s.setError);
3806
- return we({
3807
- mutationFn: Ra,
3808
- onSuccess: (s, { queueName: r }) => {
3809
- e.invalidateQueries({ queryKey: ["dlq-jobs", r] });
3810
- },
3811
- onError: (s) => {
3812
- t(s instanceof Error ? s.message : "Failed to clear DLQ");
3813
- }
3814
- });
3815
- }, Ma = async (e, t, s = 0, r = 100) => {
3816
- const a = new URLSearchParams({ status: t, start: String(s), end: String(r) }), o = await fetch(`/__motia/bullmq/queues/${encodeURIComponent(e)}/jobs?${a}`);
3817
- if (!o.ok)
3818
- throw new Error("Failed to fetch jobs");
3819
- return (await o.json()).jobs;
3820
- }, Ta = async (e, t = 0, s = 100) => {
3821
- const r = new URLSearchParams({ start: String(t), end: String(s) }), a = await fetch(`/__motia/bullmq/dlq/${encodeURIComponent(e)}/jobs?${r}`);
3822
- return a.ok ? (await a.json()).jobs : [];
3823
- }, Aa = () => {
3824
- const e = D((a) => a.selectedQueue), t = D((a) => a.selectedStatus), s = e?.name, r = e ? JSON.stringify(e.stats) : null;
3825
- return Ds({
3826
- queryKey: ["jobs", s, t, r],
3827
- queryFn: () => Ma(s, t),
3828
- enabled: !!s,
3829
- staleTime: 5e3
3830
- });
3831
- }, Fa = (e) => Ds({
3832
- queryKey: ["dlq-jobs", e],
3833
- queryFn: () => Ta(e),
3834
- enabled: !!e
3835
- }), Ls = z(({ job: e, onRetry: t }) => /* @__PURE__ */ n.jsxs("div", { className: "space-y-4", children: [
3836
- /* @__PURE__ */ n.jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ n.jsxs(X, { variant: "outline", size: "sm", onClick: t, children: [
3837
- /* @__PURE__ */ n.jsx(he, { className: "mr-2 h-4 w-4" }),
3838
- "Retry"
3839
- ] }) }),
3840
- /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-2 gap-4 text-sm", children: [
3841
- /* @__PURE__ */ n.jsxs("div", { children: [
3842
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Job ID" }),
3843
- /* @__PURE__ */ n.jsx("div", { className: "font-mono text-xs", children: e.id })
3844
- ] }),
3845
- /* @__PURE__ */ n.jsxs("div", { children: [
3846
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Original Job ID" }),
3847
- /* @__PURE__ */ n.jsx("div", { className: "font-mono text-xs", children: e.originalJobId || "-" })
3848
- ] }),
3849
- /* @__PURE__ */ n.jsxs("div", { children: [
3850
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Attempts Made" }),
3851
- /* @__PURE__ */ n.jsx("div", { className: "font-semibold", children: e.attemptsMade })
3852
- ] }),
3853
- /* @__PURE__ */ n.jsxs("div", { children: [
3854
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Failed At" }),
3855
- /* @__PURE__ */ n.jsx("div", { children: qe(e.failureTimestamp, { addSuffix: !0 }) })
3856
- ] })
3857
- ] }),
3858
- /* @__PURE__ */ n.jsxs("div", { children: [
3859
- /* @__PURE__ */ n.jsx("div", { className: "text-sm font-semibold text-destructive mb-2", children: "Failure Reason" }),
3860
- /* @__PURE__ */ n.jsx("div", { className: "font-mono text-sm bg-destructive/10 p-3 rounded text-destructive", children: e.failureReason })
3861
- ] })
3862
- ] }));
3863
- Ls.displayName = "DLQJobDetailContent";
3864
- const Us = z(({ data: e }) => /* @__PURE__ */ n.jsx("div", { className: "bg-muted/30 p-4 rounded overflow-auto max-h-[400px]", children: /* @__PURE__ */ n.jsx(Je, { src: e, theme: "atom", collapsed: 2 }) }));
3865
- Us.displayName = "DLQJobDataTab";
3866
- const Js = z(() => {
3867
- const e = D((m) => m.selectedQueue), {
3868
- data: t = [],
3869
- isLoading: s,
3870
- refetch: r
3871
- } = Fa(e?.isDLQ ? e.name : void 0), a = ka(), o = Da(), l = Pa(), [i, c] = Z(null), h = k(
3872
- (m) => {
3873
- e && a.mutate({ queueName: e.name, jobId: m });
3874
- },
3875
- [e, a]
3876
- ), d = k(() => {
3877
- e && o.mutate({ queueName: e.name });
3878
- }, [e, o]), y = k(() => {
3879
- e && l.mutate({ queueName: e.name });
3880
- }, [e, l]), f = k(() => {
3881
- c(null);
3882
- }, []), p = k(() => {
3883
- i && (h(i.id), c(null));
3884
- }, [i, h]);
3885
- return e?.isDLQ ? /* @__PURE__ */ n.jsx(ds, { children: /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col h-full", children: [
3886
- /* @__PURE__ */ n.jsxs("div", { className: "flex items-center justify-between p-3 border-b border-border", children: [
3887
- /* @__PURE__ */ n.jsxs("div", { children: [
3888
- /* @__PURE__ */ n.jsx("h2", { className: "font-semibold text-lg", children: e.displayName }),
3889
- /* @__PURE__ */ n.jsxs("p", { className: "text-sm text-muted-foreground", children: [
3890
- t.length,
3891
- " failed job",
3892
- t.length !== 1 ? "s" : "",
3893
- " in dead letter queue"
3894
- ] })
3895
- ] }),
3896
- /* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2", children: [
3897
- /* @__PURE__ */ n.jsxs(re, { children: [
3898
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsx(X, { variant: "ghost", size: "icon", onClick: () => r(), disabled: s, children: /* @__PURE__ */ n.jsx(he, { className: `h-4 w-4 ${s ? "animate-spin" : ""}` }) }) }),
3899
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Refresh DLQ jobs list" }) })
3900
- ] }),
3901
- /* @__PURE__ */ n.jsxs(re, { children: [
3902
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsxs(X, { variant: "outline", size: "sm", onClick: d, disabled: t.length === 0, children: [
3903
- /* @__PURE__ */ n.jsx(he, { className: "mr-2 h-4 w-4" }),
3904
- "Retry All"
3905
- ] }) }),
3906
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Re-queue all failed jobs to the original queue" }) })
3907
- ] }),
3908
- /* @__PURE__ */ n.jsxs(re, { children: [
3909
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsxs(
3910
- X,
3911
- {
3912
- variant: "outline",
3913
- size: "sm",
3914
- onClick: y,
3915
- disabled: t.length === 0,
3916
- className: "text-destructive",
3917
- children: [
3918
- /* @__PURE__ */ n.jsx(be, { className: "mr-2 h-4 w-4" }),
3919
- "Clear All"
3920
- ]
3921
- }
3922
- ) }),
3923
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Permanently delete all jobs from DLQ" }) })
3924
- ] })
3925
- ] })
3926
- ] }),
3927
- t.length === 0 ? /* @__PURE__ */ n.jsx("div", { className: "flex items-center justify-center flex-1 text-muted-foreground", children: "No jobs in dead letter queue" }) : /* @__PURE__ */ n.jsx("div", { className: "flex-1 overflow-auto", children: /* @__PURE__ */ n.jsxs(hs, { children: [
3928
- /* @__PURE__ */ n.jsx(fs, { className: "sticky top-0 bg-background/95 backdrop-blur-sm", children: /* @__PURE__ */ n.jsxs(Fe, { children: [
3929
- /* @__PURE__ */ n.jsx(ee, { className: "w-[180px]", children: "Job ID" }),
3930
- /* @__PURE__ */ n.jsx(ee, { className: "w-[180px]", children: "Original Job" }),
3931
- /* @__PURE__ */ n.jsx(ee, { children: "Failure Reason" }),
3932
- /* @__PURE__ */ n.jsx(ee, { className: "w-[100px]", children: "Attempts" }),
3933
- /* @__PURE__ */ n.jsx(ee, { className: "w-[150px]", children: "Failed At" }),
3934
- /* @__PURE__ */ n.jsx(ee, { className: "w-[100px]", children: "Actions" })
3935
- ] }) }),
3936
- /* @__PURE__ */ n.jsx(ms, { children: t.map((m) => /* @__PURE__ */ n.jsxs(
3937
- Fe,
3938
- {
3939
- className: "cursor-pointer hover:bg-muted-foreground/10",
3940
- onClick: () => c(m),
3941
- children: [
3942
- /* @__PURE__ */ n.jsx(te, { className: "font-mono text-xs", children: m.id }),
3943
- /* @__PURE__ */ n.jsx(te, { className: "font-mono text-xs text-muted-foreground", children: m.originalJobId || "-" }),
3944
- /* @__PURE__ */ n.jsx(te, { className: "text-destructive text-sm truncate max-w-[300px]", children: m.failureReason }),
3945
- /* @__PURE__ */ n.jsx(te, { children: m.attemptsMade }),
3946
- /* @__PURE__ */ n.jsx(te, { className: "text-xs text-muted-foreground", children: qe(m.failureTimestamp, { addSuffix: !0 }) }),
3947
- /* @__PURE__ */ n.jsx(te, { onClick: (g) => g.stopPropagation(), children: /* @__PURE__ */ n.jsxs(re, { children: [
3948
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsx(X, { variant: "ghost", size: "sm", onClick: () => h(m.id), children: /* @__PURE__ */ n.jsx(he, { className: "h-4 w-4" }) }) }),
3949
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Retry this job" }) })
3950
- ] }) })
3951
- ]
3952
- },
3953
- m.id
3954
- )) })
3955
- ] }) }),
3956
- i && /* @__PURE__ */ n.jsx(
3957
- ps,
3958
- {
3959
- onClose: f,
3960
- title: "Dead Letter Job",
3961
- initialWidth: 600,
3962
- tabs: [
3963
- {
3964
- label: "Details",
3965
- content: /* @__PURE__ */ n.jsx(Ls, { job: i, onRetry: p })
3966
- },
3967
- {
3968
- label: "Event Data",
3969
- content: /* @__PURE__ */ n.jsx(Us, { data: i.originalEvent })
3970
- }
3971
- ],
3972
- actions: [{ icon: /* @__PURE__ */ n.jsx(yt, {}), onClick: f, label: "Close" }]
3973
- }
3974
- )
3975
- ] }) }) : null;
3976
- });
3977
- Js.displayName = "DLQPanel";
3978
- /**
3979
- * @license lucide-react v0.545.0 - ISC
3980
- *
3981
- * This source code is licensed under the ISC license.
3982
- * See the LICENSE file in the root directory of this source tree.
3983
- */
3984
- const _a = [
3985
- ["path", { d: "M7 7h10v10", key: "1tivn9" }],
3986
- ["path", { d: "M7 17 17 7", key: "1vkiza" }]
3987
- ], $s = se("arrow-up-right", _a), Hs = z(({ data: e }) => /* @__PURE__ */ n.jsx("div", { className: "bg-muted/30 p-4 rounded", children: /* @__PURE__ */ n.jsx(Je, { src: e, theme: "atom", collapsed: 2 }) }));
3988
- Hs.displayName = "JobDataTab";
3989
- const Ws = z(({ opts: e }) => /* @__PURE__ */ n.jsx("div", { className: "bg-muted/30 p-4 rounded", children: /* @__PURE__ */ n.jsx(Je, { src: e, theme: "atom", collapsed: 2 }) }));
3990
- Ws.displayName = "JobOptionsTab";
3991
- const zs = z(({ returnvalue: e }) => /* @__PURE__ */ n.jsx("div", { className: "bg-muted/30 p-4 rounded", children: /* @__PURE__ */ n.jsx(Je, { src: e, theme: "atom", collapsed: 2 }) }));
3992
- zs.displayName = "JobResultTab";
3993
- const Ks = z(({ failedReason: e, stacktrace: t }) => /* @__PURE__ */ n.jsxs("div", { className: "space-y-4", children: [
3994
- /* @__PURE__ */ n.jsxs("div", { children: [
3995
- /* @__PURE__ */ n.jsx("div", { className: "text-sm font-semibold text-destructive mb-1", children: "Error Message" }),
3996
- /* @__PURE__ */ n.jsx("div", { className: "font-mono text-sm bg-destructive/10 p-3 rounded text-destructive", children: e })
3997
- ] }),
3998
- t && t.length > 0 && /* @__PURE__ */ n.jsxs("div", { children: [
3999
- /* @__PURE__ */ n.jsx("div", { className: "text-sm font-semibold text-muted-foreground mb-1", children: "Stack Trace" }),
4000
- /* @__PURE__ */ n.jsx("pre", { className: "font-mono text-xs bg-muted p-3 rounded overflow-auto max-h-[300px]", children: t.join(`
4001
- `) })
4002
- ] })
4003
- ] }));
4004
- Ks.displayName = "JobErrorTab";
4005
- const Vs = z(() => {
4006
- const e = D((b) => b.selectedJob), t = D((b) => b.selectedQueue), s = D((b) => b.jobDetailOpen), r = D((b) => b.setJobDetailOpen), a = D((b) => b.setSelectedJob), o = Qs(), l = Is(), i = qs(), c = k(() => {
4007
- r(!1), a(null);
4008
- }, [r, a]), h = k(() => {
4009
- !t || !e || (o.mutate({ queueName: t.name, jobId: e.id }), c());
4010
- }, [t, e, o, c]), d = k(() => {
4011
- !t || !e || (l.mutate({ queueName: t.name, jobId: e.id }), c());
4012
- }, [t, e, l, c]), y = k(() => {
4013
- !t || !e || (i.mutate({ queueName: t.name, jobId: e.id }), c());
4014
- }, [t, e, i, c]);
4015
- if (!s || !e || !t) return null;
4016
- const f = !!e.failedReason, p = e.delay && e.delay > 0, m = e.returnvalue !== void 0 && e.returnvalue !== null, g = [
4017
- { label: "Data", content: /* @__PURE__ */ n.jsx(Hs, { data: e.data }) },
4018
- { label: "Options", content: /* @__PURE__ */ n.jsx(Ws, { opts: e.opts }) },
4019
- ...m ? [{ label: "Result", content: /* @__PURE__ */ n.jsx(zs, { returnvalue: e.returnvalue }) }] : [],
4020
- ...f ? [
4021
- {
4022
- label: "Error",
4023
- content: /* @__PURE__ */ n.jsx(Ks, { failedReason: e.failedReason, stacktrace: e.stacktrace })
4024
- }
4025
- ] : []
4026
- ], N = f ? /* @__PURE__ */ n.jsx("span", { className: "text-destructive", children: "Failed" }) : e.finishedOn ? /* @__PURE__ */ n.jsx("span", { className: "text-green-500", children: "Completed" }) : e.processedOn ? /* @__PURE__ */ n.jsx("span", { className: "text-yellow-500", children: "Processing" }) : p ? /* @__PURE__ */ n.jsx("span", { className: "text-purple-500", children: "Delayed" }) : /* @__PURE__ */ n.jsx("span", { className: "text-blue-500", children: "Waiting" });
4027
- return /* @__PURE__ */ n.jsx(
4028
- ps,
4029
- {
4030
- onClose: c,
4031
- title: e.name,
4032
- initialWidth: 600,
4033
- tabs: g,
4034
- actions: [{ icon: /* @__PURE__ */ n.jsx(yt, {}), onClick: c, label: "Close" }],
4035
- children: /* @__PURE__ */ n.jsxs("div", { className: "space-y-4", children: [
4036
- /* @__PURE__ */ n.jsxs("div", { className: "flex gap-2", children: [
4037
- f && /* @__PURE__ */ n.jsxs(X, { variant: "outline", size: "sm", onClick: h, children: [
4038
- /* @__PURE__ */ n.jsx(he, { className: "mr-2 h-4 w-4" }),
4039
- "Retry"
4040
- ] }),
4041
- p && /* @__PURE__ */ n.jsxs(X, { variant: "outline", size: "sm", onClick: y, children: [
4042
- /* @__PURE__ */ n.jsx($s, { className: "mr-2 h-4 w-4" }),
4043
- "Promote"
4044
- ] }),
4045
- /* @__PURE__ */ n.jsxs(X, { variant: "outline", size: "sm", onClick: d, className: "text-destructive", children: [
4046
- /* @__PURE__ */ n.jsx(be, { className: "mr-2 h-4 w-4" }),
4047
- "Remove"
4048
- ] })
4049
- ] }),
4050
- /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-2 gap-4 text-sm", children: [
4051
- /* @__PURE__ */ n.jsxs("div", { children: [
4052
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Job ID" }),
4053
- /* @__PURE__ */ n.jsx("div", { className: "font-mono text-xs", children: e.id })
4054
- ] }),
4055
- /* @__PURE__ */ n.jsxs("div", { children: [
4056
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Status" }),
4057
- /* @__PURE__ */ n.jsx("div", { className: "font-semibold", children: N })
4058
- ] }),
4059
- /* @__PURE__ */ n.jsxs("div", { children: [
4060
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Created" }),
4061
- /* @__PURE__ */ n.jsx("div", { children: qe(e.timestamp, { addSuffix: !0 }) })
4062
- ] }),
4063
- /* @__PURE__ */ n.jsxs("div", { children: [
4064
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Attempts" }),
4065
- /* @__PURE__ */ n.jsx("div", { className: "font-semibold", children: e.attemptsMade })
4066
- ] }),
4067
- /* @__PURE__ */ n.jsxs("div", { children: [
4068
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Progress" }),
4069
- /* @__PURE__ */ n.jsx("div", { className: "font-semibold", children: typeof e.progress == "number" ? `${e.progress}%` : "-" })
4070
- ] }),
4071
- /* @__PURE__ */ n.jsxs("div", { children: [
4072
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Delay" }),
4073
- /* @__PURE__ */ n.jsx("div", { className: "font-semibold", children: e.delay ? `${e.delay}ms` : "-" })
4074
- ] })
4075
- ] })
4076
- ] })
4077
- }
4078
- );
4079
- });
4080
- Vs.displayName = "JobDetail";
4081
- /**
4082
- * @license lucide-react v0.545.0 - ISC
4083
- *
4084
- * This source code is licensed under the ISC license.
4085
- * See the LICENSE file in the root directory of this source tree.
4086
- */
4087
- const Qa = [
4088
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
4089
- ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
4090
- ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
4091
- ], Bs = se("ellipsis-vertical", Qa);
4092
- /**
4093
- * @license lucide-react v0.545.0 - ISC
4094
- *
4095
- * This source code is licensed under the ISC license.
4096
- * See the LICENSE file in the root directory of this source tree.
4097
- */
4098
- const Ia = [
4099
- ["rect", { x: "14", y: "3", width: "5", height: "18", rx: "1", key: "kaeet6" }],
4100
- ["rect", { x: "5", y: "3", width: "5", height: "18", rx: "1", key: "1wsw3u" }]
4101
- ], Ys = se("pause", Ia);
4102
- /**
4103
- * @license lucide-react v0.545.0 - ISC
4104
- *
4105
- * This source code is licensed under the ISC license.
4106
- * See the LICENSE file in the root directory of this source tree.
4107
- */
4108
- const qa = [
4109
- [
4110
- "path",
4111
- {
4112
- d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
4113
- key: "10ikf1"
4114
- }
4115
- ]
4116
- ], La = se("play", qa), Zs = z(({ job: e, queueName: t, onSelect: s, isSelected: r }) => {
4117
- const a = Qs(), o = Is(), l = qs(), i = k(
4118
- (d) => {
4119
- d.stopPropagation(), a.mutate({ queueName: t, jobId: e.id });
4120
- },
4121
- [t, e.id, a]
4122
- ), c = k(
4123
- (d) => {
4124
- d.stopPropagation(), o.mutate({ queueName: t, jobId: e.id });
4125
- },
4126
- [t, e.id, o]
4127
- ), h = k(
4128
- (d) => {
4129
- d.stopPropagation(), l.mutate({ queueName: t, jobId: e.id });
4130
- },
4131
- [t, e.id, l]
4132
- );
4133
- return /* @__PURE__ */ n.jsxs(
4134
- Fe,
4135
- {
4136
- onClick: s,
4137
- className: ue(
4138
- "cursor-pointer border-0",
4139
- r ? "bg-muted-foreground/10 hover:bg-muted-foreground/20" : "hover:bg-muted-foreground/10"
4140
- ),
4141
- children: [
4142
- /* @__PURE__ */ n.jsx(te, { className: "font-mono text-xs", children: e.id }),
4143
- /* @__PURE__ */ n.jsx(te, { className: "font-medium", children: e.name }),
4144
- /* @__PURE__ */ n.jsx(te, { className: "text-xs text-muted-foreground", children: qe(e.timestamp, { addSuffix: !0 }) }),
4145
- /* @__PURE__ */ n.jsx(te, { children: /* @__PURE__ */ n.jsx("span", { className: "text-xs", children: e.attemptsMade }) }),
4146
- /* @__PURE__ */ n.jsx(te, { children: typeof e.progress == "number" ? /* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2", children: [
4147
- /* @__PURE__ */ n.jsx("div", { className: "w-16 h-1.5 bg-muted rounded-full overflow-hidden", children: /* @__PURE__ */ n.jsx("div", { className: "h-full bg-primary transition-all", style: { width: `${Math.min(100, e.progress)}%` } }) }),
4148
- /* @__PURE__ */ n.jsxs("span", { className: "text-xs text-muted-foreground", children: [
4149
- e.progress,
4150
- "%"
4151
- ] })
4152
- ] }) : /* @__PURE__ */ n.jsx("span", { className: "text-xs text-muted-foreground", children: "-" }) }),
4153
- /* @__PURE__ */ n.jsx(te, { onClick: (d) => d.stopPropagation(), children: /* @__PURE__ */ n.jsxs(ys, { children: [
4154
- /* @__PURE__ */ n.jsx(gs, { asChild: !0, children: /* @__PURE__ */ n.jsx(X, { variant: "ghost", size: "icon", className: "h-8 w-8", children: /* @__PURE__ */ n.jsx(Bs, { className: "h-4 w-4" }) }) }),
4155
- /* @__PURE__ */ n.jsxs(vs, { align: "end", children: [
4156
- e.failedReason && /* @__PURE__ */ n.jsxs(ve, { onClick: i, children: [
4157
- /* @__PURE__ */ n.jsx(he, { className: "mr-2 h-4 w-4" }),
4158
- "Retry"
4159
- ] }),
4160
- e.delay && e.delay > 0 && /* @__PURE__ */ n.jsxs(ve, { onClick: h, children: [
4161
- /* @__PURE__ */ n.jsx($s, { className: "mr-2 h-4 w-4" }),
4162
- "Promote"
4163
- ] }),
4164
- /* @__PURE__ */ n.jsxs(ve, { onClick: c, className: "text-destructive", children: [
4165
- /* @__PURE__ */ n.jsx(be, { className: "mr-2 h-4 w-4" }),
4166
- "Remove"
4167
- ] })
4168
- ] })
4169
- ] }) })
4170
- ]
4171
- }
4172
- );
4173
- });
4174
- Zs.displayName = "JobRow";
4175
- const Xs = z(() => {
4176
- const { data: e = [], isLoading: t } = Aa(), s = D((i) => i.selectedQueue), r = D((i) => i.selectedJob), a = D((i) => i.setSelectedJob), o = D((i) => i.setJobDetailOpen), l = k(
4177
- (i) => {
4178
- a(i), o(!0);
4179
- },
4180
- [a, o]
4181
- );
4182
- return s ? t ? /* @__PURE__ */ n.jsx("div", { className: "flex items-center justify-center h-full text-muted-foreground", children: "Loading jobs..." }) : e.length === 0 ? /* @__PURE__ */ n.jsx("div", { className: "flex items-center justify-center h-full text-muted-foreground", children: "No jobs in this status" }) : /* @__PURE__ */ n.jsxs(hs, { children: [
4183
- /* @__PURE__ */ n.jsx(fs, { className: "sticky top-0 bg-background/95 backdrop-blur-sm", children: /* @__PURE__ */ n.jsxs(Fe, { children: [
4184
- /* @__PURE__ */ n.jsx(ee, { className: "w-[200px]", children: "Job ID" }),
4185
- /* @__PURE__ */ n.jsx(ee, { children: "Name" }),
4186
- /* @__PURE__ */ n.jsx(ee, { className: "w-[150px]", children: "Created" }),
4187
- /* @__PURE__ */ n.jsx(ee, { className: "w-[80px]", children: "Attempts" }),
4188
- /* @__PURE__ */ n.jsx(ee, { className: "w-[140px]", children: "Progress" }),
4189
- /* @__PURE__ */ n.jsx(ee, { className: "w-[60px]", children: "Actions" })
4190
- ] }) }),
4191
- /* @__PURE__ */ n.jsx(ms, { children: e.map((i) => /* @__PURE__ */ n.jsx(
4192
- Zs,
4193
- {
4194
- job: i,
4195
- queueName: s.name,
4196
- onSelect: () => l(i),
4197
- isSelected: r?.id === i.id
4198
- },
4199
- i.id
4200
- )) })
4201
- ] }) : /* @__PURE__ */ n.jsx("div", { className: "flex items-center justify-center h-full text-muted-foreground", children: "Select a queue to view jobs" });
4202
- });
4203
- Xs.displayName = "JobsTable";
4204
- const Ua = [
4205
- { value: "waiting", label: "Waiting" },
4206
- { value: "active", label: "Active" },
4207
- { value: "completed", label: "Completed" },
4208
- { value: "failed", label: "Failed" },
4209
- { value: "delayed", label: "Delayed" }
4210
- ], Gs = z(() => {
4211
- const e = ne(), t = D((m) => m.selectedQueue), s = D((m) => m.selectedStatus), r = D((m) => m.setSelectedStatus), { pauseQueue: a, resumeQueue: o, cleanQueue: l, drainQueue: i } = bs(), c = k(async () => {
4212
- t && await a(t.name);
4213
- }, [t, a]), h = k(async () => {
4214
- t && await o(t.name);
4215
- }, [t, o]), d = k(async () => {
4216
- t && await l(t.name, "completed", 0, 1e3);
4217
- }, [t, l]), y = k(async () => {
4218
- t && await l(t.name, "failed", 0, 1e3);
4219
- }, [t, l]), f = k(async () => {
4220
- t && await i(t.name);
4221
- }, [t, i]), p = k(() => {
4222
- t && e.invalidateQueries({ queryKey: ["jobs", t.name] });
4223
- }, [t, e]);
4224
- return t ? /* @__PURE__ */ n.jsx(ds, { children: /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col h-full", children: [
4225
- /* @__PURE__ */ n.jsxs("div", { className: "flex items-center justify-between p-3 border-b border-border", children: [
4226
- /* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-3", children: [
4227
- /* @__PURE__ */ n.jsx("h2", { className: "font-semibold text-lg", children: t.displayName }),
4228
- t.isPaused && /* @__PURE__ */ n.jsx("span", { className: "px-2 py-0.5 text-xs rounded bg-yellow-500/20 text-yellow-600", children: "Paused" })
4229
- ] }),
4230
- /* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2", children: [
4231
- /* @__PURE__ */ n.jsxs(re, { children: [
4232
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsx(X, { variant: "ghost", size: "icon", onClick: p, children: /* @__PURE__ */ n.jsx(he, { className: "h-4 w-4" }) }) }),
4233
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Refresh queue stats and jobs list" }) })
4234
- ] }),
4235
- t.isPaused ? /* @__PURE__ */ n.jsxs(re, { children: [
4236
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsxs(X, { variant: "ghost", size: "sm", onClick: h, children: [
4237
- /* @__PURE__ */ n.jsx(La, { className: "mr-2 h-4 w-4" }),
4238
- "Resume"
4239
- ] }) }),
4240
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Resume processing jobs in this queue" }) })
4241
- ] }) : /* @__PURE__ */ n.jsxs(re, { children: [
4242
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsxs(X, { variant: "ghost", size: "sm", onClick: c, children: [
4243
- /* @__PURE__ */ n.jsx(Ys, { className: "mr-2 h-4 w-4" }),
4244
- "Pause"
4245
- ] }) }),
4246
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "Stop workers from picking up new jobs" }) })
4247
- ] }),
4248
- /* @__PURE__ */ n.jsxs(re, { children: [
4249
- /* @__PURE__ */ n.jsx(ae, { asChild: !0, children: /* @__PURE__ */ n.jsxs(ys, { children: [
4250
- /* @__PURE__ */ n.jsx(gs, { asChild: !0, children: /* @__PURE__ */ n.jsx(X, { variant: "ghost", size: "icon", children: /* @__PURE__ */ n.jsx(Bs, { className: "h-4 w-4" }) }) }),
4251
- /* @__PURE__ */ n.jsxs(vs, { align: "end", children: [
4252
- /* @__PURE__ */ n.jsxs(ve, { onClick: d, children: [
4253
- /* @__PURE__ */ n.jsx(be, { className: "mr-2 h-4 w-4" }),
4254
- "Clean Completed"
4255
- ] }),
4256
- /* @__PURE__ */ n.jsxs(ve, { onClick: y, children: [
4257
- /* @__PURE__ */ n.jsx(be, { className: "mr-2 h-4 w-4" }),
4258
- "Clean Failed"
4259
- ] }),
4260
- /* @__PURE__ */ n.jsx(on, {}),
4261
- /* @__PURE__ */ n.jsxs(ve, { onClick: f, className: "text-destructive", children: [
4262
- /* @__PURE__ */ n.jsx(be, { className: "mr-2 h-4 w-4" }),
4263
- "Drain Queue"
4264
- ] })
4265
- ] })
4266
- ] }) }),
4267
- /* @__PURE__ */ n.jsx(ie, { children: /* @__PURE__ */ n.jsx("p", { children: "More actions" }) })
4268
- ] })
4269
- ] })
4270
- ] }),
4271
- /* @__PURE__ */ n.jsx("div", { className: "p-3 border-b border-border", children: /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-6 gap-4 text-center", children: [
4272
- /* @__PURE__ */ n.jsxs("div", { children: [
4273
- /* @__PURE__ */ n.jsx("div", { className: "text-2xl font-bold text-blue-500", children: t.stats.waiting }),
4274
- /* @__PURE__ */ n.jsx("div", { className: "text-xs text-muted-foreground", children: "Waiting" })
4275
- ] }),
4276
- /* @__PURE__ */ n.jsxs("div", { children: [
4277
- /* @__PURE__ */ n.jsx("div", { className: "text-2xl font-bold text-yellow-500", children: t.stats.active }),
4278
- /* @__PURE__ */ n.jsx("div", { className: "text-xs text-muted-foreground", children: "Active" })
4279
- ] }),
4280
- /* @__PURE__ */ n.jsxs("div", { children: [
4281
- /* @__PURE__ */ n.jsx("div", { className: "text-2xl font-bold text-green-500", children: t.stats.completed }),
4282
- /* @__PURE__ */ n.jsx("div", { className: "text-xs text-muted-foreground", children: "Completed" })
4283
- ] }),
4284
- /* @__PURE__ */ n.jsxs("div", { children: [
4285
- /* @__PURE__ */ n.jsx("div", { className: "text-2xl font-bold text-destructive", children: t.stats.failed }),
4286
- /* @__PURE__ */ n.jsx("div", { className: "text-xs text-muted-foreground", children: "Failed" })
4287
- ] }),
4288
- /* @__PURE__ */ n.jsxs("div", { children: [
4289
- /* @__PURE__ */ n.jsx("div", { className: "text-2xl font-bold text-purple-500", children: t.stats.delayed }),
4290
- /* @__PURE__ */ n.jsx("div", { className: "text-xs text-muted-foreground", children: "Delayed" })
4291
- ] }),
4292
- /* @__PURE__ */ n.jsxs("div", { children: [
4293
- /* @__PURE__ */ n.jsx("div", { className: "text-2xl font-bold text-muted-foreground", children: t.stats.paused }),
4294
- /* @__PURE__ */ n.jsx("div", { className: "text-xs text-muted-foreground", children: "Paused" })
4295
- ] })
4296
- ] }) }),
4297
- /* @__PURE__ */ n.jsxs(
4298
- ln,
4299
- {
4300
- value: s,
4301
- onValueChange: (m) => r(m),
4302
- className: "flex-1 flex flex-col",
4303
- children: [
4304
- /* @__PURE__ */ n.jsx("div", { className: "px-3 pt-2 border-b border-border", children: /* @__PURE__ */ n.jsx(cn, { children: Ua.map((m) => /* @__PURE__ */ n.jsxs(
4305
- un,
4306
- {
4307
- value: m.value,
4308
- className: ue(
4309
- "relative",
4310
- s === m.value && "after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:bg-primary"
4311
- ),
4312
- children: [
4313
- m.label,
4314
- t.stats[m.value] > 0 && /* @__PURE__ */ n.jsx("span", { className: "ml-1.5 px-1.5 py-0.5 text-[10px] rounded-full bg-muted", children: t.stats[m.value] })
4315
- ]
4316
- },
4317
- m.value
4318
- )) }) }),
4319
- /* @__PURE__ */ n.jsx("div", { className: "flex-1 overflow-auto", children: /* @__PURE__ */ n.jsx(Xs, {}) })
4320
- ]
4321
- }
4322
- )
4323
- ] }) }) : /* @__PURE__ */ n.jsx("div", { className: "flex items-center justify-center h-full text-muted-foreground", children: "Select a queue from the list to view details" });
4324
- });
4325
- Gs.displayName = "QueueDetail";
4326
- /**
4327
- * @license lucide-react v0.545.0 - ISC
4328
- *
4329
- * This source code is licensed under the ISC license.
4330
- * See the LICENSE file in the root directory of this source tree.
4331
- */
4332
- const Ja = [
4333
- [
4334
- "path",
4335
- {
4336
- d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
4337
- key: "wmoenq"
4338
- }
4339
- ],
4340
- ["path", { d: "M12 9v4", key: "juzpu7" }],
4341
- ["path", { d: "M12 17h.01", key: "p32p05" }]
4342
- ], $a = se("triangle-alert", Ja);
4343
- /**
4344
- * @license lucide-react v0.545.0 - ISC
4345
- *
4346
- * This source code is licensed under the ISC license.
4347
- * See the LICENSE file in the root directory of this source tree.
4348
- */
4349
- const Ha = [
4350
- [
4351
- "path",
4352
- {
4353
- d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
4354
- key: "zw3jo"
4355
- }
4356
- ],
4357
- [
4358
- "path",
4359
- {
4360
- d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
4361
- key: "1wduqc"
4362
- }
4363
- ],
4364
- [
4365
- "path",
4366
- {
4367
- d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
4368
- key: "kqbvx6"
4369
- }
4370
- ]
4371
- ], Wa = se("layers", Ha);
4372
- /**
4373
- * @license lucide-react v0.545.0 - ISC
4374
- *
4375
- * This source code is licensed under the ISC license.
4376
- * See the LICENSE file in the root directory of this source tree.
4377
- */
4378
- const za = [
4379
- ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
4380
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
4381
- ], Ka = se("search", za);
4382
- /**
4383
- * @license lucide-react v0.545.0 - ISC
4384
- *
4385
- * This source code is licensed under the ISC license.
4386
- * See the LICENSE file in the root directory of this source tree.
4387
- */
4388
- const Va = [
4389
- ["path", { d: "m12.5 17-.5-1-.5 1h1z", key: "3me087" }],
4390
- [
4391
- "path",
4392
- {
4393
- d: "M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",
4394
- key: "1o5pge"
4395
- }
4396
- ],
4397
- ["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
4398
- ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }]
4399
- ], Ba = se("skull", Va), dt = z(({ queue: e, isSelected: t, onClick: s }) => {
4400
- const r = e.stats.waiting + e.stats.active + e.stats.delayed + e.stats.prioritized, a = e.stats.failed > 0;
4401
- return /* @__PURE__ */ n.jsxs(
4402
- "button",
4403
- {
4404
- type: "button",
4405
- onClick: s,
4406
- className: ue(
4407
- "w-full text-left p-3 transition-colors border-b border-border",
4408
- t ? "bg-muted-foreground/10" : "hover:bg-muted/70"
4409
- ),
4410
- children: [
4411
- /* @__PURE__ */ n.jsxs("div", { className: "flex items-center gap-2 mb-1", children: [
4412
- e.isDLQ ? /* @__PURE__ */ n.jsx(Ba, { className: "w-4 h-4 text-destructive" }) : /* @__PURE__ */ n.jsx(Wa, { className: "w-4 h-4 text-muted-foreground" }),
4413
- /* @__PURE__ */ n.jsx("span", { className: "font-semibold text-sm truncate flex-1", children: e.displayName }),
4414
- e.isPaused && /* @__PURE__ */ n.jsx(Ys, { className: "w-3 h-3 text-yellow-500" }),
4415
- a && /* @__PURE__ */ n.jsx($a, { className: "w-3 h-3 text-destructive" })
4416
- ] }),
4417
- /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-4 gap-1 text-xs", children: [
4418
- /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col", children: [
4419
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Wait" }),
4420
- /* @__PURE__ */ n.jsx("span", { className: ue("font-mono", e.stats.waiting > 0 && "text-blue-500"), children: e.stats.waiting })
4421
- ] }),
4422
- /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col", children: [
4423
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Active" }),
4424
- /* @__PURE__ */ n.jsx("span", { className: ue("font-mono", e.stats.active > 0 && "text-yellow-500"), children: e.stats.active })
4425
- ] }),
4426
- /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col", children: [
4427
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Done" }),
4428
- /* @__PURE__ */ n.jsx("span", { className: ue("font-mono", e.stats.completed > 0 && "text-green-500"), children: e.stats.completed })
4429
- ] }),
4430
- /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col", children: [
4431
- /* @__PURE__ */ n.jsx("span", { className: "text-muted-foreground", children: "Failed" }),
4432
- /* @__PURE__ */ n.jsx("span", { className: ue("font-mono", e.stats.failed > 0 && "text-destructive"), children: e.stats.failed })
4433
- ] })
4434
- ] }),
4435
- (e.stats.delayed > 0 || r > 0) && /* @__PURE__ */ n.jsxs("div", { className: "flex gap-2 mt-1 text-xs text-muted-foreground", children: [
4436
- e.stats.delayed > 0 && /* @__PURE__ */ n.jsxs("span", { children: [
4437
- e.stats.delayed,
4438
- " delayed"
4439
- ] }),
4440
- r > 0 && /* @__PURE__ */ n.jsxs("span", { className: "ml-auto", children: [
4441
- r,
4442
- " pending"
4443
- ] })
4444
- ] })
4445
- ]
4446
- }
4447
- );
4448
- });
4449
- dt.displayName = "QueueItem";
4450
- const en = z(() => {
4451
- const e = D((c) => c.queues), t = D((c) => c.selectedQueue), s = D((c) => c.setSelectedQueue), r = D((c) => c.searchQuery), a = D((c) => c.setSearchQuery), o = Te(() => {
4452
- if (!r) return e;
4453
- const c = r.toLowerCase();
4454
- return e.filter((h) => h.name.toLowerCase().includes(c) || h.displayName.toLowerCase().includes(c));
4455
- }, [e, r]), l = Te(() => o.filter((c) => !c.isDLQ), [o]), i = Te(() => o.filter((c) => c.isDLQ), [o]);
4456
- return /* @__PURE__ */ n.jsxs("div", { className: "flex flex-col h-full", children: [
4457
- /* @__PURE__ */ n.jsx("div", { className: "p-2 border-b border-border", children: /* @__PURE__ */ n.jsxs("div", { className: "relative", children: [
4458
- /* @__PURE__ */ n.jsx(
4459
- dn,
4460
- {
4461
- variant: "shade",
4462
- value: r,
4463
- onChange: (c) => a(c.target.value),
4464
- className: "px-9 font-medium text-sm",
4465
- placeholder: "Search queues..."
4466
- }
4467
- ),
4468
- /* @__PURE__ */ n.jsx(Ka, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50" }),
4469
- r && /* @__PURE__ */ n.jsx(
4470
- yt,
4471
- {
4472
- className: "cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",
4473
- onClick: () => a("")
4474
- }
4475
- )
4476
- ] }) }),
4477
- /* @__PURE__ */ n.jsxs("div", { className: "flex-1 overflow-auto", children: [
4478
- l.length > 0 && /* @__PURE__ */ n.jsxs("div", { children: [
4479
- /* @__PURE__ */ n.jsxs("div", { className: "px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider bg-muted/30", children: [
4480
- "Queues (",
4481
- l.length,
4482
- ")"
4483
- ] }),
4484
- l.map((c) => /* @__PURE__ */ n.jsx(
4485
- dt,
4486
- {
4487
- queue: c,
4488
- isSelected: t?.name === c.name,
4489
- onClick: () => s(c)
4490
- },
4491
- c.name
4492
- ))
4493
- ] }),
4494
- i.length > 0 && /* @__PURE__ */ n.jsxs("div", { children: [
4495
- /* @__PURE__ */ n.jsxs("div", { className: "px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider bg-destructive/10", children: [
4496
- "Dead Letter Queues (",
4497
- i.length,
4498
- ")"
4499
- ] }),
4500
- i.map((c) => /* @__PURE__ */ n.jsx(
4501
- dt,
4502
- {
4503
- queue: c,
4504
- isSelected: t?.name === c.name,
4505
- onClick: () => s(c)
4506
- },
4507
- c.name
4508
- ))
4509
- ] }),
4510
- o.length === 0 && /* @__PURE__ */ n.jsx("div", { className: "p-4 text-center text-muted-foreground text-sm", children: r ? "No queues match your search" : "No queues found" })
4511
- ] })
4512
- ] });
4513
- });
4514
- en.displayName = "QueueList";
4515
- const tn = z(() => {
4516
- const e = D((r) => r.selectedQueue), t = D((r) => r.updateSelectedQueueStats), { queues: s } = bs();
4517
- return ke(() => {
4518
- if (e) {
4519
- const r = s.find((a) => a.name === e.name);
4520
- r && t(r);
4521
- }
4522
- }, [s, e, t]), /* @__PURE__ */ n.jsxs("div", { className: "grid grid-cols-[300px_1fr] h-full overflow-hidden", children: [
4523
- /* @__PURE__ */ n.jsx("div", { className: "border-r border-border overflow-hidden", children: /* @__PURE__ */ n.jsx(en, {}) }),
4524
- /* @__PURE__ */ n.jsx("div", { className: "overflow-hidden", children: e?.isDLQ ? /* @__PURE__ */ n.jsx(Js, {}) : /* @__PURE__ */ n.jsx(Gs, {}) }),
4525
- /* @__PURE__ */ n.jsx(Vs, {})
4526
- ] });
4527
- });
4528
- tn.displayName = "QueuesPageContent";
4529
- const Ya = z(() => /* @__PURE__ */ n.jsx(sr, { children: /* @__PURE__ */ n.jsx(tn, {}) }));
4530
- Ya.displayName = "QueuesPage";
4531
- export {
4532
- Ya as QueuesPage
4533
- };