import * as i0 from '@angular/core';
import { InjectionToken, forwardRef, Input, HostBinding, ChangeDetectionStrategy, Component, ContentChildren, ViewEncapsulation, NgModule } from '@angular/core';
import { __decorate, __metadata } from 'tslib';
import { startWith } from 'rxjs/operators';
import { NgTemplateOutlet } from '@angular/common';
import { applyCssClass } from '@fundamental-ngx/cdk/utils';

const DYNAMIC_SIDE_CONTENT_CLASS_NAME = {
    container: 'fd-dynamic-side',
    containerSizeSm: 'fd-dynamic-side--sm',
    containerSizeMd: 'fd-dynamic-side--md',
    containerSizeXl: 'fd-dynamic-side--xl',
    containerSideBelow: 'fd-dynamic-side--below',
    containerSideEqual: 'fd-dynamic-side--equal-split',
    side: 'fd-dynamic-side__side',
    main: 'fd-dynamic-side__main'
};
const DYNAMIC_SIDE_CONTENT_CHILD_TOKEN = new InjectionToken('DYNAMIC_SIDE_CONTENT_CHILDREN_TOKEN');

let componentId$2 = 0;
class DynamicSideContentMainComponent {
    /** @hidden */
    constructor(_elementRef, _render) {
        this._elementRef = _elementRef;
        this._render = _render;
        /** Unique element Id, by default it's auto generated */
        this.id = 'fd-dynamic-side-content-main-id-' + componentId$2++;
    }
    /** @hidden */
    ngOnInit() {
        this._addClassName(DYNAMIC_SIDE_CONTENT_CLASS_NAME.main);
    }
    /** @hidden */
    _addClassName(className) {
        return this._render.addClass(this._elementRef.nativeElement, className);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentMainComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.0", type: DynamicSideContentMainComponent, isStandalone: true, selector: "fd-dynamic-side-content-main", inputs: { id: "id" }, host: { properties: { "attr.id": "this.id" } }, providers: [
            {
                provide: DYNAMIC_SIDE_CONTENT_CHILD_TOKEN,
                useExisting: forwardRef(() => DynamicSideContentMainComponent)
            }
        ], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentMainComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'fd-dynamic-side-content-main',
                    template: '<ng-content></ng-content>',
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    providers: [
                        {
                            provide: DYNAMIC_SIDE_CONTENT_CHILD_TOKEN,
                            useExisting: forwardRef(() => DynamicSideContentMainComponent)
                        }
                    ],
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { id: [{
                type: Input
            }, {
                type: HostBinding,
                args: ['attr.id']
            }] } });

let componentId$1 = 0;
class DynamicSideContentSideComponent {
    /** @hidden */
    constructor(_elementRef, _render) {
        this._elementRef = _elementRef;
        this._render = _render;
        /** Unique element Id, by default it's auto generated */
        this.id = 'fd-dynamic-side-content-side-id-' + componentId$1++;
    }
    /** @hidden */
    ngOnInit() {
        this._addClassName(DYNAMIC_SIDE_CONTENT_CLASS_NAME.side);
    }
    /** @hidden */
    _addClassName(className) {
        return this._render.addClass(this._elementRef.nativeElement, className);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentSideComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.0", type: DynamicSideContentSideComponent, isStandalone: true, selector: "fd-dynamic-side-content-side", inputs: { id: "id" }, host: { properties: { "attr.id": "this.id" } }, providers: [
            {
                provide: DYNAMIC_SIDE_CONTENT_CHILD_TOKEN,
                useExisting: forwardRef(() => DynamicSideContentSideComponent)
            }
        ], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentSideComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'fd-dynamic-side-content-side',
                    template: '<ng-content></ng-content>',
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    providers: [
                        {
                            provide: DYNAMIC_SIDE_CONTENT_CHILD_TOKEN,
                            useExisting: forwardRef(() => DynamicSideContentSideComponent)
                        }
                    ],
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { id: [{
                type: Input
            }, {
                type: HostBinding,
                args: ['attr.id']
            }] } });

const getSizeClassName = (size) => {
    switch (size) {
        case 'sm':
            return DYNAMIC_SIDE_CONTENT_CLASS_NAME.containerSizeSm;
        case 'md':
        case 'lg':
            return DYNAMIC_SIDE_CONTENT_CLASS_NAME.containerSizeMd;
        case 'xl':
            return DYNAMIC_SIDE_CONTENT_CLASS_NAME.containerSizeXl;
        default:
            return null;
    }
};
const getPositionClassName = (position) => {
    switch (position) {
        case 'bottom':
            return DYNAMIC_SIDE_CONTENT_CLASS_NAME.containerSideBelow;
        case 'equalSplit':
            return DYNAMIC_SIDE_CONTENT_CLASS_NAME.containerSideEqual;
        default:
            return null;
    }
};

