'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-a0b63bee.js');

const DgaSuffix = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.onSelect = index.createEvent(this, "onSelect", 7);
        this.dpIsActive = false;
        this.selectedOption = null;
    }
    handleSuffixClick() {
        this.suffixBtn.classList.toggle('open');
    }
    handleOptionSelect(option) {
        this.selectedOption = option;
        this.onSelect.emit(option.value);
        const dropdownLabel = this.suffixBtn.querySelector('.dropdown__label');
        if (dropdownLabel) {
            dropdownLabel.classList.add('dropdown__label--selection');
        }
        this.suffixBtn.classList.remove('open');
        this.suffixBtn.classList.add('selected');
    }
    render() {
        if (this.type === 'text') {
            return (index.h("div", { class: `input__suffix input__suffix--${this.variant}-text` }, index.h("span", { class: "input__suffix-label" }, this.label)));
        }
        return (index.h(index.Fragment, null, index.h("button", { class: `input__suffix input__suffix--${this.variant} input__dropdown-btn`, onMouseDown: () => (this.dpIsActive = true), onMouseUp: () => (this.dpIsActive = false), onMouseOut: () => (this.dpIsActive = false), onClick: () => this.handleSuffixClick(), ref: el => (this.suffixBtn = el) }, index.h("span", { class: "input__suffix-icon" }, this.icon), index.h("span", { class: "dropdown__label" }, this.selectedOption && Object.keys(this.selectedOption).length ? this.selectedOption.label : ' '), index.h("span", { class: "input__suffix-label" }, this.label), index.h("span", { class: "input__suffix-chevron" }, index.h("dga-icon", { icon: "ArrowDown01Icon", variant: "stroke" }))), index.h("ul", { class: "input__dropdown-list" }, this.options &&
            this.options.map(option => {
                var _a;
                return (index.h("li", { key: option.value }, index.h("button", { class: `dropdown__option ${((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) === option.value ? 'selected' : ''}`, onClick: () => this.handleOptionSelect(option) }, index.h("span", { class: "dropdown__option-label" }, option.label), index.h("span", { class: "dropdown__option-icon" }, index.h("dga-icon", { icon: "Tick02Icon", variant: "solid" })))));
            }))));
    }
};

exports.dga_suffix = DgaSuffix;

//# sourceMappingURL=dga-suffix.cjs.entry.js.map