@carbon/ai-chat 1.10.0 → 1.11.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/css/chat-float-layout.css +201 -0
  2. package/dist/css/chat-launcher-layout.css +140 -0
  3. package/dist/es/aiChatEntry.js +53 -18
  4. package/dist/es/aiChatEntry.js.map +1 -1
  5. package/dist/es/chat.ChatAppEntry.js +525 -256
  6. package/dist/es/chat.ChatAppEntry.js.map +1 -1
  7. package/dist/es/chat.languageUtils.js +18 -1
  8. package/dist/es/chat.languageUtils.js.map +1 -1
  9. package/dist/es/serverEntry.js +2 -2
  10. package/dist/es/web-components/cds-aichat-container/index.js +124 -8
  11. package/dist/es/web-components/cds-aichat-container/index.js.map +1 -1
  12. package/dist/es/web-components/cds-aichat-custom-element/index.js +35 -9
  13. package/dist/es/web-components/cds-aichat-custom-element/index.js.map +1 -1
  14. package/dist/es-custom/aiChatEntry.js +53 -18
  15. package/dist/es-custom/aiChatEntry.js.map +1 -1
  16. package/dist/es-custom/chat.ChatAppEntry.js +525 -256
  17. package/dist/es-custom/chat.ChatAppEntry.js.map +1 -1
  18. package/dist/es-custom/chat.languageUtils.js +18 -1
  19. package/dist/es-custom/chat.languageUtils.js.map +1 -1
  20. package/dist/es-custom/serverEntry.js +2 -2
  21. package/dist/es-custom/web-components/cds-aichat-container/index.js +124 -8
  22. package/dist/es-custom/web-components/cds-aichat-container/index.js.map +1 -1
  23. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js +35 -9
  24. package/dist/es-custom/web-components/cds-aichat-custom-element/index.js.map +1 -1
  25. package/dist/scss/_chat-float-layout.scss +169 -0
  26. package/dist/scss/_chat-launcher-layout.scss +98 -0
  27. package/dist/scss/_chat-theme.scss +40 -0
  28. package/dist/types/aiChatEntry.d.ts +21 -3
  29. package/dist/types/{serverEntry-Bo87nhgF.d.ts → serverEntry-DGYva2n0.d.ts} +1872 -1519
  30. package/dist/types/serverEntry.d.ts +1 -1
  31. package/package.json +17 -13
