@foisit/vue-wrapper 2.4.1 → 2.4.2
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 -0
- package/index.mjs +484 -430
- package/package.json +1 -1
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([]) : [], ve = () => {
|
|
7
7
|
}, ze = (t) => t.charCodeAt(0) === 111 && t.charCodeAt(1) === 110 && // uppercase letter
|
|
8
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", we = (t) => typeof t == "symbol", O = (t) => t !== null && typeof t == "object";
|
|
9
|
-
let
|
|
10
|
-
const
|
|
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
|
|
24
|
+
const Ue = /;(?![^(]*\))/g, Be = /:([^]+)/, 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(Ue).forEach((n) => {
|
|
28
|
+
if (n) {
|
|
29
|
+
const i = n.split(Be);
|
|
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
|
/**
|
|
@@ -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) : ve;
|
|
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
440
|
key: (a && !we(a) ? a : `_${e}`) + // #7256 force differentiate fallback content from actual content
|
|
441
|
-
(!r &&
|
|
441
|
+
(!r && i ? "_fb" : "")
|
|
442
442
|
},
|
|
443
443
|
r || [],
|
|
444
444
|
r && t._ === 1 ? 64 : -2
|
|
@@ -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,7 +535,7 @@ 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);
|
|
@@ -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,9 +917,9 @@ 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;
|
|
@@ -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,60 +958,110 @@ 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;
|
|
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;
|
|
1007
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 {
|
|
@@ -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
|
}
|
|
@@ -1122,25 +1172,25 @@ class He {
|
|
|
1122
1172
|
constructor() {
|
|
1123
1173
|
this.synth = window.speechSynthesis;
|
|
1124
1174
|
}
|
|
1125
|
-
speak(e,
|
|
1175
|
+
speak(e, n) {
|
|
1126
1176
|
if (!this.synth) {
|
|
1127
1177
|
console.error("SpeechSynthesis API is not supported in this browser.");
|
|
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), 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
|
}
|
|
@@ -1158,8 +1208,8 @@ const be = () => {
|
|
|
1158
1208
|
const t = window;
|
|
1159
1209
|
return t.SpeechRecognition ?? t.webkitSpeechRecognition ?? null;
|
|
1160
1210
|
};
|
|
1161
|
-
class
|
|
1162
|
-
constructor(e = "en-US",
|
|
1211
|
+
class Vt {
|
|
1212
|
+
constructor(e = "en-US", n = {}) {
|
|
1163
1213
|
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
1214
|
var s;
|
|
1165
1215
|
this.ttsSpeaking = !0;
|
|
@@ -1171,9 +1221,9 @@ class Pt {
|
|
|
1171
1221
|
}, this.onTTSEnd = () => {
|
|
1172
1222
|
this.ttsSpeaking = !1, this.isListening && this.restartAllowed ? this.safeRestart() : this.emitStatus(this.isListening ? "listening" : "idle");
|
|
1173
1223
|
};
|
|
1174
|
-
const
|
|
1175
|
-
if (
|
|
1176
|
-
this.recognition = new
|
|
1224
|
+
const i = be();
|
|
1225
|
+
if (i) {
|
|
1226
|
+
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
1227
|
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
1228
|
};
|
|
1179
1229
|
const s = this.recognition;
|
|
@@ -1237,15 +1287,15 @@ class Pt {
|
|
|
1237
1287
|
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
1288
|
}
|
|
1239
1289
|
/** Handle recognized speech results */
|
|
1240
|
-
handleResult(e,
|
|
1290
|
+
handleResult(e, n) {
|
|
1241
1291
|
var s, o;
|
|
1242
1292
|
if (!this.resultCallback) return;
|
|
1243
|
-
const
|
|
1293
|
+
const i = n.confidenceThreshold ?? 0.6;
|
|
1244
1294
|
for (let r = e.resultIndex; r < e.results.length; r++) {
|
|
1245
|
-
const a = e.results[r], c = a && a[0],
|
|
1246
|
-
if (
|
|
1295
|
+
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;
|
|
1296
|
+
if (h && !(!a.isFinal && n.interimResults === !1) && !(a.isFinal && d < i))
|
|
1247
1297
|
try {
|
|
1248
|
-
this.hadResultThisSession = !0, this.resultCallback(
|
|
1298
|
+
this.hadResultThisSession = !0, this.resultCallback(h, !!a.isFinal);
|
|
1249
1299
|
} catch {
|
|
1250
1300
|
this.error("VoiceProcessor: result callback error");
|
|
1251
1301
|
}
|
|
@@ -1261,9 +1311,9 @@ class Pt {
|
|
|
1261
1311
|
}
|
|
1262
1312
|
/** Handle errors during speech recognition */
|
|
1263
1313
|
handleError(e) {
|
|
1264
|
-
const
|
|
1265
|
-
if (this.warn(`Error occurred: ${
|
|
1266
|
-
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error:
|
|
1314
|
+
const n = e == null ? void 0 : e.error;
|
|
1315
|
+
if (this.warn(`Error occurred: ${n ?? "unknown"}`), n && ["not-allowed", "service-not-allowed", "bad-grammar", "language-not-supported"].includes(n)) {
|
|
1316
|
+
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error: n });
|
|
1267
1317
|
return;
|
|
1268
1318
|
}
|
|
1269
1319
|
this.scheduleRestart();
|
|
@@ -1308,17 +1358,17 @@ class Pt {
|
|
|
1308
1358
|
const e = navigator.mediaDevices;
|
|
1309
1359
|
if (!(e != null && e.getUserMedia)) return;
|
|
1310
1360
|
this.log("prewarmAudio: requesting mic");
|
|
1311
|
-
const
|
|
1312
|
-
for (const
|
|
1361
|
+
const n = await e.getUserMedia({ audio: !0 });
|
|
1362
|
+
for (const i of n.getTracks()) i.stop();
|
|
1313
1363
|
this.prewarmed = !0, this.log("prewarmAudio: mic ready");
|
|
1314
1364
|
} catch {
|
|
1315
1365
|
this.warn("prewarmAudio: failed to get mic");
|
|
1316
1366
|
}
|
|
1317
1367
|
}
|
|
1318
|
-
emitStatus(e,
|
|
1368
|
+
emitStatus(e, n) {
|
|
1319
1369
|
if (this.statusCallback)
|
|
1320
1370
|
try {
|
|
1321
|
-
this.statusCallback(e,
|
|
1371
|
+
this.statusCallback(e, n);
|
|
1322
1372
|
} catch {
|
|
1323
1373
|
this.error("VoiceProcessor: status callback error");
|
|
1324
1374
|
}
|
|
@@ -1336,8 +1386,8 @@ class Ft {
|
|
|
1336
1386
|
this.destroy(), this.dblClickListener = () => {
|
|
1337
1387
|
e();
|
|
1338
1388
|
}, document.addEventListener("dblclick", this.dblClickListener), this.touchEndListener = () => {
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1389
|
+
const n = (/* @__PURE__ */ new Date()).getTime(), i = n - this.lastTap;
|
|
1390
|
+
i < 300 && i > 0 && e(), this.lastTap = n;
|
|
1341
1391
|
}, document.addEventListener("touchend", this.touchEndListener);
|
|
1342
1392
|
}
|
|
1343
1393
|
destroy() {
|
|
@@ -1418,22 +1468,22 @@ class zt {
|
|
|
1418
1468
|
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.config = e, this.init();
|
|
1419
1469
|
}
|
|
1420
1470
|
init() {
|
|
1421
|
-
var
|
|
1471
|
+
var n, i;
|
|
1422
1472
|
if (this.container) return;
|
|
1423
1473
|
this.injectOverlayStyles();
|
|
1424
1474
|
const e = document.getElementById("foisit-overlay-container");
|
|
1425
1475
|
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"), ((
|
|
1476
|
+
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
1477
|
return;
|
|
1428
1478
|
}
|
|
1429
|
-
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((
|
|
1479
|
+
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
1480
|
}
|
|
1431
1481
|
renderFloatingButton() {
|
|
1432
|
-
var s, o, r, a, c,
|
|
1482
|
+
var s, o, r, a, c, h;
|
|
1433
1483
|
const e = document.createElement("button");
|
|
1434
1484
|
e.innerHTML = ((s = this.config.floatingButton) == null ? void 0 : s.customHtml) || "🎙️";
|
|
1435
|
-
const
|
|
1436
|
-
e.className = "foisit-floating-btn", e.style.bottom =
|
|
1485
|
+
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";
|
|
1486
|
+
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
1487
|
}
|
|
1438
1488
|
renderChatWindow() {
|
|
1439
1489
|
var o;
|
|
@@ -1441,10 +1491,10 @@ class zt {
|
|
|
1441
1491
|
this.chatWindow = document.createElement("div"), this.chatWindow.className = "foisit-chat";
|
|
1442
1492
|
const e = document.createElement("div");
|
|
1443
1493
|
e.className = "foisit-header";
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1494
|
+
const n = document.createElement("span");
|
|
1495
|
+
n.className = "foisit-title", n.textContent = "Foisit";
|
|
1496
|
+
const i = document.createElement("button");
|
|
1497
|
+
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
1498
|
const s = document.createElement("div");
|
|
1449
1499
|
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
1500
|
var a;
|
|
@@ -1454,44 +1504,44 @@ class zt {
|
|
|
1454
1504
|
}
|
|
1455
1505
|
}), 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
1506
|
}
|
|
1457
|
-
registerCallbacks(e,
|
|
1458
|
-
this.onSubmit = e, this.onClose =
|
|
1507
|
+
registerCallbacks(e, n) {
|
|
1508
|
+
this.onSubmit = e, this.onClose = n;
|
|
1459
1509
|
}
|
|
1460
|
-
toggle(e,
|
|
1461
|
-
e && (this.onSubmit = e),
|
|
1510
|
+
toggle(e, n) {
|
|
1511
|
+
e && (this.onSubmit = e), n && (this.onClose = n), this.isOpen = !this.isOpen, this.chatWindow && (this.isOpen ? (this.chatWindow.style.display = "flex", requestAnimationFrame(() => {
|
|
1462
1512
|
this.chatWindow && (this.chatWindow.style.opacity = "1", this.chatWindow.style.transform = "translateY(0) scale(1)");
|
|
1463
1513
|
}), setTimeout(() => {
|
|
1464
|
-
var
|
|
1465
|
-
return (
|
|
1514
|
+
var i;
|
|
1515
|
+
return (i = this.input) == null ? void 0 : i.focus();
|
|
1466
1516
|
}, 100)) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1467
1517
|
this.chatWindow && !this.isOpen && (this.chatWindow.style.display = "none");
|
|
1468
1518
|
}, 200), this.onClose && this.onClose()));
|
|
1469
1519
|
}
|
|
1470
|
-
addMessage(e,
|
|
1520
|
+
addMessage(e, n) {
|
|
1471
1521
|
if (!this.messagesContainer) return;
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1522
|
+
const i = document.createElement("div");
|
|
1523
|
+
i.textContent = e, i.className = n === "user" ? "foisit-bubble user" : "foisit-bubble system", this.messagesContainer.appendChild(i), this.scrollToBottom();
|
|
1474
1524
|
}
|
|
1475
1525
|
addOptions(e) {
|
|
1476
1526
|
if (!this.messagesContainer) return;
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1527
|
+
const n = document.createElement("div");
|
|
1528
|
+
n.className = "foisit-options-container", e.forEach((i) => {
|
|
1479
1529
|
const s = document.createElement("button");
|
|
1480
|
-
s.textContent =
|
|
1530
|
+
s.textContent = i.label, s.className = "foisit-option-chip", s.setAttribute("type", "button"), s.setAttribute("aria-label", i.label);
|
|
1481
1531
|
const o = () => {
|
|
1482
|
-
if (
|
|
1483
|
-
this.onSubmit && this.onSubmit({ commandId:
|
|
1532
|
+
if (i.commandId) {
|
|
1533
|
+
this.onSubmit && this.onSubmit({ commandId: i.commandId });
|
|
1484
1534
|
return;
|
|
1485
1535
|
}
|
|
1486
|
-
const r =
|
|
1536
|
+
const r = i && typeof i.value == "string" && i.value.trim() ? i.value : i.label;
|
|
1487
1537
|
this.onSubmit && this.onSubmit(r);
|
|
1488
1538
|
};
|
|
1489
1539
|
s.onclick = o, s.onkeydown = (r) => {
|
|
1490
1540
|
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), o());
|
|
1491
|
-
},
|
|
1492
|
-
}), this.messagesContainer.appendChild(
|
|
1541
|
+
}, n.appendChild(s);
|
|
1542
|
+
}), this.messagesContainer.appendChild(n), this.scrollToBottom();
|
|
1493
1543
|
}
|
|
1494
|
-
addForm(e,
|
|
1544
|
+
addForm(e, n, i) {
|
|
1495
1545
|
if (!this.messagesContainer) return;
|
|
1496
1546
|
this.addMessage(e, "system");
|
|
1497
1547
|
const s = document.createElement("form");
|
|
@@ -1503,12 +1553,12 @@ class zt {
|
|
|
1503
1553
|
const d = document.createElement("div");
|
|
1504
1554
|
return d.className = "foisit-form-error", d.style.display = "none", d;
|
|
1505
1555
|
};
|
|
1506
|
-
(
|
|
1556
|
+
(n ?? []).forEach((d) => {
|
|
1507
1557
|
const l = document.createElement("div");
|
|
1508
1558
|
l.className = "foisit-form-group";
|
|
1509
1559
|
const f = d.description || d.name;
|
|
1510
1560
|
l.appendChild(r(f, d.required));
|
|
1511
|
-
let
|
|
1561
|
+
let m;
|
|
1512
1562
|
if (d.type === "select") {
|
|
1513
1563
|
const u = document.createElement("select");
|
|
1514
1564
|
u.className = "foisit-form-input";
|
|
@@ -1533,7 +1583,7 @@ class zt {
|
|
|
1533
1583
|
b.value = "", b.textContent = "Error loading options", u.appendChild(b);
|
|
1534
1584
|
});
|
|
1535
1585
|
}
|
|
1536
|
-
d.defaultValue != null && (u.value = String(d.defaultValue)),
|
|
1586
|
+
d.defaultValue != null && (u.value = String(d.defaultValue)), m = u;
|
|
1537
1587
|
} else if (d.type === "file") {
|
|
1538
1588
|
const u = d, v = document.createElement("input");
|
|
1539
1589
|
v.className = "foisit-form-input", v.type = "file", u.accept && Array.isArray(u.accept) && (v.accept = u.accept.join(",")), u.multiple && (v.multiple = !0), u.capture && (u.capture === !0 ? v.setAttribute("capture", "") : v.setAttribute("capture", String(u.capture))), v.addEventListener("change", async () => {
|
|
@@ -1544,7 +1594,7 @@ class zt {
|
|
|
1544
1594
|
p.textContent = `Please select at most ${S} file(s).`, p.style.display = "block";
|
|
1545
1595
|
return;
|
|
1546
1596
|
}
|
|
1547
|
-
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((w,
|
|
1597
|
+
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((w, U) => w + U.size, 0);
|
|
1548
1598
|
if (x.some((w) => w.size > b)) {
|
|
1549
1599
|
p.textContent = `One or more files exceed the maximum size of ${Math.round(b / 1024)} KB.`, p.style.display = "block";
|
|
1550
1600
|
return;
|
|
@@ -1556,45 +1606,45 @@ class zt {
|
|
|
1556
1606
|
}
|
|
1557
1607
|
if (u.accept && Array.isArray(u.accept)) {
|
|
1558
1608
|
const w = u.accept;
|
|
1559
|
-
if (!x.every((
|
|
1609
|
+
if (!x.every((B) => B.type ? w.some((W) => W.startsWith(".") ? B.name.toLowerCase().endsWith(W.toLowerCase()) : B.type === W || B.type.startsWith(W.split("/")[0] + "/")) : !0)) {
|
|
1560
1610
|
p.textContent = "One or more files have an unsupported type.", p.style.display = "block";
|
|
1561
1611
|
return;
|
|
1562
1612
|
}
|
|
1563
1613
|
}
|
|
1564
|
-
}),
|
|
1614
|
+
}), m = v;
|
|
1565
1615
|
} else {
|
|
1566
1616
|
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))),
|
|
1617
|
+
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
1618
|
}
|
|
1569
1619
|
const y = a();
|
|
1570
|
-
l.appendChild(
|
|
1620
|
+
l.appendChild(m), l.appendChild(y), o.push({
|
|
1571
1621
|
name: d.name,
|
|
1572
1622
|
type: d.type,
|
|
1573
|
-
el:
|
|
1623
|
+
el: m,
|
|
1574
1624
|
required: d.required
|
|
1575
1625
|
}), s.appendChild(l);
|
|
1576
1626
|
});
|
|
1577
1627
|
const c = document.createElement("div");
|
|
1578
1628
|
c.className = "foisit-form-actions";
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1629
|
+
const h = document.createElement("button");
|
|
1630
|
+
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
1631
|
d.preventDefault();
|
|
1582
1632
|
const l = {};
|
|
1583
1633
|
let f = !1;
|
|
1584
|
-
s.querySelectorAll(".foisit-form-error").forEach((
|
|
1585
|
-
|
|
1586
|
-
}), s.querySelectorAll(".foisit-form-input").forEach((
|
|
1587
|
-
|
|
1634
|
+
s.querySelectorAll(".foisit-form-error").forEach((m) => {
|
|
1635
|
+
m.style.display = "none", m.textContent = "";
|
|
1636
|
+
}), s.querySelectorAll(".foisit-form-input").forEach((m) => {
|
|
1637
|
+
m.classList.remove("foisit-error-border");
|
|
1588
1638
|
});
|
|
1589
|
-
for (const
|
|
1590
|
-
if (
|
|
1591
|
-
const x =
|
|
1592
|
-
if (
|
|
1639
|
+
for (const m of o) {
|
|
1640
|
+
if (m.type === "file") {
|
|
1641
|
+
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(".foisit-form-error"), S = m.el, b = Array.from(S.files || []);
|
|
1642
|
+
if (m.required && b.length === 0) {
|
|
1593
1643
|
f = !0, S.classList.add("foisit-error-border"), p && (p.textContent = "This file is required", p.style.display = "block");
|
|
1594
1644
|
continue;
|
|
1595
1645
|
}
|
|
1596
1646
|
if (b.length === 0) continue;
|
|
1597
|
-
const g = (
|
|
1647
|
+
const g = (n ?? []).find((w) => w.name === m.name), $ = (g == null ? void 0 : g.delivery) ?? "file";
|
|
1598
1648
|
if (g != null && g.maxWidth || g != null && g.maxHeight)
|
|
1599
1649
|
try {
|
|
1600
1650
|
const w = await this.getImageDimensions(b[0]);
|
|
@@ -1618,44 +1668,44 @@ class zt {
|
|
|
1618
1668
|
} catch {
|
|
1619
1669
|
}
|
|
1620
1670
|
if ($ === "file")
|
|
1621
|
-
l[
|
|
1671
|
+
l[m.name] = g != null && g.multiple ? b : b[0];
|
|
1622
1672
|
else if ($ === "base64")
|
|
1623
1673
|
try {
|
|
1624
|
-
const w = await Promise.all(b.map((
|
|
1625
|
-
l[
|
|
1674
|
+
const w = await Promise.all(b.map((U) => this.readFileAsDataURL(U)));
|
|
1675
|
+
l[m.name] = g != null && g.multiple ? w : w[0];
|
|
1626
1676
|
} catch {
|
|
1627
1677
|
f = !0, p && (p.textContent = "Failed to encode file(s) to base64.", p.style.display = "block");
|
|
1628
1678
|
continue;
|
|
1629
1679
|
}
|
|
1630
1680
|
continue;
|
|
1631
1681
|
}
|
|
1632
|
-
const y = (
|
|
1633
|
-
if (
|
|
1634
|
-
f = !0,
|
|
1682
|
+
const y = (m.el.value ?? "").toString().trim(), u = m.el.parentElement, v = u == null ? void 0 : u.querySelector(".foisit-form-error");
|
|
1683
|
+
if (m.required && (y == null || y === "")) {
|
|
1684
|
+
f = !0, m.el.classList.add("foisit-error-border"), v && (v.textContent = "This field is required", v.style.display = "block");
|
|
1635
1685
|
continue;
|
|
1636
1686
|
}
|
|
1637
1687
|
if (y !== "")
|
|
1638
|
-
if (
|
|
1688
|
+
if (m.type === "number") {
|
|
1639
1689
|
const x = Number(y);
|
|
1640
|
-
Number.isNaN(x) || (l[
|
|
1690
|
+
Number.isNaN(x) || (l[m.name] = x);
|
|
1641
1691
|
} else
|
|
1642
|
-
l[
|
|
1692
|
+
l[m.name] = y;
|
|
1643
1693
|
}
|
|
1644
1694
|
if (f) {
|
|
1645
1695
|
s.classList.add("foisit-shake"), setTimeout(() => s.classList.remove("foisit-shake"), 400);
|
|
1646
1696
|
return;
|
|
1647
1697
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
}),
|
|
1698
|
+
h.disabled = !0, h.style.opacity = "0.6", o.forEach((m) => {
|
|
1699
|
+
m.el.disabled = !0;
|
|
1700
|
+
}), i(l);
|
|
1651
1701
|
}, this.messagesContainer.appendChild(s), this.scrollToBottom();
|
|
1652
1702
|
}
|
|
1653
1703
|
showLoading() {
|
|
1654
1704
|
if (this.messagesContainer && !this.loadingEl) {
|
|
1655
1705
|
this.loadingEl = document.createElement("div"), this.loadingEl.className = "foisit-loading-dots foisit-bubble system";
|
|
1656
1706
|
for (let e = 0; e < 3; e++) {
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1707
|
+
const n = document.createElement("div");
|
|
1708
|
+
n.className = "foisit-dot", n.style.animation = `foisitPulse 1.4s infinite ease-in-out ${e * 0.2}s`, this.loadingEl.appendChild(n);
|
|
1659
1709
|
}
|
|
1660
1710
|
this.messagesContainer.appendChild(this.loadingEl), this.scrollToBottom();
|
|
1661
1711
|
}
|
|
@@ -1672,44 +1722,44 @@ class zt {
|
|
|
1672
1722
|
(e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1673
1723
|
}
|
|
1674
1724
|
readFileAsDataURL(e) {
|
|
1675
|
-
return new Promise((
|
|
1725
|
+
return new Promise((n, i) => {
|
|
1676
1726
|
const s = new FileReader();
|
|
1677
|
-
s.onerror = () =>
|
|
1727
|
+
s.onerror = () => i(new Error("Failed to read file")), s.onload = () => n(String(s.result)), s.readAsDataURL(e);
|
|
1678
1728
|
});
|
|
1679
1729
|
}
|
|
1680
1730
|
getImageDimensions(e) {
|
|
1681
|
-
return new Promise((
|
|
1731
|
+
return new Promise((n) => {
|
|
1682
1732
|
try {
|
|
1683
|
-
const
|
|
1733
|
+
const i = URL.createObjectURL(e), s = new Image();
|
|
1684
1734
|
s.onload = () => {
|
|
1685
1735
|
const o = { width: s.naturalWidth || s.width, height: s.naturalHeight || s.height };
|
|
1686
|
-
URL.revokeObjectURL(
|
|
1736
|
+
URL.revokeObjectURL(i), n(o);
|
|
1687
1737
|
}, s.onerror = () => {
|
|
1688
|
-
URL.revokeObjectURL(
|
|
1689
|
-
}, s.src =
|
|
1738
|
+
URL.revokeObjectURL(i), n({ width: 0, height: 0 });
|
|
1739
|
+
}, s.src = i;
|
|
1690
1740
|
} catch {
|
|
1691
|
-
|
|
1741
|
+
n({ width: 0, height: 0 });
|
|
1692
1742
|
}
|
|
1693
1743
|
});
|
|
1694
1744
|
}
|
|
1695
1745
|
getMediaDuration(e) {
|
|
1696
|
-
return new Promise((
|
|
1746
|
+
return new Promise((n) => {
|
|
1697
1747
|
try {
|
|
1698
|
-
const
|
|
1748
|
+
const i = URL.createObjectURL(e), s = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
|
|
1699
1749
|
let o = !1;
|
|
1700
1750
|
const r = setTimeout(() => {
|
|
1701
|
-
o || (o = !0, URL.revokeObjectURL(
|
|
1751
|
+
o || (o = !0, URL.revokeObjectURL(i), n(0));
|
|
1702
1752
|
}, 5e3);
|
|
1703
1753
|
s.preload = "metadata", s.onloadedmetadata = () => {
|
|
1704
1754
|
if (o) return;
|
|
1705
1755
|
o = !0, clearTimeout(r);
|
|
1706
1756
|
const c = s.duration || 0;
|
|
1707
|
-
URL.revokeObjectURL(
|
|
1757
|
+
URL.revokeObjectURL(i), n(c);
|
|
1708
1758
|
}, s.onerror = () => {
|
|
1709
|
-
o || (o = !0, clearTimeout(r), URL.revokeObjectURL(
|
|
1710
|
-
}, s.src =
|
|
1759
|
+
o || (o = !0, clearTimeout(r), URL.revokeObjectURL(i), n(0));
|
|
1760
|
+
}, s.src = i;
|
|
1711
1761
|
} catch {
|
|
1712
|
-
|
|
1762
|
+
n(0);
|
|
1713
1763
|
}
|
|
1714
1764
|
});
|
|
1715
1765
|
}
|
|
@@ -2040,23 +2090,23 @@ class zt {
|
|
|
2040
2090
|
`, document.head.appendChild(e);
|
|
2041
2091
|
}
|
|
2042
2092
|
}
|
|
2043
|
-
class
|
|
2093
|
+
class Ut {
|
|
2044
2094
|
constructor(e) {
|
|
2045
2095
|
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new Mt({
|
|
2046
2096
|
enableSmartIntent: this.config.enableSmartIntent !== !1,
|
|
2047
2097
|
intentEndpoint: this.config.intentEndpoint
|
|
2048
|
-
}), this.fallbackHandler = new
|
|
2098
|
+
}), this.fallbackHandler = new Pt(), this.voiceProcessor = new Vt(), this.textToSpeech = new He(), this.stateManager = new qt(), this.gestureHandler = new Ft(), this.overlayManager = new zt({
|
|
2049
2099
|
floatingButton: this.config.floatingButton,
|
|
2050
2100
|
inputPlaceholder: this.config.inputPlaceholder
|
|
2051
|
-
}), this.config.commands.forEach((
|
|
2052
|
-
async (
|
|
2053
|
-
if (typeof
|
|
2054
|
-
this.overlayManager.addMessage(
|
|
2055
|
-
else if (
|
|
2056
|
-
const
|
|
2057
|
-
|
|
2101
|
+
}), 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(
|
|
2102
|
+
async (n) => {
|
|
2103
|
+
if (typeof n == "string")
|
|
2104
|
+
this.overlayManager.addMessage(n, "user");
|
|
2105
|
+
else if (n && typeof n == "object") {
|
|
2106
|
+
const i = this.extractUserLabel(n);
|
|
2107
|
+
i && this.overlayManager.addMessage(i, "user");
|
|
2058
2108
|
}
|
|
2059
|
-
await this.handleCommand(
|
|
2109
|
+
await this.handleCommand(n);
|
|
2060
2110
|
},
|
|
2061
2111
|
() => console.log("AssistantService: Overlay closed.")
|
|
2062
2112
|
);
|
|
@@ -2079,30 +2129,30 @@ class Bt {
|
|
|
2079
2129
|
}
|
|
2080
2130
|
/** Process activation command */
|
|
2081
2131
|
async processActivation(e) {
|
|
2082
|
-
var
|
|
2083
|
-
const
|
|
2084
|
-
|
|
2132
|
+
var i;
|
|
2133
|
+
const n = (i = this.config.activationCommand) == null ? void 0 : i.toLowerCase();
|
|
2134
|
+
n && (e === n ? (console.log("AssistantService: Activation matched."), this.isActivated = !0, this.textToSpeech.speak(
|
|
2085
2135
|
this.config.introMessage || this.defaultIntroMessage
|
|
2086
2136
|
)) : console.log("AssistantService: Activation command not recognized."));
|
|
2087
2137
|
}
|
|
2088
2138
|
/** Handle recognized commands */
|
|
2089
2139
|
async handleCommand(e) {
|
|
2090
2140
|
this.overlayManager.showLoading();
|
|
2091
|
-
let
|
|
2141
|
+
let n;
|
|
2092
2142
|
try {
|
|
2093
|
-
|
|
2143
|
+
n = await this.commandHandler.executeCommand(e);
|
|
2094
2144
|
} finally {
|
|
2095
2145
|
this.overlayManager.hideLoading();
|
|
2096
2146
|
}
|
|
2097
|
-
if (
|
|
2147
|
+
if (n.type === "form" && n.fields) {
|
|
2098
2148
|
this.overlayManager.addForm(
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
async (
|
|
2149
|
+
n.message,
|
|
2150
|
+
n.fields,
|
|
2151
|
+
async (i) => {
|
|
2102
2152
|
this.overlayManager.showLoading();
|
|
2103
2153
|
let s;
|
|
2104
2154
|
try {
|
|
2105
|
-
s = await this.commandHandler.executeCommand(
|
|
2155
|
+
s = await this.commandHandler.executeCommand(i);
|
|
2106
2156
|
} finally {
|
|
2107
2157
|
this.overlayManager.hideLoading();
|
|
2108
2158
|
}
|
|
@@ -2111,12 +2161,16 @@ class Bt {
|
|
|
2111
2161
|
);
|
|
2112
2162
|
return;
|
|
2113
2163
|
}
|
|
2114
|
-
if (
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2164
|
+
if (n.type === "error") {
|
|
2165
|
+
const i = typeof e == "string" ? e : "";
|
|
2166
|
+
i ? (this.fallbackHandler.handleFallback(i), this.overlayManager.addMessage(this.fallbackHandler.getFallbackMessage(), "system")) : n.message && this.overlayManager.addMessage(n.message, "system");
|
|
2117
2167
|
return;
|
|
2118
2168
|
}
|
|
2119
|
-
|
|
2169
|
+
if ((n.type === "ambiguous" || n.type === "confirm") && n.options) {
|
|
2170
|
+
n.message && this.overlayManager.addMessage(n.message, "system"), this.overlayManager.addOptions(n.options);
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
n.message && this.overlayManager.addMessage(n.message, "system");
|
|
2120
2174
|
}
|
|
2121
2175
|
/**
|
|
2122
2176
|
* Cleanup resources
|
|
@@ -2130,15 +2184,15 @@ class Bt {
|
|
|
2130
2184
|
this.overlayManager.addForm(
|
|
2131
2185
|
e.message,
|
|
2132
2186
|
e.fields,
|
|
2133
|
-
async (
|
|
2187
|
+
async (n) => {
|
|
2134
2188
|
this.overlayManager.showLoading();
|
|
2135
|
-
let
|
|
2189
|
+
let i;
|
|
2136
2190
|
try {
|
|
2137
|
-
|
|
2191
|
+
i = await this.commandHandler.executeCommand(n);
|
|
2138
2192
|
} finally {
|
|
2139
2193
|
this.overlayManager.hideLoading();
|
|
2140
2194
|
}
|
|
2141
|
-
this.processResponse(
|
|
2195
|
+
this.processResponse(i);
|
|
2142
2196
|
}
|
|
2143
2197
|
);
|
|
2144
2198
|
return;
|
|
@@ -2150,8 +2204,8 @@ class Bt {
|
|
|
2150
2204
|
e.message && this.overlayManager.addMessage(e.message, "system");
|
|
2151
2205
|
}
|
|
2152
2206
|
/** 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,
|
|
2207
|
+
addCommand(e, n) {
|
|
2208
|
+
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e, n);
|
|
2155
2209
|
}
|
|
2156
2210
|
/** Remove a command dynamically */
|
|
2157
2211
|
removeCommand(e) {
|
|
@@ -2162,30 +2216,30 @@ class Bt {
|
|
|
2162
2216
|
return this.commandHandler.getCommands();
|
|
2163
2217
|
}
|
|
2164
2218
|
/** Toggle the assistant overlay */
|
|
2165
|
-
toggle(e,
|
|
2219
|
+
toggle(e, n) {
|
|
2166
2220
|
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(
|
|
2221
|
+
async (i) => {
|
|
2222
|
+
if (typeof i == "string")
|
|
2223
|
+
this.overlayManager.addMessage(i, "user");
|
|
2224
|
+
else if (i && typeof i == "object") {
|
|
2225
|
+
const s = this.extractUserLabel(i);
|
|
2172
2226
|
s && this.overlayManager.addMessage(s, "user");
|
|
2173
2227
|
}
|
|
2174
|
-
e && e(
|
|
2228
|
+
e && e(i), await this.handleCommand(i);
|
|
2175
2229
|
},
|
|
2176
2230
|
() => {
|
|
2177
|
-
console.log("AssistantService: Overlay closed."),
|
|
2231
|
+
console.log("AssistantService: Overlay closed."), n && n();
|
|
2178
2232
|
}
|
|
2179
2233
|
);
|
|
2180
2234
|
}
|
|
2181
2235
|
extractUserLabel(e) {
|
|
2182
|
-
const
|
|
2183
|
-
if (typeof
|
|
2184
|
-
const
|
|
2185
|
-
return typeof
|
|
2236
|
+
const n = e.label;
|
|
2237
|
+
if (typeof n == "string" && n.trim()) return n.trim();
|
|
2238
|
+
const i = e.commandId;
|
|
2239
|
+
return typeof i == "string" && i.trim() ? i.trim() : null;
|
|
2186
2240
|
}
|
|
2187
2241
|
}
|
|
2188
|
-
const
|
|
2242
|
+
const Bt = /* @__PURE__ */ mt({
|
|
2189
2243
|
name: "AssistantProvider",
|
|
2190
2244
|
props: {
|
|
2191
2245
|
config: {
|
|
@@ -2194,22 +2248,22 @@ const Wt = /* @__PURE__ */ ht({
|
|
|
2194
2248
|
}
|
|
2195
2249
|
},
|
|
2196
2250
|
setup(t, { slots: e }) {
|
|
2197
|
-
const
|
|
2198
|
-
return dt("assistantService",
|
|
2199
|
-
var
|
|
2200
|
-
return (
|
|
2251
|
+
const n = new Ut(t.config);
|
|
2252
|
+
return dt("assistantService", n), () => {
|
|
2253
|
+
var i;
|
|
2254
|
+
return (i = e.default) == null ? void 0 : i.call(e);
|
|
2201
2255
|
};
|
|
2202
2256
|
}
|
|
2203
|
-
}),
|
|
2204
|
-
const
|
|
2205
|
-
for (const [
|
|
2206
|
-
i
|
|
2207
|
-
return
|
|
2257
|
+
}), Wt = (t, e) => {
|
|
2258
|
+
const n = t.__vccOpts || t;
|
|
2259
|
+
for (const [i, s] of e)
|
|
2260
|
+
n[i] = s;
|
|
2261
|
+
return n;
|
|
2208
2262
|
};
|
|
2209
|
-
function jt(t, e,
|
|
2263
|
+
function jt(t, e, n, i, s, o) {
|
|
2210
2264
|
return gt(t.$slots, "default");
|
|
2211
2265
|
}
|
|
2212
|
-
const Kt = /* @__PURE__ */
|
|
2266
|
+
const Kt = /* @__PURE__ */ Wt(Bt, [["render", jt]]), Yt = () => {
|
|
2213
2267
|
const t = ut("assistantService");
|
|
2214
2268
|
if (!t)
|
|
2215
2269
|
throw new Error("useAssistant must be used within an AssistantProvider");
|
|
@@ -2217,6 +2271,6 @@ const Kt = /* @__PURE__ */ Ut(Wt, [["render", jt]]), Yt = () => {
|
|
|
2217
2271
|
};
|
|
2218
2272
|
export {
|
|
2219
2273
|
Kt as AssistantProvider,
|
|
2220
|
-
|
|
2274
|
+
Ut as AssistantService,
|
|
2221
2275
|
Yt as useAssistant
|
|
2222
2276
|
};
|