@ibti-tech/chatbot 0.1.2 → 0.2.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.d.ts CHANGED
@@ -8,12 +8,15 @@ declare module '@ibti-tech/chatbot/components/BotIcon/index.d.ts' {
8
8
  }
9
9
  declare module '@ibti-tech/chatbot/components/ChatUserFeedbackRating/index' {
10
10
  import React from 'react';
11
- export type ChatUserFeedbackRatingProps = {};
12
- export const ChatUserFeedbackRating: ({}: ChatUserFeedbackRatingProps) => React.JSX.Element;
11
+ import { useChatFeedbackBox } from 'contexts/Chatbot/useChatFeedbackBox';
12
+ export type ChatUserFeedbackRatingProps = {
13
+ chatFeedbackBox: ReturnType<typeof useChatFeedbackBox>;
14
+ };
15
+ export const ChatUserFeedbackRating: ({ chatFeedbackBox, }: ChatUserFeedbackRatingProps) => React.JSX.Element;
13
16
  //# sourceMappingURL=index.d.ts.map
14
17
  }
15
18
  declare module '@ibti-tech/chatbot/components/ChatUserFeedbackRating/index.d.ts' {
16
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatUserFeedbackRating/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAA;AAMzD,MAAM,MAAM,2BAA2B,GAAG,EAAE,CAAA;AAE5C,eAAO,MAAM,sBAAsB,OAAQ,2BAA2B,sBAmDrE,CAAA"}
19
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatUserFeedbackRating/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqC,MAAM,OAAO,CAAA;AAIzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAGxE,MAAM,MAAM,2BAA2B,GAAG;IACxC,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;CACvD,CAAA;AAED,eAAO,MAAM,sBAAsB,yBAEhC,2BAA2B,sBAmD7B,CAAA"}
17
20
  }