@@ -0,0 +1,201 @@
1
+ @charset "UTF-8";
2
+ /*
3
+ * Copyright IBM Corp. 2026
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * Float positioning styles for Carbon AI Chat floating widget mode.
10
+ * Following @carbon/styles component patterns where styles are wrapped in mixins.
11
+ *
12
+ * These styles can be applied to both cds-aichat-shell (for lazy loading placeholders)
13
+ * and the full ChatContainer to ensure consistent positioning and animations.
14
+ *
15
+ * Usage (Sass — mixin, for composing into your own stylesheet):
16
+ * @use "@carbon/ai-chat/scss/chat-float-layout";
17
+ * @include chat-float-layout.float-positioning;
18
+ *
19
+ * Usage (CSS — pre-compiled, no Sass pipeline needed):
20
+ * @import "@carbon/ai-chat/css/chat-float-layout.css";
21
+ *
22
+ * Classes generated:
23
+ * - .cds-aichat-float--open — base fixed positioning
24
+ * - .cds-aichat-float--opening — entrance animation
25
+ * - .cds-aichat-float--closing — exit animation
26
+ * - .cds-aichat-float--close — fully hidden state
27
+ * - .cds-aichat-float--mobile — mobile overrides
28
+ */
29
+ /*
30
+ * Copyright IBM Corp. 2025
31
+ *
32
+ * This source code is licensed under the Apache-2.0 license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */
35
+ /*
36
+ * Copyright IBM Corp. 2025
37
+ *
38
+ * This source code is licensed under the Apache-2.0 license found in the
39
+ * LICENSE file in the root directory of this source tree.
40
+ */
41
+ /*
42
+ * Copyright IBM Corp. 2025
43
+ *
44
+ * This source code is licensed under the Apache-2.0 license found in the
45
+ * LICENSE file in the root directory of this source tree.
46
+ */
47
+ /*
48
+ * Copyright IBM Corp. 2025
49
+ *
50
+ * This source code is licensed under the Apache-2.0 license found in the
51
+ * LICENSE file in the root directory of this source tree.
52
+ */
53
+ /*
54
+ * Copyright IBM Corp. 2025
55
+ *
56
+ * This source code is licensed under the Apache-2.0 license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */
59
+ /*
60
+ * Copyright IBM Corp. 2026
61
+ *
62
+ * This source code is licensed under the Apache-2.0 license found in the
63
+ * LICENSE file in the root directory of this source tree.
64
+ */
65
+ /**
66
+ * Float positioning styles for Carbon AI Chat floating widget mode.
67
+ * Following @carbon/styles component patterns where styles are wrapped in mixins.
68
+ *
69
+ * These styles can be applied to both cds-aichat-shell (for lazy loading placeholders)
70
+ * and the full ChatContainer to ensure consistent positioning and animations.
71
+ *
72
+ * Usage (Sass — mixin, for composing into your own stylesheet):
73
+ * @use "@carbon/ai-chat/scss/chat-float-layout";
74
+ * @include chat-float-layout.float-positioning;
75
+ *
76
+ * Usage (CSS — pre-compiled, no Sass pipeline needed):
77
+ * @import "@carbon/ai-chat/css/chat-float-layout.css";
78
+ *
79
+ * Classes generated:
80
+ * - .cds-aichat-float--open — base fixed positioning
81
+ * - .cds-aichat-float--opening — entrance animation
82
+ * - .cds-aichat-float--closing — exit animation
83
+ * - .cds-aichat-float--close — fully hidden state
84
+ * - .cds-aichat-float--mobile — mobile overrides
85
+ */
86
+ /*
87
+ * Copyright IBM Corp. 2025
88
+ *
89
+ * This source code is licensed under the Apache-2.0 license found in the
90
+ * LICENSE file in the root directory of this source tree.
91
+ */
92
+ /*
93
+ * Copyright IBM Corp. 2025
94
+ *
95
+ * This source code is licensed under the Apache-2.0 license found in the
96
+ * LICENSE file in the root directory of this source tree.
97
+ */
98
+ /* ============================================================================
99
+ FLOAT - BASE POSITIONING
100
+ Fixed positioning for floating widget mode
101
+ Uses logical properties for automatic RTL support
102
+ ============================================================================ */
103
+ .cds-aichat-float--open {
104
+ position: fixed;
105
+ z-index: var(--cds-aichat-z-index, 99999);
106
+ block-size: var(--cds-aichat-height, calc(100vh - 2 * 2rem));
107
+ inline-size: var(--cds-aichat-width, 380px);
108
+ inset-block-end: var(--cds-aichat-bottom-position, 3rem);
109
+ inset-block-start: var(--cds-aichat-top-position, auto);
110
+ inset-inline-end: var(--cds-aichat-right-position, 2rem);
111
+ inset-inline-start: var(--cds-aichat-left-position, auto);
112
+ max-block-size: var(--cds-aichat-max-height, 640px);
113
+ max-inline-size: var(--cds-aichat-messages-max-width, 672px);
114
+ min-block-size: var(--cds-aichat-min-height, 150px);
115
+ }
116
+
117
+ /* ============================================================================
118
+ FLOAT - OPENING ANIMATION
119
+ Animation when chat is opening
120
+ ============================================================================ */
121
+ .cds-aichat-float--opening {
122
+ animation: none;
123
+ }
124
+
125
+ @media screen and (prefers-reduced-motion: no-preference) {
126
+ .cds-aichat-float--opening:not(.cds-aichat-float--mobile) {
127
+ animation: cds-aichat-float-in 240ms cubic-bezier(0, 0, 0.3, 1) both;
128
+ }
129
+ }
130
+ /* ============================================================================
131
+ FLOAT - CLOSING ANIMATION
132
+ Animation when chat is closing
133
+ ============================================================================ */
134
+ .cds-aichat-float--closing {
135
+ animation: cds-aichat-float-out 110ms cubic-bezier(0.4, 0.14, 1, 1) both;
136
+ }
137
+
138
+ @media screen and (prefers-reduced-motion: reduce) {
139
+ .cds-aichat-float--closing {
140
+ animation: none;
141
+ }
142
+ }
143
+ /* ============================================================================
144
+ FLOAT - CLOSED STATE
145
+ Styles when chat is fully closed
146
+ ============================================================================ */
147
+ .cds-aichat-float--close {
148
+ display: none;
149
+ overflow: hidden;
150
+ border: none;
151
+ box-shadow: none;
152
+ }
153
+
154
+ /* ============================================================================
155
+ FLOAT - MOBILE RESPONSIVE
156
+ Mobile-specific positioning and animations
157
+ ============================================================================ */
158
+ .cds-aichat-float--mobile {
159
+ position: fixed;
160
+ z-index: var(--cds-aichat-z-index, 99999);
161
+ block-size: var(--cds-aichat-height, calc(100vh - 2 * 2rem));
162
+ inline-size: var(--cds-aichat-width, 380px);
163
+ inset-block-end: var(--cds-aichat-bottom-position, 3rem);
164
+ inset-block-start: var(--cds-aichat-top-position, auto);
165
+ inset-inline-end: var(--cds-aichat-right-position, 2rem);
166
+ inset-inline-start: var(--cds-aichat-left-position, auto);
167
+ max-block-size: var(--cds-aichat-max-height, 640px);
168
+ max-inline-size: 100%;
169
+ min-block-size: var(--cds-aichat-min-height, 150px);
170
+ }
171
+
172
+ .cds-aichat-float--mobile.cds-aichat-float--opening {
173
+ inset-block-end: 1px;
174
+ inset-inline-start: 1px;
175
+ }
176
+
177
+ @media screen and (prefers-reduced-motion: no-preference) {
178
+ .cds-aichat-float--mobile.cds-aichat-float--opening {
179
+ animation: cds-aichat-float-in 240ms cubic-bezier(0, 0, 0.3, 1) both;
180
+ }
181
+ }
182
+ /* ============================================================================
183
+ FLOAT - KEYFRAME ANIMATIONS
184
+ Animation definitions for opening and closing
185
+ ============================================================================ */
186
+ @keyframes cds-aichat-float-in {
187
+ 0% {
188
+ opacity: 0;
189
+ }
190
+ 100% {
191
+ opacity: 1;
192
+ }
193
+ }
194
+ @keyframes cds-aichat-float-out {
195
+ 0% {
196
+ opacity: 1;
197
+ }
198
+ 100% {
199
+ opacity: 0;
200
+ }
201
+ }
@@ -0,0 +1,140 @@
1
+ @charset "UTF-8";
2
+ /*
3
+ * Copyright IBM Corp. 2025
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * Launcher positioning styles for Carbon AI Chat floating widget mode.
10
+ * Following @carbon/styles component patterns where styles are wrapped in mixins.
11
+ *
12
+ * These styles provide fixed positioning and entrance animation for a launcher
13
+ * button, matching the positioning of the float layout. Extended (pill/CTA)
14
+ * styles are intentionally excluded — include Launcher.scss for those.
15
+ *
16
+ * Usage (Sass — mixin, for composing into your own stylesheet):
17
+ * @use "@carbon/ai-chat/scss/chat-launcher-layout";
18
+ * @include chat-launcher-layout.launcher-positioning;
19
+ *
20
+ * Usage (CSS — pre-compiled, no Sass pipeline needed):
21
+ * @import "@carbon/ai-chat/css/chat-launcher-layout.css";
22
+ *
23
+ * Classes generated:
24
+ * - .cds-aichat-launcher — base fixed positioning
25
+ * - .cds-aichat-launcher--hidden — visually hidden (preserves layout)
26
+ */
27
+ /*
28
+ * Copyright IBM Corp. 2025
29
+ *
30
+ * This source code is licensed under the Apache-2.0 license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ */
33
+ /*
34
+ * Copyright IBM Corp. 2025
35
+ *
36
+ * This source code is licensed under the Apache-2.0 license found in the
37
+ * LICENSE file in the root directory of this source tree.
38
+ */
39
+ /*
40
+ * Copyright IBM Corp. 2025
41
+ *
42
+ * This source code is licensed under the Apache-2.0 license found in the
43
+ * LICENSE file in the root directory of this source tree.
44
+ */
45
+ /*
46
+ * Copyright IBM Corp. 2025
47
+ *
48
+ * This source code is licensed under the Apache-2.0 license found in the
49
+ * LICENSE file in the root directory of this source tree.
50
+ */
51
+ /*
52
+ * Copyright IBM Corp. 2025
53
+ *
54
+ * This source code is licensed under the Apache-2.0 license found in the
55
+ * LICENSE file in the root directory of this source tree.
56
+ */
57
+ /*
58
+ * Copyright IBM Corp. 2025
59
+ *
60
+ * This source code is licensed under the Apache-2.0 license found in the
61
+ * LICENSE file in the root directory of this source tree.
62
+ */
63
+ /**
64
+ * Launcher positioning styles for Carbon AI Chat floating widget mode.
65
+ * Following @carbon/styles component patterns where styles are wrapped in mixins.
66
+ *
67
+ * These styles provide fixed positioning and entrance animation for a launcher
68
+ * button, matching the positioning of the float layout. Extended (pill/CTA)
69
+ * styles are intentionally excluded — include Launcher.scss for those.
70
+ *
71
+ * Usage (Sass — mixin, for composing into your own stylesheet):
72
+ * @use "@carbon/ai-chat/scss/chat-launcher-layout";
73
+ * @include chat-launcher-layout.launcher-positioning;
74
+ *
75
+ * Usage (CSS — pre-compiled, no Sass pipeline needed):
76
+ * @import "@carbon/ai-chat/css/chat-launcher-layout.css";
77
+ *
78
+ * Classes generated:
79
+ * - .cds-aichat-launcher — base fixed positioning
80
+ * - .cds-aichat-launcher--hidden — visually hidden (preserves layout)
81
+ */
82
+ /*
83
+ * Copyright IBM Corp. 2025
84
+ *
85
+ * This source code is licensed under the Apache-2.0 license found in the
86
+ * LICENSE file in the root directory of this source tree.
87
+ */
88
+ /*
89
+ * Copyright IBM Corp. 2025
90
+ *
91
+ * This source code is licensed under the Apache-2.0 license found in the
92
+ * LICENSE file in the root directory of this source tree.
93
+ */
94
+ /* ============================================================================
95
+ LAUNCHER - BASE POSITIONING
96
+ Fixed positioning for the launcher button
97
+ Uses logical properties for automatic RTL support
98
+ ============================================================================ */
99
+ .cds-aichat-launcher {
100
+ position: fixed;
101
+ z-index: var(--cds-aichat-z-index, 99999);
102
+ inset-block-end: var(--cds-aichat-launcher-position-bottom, 3rem);
103
+ inset-inline-end: var(--cds-aichat-launcher-position-right, 2rem);
104
+ }
105
+ @media (prefers-reduced-motion: no-preference) {
106
+ .cds-aichat-launcher {
107
+ animation: cds-aichat-launcher-in 150ms cubic-bezier(0, 0, 0.3, 1) both;
108
+ }
109
+ }
110
+
111
+ /* ============================================================================
112
+ LAUNCHER - RTL POSITIONING
113
+ Use physical left/right instead of logical properties — logical properties
114
+ on position:fixed elements resolve against the viewport direction, which
115
+ may not reflect a dir="rtl" set on a sub-element of the page.
116
+ ============================================================================ */
117
+ [dir=rtl] .cds-aichat-launcher {
118
+ inset-inline: var(--cds-aichat-launcher-position-right, 2rem) unset;
119
+ }
120
+
121
+ /* ============================================================================
122
+ LAUNCHER - HIDDEN STATE
123
+ Hides the launcher while preserving its space (avoids re-triggering
124
+ the entrance animation on remount)
125
+ ============================================================================ */
126
+ .cds-aichat-launcher--hidden {
127
+ visibility: hidden;
128
+ }
129
+
130
+ /* ============================================================================
131
+ LAUNCHER - KEYFRAME ANIMATIONS
132
+ ============================================================================ */
133
+ @keyframes cds-aichat-launcher-in {
134
+ 0% {
135
+ opacity: 0;
136
+ }
137
+ 100% {
138
+ opacity: 1;
139
+ }
140
+ }
@@ -1,21 +1,21 @@
1
1
  import { B as BusEventType } from "./chat.languageUtils.js";
