intellinum-chatbot 1.0.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,980 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ var __async = (__this, __arguments, generator) => {
33
+ return new Promise((resolve, reject) => {
34
+ var fulfilled = (value) => {
35
+ try {
36
+ step(generator.next(value));
37
+ } catch (e) {
38
+ reject(e);
39
+ }
40
+ };
41
+ var rejected = (value) => {
42
+ try {
43
+ step(generator.throw(value));
44
+ } catch (e) {
45
+ reject(e);
46
+ }
47
+ };
48
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
+ step((generator = generator.apply(__this, __arguments)).next());
50
+ });
51
+ };
52
+
53
+ // src/organisms/IntellinumChat.tsx
54
+ import { jsx } from "react/jsx-runtime";
55
+ var IntellinumChat = (props) => {
56
+ return /* @__PURE__ */ jsx("div", { children: "IntellinumChat" });
57
+ };
58
+ var IntellinumChat_default = IntellinumChat;
59
+
60
+ // src/molecules/ChatSender.tsx
61
+ import { useRef, useState as useState2 } from "react";
62
+
63
+ // src/assets/icons/SendIcon.tsx
64
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
65
+ var SendIcon = (props) => {
66
+ return /* @__PURE__ */ jsxs(
67
+ "svg",
68
+ {
69
+ width: "20",
70
+ height: "20",
71
+ viewBox: "0 0 20 20",
72
+ fill: "none",
73
+ xmlns: "http://www.w3.org/2000/svg",
74
+ children: [
75
+ /* @__PURE__ */ jsx2("g", { clipPath: "url(#clip0_1096_2365)", children: /* @__PURE__ */ jsx2(
76
+ "path",
77
+ {
78
+ d: "M1.60252 7.80845C1.17752 7.63761 1.18252 7.38345 1.63085 7.23428L17.5358 1.93261C17.9767 1.78595 18.2292 2.03262 18.1059 2.46428L13.5608 18.3693C13.4358 18.8101 13.165 18.8301 12.9633 18.4276L9.16668 10.8334L1.60252 7.80845ZM5.67752 7.64178L10.3742 9.52095L12.9075 14.5893L15.8625 4.24762L5.67668 7.64178H5.67752Z",
79
+ fill: "#FBFBFD"
80
+ }
81
+ ) }),
82
+ /* @__PURE__ */ jsx2("defs", { children: /* @__PURE__ */ jsx2("clipPath", { id: "clip0_1096_2365", children: /* @__PURE__ */ jsx2("rect", { width: "20", height: "20", fill: "white" }) }) })
83
+ ]
84
+ }
85
+ );
86
+ };
87
+ var SendIcon_default = SendIcon;
88
+
89
+ // src/providers/ChatProvider.tsx
90
+ import React, { useEffect, useState } from "react";
91
+
92
+ // src/utils/api.tsx
93
+ import axios from "axios";
94
+ var handleGenerateToken = (PROXY_URL, ORACLE_TOKEN_URL, ORACLE_CLIENT_ID, ORACLE_CLIENT_SECRET, ORACLE_SCOPE) => __async(null, null, function* () {
95
+ try {
96
+ const res = yield axios.post(PROXY_URL, {
97
+ url: ORACLE_TOKEN_URL,
98
+ payload: {
99
+ grant_type: "client_credentials",
100
+ client_id: ORACLE_CLIENT_ID,
101
+ client_secret: ORACLE_CLIENT_SECRET,
102
+ scope: ORACLE_SCOPE
103
+ },
104
+ config: {
105
+ headers: {
106
+ "Content-Type": "application/x-www-form-urlencoded"
107
+ }
108
+ }
109
+ });
110
+ localStorage.setItem("intellinum-chatbot-token", res.data.access_token);
111
+ } catch (error) {
112
+ }
113
+ });
114
+ var handleCreateApi = (PROXY_URL, ORACLE_TOKEN_URL, ORACLE_CLIENT_ID, ORACLE_CLIENT_SECRET, ORACLE_SCOPE) => {
115
+ const apiRequest = axios.create({
116
+ baseURL: PROXY_URL
117
+ });
118
+ apiRequest.interceptors.request.use(
119
+ (config) => {
120
+ const token = localStorage.getItem("intellinum-chatbot-token");
121
+ if (token) {
122
+ if (config.method == "post") {
123
+ config.data = __spreadProps(__spreadValues({}, config.data), {
124
+ config: {
125
+ headers: {
126
+ Authorization: `Bearer ${token}`
127
+ }
128
+ }
129
+ });
130
+ } else if (config.method == "get") {
131
+ config.params = __spreadProps(__spreadValues({}, config.params), {
132
+ auth: `Bearer ${token}`
133
+ });
134
+ }
135
+ }
136
+ return config;
137
+ },
138
+ (error) => {
139
+ return Promise.reject(error);
140
+ }
141
+ );
142
+ apiRequest.interceptors.response.use(
143
+ (response) => {
144
+ return response;
145
+ },
146
+ (error) => __async(null, null, function* () {
147
+ let originalConfig = error.config;
148
+ if (error.response.status === 401 && !originalConfig._retry) {
149
+ yield handleGenerateToken(
150
+ PROXY_URL,
151
+ ORACLE_TOKEN_URL,
152
+ ORACLE_CLIENT_ID,
153
+ ORACLE_CLIENT_SECRET,
154
+ ORACLE_SCOPE
155
+ );
156
+ if (originalConfig.method == "post") {
157
+ try {
158
+ originalConfig.data = JSON.parse(originalConfig.data);
159
+ } catch (error2) {
160
+ }
161
+ }
162
+ return apiRequest.request(originalConfig);
163
+ }
164
+ })
165
+ );
166
+ const handlePost = (url, payload, config) => {
167
+ const res = apiRequest.post("/", {
168
+ url,
169
+ payload,
170
+ config
171
+ });
172
+ return res;
173
+ };
174
+ const handleGet = (url) => {
175
+ const res = apiRequest.get("/?url=" + url);
176
+ return res;
177
+ };
178
+ return {
179
+ post: handlePost,
180
+ get: handleGet
181
+ };
182
+ };
183
+ var API = {
184
+ create: handleCreateApi
185
+ };
186
+ var api_default = API;
187
+
188
+ // src/providers/ChatProvider.tsx
189
+ import { jsx as jsx3 } from "react/jsx-runtime";
190
+ var ChatContext = React.createContext(null);
191
+ function ChatProvider(props) {
192
+ const {
193
+ ORACLE_TOKEN_URL,
194
+ ORACLE_BASE_URL,
195
+ ORACLE_CLIENT_ID,
196
+ ORACLE_CLIENT_SECRET,
197
+ ORACLE_SCOPE,
198
+ PROXY_URL,
199
+ WORKFLOW_CODE
200
+ } = props;
201
+ const ApiReq = api_default.create(
202
+ PROXY_URL,
203
+ ORACLE_TOKEN_URL,
204
+ ORACLE_CLIENT_ID,
205
+ ORACLE_CLIENT_SECRET,
206
+ ORACLE_SCOPE
207
+ );
208
+ const [chatHistories, setChatHistories] = useState([]);
209
+ const [chats, setChats] = useState([]);
210
+ const [isLoading, setIsLoading] = useState(true);
211
+ const [isLoadingResponse, setIsLoadingResponse] = useState(false);
212
+ const [disallowChattingMessage, setDisallowChattingMessage] = useState("");
213
+ const handleNewChat = () => __async(null, null, function* () {
214
+ });
215
+ const handleSendChat = (message) => __async(null, null, function* () {
216
+ var _a;
217
+ setIsLoadingResponse(true);
218
+ try {
219
+ const res = yield ApiReq.post(
220
+ `${ORACLE_BASE_URL}/${WORKFLOW_CODE}/invokeAsync`,
221
+ {
222
+ message,
223
+ conversational: true,
224
+ invocationMode: "ADMIN",
225
+ conversationId: ((_a = chats[chats.length - 1]) == null ? void 0 : _a.jobId) || ""
226
+ }
227
+ );
228
+ setChats((prev) => [...prev, res.data]);
229
+ const jobId = res.data.jobId;
230
+ let jobStatus = res.data.status;
231
+ while (jobStatus === "RUNNING") {
232
+ const resCheck = yield ApiReq.get(
233
+ `${ORACLE_BASE_URL}/${WORKFLOW_CODE}/status/${jobId}?invocationMode=ADMIN`
234
+ );
235
+ jobStatus = resCheck.data.status;
236
+ setChats((prev) => {
237
+ return prev.map((chat) => {
238
+ if (chat.jobId === jobId) {
239
+ return resCheck.data;
240
+ }
241
+ return chat;
242
+ });
243
+ });
244
+ if (resCheck.data.status == "RUNNING") {
245
+ yield new Promise((resolve) => setTimeout(resolve, 2e3));
246
+ }
247
+ if (resCheck.data.status !== "RUNNING" && resCheck.data.status !== "COMPLETE") {
248
+ setChats((prev) => {
249
+ return prev.map((chat) => {
250
+ if (chat.jobId === jobId) {
251
+ return __spreadProps(__spreadValues({}, resCheck.data), {
252
+ output: "Something went wrong"
253
+ });
254
+ }
255
+ return chat;
256
+ });
257
+ });
258
+ }
259
+ }
260
+ } catch (error) {
261
+ console.log("errpr", error);
262
+ }
263
+ setIsLoadingResponse(false);
264
+ });
265
+ const handleResponseChat = () => __async(null, null, function* () {
266
+ });
267
+ const handleChangeTopic = () => __async(null, null, function* () {
268
+ });
269
+ const handleAttachFile = () => __async(null, null, function* () {
270
+ });
271
+ const handleDeleteChat = () => __async(null, null, function* () {
272
+ });
273
+ const handleGetHistoryChat = () => __async(null, null, function* () {
274
+ });
275
+ useEffect(() => {
276
+ }, []);
277
+ return /* @__PURE__ */ jsx3(
278
+ ChatContext.Provider,
279
+ {
280
+ value: {
281
+ chatHistories,
282
+ setChatHistories,
283
+ chats,
284
+ setChats,
285
+ isLoading,
286
+ setIsLoading,
287
+ isLoadingResponse,
288
+ setIsLoadingResponse,
289
+ disallowChattingMessage,
290
+ setDisallowChattingMessage,
291
+ handleNewChat,
292
+ handleSendChat,
293
+ handleResponseChat,
294
+ handleChangeTopic,
295
+ handleAttachFile,
296
+ handleDeleteChat,
297
+ handleGetHistoryChat
298
+ },
299
+ children: props.children
300
+ }
301
+ );
302
+ }
303
+ var useChat = () => React.useContext(ChatContext);
304
+ var ChatProvider_default = ChatProvider;
305
+
306
+ // src/atoms/CustomLoading/index.tsx
307
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
308
+ function CustomLoading({ size = "12px" }) {
309
+ return /* @__PURE__ */ jsxs2("div", { className: "typing-dots", children: [
310
+ /* @__PURE__ */ jsx4("span", { style: { width: size, height: size } }),
311
+ /* @__PURE__ */ jsx4("span", { style: { width: size, height: size } }),
312
+ /* @__PURE__ */ jsx4("span", { style: { width: size, height: size } })
313
+ ] });
314
+ }
315
+ var CustomLoading_default = CustomLoading;
316
+
317
+ // src/molecules/ChatSender.tsx
318
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
319
+ var ChatSender = (props) => {
320
+ const textareaRef = useRef(null);
321
+ const { handleSendChat, isLoadingResponse } = useChat();
322
+ const [message, setMessage] = useState2("");
323
+ const handleInput = () => {
324
+ const el = textareaRef.current;
325
+ if (!el) return;
326
+ el.style.height = "auto";
327
+ if (!el.value) {
328
+ el.style.height = "40px";
329
+ el.style.overflowY = "hidden";
330
+ return;
331
+ }
332
+ if (el.scrollHeight > 200) {
333
+ el.style.height = "200px";
334
+ el.style.overflowY = "auto";
335
+ } else {
336
+ el.style.height = `${el.scrollHeight}px`;
337
+ el.style.overflowY = "hidden";
338
+ }
339
+ };
340
+ const sendChat = () => __async(null, null, function* () {
341
+ if (message.length > 0 && !isLoadingResponse) {
342
+ setMessage("");
343
+ setTimeout(() => {
344
+ handleInput();
345
+ }, 0);
346
+ yield handleSendChat(message);
347
+ }
348
+ });
349
+ return /* @__PURE__ */ jsxs3(
350
+ "div",
351
+ {
352
+ className: `ic-pt-4 ic-pb-2 ic-px-4 ic-w-full ic-max-w-2xl ic-bg-white ic-rounded-md ic-border ic-border-gray-200 ic-flex ic-items-start ic-justify-between ic-gap-3`,
353
+ children: [
354
+ /* @__PURE__ */ jsx5("div", { className: "ic-w-full ", children: /* @__PURE__ */ jsx5(
355
+ "textarea",
356
+ {
357
+ ref: textareaRef,
358
+ placeholder: "Ask anything",
359
+ value: message,
360
+ rows: 1,
361
+ onInput: handleInput,
362
+ className: `w-full ic-text-sm ic-py-2 ic-w-full ic-px-3 focus:ic-outline-none ic-rounded-md ic-border
363
+ ic-border-gray-300 ic-overflow-auto
364
+
365
+ `,
366
+ onChange: (e) => {
367
+ setMessage(e.target.value);
368
+ },
369
+ onKeyDown: (e) => {
370
+ if (e.key === "Enter") {
371
+ if (e.shiftKey || isLoadingResponse) return;
372
+ e.preventDefault();
373
+ sendChat();
374
+ }
375
+ }
376
+ }
377
+ ) }),
378
+ isLoadingResponse ? /* @__PURE__ */ jsx5("div", { className: "ic-mt-4", children: /* @__PURE__ */ jsx5(CustomLoading_default, { size: "8px" }) }) : /* @__PURE__ */ jsx5(
379
+ "div",
380
+ {
381
+ className: `${message.length < 1 || isLoadingResponse ? "ic-bg-gray-400" : "ic-bg-primary-500"} ic-mt-1 ic-shrink-0 ic-grow-0 ic-w-9 ic-h-9 ic-rounded-md ic-flex ic-justify-center ic-items-center ic-border ic-border-gray-300`,
382
+ onClick: () => {
383
+ sendChat();
384
+ },
385
+ children: /* @__PURE__ */ jsx5(SendIcon_default, {})
386
+ }
387
+ )
388
+ ]
389
+ }
390
+ );
391
+ };
392
+ var ChatSender_default = ChatSender;
393
+
394
+ // src/molecules/ChatHistory.tsx
395
+ import { useMemo, useState as useState4 } from "react";
396
+
397
+ // src/assets/icons/MenuFoldLineIcon.tsx
398
+ import { Fragment, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
399
+ var MenuFoldLineIcon = (props) => {
400
+ return /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsxs4(
401
+ "svg",
402
+ {
403
+ width: "20",
404
+ height: "20",
405
+ viewBox: "0 0 20 20",
406
+ fill: "none",
407
+ xmlns: "http://www.w3.org/2000/svg",
408
+ children: [
409
+ /* @__PURE__ */ jsx6("g", { clipPath: "url(#clip0_1081_1936)", children: /* @__PURE__ */ jsx6(
410
+ "path",
411
+ {
412
+ d: "M17.4993 15.0001V16.6668H2.49935V15.0001H17.4993ZM5.49602 3.25342L6.67435 4.43175L4.02268 7.08342L6.67435 9.73509L5.49602 10.9134L1.66602 7.08342L5.49602 3.25342ZM17.4993 9.16675V10.8334H9.99935V9.16675H17.4993ZM17.4993 3.33342V5.00008H9.99935V3.33342H17.4993Z",
413
+ fill: "#21305F"
414
+ }
415
+ ) }),
416
+ /* @__PURE__ */ jsx6("defs", { children: /* @__PURE__ */ jsx6("clipPath", { id: "clip0_1081_1936", children: /* @__PURE__ */ jsx6("rect", { width: "20", height: "20", fill: "white" }) }) })
417
+ ]
418
+ }
419
+ ) });
420
+ };
421
+ var MenuFoldLineIcon_default = MenuFoldLineIcon;
422
+
423
+ // src/utils/TwMerge.tsx
424
+ import { clsx } from "clsx";
425
+ import { twMerge } from "tailwind-merge";
426
+ function cn(...inputs) {
427
+ return twMerge(clsx(inputs));
428
+ }
429
+
430
+ // src/atoms/InputForm.tsx
431
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
432
+ var InputForm = (props) => {
433
+ const _a = props, { rightIcon } = _a, rest = __objRest(_a, ["rightIcon"]);
434
+ return /* @__PURE__ */ jsxs5(
435
+ "div",
436
+ {
437
+ className: `ic-border ic-border-gray-300 ic-w-full ic-rounded-md ic-flex ic-items-center
438
+ focus-within:ic-border-dark-primary-500 focus-within:ic-border-2
439
+
440
+ `,
441
+ children: [
442
+ /* @__PURE__ */ jsx7(
443
+ "input",
444
+ __spreadProps(__spreadValues({}, rest), {
445
+ className: `ic-py-2 ic-w-full ic-px-3 focus:ic-outline-none
446
+ ${cn({ "ic-pr-3 ic-border-r ic-border-gray-300": props.rightIcon })}
447
+ ${cn({ "ic-rounded-r-md": !props.rightIcon })}
448
+ `
449
+ })
450
+ ),
451
+ props.rightIcon && /* @__PURE__ */ jsx7("div", { className: "ic-py-2 ic-px-3 ic-pl-2", children: props.rightIcon })
452
+ ]
453
+ }
454
+ );
455
+ };
456
+ var InputForm_default = InputForm;
457
+
458
+ // src/assets/icons/SearchIcon.tsx
459
+ import { jsx as jsx8 } from "react/jsx-runtime";
460
+ var SearchIcon = (props) => {
461
+ return /* @__PURE__ */ jsx8(
462
+ "svg",
463
+ {
464
+ width: "17",
465
+ height: "17",
466
+ viewBox: "0 0 17 17",
467
+ fill: "none",
468
+ xmlns: "http://www.w3.org/2000/svg",
469
+ children: /* @__PURE__ */ jsx8(
470
+ "path",
471
+ {
472
+ d: "M16.0232 14.9163L10.806 9.69911C11.6156 8.65246 12.0536 7.37277 12.0536 6.02679C12.0536 4.41563 11.4248 2.90491 10.2877 1.76585C9.15067 0.626786 7.63594 0 6.02679 0C4.41763 0 2.9029 0.628795 1.76585 1.76585C0.626786 2.9029 0 4.41563 0 6.02679C0 7.63594 0.628795 9.15067 1.76585 10.2877C2.9029 11.4268 4.41563 12.0536 6.02679 12.0536C7.37277 12.0536 8.65045 11.6156 9.6971 10.808L14.9143 16.0232C14.9296 16.0385 14.9477 16.0507 14.9677 16.0589C14.9877 16.0672 15.0092 16.0715 15.0308 16.0715C15.0524 16.0715 15.0739 16.0672 15.0939 16.0589C15.1139 16.0507 15.132 16.0385 15.1473 16.0232L16.0232 15.1493C16.0385 15.134 16.0507 15.1159 16.0589 15.0959C16.0672 15.0759 16.0715 15.0545 16.0715 15.0328C16.0715 15.0112 16.0672 14.9897 16.0589 14.9697C16.0507 14.9498 16.0385 14.9316 16.0232 14.9163ZM9.20893 9.20893C8.35714 10.0587 7.22813 10.5268 6.02679 10.5268C4.82545 10.5268 3.69643 10.0587 2.84464 9.20893C1.99487 8.35714 1.52679 7.22813 1.52679 6.02679C1.52679 4.82545 1.99487 3.69442 2.84464 2.84464C3.69643 1.99487 4.82545 1.52679 6.02679 1.52679C7.22813 1.52679 8.35915 1.99286 9.20893 2.84464C10.0587 3.69643 10.5268 4.82545 10.5268 6.02679C10.5268 7.22813 10.0587 8.35915 9.20893 9.20893Z",
473
+ fill: "black",
474
+ fillOpacity: "0.45"
475
+ }
476
+ )
477
+ }
478
+ );
479
+ };
480
+ var SearchIcon_default = SearchIcon;
481
+
482
+ // src/atoms/ChatAction.tsx
483
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
484
+
485
+ // src/assets/icons/MessageIcon.tsx
486
+ import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
487
+ var MessageIcon = (props) => {
488
+ return /* @__PURE__ */ jsxs6(
489
+ "svg",
490
+ {
491
+ width: "20",
492
+ height: "20",
493
+ viewBox: "0 0 20 20",
494
+ fill: "none",
495
+ xmlns: "http://www.w3.org/2000/svg",
496
+ children: [
497
+ /* @__PURE__ */ jsxs6("g", { clipPath: "url(#clip0_1092_4826)", children: [
498
+ /* @__PURE__ */ jsx9(
499
+ "path",
500
+ {
501
+ d: "M11.3619 7.9687C10.8463 7.9687 10.4468 8.36825 10.4468 8.86156C10.4468 9.35486 10.8463 9.75441 11.3619 9.75441C11.8329 9.75441 12.2325 9.35486 12.2325 8.86156C12.2325 8.36825 11.8329 7.9687 11.3619 7.9687ZM5.11194 7.9687C4.59631 7.9687 4.19676 8.36825 4.19676 8.86156C4.19676 9.35486 4.59631 9.75441 5.11194 9.75441C5.58292 9.75441 5.98247 9.35486 5.98247 8.86156C5.98247 8.36825 5.58292 7.9687 5.11194 7.9687Z",
502
+ fill: `${props.color || "#5F79C8"}`
503
+ }
504
+ ),
505
+ /* @__PURE__ */ jsx9(
506
+ "path",
507
+ {
508
+ d: "M18.5265 6.27053C17.4938 4.84897 16.0046 3.8247 14.3077 3.36874V3.37098C13.926 2.94687 13.4952 2.55624 13.0131 2.20803C9.35908 -0.44822 4.22961 0.362048 1.5622 4.01607C-0.587352 6.98482 -0.495834 10.9781 1.69613 13.8152L1.71399 16.775C1.71399 16.8464 1.72515 16.9179 1.74747 16.9848C1.77555 17.0743 1.82098 17.1573 1.88118 17.2292C1.94138 17.301 2.01515 17.3603 2.09829 17.4037C2.18142 17.447 2.27229 17.4735 2.36568 17.4817C2.45907 17.4899 2.55316 17.4795 2.64256 17.4513L5.46845 16.5607C6.21622 16.8263 6.98854 16.9781 7.7564 17.0205L7.74524 17.0295C9.73408 18.4781 12.3412 18.9134 14.7318 18.1232L17.5689 19.0473C17.6403 19.0696 17.714 19.083 17.7899 19.083C18.185 19.083 18.5042 18.7638 18.5042 18.3687V15.3777C20.4707 12.708 20.522 9.0183 18.5265 6.27053ZM5.78095 14.9759L5.5131 14.8643L3.30327 15.5562L3.28095 13.2348L3.10238 13.0339C1.21399 10.7304 1.08899 7.41115 2.85685 4.97589C5.00863 2.02499 9.13363 1.37321 12.0756 3.50267C15.0265 5.64776 15.6805 9.76607 13.5488 12.6991C11.7609 15.1522 8.55997 16.0585 5.78095 14.9759ZM17.0533 14.5964L16.8747 14.8196L16.897 17.1411L14.7095 16.4045L14.4417 16.5161C13.1917 16.9804 11.8591 17.0183 10.6247 16.6723L10.6202 16.6701C12.3167 16.1498 13.7987 15.0932 14.8435 13.6589C16.5488 11.3085 16.8256 8.35535 15.8345 5.83749L15.8479 5.84642C16.3613 6.21473 16.8323 6.67455 17.2318 7.23035C18.8524 9.45356 18.7609 12.4804 17.0533 14.5964Z",
509
+ fill: `${props.color || "#5F79C8"}`
510
+ }
511
+ ),
512
+ /* @__PURE__ */ jsx9(
513
+ "path",
514
+ {
515
+ d: "M8.23694 7.9687C7.72131 7.9687 7.32176 8.36825 7.32176 8.86156C7.32176 9.35486 7.72131 9.75441 8.23694 9.75441C8.70792 9.75441 9.10747 9.35486 9.10747 8.86156C9.10747 8.36825 8.70792 7.9687 8.23694 7.9687Z",
516
+ fill: `${props.color || "#5F79C8"}`
517
+ }
518
+ )
519
+ ] }),
520
+ /* @__PURE__ */ jsx9("defs", { children: /* @__PURE__ */ jsx9("clipPath", { id: "clip0_1092_4826", children: /* @__PURE__ */ jsx9("rect", { width: "20", height: "20", fill: "white" }) }) })
521
+ ]
522
+ }
523
+ );
524
+ };
525
+ var MessageIcon_default = MessageIcon;
526
+
527
+ // src/assets/icons/EditIcon.tsx
528
+ import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
529
+ var EditIcon = (props) => {
530
+ return /* @__PURE__ */ jsxs7(
531
+ "svg",
532
+ {
533
+ width: "16",
534
+ height: "16",
535
+ viewBox: "0 0 16 16",
536
+ fill: "none",
537
+ xmlns: "http://www.w3.org/2000/svg",
538
+ children: [
539
+ /* @__PURE__ */ jsx10("g", { clipPath: "url(#clip0_1096_2009)", children: /* @__PURE__ */ jsx10(
540
+ "path",
541
+ {
542
+ d: "M3.45921 12.284C3.49492 12.284 3.53064 12.2805 3.56635 12.2751L6.56992 11.7483C6.60564 11.7412 6.63957 11.7251 6.66457 11.6983L14.2342 4.12868C14.2508 4.11216 14.2639 4.09254 14.2729 4.07094C14.2818 4.04934 14.2864 4.02618 14.2864 4.00279C14.2864 3.9794 14.2818 3.95625 14.2729 3.93464C14.2639 3.91304 14.2508 3.89342 14.2342 3.8769L11.2664 0.907254C11.2324 0.873326 11.1878 0.855469 11.1396 0.855469C11.0914 0.855469 11.0467 0.873326 11.0128 0.907254L3.44314 8.4769C3.41635 8.50368 3.40028 8.53583 3.39314 8.57154L2.86635 11.5751C2.84898 11.6708 2.85519 11.7692 2.88443 11.862C2.91368 11.9547 2.96509 12.0389 3.03421 12.1073C3.15207 12.2215 3.30028 12.284 3.45921 12.284ZM4.66278 9.16975L11.1396 2.69475L12.4485 4.00368L5.97171 10.4787L4.38421 10.759L4.66278 9.16975ZM14.5717 13.784H1.42885C1.11278 13.784 0.857422 14.0394 0.857422 14.3555V14.9983C0.857422 15.0769 0.921708 15.1412 1.00028 15.1412H15.0003C15.0789 15.1412 15.1431 15.0769 15.1431 14.9983V14.3555C15.1431 14.0394 14.8878 13.784 14.5717 13.784Z",
543
+ fill: "#16203F"
544
+ }
545
+ ) }),
546
+ /* @__PURE__ */ jsx10("defs", { children: /* @__PURE__ */ jsx10("clipPath", { id: "clip0_1096_2009", children: /* @__PURE__ */ jsx10("rect", { width: "16", height: "16", fill: "white" }) }) })
547
+ ]
548
+ }
549
+ );
550
+ };
551
+ var EditIcon_default = EditIcon;
552
+
553
+ // src/assets/icons/DeleteIcon.tsx
554
+ import { jsx as jsx11 } from "react/jsx-runtime";
555
+ var DeleteIcon = (props) => {
556
+ return /* @__PURE__ */ jsx11(
557
+ "svg",
558
+ {
559
+ width: "16",
560
+ height: "16",
561
+ viewBox: "0 0 16 16",
562
+ fill: "none",
563
+ xmlns: "http://www.w3.org/2000/svg",
564
+ children: /* @__PURE__ */ jsx11(
565
+ "path",
566
+ {
567
+ d: "M5.28544 2.14118H5.14258C5.22115 2.14118 5.28544 2.0769 5.28544 1.99833V2.14118H10.714V1.99833C10.714 2.0769 10.7783 2.14118 10.8569 2.14118H10.714V3.4269H11.9997V1.99833C11.9997 1.36797 11.4872 0.855469 10.8569 0.855469H5.14258C4.51222 0.855469 3.99972 1.36797 3.99972 1.99833V3.4269H5.28544V2.14118ZM14.2854 3.4269H1.71401C1.39794 3.4269 1.14258 3.68225 1.14258 3.99833V4.56975C1.14258 4.64833 1.20686 4.71261 1.28544 4.71261H2.36401L2.80508 14.0519C2.83365 14.6608 3.33722 15.1412 3.94615 15.1412H12.0533C12.664 15.1412 13.1658 14.6626 13.1944 14.0519L13.6354 4.71261H14.714C14.7926 4.71261 14.8569 4.64833 14.8569 4.56975V3.99833C14.8569 3.68225 14.6015 3.4269 14.2854 3.4269ZM11.9158 13.8555H4.08365L3.65151 4.71261H12.3479L11.9158 13.8555Z",
568
+ fill: "#FF4D4F"
569
+ }
570
+ )
571
+ }
572
+ );
573
+ };
574
+ var DeleteIcon_default = DeleteIcon;
575
+
576
+ // src/atoms/ChatAction.tsx
577
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
578
+ var ChatAction = (props) => {
579
+ const { id, title, onEdit, onDelete, activeId, onActiveChange } = props;
580
+ const [open, setOpen] = useState3(0);
581
+ const actionRef = useRef2(null);
582
+ const dotRef = useRef2(null);
583
+ useEffect2(() => {
584
+ function handleClickOutside(event) {
585
+ var _a, _b;
586
+ if (actionRef.current && !((_a = actionRef.current) == null ? void 0 : _a.contains(event.target)) && dotRef.current && !((_b = dotRef.current) == null ? void 0 : _b.contains(event.target)) && open == 0) {
587
+ setOpen(0);
588
+ }
589
+ }
590
+ document.addEventListener("mousedown", handleClickOutside);
591
+ return () => {
592
+ document.removeEventListener("mousedown", handleClickOutside);
593
+ };
594
+ }, []);
595
+ return /* @__PURE__ */ jsxs8("div", { className: "ic-w-full ic-relative", children: [
596
+ /* @__PURE__ */ jsx12(
597
+ "div",
598
+ {
599
+ className: `ic-w-full clickable hover:ic-bg-dark-primary-100 hover:ic-font-bold ic-px-2 ic-rounded-md
600
+ ${activeId == id ? "ic-bg-dark-primary-100 ic-font-bold " : ""}
601
+ `,
602
+ onClick: (e) => {
603
+ onActiveChange(id);
604
+ },
605
+ children: /* @__PURE__ */ jsxs8("div", { className: "ic-flex ic-justify-between hover:font-bold hover:ic-text-dark-primary-500 ic-w-full ic-py-2 ic-gap-2 ic-items-center", children: [
606
+ /* @__PURE__ */ jsxs8("div", { className: "ic-flex ic-text-center ic-w-full ic-gap-2 ic-items-center ic-truncate", children: [
607
+ /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsx12(
608
+ MessageIcon_default,
609
+ {
610
+ color: `${activeId == id ? "#20305f" : "#737373"} `
611
+ }
612
+ ) }),
613
+ /* @__PURE__ */ jsx12(
614
+ "p",
615
+ {
616
+ className: ` ic-text-sm ic-truncate
617
+ ${activeId == id ? "ic-text-dark-primary-500" : ""}
618
+ `,
619
+ children: title
620
+ }
621
+ )
622
+ ] }),
623
+ /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsx12(
624
+ "p",
625
+ {
626
+ ref: dotRef,
627
+ className: "\r\n ic-select-none\r\n ic-flex ic-justify-center ic-items-center ic-w-10\r\n ic-font-bold ic-rounded-md\r\n ic-pb-2 clickable hover:ic-bg-slate-200 \r\n ",
628
+ onClick: () => {
629
+ setOpen(id == open ? 0 : id);
630
+ },
631
+ children: "..."
632
+ }
633
+ ) })
634
+ ] })
635
+ }
636
+ ),
637
+ open === id && /* @__PURE__ */ jsxs8(
638
+ "div",
639
+ {
640
+ className: "ic-absolute ic-z-40 ic-top-10 ic-right-2 ic-p-2 ic-bg-white ic-shadow-md",
641
+ ref: actionRef,
642
+ onMouseEnter: (e) => {
643
+ e.preventDefault();
644
+ },
645
+ children: [
646
+ /* @__PURE__ */ jsxs8(
647
+ "div",
648
+ {
649
+ className: "ic-p-2 ic-flex ic-text-center ic-gap-2 clickable hover:ic-bg-slate-200",
650
+ onClick: () => {
651
+ onEdit(id);
652
+ },
653
+ children: [
654
+ /* @__PURE__ */ jsx12(EditIcon_default, {}),
655
+ /* @__PURE__ */ jsx12("p", { className: "ic-text-sm ic-font-bold", children: "Edit" })
656
+ ]
657
+ }
658
+ ),
659
+ /* @__PURE__ */ jsxs8(
660
+ "div",
661
+ {
662
+ className: "ic-p-2 ic-flex ic-text-center ic-gap-2 clickable hover:ic-bg-slate-200 ",
663
+ onClick: () => {
664
+ onDelete(id);
665
+ },
666
+ children: [
667
+ /* @__PURE__ */ jsx12(DeleteIcon_default, {}),
668
+ /* @__PURE__ */ jsx12("p", { className: "ic-text-sm ic-font-bold ic-text-red-500 ", children: "Delete" })
669
+ ]
670
+ }
671
+ )
672
+ ]
673
+ }
674
+ )
675
+ ] });
676
+ };
677
+ var ChatAction_default = ChatAction;
678
+
679
+ // src/molecules/ChatHistory.tsx
680
+ import _ from "lodash";
681
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
682
+ var ChatHistory = (props) => {
683
+ const { data } = props;
684
+ const [activeId, setActiveId] = useState4(0);
685
+ const [isWide, setIsWide] = useState4(true);
686
+ const groupedData = useMemo(() => {
687
+ const now = /* @__PURE__ */ new Date();
688
+ const grouped = _.groupBy(data, (item) => {
689
+ const d = new Date(item.date);
690
+ const isSameMonth = d.getMonth() === now.getMonth() && d.getFullYear() === now.getFullYear();
691
+ if (isSameMonth) return "This month";
692
+ return d.toLocaleString("en-US", { month: "short" });
693
+ });
694
+ return Object.entries(grouped).map(([key, value]) => ({
695
+ date: key,
696
+ data: value
697
+ }));
698
+ }, [data]);
699
+ return /* @__PURE__ */ jsxs9(
700
+ "div",
701
+ {
702
+ className: `
703
+ ic-transition-all ic-duration-300
704
+ ${isWide ? "ic-max-w-screen-lg" : "ic-max-w-12"}
705
+ ic-w-full `,
706
+ children: [
707
+ /* @__PURE__ */ jsxs9("div", { className: " ic-sticky ic-top-0 ic-bg-white ic-py-2 ic-z-20", children: [
708
+ /* @__PURE__ */ jsxs9(
709
+ "div",
710
+ {
711
+ className: `ic-flex ic-justify-between ic-w-full
712
+ ${cn({ "ic-flex-col ic-gap-4": !isWide })}
713
+ `,
714
+ children: [
715
+ /* @__PURE__ */ jsx13(
716
+ "div",
717
+ {
718
+ className: `clickable
719
+ ${!isWide && "ic-transform ic-scale-x-[-1]"}
720
+ `,
721
+ onClick: () => {
722
+ setIsWide(!isWide);
723
+ },
724
+ children: /* @__PURE__ */ jsx13(MenuFoldLineIcon_default, {})
725
+ }
726
+ ),
727
+ !isWide && /* @__PURE__ */ jsx13("div", { className: "clickable ic-rounded-sm ic-p-1 ic-mt-5 hover:ic-bg-dark-primary-300", children: /* @__PURE__ */ jsx13(EditIcon_default, {}) }),
728
+ isWide && /* @__PURE__ */ jsx13("div", { className: "clickable", children: "New Chat" }),
729
+ /* @__PURE__ */ jsx13("div", { className: "clickable ic-rounded-sm ic-p-1 hover:ic-bg-dark-primary-300" })
730
+ ]
731
+ }
732
+ ),
733
+ isWide && /* @__PURE__ */ jsx13("div", { className: "ic-mt-7 ic-w-full", children: /* @__PURE__ */ jsx13(
734
+ InputForm_default,
735
+ {
736
+ type: "text",
737
+ name: "keyword",
738
+ placeholder: "Search history",
739
+ autoCorrect: "off",
740
+ autoCapitalize: "off",
741
+ spellCheck: "false",
742
+ rightIcon: /* @__PURE__ */ jsx13(SearchIcon_default, {})
743
+ }
744
+ ) })
745
+ ] }),
746
+ isWide && /* @__PURE__ */ jsx13(Fragment2, { children: groupedData.map(
747
+ (r, i) => {
748
+ return /* @__PURE__ */ jsxs9("div", { className: "ic-mt-5", children: [
749
+ /* @__PURE__ */ jsx13("p", { className: "ic-font-bold ic-text-sm", children: r.date }),
750
+ /* @__PURE__ */ jsx13("div", { className: "ic-px-2", children: r.data.map((item, index) => /* @__PURE__ */ jsx13(
751
+ ChatAction_default,
752
+ {
753
+ title: item.title,
754
+ id: item.id,
755
+ activeId,
756
+ onEdit: (id) => {
757
+ },
758
+ onDelete: (id) => {
759
+ },
760
+ onActiveChange: (id) => {
761
+ setActiveId(id);
762
+ }
763
+ },
764
+ `chat-action-${item.id}-${index}`
765
+ )) })
766
+ ] }, `chat-history-${r.date}-${i}`);
767
+ }
768
+ ) })
769
+ ]
770
+ }
771
+ );
772
+ };
773
+ var ChatHistory_default = ChatHistory;
774
+
775
+ // src/atoms/SuggestionChat.tsx
776
+ import { jsx as jsx14 } from "react/jsx-runtime";
777
+ var SuggestionChat = (props) => {
778
+ return /* @__PURE__ */ jsx14("div", { children: "SuggestionChat" });
779
+ };
780
+ var SuggestionChat_default = SuggestionChat;
781
+
782
+ // src/molecules/Chatting.tsx
783
+ import { useEffect as useEffect3, useRef as useRef3, useState as useState5 } from "react";
784
+
785
+ // src/assets/icons/FlexaIcon.tsx
786
+ import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
787
+ var FlexaIcon = (props) => {
788
+ const { w, h } = props;
789
+ return /* @__PURE__ */ jsx15(Fragment3, { children: /* @__PURE__ */ jsxs10(
790
+ "svg",
791
+ {
792
+ width: w || 40,
793
+ height: h || 40,
794
+ viewBox: "0 0 40 40",
795
+ fill: "none",
796
+ xmlns: "http://www.w3.org/2000/svg",
797
+ children: [
798
+ /* @__PURE__ */ jsx15(
799
+ "path",
800
+ {
801
+ d: "M3.8513 8.02435C5.0388 5.44935 7.53255 3.3806 10.445 3.27435C15.295 3.0306 20.1638 3.14935 25.02 3.3431C22.8638 4.94935 20.5388 6.91185 20.1638 9.74935C19.7013 13.1244 19.9763 16.5494 19.97 19.9494C15.5638 20.0306 10.6825 19.1244 6.7138 21.5181C3.3513 23.5869 3.0263 27.9494 3.38255 31.4994C2.89505 25.8994 3.34505 20.2806 3.15755 14.6744C3.20755 12.4556 2.9388 10.1119 3.8513 8.02435Z",
802
+ fill: "#24315E"
803
+ }
804
+ ),
805
+ /* @__PURE__ */ jsx15(
806
+ "path",
807
+ {
808
+ d: "M25.02 3.343C28.1325 2.87425 31.8013 2.993 34.1388 5.41175C38.2263 9.1555 37.1888 17.0617 31.945 19.2367C28.1263 20.6492 23.945 20.0117 19.97 19.9492C19.9763 16.5492 19.7013 13.1242 20.1638 9.74925C20.5388 6.91175 22.8638 4.94925 25.02 3.343Z",
809
+ fill: "#F37C21"
810
+ }
811
+ ),
812
+ /* @__PURE__ */ jsx15(
813
+ "path",
814
+ {
815
+ d: "M6.71366 21.518C10.6824 19.1243 15.5637 20.0305 19.9699 19.9493C19.9637 23.6805 20.4199 27.5118 19.4012 31.1618C18.3949 34.7118 14.7887 37.243 11.0949 36.9243C7.65741 36.9493 4.91991 34.3493 3.38241 31.4993C2.66357 28.1118 3.35116 23.5868 6.71366 21.518Z",
816
+ fill: "#189DD8"
817
+ }
818
+ )
819
+ ]
820
+ }
821
+ ) });
822
+ };
823
+ var FlexaIcon_default = FlexaIcon;
824
+
825
+ // src/assets/icons/ClockIcon.tsx
826
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
827
+ var ClockIcon = (props) => {
828
+ return /* @__PURE__ */ jsxs11(
829
+ "svg",
830
+ {
831
+ width: "12",
832
+ height: "12",
833
+ viewBox: "0 0 12 12",
834
+ fill: "none",
835
+ xmlns: "http://www.w3.org/2000/svg",
836
+ children: [
837
+ /* @__PURE__ */ jsxs11("g", { clipPath: "url(#clip0_1096_17248)", children: [
838
+ /* @__PURE__ */ jsx16(
839
+ "path",
840
+ {
841
+ d: "M6 0C2.68661 0 0 2.68661 0 6C0 9.31339 2.68661 12 6 12C9.31339 12 12 9.31339 12 6C12 2.68661 9.31339 0 6 0ZM6 10.9821C3.24911 10.9821 1.01786 8.75089 1.01786 6C1.01786 3.24911 3.24911 1.01786 6 1.01786C8.75089 1.01786 10.9821 3.24911 10.9821 6C10.9821 8.75089 8.75089 10.9821 6 10.9821Z",
842
+ fill: "#8C8C8C"
843
+ }
844
+ ),
845
+ /* @__PURE__ */ jsx16(
846
+ "path",
847
+ {
848
+ d: "M8.33984 7.69428L6.43002 6.31348V2.99874C6.43002 2.93982 6.3818 2.8916 6.32287 2.8916H5.67868C5.61975 2.8916 5.57153 2.93982 5.57153 2.99874V6.68714C5.57153 6.72196 5.5876 6.7541 5.61573 6.77419L7.83091 8.38937C7.87912 8.42419 7.94609 8.41348 7.98091 8.3666L8.36394 7.84428C8.39877 7.79473 8.38805 7.72776 8.33984 7.69428Z",
849
+ fill: "#8C8C8C"
850
+ }
851
+ )
852
+ ] }),
853
+ /* @__PURE__ */ jsx16("defs", { children: /* @__PURE__ */ jsx16("clipPath", { id: "clip0_1096_17248", children: /* @__PURE__ */ jsx16("rect", { width: "12", height: "12", fill: "white" }) }) })
854
+ ]
855
+ }
856
+ );
857
+ };
858
+ var ClockIcon_default = ClockIcon;
859
+
860
+ // src/atoms/AdminChatResponse.tsx
861
+ import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
862
+ var AdminChatResponse = (props) => {
863
+ return /* @__PURE__ */ jsxs12("div", { className: "ic-flex ic-gap-4", children: [
864
+ /* @__PURE__ */ jsx17("div", { className: "", children: /* @__PURE__ */ jsx17("div", { className: "ic-h-10 ic-w-10 ic-bg-white ic-shrink-0 ic-grow-0 ic-shadow-sm ic-rounded-md ic-flex ic-justify-center ic-items-center", children: /* @__PURE__ */ jsx17(FlexaIcon_default, { w: 24, h: 24 }) }) }),
865
+ props.isLoading ? /* @__PURE__ */ jsx17("div", { className: "ic-mt-4", children: /* @__PURE__ */ jsx17(CustomLoading_default, { size: "8px" }) }) : /* @__PURE__ */ jsxs12("div", { className: "ic-bg-white ic-shadow-sm ic-p-3 ic-rounded-md", children: [
866
+ /* @__PURE__ */ jsx17("p", { className: "ic-text-sm", children: props.message || "" }),
867
+ /* @__PURE__ */ jsxs12("p", { className: "ic-mt-2 ic-w-full text-neutral-700 ic-items-center ic-text-sm ic-flex ic-gap-1 ic-justify-start", children: [
868
+ /* @__PURE__ */ jsx17(ClockIcon_default, {}),
869
+ " ",
870
+ props.time
871
+ ] })
872
+ ] })
873
+ ] });
874
+ };
875
+ var AdminChatResponse_default = AdminChatResponse;
876
+
877
+ // src/atoms/UserChatResponse.tsx
878
+ import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
879
+ var UserChatResponse = (props) => {
880
+ return /* @__PURE__ */ jsxs13("div", { className: "ic-bg-white ic-shadow-sm ic-p-3 ic-rounded-md ic-w-fit", children: [
881
+ /* @__PURE__ */ jsx18("p", { className: "ic-text-sm", children: props.message }),
882
+ /* @__PURE__ */ jsxs13("p", { className: "ic-mt-2 ic-w-full text-neutral-700 ic-items-center ic-text-sm ic-flex ic-gap-1 ic-justify-end", children: [
883
+ /* @__PURE__ */ jsx18(ClockIcon_default, {}),
884
+ " ",
885
+ props.time
886
+ ] })
887
+ ] });
888
+ };
889
+ var UserChatResponse_default = UserChatResponse;
890
+
891
+ // src/molecules/Chatting.tsx
892
+ import dayjs from "dayjs";
893
+ import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
894
+ var Chatting = (props) => {
895
+ const { chats, isLoadingResponse } = useChat();
896
+ const chatCanvasRef = useRef3(null);
897
+ const [isUserAtBottom, setIsUserAtBottom] = useState5(true);
898
+ const handleScroll = () => {
899
+ const el = chatCanvasRef.current;
900
+ if (!el) return;
901
+ setIsUserAtBottom(el.scrollHeight - el.scrollTop - el.clientHeight < 10);
902
+ };
903
+ useEffect3(() => {
904
+ const el = chatCanvasRef.current;
905
+ if (!el) return;
906
+ if (isUserAtBottom) {
907
+ el.scrollTop = el.scrollHeight;
908
+ }
909
+ }, [chats, isUserAtBottom]);
910
+ useEffect3(() => {
911
+ if (!isLoadingResponse && chats.length > 0) {
912
+ const lastChat = chats[chats.length - 1];
913
+ if (lastChat.status === "COMPLETE") {
914
+ props.onResponseChat && props.onResponseChat(lastChat);
915
+ }
916
+ }
917
+ }, [chats, isLoadingResponse]);
918
+ return /* @__PURE__ */ jsxs14(
919
+ "div",
920
+ {
921
+ ref: chatCanvasRef,
922
+ onScroll: handleScroll,
923
+ className: "ic-h-full ic-overflow-auto ic-relative ic-w-full ic-flex-col ic-items-center ic-justify-between ic-flex ",
924
+ children: [
925
+ chats.length < 1 && /* @__PURE__ */ jsx19("div", {}),
926
+ /* @__PURE__ */ jsx19("div", { className: "ic-w-full ic-flex ic-justify-center", children: chats.length < 1 ? /* @__PURE__ */ jsxs14("div", { className: "ic-flex ic-flex-col ic-text-center ic-items-center ic-gap-4", children: [
927
+ /* @__PURE__ */ jsx19(FlexaIcon_default, {}),
928
+ /* @__PURE__ */ jsxs14("p", { className: "ic-text-dark-primary-500 ic-font-bold ic-text-xl ic-text-center", children: [
929
+ "Welcome to FlexA Copilot",
930
+ /* @__PURE__ */ jsx19("br", {}),
931
+ "How i can assist you today?"
932
+ ] })
933
+ ] }) : /* @__PURE__ */ jsx19("div", { className: "ic-w-full ic-max-w-5xl ic-flex ic-flex-col ic-space-y-4 ", children: chats.map((item) => {
934
+ const input = JSON.parse(
935
+ item.input
936
+ );
937
+ return /* @__PURE__ */ jsxs14(
938
+ "div",
939
+ {
940
+ className: " ic-flex ic-flex-col ic-space-y-4 ic-w-full ",
941
+ children: [
942
+ /* @__PURE__ */ jsx19("div", { className: " ic-w-full ic-flex ic-justify-end", children: /* @__PURE__ */ jsx19("div", { className: "ic-w-full ic-flex ic-justify-end ic-max-w-4xl ic-pr-4 ic-pl-20", children: /* @__PURE__ */ jsx19(
943
+ UserChatResponse_default,
944
+ {
945
+ message: input.message,
946
+ time: dayjs(item.createDate).format("HH:mm")
947
+ }
948
+ ) }) }),
949
+ /* @__PURE__ */ jsx19("div", { className: " ic-w-full ic-flex ic-justify-start ic-pr-20", children: /* @__PURE__ */ jsx19("div", { className: "ic-w-full ic-max-w-4xl", children: /* @__PURE__ */ jsx19(
950
+ AdminChatResponse_default,
951
+ {
952
+ message: item.output,
953
+ isLoading: item.status === "RUNNING",
954
+ time: dayjs(item.endDate).format("HH:mm")
955
+ }
956
+ ) }) })
957
+ ]
958
+ },
959
+ `chat-response-${item.jobId}`
960
+ );
961
+ }) }) }),
962
+ /* @__PURE__ */ jsx19("div", { className: "ic-sticky ic-mt-4 ic-bottom-0 ic-w-full ic-flex ic-justify-center", children: /* @__PURE__ */ jsx19(ChatSender_default, {}) })
963
+ ]
964
+ }
965
+ );
966
+ };
967
+ var Chatting_default = Chatting;
968
+
969
+ // src/index.tsx
970
+ var index_default = IntellinumChat_default;
971
+ export {
972
+ ChatHistory_default as ChatHistory,
973
+ ChatProvider_default as ChatProvider,
974
+ ChatSender_default as ChatSender,
975
+ Chatting_default as Chatting,
976
+ SuggestionChat_default as SuggestionChat,
977
+ index_default as default,
978
+ useChat
979
+ };
980
+ //# sourceMappingURL=index.mjs.map