"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AtomicGeneratedAnswerThread: ()=>AtomicGeneratedAnswerThread
});
const external_lit_namespaceObject = require("lit");
const decorators_js_namespaceObject = require("lit/decorators.js");
const repeat_js_namespaceObject = require("lit/directives/repeat.js");
require("../atomic-generated-answer-content/atomic-generated-answer-content.cjs");
require("../atomic-generated-answer-thread-item/atomic-generated-answer-thread-item.cjs");
const with_tailwind_styles_cjs_namespaceObject = require("../../../decorators/with-tailwind-styles.cjs");
function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
    else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
    if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
}
const MIN_ANSWERS_TO_COLLAPSE = 2;
const GENERATED_ANSWER_CONTENT_EXPORT_PARTS = "feedback-and-copy-buttons,feedback-button,copy-button,citations-label,citation,citation-popover,generated-text,answer-code-block,answer-emphasis,answer-inline-code,answer-heading-1,answer-heading-2,answer-heading-3,answer-heading-4,answer-heading-5,answer-heading-6,answer-list-item,answer-link,answer-link-text,answer-link-icon,answer-ordered-list,answer-paragraph,answer-quote-block,answer-unordered-list,answer-strong,answer-table,answer-table-container,answer-table-content,answer-table-header";
class AtomicGeneratedAnswerThread extends external_lit_namespaceObject.LitElement {
    updated(changedProperties) {
        if (changedProperties.has('generatedAnswers')) {
            const oldValue = changedProperties.get('generatedAnswers');
            const newValue = this.generatedAnswers;
            if (oldValue?.length !== newValue?.length) this.allGeneratedAnswersDisplayed = false;
        }
    }
    render() {
        if (this.generatedAnswers.length > MIN_ANSWERS_TO_COLLAPSE && !this.allGeneratedAnswersDisplayed) {
            const lastGeneratedAnswer = this.generatedAnswers[this.generatedAnswers.length - 1];
            return (0, external_lit_namespaceObject.html)`
        <ul>
          ${this.renderShowPreviousAnswersButton()}
          ${this.renderThread([
                lastGeneratedAnswer
            ])}
        </ul>
      `;
        }
        return (0, external_lit_namespaceObject.html)`
      <ul>
        ${this.renderThread(this.generatedAnswers)}
      </ul>
    `;
    }
    renderThread(generatedAnswers) {
        const showTimelineDot = this.generatedAnswers.length > 1;
        return (0, external_lit_namespaceObject.html)`
      ${(0, repeat_js_namespaceObject.repeat)(generatedAnswers, (answer)=>answer.answerId, (answer, index)=>{
            const isLastAnswer = index === generatedAnswers.length - 1;
            return (0, external_lit_namespaceObject.html)`
            <atomic-generated-answer-thread-item
              .title=${answer.question}
              .hideLine=${isLastAnswer}
              .disableCollapse=${isLastAnswer}
              .isExpanded=${isLastAnswer}
              .showTimelineDot=${showTimelineDot}
            >
              <atomic-generated-answer-content
                .generatedAnswer=${answer}
                .i18n=${this.i18n}
                .renderCitations=${this.renderCitations}
                .onClickLike=${this.onClickLike}
                .onClickDislike=${this.onClickDislike}
                .onCopyToClipboard=${this.onCopyToClipboard}
                exportparts=${GENERATED_ANSWER_CONTENT_EXPORT_PARTS}
              ></atomic-generated-answer-content>
            </atomic-generated-answer-thread-item>
          `;
        })}
    `;
    }
    handleShowAllClick() {
        this.allGeneratedAnswersDisplayed = true;
    }
    renderShowPreviousAnswersButton() {
        const label = this.i18n?.t?.('show-previous-questions', {
            count: this.generatedAnswers.length - 1
        }) ?? 'Show previous questions';
        const showPreviousButtonClasses = `
      text-on-background text-base min-w-0 inline-flex text-left mr-auto
      px-2 py-1.5 font-normal bg-transparent border-0 appearance-none
      transition-colors hover:bg-neutral-light rounded-md cursor-pointer
      focus-visible:outline-none focus-visible:ring-2
      focus-visible:ring-primary focus-visible:ring-offset-2
    `;
        const timelineDotClasses = `
      h-2 w-2 rounded-full bg-neutral-dim
    `;
        const timelineConnectorClasses = `
      relative h-full w-px bg-neutral
      before:absolute before:left-0 before:top-[-8px]
      before:h-[8px] before:w-px before:bg-neutral before:content-['']
      after:absolute after:bottom-[-8px] after:left-0
      after:h-[8px] after:w-px after:bg-neutral after:content-['']
    `;
        return (0, external_lit_namespaceObject.html)`
      <li class="grid min-w-0">
        <div class="flex min-w-0 items-center gap-3">
          <div class="flex w-[10px] shrink-0 items-center justify-center">
            <span class=${timelineDotClasses}></span>
          </div>
          <div class="flex min-w-0 flex-col">
            <button
              type="button"
              class=${showPreviousButtonClasses}
              @click=${this.handleShowAllClick}
            >
              ${label}
            </button>
          </div>
        </div>
        <div class="flex h-3 w-[10px] shrink-0 justify-center">
          <span class=${timelineConnectorClasses}> </span>
        </div>
      </li>
    `;
    }
    constructor(...args){
        super(...args), this.generatedAnswers = [], this.renderCitations = ()=>(0, external_lit_namespaceObject.html)``, this.onClickLike = ()=>{}, this.onClickDislike = ()=>{}, this.onCopyToClipboard = ()=>{}, this.allGeneratedAnswersDisplayed = false;
    }
}
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: false
    }),
    _ts_metadata("design:type", Array)
], AtomicGeneratedAnswerThread.prototype, "generatedAnswers", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: false
    }),
    _ts_metadata("design:type", "u" < typeof i18n ? Object : i18n)
], AtomicGeneratedAnswerThread.prototype, "i18n", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: false
    }),
    _ts_metadata("design:type", Function)
], AtomicGeneratedAnswerThread.prototype, "renderCitations", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: false
    }),
    _ts_metadata("design:type", Function)
], AtomicGeneratedAnswerThread.prototype, "onClickLike", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: false
    }),
    _ts_metadata("design:type", Function)
], AtomicGeneratedAnswerThread.prototype, "onClickDislike", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.property)({
        attribute: false
    }),
    _ts_metadata("design:type", Function)
], AtomicGeneratedAnswerThread.prototype, "onCopyToClipboard", void 0);
_ts_decorate([
    (0, decorators_js_namespaceObject.state)(),
    _ts_metadata("design:type", Boolean)
], AtomicGeneratedAnswerThread.prototype, "allGeneratedAnswersDisplayed", void 0);
AtomicGeneratedAnswerThread = _ts_decorate([
    (0, decorators_js_namespaceObject.customElement)('atomic-generated-answer-thread'),
    with_tailwind_styles_cjs_namespaceObject.withTailwindStyles
], AtomicGeneratedAnswerThread);
exports.AtomicGeneratedAnswerThread = __webpack_exports__.AtomicGeneratedAnswerThread;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AtomicGeneratedAnswerThread"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
