import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { g as getIconPath } from './mer-animated-dots.js';
import 'lit';
import 'lit/directives/when.js';
import 'lit/directives/if-defined.js';
import { L as Locale } from './locale.js';

const chatContainerCss = ".chat-container{background-color:var(--elevation-background-color, --color-accent-surface-elevation-1);display:grid;block-size:100%;overflow:auto;grid-template-rows:1fr;position:relative;--chat-common-border-radius:4px}.chat-container.with-header{grid-template-rows:max-content 1fr}.section{display:contents}.header{padding:4px 4px 4px 12px;display:flex;align-items:center;justify-content:space-between;gap:var(--spacing-gap-l);color:var(--color-text-neutral-default);border-block-end:1px solid var(--color-border-surface-on-elevation-1)}.header .button-copy-chat,.header .button-delete-chat{--control-border-color:transparent !important}.header .button-delete-chat:hover{filter:brightness(1.3)}.header .button-delete-chat:active{filter:brightness(0.8)}.ch-chat-container{overflow:auto;position:relative;display:grid}.chat-container__conversation-copied{position:absolute;z-index:1;inline-size:100%;block-size:100%;background:var(--color-accent-neutral-black);opacity:0.75;backdrop-filter:saturate(180%) blur(20px);display:grid;align-items:center;justify-content:center;text-align:center;padding:var(--spacing-padding-xxxl);pointer-events:none;overflow:hidden;animation:fadeIn 100ms ease-in-out forwards;opacity:0}.chat-container__conversation-copied-wrapper{display:flex;align-items:center;gap:var(--spacing-gap-l);position:relative;inset-block-start:4px;opacity:0;animation:liftUp var(--timing-fast) ease-in-out forwards;animation-delay:var(--timing-fast)}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes liftUp{from{opacity:0;inset-block-start:4px}to{opacity:1;inset-block-start:0}}.chat::part(code-block-header__copy){--copy-text-opacity:0;--copy-text-translate-x:8px;opacity:var(--copy-text-opacity);pointer-events:none;transform:translateX(var(--copy-text-translate-x));transition:opacity 100ms ease-in-out, transform 100ms ease-in-out;font-size:var(--font-size-body-s)}.chat::part(code-block-header__copy-copied){--copy-button-pointer-events:none !important;--copy-text-opacity:1;--copy-text-translate-x:0}.chat::part(code-block-header){align-items:center;display:flex;gap:var(--spacing-gap-m)}";

