@foisit/vue-wrapper 2.0.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -45
- package/index.d.ts +3 -0
- package/index.mjs +2276 -0
- package/lib/components/AssistantProvider.vue.d.ts +16 -0
- package/lib/composables/useAssistant.d.ts +3 -0
- package/lib/services/AssistantService.d.ts +42 -0
- package/package.json +6 -2
package/index.mjs
ADDED
|
@@ -0,0 +1,2276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vue/shared v3.5.26
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
const ie = process.env.NODE_ENV !== "production" ? Object.freeze({}) : {}, qe = process.env.NODE_ENV !== "production" ? Object.freeze([]) : [], ve = () => {
|
|
7
|
+
}, ze = (t) => t.charCodeAt(0) === 111 && t.charCodeAt(1) === 110 && // uppercase letter
|
|
8
|
+
(t.charCodeAt(2) > 122 || t.charCodeAt(2) < 97), z = Object.assign, k = Array.isArray, R = (t) => typeof t == "function", T = (t) => typeof t == "string", we = (t) => typeof t == "symbol", O = (t) => t !== null && typeof t == "object";
|
|
9
|
+
let me;
|
|
10
|
+
const Q = () => me || (me = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
|
|
11
|
+
function ae(t) {
|
|
12
|
+
if (k(t)) {
|
|
13
|
+
const e = {};
|
|
14
|
+
for (let n = 0; n < t.length; n++) {
|
|
15
|
+
const i = t[n], s = T(i) ? je(i) : ae(i);
|
|
16
|
+
if (s)
|
|
17
|
+
for (const o in s)
|
|
18
|
+
e[o] = s[o];
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
} else if (T(t) || O(t))
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
const Ue = /;(?![^(]*\))/g, Be = /:([^]+)/, We = /\/\*[^]*?\*\//g;
|
|
25
|
+
function je(t) {
|
|
26
|
+
const e = {};
|
|
27
|
+
return t.replace(We, "").split(Ue).forEach((n) => {
|
|
28
|
+
if (n) {
|
|
29
|
+
const i = n.split(Be);
|
|
30
|
+
i.length > 1 && (e[i[0].trim()] = i[1].trim());
|
|
31
|
+
}
|
|
32
|
+
}), e;
|
|
33
|
+
}
|
|
34
|
+
function le(t) {
|
|
35
|
+
let e = "";
|
|
36
|
+
if (T(t))
|
|
37
|
+
e = t;
|
|
38
|
+
else if (k(t))
|
|
39
|
+
for (let n = 0; n < t.length; n++) {
|
|
40
|
+
const i = le(t[n]);
|
|
41
|
+
i && (e += i + " ");
|
|
42
|
+
}
|
|
43
|
+
else if (O(t))
|
|
44
|
+
for (const n in t)
|
|
45
|
+
t[n] && (e += n + " ");
|
|
46
|
+
return e.trim();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @vue/reactivity v3.5.26
|
|
50
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
51
|
+
* @license MIT
|
|
52
|
+
**/
|
|
53
|
+
process.env.NODE_ENV;
|
|
54
|
+
process.env.NODE_ENV;
|
|
55
|
+
process.env.NODE_ENV;
|
|
56
|
+
new Set(
|
|
57
|
+
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((t) => t !== "arguments" && t !== "caller").map((t) => Symbol[t]).filter(we)
|
|
58
|
+
);
|
|
59
|
+
function xe(t) {
|
|
60
|
+
return se(t) ? xe(t.__v_raw) : !!(t && t.__v_isReactive);
|
|
61
|
+
}
|
|
62
|
+
function se(t) {
|
|
63
|
+
return !!(t && t.__v_isReadonly);
|
|
64
|
+
}
|
|
65
|
+
function Z(t) {
|
|
66
|
+
return !!(t && t.__v_isShallow);
|
|
67
|
+
}
|
|
68
|
+
function oe(t) {
|
|
69
|
+
return t ? !!t.__v_raw : !1;
|
|
70
|
+
}
|
|
71
|
+
function M(t) {
|
|
72
|
+
const e = t && t.__v_raw;
|
|
73
|
+
return e ? M(e) : t;
|
|
74
|
+
}
|
|
75
|
+
function ce(t) {
|
|
76
|
+
return t ? t.__v_isRef === !0 : !1;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @vue/runtime-core v3.5.26
|
|
80
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
81
|
+
* @license MIT
|
|
82
|
+
**/
|
|
83
|
+
const P = [];
|
|
84
|
+
function Ke(t) {
|
|
85
|
+
P.push(t);
|
|
86
|
+
}
|
|
87
|
+
function Ye() {
|
|
88
|
+
P.pop();
|
|
89
|
+
}
|
|
90
|
+
let ee = !1;
|
|
91
|
+
function _(t, ...e) {
|
|
92
|
+
if (ee) return;
|
|
93
|
+
ee = !0;
|
|
94
|
+
const n = P.length ? P[P.length - 1].component : null, i = n && n.appContext.config.warnHandler, s = Je();
|
|
95
|
+
if (i)
|
|
96
|
+
de(
|
|
97
|
+
i,
|
|
98
|
+
n,
|
|
99
|
+
11,
|
|
100
|
+
[
|
|
101
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
102
|
+
t + e.map((o) => {
|
|
103
|
+
var r, a;
|
|
104
|
+
return (a = (r = o.toString) == null ? void 0 : r.call(o)) != null ? a : JSON.stringify(o);
|
|
105
|
+
}).join(""),
|
|
106
|
+
n && n.proxy,
|
|
107
|
+
s.map(
|
|
108
|
+
({ vnode: o }) => `at <${De(n, o.type)}>`
|
|
109
|
+
).join(`
|
|
110
|
+
`),
|
|
111
|
+
s
|
|
112
|
+
]
|
|
113
|
+
);
|
|
114
|
+
else {
|
|
115
|
+
const o = [`[Vue warn]: ${t}`, ...e];
|
|
116
|
+
s.length && o.push(`
|
|
117
|
+
`, ...Ge(s)), console.warn(...o);
|
|
118
|
+
}
|
|
119
|
+
ee = !1;
|
|
120
|
+
}
|
|
121
|
+
function Je() {
|
|
122
|
+
let t = P[P.length - 1];
|
|
123
|
+
if (!t)
|
|
124
|
+
return [];
|
|
125
|
+
const e = [];
|
|
126
|
+
for (; t; ) {
|
|
127
|
+
const n = e[0];
|
|
128
|
+
n && n.vnode === t ? n.recurseCount++ : e.push({
|
|
129
|
+
vnode: t,
|
|
130
|
+
recurseCount: 0
|
|
131
|
+
});
|
|
132
|
+
const i = t.component && t.component.parent;
|
|
133
|
+
t = i && i.vnode;
|
|
134
|
+
}
|
|
135
|
+
return e;
|
|
136
|
+
}
|
|
137
|
+
function Ge(t) {
|
|
138
|
+
const e = [];
|
|
139
|
+
return t.forEach((n, i) => {
|
|
140
|
+
e.push(...i === 0 ? [] : [`
|
|
141
|
+
`], ...Xe(n));
|
|
142
|
+
}), e;
|
|
143
|
+
}
|
|
144
|
+
function Xe({ vnode: t, recurseCount: e }) {
|
|
145
|
+
const n = e > 0 ? `... (${e} recursive calls)` : "", i = t.component ? t.component.parent == null : !1, s = ` at <${De(
|
|
146
|
+
t.component,
|
|
147
|
+
t.type,
|
|
148
|
+
i
|
|
149
|
+
)}`, o = ">" + n;
|
|
150
|
+
return t.props ? [s, ...Qe(t.props), o] : [s + o];
|
|
151
|
+
}
|
|
152
|
+
function Qe(t) {
|
|
153
|
+
const e = [], n = Object.keys(t);
|
|
154
|
+
return n.slice(0, 3).forEach((i) => {
|
|
155
|
+
e.push(...Se(i, t[i]));
|
|
156
|
+
}), n.length > 3 && e.push(" ..."), e;
|
|
157
|
+
}
|
|
158
|
+
function Se(t, e, n) {
|
|
159
|
+
return T(e) ? (e = JSON.stringify(e), n ? e : [`${t}=${e}`]) : typeof e == "number" || typeof e == "boolean" || e == null ? n ? e : [`${t}=${e}`] : ce(e) ? (e = Se(t, M(e.value), !0), n ? e : [`${t}=Ref<`, e, ">"]) : R(e) ? [`${t}=fn${e.name ? `<${e.name}>` : ""}`] : (e = M(e), n ? e : [`${t}=`, e]);
|
|
160
|
+
}
|
|
161
|
+
const Ce = {
|
|
162
|
+
sp: "serverPrefetch hook",
|
|
163
|
+
bc: "beforeCreate hook",
|
|
164
|
+
c: "created hook",
|
|
165
|
+
bm: "beforeMount hook",
|
|
166
|
+
m: "mounted hook",
|
|
167
|
+
bu: "beforeUpdate hook",
|
|
168
|
+
u: "updated",
|
|
169
|
+
bum: "beforeUnmount hook",
|
|
170
|
+
um: "unmounted hook",
|
|
171
|
+
a: "activated hook",
|
|
172
|
+
da: "deactivated hook",
|
|
173
|
+
ec: "errorCaptured hook",
|
|
174
|
+
rtc: "renderTracked hook",
|
|
175
|
+
rtg: "renderTriggered hook",
|
|
176
|
+
0: "setup function",
|
|
177
|
+
1: "render function",
|
|
178
|
+
2: "watcher getter",
|
|
179
|
+
3: "watcher callback",
|
|
180
|
+
4: "watcher cleanup function",
|
|
181
|
+
5: "native event handler",
|
|
182
|
+
6: "component event handler",
|
|
183
|
+
7: "vnode hook",
|
|
184
|
+
8: "directive hook",
|
|
185
|
+
9: "transition hook",
|
|
186
|
+
10: "app errorHandler",
|
|
187
|
+
11: "app warnHandler",
|
|
188
|
+
12: "ref function",
|
|
189
|
+
13: "async component loader",
|
|
190
|
+
14: "scheduler flush",
|
|
191
|
+
15: "component update",
|
|
192
|
+
16: "app unmount cleanup function"
|
|
193
|
+
};
|
|
194
|
+
function de(t, e, n, i) {
|
|
195
|
+
try {
|
|
196
|
+
return i ? t(...i) : t();
|
|
197
|
+
} catch (s) {
|
|
198
|
+
Ee(s, e, n);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function Ee(t, e, n, i = !0) {
|
|
202
|
+
const s = e ? e.vnode : null, { errorHandler: o, throwUnhandledErrorInProduction: r } = e && e.appContext.config || ie;
|
|
203
|
+
if (e) {
|
|
204
|
+
let a = e.parent;
|
|
205
|
+
const c = e.proxy, h = process.env.NODE_ENV !== "production" ? Ce[n] : `https://vuejs.org/error-reference/#runtime-${n}`;
|
|
206
|
+
for (; a; ) {
|
|
207
|
+
const d = a.ec;
|
|
208
|
+
if (d) {
|
|
209
|
+
for (let l = 0; l < d.length; l++)
|
|
210
|
+
if (d[l](t, c, h) === !1)
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
a = a.parent;
|
|
214
|
+
}
|
|
215
|
+
if (o) {
|
|
216
|
+
de(o, null, 10, [
|
|
217
|
+
t,
|
|
218
|
+
c,
|
|
219
|
+
h
|
|
220
|
+
]);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
Ze(t, n, s, i, r);
|
|
225
|
+
}
|
|
226
|
+
function Ze(t, e, n, i = !0, s = !1) {
|
|
227
|
+
if (process.env.NODE_ENV !== "production") {
|
|
228
|
+
const o = Ce[e];
|
|
229
|
+
if (n && Ke(n), _(`Unhandled error${o ? ` during execution of ${o}` : ""}`), n && Ye(), i)
|
|
230
|
+
throw t;
|
|
231
|
+
console.error(t);
|
|
232
|
+
} else {
|
|
233
|
+
if (s)
|
|
234
|
+
throw t;
|
|
235
|
+
console.error(t);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const C = [];
|
|
239
|
+
let I = -1;
|
|
240
|
+
const D = [];
|
|
241
|
+
let L = null, V = 0;
|
|
242
|
+
const et = /* @__PURE__ */ Promise.resolve();
|
|
243
|
+
let re = null;
|
|
244
|
+
const tt = 100;
|
|
245
|
+
function nt(t) {
|
|
246
|
+
let e = I + 1, n = C.length;
|
|
247
|
+
for (; e < n; ) {
|
|
248
|
+
const i = e + n >>> 1, s = C[i], o = H(s);
|
|
249
|
+
o < t || o === t && s.flags & 2 ? e = i + 1 : n = i;
|
|
250
|
+
}
|
|
251
|
+
return e;
|
|
252
|
+
}
|
|
253
|
+
function it(t) {
|
|
254
|
+
if (!(t.flags & 1)) {
|
|
255
|
+
const e = H(t), n = C[C.length - 1];
|
|
256
|
+
!n || // fast path when the job id is larger than the tail
|
|
257
|
+
!(t.flags & 2) && e >= H(n) ? C.push(t) : C.splice(nt(e), 0, t), t.flags |= 1, ke();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function ke() {
|
|
261
|
+
re || (re = et.then(_e));
|
|
262
|
+
}
|
|
263
|
+
function st(t) {
|
|
264
|
+
k(t) ? D.push(...t) : L && t.id === -1 ? L.splice(V + 1, 0, t) : t.flags & 1 || (D.push(t), t.flags |= 1), ke();
|
|
265
|
+
}
|
|
266
|
+
function ot(t) {
|
|
267
|
+
if (D.length) {
|
|
268
|
+
const e = [...new Set(D)].sort(
|
|
269
|
+
(n, i) => H(n) - H(i)
|
|
270
|
+
);
|
|
271
|
+
if (D.length = 0, L) {
|
|
272
|
+
L.push(...e);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
for (L = e, process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map()), V = 0; V < L.length; V++) {
|
|
276
|
+
const n = L[V];
|
|
277
|
+
process.env.NODE_ENV !== "production" && Ie(t, n) || (n.flags & 4 && (n.flags &= -2), n.flags & 8 || n(), n.flags &= -2);
|
|
278
|
+
}
|
|
279
|
+
L = null, V = 0;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const H = (t) => t.id == null ? t.flags & 2 ? -1 : 1 / 0 : t.id;
|
|
283
|
+
function _e(t) {
|
|
284
|
+
process.env.NODE_ENV !== "production" && (t = t || /* @__PURE__ */ new Map());
|
|
285
|
+
const e = process.env.NODE_ENV !== "production" ? (n) => Ie(t, n) : ve;
|
|
286
|
+
try {
|
|
287
|
+
for (I = 0; I < C.length; I++) {
|
|
288
|
+
const n = C[I];
|
|
289
|
+
if (n && !(n.flags & 8)) {
|
|
290
|
+
if (process.env.NODE_ENV !== "production" && e(n))
|
|
291
|
+
continue;
|
|
292
|
+
n.flags & 4 && (n.flags &= -2), de(
|
|
293
|
+
n,
|
|
294
|
+
n.i,
|
|
295
|
+
n.i ? 15 : 14
|
|
296
|
+
), n.flags & 4 || (n.flags &= -2);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
} finally {
|
|
300
|
+
for (; I < C.length; I++) {
|
|
301
|
+
const n = C[I];
|
|
302
|
+
n && (n.flags &= -2);
|
|
303
|
+
}
|
|
304
|
+
I = -1, C.length = 0, ot(t), re = null, (C.length || D.length) && _e(t);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function Ie(t, e) {
|
|
308
|
+
const n = t.get(e) || 0;
|
|
309
|
+
if (n > tt) {
|
|
310
|
+
const i = e.i, s = i && Fe(i.type);
|
|
311
|
+
return Ee(
|
|
312
|
+
`Maximum recursive updates exceeded${s ? ` in component <${s}>` : ""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
|
|
313
|
+
null,
|
|
314
|
+
10
|
|
315
|
+
), !0;
|
|
316
|
+
}
|
|
317
|
+
return t.set(e, n + 1), !1;
|
|
318
|
+
}
|
|
319
|
+
const te = /* @__PURE__ */ new Map();
|
|
320
|
+
process.env.NODE_ENV !== "production" && (Q().__VUE_HMR_RUNTIME__ = {
|
|
321
|
+
createRecord: ne(rt),
|
|
322
|
+
rerender: ne(at),
|
|
323
|
+
reload: ne(lt)
|
|
324
|
+
});
|
|
325
|
+
const J = /* @__PURE__ */ new Map();
|
|
326
|
+
function rt(t, e) {
|
|
327
|
+
return J.has(t) ? !1 : (J.set(t, {
|
|
328
|
+
initialDef: G(e),
|
|
329
|
+
instances: /* @__PURE__ */ new Set()
|
|
330
|
+
}), !0);
|
|
331
|
+
}
|
|
332
|
+
function G(t) {
|
|
333
|
+
return $e(t) ? t.__vccOpts : t;
|
|
334
|
+
}
|
|
335
|
+
function at(t, e) {
|
|
336
|
+
const n = J.get(t);
|
|
337
|
+
n && (n.initialDef.render = e, [...n.instances].forEach((i) => {
|
|
338
|
+
e && (i.render = e, G(i.type).render = e), i.renderCache = [], i.job.flags & 8 || i.update();
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
function lt(t, e) {
|
|
342
|
+
const n = J.get(t);
|
|
343
|
+
if (!n) return;
|
|
344
|
+
e = G(e), he(n.initialDef, e);
|
|
345
|
+
const i = [...n.instances];
|
|
346
|
+
for (let s = 0; s < i.length; s++) {
|
|
347
|
+
const o = i[s], r = G(o.type);
|
|
348
|
+
let a = te.get(r);
|
|
349
|
+
a || (r !== n.initialDef && he(r, e), te.set(r, a = /* @__PURE__ */ new Set())), a.add(o), o.appContext.propsCache.delete(o.type), o.appContext.emitsCache.delete(o.type), o.appContext.optionsCache.delete(o.type), o.ceReload ? (a.add(o), o.ceReload(e.styles), a.delete(o)) : o.parent ? it(() => {
|
|
350
|
+
o.job.flags & 8 || (o.parent.update(), a.delete(o));
|
|
351
|
+
}) : o.appContext.reload ? o.appContext.reload() : typeof window < "u" ? window.location.reload() : console.warn(
|
|
352
|
+
"[HMR] Root or manually mounted instance modified. Full reload required."
|
|
353
|
+
), o.root.ce && o !== o.root && o.root.ce._removeChildStyle(r);
|
|
354
|
+
}
|
|
355
|
+
st(() => {
|
|
356
|
+
te.clear();
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function he(t, e) {
|
|
360
|
+
z(t, e);
|
|
361
|
+
for (const n in t)
|
|
362
|
+
n !== "__file" && !(n in e) && delete t[n];
|
|
363
|
+
}
|
|
364
|
+
function ne(t) {
|
|
365
|
+
return (e, n) => {
|
|
366
|
+
try {
|
|
367
|
+
return t(e, n);
|
|
368
|
+
} catch (i) {
|
|
369
|
+
console.error(i), console.warn(
|
|
370
|
+
"[HMR] Something went wrong during Vue component hot-reload. Full reload required."
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
let F, j = [];
|
|
376
|
+
function Ae(t, e) {
|
|
377
|
+
var n, i;
|
|
378
|
+
F = t, F ? (F.enabled = !0, j.forEach(({ event: s, args: o }) => F.emit(s, ...o)), j = []) : /* handle late devtools injection - only do this if we are in an actual */ /* browser environment to avoid the timer handle stalling test runner exit */ /* (#4815) */ typeof window < "u" && // some envs mock window but not fully
|
|
379
|
+
window.HTMLElement && // also exclude jsdom
|
|
380
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
381
|
+
!((i = (n = window.navigator) == null ? void 0 : n.userAgent) != null && i.includes("jsdom")) ? ((e.__VUE_DEVTOOLS_HOOK_REPLAY__ = e.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((o) => {
|
|
382
|
+
Ae(o, e);
|
|
383
|
+
}), setTimeout(() => {
|
|
384
|
+
F || (e.__VUE_DEVTOOLS_HOOK_REPLAY__ = null, j = []);
|
|
385
|
+
}, 3e3)) : j = [];
|
|
386
|
+
}
|
|
387
|
+
let N = null, ct = null;
|
|
388
|
+
function dt(t, e) {
|
|
389
|
+
if (process.env.NODE_ENV !== "production" && (!A || A.isMounted) && _("provide() can only be used inside setup()."), A) {
|
|
390
|
+
let n = A.provides;
|
|
391
|
+
const i = A.parent && A.parent.provides;
|
|
392
|
+
i === n && (n = A.provides = Object.create(i)), n[t] = e;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function ut(t, e, n = !1) {
|
|
396
|
+
const i = Nt();
|
|
397
|
+
if (i || bt) {
|
|
398
|
+
let s = i ? i.parent == null || i.ce ? i.vnode.appContext && i.vnode.appContext.provides : i.parent.provides : void 0;
|
|
399
|
+
if (s && t in s)
|
|
400
|
+
return s[t];
|
|
401
|
+
if (arguments.length > 1)
|
|
402
|
+
return n && R(e) ? e.call(i && i.proxy) : e;
|
|
403
|
+
process.env.NODE_ENV !== "production" && _(`injection "${String(t)}" not found.`);
|
|
404
|
+
} else process.env.NODE_ENV !== "production" && _("inject() can only be used inside setup() or functional components.");
|
|
405
|
+
}
|
|
406
|
+
const ft = (t) => t.__isTeleport;
|
|
407
|
+
function Ne(t, e) {
|
|
408
|
+
t.shapeFlag & 6 && t.component ? (t.transition = e, Ne(t.component.subTree, e)) : t.shapeFlag & 128 ? (t.ssContent.transition = e.clone(t.ssContent), t.ssFallback.transition = e.clone(t.ssFallback)) : t.transition = e;
|
|
409
|
+
}
|
|
410
|
+
// @__NO_SIDE_EFFECTS__
|
|
411
|
+
function mt(t, e) {
|
|
412
|
+
return R(t) ? (
|
|
413
|
+
// #8236: extend call and options.name access are considered side-effects
|
|
414
|
+
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
|
|
415
|
+
z({ name: t.name }, e, { setup: t })
|
|
416
|
+
) : t;
|
|
417
|
+
}
|
|
418
|
+
Q().requestIdleCallback;
|
|
419
|
+
Q().cancelIdleCallback;
|
|
420
|
+
const ht = (t) => !!t.type.__asyncLoader, pt = /* @__PURE__ */ Symbol.for("v-ndc");
|
|
421
|
+
function gt(t, e, n = {}, i, s) {
|
|
422
|
+
if (N.ce || N.parent && ht(N.parent) && N.parent.ce) {
|
|
423
|
+
const h = Object.keys(n).length > 0;
|
|
424
|
+
return pe(), ge(
|
|
425
|
+
q,
|
|
426
|
+
null,
|
|
427
|
+
[ue("slot", n, i)],
|
|
428
|
+
h ? -2 : 64
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
let o = t[e];
|
|
432
|
+
process.env.NODE_ENV !== "production" && o && o.length > 1 && (_(
|
|
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), pe();
|
|
435
|
+
const r = o && Re(o(n)), a = n.key || // slot content array of a dynamic conditional slot may have a branch
|
|
436
|
+
// key attached in the `createSlots` helper, respect that
|
|
437
|
+
r && r.key, c = ge(
|
|
438
|
+
q,
|
|
439
|
+
{
|
|
440
|
+
key: (a && !we(a) ? a : `_${e}`) + // #7256 force differentiate fallback content from actual content
|
|
441
|
+
(!r && i ? "_fb" : "")
|
|
442
|
+
},
|
|
443
|
+
r || [],
|
|
444
|
+
r && t._ === 1 ? 64 : -2
|
|
445
|
+
);
|
|
446
|
+
return c.scopeId && (c.slotScopeIds = [c.scopeId + "-s"]), o && o._c && (o._d = !0), c;
|
|
447
|
+
}
|
|
448
|
+
function Re(t) {
|
|
449
|
+
return t.some((e) => Oe(e) ? !(e.type === Te || e.type === q && !Re(e.children)) : !0) ? t : null;
|
|
450
|
+
}
|
|
451
|
+
const yt = {};
|
|
452
|
+
process.env.NODE_ENV !== "production" && (yt.ownKeys = (t) => (_(
|
|
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(t)));
|
|
455
|
+
let bt = null;
|
|
456
|
+
const vt = {}, Le = (t) => Object.getPrototypeOf(t) === vt, wt = (t) => t.__isSuspense, q = /* @__PURE__ */ Symbol.for("v-fgt"), xt = /* @__PURE__ */ Symbol.for("v-txt"), Te = /* @__PURE__ */ Symbol.for("v-cmt"), K = [];
|
|
457
|
+
let E = null;
|
|
458
|
+
function pe(t = !1) {
|
|
459
|
+
K.push(E = t ? null : []);
|
|
460
|
+
}
|
|
461
|
+
function St() {
|
|
462
|
+
K.pop(), E = K[K.length - 1] || null;
|
|
463
|
+
}
|
|
464
|
+
function Ct(t) {
|
|
465
|
+
return t.dynamicChildren = E || qe, St(), E && E.push(t), t;
|
|
466
|
+
}
|
|
467
|
+
function ge(t, e, n, i, s) {
|
|
468
|
+
return Ct(
|
|
469
|
+
ue(
|
|
470
|
+
t,
|
|
471
|
+
e,
|
|
472
|
+
n,
|
|
473
|
+
i,
|
|
474
|
+
s,
|
|
475
|
+
!0
|
|
476
|
+
)
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
function Oe(t) {
|
|
480
|
+
return t ? t.__v_isVNode === !0 : !1;
|
|
481
|
+
}
|
|
482
|
+
const Et = (...t) => Pe(
|
|
483
|
+
...t
|
|
484
|
+
), Me = ({ key: t }) => t ?? null, Y = ({
|
|
485
|
+
ref: t,
|
|
486
|
+
ref_key: e,
|
|
487
|
+
ref_for: n
|
|
488
|
+
}) => (typeof t == "number" && (t = "" + t), t != null ? T(t) || ce(t) || R(t) ? { i: N, r: t, k: e, f: !!n } : t : null);
|
|
489
|
+
function kt(t, e = null, n = null, i = 0, s = null, o = t === q ? 0 : 1, r = !1, a = !1) {
|
|
490
|
+
const c = {
|
|
491
|
+
__v_isVNode: !0,
|
|
492
|
+
__v_skip: !0,
|
|
493
|
+
type: t,
|
|
494
|
+
props: e,
|
|
495
|
+
key: e && Me(e),
|
|
496
|
+
ref: e && Y(e),
|
|
497
|
+
scopeId: ct,
|
|
498
|
+
slotScopeIds: null,
|
|
499
|
+
children: n,
|
|
500
|
+
component: null,
|
|
501
|
+
suspense: null,
|
|
502
|
+
ssContent: null,
|
|
503
|
+
ssFallback: null,
|
|
504
|
+
dirs: null,
|
|
505
|
+
transition: null,
|
|
506
|
+
el: null,
|
|
507
|
+
anchor: null,
|
|
508
|
+
target: null,
|
|
509
|
+
targetStart: null,
|
|
510
|
+
targetAnchor: null,
|
|
511
|
+
staticCount: 0,
|
|
512
|
+
shapeFlag: o,
|
|
513
|
+
patchFlag: i,
|
|
514
|
+
dynamicProps: s,
|
|
515
|
+
dynamicChildren: null,
|
|
516
|
+
appContext: null,
|
|
517
|
+
ctx: N
|
|
518
|
+
};
|
|
519
|
+
return a ? (fe(c, n), o & 128 && t.normalize(c)) : n && (c.shapeFlag |= T(n) ? 8 : 16), process.env.NODE_ENV !== "production" && c.key !== c.key && _("VNode created with invalid key (NaN). VNode type:", c.type), // avoid a block node from tracking itself
|
|
520
|
+
!r && // has current parent block
|
|
521
|
+
E && // presence of a patch flag indicates this node needs patching on updates.
|
|
522
|
+
// component nodes also should always be patched, because even if the
|
|
523
|
+
// component doesn't need to update, it needs to persist the instance on to
|
|
524
|
+
// the next vnode so that it can be properly unmounted later.
|
|
525
|
+
(c.patchFlag > 0 || o & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
|
|
526
|
+
// vnode should not be considered dynamic due to handler caching.
|
|
527
|
+
c.patchFlag !== 32 && E.push(c), c;
|
|
528
|
+
}
|
|
529
|
+
const ue = process.env.NODE_ENV !== "production" ? Et : Pe;
|
|
530
|
+
function Pe(t, e = null, n = null, i = 0, s = null, o = !1) {
|
|
531
|
+
if ((!t || t === pt) && (process.env.NODE_ENV !== "production" && !t && _(`Invalid vnode type when creating vnode: ${t}.`), t = Te), Oe(t)) {
|
|
532
|
+
const a = X(
|
|
533
|
+
t,
|
|
534
|
+
e,
|
|
535
|
+
!0
|
|
536
|
+
/* mergeRef: true */
|
|
537
|
+
);
|
|
538
|
+
return n && fe(a, n), !o && E && (a.shapeFlag & 6 ? E[E.indexOf(t)] = a : E.push(a)), a.patchFlag = -2, a;
|
|
539
|
+
}
|
|
540
|
+
if ($e(t) && (t = t.__vccOpts), e) {
|
|
541
|
+
e = _t(e);
|
|
542
|
+
let { class: a, style: c } = e;
|
|
543
|
+
a && !T(a) && (e.class = le(a)), O(c) && (oe(c) && !k(c) && (c = z({}, c)), e.style = ae(c));
|
|
544
|
+
}
|
|
545
|
+
const r = T(t) ? 1 : wt(t) ? 128 : ft(t) ? 64 : O(t) ? 4 : R(t) ? 2 : 0;
|
|
546
|
+
return process.env.NODE_ENV !== "production" && r & 4 && oe(t) && (t = M(t), _(
|
|
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
|
+
`
|
|
549
|
+
Component that was made reactive: `,
|
|
550
|
+
t
|
|
551
|
+
)), kt(
|
|
552
|
+
t,
|
|
553
|
+
e,
|
|
554
|
+
n,
|
|
555
|
+
i,
|
|
556
|
+
s,
|
|
557
|
+
r,
|
|
558
|
+
o,
|
|
559
|
+
!0
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
function _t(t) {
|
|
563
|
+
return t ? oe(t) || Le(t) ? z({}, t) : t : null;
|
|
564
|
+
}
|
|
565
|
+
function X(t, e, n = !1, i = !1) {
|
|
566
|
+
const { props: s, ref: o, patchFlag: r, children: a, transition: c } = t, h = e ? At(s || {}, e) : s, d = {
|
|
567
|
+
__v_isVNode: !0,
|
|
568
|
+
__v_skip: !0,
|
|
569
|
+
type: t.type,
|
|
570
|
+
props: h,
|
|
571
|
+
key: h && Me(h),
|
|
572
|
+
ref: e && e.ref ? (
|
|
573
|
+
// #2078 in the case of <component :is="vnode" ref="extra"/>
|
|
574
|
+
// if the vnode itself already has a ref, cloneVNode will need to merge
|
|
575
|
+
// the refs so the single vnode can be set on multiple refs
|
|
576
|
+
n && o ? k(o) ? o.concat(Y(e)) : [o, Y(e)] : Y(e)
|
|
577
|
+
) : o,
|
|
578
|
+
scopeId: t.scopeId,
|
|
579
|
+
slotScopeIds: t.slotScopeIds,
|
|
580
|
+
children: process.env.NODE_ENV !== "production" && r === -1 && k(a) ? a.map(Ve) : a,
|
|
581
|
+
target: t.target,
|
|
582
|
+
targetStart: t.targetStart,
|
|
583
|
+
targetAnchor: t.targetAnchor,
|
|
584
|
+
staticCount: t.staticCount,
|
|
585
|
+
shapeFlag: t.shapeFlag,
|
|
586
|
+
// if the vnode is cloned with extra props, we can no longer assume its
|
|
587
|
+
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
|
588
|
+
// note: preserve flag for fragments since they use the flag for children
|
|
589
|
+
// fast paths only.
|
|
590
|
+
patchFlag: e && t.type !== q ? r === -1 ? 16 : r | 16 : r,
|
|
591
|
+
dynamicProps: t.dynamicProps,
|
|
592
|
+
dynamicChildren: t.dynamicChildren,
|
|
593
|
+
appContext: t.appContext,
|
|
594
|
+
dirs: t.dirs,
|
|
595
|
+
transition: c,
|
|
596
|
+
// These should technically only be non-null on mounted VNodes. However,
|
|
597
|
+
// they *should* be copied for kept-alive vnodes. So we just always copy
|
|
598
|
+
// them since them being non-null during a mount doesn't affect the logic as
|
|
599
|
+
// they will simply be overwritten.
|
|
600
|
+
component: t.component,
|
|
601
|
+
suspense: t.suspense,
|
|
602
|
+
ssContent: t.ssContent && X(t.ssContent),
|
|
603
|
+
ssFallback: t.ssFallback && X(t.ssFallback),
|
|
604
|
+
placeholder: t.placeholder,
|
|
605
|
+
el: t.el,
|
|
606
|
+
anchor: t.anchor,
|
|
607
|
+
ctx: t.ctx,
|
|
608
|
+
ce: t.ce
|
|
609
|
+
};
|
|
610
|
+
return c && i && Ne(
|
|
611
|
+
d,
|
|
612
|
+
c.clone(d)
|
|
613
|
+
), d;
|
|
614
|
+
}
|
|
615
|
+
function Ve(t) {
|
|
616
|
+
const e = X(t);
|
|
617
|
+
return k(t.children) && (e.children = t.children.map(Ve)), e;
|
|
618
|
+
}
|
|
619
|
+
function It(t = " ", e = 0) {
|
|
620
|
+
return ue(xt, null, t, e);
|
|
621
|
+
}
|
|
622
|
+
function fe(t, e) {
|
|
623
|
+
let n = 0;
|
|
624
|
+
const { shapeFlag: i } = t;
|
|
625
|
+
if (e == null)
|
|
626
|
+
e = null;
|
|
627
|
+
else if (k(e))
|
|
628
|
+
n = 16;
|
|
629
|
+
else if (typeof e == "object")
|
|
630
|
+
if (i & 65) {
|
|
631
|
+
const s = e.default;
|
|
632
|
+
s && (s._c && (s._d = !1), fe(t, s()), s._c && (s._d = !0));
|
|
633
|
+
return;
|
|
634
|
+
} else
|
|
635
|
+
n = 32, !e._ && !Le(e) && (e._ctx = N);
|
|
636
|
+
else R(e) ? (e = { default: e, _ctx: N }, n = 32) : (e = String(e), i & 64 ? (n = 16, e = [It(e)]) : n = 8);
|
|
637
|
+
t.children = e, t.shapeFlag |= n;
|
|
638
|
+
}
|
|
639
|
+
function At(...t) {
|
|
640
|
+
const e = {};
|
|
641
|
+
for (let n = 0; n < t.length; n++) {
|
|
642
|
+
const i = t[n];
|
|
643
|
+
for (const s in i)
|
|
644
|
+
if (s === "class")
|
|
645
|
+
e.class !== i.class && (e.class = le([e.class, i.class]));
|
|
646
|
+
else if (s === "style")
|
|
647
|
+
e.style = ae([e.style, i.style]);
|
|
648
|
+
else if (ze(s)) {
|
|
649
|
+
const o = e[s], r = i[s];
|
|
650
|
+
r && o !== r && !(k(o) && o.includes(r)) && (e[s] = o ? [].concat(o, r) : r);
|
|
651
|
+
} else s !== "" && (e[s] = i[s]);
|
|
652
|
+
}
|
|
653
|
+
return e;
|
|
654
|
+
}
|
|
655
|
+
let A = null;
|
|
656
|
+
const Nt = () => A || N;
|
|
657
|
+
{
|
|
658
|
+
const t = Q(), e = (n, i) => {
|
|
659
|
+
let s;
|
|
660
|
+
return (s = t[n]) || (s = t[n] = []), s.push(i), (o) => {
|
|
661
|
+
s.length > 1 ? s.forEach((r) => r(o)) : s[0](o);
|
|
662
|
+
};
|
|
663
|
+
};
|
|
664
|
+
e(
|
|
665
|
+
"__VUE_INSTANCE_SETTERS__",
|
|
666
|
+
(n) => A = n
|
|
667
|
+
), e(
|
|
668
|
+
"__VUE_SSR_SETTERS__",
|
|
669
|
+
(n) => n
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
process.env.NODE_ENV;
|
|
673
|
+
const Rt = /(?:^|[-_])\w/g, Lt = (t) => t.replace(Rt, (e) => e.toUpperCase()).replace(/[-_]/g, "");
|
|
674
|
+
function Fe(t, e = !0) {
|
|
675
|
+
return R(t) ? t.displayName || t.name : t.name || e && t.__name;
|
|
676
|
+
}
|
|
677
|
+
function De(t, e, n = !1) {
|
|
678
|
+
let i = Fe(e);
|
|
679
|
+
if (!i && e.__file) {
|
|
680
|
+
const s = e.__file.match(/([^/\\]+)\.\w+$/);
|
|
681
|
+
s && (i = s[1]);
|
|
682
|
+
}
|
|
683
|
+
if (!i && t) {
|
|
684
|
+
const s = (o) => {
|
|
685
|
+
for (const r in o)
|
|
686
|
+
if (o[r] === e)
|
|
687
|
+
return r;
|
|
688
|
+
};
|
|
689
|
+
i = s(t.components) || t.parent && s(
|
|
690
|
+
t.parent.type.components
|
|
691
|
+
) || s(t.appContext.components);
|
|
692
|
+
}
|
|
693
|
+
return i ? Lt(i) : n ? "App" : "Anonymous";
|
|
694
|
+
}
|
|
695
|
+
function $e(t) {
|
|
696
|
+
return R(t) && "__vccOpts" in t;
|
|
697
|
+
}
|
|
698
|
+
function Tt() {
|
|
699
|
+
if (process.env.NODE_ENV === "production" || typeof window > "u")
|
|
700
|
+
return;
|
|
701
|
+
const t = { style: "color:#3ba776" }, e = { style: "color:#1677ff" }, n = { style: "color:#f5222d" }, i = { style: "color:#eb2f96" }, s = {
|
|
702
|
+
__vue_custom_formatter: !0,
|
|
703
|
+
header(l) {
|
|
704
|
+
if (!O(l))
|
|
705
|
+
return null;
|
|
706
|
+
if (l.__isVue)
|
|
707
|
+
return ["div", t, "VueInstance"];
|
|
708
|
+
if (ce(l)) {
|
|
709
|
+
const f = l.value;
|
|
710
|
+
return [
|
|
711
|
+
"div",
|
|
712
|
+
{},
|
|
713
|
+
["span", t, d(l)],
|
|
714
|
+
"<",
|
|
715
|
+
a(f),
|
|
716
|
+
">"
|
|
717
|
+
];
|
|
718
|
+
} else {
|
|
719
|
+
if (xe(l))
|
|
720
|
+
return [
|
|
721
|
+
"div",
|
|
722
|
+
{},
|
|
723
|
+
["span", t, Z(l) ? "ShallowReactive" : "Reactive"],
|
|
724
|
+
"<",
|
|
725
|
+
a(l),
|
|
726
|
+
`>${se(l) ? " (readonly)" : ""}`
|
|
727
|
+
];
|
|
728
|
+
if (se(l))
|
|
729
|
+
return [
|
|
730
|
+
"div",
|
|
731
|
+
{},
|
|
732
|
+
["span", t, Z(l) ? "ShallowReadonly" : "Readonly"],
|
|
733
|
+
"<",
|
|
734
|
+
a(l),
|
|
735
|
+
">"
|
|
736
|
+
];
|
|
737
|
+
}
|
|
738
|
+
return null;
|
|
739
|
+
},
|
|
740
|
+
hasBody(l) {
|
|
741
|
+
return l && l.__isVue;
|
|
742
|
+
},
|
|
743
|
+
body(l) {
|
|
744
|
+
if (l && l.__isVue)
|
|
745
|
+
return [
|
|
746
|
+
"div",
|
|
747
|
+
{},
|
|
748
|
+
...o(l.$)
|
|
749
|
+
];
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
function o(l) {
|
|
753
|
+
const f = [];
|
|
754
|
+
l.type.props && l.props && f.push(r("props", M(l.props))), l.setupState !== ie && f.push(r("setup", l.setupState)), l.data !== ie && f.push(r("data", M(l.data)));
|
|
755
|
+
const m = c(l, "computed");
|
|
756
|
+
m && f.push(r("computed", m));
|
|
757
|
+
const y = c(l, "inject");
|
|
758
|
+
return y && f.push(r("injected", y)), f.push([
|
|
759
|
+
"div",
|
|
760
|
+
{},
|
|
761
|
+
[
|
|
762
|
+
"span",
|
|
763
|
+
{
|
|
764
|
+
style: i.style + ";opacity:0.66"
|
|
765
|
+
},
|
|
766
|
+
"$ (internal): "
|
|
767
|
+
],
|
|
768
|
+
["object", { object: l }]
|
|
769
|
+
]), f;
|
|
770
|
+
}
|
|
771
|
+
function r(l, f) {
|
|
772
|
+
return f = z({}, f), Object.keys(f).length ? [
|
|
773
|
+
"div",
|
|
774
|
+
{ style: "line-height:1.25em;margin-bottom:0.6em" },
|
|
775
|
+
[
|
|
776
|
+
"div",
|
|
777
|
+
{
|
|
778
|
+
style: "color:#476582"
|
|
779
|
+
},
|
|
780
|
+
l
|
|
781
|
+
],
|
|
782
|
+
[
|
|
783
|
+
"div",
|
|
784
|
+
{
|
|
785
|
+
style: "padding-left:1.25em"
|
|
786
|
+
},
|
|
787
|
+
...Object.keys(f).map((m) => [
|
|
788
|
+
"div",
|
|
789
|
+
{},
|
|
790
|
+
["span", i, m + ": "],
|
|
791
|
+
a(f[m], !1)
|
|
792
|
+
])
|
|
793
|
+
]
|
|
794
|
+
] : ["span", {}];
|
|
795
|
+
}
|
|
796
|
+
function a(l, f = !0) {
|
|
797
|
+
return typeof l == "number" ? ["span", e, l] : typeof l == "string" ? ["span", n, JSON.stringify(l)] : typeof l == "boolean" ? ["span", i, l] : O(l) ? ["object", { object: f ? M(l) : l }] : ["span", n, String(l)];
|
|
798
|
+
}
|
|
799
|
+
function c(l, f) {
|
|
800
|
+
const m = l.type;
|
|
801
|
+
if (R(m))
|
|
802
|
+
return;
|
|
803
|
+
const y = {};
|
|
804
|
+
for (const u in l.ctx)
|
|
805
|
+
h(m, u, f) && (y[u] = l.ctx[u]);
|
|
806
|
+
return y;
|
|
807
|
+
}
|
|
808
|
+
function h(l, f, m) {
|
|
809
|
+
const y = l[m];
|
|
810
|
+
if (k(y) && y.includes(f) || O(y) && f in y || l.extends && h(l.extends, f, m) || l.mixins && l.mixins.some((u) => h(u, f, m)))
|
|
811
|
+
return !0;
|
|
812
|
+
}
|
|
813
|
+
function d(l) {
|
|
814
|
+
return Z(l) ? "ShallowRef" : l.effect ? "ComputedRef" : "Ref";
|
|
815
|
+
}
|
|
816
|
+
window.devtoolsFormatters ? window.devtoolsFormatters.push(s) : window.devtoolsFormatters = [s];
|
|
817
|
+
}
|
|
818
|
+
process.env.NODE_ENV;
|
|
819
|
+
process.env.NODE_ENV;
|
|
820
|
+
process.env.NODE_ENV;
|
|
821
|
+
/**
|
|
822
|
+
* vue v3.5.26
|
|
823
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
824
|
+
* @license MIT
|
|
825
|
+
**/
|
|
826
|
+
function Ot() {
|
|
827
|
+
Tt();
|
|
828
|
+
}
|
|
829
|
+
process.env.NODE_ENV !== "production" && Ot();
|
|
830
|
+
class ye {
|
|
831
|
+
constructor(e) {
|
|
832
|
+
this.endpoint = e || "https://foisit-ninja.netlify.app/.netlify/functions/intent";
|
|
833
|
+
}
|
|
834
|
+
async determineIntent(e, n, i) {
|
|
835
|
+
try {
|
|
836
|
+
const s = {
|
|
837
|
+
userInput: e,
|
|
838
|
+
commands: n.map((a) => ({
|
|
839
|
+
id: a.id,
|
|
840
|
+
command: a.command,
|
|
841
|
+
description: a.description,
|
|
842
|
+
parameters: a.parameters
|
|
843
|
+
// Send param schemas to AI
|
|
844
|
+
})),
|
|
845
|
+
context: i
|
|
846
|
+
}, o = await fetch(this.endpoint, {
|
|
847
|
+
method: "POST",
|
|
848
|
+
headers: {
|
|
849
|
+
"Content-Type": "application/json"
|
|
850
|
+
},
|
|
851
|
+
body: JSON.stringify(s)
|
|
852
|
+
});
|
|
853
|
+
if (!o.ok)
|
|
854
|
+
throw new Error(`Proxy API Error: ${o.statusText}`);
|
|
855
|
+
return await o.json();
|
|
856
|
+
} catch (s) {
|
|
857
|
+
return console.error("OpenAIService Error:", s), { type: "unknown" };
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
class Mt {
|
|
862
|
+
constructor(e = !0) {
|
|
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
|
+
this.enableSmartIntent = e, this.enableSmartIntent && (this.openAIService = new ye());
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
this.enableSmartIntent = e.enableSmartIntent ?? !0, this.enableSmartIntent && (this.openAIService = new ye(e.intentEndpoint));
|
|
868
|
+
}
|
|
869
|
+
/** Add a new command (string or object) */
|
|
870
|
+
addCommand(e, n) {
|
|
871
|
+
let i;
|
|
872
|
+
if (typeof e == "string") {
|
|
873
|
+
if (!n)
|
|
874
|
+
throw new Error("Action required when adding command by string.");
|
|
875
|
+
i = {
|
|
876
|
+
id: e.toLowerCase().replace(/\s+/g, "_"),
|
|
877
|
+
command: e.toLowerCase(),
|
|
878
|
+
action: n
|
|
879
|
+
};
|
|
880
|
+
} else
|
|
881
|
+
i = { ...e }, i.id || (i.id = i.command.toLowerCase().replace(/\s+/g, "_"));
|
|
882
|
+
this.commands.set(i.command.toLowerCase(), i), i.id && (i.id, i.command);
|
|
883
|
+
}
|
|
884
|
+
/** Remove an existing command */
|
|
885
|
+
removeCommand(e) {
|
|
886
|
+
this.commands.delete(e.toLowerCase());
|
|
887
|
+
}
|
|
888
|
+
/** Execute a command by matching input */
|
|
889
|
+
async executeCommand(e) {
|
|
890
|
+
if (typeof e == "object" && e !== null) {
|
|
891
|
+
if (this.isStructured(e)) {
|
|
892
|
+
const c = String(e.commandId), h = e.params ?? {}, d = this.getCommandById(c);
|
|
893
|
+
if (!d) return { message: "That command is not available.", type: "error" };
|
|
894
|
+
const l = this.sanitizeParamsForCommand(d, h), m = (d.parameters ?? []).filter((y) => y.required).filter((y) => l[y.name] == null || l[y.name] === "");
|
|
895
|
+
return m.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(d), params: l }, {
|
|
896
|
+
message: `Please provide the required details for "${d.command}".`,
|
|
897
|
+
type: "form",
|
|
898
|
+
fields: m
|
|
899
|
+
}) : d.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(d), params: l }, this.buildConfirmResponse(d)) : this.safeRunAction(d, l);
|
|
900
|
+
}
|
|
901
|
+
if (!this.context)
|
|
902
|
+
return { message: "Session expired or invalid context.", type: "error" };
|
|
903
|
+
const o = this.getCommandById(this.context.commandId);
|
|
904
|
+
if (!o)
|
|
905
|
+
return this.context = null, { message: "Session expired or invalid context.", type: "error" };
|
|
906
|
+
if (Array.isArray(e))
|
|
907
|
+
return { message: "Invalid form payload.", type: "error" };
|
|
908
|
+
const r = {
|
|
909
|
+
...this.context.params,
|
|
910
|
+
...e
|
|
911
|
+
};
|
|
912
|
+
if (o.critical)
|
|
913
|
+
return this.context = null, this.pendingConfirmation = {
|
|
914
|
+
commandId: this.getCommandIdentifier(o),
|
|
915
|
+
params: r
|
|
916
|
+
}, this.buildConfirmResponse(o);
|
|
917
|
+
const a = await this.safeRunAction(o, r);
|
|
918
|
+
return this.context = null, this.normalizeResponse(a);
|
|
919
|
+
}
|
|
920
|
+
const n = e.trim().toLowerCase();
|
|
921
|
+
if (this.pendingConfirmation) {
|
|
922
|
+
const o = n;
|
|
923
|
+
if (["yes", "y", "confirm", "ok", "okay"].includes(o)) {
|
|
924
|
+
const { commandId: r, params: a } = this.pendingConfirmation;
|
|
925
|
+
this.pendingConfirmation = null;
|
|
926
|
+
const c = this.getCommandById(r);
|
|
927
|
+
return c ? this.safeRunAction(c, a) : { message: "That action is no longer available.", type: "error" };
|
|
928
|
+
}
|
|
929
|
+
return ["no", "n", "cancel", "stop"].includes(o) ? (this.pendingConfirmation = null, { message: "✅ Cancelled.", type: "success" }) : {
|
|
930
|
+
message: "Please confirm: Yes or No.",
|
|
931
|
+
type: "confirm",
|
|
932
|
+
options: [
|
|
933
|
+
{ label: "Yes", value: "yes" },
|
|
934
|
+
{ label: "No", value: "no" }
|
|
935
|
+
]
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
const i = this.commands.get(n);
|
|
939
|
+
if (i) {
|
|
940
|
+
const o = i, r = (o.parameters ?? []).filter((a) => a.required);
|
|
941
|
+
return r.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
942
|
+
message: `Please provide the required details for "${o.command}".`,
|
|
943
|
+
type: "form",
|
|
944
|
+
fields: r
|
|
945
|
+
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
946
|
+
}
|
|
947
|
+
const s = await this.tryDeterministicMatch(n);
|
|
948
|
+
if (s) return s;
|
|
949
|
+
if (this.enableSmartIntent && this.openAIService) {
|
|
950
|
+
const o = await this.getCommandsForAI(), r = await this.openAIService.determineIntent(
|
|
951
|
+
n,
|
|
952
|
+
o,
|
|
953
|
+
this.context
|
|
954
|
+
);
|
|
955
|
+
return this.handleAIResult(r);
|
|
956
|
+
}
|
|
957
|
+
return this.enableSmartIntent ? this.listAllCommands() : { message: "I'm not sure what you mean.", type: "error" };
|
|
958
|
+
}
|
|
959
|
+
async handleAIResult(e) {
|
|
960
|
+
if (e.type === "match" && e.match) {
|
|
961
|
+
const n = this.getCommandById(e.match);
|
|
962
|
+
if (!n)
|
|
963
|
+
return { message: "I'm not sure what you mean.", type: "error" };
|
|
964
|
+
const i = e.params ?? {}, s = this.sanitizeParamsForCommand(n, i), o = n.allowAiParamExtraction === !1 ? {} : s, a = (n.parameters ?? []).filter((h) => h.required).filter((h) => o[h.name] == null || o[h.name] === "");
|
|
965
|
+
if (e.incomplete || a.length > 0) {
|
|
966
|
+
if (this.context = { commandId: this.getCommandIdentifier(n), params: o }, !(n.collectRequiredViaForm !== !1) && this.shouldAskSingleQuestion(a)) {
|
|
967
|
+
const l = a.map((f) => f.name).join(" and ");
|
|
968
|
+
return {
|
|
969
|
+
message: e.message || `Please provide ${l}.`,
|
|
970
|
+
type: "question"
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
return {
|
|
974
|
+
message: e.message || `Please fill in the missing details for "${n.command}".`,
|
|
975
|
+
type: "form",
|
|
976
|
+
fields: a
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
if (n.critical)
|
|
980
|
+
return this.pendingConfirmation = {
|
|
981
|
+
commandId: this.getCommandIdentifier(n),
|
|
982
|
+
params: o
|
|
983
|
+
}, this.buildConfirmResponse(n);
|
|
984
|
+
const c = await n.action(o);
|
|
985
|
+
return this.normalizeResponse(c);
|
|
986
|
+
}
|
|
987
|
+
return e.type === "ambiguous" && e.options && e.options.length ? {
|
|
988
|
+
message: e.message || "Did you mean one of these?",
|
|
989
|
+
type: "ambiguous",
|
|
990
|
+
options: e.options.map((n) => ({
|
|
991
|
+
label: n.label,
|
|
992
|
+
value: n.commandId ?? n.label,
|
|
993
|
+
commandId: n.commandId
|
|
994
|
+
}))
|
|
995
|
+
} : this.listAllCommands();
|
|
996
|
+
}
|
|
997
|
+
sanitizeParamsForCommand(e, n) {
|
|
998
|
+
const i = { ...n ?? {} };
|
|
999
|
+
for (const s of e.parameters ?? []) {
|
|
1000
|
+
const o = i[s.name];
|
|
1001
|
+
if (s.type === "string") {
|
|
1002
|
+
if (typeof o != "string") {
|
|
1003
|
+
delete i[s.name];
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
1006
|
+
const r = o.trim();
|
|
1007
|
+
if (!r) {
|
|
1008
|
+
delete i[s.name];
|
|
1009
|
+
continue;
|
|
1010
|
+
}
|
|
1011
|
+
i[s.name] = r;
|
|
1012
|
+
}
|
|
1013
|
+
if (s.type === "number") {
|
|
1014
|
+
const r = typeof o == "number" ? o : Number(o == null ? void 0 : o.toString().trim());
|
|
1015
|
+
if (Number.isNaN(r)) {
|
|
1016
|
+
delete i[s.name];
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
if (typeof s.min == "number" && r < s.min) {
|
|
1020
|
+
delete i[s.name];
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1023
|
+
if (typeof s.max == "number" && r > s.max) {
|
|
1024
|
+
delete i[s.name];
|
|
1025
|
+
continue;
|
|
1026
|
+
}
|
|
1027
|
+
i[s.name] = r;
|
|
1028
|
+
}
|
|
1029
|
+
if (s.type === "date") {
|
|
1030
|
+
const r = i[s.name];
|
|
1031
|
+
if (typeof r == "string") {
|
|
1032
|
+
const a = r.trim();
|
|
1033
|
+
this.isIsoDateString(a) ? i[s.name] = a : delete i[s.name];
|
|
1034
|
+
} else
|
|
1035
|
+
delete i[s.name];
|
|
1036
|
+
}
|
|
1037
|
+
if (s.type === "select") {
|
|
1038
|
+
const r = typeof o == "string" ? o : o == null ? void 0 : o.toString();
|
|
1039
|
+
if (!r) {
|
|
1040
|
+
delete i[s.name];
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
if (Array.isArray(s.options) && s.options.length > 0 && !s.options.some((c) => String(c.value) === String(r))) {
|
|
1044
|
+
delete i[s.name];
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
i[s.name] = r;
|
|
1048
|
+
}
|
|
1049
|
+
if (s.type === "file") {
|
|
1050
|
+
const r = i[s.name], a = r && typeof r == "object" && typeof r.name == "string" && typeof r.size == "number", c = typeof r == "string" && /^data:[^;]+;base64,/.test(r);
|
|
1051
|
+
(s.delivery ?? "file") === "base64" ? !c && !a && delete i[s.name] : a || delete i[s.name];
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
return i;
|
|
1055
|
+
}
|
|
1056
|
+
isIsoDateString(e) {
|
|
1057
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
|
|
1058
|
+
const n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
|
|
1059
|
+
return !Number.isNaN(n.getTime());
|
|
1060
|
+
}
|
|
1061
|
+
shouldAskSingleQuestion(e) {
|
|
1062
|
+
if (e.length !== 1) return !1;
|
|
1063
|
+
const n = e[0].type;
|
|
1064
|
+
return n === "string" || n === "number" || n === "date";
|
|
1065
|
+
}
|
|
1066
|
+
buildConfirmResponse(e) {
|
|
1067
|
+
return {
|
|
1068
|
+
message: `⚠️ Are you sure you want to run "${e.command}"?`,
|
|
1069
|
+
type: "confirm",
|
|
1070
|
+
options: [
|
|
1071
|
+
{ label: "Yes", value: "yes" },
|
|
1072
|
+
{ label: "No", value: "no" }
|
|
1073
|
+
]
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
async tryDeterministicMatch(e) {
|
|
1077
|
+
const n = [];
|
|
1078
|
+
for (const a of this.commands.values()) {
|
|
1079
|
+
let c = 0;
|
|
1080
|
+
const h = a.command.toLowerCase();
|
|
1081
|
+
e.includes(h) && (c += 5);
|
|
1082
|
+
const d = a.keywords ?? [];
|
|
1083
|
+
for (const l of d) {
|
|
1084
|
+
const f = l.toLowerCase().trim();
|
|
1085
|
+
f && (e === f ? c += 4 : e.includes(f) && (c += 3));
|
|
1086
|
+
}
|
|
1087
|
+
c > 0 && n.push({ cmd: a, score: c });
|
|
1088
|
+
}
|
|
1089
|
+
if (n.length === 0) return null;
|
|
1090
|
+
n.sort((a, c) => c.score - a.score);
|
|
1091
|
+
const i = n[0].score, s = n.filter((a) => a.score === i).slice(0, 3);
|
|
1092
|
+
if (s.length > 1)
|
|
1093
|
+
return {
|
|
1094
|
+
message: "I think you mean one of these. Which one should I run?",
|
|
1095
|
+
type: "ambiguous",
|
|
1096
|
+
options: s.map((a) => ({
|
|
1097
|
+
label: a.cmd.command,
|
|
1098
|
+
value: a.cmd.command,
|
|
1099
|
+
commandId: a.cmd.id
|
|
1100
|
+
}))
|
|
1101
|
+
};
|
|
1102
|
+
const o = s[0].cmd, r = (o.parameters ?? []).filter((a) => a.required);
|
|
1103
|
+
return r.length > 0 ? (this.context = { commandId: this.getCommandIdentifier(o), params: {} }, {
|
|
1104
|
+
message: `Please provide the required details for "${o.command}".`,
|
|
1105
|
+
type: "form",
|
|
1106
|
+
fields: r
|
|
1107
|
+
}) : o.critical ? (this.pendingConfirmation = { commandId: this.getCommandIdentifier(o), params: {} }, this.buildConfirmResponse(o)) : this.safeRunAction(o, {});
|
|
1108
|
+
}
|
|
1109
|
+
async safeRunAction(e, n) {
|
|
1110
|
+
try {
|
|
1111
|
+
const i = await e.action(n ?? {});
|
|
1112
|
+
return this.normalizeResponse(i);
|
|
1113
|
+
} catch {
|
|
1114
|
+
return { message: "Something went wrong while running that command.", type: "error" };
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
async getCommandsForAI() {
|
|
1118
|
+
const e = Array.from(this.commands.values()).map((n) => ({
|
|
1119
|
+
...n,
|
|
1120
|
+
parameters: n.parameters ? n.parameters.map((i) => ({ ...i })) : void 0
|
|
1121
|
+
}));
|
|
1122
|
+
return await Promise.all(
|
|
1123
|
+
e.map(async (n) => {
|
|
1124
|
+
n.parameters && await Promise.all(
|
|
1125
|
+
n.parameters.map(async (i) => {
|
|
1126
|
+
if (i.type !== "select" || !i.getOptions || i.options && i.options.length) return;
|
|
1127
|
+
const s = `${n.id ?? n.command}:${i.name}`, o = this.selectOptionsCache.get(s), r = Date.now();
|
|
1128
|
+
if (o && r - o.ts < 6e4) {
|
|
1129
|
+
i.options = o.options;
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
try {
|
|
1133
|
+
const a = await i.getOptions();
|
|
1134
|
+
this.selectOptionsCache.set(s, { options: a, ts: r }), i.options = a;
|
|
1135
|
+
} catch {
|
|
1136
|
+
}
|
|
1137
|
+
})
|
|
1138
|
+
);
|
|
1139
|
+
})
|
|
1140
|
+
), e;
|
|
1141
|
+
}
|
|
1142
|
+
getCommandById(e) {
|
|
1143
|
+
for (const n of this.commands.values())
|
|
1144
|
+
if (n.id === e) return n;
|
|
1145
|
+
}
|
|
1146
|
+
listAllCommands() {
|
|
1147
|
+
return {
|
|
1148
|
+
message: "Here are the available commands:",
|
|
1149
|
+
type: "ambiguous",
|
|
1150
|
+
options: Array.from(this.commands.values()).map((n) => ({
|
|
1151
|
+
label: n.command,
|
|
1152
|
+
value: n.id ?? n.command,
|
|
1153
|
+
commandId: n.id ?? n.command
|
|
1154
|
+
}))
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
normalizeResponse(e) {
|
|
1158
|
+
return typeof e == "string" ? { message: e, type: "success" } : e && typeof e == "object" ? e : { message: "Done", type: "success" };
|
|
1159
|
+
}
|
|
1160
|
+
isStructured(e) {
|
|
1161
|
+
return typeof e.commandId == "string";
|
|
1162
|
+
}
|
|
1163
|
+
getCommandIdentifier(e) {
|
|
1164
|
+
return e.id || (e.id = e.command.toLowerCase().replace(/\s+/g, "_")), e.id;
|
|
1165
|
+
}
|
|
1166
|
+
/** List all registered commands */
|
|
1167
|
+
getCommands() {
|
|
1168
|
+
return Array.from(this.commands.keys());
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
class He {
|
|
1172
|
+
constructor() {
|
|
1173
|
+
this.synth = window.speechSynthesis;
|
|
1174
|
+
}
|
|
1175
|
+
speak(e, n) {
|
|
1176
|
+
if (!this.synth) {
|
|
1177
|
+
console.error("SpeechSynthesis API is not supported in this browser.");
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
const i = new SpeechSynthesisUtterance(e);
|
|
1181
|
+
n && (i.pitch = n.pitch || 1, i.rate = n.rate || 1, i.volume = n.volume || 1), i.onstart = () => {
|
|
1182
|
+
window.dispatchEvent(new CustomEvent("foisit:tts-start"));
|
|
1183
|
+
}, i.onend = () => {
|
|
1184
|
+
console.log("Speech finished."), window.dispatchEvent(new CustomEvent("foisit:tts-end"));
|
|
1185
|
+
}, i.onerror = (s) => {
|
|
1186
|
+
console.error("Error during speech synthesis:", s.error);
|
|
1187
|
+
}, this.synth.speak(i);
|
|
1188
|
+
}
|
|
1189
|
+
stopSpeaking() {
|
|
1190
|
+
this.synth && this.synth.cancel();
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
class Pt {
|
|
1194
|
+
constructor() {
|
|
1195
|
+
this.fallbackMessage = "Sorry, I didn’t understand that.";
|
|
1196
|
+
}
|
|
1197
|
+
setFallbackMessage(e) {
|
|
1198
|
+
this.fallbackMessage = e;
|
|
1199
|
+
}
|
|
1200
|
+
handleFallback(e) {
|
|
1201
|
+
e && console.log(`Fallback triggered for: "${e}"`), console.log(this.fallbackMessage), new He().speak(this.fallbackMessage);
|
|
1202
|
+
}
|
|
1203
|
+
getFallbackMessage() {
|
|
1204
|
+
return this.fallbackMessage;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
const be = () => {
|
|
1208
|
+
const t = window;
|
|
1209
|
+
return t.SpeechRecognition ?? t.webkitSpeechRecognition ?? null;
|
|
1210
|
+
};
|
|
1211
|
+
class Vt {
|
|
1212
|
+
constructor(e = "en-US", n = {}) {
|
|
1213
|
+
this.recognition = null, this.isListening = !1, this.engineActive = !1, this.intentionallyStopped = !1, this.restartAllowed = !0, this.lastStart = 0, this.backoffMs = 250, this.destroyed = !1, this.resultCallback = null, this.ttsSpeaking = !1, this.debugEnabled = !0, this.restartTimer = null, this.prewarmed = !1, this.hadResultThisSession = !1, this.onTTSStart = () => {
|
|
1214
|
+
var s;
|
|
1215
|
+
this.ttsSpeaking = !0;
|
|
1216
|
+
try {
|
|
1217
|
+
(s = this.recognition) == null || s.stop();
|
|
1218
|
+
} catch {
|
|
1219
|
+
}
|
|
1220
|
+
this.isListening && this.emitStatus("speaking");
|
|
1221
|
+
}, this.onTTSEnd = () => {
|
|
1222
|
+
this.ttsSpeaking = !1, this.isListening && this.restartAllowed ? this.safeRestart() : this.emitStatus(this.isListening ? "listening" : "idle");
|
|
1223
|
+
};
|
|
1224
|
+
const i = be();
|
|
1225
|
+
if (i) {
|
|
1226
|
+
this.recognition = new i(), this.recognition.lang = e, this.recognition.interimResults = n.interimResults ?? !0, this.recognition.continuous = n.continuous ?? !0, this.recognition.onresult = (o) => this.handleResult(o, n), this.recognition.onend = () => this.handleEnd(), this.recognition.onstart = () => {
|
|
1227
|
+
this.log("recognition onstart"), this.engineActive = !0, this.hadResultThisSession = !1, this.restartTimer && (clearTimeout(this.restartTimer), this.restartTimer = null), this.backoffMs = 250, this.isListening && !this.ttsSpeaking && this.emitStatus("listening");
|
|
1228
|
+
};
|
|
1229
|
+
const s = this.recognition;
|
|
1230
|
+
s.onaudiostart = () => this.log("onaudiostart"), s.onsoundstart = () => this.log("onsoundstart"), s.onspeechstart = () => this.log("onspeechstart"), s.onspeechend = () => this.log("onspeechend"), s.onsoundend = () => this.log("onsoundend"), s.onaudioend = () => this.log("onaudioend"), this.recognition.onerror = (o) => this.handleError(o);
|
|
1231
|
+
} else
|
|
1232
|
+
this.recognition = null, this.emitStatus("unsupported");
|
|
1233
|
+
window.addEventListener("foisit:tts-start", this.onTTSStart), window.addEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler = () => {
|
|
1234
|
+
var s;
|
|
1235
|
+
if (document.hidden) {
|
|
1236
|
+
try {
|
|
1237
|
+
(s = this.recognition) == null || s.stop();
|
|
1238
|
+
} catch {
|
|
1239
|
+
}
|
|
1240
|
+
this.emitStatus(this.ttsSpeaking ? "speaking" : "idle");
|
|
1241
|
+
} else this.isListening && !this.ttsSpeaking && this.safeRestart();
|
|
1242
|
+
}, document.addEventListener("visibilitychange", this.visibilityHandler);
|
|
1243
|
+
}
|
|
1244
|
+
// Debug logger helpers
|
|
1245
|
+
log(e) {
|
|
1246
|
+
this.debugEnabled && e && console.log("[VoiceProcessor]", e);
|
|
1247
|
+
}
|
|
1248
|
+
warn(e) {
|
|
1249
|
+
this.debugEnabled && e && console.warn("[VoiceProcessor]", e);
|
|
1250
|
+
}
|
|
1251
|
+
error(e) {
|
|
1252
|
+
this.debugEnabled && e && console.error("[VoiceProcessor]", e);
|
|
1253
|
+
}
|
|
1254
|
+
/** Check if SpeechRecognition is available */
|
|
1255
|
+
isSupported() {
|
|
1256
|
+
return be() !== null;
|
|
1257
|
+
}
|
|
1258
|
+
/** Allow consumers (wrappers) to observe status changes */
|
|
1259
|
+
onStatusChange(e) {
|
|
1260
|
+
this.statusCallback = e;
|
|
1261
|
+
}
|
|
1262
|
+
/** Start listening for speech input */
|
|
1263
|
+
startListening(e) {
|
|
1264
|
+
if (!this.isSupported() || !this.recognition) {
|
|
1265
|
+
this.warn("VoiceProcessor: SpeechRecognition is not supported in this browser."), this.emitStatus("unsupported");
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
if (this.isListening) {
|
|
1269
|
+
this.warn("VoiceProcessor: Already listening."), this.resultCallback = e;
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
this.resultCallback = e, this.intentionallyStopped = !1, this.restartAllowed = !0, this.isListening = !0, this.emitStatus("listening"), this.prewarmAudio().finally(() => {
|
|
1273
|
+
this.safeRestart();
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
/** Stop listening for speech input */
|
|
1277
|
+
stopListening() {
|
|
1278
|
+
var e;
|
|
1279
|
+
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus(this.ttsSpeaking ? "speaking" : "idle");
|
|
1280
|
+
try {
|
|
1281
|
+
(e = this.recognition) == null || e.stop();
|
|
1282
|
+
} catch {
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
/** Clean up listeners */
|
|
1286
|
+
destroy() {
|
|
1287
|
+
this.destroyed = !0, this.stopListening(), this.resultCallback = null, window.removeEventListener("foisit:tts-start", this.onTTSStart), window.removeEventListener("foisit:tts-end", this.onTTSEnd), this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = void 0);
|
|
1288
|
+
}
|
|
1289
|
+
/** Handle recognized speech results */
|
|
1290
|
+
handleResult(e, n) {
|
|
1291
|
+
var s, o;
|
|
1292
|
+
if (!this.resultCallback) return;
|
|
1293
|
+
const i = n.confidenceThreshold ?? 0.6;
|
|
1294
|
+
for (let r = e.resultIndex; r < e.results.length; r++) {
|
|
1295
|
+
const a = e.results[r], c = a && a[0], h = ((o = (s = c == null ? void 0 : c.transcript) == null ? void 0 : s.trim) == null ? void 0 : o.call(s)) || "", d = (c == null ? void 0 : c.confidence) ?? 0;
|
|
1296
|
+
if (h && !(!a.isFinal && n.interimResults === !1) && !(a.isFinal && d < i))
|
|
1297
|
+
try {
|
|
1298
|
+
this.hadResultThisSession = !0, this.resultCallback(h, !!a.isFinal);
|
|
1299
|
+
} catch {
|
|
1300
|
+
this.error("VoiceProcessor: result callback error");
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
/** Handle session end */
|
|
1305
|
+
handleEnd() {
|
|
1306
|
+
if (this.log("recognition onend"), this.engineActive = !1, this.destroyed || this.intentionallyStopped || !this.restartAllowed || this.ttsSpeaking) {
|
|
1307
|
+
this.ttsSpeaking || (this.isListening = !1, this.emitStatus("idle"));
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
this.isListening = !0, this.scheduleRestart();
|
|
1311
|
+
}
|
|
1312
|
+
/** Handle errors during speech recognition */
|
|
1313
|
+
handleError(e) {
|
|
1314
|
+
const n = e == null ? void 0 : e.error;
|
|
1315
|
+
if (this.warn(`Error occurred: ${n ?? "unknown"}`), n && ["not-allowed", "service-not-allowed", "bad-grammar", "language-not-supported"].includes(n)) {
|
|
1316
|
+
this.intentionallyStopped = !0, this.restartAllowed = !1, this.isListening = !1, this.emitStatus("error", { error: n });
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
this.scheduleRestart();
|
|
1320
|
+
}
|
|
1321
|
+
safeRestart() {
|
|
1322
|
+
if (!this.recognition) return;
|
|
1323
|
+
if (this.engineActive) {
|
|
1324
|
+
this.log("safeRestart: engine already active, skipping start");
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
const e = Date.now();
|
|
1328
|
+
if (e - this.lastStart < 300) {
|
|
1329
|
+
setTimeout(() => this.safeRestart(), 300);
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
this.lastStart = e;
|
|
1333
|
+
try {
|
|
1334
|
+
this.log("calling recognition.start()"), this.recognition.start(), this.backoffMs = 250, this.isListening && !this.ttsSpeaking && this.emitStatus("listening");
|
|
1335
|
+
} catch {
|
|
1336
|
+
this.error("recognition.start() threw; scheduling restart"), this.scheduleRestart();
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
scheduleRestart() {
|
|
1340
|
+
if (this.destroyed || this.intentionallyStopped || !this.restartAllowed || this.ttsSpeaking) return;
|
|
1341
|
+
if (this.engineActive) {
|
|
1342
|
+
this.log("scheduleRestart: engine active, not scheduling");
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
const e = Math.min(this.backoffMs, 2e3);
|
|
1346
|
+
if (this.log(`scheduleRestart in ${e}ms`), this.restartTimer) {
|
|
1347
|
+
this.log("scheduleRestart: restart already scheduled");
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
this.restartTimer = setTimeout(() => {
|
|
1351
|
+
this.restartTimer = null, !(this.destroyed || this.intentionallyStopped || !this.restartAllowed || this.ttsSpeaking) && this.safeRestart();
|
|
1352
|
+
}, e), this.backoffMs = Math.min(this.backoffMs * 2, 2e3);
|
|
1353
|
+
}
|
|
1354
|
+
async prewarmAudio() {
|
|
1355
|
+
if (!this.prewarmed)
|
|
1356
|
+
try {
|
|
1357
|
+
if (typeof navigator > "u" || !("mediaDevices" in navigator)) return;
|
|
1358
|
+
const e = navigator.mediaDevices;
|
|
1359
|
+
if (!(e != null && e.getUserMedia)) return;
|
|
1360
|
+
this.log("prewarmAudio: requesting mic");
|
|
1361
|
+
const n = await e.getUserMedia({ audio: !0 });
|
|
1362
|
+
for (const i of n.getTracks()) i.stop();
|
|
1363
|
+
this.prewarmed = !0, this.log("prewarmAudio: mic ready");
|
|
1364
|
+
} catch {
|
|
1365
|
+
this.warn("prewarmAudio: failed to get mic");
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
emitStatus(e, n) {
|
|
1369
|
+
if (this.statusCallback)
|
|
1370
|
+
try {
|
|
1371
|
+
this.statusCallback(e, n);
|
|
1372
|
+
} catch {
|
|
1373
|
+
this.error("VoiceProcessor: status callback error");
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
class Ft {
|
|
1378
|
+
constructor() {
|
|
1379
|
+
this.lastTap = 0;
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Sets up double-click and double-tap listeners
|
|
1383
|
+
* @param onDoubleClickOrTap Callback to execute when a double-click or double-tap is detected
|
|
1384
|
+
*/
|
|
1385
|
+
setupDoubleTapListener(e) {
|
|
1386
|
+
this.destroy(), this.dblClickListener = () => {
|
|
1387
|
+
e();
|
|
1388
|
+
}, document.addEventListener("dblclick", this.dblClickListener), this.touchEndListener = () => {
|
|
1389
|
+
const n = (/* @__PURE__ */ new Date()).getTime(), i = n - this.lastTap;
|
|
1390
|
+
i < 300 && i > 0 && e(), this.lastTap = n;
|
|
1391
|
+
}, document.addEventListener("touchend", this.touchEndListener);
|
|
1392
|
+
}
|
|
1393
|
+
destroy() {
|
|
1394
|
+
this.dblClickListener && document.removeEventListener("dblclick", this.dblClickListener), this.touchEndListener && document.removeEventListener("touchend", this.touchEndListener), this.dblClickListener = void 0, this.touchEndListener = void 0;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
function Dt() {
|
|
1398
|
+
if (document.querySelector("#assistant-styles")) {
|
|
1399
|
+
console.log("Styles already injected");
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
const e = document.createElement("style");
|
|
1403
|
+
e.id = "assistant-styles", e.innerHTML = `
|
|
1404
|
+
/* Rounded shape with gradient animation */
|
|
1405
|
+
.gradient-indicator {
|
|
1406
|
+
position: fixed;
|
|
1407
|
+
top: 20px;
|
|
1408
|
+
right: 20px;
|
|
1409
|
+
width: 60px;
|
|
1410
|
+
height: 60px;
|
|
1411
|
+
border-radius: 50%;
|
|
1412
|
+
background: linear-gradient(135deg, #ff6ec4, #7873f5, #5e8cff, #6ed0f6);
|
|
1413
|
+
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
|
|
1414
|
+
animation: amoeba 5s infinite ease-in-out;
|
|
1415
|
+
z-index: 9999; /* Ensure it's above all other elements */
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/* Amoeba effect for the borders */
|
|
1419
|
+
@keyframes amoeba {
|
|
1420
|
+
0% {
|
|
1421
|
+
border-radius: 50%;
|
|
1422
|
+
}
|
|
1423
|
+
25% {
|
|
1424
|
+
border-radius: 40% 60% 60% 40%;
|
|
1425
|
+
}
|
|
1426
|
+
50% {
|
|
1427
|
+
border-radius: 60% 40% 40% 60%;
|
|
1428
|
+
}
|
|
1429
|
+
75% {
|
|
1430
|
+
border-radius: 40% 60% 60% 40%;
|
|
1431
|
+
}
|
|
1432
|
+
100% {
|
|
1433
|
+
border-radius: 50%;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
`, document.head.appendChild(e), console.log("Gradient styles injected");
|
|
1437
|
+
}
|
|
1438
|
+
function $t() {
|
|
1439
|
+
if (document.querySelector("#gradient-indicator"))
|
|
1440
|
+
return;
|
|
1441
|
+
const t = document.createElement("div");
|
|
1442
|
+
t.id = "gradient-indicator", Dt(), t.classList.add("gradient-indicator"), document.body.appendChild(t), console.log("Gradient indicator added to the DOM");
|
|
1443
|
+
}
|
|
1444
|
+
function Ht() {
|
|
1445
|
+
const t = document.querySelector("#gradient-indicator");
|
|
1446
|
+
t && (t.remove(), console.log("Gradient indicator removed from the DOM"));
|
|
1447
|
+
}
|
|
1448
|
+
class qt {
|
|
1449
|
+
constructor() {
|
|
1450
|
+
this.state = "idle", this.subscribers = [];
|
|
1451
|
+
}
|
|
1452
|
+
getState() {
|
|
1453
|
+
return this.state;
|
|
1454
|
+
}
|
|
1455
|
+
setState(e) {
|
|
1456
|
+
this.state = e, this.notifySubscribers(), console.log("State updated:", e), e === "listening" ? $t() : Ht();
|
|
1457
|
+
}
|
|
1458
|
+
// eslint-disable-next-line no-unused-vars
|
|
1459
|
+
subscribe(e) {
|
|
1460
|
+
this.subscribers.push(e);
|
|
1461
|
+
}
|
|
1462
|
+
notifySubscribers() {
|
|
1463
|
+
this.subscribers.forEach((e) => e(this.state));
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
class zt {
|
|
1467
|
+
constructor(e) {
|
|
1468
|
+
this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1, this.loadingEl = null, this.config = e, this.init();
|
|
1469
|
+
}
|
|
1470
|
+
init() {
|
|
1471
|
+
var n, i;
|
|
1472
|
+
if (this.container) return;
|
|
1473
|
+
this.injectOverlayStyles();
|
|
1474
|
+
const e = document.getElementById("foisit-overlay-container");
|
|
1475
|
+
if (e && e instanceof HTMLElement) {
|
|
1476
|
+
this.container = e, this.chatWindow = e.querySelector(".foisit-chat"), this.messagesContainer = e.querySelector(".foisit-messages"), this.input = e.querySelector("input.foisit-input"), ((n = this.config.floatingButton) == null ? void 0 : n.visible) !== !1 && !e.querySelector(".foisit-floating-btn") && this.renderFloatingButton(), this.chatWindow || this.renderChatWindow();
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
this.container = document.createElement("div"), this.container.id = "foisit-overlay-container", this.container.className = "foisit-overlay-container", document.body.appendChild(this.container), ((i = this.config.floatingButton) == null ? void 0 : i.visible) !== !1 && this.renderFloatingButton(), this.renderChatWindow();
|
|
1480
|
+
}
|
|
1481
|
+
renderFloatingButton() {
|
|
1482
|
+
var s, o, r, a, c, h;
|
|
1483
|
+
const e = document.createElement("button");
|
|
1484
|
+
e.innerHTML = ((s = this.config.floatingButton) == null ? void 0 : s.customHtml) || "🎙️";
|
|
1485
|
+
const n = ((r = (o = this.config.floatingButton) == null ? void 0 : o.position) == null ? void 0 : r.bottom) || "20px", i = ((c = (a = this.config.floatingButton) == null ? void 0 : a.position) == null ? void 0 : c.right) || "20px";
|
|
1486
|
+
e.className = "foisit-floating-btn", e.style.bottom = n, e.style.right = i, e.onclick = () => this.toggle(), e.onmouseenter = () => e.style.transform = "scale(1.05)", e.onmouseleave = () => e.style.transform = "scale(1)", (h = this.container) == null || h.appendChild(e);
|
|
1487
|
+
}
|
|
1488
|
+
renderChatWindow() {
|
|
1489
|
+
var o;
|
|
1490
|
+
if (this.chatWindow) return;
|
|
1491
|
+
this.chatWindow = document.createElement("div"), this.chatWindow.className = "foisit-chat";
|
|
1492
|
+
const e = document.createElement("div");
|
|
1493
|
+
e.className = "foisit-header";
|
|
1494
|
+
const n = document.createElement("span");
|
|
1495
|
+
n.className = "foisit-title", n.textContent = "Foisit";
|
|
1496
|
+
const i = document.createElement("button");
|
|
1497
|
+
i.type = "button", i.className = "foisit-close", i.setAttribute("aria-label", "Close"), i.innerHTML = "×", i.addEventListener("click", () => this.toggle()), e.appendChild(n), e.appendChild(i), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "foisit-messages";
|
|
1498
|
+
const s = document.createElement("div");
|
|
1499
|
+
s.className = "foisit-input-area", this.input = document.createElement("input"), this.input.placeholder = this.config.inputPlaceholder || "Type a command...", this.input.className = "foisit-input", this.input.addEventListener("keydown", (r) => {
|
|
1500
|
+
var a;
|
|
1501
|
+
if (r.key === "Enter" && ((a = this.input) != null && a.value.trim())) {
|
|
1502
|
+
const c = this.input.value.trim();
|
|
1503
|
+
this.input.value = "", this.onSubmit && this.onSubmit(c);
|
|
1504
|
+
}
|
|
1505
|
+
}), s.appendChild(this.input), this.chatWindow.appendChild(e), this.chatWindow.appendChild(this.messagesContainer), this.chatWindow.appendChild(s), (o = this.container) == null || o.appendChild(this.chatWindow);
|
|
1506
|
+
}
|
|
1507
|
+
registerCallbacks(e, n) {
|
|
1508
|
+
this.onSubmit = e, this.onClose = n;
|
|
1509
|
+
}
|
|
1510
|
+
toggle(e, n) {
|
|
1511
|
+
e && (this.onSubmit = e), n && (this.onClose = n), this.isOpen = !this.isOpen, this.chatWindow && (this.isOpen ? (this.chatWindow.style.display = "flex", requestAnimationFrame(() => {
|
|
1512
|
+
this.chatWindow && (this.chatWindow.style.opacity = "1", this.chatWindow.style.transform = "translateY(0) scale(1)");
|
|
1513
|
+
}), setTimeout(() => {
|
|
1514
|
+
var i;
|
|
1515
|
+
return (i = this.input) == null ? void 0 : i.focus();
|
|
1516
|
+
}, 100)) : (this.chatWindow.style.opacity = "0", this.chatWindow.style.transform = "translateY(20px) scale(0.95)", setTimeout(() => {
|
|
1517
|
+
this.chatWindow && !this.isOpen && (this.chatWindow.style.display = "none");
|
|
1518
|
+
}, 200), this.onClose && this.onClose()));
|
|
1519
|
+
}
|
|
1520
|
+
addMessage(e, n) {
|
|
1521
|
+
if (!this.messagesContainer) return;
|
|
1522
|
+
const i = document.createElement("div");
|
|
1523
|
+
i.textContent = e, i.className = n === "user" ? "foisit-bubble user" : "foisit-bubble system", this.messagesContainer.appendChild(i), this.scrollToBottom();
|
|
1524
|
+
}
|
|
1525
|
+
addOptions(e) {
|
|
1526
|
+
if (!this.messagesContainer) return;
|
|
1527
|
+
const n = document.createElement("div");
|
|
1528
|
+
n.className = "foisit-options-container", e.forEach((i) => {
|
|
1529
|
+
const s = document.createElement("button");
|
|
1530
|
+
s.textContent = i.label, s.className = "foisit-option-chip", s.setAttribute("type", "button"), s.setAttribute("aria-label", i.label);
|
|
1531
|
+
const o = () => {
|
|
1532
|
+
if (i.commandId) {
|
|
1533
|
+
this.onSubmit && this.onSubmit({ commandId: i.commandId });
|
|
1534
|
+
return;
|
|
1535
|
+
}
|
|
1536
|
+
const r = i && typeof i.value == "string" && i.value.trim() ? i.value : i.label;
|
|
1537
|
+
this.onSubmit && this.onSubmit(r);
|
|
1538
|
+
};
|
|
1539
|
+
s.onclick = o, s.onkeydown = (r) => {
|
|
1540
|
+
(r.key === "Enter" || r.key === " ") && (r.preventDefault(), o());
|
|
1541
|
+
}, n.appendChild(s);
|
|
1542
|
+
}), this.messagesContainer.appendChild(n), this.scrollToBottom();
|
|
1543
|
+
}
|
|
1544
|
+
addForm(e, n, i) {
|
|
1545
|
+
if (!this.messagesContainer) return;
|
|
1546
|
+
this.addMessage(e, "system");
|
|
1547
|
+
const s = document.createElement("form");
|
|
1548
|
+
s.className = "foisit-form";
|
|
1549
|
+
const o = [], r = (d, l) => {
|
|
1550
|
+
const f = document.createElement("div");
|
|
1551
|
+
return f.className = "foisit-form-label", f.innerHTML = d + (l ? ' <span class="foisit-req-star">*</span>' : ""), f;
|
|
1552
|
+
}, a = () => {
|
|
1553
|
+
const d = document.createElement("div");
|
|
1554
|
+
return d.className = "foisit-form-error", d.style.display = "none", d;
|
|
1555
|
+
};
|
|
1556
|
+
(n ?? []).forEach((d) => {
|
|
1557
|
+
const l = document.createElement("div");
|
|
1558
|
+
l.className = "foisit-form-group";
|
|
1559
|
+
const f = d.description || d.name;
|
|
1560
|
+
l.appendChild(r(f, d.required));
|
|
1561
|
+
let m;
|
|
1562
|
+
if (d.type === "select") {
|
|
1563
|
+
const u = document.createElement("select");
|
|
1564
|
+
u.className = "foisit-form-input";
|
|
1565
|
+
const v = document.createElement("option");
|
|
1566
|
+
v.value = "", v.textContent = "Select...", u.appendChild(v);
|
|
1567
|
+
const x = (p) => {
|
|
1568
|
+
(p ?? []).forEach((S) => {
|
|
1569
|
+
const b = document.createElement("option");
|
|
1570
|
+
b.value = String(S.value ?? S.label ?? ""), b.textContent = String(S.label ?? S.value ?? ""), u.appendChild(b);
|
|
1571
|
+
});
|
|
1572
|
+
};
|
|
1573
|
+
if (Array.isArray(d.options) && d.options.length)
|
|
1574
|
+
x(d.options);
|
|
1575
|
+
else if (typeof d.getOptions == "function") {
|
|
1576
|
+
const p = d.getOptions, S = document.createElement("option");
|
|
1577
|
+
S.value = "", S.textContent = "Loading...", u.appendChild(S), Promise.resolve().then(() => p()).then((b) => {
|
|
1578
|
+
for (; u.options.length > 1; ) u.remove(1);
|
|
1579
|
+
x(b);
|
|
1580
|
+
}).catch(() => {
|
|
1581
|
+
for (; u.options.length > 1; ) u.remove(1);
|
|
1582
|
+
const b = document.createElement("option");
|
|
1583
|
+
b.value = "", b.textContent = "Error loading options", u.appendChild(b);
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
d.defaultValue != null && (u.value = String(d.defaultValue)), m = u;
|
|
1587
|
+
} else if (d.type === "file") {
|
|
1588
|
+
const u = d, v = document.createElement("input");
|
|
1589
|
+
v.className = "foisit-form-input", v.type = "file", u.accept && Array.isArray(u.accept) && (v.accept = u.accept.join(",")), u.multiple && (v.multiple = !0), u.capture && (u.capture === !0 ? v.setAttribute("capture", "") : v.setAttribute("capture", String(u.capture))), v.addEventListener("change", async () => {
|
|
1590
|
+
const x = Array.from(v.files || []), p = y;
|
|
1591
|
+
if (p.style.display = "none", p.textContent = "", x.length === 0) return;
|
|
1592
|
+
const S = u.maxFiles ?? (u.multiple ? 10 : 1);
|
|
1593
|
+
if (x.length > S) {
|
|
1594
|
+
p.textContent = `Please select at most ${S} file(s).`, p.style.display = "block";
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
const b = u.maxSizeBytes ?? 1 / 0, g = x.reduce((w, U) => w + U.size, 0);
|
|
1598
|
+
if (x.some((w) => w.size > b)) {
|
|
1599
|
+
p.textContent = `One or more files exceed the maximum size of ${Math.round(b / 1024)} KB.`, p.style.display = "block";
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
const $ = u.maxTotalBytes ?? 1 / 0;
|
|
1603
|
+
if (g > $) {
|
|
1604
|
+
p.textContent = `Total selected files exceed the maximum of ${Math.round($ / 1024)} KB.`, p.style.display = "block";
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
if (u.accept && Array.isArray(u.accept)) {
|
|
1608
|
+
const w = u.accept;
|
|
1609
|
+
if (!x.every((B) => B.type ? w.some((W) => W.startsWith(".") ? B.name.toLowerCase().endsWith(W.toLowerCase()) : B.type === W || B.type.startsWith(W.split("/")[0] + "/")) : !0)) {
|
|
1610
|
+
p.textContent = "One or more files have an unsupported type.", p.style.display = "block";
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}), m = v;
|
|
1615
|
+
} else {
|
|
1616
|
+
const u = document.createElement("input");
|
|
1617
|
+
u.className = "foisit-form-input", d.type === "string" && (u.placeholder = d.placeholder || "Type here..."), d.type === "number" ? (u.type = "number", typeof d.min == "number" && (u.min = String(d.min)), typeof d.max == "number" && (u.max = String(d.max)), typeof d.step == "number" && (u.step = String(d.step)), d.defaultValue != null && (u.value = String(d.defaultValue))) : d.type === "date" ? (u.type = "date", typeof d.min == "string" && (u.min = d.min), typeof d.max == "string" && (u.max = d.max), d.defaultValue != null && (u.value = String(d.defaultValue))) : (u.type = "text", d.defaultValue != null && (u.value = String(d.defaultValue))), m = u;
|
|
1618
|
+
}
|
|
1619
|
+
const y = a();
|
|
1620
|
+
l.appendChild(m), l.appendChild(y), o.push({
|
|
1621
|
+
name: d.name,
|
|
1622
|
+
type: d.type,
|
|
1623
|
+
el: m,
|
|
1624
|
+
required: d.required
|
|
1625
|
+
}), s.appendChild(l);
|
|
1626
|
+
});
|
|
1627
|
+
const c = document.createElement("div");
|
|
1628
|
+
c.className = "foisit-form-actions";
|
|
1629
|
+
const h = document.createElement("button");
|
|
1630
|
+
h.type = "submit", h.textContent = "Submit", h.className = "foisit-option-chip", h.style.fontWeight = "600", c.appendChild(h), s.appendChild(c), s.onsubmit = async (d) => {
|
|
1631
|
+
d.preventDefault();
|
|
1632
|
+
const l = {};
|
|
1633
|
+
let f = !1;
|
|
1634
|
+
s.querySelectorAll(".foisit-form-error").forEach((m) => {
|
|
1635
|
+
m.style.display = "none", m.textContent = "";
|
|
1636
|
+
}), s.querySelectorAll(".foisit-form-input").forEach((m) => {
|
|
1637
|
+
m.classList.remove("foisit-error-border");
|
|
1638
|
+
});
|
|
1639
|
+
for (const m of o) {
|
|
1640
|
+
if (m.type === "file") {
|
|
1641
|
+
const x = m.el.parentElement, p = x == null ? void 0 : x.querySelector(".foisit-form-error"), S = m.el, b = Array.from(S.files || []);
|
|
1642
|
+
if (m.required && b.length === 0) {
|
|
1643
|
+
f = !0, S.classList.add("foisit-error-border"), p && (p.textContent = "This file is required", p.style.display = "block");
|
|
1644
|
+
continue;
|
|
1645
|
+
}
|
|
1646
|
+
if (b.length === 0) continue;
|
|
1647
|
+
const g = (n ?? []).find((w) => w.name === m.name), $ = (g == null ? void 0 : g.delivery) ?? "file";
|
|
1648
|
+
if (g != null && g.maxWidth || g != null && g.maxHeight)
|
|
1649
|
+
try {
|
|
1650
|
+
const w = await this.getImageDimensions(b[0]);
|
|
1651
|
+
if (g.maxWidth && w.width > g.maxWidth) {
|
|
1652
|
+
f = !0, p && (p.textContent = `Image width must be ≤ ${g.maxWidth}px`, p.style.display = "block");
|
|
1653
|
+
continue;
|
|
1654
|
+
}
|
|
1655
|
+
if (g.maxHeight && w.height > g.maxHeight) {
|
|
1656
|
+
f = !0, p && (p.textContent = `Image height must be ≤ ${g.maxHeight}px`, p.style.display = "block");
|
|
1657
|
+
continue;
|
|
1658
|
+
}
|
|
1659
|
+
} catch {
|
|
1660
|
+
}
|
|
1661
|
+
if (g != null && g.maxDurationSec)
|
|
1662
|
+
try {
|
|
1663
|
+
const w = await this.getMediaDuration(b[0]);
|
|
1664
|
+
if (w && w > g.maxDurationSec) {
|
|
1665
|
+
f = !0, p && (p.textContent = `Media duration must be ≤ ${g.maxDurationSec}s`, p.style.display = "block");
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
} catch {
|
|
1669
|
+
}
|
|
1670
|
+
if ($ === "file")
|
|
1671
|
+
l[m.name] = g != null && g.multiple ? b : b[0];
|
|
1672
|
+
else if ($ === "base64")
|
|
1673
|
+
try {
|
|
1674
|
+
const w = await Promise.all(b.map((U) => this.readFileAsDataURL(U)));
|
|
1675
|
+
l[m.name] = g != null && g.multiple ? w : w[0];
|
|
1676
|
+
} catch {
|
|
1677
|
+
f = !0, p && (p.textContent = "Failed to encode file(s) to base64.", p.style.display = "block");
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
const y = (m.el.value ?? "").toString().trim(), u = m.el.parentElement, v = u == null ? void 0 : u.querySelector(".foisit-form-error");
|
|
1683
|
+
if (m.required && (y == null || y === "")) {
|
|
1684
|
+
f = !0, m.el.classList.add("foisit-error-border"), v && (v.textContent = "This field is required", v.style.display = "block");
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1687
|
+
if (y !== "")
|
|
1688
|
+
if (m.type === "number") {
|
|
1689
|
+
const x = Number(y);
|
|
1690
|
+
Number.isNaN(x) || (l[m.name] = x);
|
|
1691
|
+
} else
|
|
1692
|
+
l[m.name] = y;
|
|
1693
|
+
}
|
|
1694
|
+
if (f) {
|
|
1695
|
+
s.classList.add("foisit-shake"), setTimeout(() => s.classList.remove("foisit-shake"), 400);
|
|
1696
|
+
return;
|
|
1697
|
+
}
|
|
1698
|
+
h.disabled = !0, h.style.opacity = "0.6", o.forEach((m) => {
|
|
1699
|
+
m.el.disabled = !0;
|
|
1700
|
+
}), i(l);
|
|
1701
|
+
}, this.messagesContainer.appendChild(s), this.scrollToBottom();
|
|
1702
|
+
}
|
|
1703
|
+
showLoading() {
|
|
1704
|
+
if (this.messagesContainer && !this.loadingEl) {
|
|
1705
|
+
this.loadingEl = document.createElement("div"), this.loadingEl.className = "foisit-loading-dots foisit-bubble system";
|
|
1706
|
+
for (let e = 0; e < 3; e++) {
|
|
1707
|
+
const n = document.createElement("div");
|
|
1708
|
+
n.className = "foisit-dot", n.style.animation = `foisitPulse 1.4s infinite ease-in-out ${e * 0.2}s`, this.loadingEl.appendChild(n);
|
|
1709
|
+
}
|
|
1710
|
+
this.messagesContainer.appendChild(this.loadingEl), this.scrollToBottom();
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
hideLoading() {
|
|
1714
|
+
var e;
|
|
1715
|
+
(e = this.loadingEl) == null || e.remove(), this.loadingEl = null;
|
|
1716
|
+
}
|
|
1717
|
+
scrollToBottom() {
|
|
1718
|
+
this.messagesContainer && (this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight);
|
|
1719
|
+
}
|
|
1720
|
+
destroy() {
|
|
1721
|
+
var e;
|
|
1722
|
+
(e = this.container) == null || e.remove(), this.container = null, this.chatWindow = null, this.messagesContainer = null, this.input = null, this.isOpen = !1;
|
|
1723
|
+
}
|
|
1724
|
+
readFileAsDataURL(e) {
|
|
1725
|
+
return new Promise((n, i) => {
|
|
1726
|
+
const s = new FileReader();
|
|
1727
|
+
s.onerror = () => i(new Error("Failed to read file")), s.onload = () => n(String(s.result)), s.readAsDataURL(e);
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
getImageDimensions(e) {
|
|
1731
|
+
return new Promise((n) => {
|
|
1732
|
+
try {
|
|
1733
|
+
const i = URL.createObjectURL(e), s = new Image();
|
|
1734
|
+
s.onload = () => {
|
|
1735
|
+
const o = { width: s.naturalWidth || s.width, height: s.naturalHeight || s.height };
|
|
1736
|
+
URL.revokeObjectURL(i), n(o);
|
|
1737
|
+
}, s.onerror = () => {
|
|
1738
|
+
URL.revokeObjectURL(i), n({ width: 0, height: 0 });
|
|
1739
|
+
}, s.src = i;
|
|
1740
|
+
} catch {
|
|
1741
|
+
n({ width: 0, height: 0 });
|
|
1742
|
+
}
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
getMediaDuration(e) {
|
|
1746
|
+
return new Promise((n) => {
|
|
1747
|
+
try {
|
|
1748
|
+
const i = URL.createObjectURL(e), s = e.type.startsWith("audio") ? document.createElement("audio") : document.createElement("video");
|
|
1749
|
+
let o = !1;
|
|
1750
|
+
const r = setTimeout(() => {
|
|
1751
|
+
o || (o = !0, URL.revokeObjectURL(i), n(0));
|
|
1752
|
+
}, 5e3);
|
|
1753
|
+
s.preload = "metadata", s.onloadedmetadata = () => {
|
|
1754
|
+
if (o) return;
|
|
1755
|
+
o = !0, clearTimeout(r);
|
|
1756
|
+
const c = s.duration || 0;
|
|
1757
|
+
URL.revokeObjectURL(i), n(c);
|
|
1758
|
+
}, s.onerror = () => {
|
|
1759
|
+
o || (o = !0, clearTimeout(r), URL.revokeObjectURL(i), n(0));
|
|
1760
|
+
}, s.src = i;
|
|
1761
|
+
} catch {
|
|
1762
|
+
n(0);
|
|
1763
|
+
}
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
injectOverlayStyles() {
|
|
1767
|
+
if (document.getElementById("foisit-overlay-styles")) return;
|
|
1768
|
+
const e = document.createElement("style");
|
|
1769
|
+
e.id = "foisit-overlay-styles", e.textContent = `
|
|
1770
|
+
:root {
|
|
1771
|
+
/* LIGHT MODE (Default) - Smoother gradient */
|
|
1772
|
+
/* Changed: Softer, right-focused radial highlight to avoid a heavy white bottom */
|
|
1773
|
+
--foisit-bg: radial-gradient(ellipse at 75% 30%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.03));
|
|
1774
|
+
--foisit-border: 1px solid rgba(255, 255, 255, 0.25);
|
|
1775
|
+
--foisit-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
|
|
1776
|
+
--foisit-text: #333;
|
|
1777
|
+
|
|
1778
|
+
/* Input */
|
|
1779
|
+
--foisit-input-color: #333;
|
|
1780
|
+
--foisit-input-placeholder: rgba(60, 60, 67, 0.6);
|
|
1781
|
+
|
|
1782
|
+
/* Bubbles */
|
|
1783
|
+
--foisit-bubble-user-bg: rgba(0, 0, 0, 0.04);
|
|
1784
|
+
--foisit-bubble-user-text: #333;
|
|
1785
|
+
|
|
1786
|
+
--foisit-bubble-sys-bg: rgba(255, 255, 255, 0.45);
|
|
1787
|
+
--foisit-bubble-sys-text: #333;
|
|
1788
|
+
|
|
1789
|
+
/* Form Colors */
|
|
1790
|
+
--foisit-req-star: #ef4444; /* Red asterisk */
|
|
1791
|
+
--foisit-error-text: #dc2626;
|
|
1792
|
+
--foisit-error-border: #fca5a5;
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
@media (prefers-color-scheme: dark) {
|
|
1796
|
+
:root {
|
|
1797
|
+
/* DARK MODE */
|
|
1798
|
+
--foisit-bg: linear-gradient(135deg, rgba(40, 40, 40, 0.65), rgba(40, 40, 40, 0.25));
|
|
1799
|
+
--foisit-border: 1px solid rgba(255, 255, 255, 0.1);
|
|
1800
|
+
--foisit-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
|
|
1801
|
+
--foisit-text: #fff;
|
|
1802
|
+
|
|
1803
|
+
/* Input */
|
|
1804
|
+
--foisit-input-color: white;
|
|
1805
|
+
--foisit-input-placeholder: rgba(235, 235, 245, 0.5);
|
|
1806
|
+
|
|
1807
|
+
/* Bubbles */
|
|
1808
|
+
--foisit-bubble-user-bg: rgba(255, 255, 255, 0.1);
|
|
1809
|
+
--foisit-bubble-user-text: white;
|
|
1810
|
+
|
|
1811
|
+
--foisit-bubble-sys-bg: rgba(255, 255, 255, 0.05);
|
|
1812
|
+
--foisit-bubble-sys-text: rgba(255, 255, 255, 0.9);
|
|
1813
|
+
|
|
1814
|
+
/* Form Colors */
|
|
1815
|
+
--foisit-req-star: #f87171;
|
|
1816
|
+
--foisit-error-text: #fca5a5;
|
|
1817
|
+
--foisit-error-border: #f87171;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
@keyframes foisitPulse {
|
|
1822
|
+
0%, 100% { transform: scale(0.8); opacity: 0.5; }
|
|
1823
|
+
50% { transform: scale(1.2); opacity: 1; }
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
@keyframes foisitShake {
|
|
1827
|
+
0%, 100% { transform: translateX(0); }
|
|
1828
|
+
25% { transform: translateX(-4px); }
|
|
1829
|
+
75% { transform: translateX(4px); }
|
|
1830
|
+
}
|
|
1831
|
+
.foisit-shake { animation: foisitShake 0.4s ease-in-out; }
|
|
1832
|
+
|
|
1833
|
+
/* Container */
|
|
1834
|
+
.foisit-overlay-container {
|
|
1835
|
+
position: fixed;
|
|
1836
|
+
inset: 0;
|
|
1837
|
+
z-index: 2147483647;
|
|
1838
|
+
pointer-events: none;
|
|
1839
|
+
display: flex;
|
|
1840
|
+
flex-direction: column;
|
|
1841
|
+
justify-content: flex-end;
|
|
1842
|
+
align-items: flex-end;
|
|
1843
|
+
padding: 20px;
|
|
1844
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
.foisit-overlay-container * {
|
|
1848
|
+
box-sizing: border-box;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
/* Chat Window - Dynamic Height */
|
|
1852
|
+
.foisit-chat {
|
|
1853
|
+
position: absolute;
|
|
1854
|
+
top: 20px;
|
|
1855
|
+
right: 20px;
|
|
1856
|
+
width: min(420px, 92vw);
|
|
1857
|
+
|
|
1858
|
+
/* FIX: Auto height to prevent empty space */
|
|
1859
|
+
height: auto;
|
|
1860
|
+
min-height: 120px;
|
|
1861
|
+
max-height: 80vh;
|
|
1862
|
+
|
|
1863
|
+
background: var(--foisit-bg);
|
|
1864
|
+
border: var(--foisit-border);
|
|
1865
|
+
box-shadow: var(--foisit-shadow);
|
|
1866
|
+
|
|
1867
|
+
backdrop-filter: blur(20px);
|
|
1868
|
+
-webkit-backdrop-filter: blur(20px);
|
|
1869
|
+
|
|
1870
|
+
border-radius: 18px;
|
|
1871
|
+
display: none;
|
|
1872
|
+
flex-direction: column;
|
|
1873
|
+
overflow: hidden;
|
|
1874
|
+
pointer-events: auto;
|
|
1875
|
+
transform-origin: top right;
|
|
1876
|
+
transition: opacity 0.2s, transform 0.2s cubic-bezier(0.2, 0.9, 0.2, 1);
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
.foisit-header {
|
|
1880
|
+
display: flex;
|
|
1881
|
+
align-items: center;
|
|
1882
|
+
justify-content: space-between;
|
|
1883
|
+
padding: 12px 16px;
|
|
1884
|
+
font-weight: 600;
|
|
1885
|
+
font-size: 14px;
|
|
1886
|
+
color: var(--foisit-text);
|
|
1887
|
+
border-bottom: 1px solid rgba(127,127,127,0.08); /* Subtle separator */
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
.foisit-close {
|
|
1891
|
+
background: transparent;
|
|
1892
|
+
border: none;
|
|
1893
|
+
color: var(--foisit-text);
|
|
1894
|
+
opacity: 0.5;
|
|
1895
|
+
font-size: 24px;
|
|
1896
|
+
line-height: 1;
|
|
1897
|
+
cursor: pointer;
|
|
1898
|
+
padding: 0;
|
|
1899
|
+
width: 28px;
|
|
1900
|
+
height: 28px;
|
|
1901
|
+
display: flex;
|
|
1902
|
+
align-items: center;
|
|
1903
|
+
justify-content: center;
|
|
1904
|
+
transition: opacity 0.2s;
|
|
1905
|
+
}
|
|
1906
|
+
.foisit-close:hover { opacity: 1; }
|
|
1907
|
+
|
|
1908
|
+
/* Message Area */
|
|
1909
|
+
.foisit-messages {
|
|
1910
|
+
flex: 1;
|
|
1911
|
+
overflow-y: auto;
|
|
1912
|
+
padding: 16px;
|
|
1913
|
+
display: flex;
|
|
1914
|
+
flex-direction: column;
|
|
1915
|
+
gap: 10px;
|
|
1916
|
+
/* Ensure it doesn't get too tall initially */
|
|
1917
|
+
min-height: 60px;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
/* Make sure empty state isn't huge */
|
|
1921
|
+
.foisit-messages:empty {
|
|
1922
|
+
display: none;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/* Only show messages container if it has children */
|
|
1926
|
+
.foisit-messages:not(:empty) {
|
|
1927
|
+
display: flex;
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
/* Bubbles */
|
|
1931
|
+
.foisit-bubble {
|
|
1932
|
+
max-width: 90%;
|
|
1933
|
+
padding: 8px 14px;
|
|
1934
|
+
border-radius: 14px;
|
|
1935
|
+
font-size: 14px;
|
|
1936
|
+
line-height: 1.4;
|
|
1937
|
+
word-wrap: break-word;
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
.foisit-bubble.user {
|
|
1941
|
+
align-self: flex-end;
|
|
1942
|
+
background: var(--foisit-bubble-user-bg);
|
|
1943
|
+
color: var(--foisit-bubble-user-text);
|
|
1944
|
+
border-bottom-right-radius: 4px;
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
.foisit-bubble.system {
|
|
1948
|
+
align-self: flex-start;
|
|
1949
|
+
background: var(--foisit-bubble-sys-bg);
|
|
1950
|
+
color: var(--foisit-bubble-sys-text);
|
|
1951
|
+
border-bottom-left-radius: 4px;
|
|
1952
|
+
border: 1px solid rgba(255,255,255,0.1);
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
/* Input Area */
|
|
1956
|
+
.foisit-input-area {
|
|
1957
|
+
padding: 0;
|
|
1958
|
+
width: 100%;
|
|
1959
|
+
border-top: 1px solid rgba(127,127,127,0.08);
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1962
|
+
.foisit-input {
|
|
1963
|
+
width: 100%;
|
|
1964
|
+
background: transparent;
|
|
1965
|
+
border: none;
|
|
1966
|
+
font-size: 16px;
|
|
1967
|
+
color: var(--foisit-input-color);
|
|
1968
|
+
padding: 16px 20px;
|
|
1969
|
+
outline: none;
|
|
1970
|
+
text-align: left;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
.foisit-input::placeholder {
|
|
1974
|
+
color: var(--foisit-input-placeholder);
|
|
1975
|
+
font-weight: 400;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/* Options & Buttons */
|
|
1979
|
+
.foisit-options-container {
|
|
1980
|
+
display: flex;
|
|
1981
|
+
flex-wrap: wrap;
|
|
1982
|
+
gap: 8px;
|
|
1983
|
+
margin-left: 2px;
|
|
1984
|
+
margin-top: 4px;
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
.foisit-option-chip {
|
|
1988
|
+
padding: 6px 14px;
|
|
1989
|
+
background: var(--foisit-bubble-sys-bg);
|
|
1990
|
+
border: 1px solid rgba(127,127,127,0.1);
|
|
1991
|
+
border-radius: 20px;
|
|
1992
|
+
font-size: 13px;
|
|
1993
|
+
color: var(--foisit-text);
|
|
1994
|
+
cursor: pointer;
|
|
1995
|
+
transition: all 0.2s;
|
|
1996
|
+
font-weight: 500;
|
|
1997
|
+
}
|
|
1998
|
+
.foisit-option-chip:hover {
|
|
1999
|
+
background: rgba(127,127,127,0.15);
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
/* Form Styling */
|
|
2003
|
+
.foisit-form {
|
|
2004
|
+
background: var(--foisit-bubble-sys-bg);
|
|
2005
|
+
padding: 16px;
|
|
2006
|
+
border-radius: 14px;
|
|
2007
|
+
display: flex;
|
|
2008
|
+
flex-direction: column;
|
|
2009
|
+
gap: 12px;
|
|
2010
|
+
width: 100%;
|
|
2011
|
+
border: 1px solid rgba(127,127,127,0.1);
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
.foisit-form-label {
|
|
2015
|
+
font-size: 12px;
|
|
2016
|
+
font-weight: 600;
|
|
2017
|
+
color: var(--foisit-text);
|
|
2018
|
+
opacity: 0.9;
|
|
2019
|
+
margin-bottom: 2px;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
.foisit-req-star {
|
|
2023
|
+
color: var(--foisit-req-star);
|
|
2024
|
+
font-weight: bold;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
.foisit-form-input {
|
|
2028
|
+
width: 100%;
|
|
2029
|
+
padding: 10px;
|
|
2030
|
+
border-radius: 8px;
|
|
2031
|
+
border: 1px solid rgba(127,127,127,0.2);
|
|
2032
|
+
background: rgba(255,255,255,0.05); /* Very subtle fill */
|
|
2033
|
+
color: var(--foisit-text);
|
|
2034
|
+
font-size: 14px;
|
|
2035
|
+
outline: none;
|
|
2036
|
+
transition: border 0.2s;
|
|
2037
|
+
}
|
|
2038
|
+
.foisit-form-input:focus {
|
|
2039
|
+
border-color: var(--foisit-text);
|
|
2040
|
+
background: rgba(255,255,255,0.1);
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
.foisit-error-border {
|
|
2044
|
+
border-color: var(--foisit-error-border) !important;
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
.foisit-form-error {
|
|
2048
|
+
font-size: 11px;
|
|
2049
|
+
color: var(--foisit-error-text);
|
|
2050
|
+
margin-top: 4px;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
/* Loading */
|
|
2054
|
+
.foisit-loading-dots {
|
|
2055
|
+
display: inline-flex;
|
|
2056
|
+
gap: 4px;
|
|
2057
|
+
padding: 10px 14px;
|
|
2058
|
+
align-self: flex-start;
|
|
2059
|
+
}
|
|
2060
|
+
.foisit-dot {
|
|
2061
|
+
width: 6px;
|
|
2062
|
+
height: 6px;
|
|
2063
|
+
border-radius: 50%;
|
|
2064
|
+
background: var(--foisit-text);
|
|
2065
|
+
opacity: 0.4;
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
/* Floating Button */
|
|
2069
|
+
.foisit-floating-btn {
|
|
2070
|
+
position: absolute;
|
|
2071
|
+
width: 56px;
|
|
2072
|
+
height: 56px;
|
|
2073
|
+
border-radius: 50%;
|
|
2074
|
+
border: 1px solid rgba(255,255,255,0.2);
|
|
2075
|
+
background: var(--foisit-bg);
|
|
2076
|
+
color: var(--foisit-text);
|
|
2077
|
+
backdrop-filter: blur(10px);
|
|
2078
|
+
-webkit-backdrop-filter: blur(10px);
|
|
2079
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
|
2080
|
+
cursor: pointer;
|
|
2081
|
+
pointer-events: auto;
|
|
2082
|
+
display: flex;
|
|
2083
|
+
align-items: center;
|
|
2084
|
+
justify-content: center;
|
|
2085
|
+
font-size: 24px;
|
|
2086
|
+
z-index: 100000;
|
|
2087
|
+
transition: transform 0.2s;
|
|
2088
|
+
}
|
|
2089
|
+
.foisit-floating-btn:hover { transform: scale(1.05); }
|
|
2090
|
+
`, document.head.appendChild(e);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
class Ut {
|
|
2094
|
+
constructor(e) {
|
|
2095
|
+
this.config = e, this.isActivated = !1, this.lastProcessedInput = "", this.processingLock = !1, this.defaultIntroMessage = "How can I help you?", this.commandHandler = new Mt({
|
|
2096
|
+
enableSmartIntent: this.config.enableSmartIntent !== !1,
|
|
2097
|
+
intentEndpoint: this.config.intentEndpoint
|
|
2098
|
+
}), this.fallbackHandler = new Pt(), this.voiceProcessor = new Vt(), this.textToSpeech = new He(), this.stateManager = new qt(), this.gestureHandler = new Ft(), this.overlayManager = new zt({
|
|
2099
|
+
floatingButton: this.config.floatingButton,
|
|
2100
|
+
inputPlaceholder: this.config.inputPlaceholder
|
|
2101
|
+
}), this.config.commands.forEach((n) => this.commandHandler.addCommand(n)), this.config.fallbackResponse && this.fallbackHandler.setFallbackMessage(this.config.fallbackResponse), this.gestureHandler.setupDoubleTapListener(() => this.toggle()), this.overlayManager.registerCallbacks(
|
|
2102
|
+
async (n) => {
|
|
2103
|
+
if (typeof n == "string")
|
|
2104
|
+
this.overlayManager.addMessage(n, "user");
|
|
2105
|
+
else if (n && typeof n == "object") {
|
|
2106
|
+
const i = this.extractUserLabel(n);
|
|
2107
|
+
i && this.overlayManager.addMessage(i, "user");
|
|
2108
|
+
}
|
|
2109
|
+
await this.handleCommand(n);
|
|
2110
|
+
},
|
|
2111
|
+
() => console.log("AssistantService: Overlay closed.")
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
2114
|
+
/** Start listening for activation and commands */
|
|
2115
|
+
startListening() {
|
|
2116
|
+
console.log("AssistantService: Voice is disabled; startListening() is a no-op.");
|
|
2117
|
+
}
|
|
2118
|
+
/** Stop listening */
|
|
2119
|
+
stopListening() {
|
|
2120
|
+
console.log("AssistantService: Voice is disabled; stopListening() is a no-op."), this.isActivated = !1;
|
|
2121
|
+
}
|
|
2122
|
+
/** Reset activation state so the next activation flow can occur. */
|
|
2123
|
+
reactivate() {
|
|
2124
|
+
console.log("AssistantService: Reactivating assistant..."), this.isActivated = !1;
|
|
2125
|
+
try {
|
|
2126
|
+
this.startListening();
|
|
2127
|
+
} catch {
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
/** Process activation command */
|
|
2131
|
+
async processActivation(e) {
|
|
2132
|
+
var i;
|
|
2133
|
+
const n = (i = this.config.activationCommand) == null ? void 0 : i.toLowerCase();
|
|
2134
|
+
n && (e === n ? (console.log("AssistantService: Activation matched."), this.isActivated = !0, this.textToSpeech.speak(
|
|
2135
|
+
this.config.introMessage || this.defaultIntroMessage
|
|
2136
|
+
)) : console.log("AssistantService: Activation command not recognized."));
|
|
2137
|
+
}
|
|
2138
|
+
/** Handle recognized commands */
|
|
2139
|
+
async handleCommand(e) {
|
|
2140
|
+
this.overlayManager.showLoading();
|
|
2141
|
+
let n;
|
|
2142
|
+
try {
|
|
2143
|
+
n = await this.commandHandler.executeCommand(e);
|
|
2144
|
+
} finally {
|
|
2145
|
+
this.overlayManager.hideLoading();
|
|
2146
|
+
}
|
|
2147
|
+
if (n.type === "form" && n.fields) {
|
|
2148
|
+
this.overlayManager.addForm(
|
|
2149
|
+
n.message,
|
|
2150
|
+
n.fields,
|
|
2151
|
+
async (i) => {
|
|
2152
|
+
this.overlayManager.showLoading();
|
|
2153
|
+
let s;
|
|
2154
|
+
try {
|
|
2155
|
+
s = await this.commandHandler.executeCommand(i);
|
|
2156
|
+
} finally {
|
|
2157
|
+
this.overlayManager.hideLoading();
|
|
2158
|
+
}
|
|
2159
|
+
this.processResponse(s);
|
|
2160
|
+
}
|
|
2161
|
+
);
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
if (n.type === "error") {
|
|
2165
|
+
const i = typeof e == "string" ? e : "";
|
|
2166
|
+
i ? (this.fallbackHandler.handleFallback(i), this.overlayManager.addMessage(this.fallbackHandler.getFallbackMessage(), "system")) : n.message && this.overlayManager.addMessage(n.message, "system");
|
|
2167
|
+
return;
|
|
2168
|
+
}
|
|
2169
|
+
if ((n.type === "ambiguous" || n.type === "confirm") && n.options) {
|
|
2170
|
+
n.message && this.overlayManager.addMessage(n.message, "system"), this.overlayManager.addOptions(n.options);
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
n.message && this.overlayManager.addMessage(n.message, "system");
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Cleanup resources
|
|
2177
|
+
*/
|
|
2178
|
+
destroy() {
|
|
2179
|
+
this.voiceProcessor.stopListening(), this.gestureHandler.destroy(), this.overlayManager.destroy();
|
|
2180
|
+
}
|
|
2181
|
+
/** Unified response processing */
|
|
2182
|
+
processResponse(e) {
|
|
2183
|
+
if (e.type === "form" && e.fields) {
|
|
2184
|
+
this.overlayManager.addForm(
|
|
2185
|
+
e.message,
|
|
2186
|
+
e.fields,
|
|
2187
|
+
async (n) => {
|
|
2188
|
+
this.overlayManager.showLoading();
|
|
2189
|
+
let i;
|
|
2190
|
+
try {
|
|
2191
|
+
i = await this.commandHandler.executeCommand(n);
|
|
2192
|
+
} finally {
|
|
2193
|
+
this.overlayManager.hideLoading();
|
|
2194
|
+
}
|
|
2195
|
+
this.processResponse(i);
|
|
2196
|
+
}
|
|
2197
|
+
);
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
if ((e.type === "ambiguous" || e.type === "confirm") && e.options) {
|
|
2201
|
+
e.message && this.overlayManager.addMessage(e.message, "system"), this.overlayManager.addOptions(e.options);
|
|
2202
|
+
return;
|
|
2203
|
+
}
|
|
2204
|
+
e.message && this.overlayManager.addMessage(e.message, "system");
|
|
2205
|
+
}
|
|
2206
|
+
/** Add a command dynamically (supports string or rich object) */
|
|
2207
|
+
addCommand(e, n) {
|
|
2208
|
+
console.log(typeof e == "string" ? `AssistantService: Adding command "${e}".` : `AssistantService: Adding rich command "${e.command}".`), this.commandHandler.addCommand(e, n);
|
|
2209
|
+
}
|
|
2210
|
+
/** Remove a command dynamically */
|
|
2211
|
+
removeCommand(e) {
|
|
2212
|
+
console.log(`AssistantService: Removing command "${e}".`), this.commandHandler.removeCommand(e);
|
|
2213
|
+
}
|
|
2214
|
+
/** Get all registered commands */
|
|
2215
|
+
getCommands() {
|
|
2216
|
+
return this.commandHandler.getCommands();
|
|
2217
|
+
}
|
|
2218
|
+
/** Toggle the assistant overlay */
|
|
2219
|
+
toggle(e, n) {
|
|
2220
|
+
console.log("AssistantService: Toggling overlay..."), this.overlayManager.toggle(
|
|
2221
|
+
async (i) => {
|
|
2222
|
+
if (typeof i == "string")
|
|
2223
|
+
this.overlayManager.addMessage(i, "user");
|
|
2224
|
+
else if (i && typeof i == "object") {
|
|
2225
|
+
const s = this.extractUserLabel(i);
|
|
2226
|
+
s && this.overlayManager.addMessage(s, "user");
|
|
2227
|
+
}
|
|
2228
|
+
e && e(i), await this.handleCommand(i);
|
|
2229
|
+
},
|
|
2230
|
+
() => {
|
|
2231
|
+
console.log("AssistantService: Overlay closed."), n && n();
|
|
2232
|
+
}
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
extractUserLabel(e) {
|
|
2236
|
+
const n = e.label;
|
|
2237
|
+
if (typeof n == "string" && n.trim()) return n.trim();
|
|
2238
|
+
const i = e.commandId;
|
|
2239
|
+
return typeof i == "string" && i.trim() ? i.trim() : null;
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
const Bt = /* @__PURE__ */ mt({
|
|
2243
|
+
name: "AssistantProvider",
|
|
2244
|
+
props: {
|
|
2245
|
+
config: {
|
|
2246
|
+
type: Object,
|
|
2247
|
+
required: !0
|
|
2248
|
+
}
|
|
2249
|
+
},
|
|
2250
|
+
setup(t, { slots: e }) {
|
|
2251
|
+
const n = new Ut(t.config);
|
|
2252
|
+
return dt("assistantService", n), () => {
|
|
2253
|
+
var i;
|
|
2254
|
+
return (i = e.default) == null ? void 0 : i.call(e);
|
|
2255
|
+
};
|
|
2256
|
+
}
|
|
2257
|
+
}), Wt = (t, e) => {
|
|
2258
|
+
const n = t.__vccOpts || t;
|
|
2259
|
+
for (const [i, s] of e)
|
|
2260
|
+
n[i] = s;
|
|
2261
|
+
return n;
|
|
2262
|
+
};
|
|
2263
|
+
function jt(t, e, n, i, s, o) {
|
|
2264
|
+
return gt(t.$slots, "default");
|
|
2265
|
+
}
|
|
2266
|
+
const Kt = /* @__PURE__ */ Wt(Bt, [["render", jt]]), Yt = () => {
|
|
2267
|
+
const t = ut("assistantService");
|
|
2268
|
+
if (!t)
|
|
2269
|
+
throw new Error("useAssistant must be used within an AssistantProvider");
|
|
2270
|
+
return t;
|
|
2271
|
+
};
|
|
2272
|
+
export {
|
|
2273
|
+
Kt as AssistantProvider,
|
|
2274
|
+
Ut as AssistantService,
|
|
2275
|
+
Yt as useAssistant
|
|
2276
|
+
};
|