@aintela/chat 0.4.32 → 0.4.34

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.
@@ -27,8 +27,13 @@ export type PredictionItem = {
27
27
  * followed on 2026-09-11 for the same reason: the two-category dropdown was the last thing that still opened by
28
28
  * itself. Accepting THAT one inserts no character — it opens the list, and the character follows from the row the
29
29
  * user picks (a place becomes `@`, a date `#`).
30
+ *
31
+ * `'locationOrPerson'` (2026-10-04) is the `@` analogue of `'mixed'`: the server expects a place AND a person at the
32
+ * same caret ("Solicitar uma viagem para o |" — a destination, or whom the trip is for). One trigger serves both,
33
+ * so it inserts `@` like any place cue; the ghost only has to SAY both, and the picker has to SHOW both (see
34
+ * `personOrPlace`).
30
35
  */
31
- export type GhostKind = 'location' | 'places' | 'hotelname' | 'person' | 'date' | 'mixed';
36
+ export type GhostKind = 'location' | 'places' | 'hotelname' | 'person' | 'date' | 'mixed' | 'locationOrPerson';
32
37
  /** A Data row for the `@` picker (see `slotDateOptions`). Shaped as a trigger row so a host can splice it in. */
33
38
  export type SlotDateOption = {
34
39
  id: string;
@@ -147,6 +152,7 @@ export declare function usePromptAssist(adapter: PromptAssistAdapter, fetchers:
147
152
  vertical: SearchVertical;
148
153
  hotelNameExpected: boolean;
149
154
  hotelNameConfidence: number;
155
+ personOrPlace: boolean;
150
156
  scheduleAssist: (value: string, caret: number, isDeletion: boolean) => void;
151
157
  commit: (finalText: string) => void;
152
158
  onKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => boolean;
@@ -7,6 +7,9 @@ export type MentionGroup = 'person' | 'location' | 'hotel';
7
7
  export type AtMentionItem = PromptTriggerItem & {
8
8
  group?: MentionGroup;
9
9
  };
10
+ /** How many rows the LEADING section keeps when a slot reads as a place AND a person (`capLeading`): few enough
11
+ * that the other section's first rows are inside a ~5-row dropdown (Ciro, 2026-10-04). Typing narrows both. */
12
+ export declare const PERSON_OR_PLACE_LEAD_ROWS = 3;
10
13
  /** Which vertical the location source should search (issue #876): 'hotel' → hotel places (POIs, addresses,
11
14
  * landmarks — TripApi /hotel/locations/search), 'air' → airports/cities as before. From the server's hotel-intent
12
15
  * head via the analyze pass — never re-decided client-side. */
@@ -68,6 +71,11 @@ export interface AtMentionOptions {
68
71
  hotelNameConfidence?: number;
69
72
  /** Aborted when the query is superseded; handed to both sources. */
70
73
  signal?: AbortSignal;
74
+ /** Keep only this many rows of the LEADING source, so the other section is in view (2026-10-04). Hosts set it
75
+ * when the slot reads as a place AND a person (`usePromptAssist().personOrPlace`): ordering alone put the
76
+ * directory under every location row — 8 airports, 5 places, 3 hotel names — below a ~5-row dropdown. The
77
+ * trailing source is not cut: it is the one the cap exists to bring into view. Undefined = no cap. */
78
+ capLeading?: number;
71
79
  /** Called with the merged list every time a source (or part of one, via `onPartial`) lands, so the host can
72
80
  * draw rows as they arrive rather than when the slowest source answers. Never called after `signal` aborts. */
73
81
  onUpdate?: (items: AtMentionItem[]) => void;
@@ -89,6 +97,6 @@ export interface AtMentionOptions {
89
97
  * do that: nothing is drawn above rows already drawn. The returned promise still resolves once, with the complete
90
98
  * list, for hosts that don't stream.
91
99
  */
92
- export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical, hotelConfidence, hotelNameConfidence, signal, onUpdate, byPriority }?: AtMentionOptions): Promise<AtMentionItem[]>;
100
+ export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold, vertical, hotelConfidence, hotelNameConfidence, signal, onUpdate, byPriority, capLeading }?: AtMentionOptions): Promise<AtMentionItem[]>;
93
101
  /** True when `items[idx]` opens a new `@` section (its group differs from the previous item's). */
94
102
  export declare function isSectionStart(items: AtMentionItem[], idx: number): boolean;
@@ -17,7 +17,7 @@ export { placeCaret } from './placeCaret';
17
17
  export { swallowNextClick } from './swallowNextClick';
18
18
  export { detectTrigger, applyTriggerInsertion, findPlaceholder, placeholderAt, activatePlaceholder, advanceToPlaceholder, } from './promptTriggers';
19
19
  export type { TriggerChar, ActiveTrigger, TriggerInsertion, TemplatePlaceholder, MentionKind } from './promptTriggers';
20
- export { fetchAtMentions, isSectionStart } from './atMentions';
20
+ export { fetchAtMentions, isSectionStart, PERSON_OR_PLACE_LEAD_ROWS } from './atMentions';
21
21
  export type { AtMentionItem, MentionGroup, AtMentionFetchers, AtMentionOptions, AtQueryContext, AtPersonQueryContext, AtQueryVertical } from './atMentions';
22
22
  export { toPredictionRows } from './predictionRows';
23
23
  export type { PredictionRow } from './predictionRows';
@@ -0,0 +1,410 @@
1
+ var qt = Object.defineProperty;
2
+ var h = (t, p) => qt(t, "name", { value: p, configurable: !0 });
3
+ import { useRef as i, useEffect as re, useCallback as D, useState as d } from "react";
4
+ import { d as Nt } from "./promptTriggers-xwMJ5gRj.js";
5
+ function jt(t, p) {
6
+ const f = i(null), y = i(t);
7
+ y.current = t, re(() => {
8
+ const g = f.current;
9
+ if (g === null) return;
10
+ const k = t.findIndex((H) => H.id === g);
11
+ k < 0 && (f.current = null), p(Math.max(k, 0));
12
+ }, [t]);
13
+ const C = D((g) => {
14
+ var k;
15
+ f.current = ((k = y.current[g]) == null ? void 0 : k.id) ?? null, p(g);
16
+ }, [p]), c = D(() => {
17
+ f.current = null;
18
+ }, []);
19
+ return { pin: C, unpin: c };
20
+ }
21
+ h(jt, "useStickyHighlight");
22
+ const Ve = /* @__PURE__ */ h((t) => t.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), "foldForCompare"), Xe = /* @__PURE__ */ h((t) => t.normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").toLowerCase().replace(/\s+/g, " ").trim(), "fold"), Ft = [
23
+ "hoje",
24
+ "amanha",
25
+ "depois",
26
+ "dia",
27
+ "semana",
28
+ "proxima",
29
+ "proximo",
30
+ "fim",
31
+ "feriado",
32
+ "manha",
33
+ "tarde",
34
+ "noite",
35
+ "segunda",
36
+ "terca",
37
+ "quarta",
38
+ "quinta",
39
+ "sexta",
40
+ "sabado",
41
+ "domingo",
42
+ "janeiro",
43
+ "fevereiro",
44
+ "marco",
45
+ "abril",
46
+ "maio",
47
+ "junho",
48
+ "julho",
49
+ "agosto",
50
+ "setembro",
51
+ "outubro",
52
+ "novembro",
53
+ "dezembro"
54
+ ];
55
+ function Ut(t, p) {
56
+ const f = Xe(p);
57
+ if (f === "" || t.length === 0) return t;
58
+ const y = t.filter((c) => c.kind === "date" && ` ${Xe(c.label)}`.includes(` ${f}`)), C = /^\d/.test(f) || y.length > 0 || Ft.some((c) => c.startsWith(f.split(" ")[0]));
59
+ return t.filter((c) => c.kind === "calendar" ? C : y.includes(c));
60
+ }
61
+ h(Ut, "slotDatesFor");
62
+ const Ze = /* @__PURE__ */ h((t) => t.vertical ?? (Oe(t) ? "hotel" : "air"), "verticalOf"), Oe = /* @__PURE__ */ h((t) => t.placesExpected ?? t.hotelExpected ?? !1, "lodgingOf"), Je = /* @__PURE__ */ h((t) => t.placesConfidence ?? t.hotelConfidence ?? 0, "lodgingScoreOf"), nt = /* @__PURE__ */ h((t) => t.personExpected ?? (t.personConfidence ?? 0) >= 0.5, "personOf"), zt = /* @__PURE__ */ h((t) => nt(t) && (t.category === "location" || t.locationExpected === !0), "personAndPlaceOf"), Gt = /* @__PURE__ */ h((t) => t === "hotel" ? "Hotéis e locais" : t === "air" ? "Aeroportos" : void 0, "sectionLabel"), Ee = "Data", Ye = "Localização", Pe = /* @__PURE__ */ h(() => ({
63
+ maxLocationConfidence: 0,
64
+ maxPersonConfidence: 0,
65
+ maxHotelConfidence: 0,
66
+ locationGateFired: !1,
67
+ suggestionAccepted: !1,
68
+ ghostShown: !1,
69
+ ghostAccepted: !1,
70
+ atOpened: !1,
71
+ atAccepted: null,
72
+ manualAt: !1
73
+ }), "emptyOutcome"), et = /* @__PURE__ */ h(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), tt = /* @__PURE__ */ h((t, p, f) => {
74
+ var c;
75
+ const y = t.length;
76
+ let C = p;
77
+ for (let g = 0; g < y; g++)
78
+ if (C = (C + f + y) % y, !((c = t[C]) != null && c.disabled)) return C;
79
+ return p;
80
+ }, "nextEnabledIndex");
81
+ function Bt(t, p, f = {}) {
82
+ const { debugGhostKey: y } = f, [C, c] = d(null), [g, k] = d(null), [H, W] = d(!1), [pe, J] = d(0), [rt, ot] = d(0), [ct, st] = d(!1), [it, lt] = d("air"), [at, ut] = d(0), [dt, ft] = d(!1), [ht, pt] = d(0), [gt, mt] = d(!1), [xt, ge] = d(!1), [yt, me] = d(""), [Ct, kt] = d([]), [xe, He] = d(!1), [ye, _] = d(0), [bt, Ie] = d([]), [vt, Le] = d([]), [wt, Ce] = d(""), oe = i(""), Y = i(null), j = i(t);
83
+ j.current = t;
84
+ const U = i(p);
85
+ U.current = p;
86
+ const ee = i(f);
87
+ ee.current = f;
88
+ const I = i(null), L = i(null), ke = i(0), qe = i(0), ce = i(null), se = i(""), B = i(null), ie = i(null), be = i(et()), Q = i(null);
89
+ Q.current = C;
90
+ const V = i(null);
91
+ V.current = g;
92
+ const te = i(0), ne = i(null), X = i(!1), Rt = 8, $t = 0.5, Z = i(null), Ne = i(""), Fe = i(() => {
93
+ }), q = i(Pe()), z = i(!1), Tt = D(() => {
94
+ c(null), me("");
95
+ }, []), St = D(() => {
96
+ Ie([]), Le([]), Ce(""), oe.current = "", B.current = null, be.current = et(), q.current = Pe(), z.current = !1, He(!1), te.current = 0, ne.current = null, X.current = !1, k(null);
97
+ }, []), ve = D((e) => {
98
+ if (e.disabled) return;
99
+ q.current.suggestionAccepted = !0, e.kind === "location" && (z.current = !0), c(null);
100
+ const n = j.current, o = n.getTextarea();
101
+ if (!o) return;
102
+ const m = o.selectionStart ?? o.value.length, b = o.value.slice(0, m), P = o.value.slice(m), G = e.kind === "namedLocation" || e.kind === "location";
103
+ let a;
104
+ if (G) {
105
+ const l = Ne.current, x = b.replace(/\s+$/, "");
106
+ a = l && x.endsWith(l) ? x.slice(0, x.length - l.length) : b;
107
+ } else {
108
+ const l = b.search(/\S+$/), x = l === -1 ? "" : b.slice(l);
109
+ a = x.length > 0 && (e.kind === "date" && e.insert ? Ve(e.insert).startsWith(Ve(x)) : /^[\d./-]+$/.test(x)) ? b.slice(0, l) : b;
110
+ }
111
+ const E = a.length > 0 && !/\s$/.test(a);
112
+ if (e.kind === "date") {
113
+ const l = ee.current.enableHashDatePicker ? "#" : "", x = `${E ? " " : ""}${l}${e.insert} `, w = `${a}${x}${P}`;
114
+ n.setDraft(w), n.focusCaret(a.length + x.length), se.current = w, B.current = null, Fe.current();
115
+ return;
116
+ }
117
+ if (e.kind === "namedLocation" && e.insert) {
118
+ const l = `@${e.insert.replace(/ /g, " ")}`, x = `${E ? " " : ""}${l} `;
119
+ n.setDraft(`${a}${x}${P}`), n.focusCaret(a.length + x.length);
120
+ return;
121
+ }
122
+ const v = e.kind === "location" ? "@" : "#", r = `${E ? " " : ""}${v}`;
123
+ n.setDraft(`${a}${r}${P}`), n.focusCaret(a.length + r.length), requestAnimationFrame(() => {
124
+ const l = n.getTextarea();
125
+ l && n.syncTrigger(l);
126
+ });
127
+ }, []), we = D(async () => {
128
+ var b;
129
+ const e = U.current.resolveDates;
130
+ if (!e) return;
131
+ const n = se.current;
132
+ if (n.trim() === "") {
133
+ B.current = null;
134
+ return;
135
+ }
136
+ if (n === B.current || n.split(" ").length <= 2) return;
137
+ B.current = n, (b = ie.current) == null || b.abort();
138
+ const m = new AbortController();
139
+ ie.current = m;
140
+ try {
141
+ const { dates: P, locations: G } = await e(n, be.current, m.signal);
142
+ if (se.current !== n) return;
143
+ const a = P.filter((v) => v.display).map((v) => ({ text: v.text, display: v.display }));
144
+ Le(a), Ie(G.map((v) => v.text).filter((v) => v.trim().length > 0));
145
+ const E = a.map((v) => `${v.text}=${v.display}`).join("|");
146
+ a.length > 0 && E !== oe.current && (oe.current = E, Ce(a[a.length - 1].text), Y.current != null && window.clearTimeout(Y.current), Y.current = window.setTimeout(() => Ce(""), 2e3)), a.length === 0 && (oe.current = "");
147
+ } catch {
148
+ }
149
+ }, []);
150
+ Fe.current = we;
151
+ const At = D((e, n, o) => {
152
+ var G, a;
153
+ se.current = e, V.current !== null && (te.current += 1, te.current >= Rt && (X.current = !0, k(null)));
154
+ const m = Nt(e, n);
155
+ if ((m == null ? void 0 : m.trigger) === "@" && !/\s/.test(m.query)) {
156
+ I.current != null && (window.clearTimeout(I.current), I.current = null), L.current != null && (window.clearTimeout(L.current), L.current = null), ke.current += 1, (G = ce.current) == null || G.abort(), (a = ie.current) == null || a.abort(), B.current = null, V.current !== null && k(null), Q.current !== null && c(null), Z.current = null;
157
+ return;
158
+ }
159
+ if (e.split(" ").length <= 2) return;
160
+ const P = U.current.analyze;
161
+ P && (!o || Q.current !== null || V.current !== null) && (I.current != null && window.clearTimeout(I.current), I.current = window.setTimeout(async () => {
162
+ var v;
163
+ const E = ++ke.current;
164
+ try {
165
+ const r = await P(e, n);
166
+ if (E !== ke.current) return;
167
+ const l = j.current, x = l.getTextarea();
168
+ if (!x || x.value !== e) return;
169
+ j.current.isPickerOpen() || (ot(r.personConfidence ?? 0), J(r.locationConfidence ?? 0), st(Oe(r)), lt(Ze(r)), ut(Je(r)), ft(r.hotelNameExpected ?? !1), pt(r.hotelNameConfidence ?? 0), mt(zt(r)));
170
+ const w = q.current;
171
+ w.maxPersonConfidence = Math.max(w.maxPersonConfidence, r.personConfidence ?? 0), w.maxLocationConfidence = Math.max(w.maxLocationConfidence, r.locationConfidence ?? 0), w.maxHotelConfidence = Math.max(w.maxHotelConfidence ?? 0, Je(r)), k(null);
172
+ const $e = x.selectionStart ?? n, ze = $e === e.length, Ge = e.slice(0, $e), Ht = e.slice($e), Te = !ze && /\s$/.test(Ge) && !/^\s*@/.test(Ht), le = ze || Te, Se = l.hasAtQuery, ae = l.isPickerOpen(), Ke = r.suggestions ?? [], { enableHashDatePicker: ue = !1, datePresets: Me = ["amanhã de manhã", "quarta-feira à noite"] } = ee.current;
173
+ let S = r.category === "location" ? "location" : r.category === "date" ? "date" : r.locationExpected ? "location" : r.dateExpected ? "date" : null;
174
+ S !== "location" && r.locationCount < 2 && U.current.suggest && Q.current !== null && Z.current === "location" && le && /\s$/.test(Ge) && (S = "location");
175
+ const We = r.secondary ?? "";
176
+ let A = ue && Se && (S === "location" && We === "date" || S === "date" && We === "location");
177
+ if (A && r.locationCount >= 2 && r.locationPartialEmpty && (A = !1, S = "date"), !ae) {
178
+ const s = (r.suggestions ?? []).filter((u) => u.kind === "date").map((u) => u.value);
179
+ kt(A ? [
180
+ ...ue ? [{ id: "cal", label: "# Escolher no calendário", value: "#", kind: "calendar", section: Ee }] : [],
181
+ // "#"-prefixed, because this row REPLACES the "@" the user typed to open the picker
182
+ // (Issue 1190): the splice hands `value` the whole `@…` token, so a bare phrase ate the
183
+ // trigger and left the date wearing the wrong sigil — or none. `#` is the one the Data
184
+ // half of a mixed caret takes. Only reachable with the calendar wired (`mixed` requires
185
+ // `enableHashDatePicker`), so the character always has a picker behind it.
186
+ ...(s.length > 0 ? s : Me).map((u) => ({ id: `date:${u}`, label: u, value: `#${u}`, kind: "date", section: Ee }))
187
+ ] : []);
188
+ }
189
+ const Ae = !!(A && ee.current.promptHint && le && !ae);
190
+ if (He(Ae), Ae && (X.current || (ne.current = "mixed", W(Te), k("mixed"), w.ghostShown = !0, w.locationGateFired = !0)), ee.current.promptHint && le && !ae && !Ae) {
191
+ const s = r.personConfidence ?? 0, u = r.locationConfidence ?? 0, O = S === "location" && !A && !(r.locationCount >= 2 && r.locationPartialEmpty), T = r.hotelNameExpected ?? !1 ? "hotelname" : Oe(r) ? "places" : "location", N = S === "date" && !A && ue, F = O && nt(r) && !N ? "locationOrPerson" : s >= $t && s >= u && !N ? "person" : N ? "date" : O ? T : null;
192
+ if (F) {
193
+ X.current || (ne.current = F, W(Te), k(F), w.ghostShown = !0, (F === "location" || F === "locationOrPerson") && (w.locationGateFired = !0)), c(null), Z.current = null;
194
+ return;
195
+ }
196
+ ne.current = null;
197
+ }
198
+ if (S === "location" && r.locationCount >= 2 && r.locationPartialEmpty) {
199
+ c(null), Z.current = null;
200
+ return;
201
+ }
202
+ if (S === null || !(le && !ae && (S === "location" ? Se : S === "date"))) {
203
+ c(null), Z.current = null;
204
+ return;
205
+ }
206
+ const $ = A ? "location" : S;
207
+ Z.current = $, $ === "location" && (w.locationGateFired = !0);
208
+ const _e = Ke.filter((s) => s.kind === "location"), je = Ke.filter((s) => s.kind === "date").map((s) => s.value), de = /* @__PURE__ */ h(({ quickDates: s }) => {
209
+ if ($ !== "date" && !A) return [];
210
+ const u = A ? Ee : void 0, O = [];
211
+ if (ue && O.push({ key: "cal", label: "# Escolher no calendário", kind: "calendar", icon: "calendar", section: u }), s)
212
+ for (const T of je.length > 0 ? je : Me)
213
+ O.push({ key: `date:${T}`, label: T, kind: "date", icon: "date", insert: T, section: u });
214
+ return O;
215
+ }, "dateRows"), It = /* @__PURE__ */ h((s, u) => (u ? Gt(s) : void 0) ?? (A ? Ye : void 0), "locSection"), K = [];
216
+ if ($ === "location") {
217
+ K.push(...de({ quickDates: !0 }));
218
+ for (const s of _e)
219
+ K.push({
220
+ key: `loc:${s.value}`,
221
+ label: s.label,
222
+ kind: "namedLocation",
223
+ insert: s.value,
224
+ icon: "place",
225
+ section: A ? Ye : void 0
226
+ });
227
+ } else
228
+ K.push(...de({ quickDates: !0 }));
229
+ const fe = U.current.suggest, Lt = $ === "location" ? _e.length > 0 : !0;
230
+ if ($ === "location" && !Lt && !fe && !A) {
231
+ if (!o && r.locationExpected && r.locationPartialEmpty && r.locationCount < 2 && Se && l.currentTriggerChar() !== "@") {
232
+ const s = x.selectionStart ?? e.length, u = e.slice(0, s), O = u.length > 0 && !/\s$/.test(u);
233
+ if (!u.endsWith("@")) {
234
+ const T = O ? " @" : "@";
235
+ z.current = !0, c(null), l.setDraft(`${u}${T}${e.slice(s)}`), l.focusCaret(s + T.length), requestAnimationFrame(() => {
236
+ const N = l.getTextarea();
237
+ N && l.syncTrigger(N);
238
+ });
239
+ }
240
+ return;
241
+ }
242
+ c(null);
243
+ return;
244
+ }
245
+ if (fe ? Q.current === null && K.length > 0 && (_(0), ge(!0), c(K)) : (me(""), K.length > 0 ? (_(0), ge(!0), c(K)) : c(null)), fe) {
246
+ const s = e.slice(0, x.selectionStart ?? e.length), u = s.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), O = u === -1 ? s : s.slice(u + 1), T = $ === "location" && r.locationPartial !== void 0 ? r.locationPartial : O;
247
+ $ === "location" && (Ne.current = T), me(T);
248
+ const N = $ === "location" ? [...e.matchAll(/@\(([A-Za-z]{3})\)/g)].map((he) => he[1].toUpperCase()) : void 0, Ue = ++qe.current;
249
+ (v = ce.current) == null || v.abort();
250
+ const F = new AbortController();
251
+ ce.current = F;
252
+ try {
253
+ const he = $ === "location" ? Ze(r) : "air", De = await fe(T, $, F.signal, N, he);
254
+ if (Ue !== qe.current) return;
255
+ const Be = l.getTextarea();
256
+ if (!Be || Be.value !== e || $ === "location" && De.length === 0) return;
257
+ const M = [];
258
+ if ($ === "location") {
259
+ M.push(...de({ quickDates: !0 }));
260
+ for (const R of De)
261
+ M.push({
262
+ key: `loc:${R.insert}`,
263
+ label: R.label,
264
+ kind: "namedLocation",
265
+ insert: R.insert,
266
+ hint: [R.iata, R.region, R.country].filter(Boolean).join(" · ") || void 0,
267
+ // parity with the `@` picker
268
+ disabled: R.disabled,
269
+ // already in the prompt (same city) — greyed, not pickable
270
+ // An IATA code is what makes a row an AIRPORT; everything else is a place.
271
+ icon: R.iata ? "airport" : "place",
272
+ section: It(R.source, he === "both")
273
+ });
274
+ } else {
275
+ M.push(...de({ quickDates: !1 }));
276
+ for (const R of De)
277
+ M.push({ key: `date:${R.insert}`, label: R.label, kind: "date", icon: "date", insert: R.insert });
278
+ }
279
+ if (M.length === 0) {
280
+ c(null);
281
+ return;
282
+ }
283
+ const Qe = M.findIndex((R) => !R.disabled);
284
+ _(Qe < 0 ? 0 : Qe), ge(T.trim() === ""), c(M);
285
+ } catch {
286
+ }
287
+ }
288
+ } catch {
289
+ }
290
+ }, 200)), L.current != null && window.clearTimeout(L.current), L.current = window.setTimeout(() => {
291
+ we();
292
+ }, 300);
293
+ }, [we]), Dt = D((e) => {
294
+ var o, m;
295
+ const n = e.trim();
296
+ n && ((m = (o = U.current).commitIntent) == null || m.call(o, n, be.current, q.current)), q.current = Pe(), z.current = !1;
297
+ }, []), Et = D(() => {
298
+ const e = q.current;
299
+ e.atOpened = !0, z.current ? z.current = !1 : V.current === null && Q.current === null && (e.manualAt = !0);
300
+ }, []), Pt = D((e) => {
301
+ q.current.atAccepted = e ?? "location";
302
+ }, []), Re = D(() => {
303
+ q.current.ghostAccepted = !0;
304
+ const e = V.current === "date" ? "#" : "@";
305
+ z.current = !0, te.current = 0, ne.current = null, k(null);
306
+ const n = j.current, o = n.getTextarea();
307
+ if (!o) return;
308
+ const m = o.selectionStart ?? o.value.length, b = o.value.slice(0, m), P = o.value.slice(m), a = `${b.length > 0 && !/\s$/.test(b) ? " " : ""}${e}`;
309
+ n.setDraft(`${b}${a}${P}`), n.focusCaret(m + a.length), requestAnimationFrame(() => {
310
+ const E = n.getTextarea();
311
+ E && n.syncTrigger(E);
312
+ });
313
+ }, []), Ot = D((e) => {
314
+ const n = xe ? null : C;
315
+ if (y && e.key === y && !e.ctrlKey && !e.metaKey && !e.altKey) {
316
+ e.preventDefault();
317
+ const o = j.current.getTextarea(), m = (o == null ? void 0 : o.selectionStart) ?? (o == null ? void 0 : o.value.length) ?? 0, b = o ? o.value.slice(m) : "";
318
+ return X.current = !1, te.current = 0, W(b.trim().length > 0), k(g === "location" ? "person" : "location"), !0;
319
+ }
320
+ if (g !== null && (!n || n.length === 0)) {
321
+ if (e.key === "Tab" || e.key === "ArrowRight" && !H)
322
+ return e.preventDefault(), Re(), !0;
323
+ if (e.key === "Escape")
324
+ return e.preventDefault(), X.current = !0, k(null), !0;
325
+ }
326
+ if (!n || n.length === 0) return !1;
327
+ if (e.key === "ArrowDown")
328
+ return e.preventDefault(), _((o) => tt(n, o, 1)), !0;
329
+ if (e.key === "ArrowUp")
330
+ return e.preventDefault(), _((o) => tt(n, o, -1)), !0;
331
+ if (e.key === "Enter" || e.key === "Tab") {
332
+ e.preventDefault();
333
+ const o = n[ye];
334
+ return o && !o.disabled && ve(o), !0;
335
+ }
336
+ return e.key === "Escape" ? (e.preventDefault(), c(null), !0) : !1;
337
+ }, [C, xe, ye, ve, g, H, Re, y]);
338
+ return re(() => () => {
339
+ var e, n;
340
+ I.current != null && window.clearTimeout(I.current), L.current != null && window.clearTimeout(L.current), Y.current != null && window.clearTimeout(Y.current), (e = ie.current) == null || e.abort(), (n = ce.current) == null || n.abort();
341
+ }, []), {
342
+ predictions: xe ? null : C,
343
+ predictionsRecents: xt,
344
+ predictionQuery: yt,
345
+ slotDateOptions: Ct,
346
+ predictionHighlight: ye,
347
+ setPredictionHighlight: _,
348
+ applyPrediction: ve,
349
+ clearPredictions: Tt,
350
+ hint: g,
351
+ hintMidSentence: H,
352
+ acceptHint: Re,
353
+ resolvedLocations: bt,
354
+ resolvedDates: vt,
355
+ forceTooltipText: wt,
356
+ personConfidence: rt,
357
+ locationConfidence: pe,
358
+ hotelExpected: ct,
359
+ hotelConfidence: at,
360
+ vertical: it,
361
+ hotelNameExpected: dt,
362
+ hotelNameConfidence: ht,
363
+ personOrPlace: gt,
364
+ scheduleAssist: At,
365
+ commit: Dt,
366
+ onKeyDown: Ot,
367
+ resetSession: St,
368
+ noteAtOpened: Et,
369
+ noteAtAccepted: Pt
370
+ };
371
+ }
372
+ h(Bt, "usePromptAssist");
373
+ function Qt(t, p) {
374
+ const f = i(t), [y, C] = d(null);
375
+ return re(() => {
376
+ f.current = t;
377
+ }, [t]), re(() => {
378
+ function c() {
379
+ f.current();
380
+ }
381
+ if (h(c, "tick"), p !== null) {
382
+ const g = setInterval(c, p);
383
+ return C(g), () => {
384
+ clearInterval(g);
385
+ };
386
+ }
387
+ }, [p]), y;
388
+ }
389
+ h(Qt, "useInterval");
390
+ function Vt(t, p, f = 0, y = 0) {
391
+ const [C, c] = d(f), [g, k] = d(y);
392
+ return re(() => {
393
+ const H = t.current;
394
+ if (!H) return;
395
+ const W = new ResizeObserver((pe) => {
396
+ const J = pe[0];
397
+ J && (k(J.contentRect.height), c(J.contentRect.width));
398
+ });
399
+ return W.observe(H), c(H.getBoundingClientRect().width), () => W.disconnect();
400
+ }, [t, p]), [C, g];
401
+ }
402
+ h(Vt, "useContainerRectangle");
403
+ export {
404
+ Qt as a,
405
+ Bt as b,
406
+ jt as c,
407
+ Ut as s,
408
+ Vt as u
409
+ };
410
+ //# sourceMappingURL=useContainerWidth-C7u70yDY.js.map