import { __decorate, __extends } from "tslib";
import { createFocusTrap } from 'focus-trap';
import Component from 'vue-class-component';
import { ModulVue } from '../../utils/vue/vue';
var MFocusTrap = /** @class */ (function (_super) {
    __extends(MFocusTrap, _super);
    function MFocusTrap() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MFocusTrap.prototype.setFocusTrap = function (el, options) {
        var _a, _b, _c;
        if (options === void 0) { options = {}; }
        this.focusTrap = createFocusTrap(el, {
            escapeDeactivates: (_a = options === null || options === void 0 ? void 0 : options.escapeActive) !== null && _a !== void 0 ? _a : false,
            allowOutsideClick: true,
            initialFocus: (_b = options === null || options === void 0 ? void 0 : options.initialFocus) !== null && _b !== void 0 ? _b : el,
            returnFocusOnDeactivate: (_c = options === null || options === void 0 ? void 0 : options.returnFocusOnDeactivate) !== null && _c !== void 0 ? _c : true,
            preventScroll: true
        });
        this.focusTrap.activate();
    };
    MFocusTrap.prototype.removeFocusTrap = function () {
        if (!this.focusTrap) {
            return;
        }
        this.focusTrap.deactivate();
    };
    MFocusTrap.prototype.beforeDestroy = function () {
        if (!this.focusTrap) {
            return;
        }
        this.focusTrap.deactivate();
    };
    MFocusTrap = __decorate([
        Component
    ], MFocusTrap);
    return MFocusTrap;
}(ModulVue));
export { MFocusTrap };
//# sourceMappingURL=window-focus-trap.js.map