"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const _ids_1 = require("../../../../_ids");
class WakeLock extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['type'],
            fo: [],
            i: [],
            o: [],
        }, {}, system, _ids_1.ID_WAKE_LOCK);
        this._on_release = () => {
            // console.log('WakeLock', '_on_release')
            this._wake_lock = null;
        };
    }
    async f({ type }, done) {
        const { api: { screen: { wakeLock: { request }, }, }, } = this.__system;
        const wake_lock = await request(type);
        wake_lock.addEventListener('release', this._on_release);
        this._wake_lock = wake_lock;
    }
    d() {
        if (this._wake_lock) {
            this._wake_lock.release();
            this._wake_lock = undefined;
        }
    }
}
exports.default = WakeLock;
//# sourceMappingURL=index.js.map