import { Component, HostBinding, ChangeDetectionStrategy, ViewEncapsulation, HostListener } from '@angular/core';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { UxAppShellService } from '@eui/core';
import * as i0 from "@angular/core";
import * as i1 from "@eui/core";
const _c0 = [[["eui-app-sidebar-header-user-profile"]], [["eui-app-sidebar-header"]], [["eui-app-sidebar-body"]], [["eui-app-sidebar-footer"]], [["eui-app-sidebar-drawer"]]];
const _c1 = ["eui-app-sidebar-header-user-profile", "eui-app-sidebar-header", "eui-app-sidebar-body", "eui-app-sidebar-footer", "eui-app-sidebar-drawer"];
export class EuiAppSidebarComponent {
    constructor(asService) {
        this.asService = asService;
        this.string = 'eui-app-sidebar';
        this.windowResizedSubscription = fromEvent(window, 'resize')
            .pipe(debounceTime(300))
            .subscribe((event) => {
            this._closeMobileSidebar();
        });
    }
    close() {
        if (this.asService.state.breakpoints.isMobile
            || this.asService.state.breakpoints.isTablet
            || this.asService.state.isSidebarHidden) {
            this.asService.isSidebarOpen = false;
        }
    }
    ngOnInit() {
        this.asService.activateSidebar();
        this._closeMobileSidebar();
    }
    ngOnDestroy() {
        if (this.windowResizedSubscription) {
            this.windowResizedSubscription.unsubscribe();
        }
    }
    onMouseEnter(event) {
        this.asService.isSidebarHover = true;
    }
    onMouseLeave(event) {
        this.asService.isSidebarHover = false;
    }
    _closeMobileSidebar() {
        if (this.asService.state.breakpoints.isMobile
            || this.asService.state.breakpoints.isTablet) {
            this.asService.isSidebarOpen = false;
        }
    }
}
/** @nocollapse */ EuiAppSidebarComponent.ɵfac = function EuiAppSidebarComponent_Factory(t) { return new (t || EuiAppSidebarComponent)(i0.ɵɵdirectiveInject(i1.UxAppShellService)); };
/** @nocollapse */ EuiAppSidebarComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiAppSidebarComponent, selectors: [["eui-app-sidebar"]], hostVars: 2, hostBindings: function EuiAppSidebarComponent_HostBindings(rf, ctx) { if (rf & 1) {
        i0.ɵɵlistener("click", function EuiAppSidebarComponent_click_HostBindingHandler() { return ctx.close(); }, false, i0.ɵɵresolveBody);
    } if (rf & 2) {
        i0.ɵɵclassMap(ctx.string);
    } }, ngContentSelectors: _c1, decls: 6, vars: 0, consts: [["role", "complementary", 1, "eui-app-sidebar-content", 3, "mouseenter", "mouseleave"]], template: function EuiAppSidebarComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c0);
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵlistener("mouseenter", function EuiAppSidebarComponent_Template_div_mouseenter_0_listener($event) { return ctx.onMouseEnter($event); })("mouseleave", function EuiAppSidebarComponent_Template_div_mouseleave_0_listener($event) { return ctx.onMouseLeave($event); });
        i0.ɵɵprojection(1);
        i0.ɵɵprojection(2, 1);
        i0.ɵɵprojection(3, 2);
        i0.ɵɵprojection(4, 3);
        i0.ɵɵprojection(5, 4);
        i0.ɵɵelementEnd();
    } }, styles: [".eui-app-sidebar{background-color:var(--eui-app-sidebar-bg-color);box-shadow:0 6px 6px -3px rgba(0,0,0,.2),0 10px 14px 1px rgba(0,0,0,.14),0 4px 18px 3px rgba(0,0,0,.12)!important;height:100%;left:0;position:fixed;top:calc(var(--eui-app-header-height) + var(--eui-app-toolbar-height) + var(--eui-app-top-message-height));transition:top .1s ease,width .1s ease-in,margin-left .1s ease-in-out;width:var(--eui-app-sidebar-width);z-index:var(--eui-z-index-sidebar)}.eui-app.ff.sidebar--close:not(.sidebar--hover) .eui-app-sidebar{width:calc(var(--eui-app-sidebar-width-close-active) + 16px)}.modal-open .eui-app-sidebar{z-index:auto}.eui-app-sidebar-content{border-right:1px solid var(--eui-app-sidebar-border-right-color);box-shadow:0 8px 10px 0 rgba(183,192,206,.2);display:flex;flex-direction:column;height:100%;max-height:calc(100% - var(--eui-app-header-height) - var(--eui-app-toolbar-height));overflow:hidden;position:relative}.eui-app-sidebar-header{align-items:center;background-color:var(--eui-color-grey-lightest);border-bottom:1px solid var(--eui-color-grey-lighter);display:flex;width:100%}.eui-app-sidebar-body{display:flex;height:100%;max-height:calc(100% - var(--eui-app-sidebar-header-height) - var(--eui-app-sidebar-footer-height));overflow-x:hidden;overflow-y:scroll}.eui-app-sidebar-body::-webkit-scrollbar{background-color:var(--eui-color-grey-lightest);display:inherit;height:8px;width:8px}.eui-app-sidebar-body::-webkit-scrollbar-thumb{background-color:var(--eui-color-grey-light);border-radius:5rem}.eui-app-sidebar-body::-webkit-scrollbar-thumb:hover{background-color:var(--eui-color-grey)}.eui-app-sidebar-body::-webkit-scrollbar-track{background-color:var(--eui-color-grey-lightest);border-radius:0}.eui-app-sidebar-footer{align-items:center;display:flex;flex:0 0 auto;justify-content:center;padding:var(--eui-spacing-xs)}.eui-app-sidebar-menu{display:flex;height:100%;width:100%}@media screen and (max-width:767px){.eui-app-sidebar-body{max-height:100%}.sidebar--close .eui-app-sidebar{box-shadow:none!important;margin-left:calc(var(--eui-app-sidebar-width-active)*-1)}.sidebar--open .eui-app-sidebar{display:initial;margin-left:0;width:75%}}@media screen and (min-width:768px) and (max-width:991px){.eui-app-sidebar-body{max-height:100%}.sidebar--close .eui-app-sidebar{box-shadow:none!important;margin-left:calc(var(--eui-app-sidebar-width-active)*-1)}.sidebar--open .eui-app-sidebar{display:initial;margin-left:0;width:50%}.sidebar--hidden.sidebar--open .eui-app-sidebar{box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);width:var(--eui-app-sidebar-width-active)}}@media screen and (min-width:992px){.sidebar--close:not(.sidebar--hover) .eui-app-sidebar{width:var(--eui-app-sidebar-width-close)}.sidebar--close:not(.sidebar--hover) .eui-app-sidebar-header{display:none}.sidebar--close:not(.sidebar--hover) .eui-app-sidebar-footer{text-indent:-9999px}.sidebar--hidden.sidebar--close .eui-app-sidebar{margin-left:calc(var(--eui-app-sidebar-width-active)*-1)}.sidebar--hidden.sidebar--open .eui-app-sidebar{box-shadow:0 14px 28px rgba(0,0,0,.25),0 10px 10px rgba(0,0,0,.22);display:initial;margin-left:0;width:var(--eui-app-sidebar-width-active)}}.eui-app-sidebar-drawer{display:none}.eui-app.sidebar--open.md .eui-app-sidebar-drawer,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer{background:var(--eui-color-grey-lightester);border-top:1px solid var(--eui-color-grey-lighter);display:flex;height:100%;position:fixed;top:100vh;transition:top .25s ease-in-out}.eui-app.sidebar--open.md .eui-app-sidebar-drawer-content,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer-content{height:calc(100% - 9rem);overflow-y:auto;padding:var(--eui-spacing-s);width:100%}.eui-app.sidebar--open.md .eui-app-sidebar-drawer-content::-webkit-scrollbar,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer-content::-webkit-scrollbar{background-color:var(--eui-color-grey-lightest);display:inherit;height:8px;width:8px}.eui-app.sidebar--open.md .eui-app-sidebar-drawer-content::-webkit-scrollbar-thumb,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer-content::-webkit-scrollbar-thumb{background-color:var(--eui-color-grey-light);border-radius:5rem}.eui-app.sidebar--open.md .eui-app-sidebar-drawer-content::-webkit-scrollbar-thumb:hover,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer-content::-webkit-scrollbar-thumb:hover{background-color:var(--eui-color-grey)}.eui-app.sidebar--open.md .eui-app-sidebar-drawer-content::-webkit-scrollbar-track,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer-content::-webkit-scrollbar-track{background-color:var(--eui-color-grey-lightest);border-radius:0}.eui-app.sidebar--open.md .eui-app-sidebar-drawer--expanded,.eui-app.sidebar--open.xs .eui-app-sidebar-drawer--expanded{top:9rem}.eui-app.sidebar--close.md .eui-app-sidebar-drawer,.eui-app.sidebar--close.xs .eui-app-sidebar-drawer{position:fixed;top:100vh}@media screen and (max-width:767px){.eui-app-sidebar-drawer,.eui-app-sidebar-drawer--expanded{width:75%}}@media screen and (min-width:768px) and (max-width:991px){.eui-app-sidebar-drawer,.eui-app-sidebar-drawer--expanded{width:50%}}"], encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiAppSidebarComponent, [{
        type: Component,
        args: [{
                selector: 'eui-app-sidebar',
                templateUrl: './sidebar.component.html',
                styleUrls: ['./_styles/_index.scss'],
                changeDetection: ChangeDetectionStrategy.Default,
                encapsulation: ViewEncapsulation.None,
            }]
    }], function () { return [{ type: i1.UxAppShellService }]; }, { string: [{
            type: HostBinding,
            args: ['class']
        }], close: [{
            type: HostListener,
            args: ['body:click']
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 