quickblox-react-ui-kit 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/CommonTypes/FunctionResult.d.ts +5 -1
  2. package/dist/Data/DefaultConfigurations.d.ts +2 -2
  3. package/dist/Domain/use_cases/ai/AIAnswerAssistUseCase.d.ts +13 -0
  4. package/dist/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.d.ts +13 -0
  5. package/dist/Domain/use_cases/ai/AITranslateUseCase.d.ts +14 -0
  6. package/dist/Domain/use_cases/ai/AITranslateWithProxyUseCase.d.ts +14 -0
  7. package/dist/Presentation/Views/Base/BaseViewModel.d.ts +2 -0
  8. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.d.ts +4 -1
  9. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.d.ts +3 -2
  10. package/dist/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.d.ts +5 -13
  11. package/dist/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.d.ts +7 -0
  12. package/dist/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.d.ts +7 -0
  13. package/dist/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.d.ts +3 -1
  14. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.d.ts +7 -0
  15. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.d.ts +7 -0
  16. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.d.ts +8 -0
  17. package/dist/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.d.ts +7 -0
  18. package/dist/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.d.ts +4 -0
  19. package/dist/QBconfig.d.ts +14 -3
  20. package/dist/index-ui.js +316 -33
  21. package/dist/utils/utils.d.ts +9 -0
  22. package/global.d.ts +12 -4
  23. package/package.json +5 -1
  24. package/src/CommonTypes/FunctionResult.ts +6 -1
  25. package/src/Data/DefaultConfigurations.ts +155 -19
  26. package/src/Domain/use_cases/ai/AIAnswerAssistUseCase.ts +69 -0
  27. package/src/Domain/use_cases/ai/AIAnswerAssistWithProxyUseCase.ts +71 -0
  28. package/src/Domain/use_cases/ai/AIRephraseUseCase.ts +38 -36
  29. package/src/Domain/use_cases/ai/AIRephraseWithProxyUseCase.ts +25 -21
  30. package/src/Domain/use_cases/ai/AITranslateUseCase.ts +76 -0
  31. package/src/Domain/use_cases/ai/AITranslateWithProxyUseCase.ts +79 -0
  32. package/src/Presentation/Views/Base/BaseViewModel.ts +2 -0
  33. package/src/Presentation/Views/Dialogs/Dialogs.tsx +1 -1
  34. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIMessageWidget.ts +7 -2
  35. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/AIWidgetActions/AIWidgetActions.tsx +10 -4
  36. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/Tone.ts +29 -15
  37. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidget.tsx +10 -6
  38. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIAssistAnswerWidgetWithProxy.tsx +10 -6
  39. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidget.tsx +17 -0
  40. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAIRephraseMessageWidgetWithProxy.tsx +16 -0
  41. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidget.tsx +13 -12
  42. package/src/Presentation/components/UI/Dialogs/MessagesView/AIWidgets/UseDefaultAITranslateWidgetWithProxy.tsx +13 -12
  43. package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.scss +76 -0
  44. package/src/Presentation/components/UI/Dialogs/MessagesView/DefaultAttachmentComponent/DefaultAttachmentComponent.tsx +34 -0
  45. package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.scss +26 -0
  46. package/src/Presentation/components/UI/Dialogs/MessagesView/ErrorToast/ErrorToast.tsx +25 -0
  47. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.scss +4 -6
  48. package/src/Presentation/components/UI/Dialogs/MessagesView/InComingMessage/InComingMessage.tsx +93 -405
  49. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.scss +2 -3
  50. package/src/Presentation/components/UI/Dialogs/MessagesView/MessagesView.tsx +561 -400
  51. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.scss +62 -0
  52. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewAudioFile/PreviewAudioFile.tsx +25 -0
  53. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.scss +61 -0
  54. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDefaultFile/PreviewDefaultFile.tsx +32 -0
  55. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.scss +2 -2
  56. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewDialog.tsx +50 -2
  57. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.scss +40 -0
  58. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewImageFile/PreviewImageFile.tsx +26 -0
  59. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.scss +62 -0
  60. package/src/Presentation/components/UI/Dialogs/PreviewDialog/PreviewVideoFile/PreviewVideoFile.tsx +25 -0
  61. package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.svg +5 -0
  62. package/src/Presentation/components/UI/svgs/Icons/AIWidgets/BotIcon/BotIcon.tsx +50 -0
  63. package/src/Presentation/components/layouts/Desktop/QuickBloxUIKitDesktopLayout.tsx +3 -15
  64. package/src/Presentation/components/providers/QuickBloxUIKitProvider/useQbInitializedDataContext.ts +15 -14
  65. package/src/QBconfig.ts +156 -10
  66. package/src/package_artan_react_ui.json +13 -9
  67. package/src/package_original.json +5 -1
  68. package/src/utils/utils.ts +63 -0
@@ -1,5 +1,7 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import './MessagesView.scss';
3
+ import { QBAIRephrase } from 'qb-ai-rephrase';
4
+ import { Tone } from 'qb-ai-rephrase/src/Tone';
3
5
  import { DialogEntity } from '../../../../../Domain/entity/DialogEntity';
4
6
  import useQBConnection from '../../../providers/QuickBloxUIKitProvider/useQBConnection';
5
7
  import ScrollableContainer from '../../../containers/ScrollableContainer/ScrollableContainer';
@@ -44,10 +46,8 @@ import UiKitTheme from '../../../../assets/UiKitTheme';
44
46
  import { AIMessageWidget } from './AIWidgets/AIMessageWidget';
45
47
  import { DialogsViewModel } from '../../../../Views/Dialogs/DialogViewModel';
46
48
  import { HighLightLink, messageHasUrls } from './HighLightLink/HighLightLink';
47
- import { loopToLimitTokens } from '../../../../../utils/utils';
48
49
  import { OutGoingMessage } from './OutGoingMessage/OutGoingMessage';
49
50
  import { InComingMessage } from './InComingMessage/InComingMessage';
50
- import { Tone } from './AIWidgets/Tone';
51
51
  import NecktieIcon from '../../svgs/Icons/AIWidgets/NecktieIcon';
52
52
  import HandshakeIcon from '../../svgs/Icons/AIWidgets/HandshakeIcon';
53
53
  import WhiteCheckMarkIcon from '../../svgs/Icons/AIWidgets/WhiteCheckMarkIcon';
