@memori.ai/memori-react 7.12.2 → 7.13.1

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 (77) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +4 -4
  3. package/dist/components/Avatar/Avatar.js +2 -1
  4. package/dist/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.d.ts +0 -1
  6. package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js +23 -11
  7. package/dist/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js.map +1 -1
  8. package/dist/components/Chat/Chat.d.ts +0 -1
  9. package/dist/components/Chat/Chat.js +5 -10
  10. package/dist/components/Chat/Chat.js.map +1 -1
  11. package/dist/components/MemoriWidget/MemoriWidget.css +10 -4
  12. package/dist/components/MemoriWidget/MemoriWidget.d.ts +3 -6
  13. package/dist/components/MemoriWidget/MemoriWidget.js +39 -253
  14. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  15. package/dist/components/layouts/Chat.js +1 -1
  16. package/dist/components/layouts/Chat.js.map +1 -1
  17. package/dist/components/layouts/FullPage.js +1 -1
  18. package/dist/components/layouts/FullPage.js.map +1 -1
  19. package/dist/components/layouts/Totem.js +1 -1
  20. package/dist/components/layouts/Totem.js.map +1 -1
  21. package/dist/components/layouts/WebsiteAssistant.js +2 -2
  22. package/dist/components/layouts/WebsiteAssistant.js.map +1 -1
  23. package/dist/components/layouts/ZoomedFullBody.js +2 -2
  24. package/dist/components/layouts/ZoomedFullBody.js.map +1 -1
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +6 -4
  27. package/dist/index.js.map +1 -1
  28. package/dist/styles.css +1 -0
  29. package/esm/components/Avatar/Avatar.js +2 -1
  30. package/esm/components/Avatar/Avatar.js.map +1 -1
  31. package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.d.ts +0 -1
  32. package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js +23 -11
  33. package/esm/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.js.map +1 -1
  34. package/esm/components/Chat/Chat.d.ts +0 -1
  35. package/esm/components/Chat/Chat.js +5 -10
  36. package/esm/components/Chat/Chat.js.map +1 -1
  37. package/esm/components/MemoriWidget/MemoriWidget.css +10 -4
  38. package/esm/components/MemoriWidget/MemoriWidget.d.ts +3 -6
  39. package/esm/components/MemoriWidget/MemoriWidget.js +40 -254
  40. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  41. package/esm/components/layouts/Chat.js +1 -1
  42. package/esm/components/layouts/Chat.js.map +1 -1
  43. package/esm/components/layouts/FullPage.js +1 -1
  44. package/esm/components/layouts/FullPage.js.map +1 -1
  45. package/esm/components/layouts/Totem.js +1 -1
  46. package/esm/components/layouts/Totem.js.map +1 -1
  47. package/esm/components/layouts/WebsiteAssistant.js +2 -2
  48. package/esm/components/layouts/WebsiteAssistant.js.map +1 -1
  49. package/esm/components/layouts/ZoomedFullBody.js +2 -2
  50. package/esm/components/layouts/ZoomedFullBody.js.map +1 -1
  51. package/esm/index.d.ts +4 -2
  52. package/esm/index.js +6 -4
  53. package/esm/index.js.map +1 -1
  54. package/esm/styles.css +1 -0
  55. package/package.json +1 -1
  56. package/src/components/Avatar/Avatar.tsx +3 -4
  57. package/src/components/Avatar/AvatarView/AvatarComponent/positionControls/positionControls.tsx +35 -13
  58. package/src/components/Chat/Chat.test.tsx +0 -81
  59. package/src/components/Chat/Chat.tsx +1 -26
  60. package/src/components/Chat/__snapshots__/Chat.test.tsx.snap +0 -1159
  61. package/src/components/MemoriWidget/MemoriWidget.css +10 -4
  62. package/src/components/MemoriWidget/MemoriWidget.stories.tsx +7 -10
  63. package/src/components/MemoriWidget/MemoriWidget.tsx +55 -317
  64. package/src/components/layouts/Chat.tsx +0 -6
  65. package/src/components/layouts/FullPage.test.tsx +21 -1
  66. package/src/components/layouts/FullPage.tsx +0 -7
  67. package/src/components/layouts/Totem.tsx +0 -6
  68. package/src/components/layouts/WebsiteAssistant.tsx +0 -7
  69. package/src/components/layouts/ZoomedFullBody.tsx +0 -9
  70. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +1 -1
  71. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +463 -1
  72. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +1 -1
  73. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +1 -1
  74. package/src/components/layouts/layouts.stories.tsx +36 -38
  75. package/src/index.stories.tsx +1 -2
  76. package/src/index.tsx +20 -10
  77. package/src/styles.css +1 -0
