@apia/ai 5.0.1 → 5.0.6

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 (60) hide show
  1. package/dist/chat/ChatController/CameraController.js.map +1 -1
  2. package/dist/chat/ChatController/ChatController.d.ts +64 -4
  3. package/dist/chat/ChatController/ChatController.js +292 -16
  4. package/dist/chat/ChatController/ChatController.js.map +1 -1
  5. package/dist/chat/ChatController/TChatFeedbackForm.d.ts +7 -0
  6. package/dist/chat/ChatController/TChatFeedbackForm.d.ts.map +1 -0
  7. package/dist/chat/ChatController/components/AssistantTurnMessage.d.ts +83 -0
  8. package/dist/chat/ChatController/components/AssistantTurnMessage.d.ts.map +1 -0
  9. package/dist/chat/ChatController/components/AssistantTurnMessage.js +516 -0
  10. package/dist/chat/ChatController/components/AssistantTurnMessage.js.map +1 -0
  11. package/dist/chat/ChatController/components/Attachments.js.map +1 -1
  12. package/dist/chat/ChatController/components/Ellipsis.js.map +1 -1
  13. package/dist/chat/ChatController/components/FileAttachment.js +247 -54
  14. package/dist/chat/ChatController/components/FileAttachment.js.map +1 -1
  15. package/dist/chat/ChatController/components/Header.js.map +1 -1
  16. package/dist/chat/ChatController/components/History.d.ts +2 -1
  17. package/dist/chat/ChatController/components/History.js +35 -24
  18. package/dist/chat/ChatController/components/History.js.map +1 -1
  19. package/dist/chat/ChatController/components/MessageBlock.js.map +1 -1
  20. package/dist/chat/ChatController/components/PendingMessagesPanel.d.ts +17 -0
  21. package/dist/chat/ChatController/components/PendingMessagesPanel.d.ts.map +1 -0
  22. package/dist/chat/ChatController/components/PendingMessagesPanel.js +255 -0
  23. package/dist/chat/ChatController/components/PendingMessagesPanel.js.map +1 -0
  24. package/dist/chat/ChatController/components/TextArea/QuestionComposer.js +123 -0
  25. package/dist/chat/ChatController/components/TextArea/QuestionComposer.js.map +1 -0
  26. package/dist/chat/ChatController/components/TextArea.d.ts +17 -2
  27. package/dist/chat/ChatController/components/TextArea.js +268 -251
  28. package/dist/chat/ChatController/components/TextArea.js.map +1 -1
  29. package/dist/chat/ChatController/components/rate.js.map +1 -1
  30. package/dist/chat/ChatController/openFloatingChatController.d.ts +13 -0
  31. package/dist/chat/ChatController/openFloatingChatController.d.ts.map +1 -0
  32. package/dist/chat/ChatController/openFloatingChatController.js +24 -0
  33. package/dist/chat/ChatController/openFloatingChatController.js.map +1 -0
  34. package/dist/chat/ChatController/types.d.ts +56 -1
  35. package/dist/chat/ChatController/util.js.map +1 -1
  36. package/dist/chat/FloatingChatController.d.ts +15 -0
  37. package/dist/chat/FloatingChatController.js +15 -12
  38. package/dist/chat/FloatingChatController.js.map +1 -1
  39. package/dist/components/chat/messages/MultipleChoiceMessage.js.map +1 -1
  40. package/dist/components/documents/UploadModal/ImageIcon.js.map +1 -1
  41. package/dist/components/documents/UploadModal/getImagesWithDescription.js.map +1 -1
  42. package/dist/index.d.ts +6 -2
  43. package/dist/index.js +3 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/routines/DashboardRoutinesGeneration.js.map +1 -1
  46. package/dist/routines/RoutinesGeneration.d.ts +17 -1
  47. package/dist/routines/RoutinesGeneration.js +18 -2
  48. package/dist/routines/RoutinesGeneration.js.map +1 -1
  49. package/dist/semanticSearch/SearchController/index.js.map +1 -1
  50. package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/Component.js.map +1 -1
  51. package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/index.js.map +1 -1
  52. package/dist/semanticSearch/ViewController/types.d.ts +5 -0
  53. package/dist/semanticSearch/ViewController/types.js.map +1 -1
  54. package/dist/stream/ResponseStream.d.ts +60 -14
  55. package/dist/stream/ResponseStream.js +216 -73
  56. package/dist/stream/ResponseStream.js.map +1 -1
  57. package/dist/stream/StreamServicePoller.d.ts +10 -1
  58. package/dist/stream/StreamServicePoller.js +10 -1
  59. package/dist/stream/StreamServicePoller.js.map +1 -1
  60. package/package.json +8 -8
