tekivex-ui 2.5.1 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +436 -83
  2. package/dist/TkxForm-DSMDo2Ol.js +388 -0
  3. package/dist/TkxForm-DwV_n-eE.cjs +12 -0
  4. package/dist/headless.cjs +1 -1
  5. package/dist/headless.js +396 -195
  6. package/dist/i18n.cjs +1 -0
  7. package/dist/i18n.js +757 -0
  8. package/dist/index.cjs +27 -22
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +4994 -5089
  12. package/dist/quantum.cjs +91 -0
  13. package/dist/quantum.js +2312 -0
  14. package/dist/realtime.cjs +25 -0
  15. package/dist/realtime.js +944 -0
  16. package/dist/security-C369oOWH.cjs +1 -0
  17. package/dist/security-CzAmaMqa.js +97 -0
  18. package/dist/src/components/TkxDataGrid.d.ts +9 -1
  19. package/dist/src/components/TkxDataGrid.d.ts.map +1 -1
  20. package/dist/src/components/TkxDropdown.d.ts +41 -0
  21. package/dist/src/components/TkxDropdown.d.ts.map +1 -0
  22. package/dist/src/components/TkxLiveFeed.d.ts +891 -0
  23. package/dist/src/components/TkxLiveFeed.d.ts.map +1 -0
  24. package/dist/src/components/TkxLiveLog.d.ts +892 -0
  25. package/dist/src/components/TkxLiveLog.d.ts.map +1 -0
  26. package/dist/src/components/TkxLiveMetrics.d.ts +24 -0
  27. package/dist/src/components/TkxLiveMetrics.d.ts.map +1 -0
  28. package/dist/src/components/TkxPlayground.d.ts +15 -0
  29. package/dist/src/components/TkxPlayground.d.ts.map +1 -0
  30. package/dist/src/components/TkxQuantumForm.d.ts +20 -0
  31. package/dist/src/components/TkxQuantumForm.d.ts.map +1 -0
  32. package/dist/src/components/TkxRealTimeChart.d.ts +27 -0
  33. package/dist/src/components/TkxRealTimeChart.d.ts.map +1 -0
  34. package/dist/src/components/TkxTable.d.ts +11 -1
  35. package/dist/src/components/TkxTable.d.ts.map +1 -1
  36. package/dist/src/components/TkxThemeBuilder.d.ts +9 -0
  37. package/dist/src/components/TkxThemeBuilder.d.ts.map +1 -0
  38. package/dist/src/components/index.d.ts +1 -0
  39. package/dist/src/components/index.d.ts.map +1 -1
  40. package/dist/src/engine/index.d.ts +2 -0
  41. package/dist/src/engine/index.d.ts.map +1 -1
  42. package/dist/src/engine/quantum-ai.d.ts +201 -0
  43. package/dist/src/engine/quantum-ai.d.ts.map +1 -0
  44. package/dist/src/engine/tkx.d.ts.map +1 -1
  45. package/dist/src/headless/index.d.ts +6 -0
  46. package/dist/src/headless/index.d.ts.map +1 -1
  47. package/dist/src/headless/useInfiniteQuery.d.ts +35 -0
  48. package/dist/src/headless/useInfiniteQuery.d.ts.map +1 -0
  49. package/dist/src/headless/useSSE.d.ts +36 -0
  50. package/dist/src/headless/useSSE.d.ts.map +1 -0
  51. package/dist/src/headless/useWebSocket.d.ts +33 -0
  52. package/dist/src/headless/useWebSocket.d.ts.map +1 -0
  53. package/dist/src/quantum/index.d.ts +9 -0
  54. package/dist/src/quantum/index.d.ts.map +1 -0
  55. package/dist/src/realtime/index.d.ts +9 -0
  56. package/dist/src/realtime/index.d.ts.map +1 -0
  57. package/dist/{TkxForm-BWK4LqY3.js → tkx-BJ10JtMv.js} +372 -721
  58. package/dist/tkx-BeNyC0w7.cjs +4 -0
  59. package/package.json +16 -1
  60. package/src/components/TkxDataGrid.tsx +72 -0
  61. package/src/components/TkxDropdown.tsx +802 -0
  62. package/src/components/TkxLiveFeed.tsx +329 -0
  63. package/src/components/TkxLiveLog.tsx +470 -0
  64. package/src/components/TkxLiveMetrics.tsx +291 -0
  65. package/src/components/TkxPlayground.tsx +736 -0
  66. package/src/components/TkxQuantumForm.tsx +592 -0
  67. package/src/components/TkxRealTimeChart.tsx +381 -0
  68. package/src/components/TkxTable.tsx +351 -77
  69. package/src/components/TkxThemeBuilder.tsx +685 -0
  70. package/src/components/index.ts +4 -0
  71. package/src/engine/index.ts +2 -0
  72. package/src/engine/quantum-ai.ts +1045 -0
  73. package/src/engine/tkx.ts +95 -4
  74. package/src/headless/index.ts +6 -0
  75. package/src/headless/useInfiniteQuery.ts +153 -0
  76. package/src/headless/useSSE.ts +165 -0
  77. package/src/headless/useWebSocket.ts +229 -0
  78. package/src/quantum/index.ts +39 -0
  79. package/src/realtime/index.ts +21 -0
  80. package/dist/TkxForm-ljQjX7KD.cjs +0 -15
