(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/keycodes'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('@angular/core'), require('ng-zorro-antd/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common'), require('@angular/forms'), require('ng-zorro-antd/button'), require('ng-zorro-antd/icon'), require('ng-zorro-antd/menu')) :
    typeof define === 'function' && define.amd ? define('ng-zorro-antd/dropdown', ['exports', '@angular/cdk/keycodes', '@angular/cdk/overlay', '@angular/cdk/portal', '@angular/core', 'ng-zorro-antd/core', 'rxjs', 'rxjs/operators', '@angular/common', '@angular/forms', 'ng-zorro-antd/button', 'ng-zorro-antd/icon', 'ng-zorro-antd/menu'], factory) :
    (global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].dropdown = {}), global.ng.cdk.keycodes, global.ng.cdk.overlay, global.ng.cdk.portal, global.ng.core, global['ng-zorro-antd'].core, global.rxjs, global.rxjs.operators, global.ng.common, global.ng.forms, global['ng-zorro-antd'].button, global['ng-zorro-antd'].icon, global['ng-zorro-antd'].menu));
}(this, (function (exports, keycodes, overlay, portal, core, core$1, rxjs, operators, common, forms, button, icon, menu) { 'use strict';

    /*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */
    /* global Reflect, Promise */

    var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };

    function __extends(d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    }

    var __assign = function() {
        __assign = Object.assign || function __assign(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };

    function __rest(s, e) {
        var t = {};
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
        if (s != null && typeof Object.getOwnPropertySymbols === "function")
            for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
                if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                    t[p[i]] = s[p[i]];
            }
        return t;
    }

    function __decorate(decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    }

    function __param(paramIndex, decorator) {
        return function (target, key) { decorator(target, key, paramIndex); }
    }

    function __metadata(metadataKey, metadataValue) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
    }

    function __awaiter(thisArg, _arguments, P, generator) {
        function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
        return new (P || (P = Promise))(function (resolve, reject) {
            function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
            function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
            function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
            step((generator = generator.apply(thisArg, _arguments || [])).next());
        });
    }

    function __generator(thisArg, body) {
        var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
        return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
        function verb(n) { return function (v) { return step([n, v]); }; }
        function step(op) {
            if (f) throw new TypeError("Generator is already executing.");
            while (_) try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0: case 1: t = op; break;
                    case 4: _.label++; return { value: op[1], done: false };
                    case 5: _.label++; y = op[1]; op = [0]; continue;
                    case 7: op = _.ops.pop(); _.trys.pop(); continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                        if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                        if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                        if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                        if (t[2]) _.ops.pop();
                        _.trys.pop(); continue;
                }
                op = body.call(thisArg, _);
            } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
            if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
        }
    }

    function __exportStar(m, exports) {
        for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
    }

    function __values(o) {
        var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
        if (m) return m.call(o);
        if (o && typeof o.length === "number") return {
            next: function () {
                if (o && i >= o.length) o = void 0;
                return { value: o && o[i++], done: !o };
            }
        };
        throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
    }

    function __read(o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m) return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
        }
        catch (error) { e = { error: error }; }
        finally {
            try {
                if (r && !r.done && (m = i["return"])) m.call(i);
            }
            finally { if (e) throw e.error; }
        }
        return ar;
    }

    function __spread() {
        for (var ar = [], i = 0; i < arguments.length; i++)
            ar = ar.concat(__read(arguments[i]));
        return ar;
    }

    function __spreadArrays() {
        for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
        for (var r = Array(s), k = 0, i = 0; i < il; i++)
            for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
                r[k] = a[j];
        return r;
    };

    function __await(v) {
        return this instanceof __await ? (this.v = v, this) : new __await(v);
    }

    function __asyncGenerator(thisArg, _arguments, generator) {
        if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
        var g = generator.apply(thisArg, _arguments || []), i, q = [];
        return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
        function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
        function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
        function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
        function fulfill(value) { resume("next", value); }
        function reject(value) { resume("throw", value); }
        function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
    }

    function __asyncDelegator(o) {
        var i, p;
        return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
        function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
    }

    function __asyncValues(o) {
        if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
        var m = o[Symbol.asyncIterator], i;
        return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
        function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
        function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
    }

    function __makeTemplateObject(cooked, raw) {
        if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
        return cooked;
    };

    function __importStar(mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
        result.default = mod;
        return result;
    }

    function __importDefault(mod) {
        return (mod && mod.__esModule) ? mod : { default: mod };
    }

    function __classPrivateFieldGet(receiver, privateMap) {
        if (!privateMap.has(receiver)) {
            throw new TypeError("attempted to get private field on non-instance");
        }
        return privateMap.get(receiver);
    }

    function __classPrivateFieldSet(receiver, privateMap, value) {
        if (!privateMap.has(receiver)) {
            throw new TypeError("attempted to set private field on non-instance");
        }
        privateMap.set(receiver, value);
        return value;
    }

    var listOfPositions = [core$1.POSITION_MAP.bottomLeft, core$1.POSITION_MAP.bottomRight, core$1.POSITION_MAP.topRight, core$1.POSITION_MAP.topLeft];
    var NzDropDownDirective = /** @class */ (function () {
        function NzDropDownDirective(elementRef, overlay, viewContainerRef) {
            this.elementRef = elementRef;
            this.overlay = overlay;
            this.viewContainerRef = viewContainerRef;
            this.overlayRef = null;
            this.destroy$ = new rxjs.Subject();
            this.positionStrategy = this.overlay
                .position()
                .flexibleConnectedTo(this.elementRef.nativeElement)
                .withLockedPosition();
            this.inputVisible$ = new rxjs.BehaviorSubject(false);
            this.nzTrigger$ = new rxjs.BehaviorSubject('hover');
            this.overlayClose$ = new rxjs.Subject();
            this.nzDropdownMenu = null;
            this.nzTrigger = 'hover';
            this.nzMatchWidthElement = null;
            this.nzBackdrop = true;
            this.nzClickHide = true;
            this.nzDisabled = false;
            this.nzVisible = false;
            this.nzOverlayClassName = null;
            this.nzOverlayStyle = {};
            this.nzPlacement = 'bottomLeft';
            this.nzVisibleChange = new core.EventEmitter();
        }
        NzDropDownDirective.prototype.setDropdownMenuValue = function (key, value) {
            if (this.nzDropdownMenu) {
                this.nzDropdownMenu.setValue(key, value);
            }
        };
        NzDropDownDirective.prototype.ngOnInit = function () {
            var _this = this;
            this.positionStrategy.positionChanges.pipe(operators.takeUntil(this.destroy$)).subscribe(function (change) {
                _this.setDropdownMenuValue('dropDownPosition', change.connectionPair.originY);
            });
        };
        NzDropDownDirective.prototype.ngAfterViewInit = function () {
            var _this = this;
            if (this.nzDropdownMenu) {
                var nativeElement_1 = this.elementRef.nativeElement;
                /** host mouse state **/
                var hostMouseState$ = rxjs.merge(rxjs.fromEvent(nativeElement_1, 'mouseenter').pipe(operators.mapTo(true)), rxjs.fromEvent(nativeElement_1, 'mouseleave').pipe(operators.mapTo(false)));
                /** menu mouse state **/
                var menuMouseState$ = this.nzDropdownMenu.mouseState$;
                /** merged mouse state **/
                var mergedMouseState$_1 = rxjs.merge(menuMouseState$, hostMouseState$);
                /** host click state **/
                var hostClickState$_1 = rxjs.fromEvent(nativeElement_1, 'click').pipe(operators.mapTo(true));
                /** visible state switch by nzTrigger **/
                var visibleStateByTrigger$ = this.nzTrigger$.pipe(operators.switchMap(function (trigger) {
                    if (trigger === 'hover') {
                        return mergedMouseState$_1;
                    }
                    else if (trigger === 'click') {
                        return hostClickState$_1;
                    }
                    else {
                        return rxjs.EMPTY;
                    }
                }));
                var descendantMenuItemClick$ = this.nzDropdownMenu.descendantMenuItemClick$.pipe(operators.filter(function () { return _this.nzClickHide; }), operators.mapTo(false));
                var domTriggerVisible$ = rxjs.merge(visibleStateByTrigger$, descendantMenuItemClick$, this.overlayClose$).pipe(operators.filter(function () { return !_this.nzDisabled; }));
                var visible$ = rxjs.merge(this.inputVisible$, domTriggerVisible$);
                rxjs.combineLatest([visible$, this.nzDropdownMenu.isChildSubMenuOpen$])
                    .pipe(operators.map(function (_a) {
                    var _b = __read(_a, 2), visible = _b[0], sub = _b[1];
                    return visible || sub;
                }), operators.auditTime(150), operators.distinctUntilChanged(), operators.takeUntil(this.destroy$))
                    .subscribe(function (visible) {
                    var element = _this.nzMatchWidthElement ? _this.nzMatchWidthElement.nativeElement : nativeElement_1;
                    var triggerWidth = element.getBoundingClientRect().width;
                    if (_this.nzVisible !== visible) {
                        _this.nzVisibleChange.emit(visible);
                    }
                    _this.nzVisible = visible;
                    if (visible) {
                        /** set up overlayRef **/
                        if (!_this.overlayRef) {
                            /** new overlay **/
                            _this.overlayRef = _this.overlay.create({
                                positionStrategy: _this.positionStrategy,
                                minWidth: triggerWidth,
                                disposeOnNavigation: true,
                                hasBackdrop: _this.nzTrigger === 'click',
                                backdropClass: _this.nzBackdrop ? undefined : 'nz-overlay-transparent-backdrop',
                                scrollStrategy: _this.overlay.scrollStrategies.reposition()
                            });
                            rxjs.merge(_this.overlayRef.backdropClick(), _this.overlayRef.detachments(), _this.overlayRef.keydownEvents().pipe(operators.filter(function (e) { return e.keyCode === keycodes.ESCAPE && !keycodes.hasModifierKey(e); })))
                                .pipe(operators.mapTo(false), operators.takeUntil(_this.destroy$))
                                .subscribe(_this.overlayClose$);
                        }
                        else {
                            /** update overlay config **/
                            var overlayConfig = _this.overlayRef.getConfig();
                            overlayConfig.minWidth = triggerWidth;
                            overlayConfig.hasBackdrop = _this.nzTrigger === 'click';
                        }
                        /** open dropdown with animation **/
                        _this.positionStrategy.withPositions(__spread([core$1.POSITION_MAP[_this.nzPlacement]], listOfPositions));
                        /** reset portal if needed **/
                        if (!_this.portal || _this.portal.templateRef !== _this.nzDropdownMenu.templateRef) {
                            _this.portal = new portal.TemplatePortal(_this.nzDropdownMenu.templateRef, _this.viewContainerRef);
                        }
                        _this.overlayRef.attach(_this.portal);
                    }
                    else {
                        /** detach overlayRef if needed **/
                        if (_this.overlayRef) {
                            _this.overlayRef.detach();
                        }
                    }
                });
            }
        };
        NzDropDownDirective.prototype.ngOnDestroy = function () {
            this.destroy$.next();
            this.destroy$.complete();
            if (this.overlayRef) {
                this.overlayRef.dispose();
                this.overlayRef = null;
            }
        };
        NzDropDownDirective.prototype.ngOnChanges = function (changes) {
            var nzVisible = changes.nzVisible, nzPlacement = changes.nzPlacement, nzDisabled = changes.nzDisabled, nzOverlayClassName = changes.nzOverlayClassName, nzOverlayStyle = changes.nzOverlayStyle, nzTrigger = changes.nzTrigger;
            if (nzTrigger) {
                this.nzTrigger$.next(this.nzTrigger);
            }
            if (nzVisible) {
                this.inputVisible$.next(this.nzVisible);
            }
            if (nzDisabled && this.nzDisabled) {
                this.inputVisible$.next(false);
            }
            if (nzOverlayClassName) {
                this.setDropdownMenuValue('nzOverlayClassName', this.nzOverlayClassName);
            }
            if (nzOverlayStyle) {
                this.setDropdownMenuValue('nzOverlayStyle', this.nzOverlayStyle);
            }
            if (nzPlacement) {
                this.setDropdownMenuValue('dropDownPosition', this.nzPlacement.indexOf('top') !== -1 ? 'top' : 'bottom');
            }
        };
        /** @nocollapse */ NzDropDownDirective.ɵfac = function NzDropDownDirective_Factory(t) { return new (t || NzDropDownDirective)(core["ɵɵdirectiveInject"](core.ElementRef), core["ɵɵdirectiveInject"](overlay.Overlay), core["ɵɵdirectiveInject"](core.ViewContainerRef)); };
        /** @nocollapse */ NzDropDownDirective.ɵdir = core["ɵɵdefineDirective"]({ type: NzDropDownDirective, selectors: [["", "nz-dropdown", ""]], hostVars: 3, hostBindings: function NzDropDownDirective_HostBindings(rf, ctx) { if (rf & 2) {
                core["ɵɵattribute"]("disabled", ctx.nzDisabled ? "" : null);
                core["ɵɵclassProp"]("ant-dropdown-trigger", true);
            } }, inputs: { nzDropdownMenu: "nzDropdownMenu", nzTrigger: "nzTrigger", nzMatchWidthElement: "nzMatchWidthElement", nzBackdrop: "nzBackdrop", nzClickHide: "nzClickHide", nzDisabled: "nzDisabled", nzVisible: "nzVisible", nzOverlayClassName: "nzOverlayClassName", nzOverlayStyle: "nzOverlayStyle", nzPlacement: "nzPlacement" }, outputs: { nzVisibleChange: "nzVisibleChange" }, exportAs: ["nzDropdown"], features: [core["ɵɵNgOnChangesFeature"]] });
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzDropDownDirective.prototype, "nzBackdrop", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzDropDownDirective.prototype, "nzClickHide", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzDropDownDirective.prototype, "nzDisabled", void 0);
        __decorate([
            core$1.InputBoolean(),
            __metadata("design:type", Object)
        ], NzDropDownDirective.prototype, "nzVisible", void 0);
        return NzDropDownDirective;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzDropDownDirective, [{
            type: core.Directive,
            args: [{
                    selector: '[nz-dropdown]',
                    exportAs: 'nzDropdown',
                    host: {
                        '[attr.disabled]': "nzDisabled ? '' : null",
                        '[class.ant-dropdown-trigger]': 'true'
                    }
                }]
        }], function () { return [{ type: core.ElementRef }, { type: overlay.Overlay }, { type: core.ViewContainerRef }]; }, { nzDropdownMenu: [{
                type: core.Input
            }], nzTrigger: [{
                type: core.Input
            }], nzMatchWidthElement: [{
                type: core.Input
            }], nzBackdrop: [{
                type: core.Input
            }], nzClickHide: [{
                type: core.Input
            }], nzDisabled: [{
                type: core.Input
            }], nzVisible: [{
                type: core.Input
            }], nzOverlayClassName: [{
                type: core.Input
            }], nzOverlayStyle: [{
                type: core.Input
            }], nzPlacement: [{
                type: core.Input
            }], nzVisibleChange: [{
                type: core.Output
            }] }); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    var NzContextMenuServiceModule = /** @class */ (function () {
        function NzContextMenuServiceModule() {
        }
        /** @nocollapse */ NzContextMenuServiceModule.ɵmod = core["ɵɵdefineNgModule"]({ type: NzContextMenuServiceModule });
        /** @nocollapse */ NzContextMenuServiceModule.ɵinj = core["ɵɵdefineInjector"]({ factory: function NzContextMenuServiceModule_Factory(t) { return new (t || NzContextMenuServiceModule)(); } });
        return NzContextMenuServiceModule;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzContextMenuServiceModule, [{
            type: core.NgModule
        }], null, null); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    var NzDropDownADirective = /** @class */ (function () {
        function NzDropDownADirective() {
        }
        /** @nocollapse */ NzDropDownADirective.ɵfac = function NzDropDownADirective_Factory(t) { return new (t || NzDropDownADirective)(); };
        /** @nocollapse */ NzDropDownADirective.ɵdir = core["ɵɵdefineDirective"]({ type: NzDropDownADirective, selectors: [["a", "nz-dropdown", ""]], hostVars: 2, hostBindings: function NzDropDownADirective_HostBindings(rf, ctx) { if (rf & 2) {
                core["ɵɵclassProp"]("ant-dropdown-link", true);
            } } });
        return NzDropDownADirective;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzDropDownADirective, [{
            type: core.Directive,
            args: [{
                    selector: 'a[nz-dropdown]',
                    host: {
                        '[class.ant-dropdown-link]': 'true'
                    }
                }]
        }], null, null); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    var NzDropdownButtonDirective = /** @class */ (function () {
        function NzDropdownButtonDirective(renderer, nzButtonGroupComponent, elementRef) {
            this.renderer = renderer;
            this.nzButtonGroupComponent = nzButtonGroupComponent;
            this.elementRef = elementRef;
        }
        NzDropdownButtonDirective.prototype.ngAfterViewInit = function () {
            var parentElement = this.renderer.parentNode(this.elementRef.nativeElement);
            if (this.nzButtonGroupComponent && parentElement) {
                this.renderer.addClass(parentElement, 'ant-dropdown-button');
            }
        };
        /** @nocollapse */ NzDropdownButtonDirective.ɵfac = function NzDropdownButtonDirective_Factory(t) { return new (t || NzDropdownButtonDirective)(core["ɵɵdirectiveInject"](core.Renderer2), core["ɵɵdirectiveInject"](button.NzButtonGroupComponent, 9), core["ɵɵdirectiveInject"](core.ElementRef)); };
        /** @nocollapse */ NzDropdownButtonDirective.ɵdir = core["ɵɵdefineDirective"]({ type: NzDropdownButtonDirective, selectors: [["", "nz-button", "", "nz-dropdown", ""]] });
        return NzDropdownButtonDirective;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzDropdownButtonDirective, [{
            type: core.Directive,
            args: [{
                    selector: '[nz-button][nz-dropdown]'
                }]
        }], function () { return [{ type: core.Renderer2 }, { type: button.NzButtonGroupComponent, decorators: [{
                    type: core.Host
                }, {
                    type: core.Optional
                }] }, { type: core.ElementRef }]; }, null); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    function NzDropdownMenuComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
        var _r1142 = core["ɵɵgetCurrentView"]();
        core["ɵɵelementStart"](0, "div", 0);
        core["ɵɵlistener"]("mouseenter", function NzDropdownMenuComponent_ng_template_0_Template_div_mouseenter_0_listener() { core["ɵɵrestoreView"](_r1142); var ctx_r1141 = core["ɵɵnextContext"](); return ctx_r1141.setMouseState(true); })("mouseleave", function NzDropdownMenuComponent_ng_template_0_Template_div_mouseleave_0_listener() { core["ɵɵrestoreView"](_r1142); var ctx_r1143 = core["ɵɵnextContext"](); return ctx_r1143.setMouseState(false); });
        core["ɵɵprojection"](1);
        core["ɵɵelementEnd"]();
    } if (rf & 2) {
        var ctx_r1140 = core["ɵɵnextContext"]();
        core["ɵɵclassMap"](ctx_r1140.nzOverlayClassName);
        core["ɵɵproperty"]("ngStyle", ctx_r1140.nzOverlayStyle)("@slideMotion", ctx_r1140.dropDownPosition)("@.disabled", ctx_r1140.noAnimation == null ? null : ctx_r1140.noAnimation.nzNoAnimation)("nzNoAnimation", ctx_r1140.noAnimation == null ? null : ctx_r1140.noAnimation.nzNoAnimation);
    } }
    var _c0 = ["*"];
    var NzDropdownMenuComponent = /** @class */ (function () {
        function NzDropdownMenuComponent(cdr, elementRef, renderer, viewContainerRef, nzMenuService, noAnimation) {
            this.cdr = cdr;
            this.elementRef = elementRef;
            this.renderer = renderer;
            this.viewContainerRef = viewContainerRef;
            this.nzMenuService = nzMenuService;
            this.noAnimation = noAnimation;
            this.dropDownPosition = 'bottom';
            this.mouseState$ = new rxjs.BehaviorSubject(false);
            this.isChildSubMenuOpen$ = this.nzMenuService.isChildSubMenuOpen$;
            this.descendantMenuItemClick$ = this.nzMenuService.descendantMenuItemClick$;
            this.nzOverlayClassName = null;
            this.nzOverlayStyle = {};
        }
        NzDropdownMenuComponent.prototype.setMouseState = function (visible) {
            this.mouseState$.next(visible);
        };
        NzDropdownMenuComponent.prototype.setValue = function (key, value) {
            this[key] = value;
            this.cdr.markForCheck();
        };
        NzDropdownMenuComponent.prototype.ngAfterContentInit = function () {
            this.renderer.removeChild(this.renderer.parentNode(this.elementRef.nativeElement), this.elementRef.nativeElement);
        };
        /** @nocollapse */ NzDropdownMenuComponent.ɵfac = function NzDropdownMenuComponent_Factory(t) { return new (t || NzDropdownMenuComponent)(core["ɵɵdirectiveInject"](core.ChangeDetectorRef), core["ɵɵdirectiveInject"](core.ElementRef), core["ɵɵdirectiveInject"](core.Renderer2), core["ɵɵdirectiveInject"](core.ViewContainerRef), core["ɵɵdirectiveInject"](menu.MenuService), core["ɵɵdirectiveInject"](core$1.NzNoAnimationDirective, 9)); };
        /** @nocollapse */ NzDropdownMenuComponent.ɵcmp = core["ɵɵdefineComponent"]({ type: NzDropdownMenuComponent, selectors: [["nz-dropdown-menu"]], viewQuery: function NzDropdownMenuComponent_Query(rf, ctx) { if (rf & 1) {
                core["ɵɵstaticViewQuery"](core.TemplateRef, true);
            } if (rf & 2) {
                var _t;
                core["ɵɵqueryRefresh"](_t = core["ɵɵloadQuery"]()) && (ctx.templateRef = _t.first);
            } }, exportAs: ["nzDropdownMenu"], features: [core["ɵɵProvidersFeature"]([
                    menu.MenuService,
                    /** menu is inside dropdown-menu component **/
                    {
                        provide: menu.NzIsMenuInsideDropDownToken,
                        useValue: true
                    }
                ])], ngContentSelectors: _c0, decls: 1, vars: 0, consts: [[1, "ant-dropdown", 3, "ngStyle", "nzNoAnimation", "mouseenter", "mouseleave"]], template: function NzDropdownMenuComponent_Template(rf, ctx) { if (rf & 1) {
                core["ɵɵprojectionDef"]();
                core["ɵɵtemplate"](0, NzDropdownMenuComponent_ng_template_0_Template, 2, 6, "ng-template");
            } }, directives: [common.NgStyle, core$1.NzNoAnimationDirective], encapsulation: 2, data: { animation: [core$1.slideMotion] }, changeDetection: 0 });
        return NzDropdownMenuComponent;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzDropdownMenuComponent, [{
            type: core.Component,
            args: [{
                    selector: "nz-dropdown-menu",
                    exportAs: "nzDropdownMenu",
                    animations: [core$1.slideMotion],
                    providers: [
                        menu.MenuService,
                        /** menu is inside dropdown-menu component **/
                        {
                            provide: menu.NzIsMenuInsideDropDownToken,
                            useValue: true
                        }
                    ],
                    template: "\n    <ng-template>\n      <div\n        class=\"ant-dropdown\"\n        [class]=\"nzOverlayClassName\"\n        [ngStyle]=\"nzOverlayStyle\"\n        [@slideMotion]=\"dropDownPosition\"\n        [@.disabled]=\"noAnimation?.nzNoAnimation\"\n        [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n        (mouseenter)=\"setMouseState(true)\"\n        (mouseleave)=\"setMouseState(false)\"\n      >\n        <ng-content></ng-content>\n      </div>\n    </ng-template>\n  ",
                    preserveWhitespaces: false,
                    encapsulation: core.ViewEncapsulation.None,
                    changeDetection: core.ChangeDetectionStrategy.OnPush
                }]
        }], function () { return [{ type: core.ChangeDetectorRef }, { type: core.ElementRef }, { type: core.Renderer2 }, { type: core.ViewContainerRef }, { type: menu.MenuService }, { type: core$1.NzNoAnimationDirective, decorators: [{
                    type: core.Host
                }, {
                    type: core.Optional
                }] }]; }, { templateRef: [{
                type: core.ViewChild,
                args: [core.TemplateRef, { static: true }]
            }] }); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    var NzDropDownModule = /** @class */ (function () {
        function NzDropDownModule() {
        }
        /** @nocollapse */ NzDropDownModule.ɵmod = core["ɵɵdefineNgModule"]({ type: NzDropDownModule });
        /** @nocollapse */ NzDropDownModule.ɵinj = core["ɵɵdefineInjector"]({ factory: function NzDropDownModule_Factory(t) { return new (t || NzDropDownModule)(); }, imports: [[
                    common.CommonModule,
                    overlay.OverlayModule,
                    forms.FormsModule,
                    button.NzButtonModule,
                    menu.NzMenuModule,
                    icon.NzIconModule,
                    core$1.NzNoAnimationModule,
                    core$1.NzOverlayModule,
                    NzContextMenuServiceModule,
                    core$1.NzOutletModule
                ],
                menu.NzMenuModule] });
        return NzDropDownModule;
    }());
    (function () { (typeof ngJitMode === "undefined" || ngJitMode) && core["ɵɵsetNgModuleScope"](NzDropDownModule, { declarations: [NzDropDownDirective, NzDropDownADirective, NzDropdownMenuComponent, NzDropdownButtonDirective], imports: [common.CommonModule,
            overlay.OverlayModule,
            forms.FormsModule,
            button.NzButtonModule,
            menu.NzMenuModule,
            icon.NzIconModule,
            core$1.NzNoAnimationModule,
            core$1.NzOverlayModule,
            NzContextMenuServiceModule,
            core$1.NzOutletModule], exports: [menu.NzMenuModule, NzDropDownDirective, NzDropDownADirective, NzDropdownMenuComponent, NzDropdownButtonDirective] }); })();
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzDropDownModule, [{
            type: core.NgModule,
            args: [{
                    imports: [
                        common.CommonModule,
                        overlay.OverlayModule,
                        forms.FormsModule,
                        button.NzButtonModule,
                        menu.NzMenuModule,
                        icon.NzIconModule,
                        core$1.NzNoAnimationModule,
                        core$1.NzOverlayModule,
                        NzContextMenuServiceModule,
                        core$1.NzOutletModule
                    ],
                    declarations: [NzDropDownDirective, NzDropDownADirective, NzDropdownMenuComponent, NzDropdownButtonDirective],
                    exports: [menu.NzMenuModule, NzDropDownDirective, NzDropDownADirective, NzDropdownMenuComponent, NzDropdownButtonDirective]
                }]
        }], null, null); })();

    /**
     * @license
     * Copyright Alibaba.com All Rights Reserved.
     *
     * Use of this source code is governed by an MIT-style license that can be
     * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
     */
    var listOfPositions$1 = [
        new overlay.ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'top' }),
        new overlay.ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }),
        new overlay.ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'end', overlayY: 'bottom' }),
        new overlay.ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'end', overlayY: 'top' })
    ];
    var NzContextMenuService = /** @class */ (function () {
        function NzContextMenuService(overlay) {
            this.overlay = overlay;
            this.overlayRef = null;
            this.closeSubscription = rxjs.Subscription.EMPTY;
        }
        NzContextMenuService.prototype.create = function ($event, nzDropdownMenuComponent) {
            var _this = this;
            this.close(true);
            var x = $event.x, y = $event.y;
            if ($event instanceof MouseEvent) {
                $event.preventDefault();
            }
            var positionStrategy = this.overlay
                .position()
                .flexibleConnectedTo({ x: x, y: y })
                .withPositions(listOfPositions$1);
            this.overlayRef = this.overlay.create({
                positionStrategy: positionStrategy,
                scrollStrategy: this.overlay.scrollStrategies.close()
            });
            positionStrategy.positionChanges.subscribe(function (change) {
                nzDropdownMenuComponent.setValue('dropDownPosition', change.connectionPair.overlayY === 'bottom' ? 'top' : 'bottom');
            });
            this.closeSubscription = rxjs.merge(nzDropdownMenuComponent.descendantMenuItemClick$, rxjs.fromEvent(document, 'click').pipe(operators.filter(function (event) { return !!_this.overlayRef && !_this.overlayRef.overlayElement.contains(event.target); }), 
            /** handle firefox contextmenu event **/
            operators.filter(function (event) { return event.button !== 2; }), operators.take(1))).subscribe(function () {
                _this.close();
            });
            this.overlayRef.attach(new portal.TemplatePortal(nzDropdownMenuComponent.templateRef, nzDropdownMenuComponent.viewContainerRef));
        };
        NzContextMenuService.prototype.close = function (clear) {
            if (clear === void 0) { clear = false; }
            if (this.overlayRef) {
                this.overlayRef.detach();
                if (clear) {
                    this.overlayRef.dispose();
                }
                this.overlayRef = null;
                this.closeSubscription.unsubscribe();
            }
        };
        /** @nocollapse */ NzContextMenuService.ɵfac = function NzContextMenuService_Factory(t) { return new (t || NzContextMenuService)(core["ɵɵinject"](overlay.Overlay)); };
        /** @nocollapse */ NzContextMenuService.ɵprov = core["ɵɵdefineInjectable"]({ token: NzContextMenuService, factory: NzContextMenuService.ɵfac, providedIn: NzContextMenuServiceModule });
        return NzContextMenuService;
    }());
    /*@__PURE__*/ (function () { core["ɵsetClassMetadata"](NzContextMenuService, [{
            type: core.Injectable,
            args: [{
                    providedIn: NzContextMenuServiceModule
                }]
        }], function () { return [{ type: overlay.Overlay }]; }, null); })();

    exports.NzContextMenuService = NzContextMenuService;
    exports.NzContextMenuServiceModule = NzContextMenuServiceModule;
    exports.NzDropDownADirective = NzDropDownADirective;
    exports.NzDropDownDirective = NzDropDownDirective;
    exports.NzDropDownModule = NzDropDownModule;
    exports.NzDropdownButtonDirective = NzDropdownButtonDirective;
    exports.NzDropdownMenuComponent = NzDropdownMenuComponent;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=ng-zorro-antd-dropdown.umd.js.map
