vuesp-components 5.3.4 → 5.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.
@@ -1,134 +1,134 @@
1
- import { ref as d, reactive as Q, watch as ue, computed as F, onMounted as ot, onBeforeUnmount as lt } from "vue";
2
- import { u as St, b as bt, a as kt } from "../useDialog-Buvn63AR.js";
3
- function pt(o) {
4
- const { validationSchema: u, initialValues: p = {} } = o, w = typeof u == "function", b = d(
5
- w ? u(p) : u
6
- ), L = d(!0), j = (r) => {
7
- b.value = r;
8
- const l = Object.keys(r), v = Object.keys(i);
9
- l.forEach((a) => {
10
- a in i || (i[a] = p[a] ?? "", x[a] = [], T[a] = !1, k[a] = !1);
11
- }), v.forEach((a) => {
12
- l.includes(a) || (delete i[a], delete x[a], delete T[a], delete k[a]);
13
- }), M(), R();
14
- }, i = Q({}), x = Q({}), T = Q({}), k = Q({}), O = /* @__PURE__ */ new Map(), I = () => {
15
- Object.keys(b.value).forEach((r) => {
16
- i[r] = p[r] ?? "", x[r] = [], T[r] = !1, k[r] = !1;
1
+ import { ref as l, reactive as G, watch as oe, computed as U, onMounted as kt, onBeforeUnmount as bt } from "vue";
2
+ import { u as Mt, b as $t, a as Ct } from "../useDialog-Buvn63AR.js";
3
+ function It(c) {
4
+ const { validationSchema: i, initialValues: y = {} } = c, p = typeof i == "function", m = l(
5
+ p ? i(y) : i
6
+ ), L = l(!0), C = (s) => {
7
+ m.value = s;
8
+ const u = Object.keys(s), h = Object.keys(f);
9
+ u.forEach((a) => {
10
+ a in f || (f[a] = y[a] ?? "", g[a] = [], E[a] = !1, k[a] = !1);
11
+ }), h.forEach((a) => {
12
+ u.includes(a) || (delete f[a], delete g[a], delete E[a], delete k[a]);
13
+ }), W(), R();
14
+ }, f = G({}), g = G({}), E = G({}), k = G({}), O = /* @__PURE__ */ new Map(), q = () => {
15
+ Object.keys(m.value).forEach((s) => {
16
+ f[s] = y[s] ?? "", g[s] = [], E[s] = !1, k[s] = !1;
17
17
  }), L.value = !0;
18
- }, y = () => w ? u(i) : b.value, m = (r, l) => {
19
- const a = y()[r] || [], h = [];
20
- for (const S of a) {
21
- const g = S(l, i);
22
- g !== !0 && h.push(g);
18
+ }, b = () => p ? i(f) : m.value, _ = (s, u) => {
19
+ const a = b()[s] || [], v = [];
20
+ for (const w of a) {
21
+ const $ = w(u, f);
22
+ $ !== !0 && v.push($);
23
23
  }
24
- return x[r] = h, h.length === 0;
25
- }, U = (r, l) => {
26
- const v = y();
27
- if (!v[r]) return;
28
- m(r, l);
29
- const a = O.get(r);
30
- a && a.forEach((h) => {
31
- v[h] && m(h, i[h]);
24
+ return g[s] = v, v.length === 0;
25
+ }, T = (s, u) => {
26
+ const h = b();
27
+ if (!h[s]) return;
28
+ _(s, u);
29
+ const a = O.get(s);
30
+ a && a.forEach((v) => {
31
+ h[v] && _(v, f[v]);
32
32
  }), R();
33
- }, M = () => {
33
+ }, W = () => {
34
34
  O.clear();
35
- const r = y();
36
- Object.keys(r).forEach((l) => {
37
- (r[l] || []).forEach((a) => {
35
+ const s = b();
36
+ Object.keys(s).forEach((u) => {
37
+ (s[u] || []).forEach((a) => {
38
38
  if (typeof a == "function" && a.name === "sameAs") {
39
- const h = a.toString().match(/['"](.*?)['"]/);
40
- if (h) {
41
- const S = h[1];
42
- O.has(S) || O.set(S, /* @__PURE__ */ new Set()), O.get(S).add(l);
39
+ const v = a.toString().match(/['"](.*?)['"]/);
40
+ if (v) {
41
+ const w = v[1];
42
+ O.has(w) || O.set(w, /* @__PURE__ */ new Set()), O.get(w).add(u);
43
43
  }
44
44
  }
45
45
  });
46
46
  });
47
47
  }, R = () => {
48
- const r = y();
49
- let l = !0;
50
- return Object.keys(r).forEach((v) => {
51
- m(v, i[v]) || (l = !1);
52
- }), L.value = l, l;
53
- }, W = (r, l = {}) => {
54
- y()[r] || console.warn(`Field "${r}" not found in current validationSchema`);
55
- const a = F({
56
- get: () => i[r],
57
- set: (S) => {
58
- i[r] = S, k[r] = !0, U(r, S);
48
+ const s = b();
49
+ let u = !0;
50
+ return Object.keys(s).forEach((h) => {
51
+ _(h, f[h]) || (u = !1);
52
+ }), L.value = u, u;
53
+ }, j = (s, u = {}) => {
54
+ b()[s] || console.warn(`Field "${s}" not found in current validationSchema`);
55
+ const a = U({
56
+ get: () => f[s],
57
+ set: (w) => {
58
+ f[s] = w, k[s] = !0, T(s, w);
59
59
  }
60
- }), h = F(() => {
61
- var E;
62
- const S = {
63
- errors: x[r] || [],
64
- touched: T[r] || !1,
65
- dirty: k[r] || !1
66
- }, g = {
67
- message: (E = x[r]) == null ? void 0 : E[0],
60
+ }), v = U(() => {
61
+ var P;
62
+ const w = {
63
+ errors: g[s] || [],
64
+ touched: E[s] || !1,
65
+ dirty: k[s] || !1
66
+ }, $ = {
67
+ message: (P = g[s]) == null ? void 0 : P[0],
68
68
  onInput: (A) => {
69
- const C = A.target;
70
- a.value = C.value;
69
+ const Q = A.target;
70
+ a.value = Q.value;
71
71
  },
72
72
  onBlur: () => {
73
- T[r] = !0, U(r, i[r]);
73
+ E[s] = !0, T(s, f[s]);
74
74
  }
75
75
  };
76
- if (l.props) {
77
- const A = l.props(S);
78
- return { ...g, ...A };
76
+ if (u.props) {
77
+ const A = u.props(w);
78
+ return { ...$, ...A };
79
79
  }
80
- return g;
80
+ return $;
81
81
  });
82
- return [a, h];
83
- }, Y = (r) => async (l) => {
84
- l && l.preventDefault();
85
- const v = y();
86
- Object.keys(v).forEach((h) => {
87
- T[h] = !0;
88
- }), R() && await r(i);
89
- }, Z = () => {
90
- const r = y();
91
- Object.keys(r).forEach((l) => {
92
- i[l] = p[l] || "", x[l] = [], T[l] = !1, k[l] = !1;
82
+ return [a, v];
83
+ }, M = (s) => async (u) => {
84
+ u && u.preventDefault();
85
+ const h = b();
86
+ Object.keys(h).forEach((v) => {
87
+ E[v] = !0;
88
+ }), R() && await s(f);
89
+ }, x = () => {
90
+ const s = b();
91
+ Object.keys(s).forEach((u) => {
92
+ f[u] = y[u] || "", g[u] = [], E[u] = !1, k[u] = !1;
93
93
  }), L.value = !0;
94
94
  };
95
- return I(), M(), w && ue(
96
- () => i,
95
+ return q(), W(), p && oe(
96
+ () => f,
97
97
  () => {
98
- const r = u(i), l = b.value, v = Object.keys(r), a = Object.keys(l);
99
- (v.length !== a.length || v.some((h) => !a.includes(h))) && j(r);
98
+ const s = i(f), u = m.value, h = Object.keys(s), a = Object.keys(u);
99
+ (h.length !== a.length || h.some((v) => !a.includes(v))) && C(s);
100
100
  },
101
101
  { deep: !0 }
102
102
  ), {
103
- values: i,
104
- errors: x,
105
- defineField: W,
106
- handleSubmit: Y,
107
- resetForm: Z,
103
+ values: f,
104
+ errors: g,
105
+ defineField: j,
106
+ handleSubmit: M,
107
+ resetForm: x,
108
108
  validate: R,
109
- updateSchema: j,
109
+ updateSchema: C,
110
110
  isValid: L
111
111
  };
112
112
  }
113
- const ut = 150, it = 4096, Re = 256 * 1024, Le = 12, ft = 1200, dt = { utf8: "utf-8", cp1251: "windows-1251" }, ht = {
113
+ const Et = 150, Tt = 4096, $e = 256 * 1024, Ce = 12, Rt = 1200, Bt = { utf8: "utf-8", cp1251: "windows-1251" }, Lt = {
114
114
  encoding: "utf8",
115
115
  framing: "line",
116
116
  gapMs: 25,
117
117
  paused: !1
118
- }, vt = (o, u) => (
118
+ }, Ot = (c, i) => (
119
119
  // eslint-disable-next-line no-control-regex
120
- new TextDecoder(dt[u]).decode(o).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
121
- ), yt = (o) => Array.from(o, (u) => u.toString(16).padStart(2, "0")).join(" ");
122
- function mt(o) {
123
- var be, ke;
124
- const u = d([]), p = Q({ ...ht }), w = d(0), b = d(0), L = d(0), j = d(0), i = d(""), x = d(!1), T = d(!1), k = d(!1), O = d(1e3), I = d(((be = o.initialLineEnding) == null ? void 0 : be.call(o)) ?? "crlf"), y = d([]), m = d(-1), U = d(""), M = d("text"), R = d(null), W = d(!0), Y = d(!0), Z = d(!0), r = d(!1), l = d(!1), v = d(!1), a = d([]), h = d("");
125
- let S = 0, g = [], E = [], A = null, C = null, V = null, $ = null, H = null, N = "", _ = null, ee = 0, te = 0, X = 0, D = null;
126
- const ie = (e) => {
120
+ new TextDecoder(Bt[i]).decode(c).replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, ".")
121
+ ), At = (c) => Array.from(c, (i) => i.toString(16).padStart(2, "0")).join(" ");
122
+ function Ft(c) {
123
+ var Fe, Ue;
124
+ const i = l([]), y = G({ ...Lt }), p = l(0), m = l(0), L = l(0), C = l(0), f = l(""), g = l(!1), E = l(!1), k = l(!1), O = l(1e3), q = l("all"), b = l(!1), _ = l(!1), T = l([]), W = l(!1), R = l(""), j = l(!1), M = l(((Fe = c.initialLineEnding) == null ? void 0 : Fe.call(c)) ?? "crlf"), x = l([]), s = l(-1), u = l(""), h = l("text"), a = l(null), v = l(!0), w = l(!0), $ = l(!0), P = l(!1), A = l(!1), Q = l(!1), B = l([]), ce = l("");
125
+ let xe = 0, S = [], D = [], Y = null, le = null, Z = null, V = null, N = null, H = !1, ue = "", X = null, ie = 0, fe = 0, ee = 0, I = null;
126
+ const we = (e) => {
127
127
  var n;
128
- const t = (n = o.storageKey) == null ? void 0 : n.call(o);
128
+ const t = (n = c.storageKey) == null ? void 0 : n.call(c);
129
129
  return t ? `${t}:${e}` : null;
130
- }, fe = (e) => {
131
- const t = ie(e);
130
+ }, de = (e) => {
131
+ const t = we(e);
132
132
  if (!t || typeof localStorage > "u") return null;
133
133
  try {
134
134
  const n = localStorage.getItem(t);
@@ -136,350 +136,398 @@ function mt(o) {
136
136
  } catch {
137
137
  return null;
138
138
  }
139
- }, ne = (e, t) => {
140
- const n = ie(e);
139
+ }, te = (e, t) => {
140
+ const n = we(e);
141
141
  if (!(!n || typeof localStorage > "u"))
142
142
  try {
143
143
  localStorage.setItem(n, JSON.stringify(t));
144
144
  } catch {
145
145
  }
146
- }, de = fe("view");
147
- de && Object.assign(p, de, { paused: !1 }), p.paused = !1;
148
- const Oe = fe("quick"), Ae = ((ke = o.initialQuickCommands) == null ? void 0 : ke.call(o)) ?? [];
149
- a.value = (Oe ?? Ae).filter((e) => typeof e == "string").slice(0, Le), ue(p, () => ne("view", { ...p, paused: !1 }), { deep: !0 });
150
- const De = "vuesp-serial", B = "sessions", J = () => {
146
+ }, Se = de("view");
147
+ Se && Object.assign(y, Se, { paused: !1 }), y.paused = !1;
148
+ const ke = de("scenario");
149
+ typeof ke == "string" && (R.value = ke);
150
+ const _e = de("quick"), Pe = ((Ue = c.initialQuickCommands) == null ? void 0 : Ue.call(c)) ?? [];
151
+ B.value = (_e ?? Pe).filter((e) => typeof e == "string").slice(0, Ce), oe(y, () => te("view", { ...y, paused: !1 }), { deep: !0 });
152
+ const Ke = "vuesp-serial", F = "sessions", ne = () => {
151
153
  var t, n;
152
- const e = (t = o.storageKey) == null ? void 0 : t.call(o);
153
- return (n = o.session) != null && n.call(o) && e ? `${e}:session` : null;
154
- }, re = () => new Promise((e, t) => {
155
- const n = indexedDB.open(De, 1);
154
+ const e = (t = c.storageKey) == null ? void 0 : t.call(c);
155
+ return (n = c.session) != null && n.call(c) && e ? `${e}:session` : null;
156
+ }, he = () => new Promise((e, t) => {
157
+ const n = indexedDB.open(Ke, 1);
156
158
  n.onupgradeneeded = () => {
157
- n.result.objectStoreNames.contains(B) || n.result.createObjectStore(B);
159
+ n.result.objectStoreNames.contains(F) || n.result.createObjectStore(F);
158
160
  }, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
159
- }), Be = async (e) => {
161
+ }), qe = async (e) => {
160
162
  if (typeof indexedDB > "u") return null;
161
- const t = await re();
162
- return new Promise((n, s) => {
163
- const c = t.transaction(B, "readonly").objectStore(B).get(e);
164
- c.onsuccess = () => n(c.result ?? null), c.onerror = () => s(c.error);
163
+ const t = await he();
164
+ return new Promise((n, r) => {
165
+ const o = t.transaction(F, "readonly").objectStore(F).get(e);
166
+ o.onsuccess = () => n(o.result ?? null), o.onerror = () => r(o.error);
165
167
  });
166
- }, Fe = async (e, t) => {
168
+ }, Qe = async (e, t) => {
167
169
  if (typeof indexedDB > "u") return;
168
- const n = await re();
169
- await new Promise((s, c) => {
170
- const f = n.transaction(B, "readwrite").objectStore(B).put(t, e);
171
- f.onsuccess = () => s(), f.onerror = () => c(f.error);
170
+ const n = await he();
171
+ await new Promise((r, o) => {
172
+ const d = n.transaction(F, "readwrite").objectStore(F).put(t, e);
173
+ d.onsuccess = () => r(), d.onerror = () => o(d.error);
172
174
  });
173
- }, Ie = async (e) => {
175
+ }, Ve = async (e) => {
174
176
  if (typeof indexedDB > "u") return;
175
- const t = await re();
176
- await new Promise((n, s) => {
177
- const c = t.transaction(B, "readwrite").objectStore(B).delete(e);
178
- c.onsuccess = () => n(), c.onerror = () => s(c.error);
177
+ const t = await he();
178
+ await new Promise((n, r) => {
179
+ const o = t.transaction(F, "readwrite").objectStore(F).delete(e);
180
+ o.onsuccess = () => n(), o.onerror = () => r(o.error);
179
181
  });
180
- }, je = () => {
181
- const e = J();
182
- e && ($ && clearTimeout($), $ = setTimeout(() => {
182
+ }, He = () => {
183
+ const e = ne();
184
+ e && (V && clearTimeout(V), V = setTimeout(() => {
183
185
  const t = {
184
- lines: u.value.map((n) => ({ ...n, data: n.data ? [...n.data] : void 0 })),
185
- rxBytes: w.value,
186
- txBytes: b.value
186
+ lines: i.value.map((n) => ({ ...n, data: n.data ? [...n.data] : void 0 })),
187
+ rxBytes: p.value,
188
+ txBytes: m.value
187
189
  };
188
- Fe(e, t).catch(() => {
190
+ Qe(e, t).catch(() => {
189
191
  });
190
192
  }, 800));
191
- }, Ue = async () => {
193
+ }, Xe = async () => {
192
194
  var t;
193
- const e = J();
194
- if (!(!e || u.value.length))
195
+ const e = ne();
196
+ if (!(!e || i.value.length))
195
197
  try {
196
- const n = await Be(e);
198
+ const n = await qe(e);
197
199
  if (!((t = n == null ? void 0 : n.lines) != null && t.length)) return;
198
- u.value = n.lines, S = n.lines.reduce((s, c) => Math.max(s, c.id), 0), w.value = n.rxBytes ?? 0, b.value = n.txBytes ?? 0, v.value = !0;
200
+ i.value = n.lines, xe = n.lines.reduce((r, o) => Math.max(r, o.id), 0), p.value = n.rxBytes ?? 0, m.value = n.txBytes ?? 0, Q.value = !0;
199
201
  } catch {
200
202
  }
201
- }, se = (e, t) => {
202
- const n = vt(t, p.encoding);
203
- u.value.push({
204
- id: ++S,
203
+ }, ve = (e, t) => {
204
+ const n = Ot(t, y.encoding);
205
+ i.value.push({
206
+ id: ++xe,
205
207
  dir: e,
206
- at: (/* @__PURE__ */ new Date()).toLocaleTimeString(o.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
207
- text: p.framing === "gap" ? n.replace(/[\r\n]+/g, " ") : n,
208
- hex: yt(t),
208
+ at: (/* @__PURE__ */ new Date()).toLocaleTimeString(c.locale() === "ru" ? "ru-RU" : "en-GB", { hour12: !1 }),
209
+ text: y.framing === "gap" ? n.replace(/[\r\n]+/g, " ") : n,
210
+ hex: At(t),
209
211
  bytes: t.length,
210
212
  // Keep a bounded copy for the binary view and byte inspector.
211
213
  data: Array.from(t.slice(0, 1024))
212
214
  });
213
- const s = o.maxLines();
214
- u.value.length > s && u.value.splice(0, u.value.length - s), je();
215
- }, z = () => {
216
- A && (clearTimeout(A), A = null);
217
- }, he = () => {
218
- if (z(), !g.length) return;
219
- const e = new Uint8Array(g);
220
- g = [], se("rx", e);
221
- }, Me = () => {
222
- z();
223
- const e = p.framing === "gap" ? Math.max(5, p.gapMs) : ut;
224
- A = setTimeout(he, e);
225
- }, ve = (e) => {
226
- for (const t of e) g.push(t);
227
- if (p.framing === "line") {
215
+ const r = c.maxLines();
216
+ i.value.length > r && i.value.splice(0, i.value.length - r), He();
217
+ }, se = () => {
218
+ Y && (clearTimeout(Y), Y = null);
219
+ }, be = () => {
220
+ if (se(), !S.length) return;
221
+ const e = new Uint8Array(S);
222
+ S = [], ve("rx", e);
223
+ }, Je = () => {
224
+ se();
225
+ const e = y.framing === "gap" ? Math.max(5, y.gapMs) : Et;
226
+ Y = setTimeout(be, e);
227
+ }, Ee = (e) => {
228
+ for (const t of e) S.push(t);
229
+ if (y.framing === "line") {
228
230
  let t = 0;
229
- for (let n = 0; n < g.length; n++) {
230
- const s = g[n];
231
- if (s !== 10 && s !== 13) continue;
232
- const c = g.slice(t, n);
233
- c.length && se("rx", new Uint8Array(c)), s === 13 && g[n + 1] === 10 && n++, t = n + 1;
231
+ for (let n = 0; n < S.length; n++) {
232
+ const r = S[n];
233
+ if (r !== 10 && r !== 13) continue;
234
+ const o = S.slice(t, n);
235
+ o.length && ve("rx", new Uint8Array(o)), r === 13 && S[n + 1] === 10 && n++, t = n + 1;
234
236
  }
235
- t && (g = g.slice(t));
237
+ t && (S = S.slice(t));
236
238
  }
237
- g.length >= it ? he() : Me();
238
- }, q = () => {
239
- V && clearTimeout(V), V = null, l.value = !1;
240
- }, Ce = (e) => {
239
+ S.length >= Tt ? be() : Je();
240
+ }, J = () => {
241
+ Z && clearTimeout(Z), Z = null, A.value = !1;
242
+ }, ze = (e) => {
241
243
  var n;
242
- const t = (n = o.noReplyHint) == null ? void 0 : n.call(o);
243
- t && (q(), V = setTimeout(() => {
244
- w.value === e && (l.value = !0);
244
+ const t = (n = c.noReplyHint) == null ? void 0 : n.call(c);
245
+ t && (J(), Z = setTimeout(() => {
246
+ p.value === e && (A.value = !0);
245
247
  }, t.delay ?? 1500));
246
- }, $e = (e) => {
248
+ }, Ge = (e) => {
247
249
  if (e != null && e.length) {
248
- if (l.value && q(), w.value += e.length, p.paused) {
249
- for (const t of e) E.push(t);
250
- E.length > Re && E.splice(0, E.length - Re);
250
+ if (A.value && J(), p.value += e.length, y.paused) {
251
+ for (const t of e) D.push(t);
252
+ D.length > $e && D.splice(0, D.length - $e);
251
253
  return;
252
254
  }
253
- ve(e);
255
+ Ee(e);
254
256
  }
255
- }, _e = () => {
256
- D == null || D(), D = o.transport().subscribe($e);
257
+ }, We = () => {
258
+ I == null || I(), I = c.transport().subscribe(Ge);
257
259
  };
258
- ue(
259
- () => p.paused,
260
+ oe(
261
+ () => y.paused,
260
262
  (e) => {
261
- if (e || !E.length) return;
262
- const t = new Uint8Array(E);
263
- E = [], ve(t);
263
+ if (e || !D.length) return;
264
+ const t = new Uint8Array(D);
265
+ D = [], Ee(t);
264
266
  }
265
267
  );
266
268
  const K = async (e) => {
267
- const t = await o.transport().send(e);
268
- return t && (b.value += e.length, se("tx", e)), t;
269
- }, ae = F(() => i.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), qe = F(() => {
270
- const e = i.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
269
+ const t = await c.transport().send(e);
270
+ return t && (m.value += e.length, ve("tx", e)), t;
271
+ }, ye = U(() => f.value.replace(/^0x/i, "").replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "")), Ye = U(() => {
272
+ const e = f.value.replace(/0x/gi, "").replace(/[\s,;:]/g, "");
271
273
  return e.length > 0 && /[^0-9a-fA-F]/.test(e);
272
- }), ye = F(() => {
273
- const e = ae.value, t = [];
274
+ }), Te = U(() => {
275
+ const e = ye.value, t = [];
274
276
  for (let n = 0; n + 1 < e.length; n += 2) t.push(parseInt(e.slice(n, n + 2), 16));
275
277
  return t;
276
- }), ge = F(() => x.value ? qe.value ? o.labels().hexInvalid : ae.value && ae.value.length % 2 ? o.labels().hexOdd : "" : ""), Ke = (e) => {
278
+ }), Re = U(() => g.value ? Ye.value ? c.labels().hexInvalid : ye.value && ye.value.length % 2 ? c.labels().hexOdd : "" : ""), Ze = (e) => {
277
279
  const t = new TextEncoder(), n = [];
278
- let s = "";
279
- const c = () => {
280
- s && (n.push(...t.encode(s)), s = "");
280
+ let r = "";
281
+ const o = () => {
282
+ r && (n.push(...t.encode(r)), r = "");
281
283
  };
282
- for (let f = 0; f < e.length; f++) {
283
- const le = e[f];
284
- if (le !== "\\") {
285
- s += le;
284
+ for (let d = 0; d < e.length; d++) {
285
+ const me = e[d];
286
+ if (me !== "\\") {
287
+ r += me;
286
288
  continue;
287
289
  }
288
- const P = e[f + 1], Ee = e.slice(f + 2, f + 4);
289
- if ((P === "x" || P === "X") && /^[0-9a-fA-F]{2}$/.test(Ee)) {
290
- c(), n.push(parseInt(Ee, 16)), f += 3;
290
+ const z = e[d + 1], je = e.slice(d + 2, d + 4);
291
+ if ((z === "x" || z === "X") && /^[0-9a-fA-F]{2}$/.test(je)) {
292
+ o(), n.push(parseInt(je, 16)), d += 3;
291
293
  continue;
292
294
  }
293
- const Te = { r: 13, n: 10, t: 9, 0: 0, "\\": 92 };
294
- if (P !== void 0 && P in Te) {
295
- c(), n.push(Te[P]), f += 1;
295
+ const Me = { r: 13, n: 10, t: 9, 0: 0, "\\": 92 };
296
+ if (z !== void 0 && z in Me) {
297
+ o(), n.push(Me[z]), d += 1;
296
298
  continue;
297
299
  }
298
- s += le;
300
+ r += me;
299
301
  }
300
- return c(), n;
301
- }, ce = (e, t) => {
302
+ return o(), n;
303
+ }, re = (e, t) => {
302
304
  if (t) {
303
- const s = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
304
- if (!s.length || s.length % 2) return [];
305
- const c = [];
306
- for (let f = 0; f + 1 < s.length; f += 2) c.push(parseInt(s.slice(f, f + 2), 16));
307
- return c;
305
+ const r = e.replace(/0x/gi, "").replace(/[^0-9a-fA-F]/g, "");
306
+ if (!r.length || r.length % 2) return [];
307
+ const o = [];
308
+ for (let d = 0; d + 1 < r.length; d += 2) o.push(parseInt(r.slice(d, d + 2), 16));
309
+ return o;
308
310
  }
309
- const n = T.value ? Ke(e) : Array.from(new TextEncoder().encode(e));
310
- return (I.value === "cr" || I.value === "crlf") && n.push(13), (I.value === "lf" || I.value === "crlf") && n.push(10), n;
311
- }, Pe = async () => {
312
- if (x.value && (ge.value || !ye.value.length)) return;
313
- const e = i.value, t = ce(e, x.value);
314
- !t.length || !await K(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (y.value = [e, ...y.value.filter((s) => s !== e)].slice(0, 50), m.value = -1), i.value = "");
315
- }, pe = async (e) => {
316
- const t = ce(e, !1);
311
+ const n = E.value ? Ze(e) : Array.from(new TextEncoder().encode(e));
312
+ return (M.value === "cr" || M.value === "crlf") && n.push(13), (M.value === "lf" || M.value === "crlf") && n.push(10), n;
313
+ }, Ne = async () => {
314
+ if (g.value && (Re.value || !Te.value.length)) return;
315
+ const e = f.value, t = re(e, g.value);
316
+ !t.length || !await K(new Uint8Array(t.slice(0, 4096))) || (e.trim() && (x.value = [e, ...x.value.filter((r) => r !== e)].slice(0, 50), s.value = -1), f.value = "");
317
+ }, Be = async (e) => {
318
+ const t = re(e, !1);
317
319
  if (!t.length) return;
318
- const n = w.value;
319
- await K(new Uint8Array(t.slice(0, 4096))) && (y.value = [e, ...y.value.filter((c) => c !== e)].slice(0, 50), m.value = -1, N = e, Ce(n));
320
- }, Qe = async (e) => {
320
+ const n = p.value;
321
+ await K(new Uint8Array(t.slice(0, 4096))) && (x.value = [e, ...x.value.filter((o) => o !== e)].slice(0, 50), s.value = -1, ue = e, ze(n));
322
+ }, et = async (e) => {
321
323
  const t = new Uint8Array(await e.arrayBuffer());
322
324
  if (!t.length) return !1;
323
325
  const n = 256;
324
- for (let s = 0; s < t.length; s += n) {
325
- if (!await K(t.slice(s, s + n))) return !1;
326
- await new Promise((f) => setTimeout(f, 8));
326
+ for (let r = 0; r < t.length; r += n) {
327
+ if (!await K(t.slice(r, r + n))) return !1;
328
+ await new Promise((d) => setTimeout(d, 8));
327
329
  }
328
330
  return !0;
329
- }, G = () => {
330
- H && clearInterval(H), H = null, k.value = !1;
331
- }, Ve = async () => {
331
+ }, ae = () => {
332
+ N && clearInterval(N), N = null, k.value = !1;
333
+ }, tt = async () => {
332
334
  if (k.value) {
333
- G();
335
+ ae();
334
336
  return;
335
337
  }
336
- const e = ce(i.value, x.value);
338
+ const e = re(f.value, g.value);
337
339
  if (!e.length) return;
338
340
  const t = new Uint8Array(e.slice(0, 4096));
339
- await K(t) && (k.value = !0, H = setInterval(() => {
341
+ await K(t) && (k.value = !0, N = setInterval(() => {
340
342
  K(t);
341
343
  }, Math.max(50, O.value)));
342
- }, He = async () => {
344
+ }, nt = async () => {
343
345
  var t;
344
- const e = (t = o.noReplyHint) == null ? void 0 : t.call(o);
345
- e != null && e.onAction && (q(), await e.onAction(), (e.resend ?? !0) && N && await pe(N));
346
- }, Xe = (e) => {
346
+ const e = (t = c.noReplyHint) == null ? void 0 : t.call(c);
347
+ e != null && e.onAction && (J(), await e.onAction(), (e.resend ?? !0) && ue && await Be(ue));
348
+ }, st = (e) => {
347
349
  if (e.key === "ArrowUp") {
348
- if (!y.value.length) return;
349
- e.preventDefault(), m.value = m.value === -1 ? y.value.length - 1 : Math.max(0, m.value - 1), i.value = y.value[m.value] ?? "";
350
+ if (!x.value.length) return;
351
+ e.preventDefault(), s.value = s.value === -1 ? x.value.length - 1 : Math.max(0, s.value - 1), f.value = x.value[s.value] ?? "";
350
352
  return;
351
353
  }
352
354
  if (e.key === "ArrowDown") {
353
- if (m.value === -1) return;
354
- e.preventDefault(), m.value++, m.value >= y.value.length ? (m.value = -1, i.value = "") : i.value = y.value[m.value] ?? "";
355
+ if (s.value === -1) return;
356
+ e.preventDefault(), s.value++, s.value >= x.value.length ? (s.value = -1, f.value = "") : f.value = x.value[s.value] ?? "";
355
357
  return;
356
358
  }
357
- e.key === "Escape" && (i.value = "", m.value = -1);
358
- }, Je = F(() => {
359
- const e = U.value.trim().toLowerCase();
360
- return e ? u.value.filter((t) => t.text.toLowerCase().includes(e) || t.hex.toLowerCase().includes(e)) : u.value;
361
- }), ze = (e) => (e.data ?? []).map((t) => t.toString(2).padStart(8, "0")).join(" "), Ge = (e) => M.value === "hex" ? e.hex : M.value === "bin" ? ze(e) : e.text || e.hex, We = F(() => u.value.find((e) => e.id === R.value) ?? null), Ye = (e) => {
362
- R.value = R.value === e.id ? null : e.id;
363
- }, Ze = (e) => {
364
- const t = U.value.trim().toLowerCase();
365
- if (!t) return [{ text: e, match: !1 }];
366
- const n = e.toLowerCase(), s = [];
367
- let c = 0;
368
- for (; c < e.length; ) {
369
- const f = n.indexOf(t, c);
370
- if (f === -1) break;
371
- f > c && s.push({ text: e.slice(c, f), match: !1 }), s.push({ text: e.slice(f, f + t.length), match: !0 }), c = f + t.length;
359
+ e.key === "Escape" && (f.value = "", s.value = -1);
360
+ }, rt = (e, t) => {
361
+ if (!t) return !0;
362
+ if (b.value)
363
+ try {
364
+ const n = new RegExp(t, "i");
365
+ return n.test(e.text) || n.test(e.hex);
366
+ } catch {
367
+ return !1;
368
+ }
369
+ return e.text.toLowerCase().includes(t) || e.hex.toLowerCase().includes(t);
370
+ }, at = U(() => {
371
+ const e = u.value.trim().toLowerCase(), t = new Set(T.value);
372
+ return i.value.filter((n) => q.value !== "all" && n.dir !== q.value || _.value && !t.has(n.id) ? !1 : rt(n, e));
373
+ }), Le = (e) => T.value.includes(e.id), ot = (e) => {
374
+ T.value = Le(e) ? T.value.filter((t) => t !== e.id) : [...T.value, e.id];
375
+ }, ct = (e) => e.split(`
376
+ `).map((t) => t.trim()).filter(Boolean).map((t) => {
377
+ const n = /^(\d+)\s*:\s*(.*)$/.exec(t);
378
+ return n ? { delay: Number(n[1]), command: n[2] } : { delay: 0, command: t };
379
+ }).filter((t) => t.command.length > 0), ge = () => {
380
+ H = !0, j.value = !1;
381
+ }, lt = async () => {
382
+ if (j.value) return;
383
+ const e = ct(R.value);
384
+ if (e.length) {
385
+ H = !1, j.value = !0;
386
+ try {
387
+ for (const t of e) {
388
+ if (H || (t.delay > 0 && await new Promise((r) => setTimeout(r, t.delay)), H)) break;
389
+ const n = re(t.command, !1);
390
+ n.length && await K(new Uint8Array(n.slice(0, 4096)));
391
+ }
392
+ } finally {
393
+ j.value = !1, H = !1;
394
+ }
395
+ }
396
+ };
397
+ oe(R, (e) => te("scenario", e));
398
+ const ut = (e) => (e.data ?? []).map((t) => t.toString(2).padStart(8, "0")).join(" "), it = (e) => h.value === "hex" ? e.hex : h.value === "bin" ? ut(e) : e.text || e.hex, ft = U(() => i.value.find((e) => e.id === a.value) ?? null), dt = (e) => {
399
+ a.value = a.value === e.id ? null : e.id;
400
+ }, ht = (e) => {
401
+ const t = u.value.trim().toLowerCase();
402
+ if (!t || b.value) return [{ text: e, match: !1 }];
403
+ const n = e.toLowerCase(), r = [];
404
+ let o = 0;
405
+ for (; o < e.length; ) {
406
+ const d = n.indexOf(t, o);
407
+ if (d === -1) break;
408
+ d > o && r.push({ text: e.slice(o, d), match: !1 }), r.push({ text: e.slice(d, d + t.length), match: !0 }), o = d + t.length;
372
409
  }
373
- return c < e.length && s.push({ text: e.slice(c), match: !1 }), s.length ? s : [{ text: e, match: !1 }];
374
- }, oe = (e, t) => {
375
- const n = URL.createObjectURL(t), s = document.createElement("a"), c = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
376
- return s.href = n, s.download = `serial-${c}.${e}`, s.click(), URL.revokeObjectURL(n), !0;
377
- }, me = () => u.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
378
- `), Ne = () => {
379
- if (!u.value.length) return !1;
380
- const e = (n) => `"${String(n).replace(/"/g, '""')}"`, t = u.value.map((n) => [n.at, n.dir, n.bytes, e(n.text), e(n.hex)].join(","));
381
- return oe("csv", new Blob([["time,direction,bytes,text,hex", ...t].join(`
410
+ return o < e.length && r.push({ text: e.slice(o), match: !1 }), r.length ? r : [{ text: e, match: !1 }];
411
+ }, pe = (e, t) => {
412
+ const n = URL.createObjectURL(t), r = document.createElement("a"), o = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
413
+ return r.href = n, r.download = `serial-${o}.${e}`, r.click(), URL.revokeObjectURL(n), !0;
414
+ }, Oe = () => i.value.map((e) => `${e.at} ${e.dir.toUpperCase()} ${e.text || e.hex}`).join(`
415
+ `), vt = () => {
416
+ if (!i.value.length) return !1;
417
+ const e = (n) => `"${String(n).replace(/"/g, '""')}"`, t = i.value.map((n) => [n.at, n.dir, n.bytes, e(n.text), e(n.hex)].join(","));
418
+ return pe("csv", new Blob([["time,direction,bytes,text,hex", ...t].join(`
382
419
  `)], { type: "text/csv;charset=utf-8" }));
383
- }, et = () => {
384
- if (!u.value.length) return !1;
385
- const e = u.value.map((t) => ({ at: t.at, dir: t.dir, bytes: t.bytes, text: t.text, hex: t.hex }));
386
- return oe("json", new Blob([JSON.stringify(e, null, 2)], { type: "application/json;charset=utf-8" }));
387
- }, tt = () => {
420
+ }, yt = () => {
421
+ if (!i.value.length) return !1;
422
+ const e = i.value.map((t) => ({ at: t.at, dir: t.dir, bytes: t.bytes, text: t.text, hex: t.hex }));
423
+ return pe("json", new Blob([JSON.stringify(e, null, 2)], { type: "application/json;charset=utf-8" }));
424
+ }, gt = () => {
388
425
  var t;
389
426
  const e = [];
390
- for (const n of u.value)
427
+ for (const n of i.value)
391
428
  n.dir === "rx" && ((t = n.data) != null && t.length) && e.push(...n.data);
392
- return e.length ? oe("bin", new Blob([new Uint8Array(e)], { type: "application/octet-stream" })) : !1;
393
- }, xe = async () => {
394
- if (!u.value.length) return !1;
429
+ return e.length ? pe("bin", new Blob([new Uint8Array(e)], { type: "application/octet-stream" })) : !1;
430
+ }, Ae = async () => {
431
+ if (!i.value.length) return !1;
395
432
  try {
396
- return await navigator.clipboard.writeText(me()), r.value = !0, _ && clearTimeout(_), _ = setTimeout(() => {
397
- r.value = !1;
398
- }, ft), !0;
433
+ return await navigator.clipboard.writeText(Oe()), P.value = !0, X && clearTimeout(X), X = setTimeout(() => {
434
+ P.value = !1;
435
+ }, Rt), !0;
399
436
  } catch {
400
437
  return !1;
401
438
  }
402
- }, nt = () => {
403
- if (!u.value.length) return !1;
404
- const e = new Blob([me()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), n = document.createElement("a"), s = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
405
- return n.href = t, n.download = `serial-${s}.log`, n.click(), URL.revokeObjectURL(t), !0;
406
- }, we = () => {
407
- G(), q(), z();
408
- const e = J();
409
- e && Ie(e).catch(() => {
410
- }), v.value = !1, g = [], E = [], u.value = [], R.value = null, w.value = 0, b.value = 0, L.value = 0, j.value = 0, ee = 0, te = 0, X = performance.now();
411
- }, rt = (e) => {
412
- const t = o.labels();
439
+ }, pt = () => {
440
+ if (!i.value.length) return !1;
441
+ const e = new Blob([Oe()], { type: "text/plain;charset=utf-8" }), t = URL.createObjectURL(e), n = document.createElement("a"), r = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
442
+ return n.href = t, n.download = `serial-${r}.log`, n.click(), URL.revokeObjectURL(t), !0;
443
+ }, De = () => {
444
+ ae(), ge(), J(), se();
445
+ const e = ne();
446
+ e && Ve(e).catch(() => {
447
+ }), Q.value = !1, S = [], D = [], i.value = [], a.value = null, p.value = 0, m.value = 0, L.value = 0, C.value = 0, ie = 0, fe = 0, ee = performance.now();
448
+ }, mt = (e) => {
449
+ const t = c.labels();
413
450
  return e < 1024 ? `${e} ${t.byteShort}` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} ${t.kiloShort}` : `${(e / (1024 * 1024)).toFixed(2)} ${t.megaShort}`;
414
- }, st = () => {
415
- const e = performance.now(), t = (e - X) / 1e3;
416
- t <= 0 || (L.value = Math.max(0, Math.round((w.value - ee) / t)), j.value = Math.max(0, Math.round((b.value - te) / t)), ee = w.value, te = b.value, X = e);
417
- }, at = () => {
418
- const e = h.value.trim();
419
- e && (a.value.includes(e) || (a.value = [...a.value, e].slice(0, Le)), h.value = "", ne("quick", a.value));
420
- }, ct = (e) => {
421
- a.value = a.value.filter((t) => t !== e), ne("quick", a.value);
422
- }, Se = (e) => {
423
- e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), we()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), xe()));
451
+ }, xt = () => {
452
+ const e = performance.now(), t = (e - ee) / 1e3;
453
+ t <= 0 || (L.value = Math.max(0, Math.round((p.value - ie) / t)), C.value = Math.max(0, Math.round((m.value - fe) / t)), ie = p.value, fe = m.value, ee = e);
454
+ }, wt = () => {
455
+ const e = ce.value.trim();
456
+ e && (B.value.includes(e) || (B.value = [...B.value, e].slice(0, Ce)), ce.value = "", te("quick", B.value));
457
+ }, St = (e) => {
458
+ B.value = B.value.filter((t) => t !== e), te("quick", B.value);
459
+ }, Ie = (e) => {
460
+ e.ctrlKey && (e.key.toLowerCase() === "l" && (e.preventDefault(), De()), e.shiftKey && e.key.toLowerCase() === "c" && (e.preventDefault(), Ae()));
424
461
  };
425
- return ot(() => {
426
- _e(), J() && Ue(), X = performance.now(), C = setInterval(st, 1e3), window.addEventListener("keydown", Se);
427
- }), lt(() => {
428
- D == null || D(), D = null, G(), q(), z(), C && clearInterval(C), _ && clearTimeout(_), $ && clearTimeout($), window.removeEventListener("keydown", Se);
462
+ return kt(() => {
463
+ We(), ne() && Xe(), ee = performance.now(), le = setInterval(xt, 1e3), window.addEventListener("keydown", Ie);
464
+ }), bt(() => {
465
+ I == null || I(), I = null, ae(), ge(), J(), se(), le && clearInterval(le), X && clearTimeout(X), V && clearTimeout(V), window.removeEventListener("keydown", Ie);
429
466
  }), {
430
- lines: u,
431
- visibleLines: Je,
432
- view: p,
433
- rxBytes: w,
434
- txBytes: b,
467
+ lines: i,
468
+ visibleLines: at,
469
+ view: y,
470
+ rxBytes: p,
471
+ txBytes: m,
435
472
  rxRate: L,
436
- txRate: j,
437
- input: i,
438
- hexSend: x,
439
- escape: T,
473
+ txRate: C,
474
+ input: f,
475
+ hexSend: g,
476
+ escape: E,
440
477
  repeat: k,
441
478
  repeatMs: O,
442
- sendFile: Qe,
443
- toggleRepeat: Ve,
444
- stopRepeat: G,
445
- lineEnding: I,
446
- history: y,
447
- filter: U,
448
- mode: M,
449
- selectedId: R,
450
- selectedLine: We,
451
- selectLine: Ye,
452
- showTime: W,
453
- wrapLines: Y,
454
- autoScroll: Z,
455
- copied: r,
456
- showNoReply: l,
457
- quickCommands: a,
458
- quickInput: h,
459
- hexBytes: ye,
460
- hexError: ge,
461
- sendText: Pe,
462
- sendQuick: pe,
463
- onInputKeydown: Xe,
464
- lineContent: Ge,
465
- lineSegments: Ze,
466
- copyLog: xe,
467
- downloadLog: nt,
468
- exportCsv: Ne,
469
- exportJson: et,
470
- exportRxBin: tt,
471
- sessionRestored: v,
472
- clearLog: we,
473
- formatBytes: rt,
474
- addQuick: at,
475
- removeQuick: ct,
476
- applyHintAction: He
479
+ direction: q,
480
+ regex: b,
481
+ onlyBookmarks: _,
482
+ bookmarkIds: T,
483
+ isBookmarked: Le,
484
+ toggleBookmark: ot,
485
+ scenarioOpen: W,
486
+ scenarioText: R,
487
+ scenarioRunning: j,
488
+ startScenario: lt,
489
+ stopScenario: ge,
490
+ sendFile: et,
491
+ toggleRepeat: tt,
492
+ stopRepeat: ae,
493
+ lineEnding: M,
494
+ history: x,
495
+ filter: u,
496
+ mode: h,
497
+ selectedId: a,
498
+ selectedLine: ft,
499
+ selectLine: dt,
500
+ showTime: v,
501
+ wrapLines: w,
502
+ autoScroll: $,
503
+ copied: P,
504
+ showNoReply: A,
505
+ quickCommands: B,
506
+ quickInput: ce,
507
+ hexBytes: Te,
508
+ hexError: Re,
509
+ sendText: Ne,
510
+ sendQuick: Be,
511
+ onInputKeydown: st,
512
+ lineContent: it,
513
+ lineSegments: ht,
514
+ copyLog: Ae,
515
+ downloadLog: pt,
516
+ exportCsv: vt,
517
+ exportJson: yt,
518
+ exportRxBin: gt,
519
+ sessionRestored: Q,
520
+ clearLog: De,
521
+ formatBytes: mt,
522
+ addQuick: wt,
523
+ removeQuick: St,
524
+ applyHintAction: nt
477
525
  };
478
526
  }
479
527
  export {
480
- St as useDialog,
481
- bt as useFocusTrap,
482
- pt as useForm,
483
- mt as useSerialConsole,
484
- kt as useSwipeDown
528
+ Mt as useDialog,
529
+ $t as useFocusTrap,
530
+ It as useForm,
531
+ Ft as useSerialConsole,
532
+ Ct as useSwipeDown
485
533
  };