2
2
 
3
- export { a as ButtonItemKind, b as ButtonItemType, C as CancellationReason, c as CarbonTheme, d as CornersType, E as ErrorType, F as FeedbackInteractionType, e as FileStatusValue, H as HeaderMenuClickType, f as HumanAgentMessageType, g as HumanAgentsOnlineStatus, I as IFrameItemDisplayOption, M as MessageErrorState, h as MessageInputType, i as MessageResponseTypes, j as MessageSendSource, k as MinimizeButtonIconType, O as OnErrorType, l as OptionItemPreference, P as PageObjectId, m as PanelType, R as ReasoningStepOpenState, S as ScreenShareState, U as UserType, V as ViewChangeReason, n as ViewType, W as WidthOptions, o as WriteableElementName, p as enLanguagePack } from "./chat.languageUtils.js";
3
+ export { a as ButtonItemKind, b as ButtonItemType, C as CancellationReason, c as CarbonTheme, d as CornersType, E as ErrorType, F as FeedbackInteractionType, e as FileStatusValue, H as HeaderMenuClickType, f as HumanAgentMessageType, g as HumanAgentsOnlineStatus, I as IFrameItemDisplayOption, M as MessageErrorState, h as MessageInputType, i as MessageResponseTypes, j as MessageSendSource, k as MinimizeButtonIconType, O as OnErrorType, l as OptionItemPreference, P as PageObjectId, m as PanelType, n as PendingUploadStatus, R as ReasoningStepOpenState, S as ScreenShareState, U as UserType, V as ViewChangeReason, o as ViewType, W as WidthOptions, p as WriteableElementName, q as enLanguagePack } from "./chat.languageUtils.js";
4
4
 
5
5
  export { L as LayoutCustomProperties } from "./chat.LayoutCustomProperties.js";
6
6
 
7
+ import { I as IS_SESSION_STORAGE, g as getSuffix, V as VERSION, i as isBrowser, C as ChatAppEntry } from "./chat.ChatAppEntry.js";
8
+
7
9
  import { __decorate } from "tslib";
8
10
 
9
11
  import { createComponent } from "@lit/react";
10
12
 
11
13
  import { css, LitElement } from "lit";
12
14
 
13
- import React, { useMemo, useRef, useState, useEffect, useCallback } from "react";
15
+ import React, { useMemo, useRef, useState, useEffect, useCallback, useLayoutEffect } from "react";
14
16
 
15
17
  import { createPortal } from "react-dom";
16
18
 
17
- import { i as isBrowser, C as ChatAppEntry } from "./chat.ChatAppEntry.js";
18
-
19
19
  import { carbonElement } from "@carbon/ai-chat-components/es/globals/decorators/index.js";
20
20
 
21
21
  export { ChainOfThoughtStepStatus } from "@carbon/ai-chat-components/es/components/chain-of-thought/defs.js";
@@ -70,6 +70,10 @@ import "@carbon/icons/es/right-panel--open/16.js";
70
70
 
71
71
  import "@carbon/icons/es/right-panel--close/16.js";
72
72
 
73
+ import "@carbon/icons/es/bottom-panel--close/16.js";
74
+
75
+ import "@carbon/icons/es/bottom-panel--open/16.js";
76
+
73
77
  import "@carbon/icons/es/subtract--large/16.js";
74
78
 
75
79
  import "@carbon/web-components/es/components/ai-label/defs.js";
@@ -226,6 +230,26 @@ import "@carbon/ai-chat-components/es/react/toolbar.js";
226
230
 
227
231
  import "@carbon/web-components/es/components/chat-button/chat-button.js";
228
232
 
