'use strict';

var index = require('./index-p7cvUYAE.js');
var button = require('./button-CR9Rl1-o.js');
var parts = require('./parts-BXshb_S-.js');

const hasFilters = (params) => {
    const paginationKeys = ['after_cursor', 'before_cursor'];
    const paramKeys = Object.keys(params);
    const filterKeys = paramKeys.filter((paramKey) => !paginationKeys.includes(paramKey));
    return !!filterKeys.length;
};

const TableFiltersMenu = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.showClearButton = false;
    }
    watchParamsHandler(newValue) {
        this.showClearButton = hasFilters(newValue);
    }
    show() {
        this.menu.classList.add('show');
    }
    hide() {
        this.menu.classList.remove('show');
    }
    componentWillLoad() {
        this.showClearButton = hasFilters(this.params);
    }
    render() {
        return (index.h("div", { key: 'bcecb736427ce7859174c8f91938f720f8e32782', class: "d-flex gap-2" }, index.h("div", { key: 'aadd72cb3aac3d676a340068304802dbc5dfeab2', class: "dropdown pb-3" }, index.h("button", { key: '2dbb5590ea8ed60d2228b0f0b262332e5d377810', type: "button dropdown-toggle", ref: (el) => (this.anchorButton = el), class: "btn btn-primary dropdown-toggle", part: parts.dropdownMenuButton, "data-test-id": "open-filters-button", "data-bs-toggle": "dropdown" }, "Filters"), index.h("custom-popper", { key: 'c516ec2550207e3acc3d0186c6f86d351a6ca4a9', offset: [20, 10], strategy: "fixed", anchorRef: this.anchorButton, trigger: "click" }, index.h("form", { key: '4ee1c1bd0e5c9eacccb857986d3f2e37bb3d990b', class: "dropdown-menu", part: parts.dropdownMenu, "data-test-id": "filter-menu", ref: (el) => (this.menu = el), onSubmit: (e) => e.preventDefault() }, index.h("slot", { key: 'b274f915722d1a59af4578935c4233bcf700c7b2' })))), index.h("div", { key: 'ce527862135dd31b9b198133a3a2c19699419c5d' }, index.h(button.Button, { key: '272022c173de7f8c41ba7a88cf5aa004da11b3a2', variant: "secondary", onClick: () => this.clearParams(), hidden: !this.showClearButton, "data-test-id": "clear-filters-button" }, "Clear Filters"))));
    }
    static get watchers() { return {
        "params": ["watchParamsHandler"]
    }; }
};

exports.table_filters_menu = TableFiltersMenu;
