import { Component, ElementRef, Input } from '@angular/core';
import { DomPortal } from '@angular/cdk/portal';
import { BehaviorSubject } from 'rxjs';
import { EPaneType } from '../enums/pane-type.enum';
import { BsSplitPane } from '../panes/split-pane';
import { BsContentPane } from '../panes/content-pane';
import { BsDocumentHost } from '../panes/document-host-pane';
import { BsTabGroupPane } from '../panes/tab-group-pane';
import { BsFloatingPane } from '../panes/floating-pane';
import { Overlay } from '@angular/cdk/overlay';
import * as i0 from "@angular/core";
import * as i1 from "@angular/cdk/overlay";
import * as i2 from "@angular/common";
import * as i3 from "@angular/cdk/portal";
import * as i4 from "@mintplayer/ng-bootstrap/instance-of";
import * as i5 from "@mintplayer/ng-bootstrap/splitter";
import * as i6 from "@mintplayer/ng-bootstrap/tab-control";
import * as i7 from "@mintplayer/ng-bootstrap/resizable";
export class BsDockPaneRendererComponent {
    constructor(overlay, element) {
        this.overlay = overlay;
        this.paneTypes = EPaneType;
        this.BsDocumentHostType = BsDocumentHost;
        this.BsTabGroupType = BsTabGroupPane;
        this.BsSplitterType = BsSplitPane;
        this.BsContentPaneType = BsContentPane;
        this.BsFloatingPaneType = BsFloatingPane;
        //#region Layout
        this.layout$ = new BehaviorSubject(null);
        this.portal = new DomPortal(element);
    }
    get layout() {
        return this.layout$.value;
    }
    set layout(value) {
        this.layout$.next(value);
    }
    moveToOverlay() {
        if (!this.overlayRef && !this.portal.isAttached) {
            this.overlayRef = this.overlay.create({});
            this.portal.attach(this.overlayRef);
        }
    }
    disposeOverlay() {
        if (this.overlayRef) {
            this.portal.detach();
            this.overlayRef.dispose();
            this.overlayRef = undefined;
        }
    }
}
BsDockPaneRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsDockPaneRendererComponent, deps: [{ token: i1.Overlay }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
BsDockPaneRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsDockPaneRendererComponent, selector: "bs-dock-pane-renderer", inputs: { layout: "layout" }, ngImport: i0, template: "<!-- <ng-content></ng-content> -->\n<ng-container [bsInstanceof]=\"layout$ | async\">\n    <div *bsInstanceofCase=\"BsDocumentHostType; let documentHost\" data-hello>\n        <bs-dock-pane-renderer [layout]=\"documentHost\"></bs-dock-pane-renderer>\n    </div>\n    <bs-tab-control *bsInstanceofCase=\"BsTabGroupType; let tabGroup\" [allowDragDrop]=\"false\" class=\"d-flex flex-column h-100 dock-tabs\">\n        <bs-tab-page *ngFor=\"let tab of tabGroup.panes\">\n            <ng-container *bsTabPageHeader>\n                <ng-template [cdkPortalOutlet]=\"tab.dockPanel.headerPortal\"></ng-template>\n            </ng-container>\n            <bs-dock-pane-renderer [layout]=\"tab\"></bs-dock-pane-renderer>\n        </bs-tab-page>\n    </bs-tab-control>\n    <bs-splitter *bsInstanceofCase=\"BsSplitterType; let splitter\" [orientation]=\"splitter.orientation\">\n        <bs-split-panel *ngFor=\"let panel of splitter.panes\">\n            <bs-dock-pane-renderer [layout]=\"panel\"></bs-dock-pane-renderer>\n        </bs-split-panel>\n    </bs-splitter>\n    <ng-container *bsInstanceofCase=\"BsContentPaneType; let content\">\n        <ng-template [cdkPortalOutlet]=\"content.dockPanel.contentPortal\"></ng-template>\n    </ng-container>\n    <ng-container *bsInstanceofCase=\"BsFloatingPaneType; let floating\">\n        <bs-resizable *ngIf=\"floating.pane\" [positioning]=\"'absolute'\" [presetPosition]=\"{ left: floating.location?.x ?? 0, top: floating.location?.y ?? 0, width: floating.size?.width ?? 200, height: floating.size?.height ?? 100 }\">\n            <bs-dock-pane-renderer [layout]=\"floating.pane\"></bs-dock-pane-renderer>\n        </bs-resizable>\n    </ng-container>\n    <div *bsInstanceofDefault>\n        No match\n    </div>\n</ng-container>", styles: [".dock-tabs{background:#F3F3F3}:host ::ng-deep .tab-page-content{background:#FFF;min-height:100%}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "directive", type: i4.BsInstanceOfDirective, selector: "[bsInstanceof]", inputs: ["bsInstanceof"] }, { kind: "directive", type: i4.BsInstanceofCaseDirective, selector: "[bsInstanceofCase]", inputs: ["bsInstanceofCase"] }, { kind: "directive", type: i4.BsInstanceOfDefaultDirective, selector: "[bsInstanceofDefault]" }, { kind: "component", type: i5.BsSplitterComponent, selector: "bs-splitter", inputs: ["orientation"] }, { kind: "component", type: i5.BsSplitPanelComponent, selector: "bs-split-panel" }, { kind: "component", type: i6.BsTabControlComponent, selector: "bs-tab-control", inputs: ["border", "restrictDragging", "selectFirstTab", "tabsPosition", "allowDragDrop"] }, { kind: "component", type: i6.BsTabPageComponent, selector: "bs-tab-page", inputs: ["disabled"] }, { kind: "directive", type: i6.BsTabPageHeaderDirective, selector: "[bsTabPageHeader]" }, { kind: "component", type: i7.BsResizableComponent, selector: "bs-resizable", inputs: ["positioning", "presetPosition"] }, { kind: "component", type: BsDockPaneRendererComponent, selector: "bs-dock-pane-renderer", inputs: ["layout"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsDockPaneRendererComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-dock-pane-renderer', template: "<!-- <ng-content></ng-content> -->\n<ng-container [bsInstanceof]=\"layout$ | async\">\n    <div *bsInstanceofCase=\"BsDocumentHostType; let documentHost\" data-hello>\n        <bs-dock-pane-renderer [layout]=\"documentHost\"></bs-dock-pane-renderer>\n    </div>\n    <bs-tab-control *bsInstanceofCase=\"BsTabGroupType; let tabGroup\" [allowDragDrop]=\"false\" class=\"d-flex flex-column h-100 dock-tabs\">\n        <bs-tab-page *ngFor=\"let tab of tabGroup.panes\">\n            <ng-container *bsTabPageHeader>\n                <ng-template [cdkPortalOutlet]=\"tab.dockPanel.headerPortal\"></ng-template>\n            </ng-container>\n            <bs-dock-pane-renderer [layout]=\"tab\"></bs-dock-pane-renderer>\n        </bs-tab-page>\n    </bs-tab-control>\n    <bs-splitter *bsInstanceofCase=\"BsSplitterType; let splitter\" [orientation]=\"splitter.orientation\">\n        <bs-split-panel *ngFor=\"let panel of splitter.panes\">\n            <bs-dock-pane-renderer [layout]=\"panel\"></bs-dock-pane-renderer>\n        </bs-split-panel>\n    </bs-splitter>\n    <ng-container *bsInstanceofCase=\"BsContentPaneType; let content\">\n        <ng-template [cdkPortalOutlet]=\"content.dockPanel.contentPortal\"></ng-template>\n    </ng-container>\n    <ng-container *bsInstanceofCase=\"BsFloatingPaneType; let floating\">\n        <bs-resizable *ngIf=\"floating.pane\" [positioning]=\"'absolute'\" [presetPosition]=\"{ left: floating.location?.x ?? 0, top: floating.location?.y ?? 0, width: floating.size?.width ?? 200, height: floating.size?.height ?? 100 }\">\n            <bs-dock-pane-renderer [layout]=\"floating.pane\"></bs-dock-pane-renderer>\n        </bs-resizable>\n    </ng-container>\n    <div *bsInstanceofDefault>\n        No match\n    </div>\n</ng-container>", styles: [".dock-tabs{background:#F3F3F3}:host ::ng-deep .tab-page-content{background:#FFF;min-height:100%}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.Overlay }, { type: i0.ElementRef }]; }, propDecorators: { layout: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 