@unicom-cloud/ui 0.8.110 → 0.8.111

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.
@@ -0,0 +1,2160 @@
1
+ import { useEffect as C, useState as b, useMemo as x, useRef as y, useLayoutEffect as he, useCallback as B } from "react";
2
+ import "./DsaQZE4X.js";
3
+ import { isFunction as k, isString as te, isNumber as F, isEqual as qe, isBoolean as Ve, isUndefined as Ue, isObject as $e } from "@unicom-cloud/utils/is";
4
+ import { g as D, u as L, c as V, b as $, i as We, s as Ge, d as Ke, e as Je, f as Qe } from "./BDgzrqDN.js";
5
+ import { a as E } from "./D1iEYgh3.js";
6
+ import { u as ne } from "./BJeTDXdz.js";
7
+ import ce from "@unicom-cloud/utils/js-cookie";
8
+ import Ze from "dayjs";
9
+ import De from "lodash/debounce";
10
+ import { i as re } from "./CdXR6dj7.js";
11
+ import { u as K, c as et } from "./DfChiMIE.js";
12
+ import { i as q } from "./Di5KBCVQ.js";
13
+ import z from "@unicom-cloud/utils/screenfull";
14
+ import { isAppleDevice as tt } from "@unicom-cloud/utils/constant/platform";
15
+ import { u as se } from "./BO_5qdS_.js";
16
+ import Me from "lodash/throttle";
17
+ import de from "lodash/isPlainObject";
18
+ import ae from "@unicom-cloud/utils/query-string";
19
+ import * as nt from "react-router";
20
+ function rt(e) {
21
+ return k(e[Symbol.asyncIterator]);
22
+ }
23
+ function hn(e, t) {
24
+ C(() => {
25
+ const n = e();
26
+ let r = !1;
27
+ async function s() {
28
+ if (rt(n))
29
+ for (; !((await n.next()).done || r); )
30
+ ;
31
+ else
32
+ await n;
33
+ }
34
+ return s(), () => {
35
+ r = !0;
36
+ };
37
+ }, t);
38
+ }
39
+ function st(e = !1, t) {
40
+ const [n, r] = b(e), s = x(() => {
41
+ const o = t === void 0 ? !e : t;
42
+ return {
43
+ toggle: () => r((l) => l === e ? o : e),
44
+ set: (l) => r(l),
45
+ setLeft: () => r(e),
46
+ setRight: () => r(o)
47
+ };
48
+ }, []);
49
+ return [n, s];
50
+ }
51
+ function ot(e = !1) {
52
+ const [t, { toggle: n, set: r }] = st(!!e), s = x(() => ({
53
+ toggle: n,
54
+ set: (c) => r(!!c),
55
+ setTrue: () => r(!0),
56
+ setFalse: () => r(!1)
57
+ }), []);
58
+ return [t, s];
59
+ }
60
+ const ct = (e) => e.every((t) => {
61
+ const n = D(t);
62
+ return n ? n.getRootNode() instanceof ShadowRoot : !1;
63
+ }), at = (e) => e ? e.getRootNode() : document, ut = (e) => {
64
+ if (!e || !document.getRootNode)
65
+ return document;
66
+ const t = Array.isArray(e) ? e : [e];
67
+ return ct(t) ? at(D(t[0])) : document;
68
+ };
69
+ function pn(e, t, n = "click") {
70
+ const r = L(e);
71
+ V(
72
+ () => {
73
+ const s = (c) => {
74
+ (Array.isArray(t) ? t : [t]).some((i) => {
75
+ const l = D(i);
76
+ return !l || l.contains(c.target);
77
+ }) || r.current(c);
78
+ }, o = ut(t), a = Array.isArray(n) ? n : [n];
79
+ return a.forEach(
80
+ (c) => o.addEventListener(c, s)
81
+ ), () => {
82
+ a.forEach(
83
+ (c) => o.removeEventListener(c, s)
84
+ );
85
+ };
86
+ },
87
+ Array.isArray(n) ? n : [n],
88
+ t
89
+ );
90
+ }
91
+ function vn(e, t = {}) {
92
+ const n = e ?? {}, {
93
+ defaultValue: r,
94
+ defaultValuePropName: s = "defaultValue",
95
+ valuePropName: o = "value",
96
+ trigger: a = "onChange"
97
+ } = t, c = n[o], f = Object.prototype.hasOwnProperty.call(
98
+ n,
99
+ o
100
+ ), i = x(() => f ? c : Object.prototype.hasOwnProperty.call(n, s) ? n[s] : r, []), l = y(i);
101
+ f && (l.current = c);
102
+ const u = ne();
103
+ function m(h, ...p) {
104
+ const d = k(h) ? h(l.current) : h;
105
+ f || (l.current = d, u()), n[a] && n[a](d, ...p);
106
+ }
107
+ return [l.current, E(m)];
108
+ }
109
+ function yn(e, t = {}) {
110
+ const [n, r] = b(() => {
111
+ const o = ce.get(e);
112
+ return te(o) ? o : k(t.defaultValue) ? t.defaultValue() : t.defaultValue;
113
+ }), s = E(
114
+ (o, a = {}) => {
115
+ const { defaultValue: c, ...f } = { ...t, ...a }, i = k(o) ? o(n) : o;
116
+ r(i), i === void 0 ? ce.remove(e) : ce.set(e, i, f);
117
+ }
118
+ );
119
+ return [n, s];
120
+ }
121
+ const ue = (e) => {
122
+ if (!e)
123
+ return 0;
124
+ const t = Ze(e).valueOf() - Date.now();
125
+ return t < 0 ? 0 : t;
126
+ }, it = (e) => ({
127
+ days: Math.floor(e / 864e5),
128
+ hours: Math.floor(e / 36e5) % 24,
129
+ minutes: Math.floor(e / 6e4) % 60,
130
+ seconds: Math.floor(e / 1e3) % 60,
131
+ milliseconds: Math.floor(e) % 1e3
132
+ }), En = (e = {}) => {
133
+ const { leftTime: t, targetDate: n, interval: r = 1e3, onEnd: s } = e || {}, o = x(() => F(t) && t > 0 ? Date.now() + t : void 0, [t]), a = "leftTime" in e ? o : n, [c, f] = b(() => ue(a)), i = L(s);
134
+ C(() => {
135
+ if (!a) {
136
+ f(0);
137
+ return;
138
+ }
139
+ f(ue(a));
140
+ const u = setInterval(() => {
141
+ const m = ue(a);
142
+ f(m), m === 0 && (clearInterval(u), i.current?.());
143
+ }, r);
144
+ return () => clearInterval(u);
145
+ }, [a, r]);
146
+ const l = x(() => it(c), [c]);
147
+ return [c, l];
148
+ };
149
+ function Se(e, t = {}) {
150
+ const { min: n, max: r } = t;
151
+ let s = e;
152
+ return F(r) && (s = Math.min(r, s)), F(n) && (s = Math.max(n, s)), s;
153
+ }
154
+ function Sn(e = 0, t = {}) {
155
+ const { min: n, max: r } = t, [s, o] = b(() => Se(e, {
156
+ min: n,
157
+ max: r
158
+ })), a = (u) => {
159
+ o((m) => {
160
+ const h = F(u) ? u : u(m);
161
+ return Se(h, {
162
+ max: r,
163
+ min: n
164
+ });
165
+ });
166
+ }, c = (u = 1) => {
167
+ a((m) => m + u);
168
+ }, f = (u = 1) => {
169
+ a((m) => m - u);
170
+ }, i = (u) => {
171
+ a(u);
172
+ }, l = () => {
173
+ a(e);
174
+ };
175
+ return [
176
+ s,
177
+ {
178
+ inc: E(c),
179
+ dec: E(f),
180
+ set: E(i),
181
+ reset: E(l)
182
+ }
183
+ ];
184
+ }
185
+ function Ne(e, t) {
186
+ re && (k(e) || console.error(
187
+ `useDebounceFn expected parameter is a function, got ${typeof e}`
188
+ ));
189
+ const n = L(e), r = t?.wait ?? 1e3, s = x(
190
+ () => De(
191
+ (...o) => n.current(...o),
192
+ r,
193
+ t
194
+ ),
195
+ []
196
+ );
197
+ return $(() => {
198
+ s.cancel();
199
+ }), {
200
+ run: s,
201
+ cancel: s.cancel,
202
+ flush: s.flush
203
+ };
204
+ }
205
+ function wn(e, t) {
206
+ const [n, r] = b(e), { run: s } = Ne(() => {
207
+ r(e);
208
+ }, t);
209
+ return C(() => {
210
+ s();
211
+ }, [e]), n;
212
+ }
213
+ function bn(e, t, n) {
214
+ const [r, s] = b({}), { run: o } = Ne(() => {
215
+ s({});
216
+ }, n);
217
+ C(() => o(), t), K(e, [r]);
218
+ }
219
+ const Oe = (e = [], t = []) => qe(e, t), xe = (e) => (t, n) => {
220
+ const r = y(void 0), s = y(0);
221
+ (n === void 0 || !Oe(n, r.current)) && (s.current += 1), r.current = n, e(t, [s.current]);
222
+ }, Rn = xe(C), Tn = xe(he);
223
+ function X(e, t, n = {}) {
224
+ const { enable: r = !0 } = n, s = L(t);
225
+ V(
226
+ () => {
227
+ if (!r)
228
+ return;
229
+ const o = D(n.target, window);
230
+ if (!o?.addEventListener)
231
+ return;
232
+ const a = (f) => s.current(f), c = Array.isArray(e) ? e : [e];
233
+ return c.forEach((f) => {
234
+ o.addEventListener(f, a, {
235
+ capture: n.capture,
236
+ once: n.once,
237
+ passive: n.passive
238
+ });
239
+ }), () => {
240
+ c.forEach((f) => {
241
+ o.removeEventListener(f, a, {
242
+ capture: n.capture
243
+ });
244
+ });
245
+ };
246
+ },
247
+ [e, n.capture, n.once, n.passive, r],
248
+ n.target
249
+ );
250
+ }
251
+ const we = () => q ? document.visibilityState : "visible";
252
+ function Ln() {
253
+ const [e, t] = b(we);
254
+ return X(
255
+ "visibilitychange",
256
+ () => {
257
+ t(we());
258
+ },
259
+ {
260
+ target: () => document
261
+ }
262
+ ), e;
263
+ }
264
+ const Fe = (e) => {
265
+ re && (k(e) || console.error(
266
+ `useMount: parameter \`fn\` expected to be a function, but got "${typeof e}".`
267
+ )), C(() => e?.(), []);
268
+ }, An = (e, t, n = {}) => {
269
+ const r = L(n), s = L(e), o = y(void 0), { dragImage: a } = r.current;
270
+ Fe(() => {
271
+ if (a?.image) {
272
+ const { image: c } = a;
273
+ if (te(c)) {
274
+ const f = new Image();
275
+ f.src = c, o.current = f;
276
+ } else
277
+ o.current = c;
278
+ }
279
+ }), V(
280
+ () => {
281
+ const c = D(t);
282
+ if (!c?.addEventListener)
283
+ return;
284
+ const f = (l) => {
285
+ if (r.current.onDragStart?.(l), l.dataTransfer.setData("custom", JSON.stringify(s.current)), a?.image && o.current) {
286
+ const { offsetX: u = 0, offsetY: m = 0 } = a;
287
+ l.dataTransfer.setDragImage(
288
+ o.current,
289
+ u,
290
+ m
291
+ );
292
+ }
293
+ }, i = (l) => {
294
+ r.current.onDragEnd?.(l);
295
+ };
296
+ return c.setAttribute("draggable", "true"), c.addEventListener("dragstart", f), c.addEventListener("dragend", i), () => {
297
+ c.removeEventListener("dragstart", f), c.removeEventListener("dragend", i);
298
+ };
299
+ },
300
+ [],
301
+ t
302
+ );
303
+ }, Pn = (e, t = {}) => {
304
+ const n = L(t), r = y(void 0);
305
+ V(
306
+ () => {
307
+ const s = D(e);
308
+ if (!s?.addEventListener)
309
+ return;
310
+ const o = (u, m) => {
311
+ const h = u.getData("text/uri-list"), p = u.getData("custom");
312
+ if (p && n.current.onDom) {
313
+ let d = p;
314
+ try {
315
+ d = JSON.parse(p);
316
+ } catch {
317
+ d = p;
318
+ }
319
+ n.current.onDom(d, m);
320
+ return;
321
+ }
322
+ if (h && n.current.onUri) {
323
+ n.current.onUri(h, m);
324
+ return;
325
+ }
326
+ if (u.files && u.files.length && n.current.onFiles) {
327
+ n.current.onFiles(
328
+ Array.from(u.files),
329
+ m
330
+ );
331
+ return;
332
+ }
333
+ u.items && u.items.length && n.current.onText && u.items[0].getAsString((d) => {
334
+ n.current.onText(d, m);
335
+ });
336
+ }, a = (u) => {
337
+ u.preventDefault(), u.stopPropagation(), r.current = u.target, n.current.onDragEnter?.(u);
338
+ }, c = (u) => {
339
+ u.preventDefault(), n.current.onDragOver?.(u);
340
+ }, f = (u) => {
341
+ u.target === r.current && n.current.onDragLeave?.(u);
342
+ }, i = (u) => {
343
+ u.preventDefault(), o(u.dataTransfer, u), n.current.onDrop?.(u);
344
+ }, l = (u) => {
345
+ o(u.clipboardData, u), n.current.onPaste?.(u);
346
+ };
347
+ return s.addEventListener("dragenter", a), s.addEventListener("dragover", c), s.addEventListener("dragleave", f), s.addEventListener("drop", i), s.addEventListener("paste", l), () => {
348
+ s.removeEventListener("dragenter", a), s.removeEventListener("dragover", c), s.removeEventListener("dragleave", f), s.removeEventListener("drop", i), s.removeEventListener("paste", l);
349
+ };
350
+ },
351
+ [],
352
+ e
353
+ );
354
+ };
355
+ function Cn(e) {
356
+ const { initialValue: t, transformer: n } = e || {}, [r, s] = b(t), o = L(n), a = B(() => s(t), []), c = B((f) => {
357
+ const i = f.target.value;
358
+ return k(o.current) ? s(o.current(i)) : s(i);
359
+ }, []);
360
+ return [
361
+ r,
362
+ {
363
+ onChange: c,
364
+ reset: a
365
+ }
366
+ ];
367
+ }
368
+ const J = {}, lt = (e, t = {}) => {
369
+ const n = document.querySelector(`script[src="${e}"]`);
370
+ if (!n) {
371
+ const r = document.createElement("script");
372
+ return r.src = e, Object.keys(t).forEach((s) => {
373
+ r[s] = t[s];
374
+ }), r.setAttribute("data-status", "loading"), document.body.appendChild(r), {
375
+ ref: r,
376
+ status: "loading"
377
+ };
378
+ }
379
+ return {
380
+ ref: n,
381
+ status: n.getAttribute("data-status") || "ready"
382
+ };
383
+ }, ft = (e, t = {}) => {
384
+ const n = document.querySelector(`link[href="${e}"]`);
385
+ if (!n) {
386
+ const r = document.createElement("link");
387
+ return r.rel = "stylesheet", r.href = e, Object.keys(t).forEach((o) => {
388
+ r[o] = t[o];
389
+ }), "hideFocus" in r && r.relList && (r.rel = "preload", r.as = "style"), r.setAttribute("data-status", "loading"), document.head.appendChild(r), {
390
+ ref: r,
391
+ status: "loading"
392
+ };
393
+ }
394
+ return {
395
+ ref: n,
396
+ status: n.getAttribute("data-status") || "ready"
397
+ };
398
+ }, Dn = (e, t) => {
399
+ const [n, r] = b(e ? "loading" : "unset"), s = y(void 0);
400
+ return C(() => {
401
+ if (!e) {
402
+ r("unset");
403
+ return;
404
+ }
405
+ const o = e.replace(/[|#].*$/, "");
406
+ if (t?.type === "css" || !t?.type && /(^css!|\.css$)/.test(o)) {
407
+ const c = ft(e, t?.css);
408
+ s.current = c.ref, r(c.status);
409
+ } else if (t?.type === "js" || !t?.type && /(^js!|\.js$)/.test(o)) {
410
+ const c = lt(e, t?.js);
411
+ s.current = c.ref, r(c.status);
412
+ } else
413
+ console.error(
414
+ "Cannot infer the type of external resource, and please provide a type ('js' | 'css'). "
415
+ );
416
+ if (!s.current)
417
+ return;
418
+ J[e] === void 0 ? J[e] = 1 : J[e] += 1;
419
+ const a = (c) => {
420
+ const f = c.type === "load" ? "ready" : "error";
421
+ s.current?.setAttribute("data-status", f), r(f);
422
+ };
423
+ return s.current.addEventListener("load", a), s.current.addEventListener("error", a), () => {
424
+ s.current?.removeEventListener("load", a), s.current?.removeEventListener("error", a), J[e] -= 1, J[e] === 0 && !t?.keepWhenUnused && s.current?.remove(), s.current = void 0;
425
+ };
426
+ }, [e]), n;
427
+ }, dt = {
428
+ SVG: "image/svg+xml",
429
+ ICO: "image/x-icon",
430
+ GIF: "image/gif",
431
+ PNG: "image/png"
432
+ }, Mn = (e) => {
433
+ C(() => {
434
+ if (!e)
435
+ return;
436
+ const t = e.split("."), n = t[t.length - 1].toLocaleUpperCase(), r = document.querySelector("link[rel*='icon']") || document.createElement("link");
437
+ r.type = dt[n], r.href = e, r.rel = "shortcut icon", document.getElementsByTagName("head")[0].appendChild(r);
438
+ }, [e]);
439
+ };
440
+ function Nn(e, t) {
441
+ const [n, r] = b(!1), { onFocus: s, onBlur: o, onChange: a } = t || {};
442
+ return X(
443
+ "focusin",
444
+ (c) => {
445
+ n || (s?.(c), a?.(!0), r(!0));
446
+ },
447
+ {
448
+ target: e
449
+ }
450
+ ), X(
451
+ "focusout",
452
+ (c) => {
453
+ n && !c.currentTarget?.contains?.(c.relatedTarget) && (o?.(c), a?.(!1), r(!1));
454
+ },
455
+ {
456
+ target: e
457
+ }
458
+ ), n;
459
+ }
460
+ const On = (e, t) => {
461
+ const { onExit: n, onEnter: r, pageFullscreen: s = !1 } = t || {}, { className: o = "@unicom-cloud-ui-hooks-page-fullscreen", zIndex: a = 999999 } = Ve(s) || !s ? {} : s, c = L(n), f = L(r), [i, l] = b(m), u = y(m());
462
+ function m() {
463
+ return z.isEnabled && !!z.element && z.element === D(e);
464
+ }
465
+ const h = (v) => {
466
+ v ? f.current?.() : c.current?.();
467
+ }, p = (v) => {
468
+ u.current !== v && (h(v), l(v), u.current = v);
469
+ }, d = () => {
470
+ const v = m();
471
+ p(v);
472
+ }, T = (v) => {
473
+ const S = D(e);
474
+ if (!S)
475
+ return;
476
+ let R = document.getElementById(o);
477
+ v ? (S.classList.add(o), R || (R = document.createElement("style"), R.setAttribute("id", o), R.textContent = `
478
+ .${o} {
479
+ position: fixed; left: 0; top: 0; right: 0; bottom: 0;
480
+ width: 100% !important; height: 100% !important;
481
+ z-index: ${a};
482
+ }`, S.appendChild(R))) : (S.classList.remove(o), R && R.remove()), p(v);
483
+ }, A = () => {
484
+ const v = D(e);
485
+ if (v) {
486
+ if (s) {
487
+ T(!0);
488
+ return;
489
+ }
490
+ if (z.isEnabled)
491
+ try {
492
+ z.request(v);
493
+ } catch (S) {
494
+ console.error(S);
495
+ }
496
+ }
497
+ }, O = () => {
498
+ const v = D(e);
499
+ if (v) {
500
+ if (s) {
501
+ T(!1);
502
+ return;
503
+ }
504
+ z.isEnabled && z.element === v && z.exit();
505
+ }
506
+ }, g = () => {
507
+ i ? O() : A();
508
+ };
509
+ return C(() => {
510
+ if (!(!z.isEnabled || s))
511
+ return z.on("change", d), () => {
512
+ z.off("change", d);
513
+ };
514
+ }, []), [
515
+ i,
516
+ {
517
+ enterFullscreen: E(A),
518
+ exitFullscreen: E(O),
519
+ toggleFullscreen: E(g),
520
+ isEnabled: z.isEnabled
521
+ }
522
+ ];
523
+ };
524
+ function xn(e) {
525
+ const [t, n] = b(e), r = L(t), s = B(() => r.current, []);
526
+ return [t, n, s];
527
+ }
528
+ const mt = (e, t) => {
529
+ let n = e > 0 ? e - 1 : t.length + e;
530
+ return n >= t.length - 1 && (n = t.length - 1), n < 0 && (n = 0), n;
531
+ }, be = (e, t) => {
532
+ const n = mt(e, t);
533
+ return {
534
+ _current: t[n],
535
+ _before: t.slice(0, n),
536
+ _after: t.slice(n + 1)
537
+ };
538
+ };
539
+ function Fn(e, t = 0) {
540
+ const [n, r] = b({
541
+ present: e,
542
+ past: [],
543
+ future: []
544
+ }), { present: s, past: o, future: a } = n, c = y(e), f = (...h) => {
545
+ const p = h.length > 0 ? h[0] : c.current;
546
+ c.current = p, r({
547
+ present: p,
548
+ future: [],
549
+ past: []
550
+ });
551
+ }, i = (h) => {
552
+ const p = [...o, s], d = F(t) ? t : Number(t);
553
+ d > 0 && p.length > d && p.splice(0, 1), r({
554
+ present: h,
555
+ future: [],
556
+ past: p
557
+ });
558
+ }, l = (h = 1) => {
559
+ if (a.length === 0)
560
+ return;
561
+ const { _before: p, _current: d, _after: T } = be(h, a);
562
+ r({
563
+ past: [...o, s, ...p],
564
+ present: d,
565
+ future: T
566
+ });
567
+ }, u = (h = -1) => {
568
+ if (o.length === 0)
569
+ return;
570
+ const { _before: p, _current: d, _after: T } = be(h, o);
571
+ r({
572
+ past: p,
573
+ present: d,
574
+ future: [...T, s, ...a]
575
+ });
576
+ }, m = (h) => {
577
+ const p = F(h) ? h : Number(h);
578
+ if (p !== 0) {
579
+ if (p > 0)
580
+ return l(p);
581
+ u(p);
582
+ }
583
+ };
584
+ return {
585
+ value: s,
586
+ backLength: o.length,
587
+ forwardLength: a.length,
588
+ setValue: E(i),
589
+ go: E(m),
590
+ back: E(() => {
591
+ m(-1);
592
+ }),
593
+ forward: E(() => {
594
+ m(1);
595
+ }),
596
+ reset: E(f)
597
+ };
598
+ }
599
+ const kn = (e, t) => {
600
+ const { onEnter: n, onLeave: r, onChange: s } = t || {}, [o, { setTrue: a, setFalse: c }] = ot(!1);
601
+ return X(
602
+ "mouseenter",
603
+ () => {
604
+ n?.(), a(), s?.(!0);
605
+ },
606
+ {
607
+ target: e
608
+ }
609
+ ), X(
610
+ "mouseleave",
611
+ () => {
612
+ r?.(), c(), s?.(!1);
613
+ },
614
+ {
615
+ target: e
616
+ }
617
+ ), o;
618
+ };
619
+ function Hn(e, t) {
620
+ const { callback: n, ...r } = t || {}, [s, o] = b(), [a, c] = b();
621
+ return V(
622
+ () => {
623
+ const i = (Array.isArray(e) ? e : [e]).map((u) => D(u)).filter(Boolean);
624
+ if (!i.length)
625
+ return;
626
+ const l = new IntersectionObserver(
627
+ (u) => {
628
+ for (const m of u)
629
+ c(m.intersectionRatio), o(m.isIntersecting), n?.(m);
630
+ },
631
+ {
632
+ ...r,
633
+ root: D(t?.root)
634
+ }
635
+ );
636
+ return i.forEach((u) => l.observe(u)), () => {
637
+ l.disconnect();
638
+ };
639
+ },
640
+ [t?.rootMargin, t?.threshold, n],
641
+ e
642
+ ), [s, a];
643
+ }
644
+ const G = /* @__PURE__ */ new Map(), gt = (e, t, n) => {
645
+ const r = G.get(e);
646
+ r?.timer && clearTimeout(r.timer);
647
+ let s;
648
+ t > -1 && (s = setTimeout(() => {
649
+ G.delete(e);
650
+ }, t)), G.set(e, {
651
+ ...n,
652
+ timer: s
653
+ });
654
+ }, ht = (e) => G.get(e), _n = (e) => {
655
+ e ? (Array.isArray(e) ? e : [e]).forEach((n) => G.delete(n)) : G.clear();
656
+ }, Z = /* @__PURE__ */ new Map(), pt = (e) => Z.get(e), vt = (e, t) => {
657
+ Z.set(e, t), t.then((n) => (Z.delete(e), n)).catch(() => {
658
+ Z.delete(e);
659
+ });
660
+ }, W = {}, yt = (e, t) => {
661
+ W[e] && W[e].forEach((n) => n(t));
662
+ }, ie = (e, t) => (W[e] || (W[e] = []), W[e].push(t), function() {
663
+ const r = W[e].indexOf(t);
664
+ W[e].splice(r, 1);
665
+ }), Et = (e, {
666
+ cacheKey: t,
667
+ cacheTime: n = 300 * 1e3,
668
+ staleTime: r = 0,
669
+ setCache: s,
670
+ getCache: o
671
+ }) => {
672
+ const a = y(void 0), c = y(void 0), f = (l, u) => {
673
+ s ? s(u) : gt(l, n, u), yt(l, u.data);
674
+ }, i = (l, u = []) => o ? o(u) : ht(l);
675
+ return se(() => {
676
+ if (!t)
677
+ return;
678
+ const l = i(t);
679
+ l && Object.hasOwnProperty.call(l, "data") && (e.state.data = l.data, e.state.params = l.params, (r === -1 || Date.now() - l.time <= r) && (e.state.loading = !1)), a.current = ie(t, (u) => {
680
+ e.setState({ data: u });
681
+ });
682
+ }, []), $(() => {
683
+ a.current?.();
684
+ }), t ? {
685
+ onBefore: (l) => {
686
+ const u = i(t, l);
687
+ return !u || !Object.hasOwnProperty.call(u, "data") ? {} : r === -1 || Date.now() - u.time <= r ? {
688
+ loading: !1,
689
+ data: u?.data,
690
+ error: void 0,
691
+ returnNow: !0
692
+ } : {
693
+ data: u?.data,
694
+ error: void 0
695
+ };
696
+ },
697
+ onRequest: (l, u) => {
698
+ let m = pt(t);
699
+ return m && m !== c.current ? { servicePromise: m } : (m = l(...u), c.current = m, vt(t, m), { servicePromise: m });
700
+ },
701
+ onSuccess: (l, u) => {
702
+ t && (a.current?.(), f(t, {
703
+ data: l,
704
+ params: u,
705
+ time: Date.now()
706
+ }), a.current = ie(t, (m) => {
707
+ e.setState({ data: m });
708
+ }));
709
+ },
710
+ onMutate: (l) => {
711
+ t && (a.current?.(), f(t, {
712
+ data: l,
713
+ params: e.state.params,
714
+ time: Date.now()
715
+ }), a.current = ie(t, (u) => {
716
+ e.setState({ data: u });
717
+ }));
718
+ }
719
+ } : {};
720
+ }, St = (e, { debounceWait: t, debounceLeading: n, debounceTrailing: r, debounceMaxWait: s }) => {
721
+ const o = y(void 0), a = x(() => {
722
+ const c = {};
723
+ return n !== void 0 && (c.leading = n), r !== void 0 && (c.trailing = r), s !== void 0 && (c.maxWait = s), c;
724
+ }, [n, r, s]);
725
+ return C(() => {
726
+ if (t) {
727
+ const c = e.runAsync.bind(e);
728
+ return o.current = De(
729
+ (f) => {
730
+ f();
731
+ },
732
+ t,
733
+ a
734
+ ), e.runAsync = (...f) => new Promise((i, l) => {
735
+ o.current?.(() => {
736
+ c(...f).then(i).catch(l);
737
+ });
738
+ }), () => {
739
+ o.current?.cancel(), e.runAsync = c;
740
+ };
741
+ }
742
+ }, [t, a]), t ? {
743
+ onCancel: () => {
744
+ o.current?.cancel();
745
+ }
746
+ } : {};
747
+ }, wt = (e, { loadingDelay: t, ready: n }) => {
748
+ const r = y(void 0);
749
+ if (!t)
750
+ return {};
751
+ const s = () => {
752
+ r.current && clearTimeout(r.current);
753
+ };
754
+ return {
755
+ onBefore: () => (s(), n !== !1 && (r.current = setTimeout(() => {
756
+ e.setState({
757
+ loading: !0
758
+ });
759
+ }, t)), {
760
+ loading: !1
761
+ }),
762
+ onFinally: () => {
763
+ s();
764
+ },
765
+ onCancel: () => {
766
+ s();
767
+ }
768
+ };
769
+ }, bt = (e, { pollingInterval: t, pollingWhenHidden: n = !0, pollingErrorRetryCount: r = -1 }) => {
770
+ const s = y(void 0), o = y(void 0), a = y(0), c = () => {
771
+ s.current && clearTimeout(s.current), o.current?.();
772
+ };
773
+ return K(() => {
774
+ t || c();
775
+ }, [t]), t ? {
776
+ onBefore: () => {
777
+ c();
778
+ },
779
+ onError: () => {
780
+ a.current += 1;
781
+ },
782
+ onSuccess: () => {
783
+ a.current = 0;
784
+ },
785
+ onFinally: () => {
786
+ r === -1 || // When an error occurs, the request is not repeated after pollingErrorRetryCount retries
787
+ r !== -1 && a.current <= r ? s.current = setTimeout(() => {
788
+ !n && !We() ? o.current = Ge(() => {
789
+ e.refresh();
790
+ }) : e.refresh();
791
+ }, t) : a.current = 0;
792
+ },
793
+ onCancel: () => {
794
+ c();
795
+ }
796
+ } : {};
797
+ };
798
+ function Rt(e, t) {
799
+ let n = !1;
800
+ return (...r) => {
801
+ n || (n = !0, e(...r), setTimeout(() => {
802
+ n = !1;
803
+ }, t));
804
+ };
805
+ }
806
+ const Tt = (e, { refreshOnWindowFocus: t, focusTimespan: n = 5e3 }) => {
807
+ const r = y(void 0), s = () => {
808
+ r.current?.();
809
+ };
810
+ return C(() => {
811
+ if (t) {
812
+ const o = Rt(
813
+ e.refresh.bind(e),
814
+ n
815
+ );
816
+ r.current = Ke(() => {
817
+ o();
818
+ });
819
+ }
820
+ return () => {
821
+ s();
822
+ };
823
+ }, [t, n]), $(() => {
824
+ s();
825
+ }), {};
826
+ }, Lt = (e, { retryInterval: t, retryCount: n }) => {
827
+ const r = y(void 0), s = y(0), o = y(!1);
828
+ return n ? {
829
+ onBefore: () => {
830
+ o.current || (s.current = 0), o.current = !1, r.current && clearTimeout(r.current);
831
+ },
832
+ onSuccess: () => {
833
+ s.current = 0;
834
+ },
835
+ onError: () => {
836
+ if (s.current += 1, n === -1 || s.current <= n) {
837
+ const a = t ?? Math.min(1e3 * 2 ** s.current, 3e4);
838
+ r.current = setTimeout(() => {
839
+ o.current = !0, e.refresh();
840
+ }, a);
841
+ } else
842
+ s.current = 0;
843
+ },
844
+ onCancel: () => {
845
+ s.current = 0, r.current && clearTimeout(r.current);
846
+ }
847
+ } : {};
848
+ }, At = (e, { throttleWait: t, throttleLeading: n, throttleTrailing: r }) => {
849
+ const s = y(void 0), o = {};
850
+ return n !== void 0 && (o.leading = n), r !== void 0 && (o.trailing = r), C(() => {
851
+ if (t) {
852
+ const a = e.runAsync.bind(e);
853
+ return s.current = Me(
854
+ (c) => {
855
+ c();
856
+ },
857
+ t,
858
+ o
859
+ ), e.runAsync = (...c) => new Promise((f, i) => {
860
+ s.current?.(() => {
861
+ a(...c).then(f).catch(i);
862
+ });
863
+ }), () => {
864
+ e.runAsync = a, s.current?.cancel();
865
+ };
866
+ }
867
+ }, [t, n, r]), t ? {
868
+ onCancel: () => {
869
+ s.current?.cancel();
870
+ }
871
+ } : {};
872
+ };
873
+ class Pt {
874
+ constructor(t, n, r, s = {}) {
875
+ this.serviceRef = t, this.options = n, this.subscribe = r, this.initState = s, this.count = 0, this.state = {
876
+ loading: !1,
877
+ params: void 0,
878
+ data: void 0,
879
+ error: void 0
880
+ }, this.state = {
881
+ ...this.state,
882
+ loading: !n.manual,
883
+ ...s
884
+ };
885
+ }
886
+ setState(t = {}) {
887
+ this.state = {
888
+ ...this.state,
889
+ ...t
890
+ }, this.subscribe();
891
+ }
892
+ runPluginHandler(t, ...n) {
893
+ const r = this.pluginImpls.map((s) => s[t]?.(...n)).filter(Boolean);
894
+ return Object.assign({}, ...r);
895
+ }
896
+ async runAsync(...t) {
897
+ this.count += 1;
898
+ const n = this.count, {
899
+ stopNow: r = !1,
900
+ returnNow: s = !1,
901
+ ...o
902
+ } = this.runPluginHandler("onBefore", t);
903
+ if (r)
904
+ return new Promise(() => {
905
+ });
906
+ if (this.setState({
907
+ loading: !0,
908
+ params: t,
909
+ ...o
910
+ }), s)
911
+ return Promise.resolve(o.data);
912
+ this.options.onBefore?.(t);
913
+ try {
914
+ let { servicePromise: a } = this.runPluginHandler(
915
+ "onRequest",
916
+ this.serviceRef.current,
917
+ t
918
+ );
919
+ a || (a = this.serviceRef.current(...t));
920
+ const c = await a;
921
+ return n !== this.count ? new Promise(() => {
922
+ }) : (this.setState({
923
+ data: c,
924
+ error: void 0,
925
+ loading: !1
926
+ }), this.options.onSuccess?.(c, t), this.runPluginHandler("onSuccess", c, t), this.options.onFinally?.(t, c, void 0), n === this.count && this.runPluginHandler("onFinally", t, c, void 0), c);
927
+ } catch (a) {
928
+ if (n !== this.count)
929
+ return new Promise(() => {
930
+ });
931
+ throw this.setState({
932
+ error: a,
933
+ loading: !1
934
+ }), this.options.onError?.(a, t), this.runPluginHandler("onError", a, t), this.options.onFinally?.(t, void 0, a), n === this.count && this.runPluginHandler("onFinally", t, void 0, a), a;
935
+ }
936
+ }
937
+ run(...t) {
938
+ this.runAsync(...t).catch((n) => {
939
+ this.options.onError || console.error(n);
940
+ });
941
+ }
942
+ cancel() {
943
+ this.count += 1, this.setState({
944
+ loading: !1
945
+ }), this.runPluginHandler("onCancel");
946
+ }
947
+ refresh() {
948
+ this.run(...this.state.params || []);
949
+ }
950
+ refreshAsync() {
951
+ return this.runAsync(...this.state.params || []);
952
+ }
953
+ mutate(t) {
954
+ const n = k(t) ? t(this.state.data) : t;
955
+ this.runPluginHandler("onMutate", n), this.setState({
956
+ data: n
957
+ });
958
+ }
959
+ }
960
+ function Ct(e, t = {}, n = []) {
961
+ const { manual: r = !1, ready: s = !0, ...o } = t;
962
+ re && t.defaultParams && !Array.isArray(t.defaultParams) && console.warn(
963
+ `expected defaultParams is array, got ${typeof t.defaultParams}`
964
+ );
965
+ const a = {
966
+ manual: r,
967
+ ready: s,
968
+ ...o
969
+ }, c = L(e), f = ne(), i = se(() => {
970
+ const l = n.map((u) => u?.onInit?.(a)).filter(Boolean);
971
+ return new Pt(
972
+ c,
973
+ a,
974
+ f,
975
+ Object.assign({}, ...l)
976
+ );
977
+ }, []);
978
+ return i.options = a, i.pluginImpls = n.map(
979
+ (l) => l(i, a)
980
+ ), Fe(() => {
981
+ if (!r && s) {
982
+ const l = i.state.params || t.defaultParams || [];
983
+ i.run(...l);
984
+ }
985
+ }), $(() => {
986
+ i.cancel();
987
+ }), {
988
+ loading: i.state.loading,
989
+ data: i.state.data,
990
+ error: i.state.error,
991
+ params: i.state.params || [],
992
+ cancel: E(i.cancel.bind(i)),
993
+ refresh: E(i.refresh.bind(i)),
994
+ refreshAsync: E(i.refreshAsync.bind(i)),
995
+ run: E(i.run.bind(i)),
996
+ runAsync: E(i.runAsync.bind(i)),
997
+ mutate: E(i.mutate.bind(i))
998
+ };
999
+ }
1000
+ function ke(e, t, n) {
1001
+ return Ct(e, t, [
1002
+ ...n || [],
1003
+ St,
1004
+ wt,
1005
+ bt,
1006
+ Tt,
1007
+ At,
1008
+ Je,
1009
+ Et,
1010
+ Lt
1011
+ ]);
1012
+ }
1013
+ const Dt = (e) => e === document || e === document.documentElement || e === document.body ? Math.max(
1014
+ window.pageYOffset,
1015
+ document.documentElement.scrollTop,
1016
+ document.body.scrollTop
1017
+ ) : e.scrollTop, Re = (e) => e.scrollHeight || Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), Mt = (e) => e.clientHeight || Math.max(document.documentElement.clientHeight, document.body.clientHeight), In = (e, t = {}) => {
1018
+ const {
1019
+ target: n,
1020
+ isNoMore: r,
1021
+ threshold: s = 100,
1022
+ direction: o = "bottom",
1023
+ reloadDeps: a = [],
1024
+ manual: c,
1025
+ onBefore: f,
1026
+ onSuccess: i,
1027
+ onError: l,
1028
+ onFinally: u
1029
+ } = t, [m, h] = b(), [p, d] = b(!1), T = o === "top", A = y(void 0), O = y(0), g = x(() => r ? r(m) : !1, [m]), { loading: v, error: S, run: R, runAsync: N, cancel: I } = ke(
1030
+ async (M) => ({ currentData: await e(M), lastData: M }),
1031
+ {
1032
+ manual: c,
1033
+ onFinally: (M, _, j) => {
1034
+ d(!1), u?.(_?.currentData, j);
1035
+ },
1036
+ onBefore: () => f?.(),
1037
+ onSuccess: (M) => {
1038
+ M.lastData ? h({
1039
+ ...M.currentData,
1040
+ list: T ? [...M.currentData.list, ...M.lastData.list ?? []] : [...M.lastData.list ?? [], ...M.currentData.list]
1041
+ }) : h({
1042
+ ...M.currentData,
1043
+ list: [...M.currentData.list ?? []]
1044
+ }), setTimeout(() => {
1045
+ if (T) {
1046
+ let _ = D(n);
1047
+ if (_ = _ === document ? document.documentElement : _, _) {
1048
+ const j = Re(_);
1049
+ _.scrollTo(0, j - O.current);
1050
+ }
1051
+ } else
1052
+ ye();
1053
+ }), i?.(M.currentData);
1054
+ },
1055
+ onError: (M) => l?.(M)
1056
+ }
1057
+ ), w = E(() => {
1058
+ g || (d(!0), R(m));
1059
+ }), Y = async (M) => (await N(M)).currentData, P = E(() => g ? Promise.reject() : (d(!0), Y(m))), H = () => (d(!1), R()), oe = () => (d(!1), Y()), ye = () => {
1060
+ const M = D(n);
1061
+ if (!M)
1062
+ return;
1063
+ const _ = M === document ? document.documentElement : M, j = Dt(_), Ee = Re(_), Be = Mt(_);
1064
+ T ? (A.current !== void 0 && A.current > j && j <= s && w(), A.current = j, O.current = Ee - j) : Ee - j <= Be + s && w();
1065
+ };
1066
+ return X(
1067
+ "scroll",
1068
+ () => {
1069
+ v || p || ye();
1070
+ },
1071
+ { target: n }
1072
+ ), K(() => {
1073
+ R();
1074
+ }, [...a]), {
1075
+ data: m,
1076
+ loading: !p && v,
1077
+ error: S,
1078
+ loadingMore: p,
1079
+ noMore: g,
1080
+ loadMore: w,
1081
+ loadMoreAsync: P,
1082
+ reload: E(H),
1083
+ reloadAsync: E(oe),
1084
+ mutate: h,
1085
+ cancel: I
1086
+ };
1087
+ }, He = (e, t, n) => {
1088
+ const r = y(void 0), s = y(0);
1089
+ Oe(t, r.current) || (s.current += 1), r.current = t, V(e, [s.current], n);
1090
+ }, _e = {
1091
+ 0: 48,
1092
+ 1: 49,
1093
+ 2: 50,
1094
+ 3: 51,
1095
+ 4: 52,
1096
+ 5: 53,
1097
+ 6: 54,
1098
+ 7: 55,
1099
+ 8: 56,
1100
+ 9: 57,
1101
+ backspace: 8,
1102
+ tab: 9,
1103
+ enter: 13,
1104
+ shift: 16,
1105
+ ctrl: 17,
1106
+ alt: 18,
1107
+ pausebreak: 19,
1108
+ capslock: 20,
1109
+ esc: 27,
1110
+ space: 32,
1111
+ pageup: 33,
1112
+ pagedown: 34,
1113
+ end: 35,
1114
+ home: 36,
1115
+ leftarrow: 37,
1116
+ uparrow: 38,
1117
+ rightarrow: 39,
1118
+ downarrow: 40,
1119
+ insert: 45,
1120
+ delete: 46,
1121
+ a: 65,
1122
+ b: 66,
1123
+ c: 67,
1124
+ d: 68,
1125
+ e: 69,
1126
+ f: 70,
1127
+ g: 71,
1128
+ h: 72,
1129
+ i: 73,
1130
+ j: 74,
1131
+ k: 75,
1132
+ l: 76,
1133
+ m: 77,
1134
+ n: 78,
1135
+ o: 79,
1136
+ p: 80,
1137
+ q: 81,
1138
+ r: 82,
1139
+ s: 83,
1140
+ t: 84,
1141
+ u: 85,
1142
+ v: 86,
1143
+ w: 87,
1144
+ x: 88,
1145
+ y: 89,
1146
+ z: 90,
1147
+ leftwindowkey: 91,
1148
+ rightwindowkey: 92,
1149
+ meta: tt ? [91, 93] : [91, 92],
1150
+ selectkey: 93,
1151
+ numpad0: 96,
1152
+ numpad1: 97,
1153
+ numpad2: 98,
1154
+ numpad3: 99,
1155
+ numpad4: 100,
1156
+ numpad5: 101,
1157
+ numpad6: 102,
1158
+ numpad7: 103,
1159
+ numpad8: 104,
1160
+ numpad9: 105,
1161
+ multiply: 106,
1162
+ add: 107,
1163
+ subtract: 109,
1164
+ decimalpoint: 110,
1165
+ divide: 111,
1166
+ f1: 112,
1167
+ f2: 113,
1168
+ f3: 114,
1169
+ f4: 115,
1170
+ f5: 116,
1171
+ f6: 117,
1172
+ f7: 118,
1173
+ f8: 119,
1174
+ f9: 120,
1175
+ f10: 121,
1176
+ f11: 122,
1177
+ f12: 123,
1178
+ numlock: 144,
1179
+ scrolllock: 145,
1180
+ semicolon: 186,
1181
+ equalsign: 187,
1182
+ comma: 188,
1183
+ dash: 189,
1184
+ period: 190,
1185
+ forwardslash: 191,
1186
+ graveaccent: 192,
1187
+ openbracket: 219,
1188
+ backslash: 220,
1189
+ closebracket: 221,
1190
+ singlequote: 222
1191
+ }, me = {
1192
+ ctrl: (e) => e.ctrlKey,
1193
+ shift: (e) => e.shiftKey,
1194
+ alt: (e) => e.altKey,
1195
+ meta: (e) => e.type === "keyup" ? _e.meta.includes(e.keyCode) : e.metaKey
1196
+ };
1197
+ function Ie(e) {
1198
+ return te(e) || F(e);
1199
+ }
1200
+ function Nt(e) {
1201
+ const t = Object.keys(me).reduce((n, r) => me[r](e) ? n + 1 : n, 0);
1202
+ return [16, 17, 18, 91, 92].includes(e.keyCode) ? t : t + 1;
1203
+ }
1204
+ function Te(e, t, n) {
1205
+ if (!e.key)
1206
+ return !1;
1207
+ if (F(t))
1208
+ return e.keyCode === t ? t : !1;
1209
+ const r = t.split(".");
1210
+ let s = 0;
1211
+ for (const o of r) {
1212
+ const a = me[o], c = _e[o.toLowerCase()];
1213
+ (a && a(e) || c && c === e.keyCode) && s++;
1214
+ }
1215
+ return n ? s === r.length && Nt(e) === r.length ? t : !1 : s === r.length ? t : !1;
1216
+ }
1217
+ function Ot(e, t) {
1218
+ return k(e) ? e : Ie(e) ? (n) => Te(n, e, t) : Array.isArray(e) ? (n) => e.find((r) => Te(n, r, t)) : () => !!e;
1219
+ }
1220
+ const xt = ["keydown"];
1221
+ function Yn(e, t, n) {
1222
+ const {
1223
+ events: r = xt,
1224
+ target: s,
1225
+ exactMatch: o = !1,
1226
+ useCapture: a = !1
1227
+ } = n || {}, c = L(t), f = L(e);
1228
+ He(
1229
+ () => {
1230
+ const i = D(s, window);
1231
+ if (!i)
1232
+ return;
1233
+ const l = (u) => {
1234
+ const h = Ot(f.current, o)(u), p = Ie(h) ? h : u.key;
1235
+ if (h)
1236
+ return c.current?.(u, p);
1237
+ };
1238
+ for (const u of r)
1239
+ i?.addEventListener?.(u, l, a);
1240
+ return () => {
1241
+ for (const u of r)
1242
+ i?.removeEventListener?.(u, l, a);
1243
+ };
1244
+ },
1245
+ [r],
1246
+ s
1247
+ );
1248
+ }
1249
+ const Le = "HOOKS_SYNC_STORAGE_EVENT_NAME";
1250
+ function Ye(e) {
1251
+ function t(n, r = {}) {
1252
+ let s;
1253
+ const {
1254
+ listenStorageChange: o = !1,
1255
+ onError: a = (d) => {
1256
+ console.error(d);
1257
+ }
1258
+ } = r;
1259
+ try {
1260
+ s = e();
1261
+ } catch (d) {
1262
+ a(d);
1263
+ }
1264
+ const c = (d) => r.serializer ? r.serializer(d) : JSON.stringify(d), f = (d) => r.deserializer ? r.deserializer(d) : JSON.parse(d);
1265
+ function i() {
1266
+ try {
1267
+ const d = s?.getItem(n);
1268
+ if (d)
1269
+ return f(d);
1270
+ } catch (d) {
1271
+ a(d);
1272
+ }
1273
+ return k(r.defaultValue) ? r.defaultValue() : r.defaultValue;
1274
+ }
1275
+ const [l, u] = b(i);
1276
+ K(() => {
1277
+ u(i());
1278
+ }, [n]);
1279
+ const m = (d) => {
1280
+ const T = k(d) ? d(l) : d;
1281
+ o || u(T);
1282
+ try {
1283
+ let A;
1284
+ const O = s?.getItem(n);
1285
+ Ue(T) ? (A = null, s?.removeItem(n)) : (A = c(T), s?.setItem(n, A)), dispatchEvent(
1286
+ // send custom event to communicate within same page
1287
+ // importantly this should not be a StorageEvent since those cannot
1288
+ // be constructed with a non-built-in storage area
1289
+ new CustomEvent(Le, {
1290
+ detail: {
1291
+ key: n,
1292
+ newValue: A,
1293
+ oldValue: O,
1294
+ storageArea: s
1295
+ }
1296
+ })
1297
+ );
1298
+ } catch (A) {
1299
+ a(A);
1300
+ }
1301
+ }, h = (d) => {
1302
+ d.key !== n || d.storageArea !== s || u(i());
1303
+ }, p = (d) => {
1304
+ h(d.detail);
1305
+ };
1306
+ return X("storage", h, {
1307
+ enable: o
1308
+ }), X(Le, p, {
1309
+ enable: o
1310
+ }), [
1311
+ l,
1312
+ E(m)
1313
+ ];
1314
+ }
1315
+ return t;
1316
+ }
1317
+ const zn = Ye(
1318
+ () => q ? localStorage : void 0
1319
+ );
1320
+ function Xn(e) {
1321
+ const t = y(!1);
1322
+ return B(
1323
+ async (...n) => {
1324
+ if (!t.current) {
1325
+ t.current = !0;
1326
+ try {
1327
+ return await e(...n);
1328
+ } catch (r) {
1329
+ throw r;
1330
+ } finally {
1331
+ t.current = !1;
1332
+ }
1333
+ }
1334
+ },
1335
+ [e]
1336
+ );
1337
+ }
1338
+ function jn(e, t, { delay: n = 300, moveThreshold: r, onClick: s, onLongPressEnd: o } = {}) {
1339
+ const a = L(e), c = L(s), f = L(o), i = y(void 0), l = y(!1), u = y({ x: 0, y: 0 }), m = y(!1), h = y(!1), p = !!(r?.x && r.x > 0 || r?.y && r.y > 0);
1340
+ V(
1341
+ () => {
1342
+ const d = D(t);
1343
+ if (!d?.addEventListener)
1344
+ return;
1345
+ const T = (w) => {
1346
+ const { clientX: Y, clientY: P } = A(w), H = Math.abs(Y - u.current.x), oe = Math.abs(P - u.current.y);
1347
+ return !!(r?.x && H > r.x || r?.y && oe > r.y);
1348
+ };
1349
+ function A(w) {
1350
+ return "TouchEvent" in window && w instanceof TouchEvent ? {
1351
+ clientX: w.touches[0].clientX,
1352
+ clientY: w.touches[0].clientY
1353
+ } : w instanceof MouseEvent ? {
1354
+ clientX: w.clientX,
1355
+ clientY: w.clientY
1356
+ } : { clientX: 0, clientY: 0 };
1357
+ }
1358
+ const O = (w) => {
1359
+ i.current = setTimeout(() => {
1360
+ a.current(w), l.current = !0;
1361
+ }, n);
1362
+ }, g = (w) => {
1363
+ if (!h.current) {
1364
+ if (h.current = !0, p) {
1365
+ const { clientX: Y, clientY: P } = A(w);
1366
+ u.current.x = Y, u.current.y = P;
1367
+ }
1368
+ O(w);
1369
+ }
1370
+ }, v = (w) => {
1371
+ w?.sourceCapabilities?.firesTouchEvents || (m.current = !0, p && (u.current.x = w.clientX, u.current.y = w.clientY), O(w));
1372
+ }, S = (w) => {
1373
+ i.current && T(w) && (clearTimeout(i.current), i.current = void 0);
1374
+ }, R = (w) => {
1375
+ h.current && (h.current = !1, i.current && (clearTimeout(i.current), i.current = void 0), l.current ? f.current?.(w) : c.current && c.current(w), l.current = !1);
1376
+ }, N = (w) => {
1377
+ w?.sourceCapabilities?.firesTouchEvents || m.current && (m.current = !1, i.current && (clearTimeout(i.current), i.current = void 0), l.current ? f.current?.(w) : c.current && c.current(w), l.current = !1);
1378
+ }, I = (w) => {
1379
+ m.current && (m.current = !1, i.current && (clearTimeout(i.current), i.current = void 0), l.current && (f.current?.(w), l.current = !1));
1380
+ };
1381
+ return d.addEventListener("mousedown", v), d.addEventListener("mouseup", N), d.addEventListener("mouseleave", I), d.addEventListener("touchstart", g), d.addEventListener("touchend", R), p && (d.addEventListener("mousemove", S), d.addEventListener("touchmove", S)), () => {
1382
+ i.current && (clearTimeout(i.current), l.current = !1), d.removeEventListener("mousedown", v), d.removeEventListener("mouseup", N), d.removeEventListener("mouseleave", I), d.removeEventListener("touchstart", g), d.removeEventListener("touchend", R), p && (d.removeEventListener("mousemove", S), d.removeEventListener("touchmove", S));
1383
+ };
1384
+ },
1385
+ [],
1386
+ t
1387
+ );
1388
+ }
1389
+ function pe(e) {
1390
+ const t = y(0), [n, r] = b(e), s = B((o) => {
1391
+ cancelAnimationFrame(t.current), t.current = requestAnimationFrame(() => {
1392
+ r(o);
1393
+ });
1394
+ }, []);
1395
+ return $(() => {
1396
+ cancelAnimationFrame(t.current);
1397
+ }), [n, s];
1398
+ }
1399
+ const Ft = {
1400
+ screenX: NaN,
1401
+ screenY: NaN,
1402
+ clientX: NaN,
1403
+ clientY: NaN,
1404
+ pageX: NaN,
1405
+ pageY: NaN,
1406
+ elementX: NaN,
1407
+ elementY: NaN,
1408
+ elementH: NaN,
1409
+ elementW: NaN,
1410
+ elementPosX: NaN,
1411
+ elementPosY: NaN
1412
+ }, Bn = (e) => {
1413
+ const [t, n] = pe(Ft);
1414
+ return X(
1415
+ "mousemove",
1416
+ (r) => {
1417
+ const { screenX: s, screenY: o, clientX: a, clientY: c, pageX: f, pageY: i } = r, l = {
1418
+ screenX: s,
1419
+ screenY: o,
1420
+ clientX: a,
1421
+ clientY: c,
1422
+ pageX: f,
1423
+ pageY: i,
1424
+ elementX: NaN,
1425
+ elementY: NaN,
1426
+ elementH: NaN,
1427
+ elementW: NaN,
1428
+ elementPosX: NaN,
1429
+ elementPosY: NaN
1430
+ }, u = D(e);
1431
+ if (u) {
1432
+ const { left: m, top: h, width: p, height: d } = u.getBoundingClientRect();
1433
+ l.elementPosX = m + window.pageXOffset, l.elementPosY = h + window.pageYOffset, l.elementX = f - l.elementPosX, l.elementY = i - l.elementPosY, l.elementW = p, l.elementH = d;
1434
+ }
1435
+ n(l);
1436
+ },
1437
+ {
1438
+ target: () => document
1439
+ }
1440
+ ), t;
1441
+ }, qn = (e, t, n = {}) => {
1442
+ const r = L(e);
1443
+ He(
1444
+ () => {
1445
+ const s = D(t);
1446
+ if (!s)
1447
+ return;
1448
+ const o = new MutationObserver(r.current);
1449
+ return o.observe(s, n), () => {
1450
+ o?.disconnect();
1451
+ };
1452
+ },
1453
+ [n],
1454
+ t
1455
+ );
1456
+ };
1457
+ function ze() {
1458
+ const e = navigator;
1459
+ return $e(e) ? e.connection || e.mozConnection || e.webkitConnection : null;
1460
+ }
1461
+ function Ae() {
1462
+ const e = ze();
1463
+ return e ? {
1464
+ rtt: e.rtt,
1465
+ type: e.type,
1466
+ saveData: e.saveData,
1467
+ downlink: e.downlink,
1468
+ downlinkMax: e.downlinkMax,
1469
+ effectiveType: e.effectiveType
1470
+ } : {};
1471
+ }
1472
+ function Vn() {
1473
+ const [e, t] = b(() => ({
1474
+ since: void 0,
1475
+ online: navigator?.onLine,
1476
+ ...Ae()
1477
+ }));
1478
+ return C(() => {
1479
+ const n = () => {
1480
+ t((a) => ({
1481
+ ...a,
1482
+ online: !0,
1483
+ since: /* @__PURE__ */ new Date()
1484
+ }));
1485
+ }, r = () => {
1486
+ t((a) => ({
1487
+ ...a,
1488
+ online: !1,
1489
+ since: /* @__PURE__ */ new Date()
1490
+ }));
1491
+ }, s = () => {
1492
+ t((a) => ({
1493
+ ...a,
1494
+ ...Ae()
1495
+ }));
1496
+ };
1497
+ window.addEventListener("online", n), window.addEventListener("offline", r);
1498
+ const o = ze();
1499
+ return o?.addEventListener("change", s), () => {
1500
+ window.removeEventListener("online", n), window.removeEventListener("offline", r), o?.removeEventListener(
1501
+ "change",
1502
+ s
1503
+ );
1504
+ };
1505
+ }, []), e;
1506
+ }
1507
+ const Un = (e, t = {}) => {
1508
+ const { defaultPageSize: n = 10, defaultCurrent: r = 1, ...s } = t, o = ke(e, {
1509
+ defaultParams: [{ current: r, pageSize: n }],
1510
+ refreshDepsAction: () => {
1511
+ u(1);
1512
+ },
1513
+ ...s
1514
+ }), { current: a = 1, pageSize: c = n } = o.params[0] || {}, f = o.data?.total || 0, i = x(
1515
+ () => Math.ceil(f / c),
1516
+ [c, f]
1517
+ ), l = (h, p) => {
1518
+ let d = h <= 0 ? 1 : h;
1519
+ const T = p <= 0 ? 1 : p, A = Math.ceil(f / T);
1520
+ d > A && (d = Math.max(1, A));
1521
+ const [O = {}, ...g] = o.params || [];
1522
+ o.run(
1523
+ {
1524
+ ...O,
1525
+ current: d,
1526
+ pageSize: T
1527
+ },
1528
+ ...g
1529
+ );
1530
+ }, u = (h) => {
1531
+ l(h, c);
1532
+ }, m = (h) => {
1533
+ l(a, h);
1534
+ };
1535
+ return {
1536
+ ...o,
1537
+ pagination: {
1538
+ current: a,
1539
+ pageSize: c,
1540
+ total: f,
1541
+ totalPage: i,
1542
+ onChange: E(l),
1543
+ changeCurrent: E(u),
1544
+ changePageSize: E(m)
1545
+ }
1546
+ };
1547
+ }, kt = (e, t = 0) => {
1548
+ if (typeof requestAnimationFrame > "u")
1549
+ return {
1550
+ id: setInterval(e, t)
1551
+ };
1552
+ let n = Date.now();
1553
+ const r = {
1554
+ id: 0
1555
+ }, s = () => {
1556
+ Date.now() - n >= t && (e(), n = Date.now()), r.id = requestAnimationFrame(s);
1557
+ };
1558
+ return r.id = requestAnimationFrame(s), r;
1559
+ }, Ht = (e) => typeof cancelAnimationFrame > "u", _t = (e) => {
1560
+ if (Ht(e.id))
1561
+ return clearInterval(e.id);
1562
+ cancelAnimationFrame(e.id);
1563
+ };
1564
+ function $n(e, t, n) {
1565
+ const r = n?.immediate, s = L(e), o = y(void 0), a = B(() => {
1566
+ o.current && _t(o.current);
1567
+ }, []);
1568
+ return C(() => {
1569
+ if (!(!F(t) || t < 0))
1570
+ return r && s.current(), o.current = kt(() => {
1571
+ s.current();
1572
+ }, t), a;
1573
+ }, [t]), a;
1574
+ }
1575
+ const It = (e, t = 0) => {
1576
+ if (typeof requestAnimationFrame > "u")
1577
+ return {
1578
+ id: setTimeout(e, t)
1579
+ };
1580
+ const n = {
1581
+ id: 0
1582
+ }, r = Date.now(), s = () => {
1583
+ Date.now() - r >= t ? e() : n.id = requestAnimationFrame(s);
1584
+ };
1585
+ return n.id = requestAnimationFrame(s), n;
1586
+ }, Yt = (e) => typeof cancelAnimationFrame > "u", zt = (e) => {
1587
+ if (Yt(e.id))
1588
+ return clearTimeout(e.id);
1589
+ cancelAnimationFrame(e.id);
1590
+ };
1591
+ function Wn(e, t) {
1592
+ const n = L(e), r = y(void 0), s = B(() => {
1593
+ r.current && zt(r.current);
1594
+ }, []);
1595
+ return C(() => {
1596
+ if (!(!F(t) || t < 0))
1597
+ return r.current = It(() => {
1598
+ n.current();
1599
+ }, t), s;
1600
+ }, [t]), s;
1601
+ }
1602
+ const Pe = /* @__PURE__ */ new WeakMap(), Ce = /* @__PURE__ */ new WeakMap();
1603
+ function Xe(e, t) {
1604
+ const n = Pe.get(e);
1605
+ if (n)
1606
+ return n;
1607
+ if (Ce.has(e))
1608
+ return e;
1609
+ const r = new Proxy(e, {
1610
+ get(s, o, a) {
1611
+ const c = Reflect.get(s, o, a), f = Reflect.getOwnPropertyDescriptor(s, o);
1612
+ return !f?.configurable && !f?.writable ? c : de(c) || Array.isArray(c) ? Xe(c, t) : c;
1613
+ },
1614
+ set(s, o, a) {
1615
+ const c = Reflect.set(s, o, a);
1616
+ return t(), c;
1617
+ },
1618
+ deleteProperty(s, o) {
1619
+ const a = Reflect.deleteProperty(s, o);
1620
+ return t(), a;
1621
+ }
1622
+ });
1623
+ return Pe.set(e, r), Ce.set(r, e), r;
1624
+ }
1625
+ function Gn(e) {
1626
+ const t = ne(), n = y(e);
1627
+ return se(() => Xe(n.current, () => {
1628
+ t();
1629
+ }), []);
1630
+ }
1631
+ const Kn = (e) => {
1632
+ const t = y(e), n = se(
1633
+ () => k(t.current) ? t.current() : t.current,
1634
+ []
1635
+ ), [r, s] = b(n), o = E(() => {
1636
+ s(n);
1637
+ });
1638
+ return [r, s, o];
1639
+ }, ee = /* @__PURE__ */ new Set();
1640
+ let U, ge = {
1641
+ xs: 0,
1642
+ sm: 576,
1643
+ md: 768,
1644
+ lg: 992,
1645
+ xl: 1200
1646
+ };
1647
+ function le() {
1648
+ const e = U;
1649
+ if (ve(), e !== U)
1650
+ for (const t of ee)
1651
+ t();
1652
+ }
1653
+ let Q = !1;
1654
+ function ve() {
1655
+ const e = window.innerWidth, t = {};
1656
+ let n = !1;
1657
+ for (const r of Object.keys(ge))
1658
+ t[r] = e >= ge[r], t[r] !== U[r] && (n = !0);
1659
+ n && (U = t);
1660
+ }
1661
+ function Jn(e) {
1662
+ ge = e, U && ve();
1663
+ }
1664
+ function Qn() {
1665
+ q && !Q && (U = {}, ve(), window.addEventListener("resize", le), Q = !0);
1666
+ const [e, t] = b(U);
1667
+ return C(() => {
1668
+ if (!q)
1669
+ return;
1670
+ Q || window.addEventListener("resize", le);
1671
+ const n = () => {
1672
+ t(U);
1673
+ };
1674
+ return ee.add(n), () => {
1675
+ ee.delete(n), ee.size === 0 && (window.removeEventListener("resize", le), Q = !1);
1676
+ };
1677
+ }, []), e;
1678
+ }
1679
+ const Xt = () => {
1680
+ const e = y(!1);
1681
+ return C(() => (e.current = !1, () => {
1682
+ e.current = !0;
1683
+ }), []), e;
1684
+ };
1685
+ function Zn(e) {
1686
+ const t = Xt(), [n, r] = b(e), s = B((o) => {
1687
+ t.current || r(o);
1688
+ }, []);
1689
+ return [n, s];
1690
+ }
1691
+ function er(e, t = () => !0) {
1692
+ const [n, r] = pe(), s = L(t);
1693
+ return V(
1694
+ () => {
1695
+ const o = D(e, document);
1696
+ if (!o)
1697
+ return;
1698
+ const a = () => {
1699
+ let c;
1700
+ o === document ? document.scrollingElement ? c = {
1701
+ left: document.scrollingElement.scrollLeft,
1702
+ top: document.scrollingElement.scrollTop
1703
+ } : c = {
1704
+ left: Math.max(
1705
+ window.pageXOffset,
1706
+ document.documentElement.scrollLeft,
1707
+ document.body.scrollLeft
1708
+ ),
1709
+ top: Math.max(
1710
+ window.pageYOffset,
1711
+ document.documentElement.scrollTop,
1712
+ document.body.scrollTop
1713
+ )
1714
+ } : c = {
1715
+ left: o.scrollLeft,
1716
+ top: o.scrollTop
1717
+ }, s.current(c) && r(c);
1718
+ };
1719
+ return a(), o.addEventListener("scroll", a), () => {
1720
+ o.removeEventListener("scroll", a);
1721
+ };
1722
+ },
1723
+ [],
1724
+ e
1725
+ ), n;
1726
+ }
1727
+ function tr(e, t) {
1728
+ let n = [], r;
1729
+ Array.isArray(t) ? n = t : de(t) && (n = t?.defaultSelected ?? n, r = t?.itemKey ?? r);
1730
+ const s = (g) => k(r) ? r(g) : te(r) && de(g) ? g[r] : g, [o, a] = b(n), c = x(() => {
1731
+ const g = /* @__PURE__ */ new Map();
1732
+ return Array.isArray(o) && o.forEach((v) => {
1733
+ g.set(s(v), v);
1734
+ }), g;
1735
+ }, [o]), f = (g) => c.has(s(g)), i = (g) => {
1736
+ c.set(s(g), g), a(Array.from(c.values()));
1737
+ }, l = (g) => {
1738
+ c.delete(s(g)), a(Array.from(c.values()));
1739
+ }, u = (g) => {
1740
+ f(g) ? l(g) : i(g);
1741
+ }, m = () => {
1742
+ e.forEach((g) => {
1743
+ c.set(s(g), g);
1744
+ }), a(Array.from(c.values()));
1745
+ }, h = () => {
1746
+ e.forEach((g) => {
1747
+ c.delete(s(g));
1748
+ }), a(Array.from(c.values()));
1749
+ }, p = x(
1750
+ () => e.every((g) => !c.has(s(g))),
1751
+ [e, c]
1752
+ ), d = x(
1753
+ () => e.every((g) => c.has(s(g))) && !p,
1754
+ [e, c, p]
1755
+ ), T = x(
1756
+ () => !p && !d,
1757
+ [p, d]
1758
+ ), A = () => d ? h() : m(), O = () => {
1759
+ c.clear(), a([]);
1760
+ };
1761
+ return {
1762
+ selected: o,
1763
+ noneSelected: p,
1764
+ allSelected: d,
1765
+ partiallySelected: T,
1766
+ setSelected: a,
1767
+ isSelected: f,
1768
+ select: E(i),
1769
+ unSelect: E(l),
1770
+ toggle: E(u),
1771
+ selectAll: E(m),
1772
+ unSelectAll: E(h),
1773
+ clearAll: E(O),
1774
+ toggleAll: E(A)
1775
+ };
1776
+ }
1777
+ const nr = Ye(
1778
+ () => q ? sessionStorage : void 0
1779
+ ), rr = (e) => {
1780
+ const [t, n] = b(e), r = E((s) => {
1781
+ n((o) => {
1782
+ const a = k(s) ? s(o) : s;
1783
+ return a ? { ...o, ...a } : o;
1784
+ });
1785
+ });
1786
+ return [t, r];
1787
+ }, jt = Qe(he), Bt = q ? jt : V;
1788
+ function qt(e) {
1789
+ const [t, n] = pe(() => {
1790
+ const r = D(e);
1791
+ return r ? { width: r.clientWidth, height: r.clientHeight } : void 0;
1792
+ });
1793
+ return Bt(
1794
+ () => {
1795
+ const r = D(e);
1796
+ if (!r)
1797
+ return;
1798
+ const s = new ResizeObserver((o) => {
1799
+ o.forEach((a) => {
1800
+ const { clientWidth: c, clientHeight: f } = a.target;
1801
+ n({ width: c, height: f });
1802
+ });
1803
+ });
1804
+ return s.observe(r), () => {
1805
+ s.disconnect();
1806
+ };
1807
+ },
1808
+ [],
1809
+ e
1810
+ ), t;
1811
+ }
1812
+ const Vt = () => {
1813
+ const e = q ? window.matchMedia("(prefers-color-scheme: dark)") : void 0, [t, n] = b(() => q && e?.matches ? "dark" : "light");
1814
+ return C(() => {
1815
+ const r = (s) => {
1816
+ s.matches ? n(
1817
+ "dark"
1818
+ /* DARK */
1819
+ ) : n(
1820
+ "light"
1821
+ /* LIGHT */
1822
+ );
1823
+ };
1824
+ return e?.addEventListener("change", r), () => {
1825
+ e?.removeEventListener("change", r);
1826
+ };
1827
+ }, []), t;
1828
+ };
1829
+ function sr(e = {}) {
1830
+ const { localStorageKey: t } = e, [n, r] = b(() => t?.length && localStorage.getItem(t) || "system"), s = (c) => {
1831
+ r(c), t?.length && localStorage.setItem(t, c);
1832
+ }, o = Vt();
1833
+ return {
1834
+ theme: n === "system" ? o : n,
1835
+ themeMode: n,
1836
+ setThemeMode: E(s)
1837
+ };
1838
+ }
1839
+ function je(e, t) {
1840
+ re && (k(e) || console.error(
1841
+ `useThrottleFn expected parameter is a function, got ${typeof e}`
1842
+ ));
1843
+ const n = L(e), r = t?.wait ?? 1e3, s = x(
1844
+ () => Me(
1845
+ (...o) => n.current(...o),
1846
+ r,
1847
+ t
1848
+ ),
1849
+ []
1850
+ );
1851
+ return $(() => {
1852
+ s.cancel();
1853
+ }), {
1854
+ run: s,
1855
+ cancel: s.cancel,
1856
+ flush: s.flush
1857
+ };
1858
+ }
1859
+ function or(e, t) {
1860
+ const [n, r] = b(e), { run: s } = je(() => {
1861
+ r(e);
1862
+ }, t);
1863
+ return C(() => {
1864
+ s();
1865
+ }, [e]), n;
1866
+ }
1867
+ function cr(e, t, n) {
1868
+ const [r, s] = b({}), { run: o } = je(() => {
1869
+ s({});
1870
+ }, n);
1871
+ C(() => o(), t), K(e, [r]);
1872
+ }
1873
+ const ar = (e, t) => {
1874
+ const n = E(e), r = y(null), s = B(() => {
1875
+ r.current && clearTimeout(r.current);
1876
+ }, []);
1877
+ return C(() => {
1878
+ if (!(!F(t) || t < 0))
1879
+ return r.current = setTimeout(n, t), s;
1880
+ }, [t]), s;
1881
+ }, Ut = {
1882
+ restoreOnUnmount: !1
1883
+ };
1884
+ function ur(e, t = Ut) {
1885
+ const n = y(q ? document.title : "");
1886
+ C(() => {
1887
+ document.title = e;
1888
+ }, [e]), $(() => {
1889
+ t.restoreOnUnmount && (document.title = n.current);
1890
+ });
1891
+ }
1892
+ const $t = (e, t) => e ? e.map((n, r) => Object.is(e[r], t?.[r]) ? -1 : r).filter((n) => n >= 0) : t ? t.map((n, r) => r) : [], ir = (e, t) => {
1893
+ const n = y(void 0);
1894
+ C(() => {
1895
+ const r = $t(n.current, t), s = n.current;
1896
+ return n.current = t, e(r, s, t);
1897
+ }, t);
1898
+ }, lr = et(he), fe = nt, Wt = {
1899
+ parseNumbers: !1,
1900
+ parseBooleans: !1
1901
+ }, Gt = {
1902
+ skipNull: !1,
1903
+ skipEmptyString: !1
1904
+ }, fr = (e, t) => {
1905
+ const {
1906
+ navigateMode: n = "push",
1907
+ parseOptions: r,
1908
+ stringifyOptions: s
1909
+ } = t || {}, o = { ...Wt, ...r }, a = {
1910
+ ...Gt,
1911
+ ...s
1912
+ }, c = fe.useLocation(), f = fe.useHistory?.(), i = fe.useNavigate?.(), l = ne(), u = y(
1913
+ typeof e == "function" ? e() : e || {}
1914
+ ), m = x(() => ae.parse(c.search, o), [c.search]), h = x(
1915
+ () => ({
1916
+ ...u.current,
1917
+ ...m
1918
+ }),
1919
+ [m]
1920
+ );
1921
+ return [h, E((d) => {
1922
+ const T = typeof d == "function" ? d(h) : d;
1923
+ l(), f && f[n](
1924
+ {
1925
+ hash: c.hash,
1926
+ search: ae.stringify(
1927
+ { ...m, ...T },
1928
+ a
1929
+ ) || "?"
1930
+ },
1931
+ c.state
1932
+ ), i && i(
1933
+ {
1934
+ hash: c.hash,
1935
+ search: ae.stringify(
1936
+ { ...m, ...T },
1937
+ a
1938
+ ) || "?"
1939
+ },
1940
+ {
1941
+ replace: n === "replace",
1942
+ state: c.state
1943
+ }
1944
+ );
1945
+ })];
1946
+ }, dr = (e, t) => {
1947
+ const { containerTarget: n, wrapperTarget: r, itemHeight: s, overscan: o = 5 } = t, a = L(s), c = qt(n), f = y(!1), [i, l] = b(
1948
+ []
1949
+ ), [u, m] = b({}), h = (g, v) => {
1950
+ if (F(a.current))
1951
+ return Math.ceil(g / a.current);
1952
+ let S = 0, R = 0;
1953
+ for (let N = v; N < e.length; N++) {
1954
+ const I = a.current(N, e[N]);
1955
+ if (S += I, R = N, S >= g)
1956
+ break;
1957
+ }
1958
+ return R - v;
1959
+ }, p = (g) => {
1960
+ if (F(a.current))
1961
+ return Math.floor(g / a.current);
1962
+ let v = 0, S = 0;
1963
+ for (let R = 0; R < e.length; R++) {
1964
+ const N = a.current(R, e[R]);
1965
+ if (v += N, v >= g) {
1966
+ S = R;
1967
+ break;
1968
+ }
1969
+ }
1970
+ return S + 1;
1971
+ }, d = (g) => F(a.current) ? g * a.current : e.slice(0, g).reduce(
1972
+ (S, R, N) => S + a.current(N, e[N]),
1973
+ 0
1974
+ ), T = x(() => F(a.current) ? e.length * a.current : e.reduce(
1975
+ (g, v, S) => g + a.current(S, e[S]),
1976
+ 0
1977
+ ), [e]), A = () => {
1978
+ const g = D(n);
1979
+ if (g) {
1980
+ const { scrollTop: v, clientHeight: S } = g, R = p(v), N = h(S, R), I = Math.max(0, R - o), w = Math.min(e.length, R + N + o), Y = d(I);
1981
+ m({
1982
+ height: T - Y + "px",
1983
+ marginTop: Y + "px"
1984
+ }), l(
1985
+ e.slice(I, w).map((P, H) => ({
1986
+ data: P,
1987
+ index: H + I
1988
+ }))
1989
+ );
1990
+ }
1991
+ };
1992
+ return K(() => {
1993
+ const g = D(r);
1994
+ g && Object.keys(u).forEach(
1995
+ (v) => g.style[v] = u[v]
1996
+ );
1997
+ }, [u]), C(() => {
1998
+ !c?.width || !c?.height || A();
1999
+ }, [c?.width, c?.height, e]), X(
2000
+ "scroll",
2001
+ (g) => {
2002
+ if (f.current) {
2003
+ f.current = !1;
2004
+ return;
2005
+ }
2006
+ g.preventDefault(), A();
2007
+ },
2008
+ {
2009
+ target: n
2010
+ }
2011
+ ), [i, E((g) => {
2012
+ const v = D(n);
2013
+ v && (f.current = !0, v.scrollTop = d(g), A());
2014
+ })];
2015
+ };
2016
+ function mr(e, t = {}) {
2017
+ const {
2018
+ reconnectLimit: n = 3,
2019
+ reconnectInterval: r = 3 * 1e3,
2020
+ manual: s = !1,
2021
+ onOpen: o,
2022
+ onClose: a,
2023
+ onMessage: c,
2024
+ onError: f,
2025
+ protocols: i
2026
+ } = t, [l, u] = b(), [m, h] = b(
2027
+ 3
2028
+ /* Closed */
2029
+ ), p = L(o), d = L(a), T = L(c), A = L(f), O = L(m), g = y(0), v = y(void 0), S = y(void 0), R = () => {
2030
+ g.current < n && S.current?.readyState !== 1 && (v.current && clearTimeout(v.current), v.current = setTimeout(() => {
2031
+ N(), g.current++;
2032
+ }, r));
2033
+ }, N = () => {
2034
+ v.current && clearTimeout(v.current), S.current && S.current.close();
2035
+ const P = new WebSocket(e, i);
2036
+ h(
2037
+ 0
2038
+ /* Connecting */
2039
+ ), P.onerror = (H) => {
2040
+ S.current === P && (R(), A.current?.(H, P), h(
2041
+ P.readyState || 3
2042
+ /* Closed */
2043
+ ));
2044
+ }, P.onopen = (H) => {
2045
+ S.current === P && (p.current?.(H, P), g.current = 0, h(
2046
+ P.readyState || 1
2047
+ /* Open */
2048
+ ));
2049
+ }, P.onmessage = (H) => {
2050
+ S.current === P && (T.current?.(H, P), u(H));
2051
+ }, P.onclose = (H) => {
2052
+ d.current?.(H, P), S.current === P && R(), (!S.current || S.current === P) && h(
2053
+ P.readyState || 3
2054
+ /* Closed */
2055
+ );
2056
+ }, S.current = P;
2057
+ }, I = (P) => {
2058
+ if (O.current === 1)
2059
+ S.current?.send(P);
2060
+ else
2061
+ throw new Error("WebSocket disconnected");
2062
+ }, w = () => {
2063
+ g.current = 0, N();
2064
+ }, Y = () => {
2065
+ v.current && clearTimeout(v.current), g.current = n, S.current?.close(), S.current = void 0;
2066
+ };
2067
+ return C(() => {
2068
+ !s && e && w();
2069
+ }, [e, s]), $(() => {
2070
+ Y();
2071
+ }), {
2072
+ latestMessage: l,
2073
+ sendMessage: E(I),
2074
+ connect: E(w),
2075
+ disconnect: E(Y),
2076
+ readyState: m,
2077
+ webSocketIns: S.current
2078
+ };
2079
+ }
2080
+ function gr(e, t) {
2081
+ const n = y({});
2082
+ C(() => {
2083
+ if (n.current) {
2084
+ const r = Object.keys({ ...n.current, ...t }), s = {};
2085
+ r.forEach((o) => {
2086
+ Object.is(n.current[o], t[o]) || (s[o] = {
2087
+ from: n.current[o],
2088
+ to: t[o]
2089
+ });
2090
+ }), Object.keys(s).length && console.log("[why-did-you-update]", e, s);
2091
+ }
2092
+ n.current = t;
2093
+ });
2094
+ }
2095
+ export {
2096
+ je as $,
2097
+ In as A,
2098
+ Hn as B,
2099
+ Yn as C,
2100
+ zn as D,
2101
+ Xn as E,
2102
+ jn as F,
2103
+ Fe as G,
2104
+ Bn as H,
2105
+ qn as I,
2106
+ Vn as J,
2107
+ Un as K,
2108
+ $n as L,
2109
+ pe as M,
2110
+ Wn as N,
2111
+ Gn as O,
2112
+ ke as P,
2113
+ Kn as Q,
2114
+ Qn as R,
2115
+ Zn as S,
2116
+ er as T,
2117
+ tr as U,
2118
+ nr as V,
2119
+ rr as W,
2120
+ qt as X,
2121
+ sr as Y,
2122
+ or as Z,
2123
+ cr as _,
2124
+ Jn as a,
2125
+ ar as a0,
2126
+ ur as a1,
2127
+ st as a2,
2128
+ ir as a3,
2129
+ Xt as a4,
2130
+ lr as a5,
2131
+ fr as a6,
2132
+ dr as a7,
2133
+ mr as a8,
2134
+ gr as a9,
2135
+ ot as b,
2136
+ _n as c,
2137
+ pn as d,
2138
+ vn as e,
2139
+ yn as f,
2140
+ En as g,
2141
+ Sn as h,
2142
+ wn as i,
2143
+ bn as j,
2144
+ Ne as k,
2145
+ Rn as l,
2146
+ Tn as m,
2147
+ Ln as n,
2148
+ An as o,
2149
+ Pn as p,
2150
+ X as q,
2151
+ Cn as r,
2152
+ Dn as s,
2153
+ Mn as t,
2154
+ hn as u,
2155
+ Nn as v,
2156
+ On as w,
2157
+ xn as x,
2158
+ Fn as y,
2159
+ kn as z
2160
+ };