import { CommonModule } from '@angular/common';
import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, ContentChild, ElementRef, Output, EventEmitter } from '@angular/core';
import { MatMenuModule } from '@angular/material/menu';
import { RouterModule } from '@angular/router';
import { consumeEvent } from '@eui/core';
import { TranslateModule } from '@ngx-translate/core';
import { EuiButtonComponent } from '../eui-button';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/menu";
import * as i2 from "@angular/common";
import * as i3 from "@angular/router";
import * as i4 from "@ngx-translate/core";
function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_button_1_span_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "span", 8);
} if (rf & 2) {
    const item_r3 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵclassMapInterpolate1("eui-menu-item__category-icon eui-u-color-", item_r3 == null ? null : item_r3.iconTypeClass, " eui-icon");
    i0.ɵɵproperty("ngClass", item_r3.iconClass);
    i0.ɵɵattribute("aria-label", item_r3.iconLabel);
} }
function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_button_1_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 6);
    i0.ɵɵlistener("click", function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r9); const ctx_r8 = i0.ɵɵnextContext(3); return ctx_r8.focusButtonTrigger(); })("keydown", function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_button_1_Template_button_keydown_0_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r10 = i0.ɵɵnextContext(3); return ctx_r10.onKeyDown($event); });
    i0.ɵɵtemplate(1, EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_button_1_span_1_Template, 1, 5, "span", 7);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "translate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r3 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("disabled", item_r3.disabled);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r3.iconClass);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 3, item_r3.label), " ");
} }
function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_a_2_Template(rf, ctx) { if (rf & 1) {
    const _r13 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "a", 9);
    i0.ɵɵlistener("keydown", function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_a_2_Template_a_keydown_0_listener($event) { i0.ɵɵrestoreView(_r13); const ctx_r12 = i0.ɵɵnextContext(3); return ctx_r12.onKeyDown($event); })("click", function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_a_2_Template_a_click_0_listener($event) { i0.ɵɵrestoreView(_r13); const item_r3 = i0.ɵɵnextContext().$implicit; const ctx_r14 = i0.ɵɵnextContext(2); return ctx_r14.onClick($event, item_r3); });
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "translate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r3 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵclassProp("eui-menu-item--disabled", item_r3.disabled)("eui-menu-item__link--active", item_r3.active);
    i0.ɵɵproperty("routerLink", item_r3.url ? item_r3.url : null)("routerLinkActive", item_r3.url ? "eui-menu-item__link--active" : "");
    i0.ɵɵattribute("aria-disabled", item_r3.disabled);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 8, item_r3.label), " ");
} }
function EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_button_1_Template, 4, 5, "button", 4);
    i0.ɵɵtemplate(2, EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_a_2_Template, 3, 10, "a", 5);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r3 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !item_r3.url && !item_r3.urlExternal && !item_r3.command && !item_r3.children && !item_r3.link);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", item_r3.url || item_r3.command && !item_r3.external && !item_r3.link);
} }
function EuiDropdownButtonMenuComponent_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, EuiDropdownButtonMenuComponent_ng_template_4_ng_container_0_Template, 3, 2, "ng-container", 3);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngForOf", ctx_r1.menuItems);
} }
const _c0 = [[["button"]]];
const _c1 = ["button"];
export class EuiDropdownButtonMenuComponent {
    constructor() {
        this.clicked = new EventEmitter();
    }
    onKeyDown(event) {
        if (event.key === 'Escape' || event.key === 'Enter' || event.key === 'Tab') {
            this.focusButtonTrigger();
        }
    }
    focusButtonTrigger() {
        this.buttonTrigger.nativeElement.focus();
    }
    onClick(event, item) {
        this.clicked.emit(item);
        consumeEvent(event);
    }
}
/** @nocollapse */ EuiDropdownButtonMenuComponent.ɵfac = function EuiDropdownButtonMenuComponent_Factory(t) { return new (t || EuiDropdownButtonMenuComponent)(); };
/** @nocollapse */ EuiDropdownButtonMenuComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiDropdownButtonMenuComponent, selectors: [["eui-dropdown-button-menu"]], contentQueries: function EuiDropdownButtonMenuComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
        i0.ɵɵcontentQuery(dirIndex, EuiButtonComponent, true, ElementRef);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.buttonTrigger = _t.first);
    } }, inputs: { menuItems: "menuItems" }, outputs: { clicked: "clicked" }, ngContentSelectors: _c1, decls: 5, vars: 2, consts: [[3, "matMenuTriggerFor", "matMenuTriggerData"], ["menuContent", "matMenu"], ["matMenuContent", "menuItems"], [4, "ngFor", "ngForOf"], ["mat-menu-item", "", 3, "disabled", "click", "keydown", 4, "ngIf"], ["mat-menu-item", "", "class", "eui-menu-item__link", 3, "routerLink", "eui-menu-item--disabled", "routerLinkActive", "eui-menu-item__link--active", "keydown", "click", 4, "ngIf"], ["mat-menu-item", "", 3, "disabled", "click", "keydown"], [3, "class", "ngClass", 4, "ngIf"], [3, "ngClass"], ["mat-menu-item", "", 1, "eui-menu-item__link", 3, "routerLink", "routerLinkActive", "keydown", "click"]], template: function EuiDropdownButtonMenuComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c0);
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵprojection(1);
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(2, "mat-menu", null, 1);
        i0.ɵɵtemplate(4, EuiDropdownButtonMenuComponent_ng_template_4_Template, 1, 1, "ng-template", 2);
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        const _r0 = i0.ɵɵreference(3);
        i0.ɵɵproperty("matMenuTriggerFor", _r0)("matMenuTriggerData", ctx.menuItems);
    } }, directives: [i1.MatMenuTrigger, i1._MatMenu, i1.MatMenuContent, i2.NgForOf, i2.NgIf, i1.MatMenuItem, i2.NgClass, i3.RouterLinkWithHref, i3.RouterLinkActive], pipes: [i4.TranslatePipe], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiDropdownButtonMenuComponent, [{
        type: Component,
        args: [{
                selector: 'eui-dropdown-button-menu',
                templateUrl: './eui-dropdown-button-menu.component.html',
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
            }]
    }], function () { return []; }, { menuItems: [{
            type: Input
        }], clicked: [{
            type: Output
        }], buttonTrigger: [{
            type: ContentChild,
            args: [EuiButtonComponent, { read: ElementRef }]
        }] }); })();
