var __values = (this && this.__values) || function(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.");
};
var DIV_ELEMENT = "div";
var OverlayViewHost = /** @class */ (function () {
    function OverlayViewHost(document) {
        this.document = document;
    }
    OverlayViewHost.prototype.createElement = function (elementClassNames) {
        var e_1, _a;
        this.element = this.document.createElement(DIV_ELEMENT);
        if (elementClassNames.length) {
            try {
                for (var elementClassNames_1 = __values(elementClassNames), elementClassNames_1_1 = elementClassNames_1.next(); !elementClassNames_1_1.done; elementClassNames_1_1 = elementClassNames_1.next()) {
                    var className = elementClassNames_1_1.value;
                    this.addClass(className);
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (elementClassNames_1_1 && !elementClassNames_1_1.done && (_a = elementClassNames_1.return)) _a.call(elementClassNames_1);
                }
                finally { if (e_1) throw e_1.error; }
            }
        }
        this.element.style.left = "0px";
        this.element.style.top = "0px";
        this.appendToBody();
    };
    OverlayViewHost.prototype.appendChild = function (htmlElement) {
        this.element.appendChild(htmlElement);
    };
    OverlayViewHost.prototype.show = function () {
        this.setStyle({ 'display': '' });
    };
    OverlayViewHost.prototype.hide = function () {
        this.setStyle({ 'display': 'none' });
    };
    OverlayViewHost.prototype.addClass = function (className) {
        this.element.classList.add(className);
    };
    OverlayViewHost.prototype.removeClass = function (className) {
        this.element.classList.remove(className);
    };
    OverlayViewHost.prototype.applyPlacement = function (calculatedOffset) {
        this.element.style.left = String(calculatedOffset.left) + "px";
        this.element.style.top = String(calculatedOffset.top) + "px";
    };
    OverlayViewHost.prototype.setStyle = function (params) {
        var e_2, _a;
        var propNames = Object.getOwnPropertyNames(params);
        try {
            for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
                var key = propNames_1_1.value;
                this.element.style[key] = params[key];
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (propNames_1_1 && !propNames_1_1.done && (_a = propNames_1.return)) _a.call(propNames_1);
            }
            finally { if (e_2) throw e_2.error; }
        }
    };
    OverlayViewHost.prototype.appendToBody = function () {
        this.document.body.appendChild(this.element);
    };
    OverlayViewHost.prototype.destroy = function () {
        this.element.parentNode.removeChild(this.element);
        this.element = undefined;
    };
    return OverlayViewHost;
}());
var OverlayPositionHost = /** @class */ (function () {
    function OverlayPositionHost() {
    }
    OverlayPositionHost.prototype.getClientRectangle = function (htmlElement) {
        var box = htmlElement.getBoundingClientRect();
        var parentNode = htmlElement.parentNode;
        var doc = parentNode.ownerDocument;
        var docElement = doc.documentElement;
        var parentBox = parentNode.getBoundingClientRect();
        var parentOffset = {
            top: box.top + window.pageYOffset - docElement.clientTop,
            left: box.left + window.pageXOffset - docElement.clientLeft,
            bottom: box.bottom, height: box.height, right: box.right, width: box.width
        };
        return parentOffset;
    };
    OverlayPositionHost.prototype.getOffset = function (htmlElement) {
        return new ElementOffsetModel(htmlElement.offsetWidth, htmlElement.offsetHeight);
    };
    OverlayPositionHost.prototype.getCalculatedOffset = function (offSetModel) {
        if (offSetModel.isCenterOverlay)
            return offSetModel.placement == 'bottom' ? { top: offSetModel.position.top + offSetModel.position.height, left: offSetModel.position.left + (offSetModel.position.width / 2) - (offSetModel.overlayElementOffset.width / 2) } :
                offSetModel.placement == 'top' ? { top: (offSetModel.position.top) - (offSetModel.overlayElementOffset.height), left: offSetModel.position.left + ((offSetModel.mainElementOffset.width - offSetModel.overlayElementOffset.width) / 2) } :
                    offSetModel.placement == 'left' ? { top: (offSetModel.position.top + (offSetModel.position.height / 2) - (offSetModel.overlayElementOffset.height / 2)), left: offSetModel.position.left - offSetModel.overlayElementOffset.width } :
                        { top: (offSetModel.position.top + (offSetModel.position.height / 2) - (offSetModel.overlayElementOffset.height / 2)), left: offSetModel.position.left + offSetModel.position.width };
        else
            return offSetModel.placement == 'bottom' ? { top: offSetModel.position.top + offSetModel.position.height + 5, left: offSetModel.position.left + 5 } :
                offSetModel.placement == 'top' ? { top: (offSetModel.position.top) - (offSetModel.overlayElementOffset.height), left: offSetModel.position.left + ((offSetModel.position.width - offSetModel.overlayElementOffset.width) / 2) } :
                    offSetModel.placement == 'left' ? { top: (offSetModel.position.top + (offSetModel.position.height / 2) - (offSetModel.overlayElementOffset.height / 2)), left: offSetModel.position.left - offSetModel.overlayElementOffset.width } :
                        { top: (offSetModel.position.top + (offSetModel.position.height / 2) - (offSetModel.overlayElementOffset.height / 2)), left: offSetModel.position.left + offSetModel.position.width };
    };
    return OverlayPositionHost;
}());
var BackDrop = /** @class */ (function () {
    function BackDrop() {
    }
    BackDrop.create = function () {
        this.overlayViewHost = new OverlayViewHost(document);
        this.overlayViewHost.createElement(["modal-backdrop", "fade", "in", "show"]);
    };
    BackDrop.createValidation = function () {
        this.validationOverlayViewHost = new OverlayViewHost(document);
        this.validationOverlayViewHost.createElement(["modal-backdrop-validation", "fade", "in", "show"]);
    };
    BackDrop.isBackdrop = function () {
        return this.overlayViewHost && this.overlayViewHost.element !== undefined;
    };
    BackDrop.removeValidation = function () {
        this.validationOverlayViewHost.destroy();
        this.validationOverlayViewHost = undefined;
    };
    BackDrop.remove = function () {
        this.overlayViewHost.destroy();
        this.overlayViewHost = undefined;
    };
    BackDrop.overlayViewHost = new OverlayViewHost(document);
    BackDrop.validationOverlayViewHost = new OverlayViewHost(document);
    return BackDrop;
}());
var OffSetModel = /** @class */ (function () {
    function OffSetModel(placement, position, mainElementOffset, overlayElementOffset, isCenterOverlay) {
        if (isCenterOverlay === void 0) { isCenterOverlay = true; }
        this.placement = placement;
        this.position = position;
        this.mainElementOffset = mainElementOffset;
        this.overlayElementOffset = overlayElementOffset;
        this.isCenterOverlay = isCenterOverlay;
    }
    return OffSetModel;
}());
var ElementOffsetModel = /** @class */ (function () {
    function ElementOffsetModel(width, height) {
        this.width = width;
        this.height = height;
    }
    return ElementOffsetModel;
}());

