// © 2022 SolarWinds Worldwide, LLC. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to
//  deal in the Software without restriction, including without limitation the
//  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
//  sell copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
import { ChangeDetectorRef, Component, ElementRef, forwardRef, Input, Optional, ViewChild, ViewEncapsulation, } from "@angular/core";
import { MenuActionType } from "../../public-api";
import { MenuGroupComponent } from "../menu-group/menu-group.component";
import { MenuItemBaseComponent } from "../menu-item/menu-item-base";
import * as i0 from "@angular/core";
import * as i1 from "../menu-group/menu-group.component";
import * as i2 from "../../../icon/icon.component";
import * as i3 from "@angular/common";
/**
 * @ignore
 */
/**
 * Menu item component which is needed to perform action on click event
 */
export class MenuActionComponent extends MenuItemBaseComponent {
    constructor(group, cd) {
        super(group, cd);
        this.group = group;
        this.disabled = false;
    }
    handleClick(event) {
        event.preventDefault();
        if (this.disabled) {
            event.stopPropagation();
        }
        else {
            this.actionDone.emit();
        }
    }
    getIconColor() {
        return this.type === "destructive" ? "red" : "";
    }
    doAction(event) {
        this.handleClick(event);
    }
}
MenuActionComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuActionComponent, deps: [{ token: i1.MenuGroupComponent, optional: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
MenuActionComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: MenuActionComponent, selector: "nui-menu-action", inputs: { icon: "icon", type: "type" }, host: { attributes: { "role": "menuitem" } }, providers: [
        {
            provide: MenuItemBaseComponent,
            useExisting: forwardRef(() => MenuActionComponent),
        },
    ], viewQueries: [{ propertyName: "menuItem", first: true, predicate: ["menuAction"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
        <a
            class="nui-menu-item__action nui-menu-item__link"
            href="#"
            role="button"
            (click)="handleClick($event)"
            [ngClass]="'nui-menu-item__action-' + type"
            #menuAction
            tabindex="-1"
        >
            <nui-icon
                *ngIf="icon"
                [icon]="icon"
                [iconColor]="getIconColor()"
            ></nui-icon>
            <ng-content></ng-content>
        </a>
    `, isInline: true, styles: [".nui-menu .nui-menu-item .nui-menu-item__action,.nui-menu-popup-host .nui-menu-item .nui-menu-item__action,.nui-menu-popup .nui-menu-item .nui-menu-item__action{color:var(--nui-color-text-link,#0079aa)}.nui-menu .nui-menu-item .nui-menu-item__action:hover,.nui-menu-popup-host .nui-menu-item .nui-menu-item__action:hover,.nui-menu-popup .nui-menu-item .nui-menu-item__action:hover{text-decoration:none}.nui-menu .nui-menu-item .nui-menu-item__action-destructive,.nui-menu-popup-host .nui-menu-item .nui-menu-item__action-destructive,.nui-menu-popup .nui-menu-item .nui-menu-item__action-destructive{color:var(--nui-color-text-critical,#dd2c00)}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action{color:var(--nui-color-off,#4d4d4d)}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action:hover,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action:hover,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action:hover{cursor:not-allowed}\n"], components: [{ type: i2.IconComponent, selector: "nui-icon", inputs: ["iconColor", "brushType", "iconHoverColor", "iconSize", "cssClass", "fillContainer", "status", "childStatus", "icon", "counter"] }], directives: [{ type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: MenuActionComponent, decorators: [{
            type: Component,
            args: [{ selector: "nui-menu-action", template: `
        <a
            class="nui-menu-item__action nui-menu-item__link"
            href="#"
            role="button"
            (click)="handleClick($event)"
            [ngClass]="'nui-menu-item__action-' + type"
            #menuAction
            tabindex="-1"
        >
            <nui-icon
                *ngIf="icon"
                [icon]="icon"
                [iconColor]="getIconColor()"
            ></nui-icon>
            <ng-content></ng-content>
        </a>
    `, providers: [
                        {
                            provide: MenuItemBaseComponent,
                            useExisting: forwardRef(() => MenuActionComponent),
                        },
                    ], encapsulation: ViewEncapsulation.None, host: { role: "menuitem" }, styles: [".nui-menu .nui-menu-item .nui-menu-item__action,.nui-menu-popup-host .nui-menu-item .nui-menu-item__action,.nui-menu-popup .nui-menu-item .nui-menu-item__action{color:var(--nui-color-text-link,#0079aa)}.nui-menu .nui-menu-item .nui-menu-item__action:hover,.nui-menu-popup-host .nui-menu-item .nui-menu-item__action:hover,.nui-menu-popup .nui-menu-item .nui-menu-item__action:hover{text-decoration:none}.nui-menu .nui-menu-item .nui-menu-item__action-destructive,.nui-menu-popup-host .nui-menu-item .nui-menu-item__action-destructive,.nui-menu-popup .nui-menu-item .nui-menu-item__action-destructive{color:var(--nui-color-text-critical,#dd2c00)}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action{color:var(--nui-color-off,#4d4d4d)}.nui-menu .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action:hover,.nui-menu-popup-host .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action:hover,.nui-menu-popup .nui-menu-item.nui-menu-item--disabled>.nui-menu-item__action:hover{cursor:not-allowed}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.MenuGroupComponent, decorators: [{
                    type: Optional
                }] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { icon: [{
                type: Input
            }], type: [{
                type: Input
            }], menuItem: [{
                type: ViewChild,
                args: ["menuAction"]
            }] } });
//# sourceMappingURL=data:application/json;base64, 