import { __decorate, __metadata } from 'tslib';
import * as i0 from '@angular/core';
import { Input, Directive, HostBinding, EventEmitter, inject, ElementRef, Renderer2, HostListener, Output, input, ContentChild, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
import { applyCssClass } from '@fundamental-ngx/cdk/utils';
import { Subscription } from 'rxjs';

/**
 * Applies a thumb styles
 */
class FeedInputAvatarDirective {
    /** @hidden */
    constructor(elementRef) {
        this.elementRef = elementRef;
    }
    /** @hidden */
    buildComponentCssClass() {
        return ['fd-feed-input__thumb', this.placeholder ? `fd-avatar--placeholder` : '', this.class];
    }
    /** @hidden */
    ngOnInit() {
        this.buildComponentCssClass();
    }
    /** @hidden */
    ngOnChanges() {
        this.buildComponentCssClass();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputAvatarDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: FeedInputAvatarDirective, isStandalone: true, selector: "[fdFeedInputAvatar]", inputs: { class: "class", placeholder: "placeholder" }, usesOnChanges: true, ngImport: i0 }); }
}
__decorate([
    applyCssClass,
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", Array)
], FeedInputAvatarDirective.prototype, "buildComponentCssClass", null);
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputAvatarDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[fdFeedInputAvatar]',
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { class: [{
                type: Input
            }], placeholder: [{
                type: Input
            }], buildComponentCssClass: [] } });

/**
 * Applies button feed arrow icon and disabled state
 */
class FeedInputButtonDirective {
    /** @hidden */
    constructor(_elementRef, _renderer) {
        this._elementRef = _elementRef;
        this._renderer = _renderer;
        /** @hidden */
        this.disabled = true;
    }
    /** @hidden */
    ngOnInit() {
        this.createArrowIcon();
    }
    /** @hidden */
    get elementRef() {
        return this._elementRef;
    }
    /** @hidden create button icon */
    createArrowIcon() {
        const icon = this._renderer.createElement('i');
        this._renderer.addClass(icon, 'sap-icon--feeder-arrow');
        this._renderer.setAttribute(icon, 'role', 'presentation');
        this._renderer.appendChild(this.elementRef.nativeElement, icon);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputButtonDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: FeedInputButtonDirective, isStandalone: true, selector: "[fdFeedInputButton]", host: { properties: { "attr.aria-disabled": "this.disabled", "class.is-disabled": "this.disabled" }, classAttribute: "fd-button fd-feed-input__submit-button is-cozy" }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputButtonDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[fdFeedInputButton]',
                    host: {
                        class: 'fd-button fd-feed-input__submit-button is-cozy'
                    },
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], propDecorators: { disabled: [{
                type: HostBinding,
                args: ['attr.aria-disabled']
            }, {
                type: HostBinding,
                args: ['class.is-disabled']
            }] } });

/**
 * Applies text area auto resize and set maximum rows to grow
 */
class FeedInputTextareaDirective {
    constructor() {
        /** Event emitted when the textarea value changed */
        this.valueChange = new EventEmitter();
        /** @hidden */
        this.elementRef = inject(ElementRef);
        /** @hidden */
        this._renderer = inject(Renderer2);
    }
    /** @hidden */
    onKeyup() {
        this.resize();
        this.valueChange.emit(this.elementRef.nativeElement.value);
    }
    /** @hidden */
    ngOnInit() {
        if (this.fdFeedInputTextareaMaxRows) {
            const lineHeight = this._getTextareaLineHeight();
            this.elementRef.nativeElement.style.maxHeight = lineHeight * this.fdFeedInputTextareaMaxRows + 'px';
        }
    }
    /** @hidden make to grow textarea */
    resize() {
        this._renderer.setStyle(this.elementRef.nativeElement, 'height', 'inherit');
        const totalHeight = this._getTextareaTotalHeight();
        this._renderer.setStyle(this.elementRef.nativeElement, 'height', `${totalHeight}px`);
    }
    /** @hidden get line height of textarea */
    _getTextareaLineHeight() {
        const lineHeight = window.getComputedStyle(this.elementRef.nativeElement).getPropertyValue('line-height');
        if (lineHeight === 'normal') {
            return (parseInt(window.getComputedStyle(this.elementRef.nativeElement).getPropertyValue('font-size'), 10) * 1.1);
        }
        return parseInt(lineHeight, 10);
    }
    /** @hidden get the total height including borders and scroll height */
    _getTextareaTotalHeight() {
        const computed = window.getComputedStyle(this.elementRef.nativeElement);
        return (parseInt(computed.getPropertyValue('border-top-width'), 10) +
            this.elementRef.nativeElement.scrollHeight +
            parseInt(computed.getPropertyValue('border-bottom-width'), 10));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputTextareaDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
    static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: FeedInputTextareaDirective, isStandalone: true, selector: "textarea[fdFeedInputTextarea]", inputs: { fdFeedInputTextareaMaxRows: "fdFeedInputTextareaMaxRows" }, outputs: { valueChange: "valueChange" }, host: { listeners: { "keyup": "onKeyup()" }, properties: { "class.fd-feed-input__textarea": "true", "class.fd-textarea": "true", "disabled": "this.disabled" } }, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputTextareaDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'textarea[fdFeedInputTextarea]',
                    host: {
                        '[class.fd-feed-input__textarea]': 'true',
                        '[class.fd-textarea]': 'true'
                    },
                    standalone: true
                }]
        }], propDecorators: { fdFeedInputTextareaMaxRows: [{
                type: Input
            }], disabled: [{
                type: HostBinding,
                args: ['disabled']
            }], valueChange: [{
                type: Output
            }], onKeyup: [{
                type: HostListener,
                args: ['keyup']
            }] } });