@@ -1,21 +1,73 @@
1
1
  import { jsxs, jsx, Fragment } from '@apia/theme/jsx-runtime';
2
2
  import { observer } from 'mobx-react-lite';
3
3
  import { Form, getVariant, Box, spacing } from '@apia/theme';
4
- import { useRef, useState } from 'react';
4
+ import { makeAutoObservable } from 'mobx';
5
+ import { useRef } from 'react';
5
6
  import { getLabel } from '@apia/util';
6
7
  import { getBase64FromFile } from '../util.js';
7
8
  import { AutogrowTextarea, IconButton, ApiaUtil } from '@apia/components';
8
- import { Icon } from '@apia/icons';
9
+ import { QuestionComposer } from './TextArea/QuestionComposer.js';
10
+ import { PendingMessagesPanel } from './PendingMessagesPanel.js';
9
11
 
12
+ var __defProp = Object.defineProperty;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __publicField = (obj, key, value) => {
15
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
16
+ return value;
17
+ };
18
+ function getImageExtension(mimeType) {
19
+ const type = mimeType.toLowerCase();
20
+ if (type === "image/jpeg")
21
+ return "jpg";
22
+ if (type === "image/svg+xml")
23
+ return "svg";
24
+ return type.startsWith("image/") ? type.slice("image/".length) : "png";
25
+ }
26
+ function makePastedImageName(mimeType) {
27
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\..+/, "").replace("T", "_");
28
+ return `pasted_image_${timestamp}.${getImageExtension(mimeType)}`;
29
+ }
30
+ function normalizePastedImageFile(file) {
31
+ if (file.name) {
32
+ return file;
33
+ }
34
+ return new File([file], makePastedImageName(file.type), {
35
+ lastModified: Date.now(),
36
+ type: file.type
37
+ });
38
+ }
39
+ function getPastedImageFiles(clipboardData) {
40
+ const itemFiles = Array.from(clipboardData.items).filter((item) => item.kind === "file" && item.type.startsWith("image/")).map((item) => item.getAsFile()).filter((file) => file instanceof File);
41
+ const files = itemFiles.length > 0 ? itemFiles : Array.from(clipboardData.files).filter(
42
+ (file) => file.type.startsWith("image/")
43
+ );
44
+ return files.map(normalizePastedImageFile);
45
+ }
46
+ class TextAreaState {
47
+ constructor() {
48
+ __publicField(this, "dragging", false);
49
+ __publicField(this, "setDragging", (dragging) => {
50
+ this.dragging = dragging;
51
+ });
52
+ makeAutoObservable(this);
53
+ }
54
+ }
10
55
  const TextArea = observer(
11
56
  ({
12
57
  additionalOptions = [],
13
58
  isLoading,
59
+ isModelSelectionLoading = false,
14
60
  isRecording,
61
+ allowModelSelection = false,
62
+ canAttach = true,
63
+ canNavigateHistory = true,
64
+ canOpenCamera = true,
65
+ canRecord = true,
15
66
  disablePrevButton,
16
67
  disableNextButton,
17
68
  onSubmit,
18
69
  onChange,
70
+ onChangeModel,
19
71
  onClearHistory,
20
72
  onAttach,
21
73
  onRecord,
@@ -25,6 +77,8 @@ const TextArea = observer(
25
77
  onNext,
26
78
  value,
27
79
  attachments,
80
+ modelOptions = [],
81
+ selectedModel,
28
82
  className,
29
83
  pendingQuestion,
30
84
  questionDraft = "",
@@ -34,58 +88,122 @@ const TextArea = observer(
34
88
  onQuestionSkip,
35
89
  canCancelRequest = false,
36
90
  isCancellingRequest = false,
37
- onCancelRequest
91
+ onCancelRequest,
92
+ onStop,
93
+ onPendingMessagesHeightChange,
94
+ onRemovePendingMessage,
95
+ onUpdatePendingMessage,
96
+ pendingMessages = []
38
97
  }) => {
39
98
  const fileInputRef = useRef(null);
40
99
  const searchControlsRef = useRef(null);
41
- const [dragging, setDragging] = useState(false);
100
+ const stateRef = useRef();
101
+ if (!stateRef.current) {
102
+ stateRef.current = new TextAreaState();
103
+ }
104
+ const state = stateRef.current;
105
+ const attachFiles = async (files) => {
106
+ for (const f of files) {
107
+ const base64 = await getBase64FromFile(f);
108
+ onAttach({
109
+ base64,
110
+ name: f.name,
111
+ id: f.name
112
+ });
113
+ }
114
+ };
42
115
  const handleAttachments = async (ev) => {
43
116
  if (ev.target.files) {
44
- for await (const f of ev.target.files) {
45
- const base64 = await getBase64FromFile(f);
46
- onAttach({
47
- base64,
48
- name: f.name,
49
- id: f.name
50
- });
51
- }
117
+ await attachFiles(Array.from(ev.target.files));
52
118
  ev.target.value = "";
53
119
  }
54
120
  };
55
- const menuItemsList = [
56
- ...additionalOptions.length > 0 ? [...additionalOptions, "separator"] : [],
57
- {
121
+ const handlePaste = async (ev) => {
122
+ const files = getPastedImageFiles(ev.clipboardData);
123
+ if (files.length === 0) {
124
+ return;
125
+ }
126
+ ev.preventDefault();
127
+ await attachFiles(files);
128
+ };
129
+ const menuItemsList = [];
130
+ const addMenuSection = (items) => {
131
+ if (items.length === 0) {
132
+ return;
133
+ }
134
+ if (menuItemsList.length > 0 && menuItemsList[menuItemsList.length - 1] !== "separator") {
135
+ menuItemsList.push("separator");
136
+ }
137
+ menuItemsList.push(...items);
138
+ };
139
+ const attachmentItems = [];
140
+ if (canAttach) {
141
+ attachmentItems.push({
58
142
  children: getLabel("btnUpload").text,
59
143
  title: getLabel("btnUpload").text,
60
144
  icon: "File",
61
145
  onClick: () => fileInputRef.current?.click(),
62
146
  key: "2"
63
- },
64
- {
147
+ });
148
+ }
149
+ if (canAttach && canOpenCamera) {
150
+ attachmentItems.push({
65
151
  title: getLabel("lblOpenCamera").text,
66
152
  children: getLabel("lblOpenCamera").text,
67
153
  icon: "Camera",
68
154
  onClick: onVideoRecord,
69
155
  key: "3"
70
- },
71
- "separator",
72
- {
73
- icon: "ArrowLeft",
74
- children: getLabel("btnAiPrevious").text,
75
- title: getLabel("btnAiPrevious").text,
76
- onClick: onPrev,
77
- disabled: disablePrevButton,
78
- key: "0"
79
- },
80
- {
81
- icon: "ArrowRight",
82
- children: getLabel("btnAiNext").text,
83
- title: getLabel("btnAiNext").text,
84
- onClick: onNext,
85
- disabled: disableNextButton,
86
- key: "1"
87
- },
88
- "separator",
156
+ });
157
+ }
158
+ const modelItems = [];
159
+ if (allowModelSelection && modelOptions.length > 0) {
160
+ modelItems.push({
161
+ children: "Modelos disponibles",
162
+ disabled: true,
163
+ key: "model-selection-header",
164
+ title: "Modelos disponibles"
165
+ });
166
+ modelItems.push(
167
+ ...modelOptions.map((model) => ({
168
+ children: model.label,
169
+ disabled: isModelSelectionLoading,
170
+ icon: model.id === selectedModel ? "Check" : void 0,
171
+ key: `model-selection-${model.id}`,
172
+ onClick: () => {
173
+ if (model.id !== selectedModel) {
174
+ onChangeModel?.(model.id);
175
+ }
176
+ },
177
+ title: model.label
178
+ }))
179
+ );
180
+ }
181
+ const historyItems = [];
182
+ if (canNavigateHistory) {
183
+ historyItems.push(
184
+ {
185
+ icon: "ArrowLeft",
186
+ children: getLabel("btnAiPrevious").text,
187
+ title: getLabel("btnAiPrevious").text,
188
+ onClick: onPrev,
189
+ disabled: disablePrevButton,
190
+ key: "0"
191
+ },
192
+ {
193
+ icon: "ArrowRight",
194
+ children: getLabel("btnAiNext").text,
195
+ title: getLabel("btnAiNext").text,
196
+ onClick: onNext,
197
+ disabled: disableNextButton,
198
+ key: "1"
199
+ }
200
+ );
201
+ }
202
+ addMenuSection(additionalOptions);
203
+ addMenuSection(attachmentItems);
204
+ addMenuSection(modelItems);
205
+ addMenuSection(historyItems);
206
+ addMenuSection([
89
207
  {
90
208
  icon: "Trash",
91
209
  onClick: onClearHistory,
@@ -93,27 +211,25 @@ const TextArea = observer(
93
211
  children: getLabel("btnAiDeleteMessages").text,
94
212
  title: getLabel("btnAiDeleteMessages").text
95
213
  }
96
- ];
214
+ ]);
215
+ const canSubmitCurrentMessage = !isModelSelectionLoading && (value !== "" || attachments.length > 0);
216
+ const showRecordButton = canRecord && !isLoading && !isRecording && value === "" && attachments.length === 0;
217
+ const canStopRequest = isLoading && !isRecording && (Boolean(onStop) || canCancelRequest);
97
218
  const handleDragLeave = (ev) => {
98
219
  ev.preventDefault();
99
- setDragging(false);
220
+ state.setDragging(false);
100
221
  };
101
- const handleDrop = (ev) => {
222
+ const handleDrop = async (ev) => {
102
223
  ev.preventDefault();
103
- setDragging(false);
104
- const fileElement = document.getElementById(
105
- `invisible__attach__file`
106
- );
107
- (fileInputRef.current ?? fileElement).files = ev.dataTransfer.files;
108
- const event = new Event("change", { bubbles: true });
109
- fileElement.dispatchEvent(event);
224
+ state.setDragging(false);
225
+ await attachFiles(Array.from(ev.dataTransfer.files));
110
226
  };
111
227
  const handleDragOver = (ev) => {
112
228
  ev.preventDefault();
113
229
  };
114
230
  const handleDragEnter = (ev) => {
115
231
  ev.preventDefault();
116
- setDragging(true);
232
+ state.setDragging(true);
117
233
  };
118
234
  return /* @__PURE__ */ jsxs(
119
235
  Form,
@@ -126,10 +242,10 @@ const TextArea = observer(
126
242
  ev.preventDefault();
127
243
  onSubmit();
128
244
  },
129
- className: `search_controls ${className}`,
245
+ className: `search_controls ${className || ""}`,
130
246
  ...getVariant("layout.common.chat.form"),
131
247
  children: [
132
- dragging ? /* @__PURE__ */ jsx(
248
+ state.dragging ? /* @__PURE__ */ jsx(
133
249
  Box,
134
250
  {
135
251
  sx: {
@@ -142,103 +258,119 @@ const TextArea = observer(
142
258
  },
143
259
  children: getLabel("msgAiDragAndDrop").text
144
260
  }
145
- ) : pendingQuestion ? /* @__PURE__ */ jsx(
146
- QuestionComposer,
147
- {
148
- pendingQuestion,
149
- questionDraft,
150
- onQuestionDraftChange,
151
- onQuestionOptionSelect,
152
- onQuestionCustomSubmit,
153
- onQuestionSkip,
154
- canCancelRequest,
155
- isCancellingRequest,
156
- onCancelRequest
157
- }
158
261
  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
159
262
  /* @__PURE__ */ jsx(
160
- AutogrowTextarea,
263
+ PendingMessagesPanel,
161
264
  {
162
- ref: searchControlsRef,
163
- "aria-label": (
164
- /** TODO: Crear etiqueta para busqueda */
165
- "Frase de busqueda"
166
- ),
167
- value,
168
- className: "searchTextArea",
169
- onChange: (ev) => onChange(ev.target.value),
170
- onKeyDown: (ev) => {
171
- if ((ev.code === "Enter" || ev.code === "NumpadEnter") && !ev.shiftKey) {
172
- ev.preventDefault();
173
- ev.target.closest("form").querySelector('[type="submit"]').click();
174
- }
175
- },
176
- sx: {
177
- resize: "none",
178
- px: spacing(4),
179
- background: "transparent",
180
- border: "none",
181
- alignContent: "center"
182
- }
265
+ messages: pendingMessages,
266
+ onHeightChange: onPendingMessagesHeightChange,
267
+ onRemoveMessage: (message) => onRemovePendingMessage?.(message),
268
+ onUpdateMessage: (message, value2) => onUpdatePendingMessage?.(message, value2)
183
269
  }
184
270
  ),
185
- /* @__PURE__ */ jsxs(Box, { className: "chatButtons", children: [
271
+ pendingQuestion ? /* @__PURE__ */ jsx(
272
+ QuestionComposer,
273
+ {
274
+ pendingQuestion,
275
+ questionDraft,
276
+ onQuestionDraftChange,
277
+ onQuestionOptionSelect,
278
+ onQuestionCustomSubmit,
279
+ onQuestionSkip,
280
+ canCancelRequest,
281
+ isCancellingRequest,
282
+ onCancelRequest
283
+ }
284
+ ) : /* @__PURE__ */ jsxs(Box, { className: "chatInputRow", children: [
186
285
  /* @__PURE__ */ jsx(
187
- IconButton,
286
+ AutogrowTextarea,
188
287
  {
189
- className: "ChatBarButton",
190
- icon: isRecording ? "Trash" : "Ellipsis",
191
- variant: "icon-only",
192
- iconSize: "Sm",
193
- onClick: isRecording ? onRecordCancel : (ev) => {
194
- ApiaUtil.instance.menu.open({
195
- menuProps: {
196
- anchorPoint: { x: ev.clientX, y: ev.clientY }
197
- },
198
- items: menuItemsList
199
- });
288
+ ref: searchControlsRef,
289
+ "aria-label": (
290
+ /** TODO: Crear etiqueta para busqueda */
291
+ "Frase de busqueda"
292
+ ),
293
+ value,
294
+ className: "searchTextArea",
295
+ onChange: (ev) => onChange(ev.target.value),
296
+ onPaste: handlePaste,
297
+ onKeyDown: (ev) => {
298
+ if ((ev.code === "Enter" || ev.code === "NumpadEnter") && !ev.shiftKey) {
299
+ ev.preventDefault();
300
+ ev.target.closest("form").querySelector('[type="submit"]').click();
301
+ }
302
+ },
303
+ sx: {
304
+ resize: "none",
305
+ px: spacing(4),
306
+ background: "transparent",
307
+ border: "none",
308
+ alignContent: "center"
200
309
  }
201
310
  }
202
311
  ),
203
- value === "" && attachments.length === 0 || isRecording ? canCancelRequest && isLoading && !isRecording ? /* @__PURE__ */ jsx(
204
- IconButton,
205
- {
206
- className: "ChatBarButton",
207
- icon: "Stop",
208
- variant: "icon-only",
209
- iconSize: "Sm",
210
- title: "Cancelar respuesta",
211
- onClick: () => onCancelRequest?.(),
212
- isLoading: isCancellingRequest,
213
- disabled: isCancellingRequest
214
- }
215
- ) : /* @__PURE__ */ jsx(
216
- IconButton,
217
- {
218
- className: `ChatBarButton ${isRecording ? "isRecording" : ""}`,
219
- icon: isRecording ? "Stop" : "Microphone",
220
- variant: "icon-only",
221
- iconSize: "Sm",
222
- title: getLabel("lblAiRecordAudio").text,
223
- onClick: onRecord,
224
- disabled: isLoading && !isRecording,
225
- sx: {
226
- color: isRecording ? "red" : void 0
227
- },
228
- id: "transcribeAudio"
229
- }
230
- ) : /* @__PURE__ */ jsx(
231
- IconButton,
232
- {
233
- className: "ChatBarButton",
234
- isLoading,
235
- icon: "ArrowRight",
236
- variant: "icon-only",
237
- iconSize: "Sm",
238
- title: getLabel("btnBus").title,
239
- type: "submit"
240
- }
241
- )
312
+ /* @__PURE__ */ jsxs(Box, { className: "chatButtons", children: [
313
+ /* @__PURE__ */ jsx(
314
+ IconButton,
315
+ {
316
+ className: "ChatBarButton",
317
+ icon: isRecording ? "Trash" : "Ellipsis",
318
+ variant: "icon-only",
319
+ iconSize: "Sm",
320
+ onClick: isRecording ? onRecordCancel : (ev) => {
321
+ ApiaUtil.instance.menu.open({
322
+ menuProps: {
323
+ anchorPoint: { x: ev.clientX, y: ev.clientY }
324
+ },
325
+ items: menuItemsList
326
+ });
327
+ }
328
+ }
329
+ ),
330
+ canStopRequest && /* @__PURE__ */ jsx(
331
+ IconButton,
332
+ {
333
+ className: "ChatBarButton",
334
+ icon: "Stop",
335
+ variant: "icon-only",
336
+ iconSize: "Sm",
337
+ title: getLabel("btnCan").text,
338
+ onClick: () => onStop ? onStop() : onCancelRequest?.(),
339
+ isLoading: isCancellingRequest,
340
+ disabled: isCancellingRequest,
341
+ sx: {
342
+ color: "palette.error.main"
343
+ }
344
+ }
345
+ ),
346
+ showRecordButton ? /* @__PURE__ */ jsx(
347
+ IconButton,
348
+ {
349
+ className: `ChatBarButton ${isRecording ? "isRecording" : ""}`,
350
+ icon: isRecording ? "Stop" : "Microphone",
351
+ variant: "icon-only",
352
+ iconSize: "Sm",
353
+ title: getLabel("lblAiRecordAudio").text,
354
+ onClick: onRecord,
355
+ disabled: isModelSelectionLoading || isLoading && !isRecording,
356
+ sx: {
357
+ color: isRecording ? "red" : void 0
358
+ },
359
+ id: "transcribeAudio"
360
+ }
361
+ ) : /* @__PURE__ */ jsx(
362
+ IconButton,
363
+ {
364
+ className: "ChatBarButton",
365
+ icon: "ArrowRight",
366
+ variant: "icon-only",
367
+ iconSize: "Sm",
368
+ title: getLabel("btnBus").title,
369
+ type: "submit",
370
+ disabled: !canSubmitCurrentMessage && !isRecording
371
+ }
372
+ )
373
+ ] })
242
374
  ] })
243
375
  ] }),
244
376
  /* @__PURE__ */ jsx(
@@ -257,121 +389,6 @@ const TextArea = observer(
257
389
  );
258
390
  }
259
391
  );
260
- const QuestionComposer = ({
261
- pendingQuestion,
262
- questionDraft,
263
- onQuestionDraftChange,
264
- onQuestionOptionSelect,
265
- onQuestionCustomSubmit,
266
- onQuestionSkip,
267
- canCancelRequest,
268
- isCancellingRequest,
269
- onCancelRequest
270
- }) => {
271
- return /* @__PURE__ */ jsxs(Box, { className: "chatQuestion", children: [
272
- /* @__PURE__ */ jsx(Box, { className: "chatQuestion__eyebrow", children: "Pregunta del agente" }),
273
- /* @__PURE__ */ jsx(Box, { className: "chatQuestion__title", children: pendingQuestion.title }),
274
- pendingQuestion.description && /* @__PURE__ */ jsx(Box, { className: "chatQuestion__description", children: pendingQuestion.description }),
275
- /* @__PURE__ */ jsx(Box, { className: "chatQuestion__options", children: pendingQuestion.options.map((option) => /* @__PURE__ */ jsx(
276
- QuestionOptionButton,
277
- {
278
- option,
279
- onClick: () => onQuestionOptionSelect?.(option)
280
- },
281
- `${pendingQuestion.id}_${option.value}`
282
- )) }),
283
- /* @__PURE__ */ jsxs(Box, { className: "chatQuestion__custom", children: [
284
- /* @__PURE__ */ jsx(Box, { className: "chatQuestion__customLabel", children: "Otra respuesta" }),
285
- /* @__PURE__ */ jsx(
286
- AutogrowTextarea,
287
- {
288
- "aria-label": "Respuesta personalizada",
289
- value: questionDraft,
290
- className: "chatQuestion__customInput",
291
- onChange: (ev) => onQuestionDraftChange?.(ev.target.value),
292
- onKeyDown: (ev) => {
293
- if ((ev.code === "Enter" || ev.code === "NumpadEnter") && !ev.shiftKey) {
294
- ev.preventDefault();
295
- onQuestionCustomSubmit?.();
296
- }
297
- },
298
- sx: {
299
- resize: "none",
300
- background: "transparent",
301
- border: "none",
302
- minHeight: "56px",
303
- width: "100%"
304
- }
305
- }
306
- ),
307
- /* @__PURE__ */ jsxs(Box, { className: "chatQuestion__actions", children: [
308
- canCancelRequest && /* @__PURE__ */ jsx(
309
- "button",
310
- {
311
- type: "button",
312
- className: "chatQuestion__action chatQuestion__action--ghost",
313
- onClick: () => onCancelRequest?.(),
314
- disabled: isCancellingRequest,
315
- children: isCancellingRequest ? "Cancelando..." : "Cancelar"
316
- }
317
- ),
318
- /* @__PURE__ */ jsx(
319
- "button",
320
- {
321
- type: "button",
322
- className: "chatQuestion__action chatQuestion__action--ghost",
323
- onClick: () => onQuestionSkip?.(),
324
- children: "Saltar"
325
- }
326
- ),
327
- /* @__PURE__ */ jsx(
328
- "button",
329
- {
330
- type: "button",
331
- className: "chatQuestion__action",
332
- onClick: () => onQuestionCustomSubmit?.(),
333
- disabled: questionDraft.trim().length === 0,
334
- children: "Enviar respuesta"
335
- }
336
- )
337
- ] })
338
- ] })
339
- ] });
340
- };
341
- const QuestionOptionButton = ({
342
- option,
343
- onClick
344
- }) => {
345
- const tooltip = ApiaUtil.instance.tooltips.useHover(
346
- option.description ? {
347
- preferredOrientationX: "left",
348
- preferredOrientationY: "top",
349
- attachToMousePosition: true,
350
- closeOnMouseLeaveAttachedElement: true,
351
- children: /* @__PURE__ */ jsx(Box, { className: "chatQuestion__tooltip", children: option.description })
352
- } : void 0
353
- );
354
- return /* @__PURE__ */ jsxs(
355
- "button",
356
- {
357
- type: "button",
358
- className: "chatQuestion__option",
359
- onClick: () => onClick(),
360
- children: [
361
- /* @__PURE__ */ jsx(Box, { className: "chatQuestion__optionLabel", children: option.label }),
362
- option.description && /* @__PURE__ */ jsx(
363
- Box,
364
- {
365
- as: "span",
366
- className: "chatQuestion__optionInfo",
367
- ref: tooltip.ref,
368
- children: /* @__PURE__ */ jsx(Icon, { name: "Info", size: 12, title: "" })
369
- }
370
- )
371
- ]
372
- }
373
- );
374
- };
375
392
 
376
393
  export { TextArea };
377
394
  //# sourceMappingURL=TextArea.js.map