import { Directive, Input, HostListener, Optional } from '@angular/core';
import { Button } from '../button/button';
import { MenuController } from './menu-controller';
import { Navbar } from '../navbar/navbar';
import { ViewController } from '../../navigation/view-controller';
export class MenuToggle {
    constructor(_menu, _viewCtrl, _button, _navbar) {
        this._menu = _menu;
        this._viewCtrl = _viewCtrl;
        this._button = _button;
        this._navbar = _navbar;
        this._isButton = !!_button;
        this._inNavbar = !!_navbar;
    }
    ngAfterContentInit() {
        if (this._isButton) {
            this._button._setClass('menutoggle', true);
        }
    }
    toggle() {
        let menu = this._menu.get(this.menuToggle);
        menu && menu.toggle();
    }
    get isHidden() {
        if (this._inNavbar && this._viewCtrl) {
            if (this._viewCtrl.isFirst()) {
                return false;
            }
            let menu = this._menu.get(this.menuToggle);
            if (menu) {
                return !menu.persistent;
            }
        }
        return false;
    }
}
MenuToggle.decorators = [
    { type: Directive, args: [{
                selector: '[menuToggle]',
                host: {
                    '[hidden]': 'isHidden'
                }
            },] },
];
MenuToggle.ctorParameters = [
    { type: MenuController, },
    { type: ViewController, decorators: [{ type: Optional },] },
    { type: Button, decorators: [{ type: Optional },] },
    { type: Navbar, decorators: [{ type: Optional },] },
];
MenuToggle.propDecorators = {
    'menuToggle': [{ type: Input },],
    'toggle': [{ type: HostListener, args: ['click',] },],
};
//# sourceMappingURL=menu-toggle.js.map