import { Component, ContentChildren, EventEmitter, Input, Output, QueryList } from '@angular/core';
import { AlTabComponent } from './al-tab/al-tab.component';
import * as i0 from "@angular/core";
import * as i1 from "../al-wrapper/al-wrapper.component";
import * as i2 from "@angular/common";
var _c0 = function (a0) { return [a0]; };
function AlTabsComponent_button_3_Template(rf, ctx) { if (rf & 1) {
    var _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 3);
    i0.ɵɵlistener("click", function AlTabsComponent_button_3_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); var tab_r1 = ctx.$implicit; var ctx_r2 = i0.ɵɵnextContext(); return ctx_r2.selectTab(tab_r1); });
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "titlecase");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var tab_r1 = ctx.$implicit;
    i0.ɵɵattribute("aria-selected", i0.ɵɵpureFunction1(4, _c0, tab_r1.active ? "true" : "false"));
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(2, 2, tab_r1.name), " ");
} }
var _c1 = ["*"];
var AlTabsComponent = /** @class */ (function () {
    function AlTabsComponent() {
        this.selected = '';
        this.tabSelected = new EventEmitter();
    }
    // contentChildren are set
    AlTabsComponent.prototype.ngAfterContentInit = function () {
        // get all active tabs
        var activeTabs = this.tabs.filter(function (tab) { return tab.active; });
        // if there is no active tab set, activate the first
        if (activeTabs.length === 0) {
            this.selectTab(this.tabs.first);
        }
    };
    AlTabsComponent.prototype.selectTab = function (tab) {
        this.tabs.forEach(function (tab) {
            tab.active = false;
        });
        tab.active = true;
        this.tabSelected.emit(tab.name);
    };
    /** @nocollapse */ AlTabsComponent.ɵfac = function AlTabsComponent_Factory(t) { return new (t || AlTabsComponent)(); };
    /** @nocollapse */ AlTabsComponent.ɵcmp = i0.ɵɵdefineComponent({ type: AlTabsComponent, selectors: [["al2-tabs"]], contentQueries: function AlTabsComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
            i0.ɵɵcontentQuery(dirIndex, AlTabComponent, false);
        } if (rf & 2) {
            var _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tabs = _t);
        } }, inputs: { selected: "selected" }, outputs: { tabSelected: "tabSelected" }, ngContentSelectors: _c1, decls: 5, vars: 1, consts: [[1, "ald-tabs"], ["role", "tablist", 1, "ald-tabs__list"], ["role", "tab", "class", "ald-tabs__button", 3, "click", 4, "ngFor", "ngForOf"], ["role", "tab", 1, "ald-tabs__button", 3, "click"]], template: function AlTabsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵelementStart(1, "div", 1);
            i0.ɵɵelementStart(2, "al2-wrapper");
            i0.ɵɵtemplate(3, AlTabsComponent_button_3_Template, 3, 6, "button", 2);
            i0.ɵɵelementEnd();
            i0.ɵɵelementEnd();
            i0.ɵɵelementEnd();
            i0.ɵɵprojection(4);
        } if (rf & 2) {
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngForOf", ctx.tabs);
        } }, directives: [i1.AlWrapperComponent, i2.NgForOf], pipes: [i2.TitleCasePipe], encapsulation: 2 });
    return AlTabsComponent;
}());
export { AlTabsComponent };
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(AlTabsComponent, [{
        type: Component,
        args: [{
                selector: 'al2-tabs',
                templateUrl: './al-tabs.component.html'
            }]
    }], null, { tabs: [{
            type: ContentChildren,
            args: [AlTabComponent]
        }], selected: [{
            type: Input
        }], tabSelected: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWwtdGFicy5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AYWwvbmctZ2VuZXJpYy1jb21wb25lbnRzLyIsInNvdXJjZXMiOlsibmV3LWNvbXBvbmVudHMvYWwtdGFicy9hbC10YWJzLmNvbXBvbmVudC50cyIs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