@@ -15,7 +15,6 @@ const Auth_1 = tslib_1.__importDefault(require("../Auth/Auth"));
15
15
  const Chat_1 = tslib_1.__importDefault(require("../Chat/Chat"));
16
16
  const StartPanel_1 = tslib_1.__importDefault(require("../StartPanel/StartPanel"));
17
17
  const Avatar_1 = tslib_1.__importDefault(require("../Avatar/Avatar"));
18
- const ChangeMode_1 = tslib_1.__importDefault(require("../ChangeMode/ChangeMode"));
19
18
  const Header_1 = tslib_1.__importDefault(require("../Header/Header"));
20
19
  const PoweredBy_1 = tslib_1.__importDefault(require("../PoweredBy/PoweredBy"));
21
20
  const AgeVerificationModal_1 = tslib_1.__importDefault(require("../AgeVerificationModal/AgeVerificationModal"));
@@ -155,7 +154,7 @@ let memoriPassword;
155
154
  let speakerMuted = false;
156
155
  let memoriSpeaking = false;
157
156
  let userToken;
158
- const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showInstruct = false, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, showClear = false, showLogin = false, showUpload = false, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiURL = 'https://backend.memori.ai', engineURL = 'https://engine.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, useMathFormatting = false, }) => {
157
+ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenantID, memoriLang, multilingual, integration, layout = 'DEFAULT', customLayout, showShare, preview = false, embed = false, showCopyButton = true, showTranslationOriginal = false, showInputs = true, showDates = false, showContextPerLine = false, showSettings = true, showTypingText = false, showClear = false, showLogin = false, showUpload = false, showOnlyLastMessages, height = '100vh', secret, baseUrl = 'https://aisuru.com', apiURL = 'https://backend.memori.ai', engineURL = 'https://engine.memori.ai', initialContextVars, initialQuestion, ogImage, sessionID: initialSessionID, tenant, personification, authToken, AZURE_COGNITIVE_SERVICES_TTS_KEY, enableAudio, defaultSpeakerActive = true, disableTextEnteredEvents = false, onStateChange, additionalInfo, additionalSettings, customMediaRenderer, userAvatar, useMathFormatting = false, autoStart = false, applyVarsToRoot = false, }) => {
159
158
  var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
160
159
  const { t, i18n } = (0, react_i18next_1.useTranslation)();
161
160
  const [isClient, setIsClient] = (0, react_1.useState)(false);
@@ -225,7 +224,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
225
224
  const [showSettingsDrawer, setShowSettingsDrawer] = (0, react_1.useState)(false);
226
225
  const [showKnownFactsDrawer, setShowKnownFactsDrawer] = (0, react_1.useState)(false);
227
226
  const [showExpertsDrawer, setShowExpertsDrawer] = (0, react_1.useState)(false);
228
- const [muteSpeaker, setMuteSpeaker] = (0, react_1.useState)(!defaultEnableAudio || !defaultSpeakerActive);
227
+ const [muteSpeaker, setMuteSpeaker] = (0, react_1.useState)(!defaultEnableAudio || !defaultSpeakerActive || autoStart);
229
228
  const [continuousSpeech, setContinuousSpeech] = (0, react_1.useState)(false);
230
229
  const [continuousSpeechTimeout, setContinuousSpeechTimeout] = (0, react_1.useState)(2);
231
230
  const [isPlayingAudio, setIsPlayingAudio] = (0, react_1.useState)(false);
@@ -252,8 +251,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
252
251
  else {
253
252
  defaultControlsPosition = 'bottom';
254
253
  }
255
- setMuteSpeaker((0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive));
256
- speakerMuted = (0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive);
254
+ setMuteSpeaker(autoStart ||
255
+ (0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive || autoStart));
256
+ speakerMuted =
257
+ autoStart ||
258
+ (0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio || !defaultSpeakerActive || autoStart);
257
259
  setContinuousSpeech(microphoneMode === 'CONTINUOUS');
258
260
  setContinuousSpeechTimeout((0, configuration_1.getLocalConfig)('continuousSpeechTimeout', 2));
259
261
  setControlsPosition((0, configuration_1.getLocalConfig)('controlsPosition', defaultControlsPosition));
@@ -356,7 +358,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
356
358
  try {
357
359
  if (!hidden &&
358
360
  translate &&
359
- !instruct &&
360
361
  isMultilanguageEnabled &&
361
362
  userLang.toUpperCase() !== language.toUpperCase()) {
362
363
  const translation = await (0, translations_1.getTranslation)(text, language, userLang, baseUrl);
@@ -373,78 +374,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
373
374
  const emission = useLoaderTextAsMsg && typingText
374
375
  ? typingText
375
376
  : (_d = currentState.emission) !== null && _d !== void 0 ? _d : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
376
- if (currentState.state === 'X4' && memori.giverTag) {
377
- const { currentState, ...resp } = await postTagChangedEvent(sessionID, memori.giverTag);
378
- if (resp.resultCode === 0) {
379
- setCurrentDialogState(currentState);
380
- if (emission) {
381
- pushMessage({
382
- text: emission,
383
- emitter: currentState.emitter,
384
- media: currentState.media,
385
- fromUser: false,
386
- questionAnswered: msg,
387
- contextVars: currentState.contextVars,
388
- date: currentState.currentDate,
389
- placeName: currentState.currentPlaceName,
390
- placeLatitude: currentState.currentLatitude,
391
- placeLongitude: currentState.currentLongitude,
392
- placeUncertaintyKm: currentState.currentUncertaintyKm,
393
- tag: currentState.currentTag,
394
- memoryTags: currentState.memoryTags,
395
- });
396
- speak(emission);
397
- }
398
- }
399
- else {
400
- console.error(response, resp);
401
- react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(resp.resultCode)));
402
- gotError = true;
403
- }
404
- }
405
- else if (currentState.state === 'X2d' && memori.giverTag) {
406
- const { currentState, ...resp } = await postTextEnteredEvent({
407
- sessionId: sessionID,
408
- text: Math.random().toString().substring(2, 8),
409
- });
410
- if (resp.resultCode === 0) {
411
- const { currentState, ...resp } = await postTagChangedEvent(sessionID, memori.giverTag);
412
- if (resp.resultCode === 0) {
413
- setCurrentDialogState(currentState);
414
- if (emission) {
415
- pushMessage({
416
- text: emission,
417
- emitter: currentState.emitter,
418
- media: currentState.media,
419
- fromUser: false,
420
- questionAnswered: msg,
421
- contextVars: currentState.contextVars,
422
- date: currentState.currentDate,
423
- placeName: currentState.currentPlaceName,
424
- placeLatitude: currentState.currentLatitude,
425
- placeLongitude: currentState.currentLongitude,
426
- placeUncertaintyKm: currentState.currentUncertaintyKm,
427
- tag: currentState.currentTag,
428
- memoryTags: currentState.memoryTags,
429
- });
430
- speak(emission);
431
- }
432
- }
433
- else {
434
- console.error(response, resp);
435
- react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(resp.resultCode)));
436
- gotError = true;
437
- }
438
- }
439
- else {
440
- console.error(response, resp);
441
- react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(resp.resultCode)));
442
- gotError = true;
443
- }
444
- }
445
- else if (userLang.toLowerCase() !== language.toLowerCase() &&
377
+ if (userLang.toLowerCase() !== language.toLowerCase() &&
446
378
  emission &&
447
- !instruct &&
448
379
  isMultilanguageEnabled) {
449
380
  translateDialogState(currentState, userLang, msg).then(ts => {
450
381
  let text = ts.translatedEmission || ts.emission;
@@ -481,7 +412,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
481
412
  }
482
413
  else if (response.resultCode === 404) {
483
414
  setHistory(h => [...h.slice(0, h.length - 1)]);
484
- reopenSession(false, memoriPwd || memori.secretToken, memoriTokens, instruct && memori.giverTag ? memori.giverTag : undefined, instruct && memori.giverPIN ? memori.giverPIN : undefined, {
415
+ reopenSession(false, memoriPwd || memori.secretToken, memoriTokens, undefined, undefined, {
485
416
  PATHNAME: window.location.pathname,
486
417
  ROUTE: ((_g = (_f = window.location.pathname) === null || _f === void 0 ? void 0 : _f.split('/')) === null || _g === void 0 ? void 0 : _g.pop()) || '',
487
418
  ...(initialContextVars || {}),
@@ -512,7 +443,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
512
443
  let translatedState = { ...state };
513
444
  let translatedMsg = null;
514
445
  if (!emission ||
515
- instruct ||
516
446
  language.toUpperCase() === userLang.toUpperCase() ||
517
447
  !isMultilanguageEnabled) {
518
448
  translatedState = { ...state, emission };
@@ -646,7 +576,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
646
576
  });
647
577
  };
648
578
  const fetchSession = async (params) => {
649
- var _a, _b, _c, _d, _f, _g;
579
+ var _a, _b, _c, _d, _f;
650
580
  let storageBirthDate = (0, configuration_1.getLocalConfig)('birthDate', undefined);
651
581
  let userBirthDate = (_a = birthDate !== null && birthDate !== void 0 ? birthDate : params.birthDate) !== null && _a !== void 0 ? _a : storageBirthDate;
652
582
  if (!userBirthDate && !!minAge) {
@@ -662,13 +592,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
662
592
  }
663
593
  setLoading(true);
664
594
  try {
665
- if (!memori.giverTag && !!((_b = memori.receivedInvitations) === null || _b === void 0 ? void 0 : _b.length)) {
666
- let giverInvitation = memori.receivedInvitations.find((i) => i.type === 'GIVER' && i.state === 'ACCEPTED');
667
- if (giverInvitation) {
668
- memori.giverTag = giverInvitation.tag;
669
- memori.giverPIN = giverInvitation.pin;
670
- }
671
- }
672
595
  let referral;
673
596
  try {
674
597
  referral = (() => {
@@ -681,11 +604,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
681
604
  const session = await initSession({
682
605
  ...params,
683
606
  birthDate: userBirthDate,
684
- tag: (_c = params.tag) !== null && _c !== void 0 ? _c : personification === null || personification === void 0 ? void 0 : personification.tag,
685
- pin: (_d = params.pin) !== null && _d !== void 0 ? _d : personification === null || personification === void 0 ? void 0 : personification.pin,
607
+ tag: (_b = params.tag) !== null && _b !== void 0 ? _b : personification === null || personification === void 0 ? void 0 : personification.tag,
608
+ pin: (_c = params.pin) !== null && _c !== void 0 ? _c : personification === null || personification === void 0 ? void 0 : personification.pin,
686
609
  additionalInfo: {
687
610
  ...(additionalInfo || {}),
688
- loginToken: (_g = (_f = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _f !== void 0 ? _f : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _g !== void 0 ? _g : authToken,
611
+ loginToken: (_f = (_d = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _d !== void 0 ? _d : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _f !== void 0 ? _f : authToken,
689
612
  language: getCultureCodeByLanguage(userLang),
690
613
  referral: referral,
691
614
  timeZoneOffset: new Date().getTimezoneOffset().toString(),
@@ -695,6 +618,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
695
618
  (session === null || session === void 0 ? void 0 : session.currentState) &&
696
619
  session.resultCode === 0) {
697
620
  setSessionId(session.sessionID);
621
+ setInstruct((currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) === memori.giverTag);
698
622
  if (position)
699
623
  applyPosition(position, session.sessionID);
700
624
  setLoading(false);
@@ -754,8 +678,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
754
678
  memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
755
679
  password: password || memoriPwd || memori.secretToken,
756
680
  recoveryTokens: recoveryTokens || memoriTokens,
757
- tag,
758
- pin,
681
+ tag: tag !== null && tag !== void 0 ? tag : personification === null || personification === void 0 ? void 0 : personification.tag,
682
+ pin: pin !== null && pin !== void 0 ? pin : personification === null || personification === void 0 ? void 0 : personification.pin,
759
683
  initialContextVars: {
760
684
  PATHNAME: window.location.pathname,
761
685
  ROUTE: ((_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) || '',
@@ -886,8 +810,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
886
810
  fetchSession({
887
811
  memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
888
812
  password: secret || memoriPwd || memori.secretToken,
889
- tag: memori.giverTag,
890
- pin: memori.giverPIN,
813
+ tag: tag !== null && tag !== void 0 ? tag : personification === null || personification === void 0 ? void 0 : personification.tag,
814
+ pin: pin !== null && pin !== void 0 ? pin : personification === null || personification === void 0 ? void 0 : personification.pin,
891
815
  initialContextVars: {
892
816
  PATHNAME: window.location.pathname,
893
817
  ROUTE: ((_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) || '',
@@ -920,19 +844,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
920
844
  }
921
845
  return null;
922
846
  };
923
- const restoreGiverTag = async () => {
924
- if (sessionId && memori.giverTag && memori.giverPIN) {
925
- setHistory([]);
926
- await changeTag(memori.engineMemoriID, sessionId, memori.giverTag, memori.giverPIN);
927
- }
928
- };
929
- (0, react_1.useEffect)(() => {
930
- return () => {
931
- if (!currentDialogState ||
932
- (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== memori.giverTag)
933
- restoreGiverTag();
934
- };
935
- }, []);
936
847
  const sendDateChangedEvent = (0, react_1.useCallback)(async ({ sessionID, date, state, }) => {
937
848
  var _a;
938
849
  const session = sessionID !== null && sessionID !== void 0 ? sessionID : sessionId;
@@ -1004,8 +915,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1004
915
  const { currentState, ...response } = await postTimeoutEvent(sessionId);
1005
916
  if (response.resultCode === 0 && currentState) {
1006
917
  const emission = currentState.emission;
1007
- if (!instruct &&
1008
- isMultilanguageEnabled &&
918
+ if (isMultilanguageEnabled &&
1009
919
  userLang !== (i18n === null || i18n === void 0 ? void 0 : i18n.language) &&
1010
920
  emission &&
1011
921
  emission.length > 0) {
@@ -1270,15 +1180,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1270
1180
  const e = new CustomEvent('MemoriEndSpeak');
1271
1181
  document.dispatchEvent(e);
1272
1182
  };
1273
- const handleSpeechEnd = () => {
1274
- memoriSpeaking = false;
1275
- setMemoriTyping(false);
1276
- emitEndSpeakEvent();
1277
- };
1278
- const generateSSMLText = (text) => {
1279
- const textToSpeak = (0, utils_1.escapeHTML)((0, utils_1.stripMarkdown)((0, utils_1.stripEmojis)((0, utils_1.stripHTML)((0, utils_1.stripOutputTags)(text)))));
1280
- return `<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xmlns:emo="http://www.w3.org/2009/10/emotionml" xml:lang="${getCultureCodeByLanguage(userLang)}"><voice name="${getTTSVoice(userLang)}"><s>${replaceTextWithPhonemes(textToSpeak, userLang.toLowerCase())}</s></voice></speak>`;
1281
- };
1282
1183
  const speak = (text) => {
1283
1184
  if (!AZURE_COGNITIVE_SERVICES_TTS_KEY || preview) {
1284
1185
  emitEndSpeakEvent();
@@ -1622,7 +1523,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1622
1523
  const integrationProperties = (integration
1623
1524
  ? {
1624
1525
  '--memori-chat-bubble-bg': '#fff',
1625
- ...(integrationConfig && !showInstruct
1526
+ ...(integrationConfig && !instruct
1626
1527
  ? { '--memori-text-color': (_q = integrationConfig.textColor) !== null && _q !== void 0 ? _q : '#000' }
1627
1528
  : {}),
1628
1529
  ...((integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.buttonBgColor)
@@ -1660,11 +1561,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1660
1561
  }
1661
1562
  : {});
1662
1563
  const integrationStylesheet = `
1663
- ${preview
1664
- ? '#preview,'
1665
- : selectedLayout === 'WEBSITE_ASSISTANT'
1666
- ? ''
1667
- : ':root,'} .memori-widget, .memori-drawer, .memori-modal {
1564
+ ${preview ? '#preview, ' : applyVarsToRoot ? ':root, ' : ''}memori-client, .memori-widget, .memori-drawer, .memori-modal {
1668
1565
  ${Object.entries(integrationProperties)
1669
1566
  .map(([key, value]) => `${key}: ${value};`)
1670
1567
  .join('\n')}
@@ -1711,74 +1608,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1711
1608
  document.head.append(meta);
1712
1609
  }
1713
1610
  }, [integrationConfig, memori.avatarURL, ogImage]);
1714
- const selectReceiverTag = async (tag) => {
1715
- var _a;
1716
- if (!sessionId)
1717
- return;
1718
- try {
1719
- const { currentState, ...resp } = await postTagChangedEvent(sessionId, tag);
1720
- if (resp.resultCode === 0) {
1721
- pushMessage({
1722
- text: tag,
1723
- fromUser: true,
1724
- });
1725
- if (currentState.state === 'X4' && memori.giverTag) {
1726
- const { currentState, ...resp } = await client.postTagChangedEvent(sessionId, memori.giverTag);
1727
- if (resp.resultCode === 0) {
1728
- setCurrentDialogState(currentState);
1729
- if (currentState.emission) {
1730
- pushMessage({
1731
- text: currentState.emission,
1732
- emitter: currentState.emitter,
1733
- media: currentState.media,
1734
- fromUser: false,
1735
- contextVars: currentState.contextVars,
1736
- date: currentState.currentDate,
1737
- placeName: currentState.currentPlaceName,
1738
- placeLatitude: currentState.currentLatitude,
1739
- placeLongitude: currentState.currentLongitude,
1740
- placeUncertaintyKm: currentState.currentUncertaintyKm,
1741
- tag: currentState.currentTag,
1742
- memoryTags: currentState.memoryTags,
1743
- });
1744
- }
1745
- }
1746
- else {
1747
- console.error(resp);
1748
- react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(resp.resultCode)));
1749
- }
1750
- }
1751
- else {
1752
- setCurrentDialogState(currentState);
1753
- if (currentState.emission) {
1754
- pushMessage({
1755
- text: currentState.emission,
1756
- emitter: currentState.emitter,
1757
- media: currentState.media,
1758
- fromUser: false,
1759
- contextVars: currentState.contextVars,
1760
- date: currentState.currentDate,
1761
- placeName: currentState.currentPlaceName,
1762
- placeLatitude: currentState.currentLatitude,
1763
- placeLongitude: currentState.currentLongitude,
1764
- placeUncertaintyKm: currentState.currentUncertaintyKm,
1765
- tag: currentState.currentTag,
1766
- memoryTags: currentState.memoryTags,
1767
- });
1768
- }
1769
- }
1770
- }
1771
- else {
1772
- console.error(resp, tag, (_a = currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.knownTags) === null || _a === void 0 ? void 0 : _a[tag]);
1773
- react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(resp.resultCode)));
1774
- }
1775
- }
1776
- catch (e) {
1777
- let err = e;
1778
- console.error(err);
1779
- react_hot_toast_1.default.error(err.message);
1780
- }
1781
- };
1782
1611
  const simulateUserPrompt = (text, translatedText) => {
1783
1612
  stopListening();
1784
1613
  stopAudio();
@@ -1821,7 +1650,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1821
1650
  };
1822
1651
  }, [sessionId, userLang, disableTextEnteredEvents]);
1823
1652
  const onClickStart = (0, react_1.useCallback)(async (session, initialSessionExpired = false) => {
1824
- var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _t, _u, _v, _w;
1653
+ var _a, _b, _c, _d, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1825
1654
  const sessionID = (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
1826
1655
  const dialogState = (session === null || session === void 0 ? void 0 : session.dialogState) || currentDialogState;
1827
1656
  setClickedStart(true);
@@ -1905,44 +1734,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1905
1734
  applyPosition(position, sessionID);
1906
1735
  if (memori.needsDateTime)
1907
1736
  sendDateChangedEvent({ sessionID: sessionID, state: currentState });
1908
- if (instruct &&
1909
- memori.giverTag &&
1910
- (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== memori.giverTag) {
1911
- try {
1912
- console.debug('change tag #0');
1913
- await changeTag(memori.engineMemoriID, sessionID, '-');
1914
- const session = await changeTag(memori.engineMemoriID, sessionID, memori.giverTag, memori.giverPIN);
1915
- if (session && session.resultCode === 0) {
1916
- translateDialogState(session.currentState, userLang)
1917
- .then(ts => {
1918
- let text = ts.translatedEmission || ts.emission;
1919
- if (text) {
1920
- speak(text);
1921
- }
1922
- })
1923
- .finally(() => {
1924
- setHasUserActivatedSpeak(true);
1925
- });
1926
- }
1927
- else {
1928
- console.error('session #1', session);
1929
- throw new Error('No session');
1930
- }
1931
- }
1932
- catch (e) {
1933
- console.error('session #2', e);
1934
- reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, memori === null || memori === void 0 ? void 0 : memori.giverTag, memori === null || memori === void 0 ? void 0 : memori.giverPIN, {
1935
- PATHNAME: (_h = window.location.pathname) === null || _h === void 0 ? void 0 : _h.toUpperCase(),
1936
- ROUTE: ((_l = (_k = (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.split('/')) === null || _k === void 0 ? void 0 : _k.pop()) === null || _l === void 0 ? void 0 : _l.toUpperCase()) ||
1937
- '',
1938
- ...(initialContextVars || {}),
1939
- }, initialQuestion, birth).then(() => {
1940
- setHasUserActivatedSpeak(true);
1941
- });
1942
- }
1943
- }
1944
- else if (!instruct &&
1945
- personification &&
1737
+ if (personification &&
1946
1738
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== personification.tag) {
1947
1739
  try {
1948
1740
  console.debug('change tag #3');
@@ -1968,8 +1760,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1968
1760
  catch (e) {
1969
1761
  console.error('session #5', e);
1970
1762
  reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
1971
- PATHNAME: (_m = window.location.pathname) === null || _m === void 0 ? void 0 : _m.toUpperCase(),
1972
- ROUTE: ((_q = (_p = (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.split('/')) === null || _p === void 0 ? void 0 : _p.pop()) === null || _q === void 0 ? void 0 : _q.toUpperCase()) ||
1763
+ PATHNAME: (_h = window.location.pathname) === null || _h === void 0 ? void 0 : _h.toUpperCase(),
1764
+ ROUTE: ((_l = (_k = (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.split('/')) === null || _k === void 0 ? void 0 : _k.pop()) === null || _l === void 0 ? void 0 : _l.toUpperCase()) ||
1973
1765
  '',
1974
1766
  ...(initialContextVars || {}),
1975
1767
  }, initialQuestion, birth).then(() => {
@@ -1977,8 +1769,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
1977
1769
  });
1978
1770
  }
1979
1771
  }
1980
- else if (!instruct &&
1981
- !personification &&
1772
+ else if (!personification &&
1982
1773
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) &&
1983
1774
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== constants_1.anonTag &&
1984
1775
  (currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== '-') {
@@ -2006,8 +1797,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2006
1797
  catch (e) {
2007
1798
  console.error('session #8', e);
2008
1799
  reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, undefined, undefined, {
2009
- PATHNAME: (_r = window.location.pathname) === null || _r === void 0 ? void 0 : _r.toUpperCase(),
2010
- ROUTE: ((_v = (_u = (_t = window.location.pathname) === null || _t === void 0 ? void 0 : _t.split('/')) === null || _u === void 0 ? void 0 : _u.pop()) === null || _v === void 0 ? void 0 : _v.toUpperCase()) ||
1800
+ PATHNAME: (_m = window.location.pathname) === null || _m === void 0 ? void 0 : _m.toUpperCase(),
1801
+ ROUTE: ((_q = (_p = (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.split('/')) === null || _p === void 0 ? void 0 : _p.pop()) === null || _q === void 0 ? void 0 : _q.toUpperCase()) ||
2011
1802
  '',
2012
1803
  ...(initialContextVars || {}),
2013
1804
  }, initialQuestion, birth).then(() => {
@@ -2018,7 +1809,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2018
1809
  else {
2019
1810
  try {
2020
1811
  const { chatLogs, ...resp } = await getSessionChatLogs(sessionID, sessionID);
2021
- const messages = (_w = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _w === void 0 ? void 0 : _w.lines.map((l, i) => {
1812
+ const messages = (_r = chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]) === null || _r === void 0 ? void 0 : _r.lines.map((l, i) => {
2022
1813
  var _a, _b;
2023
1814
  return ({
2024
1815
  text: l.text,
@@ -2081,6 +1872,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2081
1872
  });
2082
1873
  }
2083
1874
  }, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
1875
+ (0, react_1.useEffect)(() => {
1876
+ if (!clickedStart && autoStart) {
1877
+ onClickStart();
1878
+ }
1879
+ }, [clickedStart, autoStart]);
2084
1880
  (0, react_1.useEffect)(() => {
2085
1881
  const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
2086
1882
  document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
@@ -2283,14 +2079,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2283
2079
  showCopyButton,
2284
2080
  showTranslationOriginal,
2285
2081
  client,
2286
- selectReceiverTag,
2082
+ instruct,
2287
2083
  preview,
2288
2084
  sendOnEnter,
2289
2085
  setSendOnEnter,
2290
2086
  microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK',
2291
2087
  attachmentsMenuOpen,
2292
2088
  setAttachmentsMenuOpen,
2293
- instruct,
2294
2089
  showInputs,
2295
2090
  showMicrophone: !!AZURE_COGNITIVE_SERVICES_TTS_KEY,
2296
2091
  userMessage,
@@ -2327,16 +2122,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2327
2122
  };
2328
2123
  const integrationBackground = integration && globalBackgroundUrl ? ((0, jsx_runtime_1.jsx)("div", { className: "memori--global-background", children: (0, jsx_runtime_1.jsx)("div", { className: "memori--global-background-image", style: { backgroundImage: globalBackgroundUrl } }) })) : ((0, jsx_runtime_1.jsx)("div", { className: "memori--global-background no-background-image" }));
2329
2124
  const integrationStyle = integration ? ((0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: integrationStylesheet } })) : null;
2330
- const onChangeMode = (mode) => {
2331
- setInstruct(mode === 'instruct');
2332
- setHasUserActivatedSpeak(false);
2333
- setClickedStart(false);
2334
- };
2335
- const changeModeProps = {
2336
- canInstruct: !!memori.giverTag,
2337
- instruct: !!instruct,
2338
- onChangeMode,
2339
- };
2340
2125
  const poweredBy = ((0, jsx_runtime_1.jsx)(PoweredBy_1.default, { tenant: tenant, userLang: userLang, integrationID: integration === null || integration === void 0 ? void 0 : integration.integrationID, memoriHash: `${memori.ownerTenantName}-${memori.ownerUserName}-${memori.name}` }));
2341
2126
  const Layout = customLayout
2342
2127
  ? customLayout
@@ -2354,6 +2139,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2354
2139
  ? ZoomedFullBody_1.default
2355
2140
  : FullPage_1.default;
2356
2141
  return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)('memori', 'memori-widget', `memori-layout-${layout.toLowerCase()}`, `memori-controls-${controlsPosition.toLowerCase()}`, `memori--avatar-${(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar) || 'default'}`, {
2142
+ 'memori--auto-start': autoStart,
2357
2143
  'memori--preview': preview,
2358
2144
  'memori--embed': embed,
2359
2145
  'memori--with-integration': integration,
@@ -2364,7 +2150,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2364
2150
  }), "data-memori-name": memori === null || memori === void 0 ? void 0 : memori.name, "data-memori-id": memori === null || memori === void 0 ? void 0 : memori.engineMemoriID, "data-memori-secondary-id": memori === null || memori === void 0 ? void 0 : memori.memoriID, "data-memori-session-id": sessionId, "data-memori-integration": integration === null || integration === void 0 ? void 0 : integration.integrationID, "data-memori-engine-state": JSON.stringify({
2365
2151
  ...currentDialogState,
2366
2152
  sessionID: sessionId,
2367
- }), style: { height }, children: [(0, jsx_runtime_1.jsx)(Layout, { Header: Header_1.default, headerProps: headerProps, Avatar: Avatar_1.default, avatarProps: avatarProps, Chat: Chat_1.default, chatProps: chatProps, StartPanel: StartPanel_1.default, startPanelProps: startPanelProps, integrationStyle: integrationStyle, integrationBackground: integrationBackground, ChangeMode: ChangeMode_1.default, changeModeProps: changeModeProps, poweredBy: poweredBy, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, showInstruct: showInstruct, loading: loading }), (0, jsx_runtime_1.jsx)("audio", { id: "memori-audio", style: { display: 'none' }, src: "https://aisuru.com/intro.mp3" }), isClient && ((0, jsx_runtime_1.jsx)(Auth_1.default, { withModal: true, pwdOrTokens: authModalState, openModal: !!authModalState, setPwdOrTokens: setAuthModalState, showTokens: memori.privacyType === 'SECRET', onFinish: async (values) => {
2153
+ }), style: { height }, children: [(0, jsx_runtime_1.jsx)(Layout, { Header: Header_1.default, headerProps: headerProps, Avatar: Avatar_1.default, avatarProps: avatarProps, Chat: Chat_1.default, chatProps: chatProps, StartPanel: StartPanel_1.default, startPanelProps: startPanelProps, integrationStyle: integrationStyle, integrationBackground: integrationBackground, poweredBy: poweredBy, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, loading: loading }), (0, jsx_runtime_1.jsx)("audio", { id: "memori-audio", style: { display: 'none' }, src: "https://aisuru.com/intro.mp3" }), isClient && ((0, jsx_runtime_1.jsx)(Auth_1.default, { withModal: true, pwdOrTokens: authModalState, openModal: !!authModalState, setPwdOrTokens: setAuthModalState, showTokens: memori.privacyType === 'SECRET', onFinish: async (values) => {
2368
2154
  var _a, _b, _c, _d;
2369
2155
  if (values['password'])
2370
2156
  setMemoriPwd(values['password']);
@@ -2372,7 +2158,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2372
2158
  memoriPassword = values['password'];
2373
2159
  if (values['tokens'])
2374
2160
  setMemoriTokens(values['tokens']);
2375
- reopenSession(!sessionId, values['password'], values['tokens'], instruct ? memori.giverTag : personification === null || personification === void 0 ? void 0 : personification.tag, instruct ? memori.giverPIN : personification === null || personification === void 0 ? void 0 : personification.pin, {
2161
+ reopenSession(!sessionId, values['password'], values['tokens'], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2376
2162
  PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2377
2163
  ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
2378
2164
  '',
@@ -2391,7 +2177,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2391
2177
  if (birthDate) {
2392
2178
  setBirthDate(birthDate);
2393
2179
  (0, configuration_1.setLocalConfig)('birthDate', birthDate);
2394
- reopenSession(!sessionId, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), memoriTokens, instruct ? memori.giverTag : personification === null || personification === void 0 ? void 0 : personification.tag, instruct ? memori.giverPIN : personification === null || personification === void 0 ? void 0 : personification.pin, {
2180
+ reopenSession(!sessionId, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), memoriTokens, personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2395
2181
  PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2396
2182
  ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) || '',
2397
2183
  ...(initialContextVars || {}),