@box/box-ai-content-answers 2.1.38 → 2.1.39

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 (107) hide show
  1. package/dist/chunks/answer-content.js +1 -32
  2. package/dist/chunks/answer.js +1 -183
  3. package/dist/chunks/box-ai-content-answers.js +1 -78
  4. package/dist/chunks/chat.js +1 -116
  5. package/dist/chunks/citation.js +1 -124
  6. package/dist/chunks/clear-conversation-button.js +1 -37
  7. package/dist/chunks/content.js +1 -89
  8. package/dist/chunks/content2.js +1 -213
  9. package/dist/chunks/contextual-items-message.js +1 -43
  10. package/dist/chunks/embed-the-answer-button.js +1 -52
  11. package/dist/chunks/feedback-tooltip.js +1 -130
  12. package/dist/chunks/footer-actions.js +1 -44
  13. package/dist/chunks/inline-error.js +1 -63
  14. package/dist/chunks/items-dropdown.js +1 -67
  15. package/dist/chunks/markdown.js +6 -6776
  16. package/dist/chunks/markdown.module.js +1 -13
  17. package/dist/chunks/media-container.js +1 -32
  18. package/dist/chunks/question.js +1 -29
  19. package/dist/chunks/references.js +1 -43
  20. package/dist/chunks/stopResponseButton.js +1 -45
  21. package/dist/chunks/suggested-questions.js +1 -70
  22. package/dist/chunks/suggestions.js +1 -35
  23. package/dist/chunks/thinkingBubble.js +1 -111
  24. package/dist/chunks/thumb-buttons.js +1 -103
  25. package/dist/chunks/types.js +1 -14
  26. package/dist/chunks/unsupported-items-notice.js +1 -25
  27. package/dist/chunks/warning-message.js +1 -21
  28. package/dist/esm/index.js +1 -11
  29. package/dist/esm/lib/box-ai-content-answers.js +1 -2
  30. package/dist/esm/lib/components/answer/answer-content.js +1 -2
  31. package/dist/esm/lib/components/answer/answer.js +1 -2
  32. package/dist/esm/lib/components/answer/citation.js +1 -2
  33. package/dist/esm/lib/components/answer/constants.js +1 -2
  34. package/dist/esm/lib/components/answer/copy-button.js +1 -46
  35. package/dist/esm/lib/components/answer/embed-the-answer-button.js +1 -2
  36. package/dist/esm/lib/components/answer/feedback-tooltip.js +1 -2
  37. package/dist/esm/lib/components/answer/inline-error.js +1 -2
  38. package/dist/esm/lib/components/answer/loading-indicator.js +1 -29
  39. package/dist/esm/lib/components/answer/messages.js +1 -148
  40. package/dist/esm/lib/components/answer/no-citations.js +1 -29
  41. package/dist/esm/lib/components/answer/references.js +1 -2
  42. package/dist/esm/lib/components/answer/thumb-buttons.js +1 -2
  43. package/dist/esm/lib/components/api-wrapper/actions.js +1 -2
  44. package/dist/esm/lib/components/api-wrapper/api-wrapper.js +1 -8
  45. package/dist/esm/lib/components/api-wrapper/constants.js +1 -30
  46. package/dist/esm/lib/components/api-wrapper/content-answers-component.js +1 -83
  47. package/dist/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +1 -211
  48. package/dist/esm/lib/components/api-wrapper/records.js +1 -38
  49. package/dist/esm/lib/components/api-wrapper/reducer.js +1 -42
  50. package/dist/esm/lib/components/api-wrapper/utils/format.js +1 -13
  51. package/dist/esm/lib/components/api-wrapper/utils/request.js +1 -12
  52. package/dist/esm/lib/components/api-wrapper/utils/stream.js +2 -116
  53. package/dist/esm/lib/components/api-wrapper/utils/typed-record.js +1 -3
  54. package/dist/esm/lib/components/chat/chat.js +1 -2
  55. package/dist/esm/lib/components/chat/index.js +1 -2
  56. package/dist/esm/lib/components/common/agentUtils.js +1 -5
  57. package/dist/esm/lib/components/common/constants.js +1 -19
  58. package/dist/esm/lib/components/common/focusInputUtils.js +1 -5
  59. package/dist/esm/lib/components/common/inline-citation.js +1 -24
  60. package/dist/esm/lib/components/common/keyInputUtils.js +1 -3
  61. package/dist/esm/lib/components/common/markdown-react.js +1 -97
  62. package/dist/esm/lib/components/common/markdown.js +1 -2
  63. package/dist/esm/lib/components/common/media-container.js +1 -2
  64. package/dist/esm/lib/components/common/mock-data.js +1 -305
  65. package/dist/esm/lib/components/common/performance.js +1 -3
  66. package/dist/esm/lib/components/content/content.js +1 -2
  67. package/dist/esm/lib/components/content/index.js +1 -2
  68. package/dist/esm/lib/components/footer/constants.js +1 -12
  69. package/dist/esm/lib/components/footer/footer-actions.js +1 -2
  70. package/dist/esm/lib/components/footer/footer.js +1 -151
  71. package/dist/esm/lib/components/footer/index.js +1 -2
  72. package/dist/esm/lib/components/footer/messages.js +1 -36
  73. package/dist/esm/lib/components/footer/stopResponseButton.js +1 -2
  74. package/dist/esm/lib/components/modal/clear-conversation-button.js +1 -2
  75. package/dist/esm/lib/components/modal/hooks/useEventListeners.js +1 -10
  76. package/dist/esm/lib/components/modal/hooks/useStopPropagationOnEsc.js +1 -19
  77. package/dist/esm/lib/components/modal/messages.js +1 -20
  78. package/dist/esm/lib/components/modal/modal.js +1 -143
  79. package/dist/esm/lib/components/modal/title.js +1 -14
  80. package/dist/esm/lib/components/modal-error/index.js +1 -2
  81. package/dist/esm/lib/components/modal-error/messages.js +1 -16
  82. package/dist/esm/lib/components/modal-error/modal-error.js +1 -33
  83. package/dist/esm/lib/components/question/question.js +1 -2
  84. package/dist/esm/lib/components/sidebar/content.js +1 -2
  85. package/dist/esm/lib/components/sidebar/context.js +1 -16
  86. package/dist/esm/lib/components/sidebar/messages.js +1 -28
  87. package/dist/esm/lib/components/sidebar/sidebar.js +1 -80
  88. package/dist/esm/lib/components/sidebar/title.js +1 -14
  89. package/dist/esm/lib/components/suggested-questions/messages.js +1 -16
  90. package/dist/esm/lib/components/suggested-questions/mocks.js +1 -36
  91. package/dist/esm/lib/components/suggested-questions/suggested-questions.js +1 -2
  92. package/dist/esm/lib/components/suggested-questions/suggestions.js +1 -2
  93. package/dist/esm/lib/components/thinkingBubble/boxAILoadingIndicator.js +11 -277
  94. package/dist/esm/lib/components/thinkingBubble/messages.js +1 -24
  95. package/dist/esm/lib/components/thinkingBubble/thinkingBubble.js +1 -2
  96. package/dist/esm/lib/components/welcome-message/contextual-items-message.js +1 -2
  97. package/dist/esm/lib/components/welcome-message/items-dropdown.js +1 -2
  98. package/dist/esm/lib/components/welcome-message/messages.js +10 -52
  99. package/dist/esm/lib/components/welcome-message/unsupported-items-notice.js +1 -2
  100. package/dist/esm/lib/components/welcome-message/warning-message.js +1 -2
  101. package/dist/esm/lib/components/welcome-message/welcome-message.js +1 -53
  102. package/dist/esm/lib/constants.js +1 -9
  103. package/dist/esm/lib/hooks/usePromptFocus.js +1 -28
  104. package/dist/esm/lib/messages.js +1 -56
  105. package/dist/esm/lib/utils/constants.js +1 -2
  106. package/dist/esm/lib/utils/inlineCitationsUtils.js +1 -18
  107. package/package.json +11 -11
