"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require("@angular/core");
var popoutList_service_1 = require("./popoutList.service");
var PopoutTriggerDirective = (function () {
    function PopoutTriggerDirective(popoutListService) {
        var _this = this;
        this.downArrow = function () { return _this.next(); };
        this.upArrow = function () { return _this.previous(); };
        this.toggle = function () { return _this.toggleList(); };
        this.onEnter = function () { return _this.select(); };
        this.popoutListService = popoutListService;
    }
    PopoutTriggerDirective.prototype.toggleList = function () {
        if (this.popoutListService.showOptions) {
            this.popoutListService.close();
        }
        else {
            this.popoutListService.open();
        }
    };
    PopoutTriggerDirective.prototype.next = function () {
        if (this.popoutListService.showOptions) {
            this.popoutListService.focusNext();
        }
    };
    PopoutTriggerDirective.prototype.previous = function () {
        if (this.popoutListService.showOptions) {
            this.popoutListService.focusPrevious();
        }
    };
    PopoutTriggerDirective.prototype.select = function () {
        if (this.popoutListService.current) {
            this.popoutListService.selectCurrent();
        }
        else {
            this.popoutListService.close();
        }
    };
    return PopoutTriggerDirective;
}());
__decorate([
    core_1.HostListener('keyup.arrowdown'),
    __metadata("design:type", Object)
], PopoutTriggerDirective.prototype, "downArrow", void 0);
__decorate([
    core_1.HostListener('keyup.arrowup'),
    __metadata("design:type", Object)
], PopoutTriggerDirective.prototype, "upArrow", void 0);
__decorate([
    core_1.HostListener('click'),
    __metadata("design:type", Object)
], PopoutTriggerDirective.prototype, "toggle", void 0);
__decorate([
    core_1.HostListener('keyup.enter'),
    __metadata("design:type", Object)
], PopoutTriggerDirective.prototype, "onEnter", void 0);
PopoutTriggerDirective = __decorate([
    core_1.Directive({
        selector: '[rlPopoutTrigger]',
    }),
    __metadata("design:paramtypes", [popoutList_service_1.PopoutListService])
], PopoutTriggerDirective);
exports.PopoutTriggerDirective = PopoutTriggerDirective;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9wb3V0VHJpZ2dlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInBvcG91dFRyaWdnZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLHNDQUF3RDtBQUV4RCwyREFBeUQ7QUFLekQsSUFBYSxzQkFBc0I7SUFRbEMsZ0NBQVksaUJBQXlDO1FBQXJELGlCQUVDO1FBVGdDLGNBQVMsR0FBRyxjQUFNLE9BQUEsS0FBSSxDQUFDLElBQUksRUFBRSxFQUFYLENBQVcsQ0FBQztRQUNoQyxZQUFPLEdBQUcsY0FBTSxPQUFBLEtBQUksQ0FBQyxRQUFRLEVBQUUsRUFBZixDQUFlLENBQUM7UUFDeEMsV0FBTSxHQUFHLGNBQU0sT0FBQSxLQUFJLENBQUMsVUFBVSxFQUFFLEVBQWpCLENBQWlCLENBQUM7UUFDM0IsWUFBTyxHQUFHLGNBQU0sT0FBQSxLQUFJLENBQUMsTUFBTSxFQUFFLEVBQWIsQ0FBYSxDQUFDO1FBSzFELElBQUksQ0FBQyxpQkFBaUIsR0FBRyxpQkFBaUIsQ0FBQztJQUM1QyxDQUFDO0lBRUQsMkNBQVUsR0FBVjtRQUNDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQ3hDLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQUNoQyxDQUFD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