import { buildQuerySummary } from "@coveo/headless/insight";
import { LitElement, html } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { renderIconButton } from "../../common/icon-button.js";
import { bindStateToController } from "../../../decorators/bind-state.js";
import { bindingGuard } from "../../../decorators/binding-guard.js";
import { bindings } from "../../../decorators/bindings.js";
import { errorGuard } from "../../../decorators/error-guard.js";
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
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);
}
class AtomicInsightGenerateAnswerButton extends LitElement {
    initialize() {
        this.querySummary = buildQuerySummary(this.bindings.engine);
    }
    render() {
        const { hasQuery, total } = this.querySummaryState;
        if (hasQuery || 0 === total) return html``;
        return html`
      ${renderIconButton({
            props: {
                partPrefix: 'generate-answer',
                style: 'primary',
                icon: 'assets://sparkles.svg',
                ariaLabel: this.tooltip,
                title: this.tooltip
            }
        })}
    `;
    }
    constructor(...args){
        super(...args), this.tooltip = 'Generate Answer';
    }
}
_ts_decorate([
    state(),
    _ts_metadata("design:type", "u" < typeof InsightBindings ? Object : InsightBindings)
], AtomicInsightGenerateAnswerButton.prototype, "bindings", void 0);
_ts_decorate([
    state(),
    _ts_metadata("design:type", "u" < typeof Error ? Object : Error)
], AtomicInsightGenerateAnswerButton.prototype, "error", void 0);
_ts_decorate([
    bindStateToController('querySummary'),
    state(),
    _ts_metadata("design:type", "u" < typeof QuerySummaryState ? Object : QuerySummaryState)
], AtomicInsightGenerateAnswerButton.prototype, "querySummaryState", void 0);
_ts_decorate([
    property({
        type: String,
        attribute: 'tooltip'
    })
], AtomicInsightGenerateAnswerButton.prototype, "tooltip", void 0);
_ts_decorate([
    errorGuard(),
    bindingGuard(),
    _ts_metadata("design:type", Function),
    _ts_metadata("design:paramtypes", []),
    _ts_metadata("design:returntype", void 0)
], AtomicInsightGenerateAnswerButton.prototype, "render", null);
AtomicInsightGenerateAnswerButton = _ts_decorate([
    customElement('atomic-insight-generate-answer-button'),
    bindings(),
    withTailwindStyles
], AtomicInsightGenerateAnswerButton);
export { AtomicInsightGenerateAnswerButton };
