@carbon/ai-chat 1.15.0 → 1.16.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.
@@ -90,6 +90,8 @@ import "lodash-es/throttle.js";
90
90
 
91
91
  import "@carbon/icons/es/down-to-bottom/16.js";
92
92
 
93
+ import "@carbon/ai-chat-components/es/globals/settings.js";
94
+
93
95
  import "@carbon/icons/es/screen--off/16.js";
94
96
 
95
97
  import "@carbon/icons/es/user--avatar/32.js";
@@ -126,8 +128,6 @@ import "@carbon/ai-chat-components/es/react/feedback-buttons.js";
126
128
 
127
129
  import "@carbon/ai-chat-components/es/react/feedback.js";
128
130
 
129
- import "@carbon/ai-chat-components/es/globals/settings.js";
130
-
131
131
  import "@carbon/icons/es/checkmark/16.js";
132
132
 
133
133
  import "@carbon/icons/es/headset/16.js";
@@ -214,12 +214,12 @@ import "@carbon/icons/es/stop--filled/16.js";
214
214
 
215
215
  import "@carbon/ai-chat-components/es/react/panel.js";
216
216
 
217
- import "@carbon/icons/es/chevron--down/20.js";
218
-
219
- import "@carbon/icons/es/close--large/20.js";
217
+ import "@carbon/icons/es/chevron--left/16.js";
220
218
 
221
219
  import "@carbon/ai-chat-components/es/react/toolbar.js";
222
220
 
221
+ import "@carbon/web-components/es/components/icon-button/icon-button.js";
222
+
223
223
  import "@carbon/web-components/es/components/chat-button/chat-button.js";
224
224
 
225
225
  import "@carbon/ai-chat-components/es/components/chain-of-thought/defs.js";
@@ -92,6 +92,8 @@ import "lodash-es/throttle.js";
92
92
 
93
93
  import "@carbon/icons/es/down-to-bottom/16.js";
94
94
 
95
+ import "@carbon/ai-chat-components/es/globals/settings.js";
96
+
95
97
  import "@carbon/icons/es/screen--off/16.js";
96
98
 
97
99
  import "@carbon/icons/es/user--avatar/32.js";
@@ -128,8 +130,6 @@ import "@carbon/ai-chat-components/es/react/feedback-buttons.js";
128
130
 
129
131
  import "@carbon/ai-chat-components/es/react/feedback.js";
130
132
 
131
- import "@carbon/ai-chat-components/es/globals/settings.js";
132
-
133
133
  import "@carbon/icons/es/checkmark/16.js";
134
134
 
135
135
  import "@carbon/icons/es/headset/16.js";
@@ -216,12 +216,12 @@ import "@carbon/icons/es/stop--filled/16.js";
216
216
 
217
217
  import "@carbon/ai-chat-components/es/react/panel.js";
218
218
 
219
- import "@carbon/icons/es/chevron--down/20.js";
220
-
221
- import "@carbon/icons/es/close--large/20.js";
219
+ import "@carbon/icons/es/chevron--left/16.js";
222
220
 
223
221
  import "@carbon/ai-chat-components/es/react/toolbar.js";
224
222
 
223
+ import "@carbon/web-components/es/components/icon-button/icon-button.js";
224
+
225
225
  import "@carbon/web-components/es/components/chat-button/chat-button.js";
226
226
 
