(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@wm/components/page'), require('@wm/components/page/left-panel'), require('@wm/core'), require('@wm/mobile/core'), require('@angular/common'), require('@wm/components/base')) :
    typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@wm/components/page', '@wm/components/page/left-panel', '@wm/core', '@wm/mobile/core', '@angular/common', '@wm/components/base'], factory) :
    (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.wm = global.wm || {}, global.wm.mobile = global.wm.mobile || {}, global.wm.mobile.components = global.wm.mobile.components || {}, global.wm.mobile.components.page = global.wm.mobile.components.page || {}, global.wm.mobile.components.page.leftpanel = {}), global.ng.core, global.wm.components.page, global.wm.components.page.leftpanel, global.wm.core, global.wm.mobile.core, global.ng.common, global.wm.components.base));
})(this, (function (exports, i0, i1, i2, core, i3, common, base) { 'use strict';

    function _interopNamespaceDefault(e) {
        var n = Object.create(null);
        if (e) {
            Object.keys(e).forEach(function (k) {
                if (k !== 'default') {
                    var d = Object.getOwnPropertyDescriptor(e, k);
                    Object.defineProperty(n, k, d.get ? d : {
                        enumerable: true,
                        get: function () { return e[k]; }
                    });
                }
            });
        }
        n.default = e;
        return Object.freeze(n);
    }

    var i0__namespace = /*#__PURE__*/_interopNamespaceDefault(i0);
    var i1__namespace = /*#__PURE__*/_interopNamespaceDefault(i1);
    var i2__namespace = /*#__PURE__*/_interopNamespaceDefault(i2);
    var i3__namespace = /*#__PURE__*/_interopNamespaceDefault(i3);

    class MobileLeftPanelDirective {
        constructor(page, leftPanelRef, deviceService, elRef) {
            this.page = page;
            this.leftPanelRef = leftPanelRef;
            this.deviceService = deviceService;
            core.addClass(elRef.nativeElement, 'wm-mobile-app-left-panel');
            page.notify('wmLeftPanel:ready', leftPanelRef);
            page.subscribe('wmLeftPanel:expand', () => {
                this._backBtnListenerDestroyer = deviceService.onBackButtonTap(() => {
                    leftPanelRef.collapse();
                    return false;
                });
            });
            page.subscribe('wmLeftPanel:collapse', () => {
                this.destroyBackBtnListener();
            });
        }
        ngOnDestroy() {
            this.destroyBackBtnListener();
        }
        destroyBackBtnListener() {
            if (this._backBtnListenerDestroyer) {
                this._backBtnListenerDestroyer();
                this._backBtnListenerDestroyer = null;
            }
        }
        static { this.ɵfac = function MobileLeftPanelDirective_Factory(t) { return new (t || MobileLeftPanelDirective)(i0__namespace.ɵɵdirectiveInject(i1__namespace.PageDirective), i0__namespace.ɵɵdirectiveInject(i2__namespace.LeftPanelDirective), i0__namespace.ɵɵdirectiveInject(i3__namespace.DeviceService), i0__namespace.ɵɵdirectiveInject(i0__namespace.ElementRef)); }; }
        static { this.ɵdir = /*@__PURE__*/ i0__namespace.ɵɵdefineDirective({ type: MobileLeftPanelDirective, selectors: [["", "wmLeftPanel", ""]] }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(MobileLeftPanelDirective, [{
            type: i0.Directive,
            args: [{
                    selector: '[wmLeftPanel]'
                }]
        }], () => [{ type: i1__namespace.PageDirective }, { type: i2__namespace.LeftPanelDirective }, { type: i3__namespace.DeviceService }, { type: i0__namespace.ElementRef }], null); })();

    const components = [
        MobileLeftPanelDirective
    ];
    class LeftPanelModule {
        static { this.ɵfac = function LeftPanelModule_Factory(t) { return new (t || LeftPanelModule)(); }; }
        static { this.ɵmod = /*@__PURE__*/ i0__namespace.ɵɵdefineNgModule({ type: LeftPanelModule }); }
        static { this.ɵinj = /*@__PURE__*/ i0__namespace.ɵɵdefineInjector({ imports: [common.CommonModule,
                base.WmComponentsModule] }); }
    }
    (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0__namespace.ɵsetClassMetadata(LeftPanelModule, [{
            type: i0.NgModule,
            args: [{
                    imports: [
                        common.CommonModule,
                        base.WmComponentsModule
                    ],
                    declarations: [...components],
                    exports: [...components]
                }]
        }], null, null); })();
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0__namespace.ɵɵsetNgModuleScope(LeftPanelModule, { declarations: [MobileLeftPanelDirective], imports: [common.CommonModule,
            base.WmComponentsModule], exports: [MobileLeftPanelDirective] }); })();

    exports.LeftPanelModule = LeftPanelModule;
    exports.MobileLeftPanelDirective = MobileLeftPanelDirective;

}));
