@foisit/vue-wrapper 2.4.1 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/index.mjs +518 -460
- package/package.json +16 -6
package/index.mjs
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
const
|
|
6
|
+
const ie = process.env.NODE_ENV !== "production" ? Object.freeze({}) : {}, qe = process.env.NODE_ENV !== "production" ? Object.freeze([]) : [], we = () => {
|
|
7
7
|
}, ze = (t) => t.charCodeAt(0) === 111 && t.charCodeAt(1) === 110 && // uppercase letter
|
|
8
|
-
(t.charCodeAt(2) > 122 || t.charCodeAt(2) < 97), z = Object.assign, k = Array.isArray, R = (t) => typeof t == "function", T = (t) => typeof t == "string",
|
|
9
|
-
let
|
|
10
|
-
const
|
|
8
|
+
(t.charCodeAt(2) > 122 || t.charCodeAt(2) < 97), z = Object.assign, k = Array.isArray, R = (t) => typeof t == "function", T = (t) => typeof t == "string", ve = (t) => typeof t == "symbol", O = (t) => t !== null && typeof t == "object";
|
|
9
|
+
let me;
|
|
10
|
+
const Q = () => me || (me = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
|
|
11
11
|
function ae(t) {
|
|
12
12
|
if (k(t)) {
|
|
13
13
|
const e = {};
|
|
14
|
-
for (let
|
|
15
|
-
const
|
|
14
|
+
for (let n = 0; n < t.length; n++) {
|
|
15
|
+
const i = t[n], s = T(i) ? je(i) : ae(i);
|
|
16
16
|
if (s)
|
|
17
17
|
for (const o in s)
|
|
18
18
|
e[o] = s[o];
|
|
@@ -21,13 +21,13 @@ function ae(t) {
|
|
|
21
21
|
} else if (T(t) || O(t))
|
|
22
22
|
return t;
|
|
23
23
|
}
|
|
24
|
-
const Be = /;(?![^(]*\))/g,
|
|
24
|
+
const Be = /;(?![^(]*\))/g, Ue = /:([^]+)/, We = /\/\*[^]*?\*\//g;
|
|
25
25
|
function je(t) {
|
|
26
26
|
const e = {};
|
|
27
|
-
return t.replace(
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
return t.replace(We, "").split(Be).forEach((n) => {
|
|
28
|
+
if (n) {
|
|
29
|
+
const i = n.split(Ue);
|
|
30
|
+
i.length > 1 && (e[i[0].trim()] = i[1].trim());
|
|
31
31
|
}
|
|
32
32
|
}), e;
|
|
33
33
|
}
|
|
@@ -36,13 +36,13 @@ function le(t) {
|
|
|
36
36
|
if (T(t))
|
|
37
37
|
e = t;
|
|
38
38
|
else if (k(t))
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
|
|
39
|
+
for (let n = 0; n < t.length; n++) {
|
|
40
|
+
const i = le(t[n]);
|
|
41
|
+
i && (e += i + " ");
|
|
42
42
|
}
|
|
43
43
|
else if (O(t))
|
|
44
|
-
for (const
|
|
45
|
-
t[
|
|
44
|
+
for (const n in t)
|
|
45
|
+
t[n] && (e += n + " ");
|
|
46
46
|
return e.trim();
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -54,7 +54,7 @@ process.env.NODE_ENV;
|
|
|
54
54
|
process.env.NODE_ENV;
|
|
55
55
|
process.env.NODE_ENV;
|
|
56
56
|
new Set(
|
|
57
|
-
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((t) => t !== "arguments" && t !== "caller").map((t) => Symbol[t]).filter(
|
|
57
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((t) => t !== "arguments" && t !== "caller").map((t) => Symbol[t]).filter(ve)
|
|
58
58
|
);
|
|
59
59
|
function xe(t) {
|
|
60
60
|
return se(t) ? xe(t.__v_raw) : !!(t && t.__v_isReactive);
|
|
@@ -62,7 +62,7 @@ function xe(t) {
|
|
|
62
62
|
function se(t) {
|
|
63
63
|
return !!(t && t.__v_isReadonly);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function Z(t) {
|
|
66
66
|
return !!(t && t.__v_isShallow);
|
|
67
67
|
}
|
|
68
68
|
function oe(t) {
|
|
@@ -80,22 +80,22 @@ function ce(t) {
|
|
|
80
80
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
81
81
|
* @license MIT
|
|
82
82
|
**/
|
|
83
|
-
const
|
|
83
|
+
const P = [];
|
|
84
84
|
function Ke(t) {
|
|
85
|
-
|
|
85
|
+
P.push(t);
|
|
86
86
|
}
|
|
87
87
|
function Ye() {
|
|
88
|
-
|
|
88
|
+
P.pop();
|
|
89
89
|
}
|
|
90
90
|
let ee = !1;
|
|
91
91
|
function _(t, ...e) {
|
|
92
92
|
if (ee) return;
|
|
93
93
|
ee = !0;
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
94
|
+
const n = P.length ? P[P.length - 1].component : null, i = n && n.appContext.config.warnHandler, s = Je();
|
|
95
|
+
if (i)
|
|
96
96
|
de(
|
|
97
|
-
n,
|
|
98
97
|
i,
|
|
98
|
+
n,
|
|
99
99
|
11,
|
|
100
100
|
[
|
|
101
101
|
// eslint-disable-next-line no-restricted-syntax
|
|
@@ -103,9 +103,9 @@ function _(t, ...e) {
|
|
|
103
103
|
var r, a;
|
|
104
104
|
return (a = (r = o.toString) == null ? void 0 : r.call(o)) != null ? a : JSON.stringify(o);
|
|
105
105
|
}).join(""),
|
|
106
|
-
|
|
106
|
+
n && n.proxy,
|
|
107
107
|
s.map(
|
|
108
|
-
({ vnode: o }) => `at <${De(
|
|
108
|
+
({ vnode: o }) => `at <${De(n, o.type)}>`
|
|
109
109
|
).join(`
|
|
110
110
|
`),
|
|
111
111
|
s
|
|
@@ -119,44 +119,44 @@ function _(t, ...e) {
|
|
|
119
119
|
ee = !1;
|
|
120
120
|
}
|
|
121
121
|
function Je() {
|
|
122
|
-
let t =
|
|
122
|
+
let t = P[P.length - 1];
|
|
123
123
|
if (!t)
|
|
124
124
|
return [];
|
|
125
125
|
const e = [];
|
|
126
126
|
for (; t; ) {
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
const n = e[0];
|
|
128
|
+
n && n.vnode === t ? n.recurseCount++ : e.push({
|
|
129
129
|
vnode: t,
|
|
130
130
|
recurseCount: 0
|
|
131
131
|
});
|
|
132
|
-
const
|
|
133
|
-
t =
|
|
132
|
+
const i = t.component && t.component.parent;
|
|
133
|
+
t = i && i.vnode;
|
|
134
134
|
}
|
|
135
135
|
return e;
|
|
136
136
|
}
|
|
137
137
|
function Ge(t) {
|
|
138
138
|
const e = [];
|
|
139
|
-
return t.forEach((
|
|
140
|
-
e.push(...
|
|
141
|
-
`], ...Xe(
|
|
139
|
+
return t.forEach((n, i) => {
|
|
140
|
+
e.push(...i === 0 ? [] : [`
|
|
141
|
+
`], ...Xe(n));
|
|
142
142
|
}), e;
|
|
143
143
|
}
|
|
144
144
|
function Xe({ vnode: t, recurseCount: e }) {
|
|
145
|
-
const
|
|
145
|
+
const n = e > 0 ? `... (${e} recursive calls)` : "", i = t.component ? t.component.parent == null : !1, s = ` at <${De(
|
|
146
146
|
t.component,
|
|
147
147
|
t.type,
|
|
148
|
-
|
|
149
|
-
)}`, o = ">" +
|
|
150
|
-
return t.props ? [s, ...
|
|
148
|
+
i
|
|
149
|
+
)}`, o = ">" + n;
|
|
150
|
+
return t.props ? [s, ...Qe(t.props), o] : [s + o];
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
const e = [],
|
|
154
|
-
return
|
|
155
|
-
e.push(...Se(
|
|
156
|
-
}),
|
|
152
|
+
function Qe(t) {
|
|
153
|
+
const e = [], n = Object.keys(t);
|
|
154
|
+
return n.slice(0, 3).forEach((i) => {
|
|
155
|
+
e.push(...Se(i, t[i]));
|
|
156
|
+
}), n.length > 3 && e.push(" ..."), e;
|
|
157
157
|
}
|
|
158
|
-
function Se(t, e,
|
|
159
|
-
return T(e) ? (e = JSON.stringify(e),
|
|
158
|
+
function Se(t, e, n) {
|
|
159
|
+
return T(e) ? (e = JSON.stringify(e), n ? e : [`${t}=${e}`]) : typeof e == "number" || typeof e == "boolean" || e == null ? n ? e : [`${t}=${e}`] : ce(e) ? (e = Se(t, M(e.value), !0), n ? e : [`${t}=Ref<`, e, ">"]) : R(e) ? [`${t}=fn${e.name ? `<${e.name}>` : ""}`] : (e = M(e), n ? e : [`${t}=`, e]);
|
|
160
160
|
}
|
|
161
161
|
const Ce = {
|
|
162
162
|
sp: "serverPrefetch hook",
|
|
@@ -191,23 +191,23 @@ const Ce = {
|
|
|
191
191
|
15: "component update",
|
|
192
192
|
16: "app unmount cleanup function"
|
|
193
193
|
};
|
|
194
|
-
function de(t, e,
|
|
194
|
+
function de(t, e, n, i) {
|
|
195
195
|
try {
|
|
196
|
-
return
|
|
196
|
+
return i ? t(...i) : t();
|
|
197
197
|
} catch (s) {
|
|
198
|
-
Ee(s, e,
|
|
198
|
+
Ee(s, e, n);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function Ee(t, e,
|
|
202
|
-
const s = e ? e.vnode : null, { errorHandler: o, throwUnhandledErrorInProduction: r } = e && e.appContext.config ||
|
|
201
|
+
function Ee(t, e, n, i = !0) {
|
|
202
|
+
const s = e ? e.vnode : null, { errorHandler: o, throwUnhandledErrorInProduction: r } = e && e.appContext.config || ie;
|
|
203
203
|
if (e) {
|
|
204
204
|
let a = e.parent;
|
|
205
|
-
const c = e.proxy,
|
|
205
|
+
const c = e.proxy, h = process.env.NODE_ENV !== "production" ? Ce[n] : `https://vuejs.org/error-reference/#runtime-${n}`;
|
|
206
206
|
for (; a; ) {
|
|
207
207
|
const d = a.ec;
|
|
208
208
|
if (d) {
|
|
209
209
|
for (let l = 0; l < d.length; l++)
|
|
210
|
-
if (d[l](t, c,
|
|
210
|
+
if (d[l](t, c, h) === !1)
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
a = a.parent;
|
|
@@ -216,17 +216,17 @@ function Ee(t, e, i, n = !0) {
|
|
|
216
216
|
de(o, null, 10, [
|
|
217
217
|
t,
|
|
218
218
|
c,
|
|
219
|
-
|
|
219
|
+
h
|
|
220
220
|
]);
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
Ze(t, n, s, i, r);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function Ze(t, e, n, i = !0, s = !1) {
|
|
227
227
|
if (process.env.NODE_ENV !== "production") {
|
|
228
228
|
const o = Ce[e];
|
|
229
|
-
if (
|
|
229
|
+
if (n && Ke(n), _(`Unhandled error${o ? ` during execution of ${o}` : ""}`), n && Ye(), i)
|
|
230
230
|
throw t;
|
|
231
231
|
console.error(t);
|
|
232
232
|
} else {
|
|
@@ -238,89 +238,89 @@ function Qe(t, e, i, n = !0, s = !1) {
|
|
|
238
238
|
const C = [];
|
|
239
239
|
let I = -1;
|
|
240
240
|
const D = [];
|
|
241
|
-
let L = null,
|
|
241
|
+
let L = null, V = 0;
|
|
242
242
|
const et = /* @__PURE__ */ Promise.resolve();
|
|
243
243
|
let re = null;
|
|
244
244
|
const tt = 100;
|
|
245
|
-
function
|
|
246
|
-
let e = I + 1,
|
|
247
|
-
for (; e <
|
|
248
|
-
const
|
|
249
|
-
o < t || o === t && s.flags & 2 ? e =
|
|
245
|
+
function nt(t) {
|
|
246
|
+
let e = I + 1, n = C.length;
|
|
247
|
+
for (; e < n; ) {
|
|
248
|
+
const i = e + n >>> 1, s = C[i], o = H(s);
|
|
249
|
+
o < t || o === t && s.flags & 2 ? e = i + 1 : n = i;
|
|
250
250
|
}
|
|
251
251
|
return e;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function it(t) {
|
|
254
254
|
if (!(t.flags & 1)) {
|
|
255
|
-
const e = H(t),
|
|
256
|
-
!
|
|
257
|
-
!(t.flags & 2) && e >= H(
|
|
255
|
+
const e = H(t), n = C[C.length - 1];
|
|
256
|
+
!n || // fast path when the job id is larger than the tail
|
|
257
|
+
!(t.flags & 2) && e >= H(n) ? C.push(t) : C.splice(nt(e), 0, t), t.flags |= 1, ke();
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
function ke() {
|
|
261
261
|
re || (re = et.then(_e));
|
|
262
262
|
}
|
|
263
263
|
function st(t) {
|
|
264
|
-
k(t) ? D.push(...t) : L && t.id === -1 ? L.splice(
|
|
264
|
+
k(t) ? D.push(...t) : L && t.id === -1 ? L.splice(V + 1, 0, t) : t.flags & 1 || (D.push(t), t.flags |= 1), ke();
|
|
265
265
|
}
|
|
266
266
|
function ot(t) {
|
|
267
267
|
if (D.length) {
|
|
268
268
|
const e = [...new Set(D)].sort(
|
|
269
|
-
(
|
|
269
|
+
(n, i) => H(n) - H(i)
|
|
270
270
|
);
|
|
271
271
|
if (D.length = 0, L) {
|
|
272
272
|
L.push(...e);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
for (L = e, process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map()),
|
|
276
|
-
const
|
|
277
|
-
process.env.NODE_ENV !== "production" && Ie(t,
|
|
275
|
+
for (L = e, process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map()), V = 0; V < L.length; V++) {
|
|
276
|
+
const n = L[V];
|
|
277
|
+
process.env.NODE_ENV !== "production" && Ie(t, n) || (n.flags & 4 && (n.flags &= -2), n.flags & 8 || n(), n.flags &= -2);
|
|
278
278
|
}
|
|
279
|
-
L = null,
|
|
279
|
+
L = null, V = 0;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
282
|
const H = (t) => t.id == null ? t.flags & 2 ? -1 : 1 / 0 : t.id;
|
|
283
283
|
function _e(t) {
|
|
284
284
|
process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map());
|
|
285
|
-
const e = process.env.NODE_ENV !== "production" ? (
|
|
285
|
+
const e = process.env.NODE_ENV !== "production" ? (n) => Ie(t, n) : we;
|
|
286
286
|
try {
|
|
287
287
|
for (I = 0; I < C.length; I++) {
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
if (process.env.NODE_ENV !== "production" && e(
|
|
288
|
+
const n = C[I];
|
|
289
|
+
if (n && !(n.flags & 8)) {
|
|
290
|
+
if (process.env.NODE_ENV !== "production" && e(n))
|
|
291
291
|
continue;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
),
|
|
292
|
+
n.flags & 4 && (n.flags &= -2), de(
|
|
293
|
+
n,
|
|
294
|
+
n.i,
|
|
295
|
+
n.i ? 15 : 14
|
|
296
|
+
), n.flags & 4 || (n.flags &= -2);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
} finally {
|
|
300
300
|
for (; I < C.length; I++) {
|
|
301
|
-
const
|
|
302
|
-
|
|
301
|
+
const n = C[I];
|
|
302
|
+
n && (n.flags &= -2);
|
|
303
303
|
}
|
|
304
304
|
I = -1, C.length = 0, ot(t), re = null, (C.length || D.length) && _e(t);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
function Ie(t, e) {
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
308
|
+
const n = t.get(e) || 0;
|
|
309
|
+
if (n > tt) {
|
|
310
|
+
const i = e.i, s = i && Fe(i.type);
|
|
311
311
|
return Ee(
|
|
312
312
|
`Maximum recursive updates exceeded${s ? ` in component <${s}>` : ""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
|
|
313
313
|
null,
|
|
314
314
|
10
|
|
315
315
|
), !0;
|
|
316
316
|
}
|
|
317
|
-
return t.set(e,
|
|
317
|
+
return t.set(e, n + 1), !1;
|
|
318
318
|
}
|
|
319
319
|
const te = /* @__PURE__ */ new Map();
|
|
320
|
-
process.env.NODE_ENV !== "production" && (
|
|
321
|
-
createRecord:
|
|
322
|
-
rerender:
|
|
323
|
-
reload:
|
|
320
|
+
process.env.NODE_ENV !== "production" && (Q().__VUE_HMR_RUNTIME__ = {
|
|
321
|
+
createRecord: ne(rt),
|
|
322
|
+
rerender: ne(at),
|
|
323
|
+
reload: ne(lt)
|
|
324
324
|
});
|
|
325
325
|
const J = /* @__PURE__ */ new Map();
|
|
326
326
|
function rt(t, e) {
|
|
@@ -333,20 +333,20 @@ function G(t) {
|
|
|
333
333
|
return $e(t) ? t.__vccOpts : t;
|
|
334
334
|
}
|
|
335
335
|
function at(t, e) {
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
e && (
|
|
336
|
+
const n = J.get(t);
|
|
337
|
+
n && (n.initialDef.render = e, [...n.instances].forEach((i) => {
|
|
338
|
+
e && (i.render = e, G(i.type).render = e), i.renderCache = [], i.job.flags & 8 || i.update();
|
|
339
339
|
}));
|
|
340
340
|
}
|
|
341
341
|
function lt(t, e) {
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
344
|
-
e = G(e),
|
|
345
|
-
const
|
|
346
|
-
for (let s = 0; s <
|
|
347
|
-
const o =
|
|
342
|
+
const n = J.get(t);
|
|
343
|
+
if (!n) return;
|
|
344
|
+
e = G(e), he(n.initialDef, e);
|
|
345
|
+
const i = [...n.instances];
|
|
346
|
+
for (let s = 0; s < i.length; s++) {
|
|
347
|
+
const o = i[s], r = G(o.type);
|
|
348
348
|
let a = te.get(r);
|
|
349
|
-
a || (r !==
|
|
349
|
+
a || (r !== n.initialDef && he(r, e), te.set(r, a = /* @__PURE__ */ new Set())), a.add(o), o.appContext.propsCache.delete(o.type), o.appContext.emitsCache.delete(o.type), o.appContext.optionsCache.delete(o.type), o.ceReload ? (a.add(o), o.ceReload(e.styles), a.delete(o)) : o.parent ? it(() => {
|
|
350
350
|
o.job.flags & 8 || (o.parent.update(), a.delete(o));
|
|
351
351
|
}) : o.appContext.reload ? o.appContext.reload() : typeof window < "u" ? window.location.reload() : console.warn(
|
|
352
352
|
"[HMR] Root or manually mounted instance modified. Full reload required."
|
|
@@ -356,17 +356,17 @@ function lt(t, e) {
|
|
|
356
356
|
te.clear();
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function he(t, e) {
|
|
360
360
|
z(t, e);
|
|
361
|
-
for (const
|
|
362
|
-
|
|
361
|
+
for (const n in t)
|
|
362
|
+
n !== "__file" && !(n in e) && delete t[n];
|
|
363
363
|
}
|
|
364
|
-
function
|
|
365
|
-
return (e,
|
|
364
|
+
function ne(t) {
|
|
365
|
+
return (e, n) => {
|
|
366
366
|
try {
|
|
367
|
-
return t(e,
|
|
368
|
-
} catch (
|
|
369
|
-
console.error(
|
|
367
|
+
return t(e, n);
|
|
368
|
+
} catch (i) {
|
|
369
|
+
console.error(i), console.warn(
|
|
370
370
|
"[HMR] Something went wrong during Vue component hot-reload. Full reload required."
|
|
371
371
|
);
|
|
372
372
|
}
|
|
@@ -374,11 +374,11 @@ function ie(t) {
|
|
|
374
374
|
}
|
|
375
375
|
let F, j = [];
|
|
376
376
|
function Ae(t, e) {
|
|
377
|
-
var
|
|
377
|
+
var n, i;
|
|
378
378
|
F = t, F ? (F.enabled = !0, j.forEach(({ event: s, args: o }) => F.emit(s, ...o)), j = []) : /* handle late devtools injection - only do this if we are in an actual */ /* browser environment to avoid the timer handle stalling test runner exit */ /* (#4815) */ typeof window < "u" && // some envs mock window but not fully
|
|
379
379
|
window.HTMLElement && // also exclude jsdom
|
|
380
380
|
// eslint-disable-next-line no-restricted-syntax
|
|
381
|
-
!((
|
|
381
|
+
!((i = (n = window.navigator) == null ? void 0 : n.userAgent) != null && i.includes("jsdom")) ? ((e.__VUE_DEVTOOLS_HOOK_REPLAY__ = e.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((o) => {
|
|
382
382
|
Ae(o, e);
|
|
383
383
|
}), setTimeout(() => {
|
|
384
384
|
F || (e.__VUE_DEVTOOLS_HOOK_REPLAY__ = null, j = []);
|
|
@@ -387,19 +387,19 @@ function Ae(t, e) {
|
|
|
387
387
|
let N = null, ct = null;
|
|
388
388
|
function dt(t, e) {
|
|
389
389
|
if (process.env.NODE_ENV !== "production" && (!A || A.isMounted) && _("provide() can only be used inside setup()."), A) {
|
|
390
|
-
let
|
|
391
|
-
const
|
|
392
|
-
|
|
390
|
+
let n = A.provides;
|
|
391
|
+
const i = A.parent && A.parent.provides;
|
|
392
|
+
i === n && (n = A.provides = Object.create(i)), n[t] = e;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
function ut(t, e,
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
let s =
|
|
395
|
+
function ut(t, e, n = !1) {
|
|
396
|
+
const i = Nt();
|
|
397
|
+
if (i || bt) {
|
|
398
|
+
let s = i ? i.parent == null || i.ce ? i.vnode.appContext && i.vnode.appContext.provides : i.parent.provides : void 0;
|
|
399
399
|
if (s && t in s)
|
|
400
400
|
return s[t];
|
|
401
401
|
if (arguments.length > 1)
|
|
402
|
-
return
|
|
402
|
+
return n && R(e) ? e.call(i && i.proxy) : e;
|
|
403
403
|
process.env.NODE_ENV !== "production" && _(`injection "${String(t)}" not found.`);
|
|
404
404
|
} else process.env.NODE_ENV !== "production" && _("inject() can only be used inside setup() or functional components.");
|
|
405
405
|
}
|
|
@@ -408,37 +408,37 @@ function Ne(t, e) {
|
|
|
408
408
|
t.shapeFlag & 6 && t.component ? (t.transition = e, Ne(t.component.subTree, e)) : t.shapeFlag & 128 ? (t.ssContent.transition = e.clone(t.ssContent), t.ssFallback.transition = e.clone(t.ssFallback)) : t.transition = e;
|
|
409
409
|
}
|
|
410
410
|
// @__NO_SIDE_EFFECTS__
|
|
411
|
-
function
|
|
411
|
+
function mt(t, e) {
|
|
412
412
|
return R(t) ? (
|
|
413
413
|
// #8236: extend call and options.name access are considered side-effects
|
|
414
414
|
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
|
|
415
415
|
z({ name: t.name }, e, { setup: t })
|
|
416
416
|
) : t;
|
|
417
417
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
function gt(t, e,
|
|
422
|
-
if (N.ce || N.parent &&
|
|
423
|
-
const
|
|
418
|
+
Q().requestIdleCallback;
|
|
419
|
+
Q().cancelIdleCallback;
|
|
420
|
+
const ht = (t) => !!t.type.__asyncLoader, pt = /* @__PURE__ */ Symbol.for("v-ndc");
|
|
421
|
+
function gt(t, e, n = {}, i, s) {
|
|
422
|
+
if (N.ce || N.parent && ht(N.parent) && N.parent.ce) {
|
|
423
|
+
const h = Object.keys(n).length > 0;
|
|
424
424
|
return pe(), ge(
|
|
425
425
|
q,
|
|
426
426
|
null,
|
|
427
|
-
[ue("slot",
|
|
428
|
-
|
|
427
|
+
[ue("slot", n, i)],
|
|
428
|
+
h ? -2 : 64
|
|
429
429
|
);
|
|
430
430
|
}
|
|
431
431
|
let o = t[e];
|
|
432
432
|
process.env.NODE_ENV !== "production" && o && o.length > 1 && (_(
|
|
433
433
|
"SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template."
|
|
434
434
|
), o = () => []), o && o._c && (o._d = !1), pe();
|
|
435
|
-
const r = o && Re(o(
|
|
435
|
+
const r = o && Re(o(n)), a = n.key || // slot content array of a dynamic conditional slot may have a branch
|
|
436
436
|
// key attached in the `createSlots` helper, respect that
|
|
437
437
|
r && r.key, c = ge(
|
|
438
438
|
q,
|
|
439
439
|
{
|
|
440
|
-
key: (a && !
|
|
441
|
-
(!r &&
|
|
440
|
+
key: (a && !ve(a) ? a : `_${e}`) + // #7256 force differentiate fallback content from actual content
|
|
441
|
+
(!r && i ? "_fb" : "")
|
|
442
442
|
},
|
|
443
443
|
r || [],
|
|
444
444
|
r && t._ === 1 ? 64 : -2
|
|
@@ -453,7 +453,7 @@ process.env.NODE_ENV !== "production" && (yt.ownKeys = (t) => (_(
|
|
|
453
453
|
"Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."
|
|
454
454
|
), Reflect.ownKeys(t)));
|
|
455
455
|
let bt = null;
|
|
456
|
-
const
|
|
456
|
+
const wt = {}, Le = (t) => Object.getPrototypeOf(t) === wt, vt = (t) => t.__isSuspense, q = /* @__PURE__ */ Symbol.for("v-fgt"), xt = /* @__PURE__ */ Symbol.for("v-txt"), Te = /* @__PURE__ */ Symbol.for("v-cmt"), K = [];
|
|
457
457
|
let E = null;
|
|
458
458
|
function pe(t = !1) {
|
|
459
459
|
K.push(E = t ? null : []);
|
|
@@ -464,13 +464,13 @@ function St() {
|
|
|
464
464
|
function Ct(t) {
|
|
465
465
|
return t.dynamicChildren = E || qe, St(), E && E.push(t), t;
|
|
466
466
|
}
|
|
467
|
-
function ge(t, e,
|
|
467
|
+
function ge(t, e, n, i, s) {
|
|
468
468
|
return Ct(
|
|
469
469
|
ue(
|
|
470
470
|
t,
|
|
471
471
|
e,
|
|
472
|
-
i,
|
|
473
472
|
n,
|
|
473
|
+
i,
|
|
474
474
|
s,
|
|
475
475
|
!0
|
|
476
476
|
)
|
|
@@ -479,14 +479,14 @@ function ge(t, e, i, n, s) {
|
|
|
479
479
|
function Oe(t) {
|
|
480
480
|
return t ? t.__v_isVNode === !0 : !1;
|
|
481
481
|
}
|
|
482
|
-
const Et = (...t) =>
|
|
482
|
+
const Et = (...t) => Pe(
|
|
483
483
|
...t
|
|
484
484
|
), Me = ({ key: t }) => t ?? null, Y = ({
|
|
485
485
|
ref: t,
|
|
486
486
|
ref_key: e,
|
|
487
|
-
ref_for:
|
|
488
|
-
}) => (typeof t == "number" && (t = "" + t), t != null ? T(t) || ce(t) || R(t) ? { i: N, r: t, k: e, f: !!
|
|
489
|
-
function kt(t, e = null,
|
|
487
|
+
ref_for: n
|
|
488
|
+
}) => (typeof t == "number" && (t = "" + t), t != null ? T(t) || ce(t) || R(t) ? { i: N, r: t, k: e, f: !!n } : t : null);
|
|
489
|
+
function kt(t, e = null, n = null, i = 0, s = null, o = t === q ? 0 : 1, r = !1, a = !1) {
|
|
490
490
|
const c = {
|
|
491
491
|
__v_isVNode: !0,
|
|
492
492
|
__v_skip: !0,
|
|
@@ -496,7 +496,7 @@ function kt(t, e = null, i = null, n = 0, s = null, o = t === q ? 0 : 1, r = !1,
|
|
|
496
496
|
ref: e && Y(e),
|
|
497
497
|
scopeId: ct,
|
|
498
498
|
slotScopeIds: null,
|
|
499
|
-
children:
|
|
499
|
+
children: n,
|
|
500
500
|
component: null,
|
|
501
501
|
suspense: null,
|
|
502
502
|
ssContent: null,
|
|
@@ -510,13 +510,13 @@ function kt(t, e = null, i = null, n = 0, s = null, o = t === q ? 0 : 1, r = !1,
|
|
|
510
510
|
targetAnchor: null,
|
|
511
511
|
staticCount: 0,
|
|
512
512
|
shapeFlag: o,
|
|
513
|
-
patchFlag:
|
|
513
|
+
patchFlag: i,
|
|
514
514
|
dynamicProps: s,
|
|
515
515
|
dynamicChildren: null,
|
|
516
516
|
appContext: null,
|
|
517
517
|
ctx: N
|
|
518
518
|
};
|
|
519
|
-
return a ? (fe(c,
|
|
519
|
+
return a ? (fe(c, n), o & 128 && t.normalize(c)) : n && (c.shapeFlag |= T(n) ? 8 : 16), process.env.NODE_ENV !== "production" && c.key !== c.key && _("VNode created with invalid key (NaN). VNode type:", c.type), // avoid a block node from tracking itself
|
|
520
520
|
!r && // has current parent block
|
|
521
521
|
E && // presence of a patch flag indicates this node needs patching on updates.
|
|
522
522
|
// component nodes also should always be patched, because even if the
|
|
@@ -526,8 +526,8 @@ function kt(t, e = null, i = null, n = 0, s = null, o = t === q ? 0 : 1, r = !1,
|
|
|
526
526
|
// vnode should not be considered dynamic due to handler caching.
|
|
527
527
|
c.patchFlag !== 32 && E.push(c), c;
|
|
528
528
|
}
|
|
529
|
-
const ue = process.env.NODE_ENV !== "production" ? Et :
|
|
530
|
-
function
|
|
529
|
+
const ue = process.env.NODE_ENV !== "production" ? Et : Pe;
|
|
530
|
+
function Pe(t, e = null, n = null, i = 0, s = null, o = !1) {
|
|
531
531
|
if ((!t || t === pt) && (process.env.NODE_ENV !== "production" && !t && _(`Invalid vnode type when creating vnode: ${t}.`), t = Te), Oe(t)) {
|
|
532
532
|
const a = X(
|
|
533
533
|
t,
|
|
@@ -535,14 +535,14 @@ function Ve(t, e = null, i = null, n = 0, s = null, o = !1) {
|
|
|
535
535
|
!0
|
|
536
536
|
/* mergeRef: true */
|
|
537
537
|
);
|
|
538
|
-
return
|
|
538
|
+
return n && fe(a, n), !o && E && (a.shapeFlag & 6 ? E[E.indexOf(t)] = a : E.push(a)), a.patchFlag = -2, a;
|
|
539
539
|
}
|
|
540
540
|
if ($e(t) && (t = t.__vccOpts), e) {
|
|
541
541
|
e = _t(e);
|
|
542
542
|
let { class: a, style: c } = e;
|
|
543
543
|
a && !T(a) && (e.class = le(a)), O(c) && (oe(c) && !k(c) && (c = z({}, c)), e.style = ae(c));
|
|
544
544
|
}
|
|
545
|
-
const r = T(t) ? 1 :
|
|
545
|
+
const r = T(t) ? 1 : vt(t) ? 128 : ft(t) ? 64 : O(t) ? 4 : R(t) ? 2 : 0;
|
|
546
546
|
return process.env.NODE_ENV !== "production" && r & 4 && oe(t) && (t = M(t), _(
|
|
547
547
|
"Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.",
|
|
548
548
|
`
|
|
@@ -551,8 +551,8 @@ Component that was made reactive: `,
|
|
|
551
551
|
)), kt(
|
|
552
552
|
t,
|
|
553
553
|
e,
|
|
554
|
-
i,
|
|
555
554
|
n,
|
|
555
|
+
i,
|
|
556
556
|
s,
|
|
557
557
|
r,
|
|
558
558
|
o,
|
|
@@ -562,22 +562,22 @@ Component that was made reactive: `,
|
|
|
562
562
|
function _t(t) {
|
|
563
563
|
return t ? oe(t) || Le(t) ? z({}, t) : t : null;
|
|
564
564
|
}
|
|
565
|
-
function X(t, e,
|
|
566
|
-
const { props: s, ref: o, patchFlag: r, children: a, transition: c } = t,
|
|
565
|
+
function X(t, e, n = !1, i = !1) {
|
|
566
|
+
const { props: s, ref: o, patchFlag: r, children: a, transition: c } = t, h = e ? At(s || {}, e) : s, d = {
|
|
567
567
|
__v_isVNode: !0,
|
|
568
568
|
__v_skip: !0,
|
|
569
569
|
type: t.type,
|
|
570
|
-
props:
|
|
571
|
-
key:
|
|
570
|
+
props: h,
|
|
571
|
+
key: h && Me(h),
|
|
572
572
|
ref: e && e.ref ? (
|
|
573
573
|
// #2078 in the case of <component :is="vnode" ref="extra"/>
|
|
574
574
|
// if the vnode itself already has a ref, cloneVNode will need to merge
|
|
575
575
|
// the refs so the single vnode can be set on multiple refs
|
|
576
|
-
|
|
576
|
+
n && o ? k(o) ? o.concat(Y(e)) : [o, Y(e)] : Y(e)
|
|
577
577
|
) : o,
|
|
578
578
|
scopeId: t.scopeId,
|
|
579
579
|
slotScopeIds: t.slotScopeIds,
|
|
580
|
-
children: process.env.NODE_ENV !== "production" && r === -1 && k(a) ? a.map(
|
|
580
|
+
children: process.env.NODE_ENV !== "production" && r === -1 && k(a) ? a.map(Ve) : a,
|
|
581
581
|
target: t.target,
|
|
582
582
|
targetStart: t.targetStart,
|
|
583
583
|
targetAnchor: t.targetAnchor,
|
|
@@ -607,66 +607,66 @@ function X(t, e, i = !1, n = !1) {
|
|
|
607
607
|
ctx: t.ctx,
|
|
608
608
|
ce: t.ce
|
|
609
609
|
};
|
|
610
|
-
return c &&
|
|
610
|
+
return c && i && Ne(
|
|
611
611
|
d,
|
|
612
612
|
c.clone(d)
|
|
613
613
|
), d;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
615
|
+
function Ve(t) {
|
|
616
616
|
const e = X(t);
|
|
617
|
-
return k(t.children) && (e.children = t.children.map(
|
|
617
|
+
return k(t.children) && (e.children = t.children.map(Ve)), e;
|
|
618
618
|
}
|
|
619
619
|
function It(t = " ", e = 0) {
|
|
620
620
|
return ue(xt, null, t, e);
|
|
621
621
|
}
|
|
622
622
|
function fe(t, e) {
|
|
623
|
-
let
|
|
624
|
-
const { shapeFlag:
|
|
623
|
+
let n = 0;
|
|
624
|
+
const { shapeFlag: i } = t;
|
|
625
625
|
if (e == null)
|
|
626
626
|
e = null;
|
|
627
627
|
else if (k(e))
|
|
628
|
-
|
|
628
|
+
n = 16;
|
|
629
629
|
else if (typeof e == "object")
|
|
630
|
-
if (
|
|
630
|
+
if (i & 65) {
|
|
631
631
|
const s = e.default;
|
|
632
632
|
s && (s._c && (s._d = !1), fe(t, s()), s._c && (s._d = !0));
|
|
633
633
|
return;
|
|
634
634
|
} else
|
|
635
|
-
|
|
636
|
-
else R(e) ? (e = { default: e, _ctx: N },
|
|
637
|
-
t.children = e, t.shapeFlag |=
|
|
635
|
+
n = 32, !e._ && !Le(e) && (e._ctx = N);
|
|
636
|
+
else R(e) ? (e = { default: e, _ctx: N }, n = 32) : (e = String(e), i & 64 ? (n = 16, e = [It(e)]) : n = 8);
|
|
637
|
+
t.children = e, t.shapeFlag |= n;
|
|
638
638
|
}
|
|
639
639
|
function At(...t) {
|
|
640
640
|
const e = {};
|
|
641
|
-
for (let
|
|
642
|
-
const
|
|
643
|
-
for (const s in
|
|
641
|
+
for (let n = 0; n < t.length; n++) {
|
|
642
|
+
const i = t[n];
|
|
643
|
+
for (const s in i)
|
|
644
644
|
if (s === "class")
|
|
645
|
-
e.class !==
|
|
645
|
+
e.class !== i.class && (e.class = le([e.class, i.class]));
|
|
646
646
|
else if (s === "style")
|
|
647
|
-
e.style = ae([e.style,
|
|
647
|
+
e.style = ae([e.style, i.style]);
|
|
648
648
|
else if (ze(s)) {
|
|
649
|
-
const o = e[s], r =
|
|
649
|
+
const o = e[s], r = i[s];
|
|
650
650
|
r && o !== r && !(k(o) && o.includes(r)) && (e[s] = o ? [].concat(o, r) : r);
|
|
651
|
-
} else s !== "" && (e[s] =
|
|
651
|
+
} else s !== "" && (e[s] = i[s]);
|
|
652
652
|
}
|
|
653
653
|
return e;
|
|
654
654
|
}
|
|
655
655
|
let A = null;
|
|
656
656
|
const Nt = () => A || N;
|
|
657
657
|
{
|
|
658
|
-
const t =
|
|
658
|
+
const t = Q(), e = (n, i) => {
|
|
659
659
|
let s;
|
|
660
|
-
return (s = t[
|
|
660
|
+
return (s = t[n]) || (s = t[n] = []), s.push(i), (o) => {
|
|
661
661
|
s.length > 1 ? s.forEach((r) => r(o)) : s[0](o);
|
|
662
662
|
};
|
|
663
663
|
};
|
|
664
664
|
e(
|
|
665
665
|
"__VUE_INSTANCE_SETTERS__",
|
|
666
|
-
(
|
|
666
|
+
(n) => A = n
|
|
667
667
|
), e(
|
|
668
668
|
"__VUE_SSR_SETTERS__",
|
|
669
|
-
(
|
|
669
|
+
(n) => n
|
|
670
670
|
);
|
|
671
671
|
}
|
|
672
672
|
process.env.NODE_ENV;
|
|
@@ -674,23 +674,23 @@ const Rt = /(?:^|[-_])\w/g, Lt = (t) => t.replace(Rt, (e) => e.toUpperCase()).re
|
|
|
674
674
|
function Fe(t, e = !0) {
|
|
675
675
|
return R(t) ? t.displayName || t.name : t.name || e && t.__name;
|
|
676
676
|
}
|
|
677
|
-
function De(t, e,
|
|
678
|
-
let
|
|
679
|
-
if (!
|
|
677
|
+
function De(t, e, n = !1) {
|
|
678
|
+
let i = Fe(e);
|
|
679
|
+
if (!i && e.__file) {
|
|
680
680
|
const s = e.__file.match(/([^/\\]+)\.\w+$/);
|
|
681
|
-
s && (
|
|
681
|
+
s && (i = s[1]);
|
|
682
682
|
}
|
|
683
|
-
if (!
|
|
683
|
+
if (!i && t) {
|
|
684
684
|
const s = (o) => {
|
|
685
685
|
for (const r in o)
|
|
686
686
|
if (o[r] === e)
|
|
687
687
|
return r;
|
|
688
688
|
};
|
|
689
|
-
|
|
689
|
+
i = s(t.components) || t.parent && s(
|
|
690
690
|
t.parent.type.components
|
|
691
691
|
) || s(t.appContext.components);
|
|
692
692
|
}
|
|
693
|
-
return
|
|
693
|
+
return i ? Lt(i) : n ? "App" : "Anonymous";
|
|
694
694
|
}
|
|
695
695
|
function $e(t) {
|
|
696
696
|
return R(t) && "__vccOpts" in t;
|
|
@@ -698,7 +698,7 @@ function $e(t) {
|
|
|
698
698
|
function Tt() {
|
|
699
699
|
if (process.env.NODE_ENV === "production" || typeof window > "u")
|
|
700
700
|
return;
|
|
701
|
-
const t = { style: "color:#3ba776" }, e = { style: "color:#1677ff" },
|
|
701
|
+
const t = { style: "color:#3ba776" }, e = { style: "color:#1677ff" }, n = { style: "color:#f5222d" }, i = { style: "color:#eb2f96" }, s = {
|
|
702
702
|
__vue_custom_formatter: !0,
|
|
703
703
|
header(l) {
|
|
704
704
|
if (!O(l))
|
|
@@ -720,7 +720,7 @@ function Tt() {
|
|
|
720
720
|
return [
|
|
721
721
|
"div",
|
|
722
722
|
{},
|
|
723
|
-
["span", t,
|
|
723
|
+
["span", t, Z(l) ? "ShallowReactive" : "Reactive"],
|
|
724
724
|
"<",
|
|
725
725
|
a(l),
|
|
726
726
|
`>${se(l) ? " (readonly)" : ""}`
|
|
@@ -729,7 +729,7 @@ function Tt() {
|
|
|
729
729
|
return [
|
|
730
730
|
"div",
|
|
731
731
|
{},
|
|
732
|
-
["span", t,
|
|
732
|
+
["span", t, Z(l) ? "ShallowReadonly" : "Readonly"],
|
|
733
733
|
"<",
|
|
734
734
|
a(l),
|
|
735
735
|
">"
|
|
@@ -751,9 +751,9 @@ function Tt() {
|
|
|
751
751
|
};
|
|
752
752
|
function o(l) {
|
|
753
753
|
const f = [];
|
|
754
|
-
l.type.props && l.props && f.push(r("props", M(l.props))), l.setupState !==
|
|
755
|
-
const
|
|
756
|
-
|
|
754
|
+
l.type.props && l.props && f.push(r("props", M(l.props))), l.setupState !== ie && f.push(r("setup", l.setupState)), l.data !== ie && f.push(r("data", M(l.data)));
|
|
755
|
+
const m = c(l, "computed");
|
|
756
|
+
m && f.push(r("computed", m));
|
|
757
757
|
const y = c(l, "inject");
|
|
758
758
|
return y && f.push(r("injected", y)), f.push([
|
|
759
759
|
"div",
|
|
@@ -761,7 +761,7 @@ function Tt() {
|
|
|
761
761
|
[
|
|
762
762
|
"span",
|
|
763
763
|
{
|
|
764
|
-
style:
|
|
764
|
+
style: i.style + ";opacity:0.66"
|
|
765
765
|
},
|
|
766
766
|
"$ (internal): "
|
|
767
767
|
],
|
|
@@ -784,34 +784,34 @@ function Tt() {
|
|
|
784
784
|
{
|
|
785
785
|
style: "padding-left:1.25em"
|
|
786
786
|
},
|
|
787
|
-
...Object.keys(f).map((
|
|
787
|
+
...Object.keys(f).map((m) => [
|
|
788
788
|
"div",
|
|
789
789
|
{},
|
|
790
|
-
["span",
|
|
791
|
-
a(f[
|
|
790
|
+
["span", i, m + ": "],
|
|
791
|
+
a(f[m], !1)
|
|
792
792
|
])
|
|
793
793
|
]
|
|
794
794
|
] : ["span", {}];
|
|
795
795
|
}
|
|
796
796
|
function a(l, f = !0) {
|
|
797
|
-
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span",
|
|
797
|
+
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span", n, JSON.stringify(l)] : typeof l == "boolean" ? ["span", i, l] : O(l) ? ["object", { object: f ? M(l) : l }] : ["span", n, String(l)];
|
|
798
798
|
}
|
|
799
799
|
function c(l, f) {
|
|
800
|
-
const
|
|
801
|
-
if (R(
|
|
800
|
+
const m = l.type;
|
|
801
|
+
if (R(m))
|
|
802
802
|
return;
|
|
803
803
|
const y = {};
|
|
804
804
|
for (const u in l.ctx)
|
|
805
|
-
m
|
|
805
|
+
h(m, u, f) && (y[u] = l.ctx[u]);
|
|
806
806
|
return y;
|
|
807
807
|
}
|
|
808
|
-
function
|
|
809
|
-
const y = l[
|
|
810
|
-
if (k(y) && y.includes(f) || O(y) && f in y || l.extends &&
|
|
808
|
+
function h(l, f, m) {
|
|
809
|
+
const y = l[m];
|
|
810
|
+
if (k(y) && y.includes(f) || O(y) && f in y || l.extends && h(l.extends, f, m) || l.mixins && l.mixins.some((u) => h(u, f, m)))
|
|
811
811
|
return !0;
|
|
812
812
|
}
|
|
813
813
|
function d(l) {
|
|
814
|
-
return
|
|
814
|
+
return Z(l) ? "ShallowRef" : l.effect ? "ComputedRef" : "Ref";
|
|
815
815
|
}
|
|
816
816
|
window.devtoolsFormatters ? window.devtoolsFormatters.push(s) : window.devtoolsFormatters = [s];
|
|
817
817
|
}
|
|
@@ -831,18 +831,18 @@ class ye {
|
|
|
831
831
|
constructor(e) {
|
|
832
832
|
this.endpoint = e || "https://foisit-ninja.netlify.app/.netlify/functions/intent";
|
|
833
833
|
}
|
|
834
|
-
async determineIntent(e,
|
|
834
|
+
async determineIntent(e, n, i) {
|
|
835
835
|
try {
|
|
836
836
|
const s = {
|
|
837
837
|
userInput: e,
|
|
838
|
-
commands:
|
|
838
|
+
commands: n.map((a) => ({
|
|
839
839
|
id: a.id,
|
|
840
840
|
command: a.command,
|
|
841
841
|
description: a.description,
|
|
842
842
|
parameters: a.parameters
|
|
843
843
|
// Send param schemas to AI
|
|
844
844
|
})),
|
|
845
|
-
context:
|
|
845
|
+
context: i
|
|
846
846
|
}, o = await fetch(this.endpoint, {
|
|
847
847
|
method: "POST",
|
|
848
848
|
headers: {
|
|
@@ -867,19 +867,19 @@ class Mt {
|
|
|
867
867
|
this.enableSmartIntent = e.enableSmartIntent ?? !0, this.enableSmartIntent && (this.openAIService = new ye(e.intentEndpoint));
|
|
868
868
|
}
|
|
869
869
|
/** Add a new command (string or object) */
|
|
870
|
-
addCommand(e,
|
|
871
|
-
let
|
|
870
|
+
addCommand(e, n) {
|
|
871
|
+
let i;
|
|
872
872
|
if (typeof e == "string") {
|
|
873
|
-
if (!
|
|
873
|
+
if (!n)
|
|
874
874
|
throw new Error("Action required when adding command by string.");
|
|
875
|
-
|
|
875
|
+
i = {
|
|
876
876
|
id: e.toLowerCase().replace(/\s+/g, "_"),
|
|
877
877
|
command: e.toLowerCase(),
|
|
878
|
-
action:
|
|
878
|
+
action: n
|
|
879
879
|
};
|
|
880
880
|
} else
|
|
881
|
-
|
|
882
|
-
this.commands.set(
|
|
881
|
+
i = { ...e }, i.id || (i.id = i.command.toLowerCase().replace(/\s+/g, "_"));
|
|
882
|
+
this.commands.set(i.command.toLowerCase(), i), i.id && (i.id, i.command);
|
|
883
883
|
}
|
|
884
884
|
/** Remove an existing command */
|
|
885
885
|
removeCommand(e) {
|
|
@@ -889,13 +889,13 @@ class Mt {
|
|
|
889
889
|
async executeCommand(e) {
|
|
890
890
|
if (typeof e == "object" && e !== null) {
|
|
891
891
|
if (this.isStructured(e)) {
|
|
892
|
-
const c = String(e.commandId),
|
|
892
|
+
const c = String(e.commandId), h = e.params ?? {}, d = this.getCommandById(c);
|
|
893
893
|
if (!d) return { message: "That command is not available.", type: "error" };
|
|
894
|
-
const l = this.sanitizeParamsForCommand(d,
|
|
895
|
-
return
|
|
894
|
+
const l = this.sanitizeParamsForCommand(d, h), m = (d.parameters ?? []).filter((y) => y.required).filter((y) => l[y.name] == null || l[y.name] === "");
|
|
895
|
+
return m.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(d), params: l }, {
|
|
896
896
|
message: `Please provide the required details for "${d.command}".`,
|
|
897
897
|
type: "form",
|
|
898
|
-
fields:
|
|
898
|
+
fields: m
|
|
899
899
|
}) : d.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(d), params: l }, this.buildConfirmResponse(d)) : this.safeRunAction(d, l);
|
|
900
900
|
}
|
|
901
901
|
if (!this.context)
|
|
@@ -917,16 +917,16 @@ class Mt {
|
|
|
917
917
|
const a = await this.safeRunAction(o, r);
|
|
918
918
|
return this.context = null, this.normalizeResponse(a);
|
|
919
919
|
}
|
|
920
|
-
const
|
|
920
|
+
const n = e.trim().toLowerCase();
|
|
921
921
|
if (this.pendingConfirmation) {
|
|
922
|
-
const o =
|
|
922
|
+
const o = n;
|
|
923
923
|
if (["yes", "y", "confirm", "ok", "okay"].includes(o)) {
|
|
924
924
|
const { commandId: r, params: a } = this.pendingConfirmation;
|
|
925
925
|
this.pendingConfirmation = null;
|
|
926
926
|
const c = this.getCommandById(r);
|
|
927
927
|
return c ? this.safeRunAction(c, a) : { message: "That action is no longer available.", type: "error" };
|
|
928
928
|
}
|
|
929
|
-
return ["no", "n", "cancel", "stop"].includes(o) ? (this.pendingConfirmation = null, { message: "
|
|
929
|
+
return ["no", "n", "cancel", "stop"].includes(o) ? (this.pendingConfirmation = null, { message: "Cancelled.", type: "success" }) : {
|
|
930
930
|
message: "Please confirm: Yes or No.",
|
|
931
931
|
type: "confirm",
|
|
932
932
|
options: [
|
|
@@ -935,20 +935,20 @@ class Mt {
|
|
|
935
935
|
]
|
|
936
936
|
};
|
|
937
937
|
}
|
|
938
|
-
const
|
|
939
|
-
if (
|
|
940
|
-
const o =
|
|
938
|
+
const i = this.commands.get(n);
|
|
939
|
+
if (i) {
|
|
940
|
+
const o = i, r = (o.parameters ?? []).filter((a) => a.required);
|
|
941
941
|
return r.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
942
942
|
message: `Please provide the required details for "${o.command}".`,
|
|
943
943
|
type: "form",
|
|
944
944
|
fields: r
|
|
945
945
|
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
946
946
|
}
|
|
947
|
-
const s = await this.tryDeterministicMatch(
|
|
947
|
+
const s = await this.tryDeterministicMatch(n);
|
|
948
948
|
if (s) return s;
|
|
949
949
|
if (this.enableSmartIntent && this.openAIService) {
|
|
950
950
|
const o = await this.getCommandsForAI(), r = await this.openAIService.determineIntent(
|
|
951
|
-
|
|
951
|
+
n,
|
|
952
952
|
o,
|
|
953
953
|
this.context
|
|
954
954
|
);
|
|
@@ -958,64 +958,114 @@ class Mt {
|
|
|
958
958
|
}
|
|
959
959
|
async handleAIResult(e) {
|
|
960
960
|
if (e.type === "match" && e.match) {
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
961
|
+
const n = this.getCommandById(e.match);
|
|
962
|
+
if (!n)
|
|
963
963
|
return { message: "I'm not sure what you mean.", type: "error" };
|
|
964
|
-
const
|
|
965
|
-
if (e.incomplete ||
|
|
966
|
-
this.context = { commandId: this.getCommandIdentifier(
|
|
967
|
-
|
|
968
|
-
if (r.length <= 2 && !c) {
|
|
969
|
-
const m = r.map((d) => d.name).join(" and ");
|
|
964
|
+
const i = e.params ?? {}, s = this.sanitizeParamsForCommand(n, i), o = n.allowAiParamExtraction === !1 ? {} : s, a = (n.parameters ?? []).filter((h) => h.required).filter((h) => o[h.name] == null || o[h.name] === "");
|
|
965
|
+
if (e.incomplete || a.length > 0) {
|
|
966
|
+
if (this.context = { commandId: this.getCommandIdentifier(n), params: o }, !(n.collectRequiredViaForm !== !1) && this.shouldAskSingleQuestion(a)) {
|
|
967
|
+
const l = a.map((f) => f.name).join(" and ");
|
|
970
968
|
return {
|
|
971
|
-
message: e.message || `Please provide ${
|
|
969
|
+
message: e.message || `Please provide ${l}.`,
|
|
972
970
|
type: "question"
|
|
973
971
|
};
|
|
974
972
|
}
|
|
975
973
|
return {
|
|
976
|
-
message: e.message || `Please fill in the missing details for "${
|
|
974
|
+
message: e.message || `Please fill in the missing details for "${n.command}".`,
|
|
977
975
|
type: "form",
|
|
978
|
-
fields:
|
|
976
|
+
fields: a
|
|
979
977
|
};
|
|
980
978
|
}
|
|
981
|
-
if (
|
|
979
|
+
if (n.critical)
|
|
982
980
|
return this.pendingConfirmation = {
|
|
983
|
-
commandId: this.getCommandIdentifier(
|
|
984
|
-
params:
|
|
985
|
-
}, this.buildConfirmResponse(
|
|
986
|
-
const
|
|
987
|
-
return this.normalizeResponse(
|
|
981
|
+
commandId: this.getCommandIdentifier(n),
|
|
982
|
+
params: o
|
|
983
|
+
}, this.buildConfirmResponse(n);
|
|
984
|
+
const c = await n.action(o);
|
|
985
|
+
return this.normalizeResponse(c);
|
|
988
986
|
}
|
|
989
987
|
return e.type === "ambiguous" && e.options && e.options.length ? {
|
|
990
988
|
message: e.message || "Did you mean one of these?",
|
|
991
989
|
type: "ambiguous",
|
|
992
|
-
options: e.options.map((
|
|
993
|
-
label:
|
|
994
|
-
value:
|
|
995
|
-
commandId:
|
|
990
|
+
options: e.options.map((n) => ({
|
|
991
|
+
label: n.label,
|
|
992
|
+
value: n.commandId ?? n.label,
|
|
993
|
+
commandId: n.commandId
|
|
996
994
|
}))
|
|
997
995
|
} : this.listAllCommands();
|
|
998
996
|
}
|
|
999
|
-
sanitizeParamsForCommand(e,
|
|
1000
|
-
const
|
|
1001
|
-
for (const s of e.parameters ?? [])
|
|
997
|
+
sanitizeParamsForCommand(e, n) {
|
|
998
|
+
const i = { ...n ?? {} };
|
|
999
|
+
for (const s of e.parameters ?? []) {
|
|
1000
|
+
const o = i[s.name];
|
|
1001
|
+
if (s.type === "string") {
|
|
1002
|
+
if (typeof o != "string") {
|
|
1003
|
+
delete i[s.name];
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
1006
|
+
const r = o.trim();
|
|
1007
|
+
if (!r) {
|
|
1008
|
+
delete i[s.name];
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
1011
|
+
i[s.name] = r;
|
|
1012
|
+
}
|
|
1013
|
+
if (s.type === "number") {
|
|
1014
|
+
const r = typeof o == "number" ? o : Number(o == null ? void 0 : o.toString().trim());
|
|
1015
|
+
if (Number.isNaN(r)) {
|
|
1016
|
+
delete i[s.name];
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
if (typeof s.min == "number" && r < s.min) {
|
|
1020
|
+
delete i[s.name];
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1023
|
+
if (typeof s.max == "number" && r > s.max) {
|
|
1024
|
+
delete i[s.name];
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
1027
|
+
i[s.name] = r;
|
|
1028
|
+
}
|
|
1002
1029
|
if (s.type === "date") {
|
|
1003
|
-
const
|
|
1004
|
-
if (typeof
|
|
1005
|
-
const
|
|
1006
|
-
this.isIsoDateString(
|
|
1030
|
+
const r = i[s.name];
|
|
1031
|
+
if (typeof r == "string") {
|
|
1032
|
+
const a = r.trim();
|
|
1033
|
+
this.isIsoDateString(a) ? i[s.name] = a : delete i[s.name];
|
|
1034
|
+
} else
|
|
1035
|
+
delete i[s.name];
|
|
1036
|
+
}
|
|
1037
|
+
if (s.type === "select") {
|
|
1038
|
+
const r = typeof o == "string" ? o : o == null ? void 0 : o.toString();
|
|
1039
|
+
if (!r) {
|
|
1040
|
+
delete i[s.name];
|
|
1041
|
+
continue;
|
|
1007
1042
|
}
|
|
1043
|
+
if (Array.isArray(s.options) && s.options.length > 0 && !s.options.some((c) => String(c.value) === String(r))) {
|
|
1044
|
+
delete i[s.name];
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
i[s.name] = r;
|
|
1048
|
+
}
|
|
1049
|
+
if (s.type === "file") {
|
|
1050
|
+
const r = i[s.name], a = r && typeof r == "object" && typeof r.name == "string" && typeof r.size == "number", c = typeof r == "string" && /^data:[^;]+;base64,/.test(r);
|
|
1051
|
+
(s.delivery ?? "file") === "base64" ? !c && !a && delete i[s.name] : a || delete i[s.name];
|
|
1008
1052
|
}
|
|
1009
|
-
|
|
1053
|
+
}
|
|
1054
|
+
return i;
|
|
1010
1055
|
}
|
|
1011
1056
|
isIsoDateString(e) {
|
|
1012
1057
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
|
|
1013
|
-
const
|
|
1014
|
-
return !Number.isNaN(
|
|
1058
|
+
const n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
1059
|
+
return !Number.isNaN(n.getTime());
|
|
1060
|
+
}
|
|
1061
|
+
shouldAskSingleQuestion(e) {
|
|
1062
|
+
if (e.length !== 1) return !1;
|
|
1063
|
+
const n = e[0].type;
|
|
1064
|
+
return n === "string" || n === "number" || n === "date";
|
|
1015
1065
|
}
|
|
1016
1066
|
buildConfirmResponse(e) {
|
|
1017
1067
|
return {
|
|
1018
|
-
message:
|
|
1068
|
+
message: `Are you sure you want to run "${e.command}"?`,
|
|
1019
1069
|
type: "confirm",
|
|
1020
1070
|
options: [
|
|
1021
1071
|
{ label: "Yes", value: "yes" },
|
|
@@ -1024,21 +1074,21 @@ class Mt {
|
|
|
1024
1074
|
};
|
|
1025
1075
|
}
|
|
1026
1076
|
async tryDeterministicMatch(e) {
|
|
1027
|
-
const
|
|
1077
|
+
const n = [];
|
|
1028
1078
|
for (const a of this.commands.values()) {
|
|
1029
1079
|
let c = 0;
|
|
1030
|
-
const
|
|
1031
|
-
e.includes(
|
|
1080
|
+
const h = a.command.toLowerCase();
|
|
1081
|
+
e.includes(h) && (c += 5);
|
|
1032
1082
|
const d = a.keywords ?? [];
|
|
1033
1083
|
for (const l of d) {
|
|
1034
1084
|
const f = l.toLowerCase().trim();
|
|
1035
1085
|
f && (e === f ? c += 4 : e.includes(f) && (c += 3));
|
|
1036
1086
|
}
|
|
1037
|
-
c > 0 &&
|
|
1087
|
+
c > 0 && n.push({ cmd: a, score: c });
|
|
1038
1088
|
}
|
|
1039
|
-
if (
|
|
1040
|
-
|
|
1041
|
-
const
|
|
1089
|
+
if (n.length === 0) return null;
|
|
1090
|
+
n.sort((a, c) => c.score - a.score);
|
|
1091
|
+
const i = n[0].score, s = n.filter((a) => a.score === i).slice(0, 3);
|
|
1042
1092
|
if (s.length > 1)
|
|
1043
1093
|
return {
|
|
1044
1094
|
message: "I think you mean one of these. Which one should I run?",
|
|
@@ -1056,32 +1106,32 @@ class Mt {
|
|
|
1056
1106
|
fields: r
|
|
1057
1107
|
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
1058
1108
|
}
|
|
1059
|
-
async safeRunAction(e,
|
|
1109
|
+
async safeRunAction(e, n) {
|
|
1060
1110
|
try {
|
|
1061
|
-
const
|
|
1062
|
-
return this.normalizeResponse(
|
|
1111
|
+
const i = await e.action(n ?? {});
|
|
1112
|
+
return this.normalizeResponse(i);
|
|
1063
1113
|
} catch {
|
|
1064
1114
|
return { message: "Something went wrong while running that command.", type: "error" };
|
|
1065
1115
|
}
|
|
1066
1116
|
}
|
|
1067
1117
|
async getCommandsForAI() {
|
|
1068
|
-
const e = Array.from(this.commands.values()).map((
|
|
1069
|
-
...
|
|
1070
|
-
parameters:
|
|
1118
|
+
const e = Array.from(this.commands.values()).map((n) => ({
|
|
1119
|
+
...n,
|
|
1120
|
+
parameters: n.parameters ? n.parameters.map((i) => ({ ...i })) : void 0
|
|
1071
1121
|
}));
|
|
1072
1122
|
return await Promise.all(
|
|
1073
|
-
e.map(async (
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
if (
|
|
1077
|
-
const s = `${
|
|
1123
|
+
e.map(async (n) => {
|
|
1124
|
+
n.parameters && await Promise.all(
|
|
1125
|
+
n.parameters.map(async (i) => {
|
|
1126
|
+
if (i.type !== "select" || !i.getOptions || i.options && i.options.length) return;
|
|
1127
|
+
const s = `${n.id ?? n.command}:${i.name}`, o = this.selectOptionsCache.get(s), r = Date.now();
|
|
1078
1128
|
if (o && r - o.ts < 6e4) {
|
|
1079
|
-
|
|
1129
|
+
i.options = o.options;
|
|
1080
1130
|
return;
|
|
1081
1131
|
}
|
|
1082
1132
|
try {
|
|
1083
|
-
const a = await
|
|
1084
|
-
this.selectOptionsCache.set(s, { options: a, ts: r }),
|
|
1133
|
+
const a = await i.getOptions();
|
|
1134
|
+
this.selectOptionsCache.set(s, { options: a, ts: r }), i.options = a;
|
|
1085
1135
|
} catch {
|
|
1086
1136
|
}
|
|
1087
1137
|
})
|
|
@@ -1090,17 +1140,17 @@ class Mt {
|
|
|
1090
1140
|
), e;
|
|
1091
1141
|
}
|
|
1092
1142
|
getCommandById(e) {
|
|
1093
|
-
for (const
|
|
1094
|
-
if (
|
|
1143
|
+
for (const n of this.commands.values())
|
|
1144
|
+
if (n.id === e) return n;
|
|
1095
1145
|
}
|
|
1096
1146
|
listAllCommands() {
|
|
1097
1147
|
return {
|
|
1098
1148
|
message: "Here are the available commands:",
|
|
1099
1149
|
type: "ambiguous",
|
|
1100
|
-
options: Array.from(this.commands.values()).map((
|
|
1101
|
-
label:
|
|
1102
|
-
value:
|
|
1103
|
-
commandId:
|
|
1150
|
+
options: Array.from(this.commands.values()).map((n) => ({
|
|
1151
|
+
label: n.command,
|
|
1152
|
+
value: n.id ?? n.command,
|
|
1153
|
+
commandId: n.id ?? n.command
|
|
1104
1154
|
}))
|
|
1105
1155
|
};
|
|
1106
1156
|
}
|
|
@@ -1120,27 +1170,27 @@ class Mt {
|
|
|
1120
1170
|
}
|
|
1121
1171
|
class He {
|
|
1122
1172
|
constructor() {
|
|
1123
|
-
this.synth = window.speechSynthesis;
|
|
1173
|
+
this.synth = typeof window < "u" ? window.speechSynthesis : null;
|
|
1124
1174
|
}
|
|
1125
|
-
speak(e,
|
|
1175
|
+
speak(e, n) {
|
|
1126
1176
|
if (!this.synth) {
|
|
1127
|
-
console.error("SpeechSynthesis API is not supported in this
|
|
1177
|
+
console.error("SpeechSynthesis API is not supported in this environment.");
|
|
1128
1178
|
return;
|
|
1129
1179
|
}
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1180
|
+
const i = new SpeechSynthesisUtterance(e);
|
|
1181
|
+
n && (i.pitch = n.pitch || 1, i.rate = n.rate || 1, i.volume = n.volume || 1), typeof window < "u" && (i.onstart = () => {
|
|
1132
1182
|
window.dispatchEvent(new CustomEvent("foisit:tts-start"));
|
|
1133
|
-
},
|
|
1183
|
+
}, i.onend = () => {
|
|
1134
1184
|
console.log("Speech finished."), window.dispatchEvent(new CustomEvent("foisit:tts-end"));
|
|
1135
|
-
},
|
|
1185
|
+
}), i.onerror = (s) => {
|
|
1136
1186
|
console.error("Error during speech synthesis:", s.error);
|
|
1137
|
-
}, this.synth.speak(
|
|
1187
|
+
}, this.synth.speak(i);
|
|
1138
1188
|
}
|
|
1139
1189
|
stopSpeaking() {
|
|
1140
1190
|
this.synth && this.synth.cancel();
|
|
1141
1191
|
}
|
|
1142
1192
|
}
|
|
1143
|
-
class
|
|
1193
|
+
class Pt {
|
|
1144
1194
|
constructor() {
|
|
1145
1195
|
this.fallbackMessage = "Sorry, I didn’t understand that.";
|
|
1146
1196
|
}
|
|
@@ -1155,11 +1205,12 @@ class Vt {
|
|
|
1155
1205
|
}
|
|
1156
1206
|
}
|
|
1157
1207
|
const be = () => {
|
|
1208
|
+
if (typeof window > "u") return null;
|
|
1158
1209
|
const t = window;
|
|
1159
1210
|
return t.SpeechRecognition ?? t.webkitSpeechRecognition ?? null;
|
|
1160
1211
|
};
|
|
1161
|
-
class
|
|
1162
|
-
constructor(e = "en-US",
|
|
1212
|
+
class Vt {
|
|
1213
|
+
constructor(e = "en-US", n = {}) {
|
|
1163
1214
|
this.recognition = null, this.isListening = !1, this.engineActive = !1, this.intentionallyStopped = !1, this.restartAllowed = !0, this.lastStart = 0, this.backoffMs = 250, this.destroyed = !1, this.resultCallback = null, this.ttsSpeaking = !1, this.debugEnabled = !0, this.restartTimer = null, this.prewarmed = !1, this.hadResultThisSession = !1, this.onTTSStart = () => {
|
|
1164
1215
|
var s;
|
|
1165
1216
|
this.ttsSpeaking = !0;
|
|
@@ -1171,25 +1222,25 @@ class Pt {
|
|
|
1171
1222
|
}, this.onTTSEnd = () => {
|
|
1172
1223
|
this.ttsSpeaking = !1, this.isListening && this.restartAllowed ? this.safeRestart() : this.emitStatus(this.isListening ? "listening" : "idle");
|
|
1173
1224
|
};
|
|
1174
|
-
const
|
|
1175
|
-
if (
|
|
1176
|
-
this.recognition = new
|
|
1225
|
+
const i = be();
|
|
1226
|
+
if (i) {
|
|
1227
|
+
this.recognition = new i(), this.recognition.lang = e, this.recognition.interimResults = n.interimResults ?? !0, this.recognition.continuous = n.continuous ?? !0, this.recognition.onresult = (o) => this.handleResult(o, n), this.recognition.onend = () => this.handleEnd(), this.recognition.onstart = () => {
|
|
1177
1228
|
this.log("recognition onstart"), this.engineActive = !0, this.hadResultThisSession = !1, this.restartTimer && (clearTimeout(this.restartTimer), this.restartTimer = null), this.backoffMs = 250, this.isListening && !this.ttsSpeaking && this.emitStatus("listening");
|
|
1178
1229
|
};
|
|
1179
1230
|
const s = this.recognition;
|
|
1180
1231
|
s.onaudiostart = () => this.log("onaudiostart"), s.onsoundstart = () => this.log("onsoundstart"), s.onspeechstart = () => this.log("onspeechstart"), s.onspeechend = () => this.log("onspeechend"), s.onsoundend = () => this.log("onsoundend"), s.onaudioend = () => this.log("onaudioend"), this.recognition.onerror = (o) => this.handleError(o);
|
|
1181
1232
|
} else
|
|
1182
1233
|
this.recognition = null, this.emitStatus("unsupported");
|
|
1183
|
-
window.addEventListener("foisit:tts-start", this.onTTSStart), window.addEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler = () => {
|
|
1234
|
+
typeof window < "u" ? (window.addEventListener("foisit:tts-start", this.onTTSStart), window.addEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler = () => {
|
|
1184
1235
|
var s;
|
|
1185
|
-
if (document.hidden) {
|
|
1236
|
+
if (typeof document < "u" && document.hidden) {
|
|
1186
1237
|
try {
|
|
1187
1238
|
(s = this.recognition) == null || s.stop();
|
|
1188
1239
|
} catch {
|
|
1189
1240
|
}
|
|
1190
1241
|
this.emitStatus(this.ttsSpeaking ? "speaking" : "idle");
|
|
1191
1242
|
} else this.isListening && !this.ttsSpeaking && this.safeRestart();
|
|
1192
|
-
}, document.addEventListener("visibilitychange", this.visibilityHandler);
|
|
1243
|
+
}, typeof document < "u" && document.addEventListener("visibilitychange", this.visibilityHandler)) : this.visibilityHandler = void 0;
|
|
1193
1244
|
}
|
|
1194
1245
|
// Debug logger helpers
|
|
1195
1246
|
log(e) {
|
|
@@ -1237,15 +1288,15 @@ class Pt {
|
|
|
1237
1288
|
this.destroyed = !0, this.stopListening(), this.resultCallback = null, window.removeEventListener("foisit:tts-start", this.onTTSStart), window.removeEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = void 0);
|
|
1238
1289
|
}
|
|
1239
1290
|
/** Handle recognized speech results */
|
|
1240
|
-
handleResult(e,
|
|
1291
|
+
handleResult(e, n) {
|
|
1241
1292
|
var s, o;
|
|
1242
1293
|
if (!this.resultCallback) return;
|
|
1243
|
-
const
|
|
1294
|
+
const i = n.confidenceThreshold ?? 0.6;
|
|
1244
1295
|
for (let r = e.resultIndex; r < e.results.length; r++) {
|
|
1245
|
-
const a = e.results[r], c = a && a[0],
|
|
1246
|
-
if (
|
|
1296
|
+
const a = e.results[r], c = a && a[0], h = ((o = (s = c == null ? void 0 : c.transcript) == null ? void 0 : s.trim) == null ? void 0 : o.call(s)) || "", d = (c == null ? void 0 : c.confidence) ?? 0;
|
|
1297
|
+
if (h && !(!a.isFinal && n.interimResults === !1) && !(a.isFinal && d < i))
|
|
1247
1298
|
try {
|
|
1248
|
-
this.hadResultThisSession = !0, this.resultCallback(
|
|
1299
|
+
this.hadResultThisSession = !0, this.resultCallback(h, !!a.isFinal);
|
|
1249
1300
|
} catch {
|
|
1250
1301
|
this.error("VoiceProcessor: result callback error");
|
|
1251
1302
|
}
|
|
@@ -1261,9 +1312,9 @@ class Pt {
|
|
|
1261
1312
|
}
|
|
1262
1313
|
/** Handle errors during speech recognition */
|
|
1263
1314
|
handleError(e) {
|
|
1264
|
-
const
|
|
1265
|
-
if (this.warn(`Error occurred: ${
|
|
1266
|
-
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error:
|
|
1315
|
+
const n = e == null ? void 0 : e.error;
|
|
1316
|
+
if (this.warn(`Error occurred: ${n ?? "unknown"}`), n && ["not-allowed", "service-not-allowed", "bad-grammar", "language-not-supported"].includes(n)) {
|
|
1317
|
+
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error: n });
|
|
1267
1318
|
return;
|
|
1268
1319
|
}
|
|
1269
1320
|
this.scheduleRestart();
|
|
@@ -1308,17 +1359,17 @@ class Pt {
|
|
|
1308
1359
|
const e = navigator.mediaDevices;
|
|
1309
1360
|
if (!(e != null && e.getUserMedia)) return;
|
|
1310
1361
|
this.log("prewarmAudio: requesting mic");
|
|
1311
|
-
const
|
|
1312
|
-
for (const
|
|
1362
|
+
const n = await e.getUserMedia({ audio: !0 });
|
|
1363
|
+
for (const i of n.getTracks()) i.stop();
|
|
1313
1364
|
this.prewarmed = !0, this.log("prewarmAudio: mic ready");
|
|
1314
1365
|
} catch {
|
|
1315
1366
|
this.warn("prewarmAudio: failed to get mic");
|
|
1316
1367
|
}
|
|
1317
1368
|
}
|
|
1318
|
-
emitStatus(e,
|
|
1369
|
+
emitStatus(e, n) {
|
|
1319
1370
|
if (this.statusCallback)
|
|
1320
1371
|
try {
|
|
1321
|
-
this.statusCallback(e,
|
|
1372
|
+
this.statusCallback(e, n);
|
|
1322
1373
|
} catch {
|
|
1323
1374
|
this.error("VoiceProcessor: status callback error");
|
|
1324
1375
|
}
|
|
@@ -1336,8 +1387,8 @@ class Ft {
|
|
|
1336
1387
|
this.destroy(), this.dblClickListener = () => {
|
|
1337
1388
|
e();
|
|
1338
1389
|
}, document.addEventListener("dblclick", this.dblClickListener), this.touchEndListener = () => {
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1390
|
+
const n = (/* @__PURE__ */ new Date()).getTime(), i = n - this.lastTap;
|
|
1391
|
+
i < 300 && i > 0 && e(), this.lastTap = n;
|
|
1341
1392
|
}, document.addEventListener("touchend", this.touchEndListener);
|
|
1342
1393
|
}
|
|
1343
1394
|
destroy() {
|
|
@@ -1395,7 +1446,10 @@ function Ht() {
|
|
|
1395
1446
|
const t = document.querySelector("#gradient-indicator");
|
|
1396
1447
|
t && (t.remove(), console.log("Gradient indicator removed from the DOM"));
|
|
1397
1448
|
}
|
|
1398
|
-
|
|
1449
|
+
function qt() {
|
|
1450
|
+
return typeof window < "u" && typeof document < "u";
|
|
1451
|
+
}
|
|
1452
|
+
class zt {
|
|
1399
1453
|
constructor() {
|
|
1400
1454
|
this.state = "idle", this.subscribers = [];
|
|
1401
1455
|
}
|
|
@@ -1413,27 +1467,27 @@ class qt {
|
|
|
1413
1467
|
this.subscribers.forEach((e) => e(this.state));
|
|
1414
1468
|
}
|
|
1415
1469
|
}
|
|
1416
|
-
class
|
|
1470
|
+
class Bt {
|
|
1417
1471
|
constructor(e) {
|
|
1418
|
-
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.config = e, this.init();
|
|
1472
|
+
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.active = qt(), this.config = e, this.active && this.init();
|
|
1419
1473
|
}
|
|
1420
1474
|
init() {
|
|
1421
|
-
var
|
|
1475
|
+
var n, i;
|
|
1422
1476
|
if (this.container) return;
|
|
1423
1477
|
this.injectOverlayStyles();
|
|
1424
1478
|
const e = document.getElementById("foisit-overlay-container");
|
|
1425
1479
|
if (e && e instanceof HTMLElement) {
|
|
1426
|
-
this.container = e, this.chatWindow = e.querySelector(".foisit-chat"), this.messagesContainer = e.querySelector(".foisit-messages"), this.input = e.querySelector("input.foisit-input"), ((
|
|
1480
|
+
this.container = e, this.chatWindow = e.querySelector(".foisit-chat"), this.messagesContainer = e.querySelector(".foisit-messages"), this.input = e.querySelector("input.foisit-input"), ((n = this.config.floatingButton) == null ? void 0 : n.visible) !== !1 && !e.querySelector(".foisit-floating-btn") && this.renderFloatingButton(), this.chatWindow || this.renderChatWindow();
|
|
1427
1481
|
return;
|
|
1428
1482
|
}
|
|
1429
|
-
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((
|
|
1483
|
+
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((i = this.config.floatingButton) == null ? void 0 : i.visible) !== !1 && this.renderFloatingButton(), this.renderChatWindow();
|
|
1430
1484
|
}
|
|
1431
1485
|
renderFloatingButton() {
|
|
1432
|
-
var s, o, r, a, c,
|
|
1486
|
+
var s, o, r, a, c, h;
|
|
1433
1487
|
const e = document.createElement("button");
|
|
1434
1488
|
e.innerHTML = ((s = this.config.floatingButton) == null ? void 0 : s.customHtml) || "🎙️";
|
|
1435
|
-
const
|
|
1436
|
-
e.className = "foisit-floating-btn", e.style.bottom =
|
|
1489
|
+
const n = ((r = (o = this.config.floatingButton) == null ? void 0 : o.position) == null ? void 0 : r.bottom) || "20px", i = ((c = (a = this.config.floatingButton) == null ? void 0 : a.position) == null ? void 0 : c.right) || "20px";
|
|
1490
|
+
e.className = "foisit-floating-btn", e.style.bottom = n, e.style.right = i, e.onclick = () => this.toggle(), e.onmouseenter = () => e.style.transform = "scale(1.05)", e.onmouseleave = () => e.style.transform = "scale(1)", (h = this.container) == null || h.appendChild(e);
|
|
1437
1491
|
}
|
|
1438
1492
|
renderChatWindow() {
|
|
1439
1493
|
var o;
|
|
@@ -1441,10 +1495,10 @@ class zt {
|
|
|
1441
1495
|
this.chatWindow = document.createElement("div"), this.chatWindow.className = "foisit-chat";
|
|
1442
1496
|
const e = document.createElement("div");
|
|
1443
1497
|
e.className = "foisit-header";
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1498
|
+
const n = document.createElement("span");
|
|
1499
|
+
n.className = "foisit-title", n.textContent = "Foisit";
|
|
1500
|
+
const i = document.createElement("button");
|
|
1501
|
+
i.type = "button", i.className = "foisit-close", i.setAttribute("aria-label", "Close"), i.innerHTML = "×", i.addEventListener("click", () => this.toggle()), e.appendChild(n), e.appendChild(i), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "foisit-messages";
|
|
1448
1502
|
const s = document.createElement("div");
|
|
1449
1503
|
s.className = "foisit-input-area", this.input = document.createElement("input"), this.input.placeholder = this.config.inputPlaceholder || "Type a command...", this.input.className = "foisit-input", this.input.addEventListener("keydown", (r) => {
|
|
1450
1504
|
var a;
|
|
@@ -1454,44 +1508,44 @@ class zt {
|
|
|
1454
1508
|
}
|
|
1455
1509
|
}), s.appendChild(this.input), this.chatWindow.appendChild(e), this.chatWindow.appendChild(this.messagesContainer), this.chatWindow.appendChild(s), (o = this.container) == null || o.appendChild(this.chatWindow);
|
|
1456
1510
|
}
|
|
1457
|
-
registerCallbacks(e,
|
|
1458
|
-
this.onSubmit = e, this.onClose =
|
|
1511
|
+
registerCallbacks(e, n) {
|
|
1512
|
+
this.active && (this.onSubmit = e, this.onClose = n);
|
|
1459
1513
|
}
|
|
1460
|
-
toggle(e,
|
|
1461
|
-
e && (this.onSubmit = e),
|
|
1514
|
+
toggle(e, n) {
|
|
1515
|
+
this.active && (e && (this.onSubmit = e), n && (this.onClose = n), this.isOpen = !this.isOpen, this.chatWindow && (this.isOpen ? (this.chatWindow.style.display = "flex", requestAnimationFrame(() => {
|
|
1462
1516
|
this.chatWindow && (this.chatWindow.style.opacity = "1", this.chatWindow.style.transform = "translateY(0) scale(1)");
|
|
1463
1517
|
}), setTimeout(() => {
|
|
1464
|
-
var
|
|
1465
|
-
return (
|
|
1518
|
+
var i;
|
|
1519
|
+
return (i = this.input) == null ? void 0 : i.focus();
|
|
1466
1520
|
}, 100)) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1467
1521
|
this.chatWindow && !this.isOpen && (this.chatWindow.style.display = "none");
|
|
1468
|
-
}, 200), this.onClose && this.onClose()));
|
|
1522
|
+
}, 200), this.onClose && this.onClose())));
|
|
1469
1523
|
}
|
|
1470
|
-
addMessage(e,
|
|
1524
|
+
addMessage(e, n) {
|
|
1471
1525
|
if (!this.messagesContainer) return;
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1526
|
+
const i = document.createElement("div");
|
|
1527
|
+
i.textContent = e, i.className = n === "user" ? "foisit-bubble user" : "foisit-bubble system", this.messagesContainer.appendChild(i), this.scrollToBottom();
|
|
1474
1528
|
}
|
|
1475
1529
|
addOptions(e) {
|
|
1476
1530
|
if (!this.messagesContainer) return;
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1531
|
+
const n = document.createElement("div");
|
|
1532
|
+
n.className = "foisit-options-container", e.forEach((i) => {
|
|
1479
1533
|
const s = document.createElement("button");
|
|
1480
|
-
s.textContent =
|
|
1534
|
+
s.textContent = i.label, s.className = "foisit-option-chip", s.setAttribute("type", "button"), s.setAttribute("aria-label", i.label);
|
|
1481
1535
|
const o = () => {
|
|
1482
|
-
if (
|
|
1483
|
-
this.onSubmit && this.onSubmit({ commandId:
|
|
1536
|
+
if (i.commandId) {
|
|
1537
|
+
this.onSubmit && this.onSubmit({ commandId: i.commandId });
|
|
1484
1538
|
return;
|
|
1485
1539
|
}
|
|
1486
|
-
const r =
|
|
1540
|
+
const r = i && typeof i.value == "string" && i.value.trim() ? i.value : i.label;
|
|
1487
1541
|
this.onSubmit && this.onSubmit(r);
|
|
1488
1542
|
};
|
|
1489
1543
|
s.onclick = o, s.onkeydown = (r) => {
|
|
1490
1544
|
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), o());
|
|
1491
|
-
},
|
|
1492
|
-
}), this.messagesContainer.appendChild(
|
|
1545
|
+
}, n.appendChild(s);
|
|
1546
|
+
}), this.messagesContainer.appendChild(n), this.scrollToBottom();
|
|
1493
1547
|
}
|
|
1494
|
-
addForm(e,
|
|
1548
|
+
addForm(e, n, i) {
|
|
1495
1549
|
if (!this.messagesContainer) return;
|
|
1496
1550
|
this.addMessage(e, "system");
|
|
1497
1551
|
const s = document.createElement("form");
|
|
@@ -1503,17 +1557,17 @@ class zt {
|
|
|
1503
1557
|
const d = document.createElement("div");
|
|
1504
1558
|
return d.className = "foisit-form-error", d.style.display = "none", d;
|
|
1505
1559
|
};
|
|
1506
|
-
(
|
|
1560
|
+
(n ?? []).forEach((d) => {
|
|
1507
1561
|
const l = document.createElement("div");
|
|
1508
1562
|
l.className = "foisit-form-group";
|
|
1509
1563
|
const f = d.description || d.name;
|
|
1510
1564
|
l.appendChild(r(f, d.required));
|
|
1511
|
-
let
|
|
1565
|
+
let m;
|
|
1512
1566
|
if (d.type === "select") {
|
|
1513
1567
|
const u = document.createElement("select");
|
|
1514
1568
|
u.className = "foisit-form-input";
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1569
|
+
const w = document.createElement("option");
|
|
1570
|
+
w.value = "", w.textContent = "Select...", u.appendChild(w);
|
|
1517
1571
|
const x = (p) => {
|
|
1518
1572
|
(p ?? []).forEach((S) => {
|
|
1519
1573
|
const b = document.createElement("option");
|
|
@@ -1533,19 +1587,19 @@ class zt {
|
|
|
1533
1587
|
b.value = "", b.textContent = "Error loading options", u.appendChild(b);
|
|
1534
1588
|
});
|
|
1535
1589
|
}
|
|
1536
|
-
d.defaultValue != null && (u.value = String(d.defaultValue)),
|
|
1590
|
+
d.defaultValue != null && (u.value = String(d.defaultValue)), m = u;
|
|
1537
1591
|
} else if (d.type === "file") {
|
|
1538
|
-
const u = d,
|
|
1539
|
-
|
|
1540
|
-
const x = Array.from(
|
|
1592
|
+
const u = d, w = document.createElement("input");
|
|
1593
|
+
w.className = "foisit-form-input", w.type = "file", u.accept && Array.isArray(u.accept) && (w.accept = u.accept.join(",")), u.multiple && (w.multiple = !0), u.capture && (u.capture === !0 ? w.setAttribute("capture", "") : w.setAttribute("capture", String(u.capture))), w.addEventListener("change", async () => {
|
|
1594
|
+
const x = Array.from(w.files || []), p = y;
|
|
1541
1595
|
if (p.style.display = "none", p.textContent = "", x.length === 0) return;
|
|
1542
1596
|
const S = u.maxFiles ?? (u.multiple ? 10 : 1);
|
|
1543
1597
|
if (x.length > S) {
|
|
1544
1598
|
p.textContent = `Please select at most ${S} file(s).`, p.style.display = "block";
|
|
1545
1599
|
return;
|
|
1546
1600
|
}
|
|
1547
|
-
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((
|
|
1548
|
-
if (x.some((
|
|
1601
|
+
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((v, B) => v + B.size, 0);
|
|
1602
|
+
if (x.some((v) => v.size > b)) {
|
|
1549
1603
|
p.textContent = `One or more files exceed the maximum size of ${Math.round(b / 1024)} KB.`, p.style.display = "block";
|
|
1550
1604
|
return;
|
|
1551
1605
|
}
|
|
@@ -1555,54 +1609,54 @@ class zt {
|
|
|
1555
1609
|
return;
|
|
1556
1610
|
}
|
|
1557
1611
|
if (u.accept && Array.isArray(u.accept)) {
|
|
1558
|
-
const
|
|
1559
|
-
if (!x.every((
|
|
1612
|
+
const v = u.accept;
|
|
1613
|
+
if (!x.every((U) => U.type ? v.some((W) => W.startsWith(".") ? U.name.toLowerCase().endsWith(W.toLowerCase()) : U.type === W || U.type.startsWith(W.split("/")[0] + "/")) : !0)) {
|
|
1560
1614
|
p.textContent = "One or more files have an unsupported type.", p.style.display = "block";
|
|
1561
1615
|
return;
|
|
1562
1616
|
}
|
|
1563
1617
|
}
|
|
1564
|
-
}),
|
|
1618
|
+
}), m = w;
|
|
1565
1619
|
} else {
|
|
1566
1620
|
const u = document.createElement("input");
|
|
1567
|
-
u.className = "foisit-form-input", d.type === "string" && (u.placeholder = d.placeholder || "Type here..."), d.type === "number" ? (u.type = "number", typeof d.min == "number" && (u.min = String(d.min)), typeof d.max == "number" && (u.max = String(d.max)), typeof d.step == "number" && (u.step = String(d.step)), d.defaultValue != null && (u.value = String(d.defaultValue))) : d.type === "date" ? (u.type = "date", typeof d.min == "string" && (u.min = d.min), typeof d.max == "string" && (u.max = d.max), d.defaultValue != null && (u.value = String(d.defaultValue))) : (u.type = "text", d.defaultValue != null && (u.value = String(d.defaultValue))),
|
|
1621
|
+
u.className = "foisit-form-input", d.type === "string" && (u.placeholder = d.placeholder || "Type here..."), d.type === "number" ? (u.type = "number", typeof d.min == "number" && (u.min = String(d.min)), typeof d.max == "number" && (u.max = String(d.max)), typeof d.step == "number" && (u.step = String(d.step)), d.defaultValue != null && (u.value = String(d.defaultValue))) : d.type === "date" ? (u.type = "date", typeof d.min == "string" && (u.min = d.min), typeof d.max == "string" && (u.max = d.max), d.defaultValue != null && (u.value = String(d.defaultValue))) : (u.type = "text", d.defaultValue != null && (u.value = String(d.defaultValue))), m = u;
|
|
1568
1622
|
}
|
|
1569
1623
|
const y = a();
|
|
1570
|
-
l.appendChild(
|
|
1624
|
+
l.appendChild(m), l.appendChild(y), o.push({
|
|
1571
1625
|
name: d.name,
|
|
1572
1626
|
type: d.type,
|
|
1573
|
-
el:
|
|
1627
|
+
el: m,
|
|
1574
1628
|
required: d.required
|
|
1575
1629
|
}), s.appendChild(l);
|
|
1576
1630
|
});
|
|
1577
1631
|
const c = document.createElement("div");
|
|
1578
1632
|
c.className = "foisit-form-actions";
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1633
|
+
const h = document.createElement("button");
|
|
1634
|
+
h.type = "submit", h.textContent = "Submit", h.className = "foisit-option-chip", h.style.fontWeight = "600", c.appendChild(h), s.appendChild(c), s.onsubmit = async (d) => {
|
|
1581
1635
|
d.preventDefault();
|
|
1582
1636
|
const l = {};
|
|
1583
1637
|
let f = !1;
|
|
1584
|
-
s.querySelectorAll(".foisit-form-error").forEach((
|
|
1585
|
-
|
|
1586
|
-
}), s.querySelectorAll(".foisit-form-input").forEach((
|
|
1587
|
-
|
|
1638
|
+
s.querySelectorAll(".foisit-form-error").forEach((m) => {
|
|
1639
|
+
m.style.display = "none", m.textContent = "";
|
|
1640
|
+
}), s.querySelectorAll(".foisit-form-input").forEach((m) => {
|
|
1641
|
+
m.classList.remove("foisit-error-border");
|
|
1588
1642
|
});
|
|
1589
|
-
for (const
|
|
1590
|
-
if (
|
|
1591
|
-
const x =
|
|
1592
|
-
if (
|
|
1643
|
+
for (const m of o) {
|
|
1644
|
+
if (m.type === "file") {
|
|
1645
|
+
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(".foisit-form-error"), S = m.el, b = Array.from(S.files || []);
|
|
1646
|
+
if (m.required && b.length === 0) {
|
|
1593
1647
|
f = !0, S.classList.add("foisit-error-border"), p && (p.textContent = "This file is required", p.style.display = "block");
|
|
1594
1648
|
continue;
|
|
1595
1649
|
}
|
|
1596
1650
|
if (b.length === 0) continue;
|
|
1597
|
-
const g = (
|
|
1651
|
+
const g = (n ?? []).find((v) => v.name === m.name), $ = (g == null ? void 0 : g.delivery) ?? "file";
|
|
1598
1652
|
if (g != null && g.maxWidth || g != null && g.maxHeight)
|
|
1599
1653
|
try {
|
|
1600
|
-
const
|
|
1601
|
-
if (g.maxWidth &&
|
|
1654
|
+
const v = await this.getImageDimensions(b[0]);
|
|
1655
|
+
if (g.maxWidth && v.width > g.maxWidth) {
|
|
1602
1656
|
f = !0, p && (p.textContent = `Image width must be ≤ ${g.maxWidth}px`, p.style.display = "block");
|
|
1603
1657
|
continue;
|
|
1604
1658
|
}
|
|
1605
|
-
if (g.maxHeight &&
|
|
1659
|
+
if (g.maxHeight && v.height > g.maxHeight) {
|
|
1606
1660
|
f = !0, p && (p.textContent = `Image height must be ≤ ${g.maxHeight}px`, p.style.display = "block");
|
|
1607
1661
|
continue;
|
|
1608
1662
|
}
|
|
@@ -1610,52 +1664,52 @@ class zt {
|
|
|
1610
1664
|
}
|
|
1611
1665
|
if (g != null && g.maxDurationSec)
|
|
1612
1666
|
try {
|
|
1613
|
-
const
|
|
1614
|
-
if (
|
|
1667
|
+
const v = await this.getMediaDuration(b[0]);
|
|
1668
|
+
if (v && v > g.maxDurationSec) {
|
|
1615
1669
|
f = !0, p && (p.textContent = `Media duration must be ≤ ${g.maxDurationSec}s`, p.style.display = "block");
|
|
1616
1670
|
continue;
|
|
1617
1671
|
}
|
|
1618
1672
|
} catch {
|
|
1619
1673
|
}
|
|
1620
1674
|
if ($ === "file")
|
|
1621
|
-
l[
|
|
1675
|
+
l[m.name] = g != null && g.multiple ? b : b[0];
|
|
1622
1676
|
else if ($ === "base64")
|
|
1623
1677
|
try {
|
|
1624
|
-
const
|
|
1625
|
-
l[
|
|
1678
|
+
const v = await Promise.all(b.map((B) => this.readFileAsDataURL(B)));
|
|
1679
|
+
l[m.name] = g != null && g.multiple ? v : v[0];
|
|
1626
1680
|
} catch {
|
|
1627
1681
|
f = !0, p && (p.textContent = "Failed to encode file(s) to base64.", p.style.display = "block");
|
|
1628
1682
|
continue;
|
|
1629
1683
|
}
|
|
1630
1684
|
continue;
|
|
1631
1685
|
}
|
|
1632
|
-
const y = (
|
|
1633
|
-
if (
|
|
1634
|
-
f = !0,
|
|
1686
|
+
const y = (m.el.value ?? "").toString().trim(), u = m.el.parentElement, w = u == null ? void 0 : u.querySelector(".foisit-form-error");
|
|
1687
|
+
if (m.required && (y == null || y === "")) {
|
|
1688
|
+
f = !0, m.el.classList.add("foisit-error-border"), w && (w.textContent = "This field is required", w.style.display = "block");
|
|
1635
1689
|
continue;
|
|
1636
1690
|
}
|
|
1637
1691
|
if (y !== "")
|
|
1638
|
-
if (
|
|
1692
|
+
if (m.type === "number") {
|
|
1639
1693
|
const x = Number(y);
|
|
1640
|
-
Number.isNaN(x) || (l[
|
|
1694
|
+
Number.isNaN(x) || (l[m.name] = x);
|
|
1641
1695
|
} else
|
|
1642
|
-
l[
|
|
1696
|
+
l[m.name] = y;
|
|
1643
1697
|
}
|
|
1644
1698
|
if (f) {
|
|
1645
1699
|
s.classList.add("foisit-shake"), setTimeout(() => s.classList.remove("foisit-shake"), 400);
|
|
1646
1700
|
return;
|
|
1647
1701
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
}),
|
|
1702
|
+
h.disabled = !0, h.style.opacity = "0.6", o.forEach((m) => {
|
|
1703
|
+
m.el.disabled = !0;
|
|
1704
|
+
}), i(l);
|
|
1651
1705
|
}, this.messagesContainer.appendChild(s), this.scrollToBottom();
|
|
1652
1706
|
}
|
|
1653
1707
|
showLoading() {
|
|
1654
1708
|
if (this.messagesContainer && !this.loadingEl) {
|
|
1655
1709
|
this.loadingEl = document.createElement("div"), this.loadingEl.className = "foisit-loading-dots foisit-bubble system";
|
|
1656
1710
|
for (let e = 0; e < 3; e++) {
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1711
|
+
const n = document.createElement("div");
|
|
1712
|
+
n.className = "foisit-dot", n.style.animation = `foisitPulse 1.4s infinite ease-in-out ${e * 0.2}s`, this.loadingEl.appendChild(n);
|
|
1659
1713
|
}
|
|
1660
1714
|
this.messagesContainer.appendChild(this.loadingEl), this.scrollToBottom();
|
|
1661
1715
|
}
|
|
@@ -1672,44 +1726,44 @@ class zt {
|
|
|
1672
1726
|
(e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1673
1727
|
}
|
|
1674
1728
|
readFileAsDataURL(e) {
|
|
1675
|
-
return new Promise((
|
|
1729
|
+
return new Promise((n, i) => {
|
|
1676
1730
|
const s = new FileReader();
|
|
1677
|
-
s.onerror = () =>
|
|
1731
|
+
s.onerror = () => i(new Error("Failed to read file")), s.onload = () => n(String(s.result)), s.readAsDataURL(e);
|
|
1678
1732
|
});
|
|
1679
1733
|
}
|
|
1680
1734
|
getImageDimensions(e) {
|
|
1681
|
-
return new Promise((
|
|
1735
|
+
return new Promise((n) => {
|
|
1682
1736
|
try {
|
|
1683
|
-
const
|
|
1737
|
+
const i = URL.createObjectURL(e), s = new Image();
|
|
1684
1738
|
s.onload = () => {
|
|
1685
1739
|
const o = { width: s.naturalWidth || s.width, height: s.naturalHeight || s.height };
|
|
1686
|
-
URL.revokeObjectURL(
|
|
1740
|
+
URL.revokeObjectURL(i), n(o);
|
|
1687
1741
|
}, s.onerror = () => {
|
|
1688
|
-
URL.revokeObjectURL(
|
|
1689
|
-
}, s.src =
|
|
1742
|
+
URL.revokeObjectURL(i), n({ width: 0, height: 0 });
|
|
1743
|
+
}, s.src = i;
|
|
1690
1744
|
} catch {
|
|
1691
|
-
|
|
1745
|
+
n({ width: 0, height: 0 });
|
|
1692
1746
|
}
|
|
1693
1747
|
});
|
|
1694
1748
|
}
|
|
1695
1749
|
getMediaDuration(e) {
|
|
1696
|
-
return new Promise((
|
|
1750
|
+
return new Promise((n) => {
|
|
1697
1751
|
try {
|
|
1698
|
-
const
|
|
1752
|
+
const i = URL.createObjectURL(e), s = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
|
|
1699
1753
|
let o = !1;
|
|
1700
1754
|
const r = setTimeout(() => {
|
|
1701
|
-
o || (o = !0, URL.revokeObjectURL(
|
|
1755
|
+
o || (o = !0, URL.revokeObjectURL(i), n(0));
|
|
1702
1756
|
}, 5e3);
|
|
1703
1757
|
s.preload = "metadata", s.onloadedmetadata = () => {
|
|
1704
1758
|
if (o) return;
|
|
1705
1759
|
o = !0, clearTimeout(r);
|
|
1706
1760
|
const c = s.duration || 0;
|
|
1707
|
-
URL.revokeObjectURL(
|
|
1761
|
+
URL.revokeObjectURL(i), n(c);
|
|
1708
1762
|
}, s.onerror = () => {
|
|
1709
|
-
o || (o = !0, clearTimeout(r), URL.revokeObjectURL(
|
|
1710
|
-
}, s.src =
|
|
1763
|
+
o || (o = !0, clearTimeout(r), URL.revokeObjectURL(i), n(0));
|
|
1764
|
+
}, s.src = i;
|
|
1711
1765
|
} catch {
|
|
1712
|
-
|
|
1766
|
+
n(0);
|
|
1713
1767
|
}
|
|
1714
1768
|
});
|
|
1715
1769
|
}
|
|
@@ -2040,23 +2094,23 @@ class zt {
|
|
|
2040
2094
|
`, document.head.appendChild(e);
|
|
2041
2095
|
}
|
|
2042
2096
|
}
|
|
2043
|
-
class
|
|
2097
|
+
class Ut {
|
|
2044
2098
|
constructor(e) {
|
|
2045
2099
|
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new Mt({
|
|
2046
2100
|
enableSmartIntent: this.config.enableSmartIntent !== !1,
|
|
2047
2101
|
intentEndpoint: this.config.intentEndpoint
|
|
2048
|
-
}), this.fallbackHandler = new
|
|
2102
|
+
}), this.fallbackHandler = new Pt(), this.voiceProcessor = new Vt(), this.textToSpeech = new He(), this.stateManager = new zt(), this.gestureHandler = new Ft(), this.overlayManager = new Bt({
|
|
2049
2103
|
floatingButton: this.config.floatingButton,
|
|
2050
2104
|
inputPlaceholder: this.config.inputPlaceholder
|
|
2051
|
-
}), this.config.commands.forEach((
|
|
2052
|
-
async (
|
|
2053
|
-
if (typeof
|
|
2054
|
-
this.overlayManager.addMessage(
|
|
2055
|
-
else if (
|
|
2056
|
-
const
|
|
2057
|
-
|
|
2105
|
+
}), this.config.commands.forEach((n) => this.commandHandler.addCommand(n)), this.config.fallbackResponse && this.fallbackHandler.setFallbackMessage(this.config.fallbackResponse), this.gestureHandler.setupDoubleTapListener(() => this.toggle()), this.overlayManager.registerCallbacks(
|
|
2106
|
+
async (n) => {
|
|
2107
|
+
if (typeof n == "string")
|
|
2108
|
+
this.overlayManager.addMessage(n, "user");
|
|
2109
|
+
else if (n && typeof n == "object") {
|
|
2110
|
+
const i = this.extractUserLabel(n);
|
|
2111
|
+
i && this.overlayManager.addMessage(i, "user");
|
|
2058
2112
|
}
|
|
2059
|
-
await this.handleCommand(
|
|
2113
|
+
await this.handleCommand(n);
|
|
2060
2114
|
},
|
|
2061
2115
|
() => console.log("AssistantService: Overlay closed.")
|
|
2062
2116
|
);
|
|
@@ -2079,30 +2133,30 @@ class Bt {
|
|
|
2079
2133
|
}
|
|
2080
2134
|
/** Process activation command */
|
|
2081
2135
|
async processActivation(e) {
|
|
2082
|
-
var
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2136
|
+
var i;
|
|
2137
|
+
const n = (i = this.config.activationCommand) == null ? void 0 : i.toLowerCase();
|
|
2138
|
+
n && (e === n ? (console.log("AssistantService: Activation matched."), this.isActivated = !0, this.textToSpeech.speak(
|
|
2085
2139
|
this.config.introMessage || this.defaultIntroMessage
|
|
2086
2140
|
)) : console.log("AssistantService: Activation command not recognized."));
|
|
2087
2141
|
}
|
|
2088
2142
|
/** Handle recognized commands */
|
|
2089
2143
|
async handleCommand(e) {
|
|
2090
2144
|
this.overlayManager.showLoading();
|
|
2091
|
-
let
|
|
2145
|
+
let n;
|
|
2092
2146
|
try {
|
|
2093
|
-
|
|
2147
|
+
n = await this.commandHandler.executeCommand(e);
|
|
2094
2148
|
} finally {
|
|
2095
2149
|
this.overlayManager.hideLoading();
|
|
2096
2150
|
}
|
|
2097
|
-
if (
|
|
2151
|
+
if (n.type === "form" && n.fields) {
|
|
2098
2152
|
this.overlayManager.addForm(
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
async (
|
|
2153
|
+
n.message,
|
|
2154
|
+
n.fields,
|
|
2155
|
+
async (i) => {
|
|
2102
2156
|
this.overlayManager.showLoading();
|
|
2103
2157
|
let s;
|
|
2104
2158
|
try {
|
|
2105
|
-
s = await this.commandHandler.executeCommand(
|
|
2159
|
+
s = await this.commandHandler.executeCommand(i);
|
|
2106
2160
|
} finally {
|
|
2107
2161
|
this.overlayManager.hideLoading();
|
|
2108
2162
|
}
|
|
@@ -2111,12 +2165,16 @@ class Bt {
|
|
|
2111
2165
|
);
|
|
2112
2166
|
return;
|
|
2113
2167
|
}
|
|
2114
|
-
if (
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2168
|
+
if (n.type === "error") {
|
|
2169
|
+
const i = typeof e == "string" ? e : "";
|
|
2170
|
+
i ? (this.fallbackHandler.handleFallback(i), this.overlayManager.addMessage(this.fallbackHandler.getFallbackMessage(), "system")) : n.message && this.overlayManager.addMessage(n.message, "system");
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
if ((n.type === "ambiguous" || n.type === "confirm") && n.options) {
|
|
2174
|
+
n.message && this.overlayManager.addMessage(n.message, "system"), this.overlayManager.addOptions(n.options);
|
|
2117
2175
|
return;
|
|
2118
2176
|
}
|
|
2119
|
-
|
|
2177
|
+
n.message && this.overlayManager.addMessage(n.message, "system");
|
|
2120
2178
|
}
|
|
2121
2179
|
/**
|
|
2122
2180
|
* Cleanup resources
|
|
@@ -2130,15 +2188,15 @@ class Bt {
|
|
|
2130
2188
|
this.overlayManager.addForm(
|
|
2131
2189
|
e.message,
|
|
2132
2190
|
e.fields,
|
|
2133
|
-
async (
|
|
2191
|
+
async (n) => {
|
|
2134
2192
|
this.overlayManager.showLoading();
|
|
2135
|
-
let
|
|
2193
|
+
let i;
|
|
2136
2194
|
try {
|
|
2137
|
-
|
|
2195
|
+
i = await this.commandHandler.executeCommand(n);
|
|
2138
2196
|
} finally {
|
|
2139
2197
|
this.overlayManager.hideLoading();
|
|
2140
2198
|
}
|
|
2141
|
-
this.processResponse(
|
|
2199
|
+
this.processResponse(i);
|
|
2142
2200
|
}
|
|
2143
2201
|
);
|
|
2144
2202
|
return;
|
|
@@ -2150,8 +2208,8 @@ class Bt {
|
|
|
2150
2208
|
e.message && this.overlayManager.addMessage(e.message, "system");
|
|
2151
2209
|
}
|
|
2152
2210
|
/** Add a command dynamically (supports string or rich object) */
|
|
2153
|
-
addCommand(e,
|
|
2154
|
-
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e,
|
|
2211
|
+
addCommand(e, n) {
|
|
2212
|
+
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e, n);
|
|
2155
2213
|
}
|
|
2156
2214
|
/** Remove a command dynamically */
|
|
2157
2215
|
removeCommand(e) {
|
|
@@ -2162,30 +2220,30 @@ class Bt {
|
|
|
2162
2220
|
return this.commandHandler.getCommands();
|
|
2163
2221
|
}
|
|
2164
2222
|
/** Toggle the assistant overlay */
|
|
2165
|
-
toggle(e,
|
|
2223
|
+
toggle(e, n) {
|
|
2166
2224
|
console.log("AssistantService: Toggling overlay..."), this.overlayManager.toggle(
|
|
2167
|
-
async (
|
|
2168
|
-
if (typeof
|
|
2169
|
-
this.overlayManager.addMessage(
|
|
2170
|
-
else if (
|
|
2171
|
-
const s = this.extractUserLabel(
|
|
2225
|
+
async (i) => {
|
|
2226
|
+
if (typeof i == "string")
|
|
2227
|
+
this.overlayManager.addMessage(i, "user");
|
|
2228
|
+
else if (i && typeof i == "object") {
|
|
2229
|
+
const s = this.extractUserLabel(i);
|
|
2172
2230
|
s && this.overlayManager.addMessage(s, "user");
|
|
2173
2231
|
}
|
|
2174
|
-
e && e(
|
|
2232
|
+
e && e(i), await this.handleCommand(i);
|
|
2175
2233
|
},
|
|
2176
2234
|
() => {
|
|
2177
|
-
console.log("AssistantService: Overlay closed."),
|
|
2235
|
+
console.log("AssistantService: Overlay closed."), n && n();
|
|
2178
2236
|
}
|
|
2179
2237
|
);
|
|
2180
2238
|
}
|
|
2181
2239
|
extractUserLabel(e) {
|
|
2182
|
-
const
|
|
2183
|
-
if (typeof
|
|
2184
|
-
const
|
|
2185
|
-
return typeof
|
|
2240
|
+
const n = e.label;
|
|
2241
|
+
if (typeof n == "string" && n.trim()) return n.trim();
|
|
2242
|
+
const i = e.commandId;
|
|
2243
|
+
return typeof i == "string" && i.trim() ? i.trim() : null;
|
|
2186
2244
|
}
|
|
2187
2245
|
}
|
|
2188
|
-
const Wt = /* @__PURE__ */
|
|
2246
|
+
const Wt = /* @__PURE__ */ mt({
|
|
2189
2247
|
name: "AssistantProvider",
|
|
2190
2248
|
props: {
|
|
2191
2249
|
config: {
|
|
@@ -2194,29 +2252,29 @@ const Wt = /* @__PURE__ */ ht({
|
|
|
2194
2252
|
}
|
|
2195
2253
|
},
|
|
2196
2254
|
setup(t, { slots: e }) {
|
|
2197
|
-
const
|
|
2198
|
-
return dt("assistantService",
|
|
2199
|
-
var
|
|
2200
|
-
return (
|
|
2255
|
+
const n = new Ut(t.config);
|
|
2256
|
+
return dt("assistantService", n), () => {
|
|
2257
|
+
var i;
|
|
2258
|
+
return (i = e.default) == null ? void 0 : i.call(e);
|
|
2201
2259
|
};
|
|
2202
2260
|
}
|
|
2203
|
-
}),
|
|
2204
|
-
const
|
|
2205
|
-
for (const [
|
|
2206
|
-
i
|
|
2207
|
-
return
|
|
2261
|
+
}), jt = (t, e) => {
|
|
2262
|
+
const n = t.__vccOpts || t;
|
|
2263
|
+
for (const [i, s] of e)
|
|
2264
|
+
n[i] = s;
|
|
2265
|
+
return n;
|
|
2208
2266
|
};
|
|
2209
|
-
function
|
|
2267
|
+
function Kt(t, e, n, i, s, o) {
|
|
2210
2268
|
return gt(t.$slots, "default");
|
|
2211
2269
|
}
|
|
2212
|
-
const
|
|
2270
|
+
const Yt = /* @__PURE__ */ jt(Wt, [["render", Kt]]), Jt = () => {
|
|
2213
2271
|
const t = ut("assistantService");
|
|
2214
2272
|
if (!t)
|
|
2215
2273
|
throw new Error("useAssistant must be used within an AssistantProvider");
|
|
2216
2274
|
return t;
|
|
2217
2275
|
};
|
|
2218
2276
|
export {
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2277
|
+
Yt as AssistantProvider,
|
|
2278
|
+
Ut as AssistantService,
|
|
2279
|
+
Jt as useAssistant
|
|
2222
2280
|
};
|