package/dist/headless.js CHANGED
@@ -1,258 +1,459 @@
1
- import { c as q, h as H, r as J, k as K, s as N, l as U, m as B, n as Q, a as $, e as G, d as W, b as X, p as Y, u as Z, q as _ } from "./TkxForm-BWK4LqY3.js";
2
- import { f as te, l as ne, m as se, q as re, s as oe, t as ce, F as ue } from "./index-eT_U4qB2.js";
3
- import { useState as g, useCallback as i, useRef as A, useMemo as O, useEffect as x } from "react";
4
- function k(e = !1) {
5
- const [r, t] = g(e), n = i(() => t(!0), []), s = i(() => t(!1), []), c = i(() => t((o) => !o), []);
6
- return { isOpen: r, open: n, close: s, toggle: c };
1
+ import { a as ge, d as me, c as he, b as ye, f as Se, u as pe, g as we } from "./TkxForm-DSMDo2Ol.js";
2
+ import { c as be, e as Ee, r as xe, b as Ie, d as Oe, f as De } from "./tkx-BJ10JtMv.js";
3
+ import { f as Te, l as Ae, m as Ce, q as Me, s as ke, t as Fe, F as Le } from "./index-eT_U4qB2.js";
4
+ import { b as Pe, s as Ne } from "./security-CzAmaMqa.js";
5
+ import { useState as S, useCallback as a, useRef as g, useMemo as X, useEffect as z } from "react";
6
+ function Z(e = !1) {
7
+ const [c, t] = S(e), r = a(() => t(!0), []), n = a(() => t(!1), []), o = a(() => t((s) => !s), []);
8
+ return { isOpen: c, open: r, close: n, toggle: o };
7
9
  }
8
- function V({
10
+ function _({
9
11
  count: e,
10
- initialIndex: r = 0,
12
+ initialIndex: c = 0,
11
13
  orientation: t = "horizontal",
12
- loop: n = !0
14
+ loop: r = !0
13
15
  }) {
14
- const [s, c] = g(r), o = A([]), u = i(
15
- (l) => {
16
- c((a) => {
17
- let h = a + l;
18
- return n ? h = (h % e + e) % e : h = Math.max(0, Math.min(e - 1, h)), requestAnimationFrame(() => {
19
- var y;
20
- (y = o.current[h]) == null || y.focus();
21
- }), h;
16
+ const [n, o] = S(c), s = g([]), l = a(
17
+ (i) => {
18
+ o((d) => {
19
+ let p = d + i;
20
+ return r ? p = (p % e + e) % e : p = Math.max(0, Math.min(e - 1, p)), requestAnimationFrame(() => {
21
+ var I;
22
+ (I = s.current[p]) == null || I.focus();
23
+ }), p;
22
24
  });
23
25
  },
24
- [e, n]
25
- ), w = i(
26
- (l) => ({
27
- tabIndex: l === s ? 0 : -1,
28
- "data-focused": l === s,
29
- onFocus: () => c(l),
30
- onKeyDown: (a) => {
31
- const h = t === "horizontal" || t === "both", y = t === "vertical" || t === "both";
32
- h && a.key === "ArrowRight" && (a.preventDefault(), u(1)), h && a.key === "ArrowLeft" && (a.preventDefault(), u(-1)), y && a.key === "ArrowDown" && (a.preventDefault(), u(1)), y && a.key === "ArrowUp" && (a.preventDefault(), u(-1)), a.key === "Home" && (a.preventDefault(), c(0), requestAnimationFrame(() => {
33
- var p;
34
- return (p = o.current[0]) == null ? void 0 : p.focus();
35
- })), a.key === "End" && (a.preventDefault(), c(e - 1), requestAnimationFrame(() => {
36
- var p;
37
- return (p = o.current[e - 1]) == null ? void 0 : p.focus();
26
+ [e, r]
27
+ ), m = a(
28
+ (i) => ({
29
+ tabIndex: i === n ? 0 : -1,
30
+ "data-focused": i === n,
31
+ onFocus: () => o(i),
32
+ onKeyDown: (d) => {
33
+ const p = t === "horizontal" || t === "both", I = t === "vertical" || t === "both";
34
+ p && d.key === "ArrowRight" && (d.preventDefault(), l(1)), p && d.key === "ArrowLeft" && (d.preventDefault(), l(-1)), I && d.key === "ArrowDown" && (d.preventDefault(), l(1)), I && d.key === "ArrowUp" && (d.preventDefault(), l(-1)), d.key === "Home" && (d.preventDefault(), o(0), requestAnimationFrame(() => {
35
+ var w;
36
+ return (w = s.current[0]) == null ? void 0 : w.focus();
37
+ })), d.key === "End" && (d.preventDefault(), o(e - 1), requestAnimationFrame(() => {
38
+ var w;
39
+ return (w = s.current[e - 1]) == null ? void 0 : w.focus();
38
40
  }));
39
41
  }
40
42
  }),
41
- [s, u, t, e]
43
+ [n, l, t, e]
42
44
  );
43
- return { focusedIndex: s, setFocusedIndex: c, getItemProps: w };
45
+ return { focusedIndex: n, setFocusedIndex: o, getItemProps: m };
44
46
  }
45
- function T({
47
+ function ee({
46
48
  initialValues: e,
47
- validate: r
49
+ validate: c
48
50
  }) {
49
- const [t, n] = g({ ...e }), [s, c] = g({}), [o, u] = g({}), w = A(e), l = i((d, b) => {
50
- n((v) => ({ ...v, [d]: b }));
51
- }, []), a = i((d) => {
52
- n((b) => ({ ...b, ...d }));
53
- }, []), h = i((d) => {
54
- u((b) => ({ ...b, [d]: !0 }));
55
- }, []), y = i(() => {
56
- if (!r) return !0;
57
- const d = r(t), b = Object.fromEntries(
58
- Object.entries(d).filter(([, I]) => I != null)
51
+ const [t, r] = S({ ...e }), [n, o] = S({}), [s, l] = S({}), m = g(e), i = a((f, y) => {
52
+ r((T) => ({ ...T, [f]: y }));
53
+ }, []), d = a((f) => {
54
+ r((y) => ({ ...y, ...f }));
55
+ }, []), p = a((f) => {
56
+ l((y) => ({ ...y, [f]: !0 }));
57
+ }, []), I = a(() => {
58
+ if (!c) return !0;
59
+ const f = c(t), y = Object.fromEntries(
60
+ Object.entries(f).filter(([, A]) => A != null)
59
61
  );
60
- c(b);
61
- const v = Object.fromEntries(
62
- Object.keys(t).map((I) => [I, !0])
62
+ o(y);
63
+ const T = Object.fromEntries(
64
+ Object.keys(t).map((A) => [A, !0])
63
65
  );
64
- return u(v), Object.keys(b).length === 0;
65
- }, [t, r]), p = i(() => {
66
- n({ ...w.current }), c({}), u({});
67
- }, []), f = Object.keys(t).some(
68
- (d) => t[d] !== w.current[d]
69
- ), S = Object.keys(s).length === 0, m = i(
70
- (d) => ({
71
- value: t[d],
72
- onChange: (b) => {
73
- l(d, b.target.value);
66
+ return l(T), Object.keys(y).length === 0;
67
+ }, [t, c]), w = a(() => {
68
+ r({ ...m.current }), o({}), l({});
69
+ }, []), h = Object.keys(t).some(
70
+ (f) => t[f] !== m.current[f]
71
+ ), b = Object.keys(n).length === 0, u = a(
72
+ (f) => ({
73
+ value: t[f],
74
+ onChange: (y) => {
75
+ i(f, y.target.value);
74
76
  },
75
- onBlur: () => h(d),
76
- "aria-invalid": o[d] && s[d] ? !0 : void 0,
77
- "aria-describedby": s[d] ? `${String(d)}-error` : void 0
77
+ onBlur: () => p(f),
78
+ "aria-invalid": s[f] && n[f] ? !0 : void 0,
79
+ "aria-describedby": n[f] ? `${String(f)}-error` : void 0
78
80
  }),
79
- [t, s, o, l, h]
81
+ [t, n, s, i, p]
80
82
  );
81
- return { values: t, errors: s, touched: o, dirty: f, isValid: S, setValue: l, setValues: a, touchField: h, validate: y, reset: p, getFieldProps: m };
83
+ return { values: t, errors: n, touched: s, dirty: h, isValid: b, setValue: i, setValues: d, touchField: p, validate: I, reset: w, getFieldProps: u };
82
84
  }
83
- function E({
85
+ function te({
84
86
  items: e,
85
- initialSelected: r = [],
87
+ initialSelected: c = [],
86
88
  multiple: t = !0
87
89
  }) {
88
- const [n, s] = g(() => new Set(r)), c = i((f) => {
89
- s((S) => {
90
- const m = new Set(S);
91
- return m.has(f) ? m.delete(f) : (t || m.clear(), m.add(f)), m;
90
+ const [r, n] = S(() => new Set(c)), o = a((h) => {
91
+ n((b) => {
92
+ const u = new Set(b);
93
+ return u.has(h) ? u.delete(h) : (t || u.clear(), u.add(h)), u;
92
94
  });
93
- }, [t]), o = i((f) => {
94
- s((S) => {
95
- if (S.has(f)) return S;
96
- const m = t ? new Set(S) : /* @__PURE__ */ new Set();
97
- return m.add(f), m;
95
+ }, [t]), s = a((h) => {
96
+ n((b) => {
97
+ if (b.has(h)) return b;
98
+ const u = t ? new Set(b) : /* @__PURE__ */ new Set();
99
+ return u.add(h), u;
98
100
  });
99
- }, [t]), u = i((f) => {
100
- s((S) => {
101
- if (!S.has(f)) return S;
102
- const m = new Set(S);
103
- return m.delete(f), m;
101
+ }, [t]), l = a((h) => {
102
+ n((b) => {
103
+ if (!b.has(h)) return b;
104
+ const u = new Set(b);
105
+ return u.delete(h), u;
104
106
  });
105
- }, []), w = i(() => {
106
- t && s(new Set(e));
107
- }, [e, t]), l = i(() => s(/* @__PURE__ */ new Set()), []), a = i(() => {
108
- s((f) => e.every((m) => f.has(m)) ? /* @__PURE__ */ new Set() : new Set(e));
109
- }, [e]), h = e.length > 0 && e.every((f) => n.has(f)), y = e.some((f) => n.has(f)), p = O(() => Array.from(n), [n]);
107
+ }, []), m = a(() => {
108
+ t && n(new Set(e));
109
+ }, [e, t]), i = a(() => n(/* @__PURE__ */ new Set()), []), d = a(() => {
110
+ n((h) => e.every((u) => h.has(u)) ? /* @__PURE__ */ new Set() : new Set(e));
111
+ }, [e]), p = e.length > 0 && e.every((h) => r.has(h)), I = e.some((h) => r.has(h)), w = X(() => Array.from(r), [r]);
110
112
  return {
111
- selected: n,
112
- isSelected: i((f) => n.has(f), [n]),
113
- toggle: c,
114
- select: o,
115
- deselect: u,
116
- selectAll: w,
117
- deselectAll: l,
118
- toggleAll: a,
119
- allSelected: h,
120
- someSelected: y,
121
- selectedCount: n.size,
122
- selectedArray: p
113
+ selected: r,
114
+ isSelected: a((h) => r.has(h), [r]),
115
+ toggle: o,
116
+ select: s,
117
+ deselect: l,
118
+ selectAll: m,
119
+ deselectAll: i,
120
+ toggleAll: d,
121
+ allSelected: p,
122
+ someSelected: I,
123
+ selectedCount: r.size,
124
+ selectedArray: w
123
125
  };
124
126
  }
125
- function F(e, r) {
126
- const [t, n] = g(e);
127
- return x(() => {
128
- const s = setTimeout(() => n(e), r);
129
- return () => clearTimeout(s);
130
- }, [e, r]), t;
127
+ function ne(e, c) {
128
+ const [t, r] = S(e);
129
+ return z(() => {
130
+ const n = setTimeout(() => r(e), c);
131
+ return () => clearTimeout(n);
132
+ }, [e, c]), t;
131
133
  }
132
- function j(e, r) {
133
- const [t, n] = g(e), s = A(Date.now());
134
- return x(() => {
135
- const c = Date.now(), o = r - (c - s.current);
136
- if (o <= 0)
137
- s.current = c, n(e);
134
+ function re(e, c) {
135
+ const [t, r] = S(e), n = g(Date.now());
136
+ return z(() => {
137
+ const o = Date.now(), s = c - (o - n.current);
138
+ if (s <= 0)
139
+ n.current = o, r(e);
138
140
  else {
139
- const u = setTimeout(() => {
140
- s.current = Date.now(), n(e);
141
- }, o);
142
- return () => clearTimeout(u);
141
+ const l = setTimeout(() => {
142
+ n.current = Date.now(), r(e);
143
+ }, s);
144
+ return () => clearTimeout(l);
143
145
  }
144
- }, [e, r]), t;
146
+ }, [e, c]), t;
145
147
  }
146
- function C({
148
+ function ce({
147
149
  value: e,
148
- onChange: r,
150
+ onChange: c,
149
151
  defaultValue: t
150
152
  }) {
151
- const n = e !== void 0, [s, c] = g(t), o = A(r);
152
- o.current = r;
153
- const u = i(
154
- (w) => {
155
- var l;
156
- n || c(w), (l = o.current) == null || l.call(o, w);
153
+ const r = e !== void 0, [n, o] = S(t), s = g(c);
154
+ s.current = c;
155
+ const l = a(
156
+ (m) => {
157
+ var i;
158
+ r || o(m), (i = s.current) == null || i.call(s, m);
157
159
  },
158
- [n]
160
+ [r]
159
161
  );
160
- return [n ? e : s, u];
162
+ return [r ? e : n, l];
161
163
  }
162
- function R(e) {
163
- const [r, t] = g(() => typeof window > "u" ? !1 : window.matchMedia(e).matches);
164
- return x(() => {
164
+ function se(e) {
165
+ const [c, t] = S(() => typeof window > "u" ? !1 : window.matchMedia(e).matches);
166
+ return z(() => {
165
167
  if (typeof window > "u") return;
166
- const n = window.matchMedia(e);
167
- t(n.matches);
168
- const s = (c) => t(c.matches);
169
- return n.addEventListener("change", s), () => n.removeEventListener("change", s);
170
- }, [e]), r;
168
+ const r = window.matchMedia(e);
169
+ t(r.matches);
170
+ const n = (o) => t(o.matches);
171
+ return r.addEventListener("change", n), () => r.removeEventListener("change", n);
172
+ }, [e]), c;
171
173
  }
172
- function M(e, r) {
173
- const [t, n] = g(() => {
174
- if (typeof window > "u") return r;
174
+ function oe(e, c) {
175
+ const [t, r] = S(() => {
176
+ if (typeof window > "u") return c;
175
177
  try {
176
- const o = window.localStorage.getItem(e);
177
- return o !== null ? JSON.parse(o) : r;
178
+ const s = window.localStorage.getItem(e);
179
+ return s !== null ? JSON.parse(s) : c;
178
180
  } catch {
179
- return r;
181
+ return c;
180
182
  }
181
- }), s = i(
182
- (o) => {
183
- n((u) => {
184
- const w = typeof o == "function" ? o(u) : o;
183
+ }), n = a(
184
+ (s) => {
185
+ r((l) => {
186
+ const m = typeof s == "function" ? s(l) : s;
185
187
  if (typeof window < "u")
186
188
  try {
187
- window.localStorage.setItem(e, JSON.stringify(w));
189
+ window.localStorage.setItem(e, JSON.stringify(m));
188
190
  } catch {
189
191
  }
190
- return w;
192
+ return m;
191
193
  });
192
194
  },
193
195
  [e]
194
- ), c = i(() => {
195
- if (n(r), typeof window < "u")
196
+ ), o = a(() => {
197
+ if (r(c), typeof window < "u")
196
198
  try {
197
199
  window.localStorage.removeItem(e);
198
200
  } catch {
199
201
  }
200
- }, [e, r]);
201
- return [t, s, c];
202
+ }, [e, c]);
203
+ return [t, n, o];
202
204
  }
203
- function z({
205
+ function ue({
204
206
  threshold: e = 0,
205
- rootMargin: r = "0px",
207
+ rootMargin: c = "0px",
206
208
  root: t = null,
207
- once: n = !1
209
+ once: r = !1
208
210
  } = {}) {
209
- const s = A(null), [c, o] = g(null), u = A(null);
210
- return x(() => {
211
- const w = s.current;
212
- if (!(!w || typeof IntersectionObserver > "u"))
213
- return u.current = new IntersectionObserver(
214
- ([l]) => {
215
- var a;
216
- o(l), n && l.isIntersecting && ((a = u.current) == null || a.unobserve(w));
211
+ const n = g(null), [o, s] = S(null), l = g(null);
212
+ return z(() => {
213
+ const m = n.current;
214
+ if (!(!m || typeof IntersectionObserver > "u"))
215
+ return l.current = new IntersectionObserver(
216
+ ([i]) => {
217
+ var d;
218
+ s(i), r && i.isIntersecting && ((d = l.current) == null || d.unobserve(m));
217
219
  },
218
- { threshold: e, rootMargin: r, root: t }
219
- ), u.current.observe(w), () => {
220
- var l;
221
- return (l = u.current) == null ? void 0 : l.disconnect();
220
+ { threshold: e, rootMargin: c, root: t }
221
+ ), l.current.observe(m), () => {
222
+ var i;
223
+ return (i = l.current) == null ? void 0 : i.disconnect();
222
224
  };
223
- }, [e, r, t, n]), { ref: s, isIntersecting: (c == null ? void 0 : c.isIntersecting) ?? !1, entry: c };
225
+ }, [e, c, t, r]), { ref: n, isIntersecting: (o == null ? void 0 : o.isIntersecting) ?? !1, entry: o };
226
+ }
227
+ function ae(e) {
228
+ const {
229
+ url: c,
230
+ protocols: t,
231
+ reconnect: r = !0,
232
+ reconnectDelay: n = 1e3,
233
+ reconnectAttempts: o = 10,
234
+ heartbeatInterval: s = 3e4,
235
+ heartbeatMessage: l = "ping",
236
+ onOpen: m,
237
+ onClose: i,
238
+ onError: d,
239
+ onMessage: p
240
+ } = e, [I, w] = S("disconnected"), [h, b] = S(null), [u, f] = S([]), [y, T] = S(0), [A, V] = S(null), v = g(null), k = g(0), j = g(null), F = g(null), P = g(null), O = g([]), E = g(!0), C = g(!1), x = g(m), L = g(i), N = g(d), W = g(p);
241
+ x.current = m, L.current = i, N.current = d, W.current = p;
242
+ const q = a(() => {
243
+ j.current && (clearTimeout(j.current), j.current = null), F.current && (clearInterval(F.current), F.current = null);
244
+ }, []), U = a((R) => {
245
+ for (; O.current.length > 0; ) {
246
+ const M = O.current.shift();
247
+ M !== void 0 && R.send(typeof M == "string" ? M : JSON.stringify(M));
248
+ }
249
+ }, []), Q = a(() => {
250
+ if (v.current && v.current.readyState === WebSocket.OPEN) return;
251
+ C.current = !1, q(), E.current && w("connecting");
252
+ const R = new WebSocket(c, t);
253
+ v.current = R, R.onopen = (M) => {
254
+ var D;
255
+ E.current && (w("connected"), k.current = 0, T(0), (D = x.current) == null || D.call(x, M), U(R), F.current = setInterval(() => {
256
+ if (R.readyState === WebSocket.OPEN) {
257
+ P.current = Date.now();
258
+ try {
259
+ R.send(JSON.stringify({ type: "ping", t: P.current }));
260
+ } catch {
261
+ }
262
+ }
263
+ }, s));
264
+ }, R.onmessage = (M) => {
265
+ var H;
266
+ if (!E.current) return;
267
+ let D;
268
+ try {
269
+ D = JSON.parse(M.data);
270
+ } catch {
271
+ D = M.data;
272
+ }
273
+ const J = D;
274
+ if (J && typeof J == "object" && J.type === "pong" && typeof J.t == "number") {
275
+ V(Date.now() - J.t);
276
+ return;
277
+ }
278
+ if (D === l && P.current !== null) {
279
+ V(Date.now() - P.current), P.current = null;
280
+ return;
281
+ }
282
+ b(D), f((G) => {
283
+ const K = [...G, D];
284
+ return K.length > 100 ? K.slice(K.length - 100) : K;
285
+ }), (H = W.current) == null || H.call(W, D);
286
+ }, R.onerror = (M) => {
287
+ var D;
288
+ E.current && (w("error"), (D = N.current) == null || D.call(N, M));
289
+ }, R.onclose = (M) => {
290
+ var D;
291
+ if (E.current && (q(), w("disconnected"), (D = L.current) == null || D.call(L, M), !C.current && r && k.current < o)) {
292
+ const J = k.current, H = n * Math.pow(1.5, J);
293
+ k.current += 1, T(k.current), j.current = setTimeout(() => {
294
+ E.current && Q();
295
+ }, H);
296
+ }
297
+ };
298
+ }, [c, t, r, n, o, s, l, q, U]), B = a(() => {
299
+ C.current = !0, q(), v.current && (v.current.close(), v.current = null), E.current && w("disconnected");
300
+ }, [q]), $ = a((R) => {
301
+ v.current && v.current.readyState === WebSocket.OPEN ? v.current.send(typeof R == "string" ? R : JSON.stringify(R)) : O.current.push(R);
302
+ }, []);
303
+ return z(() => (E.current = !0, Q(), () => {
304
+ E.current = !1, C.current = !0, q(), v.current && (v.current.close(), v.current = null);
305
+ }), []), { status: I, lastMessage: h, messages: u, send: $, connect: Q, disconnect: B, reconnectCount: y, latency: A };
306
+ }
307
+ function le(e) {
308
+ const {
309
+ url: c,
310
+ events: t = ["message"],
311
+ withCredentials: r = !1,
312
+ reconnect: n = !0,
313
+ reconnectDelay: o = 3e3,
314
+ onOpen: s,
315
+ onError: l
316
+ } = e, [m, i] = S("connecting"), [d, p] = S(null), [I, w] = S([]), [h, b] = S(0), u = g(null), f = g(null), y = g(!0), T = g(!1), A = g(s), V = g(l);
317
+ A.current = s, V.current = l;
318
+ const v = a(() => {
319
+ f.current && (clearTimeout(f.current), f.current = null);
320
+ }, []), k = a(() => {
321
+ if (typeof EventSource > "u") {
322
+ y.current && i("error");
323
+ return;
324
+ }
325
+ T.current = !1, v(), u.current && (u.current.close(), u.current = null), y.current && i("connecting");
326
+ const F = new EventSource(c, { withCredentials: r });
327
+ u.current = F, F.onopen = () => {
328
+ var O;
329
+ y.current && (i("connected"), (O = A.current) == null || O.call(A));
330
+ }, F.onerror = (O) => {
331
+ var E;
332
+ y.current && (i("error"), (E = V.current) == null || E.call(V, O), !T.current && n && (v(), f.current = setTimeout(() => {
333
+ y.current && k();
334
+ }, o)));
335
+ };
336
+ const P = (O) => (E) => {
337
+ if (!y.current) return;
338
+ let C;
339
+ try {
340
+ C = JSON.parse(E.data);
341
+ } catch {
342
+ C = E.data;
343
+ }
344
+ const x = {
345
+ type: O,
346
+ data: C,
347
+ timestamp: Date.now(),
348
+ ...E.lastEventId ? { id: E.lastEventId } : {}
349
+ };
350
+ p({ type: x.type, data: x.data, id: x.id }), w((L) => {
351
+ const N = [...L, x];
352
+ return N.length > 200 ? N.slice(N.length - 200) : N;
353
+ }), b((L) => L + 1);
354
+ };
355
+ for (const O of t)
356
+ F.addEventListener(O, P(O));
357
+ }, [c, r, n, o, v]), j = a(() => {
358
+ T.current = !0, v(), u.current && (u.current.close(), u.current = null), y.current && i("closed");
359
+ }, [v]);
360
+ return z(() => (y.current = !0, k(), () => {
361
+ y.current = !1, T.current = !0, v(), u.current && (u.current.close(), u.current = null);
362
+ }), []), {
363
+ status: m,
364
+ lastEvent: d,
365
+ events: I,
366
+ connect: k,
367
+ disconnect: j,
368
+ eventCount: h
369
+ };
370
+ }
371
+ function ie(e) {
372
+ const {
373
+ queryFn: c,
374
+ initialCursor: t = null,
375
+ enabled: r = !0,
376
+ dedupKey: n
377
+ } = e, [o, s] = S([]), [l, m] = S("idle"), [i, d] = S(null), [p, I] = S(!1), [w, h] = S(0), b = g(t ?? null), u = g(!1), f = g(!0), y = g(void 0), T = g(c);
378
+ T.current = c;
379
+ const A = a(
380
+ async (P, O, E) => {
381
+ if (u.current || n !== void 0 && n === y.current) return;
382
+ u.current = !0;
383
+ let C = !1;
384
+ f.current && (m(E ? "loading" : "fetching-more"), d(null));
385
+ try {
386
+ const x = await T.current(P, O);
387
+ if (C || !f.current) return;
388
+ n !== void 0 && (y.current = n), b.current = x.nextCursor, s((L) => E ? [x.data] : [...L, x.data]), I(x.hasMore), h(O), m("success");
389
+ } catch (x) {
390
+ if (C || !f.current) return;
391
+ d(x instanceof Error ? x : new Error(String(x))), m("error");
392
+ } finally {
393
+ C || (u.current = !1);
394
+ }
395
+ return () => {
396
+ C = !0;
397
+ };
398
+ },
399
+ // dedupKey intentionally included to allow re-checking on each call
400
+ [n]
401
+ ), V = a(() => {
402
+ !p || u.current || A(b.current, w + 1, !1);
403
+ }, [p, w, A]), v = a(() => {
404
+ u.current = !1, y.current = void 0, b.current = t ?? null, s([]), m("idle"), d(null), I(!1), h(0);
405
+ }, [t]);
406
+ z(() => (f.current = !0, r && A(t ?? null, 0, !0), () => {
407
+ f.current = !1;
408
+ }), [r]);
409
+ const k = o.flat(), j = l === "fetching-more", F = k.length;
410
+ return {
411
+ data: k,
412
+ pages: o,
413
+ status: l,
414
+ error: i,
415
+ hasMore: p,
416
+ isFetchingMore: j,
417
+ fetchMore: V,
418
+ reset: v,
419
+ pageIndex: w,
420
+ totalLoaded: F
421
+ };
224
422
  }
225
423
  export {
226
- te as contrastRatio,
227
- ne as cssVar,
228
- q as cx,
229
- H as extractAtomicCSS,
230
- se as extractCSS,
231
- re as injectStyles,
232
- oe as meetsAA,
233
- ce as meetsAAA,
234
- J as resetAtomicCSS,
235
- ue as resetStyles,
236
- K as sanitizeProps,
237
- N as sanitizeString,
238
- U as tkxListPlugins,
239
- B as tkxPlugin,
240
- Q as tkxRemovePlugin,
241
- $ as useAnnounce,
242
- G as useClickOutside,
243
- C as useControllable,
244
- F as useDebounce,
245
- k as useDisclosure,
246
- W as useEscapeKey,
247
- X as useFocusTrap,
248
- T as useFormState,
249
- Y as useHighContrast,
250
- z as useIntersectionObserver,
251
- E as useListSelection,
252
- M as useLocalStorage,
253
- R as useMediaQuery,
254
- Z as useReducedMotion,
255
- V as useRovingTabIndex,
256
- j as useThrottle,
257
- _ as useTkxForm
424
+ Te as contrastRatio,
425
+ Ae as cssVar,
426
+ be as cx,
427
+ Ee as extractAtomicCSS,
428
+ Ce as extractCSS,
429
+ Me as injectStyles,
430
+ ke as meetsAA,
431
+ Fe as meetsAAA,
432
+ xe as resetAtomicCSS,
433
+ Le as resetStyles,
434
+ Pe as sanitizeProps,
435
+ Ne as sanitizeString,
436
+ Ie as tkxListPlugins,
437
+ Oe as tkxPlugin,
438
+ De as tkxRemovePlugin,
439
+ ge as useAnnounce,
440
+ me as useClickOutside,
441
+ ce as useControllable,
442
+ ne as useDebounce,
443
+ Z as useDisclosure,
444
+ he as useEscapeKey,
445
+ ye as useFocusTrap,
446
+ ee as useFormState,
447
+ Se as useHighContrast,
448
+ ie as useInfiniteQuery,
449
+ ue as useIntersectionObserver,
450
+ te as useListSelection,
451
+ oe as useLocalStorage,
452
+ se as useMediaQuery,
453
+ pe as useReducedMotion,
454
+ _ as useRovingTabIndex,
455
+ le as useSSE,
456
+ re as useThrottle,
457
+ we as useTkxForm,
458
+ ae as useWebSocket
258
459
  };