@autogames/sdk 1.2.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autogames-sdk.esm.js +1 -1
- package/dist/autogames-sdk.js +483 -483
- package/dist/{basic-CX_SLrXD.js → basic-DsUk1yju.js} +4 -4
- package/dist/{bridge-mount-CWHdoUW-.js → bridge-mount-FZvmk0-F.js} +36475 -26284
- package/dist/{ccip-qoKRUuU4.js → ccip-BUftQff6.js} +1 -1
- package/dist/chat-mount-SHiAmGqS.js +54 -0
- package/dist/{core-CvTNuh95.js → core-vSvn2d7W.js} +6 -6
- package/dist/{features-CvmBsK4Z.js → features-CN9CGh2p.js} +1 -1
- package/dist/{index-CdNZo-Hc.js → index-C7GvpVec.js} +2 -2
- package/dist/{index-YZZeCzJW.js → index-CGVyS_an.js} +1 -1
- package/dist/{index-BDOF-uep.js → index-DCrq_-Sk.js} +4 -4
- package/dist/{main-DBE9yqee.js → main-WFUU9G7G.js} +218 -206
- package/dist/main.d.ts +9 -2
- package/dist/{parseSignature-Brkx4zaC.js → parseSignature-Di33-DjX.js} +1 -1
- package/dist/{secp256k1-BNkeet6Q.js → secp256k1-CQV8E5Pv.js} +1 -1
- package/dist/stats-confirm.html +1 -1
- package/dist/{w3m-modal-0BRLpsIo.js → w3m-modal-BNIIM0f0.js} +2 -2
- package/package.json +3 -2
- package/dist/chat-mount-gXq-EZa2.js +0 -2744
- package/dist/index-BfOurzzw.js +0 -10194
|
@@ -1,2744 +0,0 @@
|
|
|
1
|
-
import { j as h, r as Ee, c as Pe } from "./index-BfOurzzw.js";
|
|
2
|
-
import { a as f, b as kt, A as Zt, u as pt } from "./main-DBE9yqee.js";
|
|
3
|
-
var Z = class {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
|
|
6
|
-
}
|
|
7
|
-
subscribe(t) {
|
|
8
|
-
return this.listeners.add(t), this.onSubscribe(), () => {
|
|
9
|
-
this.listeners.delete(t), this.onUnsubscribe();
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
hasListeners() {
|
|
13
|
-
return this.listeners.size > 0;
|
|
14
|
-
}
|
|
15
|
-
onSubscribe() {
|
|
16
|
-
}
|
|
17
|
-
onUnsubscribe() {
|
|
18
|
-
}
|
|
19
|
-
}, Me = {
|
|
20
|
-
// We need the wrapper function syntax below instead of direct references to
|
|
21
|
-
// global setTimeout etc.
|
|
22
|
-
//
|
|
23
|
-
// BAD: `setTimeout: setTimeout`
|
|
24
|
-
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
25
|
-
//
|
|
26
|
-
// If we use direct references here, then anything that wants to spy on or
|
|
27
|
-
// replace the global setTimeout (like tests) won't work since we'll already
|
|
28
|
-
// have a hard reference to the original implementation at the time when this
|
|
29
|
-
// file was imported.
|
|
30
|
-
setTimeout: (t, e) => setTimeout(t, e),
|
|
31
|
-
clearTimeout: (t) => clearTimeout(t),
|
|
32
|
-
setInterval: (t, e) => setInterval(t, e),
|
|
33
|
-
clearInterval: (t) => clearInterval(t)
|
|
34
|
-
}, je = class {
|
|
35
|
-
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
36
|
-
// type at app boot; and if we leave that type, then any new timer provider
|
|
37
|
-
// would need to support ReturnType<typeof setTimeout>, which is infeasible.
|
|
38
|
-
//
|
|
39
|
-
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
40
|
-
// this class is unsafe internally to allow for extension.
|
|
41
|
-
#t = Me;
|
|
42
|
-
#e = !1;
|
|
43
|
-
setTimeoutProvider(t) {
|
|
44
|
-
this.#t = t;
|
|
45
|
-
}
|
|
46
|
-
setTimeout(t, e) {
|
|
47
|
-
return this.#t.setTimeout(t, e);
|
|
48
|
-
}
|
|
49
|
-
clearTimeout(t) {
|
|
50
|
-
this.#t.clearTimeout(t);
|
|
51
|
-
}
|
|
52
|
-
setInterval(t, e) {
|
|
53
|
-
return this.#t.setInterval(t, e);
|
|
54
|
-
}
|
|
55
|
-
clearInterval(t) {
|
|
56
|
-
this.#t.clearInterval(t);
|
|
57
|
-
}
|
|
58
|
-
}, G = new je();
|
|
59
|
-
function Ne(t) {
|
|
60
|
-
setTimeout(t, 0);
|
|
61
|
-
}
|
|
62
|
-
var V = typeof window > "u" || "Deno" in globalThis;
|
|
63
|
-
function L() {
|
|
64
|
-
}
|
|
65
|
-
function Ie(t, e) {
|
|
66
|
-
return typeof t == "function" ? t(e) : t;
|
|
67
|
-
}
|
|
68
|
-
function yt(t) {
|
|
69
|
-
return typeof t == "number" && t >= 0 && t !== 1 / 0;
|
|
70
|
-
}
|
|
71
|
-
function te(t, e) {
|
|
72
|
-
return Math.max(t + (e || 0) - Date.now(), 0);
|
|
73
|
-
}
|
|
74
|
-
function H(t, e) {
|
|
75
|
-
return typeof t == "function" ? t(e) : t;
|
|
76
|
-
}
|
|
77
|
-
function _(t, e) {
|
|
78
|
-
return typeof t == "function" ? t(e) : t;
|
|
79
|
-
}
|
|
80
|
-
function Dt(t, e) {
|
|
81
|
-
const {
|
|
82
|
-
type: s = "all",
|
|
83
|
-
exact: r,
|
|
84
|
-
fetchStatus: i,
|
|
85
|
-
predicate: n,
|
|
86
|
-
queryKey: o,
|
|
87
|
-
stale: a
|
|
88
|
-
} = t;
|
|
89
|
-
if (o) {
|
|
90
|
-
if (r) {
|
|
91
|
-
if (e.queryHash !== Et(o, e.options))
|
|
92
|
-
return !1;
|
|
93
|
-
} else if (!st(e.queryKey, o))
|
|
94
|
-
return !1;
|
|
95
|
-
}
|
|
96
|
-
if (s !== "all") {
|
|
97
|
-
const u = e.isActive();
|
|
98
|
-
if (s === "active" && !u || s === "inactive" && u)
|
|
99
|
-
return !1;
|
|
100
|
-
}
|
|
101
|
-
return !(typeof a == "boolean" && e.isStale() !== a || i && i !== e.state.fetchStatus || n && !n(e));
|
|
102
|
-
}
|
|
103
|
-
function Qt(t, e) {
|
|
104
|
-
const { exact: s, status: r, predicate: i, mutationKey: n } = t;
|
|
105
|
-
if (n) {
|
|
106
|
-
if (!e.options.mutationKey)
|
|
107
|
-
return !1;
|
|
108
|
-
if (s) {
|
|
109
|
-
if (Y(e.options.mutationKey) !== Y(n))
|
|
110
|
-
return !1;
|
|
111
|
-
} else if (!st(e.options.mutationKey, n))
|
|
112
|
-
return !1;
|
|
113
|
-
}
|
|
114
|
-
return !(r && e.state.status !== r || i && !i(e));
|
|
115
|
-
}
|
|
116
|
-
function Et(t, e) {
|
|
117
|
-
return (e?.queryKeyHashFn || Y)(t);
|
|
118
|
-
}
|
|
119
|
-
function Y(t) {
|
|
120
|
-
return JSON.stringify(
|
|
121
|
-
t,
|
|
122
|
-
(e, s) => vt(s) ? Object.keys(s).sort().reduce((r, i) => (r[i] = s[i], r), {}) : s
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
function st(t, e) {
|
|
126
|
-
return t === e ? !0 : typeof t != typeof e ? !1 : t && e && typeof t == "object" && typeof e == "object" ? Object.keys(e).every((s) => st(t[s], e[s])) : !1;
|
|
127
|
-
}
|
|
128
|
-
var Te = Object.prototype.hasOwnProperty;
|
|
129
|
-
function ee(t, e) {
|
|
130
|
-
if (t === e)
|
|
131
|
-
return t;
|
|
132
|
-
const s = $t(t) && $t(e);
|
|
133
|
-
if (!s && !(vt(t) && vt(e))) return e;
|
|
134
|
-
const i = (s ? t : Object.keys(t)).length, n = s ? e : Object.keys(e), o = n.length, a = s ? new Array(o) : {};
|
|
135
|
-
let u = 0;
|
|
136
|
-
for (let l = 0; l < o; l++) {
|
|
137
|
-
const c = s ? l : n[l], p = t[c], d = e[c];
|
|
138
|
-
if (p === d) {
|
|
139
|
-
a[c] = p, (s ? l < i : Te.call(t, c)) && u++;
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
if (p === null || d === null || typeof p != "object" || typeof d != "object") {
|
|
143
|
-
a[c] = d;
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
const S = ee(p, d);
|
|
147
|
-
a[c] = S, S === p && u++;
|
|
148
|
-
}
|
|
149
|
-
return i === o && u === i ? t : a;
|
|
150
|
-
}
|
|
151
|
-
function ut(t, e) {
|
|
152
|
-
if (!e || Object.keys(t).length !== Object.keys(e).length)
|
|
153
|
-
return !1;
|
|
154
|
-
for (const s in t)
|
|
155
|
-
if (t[s] !== e[s])
|
|
156
|
-
return !1;
|
|
157
|
-
return !0;
|
|
158
|
-
}
|
|
159
|
-
function $t(t) {
|
|
160
|
-
return Array.isArray(t) && t.length === Object.keys(t).length;
|
|
161
|
-
}
|
|
162
|
-
function vt(t) {
|
|
163
|
-
if (!Lt(t))
|
|
164
|
-
return !1;
|
|
165
|
-
const e = t.constructor;
|
|
166
|
-
if (e === void 0)
|
|
167
|
-
return !0;
|
|
168
|
-
const s = e.prototype;
|
|
169
|
-
return !(!Lt(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(t) !== Object.prototype);
|
|
170
|
-
}
|
|
171
|
-
function Lt(t) {
|
|
172
|
-
return Object.prototype.toString.call(t) === "[object Object]";
|
|
173
|
-
}
|
|
174
|
-
function Fe(t) {
|
|
175
|
-
return new Promise((e) => {
|
|
176
|
-
G.setTimeout(e, t);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function bt(t, e, s) {
|
|
180
|
-
return typeof s.structuralSharing == "function" ? s.structuralSharing(t, e) : s.structuralSharing !== !1 ? ee(t, e) : e;
|
|
181
|
-
}
|
|
182
|
-
function Ae(t, e, s = 0) {
|
|
183
|
-
const r = [...t, e];
|
|
184
|
-
return s && r.length > s ? r.slice(1) : r;
|
|
185
|
-
}
|
|
186
|
-
function De(t, e, s = 0) {
|
|
187
|
-
const r = [e, ...t];
|
|
188
|
-
return s && r.length > s ? r.slice(0, -1) : r;
|
|
189
|
-
}
|
|
190
|
-
var Pt = Symbol();
|
|
191
|
-
function se(t, e) {
|
|
192
|
-
return !t.queryFn && e?.initialPromise ? () => e.initialPromise : !t.queryFn || t.queryFn === Pt ? () => Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)) : t.queryFn;
|
|
193
|
-
}
|
|
194
|
-
function re(t, e) {
|
|
195
|
-
return typeof t == "function" ? t(...e) : !!t;
|
|
196
|
-
}
|
|
197
|
-
var Qe = class extends Z {
|
|
198
|
-
#t;
|
|
199
|
-
#e;
|
|
200
|
-
#s;
|
|
201
|
-
constructor() {
|
|
202
|
-
super(), this.#s = (t) => {
|
|
203
|
-
if (!V && window.addEventListener) {
|
|
204
|
-
const e = () => t();
|
|
205
|
-
return window.addEventListener("visibilitychange", e, !1), () => {
|
|
206
|
-
window.removeEventListener("visibilitychange", e);
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
onSubscribe() {
|
|
212
|
-
this.#e || this.setEventListener(this.#s);
|
|
213
|
-
}
|
|
214
|
-
onUnsubscribe() {
|
|
215
|
-
this.hasListeners() || (this.#e?.(), this.#e = void 0);
|
|
216
|
-
}
|
|
217
|
-
setEventListener(t) {
|
|
218
|
-
this.#s = t, this.#e?.(), this.#e = t((e) => {
|
|
219
|
-
typeof e == "boolean" ? this.setFocused(e) : this.onFocus();
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
setFocused(t) {
|
|
223
|
-
this.#t !== t && (this.#t = t, this.onFocus());
|
|
224
|
-
}
|
|
225
|
-
onFocus() {
|
|
226
|
-
const t = this.isFocused();
|
|
227
|
-
this.listeners.forEach((e) => {
|
|
228
|
-
e(t);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
isFocused() {
|
|
232
|
-
return typeof this.#t == "boolean" ? this.#t : globalThis.document?.visibilityState !== "hidden";
|
|
233
|
-
}
|
|
234
|
-
}, Mt = new Qe();
|
|
235
|
-
function xt() {
|
|
236
|
-
let t, e;
|
|
237
|
-
const s = new Promise((i, n) => {
|
|
238
|
-
t = i, e = n;
|
|
239
|
-
});
|
|
240
|
-
s.status = "pending", s.catch(() => {
|
|
241
|
-
});
|
|
242
|
-
function r(i) {
|
|
243
|
-
Object.assign(s, i), delete s.resolve, delete s.reject;
|
|
244
|
-
}
|
|
245
|
-
return s.resolve = (i) => {
|
|
246
|
-
r({
|
|
247
|
-
status: "fulfilled",
|
|
248
|
-
value: i
|
|
249
|
-
}), t(i);
|
|
250
|
-
}, s.reject = (i) => {
|
|
251
|
-
r({
|
|
252
|
-
status: "rejected",
|
|
253
|
-
reason: i
|
|
254
|
-
}), e(i);
|
|
255
|
-
}, s;
|
|
256
|
-
}
|
|
257
|
-
var $e = Ne;
|
|
258
|
-
function Le() {
|
|
259
|
-
let t = [], e = 0, s = (a) => {
|
|
260
|
-
a();
|
|
261
|
-
}, r = (a) => {
|
|
262
|
-
a();
|
|
263
|
-
}, i = $e;
|
|
264
|
-
const n = (a) => {
|
|
265
|
-
e ? t.push(a) : i(() => {
|
|
266
|
-
s(a);
|
|
267
|
-
});
|
|
268
|
-
}, o = () => {
|
|
269
|
-
const a = t;
|
|
270
|
-
t = [], a.length && i(() => {
|
|
271
|
-
r(() => {
|
|
272
|
-
a.forEach((u) => {
|
|
273
|
-
s(u);
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
return {
|
|
279
|
-
batch: (a) => {
|
|
280
|
-
let u;
|
|
281
|
-
e++;
|
|
282
|
-
try {
|
|
283
|
-
u = a();
|
|
284
|
-
} finally {
|
|
285
|
-
e--, e || o();
|
|
286
|
-
}
|
|
287
|
-
return u;
|
|
288
|
-
},
|
|
289
|
-
/**
|
|
290
|
-
* All calls to the wrapped function will be batched.
|
|
291
|
-
*/
|
|
292
|
-
batchCalls: (a) => (...u) => {
|
|
293
|
-
n(() => {
|
|
294
|
-
a(...u);
|
|
295
|
-
});
|
|
296
|
-
},
|
|
297
|
-
schedule: n,
|
|
298
|
-
/**
|
|
299
|
-
* Use this method to set a custom notify function.
|
|
300
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
301
|
-
*/
|
|
302
|
-
setNotifyFunction: (a) => {
|
|
303
|
-
s = a;
|
|
304
|
-
},
|
|
305
|
-
/**
|
|
306
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
307
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
308
|
-
*/
|
|
309
|
-
setBatchNotifyFunction: (a) => {
|
|
310
|
-
r = a;
|
|
311
|
-
},
|
|
312
|
-
setScheduler: (a) => {
|
|
313
|
-
i = a;
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
var F = Le(), qe = class extends Z {
|
|
318
|
-
#t = !0;
|
|
319
|
-
#e;
|
|
320
|
-
#s;
|
|
321
|
-
constructor() {
|
|
322
|
-
super(), this.#s = (t) => {
|
|
323
|
-
if (!V && window.addEventListener) {
|
|
324
|
-
const e = () => t(!0), s = () => t(!1);
|
|
325
|
-
return window.addEventListener("online", e, !1), window.addEventListener("offline", s, !1), () => {
|
|
326
|
-
window.removeEventListener("online", e), window.removeEventListener("offline", s);
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
onSubscribe() {
|
|
332
|
-
this.#e || this.setEventListener(this.#s);
|
|
333
|
-
}
|
|
334
|
-
onUnsubscribe() {
|
|
335
|
-
this.hasListeners() || (this.#e?.(), this.#e = void 0);
|
|
336
|
-
}
|
|
337
|
-
setEventListener(t) {
|
|
338
|
-
this.#s = t, this.#e?.(), this.#e = t(this.setOnline.bind(this));
|
|
339
|
-
}
|
|
340
|
-
setOnline(t) {
|
|
341
|
-
this.#t !== t && (this.#t = t, this.listeners.forEach((s) => {
|
|
342
|
-
s(t);
|
|
343
|
-
}));
|
|
344
|
-
}
|
|
345
|
-
isOnline() {
|
|
346
|
-
return this.#t;
|
|
347
|
-
}
|
|
348
|
-
}, ht = new qe();
|
|
349
|
-
function Ue(t) {
|
|
350
|
-
return Math.min(1e3 * 2 ** t, 3e4);
|
|
351
|
-
}
|
|
352
|
-
function ie(t) {
|
|
353
|
-
return (t ?? "online") === "online" ? ht.isOnline() : !0;
|
|
354
|
-
}
|
|
355
|
-
var wt = class extends Error {
|
|
356
|
-
constructor(t) {
|
|
357
|
-
super("CancelledError"), this.revert = t?.revert, this.silent = t?.silent;
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
function ne(t) {
|
|
361
|
-
let e = !1, s = 0, r;
|
|
362
|
-
const i = xt(), n = () => i.status !== "pending", o = (m) => {
|
|
363
|
-
if (!n()) {
|
|
364
|
-
const v = new wt(m);
|
|
365
|
-
d(v), t.onCancel?.(v);
|
|
366
|
-
}
|
|
367
|
-
}, a = () => {
|
|
368
|
-
e = !0;
|
|
369
|
-
}, u = () => {
|
|
370
|
-
e = !1;
|
|
371
|
-
}, l = () => Mt.isFocused() && (t.networkMode === "always" || ht.isOnline()) && t.canRun(), c = () => ie(t.networkMode) && t.canRun(), p = (m) => {
|
|
372
|
-
n() || (r?.(), i.resolve(m));
|
|
373
|
-
}, d = (m) => {
|
|
374
|
-
n() || (r?.(), i.reject(m));
|
|
375
|
-
}, S = () => new Promise((m) => {
|
|
376
|
-
r = (v) => {
|
|
377
|
-
(n() || l()) && m(v);
|
|
378
|
-
}, t.onPause?.();
|
|
379
|
-
}).then(() => {
|
|
380
|
-
r = void 0, n() || t.onContinue?.();
|
|
381
|
-
}), y = () => {
|
|
382
|
-
if (n())
|
|
383
|
-
return;
|
|
384
|
-
let m;
|
|
385
|
-
const v = s === 0 ? t.initialPromise : void 0;
|
|
386
|
-
try {
|
|
387
|
-
m = v ?? t.fn();
|
|
388
|
-
} catch (x) {
|
|
389
|
-
m = Promise.reject(x);
|
|
390
|
-
}
|
|
391
|
-
Promise.resolve(m).then(p).catch((x) => {
|
|
392
|
-
if (n())
|
|
393
|
-
return;
|
|
394
|
-
const P = t.retry ?? (V ? 0 : 3), E = t.retryDelay ?? Ue, A = typeof E == "function" ? E(s, x) : E, Q = P === !0 || typeof P == "number" && s < P || typeof P == "function" && P(s, x);
|
|
395
|
-
if (e || !Q) {
|
|
396
|
-
d(x);
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
s++, t.onFail?.(s, x), Fe(A).then(() => l() ? void 0 : S()).then(() => {
|
|
400
|
-
e ? d(x) : y();
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
};
|
|
404
|
-
return {
|
|
405
|
-
promise: i,
|
|
406
|
-
status: () => i.status,
|
|
407
|
-
cancel: o,
|
|
408
|
-
continue: () => (r?.(), i),
|
|
409
|
-
cancelRetry: a,
|
|
410
|
-
continueRetry: u,
|
|
411
|
-
canStart: c,
|
|
412
|
-
start: () => (c() ? y() : S().then(y), i)
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
var ae = class {
|
|
416
|
-
#t;
|
|
417
|
-
destroy() {
|
|
418
|
-
this.clearGcTimeout();
|
|
419
|
-
}
|
|
420
|
-
scheduleGc() {
|
|
421
|
-
this.clearGcTimeout(), yt(this.gcTime) && (this.#t = G.setTimeout(() => {
|
|
422
|
-
this.optionalRemove();
|
|
423
|
-
}, this.gcTime));
|
|
424
|
-
}
|
|
425
|
-
updateGcTime(t) {
|
|
426
|
-
this.gcTime = Math.max(
|
|
427
|
-
this.gcTime || 0,
|
|
428
|
-
t ?? (V ? 1 / 0 : 300 * 1e3)
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
clearGcTimeout() {
|
|
432
|
-
this.#t && (G.clearTimeout(this.#t), this.#t = void 0);
|
|
433
|
-
}
|
|
434
|
-
}, _e = class extends ae {
|
|
435
|
-
#t;
|
|
436
|
-
#e;
|
|
437
|
-
#s;
|
|
438
|
-
#i;
|
|
439
|
-
#r;
|
|
440
|
-
#a;
|
|
441
|
-
#o;
|
|
442
|
-
constructor(t) {
|
|
443
|
-
super(), this.#o = !1, this.#a = t.defaultOptions, this.setOptions(t.options), this.observers = [], this.#i = t.client, this.#s = this.#i.getQueryCache(), this.queryKey = t.queryKey, this.queryHash = t.queryHash, this.#t = Ut(this.options), this.state = t.state ?? this.#t, this.scheduleGc();
|
|
444
|
-
}
|
|
445
|
-
get meta() {
|
|
446
|
-
return this.options.meta;
|
|
447
|
-
}
|
|
448
|
-
get promise() {
|
|
449
|
-
return this.#r?.promise;
|
|
450
|
-
}
|
|
451
|
-
setOptions(t) {
|
|
452
|
-
if (this.options = { ...this.#a, ...t }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
|
|
453
|
-
const e = Ut(this.options);
|
|
454
|
-
e.data !== void 0 && (this.setState(
|
|
455
|
-
qt(e.data, e.dataUpdatedAt)
|
|
456
|
-
), this.#t = e);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
optionalRemove() {
|
|
460
|
-
!this.observers.length && this.state.fetchStatus === "idle" && this.#s.remove(this);
|
|
461
|
-
}
|
|
462
|
-
setData(t, e) {
|
|
463
|
-
const s = bt(this.state.data, t, this.options);
|
|
464
|
-
return this.#n({
|
|
465
|
-
data: s,
|
|
466
|
-
type: "success",
|
|
467
|
-
dataUpdatedAt: e?.updatedAt,
|
|
468
|
-
manual: e?.manual
|
|
469
|
-
}), s;
|
|
470
|
-
}
|
|
471
|
-
setState(t, e) {
|
|
472
|
-
this.#n({ type: "setState", state: t, setStateOptions: e });
|
|
473
|
-
}
|
|
474
|
-
cancel(t) {
|
|
475
|
-
const e = this.#r?.promise;
|
|
476
|
-
return this.#r?.cancel(t), e ? e.then(L).catch(L) : Promise.resolve();
|
|
477
|
-
}
|
|
478
|
-
destroy() {
|
|
479
|
-
super.destroy(), this.cancel({ silent: !0 });
|
|
480
|
-
}
|
|
481
|
-
reset() {
|
|
482
|
-
this.destroy(), this.setState(this.#t);
|
|
483
|
-
}
|
|
484
|
-
isActive() {
|
|
485
|
-
return this.observers.some(
|
|
486
|
-
(t) => _(t.options.enabled, this) !== !1
|
|
487
|
-
);
|
|
488
|
-
}
|
|
489
|
-
isDisabled() {
|
|
490
|
-
return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Pt || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
|
|
491
|
-
}
|
|
492
|
-
isStatic() {
|
|
493
|
-
return this.getObserversCount() > 0 ? this.observers.some(
|
|
494
|
-
(t) => H(t.options.staleTime, this) === "static"
|
|
495
|
-
) : !1;
|
|
496
|
-
}
|
|
497
|
-
isStale() {
|
|
498
|
-
return this.getObserversCount() > 0 ? this.observers.some(
|
|
499
|
-
(t) => t.getCurrentResult().isStale
|
|
500
|
-
) : this.state.data === void 0 || this.state.isInvalidated;
|
|
501
|
-
}
|
|
502
|
-
isStaleByTime(t = 0) {
|
|
503
|
-
return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !te(this.state.dataUpdatedAt, t);
|
|
504
|
-
}
|
|
505
|
-
onFocus() {
|
|
506
|
-
this.observers.find((e) => e.shouldFetchOnWindowFocus())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
|
|
507
|
-
}
|
|
508
|
-
onOnline() {
|
|
509
|
-
this.observers.find((e) => e.shouldFetchOnReconnect())?.refetch({ cancelRefetch: !1 }), this.#r?.continue();
|
|
510
|
-
}
|
|
511
|
-
addObserver(t) {
|
|
512
|
-
this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), this.#s.notify({ type: "observerAdded", query: this, observer: t }));
|
|
513
|
-
}
|
|
514
|
-
removeObserver(t) {
|
|
515
|
-
this.observers.includes(t) && (this.observers = this.observers.filter((e) => e !== t), this.observers.length || (this.#r && (this.#o ? this.#r.cancel({ revert: !0 }) : this.#r.cancelRetry()), this.scheduleGc()), this.#s.notify({ type: "observerRemoved", query: this, observer: t }));
|
|
516
|
-
}
|
|
517
|
-
getObserversCount() {
|
|
518
|
-
return this.observers.length;
|
|
519
|
-
}
|
|
520
|
-
invalidate() {
|
|
521
|
-
this.state.isInvalidated || this.#n({ type: "invalidate" });
|
|
522
|
-
}
|
|
523
|
-
async fetch(t, e) {
|
|
524
|
-
if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
|
|
525
|
-
// re-start the fetch; there is a chance that the query is still in a
|
|
526
|
-
// pending state when that happens
|
|
527
|
-
this.#r?.status() !== "rejected") {
|
|
528
|
-
if (this.state.data !== void 0 && e?.cancelRefetch)
|
|
529
|
-
this.cancel({ silent: !0 });
|
|
530
|
-
else if (this.#r)
|
|
531
|
-
return this.#r.continueRetry(), this.#r.promise;
|
|
532
|
-
}
|
|
533
|
-
if (t && this.setOptions(t), !this.options.queryFn) {
|
|
534
|
-
const a = this.observers.find((u) => u.options.queryFn);
|
|
535
|
-
a && this.setOptions(a.options);
|
|
536
|
-
}
|
|
537
|
-
const s = new AbortController(), r = (a) => {
|
|
538
|
-
Object.defineProperty(a, "signal", {
|
|
539
|
-
enumerable: !0,
|
|
540
|
-
get: () => (this.#o = !0, s.signal)
|
|
541
|
-
});
|
|
542
|
-
}, i = () => {
|
|
543
|
-
const a = se(this.options, e), l = (() => {
|
|
544
|
-
const c = {
|
|
545
|
-
client: this.#i,
|
|
546
|
-
queryKey: this.queryKey,
|
|
547
|
-
meta: this.meta
|
|
548
|
-
};
|
|
549
|
-
return r(c), c;
|
|
550
|
-
})();
|
|
551
|
-
return this.#o = !1, this.options.persister ? this.options.persister(
|
|
552
|
-
a,
|
|
553
|
-
l,
|
|
554
|
-
this
|
|
555
|
-
) : a(l);
|
|
556
|
-
}, o = (() => {
|
|
557
|
-
const a = {
|
|
558
|
-
fetchOptions: e,
|
|
559
|
-
options: this.options,
|
|
560
|
-
queryKey: this.queryKey,
|
|
561
|
-
client: this.#i,
|
|
562
|
-
state: this.state,
|
|
563
|
-
fetchFn: i
|
|
564
|
-
};
|
|
565
|
-
return r(a), a;
|
|
566
|
-
})();
|
|
567
|
-
this.options.behavior?.onFetch(o, this), this.#e = this.state, (this.state.fetchStatus === "idle" || this.state.fetchMeta !== o.fetchOptions?.meta) && this.#n({ type: "fetch", meta: o.fetchOptions?.meta }), this.#r = ne({
|
|
568
|
-
initialPromise: e?.initialPromise,
|
|
569
|
-
fn: o.fetchFn,
|
|
570
|
-
onCancel: (a) => {
|
|
571
|
-
a instanceof wt && a.revert && this.setState({
|
|
572
|
-
...this.#e,
|
|
573
|
-
fetchStatus: "idle"
|
|
574
|
-
}), s.abort();
|
|
575
|
-
},
|
|
576
|
-
onFail: (a, u) => {
|
|
577
|
-
this.#n({ type: "failed", failureCount: a, error: u });
|
|
578
|
-
},
|
|
579
|
-
onPause: () => {
|
|
580
|
-
this.#n({ type: "pause" });
|
|
581
|
-
},
|
|
582
|
-
onContinue: () => {
|
|
583
|
-
this.#n({ type: "continue" });
|
|
584
|
-
},
|
|
585
|
-
retry: o.options.retry,
|
|
586
|
-
retryDelay: o.options.retryDelay,
|
|
587
|
-
networkMode: o.options.networkMode,
|
|
588
|
-
canRun: () => !0
|
|
589
|
-
});
|
|
590
|
-
try {
|
|
591
|
-
const a = await this.#r.start();
|
|
592
|
-
if (a === void 0)
|
|
593
|
-
throw new Error(`${this.queryHash} data is undefined`);
|
|
594
|
-
return this.setData(a), this.#s.config.onSuccess?.(a, this), this.#s.config.onSettled?.(
|
|
595
|
-
a,
|
|
596
|
-
this.state.error,
|
|
597
|
-
this
|
|
598
|
-
), a;
|
|
599
|
-
} catch (a) {
|
|
600
|
-
if (a instanceof wt) {
|
|
601
|
-
if (a.silent)
|
|
602
|
-
return this.#r.promise;
|
|
603
|
-
if (a.revert) {
|
|
604
|
-
if (this.state.data === void 0)
|
|
605
|
-
throw a;
|
|
606
|
-
return this.state.data;
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
throw this.#n({
|
|
610
|
-
type: "error",
|
|
611
|
-
error: a
|
|
612
|
-
}), this.#s.config.onError?.(
|
|
613
|
-
a,
|
|
614
|
-
this
|
|
615
|
-
), this.#s.config.onSettled?.(
|
|
616
|
-
this.state.data,
|
|
617
|
-
a,
|
|
618
|
-
this
|
|
619
|
-
), a;
|
|
620
|
-
} finally {
|
|
621
|
-
this.scheduleGc();
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
#n(t) {
|
|
625
|
-
const e = (s) => {
|
|
626
|
-
switch (t.type) {
|
|
627
|
-
case "failed":
|
|
628
|
-
return {
|
|
629
|
-
...s,
|
|
630
|
-
fetchFailureCount: t.failureCount,
|
|
631
|
-
fetchFailureReason: t.error
|
|
632
|
-
};
|
|
633
|
-
case "pause":
|
|
634
|
-
return {
|
|
635
|
-
...s,
|
|
636
|
-
fetchStatus: "paused"
|
|
637
|
-
};
|
|
638
|
-
case "continue":
|
|
639
|
-
return {
|
|
640
|
-
...s,
|
|
641
|
-
fetchStatus: "fetching"
|
|
642
|
-
};
|
|
643
|
-
case "fetch":
|
|
644
|
-
return {
|
|
645
|
-
...s,
|
|
646
|
-
...oe(s.data, this.options),
|
|
647
|
-
fetchMeta: t.meta ?? null
|
|
648
|
-
};
|
|
649
|
-
case "success":
|
|
650
|
-
const r = {
|
|
651
|
-
...s,
|
|
652
|
-
...qt(t.data, t.dataUpdatedAt),
|
|
653
|
-
dataUpdateCount: s.dataUpdateCount + 1,
|
|
654
|
-
...!t.manual && {
|
|
655
|
-
fetchStatus: "idle",
|
|
656
|
-
fetchFailureCount: 0,
|
|
657
|
-
fetchFailureReason: null
|
|
658
|
-
}
|
|
659
|
-
};
|
|
660
|
-
return this.#e = t.manual ? r : void 0, r;
|
|
661
|
-
case "error":
|
|
662
|
-
const i = t.error;
|
|
663
|
-
return {
|
|
664
|
-
...s,
|
|
665
|
-
error: i,
|
|
666
|
-
errorUpdateCount: s.errorUpdateCount + 1,
|
|
667
|
-
errorUpdatedAt: Date.now(),
|
|
668
|
-
fetchFailureCount: s.fetchFailureCount + 1,
|
|
669
|
-
fetchFailureReason: i,
|
|
670
|
-
fetchStatus: "idle",
|
|
671
|
-
status: "error"
|
|
672
|
-
};
|
|
673
|
-
case "invalidate":
|
|
674
|
-
return {
|
|
675
|
-
...s,
|
|
676
|
-
isInvalidated: !0
|
|
677
|
-
};
|
|
678
|
-
case "setState":
|
|
679
|
-
return {
|
|
680
|
-
...s,
|
|
681
|
-
...t.state
|
|
682
|
-
};
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
this.state = e(this.state), F.batch(() => {
|
|
686
|
-
this.observers.forEach((s) => {
|
|
687
|
-
s.onQueryUpdate();
|
|
688
|
-
}), this.#s.notify({ query: this, type: "updated", action: t });
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
function oe(t, e) {
|
|
693
|
-
return {
|
|
694
|
-
fetchFailureCount: 0,
|
|
695
|
-
fetchFailureReason: null,
|
|
696
|
-
fetchStatus: ie(e.networkMode) ? "fetching" : "paused",
|
|
697
|
-
...t === void 0 && {
|
|
698
|
-
error: null,
|
|
699
|
-
status: "pending"
|
|
700
|
-
}
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
function qt(t, e) {
|
|
704
|
-
return {
|
|
705
|
-
data: t,
|
|
706
|
-
dataUpdatedAt: e ?? Date.now(),
|
|
707
|
-
error: null,
|
|
708
|
-
isInvalidated: !1,
|
|
709
|
-
status: "success"
|
|
710
|
-
};
|
|
711
|
-
}
|
|
712
|
-
function Ut(t) {
|
|
713
|
-
const e = typeof t.initialData == "function" ? t.initialData() : t.initialData, s = e !== void 0, r = s ? typeof t.initialDataUpdatedAt == "function" ? t.initialDataUpdatedAt() : t.initialDataUpdatedAt : 0;
|
|
714
|
-
return {
|
|
715
|
-
data: e,
|
|
716
|
-
dataUpdateCount: 0,
|
|
717
|
-
dataUpdatedAt: s ? r ?? Date.now() : 0,
|
|
718
|
-
error: null,
|
|
719
|
-
errorUpdateCount: 0,
|
|
720
|
-
errorUpdatedAt: 0,
|
|
721
|
-
fetchFailureCount: 0,
|
|
722
|
-
fetchFailureReason: null,
|
|
723
|
-
fetchMeta: null,
|
|
724
|
-
isInvalidated: !1,
|
|
725
|
-
status: s ? "success" : "pending",
|
|
726
|
-
fetchStatus: "idle"
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
var ce = class extends Z {
|
|
730
|
-
constructor(t, e) {
|
|
731
|
-
super(), this.options = e, this.#t = t, this.#n = null, this.#o = xt(), this.bindMethods(), this.setOptions(e);
|
|
732
|
-
}
|
|
733
|
-
#t;
|
|
734
|
-
#e = void 0;
|
|
735
|
-
#s = void 0;
|
|
736
|
-
#i = void 0;
|
|
737
|
-
#r;
|
|
738
|
-
#a;
|
|
739
|
-
#o;
|
|
740
|
-
#n;
|
|
741
|
-
#m;
|
|
742
|
-
#d;
|
|
743
|
-
// This property keeps track of the last query with defined data.
|
|
744
|
-
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
745
|
-
#f;
|
|
746
|
-
#u;
|
|
747
|
-
#h;
|
|
748
|
-
#c;
|
|
749
|
-
#p = /* @__PURE__ */ new Set();
|
|
750
|
-
bindMethods() {
|
|
751
|
-
this.refetch = this.refetch.bind(this);
|
|
752
|
-
}
|
|
753
|
-
onSubscribe() {
|
|
754
|
-
this.listeners.size === 1 && (this.#e.addObserver(this), _t(this.#e, this.options) ? this.#l() : this.updateResult(), this.#b());
|
|
755
|
-
}
|
|
756
|
-
onUnsubscribe() {
|
|
757
|
-
this.hasListeners() || this.destroy();
|
|
758
|
-
}
|
|
759
|
-
shouldFetchOnReconnect() {
|
|
760
|
-
return Ct(
|
|
761
|
-
this.#e,
|
|
762
|
-
this.options,
|
|
763
|
-
this.options.refetchOnReconnect
|
|
764
|
-
);
|
|
765
|
-
}
|
|
766
|
-
shouldFetchOnWindowFocus() {
|
|
767
|
-
return Ct(
|
|
768
|
-
this.#e,
|
|
769
|
-
this.options,
|
|
770
|
-
this.options.refetchOnWindowFocus
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
destroy() {
|
|
774
|
-
this.listeners = /* @__PURE__ */ new Set(), this.#x(), this.#w(), this.#e.removeObserver(this);
|
|
775
|
-
}
|
|
776
|
-
setOptions(t) {
|
|
777
|
-
const e = this.options, s = this.#e;
|
|
778
|
-
if (this.options = this.#t.defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof _(this.options.enabled, this.#e) != "boolean")
|
|
779
|
-
throw new Error(
|
|
780
|
-
"Expected enabled to be a boolean or a callback that returns a boolean"
|
|
781
|
-
);
|
|
782
|
-
this.#C(), this.#e.setOptions(this.options), e._defaulted && !ut(this.options, e) && this.#t.getQueryCache().notify({
|
|
783
|
-
type: "observerOptionsUpdated",
|
|
784
|
-
query: this.#e,
|
|
785
|
-
observer: this
|
|
786
|
-
});
|
|
787
|
-
const r = this.hasListeners();
|
|
788
|
-
r && Kt(
|
|
789
|
-
this.#e,
|
|
790
|
-
s,
|
|
791
|
-
this.options,
|
|
792
|
-
e
|
|
793
|
-
) && this.#l(), this.updateResult(), r && (this.#e !== s || _(this.options.enabled, this.#e) !== _(e.enabled, this.#e) || H(this.options.staleTime, this.#e) !== H(e.staleTime, this.#e)) && this.#g();
|
|
794
|
-
const i = this.#y();
|
|
795
|
-
r && (this.#e !== s || _(this.options.enabled, this.#e) !== _(e.enabled, this.#e) || i !== this.#c) && this.#v(i);
|
|
796
|
-
}
|
|
797
|
-
getOptimisticResult(t) {
|
|
798
|
-
const e = this.#t.getQueryCache().build(this.#t, t), s = this.createResult(e, t);
|
|
799
|
-
return ze(this, s) && (this.#i = s, this.#a = this.options, this.#r = this.#e.state), s;
|
|
800
|
-
}
|
|
801
|
-
getCurrentResult() {
|
|
802
|
-
return this.#i;
|
|
803
|
-
}
|
|
804
|
-
trackResult(t, e) {
|
|
805
|
-
return new Proxy(t, {
|
|
806
|
-
get: (s, r) => (this.trackProp(r), e?.(r), r === "promise" && (this.trackProp("data"), !this.options.experimental_prefetchInRender && this.#o.status === "pending" && this.#o.reject(
|
|
807
|
-
new Error(
|
|
808
|
-
"experimental_prefetchInRender feature flag is not enabled"
|
|
809
|
-
)
|
|
810
|
-
)), Reflect.get(s, r))
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
trackProp(t) {
|
|
814
|
-
this.#p.add(t);
|
|
815
|
-
}
|
|
816
|
-
getCurrentQuery() {
|
|
817
|
-
return this.#e;
|
|
818
|
-
}
|
|
819
|
-
refetch({ ...t } = {}) {
|
|
820
|
-
return this.fetch({
|
|
821
|
-
...t
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
fetchOptimistic(t) {
|
|
825
|
-
const e = this.#t.defaultQueryOptions(t), s = this.#t.getQueryCache().build(this.#t, e);
|
|
826
|
-
return s.fetch().then(() => this.createResult(s, e));
|
|
827
|
-
}
|
|
828
|
-
fetch(t) {
|
|
829
|
-
return this.#l({
|
|
830
|
-
...t,
|
|
831
|
-
cancelRefetch: t.cancelRefetch ?? !0
|
|
832
|
-
}).then(() => (this.updateResult(), this.#i));
|
|
833
|
-
}
|
|
834
|
-
#l(t) {
|
|
835
|
-
this.#C();
|
|
836
|
-
let e = this.#e.fetch(
|
|
837
|
-
this.options,
|
|
838
|
-
t
|
|
839
|
-
);
|
|
840
|
-
return t?.throwOnError || (e = e.catch(L)), e;
|
|
841
|
-
}
|
|
842
|
-
#g() {
|
|
843
|
-
this.#x();
|
|
844
|
-
const t = H(
|
|
845
|
-
this.options.staleTime,
|
|
846
|
-
this.#e
|
|
847
|
-
);
|
|
848
|
-
if (V || this.#i.isStale || !yt(t))
|
|
849
|
-
return;
|
|
850
|
-
const s = te(this.#i.dataUpdatedAt, t) + 1;
|
|
851
|
-
this.#u = G.setTimeout(() => {
|
|
852
|
-
this.#i.isStale || this.updateResult();
|
|
853
|
-
}, s);
|
|
854
|
-
}
|
|
855
|
-
#y() {
|
|
856
|
-
return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(this.#e) : this.options.refetchInterval) ?? !1;
|
|
857
|
-
}
|
|
858
|
-
#v(t) {
|
|
859
|
-
this.#w(), this.#c = t, !(V || _(this.options.enabled, this.#e) === !1 || !yt(this.#c) || this.#c === 0) && (this.#h = G.setInterval(() => {
|
|
860
|
-
(this.options.refetchIntervalInBackground || Mt.isFocused()) && this.#l();
|
|
861
|
-
}, this.#c));
|
|
862
|
-
}
|
|
863
|
-
#b() {
|
|
864
|
-
this.#g(), this.#v(this.#y());
|
|
865
|
-
}
|
|
866
|
-
#x() {
|
|
867
|
-
this.#u && (G.clearTimeout(this.#u), this.#u = void 0);
|
|
868
|
-
}
|
|
869
|
-
#w() {
|
|
870
|
-
this.#h && (G.clearInterval(this.#h), this.#h = void 0);
|
|
871
|
-
}
|
|
872
|
-
createResult(t, e) {
|
|
873
|
-
const s = this.#e, r = this.options, i = this.#i, n = this.#r, o = this.#a, u = t !== s ? t.state : this.#s, { state: l } = t;
|
|
874
|
-
let c = { ...l }, p = !1, d;
|
|
875
|
-
if (e._optimisticResults) {
|
|
876
|
-
const M = this.hasListeners(), j = !M && _t(t, e), $ = M && Kt(t, s, e, r);
|
|
877
|
-
(j || $) && (c = {
|
|
878
|
-
...c,
|
|
879
|
-
...oe(l.data, t.options)
|
|
880
|
-
}), e._optimisticResults === "isRestoring" && (c.fetchStatus = "idle");
|
|
881
|
-
}
|
|
882
|
-
let { error: S, errorUpdatedAt: y, status: m } = c;
|
|
883
|
-
d = c.data;
|
|
884
|
-
let v = !1;
|
|
885
|
-
if (e.placeholderData !== void 0 && d === void 0 && m === "pending") {
|
|
886
|
-
let M;
|
|
887
|
-
i?.isPlaceholderData && e.placeholderData === o?.placeholderData ? (M = i.data, v = !0) : M = typeof e.placeholderData == "function" ? e.placeholderData(
|
|
888
|
-
this.#f?.state.data,
|
|
889
|
-
this.#f
|
|
890
|
-
) : e.placeholderData, M !== void 0 && (m = "success", d = bt(
|
|
891
|
-
i?.data,
|
|
892
|
-
M,
|
|
893
|
-
e
|
|
894
|
-
), p = !0);
|
|
895
|
-
}
|
|
896
|
-
if (e.select && d !== void 0 && !v)
|
|
897
|
-
if (i && d === n?.data && e.select === this.#m)
|
|
898
|
-
d = this.#d;
|
|
899
|
-
else
|
|
900
|
-
try {
|
|
901
|
-
this.#m = e.select, d = e.select(d), d = bt(i?.data, d, e), this.#d = d, this.#n = null;
|
|
902
|
-
} catch (M) {
|
|
903
|
-
this.#n = M;
|
|
904
|
-
}
|
|
905
|
-
this.#n && (S = this.#n, d = this.#d, y = Date.now(), m = "error");
|
|
906
|
-
const x = c.fetchStatus === "fetching", P = m === "pending", E = m === "error", A = P && x, Q = d !== void 0, I = {
|
|
907
|
-
status: m,
|
|
908
|
-
fetchStatus: c.fetchStatus,
|
|
909
|
-
isPending: P,
|
|
910
|
-
isSuccess: m === "success",
|
|
911
|
-
isError: E,
|
|
912
|
-
isInitialLoading: A,
|
|
913
|
-
isLoading: A,
|
|
914
|
-
data: d,
|
|
915
|
-
dataUpdatedAt: c.dataUpdatedAt,
|
|
916
|
-
error: S,
|
|
917
|
-
errorUpdatedAt: y,
|
|
918
|
-
failureCount: c.fetchFailureCount,
|
|
919
|
-
failureReason: c.fetchFailureReason,
|
|
920
|
-
errorUpdateCount: c.errorUpdateCount,
|
|
921
|
-
isFetched: c.dataUpdateCount > 0 || c.errorUpdateCount > 0,
|
|
922
|
-
isFetchedAfterMount: c.dataUpdateCount > u.dataUpdateCount || c.errorUpdateCount > u.errorUpdateCount,
|
|
923
|
-
isFetching: x,
|
|
924
|
-
isRefetching: x && !P,
|
|
925
|
-
isLoadingError: E && !Q,
|
|
926
|
-
isPaused: c.fetchStatus === "paused",
|
|
927
|
-
isPlaceholderData: p,
|
|
928
|
-
isRefetchError: E && Q,
|
|
929
|
-
isStale: jt(t, e),
|
|
930
|
-
refetch: this.refetch,
|
|
931
|
-
promise: this.#o,
|
|
932
|
-
isEnabled: _(e.enabled, t) !== !1
|
|
933
|
-
};
|
|
934
|
-
if (this.options.experimental_prefetchInRender) {
|
|
935
|
-
const M = (U) => {
|
|
936
|
-
I.status === "error" ? U.reject(I.error) : I.data !== void 0 && U.resolve(I.data);
|
|
937
|
-
}, j = () => {
|
|
938
|
-
const U = this.#o = I.promise = xt();
|
|
939
|
-
M(U);
|
|
940
|
-
}, $ = this.#o;
|
|
941
|
-
switch ($.status) {
|
|
942
|
-
case "pending":
|
|
943
|
-
t.queryHash === s.queryHash && M($);
|
|
944
|
-
break;
|
|
945
|
-
case "fulfilled":
|
|
946
|
-
(I.status === "error" || I.data !== $.value) && j();
|
|
947
|
-
break;
|
|
948
|
-
case "rejected":
|
|
949
|
-
(I.status !== "error" || I.error !== $.reason) && j();
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
return I;
|
|
954
|
-
}
|
|
955
|
-
updateResult() {
|
|
956
|
-
const t = this.#i, e = this.createResult(this.#e, this.options);
|
|
957
|
-
if (this.#r = this.#e.state, this.#a = this.options, this.#r.data !== void 0 && (this.#f = this.#e), ut(e, t))
|
|
958
|
-
return;
|
|
959
|
-
this.#i = e;
|
|
960
|
-
const s = () => {
|
|
961
|
-
if (!t)
|
|
962
|
-
return !0;
|
|
963
|
-
const { notifyOnChangeProps: r } = this.options, i = typeof r == "function" ? r() : r;
|
|
964
|
-
if (i === "all" || !i && !this.#p.size)
|
|
965
|
-
return !0;
|
|
966
|
-
const n = new Set(
|
|
967
|
-
i ?? this.#p
|
|
968
|
-
);
|
|
969
|
-
return this.options.throwOnError && n.add("error"), Object.keys(this.#i).some((o) => {
|
|
970
|
-
const a = o;
|
|
971
|
-
return this.#i[a] !== t[a] && n.has(a);
|
|
972
|
-
});
|
|
973
|
-
};
|
|
974
|
-
this.#S({ listeners: s() });
|
|
975
|
-
}
|
|
976
|
-
#C() {
|
|
977
|
-
const t = this.#t.getQueryCache().build(this.#t, this.options);
|
|
978
|
-
if (t === this.#e)
|
|
979
|
-
return;
|
|
980
|
-
const e = this.#e;
|
|
981
|
-
this.#e = t, this.#s = t.state, this.hasListeners() && (e?.removeObserver(this), t.addObserver(this));
|
|
982
|
-
}
|
|
983
|
-
onQueryUpdate() {
|
|
984
|
-
this.updateResult(), this.hasListeners() && this.#b();
|
|
985
|
-
}
|
|
986
|
-
#S(t) {
|
|
987
|
-
F.batch(() => {
|
|
988
|
-
t.listeners && this.listeners.forEach((e) => {
|
|
989
|
-
e(this.#i);
|
|
990
|
-
}), this.#t.getQueryCache().notify({
|
|
991
|
-
query: this.#e,
|
|
992
|
-
type: "observerResultsUpdated"
|
|
993
|
-
});
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
function Ke(t, e) {
|
|
998
|
-
return _(e.enabled, t) !== !1 && t.state.data === void 0 && !(t.state.status === "error" && e.retryOnMount === !1);
|
|
999
|
-
}
|
|
1000
|
-
function _t(t, e) {
|
|
1001
|
-
return Ke(t, e) || t.state.data !== void 0 && Ct(t, e, e.refetchOnMount);
|
|
1002
|
-
}
|
|
1003
|
-
function Ct(t, e, s) {
|
|
1004
|
-
if (_(e.enabled, t) !== !1 && H(e.staleTime, t) !== "static") {
|
|
1005
|
-
const r = typeof s == "function" ? s(t) : s;
|
|
1006
|
-
return r === "always" || r !== !1 && jt(t, e);
|
|
1007
|
-
}
|
|
1008
|
-
return !1;
|
|
1009
|
-
}
|
|
1010
|
-
function Kt(t, e, s, r) {
|
|
1011
|
-
return (t !== e || _(r.enabled, t) === !1) && (!s.suspense || t.state.status !== "error") && jt(t, s);
|
|
1012
|
-
}
|
|
1013
|
-
function jt(t, e) {
|
|
1014
|
-
return _(e.enabled, t) !== !1 && t.isStaleByTime(H(e.staleTime, t));
|
|
1015
|
-
}
|
|
1016
|
-
function ze(t, e) {
|
|
1017
|
-
return !ut(t.getCurrentResult(), e);
|
|
1018
|
-
}
|
|
1019
|
-
function lt(t) {
|
|
1020
|
-
return {
|
|
1021
|
-
onFetch: (e, s) => {
|
|
1022
|
-
const r = e.options, i = e.fetchOptions?.meta?.fetchMore?.direction, n = e.state.data?.pages || [], o = e.state.data?.pageParams || [];
|
|
1023
|
-
let a = { pages: [], pageParams: [] }, u = 0;
|
|
1024
|
-
const l = async () => {
|
|
1025
|
-
let c = !1;
|
|
1026
|
-
const p = (y) => {
|
|
1027
|
-
Object.defineProperty(y, "signal", {
|
|
1028
|
-
enumerable: !0,
|
|
1029
|
-
get: () => (e.signal.aborted ? c = !0 : e.signal.addEventListener("abort", () => {
|
|
1030
|
-
c = !0;
|
|
1031
|
-
}), e.signal)
|
|
1032
|
-
});
|
|
1033
|
-
}, d = se(e.options, e.fetchOptions), S = async (y, m, v) => {
|
|
1034
|
-
if (c)
|
|
1035
|
-
return Promise.reject();
|
|
1036
|
-
if (m == null && y.pages.length)
|
|
1037
|
-
return Promise.resolve(y);
|
|
1038
|
-
const P = (() => {
|
|
1039
|
-
const R = {
|
|
1040
|
-
client: e.client,
|
|
1041
|
-
queryKey: e.queryKey,
|
|
1042
|
-
pageParam: m,
|
|
1043
|
-
direction: v ? "backward" : "forward",
|
|
1044
|
-
meta: e.options.meta
|
|
1045
|
-
};
|
|
1046
|
-
return p(R), R;
|
|
1047
|
-
})(), E = await d(P), { maxPages: A } = e.options, Q = v ? De : Ae;
|
|
1048
|
-
return {
|
|
1049
|
-
pages: Q(y.pages, E, A),
|
|
1050
|
-
pageParams: Q(y.pageParams, m, A)
|
|
1051
|
-
};
|
|
1052
|
-
};
|
|
1053
|
-
if (i && n.length) {
|
|
1054
|
-
const y = i === "backward", m = y ? ue : St, v = {
|
|
1055
|
-
pages: n,
|
|
1056
|
-
pageParams: o
|
|
1057
|
-
}, x = m(r, v);
|
|
1058
|
-
a = await S(v, x, y);
|
|
1059
|
-
} else {
|
|
1060
|
-
const y = t ?? n.length;
|
|
1061
|
-
do {
|
|
1062
|
-
const m = u === 0 ? o[0] ?? r.initialPageParam : St(r, a);
|
|
1063
|
-
if (u > 0 && m == null)
|
|
1064
|
-
break;
|
|
1065
|
-
a = await S(a, m), u++;
|
|
1066
|
-
} while (u < y);
|
|
1067
|
-
}
|
|
1068
|
-
return a;
|
|
1069
|
-
};
|
|
1070
|
-
e.options.persister ? e.fetchFn = () => e.options.persister?.(
|
|
1071
|
-
l,
|
|
1072
|
-
{
|
|
1073
|
-
client: e.client,
|
|
1074
|
-
queryKey: e.queryKey,
|
|
1075
|
-
meta: e.options.meta,
|
|
1076
|
-
signal: e.signal
|
|
1077
|
-
},
|
|
1078
|
-
s
|
|
1079
|
-
) : e.fetchFn = l;
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
function St(t, { pages: e, pageParams: s }) {
|
|
1084
|
-
const r = e.length - 1;
|
|
1085
|
-
return e.length > 0 ? t.getNextPageParam(
|
|
1086
|
-
e[r],
|
|
1087
|
-
e,
|
|
1088
|
-
s[r],
|
|
1089
|
-
s
|
|
1090
|
-
) : void 0;
|
|
1091
|
-
}
|
|
1092
|
-
function ue(t, { pages: e, pageParams: s }) {
|
|
1093
|
-
return e.length > 0 ? t.getPreviousPageParam?.(e[0], e, s[0], s) : void 0;
|
|
1094
|
-
}
|
|
1095
|
-
function Be(t, e) {
|
|
1096
|
-
return e ? St(t, e) != null : !1;
|
|
1097
|
-
}
|
|
1098
|
-
function He(t, e) {
|
|
1099
|
-
return !e || !t.getPreviousPageParam ? !1 : ue(t, e) != null;
|
|
1100
|
-
}
|
|
1101
|
-
var Ge = class extends ce {
|
|
1102
|
-
constructor(t, e) {
|
|
1103
|
-
super(t, e);
|
|
1104
|
-
}
|
|
1105
|
-
bindMethods() {
|
|
1106
|
-
super.bindMethods(), this.fetchNextPage = this.fetchNextPage.bind(this), this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
|
|
1107
|
-
}
|
|
1108
|
-
setOptions(t) {
|
|
1109
|
-
super.setOptions({
|
|
1110
|
-
...t,
|
|
1111
|
-
behavior: lt()
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
getOptimisticResult(t) {
|
|
1115
|
-
return t.behavior = lt(), super.getOptimisticResult(t);
|
|
1116
|
-
}
|
|
1117
|
-
fetchNextPage(t) {
|
|
1118
|
-
return this.fetch({
|
|
1119
|
-
...t,
|
|
1120
|
-
meta: {
|
|
1121
|
-
fetchMore: { direction: "forward" }
|
|
1122
|
-
}
|
|
1123
|
-
});
|
|
1124
|
-
}
|
|
1125
|
-
fetchPreviousPage(t) {
|
|
1126
|
-
return this.fetch({
|
|
1127
|
-
...t,
|
|
1128
|
-
meta: {
|
|
1129
|
-
fetchMore: { direction: "backward" }
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
createResult(t, e) {
|
|
1134
|
-
const { state: s } = t, r = super.createResult(t, e), { isFetching: i, isRefetching: n, isError: o, isRefetchError: a } = r, u = s.fetchMeta?.fetchMore?.direction, l = o && u === "forward", c = i && u === "forward", p = o && u === "backward", d = i && u === "backward";
|
|
1135
|
-
return {
|
|
1136
|
-
...r,
|
|
1137
|
-
fetchNextPage: this.fetchNextPage,
|
|
1138
|
-
fetchPreviousPage: this.fetchPreviousPage,
|
|
1139
|
-
hasNextPage: Be(e, s.data),
|
|
1140
|
-
hasPreviousPage: He(e, s.data),
|
|
1141
|
-
isFetchNextPageError: l,
|
|
1142
|
-
isFetchingNextPage: c,
|
|
1143
|
-
isFetchPreviousPageError: p,
|
|
1144
|
-
isFetchingPreviousPage: d,
|
|
1145
|
-
isRefetchError: a && !l && !p,
|
|
1146
|
-
isRefetching: n && !c && !d
|
|
1147
|
-
};
|
|
1148
|
-
}
|
|
1149
|
-
}, We = class extends ae {
|
|
1150
|
-
#t;
|
|
1151
|
-
#e;
|
|
1152
|
-
#s;
|
|
1153
|
-
#i;
|
|
1154
|
-
constructor(t) {
|
|
1155
|
-
super(), this.#t = t.client, this.mutationId = t.mutationId, this.#s = t.mutationCache, this.#e = [], this.state = t.state || he(), this.setOptions(t.options), this.scheduleGc();
|
|
1156
|
-
}
|
|
1157
|
-
setOptions(t) {
|
|
1158
|
-
this.options = t, this.updateGcTime(this.options.gcTime);
|
|
1159
|
-
}
|
|
1160
|
-
get meta() {
|
|
1161
|
-
return this.options.meta;
|
|
1162
|
-
}
|
|
1163
|
-
addObserver(t) {
|
|
1164
|
-
this.#e.includes(t) || (this.#e.push(t), this.clearGcTimeout(), this.#s.notify({
|
|
1165
|
-
type: "observerAdded",
|
|
1166
|
-
mutation: this,
|
|
1167
|
-
observer: t
|
|
1168
|
-
}));
|
|
1169
|
-
}
|
|
1170
|
-
removeObserver(t) {
|
|
1171
|
-
this.#e = this.#e.filter((e) => e !== t), this.scheduleGc(), this.#s.notify({
|
|
1172
|
-
type: "observerRemoved",
|
|
1173
|
-
mutation: this,
|
|
1174
|
-
observer: t
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
optionalRemove() {
|
|
1178
|
-
this.#e.length || (this.state.status === "pending" ? this.scheduleGc() : this.#s.remove(this));
|
|
1179
|
-
}
|
|
1180
|
-
continue() {
|
|
1181
|
-
return this.#i?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
|
|
1182
|
-
this.execute(this.state.variables);
|
|
1183
|
-
}
|
|
1184
|
-
async execute(t) {
|
|
1185
|
-
const e = () => {
|
|
1186
|
-
this.#r({ type: "continue" });
|
|
1187
|
-
}, s = {
|
|
1188
|
-
client: this.#t,
|
|
1189
|
-
meta: this.options.meta,
|
|
1190
|
-
mutationKey: this.options.mutationKey
|
|
1191
|
-
};
|
|
1192
|
-
this.#i = ne({
|
|
1193
|
-
fn: () => this.options.mutationFn ? this.options.mutationFn(t, s) : Promise.reject(new Error("No mutationFn found")),
|
|
1194
|
-
onFail: (n, o) => {
|
|
1195
|
-
this.#r({ type: "failed", failureCount: n, error: o });
|
|
1196
|
-
},
|
|
1197
|
-
onPause: () => {
|
|
1198
|
-
this.#r({ type: "pause" });
|
|
1199
|
-
},
|
|
1200
|
-
onContinue: e,
|
|
1201
|
-
retry: this.options.retry ?? 0,
|
|
1202
|
-
retryDelay: this.options.retryDelay,
|
|
1203
|
-
networkMode: this.options.networkMode,
|
|
1204
|
-
canRun: () => this.#s.canRun(this)
|
|
1205
|
-
});
|
|
1206
|
-
const r = this.state.status === "pending", i = !this.#i.canStart();
|
|
1207
|
-
try {
|
|
1208
|
-
if (r)
|
|
1209
|
-
e();
|
|
1210
|
-
else {
|
|
1211
|
-
this.#r({ type: "pending", variables: t, isPaused: i }), await this.#s.config.onMutate?.(
|
|
1212
|
-
t,
|
|
1213
|
-
this,
|
|
1214
|
-
s
|
|
1215
|
-
);
|
|
1216
|
-
const o = await this.options.onMutate?.(
|
|
1217
|
-
t,
|
|
1218
|
-
s
|
|
1219
|
-
);
|
|
1220
|
-
o !== this.state.context && this.#r({
|
|
1221
|
-
type: "pending",
|
|
1222
|
-
context: o,
|
|
1223
|
-
variables: t,
|
|
1224
|
-
isPaused: i
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
const n = await this.#i.start();
|
|
1228
|
-
return await this.#s.config.onSuccess?.(
|
|
1229
|
-
n,
|
|
1230
|
-
t,
|
|
1231
|
-
this.state.context,
|
|
1232
|
-
this,
|
|
1233
|
-
s
|
|
1234
|
-
), await this.options.onSuccess?.(
|
|
1235
|
-
n,
|
|
1236
|
-
t,
|
|
1237
|
-
this.state.context,
|
|
1238
|
-
s
|
|
1239
|
-
), await this.#s.config.onSettled?.(
|
|
1240
|
-
n,
|
|
1241
|
-
null,
|
|
1242
|
-
this.state.variables,
|
|
1243
|
-
this.state.context,
|
|
1244
|
-
this,
|
|
1245
|
-
s
|
|
1246
|
-
), await this.options.onSettled?.(
|
|
1247
|
-
n,
|
|
1248
|
-
null,
|
|
1249
|
-
t,
|
|
1250
|
-
this.state.context,
|
|
1251
|
-
s
|
|
1252
|
-
), this.#r({ type: "success", data: n }), n;
|
|
1253
|
-
} catch (n) {
|
|
1254
|
-
try {
|
|
1255
|
-
throw await this.#s.config.onError?.(
|
|
1256
|
-
n,
|
|
1257
|
-
t,
|
|
1258
|
-
this.state.context,
|
|
1259
|
-
this,
|
|
1260
|
-
s
|
|
1261
|
-
), await this.options.onError?.(
|
|
1262
|
-
n,
|
|
1263
|
-
t,
|
|
1264
|
-
this.state.context,
|
|
1265
|
-
s
|
|
1266
|
-
), await this.#s.config.onSettled?.(
|
|
1267
|
-
void 0,
|
|
1268
|
-
n,
|
|
1269
|
-
this.state.variables,
|
|
1270
|
-
this.state.context,
|
|
1271
|
-
this,
|
|
1272
|
-
s
|
|
1273
|
-
), await this.options.onSettled?.(
|
|
1274
|
-
void 0,
|
|
1275
|
-
n,
|
|
1276
|
-
t,
|
|
1277
|
-
this.state.context,
|
|
1278
|
-
s
|
|
1279
|
-
), n;
|
|
1280
|
-
} finally {
|
|
1281
|
-
this.#r({ type: "error", error: n });
|
|
1282
|
-
}
|
|
1283
|
-
} finally {
|
|
1284
|
-
this.#s.runNext(this);
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
#r(t) {
|
|
1288
|
-
const e = (s) => {
|
|
1289
|
-
switch (t.type) {
|
|
1290
|
-
case "failed":
|
|
1291
|
-
return {
|
|
1292
|
-
...s,
|
|
1293
|
-
failureCount: t.failureCount,
|
|
1294
|
-
failureReason: t.error
|
|
1295
|
-
};
|
|
1296
|
-
case "pause":
|
|
1297
|
-
return {
|
|
1298
|
-
...s,
|
|
1299
|
-
isPaused: !0
|
|
1300
|
-
};
|
|
1301
|
-
case "continue":
|
|
1302
|
-
return {
|
|
1303
|
-
...s,
|
|
1304
|
-
isPaused: !1
|
|
1305
|
-
};
|
|
1306
|
-
case "pending":
|
|
1307
|
-
return {
|
|
1308
|
-
...s,
|
|
1309
|
-
context: t.context,
|
|
1310
|
-
data: void 0,
|
|
1311
|
-
failureCount: 0,
|
|
1312
|
-
failureReason: null,
|
|
1313
|
-
error: null,
|
|
1314
|
-
isPaused: t.isPaused,
|
|
1315
|
-
status: "pending",
|
|
1316
|
-
variables: t.variables,
|
|
1317
|
-
submittedAt: Date.now()
|
|
1318
|
-
};
|
|
1319
|
-
case "success":
|
|
1320
|
-
return {
|
|
1321
|
-
...s,
|
|
1322
|
-
data: t.data,
|
|
1323
|
-
failureCount: 0,
|
|
1324
|
-
failureReason: null,
|
|
1325
|
-
error: null,
|
|
1326
|
-
status: "success",
|
|
1327
|
-
isPaused: !1
|
|
1328
|
-
};
|
|
1329
|
-
case "error":
|
|
1330
|
-
return {
|
|
1331
|
-
...s,
|
|
1332
|
-
data: void 0,
|
|
1333
|
-
error: t.error,
|
|
1334
|
-
failureCount: s.failureCount + 1,
|
|
1335
|
-
failureReason: t.error,
|
|
1336
|
-
isPaused: !1,
|
|
1337
|
-
status: "error"
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
};
|
|
1341
|
-
this.state = e(this.state), F.batch(() => {
|
|
1342
|
-
this.#e.forEach((s) => {
|
|
1343
|
-
s.onMutationUpdate(t);
|
|
1344
|
-
}), this.#s.notify({
|
|
1345
|
-
mutation: this,
|
|
1346
|
-
type: "updated",
|
|
1347
|
-
action: t
|
|
1348
|
-
});
|
|
1349
|
-
});
|
|
1350
|
-
}
|
|
1351
|
-
};
|
|
1352
|
-
function he() {
|
|
1353
|
-
return {
|
|
1354
|
-
context: void 0,
|
|
1355
|
-
data: void 0,
|
|
1356
|
-
error: null,
|
|
1357
|
-
failureCount: 0,
|
|
1358
|
-
failureReason: null,
|
|
1359
|
-
isPaused: !1,
|
|
1360
|
-
status: "idle",
|
|
1361
|
-
variables: void 0,
|
|
1362
|
-
submittedAt: 0
|
|
1363
|
-
};
|
|
1364
|
-
}
|
|
1365
|
-
var Ve = class extends Z {
|
|
1366
|
-
constructor(t = {}) {
|
|
1367
|
-
super(), this.config = t, this.#t = /* @__PURE__ */ new Set(), this.#e = /* @__PURE__ */ new Map(), this.#s = 0;
|
|
1368
|
-
}
|
|
1369
|
-
#t;
|
|
1370
|
-
#e;
|
|
1371
|
-
#s;
|
|
1372
|
-
build(t, e, s) {
|
|
1373
|
-
const r = new We({
|
|
1374
|
-
client: t,
|
|
1375
|
-
mutationCache: this,
|
|
1376
|
-
mutationId: ++this.#s,
|
|
1377
|
-
options: t.defaultMutationOptions(e),
|
|
1378
|
-
state: s
|
|
1379
|
-
});
|
|
1380
|
-
return this.add(r), r;
|
|
1381
|
-
}
|
|
1382
|
-
add(t) {
|
|
1383
|
-
this.#t.add(t);
|
|
1384
|
-
const e = ot(t);
|
|
1385
|
-
if (typeof e == "string") {
|
|
1386
|
-
const s = this.#e.get(e);
|
|
1387
|
-
s ? s.push(t) : this.#e.set(e, [t]);
|
|
1388
|
-
}
|
|
1389
|
-
this.notify({ type: "added", mutation: t });
|
|
1390
|
-
}
|
|
1391
|
-
remove(t) {
|
|
1392
|
-
if (this.#t.delete(t)) {
|
|
1393
|
-
const e = ot(t);
|
|
1394
|
-
if (typeof e == "string") {
|
|
1395
|
-
const s = this.#e.get(e);
|
|
1396
|
-
if (s)
|
|
1397
|
-
if (s.length > 1) {
|
|
1398
|
-
const r = s.indexOf(t);
|
|
1399
|
-
r !== -1 && s.splice(r, 1);
|
|
1400
|
-
} else s[0] === t && this.#e.delete(e);
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
this.notify({ type: "removed", mutation: t });
|
|
1404
|
-
}
|
|
1405
|
-
canRun(t) {
|
|
1406
|
-
const e = ot(t);
|
|
1407
|
-
if (typeof e == "string") {
|
|
1408
|
-
const r = this.#e.get(e)?.find(
|
|
1409
|
-
(i) => i.state.status === "pending"
|
|
1410
|
-
);
|
|
1411
|
-
return !r || r === t;
|
|
1412
|
-
} else
|
|
1413
|
-
return !0;
|
|
1414
|
-
}
|
|
1415
|
-
runNext(t) {
|
|
1416
|
-
const e = ot(t);
|
|
1417
|
-
return typeof e == "string" ? this.#e.get(e)?.find((r) => r !== t && r.state.isPaused)?.continue() ?? Promise.resolve() : Promise.resolve();
|
|
1418
|
-
}
|
|
1419
|
-
clear() {
|
|
1420
|
-
F.batch(() => {
|
|
1421
|
-
this.#t.forEach((t) => {
|
|
1422
|
-
this.notify({ type: "removed", mutation: t });
|
|
1423
|
-
}), this.#t.clear(), this.#e.clear();
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
getAll() {
|
|
1427
|
-
return Array.from(this.#t);
|
|
1428
|
-
}
|
|
1429
|
-
find(t) {
|
|
1430
|
-
const e = { exact: !0, ...t };
|
|
1431
|
-
return this.getAll().find(
|
|
1432
|
-
(s) => Qt(e, s)
|
|
1433
|
-
);
|
|
1434
|
-
}
|
|
1435
|
-
findAll(t = {}) {
|
|
1436
|
-
return this.getAll().filter((e) => Qt(t, e));
|
|
1437
|
-
}
|
|
1438
|
-
notify(t) {
|
|
1439
|
-
F.batch(() => {
|
|
1440
|
-
this.listeners.forEach((e) => {
|
|
1441
|
-
e(t);
|
|
1442
|
-
});
|
|
1443
|
-
});
|
|
1444
|
-
}
|
|
1445
|
-
resumePausedMutations() {
|
|
1446
|
-
const t = this.getAll().filter((e) => e.state.isPaused);
|
|
1447
|
-
return F.batch(
|
|
1448
|
-
() => Promise.all(
|
|
1449
|
-
t.map((e) => e.continue().catch(L))
|
|
1450
|
-
)
|
|
1451
|
-
);
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
function ot(t) {
|
|
1455
|
-
return t.options.scope?.id;
|
|
1456
|
-
}
|
|
1457
|
-
var Ye = class extends Z {
|
|
1458
|
-
#t;
|
|
1459
|
-
#e = void 0;
|
|
1460
|
-
#s;
|
|
1461
|
-
#i;
|
|
1462
|
-
constructor(e, s) {
|
|
1463
|
-
super(), this.#t = e, this.setOptions(s), this.bindMethods(), this.#r();
|
|
1464
|
-
}
|
|
1465
|
-
bindMethods() {
|
|
1466
|
-
this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
|
|
1467
|
-
}
|
|
1468
|
-
setOptions(e) {
|
|
1469
|
-
const s = this.options;
|
|
1470
|
-
this.options = this.#t.defaultMutationOptions(e), ut(this.options, s) || this.#t.getMutationCache().notify({
|
|
1471
|
-
type: "observerOptionsUpdated",
|
|
1472
|
-
mutation: this.#s,
|
|
1473
|
-
observer: this
|
|
1474
|
-
}), s?.mutationKey && this.options.mutationKey && Y(s.mutationKey) !== Y(this.options.mutationKey) ? this.reset() : this.#s?.state.status === "pending" && this.#s.setOptions(this.options);
|
|
1475
|
-
}
|
|
1476
|
-
onUnsubscribe() {
|
|
1477
|
-
this.hasListeners() || this.#s?.removeObserver(this);
|
|
1478
|
-
}
|
|
1479
|
-
onMutationUpdate(e) {
|
|
1480
|
-
this.#r(), this.#a(e);
|
|
1481
|
-
}
|
|
1482
|
-
getCurrentResult() {
|
|
1483
|
-
return this.#e;
|
|
1484
|
-
}
|
|
1485
|
-
reset() {
|
|
1486
|
-
this.#s?.removeObserver(this), this.#s = void 0, this.#r(), this.#a();
|
|
1487
|
-
}
|
|
1488
|
-
mutate(e, s) {
|
|
1489
|
-
return this.#i = s, this.#s?.removeObserver(this), this.#s = this.#t.getMutationCache().build(this.#t, this.options), this.#s.addObserver(this), this.#s.execute(e);
|
|
1490
|
-
}
|
|
1491
|
-
#r() {
|
|
1492
|
-
const e = this.#s?.state ?? he();
|
|
1493
|
-
this.#e = {
|
|
1494
|
-
...e,
|
|
1495
|
-
isPending: e.status === "pending",
|
|
1496
|
-
isSuccess: e.status === "success",
|
|
1497
|
-
isError: e.status === "error",
|
|
1498
|
-
isIdle: e.status === "idle",
|
|
1499
|
-
mutate: this.mutate,
|
|
1500
|
-
reset: this.reset
|
|
1501
|
-
};
|
|
1502
|
-
}
|
|
1503
|
-
#a(e) {
|
|
1504
|
-
F.batch(() => {
|
|
1505
|
-
if (this.#i && this.hasListeners()) {
|
|
1506
|
-
const s = this.#e.variables, r = this.#e.context, i = {
|
|
1507
|
-
client: this.#t,
|
|
1508
|
-
meta: this.options.meta,
|
|
1509
|
-
mutationKey: this.options.mutationKey
|
|
1510
|
-
};
|
|
1511
|
-
e?.type === "success" ? (this.#i.onSuccess?.(
|
|
1512
|
-
e.data,
|
|
1513
|
-
s,
|
|
1514
|
-
r,
|
|
1515
|
-
i
|
|
1516
|
-
), this.#i.onSettled?.(
|
|
1517
|
-
e.data,
|
|
1518
|
-
null,
|
|
1519
|
-
s,
|
|
1520
|
-
r,
|
|
1521
|
-
i
|
|
1522
|
-
)) : e?.type === "error" && (this.#i.onError?.(
|
|
1523
|
-
e.error,
|
|
1524
|
-
s,
|
|
1525
|
-
r,
|
|
1526
|
-
i
|
|
1527
|
-
), this.#i.onSettled?.(
|
|
1528
|
-
void 0,
|
|
1529
|
-
e.error,
|
|
1530
|
-
s,
|
|
1531
|
-
r,
|
|
1532
|
-
i
|
|
1533
|
-
));
|
|
1534
|
-
}
|
|
1535
|
-
this.listeners.forEach((s) => {
|
|
1536
|
-
s(this.#e);
|
|
1537
|
-
});
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
}, Xe = class extends Z {
|
|
1541
|
-
constructor(t = {}) {
|
|
1542
|
-
super(), this.config = t, this.#t = /* @__PURE__ */ new Map();
|
|
1543
|
-
}
|
|
1544
|
-
#t;
|
|
1545
|
-
build(t, e, s) {
|
|
1546
|
-
const r = e.queryKey, i = e.queryHash ?? Et(r, e);
|
|
1547
|
-
let n = this.get(i);
|
|
1548
|
-
return n || (n = new _e({
|
|
1549
|
-
client: t,
|
|
1550
|
-
queryKey: r,
|
|
1551
|
-
queryHash: i,
|
|
1552
|
-
options: t.defaultQueryOptions(e),
|
|
1553
|
-
state: s,
|
|
1554
|
-
defaultOptions: t.getQueryDefaults(r)
|
|
1555
|
-
}), this.add(n)), n;
|
|
1556
|
-
}
|
|
1557
|
-
add(t) {
|
|
1558
|
-
this.#t.has(t.queryHash) || (this.#t.set(t.queryHash, t), this.notify({
|
|
1559
|
-
type: "added",
|
|
1560
|
-
query: t
|
|
1561
|
-
}));
|
|
1562
|
-
}
|
|
1563
|
-
remove(t) {
|
|
1564
|
-
const e = this.#t.get(t.queryHash);
|
|
1565
|
-
e && (t.destroy(), e === t && this.#t.delete(t.queryHash), this.notify({ type: "removed", query: t }));
|
|
1566
|
-
}
|
|
1567
|
-
clear() {
|
|
1568
|
-
F.batch(() => {
|
|
1569
|
-
this.getAll().forEach((t) => {
|
|
1570
|
-
this.remove(t);
|
|
1571
|
-
});
|
|
1572
|
-
});
|
|
1573
|
-
}
|
|
1574
|
-
get(t) {
|
|
1575
|
-
return this.#t.get(t);
|
|
1576
|
-
}
|
|
1577
|
-
getAll() {
|
|
1578
|
-
return [...this.#t.values()];
|
|
1579
|
-
}
|
|
1580
|
-
find(t) {
|
|
1581
|
-
const e = { exact: !0, ...t };
|
|
1582
|
-
return this.getAll().find(
|
|
1583
|
-
(s) => Dt(e, s)
|
|
1584
|
-
);
|
|
1585
|
-
}
|
|
1586
|
-
findAll(t = {}) {
|
|
1587
|
-
const e = this.getAll();
|
|
1588
|
-
return Object.keys(t).length > 0 ? e.filter((s) => Dt(t, s)) : e;
|
|
1589
|
-
}
|
|
1590
|
-
notify(t) {
|
|
1591
|
-
F.batch(() => {
|
|
1592
|
-
this.listeners.forEach((e) => {
|
|
1593
|
-
e(t);
|
|
1594
|
-
});
|
|
1595
|
-
});
|
|
1596
|
-
}
|
|
1597
|
-
onFocus() {
|
|
1598
|
-
F.batch(() => {
|
|
1599
|
-
this.getAll().forEach((t) => {
|
|
1600
|
-
t.onFocus();
|
|
1601
|
-
});
|
|
1602
|
-
});
|
|
1603
|
-
}
|
|
1604
|
-
onOnline() {
|
|
1605
|
-
F.batch(() => {
|
|
1606
|
-
this.getAll().forEach((t) => {
|
|
1607
|
-
t.onOnline();
|
|
1608
|
-
});
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
}, Je = class {
|
|
1612
|
-
#t;
|
|
1613
|
-
#e;
|
|
1614
|
-
#s;
|
|
1615
|
-
#i;
|
|
1616
|
-
#r;
|
|
1617
|
-
#a;
|
|
1618
|
-
#o;
|
|
1619
|
-
#n;
|
|
1620
|
-
constructor(t = {}) {
|
|
1621
|
-
this.#t = t.queryCache || new Xe(), this.#e = t.mutationCache || new Ve(), this.#s = t.defaultOptions || {}, this.#i = /* @__PURE__ */ new Map(), this.#r = /* @__PURE__ */ new Map(), this.#a = 0;
|
|
1622
|
-
}
|
|
1623
|
-
mount() {
|
|
1624
|
-
this.#a++, this.#a === 1 && (this.#o = Mt.subscribe(async (t) => {
|
|
1625
|
-
t && (await this.resumePausedMutations(), this.#t.onFocus());
|
|
1626
|
-
}), this.#n = ht.subscribe(async (t) => {
|
|
1627
|
-
t && (await this.resumePausedMutations(), this.#t.onOnline());
|
|
1628
|
-
}));
|
|
1629
|
-
}
|
|
1630
|
-
unmount() {
|
|
1631
|
-
this.#a--, this.#a === 0 && (this.#o?.(), this.#o = void 0, this.#n?.(), this.#n = void 0);
|
|
1632
|
-
}
|
|
1633
|
-
isFetching(t) {
|
|
1634
|
-
return this.#t.findAll({ ...t, fetchStatus: "fetching" }).length;
|
|
1635
|
-
}
|
|
1636
|
-
isMutating(t) {
|
|
1637
|
-
return this.#e.findAll({ ...t, status: "pending" }).length;
|
|
1638
|
-
}
|
|
1639
|
-
/**
|
|
1640
|
-
* Imperative (non-reactive) way to retrieve data for a QueryKey.
|
|
1641
|
-
* Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
|
|
1642
|
-
*
|
|
1643
|
-
* Hint: Do not use this function inside a component, because it won't receive updates.
|
|
1644
|
-
* Use `useQuery` to create a `QueryObserver` that subscribes to changes.
|
|
1645
|
-
*/
|
|
1646
|
-
getQueryData(t) {
|
|
1647
|
-
const e = this.defaultQueryOptions({ queryKey: t });
|
|
1648
|
-
return this.#t.get(e.queryHash)?.state.data;
|
|
1649
|
-
}
|
|
1650
|
-
ensureQueryData(t) {
|
|
1651
|
-
const e = this.defaultQueryOptions(t), s = this.#t.build(this, e), r = s.state.data;
|
|
1652
|
-
return r === void 0 ? this.fetchQuery(t) : (t.revalidateIfStale && s.isStaleByTime(H(e.staleTime, s)) && this.prefetchQuery(e), Promise.resolve(r));
|
|
1653
|
-
}
|
|
1654
|
-
getQueriesData(t) {
|
|
1655
|
-
return this.#t.findAll(t).map(({ queryKey: e, state: s }) => {
|
|
1656
|
-
const r = s.data;
|
|
1657
|
-
return [e, r];
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
setQueryData(t, e, s) {
|
|
1661
|
-
const r = this.defaultQueryOptions({ queryKey: t }), n = this.#t.get(
|
|
1662
|
-
r.queryHash
|
|
1663
|
-
)?.state.data, o = Ie(e, n);
|
|
1664
|
-
if (o !== void 0)
|
|
1665
|
-
return this.#t.build(this, r).setData(o, { ...s, manual: !0 });
|
|
1666
|
-
}
|
|
1667
|
-
setQueriesData(t, e, s) {
|
|
1668
|
-
return F.batch(
|
|
1669
|
-
() => this.#t.findAll(t).map(({ queryKey: r }) => [
|
|
1670
|
-
r,
|
|
1671
|
-
this.setQueryData(r, e, s)
|
|
1672
|
-
])
|
|
1673
|
-
);
|
|
1674
|
-
}
|
|
1675
|
-
getQueryState(t) {
|
|
1676
|
-
const e = this.defaultQueryOptions({ queryKey: t });
|
|
1677
|
-
return this.#t.get(
|
|
1678
|
-
e.queryHash
|
|
1679
|
-
)?.state;
|
|
1680
|
-
}
|
|
1681
|
-
removeQueries(t) {
|
|
1682
|
-
const e = this.#t;
|
|
1683
|
-
F.batch(() => {
|
|
1684
|
-
e.findAll(t).forEach((s) => {
|
|
1685
|
-
e.remove(s);
|
|
1686
|
-
});
|
|
1687
|
-
});
|
|
1688
|
-
}
|
|
1689
|
-
resetQueries(t, e) {
|
|
1690
|
-
const s = this.#t;
|
|
1691
|
-
return F.batch(() => (s.findAll(t).forEach((r) => {
|
|
1692
|
-
r.reset();
|
|
1693
|
-
}), this.refetchQueries(
|
|
1694
|
-
{
|
|
1695
|
-
type: "active",
|
|
1696
|
-
...t
|
|
1697
|
-
},
|
|
1698
|
-
e
|
|
1699
|
-
)));
|
|
1700
|
-
}
|
|
1701
|
-
cancelQueries(t, e = {}) {
|
|
1702
|
-
const s = { revert: !0, ...e }, r = F.batch(
|
|
1703
|
-
() => this.#t.findAll(t).map((i) => i.cancel(s))
|
|
1704
|
-
);
|
|
1705
|
-
return Promise.all(r).then(L).catch(L);
|
|
1706
|
-
}
|
|
1707
|
-
invalidateQueries(t, e = {}) {
|
|
1708
|
-
return F.batch(() => (this.#t.findAll(t).forEach((s) => {
|
|
1709
|
-
s.invalidate();
|
|
1710
|
-
}), t?.refetchType === "none" ? Promise.resolve() : this.refetchQueries(
|
|
1711
|
-
{
|
|
1712
|
-
...t,
|
|
1713
|
-
type: t?.refetchType ?? t?.type ?? "active"
|
|
1714
|
-
},
|
|
1715
|
-
e
|
|
1716
|
-
)));
|
|
1717
|
-
}
|
|
1718
|
-
refetchQueries(t, e = {}) {
|
|
1719
|
-
const s = {
|
|
1720
|
-
...e,
|
|
1721
|
-
cancelRefetch: e.cancelRefetch ?? !0
|
|
1722
|
-
}, r = F.batch(
|
|
1723
|
-
() => this.#t.findAll(t).filter((i) => !i.isDisabled() && !i.isStatic()).map((i) => {
|
|
1724
|
-
let n = i.fetch(void 0, s);
|
|
1725
|
-
return s.throwOnError || (n = n.catch(L)), i.state.fetchStatus === "paused" ? Promise.resolve() : n;
|
|
1726
|
-
})
|
|
1727
|
-
);
|
|
1728
|
-
return Promise.all(r).then(L);
|
|
1729
|
-
}
|
|
1730
|
-
fetchQuery(t) {
|
|
1731
|
-
const e = this.defaultQueryOptions(t);
|
|
1732
|
-
e.retry === void 0 && (e.retry = !1);
|
|
1733
|
-
const s = this.#t.build(this, e);
|
|
1734
|
-
return s.isStaleByTime(
|
|
1735
|
-
H(e.staleTime, s)
|
|
1736
|
-
) ? s.fetch(e) : Promise.resolve(s.state.data);
|
|
1737
|
-
}
|
|
1738
|
-
prefetchQuery(t) {
|
|
1739
|
-
return this.fetchQuery(t).then(L).catch(L);
|
|
1740
|
-
}
|
|
1741
|
-
fetchInfiniteQuery(t) {
|
|
1742
|
-
return t.behavior = lt(t.pages), this.fetchQuery(t);
|
|
1743
|
-
}
|
|
1744
|
-
prefetchInfiniteQuery(t) {
|
|
1745
|
-
return this.fetchInfiniteQuery(t).then(L).catch(L);
|
|
1746
|
-
}
|
|
1747
|
-
ensureInfiniteQueryData(t) {
|
|
1748
|
-
return t.behavior = lt(t.pages), this.ensureQueryData(t);
|
|
1749
|
-
}
|
|
1750
|
-
resumePausedMutations() {
|
|
1751
|
-
return ht.isOnline() ? this.#e.resumePausedMutations() : Promise.resolve();
|
|
1752
|
-
}
|
|
1753
|
-
getQueryCache() {
|
|
1754
|
-
return this.#t;
|
|
1755
|
-
}
|
|
1756
|
-
getMutationCache() {
|
|
1757
|
-
return this.#e;
|
|
1758
|
-
}
|
|
1759
|
-
getDefaultOptions() {
|
|
1760
|
-
return this.#s;
|
|
1761
|
-
}
|
|
1762
|
-
setDefaultOptions(t) {
|
|
1763
|
-
this.#s = t;
|
|
1764
|
-
}
|
|
1765
|
-
setQueryDefaults(t, e) {
|
|
1766
|
-
this.#i.set(Y(t), {
|
|
1767
|
-
queryKey: t,
|
|
1768
|
-
defaultOptions: e
|
|
1769
|
-
});
|
|
1770
|
-
}
|
|
1771
|
-
getQueryDefaults(t) {
|
|
1772
|
-
const e = [...this.#i.values()], s = {};
|
|
1773
|
-
return e.forEach((r) => {
|
|
1774
|
-
st(t, r.queryKey) && Object.assign(s, r.defaultOptions);
|
|
1775
|
-
}), s;
|
|
1776
|
-
}
|
|
1777
|
-
setMutationDefaults(t, e) {
|
|
1778
|
-
this.#r.set(Y(t), {
|
|
1779
|
-
mutationKey: t,
|
|
1780
|
-
defaultOptions: e
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
getMutationDefaults(t) {
|
|
1784
|
-
const e = [...this.#r.values()], s = {};
|
|
1785
|
-
return e.forEach((r) => {
|
|
1786
|
-
st(t, r.mutationKey) && Object.assign(s, r.defaultOptions);
|
|
1787
|
-
}), s;
|
|
1788
|
-
}
|
|
1789
|
-
defaultQueryOptions(t) {
|
|
1790
|
-
if (t._defaulted)
|
|
1791
|
-
return t;
|
|
1792
|
-
const e = {
|
|
1793
|
-
...this.#s.queries,
|
|
1794
|
-
...this.getQueryDefaults(t.queryKey),
|
|
1795
|
-
...t,
|
|
1796
|
-
_defaulted: !0
|
|
1797
|
-
};
|
|
1798
|
-
return e.queryHash || (e.queryHash = Et(
|
|
1799
|
-
e.queryKey,
|
|
1800
|
-
e
|
|
1801
|
-
)), e.refetchOnReconnect === void 0 && (e.refetchOnReconnect = e.networkMode !== "always"), e.throwOnError === void 0 && (e.throwOnError = !!e.suspense), !e.networkMode && e.persister && (e.networkMode = "offlineFirst"), e.queryFn === Pt && (e.enabled = !1), e;
|
|
1802
|
-
}
|
|
1803
|
-
defaultMutationOptions(t) {
|
|
1804
|
-
return t?._defaulted ? t : {
|
|
1805
|
-
...this.#s.mutations,
|
|
1806
|
-
...t?.mutationKey && this.getMutationDefaults(t.mutationKey),
|
|
1807
|
-
...t,
|
|
1808
|
-
_defaulted: !0
|
|
1809
|
-
};
|
|
1810
|
-
}
|
|
1811
|
-
clear() {
|
|
1812
|
-
this.#t.clear(), this.#e.clear();
|
|
1813
|
-
}
|
|
1814
|
-
}, le = f.createContext(
|
|
1815
|
-
void 0
|
|
1816
|
-
), Nt = (t) => {
|
|
1817
|
-
const e = f.useContext(le);
|
|
1818
|
-
if (!e)
|
|
1819
|
-
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
1820
|
-
return e;
|
|
1821
|
-
}, Ze = ({
|
|
1822
|
-
client: t,
|
|
1823
|
-
children: e
|
|
1824
|
-
}) => (f.useEffect(() => (t.mount(), () => {
|
|
1825
|
-
t.unmount();
|
|
1826
|
-
}), [t]), /* @__PURE__ */ h.jsx(le.Provider, { value: t, children: e })), de = f.createContext(!1), ts = () => f.useContext(de);
|
|
1827
|
-
de.Provider;
|
|
1828
|
-
function es() {
|
|
1829
|
-
let t = !1;
|
|
1830
|
-
return {
|
|
1831
|
-
clearReset: () => {
|
|
1832
|
-
t = !1;
|
|
1833
|
-
},
|
|
1834
|
-
reset: () => {
|
|
1835
|
-
t = !0;
|
|
1836
|
-
},
|
|
1837
|
-
isReset: () => t
|
|
1838
|
-
};
|
|
1839
|
-
}
|
|
1840
|
-
var ss = f.createContext(es()), rs = () => f.useContext(ss), is = (t, e) => {
|
|
1841
|
-
(t.suspense || t.throwOnError || t.experimental_prefetchInRender) && (e.isReset() || (t.retryOnMount = !1));
|
|
1842
|
-
}, ns = (t) => {
|
|
1843
|
-
f.useEffect(() => {
|
|
1844
|
-
t.clearReset();
|
|
1845
|
-
}, [t]);
|
|
1846
|
-
}, as = ({
|
|
1847
|
-
result: t,
|
|
1848
|
-
errorResetBoundary: e,
|
|
1849
|
-
throwOnError: s,
|
|
1850
|
-
query: r,
|
|
1851
|
-
suspense: i
|
|
1852
|
-
}) => t.isError && !e.isReset() && !t.isFetching && r && (i && t.data === void 0 || re(s, [t.error, r])), os = (t) => {
|
|
1853
|
-
if (t.suspense) {
|
|
1854
|
-
const s = (i) => i === "static" ? i : Math.max(i ?? 1e3, 1e3), r = t.staleTime;
|
|
1855
|
-
t.staleTime = typeof r == "function" ? (...i) => s(r(...i)) : s(r), typeof t.gcTime == "number" && (t.gcTime = Math.max(
|
|
1856
|
-
t.gcTime,
|
|
1857
|
-
1e3
|
|
1858
|
-
));
|
|
1859
|
-
}
|
|
1860
|
-
}, cs = (t, e) => t.isLoading && t.isFetching && !e, us = (t, e) => t?.suspense && e.isPending, zt = (t, e, s) => e.fetchOptimistic(t).catch(() => {
|
|
1861
|
-
s.clearReset();
|
|
1862
|
-
});
|
|
1863
|
-
function fe(t, e, s) {
|
|
1864
|
-
const r = ts(), i = rs(), n = Nt(), o = n.defaultQueryOptions(t);
|
|
1865
|
-
n.getDefaultOptions().queries?._experimental_beforeQuery?.(
|
|
1866
|
-
o
|
|
1867
|
-
), o._optimisticResults = r ? "isRestoring" : "optimistic", os(o), is(o, i), ns(i);
|
|
1868
|
-
const a = !n.getQueryCache().get(o.queryHash), [u] = f.useState(
|
|
1869
|
-
() => new e(
|
|
1870
|
-
n,
|
|
1871
|
-
o
|
|
1872
|
-
)
|
|
1873
|
-
), l = u.getOptimisticResult(o), c = !r && t.subscribed !== !1;
|
|
1874
|
-
if (f.useSyncExternalStore(
|
|
1875
|
-
f.useCallback(
|
|
1876
|
-
(p) => {
|
|
1877
|
-
const d = c ? u.subscribe(F.batchCalls(p)) : L;
|
|
1878
|
-
return u.updateResult(), d;
|
|
1879
|
-
},
|
|
1880
|
-
[u, c]
|
|
1881
|
-
),
|
|
1882
|
-
() => u.getCurrentResult(),
|
|
1883
|
-
() => u.getCurrentResult()
|
|
1884
|
-
), f.useEffect(() => {
|
|
1885
|
-
u.setOptions(o);
|
|
1886
|
-
}, [o, u]), us(o, l))
|
|
1887
|
-
throw zt(o, u, i);
|
|
1888
|
-
if (as({
|
|
1889
|
-
result: l,
|
|
1890
|
-
errorResetBoundary: i,
|
|
1891
|
-
throwOnError: o.throwOnError,
|
|
1892
|
-
query: n.getQueryCache().get(o.queryHash),
|
|
1893
|
-
suspense: o.suspense
|
|
1894
|
-
}))
|
|
1895
|
-
throw l.error;
|
|
1896
|
-
return n.getDefaultOptions().queries?._experimental_afterQuery?.(
|
|
1897
|
-
o,
|
|
1898
|
-
l
|
|
1899
|
-
), o.experimental_prefetchInRender && !V && cs(l, r) && (a ? (
|
|
1900
|
-
// Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
|
|
1901
|
-
zt(o, u, i)
|
|
1902
|
-
) : (
|
|
1903
|
-
// subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
|
|
1904
|
-
n.getQueryCache().get(o.queryHash)?.promise
|
|
1905
|
-
))?.catch(L).finally(() => {
|
|
1906
|
-
u.updateResult();
|
|
1907
|
-
}), o.notifyOnChangeProps ? l : u.trackResult(l);
|
|
1908
|
-
}
|
|
1909
|
-
function hs(t, e) {
|
|
1910
|
-
return fe(t, ce);
|
|
1911
|
-
}
|
|
1912
|
-
function ls(t, e) {
|
|
1913
|
-
const s = Nt(), [r] = f.useState(
|
|
1914
|
-
() => new Ye(
|
|
1915
|
-
s,
|
|
1916
|
-
t
|
|
1917
|
-
)
|
|
1918
|
-
);
|
|
1919
|
-
f.useEffect(() => {
|
|
1920
|
-
r.setOptions(t);
|
|
1921
|
-
}, [r, t]);
|
|
1922
|
-
const i = f.useSyncExternalStore(
|
|
1923
|
-
f.useCallback(
|
|
1924
|
-
(o) => r.subscribe(F.batchCalls(o)),
|
|
1925
|
-
[r]
|
|
1926
|
-
),
|
|
1927
|
-
() => r.getCurrentResult(),
|
|
1928
|
-
() => r.getCurrentResult()
|
|
1929
|
-
), n = f.useCallback(
|
|
1930
|
-
(o, a) => {
|
|
1931
|
-
r.mutate(o, a).catch(L);
|
|
1932
|
-
},
|
|
1933
|
-
[r]
|
|
1934
|
-
);
|
|
1935
|
-
if (i.error && re(r.options.throwOnError, [i.error]))
|
|
1936
|
-
throw i.error;
|
|
1937
|
-
return { ...i, mutate: n, mutateAsync: i.mutate };
|
|
1938
|
-
}
|
|
1939
|
-
function ds(t, e) {
|
|
1940
|
-
return fe(
|
|
1941
|
-
t,
|
|
1942
|
-
Ge
|
|
1943
|
-
);
|
|
1944
|
-
}
|
|
1945
|
-
const fs = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ps = (t) => t.replace(
|
|
1946
|
-
/^([A-Z])|[\s-_]+(\w)/g,
|
|
1947
|
-
(e, s, r) => r ? r.toUpperCase() : s.toLowerCase()
|
|
1948
|
-
), Bt = (t) => {
|
|
1949
|
-
const e = ps(t);
|
|
1950
|
-
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1951
|
-
}, pe = (...t) => t.filter((e, s, r) => !!e && e.trim() !== "" && r.indexOf(e) === s).join(" ").trim(), ms = (t) => {
|
|
1952
|
-
for (const e in t)
|
|
1953
|
-
if (e.startsWith("aria-") || e === "role" || e === "title")
|
|
1954
|
-
return !0;
|
|
1955
|
-
};
|
|
1956
|
-
var gs = {
|
|
1957
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1958
|
-
width: 24,
|
|
1959
|
-
height: 24,
|
|
1960
|
-
viewBox: "0 0 24 24",
|
|
1961
|
-
fill: "none",
|
|
1962
|
-
stroke: "currentColor",
|
|
1963
|
-
strokeWidth: 2,
|
|
1964
|
-
strokeLinecap: "round",
|
|
1965
|
-
strokeLinejoin: "round"
|
|
1966
|
-
};
|
|
1967
|
-
const ys = f.forwardRef(
|
|
1968
|
-
({
|
|
1969
|
-
color: t = "currentColor",
|
|
1970
|
-
size: e = 24,
|
|
1971
|
-
strokeWidth: s = 2,
|
|
1972
|
-
absoluteStrokeWidth: r,
|
|
1973
|
-
className: i = "",
|
|
1974
|
-
children: n,
|
|
1975
|
-
iconNode: o,
|
|
1976
|
-
...a
|
|
1977
|
-
}, u) => f.createElement(
|
|
1978
|
-
"svg",
|
|
1979
|
-
{
|
|
1980
|
-
ref: u,
|
|
1981
|
-
...gs,
|
|
1982
|
-
width: e,
|
|
1983
|
-
height: e,
|
|
1984
|
-
stroke: t,
|
|
1985
|
-
strokeWidth: r ? Number(s) * 24 / Number(e) : s,
|
|
1986
|
-
className: pe("lucide", i),
|
|
1987
|
-
...!n && !ms(a) && { "aria-hidden": "true" },
|
|
1988
|
-
...a
|
|
1989
|
-
},
|
|
1990
|
-
[
|
|
1991
|
-
...o.map(([l, c]) => f.createElement(l, c)),
|
|
1992
|
-
...Array.isArray(n) ? n : [n]
|
|
1993
|
-
]
|
|
1994
|
-
)
|
|
1995
|
-
);
|
|
1996
|
-
const it = (t, e) => {
|
|
1997
|
-
const s = f.forwardRef(
|
|
1998
|
-
({ className: r, ...i }, n) => f.createElement(ys, {
|
|
1999
|
-
ref: n,
|
|
2000
|
-
iconNode: e,
|
|
2001
|
-
className: pe(
|
|
2002
|
-
`lucide-${fs(Bt(t))}`,
|
|
2003
|
-
`lucide-${t}`,
|
|
2004
|
-
r
|
|
2005
|
-
),
|
|
2006
|
-
...i
|
|
2007
|
-
})
|
|
2008
|
-
);
|
|
2009
|
-
return s.displayName = Bt(t), s;
|
|
2010
|
-
};
|
|
2011
|
-
const vs = [
|
|
2012
|
-
["path", { d: "m5 12 7-7 7 7", key: "hav0vg" }],
|
|
2013
|
-
["path", { d: "M12 19V5", key: "x0mq9r" }]
|
|
2014
|
-
], bs = it("arrow-up", vs);
|
|
2015
|
-
const xs = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], ws = it("chevron-down", xs);
|
|
2016
|
-
const Cs = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], Ot = it("loader-circle", Cs);
|
|
2017
|
-
const Ss = [
|
|
2018
|
-
[
|
|
2019
|
-
"path",
|
|
2020
|
-
{
|
|
2021
|
-
d: "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",
|
|
2022
|
-
key: "18887p"
|
|
2023
|
-
}
|
|
2024
|
-
],
|
|
2025
|
-
["path", { d: "M7 11h10", key: "1twpyw" }],
|
|
2026
|
-
["path", { d: "M7 15h6", key: "d9of3u" }],
|
|
2027
|
-
["path", { d: "M7 7h8", key: "af5zfr" }]
|
|
2028
|
-
], Ht = it("message-square-text", Ss);
|
|
2029
|
-
const Os = [
|
|
2030
|
-
["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
|
|
2031
|
-
["path", { d: "M21 3v5h-5", key: "1q7to0" }]
|
|
2032
|
-
], Gt = it("rotate-cw", Os), rt = null, { min: W, max: K, abs: Wt, floor: Rs } = Math, me = (t, e, s) => W(s, K(e, t)), ge = (t) => [...t].sort(((e, s) => e - s)), ye = typeof queueMicrotask == "function" ? queueMicrotask : (t) => {
|
|
2033
|
-
Promise.resolve().then(t);
|
|
2034
|
-
}, Rt = () => {
|
|
2035
|
-
let t;
|
|
2036
|
-
return [new Promise(((e) => {
|
|
2037
|
-
t = e;
|
|
2038
|
-
})), t];
|
|
2039
|
-
}, ve = (t) => {
|
|
2040
|
-
let e;
|
|
2041
|
-
return () => (t && (e = t(), t = void 0), e);
|
|
2042
|
-
}, et = (t, e, s) => {
|
|
2043
|
-
const r = s ? "unshift" : "push";
|
|
2044
|
-
for (let i = 0; i < e; i++) t[r](-1);
|
|
2045
|
-
return t;
|
|
2046
|
-
}, be = (t, e) => {
|
|
2047
|
-
const s = t.t[e];
|
|
2048
|
-
return s === -1 ? t.o : s;
|
|
2049
|
-
}, ks = (t, e, s) => {
|
|
2050
|
-
const r = t.t[e] === -1;
|
|
2051
|
-
return t.t[e] = s, t.i = W(e, t.i), r;
|
|
2052
|
-
}, ct = (t, e) => {
|
|
2053
|
-
if (!t.l) return 0;
|
|
2054
|
-
if (t.i >= e) return t.u[e];
|
|
2055
|
-
t.i < 0 && (t.u[0] = 0, t.i = 0);
|
|
2056
|
-
let s = t.i, r = t.u[s];
|
|
2057
|
-
for (; s < e; ) r += be(t, s), t.u[++s] = r;
|
|
2058
|
-
return t.i = e, r;
|
|
2059
|
-
}, X = (t, e, s = 0, r = t.l - 1) => {
|
|
2060
|
-
let i = s;
|
|
2061
|
-
for (; s <= r; ) {
|
|
2062
|
-
const n = Rs((s + r) / 2);
|
|
2063
|
-
ct(t, n) <= e ? (i = n, s = n + 1) : r = n - 1;
|
|
2064
|
-
}
|
|
2065
|
-
return me(i, 0, t.l - 1);
|
|
2066
|
-
}, Vt = (t, e, s) => {
|
|
2067
|
-
const r = e - t.l;
|
|
2068
|
-
return t.i = s ? -1 : W(e - 1, t.i), t.l = e, r > 0 ? (et(t.u, r), et(t.t, r, s), t.o * r) : (t.u.splice(r), (s ? t.t.splice(0, -r) : t.t.splice(r)).reduce(((i, n) => i - (n === -1 ? t.o : n)), 0));
|
|
2069
|
-
}, Es = typeof window < "u", Ps = (t) => t.documentElement, Ms = (t) => t.ownerDocument, js = (t) => t.defaultView, xe = /* @__PURE__ */ ve((() => !!/iP(hone|od|ad)/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0)), Ns = /* @__PURE__ */ ve((() => "scrollBehavior" in Ps(document).style)), Is = (t) => K(t.h(), t.p()), Ts = (t, e = 40, s = 0, r, i = !1) => {
|
|
2070
|
-
let n = !!s, o = 1, a = 0, u = 0, l = 0, c = 0, p = 0, d = 0, S = 0, y = 0, m = rt, v = [0, n ? K(s - 1, 0) : -1], x = 0, P = !1;
|
|
2071
|
-
const E = ((w, g, O) => ({ o: g, t: O ? et(O.slice(0, W(w, O.length)), K(0, w - O.length)) : et([], w), l: w, i: -1, u: et([], w + 1) }))(t, r ? r[1] : e, r && r[0]), A = /* @__PURE__ */ new Set(), Q = () => l - u, R = () => Q() + p + c, I = (w, g) => ((O, T, N, k) => {
|
|
2072
|
-
if (k = W(k, O.l - 1), ct(O, k) <= T) {
|
|
2073
|
-
const b = X(O, N, k);
|
|
2074
|
-
return [X(O, T, k, b), b];
|
|
2075
|
-
}
|
|
2076
|
-
{
|
|
2077
|
-
const b = X(O, T, void 0, k);
|
|
2078
|
-
return [b, X(O, N, b)];
|
|
2079
|
-
}
|
|
2080
|
-
})(E, w, g, v[0]), M = () => ct(E, E.l), j = (w, g) => {
|
|
2081
|
-
const O = ct(E, w) - p;
|
|
2082
|
-
return g ? M() - O - $(w) : O;
|
|
2083
|
-
}, $ = (w) => be(E, w), U = (w, g = -1) => E.t[w] === g, B = (w) => {
|
|
2084
|
-
w && (xe() && S !== 0 || m && y === 1 ? p += w : c += w);
|
|
2085
|
-
};
|
|
2086
|
-
return { v: () => {
|
|
2087
|
-
A.clear();
|
|
2088
|
-
}, m: () => o, _: () => ((w) => [w.t.slice(), w.o])(E), S: (w = 200) => {
|
|
2089
|
-
if (!P || n) return v;
|
|
2090
|
-
let g, O;
|
|
2091
|
-
if (d) [g, O] = v;
|
|
2092
|
-
else {
|
|
2093
|
-
let T = K(0, R()), N = T + a;
|
|
2094
|
-
i || (w = K(0, w), S !== 1 && (T -= w), S !== 2 && (N += w)), [g, O] = v = I(K(0, T), K(0, N)), m && (g = W(g, m[0]), O = K(O, m[1]));
|
|
2095
|
-
}
|
|
2096
|
-
return [K(g, 0), W(O, E.l - 1)];
|
|
2097
|
-
}, $: (w) => X(E, w - u), I: U, k: j, R: $, T: () => E.l, C: () => l, M: () => S !== 0, p: () => a, O: () => u, h: M, H: () => (d = c, c = 0, [d, y === 2]), W: (w, g) => {
|
|
2098
|
-
const O = [w, g];
|
|
2099
|
-
return A.add(O), () => {
|
|
2100
|
-
A.delete(O);
|
|
2101
|
-
};
|
|
2102
|
-
}, B: (w, g) => {
|
|
2103
|
-
let O, T, N = 0;
|
|
2104
|
-
switch (w) {
|
|
2105
|
-
case 1: {
|
|
2106
|
-
if (g === l && y === 0) break;
|
|
2107
|
-
const k = d;
|
|
2108
|
-
d = 0;
|
|
2109
|
-
const b = g - l, D = Wt(b);
|
|
2110
|
-
k && D < Wt(k) + 1 || y !== 0 || (S = b < 0 ? 2 : 1), n && (n = !1), l = g, N = 4;
|
|
2111
|
-
const z = Q();
|
|
2112
|
-
z >= -a && z <= M() && (N += 1, T = D > a);
|
|
2113
|
-
break;
|
|
2114
|
-
}
|
|
2115
|
-
case 2:
|
|
2116
|
-
N = 8, S !== 0 && (O = !0, N += 1), S = 0, y = 0, m = rt;
|
|
2117
|
-
break;
|
|
2118
|
-
case 3: {
|
|
2119
|
-
const k = g.filter((([b, D]) => !U(b, D)));
|
|
2120
|
-
if (!k.length) break;
|
|
2121
|
-
B(k.reduce(((b, [D, z]) => ((y === 2 || (m && y === 1 ? D < m[0] : j(D + (S === 0 && y === 0 ? 1 : 0)) < Q())) && (b += z - $(D)), b)), 0));
|
|
2122
|
-
for (const [b, D] of k) {
|
|
2123
|
-
const z = $(b), nt = ks(E, b, D);
|
|
2124
|
-
i && (x += nt ? D : D - z);
|
|
2125
|
-
}
|
|
2126
|
-
i && a && x > a && (B(((b, D) => {
|
|
2127
|
-
let z = 0;
|
|
2128
|
-
const nt = [];
|
|
2129
|
-
b.t.forEach(((At, ke) => {
|
|
2130
|
-
At !== -1 && (nt.push(At), ke < D && z++);
|
|
2131
|
-
})), b.i = -1;
|
|
2132
|
-
const at = ge(nt), Ft = at.length, ft = Ft / 2 | 0, Oe = Ft % 2 == 0 ? (at[ft - 1] + at[ft]) / 2 : at[ft], Re = b.o;
|
|
2133
|
-
return ((b.o = Oe) - Re) * K(D - z, 0);
|
|
2134
|
-
})(E, X(E, R()))), i = !1), N = 3, T = !0;
|
|
2135
|
-
break;
|
|
2136
|
-
}
|
|
2137
|
-
case 4:
|
|
2138
|
-
a !== g && (a || (P = T = !0), a = g, N = 3);
|
|
2139
|
-
break;
|
|
2140
|
-
case 5:
|
|
2141
|
-
g[1] ? (B(Vt(E, g[0], !0)), y = 2, N = 1) : (Vt(E, g[0]), N = 1);
|
|
2142
|
-
break;
|
|
2143
|
-
case 6:
|
|
2144
|
-
u = g;
|
|
2145
|
-
break;
|
|
2146
|
-
case 7:
|
|
2147
|
-
y = 1;
|
|
2148
|
-
break;
|
|
2149
|
-
case 8:
|
|
2150
|
-
m = I(g, g + a), N = 1;
|
|
2151
|
-
}
|
|
2152
|
-
N && (o = 1 + (2147483647 & o), O && p && (c += p, p = 0), A.forEach((([k, b]) => {
|
|
2153
|
-
N & k && b(T);
|
|
2154
|
-
})));
|
|
2155
|
-
} };
|
|
2156
|
-
}, It = setTimeout, mt = (t, e) => e ? -t : t, Fs = (t, e, s, r, i, n) => {
|
|
2157
|
-
const o = Date.now;
|
|
2158
|
-
let a = 0, u = !1, l = !1, c = !1, p = !1;
|
|
2159
|
-
const d = (() => {
|
|
2160
|
-
let x;
|
|
2161
|
-
const P = () => {
|
|
2162
|
-
x != rt && clearTimeout(x);
|
|
2163
|
-
}, E = () => {
|
|
2164
|
-
P(), x = It((() => {
|
|
2165
|
-
x = rt, (() => {
|
|
2166
|
-
if (u || l) return u = !1, void d();
|
|
2167
|
-
c = !1, t.B(2);
|
|
2168
|
-
})();
|
|
2169
|
-
}), 150);
|
|
2170
|
-
};
|
|
2171
|
-
return E.J = P, E;
|
|
2172
|
-
})(), S = () => {
|
|
2173
|
-
a = o(), c && (p = !0), t.B(1, r()), d();
|
|
2174
|
-
}, y = (x) => {
|
|
2175
|
-
if (u || !t.M() || x.ctrlKey) return;
|
|
2176
|
-
const P = o() - a;
|
|
2177
|
-
150 > P && 50 < P && (s ? x.deltaX : x.deltaY) && (u = !0);
|
|
2178
|
-
}, m = () => {
|
|
2179
|
-
l = !0, c = p = !1;
|
|
2180
|
-
}, v = () => {
|
|
2181
|
-
l = !1, xe() && (c = !0);
|
|
2182
|
-
};
|
|
2183
|
-
return e.addEventListener("scroll", S), e.addEventListener("wheel", y, { passive: !0 }), e.addEventListener("touchstart", m, { passive: !0 }), e.addEventListener("touchend", v, { passive: !0 }), { A: () => {
|
|
2184
|
-
e.removeEventListener("scroll", S), e.removeEventListener("wheel", y), e.removeEventListener("touchstart", m), e.removeEventListener("touchend", v), d.J();
|
|
2185
|
-
}, L: () => {
|
|
2186
|
-
const [x, P] = t.H();
|
|
2187
|
-
x && (i(x, P, p), p = !1, P && t.p() > t.h() && t.B(1, r()));
|
|
2188
|
-
} };
|
|
2189
|
-
}, As = (t, e, s) => {
|
|
2190
|
-
let r;
|
|
2191
|
-
return [async (i, n) => {
|
|
2192
|
-
if (!await e()) return;
|
|
2193
|
-
r && r();
|
|
2194
|
-
const o = () => {
|
|
2195
|
-
const [a, u] = Rt();
|
|
2196
|
-
return r = () => {
|
|
2197
|
-
u(!1);
|
|
2198
|
-
}, t.p() && It(r, 150), [a, t.W(2, (() => {
|
|
2199
|
-
u(!0);
|
|
2200
|
-
}))];
|
|
2201
|
-
};
|
|
2202
|
-
if (n && Ns()) t.B(8, i()), ye((async () => {
|
|
2203
|
-
for (; ; ) {
|
|
2204
|
-
let a = !0;
|
|
2205
|
-
for (let [c, p] = t.S(); c <= p; c++) if (t.I(c)) {
|
|
2206
|
-
a = !1;
|
|
2207
|
-
break;
|
|
2208
|
-
}
|
|
2209
|
-
if (a) break;
|
|
2210
|
-
const [u, l] = o();
|
|
2211
|
-
try {
|
|
2212
|
-
if (!await u) return;
|
|
2213
|
-
} finally {
|
|
2214
|
-
l();
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
t.B(7), s(i(), n);
|
|
2218
|
-
}));
|
|
2219
|
-
else for (; ; ) {
|
|
2220
|
-
const [a, u] = o();
|
|
2221
|
-
try {
|
|
2222
|
-
if (t.B(7), s(i()), !await a) return;
|
|
2223
|
-
} finally {
|
|
2224
|
-
u();
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
}, () => {
|
|
2228
|
-
r && r();
|
|
2229
|
-
}];
|
|
2230
|
-
}, Ds = (t, e) => {
|
|
2231
|
-
let s, r, i = Rt(), n = !1;
|
|
2232
|
-
const o = e ? "scrollLeft" : "scrollTop", a = e ? "overflowX" : "overflowY", [u, l] = As(t, (() => i[0]), ((c, p) => {
|
|
2233
|
-
c = mt(c, n), p ? s.scrollTo({ [e ? "left" : "top"]: c, behavior: "smooth" }) : s[o] = c;
|
|
2234
|
-
}));
|
|
2235
|
-
return { N(c) {
|
|
2236
|
-
s = c, e && (n = getComputedStyle(c).direction === "rtl"), r = Fs(t, c, e, (() => mt(c[o], n)), ((p, d, S) => {
|
|
2237
|
-
if (S) {
|
|
2238
|
-
const y = c.style, m = y[a];
|
|
2239
|
-
y[a] = "hidden", It((() => {
|
|
2240
|
-
y[a] = m;
|
|
2241
|
-
}));
|
|
2242
|
-
}
|
|
2243
|
-
c[o] = mt(t.C() + p, n), d && l();
|
|
2244
|
-
})), i[1](!0);
|
|
2245
|
-
}, v() {
|
|
2246
|
-
r && r.A(), i[1](!1), i = Rt();
|
|
2247
|
-
}, P: () => n, V(c) {
|
|
2248
|
-
u((() => c));
|
|
2249
|
-
}, X(c) {
|
|
2250
|
-
c += t.C(), u((() => c));
|
|
2251
|
-
}, Y(c, { align: p, smooth: d, offset: S = 0 } = {}) {
|
|
2252
|
-
if (c = me(c, 0, t.T() - 1), p === "nearest") {
|
|
2253
|
-
const y = t.k(c), m = t.C();
|
|
2254
|
-
if (y < m) p = "start";
|
|
2255
|
-
else {
|
|
2256
|
-
if (!(y + t.R(c) > m + t.p())) return;
|
|
2257
|
-
p = "end";
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
u((() => S + t.O() + t.k(c) + (p === "end" ? t.R(c) - t.p() : p === "center" ? (t.R(c) - t.p()) / 2 : 0)), d);
|
|
2261
|
-
}, q: () => {
|
|
2262
|
-
r && r.L();
|
|
2263
|
-
} };
|
|
2264
|
-
}, Qs = (t) => {
|
|
2265
|
-
let e;
|
|
2266
|
-
return { D(s) {
|
|
2267
|
-
(e || (e = new (js(Ms(s))).ResizeObserver(t))).observe(s);
|
|
2268
|
-
}, j(s) {
|
|
2269
|
-
e.unobserve(s);
|
|
2270
|
-
}, A() {
|
|
2271
|
-
e && e.disconnect();
|
|
2272
|
-
} };
|
|
2273
|
-
}, $s = (t, e) => {
|
|
2274
|
-
let s;
|
|
2275
|
-
const r = e ? "width" : "height", i = /* @__PURE__ */ new WeakMap(), n = Qs(((o) => {
|
|
2276
|
-
const a = [];
|
|
2277
|
-
for (const { target: u, contentRect: l } of o) if (u.offsetParent) if (u === s) t.B(4, l[r]);
|
|
2278
|
-
else {
|
|
2279
|
-
const c = i.get(u);
|
|
2280
|
-
c != rt && a.push([c, l[r]]);
|
|
2281
|
-
}
|
|
2282
|
-
a.length && t.B(3, a);
|
|
2283
|
-
}));
|
|
2284
|
-
return { G(o) {
|
|
2285
|
-
n.D(s = o);
|
|
2286
|
-
}, U: (o, a) => (i.set(o, a), n.D(o), () => {
|
|
2287
|
-
i.delete(o), n.j(o);
|
|
2288
|
-
}), v: n.A };
|
|
2289
|
-
}, dt = Es ? f.useLayoutEffect : f.useEffect, q = "current", we = (t, e) => {
|
|
2290
|
-
if (Array.isArray(t)) for (const s of t) we(s, e);
|
|
2291
|
-
else t == null || typeof t == "boolean" || e.push(t);
|
|
2292
|
-
}, Ls = (t, e) => {
|
|
2293
|
-
const s = t.key;
|
|
2294
|
-
return s ?? "_" + e;
|
|
2295
|
-
}, qs = (t) => {
|
|
2296
|
-
const e = f.useRef(null);
|
|
2297
|
-
return e[q] || (e[q] = t());
|
|
2298
|
-
}, Yt = (t) => {
|
|
2299
|
-
const e = f.useRef(t);
|
|
2300
|
-
return dt((() => {
|
|
2301
|
-
e[q] = t;
|
|
2302
|
-
}), [t]), e;
|
|
2303
|
-
}, Us = /* @__PURE__ */ f.memo((({ Z: t, ee: e, te: s, oe: r, ne: i, re: n, se: o, ie: a }) => {
|
|
2304
|
-
const u = f.useRef(null);
|
|
2305
|
-
dt((() => e(u[q], s)), [s]);
|
|
2306
|
-
const l = f.useMemo((() => {
|
|
2307
|
-
const c = { contain: "layout style", position: i && a ? void 0 : "absolute", [o ? "height" : "width"]: "100%", [o ? "top" : "left"]: 0, [o ? "left" : "top"]: r, visibility: !i || a ? void 0 : "hidden" };
|
|
2308
|
-
return o && (c.display = "inline-flex"), c;
|
|
2309
|
-
}), [r, i, a, o]);
|
|
2310
|
-
return h.jsx(n, typeof n == "string" ? { ref: u, style: l, children: t } : { ref: u, style: l, index: s, children: t });
|
|
2311
|
-
})), _s = (t, e) => f.useMemo((() => {
|
|
2312
|
-
if (typeof t == "function") return [(r) => t(e[r], r), e.length];
|
|
2313
|
-
const s = ((r) => {
|
|
2314
|
-
const i = [];
|
|
2315
|
-
return we(r, i), i;
|
|
2316
|
-
})(t);
|
|
2317
|
-
return [(r) => s[r], s.length];
|
|
2318
|
-
}), [t, e]), Ks = /* @__PURE__ */ f.forwardRef((({ children: t, data: e, bufferSize: s, itemSize: r, shift: i, horizontal: n, keepMounted: o, cache: a, startMargin: u = 0, ssrCount: l, as: c = "div", item: p = "div", scrollRef: d, onScroll: S, onScrollEnd: y }, m) => {
|
|
2319
|
-
const [v, x] = _s(t, e), P = f.useRef(null), E = f.useRef(!!l), A = Yt(S), Q = Yt(y), [R, I, M, j] = qs((() => {
|
|
2320
|
-
const k = !!n, b = Ts(x, r, l, a, !r);
|
|
2321
|
-
return [b, $s(b, k), Ds(b, k), k];
|
|
2322
|
-
}));
|
|
2323
|
-
x !== R.T() && R.B(5, [x, i]), u !== R.O() && R.B(6, u);
|
|
2324
|
-
const [$, U] = f.useReducer(R.m, void 0, R.m), B = R.M(), w = R.h(), g = M.P(), O = !j && g ? "unshift" : "push", T = [], N = (k) => {
|
|
2325
|
-
const b = v(k);
|
|
2326
|
-
return h.jsx(Us, { ee: I.U, te: k, oe: R.k(k, g), ne: R.I(k), re: p, Z: b, se: j, ie: E[q] }, Ls(b, k));
|
|
2327
|
-
};
|
|
2328
|
-
if (dt((() => {
|
|
2329
|
-
E[q] = !1, R.W(1, ((b) => {
|
|
2330
|
-
b ? Ee.flushSync(U) : U();
|
|
2331
|
-
})), R.W(4, (() => {
|
|
2332
|
-
A[q] && A[q](R.C());
|
|
2333
|
-
})), R.W(8, (() => {
|
|
2334
|
-
Q[q] && Q[q]();
|
|
2335
|
-
}));
|
|
2336
|
-
const k = (b) => {
|
|
2337
|
-
I.G(b), M.N(b);
|
|
2338
|
-
};
|
|
2339
|
-
return d ? ye((() => {
|
|
2340
|
-
d[q] && k(d[q]);
|
|
2341
|
-
})) : k(P[q].parentElement), () => {
|
|
2342
|
-
R.v(), I.v(), M.v();
|
|
2343
|
-
};
|
|
2344
|
-
}), []), dt((() => {
|
|
2345
|
-
M.q();
|
|
2346
|
-
}), [$]), f.useImperativeHandle(m, (() => ({ get cache() {
|
|
2347
|
-
return R._();
|
|
2348
|
-
}, get scrollOffset() {
|
|
2349
|
-
return R.C();
|
|
2350
|
-
}, get scrollSize() {
|
|
2351
|
-
return Is(R);
|
|
2352
|
-
}, get viewportSize() {
|
|
2353
|
-
return R.p();
|
|
2354
|
-
}, findItemIndex: R.$, getItemOffset: R.k, getItemSize: R.R, scrollToIndex: M.Y, scrollTo: M.V, scrollBy: M.X })), []), o) {
|
|
2355
|
-
const k = new Set(o);
|
|
2356
|
-
for (let [b, D] = R.S(s); b <= D; b++) k.add(b);
|
|
2357
|
-
ge([...k]).forEach(((b) => {
|
|
2358
|
-
T[O](N(b));
|
|
2359
|
-
}));
|
|
2360
|
-
} else for (let [k, b] = R.S(s); k <= b; k++) T[O](N(k));
|
|
2361
|
-
return h.jsx(c, { ref: P, style: { contain: "size style", overflowAnchor: "none", flex: "none", position: "relative", width: j ? w : "100%", height: j ? "100%" : w, pointerEvents: B ? "none" : void 0 }, children: T });
|
|
2362
|
-
}));
|
|
2363
|
-
async function zs(t, e) {
|
|
2364
|
-
return (await kt.get(`/chats/${t}/entries`, {
|
|
2365
|
-
params: e
|
|
2366
|
-
})).data?.entries ?? [];
|
|
2367
|
-
}
|
|
2368
|
-
const Xt = 50, Ce = "chat-messages", Bs = (t, e = { limit: Xt }) => {
|
|
2369
|
-
const s = e.limit ?? Xt;
|
|
2370
|
-
return {
|
|
2371
|
-
queryKey: [Ce, t ? Number(t) : null, { limit: s }],
|
|
2372
|
-
enabled: t !== null,
|
|
2373
|
-
initialPageParam: null,
|
|
2374
|
-
refetchInterval: 5e3,
|
|
2375
|
-
// Fetch new messages every 5 seconds
|
|
2376
|
-
queryFn: async ({ pageParam: r }) => {
|
|
2377
|
-
if (!t) throw new Error("Chat ID is required");
|
|
2378
|
-
return zs(t, {
|
|
2379
|
-
limit: s,
|
|
2380
|
-
prev_message: r ? JSON.stringify(r) : void 0
|
|
2381
|
-
});
|
|
2382
|
-
},
|
|
2383
|
-
getNextPageParam: (r) => !r || r.length !== s ? null : r[r.length - 1]
|
|
2384
|
-
};
|
|
2385
|
-
};
|
|
2386
|
-
function Hs(t, e) {
|
|
2387
|
-
return ds(Bs(t, e));
|
|
2388
|
-
}
|
|
2389
|
-
async function Gs(t) {
|
|
2390
|
-
try {
|
|
2391
|
-
return (await kt.get(`/games/${t}`)).data.game;
|
|
2392
|
-
} catch (e) {
|
|
2393
|
-
if (e instanceof Zt && e.response?.status === 404)
|
|
2394
|
-
return null;
|
|
2395
|
-
throw e;
|
|
2396
|
-
}
|
|
2397
|
-
}
|
|
2398
|
-
const Ws = "game", Vs = (t) => ({
|
|
2399
|
-
queryKey: [Ws, Number(t)],
|
|
2400
|
-
queryFn: async () => Gs(t),
|
|
2401
|
-
staleTime: 1 / 0
|
|
2402
|
-
});
|
|
2403
|
-
function Ys(t) {
|
|
2404
|
-
return hs(Vs(t));
|
|
2405
|
-
}
|
|
2406
|
-
class Se extends Error {
|
|
2407
|
-
constructor(e = "You are sending messages too quickly. Please wait a moment.") {
|
|
2408
|
-
super(e), this.name = "RateLimitError";
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
async function Xs(t) {
|
|
2412
|
-
try {
|
|
2413
|
-
return (await kt.post(`/chats/${t.chatID}/messages`, {
|
|
2414
|
-
chatID: t.chatID,
|
|
2415
|
-
content: t.content
|
|
2416
|
-
})).data;
|
|
2417
|
-
} catch (e) {
|
|
2418
|
-
throw e instanceof Zt && e.response?.status === 429 ? new Se() : e;
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
function Js(t) {
|
|
2422
|
-
const e = Nt(), { onSettled: s, onError: r, ...i } = t ?? {};
|
|
2423
|
-
return ls({
|
|
2424
|
-
mutationFn: (n) => Xs(n),
|
|
2425
|
-
onError: (n, ...o) => {
|
|
2426
|
-
n instanceof Se && console.error(n.message), r?.(n, ...o);
|
|
2427
|
-
},
|
|
2428
|
-
onSettled: (n, ...o) => {
|
|
2429
|
-
n && e.invalidateQueries({ queryKey: [Ce, n.entry.ChatID] }), s?.(n, ...o);
|
|
2430
|
-
},
|
|
2431
|
-
...i
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
const gt = 255;
|
|
2435
|
-
function Zs({ chatId: t, onMessageSent: e }) {
|
|
2436
|
-
const [s, r] = f.useState(""), i = f.useRef(null), n = pt((v) => v.user), o = pt((v) => v.isAuthenticated), a = pt((v) => v.login), { mutate: u, isPending: l } = Js({
|
|
2437
|
-
onSuccess: () => {
|
|
2438
|
-
r(""), e?.();
|
|
2439
|
-
}
|
|
2440
|
-
}), c = () => {
|
|
2441
|
-
const v = s.trim();
|
|
2442
|
-
if (!(!v || l)) {
|
|
2443
|
-
if (!o) {
|
|
2444
|
-
a();
|
|
2445
|
-
return;
|
|
2446
|
-
}
|
|
2447
|
-
u({ chatID: t, content: v });
|
|
2448
|
-
}
|
|
2449
|
-
}, p = (v) => {
|
|
2450
|
-
v.key === "Enter" && !v.shiftKey && (v.preventDefault(), c());
|
|
2451
|
-
}, d = s.length > gt, S = l || !s.trim() || d, y = n?.SolanaAddress || n?.ID?.toString() || "anonymous", m = n?.ImageURL || `https://api.dicebear.com/7.x/avataaars/svg?seed=${y}`;
|
|
2452
|
-
return /* @__PURE__ */ h.jsx("div", { className: "chat-input-container", children: /* @__PURE__ */ h.jsxs("div", { className: "chat-input-wrapper", children: [
|
|
2453
|
-
/* @__PURE__ */ h.jsx(
|
|
2454
|
-
"textarea",
|
|
2455
|
-
{
|
|
2456
|
-
ref: i,
|
|
2457
|
-
value: s,
|
|
2458
|
-
onChange: (v) => r(v.target.value),
|
|
2459
|
-
onKeyDown: p,
|
|
2460
|
-
placeholder: o ? "Write a message..." : "Login to send messages...",
|
|
2461
|
-
className: "chat-input-textarea",
|
|
2462
|
-
disabled: l,
|
|
2463
|
-
maxLength: gt + 50
|
|
2464
|
-
}
|
|
2465
|
-
),
|
|
2466
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-input-footer", children: [
|
|
2467
|
-
o && n && /* @__PURE__ */ h.jsx("div", { className: "chat-input-avatar", children: /* @__PURE__ */ h.jsx("img", { src: m, alt: "You", className: "chat-input-avatar-img" }) }),
|
|
2468
|
-
/* @__PURE__ */ h.jsxs("span", { className: `chat-input-counter ${d ? "chat-input-counter--error" : ""}`, children: [
|
|
2469
|
-
s.length,
|
|
2470
|
-
"/",
|
|
2471
|
-
gt
|
|
2472
|
-
] }),
|
|
2473
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-input-divider" }),
|
|
2474
|
-
/* @__PURE__ */ h.jsx(
|
|
2475
|
-
"button",
|
|
2476
|
-
{
|
|
2477
|
-
type: "button",
|
|
2478
|
-
onClick: c,
|
|
2479
|
-
disabled: S,
|
|
2480
|
-
className: "chat-input-button",
|
|
2481
|
-
"aria-label": o ? "Send message" : "Login to send",
|
|
2482
|
-
children: l ? /* @__PURE__ */ h.jsx(Ot, { className: "chat-input-spinner" }) : /* @__PURE__ */ h.jsx(bs, { className: "chat-input-icon" })
|
|
2483
|
-
}
|
|
2484
|
-
)
|
|
2485
|
-
] })
|
|
2486
|
-
] }) });
|
|
2487
|
-
}
|
|
2488
|
-
function Jt(t, e = 4) {
|
|
2489
|
-
return !t || t.length < e * 2 + 3 ? t : `${t.slice(0, e)}...${t.slice(-e)}`;
|
|
2490
|
-
}
|
|
2491
|
-
function Tt(t) {
|
|
2492
|
-
const e = new Date(t), r = (/* @__PURE__ */ new Date()).getTime() - e.getTime(), i = Math.floor(r / 1e3), n = Math.floor(i / 60), o = Math.floor(n / 60), a = Math.floor(o / 24);
|
|
2493
|
-
return i < 60 ? "now" : n < 60 ? `${n}m` : o < 24 ? `${o}h` : a < 7 ? `${a}d` : e.toLocaleDateString();
|
|
2494
|
-
}
|
|
2495
|
-
function tr({ entry: t }) {
|
|
2496
|
-
if (t.EntryType !== "user_message" || !t.UserMessage) return null;
|
|
2497
|
-
const { UserMessage: e } = t, s = e.User, r = s.SolanaAddress || s.ID.toString(), i = s.ImageURL || `https://api.dicebear.com/7.x/avataaars/svg?seed=${r}`;
|
|
2498
|
-
return /* @__PURE__ */ h.jsxs("div", { className: "chat-message-card", "data-entry-id": t.ID, "data-entry-type": "user_message", children: [
|
|
2499
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-message-avatar", children: /* @__PURE__ */ h.jsx(
|
|
2500
|
-
"img",
|
|
2501
|
-
{
|
|
2502
|
-
src: i,
|
|
2503
|
-
alt: Jt(s.SolanaAddress),
|
|
2504
|
-
className: "chat-message-avatar-img"
|
|
2505
|
-
}
|
|
2506
|
-
) }),
|
|
2507
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-message-content", children: [
|
|
2508
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-message-header", children: [
|
|
2509
|
-
/* @__PURE__ */ h.jsx("span", { className: "chat-message-username", children: Jt(s.SolanaAddress) }),
|
|
2510
|
-
/* @__PURE__ */ h.jsx("span", { className: "chat-message-time", children: Tt(t.CreatedAt) })
|
|
2511
|
-
] }),
|
|
2512
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-message-text", children: e.Content })
|
|
2513
|
-
] })
|
|
2514
|
-
] });
|
|
2515
|
-
}
|
|
2516
|
-
function er({ entry: t }) {
|
|
2517
|
-
if (t.EntryType !== "game_event" || !t.GameEvent) return null;
|
|
2518
|
-
const { GameEvent: e } = t, s = e.Game;
|
|
2519
|
-
return /* @__PURE__ */ h.jsx(
|
|
2520
|
-
"div",
|
|
2521
|
-
{
|
|
2522
|
-
className: "chat-message-card chat-message-card--event",
|
|
2523
|
-
"data-entry-id": t.ID,
|
|
2524
|
-
"data-entry-type": "game_event",
|
|
2525
|
-
children: /* @__PURE__ */ h.jsxs("div", { className: "chat-message-content", children: [
|
|
2526
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-message-header", children: [
|
|
2527
|
-
s && /* @__PURE__ */ h.jsx("span", { className: "chat-message-username chat-message-username--link", children: e.Title }),
|
|
2528
|
-
!s && /* @__PURE__ */ h.jsx("span", { className: "chat-message-username", children: e.Title }),
|
|
2529
|
-
/* @__PURE__ */ h.jsx("span", { className: "chat-message-time", children: Tt(t.CreatedAt) })
|
|
2530
|
-
] }),
|
|
2531
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-message-event-content", children: [
|
|
2532
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-message-text chat-message-text--title", children: e.Title }),
|
|
2533
|
-
e.ShortSummary && /* @__PURE__ */ h.jsx("p", { className: "chat-message-text chat-message-text--summary", children: e.ShortSummary }),
|
|
2534
|
-
e.Description && /* @__PURE__ */ h.jsx("p", { className: "chat-message-text", children: e.Description })
|
|
2535
|
-
] })
|
|
2536
|
-
] })
|
|
2537
|
-
}
|
|
2538
|
-
);
|
|
2539
|
-
}
|
|
2540
|
-
function sr({ entry: t }) {
|
|
2541
|
-
if (t.EntryType !== "token_event" || !t.TokenEvent) return null;
|
|
2542
|
-
const { TokenEvent: e } = t, s = e.Token;
|
|
2543
|
-
return /* @__PURE__ */ h.jsx(
|
|
2544
|
-
"div",
|
|
2545
|
-
{
|
|
2546
|
-
className: "chat-message-card chat-message-card--event",
|
|
2547
|
-
"data-entry-id": t.ID,
|
|
2548
|
-
"data-entry-type": "token_event",
|
|
2549
|
-
children: /* @__PURE__ */ h.jsxs("div", { className: "chat-message-content", children: [
|
|
2550
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-message-header", children: [
|
|
2551
|
-
s && /* @__PURE__ */ h.jsxs("span", { className: "chat-message-username chat-message-username--link", children: [
|
|
2552
|
-
e.Title,
|
|
2553
|
-
" (",
|
|
2554
|
-
e.Token?.Ticker,
|
|
2555
|
-
")"
|
|
2556
|
-
] }),
|
|
2557
|
-
!s && /* @__PURE__ */ h.jsx("span", { className: "chat-message-username", children: e.Title }),
|
|
2558
|
-
/* @__PURE__ */ h.jsx("span", { className: "chat-message-time", children: Tt(t.CreatedAt) })
|
|
2559
|
-
] }),
|
|
2560
|
-
/* @__PURE__ */ h.jsxs("div", { className: "chat-message-event-content", children: [
|
|
2561
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-message-text chat-message-text--title", children: e.Title }),
|
|
2562
|
-
e.ShortSummary && /* @__PURE__ */ h.jsx("p", { className: "chat-message-text chat-message-text--summary", children: e.ShortSummary }),
|
|
2563
|
-
e.Description && /* @__PURE__ */ h.jsx("p", { className: "chat-message-text", children: e.Description })
|
|
2564
|
-
] })
|
|
2565
|
-
] })
|
|
2566
|
-
}
|
|
2567
|
-
);
|
|
2568
|
-
}
|
|
2569
|
-
function rr({ entry: t }) {
|
|
2570
|
-
switch (t.EntryType) {
|
|
2571
|
-
case "user_message":
|
|
2572
|
-
return /* @__PURE__ */ h.jsx(tr, { entry: t });
|
|
2573
|
-
case "game_event":
|
|
2574
|
-
return /* @__PURE__ */ h.jsx(er, { entry: t });
|
|
2575
|
-
case "token_event":
|
|
2576
|
-
return /* @__PURE__ */ h.jsx(sr, { entry: t });
|
|
2577
|
-
default:
|
|
2578
|
-
return null;
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
const ir = new Je({
|
|
2582
|
-
defaultOptions: {
|
|
2583
|
-
queries: {
|
|
2584
|
-
staleTime: 1e3 * 60,
|
|
2585
|
-
// 1 minute
|
|
2586
|
-
refetchOnWindowFocus: !1
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
});
|
|
2590
|
-
function nr({ gameId: t, onOpenChange: e }) {
|
|
2591
|
-
const [s, r] = f.useState(!1), i = f.useRef(!1), n = f.useRef(!1), o = f.useRef(!1), a = f.useRef(!1), u = f.useRef(!0), l = f.useRef(!1), c = f.useRef(null), {
|
|
2592
|
-
data: p,
|
|
2593
|
-
isLoading: d,
|
|
2594
|
-
isError: S,
|
|
2595
|
-
error: y,
|
|
2596
|
-
refetch: m
|
|
2597
|
-
} = Ys(t), v = p?.ChatID ?? null, {
|
|
2598
|
-
data: x,
|
|
2599
|
-
fetchNextPage: P,
|
|
2600
|
-
hasNextPage: E,
|
|
2601
|
-
isFetchingNextPage: A,
|
|
2602
|
-
isLoading: Q,
|
|
2603
|
-
isFetching: R,
|
|
2604
|
-
isError: I,
|
|
2605
|
-
refetch: M
|
|
2606
|
-
} = Hs(v), j = f.useMemo(() => x ? x.pages.flat().reverse() : [], [x]), $ = f.useCallback(() => {
|
|
2607
|
-
u.current = !0, n.current = !0;
|
|
2608
|
-
}, []), U = f.useCallback(() => {
|
|
2609
|
-
i.current || !E || A || (i.current = !0, a.current = !0, P().finally(() => {
|
|
2610
|
-
i.current = !1;
|
|
2611
|
-
}));
|
|
2612
|
-
}, [E, A, P]);
|
|
2613
|
-
f.useLayoutEffect(() => {
|
|
2614
|
-
a.current = !1;
|
|
2615
|
-
}), f.useEffect(() => {
|
|
2616
|
-
if (!c.current) return;
|
|
2617
|
-
const g = c.current, O = j.length - 1;
|
|
2618
|
-
u.current && O >= 0 && g.scrollToIndex(O, { align: "end" });
|
|
2619
|
-
}, [j.length]), f.useLayoutEffect(() => {
|
|
2620
|
-
if (s && c.current && j.length > 0 && !l.current) {
|
|
2621
|
-
const g = c.current, O = j.length - 1;
|
|
2622
|
-
g.scrollToIndex(O, { align: "end" }), u.current = !0, l.current = !0;
|
|
2623
|
-
}
|
|
2624
|
-
s || (l.current = !1);
|
|
2625
|
-
}, [s, j.length]), f.useEffect(() => {
|
|
2626
|
-
const g = c.current;
|
|
2627
|
-
if (!g) return;
|
|
2628
|
-
const O = o.current && !R;
|
|
2629
|
-
if (n.current && O) {
|
|
2630
|
-
const T = j.length - 1;
|
|
2631
|
-
T >= 0 && g.scrollToIndex(T, { align: "end" }), n.current = !1;
|
|
2632
|
-
}
|
|
2633
|
-
o.current = R;
|
|
2634
|
-
}, [R, j.length]);
|
|
2635
|
-
const B = () => {
|
|
2636
|
-
const g = !s;
|
|
2637
|
-
r(g), e?.(g);
|
|
2638
|
-
}, w = () => d ? /* @__PURE__ */ h.jsxs("div", { className: "chat-empty", children: [
|
|
2639
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-empty-icon", children: /* @__PURE__ */ h.jsx(Ot, { className: "chat-spinner" }) }),
|
|
2640
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-text", children: "Loading game data..." })
|
|
2641
|
-
] }) : S ? /* @__PURE__ */ h.jsxs("div", { className: "chat-empty", children: [
|
|
2642
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-title", children: "Failed to load game" }),
|
|
2643
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-text", children: y instanceof Error ? y.message : "Unknown error occurred" }),
|
|
2644
|
-
/* @__PURE__ */ h.jsxs("button", { type: "button", onClick: () => m(), className: "chat-retry-button", children: [
|
|
2645
|
-
/* @__PURE__ */ h.jsx(Gt, { className: "chat-retry-icon" }),
|
|
2646
|
-
"Retry"
|
|
2647
|
-
] })
|
|
2648
|
-
] }) : v ? Q ? /* @__PURE__ */ h.jsxs("div", { className: "chat-empty", children: [
|
|
2649
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-empty-icon", children: /* @__PURE__ */ h.jsx(Ot, { className: "chat-spinner" }) }),
|
|
2650
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-text", children: "Loading messages..." })
|
|
2651
|
-
] }) : I ? /* @__PURE__ */ h.jsxs("div", { className: "chat-empty", children: [
|
|
2652
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-title", children: "Failed to load messages" }),
|
|
2653
|
-
/* @__PURE__ */ h.jsxs("button", { type: "button", onClick: () => M(), className: "chat-retry-button", children: [
|
|
2654
|
-
/* @__PURE__ */ h.jsx(Gt, { className: "chat-retry-icon" }),
|
|
2655
|
-
"Retry"
|
|
2656
|
-
] })
|
|
2657
|
-
] }) : j.length === 0 ? /* @__PURE__ */ h.jsxs("div", { className: "chat-empty", children: [
|
|
2658
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-empty-icon", children: /* @__PURE__ */ h.jsx(Ht, { className: "chat-empty-svg" }) }),
|
|
2659
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-title", children: "No messages yet" }),
|
|
2660
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-text", children: "Be the first to start the conversation!" })
|
|
2661
|
-
] }) : /* @__PURE__ */ h.jsxs("div", { className: "chat-messages-container", children: [
|
|
2662
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-messages-spacer" }),
|
|
2663
|
-
/* @__PURE__ */ h.jsx(
|
|
2664
|
-
Ks,
|
|
2665
|
-
{
|
|
2666
|
-
ref: c,
|
|
2667
|
-
shift: a.current,
|
|
2668
|
-
onScroll: (g) => {
|
|
2669
|
-
c.current && (u.current = g - c.current.scrollSize + c.current.viewportSize >= -1.5, g < 100 && (a.current = !0, U()));
|
|
2670
|
-
},
|
|
2671
|
-
children: j.map((g) => /* @__PURE__ */ h.jsx(rr, { entry: g }, g.ID))
|
|
2672
|
-
}
|
|
2673
|
-
)
|
|
2674
|
-
] }) : /* @__PURE__ */ h.jsxs("div", { className: "chat-empty", children: [
|
|
2675
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-title", children: "Chat not available" }),
|
|
2676
|
-
/* @__PURE__ */ h.jsx("p", { className: "chat-empty-text", children: "This game does not have a chat configured." })
|
|
2677
|
-
] });
|
|
2678
|
-
return s ? /* @__PURE__ */ h.jsxs("div", { className: "chat-widget", children: [
|
|
2679
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-widget-header", children: /* @__PURE__ */ h.jsx(
|
|
2680
|
-
"button",
|
|
2681
|
-
{
|
|
2682
|
-
type: "button",
|
|
2683
|
-
className: "chat-widget-header-button",
|
|
2684
|
-
onClick: B,
|
|
2685
|
-
"aria-label": "Minimize chat",
|
|
2686
|
-
children: /* @__PURE__ */ h.jsx(ws, { className: "chat-widget-header-icon" })
|
|
2687
|
-
}
|
|
2688
|
-
) }),
|
|
2689
|
-
/* @__PURE__ */ h.jsx("div", { className: "chat-widget-body", children: w() }),
|
|
2690
|
-
v && /* @__PURE__ */ h.jsx(Zs, { chatId: v, onMessageSent: $ })
|
|
2691
|
-
] }) : /* @__PURE__ */ h.jsx(
|
|
2692
|
-
"button",
|
|
2693
|
-
{
|
|
2694
|
-
type: "button",
|
|
2695
|
-
className: "chat-widget-bubble",
|
|
2696
|
-
onClick: B,
|
|
2697
|
-
"aria-label": "Open chat",
|
|
2698
|
-
children: /* @__PURE__ */ h.jsx(Ht, { className: "chat-widget-bubble-icon" })
|
|
2699
|
-
}
|
|
2700
|
-
);
|
|
2701
|
-
}
|
|
2702
|
-
function ar(t) {
|
|
2703
|
-
return /* @__PURE__ */ h.jsx(Ze, { client: ir, children: /* @__PURE__ */ h.jsx(nr, { ...t }) });
|
|
2704
|
-
}
|
|
2705
|
-
const or = ":host{--chat-position-offset-x: 20px;--chat-position-offset-y: 20px;position:fixed;z-index:9999;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;color:#fffffff2;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;inset:auto}:host:not([data-side]):not([data-vertical]){left:auto;right:var(--chat-position-offset-x, 20px);top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-side=left][data-vertical=top]{left:var(--chat-position-offset-x, 20px);right:auto;top:var(--chat-position-offset-y, 20px);bottom:auto}:host[data-side=right][data-vertical=top]{left:auto;right:var(--chat-position-offset-x, 20px);top:var(--chat-position-offset-y, 20px);bottom:auto}:host[data-side=left][data-vertical=bottom]{left:var(--chat-position-offset-x, 20px);right:auto;top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-side=right][data-vertical=bottom]{left:auto;right:var(--chat-position-offset-x, 20px);top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-side=left]{left:var(--chat-position-offset-x, 20px);right:auto}:host[data-side=right]{left:auto;right:var(--chat-position-offset-x, 20px)}:host[data-vertical=top]{top:var(--chat-position-offset-y, 20px);bottom:auto}:host[data-vertical=bottom]{top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-vertical=middle]{top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-vertical=middle].chat-widget-open{top:50%;bottom:auto;transform:translateY(-50%)}:host[data-side=left][data-vertical=middle]{left:var(--chat-position-offset-x, 20px);right:auto;top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-side=left][data-vertical=middle].chat-widget-open{left:var(--chat-position-offset-x, 20px);right:auto;top:50%;bottom:auto;transform:translateY(-50%)}:host[data-side=right][data-vertical=middle]{left:auto;right:var(--chat-position-offset-x, 20px);top:auto;bottom:var(--chat-position-offset-y, 20px)}:host[data-side=right][data-vertical=middle].chat-widget-open{left:auto;right:var(--chat-position-offset-x, 20px);top:50%;bottom:auto;transform:translateY(-50%)}.chat-widget-bubble{display:flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:50%;background:#000000a6;background-blend-mode:overlay;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);color:#fffffff2;border:.5px solid rgba(255,255,255,.1);cursor:pointer;box-shadow:0 4px 12px #00000026;will-change:transform;transition:transform .2s ease,box-shadow .2s ease,background .2s ease}.chat-widget-bubble:hover{transform:scale(1.05);box-shadow:0 6px 16px #0003}.chat-widget-bubble:active{transform:scale(.98)}.chat-widget-bubble-icon{width:24px;height:24px}.chat-widget{display:flex;flex-direction:column;width:380px;height:520px;max-width:calc(100vw - 40px);max-height:calc(100vh - 100px);background:transparent;border:none;border-radius:16px;overflow:hidden;animation:chat-widget-open .2s ease-out}@keyframes chat-widget-open{0%{opacity:0;transform:translateY(10px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}.chat-widget-header{display:flex;align-items:center;justify-content:flex-end;padding:6px;background:transparent;border-bottom:none}.chat-widget-header-button{display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:50%;background:#000000a6;background-blend-mode:overlay;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);color:#fffffff2;border:.5px solid rgba(255,255,255,.1);cursor:pointer;box-shadow:0 4px 12px #00000026;will-change:transform;transition:transform .2s ease,box-shadow .2s ease,background .2s ease}.chat-widget-header-button:hover{transform:scale(1.05);background:#11111180;box-shadow:0 6px 16px #0003}.chat-widget-header-button:active{transform:scale(.98)}.chat-widget-header-icon{width:20px;height:20px}.chat-widget-body{flex:1;overflow:hidden;display:flex;flex-direction:column}.chat-messages-container{flex:1;overflow-y:auto;overflow-anchor:none;overscroll-behavior:contain;display:flex;flex-direction:column;padding:12px 12px 0}.chat-messages-spacer{flex-grow:1}.chat-message-card{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;margin-bottom:8px;background:#000000a6;background-blend-mode:overlay;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-radius:16px;border:.5px solid rgba(255,255,255,.1)}.chat-message-avatar{flex-shrink:0}.chat-message-avatar-img{width:36px;height:36px;border-radius:50%;background:#ffffff1a;object-fit:cover}.chat-message-content{flex:1;min-width:0}.chat-message-header{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px}.chat-message-username{font-size:13px;font-weight:500;color:#ffffffb3}.chat-message-time{font-size:11px;color:#fff9;flex-shrink:0}.chat-message-text{margin:0;font-size:14px;color:#fffffff2;white-space:pre-wrap;word-wrap:break-word;overflow-wrap:break-word}.chat-message-text--title{font-weight:600;margin-bottom:4px}.chat-message-text--summary{color:#ffffffb3;margin-bottom:4px}.chat-message-username--link{cursor:pointer;text-decoration:underline;text-decoration-color:transparent;transition:text-decoration-color .15s ease}.chat-message-username--link:hover{text-decoration-color:currentColor}.chat-message-card--event{padding-left:12px}.chat-message-event-content{display:flex;flex-direction:column;gap:4px}.chat-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;padding:32px;text-align:center;margin:12px;background:#000000a6;background-blend-mode:overlay;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-radius:16px;border:.5px solid rgba(255,255,255,.1)}.chat-empty-icon{margin-bottom:12px}.chat-empty-svg{width:40px;height:40px;color:#ffffffb3}.chat-empty-title{margin:0 0 4px;font-size:15px;font-weight:600;color:#fffffff2}.chat-empty-text{margin:0;font-size:13px;color:#ffffffb3}.chat-retry-button{display:inline-flex;align-items:center;gap:6px;margin-top:12px;padding:8px 14px;font-size:13px;font-weight:500;color:#fffffff2;background:#000000a6;background-blend-mode:overlay;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:.5px solid rgba(255,255,255,.1);border-radius:8px;cursor:pointer;transition:border-color .15s ease}.chat-retry-button:hover{border-color:#fff3}.chat-retry-icon{width:14px;height:14px}.chat-spinner{width:24px;height:24px;color:#fffffff2;animation:chat-spinner-rotate 1s linear infinite}@keyframes chat-spinner-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.chat-input-container{border-top:none;background:transparent}.chat-input-wrapper{display:flex;flex-direction:column;background:#000000a6;background-blend-mode:overlay;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border:.5px solid rgba(255,255,255,.1);border-radius:16px;overflow:hidden;transition:border-color .15s ease;min-width:0;max-width:100%}.chat-input-wrapper:focus-within{border-color:#fff3}.chat-input-textarea{width:100%;min-height:80px;max-height:120px;padding:10px 12px;font-size:16px;font-family:inherit;line-height:1.5;color:#fffffff2;background:transparent;border:none;resize:none;outline:none;box-sizing:border-box;overflow-wrap:break-word;word-wrap:break-word;overflow-x:hidden}.chat-input-textarea::placeholder{color:#ffffff80}.chat-input-textarea:disabled{opacity:.6;cursor:not-allowed}.chat-input-footer{display:flex;align-items:center;gap:8px;padding:8px 12px;background:transparent;border-top:1px solid rgba(255,255,255,.1)}.chat-input-avatar{flex-shrink:0}.chat-input-avatar-img{width:28px;height:28px;border-radius:50%;background:#ffffff1a;object-fit:cover}.chat-input-counter{font-size:12px;color:#ffffffb3;margin-left:auto}.chat-input-counter--error{color:#ff5757e6}.chat-input-divider{width:1px;height:16px;background:#ffffff1a}.chat-input-button{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;border-radius:50%;background:#4fff7e;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);color:#000000e6;cursor:pointer;transition:opacity .15s ease,transform .15s ease,background .15s ease}.chat-input-button:hover:not(:disabled){background:#3fe66a;opacity:1}.chat-input-button:active:not(:disabled){transform:scale(.95)}.chat-input-button:disabled{opacity:.5;cursor:not-allowed}.chat-input-icon{width:16px;height:16px}.chat-input-spinner{width:16px;height:16px;animation:chat-spinner-rotate 1s linear infinite}@media(max-width:480px){:host{inset:auto 10px 10px}:host .chat-widget{width:100%;max-width:none;height:calc(100vh - 80px);transform:none;top:auto;bottom:10px}.chat-widget-bubble{width:48px;height:48px}.chat-widget-bubble-icon{width:20px;height:20px}}";
|
|
2706
|
-
let J = null, C = null, tt = null;
|
|
2707
|
-
function dr(t, e) {
|
|
2708
|
-
if (J) {
|
|
2709
|
-
console.warn("Chat widget already mounted");
|
|
2710
|
-
return;
|
|
2711
|
-
}
|
|
2712
|
-
C = document.createElement("div"), C.id = "autogames-chat-widget", document.body.appendChild(C);
|
|
2713
|
-
const s = e?.position || {}, r = s.side || "right", i = s.vertical || "bottom", n = s.offsetX ?? 20, o = s.offsetY ?? 20, a = C.attachShadow({ mode: "open" });
|
|
2714
|
-
C.setAttribute("data-side", r), C.setAttribute("data-vertical", i), C.style.setProperty("--chat-position-offset-x", `${n}px`), C.style.setProperty("--chat-position-offset-y", `${o}px`), C.style.position = "fixed", C.style.zIndex = "9999", C.style.left = "auto", C.style.right = "auto", C.style.top = "auto", C.style.bottom = "auto", r === "left" ? (C.style.left = `${n}px`, C.style.right = "auto") : (C.style.left = "auto", C.style.right = `${n}px`), i === "top" ? (C.style.top = `${o}px`, C.style.bottom = "auto") : (i === "bottom" || i === "middle") && (C.style.top = "auto", C.style.bottom = `${o}px`);
|
|
2715
|
-
const u = document.createElement("style");
|
|
2716
|
-
u.textContent = or, a.appendChild(u);
|
|
2717
|
-
const l = document.createElement("div");
|
|
2718
|
-
l.id = "chat-widget-root", a.appendChild(l), tt = l, J = Pe.createRoot(l), J.render(
|
|
2719
|
-
/* @__PURE__ */ h.jsx(f.StrictMode, { children: /* @__PURE__ */ h.jsx(
|
|
2720
|
-
ar,
|
|
2721
|
-
{
|
|
2722
|
-
gameId: t,
|
|
2723
|
-
onClose: () => cr(),
|
|
2724
|
-
onOpenChange: (c) => {
|
|
2725
|
-
if (tt && (c ? tt.classList.add("chat-widget-open") : tt.classList.remove("chat-widget-open")), C) {
|
|
2726
|
-
if (c)
|
|
2727
|
-
C.classList.add("chat-widget-open"), C.getAttribute("data-vertical") === "middle" && (C.style.top = "50%", C.style.bottom = "auto", C.style.transform = "translateY(-50%)");
|
|
2728
|
-
else if (C.classList.remove("chat-widget-open"), C.getAttribute("data-vertical") === "middle") {
|
|
2729
|
-
const S = C.style.getPropertyValue("--chat-position-offset-y") || "20px";
|
|
2730
|
-
C.style.top = "auto", C.style.bottom = S, C.style.transform = "none";
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
|
-
) })
|
|
2736
|
-
);
|
|
2737
|
-
}
|
|
2738
|
-
function cr() {
|
|
2739
|
-
J && (J.unmount(), J = null), C && (C.remove(), C = null), tt = null;
|
|
2740
|
-
}
|
|
2741
|
-
export {
|
|
2742
|
-
dr as mountChatWidget,
|
|
2743
|
-
cr as unmountChatWidget
|
|
2744
|
-
};
|