import { ValidationError } from "../../core/index.js";
import {} from "../Component.js";
export class ActiveComponent {
    activeSelf;
    activeInHierarchy;
    constructor(active = true) {
        if (typeof active !== "boolean")
            throw new ValidationError("ACTIVE_COMPONENT", "ActiveComponent expects a boolean active state.");
        this.activeSelf = active;
        this.activeInHierarchy = active;
    }
    get isActive() {
        return this.activeSelf;
    }
    get isActiveInHierarchy() {
        return this.activeInHierarchy;
    }
    setActive(active) {
        if (typeof active !== "boolean")
            throw new ValidationError("ACTIVE_COMPONENT", "Active state must be boolean.");
        this.activeSelf = active;
    }
    toggle() {
        this.activeSelf = !this.activeSelf;
    }
    toJSON() {
        return { activeSelf: this.activeSelf };
    }
    static schema = {
        version: 1,
        serialize(component) {
            const active = component;
            return { activeSelf: active.activeSelf };
        },
        deserialize(data) {
            if (!isRecord(data) || typeof data.activeSelf !== "boolean") {
                throw new ValidationError("ACTIVE_COMPONENT_DESERIALIZE", "ActiveComponent data requires activeSelf boolean.");
            }
            return new ActiveComponent(data.activeSelf);
        }
    };
}
function isRecord(value) {
    return typeof value === "object" && value !== null;
}
//# sourceMappingURL=ActiveComponent.js.map