@box/box-ai-content-answers 1.19.4 → 1.21.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 (48) hide show
  1. package/dist/chunks/clear-conversation-button.js +15 -16
  2. package/dist/chunks/stopResponseButton.js +19 -23
  3. package/dist/chunks/types.js +8 -8
  4. package/dist/chunks/warning-message.js +15 -16
  5. package/dist/esm/lib/components/answer/answer-content.js +15 -15
  6. package/dist/esm/lib/components/answer/answer.js +107 -109
  7. package/dist/esm/lib/components/answer/citation.js +23 -24
  8. package/dist/esm/lib/components/answer/copy-button.js +3 -3
  9. package/dist/esm/lib/components/answer/embed-the-answer-button.js +44 -44
  10. package/dist/esm/lib/components/answer/feedback-tooltip.js +63 -56
  11. package/dist/esm/lib/components/answer/inline-error.js +1 -1
  12. package/dist/esm/lib/components/answer/loading-indicator.js +15 -18
  13. package/dist/esm/lib/components/answer/references.js +30 -30
  14. package/dist/esm/lib/components/answer/thumb-buttons.js +95 -96
  15. package/dist/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +166 -167
  16. package/dist/esm/lib/components/api-wrapper/reducer.js +1 -1
  17. package/dist/esm/lib/components/api-wrapper/utils/request.js +8 -8
  18. package/dist/esm/lib/components/api-wrapper/utils/stream.js +24 -25
  19. package/dist/esm/lib/components/chat/chat.js +78 -79
  20. package/dist/esm/lib/components/common/focusInputUtils.js +3 -4
  21. package/dist/esm/lib/components/common/markdown-react.js +91 -93
  22. package/dist/esm/lib/components/common/markdown.js +2666 -2696
  23. package/dist/esm/lib/components/content/content.js +38 -39
  24. package/dist/esm/lib/components/footer/footer-actions.js +3 -3
  25. package/dist/esm/lib/components/footer/footer.js +97 -98
  26. package/dist/esm/lib/components/modal/modal.js +121 -122
  27. package/dist/esm/lib/components/sidebar/content.js +95 -101
  28. package/dist/esm/lib/components/sidebar/sidebar.js +82 -83
  29. package/dist/esm/lib/components/suggested-questions/suggested-questions.js +1 -1
  30. package/dist/esm/lib/components/suggested-questions/suggestions.js +30 -30
  31. package/dist/esm/lib/components/welcome-message/contextual-items-message.js +36 -38
  32. package/dist/esm/lib/components/welcome-message/items-dropdown.js +27 -27
  33. package/dist/esm/lib/hooks/usePromptFocus.js +13 -14
  34. package/dist/i18n/en-x-pseudo.js +89 -89
  35. package/dist/i18n/en-x-pseudo.properties +89 -89
  36. package/dist/styles/answer-content.css +1 -1
  37. package/dist/styles/answer.css +1 -1
  38. package/dist/styles/box-ai-content-answers.css +1 -1
  39. package/dist/styles/chat.css +1 -1
  40. package/dist/styles/clear-conversation-button.css +1 -1
  41. package/dist/styles/content.css +1 -1
  42. package/dist/styles/content2.css +1 -1
  43. package/dist/styles/markdown2.css +1 -1
  44. package/dist/styles/question.css +1 -1
  45. package/dist/styles/stopResponseButton.css +1 -1
  46. package/dist/styles/warning-message.css +1 -1
  47. package/dist/types/lib/components/api-wrapper/hooks/useContentAnswers.d.ts +1 -1
  48. package/package.json +11 -11