227
227
  import "@carbon/ai-chat-components/es/components/chain-of-thought/defs.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../../src/web-components/cds-aichat-custom-element/index.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 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\n// Ensure the container custom element is registered whenever the\n// custom element module is imported by re-exporting its exports.\n// This prevents bundlers (and our own multi-entry Rollup build)\n// from pruning the side-effect-only import.\nexport { default as __cds_aichat_container_register } from \"../cds-aichat-container\";\nimport \"../cds-aichat-container\";\n\nimport { html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\nimport { FlattenedConfigElement } from \"../shared/FlattenedConfigElement\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventCustomFooterSlot,\n BusEventType,\n BusEventUserDefinedResponse,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../../types/events/eventBusTypes\";\nimport type {\n WCMarkdown,\n WCRenderCustomMessageFooter,\n WCRenderUserDefinedResponse,\n} from \"../../types/component/ChatContainer\";\n\n/**\n * cds-aichat-custom-element will is a pass through to cds-aichat-container. It takes any user_defined and writeable element\n * slotted content and forwards it to cds-aichat-container. It also will setup the custom element with a default viewChange\n * pattern (e.g. hiding and showing the custom element when the chat should be open/closed) if a onViewChange property is not\n * defined. Finally, it registers the custom element with cds-aichat-container so a default \"floating\" element will not be created.\n *\n * The custom element should be sized using external CSS. When hidden, the 'cds-aichat--hidden' class is added to set dimensions to 0x0.\n */\n@carbonElement(\"cds-aichat-custom-element\")\nclass ChatCustomElement extends FlattenedConfigElement {\n /**\n * Shared stylesheet for hiding styles.\n */\n private static hideSheet = new CSSStyleSheet();\n static {\n // Hide styles that override any external sizing. `replaceSync` is absent\n // in non-browser environments (e.g. the jsdom-based test environment), so\n // skip styling there rather than throwing at module-evaluation time.\n ChatCustomElement.hideSheet.replaceSync?.(`\n :host {\n display: block;\n }\n :host(.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 display: block !important;\n }\n `);\n }\n\n /**\n * Adopt our stylesheet into every shadowRoot.\n */\n protected createRenderRoot(): ShadowRoot {\n // Lits default createRenderRoot actually returns a ShadowRoot\n const root = super.createRenderRoot() as ShadowRoot;\n\n // now TS knows root.adoptedStyleSheets exists\n root.adoptedStyleSheets = [\n ...root.adoptedStyleSheets,\n ChatCustomElement.hideSheet,\n ];\n return root;\n }\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n @property({ attribute: false })\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n @property({ attribute: false })\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\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 CSS class name values on this element 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 @property()\n onViewPreChange?: (event: BusEventViewPreChange) => 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 @property()\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n /**\n * Optional callback to render user defined responses. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, and element lifecycle.\n */\n @property({ attribute: false })\n renderUserDefinedResponse?: WCRenderUserDefinedResponse;\n\n /**\n * Optional callback to render custom message footers. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, and element lifecycle.\n */\n @property({ attribute: false })\n renderCustomMessageFooter?: WCRenderCustomMessageFooter;\n\n // markdown is declared on the FlattenedConfigElement base; the attributes\n // interface narrows its type.\n\n @state()\n private _userDefinedSlotNames: string[] = [];\n\n @state()\n private _writeableElementSlots: string[] = [];\n\n @state()\n private _customFooterSlotNames: string[] = [];\n\n /**\n * Active slot names for markdown-plugin output hosted at this element.\n * Populated when this element accepts the host-mount event; drained when\n * the matching unmount event fires.\n */\n @state()\n private _pluginSlotNames: string[] = [];\n\n /**\n * Page-level host elements created for plugin-output slots, keyed by slot\n * name. Created in this element's outer light DOM so consumer-loaded\n * stylesheets (e.g. KaTeX) reach the rendered HTML normally.\n */\n private _pluginHosts: Map<string, HTMLElement> = new Map();\n\n @state()\n private _instance!: ChatInstance;\n\n private defaultViewChangeHandler = (event: BusEventViewChange) => {\n if (event.newViewState.mainWindow) {\n this.classList.remove(\"cds-aichat--hidden\");\n } else {\n this.classList.add(\"cds-aichat--hidden\");\n }\n };\n\n private userDefinedHandler = (\n event: BusEventUserDefinedResponse | BusEventChunkUserDefinedResponse,\n ) => {\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n };\n\n private customFooterHandler = (event: BusEventCustomFooterSlot) => {\n const { slotName } = event.data;\n if (!this._customFooterSlotNames.includes(slotName)) {\n this._customFooterSlotNames = [...this._customFooterSlotNames, slotName];\n }\n };\n\n private handlePluginHostMount = (event: Event) => {\n const detail = (\n event as CustomEvent<{\n slotName: string;\n html: string;\n isInline: boolean;\n }>\n ).detail;\n if (!detail?.slotName) {\n return;\n }\n if (!this._pluginSlotNames.includes(detail.slotName)) {\n this._pluginSlotNames = [...this._pluginSlotNames, detail.slotName];\n }\n // cds-aichat-custom-element is always the outermost chat element in its\n // shadow chain; there is no further chat ancestor to defer to. Take\n // hosting unconditionally.\n event.preventDefault();\n let host = this._pluginHosts.get(detail.slotName);\n if (!host) {\n host = document.createElement(detail.isInline ? \"span\" : \"div\");\n host.setAttribute(\"slot\", detail.slotName);\n // Match `.cds-aichat-markdown-stack > *:not(:first-child)` spacing;\n // shadow CSS doesn't reach this host (it lives in this element's\n // outer light DOM), so apply it inline. Inline output flows with\n // text and gets no extra spacing.\n if (!detail.isInline) {\n host.style.marginBlockStart = \"1rem\";\n }\n this._pluginHosts.set(detail.slotName, host);\n this.appendChild(host);\n }\n if (host.innerHTML !== detail.html) {\n host.innerHTML = detail.html;\n }\n };\n\n private handlePluginHostUpdate = (event: Event) => {\n const detail = (event as CustomEvent<{ slotName: string; html: string }>)\n .detail;\n if (!detail?.slotName) {\n return;\n }\n const host = this._pluginHosts.get(detail.slotName);\n if (host && host.innerHTML !== detail.html) {\n host.innerHTML = detail.html;\n }\n };\n\n private handlePluginHostUnmount = (event: Event) => {\n const detail = (event as CustomEvent<{ slotName: string }>).detail;\n if (!detail?.slotName) {\n return;\n }\n this._pluginSlotNames = this._pluginSlotNames.filter(\n (n) => n !== detail.slotName,\n );\n const host = this._pluginHosts.get(detail.slotName);\n if (host) {\n host.remove();\n this._pluginHosts.delete(detail.slotName);\n }\n };\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\n \"cds-aichat-markdown-plugin-host-mount\",\n this.handlePluginHostMount,\n );\n this.addEventListener(\n \"cds-aichat-markdown-plugin-host-update\",\n this.handlePluginHostUpdate,\n );\n this.addEventListener(\n \"cds-aichat-markdown-plugin-host-unmount\",\n this.handlePluginHostUnmount,\n );\n }\n\n disconnectedCallback() {\n this.removeEventListener(\n \"cds-aichat-markdown-plugin-host-mount\",\n this.handlePluginHostMount,\n );\n this.removeEventListener(\n \"cds-aichat-markdown-plugin-host-update\",\n this.handlePluginHostUpdate,\n );\n this.removeEventListener(\n \"cds-aichat-markdown-plugin-host-unmount\",\n this.handlePluginHostUnmount,\n );\n for (const host of this._pluginHosts.values()) {\n host.remove();\n }\n this._pluginHosts.clear();\n super.disconnectedCallback();\n }\n\n private onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n if (this.onViewPreChange) {\n this._instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: this.onViewPreChange,\n });\n }\n this._instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: this.onViewChange || this.defaultViewChangeHandler,\n });\n\n if (!this.renderUserDefinedResponse) {\n // Legacy path: custom-element tracks slot names for manual slotting.\n // When renderUserDefinedResponse is set, the inner cds-aichat-container handles everything.\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n }\n\n if (!this.renderCustomMessageFooter) {\n // Legacy path: custom-element tracks slot names for manual slotting.\n // When renderCustomMessageFooter is set, the inner cds-aichat-container handles everything.\n this._instance.on({\n type: BusEventType.CUSTOM_FOOTER_SLOT,\n handler: this.customFooterHandler,\n });\n }\n this.addWriteableElementSlots();\n await this.onBeforeRender?.(instance);\n };\n\n private addWriteableElementSlots() {\n this._writeableElementSlots = Object.keys(this._instance.writeableElements);\n }\n\n render() {\n return html`\n <cds-aichat-container\n .config=${this.resolvedConfig}\n .header=${this.resolvedConfig.header}\n .onAfterRender=${this.onAfterRender}\n .onBeforeRender=${this.onBeforeRenderOverride}\n .element=${this}\n .renderUserDefinedResponse=${this.renderUserDefinedResponse}\n .renderCustomMessageFooter=${this.renderCustomMessageFooter}\n .markdown=${this.markdown as WCMarkdown | undefined}\n >\n ${this._writeableElementSlots.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n ${this.renderUserDefinedResponse\n ? null\n : this._userDefinedSlotNames.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n ${this.renderCustomMessageFooter\n ? null\n : this._customFooterSlotNames.map(\n (slot) =>\n html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n ${this._pluginSlotNames.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n </cds-aichat-container>\n `;\n }\n}\n\n/**\n * Attributes interface for the cds-aichat-custom-element web component.\n * This interface extends {@link PublicConfig} with additional component-specific props,\n * flattening all config properties as top-level properties for better TypeScript IntelliSense.\n *\n * @category Web component\n */\ninterface CdsAiChatCustomElementAttributes extends Omit<\n PublicConfig,\n \"markdown\"\n> {\n /**\n * Markdown rendering customization. Extends the framework-neutral\n * `PublicConfig.markdown` with web-component `customRenderers`.\n *\n * @experimental\n */\n markdown?: WCMarkdown;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * An optional listener for \"view:change\" events. Such a listener is required when using a custom element in order\n * to control the visibility of the Carbon AI Chat main window. If no callback is provided here, a default one will be\n * used that injects styling into the app that will show and hide the Carbon AI Chat main window and also change the\n * size of the custom element so it doesn't take up space when the main window is closed.\n *\n * You can provide a different callback here if you want custom behavior such as an animation when the main window\n * is opened or closed.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded. After Carbon AI Chat is loaded, the event\n * handler will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n /**\n * Optional callback to render user defined responses. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, streaming state, and element lifecycle.\n */\n renderUserDefinedResponse?: WCRenderUserDefinedResponse;\n\n /**\n * Optional callback to render custom message footers. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, and element lifecycle.\n */\n renderCustomMessageFooter?: WCRenderCustomMessageFooter;\n}\n\nexport { CdsAiChatCustomElementAttributes };\n\nexport default ChatCustomElement;\n"],"names":["ChatCustomElement","ChatCustomElement_1","FlattenedConfigElement","constructor","this","_userDefinedSlotNames","_writeableElementSlots","_customFooterSlotNames","_pluginSlotNames","_pluginHosts","Map","defaultViewChangeHandler","event","newViewState","mainWindow","classList","remove","add","userDefinedHandler","slot","data","includes","customFooterHandler","slotName","handlePluginHostMount","detail","preventDefault","host","get","document","createElement","isInline","setAttribute","style","marginBlockStart","set","appendChild","innerHTML","html","handlePluginHostUpdate","handlePluginHostUnmount","filter","n","delete","onBeforeRenderOverride","async","instance","_instance","onViewPreChange","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE","onViewChange","renderUserDefinedResponse","USER_DEFINED_RESPONSE","CHUNK_USER_DEFINED_RESPONSE","renderCustomMessageFooter","CUSTOM_FOOTER_SLOT","addWriteableElementSlots","onBeforeRender","createRenderRoot","root","super","adoptedStyleSheets","hideSheet","connectedCallback","addEventListener","disconnectedCallback","removeEventListener","values","clear","Object","keys","writeableElements","render","resolvedConfig","header","onAfterRender","markdown","map","CSSStyleSheet","replaceSync","__decorate","property","attribute","prototype","state","carbonElement","ChatCustomElement_default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAMA,oBAAiBC,sBAAvB,MAAMD,0BAA0BE;EAAhC,WAAAC;;IAoHUC,KAAAC,wBAAkC;IAGlCD,KAAAE,yBAAmC;IAGnCF,KAAAG,yBAAmC;IAQnCH,KAAAI,mBAA6B;IAO7BJ,KAAAK,eAAyC,IAAIC;IAK7CN,KAAAO,2BAA4BC;MAClC,IAAIA,MAAMC,aAAaC,YAAY;QACjCV,KAAKW,UAAUC,OAAO;AACxB,aAAO;QACLZ,KAAKW,UAAUE,IAAI;AACrB;;IAGMb,KAAAc,qBACNN;MAEA,OAAMO,QAAWP,MAAMQ;MACvB,KAAKhB,KAAKC,sBAAsBgB,SAASF,OAAO;QAC9Cf,K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A;;AA5I7BxF,oBAAiBC,sBAAAoF,WAAA,EADtBK,cAAc,gCACT1F;;AAiZN,IAAA2F,4BAAe3F;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/web-components/cds-aichat-custom-element/index.ts"],"sourcesContent":["/*\n * Copyright IBM Corp. 2025, 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\n// Ensure the container custom element is registered whenever the\n// custom element module is imported by re-exporting its exports.\n// This prevents bundlers (and our own multi-entry Rollup build)\n// from pruning the side-effect-only import.\nexport { default as __cds_aichat_container_register } from \"../cds-aichat-container\";\nimport \"../cds-aichat-container\";\n\nimport { html } from \"lit\";\nimport { property, state } from \"lit/decorators.js\";\n\nimport { carbonElement } from \"@carbon/ai-chat-components/es/globals/decorators/index.js\";\nimport { PublicConfig } from \"../../types/config/PublicConfig\";\nimport { FlattenedConfigElement } from \"../shared/FlattenedConfigElement\";\nimport { ChatInstance } from \"../../types/instance/ChatInstance\";\nimport {\n BusEventChunkUserDefinedResponse,\n BusEventCustomFooterSlot,\n BusEventType,\n BusEventUserDefinedResponse,\n BusEventViewChange,\n BusEventViewPreChange,\n} from \"../../types/events/eventBusTypes\";\nimport type {\n WCMarkdown,\n WCRenderCustomMessageFooter,\n WCRenderUserDefinedResponse,\n} from \"../../types/component/ChatContainer\";\n\n/**\n * cds-aichat-custom-element will is a pass through to cds-aichat-container. It takes any user_defined and writeable element\n * slotted content and forwards it to cds-aichat-container. It also will setup the custom element with a default viewChange\n * pattern (e.g. hiding and showing the custom element when the chat should be open/closed) if a onViewChange property is not\n * defined. Finally, it registers the custom element with cds-aichat-container so a default \"floating\" element will not be created.\n *\n * The custom element should be sized using external CSS. When hidden, the 'cds-aichat--hidden' class is added to set dimensions to 0x0.\n */\n@carbonElement(\"cds-aichat-custom-element\")\nclass ChatCustomElement extends FlattenedConfigElement {\n /**\n * Shared stylesheet for hiding styles.\n */\n private static hideSheet = new CSSStyleSheet();\n static {\n // Hide styles that override any external sizing. `replaceSync` is absent\n // in non-browser environments (e.g. the jsdom-based test environment), so\n // skip styling there rather than throwing at module-evaluation time.\n ChatCustomElement.hideSheet.replaceSync?.(`\n :host {\n display: block;\n }\n :host(.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 display: block !important;\n }\n `);\n }\n\n /**\n * Adopt our stylesheet into every shadowRoot.\n */\n protected createRenderRoot(): ShadowRoot {\n // Lits default createRenderRoot actually returns a ShadowRoot\n const root = super.createRenderRoot() as ShadowRoot;\n\n // now TS knows root.adoptedStyleSheets exists\n root.adoptedStyleSheets = [\n ...root.adoptedStyleSheets,\n ChatCustomElement.hideSheet,\n ];\n return root;\n }\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n *\n * Use it to capture the {@link ChatInstance} so you can call instance methods later.\n *\n * @example\n * ```ts\n * const onBeforeRender = (instance: ChatInstance) => {\n * this.instance = instance;\n * };\n * // <cds-aichat-custom-element .onBeforeRender=${onBeforeRender}></cds-aichat-custom-element>\n * ```\n */\n @property({ attribute: false })\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n *\n * Like `onBeforeRender`, it receives the {@link ChatInstance}; use it when you need the instance only after the\n * first render has completed.\n */\n @property({ attribute: false })\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\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 CSS class name values on this element 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 @property()\n onViewPreChange?: (event: BusEventViewPreChange) => 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 @property()\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n /**\n * Optional callback to render user defined responses. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, and element lifecycle.\n */\n @property({ attribute: false })\n renderUserDefinedResponse?: WCRenderUserDefinedResponse;\n\n /**\n * Optional callback to render custom message footers. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, and element lifecycle.\n */\n @property({ attribute: false })\n renderCustomMessageFooter?: WCRenderCustomMessageFooter;\n\n // markdown is declared on the FlattenedConfigElement base; the attributes\n // interface narrows its type.\n\n @state()\n private _userDefinedSlotNames: string[] = [];\n\n @state()\n private _writeableElementSlots: string[] = [];\n\n @state()\n private _customFooterSlotNames: string[] = [];\n\n /**\n * Active slot names for markdown-plugin output hosted at this element.\n * Populated when this element accepts the host-mount event; drained when\n * the matching unmount event fires.\n */\n @state()\n private _pluginSlotNames: string[] = [];\n\n /**\n * Page-level host elements created for plugin-output slots, keyed by slot\n * name. Created in this element's outer light DOM so consumer-loaded\n * stylesheets (e.g. KaTeX) reach the rendered HTML normally.\n */\n private _pluginHosts: Map<string, HTMLElement> = new Map();\n\n @state()\n private _instance!: ChatInstance;\n\n private defaultViewChangeHandler = (event: BusEventViewChange) => {\n if (event.newViewState.mainWindow) {\n this.classList.remove(\"cds-aichat--hidden\");\n } else {\n this.classList.add(\"cds-aichat--hidden\");\n }\n };\n\n private userDefinedHandler = (\n event: BusEventUserDefinedResponse | BusEventChunkUserDefinedResponse,\n ) => {\n const { slot } = event.data;\n if (!this._userDefinedSlotNames.includes(slot)) {\n this._userDefinedSlotNames = [...this._userDefinedSlotNames, slot];\n }\n };\n\n private customFooterHandler = (event: BusEventCustomFooterSlot) => {\n const { slotName } = event.data;\n if (!this._customFooterSlotNames.includes(slotName)) {\n this._customFooterSlotNames = [...this._customFooterSlotNames, slotName];\n }\n };\n\n private handlePluginHostMount = (event: Event) => {\n const detail = (\n event as CustomEvent<{\n slotName: string;\n html: string;\n isInline: boolean;\n }>\n ).detail;\n if (!detail?.slotName) {\n return;\n }\n if (!this._pluginSlotNames.includes(detail.slotName)) {\n this._pluginSlotNames = [...this._pluginSlotNames, detail.slotName];\n }\n // cds-aichat-custom-element is always the outermost chat element in its\n // shadow chain; there is no further chat ancestor to defer to. Take\n // hosting unconditionally.\n event.preventDefault();\n let host = this._pluginHosts.get(detail.slotName);\n if (!host) {\n host = document.createElement(detail.isInline ? \"span\" : \"div\");\n host.setAttribute(\"slot\", detail.slotName);\n // Match `.cds-aichat-markdown-stack > *:not(:first-child)` spacing;\n // shadow CSS doesn't reach this host (it lives in this element's\n // outer light DOM), so apply it inline. Inline output flows with\n // text and gets no extra spacing.\n if (!detail.isInline) {\n host.style.marginBlockStart = \"1rem\";\n }\n this._pluginHosts.set(detail.slotName, host);\n this.appendChild(host);\n }\n if (host.innerHTML !== detail.html) {\n host.innerHTML = detail.html;\n }\n };\n\n private handlePluginHostUpdate = (event: Event) => {\n const detail = (event as CustomEvent<{ slotName: string; html: string }>)\n .detail;\n if (!detail?.slotName) {\n return;\n }\n const host = this._pluginHosts.get(detail.slotName);\n if (host && host.innerHTML !== detail.html) {\n host.innerHTML = detail.html;\n }\n };\n\n private handlePluginHostUnmount = (event: Event) => {\n const detail = (event as CustomEvent<{ slotName: string }>).detail;\n if (!detail?.slotName) {\n return;\n }\n this._pluginSlotNames = this._pluginSlotNames.filter(\n (n) => n !== detail.slotName,\n );\n const host = this._pluginHosts.get(detail.slotName);\n if (host) {\n host.remove();\n this._pluginHosts.delete(detail.slotName);\n }\n };\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener(\n \"cds-aichat-markdown-plugin-host-mount\",\n this.handlePluginHostMount,\n );\n this.addEventListener(\n \"cds-aichat-markdown-plugin-host-update\",\n this.handlePluginHostUpdate,\n );\n this.addEventListener(\n \"cds-aichat-markdown-plugin-host-unmount\",\n this.handlePluginHostUnmount,\n );\n }\n\n disconnectedCallback() {\n this.removeEventListener(\n \"cds-aichat-markdown-plugin-host-mount\",\n this.handlePluginHostMount,\n );\n this.removeEventListener(\n \"cds-aichat-markdown-plugin-host-update\",\n this.handlePluginHostUpdate,\n );\n this.removeEventListener(\n \"cds-aichat-markdown-plugin-host-unmount\",\n this.handlePluginHostUnmount,\n );\n for (const host of this._pluginHosts.values()) {\n host.remove();\n }\n this._pluginHosts.clear();\n super.disconnectedCallback();\n }\n\n private onBeforeRenderOverride = async (instance: ChatInstance) => {\n this._instance = instance;\n if (this.onViewPreChange) {\n this._instance.on({\n type: BusEventType.VIEW_PRE_CHANGE,\n handler: this.onViewPreChange,\n });\n }\n this._instance.on({\n type: BusEventType.VIEW_CHANGE,\n handler: this.onViewChange || this.defaultViewChangeHandler,\n });\n\n if (!this.renderUserDefinedResponse) {\n // Legacy path: custom-element tracks slot names for manual slotting.\n // When renderUserDefinedResponse is set, the inner cds-aichat-container handles everything.\n this._instance.on({\n type: BusEventType.USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n this._instance.on({\n type: BusEventType.CHUNK_USER_DEFINED_RESPONSE,\n handler: this.userDefinedHandler,\n });\n }\n\n if (!this.renderCustomMessageFooter) {\n // Legacy path: custom-element tracks slot names for manual slotting.\n // When renderCustomMessageFooter is set, the inner cds-aichat-container handles everything.\n this._instance.on({\n type: BusEventType.CUSTOM_FOOTER_SLOT,\n handler: this.customFooterHandler,\n });\n }\n this.addWriteableElementSlots();\n await this.onBeforeRender?.(instance);\n };\n\n private addWriteableElementSlots() {\n this._writeableElementSlots = Object.keys(this._instance.writeableElements);\n }\n\n render() {\n return html`\n <cds-aichat-container\n .config=${this.resolvedConfig}\n .header=${this.resolvedConfig.header}\n .onAfterRender=${this.onAfterRender}\n .onBeforeRender=${this.onBeforeRenderOverride}\n .element=${this}\n .renderUserDefinedResponse=${this.renderUserDefinedResponse}\n .renderCustomMessageFooter=${this.renderCustomMessageFooter}\n .markdown=${this.markdown as WCMarkdown | undefined}\n >\n ${this._writeableElementSlots.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n ${this.renderUserDefinedResponse\n ? null\n : this._userDefinedSlotNames.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n ${this.renderCustomMessageFooter\n ? null\n : this._customFooterSlotNames.map(\n (slot) =>\n html`<div slot=${slot}><slot name=${slot}></slot></div>`,\n )}\n ${this._pluginSlotNames.map(\n (slot) => html`<slot name=${slot} slot=${slot}></slot>`,\n )}\n </cds-aichat-container>\n `;\n }\n}\n\n/**\n * Attributes interface for the cds-aichat-custom-element web component.\n * This interface extends {@link PublicConfig} with additional component-specific props,\n * flattening all config properties as top-level properties for better TypeScript IntelliSense.\n *\n * @category Web component\n */\ninterface CdsAiChatCustomElementAttributes extends Omit<\n PublicConfig,\n \"markdown\"\n> {\n /**\n * Markdown rendering customization. Extends the framework-neutral\n * `PublicConfig.markdown` with web-component `customRenderers`.\n *\n * @experimental\n */\n markdown?: WCMarkdown;\n\n /**\n * This function is called before the render function of Carbon AI Chat is called. This function can return a Promise\n * which will cause Carbon AI Chat to wait for it before rendering.\n */\n onBeforeRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * This function is called after the render function of Carbon AI Chat is called.\n */\n onAfterRender?: (instance: ChatInstance) => Promise<void> | void;\n\n /**\n * Called before a view change (the chat opening or closing) and awaited before the change proceeds. Use it to update\n * this element's CSS classes and run open/close animations to completion before the chat shell's inner contents are\n * hidden. A common pattern is to use this when the chat is closing and `onViewChange` when it opens.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded. After Carbon AI Chat is loaded, the\n * callback will not be updated.\n */\n onViewPreChange?: (event: BusEventViewPreChange) => Promise<void> | void;\n\n /**\n * An optional listener for \"view:change\" events. Such a listener is required when using a custom element in order\n * to control the visibility of the Carbon AI Chat main window. If no callback is provided here, a default one will be\n * used that injects styling into the app that will show and hide the Carbon AI Chat main window and also change the\n * size of the custom element so it doesn't take up space when the main window is closed.\n *\n * You can provide a different callback here if you want custom behavior such as an animation when the main window\n * is opened or closed.\n *\n * Note that this function can only be provided before Carbon AI Chat is loaded. After Carbon AI Chat is loaded, the event\n * handler will not be updated.\n */\n onViewChange?: (event: BusEventViewChange, instance: ChatInstance) => void;\n\n /**\n * Optional callback to render user defined responses. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, streaming state, and element lifecycle.\n */\n renderUserDefinedResponse?: WCRenderUserDefinedResponse;\n\n /**\n * Optional callback to render custom message footers. When provided, the inner cds-aichat-container\n * manages all event listening, slot tracking, and element lifecycle.\n */\n renderCustomMessageFooter?: WCRenderCustomMessageFooter;\n}\n\nexport { CdsAiChatCustomElementAttributes };\n\nexport default ChatCustomElement;\n"],"names":["ChatCustomElement","ChatCustomElement_1","FlattenedConfigElement","constructor","this","_userDefinedSlotNames","_writeableElementSlots","_customFooterSlotNames","_pluginSlotNames","_pluginHosts","Map","defaultViewChangeHandler","event","newViewState","mainWindow","classList","remove","add","userDefinedHandler","slot","data","includes","customFooterHandler","slotName","handlePluginHostMount","detail","preventDefault","host","get","document","createElement","isInline","setAttribute","style","marginBlockStart","set","appendChild","innerHTML","html","handlePluginHostUpdate","handlePluginHostUnmount","filter","n","delete","onBeforeRenderOverride","async","instance","_instance","onViewPreChange","on","type","BusEventType","VIEW_PRE_CHANGE","handler","VIEW_CHANGE","onViewChange","renderUserDefinedResponse","USER_DEFINED_RESPONSE","CHUNK_USER_DEFINED_RESPONSE","renderCustomMessageFooter","CUSTOM_FOOTER_SLOT","addWriteableElementSlots","onBeforeRender","createRenderRoot","root","super","adoptedStyleSheets","hideSheet","connectedCallback","addEventListener","disconnectedCallback","removeEventListener","values","clear","Object","keys","writeableElements","render","resolvedConfig","header","onAfterRender","markdown","map","CSSStyleSheet","replaceSync","__decorate","property","attribute","prototype","state","carbonElement","ChatCustomElement_default"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAMA,oBAAiBC,sBAAvB,MAAMD,0BAA0BE;EAAhC,WAAAC;;IAiIUC,KAAAC,wBAAkC;IAGlCD,KAAAE,yBAAmC;IAGnCF,KAAAG,yBAAmC;IAQnCH,KAAAI,mBAA6B;IAO7BJ,KAAAK,eAAyC,IAAIC;IAK7CN,KAAAO,2BAA4BC;MAClC,IAAIA,MAAMC,aAAaC,YAAY;QACjCV,KAAKW,UAAUC,OAAO;AACxB,aAAO;QACLZ,KAAKW,UAAUE,IAAI;AACrB;;IAGMb,KAAAc,qBACNN;MAEA,OAAMO,QA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WACuCzF,kBAAAwF,WAAA;;AAUhCH,WAAA,EADPI,WACgCzF,kBAAAwF,WAAA;;AAzJ7BxF,oBAAiBC,sBAAAoF,WAAA,EADtBK,cAAc,gCACT1F;;AAwaN,IAAA2F,4BAAe3F;;"}
@@ -92,6 +92,8 @@ import "lodash-es/throttle.js";
92
92
 
93
93
  import "@carbon/icons/es/down-to-bottom/16.js";
94
94
 
95
+ import "@carbon/ai-chat-components/es-custom/globals/settings.js";
96
+
95
97
  import "@carbon/icons/es/screen--off/16.js";
96
98
 
97
99
  import "@carbon/icons/es/user--avatar/32.js";
@@ -128,8 +130,6 @@ import "@carbon/ai-chat-components/es-custom/react/feedback-buttons.js";
128
130
 
129
131
  import "@carbon/ai-chat-components/es-custom/react/feedback.js";
130
132
 
131
- import "@carbon/ai-chat-components/es-custom/globals/settings.js";
132
-
133
133
  import "@carbon/icons/es/checkmark/16.js";
134
134
 
135
135
  import "@carbon/icons/es/headset/16.js";
@@ -218,12 +218,12 @@ import "lit/decorators.js";
218
218
 
219
219
  import "@carbon/ai-chat-components/es-custom/react/panel.js";
220
220
 
221
- import "@carbon/icons/es/chevron--down/20.js";
222
-
223
- import "@carbon/icons/es/close--large/20.js";
221
+ import "@carbon/icons/es/chevron--left/16.js";
224
222
 
225
223
  import "@carbon/ai-chat-components/es-custom/react/toolbar.js";
226
224
 
225
+ import "@carbon/web-components/es-custom/components/icon-button/icon-button.js";
226
+
227
227
  import "@carbon/web-components/es-custom/components/chat-button/chat-button.js";
228
228
 
229
229
  function readCarbonChatSession(namespace) {
@@ -76,6 +76,8 @@ import throttle from "lodash-es/throttle.js";
76
76
 
77
77
  import DownToBottom16 from "@carbon/icons/es/down-to-bottom/16.js";
78
78
 
79
+ import prefix from "@carbon/ai-chat-components/es-custom/globals/settings.js";
80
+
79
81
  import ScreenOff16 from "@carbon/icons/es/screen--off/16.js";
80
82
 
81
83
  import UserAvatar32 from "@carbon/icons/es/user--avatar/32.js";
@@ -112,8 +114,6 @@ import FeedbackButtons from "@carbon/ai-chat-components/es-custom/react/feedback
112
114
 
113
115
  import Feedback from "@carbon/ai-chat-components/es-custom/react/feedback.js";
114
116
 
115
- import prefix from "@carbon/ai-chat-components/es-custom/globals/settings.js";
116
-
117
117
  import Checkmark16 from "@carbon/icons/es/checkmark/16.js";
118
118
 
119
119
  import Headset16 from "@carbon/icons/es/headset/16.js";
@@ -208,12 +208,12 @@ import { property } from "lit/decorators.js";
208
208
 
209
209
  import ChatPanel from "@carbon/ai-chat-components/es-custom/react/panel.js";
210
210
 
211
- import ChevronDown20 from "@carbon/icons/es/chevron--down/20.js";
212
-
213
- import CloseLarge20 from "@carbon/icons/es/close--large/20.js";
211
+ import ChevronLeft16 from "@carbon/icons/es/chevron--left/16.js";
214
212
 
215
213
  import Toolbar from "@carbon/ai-chat-components/es-custom/react/toolbar.js";
216
214
 
215
+ import CarbonIconButtonElement from "@carbon/web-components/es-custom/components/icon-button/icon-button.js";
216
+
217
217
  import CarbonChatButtonElement, { CHAT_BUTTON_SIZE as CHAT_BUTTON_SIZE$1, CHAT_BUTTON_KIND as CHAT_BUTTON_KIND$1 } from "@carbon/web-components/es-custom/components/chat-button/chat-button.js";
218
218
 
219
219
  const VERSION = "1.15.0";
@@ -2017,7 +2017,9 @@ const DEFAULT_CUSTOM_PANEL_CONFIG_OPTIONS = {
2017
2017
  hideBackButton: false,
2018
2018
  disableAnimation: false,
2019
2019
  fullWidth: false,
2020
- backButtonType: "minimize"
2020
+ backButtonType: "minimize",
2021
+ showChatHeader: false,
2022
+ openFromSide: false
2021
2023
  };
2022
2024
 
2023
2025
  deepFreeze(DEFAULT_CUSTOM_PANEL_CONFIG_OPTIONS);
@@ -11145,7 +11147,7 @@ const OperationalTag = createComponent({
11145
11147
  react: React
11146
11148
  });
11147
11149
 
11148
- const ChevronDown = carbonIconToReact(ChevronDown16);
11150
+ const ChevronDown$1 = carbonIconToReact(ChevronDown16);
11149
11151
 
11150
11152
  const ChevronUp = carbonIconToReact(ChevronUp16);
11151
11153
 
@@ -11191,7 +11193,7 @@ function ConversationalSearchText(props) {
11191
11193
  "aria-label": languagePack.conversationalSearch_toggleCitations
11192
11194
  }, React.createElement("span", {
11193
11195
  slot: "icon"
11194
- }, citationsOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null))))));
11196
+ }, citationsOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown$1, null))))));
11195
11197
  }
