"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var angular = require("angular");
var _ = require("lodash");
var onChangeTrigger_1 = require("./onChangeTrigger");
var trigger_1 = require("./trigger");
__export(require("./onChangeTrigger"));
__export(require("./trigger"));
exports.defaultTriggers = 'onChange';
exports.moduleName = 'rl.ui.services.autosave.triggers';
exports.factoryName = 'autosaveTriggers';
var TriggerService = (function () {
    function TriggerService($rootScope) {
        this.triggers = {
            onChange: new onChangeTrigger_1.OnChangeTrigger($rootScope),
            none: new trigger_1.Trigger('none'),
        };
    }
    TriggerService.prototype.setTriggers = function (triggerString, autosave) {
        if (triggerString == null) {
            triggerString = exports.defaultTriggers;
        }
        _.each(this.triggers, function (trigger) {
            if (trigger.hasMatch(triggerString)) {
                trigger.setTrigger(autosave);
            }
        });
    };
    return TriggerService;
}());
triggerServiceFactory.$inject = ['$rootScope'];
function triggerServiceFactory($rootScope) {
    return {
        getInstance: function () {
            return new TriggerService($rootScope);
        },
    };
}
angular.module(exports.moduleName, [])
    .factory(exports.factoryName, triggerServiceFactory);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJpZ2dlcnMuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRyaWdnZXJzLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLGlDQUFtQztBQUNuQywwQkFBNEI7QUFFNUIscURBQXNFO0FBQ3RFLHFDQUE4QztBQUU5Qyx1Q0FBa0M7QUFDbEMsK0JBQTBCO0FBRWYsUUFBQSxlQUFlLEdBQVcsVUFBVSxDQUFDO0FBRXJDLFFBQUEsVUFBVSxHQUFXLGtDQUFrQyxDQUFDO0FBQ3hELFFBQUEsV0FBVyxHQUFXLGtCQUFrQixDQUFDO0FBb0JwRDtJQUdDLHdCQUFZLFVBQXFDO1FBQ2hELElBQUksQ0FBQyxRQUFRLEd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