import { Component, HostBinding, Input, HostListener, ChangeDetectorRef, Renderer2, Optional, ElementRef } from '@angular/core';
import { NzMenuComponent } from './nz-menu.component';
import { NzSubMenuComponent } from './nz-submenu.component';
export var PADDING_BASE = 24;
var NzMenuItemComponent = (function () {
    function NzMenuItemComponent(_renderer, cd, nzMenuComponent, nzSubMenuComponent, hostElement) {
        this._renderer = _renderer;
        this.cd = cd;
        this.nzMenuComponent = nzMenuComponent;
        this.nzSubMenuComponent = nzSubMenuComponent;
        this.hostElement = hostElement;
        this.level = 0;
        this.padding = null;
        this.isInDropDown = false;
        this.selected = false;
        this.nzDisable = false;
        this.nzMenuComponent.menuItems.push(this);
        /** store origin padding in padding */
        if (this.hostElement.nativeElement.style['padding-left']) {
            this.padding = parseInt(this.hostElement.nativeElement.style['padding-left'], 10);
        }
    }
    Object.defineProperty(NzMenuItemComponent.prototype, "nzSelected", {
        get: function () {
            return this.selected;
        },
        set: function (value) {
            this.selected = value;
            if (value) {
                this._renderer.addClass(this.hostElement.nativeElement, 'ant-menu-item-selected');
            }
            else {
                this._renderer.removeClass(this.hostElement.nativeElement, 'ant-menu-item-selected');
            }
        },
        enumerable: true,
        configurable: true
    });
    /** clear all item selected status except this */
    NzMenuItemComponent.prototype._onClickItem = function () {
        if (this.nzMenuComponent.nzClickActive && (!this.nzDisable)) {
            this.nzMenuComponent.clearAllSelected();
            this.nzSelected = true;
        }
    };
    Object.defineProperty(NzMenuItemComponent.prototype, "_isInDropDownClass", {
        /** define host class */
        get: function () {
            return this.isInDropDown;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzMenuItemComponent.prototype, "_isNotInDropDownClass", {
        get: function () {
            return !this.isInDropDown;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzMenuItemComponent.prototype, "setDropDownDisableClass", {
        get: function () {
            return this.isInDropDown && this.nzDisable;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzMenuItemComponent.prototype, "setMenuDisableClass", {
        get: function () {
            return (!this.isInDropDown) && this.nzDisable;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzMenuItemComponent.prototype, "setPaddingLeft", {
        get: function () {
            if (this.nzSubMenuComponent) {
                /** if in sub menu component */
                if (this.nzSubMenuComponent.nzMenuComponent.nzMode === 'inline') {
                    /** if host menu's mode is inline add PADDING_BASE * level padding */
                    return (this.nzSubMenuComponent.level + 1) * PADDING_BASE;
                }
                else {
                    /** return origin padding */
                    return this.padding;
                }
            }
            else if (this.nzMenuComponent.hasSubMenu && (this.nzMenuComponent.nzMode === 'inline')) {
                /** not in sub menu component but root menu's mode is inline and contains submenu return default padding*/
                return PADDING_BASE;
            }
            else {
                return this.padding;
            }
        },
        enumerable: true,
        configurable: true
    });
    NzMenuItemComponent.prototype.ngAfterViewInit = function () {
        var _this = this;
        setTimeout(function (_) {
            _this.isInDropDown = _this.nzMenuComponent.isInDropDown;
        });
    };
    return NzMenuItemComponent;
}());
export { NzMenuItemComponent };
NzMenuItemComponent.decorators = [
    { type: Component, args: [{
                selector: '[nz-menu-item]',
                template: "\n    <ng-content></ng-content>",
            },] },
];
/** @nocollapse */
NzMenuItemComponent.ctorParameters = function () { return [
    { type: Renderer2, },
    { type: ChangeDetectorRef, },
    { type: NzMenuComponent, },
    { type: NzSubMenuComponent, decorators: [{ type: Optional },] },
    { type: ElementRef, },
]; };
NzMenuItemComponent.propDecorators = {
    'nzDisable': [{ type: Input },],
    'nzSelected': [{ type: Input },],
    '_onClickItem': [{ type: HostListener, args: ['click', ['$event'],] },],
    '_isInDropDownClass': [{ type: HostBinding, args: ['class.ant-dropdown-menu-item',] },],
    '_isNotInDropDownClass': [{ type: HostBinding, args: ['class.ant-menu-item',] },],
    'setDropDownDisableClass': [{ type: HostBinding, args: ['class.ant-dropdown-menu-item-disabled',] },],
    'setMenuDisableClass': [{ type: HostBinding, args: ['class.ant-menu-item-disabled',] },],
    'setPaddingLeft': [{ type: HostBinding, args: ['style.padding-left.px',] },],
};
