@devicai/ui 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js +334 -0
  2. package/dist/cjs/components/AIElementWrapper/AIElementWrapper.js.map +1 -0
  3. package/dist/cjs/components/AIElementWrapper/activeWrapperRegistry.js +30 -0
  4. package/dist/cjs/components/AIElementWrapper/activeWrapperRegistry.js.map +1 -0
  5. package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js +161 -0
  6. package/dist/cjs/components/AIElementWrapper/useAIElementWrapper.js.map +1 -0
  7. package/dist/cjs/components/ChatDrawer/ChatDrawer.js +34 -4
  8. package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
  9. package/dist/cjs/components/ChatDrawer/ChatInput.js +8 -2
  10. package/dist/cjs/components/ChatDrawer/ChatInput.js.map +1 -1
  11. package/dist/cjs/components/ChatDrawer/ChatMessages.js +29 -2
  12. package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
  13. package/dist/cjs/components/ChatDrawer/HandoffSubagentWidget.js +1 -1
  14. package/dist/cjs/hooks/useDevicChat.js +1 -1
  15. package/dist/cjs/index.js +4 -0
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/provider/DevicProvider.js +53 -14
  18. package/dist/cjs/provider/DevicProvider.js.map +1 -1
  19. package/dist/cjs/styles.css +1 -1
  20. package/dist/esm/components/AIElementWrapper/AIElementWrapper.d.ts +14 -0
  21. package/dist/esm/components/AIElementWrapper/AIElementWrapper.js +332 -0
  22. package/dist/esm/components/AIElementWrapper/AIElementWrapper.js.map +1 -0
  23. package/dist/esm/components/AIElementWrapper/AIElementWrapper.types.d.ts +185 -0
  24. package/dist/esm/components/AIElementWrapper/activeWrapperRegistry.d.ts +10 -0
  25. package/dist/esm/components/AIElementWrapper/activeWrapperRegistry.js +26 -0
  26. package/dist/esm/components/AIElementWrapper/activeWrapperRegistry.js.map +1 -0
  27. package/dist/esm/components/AIElementWrapper/index.d.ts +3 -0
  28. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.d.ts +26 -0
  29. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js +159 -0
  30. package/dist/esm/components/AIElementWrapper/useAIElementWrapper.js.map +1 -0
  31. package/dist/esm/components/ChatDrawer/ChatDrawer.js +34 -4
  32. package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
  33. package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +11 -0
  34. package/dist/esm/components/ChatDrawer/ChatInput.d.ts +1 -1
  35. package/dist/esm/components/ChatDrawer/ChatInput.js +8 -2
  36. package/dist/esm/components/ChatDrawer/ChatInput.js.map +1 -1
  37. package/dist/esm/components/ChatDrawer/ChatMessages.js +29 -2
  38. package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
  39. package/dist/esm/components/ChatDrawer/HandoffSubagentWidget.js +1 -1
  40. package/dist/esm/hooks/useDevicChat.js +1 -1
  41. package/dist/esm/index.d.ts +3 -1
  42. package/dist/esm/index.js +2 -0
  43. package/dist/esm/index.js.map +1 -1
  44. package/dist/esm/provider/DevicProvider.js +54 -15
  45. package/dist/esm/provider/DevicProvider.js.map +1 -1
  46. package/dist/esm/provider/index.d.ts +1 -1
  47. package/dist/esm/provider/types.d.ts +50 -0
  48. package/dist/esm/styles.css +1 -1
  49. package/package.json +1 -1