18
21
  declare module '@ibti-tech/chatbot/components/ChatUserFeedbackRating/styles' {
19
22
  /// <reference types="react" />
@@ -25,7 +28,7 @@ declare module '@ibti-tech/chatbot/components/ChatUserFeedbackRating/styles' {
25
28
  layer?: import("@ibti-tech/ui").ThemeLayerIndex | undefined;
26
29
  hoverable?: boolean | undefined;
27
30
  children?: import("react").ReactNode;
28
- roundedCorners?: "none" | "small" | "medium" | "large" | undefined;
31
+ roundedCorners?: "small" | "none" | "medium" | "large" | undefined;
29
32
  tag?: keyof HTMLElementTagNameMap | undefined;
30
33
  boxShadow?: boolean | undefined;
31
34
  } & import("react").HTMLAttributes<HTMLDivElement>, never>> & string & Omit<({ layer, hoverable, children, roundedCorners, tag, boxShadow, ...props }: import("@ibti-tech/ui").CardBaseProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
@@ -67,13 +70,6 @@ declare module '@ibti-tech/chatbot/components/ChatbotBody/index' {
67
70
  declare module '@ibti-tech/chatbot/components/ChatbotBody/index.d.ts' {
68
71
  {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotBody/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAShD,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAEjC,eAAO,MAAM,WAAW,+BAoCvB,CAAA;AAED,eAAe,WAAW,CAAA"}
69
72
  }
70
- declare module '@ibti-tech/chatbot/components/ChatbotBody/index.spec' {
71
- export {};
72
- //# sourceMappingURL=index.spec.d.ts.map
73
- }
74
- declare module '@ibti-tech/chatbot/components/ChatbotBody/index.spec.d.ts' {
75
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotBody/index.spec.tsx"],"names":[],"mappings":""}
76
- }
77
73
  declare module '@ibti-tech/chatbot/components/ChatbotBody/styles' {
78
74
  /// <reference types="react" />
79
75
  export const ChatbotInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -92,7 +88,7 @@ declare module '@ibti-tech/chatbot/components/ChatbotDevice/index' {
92
88
  //# sourceMappingURL=index.d.ts.map
93
89
  }
94
90
  declare module '@ibti-tech/chatbot/components/ChatbotDevice/index.d.ts' {
95
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotDevice/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,MAAM,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEnC,eAAO,MAAM,aAAa,OAAQ,kBAAkB,sBAYnD,CAAA;AAED,eAAe,aAAa,CAAA"}
91
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotDevice/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB,MAAM,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEnC,eAAO,MAAM,aAAa,OAAQ,kBAAkB,sBAanD,CAAA;AAED,eAAe,aAAa,CAAA"}
96
92
  }
97
93
  declare module '@ibti-tech/chatbot/components/ChatbotDevice/styles' {
98
94
  /// <reference types="react" />
@@ -102,7 +98,7 @@ declare module '@ibti-tech/chatbot/components/ChatbotDevice/styles' {
102
98
  //# sourceMappingURL=styles.d.ts.map
103
99
  }
104
100
  declare module '@ibti-tech/chatbot/components/ChatbotDevice/styles.d.ts' {
105
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotDevice/styles.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,OAAO;aAAyB,OAAO;YA8BnD,CAAA"}
101
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotDevice/styles.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,OAAO;aAAyB,OAAO;YA0BnD,CAAA"}
106
102
  }
107
103
  declare module '@ibti-tech/chatbot/components/ChatbotFooter/index' {
108
104
  import React from 'react';
@@ -112,14 +108,7 @@ declare module '@ibti-tech/chatbot/components/ChatbotFooter/index' {
112
108
  //# sourceMappingURL=index.d.ts.map
113
109
  }
114
110
  declare module '@ibti-tech/chatbot/components/ChatbotFooter/index.d.ts' {
115
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotFooter/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAMvC,MAAM,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEnC,eAAO,MAAM,aAAa,OAAQ,kBAAkB,sBAsCnD,CAAA;AAED,eAAe,aAAa,CAAA"}
116
- }
117
- declare module '@ibti-tech/chatbot/components/ChatbotFooter/index.spec' {
118
- export {};
119
- //# sourceMappingURL=index.spec.d.ts.map
120
- }
121
- declare module '@ibti-tech/chatbot/components/ChatbotFooter/index.spec.d.ts' {
122
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotFooter/index.spec.tsx"],"names":[],"mappings":""}
111
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotFooter/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAcvC,MAAM,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEnC,eAAO,MAAM,aAAa,OAAQ,kBAAkB,sBAwCnD,CAAA;AAED,eAAe,aAAa,CAAA"}
123
112
  }
124
113
  declare module '@ibti-tech/chatbot/components/ChatbotFooter/styles' {
125
114
  /// <reference types="react" />
@@ -133,20 +122,16 @@ declare module '@ibti-tech/chatbot/components/ChatbotFooter/styles.d.ts' {
133
122
  }
134
123
  declare module '@ibti-tech/chatbot/components/ChatbotHeader/index' {
135
124
  import React from 'react';
136
- export type ChatbotHeaderProps = {};
137
- export const ChatbotHeader: ({}: ChatbotHeaderProps) => React.JSX.Element;
125
+ import { useChatFeedbackBox } from 'contexts/Chatbot/useChatFeedbackBox';
126
+ export type ChatbotHeaderProps = {
127
+ chatFeedbackBox: ReturnType<typeof useChatFeedbackBox>;
128
+ };
129
+ export const ChatbotHeader: ({ chatFeedbackBox }: ChatbotHeaderProps) => React.JSX.Element;
138
130
  export default ChatbotHeader;
139
131
  //# sourceMappingURL=index.d.ts.map
140
132
  }
141
133
  declare module '@ibti-tech/chatbot/components/ChatbotHeader/index.d.ts' {
142
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotHeader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,MAAM,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAEnC,eAAO,MAAM,aAAa,OAAQ,kBAAkB,sBAcnD,CAAA;AAED,eAAe,aAAa,CAAA"}
143
- }
144
- declare module '@ibti-tech/chatbot/components/ChatbotHeader/index.spec' {
145
- export {};
146
- //# sourceMappingURL=index.spec.d.ts.map
147
- }
148
- declare module '@ibti-tech/chatbot/components/ChatbotHeader/index.spec.d.ts' {
149
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotHeader/index.spec.tsx"],"names":[],"mappings":""}
134
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotHeader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAExE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;CACvD,CAAA;AAED,eAAO,MAAM,aAAa,wBAAyB,kBAAkB,sBAqBpE,CAAA;AAED,eAAe,aAAa,CAAA"}
150
135
  }
151
136
  declare module '@ibti-tech/chatbot/components/ChatbotHeader/styles' {
152
137
  /// <reference types="react" />
@@ -157,7 +142,7 @@ declare module '@ibti-tech/chatbot/components/ChatbotHeader/styles' {
157
142
  //# sourceMappingURL=styles.d.ts.map
158
143
  }
159
144
  declare module '@ibti-tech/chatbot/components/ChatbotHeader/styles.d.ts' {
160
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotHeader/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,IAAI,+NAGhB,CAAA;AAED,eAAO,MAAM,WAAW,6NAGvB,CAAA;AAED,eAAO,MAAM,YAAY,+NAaxB,CAAA;AAED,eAAO,MAAM,OAAO,6NAMnB,CAAA"}
145
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/ChatbotHeader/styles.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,IAAI,+NAGhB,CAAA;AAED,eAAO,MAAM,WAAW,6NAIvB,CAAA;AAED,eAAO,MAAM,YAAY,+NAaxB,CAAA;AAED,eAAO,MAAM,OAAO,6NAMnB,CAAA"}
161
146
  }
162
147
  declare module '@ibti-tech/chatbot/components/ChatbotStatusLabel/index' {
163
148
  import React from 'react';
@@ -209,20 +194,14 @@ declare module '@ibti-tech/chatbot/components/MessageBalloon/index' {
209
194
  //# sourceMappingURL=index.d.ts.map
210
195
  }
211
196
  declare module '@ibti-tech/chatbot/components/MessageBalloon/index.d.ts' {
212
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/MessageBalloon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAMpC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC,WAAW,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAOD,eAAO,MAAM,cAAc,8BAGxB,mBAAmB,sBAgBrB,CAAA;AAED,eAAe,cAAc,CAAA"}
213
- }
214
- declare module '@ibti-tech/chatbot/components/MessageBalloon/index.spec' {
215
- export {};
216
- //# sourceMappingURL=index.spec.d.ts.map
217
- }
218
- declare module '@ibti-tech/chatbot/components/MessageBalloon/index.spec.d.ts' {
219
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/MessageBalloon/index.spec.tsx"],"names":[],"mappings":""}
197
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/MessageBalloon/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAOpC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC,WAAW,CAAA;IAC9B,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAOD,eAAO,MAAM,cAAc,8BAGxB,mBAAmB,sBAiBrB,CAAA;AAED,eAAe,cAAc,CAAA"}
220
198
  }
221
199
  declare module '@ibti-tech/chatbot/components/MessageBalloon/styles' {
222
200
  /// <reference types="react" />
223
201
  export const Time: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
224
202
  export const Balloon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
225
203
  $type: 'received' | 'sent';
204
+ $error?: boolean | undefined;
226
205
  }>> & string;
227
206
  export const Label: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
228
207
  export const Wrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
@@ -231,7 +210,7 @@ declare module '@ibti-tech/chatbot/components/MessageBalloon/styles' {
231
210
  //# sourceMappingURL=styles.d.ts.map
232
211
  }
233
212
  declare module '@ibti-tech/chatbot/components/MessageBalloon/styles.d.ts' {
234
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/MessageBalloon/styles.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,IAAI,+NAEhB,CAAA;AAED,eAAO,MAAM,OAAO;WAAuB,UAAU,GAAG,MAAM;YAkE7D,CAAA;AAED,eAAO,MAAM,KAAK,+NAEjB,CAAA;AAED,eAAO,MAAM,OAAO;WAAuB,UAAU,GAAG,MAAM;YAiB7D,CAAA"}
213
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/MessageBalloon/styles.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,IAAI,+NAEhB,CAAA;AAED,eAAO,MAAM,OAAO;WACX,UAAU,GAAG,MAAM;;YA0E3B,CAAA;AAED,eAAO,MAAM,KAAK,+NAEjB,CAAA;AAED,eAAO,MAAM,OAAO;WAAuB,UAAU,GAAG,MAAM;YAiB7D,CAAA"}
235
214
  }
236
215
  declare module '@ibti-tech/chatbot/components/SuggestedQuestions/index' {
237
216
  import React from 'react';
@@ -243,13 +222,6 @@ declare module '@ibti-tech/chatbot/components/SuggestedQuestions/index' {
243
222
  declare module '@ibti-tech/chatbot/components/SuggestedQuestions/index.d.ts' {
244
223
  {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/SuggestedQuestions/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,MAAM,MAAM,uBAAuB,GAAG,EAAE,CAAA;AAExC,eAAO,MAAM,kBAAkB,OAAQ,uBAAuB,kCA4B7D,CAAA;AAED,eAAe,kBAAkB,CAAA"}
245
224
  }
246
- declare module '@ibti-tech/chatbot/components/SuggestedQuestions/index.spec' {
247
- export {};
248
- //# sourceMappingURL=index.spec.d.ts.map
249
- }
250
- declare module '@ibti-tech/chatbot/components/SuggestedQuestions/index.spec.d.ts' {
251
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/components/SuggestedQuestions/index.spec.tsx"],"names":[],"mappings":""}
252
- }
253
225
  declare module '@ibti-tech/chatbot/components/SuggestedQuestions/styles' {
254
226
  /// <reference types="react" />
255
227
  export const QuestionButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("@ibti-tech/ui").ButtonProps & import("styled-components/dist/types").BaseObject, import("styled-components/dist/types").BaseObject>> & string & Omit<({ size, suffix, prefix, fillWidth, ...props }: import("@ibti-tech/ui").ButtonProps) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
@@ -307,6 +279,7 @@ declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatFeedbackBox' {
307
279
  };
308
280
  export const useChatFeedbackBox: () => {
309
281
  opened: boolean;
282
+ open: () => void;
310
283
  close: () => void;
311
284
  sendUserRating: ({ ratingScore, description, }: SendUserRatingProps) => Promise<void>;
312
285
  loading: boolean;
@@ -315,7 +288,7 @@ declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatFeedbackBox' {
315
288
  //# sourceMappingURL=useChatFeedbackBox.d.ts.map
316
289
  }
317
290
  declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatFeedbackBox.d.ts' {
318
- {"version":3,"file":"useChatFeedbackBox.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/contexts/Chatbot/useChatFeedbackBox.ts"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB;;;oDAkB1B,mBAAmB;;CA0BvB,CAAA"}
291
+ {"version":3,"file":"useChatFeedbackBox.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/contexts/Chatbot/useChatFeedbackBox.ts"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,kBAAkB;;;;oDAsB1B,mBAAmB;;CA2BvB,CAAA"}
319
292
  }
320
293
  declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatbot' {
321
294
  export const useChatbot: () => import("@ibti-tech/chatbot/contexts/Chatbot/context").ChatbotContextProps;
@@ -348,7 +321,7 @@ declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatbotMessages' {
348
321
  //# sourceMappingURL=useChatbotMessages.d.ts.map
349
322
  }
350
323
  declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatbotMessages.d.ts' {
351
- {"version":3,"file":"useChatbotMessages.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/contexts/Chatbot/useChatbotMessages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAMpC,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,kBAAkB,wBAG5B,yBAAyB;;iCAuEgB,MAAM;;;;;;;;;;CA6DjD,CAAA;AAED,eAAe,kBAAkB,CAAA"}
324
+ {"version":3,"file":"useChatbotMessages.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/contexts/Chatbot/useChatbotMessages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAQpC,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,kBAAkB,wBAG5B,yBAAyB;;iCA4EgB,MAAM;;;;;;;;;;CAqFjD,CAAA;AAED,eAAe,kBAAkB,CAAA"}
352
325
  }
353
326
  declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatbotSuggestedQuestions' {
354
327
  import { ChatbotTypes } from 'types';
@@ -368,6 +341,19 @@ declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatbotSuggestedQuestions
368
341
  declare module '@ibti-tech/chatbot/contexts/Chatbot/useChatbotSuggestedQuestions.d.ts' {
369
342
  {"version":3,"file":"useChatbotSuggestedQuestions.d.ts","sourceRoot":"","sources":["../../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/contexts/Chatbot/useChatbotSuggestedQuestions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,MAAM,MAAM,mCAAmC,GAAG;IAChD,WAAW,EAAE,YAAY,CAAC,eAAe,EAAE,CAAA;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,4BAA4B,qCAItC,mCAAmC;;;;;CA2BrC,CAAA"}
370
343
  }
344
+ declare module '@ibti-tech/chatbot/cookies/chat' {
345
+ import { ChatbotTypes } from 'types';
346
+ export class ChatCookieManager {
347
+ cookieKey: string;
348
+ checkValidJSONData(data: any): void;
349
+ getData(): ChatbotTypes.ChatMessage[];
350
+ saveData(data: ChatbotTypes.ChatMessage[]): void;
351
+ }
352
+ //# sourceMappingURL=chat.d.ts.map
353
+ }
354
+ declare module '@ibti-tech/chatbot/cookies/chat.d.ts' {
355
+ {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/cookies/chat.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,qBAAa,iBAAiB;IAC5B,SAAS,SAAqB;IAE9B,kBAAkB,CAAC,IAAI,EAAE,GAAG;IAQ5B,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE;IAiBrC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,WAAW,EAAE;CAW1C"}
356
+ }
371
357
  declare module '@ibti-tech/chatbot/events/assistant-answer' {
372
358
  export const dispatchAssitantAnswer: () => void;
373
359
  //# sourceMappingURL=assistant-answer.d.ts.map
@@ -443,12 +429,13 @@ declare module '@ibti-tech/chatbot/i18n/LocaleTerms' {
443
429
  MESSAGE_FIELD: string;
444
430
  SUBMIT_BUTTON: string;
445
431
  CLOSE_BUTTON: string;
432
+ RATE: string;
446
433
  };
447
434
  }
448
435
  //# sourceMappingURL=LocaleTerms.d.ts.map
449
436
  }
450
437
  declare module '@ibti-tech/chatbot/i18n/LocaleTerms.d.ts' {
451
- {"version":3,"file":"LocaleTerms.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/i18n/LocaleTerms.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAA;QACd,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,mBAAmB,EAAE;QACnB,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,aAAa,EAAE;QACb,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,aAAa,EAAE,MAAM,CAAA;QACrB,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;CACF"}
438
+ {"version":3,"file":"LocaleTerms.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/i18n/LocaleTerms.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,MAAM,CAAA;IACpB,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAA;QACd,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,WAAW,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,WAAW,EAAE;QACX,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,mBAAmB,EAAE;QACnB,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,aAAa,EAAE;QACb,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,aAAa,EAAE,MAAM,CAAA;QACrB,YAAY,EAAE,MAAM,CAAA;QACpB,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF"}
452
439
  }
453
440
  declare module '@ibti-tech/chatbot/i18n/index' {
454
441
  import { ChatbotTypes } from 'types';
@@ -472,13 +459,6 @@ declare module '@ibti-tech/chatbot/index' {
472
459
  declare module '@ibti-tech/chatbot/index.d.ts' {
473
460
  {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA"}
474
461
  }
475
- declare module '@ibti-tech/chatbot/index.spec' {
476
- export {};
477
- //# sourceMappingURL=index.spec.d.ts.map
478
- }
479
- declare module '@ibti-tech/chatbot/index.spec.d.ts' {
480
- {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/index.spec.tsx"],"names":[],"mappings":""}
481
- }
482
462
  declare module '@ibti-tech/chatbot/mocks/chatHistory' {
483
463
  export const chatHistoryMocked: readonly [{
484
464
  readonly timestamp: "2024-05-23T10:15:00Z";
@@ -551,7 +531,6 @@ declare module '@ibti-tech/chatbot/services/chatbot-api' {
551
531
  apiURL: string;
552
532
  onReceiving: (receivedMessage: string, receivedPart: string) => void;
553
533
  onDone: () => void;
554
- onError: (err: unknown) => void;
555
534
  };
556
535
  export type GetSuggestedQuestions = {
557
536
  chatContext: Pick<ChatbotTypes.ChatMessage, 'content' | 'role'>[];
@@ -566,13 +545,13 @@ declare module '@ibti-tech/chatbot/services/chatbot-api' {
566
545
  ratingScore: number;
567
546
  description?: string;
568
547
  };
569
- export const sendChatContext: ({ chatContext, locale, onReceiving, onDone, apiURL, onError, }: SendNewQuestionOptions) => Promise<void>;
570
- export const getSuggestedQuestions: ({ chatContext, apiURL, locale, }: GetSuggestedQuestions) => Promise<string[]>;
548
+ export const sendChatContext: ({ chatContext, locale, onReceiving, onDone, apiURL, }: SendNewQuestionOptions) => Promise<void>;
571
549
  export const sendUserChatFeedback: ({ apiURL, chatContext, locale, ratingScore, description, }: SendUserChatFeedbackParams) => Promise<Response>;
550
+ export const getWelcomeMessage: (apiUrl: string, locale?: ChatbotTypes.Locale) => Promise<string>;
572
551
  //# sourceMappingURL=chatbot-api.d.ts.map
573
552
  }
574
553
  declare module '@ibti-tech/chatbot/services/chatbot-api.d.ts' {
575
- {"version":3,"file":"chatbot-api.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/services/chatbot-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpE,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,mEAOzB,sBAAsB,kBAsCnB,CAAA;AAEN,eAAO,MAAM,qBAAqB,qCAI/B,qBAAqB,sBAiBvB,CAAA;AAED,eAAO,MAAM,oBAAoB,+DAM9B,0BAA0B,sBAYzB,CAAA"}
554
+ {"version":3,"file":"chatbot-api.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/services/chatbot-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IACpE,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAEzC,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAA;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,CAAA;IACjE,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,0DAMzB,sBAAsB,kBAuCrB,CAAA;AAyBJ,eAAO,MAAM,oBAAoB,+DAM9B,0BAA0B,sBAYzB,CAAA;AAEJ,eAAO,MAAM,iBAAiB,WACpB,MAAM,WACN,aAAa,MAAM,oBAS5B,CAAA"}
576
555
  }
577
556
  declare module '@ibti-tech/chatbot/themes/index' {
578
557
  export const themes: {
@@ -673,6 +652,7 @@ declare module '@ibti-tech/chatbot/types/index' {
673
652
  timestamp: string;
674
653
  role: 'user' | 'assistant';
675
654
  content: string;
655
+ error?: boolean;
676
656
  };
677
657
  type ChatContextItem = {
678
658
  role: 'user' | 'assistant';
@@ -687,7 +667,7 @@ declare module '@ibti-tech/chatbot/types/index' {
687
667
  //# sourceMappingURL=index.d.ts.map
688
668
  }
689
669
  declare module '@ibti-tech/chatbot/types/index.d.ts' {
690
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/types/index.ts"],"names":[],"mappings":"AAAA,yBAAiB,YAAY,CAAC;IAC5B,KAAY,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;IAEpC,KAAY,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;IAEnC,KAAY,WAAW,GAAG;QACxB,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;QAC1B,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IAED,KAAY,eAAe,GAAG;QAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;QAC1B,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IAED,KAAY,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAA;IAErE,UAAiB,MAAM;QACrB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,sBAAsB,CAAC,EAAE,MAAM,CAAA;KAChC;CACF"}
670
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../home/juan/projetos/ibti/chatbot/ibti-chatbot/src/types/index.ts"],"names":[],"mappings":"AAAA,yBAAiB,YAAY,CAAC;IAC5B,KAAY,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;IAEpC,KAAY,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;IAEnC,KAAY,WAAW,GAAG;QACxB,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;QAC1B,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;IAED,KAAY,eAAe,GAAG;QAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;QAC1B,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;IAED,KAAY,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAA;IAErE,UAAiB,MAAM;QACrB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,sBAAsB,CAAC,EAAE,MAAM,CAAA;KAChC;CACF"}
691
671
  }
692
672
  declare module '@ibti-tech/chatbot/utils/formatMessageTime' {
693
673
  import { ChatbotTypes } from 'types';
package/dist/index.mjs CHANGED
@@ -25,6 +25,107 @@ import { v4 as uuidv4 } from "uuid";
25
25
 
26
26
  // src/contexts/Chatbot/useChatbotSuggestedQuestions.ts
27
27
  import { useState } from "react";
28
+ var useChatbotSuggestedQuestions = /* @__PURE__ */ __name(({
29
+ chatContext,
30
+ locale = "en",
31
+ apiURL
32
+ }) => {
33
+ const [loading, setLoading] = useState(false);
34
+ const [data, setData] = useState([]);
35
+ const fetchData = /* @__PURE__ */ __name(async () => {
36
+ if (chatContext.length === 0) return;
37
+ setLoading(true);
38
+ setLoading(false);
39
+ }, "fetchData");
40
+ const resetData = /* @__PURE__ */ __name(() => {
41
+ setData([]);
42
+ }, "resetData");
43
+ return {
44
+ loading,
45
+ data,
46
+ fetchData,
47
+ resetData
48
+ };
49
+ }, "useChatbotSuggestedQuestions");
50
+
51
+ // src/events/eventNames.ts
52
+ var CUSTOM_EVENT_NAMES = {
53
+ ASSISTANT_ANSWER_FINISHED: "ASSISTANT_ANSWER_FINISHED"
54
+ };
55
+
56
+ // src/events/assistant-answer.ts
57
+ var dispatchAssitantAnswer = /* @__PURE__ */ __name(() => {
58
+ const evt = new CustomEvent(CUSTOM_EVENT_NAMES.ASSISTANT_ANSWER_FINISHED);
59
+ document.dispatchEvent(evt);
60
+ }, "dispatchAssitantAnswer");
61
+
62
+ // src/i18n/en.json
63
+ var en_default = {
64
+ CHATBOT_NAME: "IBTI Chatbot (Beta)",
65
+ STATUS: {
66
+ ONLINE: "Now online",
67
+ LOADING: "Loading...",
68
+ WRITING: "Writing answer...",
69
+ UNAVAILABLE: "Unavailable"
70
+ },
71
+ ERRORS: {
72
+ UNKNOWN: "Sorry. We couldn't provide a response."
73
+ },
74
+ INPUT_PLACEHOLDER: "Ask something",
75
+ CHATBOT_BAR: {
76
+ OPEN: "Open {{CHATBOT_NAME}}",
77
+ CLOSE: "Close {{CHATBOT_NAME}}"
78
+ },
79
+ SUGGESTED_QUESTIONS: {
80
+ TITLE: "You may like to ask:",
81
+ LOADING: "Loading suggested questions..."
82
+ },
83
+ CHAT_FEEDBACK: {
84
+ TITLE: "Rate the Chatbot",
85
+ DESCRIPTION: "Give us a feedback about our bot assistant.",
86
+ MESSAGE_FIELD: "Description",
87
+ SUBMIT_BUTTON: "Send",
88
+ CLOSE_BUTTON: "Close",
89
+ RATE: "Rate assistant"
90
+ }
91
+ };
92
+
93
+ // src/i18n/pt_BR.json
94
+ var pt_BR_default = {
95
+ CHATBOT_NAME: "Assistente da IBTI (Beta)",
96
+ STATUS: {
97
+ ONLINE: "Ativo agora",
98
+ LOADING: "Carregando...",
99
+ WRITING: "Escrevendo resposta...",
100
+ UNAVAILABLE: "Indispon\xEDvel"
101
+ },
102
+ ERRORS: {
103
+ UNKNOWN: "Desculpe. N\xE3o conseguimos fornecer uma resposta."
104
+ },
105
+ INPUT_PLACEHOLDER: "Pergunte alguma coisa",
106
+ CHATBOT_BAR: {
107
+ OPEN: "Abrir Assistente da IBTI",
108
+ CLOSE: "Fechar Assistente da IBTI"
109
+ },
110
+ SUGGESTED_QUESTIONS: {
111
+ TITLE: "Voc\xEA pode querer perguntar:",
112
+ LOADING: "Carregando perguntas sugeridas..."
113
+ },
114
+ CHAT_FEEDBACK: {
115
+ TITLE: "Avalie nosso Assistente",
116
+ DESCRIPTION: "D\xEA-nos um feedback sobre o nosso assistente virtual.",
117
+ MESSAGE_FIELD: "Descri\xE7\xE3o",
118
+ SUBMIT_BUTTON: "Enviar",
119
+ CLOSE_BUTTON: "Fechar",
120
+ RATE: "Avaliar assistente"
121
+ }
122
+ };
123
+
124
+ // src/i18n/index.ts
125
+ var i18n = {
126
+ en: en_default,
127
+ "pt-BR": pt_BR_default
128
+ };
28
129
 
29
130
  // src/services/chatbot-api.ts
30
131
  var sendChatContext = /* @__PURE__ */ __name(async ({
@@ -32,8 +133,7 @@ var sendChatContext = /* @__PURE__ */ __name(async ({
32
133
  locale = "en",
33
134
  onReceiving,
34
135
  onDone,
35
- apiURL,
36
- onError
136
+ apiURL
37
137
  }) => fetch(`${apiURL}/chat/completion?locale=${locale}`, {
38
138
  method: "POST",
39
139
  headers: {
@@ -43,6 +143,10 @@ var sendChatContext = /* @__PURE__ */ __name(async ({
43
143
  context: chatContext
44
144
  })
45
145
  }).then((response) => {
146
+ if (!response.ok)
147
+ throw new Error(
148
+ i18n[locale].ERRORS.UNKNOWN + ` (status: ${response.status})`
149
+ );
46
150
  if (!response.body) return;
47
151
  const reader = response.body.getReader();
48
152
  const decoder = new TextDecoder();
@@ -61,29 +165,7 @@ var sendChatContext = /* @__PURE__ */ __name(async ({
61
165
  }
62
166
  __name(read, "read");
63
167
  read();
64
- }).catch((err) => {
65
- onError(err);
66
168
  }), "sendChatContext");
67
- var getSuggestedQuestions = /* @__PURE__ */ __name(async ({
68
- chatContext,
69
- apiURL,
70
- locale = "en"
71
- }) => {
72
- const res = await fetch(
73
- `${apiURL}/chat/suggested_questions?locale=${locale}`,
74
- {
75
- method: "POST",
76
- headers: {
77
- "Content-type": "application/json"
78
- },
79
- body: JSON.stringify({
80
- context: chatContext
81
- })
82
- }
83
- );
84
- const data = await res.json();
85
- return data;
86
- }, "getSuggestedQuestions");
87
169
  var sendUserChatFeedback = /* @__PURE__ */ __name(async ({
88
170
  apiURL,
89
171
  chatContext,
@@ -102,57 +184,73 @@ var sendUserChatFeedback = /* @__PURE__ */ __name(async ({
102
184
  message: description
103
185
  })
104
186
  }), "sendUserChatFeedback");
105
-
106
- // src/contexts/Chatbot/useChatbotSuggestedQuestions.ts
107
- var useChatbotSuggestedQuestions = /* @__PURE__ */ __name(({
108
- chatContext,
109
- locale = "en",
110
- apiURL
111
- }) => {
112
- const [loading, setLoading] = useState(false);
113
- const [data, setData] = useState([]);
114
- const fetchData = /* @__PURE__ */ __name(async () => {
115
- if (chatContext.length === 0) return;
116
- setLoading(true);
117
- const suggestedData = await getSuggestedQuestions({
118
- chatContext,
119
- locale,
120
- apiURL
121
- });
122
- setData(suggestedData);
123
- setLoading(false);
124
- }, "fetchData");
125
- const resetData = /* @__PURE__ */ __name(() => {
126
- setData([]);
127
- }, "resetData");
128
- return {
129
- loading,
130
- data,
131
- fetchData,
132
- resetData
133
- };
134
- }, "useChatbotSuggestedQuestions");
135
-
136
- // src/events/eventNames.ts
137
- var CUSTOM_EVENT_NAMES = {
138
- ASSISTANT_ANSWER_FINISHED: "ASSISTANT_ANSWER_FINISHED"
187
+ var getWelcomeMessage = /* @__PURE__ */ __name(async (apiUrl, locale = "en") => {
188
+ const req = await fetch(`${apiUrl}/chat/welcome?locale=${locale}`, {
189
+ method: "GET"
190
+ });
191
+ const data = await req.json();
192
+ return data.welcomeMessage;
193
+ }, "getWelcomeMessage");
194
+
195
+ // src/cookies/chat.tsx
196
+ import { parseCookies, setCookie } from "nookies";
197
+ var ChatCookieManager = class {
198
+ constructor() {
199
+ this.cookieKey = "ibtiChatbot@chat";
200
+ }
201
+ static {
202
+ __name(this, "ChatCookieManager");
203
+ }
204
+ checkValidJSONData(data) {
205
+ try {
206
+ JSON.parse(JSON.stringify(data));
207
+ } catch (err) {
208
+ throw new Error("Invalid chat context data.");
209
+ }
210
+ }
211
+ getData() {
212
+ const cookies = parseCookies();
213
+ if (!cookies[this.cookieKey]) {
214
+ this.saveData([]);
215
+ return [];
216
+ }
217
+ try {
218
+ const data = JSON.parse(cookies[this.cookieKey]);
219
+ return data;
220
+ } catch (err) {
221
+ this.saveData([]);
222
+ return [];
223
+ }
224
+ }
225
+ saveData(data) {
226
+ try {
227
+ this.checkValidJSONData(data);
228
+ setCookie(null, this.cookieKey, JSON.stringify(data), {
229
+ expiresIn: 60 * 60 * 24
230
+ });
231
+ } catch (err) {
232
+ throw new Error("Fail to save chat context data");
233
+ }
234
+ }
139
235
  };
140
236
 
141
- // src/events/assistant-answer.ts
142
- var dispatchAssitantAnswer = /* @__PURE__ */ __name(() => {
143
- const evt = new CustomEvent(CUSTOM_EVENT_NAMES.ASSISTANT_ANSWER_FINISHED);
144
- document.dispatchEvent(evt);
145
- }, "dispatchAssitantAnswer");
237
+ // src/hooks/useI18n.ts
238
+ var useI18n = /* @__PURE__ */ __name(() => {
239
+ const { locale } = useChatbot();
240
+ return i18n[locale];
241
+ }, "useI18n");
146
242
 
147
243
  // src/contexts/Chatbot/useChatbotMessages.ts
148
244
  var useChatbotMessages = /* @__PURE__ */ __name(({
149
245
  apiURL,
150
246
  locale
151
247
  }) => {
248
+ const i18n2 = useI18n();
249
+ const chatCookie = new ChatCookieManager();
152
250
  const [chatMessages, setChatMessages] = useState2(
153
251
  []
154
252
  );
155
- const [assistantIntroduced, setAssistantIntroduced] = useState2(false);
253
+ const [initialized, setInitialized] = useState2(false);
156
254
  const [loading, setLoading] = useState2(false);
157
255
  const [writing, setWriting] = useState2(false);
158
256
  const [error, setError] = useState2();
@@ -179,13 +277,14 @@ var useChatbotMessages = /* @__PURE__ */ __name(({
179
277
  setChatMessages(newHistory);
180
278
  return messageData;
181
279
  }, "createQuestionMessageIntoHistory");
182
- const createOrUpdateAnswerMessageIntoHistory = /* @__PURE__ */ __name((answer, id) => {
280
+ const createOrUpdateAnswerMessageIntoHistory = /* @__PURE__ */ __name((answer, id, error2 = false) => {
183
281
  const timestamp = (/* @__PURE__ */ new Date()).toUTCString();
184
282
  const messageData = {
185
283
  id,
186
284
  timestamp,
187
285
  role: "assistant",
188
- content: answer
286
+ content: answer,
287
+ error: error2
189
288
  };
190
289
  setChatMessages((prev) => {
191
290
  const itemAlreadyExists = prev.some((item) => item.id == id);
@@ -212,42 +311,64 @@ var useChatbotMessages = /* @__PURE__ */ __name(({
212
311
  userQuestion,
213
312
  questionId
214
313
  );
215
- await sendChatContext({
216
- apiURL,
217
- locale,
218
- chatContext: [
219
- ...chatMessages.map((item) => ({
220
- role: item.role,
221
- content: item.content
222
- })),
223
- { role: chatContext.role, content: chatContext.content }
224
- ],
225
- onReceiving(receivedMessage) {
226
- setLoading(false);
227
- setWriting(true);
228
- createOrUpdateAnswerMessageIntoHistory(receivedMessage, answerId);
229
- },
230
- onDone: /* @__PURE__ */ __name(() => {
231
- setWriting(false);
232
- suggestedQuestions.fetchData();
233
- }, "onDone"),
234
- onError: setError
235
- });
314
+ try {
315
+ await sendChatContext({
316
+ apiURL,
317
+ locale,
318
+ chatContext: [
319
+ ...chatMessages.map((item) => ({
320
+ role: item.role,
321
+ content: item.content
322
+ })),
323
+ { role: chatContext.role, content: chatContext.content }
324
+ ],
325
+ onReceiving(receivedMessage) {
326
+ setLoading(false);
327
+ setWriting(true);
328
+ createOrUpdateAnswerMessageIntoHistory(receivedMessage, answerId);
329
+ },
330
+ onDone: /* @__PURE__ */ __name(() => {
331
+ setWriting(false);
332
+ suggestedQuestions.fetchData();
333
+ }, "onDone")
334
+ });
335
+ } catch (err) {
336
+ if (err instanceof Error) {
337
+ createOrUpdateAnswerMessageIntoHistory(err.message, answerId, true);
338
+ }
339
+ }
340
+ chatCookie.saveData([
341
+ ...chatMessages,
342
+ {
343
+ id: uuidv4(),
344
+ timestamp: (/* @__PURE__ */ new Date()).toUTCString(),
345
+ role: chatContext.role,
346
+ content: chatContext.content
347
+ }
348
+ ]);
236
349
  dispatchAssitantAnswer();
237
350
  }, "makeQuestion");
238
- const introduceAssistant = /* @__PURE__ */ __name(() => {
239
- const firstMessage = {
240
- "pt-BR": "Ol\xE1!",
241
- en: "Hello!"
242
- }[locale];
243
- makeQuestion(firstMessage);
244
- setAssistantIntroduced(true);
245
- setChatMessages((prev) => prev.slice(1));
246
- }, "introduceAssistant");
351
+ const init = /* @__PURE__ */ __name(async () => {
352
+ const savedData = chatCookie.getData();
353
+ if (savedData && savedData.length > 0) {
354
+ setChatMessages(savedData);
355
+ } else {
356
+ const firstMessage = await getWelcomeMessage(apiURL, locale);
357
+ setChatMessages([
358
+ {
359
+ id: uuidv4(),
360
+ timestamp: (/* @__PURE__ */ new Date()).toUTCString(),
361
+ role: "assistant",
362
+ content: firstMessage
363
+ }
364
+ ]);
365
+ }
366
+ setInitialized(true);
367
+ }, "init");
247
368
  useEffect(() => {
248
- if (assistantIntroduced) return;
249
- introduceAssistant();
250
- }, [assistantIntroduced]);
369
+ if (initialized) return;
370
+ init();
371
+ }, [initialized]);
251
372
  return {
252
373
  chatMessages,
253
374
  makeQuestion,
@@ -322,15 +443,9 @@ import React13 from "react";
322
443
 
323
444
  // src/components/ChatbotDevice/styles.ts
324
445
  import { breakpoints, screens } from "@ibti-tech/ui";
325
- import { mix } from "polished";
326
446
  import { css, styled } from "styled-components";
327
447
  var Wrapper = styled.div`
328
448
  width: 100%;
329
- /* background-color: ${(props) => mix(
330
- 0.05,
331
- props.theme.colors.palette.primary.normal,
332
- props.theme.colors.layers[0].background
333
- )}; */
334
449
  background-color: ${(props) => props.theme.colors.layers[1].background};
335
450
  border: 1px solid ${(props) => props.theme.colors.layers[1].border};
336
451
  display: flex;
@@ -341,6 +456,8 @@ var Wrapper = styled.div`
341
456
  overflow: hidden;
342
457
  pointer-events: all;
343
458
  height: 100vh;
459
+ max-height: calc(100vh - 45px);
460
+ box-sizing: border-box;
344
461
  position: relative;
345
462
 
346
463
  ${screens.tablet} {
@@ -365,6 +482,7 @@ var Name = styled2.span`
365
482
  var ProfileInfo = styled2.div`
366
483
  display: flex;
367
484
  flex-direction: column;
485
+ margin-right: auto;
368
486
  `;
369
487
  var ProfileImage = styled2.span`
370
488
  height: 2.5rem;
@@ -400,78 +518,6 @@ var BotIcon = /* @__PURE__ */ __name(() => {
400
518
  ));
401
519
  }, "BotIcon");
402
520
 
403
- // src/i18n/en.json
404
- var en_default = {
405
- CHATBOT_NAME: "IBTI Chatbot (Beta)",
406
- STATUS: {
407
- ONLINE: "Now online",
408
- LOADING: "Loading...",
409
- WRITING: "Writing answer...",
410
- UNAVAILABLE: "Unavailable"
411
- },
412
- ERRORS: {
413
- UNKNOWN: "Sorry. We couldn't provide a response."
414
- },
415
- INPUT_PLACEHOLDER: "Ask something",
416
- CHATBOT_BAR: {
417
- OPEN: "Open {{CHATBOT_NAME}}",
418
- CLOSE: "Close {{CHATBOT_NAME}}"
419
- },
420
- SUGGESTED_QUESTIONS: {
421
- TITLE: "You may like to ask:",
422
- LOADING: "Loading suggested questions..."
423
- },
424
- CHAT_FEEDBACK: {
425
- TITLE: "Rate the Chatbot",
426
- DESCRIPTION: "Give us a feedback about our bot assistant.",
427
- MESSAGE_FIELD: "Description",
428
- SUBMIT_BUTTON: "Send",
429
- CLOSE_BUTTON: "Close"
430
- }
431
- };
432
-
433
- // src/i18n/pt_BR.json
434
- var pt_BR_default = {
435
- CHATBOT_NAME: "Assistente da IBTI (Beta)",
436
- STATUS: {
437
- ONLINE: "Ativo agora",
438
- LOADING: "Carregando...",
439
- WRITING: "Escrevendo resposta...",
440
- UNAVAILABLE: "Indispon\xEDvel"
441
- },
442
- ERRORS: {
443
- UNKNOWN: "Desculpe. N\xE3o conseguimos fornecer uma resposta."
444
- },
445
- INPUT_PLACEHOLDER: "Pergunte alguma coisa",
446
- CHATBOT_BAR: {
447
- OPEN: "Abrir Assistente da IBTI",
448
- CLOSE: "Fechar Assistente da IBTI"
449
- },
450
- SUGGESTED_QUESTIONS: {
451
- TITLE: "Voc\xEA pode querer perguntar:",
452
- LOADING: "Carregando perguntas sugeridas..."
453
- },
454
- CHAT_FEEDBACK: {
455
- TITLE: "Avalie nosso Assistente",
456
- DESCRIPTION: "D\xEA-nos um feedback sobre o nosso assistente virtual.",
457
- MESSAGE_FIELD: "Descri\xE7\xE3o",
458
- SUBMIT_BUTTON: "Enviar",
459
- CLOSE_BUTTON: "Fechar"
460
- }
461
- };
462
-
463
- // src/i18n/index.ts
464
- var i18n = {
465
- en: en_default,
466
- "pt-BR": pt_BR_default
467
- };
468
-
469
- // src/hooks/useI18n.ts
470
- var useI18n = /* @__PURE__ */ __name(() => {
471
- const { locale } = useChatbot();
472
- return i18n[locale];
473
- }, "useI18n");
474
-
475
521
  // src/components/ChatbotStatusLabel/index.tsx
476
522
  import React5 from "react";
477
523
 
@@ -515,9 +561,19 @@ var ChatbotStatusLabel = /* @__PURE__ */ __name(({}) => {
515
561
  var ChatbotStatusLabel_default = ChatbotStatusLabel;
516
562
 
517
563
  // src/components/ChatbotHeader/index.tsx
518
- var ChatbotHeader = /* @__PURE__ */ __name(({}) => {
564
+ import { Button } from "@ibti-tech/ui";
565
+ var ChatbotHeader = /* @__PURE__ */ __name(({ chatFeedbackBox }) => {
519
566
  const i18n2 = useI18n();
520
- return /* @__PURE__ */ React6.createElement(Wrapper2, null, /* @__PURE__ */ React6.createElement(ProfileImage, null, /* @__PURE__ */ React6.createElement(BotIcon, null)), /* @__PURE__ */ React6.createElement(ProfileInfo, null, /* @__PURE__ */ React6.createElement(Name, null, i18n2.CHATBOT_NAME), /* @__PURE__ */ React6.createElement(ChatbotStatusLabel_default, null)));
567
+ return /* @__PURE__ */ React6.createElement(Wrapper2, null, /* @__PURE__ */ React6.createElement(ProfileImage, null, /* @__PURE__ */ React6.createElement(BotIcon, null)), /* @__PURE__ */ React6.createElement(ProfileInfo, null, /* @__PURE__ */ React6.createElement(Name, null, i18n2.CHATBOT_NAME), /* @__PURE__ */ React6.createElement(ChatbotStatusLabel_default, null)), /* @__PURE__ */ React6.createElement(
568
+ Button,
569
+ {
570
+ label: i18n2.CHAT_FEEDBACK.RATE,
571
+ onClick: chatFeedbackBox.open,
572
+ size: "small",
573
+ layer: 2,
574
+ variant: "layerBased"
575
+ }
576
+ ));
521
577
  }, "ChatbotHeader");
522
578
  var ChatbotHeader_default = ChatbotHeader;
523
579
 
@@ -555,6 +611,8 @@ var Balloon = styled5.div`
555
611
  border-radius: ${(props) => props.theme.borderRadius.medium};
556
612
  position: relative;
557
613
  line-height: 1.5em;
614
+ display: flex;
615
+ gap: ${(props) => props.theme.spacing.components.small};
558
616
 
559
617
  &::after {
560
618
  position: absolute;
@@ -564,13 +622,17 @@ var Balloon = styled5.div`
564
622
  border-style: solid;
565
623
  }
566
624
 
567
- ${({ $type }) => {
625
+ ${({ $type, $error }) => {
568
626
  switch ($type) {
569
627
  case "received":
570
628
  return css2`
571
629
  background: ${(props) => props.theme.colors.layers[2].background};
572
630
  border-top-left-radius: 0;
573
631
 
632
+ ${$error && css2`
633
+ color: ${(props) => props.theme.colors.palette.error.normal};
634
+ `}
635
+
574
636
  &::after {
575
637
  border-width: 0px 10px 10px 0;
576
638
  border-color: transparent
@@ -596,7 +658,6 @@ var Balloon = styled5.div`
596
658
  `;
597
659
  }
598
660
  }}
599
-
600
661
  // Markdown styles
601
662
 
602
663
  display: flex;
@@ -645,6 +706,7 @@ var formatMessageTime = /* @__PURE__ */ __name((dateUTC, currentDateUTC, locale)
645
706
 
646
707
  // src/components/MessageBalloon/index.tsx
647
708
  import Markdown from "react-markdown";
709
+ import { CircleExclamationIcon } from "@ibti-tech/ui";
648
710
  var messageTypes = {
649
711
  assistant: "received",
650
712
  user: "sent"
@@ -656,7 +718,7 @@ var MessageBalloon = /* @__PURE__ */ __name(({
656
718
  const messageType = messageTypes[data.role];
657
719
  const i18n2 = useI18n();
658
720
  const { locale } = useChatbot_default();
659
- return /* @__PURE__ */ React7.createElement(Wrapper5, { $type: messageType }, data.role == "assistant" && /* @__PURE__ */ React7.createElement(Label, null, i18n2.CHATBOT_NAME), /* @__PURE__ */ React7.createElement(Balloon, { $type: messageType }, /* @__PURE__ */ React7.createElement(Markdown, null, data.content)), /* @__PURE__ */ React7.createElement(Time, null, formatMessageTime(data.timestamp, currentDateUTC, locale)));
721
+ return /* @__PURE__ */ React7.createElement(Wrapper5, { $type: messageType }, data.role == "assistant" && /* @__PURE__ */ React7.createElement(Label, null, i18n2.CHATBOT_NAME), /* @__PURE__ */ React7.createElement(Balloon, { $type: messageType, $error: data.error }, data.error && /* @__PURE__ */ React7.createElement(CircleExclamationIcon, null), /* @__PURE__ */ React7.createElement(Markdown, null, data.content)), /* @__PURE__ */ React7.createElement(Time, null, formatMessageTime(data.timestamp, currentDateUTC, locale)));
660
722
  }, "MessageBalloon");
661
723
  var MessageBalloon_default = MessageBalloon;
662
724
 
@@ -732,9 +794,9 @@ var useUpdatedTime = /* @__PURE__ */ __name(({
732
794
  import React8 from "react";
733
795
 
734
796
  // src/components/SuggestedQuestions/styles.ts
735
- import { Button } from "@ibti-tech/ui";
797
+ import { Button as Button2 } from "@ibti-tech/ui";
736
798
  import { styled as styled6 } from "styled-components";
737
- var QuestionButton = styled6(Button)`
799
+ var QuestionButton = styled6(Button2)`
738
800
  text-align: left;
739
801
  justify-content: flex-start;
740
802
  height: auto;
@@ -831,7 +893,12 @@ var Wrapper7 = styled7.div`
831
893
  `;
832
894
 
833
895
  // src/components/ChatbotFooter/index.tsx
834
- import { ArrowRightIcon, Spinner, TextInput } from "@ibti-tech/ui";
896
+ import {
897
+ ArrowUpIcon,
898
+ IconButton,
899
+ Spinner,
900
+ TextArea
901
+ } from "@ibti-tech/ui";
835
902
  var ChatbotFooter = /* @__PURE__ */ __name(({}) => {
836
903
  const { makeQuestion, loading, writing, suggestedQuestions } = useChatbot_default();
837
904
  const [questionInput, setQuestionInput] = useState6("");
@@ -842,20 +909,24 @@ var ChatbotFooter = /* @__PURE__ */ __name(({}) => {
842
909
  await makeQuestion(questionInput);
843
910
  }, "handleSubmit");
844
911
  return /* @__PURE__ */ React10.createElement(Wrapper7, { "data-testid": "chatbot-footer" }, suggestedQuestions.loading && /* @__PURE__ */ React10.createElement(LoadingSuggestedQuestions, null, /* @__PURE__ */ React10.createElement(Spinner, { size: "extra-small" }), i18nTerms.SUGGESTED_QUESTIONS.LOADING), /* @__PURE__ */ React10.createElement(Form, { onSubmit: handleSubmit }, /* @__PURE__ */ React10.createElement(
845
- TextInput,
912
+ TextArea,
846
913
  {
847
914
  fillWidth: true,
848
- shape: "pill",
849
915
  disabled: loading || writing,
850
916
  value: questionInput,
851
917
  onChange: (e) => setQuestionInput(e.target.value),
852
918
  placeholder: i18nTerms.INPUT_PLACEHOLDER,
853
- button: {
854
- icon: loading || writing ? void 0 : ArrowRightIcon,
855
- loading,
856
- disabled: loading || writing || !questionInput,
857
- type: "submit"
858
- }
919
+ className: "textareaField",
920
+ rows: 1,
921
+ layer: 2
922
+ }
923
+ ), /* @__PURE__ */ React10.createElement(
924
+ IconButton,
925
+ {
926
+ icon: ArrowUpIcon,
927
+ loading,
928
+ disabled: loading || writing || !questionInput,
929
+ type: "submit"
859
930
  }
860
931
  )));
861
932
  }, "ChatbotFooter");
@@ -903,8 +974,8 @@ var ChatbotToggle = /* @__PURE__ */ __name(() => {
903
974
  var ChatbotToggle_default = ChatbotToggle;
904
975
 
905
976
  // src/components/ChatUserFeedbackRating/index.tsx
906
- import React12, { useState as useState8 } from "react";
907
- import { Button as Button2, RatingStars, TextArea } from "@ibti-tech/ui";
977
+ import React12, { useState as useState7 } from "react";
978
+ import { Button as Button4, RatingStars, TextArea as TextArea2 } from "@ibti-tech/ui";
908
979
 
909
980
  // src/components/ChatUserFeedbackRating/styles.ts
910
981
  import { CardBase } from "@ibti-tech/ui";
@@ -961,55 +1032,13 @@ var Wrapper8 = styled9.div`
961
1032
  `}
962
1033
  `;
963
1034
 
964
- // src/contexts/Chatbot/useChatFeedbackBox.ts
965
- import { useEffect as useEffect6, useState as useState7 } from "react";
966
- var useChatFeedbackBox = /* @__PURE__ */ __name(() => {
967
- const { chatMessages, apiURL, locale } = useChatbot_default();
968
- const [rated, setRated] = useState7(false);
969
- const [opened, setOpened] = useState7(false);
970
- const [loading, setLoading] = useState7(false);
971
- useEffect6(() => {
972
- if (chatMessages.length > 6 && !rated) setOpened(true);
973
- }, [chatMessages]);
974
- const close = /* @__PURE__ */ __name(() => {
975
- setOpened(false);
976
- setRated(true);
977
- }, "close");
978
- const sendUserRating = /* @__PURE__ */ __name(async ({
979
- ratingScore,
980
- description
981
- }) => {
982
- try {
983
- setLoading(true);
984
- await sendUserChatFeedback({
985
- apiURL,
986
- chatContext: chatMessages.map((item) => ({
987
- role: item.role,
988
- content: item.content
989
- })),
990
- locale,
991
- ratingScore,
992
- description
993
- });
994
- } finally {
995
- setLoading(false);
996
- setRated(true);
997
- setOpened(false);
998
- }
999
- }, "sendUserRating");
1000
- return {
1001
- opened,
1002
- close,
1003
- sendUserRating,
1004
- loading
1005
- };
1006
- }, "useChatFeedbackBox");
1007
-
1008
1035
  // src/components/ChatUserFeedbackRating/index.tsx
1009
- var ChatUserFeedbackRating = /* @__PURE__ */ __name(({}) => {
1010
- const chatFeedbackBox = useChatFeedbackBox();
1011
- const [ratingValue, setRatingValue] = useState8(5);
1012
- const [descriptionValue, setDescriptionValue] = useState8("");
1036
+ var ChatUserFeedbackRating = /* @__PURE__ */ __name(({
1037
+ chatFeedbackBox
1038
+ }) => {
1039
+ const chatbot = useChatbot_default();
1040
+ const [ratingValue, setRatingValue] = useState7(5);
1041
+ const [descriptionValue, setDescriptionValue] = useState7("");
1013
1042
  const i18nTerms = useI18n();
1014
1043
  const handleSubmit = /* @__PURE__ */ __name((e) => {
1015
1044
  e.preventDefault();
@@ -1018,7 +1047,7 @@ var ChatUserFeedbackRating = /* @__PURE__ */ __name(({}) => {
1018
1047
  ratingScore: ratingValue
1019
1048
  });
1020
1049
  }, "handleSubmit");
1021
- return /* @__PURE__ */ React12.createElement(Wrapper8, { $opened: chatFeedbackBox.opened }, /* @__PURE__ */ React12.createElement(Box, null, /* @__PURE__ */ React12.createElement(Title2, null, i18nTerms.CHAT_FEEDBACK.TITLE), /* @__PURE__ */ React12.createElement(Description, null, i18nTerms.CHAT_FEEDBACK.DESCRIPTION), /* @__PURE__ */ React12.createElement(Form2, { onSubmit: handleSubmit }, /* @__PURE__ */ React12.createElement(
1050
+ return /* @__PURE__ */ React12.createElement(Wrapper8, { $opened: chatFeedbackBox.opened && chatbot.opened }, /* @__PURE__ */ React12.createElement(Box, null, /* @__PURE__ */ React12.createElement(Title2, null, i18nTerms.CHAT_FEEDBACK.TITLE), /* @__PURE__ */ React12.createElement(Description, null, i18nTerms.CHAT_FEEDBACK.DESCRIPTION), /* @__PURE__ */ React12.createElement(Form2, { onSubmit: handleSubmit }, /* @__PURE__ */ React12.createElement(
1022
1051
  RatingStars,
1023
1052
  {
1024
1053
  value: ratingValue,
@@ -1026,7 +1055,7 @@ var ChatUserFeedbackRating = /* @__PURE__ */ __name(({}) => {
1026
1055
  layer: 2
1027
1056
  }
1028
1057
  ), /* @__PURE__ */ React12.createElement(
1029
- TextArea,
1058
+ TextArea2,
1030
1059
  {
1031
1060
  layer: 2,
1032
1061
  placeholder: i18nTerms.CHAT_FEEDBACK.MESSAGE_FIELD,
@@ -1035,7 +1064,7 @@ var ChatUserFeedbackRating = /* @__PURE__ */ __name(({}) => {
1035
1064
  onChange: (e) => setDescriptionValue(e.target.value)
1036
1065
  }
1037
1066
  ), /* @__PURE__ */ React12.createElement(ActionButtons, null, /* @__PURE__ */ React12.createElement(
1038
- Button2,
1067
+ Button4,
1039
1068
  {
1040
1069
  onClick: chatFeedbackBox.close,
1041
1070
  label: i18nTerms.CHAT_FEEDBACK.CLOSE_BUTTON,
@@ -1043,7 +1072,7 @@ var ChatUserFeedbackRating = /* @__PURE__ */ __name(({}) => {
1043
1072
  variant: "layerBased"
1044
1073
  }
1045
1074
  ), /* @__PURE__ */ React12.createElement(
1046
- Button2,
1075
+ Button4,
1047
1076
  {
1048
1077
  type: "submit",
1049
1078
  label: i18nTerms.CHAT_FEEDBACK.SUBMIT_BUTTON,
@@ -1053,10 +1082,59 @@ var ChatUserFeedbackRating = /* @__PURE__ */ __name(({}) => {
1053
1082
  )))));
1054
1083
  }, "ChatUserFeedbackRating");
1055
1084
 
1085
+ // src/contexts/Chatbot/useChatFeedbackBox.ts
1086
+ import { useEffect as useEffect6, useState as useState8 } from "react";
1087
+ var useChatFeedbackBox = /* @__PURE__ */ __name(() => {
1088
+ const { chatMessages, apiURL, locale } = useChatbot_default();
1089
+ const [rated, setRated] = useState8(false);
1090
+ const [opened, setOpened] = useState8(false);
1091
+ const [loading, setLoading] = useState8(false);
1092
+ useEffect6(() => {
1093
+ if (chatMessages.length > 6 && !rated) setOpened(true);
1094
+ }, [chatMessages]);
1095
+ const open = /* @__PURE__ */ __name(() => {
1096
+ setOpened(true);
1097
+ }, "open");
1098
+ const close = /* @__PURE__ */ __name(() => {
1099
+ setOpened(false);
1100
+ setRated(true);
1101
+ }, "close");
1102
+ const sendUserRating = /* @__PURE__ */ __name(async ({
1103
+ ratingScore,
1104
+ description
1105
+ }) => {
1106
+ try {
1107
+ setLoading(true);
1108
+ await sendUserChatFeedback({
1109
+ apiURL,
1110
+ chatContext: chatMessages.map((item) => ({
1111
+ role: item.role,
1112
+ content: item.content
1113
+ })),
1114
+ locale,
1115
+ ratingScore,
1116
+ description
1117
+ });
1118
+ } finally {
1119
+ setLoading(false);
1120
+ setRated(true);
1121
+ setOpened(false);
1122
+ }
1123
+ }, "sendUserRating");
1124
+ return {
1125
+ opened,
1126
+ open,
1127
+ close,
1128
+ sendUserRating,
1129
+ loading
1130
+ };
1131
+ }, "useChatFeedbackBox");
1132
+
1056
1133
  // src/components/ChatbotDevice/index.tsx
1057
1134
  var ChatbotDevice = /* @__PURE__ */ __name(({}) => {
1058
1135
  const { opened } = useChatbot_default();
1059
- return /* @__PURE__ */ React13.createElement(Wrapper, { $opened: opened }, /* @__PURE__ */ React13.createElement(ChatUserFeedbackRating, null), /* @__PURE__ */ React13.createElement(ChatbotHeader_default, null), /* @__PURE__ */ React13.createElement(ChatbotBody_default, null), /* @__PURE__ */ React13.createElement(ChatbotFooter_default, null), /* @__PURE__ */ React13.createElement(ChatbotToggle_default, null));
1136
+ const chatFeedbackBox = useChatFeedbackBox();
1137
+ return /* @__PURE__ */ React13.createElement(Wrapper, { $opened: opened }, /* @__PURE__ */ React13.createElement(ChatUserFeedbackRating, { chatFeedbackBox }), /* @__PURE__ */ React13.createElement(ChatbotHeader_default, { chatFeedbackBox }), /* @__PURE__ */ React13.createElement(ChatbotBody_default, null), /* @__PURE__ */ React13.createElement(ChatbotFooter_default, null), /* @__PURE__ */ React13.createElement(ChatbotToggle_default, null));
1060
1138
  }, "ChatbotDevice");
1061
1139
  var ChatbotDevice_default = ChatbotDevice;
1062
1140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibti-tech/chatbot",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Chatbot developed for ibti products",
5
5
  "main": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "@ibti-tech/prettier-config": "^0.1.6",
44
44
  "@ibti-tech/tsconfig": "^0.0.3",
45
- "@ibti-tech/ui": "^0.16.2",
45
+ "@ibti-tech/ui": "^0.16.4",
46
46
  "@testing-library/react": "^15.0.7",
47
47
  "@types/react": "^18.3.2",
48
48
  "@types/uuid": "^9.0.8",