let componentId = 0;
class DynamicSideContentComponent {
    /**
     * Side content position, can be 'left' | 'right' | 'bottom' | 'equalSplit' | 'none'.
     */
    set position(position) {
        this._position = position;
        this._calculateSidePosition();
    }
    get position() {
        return this._position;
    }
    /** @hidden */
    constructor(elementRef, _changeDetectorRef) {
        this.elementRef = elementRef;
        this._changeDetectorRef = _changeDetectorRef;
        /**
         * Screen size, can be 'sm' | 'md' | 'lg' | 'xl'.
         */
        this.size = 'xl';
        /** Unique element Id, by default it's auto generated */
        this.id = 'fd-dynamic-side-content-id-' + componentId++;
        /**
         * @hidden
         * Indicates when side content should be rendered before or after main content
         */
        this._isSideBefore = true;
        /** @hidden */
        this._isSideProjectedAsFirst = false;
        /** @hidden */
        this._position = 'none';
    }
    /** @hidden */
    buildComponentCssClass() {
        return [
            DYNAMIC_SIDE_CONTENT_CLASS_NAME.container,
            getSizeClassName(this.size),
            getPositionClassName(this.position)
        ].filter((v) => !!v);
    }
    /** @hidden */
    ngOnChanges() {
        this.buildComponentCssClass();
    }
    /** @hidden */
    ngOnInit() {
        this.buildComponentCssClass();
    }
    /** @hidden */
    ngAfterContentInit() {
        this._listenToChildrenOrder();
    }
    /** @hidden */
    _listenToChildrenOrder() {
        this._children.changes.pipe(startWith(this._children)).subscribe(() => {
            this._isSideProjectedAsFirst = this._children.first instanceof DynamicSideContentSideComponent;
            this._calculateSidePosition();
            this._changeDetectorRef.markForCheck();
        });
    }
    /** @hidden */
    _calculateSidePosition() {
        const position = this._position;
        if (position === 'none' || position === 'equalSplit' || !position) {
            this._isSideBefore = this._isSideProjectedAsFirst;
        }
        if (position === 'left') {
            this._isSideBefore = true;
        }
        if (position === 'right' || position === 'bottom') {
            this._isSideBefore = false;
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: DynamicSideContentComponent, isStandalone: true, selector: "fd-dynamic-side-content", inputs: { position: "position", size: "size", id: "id" }, host: { properties: { "attr.id": "this.id" } }, queries: [{ propertyName: "_children", predicate: DYNAMIC_SIDE_CONTENT_CHILD_TOKEN }], usesOnChanges: true, ngImport: i0, template: "@if (_isSideBefore) {\n    <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n}\n<!-- Main Content -->\n<ng-content select=\"fd-dynamic-side-content-main\"></ng-content>\n@if (!_isSideBefore) {\n    <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n}\n<ng-template #sideTemplate>\n    <!-- Side Content -->\n    <ng-content select=\"fd-dynamic-side-content-side\"></ng-content>\n</ng-template>\n", styles: [".fd-dynamic-side{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);display:-webkit-box;display:-ms-flexbox;display:flex;font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;width:100%}.fd-dynamic-side:after,.fd-dynamic-side:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-dynamic-side .fd-dynamic-side__main{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0;width:75%}.fd-dynamic-side .fd-dynamic-side__main:after,.fd-dynamic-side .fd-dynamic-side__main:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-dynamic-side .fd-dynamic-side__side{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0;-webkit-box-flex:1;-ms-flex:1 1 0px;flex:1 1 0}.fd-dynamic-side .fd-dynamic-side__side:after,.fd-dynamic-side .fd-dynamic-side__side:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-dynamic-side--sm .fd-dynamic-side__main{width:100%}.fd-dynamic-side--sm .fd-dynamic-side__side{display:none}.fd-dynamic-side--md .fd-dynamic-side__main{width:66.666%}.fd-dynamic-side--md .fd-dynamic-side__side{display:block}.fd-dynamic-side--xl .fd-dynamic-side__main{width:75%}.fd-dynamic-side--equal-split{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.fd-dynamic-side--equal-split .fd-dynamic-side__main,.fd-dynamic-side--equal-split .fd-dynamic-side__side{-webkit-box-flex:1;-ms-flex:1 1 50%;flex:1 1 50%;width:50%}.fd-dynamic-side--below{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.fd-dynamic-side--below .fd-dynamic-side__main{width:100%}.fd-dynamic-side--below .fd-dynamic-side__side{display:block;width:100%;-webkit-box-flex:0;-ms-flex:none;flex:none}\n/*! Bundled license information:\n\nfundamental-styles/dist/dynamic-side-content.css:\n  (*!\n   * Fundamental Library Styles v0.41.7\n   * Copyright (c) 2026 SAP SE or an SAP affiliate company.\n   * Licensed under Apache License 2.0 (https://github.com/SAP/fundamental-styles/blob/main/LICENSE)\n   *)\n*/\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
__decorate([
    applyCssClass,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Array)
], DynamicSideContentComponent.prototype, "buildComponentCssClass", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fd-dynamic-side-content', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [NgTemplateOutlet], template: "@if (_isSideBefore) {\n    <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n}\n<!-- Main Content -->\n<ng-content select=\"fd-dynamic-side-content-main\"></ng-content>\n@if (!_isSideBefore) {\n    <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n}\n<ng-template #sideTemplate>\n    <!-- Side Content -->\n    <ng-content select=\"fd-dynamic-side-content-side\"></ng-content>\n</ng-template>\n", styles: [".fd-dynamic-side{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);display:-webkit-box;display:-ms-flexbox;display:flex;font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;width:100%}.fd-dynamic-side:after,.fd-dynamic-side:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-dynamic-side .fd-dynamic-side__main{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0;width:75%}.fd-dynamic-side .fd-dynamic-side__main:after,.fd-dynamic-side .fd-dynamic-side__main:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-dynamic-side .fd-dynamic-side__side{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0;-webkit-box-flex:1;-ms-flex:1 1 0px;flex:1 1 0}.fd-dynamic-side .fd-dynamic-side__side:after,.fd-dynamic-side .fd-dynamic-side__side:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-dynamic-side--sm .fd-dynamic-side__main{width:100%}.fd-dynamic-side--sm .fd-dynamic-side__side{display:none}.fd-dynamic-side--md .fd-dynamic-side__main{width:66.666%}.fd-dynamic-side--md .fd-dynamic-side__side{display:block}.fd-dynamic-side--xl .fd-dynamic-side__main{width:75%}.fd-dynamic-side--equal-split{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.fd-dynamic-side--equal-split .fd-dynamic-side__main,.fd-dynamic-side--equal-split .fd-dynamic-side__side{-webkit-box-flex:1;-ms-flex:1 1 50%;flex:1 1 50%;width:50%}.fd-dynamic-side--below{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.fd-dynamic-side--below .fd-dynamic-side__main{width:100%}.fd-dynamic-side--below .fd-dynamic-side__side{display:block;width:100%;-webkit-box-flex:0;-ms-flex:none;flex:none}\n/*! Bundled license information:\n\nfundamental-styles/dist/dynamic-side-content.css:\n  (*!\n   * Fundamental Library Styles v0.41.7\n   * Copyright (c) 2026 SAP SE or an SAP affiliate company.\n   * Licensed under Apache License 2.0 (https://github.com/SAP/fundamental-styles/blob/main/LICENSE)\n   *)\n*/\n"] }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }], propDecorators: { position: [{
                type: Input
            }], size: [{
                type: Input
            }], id: [{
                type: Input
            }, {
                type: HostBinding,
                args: ['attr.id']
            }], _children: [{
                type: ContentChildren,
                args: [DYNAMIC_SIDE_CONTENT_CHILD_TOKEN]
            }], buildComponentCssClass: [] } });

const components = [DynamicSideContentComponent, DynamicSideContentSideComponent, DynamicSideContentMainComponent];
/**
 * @deprecated
 */
class DynamicSideContentModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentModule, imports: [DynamicSideContentComponent, DynamicSideContentSideComponent, DynamicSideContentMainComponent], exports: [DynamicSideContentComponent, DynamicSideContentSideComponent, DynamicSideContentMainComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: DynamicSideContentModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [...components],
                    exports: [...components]
                }]
        }] });

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

export { DYNAMIC_SIDE_CONTENT_CHILD_TOKEN, DYNAMIC_SIDE_CONTENT_CLASS_NAME, DynamicSideContentComponent, DynamicSideContentMainComponent, DynamicSideContentModule, DynamicSideContentSideComponent };
//# sourceMappingURL=fundamental-ngx-core-dynamic-side-content.mjs.map
