var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m") throw new TypeError("Private method is not writable");
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _EdenButton_tooltip, _EdenButton_direction, _EdenButton_content, _EdenButton_createTooltip, _EdenButton_removeTooltip;
import EdenTooltip from "./eden-tooltip.js";
class EdenButton extends HTMLButtonElement {
    constructor() {
        super();
        _EdenButton_tooltip.set(this, void 0);
        _EdenButton_direction.set(this, void 0);
        _EdenButton_content.set(this, void 0);
        _EdenButton_createTooltip.set(this, () => {
            __classPrivateFieldSet(this, _EdenButton_tooltip, this.getAttribute("tooltip"), "f");
            __classPrivateFieldSet(this, _EdenButton_direction, this.getAttribute("direction"), "f");
            if (__classPrivateFieldGet(this, _EdenButton_tooltip, "f") === null)
                return;
            const tooltip = new EdenTooltip(this, __classPrivateFieldGet(this, _EdenButton_tooltip, "f"), __classPrivateFieldGet(this, _EdenButton_direction, "f"));
            __classPrivateFieldSet(this, _EdenButton_content, tooltip, "f");
            document.body.appendChild(__classPrivateFieldGet(this, _EdenButton_content, "f"));
        });
        _EdenButton_removeTooltip.set(this, () => {
            if (!__classPrivateFieldGet(this, _EdenButton_tooltip, "f") || !__classPrivateFieldGet(this, _EdenButton_content, "f"))
                return;
            try {
                __classPrivateFieldGet(this, _EdenButton_content, "f").remove();
                __classPrivateFieldSet(this, _EdenButton_content, null, "f");
            }
            catch {
            }
        });
        __classPrivateFieldSet(this, _EdenButton_tooltip, null, "f");
        __classPrivateFieldSet(this, _EdenButton_direction, null, "f");
        __classPrivateFieldSet(this, _EdenButton_content, null, "f");
        this.disabled =
            this.hasAttribute("disabled") &&
                this.getAttribute("disabled") !== "false";
    }
    connectedCallback() {
        if (!this.disabled) {
            this.addEventListener("mouseenter", __classPrivateFieldGet(this, _EdenButton_createTooltip, "f"));
            this.addEventListener("mouseleave", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            this.addEventListener("blur", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            this.addEventListener("mousedown", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            window.addEventListener("scroll", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
        }
    }
    disconnectedCallback() {
        if (!this.disabled) {
            window.removeEventListener("scroll", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            this.removeEventListener("mousedown", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            this.removeEventListener("blur", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            this.removeEventListener("mouseleave", __classPrivateFieldGet(this, _EdenButton_removeTooltip, "f"));
            this.removeEventListener("mouseenter", __classPrivateFieldGet(this, _EdenButton_createTooltip, "f"));
        }
    }
}
_EdenButton_tooltip = new WeakMap(), _EdenButton_direction = new WeakMap(), _EdenButton_content = new WeakMap(), _EdenButton_createTooltip = new WeakMap(), _EdenButton_removeTooltip = new WeakMap();
if (!customElements.get("eden-button")) {
    customElements.define("eden-button", EdenButton, { extends: "button" });
}