class FeedInputComponent {
    constructor() {
        /** Component disable state */
        this.disabled = false;
        /** Value for aria label */
        this.ariaLabel = input(...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : []));
        /** @hidden */
        this._subscriptions = new Subscription();
    }
    /** @hidden */
    ngAfterContentInit() {
        if (this.disabled) {
            this.textareaElement.disabled = true;
        }
        this._subscriptions.add(this.textareaElement.valueChange.subscribe((value) => (this.buttonElement.disabled = !value)));
    }
    /** @hidden */
    ngOnDestroy() {
        this._subscriptions.unsubscribe();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.1.0", type: FeedInputComponent, isStandalone: true, selector: "fd-feed-input", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: false, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, queries: [{ propertyName: "textareaElement", first: true, predicate: i0.forwardRef(() => FeedInputTextareaDirective), descendants: true }, { propertyName: "buttonElement", first: true, predicate: i0.forwardRef(() => FeedInputButtonDirective), descendants: true }], ngImport: i0, template: "<div class=\"fd-feed-input\" role=\"group\" [attr.aria-label]=\"ariaLabel()\" [class.is-disabled]=\"disabled\">\n    <div class=\"fd-feed-input__container\">\n        <ng-content></ng-content>\n    </div>\n</div>\n", styles: [".fd-feed-input{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);container-name:feed-input;container-type:inline-size;font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;height:100%;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0}.fd-feed-input:after,.fd-feed-input:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-feed-input.is-disabled,.fd-feed-input:disabled,.fd-feed-input[aria-disabled=true]{cursor:not-allowed;opacity:1;pointer-events:auto}.fd-feed-input.is-disabled textarea::-webkit-input-placeholder,.fd-feed-input:disabled textarea::-webkit-input-placeholder,.fd-feed-input[aria-disabled=true] textarea::-webkit-input-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea::-moz-placeholder,.fd-feed-input:disabled textarea::-moz-placeholder,.fd-feed-input[aria-disabled=true] textarea::-moz-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea:-ms-input-placeholder,.fd-feed-input:disabled textarea:-ms-input-placeholder,.fd-feed-input[aria-disabled=true] textarea:-ms-input-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea::-ms-input-placeholder,.fd-feed-input:disabled textarea::-ms-input-placeholder,.fd-feed-input[aria-disabled=true] textarea::-ms-input-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea::placeholder,.fd-feed-input:disabled textarea::placeholder,.fd-feed-input[aria-disabled=true] textarea::placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input .fd-feed-input__container{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;background-color:var(--sapGroup_ContentBackground);-ms-flex-direction:row;flex-direction:row;gap:.5rem;margin-block:1rem;padding-block:1rem;padding-inline:1rem .5rem}.fd-feed-input .fd-feed-input__container:after,.fd-feed-input .fd-feed-input__container:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-feed-input .fd-feed-input__textarea{margin-block:0;margin-inline:0;max-height:20rem;min-height:3rem;padding-block:.375rem;padding-inline:.5rem}.fd-feed-input .fd-feed-input__submit-button{margin-block:.375rem;-ms-flex-item-align:end;align-self:flex-end}.fd-feed-input .fd-feed-input__submit-button[dir=rtl],[dir=rtl] .fd-feed-input .fd-feed-input__submit-button{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fd-feed-input .fd-feed-input__submit-button[class*=-compact],.fd-feed-input .fd-feed-input__submit-button[class*=-condensed],[class*=-compact] .fd-feed-input .fd-feed-input__submit-button:not([class*=-cozy]),[class*=-condensed] .fd-feed-input .fd-feed-input__submit-button:not([class*=-cozy]){--fdButton_Compact_Height:var(--sapElement_Height);--fdButton_Clickable_Height:2.75rem;--fdButton_Padding_X:.625rem;--fdButton_Min_Width:2.25rem;--fdButton_Badge_Margin_Inline_Start:0;--fdButton_Badge_Size_Attention:.75rem}@container feed-input (max-width: 20rem){.fd-feed-input .fd-feed-input__container{margin-block:0}.fd-feed-input .fd-feed-input__thumb{display:none}}\n/*! Bundled license information:\n\nfundamental-styles/dist/feed-input.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"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fd-feed-input', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, template: "<div class=\"fd-feed-input\" role=\"group\" [attr.aria-label]=\"ariaLabel()\" [class.is-disabled]=\"disabled\">\n    <div class=\"fd-feed-input__container\">\n        <ng-content></ng-content>\n    </div>\n</div>\n", styles: [".fd-feed-input{border:0;-webkit-box-sizing:border-box;box-sizing:border-box;color:var(--sapTextColor);container-name:feed-input;container-type:inline-size;font-family:var(--sapFontFamily);font-size:var(--sapFontSize);font-weight:400;forced-color-adjust:none;height:100%;line-height:normal;margin-block:0;margin-inline:0;padding-block:0;padding-inline:0}.fd-feed-input:after,.fd-feed-input:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-feed-input.is-disabled,.fd-feed-input:disabled,.fd-feed-input[aria-disabled=true]{cursor:not-allowed;opacity:1;pointer-events:auto}.fd-feed-input.is-disabled textarea::-webkit-input-placeholder,.fd-feed-input:disabled textarea::-webkit-input-placeholder,.fd-feed-input[aria-disabled=true] textarea::-webkit-input-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea::-moz-placeholder,.fd-feed-input:disabled textarea::-moz-placeholder,.fd-feed-input[aria-disabled=true] textarea::-moz-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea:-ms-input-placeholder,.fd-feed-input:disabled textarea:-ms-input-placeholder,.fd-feed-input[aria-disabled=true] textarea:-ms-input-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea::-ms-input-placeholder,.fd-feed-input:disabled textarea::-ms-input-placeholder,.fd-feed-input[aria-disabled=true] textarea::-ms-input-placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input.is-disabled textarea::placeholder,.fd-feed-input:disabled textarea::placeholder,.fd-feed-input[aria-disabled=true] textarea::placeholder{color:var(--sapTextColor,#32363a);font-style:var(--fdFeed_Input_Placeholder_Font_Style)}.fd-feed-input .fd-feed-input__container{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;background-color:var(--sapGroup_ContentBackground);-ms-flex-direction:row;flex-direction:row;gap:.5rem;margin-block:1rem;padding-block:1rem;padding-inline:1rem .5rem}.fd-feed-input .fd-feed-input__container:after,.fd-feed-input .fd-feed-input__container:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-feed-input .fd-feed-input__textarea{margin-block:0;margin-inline:0;max-height:20rem;min-height:3rem;padding-block:.375rem;padding-inline:.5rem}.fd-feed-input .fd-feed-input__submit-button{margin-block:.375rem;-ms-flex-item-align:end;align-self:flex-end}.fd-feed-input .fd-feed-input__submit-button[dir=rtl],[dir=rtl] .fd-feed-input .fd-feed-input__submit-button{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.fd-feed-input .fd-feed-input__submit-button[class*=-compact],.fd-feed-input .fd-feed-input__submit-button[class*=-condensed],[class*=-compact] .fd-feed-input .fd-feed-input__submit-button:not([class*=-cozy]),[class*=-condensed] .fd-feed-input .fd-feed-input__submit-button:not([class*=-cozy]){--fdButton_Compact_Height:var(--sapElement_Height);--fdButton_Clickable_Height:2.75rem;--fdButton_Padding_X:.625rem;--fdButton_Min_Width:2.25rem;--fdButton_Badge_Margin_Inline_Start:0;--fdButton_Badge_Size_Attention:.75rem}@container feed-input (max-width: 20rem){.fd-feed-input .fd-feed-input__container{margin-block:0}.fd-feed-input .fd-feed-input__thumb{display:none}}\n/*! Bundled license information:\n\nfundamental-styles/dist/feed-input.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"] }]
        }], propDecorators: { disabled: [{
                type: Input
            }], textareaElement: [{
                type: ContentChild,
                args: [forwardRef(() => FeedInputTextareaDirective)]
            }], buttonElement: [{
                type: ContentChild,
                args: [forwardRef(() => FeedInputButtonDirective)]
            }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }] } });

const components = [FeedInputComponent, FeedInputTextareaDirective, FeedInputButtonDirective, FeedInputAvatarDirective];
/**
 * @deprecated
 * Use direct imports of components and directives.
 */
class FeedInputModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: FeedInputModule, imports: [FeedInputComponent, FeedInputTextareaDirective, FeedInputButtonDirective, FeedInputAvatarDirective], exports: [FeedInputComponent, FeedInputTextareaDirective, FeedInputButtonDirective, FeedInputAvatarDirective] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: FeedInputModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [...components],
                    exports: [...components]
                }]
        }] });

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

export { FeedInputAvatarDirective, FeedInputButtonDirective, FeedInputComponent, FeedInputModule, FeedInputTextareaDirective };
//# sourceMappingURL=fundamental-ngx-core-feed-input.mjs.map
