"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.whenInteracted = exports.DIM_TIMEOUT_T = exports.DIM_OPACITY = void 0;
const listenMovement_1 = require("./listenMovement");
exports.DIM_OPACITY = 0.2;
exports.DIM_TIMEOUT_T = 3000;
function whenInteracted(component, ms = 6000, active = true, on_active, on_inactive) {
    let timeout = null;
    const resetTimeout = () => {
        if (timeout) {
            clearTimeout(timeout);
        }
        timeout = setTimeout(() => {
            active = false;
            on_inactive();
        }, ms);
    };
    resetTimeout();
    const unlisten = (0, listenMovement_1.listenMovement)(component, () => {
        resetTimeout();
        on_active();
    });
    if (active) {
        on_active();
    }
    else {
        on_inactive();
    }
    return unlisten;
}
exports.whenInteracted = whenInteracted;
//# sourceMappingURL=whenInteracted.js.map