@foisit/vue-wrapper 2.4.4 → 3.0.0

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