@aintela/chat 0.2.32 → 0.2.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.
- package/dist/{atMentions-DqhG_vde.js → atMentions-C5Fs9Yab.js} +32 -32
- package/dist/{atMentions-DqhG_vde.js.map → atMentions-C5Fs9Yab.js.map} +1 -1
- package/dist/{auth-BN22f1HF.js → auth-ffNUief3.js} +2 -2
- package/dist/{auth-BN22f1HF.js.map → auth-ffNUief3.js.map} +1 -1
- package/dist/components.js +2880 -2785
- package/dist/components.js.map +1 -1
- package/dist/hooks.js +1 -1
- package/dist/{httpArtifactService-hGsIslw7.js → httpArtifactService-3J9rNvgw.js} +213 -184
- package/dist/{httpArtifactService-hGsIslw7.js.map → httpArtifactService-3J9rNvgw.js.map} +1 -1
- package/dist/index.js +4 -4
- package/dist/services.js +1 -1
- package/dist/src/hooks/index.d.ts +1 -1
- package/dist/src/hooks/usePromptAssist.d.ts +34 -1
- package/dist/src/services/httpPromptAssistService.d.ts +6 -1
- package/dist/src/services/servers/AgentGatewayWSAsync.d.ts +7 -0
- package/dist/src/utils/atMentions.d.ts +10 -6
- package/dist/useContainerWidth-Cs50UcTK.js +309 -0
- package/dist/useContainerWidth-Cs50UcTK.js.map +1 -0
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/useContainerWidth-D0CQQqZ2.js +0 -262
- package/dist/useContainerWidth-D0CQQqZ2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@ import { A as T, a as u, C as L, M as x, b as P, S as f, i as R } from "./Memory
|
|
|
4
4
|
import { C as U, C as y } from "./ClientMessage-EKgfuTp8.js";
|
|
5
5
|
import { C as D, P as B } from "./Prompt-DZb7OaPp.js";
|
|
6
6
|
import { A as F, a as b, b as k, c as N, d as H, e as G, C as O, f as W, D as w, E as z, g as J, G as j, h as q, M as K, i as X, R as Y, j as Q, S as Z, l as $, m as ee, n as ae, o as te, p as se, q as oe, r as ne, s as re, t as ie, u as ce } from "./environmentUtils-CUVZ6Dq1.js";
|
|
7
|
-
import { A as Se, a as pe, E as Ae, H as Ce, I as de, L as ge, W as Ie } from "./httpArtifactService-
|
|
7
|
+
import { A as Se, a as pe, E as Ae, H as Ce, I as de, L as ge, W as Ie } from "./httpArtifactService-3J9rNvgw.js";
|
|
8
8
|
import { A as Ee } from "./artifactHtmlHandler-CMQJf1cX.js";
|
|
9
9
|
import { H as me, d as Te } from "./httpSessionService-M1IKQIQK.js";
|
|
10
10
|
import { APPBAR_V2_HEIGHT as Le, AgentActivityV2 as xe, AiChat as Pe, AiChatDrawer as fe, AiChatFloating as Re, AiChatFloatingV2 as Me, AiChatProvider as Ue, AiChatServiceContext as ye, AiChatV2Pane as _e, AppBarV2 as De, AppRailV2 as Be, AppShellV2 as Ve, ArtifactRender as Fe, BoxedPart as be, BrainIcon as ke, ChartIcon as Ne, ChatIcon as He, ChatPane as Ge, ChatsHistoryV2 as Oe, CheckIcon as We, ChevronIcon as we, ChevronRightIcon as ze, CloseIcon as Je, CodeIcon as je, ComposerIcon as qe, DEFAULT_PART_RENDERERS as Ke, DashboardIcon as Xe, DataExplorerIcon as Ye, DelayTextComponent as Qe, EnvironmentProvider as Ze, FileIcon as $e, FunctionPart as ea, GlobeIcon as aa, HistoryIcon as ta, IDLE_TIMEOUT as sa, InertEnvironmentProvider as oa, JsxErrorBoundary as na, LIVE_TSX_DEFAULT_MAX_CHARS_FOR_FULL as ra, LastPromptsV2 as ia, LinearBackgroundProgress as ca, LinearProgressBarWithMarkers as la, ListCheckIcon as Sa, LiveJsxBlock as pa, LiveTsxConfigProvider as Aa, LlmResponseRender as Ca, LoadingDots as da, LockClosedIcon as ga, LockOpenIcon as Ia, MOBILE_NAV_DEFAULT as va, MarkdownExtended as Ea, MenuIcon as ha, Message as ma, MobileDrawerV2 as Ta, PanelIcon as ua, PauseIcon as La, PinIcon as xa, PlusIcon as Pa, PromptDateMarkers as fa, PromptV2 as Ra, RunProgressPanelV2 as Ma, RunProgressStripV2 as Ua, SearchIcon as ya, SendIcon as _a, SessionStateManagerService as Da, SparkleIcon as Ba, Sparkline as Va, StopIcon as Fa, Stopwatch as ba, SubAgentBox as ka, SubAgentBoxV2 as Na, SuspendedPart as Ha, TableIcon as Ga, TaskListV2 as Oa, TerminalIcon as Wa, TextPart as wa, ThoughtPart as za, ToolIcon as Ja, TrashIcon as ja, UiToolDispatcher as qa, UsersIcon as Ka, V2_CHART_PALETTE as Xa, WARNING_THRESHOLD as Ya, WaitingPart as Qa, classifyPart as Za, configureFriendlyMapping as $a, createAiChatSessionStore as et, createAiChatSessionStore as at, createUiToolRegistry as tt, extendDefaultScope as st, extendModuleRegistry as ot, getDefaultJsxScope as nt, getFriendlyLabel as rt, parseClientOutput as it, parseContentBlocks as ct, parseUiArgs as lt, useAiChatServices as St, useAiChatSessionStore as pt, useEnvironment as At, useEnvironmentOptional as Ct, useLiveTsxMaxCharsForFull as dt, useResponsiveLayout as gt, v2Card as It, v2Chip as vt, v2IconBtn as Et, v2MonoMeta as ht, v2SectionLabel as mt, v2Theme as Tt } from "./components.js";
|
|
11
|
-
import { u as Lt, a as xt, b as Pt, c as ft } from "./useContainerWidth-
|
|
12
|
-
import { A as Mt, a as Ut, b as yt, G as _t, d as Dt, c as Bt, e as Vt, f as Ft, g as bt, h as kt, i as Nt, j as Ht, k as Gt, l as Ot, m as Wt, n as wt, o as zt, p as Jt, q as jt, r as qt, s as Kt, t as Xt, u as Yt, v as Qt } from "./auth-
|
|
13
|
-
import { S as $t, c as es, a as as, e as ts, b as ss, f as os, i as ns, d as rs, p as is, g as cs, s as ls, k as Ss, t as ps } from "./atMentions-
|
|
11
|
+
import { u as Lt, a as xt, b as Pt, c as ft } from "./useContainerWidth-Cs50UcTK.js";
|
|
12
|
+
import { A as Mt, a as Ut, b as yt, G as _t, d as Dt, c as Bt, e as Vt, f as Ft, g as bt, h as kt, i as Nt, j as Ht, k as Gt, l as Ot, m as Wt, n as wt, o as zt, p as Jt, q as jt, r as qt, s as Kt, t as Xt, u as Yt, v as Qt } from "./auth-ffNUief3.js";
|
|
13
|
+
import { S as $t, c as es, a as as, e as ts, b as ss, f as os, i as ns, d as rs, p as is, g as cs, s as ls, k as Ss, t as ps } from "./atMentions-C5Fs9Yab.js";
|
|
14
14
|
import { u as Cs } from "./useChatSessions-C-XVE-h3.js";
|
|
15
15
|
import { Score as gs } from "./interfaces.js";
|
|
16
16
|
export {
|
package/dist/services.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as a, a as r, E as s, H as o, I as c, L as n, W as i } from "./httpArtifactService-
|
|
1
|
+
import { A as a, a as r, E as s, H as o, I as c, L as n, W as i } from "./httpArtifactService-3J9rNvgw.js";
|
|
2
2
|
import { A as v } from "./artifactHtmlHandler-CMQJf1cX.js";
|
|
3
3
|
import { H, d as f } from "./httpSessionService-M1IKQIQK.js";
|
|
4
4
|
export {
|
|
@@ -3,4 +3,4 @@ export { useContainerWidth, useContainerRectangle } from './useContainerWidth';
|
|
|
3
3
|
export { useChatSessions } from './useChatSessions';
|
|
4
4
|
export type { UseChatSessionsOptions, UseChatSessionsResult, ChatSessionListItem, ChatSessionGroup, } from './useChatSessions';
|
|
5
5
|
export { usePromptAssist } from './usePromptAssist';
|
|
6
|
-
export type { PredictionItem, ResolvedDateItem, PromptAssistAdapter, PromptAssistFetchers, PromptAssistOptions, } from './usePromptAssist';
|
|
6
|
+
export type { PredictionItem, ResolvedDateItem, PromptAssistAdapter, PromptAssistFetchers, PromptAssistOptions, AssistOutcome, } from './usePromptAssist';
|
|
@@ -15,6 +15,30 @@ export type ResolvedDateItem = {
|
|
|
15
15
|
text: string;
|
|
16
16
|
display: string;
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Send-time summary of what the assist UI did during ONE composition (issue #159 Phase 1) — attached to the
|
|
20
|
+
* commit so the server can store {prompt, outcome} as a behavioral label and emit gate-precision metrics:
|
|
21
|
+
* gate fired + assist used ≈ true positive; fired + ignored ≈ false-positive candidate; gate quiet + the user
|
|
22
|
+
* typed `@` themselves ≈ false-negative candidate. Numbers/booleans only, no extra text.
|
|
23
|
+
*/
|
|
24
|
+
export type AssistOutcome = {
|
|
25
|
+
/** Highest location-intent confidence any analyze reported while composing. */
|
|
26
|
+
maxLocationConfidence: number;
|
|
27
|
+
/** Highest person-intent confidence any analyze reported while composing. */
|
|
28
|
+
maxPersonConfidence: number;
|
|
29
|
+
/** Location assist became VISIBLE at least once (dropdown, location ghost, or auto-`@`). */
|
|
30
|
+
locationGateFired: boolean;
|
|
31
|
+
/** The user accepted an item from the predictions dropdown. */
|
|
32
|
+
suggestionAccepted: boolean;
|
|
33
|
+
ghostShown: boolean;
|
|
34
|
+
ghostAccepted: boolean;
|
|
35
|
+
/** The `@` picker was opened at least once (host reports via noteAtOpened). */
|
|
36
|
+
atOpened: boolean;
|
|
37
|
+
/** Section of the last accepted `@` mention (host reports via noteAtAccepted). */
|
|
38
|
+
atAccepted: 'person' | 'location' | null;
|
|
39
|
+
/** The user typed `@` themselves while nothing assist-y was showing — a recall miss signal. */
|
|
40
|
+
manualAt: boolean;
|
|
41
|
+
};
|
|
18
42
|
/** The DOM operations the hook needs from its host composer — so the same logic drives PromptV2 and PromptComposer. */
|
|
19
43
|
export interface PromptAssistAdapter {
|
|
20
44
|
getTextarea: () => HTMLTextAreaElement | null;
|
|
@@ -34,12 +58,16 @@ export interface PromptAssistAdapter {
|
|
|
34
58
|
export interface PromptAssistFetchers {
|
|
35
59
|
analyze?: (text: string, caret: number) => Promise<PromptAnalysis>;
|
|
36
60
|
resolveDates?: (text: string, sessionId?: string, signal?: AbortSignal) => Promise<PromptResolution>;
|
|
37
|
-
commitIntent?: (text: string, sessionId?: string) => void;
|
|
61
|
+
commitIntent?: (text: string, sessionId?: string, assist?: AssistOutcome) => void;
|
|
38
62
|
suggest?: (q: string, kind: 'location' | 'date' | 'both', signal?: AbortSignal, exclude?: string[]) => Promise<SuggestItem[]>;
|
|
39
63
|
}
|
|
40
64
|
export interface PromptAssistOptions {
|
|
41
65
|
enableHashDatePicker?: boolean;
|
|
42
66
|
datePresets?: string[];
|
|
67
|
+
/** When true, a location OR person prediction shows a PHANTOM ghost at the caret ("@ Localidade" / "@ Nome
|
|
68
|
+
* pessoa") teaching the `@` trigger, INSTEAD of auto-opening the location predictions dropdown. Date still uses
|
|
69
|
+
* its dropdown. The host reads `hint` to render the ghost and wires Tab/→ to `acceptHint`. Default false. */
|
|
70
|
+
promptHint?: boolean;
|
|
43
71
|
}
|
|
44
72
|
/**
|
|
45
73
|
* Headless prompt-assist logic shared by the chat composer (PromptV2) and the home composer (obtapp PromptComposer):
|
|
@@ -54,12 +82,17 @@ export declare function usePromptAssist(adapter: PromptAssistAdapter, fetchers:
|
|
|
54
82
|
setPredictionHighlight: import('react').Dispatch<import('react').SetStateAction<number>>;
|
|
55
83
|
applyPrediction: (p: PredictionItem) => void;
|
|
56
84
|
clearPredictions: () => void;
|
|
85
|
+
hint: "location" | "person" | null;
|
|
86
|
+
acceptHint: () => void;
|
|
57
87
|
resolvedLocations: string[];
|
|
58
88
|
resolvedDates: ResolvedDateItem[];
|
|
59
89
|
forceTooltipText: string;
|
|
60
90
|
personConfidence: number;
|
|
91
|
+
locationConfidence: number;
|
|
61
92
|
scheduleAssist: (value: string, caret: number, isDeletion: boolean) => void;
|
|
62
93
|
commit: (finalText: string) => void;
|
|
63
94
|
onKeyDown: (e: KeyboardEvent<HTMLTextAreaElement>) => boolean;
|
|
64
95
|
resetSession: () => void;
|
|
96
|
+
noteAtOpened: () => void;
|
|
97
|
+
noteAtAccepted: (group?: "person" | "location") => void;
|
|
65
98
|
};
|
|
@@ -42,6 +42,9 @@ export interface PromptAnalysis {
|
|
|
42
42
|
* optional for back-compat with a server that predates the classifier (absent → treated as 0/false). */
|
|
43
43
|
personExpected?: boolean;
|
|
44
44
|
personConfidence?: number;
|
|
45
|
+
/** P(the prompt is a flight/place search) from the location-intent classifier. Drives the phantom "@ Localidade"
|
|
46
|
+
* cue and biases the `@` picker toward Locais when location outweighs person. Optional (older server → 0). */
|
|
47
|
+
locationConfidence?: number;
|
|
45
48
|
}
|
|
46
49
|
/** Slow-path resolved date — `start`/`length` anchor the chip; `display` is e.g. "quarta 8 de Jul". */
|
|
47
50
|
export interface ResolvedDate {
|
|
@@ -77,6 +80,8 @@ export declare class HttpPromptAssistService {
|
|
|
77
80
|
/**
|
|
78
81
|
* Fire-and-forget on SEND: tells the server to LEARN from the final prompt (commit=true). Learning only on
|
|
79
82
|
* commit means in-progress `@`-query partials typed while composing never get recorded as places.
|
|
83
|
+
* `assist` (issue #159 Phase 1) is the composition-outcome summary from `usePromptAssist` — the server stores
|
|
84
|
+
* it with the prompt as a behavioral label and emits gate-precision metrics. Optional: older callers omit it.
|
|
80
85
|
*/
|
|
81
|
-
commitIntent(text: string, sessionId?: string): Promise<void>;
|
|
86
|
+
commitIntent(text: string, sessionId?: string, assist?: unknown): Promise<void>;
|
|
82
87
|
}
|
|
@@ -22,6 +22,13 @@ export declare class AgentGatewayWSAsync extends AgentGatewayService {
|
|
|
22
22
|
protected root_url: string;
|
|
23
23
|
protected hearBeatPort?: IHeartbeatPort;
|
|
24
24
|
connectionAttempts: number;
|
|
25
|
+
/**
|
|
26
|
+
* True once a WS has successfully opened at least once in this gateway's
|
|
27
|
+
* lifetime. Gates the "Reiniciando a conexão" toast: a drop of a working
|
|
28
|
+
* connection is worth telling the user about, a failed initial dial is not
|
|
29
|
+
* (the Connecting state already covers it).
|
|
30
|
+
*/
|
|
31
|
+
private everConnected;
|
|
25
32
|
constructor(user: User, eventBusService: EventBusService, artifactService: IArtifactService, baseUrl: string, config: AgentContext, sessionStore: AiChatStore, notificationPort: INotificationPort, ws: IWebSocketConnection, storageService: IStorageService, heartbeatPort?: IHeartbeatPort, sessionId?: string);
|
|
26
33
|
getStoredSessionId(): string | undefined;
|
|
27
34
|
isInteractionComplete(interactionId: string): boolean | undefined;
|
|
@@ -13,16 +13,20 @@ export interface AtMentionFetchers {
|
|
|
13
13
|
export interface AtMentionOptions {
|
|
14
14
|
/** Person-intent confidence from the analyze pass; orders the two sections. Default 0. */
|
|
15
15
|
personConfidence?: number;
|
|
16
|
-
/**
|
|
16
|
+
/** Location-intent confidence from the analyze pass. When location outweighs person, the Locais section leads —
|
|
17
|
+
* so an `@` accepted from a location context ("voos saindo de @") searches PLACES, not people. Default 0. */
|
|
18
|
+
locationConfidence?: number;
|
|
19
|
+
/** Confidence at/above which the person section MAY lead (it still only wins if it also outweighs location). Default 0.5. */
|
|
17
20
|
personFirstThreshold?: number;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Fetch `@` mention items from whichever sources are wired, as one flat list. When BOTH a location and a person
|
|
21
|
-
* source are present, items are tagged with their `group` and ordered by
|
|
22
|
-
* when
|
|
23
|
-
*
|
|
24
|
-
* source
|
|
24
|
+
* source are present, items are tagged with their `group` and ordered by intent — the Pessoas section leads only
|
|
25
|
+
* when person-intent both clears its threshold AND outweighs location-intent; otherwise Locais leads. This means an
|
|
26
|
+
* `@` opened in a clear location context ("voos saindo de @") searches PLACES first even though `@` is dual-purpose.
|
|
27
|
+
* A single wired source returns an untagged flat list (unchanged behaviour). Each source is awaited in parallel and
|
|
28
|
+
* failures are isolated: one source erroring never sinks the other.
|
|
25
29
|
*/
|
|
26
|
-
export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, personFirstThreshold }?: AtMentionOptions): Promise<AtMentionItem[]>;
|
|
30
|
+
export declare function fetchAtMentions(query: string, { onAtQuery, onAtPersonQuery }: AtMentionFetchers, { personConfidence, locationConfidence, personFirstThreshold }?: AtMentionOptions): Promise<AtMentionItem[]>;
|
|
27
31
|
/** True when `items[idx]` opens a new `@` section (its group differs from the previous item's). */
|
|
28
32
|
export declare function isSectionStart(items: AtMentionItem[], idx: number): boolean;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
var _t = Object.defineProperty;
|
|
2
|
+
var C = (u, l) => _t(u, "name", { value: l, configurable: !0 });
|
|
3
|
+
import { useState as $, useRef as s, useCallback as k, useEffect as j } from "react";
|
|
4
|
+
const pt = /* @__PURE__ */ C(() => ({
|
|
5
|
+
maxLocationConfidence: 0,
|
|
6
|
+
maxPersonConfidence: 0,
|
|
7
|
+
locationGateFired: !1,
|
|
8
|
+
suggestionAccepted: !1,
|
|
9
|
+
ghostShown: !1,
|
|
10
|
+
ghostAccepted: !1,
|
|
11
|
+
atOpened: !1,
|
|
12
|
+
atAccepted: null,
|
|
13
|
+
manualAt: !1
|
|
14
|
+
}), "emptyOutcome"), St = /* @__PURE__ */ C(() => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`, "newSessionId"), Dt = /* @__PURE__ */ C((u, l, m) => {
|
|
15
|
+
var g;
|
|
16
|
+
const i = u.length;
|
|
17
|
+
let o = l;
|
|
18
|
+
for (let h = 0; h < i; h++)
|
|
19
|
+
if (o = (o + m + i) % i, !((g = u[o]) != null && g.disabled)) return o;
|
|
20
|
+
return l;
|
|
21
|
+
}, "nextEnabledIndex"), jt = /* @__PURE__ */ C((u) => {
|
|
22
|
+
const l = /* @__PURE__ */ new Date();
|
|
23
|
+
l.setDate(l.getDate() + u);
|
|
24
|
+
const m = String(l.getDate()).padStart(2, "0"), i = String(l.getMonth() + 1).padStart(2, "0");
|
|
25
|
+
return `${m}/${i}/${l.getFullYear()}`;
|
|
26
|
+
}, "plusDaysBR");
|
|
27
|
+
function Zt(u, l, m = {}) {
|
|
28
|
+
const [i, o] = $(null), [g, h] = $(null), [F, S] = $(0), [Q, et] = $(0), [z, nt] = $(!1), [rt, L] = $(0), [Pt, mt] = $([]), [Et, yt] = $([]), [It, ot] = $(""), X = s(""), B = s(null), Y = s(u);
|
|
29
|
+
Y.current = u;
|
|
30
|
+
const H = s(l);
|
|
31
|
+
H.current = l;
|
|
32
|
+
const ct = s(m);
|
|
33
|
+
ct.current = m;
|
|
34
|
+
const U = s(null), W = s(null), $t = s(0), Rt = s(0), st = s(null), Z = s(""), K = s(null), it = s(null), lt = s(St()), M = s(null);
|
|
35
|
+
M.current = i;
|
|
36
|
+
const at = s(null);
|
|
37
|
+
at.current = g;
|
|
38
|
+
const J = s(0), ut = s(null), Lt = 4, Ht = 0.5, G = s(null), wt = s(""), vt = s(() => {
|
|
39
|
+
}), D = s(pt()), I = s(!1), Ot = k(() => o(null), []), qt = k(() => {
|
|
40
|
+
mt([]), yt([]), ot(""), X.current = "", K.current = null, lt.current = St(), D.current = pt(), I.current = !1;
|
|
41
|
+
}, []), dt = k((t) => {
|
|
42
|
+
if (t.disabled) return;
|
|
43
|
+
D.current.suggestionAccepted = !0, t.kind === "location" && (I.current = !0), o(null);
|
|
44
|
+
const e = Y.current, d = e.getTextarea();
|
|
45
|
+
if (!d) return;
|
|
46
|
+
const p = d.selectionStart ?? d.value.length, b = d.value.slice(0, p), x = d.value.slice(p), n = t.kind === "namedLocation" || t.kind === "location";
|
|
47
|
+
let r;
|
|
48
|
+
if (n) {
|
|
49
|
+
const f = wt.current, R = b.replace(/\s+$/, "");
|
|
50
|
+
r = f && R.endsWith(f) ? R.slice(0, R.length - f.length) : b;
|
|
51
|
+
} else {
|
|
52
|
+
const f = b.search(/\S+$/);
|
|
53
|
+
r = f === -1 ? b : b.slice(0, f);
|
|
54
|
+
}
|
|
55
|
+
const a = r.length > 0 && !/\s$/.test(r);
|
|
56
|
+
if (t.kind === "date") {
|
|
57
|
+
const f = `${a ? " " : ""}${t.insert} `, R = `${r}${f}${x}`;
|
|
58
|
+
e.setDraft(R), e.focusCaret(r.length + f.length), Z.current = R, K.current = null, vt.current();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (t.kind === "namedLocation" && t.insert) {
|
|
62
|
+
const f = `@${t.insert.replace(/ /g, " ")}`, R = `${a ? " " : ""}${f} `;
|
|
63
|
+
e.setDraft(`${r}${R}${x}`), e.focusCaret(r.length + R.length);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const T = t.kind === "location" ? "@" : "#", O = `${a ? " " : ""}${T}`;
|
|
67
|
+
e.setDraft(`${r}${O}${x}`), e.focusCaret(r.length + O.length), requestAnimationFrame(() => {
|
|
68
|
+
const f = e.getTextarea();
|
|
69
|
+
f && e.syncTrigger(f);
|
|
70
|
+
});
|
|
71
|
+
}, []), ft = k(async () => {
|
|
72
|
+
var p;
|
|
73
|
+
const t = H.current.resolveDates;
|
|
74
|
+
if (!t) return;
|
|
75
|
+
const e = Z.current;
|
|
76
|
+
if (e.trim() === "") {
|
|
77
|
+
K.current = null;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (e === K.current) return;
|
|
81
|
+
K.current = e, (p = it.current) == null || p.abort();
|
|
82
|
+
const d = new AbortController();
|
|
83
|
+
it.current = d;
|
|
84
|
+
try {
|
|
85
|
+
const { dates: b, locations: x } = await t(e, lt.current, d.signal);
|
|
86
|
+
if (Z.current !== e) return;
|
|
87
|
+
const n = b.filter((a) => a.display).map((a) => ({ text: a.text, display: a.display }));
|
|
88
|
+
yt(n), mt(x.map((a) => a.text).filter((a) => a.trim().length > 0));
|
|
89
|
+
const r = n.map((a) => `${a.text}=${a.display}`).join("|");
|
|
90
|
+
n.length > 0 && r !== X.current && (X.current = r, ot(n[n.length - 1].text), B.current != null && window.clearTimeout(B.current), B.current = window.setTimeout(() => ot(""), 2e3)), n.length === 0 && (X.current = "");
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
vt.current = ft;
|
|
95
|
+
const Ft = k((t, e, d) => {
|
|
96
|
+
Z.current = t;
|
|
97
|
+
const p = H.current.analyze;
|
|
98
|
+
p && (!d || M.current !== null || at.current !== null) && (U.current != null && window.clearTimeout(U.current), U.current = window.setTimeout(async () => {
|
|
99
|
+
var x;
|
|
100
|
+
const b = ++$t.current;
|
|
101
|
+
try {
|
|
102
|
+
const n = await p(t, e);
|
|
103
|
+
if (b !== $t.current) return;
|
|
104
|
+
const r = Y.current, a = r.getTextarea();
|
|
105
|
+
if (!a || a.value !== t) return;
|
|
106
|
+
et(n.personConfidence ?? 0), S(n.locationConfidence ?? 0);
|
|
107
|
+
const T = D.current;
|
|
108
|
+
T.maxPersonConfidence = Math.max(T.maxPersonConfidence, n.personConfidence ?? 0), T.maxLocationConfidence = Math.max(T.maxLocationConfidence, n.locationConfidence ?? 0), h(null);
|
|
109
|
+
const O = (a.selectionStart ?? e) === t.length, f = r.hasAtQuery, R = r.isPickerOpen(), bt = n.suggestions ?? [], { enableHashDatePicker: Kt = !1, datePresets: Mt = ["amanhã de manhã", "quarta-feira à noite"] } = ct.current;
|
|
110
|
+
let P = n.category === "location" ? "location" : n.category === "date" ? "date" : n.locationExpected ? "location" : n.dateExpected ? "date" : null;
|
|
111
|
+
if (P !== "location" && n.locationCount < 2 && H.current.suggest && M.current !== null && G.current === "location" && O && /\s$/.test(t) && (P = "location"), ct.current.promptHint && O && !R) {
|
|
112
|
+
const c = n.personConfidence ?? 0, A = n.locationConfidence ?? 0, N = P === "location" && !(n.locationCount >= 2 && n.locationPartialEmpty), v = c >= Ht && c >= A ? "person" : N ? "location" : null;
|
|
113
|
+
if (v) {
|
|
114
|
+
v !== ut.current && (J.current = 0), ut.current = v, J.current += 1, J.current <= Lt && (h(v), T.ghostShown = !0, v === "location" && (T.locationGateFired = !0)), o(null), G.current = null;
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
ut.current = null, J.current = 0;
|
|
118
|
+
}
|
|
119
|
+
if (P === "location" && n.locationCount >= 2 && n.locationPartialEmpty) {
|
|
120
|
+
o(null), G.current = null;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (P === null || !(O && !R && (P === "location" ? f : P === "date"))) {
|
|
124
|
+
o(null), G.current = null;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const w = P;
|
|
128
|
+
G.current = w, w === "location" && (T.locationGateFired = !0);
|
|
129
|
+
const ht = /* @__PURE__ */ C(() => w === "date" && Kt ? [{ key: "cal", label: `📅 no dia #${jt(2)}`, kind: "calendar" }] : [], "genericTail"), Ct = bt.filter((c) => c.kind === "location"), kt = bt.filter((c) => c.kind === "date").map((c) => c.value), E = [];
|
|
130
|
+
if (w === "location") {
|
|
131
|
+
for (const c of Ct)
|
|
132
|
+
E.push({ key: `loc:${c.value}`, label: `📍 ${c.label}`, kind: "namedLocation", insert: c.value });
|
|
133
|
+
E.push(...ht());
|
|
134
|
+
} else {
|
|
135
|
+
for (const c of kt.length > 0 ? kt : Mt)
|
|
136
|
+
E.push({ key: `date:${c}`, label: `📅 ${c}`, kind: "date", insert: c });
|
|
137
|
+
E.push(...ht());
|
|
138
|
+
}
|
|
139
|
+
const V = H.current.suggest, Gt = w === "location" ? Ct.length > 0 : !0;
|
|
140
|
+
if (w === "location" && !Gt && !V) {
|
|
141
|
+
if (!d && n.locationExpected && n.locationPartialEmpty && n.locationCount < 2 && f && r.currentTriggerChar() !== "@") {
|
|
142
|
+
const c = a.selectionStart ?? t.length, A = t.slice(0, c), N = A.length > 0 && !/\s$/.test(A);
|
|
143
|
+
if (!A.endsWith("@")) {
|
|
144
|
+
const v = N ? " @" : "@";
|
|
145
|
+
I.current = !0, o(null), r.setDraft(`${A}${v}${t.slice(c)}`), r.focusCaret(c + v.length), requestAnimationFrame(() => {
|
|
146
|
+
const tt = r.getTextarea();
|
|
147
|
+
tt && r.syncTrigger(tt);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
o(null);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (V ? M.current === null && E.length > 0 && (L(0), nt(!0), o(E)) : E.length > 0 ? (L(0), nt(!0), o(E)) : o(null), V) {
|
|
156
|
+
const c = t.slice(0, a.selectionStart ?? t.length), A = c.search(/[ \t\r\n](?=[^ \t\r\n]*$)/), N = A === -1 ? c : c.slice(A + 1), v = w === "location" && n.locationPartial !== void 0 ? n.locationPartial : N;
|
|
157
|
+
w === "location" && (wt.current = v);
|
|
158
|
+
const tt = w === "location" ? [...t.matchAll(/@\(([A-Za-z]{3})\)/g)].map((_) => _[1].toUpperCase()) : void 0, Nt = ++Rt.current;
|
|
159
|
+
(x = st.current) == null || x.abort();
|
|
160
|
+
const xt = new AbortController();
|
|
161
|
+
st.current = xt;
|
|
162
|
+
try {
|
|
163
|
+
const _ = await V(v, w, xt.signal, tt);
|
|
164
|
+
if (Nt !== Rt.current) return;
|
|
165
|
+
const Tt = r.getTextarea();
|
|
166
|
+
if (!Tt || Tt.value !== t || w === "location" && _.length === 0) return;
|
|
167
|
+
const q = [];
|
|
168
|
+
if (w === "location")
|
|
169
|
+
for (const y of _)
|
|
170
|
+
q.push({
|
|
171
|
+
key: `loc:${y.insert}`,
|
|
172
|
+
label: `📍 ${y.label}`,
|
|
173
|
+
kind: "namedLocation",
|
|
174
|
+
insert: y.insert,
|
|
175
|
+
hint: [y.iata, y.region, y.country].filter(Boolean).join(" · ") || void 0,
|
|
176
|
+
// parity with the `@` picker
|
|
177
|
+
disabled: y.disabled
|
|
178
|
+
// already in the prompt (same city) — greyed, not pickable
|
|
179
|
+
});
|
|
180
|
+
else
|
|
181
|
+
for (const y of _)
|
|
182
|
+
q.push({ key: `date:${y.insert}`, label: `📅 ${y.label}`, kind: "date", insert: y.insert });
|
|
183
|
+
if (q.push(...ht()), q.length === 0) {
|
|
184
|
+
o(null);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const At = q.findIndex((y) => !y.disabled);
|
|
188
|
+
L(At < 0 ? 0 : At), nt(v.trim() === ""), o(q);
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
}, 200)), W.current != null && window.clearTimeout(W.current), W.current = window.setTimeout(() => {
|
|
195
|
+
ft();
|
|
196
|
+
}, 300);
|
|
197
|
+
}, [ft]), zt = k((t) => {
|
|
198
|
+
var d, p;
|
|
199
|
+
const e = t.trim();
|
|
200
|
+
e && ((p = (d = H.current).commitIntent) == null || p.call(d, e, lt.current, D.current)), D.current = pt(), I.current = !1;
|
|
201
|
+
}, []), Bt = k(() => {
|
|
202
|
+
const t = D.current;
|
|
203
|
+
t.atOpened = !0, I.current ? I.current = !1 : at.current === null && M.current === null && (t.manualAt = !0);
|
|
204
|
+
}, []), Ut = k((t) => {
|
|
205
|
+
D.current.atAccepted = t ?? "location";
|
|
206
|
+
}, []), gt = k(() => {
|
|
207
|
+
D.current.ghostAccepted = !0, I.current = !0, h(null);
|
|
208
|
+
const t = Y.current, e = t.getTextarea();
|
|
209
|
+
if (!e) return;
|
|
210
|
+
const d = e.selectionStart ?? e.value.length, p = e.value.slice(0, d), b = e.value.slice(d), n = `${p.length > 0 && !/\s$/.test(p) ? " " : ""}@`;
|
|
211
|
+
t.setDraft(`${p}${n}${b}`), t.focusCaret(d + n.length), requestAnimationFrame(() => {
|
|
212
|
+
const r = t.getTextarea();
|
|
213
|
+
r && t.syncTrigger(r);
|
|
214
|
+
});
|
|
215
|
+
}, []), Wt = k((t) => {
|
|
216
|
+
if (g !== null && (!i || i.length === 0)) {
|
|
217
|
+
if (t.key === "Tab" || t.key === "ArrowRight")
|
|
218
|
+
return t.preventDefault(), gt(), !0;
|
|
219
|
+
if (t.key === "Escape")
|
|
220
|
+
return t.preventDefault(), h(null), !0;
|
|
221
|
+
}
|
|
222
|
+
if (!i || i.length === 0) return !1;
|
|
223
|
+
if (t.key === "ArrowDown")
|
|
224
|
+
return t.preventDefault(), L((e) => Dt(i, e, 1)), !0;
|
|
225
|
+
if (t.key === "ArrowUp")
|
|
226
|
+
return t.preventDefault(), L((e) => Dt(i, e, -1)), !0;
|
|
227
|
+
if (t.key === "Enter" || t.key === "Tab") {
|
|
228
|
+
t.preventDefault();
|
|
229
|
+
const e = i[rt];
|
|
230
|
+
return e && !e.disabled && dt(e), !0;
|
|
231
|
+
}
|
|
232
|
+
return t.key === "Escape" ? (t.preventDefault(), o(null), !0) : !1;
|
|
233
|
+
}, [i, rt, dt, g, gt]);
|
|
234
|
+
return j(() => () => {
|
|
235
|
+
var t, e;
|
|
236
|
+
U.current != null && window.clearTimeout(U.current), W.current != null && window.clearTimeout(W.current), B.current != null && window.clearTimeout(B.current), (t = it.current) == null || t.abort(), (e = st.current) == null || e.abort();
|
|
237
|
+
}, []), {
|
|
238
|
+
predictions: i,
|
|
239
|
+
predictionsRecents: z,
|
|
240
|
+
predictionHighlight: rt,
|
|
241
|
+
setPredictionHighlight: L,
|
|
242
|
+
applyPrediction: dt,
|
|
243
|
+
clearPredictions: Ot,
|
|
244
|
+
hint: g,
|
|
245
|
+
acceptHint: gt,
|
|
246
|
+
resolvedLocations: Pt,
|
|
247
|
+
resolvedDates: Et,
|
|
248
|
+
forceTooltipText: It,
|
|
249
|
+
personConfidence: Q,
|
|
250
|
+
locationConfidence: F,
|
|
251
|
+
scheduleAssist: Ft,
|
|
252
|
+
commit: zt,
|
|
253
|
+
onKeyDown: Wt,
|
|
254
|
+
resetSession: qt,
|
|
255
|
+
noteAtOpened: Bt,
|
|
256
|
+
noteAtAccepted: Ut
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
C(Zt, "usePromptAssist");
|
|
260
|
+
function Jt(u, l) {
|
|
261
|
+
const m = s(u), [i, o] = $(null);
|
|
262
|
+
return j(() => {
|
|
263
|
+
m.current = u;
|
|
264
|
+
}, [u]), j(() => {
|
|
265
|
+
function g() {
|
|
266
|
+
m.current();
|
|
267
|
+
}
|
|
268
|
+
if (C(g, "tick"), l !== null) {
|
|
269
|
+
const h = setInterval(g, l);
|
|
270
|
+
return o(h), () => {
|
|
271
|
+
clearInterval(h);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}, [l]), i;
|
|
275
|
+
}
|
|
276
|
+
C(Jt, "useInterval");
|
|
277
|
+
function Vt(u, l, m = 0) {
|
|
278
|
+
const [i, o] = $(m);
|
|
279
|
+
return j(() => {
|
|
280
|
+
const g = u.current;
|
|
281
|
+
if (!g) return;
|
|
282
|
+
const h = new ResizeObserver((F) => {
|
|
283
|
+
const S = F[0];
|
|
284
|
+
S && o(S.contentRect.width);
|
|
285
|
+
});
|
|
286
|
+
return h.observe(g), o(g.getBoundingClientRect().width), () => h.disconnect();
|
|
287
|
+
}, [u, l]), i;
|
|
288
|
+
}
|
|
289
|
+
C(Vt, "useContainerWidth");
|
|
290
|
+
function te(u, l, m = 0, i = 0) {
|
|
291
|
+
const [o, g] = $(m), [h, F] = $(i);
|
|
292
|
+
return j(() => {
|
|
293
|
+
const S = u.current;
|
|
294
|
+
if (!S) return;
|
|
295
|
+
const Q = new ResizeObserver((et) => {
|
|
296
|
+
const z = et[0];
|
|
297
|
+
z && (F(z.contentRect.height), g(z.contentRect.width));
|
|
298
|
+
});
|
|
299
|
+
return Q.observe(S), g(S.getBoundingClientRect().width), () => Q.disconnect();
|
|
300
|
+
}, [u, l]), [o, h];
|
|
301
|
+
}
|
|
302
|
+
C(te, "useContainerRectangle");
|
|
303
|
+
export {
|
|
304
|
+
Vt as a,
|
|
305
|
+
Jt as b,
|
|
306
|
+
Zt as c,
|
|
307
|
+
te as u
|
|
308
|
+
};
|
|
309
|
+
//# sourceMappingURL=useContainerWidth-Cs50UcTK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContainerWidth-Cs50UcTK.js","sources":["../src/hooks/usePromptAssist.ts","../src/hooks/useIntervalHook.ts","../src/hooks/useContainerWidth.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type KeyboardEvent } from 'react';\nimport type { PromptAnalysis, PromptResolution, SuggestItem } from '../services/httpPromptAssistService';\n\n/** A dropdown item. `namedLocation` inserts `@Name` directly; `location`/`calendar` insert `@`/`#` and open the picker. */\nexport type PredictionItem = {\n key: string;\n label: string;\n kind: 'location' | 'namedLocation' | 'date' | 'calendar';\n insert?: string;\n /** Secondary line (e.g. \"GRU · SP · Brasil\") — parity with the `@` picker's hint. Optional. */\n hint?: string;\n /** Non-pickable (already in the prompt, same place/city) — rendered greyed and skipped by nav/apply. */\n disabled?: boolean;\n};\n\nexport type ResolvedDateItem = { text: string; display: string };\n\n/**\n * Send-time summary of what the assist UI did during ONE composition (issue #159 Phase 1) — attached to the\n * commit so the server can store {prompt, outcome} as a behavioral label and emit gate-precision metrics:\n * gate fired + assist used ≈ true positive; fired + ignored ≈ false-positive candidate; gate quiet + the user\n * typed `@` themselves ≈ false-negative candidate. Numbers/booleans only, no extra text.\n */\nexport type AssistOutcome = {\n /** Highest location-intent confidence any analyze reported while composing. */\n maxLocationConfidence: number;\n /** Highest person-intent confidence any analyze reported while composing. */\n maxPersonConfidence: number;\n /** Location assist became VISIBLE at least once (dropdown, location ghost, or auto-`@`). */\n locationGateFired: boolean;\n /** The user accepted an item from the predictions dropdown. */\n suggestionAccepted: boolean;\n ghostShown: boolean;\n ghostAccepted: boolean;\n /** The `@` picker was opened at least once (host reports via noteAtOpened). */\n atOpened: boolean;\n /** Section of the last accepted `@` mention (host reports via noteAtAccepted). */\n atAccepted: 'person' | 'location' | null;\n /** The user typed `@` themselves while nothing assist-y was showing — a recall miss signal. */\n manualAt: boolean;\n};\n\nconst emptyOutcome = (): AssistOutcome => ({\n maxLocationConfidence: 0, maxPersonConfidence: 0,\n locationGateFired: false, suggestionAccepted: false,\n ghostShown: false, ghostAccepted: false,\n atOpened: false, atAccepted: null, manualAt: false,\n});\n\n/** The DOM operations the hook needs from its host composer — so the same logic drives PromptV2 and PromptComposer. */\nexport interface PromptAssistAdapter {\n getTextarea: () => HTMLTextAreaElement | null;\n /** Replace the draft value (host owns the React state). */\n setDraft: (next: string) => void;\n /** After a programmatic edit, focus the textarea and place the caret (host defers a frame if needed). */\n focusCaret: (pos: number) => void;\n /** Re-detect the `@`/`#` trigger at the caret and open the matching picker (host's existing flow). */\n syncTrigger: (ta: HTMLTextAreaElement) => void;\n /** Is a location/date picker already open? (suppresses the predictions dropdown / auto-`@`) */\n isPickerOpen: () => boolean;\n /** The trigger char of any open picker, or null — used to avoid re-inserting `@`. */\n currentTriggerChar: () => string | null;\n /** Whether the `@` location fetcher is wired (else no auto-`@` / generic \"Local…\"). */\n hasAtQuery: boolean;\n}\n\nexport interface PromptAssistFetchers {\n analyze?: (text: string, caret: number) => Promise<PromptAnalysis>;\n resolveDates?: (text: string, sessionId?: string, signal?: AbortSignal) => Promise<PromptResolution>;\n commitIntent?: (text: string, sessionId?: string, assist?: AssistOutcome) => void;\n suggest?: (q: string, kind: 'location' | 'date' | 'both', signal?: AbortSignal, exclude?: string[]) => Promise<SuggestItem[]>;\n}\n\nexport interface PromptAssistOptions {\n enableHashDatePicker?: boolean;\n datePresets?: string[];\n /** When true, a location OR person prediction shows a PHANTOM ghost at the caret (\"@ Localidade\" / \"@ Nome\n * pessoa\") teaching the `@` trigger, INSTEAD of auto-opening the location predictions dropdown. Date still uses\n * its dropdown. The host reads `hint` to render the ghost and wires Tab/→ to `acceptHint`. Default false. */\n promptHint?: boolean;\n}\n\nconst newSessionId = () =>\n typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `s-${Date.now()}-${Math.random()}`;\n\n/** Next selectable (non-disabled) index from `from` moving `dir` (±1), wrapping. Stays put if all are disabled. */\nconst nextEnabledIndex = (items: PredictionItem[], from: number, dir: 1 | -1): number => {\n const n = items.length;\n let idx = from;\n for (let step = 0; step < n; step++) {\n idx = (idx + dir + n) % n;\n if (!items[idx]?.disabled) return idx;\n }\n return from;\n};\n\n/** Today + n days, formatted DD/MM/YYYY — the default shown on the \"no dia #…\" date-picker suggestion. */\nconst plusDaysBR = (n: number) => {\n const d = new Date();\n d.setDate(d.getDate() + n);\n const dd = String(d.getDate()).padStart(2, '0');\n const mm = String(d.getMonth() + 1).padStart(2, '0');\n return `${dd}/${mm}/${d.getFullYear()}`;\n};\n\n/**\n * Headless prompt-assist logic shared by the chat composer (PromptV2) and the home composer (obtapp PromptComposer):\n * the analyze quick pass (auto-`@` + combined predictions dropdown), the resolve slow pass (date resolution +\n * mapped-location chips), commit-on-send learning, and keyboard nav — all with NO rendering/anchoring assumptions.\n * The host provides its DOM ops via {@link PromptAssistAdapter} and renders the returned `predictions` however it wants.\n */\nexport function usePromptAssist(\n adapter: PromptAssistAdapter,\n fetchers: PromptAssistFetchers,\n options: PromptAssistOptions = {},\n) {\n const [predictions, setPredictions] = useState<PredictionItem[] | null>(null);\n // #1 phantom teaching cue: which \"@ …\" ghost to paint at the caret (promptHint option) instead of the dropdown —\n // 'location' → \"@ Localidade\", 'person' → \"@ Nome pessoa\", null → none. The dominant intent wins. Cleared each\n // analyze unless re-armed below.\n const [hint, setHint] = useState<'location' | 'person' | null>(null);\n // Latest analyze's location-intent confidence — hosts pass it to fetchAtMentions so the `@` picker leads with\n // Locais when location outweighs person (an `@` in a location context searches places, not people).\n const [locationConfidence, setLocationConfidence] = useState(0);\n // Issue #112 — the latest analyze's person-intent signal (P the user is referring to a PERSON/passenger). Hosts\n // use this to order/section the `@` picker's sources (people vs places). Updated on every analyze; 0 when the\n // feature is off server-side or the text is empty.\n const [personConfidence, setPersonConfidence] = useState(0);\n // True when the current predictions are the \"recents\" set (analyze pre-fill or an empty-query suggest) rather\n // than results for a typed query — lets the host label it \"recentes\" + hint that typing surfaces more.\n const [predictionsRecents, setPredictionsRecents] = useState(false);\n const [predictionHighlight, setPredictionHighlight] = useState(0);\n const [resolvedLocations, setResolvedLocations] = useState<string[]>([]);\n const [resolvedDates, setResolvedDates] = useState<ResolvedDateItem[]>([]);\n // The date text whose marker tooltip should auto-open (set on a NEW resolution, cleared after 2s) — identical\n // to PromptV2's behavior so both composers surface a freshly-resolved date the same way.\n const [forceTooltipText, setForceTooltipText] = useState('');\n const lastResolvedKeyRef = useRef('');\n const tooltipTimerRef = useRef<number | null>(null);\n\n // Latest adapter/fetchers/options via refs — the debounced callbacks must not capture stale closures.\n const adapterRef = useRef(adapter); adapterRef.current = adapter;\n const fetchersRef = useRef(fetchers); fetchersRef.current = fetchers;\n const optionsRef = useRef(options); optionsRef.current = options;\n\n const analyzeTimerRef = useRef<number | null>(null);\n const resolveTimerRef = useRef<number | null>(null);\n const analyzeSeqRef = useRef(0);\n const suggestSeqRef = useRef(0);\n const suggestAbortRef = useRef<AbortController | null>(null);\n const draftRef = useRef('');\n const lastResolveTextRef = useRef<string | null>(null);\n const resolveAbortRef = useRef<AbortController | null>(null);\n const sessionIdRef = useRef<string>(newSessionId());\n // Current predictions (mirror of state) so the debounced analyze can tell if the dropdown is already open —\n // lets us pre-fill only on FIRST open instead of re-flashing the tenant list on every keystroke.\n const predictionsRef = useRef<PredictionItem[] | null>(null);\n predictionsRef.current = predictions;\n // Mirror of hint so the debounced analyze can (a) keep running on deletion while a ghost is up and (b) let\n // onKeyDown accept it without stale closures.\n const hintRef = useRef<'location' | 'person' | null>(null);\n hintRef.current = hint;\n // #1 anti-nag: consecutive analyses the CURRENT ghost kind (hintKindRef) has ridden. After MAX_HINT_STREAK it\n // stops showing (user saw it and kept typing); resets when the kind changes or a cue-less analyze arrives, so a\n // fresh context re-teaches. Keeps the phantom from being sticky.\n const hintStreakRef = useRef(0);\n const hintKindRef = useRef<'location' | 'person' | null>(null);\n const MAX_HINT_STREAK = 4;\n const PERSON_HINT_THRESHOLD = 0.5;\n // The kind the open dropdown is currently showing (null when closed) — lets a trailing space keep an open\n // location dropdown alive (as recents) instead of collapsing it.\n const lastKindRef = useRef<'location' | 'date' | null>(null);\n // The server-parsed location partial the open dropdown filtered on (\"belo\", \"São Paulo\", or \"\" for recents).\n // applyPrediction strips exactly this — including across a trailing space — so a pick REPLACES the partial\n // instead of appending after it, and never eats a completed \"@\" mention (empty partial → append).\n const locationPartialRef = useRef('');\n // Stable pointer to runResolve so applyPrediction (defined earlier) can force a resolve after a date pick.\n const runResolveRef = useRef<() => void>(() => {});\n\n // Issue #159 Phase 1 — the per-composition outcome accumulator (sent with the commit, reset per session).\n const outcomeRef = useRef<AssistOutcome>(emptyOutcome());\n // Set when WE insert the \"@\" (ghost accept / dropdown generic pick / auto-\"@\"), consumed by the host's next\n // noteAtOpened — distinguishes a programmatic picker-open from the user typing \"@\" themselves (manualAt).\n const programmaticAtRef = useRef(false);\n\n const clearPredictions = useCallback(() => setPredictions(null), []);\n\n /** Call when the draft empties (send / reseed): clear mapped data and start a fresh learning session. */\n const resetSession = useCallback(() => {\n setResolvedLocations([]);\n setResolvedDates([]);\n setForceTooltipText('');\n lastResolvedKeyRef.current = '';\n lastResolveTextRef.current = null;\n sessionIdRef.current = newSessionId();\n outcomeRef.current = emptyOutcome();\n programmaticAtRef.current = false;\n }, []);\n\n const applyPrediction = useCallback((p: PredictionItem) => {\n if (p.disabled) return; // already in the prompt (same city) — not selectable; keep the dropdown open\n outcomeRef.current.suggestionAccepted = true;\n if (p.kind === 'location') programmaticAtRef.current = true; // generic pick inserts \"@\" → picker opens programmatically\n setPredictions(null);\n const ad = adapterRef.current;\n const ta = ad.getTextarea();\n if (!ta) return;\n const caret = ta.selectionStart ?? ta.value.length;\n const rawBefore = ta.value.slice(0, caret);\n const after = ta.value.slice(caret);\n // A pick must REPLACE what the dropdown filtered on, not append after it (\"sao @São Paulo\" bug).\n // LOCATIONS: strip exactly the server-parsed partial (locationPartialRef) — this spans a trailing space\n // (\"de belo \" → \"belo\") and is \"\" for a recents/mention pick, so we append instead of eating a finished\n // \"@\" mention. DATES: strip the trailing word as before.\n const isLocationPick = p.kind === 'namedLocation' || p.kind === 'location';\n let before: string;\n if (isLocationPick) {\n const partial = locationPartialRef.current;\n const trimmedEnd = rawBefore.replace(/\\s+$/, '');\n before = partial && trimmedEnd.endsWith(partial) ? trimmedEnd.slice(0, trimmedEnd.length - partial.length) : rawBefore;\n } else {\n const wordStart = rawBefore.search(/\\S+$/);\n before = wordStart === -1 ? rawBefore : rawBefore.slice(0, wordStart);\n }\n const needsSpace = before.length > 0 && !/\\s$/.test(before);\n\n if (p.kind === 'date') {\n const ins = `${needsSpace ? ' ' : ''}${p.insert} `;\n const next = `${before}${ins}${after}`;\n ad.setDraft(next);\n ad.focusCaret(before.length + ins.length);\n // A programmatic setDraft doesn't fire onChange, so force a resolve now → the picked date resolves\n // into its chip/marker immediately instead of waiting for the next keystroke.\n draftRef.current = next;\n lastResolveTextRef.current = null;\n runResolveRef.current();\n return;\n }\n if (p.kind === 'namedLocation' && p.insert) {\n // A specific place → finished \"@\" mention (NBSP-joined so a multi-word name stays one chip / one mention).\n const mention = `@${p.insert.replace(/ /g, String.fromCharCode(0xA0))}`;\n const ins = `${needsSpace ? ' ' : ''}${mention} `;\n ad.setDraft(`${before}${ins}${after}`);\n ad.focusCaret(before.length + ins.length);\n return;\n }\n // Generic location / calendar → insert the trigger char and open the host's picker.\n const chr = p.kind === 'location' ? '@' : '#';\n const ins = `${needsSpace ? ' ' : ''}${chr}`;\n ad.setDraft(`${before}${ins}${after}`);\n ad.focusCaret(before.length + ins.length);\n requestAnimationFrame(() => { const t = ad.getTextarea(); if (t) ad.syncTrigger(t); });\n }, []);\n\n const runResolve = useCallback(async () => {\n const resolve = fetchersRef.current.resolveDates;\n if (!resolve) return;\n const text = draftRef.current;\n if (text.trim() === '') { lastResolveTextRef.current = null; return; }\n if (text === lastResolveTextRef.current) return; // unchanged since last call\n lastResolveTextRef.current = text;\n resolveAbortRef.current?.abort();\n const ac = new AbortController();\n resolveAbortRef.current = ac;\n try {\n const { dates, locations } = await resolve(text, sessionIdRef.current, ac.signal);\n if (draftRef.current !== text) return; // moved on while in flight\n const resolved = dates.filter((d) => d.display).map((d) => ({ text: d.text, display: d.display }));\n setResolvedDates(resolved);\n setResolvedLocations(locations.map((l) => l.text).filter((t) => t.trim().length > 0));\n // Auto-open the newest date's tooltip for 2s (only when the resolution set actually changed).\n const key = resolved.map((r) => `${r.text}=${r.display}`).join('|');\n if (resolved.length > 0 && key !== lastResolvedKeyRef.current) {\n lastResolvedKeyRef.current = key;\n setForceTooltipText(resolved[resolved.length - 1].text);\n if (tooltipTimerRef.current != null) window.clearTimeout(tooltipTimerRef.current);\n tooltipTimerRef.current = window.setTimeout(() => setForceTooltipText(''), 2000);\n }\n if (resolved.length === 0) lastResolvedKeyRef.current = '';\n } catch { /* ignore — includes AbortError from a superseded call */ }\n }, []);\n runResolveRef.current = runResolve;\n\n /** Call from the textarea's onChange. Runs the debounced analyze (200ms) + resolve (300ms) passes. */\n const scheduleAssist = useCallback((value: string, caret: number, isDeletion: boolean) => {\n draftRef.current = value;\n const analyze = fetchersRef.current.analyze;\n // Run analyze on typing, AND on deletion WHILE the dropdown is open — so backspacing re-filters the list\n // (shorter query) and closes it once the context ends. When nothing's open, deletion still skips analyze\n // (no auto-'@' / churn while correcting text elsewhere).\n if (analyze && (!isDeletion || predictionsRef.current !== null || hintRef.current !== null)) {\n if (analyzeTimerRef.current != null) window.clearTimeout(analyzeTimerRef.current);\n analyzeTimerRef.current = window.setTimeout(async () => {\n const seq = ++analyzeSeqRef.current;\n try {\n const a = await analyze(value, caret);\n if (seq !== analyzeSeqRef.current) return;\n const ad = adapterRef.current;\n const live = ad.getTextarea();\n if (!live || live.value !== value) return;\n\n // Person-intent (issue #112) — surfaced regardless of the loc/date dropdown decision below, so the\n // host's `@` picker can consult it whether or not a predictions dropdown is currently open.\n setPersonConfidence(a.personConfidence ?? 0);\n setLocationConfidence(a.locationConfidence ?? 0);\n // #159 Phase 1 — outcome accumulator: the composition's peak confidences.\n const outcome = outcomeRef.current;\n outcome.maxPersonConfidence = Math.max(outcome.maxPersonConfidence, a.personConfidence ?? 0);\n outcome.maxLocationConfidence = Math.max(outcome.maxLocationConfidence, a.locationConfidence ?? 0);\n // Default the ghost off; the block below re-arms it in promptHint mode. Makes every early-return\n // path (safeguards, gating) clear a stale ghost.\n setHint(null);\n\n const caretEnd = (live.selectionStart ?? caret) === value.length;\n const canLoc = ad.hasAtQuery;\n const pickerOpen = ad.isPickerOpen();\n const named = a.suggestions ?? [];\n const { enableHashDatePicker = false, datePresets = ['amanhã de manhã', 'quarta-feira à noite'] } = optionsRef.current;\n\n // Single-winner dropdown kind: prefer a.category, else fall back to the (at-most-one) expected flags.\n let decided: 'location' | 'date' | null =\n a.category === 'location' ? 'location'\n : a.category === 'date' ? 'date'\n : a.locationExpected ? 'location'\n : a.dateExpected ? 'date'\n : null;\n // Grace: a bare trailing space shouldn't collapse — OR flip to dates — an already-open location\n // dropdown. After the space the server may report \"done\" (null) OR predict a date (a learned\n // \"de [loc] \" → date template), but the user just hit space and is likely still on the location —\n // keep it open as the LOCATION recents list (empty query → suggest returns recents). Overrides\n // null AND date. Only when it was a location dropdown, suggest is wired, the caret's at the end,\n // and the text ends in a space. Typing an actual date WORD (no trailing space) still switches.\n // Not when 2 locations are already present — then the natural next slot is a DATE, so let it through.\n if (decided !== 'location' && a.locationCount < 2 && Boolean(fetchersRef.current.suggest)\n && predictionsRef.current !== null && lastKindRef.current === 'location' && caretEnd && /\\s$/.test(value)) {\n decided = 'location';\n }\n // #1 phantom cue: pick the DOMINANT intent and paint an \"@ …\" ghost teaching the trigger, instead\n // of a dropdown. Person can win even when the loc/date ladder is null (\"adiciona o joão\"), so we\n // decide here — BEFORE the dropdown gating. Requires promptHint mode, caret at end, no picker open.\n if (optionsRef.current.promptHint && caretEnd && !pickerOpen) {\n const per = a.personConfidence ?? 0;\n const loc = a.locationConfidence ?? 0;\n // Location ghost only when the ladder actually expects a location and it isn't the suppressed\n // 3rd-location case. Person wins ties-and-above only when it clears its threshold.\n const locationGhost = decided === 'location' && !(a.locationCount >= 2 && a.locationPartialEmpty);\n const kind: 'location' | 'person' | null =\n (per >= PERSON_HINT_THRESHOLD && per >= loc) ? 'person'\n : locationGhost ? 'location'\n : null;\n if (kind) {\n if (kind !== hintKindRef.current) hintStreakRef.current = 0; // new context → restart streak\n hintKindRef.current = kind;\n hintStreakRef.current += 1;\n if (hintStreakRef.current <= MAX_HINT_STREAK) {\n setHint(kind); // else stay hidden (anti-nag)\n outcome.ghostShown = true;\n if (kind === 'location') outcome.locationGateFired = true;\n }\n setPredictions(null);\n lastKindRef.current = null;\n return;\n }\n // Ghost mode but nothing to teach this cycle → reset so a fresh context re-shows the phantom.\n hintKindRef.current = null;\n hintStreakRef.current = 0;\n }\n\n // 2-location safeguard: with origin + destination already present, a merely PREDICTED (not-being-\n // typed) 3rd location — typically just the model guessing — shouldn't open a dropdown. Actively\n // typing a 3rd location (partial non-empty) still shows.\n if (decided === 'location' && a.locationCount >= 2 && a.locationPartialEmpty) {\n setPredictions(null); lastKindRef.current = null; return;\n }\n\n // A location dropdown needs the `@` fetcher wired to be useful.\n const kindActive = decided === 'location' ? canLoc : decided === 'date';\n\n // Gating: caret at end, no picker open.\n if (decided === null || !(caretEnd && !pickerOpen && kindActive)) { setPredictions(null); lastKindRef.current = null; return; }\n // In promptHint mode a LOCATION is already handled by the ghost block above (returns), so reaching\n // here means either the dropdown mode (promptHint off) or a DATE — both use the dropdown below.\n const kind: 'location' | 'date' = decided;\n lastKindRef.current = kind;\n // Location assist is about to surface (dropdown or the auto-\"@\" fallback below) — with the\n // blank-query pre-search in place the dropdown virtually always has content past this gate.\n if (kind === 'location') outcome.locationGateFired = true;\n\n // Generic affordances appended after the named items. The location \"Local…\" entry is gone —\n // free-form typing now searches directly, so it's redundant. The date picker entry stays.\n const genericTail = (): PredictionItem[] =>\n kind === 'date' && enableHashDatePicker\n ? [{ key: 'cal', label: `📅 no dia #${plusDaysBR(2)}`, kind: 'calendar' } as PredictionItem]\n : [];\n\n const namedLocs = named.filter((s) => s.kind === 'location');\n const namedDates = named.filter((s) => s.kind === 'date').map((s) => s.value);\n\n // Pre-fill immediately (no await) from analyze's suggestions so the user sees something instantly.\n const prefill: PredictionItem[] = [];\n if (kind === 'location') {\n for (const s of namedLocs)\n prefill.push({ key: `loc:${s.value}`, label: `📍 ${s.label}`, kind: 'namedLocation', insert: s.value });\n prefill.push(...genericTail());\n } else {\n for (const d of (namedDates.length > 0 ? namedDates : datePresets))\n prefill.push({ key: `date:${d}`, label: `📅 ${d}`, kind: 'date', insert: d });\n prefill.push(...genericTail());\n }\n\n const suggest = fetchersRef.current.suggest;\n const hasNamed = kind === 'location' ? namedLocs.length > 0 : true;\n\n // If the dropdown would be empty AND there's no suggest fetcher to fill it, fall back to auto-'@'.\n if (kind === 'location' && !hasNamed && !suggest) {\n if (!isDeletion && a.locationExpected && a.locationPartialEmpty && a.locationCount < 2\n && canLoc && ad.currentTriggerChar() !== '@') {\n const c = live.selectionStart ?? value.length;\n const before = value.slice(0, c);\n const needsSpace = before.length > 0 && !/\\s$/.test(before);\n if (!before.endsWith('@')) {\n const insert = needsSpace ? ' @' : '@';\n programmaticAtRef.current = true; // auto-\"@\" → the picker opens programmatically\n setPredictions(null);\n ad.setDraft(`${before}${insert}${value.slice(c)}`);\n ad.focusCaret(c + insert.length);\n requestAnimationFrame(() => { const t = ad.getTextarea(); if (t) ad.syncTrigger(t); });\n }\n return;\n }\n setPredictions(null);\n return;\n }\n\n // Show the pre-filled list. With a suggest fetcher wired, only pre-fill on FIRST open (when the\n // dropdown was closed) — re-setting it every keystroke re-flashes the tenant list under the\n // incoming search results. Once open, keep the current list and let suggest refine it below.\n // Without a suggest fetcher, the pre-fill IS the content, so keep updating it each keystroke.\n if (!suggest) {\n if (prefill.length > 0) { setPredictionHighlight(0); setPredictionsRecents(true); setPredictions(prefill); }\n else setPredictions(null);\n } else if (predictionsRef.current === null && prefill.length > 0) {\n setPredictionHighlight(0);\n setPredictionsRecents(true); // pre-fill = the user's history = recents\n setPredictions(prefill);\n }\n\n // Then refine via the host-provided unified suggest source (search-as-you-type).\n if (suggest) {\n // Query = what the user is typing for the current slot. For LOCATIONS the server owns the\n // parse (a.locationPartial: \"@\"-mentions stripped, so \"@São Paulo \" → \"\" → recents and\n // \"de belo \" → \"belo\" → filter) — no client-side whitespace guessing, which can't tell a\n // partial from a cue or a finished mention. Falls back to the trailing word for dates, or if\n // an older server didn't send the field.\n const beforeCaret = value.slice(0, live.selectionStart ?? value.length);\n const wsIdx = beforeCaret.search(/[ \\t\\r\\n](?=[^ \\t\\r\\n]*$)/);\n const trailingWord = wsIdx === -1 ? beforeCaret : beforeCaret.slice(wsIdx + 1);\n const q = kind === 'location' && a.locationPartial !== undefined ? a.locationPartial : trailingWord;\n // Remember what a location pick should replace (server partial, or the trailing word fallback).\n if (kind === 'location') locationPartialRef.current = q;\n\n // Locations already picked in the prompt (the \"@(IATA) …\" mentions) — the suggest source\n // drops them AND anything in the same city, so it never offers an impossible SAO→SAO / GRU→CGH.\n const exclude = kind === 'location'\n ? [...value.matchAll(/@\\(([A-Za-z]{3})\\)/g)].map((m) => m[1].toUpperCase())\n : undefined;\n\n const sseq = ++suggestSeqRef.current;\n suggestAbortRef.current?.abort();\n const ac = new AbortController();\n suggestAbortRef.current = ac;\n try {\n const items = await suggest(q, kind, ac.signal, exclude);\n if (sseq !== suggestSeqRef.current) return; // overtaken\n const live2 = ad.getTextarea();\n if (!live2 || live2.value !== value) return; // text changed while in flight\n // Keep the useful pre-filled list on an empty result — the \"user is ignoring the dropdown\"\n // case is handled by the server's word cap (partial > 3 plain words → not a location).\n if (kind === 'location' && items.length === 0) return;\n\n const refined: PredictionItem[] = [];\n if (kind === 'location') {\n for (const it of items)\n refined.push({\n key: `loc:${it.insert}`, label: `📍 ${it.label}`, kind: 'namedLocation', insert: it.insert,\n hint: [it.iata, it.region, it.country].filter(Boolean).join(' · ') || undefined, // parity with the `@` picker\n disabled: it.disabled, // already in the prompt (same city) — greyed, not pickable\n });\n } else {\n for (const it of items)\n refined.push({ key: `date:${it.insert}`, label: `📅 ${it.label}`, kind: 'date', insert: it.insert });\n }\n refined.push(...genericTail());\n if (refined.length === 0) { setPredictions(null); return; } // nothing to show\n const firstEnabled = refined.findIndex((p) => !p.disabled); // don't land the highlight on a disabled item\n setPredictionHighlight(firstEnabled < 0 ? 0 : firstEnabled);\n setPredictionsRecents(q.trim() === ''); // empty query → recents; typed query → search results\n setPredictions(refined);\n } catch { /* ignore — includes AbortError from a superseded call */ }\n }\n } catch { /* transient — ignore */ }\n }, 200);\n }\n\n if (resolveTimerRef.current != null) window.clearTimeout(resolveTimerRef.current);\n resolveTimerRef.current = window.setTimeout(() => { void runResolve(); }, 300);\n }, [runResolve]);\n\n /** Call on send with the FINAL text (NBSP-preserving) so the server learns the committed intent. Attaches the\n * composition's assist outcome (#159 Phase 1) as the behavioral label, then resets the accumulator. */\n const commit = useCallback((finalText: string) => {\n const t = finalText.trim();\n if (t) fetchersRef.current.commitIntent?.(t, sessionIdRef.current, outcomeRef.current);\n outcomeRef.current = emptyOutcome();\n programmaticAtRef.current = false;\n }, []);\n\n /** Host reports: the `@` picker opened. Distinguishes a programmatic open (ghost accept / dropdown pick /\n * auto-`@` — we set the flag ourselves) from the user typing `@` with no assist showing (manualAt: the gate\n * stayed quiet but the user wanted a mention — a recall-miss label). */\n const noteAtOpened = useCallback(() => {\n const outcome = outcomeRef.current;\n outcome.atOpened = true;\n if (programmaticAtRef.current) programmaticAtRef.current = false; // consume — not manual\n else if (hintRef.current === null && predictionsRef.current === null) outcome.manualAt = true;\n }, []);\n\n /** Host reports: an `@` mention was accepted, from the given section (undefined ⇒ single-source picker). */\n const noteAtAccepted = useCallback((group?: 'person' | 'location') => {\n outcomeRef.current.atAccepted = group ?? 'location';\n }, []);\n\n /** #1: accept the phantom ghost (location OR person) — insert \"@\" at the caret (a leading space if the char\n * before isn't whitespace, so it never concatenates) and open the host's `@` picker, which sections itself into\n * Pessoas/Locais. The teach-the-trigger payoff, identical for both ghost kinds. */\n const acceptHint = useCallback(() => {\n outcomeRef.current.ghostAccepted = true;\n programmaticAtRef.current = true; // the \"@\" we insert below opens the picker programmatically\n setHint(null);\n const ad = adapterRef.current;\n const ta = ad.getTextarea();\n if (!ta) return;\n const caret = ta.selectionStart ?? ta.value.length;\n const before = ta.value.slice(0, caret);\n const after = ta.value.slice(caret);\n const needsSpace = before.length > 0 && !/\\s$/.test(before);\n const ins = `${needsSpace ? ' ' : ''}@`;\n ad.setDraft(`${before}${ins}${after}`);\n ad.focusCaret(caret + ins.length);\n requestAnimationFrame(() => { const t = ad.getTextarea(); if (t) ad.syncTrigger(t); });\n }, []);\n\n /** Wire to the textarea's onKeyDown; returns true if it handled the key (host should then stop). */\n const onKeyDown = useCallback((e: KeyboardEvent<HTMLTextAreaElement>): boolean => {\n // #1 ghost: with a phantom up and no dropdown, Tab/→ accepts it (inserts \"@\"), Esc dismisses. The caret is\n // at end-of-text here (analyze gates on caretEnd), so → is a safe accept key and doesn't eat a cursor move.\n if (hint !== null && (!predictions || predictions.length === 0)) {\n if (e.key === 'Tab' || e.key === 'ArrowRight') { e.preventDefault(); acceptHint(); return true; }\n if (e.key === 'Escape') { e.preventDefault(); setHint(null); return true; }\n }\n if (!predictions || predictions.length === 0) return false;\n if (e.key === 'ArrowDown') { e.preventDefault(); setPredictionHighlight((i) => nextEnabledIndex(predictions, i, 1)); return true; }\n if (e.key === 'ArrowUp') { e.preventDefault(); setPredictionHighlight((i) => nextEnabledIndex(predictions, i, -1)); return true; }\n if (e.key === 'Enter' || e.key === 'Tab') { e.preventDefault(); const it = predictions[predictionHighlight]; if (it && !it.disabled) applyPrediction(it); return true; }\n if (e.key === 'Escape') { e.preventDefault(); setPredictions(null); return true; }\n return false;\n }, [predictions, predictionHighlight, applyPrediction, hint, acceptHint]);\n\n useEffect(() => () => {\n if (analyzeTimerRef.current != null) window.clearTimeout(analyzeTimerRef.current);\n if (resolveTimerRef.current != null) window.clearTimeout(resolveTimerRef.current);\n if (tooltipTimerRef.current != null) window.clearTimeout(tooltipTimerRef.current);\n resolveAbortRef.current?.abort();\n suggestAbortRef.current?.abort();\n }, []);\n\n return {\n predictions, predictionsRecents, predictionHighlight, setPredictionHighlight,\n applyPrediction, clearPredictions,\n hint, acceptHint,\n resolvedLocations, resolvedDates, forceTooltipText,\n personConfidence, locationConfidence,\n scheduleAssist, commit, onKeyDown, resetSession,\n noteAtOpened, noteAtAccepted,\n };\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n// Custom useInterval hook\nfunction useInterval(callback: () => void, delay: number) {\n const savedCallback = useRef(callback);\n const [intervalId, setIntervalId] = useState<NodeJS.Timeout | null>(null)\n\n // Remember the latest callback.\n useEffect(() => {\n savedCallback.current = callback;\n }, [callback]);\n\n // Set up the interval.\n useEffect(() => {\n function tick() {\n savedCallback.current();\n }\n if (delay !== null) {\n const id = setInterval(tick, delay);\n setIntervalId(id)\n return () => {\n\n clearInterval(id); // Cleanup function\n }\n }\n }, [delay]);\n\n return intervalId;\n}\n\nexport default useInterval","import { useState, useEffect } from \"react\";\n\nexport function useContainerWidth(ref: React.RefObject<HTMLElement | null>, renderId: string, initialWidth = 0) {\n const [width, setWidth] = useState(initialWidth);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) setWidth(entry.contentRect.width);\n });\n\n observer.observe(el);\n setWidth(el.getBoundingClientRect().width);\n\n return () => observer.disconnect();\n }, [ref, renderId]);\n\n return width;\n}\n\nexport function useContainerRectangle(ref: React.RefObject<HTMLElement | null>, renderId: string, initialWidth = 0, initialHeight = 0) {\n const [width, setWidth] = useState(initialWidth);\n const [height, setHeight] = useState(initialHeight);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n\n const observer = new ResizeObserver((entries) => {\n const entry = entries[0];\n if (entry) {\n setHeight(entry.contentRect.height);\n setWidth(entry.contentRect.width);\n }\n });\n\n observer.observe(el);\n setWidth(el.getBoundingClientRect().width);\n\n return () => observer.disconnect();\n }, [ref, renderId]);\n\n return [width, height];\n}"],"names":["emptyOutcome","__name","newSessionId","nextEnabledIndex","items","from","dir","n","idx","step","_a","plusDaysBR","d","dd","mm","usePromptAssist","adapter","fetchers","options","predictions","setPredictions","useState","hint","setHint","locationConfidence","setLocationConfidence","personConfidence","setPersonConfidence","predictionsRecents","setPredictionsRecents","predictionHighlight","setPredictionHighlight","resolvedLocations","setResolvedLocations","resolvedDates","setResolvedDates","forceTooltipText","setForceTooltipText","lastResolvedKeyRef","useRef","tooltipTimerRef","adapterRef","fetchersRef","optionsRef","analyzeTimerRef","resolveTimerRef","analyzeSeqRef","suggestSeqRef","suggestAbortRef","draftRef","lastResolveTextRef","resolveAbortRef","sessionIdRef","predictionsRef","hintRef","hintStreakRef","hintKindRef","MAX_HINT_STREAK","PERSON_HINT_THRESHOLD","lastKindRef","locationPartialRef","runResolveRef","outcomeRef","programmaticAtRef","clearPredictions","useCallback","resetSession","applyPrediction","p","ad","ta","caret","rawBefore","after","isLocationPick","before","partial","trimmedEnd","wordStart","needsSpace","ins","next","mention","chr","t","runResolve","resolve","text","ac","dates","locations","resolved","l","key","r","scheduleAssist","value","isDeletion","analyze","seq","a","live","outcome","caretEnd","canLoc","pickerOpen","named","enableHashDatePicker","datePresets","decided","per","loc","locationGhost","kind","genericTail","namedLocs","s","namedDates","prefill","suggest","hasNamed","insert","beforeCaret","wsIdx","trailingWord","q","exclude","m","sseq","live2","refined","it","firstEnabled","commit","finalText","noteAtOpened","noteAtAccepted","group","acceptHint","onKeyDown","e","i","useEffect","_b","useInterval","callback","delay","savedCallback","intervalId","setIntervalId","tick","id","useContainerWidth","ref","renderId","initialWidth","width","setWidth","el","observer","entries","entry","useContainerRectangle","initialHeight","height","setHeight"],"mappings":";;;AA0CA,MAAMA,KAAe,gBAAAC,EAAA,OAAsB;AAAA,EACvC,uBAAuB;AAAA,EAAG,qBAAqB;AAAA,EAC/C,mBAAmB;AAAA,EAAO,oBAAoB;AAAA,EAC9C,YAAY;AAAA,EAAO,eAAe;AAAA,EAClC,UAAU;AAAA,EAAO,YAAY;AAAA,EAAM,UAAU;AACjD,IALqB,iBAwCfC,KAAe,gBAAAD,EAAA,MACjB,OAAO,SAAW,OAAe,OAAO,aAAa,OAAO,WAAA,IAAe,KAAK,KAAK,IAAA,CAAK,IAAI,KAAK,QAAQ,IAD1F,iBAIfE,KAAmB,gBAAAF,EAAA,CAACG,GAAyBC,GAAcC,MAAwB;;AACrF,QAAMC,IAAIH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ils-CUVZ6Dq1.js";
|
|
2
|
-
import { A as g, a as U, b as E, G as S, d as p, c as m, e as B, f as L, g as f, h, i as v, j as N, k as D, l as _, m as C, n as b, o as x, p as O, q as G, r as V, s as k, t as F, u as T, v as u } from "./auth-
|
|
3
|
-
import { S as R, c as W, a as y, e as q, b as H, f as P, i as j, d as w, p as z, g as J, s as K, k as Y, t as Q } from "./atMentions-
|
|
2
|
+
import { A as g, a as U, b as E, G as S, d as p, c as m, e as B, f as L, g as f, h, i as v, j as N, k as D, l as _, m as C, n as b, o as x, p as O, q as G, r as V, s as k, t as F, u as T, v as u } from "./auth-ffNUief3.js";
|
|
3
|
+
import { S as R, c as W, a as y, e as q, b as H, f as P, i as j, d as w, p as z, g as J, s as K, k as Y, t as Q } from "./atMentions-C5Fs9Yab.js";
|
|
4
4
|
export {
|
|
5
5
|
g as ALLOWED_DOMAINS,
|
|
6
6
|
U as ALLOWED_EMAILS,
|