@foisit/vue-wrapper 2.4.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -6
- package/index.d.ts +1 -0
- package/index.mjs +1163 -848
- package/lib/services/AssistantService.d.ts +10 -0
- package/package.json +9 -2
package/index.mjs
CHANGED
|
@@ -3,46 +3,46 @@
|
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
const
|
|
7
|
-
},
|
|
8
|
-
(
|
|
9
|
-
let
|
|
10
|
-
const Q = () =>
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
6
|
+
const se = process.env.NODE_ENV !== "production" ? Object.freeze({}) : {}, ze = process.env.NODE_ENV !== "production" ? Object.freeze([]) : [], we = () => {
|
|
7
|
+
}, Be = (i) => i.charCodeAt(0) === 111 && i.charCodeAt(1) === 110 && // uppercase letter
|
|
8
|
+
(i.charCodeAt(2) > 122 || i.charCodeAt(2) < 97), z = Object.assign, E = Array.isArray, M = (i) => typeof i == "function", R = (i) => typeof i == "string", xe = (i) => typeof i == "symbol", T = (i) => i !== null && typeof i == "object";
|
|
9
|
+
let he;
|
|
10
|
+
const Q = () => he || (he = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
|
|
11
|
+
function le(i) {
|
|
12
|
+
if (E(i)) {
|
|
13
13
|
const e = {};
|
|
14
|
-
for (let
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
for (const o in
|
|
18
|
-
e[o] =
|
|
14
|
+
for (let t = 0; t < i.length; t++) {
|
|
15
|
+
const s = i[t], n = R(s) ? Ye(s) : le(s);
|
|
16
|
+
if (n)
|
|
17
|
+
for (const o in n)
|
|
18
|
+
e[o] = n[o];
|
|
19
19
|
}
|
|
20
20
|
return e;
|
|
21
|
-
} else if (
|
|
22
|
-
return
|
|
21
|
+
} else if (R(i) || T(i))
|
|
22
|
+
return i;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
24
|
+
const Ue = /;(?![^(]*\))/g, We = /:([^]+)/, je = /\/\*[^]*?\*\//g;
|
|
25
|
+
function Ye(i) {
|
|
26
26
|
const e = {};
|
|
27
|
-
return
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
|
|
27
|
+
return i.replace(je, "").split(Ue).forEach((t) => {
|
|
28
|
+
if (t) {
|
|
29
|
+
const s = t.split(We);
|
|
30
|
+
s.length > 1 && (e[s[0].trim()] = s[1].trim());
|
|
31
31
|
}
|
|
32
32
|
}), e;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function ce(i) {
|
|
35
35
|
let e = "";
|
|
36
|
-
if (
|
|
37
|
-
e =
|
|
38
|
-
else if (
|
|
39
|
-
for (let
|
|
40
|
-
const
|
|
41
|
-
|
|
36
|
+
if (R(i))
|
|
37
|
+
e = i;
|
|
38
|
+
else if (E(i))
|
|
39
|
+
for (let t = 0; t < i.length; t++) {
|
|
40
|
+
const s = ce(i[t]);
|
|
41
|
+
s && (e += s + " ");
|
|
42
42
|
}
|
|
43
|
-
else if (
|
|
44
|
-
for (const
|
|
45
|
-
t
|
|
43
|
+
else if (T(i))
|
|
44
|
+
for (const t in i)
|
|
45
|
+
i[t] && (e += t + " ");
|
|
46
46
|
return e.trim();
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
@@ -54,111 +54,111 @@ 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((
|
|
57
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((i) => i !== "arguments" && i !== "caller").map((i) => Symbol[i]).filter(xe)
|
|
58
58
|
);
|
|
59
|
-
function
|
|
60
|
-
return
|
|
59
|
+
function Ce(i) {
|
|
60
|
+
return ne(i) ? Ce(i.__v_raw) : !!(i && i.__v_isReactive);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
return !!(
|
|
62
|
+
function ne(i) {
|
|
63
|
+
return !!(i && i.__v_isReadonly);
|
|
64
64
|
}
|
|
65
|
-
function Z(
|
|
66
|
-
return !!(
|
|
65
|
+
function Z(i) {
|
|
66
|
+
return !!(i && i.__v_isShallow);
|
|
67
67
|
}
|
|
68
|
-
function oe(
|
|
69
|
-
return
|
|
68
|
+
function oe(i) {
|
|
69
|
+
return i ? !!i.__v_raw : !1;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
const e =
|
|
73
|
-
return e ?
|
|
71
|
+
function O(i) {
|
|
72
|
+
const e = i && i.__v_raw;
|
|
73
|
+
return e ? O(e) : i;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
75
|
+
function de(i) {
|
|
76
|
+
return i ? i.__v_isRef === !0 : !1;
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* @vue/runtime-core v3.5.26
|
|
80
80
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
81
81
|
* @license MIT
|
|
82
82
|
**/
|
|
83
|
-
const
|
|
84
|
-
function
|
|
85
|
-
|
|
83
|
+
const $ = [];
|
|
84
|
+
function Ge(i) {
|
|
85
|
+
$.push(i);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
87
|
+
function Ke() {
|
|
88
|
+
$.pop();
|
|
89
89
|
}
|
|
90
90
|
let ee = !1;
|
|
91
|
-
function _(
|
|
91
|
+
function _(i, ...e) {
|
|
92
92
|
if (ee) return;
|
|
93
93
|
ee = !0;
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
const t = $.length ? $[$.length - 1].component : null, s = t && t.appContext.config.warnHandler, n = Je();
|
|
95
|
+
if (s)
|
|
96
|
+
ue(
|
|
97
|
+
s,
|
|
98
|
+
t,
|
|
99
99
|
11,
|
|
100
100
|
[
|
|
101
101
|
// eslint-disable-next-line no-restricted-syntax
|
|
102
|
-
|
|
103
|
-
var
|
|
104
|
-
return (
|
|
102
|
+
i + e.map((o) => {
|
|
103
|
+
var a, r;
|
|
104
|
+
return (r = (a = o.toString) == null ? void 0 : a.call(o)) != null ? r : JSON.stringify(o);
|
|
105
105
|
}).join(""),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
({ vnode: o }) => `at <${
|
|
106
|
+
t && t.proxy,
|
|
107
|
+
n.map(
|
|
108
|
+
({ vnode: o }) => `at <${Ve(t, o.type)}>`
|
|
109
109
|
).join(`
|
|
110
110
|
`),
|
|
111
|
-
|
|
111
|
+
n
|
|
112
112
|
]
|
|
113
113
|
);
|
|
114
114
|
else {
|
|
115
|
-
const o = [`[Vue warn]: ${
|
|
116
|
-
|
|
117
|
-
`, ...
|
|
115
|
+
const o = [`[Vue warn]: ${i}`, ...e];
|
|
116
|
+
n.length && o.push(`
|
|
117
|
+
`, ...Xe(n)), console.warn(...o);
|
|
118
118
|
}
|
|
119
119
|
ee = !1;
|
|
120
120
|
}
|
|
121
121
|
function Je() {
|
|
122
|
-
let
|
|
123
|
-
if (!
|
|
122
|
+
let i = $[$.length - 1];
|
|
123
|
+
if (!i)
|
|
124
124
|
return [];
|
|
125
125
|
const e = [];
|
|
126
|
-
for (;
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
vnode:
|
|
126
|
+
for (; i; ) {
|
|
127
|
+
const t = e[0];
|
|
128
|
+
t && t.vnode === i ? t.recurseCount++ : e.push({
|
|
129
|
+
vnode: i,
|
|
130
130
|
recurseCount: 0
|
|
131
131
|
});
|
|
132
|
-
const
|
|
133
|
-
|
|
132
|
+
const s = i.component && i.component.parent;
|
|
133
|
+
i = s && s.vnode;
|
|
134
134
|
}
|
|
135
135
|
return e;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Xe(i) {
|
|
138
138
|
const e = [];
|
|
139
|
-
return
|
|
140
|
-
e.push(...
|
|
141
|
-
`], ...
|
|
139
|
+
return i.forEach((t, s) => {
|
|
140
|
+
e.push(...s === 0 ? [] : [`
|
|
141
|
+
`], ...Qe(t));
|
|
142
142
|
}), e;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
)}`, o = ">" +
|
|
150
|
-
return
|
|
144
|
+
function Qe({ vnode: i, recurseCount: e }) {
|
|
145
|
+
const t = e > 0 ? `... (${e} recursive calls)` : "", s = i.component ? i.component.parent == null : !1, n = ` at <${Ve(
|
|
146
|
+
i.component,
|
|
147
|
+
i.type,
|
|
148
|
+
s
|
|
149
|
+
)}`, o = ">" + t;
|
|
150
|
+
return i.props ? [n, ...Ze(i.props), o] : [n + o];
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
const e = [],
|
|
154
|
-
return
|
|
155
|
-
e.push(...Se(
|
|
156
|
-
}),
|
|
152
|
+
function Ze(i) {
|
|
153
|
+
const e = [], t = Object.keys(i);
|
|
154
|
+
return t.slice(0, 3).forEach((s) => {
|
|
155
|
+
e.push(...Se(s, i[s]));
|
|
156
|
+
}), t.length > 3 && e.push(" ..."), e;
|
|
157
157
|
}
|
|
158
|
-
function Se(
|
|
159
|
-
return
|
|
158
|
+
function Se(i, e, t) {
|
|
159
|
+
return R(e) ? (e = JSON.stringify(e), t ? e : [`${i}=${e}`]) : typeof e == "number" || typeof e == "boolean" || e == null ? t ? e : [`${i}=${e}`] : de(e) ? (e = Se(i, O(e.value), !0), t ? e : [`${i}=Ref<`, e, ">"]) : M(e) ? [`${i}=fn${e.name ? `<${e.name}>` : ""}`] : (e = O(e), t ? e : [`${i}=`, e]);
|
|
160
160
|
}
|
|
161
|
-
const
|
|
161
|
+
const ke = {
|
|
162
162
|
sp: "serverPrefetch hook",
|
|
163
163
|
bc: "beforeCreate hook",
|
|
164
164
|
c: "created hook",
|
|
@@ -191,312 +191,312 @@ const Ce = {
|
|
|
191
191
|
15: "component update",
|
|
192
192
|
16: "app unmount cleanup function"
|
|
193
193
|
};
|
|
194
|
-
function
|
|
194
|
+
function ue(i, e, t, s) {
|
|
195
195
|
try {
|
|
196
|
-
return
|
|
197
|
-
} catch (
|
|
198
|
-
Ee(
|
|
196
|
+
return s ? i(...s) : i();
|
|
197
|
+
} catch (n) {
|
|
198
|
+
Ee(n, e, t);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
function Ee(
|
|
202
|
-
const
|
|
201
|
+
function Ee(i, e, t, s = !0) {
|
|
202
|
+
const n = e ? e.vnode : null, { errorHandler: o, throwUnhandledErrorInProduction: a } = e && e.appContext.config || se;
|
|
203
203
|
if (e) {
|
|
204
|
-
let
|
|
205
|
-
const c = e.proxy, h = process.env.NODE_ENV !== "production" ?
|
|
206
|
-
for (;
|
|
207
|
-
const d =
|
|
204
|
+
let r = e.parent;
|
|
205
|
+
const c = e.proxy, h = process.env.NODE_ENV !== "production" ? ke[t] : `https://vuejs.org/error-reference/#runtime-${t}`;
|
|
206
|
+
for (; r; ) {
|
|
207
|
+
const d = r.ec;
|
|
208
208
|
if (d) {
|
|
209
209
|
for (let l = 0; l < d.length; l++)
|
|
210
|
-
if (d[l](
|
|
210
|
+
if (d[l](i, c, h) === !1)
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
r = r.parent;
|
|
214
214
|
}
|
|
215
215
|
if (o) {
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
ue(o, null, 10, [
|
|
217
|
+
i,
|
|
218
218
|
c,
|
|
219
219
|
h
|
|
220
220
|
]);
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
et(i, t, n, s, a);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function et(i, e, t, s = !0, n = !1) {
|
|
227
227
|
if (process.env.NODE_ENV !== "production") {
|
|
228
|
-
const o =
|
|
229
|
-
if (
|
|
230
|
-
throw
|
|
231
|
-
console.error(
|
|
228
|
+
const o = ke[e];
|
|
229
|
+
if (t && Ge(t), _(`Unhandled error${o ? ` during execution of ${o}` : ""}`), t && Ke(), s)
|
|
230
|
+
throw i;
|
|
231
|
+
console.error(i);
|
|
232
232
|
} else {
|
|
233
|
-
if (
|
|
234
|
-
throw
|
|
235
|
-
console.error(
|
|
233
|
+
if (n)
|
|
234
|
+
throw i;
|
|
235
|
+
console.error(i);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
const
|
|
239
|
-
let
|
|
240
|
-
const
|
|
241
|
-
let
|
|
242
|
-
const
|
|
238
|
+
const S = [];
|
|
239
|
+
let A = -1;
|
|
240
|
+
const P = [];
|
|
241
|
+
let N = null, F = 0;
|
|
242
|
+
const tt = /* @__PURE__ */ Promise.resolve();
|
|
243
243
|
let re = null;
|
|
244
|
-
const
|
|
245
|
-
function
|
|
246
|
-
let e =
|
|
247
|
-
for (; e <
|
|
248
|
-
const
|
|
249
|
-
o <
|
|
244
|
+
const it = 100;
|
|
245
|
+
function st(i) {
|
|
246
|
+
let e = A + 1, t = S.length;
|
|
247
|
+
for (; e < t; ) {
|
|
248
|
+
const s = e + t >>> 1, n = S[s], o = D(n);
|
|
249
|
+
o < i || o === i && n.flags & 2 ? e = s + 1 : t = s;
|
|
250
250
|
}
|
|
251
251
|
return e;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
if (!(
|
|
255
|
-
const e =
|
|
256
|
-
!
|
|
257
|
-
!(
|
|
253
|
+
function nt(i) {
|
|
254
|
+
if (!(i.flags & 1)) {
|
|
255
|
+
const e = D(i), t = S[S.length - 1];
|
|
256
|
+
!t || // fast path when the job id is larger than the tail
|
|
257
|
+
!(i.flags & 2) && e >= D(t) ? S.push(i) : S.splice(st(e), 0, i), i.flags |= 1, _e();
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
re || (re =
|
|
260
|
+
function _e() {
|
|
261
|
+
re || (re = tt.then(Ae));
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
263
|
+
function ot(i) {
|
|
264
|
+
E(i) ? P.push(...i) : N && i.id === -1 ? N.splice(F + 1, 0, i) : i.flags & 1 || (P.push(i), i.flags |= 1), _e();
|
|
265
265
|
}
|
|
266
|
-
function
|
|
267
|
-
if (
|
|
268
|
-
const e = [...new Set(
|
|
269
|
-
(
|
|
266
|
+
function rt(i) {
|
|
267
|
+
if (P.length) {
|
|
268
|
+
const e = [...new Set(P)].sort(
|
|
269
|
+
(t, s) => D(t) - D(s)
|
|
270
270
|
);
|
|
271
|
-
if (
|
|
272
|
-
|
|
271
|
+
if (P.length = 0, N) {
|
|
272
|
+
N.push(...e);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
for (
|
|
276
|
-
const
|
|
277
|
-
process.env.NODE_ENV !== "production" &&
|
|
275
|
+
for (N = e, process.env.NODE_ENV !== "production" && (i = i || /* @__PURE__ */ new Map()), F = 0; F < N.length; F++) {
|
|
276
|
+
const t = N[F];
|
|
277
|
+
process.env.NODE_ENV !== "production" && Le(i, t) || (t.flags & 4 && (t.flags &= -2), t.flags & 8 || t(), t.flags &= -2);
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
N = null, F = 0;
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
function
|
|
284
|
-
process.env.NODE_ENV !== "production" && (
|
|
285
|
-
const e = process.env.NODE_ENV !== "production" ? (
|
|
282
|
+
const D = (i) => i.id == null ? i.flags & 2 ? -1 : 1 / 0 : i.id;
|
|
283
|
+
function Ae(i) {
|
|
284
|
+
process.env.NODE_ENV !== "production" && (i = i || /* @__PURE__ */ new Map());
|
|
285
|
+
const e = process.env.NODE_ENV !== "production" ? (t) => Le(i, t) : we;
|
|
286
286
|
try {
|
|
287
|
-
for (
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
if (process.env.NODE_ENV !== "production" && e(
|
|
287
|
+
for (A = 0; A < S.length; A++) {
|
|
288
|
+
const t = S[A];
|
|
289
|
+
if (t && !(t.flags & 8)) {
|
|
290
|
+
if (process.env.NODE_ENV !== "production" && e(t))
|
|
291
291
|
continue;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
),
|
|
292
|
+
t.flags & 4 && (t.flags &= -2), ue(
|
|
293
|
+
t,
|
|
294
|
+
t.i,
|
|
295
|
+
t.i ? 15 : 14
|
|
296
|
+
), t.flags & 4 || (t.flags &= -2);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
} finally {
|
|
300
|
-
for (;
|
|
301
|
-
const
|
|
302
|
-
|
|
300
|
+
for (; A < S.length; A++) {
|
|
301
|
+
const t = S[A];
|
|
302
|
+
t && (t.flags &= -2);
|
|
303
303
|
}
|
|
304
|
-
|
|
304
|
+
A = -1, S.length = 0, rt(i), re = null, (S.length || P.length) && Ae(i);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
307
|
+
function Le(i, e) {
|
|
308
|
+
const t = i.get(e) || 0;
|
|
309
|
+
if (t > it) {
|
|
310
|
+
const s = e.i, n = s && Pe(s.type);
|
|
311
311
|
return Ee(
|
|
312
|
-
`Maximum recursive updates exceeded${
|
|
312
|
+
`Maximum recursive updates exceeded${n ? ` in component <${n}>` : ""}. 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
|
|
317
|
+
return i.set(e, t + 1), !1;
|
|
318
318
|
}
|
|
319
319
|
const te = /* @__PURE__ */ new Map();
|
|
320
320
|
process.env.NODE_ENV !== "production" && (Q().__VUE_HMR_RUNTIME__ = {
|
|
321
|
-
createRecord:
|
|
322
|
-
rerender:
|
|
323
|
-
reload:
|
|
321
|
+
createRecord: ie(at),
|
|
322
|
+
rerender: ie(lt),
|
|
323
|
+
reload: ie(ct)
|
|
324
324
|
});
|
|
325
|
-
const
|
|
326
|
-
function
|
|
327
|
-
return
|
|
328
|
-
initialDef:
|
|
325
|
+
const K = /* @__PURE__ */ new Map();
|
|
326
|
+
function at(i, e) {
|
|
327
|
+
return K.has(i) ? !1 : (K.set(i, {
|
|
328
|
+
initialDef: J(e),
|
|
329
329
|
instances: /* @__PURE__ */ new Set()
|
|
330
330
|
}), !0);
|
|
331
331
|
}
|
|
332
|
-
function
|
|
333
|
-
return
|
|
332
|
+
function J(i) {
|
|
333
|
+
return De(i) ? i.__vccOpts : i;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
e && (
|
|
335
|
+
function lt(i, e) {
|
|
336
|
+
const t = K.get(i);
|
|
337
|
+
t && (t.initialDef.render = e, [...t.instances].forEach((s) => {
|
|
338
|
+
e && (s.render = e, J(s.type).render = e), s.renderCache = [], s.job.flags & 8 || s.update();
|
|
339
339
|
}));
|
|
340
340
|
}
|
|
341
|
-
function
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
344
|
-
e =
|
|
345
|
-
const
|
|
346
|
-
for (let
|
|
347
|
-
const o =
|
|
348
|
-
let
|
|
349
|
-
|
|
350
|
-
o.job.flags & 8 || (o.parent.update(),
|
|
341
|
+
function ct(i, e) {
|
|
342
|
+
const t = K.get(i);
|
|
343
|
+
if (!t) return;
|
|
344
|
+
e = J(e), pe(t.initialDef, e);
|
|
345
|
+
const s = [...t.instances];
|
|
346
|
+
for (let n = 0; n < s.length; n++) {
|
|
347
|
+
const o = s[n], a = J(o.type);
|
|
348
|
+
let r = te.get(a);
|
|
349
|
+
r || (a !== t.initialDef && pe(a, e), te.set(a, r = /* @__PURE__ */ new Set())), r.add(o), o.appContext.propsCache.delete(o.type), o.appContext.emitsCache.delete(o.type), o.appContext.optionsCache.delete(o.type), o.ceReload ? (r.add(o), o.ceReload(e.styles), r.delete(o)) : o.parent ? nt(() => {
|
|
350
|
+
o.job.flags & 8 || (o.parent.update(), r.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."
|
|
353
|
-
), o.root.ce && o !== o.root && o.root.ce._removeChildStyle(
|
|
353
|
+
), o.root.ce && o !== o.root && o.root.ce._removeChildStyle(a);
|
|
354
354
|
}
|
|
355
|
-
|
|
355
|
+
ot(() => {
|
|
356
356
|
te.clear();
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
|
-
function
|
|
360
|
-
z(
|
|
361
|
-
for (const
|
|
362
|
-
|
|
359
|
+
function pe(i, e) {
|
|
360
|
+
z(i, e);
|
|
361
|
+
for (const t in i)
|
|
362
|
+
t !== "__file" && !(t in e) && delete i[t];
|
|
363
363
|
}
|
|
364
|
-
function
|
|
365
|
-
return (e,
|
|
364
|
+
function ie(i) {
|
|
365
|
+
return (e, t) => {
|
|
366
366
|
try {
|
|
367
|
-
return
|
|
368
|
-
} catch (
|
|
369
|
-
console.error(
|
|
367
|
+
return i(e, t);
|
|
368
|
+
} catch (s) {
|
|
369
|
+
console.error(s), console.warn(
|
|
370
370
|
"[HMR] Something went wrong during Vue component hot-reload. Full reload required."
|
|
371
371
|
);
|
|
372
372
|
}
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
let
|
|
376
|
-
function
|
|
377
|
-
var
|
|
378
|
-
|
|
375
|
+
let H, j = [];
|
|
376
|
+
function Ie(i, e) {
|
|
377
|
+
var t, s;
|
|
378
|
+
H = i, H ? (H.enabled = !0, j.forEach(({ event: n, args: o }) => H.emit(n, ...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
|
-
!((
|
|
382
|
-
|
|
381
|
+
!((s = (t = window.navigator) == null ? void 0 : t.userAgent) != null && s.includes("jsdom")) ? ((e.__VUE_DEVTOOLS_HOOK_REPLAY__ = e.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((o) => {
|
|
382
|
+
Ie(o, e);
|
|
383
383
|
}), setTimeout(() => {
|
|
384
|
-
|
|
384
|
+
H || (e.__VUE_DEVTOOLS_HOOK_REPLAY__ = null, j = []);
|
|
385
385
|
}, 3e3)) : j = [];
|
|
386
386
|
}
|
|
387
|
-
let
|
|
388
|
-
function
|
|
389
|
-
if (process.env.NODE_ENV !== "production" && (!
|
|
390
|
-
let
|
|
391
|
-
const
|
|
392
|
-
|
|
387
|
+
let I = null, dt = null;
|
|
388
|
+
function ut(i, e) {
|
|
389
|
+
if (process.env.NODE_ENV !== "production" && (!L || L.isMounted) && _("provide() can only be used inside setup()."), L) {
|
|
390
|
+
let t = L.provides;
|
|
391
|
+
const s = L.parent && L.parent.provides;
|
|
392
|
+
s === t && (t = L.provides = Object.create(s)), t[i] = e;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
398
|
-
let
|
|
399
|
-
if (
|
|
400
|
-
return
|
|
395
|
+
function ft(i, e, t = !1) {
|
|
396
|
+
const s = Mt();
|
|
397
|
+
if (s || vt) {
|
|
398
|
+
let n = s ? s.parent == null || s.ce ? s.vnode.appContext && s.vnode.appContext.provides : s.parent.provides : void 0;
|
|
399
|
+
if (n && i in n)
|
|
400
|
+
return n[i];
|
|
401
401
|
if (arguments.length > 1)
|
|
402
|
-
return
|
|
403
|
-
process.env.NODE_ENV !== "production" && _(`injection "${String(
|
|
402
|
+
return t && M(e) ? e.call(s && s.proxy) : e;
|
|
403
|
+
process.env.NODE_ENV !== "production" && _(`injection "${String(i)}" not found.`);
|
|
404
404
|
} else process.env.NODE_ENV !== "production" && _("inject() can only be used inside setup() or functional components.");
|
|
405
405
|
}
|
|
406
|
-
const
|
|
407
|
-
function
|
|
408
|
-
|
|
406
|
+
const mt = (i) => i.__isTeleport;
|
|
407
|
+
function Me(i, e) {
|
|
408
|
+
i.shapeFlag & 6 && i.component ? (i.transition = e, Me(i.component.subTree, e)) : i.shapeFlag & 128 ? (i.ssContent.transition = e.clone(i.ssContent), i.ssFallback.transition = e.clone(i.ssFallback)) : i.transition = e;
|
|
409
409
|
}
|
|
410
410
|
// @__NO_SIDE_EFFECTS__
|
|
411
|
-
function
|
|
412
|
-
return
|
|
411
|
+
function ht(i, e) {
|
|
412
|
+
return M(i) ? (
|
|
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
|
-
z({ name:
|
|
416
|
-
) :
|
|
415
|
+
z({ name: i.name }, e, { setup: i })
|
|
416
|
+
) : i;
|
|
417
417
|
}
|
|
418
418
|
Q().requestIdleCallback;
|
|
419
419
|
Q().cancelIdleCallback;
|
|
420
|
-
const
|
|
421
|
-
function
|
|
422
|
-
if (
|
|
423
|
-
const h = Object.keys(
|
|
424
|
-
return
|
|
420
|
+
const pt = (i) => !!i.type.__asyncLoader, gt = /* @__PURE__ */ Symbol.for("v-ndc");
|
|
421
|
+
function bt(i, e, t = {}, s, n) {
|
|
422
|
+
if (I.ce || I.parent && pt(I.parent) && I.parent.ce) {
|
|
423
|
+
const h = Object.keys(t).length > 0;
|
|
424
|
+
return ge(), be(
|
|
425
425
|
q,
|
|
426
426
|
null,
|
|
427
|
-
[
|
|
427
|
+
[fe("slot", t, s)],
|
|
428
428
|
h ? -2 : 64
|
|
429
429
|
);
|
|
430
430
|
}
|
|
431
|
-
let o =
|
|
431
|
+
let o = i[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
|
-
), o = () => []), o && o._c && (o._d = !1),
|
|
435
|
-
const
|
|
434
|
+
), o = () => []), o && o._c && (o._d = !1), ge();
|
|
435
|
+
const a = o && Ne(o(t)), r = t.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
|
+
a && a.key, c = be(
|
|
438
438
|
q,
|
|
439
439
|
{
|
|
440
|
-
key: (
|
|
441
|
-
(!
|
|
440
|
+
key: (r && !xe(r) ? r : `_${e}`) + // #7256 force differentiate fallback content from actual content
|
|
441
|
+
(!a && s ? "_fb" : "")
|
|
442
442
|
},
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
a || [],
|
|
444
|
+
a && i._ === 1 ? 64 : -2
|
|
445
445
|
);
|
|
446
446
|
return c.scopeId && (c.slotScopeIds = [c.scopeId + "-s"]), o && o._c && (o._d = !0), c;
|
|
447
447
|
}
|
|
448
|
-
function
|
|
449
|
-
return
|
|
448
|
+
function Ne(i) {
|
|
449
|
+
return i.some((e) => Oe(e) ? !(e.type === Te || e.type === q && !Ne(e.children)) : !0) ? i : null;
|
|
450
450
|
}
|
|
451
451
|
const yt = {};
|
|
452
|
-
process.env.NODE_ENV !== "production" && (yt.ownKeys = (
|
|
452
|
+
process.env.NODE_ENV !== "production" && (yt.ownKeys = (i) => (_(
|
|
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
|
-
), Reflect.ownKeys(
|
|
455
|
-
let
|
|
456
|
-
const wt = {},
|
|
457
|
-
let
|
|
458
|
-
function
|
|
459
|
-
|
|
454
|
+
), Reflect.ownKeys(i)));
|
|
455
|
+
let vt = null;
|
|
456
|
+
const wt = {}, Re = (i) => Object.getPrototypeOf(i) === wt, xt = (i) => i.__isSuspense, q = /* @__PURE__ */ Symbol.for("v-fgt"), Ct = /* @__PURE__ */ Symbol.for("v-txt"), Te = /* @__PURE__ */ Symbol.for("v-cmt"), Y = [];
|
|
457
|
+
let k = null;
|
|
458
|
+
function ge(i = !1) {
|
|
459
|
+
Y.push(k = i ? null : []);
|
|
460
460
|
}
|
|
461
461
|
function St() {
|
|
462
|
-
|
|
462
|
+
Y.pop(), k = Y[Y.length - 1] || null;
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
return
|
|
464
|
+
function kt(i) {
|
|
465
|
+
return i.dynamicChildren = k || ze, St(), k && k.push(i), i;
|
|
466
466
|
}
|
|
467
|
-
function
|
|
468
|
-
return
|
|
469
|
-
|
|
470
|
-
t,
|
|
471
|
-
e,
|
|
472
|
-
n,
|
|
467
|
+
function be(i, e, t, s, n) {
|
|
468
|
+
return kt(
|
|
469
|
+
fe(
|
|
473
470
|
i,
|
|
471
|
+
e,
|
|
472
|
+
t,
|
|
474
473
|
s,
|
|
474
|
+
n,
|
|
475
475
|
!0
|
|
476
476
|
)
|
|
477
477
|
);
|
|
478
478
|
}
|
|
479
|
-
function Oe(
|
|
480
|
-
return
|
|
479
|
+
function Oe(i) {
|
|
480
|
+
return i ? i.__v_isVNode === !0 : !1;
|
|
481
481
|
}
|
|
482
|
-
const Et = (...
|
|
483
|
-
...
|
|
484
|
-
),
|
|
485
|
-
ref:
|
|
482
|
+
const Et = (...i) => Fe(
|
|
483
|
+
...i
|
|
484
|
+
), $e = ({ key: i }) => i ?? null, G = ({
|
|
485
|
+
ref: i,
|
|
486
486
|
ref_key: e,
|
|
487
|
-
ref_for:
|
|
488
|
-
}) => (typeof
|
|
489
|
-
function
|
|
487
|
+
ref_for: t
|
|
488
|
+
}) => (typeof i == "number" && (i = "" + i), i != null ? R(i) || de(i) || M(i) ? { i: I, r: i, k: e, f: !!t } : i : null);
|
|
489
|
+
function _t(i, e = null, t = null, s = 0, n = null, o = i === q ? 0 : 1, a = !1, r = !1) {
|
|
490
490
|
const c = {
|
|
491
491
|
__v_isVNode: !0,
|
|
492
492
|
__v_skip: !0,
|
|
493
|
-
type:
|
|
493
|
+
type: i,
|
|
494
494
|
props: e,
|
|
495
|
-
key: e &&
|
|
496
|
-
ref: e &&
|
|
497
|
-
scopeId:
|
|
495
|
+
key: e && $e(e),
|
|
496
|
+
ref: e && G(e),
|
|
497
|
+
scopeId: dt,
|
|
498
498
|
slotScopeIds: null,
|
|
499
|
-
children:
|
|
499
|
+
children: t,
|
|
500
500
|
component: null,
|
|
501
501
|
suspense: null,
|
|
502
502
|
ssContent: null,
|
|
@@ -510,228 +510,228 @@ function kt(t, e = null, n = null, i = 0, s = null, o = t === q ? 0 : 1, r = !1,
|
|
|
510
510
|
targetAnchor: null,
|
|
511
511
|
staticCount: 0,
|
|
512
512
|
shapeFlag: o,
|
|
513
|
-
patchFlag:
|
|
514
|
-
dynamicProps:
|
|
513
|
+
patchFlag: s,
|
|
514
|
+
dynamicProps: n,
|
|
515
515
|
dynamicChildren: null,
|
|
516
516
|
appContext: null,
|
|
517
|
-
ctx:
|
|
517
|
+
ctx: I
|
|
518
518
|
};
|
|
519
|
-
return
|
|
520
|
-
!
|
|
521
|
-
|
|
519
|
+
return r ? (me(c, t), o & 128 && i.normalize(c)) : t && (c.shapeFlag |= R(t) ? 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
|
+
!a && // has current parent block
|
|
521
|
+
k && // 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
|
|
523
523
|
// component doesn't need to update, it needs to persist the instance on to
|
|
524
524
|
// the next vnode so that it can be properly unmounted later.
|
|
525
525
|
(c.patchFlag > 0 || o & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
|
|
526
526
|
// vnode should not be considered dynamic due to handler caching.
|
|
527
|
-
c.patchFlag !== 32 &&
|
|
527
|
+
c.patchFlag !== 32 && k.push(c), c;
|
|
528
528
|
}
|
|
529
|
-
const
|
|
530
|
-
function
|
|
531
|
-
if ((!
|
|
532
|
-
const
|
|
533
|
-
|
|
529
|
+
const fe = process.env.NODE_ENV !== "production" ? Et : Fe;
|
|
530
|
+
function Fe(i, e = null, t = null, s = 0, n = null, o = !1) {
|
|
531
|
+
if ((!i || i === gt) && (process.env.NODE_ENV !== "production" && !i && _(`Invalid vnode type when creating vnode: ${i}.`), i = Te), Oe(i)) {
|
|
532
|
+
const r = X(
|
|
533
|
+
i,
|
|
534
534
|
e,
|
|
535
535
|
!0
|
|
536
536
|
/* mergeRef: true */
|
|
537
537
|
);
|
|
538
|
-
return
|
|
538
|
+
return t && me(r, t), !o && k && (r.shapeFlag & 6 ? k[k.indexOf(i)] = r : k.push(r)), r.patchFlag = -2, r;
|
|
539
539
|
}
|
|
540
|
-
if (
|
|
541
|
-
e =
|
|
542
|
-
let { class:
|
|
543
|
-
|
|
540
|
+
if (De(i) && (i = i.__vccOpts), e) {
|
|
541
|
+
e = At(e);
|
|
542
|
+
let { class: r, style: c } = e;
|
|
543
|
+
r && !R(r) && (e.class = ce(r)), T(c) && (oe(c) && !E(c) && (c = z({}, c)), e.style = le(c));
|
|
544
544
|
}
|
|
545
|
-
const
|
|
546
|
-
return process.env.NODE_ENV !== "production" &&
|
|
545
|
+
const a = R(i) ? 1 : xt(i) ? 128 : mt(i) ? 64 : T(i) ? 4 : M(i) ? 2 : 0;
|
|
546
|
+
return process.env.NODE_ENV !== "production" && a & 4 && oe(i) && (i = O(i), _(
|
|
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
|
`
|
|
549
549
|
Component that was made reactive: `,
|
|
550
|
-
|
|
551
|
-
)),
|
|
552
|
-
t,
|
|
553
|
-
e,
|
|
554
|
-
n,
|
|
550
|
+
i
|
|
551
|
+
)), _t(
|
|
555
552
|
i,
|
|
553
|
+
e,
|
|
554
|
+
t,
|
|
556
555
|
s,
|
|
557
|
-
|
|
556
|
+
n,
|
|
557
|
+
a,
|
|
558
558
|
o,
|
|
559
559
|
!0
|
|
560
560
|
);
|
|
561
561
|
}
|
|
562
|
-
function
|
|
563
|
-
return
|
|
562
|
+
function At(i) {
|
|
563
|
+
return i ? oe(i) || Re(i) ? z({}, i) : i : null;
|
|
564
564
|
}
|
|
565
|
-
function X(
|
|
566
|
-
const { props:
|
|
565
|
+
function X(i, e, t = !1, s = !1) {
|
|
566
|
+
const { props: n, ref: o, patchFlag: a, children: r, transition: c } = i, h = e ? It(n || {}, e) : n, d = {
|
|
567
567
|
__v_isVNode: !0,
|
|
568
568
|
__v_skip: !0,
|
|
569
|
-
type:
|
|
569
|
+
type: i.type,
|
|
570
570
|
props: h,
|
|
571
|
-
key: h &&
|
|
571
|
+
key: h && $e(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
|
+
t && o ? E(o) ? o.concat(G(e)) : [o, G(e)] : G(e)
|
|
577
577
|
) : o,
|
|
578
|
-
scopeId:
|
|
579
|
-
slotScopeIds:
|
|
580
|
-
children: process.env.NODE_ENV !== "production" &&
|
|
581
|
-
target:
|
|
582
|
-
targetStart:
|
|
583
|
-
targetAnchor:
|
|
584
|
-
staticCount:
|
|
585
|
-
shapeFlag:
|
|
578
|
+
scopeId: i.scopeId,
|
|
579
|
+
slotScopeIds: i.slotScopeIds,
|
|
580
|
+
children: process.env.NODE_ENV !== "production" && a === -1 && E(r) ? r.map(He) : r,
|
|
581
|
+
target: i.target,
|
|
582
|
+
targetStart: i.targetStart,
|
|
583
|
+
targetAnchor: i.targetAnchor,
|
|
584
|
+
staticCount: i.staticCount,
|
|
585
|
+
shapeFlag: i.shapeFlag,
|
|
586
586
|
// if the vnode is cloned with extra props, we can no longer assume its
|
|
587
587
|
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
|
588
588
|
// note: preserve flag for fragments since they use the flag for children
|
|
589
589
|
// fast paths only.
|
|
590
|
-
patchFlag: e &&
|
|
591
|
-
dynamicProps:
|
|
592
|
-
dynamicChildren:
|
|
593
|
-
appContext:
|
|
594
|
-
dirs:
|
|
590
|
+
patchFlag: e && i.type !== q ? a === -1 ? 16 : a | 16 : a,
|
|
591
|
+
dynamicProps: i.dynamicProps,
|
|
592
|
+
dynamicChildren: i.dynamicChildren,
|
|
593
|
+
appContext: i.appContext,
|
|
594
|
+
dirs: i.dirs,
|
|
595
595
|
transition: c,
|
|
596
596
|
// These should technically only be non-null on mounted VNodes. However,
|
|
597
597
|
// they *should* be copied for kept-alive vnodes. So we just always copy
|
|
598
598
|
// them since them being non-null during a mount doesn't affect the logic as
|
|
599
599
|
// they will simply be overwritten.
|
|
600
|
-
component:
|
|
601
|
-
suspense:
|
|
602
|
-
ssContent:
|
|
603
|
-
ssFallback:
|
|
604
|
-
placeholder:
|
|
605
|
-
el:
|
|
606
|
-
anchor:
|
|
607
|
-
ctx:
|
|
608
|
-
ce:
|
|
600
|
+
component: i.component,
|
|
601
|
+
suspense: i.suspense,
|
|
602
|
+
ssContent: i.ssContent && X(i.ssContent),
|
|
603
|
+
ssFallback: i.ssFallback && X(i.ssFallback),
|
|
604
|
+
placeholder: i.placeholder,
|
|
605
|
+
el: i.el,
|
|
606
|
+
anchor: i.anchor,
|
|
607
|
+
ctx: i.ctx,
|
|
608
|
+
ce: i.ce
|
|
609
609
|
};
|
|
610
|
-
return c &&
|
|
610
|
+
return c && s && Me(
|
|
611
611
|
d,
|
|
612
612
|
c.clone(d)
|
|
613
613
|
), d;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
616
|
-
const e = X(
|
|
617
|
-
return
|
|
615
|
+
function He(i) {
|
|
616
|
+
const e = X(i);
|
|
617
|
+
return E(i.children) && (e.children = i.children.map(He)), e;
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
return
|
|
619
|
+
function Lt(i = " ", e = 0) {
|
|
620
|
+
return fe(Ct, null, i, e);
|
|
621
621
|
}
|
|
622
|
-
function
|
|
623
|
-
let
|
|
624
|
-
const { shapeFlag:
|
|
622
|
+
function me(i, e) {
|
|
623
|
+
let t = 0;
|
|
624
|
+
const { shapeFlag: s } = i;
|
|
625
625
|
if (e == null)
|
|
626
626
|
e = null;
|
|
627
|
-
else if (
|
|
628
|
-
|
|
627
|
+
else if (E(e))
|
|
628
|
+
t = 16;
|
|
629
629
|
else if (typeof e == "object")
|
|
630
|
-
if (
|
|
631
|
-
const
|
|
632
|
-
|
|
630
|
+
if (s & 65) {
|
|
631
|
+
const n = e.default;
|
|
632
|
+
n && (n._c && (n._d = !1), me(i, n()), n._c && (n._d = !0));
|
|
633
633
|
return;
|
|
634
634
|
} else
|
|
635
|
-
|
|
636
|
-
else
|
|
637
|
-
|
|
635
|
+
t = 32, !e._ && !Re(e) && (e._ctx = I);
|
|
636
|
+
else M(e) ? (e = { default: e, _ctx: I }, t = 32) : (e = String(e), s & 64 ? (t = 16, e = [Lt(e)]) : t = 8);
|
|
637
|
+
i.children = e, i.shapeFlag |= t;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function It(...i) {
|
|
640
640
|
const e = {};
|
|
641
|
-
for (let
|
|
642
|
-
const
|
|
643
|
-
for (const
|
|
644
|
-
if (
|
|
645
|
-
e.class !==
|
|
646
|
-
else if (
|
|
647
|
-
e.style =
|
|
648
|
-
else if (
|
|
649
|
-
const o = e[
|
|
650
|
-
|
|
651
|
-
} else
|
|
641
|
+
for (let t = 0; t < i.length; t++) {
|
|
642
|
+
const s = i[t];
|
|
643
|
+
for (const n in s)
|
|
644
|
+
if (n === "class")
|
|
645
|
+
e.class !== s.class && (e.class = ce([e.class, s.class]));
|
|
646
|
+
else if (n === "style")
|
|
647
|
+
e.style = le([e.style, s.style]);
|
|
648
|
+
else if (Be(n)) {
|
|
649
|
+
const o = e[n], a = s[n];
|
|
650
|
+
a && o !== a && !(E(o) && o.includes(a)) && (e[n] = o ? [].concat(o, a) : a);
|
|
651
|
+
} else n !== "" && (e[n] = s[n]);
|
|
652
652
|
}
|
|
653
653
|
return e;
|
|
654
654
|
}
|
|
655
|
-
let
|
|
656
|
-
const
|
|
655
|
+
let L = null;
|
|
656
|
+
const Mt = () => L || I;
|
|
657
657
|
{
|
|
658
|
-
const
|
|
659
|
-
let
|
|
660
|
-
return (
|
|
661
|
-
|
|
658
|
+
const i = Q(), e = (t, s) => {
|
|
659
|
+
let n;
|
|
660
|
+
return (n = i[t]) || (n = i[t] = []), n.push(s), (o) => {
|
|
661
|
+
n.length > 1 ? n.forEach((a) => a(o)) : n[0](o);
|
|
662
662
|
};
|
|
663
663
|
};
|
|
664
664
|
e(
|
|
665
665
|
"__VUE_INSTANCE_SETTERS__",
|
|
666
|
-
(
|
|
666
|
+
(t) => L = t
|
|
667
667
|
), e(
|
|
668
668
|
"__VUE_SSR_SETTERS__",
|
|
669
|
-
(
|
|
669
|
+
(t) => t
|
|
670
670
|
);
|
|
671
671
|
}
|
|
672
672
|
process.env.NODE_ENV;
|
|
673
|
-
const
|
|
674
|
-
function
|
|
675
|
-
return
|
|
676
|
-
}
|
|
677
|
-
function
|
|
678
|
-
let
|
|
679
|
-
if (!
|
|
680
|
-
const
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
if (!
|
|
684
|
-
const
|
|
685
|
-
for (const
|
|
686
|
-
if (o[
|
|
687
|
-
return
|
|
673
|
+
const Nt = /(?:^|[-_])\w/g, Rt = (i) => i.replace(Nt, (e) => e.toUpperCase()).replace(/[-_]/g, "");
|
|
674
|
+
function Pe(i, e = !0) {
|
|
675
|
+
return M(i) ? i.displayName || i.name : i.name || e && i.__name;
|
|
676
|
+
}
|
|
677
|
+
function Ve(i, e, t = !1) {
|
|
678
|
+
let s = Pe(e);
|
|
679
|
+
if (!s && e.__file) {
|
|
680
|
+
const n = e.__file.match(/([^/\\]+)\.\w+$/);
|
|
681
|
+
n && (s = n[1]);
|
|
682
|
+
}
|
|
683
|
+
if (!s && i) {
|
|
684
|
+
const n = (o) => {
|
|
685
|
+
for (const a in o)
|
|
686
|
+
if (o[a] === e)
|
|
687
|
+
return a;
|
|
688
688
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
) ||
|
|
689
|
+
s = n(i.components) || i.parent && n(
|
|
690
|
+
i.parent.type.components
|
|
691
|
+
) || n(i.appContext.components);
|
|
692
692
|
}
|
|
693
|
-
return
|
|
693
|
+
return s ? Rt(s) : t ? "App" : "Anonymous";
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return
|
|
695
|
+
function De(i) {
|
|
696
|
+
return M(i) && "__vccOpts" in i;
|
|
697
697
|
}
|
|
698
698
|
function Tt() {
|
|
699
699
|
if (process.env.NODE_ENV === "production" || typeof window > "u")
|
|
700
700
|
return;
|
|
701
|
-
const
|
|
701
|
+
const i = { style: "color:#3ba776" }, e = { style: "color:#1677ff" }, t = { style: "color:#f5222d" }, s = { style: "color:#eb2f96" }, n = {
|
|
702
702
|
__vue_custom_formatter: !0,
|
|
703
703
|
header(l) {
|
|
704
|
-
if (!
|
|
704
|
+
if (!T(l))
|
|
705
705
|
return null;
|
|
706
706
|
if (l.__isVue)
|
|
707
|
-
return ["div",
|
|
708
|
-
if (
|
|
707
|
+
return ["div", i, "VueInstance"];
|
|
708
|
+
if (de(l)) {
|
|
709
709
|
const f = l.value;
|
|
710
710
|
return [
|
|
711
711
|
"div",
|
|
712
712
|
{},
|
|
713
|
-
["span",
|
|
713
|
+
["span", i, d(l)],
|
|
714
714
|
"<",
|
|
715
|
-
|
|
715
|
+
r(f),
|
|
716
716
|
">"
|
|
717
717
|
];
|
|
718
718
|
} else {
|
|
719
|
-
if (
|
|
719
|
+
if (Ce(l))
|
|
720
720
|
return [
|
|
721
721
|
"div",
|
|
722
722
|
{},
|
|
723
|
-
["span",
|
|
723
|
+
["span", i, Z(l) ? "ShallowReactive" : "Reactive"],
|
|
724
724
|
"<",
|
|
725
|
-
|
|
726
|
-
`>${
|
|
725
|
+
r(l),
|
|
726
|
+
`>${ne(l) ? " (readonly)" : ""}`
|
|
727
727
|
];
|
|
728
|
-
if (
|
|
728
|
+
if (ne(l))
|
|
729
729
|
return [
|
|
730
730
|
"div",
|
|
731
731
|
{},
|
|
732
|
-
["span",
|
|
732
|
+
["span", i, Z(l) ? "ShallowReadonly" : "Readonly"],
|
|
733
733
|
"<",
|
|
734
|
-
|
|
734
|
+
r(l),
|
|
735
735
|
">"
|
|
736
736
|
];
|
|
737
737
|
}
|
|
@@ -751,24 +751,24 @@ function Tt() {
|
|
|
751
751
|
};
|
|
752
752
|
function o(l) {
|
|
753
753
|
const f = [];
|
|
754
|
-
l.type.props && l.props && f.push(
|
|
754
|
+
l.type.props && l.props && f.push(a("props", O(l.props))), l.setupState !== se && f.push(a("setup", l.setupState)), l.data !== se && f.push(a("data", O(l.data)));
|
|
755
755
|
const m = c(l, "computed");
|
|
756
|
-
m && f.push(
|
|
757
|
-
const
|
|
758
|
-
return
|
|
756
|
+
m && f.push(a("computed", m));
|
|
757
|
+
const b = c(l, "inject");
|
|
758
|
+
return b && f.push(a("injected", b)), f.push([
|
|
759
759
|
"div",
|
|
760
760
|
{},
|
|
761
761
|
[
|
|
762
762
|
"span",
|
|
763
763
|
{
|
|
764
|
-
style:
|
|
764
|
+
style: s.style + ";opacity:0.66"
|
|
765
765
|
},
|
|
766
766
|
"$ (internal): "
|
|
767
767
|
],
|
|
768
768
|
["object", { object: l }]
|
|
769
769
|
]), f;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function a(l, f) {
|
|
772
772
|
return f = z({}, f), Object.keys(f).length ? [
|
|
773
773
|
"div",
|
|
774
774
|
{ style: "line-height:1.25em;margin-bottom:0.6em" },
|
|
@@ -787,33 +787,33 @@ function Tt() {
|
|
|
787
787
|
...Object.keys(f).map((m) => [
|
|
788
788
|
"div",
|
|
789
789
|
{},
|
|
790
|
-
["span",
|
|
791
|
-
|
|
790
|
+
["span", s, m + ": "],
|
|
791
|
+
r(f[m], !1)
|
|
792
792
|
])
|
|
793
793
|
]
|
|
794
794
|
] : ["span", {}];
|
|
795
795
|
}
|
|
796
|
-
function
|
|
797
|
-
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span",
|
|
796
|
+
function r(l, f = !0) {
|
|
797
|
+
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span", t, JSON.stringify(l)] : typeof l == "boolean" ? ["span", s, l] : T(l) ? ["object", { object: f ? O(l) : l }] : ["span", t, String(l)];
|
|
798
798
|
}
|
|
799
799
|
function c(l, f) {
|
|
800
800
|
const m = l.type;
|
|
801
|
-
if (
|
|
801
|
+
if (M(m))
|
|
802
802
|
return;
|
|
803
|
-
const
|
|
803
|
+
const b = {};
|
|
804
804
|
for (const u in l.ctx)
|
|
805
|
-
h(m, u, f) && (
|
|
806
|
-
return
|
|
805
|
+
h(m, u, f) && (b[u] = l.ctx[u]);
|
|
806
|
+
return b;
|
|
807
807
|
}
|
|
808
808
|
function h(l, f, m) {
|
|
809
|
-
const
|
|
810
|
-
if (
|
|
809
|
+
const b = l[m];
|
|
810
|
+
if (E(b) && b.includes(f) || T(b) && f in b || 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
814
|
return Z(l) ? "ShallowRef" : l.effect ? "ComputedRef" : "Ref";
|
|
815
815
|
}
|
|
816
|
-
window.devtoolsFormatters ? window.devtoolsFormatters.push(
|
|
816
|
+
window.devtoolsFormatters ? window.devtoolsFormatters.push(n) : window.devtoolsFormatters = [n];
|
|
817
817
|
}
|
|
818
818
|
process.env.NODE_ENV;
|
|
819
819
|
process.env.NODE_ENV;
|
|
@@ -831,34 +831,34 @@ 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, t, s) {
|
|
835
835
|
try {
|
|
836
|
-
const
|
|
836
|
+
const n = {
|
|
837
837
|
userInput: e,
|
|
838
|
-
commands:
|
|
839
|
-
id:
|
|
840
|
-
command:
|
|
841
|
-
description:
|
|
842
|
-
parameters:
|
|
838
|
+
commands: t.map((r) => ({
|
|
839
|
+
id: r.id,
|
|
840
|
+
command: r.command,
|
|
841
|
+
description: r.description,
|
|
842
|
+
parameters: r.parameters
|
|
843
843
|
// Send param schemas to AI
|
|
844
844
|
})),
|
|
845
|
-
context:
|
|
845
|
+
context: s
|
|
846
846
|
}, o = await fetch(this.endpoint, {
|
|
847
847
|
method: "POST",
|
|
848
848
|
headers: {
|
|
849
849
|
"Content-Type": "application/json"
|
|
850
850
|
},
|
|
851
|
-
body: JSON.stringify(
|
|
851
|
+
body: JSON.stringify(n)
|
|
852
852
|
});
|
|
853
853
|
if (!o.ok)
|
|
854
854
|
throw new Error(`Proxy API Error: ${o.statusText}`);
|
|
855
855
|
return await o.json();
|
|
856
|
-
} catch (
|
|
857
|
-
return console.error("OpenAIService Error:",
|
|
856
|
+
} catch (n) {
|
|
857
|
+
return console.error("OpenAIService Error:", n), { type: "unknown" };
|
|
858
858
|
}
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
|
-
class
|
|
861
|
+
class $t {
|
|
862
862
|
constructor(e = !0) {
|
|
863
863
|
if (this.commands = /* @__PURE__ */ new Map(), this.openAIService = null, this.context = null, this.pendingConfirmation = null, this.enableSmartIntent = !0, this.selectOptionsCache = /* @__PURE__ */ new Map(), typeof e == "boolean") {
|
|
864
864
|
this.enableSmartIntent = e, this.enableSmartIntent && (this.openAIService = new ye());
|
|
@@ -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, t) {
|
|
871
|
+
let s;
|
|
872
872
|
if (typeof e == "string") {
|
|
873
|
-
if (!
|
|
873
|
+
if (!t)
|
|
874
874
|
throw new Error("Action required when adding command by string.");
|
|
875
|
-
|
|
875
|
+
s = {
|
|
876
876
|
id: e.toLowerCase().replace(/\s+/g, "_"),
|
|
877
877
|
command: e.toLowerCase(),
|
|
878
|
-
action:
|
|
878
|
+
action: t
|
|
879
879
|
};
|
|
880
880
|
} else
|
|
881
|
-
|
|
882
|
-
this.commands.set(
|
|
881
|
+
s = { ...e }, s.id || (s.id = s.command.toLowerCase().replace(/\s+/g, "_"));
|
|
882
|
+
this.commands.set(s.command.toLowerCase(), s), s.id && (s.id, s.command);
|
|
883
883
|
}
|
|
884
884
|
/** Remove an existing command */
|
|
885
885
|
removeCommand(e) {
|
|
@@ -891,7 +891,7 @@ class Mt {
|
|
|
891
891
|
if (this.isStructured(e)) {
|
|
892
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, h), m = (d.parameters ?? []).filter((
|
|
894
|
+
const l = this.sanitizeParamsForCommand(d, h), m = (d.parameters ?? []).filter((b) => b.required).filter((b) => l[b.name] == null || l[b.name] === "");
|
|
895
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",
|
|
@@ -905,26 +905,26 @@ class Mt {
|
|
|
905
905
|
return this.context = null, { message: "Session expired or invalid context.", type: "error" };
|
|
906
906
|
if (Array.isArray(e))
|
|
907
907
|
return { message: "Invalid form payload.", type: "error" };
|
|
908
|
-
const
|
|
908
|
+
const a = {
|
|
909
909
|
...this.context.params,
|
|
910
910
|
...e
|
|
911
911
|
};
|
|
912
912
|
if (o.critical)
|
|
913
913
|
return this.context = null, this.pendingConfirmation = {
|
|
914
914
|
commandId: this.getCommandIdentifier(o),
|
|
915
|
-
params:
|
|
915
|
+
params: a
|
|
916
916
|
}, this.buildConfirmResponse(o);
|
|
917
|
-
const
|
|
918
|
-
return this.context = null, this.normalizeResponse(
|
|
917
|
+
const r = await this.safeRunAction(o, a);
|
|
918
|
+
return this.context = null, this.normalizeResponse(r);
|
|
919
919
|
}
|
|
920
|
-
const
|
|
920
|
+
const t = e.trim().toLowerCase();
|
|
921
921
|
if (this.pendingConfirmation) {
|
|
922
|
-
const o =
|
|
922
|
+
const o = t;
|
|
923
923
|
if (["yes", "y", "confirm", "ok", "okay"].includes(o)) {
|
|
924
|
-
const { commandId:
|
|
924
|
+
const { commandId: a, params: r } = this.pendingConfirmation;
|
|
925
925
|
this.pendingConfirmation = null;
|
|
926
|
-
const c = this.getCommandById(
|
|
927
|
-
return c ? this.safeRunAction(c,
|
|
926
|
+
const c = this.getCommandById(a);
|
|
927
|
+
return c ? this.safeRunAction(c, r) : { message: "That action is no longer available.", type: "error" };
|
|
928
928
|
}
|
|
929
929
|
return ["no", "n", "cancel", "stop"].includes(o) ? (this.pendingConfirmation = null, { message: "Cancelled.", type: "success" }) : {
|
|
930
930
|
message: "Please confirm: Yes or No.",
|
|
@@ -935,133 +935,138 @@ class Mt {
|
|
|
935
935
|
]
|
|
936
936
|
};
|
|
937
937
|
}
|
|
938
|
-
const
|
|
939
|
-
if (
|
|
940
|
-
const o =
|
|
941
|
-
|
|
938
|
+
const s = this.commands.get(t);
|
|
939
|
+
if (s) {
|
|
940
|
+
const o = s;
|
|
941
|
+
if (o.macro)
|
|
942
|
+
return this.safeRunAction(o, {});
|
|
943
|
+
const a = (o.parameters ?? []).filter((r) => r.required);
|
|
944
|
+
return a.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
942
945
|
message: `Please provide the required details for "${o.command}".`,
|
|
943
946
|
type: "form",
|
|
944
|
-
fields:
|
|
947
|
+
fields: a
|
|
945
948
|
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
946
949
|
}
|
|
947
|
-
const
|
|
948
|
-
if (
|
|
950
|
+
const n = await this.tryDeterministicMatch(t);
|
|
951
|
+
if (n) return n;
|
|
949
952
|
if (this.enableSmartIntent && this.openAIService) {
|
|
950
|
-
const o = await this.getCommandsForAI(),
|
|
951
|
-
|
|
953
|
+
const o = await this.getCommandsForAI(), a = await this.openAIService.determineIntent(
|
|
954
|
+
t,
|
|
952
955
|
o,
|
|
953
956
|
this.context
|
|
954
957
|
);
|
|
955
|
-
return this.handleAIResult(
|
|
958
|
+
return this.handleAIResult(a);
|
|
956
959
|
}
|
|
957
960
|
return this.enableSmartIntent ? this.listAllCommands() : { message: "I'm not sure what you mean.", type: "error" };
|
|
958
961
|
}
|
|
959
962
|
async handleAIResult(e) {
|
|
960
963
|
if (e.type === "match" && e.match) {
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
964
|
+
const t = this.getCommandById(e.match);
|
|
965
|
+
if (!t)
|
|
963
966
|
return { message: "I'm not sure what you mean.", type: "error" };
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
967
|
+
if (t.macro)
|
|
968
|
+
return this.safeRunAction(t, {});
|
|
969
|
+
const s = e.params ?? {}, n = this.sanitizeParamsForCommand(t, s), o = t.allowAiParamExtraction === !1 ? {} : n, r = (t.parameters ?? []).filter((h) => h.required).filter((h) => o[h.name] == null || o[h.name] === "");
|
|
970
|
+
if (e.incomplete || r.length > 0) {
|
|
971
|
+
if (this.context = { commandId: this.getCommandIdentifier(t), params: o }, !(t.collectRequiredViaForm !== !1) && this.shouldAskSingleQuestion(r)) {
|
|
972
|
+
const l = r.map((f) => f.name).join(" and ");
|
|
968
973
|
return {
|
|
969
974
|
message: e.message || `Please provide ${l}.`,
|
|
970
975
|
type: "question"
|
|
971
976
|
};
|
|
972
977
|
}
|
|
973
978
|
return {
|
|
974
|
-
message: e.message || `Please fill in the missing details for "${
|
|
979
|
+
message: e.message || `Please fill in the missing details for "${t.command}".`,
|
|
975
980
|
type: "form",
|
|
976
|
-
fields:
|
|
981
|
+
fields: r
|
|
977
982
|
};
|
|
978
983
|
}
|
|
979
|
-
if (
|
|
984
|
+
if (t.critical)
|
|
980
985
|
return this.pendingConfirmation = {
|
|
981
|
-
commandId: this.getCommandIdentifier(
|
|
986
|
+
commandId: this.getCommandIdentifier(t),
|
|
982
987
|
params: o
|
|
983
|
-
}, this.buildConfirmResponse(
|
|
984
|
-
const c = await
|
|
988
|
+
}, this.buildConfirmResponse(t);
|
|
989
|
+
const c = await t.action(o);
|
|
985
990
|
return this.normalizeResponse(c);
|
|
986
991
|
}
|
|
987
992
|
return e.type === "ambiguous" && e.options && e.options.length ? {
|
|
988
993
|
message: e.message || "Did you mean one of these?",
|
|
989
994
|
type: "ambiguous",
|
|
990
|
-
options: e.options.map((
|
|
991
|
-
label:
|
|
992
|
-
value:
|
|
993
|
-
commandId:
|
|
995
|
+
options: e.options.map((t) => ({
|
|
996
|
+
label: t.label,
|
|
997
|
+
value: t.commandId ?? t.label,
|
|
998
|
+
commandId: t.commandId
|
|
994
999
|
}))
|
|
995
1000
|
} : this.listAllCommands();
|
|
996
1001
|
}
|
|
997
|
-
sanitizeParamsForCommand(e,
|
|
998
|
-
const
|
|
999
|
-
for (const
|
|
1000
|
-
const o =
|
|
1001
|
-
if (
|
|
1002
|
+
sanitizeParamsForCommand(e, t) {
|
|
1003
|
+
const s = { ...t ?? {} };
|
|
1004
|
+
for (const n of e.parameters ?? []) {
|
|
1005
|
+
const o = s[n.name];
|
|
1006
|
+
if (n.type === "string") {
|
|
1002
1007
|
if (typeof o != "string") {
|
|
1003
|
-
delete
|
|
1008
|
+
delete s[n.name];
|
|
1004
1009
|
continue;
|
|
1005
1010
|
}
|
|
1006
|
-
const
|
|
1007
|
-
if (!
|
|
1008
|
-
delete
|
|
1011
|
+
const a = o.trim();
|
|
1012
|
+
if (!a) {
|
|
1013
|
+
delete s[n.name];
|
|
1009
1014
|
continue;
|
|
1010
1015
|
}
|
|
1011
|
-
|
|
1016
|
+
s[n.name] = a;
|
|
1012
1017
|
}
|
|
1013
|
-
if (
|
|
1014
|
-
const
|
|
1015
|
-
if (Number.isNaN(
|
|
1016
|
-
delete
|
|
1018
|
+
if (n.type === "number") {
|
|
1019
|
+
const a = typeof o == "number" ? o : Number(o == null ? void 0 : o.toString().trim());
|
|
1020
|
+
if (Number.isNaN(a)) {
|
|
1021
|
+
delete s[n.name];
|
|
1017
1022
|
continue;
|
|
1018
1023
|
}
|
|
1019
|
-
if (typeof
|
|
1020
|
-
delete
|
|
1024
|
+
if (typeof n.min == "number" && a < n.min) {
|
|
1025
|
+
delete s[n.name];
|
|
1021
1026
|
continue;
|
|
1022
1027
|
}
|
|
1023
|
-
if (typeof
|
|
1024
|
-
delete
|
|
1028
|
+
if (typeof n.max == "number" && a > n.max) {
|
|
1029
|
+
delete s[n.name];
|
|
1025
1030
|
continue;
|
|
1026
1031
|
}
|
|
1027
|
-
|
|
1032
|
+
s[n.name] = a;
|
|
1028
1033
|
}
|
|
1029
|
-
if (
|
|
1030
|
-
const
|
|
1031
|
-
if (typeof
|
|
1032
|
-
const
|
|
1033
|
-
this.isIsoDateString(
|
|
1034
|
+
if (n.type === "date") {
|
|
1035
|
+
const a = s[n.name];
|
|
1036
|
+
if (typeof a == "string") {
|
|
1037
|
+
const r = a.trim();
|
|
1038
|
+
this.isIsoDateString(r) ? s[n.name] = r : delete s[n.name];
|
|
1034
1039
|
} else
|
|
1035
|
-
delete
|
|
1040
|
+
delete s[n.name];
|
|
1036
1041
|
}
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1039
|
-
if (!
|
|
1040
|
-
delete
|
|
1042
|
+
if (n.type === "select") {
|
|
1043
|
+
const a = typeof o == "string" ? o : o == null ? void 0 : o.toString();
|
|
1044
|
+
if (!a) {
|
|
1045
|
+
delete s[n.name];
|
|
1041
1046
|
continue;
|
|
1042
1047
|
}
|
|
1043
|
-
if (Array.isArray(
|
|
1044
|
-
delete
|
|
1048
|
+
if (Array.isArray(n.options) && n.options.length > 0 && !n.options.some((c) => String(c.value) === String(a))) {
|
|
1049
|
+
delete s[n.name];
|
|
1045
1050
|
continue;
|
|
1046
1051
|
}
|
|
1047
|
-
|
|
1052
|
+
s[n.name] = a;
|
|
1048
1053
|
}
|
|
1049
|
-
if (
|
|
1050
|
-
const
|
|
1051
|
-
(
|
|
1054
|
+
if (n.type === "file") {
|
|
1055
|
+
const a = s[n.name], r = a && typeof a == "object" && typeof a.name == "string" && typeof a.size == "number", c = typeof a == "string" && /^data:[^;]+;base64,/.test(a);
|
|
1056
|
+
(n.delivery ?? "file") === "base64" ? !c && !r && delete s[n.name] : r || delete s[n.name];
|
|
1052
1057
|
}
|
|
1053
1058
|
}
|
|
1054
|
-
return
|
|
1059
|
+
return s;
|
|
1055
1060
|
}
|
|
1056
1061
|
isIsoDateString(e) {
|
|
1057
1062
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
|
|
1058
|
-
const
|
|
1059
|
-
return !Number.isNaN(
|
|
1063
|
+
const t = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
1064
|
+
return !Number.isNaN(t.getTime());
|
|
1060
1065
|
}
|
|
1061
1066
|
shouldAskSingleQuestion(e) {
|
|
1062
1067
|
if (e.length !== 1) return !1;
|
|
1063
|
-
const
|
|
1064
|
-
return
|
|
1068
|
+
const t = e[0].type;
|
|
1069
|
+
return t === "string" || t === "number" || t === "date";
|
|
1065
1070
|
}
|
|
1066
1071
|
buildConfirmResponse(e) {
|
|
1067
1072
|
return {
|
|
@@ -1074,64 +1079,64 @@ class Mt {
|
|
|
1074
1079
|
};
|
|
1075
1080
|
}
|
|
1076
1081
|
async tryDeterministicMatch(e) {
|
|
1077
|
-
const
|
|
1078
|
-
for (const
|
|
1082
|
+
const t = [];
|
|
1083
|
+
for (const r of this.commands.values()) {
|
|
1079
1084
|
let c = 0;
|
|
1080
|
-
const h =
|
|
1085
|
+
const h = r.command.toLowerCase();
|
|
1081
1086
|
e.includes(h) && (c += 5);
|
|
1082
|
-
const d =
|
|
1087
|
+
const d = r.keywords ?? [];
|
|
1083
1088
|
for (const l of d) {
|
|
1084
1089
|
const f = l.toLowerCase().trim();
|
|
1085
1090
|
f && (e === f ? c += 4 : e.includes(f) && (c += 3));
|
|
1086
1091
|
}
|
|
1087
|
-
c > 0 &&
|
|
1092
|
+
c > 0 && t.push({ cmd: r, score: c });
|
|
1088
1093
|
}
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
if (
|
|
1094
|
+
if (t.length === 0) return null;
|
|
1095
|
+
t.sort((r, c) => c.score - r.score);
|
|
1096
|
+
const s = t[0].score, n = t.filter((r) => r.score === s).slice(0, 3);
|
|
1097
|
+
if (n.length > 1)
|
|
1093
1098
|
return {
|
|
1094
1099
|
message: "I think you mean one of these. Which one should I run?",
|
|
1095
1100
|
type: "ambiguous",
|
|
1096
|
-
options:
|
|
1097
|
-
label:
|
|
1098
|
-
value:
|
|
1099
|
-
commandId:
|
|
1101
|
+
options: n.map((r) => ({
|
|
1102
|
+
label: r.cmd.command,
|
|
1103
|
+
value: r.cmd.command,
|
|
1104
|
+
commandId: r.cmd.id
|
|
1100
1105
|
}))
|
|
1101
1106
|
};
|
|
1102
|
-
const o =
|
|
1103
|
-
return
|
|
1107
|
+
const o = n[0].cmd, a = (o.parameters ?? []).filter((r) => r.required);
|
|
1108
|
+
return a.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
1104
1109
|
message: `Please provide the required details for "${o.command}".`,
|
|
1105
1110
|
type: "form",
|
|
1106
|
-
fields:
|
|
1111
|
+
fields: a
|
|
1107
1112
|
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
1108
1113
|
}
|
|
1109
|
-
async safeRunAction(e,
|
|
1114
|
+
async safeRunAction(e, t) {
|
|
1110
1115
|
try {
|
|
1111
|
-
const
|
|
1112
|
-
return this.normalizeResponse(
|
|
1116
|
+
const s = await e.action(t ?? {});
|
|
1117
|
+
return this.normalizeResponse(s);
|
|
1113
1118
|
} catch {
|
|
1114
1119
|
return { message: "Something went wrong while running that command.", type: "error" };
|
|
1115
1120
|
}
|
|
1116
1121
|
}
|
|
1117
1122
|
async getCommandsForAI() {
|
|
1118
|
-
const e = Array.from(this.commands.values()).map((
|
|
1119
|
-
...
|
|
1120
|
-
parameters:
|
|
1123
|
+
const e = Array.from(this.commands.values()).map((t) => ({
|
|
1124
|
+
...t,
|
|
1125
|
+
parameters: t.parameters ? t.parameters.map((s) => ({ ...s })) : void 0
|
|
1121
1126
|
}));
|
|
1122
1127
|
return await Promise.all(
|
|
1123
|
-
e.map(async (
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
if (
|
|
1127
|
-
const
|
|
1128
|
-
if (o &&
|
|
1129
|
-
|
|
1128
|
+
e.map(async (t) => {
|
|
1129
|
+
t.parameters && await Promise.all(
|
|
1130
|
+
t.parameters.map(async (s) => {
|
|
1131
|
+
if (s.type !== "select" || !s.getOptions || s.options && s.options.length) return;
|
|
1132
|
+
const n = `${t.id ?? t.command}:${s.name}`, o = this.selectOptionsCache.get(n), a = Date.now();
|
|
1133
|
+
if (o && a - o.ts < 6e4) {
|
|
1134
|
+
s.options = o.options;
|
|
1130
1135
|
return;
|
|
1131
1136
|
}
|
|
1132
1137
|
try {
|
|
1133
|
-
const
|
|
1134
|
-
this.selectOptionsCache.set(
|
|
1138
|
+
const r = await s.getOptions();
|
|
1139
|
+
this.selectOptionsCache.set(n, { options: r, ts: a }), s.options = r;
|
|
1135
1140
|
} catch {
|
|
1136
1141
|
}
|
|
1137
1142
|
})
|
|
@@ -1140,17 +1145,17 @@ class Mt {
|
|
|
1140
1145
|
), e;
|
|
1141
1146
|
}
|
|
1142
1147
|
getCommandById(e) {
|
|
1143
|
-
for (const
|
|
1144
|
-
if (
|
|
1148
|
+
for (const t of this.commands.values())
|
|
1149
|
+
if (t.id === e) return t;
|
|
1145
1150
|
}
|
|
1146
1151
|
listAllCommands() {
|
|
1147
1152
|
return {
|
|
1148
1153
|
message: "Here are the available commands:",
|
|
1149
1154
|
type: "ambiguous",
|
|
1150
|
-
options: Array.from(this.commands.values()).map((
|
|
1151
|
-
label:
|
|
1152
|
-
value:
|
|
1153
|
-
commandId:
|
|
1155
|
+
options: Array.from(this.commands.values()).map((t) => ({
|
|
1156
|
+
label: t.command,
|
|
1157
|
+
value: t.id ?? t.command,
|
|
1158
|
+
commandId: t.id ?? t.command
|
|
1154
1159
|
}))
|
|
1155
1160
|
};
|
|
1156
1161
|
}
|
|
@@ -1168,29 +1173,29 @@ class Mt {
|
|
|
1168
1173
|
return Array.from(this.commands.keys());
|
|
1169
1174
|
}
|
|
1170
1175
|
}
|
|
1171
|
-
class
|
|
1176
|
+
class qe {
|
|
1172
1177
|
constructor() {
|
|
1173
1178
|
this.synth = typeof window < "u" ? window.speechSynthesis : null;
|
|
1174
1179
|
}
|
|
1175
|
-
speak(e,
|
|
1180
|
+
speak(e, t) {
|
|
1176
1181
|
if (!this.synth) {
|
|
1177
1182
|
console.error("SpeechSynthesis API is not supported in this environment.");
|
|
1178
1183
|
return;
|
|
1179
1184
|
}
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1185
|
+
const s = new SpeechSynthesisUtterance(e);
|
|
1186
|
+
t && (s.pitch = t.pitch || 1, s.rate = t.rate || 1, s.volume = t.volume || 1), typeof window < "u" && (s.onstart = () => {
|
|
1182
1187
|
window.dispatchEvent(new CustomEvent("foisit:tts-start"));
|
|
1183
|
-
},
|
|
1188
|
+
}, s.onend = () => {
|
|
1184
1189
|
console.log("Speech finished."), window.dispatchEvent(new CustomEvent("foisit:tts-end"));
|
|
1185
|
-
}),
|
|
1186
|
-
console.error("Error during speech synthesis:",
|
|
1187
|
-
}, this.synth.speak(
|
|
1190
|
+
}), s.onerror = (n) => {
|
|
1191
|
+
console.error("Error during speech synthesis:", n.error);
|
|
1192
|
+
}, this.synth.speak(s);
|
|
1188
1193
|
}
|
|
1189
1194
|
stopSpeaking() {
|
|
1190
1195
|
this.synth && this.synth.cancel();
|
|
1191
1196
|
}
|
|
1192
1197
|
}
|
|
1193
|
-
class
|
|
1198
|
+
class Ft {
|
|
1194
1199
|
constructor() {
|
|
1195
1200
|
this.fallbackMessage = "Sorry, I didn’t understand that.";
|
|
1196
1201
|
}
|
|
@@ -1198,44 +1203,44 @@ class Pt {
|
|
|
1198
1203
|
this.fallbackMessage = e;
|
|
1199
1204
|
}
|
|
1200
1205
|
handleFallback(e) {
|
|
1201
|
-
e && console.log(`Fallback triggered for: "${e}"`), console.log(this.fallbackMessage), new
|
|
1206
|
+
e && console.log(`Fallback triggered for: "${e}"`), console.log(this.fallbackMessage), new qe().speak(this.fallbackMessage);
|
|
1202
1207
|
}
|
|
1203
1208
|
getFallbackMessage() {
|
|
1204
1209
|
return this.fallbackMessage;
|
|
1205
1210
|
}
|
|
1206
1211
|
}
|
|
1207
|
-
const
|
|
1212
|
+
const ve = () => {
|
|
1208
1213
|
if (typeof window > "u") return null;
|
|
1209
|
-
const
|
|
1210
|
-
return
|
|
1214
|
+
const i = window;
|
|
1215
|
+
return i.SpeechRecognition ?? i.webkitSpeechRecognition ?? null;
|
|
1211
1216
|
};
|
|
1212
|
-
class
|
|
1213
|
-
constructor(e = "en-US",
|
|
1217
|
+
class Ht {
|
|
1218
|
+
constructor(e = "en-US", t = {}) {
|
|
1214
1219
|
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 = () => {
|
|
1215
|
-
var
|
|
1220
|
+
var n;
|
|
1216
1221
|
this.ttsSpeaking = !0;
|
|
1217
1222
|
try {
|
|
1218
|
-
(
|
|
1223
|
+
(n = this.recognition) == null || n.stop();
|
|
1219
1224
|
} catch {
|
|
1220
1225
|
}
|
|
1221
1226
|
this.isListening && this.emitStatus("speaking");
|
|
1222
1227
|
}, this.onTTSEnd = () => {
|
|
1223
1228
|
this.ttsSpeaking = !1, this.isListening && this.restartAllowed ? this.safeRestart() : this.emitStatus(this.isListening ? "listening" : "idle");
|
|
1224
1229
|
};
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
this.recognition = new
|
|
1230
|
+
const s = ve();
|
|
1231
|
+
if (s) {
|
|
1232
|
+
this.recognition = new s(), this.recognition.lang = e, this.recognition.interimResults = t.interimResults ?? !0, this.recognition.continuous = t.continuous ?? !0, this.recognition.onresult = (o) => this.handleResult(o, t), this.recognition.onend = () => this.handleEnd(), this.recognition.onstart = () => {
|
|
1228
1233
|
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");
|
|
1229
1234
|
};
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1235
|
+
const n = this.recognition;
|
|
1236
|
+
n.onaudiostart = () => this.log("onaudiostart"), n.onsoundstart = () => this.log("onsoundstart"), n.onspeechstart = () => this.log("onspeechstart"), n.onspeechend = () => this.log("onspeechend"), n.onsoundend = () => this.log("onsoundend"), n.onaudioend = () => this.log("onaudioend"), this.recognition.onerror = (o) => this.handleError(o);
|
|
1232
1237
|
} else
|
|
1233
1238
|
this.recognition = null, this.emitStatus("unsupported");
|
|
1234
1239
|
typeof window < "u" ? (window.addEventListener("foisit:tts-start", this.onTTSStart), window.addEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler = () => {
|
|
1235
|
-
var
|
|
1240
|
+
var n;
|
|
1236
1241
|
if (typeof document < "u" && document.hidden) {
|
|
1237
1242
|
try {
|
|
1238
|
-
(
|
|
1243
|
+
(n = this.recognition) == null || n.stop();
|
|
1239
1244
|
} catch {
|
|
1240
1245
|
}
|
|
1241
1246
|
this.emitStatus(this.ttsSpeaking ? "speaking" : "idle");
|
|
@@ -1254,7 +1259,7 @@ class Vt {
|
|
|
1254
1259
|
}
|
|
1255
1260
|
/** Check if SpeechRecognition is available */
|
|
1256
1261
|
isSupported() {
|
|
1257
|
-
return
|
|
1262
|
+
return ve() !== null;
|
|
1258
1263
|
}
|
|
1259
1264
|
/** Allow consumers (wrappers) to observe status changes */
|
|
1260
1265
|
onStatusChange(e) {
|
|
@@ -1288,15 +1293,15 @@ class Vt {
|
|
|
1288
1293
|
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);
|
|
1289
1294
|
}
|
|
1290
1295
|
/** Handle recognized speech results */
|
|
1291
|
-
handleResult(e,
|
|
1292
|
-
var
|
|
1296
|
+
handleResult(e, t) {
|
|
1297
|
+
var n, o;
|
|
1293
1298
|
if (!this.resultCallback) return;
|
|
1294
|
-
const
|
|
1295
|
-
for (let
|
|
1296
|
-
const
|
|
1297
|
-
if (h && !(!
|
|
1299
|
+
const s = t.confidenceThreshold ?? 0.6;
|
|
1300
|
+
for (let a = e.resultIndex; a < e.results.length; a++) {
|
|
1301
|
+
const r = e.results[a], c = r && r[0], h = ((o = (n = c == null ? void 0 : c.transcript) == null ? void 0 : n.trim) == null ? void 0 : o.call(n)) || "", d = (c == null ? void 0 : c.confidence) ?? 0;
|
|
1302
|
+
if (h && !(!r.isFinal && t.interimResults === !1) && !(r.isFinal && d < s))
|
|
1298
1303
|
try {
|
|
1299
|
-
this.hadResultThisSession = !0, this.resultCallback(h, !!
|
|
1304
|
+
this.hadResultThisSession = !0, this.resultCallback(h, !!r.isFinal);
|
|
1300
1305
|
} catch {
|
|
1301
1306
|
this.error("VoiceProcessor: result callback error");
|
|
1302
1307
|
}
|
|
@@ -1312,9 +1317,9 @@ class Vt {
|
|
|
1312
1317
|
}
|
|
1313
1318
|
/** Handle errors during speech recognition */
|
|
1314
1319
|
handleError(e) {
|
|
1315
|
-
const
|
|
1316
|
-
if (this.warn(`Error occurred: ${
|
|
1317
|
-
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error:
|
|
1320
|
+
const t = e == null ? void 0 : e.error;
|
|
1321
|
+
if (this.warn(`Error occurred: ${t ?? "unknown"}`), t && ["not-allowed", "service-not-allowed", "bad-grammar", "language-not-supported"].includes(t)) {
|
|
1322
|
+
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error: t });
|
|
1318
1323
|
return;
|
|
1319
1324
|
}
|
|
1320
1325
|
this.scheduleRestart();
|
|
@@ -1359,43 +1364,45 @@ class Vt {
|
|
|
1359
1364
|
const e = navigator.mediaDevices;
|
|
1360
1365
|
if (!(e != null && e.getUserMedia)) return;
|
|
1361
1366
|
this.log("prewarmAudio: requesting mic");
|
|
1362
|
-
const
|
|
1363
|
-
for (const
|
|
1367
|
+
const t = await e.getUserMedia({ audio: !0 });
|
|
1368
|
+
for (const s of t.getTracks()) s.stop();
|
|
1364
1369
|
this.prewarmed = !0, this.log("prewarmAudio: mic ready");
|
|
1365
1370
|
} catch {
|
|
1366
1371
|
this.warn("prewarmAudio: failed to get mic");
|
|
1367
1372
|
}
|
|
1368
1373
|
}
|
|
1369
|
-
emitStatus(e,
|
|
1374
|
+
emitStatus(e, t) {
|
|
1370
1375
|
if (this.statusCallback)
|
|
1371
1376
|
try {
|
|
1372
|
-
this.statusCallback(e,
|
|
1377
|
+
this.statusCallback(e, t);
|
|
1373
1378
|
} catch {
|
|
1374
1379
|
this.error("VoiceProcessor: status callback error");
|
|
1375
1380
|
}
|
|
1376
1381
|
}
|
|
1377
1382
|
}
|
|
1378
|
-
class
|
|
1383
|
+
class ae {
|
|
1379
1384
|
constructor() {
|
|
1380
|
-
this.lastTap = 0;
|
|
1385
|
+
this.lastTap = 0, this.tapCount = 0;
|
|
1381
1386
|
}
|
|
1382
1387
|
/**
|
|
1383
|
-
* Sets up
|
|
1384
|
-
* @param
|
|
1388
|
+
* Sets up triple-click and triple-tap listeners
|
|
1389
|
+
* @param onTripleClickOrTap Callback to execute when a triple-click or triple-tap is detected
|
|
1385
1390
|
*/
|
|
1386
|
-
|
|
1387
|
-
this.destroy(), this.
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1391
|
+
setupTripleTapListener(e) {
|
|
1392
|
+
this.destroy(), this.clickListener = () => {
|
|
1393
|
+
this.tapCount++, this.tapCount === 1 ? this.tapTimeout = window.setTimeout(() => {
|
|
1394
|
+
this.tapCount = 0;
|
|
1395
|
+
}, 500) : this.tapCount === 3 && (clearTimeout(this.tapTimeout), this.tapCount = 0, e());
|
|
1396
|
+
}, document.addEventListener("click", this.clickListener), this.touchEndListener = () => {
|
|
1397
|
+
const t = (/* @__PURE__ */ new Date()).getTime(), s = t - this.lastTap;
|
|
1398
|
+
s < 500 && s > 0 ? (this.tapCount++, this.tapCount === 3 && (this.tapCount = 0, e())) : this.tapCount = 1, this.lastTap = t;
|
|
1392
1399
|
}, document.addEventListener("touchend", this.touchEndListener);
|
|
1393
1400
|
}
|
|
1394
1401
|
destroy() {
|
|
1395
|
-
this.dblClickListener && document.removeEventListener("dblclick", this.dblClickListener), this.touchEndListener && document.removeEventListener("touchend", this.touchEndListener), this.dblClickListener = void 0, this.touchEndListener = void 0;
|
|
1402
|
+
this.dblClickListener && document.removeEventListener("dblclick", this.dblClickListener), this.touchEndListener && document.removeEventListener("touchend", this.touchEndListener), this.clickListener && document.removeEventListener("click", this.clickListener), this.tapTimeout && clearTimeout(this.tapTimeout), this.dblClickListener = void 0, this.touchEndListener = void 0, this.clickListener = void 0, this.tapTimeout = void 0, this.tapCount = 0;
|
|
1396
1403
|
}
|
|
1397
1404
|
}
|
|
1398
|
-
function
|
|
1405
|
+
function Pt() {
|
|
1399
1406
|
if (document.querySelector("#assistant-styles")) {
|
|
1400
1407
|
console.log("Styles already injected");
|
|
1401
1408
|
return;
|
|
@@ -1436,15 +1443,15 @@ function Dt() {
|
|
|
1436
1443
|
}
|
|
1437
1444
|
`, document.head.appendChild(e), console.log("Gradient styles injected");
|
|
1438
1445
|
}
|
|
1439
|
-
function
|
|
1446
|
+
function Vt() {
|
|
1440
1447
|
if (document.querySelector("#gradient-indicator"))
|
|
1441
1448
|
return;
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1449
|
+
const i = document.createElement("div");
|
|
1450
|
+
i.id = "gradient-indicator", Pt(), i.classList.add("gradient-indicator"), document.body.appendChild(i), console.log("Gradient indicator added to the DOM");
|
|
1444
1451
|
}
|
|
1445
|
-
function
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1452
|
+
function Dt() {
|
|
1453
|
+
const i = document.querySelector("#gradient-indicator");
|
|
1454
|
+
i && (i.remove(), console.log("Gradient indicator removed from the DOM"));
|
|
1448
1455
|
}
|
|
1449
1456
|
function qt() {
|
|
1450
1457
|
return typeof window < "u" && typeof document < "u";
|
|
@@ -1457,7 +1464,7 @@ class zt {
|
|
|
1457
1464
|
return this.state;
|
|
1458
1465
|
}
|
|
1459
1466
|
setState(e) {
|
|
1460
|
-
this.state = e, this.notifySubscribers(), console.log("State updated:", e), e === "listening" ?
|
|
1467
|
+
this.state = e, this.notifySubscribers(), console.log("State updated:", e), e === "listening" ? Vt() : Dt();
|
|
1461
1468
|
}
|
|
1462
1469
|
// eslint-disable-next-line no-unused-vars
|
|
1463
1470
|
subscribe(e) {
|
|
@@ -1469,25 +1476,103 @@ class zt {
|
|
|
1469
1476
|
}
|
|
1470
1477
|
class Bt {
|
|
1471
1478
|
constructor(e) {
|
|
1472
|
-
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.
|
|
1479
|
+
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.commandHandlers = /* @__PURE__ */ new Map(), this.active = qt(), this.handleClickOutside = (t) => {
|
|
1480
|
+
const s = t.target;
|
|
1481
|
+
this.chatWindow && this.chatWindow.contains(s) || s.closest(".foisit-floating-btn") || this.toggle();
|
|
1482
|
+
}, this.config = e, this.active && this.init();
|
|
1483
|
+
}
|
|
1484
|
+
/** Register a command handler that can be invoked programmatically via `runCommand` */
|
|
1485
|
+
registerCommandHandler(e, t) {
|
|
1486
|
+
!e || typeof t != "function" || this.commandHandlers.set(e, t);
|
|
1487
|
+
}
|
|
1488
|
+
/** Check whether a programmatic handler is registered locally */
|
|
1489
|
+
hasCommandHandler(e) {
|
|
1490
|
+
return this.commandHandlers.has(e);
|
|
1491
|
+
}
|
|
1492
|
+
/** Set an external executor (used to run commands registered via CommandHandler) */
|
|
1493
|
+
setExternalCommandExecutor(e) {
|
|
1494
|
+
this.externalCommandExecutor = e;
|
|
1495
|
+
}
|
|
1496
|
+
/** Unregister a previously registered command handler */
|
|
1497
|
+
unregisterCommandHandler(e) {
|
|
1498
|
+
e && this.commandHandlers.delete(e);
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Run a registered command by id. Options:
|
|
1502
|
+
* - `params`: passed to the handler
|
|
1503
|
+
* - `openOverlay`: if true, open the overlay before running
|
|
1504
|
+
* - `showInvocation`: if true, show the invocation as a user message
|
|
1505
|
+
*/
|
|
1506
|
+
async runCommand(e) {
|
|
1507
|
+
if (!e || !e.commandId)
|
|
1508
|
+
throw new Error("runCommand requires a commandId");
|
|
1509
|
+
const {
|
|
1510
|
+
commandId: t,
|
|
1511
|
+
params: s,
|
|
1512
|
+
openOverlay: n = !0,
|
|
1513
|
+
showInvocation: o = !0
|
|
1514
|
+
} = e;
|
|
1515
|
+
n && !this.isOpen && this.toggle();
|
|
1516
|
+
const a = this.commandHandlers.get(t);
|
|
1517
|
+
if (a && o && this.messagesContainer && this.addMessage(`Command: ${t}`, "user"), a)
|
|
1518
|
+
try {
|
|
1519
|
+
this.showLoading();
|
|
1520
|
+
const r = await a(s);
|
|
1521
|
+
if (this.hideLoading(), typeof r == "string")
|
|
1522
|
+
this.addMessage(r, "system");
|
|
1523
|
+
else if (r && typeof r == "object")
|
|
1524
|
+
try {
|
|
1525
|
+
this.addMessage(JSON.stringify(r, null, 2), "system");
|
|
1526
|
+
} catch {
|
|
1527
|
+
this.addMessage(String(r), "system");
|
|
1528
|
+
}
|
|
1529
|
+
else r == null || this.addMessage(String(r), "system");
|
|
1530
|
+
return r;
|
|
1531
|
+
} catch (r) {
|
|
1532
|
+
throw this.hideLoading(), this.addMessage(
|
|
1533
|
+
`Command "${t}" failed: ${String(r)}`,
|
|
1534
|
+
"system"
|
|
1535
|
+
), r;
|
|
1536
|
+
}
|
|
1537
|
+
if (this.externalCommandExecutor)
|
|
1538
|
+
try {
|
|
1539
|
+
this.showLoading();
|
|
1540
|
+
const r = await this.externalCommandExecutor({ commandId: t, params: s });
|
|
1541
|
+
return this.hideLoading(), r;
|
|
1542
|
+
} catch (r) {
|
|
1543
|
+
throw this.hideLoading(), this.addMessage(
|
|
1544
|
+
`Command "${t}" failed: ${String(r)}`,
|
|
1545
|
+
"system"
|
|
1546
|
+
), r;
|
|
1547
|
+
}
|
|
1548
|
+
this.addMessage(
|
|
1549
|
+
`No handler registered for command "${t}".`,
|
|
1550
|
+
"system"
|
|
1551
|
+
);
|
|
1473
1552
|
}
|
|
1474
1553
|
init() {
|
|
1475
|
-
var
|
|
1554
|
+
var t, s;
|
|
1476
1555
|
if (this.container) return;
|
|
1477
1556
|
this.injectOverlayStyles();
|
|
1478
1557
|
const e = document.getElementById("foisit-overlay-container");
|
|
1479
1558
|
if (e && e instanceof HTMLElement) {
|
|
1480
|
-
this.container = e, this.chatWindow = e.querySelector(
|
|
1559
|
+
this.container = e, this.chatWindow = e.querySelector(
|
|
1560
|
+
".foisit-chat"
|
|
1561
|
+
), this.messagesContainer = e.querySelector(
|
|
1562
|
+
".foisit-messages"
|
|
1563
|
+
), this.input = e.querySelector(
|
|
1564
|
+
"input.foisit-input"
|
|
1565
|
+
), ((t = this.config.floatingButton) == null ? void 0 : t.visible) !== !1 && !e.querySelector(".foisit-floating-btn") && this.renderFloatingButton(), this.chatWindow || this.renderChatWindow(), this.config.enableGestureActivation && (this.gestureHandler = new ae(), this.gestureHandler.setupTripleTapListener(() => this.toggle()));
|
|
1481
1566
|
return;
|
|
1482
1567
|
}
|
|
1483
|
-
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((
|
|
1568
|
+
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((s = this.config.floatingButton) == null ? void 0 : s.visible) !== !1 && this.renderFloatingButton(), this.renderChatWindow(), this.config.enableGestureActivation && (this.gestureHandler = new ae(), this.gestureHandler.setupTripleTapListener(() => this.toggle()));
|
|
1484
1569
|
}
|
|
1485
1570
|
renderFloatingButton() {
|
|
1486
|
-
var
|
|
1571
|
+
var n, o, a, r, c, h;
|
|
1487
1572
|
const e = document.createElement("button");
|
|
1488
|
-
e.innerHTML = ((
|
|
1489
|
-
const
|
|
1490
|
-
e.className = "foisit-floating-btn", e.style.bottom =
|
|
1573
|
+
e.innerHTML = ((n = this.config.floatingButton) == null ? void 0 : n.customHtml) || "🎙️";
|
|
1574
|
+
const t = ((a = (o = this.config.floatingButton) == null ? void 0 : o.position) == null ? void 0 : a.bottom) || "20px", s = ((c = (r = this.config.floatingButton) == null ? void 0 : r.position) == null ? void 0 : c.right) || "20px";
|
|
1575
|
+
e.className = "foisit-floating-btn", e.style.bottom = t, e.style.right = s, 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);
|
|
1491
1576
|
}
|
|
1492
1577
|
renderChatWindow() {
|
|
1493
1578
|
var o;
|
|
@@ -1495,168 +1580,184 @@ class Bt {
|
|
|
1495
1580
|
this.chatWindow = document.createElement("div"), this.chatWindow.className = "foisit-chat";
|
|
1496
1581
|
const e = document.createElement("div");
|
|
1497
1582
|
e.className = "foisit-header";
|
|
1498
|
-
const
|
|
1499
|
-
|
|
1500
|
-
const
|
|
1501
|
-
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1504
|
-
var
|
|
1505
|
-
if (
|
|
1583
|
+
const t = document.createElement("span");
|
|
1584
|
+
t.className = "foisit-title", t.textContent = "Foisit";
|
|
1585
|
+
const s = document.createElement("button");
|
|
1586
|
+
s.type = "button", s.className = "foisit-close", s.setAttribute("aria-label", "Close"), s.innerHTML = "×", s.addEventListener("click", () => this.toggle()), e.appendChild(t), e.appendChild(s), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "foisit-messages";
|
|
1587
|
+
const n = document.createElement("div");
|
|
1588
|
+
n.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", (a) => {
|
|
1589
|
+
var r;
|
|
1590
|
+
if (a.key === "Enter" && ((r = this.input) != null && r.value.trim())) {
|
|
1506
1591
|
const c = this.input.value.trim();
|
|
1507
1592
|
this.input.value = "", this.onSubmit && this.onSubmit(c);
|
|
1508
1593
|
}
|
|
1509
|
-
}),
|
|
1594
|
+
}), n.appendChild(this.input), this.chatWindow.appendChild(e), this.chatWindow.appendChild(this.messagesContainer), this.chatWindow.appendChild(n), (o = this.container) == null || o.appendChild(this.chatWindow);
|
|
1510
1595
|
}
|
|
1511
|
-
registerCallbacks(e,
|
|
1512
|
-
this.active && (this.onSubmit = e, this.onClose =
|
|
1596
|
+
registerCallbacks(e, t) {
|
|
1597
|
+
this.active && (this.onSubmit = e, this.onClose = t);
|
|
1513
1598
|
}
|
|
1514
|
-
toggle(e,
|
|
1515
|
-
this.active && (e && (this.onSubmit = e),
|
|
1599
|
+
toggle(e, t) {
|
|
1600
|
+
this.active && (e && (this.onSubmit = e), t && (this.onClose = t), this.isOpen = !this.isOpen, this.chatWindow && (this.isOpen ? (this.container && (this.container.style.pointerEvents = "auto"), this.chatWindow.style.display = "flex", requestAnimationFrame(() => {
|
|
1516
1601
|
this.chatWindow && (this.chatWindow.style.opacity = "1", this.chatWindow.style.transform = "translateY(0) scale(1)");
|
|
1517
1602
|
}), setTimeout(() => {
|
|
1518
|
-
var
|
|
1519
|
-
return (
|
|
1520
|
-
}, 100)) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1603
|
+
var s;
|
|
1604
|
+
return (s = this.input) == null ? void 0 : s.focus();
|
|
1605
|
+
}, 100), this.addClickOutsideListener()) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1521
1606
|
this.chatWindow && !this.isOpen && (this.chatWindow.style.display = "none");
|
|
1522
|
-
}, 200), this.onClose && this.onClose())));
|
|
1607
|
+
}, 200), this.onClose && this.onClose(), this.removeClickOutsideListener(), this.container && (this.container.style.pointerEvents = "none"))));
|
|
1608
|
+
}
|
|
1609
|
+
addClickOutsideListener() {
|
|
1610
|
+
this.container && (this.removeClickOutsideListener(), this.container.addEventListener("click", this.handleClickOutside));
|
|
1611
|
+
}
|
|
1612
|
+
removeClickOutsideListener() {
|
|
1613
|
+
this.container && this.container.removeEventListener("click", this.handleClickOutside);
|
|
1523
1614
|
}
|
|
1524
|
-
addMessage(e,
|
|
1615
|
+
addMessage(e, t) {
|
|
1525
1616
|
if (!this.messagesContainer) return;
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1617
|
+
const s = document.createElement("div");
|
|
1618
|
+
t === "system" ? s.innerHTML = this.renderMarkdown(e) : s.textContent = e, s.className = t === "user" ? "foisit-bubble user" : "foisit-bubble system";
|
|
1619
|
+
const n = (e || "").length || 0, o = Math.max(120, 700 - Math.min(600, Math.floor(n * 6)));
|
|
1620
|
+
s.style.opacity = "0", s.style.transform = "translateY(8px)", s.style.transition = "none", this.messagesContainer.appendChild(s), this.animateMessageEntrance(s, o), this.scrollToBottom();
|
|
1528
1621
|
}
|
|
1529
1622
|
addOptions(e) {
|
|
1530
1623
|
if (!this.messagesContainer) return;
|
|
1531
|
-
const
|
|
1532
|
-
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1624
|
+
const t = document.createElement("div");
|
|
1625
|
+
t.className = "foisit-options-container", e.forEach((s) => {
|
|
1626
|
+
const n = document.createElement("button");
|
|
1627
|
+
n.textContent = s.label, n.className = "foisit-option-chip", n.setAttribute("type", "button"), n.setAttribute("aria-label", s.label);
|
|
1535
1628
|
const o = () => {
|
|
1536
|
-
if (
|
|
1537
|
-
this.onSubmit && this.onSubmit({ commandId:
|
|
1629
|
+
if (s.commandId) {
|
|
1630
|
+
this.onSubmit && this.onSubmit({ commandId: s.commandId });
|
|
1538
1631
|
return;
|
|
1539
1632
|
}
|
|
1540
|
-
const
|
|
1541
|
-
this.onSubmit && this.onSubmit(
|
|
1633
|
+
const a = s && typeof s.value == "string" && s.value.trim() ? s.value : s.label;
|
|
1634
|
+
this.onSubmit && this.onSubmit(a);
|
|
1542
1635
|
};
|
|
1543
|
-
|
|
1544
|
-
(
|
|
1545
|
-
},
|
|
1546
|
-
}), this.messagesContainer.appendChild(
|
|
1636
|
+
n.onclick = o, n.onkeydown = (a) => {
|
|
1637
|
+
(a.key === "Enter" || a.key === " ") && (a.preventDefault(), o());
|
|
1638
|
+
}, t.appendChild(n);
|
|
1639
|
+
}), this.messagesContainer.appendChild(t), this.scrollToBottom();
|
|
1547
1640
|
}
|
|
1548
|
-
addForm(e,
|
|
1641
|
+
addForm(e, t, s) {
|
|
1549
1642
|
if (!this.messagesContainer) return;
|
|
1550
1643
|
this.addMessage(e, "system");
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
const o = [],
|
|
1644
|
+
const n = document.createElement("form");
|
|
1645
|
+
n.className = "foisit-form";
|
|
1646
|
+
const o = [], a = (d, l) => {
|
|
1554
1647
|
const f = document.createElement("div");
|
|
1555
1648
|
return f.className = "foisit-form-label", f.innerHTML = d + (l ? ' <span class="foisit-req-star">*</span>' : ""), f;
|
|
1556
|
-
},
|
|
1649
|
+
}, r = () => {
|
|
1557
1650
|
const d = document.createElement("div");
|
|
1558
1651
|
return d.className = "foisit-form-error", d.style.display = "none", d;
|
|
1559
1652
|
};
|
|
1560
|
-
(
|
|
1653
|
+
(t ?? []).forEach((d) => {
|
|
1561
1654
|
const l = document.createElement("div");
|
|
1562
1655
|
l.className = "foisit-form-group";
|
|
1563
1656
|
const f = d.description || d.name;
|
|
1564
|
-
l.appendChild(
|
|
1657
|
+
l.appendChild(a(f, d.required));
|
|
1565
1658
|
let m;
|
|
1566
1659
|
if (d.type === "select") {
|
|
1567
1660
|
const u = document.createElement("select");
|
|
1568
1661
|
u.className = "foisit-form-input";
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1662
|
+
const v = document.createElement("option");
|
|
1663
|
+
v.value = "", v.textContent = "Select...", u.appendChild(v);
|
|
1571
1664
|
const x = (p) => {
|
|
1572
|
-
(p ?? []).forEach((
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1665
|
+
(p ?? []).forEach((C) => {
|
|
1666
|
+
const y = document.createElement("option");
|
|
1667
|
+
y.value = String(C.value ?? C.label ?? ""), y.textContent = String(C.label ?? C.value ?? ""), u.appendChild(y);
|
|
1575
1668
|
});
|
|
1576
1669
|
};
|
|
1577
1670
|
if (Array.isArray(d.options) && d.options.length)
|
|
1578
1671
|
x(d.options);
|
|
1579
1672
|
else if (typeof d.getOptions == "function") {
|
|
1580
|
-
const p = d.getOptions,
|
|
1581
|
-
|
|
1673
|
+
const p = d.getOptions, C = document.createElement("option");
|
|
1674
|
+
C.value = "", C.textContent = "Loading...", u.appendChild(C), Promise.resolve().then(() => p()).then((y) => {
|
|
1582
1675
|
for (; u.options.length > 1; ) u.remove(1);
|
|
1583
|
-
x(
|
|
1676
|
+
x(y);
|
|
1584
1677
|
}).catch(() => {
|
|
1585
1678
|
for (; u.options.length > 1; ) u.remove(1);
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1679
|
+
const y = document.createElement("option");
|
|
1680
|
+
y.value = "", y.textContent = "Error loading options", u.appendChild(y);
|
|
1588
1681
|
});
|
|
1589
1682
|
}
|
|
1590
1683
|
d.defaultValue != null && (u.value = String(d.defaultValue)), m = u;
|
|
1591
1684
|
} else if (d.type === "file") {
|
|
1592
|
-
const u = d,
|
|
1593
|
-
|
|
1594
|
-
const x = Array.from(
|
|
1685
|
+
const u = d, v = document.createElement("input");
|
|
1686
|
+
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 () => {
|
|
1687
|
+
const x = Array.from(v.files || []), p = b;
|
|
1595
1688
|
if (p.style.display = "none", p.textContent = "", x.length === 0) return;
|
|
1596
|
-
const
|
|
1597
|
-
if (x.length >
|
|
1598
|
-
p.textContent = `Please select at most ${
|
|
1689
|
+
const C = u.maxFiles ?? (u.multiple ? 10 : 1);
|
|
1690
|
+
if (x.length > C) {
|
|
1691
|
+
p.textContent = `Please select at most ${C} file(s).`, p.style.display = "block";
|
|
1599
1692
|
return;
|
|
1600
1693
|
}
|
|
1601
|
-
const
|
|
1602
|
-
if (x.some((
|
|
1603
|
-
p.textContent = `One or more files exceed the maximum size of ${Math.round(
|
|
1694
|
+
const y = u.maxSizeBytes ?? 1 / 0, g = x.reduce((w, B) => w + B.size, 0);
|
|
1695
|
+
if (x.some((w) => w.size > y)) {
|
|
1696
|
+
p.textContent = `One or more files exceed the maximum size of ${Math.round(
|
|
1697
|
+
y / 1024
|
|
1698
|
+
)} KB.`, p.style.display = "block";
|
|
1604
1699
|
return;
|
|
1605
1700
|
}
|
|
1606
|
-
const
|
|
1607
|
-
if (g >
|
|
1608
|
-
p.textContent = `Total selected files exceed the maximum of ${Math.round(
|
|
1701
|
+
const V = u.maxTotalBytes ?? 1 / 0;
|
|
1702
|
+
if (g > V) {
|
|
1703
|
+
p.textContent = `Total selected files exceed the maximum of ${Math.round(
|
|
1704
|
+
V / 1024
|
|
1705
|
+
)} KB.`, p.style.display = "block";
|
|
1609
1706
|
return;
|
|
1610
1707
|
}
|
|
1611
1708
|
if (u.accept && Array.isArray(u.accept)) {
|
|
1612
|
-
const
|
|
1613
|
-
if (!x.every((U) => U.type ?
|
|
1709
|
+
const w = u.accept;
|
|
1710
|
+
if (!x.every((U) => U.type ? w.some(
|
|
1711
|
+
(W) => W.startsWith(".") ? U.name.toLowerCase().endsWith(W.toLowerCase()) : U.type === W || U.type.startsWith(W.split("/")[0] + "/")
|
|
1712
|
+
) : !0)) {
|
|
1614
1713
|
p.textContent = "One or more files have an unsupported type.", p.style.display = "block";
|
|
1615
1714
|
return;
|
|
1616
1715
|
}
|
|
1617
1716
|
}
|
|
1618
|
-
}), m =
|
|
1717
|
+
}), m = v;
|
|
1619
1718
|
} else {
|
|
1620
1719
|
const u = document.createElement("input");
|
|
1621
1720
|
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;
|
|
1622
1721
|
}
|
|
1623
|
-
const
|
|
1624
|
-
l.appendChild(m), l.appendChild(
|
|
1722
|
+
const b = r();
|
|
1723
|
+
l.appendChild(m), l.appendChild(b), o.push({
|
|
1625
1724
|
name: d.name,
|
|
1626
1725
|
type: d.type,
|
|
1627
1726
|
el: m,
|
|
1628
1727
|
required: d.required
|
|
1629
|
-
}),
|
|
1728
|
+
}), n.appendChild(l);
|
|
1630
1729
|
});
|
|
1631
1730
|
const c = document.createElement("div");
|
|
1632
1731
|
c.className = "foisit-form-actions";
|
|
1633
1732
|
const h = document.createElement("button");
|
|
1634
|
-
h.type = "submit", h.textContent = "Submit", h.className = "foisit-option-chip", h.style.fontWeight = "600", c.appendChild(h),
|
|
1733
|
+
h.type = "submit", h.textContent = "Submit", h.className = "foisit-option-chip", h.style.fontWeight = "600", c.appendChild(h), n.appendChild(c), n.onsubmit = async (d) => {
|
|
1635
1734
|
d.preventDefault();
|
|
1636
1735
|
const l = {};
|
|
1637
1736
|
let f = !1;
|
|
1638
|
-
|
|
1737
|
+
n.querySelectorAll(".foisit-form-error").forEach((m) => {
|
|
1639
1738
|
m.style.display = "none", m.textContent = "";
|
|
1640
|
-
}),
|
|
1739
|
+
}), n.querySelectorAll(".foisit-form-input").forEach((m) => {
|
|
1641
1740
|
m.classList.remove("foisit-error-border");
|
|
1642
1741
|
});
|
|
1643
1742
|
for (const m of o) {
|
|
1644
1743
|
if (m.type === "file") {
|
|
1645
|
-
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(
|
|
1646
|
-
|
|
1647
|
-
|
|
1744
|
+
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(
|
|
1745
|
+
".foisit-form-error"
|
|
1746
|
+
), C = m.el, y = Array.from(C.files || []);
|
|
1747
|
+
if (m.required && y.length === 0) {
|
|
1748
|
+
f = !0, C.classList.add("foisit-error-border"), p && (p.textContent = "This file is required", p.style.display = "block");
|
|
1648
1749
|
continue;
|
|
1649
1750
|
}
|
|
1650
|
-
if (
|
|
1651
|
-
const g = (
|
|
1751
|
+
if (y.length === 0) continue;
|
|
1752
|
+
const g = (t ?? []).find((w) => w.name === m.name), V = (g == null ? void 0 : g.delivery) ?? "file";
|
|
1652
1753
|
if (g != null && g.maxWidth || g != null && g.maxHeight)
|
|
1653
1754
|
try {
|
|
1654
|
-
const
|
|
1655
|
-
if (g.maxWidth &&
|
|
1755
|
+
const w = await this.getImageDimensions(y[0]);
|
|
1756
|
+
if (g.maxWidth && w.width > g.maxWidth) {
|
|
1656
1757
|
f = !0, p && (p.textContent = `Image width must be ≤ ${g.maxWidth}px`, p.style.display = "block");
|
|
1657
1758
|
continue;
|
|
1658
1759
|
}
|
|
1659
|
-
if (g.maxHeight &&
|
|
1760
|
+
if (g.maxHeight && w.height > g.maxHeight) {
|
|
1660
1761
|
f = !0, p && (p.textContent = `Image height must be ≤ ${g.maxHeight}px`, p.style.display = "block");
|
|
1661
1762
|
continue;
|
|
1662
1763
|
}
|
|
@@ -1664,52 +1765,56 @@ class Bt {
|
|
|
1664
1765
|
}
|
|
1665
1766
|
if (g != null && g.maxDurationSec)
|
|
1666
1767
|
try {
|
|
1667
|
-
const
|
|
1668
|
-
if (
|
|
1768
|
+
const w = await this.getMediaDuration(y[0]);
|
|
1769
|
+
if (w && w > g.maxDurationSec) {
|
|
1669
1770
|
f = !0, p && (p.textContent = `Media duration must be ≤ ${g.maxDurationSec}s`, p.style.display = "block");
|
|
1670
1771
|
continue;
|
|
1671
1772
|
}
|
|
1672
1773
|
} catch {
|
|
1673
1774
|
}
|
|
1674
|
-
if (
|
|
1675
|
-
l[m.name] = g != null && g.multiple ?
|
|
1676
|
-
else if (
|
|
1775
|
+
if (V === "file")
|
|
1776
|
+
l[m.name] = g != null && g.multiple ? y : y[0];
|
|
1777
|
+
else if (V === "base64")
|
|
1677
1778
|
try {
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1779
|
+
const w = await Promise.all(
|
|
1780
|
+
y.map((B) => this.readFileAsDataURL(B))
|
|
1781
|
+
);
|
|
1782
|
+
l[m.name] = g != null && g.multiple ? w : w[0];
|
|
1680
1783
|
} catch {
|
|
1681
1784
|
f = !0, p && (p.textContent = "Failed to encode file(s) to base64.", p.style.display = "block");
|
|
1682
1785
|
continue;
|
|
1683
1786
|
}
|
|
1684
1787
|
continue;
|
|
1685
1788
|
}
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1688
|
-
|
|
1789
|
+
const b = (m.el.value ?? "").toString().trim(), u = m.el.parentElement, v = u == null ? void 0 : u.querySelector(
|
|
1790
|
+
".foisit-form-error"
|
|
1791
|
+
);
|
|
1792
|
+
if (m.required && (b == null || b === "")) {
|
|
1793
|
+
f = !0, m.el.classList.add("foisit-error-border"), v && (v.textContent = "This field is required", v.style.display = "block");
|
|
1689
1794
|
continue;
|
|
1690
1795
|
}
|
|
1691
|
-
if (
|
|
1796
|
+
if (b !== "")
|
|
1692
1797
|
if (m.type === "number") {
|
|
1693
|
-
const x = Number(
|
|
1798
|
+
const x = Number(b);
|
|
1694
1799
|
Number.isNaN(x) || (l[m.name] = x);
|
|
1695
1800
|
} else
|
|
1696
|
-
l[m.name] =
|
|
1801
|
+
l[m.name] = b;
|
|
1697
1802
|
}
|
|
1698
1803
|
if (f) {
|
|
1699
|
-
|
|
1804
|
+
n.classList.add("foisit-shake"), setTimeout(() => n.classList.remove("foisit-shake"), 400);
|
|
1700
1805
|
return;
|
|
1701
1806
|
}
|
|
1702
1807
|
h.disabled = !0, h.style.opacity = "0.6", o.forEach((m) => {
|
|
1703
1808
|
m.el.disabled = !0;
|
|
1704
|
-
}),
|
|
1705
|
-
}, this.messagesContainer.appendChild(
|
|
1809
|
+
}), s(l);
|
|
1810
|
+
}, this.messagesContainer.appendChild(n), this.scrollToBottom();
|
|
1706
1811
|
}
|
|
1707
1812
|
showLoading() {
|
|
1708
1813
|
if (this.messagesContainer && !this.loadingEl) {
|
|
1709
1814
|
this.loadingEl = document.createElement("div"), this.loadingEl.className = "foisit-loading-dots foisit-bubble system";
|
|
1710
1815
|
for (let e = 0; e < 3; e++) {
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1816
|
+
const t = document.createElement("div");
|
|
1817
|
+
t.className = "foisit-dot", t.style.animation = `foisitPulse 1.4s infinite ease-in-out ${e * 0.2}s`, this.loadingEl.appendChild(t);
|
|
1713
1818
|
}
|
|
1714
1819
|
this.messagesContainer.appendChild(this.loadingEl), this.scrollToBottom();
|
|
1715
1820
|
}
|
|
@@ -1721,106 +1826,208 @@ class Bt {
|
|
|
1721
1826
|
scrollToBottom() {
|
|
1722
1827
|
this.messagesContainer && (this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight);
|
|
1723
1828
|
}
|
|
1829
|
+
/** Subtle entrance animation for new messages */
|
|
1830
|
+
animateMessageEntrance(e, t) {
|
|
1831
|
+
if (!e) return;
|
|
1832
|
+
e.style.transition = `opacity ${t}ms cubic-bezier(0.22, 0.9, 0.32, 1), transform ${Math.max(
|
|
1833
|
+
120,
|
|
1834
|
+
t
|
|
1835
|
+
)}ms cubic-bezier(0.22, 0.9, 0.32, 1)`, requestAnimationFrame(() => {
|
|
1836
|
+
e.style.opacity = "1", e.style.transform = "translateY(0)";
|
|
1837
|
+
});
|
|
1838
|
+
const s = () => {
|
|
1839
|
+
try {
|
|
1840
|
+
e.style.transition = "";
|
|
1841
|
+
} catch {
|
|
1842
|
+
}
|
|
1843
|
+
e.removeEventListener("transitionend", s);
|
|
1844
|
+
};
|
|
1845
|
+
e.addEventListener("transitionend", s);
|
|
1846
|
+
}
|
|
1847
|
+
/** Smoothly scroll messages container to bottom over duration (ms) */
|
|
1848
|
+
animateScrollToBottom(e) {
|
|
1849
|
+
if (!this.messagesContainer) return;
|
|
1850
|
+
const t = this.messagesContainer, s = t.scrollTop, n = t.scrollHeight - t.clientHeight;
|
|
1851
|
+
if (n <= s || e <= 0) {
|
|
1852
|
+
t.scrollTop = n;
|
|
1853
|
+
return;
|
|
1854
|
+
}
|
|
1855
|
+
const o = n - s, a = performance.now(), r = (c) => {
|
|
1856
|
+
const h = Math.min(1, (c - a) / e), d = 1 - Math.pow(1 - h, 3);
|
|
1857
|
+
t.scrollTop = Math.round(s + o * d), h < 1 && requestAnimationFrame(r);
|
|
1858
|
+
};
|
|
1859
|
+
requestAnimationFrame(r);
|
|
1860
|
+
}
|
|
1724
1861
|
destroy() {
|
|
1725
1862
|
var e;
|
|
1726
|
-
(e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1863
|
+
this.removeClickOutsideListener(), (e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1864
|
+
}
|
|
1865
|
+
/** Escape HTML special characters to prevent XSS */
|
|
1866
|
+
escapeHtml(e) {
|
|
1867
|
+
const t = {
|
|
1868
|
+
"&": "&",
|
|
1869
|
+
"<": "<",
|
|
1870
|
+
">": ">",
|
|
1871
|
+
'"': """,
|
|
1872
|
+
"'": "'"
|
|
1873
|
+
};
|
|
1874
|
+
return e.replace(/[&<>"']/g, (s) => t[s]);
|
|
1875
|
+
}
|
|
1876
|
+
/** Simple markdown renderer for AI responses */
|
|
1877
|
+
renderMarkdown(e) {
|
|
1878
|
+
let t = this.escapeHtml(e);
|
|
1879
|
+
return t = t.replace(/```(\w*)\n([\s\S]*?)```/g, (s, n, o) => `<pre class="foisit-code-block"><code${n ? ` class="language-${n}"` : ""}>${o.trim()}</code></pre>`), t = t.replace(
|
|
1880
|
+
/`([^`]+)`/g,
|
|
1881
|
+
'<code class="foisit-inline-code">$1</code>'
|
|
1882
|
+
), t = t.replace(/^###### (.+)$/gm, '<h6 class="foisit-md-h6">$1</h6>'), t = t.replace(/^##### (.+)$/gm, '<h5 class="foisit-md-h5">$1</h5>'), t = t.replace(/^#### (.+)$/gm, '<h4 class="foisit-md-h4">$1</h4>'), t = t.replace(/^### (.+)$/gm, '<h3 class="foisit-md-h3">$1</h3>'), t = t.replace(/^## (.+)$/gm, '<h2 class="foisit-md-h2">$1</h2>'), t = t.replace(/^# (.+)$/gm, '<h1 class="foisit-md-h1">$1</h1>'), t = t.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>"), t = t.replace(/__([^_]+)__/g, "<strong>$1</strong>"), t = t.replace(/\*([^*]+)\*/g, "<em>$1</em>"), t = t.replace(new RegExp("(?<!_)_([^_]+)_(?!_)", "g"), "<em>$1</em>"), t = t.replace(/~~([^~]+)~~/g, "<del>$1</del>"), t = t.replace(
|
|
1883
|
+
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
1884
|
+
'<a href="$2" target="_blank" rel="noopener noreferrer" class="foisit-md-link">$1</a>'
|
|
1885
|
+
), t = t.replace(/^[\-\*] (.+)$/gm, '<li class="foisit-md-li">$1</li>'), t = t.replace(
|
|
1886
|
+
/(<li class="foisit-md-li">.*<\/li>\n?)+/g,
|
|
1887
|
+
(s) => `<ul class="foisit-md-ul">${s}</ul>`
|
|
1888
|
+
), t = t.replace(/^\d+\. (.+)$/gm, '<li class="foisit-md-li">$1</li>'), t = t.replace(
|
|
1889
|
+
new RegExp('(?<!<\\/ul>)(<li class="foisit-md-li">.*<\\/li>\\n?)+', "g"),
|
|
1890
|
+
(s) => s.includes("<ul") ? s : `<ol class="foisit-md-ol">${s}</ol>`
|
|
1891
|
+
), t = t.replace(
|
|
1892
|
+
/^> (.+)$/gm,
|
|
1893
|
+
'<blockquote class="foisit-md-blockquote">$1</blockquote>'
|
|
1894
|
+
), t = t.replace(/^(---|___|\*\*\*)$/gm, '<hr class="foisit-md-hr">'), t = t.replace(/\n\n+/g, '</p><p class="foisit-md-p">'), t = t.replace(/\n/g, "<br>"), t.match(/^<(h[1-6]|ul|ol|pre|blockquote|hr|p)/) || (t = `<p class="foisit-md-p">${t}</p>`), t;
|
|
1727
1895
|
}
|
|
1728
1896
|
readFileAsDataURL(e) {
|
|
1729
|
-
return new Promise((
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1897
|
+
return new Promise((t, s) => {
|
|
1898
|
+
const n = new FileReader();
|
|
1899
|
+
n.onerror = () => s(new Error("Failed to read file")), n.onload = () => t(String(n.result)), n.readAsDataURL(e);
|
|
1732
1900
|
});
|
|
1733
1901
|
}
|
|
1734
1902
|
getImageDimensions(e) {
|
|
1735
|
-
return new Promise((
|
|
1903
|
+
return new Promise((t) => {
|
|
1736
1904
|
try {
|
|
1737
|
-
const
|
|
1738
|
-
|
|
1739
|
-
const o = {
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1905
|
+
const s = URL.createObjectURL(e), n = new Image();
|
|
1906
|
+
n.onload = () => {
|
|
1907
|
+
const o = {
|
|
1908
|
+
width: n.naturalWidth || n.width,
|
|
1909
|
+
height: n.naturalHeight || n.height
|
|
1910
|
+
};
|
|
1911
|
+
URL.revokeObjectURL(s), t(o);
|
|
1912
|
+
}, n.onerror = () => {
|
|
1913
|
+
URL.revokeObjectURL(s), t({ width: 0, height: 0 });
|
|
1914
|
+
}, n.src = s;
|
|
1744
1915
|
} catch {
|
|
1745
|
-
|
|
1916
|
+
t({ width: 0, height: 0 });
|
|
1746
1917
|
}
|
|
1747
1918
|
});
|
|
1748
1919
|
}
|
|
1749
1920
|
getMediaDuration(e) {
|
|
1750
|
-
return new Promise((
|
|
1921
|
+
return new Promise((t) => {
|
|
1751
1922
|
try {
|
|
1752
|
-
const
|
|
1923
|
+
const s = URL.createObjectURL(e), n = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
|
|
1753
1924
|
let o = !1;
|
|
1754
|
-
const
|
|
1755
|
-
o || (o = !0, URL.revokeObjectURL(
|
|
1925
|
+
const a = setTimeout(() => {
|
|
1926
|
+
o || (o = !0, URL.revokeObjectURL(s), t(0));
|
|
1756
1927
|
}, 5e3);
|
|
1757
|
-
|
|
1928
|
+
n.preload = "metadata", n.onloadedmetadata = () => {
|
|
1758
1929
|
if (o) return;
|
|
1759
|
-
o = !0, clearTimeout(
|
|
1760
|
-
const c =
|
|
1761
|
-
URL.revokeObjectURL(
|
|
1762
|
-
},
|
|
1763
|
-
o || (o = !0, clearTimeout(
|
|
1764
|
-
},
|
|
1930
|
+
o = !0, clearTimeout(a);
|
|
1931
|
+
const c = n.duration || 0;
|
|
1932
|
+
URL.revokeObjectURL(s), t(c);
|
|
1933
|
+
}, n.onerror = () => {
|
|
1934
|
+
o || (o = !0, clearTimeout(a), URL.revokeObjectURL(s), t(0));
|
|
1935
|
+
}, n.src = s;
|
|
1765
1936
|
} catch {
|
|
1766
|
-
|
|
1937
|
+
t(0);
|
|
1767
1938
|
}
|
|
1768
1939
|
});
|
|
1769
1940
|
}
|
|
1770
1941
|
injectOverlayStyles() {
|
|
1771
1942
|
if (document.getElementById("foisit-overlay-styles")) return;
|
|
1772
1943
|
const e = document.createElement("style");
|
|
1773
|
-
e.id = "foisit-overlay-styles"
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1944
|
+
e.id = "foisit-overlay-styles";
|
|
1945
|
+
const t = this.config.theme || "glass", s = this.config.themeColors || {};
|
|
1946
|
+
if (t === "solid") {
|
|
1947
|
+
const n = s.background || "#1a1a2e", o = s.text || "#ffffff", a = s.accent || "linear-gradient(135deg, #667eea 0%, #764ba2 100%)", r = s.userBubbleBg || "rgba(102, 126, 234, 0.2)", c = s.systemBubbleBg || "rgba(255, 255, 255, 0.08)", h = s.border || "rgba(255, 255, 255, 0.1)";
|
|
1948
|
+
e.textContent = `
|
|
1949
|
+
:root {
|
|
1950
|
+
/* SOLID THEME - Custom Colors */
|
|
1951
|
+
--foisit-bg: ${n};
|
|
1952
|
+
--foisit-border: 1px solid ${h};
|
|
1953
|
+
--foisit-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
|
|
1954
|
+
--foisit-text: ${o};
|
|
1955
|
+
--foisit-accent: ${a};
|
|
1956
|
+
--foisit-backdrop: none;
|
|
1785
1957
|
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1958
|
+
/* Input */
|
|
1959
|
+
--foisit-input-color: ${o};
|
|
1960
|
+
--foisit-input-placeholder: ${o}99;
|
|
1789
1961
|
|
|
1790
|
-
|
|
1791
|
-
|
|
1962
|
+
/* Bubbles */
|
|
1963
|
+
--foisit-bubble-user-bg: ${r};
|
|
1964
|
+
--foisit-bubble-user-text: ${o};
|
|
1792
1965
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
--foisit-error-text: #dc2626;
|
|
1796
|
-
--foisit-error-border: #fca5a5;
|
|
1797
|
-
}
|
|
1966
|
+
--foisit-bubble-sys-bg: ${c};
|
|
1967
|
+
--foisit-bubble-sys-text: ${o}ee;
|
|
1798
1968
|
|
|
1799
|
-
|
|
1969
|
+
/* Form Colors */
|
|
1970
|
+
--foisit-req-star: #f87171;
|
|
1971
|
+
--foisit-error-text: #fca5a5;
|
|
1972
|
+
--foisit-error-border: #f87171;
|
|
1973
|
+
}
|
|
1974
|
+
`;
|
|
1975
|
+
} else
|
|
1976
|
+
e.textContent = `
|
|
1800
1977
|
:root {
|
|
1801
|
-
/*
|
|
1802
|
-
|
|
1803
|
-
--foisit-
|
|
1804
|
-
--foisit-
|
|
1805
|
-
--foisit-
|
|
1978
|
+
/* LIGHT MODE (Default) - Smoother gradient */
|
|
1979
|
+
/* Changed: Softer, right-focused radial highlight to avoid a heavy white bottom */
|
|
1980
|
+
--foisit-bg: radial-gradient(ellipse at 75% 30%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
|
|
1981
|
+
--foisit-border: 1px solid rgba(255, 255, 255, 0.25);
|
|
1982
|
+
--foisit-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
|
|
1983
|
+
--foisit-text: #333;
|
|
1984
|
+
--foisit-backdrop: blur(20px);
|
|
1806
1985
|
|
|
1807
1986
|
/* Input */
|
|
1808
|
-
--foisit-input-color:
|
|
1809
|
-
--foisit-input-placeholder: rgba(
|
|
1987
|
+
--foisit-input-color: #333;
|
|
1988
|
+
--foisit-input-placeholder: rgba(60, 60, 67, 0.6);
|
|
1810
1989
|
|
|
1811
1990
|
/* Bubbles */
|
|
1812
|
-
--foisit-bubble-user-bg: rgba(
|
|
1813
|
-
--foisit-bubble-user-text:
|
|
1991
|
+
--foisit-bubble-user-bg: rgba(0, 0, 0, 0.04);
|
|
1992
|
+
--foisit-bubble-user-text: #333;
|
|
1814
1993
|
|
|
1815
|
-
--foisit-bubble-sys-bg: rgba(255, 255, 255, 0.
|
|
1816
|
-
--foisit-bubble-sys-text:
|
|
1994
|
+
--foisit-bubble-sys-bg: rgba(255, 255, 255, 0.45);
|
|
1995
|
+
--foisit-bubble-sys-text: #333;
|
|
1817
1996
|
|
|
1818
1997
|
/* Form Colors */
|
|
1819
|
-
--foisit-req-star: #
|
|
1820
|
-
--foisit-error-text: #
|
|
1821
|
-
--foisit-error-border: #
|
|
1998
|
+
--foisit-req-star: #ef4444; /* Red asterisk */
|
|
1999
|
+
--foisit-error-text: #dc2626;
|
|
2000
|
+
--foisit-error-border: #fca5a5;
|
|
1822
2001
|
}
|
|
1823
|
-
|
|
2002
|
+
|
|
2003
|
+
@media (prefers-color-scheme: dark) {
|
|
2004
|
+
:root {
|
|
2005
|
+
/* DARK MODE */
|
|
2006
|
+
--foisit-bg: linear-gradient(135deg, rgba(40, 40, 40, 0.65), rgba(40, 40, 40, 0.25));
|
|
2007
|
+
--foisit-border: 1px solid rgba(255, 255, 255, 0.1);
|
|
2008
|
+
--foisit-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
|
|
2009
|
+
--foisit-text: #fff;
|
|
2010
|
+
--foisit-backdrop: blur(20px);
|
|
2011
|
+
|
|
2012
|
+
/* Input */
|
|
2013
|
+
--foisit-input-color: white;
|
|
2014
|
+
--foisit-input-placeholder: rgba(235, 235, 245, 0.5);
|
|
2015
|
+
|
|
2016
|
+
/* Bubbles */
|
|
2017
|
+
--foisit-bubble-user-bg: rgba(255, 255, 255, 0.1);
|
|
2018
|
+
--foisit-bubble-user-text: white;
|
|
2019
|
+
|
|
2020
|
+
--foisit-bubble-sys-bg: rgba(255, 255, 255, 0.05);
|
|
2021
|
+
--foisit-bubble-sys-text: rgba(255, 255, 255, 0.9);
|
|
2022
|
+
|
|
2023
|
+
/* Form Colors */
|
|
2024
|
+
--foisit-req-star: #f87171;
|
|
2025
|
+
--foisit-error-text: #fca5a5;
|
|
2026
|
+
--foisit-error-border: #f87171;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
`;
|
|
2030
|
+
e.textContent += `
|
|
1824
2031
|
|
|
1825
2032
|
@keyframes foisitPulse {
|
|
1826
2033
|
0%, 100% { transform: scale(0.8); opacity: 0.5; }
|
|
@@ -1868,8 +2075,8 @@ class Bt {
|
|
|
1868
2075
|
border: var(--foisit-border);
|
|
1869
2076
|
box-shadow: var(--foisit-shadow);
|
|
1870
2077
|
|
|
1871
|
-
backdrop-filter:
|
|
1872
|
-
-webkit-backdrop-filter:
|
|
2078
|
+
backdrop-filter: var(--foisit-backdrop);
|
|
2079
|
+
-webkit-backdrop-filter: var(--foisit-backdrop);
|
|
1873
2080
|
|
|
1874
2081
|
border-radius: 18px;
|
|
1875
2082
|
display: none;
|
|
@@ -2078,8 +2285,8 @@ class Bt {
|
|
|
2078
2285
|
border: 1px solid rgba(255,255,255,0.2);
|
|
2079
2286
|
background: var(--foisit-bg);
|
|
2080
2287
|
color: var(--foisit-text);
|
|
2081
|
-
backdrop-filter:
|
|
2082
|
-
-webkit-backdrop-filter:
|
|
2288
|
+
backdrop-filter: var(--foisit-backdrop);
|
|
2289
|
+
-webkit-backdrop-filter: var(--foisit-backdrop);
|
|
2083
2290
|
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
2084
2291
|
cursor: pointer;
|
|
2085
2292
|
pointer-events: auto;
|
|
@@ -2091,37 +2298,129 @@ class Bt {
|
|
|
2091
2298
|
transition: transform 0.2s;
|
|
2092
2299
|
}
|
|
2093
2300
|
.foisit-floating-btn:hover { transform: scale(1.05); }
|
|
2301
|
+
|
|
2302
|
+
/* Markdown Styles */
|
|
2303
|
+
.foisit-bubble.system .foisit-md-p { margin: 0 0 0.5em 0; }
|
|
2304
|
+
.foisit-bubble.system .foisit-md-p:last-child { margin-bottom: 0; }
|
|
2305
|
+
|
|
2306
|
+
.foisit-bubble.system .foisit-md-h1,
|
|
2307
|
+
.foisit-bubble.system .foisit-md-h2,
|
|
2308
|
+
.foisit-bubble.system .foisit-md-h3,
|
|
2309
|
+
.foisit-bubble.system .foisit-md-h4,
|
|
2310
|
+
.foisit-bubble.system .foisit-md-h5,
|
|
2311
|
+
.foisit-bubble.system .foisit-md-h6 {
|
|
2312
|
+
margin: 0.8em 0 0.4em 0;
|
|
2313
|
+
font-weight: 600;
|
|
2314
|
+
line-height: 1.3;
|
|
2315
|
+
}
|
|
2316
|
+
.foisit-bubble.system .foisit-md-h1:first-child,
|
|
2317
|
+
.foisit-bubble.system .foisit-md-h2:first-child,
|
|
2318
|
+
.foisit-bubble.system .foisit-md-h3:first-child { margin-top: 0; }
|
|
2319
|
+
|
|
2320
|
+
.foisit-bubble.system .foisit-md-h1 { font-size: 1.4em; }
|
|
2321
|
+
.foisit-bubble.system .foisit-md-h2 { font-size: 1.25em; }
|
|
2322
|
+
.foisit-bubble.system .foisit-md-h3 { font-size: 1.1em; }
|
|
2323
|
+
.foisit-bubble.system .foisit-md-h4 { font-size: 1em; }
|
|
2324
|
+
.foisit-bubble.system .foisit-md-h5 { font-size: 0.95em; }
|
|
2325
|
+
.foisit-bubble.system .foisit-md-h6 { font-size: 0.9em; opacity: 0.85; }
|
|
2326
|
+
|
|
2327
|
+
.foisit-bubble.system .foisit-md-ul,
|
|
2328
|
+
.foisit-bubble.system .foisit-md-ol {
|
|
2329
|
+
margin: 0.5em 0;
|
|
2330
|
+
padding-left: 1.5em;
|
|
2331
|
+
}
|
|
2332
|
+
.foisit-bubble.system .foisit-md-li { margin: 0.25em 0; }
|
|
2333
|
+
|
|
2334
|
+
.foisit-bubble.system .foisit-code-block {
|
|
2335
|
+
background: rgba(0,0,0,0.15);
|
|
2336
|
+
border-radius: 6px;
|
|
2337
|
+
padding: 10px 12px;
|
|
2338
|
+
margin: 0.5em 0;
|
|
2339
|
+
overflow-x: auto;
|
|
2340
|
+
font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
2341
|
+
font-size: 0.85em;
|
|
2342
|
+
line-height: 1.4;
|
|
2343
|
+
}
|
|
2344
|
+
.foisit-bubble.system .foisit-code-block code {
|
|
2345
|
+
background: transparent;
|
|
2346
|
+
padding: 0;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
.foisit-bubble.system .foisit-inline-code {
|
|
2350
|
+
background: rgba(0,0,0,0.1);
|
|
2351
|
+
padding: 2px 6px;
|
|
2352
|
+
border-radius: 4px;
|
|
2353
|
+
font-family: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
|
2354
|
+
font-size: 0.9em;
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
.foisit-bubble.system .foisit-md-blockquote {
|
|
2358
|
+
border-left: 3px solid rgba(127,127,127,0.4);
|
|
2359
|
+
margin: 0.5em 0;
|
|
2360
|
+
padding-left: 12px;
|
|
2361
|
+
opacity: 0.9;
|
|
2362
|
+
font-style: italic;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
.foisit-bubble.system .foisit-md-link {
|
|
2366
|
+
color: inherit;
|
|
2367
|
+
text-decoration: underline;
|
|
2368
|
+
opacity: 0.9;
|
|
2369
|
+
}
|
|
2370
|
+
.foisit-bubble.system .foisit-md-link:hover { opacity: 1; }
|
|
2371
|
+
|
|
2372
|
+
.foisit-bubble.system .foisit-md-hr {
|
|
2373
|
+
border: none;
|
|
2374
|
+
border-top: 1px solid rgba(127,127,127,0.3);
|
|
2375
|
+
margin: 0.8em 0;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
.foisit-bubble.system strong { font-weight: 600; }
|
|
2379
|
+
.foisit-bubble.system em { font-style: italic; }
|
|
2380
|
+
.foisit-bubble.system del { text-decoration: line-through; opacity: 0.7; }
|
|
2381
|
+
|
|
2382
|
+
@media (prefers-color-scheme: dark) {
|
|
2383
|
+
.foisit-bubble.system .foisit-code-block { background: rgba(255,255,255,0.08); }
|
|
2384
|
+
.foisit-bubble.system .foisit-inline-code { background: rgba(255,255,255,0.1); }
|
|
2385
|
+
}
|
|
2094
2386
|
`, document.head.appendChild(e);
|
|
2095
2387
|
}
|
|
2096
2388
|
}
|
|
2097
2389
|
class Ut {
|
|
2098
2390
|
constructor(e) {
|
|
2099
|
-
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new
|
|
2391
|
+
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new $t({
|
|
2100
2392
|
enableSmartIntent: this.config.enableSmartIntent !== !1,
|
|
2101
2393
|
intentEndpoint: this.config.intentEndpoint
|
|
2102
|
-
}), this.fallbackHandler = new
|
|
2394
|
+
}), this.fallbackHandler = new Ft(), this.voiceProcessor = new Ht(), this.textToSpeech = new qe(), this.stateManager = new zt(), this.gestureHandler = new ae(), this.overlayManager = new Bt({
|
|
2103
2395
|
floatingButton: this.config.floatingButton,
|
|
2104
|
-
inputPlaceholder: this.config.inputPlaceholder
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2396
|
+
inputPlaceholder: this.config.inputPlaceholder,
|
|
2397
|
+
enableGestureActivation: this.config.enableGestureActivation,
|
|
2398
|
+
theme: this.config.theme,
|
|
2399
|
+
themeColors: this.config.themeColors
|
|
2400
|
+
}), this.overlayManager.setExternalCommandExecutor(async (t) => this.commandHandler.executeCommand(t)), this.config.commands.forEach((t) => this.commandHandler.addCommand(t)), this.config.fallbackResponse && this.fallbackHandler.setFallbackMessage(this.config.fallbackResponse), this.overlayManager.registerCallbacks(
|
|
2401
|
+
async (t) => {
|
|
2402
|
+
if (typeof t == "string")
|
|
2403
|
+
this.overlayManager.addMessage(t, "user");
|
|
2404
|
+
else if (t && typeof t == "object") {
|
|
2405
|
+
const s = this.extractUserLabel(t);
|
|
2406
|
+
s && this.overlayManager.addMessage(s, "user");
|
|
2112
2407
|
}
|
|
2113
|
-
await this.handleCommand(
|
|
2408
|
+
await this.handleCommand(t);
|
|
2114
2409
|
},
|
|
2115
2410
|
() => console.log("AssistantService: Overlay closed.")
|
|
2116
2411
|
);
|
|
2117
2412
|
}
|
|
2118
2413
|
/** Start listening for activation and commands */
|
|
2119
2414
|
startListening() {
|
|
2120
|
-
console.log(
|
|
2415
|
+
console.log(
|
|
2416
|
+
"AssistantService: Voice is disabled; startListening() is a no-op."
|
|
2417
|
+
);
|
|
2121
2418
|
}
|
|
2122
2419
|
/** Stop listening */
|
|
2123
2420
|
stopListening() {
|
|
2124
|
-
console.log(
|
|
2421
|
+
console.log(
|
|
2422
|
+
"AssistantService: Voice is disabled; stopListening() is a no-op."
|
|
2423
|
+
), this.isActivated = !1;
|
|
2125
2424
|
}
|
|
2126
2425
|
/** Reset activation state so the next activation flow can occur. */
|
|
2127
2426
|
reactivate() {
|
|
@@ -2133,48 +2432,51 @@ class Ut {
|
|
|
2133
2432
|
}
|
|
2134
2433
|
/** Process activation command */
|
|
2135
2434
|
async processActivation(e) {
|
|
2136
|
-
var
|
|
2137
|
-
const
|
|
2138
|
-
|
|
2435
|
+
var s;
|
|
2436
|
+
const t = (s = this.config.activationCommand) == null ? void 0 : s.toLowerCase();
|
|
2437
|
+
t && (e === t ? (console.log("AssistantService: Activation matched."), this.isActivated = !0, this.textToSpeech.speak(
|
|
2139
2438
|
this.config.introMessage || this.defaultIntroMessage
|
|
2140
2439
|
)) : console.log("AssistantService: Activation command not recognized."));
|
|
2141
2440
|
}
|
|
2142
2441
|
/** Handle recognized commands */
|
|
2143
2442
|
async handleCommand(e) {
|
|
2144
2443
|
this.overlayManager.showLoading();
|
|
2145
|
-
let
|
|
2444
|
+
let t;
|
|
2146
2445
|
try {
|
|
2147
|
-
|
|
2446
|
+
t = await this.commandHandler.executeCommand(e);
|
|
2148
2447
|
} finally {
|
|
2149
2448
|
this.overlayManager.hideLoading();
|
|
2150
2449
|
}
|
|
2151
|
-
if (
|
|
2450
|
+
if (t.type === "form" && t.fields) {
|
|
2152
2451
|
this.overlayManager.addForm(
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
async (
|
|
2452
|
+
t.message,
|
|
2453
|
+
t.fields,
|
|
2454
|
+
async (s) => {
|
|
2156
2455
|
this.overlayManager.showLoading();
|
|
2157
|
-
let
|
|
2456
|
+
let n;
|
|
2158
2457
|
try {
|
|
2159
|
-
|
|
2458
|
+
n = await this.commandHandler.executeCommand(s);
|
|
2160
2459
|
} finally {
|
|
2161
2460
|
this.overlayManager.hideLoading();
|
|
2162
2461
|
}
|
|
2163
|
-
this.processResponse(
|
|
2462
|
+
this.processResponse(n);
|
|
2164
2463
|
}
|
|
2165
2464
|
);
|
|
2166
2465
|
return;
|
|
2167
2466
|
}
|
|
2168
|
-
if (
|
|
2169
|
-
const
|
|
2170
|
-
|
|
2467
|
+
if (t.type === "error") {
|
|
2468
|
+
const s = typeof e == "string" ? e : "";
|
|
2469
|
+
s ? (this.fallbackHandler.handleFallback(s), this.overlayManager.addMessage(
|
|
2470
|
+
this.fallbackHandler.getFallbackMessage(),
|
|
2471
|
+
"system"
|
|
2472
|
+
)) : t.message && this.overlayManager.addMessage(t.message, "system");
|
|
2171
2473
|
return;
|
|
2172
2474
|
}
|
|
2173
|
-
if ((
|
|
2174
|
-
|
|
2475
|
+
if ((t.type === "ambiguous" || t.type === "confirm") && t.options) {
|
|
2476
|
+
t.message && this.overlayManager.addMessage(t.message, "system"), this.overlayManager.addOptions(t.options);
|
|
2175
2477
|
return;
|
|
2176
2478
|
}
|
|
2177
|
-
|
|
2479
|
+
t.message && this.overlayManager.addMessage(t.message, "system");
|
|
2178
2480
|
}
|
|
2179
2481
|
/**
|
|
2180
2482
|
* Cleanup resources
|
|
@@ -2188,15 +2490,15 @@ class Ut {
|
|
|
2188
2490
|
this.overlayManager.addForm(
|
|
2189
2491
|
e.message,
|
|
2190
2492
|
e.fields,
|
|
2191
|
-
async (
|
|
2493
|
+
async (t) => {
|
|
2192
2494
|
this.overlayManager.showLoading();
|
|
2193
|
-
let
|
|
2495
|
+
let s;
|
|
2194
2496
|
try {
|
|
2195
|
-
|
|
2497
|
+
s = await this.commandHandler.executeCommand(t);
|
|
2196
2498
|
} finally {
|
|
2197
2499
|
this.overlayManager.hideLoading();
|
|
2198
2500
|
}
|
|
2199
|
-
this.processResponse(
|
|
2501
|
+
this.processResponse(s);
|
|
2200
2502
|
}
|
|
2201
2503
|
);
|
|
2202
2504
|
return;
|
|
@@ -2207,9 +2509,22 @@ class Ut {
|
|
|
2207
2509
|
}
|
|
2208
2510
|
e.message && this.overlayManager.addMessage(e.message, "system");
|
|
2209
2511
|
}
|
|
2512
|
+
/** Expose programmatic command handler registration to host apps */
|
|
2513
|
+
registerCommandHandler(e, t) {
|
|
2514
|
+
this.overlayManager && this.overlayManager.registerCommandHandler(e, t);
|
|
2515
|
+
}
|
|
2516
|
+
unregisterCommandHandler(e) {
|
|
2517
|
+
this.overlayManager && this.overlayManager.unregisterCommandHandler(e);
|
|
2518
|
+
}
|
|
2519
|
+
/** Programmatically run a registered command (proxies to OverlayManager) */
|
|
2520
|
+
async runCommand(e) {
|
|
2521
|
+
if (!this.overlayManager) throw new Error("Overlay manager not available.");
|
|
2522
|
+
const t = await this.overlayManager.runCommand(e);
|
|
2523
|
+
return t && typeof t == "object" && "type" in t && this.processResponse(t), t;
|
|
2524
|
+
}
|
|
2210
2525
|
/** Add a command dynamically (supports string or rich object) */
|
|
2211
|
-
addCommand(e,
|
|
2212
|
-
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e,
|
|
2526
|
+
addCommand(e, t) {
|
|
2527
|
+
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e, t);
|
|
2213
2528
|
}
|
|
2214
2529
|
/** Remove a command dynamically */
|
|
2215
2530
|
removeCommand(e) {
|
|
@@ -2220,30 +2535,30 @@ class Ut {
|
|
|
2220
2535
|
return this.commandHandler.getCommands();
|
|
2221
2536
|
}
|
|
2222
2537
|
/** Toggle the assistant overlay */
|
|
2223
|
-
toggle(e,
|
|
2538
|
+
toggle(e, t) {
|
|
2224
2539
|
console.log("AssistantService: Toggling overlay..."), this.overlayManager.toggle(
|
|
2225
|
-
async (
|
|
2226
|
-
if (typeof
|
|
2227
|
-
this.overlayManager.addMessage(
|
|
2228
|
-
else if (
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2540
|
+
async (s) => {
|
|
2541
|
+
if (typeof s == "string")
|
|
2542
|
+
this.overlayManager.addMessage(s, "user");
|
|
2543
|
+
else if (s && typeof s == "object") {
|
|
2544
|
+
const n = this.extractUserLabel(s);
|
|
2545
|
+
n && this.overlayManager.addMessage(n, "user");
|
|
2231
2546
|
}
|
|
2232
|
-
e && e(
|
|
2547
|
+
e && e(s), await this.handleCommand(s);
|
|
2233
2548
|
},
|
|
2234
2549
|
() => {
|
|
2235
|
-
console.log("AssistantService: Overlay closed."),
|
|
2550
|
+
console.log("AssistantService: Overlay closed."), t && t();
|
|
2236
2551
|
}
|
|
2237
2552
|
);
|
|
2238
2553
|
}
|
|
2239
2554
|
extractUserLabel(e) {
|
|
2240
|
-
const
|
|
2241
|
-
if (typeof
|
|
2242
|
-
const
|
|
2243
|
-
return typeof
|
|
2555
|
+
const t = e.label;
|
|
2556
|
+
if (typeof t == "string" && t.trim()) return t.trim();
|
|
2557
|
+
const s = e.commandId;
|
|
2558
|
+
return typeof s == "string" && s.trim() ? s.trim() : null;
|
|
2244
2559
|
}
|
|
2245
2560
|
}
|
|
2246
|
-
const Wt = /* @__PURE__ */
|
|
2561
|
+
const Wt = /* @__PURE__ */ ht({
|
|
2247
2562
|
name: "AssistantProvider",
|
|
2248
2563
|
props: {
|
|
2249
2564
|
config: {
|
|
@@ -2251,30 +2566,30 @@ const Wt = /* @__PURE__ */ mt({
|
|
|
2251
2566
|
required: !0
|
|
2252
2567
|
}
|
|
2253
2568
|
},
|
|
2254
|
-
setup(
|
|
2255
|
-
const
|
|
2256
|
-
return
|
|
2257
|
-
var
|
|
2258
|
-
return (
|
|
2569
|
+
setup(i, { slots: e }) {
|
|
2570
|
+
const t = new Ut(i.config);
|
|
2571
|
+
return ut("assistantService", t), () => {
|
|
2572
|
+
var s;
|
|
2573
|
+
return (s = e.default) == null ? void 0 : s.call(e);
|
|
2259
2574
|
};
|
|
2260
2575
|
}
|
|
2261
|
-
}), jt = (
|
|
2262
|
-
const
|
|
2263
|
-
for (const [
|
|
2264
|
-
|
|
2265
|
-
return
|
|
2576
|
+
}), jt = (i, e) => {
|
|
2577
|
+
const t = i.__vccOpts || i;
|
|
2578
|
+
for (const [s, n] of e)
|
|
2579
|
+
t[s] = n;
|
|
2580
|
+
return t;
|
|
2266
2581
|
};
|
|
2267
|
-
function
|
|
2268
|
-
return
|
|
2582
|
+
function Yt(i, e, t, s, n, o) {
|
|
2583
|
+
return bt(i.$slots, "default");
|
|
2269
2584
|
}
|
|
2270
|
-
const
|
|
2271
|
-
const
|
|
2272
|
-
if (!
|
|
2585
|
+
const Gt = /* @__PURE__ */ jt(Wt, [["render", Yt]]), Kt = () => {
|
|
2586
|
+
const i = ft("assistantService");
|
|
2587
|
+
if (!i)
|
|
2273
2588
|
throw new Error("useAssistant must be used within an AssistantProvider");
|
|
2274
|
-
return
|
|
2589
|
+
return i;
|
|
2275
2590
|
};
|
|
2276
2591
|
export {
|
|
2277
|
-
|
|
2592
|
+
Gt as AssistantProvider,
|
|
2278
2593
|
Ut as AssistantService,
|
|
2279
|
-
|
|
2594
|
+
Kt as useAssistant
|
|
2280
2595
|
};
|