@@ -1,120 +1,119 @@
1
- import { useBlueprintModernization as J, useNotification as K, Tooltip as N, IconButton as y } from "@box/blueprint-web";
2
- import { ThumbUp as Q, ThumbDown as V } from "@box/blueprint-web-assets/icons/Fill";
3
- import { ThumbUp as X, ThumbDown as Y } from "@box/blueprint-web-assets/icons/Line";
4
- import { ThumbsUp as Z, ThumbsDown as C } from "@box/blueprint-web-assets/icons/Medium";
5
- import { ThumbsUp as O, ThumbsDown as q } from "@box/blueprint-web-assets/icons/MediumFilled";
6
- import { useAgents as k } from "@box/box-ai-agent-selector";
7
- import b from "react";
8
- import { useIntl as F } from "react-intl";
9
- import { LOGGER_BASE_CONFIG as tt, LOGGER_ACTION_PROGRAMMATIC as st } from "../common/constants.js";
10
- import { FeedbackTooltip as at } from "./feedback-tooltip.js";
11
- import x from "../../messages.js";
12
- import { focusInput as mt } from "../common/focusInputUtils.js";
13
- import i from "./messages.js";
14
- import { jsxs as ot, Fragment as lt, jsx as n } from "react/jsx-runtime";
15
- import '../../../../styles/thumb-buttons.css';const ut = "_thumbDown_1axcd_1", rt = {
16
- thumbDown: ut
17
- }, r = {
1
+ import { useBlueprintModernization as W, useNotification as E, Tooltip as A, IconButton as L } from "@box/blueprint-web";
2
+ import { ThumbUp as j, ThumbDown as F } from "@box/blueprint-web-assets/icons/Fill";
3
+ import { ThumbUp as J, ThumbDown as K } from "@box/blueprint-web-assets/icons/Line";
4
+ import { ThumbsUp as Q, ThumbsDown as V } from "@box/blueprint-web-assets/icons/Medium";
5
+ import { ThumbsUp as X, ThumbsDown as Y } from "@box/blueprint-web-assets/icons/MediumFilled";
6
+ import { useAgents as Z } from "@box/box-ai-agent-selector";
7
+ import c from "react";
8
+ import { useIntl as q } from "react-intl";
9
+ import { LOGGER_ACTION_PROGRAMMATIC as tt, LOGGER_BASE_CONFIG as et } from "../common/constants.js";
10
+ import { FeedbackTooltip as ot } from "./feedback-tooltip.js";
11
+ import C from "../../messages.js";
12
+ import { focusInput as at } from "../common/focusInputUtils.js";
13
+ import l from "./messages.js";
14
+ import { jsxs as st, Fragment as nt, jsx as i } from "react/jsx-runtime";
15
+ import '../../../../styles/thumb-buttons.css';const mt = "_thumbDown_1axcd_1", lt = {
16
+ thumbDown: mt
17
+ }, m = {
18
18
  THUMB_UP: "positive",
19
- THUMB_DOWN: "negative",
20
- NONE: "none"
21
- }, Mt = ({
22
- feedbackValue: H,
23
- hostAppName: h,
24
- isFeedbackFormEnabled: I = !1,
25
- isFeedbackTooltipOpen: P = !1,
26
- items: U,
27
- onFeedbackFormSubmit: D,
28
- onFeedbackTooltipOpenChange: s,
29
- prompt: p,
30
- promptType: _,
31
- questionId: a,
32
- recordAction: f,
33
- response: B,
34
- setAnswerFeedback: e,
19
+ THUMB_DOWN: "negative"
20
+ }, Bt = ({
21
+ feedbackValue: y,
22
+ hostAppName: b,
23
+ isFeedbackFormEnabled: O = !1,
24
+ isFeedbackTooltipOpen: x = !1,
25
+ items: p,
26
+ onFeedbackFormSubmit: h,
27
+ onFeedbackTooltipOpenChange: r,
28
+ prompt: T,
29
+ promptType: d,
30
+ questionId: e,
31
+ recordAction: U,
32
+ response: D,
33
+ setAnswerFeedback: _,
35
34
  shouldFeedbackFormIncludeFeedbackText: w = !1,
36
- shouldFeedbackIncludePromptData: M = !1,
37
- variant: d
35
+ shouldFeedbackIncludePromptData: B = !1,
36
+ variant: M
38
37
  }) => {
39
38
  const {
40
- enableModernizedComponents: m
41
- } = J(), {
42
- formatMessage: o
43
- } = F(), {
44
- addNotification: v
45
- } = K(), {
46
- selectedAgent: L
47
- } = k(), u = H, T = b.useMemo(() => U.filter((t) => t.status === "supported").map((t) => t.fileType), [U]), c = b.useCallback((t) => {
48
- u !== t && (e == null || e(a, t), f == null || f({
49
- ...tt,
50
- action: st,
39
+ enableModernizedComponents: o
40
+ } = W(), {
41
+ formatMessage: a
42
+ } = q(), {
43
+ addNotification: H
44
+ } = E(), {
45
+ selectedAgent: g
46
+ } = Z(), n = y, f = c.useMemo(() => p.filter((t) => t.status === "supported").map((t) => t.fileType), [p]), u = c.useCallback((t) => {
47
+ n !== t && (_?.(e, t), U?.({
48
+ ...et,
49
+ action: tt,
51
50
  target: "answer_feedback",
52
- component: d,
51
+ component: M,
53
52
  data: {
54
53
  feedback_value: t,
55
- file_types: T,
56
- feature: h,
57
- prompt_type: _
54
+ file_types: f,
55
+ feature: b,
56
+ prompt_type: d
58
57
  }
59
- }), mt());
60
- }, [h, f, u, d, T, a, e, _]), G = ({
58
+ }), at());
59
+ }, [b, U, n, M, f, e, _, d]), I = ({
61
60
  feedback: t,
62
- feedbackPromptShareConsent: j,
63
- issueType: g
61
+ feedbackPromptShareConsent: $,
62
+ issueType: z
64
63
  }) => {
65
- if (s == null || s(!1, a), !D)
64
+ if (r?.(!1, e), !h)
66
65
  return;
67
- const l = {
68
- fileTypes: T,
66
+ const s = {
67
+ fileTypes: f,
69
68
  hasPromptData: !1,
70
- hostApp: h,
71
- issueType: g,
69
+ hostApp: b,
70
+ issueType: z,
72
71
  timestamp: Date.now(),
73
- questionId: a
72
+ questionId: e
74
73
  };
75
- w && (l.feedback = t, l.hasFeedback = !!t), M && j && p && B && (l.hasPromptData = !0, l.prompt = p, l.response = B), L && (l.selectedAgentName = L.name), D(l, () => {
76
- v({
74
+ w && (s.feedback = t, s.hasFeedback = !!t), B && $ && T && D && (s.hasPromptData = !0, s.prompt = T, s.response = D), g && (s.selectedAgentName = g.name), h(s, () => {
75
+ H({
77
76
  sensitivity: "foreground",
78
- styledText: o(i.feedbackTooltipConfirmation),
77
+ styledText: a(l.feedbackTooltipConfirmation),
79
78
  variant: "success",
80
- typeIconAriaLabel: o(x.ariaTypeSuccessIconLabel),
81
- closeButtonAriaLabel: o(x.closeButtonText)
79
+ typeIconAriaLabel: a(C.ariaTypeSuccessIconLabel),
80
+ closeButtonAriaLabel: a(C.closeButtonText)
82
81
  });
83
82
  });
84
- }, R = (t) => {
85
- t || s == null || s(!1, a);
86
- }, S = b.useCallback(() => c(r.THUMB_UP), [c]), $ = b.useCallback(() => {
87
- c(r.THUMB_DOWN), s == null || s(!0, a);
88
- }, [c, s, a]), z = m ? Z : X, A = m ? C : Y, E = m ? O : Q, W = m ? q : V;
89
- return /* @__PURE__ */ ot(lt, {
90
- children: [/* @__PURE__ */ n(N, {
91
- content: o(i.thumbsUpAriaLabel),
92
- children: /* @__PURE__ */ n(y, {
93
- "aria-label": o(i.thumbsUpAriaLabel),
94
- disabled: u === r.THUMB_DOWN,
95
- icon: u === r.THUMB_UP ? E : z,
96
- onClick: S,
83
+ }, N = (t) => {
84
+ t || r?.(!1, e);
85
+ }, k = c.useCallback(() => u(m.THUMB_UP), [u]), P = c.useCallback(() => {
86
+ u(m.THUMB_DOWN), r?.(!0, e);
87
+ }, [u, r, e]), v = o ? Q : J, G = o ? V : K, R = o ? X : j, S = o ? Y : F;
88
+ return /* @__PURE__ */ st(nt, {
89
+ children: [/* @__PURE__ */ i(A, {
90
+ content: a(l.thumbsUpAriaLabel),
91
+ children: /* @__PURE__ */ i(L, {
92
+ "aria-label": a(l.thumbsUpAriaLabel),
93
+ disabled: n === m.THUMB_DOWN,
94
+ icon: n === m.THUMB_UP ? R : v,
95
+ onClick: k,
97
96
  size: "x-small",
98
- variant: m ? "icon-logo" : "default",
97
+ variant: o ? "icon-logo" : "default",
99
98
  "data-target-id": "IconButton-thumbsUpAriaLabel"
100
99
  })
101
- }), /* @__PURE__ */ n(at, {
102
- isOpen: P,
103
- onOpenChange: R,
104
- onSubmit: G,
100
+ }), /* @__PURE__ */ i(ot, {
101
+ isOpen: x,
102
+ onOpenChange: N,
103
+ onSubmit: I,
105
104
  shouldIncludeFeedbackText: w,
106
- shouldIncludePromptShareConsent: M,
107
- shouldShow: I,
108
- children: /* @__PURE__ */ n(N, {
109
- content: o(i.thumbsDownAriaLabel),
110
- children: /* @__PURE__ */ n(y, {
111
- "aria-label": o(i.thumbsDownAriaLabel),
112
- className: m ? "" : rt.thumbDown,
113
- disabled: u === r.THUMB_UP,
114
- icon: u === r.THUMB_DOWN ? W : A,
115
- onClick: $,
105
+ shouldIncludePromptShareConsent: B,
106
+ shouldShow: O,
107
+ children: /* @__PURE__ */ i(A, {
108
+ content: a(l.thumbsDownAriaLabel),
109
+ children: /* @__PURE__ */ i(L, {
110
+ "aria-label": a(l.thumbsDownAriaLabel),
111
+ className: o ? "" : lt.thumbDown,
112
+ disabled: n === m.THUMB_UP,
113
+ icon: n === m.THUMB_DOWN ? S : G,
114
+ onClick: P,
116
115
  size: "x-small",
117
- variant: m ? "icon-logo" : "default",
116
+ variant: o ? "icon-logo" : "default",
118
117
  "data-target-id": "IconButton-thumbsDownAriaLabel"
119
118
  })
120
119
  })
@@ -122,6 +121,6 @@ import '../../../../styles/thumb-buttons.css';const ut = "_thumbDown_1axcd_1", r
122
121
  });
123
122
  };
124
123
  export {
125
- Mt as ThumbButtons,
126
- Mt as default
124
+ Bt as ThumbButtons,
125
+ Bt as default
127
126
  };
@@ -1,248 +1,247 @@
1
- import { useAgentsDispatch as as, ACTIONS as is } from "@box/box-ai-agent-selector";
2
- import us from "lodash/camelCase";
3
- import t, { useMemo as cs, useCallback as Es } from "react";
4
- import { A as T, C as fs, R as V } from "../../../../../chunks/types.js";
5
- import { SET_NEW_ITEM as rs, UPDATE_QUESTION as Cs, SET_MODAL_ERROR as _s, SET_MODAL_SUCCESS as Ts, SET_IS_LOADING as X, SET_ANSWER_FEEDBACK as Rs, CLEAR_CONVERSATION_HISTORY as ds, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as Y, SET_SUGGESTED_QUESTIONS as Ns } from "../actions.js";
6
- import { QuestionRecord as Os } from "../records.js";
7
- import { defaultFormatSuggestions as ys, defaultFormatCitations as Ss } from "../utils/format.js";
8
- import { getAnswerRequest as As } from "../utils/request.js";
1
+ import { useAgentsDispatch as ae, ACTIONS as le } from "@box/box-ai-agent-selector";
2
+ import ie from "lodash/camelCase";
3
+ import r, { useMemo as ce, useCallback as ue } from "react";
4
+ import { A as _, C as Ee, R as J } from "../../../../../chunks/types.js";
5
+ import { SET_NEW_ITEM as fe, UPDATE_QUESTION as Ce, SET_MODAL_ERROR as _e, SET_MODAL_SUCCESS as Te, SET_IS_LOADING as V, SET_ANSWER_FEEDBACK as Re, CLEAR_CONVERSATION_HISTORY as de, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as X, SET_SUGGESTED_QUESTIONS as Ae } from "../actions.js";
6
+ import { QuestionRecord as Ne } from "../records.js";
7
+ import { defaultFormatCitations as Oe, defaultFormatSuggestions as ye } from "../utils/format.js";
8
+ import { getAnswerRequest as Se } from "../utils/request.js";
9
9
  import F from "../utils/stream.js";
10
- const Ls = /Too Many Requests/i, z = "Agent not found";
11
- function Fs({
12
- contentAnswers: a,
13
- createSessionRequest: y,
10
+ const Le = /Too Many Requests/i, Y = "Agent not found";
11
+ function Fe({
12
+ contentAnswers: i,
13
+ createSessionRequest: d,
14
14
  dispatchStateUpdate: o,
15
15
  enterpriseId: D,
16
- fetchTimeout: m,
17
- formatCitations: v = Ss,
18
- getAnswerStreaming: j,
19
- getAnswer: x,
20
- getSuggestedQuestions: I,
21
- isStopResponseEnabled: K,
22
- isStreamingEnabled: A,
23
- itemID: E,
24
- items: u,
25
- onSuggestedQuestionsFetched: P,
26
- sendErrorLog: g,
27
- shouldPreinitSession: N = !0,
28
- userId: W
16
+ fetchTimeout: g,
17
+ formatCitations: v = Oe,
18
+ getAnswerStreaming: w,
19
+ getAnswer: j,
20
+ getSuggestedQuestions: k,
21
+ isStopResponseEnabled: x,
22
+ isStreamingEnabled: O,
23
+ itemID: u,
24
+ items: l,
25
+ onSuggestedQuestionsFetched: K,
26
+ sendErrorLog: m,
27
+ shouldPreinitSession: R = !0,
28
+ userId: P
29
29
  }) {
30
- const S = t.useRef(null), $ = as(), L = cs(() => Array.isArray(u) && u.length > 1, [u]), B = Es((s) => Array.isArray(s) ? v(s) : null, [v]);
31
- t.useEffect(
32
- (s) => {
33
- E && E !== a.item.id && o({
34
- type: rs,
35
- itemID: E,
36
- fileVersionID: s
30
+ const A = r.useRef(null), W = ae(), y = ce(() => Array.isArray(l) && l.length > 1, [l]), $ = ue((e) => Array.isArray(e) ? v(e) : null, [v]);
31
+ r.useEffect(
32
+ (e) => {
33
+ u && u !== i.item.id && o({
34
+ type: fe,
35
+ itemID: u,
36
+ fileVersionID: e
37
37
  });
38
38
  },
39
39
  // eslint-disable-next-line react-hooks/exhaustive-deps
40
- [E]
40
+ [u]
41
41
  );
42
- const c = t.useCallback((s, e) => {
42
+ const c = r.useCallback((e, s) => {
43
43
  o({
44
- type: Cs,
45
- newQuestion: s,
46
- session: e
47
- }), S.current = s;
48
- }, [o]), H = t.useCallback((s) => {
44
+ type: Ce,
45
+ newQuestion: e,
46
+ session: s
47
+ }), A.current = e;
48
+ }, [o]), B = r.useCallback((e) => {
49
49
  o({
50
- type: _s,
51
- error: s
50
+ type: _e,
51
+ error: e
52
52
  });
53
- }, [o]), G = t.useCallback((s, e, l) => {
53
+ }, [o]), I = r.useCallback((e, s, t) => {
54
54
  const {
55
- answer: i,
56
- thinkingAnswer: f,
55
+ answer: a,
56
+ thinkingAnswer: E,
57
57
  error: n,
58
- citations: r = [],
59
- createdAt: R = null,
58
+ citations: f = [],
59
+ createdAt: T = null,
60
60
  encodedSession: C = void 0,
61
- contextSession: d = void 0
62
- } = s, O = e.set("citations", B(r)).merge({
63
- answer: i,
64
- thinkingAnswer: f,
61
+ contextSession: b = void 0
62
+ } = e, M = s.set("citations", $(f)).merge({
63
+ answer: a,
64
+ thinkingAnswer: E,
65
65
  error: n,
66
- created_at: R,
66
+ created_at: T,
67
67
  isLoading: !1,
68
- isCompleted: l
68
+ isCompleted: t
69
69
  });
70
- let _;
71
- C && (_ = {
70
+ let N;
71
+ C && (N = {
72
72
  encodedSession: C
73
- }), d && (_ = {
74
- contextSession: d
75
- }), c(O, _);
76
- }, [c, B]), Q = t.useCallback(
73
+ }), b && (N = {
74
+ contextSession: b
75
+ }), c(M, N);
76
+ }, [c, $]), G = r.useCallback(
77
77
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- (s, e) => {
79
- var d, O, _;
80
- const l = (s == null ? void 0 : s.message) || "", i = ((d = s == null ? void 0 : s.response) == null ? void 0 : d.status) === 429 || Ls.test(l), f = (s == null ? void 0 : s.code) === z || (s == null ? void 0 : s.errorCode) === z, n = ((O = s == null ? void 0 : s.response) == null ? void 0 : O.status) === 204, r = ((_ = s == null ? void 0 : s.response) == null ? void 0 : _.status) === 412, R = n ? T.NO_CONTENT : i ? T.RATE_LIMITING : r ? T.PRECONDITION_FAILED : f ? T.AGENT_NOT_FOUND : T.GENERAL, C = e.merge({
81
- error: R,
78
+ (e, s) => {
79
+ const t = e?.message || "", a = e?.response?.status === 429 || Le.test(t), E = e?.code === Y || e?.errorCode === Y, n = e?.response?.status === 204, f = e?.response?.status === 412, T = n ? _.NO_CONTENT : a ? _.RATE_LIMITING : f ? _.PRECONDITION_FAILED : E ? _.AGENT_NOT_FOUND : _.GENERAL, C = s.merge({
80
+ error: T,
82
81
  isLoading: !1,
83
82
  isCompleted: !0
84
83
  });
85
84
  c(C, void 0);
86
85
  },
87
86
  [c]
88
- ), b = t.useCallback(async (s, e) => {
87
+ ), S = r.useCallback(async (e, s) => {
89
88
  try {
90
- const l = {
91
- prompt: s.prompt,
92
- aiAgent: e || void 0,
93
- userId: W,
89
+ const t = {
90
+ prompt: e.prompt,
91
+ aiAgent: s || void 0,
92
+ userId: P,
94
93
  enterpriseId: D
95
- }, i = `content-answers-${s.id}`;
96
- let f;
97
- A && (f = F.createAbortRequest(i));
98
- const n = await As(l, A, i, E, u, a, x, j, f, m, g);
99
- A ? F.receiveStreamedResponse(i, n, (r) => {
94
+ }, a = `content-answers-${e.id}`;
95
+ let E;
96
+ O && (E = F.createAbortRequest(a));
97
+ const n = await Se(t, O, a, u, l, i, j, w, E, g, m);
98
+ O ? F.receiveStreamedResponse(a, n, (f) => {
100
99
  const {
101
- code: R,
100
+ code: T,
102
101
  data: C,
103
- error: d,
104
- citations: O,
105
- contextSession: _,
106
- isCompleted: os,
107
- createdAt: ts,
108
- thinkingAnswer: ns
109
- } = r, ls = {
110
- thinkingAnswer: ns,
102
+ error: b,
103
+ citations: M,
104
+ contextSession: N,
105
+ isCompleted: oe,
106
+ createdAt: re,
107
+ thinkingAnswer: ne
108
+ } = f, te = {
109
+ thinkingAnswer: ne,
111
110
  answer: C,
112
- citations: O,
113
- error: d,
114
- contextSession: _,
115
- createdAt: ts
111
+ citations: M,
112
+ error: b,
113
+ contextSession: N,
114
+ createdAt: re
116
115
  };
117
- n.ok && n.status === 200 ? G({
118
- ...ls
119
- }, s, os) : Q({
116
+ n.ok && n.status === 200 ? I({
117
+ ...te
118
+ }, e, oe) : G({
120
119
  response: n,
121
- code: R
122
- }, s);
123
- }, void 0, m, g) : (Object.entries(n).forEach(([r, R]) => {
124
- const C = us(r);
125
- delete n[r], n[C] = R;
126
- }), G(n, s, !0));
127
- } catch (l) {
128
- if (K && l instanceof Error && l.name === "AbortError") {
129
- const i = s.set("error", []).merge({
130
- error: T.RESPONSE_STOPPED,
120
+ code: T
121
+ }, e);
122
+ }, void 0, g, m) : (Object.entries(n).forEach(([f, T]) => {
123
+ const C = ie(f);
124
+ delete n[f], n[C] = T;
125
+ }), I(n, e, !0));
126
+ } catch (t) {
127
+ if (x && t instanceof Error && t.name === "AbortError") {
128
+ const a = e.set("error", []).merge({
129
+ error: _.RESPONSE_STOPPED,
131
130
  isLoading: !1,
132
131
  isCompleted: !0
133
132
  });
134
- c(i);
133
+ c(a);
135
134
  } else
136
- Q(l, s);
135
+ G(t, e);
137
136
  }
138
- }, [W, D, A, E, u, a, x, j, m, g, G, Q, K, c]), J = t.useCallback((s) => {
137
+ }, [P, D, O, u, l, i, j, w, g, m, I, G, x, c]), H = r.useCallback((e) => {
139
138
  const {
140
- encoded_session: e,
139
+ encoded_session: s,
141
140
  metadata: {
142
- is_large_file: l
141
+ is_large_file: t
143
142
  } = {
144
143
  is_large_file: !1
145
144
  }
146
- } = s;
145
+ } = e;
147
146
  o({
148
- type: Ts,
149
- encodedSession: e,
150
- isLargeFile: l
147
+ type: Te,
148
+ encodedSession: s,
149
+ isLargeFile: t
151
150
  });
152
- }, [o]), p = t.useCallback(async (s = !0, e = !0) => {
151
+ }, [o]), Q = r.useCallback(async (e = !0, s = !0) => {
153
152
  try {
154
- s && o({
155
- type: X,
153
+ e && o({
154
+ type: V,
156
155
  isLoading: !0
157
156
  });
158
- const l = await y({
159
- items: u
160
- }, E);
161
- J(l);
157
+ const t = await d({
158
+ items: l
159
+ }, u);
160
+ H(t);
162
161
  } catch {
163
- if (e && H(fs.GENERAL), !N && (o({
164
- type: X,
162
+ if (s && B(Ee.GENERAL), !R && (o({
163
+ type: V,
165
164
  isLoading: !1
166
- }), S.current)) {
167
- const i = S.current.set("error", T.GENERAL).merge({
165
+ }), A.current)) {
166
+ const a = A.current.set("error", _.GENERAL).merge({
168
167
  isLoading: !1,
169
168
  isCompleted: !0
170
169
  });
171
- c(i);
170
+ c(a);
172
171
  }
173
172
  }
174
- }, [y, u, E, J, o, N, H, c]), M = t.useCallback((s, e, l = !0) => {
175
- const i = !a.isLoading && !a.encodedSession && !L && y, f = (a == null ? void 0 : a.questions) || [];
176
- l && (s.id = `${f.length}`), !N && i && (s.error = T.GENERAL, s.isLoading = !1, s.isCompleted = !0);
177
- const n = new Os(s);
178
- return c(n), N || a.encodedSession ? b(n, e) : !a.isLoading && !N && y && p(!0, !1), n;
179
- }, [a.encodedSession, a.isLoading, a == null ? void 0 : a.questions, p, y, L, b, N, c]), Z = t.useCallback((s, e) => {
173
+ }, [d, l, u, H, o, R, B, c]), p = r.useCallback((e, s, t = !0) => {
174
+ const a = !i.isLoading && !i.encodedSession && !y && d, E = i?.questions || [];
175
+ t && (e.id = `${E.length}`), !R && a && (e.error = _.GENERAL, e.isLoading = !1, e.isCompleted = !0);
176
+ const n = new Ne(e);
177
+ return c(n), R || i.encodedSession ? S(n, s) : !i.isLoading && !R && d && Q(!0, !1), n;
178
+ }, [i.encodedSession, i.isLoading, i?.questions, Q, d, y, S, R, c]), z = r.useCallback((e, s) => {
180
179
  o({
181
- type: Rs,
182
- questionId: s,
183
- feedbackValue: e
180
+ type: Re,
181
+ questionId: e,
182
+ feedbackValue: s
184
183
  });
185
- }, [o]), q = t.useCallback(() => {
184
+ }, [o]), Z = r.useCallback(() => {
186
185
  o({
187
- type: ds
186
+ type: de
188
187
  });
189
- }, [o]), w = t.useCallback(async (s, e) => {
190
- M({
191
- ...s.toJS(),
188
+ }, [o]), q = r.useCallback(async (e, s) => {
189
+ p({
190
+ ...e.toJS(),
192
191
  answer: "",
193
192
  isLoading: !0,
194
193
  isCompleted: !1,
195
194
  error: null
196
- }, e, !1);
197
- }, [M]), h = t.useCallback((s) => {
198
- let e;
199
- s ? e = s.id : S.current && (e = S.current.id), e && F.abortRequest(`content-answers-${e}`, !0);
200
- }, []), U = t.useCallback(async (s) => {
201
- s && $({
202
- type: is.SET_ASK_CONFIG,
203
- id: s.id,
204
- ask: s == null ? void 0 : s.ask
195
+ }, s, !1);
196
+ }, [p]), h = r.useCallback((e) => {
197
+ let s;
198
+ e ? s = e.id : A.current && (s = A.current.id), s && F.abortRequest(`content-answers-${s}`, !0);
199
+ }, []), U = r.useCallback(async (e) => {
200
+ e && W({
201
+ type: le.SET_ASK_CONFIG,
202
+ id: e.id,
203
+ ask: e?.ask
205
204
  });
206
- }, [$]), [k, ss] = t.useState("");
207
- t.useEffect(() => {
208
- if (!u || u.length === 0)
205
+ }, [W]), [L, ee] = r.useState("");
206
+ r.useEffect(() => {
207
+ if (!l || l.length === 0)
209
208
  return;
210
- const s = u.map((e) => e.id).join(",");
211
- s !== k && ss(s);
212
- }, [u, k]);
213
- const es = t.useCallback(async () => {
214
- if (!(!k || !I || L)) {
209
+ const e = l.map((s) => s.id).join(",");
210
+ e !== L && ee(e);
211
+ }, [l, L]);
212
+ const se = r.useCallback(async () => {
213
+ if (!(!L || !k || y)) {
215
214
  o({
216
- type: Y,
217
- requestState: V.IN_PROGRESS
215
+ type: X,
216
+ requestState: J.IN_PROGRESS
218
217
  });
219
218
  try {
220
- const s = ys(await I(E, u));
221
- P && P(s), o({
222
- type: Ns,
223
- suggestedQuestions: s
219
+ const e = ye(await k(u, l));
220
+ K && K(e), o({
221
+ type: Ae,
222
+ suggestedQuestions: e
224
223
  });
225
224
  } catch {
226
225
  o({
227
- type: Y,
228
- requestState: V.ERROR
226
+ type: X,
227
+ requestState: J.ERROR
229
228
  });
230
229
  }
231
230
  }
232
- }, [o, I, L, E, k]);
231
+ }, [o, k, y, u, L]);
233
232
  return {
234
- clearConversation: q,
235
- createSession: p,
233
+ clearConversation: Z,
234
+ createSession: Q,
236
235
  fetchAgentConfig: U,
237
- fetchSuggestedQuestions: es,
238
- retryQuestion: w,
239
- sendQuestion: M,
240
- sendQuestionAnswerRequest: b,
241
- setAnswerFeedback: Z,
236
+ fetchSuggestedQuestions: se,
237
+ retryQuestion: q,
238
+ sendQuestion: p,
239
+ sendQuestionAnswerRequest: S,
240
+ setAnswerFeedback: z,
242
241
  stopQuestion: h,
243
242
  updateQuestionInState: c
244
243
  };
245
244
  }
246
245
  export {
247
- Fs as useContentAnswers
246
+ Fe as useContentAnswers
248
247
  };
@@ -26,7 +26,7 @@ const O = (t, s) => {
26
26
  } = t, {
27
27
  newQuestion: n,
28
28
  session: u
29
- } = s, r = [...e], i = (e == null ? void 0 : e.findIndex((o) => o.id === n.id)) ?? -1;
29
+ } = s, r = [...e], i = e?.findIndex((o) => o.id === n.id) ?? -1;
30
30
  i >= 0 ? r[i] = n : r.push(n);
31
31
  const {
32
32
  isCompleted: S