@memori.ai/memori-react 9.0.0-alpha.6 → 9.0.0-alpha.7

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 (132) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/components/AgeVerificationModal/AgeVerificationModal.js +3 -1
  3. package/dist/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
  4. package/dist/components/Auth/Auth.js +3 -1
  5. package/dist/components/Auth/Auth.js.map +1 -1
  6. package/dist/components/Chat/Chat.js +3 -1
  7. package/dist/components/Chat/Chat.js.map +1 -1
  8. package/dist/components/ChatBubble/ChatBubble.js +3 -1
  9. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  10. package/dist/components/ChatHistoryDrawer/ChatHistory.js +3 -1
  11. package/dist/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
  12. package/dist/components/ContentPreviewModal/ContentPreviewModal.js +3 -1
  13. package/dist/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -1
  14. package/dist/components/ExpertsDrawer/ExpertsDrawer.js +3 -1
  15. package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  16. package/dist/components/KnownFacts/KnownFacts.js +5 -3
  17. package/dist/components/KnownFacts/KnownFacts.js.map +1 -1
  18. package/dist/components/LoginDrawer/LoginDrawer.js +3 -1
  19. package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
  20. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
  21. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +4 -1
  22. package/dist/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
  23. package/dist/components/MemoriWidget/MemoriWidget.css +4 -2
  24. package/dist/components/MemoriWidget/MemoriWidget.js +130 -126
  25. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  26. package/dist/components/SettingsDrawer/SettingsDrawer.js +3 -1
  27. package/dist/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
  28. package/dist/components/StartPanel/StartPanel.js +3 -1
  29. package/dist/components/StartPanel/StartPanel.js.map +1 -1
  30. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js +3 -1
  31. package/dist/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  32. package/dist/components/UploadButton/UploadImages/UploadImages.js +3 -1
  33. package/dist/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
  34. package/dist/components/WhyThisAnswer/WhyThisAnswer.js +3 -1
  35. package/dist/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
  36. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -1
  37. package/dist/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
  38. package/dist/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
  39. package/dist/components/layouts/chat.css +2 -1
  40. package/dist/components/layouts/fullpage.css +31 -8
  41. package/dist/components/layouts/hidden-chat.css +1 -0
  42. package/dist/components/layouts/totem.css +2 -1
  43. package/dist/components/layouts/zoomed-full-body.css +32 -7
  44. package/dist/context/widgetSurfaceContext.d.ts +3 -0
  45. package/dist/context/widgetSurfaceContext.js +11 -0
  46. package/dist/context/widgetSurfaceContext.js.map +1 -0
  47. package/dist/styles.css +1 -1
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/esm/components/AgeVerificationModal/AgeVerificationModal.js +3 -1
  51. package/esm/components/AgeVerificationModal/AgeVerificationModal.js.map +1 -1
  52. package/esm/components/Auth/Auth.js +3 -1
  53. package/esm/components/Auth/Auth.js.map +1 -1
  54. package/esm/components/Chat/Chat.js +3 -1
  55. package/esm/components/Chat/Chat.js.map +1 -1
  56. package/esm/components/ChatBubble/ChatBubble.js +3 -1
  57. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  58. package/esm/components/ChatHistoryDrawer/ChatHistory.js +3 -1
  59. package/esm/components/ChatHistoryDrawer/ChatHistory.js.map +1 -1
  60. package/esm/components/ContentPreviewModal/ContentPreviewModal.js +3 -1
  61. package/esm/components/ContentPreviewModal/ContentPreviewModal.js.map +1 -1
  62. package/esm/components/ExpertsDrawer/ExpertsDrawer.js +3 -1
  63. package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  64. package/esm/components/KnownFacts/KnownFacts.js +5 -3
  65. package/esm/components/KnownFacts/KnownFacts.js.map +1 -1
  66. package/esm/components/LoginDrawer/LoginDrawer.js +3 -1
  67. package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
  68. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
  69. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js +4 -1
  70. package/esm/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.js.map +1 -1
  71. package/esm/components/MemoriWidget/MemoriWidget.css +4 -2
  72. package/esm/components/MemoriWidget/MemoriWidget.js +130 -126
  73. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  74. package/esm/components/SettingsDrawer/SettingsDrawer.js +3 -1
  75. package/esm/components/SettingsDrawer/SettingsDrawer.js.map +1 -1
  76. package/esm/components/StartPanel/StartPanel.js +3 -1
  77. package/esm/components/StartPanel/StartPanel.js.map +1 -1
  78. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js +3 -1
  79. package/esm/components/UploadButton/UploadDocuments/UploadDocuments.js.map +1 -1
  80. package/esm/components/UploadButton/UploadImages/UploadImages.js +3 -1
  81. package/esm/components/UploadButton/UploadImages/UploadImages.js.map +1 -1
  82. package/esm/components/WhyThisAnswer/WhyThisAnswer.js +3 -1
  83. package/esm/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
  84. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js +3 -1
  85. package/esm/components/layouts/WebsiteAssistant/WebsiteAssistant.js.map +1 -1
  86. package/esm/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
  87. package/esm/components/layouts/chat.css +2 -1
  88. package/esm/components/layouts/fullpage.css +31 -8
  89. package/esm/components/layouts/hidden-chat.css +1 -0
  90. package/esm/components/layouts/totem.css +2 -1
  91. package/esm/components/layouts/zoomed-full-body.css +32 -7
  92. package/esm/context/widgetSurfaceContext.d.ts +3 -0
  93. package/esm/context/widgetSurfaceContext.js +7 -0
  94. package/esm/context/widgetSurfaceContext.js.map +1 -0
  95. package/esm/styles.css +1 -1
  96. package/esm/version.d.ts +1 -1
  97. package/esm/version.js +1 -1
  98. package/package.json +1 -1
  99. package/src/components/AgeVerificationModal/AgeVerificationModal.tsx +3 -0
  100. package/src/components/Auth/Auth.tsx +3 -0
  101. package/src/components/Chat/Chat.tsx +3 -0
  102. package/src/components/ChatBubble/ChatBubble.tsx +3 -0
  103. package/src/components/ChatHistoryDrawer/ChatHistory.tsx +3 -0
  104. package/src/components/ContentPreviewModal/ContentPreviewModal.tsx +3 -0
  105. package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +3 -0
  106. package/src/components/KnownFacts/KnownFacts.tsx +5 -0
  107. package/src/components/LoginDrawer/LoginDrawer.tsx +3 -0
  108. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.css +19 -5
  109. package/src/components/MemoriArtifactSystem/components/ArtifactDrawer/ArtifactDrawer.tsx +4 -0
  110. package/src/components/MemoriWidget/MemoriWidget.css +4 -2
  111. package/src/components/MemoriWidget/MemoriWidget.tsx +33 -18
  112. package/src/components/SettingsDrawer/SettingsDrawer.tsx +3 -0
  113. package/src/components/StartPanel/StartPanel.tsx +3 -0
  114. package/src/components/UploadButton/UploadDocuments/UploadDocuments.tsx +3 -0
  115. package/src/components/UploadButton/UploadImages/UploadImages.tsx +3 -0
  116. package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +3 -0
  117. package/src/components/layouts/WebsiteAssistant/WebsiteAssistant.tsx +4 -0
  118. package/src/components/layouts/WebsiteAssistant/__snapshots__/WebsiteAssistant.test.tsx.snap +48 -44
  119. package/src/components/layouts/WebsiteAssistant/website-assistant.css +19 -0
  120. package/src/components/layouts/__snapshots__/Chat.test.tsx.snap +533 -529
  121. package/src/components/layouts/__snapshots__/FullPage.test.tsx.snap +1058 -1050
  122. package/src/components/layouts/__snapshots__/HiddenChat.test.tsx.snap +443 -439
  123. package/src/components/layouts/__snapshots__/Totem.test.tsx.snap +584 -580
  124. package/src/components/layouts/__snapshots__/ZoomedFullBody.test.tsx.snap +528 -524
  125. package/src/components/layouts/chat.css +2 -1
  126. package/src/components/layouts/fullpage.css +31 -8
  127. package/src/components/layouts/hidden-chat.css +1 -0
  128. package/src/components/layouts/totem.css +2 -1
  129. package/src/components/layouts/zoomed-full-body.css +32 -7
  130. package/src/context/widgetSurfaceContext.tsx +14 -0
  131. package/src/styles.css +61 -1
  132. package/src/version.ts +1 -1
