import { html } from "lit";
import { when } from "lit/directives/when.js";
import { copyButtonClickHandler } from "./utils.js";
const downloadCodeBlockCallback = (plainText, language, downloadCodeBlock) => () => downloadCodeBlock(plainText, language);
export const customCodeBlockRender = (chatRef) => (options) => {
    const { accessibleName, text } = chatRef.translations;
    const downloadCb = chatRef.callbacks?.downloadCodeBlock;
    return html `<div part="code-block"><div part="code-block__header"><span part="code-block__header-caption">${options.language ?? "txt"}</span><div part="code-block__header-actions"><button class="button-copy-code" aria-label="${text.copyCodeButton}" part="code-block__button--icon-only code-block__copy-code-button" type="button" @click="${(e) => copyButtonClickHandler(e, options.plainText)}"></button> ${when(downloadCb, () => html `<button aria-label="${accessibleName.downloadCodeButton}" part="code-block__button--icon-only code-block__download-code-button" @click="${downloadCodeBlockCallback(options.plainText, options.language, downloadCb)}"></button>`)}</div></div><ch-code .language="${options.language}" .lastNestedChildClass="${options.lastNestedChildClass}" part="code-block__content" .showIndicator="${options.showIndicator}" .value="${options.plainText}"></ch-code></div>`;
};