@@ -1,211 +1 @@
1
- import { a as e, r as t, t as n } from "../../../../../chunks/types.js";
2
- import { CLEAR_CONVERSATION_HISTORY as r, SET_ANSWER_FEEDBACK as i, SET_IS_LOADING as a, SET_MODAL_ERROR as o, SET_MODAL_SUCCESS as s, SET_NEW_ITEM as c, SET_SUGGESTED_QUESTIONS as l, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as u, UPDATE_QUESTION as d } from "../actions.js";
3
- import { QuestionRecord as f } from "../records.js";
4
- import { defaultFormatCitations as p, defaultFormatSuggestions as m } from "../utils/format.js";
5
- import h from "../utils/stream.js";
6
- import { getAnswerRequest as g } from "../utils/request.js";
7
- import _, { useCallback as v, useMemo as y } from "react";
8
- import { ACTIONS as b, useAgentsDispatch as x } from "@box/box-ai-agent-selector";
9
- import S from "lodash/camelCase";
10
- var ee = /Too Many Requests/i, C = "Agent not found";
11
- function w({ contentAnswers: w, createSessionRequest: T, dispatchStateUpdate: E, enterpriseId: D, fetchTimeout: O, formatCitations: k = p, getAnswerStreaming: A, getAnswer: j, getSuggestedQuestions: M, isStopResponseEnabled: N, isStreamingEnabled: P, itemID: F, items: I, onSuggestedQuestionsFetched: L, sendErrorLog: R, shouldPreinitSession: z = !0, userId: B }) {
12
- let V = _.useRef(null), H = x(), U = y(() => Array.isArray(I) && I.length > 1, [I]), W = v((e) => Array.isArray(e) ? k(e) : null, [k]);
13
- _.useEffect((e) => {
14
- F && F !== w.item.id && E({
15
- type: c,
16
- itemID: F,
17
- fileVersionID: e
18
- });
19
- }, [F]);
20
- let G = _.useCallback((e, t) => {
21
- E({
22
- type: d,
23
- newQuestion: e,
24
- session: t
25
- }), V.current = e;
26
- }, [E]), K = _.useCallback((e) => {
27
- E({
28
- type: o,
29
- error: e
30
- });
31
- }, [E]), q = _.useCallback((e, t, n) => {
32
- let { answer: r, thinkingAnswer: i, error: a, citations: o = [], createdAt: s = null, encodedSession: c = void 0, contextSession: l = void 0 } = e, u = t.set("citations", W(o)).merge({
33
- answer: r,
34
- thinkingAnswer: i,
35
- error: a,
36
- created_at: s,
37
- isLoading: !1,
38
- isCompleted: n
39
- }), d;
40
- c && (d = { encodedSession: c }), l && (d = { contextSession: l }), G(u, d);
41
- }, [G, W]), J = _.useCallback((e, t) => {
42
- let r = e?.message || "", i = e?.response?.status === 429 || ee.test(r), a = e?.code === C || e?.errorCode === C, o = e?.response?.status === 204, s = e?.response?.status === 412, c = o ? n.NO_CONTENT : i ? n.RATE_LIMITING : s ? n.PRECONDITION_FAILED : a ? n.AGENT_NOT_FOUND : n.GENERAL;
43
- G(t.merge({
44
- error: c,
45
- isLoading: !1,
46
- isCompleted: !0
47
- }), void 0);
48
- }, [G]), Y = _.useCallback(async (e, t) => {
49
- try {
50
- let n = {
51
- prompt: e.prompt,
52
- aiAgent: t || void 0,
53
- userId: B,
54
- enterpriseId: D
55
- }, r = `content-answers-${e.id}`, i;
56
- P && (i = h.createAbortRequest(r));
57
- let a = await g(n, P, r, F, I, w, j, A, i, O, R);
58
- P ? h.receiveStreamedResponse(r, a, (t) => {
59
- let { code: n, data: r, error: i, citations: o, contextSession: s, isCompleted: c, createdAt: l, thinkingAnswer: u } = t, d = {
60
- thinkingAnswer: u,
61
- answer: r,
62
- citations: o,
63
- error: i,
64
- contextSession: s,
65
- createdAt: l
66
- };
67
- a.ok && a.status === 200 ? q({ ...d }, e, c) : J({
68
- response: a,
69
- code: n
70
- }, e);
71
- }, void 0, O, R) : (Object.entries(a).forEach(([e, t]) => {
72
- let n = S(e);
73
- delete a[e], a[n] = t;
74
- }), q(a, e, !0));
75
- } catch (t) {
76
- N && t instanceof Error && t.name === "AbortError" ? G(e.set("error", []).merge({
77
- error: n.RESPONSE_STOPPED,
78
- isLoading: !1,
79
- isCompleted: !0
80
- })) : J(t, e);
81
- }
82
- }, [
83
- B,
84
- D,
85
- P,
86
- F,
87
- I,
88
- w,
89
- j,
90
- A,
91
- O,
92
- R,
93
- q,
94
- J,
95
- N,
96
- G
97
- ]), X = _.useCallback((e) => {
98
- let { encoded_session: t, metadata: { is_large_file: n } = { is_large_file: !1 } } = e;
99
- E({
100
- type: s,
101
- encodedSession: t,
102
- isLargeFile: n
103
- });
104
- }, [E]), Z = _.useCallback(async (e = !0, r = !0) => {
105
- try {
106
- e && E({
107
- type: a,
108
- isLoading: !0
109
- }), X(await T({ items: I }, F));
110
- } catch {
111
- r && K(t.GENERAL), z || (E({
112
- type: a,
113
- isLoading: !1
114
- }), V.current && G(V.current.set("error", n.GENERAL).merge({
115
- isLoading: !1,
116
- isCompleted: !0
117
- })));
118
- }
119
- }, [
120
- T,
121
- I,
122
- F,
123
- X,
124
- E,
125
- z,
126
- K,
127
- G
128
- ]), Q = _.useCallback((e, t, r = !0) => {
129
- let i = !w.isLoading && !w.encodedSession && !U && T, a = w?.questions || [];
130
- r && (e.id = `${a.length}`), !z && i && (e.error = n.GENERAL, e.isLoading = !1, e.isCompleted = !0);
131
- let o = new f(e);
132
- return G(o), z || w.encodedSession ? Y(o, t) : !w.isLoading && !z && T && Z(!0, !1), o;
133
- }, [
134
- w.encodedSession,
135
- w.isLoading,
136
- w?.questions,
137
- Z,
138
- T,
139
- U,
140
- Y,
141
- z,
142
- G
143
- ]), te = _.useCallback((e, t) => {
144
- E({
145
- type: i,
146
- questionId: e,
147
- feedbackValue: t
148
- });
149
- }, [E]), ne = _.useCallback(() => {
150
- E({ type: r });
151
- }, [E]), re = _.useCallback(async (e, t) => {
152
- Q({
153
- ...e.toJS(),
154
- answer: "",
155
- isLoading: !0,
156
- isCompleted: !1,
157
- error: null
158
- }, t, !1);
159
- }, [Q]), ie = _.useCallback((e) => {
160
- let t;
161
- e ? t = e.id : V.current && (t = V.current.id), t && h.abortRequest(`content-answers-${t}`, !0);
162
- }, []), ae = _.useCallback(async (e) => {
163
- e && H({
164
- type: b.SET_ASK_CONFIG,
165
- id: e.id,
166
- ask: e?.ask
167
- });
168
- }, [H]), [$, oe] = _.useState("");
169
- return _.useEffect(() => {
170
- if (!I || I.length === 0) return;
171
- let e = I.map((e) => e.id).join(",");
172
- e !== $ && oe(e);
173
- }, [I, $]), {
174
- clearConversation: ne,
175
- createSession: Z,
176
- fetchAgentConfig: ae,
177
- fetchSuggestedQuestions: _.useCallback(async () => {
178
- if (!(!$ || !M || U)) {
179
- E({
180
- type: u,
181
- requestState: e.IN_PROGRESS
182
- });
183
- try {
184
- let e = m(await M(F, I));
185
- L && L(e), E({
186
- type: l,
187
- suggestedQuestions: e
188
- });
189
- } catch {
190
- E({
191
- type: u,
192
- requestState: e.ERROR
193
- });
194
- }
195
- }
196
- }, [
197
- E,
198
- M,
199
- U,
200
- F,
201
- $
202
- ]),
203
- retryQuestion: re,
204
- sendQuestion: Q,
205
- sendQuestionAnswerRequest: Y,
206
- setAnswerFeedback: te,
207
- stopQuestion: ie,
208
- updateQuestionInState: G
209
- };
210
- }
211
- export { w as useContentAnswers };
1
+ import{a as REQUEST_STATE$1,r as CONTENT_ERROR,t as ANSWER_ERROR}from"../../../../../chunks/types.js";import{CLEAR_CONVERSATION_HISTORY,SET_ANSWER_FEEDBACK,SET_IS_LOADING,SET_MODAL_ERROR,SET_MODAL_SUCCESS,SET_NEW_ITEM,SET_SUGGESTED_QUESTIONS,SET_SUGGESTED_QUESTIONS_REQUEST_STATE,UPDATE_QUESTION}from"../actions.js";import{QuestionRecord}from"../records.js";import{defaultFormatCitations,defaultFormatSuggestions}from"../utils/format.js";import stream_default from"../utils/stream.js";import{getAnswerRequest}from"../utils/request.js";import React,{useCallback,useMemo}from"react";import{ACTIONS,useAgentsDispatch}from"@box/box-ai-agent-selector";import camelCase from"lodash/camelCase";var RATE_LIMIT_REGEX=/Too Many Requests/i,AGENT_ERROR_MESSAGE=`Agent not found`;function useContentAnswers({contentAnswers,createSessionRequest,dispatchStateUpdate,enterpriseId,fetchTimeout,formatCitations=defaultFormatCitations,getAnswerStreaming,getAnswer,getSuggestedQuestions,isStopResponseEnabled,isStreamingEnabled,itemID,items,onSuggestedQuestionsFetched,sendErrorLog,shouldPreinitSession=!0,userId}){let latestQuestionRef=React.useRef(null),dispatch=useAgentsDispatch(),isMultiDocMode=useMemo(()=>Array.isArray(items)&&items.length>1,[items]),handleFormatCitations=useCallback(citations=>Array.isArray(citations)?formatCitations(citations):null,[formatCitations]);React.useEffect(fileVersionID=>{itemID&&itemID!==contentAnswers.item.id&&dispatchStateUpdate({type:SET_NEW_ITEM,itemID,fileVersionID})},[itemID]);let updateQuestionInState=React.useCallback((newQuestion,session)=>{dispatchStateUpdate({type:UPDATE_QUESTION,newQuestion,session}),latestQuestionRef.current=newQuestion},[dispatchStateUpdate]),handleModalError=React.useCallback(error=>{dispatchStateUpdate({type:SET_MODAL_ERROR,error})},[dispatchStateUpdate]),handleQuestionAnswerSuccess=React.useCallback((result,question,isCompleted)=>{let{answer,thinkingAnswer,error,citations:rawCitations=[],createdAt=null,encodedSession=void 0,contextSession=void 0}=result,updatedQuestion=question.set(`citations`,handleFormatCitations(rawCitations)).merge({answer,thinkingAnswer,error,created_at:createdAt,isLoading:!1,isCompleted}),sessionObj;encodedSession&&(sessionObj={encodedSession}),contextSession&&(sessionObj={contextSession}),updateQuestionInState(updatedQuestion,sessionObj)},[updateQuestionInState,handleFormatCitations]),handleQuestionAnswerError=React.useCallback((error,question)=>{let errorMessage=error?.message||``,isRateLimitingError=error?.response?.status===429||RATE_LIMIT_REGEX.test(errorMessage),isAgentError=error?.code===AGENT_ERROR_MESSAGE||error?.errorCode===AGENT_ERROR_MESSAGE,isNoContentError=error?.response?.status===204,isPreconditionFailedError=error?.response?.status===412,errorCode=isNoContentError?ANSWER_ERROR.NO_CONTENT:isRateLimitingError?ANSWER_ERROR.RATE_LIMITING:isPreconditionFailedError?ANSWER_ERROR.PRECONDITION_FAILED:isAgentError?ANSWER_ERROR.AGENT_NOT_FOUND:ANSWER_ERROR.GENERAL;updateQuestionInState(question.merge({error:errorCode,isLoading:!1,isCompleted:!0}),void 0)},[updateQuestionInState]),sendQuestionAnswerRequest=React.useCallback(async(questionRecord,aiAgent)=>{try{let requestObject={prompt:questionRecord.prompt,aiAgent:aiAgent||void 0,userId,enterpriseId},questionID=`content-answers-${questionRecord.id}`,abortController;isStreamingEnabled&&(abortController=stream_default.createAbortRequest(questionID));let result=await getAnswerRequest(requestObject,isStreamingEnabled,questionID,itemID,items,contentAnswers,getAnswer,getAnswerStreaming,abortController,fetchTimeout,sendErrorLog);isStreamingEnabled?stream_default.receiveStreamedResponse(questionID,result,streamResult=>{let{code,data,error,citations,contextSession,isCompleted,createdAt,thinkingAnswer}=streamResult,updatedProps={thinkingAnswer,answer:data,citations,error,contextSession,createdAt};result.ok&&result.status===200?handleQuestionAnswerSuccess({...updatedProps},questionRecord,isCompleted):handleQuestionAnswerError({response:result,code},questionRecord)},void 0,fetchTimeout,sendErrorLog):(Object.entries(result).forEach(([key,value])=>{let updatedKey=camelCase(key);delete result[key],result[updatedKey]=value}),handleQuestionAnswerSuccess(result,questionRecord,!0))}catch(error){isStopResponseEnabled&&error instanceof Error&&error.name===`AbortError`?updateQuestionInState(questionRecord.set(`error`,[]).merge({error:ANSWER_ERROR.RESPONSE_STOPPED,isLoading:!1,isCompleted:!0})):handleQuestionAnswerError(error,questionRecord)}},[userId,enterpriseId,isStreamingEnabled,itemID,items,contentAnswers,getAnswer,getAnswerStreaming,fetchTimeout,sendErrorLog,handleQuestionAnswerSuccess,handleQuestionAnswerError,isStopResponseEnabled,updateQuestionInState]),handleCreateSessionSuccess=React.useCallback(createSessionResult=>{let{encoded_session:encodedSession,metadata:{is_large_file:isLargeFile}={is_large_file:!1}}=createSessionResult;dispatchStateUpdate({type:SET_MODAL_SUCCESS,encodedSession,isLargeFile})},[dispatchStateUpdate]),createSession=React.useCallback(async(shouldAddLoading=!0,shouldTriggerError=!0)=>{try{shouldAddLoading&&dispatchStateUpdate({type:SET_IS_LOADING,isLoading:!0}),handleCreateSessionSuccess(await createSessionRequest({items},itemID))}catch{shouldTriggerError&&handleModalError(CONTENT_ERROR.GENERAL),shouldPreinitSession||(dispatchStateUpdate({type:SET_IS_LOADING,isLoading:!1}),latestQuestionRef.current&&updateQuestionInState(latestQuestionRef.current.set(`error`,ANSWER_ERROR.GENERAL).merge({isLoading:!1,isCompleted:!0})))}},[createSessionRequest,items,itemID,handleCreateSessionSuccess,dispatchStateUpdate,shouldPreinitSession,handleModalError,updateQuestionInState]),sendQuestion=React.useCallback((question,aiAgent,shouldCreateQuestion=!0)=>{let didSessionFailToLoad=!contentAnswers.isLoading&&!contentAnswers.encodedSession&&!isMultiDocMode&&createSessionRequest,questionList=contentAnswers?.questions||[];shouldCreateQuestion&&(question.id=`${questionList.length}`),!shouldPreinitSession&&didSessionFailToLoad&&(question.error=ANSWER_ERROR.GENERAL,question.isLoading=!1,question.isCompleted=!0);let questionRecord=new QuestionRecord(question);return updateQuestionInState(questionRecord),shouldPreinitSession||contentAnswers.encodedSession?sendQuestionAnswerRequest(questionRecord,aiAgent):!contentAnswers.isLoading&&!shouldPreinitSession&&createSessionRequest&&createSession(!0,!1),questionRecord},[contentAnswers.encodedSession,contentAnswers.isLoading,contentAnswers?.questions,createSession,createSessionRequest,isMultiDocMode,sendQuestionAnswerRequest,shouldPreinitSession,updateQuestionInState]),setAnswerFeedback=React.useCallback((questionId,feedbackValue)=>{dispatchStateUpdate({type:SET_ANSWER_FEEDBACK,questionId,feedbackValue})},[dispatchStateUpdate]),clearConversation=React.useCallback(()=>{dispatchStateUpdate({type:CLEAR_CONVERSATION_HISTORY})},[dispatchStateUpdate]),retryQuestion=React.useCallback(async(question,aiAgent)=>{sendQuestion({...question.toJS(),answer:``,isLoading:!0,isCompleted:!1,error:null},aiAgent,!1)},[sendQuestion]),stopQuestion=React.useCallback(lastQuestion=>{let lastQuestionID;lastQuestion?lastQuestionID=lastQuestion.id:latestQuestionRef.current&&(lastQuestionID=latestQuestionRef.current.id),lastQuestionID&&stream_default.abortRequest(`content-answers-${lastQuestionID}`,!0)},[]),fetchAgentConfig=React.useCallback(async agent=>{agent&&dispatch({type:ACTIONS.SET_ASK_CONFIG,id:agent.id,ask:agent?.ask})},[dispatch]),[stableItemIDs,setStableItemIDs]=React.useState(``);return React.useEffect(()=>{if(!items||items.length===0)return;let newItemIds=items.map(item=>item.id).join(`,`);newItemIds!==stableItemIDs&&setStableItemIDs(newItemIds)},[items,stableItemIDs]),{clearConversation,createSession,fetchAgentConfig,fetchSuggestedQuestions:React.useCallback(async()=>{if(!(!stableItemIDs||!getSuggestedQuestions||isMultiDocMode)){dispatchStateUpdate({type:SET_SUGGESTED_QUESTIONS_REQUEST_STATE,requestState:REQUEST_STATE$1.IN_PROGRESS});try{let suggestedQuestions=defaultFormatSuggestions(await getSuggestedQuestions(itemID,items));onSuggestedQuestionsFetched&&onSuggestedQuestionsFetched(suggestedQuestions),dispatchStateUpdate({type:SET_SUGGESTED_QUESTIONS,suggestedQuestions})}catch{dispatchStateUpdate({type:SET_SUGGESTED_QUESTIONS_REQUEST_STATE,requestState:REQUEST_STATE$1.ERROR})}}},[dispatchStateUpdate,getSuggestedQuestions,isMultiDocMode,itemID,stableItemIDs]),retryQuestion,sendQuestion,sendQuestionAnswerRequest,setAnswerFeedback,stopQuestion,updateQuestionInState}}export{useContentAnswers};
@@ -1,38 +1 @@
1
- import { a as e, s as t } from "../../../../chunks/types.js";
2
- import { createTypedRecord as n } from "./utils/typed-record.js";
3
- var r = n({
4
- has_streamed_responses: !0,
5
- has_citations_enabled: !1,
6
- has_thinking_enabled: !1
7
- }), i = n({
8
- type: "file",
9
- id: null,
10
- version_id: null
11
- }), a = n({
12
- suggestions: [],
13
- requestState: e.NOT_STARTED
14
- }), o = n({
15
- config: new r(),
16
- encodedSession: null,
17
- contextSession: null,
18
- error: null,
19
- isLoading: !1,
20
- hasRequestInProgress: !1,
21
- item: new i(),
22
- questions: [],
23
- shouldShowLandingPage: !0,
24
- suggestedQuestions: new a()
25
- }), s = n({
26
- answer: null,
27
- citations: [],
28
- created_at: null,
29
- id: null,
30
- isCompleted: !1,
31
- thinkingAnswer: null,
32
- isLoading: !0,
33
- error: null,
34
- prompt: null,
35
- feedbackValue: "none",
36
- promptType: t
37
- });
38
- export { r as ContentAnswersConfigRecord, i as ContentAnswersItemRecord, o as ContentAnswersRecord, s as QuestionRecord, a as SuggestedQuestionsRecord };
1
+ import{a as REQUEST_STATE,s as USER_INPUT_PROMPT_TYPE}from"../../../../chunks/types.js";import{createTypedRecord}from"./utils/typed-record.js";var ContentAnswersConfigRecord=createTypedRecord({has_streamed_responses:!0,has_citations_enabled:!1,has_thinking_enabled:!1}),ContentAnswersItemRecord=createTypedRecord({type:`file`,id:null,version_id:null}),SuggestedQuestionsRecord=createTypedRecord({suggestions:[],requestState:REQUEST_STATE.NOT_STARTED}),ContentAnswersRecord=createTypedRecord({config:new ContentAnswersConfigRecord,encodedSession:null,contextSession:null,error:null,isLoading:!1,hasRequestInProgress:!1,item:new ContentAnswersItemRecord,questions:[],shouldShowLandingPage:!0,suggestedQuestions:new SuggestedQuestionsRecord}),QuestionRecord=createTypedRecord({answer:null,citations:[],created_at:null,id:null,isCompleted:!1,thinkingAnswer:null,isLoading:!0,error:null,prompt:null,feedbackValue:`none`,promptType:USER_INPUT_PROMPT_TYPE});export{ContentAnswersConfigRecord,ContentAnswersItemRecord,ContentAnswersRecord,QuestionRecord,SuggestedQuestionsRecord};
@@ -1,42 +1 @@
1
- import { a as e, r as t } from "../../../../chunks/types.js";
2
- import { CLEAR_CONVERSATION_HISTORY as n, SET_ANSWER_FEEDBACK as r, SET_IS_LOADING as i, SET_MODAL_ERROR as a, SET_MODAL_SUCCESS as o, SET_NEW_ITEM as s, SET_SUGGESTED_QUESTIONS as c, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as l, UPDATE_QUESTION as u } from "./actions.js";
3
- import { ContentAnswersItemRecord as d, ContentAnswersRecord as f } from "./records.js";
4
- var p = (p, m) => {
5
- switch (m.type) {
6
- case s: return new f({ item: new d({
7
- id: m.itemID,
8
- version_id: m.fileVersionID && m.fileVersionID.toString()
9
- }) });
10
- case i: return p.set("isLoading", m.isLoading);
11
- case n: {
12
- let { hasRequestInProgress: e } = p;
13
- return p.withMutations((t) => {
14
- t.set("shouldShowLandingPage", !e), t.set("questions", []), t.set("contextSession", null);
15
- });
16
- }
17
- case u: {
18
- let { questions: e } = p, { newQuestion: t, session: n } = m, r = [...e], i = e?.findIndex((e) => e.id === t.id) ?? -1;
19
- i >= 0 ? r[i] = t : r.push(t);
20
- let { isCompleted: a } = m.newQuestion;
21
- return p.withMutations((e) => {
22
- n && e.merge(n), e.set("hasRequestInProgress", !a), e.set("questions", r), e.set("shouldShowLandingPage", !1);
23
- });
24
- }
25
- case a: return p.set("error", m.error);
26
- case o: return p.withMutations((e) => {
27
- e.set("encodedSession", m.encodedSession), e.set("error", m.isLargeFile ? t.LARGE_FILE : null), e.set("isLoading", !1);
28
- });
29
- case l: return p.withMutations((e) => {
30
- e.setIn(["suggestedQuestions", "requestState"], m.requestState);
31
- });
32
- case c: return p.withMutations((t) => {
33
- t.setIn(["suggestedQuestions", "requestState"], e.SUCCESS), t.setIn(["suggestedQuestions", "suggestions"], m.suggestedQuestions);
34
- });
35
- case r: {
36
- let { questionId: e, feedbackValue: t } = m;
37
- return p.updateIn(["questions"], (n) => n.map((n) => n.get("id") === e ? n.set("feedbackValue", t) : n));
38
- }
39
- default: return p;
40
- }
41
- };
42
- export { p as default };
1
+ import{a as REQUEST_STATE,r as CONTENT_ERROR}from"../../../../chunks/types.js";import{CLEAR_CONVERSATION_HISTORY,SET_ANSWER_FEEDBACK,SET_IS_LOADING,SET_MODAL_ERROR,SET_MODAL_SUCCESS,SET_NEW_ITEM,SET_SUGGESTED_QUESTIONS,SET_SUGGESTED_QUESTIONS_REQUEST_STATE,UPDATE_QUESTION}from"./actions.js";import{ContentAnswersItemRecord,ContentAnswersRecord}from"./records.js";var contentAnswersReducer=(state,action)=>{switch(action.type){case SET_NEW_ITEM:return new ContentAnswersRecord({item:new ContentAnswersItemRecord({id:action.itemID,version_id:action.fileVersionID&&action.fileVersionID.toString()})});case SET_IS_LOADING:return state.set(`isLoading`,action.isLoading);case CLEAR_CONVERSATION_HISTORY:{let{hasRequestInProgress}=state;return state.withMutations(data=>{data.set(`shouldShowLandingPage`,!hasRequestInProgress),data.set(`questions`,[]),data.set(`contextSession`,null)})}case UPDATE_QUESTION:{let{questions}=state,{newQuestion,session}=action,updatedQuestions=[...questions],questionIndex=questions?.findIndex(q=>q.id===newQuestion.id)??-1;questionIndex>=0?updatedQuestions[questionIndex]=newQuestion:updatedQuestions.push(newQuestion);let{isCompleted}=action.newQuestion;return state.withMutations(data=>{session&&data.merge(session),data.set(`hasRequestInProgress`,!isCompleted),data.set(`questions`,updatedQuestions),data.set(`shouldShowLandingPage`,!1)})}case SET_MODAL_ERROR:return state.set(`error`,action.error);case SET_MODAL_SUCCESS:return state.withMutations(data=>{data.set(`encodedSession`,action.encodedSession),data.set(`error`,action.isLargeFile?CONTENT_ERROR.LARGE_FILE:null),data.set(`isLoading`,!1)});case SET_SUGGESTED_QUESTIONS_REQUEST_STATE:return state.withMutations(data=>{data.setIn([`suggestedQuestions`,`requestState`],action.requestState)});case SET_SUGGESTED_QUESTIONS:return state.withMutations(data=>{data.setIn([`suggestedQuestions`,`requestState`],REQUEST_STATE.SUCCESS),data.setIn([`suggestedQuestions`,`suggestions`],action.suggestedQuestions)});case SET_ANSWER_FEEDBACK:{let{questionId,feedbackValue}=action;return state.updateIn([`questions`],questions=>questions.map(question=>question.get(`id`)===questionId?question.set(`feedbackValue`,feedbackValue):question))}default:return state}};export{contentAnswersReducer as default};
@@ -1,13 +1 @@
1
- import { o as e } from "../../../../../chunks/types.js";
2
- var t = (e) => e.map((e) => ({
3
- content: e.cited_text_content,
4
- location: e.cited_text_location,
5
- title: e.cited_doc_name,
6
- fileId: e.cited_doc_id,
7
- source: e.cited_doc_source
8
- })), n = (t) => t.suggestedPrompts.map((t, n) => ({
9
- prompt: t,
10
- id: `suggestion-${n}`,
11
- type: e.INTELLIGENT
12
- }));
13
- export { t as defaultFormatCitations, n as defaultFormatSuggestions };
1
+ import{o as SUGGESTED_QUESTION_PROMPT_TYPE}from"../../../../../chunks/types.js";var defaultFormatCitations=citations=>citations.map(c=>({content:c.cited_text_content,location:c.cited_text_location,title:c.cited_doc_name,fileId:c.cited_doc_id,source:c.cited_doc_source})),defaultFormatSuggestions=suggestions=>suggestions.suggestedPrompts.map((prompt,index)=>({prompt,id:`suggestion-${index}`,type:SUGGESTED_QUESTION_PROMPT_TYPE.INTELLIGENT}));export{defaultFormatCitations,defaultFormatSuggestions};
@@ -1,12 +1 @@
1
- import e, { FETCH_TIMEOUT as t } from "./stream.js";
2
- var n = (t, n, r) => setTimeout(() => {
3
- e.abortRequest(t), r && r({
4
- eventType: "ai-client-initial-streaming-timeout-error",
5
- message: "Initial streaming timeout error",
6
- origin: "AIClientErrorLog"
7
- });
8
- }, n), r = async (e, r = !1, i, a, o, s, c, l, u, d, f) => {
9
- let p, m = n(i, d?.initial || t.initial, f);
10
- return r && l ? p = await l(e, a, o, u, s) : c && (p = await c(e, a, o, s)), clearTimeout(m), p;
11
- };
12
- export { r as getAnswerRequest };
1
+ import stream_default,{FETCH_TIMEOUT}from"./stream.js";var setInitialTimeout=(requestID,abortTimeout,sendErrorLog)=>setTimeout(()=>{stream_default.abortRequest(requestID),sendErrorLog&&sendErrorLog({eventType:`ai-client-initial-streaming-timeout-error`,message:`Initial streaming timeout error`,origin:`AIClientErrorLog`})},abortTimeout),getAnswerRequest=async(payload,isStreamingRequest=!1,requestID,itemID,items,state,fetcher,fetcherStreaming,abortController,fetchTimeout,sendErrorLog)=>{let response,initialTimeout=setInitialTimeout(requestID,fetchTimeout?.initial||FETCH_TIMEOUT.initial,sendErrorLog);return isStreamingRequest&&fetcherStreaming?response=await fetcherStreaming(payload,itemID,items,abortController,state):fetcher&&(response=await fetcher(payload,itemID,items,state)),clearTimeout(initialTimeout),response};export{getAnswerRequest};
@@ -1,116 +1,2 @@
1
- import { t as e } from "../../../../../chunks/types.js";
2
- import t from "lodash/camelCase";
3
- var n = {
4
- chunk: 15 * 1e3,
5
- initial: 45 * 1e3
6
- }, r = {
7
- RESPONSE_FAILED: e.RESPONSE_FAILED,
8
- RESPONSE_INTERRUPTED: e.RESPONSE_INTERRUPTED,
9
- RESPONSE_STOPPED: e.RESPONSE_STOPPED
10
- }, i = {
11
- CONTINUE: "continue",
12
- DONE: "done",
13
- ERROR: "error"
14
- }, a = new class {
15
- abortControllerMap = /* @__PURE__ */ new Map();
16
- chunkTimeout = n.chunk;
17
- abortRequest(e, t = !1) {
18
- let n = this.abortControllerMap.get(e);
19
- n && (n.isAbortFunctionCalled = !0, n.isUserInitiatedAbort = t, this.abortControllerMap.set(e, n), n.abortController.abort());
20
- }
21
- createAbortRequest(e) {
22
- let t = {
23
- abortController: new AbortController(),
24
- isAbortFunctionCalled: !1,
25
- isUserInitiatedAbort: !1
26
- };
27
- return this.abortControllerMap.set(e, t), t.abortController;
28
- }
29
- handleCompleteLine(e, t) {
30
- let n = e.trim();
31
- n && t.push(n);
32
- }
33
- tryParsePartialLine(e, t, n) {
34
- if (t || !e.trim().endsWith("}")) return e;
35
- let r = e.trim();
36
- try {
37
- return JSON.parse(r), n.push(r), "";
38
- } catch {
39
- return e;
40
- }
41
- }
42
- parseChunk(e, t) {
43
- let n = "", r = !1, i = !1;
44
- for (let a of e) i ? (n += a, i = !1) : a === "\\" ? (n += a, i = !0) : a === "\"" ? (n += a, r = !r) : (a === "\n" || a === "\r") && !r ? (this.handleCompleteLine(n, t), n = "") : n += a;
45
- return this.tryParsePartialLine(n, r, t);
46
- }
47
- parseNDJSON(e, n, r) {
48
- let i = new TextDecoder().decode(n), a = e.partialData + i, o = [];
49
- e.partialData = this.parseChunk(a, o);
50
- let s = "";
51
- o.forEach((n) => {
52
- try {
53
- let i = JSON.parse(n);
54
- i[r] && (s += i[r]), i.thinking_answer && (e.thinkingAnswer ||= "", e.thinkingAnswer += i.thinking_answer), Object.entries(i).forEach(([n, i]) => {
55
- let a = t(n);
56
- a !== r && a !== "thinkingAnswer" && (e[a] = i);
57
- });
58
- } catch (e) {
59
- console.error("Failed to parse NDJSON line:", e);
60
- }
61
- }), e.data += s;
62
- }
63
- receiveStreamedResponse(e, t, r, i = "answer", a, o) {
64
- let s = this.initializeStreamedResponseState(), c = t.body?.getReader();
65
- if (this.chunkTimeout = a?.chunk || n.chunk, !c) {
66
- this.handleNoResponseBody(r, s);
67
- return;
68
- }
69
- let l, u = () => {
70
- c.read().then((t) => {
71
- this.handleChunkSuccess(l, r, t, e, s, i), t.done || (l = this.setChunkTimeout(e, o), u());
72
- }).catch((t) => {
73
- this.handleChunkError(l, r, e, s);
74
- });
75
- };
76
- u();
77
- }
78
- initializeStreamedResponseState() {
79
- return {
80
- completionReason: null,
81
- contextSession: null,
82
- data: "",
83
- error: null,
84
- isAborted: !1,
85
- isCompleted: !1,
86
- partialData: ""
87
- };
88
- }
89
- handleChunkSuccess(t, n, a, o, s, c) {
90
- if (!a) return;
91
- clearTimeout(t);
92
- let { completionReason: l } = s;
93
- s.isCompleted = a.done || l !== null, a.value && this.parseNDJSON(s, a.value, c), s.isCompleted && (this.removeAbortController(o), l !== i.DONE && (s.data ? s.error = l === i.CONTINUE ? r.RESPONSE_INTERRUPTED : r.RESPONSE_FAILED : s.error = e.NO_CONTENT)), n(s);
94
- }
95
- handleChunkError(e, t, n, i) {
96
- i.error = r.RESPONSE_FAILED;
97
- let a = this.abortControllerMap.get(n);
98
- a && a.isUserInitiatedAbort && (i.error = r.RESPONSE_STOPPED, i.isAborted = a.isUserInitiatedAbort), i.isCompleted = !0, this.removeAbortController(n), clearTimeout(e), t(i);
99
- }
100
- handleNoResponseBody(t, n) {
101
- n.error = e.NO_CONTENT, n.isCompleted = !0, t(n);
102
- }
103
- removeAbortController(e) {
104
- this.abortControllerMap.delete(e);
105
- }
106
- setChunkTimeout(e, t) {
107
- return setTimeout(() => {
108
- this.abortRequest(e), t && t({
109
- eventType: "ai-client-chunk-streaming-timeout-error",
110
- message: "Chunk streaming timeout error",
111
- origin: "AIClientErrorLog"
112
- });
113
- }, this.chunkTimeout);
114
- }
115
- }();
116
- export { n as FETCH_TIMEOUT, i as STREAMING_COMPLETION_REASON, r as STREAM_ERROR, a as default };
1
+ import{t as ANSWER_ERROR}from"../../../../../chunks/types.js";import camelCase from"lodash/camelCase";var FETCH_TIMEOUT={chunk:15*1e3,initial:45*1e3},STREAM_ERROR={RESPONSE_FAILED:ANSWER_ERROR.RESPONSE_FAILED,RESPONSE_INTERRUPTED:ANSWER_ERROR.RESPONSE_INTERRUPTED,RESPONSE_STOPPED:ANSWER_ERROR.RESPONSE_STOPPED},STREAMING_COMPLETION_REASON={CONTINUE:`continue`,DONE:`done`,ERROR:`error`},stream_default=new class{abortControllerMap=new Map;chunkTimeout=FETCH_TIMEOUT.chunk;abortRequest(requestID,userAborted=!1){let abort=this.abortControllerMap.get(requestID);abort&&(abort.isAbortFunctionCalled=!0,abort.isUserInitiatedAbort=userAborted,this.abortControllerMap.set(requestID,abort),abort.abortController.abort())}createAbortRequest(requestID){let abort={abortController:new AbortController,isAbortFunctionCalled:!1,isUserInitiatedAbort:!1};return this.abortControllerMap.set(requestID,abort),abort.abortController}handleCompleteLine(currentLine,lines){let trimmed=currentLine.trim();trimmed&&lines.push(trimmed)}tryParsePartialLine(currentLine,insideString,lines){if(insideString||!currentLine.trim().endsWith(`}`))return currentLine;let trimmed=currentLine.trim();try{return JSON.parse(trimmed),lines.push(trimmed),``}catch{return currentLine}}parseChunk(rawNDJSON,lines){let currentLine=``,insideString=!1,escapeNext=!1;for(let char of rawNDJSON)escapeNext?(currentLine+=char,escapeNext=!1):char===`\\`?(currentLine+=char,escapeNext=!0):char===`"`?(currentLine+=char,insideString=!insideString):(char===`
2
+ `||char===`\r`)&&!insideString?(this.handleCompleteLine(currentLine,lines),currentLine=``):currentLine+=char;return this.tryParsePartialLine(currentLine,insideString,lines)}parseNDJSON(responseState,rawChunk,streamingProperty){let chunk=new TextDecoder().decode(rawChunk),rawNDJSON=responseState.partialData+chunk,lines=[];responseState.partialData=this.parseChunk(rawNDJSON,lines);let dataChunk=``;lines.forEach(line=>{try{let object=JSON.parse(line);object[streamingProperty]&&(dataChunk+=object[streamingProperty]),object.thinking_answer&&(responseState.thinkingAnswer||=``,responseState.thinkingAnswer+=object.thinking_answer),Object.entries(object).forEach(([key,value])=>{let updatedKey=camelCase(key);updatedKey!==streamingProperty&&updatedKey!==`thinkingAnswer`&&(responseState[updatedKey]=value)})}catch(error){console.error(`Failed to parse NDJSON line:`,error)}}),responseState.data+=dataChunk}receiveStreamedResponse(requestID,response,onStreamResponse,streamingProperty=`answer`,fetchTimeout,sendErrorLog){let streamedResponseState=this.initializeStreamedResponseState(),reader=response.body?.getReader();if(this.chunkTimeout=fetchTimeout?.chunk||FETCH_TIMEOUT.chunk,!reader){this.handleNoResponseBody(onStreamResponse,streamedResponseState);return}let chunkTimeoutId,readNextChunk=()=>{reader.read().then(result=>{this.handleChunkSuccess(chunkTimeoutId,onStreamResponse,result,requestID,streamedResponseState,streamingProperty),result.done||(chunkTimeoutId=this.setChunkTimeout(requestID,sendErrorLog),readNextChunk())}).catch(err=>{this.handleChunkError(chunkTimeoutId,onStreamResponse,requestID,streamedResponseState)})};readNextChunk()}initializeStreamedResponseState(){return{completionReason:null,contextSession:null,data:``,error:null,isAborted:!1,isCompleted:!1,partialData:``}}handleChunkSuccess(chunkTimeoutId,onStreamResponse,result,requestID,streamedResponseState,streamingProperty){if(!result)return;clearTimeout(chunkTimeoutId);let{completionReason}=streamedResponseState;streamedResponseState.isCompleted=result.done||completionReason!==null,result.value&&this.parseNDJSON(streamedResponseState,result.value,streamingProperty),streamedResponseState.isCompleted&&(this.removeAbortController(requestID),completionReason!==STREAMING_COMPLETION_REASON.DONE&&(streamedResponseState.data?streamedResponseState.error=completionReason===STREAMING_COMPLETION_REASON.CONTINUE?STREAM_ERROR.RESPONSE_INTERRUPTED:STREAM_ERROR.RESPONSE_FAILED:streamedResponseState.error=ANSWER_ERROR.NO_CONTENT)),onStreamResponse(streamedResponseState)}handleChunkError(chunkTimeoutId,onStreamResponse,requestID,streamedResponseState){streamedResponseState.error=STREAM_ERROR.RESPONSE_FAILED;let abort=this.abortControllerMap.get(requestID);abort&&abort.isUserInitiatedAbort&&(streamedResponseState.error=STREAM_ERROR.RESPONSE_STOPPED,streamedResponseState.isAborted=abort.isUserInitiatedAbort),streamedResponseState.isCompleted=!0,this.removeAbortController(requestID),clearTimeout(chunkTimeoutId),onStreamResponse(streamedResponseState)}handleNoResponseBody(onStreamResponse,streamedResponseState){streamedResponseState.error=ANSWER_ERROR.NO_CONTENT,streamedResponseState.isCompleted=!0,onStreamResponse(streamedResponseState)}removeAbortController(requestID){this.abortControllerMap.delete(requestID)}setChunkTimeout(requestID,sendErrorLog){return setTimeout(()=>{this.abortRequest(requestID),sendErrorLog&&sendErrorLog({eventType:`ai-client-chunk-streaming-timeout-error`,message:`Chunk streaming timeout error`,origin:`AIClientErrorLog`})},this.chunkTimeout)}};export{FETCH_TIMEOUT,STREAMING_COMPLETION_REASON,STREAM_ERROR,stream_default as default};
@@ -1,3 +1 @@
1
- import { Record as e } from "immutable";
2
- var t = (t) => e(t);
3
- export { t as createTypedRecord };
1
+ import{Record}from"immutable";var createTypedRecord=defaults=>Record(defaults);export{createTypedRecord};
@@ -1,2 +1 @@
1
- import { t as e } from "../../../../chunks/chat.js";
2
- export { e as Chat, e as default };
1
+ import{t as Chat}from"../../../../chunks/chat.js";export{Chat,Chat as default};
@@ -1,2 +1 @@
1
- import { t as e } from "../../../../chunks/chat.js";
2
- export { e as Chat };
1
+ import{t as Chat}from"../../../../chunks/chat.js";export{Chat};
@@ -1,5 +1 @@
1
- var e = (e, t) => {
2
- let n;
3
- return e && (n = t ? { id: t.id } : void 0), n;
4
- };
5
- export { e as getAIAgentConfig };
1
+ var getAIAgentConfig=(isAIStudioAgentSelectorEnabled,aiStudioSelectedAgent)=>{let aiAgent;return isAIStudioAgentSelectorEnabled&&(aiAgent=aiStudioSelectedAgent?{id:aiStudioSelectedAgent.id}:void 0),aiAgent};export{getAIAgentConfig};
@@ -1,19 +1 @@
1
- var e = "modal", t = "answers", n = "programmatic", r = "click", i = "keypress", a = {
2
- action: n,
3
- component: e,
4
- feature: t
5
- }, o = "data_ready", s = "component_initialized", c = "js_ready", l = [
6
- "xls",
7
- "xlsx",
8
- "csv",
9
- "tsv"
10
- ], u = [
11
- "xls",
12
- "xlsx",
13
- "xlsm",
14
- "xlsb",
15
- "csv",
16
- "ods",
17
- "gsheet"
18
- ], d = "boxai_sidebar";
19
- export { o as EVENT_DATA_READY, s as EVENT_INITIALIZED, c as EVENT_JS_READY, l as INTELLIGENT_QUERY_COMPATIBLE_SPREADSHEET_EXTENSIONS, r as LOGGER_ACTION_CLICK, i as LOGGER_ACTION_KEYPRESS, n as LOGGER_ACTION_PROGRAMMATIC, a as LOGGER_BASE_CONFIG, e as LOGGER_COMPONENT, t as LOGGER_FEATURE, d as ORIGIN_BOXAI_SIDEBAR, u as SPREADSHEET_FILE_EXTENSIONS };
1
+ var LOGGER_COMPONENT=`modal`,LOGGER_FEATURE=`answers`,LOGGER_ACTION_PROGRAMMATIC=`programmatic`,LOGGER_ACTION_CLICK=`click`,LOGGER_ACTION_KEYPRESS=`keypress`,LOGGER_BASE_CONFIG={action:LOGGER_ACTION_PROGRAMMATIC,component:LOGGER_COMPONENT,feature:LOGGER_FEATURE},EVENT_DATA_READY=`data_ready`,EVENT_INITIALIZED=`component_initialized`,EVENT_JS_READY=`js_ready`,INTELLIGENT_QUERY_COMPATIBLE_SPREADSHEET_EXTENSIONS=[`xls`,`xlsx`,`csv`,`tsv`],SPREADSHEET_FILE_EXTENSIONS=[`xls`,`xlsx`,`xlsm`,`xlsb`,`csv`,`ods`,`gsheet`],ORIGIN_BOXAI_SIDEBAR=`boxai_sidebar`;export{EVENT_DATA_READY,EVENT_INITIALIZED,EVENT_JS_READY,INTELLIGENT_QUERY_COMPATIBLE_SPREADSHEET_EXTENSIONS,LOGGER_ACTION_CLICK,LOGGER_ACTION_KEYPRESS,LOGGER_ACTION_PROGRAMMATIC,LOGGER_BASE_CONFIG,LOGGER_COMPONENT,LOGGER_FEATURE,ORIGIN_BOXAI_SIDEBAR,SPREADSHEET_FILE_EXTENSIONS};
@@ -1,5 +1 @@
1
- import { INPUT_TARGET_ID as e } from "../footer/constants.js";
2
- function t() {
3
- document.querySelector(`[data-target-id="${e}"]`)?.focus();
4
- }
5
- export { t as focusInput };
1
+ import{INPUT_TARGET_ID}from"../footer/constants.js";function focusInput(){document.querySelector(`[data-target-id="${INPUT_TARGET_ID}"]`)?.focus()}export{focusInput};
@@ -1,24 +1 @@
1
- import e from "../answer/messages.js";
2
- import { isBoxDomain as t } from "../../utils/inlineCitationsUtils.js";
3
- import { t as n } from "../../../../chunks/markdown.module.js";
4
- import { useCallback as r, useMemo as i } from "react";
5
- import { Link as a, Tooltip as o } from "@box/blueprint-web";
6
- import { useIntl as s } from "react-intl";
7
- import { jsx as c } from "react/jsx-runtime";
8
- var l = ({ fileName: l, href: u, isInlineCitationV2Enabled: d = !1 }) => {
9
- let { formatMessage: f } = s(), p = r(() => {
10
- window.open(u, "_blank", "noopener,noreferrer");
11
- }, [u]);
12
- return i(() => t(u), [u]) ? /* @__PURE__ */ c(o, {
13
- content: l,
14
- children: /* @__PURE__ */ c(a, {
15
- "aria-label": f(e.inlineCitationAriaLabel, { fileName: l }),
16
- className: d ? n.inlineCitation : n.inlineCitationWrapper,
17
- href: u,
18
- onClick: p,
19
- "data-target-id": "Link-inlineCitationAriaLabel",
20
- children: l
21
- })
22
- }) : /* @__PURE__ */ c("span", { children: l });
23
- };
24
- export { l as default };
1
+ import messages from"../answer/messages.js";import{isBoxDomain}from"../../utils/inlineCitationsUtils.js";import{t as markdown_module_default}from"../../../../chunks/markdown.module.js";import{useCallback,useMemo}from"react";import{Link,Tooltip}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx}from"react/jsx-runtime";var InlineCitation=({fileName,href,isInlineCitationV2Enabled=!1})=>{let{formatMessage}=useIntl(),handleClick=useCallback(()=>{window.open(href,`_blank`,`noopener,noreferrer`)},[href]);return useMemo(()=>isBoxDomain(href),[href])?jsx(Tooltip,{content:fileName,children:jsx(Link,{"aria-label":formatMessage(messages.inlineCitationAriaLabel,{fileName}),className:isInlineCitationV2Enabled?markdown_module_default.inlineCitation:markdown_module_default.inlineCitationWrapper,href,onClick:handleClick,"data-target-id":`Link-inlineCitationAriaLabel`,children:fileName})}):jsx(`span`,{children:fileName})};export{InlineCitation as default};
@@ -1,3 +1 @@
1
- import { KEY_CODE as e } from "../footer/constants.js";
2
- var t = (t) => t.ctrlKey && t.shiftKey && (t.keyCode === e.X || t.keyCode === e.X_LOWERCASE), n = (t) => t.keyCode === e.ENTER && t.shiftKey === !1;
3
- export { t as isDebugModeTrigger, n as isEnterTrigger };
1
+ import{KEY_CODE}from"../footer/constants.js";var isDebugModeTrigger=event=>event.ctrlKey&&event.shiftKey&&(event.keyCode===KEY_CODE.X||event.keyCode===KEY_CODE.X_LOWERCASE),isEnterTrigger=event=>event.keyCode===KEY_CODE.ENTER&&event.shiftKey===!1;export{isDebugModeTrigger,isEnterTrigger};