@@ -11,6 +11,7 @@ const memori_api_client_1 = tslib_1.__importDefault(require("@memori.ai/memori-a
11
11
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
12
12
  const luxon_1 = require("luxon");
13
13
  const ui_1 = require("@memori.ai/ui");
14
+ const widgetSurfaceContext_1 = require("../../context/widgetSurfaceContext");
14
15
  const Auth_1 = tslib_1.__importDefault(require("../Auth/Auth"));
15
16
  const Chat_1 = tslib_1.__importDefault(require("../Chat/Chat"));
16
17
  const StartPanel_1 = tslib_1.__importDefault(require("../StartPanel/StartPanel"));
@@ -213,6 +214,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
213
214
  const [instruct, setInstruct] = (0, react_1.useState)(false);
214
215
  const [enableFocusChatInput, setEnableFocusChatInput] = (0, react_1.useState)(true);
215
216
  const [widgetRootEl, setWidgetRootEl] = (0, react_1.useState)(null);
217
+ const [widgetSurfaceEl, setWidgetSurfaceEl] = (0, react_1.useState)(null);
216
218
  const [isDarkTheme, setIsDarkTheme] = (0, react_1.useState)(false);
217
219
  (0, react_1.useEffect)(() => {
218
220
  var _a;
@@ -2342,7 +2344,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2342
2344
  : FullPage_1.default;
2343
2345
  const widgetTheme = (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.theme) === 'light' || (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.theme) === 'dark'
2344
2346
  ? integrationConfig.theme
2345
- : undefined;
2347
+ : isDarkTheme
2348
+ ? 'dark'
2349
+ : undefined;
2346
2350
  return ((0, jsx_runtime_1.jsx)("div", { ref: setWidgetRootEl, className: (0, classnames_1.default)('memori', 'memori-widget', `memori-layout-${String(selectedLayout).toLowerCase()}`, `memori-controls-${String(controlsPosition).toLowerCase()}`, `memori--avatar-${(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar) || 'default'}`, {
2347
2351
  'memori--auto-start': autoStart,
2348
2352
  'memori--preview': preview,
@@ -2355,132 +2359,132 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
2355
2359
  }), "data-theme": widgetTheme, "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({
2356
2360
  ...currentDialogState,
2357
2361
  sessionID: sessionId,
2358
- }), style: { height }, children: (0, jsx_runtime_1.jsxs)(ui_1.MemoriUIProvider, { container: widgetRootEl, theme: widgetTheme, 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, autoStart: autoStart, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, loading: loading, avatar3dHidden: avatar3dHidden !== null && avatar3dHidden !== void 0 ? avatar3dHidden : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar_3d_hidden }), (0, jsx_runtime_1.jsx)(ArtifactAPI_1.ArtifactAPIBridge, { pushMessage: (message) => {
2359
- setHistory(history => {
2360
- if (!history.length)
2361
- return history;
2362
- const lastMessage = history[history.length - 1];
2363
- if (!lastMessage || lastMessage.fromUser)
2364
- return history;
2365
- const updatedLastMessage = {
2366
- ...lastMessage,
2367
- text: lastMessage.text + message.text,
2368
- };
2369
- return [...history.slice(0, -1), updatedLastMessage];
2370
- });
2371
- } }), (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: (values) => {
2372
- var _a, _b, _c, _d;
2373
- if (values['password'])
2374
- setMemoriPwd(values['password']);
2375
- if (values['password'])
2376
- memoriPassword = values['password'];
2377
- if (values['tokens'])
2378
- setMemoriTokens(values['tokens']);
2379
- return reopenSession(!sessionId, values['password'], values['tokens'], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2380
- LANG: userLang,
2381
- PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2382
- 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()) || '',
2383
- ...(initialContextVars || {}),
2384
- }, initialQuestion, birthDate)
2385
- .then(state => {
2386
- if (!(state === null || state === void 0 ? void 0 : state.sessionID)) {
2387
- throw new Error('AUTH_FAILED');
2388
- }
2389
- setAuthModalState(null);
2390
- if (state === null || state === void 0 ? void 0 : state.dialogState) {
2391
- setHasUserActivatedSpeak(true);
2392
- }
2393
- else {
2394
- onClickStart(state);
2395
- }
2396
- })
2397
- .catch(error => {
2398
- if (!(error instanceof Error) ||
2399
- error.message !== 'AUTH_FAILED') {
2400
- setGotErrorInOpening(true);
2401
- }
2402
- throw error;
2403
- });
2404
- }, minimumNumberOfRecoveryTokens: (_17 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _17 !== void 0 ? _17 : 1 })), isClient && ((0, jsx_runtime_1.jsx)(AgeVerificationModal_1.default, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
2405
- var _a, _b, _c, _d;
2406
- if (birthDate) {
2407
- setBirthDate(birthDate);
2408
- (0, configuration_1.setLocalConfig)('birthDate', birthDate);
2409
- 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, {
2410
- LANG: userLang,
2411
- PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2412
- 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()) || '',
2413
- ...(initialContextVars || {}),
2414
- }, initialQuestion, birthDate)
2415
- .then(state => {
2416
- setShowAgeVerification(false);
2417
- setAuthModalState(null);
2418
- onClickStart(state || undefined);
2419
- })
2420
- .catch(() => {
2421
- setShowAgeVerification(false);
2422
- setGotErrorInOpening(true);
2423
- });
2424
- }
2425
- else {
2426
- setShowAgeVerification(false);
2427
- setClickedStart(false);
2428
- }
2429
- } })), showSettingsDrawer && ((0, jsx_runtime_1.jsx)(SettingsDrawer_1.default, { layout: selectedLayout, open: !!showSettingsDrawer, onClose: () => setShowSettingsDrawer(false), microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK', continuousSpeechTimeout: continuousSpeechTimeout, setMicrophoneMode: mode => setContinuousSpeech(mode === 'CONTINUOUS'), setContinuousSpeechTimeout: setContinuousSpeechTimeout, controlsPosition: controlsPosition, setControlsPosition: setControlsPosition, hideEmissions: hideEmissions, setHideEmissions: setHideEmissions, avatarType: avatarType, setAvatarType: setAvatarType, enablePositionControls: enablePositionControls, setEnablePositionControls: setEnablePositionControls, isAvatar3d: !!(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatarURL), additionalSettings: additionalSettings, speakerMuted: speakerMuted })), showChatHistoryDrawer && ((0, jsx_runtime_1.jsx)(ChatHistory_1.default, { open: !!showChatHistoryDrawer, onClose: () => setShowChatHistoryDrawer(false), resumeSession: chatLog => {
2430
- setChatLogID(chatLog.chatLogID);
2431
- onClickStart(undefined, false, chatLog);
2432
- setShowChatHistoryDrawer(false);
2433
- }, apiClient: client, sessionId: sessionId || '', memori: memori, baseUrl: baseUrl, history: history, apiUrl: client.constants.BACKEND_URL, loginToken: loginToken, language: language, userLang: userLang, isMultilanguageEnabled: isMultilanguageEnabled })), showKnownFactsDrawer && sessionId && ((0, jsx_runtime_1.jsx)(KnownFacts_1.default, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && ((0, jsx_runtime_1.jsx)(ExpertsDrawer_1.default, { apiUrl: client.constants.BACKEND_URL, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) })), showLoginDrawer && (tenant === null || tenant === void 0 ? void 0 : tenant.name) && ((0, jsx_runtime_1.jsx)(LoginDrawer_1.default, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), drawerClassName: selectedLayout === 'WEBSITE_ASSISTANT'
2434
- ? 'memori-drawer--above-website-assistant'
2435
- : undefined, onLogin: (user, token) => {
2436
- var _a, _b, _c, _d;
2437
- reopenSession(false, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), [], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2438
- LANG: userLang,
2439
- PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2440
- 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()) || '',
2441
- ...(initialContextVars || {}),
2442
- }, undefined, birthDate, { loginToken: token }, undefined, sessionId).then(state => {
2443
- var _a, _b;
2444
- setShowLoginDrawer(false);
2445
- setUser(user);
2446
- setLoginToken(token);
2447
- userTokenRef.current = token;
2448
- (0, configuration_1.setLocalConfig)('loginToken', token);
2449
- if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
2450
- state.sessionID !== sessionId &&
2451
- (state === null || state === void 0 ? void 0 : state.dialogState)) {
2452
- const username = (user === null || user === void 0 ? void 0 : user.userName) || t('login.user');
2453
- pushMessage({
2454
- text: '',
2455
- emitter: state.dialogState.emitter,
2456
- media: (_b = (_a = state.dialogState.emittedMedia) !== null && _a !== void 0 ? _a : state.dialogState.media) !== null && _b !== void 0 ? _b : [],
2457
- fromUser: false,
2458
- initial: t('login.successfullyLoggedIn', {
2459
- username,
2460
- }),
2461
- contextVars: state.dialogState.contextVars,
2462
- date: state.dialogState.currentDate,
2463
- placeName: state.dialogState.currentPlaceName,
2464
- placeLatitude: state.dialogState.currentLatitude,
2465
- placeLongitude: state.dialogState.currentLongitude,
2466
- placeUncertaintyKm: state.dialogState.currentUncertaintyKm,
2467
- tag: state.dialogState.currentTag,
2468
- memoryTags: state.dialogState.memoryTags,
2362
+ }), style: { height }, children: (0, jsx_runtime_1.jsx)(ui_1.MemoriUIProvider, { container: widgetRootEl, theme: widgetTheme, children: (0, jsx_runtime_1.jsx)(widgetSurfaceContext_1.WidgetSurfaceProvider, { value: widgetSurfaceEl, children: (0, jsx_runtime_1.jsxs)("div", { ref: setWidgetSurfaceEl, className: "memori-widget__surface", 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, autoStart: autoStart, sessionId: sessionId, hasUserActivatedSpeak: hasUserActivatedSpeak, loading: loading, avatar3dHidden: avatar3dHidden !== null && avatar3dHidden !== void 0 ? avatar3dHidden : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatar_3d_hidden }), (0, jsx_runtime_1.jsx)(ArtifactAPI_1.ArtifactAPIBridge, { pushMessage: (message) => {
2363
+ setHistory(history => {
2364
+ if (!history.length)
2365
+ return history;
2366
+ const lastMessage = history[history.length - 1];
2367
+ if (!lastMessage || lastMessage.fromUser)
2368
+ return history;
2369
+ const updatedLastMessage = {
2370
+ ...lastMessage,
2371
+ text: lastMessage.text + message.text,
2372
+ };
2373
+ return [...history.slice(0, -1), updatedLastMessage];
2469
2374
  });
2470
- setCurrentDialogState(state.dialogState);
2471
- }
2472
- });
2473
- }, setUser: setUser, onLogout: () => {
2474
- if (!loginToken)
2475
- return;
2476
- client.backend.pwlUserLogout(loginToken).then(() => {
2477
- setShowLoginDrawer(false);
2478
- setUser(undefined);
2479
- setLoginToken(undefined);
2480
- userTokenRef.current = undefined;
2481
- (0, configuration_1.removeLocalConfig)('loginToken');
2482
- });
2483
- } }))] }) }));
2375
+ } }), (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: (values) => {
2376
+ var _a, _b, _c, _d;
2377
+ if (values['password'])
2378
+ setMemoriPwd(values['password']);
2379
+ if (values['password'])
2380
+ memoriPassword = values['password'];
2381
+ if (values['tokens'])
2382
+ setMemoriTokens(values['tokens']);
2383
+ return reopenSession(!sessionId, values['password'], values['tokens'], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2384
+ LANG: userLang,
2385
+ PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2386
+ 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()) || '',
2387
+ ...(initialContextVars || {}),
2388
+ }, initialQuestion, birthDate)
2389
+ .then(state => {
2390
+ if (!(state === null || state === void 0 ? void 0 : state.sessionID)) {
2391
+ throw new Error('AUTH_FAILED');
2392
+ }
2393
+ setAuthModalState(null);
2394
+ if (state === null || state === void 0 ? void 0 : state.dialogState) {
2395
+ setHasUserActivatedSpeak(true);
2396
+ }
2397
+ else {
2398
+ onClickStart(state);
2399
+ }
2400
+ })
2401
+ .catch(error => {
2402
+ if (!(error instanceof Error) ||
2403
+ error.message !== 'AUTH_FAILED') {
2404
+ setGotErrorInOpening(true);
2405
+ }
2406
+ throw error;
2407
+ });
2408
+ }, minimumNumberOfRecoveryTokens: (_17 = memori === null || memori === void 0 ? void 0 : memori.minimumNumberOfRecoveryTokens) !== null && _17 !== void 0 ? _17 : 1 })), isClient && ((0, jsx_runtime_1.jsx)(AgeVerificationModal_1.default, { visible: showAgeVerification, minAge: minAge, onClose: birthDate => {
2409
+ var _a, _b, _c, _d;
2410
+ if (birthDate) {
2411
+ setBirthDate(birthDate);
2412
+ (0, configuration_1.setLocalConfig)('birthDate', birthDate);
2413
+ 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, {
2414
+ LANG: userLang,
2415
+ PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2416
+ 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()) || '',
2417
+ ...(initialContextVars || {}),
2418
+ }, initialQuestion, birthDate)
2419
+ .then(state => {
2420
+ setShowAgeVerification(false);
2421
+ setAuthModalState(null);
2422
+ onClickStart(state || undefined);
2423
+ })
2424
+ .catch(() => {
2425
+ setShowAgeVerification(false);
2426
+ setGotErrorInOpening(true);
2427
+ });
2428
+ }
2429
+ else {
2430
+ setShowAgeVerification(false);
2431
+ setClickedStart(false);
2432
+ }
2433
+ } })), showSettingsDrawer && ((0, jsx_runtime_1.jsx)(SettingsDrawer_1.default, { layout: selectedLayout, open: !!showSettingsDrawer, onClose: () => setShowSettingsDrawer(false), microphoneMode: continuousSpeech ? 'CONTINUOUS' : 'HOLD_TO_TALK', continuousSpeechTimeout: continuousSpeechTimeout, setMicrophoneMode: mode => setContinuousSpeech(mode === 'CONTINUOUS'), setContinuousSpeechTimeout: setContinuousSpeechTimeout, controlsPosition: controlsPosition, setControlsPosition: setControlsPosition, hideEmissions: hideEmissions, setHideEmissions: setHideEmissions, avatarType: avatarType, setAvatarType: setAvatarType, enablePositionControls: enablePositionControls, setEnablePositionControls: setEnablePositionControls, isAvatar3d: !!(integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.avatarURL), additionalSettings: additionalSettings, speakerMuted: speakerMuted })), showChatHistoryDrawer && ((0, jsx_runtime_1.jsx)(ChatHistory_1.default, { open: !!showChatHistoryDrawer, onClose: () => setShowChatHistoryDrawer(false), resumeSession: chatLog => {
2434
+ setChatLogID(chatLog.chatLogID);
2435
+ onClickStart(undefined, false, chatLog);
2436
+ setShowChatHistoryDrawer(false);
2437
+ }, apiClient: client, sessionId: sessionId || '', memori: memori, baseUrl: baseUrl, history: history, apiUrl: client.constants.BACKEND_URL, loginToken: loginToken, language: language, userLang: userLang, isMultilanguageEnabled: isMultilanguageEnabled })), showKnownFactsDrawer && sessionId && ((0, jsx_runtime_1.jsx)(KnownFacts_1.default, { apiClient: client, memori: memori, sessionID: sessionId, visible: showKnownFactsDrawer, closeDrawer: () => setShowKnownFactsDrawer(false) })), showExpertsDrawer && !!experts && ((0, jsx_runtime_1.jsx)(ExpertsDrawer_1.default, { apiUrl: client.constants.BACKEND_URL, baseUrl: baseUrl, tenant: tenant, experts: experts, open: showExpertsDrawer, onClose: () => setShowExpertsDrawer(false) })), showLoginDrawer && (tenant === null || tenant === void 0 ? void 0 : tenant.name) && ((0, jsx_runtime_1.jsx)(LoginDrawer_1.default, { tenant: tenant, apiClient: client, open: !!showLoginDrawer, user: user, loginToken: loginToken, onClose: () => setShowLoginDrawer(false), drawerClassName: selectedLayout === 'WEBSITE_ASSISTANT'
2438
+ ? 'memori-drawer--above-website-assistant'
2439
+ : undefined, onLogin: (user, token) => {
2440
+ var _a, _b, _c, _d;
2441
+ reopenSession(false, memoriPassword || memoriPwd || (memori === null || memori === void 0 ? void 0 : memori.secretToken), [], personification === null || personification === void 0 ? void 0 : personification.tag, personification === null || personification === void 0 ? void 0 : personification.pin, {
2442
+ LANG: userLang,
2443
+ PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
2444
+ 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()) || '',
2445
+ ...(initialContextVars || {}),
2446
+ }, undefined, birthDate, { loginToken: token }, undefined, sessionId).then(state => {
2447
+ var _a, _b;
2448
+ setShowLoginDrawer(false);
2449
+ setUser(user);
2450
+ setLoginToken(token);
2451
+ userTokenRef.current = token;
2452
+ (0, configuration_1.setLocalConfig)('loginToken', token);
2453
+ if ((state === null || state === void 0 ? void 0 : state.sessionID) &&
2454
+ state.sessionID !== sessionId &&
2455
+ (state === null || state === void 0 ? void 0 : state.dialogState)) {
2456
+ const username = (user === null || user === void 0 ? void 0 : user.userName) || t('login.user');
2457
+ pushMessage({
2458
+ text: '',
2459
+ emitter: state.dialogState.emitter,
2460
+ media: (_b = (_a = state.dialogState.emittedMedia) !== null && _a !== void 0 ? _a : state.dialogState.media) !== null && _b !== void 0 ? _b : [],
2461
+ fromUser: false,
2462
+ initial: t('login.successfullyLoggedIn', {
2463
+ username,
2464
+ }),
2465
+ contextVars: state.dialogState.contextVars,
2466
+ date: state.dialogState.currentDate,
2467
+ placeName: state.dialogState.currentPlaceName,
2468
+ placeLatitude: state.dialogState.currentLatitude,
2469
+ placeLongitude: state.dialogState.currentLongitude,
2470
+ placeUncertaintyKm: state.dialogState.currentUncertaintyKm,
2471
+ tag: state.dialogState.currentTag,
2472
+ memoryTags: state.dialogState.memoryTags,
2473
+ });
2474
+ setCurrentDialogState(state.dialogState);
2475
+ }
2476
+ });
2477
+ }, setUser: setUser, onLogout: () => {
2478
+ if (!loginToken)
2479
+ return;
2480
+ client.backend.pwlUserLogout(loginToken).then(() => {
2481
+ setShowLoginDrawer(false);
2482
+ setUser(undefined);
2483
+ setLoginToken(undefined);
2484
+ userTokenRef.current = undefined;
2485
+ (0, configuration_1.removeLocalConfig)('loginToken');
2486
+ });
2487
+ } }))] }) }) }) }));
2484
2488
  };
2485
2489
  exports.default = MemoriWidget;
2486
2490
  //# sourceMappingURL=MemoriWidget.js.map