var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m")
        throw new TypeError("Private method is not writable");
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _GxIdeChatContainer_menuItems, _GxIdeChatContainer_componentLocale, _GxIdeChatContainer_showMenuHandler, _GxIdeChatContainer_menuExpandedChangeHandler, _GxIdeChatContainer_copyConversationHandler, _GxIdeChatContainer_deleteConversationHandler;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "utils/typography",
    "chameleon/scrollbar",
    "components/button",
    "components/dropdown",
    "components/icon",
    "utils/elevation"
];
const COPY_ICON = getIconPath({
    category: "system",
    name: "copy",
    colorType: "primary"
});
const DELETE_ICON = getIconPath({
    category: "system",
    name: "delete-outlined",
    colorType: "primary"
});
const CONVERSATION_ICON = getIconPath({
    category: "objects",
    name: "conversational-flows"
});
const MORE_HORIZONTAL_ICON = getIconPath({
    category: "system",
    name: "more-horizontal",
    colorType: "interactive"
});
const GxIdeChatContainer = /*@__PURE__*/ proxyCustomElement(class GxIdeChatContainer extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        _GxIdeChatContainer_menuItems.set(this, [
            { type: "slot", id: "delete-chat-button" },
            { type: "slot", id: "copy-chat-button" }
        ]);
        /**
         * The component hard-coded strings translations.
         */
        // eslint-disable-next-line @stencil-community/own-props-must-be-private
        _GxIdeChatContainer_componentLocale.set(this, void 0);
        _GxIdeChatContainer_showMenuHandler.set(this, () => {
            this.menuIsExpanded = true;
        });
        _GxIdeChatContainer_menuExpandedChangeHandler.set(this, (event) => {
            this.menuIsExpanded = event.detail;
        });
        _GxIdeChatContainer_copyConversationHandler.set(this, () => {
            if (this.copyConversationCallback) {
                this.copyConversationCallback();
                this.menuIsExpanded = false;
            }
        });
        _GxIdeChatContainer_deleteConversationHandler.set(this, () => {
            if (this.deleteConversationCallback) {
                this.deleteConversationCallback();
                this.menuIsExpanded = false;
            }
        });
        this.displayConversationCopiedMessage = false;
        this.menuIsExpanded = false;
        this.chatTitle = undefined;
        this.copyConversationCallback = undefined;
        this.deleteConversationCallback = undefined;
        this.displayWelcomeScreen = false;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeChatContainer_componentLocale, await Locale.getComponentStrings(this.el), "f");
    }
    /**
     * It will display a feedback message that the conversation has been copied
     */
    async showCopyConversationMessage() {
        this.displayConversationCopiedMessage = true;
        setTimeout(() => {
            this.displayConversationCopiedMessage = false;
        }, 2000);
    }
    render() {
        const renderHeader = this.chatTitle ||
            this.copyConversationCallback ||
            this.deleteConversationCallback;
        const renderButtonsGroup = this.copyConversationCallback || this.deleteConversationCallback;
        return (h(Host, { class: {
                "chat-container": true,
                "with-header": !!renderHeader
            } }, h("ch-theme", { model: CSS_BUNDLES }), h("section", { class: "section" }, renderHeader && (h("header", { class: "header caption-semi-bold-l" }, this.chatTitle && this.chatTitle, renderButtonsGroup && (h("ch-action-menu-render", { class: "dropdown", blockAlign: "inside-start", inlineAlign: "inside-end", model: __classPrivateFieldGet(this, _GxIdeChatContainer_menuItems, "f"), expanded: this.menuIsExpanded, onExpandedChange: __classPrivateFieldGet(this, _GxIdeChatContainer_menuExpandedChangeHandler, "f") }, h("button", { class: "button-tertiary button-icon-only", onClick: __classPrivateFieldGet(this, _GxIdeChatContainer_showMenuHandler, "f"), type: "button", "aria-label": __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").showMenuAriaLabel, title: __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").showMenuAriaLabel }, h("ch-image", { class: "icon-m", src: MORE_HORIZONTAL_ICON })), this.copyConversationCallback && (h("button", { class: "button-tertiary button-icon-and-text button-copy-chat", slot: "copy-chat-button", onClick: __classPrivateFieldGet(this, _GxIdeChatContainer_copyConversationHandler, "f"), type: "button", "aria-label": __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").copyConversationAriaLabel, title: __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").copyConversationAriaLabel }, h("ch-image", { class: "icon-m", src: COPY_ICON }), __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").copyConversationLabel)), this.deleteConversationCallback && (h("button", { class: "button-tertiary button-icon-and-text button-delete-chat", slot: "delete-chat-button", onClick: __classPrivateFieldGet(this, _GxIdeChatContainer_deleteConversationHandler, "f"), type: "button", "aria-label": __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").deleteConversationAriaLabel, title: __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").deleteConversationAriaLabel }, h("ch-image", { class: "icon-m", src: DELETE_ICON }), __classPrivateFieldGet(this, _GxIdeChatContainer_componentLocale, "f").clearConversationLabel)))))), h("section", { class: "ch-chat-container" }, h("slot", null), this.displayConversationCopiedMessage && (h("div", { class: "chat-container__conversation-copied" }, h("div", { class: "chat-container__conversation-copied-wrapper" }, h("ch-image", { class: "icon-m", src: CONVERSATION_ICON }), h("p", { class: "body-regular-l" }, "conversation copied"))))))));
    }
    static get assetsDirs() { return ["gx-ide-assets/chat-container"]; }
    get el() { return this; }
    static get style() { return chatContainerCss; }
}, [4, "gx-ide-chat-container", {
        "chatTitle": [1, "chat-title"],
        "copyConversationCallback": [16],
        "deleteConversationCallback": [16],
        "displayWelcomeScreen": [4, "display-welcome-screen"],
        "displayConversationCopiedMessage": [32],
        "menuIsExpanded": [32],
        "showCopyConversationMessage": [64]
    }]);
_GxIdeChatContainer_menuItems = new WeakMap(), _GxIdeChatContainer_componentLocale = new WeakMap(), _GxIdeChatContainer_showMenuHandler = new WeakMap(), _GxIdeChatContainer_menuExpandedChangeHandler = new WeakMap(), _GxIdeChatContainer_copyConversationHandler = new WeakMap(), _GxIdeChatContainer_deleteConversationHandler = new WeakMap();
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["gx-ide-chat-container"];
    components.forEach(tagName => { switch (tagName) {
        case "gx-ide-chat-container":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, GxIdeChatContainer);
            }
            break;
    } });
}

export { GxIdeChatContainer as G, defineCustomElement as d };

//# sourceMappingURL=chat-container.js.map