var __values$1 = (this && this.__values) || function(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.");
};
var ComponentView = /** @class */ (function () {
    function ComponentView(_component, _viewContainerRef, _componentFactoryResolver) {
        this.component = _component;
        this.viewContainerRef = _viewContainerRef;
        this.componentFactoryResolver = _componentFactoryResolver;
    }
    ComponentView.prototype.create = function (params) {
        var componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.component);
        this.componentRef = this.viewContainerRef.createComponent(componentFactory, this.viewContainerRef.length, this.viewContainerRef.parentInjector);
        if (params)
            this.setParams(params);
    };
    ComponentView.prototype.setParams = function (params) {
        var e_1, _a;
        var propNames = Object.getOwnPropertyNames(params);
        try {
            for (var propNames_1 = __values$1(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
                var key = propNames_1_1.value;
                this.componentRef.instance[key] = params[key];
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (propNames_1_1 && !propNames_1_1.done && (_a = propNames_1.return)) _a.call(propNames_1);
            }
            finally { if (e_1) throw e_1.error; }
        }
    };
    ComponentView.prototype.rootNode = function () {
        return this.componentRef.hostView.rootNodes[0];
    };
    ComponentView.prototype.getComponentRef = function () {
        return this.componentRef;
    };
    ComponentView.prototype.destroy = function () {
        if (this.componentRef) {
            this.componentRef.destroy();
            this.componentRef = undefined;
        }
    };
    return ComponentView;
}());

/**
 * Generated bundle index. Do not edit.
 */

export { BackDrop, ComponentView, DIV_ELEMENT, ElementOffsetModel, OffSetModel, OverlayPositionHost, OverlayViewHost };
//# sourceMappingURL=rxweb-angular-api.js.map