export class EuiDropdownButtonMenuModule {
}
/** @nocollapse */ EuiDropdownButtonMenuModule.ɵmod = i0.ɵɵdefineNgModule({ type: EuiDropdownButtonMenuModule });
/** @nocollapse */ EuiDropdownButtonMenuModule.ɵinj = i0.ɵɵdefineInjector({ factory: function EuiDropdownButtonMenuModule_Factory(t) { return new (t || EuiDropdownButtonMenuModule)(); }, imports: [[
            CommonModule,
            RouterModule,
            MatMenuModule,
            TranslateModule
        ]] });
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(EuiDropdownButtonMenuModule, { declarations: [EuiDropdownButtonMenuComponent], imports: [CommonModule,
        RouterModule,
        MatMenuModule,
        TranslateModule], exports: [EuiDropdownButtonMenuComponent] }); })();
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiDropdownButtonMenuModule, [{
        type: NgModule,
        args: [{
                imports: [
                    CommonModule,
                    RouterModule,
                    MatMenuModule,
                    TranslateModule
                ],
                declarations: [
                    EuiDropdownButtonMenuComponent,
                ],
                exports: [
                    EuiDropdownButtonMenuComponent,
                ],
            }]
    }], null, null); })();
//# sourceMappingURL=data:application/json;base64, 