@@ -60,11 +60,13 @@ import PointUpIcon from '../../svgs/Icons/AIWidgets/PointUpIcon';
60
60
  import SmirkIcon from '../../svgs/Icons/AIWidgets/SmirkIcon';
61
61
  import PerformingArtsIcon from '../../svgs/Icons/AIWidgets/PerformingArtsIcon';
62
62
  import { FunctionTypeVoidToVoid } from '../../../../Views/Base/BaseViewModel';
63
- import { IChatMessage } from '../../../../../Data/source/AISource';
64
- import AIWidgetActions from './AIWidgets/AIWidgetActions/AIWidgetActions';
63
+ import AIWidgetActions, {
64
+ MenuItem,
65
+ } from './AIWidgets/AIWidgetActions/AIWidgetActions';
65
66
  import ToneIcon from '../../svgs/Icons/Actions/Tone';
66
- // import ToneIcon from '../../svgs/Icons/Actions/Tone';
67
- // import AIWidgetActions from './AIWidgets/AIWidgetActions/AIWidgetActions';
67
+ import DefaultAttachmentComponent from './DefaultAttachmentComponent/DefaultAttachmentComponent';
68
+ import { AIUtils } from '../../../../../utils/utils';
69
+ import { ErrorToast } from './ErrorToast/ErrorToast';
68
70
 
