import { r as registerInstance, h, F as Fragment } from './index-1acf58d3.js';

const DgaMenu = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.anchorEl = null;
        this.open = false;
        this.onClose = () => { };
        // Method to detect outside click
        this.handleClickOutside = (event) => {
            if (this.anchorEl && !this.anchorEl.contains(event.target)) {
                this.onClose();
            }
        };
    }
    componentDidLoad() {
        // Add event listener to handle clicks outside the menu
        document.addEventListener('click', this.handleClickOutside);
    }
    disconnectedCallback() {
        // Cleanup event listener when the component is destroyed
        document.removeEventListener('click', this.handleClickOutside);
    }
    getMenuStyle() {
        var _a;
        const rect = (_a = this.anchorEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
        return {
            position: 'absolute',
            top: `${(rect === null || rect === void 0 ? void 0 : rect.bottom) + window.scrollY}px`,
            left: `${(rect === null || rect === void 0 ? void 0 : rect.left) + window.scrollX}px`,
            zIndex: '1000',
        };
    }
    render() {
        return (h(Fragment, { key: '5e10a99bade5cd109be97e44b4a780737b248ce6' }, this.open && this.anchorEl && (h("ul", { key: '0b78ff517c4c128cfce96fa7eff5f53a606c2c77', class: "menu", style: this.getMenuStyle() }, h("slot", { key: '177676d0a8d61e73873c2b513e79046a7cdaf24c' })))));
    }
};

export { DgaMenu as dga_menu };

//# sourceMappingURL=dga-menu.entry.js.map