"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleAllowHoverLabelUC = void 0;
exports.makeToggleAllowHoverLabel = makeToggleAllowHoverLabel;
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const HoverLabelEntity_1 = require("../Entities/HoverLabelEntity");
class ToggleAllowHoverLabelUC extends core_1.AppObjectUC {
    static get(appObjects) {
        return (0, core_1.getSingletonComponent)(ToggleAllowHoverLabelUC.type, appObjects);
    }
}
exports.ToggleAllowHoverLabelUC = ToggleAllowHoverLabelUC;
ToggleAllowHoverLabelUC.type = "ToggleAllowHoverLabelUC";
function makeToggleAllowHoverLabel(appObject) {
    return new ToggleAllowHoverLabelIMP(appObject);
}
class ToggleAllowHoverLabelIMP extends ToggleAllowHoverLabelUC {
    constructor(appObject) {
        super(appObject, ToggleAllowHoverLabelUC.type);
        this.toggleAllowHoverLabel = () => {
            if (!this.hoverLabelEntity)
                return;
            this.hoverLabelEntity.allowHoverLabel = !this.hoverLabelEntity
                .allowHoverLabel;
            (0, Dispatcher_1.dispatchStateChange)(this.appObjects);
        };
        this.hoverLabelEntity = this.appObject.getComponent(HoverLabelEntity_1.HoverLabelEntity.type);
        if (!this.hoverLabelEntity) {
            this.warn("PM has been added to an App Object that does not have a HoverLabelEntity. Add the Entity first");
        }
    }
}
//# sourceMappingURL=ToggleAllowHoverLabel.js.map