import * as i0 from '@angular/core';
import { input, model, computed, signal, ChangeDetectionStrategy, ViewEncapsulation, Component, NgModule } from '@angular/core';
import { LineClampDirective, LineClampTargetDirective } from '@fundamental-ngx/cdk/utils';
import { LinkComponent } from '@fundamental-ngx/core/link';
import { FdTranslatePipe } from '@fundamental-ngx/i18n';

/**
 * Text component for displaying text content with optional line clamping, hyphenation, and expand/collapse functionality.
 */
class TextComponent {
    constructor() {
        /**
         * The text content to render.
         * @default ''
         */
        this.text = input('', ...(ngDevMode ? [{ debugName: "text" }] : []));
        /**
         * Maximum number of visible lines before text is clamped. Set to `null` to disable.
         * @default null
         */
        this.maxLines = input(null, ...(ngDevMode ? [{ debugName: "maxLines" }] : []));
        /**
         * Preserves whitespace and line breaks using CSS `white-space: pre-wrap`.
         * @default false
         */
        this.whitespaces = input(false, ...(ngDevMode ? [{ debugName: "whitespaces" }] : []));
        /**
         * Controls hyphenation behavior using CSS `hyphens` property.
         * @default null
         */
        this.hyphenation = input(null, ...(ngDevMode ? [{ debugName: "hyphenation" }] : []));
        /**
         * Displays "more"/"less" links to expand/collapse text. Requires `maxLines` to be set.
         * @default false
         */
        this.expandable = input(false, ...(ngDevMode ? [{ debugName: "expandable" }] : []));
        /**
         * Controls collapsed/expanded state. Two-way bindable via `[(isCollapsed)]`.
         * @default true
         */
        this.isCollapsed = model(true, ...(ngDevMode ? [{ debugName: "isCollapsed" }] : []));
        /**
         * Computed signal that checks if maxLines is set to a valid positive number.
         * @hidden
         */
        this._hasValidMaxLines = computed(() => (this.maxLines() ?? 0) > 0, ...(ngDevMode ? [{ debugName: "_hasValidMaxLines" }] : []));
        /**
         * Computed signal determining if text should display in collapsed state.
         * @hidden
         */
        this._isCollapsed = computed(() => this.isCollapsed() && this._hasValidMaxLines(), ...(ngDevMode ? [{ debugName: "_isCollapsed" }] : []));
        /**
         * Computed signal determining if expand/collapse functionality is enabled.
         * @hidden
         */
        this._expandable = computed(() => this.expandable() && this._hasValidMaxLines(), ...(ngDevMode ? [{ debugName: "_expandable" }] : []));
        /**
         * Tracks whether text content exceeds maximum lines.
         * @hidden
         */
        this._hasMore = signal(false, ...(ngDevMode ? [{ debugName: "_hasMore" }] : []));
    }
    /**
     * Toggles collapsed/expanded state and notifies parent components.
     * @hidden
     */
    toggleTextView() {
        this.isCollapsed.update((collapsed) => !collapsed);
    }
    /**
     * Updates `_hasMore` signal based on actual line count from line clamp directive.
     * Signal update automatically triggers change detection.
     * @hidden
     */
    checkLineCount(count) {
        const max = this.maxLines();
        this._hasMore.set(!!max && count > max);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TextComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.0", type: TextComponent, isStandalone: true, selector: "fd-text", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, maxLines: { classPropertyName: "maxLines", publicName: "maxLines", isSignal: true, isRequired: false, transformFunction: null }, whitespaces: { classPropertyName: "whitespaces", publicName: "whitespaces", isSignal: true, isRequired: false, transformFunction: null }, hyphenation: { classPropertyName: "hyphenation", publicName: "hyphenation", isSignal: true, isRequired: false, transformFunction: null }, expandable: { classPropertyName: "expandable", publicName: "expandable", isSignal: true, isRequired: false, transformFunction: null }, isCollapsed: { classPropertyName: "isCollapsed", publicName: "isCollapsed", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { isCollapsed: "isCollapsedChange" }, ngImport: i0, template: "<p class=\"fd-text\" [class.fd-text--pre-wrap]=\"whitespaces()\" [style.hyphens]=\"hyphenation()\">\n    <span\n        fdkLineClamp\n        class=\"fd-text__lineclamp\"\n        #lineClamp=\"fdLineClamp\"\n        [fdLineclampState]=\"_isCollapsed()\"\n        [fdLineClampLines]=\"maxLines()\"\n        (lineCountUpdate)=\"checkLineCount($event)\"\n    >\n        <span fdkLineClampTarget [fdLineClampTargetText]=\"text()\" (update)=\"lineClamp.refreshTarget($event)\"></span>\n    </span>\n    @if (_expandable() && _hasMore()) {\n        <a\n            fd-link\n            tabindex=\"0\"\n            class=\"fd-text__link--more\"\n            (keydown.enter)=\"toggleTextView()\"\n            (click)=\"toggleTextView()\"\n        >\n            {{ isCollapsed() ? ('coreText.moreLabel' | fdTranslate) : ('coreText.lessLabel' | fdTranslate) }}\n        </a>\n    }\n</p>\n", styles: [".fd-text{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}.fd-text:after,.fd-text:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-text::-moz-selection{background-color:var(--fdText_Selected_Background_Color);color:var(--sapContent_ContrastTextColor)}.fd-text::selection{background-color:var(--fdText_Selected_Background_Color);color:var(--sapContent_ContrastTextColor)}.fd-text--max-lines{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}.fd-text--pre-wrap{white-space:pre-wrap}.fd-text--hyphenation{-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.fd-text__link--more{cursor:pointer;text-transform:capitalize}.fd-text__ai-highlight{background-color:var(--sapInformationBackground);border-radius:.25rem;color:inherit;padding-inline:.125rem}.fd-text__ai-highlight.is-focus,.fd-text__ai-highlight.is-hover,.fd-text__ai-highlight:focus,.fd-text__ai-highlight:hover{-webkit-box-shadow:0 0 0 .0625rem var(--sapInformationBorderColor);box-shadow:0 0 0 .0625rem var(--sapInformationBorderColor)}.fd-text__ai-highlight.is-focus,.fd-text__ai-highlight:focus{z-index:5}.fd-text__ai-highlight.is-hidden{background-color:transparent}.fd-text__ai-highlight.is-hidden.is-hover,.fd-text__ai-highlight.is-hidden:hover{-webkit-box-shadow:none;box-shadow:none}.fd-text__ai-highlight.is-hidden.is-focus,.fd-text__ai-highlight.is-hidden:focus{-webkit-box-shadow:none;box-shadow:none;z-index:5}.fd-text__lineclamp{display:block}\n/*! Bundled license information:\n\nfundamental-styles/dist/text.css:\n  (*!\n   * Fundamental Library Styles v0.40.1\n   * Copyright (c) 2025 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: LineClampDirective, selector: "[fdkLineClamp]", inputs: ["fdLineClampLines", "fdLineclampState"], outputs: ["lineCountUpdate"], exportAs: ["fdLineClamp"] }, { kind: "directive", type: LineClampTargetDirective, selector: "[fdkLineClampTarget], [fdLineClampTarget], [fd-lineclamp-target]", inputs: ["fdLineClampTargetText"], outputs: ["update"], exportAs: ["fdLineClampTarget"] }, { kind: "component", type: LinkComponent, selector: "[fdLink], [fd-link]", inputs: ["emphasized", "disabled", "inverted", "subtle", "undecorated", "touchTarget"] }, { kind: "pipe", type: FdTranslatePipe, name: "fdTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TextComponent, decorators: [{
            type: Component,
            args: [{ selector: 'fd-text', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, imports: [LineClampDirective, LineClampTargetDirective, LinkComponent, FdTranslatePipe], template: "<p class=\"fd-text\" [class.fd-text--pre-wrap]=\"whitespaces()\" [style.hyphens]=\"hyphenation()\">\n    <span\n        fdkLineClamp\n        class=\"fd-text__lineclamp\"\n        #lineClamp=\"fdLineClamp\"\n        [fdLineclampState]=\"_isCollapsed()\"\n        [fdLineClampLines]=\"maxLines()\"\n        (lineCountUpdate)=\"checkLineCount($event)\"\n    >\n        <span fdkLineClampTarget [fdLineClampTargetText]=\"text()\" (update)=\"lineClamp.refreshTarget($event)\"></span>\n    </span>\n    @if (_expandable() && _hasMore()) {\n        <a\n            fd-link\n            tabindex=\"0\"\n            class=\"fd-text__link--more\"\n            (keydown.enter)=\"toggleTextView()\"\n            (click)=\"toggleTextView()\"\n        >\n            {{ isCollapsed() ? ('coreText.moreLabel' | fdTranslate) : ('coreText.lessLabel' | fdTranslate) }}\n        </a>\n    }\n</p>\n", styles: [".fd-text{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}.fd-text:after,.fd-text:before{-webkit-box-sizing:inherit;box-sizing:inherit;font-size:inherit}.fd-text::-moz-selection{background-color:var(--fdText_Selected_Background_Color);color:var(--sapContent_ContrastTextColor)}.fd-text::selection{background-color:var(--fdText_Selected_Background_Color);color:var(--sapContent_ContrastTextColor)}.fd-text--max-lines{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}.fd-text--pre-wrap{white-space:pre-wrap}.fd-text--hyphenation{-ms-hyphens:auto;-webkit-hyphens:auto;hyphens:auto}.fd-text__link--more{cursor:pointer;text-transform:capitalize}.fd-text__ai-highlight{background-color:var(--sapInformationBackground);border-radius:.25rem;color:inherit;padding-inline:.125rem}.fd-text__ai-highlight.is-focus,.fd-text__ai-highlight.is-hover,.fd-text__ai-highlight:focus,.fd-text__ai-highlight:hover{-webkit-box-shadow:0 0 0 .0625rem var(--sapInformationBorderColor);box-shadow:0 0 0 .0625rem var(--sapInformationBorderColor)}.fd-text__ai-highlight.is-focus,.fd-text__ai-highlight:focus{z-index:5}.fd-text__ai-highlight.is-hidden{background-color:transparent}.fd-text__ai-highlight.is-hidden.is-hover,.fd-text__ai-highlight.is-hidden:hover{-webkit-box-shadow:none;box-shadow:none}.fd-text__ai-highlight.is-hidden.is-focus,.fd-text__ai-highlight.is-hidden:focus{-webkit-box-shadow:none;box-shadow:none;z-index:5}.fd-text__lineclamp{display:block}\n/*! Bundled license information:\n\nfundamental-styles/dist/text.css:\n  (*!\n   * Fundamental Library Styles v0.40.1\n   * Copyright (c) 2025 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: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], maxLines: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxLines", required: false }] }], whitespaces: [{ type: i0.Input, args: [{ isSignal: true, alias: "whitespaces", required: false }] }], hyphenation: [{ type: i0.Input, args: [{ isSignal: true, alias: "hyphenation", required: false }] }], expandable: [{ type: i0.Input, args: [{ isSignal: true, alias: "expandable", required: false }] }], isCollapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "isCollapsed", required: false }] }, { type: i0.Output, args: ["isCollapsedChange"] }] } });

/**
 * @deprecated Use the standalone `TextComponent` directly instead. Import `TextComponent` in your component's imports array.
 * This module will be removed in a future version.
 */
class TextModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: TextModule, imports: [TextComponent], exports: [TextComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TextModule, imports: [TextComponent] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: TextModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [TextComponent],
                    exports: [TextComponent]
                }]
        }] });

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

export { TextComponent, TextModule };
//# sourceMappingURL=fundamental-ngx-core-text.mjs.map