11196
11198
 
11197
11199
  function insertHighlightMarkdown(text, highlightCitation) {
@@ -13295,14 +13297,16 @@ class MessagesComponent extends PureComponent {
13295
13297
  });
13296
13298
  this.scheduleAutoScroll = (options = {}, includePublicSpacerReconciliation = false) => {
13297
13299
  requestAnimationFrame(() => {
13298
- const scrollElement = this.messagesContainerWithScrollingRef.current;
13299
- if (!scrollElement) {
13300
- return;
13301
- }
13302
- this.executeResolvedAutoScrollAction(options, scrollElement);
13303
- if (includePublicSpacerReconciliation) {
13304
- this.reconcileSpacerAfterPublicDoAutoScroll(scrollElement);
13305
- }
13300
+ void (async () => {
13301
+ const scrollElement = this.messagesContainerWithScrollingRef.current;
13302
+ if (!scrollElement) {
13303
+ return;
13304
+ }
13305
+ await this.executeResolvedAutoScrollAction(options, scrollElement);
13306
+ if (includePublicSpacerReconciliation) {
13307
+ this.reconcileSpacerAfterPublicDoAutoScroll(scrollElement);
13308
+ }
13309
+ })();
13306
13310
  });
13307
13311
  };
13308
13312
  this.doAutoScrollInternal = (options = {}) => {
@@ -13400,7 +13404,10 @@ class MessagesComponent extends PureComponent {
13400
13404
  if (scrollElement && spacerElem && this.pinnedMessageComponent) {
13401
13405
  const maxScrollTop = scrollElement.scrollHeight - scrollElement.clientHeight;
13402
13406
  const wasBrowserCapped = scrollElement.scrollTop >= maxScrollTop - 2 && scrollElement.scrollTop < this.pinnedScrollTop;
13403
- this.domSpacerHeight = Math.max(0, this.domSpacerHeight - delta);
13407
+ const deltaCompensated = Math.max(0, this.domSpacerHeight - delta);
13408
+ const contentHeightWithoutSpacer = scrollElement.scrollHeight - this.domSpacerHeight;
13409
+ const minSpacerForPin = Math.max(0, this.pinnedScrollTop + scrollElement.clientHeight - contentHeightWithoutSpacer);
13410
+ this.domSpacerHeight = Math.min(deltaCompensated, Math.max(this.domSpacerHeight, minSpacerForPin));
13404
13411
  applySpacerDeficit(spacerElem, this.domSpacerHeight);
13405
13412
  const scrollDelta = Math.abs(scrollElement.scrollTop - this.pinnedScrollTop);
13406
13413
  const hasScrolledAway = scrollDelta > 50;
@@ -13494,6 +13501,20 @@ class MessagesComponent extends PureComponent {
13494
13501
  this.pinnedScrollTop = result.scrollTop;
13495
13502
  debugAutoScroll(`[autoScroll] Pinned message, scrollTop=${result.scrollTop}, spacer=${result.currentSpacerHeight}px`);
13496
13503
  }
13504
+ async waitForMessageComponentLayout(messageComponent) {
13505
+ const targetElem = messageComponent?.ref?.current;
13506
+ if (!targetElem) {
13507
+ return;
13508
+ }
13509
+ const markdownElement = targetElem.querySelector(`${prefix}-markdown`);
13510
+ if (!markdownElement) {
13511
+ return;
13512
+ }
13513
+ await (markdownElement.updateComplete?.catch(() => undefined));
13514
+ await new Promise(resolve => {
13515
+ requestAnimationFrame(() => resolve());
13516
+ });
13517
+ }
13497
13518
  executeRecalculateSpacer(scrollElement) {
13498
13519
  const result = recalculatePinnedMessageSpacer({
13499
13520
  pinnedMessageComponent: this.pinnedMessageComponent,
@@ -13505,7 +13526,7 @@ class MessagesComponent extends PureComponent {
13505
13526
  }
13506
13527
  this.domSpacerHeight = result.deficit;
13507
13528
  }
13508
- executeResolvedAutoScrollAction(options, scrollElement) {
13529
+ async executeResolvedAutoScrollAction(options, scrollElement) {
13509
13530
  const action = resolveAutoScrollAction({
13510
13531
  allMessagesByID: this.props.allMessagesByID,
13511
13532
  localMessageItems: this.props.localMessageItems,
@@ -13532,6 +13553,10 @@ class MessagesComponent extends PureComponent {
13532
13553
  return;
13533
13554
 
13534
13555
  case "pin_message":
13556
+ await this.waitForMessageComponentLayout(action.messageComponent);
13557
+ if (!scrollElement.isConnected) {
13558
+ return;
13559
+ }
13535
13560
  this.executePinAndScroll(action.messageComponent, scrollElement);
13536
13561
  return;
13537
13562
 
@@ -14728,20 +14753,76 @@ function RequestScreenShareModal() {
14728
14753
  });
14729
14754
  }
14730
14755
 
14731
- function PanelHeader({title, showBackButton = true, labelBackButton, backButtonType = "minimize", onClickBack}) {
14732
- const toolbarActions = useMemo(() => showBackButton ? [ {
14733
- text: labelBackButton ?? "",
14734
- icon: backButtonType === "close" ? CloseLarge20 : ChevronDown20,
14735
- size: "md",
14736
- onClick: () => onClickBack?.()
14737
- } ] : [], [ backButtonType, labelBackButton, onClickBack, showBackButton ]);
14756
+ const IconButton = createComponent({
14757
+ tagName: "cds-custom-icon-button",
14758
+ elementClass: CarbonIconButtonElement,
14759
+ react: React
14760
+ });
14761
+
14762
+ const ChevronDown = carbonIconToReact(ChevronDown16);
14763
+
14764
+ const ChevronLeft = carbonIconToReact(ChevronLeft16);
14765
+
14766
+ const CloseLarge = carbonIconToReact(CloseLarge16);
14767
+
14768
+ function PanelHeader({title, openFromSide, showBackButton = true, labelBackButton, backButtonType = "minimize", backButtonPosition = "end", onClickBack}) {
14769
+ const {backButtonIcon, BackButtonIcon} = useMemo(() => {
14770
+ const icons = {
14771
+ close: {
14772
+ iconDescriptor: CloseLarge16,
14773
+ IconComponent: CloseLarge
14774
+ },
14775
+ side: {
14776
+ iconDescriptor: ChevronLeft16,
14777
+ IconComponent: ChevronLeft
14778
+ },
14779
+ down: {
14780
+ iconDescriptor: ChevronDown16,
14781
+ IconComponent: ChevronDown
14782
+ }
14783
+ };
14784
+ const iconKey = backButtonType === "close" ? "close" : openFromSide ? "side" : "down";
14785
+ const selected = icons[iconKey];
14786
+ return {
14787
+ backButtonIcon: selected.iconDescriptor,
14788
+ BackButtonIcon: selected.IconComponent
14789
+ };
14790
+ }, [ backButtonType, openFromSide ]);
14791
+ const toolbarActions = useMemo(() => {
14792
+ if (!showBackButton || backButtonPosition === "start") {
14793
+ return [];
14794
+ }
14795
+ return [ {
14796
+ text: labelBackButton ?? "",
14797
+ icon: backButtonIcon,
14798
+ size: "md",
14799
+ onClick: () => onClickBack?.()
14800
+ } ];
14801
+ }, [ labelBackButton, onClickBack, showBackButton, backButtonPosition, backButtonIcon ]);
14802
+ const tooltipAlign = isDirectionRTL() ? "bottom-end" : "bottom-start";
14738
14803
  return React.createElement("div", {
14739
14804
  "data-floating-menu-container": true
14740
14805
  }, React.createElement(Toolbar, {
14741
14806
  actions: toolbarActions
14742
14807
  }, React.createElement("div", {
14743
14808
  slot: "title"
14744
- }, title)));
14809
+ }, title && React.createElement(MarkdownWithDefaultsExport, {
14810
+ text: title
14811
+ })), showBackButton && backButtonPosition === "start" && React.createElement("div", {
14812
+ slot: "navigation"
14813
+ }, React.createElement(IconButton, {
14814
+ "data-rounded": "top-left",
14815
+ size: "md",
14816
+ kind: BUTTON_KIND.GHOST,
14817
+ align: tooltipAlign,
14818
+ enterDelayMs: 0,
14819
+ leaveDelayMs: 0,
14820
+ onClick: () => onClickBack?.()
14821
+ }, React.createElement(BackButtonIcon, {
14822
+ slot: "icon"
14823
+ }), labelBackButton && React.createElement("span", {
14824
+ slot: "tooltip-content"
14825
+ }, labelBackButton)))));
14745
14826
  }
14746
14827
 
14747
14828
  const HydrationPanel = ({isHydrated, languagePack}) => React.createElement("div", {
@@ -15522,9 +15603,10 @@ const AppShellPanels = React.memo(function AppShellPanels({serviceManager, langu
15522
15603
  fullWidth: "fullWidth" in customPanelState.options && customPanelState.options.fullWidth ? true : false,
15523
15604
  showFrame: "showFrame" in customPanelState.options && customPanelState.options.showFrame ? true : false,
15524
15605
  aiEnabled: "aiEnabled" in customPanelState.options && customPanelState.options.aiEnabled ? true : false,
15525
- showChatHeader: !isLegacyCustomPanel,
15526
- animationOnOpen: customPanelState.options.disableAnimation ? "none" : "slide-in-from-bottom",
15527
- animationOnClose: customPanelState.options.disableAnimation ? "none" : "slide-out-to-bottom",
15606
+ showChatHeader: !isLegacyCustomPanel && "showChatHeader" in customPanelState.options && customPanelState.options.showChatHeader ? true : false,
15607
+ animationOnOpen: customPanelState.options.disableAnimation ? "none" : "openFromSide" in customPanelState.options && customPanelState.options.openFromSide ? "slide-in-from-start" : "slide-in-from-bottom",
15608
+ animationOnClose: customPanelState.options.disableAnimation ? "none" : "openFromSide" in customPanelState.options && customPanelState.options.openFromSide ? "slide-out-to-start" : "slide-out-to-bottom",
15609
+ openFromSide: "openFromSide" in customPanelState.options && customPanelState.options.openFromSide ? true : false,
15528
15610
  onOpenStart: () => {
15529
15611
  serviceManager.eventBus.fire({
15530
15612
  type: BusEventType.CUSTOM_PANEL_PRE_OPEN
@@ -15576,6 +15658,8 @@ const AppShellPanels = React.memo(function AppShellPanels({serviceManager, langu
15576
15658
  title: panelTitle,
15577
15659
  labelBackButton: languagePack.general_returnToAssistant,
15578
15660
  backButtonType: "backButtonType" in customPanelState.options ? customPanelState.options.backButtonType : undefined,
15661
+ backButtonPosition: "backButtonPosition" in customPanelState.options ? customPanelState.options.backButtonPosition : undefined,
15662
+ openFromSide: "openFromSide" in customPanelState.options && customPanelState.options.openFromSide,
15579
15663
  onClickBack: () => {
15580
15664
  serviceManager.store.dispatch(actions.setCustomPanelOpen(false));
15581
15665
  "onClickBack" in customPanelState.options && customPanelState.options.onClickBack?.();