69
71
  type HeaderDialogsMessagesProps = {
70
72
  AIRephrase?: AIMessageWidget;
@@ -114,32 +116,18 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
114
116
  const [messagesToView, setMessagesToView] = React.useState<MessageEntity[]>(
115
117
  [],
116
118
  );
119
+ const [showErrorToast, setShowErrorToast] = useState<boolean>(true);
120
+ const [messageErrorToast, setMessageErrorToast] = useState<string>('');
117
121
 
118
122
  const [waitAIWidget, setWaitAIWidget] = useState<boolean>(false);
119
- const messageEntitiesToIChatMessageCollection = (
120
- messageEntities: MessageEntity[],
121
- ): IChatMessage[] => {
122
- const MAX_TOKENS = 3584;
123
- const items = messageEntities.filter(
124
- (it) =>
125
- !it.notification_type ||
126
- (it.notification_type && it.notification_type.length === 0),
127
- );
128
- const messages = loopToLimitTokens(
129
- MAX_TOKENS,
130
- items,
131
- ({ message }) => message || '',
132
- ).reverse();
133
- const chatCompletionMessages: IChatMessage[] = messages.map(
134
- ({ message, sender_id }) => ({
135
- role: sender_id === currentUserId ? 'user' : 'assistant',
136
- content: message,
137
- }),
138
- );
123
+ const [prevTextMessage, setPrevTextMessage] = useState<string>('');
139
124
 
140
- //
141
- return chatCompletionMessages;
142
- };
125
+ const maxTokensForAIRephrase =
126
+ currentContext.InitParams.qbConfig.configAIApi.AIRephraseWidgetConfig
127
+ .maxTokens;
128
+
129
+ const rephraseTones: Tone[] =
130
+ currentContext.InitParams.qbConfig.configAIApi.AIRephraseWidgetConfig.Tones;
143
131
 
144
132
  const messagesViewModel: MessagesViewModel = useMessagesViewModel(
145
133
  dialogsViewModel.entity?.type,
@@ -148,6 +136,15 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
148
136
 
149
137
  const { maxFileSize } = currentContext.InitParams;
150
138
 
139
+ useEffect(() => {
140
+ if (showErrorToast) {
141
+ setTimeout(() => {
142
+ setShowErrorToast(false);
143
+ setMessageErrorToast('');
144
+ }, 1800);
145
+ }
146
+ }, [showErrorToast]);
147
+
151
148
  useEffect(() => {
152
149
  console.log('HAVE NEW DIALOG');
153
150
  // messagesViewModel.getMessages(new Pagination());
@@ -282,7 +279,11 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
282
279
  let messageContent: JSX.Element = messageText;
283
280
 
284
281
  const attachmentContentRender = (att: ChatMessageAttachmentEntity) => {
285
- let contentPlaceHolder: JSX.Element = <div>{att.type.toString()}</div>;
282
+ // let contentPlaceHolder: JSX.Element = <div>{att.type.toString()}</div>;
283
+
284
+ let contentPlaceHolder: JSX.Element = (
285
+ <DefaultAttachmentComponent fileName={att.file?.name || ''} />
286
+ );
286
287
 
287
288
  if (att.type.toString().includes(FileType.video)) {
288
289
  contentPlaceHolder = att.file ? (
@@ -307,9 +308,10 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
307
308
  }
308
309
  if (att.type.toString().includes(FileType.text)) {
309
310
  contentPlaceHolder = att.file ? (
310
- <div>TEXT</div>
311
+ // <div>TEXT</div>
312
+ <DefaultAttachmentComponent fileName={att.file.name || ''} />
311
313
  ) : (
312
- <ImageFile applyZoom />
314
+ <ImageFile width="24" height="24" applyZoom />
313
315
  );
314
316
  }
315
317
  let contentResult: JSX.Element = (
@@ -380,10 +382,16 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
380
382
  senderName={getSenderName(message.sender)}
381
383
  message={message}
382
384
  // element={messageContentRender(message)}
383
- onLoader={() => {
384
- // sendMessageToTranslate(message);
385
+ onStartLoader={() => {
385
386
  setWaitAIWidget(true);
386
387
  }}
388
+ onStopLoader={() => {
389
+ setWaitAIWidget(false);
390
+ }}
391
+ onErrorToast={(messageError) => {
392
+ setShowErrorToast(true);
393
+ setMessageErrorToast(messageError);
394
+ }}
387
395
  // renderWidget={
388
396
  // <ContextMenu
389
397
  // widgetToRender={
@@ -539,31 +547,29 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
539
547
  // eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/require-await
540
548
  const startRecording = async () => {
541
549
  if (!stream) return;
542
- // const mimeTypes = [
543
- // 'audio/aac',
544
- // 'audio/mp4',
545
- // 'audio/mpeg',
546
- // 'audio/ogg',
547
- // 'audio/wav',
548
- // 'audio/webm',
549
- // 'audio/3gpp',
550
- // 'audio/flac',
551
- // 'audio/x-aiff',
552
- // 'audio/x-m4a',
553
- // ];
554
- //
555
- // console.log('MIME TYPES: ');
556
- // mimeTypes.forEach((mimeType) => {
557
- // if (MediaRecorder.isTypeSupported(mimeType)) {
558
- // console.log(`${mimeType} is supported`);
559
- // } else {
560
- // console.log(`${mimeType} is not supported`);
561
- // }
562
- // });
550
+ const mimeTypes = [
551
+ 'audio/aac',
552
+ 'audio/mp4',
553
+ 'audio/mpeg',
554
+ 'audio/ogg',
555
+ 'audio/wav',
556
+ 'audio/webm',
557
+ 'audio/3gpp',
558
+ 'audio/flac',
559
+ 'audio/x-aiff',
560
+ 'audio/x-m4a',
561
+ ];
562
+
563
+ console.log('MIME TYPES: ');
564
+ mimeTypes.forEach((mType) => {
565
+ if (MediaRecorder.isTypeSupported(mimeType)) {
566
+ console.log(`${mType} is supported`);
567
+ } else {
568
+ console.log(`${mType} is not supported`);
569
+ }
570
+ });
563
571
  // audio/mp4;codecs=mp4a audio/webm;codecs=opus audio/webm;codecs=vp9,opus
564
- const mimeContent = window.MediaRecorder.isTypeSupported(
565
- 'audio/mp4;codecs=mp4a',
566
- )
572
+ const mimeContent = window.MediaRecorder.isTypeSupported('audio/mp4')
567
573
  ? 'audio/mp4;codecs=mp4a'
568
574
  : 'audio/webm;codecs=opus';
569
575
 
@@ -604,7 +610,8 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
604
610
  // const mp4Blob = new Blob(recordedChunks, { type: 'video/mp4' });
605
611
 
606
612
  // const audioBlob = new Blob(audioChunks, { type: 'video/mp4' }); // mimeType
607
- const audioBlob = new Blob(audioChunks, { type: 'audio/mp4' }); // mimeType
613
+ // const audioBlob = new Blob(audioChunks, { type: 'audio/mp4' }); // mimeType
614
+ const audioBlob = new Blob(audioChunks, { type: 'audio/mp4' });
608
615
 
609
616
  setResultAudioBlob(audioBlob);
610
617
 
@@ -754,163 +761,493 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
754
761
  const useUpContent = upHeaderContent || false;
755
762
 
756
763
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
764
+ // function getAIEditingMessagesItems() {
765
+ // return [
766
+ // {
767
+ // title: 'Professional Tone',
768
+ // icon: <NecktieIcon />,
769
+ // action: () => {
770
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
771
+ // setWaitAIWidget(true);
772
+ // AIRephrase?.textToWidget(
773
+ // messageText,
774
+ // AIUtils.messageEntitiesToIChatMessageCollection(
775
+ // messagesToView,
776
+ // currentUserId,
777
+ // maxTokensForAIRephrase,
778
+ // ),
779
+ // {
780
+ // tone: QBAIRephrase.defaultTones()[0],
781
+ // // tone: {
782
+ // // name: 'Professional Tone',
783
+ // // description: '',
784
+ // // iconEmoji: '',
785
+ // // },
786
+ // },
787
+ // )
788
+ // .then((answerText) => {
789
+ // // eslint-disable-next-line promise/always-return
790
+ // if (answerText === 'Rephrase failed.') {
791
+ // setMessageErrorToast('Rephrase failed.');
792
+ // setShowErrorToast(true);
793
+ // }
794
+ // setWaitAIWidget(false);
795
+ // })
796
+ // .catch(() => {
797
+ // setMessageErrorToast('Rephrase failed.');
798
+ // setShowErrorToast(true);
799
+ // setWaitAIWidget(false);
800
+ // });
801
+ // }
802
+ // },
803
+ // },
804
+ // {
805
+ // title: 'Friendly Tone',
806
+ // icon: <HandshakeIcon />,
807
+ // action: () => {
808
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
809
+ // setWaitAIWidget(true);
810
+ // AIRephrase?.textToWidget(
811
+ // messageText,
812
+ // AIUtils.messageEntitiesToIChatMessageCollection(
813
+ // messagesToView,
814
+ // currentUserId,
815
+ // maxTokensForAIRephrase,
816
+ // ),
817
+ // {
818
+ // // tone: { name: 'Friendly Tone', description: '', iconEmoji: '' },
819
+ // tone: QBAIRephrase.defaultTones()[1],
820
+ // },
821
+ // )
822
+ // .then((answerText) => {
823
+ // // eslint-disable-next-line promise/always-return
824
+ // if (answerText === 'Rephrase failed.') {
825
+ // setMessageErrorToast('Rephrase failed.');
826
+ // setShowErrorToast(true);
827
+ // }
828
+ // setWaitAIWidget(false);
829
+ // })
830
+ // .catch(() => {
831
+ // setMessageErrorToast('Rephrase failed.');
832
+ // setShowErrorToast(true);
833
+ // setWaitAIWidget(false);
834
+ // });
835
+ // }
836
+ // },
837
+ // },
838
+ // {
839
+ // title: 'Encouraging Tone',
840
+ // icon: <MuscleIcon />,
841
+ // action: () => {
842
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
843
+ // setWaitAIWidget(true);
844
+ // AIRephrase?.textToWidget(
845
+ // messageText,
846
+ // AIUtils.messageEntitiesToIChatMessageCollection(
847
+ // messagesToView,
848
+ // currentUserId,
849
+ // maxTokensForAIRephrase,
850
+ // ),
851
+ // {
852
+ // tone: QBAIRephrase.defaultTones()[2],
853
+ // // tone: {
854
+ // // name: 'Encouraging Tone',
855
+ // // description: '',
856
+ // // iconEmoji: '',
857
+ // // },
858
+ // },
859
+ // )
860
+ // .then((answerText) => {
861
+ // // eslint-disable-next-line promise/always-return
862
+ // if (answerText === 'Rephrase failed.') {
863
+ // setMessageErrorToast('Rephrase failed.');
864
+ // setShowErrorToast(true);
865
+ // }
866
+ // setWaitAIWidget(false);
867
+ // })
868
+ // .catch(() => {
869
+ // setMessageErrorToast('Rephrase failed.');
870
+ // setShowErrorToast(true);
871
+ // setWaitAIWidget(false);
872
+ // });
873
+ // }
874
+ // },
875
+ // },
876
+ // {
877
+ // title: 'Empathetic Tone',
878
+ // icon: <PalmsUpTogetherIcon />,
879
+ // action: () => {
880
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
881
+ // setWaitAIWidget(true);
882
+ // AIRephrase?.textToWidget(
883
+ // messageText,
884
+ // AIUtils.messageEntitiesToIChatMessageCollection(
885
+ // messagesToView,
886
+ // currentUserId,
887
+ // maxTokensForAIRephrase,
888
+ // ),
889
+ // {
890
+ // tone: QBAIRephrase.defaultTones()[3],
891
+ // // tone: {
892
+ // // name: 'Empathetic Tone',
893
+ // // description: '',
894
+ // // iconEmoji: '',
895
+ // // },
896
+ // },
897
+ // )
898
+ // .then((answerText) => {
899
+ // // eslint-disable-next-line promise/always-return
900
+ // if (answerText === 'Rephrase failed.') {
901
+ // setMessageErrorToast('Rephrase failed.');
902
+ // setShowErrorToast(true);
903
+ // }
904
+ // setWaitAIWidget(false);
905
+ // })
906
+ // .catch(() => {
907
+ // setMessageErrorToast('Rephrase failed.');
908
+ // setShowErrorToast(true);
909
+ // setWaitAIWidget(false);
910
+ // });
911
+ // }
912
+ // },
913
+ // },
914
+ // {
915
+ // title: 'Neutral Tone',
916
+ // icon: <NeutralFaceIcon />,
917
+ // action: () => {
918
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
919
+ // setWaitAIWidget(true);
920
+ // AIRephrase?.textToWidget(
921
+ // messageText,
922
+ // AIUtils.messageEntitiesToIChatMessageCollection(
923
+ // messagesToView,
924
+ // currentUserId,
925
+ // maxTokensForAIRephrase,
926
+ // ),
927
+ // {
928
+ // // tone: { name: 'Neutral Tone', description: '', iconEmoji: '' },
929
+ // tone: QBAIRephrase.defaultTones()[4],
930
+ // },
931
+ // )
932
+ // .then((answerText) => {
933
+ // // eslint-disable-next-line promise/always-return
934
+ // if (answerText === 'Rephrase failed.') {
935
+ // setMessageErrorToast('Rephrase failed.');
936
+ // setShowErrorToast(true);
937
+ // }
938
+ // setWaitAIWidget(false);
939
+ // })
940
+ // .catch(() => {
941
+ // setMessageErrorToast('Rephrase failed.');
942
+ // setShowErrorToast(true);
943
+ // setWaitAIWidget(false);
944
+ // });
945
+ // }
946
+ // },
947
+ // },
948
+ // {
949
+ // title: 'Assertive Tone',
950
+ // icon: <HammerIcon />,
951
+ // action: () => {
952
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
953
+ // setWaitAIWidget(true);
954
+ // AIRephrase?.textToWidget(
955
+ // messageText,
956
+ // AIUtils.messageEntitiesToIChatMessageCollection(
957
+ // messagesToView,
958
+ // currentUserId,
959
+ // maxTokensForAIRephrase,
960
+ // ),
961
+ // {
962
+ // tone: QBAIRephrase.defaultTones()[5],
963
+ // // tone: {
964
+ // // name: 'Assertive Tone',
965
+ // // description: '',
966
+ // // iconEmoji: '',
967
+ // // },
968
+ // },
969
+ // )
970
+ // .then((answerText) => {
971
+ // // eslint-disable-next-line promise/always-return
972
+ // if (answerText === 'Rephrase failed.') {
973
+ // setMessageErrorToast('Rephrase failed.');
974
+ // setShowErrorToast(true);
975
+ // }
976
+ // setWaitAIWidget(false);
977
+ // })
978
+ // .catch(() => {
979
+ // setMessageErrorToast('Rephrase failed.');
980
+ // setShowErrorToast(true);
981
+ // setWaitAIWidget(false);
982
+ // });
983
+ // }
984
+ // },
985
+ // },
986
+ // {
987
+ // title: 'Instructive Tone',
988
+ // icon: <BookIcon />,
989
+ // action: () => {
990
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
991
+ // setWaitAIWidget(true);
992
+ // AIRephrase?.textToWidget(
993
+ // messageText,
994
+ // AIUtils.messageEntitiesToIChatMessageCollection(
995
+ // messagesToView,
996
+ // currentUserId,
997
+ // maxTokensForAIRephrase,
998
+ // ),
999
+ // {
1000
+ // tone: QBAIRephrase.defaultTones()[6],
1001
+ // // tone: {
1002
+ // // name: 'Instructive Tone',
1003
+ // // description: '',
1004
+ // // iconEmoji: '',
1005
+ // // },
1006
+ // },
1007
+ // )
1008
+ // .then((answerText) => {
1009
+ // // eslint-disable-next-line promise/always-return
1010
+ // if (answerText === 'Rephrase failed.') {
1011
+ // setMessageErrorToast('Rephrase failed.');
1012
+ // setShowErrorToast(true);
1013
+ // }
1014
+ // setWaitAIWidget(false);
1015
+ // })
1016
+ // .catch(() => {
1017
+ // setMessageErrorToast('Rephrase failed.');
1018
+ // setShowErrorToast(true);
1019
+ // setWaitAIWidget(false);
1020
+ // });
1021
+ // }
1022
+ // },
1023
+ // },
1024
+ // {
1025
+ // title: 'Persuasive Tone',
1026
+ // icon: <PointUpIcon />,
1027
+ // action: () => {
1028
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
1029
+ // setWaitAIWidget(true);
1030
+ // AIRephrase?.textToWidget(
1031
+ // messageText,
1032
+ // AIUtils.messageEntitiesToIChatMessageCollection(
1033
+ // messagesToView,
1034
+ // currentUserId,
1035
+ // maxTokensForAIRephrase,
1036
+ // ),
1037
+ // {
1038
+ // tone: QBAIRephrase.defaultTones()[7],
1039
+ // // tone: {
1040
+ // // name: 'Persuasive Tone',
1041
+ // // description: '',
1042
+ // // iconEmoji: '',
1043
+ // // },
1044
+ // },
1045
+ // )
1046
+ // .then((answerText) => {
1047
+ // // eslint-disable-next-line promise/always-return
1048
+ // if (answerText === 'Rephrase failed.') {
1049
+ // setMessageErrorToast('Rephrase failed.');
1050
+ // setShowErrorToast(true);
1051
+ // }
1052
+ // setWaitAIWidget(false);
1053
+ // })
1054
+ // .catch(() => {
1055
+ // setMessageErrorToast('Rephrase failed.');
1056
+ // setShowErrorToast(true);
1057
+ // setWaitAIWidget(false);
1058
+ // });
1059
+ // }
1060
+ // },
1061
+ // },
1062
+ // {
1063
+ // title: 'Sarcastic/Ironic Tone',
1064
+ // icon: <SmirkIcon />,
1065
+ // action: () => {
1066
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
1067
+ // setWaitAIWidget(true);
1068
+ // AIRephrase?.textToWidget(
1069
+ // messageText,
1070
+ // AIUtils.messageEntitiesToIChatMessageCollection(
1071
+ // messagesToView,
1072
+ // currentUserId,
1073
+ // maxTokensForAIRephrase,
1074
+ // ),
1075
+ // {
1076
+ // tone: QBAIRephrase.defaultTones()[8],
1077
+ // // tone: {
1078
+ // // name: 'Sarcastic/Ironic Tone',
1079
+ // // description: '',
1080
+ // // iconEmoji: '',
1081
+ // // },
1082
+ // },
1083
+ // )
1084
+ // .then((answerText) => {
1085
+ // // eslint-disable-next-line promise/always-return
1086
+ // if (answerText === 'Rephrase failed.') {
1087
+ // setMessageErrorToast('Rephrase failed.');
1088
+ // setShowErrorToast(true);
1089
+ // }
1090
+ // setWaitAIWidget(false);
1091
+ // })
1092
+ // .catch(() => {
1093
+ // setMessageErrorToast('Rephrase failed.');
1094
+ // setShowErrorToast(true);
1095
+ // setWaitAIWidget(false);
1096
+ // });
1097
+ // }
1098
+ // },
1099
+ // },
1100
+ // {
1101
+ // title: 'Poetic Tone',
1102
+ // icon: <PerformingArtsIcon />,
1103
+ // action: () => {
1104
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
1105
+ // setWaitAIWidget(true);
1106
+ // AIRephrase?.textToWidget(
1107
+ // messageText,
1108
+ // AIUtils.messageEntitiesToIChatMessageCollection(
1109
+ // messagesToView,
1110
+ // currentUserId,
1111
+ // maxTokensForAIRephrase,
1112
+ // ),
1113
+ // {
1114
+ // tone: QBAIRephrase.defaultTones()[9],
1115
+ // // tone: { name: 'Poetic Tone', description: '', iconEmoji: '' }
1116
+ // },
1117
+ // )
1118
+ // .then((answerText) => {
1119
+ // // eslint-disable-next-line promise/always-return
1120
+ // if (answerText === 'Rephrase failed.') {
1121
+ // setMessageErrorToast('Rephrase failed.');
1122
+ // setShowErrorToast(true);
1123
+ // }
1124
+ // setWaitAIWidget(false);
1125
+ // })
1126
+ // .catch(() => {
1127
+ // setMessageErrorToast('Rephrase failed.');
1128
+ // setShowErrorToast(true);
1129
+ // setWaitAIWidget(false);
1130
+ // });
1131
+ // }
1132
+ // },
1133
+ // },
1134
+ // {
1135
+ // title: 'Back to original text',
1136
+ // icon: <WhiteCheckMarkIcon />,
1137
+ // action: () => {
1138
+ // if (messageText && messageText.length > 0 && !waitAIWidget) {
1139
+ // setWaitAIWidget(true);
1140
+ // AIRephrase?.textToWidget(
1141
+ // messageText,
1142
+ // AIUtils.messageEntitiesToIChatMessageCollection(
1143
+ // messagesToView,
1144
+ // currentUserId,
1145
+ // maxTokensForAIRephrase,
1146
+ // ),
1147
+ // {
1148
+ // tone: {
1149
+ // name: 'Unchanged',
1150
+ // description: 'Unchanged',
1151
+ // iconEmoji: '',
1152
+ // },
1153
+ // },
1154
+ // )
1155
+ // .then((answerText) => {
1156
+ // // eslint-disable-next-line promise/always-return
1157
+ // if (answerText === 'Rephrase failed.') {
1158
+ // setMessageErrorToast('Rephrase failed.');
1159
+ // setShowErrorToast(true);
1160
+ // }
1161
+ // setWaitAIWidget(false);
1162
+ // })
1163
+ // .catch(() => {
1164
+ // setMessageErrorToast('Rephrase failed.');
1165
+ // setShowErrorToast(true);
1166
+ // setWaitAIWidget(false);
1167
+ // });
1168
+ // }
1169
+ // },
1170
+ // },
1171
+ // ];
1172
+ // }
1173
+
1174
+ function getDefaultIcon(index: number) {
1175
+ const defaultIcons = [
1176
+ <NecktieIcon />,
1177
+ <HandshakeIcon />,
1178
+ <MuscleIcon />,
1179
+ <PalmsUpTogetherIcon />,
1180
+ <NeutralFaceIcon />,
1181
+ <HammerIcon />,
1182
+ <BookIcon />,
1183
+ <PointUpIcon />,
1184
+ <SmirkIcon />,
1185
+ <PerformingArtsIcon />,
1186
+ ];
1187
+
1188
+ return defaultIcons[index] || <NeutralFaceIcon />;
1189
+ }
1190
+
757
1191
  function getAIEditingMessagesItems() {
758
- return [
759
- {
760
- title: 'Professional Tone',
761
- icon: <NecktieIcon />,
762
- action: () => {
763
- if (messageText && messageText.length > 0 && !waitAIWidget) {
764
- setWaitAIWidget(true);
765
- AIRephrase?.textToWidget(
766
- messageText,
767
- messageEntitiesToIChatMessageCollection(messagesToView),
768
- { tone: Tone.Professional },
769
- );
770
- }
771
- },
772
- },
773
- {
774
- title: 'Friendly Tone',
775
- icon: <HandshakeIcon />,
776
- action: () => {
777
- if (messageText && messageText.length > 0 && !waitAIWidget) {
778
- setWaitAIWidget(true);
779
- AIRephrase?.textToWidget(
780
- messageText,
781
- messageEntitiesToIChatMessageCollection(messagesToView),
782
- { tone: Tone.Friendly },
783
- );
784
- }
785
- },
786
- },
787
- {
788
- title: 'Encouraging Tone',
789
- icon: <MuscleIcon />,
790
- action: () => {
791
- if (messageText && messageText.length > 0 && !waitAIWidget) {
792
- setWaitAIWidget(true);
793
- AIRephrase?.textToWidget(
794
- messageText,
795
- messageEntitiesToIChatMessageCollection(messagesToView),
796
- { tone: Tone.Encouraging },
797
- );
798
- }
799
- },
800
- },
801
- {
802
- title: 'Empathetic Tone',
803
- icon: <PalmsUpTogetherIcon />,
804
- action: () => {
805
- if (messageText && messageText.length > 0 && !waitAIWidget) {
806
- setWaitAIWidget(true);
807
- AIRephrase?.textToWidget(
808
- messageText,
809
- messageEntitiesToIChatMessageCollection(messagesToView),
810
- { tone: Tone.Empathetic },
811
- );
812
- }
813
- },
814
- },
815
- {
816
- title: 'Neutral Tone',
817
- icon: <NeutralFaceIcon />,
818
- action: () => {
819
- if (messageText && messageText.length > 0 && !waitAIWidget) {
820
- setWaitAIWidget(true);
821
- AIRephrase?.textToWidget(
822
- messageText,
823
- messageEntitiesToIChatMessageCollection(messagesToView),
824
- { tone: Tone.Neutral },
825
- );
826
- }
827
- },
828
- },
829
- {
830
- title: 'Assertive Tone',
831
- icon: <HammerIcon />,
832
- action: () => {
833
- if (messageText && messageText.length > 0 && !waitAIWidget) {
834
- setWaitAIWidget(true);
835
- AIRephrase?.textToWidget(
836
- messageText,
837
- messageEntitiesToIChatMessageCollection(messagesToView),
838
- { tone: Tone.Assertive },
839
- );
840
- }
841
- },
842
- },
843
- {
844
- title: 'Instructive Tone',
845
- icon: <BookIcon />,
846
- action: () => {
847
- if (messageText && messageText.length > 0 && !waitAIWidget) {
848
- setWaitAIWidget(true);
849
- AIRephrase?.textToWidget(
850
- messageText,
851
- messageEntitiesToIChatMessageCollection(messagesToView),
852
- { tone: Tone.Instructive },
853
- );
854
- }
855
- },
856
- },
857
- {
858
- title: 'Persuasive Tone',
859
- icon: <PointUpIcon />,
860
- action: () => {
861
- if (messageText && messageText.length > 0 && !waitAIWidget) {
862
- setWaitAIWidget(true);
863
- AIRephrase?.textToWidget(
864
- messageText,
865
- messageEntitiesToIChatMessageCollection(messagesToView),
866
- { tone: Tone.Persuasive },
867
- );
868
- }
869
- },
870
- },
871
- {
872
- title: 'Sarcastic/Ironic Tone',
873
- icon: <SmirkIcon />,
874
- action: () => {
875
- if (messageText && messageText.length > 0 && !waitAIWidget) {
876
- setWaitAIWidget(true);
877
- AIRephrase?.textToWidget(
878
- messageText,
879
- messageEntitiesToIChatMessageCollection(messagesToView),
880
- { tone: Tone.Sarcastic },
881
- );
882
- }
883
- },
884
- },
885
- {
886
- title: 'Poetic Tone',
887
- icon: <PerformingArtsIcon />,
888
- action: () => {
889
- if (messageText && messageText.length > 0 && !waitAIWidget) {
890
- setWaitAIWidget(true);
891
- AIRephrase?.textToWidget(
892
- messageText,
893
- messageEntitiesToIChatMessageCollection(messagesToView),
894
- { tone: Tone.Poetic },
895
- );
896
- }
897
- },
898
- },
899
- {
900
- title: 'Back to original text',
901
- icon: <WhiteCheckMarkIcon />,
902
- action: () => {
903
- if (messageText && messageText.length > 0 && !waitAIWidget) {
904
- setWaitAIWidget(true);
905
- AIRephrase?.textToWidget(
906
- messageText,
907
- messageEntitiesToIChatMessageCollection(messagesToView),
908
- { tone: Tone.Unchanged },
909
- );
910
- }
911
- },
1192
+ const items: MenuItem[] = [];
1193
+
1194
+ const tones = rephraseTones || QBAIRephrase.defaultTones();
1195
+
1196
+ for (let i = 0; i < tones.length; i += 1) {
1197
+ const tone = tones[i];
1198
+ const title = tone.name;
1199
+ const icon = getDefaultIcon(i) || <NeutralFaceIcon />;
1200
+
1201
+ const action = () => {
1202
+ if (messageText && messageText.length > 0 && !waitAIWidget) {
1203
+ setWaitAIWidget(true);
1204
+ setPrevTextMessage(messageText);
1205
+ AIRephrase?.textToWidget(
1206
+ messageText,
1207
+ AIUtils.messageEntitiesToIChatMessageCollection(
1208
+ messagesToView,
1209
+ currentUserId,
1210
+ maxTokensForAIRephrase,
1211
+ ),
1212
+ {
1213
+ tone,
1214
+ },
1215
+ )
1216
+ .then((answerText) => {
1217
+ // eslint-disable-next-line promise/always-return
1218
+ if (answerText === 'Rephrase failed.') {
1219
+ setMessageErrorToast('Rephrase failed.');
1220
+ setShowErrorToast(true);
1221
+ }
1222
+ setWaitAIWidget(false);
1223
+ })
1224
+ .catch(() => {
1225
+ setMessageErrorToast('Rephrase failed.');
1226
+ setShowErrorToast(true);
1227
+ setWaitAIWidget(false);
1228
+ });
1229
+ }
1230
+ };
1231
+
1232
+ items.push({
1233
+ title,
1234
+ icon,
1235
+ action,
1236
+ });
1237
+ }
1238
+ //
1239
+ items.push({
1240
+ title: 'Back to prev.',
1241
+ icon: <WhiteCheckMarkIcon />,
1242
+ action: () => {
1243
+ if (messageText && messageText.length > 0 && !waitAIWidget) {
1244
+ setMessageText(prevTextMessage);
1245
+ }
912
1246
  },
913
- ];
1247
+ });
1248
+
1249
+ //
1250
+ return items;
914
1251
  }
915
1252
 
916
1253
  return (
@@ -943,6 +1280,10 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
943
1280
  />
944
1281
  {useSubContent && subHeaderContent}
945
1282
  </div>
1283
+ {showErrorToast && !messagesViewModel?.loading ? (
1284
+ <ErrorToast messageText={messageErrorToast} />
1285
+ ) : null}
1286
+
946
1287
  {/* <div */}
947
1288
  {/* style={{ */}
948
1289
  {/* flexGrow: `1`, */}
@@ -1187,7 +1528,12 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
1187
1528
  </div>
1188
1529
  <div className="right">
1189
1530
  {AIRephrase && (
1190
- <div className="icon">
1531
+ <div
1532
+ className="icon"
1533
+ style={{
1534
+ cursor: !waitAIWidget ? 'pointer' : '',
1535
+ }}
1536
+ >
1191
1537
  <AIWidgetActions
1192
1538
  widgetToRender={
1193
1539
  <ToneIcon
@@ -1221,191 +1567,6 @@ const MessagesView: React.FC<HeaderDialogsMessagesProps> = ({
1221
1567
  }}
1222
1568
  />
1223
1569
  )}
1224
- {/* {AIRephrase && ( */}
1225
- {/* <div> */}
1226
- {/* /!* <ContextMenu *!/ */}
1227
- {/* /!* widgetToRender={ *!/ */}
1228
- {/* /!* <AIWidgetIcon *!/ */}
1229
- {/* /!* applyZoom *!/ */}
1230
- {/* /!* color="var(--main-elements)" *!/ */}
1231
- {/* /!* width="24" *!/ */}
1232
- {/* /!* height="24" *!/ */}
1233
- {/* /!* /> *!/ */}
1234
- {/* /!* } *!/ */}
1235
- {/* /!* items={[ *!/ */}
1236
- {/* /!* // { *!/ */}
1237
- {/* /!* // title: 'AI Chat Summary', *!/ */}
1238
- {/* /!* // // eslint-disable-next-line @typescript-eslint/no-empty-function *!/ */}
1239
- {/* /!* // action: () => {}, *!/ */}
1240
- {/* /!* // }, *!/ */}
1241
- {/* /!* { *!/ */}
1242
- {/* /!* title: 'AI Translate', *!/ */}
1243
- {/* /!* action: () => { *!/ */}
1244
- {/* /!* if ( *!/ */}
1245
- {/* /!* messageText && *!/ */}
1246
- {/* /!* messageText.length > 0 && *!/ */}
1247
- {/* /!* !waitAIWidget *!/ */}
1248
- {/* /!* ) { *!/ */}
1249
- {/* /!* setWaitAIWidget(true); *!/ */}
1250
- {/* /!* AITranslation?.textToWidget( *!/ */}
1251
- {/* /!* messageText, *!/ */}
1252
- {/* /!* messageEntitiesToIChatMessageCollection(messagesToView), *!/ */}
1253
- {/* /!* ); *!/ */}
1254
- {/* /!* } *!/ */}
1255
- {/* /!* }, *!/ */}
1256
- {/* /!* }, *!/ */}
1257
- {/* /!* ]} *!/ */}
1258
- {/* /!* /> *!/ */}
1259
- {/* /!* <AIWidgetActions *!/ */}
1260
- {/* /!* widgetToRender={ *!/ */}
1261
- {/* /!* <AIWidgetIcon *!/ */}
1262
- {/* /!* applyZoom *!/ */}
1263
- {/* /!* color="var(--main-elements)" *!/ */}
1264
- {/* /!* width="16" *!/ */}
1265
- {/* /!* height="16" *!/ */}
1266
- {/* /!* /> *!/ */}
1267
- {/* /!* } *!/ */}
1268
- {/* /!* items={[ *!/ */}
1269
- {/* /!* { *!/ */}
1270
- {/* /!* title: 'English', *!/ */}
1271
- {/* /!* // eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-misused-promises *!/ */}
1272
- {/* /!* action: async () => { *!/ */}
1273
- {/* /!* if ( *!/ */}
1274
- {/* /!* messageText && *!/ */}
1275
- {/* /!* messageText.length > 0 && *!/ */}
1276
- {/* /!* !waitAIWidget *!/ */}
1277
- {/* /!* ) { *!/ */}
1278
- {/* /!* setWaitAIWidget(true); *!/ */}
1279
- {/* /!* const translation = await AITranslation?.textToWidget( *!/ */}
1280
- {/* /!* messageText, *!/ */}
1281
- {/* /!* messageEntitiesToIChatMessageCollection(messagesToView), *!/ */}
1282
- {/* /!* { *!/ */}
1283
- {/* /!* language: *!/ */}
1284
- {/* /!* 'English' || *!/ */}
1285
- {/* /!* QBConfig.configAIApi.AITranslateWidgetConfig *!/ */}
1286
- {/* /!* .defaultLanguage, *!/ */}
1287
- {/* /!* }, *!/ */}
1288
- {/* /!* ); *!/ */}
1289
-
1290
- {/* /!* setMessageText(translation || ''); *!/ */}
1291
- {/* /!* } *!/ */}
1292
- {/* /!* }, *!/ */}
1293
- {/* /!* }, *!/ */}
1294
- {/* /!* { *!/ */}
1295
- {/* /!* title: 'Ukrainian', *!/ */}
1296
- {/* /!* // eslint-disable-next-line @typescript-eslint/no-misused-promises *!/ */}
1297
- {/* /!* action: async () => { *!/ */}
1298
- {/* /!* if ( *!/ */}
1299
- {/* /!* messageText && *!/ */}
1300
- {/* /!* messageText.length > 0 && *!/ */}
1301
- {/* /!* !waitAIWidget *!/ */}
1302
- {/* /!* ) { *!/ */}
1303
- {/* /!* setWaitAIWidget(true); *!/ */}
1304
- {/* /!* const translation = await AITranslation?.textToWidget( *!/ */}
1305
- {/* /!* messageText, *!/ */}
1306
- {/* /!* messageEntitiesToIChatMessageCollection(messagesToView), *!/ */}
1307
- {/* /!* { *!/ */}
1308
- {/* /!* language: *!/ */}
1309
- {/* /!* 'Ukrainian' || *!/ */}
1310
- {/* /!* QBConfig.configAIApi.AITranslateWidgetConfig *!/ */}
1311
- {/* /!* .defaultLanguage, *!/ */}
1312
- {/* /!* }, *!/ */}
1313
- {/* /!* ); *!/ */}
1314
-
1315
- {/* /!* setMessageText(translation || ''); *!/ */}
1316
- {/* /!* } *!/ */}
1317
- {/* /!* }, *!/ */}
1318
- {/* /!* }, *!/ */}
1319
- {/* /!* { *!/ */}
1320
- {/* /!* title: 'Spanish', *!/ */}
1321
- {/* /!* // eslint-disable-next-line @typescript-eslint/no-misused-promises *!/ */}
1322
- {/* /!* action: async () => { *!/ */}
1323
- {/* /!* if ( *!/ */}
1324
- {/* /!* messageText && *!/ */}
1325
- {/* /!* messageText.length > 0 && *!/ */}
1326
- {/* /!* !waitAIWidget *!/ */}
1327
- {/* /!* ) { *!/ */}
1328
- {/* /!* setWaitAIWidget(true); *!/ */}
1329
- {/* /!* const translation = await AITranslation?.textToWidget( *!/ */}
1330
- {/* /!* messageText, *!/ */}
1331
- {/* /!* messageEntitiesToIChatMessageCollection(messagesToView), *!/ */}
1332
- {/* /!* { *!/ */}
1333
- {/* /!* language: *!/ */}
1334
- {/* /!* 'Spanish' || *!/ */}
1335
- {/* /!* QBConfig.configAIApi.AITranslateWidgetConfig *!/ */}
1336
- {/* /!* .defaultLanguage, *!/ */}
1337
- {/* /!* }, *!/ */}
1338
- {/* /!* ); *!/ */}
1339
-
1340
- {/* /!* setMessageText(translation || ''); *!/ */}
1341
- {/* /!* } *!/ */}
1342
- {/* /!* }, *!/ */}
1343
- {/* /!* }, *!/ */}
1344
- {/* /!* { *!/ */}
1345
- {/* /!* title: 'Portuguese', *!/ */}
1346
- {/* /!* // eslint-disable-next-line @typescript-eslint/no-misused-promises *!/ */}
1347
- {/* /!* action: async () => { *!/ */}
1348
- {/* /!* if ( *!/ */}
1349
- {/* /!* messageText && *!/ */}
1350
- {/* /!* messageText.length > 0 && *!/ */}
1351
- {/* /!* !waitAIWidget *!/ */}
1352
- {/* /!* ) { *!/ */}
1353
- {/* /!* setWaitAIWidget(true); *!/ */}
1354
- {/* /!* const translation = await AITranslation?.textToWidget( *!/ */}
1355
- {/* /!* messageText, *!/ */}
1356
- {/* /!* messageEntitiesToIChatMessageCollection(messagesToView), *!/ */}
1357
- {/* /!* { *!/ */}
1358
- {/* /!* language: *!/ */}
1359
- {/* /!* 'Portuguese' || *!/ */}
1360
- {/* /!* QBConfig.configAIApi.AITranslateWidgetConfig *!/ */}
1361
- {/* /!* .defaultLanguage, *!/ */}
1362
- {/* /!* }, *!/ */}
1363
- {/* /!* ); *!/ */}
1364
-
1365
- {/* /!* setMessageText(translation || ''); *!/ */}
1366
- {/* /!* } *!/ */}
1367
- {/* /!* }, *!/ */}
1368
- {/* /!* }, *!/ */}
1369
- {/* /!* { *!/ */}
1370
- {/* /!* title: 'French', *!/ */}
1371
- {/* /!* // eslint-disable-next-line @typescript-eslint/no-misused-promises *!/ */}
1372
- {/* /!* action: async () => { *!/ */}
1373
- {/* /!* if ( *!/ */}
1374
- {/* /!* messageText && *!/ */}
1375
- {/* /!* messageText.length > 0 && *!/ */}
1376
- {/* /!* !waitAIWidget *!/ */}
1377
- {/* /!* ) { *!/ */}
1378
- {/* /!* setWaitAIWidget(true); *!/ */}
1379
- {/* /!* const translation = await AITranslation?.textToWidget( *!/ */}
1380
- {/* /!* messageText, *!/ */}
1381
- {/* /!* messageEntitiesToIChatMessageCollection(messagesToView), *!/ */}
1382
- {/* /!* { *!/ */}
1383
- {/* /!* language: *!/ */}
1384
- {/* /!* 'French' || *!/ */}
1385
- {/* /!* QBConfig.configAIApi.AITranslateWidgetConfig *!/ */}
1386
- {/* /!* .defaultLanguage, *!/ */}
1387
- {/* /!* }, *!/ */}
1388
- {/* /!* ); *!/ */}
1389
-
1390
- {/* /!* setMessageText(translation || ''); *!/ */}
1391
- {/* /!* } *!/ */}
1392
- {/* /!* }, *!/ */}
1393
- {/* /!* }, *!/ */}
1394
- {/* /!* // { *!/ */}
1395
- {/* /!* // title: 'German', *!/ */}
1396
- {/* /!* // action: () => {}, *!/ */}
1397
- {/* /!* // }, *!/ */}
1398
- {/* /!* ]} *!/ */}
1399
- {/* /!* /> *!/ */}
1400
- {/* <AIWidgetActions */}
1401
- {/* title="AI Rephrase Message" */}
1402
- {/* widgetToRender={ */}
1403
- {/* <AIWidgetIcon applyZoom color="blue" width="24" height="24" /> */}
1404
- {/* } */}
1405
- {/* items={getAIEditingMessagesItems()} */}
1406
- {/* /> */}
1407
- {/* </div> */}
1408
- {/* )} */}
1409
1570
  {!isVoiceMessage && !waitAIWidget && (
1410
1571
  <div>
1411
1572
  <ActiveSvg