"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BindingMonitor = void 0;
var operators_1 = require("rxjs/operators");
var react_1 = require("@platform/react");
var BindingMonitor = (function () {
    function BindingMonitor(args) {
        var grid = args.grid;
        var keydown$ = grid.events$.pipe(operators_1.filter(function (e) { return e.type === 'GRID/keydown'; }), operators_1.filter(function (e) { return grid.isReady; }), operators_1.filter(function (e) { return !grid.isEditing; }), operators_1.map(function (e) { return e.payload; }));
        this.grid = grid;
        this.keydown$ = keydown$;
    }
    BindingMonitor.prototype.is = function (command, e) {
        var binding = this.grid.keyBindings.find(function (binding) { return binding.command === command; });
        return binding ? react_1.Keyboard.matchEvent(binding.key, e) : false;
    };
    BindingMonitor.prototype.monitor = function (command, handler) {
        var _this = this;
        this.keydown$.pipe(operators_1.filter(function (e) { return _this.is(command, e); })).subscribe(function (e) { return handler(e); });
    };
    return BindingMonitor;
}());
exports.BindingMonitor = BindingMonitor;
