import { r as registerInstance, d as createEvent, h, c as getElement } from './core-3f33e631.js';
import { T as Tunnel } from './i18n.provider-106e9203.js';

var FilterTypeLabels;
(function (FilterTypeLabels) {
    FilterTypeLabels["contains"] = "Contains";
    FilterTypeLabels["ends-with"] = "Ends With";
    FilterTypeLabels["equals"] = "Equals";
    FilterTypeLabels["starts-with"] = "Starts With";
})(FilterTypeLabels || (FilterTypeLabels = {}));
const StringFilterPanel = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.anjFilterChange = createEvent(this, "anjFilterChange", 7);
    }
    async reset() {
        this.element.querySelector('form').reset();
    }
    componentWillLoad() {
        this.type = this.filter ? this.filter.type : this.types[0] || 'contains';
    }
    onSubmit(e) {
        e.preventDefault();
        const filter = {};
        Array.from(e.target.querySelectorAll('input')).forEach((i) => {
            filter[i.name] = i.value.trim() !== '' ? i.value.trim() : undefined;
        });
        filter.type = this.type;
        this.anjFilterChange.emit(filter);
    }
    render() {
        return (h("form", { onSubmit: (e) => this.onSubmit(e) }, h("input", { type: "hidden", name: "field", value: this.field }), this.types.length > 1 ?
            h("anj-form-group", null, h("anj-label", null, this.translator('Type')), h("anj-select", { name: "type", value: this.type, onAnjChange: e => this.type = e.detail.value }, this.types.map(t => h("anj-option", { value: t }, this.translator(FilterTypeLabels[t])))))
            : undefined, h("anj-form-group", null, h("anj-label", null, this.translator('Filter')), h("anj-input", { name: "query" })), h("anj-button-group", { align: "right" }, h("anj-button", { context: "text", type: "submit" }, this.translator('Apply')))));
    }
    get element() { return getElement(this); }
    static get style() { return ".sc-anj-string-filter-panel-h {\n  display: block;\n  padding: 1rem;\n}\n.sc-anj-string-filter-panel-h anj-button-group.sc-anj-string-filter-panel {\n  margin-bottom: 0;\n}"; }
};
Tunnel.injectProps(StringFilterPanel, ['translator']);

export { StringFilterPanel as anj_string_filter_panel };
