var __decorate = (this && this.__decorate) || function (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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { ChangeDetectorRef, Component, ComponentFactoryResolver, HostBinding, Injector, Input, ViewChild, ViewContainerRef, } from '@angular/core';
import { ElPosition } from './overlay-position';
import { ElPortalInjector, ElPortalOutletDirective } from './mapping';
var ElPositionedContainer = /** @class */ (function () {
    function ElPositionedContainer() {
    }
    Object.defineProperty(ElPositionedContainer.prototype, "top", {
        get: function () {
            return this.position === ElPosition.TOP;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "topStart", {
        get: function () {
            return this.position === ElPosition.TOP_START;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "topEnd", {
        get: function () {
            return this.position === ElPosition.TOP_END;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "right", {
        get: function () {
            return this.position === ElPosition.RIGHT || this.position === ElPosition.END;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "endTop", {
        get: function () {
            return this.position === ElPosition.END_TOP;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "endBottom", {
        get: function () {
            return this.position === ElPosition.END_BOTTOM;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "bottom", {
        get: function () {
            return this.position === ElPosition.BOTTOM;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "bottomStart", {
        get: function () {
            return this.position === ElPosition.BOTTOM_START;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "bottomEnd", {
        get: function () {
            return this.position === ElPosition.BOTTOM_END;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "left", {
        get: function () {
            return this.position === ElPosition.LEFT || this.position === ElPosition.START;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "startTop", {
        get: function () {
            return this.position === ElPosition.START_TOP;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElPositionedContainer.prototype, "startBottom", {
        get: function () {
            return this.position === ElPosition.START_BOTTOM;
        },
        enumerable: true,
        configurable: true
    });
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], ElPositionedContainer.prototype, "position", void 0);
    __decorate([
        HostBinding('class.el-overlay-top'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "top", null);
    __decorate([
        HostBinding('class.el-overlay-top-start'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "topStart", null);
    __decorate([
        HostBinding('class.el-overlay-top-end'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "topEnd", null);
    __decorate([
        HostBinding('class.el-overlay-right'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "right", null);
    __decorate([
        HostBinding('class.el-overlay-end-top'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "endTop", null);
    __decorate([
        HostBinding('class.el-overlay-end-bottom'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "endBottom", null);
    __decorate([
        HostBinding('class.el-overlay-bottom'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "bottom", null);
    __decorate([
        HostBinding('class.el-overlay-bottom-start'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "bottomStart", null);
    __decorate([
        HostBinding('class.el-overlay-bottom-end'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "bottomEnd", null);
    __decorate([
        HostBinding('class.el-overlay-left'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "left", null);
    __decorate([
        HostBinding('class.el-overlay-start-top'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "startTop", null);
    __decorate([
        HostBinding('class.el-overlay-start-bottom'),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [])
    ], ElPositionedContainer.prototype, "startBottom", null);
    return ElPositionedContainer;
}());
export { ElPositionedContainer };
var ElOverlayContainerComponent = /** @class */ (function () {
    function ElOverlayContainerComponent(vcr, injector, changeDetectorRef) {
        this.vcr = vcr;
        this.injector = injector;
        this.changeDetectorRef = changeDetectorRef;
        this.isAttached = false;
    }
    Object.defineProperty(ElOverlayContainerComponent.prototype, "isStringContent", {
        get: function () {
            return !!this.content;
        },
        enumerable: true,
        configurable: true
    });
    ElOverlayContainerComponent.prototype.attachComponentPortal = function (portal, context) {
        portal.injector = this.createChildInjector(portal.componentFactoryResolver);
        var componentRef = this.portalOutlet.attachComponentPortal(portal);
        if (context) {
            Object.assign(componentRef.instance, context);
        }
        componentRef.changeDetectorRef.markForCheck();
        componentRef.changeDetectorRef.detectChanges();
        this.isAttached = true;
        return componentRef;
    };
    ElOverlayContainerComponent.prototype.attachTemplatePortal = function (portal) {
        var templateRef = this.portalOutlet.attachTemplatePortal(portal);
        templateRef.detectChanges();
        this.isAttached = true;
        return templateRef;
    };
    ElOverlayContainerComponent.prototype.attachStringContent = function (content) {
        this.content = content;
        this.changeDetectorRef.markForCheck();
        this.changeDetectorRef.detectChanges();
        this.isAttached = true;
    };
    ElOverlayContainerComponent.prototype.detach = function () {
        if (this.portalOutlet.hasAttached()) {
            this.portalOutlet.detach();
        }
        this.attachStringContent(null);
        this.isAttached = false;
    };
    ElOverlayContainerComponent.prototype.createChildInjector = function (cfr) {
        return new ElPortalInjector(this.injector, new WeakMap([
            [ComponentFactoryResolver, cfr],
        ]));
    };
    __decorate([
        ViewChild(ElPortalOutletDirective, { static: true }),
        __metadata("design:type", ElPortalOutletDirective)
    ], ElOverlayContainerComponent.prototype, "portalOutlet", void 0);
    ElOverlayContainerComponent = __decorate([
        Component({
            selector: 'el-overlay-container',
            template: "\n    <div *ngIf=\"isStringContent\" class=\"primitive-overlay\">{{ content }}</div>\n    <ng-template elPortalOutlet></ng-template>\n  "
        }),
        __metadata("design:paramtypes", [ViewContainerRef,
            Injector, ChangeDetectorRef])
    ], ElOverlayContainerComponent);
    return ElOverlayContainerComponent;
}());
export { ElOverlayContainerComponent };
//# sourceMappingURL=overlay-container.js.map