233
+ function readCarbonChatSession(namespace) {
234
+ try {
235
+ if (!IS_SESSION_STORAGE()) {
236
+ return null;
237
+ }
238
+ const key = `CARBON_CHAT_SESSION${getSuffix(namespace)}`;
239
+ const raw = window.sessionStorage.getItem(key);
240
+ if (!raw) {
241
+ return null;
242
+ }
243
+ const session = JSON.parse(raw);
244
+ if (session?.version !== VERSION) {
245
+ return null;
246
+ }
247
+ return session;
248
+ } catch {
249
+ return null;
250
+ }
251
+ }
252
+
229
253
  let ChatContainerReact = class ChatContainerReact extends LitElement {
230
254
  firstUpdated(changedProperties) {
231
255
  super.firstUpdated(changedProperties);
@@ -251,7 +275,7 @@ const ReactChatContainer = React.memo(createComponent({
251
275
  }));
252
276
 
253
277
  function ChatContainer(props) {
254
- const {onBeforeRender, onAfterRender, strings, serviceDeskFactory, serviceDesk, renderUserDefinedResponse, renderCustomMessageFooter, renderWriteableElements, element, onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, shouldSanitizeHTML, header, history, layout, messaging, isReadonly, persistFeedback, assistantName, locale, homescreen, launcher, input, keyboardShortcuts} = props;
278
+ const {onBeforeRender, onAfterRender, strings, serviceDeskFactory, serviceDesk, renderUserDefinedResponse, renderCustomMessageFooter, renderWriteableElements, element, onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, shouldSanitizeHTML, header, history, layout, messaging, isReadonly, persistFeedback, assistantName, assistantAvatarUrl, locale, homescreen, launcher, input, keyboardShortcuts, upload, ...domProps} = props;
255
279
  const config = useMemo(() => ({
256
280
  onError,
257
281
  openChatByDefault,
@@ -271,12 +295,14 @@ function ChatContainer(props) {
271
295
  isReadonly,
272
296
  persistFeedback,
273
297
  assistantName,
298
+ assistantAvatarUrl,
274
299
  locale,
275
300
  homescreen,
276
301
  launcher,
277
302
  input,
278
- keyboardShortcuts
279
- }), [ onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, shouldSanitizeHTML, header, history, layout, messaging, isReadonly, persistFeedback, assistantName, locale, homescreen, launcher, input, keyboardShortcuts ]);
303
+ keyboardShortcuts,
304
+ upload
305
+ }), [ onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, shouldSanitizeHTML, header, history, layout, messaging, isReadonly, persistFeedback, assistantName, assistantAvatarUrl, locale, homescreen, launcher, input, keyboardShortcuts, upload ]);
280
306
  const wrapperRef = useRef(null);
281
307
  const [wrapper, setWrapper] = useState(null);
282
308
  const [container, setContainer] = useState(null);
@@ -345,7 +371,8 @@ function ChatContainer(props) {
345
371
  return null;
346
372
  }
347
373
  return React.createElement(React.Fragment, null, React.createElement(ReactChatContainer, {
348
- ref: wrapperRef
374
+ ref: wrapperRef,
375
+ ...domProps
349
376
  }), container && createPortal(React.createElement(ChatAppEntry, {
350
377
  key: "stable-chat-instance",
351
378
  config,
@@ -381,15 +408,20 @@ if (isBrowser() && !document.getElementById("cds-aichat-custom-element-styles"))
381
408
  }
382
409
 
383
410
  function ChatCustomElement(props) {
384
- const {strings, serviceDeskFactory, serviceDesk, onBeforeRender, onAfterRender, renderUserDefinedResponse, renderCustomMessageFooter, renderWriteableElements, className, id, onViewChange, onViewPreChange, onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, shouldSanitizeHTML, header, history, layout, messaging, isReadonly, persistFeedback, assistantName, locale, homescreen, launcher, input, keyboardShortcuts} = props;
385
- const [customElement, setCustomElement] = useState();
411
+ const {strings, serviceDeskFactory, serviceDesk, onBeforeRender, onAfterRender, renderUserDefinedResponse, renderCustomMessageFooter, renderWriteableElements, className, id, onViewChange, onViewPreChange, onError, openChatByDefault, disclaimer, disableCustomElementMobileEnhancements, debug, exposeServiceManagerForTesting, injectCarbonTheme, aiEnabled, shouldTakeFocusIfOpensAutomatically, namespace, shouldSanitizeHTML, header, history, layout, messaging, isReadonly, persistFeedback, assistantName, assistantAvatarUrl, locale, homescreen, launcher, input, keyboardShortcuts, upload, ...domProps} = props;
412
+ const containerRef = useRef(null);
413
+ const [elementReady, setElementReady] = useState(false);
414
+ useLayoutEffect(() => {
415
+ setElementReady(true);
416
+ }, []);
386
417
  const onBeforeRenderOverride = useCallback(async instance => {
387
418
  function defaultViewChangeHandler(event) {
388
- if (customElement) {
419
+ const el = containerRef.current;
420
+ if (el) {
389
421
  if (event.newViewState.mainWindow) {
390
- customElement.classList.remove("cds-aichat--hidden");
422
+ el.classList.remove("cds-aichat--hidden");
391
423
  } else {
392
- customElement.classList.add("cds-aichat--hidden");
424
+ el.classList.add("cds-aichat--hidden");
393
425
  }
394
426
  }
395
427
  }
@@ -404,12 +436,13 @@ function ChatCustomElement(props) {
404
436
  handler: onViewChange || defaultViewChangeHandler
405
437
  });
406
438
  return onBeforeRender?.(instance);
407
- }, [ onViewPreChange, onViewChange, onBeforeRender, customElement ]);
439
+ }, [ onViewPreChange, onViewChange, onBeforeRender ]);
408
440
  return React.createElement("div", {
409
441
  className,
410
442
  id,
411
- ref: setCustomElement
412
- }, customElement && React.createElement(ChatContainer, {
443
+ ref: containerRef,
444
+ ...domProps
445
+ }, elementReady && containerRef.current && React.createElement(ChatContainer, {
413
446
  onError,
414
447
  openChatByDefault,
415
448
  disclaimer,
@@ -428,11 +461,13 @@ function ChatCustomElement(props) {
428
461
  isReadonly,
429
462
  persistFeedback,
430
463
  assistantName,
464
+ assistantAvatarUrl,
431
465
  locale,
432
466
  homescreen,
433
467
  launcher,
434
468
  input,
435
469
  keyboardShortcuts,
470
+ upload,
436
471
  strings,
437
472
  serviceDeskFactory,
438
473
  serviceDesk,
@@ -441,9 +476,9 @@ function ChatCustomElement(props) {
441
476
  renderUserDefinedResponse,
442
477
  renderCustomMessageFooter,
443
478
  renderWriteableElements,
444
- element: customElement
479
+ element: containerRef.current
445
480
  }));
446
481
  }
447
482
 
448
- export { BusEventType, ChatContainer, ChatCustomElement };
483
+ export { BusEventType, ChatContainer, ChatCustomElement, readCarbonChatSession };
449
484
  //# sourceMappingURL=aiChatEntry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aiChatEntry.js","sources":["../../../../src/react/ChatContainer.tsx","../../../../src/react/ChatCustomElement.tsx"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport { createComponent } from \"@lit/react\";\nimport { css, LitElement, PropertyValues } from \"lit\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport ChatAppEntry from \"../chat/ChatAppEntry\";\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { ChatContainerProps } from \"../types/component/ChatContainer\";\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport { PublicConfig } from \"../types/config/PublicConfig\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * This component creates a custom element protected by a shadow DOM to render the React application into. It creates\n * slotted elements for user_defined responses and for writable elements.\n *\n * The corresponding slots are defined within the React application and are rendered in place.\n */\n\n/**\n * Create a web component to host the React application. We do this so we can provide custom elements and user_defined responses as\n * slotted content so they maintain their own styling in a safe way.\n */\n@carbonElement(\"cds-aichat-react\")\nclass ChatContainerReact extends LitElement {\n static styles = css`\n :host {\n width: 100%;\n height: 100%;\n }\n `;\n\n /**\n * Dispatch a custom event when the shadow DOM is ready\n * This ensures React can safely access shadowRoot\n */\n firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n this.dispatchEvent(new CustomEvent(\"shadow-ready\", { bubbles: true }));\n }\n}\n\n// Wrap the custom element as a React component\nconst ReactChatContainer = React.memo(\n createComponent({\n tagName: \"cds-aichat-react\",\n elementClass: ChatContainerReact,\n react: React,\n }),\n);\n\n/**\n * The ChatContainer controls rendering the React application into the shadow DOM of the cds-aichat-react web component.\n * It also injects the writeable element and user_defined response slots into said web component.\n *\n * @category React\n */\nfunction ChatContainer(props: ChatContainerProps) {\n const {\n onBeforeRender,\n onAfterRender,\n strings,\n serviceDeskFactory,\n serviceDesk,\n renderUserDefinedResponse,\n renderCustomMessageFooter,\n renderWriteableElements,\n element,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n } = props;\n // Reconstruct PublicConfig from flattened props\n const config = useMemo(\n (): PublicConfig => ({\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n }),\n [\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n ],\n );\n\n const wrapperRef = useRef(null); // Ref for the React wrapper component\n const [wrapper, setWrapper] = useState(null);\n const [container, setContainer] = useState<HTMLElement | null>(null); // Actual element we render the React Portal to in the Shadowroot.\n\n const [writeableElementSlots, setWriteableElementSlots] = useState<\n HTMLElement[]\n >([]);\n const [currentInstance, setCurrentInstance] = useState<ChatInstance>(null);\n\n /**\n * Setup the DOM nodes of both the web component to be able to inject slotted content into it, and the element inside the\n * shadow DOM we will inject our React application into.\n */\n useEffect(() => {\n if (!wrapperRef.current) {\n return null; // Early return when there's nothing to set up because the element isn't ready.\n }\n\n let eventListenerAdded = false;\n\n const wrapperElement = wrapperRef.current as unknown as ChatContainerReact;\n\n // We need to check if the element in the shadow DOM we are render the React application to exists.\n // If it doesn't, we need to create and append it.\n\n const handleShadowReady = () => {\n // Now we know shadowRoot is definitely available\n let reactElement = wrapperElement.shadowRoot.querySelector(\n \".cds-aichat--react-app\",\n ) as HTMLElement;\n\n if (!reactElement) {\n reactElement = document.createElement(\"div\");\n reactElement.classList.add(\"cds-aichat--react-app\");\n wrapperElement.shadowRoot.appendChild(reactElement);\n }\n\n if (wrapperElement !== wrapper) {\n setWrapper(wrapperElement);\n }\n if (reactElement !== container) {\n setContainer(reactElement);\n }\n };\n\n if (wrapperElement.shadowRoot) {\n // Already ready\n handleShadowReady();\n } else {\n // Wait for ready event\n eventListenerAdded = true;\n wrapperElement.addEventListener(\"shadow-ready\", handleShadowReady, {\n once: true,\n });\n }\n\n return () => {\n if (eventListenerAdded) {\n wrapperElement.removeEventListener(\"shadow-ready\", handleShadowReady);\n }\n };\n }, [container, wrapper, currentInstance]);\n\n /**\n * Here we write the slotted elements into the wrapper so they are passed into the application to be rendered in their slot.\n */\n useEffect(() => {\n if (wrapper) {\n const combinedNodes: HTMLElement[] = [...writeableElementSlots];\n const currentNodes: HTMLElement[] = Array.from(\n wrapper.childNodes,\n ) as HTMLElement[];\n\n // Append new nodes that aren't already in the container\n combinedNodes.forEach((node) => {\n if (!currentNodes.includes(node)) {\n wrapper.appendChild(node);\n }\n });\n }\n }, [writeableElementSlots, wrapper]);\n\n const onBeforeRenderOverride = useCallback(\n (instance: ChatInstance) => {\n if (instance) {\n const addWriteableElementSlots = () => {\n const slots: HTMLElement[] = Object.entries(\n instance.writeableElements,\n ).map((writeableElement) => {\n const [key, element] = writeableElement;\n element.setAttribute(\"slot\", key); // Assign slot attributes dynamically\n return element;\n });\n setWriteableElementSlots(slots);\n };\n\n addWriteableElementSlots();\n onBeforeRender?.(instance);\n }\n },\n [onBeforeRender],\n );\n\n // If we are in SSR mode, just short circuit here. This prevents all of our window.* and document.* stuff from trying\n // to run and erroring out.\n if (!isBrowser()) {\n return null;\n }\n\n return (\n <>\n <ReactChatContainer ref={wrapperRef} />\n {container &&\n createPortal(\n <ChatAppEntry\n key=\"stable-chat-instance\"\n config={config}\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderCustomMessageFooter={renderCustomMessageFooter}\n renderWriteableElements={renderWriteableElements}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n container={container}\n setParentInstance={setCurrentInstance}\n element={element}\n chatWrapper={wrapper}\n />,\n container,\n )}\n </>\n );\n}\n\nexport { ChatContainer, ChatContainerProps };\n","/*\n * Copyright IBM Corp. 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport React, { useCallback, useState } from \"react\";\n\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport {\n BusEventType,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../types/events/eventBusTypes\";\nimport { ChatContainer, ChatContainerProps } from \"./ChatContainer\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * Properties for the ChatContainer React component. This interface extends\n * {@link ChatContainerProps} and {@link PublicConfig} with additional component-specific props, flattening all\n * config properties as top-level props for better TypeScript IntelliSense.\n *\n * @category React\n */\ninterface ChatCustomElementProps extends ChatContainerProps {\n /**\n * A CSS class name that will be added to the custom element. This class must define the size of the\n * your custom element (width and height or using logical inline-size/block-size).\n *\n * You can make use of onViewPreChange and/or onViewChange to mutate this className value so have open/close animations.\n *\n * By default, the chat will just set the chat shell to a 0x0 size and mark everything but the launcher (is you are using it)\n * as display: none; if the chat is set to closed.\n */\n className: string;\n\n /**\n * An optional id that will be added to the custom element.\n */\n id?: string;\n\n /**\n * Called before a view change (chat opening/closing). The chat will hide the chat shell inside your custom element\n * to prevent invisible keyboard stops when the view change is *complete*.\n *\n * Use this callback to update your className value *before* the view change happens if you want to add any open/close\n * animations to your custom element before the chat shell inner contents are hidden. It is async and so you can\n * tie it to native the AnimationEvent and only return when your animations have completed.\n *\n * A common pattern is to use this for when the chat is closing and to use onViewChange for when the chat opens.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewPreChange?: (\n event: BusEventViewPreChange,\n instance: ChatInstance,\n ) => Promise<void> | void;\n\n /**\n * Called when the chat view change is complete. If no callback is provided here, the default behavior will be to set\n * the chat shell to 0x0 size and set all inner contents aside from the launcher, if you are using it, to display: none.\n * The inner contents of the chat shell (aside from the launcher if you are using it) are always set to display: none\n * regardless of what is configured with this callback to prevent invisible tab stops and screen reader issues.\n *\n * Use this callback to update your className value when the chat has finished being opened or closed.\n *\n * You can provide a different callback here if you want custom animation behavior when the chat is opened or closed.\n * The animation behavior defined here will run in concert with the chat inside your custom container being hidden.\n *\n * If you want to run animations before the inner contents of the chat shell is shrunk and the inner contents are hidden,\n * make use of onViewPreChange.\n *\n * A common pattern is to use this for when the chat is opening and to use onViewPreChange for when the chat closes.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n}\n\nconst customElementStylesheet =\n isBrowser() && typeof CSSStyleSheet !== \"undefined\"\n ? new CSSStyleSheet()\n : null;\n\nconst hideStyles = `\n .cds-aichat--hidden {\n width: 0 !important;\n height: 0 !important;\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: 0 !important;\n max-height: 0 !important;\n inline-size: 0 !important;\n block-size: 0 !important;\n min-inline-size: 0 !important;\n min-block-size: 0 !important;\n max-inline-size: 0 !important;\n max-block-size: 0 !important;\n overflow: hidden !important;\n }\n`;\n\n// Inject styles using adopted stylesheets when available, fallback to style element\nif (\n isBrowser() &&\n !document.getElementById(\"cds-aichat-custom-element-styles\")\n) {\n if (customElementStylesheet && \"replaceSync\" in customElementStylesheet) {\n customElementStylesheet.replaceSync(hideStyles);\n document.adoptedStyleSheets = [\n ...document.adoptedStyleSheets,\n customElementStylesheet,\n ];\n } else {\n // Fallback for when adoptedStyleSheets are not supported\n const style = document.createElement(\"style\");\n style.id = \"cds-aichat-custom-element-styles\";\n style.textContent = hideStyles;\n document.head.appendChild(style);\n }\n}\n\n/**\n * This is the React component for people injecting a Carbon AI Chat with a custom element.\n *\n * It provides said element any class or id defined on itself for styling. It then calls ChatContainer with the custom\n * element passed in as a property to be used instead of generating an element with the default properties for a\n * floating chat.\n *\n * @category React\n */\nfunction ChatCustomElement(props: ChatCustomElementProps) {\n const {\n strings,\n serviceDeskFactory,\n serviceDesk,\n onBeforeRender,\n onAfterRender,\n renderUserDefinedResponse,\n renderCustomMessageFooter,\n renderWriteableElements,\n className,\n id,\n onViewChange,\n onViewPreChange,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n } = props;\n\n const [customElement, setCustomElement] = useState<HTMLDivElement>();\n\n const onBeforeRenderOverride = useCallback(\n async (instance: ChatInstance) => {\n /**\n * A default handler for the \"view:change\" event. This will be used to show or hide the Carbon AI Chat main window\n * by adding/removing a CSS class that sets the element size to 0x0 when hidden.\n */\n function defaultViewChangeHandler(event: BusEventViewChange) {\n if (customElement) {\n if (event.newViewState.mainWindow) {\n // Show: remove the hidden class, let the provided className handle sizing\n customElement.classList.remove(\"cds-aichat--hidden\");\n } else {\n // Hide: add the hidden class to set size to 0x0\n customElement.classList.add(\"cds-aichat--hidden\");\n }\n }\n }\n\n if (onViewPreChange) {\n instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: onViewPreChange,\n });\n }\n\n instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: onViewChange || defaultViewChangeHandler,\n });\n\n return onBeforeRender?.(instance);\n },\n [onViewPreChange, onViewChange, onBeforeRender, customElement],\n );\n\n return (\n <div className={className} id={id} ref={setCustomElement}>\n {customElement && (\n <ChatContainer\n // Flattened PublicConfig properties\n onError={onError}\n openChatByDefault={openChatByDefault}\n disclaimer={disclaimer}\n disableCustomElementMobileEnhancements={\n disableCustomElementMobileEnhancements\n }\n debug={debug}\n exposeServiceManagerForTesting={exposeServiceManagerForTesting}\n injectCarbonTheme={injectCarbonTheme}\n aiEnabled={aiEnabled}\n shouldTakeFocusIfOpensAutomatically={\n shouldTakeFocusIfOpensAutomatically\n }\n namespace={namespace}\n shouldSanitizeHTML={shouldSanitizeHTML}\n header={header}\n history={history}\n layout={layout}\n messaging={messaging}\n isReadonly={isReadonly}\n persistFeedback={persistFeedback}\n assistantName={assistantName}\n locale={locale}\n homescreen={homescreen}\n launcher={launcher}\n input={input}\n keyboardShortcuts={keyboardShortcuts}\n // Other ChatContainer props\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderCustomMessageFooter={renderCustomMessageFooter}\n renderWriteableElements={renderWriteableElements}\n element={customElement}\n />\n )}\n </div>\n );\n}\n\nexport { ChatCustomElement, ChatCustomElementProps };\n"],"names":["ChatContainerReact","LitElement","firstUpdated","changedProperties","super","this","dispatchEvent","CustomEvent","bubbles","styles","css","__decorate","carbonElement","ReactChatContainer","React","memo","createComponent","tagName","elementClass","react","ChatContainer","props","onBeforeRender","onAfterRender","strings","serviceDeskFactory","serviceDesk","renderUserDefinedResponse","renderCustomMessageFooter","renderWriteableElements","element","onError","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","aiEnabled","shouldTakeFocusIfOpensAutomatically","namespace","shouldSanitizeHTML","header","history","layout","messaging","isReadonly","persistFeedback","assistantName","locale","homescreen","launcher","input","keyboardShortcuts","config","useMemo","wrapperRef","useRef","wrapper","setWrapper","useState","container","setContainer","writeableElementSlots","setWriteableElementSlots","currentInstance","setCurrentInstance","useEffect","current","eventListenerAdded","wrapperElement","handleShadowReady","reactElement","shadowRoot","querySelector","document","createElement","classList","add","appendChild","addEventListener","once","removeEventListener","combinedNodes","currentNodes","Array","from","childNodes","forEach","node","includes","onBeforeRenderOverride","useCallback","instance","addWriteableElementSlots","slots","Object","entries","writeableElements","map","writeableElement","key","setAttribute","isBrowser","Fragment","ref","createPortal","ChatAppEntry","setParentInstance","chatWrapper","customElementStylesheet","CSSStyleSheet","hideStyles","getElementById","replaceSync","adoptedStyleSheets","style","id","textContent","head","ChatCustomElement","className","onViewChange","onViewPreChange","customElement","setCustomElement","async","defaultViewChangeHandler","event","newViewState","mainWindow","remove","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,qBAAN,MAAMA,2BAA2BC;EAY/B,YAAAC,CAAaC;IACXC,MAAMF,aAAaC;IACnBE,KAAKC,cAAc,IAAIC,YAAY,gBAAgB;MAAEC,SAAS;;AAChE;;;AAdOR,mBAAAS,SAASC,GAAG;;;;;;;AADfV,qBAAkBW,WAAA,EADvBC,cAAc,uBACTZ;;AAmBN,MAAMa,qBAAqBC,MAAMC,KAC/BC,gBAAgB;EACdC,SAAS;EACTC,cAAclB;EACdmB,OAAOL;;;AAUX,SAASM,cAAcC;EACrB,OAAMC,gBACUC,eACDC,SACNC,oBACWC,aACPC,2BACcC,2BACAC,yBACFC,SAChBC,SAEAC,mBACUC,YACPC,wCAC4BC,OACjCC,gCACyBC,mBACbC,WACRC,qCAC0BC,WAC1BC,oBACSC,QACZC,SACCC,QACDC,WACGC,YACCC,iBACKC,eACFC,QACPC,YACIC,UACFC,OACHC,qBAEHhC;EAEJ,MAAMiC,SAASC,QACb,OAAA;IACExB;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC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eC,oBAAoBjE;EAE1C,MAAM+B,yBAAyBC,YAC7BkC,MAAOjC;IAKL,SAASkC,yBAAyBC;MAChC,IAAIJ,eAAe;QACjB,IAAII,MAAMC,aAAaC,YAAY;UAEjCN,cAAc/C,UAAUsD,OAAO;AACjC,eAAO;UAELP,cAAc/C,UAAUC,IAAI;AAC9B;AACF;AACF;IAEA,IAAI6C,iBAAiB;MACnB9B,SAASuC,GAAG;QACVC,MAAMC,aAAaC;QACnBC,SAASb;;AAEb;IAEA9B,SAASuC,GAAG;MACVC,MAAMC,aAAaG;MACnBD,SAASd,gBAAgBK;;IAG3B,OAAOzG,iBAAiBuE;KAE1B,EAAC8B,iBAAiBD,cAAcpG,gBAAgBsG;EAGlD,OACE9G,MAAA8D,cAAA,OAAA;IAAK6C;IAAsBJ;IAAQZ,KAAKoB;KACrCD,iBACC9G,oBAACM;IAECW;IACAC;IACAC;IACAC;IAGAC;IACAC;IACAC;IACAC;IACAC;IAGAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IAEA7B;IACAC;IACAC;IACAJ,gBAAgBqE;IAChBpE;IACAI;IACAC;IACAC;IACAC,SAAS8F;;AAKnB;;"}
1
+ {"version":3,"file":"aiChatEntry.js","sources":["../../../../src/globals/utils/readCarbonChatSession.ts","../../../../src/react/ChatContainer.tsx","../../../../src/react/ChatCustomElement.tsx"],"sourcesContent":["/*\n * Copyright IBM Corp. 2026\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport { VERSION } from \"../../chat/utils/environmentVariables\";\nimport { PersistedState } from \"../../types/state/AppState\";\nimport { IS_SESSION_STORAGE } from \"../../chat/utils/browserUtils\";\nimport { getSuffix } from \"../../chat/services/NamespaceService\";\n\n/**\n * Reads and validates the Carbon AI Chat session from sessionStorage.\n * Returns null if no session exists, if the data is corrupt, or if the\n * session was written by a different version of the library (version mismatch).\n *\n * Pass the same namespace value as {@link PublicConfig.namespace} (if any).\n *\n * @example\n * const session = readCarbonChatSession();\n * const wasOpen = session?.viewState.mainWindow === true;\n *\n * @example\n * // With a namespace matching PublicConfig.namespace\n * const session = readCarbonChatSession(\"myapp\");\n * const wasOpen = session?.viewState.mainWindow === true;\n */\nfunction readCarbonChatSession(namespace?: string): PersistedState | null {\n try {\n if (!IS_SESSION_STORAGE()) {\n return null;\n }\n const key = `CARBON_CHAT_SESSION${getSuffix(namespace)}`;\n const raw = window.sessionStorage.getItem(key);\n if (!raw) {\n return null;\n }\n const session = JSON.parse(raw) as PersistedState;\n if (session?.version !== VERSION) {\n return null;\n }\n return session;\n } catch {\n return null;\n }\n}\n\nexport { readCarbonChatSession };\n","/*\n * Copyright IBM Corp. 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport { createComponent } from \"@lit/react\";\nimport { css, LitElement, PropertyValues } from \"lit\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport ChatAppEntry from \"../chat/ChatAppEntry\";\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { ChatContainerProps } from \"../types/component/ChatContainer\";\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport { PublicConfig } from \"../types/config/PublicConfig\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * This component creates a custom element protected by a shadow DOM to render the React application into. It creates\n * slotted elements for user_defined responses and for writable elements.\n *\n * The corresponding slots are defined within the React application and are rendered in place.\n */\n\n/**\n * Create a web component to host the React application. We do this so we can provide custom elements and user_defined responses as\n * slotted content so they maintain their own styling in a safe way.\n */\n@carbonElement(\"cds-aichat-react\")\nclass ChatContainerReact extends LitElement {\n static styles = css`\n :host {\n width: 100%;\n height: 100%;\n }\n `;\n\n /**\n * Dispatch a custom event when the shadow DOM is ready\n * This ensures React can safely access shadowRoot\n */\n firstUpdated(changedProperties: PropertyValues) {\n super.firstUpdated(changedProperties);\n this.dispatchEvent(new CustomEvent(\"shadow-ready\", { bubbles: true }));\n }\n}\n\n// Wrap the custom element as a React component\nconst ReactChatContainer = React.memo(\n createComponent({\n tagName: \"cds-aichat-react\",\n elementClass: ChatContainerReact,\n react: React,\n }),\n);\n\n/**\n * The ChatContainer controls rendering the React application into the shadow DOM of the cds-aichat-react web component.\n * It also injects the writeable element and user_defined response slots into said web component.\n *\n * @category React\n */\nfunction ChatContainer(props: ChatContainerProps) {\n const {\n onBeforeRender,\n onAfterRender,\n strings,\n serviceDeskFactory,\n serviceDesk,\n renderUserDefinedResponse,\n renderCustomMessageFooter,\n renderWriteableElements,\n element,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n assistantAvatarUrl,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n upload,\n ...domProps\n } = props;\n // Reconstruct PublicConfig from flattened props\n const config = useMemo(\n (): PublicConfig => ({\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n assistantAvatarUrl,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n upload,\n }),\n [\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n assistantAvatarUrl,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n upload,\n ],\n );\n\n const wrapperRef = useRef(null); // Ref for the React wrapper component\n const [wrapper, setWrapper] = useState(null);\n const [container, setContainer] = useState<HTMLElement | null>(null); // Actual element we render the React Portal to in the Shadowroot.\n\n const [writeableElementSlots, setWriteableElementSlots] = useState<\n HTMLElement[]\n >([]);\n const [currentInstance, setCurrentInstance] = useState<ChatInstance>(null);\n\n /**\n * Setup the DOM nodes of both the web component to be able to inject slotted content into it, and the element inside the\n * shadow DOM we will inject our React application into.\n */\n useEffect(() => {\n if (!wrapperRef.current) {\n return null; // Early return when there's nothing to set up because the element isn't ready.\n }\n\n let eventListenerAdded = false;\n\n const wrapperElement = wrapperRef.current as unknown as ChatContainerReact;\n\n // We need to check if the element in the shadow DOM we are render the React application to exists.\n // If it doesn't, we need to create and append it.\n\n const handleShadowReady = () => {\n // Now we know shadowRoot is definitely available\n let reactElement = wrapperElement.shadowRoot.querySelector(\n \".cds-aichat--react-app\",\n ) as HTMLElement;\n\n if (!reactElement) {\n reactElement = document.createElement(\"div\");\n reactElement.classList.add(\"cds-aichat--react-app\");\n wrapperElement.shadowRoot.appendChild(reactElement);\n }\n\n if (wrapperElement !== wrapper) {\n setWrapper(wrapperElement);\n }\n if (reactElement !== container) {\n setContainer(reactElement);\n }\n };\n\n if (wrapperElement.shadowRoot) {\n // Already ready\n handleShadowReady();\n } else {\n // Wait for ready event\n eventListenerAdded = true;\n wrapperElement.addEventListener(\"shadow-ready\", handleShadowReady, {\n once: true,\n });\n }\n\n return () => {\n if (eventListenerAdded) {\n wrapperElement.removeEventListener(\"shadow-ready\", handleShadowReady);\n }\n };\n }, [container, wrapper, currentInstance]);\n\n /**\n * Here we write the slotted elements into the wrapper so they are passed into the application to be rendered in their slot.\n */\n useEffect(() => {\n if (wrapper) {\n const combinedNodes: HTMLElement[] = [...writeableElementSlots];\n const currentNodes: HTMLElement[] = Array.from(\n wrapper.childNodes,\n ) as HTMLElement[];\n\n // Append new nodes that aren't already in the container\n combinedNodes.forEach((node) => {\n if (!currentNodes.includes(node)) {\n wrapper.appendChild(node);\n }\n });\n }\n }, [writeableElementSlots, wrapper]);\n\n const onBeforeRenderOverride = useCallback(\n (instance: ChatInstance) => {\n if (instance) {\n const addWriteableElementSlots = () => {\n const slots: HTMLElement[] = Object.entries(\n instance.writeableElements,\n ).map((writeableElement) => {\n const [key, element] = writeableElement;\n element.setAttribute(\"slot\", key); // Assign slot attributes dynamically\n return element;\n });\n setWriteableElementSlots(slots);\n };\n\n addWriteableElementSlots();\n onBeforeRender?.(instance);\n }\n },\n [onBeforeRender],\n );\n\n // If we are in SSR mode, just short circuit here. This prevents all of our window.* and document.* stuff from trying\n // to run and erroring out.\n if (!isBrowser()) {\n return null;\n }\n\n return (\n <>\n <ReactChatContainer ref={wrapperRef} {...domProps} />\n {container &&\n createPortal(\n <ChatAppEntry\n key=\"stable-chat-instance\"\n config={config}\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderCustomMessageFooter={renderCustomMessageFooter}\n renderWriteableElements={renderWriteableElements}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n container={container}\n setParentInstance={setCurrentInstance}\n element={element}\n chatWrapper={wrapper}\n />,\n container,\n )}\n </>\n );\n}\n\nexport { ChatContainer, ChatContainerProps };\n","/*\n * Copyright IBM Corp. 2025\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @license\n */\n\nimport React, { useCallback, useLayoutEffect, useRef, useState } from \"react\";\n\nimport { ChatInstance } from \"../types/instance/ChatInstance\";\nimport {\n BusEventType,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../types/events/eventBusTypes\";\nimport { ChatContainer, ChatContainerProps } from \"./ChatContainer\";\nimport { isBrowser } from \"../chat/utils/browserUtils\";\n\n/**\n * Properties for the ChatContainer React component. This interface extends\n * {@link ChatContainerProps} and {@link PublicConfig} with additional component-specific props, flattening all\n * config properties as top-level props for better TypeScript IntelliSense.\n *\n * @category React\n */\ninterface ChatCustomElementProps extends ChatContainerProps {\n /**\n * A CSS class name that will be added to the custom element. This class must define the size of the\n * your custom element (width and height or using logical inline-size/block-size).\n *\n * You can make use of onViewPreChange and/or onViewChange to mutate this className value so have open/close animations.\n *\n * By default, the chat will just set the chat shell to a 0x0 size and mark everything but the launcher (is you are using it)\n * as display: none; if the chat is set to closed.\n */\n className: string;\n\n /**\n * An optional id that will be added to the custom element.\n */\n id?: string;\n\n /**\n * Called before a view change (chat opening/closing). The chat will hide the chat shell inside your custom element\n * to prevent invisible keyboard stops when the view change is *complete*.\n *\n * Use this callback to update your className value *before* the view change happens if you want to add any open/close\n * animations to your custom element before the chat shell inner contents are hidden. It is async and so you can\n * tie it to native the AnimationEvent and only return when your animations have completed.\n *\n * A common pattern is to use this for when the chat is closing and to use onViewChange for when the chat opens.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewPreChange?: (\n event: BusEventViewPreChange,\n instance: ChatInstance,\n ) => Promise<void> | void;\n\n /**\n * Called when the chat view change is complete. If no callback is provided here, the default behavior will be to set\n * the chat shell to 0x0 size and set all inner contents aside from the launcher, if you are using it, to display: none.\n * The inner contents of the chat shell (aside from the launcher if you are using it) are always set to display: none\n * regardless of what is configured with this callback to prevent invisible tab stops and screen reader issues.\n *\n * Use this callback to update your className value when the chat has finished being opened or closed.\n *\n * You can provide a different callback here if you want custom animation behavior when the chat is opened or closed.\n * The animation behavior defined here will run in concert with the chat inside your custom container being hidden.\n *\n * If you want to run animations before the inner contents of the chat shell is shrunk and the inner contents are hidden,\n * make use of onViewPreChange.\n *\n * A common pattern is to use this for when the chat is opening and to use onViewPreChange for when the chat closes.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded as it is registered before the\n * chat renders. After Carbon AI Chat is loaded, the callback will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n}\n\nconst customElementStylesheet =\n isBrowser() && typeof CSSStyleSheet !== \"undefined\"\n ? new CSSStyleSheet()\n : null;\n\nconst hideStyles = `\n .cds-aichat--hidden {\n width: 0 !important;\n height: 0 !important;\n min-width: 0 !important;\n min-height: 0 !important;\n max-width: 0 !important;\n max-height: 0 !important;\n inline-size: 0 !important;\n block-size: 0 !important;\n min-inline-size: 0 !important;\n min-block-size: 0 !important;\n max-inline-size: 0 !important;\n max-block-size: 0 !important;\n overflow: hidden !important;\n }\n`;\n\n// Inject styles using adopted stylesheets when available, fallback to style element\nif (\n isBrowser() &&\n !document.getElementById(\"cds-aichat-custom-element-styles\")\n) {\n if (customElementStylesheet && \"replaceSync\" in customElementStylesheet) {\n customElementStylesheet.replaceSync(hideStyles);\n document.adoptedStyleSheets = [\n ...document.adoptedStyleSheets,\n customElementStylesheet,\n ];\n } else {\n // Fallback for when adoptedStyleSheets are not supported\n const style = document.createElement(\"style\");\n style.id = \"cds-aichat-custom-element-styles\";\n style.textContent = hideStyles;\n document.head.appendChild(style);\n }\n}\n\n/**\n * This is the React component for people injecting a Carbon AI Chat with a custom element.\n *\n * It provides said element any class or id defined on itself for styling. It then calls ChatContainer with the custom\n * element passed in as a property to be used instead of generating an element with the default properties for a\n * floating chat.\n *\n * @category React\n */\nfunction ChatCustomElement(props: ChatCustomElementProps) {\n const {\n strings,\n serviceDeskFactory,\n serviceDesk,\n onBeforeRender,\n onAfterRender,\n renderUserDefinedResponse,\n renderCustomMessageFooter,\n renderWriteableElements,\n className,\n id,\n onViewChange,\n onViewPreChange,\n // Flattened PublicConfig properties\n onError,\n openChatByDefault,\n disclaimer,\n disableCustomElementMobileEnhancements,\n debug,\n exposeServiceManagerForTesting,\n injectCarbonTheme,\n aiEnabled,\n shouldTakeFocusIfOpensAutomatically,\n namespace,\n shouldSanitizeHTML,\n header,\n history,\n layout,\n messaging,\n isReadonly,\n persistFeedback,\n assistantName,\n assistantAvatarUrl,\n locale,\n homescreen,\n launcher,\n input,\n keyboardShortcuts,\n upload,\n ...domProps\n } = props;\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [elementReady, setElementReady] = useState(false);\n\n useLayoutEffect(() => {\n setElementReady(true);\n }, []);\n\n const onBeforeRenderOverride = useCallback(\n async (instance: ChatInstance) => {\n /**\n * A default handler for the \"view:change\" event. This will be used to show or hide the Carbon AI Chat main window\n * by adding/removing a CSS class that sets the element size to 0x0 when hidden.\n */\n function defaultViewChangeHandler(event: BusEventViewChange) {\n const el = containerRef.current;\n if (el) {\n if (event.newViewState.mainWindow) {\n // Show: remove the hidden class, let the provided className handle sizing\n el.classList.remove(\"cds-aichat--hidden\");\n } else {\n // Hide: add the hidden class to set size to 0x0\n el.classList.add(\"cds-aichat--hidden\");\n }\n }\n }\n\n if (onViewPreChange) {\n instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: onViewPreChange,\n });\n }\n\n instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: onViewChange || defaultViewChangeHandler,\n });\n\n return onBeforeRender?.(instance);\n },\n [onViewPreChange, onViewChange, onBeforeRender],\n );\n\n return (\n <div className={className} id={id} ref={containerRef} {...domProps}>\n {elementReady && containerRef.current && (\n <ChatContainer\n // Flattened PublicConfig properties\n onError={onError}\n openChatByDefault={openChatByDefault}\n disclaimer={disclaimer}\n disableCustomElementMobileEnhancements={\n disableCustomElementMobileEnhancements\n }\n debug={debug}\n exposeServiceManagerForTesting={exposeServiceManagerForTesting}\n injectCarbonTheme={injectCarbonTheme}\n aiEnabled={aiEnabled}\n shouldTakeFocusIfOpensAutomatically={\n shouldTakeFocusIfOpensAutomatically\n }\n namespace={namespace}\n shouldSanitizeHTML={shouldSanitizeHTML}\n header={header}\n history={history}\n layout={layout}\n messaging={messaging}\n isReadonly={isReadonly}\n persistFeedback={persistFeedback}\n assistantName={assistantName}\n assistantAvatarUrl={assistantAvatarUrl}\n locale={locale}\n homescreen={homescreen}\n launcher={launcher}\n input={input}\n keyboardShortcuts={keyboardShortcuts}\n upload={upload}\n // Other ChatContainer props\n strings={strings}\n serviceDeskFactory={serviceDeskFactory}\n serviceDesk={serviceDesk}\n onBeforeRender={onBeforeRenderOverride}\n onAfterRender={onAfterRender}\n renderUserDefinedResponse={renderUserDefinedResponse}\n renderCustomMessageFooter={renderCustomMessageFooter}\n renderWriteableElements={renderWriteableElements}\n element={containerRef.current}\n />\n )}\n </div>\n );\n}\n\nexport { ChatCustomElement, ChatCustomElementProps };\n"],"names":["readCarbonChatSession","namespace","IS_SESSION_STORAGE","key","getSuffix","raw","window","sessionStorage","getItem","session","JSON","parse","version","VERSION","ChatContainerReact","LitElement","firstUpdated","changedProperties","super","this","dispatchEvent","CustomEvent","bubbles","styles","css","__decorate","carbonElement","ReactChatContainer","React","memo","createComponent","tagName","elementClass","react","ChatContainer","props","onBeforeRender","onAfterRender","strings","serviceDeskFactory","serviceDesk","renderUserDefinedResponse","renderCustomMessageFooter","renderWriteableElements","element","onError","openChatByDefault","disclaimer","disableCustomElementMobileEnhancements","debug","exposeServiceManagerForTesting","injectCarbonTheme","aiEnabled","shouldTakeFocusIfOpensAutomatically","shouldSanitizeHTML","header","history","layout","messaging","isReadonly","persistFeedback","assistantName","assistantAvatarUrl","locale","homescreen","launcher","input","keyboardShortcuts","upload","domProps","config","useMemo","wrapperRef","useRef","wrapper","setWrapper","useState","container","setContainer","writeableElementSlots","setWriteableElementSlots","currentInstance","setCurrentInstance","useEffect","current","eventListenerAdded","wrapperElement","handleShadowReady","reactElement","shadowRoot","querySelector","document","createElement","classList","add","appendChild","addEventListener","once","removeEventListener","combinedNodes","currentNodes","Array","from","childNodes","forEach","node","includes","onBeforeRenderOverride","useCallback","instance","addWriteableElementSlots","slots","Object","entries","writeableElements","map","writeableElement","setAttribute","isBrowser","Fragment","ref","createPortal","ChatAppEntry","setParentInstance","chatWrapper","customElementStylesheet","CSSStyleSheet","hideStyles","getElementById","replaceSync","adoptedStyleSheets","style","id","textContent","head","ChatCustomElement","className","onViewChange","onViewPreChange","containerRef","elementReady","setElementReady","useLayoutEffect","async","defaultViewChangeHandler","event","el","newViewState","mainWindow","remove","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAASA,sBAAsBC;EAC7B;IACE,KAAKC,sBAAsB;MACzB,OAAO;AACT;IACA,MAAMC,MAAM,sBAAsBC,UAAUH;IAC5C,MAAMI,MAAMC,OAAOC,eAAeC,QAAQL;IAC1C,KAAKE,KAAK;MACR,OAAO;AACT;IACA,MAAMI,UAAUC,KAAKC,MAAMN;IAC3B,IAAII,SAASG,YAAYC,SAAS;MAChC,OAAO;AACT;IACA,OAAOJ;AACT,IAAE;IACA,OAAO;AACT;AACF;;ACTA,IAAMK,qBAAN,MAAMA,2BAA2BC;EAY/B,YAAAC,CAAaC;IACXC,MAAMF,aAAaC;IACnBE,KAAKC,cAAc,IAAIC,YAAY,gBAAgB;MAAEC,SAAS;;AAChE;;;AAdOR,mBAAAS,SAASC,GAAG;;;;;;;AADfV,qBAAkBW,WAAA,EADvBC,cAAc,uBACTZ;;AAmBN,MAAMa,qBAAqBC,MAAMC,KAC/BC,gBAAgB;EACdC,SAAS;EACTC,cAAclB;EACdmB,OAAOL;;;AAUX,SAASM,cAAcC;EACrB,OAAMC,gBACUC,eACDC,SACNC,oBACWC,aACP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