@@ -0,0 +1,334 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var reactDom = require('react-dom');
6
+ var DevicContext = require('../../provider/DevicContext.js');
7
+ var index = require('../../utils/index.js');
8
+ var useAIElementWrapper = require('./useAIElementWrapper.js');
9
+ var activeWrapperRegistry = require('./activeWrapperRegistry.js');
10
+
11
+ const DEFAULT_OPTIONS = {
12
+ showOn: 'hover',
13
+ triggerPlacement: 'bottom',
14
+ tooltipPlacement: 'bottom',
15
+ tooltipWidth: 360,
16
+ triggerLabel: 'Preguntar a IA',
17
+ highlightOnInteract: true,
18
+ zIndex: 2147483000,
19
+ triggerBorderRadius: 999,
20
+ color: undefined,
21
+ drawerPromptPrefix: undefined,
22
+ defaultInlinePrompt: undefined,
23
+ };
24
+ function rectFromDom(rect) {
25
+ return { top: rect.top, left: rect.left, width: rect.width, height: rect.height };
26
+ }
27
+ function placementStyle(placement, anchor, offset = 8) {
28
+ const cx = anchor.left + anchor.width / 2;
29
+ const cy = anchor.top + anchor.height / 2;
30
+ switch (placement) {
31
+ case 'top':
32
+ return { position: 'fixed', top: anchor.top - offset, left: cx, transform: 'translate(-50%, -100%)' };
33
+ case 'bottom':
34
+ return { position: 'fixed', top: anchor.top + anchor.height + offset, left: cx, transform: 'translateX(-50%)' };
35
+ case 'left':
36
+ return { position: 'fixed', top: cy, left: anchor.left - offset, transform: 'translate(-100%, -50%)' };
37
+ case 'right':
38
+ return { position: 'fixed', top: cy, left: anchor.left + anchor.width + offset, transform: 'translateY(-50%)' };
39
+ }
40
+ }
41
+ /**
42
+ * AIElementWrapper wraps an arbitrary React node and exposes an AI trigger
43
+ * that can either show an inline floating tooltip with the assistant's
44
+ * answer (`behavior='inline'`) or push a reference to the registered
45
+ * ChatDrawer (`behavior='drawer'`).
46
+ *
47
+ * The trigger and inline tooltip are rendered through a React portal anchored
48
+ * to the wrapped element, so they always sit above other UI (including the
49
+ * ChatDrawer) regardless of stacking context.
50
+ */
51
+ const AIElementWrapper = React.forwardRef(function AIElementWrapper(props, ref) {
52
+ const { label, data, referenceContent, behavior = 'inline', trigger, options = {}, assistantId, getPrompt, apiKey, baseUrl, tenantId, tenantMetadata, modelInterfaceTools, inlineRenderer, onActivate, onInlineResponse, onError, className, style, children, } = props;
53
+ const merged = React.useMemo(() => ({ ...DEFAULT_OPTIONS, ...options }), [options]);
54
+ // Stable instance ID used by the active-wrapper registry (singleton)
55
+ const wrapperIdRef = React.useRef('');
56
+ if (!wrapperIdRef.current)
57
+ wrapperIdRef.current = index.generateId();
58
+ const [activeWrapperId, setActiveWrapperLocal] = React.useState(activeWrapperRegistry.getActiveWrapper());
59
+ React.useEffect(() => activeWrapperRegistry.subscribeActiveWrapper(setActiveWrapperLocal), []);
60
+ const context = DevicContext.useOptionalDevicContext();
61
+ const containerRef = React.useRef(null);
62
+ const tooltipRef = React.useRef(null);
63
+ const triggerRef = React.useRef(null);
64
+ const [isHovered, setIsHovered] = React.useState(false);
65
+ const hoverTimerRef = React.useRef(null);
66
+ const setHoveredImmediately = React.useCallback((v) => {
67
+ if (hoverTimerRef.current) {
68
+ clearTimeout(hoverTimerRef.current);
69
+ hoverTimerRef.current = null;
70
+ }
71
+ if (v) {
72
+ setIsHovered(true);
73
+ }
74
+ else {
75
+ // Grace period so the cursor can travel from the wrapper to the
76
+ // portal-rendered trigger without the trigger disappearing mid-flight.
77
+ hoverTimerRef.current = setTimeout(() => setIsHovered(false), 200);
78
+ }
79
+ }, []);
80
+ React.useEffect(() => () => {
81
+ if (hoverTimerRef.current)
82
+ clearTimeout(hoverTimerRef.current);
83
+ }, []);
84
+ const [isInlineOpen, setIsInlineOpen] = React.useState(false);
85
+ const [containerRect, setContainerRect] = React.useState(null);
86
+ const [selectionRect, setSelectionRect] = React.useState(null);
87
+ const inline = useAIElementWrapper.useAIElementWrapper({
88
+ assistantId,
89
+ apiKey,
90
+ baseUrl,
91
+ tenantId,
92
+ tenantMetadata,
93
+ modelInterfaceTools,
94
+ onResponse: onInlineResponse,
95
+ onError,
96
+ });
97
+ // What this wrapper would show if there were no coordination.
98
+ const wantsTriggerVisible = merged.showOn === 'always' ||
99
+ (merged.showOn === 'hover' && isHovered) ||
100
+ (merged.showOn === 'click' && isInlineOpen) ||
101
+ (merged.showOn === 'select' && selectionRect !== null);
102
+ // Coordinate via the singleton registry so only one wrapper shows the
103
+ // floating trigger at a time. The most recent wrapper to want visibility
104
+ // wins; others hide until they are activated again.
105
+ const isActive = activeWrapperId === wrapperIdRef.current;
106
+ const triggerVisible = wantsTriggerVisible && (activeWrapperId === null || isActive);
107
+ React.useEffect(() => {
108
+ const id = wrapperIdRef.current;
109
+ if (wantsTriggerVisible) {
110
+ activeWrapperRegistry.setActiveWrapper(id);
111
+ }
112
+ else if (activeWrapperRegistry.getActiveWrapper() === id) {
113
+ activeWrapperRegistry.setActiveWrapper(null);
114
+ }
115
+ }, [wantsTriggerVisible]);
116
+ // Release the registry slot if the component unmounts while active.
117
+ React.useEffect(() => () => {
118
+ if (activeWrapperRegistry.getActiveWrapper() === wrapperIdRef.current) {
119
+ activeWrapperRegistry.setActiveWrapper(null);
120
+ }
121
+ }, []);
122
+ // Track container rect (for hover/click/always trigger and tooltip anchor)
123
+ const updateContainerRect = React.useCallback(() => {
124
+ const el = containerRef.current;
125
+ if (!el)
126
+ return;
127
+ setContainerRect(rectFromDom(el.getBoundingClientRect()));
128
+ }, []);
129
+ React.useLayoutEffect(() => {
130
+ if (!triggerVisible && !isInlineOpen)
131
+ return;
132
+ updateContainerRect();
133
+ const onScrollOrResize = () => updateContainerRect();
134
+ window.addEventListener('scroll', onScrollOrResize, true);
135
+ window.addEventListener('resize', onScrollOrResize);
136
+ return () => {
137
+ window.removeEventListener('scroll', onScrollOrResize, true);
138
+ window.removeEventListener('resize', onScrollOrResize);
139
+ };
140
+ }, [triggerVisible, isInlineOpen, updateContainerRect]);
141
+ // selectionchange listener for showOn='select'
142
+ React.useEffect(() => {
143
+ if (merged.showOn !== 'select') {
144
+ setSelectionRect(null);
145
+ return;
146
+ }
147
+ const isInside = (node, cont) => {
148
+ if (!node)
149
+ return false;
150
+ if (node === cont)
151
+ return true;
152
+ return cont.contains(node);
153
+ };
154
+ const recompute = () => {
155
+ const sel = window.getSelection();
156
+ const cont = containerRef.current;
157
+ if (!sel || sel.isCollapsed || !cont || sel.rangeCount === 0) {
158
+ setSelectionRect(null);
159
+ return;
160
+ }
161
+ // Don't react to selections happening elsewhere — but tolerate the
162
+ // case where anchor or focus are inside our container.
163
+ if (!isInside(sel.anchorNode, cont) && !isInside(sel.focusNode, cont)) {
164
+ setSelectionRect(null);
165
+ return;
166
+ }
167
+ const range = sel.getRangeAt(0);
168
+ const rect = range.getBoundingClientRect();
169
+ if (rect.width === 0 && rect.height === 0) {
170
+ setSelectionRect(null);
171
+ return;
172
+ }
173
+ setSelectionRect(rectFromDom(rect));
174
+ };
175
+ const onMouseUp = () => {
176
+ // Run on next tick so the browser commits the final selection state.
177
+ setTimeout(recompute, 0);
178
+ };
179
+ document.addEventListener('selectionchange', recompute);
180
+ document.addEventListener('mouseup', onMouseUp);
181
+ return () => {
182
+ document.removeEventListener('selectionchange', recompute);
183
+ document.removeEventListener('mouseup', onMouseUp);
184
+ };
185
+ }, [merged.showOn]);
186
+ const buildPrompt = React.useCallback(() => {
187
+ if (getPrompt)
188
+ return getPrompt({ data, label });
189
+ if (merged.defaultInlinePrompt)
190
+ return merged.defaultInlinePrompt;
191
+ // Use selected text if available, otherwise fall back to label
192
+ if (merged.showOn === 'select') {
193
+ const sel = window.getSelection();
194
+ const txt = sel?.toString().trim();
195
+ if (txt)
196
+ return `Cuéntame más sobre: "${txt}"`;
197
+ }
198
+ return `Cuéntame más sobre: ${label}`;
199
+ }, [getPrompt, data, label, merged.defaultInlinePrompt, merged.showOn]);
200
+ const handleActivate = React.useCallback(() => {
201
+ onActivate?.();
202
+ if (behavior === 'inline') {
203
+ if (!assistantId) {
204
+ const err = new Error('assistantId is required for behavior="inline"');
205
+ onError?.(err);
206
+ // eslint-disable-next-line no-console
207
+ console.warn('[AIElementWrapper]', err.message);
208
+ return;
209
+ }
210
+ setIsInlineOpen(true);
211
+ inline.reset();
212
+ inline.sendInlinePrompt(buildPrompt());
213
+ return;
214
+ }
215
+ // drawer behavior
216
+ if (!context) {
217
+ // eslint-disable-next-line no-console
218
+ console.warn('[AIElementWrapper] behavior="drawer" requires a DevicProvider ancestor.');
219
+ return;
220
+ }
221
+ // For 'select' showOn, prefer selected text as label content fallback
222
+ let finalLabel = label;
223
+ if (merged.showOn === 'select') {
224
+ const txt = window.getSelection()?.toString().trim();
225
+ if (txt)
226
+ finalLabel = txt;
227
+ }
228
+ context.addReference({ label: finalLabel, content: referenceContent, data });
229
+ context.openDrawer();
230
+ }, [
231
+ onActivate,
232
+ behavior,
233
+ assistantId,
234
+ onError,
235
+ inline,
236
+ buildPrompt,
237
+ context,
238
+ label,
239
+ referenceContent,
240
+ data,
241
+ merged.showOn,
242
+ ]);
243
+ const closeInline = React.useCallback(() => {
244
+ setIsInlineOpen(false);
245
+ inline.reset();
246
+ }, [inline]);
247
+ React.useImperativeHandle(ref, () => ({
248
+ activate: handleActivate,
249
+ close: closeInline,
250
+ }), [handleActivate, closeInline]);
251
+ // Click outside to close inline tooltip
252
+ React.useEffect(() => {
253
+ if (!isInlineOpen)
254
+ return;
255
+ const handler = (e) => {
256
+ const t = tooltipRef.current;
257
+ const c = containerRef.current;
258
+ const tr = triggerRef.current;
259
+ const target = e.target;
260
+ if (t && !t.contains(target) &&
261
+ c && !c.contains(target) &&
262
+ (!tr || !tr.contains(target))) {
263
+ closeInline();
264
+ }
265
+ };
266
+ document.addEventListener('mousedown', handler);
267
+ return () => document.removeEventListener('mousedown', handler);
268
+ }, [isInlineOpen, closeInline]);
269
+ // Anchor for trigger: selection rect (when showOn='select') else container rect
270
+ const triggerAnchor = merged.showOn === 'select' ? selectionRect : containerRect;
271
+ // Tooltip anchor: container rect (or selection if select mode)
272
+ const tooltipAnchor = merged.showOn === 'select' && selectionRect ? selectionRect : containerRect;
273
+ const triggerStyle = React.useMemo(() => {
274
+ if (!triggerAnchor)
275
+ return { display: 'none' };
276
+ return {
277
+ ...placementStyle(merged.triggerPlacement, triggerAnchor),
278
+ zIndex: merged.zIndex + 1,
279
+ pointerEvents: 'auto',
280
+ };
281
+ }, [triggerAnchor, merged.triggerPlacement, merged.zIndex]);
282
+ const tooltipStyle = React.useMemo(() => {
283
+ const w = typeof merged.tooltipWidth === 'number' ? `${merged.tooltipWidth}px` : merged.tooltipWidth;
284
+ if (!tooltipAnchor)
285
+ return { display: 'none' };
286
+ return {
287
+ ...placementStyle(merged.tooltipPlacement, tooltipAnchor),
288
+ width: w,
289
+ zIndex: merged.zIndex,
290
+ };
291
+ }, [tooltipAnchor, merged.tooltipPlacement, merged.tooltipWidth, merged.zIndex]);
292
+ const renderInlineContent = () => {
293
+ if (inline.error) {
294
+ return jsxRuntime.jsx("div", { className: "devic-aiwrap-error", children: inline.error.message });
295
+ }
296
+ if (inline.isProcessing) {
297
+ return (jsxRuntime.jsxs("div", { className: "devic-aiwrap-processing", children: [jsxRuntime.jsx("span", { className: "devic-aiwrap-spinner", "aria-hidden": "true" }), jsxRuntime.jsx("span", { children: "Pensando\u2026" })] }));
298
+ }
299
+ if (inline.response) {
300
+ if (inlineRenderer)
301
+ return inlineRenderer(inline.response);
302
+ const text = typeof inline.response.content === 'string'
303
+ ? inline.response.content
304
+ : inline.response.content?.message || '';
305
+ return jsxRuntime.jsx("div", { className: "devic-aiwrap-answer", children: text });
306
+ }
307
+ return null;
308
+ };
309
+ const triggerNode = trigger ?? (jsxRuntime.jsxs("button", { type: "button", className: "devic-aiwrap-trigger", style: {
310
+ borderRadius: typeof merged.triggerBorderRadius === 'number'
311
+ ? `${merged.triggerBorderRadius}px`
312
+ : merged.triggerBorderRadius,
313
+ ...(merged.color ? { ['--devic-aiwrap-color']: merged.color } : {}),
314
+ }, children: [jsxRuntime.jsx("span", { className: "devic-aiwrap-trigger-icon", "aria-hidden": "true", children: jsxRuntime.jsx(SparklesIcon, {}) }), jsxRuntime.jsx("span", { className: "devic-aiwrap-trigger-label", children: merged.triggerLabel })] }));
315
+ const portalTarget = typeof document !== 'undefined' ? document.body : null;
316
+ return (jsxRuntime.jsxs("span", { ref: containerRef, className: `devic-aiwrap-container ${className || ''}`, style: { position: 'relative', display: 'inline-block', ...style }, "data-highlight": merged.highlightOnInteract && (isHovered || isInlineOpen) ? 'true' : 'false', onMouseEnter: () => setHoveredImmediately(true), onMouseLeave: () => setHoveredImmediately(false), children: [jsxRuntime.jsx("span", { className: "devic-aiwrap-content", children: children }), portalTarget && triggerVisible &&
317
+ reactDom.createPortal(jsxRuntime.jsx("div", { ref: triggerRef, className: "devic-aiwrap-trigger-wrapper", style: triggerStyle, onMouseEnter: () => setHoveredImmediately(true), onMouseLeave: () => setHoveredImmediately(false), onMouseDown: (e) => {
318
+ // Prevent losing the text selection when interacting with trigger
319
+ e.preventDefault();
320
+ }, onClick: (e) => {
321
+ e.stopPropagation();
322
+ handleActivate();
323
+ }, children: triggerNode }), portalTarget), portalTarget && behavior === 'inline' && isInlineOpen &&
324
+ reactDom.createPortal(jsxRuntime.jsxs("div", { ref: tooltipRef, className: "devic-aiwrap-tooltip", style: tooltipStyle, "data-placement": merged.tooltipPlacement, children: [jsxRuntime.jsxs("div", { className: "devic-aiwrap-tooltip-header", children: [jsxRuntime.jsx("span", { className: "devic-aiwrap-tooltip-label", children: label }), jsxRuntime.jsx("button", { type: "button", className: "devic-aiwrap-tooltip-close", onClick: closeInline, "aria-label": "Cerrar", children: jsxRuntime.jsx(CloseIcon, {}) })] }), jsxRuntime.jsx("div", { className: "devic-aiwrap-tooltip-body", children: renderInlineContent() })] }), portalTarget)] }));
325
+ });
326
+ function SparklesIcon() {
327
+ return (jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("path", { d: "M10 2L11.5 8.5L18 10L11.5 11.5L10 18L8.5 11.5L2 10L8.5 8.5L10 2Z", opacity: "0.95" }), jsxRuntime.jsx("path", { d: "M16 3L16.5 5L18.5 5.5L16.5 6L16 8L15.5 6L13.5 5.5L15.5 5L16 3Z", opacity: "0.6" })] }));
328
+ }
329
+ function CloseIcon() {
330
+ return (jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }));
331
+ }
332
+
333
+ exports.AIElementWrapper = AIElementWrapper;
334
+ //# sourceMappingURL=AIElementWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIElementWrapper.js","sources":["../../../../../src/components/AIElementWrapper/AIElementWrapper.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useOptionalDevicContext } from '../../provider';\nimport { useAIElementWrapper } from './useAIElementWrapper';\nimport {\n getActiveWrapper,\n setActiveWrapper,\n subscribeActiveWrapper,\n} from './activeWrapperRegistry';\nimport { generateId } from '../../utils';\nimport type {\n AIElementWrapperHandle,\n AIElementWrapperOptions,\n AIElementWrapperPlacement,\n AIElementWrapperProps,\n} from './AIElementWrapper.types';\nimport './AIElementWrapper.css';\n\nconst DEFAULT_OPTIONS: Required<\n Omit<AIElementWrapperOptions, 'color' | 'drawerPromptPrefix' | 'defaultInlinePrompt'>\n> & {\n color?: string;\n drawerPromptPrefix?: AIElementWrapperOptions['drawerPromptPrefix'];\n defaultInlinePrompt?: string;\n} = {\n showOn: 'hover',\n triggerPlacement: 'bottom',\n tooltipPlacement: 'bottom',\n tooltipWidth: 360,\n triggerLabel: 'Preguntar a IA',\n highlightOnInteract: true,\n zIndex: 2147483000,\n triggerBorderRadius: 999,\n color: undefined,\n drawerPromptPrefix: undefined,\n defaultInlinePrompt: undefined,\n};\n\ninterface AnchorRect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\nfunction rectFromDom(rect: DOMRect): AnchorRect {\n return { top: rect.top, left: rect.left, width: rect.width, height: rect.height };\n}\n\nfunction placementStyle(\n placement: AIElementWrapperPlacement,\n anchor: AnchorRect,\n offset = 8\n): React.CSSProperties {\n const cx = anchor.left + anchor.width / 2;\n const cy = anchor.top + anchor.height / 2;\n switch (placement) {\n case 'top':\n return { position: 'fixed', top: anchor.top - offset, left: cx, transform: 'translate(-50%, -100%)' };\n case 'bottom':\n return { position: 'fixed', top: anchor.top + anchor.height + offset, left: cx, transform: 'translateX(-50%)' };\n case 'left':\n return { position: 'fixed', top: cy, left: anchor.left - offset, transform: 'translate(-100%, -50%)' };\n case 'right':\n return { position: 'fixed', top: cy, left: anchor.left + anchor.width + offset, transform: 'translateY(-50%)' };\n }\n}\n\n/**\n * AIElementWrapper wraps an arbitrary React node and exposes an AI trigger\n * that can either show an inline floating tooltip with the assistant's\n * answer (`behavior='inline'`) or push a reference to the registered\n * ChatDrawer (`behavior='drawer'`).\n *\n * The trigger and inline tooltip are rendered through a React portal anchored\n * to the wrapped element, so they always sit above other UI (including the\n * ChatDrawer) regardless of stacking context.\n */\nexport const AIElementWrapper = forwardRef<AIElementWrapperHandle, AIElementWrapperProps>(\n function AIElementWrapper(props, ref) {\n const {\n label,\n data,\n referenceContent,\n behavior = 'inline',\n trigger,\n options = {},\n assistantId,\n getPrompt,\n apiKey,\n baseUrl,\n tenantId,\n tenantMetadata,\n modelInterfaceTools,\n inlineRenderer,\n onActivate,\n onInlineResponse,\n onError,\n className,\n style,\n children,\n } = props;\n\n const merged = useMemo(() => ({ ...DEFAULT_OPTIONS, ...options }), [options]);\n\n // Stable instance ID used by the active-wrapper registry (singleton)\n const wrapperIdRef = useRef<string>('');\n if (!wrapperIdRef.current) wrapperIdRef.current = generateId();\n\n const [activeWrapperId, setActiveWrapperLocal] = useState<string | null>(getActiveWrapper());\n useEffect(() => subscribeActiveWrapper(setActiveWrapperLocal), []);\n\n const context = useOptionalDevicContext();\n const containerRef = useRef<HTMLSpanElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLDivElement>(null);\n\n const [isHovered, setIsHovered] = useState(false);\n const hoverTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const setHoveredImmediately = useCallback((v: boolean) => {\n if (hoverTimerRef.current) {\n clearTimeout(hoverTimerRef.current);\n hoverTimerRef.current = null;\n }\n if (v) {\n setIsHovered(true);\n } else {\n // Grace period so the cursor can travel from the wrapper to the\n // portal-rendered trigger without the trigger disappearing mid-flight.\n hoverTimerRef.current = setTimeout(() => setIsHovered(false), 200);\n }\n }, []);\n useEffect(() => () => {\n if (hoverTimerRef.current) clearTimeout(hoverTimerRef.current);\n }, []);\n const [isInlineOpen, setIsInlineOpen] = useState(false);\n const [containerRect, setContainerRect] = useState<AnchorRect | null>(null);\n const [selectionRect, setSelectionRect] = useState<AnchorRect | null>(null);\n\n const inline = useAIElementWrapper({\n assistantId,\n apiKey,\n baseUrl,\n tenantId,\n tenantMetadata,\n modelInterfaceTools,\n onResponse: onInlineResponse,\n onError,\n });\n\n // What this wrapper would show if there were no coordination.\n const wantsTriggerVisible =\n merged.showOn === 'always' ||\n (merged.showOn === 'hover' && isHovered) ||\n (merged.showOn === 'click' && isInlineOpen) ||\n (merged.showOn === 'select' && selectionRect !== null);\n\n // Coordinate via the singleton registry so only one wrapper shows the\n // floating trigger at a time. The most recent wrapper to want visibility\n // wins; others hide until they are activated again.\n const isActive = activeWrapperId === wrapperIdRef.current;\n const triggerVisible = wantsTriggerVisible && (activeWrapperId === null || isActive);\n\n useEffect(() => {\n const id = wrapperIdRef.current;\n if (wantsTriggerVisible) {\n setActiveWrapper(id);\n } else if (getActiveWrapper() === id) {\n setActiveWrapper(null);\n }\n }, [wantsTriggerVisible]);\n\n // Release the registry slot if the component unmounts while active.\n useEffect(\n () => () => {\n if (getActiveWrapper() === wrapperIdRef.current) {\n setActiveWrapper(null);\n }\n },\n []\n );\n\n // Track container rect (for hover/click/always trigger and tooltip anchor)\n const updateContainerRect = useCallback(() => {\n const el = containerRef.current;\n if (!el) return;\n setContainerRect(rectFromDom(el.getBoundingClientRect()));\n }, []);\n\n useLayoutEffect(() => {\n if (!triggerVisible && !isInlineOpen) return;\n updateContainerRect();\n const onScrollOrResize = () => updateContainerRect();\n window.addEventListener('scroll', onScrollOrResize, true);\n window.addEventListener('resize', onScrollOrResize);\n return () => {\n window.removeEventListener('scroll', onScrollOrResize, true);\n window.removeEventListener('resize', onScrollOrResize);\n };\n }, [triggerVisible, isInlineOpen, updateContainerRect]);\n\n // selectionchange listener for showOn='select'\n useEffect(() => {\n if (merged.showOn !== 'select') {\n setSelectionRect(null);\n return;\n }\n const isInside = (node: Node | null, cont: HTMLElement) => {\n if (!node) return false;\n if (node === cont) return true;\n return cont.contains(node);\n };\n const recompute = () => {\n const sel = window.getSelection();\n const cont = containerRef.current;\n if (!sel || sel.isCollapsed || !cont || sel.rangeCount === 0) {\n setSelectionRect(null);\n return;\n }\n // Don't react to selections happening elsewhere — but tolerate the\n // case where anchor or focus are inside our container.\n if (!isInside(sel.anchorNode, cont) && !isInside(sel.focusNode, cont)) {\n setSelectionRect(null);\n return;\n }\n const range = sel.getRangeAt(0);\n const rect = range.getBoundingClientRect();\n if (rect.width === 0 && rect.height === 0) {\n setSelectionRect(null);\n return;\n }\n setSelectionRect(rectFromDom(rect));\n };\n const onMouseUp = () => {\n // Run on next tick so the browser commits the final selection state.\n setTimeout(recompute, 0);\n };\n document.addEventListener('selectionchange', recompute);\n document.addEventListener('mouseup', onMouseUp);\n return () => {\n document.removeEventListener('selectionchange', recompute);\n document.removeEventListener('mouseup', onMouseUp);\n };\n }, [merged.showOn]);\n\n const buildPrompt = useCallback((): string => {\n if (getPrompt) return getPrompt({ data, label });\n if (merged.defaultInlinePrompt) return merged.defaultInlinePrompt;\n // Use selected text if available, otherwise fall back to label\n if (merged.showOn === 'select') {\n const sel = window.getSelection();\n const txt = sel?.toString().trim();\n if (txt) return `Cuéntame más sobre: \"${txt}\"`;\n }\n return `Cuéntame más sobre: ${label}`;\n }, [getPrompt, data, label, merged.defaultInlinePrompt, merged.showOn]);\n\n const handleActivate = useCallback(() => {\n onActivate?.();\n\n if (behavior === 'inline') {\n if (!assistantId) {\n const err = new Error('assistantId is required for behavior=\"inline\"');\n onError?.(err);\n // eslint-disable-next-line no-console\n console.warn('[AIElementWrapper]', err.message);\n return;\n }\n setIsInlineOpen(true);\n inline.reset();\n inline.sendInlinePrompt(buildPrompt());\n return;\n }\n\n // drawer behavior\n if (!context) {\n // eslint-disable-next-line no-console\n console.warn(\n '[AIElementWrapper] behavior=\"drawer\" requires a DevicProvider ancestor.'\n );\n return;\n }\n // For 'select' showOn, prefer selected text as label content fallback\n let finalLabel = label;\n if (merged.showOn === 'select') {\n const txt = window.getSelection()?.toString().trim();\n if (txt) finalLabel = txt;\n }\n context.addReference({ label: finalLabel, content: referenceContent, data });\n context.openDrawer();\n }, [\n onActivate,\n behavior,\n assistantId,\n onError,\n inline,\n buildPrompt,\n context,\n label,\n referenceContent,\n data,\n merged.showOn,\n ]);\n\n const closeInline = useCallback(() => {\n setIsInlineOpen(false);\n inline.reset();\n }, [inline]);\n\n useImperativeHandle(\n ref,\n () => ({\n activate: handleActivate,\n close: closeInline,\n }),\n [handleActivate, closeInline]\n );\n\n // Click outside to close inline tooltip\n useEffect(() => {\n if (!isInlineOpen) return;\n const handler = (e: MouseEvent) => {\n const t = tooltipRef.current;\n const c = containerRef.current;\n const tr = triggerRef.current;\n const target = e.target as Node;\n if (\n t && !t.contains(target) &&\n c && !c.contains(target) &&\n (!tr || !tr.contains(target))\n ) {\n closeInline();\n }\n };\n document.addEventListener('mousedown', handler);\n return () => document.removeEventListener('mousedown', handler);\n }, [isInlineOpen, closeInline]);\n\n // Anchor for trigger: selection rect (when showOn='select') else container rect\n const triggerAnchor = merged.showOn === 'select' ? selectionRect : containerRect;\n // Tooltip anchor: container rect (or selection if select mode)\n const tooltipAnchor = merged.showOn === 'select' && selectionRect ? selectionRect : containerRect;\n\n const triggerStyle = useMemo<React.CSSProperties>(() => {\n if (!triggerAnchor) return { display: 'none' };\n return {\n ...placementStyle(merged.triggerPlacement, triggerAnchor),\n zIndex: merged.zIndex + 1,\n pointerEvents: 'auto',\n };\n }, [triggerAnchor, merged.triggerPlacement, merged.zIndex]);\n\n const tooltipStyle = useMemo<React.CSSProperties>(() => {\n const w = typeof merged.tooltipWidth === 'number' ? `${merged.tooltipWidth}px` : merged.tooltipWidth;\n if (!tooltipAnchor) return { display: 'none' };\n return {\n ...placementStyle(merged.tooltipPlacement, tooltipAnchor),\n width: w,\n zIndex: merged.zIndex,\n };\n }, [tooltipAnchor, merged.tooltipPlacement, merged.tooltipWidth, merged.zIndex]);\n\n const renderInlineContent = () => {\n if (inline.error) {\n return <div className=\"devic-aiwrap-error\">{inline.error.message}</div>;\n }\n if (inline.isProcessing) {\n return (\n <div className=\"devic-aiwrap-processing\">\n <span className=\"devic-aiwrap-spinner\" aria-hidden=\"true\" />\n <span>Pensando…</span>\n </div>\n );\n }\n if (inline.response) {\n if (inlineRenderer) return inlineRenderer(inline.response);\n const text =\n typeof inline.response.content === 'string'\n ? inline.response.content\n : (inline.response.content as any)?.message || '';\n return <div className=\"devic-aiwrap-answer\">{text}</div>;\n }\n return null;\n };\n\n const triggerNode = trigger ?? (\n <button\n type=\"button\"\n className=\"devic-aiwrap-trigger\"\n style={{\n borderRadius:\n typeof merged.triggerBorderRadius === 'number'\n ? `${merged.triggerBorderRadius}px`\n : merged.triggerBorderRadius,\n ...(merged.color ? { ['--devic-aiwrap-color' as any]: merged.color } : {}),\n }}\n >\n <span className=\"devic-aiwrap-trigger-icon\" aria-hidden=\"true\">\n <SparklesIcon />\n </span>\n <span className=\"devic-aiwrap-trigger-label\">{merged.triggerLabel}</span>\n </button>\n );\n\n const portalTarget = typeof document !== 'undefined' ? document.body : null;\n\n return (\n <span\n ref={containerRef}\n className={`devic-aiwrap-container ${className || ''}`}\n style={{ position: 'relative', display: 'inline-block', ...style }}\n data-highlight={merged.highlightOnInteract && (isHovered || isInlineOpen) ? 'true' : 'false'}\n onMouseEnter={() => setHoveredImmediately(true)}\n onMouseLeave={() => setHoveredImmediately(false)}\n >\n <span className=\"devic-aiwrap-content\">{children}</span>\n\n {portalTarget && triggerVisible &&\n createPortal(\n <div\n ref={triggerRef}\n className=\"devic-aiwrap-trigger-wrapper\"\n style={triggerStyle}\n onMouseEnter={() => setHoveredImmediately(true)}\n onMouseLeave={() => setHoveredImmediately(false)}\n onMouseDown={(e) => {\n // Prevent losing the text selection when interacting with trigger\n e.preventDefault();\n }}\n onClick={(e) => {\n e.stopPropagation();\n handleActivate();\n }}\n >\n {triggerNode}\n </div>,\n portalTarget\n )}\n\n {portalTarget && behavior === 'inline' && isInlineOpen &&\n createPortal(\n <div\n ref={tooltipRef}\n className=\"devic-aiwrap-tooltip\"\n style={tooltipStyle}\n data-placement={merged.tooltipPlacement}\n >\n <div className=\"devic-aiwrap-tooltip-header\">\n <span className=\"devic-aiwrap-tooltip-label\">{label}</span>\n <button\n type=\"button\"\n className=\"devic-aiwrap-tooltip-close\"\n onClick={closeInline}\n aria-label=\"Cerrar\"\n >\n <CloseIcon />\n </button>\n </div>\n <div className=\"devic-aiwrap-tooltip-body\">{renderInlineContent()}</div>\n </div>,\n portalTarget\n )}\n </span>\n );\n }\n);\n\nfunction SparklesIcon(): JSX.Element {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 20 20\" fill=\"currentColor\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10 2L11.5 8.5L18 10L11.5 11.5L10 18L8.5 11.5L2 10L8.5 8.5L10 2Z\" opacity=\"0.95\" />\n <path d=\"M16 3L16.5 5L18.5 5.5L16.5 6L16 8L15.5 6L13.5 5.5L15.5 5L16 3Z\" opacity=\"0.6\" />\n </svg>\n );\n}\n\nfunction CloseIcon(): JSX.Element {\n return (\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n"],"names":["forwardRef","useMemo","useRef","generateId","useState","getActiveWrapper","useEffect","subscribeActiveWrapper","useOptionalDevicContext","useCallback","useAIElementWrapper","setActiveWrapper","useLayoutEffect","useImperativeHandle","_jsx","_jsxs","createPortal"],"mappings":";;;;;;;;;;AA2BA,MAAM,eAAe,GAMjB;AACF,IAAA,MAAM,EAAE,OAAO;AACf,IAAA,gBAAgB,EAAE,QAAQ;AAC1B,IAAA,gBAAgB,EAAE,QAAQ;AAC1B,IAAA,YAAY,EAAE,GAAG;AACjB,IAAA,YAAY,EAAE,gBAAgB;AAC9B,IAAA,mBAAmB,EAAE,IAAI;AACzB,IAAA,MAAM,EAAE,UAAU;AAClB,IAAA,mBAAmB,EAAE,GAAG;AACxB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,kBAAkB,EAAE,SAAS;AAC7B,IAAA,mBAAmB,EAAE,SAAS;CAC/B;AASD,SAAS,WAAW,CAAC,IAAa,EAAA;IAChC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;AACnF;AAEA,SAAS,cAAc,CACrB,SAAoC,EACpC,MAAkB,EAClB,MAAM,GAAG,CAAC,EAAA;IAEV,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC;IACzC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;IACzC,QAAQ,SAAS;AACf,QAAA,KAAK,KAAK;YACR,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE;AACvG,QAAA,KAAK,QAAQ;YACX,OAA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AA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,kEAAkE,EAAC,OAAO,EAAC,MAAM,GAAG,EAC5FA,cAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,gEAAgE,EAAC,OAAO,EAAC,KAAK,EAAA,CAAG,CAAA,EAAA,CACrF;AAEV;AAEA,SAAS,SAAS,GAAA;AAChB,IAAA,QACEC,eAAA,CAAA,KAAA,EAAA,EAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAA,QAAA,EAAA,CAC5ID,cAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACtCA,cAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAAA,CAClC;AAEV;;;;"}
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Module-level singleton that coordinates which AIElementWrapper instance
5
+ * currently owns the floating trigger. Ensures only one wrapper shows its
6
+ * trigger at any given time across the page.
7
+ */
8
+ let activeId = null;
9
+ const listeners = new Set();
10
+ function getActiveWrapper() {
11
+ return activeId;
12
+ }
13
+ function setActiveWrapper(id) {
14
+ if (activeId === id)
15
+ return;
16
+ activeId = id;
17
+ for (const l of listeners)
18
+ l(activeId);
19
+ }
20
+ function subscribeActiveWrapper(listener) {
21
+ listeners.add(listener);
22
+ return () => {
23
+ listeners.delete(listener);
24
+ };
25
+ }
26
+
27
+ exports.getActiveWrapper = getActiveWrapper;
28
+ exports.setActiveWrapper = setActiveWrapper;
29
+ exports.subscribeActiveWrapper = subscribeActiveWrapper;
30
+ //# sourceMappingURL=activeWrapperRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activeWrapperRegistry.js","sources":["../../../../../src/components/AIElementWrapper/activeWrapperRegistry.ts"],"sourcesContent":["/**\n * Module-level singleton that coordinates which AIElementWrapper instance\n * currently owns the floating trigger. Ensures only one wrapper shows its\n * trigger at any given time across the page.\n */\n\ntype Listener = (activeId: string | null) => void;\n\nlet activeId: string | null = null;\nconst listeners = new Set<Listener>();\n\nexport function getActiveWrapper(): string | null {\n return activeId;\n}\n\nexport function setActiveWrapper(id: string | null): void {\n if (activeId === id) return;\n activeId = id;\n for (const l of listeners) l(activeId);\n}\n\nexport function subscribeActiveWrapper(listener: Listener): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AAIH,IAAI,QAAQ,GAAkB,IAAI;AAClC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAY;SAErB,gBAAgB,GAAA;AAC9B,IAAA,OAAO,QAAQ;AACjB;AAEM,SAAU,gBAAgB,CAAC,EAAiB,EAAA;IAChD,IAAI,QAAQ,KAAK,EAAE;QAAE;IACrB,QAAQ,GAAG,EAAE;IACb,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,CAAC,CAAC,QAAQ,CAAC;AACxC;AAEM,SAAU,sBAAsB,CAAC,QAAkB,EAAA;AACvD,IAAA,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC;AACvB,IAAA,OAAO,MAAK;AACV,QAAA,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC;AAC5B,IAAA,CAAC;AACH;;;;;;"}
@@ -0,0 +1,161 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ require('react/jsx-runtime');
5
+ var DevicContext = require('../../provider/DevicContext.js');
6
+ var client = require('../../api/client.js');
7
+ var usePolling = require('../../hooks/usePolling.js');
8
+ var useModelInterface = require('../../hooks/useModelInterface.js');
9
+
10
+ /**
11
+ * Hook that manages the inline AI generation flow for AIElementWrapper.
12
+ * Reuses sendMessageAsync + polling, similar to useAIGenerationButton but
13
+ * without the modal/tooltip UI orchestration.
14
+ */
15
+ function useAIElementWrapper(options) {
16
+ const { assistantId, apiKey: propsApiKey, baseUrl: propsBaseUrl, tenantId, tenantMetadata, modelInterfaceTools = [], onResponse, onError, } = options;
17
+ const context = DevicContext.useOptionalDevicContext();
18
+ const apiKey = propsApiKey || context?.apiKey;
19
+ const baseUrl = propsBaseUrl || context?.baseUrl || 'https://api.devic.ai';
20
+ const resolvedTenantId = tenantId || context?.tenantId;
21
+ const resolvedTenantMetadata = { ...context?.tenantMetadata, ...tenantMetadata };
22
+ const [isProcessing, setIsProcessing] = React.useState(false);
23
+ const [response, setResponse] = React.useState(null);
24
+ const [error, setError] = React.useState(null);
25
+ const [chatUid, setChatUid] = React.useState(null);
26
+ const [shouldPoll, setShouldPoll] = React.useState(false);
27
+ const onResponseRef = React.useRef(onResponse);
28
+ const onErrorRef = React.useRef(onError);
29
+ React.useEffect(() => {
30
+ onResponseRef.current = onResponse;
31
+ onErrorRef.current = onError;
32
+ });
33
+ const clientRef = React.useRef(null);
34
+ if (!clientRef.current && apiKey) {
35
+ clientRef.current = new client.DevicApiClient({ apiKey, baseUrl });
36
+ }
37
+ React.useEffect(() => {
38
+ if (clientRef.current && apiKey) {
39
+ clientRef.current.setConfig({ apiKey, baseUrl });
40
+ }
41
+ }, [apiKey, baseUrl]);
42
+ const { toolSchemas, handleToolCalls: executeToolCalls, extractPendingToolCalls, } = useModelInterface.useModelInterface({ tools: modelInterfaceTools });
43
+ const handlePendingToolCalls = React.useCallback(async (data) => {
44
+ if (!clientRef.current || !chatUid || !assistantId)
45
+ return;
46
+ const pendingCalls = data.pendingToolCalls || extractPendingToolCalls(data.chatHistory);
47
+ if (pendingCalls.length === 0)
48
+ return;
49
+ try {
50
+ const { responses } = await executeToolCalls(pendingCalls);
51
+ if (responses.length > 0) {
52
+ await clientRef.current.sendToolResponses(assistantId, chatUid, responses);
53
+ setShouldPoll(true);
54
+ }
55
+ }
56
+ catch (err) {
57
+ const error = err instanceof Error ? err : new Error(String(err));
58
+ setError(error);
59
+ onErrorRef.current?.(error);
60
+ }
61
+ }, [chatUid, assistantId, executeToolCalls, extractPendingToolCalls]);
62
+ usePolling.usePolling(shouldPoll ? chatUid : null, async () => {
63
+ if (!clientRef.current || !chatUid || !assistantId) {
64
+ throw new Error('Cannot poll without client, chatUid or assistantId');
65
+ }
66
+ return clientRef.current.getRealtimeHistory(assistantId, chatUid);
67
+ }, {
68
+ interval: 1000,
69
+ enabled: shouldPoll,
70
+ stopStatuses: ['completed', 'error', 'waiting_for_tool_response'],
71
+ onUpdate: async (data) => {
72
+ if (data.status === 'waiting_for_tool_response' || data.pendingToolCalls?.length) {
73
+ await handlePendingToolCalls(data);
74
+ }
75
+ },
76
+ onStop: (data) => {
77
+ setShouldPoll(false);
78
+ if (data?.status === 'error') {
79
+ setIsProcessing(false);
80
+ const err = new Error('Processing failed');
81
+ setError(err);
82
+ onErrorRef.current?.(err);
83
+ return;
84
+ }
85
+ if (data?.status === 'completed') {
86
+ setIsProcessing(false);
87
+ const assistantMessages = data.chatHistory.filter((m) => m.role === 'assistant');
88
+ const last = assistantMessages[assistantMessages.length - 1];
89
+ if (last) {
90
+ setResponse(last);
91
+ onResponseRef.current?.(last);
92
+ }
93
+ }
94
+ },
95
+ onError: (err) => {
96
+ setError(err);
97
+ setIsProcessing(false);
98
+ setShouldPoll(false);
99
+ onErrorRef.current?.(err);
100
+ },
101
+ });
102
+ const sendInlinePrompt = React.useCallback(async (prompt) => {
103
+ if (!assistantId) {
104
+ const err = new Error('assistantId is required for inline behavior');
105
+ setError(err);
106
+ onErrorRef.current?.(err);
107
+ return;
108
+ }
109
+ if (!clientRef.current) {
110
+ const err = new Error('API client not configured. Please provide an API key.');
111
+ setError(err);
112
+ onErrorRef.current?.(err);
113
+ return;
114
+ }
115
+ const trimmed = prompt.trim();
116
+ if (!trimmed) {
117
+ const err = new Error('Prompt is empty');
118
+ setError(err);
119
+ onErrorRef.current?.(err);
120
+ return;
121
+ }
122
+ setIsProcessing(true);
123
+ setError(null);
124
+ setResponse(null);
125
+ try {
126
+ const dto = {
127
+ message: trimmed,
128
+ metadata: resolvedTenantMetadata,
129
+ tenantId: resolvedTenantId,
130
+ ...(toolSchemas.length > 0 && { tools: toolSchemas }),
131
+ };
132
+ const resp = await clientRef.current.sendMessageAsync(assistantId, dto);
133
+ if (resp.chatUid)
134
+ setChatUid(resp.chatUid);
135
+ setShouldPoll(true);
136
+ }
137
+ catch (err) {
138
+ const error = err instanceof Error ? err : new Error(String(err));
139
+ setError(error);
140
+ setIsProcessing(false);
141
+ onErrorRef.current?.(error);
142
+ }
143
+ }, [assistantId, resolvedTenantId, resolvedTenantMetadata, toolSchemas]);
144
+ const reset = React.useCallback(() => {
145
+ setIsProcessing(false);
146
+ setResponse(null);
147
+ setError(null);
148
+ setChatUid(null);
149
+ setShouldPoll(false);
150
+ }, []);
151
+ return {
152
+ isProcessing,
153
+ response,
154
+ error,
155
+ sendInlinePrompt,
156
+ reset,
157
+ };
158
+ }
159
+
160
+ exports.useAIElementWrapper = useAIElementWrapper;
161
+ //# sourceMappingURL=useAIElementWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAIElementWrapper.js","sources":["../../../../../src/components/AIElementWrapper/useAIElementWrapper.ts"],"sourcesContent":["import { useState, useCallback, useRef, useEffect } from 'react';\nimport { useOptionalDevicContext } from '../../provider';\nimport { DevicApiClient } from '../../api/client';\nimport { usePolling } from '../../hooks/usePolling';\nimport { useModelInterface } from '../../hooks/useModelInterface';\nimport type {\n ChatMessage,\n ModelInterfaceTool,\n RealtimeChatHistory,\n} from '../../api/types';\n\nexport interface UseAIElementWrapperOptions {\n assistantId?: string;\n apiKey?: string;\n baseUrl?: string;\n tenantId?: string;\n tenantMetadata?: Record<string, any>;\n modelInterfaceTools?: ModelInterfaceTool[];\n onResponse?: (message: ChatMessage) => void;\n onError?: (error: Error) => void;\n}\n\nexport interface UseAIElementWrapperResult {\n isProcessing: boolean;\n response: ChatMessage | null;\n error: Error | null;\n /** Send a prompt to the inline assistant. */\n sendInlinePrompt: (prompt: string) => Promise<void>;\n /** Reset response/error state. */\n reset: () => void;\n}\n\n/**\n * Hook that manages the inline AI generation flow for AIElementWrapper.\n * Reuses sendMessageAsync + polling, similar to useAIGenerationButton but\n * without the modal/tooltip UI orchestration.\n */\nexport function useAIElementWrapper(\n options: UseAIElementWrapperOptions\n): UseAIElementWrapperResult {\n const {\n assistantId,\n apiKey: propsApiKey,\n baseUrl: propsBaseUrl,\n tenantId,\n tenantMetadata,\n modelInterfaceTools = [],\n onResponse,\n onError,\n } = options;\n\n const context = useOptionalDevicContext();\n const apiKey = propsApiKey || context?.apiKey;\n const baseUrl = propsBaseUrl || context?.baseUrl || 'https://api.devic.ai';\n const resolvedTenantId = tenantId || context?.tenantId;\n const resolvedTenantMetadata = { ...context?.tenantMetadata, ...tenantMetadata };\n\n const [isProcessing, setIsProcessing] = useState(false);\n const [response, setResponse] = useState<ChatMessage | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [chatUid, setChatUid] = useState<string | null>(null);\n const [shouldPoll, setShouldPoll] = useState(false);\n\n const onResponseRef = useRef(onResponse);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onResponseRef.current = onResponse;\n onErrorRef.current = onError;\n });\n\n const clientRef = useRef<DevicApiClient | null>(null);\n if (!clientRef.current && apiKey) {\n clientRef.current = new DevicApiClient({ apiKey, baseUrl });\n }\n useEffect(() => {\n if (clientRef.current && apiKey) {\n clientRef.current.setConfig({ apiKey, baseUrl });\n }\n }, [apiKey, baseUrl]);\n\n const {\n toolSchemas,\n handleToolCalls: executeToolCalls,\n extractPendingToolCalls,\n } = useModelInterface({ tools: modelInterfaceTools });\n\n const handlePendingToolCalls = useCallback(\n async (data: RealtimeChatHistory) => {\n if (!clientRef.current || !chatUid || !assistantId) return;\n const pendingCalls =\n data.pendingToolCalls || extractPendingToolCalls(data.chatHistory);\n if (pendingCalls.length === 0) return;\n try {\n const { responses } = await executeToolCalls(pendingCalls);\n if (responses.length > 0) {\n await clientRef.current.sendToolResponses(assistantId, chatUid, responses);\n setShouldPoll(true);\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onErrorRef.current?.(error);\n }\n },\n [chatUid, assistantId, executeToolCalls, extractPendingToolCalls]\n );\n\n usePolling(\n shouldPoll ? chatUid : null,\n async () => {\n if (!clientRef.current || !chatUid || !assistantId) {\n throw new Error('Cannot poll without client, chatUid or assistantId');\n }\n return clientRef.current.getRealtimeHistory(assistantId, chatUid);\n },\n {\n interval: 1000,\n enabled: shouldPoll,\n stopStatuses: ['completed', 'error', 'waiting_for_tool_response'],\n onUpdate: async (data: RealtimeChatHistory) => {\n if (data.status === 'waiting_for_tool_response' || data.pendingToolCalls?.length) {\n await handlePendingToolCalls(data);\n }\n },\n onStop: (data) => {\n setShouldPoll(false);\n if (data?.status === 'error') {\n setIsProcessing(false);\n const err = new Error('Processing failed');\n setError(err);\n onErrorRef.current?.(err);\n return;\n }\n if (data?.status === 'completed') {\n setIsProcessing(false);\n const assistantMessages = data.chatHistory.filter(\n (m: ChatMessage) => m.role === 'assistant'\n );\n const last = assistantMessages[assistantMessages.length - 1];\n if (last) {\n setResponse(last);\n onResponseRef.current?.(last);\n }\n }\n },\n onError: (err) => {\n setError(err);\n setIsProcessing(false);\n setShouldPoll(false);\n onErrorRef.current?.(err);\n },\n }\n );\n\n const sendInlinePrompt = useCallback(\n async (prompt: string) => {\n if (!assistantId) {\n const err = new Error('assistantId is required for inline behavior');\n setError(err);\n onErrorRef.current?.(err);\n return;\n }\n if (!clientRef.current) {\n const err = new Error('API client not configured. Please provide an API key.');\n setError(err);\n onErrorRef.current?.(err);\n return;\n }\n const trimmed = prompt.trim();\n if (!trimmed) {\n const err = new Error('Prompt is empty');\n setError(err);\n onErrorRef.current?.(err);\n return;\n }\n\n setIsProcessing(true);\n setError(null);\n setResponse(null);\n\n try {\n const dto = {\n message: trimmed,\n metadata: resolvedTenantMetadata,\n tenantId: resolvedTenantId,\n ...(toolSchemas.length > 0 && { tools: toolSchemas }),\n };\n const resp = await clientRef.current.sendMessageAsync(assistantId, dto);\n if (resp.chatUid) setChatUid(resp.chatUid);\n setShouldPoll(true);\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n setIsProcessing(false);\n onErrorRef.current?.(error);\n }\n },\n [assistantId, resolvedTenantId, resolvedTenantMetadata, toolSchemas]\n );\n\n const reset = useCallback(() => {\n setIsProcessing(false);\n setResponse(null);\n setError(null);\n setChatUid(null);\n setShouldPoll(false);\n }, []);\n\n return {\n isProcessing,\n response,\n error,\n sendInlinePrompt,\n reset,\n };\n}\n"],"names":["useOptionalDevicContext","useState","useRef","useEffect","DevicApiClient","useModelInterface","useCallback","usePolling"],"mappings":";;;;;;;;;AAgCA;;;;AAIG;AACG,SAAU,mBAAmB,CACjC,OAAmC,EAAA;IAEnC,MAAM,EACJ,WAAW,EACX,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,YAAY,EACrB,QAAQ,EACR,cAAc,EACd,mBAAmB,GAAG,EAAE,EACxB,UAAU,EACV,OAAO,GACR,GAAG,OAAO;AAEX,IAAA,MAAM,OAAO,GAAGA,oCAAuB,EAAE;AACzC,IAAA,MAAM,MAAM,GAAG,WAAW,IAAI,OAAO,EAAE,MAAM;IAC7C,MAAM,OAAO,GAAG,YAAY,IAAI,OAAO,EAAE,OAAO,IAAI,sBAAsB;AAC1E,IAAA,MAAM,gBAAgB,GAAG,QAAQ,IAAI,OAAO,EAAE,QAAQ;IACtD,MAAM,sBAAsB,GAAG,EAAE,GAAG,OAAO,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAEhF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGC,cAA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