/**
 * @author Mohasin Nadaf <mohasin.nadaf@alertlogic.com>
 * @copyright 2020 Alert Logic, Inc.
 */
import { Component, Input, EventEmitter, Output, ViewChild } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { AlViewHelperComponent } from '../al-view-helper/al-view-helper.component';
import { Sidebar } from 'primeng-lts/sidebar';
import * as i0 from "@angular/core";
import * as i1 from "primeng-lts/sidebar";
import * as i2 from "@angular/common";
import * as i3 from "primeng-lts/button";
import * as i4 from "../al-view-helper/al-view-helper.component";
const _c0 = ["viewHelper"];
const _c1 = ["pSidebar"];
function AlSidebarComponent_div_4_Template(rf, ctx) { if (rf & 1) {
    const _r8 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 14);
    i0.ɵɵelementStart(1, "i", 15);
    i0.ɵɵlistener("click", function AlSidebarComponent_div_4_Template_i_click_1_listener() { i0.ɵɵrestoreView(_r8); const ctx_r7 = i0.ɵɵnextContext(); return ctx_r7.toggleExpand(); });
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", ctx_r1.config.expand ? "fullscreen_exit" : "fullscreen", "");
} }
function AlSidebarComponent_i_6_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "i", 16);
    i0.ɵɵlistener("click", function AlSidebarComponent_i_6_Template_i_click_0_listener() { i0.ɵɵrestoreView(_r10); const ctx_r9 = i0.ɵɵnextContext(); return ctx_r9.headerIconClicked(); });
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r2.config.header.icon == null ? null : ctx_r2.config.header.icon.name);
} }
function AlSidebarComponent_i_7_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "i", 17);
    i0.ɵɵlistener("click", function AlSidebarComponent_i_7_Template_i_click_0_listener() { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(); return ctx_r11.headerIconClicked(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵclassMap(ctx_r3.config.header.icon == null ? null : ctx_r3.config.header.icon.cssClasses);
} }
function AlSidebarComponent_i_11_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "i", 18);
    i0.ɵɵlistener("click", function AlSidebarComponent_i_11_Template_i_click_0_listener() { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(); return ctx_r13.close(); });
    i0.ɵɵtext(1, "close");
    i0.ɵɵelementEnd();
} }
function AlSidebarComponent_div_12_button_1_Template(rf, ctx) { if (rf & 1) {
    const _r19 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 23);
    i0.ɵɵlistener("click", function AlSidebarComponent_div_12_button_1_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r19); const ctx_r18 = i0.ɵɵnextContext(2); return ctx_r18.secondaryAction(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r15 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("label", ctx_r15.config.secondary.text);
    i0.ɵɵproperty("disabled", ctx_r15.config.secondary.disabled);
} }
function AlSidebarComponent_div_12_button_2_Template(rf, ctx) { if (rf & 1) {
    const _r21 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 24);
    i0.ɵɵlistener("click", function AlSidebarComponent_div_12_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r21); const ctx_r20 = i0.ɵɵnextContext(2); return ctx_r20.tertiaryAction(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r16 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("label", ctx_r16.config.ternary.text);
    i0.ɵɵproperty("disabled", ctx_r16.config.ternary.disabled);
} }
function AlSidebarComponent_div_12_button_3_Template(rf, ctx) { if (rf & 1) {
    const _r23 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 25);
    i0.ɵɵlistener("click", function AlSidebarComponent_div_12_button_3_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r23); const ctx_r22 = i0.ɵɵnextContext(2); return ctx_r22.save(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r17 = i0.ɵɵnextContext(2);
    i0.ɵɵpropertyInterpolate("label", ctx_r17.config.primary.text);
    i0.ɵɵproperty("disabled", ctx_r17.config.primary.disabled);
} }
const _c2 = function (a0) { return { "backgroundColor": a0 }; };
function AlSidebarComponent_div_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 19);
    i0.ɵɵtemplate(1, AlSidebarComponent_div_12_button_1_Template, 1, 2, "button", 20);
    i0.ɵɵtemplate(2, AlSidebarComponent_div_12_button_2_Template, 1, 2, "button", 21);
    i0.ɵɵtemplate(3, AlSidebarComponent_div_12_button_3_Template, 1, 2, "button", 22);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(4, _c2, ctx_r5.config.toolbarColor));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r5.config.secondary);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r5.config.ternary);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r5.config.primary);
} }
function AlSidebarComponent_al_view_helper_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "al-view-helper", 26, 27);
} if (rf & 2) {
    const ctx_r6 = i0.ɵɵnextContext();
    i0.ɵɵproperty("loading", ctx_r6.config.isloading)("notifyPanel", true);
} }
const _c3 = function (a0) { return { width: a0, padding: 0 }; };
const _c4 = function (a0) { return { "background-color": a0 }; };
const _c5 = ["*"];
export class AlSidebarComponent {
    constructor() {
        this.visible = false;
        this.expanded = false;
        this.hideOnClose = true;
        this.onClosed = new EventEmitter();
        this.onSaved = new EventEmitter();
        this.onToggleExpand = new EventEmitter();
        this.onHeaderIconClicked = new EventEmitter();
    }
    toggleExpand() {
        this.config.expand = !this.config.expand;
        this.onToggleExpand.emit(this.config.expand);
    }
    open() {
        this.visible = true;
    }
    hide() {
        this.visible = false;
        if (this.pSideBar.mask) {
            this.pSideBar.disableModality();
        }
    }
    close() {
        if (this.hideOnClose) {
            this.hide();
        }
        this.onClosed.emit();
    }
    headerIconClicked() {
        this.onHeaderIconClicked.emit();
    }
    secondaryAction() {
        if (this.config.secondary && this.config.secondary.callback) {
            this.config.secondary.callback();
        }
        else {
            this.close();
        }
    }
    tertiaryAction() {
        if (this.config.ternary && this.config.ternary.callback) {
            this.config.ternary.callback();
        }
        else {
            this.close();
        }
    }
    save() {
        this.onSaved.emit();
    }
    /**
     *  Emits a notification through the panel's viewhelper instance.
     */
    notify(text, type, autoDismiss = 0) {
        this.helper.notify(text, type, autoDismiss);
    }
    /**
     *  Emits an info-style notification through the panel's viewhelper instance.
     */
    notifyInfo(text, autoDismiss = 0, flush = false) {
        this.helper.notifyInfo(text, autoDismiss, flush);
    }
    /**
     *  Emits a warning notification through the panel's viewhelper instance.
     */
    notifyWarning(text, autoDismiss = 0, flush = false) {
        this.helper.notifyWarning(text, autoDismiss, flush);
    }
    /**
     *  Emits an error notification through the panel's viewhelper instance.
     */
    notifyError(text, autoDismiss = 0, flush = false) {
        this.helper.notifyError(text, autoDismiss, flush);
    }
    /**
     *  Emits an success notification through the panel's viewhelper instance.
     */
    notifySuccess(text, autoDismiss = 0, flush = false) {
        this.helper.notifySuccess(text, autoDismiss, flush);
    }
    /**
     * Clean the notifications
     */
    cleanNotifications() {
        this.helper.cleanNotifications();
    }
}
/** @nocollapse */ AlSidebarComponent.ɵfac = function AlSidebarComponent_Factory(t) { return new (t || AlSidebarComponent)(); };
/** @nocollapse */ AlSidebarComponent.ɵcmp = i0.ɵɵdefineComponent({ type: AlSidebarComponent, selectors: [["al-sidebar"]], viewQuery: function AlSidebarComponent_Query(rf, ctx) { if (rf & 1) {
        i0.ɵɵviewQuery(_c0, true);
        i0.ɵɵviewQuery(_c1, true);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.helper = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.pSideBar = _t.first);
    } }, inputs: { visible: "visible", expanded: "expanded", config: "config", hideOnClose: "hideOnClose" }, outputs: { onClosed: "onClosed", onSaved: "onSaved", onToggleExpand: "onToggleExpand", onHeaderIconClicked: "onHeaderIconClicked" }, ngContentSelectors: _c5, decls: 17, vars: 18, consts: [["position", "right", 1, "al-sidebar", 3, "visible", "showCloseIcon", "modal", "dismissible", "visibleChange"], ["pSidebar", ""], [1, "header", 3, "ngStyle"], [1, "p-grid", "p-align-center", "no-margin"], ["class", "p-col-1", 4, "ngIf"], [1, "p-col", "title"], ["class", "material-icons", 3, "click", 4, "ngIf"], [3, "class", "click", 4, "ngIf"], [1, "p-col-1", "no-pad-left"], ["class", "material-icons close-icon", 3, "click", 4, "ngIf"], ["class", "toolbar", 3, "ngStyle", 4, "ngIf"], [1, "content"], [1, "content-body"], [3, "loading", "notifyPanel", 4, "ngIf"], [1, "p-col-1"], ["fxFlexAlign", "baseline", 1, "material-icons", "expand-icon", 3, "click"], [1, "material-icons", 3, "click"], [3, "click"], [1, "material-icons", "close-icon", 3, "click"], [1, "toolbar", 3, "ngStyle"], ["type", "button", "pButton", "", "icon", "", "class", "flat ui-button-raised ui-button-rounded", 3, "label", "disabled", "click", 4, "ngIf"], ["type", "button", "pButton", "", "icon", "", "class", "ui-button-raised ui-button-rounded", 3, "label", "disabled", "click", 4, "ngIf"], ["type", "button", "pButton", "", "icon", "", "class", "primaryAction ui-button-raised ui-button-rounded", 3, "label", "disabled", "click", 4, "ngIf"], ["type", "button", "pButton", "", "icon", "", 1, "flat", "ui-button-raised", "ui-button-rounded", 3, "label", "disabled", "click"], ["type", "button", "pButton", "", "icon", "", 1, "ui-button-raised", "ui-button-rounded", 3, "label", "disabled", "click"], ["type", "button", "pButton", "", "icon", "", 1, "primaryAction", "ui-button-raised", "ui-button-rounded", 3, "label", "disabled", "click"], [3, "loading", "notifyPanel"], ["viewHelper", ""]], template: function AlSidebarComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef();
        i0.ɵɵelementStart(0, "p-sidebar", 0, 1);
        i0.ɵɵlistener("visibleChange", function AlSidebarComponent_Template_p_sidebar_visibleChange_0_listener($event) { return ctx.visible = $event; });
        i0.ɵɵelementStart(2, "div", 2);
        i0.ɵɵelementStart(3, "div", 3);
        i0.ɵɵtemplate(4, AlSidebarComponent_div_4_Template, 3, 1, "div", 4);
        i0.ɵɵelementStart(5, "div", 5);
        i0.ɵɵtemplate(6, AlSidebarComponent_i_6_Template, 2, 1, "i", 6);
        i0.ɵɵtemplate(7, AlSidebarComponent_i_7_Template, 1, 3, "i", 7);
        i0.ɵɵelementStart(8, "span");
        i0.ɵɵtext(9);
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementStart(10, "div", 8);
        i0.ɵɵtemplate(11, AlSidebarComponent_i_11_Template, 2, 0, "i", 9);
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(12, AlSidebarComponent_div_12_Template, 4, 6, "div", 10);
        i0.ɵɵelementStart(13, "div", 11);
        i0.ɵɵelementStart(14, "div", 12);
        i0.ɵɵtemplate(15, AlSidebarComponent_al_view_helper_15_Template, 2, 2, "al-view-helper", 13);
        i0.ɵɵprojection(16);
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵstyleMap(i0.ɵɵpureFunction1(14, _c3, ctx.config.expand ? "50%" : "25em"));
        i0.ɵɵproperty("visible", ctx.visible)("showCloseIcon", false)("modal", ctx.config.modal)("dismissible", "false");
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngStyle", i0.ɵɵpureFunction1(16, _c4, ctx.config.headerColor));
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.config.expandable);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.config.header.icon == null ? null : ctx.config.header.icon.name);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.config.header.icon == null ? null : ctx.config.header.icon.cssClasses);
        i0.ɵɵadvance(2);
        i0.ɵɵtextInterpolate(ctx.config.header.title);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.config.header.showClose);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.config.enableButtonToolbar);
        i0.ɵɵadvance(3);
        i0.ɵɵproperty("ngIf", ctx.config.viewHelper);
    } }, directives: [i1.Sidebar, i2.NgStyle, i2.NgIf, i3.ButtonDirective, i4.AlViewHelperComponent], styles: ["[_nghost-%COMP%]     .ui-widget-content{overflow-y:auto}.al-sidebar[_ngcontent-%COMP%]   .expand[_ngcontent-%COMP%]{width:50%}.al-sidebar[_ngcontent-%COMP%]   .no-margin[_ngcontent-%COMP%]{margin:0}.al-sidebar[_ngcontent-%COMP%]   .header[_ngcontent-%COMP%]{font-size:18px;color:#fff;min-height:50px;background-color:#57a0d7}.al-sidebar[_ngcontent-%COMP%]   .header[_ngcontent-%COMP%]   .expand-icon[_ngcontent-%COMP%]{font-size:1.2em;position:absolute;top:0;left:0;cursor:pointer}.al-sidebar[_ngcontent-%COMP%]   .header[_ngcontent-%COMP%]   .close-icon[_ngcontent-%COMP%]{font-size:1.2em;display:inline-flex;cursor:pointer}.al-sidebar[_ngcontent-%COMP%]   .header[_ngcontent-%COMP%]   .title[_ngcontent-%COMP%]{display:flex;line-height:27px;align-items:center;padding:12px}.al-sidebar[_ngcontent-%COMP%]   .header[_ngcontent-%COMP%]   .title[_ngcontent-%COMP%]   i[_ngcontent-%COMP%]{margin-right:5px}.al-sidebar[_ngcontent-%COMP%]   .ui-sidebar[_ngcontent-%COMP%]{padding:0}.al-sidebar[_ngcontent-%COMP%]   .toolbar[_ngcontent-%COMP%]{padding:5px;text-align:right;width:100%;background-color:#ededed!important}.al-sidebar[_ngcontent-%COMP%]   .toolbar[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{margin-left:5px;margin-right:5px;font-weight:400}.al-sidebar[_ngcontent-%COMP%]   .content[_ngcontent-%COMP%]{padding-top:5px;padding-bottom:5px;height:calc(100% - 97px)}.al-sidebar[_ngcontent-%COMP%]   .content[_ngcontent-%COMP%]   .content-body[_ngcontent-%COMP%]{padding:24px 24px 0;width:100%;height:100%}.al-sidebar[_ngcontent-%COMP%]   .no-pad-left[_ngcontent-%COMP%]{padding-left:0;text-align:right}.al-sidebar[_ngcontent-%COMP%]   .ui-widget-content[_ngcontent-%COMP%]   .pi[_ngcontent-%COMP%]{color:#fff}"], data: { animation: [
            trigger('panelState', [
                state('hidden', style({
                    opacity: 0
                })),
                state('visible', style({
                    opacity: 1
                })),
                transition('visible => hidden', animate('300ms ease-in')),
                transition('hidden => visible', animate('300ms ease-out'))
            ])
        ] } });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(AlSidebarComponent, [{
        type: Component,
        args: [{
                selector: 'al-sidebar',
                templateUrl: './al-sidebar.component.html',
                styleUrls: ['./al-sidebar.component.scss'],
                animations: [
                    trigger('panelState', [
                        state('hidden', style({
                            opacity: 0
                        })),
                        state('visible', style({
                            opacity: 1
                        })),
                        transition('visible => hidden', animate('300ms ease-in')),
                        transition('hidden => visible', animate('300ms ease-out'))
                    ])
                ]
            }]
    }], null, { visible: [{
            type: Input
        }], expanded: [{
            type: Input
        }], config: [{
            type: Input
        }], hideOnClose: [{
            type: Input
        }], helper: [{
            type: ViewChild,
            args: ["viewHelper", { static: false }]
        }], pSideBar: [{
            type: ViewChild,
            args: ["pSidebar", { static: false }]
        }], onClosed: [{
            type: Output
        }], onSaved: [{
            type: Output
        }], onToggleExpand: [{
            type: Output
        }], onHeaderIconClicked: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 